From df0e469fdcf0e0b3ef74bac6500e5751c40b4ec1 Mon Sep 17 00:00:00 2001 From: Apple Date: Fri, 24 Oct 2003 23:30:25 +0000 Subject: [PATCH] Security-163.tar.gz --- AppleCSP/AES/aescsp.cpp | 2 +- AppleCSP/AES/gladmanContext.cpp | 2 +- AppleCSP/AES/rijndael-alg-ref.c | 5 + AppleCSP/AES/rijndaelApi.c | 6 +- AppleCSP/AppleCSP/AppleCSP.cpp | 143 +- AppleCSP/AppleCSP/AppleCSPContext.cpp | 32 +- AppleCSP/AppleCSP/AppleCSPKeys.cpp | 89 + AppleCSP/AppleCSP/AppleCSPKeys.h | 118 + AppleCSP/AppleCSP/AppleCSPSession.h | 56 +- AppleCSP/AppleCSP/AppleCSPUtils.cpp | 119 + AppleCSP/AppleCSP/AppleCSPUtils.h | 10 + AppleCSP/AppleCSP/BinaryKey.h | 32 +- AppleCSP/AppleCSP/BlockCryptor.cpp | 8 +- AppleCSP/AppleCSP/SignatureContext.cpp | 2 +- AppleCSP/AppleCSP/deriveKey.cpp | 17 +- AppleCSP/AppleCSP/pkcs8.cpp | 112 + .../policy.h => AppleCSP/AppleCSP/pkcs8.h | 41 +- AppleCSP/AppleCSP/pkcs_7_8.cpp | 324 - AppleCSP/AppleCSP/pkcs_7_8.h | 81 - AppleCSP/AppleCSP/wrapKey.cpp | 219 +- AppleCSP/AppleCSP/wrapKeyCms.cpp | 6 +- AppleCSP/BSafeCSP/bsafeKeyGen.cpp | 19 +- AppleCSP/BSafeCSP/bsafeSymmetric.cpp | 2 +- AppleCSP/BSafeCSP/bsafecspi.h | 13 +- AppleCSP/CVSVersionInfo.txt | 2 +- AppleCSP/ComCryption/ascContext.cpp | 4 +- AppleCSP/CryptKit/.cvsignore | 2 - AppleCSP/CryptKit/ByteRep.txt | 293 - AppleCSP/CryptKitCSP/CryptKitAsn1.cpp | 81 + AppleCSP/CryptKitCSP/CryptKitAsn1.h | 133 + AppleCSP/CryptKitCSP/CryptKitDER.cpp | 493 +- AppleCSP/CryptKitCSP/FEECSPUtils.cpp | 3 +- AppleCSP/CryptKitCSP/FEEKeys.cpp | 80 +- AppleCSP/CryptKitCSP/FEEKeys.h | 20 +- AppleCSP/CryptKitCSP/FEESignatureObject.cpp | 2 +- AppleCSP/DiffieHellman/DH_exchange.cpp | 76 +- AppleCSP/DiffieHellman/DH_keys.cpp | 349 +- AppleCSP/DiffieHellman/DH_keys.h | 46 +- AppleCSP/DiffieHellman/DH_utils.cpp | 86 +- AppleCSP/DiffieHellman/DH_utils.h | 6 +- AppleCSP/MiscCSPAlgs/MD5.c | 35 +- AppleCSP/MiscCSPAlgs/MD5.h | 1 + AppleCSP/MiscCSPAlgs/SHA1.h | 3 + AppleCSP/MiscCSPAlgs/SHA1_priv.c | 6 +- AppleCSP/MiscCSPAlgs/bfContext.cpp | 119 + AppleCSP/MiscCSPAlgs/bfContext.h | 80 + AppleCSP/MiscCSPAlgs/castContext.cpp | 120 + AppleCSP/MiscCSPAlgs/castContext.h | 93 + AppleCSP/MiscCSPAlgs/desContext.cpp | 4 +- AppleCSP/MiscCSPAlgs/miscAlgFactory.cpp | 34 + AppleCSP/MiscCSPAlgs/pkcs12Derive.cpp | 430 + AppleCSP/MiscCSPAlgs/pkcs12Derive.h | 47 + AppleCSP/MiscCSPAlgs/rc4Context.cpp | 4 +- AppleCSP/PBKDF2/HMACSHA1.c | 68 +- AppleCSP/PBKDF2/HMACSHA1.h | 10 +- AppleCSP/PBKDF2/pbkdDigest.cpp | 82 + AppleCSP/PBKDF2/pbkdDigest.h | 67 + AppleCSP/PBKDF2/pbkdf2.c | 9 +- AppleCSP/RSA_DSA/RSA_DSA_keys.cpp | 291 +- AppleCSP/RSA_DSA/RSA_DSA_keys.h | 44 +- AppleCSP/RSA_DSA/RSA_DSA_signature.cpp | 19 +- AppleCSP/RSA_DSA/RSA_DSA_utils.cpp | 220 +- AppleCSP/RSA_DSA/RSA_DSA_utils.h | 22 +- AppleCSP/RSA_DSA/RSA_asymmetric.cpp | 20 +- AppleCSP/open_ssl/LICENSE | 60 + AppleCSP/open_ssl/bf/COPYRIGHT | 46 + AppleCSP/open_ssl/bf/README | 8 + AppleCSP/open_ssl/bf/bf_ecb.c | 96 + AppleCSP/open_ssl/bf/bf_enc.c | 306 + AppleCSP/open_ssl/bf/bf_locl.h | 232 + AppleCSP/open_ssl/bf/bf_pi.h | 325 + AppleCSP/open_ssl/bf/bf_skey.c | 116 + AppleCSP/open_ssl/bn/bn_lib.c | 6 +- AppleCSP/open_ssl/cast/c_ecb.c | 80 + AppleCSP/open_ssl/cast/c_enc.c | 210 + AppleCSP/open_ssl/cast/c_skey.c | 166 + AppleCSP/open_ssl/cast/cast_lcl.h | 239 + AppleCSP/open_ssl/cast/cast_s.h | 585 + AppleCSP/open_ssl/openssl/blowfish.h | 129 + AppleCSP/open_ssl/openssl/cast.h | 103 + AppleCSP/open_ssl/openssl/opensslconf.h | 8 +- .../open_ssl/opensslUtils/openRsaSnacc.cpp | 755 - AppleCSP/open_ssl/opensslUtils/openRsaSnacc.h | 121 - .../open_ssl/opensslUtils/opensslAsn1.cpp | 1686 ++ AppleCSP/open_ssl/opensslUtils/opensslAsn1.h | 156 + .../open_ssl/opensslUtils/opensslUtils.cpp | 6 +- .../open_ssl/opensslUtils/osKeyTemplates.cpp | 140 + .../open_ssl/opensslUtils/osKeyTemplates.h | 187 + AppleCSP/open_ssl/rsa/rsa_gen.c | 3 +- AppleCSPDL/CVSVersionInfo.txt | 2 +- AppleCSPDL/SSCSPSession.cpp | 101 +- AppleCSPDL/SSCSPSession.h | 3 +- AppleCSPDL/SSContext.cpp | 17 +- AppleCSPDL/SSDLSession.cpp | 13 +- AppleCSPDL/SSDatabase.cpp | 36 +- AppleCSPDL/SSDatabase.h | 6 +- AppleDL/CVSVersionInfo.txt | 2 +- AppleX509CL/AppleX509CL.mcp | Bin 103293 -> 0 bytes AppleX509CL/AppleX509CLSession.cpp | 4 +- AppleX509CL/AppleX509CLSession.h | 4 +- AppleX509CL/CLCachedEntry.h | 13 +- AppleX509CL/CLCertExtensions.cpp | 1212 +- AppleX509CL/CLCertExtensions.h | 34 +- AppleX509CL/CLCrlExtensions.cpp | 143 + .../tcl-p.c => AppleX509CL/CLCrlExtensions.h | 49 +- AppleX509CL/CLFieldsCommon.cpp | 479 + AppleX509CL/CLFieldsCommon.h | 147 + AppleX509CL/CSPAttacher.cpp | 4 +- AppleX509CL/CVSVersionInfo.txt | 2 +- AppleX509CL/CertBuilder.cpp | 190 - AppleX509CL/CertBuilder.h | 85 - AppleX509CL/CertFields.cpp | 882 +- AppleX509CL/CrlFields.cpp | 725 + AppleX509CL/DecodedCert.cpp | 186 +- AppleX509CL/DecodedCert.h | 134 +- AppleX509CL/DecodedCrl.cpp | 115 + AppleX509CL/DecodedCrl.h | 107 + AppleX509CL/DecodedExtensions.cpp | 462 + AppleX509CL/DecodedExtensions.h | 156 + AppleX509CL/DecodedItem.cpp | 99 + AppleX509CL/DecodedItem.h | 231 + AppleX509CL/Session_CRL.cpp | 260 +- AppleX509CL/Session_CSR.cpp | 185 +- AppleX509CL/Session_Cert.cpp | 49 +- AppleX509CL/Session_Crypto.cpp | 86 +- AppleX509CL/SnaccUtils.cpp | 934 - AppleX509CL/SnaccUtils.h | 144 - AppleX509CL/clNameUtils.cpp | 741 + AppleX509CL/clNameUtils.h | 121 + AppleX509CL/clNssUtils.cpp | 997 + AppleX509CL/clNssUtils.h | 203 + AppleX509CL/cldebugging.c | 91 - AppleX509CL/cldebugging.h | 131 +- AppleX509TP/AppleTPSession.cpp | 120 +- AppleX509TP/AppleTPSession.h | 41 +- AppleX509TP/CVSVersionInfo.txt | 2 +- AppleX509TP/TPCertInfo.cpp | 1281 +- AppleX509TP/TPCertInfo.h | 410 +- AppleX509TP/TPCrlInfo.cpp | 723 + AppleX509TP/TPCrlInfo.h | 229 + AppleX509TP/TPDatabase.cpp | 706 + AppleX509TP/TPDatabase.h | 70 + AppleX509TP/TPNetwork.cpp | 534 + AppleX509TP/TPNetwork.h | 64 + AppleX509TP/certGroupUtils.cpp | 562 +- AppleX509TP/certGroupUtils.h | 57 +- AppleX509TP/rootCerts.cpp | 165 +- AppleX509TP/rootCerts.h | 36 +- AppleX509TP/tpCertGroup.cpp | 823 +- AppleX509TP/tpCredRequest.cpp | 21 +- AppleX509TP/tpCrlVerify.cpp | 350 + AppleX509TP/tpCrlVerify.h | 140 + AppleX509TP/tpPolicies.cpp | 827 +- AppleX509TP/tpPolicies.h | 21 +- AppleX509TP/tpTime.c | 106 +- AppleX509TP/tpTime.h | 18 +- AppleX509TP/tpdebugging.c | 83 - AppleX509TP/tpdebugging.h | 128 +- .../cdsaUtils.c => CdsaUtils/cuCdsaUtils.cpp | 294 +- CdsaUtils/cuCdsaUtils.h | 151 + CdsaUtils/cuDbUtils.cpp | 559 + CdsaUtils/cuDbUtils.h | 71 + {CertTool/cdsaUtils => CdsaUtils}/cuEnc64.c | 56 +- CdsaUtils/cuEnc64.h | 67 + CdsaUtils/cuFileIo.c | 113 + CdsaUtils/cuFileIo.h | 41 + .../cuOidParser.cpp | 26 +- CdsaUtils/cuOidParser.h | 62 + CdsaUtils/cuPem.cpp | 198 + CdsaUtils/cuPem.h | 50 + .../cuPrintCert.cpp | 748 +- CdsaUtils/cuPrintCert.h | 64 + CdsaUtils/cuTimeStr.cpp | 283 + CdsaUtils/cuTimeStr.h | 74 + CertTool/CertTool.cpp | 1581 ++ CertTool/CertTool.html | 340 +- CertTool/CertTool/CertTool.cpp | 1233 -- CertTool/CertTool/CertUI.h | 137 - CertTool/{CertTool => }/CertUI.cpp | 75 +- CertTool/CertUI.h | 112 + CertTool/cdsaUtils/cuEnc64.h | 65 - CertTool/cdsaUtils/fileIo.c | 141 - CertTool/cdsaUtils/fileIo.h | 69 - CertTool/cdsaUtils/oidParser.h | 44 - CertTool/cdsaUtils/pem.cpp | 170 - CertTool/cdsaUtils/pem.h | 72 - CertTool/cdsaUtils/printCert.h | 32 - CertTool/cdsaUtils/timeStr.cpp | 144 - CertTool/cdsaUtils/timeStr.h | 27 - CertTool/certtool.1 | 436 + CertTool/{cdsaUtils => }/dumpasn1.cfg | 16 +- CrlRefresh/crlRefresh.cpp | 1202 ++ CrlRefresh/ldapFetch.cpp | 272 + CrlRefresh/ldapFetch.h | 50 + Documentation/AppleTP_Spec.doc | Bin 283136 -> 51200 bytes Documentation/C++Utilities.cwk | Bin 97493 -> 132909 bytes Documentation/DebuggingAids.cwk | Bin 37201 -> 62061 bytes Keychain/ACL.cpp | 76 +- Keychain/ACL.h | 21 +- Keychain/Access.cpp | 61 +- Keychain/Access.h | 10 +- Keychain/CCallbackMgr.cp | 64 +- Keychain/CCallbackMgr.h | 9 +- Keychain/Certificate.cpp | 572 +- Keychain/Certificate.h | 46 +- Keychain/CertificateRequest.cpp | 2 +- Keychain/CertificateRequest.h | 5 +- Keychain/DLDBListCFPref.cpp | 680 +- Keychain/DLDBListCFPref.h | 78 +- Keychain/DefaultKeychain.cpp | 97 - Keychain/DefaultKeychain.h | 78 - Keychain/ExecCLITool.cpp | 313 + Keychain/ExecCLITool.h | 93 + Keychain/FileVaultSPI.cpp | 148 + Keychain/FileVaultSPI.h | 152 + Keychain/Globals.h | 5 +- Keychain/Identity.cpp | 28 +- Keychain/Identity.h | 17 +- Keychain/IdentityCursor.cpp | 6 +- Keychain/IdentityCursor.h | 10 +- Keychain/Item.cpp | 59 +- Keychain/Item.h | 9 +- Keychain/KCCursor.cpp | 24 +- Keychain/KCCursor.h | 13 +- Keychain/KCEventNotifier.cpp | 40 +- Keychain/KCEventNotifier.h | 7 +- Keychain/KCEventObserver.cpp | 56 +- Keychain/KCEventObserver.h | 37 +- Keychain/KeyItem.cpp | 336 +- Keychain/KeyItem.h | 38 +- Keychain/Keychains.cpp | 122 +- Keychain/Keychains.h | 11 +- Keychain/Policies.cpp | 2 +- Keychain/Policies.h | 6 +- Keychain/PolicyCursor.cpp | 8 +- Keychain/PolicyCursor.h | 8 +- Keychain/Refs.h | 127 - Keychain/SFFileVault.cpp | 408 + Keychain/SFFileVault.h | 60 + Keychain/Schema.h | 15 + Keychain/Schema.m4 | 15 +- Keychain/SecACL.cpp | 39 +- Keychain/SecAccess.cpp | 20 +- Keychain/SecAccessPriv.h | 56 + Keychain/SecBase.h | 84 +- Keychain/SecCFTypes.cpp | 103 +- Keychain/SecCFTypes.h | 123 +- Keychain/SecCertificate.cpp | 180 +- Keychain/SecCertificate.h | 1 + Keychain/SecCertificatePriv.h | 91 + Keychain/SecCertificateRequest.cpp | 2 +- Keychain/SecFileVaultCert.cpp | 564 + Keychain/SecFileVaultCert.h | 147 + Keychain/SecIdentity.cpp | 30 +- .../policy.h => Keychain/SecIdentityPriv.h | 35 +- Keychain/SecIdentitySearch.cpp | 14 +- Keychain/SecKey.cpp | 110 +- Keychain/SecKeyPriv.h | 43 + Keychain/SecKeychain.cpp | 287 +- Keychain/SecKeychain.h | 212 +- Keychain/SecKeychainAPI.cpp | 12 + Keychain/SecKeychainAPI.h | 2 + Keychain/SecKeychainAPIPriv.h | 54 + Keychain/SecKeychainAddIToolsPassword.c | 195 + Keychain/SecKeychainItem.cpp | 95 +- Keychain/SecKeychainItem.h | 30 +- Keychain/SecKeychainSearch.cpp | 14 +- Keychain/SecPolicy.cpp | 24 +- Keychain/SecPolicyPriv.h | 48 + Keychain/SecPolicySearch.cpp | 14 +- Keychain/SecRuntime.cpp | 134 +- Keychain/SecRuntime.h | 187 +- Keychain/SecTrust.cpp | 63 +- Keychain/SecTrust.h | 3 +- Keychain/SecTrustPriv.h | 58 + Keychain/SecTrustedApplication.cpp | 92 +- Keychain/SecTrustedApplicationPriv.h | 77 + Keychain/Security.h | 2 + Keychain/StorageManager.cpp | 977 +- Keychain/StorageManager.h | 60 +- Keychain/Trust.cpp | 127 +- Keychain/Trust.h | 17 +- Keychain/TrustItem.cpp | 74 +- Keychain/TrustItem.h | 9 +- Keychain/TrustStore.cpp | 41 +- Keychain/TrustedApplication.cpp | 55 +- Keychain/TrustedApplication.h | 28 +- Keychain/generateErrStrings.pl | 83 + Keychain/iToolsTrustedApps.plist | 12 + Keychain/srCdsaUtils.cpp | 553 + .../cdsaUtils.h => Keychain/srCdsaUtils.h | 77 +- Network/connectionpool.cpp | 8 +- Network/connectionpool.h | 2 +- Network/ftp-protocol.cpp | 10 +- Network/ftp-proxy-protocol.cpp | 2 +- Network/http-protocol.cpp | 6 +- Network/http-proxy-protocol.cpp | 2 +- Network/multiobserver.h | 2 +- Network/netconnection.cpp | 10 +- Network/netconnection.h | 2 +- Network/neterror.h | 2 +- Network/netmanager.cpp | 28 +- Network/netmanager.h | 2 +- Network/networkchooser.h | 2 +- Network/observer.h | 2 +- Network/parameters.h | 4 +- Network/protocol.h | 2 +- Network/target.h | 2 +- Network/transfer.cpp | 8 +- Network/transfer.h | 2 +- Network/xfercore.cpp | 52 +- SecureTransport/CVSVersionInfo.txt | 2 +- SecureTransport/README | 1 - .../SecureTransport.pbproj/project.pbxproj | 65 +- SecureTransport/SecureTransport/CipherSuite.h | 2 - .../SecureTransport/SecureTransport.h | 129 +- SecureTransport/appleCdsa.cpp | 925 +- SecureTransport/cipherSpecs.cpp | 149 +- .../privateInc/SecureTransportPriv.h | 30 + SecureTransport/privateInc/appleCdsa.h | 32 +- SecureTransport/privateInc/cryptType.h | 7 + SecureTransport/privateInc/sslAlertMessage.h | 9 +- SecureTransport/privateInc/sslBER.h | 17 + SecureTransport/privateInc/sslBuildFlags.h | 14 - SecureTransport/privateInc/sslContext.h | 70 +- SecureTransport/privateInc/sslDebug.h | 20 +- SecureTransport/privateInc/sslHandshake.h | 8 +- SecureTransport/privateInc/sslKeychain.h | 42 +- SecureTransport/privateInc/sslMemory.h | 4 + SecureTransport/privateInc/sslPriv.h | 9 +- SecureTransport/privateInc/sslUtils.h | 10 +- SecureTransport/secureTransport.exp | 2 + SecureTransport/securetransport++.cpp | 18 +- SecureTransport/ssl2Message.cpp | 101 +- SecureTransport/ssl2Protocol.cpp | 64 +- SecureTransport/ssl2Record.cpp | 9 +- SecureTransport/ssl3Callouts.cpp | 8 +- SecureTransport/sslAlertMessage.cpp | 223 +- SecureTransport/sslBER.cpp | 201 +- SecureTransport/sslCert.cpp | 35 +- SecureTransport/sslChangeCipher.cpp | 2 +- SecureTransport/sslContext.cpp | 437 +- SecureTransport/sslHandshake.cpp | 146 +- SecureTransport/sslHandshakeHello.cpp | 48 +- SecureTransport/sslKeyExchange.cpp | 1589 +- SecureTransport/sslKeychain.cpp | 340 +- SecureTransport/sslMemory.cpp | 17 +- SecureTransport/sslRecord.cpp | 31 +- SecureTransport/sslSession.cpp | 2 - SecureTransport/sslTransport.cpp | 84 +- SecureTransport/sslUtils.cpp | 106 +- SecureTransport/tls1Callouts.cpp | 18 +- SecureTransport/tls_hmac.cpp | 4 + Security.exp | 20 +- Security.order | 6655 ++++++ Security.pbproj/project.pbxproj | 17224 +++++++++------- SecurityASN1/CVSVersionInfo.txt | 5 - SecurityASN1/Makefile | 65 - SecurityASN1/PkcsCms.pbproj/project.pbxproj | 797 - SecurityASN1/asn/appleoids.asn | 195 - SecurityASN1/asn/asn-useful.asn1 | 105 - SecurityASN1/asn/pkcs1.asn1 | 205 - SecurityASN1/asn/pkcs10.asn | 53 - SecurityASN1/asn/pkcs1oids.asn | 46 - SecurityASN1/asn/pkcs5.asn1 | 141 - SecurityASN1/asn/pkcs7.asn | 63 - SecurityASN1/asn/pkcs8.asn | 40 - SecurityASN1/asn/pkcs9oids.asn | 19 - SecurityASN1/asn/sm_cms.asn | 431 - SecurityASN1/asn/sm_ess.asn | 238 - SecurityASN1/asn/sm_vdatypes.asn | 13 - SecurityASN1/asn/sm_x411mtsas.asn | 158 - SecurityASN1/asn/sm_x411ub.asn | 131 - SecurityASN1/asn/sm_x501if.asn | 48 - SecurityASN1/asn/sm_x501ud.asn | 136 - SecurityASN1/asn/sm_x509af.asn | 215 - SecurityASN1/asn/sm_x509ce.asn | 265 - SecurityASN1/asn/sm_x509cmn.asn | 41 - SecurityASN1/asn/sm_x520sa.asn | 196 - SecurityASN1/c++/.cvsignore | 1 - SecurityASN1/c++/appleoids.cpp | 3361 --- SecurityASN1/c++/pkcs10.cpp | 738 - SecurityASN1/c++/pkcs1oids.cpp | 552 - SecurityASN1/c++/pkcs7.cpp | 473 - SecurityASN1/c++/pkcs8.cpp | 500 - SecurityASN1/c++/pkcs9oids.cpp | 35 - SecurityASN1/c++/sm_cms.cpp | 10334 --------- SecurityASN1/c++/sm_ess.cpp | 6649 ------ SecurityASN1/c++/sm_vdatypes.cpp | 70 - SecurityASN1/c++/sm_x411mtsas.cpp | 4836 ----- SecurityASN1/c++/sm_x411ub.cpp | 35 - SecurityASN1/c++/sm_x501if.cpp | 3470 ---- SecurityASN1/c++/sm_x501ud.cpp | 35 - SecurityASN1/c++/sm_x509af.cpp | 9586 --------- SecurityASN1/c++/sm_x509ce.cpp | 6837 ------ SecurityASN1/c++/sm_x509cmn.cpp | 1108 - SecurityASN1/c++/sm_x520sa.cpp | 304 - SecurityASN1/inc/.cvsignore | 0 SecurityASN1/inc/appleoids.h | 471 - SecurityASN1/inc/pkcs10.h | 110 - SecurityASN1/inc/pkcs1oids.h | 104 - SecurityASN1/inc/pkcs7.h | 111 - SecurityASN1/inc/pkcs8.h | 78 - SecurityASN1/inc/pkcs9oids.h | 45 - SecurityASN1/inc/sm_cms.h | 1454 -- SecurityASN1/inc/sm_ess.h | 1057 - SecurityASN1/inc/sm_vdatypes.h | 45 - SecurityASN1/inc/sm_x411mtsas.h | 666 - SecurityASN1/inc/sm_x411ub.h | 139 - SecurityASN1/inc/sm_x501if.h | 531 - SecurityASN1/inc/sm_x501ud.h | 133 - SecurityASN1/inc/sm_x509af.h | 1186 -- SecurityASN1/inc/sm_x509ce.h | 1059 - SecurityASN1/inc/sm_x509cmn.h | 165 - SecurityASN1/inc/sm_x520sa.h | 331 - SecuritySNACCRuntime/.cvsignore | 1 - SecuritySNACCRuntime/Apple_README | 53 - SecuritySNACCRuntime/COPYING | 339 - SecuritySNACCRuntime/CVSVersionInfo.txt | 5 - SecuritySNACCRuntime/ChangeLog | 761 - SecuritySNACCRuntime/INSTALL | 146 - SecuritySNACCRuntime/MacOSX-Install | 14 - SecuritySNACCRuntime/MacOSX-configure | 6 - SecuritySNACCRuntime/MacOSX-make | 21 - SecuritySNACCRuntime/NEWS | 160 - SecuritySNACCRuntime/README | 230 - SecuritySNACCRuntime/VDADER_RULES.TXT | 24 - SecuritySNACCRuntime/acconfig.h | 79 - SecuritySNACCRuntime/asn1specs/any.asn1 | 116 - .../asn1specs/asn-useful.asn1 | 99 - .../asn1specs/asn1module.asn1 | 673 - SecuritySNACCRuntime/asn1specs/err-test.asn1 | 237 - SecuritySNACCRuntime/asn1specs/ex1.asn1 | 40 - SecuritySNACCRuntime/asn1specs/install-sh | 238 - SecuritySNACCRuntime/asn1specs/makefile | 47 - SecuritySNACCRuntime/asn1specs/p-rec.asn1 | 56 - .../asn1specs/rfc1155-smi.asn1 | 155 - .../asn1specs/rfc1157-snmp.asn1 | 166 - .../asn1specs/rfc1213-mib2.asn1 | 2663 --- SecuritySNACCRuntime/asn1specs/tbl.asn1 | 171 - SecuritySNACCRuntime/c++-examples/any/README | 96 - .../c++-examples/any/example.C | 142 - .../c++-examples/any/genber.C | 220 - .../c++-examples/any/makefile | 169 - SecuritySNACCRuntime/c++-examples/makefile | 36 - .../c++-examples/simple/README | 111 - .../c++-examples/simple/example.C | 142 - .../c++-examples/simple/genber.C | 126 - .../c++-examples/simple/good-pr.ber | Bin 145 -> 0 bytes .../c++-examples/simple/makefile | 158 - SecuritySNACCRuntime/c++-examples/snmp/README | 132 - .../c++-examples/snmp/makefile | 115 - .../c++-examples/test-lib/README | 43 - .../c++-examples/test-lib/makefile | 68 - .../c++-examples/test-lib/test-lib.C | 815 - SecuritySNACCRuntime/c++-lib/README | 34 - SecuritySNACCRuntime/c++-lib/c++/asn-any.cpp | 344 - SecuritySNACCRuntime/c++-lib/c++/asn-bits.cpp | 605 - SecuritySNACCRuntime/c++-lib/c++/asn-bool.cpp | 215 - SecuritySNACCRuntime/c++-lib/c++/asn-enum.cpp | 181 - SecuritySNACCRuntime/c++-lib/c++/asn-int.cpp | 297 - SecuritySNACCRuntime/c++-lib/c++/asn-len.cpp | 188 - SecuritySNACCRuntime/c++-lib/c++/asn-list.cpp | 376 - SecuritySNACCRuntime/c++-lib/c++/asn-null.cpp | 185 - SecuritySNACCRuntime/c++-lib/c++/asn-octs.cpp | 518 - SecuritySNACCRuntime/c++-lib/c++/asn-oid.cpp | 479 - SecuritySNACCRuntime/c++-lib/c++/asn-real.cpp | 955 - SecuritySNACCRuntime/c++-lib/c++/asn-tag.cpp | 92 - SecuritySNACCRuntime/c++-lib/c++/asn-type.cpp | 209 - .../c++-lib/c++/asn-useful.cpp | 1095 - SecuritySNACCRuntime/c++-lib/c++/hash.cpp | 291 - SecuritySNACCRuntime/c++-lib/c++/meta.cpp | 464 - SecuritySNACCRuntime/c++-lib/c++/print.cpp | 109 - SecuritySNACCRuntime/c++-lib/c++/str-stk.cpp | 152 - SecuritySNACCRuntime/c++-lib/c++/tcl-if.cpp | 1103 - SecuritySNACCRuntime/c++-lib/c++/tkAppInit.c | 139 - SecuritySNACCRuntime/c++-lib/dependencies | 0 SecuritySNACCRuntime/c++-lib/inc/asn-any.h | 203 - SecuritySNACCRuntime/c++-lib/inc/asn-bits.h | 188 - SecuritySNACCRuntime/c++-lib/inc/asn-bool.h | 177 - SecuritySNACCRuntime/c++-lib/inc/asn-buf.h | 216 - SecuritySNACCRuntime/c++-lib/inc/asn-config.h | 346 - SecuritySNACCRuntime/c++-lib/inc/asn-enum.h | 118 - SecuritySNACCRuntime/c++-lib/inc/asn-incl.h | 121 - SecuritySNACCRuntime/c++-lib/inc/asn-int.h | 124 - SecuritySNACCRuntime/c++-lib/inc/asn-len.h | 130 - SecuritySNACCRuntime/c++-lib/inc/asn-list.h | 197 - SecuritySNACCRuntime/c++-lib/inc/asn-null.h | 111 - SecuritySNACCRuntime/c++-lib/inc/asn-octs.h | 202 - SecuritySNACCRuntime/c++-lib/inc/asn-oid.h | 194 - SecuritySNACCRuntime/c++-lib/inc/asn-real.h | 132 - SecuritySNACCRuntime/c++-lib/inc/asn-tag.h | 273 - SecuritySNACCRuntime/c++-lib/inc/asn-type.h | 172 - SecuritySNACCRuntime/c++-lib/inc/asn-useful.h | 408 - SecuritySNACCRuntime/c++-lib/inc/cdsaUtils.h | 77 - SecuritySNACCRuntime/c++-lib/inc/config.h | 128 - SecuritySNACCRuntime/c++-lib/inc/hash.h | 106 - SecuritySNACCRuntime/c++-lib/inc/init.h | 48 - SecuritySNACCRuntime/c++-lib/inc/meta.h | 284 - SecuritySNACCRuntime/c++-lib/inc/print.h | 88 - .../c++-lib/inc/sm_vdasnacc.h | 392 - .../c++-lib/inc/sm_vdatypes.h | 66 - SecuritySNACCRuntime/c++-lib/inc/snacc.h | 215 - SecuritySNACCRuntime/c++-lib/inc/str-stk.h | 107 - SecuritySNACCRuntime/c++-lib/inc/tcl-if.h | 117 - SecuritySNACCRuntime/c++-lib/install-sh | 238 - SecuritySNACCRuntime/c++-lib/makefile | 326 - .../c++-lib/src/asn-useful.cpp | 1095 - .../c++-lib/src/cdsaUtils.cpp | 197 - .../c++-lib/src/sm_buffer.cpp | 898 - .../c++-lib/src/sm_vdasnacc.cpp | 560 - SecuritySNACCRuntime/c++-lib/src/tkAppInit.c | 136 - SecuritySNACCRuntime/c++-lib/stamp-useful | 1 - SecuritySNACCRuntime/c-examples/any/README | 113 - SecuritySNACCRuntime/c-examples/any/example.c | 188 - SecuritySNACCRuntime/c-examples/any/genber.c | 191 - SecuritySNACCRuntime/c-examples/any/makefile | 150 - SecuritySNACCRuntime/c-examples/makefile | 53 - SecuritySNACCRuntime/c-examples/simple/README | 134 - .../c-examples/simple/expbuf-ex.c | 196 - .../c-examples/simple/genber.c | 181 - .../c-examples/simple/good-pr.ber | Bin 145 -> 0 bytes .../c-examples/simple/makefile | 204 - .../c-examples/simple/minbuf-ex.c | 189 - .../c-examples/simple/sbuf-ex.c | 181 - SecuritySNACCRuntime/c-examples/snmp/README | 124 - SecuritySNACCRuntime/c-examples/snmp/makefile | 97 - .../c-examples/test-lib/README | 43 - .../c-examples/test-lib/makefile | 56 - .../c-examples/test-lib/test-lib.c | 962 - SecuritySNACCRuntime/c-lib/.cvsignore | 5 - SecuritySNACCRuntime/c-lib/README | 36 - SecuritySNACCRuntime/c-lib/asn-useful.c | 874 - SecuritySNACCRuntime/c-lib/asn-useful.h | 325 - SecuritySNACCRuntime/c-lib/boot/asn-useful.c | 799 - SecuritySNACCRuntime/c-lib/boot/asn-useful.h | 295 - SecuritySNACCRuntime/c-lib/boot/tbl.c | 2137 -- SecuritySNACCRuntime/c-lib/boot/tbl.h | 362 - SecuritySNACCRuntime/c-lib/dependencies | 1040 - SecuritySNACCRuntime/c-lib/inc/asn-any.h | 149 - SecuritySNACCRuntime/c-lib/inc/asn-bits.h | 96 - SecuritySNACCRuntime/c-lib/inc/asn-bool.h | 73 - SecuritySNACCRuntime/c-lib/inc/asn-config.h | 230 - SecuritySNACCRuntime/c-lib/inc/asn-enum.h | 76 - SecuritySNACCRuntime/c-lib/inc/asn-incl.h | 69 - SecuritySNACCRuntime/c-lib/inc/asn-int.h | 111 - SecuritySNACCRuntime/c-lib/inc/asn-len.h | 141 - SecuritySNACCRuntime/c-lib/inc/asn-list.h | 160 - SecuritySNACCRuntime/c-lib/inc/asn-null.h | 75 - SecuritySNACCRuntime/c-lib/inc/asn-octs.h | 86 - SecuritySNACCRuntime/c-lib/inc/asn-oid.h | 99 - SecuritySNACCRuntime/c-lib/inc/asn-real.h | 79 - SecuritySNACCRuntime/c-lib/inc/asn-tag.h | 260 - SecuritySNACCRuntime/c-lib/inc/asn-useful.h | 325 - SecuritySNACCRuntime/c-lib/inc/exp-buf.h | 168 - SecuritySNACCRuntime/c-lib/inc/gen-buf.h | 110 - SecuritySNACCRuntime/c-lib/inc/hash.h | 89 - SecuritySNACCRuntime/c-lib/inc/mem.h | 61 - SecuritySNACCRuntime/c-lib/inc/min-buf.h | 100 - SecuritySNACCRuntime/c-lib/inc/nibble-alloc.h | 86 - SecuritySNACCRuntime/c-lib/inc/print.h | 62 - SecuritySNACCRuntime/c-lib/inc/sbuf.h | 249 - SecuritySNACCRuntime/c-lib/inc/str-stk.h | 135 - SecuritySNACCRuntime/c-lib/inc/tbl-dec.h | 57 - SecuritySNACCRuntime/c-lib/inc/tbl-enc.h | 56 - SecuritySNACCRuntime/c-lib/inc/tbl-free.h | 57 - .../c-lib/inc/tbl-gen-c-hdr.h | 55 - SecuritySNACCRuntime/c-lib/inc/tbl-gen.h | 42 - SecuritySNACCRuntime/c-lib/inc/tbl-incl.h | 79 - SecuritySNACCRuntime/c-lib/inc/tbl-print.h | 57 - SecuritySNACCRuntime/c-lib/inc/tbl-util.h | 75 - SecuritySNACCRuntime/c-lib/inc/tbl.h | 344 - SecuritySNACCRuntime/c-lib/install-sh | 238 - SecuritySNACCRuntime/c-lib/makefile | 401 - SecuritySNACCRuntime/c-lib/src/asn-any.c | 269 - SecuritySNACCRuntime/c-lib/src/asn-bits.c | 450 - SecuritySNACCRuntime/c-lib/src/asn-bool.c | 157 - SecuritySNACCRuntime/c-lib/src/asn-enum.c | 101 - SecuritySNACCRuntime/c-lib/src/asn-int.c | 399 - SecuritySNACCRuntime/c-lib/src/asn-len.c | 233 - SecuritySNACCRuntime/c-lib/src/asn-list.c | 486 - SecuritySNACCRuntime/c-lib/src/asn-null.c | 133 - SecuritySNACCRuntime/c-lib/src/asn-octs.c | 338 - SecuritySNACCRuntime/c-lib/src/asn-oid.c | 348 - SecuritySNACCRuntime/c-lib/src/asn-real.c | 884 - SecuritySNACCRuntime/c-lib/src/asn-tag.c | 176 - SecuritySNACCRuntime/c-lib/src/asn-useful.c | 874 - SecuritySNACCRuntime/c-lib/src/exp-buf.c | 896 - SecuritySNACCRuntime/c-lib/src/hash.c | 274 - SecuritySNACCRuntime/c-lib/src/nibble-alloc.c | 231 - SecuritySNACCRuntime/c-lib/src/print.c | 105 - SecuritySNACCRuntime/c-lib/src/sbuf.c | 405 - SecuritySNACCRuntime/c-lib/src/str-stk.c | 59 - SecuritySNACCRuntime/c-lib/src/tbl-dbg.c | 466 - SecuritySNACCRuntime/c-lib/src/tbl-dec.c | 456 - SecuritySNACCRuntime/c-lib/src/tbl-enc.c | 346 - SecuritySNACCRuntime/c-lib/src/tbl-free.c | 163 - SecuritySNACCRuntime/c-lib/src/tbl-gen.c | 669 - SecuritySNACCRuntime/c-lib/src/tbl-print.c | 194 - SecuritySNACCRuntime/c-lib/src/tbl-util.c | 443 - SecuritySNACCRuntime/c-lib/src/tbl.c | 2119 -- SecuritySNACCRuntime/c-lib/stamp-tbl | 1 - SecuritySNACCRuntime/c-lib/stamp-useful | 1 - SecuritySNACCRuntime/c-lib/tbl.c | 2119 -- SecuritySNACCRuntime/c-lib/tbl.h | 344 - SecuritySNACCRuntime/c-lib/tbl.h.patch | 23 - SecuritySNACCRuntime/compiler/README | 111 - .../compiler/back-ends/.cvsignore | 1 - .../compiler/back-ends/c++-gen/gen-any.c | 309 - .../compiler/back-ends/c++-gen/gen-any.h | 53 - .../compiler/back-ends/c++-gen/gen-code.c | 5650 ----- .../compiler/back-ends/c++-gen/gen-code.h | 63 - .../compiler/back-ends/c++-gen/gen-vals.c | 325 - .../compiler/back-ends/c++-gen/gen-vals.h | 83 - .../compiler/back-ends/c++-gen/kwd.c | 112 - .../compiler/back-ends/c++-gen/kwd.h | 53 - .../compiler/back-ends/c++-gen/rules.c | 366 - .../compiler/back-ends/c++-gen/rules.h | 71 - .../compiler/back-ends/c++-gen/types.c | 677 - .../compiler/back-ends/c++-gen/types.h | 53 - .../compiler/back-ends/c-gen/gen-any.c | 338 - .../compiler/back-ends/c-gen/gen-any.h | 58 - .../compiler/back-ends/c-gen/gen-any2.c | 335 - .../compiler/back-ends/c-gen/gen-code.c | 267 - .../compiler/back-ends/c-gen/gen-code.h | 57 - .../compiler/back-ends/c-gen/gen-code2.c | 264 - .../compiler/back-ends/c-gen/gen-dec.c | 1912 -- .../compiler/back-ends/c-gen/gen-dec.h | 60 - .../compiler/back-ends/c-gen/gen-enc.c | 852 - .../compiler/back-ends/c-gen/gen-enc.h | 60 - .../compiler/back-ends/c-gen/gen-free.c | 514 - .../compiler/back-ends/c-gen/gen-free.h | 57 - .../compiler/back-ends/c-gen/gen-print.c | 547 - .../compiler/back-ends/c-gen/gen-print.h | 55 - .../compiler/back-ends/c-gen/gen-type.c | 401 - .../compiler/back-ends/c-gen/gen-type.h | 57 - .../compiler/back-ends/c-gen/gen-vals.c | 238 - .../compiler/back-ends/c-gen/gen-vals.h | 59 - .../compiler/back-ends/c-gen/gen-vals2.c | 235 - .../compiler/back-ends/c-gen/kwd.c | 100 - .../compiler/back-ends/c-gen/kwd.h | 52 - .../compiler/back-ends/c-gen/kwd2.c | 97 - .../compiler/back-ends/c-gen/rules.c | 564 - .../compiler/back-ends/c-gen/rules.h | 69 - .../compiler/back-ends/c-gen/rules2.c | 561 - .../compiler/back-ends/c-gen/type-info.c | 1315 -- .../compiler/back-ends/c-gen/type-info.h | 98 - .../compiler/back-ends/c-gen/util.c | 227 - .../compiler/back-ends/c-gen/util.h | 65 - .../compiler/back-ends/cond.c | 76 - .../compiler/back-ends/cond.h | 49 - .../compiler/back-ends/idl-gen/gen-any.c | 294 - .../compiler/back-ends/idl-gen/gen-any.h | 47 - .../compiler/back-ends/idl-gen/gen-code.c | 498 - .../compiler/back-ends/idl-gen/gen-code.h | 46 - .../compiler/back-ends/idl-gen/gen-vals.c | 217 - .../compiler/back-ends/idl-gen/gen-vals.h | 59 - .../compiler/back-ends/idl-gen/rules.c | 353 - .../compiler/back-ends/idl-gen/rules.h | 65 - .../compiler/back-ends/idl-gen/types.c | 675 - .../compiler/back-ends/idl-gen/types.h | 47 - .../compiler/back-ends/str-util.c | 606 - .../compiler/back-ends/str-util.h | 95 - .../compiler/back-ends/tag-util.c | 536 - .../compiler/back-ends/tag-util.h | 60 - SecuritySNACCRuntime/compiler/boot/tbl.c | 592 - SecuritySNACCRuntime/compiler/boot/tbl.h | 242 - SecuritySNACCRuntime/compiler/core/.cvsignore | 1 - .../compiler/core/asn1module.h | 1028 - SecuritySNACCRuntime/compiler/core/define.c | 220 - SecuritySNACCRuntime/compiler/core/define.h | 57 - .../compiler/core/dependency.c | 750 - .../compiler/core/dependency.h | 29 - .../compiler/core/do-macros.c | 732 - .../compiler/core/do-macros.h | 33 - SecuritySNACCRuntime/compiler/core/err-chk.c | 996 - SecuritySNACCRuntime/compiler/core/err-chk.h | 34 - SecuritySNACCRuntime/compiler/core/exports.c | 117 - SecuritySNACCRuntime/compiler/core/exports.h | 52 - SecuritySNACCRuntime/compiler/core/gen-tbls.c | 741 - SecuritySNACCRuntime/compiler/core/gen-tbls.h | 40 - SecuritySNACCRuntime/compiler/core/lex-asn1.c | 3496 ---- SecuritySNACCRuntime/compiler/core/lex-asn1.l | 523 - .../compiler/core/lex-stuff.h | 56 - .../compiler/core/lib-types.c | 66 - .../compiler/core/lib-types.h | 47 - .../compiler/core/link-types.c | 1273 -- .../compiler/core/link-types.h | 34 - .../compiler/core/link-values.c | 1266 -- .../compiler/core/link-values.h | 34 - SecuritySNACCRuntime/compiler/core/mem.c | 97 - SecuritySNACCRuntime/compiler/core/meta.c | 57 - SecuritySNACCRuntime/compiler/core/meta.h | 60 - .../compiler/core/normalize.c | 860 - .../compiler/core/normalize.h | 30 - SecuritySNACCRuntime/compiler/core/oid.c | 270 - SecuritySNACCRuntime/compiler/core/oid.h | 32 - .../compiler/core/parse-asn1.c | 4619 ----- .../compiler/core/parse-asn1.h | 183 - .../compiler/core/parse-asn1.y | 3196 --- SecuritySNACCRuntime/compiler/core/parser.h | 36 - SecuritySNACCRuntime/compiler/core/print.c | 2767 --- SecuritySNACCRuntime/compiler/core/print.h | 136 - SecuritySNACCRuntime/compiler/core/print2.c | 2764 --- .../compiler/core/recursive.c | 199 - .../compiler/core/recursive.h | 29 - .../compiler/core/snacc-util.c | 1334 -- .../compiler/core/snacc-util.h | 139 - SecuritySNACCRuntime/compiler/core/snacc.c | 1361 -- SecuritySNACCRuntime/compiler/core/tbl.c | 574 - SecuritySNACCRuntime/compiler/core/tbl.h | 224 - .../compiler/core/tblCompiler.c | 574 - .../compiler/core/val-parser.c | 734 - .../compiler/core/val-parser.h | 37 - SecuritySNACCRuntime/compiler/dependencies | 766 - SecuritySNACCRuntime/compiler/install-sh | 238 - SecuritySNACCRuntime/compiler/makefile | 386 - SecuritySNACCRuntime/compiler/stamp-tbl | 1 - SecuritySNACCRuntime/compiler/tbl.c | 574 - SecuritySNACCRuntime/compiler/tbl.h | 224 - SecuritySNACCRuntime/config.cache | 68 - SecuritySNACCRuntime/config.h | 128 - SecuritySNACCRuntime/config.h.in | 160 - SecuritySNACCRuntime/config.log | 80 - SecuritySNACCRuntime/config.status | 349 - SecuritySNACCRuntime/configure | 4458 ---- SecuritySNACCRuntime/configure.in | 189 - SecuritySNACCRuntime/doc/asn1-defs.tex | 910 - SecuritySNACCRuntime/doc/c++-gen.tex | 720 - SecuritySNACCRuntime/doc/c++-lib.tex | 973 - SecuritySNACCRuntime/doc/c-gen.tex | 772 - SecuritySNACCRuntime/doc/c-lib.tex | 1384 -- SecuritySNACCRuntime/doc/coding.tex | 105 - SecuritySNACCRuntime/doc/corba.bib | 35 - SecuritySNACCRuntime/doc/design.tex | 761 - SecuritySNACCRuntime/doc/editor.tex | 462 - SecuritySNACCRuntime/doc/future-work.tex | 80 - SecuritySNACCRuntime/doc/idl-gen.tex | 19 - SecuritySNACCRuntime/doc/install-sh | 238 - SecuritySNACCRuntime/doc/intro-1.1.tex | 407 - SecuritySNACCRuntime/doc/intro-1.2.tex | 422 - SecuritySNACCRuntime/doc/makefile | 237 - SecuritySNACCRuntime/doc/makefile.tex | 121 - SecuritySNACCRuntime/doc/meta.tex | 670 - SecuritySNACCRuntime/doc/misc-hyph.tex | 23 - SecuritySNACCRuntime/doc/mkchdr.1 | 60 - SecuritySNACCRuntime/doc/modifying.tex | 49 - SecuritySNACCRuntime/doc/ptbl.1 | 64 - SecuritySNACCRuntime/doc/pval.1 | 63 - SecuritySNACCRuntime/doc/snacc.1 | 305 - SecuritySNACCRuntime/doc/snacc.bib | 269 - SecuritySNACCRuntime/doc/snacc.n | 242 - SecuritySNACCRuntime/doc/snacc.tex | 172 - SecuritySNACCRuntime/doc/snacced.1 | 248 - SecuritySNACCRuntime/doc/tcl.bib | 21 - SecuritySNACCRuntime/doc/tcl.tex | 456 - SecuritySNACCRuntime/doc/ttab.tex | 532 - SecuritySNACCRuntime/doc/tumble.sed | 4 - SecuritySNACCRuntime/doc/version.tex | 1 - SecuritySNACCRuntime/install-sh | 238 - SecuritySNACCRuntime/makefile | 225 - SecuritySNACCRuntime/makehead | 75 - SecuritySNACCRuntime/makehead.in | 113 - SecuritySNACCRuntime/makehead.static | 134 - SecuritySNACCRuntime/maketail | 78 - SecuritySNACCRuntime/mkinstalldirs | 32 - SecuritySNACCRuntime/snacc.h | 186 - .../snacc.pbproj/project.pbxproj | 1137 - SecuritySNACCRuntime/stamp-h | 1 - SecuritySNACCRuntime/stamp-h.in | 1 - SecuritySNACCRuntime/tbl-example/README | 89 - SecuritySNACCRuntime/tbl-example/dependencies | 0 SecuritySNACCRuntime/tbl-example/example.c | 201 - SecuritySNACCRuntime/tbl-example/makefile | 88 - SecuritySNACCRuntime/tbl-example/p-rec.ber | Bin 145 -> 0 bytes SecuritySNACCRuntime/tbl-example/p-rec.h | 64 - SecuritySNACCRuntime/tbl-example/p-rec.tt | Bin 1612 -> 0 bytes SecuritySNACCRuntime/tbl-tools/makefile | 55 - SecuritySNACCRuntime/tcl-asn/README | 75 - SecuritySNACCRuntime/tcl-asn/asnwish.c | 29 - SecuritySNACCRuntime/tcl-asn/beredit | 372 - SecuritySNACCRuntime/tcl-asn/makefile | 90 - SecuritySNACCRuntime/tcl-asn/tclasn.c | 1185 -- SecuritySNACCRuntime/tcl-example/dependencies | 0 SecuritySNACCRuntime/tcl-example/edex0.asn1 | 39 - SecuritySNACCRuntime/tcl-example/edex1.asn1 | 78 - SecuritySNACCRuntime/tcl-example/makefile | 102 - SecuritySNACCRuntime/tcl-lib/bindings.tcl | 30 - SecuritySNACCRuntime/tcl-lib/help.tcl | 48 - SecuritySNACCRuntime/tcl-lib/make-snacced | 16 - SecuritySNACCRuntime/tcl-lib/makefile | 69 - SecuritySNACCRuntime/tcl-lib/selbox.tcl | 362 - SecuritySNACCRuntime/tcl-lib/snacced.tcl | 1604 -- SecuritySNACCRuntime/tcl-lib/tkuti.tcl | 21 - SecuritySNACCRuntime/tcl-lib/uti.tcl | 15 - SecuritySNACCRuntime/version.h | 21 - SecurityServer/Authorization/AuthSession.h | 55 +- .../Authorization/Authorization.cpp | 188 +- SecurityServer/Authorization/Authorization.h | 39 +- .../Authorization/AuthorizationDB.h | 154 + .../Authorization/AuthorizationDBPlist.cpp | 378 + .../Authorization/AuthorizationDBPlist.h | 62 + .../Authorization/AuthorizationData.cpp | 415 +- .../Authorization/AuthorizationData.h | 246 +- .../Authorization/AuthorizationEngine.cpp | 1222 +- .../Authorization/AuthorizationEngine.h | 149 +- .../Authorization/AuthorizationPlugin.h | 4 +- .../Authorization/AuthorizationPriv.h | 171 + .../Authorization/AuthorizationRule.cpp | 1171 ++ .../Authorization/AuthorizationRule.h | 146 + .../Authorization/AuthorizationTags.h | 13 + .../Authorization/AuthorizationTrampoline.cpp | 10 +- .../Authorization/AuthorizationWalkers.h | 16 +- .../Authorization/authorization.plist | 628 +- .../Authorization/privPort.h | 42 +- .../Authorization/privPortClient.cpp | 170 + .../Authorization/privPortServer.cpp | 191 + .../Authorization/trampolineClient.cpp | 20 +- SecurityServer/CVSVersionInfo.txt | 2 +- SecurityServer/Makefile.startup | 13 +- SecurityServer/SecurityAgentClient.cpp | 295 +- SecurityServer/SecurityAgentClient.h | 55 +- SecurityServer/SecurityServer.order | 368 +- .../StartupItems/CodeEquivalenceCandidates | 26 + SecurityServer/StartupItems/SecurityServer | 35 +- SecurityServer/TODO | 17 - SecurityServer/acl_keychain.cpp | 37 +- SecurityServer/acls.cpp | 69 +- SecurityServer/acls.h | 17 +- SecurityServer/agentquery.cpp | 209 +- SecurityServer/agentquery.h | 85 +- SecurityServer/authority.cpp | 99 +- SecurityServer/authority.h | 14 +- SecurityServer/cfnotifier.cpp | 134 +- SecurityServer/cfnotifier.h | 1 - SecurityServer/codesigdb.cpp | 381 + SecurityServer/codesigdb.h | 101 + SecurityServer/connection.cpp | 46 +- SecurityServer/dbcrypto.cpp | 180 +- SecurityServer/dbcrypto.h | 31 +- SecurityServer/dictionary.cpp | 273 + SecurityServer/dictionary.h | 90 + SecurityServer/entropy.cpp | 10 +- SecurityServer/eventlistener.cpp | 118 + SecurityServer/eventlistener.h | 41 + SecurityServer/flippers.cpp | 79 + SecurityServer/flippers.h | 84 + SecurityServer/generate.cf | 42 + SecurityServer/generate.pl | 71 + SecurityServer/key.cpp | 92 +- SecurityServer/key.h | 32 +- SecurityServer/main.cpp | 68 +- SecurityServer/notifications.cpp | 13 +- SecurityServer/process.cpp | 150 +- SecurityServer/process.h | 30 +- SecurityServer/secagent.defs | 12 +- SecurityServer/secagent_types.h | 1 + SecurityServer/securityserver.h | 1 + SecurityServer/server.cpp | 124 +- SecurityServer/server.h | 39 +- SecurityServer/session.cpp | 144 +- SecurityServer/session.h | 27 +- SecurityServer/ssblob.cpp | 11 +- SecurityServer/ssblob.h | 58 +- SecurityServer/ssclient.cpp | 56 +- SecurityServer/ssclient.h | 114 +- SecurityServer/sstransit.cpp | 204 +- SecurityServer/sstransit.h | 13 + SecurityServer/systemkeychain.cpp | 373 + SecurityServer/transition.cpp | 332 +- SecurityServer/transwalkers.cpp | 82 + SecurityServer/transwalkers.h | 240 + SecurityServer/ucsp.defs | 79 +- SecurityServer/ucsp_types.h | 9 + SecurityServer/xdatabase.cpp | 645 +- SecurityServer/xdatabase.h | 91 +- cdsa/CVSVersionInfo.txt | 2 +- cdsa/cdsa/certextensions.h | 217 +- cdsa/cdsa/cssmapple.h | 260 +- cdsa/cdsa/cssmconfig.h | 6 - cdsa/cdsa/cssmspi.h | 22 - cdsa/cdsa/cssmtype.h | 2 +- cdsa/cdsa/oidsalg.h | 38 +- cdsa/cdsa/oidsattr.h | 28 + cdsa/cdsa/oidsbase.h | 15 + cdsa/cdsa/oidscert.h | 26 +- cdsa/cdsa/x509defs.h | 2 +- cdsa/cdsa_client/aclclient.cpp | 49 +- cdsa/cdsa_client/aclclient.h | 43 +- cdsa/cdsa_client/aclsupport.cpp | 340 - cdsa/cdsa_client/aclsupport.h | 100 - cdsa/cdsa_client/cryptoclient.cpp | 6 + cdsa/cdsa_client/cryptoclient.h | 2 +- cdsa/cdsa_client/cspclient.cpp | 4 +- cdsa/cdsa_client/cspclient.h | 8 + cdsa/cdsa_client/cssmclient.h | 1 + cdsa/cdsa_client/dlclient.cpp | 103 +- cdsa/cdsa_client/dlclient.h | 25 +- cdsa/cdsa_client/keyclient.cpp | 6 +- cdsa/cdsa_client/keyclient.h | 19 +- cdsa/cdsa_client/securestorage.cpp | 25 +- cdsa/cdsa_client/securestorage.h | 7 - cdsa/cdsa_client/tpclient.cpp | 4 +- cdsa/cdsa_pluginlib/CSPsession.cpp | 5 +- cdsa/cdsa_pluginlib/csputilities.cpp | 13 +- cdsa/cdsa_pluginlib/generator.cfg | 85 +- cdsa/cdsa_pluginlib/generator.pl | 4 +- cdsa/cdsa_utilities/AppleDatabase.cpp | 345 +- cdsa/cdsa_utilities/AppleDatabase.h | 44 +- cdsa/cdsa_utilities/AtomicFile.cpp | 1533 +- cdsa/cdsa_utilities/AtomicFile.h | 300 +- cdsa/cdsa_utilities/DatabaseSession.cpp | 16 +- cdsa/cdsa_utilities/DbContext.cpp | 83 - cdsa/cdsa_utilities/DbIndex.cpp | 6 +- cdsa/cdsa_utilities/DbIndex.h | 2 +- cdsa/cdsa_utilities/MetaAttribute.h | 12 +- cdsa/cdsa_utilities/MetaRecord.cpp | 14 +- cdsa/cdsa_utilities/ReadWriteSection.h | 16 +- cdsa/cdsa_utilities/acl_codesigning.cpp | 10 +- cdsa/cdsa_utilities/acl_codesigning.h | 2 +- cdsa/cdsa_utilities/acl_password.cpp | 1 + cdsa/cdsa_utilities/acl_process.cpp | 27 +- cdsa/cdsa_utilities/acl_process.h | 14 +- cdsa/cdsa_utilities/acl_threshold.cpp | 11 +- cdsa/cdsa_utilities/bufferfifo.h | 2 +- cdsa/cdsa_utilities/cfutilities.h | 21 +- cdsa/cdsa_utilities/codesigning.h | 2 + cdsa/cdsa_utilities/context.cpp | 11 + cdsa/cdsa_utilities/context.h | 23 +- cdsa/cdsa_utilities/cssmacl.cpp | 62 +- cdsa/cdsa_utilities/cssmacl.h | 22 +- cdsa/cdsa_utilities/cssmaclpod.h | 62 +- cdsa/cdsa_utilities/cssmalloc.h | 6 +- cdsa/cdsa_utilities/cssmcert.cpp | 2 + cdsa/cdsa_utilities/cssmcred.cpp | 21 + cdsa/cdsa_utilities/cssmcred.h | 26 +- cdsa/cdsa_utilities/cssmdata.h | 21 + cdsa/cdsa_utilities/cssmdates.h | 5 +- cdsa/cdsa_utilities/cssmdb.cpp | 41 +- cdsa/cdsa_utilities/cssmdb.h | 22 +- cdsa/cdsa_utilities/cssmerrno.cpp | 23 +- cdsa/cdsa_utilities/cssmlist.cpp | 16 + cdsa/cdsa_utilities/cssmlist.h | 87 +- cdsa/cdsa_utilities/cssmtrust.h | 16 + cdsa/cdsa_utilities/cssmwalkers.h | 59 +- cdsa/cdsa_utilities/daemon.cpp | 4 +- cdsa/cdsa_utilities/db++.cpp | 138 + cdsa/cdsa_utilities/db++.h | 85 + cdsa/cdsa_utilities/debugging.cpp | 95 +- cdsa/cdsa_utilities/debugging.h | 126 +- cdsa/cdsa_utilities/debugsupport.h | 20 - cdsa/cdsa_utilities/devrandom.cpp | 30 +- cdsa/cdsa_utilities/devrandom.h | 11 +- cdsa/cdsa_utilities/endian.cpp | 51 + cdsa/cdsa_utilities/endian.h | 129 + cdsa/cdsa_utilities/fdmover.cpp | 100 + cdsa/cdsa_utilities/fdmover.h | 87 + cdsa/cdsa_utilities/generator.pl | 19 +- cdsa/cdsa_utilities/globalizer.cpp | 3 +- cdsa/cdsa_utilities/globalizer.h | 10 +- cdsa/cdsa_utilities/handleobject.cpp | 2 +- cdsa/cdsa_utilities/headermap.cpp | 1 + cdsa/cdsa_utilities/headermap.h | 2 +- cdsa/cdsa_utilities/hosts.cpp | 2 +- cdsa/cdsa_utilities/hosts.h | 2 +- cdsa/cdsa_utilities/ip++.cpp | 96 +- cdsa/cdsa_utilities/ip++.h | 34 +- cdsa/cdsa_utilities/ktracecodes.h | 120 + cdsa/cdsa_utilities/logging.cpp | 2 +- cdsa/cdsa_utilities/mach++.cpp | 33 +- cdsa/cdsa_utilities/machrunloopserver.cpp | 19 +- cdsa/cdsa_utilities/machserver.cpp | 36 +- cdsa/cdsa_utilities/memstreams.h | 156 + cdsa/cdsa_utilities/memutils.h | 119 - cdsa/cdsa_utilities/osxsigning.cpp | 14 +- cdsa/cdsa_utilities/powerwatch.cpp | 22 +- cdsa/cdsa_utilities/selector.cpp | 18 +- cdsa/cdsa_utilities/socks++4.cpp | 6 +- cdsa/cdsa_utilities/socks++5.cpp | 12 +- cdsa/cdsa_utilities/streams.h | 2 +- cdsa/cdsa_utilities/threading.cpp | 65 +- cdsa/cdsa_utilities/threading.h | 18 +- cdsa/cdsa_utilities/timeflow.cpp | 21 +- cdsa/cdsa_utilities/timeflow.h | 2 + cdsa/cdsa_utilities/tqueue.h | 6 +- cdsa/cdsa_utilities/unix++.cpp | 21 +- cdsa/cdsa_utilities/unix++.h | 61 +- cdsa/cdsa_utilities/url.h | 2 +- cdsa/cdsa_utilities/utilities.cpp | 106 +- cdsa/cdsa_utilities/utilities.h | 65 +- cdsa/cdsa_utilities/walkers.cpp | 12 +- cdsa/cdsa_utilities/walkers.h | 114 +- cdsa/cssm/MDS | 2 +- cdsa/cssm/attachfactory.cpp | 18 +- cdsa/cssm/manager.cpp | 10 +- cdsa/cssm/oidsalg.c | 219 +- cdsa/cssm/oidsattr.c | 84 + cdsa/cssm/oidscert.cpp | 135 +- cdsa/cssm/oidscrl.cpp | 157 +- cdsa/cssm/transition.cpp | 2 +- cdsa/generator.mk | 26 +- cdsa/mds/MDSAttrStrings.cpp | 31 - cdsa/mds/MDSAttrUtils.h | 4 +- cdsa/mds/MDSDictionary.cpp | 7 - cdsa/mds/MDSSession.cpp | 49 +- cdsa/mds/MDSSession.h | 6 +- checkpw/checkpw.c | 15 +- checkpw/checkpw.h | 19 +- keychains/Makefile | 22 +- keychains/X509Anchors | Bin 153168 -> 178112 bytes keychains/X509Certificates | Bin 0 -> 79704 bytes keychains/certs/C3_ID_CA.cer | Bin 0 -> 1061 bytes keychains/certs/C3_Mail_CA.cer | Bin 0 -> 1063 bytes keychains/certs/DOD_CLASS_3_CA-10.cer | Bin 0 -> 1050 bytes keychains/certs/DOD_CLASS_3_CA-3.cer | Bin 0 -> 1049 bytes keychains/certs/DOD_CLASS_3_CA-4.cer | Bin 0 -> 1049 bytes keychains/certs/DOD_CLASS_3_CA-5.cer | Bin 0 -> 1049 bytes keychains/certs/DOD_CLASS_3_CA-6.cer | Bin 0 -> 1049 bytes keychains/certs/DOD_CLASS_3_CA-7.cer | Bin 0 -> 1049 bytes keychains/certs/DOD_CLASS_3_CA-9.cer | Bin 0 -> 1049 bytes keychains/certs/DOD_CLASS_3_CAC_CA.cer | Bin 0 -> 1051 bytes keychains/certs/DOD_CLASS_3_CAC_EMAIL_CA.cer | Bin 0 -> 1057 bytes keychains/certs/DOD_CLASS_3_EMAIL_CA-10.cer | Bin 0 -> 1056 bytes keychains/certs/DOD_CLASS_3_EMAIL_CA-3.cer | Bin 0 -> 1055 bytes keychains/certs/DOD_CLASS_3_EMAIL_CA-4.cer | Bin 0 -> 1055 bytes keychains/certs/DOD_CLASS_3_EMAIL_CA-5.cer | Bin 0 -> 1055 bytes keychains/certs/DOD_CLASS_3_EMAIL_CA-6.cer | Bin 0 -> 1055 bytes keychains/certs/DOD_CLASS_3_EMAIL_CA-7.cer | Bin 0 -> 1055 bytes keychains/certs/DOD_CLASS_3_EMAIL_CA-9.cer | Bin 0 -> 1055 bytes .../certs/GeoTrust_True_Credentials_CA_2.cer | Bin 0 -> 699 bytes keychains/certs/JITC_Class3ID_CA.crt | Bin 0 -> 1053 bytes keychains/certs/JITC_Class3Mail_CA.crt | Bin 0 -> 1055 bytes keychains/certs/acClasse0_0.cer | Bin 0 -> 711 bytes keychains/certs/acClasse0_1.cer | Bin 0 -> 783 bytes keychains/certs/acClasse1_0.cer | Bin 0 -> 782 bytes keychains/certs/acClasse1_1.cer | Bin 0 -> 711 bytes keychains/certs/acClasse2_0.cer | Bin 0 -> 782 bytes keychains/certs/acClasse2_1.cer | Bin 0 -> 712 bytes keychains/certs/acClasse3_0.cer | Bin 0 -> 783 bytes keychains/certs/acClasse3_1.cer | Bin 0 -> 711 bytes keychains/certs/acClasse4.cer | Bin 0 -> 794 bytes keychains/certs/acClasse5.cer | Bin 0 -> 774 bytes keychains/certs/acCps2_2.cer | Bin 0 -> 685 bytes keychains/certs/gipCps0.cer | Bin 0 -> 690 bytes keychains/certscript | 24 + keychains/makecerts | 24 + keychains/roots/2048CA.cer | Bin 0 -> 1120 bytes keychains/roots/GClient_cert.cer | Bin 0 -> 1159 bytes keychains/roots/GeoTrust_Global_CA.cer | Bin 0 -> 856 bytes keychains/roots/JITC_Class3_root.cer | Bin 0 -> 637 bytes keychains/roots/clientCA.cer | Bin 0 -> 1265 bytes keychains/roots/gipCps1.cer | Bin 0 -> 807 bytes keychains/roots/globalSignRoot.cer | Bin 0 -> 889 bytes keychains/roots/gssl_64.cer | Bin 0 -> 1177 bytes keychains/roots/webroot.cer | Bin 0 -> 1244 bytes symbol_strip.sh | 31 +- 1056 files changed, 66070 insertions(+), 220648 deletions(-) create mode 100644 AppleCSP/AppleCSP/AppleCSPKeys.cpp create mode 100644 AppleCSP/AppleCSP/AppleCSPKeys.h create mode 100644 AppleCSP/AppleCSP/pkcs8.cpp rename SecuritySNACCRuntime/policy.h => AppleCSP/AppleCSP/pkcs8.h (71%) delete mode 100644 AppleCSP/AppleCSP/pkcs_7_8.cpp delete mode 100644 AppleCSP/AppleCSP/pkcs_7_8.h delete mode 100644 AppleCSP/CryptKit/.cvsignore delete mode 100644 AppleCSP/CryptKit/ByteRep.txt create mode 100644 AppleCSP/CryptKitCSP/CryptKitAsn1.cpp create mode 100644 AppleCSP/CryptKitCSP/CryptKitAsn1.h create mode 100644 AppleCSP/MiscCSPAlgs/bfContext.cpp create mode 100644 AppleCSP/MiscCSPAlgs/bfContext.h create mode 100644 AppleCSP/MiscCSPAlgs/castContext.cpp create mode 100644 AppleCSP/MiscCSPAlgs/castContext.h create mode 100644 AppleCSP/MiscCSPAlgs/pkcs12Derive.cpp create mode 100644 AppleCSP/MiscCSPAlgs/pkcs12Derive.h create mode 100644 AppleCSP/PBKDF2/pbkdDigest.cpp create mode 100644 AppleCSP/PBKDF2/pbkdDigest.h create mode 100644 AppleCSP/open_ssl/LICENSE create mode 100644 AppleCSP/open_ssl/bf/COPYRIGHT create mode 100644 AppleCSP/open_ssl/bf/README create mode 100644 AppleCSP/open_ssl/bf/bf_ecb.c create mode 100644 AppleCSP/open_ssl/bf/bf_enc.c create mode 100644 AppleCSP/open_ssl/bf/bf_locl.h create mode 100644 AppleCSP/open_ssl/bf/bf_pi.h create mode 100644 AppleCSP/open_ssl/bf/bf_skey.c create mode 100644 AppleCSP/open_ssl/cast/c_ecb.c create mode 100644 AppleCSP/open_ssl/cast/c_enc.c create mode 100644 AppleCSP/open_ssl/cast/c_skey.c create mode 100644 AppleCSP/open_ssl/cast/cast_lcl.h create mode 100644 AppleCSP/open_ssl/cast/cast_s.h create mode 100644 AppleCSP/open_ssl/openssl/blowfish.h create mode 100644 AppleCSP/open_ssl/openssl/cast.h delete mode 100644 AppleCSP/open_ssl/opensslUtils/openRsaSnacc.cpp delete mode 100644 AppleCSP/open_ssl/opensslUtils/openRsaSnacc.h create mode 100644 AppleCSP/open_ssl/opensslUtils/opensslAsn1.cpp create mode 100644 AppleCSP/open_ssl/opensslUtils/opensslAsn1.h create mode 100644 AppleCSP/open_ssl/opensslUtils/osKeyTemplates.cpp create mode 100644 AppleCSP/open_ssl/opensslUtils/osKeyTemplates.h delete mode 100644 AppleX509CL/AppleX509CL.mcp create mode 100644 AppleX509CL/CLCrlExtensions.cpp rename SecuritySNACCRuntime/tcl-p.c => AppleX509CL/CLCrlExtensions.h (53%) create mode 100644 AppleX509CL/CLFieldsCommon.cpp create mode 100644 AppleX509CL/CLFieldsCommon.h delete mode 100644 AppleX509CL/CertBuilder.cpp delete mode 100644 AppleX509CL/CertBuilder.h create mode 100644 AppleX509CL/CrlFields.cpp create mode 100644 AppleX509CL/DecodedCrl.cpp create mode 100644 AppleX509CL/DecodedCrl.h create mode 100644 AppleX509CL/DecodedExtensions.cpp create mode 100644 AppleX509CL/DecodedExtensions.h create mode 100644 AppleX509CL/DecodedItem.cpp create mode 100644 AppleX509CL/DecodedItem.h delete mode 100644 AppleX509CL/SnaccUtils.cpp delete mode 100644 AppleX509CL/SnaccUtils.h create mode 100644 AppleX509CL/clNameUtils.cpp create mode 100644 AppleX509CL/clNameUtils.h create mode 100644 AppleX509CL/clNssUtils.cpp create mode 100644 AppleX509CL/clNssUtils.h delete mode 100644 AppleX509CL/cldebugging.c create mode 100644 AppleX509TP/TPCrlInfo.cpp create mode 100644 AppleX509TP/TPCrlInfo.h create mode 100644 AppleX509TP/TPDatabase.cpp create mode 100644 AppleX509TP/TPDatabase.h create mode 100644 AppleX509TP/TPNetwork.cpp create mode 100644 AppleX509TP/TPNetwork.h create mode 100644 AppleX509TP/tpCrlVerify.cpp create mode 100644 AppleX509TP/tpCrlVerify.h delete mode 100644 AppleX509TP/tpdebugging.c rename CertTool/cdsaUtils/cdsaUtils.c => CdsaUtils/cuCdsaUtils.cpp (66%) create mode 100644 CdsaUtils/cuCdsaUtils.h create mode 100644 CdsaUtils/cuDbUtils.cpp create mode 100644 CdsaUtils/cuDbUtils.h rename {CertTool/cdsaUtils => CdsaUtils}/cuEnc64.c (85%) create mode 100644 CdsaUtils/cuEnc64.h create mode 100644 CdsaUtils/cuFileIo.c create mode 100644 CdsaUtils/cuFileIo.h rename CertTool/cdsaUtils/oidParser.cpp => CdsaUtils/cuOidParser.cpp (86%) create mode 100644 CdsaUtils/cuOidParser.h create mode 100644 CdsaUtils/cuPem.cpp create mode 100644 CdsaUtils/cuPem.h rename CertTool/cdsaUtils/printCert.cpp => CdsaUtils/cuPrintCert.cpp (52%) create mode 100644 CdsaUtils/cuPrintCert.h create mode 100644 CdsaUtils/cuTimeStr.cpp create mode 100644 CdsaUtils/cuTimeStr.h create mode 100644 CertTool/CertTool.cpp delete mode 100644 CertTool/CertTool/CertTool.cpp delete mode 100644 CertTool/CertTool/CertUI.h rename CertTool/{CertTool => }/CertUI.cpp (79%) create mode 100644 CertTool/CertUI.h delete mode 100644 CertTool/cdsaUtils/cuEnc64.h delete mode 100644 CertTool/cdsaUtils/fileIo.c delete mode 100644 CertTool/cdsaUtils/fileIo.h delete mode 100644 CertTool/cdsaUtils/oidParser.h delete mode 100644 CertTool/cdsaUtils/pem.cpp delete mode 100644 CertTool/cdsaUtils/pem.h delete mode 100644 CertTool/cdsaUtils/printCert.h delete mode 100644 CertTool/cdsaUtils/timeStr.cpp delete mode 100644 CertTool/cdsaUtils/timeStr.h create mode 100644 CertTool/certtool.1 rename CertTool/{cdsaUtils => }/dumpasn1.cfg (99%) create mode 100644 CrlRefresh/crlRefresh.cpp create mode 100644 CrlRefresh/ldapFetch.cpp create mode 100644 CrlRefresh/ldapFetch.h delete mode 100644 Keychain/DefaultKeychain.cpp delete mode 100644 Keychain/DefaultKeychain.h create mode 100644 Keychain/ExecCLITool.cpp create mode 100644 Keychain/ExecCLITool.h create mode 100644 Keychain/FileVaultSPI.cpp create mode 100644 Keychain/FileVaultSPI.h delete mode 100644 Keychain/Refs.h create mode 100644 Keychain/SFFileVault.cpp create mode 100644 Keychain/SFFileVault.h create mode 100644 Keychain/SecAccessPriv.h create mode 100644 Keychain/SecCertificatePriv.h create mode 100644 Keychain/SecFileVaultCert.cpp create mode 100644 Keychain/SecFileVaultCert.h rename SecuritySNACCRuntime/c++-lib/inc/policy.h => Keychain/SecIdentityPriv.h (66%) create mode 100644 Keychain/SecKeychainAddIToolsPassword.c create mode 100644 Keychain/SecPolicyPriv.h create mode 100644 Keychain/SecTrustPriv.h create mode 100644 Keychain/SecTrustedApplicationPriv.h create mode 100644 Keychain/generateErrStrings.pl create mode 100644 Keychain/iToolsTrustedApps.plist create mode 100644 Keychain/srCdsaUtils.cpp rename CertTool/cdsaUtils/cdsaUtils.h => Keychain/srCdsaUtils.h (75%) create mode 100644 Security.order delete mode 100644 SecurityASN1/CVSVersionInfo.txt delete mode 100644 SecurityASN1/Makefile delete mode 100644 SecurityASN1/PkcsCms.pbproj/project.pbxproj delete mode 100644 SecurityASN1/asn/appleoids.asn delete mode 100644 SecurityASN1/asn/asn-useful.asn1 delete mode 100644 SecurityASN1/asn/pkcs1.asn1 delete mode 100644 SecurityASN1/asn/pkcs10.asn delete mode 100644 SecurityASN1/asn/pkcs1oids.asn delete mode 100644 SecurityASN1/asn/pkcs5.asn1 delete mode 100644 SecurityASN1/asn/pkcs7.asn delete mode 100644 SecurityASN1/asn/pkcs8.asn delete mode 100644 SecurityASN1/asn/pkcs9oids.asn delete mode 100644 SecurityASN1/asn/sm_cms.asn delete mode 100644 SecurityASN1/asn/sm_ess.asn delete mode 100644 SecurityASN1/asn/sm_vdatypes.asn delete mode 100644 SecurityASN1/asn/sm_x411mtsas.asn delete mode 100644 SecurityASN1/asn/sm_x411ub.asn delete mode 100644 SecurityASN1/asn/sm_x501if.asn delete mode 100644 SecurityASN1/asn/sm_x501ud.asn delete mode 100644 SecurityASN1/asn/sm_x509af.asn delete mode 100644 SecurityASN1/asn/sm_x509ce.asn delete mode 100644 SecurityASN1/asn/sm_x509cmn.asn delete mode 100644 SecurityASN1/asn/sm_x520sa.asn delete mode 100644 SecurityASN1/c++/.cvsignore delete mode 100644 SecurityASN1/c++/appleoids.cpp delete mode 100644 SecurityASN1/c++/pkcs10.cpp delete mode 100644 SecurityASN1/c++/pkcs1oids.cpp delete mode 100644 SecurityASN1/c++/pkcs7.cpp delete mode 100644 SecurityASN1/c++/pkcs8.cpp delete mode 100644 SecurityASN1/c++/pkcs9oids.cpp delete mode 100644 SecurityASN1/c++/sm_cms.cpp delete mode 100644 SecurityASN1/c++/sm_ess.cpp delete mode 100644 SecurityASN1/c++/sm_vdatypes.cpp delete mode 100644 SecurityASN1/c++/sm_x411mtsas.cpp delete mode 100644 SecurityASN1/c++/sm_x411ub.cpp delete mode 100644 SecurityASN1/c++/sm_x501if.cpp delete mode 100644 SecurityASN1/c++/sm_x501ud.cpp delete mode 100644 SecurityASN1/c++/sm_x509af.cpp delete mode 100644 SecurityASN1/c++/sm_x509ce.cpp delete mode 100644 SecurityASN1/c++/sm_x509cmn.cpp delete mode 100644 SecurityASN1/c++/sm_x520sa.cpp delete mode 100644 SecurityASN1/inc/.cvsignore delete mode 100644 SecurityASN1/inc/appleoids.h delete mode 100644 SecurityASN1/inc/pkcs10.h delete mode 100644 SecurityASN1/inc/pkcs1oids.h delete mode 100644 SecurityASN1/inc/pkcs7.h delete mode 100644 SecurityASN1/inc/pkcs8.h delete mode 100644 SecurityASN1/inc/pkcs9oids.h delete mode 100644 SecurityASN1/inc/sm_cms.h delete mode 100644 SecurityASN1/inc/sm_ess.h delete mode 100644 SecurityASN1/inc/sm_vdatypes.h delete mode 100644 SecurityASN1/inc/sm_x411mtsas.h delete mode 100644 SecurityASN1/inc/sm_x411ub.h delete mode 100644 SecurityASN1/inc/sm_x501if.h delete mode 100644 SecurityASN1/inc/sm_x501ud.h delete mode 100644 SecurityASN1/inc/sm_x509af.h delete mode 100644 SecurityASN1/inc/sm_x509ce.h delete mode 100644 SecurityASN1/inc/sm_x509cmn.h delete mode 100644 SecurityASN1/inc/sm_x520sa.h delete mode 100644 SecuritySNACCRuntime/.cvsignore delete mode 100644 SecuritySNACCRuntime/Apple_README delete mode 100644 SecuritySNACCRuntime/COPYING delete mode 100644 SecuritySNACCRuntime/CVSVersionInfo.txt delete mode 100644 SecuritySNACCRuntime/ChangeLog delete mode 100644 SecuritySNACCRuntime/INSTALL delete mode 100755 SecuritySNACCRuntime/MacOSX-Install delete mode 100644 SecuritySNACCRuntime/MacOSX-configure delete mode 100644 SecuritySNACCRuntime/MacOSX-make delete mode 100644 SecuritySNACCRuntime/NEWS delete mode 100644 SecuritySNACCRuntime/README delete mode 100644 SecuritySNACCRuntime/VDADER_RULES.TXT delete mode 100644 SecuritySNACCRuntime/acconfig.h delete mode 100644 SecuritySNACCRuntime/asn1specs/any.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/asn-useful.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/asn1module.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/err-test.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/ex1.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/install-sh delete mode 100644 SecuritySNACCRuntime/asn1specs/makefile delete mode 100644 SecuritySNACCRuntime/asn1specs/p-rec.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/rfc1155-smi.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/rfc1157-snmp.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/rfc1213-mib2.asn1 delete mode 100644 SecuritySNACCRuntime/asn1specs/tbl.asn1 delete mode 100644 SecuritySNACCRuntime/c++-examples/any/README delete mode 100644 SecuritySNACCRuntime/c++-examples/any/example.C delete mode 100644 SecuritySNACCRuntime/c++-examples/any/genber.C delete mode 100644 SecuritySNACCRuntime/c++-examples/any/makefile delete mode 100644 SecuritySNACCRuntime/c++-examples/makefile delete mode 100644 SecuritySNACCRuntime/c++-examples/simple/README delete mode 100644 SecuritySNACCRuntime/c++-examples/simple/example.C delete mode 100644 SecuritySNACCRuntime/c++-examples/simple/genber.C delete mode 100644 SecuritySNACCRuntime/c++-examples/simple/good-pr.ber delete mode 100644 SecuritySNACCRuntime/c++-examples/simple/makefile delete mode 100644 SecuritySNACCRuntime/c++-examples/snmp/README delete mode 100644 SecuritySNACCRuntime/c++-examples/snmp/makefile delete mode 100644 SecuritySNACCRuntime/c++-examples/test-lib/README delete mode 100644 SecuritySNACCRuntime/c++-examples/test-lib/makefile delete mode 100644 SecuritySNACCRuntime/c++-examples/test-lib/test-lib.C delete mode 100644 SecuritySNACCRuntime/c++-lib/README delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-any.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-bits.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-bool.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-enum.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-int.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-len.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-list.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-null.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-octs.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-oid.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-real.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-tag.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-type.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/asn-useful.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/hash.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/meta.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/print.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/str-stk.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/tcl-if.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/c++/tkAppInit.c delete mode 100644 SecuritySNACCRuntime/c++-lib/dependencies delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-any.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-bits.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-bool.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-buf.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-config.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-enum.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-incl.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-int.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-len.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-list.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-null.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-octs.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-oid.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-real.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-tag.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-type.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/asn-useful.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/cdsaUtils.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/config.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/hash.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/init.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/meta.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/print.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/sm_vdasnacc.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/sm_vdatypes.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/snacc.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/str-stk.h delete mode 100644 SecuritySNACCRuntime/c++-lib/inc/tcl-if.h delete mode 100644 SecuritySNACCRuntime/c++-lib/install-sh delete mode 100644 SecuritySNACCRuntime/c++-lib/makefile delete mode 100644 SecuritySNACCRuntime/c++-lib/src/asn-useful.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/src/cdsaUtils.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/src/sm_buffer.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/src/sm_vdasnacc.cpp delete mode 100644 SecuritySNACCRuntime/c++-lib/src/tkAppInit.c delete mode 100644 SecuritySNACCRuntime/c++-lib/stamp-useful delete mode 100644 SecuritySNACCRuntime/c-examples/any/README delete mode 100644 SecuritySNACCRuntime/c-examples/any/example.c delete mode 100644 SecuritySNACCRuntime/c-examples/any/genber.c delete mode 100644 SecuritySNACCRuntime/c-examples/any/makefile delete mode 100644 SecuritySNACCRuntime/c-examples/makefile delete mode 100644 SecuritySNACCRuntime/c-examples/simple/README delete mode 100644 SecuritySNACCRuntime/c-examples/simple/expbuf-ex.c delete mode 100644 SecuritySNACCRuntime/c-examples/simple/genber.c delete mode 100644 SecuritySNACCRuntime/c-examples/simple/good-pr.ber delete mode 100644 SecuritySNACCRuntime/c-examples/simple/makefile delete mode 100644 SecuritySNACCRuntime/c-examples/simple/minbuf-ex.c delete mode 100644 SecuritySNACCRuntime/c-examples/simple/sbuf-ex.c delete mode 100644 SecuritySNACCRuntime/c-examples/snmp/README delete mode 100644 SecuritySNACCRuntime/c-examples/snmp/makefile delete mode 100644 SecuritySNACCRuntime/c-examples/test-lib/README delete mode 100644 SecuritySNACCRuntime/c-examples/test-lib/makefile delete mode 100644 SecuritySNACCRuntime/c-examples/test-lib/test-lib.c delete mode 100644 SecuritySNACCRuntime/c-lib/.cvsignore delete mode 100644 SecuritySNACCRuntime/c-lib/README delete mode 100644 SecuritySNACCRuntime/c-lib/asn-useful.c delete mode 100644 SecuritySNACCRuntime/c-lib/asn-useful.h delete mode 100644 SecuritySNACCRuntime/c-lib/boot/asn-useful.c delete mode 100644 SecuritySNACCRuntime/c-lib/boot/asn-useful.h delete mode 100644 SecuritySNACCRuntime/c-lib/boot/tbl.c delete mode 100644 SecuritySNACCRuntime/c-lib/boot/tbl.h delete mode 100644 SecuritySNACCRuntime/c-lib/dependencies delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-any.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-bits.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-bool.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-config.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-enum.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-incl.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-int.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-len.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-list.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-null.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-octs.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-oid.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-real.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-tag.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/asn-useful.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/exp-buf.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/gen-buf.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/hash.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/mem.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/min-buf.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/nibble-alloc.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/print.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/sbuf.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/str-stk.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl-dec.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl-enc.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl-free.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl-gen-c-hdr.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl-gen.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl-incl.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl-print.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl-util.h delete mode 100644 SecuritySNACCRuntime/c-lib/inc/tbl.h delete mode 100644 SecuritySNACCRuntime/c-lib/install-sh delete mode 100644 SecuritySNACCRuntime/c-lib/makefile delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-any.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-bits.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-bool.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-enum.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-int.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-len.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-list.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-null.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-octs.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-oid.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-real.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-tag.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/asn-useful.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/exp-buf.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/hash.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/nibble-alloc.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/print.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/sbuf.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/str-stk.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/tbl-dbg.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/tbl-dec.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/tbl-enc.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/tbl-free.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/tbl-gen.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/tbl-print.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/tbl-util.c delete mode 100644 SecuritySNACCRuntime/c-lib/src/tbl.c delete mode 100644 SecuritySNACCRuntime/c-lib/stamp-tbl delete mode 100644 SecuritySNACCRuntime/c-lib/stamp-useful delete mode 100644 SecuritySNACCRuntime/c-lib/tbl.c delete mode 100644 SecuritySNACCRuntime/c-lib/tbl.h delete mode 100644 SecuritySNACCRuntime/c-lib/tbl.h.patch delete mode 100644 SecuritySNACCRuntime/compiler/README delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/.cvsignore delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-any.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-any.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-code.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-code.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-vals.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-vals.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/kwd.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/kwd.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/rules.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/rules.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/types.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c++-gen/types.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any2.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code2.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-dec.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-dec.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-free.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-free.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-print.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-print.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-type.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-type.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals2.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd2.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/rules.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/rules.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/rules2.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/type-info.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/type-info.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/util.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/c-gen/util.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/cond.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/cond.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-any.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-any.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-code.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-code.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-vals.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-vals.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/rules.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/rules.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/types.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/idl-gen/types.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/str-util.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/str-util.h delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/tag-util.c delete mode 100644 SecuritySNACCRuntime/compiler/back-ends/tag-util.h delete mode 100644 SecuritySNACCRuntime/compiler/boot/tbl.c delete mode 100644 SecuritySNACCRuntime/compiler/boot/tbl.h delete mode 100644 SecuritySNACCRuntime/compiler/core/.cvsignore delete mode 100644 SecuritySNACCRuntime/compiler/core/asn1module.h delete mode 100644 SecuritySNACCRuntime/compiler/core/define.c delete mode 100644 SecuritySNACCRuntime/compiler/core/define.h delete mode 100644 SecuritySNACCRuntime/compiler/core/dependency.c delete mode 100644 SecuritySNACCRuntime/compiler/core/dependency.h delete mode 100644 SecuritySNACCRuntime/compiler/core/do-macros.c delete mode 100644 SecuritySNACCRuntime/compiler/core/do-macros.h delete mode 100644 SecuritySNACCRuntime/compiler/core/err-chk.c delete mode 100644 SecuritySNACCRuntime/compiler/core/err-chk.h delete mode 100644 SecuritySNACCRuntime/compiler/core/exports.c delete mode 100644 SecuritySNACCRuntime/compiler/core/exports.h delete mode 100644 SecuritySNACCRuntime/compiler/core/gen-tbls.c delete mode 100644 SecuritySNACCRuntime/compiler/core/gen-tbls.h delete mode 100644 SecuritySNACCRuntime/compiler/core/lex-asn1.c delete mode 100644 SecuritySNACCRuntime/compiler/core/lex-asn1.l delete mode 100644 SecuritySNACCRuntime/compiler/core/lex-stuff.h delete mode 100644 SecuritySNACCRuntime/compiler/core/lib-types.c delete mode 100644 SecuritySNACCRuntime/compiler/core/lib-types.h delete mode 100644 SecuritySNACCRuntime/compiler/core/link-types.c delete mode 100644 SecuritySNACCRuntime/compiler/core/link-types.h delete mode 100644 SecuritySNACCRuntime/compiler/core/link-values.c delete mode 100644 SecuritySNACCRuntime/compiler/core/link-values.h delete mode 100644 SecuritySNACCRuntime/compiler/core/mem.c delete mode 100644 SecuritySNACCRuntime/compiler/core/meta.c delete mode 100644 SecuritySNACCRuntime/compiler/core/meta.h delete mode 100644 SecuritySNACCRuntime/compiler/core/normalize.c delete mode 100644 SecuritySNACCRuntime/compiler/core/normalize.h delete mode 100644 SecuritySNACCRuntime/compiler/core/oid.c delete mode 100644 SecuritySNACCRuntime/compiler/core/oid.h delete mode 100644 SecuritySNACCRuntime/compiler/core/parse-asn1.c delete mode 100644 SecuritySNACCRuntime/compiler/core/parse-asn1.h delete mode 100644 SecuritySNACCRuntime/compiler/core/parse-asn1.y delete mode 100644 SecuritySNACCRuntime/compiler/core/parser.h delete mode 100644 SecuritySNACCRuntime/compiler/core/print.c delete mode 100644 SecuritySNACCRuntime/compiler/core/print.h delete mode 100644 SecuritySNACCRuntime/compiler/core/print2.c delete mode 100644 SecuritySNACCRuntime/compiler/core/recursive.c delete mode 100644 SecuritySNACCRuntime/compiler/core/recursive.h delete mode 100644 SecuritySNACCRuntime/compiler/core/snacc-util.c delete mode 100644 SecuritySNACCRuntime/compiler/core/snacc-util.h delete mode 100644 SecuritySNACCRuntime/compiler/core/snacc.c delete mode 100644 SecuritySNACCRuntime/compiler/core/tbl.c delete mode 100644 SecuritySNACCRuntime/compiler/core/tbl.h delete mode 100644 SecuritySNACCRuntime/compiler/core/tblCompiler.c delete mode 100644 SecuritySNACCRuntime/compiler/core/val-parser.c delete mode 100644 SecuritySNACCRuntime/compiler/core/val-parser.h delete mode 100644 SecuritySNACCRuntime/compiler/dependencies delete mode 100644 SecuritySNACCRuntime/compiler/install-sh delete mode 100644 SecuritySNACCRuntime/compiler/makefile delete mode 100644 SecuritySNACCRuntime/compiler/stamp-tbl delete mode 100644 SecuritySNACCRuntime/compiler/tbl.c delete mode 100644 SecuritySNACCRuntime/compiler/tbl.h delete mode 100644 SecuritySNACCRuntime/config.cache delete mode 100644 SecuritySNACCRuntime/config.h delete mode 100644 SecuritySNACCRuntime/config.h.in delete mode 100644 SecuritySNACCRuntime/config.log delete mode 100644 SecuritySNACCRuntime/config.status delete mode 100644 SecuritySNACCRuntime/configure delete mode 100644 SecuritySNACCRuntime/configure.in delete mode 100644 SecuritySNACCRuntime/doc/asn1-defs.tex delete mode 100644 SecuritySNACCRuntime/doc/c++-gen.tex delete mode 100644 SecuritySNACCRuntime/doc/c++-lib.tex delete mode 100644 SecuritySNACCRuntime/doc/c-gen.tex delete mode 100644 SecuritySNACCRuntime/doc/c-lib.tex delete mode 100644 SecuritySNACCRuntime/doc/coding.tex delete mode 100644 SecuritySNACCRuntime/doc/corba.bib delete mode 100644 SecuritySNACCRuntime/doc/design.tex delete mode 100644 SecuritySNACCRuntime/doc/editor.tex delete mode 100644 SecuritySNACCRuntime/doc/future-work.tex delete mode 100644 SecuritySNACCRuntime/doc/idl-gen.tex delete mode 100644 SecuritySNACCRuntime/doc/install-sh delete mode 100644 SecuritySNACCRuntime/doc/intro-1.1.tex delete mode 100644 SecuritySNACCRuntime/doc/intro-1.2.tex delete mode 100644 SecuritySNACCRuntime/doc/makefile delete mode 100644 SecuritySNACCRuntime/doc/makefile.tex delete mode 100644 SecuritySNACCRuntime/doc/meta.tex delete mode 100644 SecuritySNACCRuntime/doc/misc-hyph.tex delete mode 100644 SecuritySNACCRuntime/doc/mkchdr.1 delete mode 100644 SecuritySNACCRuntime/doc/modifying.tex delete mode 100644 SecuritySNACCRuntime/doc/ptbl.1 delete mode 100644 SecuritySNACCRuntime/doc/pval.1 delete mode 100644 SecuritySNACCRuntime/doc/snacc.1 delete mode 100644 SecuritySNACCRuntime/doc/snacc.bib delete mode 100644 SecuritySNACCRuntime/doc/snacc.n delete mode 100644 SecuritySNACCRuntime/doc/snacc.tex delete mode 100644 SecuritySNACCRuntime/doc/snacced.1 delete mode 100644 SecuritySNACCRuntime/doc/tcl.bib delete mode 100644 SecuritySNACCRuntime/doc/tcl.tex delete mode 100644 SecuritySNACCRuntime/doc/ttab.tex delete mode 100644 SecuritySNACCRuntime/doc/tumble.sed delete mode 100644 SecuritySNACCRuntime/doc/version.tex delete mode 100644 SecuritySNACCRuntime/install-sh delete mode 100644 SecuritySNACCRuntime/makefile delete mode 100644 SecuritySNACCRuntime/makehead delete mode 100644 SecuritySNACCRuntime/makehead.in delete mode 100644 SecuritySNACCRuntime/makehead.static delete mode 100644 SecuritySNACCRuntime/maketail delete mode 100644 SecuritySNACCRuntime/mkinstalldirs delete mode 100644 SecuritySNACCRuntime/snacc.h delete mode 100644 SecuritySNACCRuntime/snacc.pbproj/project.pbxproj delete mode 100644 SecuritySNACCRuntime/stamp-h delete mode 100644 SecuritySNACCRuntime/stamp-h.in delete mode 100644 SecuritySNACCRuntime/tbl-example/README delete mode 100644 SecuritySNACCRuntime/tbl-example/dependencies delete mode 100644 SecuritySNACCRuntime/tbl-example/example.c delete mode 100644 SecuritySNACCRuntime/tbl-example/makefile delete mode 100644 SecuritySNACCRuntime/tbl-example/p-rec.ber delete mode 100644 SecuritySNACCRuntime/tbl-example/p-rec.h delete mode 100644 SecuritySNACCRuntime/tbl-example/p-rec.tt delete mode 100644 SecuritySNACCRuntime/tbl-tools/makefile delete mode 100644 SecuritySNACCRuntime/tcl-asn/README delete mode 100644 SecuritySNACCRuntime/tcl-asn/asnwish.c delete mode 100644 SecuritySNACCRuntime/tcl-asn/beredit delete mode 100644 SecuritySNACCRuntime/tcl-asn/makefile delete mode 100644 SecuritySNACCRuntime/tcl-asn/tclasn.c delete mode 100644 SecuritySNACCRuntime/tcl-example/dependencies delete mode 100644 SecuritySNACCRuntime/tcl-example/edex0.asn1 delete mode 100644 SecuritySNACCRuntime/tcl-example/edex1.asn1 delete mode 100644 SecuritySNACCRuntime/tcl-example/makefile delete mode 100644 SecuritySNACCRuntime/tcl-lib/bindings.tcl delete mode 100644 SecuritySNACCRuntime/tcl-lib/help.tcl delete mode 100644 SecuritySNACCRuntime/tcl-lib/make-snacced delete mode 100644 SecuritySNACCRuntime/tcl-lib/makefile delete mode 100644 SecuritySNACCRuntime/tcl-lib/selbox.tcl delete mode 100644 SecuritySNACCRuntime/tcl-lib/snacced.tcl delete mode 100644 SecuritySNACCRuntime/tcl-lib/tkuti.tcl delete mode 100644 SecuritySNACCRuntime/tcl-lib/uti.tcl delete mode 100644 SecuritySNACCRuntime/version.h create mode 100644 SecurityServer/Authorization/AuthorizationDB.h create mode 100644 SecurityServer/Authorization/AuthorizationDBPlist.cpp create mode 100644 SecurityServer/Authorization/AuthorizationDBPlist.h create mode 100644 SecurityServer/Authorization/AuthorizationPriv.h create mode 100644 SecurityServer/Authorization/AuthorizationRule.cpp create mode 100644 SecurityServer/Authorization/AuthorizationRule.h rename SecuritySNACCRuntime/c-lib/inc/tbl-dbg.h => SecurityServer/Authorization/privPort.h (56%) create mode 100644 SecurityServer/Authorization/privPortClient.cpp create mode 100644 SecurityServer/Authorization/privPortServer.cpp create mode 100644 SecurityServer/StartupItems/CodeEquivalenceCandidates create mode 100644 SecurityServer/codesigdb.cpp create mode 100644 SecurityServer/codesigdb.h create mode 100644 SecurityServer/dictionary.cpp create mode 100644 SecurityServer/dictionary.h create mode 100644 SecurityServer/eventlistener.cpp create mode 100644 SecurityServer/eventlistener.h create mode 100644 SecurityServer/flippers.cpp create mode 100644 SecurityServer/flippers.h create mode 100644 SecurityServer/generate.cf create mode 100755 SecurityServer/generate.pl create mode 100644 SecurityServer/systemkeychain.cpp create mode 100644 SecurityServer/transwalkers.cpp create mode 100644 SecurityServer/transwalkers.h delete mode 100644 cdsa/cdsa_client/aclsupport.cpp delete mode 100644 cdsa/cdsa_client/aclsupport.h create mode 100644 cdsa/cdsa_utilities/db++.cpp create mode 100644 cdsa/cdsa_utilities/db++.h create mode 100644 cdsa/cdsa_utilities/endian.cpp create mode 100644 cdsa/cdsa_utilities/endian.h create mode 100644 cdsa/cdsa_utilities/fdmover.cpp create mode 100644 cdsa/cdsa_utilities/fdmover.h create mode 100644 cdsa/cdsa_utilities/ktracecodes.h create mode 100644 cdsa/cdsa_utilities/memstreams.h create mode 100644 keychains/X509Certificates create mode 100644 keychains/certs/C3_ID_CA.cer create mode 100644 keychains/certs/C3_Mail_CA.cer create mode 100644 keychains/certs/DOD_CLASS_3_CA-10.cer create mode 100644 keychains/certs/DOD_CLASS_3_CA-3.cer create mode 100644 keychains/certs/DOD_CLASS_3_CA-4.cer create mode 100644 keychains/certs/DOD_CLASS_3_CA-5.cer create mode 100644 keychains/certs/DOD_CLASS_3_CA-6.cer create mode 100644 keychains/certs/DOD_CLASS_3_CA-7.cer create mode 100644 keychains/certs/DOD_CLASS_3_CA-9.cer create mode 100644 keychains/certs/DOD_CLASS_3_CAC_CA.cer create mode 100644 keychains/certs/DOD_CLASS_3_CAC_EMAIL_CA.cer create mode 100644 keychains/certs/DOD_CLASS_3_EMAIL_CA-10.cer create mode 100644 keychains/certs/DOD_CLASS_3_EMAIL_CA-3.cer create mode 100644 keychains/certs/DOD_CLASS_3_EMAIL_CA-4.cer create mode 100644 keychains/certs/DOD_CLASS_3_EMAIL_CA-5.cer create mode 100644 keychains/certs/DOD_CLASS_3_EMAIL_CA-6.cer create mode 100644 keychains/certs/DOD_CLASS_3_EMAIL_CA-7.cer create mode 100644 keychains/certs/DOD_CLASS_3_EMAIL_CA-9.cer create mode 100644 keychains/certs/GeoTrust_True_Credentials_CA_2.cer create mode 100644 keychains/certs/JITC_Class3ID_CA.crt create mode 100644 keychains/certs/JITC_Class3Mail_CA.crt create mode 100644 keychains/certs/acClasse0_0.cer create mode 100644 keychains/certs/acClasse0_1.cer create mode 100644 keychains/certs/acClasse1_0.cer create mode 100644 keychains/certs/acClasse1_1.cer create mode 100644 keychains/certs/acClasse2_0.cer create mode 100644 keychains/certs/acClasse2_1.cer create mode 100644 keychains/certs/acClasse3_0.cer create mode 100644 keychains/certs/acClasse3_1.cer create mode 100644 keychains/certs/acClasse4.cer create mode 100644 keychains/certs/acClasse5.cer create mode 100644 keychains/certs/acCps2_2.cer create mode 100644 keychains/certs/gipCps0.cer create mode 100755 keychains/certscript create mode 100755 keychains/makecerts create mode 100644 keychains/roots/2048CA.cer create mode 100644 keychains/roots/GClient_cert.cer create mode 100644 keychains/roots/GeoTrust_Global_CA.cer create mode 100644 keychains/roots/JITC_Class3_root.cer create mode 100644 keychains/roots/clientCA.cer create mode 100644 keychains/roots/gipCps1.cer create mode 100644 keychains/roots/globalSignRoot.cer create mode 100644 keychains/roots/gssl_64.cer create mode 100644 keychains/roots/webroot.cer diff --git a/AppleCSP/AES/aescsp.cpp b/AppleCSP/AES/aescsp.cpp index 5377e319..5fa79cad 100644 --- a/AppleCSP/AES/aescsp.cpp +++ b/AppleCSP/AES/aescsp.cpp @@ -181,7 +181,7 @@ void AESContext::init( /* common standard path */ mEncryptFcn = rijndaelBlockEncrypt; mDecryptFcn = rijndaelBlockDecrypt; -#endif !GLADMAN_AES_128_ENABLE +#endif /* !GLADMAN_AES_128_ENABLE */ /* Finally, have BlockCryptor do its setup */ setup(mBlockSize, context); diff --git a/AppleCSP/AES/gladmanContext.cpp b/AppleCSP/AES/gladmanContext.cpp index 63d8fe51..ac3922ed 100644 --- a/AppleCSP/AES/gladmanContext.cpp +++ b/AppleCSP/AES/gladmanContext.cpp @@ -132,7 +132,7 @@ void GAESContext::init( set_key((u4byte *)keyData, keyLen * 8, &mAesKey); /* save this raw key data */ - memmove(mRawKey, keyData, mRawKeySize); + memmove(mRawKey, keyData, keyLen); mRawKeySize = keyLen; } diff --git a/AppleCSP/AES/rijndael-alg-ref.c b/AppleCSP/AES/rijndael-alg-ref.c index 22179cd4..e9bc4870 100644 --- a/AppleCSP/AES/rijndael-alg-ref.c +++ b/AppleCSP/AES/rijndael-alg-ref.c @@ -53,6 +53,8 @@ static const word8 shifts[3][4][2] = { } }; +#if !GLADMAN_AES_128_ENABLE + /* 128 bit key/word shift table in bits */ static const word8 shifts128[4][2] = { { 0, 0 }, @@ -61,6 +63,8 @@ static const word8 shifts128[4][2] = { { 24, 8 } }; +#endif /* GLADMAN_AES_128_ENABLE */ + #if !AES_MUL_BY_LOOKUP /* * Profiling measurements showed that the mul routine is where a large propertion of @@ -73,6 +77,7 @@ static const word8 shifts128[4][2] = { * and 1.88 for decrypt. (Decrypt wins more for this enhancement because the * InvMixColumn does four muls, vs. 2 muls for MixColumn). Measurements taken * on a 500 MHz G4 with 1 MB of L2 cache. + */ /* * The mod 255 op in mul is really expensive... diff --git a/AppleCSP/AES/rijndaelApi.c b/AppleCSP/AES/rijndaelApi.c index aba5b870..67e84235 100644 --- a/AppleCSP/AES/rijndaelApi.c +++ b/AppleCSP/AES/rijndaelApi.c @@ -121,7 +121,8 @@ int rijndaelBlockEncrypt( word8 *input, word8 *outBuffer) { - int j, t; + int t; + unsigned j; word8 localBlock[4][MAXBC]; // working memory: encrypt/decrypt in place here #if AES_CONSISTENCY_CHECK @@ -159,7 +160,8 @@ int rijndaelBlockDecrypt( word8 *input, word8 *outBuffer) { - int j, t; + int t; + unsigned j; word8 localBlock[4][MAXBC]; // working memory: encrypt/decrypt in place here #if AES_CONSISTENCY_CHECK diff --git a/AppleCSP/AppleCSP/AppleCSP.cpp b/AppleCSP/AppleCSP/AppleCSP.cpp index e51ec979..e03be7b9 100644 --- a/AppleCSP/AppleCSP/AppleCSP.cpp +++ b/AppleCSP/AppleCSP/AppleCSP.cpp @@ -382,6 +382,8 @@ void AppleCSPSession::addRefKey( cssmKey.KeyHeader.BlobType = CSSM_KEYBLOB_REFERENCE; cssmKey.KeyHeader.Format = CSSM_KEYBLOB_REF_FORMAT_INTEGER; keyRefToCssmData(keyRef, cssmKey.KeyData, normAllocator); + secdebug("freeKey", "CSP addRefKey key %p keyData %p keyRef %p", + &cssmKey, cssmKey.KeyData.Data, &binKey); } // Given a CssmKey in reference form, obtain the associated @@ -425,6 +427,7 @@ void AppleCSPSession::FreeKey( CssmKey &KeyPtr, CSSM_BOOL Delete) { + if((KeyPtr.blobType() == CSSM_KEYBLOB_REFERENCE) && (KeyPtr.cspGuid() == plugin.myGuid())) { // it's a ref key we generated - delete associated BinaryKey @@ -433,6 +436,8 @@ void AppleCSPSession::FreeKey( StLock _(refKeyMapLock); BinaryKey *binKey = lookupKeyRef(keyRef); if(binKey != NULL) { + secdebug("freeKey", "CSP FreeKey key %p keyData %p binKey %p", + &KeyPtr, KeyPtr.KeyData.Data, binKey); try { refKeyMap.erase(keyRef); delete binKey; @@ -442,6 +447,9 @@ void AppleCSPSession::FreeKey( "ref key\n"); } } + else { + secdebug("freeKey", "CSP freeKey unknown key"); + } } } CSPFullPluginSession::FreeKey(AccessCred, KeyPtr, Delete); @@ -480,32 +488,64 @@ void AppleCSPSession::PassThrough( } /* - * Ref key: obtain binary and blob - * Raw key: already have the blob + * Ref key: obtain binary, ask it for blob + * Raw key: get info provider, ask it for the blob. This + * allows for an optimized path which avoids + * converting to a BinaryKey. */ - CssmData rawBlob; - bool allocdRawBlob = false; + CssmData blobToHash; switch(key.blobType()) { case CSSM_KEYBLOB_RAW: - /* trivial case */ - rawBlob = CssmData::overlay(key.KeyData); + { + CSPKeyInfoProvider *provider = infoProvider(key); + bool converted = + provider->getHashableBlob(privAllocator, blobToHash); + if(converted) { + /* took optimized case; proceed */ + delete provider; + break; + } + + /* convert to BinaryKey and ask it to do the work */ + BinaryKey *binKey; + CSSM_KEYATTR_FLAGS flags = 0; // not used + provider->CssmKeyToBinary(NULL, // no paramKey + flags, + &binKey); + binKey->mKeyHeader = + CssmKey::Header::overlay(key.KeyHeader); + CSSM_KEYBLOB_FORMAT rawFormat; + rawFormat = CSSM_KEYBLOB_RAW_FORMAT_DIGEST; + CSSM_KEYATTR_FLAGS attrFlags = 0; + binKey->generateKeyBlob(privAllocator, + blobToHash, + rawFormat, + *this, + NULL, + attrFlags); + delete binKey; + delete provider; break; + } case CSSM_KEYBLOB_REFERENCE: { BinaryKey &binKey = lookupRefKey(key); CSSM_KEYBLOB_FORMAT rawFormat; - rawFormat = requestedKeyFormat(Context, key); + rawFormat = CSSM_KEYBLOB_RAW_FORMAT_DIGEST; + CSSM_KEYATTR_FLAGS attrFlags = 0; binKey.generateKeyBlob(privAllocator, - rawBlob, - rawFormat); + blobToHash, + rawFormat, + *this, + NULL, + attrFlags); } - allocdRawBlob = true; // remember - we need to free break; default: CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); } - /* obtain sha1 hash of rawBlob */ + /* obtain sha1 hash of blobToHash */ CSSM_DATA_PTR outHash = NULL; try { @@ -516,15 +556,12 @@ void AppleCSPSession::PassThrough( outHash->Length = SHA1_DIGEST_SIZE; } catch(...) { - if(allocdRawBlob) { - freeCssmData(rawBlob, privAllocator); - } + freeCssmData(blobToHash, privAllocator); throw; } - cspGenSha1Hash(rawBlob.data(), rawBlob.length(), outHash->Data); - if(allocdRawBlob) { - freeCssmData(rawBlob, privAllocator); - } + cspGenSha1Hash(blobToHash.data(), blobToHash.length(), + outHash->Data); + freeCssmData(blobToHash, privAllocator); *OutData = outHash; return; } @@ -541,7 +578,14 @@ void AppleCSPSession::getKeySize(const CssmKey &key, CSSM_KEY_SIZE &size) { CSPKeyInfoProvider *provider = infoProvider(key); - provider->QueryKeySizeInBits(size); + try { + provider->QueryKeySizeInBits(size); + } + catch(...) { + /* don't leak this on error */ + delete provider; + throw; + } delete provider; } @@ -610,80 +654,39 @@ CSPKeyInfoProvider *AppleCSPSession::infoProvider( #ifdef BSAFE_CSP_ENABLE /* Give BSAFE first shot, if it's here */ - provider = BSafe::BSafeKeyInfoProvider::provider(key); + provider = BSafe::BSafeKeyInfoProvider::provider(key, *this); if(provider != NULL) { return provider; } #endif - provider = RSAKeyInfoProvider::provider(key); + provider = RSAKeyInfoProvider::provider(key, *this); if(provider != NULL) { return provider; } - provider = SymmetricKeyInfoProvider::provider(key); + provider = SymmetricKeyInfoProvider::provider(key, *this); if(provider != NULL) { return provider; } #ifdef CRYPTKIT_CSP_ENABLE - provider = CryptKit::FEEKeyInfoProvider::provider(key); + provider = CryptKit::FEEKeyInfoProvider::provider(key, *this); if(provider != NULL) { return provider; } #endif - provider = DSAKeyInfoProvider::provider(key); + provider = DSAKeyInfoProvider::provider(key, *this); if(provider != NULL) { return provider; } - CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); -} - -/* - * CSPKeyInfoProvider for symmetric keys. - */ -CSPKeyInfoProvider *SymmetricKeyInfoProvider::provider( - const CssmKey &cssmKey) -{ - if(cssmKey.blobType() != CSSM_KEYBLOB_RAW) { - errorLog0("KeyInfoProvider deals only with RAW keys!\n"); - CssmError::throwMe(CSSMERR_CSP_INTERNAL_ERROR); - } - if(cssmKey.keyClass() != CSSM_KEYCLASS_SESSION_KEY) { - /* that's all we need to know */ - return NULL; + provider = DHKeyInfoProvider::provider(key, *this); + if(provider != NULL) { + return provider; } - return new SymmetricKeyInfoProvider(cssmKey); -} - -SymmetricKeyInfoProvider::SymmetricKeyInfoProvider( - const CssmKey &cssmKey) : - CSPKeyInfoProvider(cssmKey) -{ -} - -/* cook up a Binary key */ -void SymmetricKeyInfoProvider::CssmKeyToBinary( - BinaryKey **binKey) -{ - CASSERT(mKey.keyClass() == CSSM_KEYCLASS_SESSION_KEY); - SymmetricBinaryKey *symBinKey = new SymmetricBinaryKey( - mKey.KeyHeader.LogicalKeySizeInBits); - copyCssmData(mKey, - symBinKey->mKeyData, - symBinKey->mAllocator); - *binKey = symBinKey; -} - -/* obtain key size in bits */ -void SymmetricKeyInfoProvider::QueryKeySizeInBits( - CSSM_KEY_SIZE &keySize) -{ - /* FIXME - do we ever need to calculate RC2 effective size here? */ - keySize.LogicalKeySizeInBits = keySize.EffectiveKeySizeInBits = - mKey.length() * 8; + + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); } - diff --git a/AppleCSP/AppleCSP/AppleCSPContext.cpp b/AppleCSP/AppleCSP/AppleCSPContext.cpp index 0bccf355..babd9af3 100644 --- a/AppleCSP/AppleCSP/AppleCSPContext.cpp +++ b/AppleCSP/AppleCSP/AppleCSPContext.cpp @@ -51,6 +51,7 @@ void AppleCSPContext::symmetricKeyBits( CssmError::throwMe(CSSMERR_CSP_ALGID_MISMATCH); } cspValidateIntendedKeyUsage(&key.KeyHeader, intendedUse); + cspVerifyKeyTimes(key.KeyHeader); /* extract raw bits one way or the other */ switch(key.blobType()) { @@ -116,7 +117,10 @@ void AppleKeyPairGenContext::generate( privHdr.KeyAttr &= ~KEY_ATTR_RETURN_MASK; // Handle key formatting. Delete the BinaryKeys if - // we're not creating ref keys. + // we're not creating ref keys, after safe completion of + // generateKeyBlob (which may throw, in which case the binary keys + // get deleted by our caller). + CSSM_KEYATTR_FLAGS attrFlags = 0; switch(pubStorage) { case CKS_Ref: session.addRefKey(*pubBinKey, pubKey); @@ -127,11 +131,12 @@ void AppleKeyPairGenContext::generate( pubBinKey->generateKeyBlob( session.normAlloc(), // alloc in user space CssmData::overlay(pubKey.KeyData), - pubHdr.Format); - delete pubBinKey; + pubHdr.Format, + session, + NULL, // no paramKey here! + attrFlags); break; case CKS_None: - delete pubBinKey; break; } switch(privStorage) { @@ -144,13 +149,20 @@ void AppleKeyPairGenContext::generate( privBinKey->generateKeyBlob( session.normAlloc(), // alloc in user space CssmData::overlay(privKey.KeyData), - privHdr.Format); - delete privBinKey; + privHdr.Format, + session, + NULL, + attrFlags); break; case CKS_None: - delete privBinKey; break; } + if(pubStorage != CKS_Ref) { + delete pubBinKey; + } + if(privStorage != CKS_Ref) { + delete privBinKey; + } } /* @@ -239,11 +251,15 @@ SymmetricBinaryKey::~SymmetricBinaryKey() void SymmetricBinaryKey::generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format) // CSSM_KEYBLOB_RAW_FORMAT_PKCS1, etc. + CSSM_KEYBLOB_FORMAT &format, // CSSM_KEYBLOB_RAW_FORMAT_PKCS1, etc. + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags) /* IN/OUT */ { switch(format) { case CSSM_KEYBLOB_RAW_FORMAT_NONE: // default case CSSM_KEYBLOB_RAW_FORMAT_OCTET_STRING: // the one we can do + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: // same thing break; default: CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_SYMMETRIC_KEY_FORMAT); diff --git a/AppleCSP/AppleCSP/AppleCSPKeys.cpp b/AppleCSP/AppleCSP/AppleCSPKeys.cpp new file mode 100644 index 00000000..b9ed3ec1 --- /dev/null +++ b/AppleCSP/AppleCSP/AppleCSPKeys.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ +/* + * AppleCSPKeys.cpp - Key support + */ + +#include "AppleCSPKeys.h" +#include "AppleCSPUtils.h" +/* + * CSPKeyInfoProvider for symmetric keys. + */ +CSPKeyInfoProvider *SymmetricKeyInfoProvider::provider( + const CssmKey &cssmKey, + AppleCSPSession &session) +{ + if(cssmKey.blobType() != CSSM_KEYBLOB_RAW) { + errorLog0("KeyInfoProvider deals only with RAW keys!\n"); + CssmError::throwMe(CSSMERR_CSP_INTERNAL_ERROR); + } + if(cssmKey.keyClass() != CSSM_KEYCLASS_SESSION_KEY) { + /* that's all we need to know */ + return NULL; + } + return new SymmetricKeyInfoProvider(cssmKey, session); +} + +SymmetricKeyInfoProvider::SymmetricKeyInfoProvider( + const CssmKey &cssmKey, + AppleCSPSession &session) : + CSPKeyInfoProvider(cssmKey, session) +{ +} + +/* cook up a Binary key */ +void SymmetricKeyInfoProvider::CssmKeyToBinary( + CssmKey *paramKey, // ignored + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT + BinaryKey **binKey) +{ + CASSERT(mKey.keyClass() == CSSM_KEYCLASS_SESSION_KEY); + SymmetricBinaryKey *symBinKey = new SymmetricBinaryKey( + mKey.KeyHeader.LogicalKeySizeInBits); + copyCssmData(mKey, + symBinKey->mKeyData, + symBinKey->mAllocator); + *binKey = symBinKey; +} + +/* obtain key size in bits */ +void SymmetricKeyInfoProvider::QueryKeySizeInBits( + CSSM_KEY_SIZE &keySize) +{ + /* FIXME - do we ever need to calculate RC2 effective size here? */ + keySize.LogicalKeySizeInBits = keySize.EffectiveKeySizeInBits = + mKey.length() * 8; +} + +/* + * Obtain blob suitable for hashing in CSSM_APPLECSP_KEYDIGEST + * passthrough. + */ +bool SymmetricKeyInfoProvider::getHashableBlob( + CssmAllocator &allocator, + CssmData &blob) // blob to hash goes here +{ + /* + * This is trivial: the raw key is already in the "proper" format. + */ + assert(mKey.blobType() == CSSM_KEYBLOB_RAW); + const CssmData &keyBlob = CssmData::overlay(mKey.KeyData); + copyCssmData(keyBlob, blob, allocator); + return true; +} + diff --git a/AppleCSP/AppleCSP/AppleCSPKeys.h b/AppleCSP/AppleCSP/AppleCSPKeys.h new file mode 100644 index 00000000..ba961b48 --- /dev/null +++ b/AppleCSP/AppleCSP/AppleCSPKeys.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ +/* + * AppleCSPKeys.h - Key support + */ + +#ifndef _APPLE_CSP_KEYS_H_ +#define _APPLE_CSP_KEYS_H_ + +#include "AppleCSPSession.h" + +/* + * Class to provide key-specific info. Each module dealing with keys + * implements one of these. It's sort of like a CSP-specific CSPContext + * without the Context object. AppleCSPSession finds one of these by + * querying module-specific subclasses, looking for one in which + * the constructor succeeds (which occurs when the specified key + * meets a subclass's specification). + */ +class CSPKeyInfoProvider +{ +protected: + CSPKeyInfoProvider( + const CssmKey &cssmKey, + AppleCSPSession &session) : + mKey(cssmKey), + mSession(session) { } +public: + /* + * This is the public way to construct - returns NULL if key is + * not handled. Static declaration per subclass. + * + * static CSPKeyInfoProvider *provider( + * const CssmKey &cssmKey, + *  AppleCSPSession &session); + */ + virtual ~CSPKeyInfoProvider() { } + + /* + * Cook up a Binary key. + * + * Incoming paramKey optionally contains a key from which + * additional algorithm parameters may be obtained to create + * a fully specified key in case the key provided to our + * constructor was a partial key. + * + * The attrFlags argument is a means for the info provider to + * inform the caller that the incoming key has additional + * attributes, currently CSSM_KEYATTR_PARTIAL. The provider + * ORs in bits as appropriate. + */ + virtual void CssmKeyToBinary( + CssmKey *paramKey, // optional + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT + BinaryKey **binKey) = 0; // RETURNED + + /* obtain key size in bits */ + virtual void QueryKeySizeInBits( + CSSM_KEY_SIZE &keySize) = 0; // RETURNED + + /* + * Get blob appropriate for calculating key digest, if possible + * to do without generating a BinaryKey. Returns true if + * successful, falseif BinaryKey generation is required. + */ + virtual bool getHashableBlob( + CssmAllocator &allocator, + CssmData &hashBlob) = 0; // blob to hash goes here + +protected: + const CssmKey &mKey; + AppleCSPSession &mSession; +}; + +/* + * CSPKeyInfoProvider for symmetric keys (handled directly by + * the session). + */ +class SymmetricKeyInfoProvider : public CSPKeyInfoProvider +{ +private: + SymmetricKeyInfoProvider( + const CssmKey &cssmKey, + AppleCSPSession &session); +public: + static CSPKeyInfoProvider *provider( + const CssmKey &cssmKey, + AppleCSPSession &session); + + ~SymmetricKeyInfoProvider() { } + void CssmKeyToBinary( + CssmKey *paramKey, // ignored + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT + BinaryKey **binKey); // RETURNED + void QueryKeySizeInBits( + CSSM_KEY_SIZE &keySize); // RETURNED + bool getHashableBlob( + CssmAllocator &allocator, + CssmData &hashBlob); +}; + +#endif /* _APPLE_CSP_KEYS_H_ */ + diff --git a/AppleCSP/AppleCSP/AppleCSPSession.h b/AppleCSP/AppleCSP/AppleCSPSession.h index aa5eec9f..c5f447cd 100644 --- a/AppleCSP/AppleCSP/AppleCSPSession.h +++ b/AppleCSP/AppleCSP/AppleCSPSession.h @@ -193,60 +193,10 @@ private: CSPKeyInfoProvider *infoProvider( const CssmKey &key); -}; /* AppleCSPSession */ - -/* - * Class to provide key-specific info. Each module dealing with keys - * implements one of these. It's sort of like a CSP-specific CSPContext - * without the Context object. AppleCSPSession finds one of these by - * querying module-specific subclasses, looking for one in which - * the constructor succeeds. - */ -class CSPKeyInfoProvider -{ -protected: - CSPKeyInfoProvider( - const CssmKey &cssmKey) : mKey(cssmKey) { } -public: - /* - * This is the public way to construct - returns NULL if key is - * not handled. Static declaration per subclass. - * - * static CSPKeyInfoProvider *provider( - * const CssmKey &cssmKey); - */ - virtual ~CSPKeyInfoProvider() { } + void pkcs8InferKeyHeader( + CssmKey &key); - /* cook up a Binary key */ - virtual void CssmKeyToBinary( - BinaryKey **binKey) = 0; // RETURNED - - /* obtain key size in bits */ - virtual void QueryKeySizeInBits( - CSSM_KEY_SIZE &keySize) = 0; // RETURNED - -protected: - const CssmKey &mKey; -}; +}; /* AppleCSPSession */ -/* - * CSPKeyInfoProvider for symmetric keys (handled directly by - * the session). - */ -class SymmetricKeyInfoProvider : public CSPKeyInfoProvider -{ -private: - SymmetricKeyInfoProvider( - const CssmKey &cssmKey); -public: - static CSPKeyInfoProvider *provider( - const CssmKey &cssmKey); - - ~SymmetricKeyInfoProvider() { } - void CssmKeyToBinary( - BinaryKey **binKey); // RETURNED - void QueryKeySizeInBits( - CSSM_KEY_SIZE &keySize); // RETURNED -}; #endif //_APPLE_CSP_SESSION_H_ diff --git a/AppleCSP/AppleCSP/AppleCSPUtils.cpp b/AppleCSP/AppleCSP/AppleCSPUtils.cpp index c33dd3a2..2ba83229 100644 --- a/AppleCSP/AppleCSP/AppleCSPUtils.cpp +++ b/AppleCSP/AppleCSP/AppleCSPUtils.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -463,6 +464,29 @@ void copyData( allocator); } +/* + * Compare two CSSM_DATAs, return CSSM_TRUE if identical. + */ +CSSM_BOOL cspCompareCssmData( + const CSSM_DATA *data1, + const CSSM_DATA *data2) +{ + if((data1 == NULL) || (data1->Data == NULL) || + (data2 == NULL) || (data2->Data == NULL) || + (data1->Length != data2->Length)) { + return CSSM_FALSE; + } + if(data1->Length != data2->Length) { + return CSSM_FALSE; + } + if(memcmp(data1->Data, data2->Data, data1->Length) == 0) { + return CSSM_TRUE; + } + else { + return CSSM_FALSE; + } +} + /* * This takes care of mallocing the KeyLabel field. */ @@ -559,3 +583,98 @@ void cspGenSha1Hash( sha1.digestUpdate(inData, inDataLen); sha1.digestFinal(out); } + +/* + * Convert a CSSM_DATE to a CssmUniformDate, or NULL if the CSSM_DATE + * is empty. + */ +static CssmUniformDate *cspGetUniformDate( + const CSSM_DATE &cdate) +{ + bool isZero = true; + unsigned char *cp = (unsigned char *)&cdate; + for(unsigned i=0; i *end) { + keyDateDebug("Invalid end date"); + err = CSSMERR_CSP_APPLE_INVALID_KEY_END_DATE; + } + else { + keyDateDebug("Valid end date"); + } + } + else { + keyDateDebug("Empty end date"); + } + } + if(now) { + delete now; + } + if(end) { + delete end; + } + if(start) { + delete start; + } + if(err) { + CssmError::throwMe(err); + } +} + diff --git a/AppleCSP/AppleCSP/AppleCSPUtils.h b/AppleCSP/AppleCSP/AppleCSPUtils.h index b6730aa1..3e596522 100644 --- a/AppleCSP/AppleCSP/AppleCSPUtils.h +++ b/AppleCSP/AppleCSP/AppleCSPUtils.h @@ -135,6 +135,13 @@ void copyData( CSSM_DATA &dst, CssmAllocator &allocator); +/* + * Compare two CSSM_DATAs, return CSSM_TRUE if identical. + */ +CSSM_BOOL cspCompareCssmData( + const CSSM_DATA *data1, + const CSSM_DATA *data2); + /* * This takes care of mallocing the and KeyLabel field. */ @@ -168,6 +175,9 @@ void cspGenSha1Hash( size_t inDataLen, void *out); // caller mallocs, digest goes here +void cspVerifyKeyTimes( + const CSSM_KEYHEADER &hdr); + #ifdef __cplusplus } #endif diff --git a/AppleCSP/AppleCSP/BinaryKey.h b/AppleCSP/AppleCSP/BinaryKey.h index ef42392d..0ff22fcc 100644 --- a/AppleCSP/AppleCSP/BinaryKey.h +++ b/AppleCSP/AppleCSP/BinaryKey.h @@ -29,6 +29,15 @@ // opaque key reference type typedef uint32 KeyRef; +class AppleCSPSession; + +/* + * unique blob type passed to generateKeyBlob() for key digest calculation + */ +#define CSSM_KEYBLOB_RAW_FORMAT_DIGEST \ + (CSSM_KEYBLOB_RAW_FORMAT_VENDOR_DEFINED + 0x12345) + + // frame for Binary key; all modules (BSAFE, CryptKit) must subclass // this and add a member whose type is the native raw key object. // Subclasses must implement constructor, destructor, and generateKeyBlob(). @@ -46,11 +55,27 @@ public: * CSSM_ATTRIBUTE_{PUBLIC,PRIVATE,SYMMETRIC}_KEY_FORMAT attribute in the current * context. If so such attribute is present, the default value * CSSM_KEYBLOB_RAW_FORMAT_NONE is specified as the default input param. + * + * All BinaryKeys must handle the special case format + * CSSM_KEYBLOB_RAW_FORMAT_DIGEST, which creates a blob suitable for use + * in calcuating the digest of the key blob. + * + * The session and paramKey arguments facilitate the conversion of a partial + * BinaryKey to a fully formed raw key, i.e., a null wrap to get a fully formed + * raw key. The attrFlags aregument is used to indicate that this operation + * did in fact convert a partial binary key to a fully formed raw key + * (in which case the subclass clears the CSSM_KEYATTR_PARTIAL bit + * in attrFlags before returning). */ virtual void generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format) // in/out, CSSM_KEYBLOB_RAW_FORMAT_PKCS1, etc. + CSSM_KEYBLOB_FORMAT &format, // in/out, CSSM_KEYBLOB_RAW_FORMAT_PKCS1, + // etc. + AppleCSPSession &session, + const CssmKey *paramKey, // optional + CSSM_KEYATTR_FLAGS &attrFlags) // IN/OUT + { CssmError::throwMe(CSSMERR_CSP_FUNCTION_NOT_IMPLEMENTED); } @@ -69,7 +94,10 @@ public: void generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format); // CSSM_KEYBLOB_RAW_FORMAT_PKCS1, etc. + CSSM_KEYBLOB_FORMAT &format, /* CSSM_KEYBLOB_RAW_FORMAT_PKCS1, etc. */ + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags); /* IN/OUT */ CssmData mKeyData; CssmAllocator &mAllocator; diff --git a/AppleCSP/AppleCSP/BlockCryptor.cpp b/AppleCSP/AppleCSP/BlockCryptor.cpp index 16af0f05..a343e5bd 100644 --- a/AppleCSP/AppleCSP/BlockCryptor.cpp +++ b/AppleCSP/AppleCSP/BlockCryptor.cpp @@ -32,9 +32,9 @@ #include #include -#define BlockCryptDebug(args...) debug("blockCrypt", ## args) -#define bprintf(args...) debug("blockCryptBuf", ## args) -#define ioprintf(args...) debug("blockCryptIo", ## args) +#define BlockCryptDebug(args...) secdebug("blockCrypt", ## args) +#define bprintf(args...) secdebug("blockCryptBuf", ## args) +#define ioprintf(args...) secdebug("blockCryptIo", ## args) BlockCryptor::~BlockCryptor() { @@ -576,7 +576,7 @@ size_t BlockCryptor::inputSize( size_t BlockCryptor::outputSize( bool final, - size_t inSize = 0) // output for given input size + size_t inSize /*= 0*/) // output for given input size { size_t rawBytes = inSize + mInBufSize; // huh?Êdon't round this up! diff --git a/AppleCSP/AppleCSP/SignatureContext.cpp b/AppleCSP/AppleCSP/SignatureContext.cpp index d32cc35e..85c78511 100644 --- a/AppleCSP/AppleCSP/SignatureContext.cpp +++ b/AppleCSP/AppleCSP/SignatureContext.cpp @@ -28,7 +28,7 @@ #include -#define cspSigDebug(args...) debug("cspSig", ## args) +#define cspSigDebug(args...) secdebug("cspSig", ## args) SignatureContext::~SignatureContext() { diff --git a/AppleCSP/AppleCSP/deriveKey.cpp b/AppleCSP/AppleCSP/deriveKey.cpp index 2b416a44..92476964 100644 --- a/AppleCSP/AppleCSP/deriveKey.cpp +++ b/AppleCSP/AppleCSP/deriveKey.cpp @@ -28,6 +28,8 @@ #include #include +#include +#include #include "AppleCSPSession.h" #include "AppleCSPUtils.h" #include "cspdebugging.h" @@ -124,9 +126,7 @@ void AppleCSPSession::DeriveKey_PBKDF2( * Member function initially declared for CSPAbstractPluginSession; * we're overriding the null version in CSPFullPluginSession. * - * Currently we only support one derive key algorithm - - * CSSM_ALGID_PKCS5_PBKDF2, with PRF CSSM_PKCS5_PBKDF2_PRF_HMAC_SHA1 - * PRF. We'll generate any type of key (for now). + * We'll generate any type of key (for now). */ void AppleCSPSession::DeriveKey( CSSM_CC_HANDLE CCHandle, @@ -142,6 +142,8 @@ void AppleCSPSession::DeriveKey( switch(context.algorithm()) { case CSSM_ALGID_PKCS5_PBKDF2: case CSSM_ALGID_DH: + case CSSM_ALGID_PKCS12_PBE_ENCR: + case CSSM_ALGID_PKCS12_PBE_MAC: break; /* maybe more here, later */ default: @@ -197,6 +199,12 @@ void AppleCSPSession::DeriveKey( keyData, *this); break; + case CSSM_ALGID_PKCS12_PBE_ENCR: + case CSSM_ALGID_PKCS12_PBE_MAC: + DeriveKey_PKCS12(context, + Param, + keyData); + break; /* maybe more here, later */ default: assert(0); @@ -211,7 +219,8 @@ void AppleCSPSession::DeriveKey( CSSM_KEYCLASS_SESSION_KEY, KeyAttr, KeyUsage); - hdr.LogicalKeySizeInBits = reqKeySize; + /* handle derived size < requested size, legal for Diffie-Hellman */ + hdr.LogicalKeySizeInBits = keyData->Length * 8; if(keyStorage == CKS_Ref) { /* store and convert to ref key */ diff --git a/AppleCSP/AppleCSP/pkcs8.cpp b/AppleCSP/AppleCSP/pkcs8.cpp new file mode 100644 index 00000000..70fc647b --- /dev/null +++ b/AppleCSP/AppleCSP/pkcs8.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// pkcs8.cpp - PKCS8 key wrap/unwrap support. +// + + +#include "pkcs8.h" +#include "AppleCSPUtils.h" +#include "AppleCSPKeys.h" +#include +#include +#include +#include "AppleCSPSession.h" +#include + +/* + * Given a key in PKCS8 format, fill in the following + * header fields: + * + * CSSM_KEYBLOB_FORMAT Format + * CSSM_ALGORITHMS AlgorithmId + * uint32 LogicalKeySizeInBits + */ +void AppleCSPSession::pkcs8InferKeyHeader( + CssmKey &key) +{ + /* + * Incoming key blob is a PrivateKeyInfo. Take it apart + * to get its algorithm info, from which we infer other + * fields. + */ + NSS_PrivateKeyInfo privKeyInfo; + SecNssCoder coder; + CSSM_DATA &keyData = key.KeyData; + + memset(&privKeyInfo, 0, sizeof(privKeyInfo)); + if(coder.decodeItem(keyData, NSS_PrivateKeyInfoTemplate, + &privKeyInfo)) { + errorLog0("pkcs8InferKeyHeader decode error\n"); + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); + } + + CSSM_KEYHEADER &hdr = key.KeyHeader; + if(!cssmOidToAlg(&privKeyInfo.algorithm.algorithm, + &hdr.AlgorithmId)) { + errorLog0("pkcs8InferKeyHeader unknown algorithm\n"); + CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); + } + + switch(hdr.AlgorithmId) { + case CSSM_ALGID_RSA: + hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_PKCS8; + break; + case CSSM_ALGID_DSA: + hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_FIPS186; + break; + default: + /* punt */ + hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_NONE; + break; + } + + /* + * Find someone whoe knows about this key and ask them the + * key size + */ + CSPKeyInfoProvider *provider = infoProvider(key); + if(provider == NULL) { + errorLog0("pkcs8InferKeyHeader no info provider\n"); + /* but we got this far, so don't abort */ + return; + } + CSSM_KEY_SIZE keySize; + provider->QueryKeySizeInBits(keySize); + hdr.LogicalKeySizeInBits = keySize.LogicalKeySizeInBits; + delete provider; +} + +/* + * When doing a PKCS8 wrap operation on a reference key, this + * is used to infer the blob type to obtain before the encryption. + */ +CSSM_KEYBLOB_FORMAT pkcs8RawKeyFormat( + CSSM_ALGORITHMS keyAlg) +{ + switch(keyAlg) { + case CSSM_ALGID_RSA: + return CSSM_KEYBLOB_RAW_FORMAT_PKCS8; + case CSSM_ALGID_DSA: + return CSSM_KEYBLOB_RAW_FORMAT_FIPS186; + default: + /* punt */ + return CSSM_KEYBLOB_RAW_FORMAT_NONE; + } +} diff --git a/SecuritySNACCRuntime/policy.h b/AppleCSP/AppleCSP/pkcs8.h similarity index 71% rename from SecuritySNACCRuntime/policy.h rename to AppleCSP/AppleCSP/pkcs8.h index d69d0b20..0d7de07a 100644 --- a/SecuritySNACCRuntime/policy.h +++ b/AppleCSP/AppleCSP/pkcs8.h @@ -15,31 +15,28 @@ * specific language governing rights and limitations under the License. */ +// +// pkcs8.cpp - PKCS8 key wrap/unwrap support. +// -/* - * file: policy.h - * - */ +#ifndef _PKCS_8_H_ +#define _PKCS_8_H_ -/* - * enable the snacc compiler's Tcl interface generating code? - * set it to 0 or 1. - */ -#ifndef NO_TCL -#define NO_TCL 0 -#endif +#include +#include +#include +#include "AppleCSPSession.h" -/* - * enable code for meta code generation? - * the Tcl code needs it. - */ -#ifndef NO_META -#define NO_META NO_TCL +#ifdef __cplusplus +extern "C" { #endif -/* - * enable code for CORBA IDL generation? - */ -#ifndef IDL -#define IDL 1 + +CSSM_KEYBLOB_FORMAT pkcs8RawKeyFormat( + CSSM_ALGORITHMS keyAlg); + +#ifdef __cplusplus +} #endif + +#endif /* _PKCS_7_8_H_ */ diff --git a/AppleCSP/AppleCSP/pkcs_7_8.cpp b/AppleCSP/AppleCSP/pkcs_7_8.cpp deleted file mode 100644 index 8d54cd55..00000000 --- a/AppleCSP/AppleCSP/pkcs_7_8.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// -// pkcs_7_8.cpp - encopde/decode key blobs in PKCS7 and -// PKCS8 format. -// - - -#include "pkcs_7_8.h" -#include "AppleCSPUtils.h" -#include - -/* - * NOTE: snacc-generated code is believed to be not thread safe. Thus we - * use the Mutex snaccLock to single-thread access to snacc-generated code. - */ - -static Mutex snaccLock; - -// bring in a ton of snacc-related stuff -#include -#include - -// snacc-generated - snacc really should place these in pkcs[78].h -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void algAndModeToOid( - CSSM_ALGORITHMS alg, - CSSM_ENCRYPT_MODE mode, - AsnOid &oid) // to set -{ - switch(alg) { - case CSSM_ALGID_DES: - /* FIXME - plain old 56-bit DES doesn't have an OID! */ - case CSSM_ALGID_3DES_3KEY_EDE: - oid.ReSet(des_ede3_cbc_arc); - break; - case CSSM_ALGID_RC2: - switch(mode) { - case CSSM_ALGMODE_CBCPadIV8: - case CSSM_ALGMODE_CBC_IV8: - oid.ReSet(rc2_cbc_arc); - break; - default: - oid.ReSet(rc2_ecb_arc); - break; - } - break; - case CSSM_ALGID_RC4: - oid.ReSet(rc4_arc); - break; - case CSSM_ALGID_RC5: - if(mode == CSSM_ALGMODE_CBCPadIV8) { - oid.ReSet(rc5_CBCPad_arc); - } - else { - oid.ReSet(rc5CBC_arc); - } - break; - case CSSM_ALGID_DESX: - oid.ReSet(desx_CBC_arc); - break; - case CSSM_ALGID_RSA: - oid.ReSet(rsaEncryption_arc); // from pkcs1oids.h - break; - default: - errorLog2("algAndModeToOid: Unknown alg %d mode %d\n", (int)alg, - (int)mode); - CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); - } - return; -} - - -/* - * PKCS 7 format: - * - * EncryptedData ::= SEQUENCE { - * version INTEGER {edVer0(0)} (edVer0), - * encryptedContentInfo EncryptedContentInfo - * } - * - * EncryptedContentInfo ::= SEQUENCE { - * contentType ContentType, - * contentEncryptionAlgorithm - * ContentEncryptionAlgorithmIdentifier, - * encryptedContent - * [0] IMPLICIT EncryptedContent OPTIONAL - * } - * - * EncryptedContent ::= OCTET STRING - */ - -#define PKCS7_BUFSIZE 128 /* plus sizeof encryptedContent */ - -/* - * Given a symmetric CssmKey in raw format, and its encrypted blob, - * cook up a PKCS-7 encoded blob. - */ -void cspEncodePkcs7( - CSSM_ALGORITHMS alg, // encryption alg, used by PKCS7 - CSSM_ENCRYPT_MODE mode, // ditto - const CssmData &encryptedBlob, - CssmData &encodedBlob, // mallocd and RETURNED - CssmAllocator &allocator) -{ - AsnBuf buf; - char *b; - unsigned bLen; - EncryptedData1 ed; - EncryptedContentInfo1 *eci; - AlgorithmIdentifier *algId; - AsnLen len; - StLock _(snaccLock); - - // init some values - ed.version.Set(EncryptedDataInt::edVer0); - eci = ed.encryptedContentInfo = new EncryptedContentInfo1; - eci->contentType = encryptedData; // OID from pkcs7.h - algId = eci->contentEncryptionAlgorithm = new AlgorithmIdentifier; - - /* - * select an AsnOid based in key algorithm and mode. - * Note we support more alg/mode combos that there are - * assigned oids; no big deal - currently we don't even - * parse the OID on decode anyway. - */ - algAndModeToOid(alg, mode, algId->algorithm); - - // unlike pkcs8, this one is a pointer - it gets deleted by - // EncryptedContentInfo1's destructor - eci->encryptedContent = new AsnOcts( - (char *)encryptedBlob.Data, (size_t)encryptedBlob.Length); - - // cook up an AsnBuf to stash the encoded blob in - bLen = PKCS7_BUFSIZE + encryptedBlob.Length; - b = (char *)allocator.malloc(bLen); - buf.Init(b, bLen); - buf.ResetInWriteRvsMode(); - - // pkcs7 encode - len = ed.BEnc(buf); - - // malloc & copy back to encodedBlob - setUpCssmData(encodedBlob, len, allocator); - memmove(encodedBlob.Data, buf.DataPtr(), len); - allocator.free(b); -} - - -/* - * Given a symmetric key in (encrypted, encoded) PKCS-7 format, - * obtain its encrypted key blob. - */ -void cspDecodePkcs7( - const CssmKey &wrappedKey, // for inferring format - CssmData &decodedBlob, // mallocd and RETURNED - CSSM_KEYBLOB_FORMAT &format, // RETURNED - CssmAllocator &allocator) -{ - const CssmData &encodedBlob = - CssmData::overlay(wrappedKey.KeyData); - ENV_TYPE jbuf; - EncryptedData1 ed; - int rtn; - AsnBuf buf; - size_t len = (size_t)encodedBlob.Length; - StLock _(snaccLock); - - buf.InstallData((char *)encodedBlob.Data, len); - try { - int i; - EncryptedContentInfo1 *eci; - - ed.BDec(buf, len, jbuf); - - i = ed.version; - if(i != EncryptedDataInt::edVer0) { - errorLog1("cspDecodePkcs7: bad edDec.version (%d)\n", i); - CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); - } - eci = ed.encryptedContentInfo; - if(!(eci->contentType == encryptedData)) { - errorLog0("cspDecodePkcs7: bad contentType\n"); - CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); - } - - /* ignore encryption alg (for now) */ - - /* eci->encryptedContent is decodedBlob */ - setUpCssmData(decodedBlob, - eci->encryptedContent->Len(), - allocator); - memmove(decodedBlob.Data, - (char *)(*eci->encryptedContent), - eci->encryptedContent->Len()); - } - catch(...) { - errorLog1("cspDecodePkcs7: BDec threw %d\n", rtn); - CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); - } - - format = inferFormat(wrappedKey); -} - -/* - * PKCS-8 format - * - * EncryptedPrivateKeyInfo ::= SEQUENCE { - * encryptionAlgorithm AlgorithmIdentifier - * {{KeyEncryptionAlgorithms}}, - * encryptedData EncryptedData - * } - * - * EncryptedData ::= OCTET STRING - */ - -#define PKCS8_BUFSIZE 64 /* plus sizeof encryptedBlob */ - -/* - * Given an asymmetric CssmKey in raw format, and its encrypted blob, - * cook up a PKCS-8 encoded blob. - */ -void cspEncodePkcs8( - CSSM_ALGORITHMS alg, // encryption alg, used by PKCS8 - CSSM_ENCRYPT_MODE mode, // ditto - const CssmData &encryptedBlob, - CssmData &encodedBlob, // mallocd and RETURNED - CssmAllocator &allocator) -{ - AsnBuf buf; - char *b; - unsigned bLen; - EncryptedPrivateKeyInfo epki; - AsnLen len; - StLock _(snaccLock); - - epki.encryptionAlgorithm = new AlgorithmIdentifier; - algAndModeToOid(alg, mode, epki.encryptionAlgorithm->algorithm); - epki.encryptedKey.Set((char *)encryptedBlob.Data, encryptedBlob.Length); - - // cook up an AsnBuf to stash the encoded blob in - bLen = PKCS8_BUFSIZE + encryptedBlob.Length; - b = (char *)allocator.malloc(bLen); - buf.Init(b, bLen); - buf.ResetInWriteRvsMode(); - - // pkcs8 encode - len = epki.BEnc(buf); - - // malloc & copy back to encodedBlob - setUpCssmData(encodedBlob, len, allocator); - memmove(encodedBlob.Data, buf.DataPtr(), len); - allocator.free(b); -} - -/* - * Given a a private key in (encrypted, encoded) PKCS-8 format, - * obtain its encrypted key blob. - */ -void cspDecodePkcs8( - const CssmKey &wrappedKey, // for inferring format - CssmData &decodedBlob, // mallocd and RETURNED - CSSM_KEYBLOB_FORMAT &format, // RETURNED - CssmAllocator &allocator) -{ - const CssmData &encodedBlob = - CssmData::overlay(wrappedKey.KeyData); - ENV_TYPE jbuf; - EncryptedData1 ed; - int rtn; - AsnBuf buf; - size_t len = (size_t)encodedBlob.Length; - StLock _(snaccLock); - - buf.InstallData((char *)encodedBlob.Data, len); - try { - EncryptedPrivateKeyInfo epki; - - epki.BDec(buf, len, jbuf); - - /* skip algorithm - just snag encryptedKey */ - len = epki.encryptedKey.Len(); - setUpCssmData(decodedBlob, len, allocator); - memmove(decodedBlob.Data, - (char *)(epki.encryptedKey), - len); - } - catch(...) { - errorLog1("cspDecodePkcs8: BDec threw %d\n", rtn); - CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); - } - - format = inferFormat(wrappedKey); -} diff --git a/AppleCSP/AppleCSP/pkcs_7_8.h b/AppleCSP/AppleCSP/pkcs_7_8.h deleted file mode 100644 index 669ceb0d..00000000 --- a/AppleCSP/AppleCSP/pkcs_7_8.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// -// pkcs_7_8.h - encode/decode key blobs in PKCS7 and -// PKCS8 format. -// - -#ifndef _PKCS_7_8_H_ -#define _PKCS_7_8_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Given a symmetric CssmKey in raw format, and its encrypted blob, - * cook up a PKCS-7 encoded blob. - */ -void cspEncodePkcs7( - CSSM_ALGORITHMS alg, // encryption alg, used by PKCS7 - CSSM_ENCRYPT_MODE mode, // ditto - const CssmData &encryptedBlob, - CssmData &encodedBlob, // mallocd and RETURNED - CssmAllocator &allocator); - -/* - * Given a symmetric key in (encrypted, encoded) PKCS-7 format, - * obtain its encrypted key blob. - */ -void cspDecodePkcs7( - const CssmKey &wrappedKey, // for inferring format - CssmData &decodedBlob, // mallocd and RETURNED - CSSM_KEYBLOB_FORMAT &format, // RETURNED - CssmAllocator &allocator); - -/* - * Given an asymmetric CssmKey in raw format, and its encrypted blob, - * cook up a PKCS-8 encoded blob. - */ -void cspEncodePkcs8( - CSSM_ALGORITHMS alg, // encryption alg, used by PKCS8 - CSSM_ENCRYPT_MODE mode, // ditto - const CssmData &encryptedBlob, - CssmData &encodedBlob, // mallocd and RETURNED - CssmAllocator &allocator); - -/* - * Given a an asymmetric key in (encrypted, encoded) PKCS-8 format, - * obtain its encrypted key blob. - */ -void cspDecodePkcs8( - const CssmKey &wrappedKey, // for inferring format - CssmData &decodedBlob, // mallocd and RETURNED - CSSM_KEYBLOB_FORMAT &format, // RETURNED - CssmAllocator &allocator); - -#ifdef __cplusplus -} -#endif - -#endif /* _PKCS_7_8_H_ */ \ No newline at end of file diff --git a/AppleCSP/AppleCSP/wrapKey.cpp b/AppleCSP/AppleCSP/wrapKey.cpp index be08e27a..e181fc66 100644 --- a/AppleCSP/AppleCSP/wrapKey.cpp +++ b/AppleCSP/AppleCSP/wrapKey.cpp @@ -28,9 +28,8 @@ #include "AppleCSPSession.h" #include "AppleCSPUtils.h" -#ifdef USE_SNACC -#include "pkcs_7_8.h" -#endif +#include "AppleCSPKeys.h" +#include "pkcs8.h" #include "cspdebugging.h" /* @@ -43,8 +42,9 @@ * must be of class ALGCLASS_SYMMETRIC or ALGCLASS_ASYMMETRIC, * matching the wrapping key. * - * Private keys will be PKCS8 encoded; session keys will be - * PKCS7 encoded. Both input keys may be in raw or reference + * In the absence of an explicit CSSM_ATTRIBUTE_WRAPPED_KEY_FORMAT + * attribute, private keys will be PKCS8 wrapped; session keys will be + * PKCS7 wrapped. Both input keys may be in raw or reference * format. Wrapped key will have BlobType CSSM_KEYBLOB_WRAPPED. * * -- Convert a reference key to a RAW key (with no encrypting). @@ -68,13 +68,15 @@ * a modified CMS-style wrapping which is similar to that specified in * RFC2630, with some modification. * - * Default wrapping if none specified: + * Default wrapping if none specified based on ther unwrapped key as + * follows: * - * UnwrappedKey type WrappingKey type Format - * ----------------- ---------------- ------------------------- - * 3DES 3DES CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM - * any Other symmetric CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS7 - * any Other asymmetric CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8 + * UnwrappedKey Wrap format + * ------------ ----------- + * Symmetric PKCS7 + * Public APPLE_CUSTOM + * FEE private APPLE_CUSTOM + * Other private PKCS8 */ void AppleCSPSession::WrapKey( @@ -130,7 +132,8 @@ void AppleCSPSession::WrapKey( } #endif /* ALLOW_PUB_KEY_WRAP */ cspValidateIntendedKeyUsage(&wrappingKey->KeyHeader, CSSM_KEYUSE_WRAP); - + cspVerifyKeyTimes(wrappingKey->KeyHeader); + /* * make sure wrapping key type matches context */ @@ -163,41 +166,48 @@ void AppleCSPSession::WrapKey( */ wrapFormat = Context.getInt(CSSM_ATTRIBUTE_WRAPPED_KEY_FORMAT); if(wrapFormat == CSSM_KEYBLOB_WRAPPED_FORMAT_NONE) { - /* figure out a default */ - if(wrapType == CSSM_ALGCLASS_ASYMMETRIC) { - /* easy */ -#ifdef USE_SNACC - wrapFormat = CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8; -#else - wrapFormat = CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM; -#endif - } - else { - CASSERT(wrapType == CSSM_ALGCLASS_SYMMETRIC); - if((wrappingKey->algorithm() == CSSM_ALGID_3DES_3KEY) && - (UnwrappedKey.algorithm() == CSSM_ALGID_3DES_3KEY)) { - /* apple custom CMS */ - wrapFormat = CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM; - } - else { - /* normal case for symmetric wrapping keys */ -#ifdef USE_SNACC + /* figure out a default based on unwrapped key */ + switch(UnwrappedKey.keyClass()) { + case CSSM_KEYCLASS_SESSION_KEY: wrapFormat = CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS7; -#else + break; + case CSSM_KEYCLASS_PUBLIC_KEY: wrapFormat = CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM; -#endif - } - } /* default for symmetric wrapping key */ + break; + case CSSM_KEYCLASS_PRIVATE_KEY: + switch(UnwrappedKey.algorithm()) { + case CSSM_ALGID_FEE: + wrapFormat = CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM; + break; + default: + wrapFormat = CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8; + break; + } + break; + default: + /* NOT REACHED - checked above */ + break; + } } /* no format present or FORMAT_NONE */ } /* make sure we have a valid format here */ switch(wrapFormat) { -#if 0 case CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS7: + if(UnwrappedKey.keyClass() != CSSM_KEYCLASS_SESSION_KEY) { + /* this wrapping style only for symmetric keys */ + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); + } + break; case CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8: -#endif + if(UnwrappedKey.keyClass() != CSSM_KEYCLASS_PRIVATE_KEY) { + /* this wrapping style only for private keys */ + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); + } + break; case CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM: + /* no restrictions (well AES can't be the wrap alg but that will + * be caught later */ break; case CSSM_KEYBLOB_WRAPPED_FORMAT_NONE: if(isNullWrap) { @@ -214,6 +224,13 @@ void AppleCSPSession::WrapKey( bool allocdRawBlob = false; CSSM_KEYBLOB_FORMAT rawFormat; + /* + * Outgoing same as incoming unless a partial key is completed during + * generateKeyBlob() + */ + const CssmKey::Header &unwrappedHdr = UnwrappedKey.header(); + CSSM_KEYATTR_FLAGS unwrappedKeyAttrFlags = unwrappedHdr.KeyAttr; + switch(UnwrappedKey.blobType()) { case CSSM_KEYBLOB_RAW: /* trivial case */ @@ -224,23 +241,43 @@ void AppleCSPSession::WrapKey( /* get binary key, then get blob from it */ { BinaryKey &binKey = lookupRefKey(UnwrappedKey); + /* - * Special case for null wrap - prevent caller from obtaining - * clear bits if CSSM_KEYATTR_SENSITIVE or !CSSM_KEYATTR_EXTRACTABLE. - * Don't trust the caller's header; use the one in the BinaryKey. + * Subsequent tests for extractability: don't trust the + * caller's header; use the one in the BinaryKey. */ - if(isNullWrap) { - CSSM_KEYATTR_FLAGS keyAttr = binKey.mKeyHeader.KeyAttr; - if((keyAttr & CSSM_KEYATTR_SENSITIVE) || - !(keyAttr & CSSM_KEYATTR_EXTRACTABLE)) { - CssmError::throwMe( - CSSMERR_CSP_INVALID_KEYATTR_MASK); - } + CSSM_KEYATTR_FLAGS keyAttr = binKey.mKeyHeader.KeyAttr; + if(!(keyAttr & CSSM_KEYATTR_EXTRACTABLE)) { + /* this key not extractable in any form */ + CssmError::throwMe(CSSMERR_CSP_INVALID_KEYATTR_MASK); + } + + /* + * Null wrap - prevent caller from obtaining + * clear bits if CSSM_KEYATTR_SENSITIVE + */ + if(isNullWrap && (keyAttr & CSSM_KEYATTR_SENSITIVE)) { + CssmError::throwMe(CSSMERR_CSP_INVALID_KEYATTR_MASK); + } + + /* + * Special case for PKCS8: need to get blob of a specific + * algorithm-dependent format. + */ + if(wrapFormat == CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8) { + rawFormat = pkcs8RawKeyFormat(binKey.mKeyHeader.Format); } - rawFormat = requestedKeyFormat(Context, UnwrappedKey); + else { + rawFormat = requestedKeyFormat(Context, UnwrappedKey); + } + /* optional parameter-bearing key */ + CssmKey *paramKey = Context.get(CSSM_ATTRIBUTE_PARAM_KEY); binKey.generateKeyBlob(privAllocator, rawBlob, - rawFormat); + rawFormat, + *this, + paramKey, + unwrappedKeyAttrFlags); } allocdRawBlob = true; // remember - we need to free break; @@ -253,16 +290,17 @@ void AppleCSPSession::WrapKey( /* * Prepare outgoing header. */ - const CssmKey::Header &unwrappedHdr = UnwrappedKey.header(); setKeyHeader(wrappedHdr, plugin.myGuid(), unwrappedHdr.algorithm(), // same as incoming unwrappedHdr.keyClass(), // same as incoming - unwrappedHdr.KeyAttr, + unwrappedKeyAttrFlags, unwrappedHdr.KeyUsage); wrappedHdr.LogicalKeySizeInBits = unwrappedHdr.LogicalKeySizeInBits; wrappedHdr.WrapAlgorithmId = Context.algorithm(); // true for null // and non-Null + wrappedHdr.StartDate = unwrappedHdr.StartDate; + wrappedHdr.EndDate = unwrappedHdr.EndDate; wrappedHdr.Format = wrapFormat; if(isNullWrap) { wrappedHdr.BlobType = CSSM_KEYBLOB_RAW; @@ -316,7 +354,6 @@ void AppleCSPSession::WrapKey( normAllocator); wrappedHdr.Format = rawFormat; } -#ifdef USE_SNACC else { /* encrypt rawBlob using caller's context, then encode to * WrappedKey.KeyData */ @@ -334,42 +371,24 @@ void AppleCSPSession::WrapKey( // I'm not 100% sure about this.... assert(remData.Length == 0); encryptedBlob.Length = bytesEncrypted; - if(wrapFormat == CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS7) { - cspEncodePkcs7(Context.algorithm(), - Context.getInt(CSSM_ATTRIBUTE_MODE), - encryptedBlob, - CssmData::overlay(WrappedKey.KeyData), - normAllocator); - } - else { - CASSERT(wrapFormat == CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8); - cspEncodePkcs8(Context.algorithm(), - Context.getInt(CSSM_ATTRIBUTE_MODE), - encryptedBlob, - CssmData::overlay(WrappedKey.KeyData), - normAllocator); - } + WrappedKey.KeyData = encryptedBlob; wrappedHdr.BlobType = CSSM_KEYBLOB_WRAPPED; // OK to be zero or not present wrappedHdr.WrapMode = Context.getInt( CSSM_ATTRIBUTE_MODE); } -#endif } catch (...) { errorLog0("WrapKey: EncryptData() threw exception\n"); if(allocdRawBlob) { freeCssmData(rawBlob, privAllocator); } - /* mallocd in EncryptData, thus normAllocator */ - freeCssmData(encryptedBlob, normAllocator); freeCssmData(remData,normAllocator); throw; } if(allocdRawBlob) { freeCssmData(rawBlob, privAllocator); } - freeCssmData(encryptedBlob, normAllocator); freeCssmData(remData, normAllocator); } @@ -448,6 +467,7 @@ void AppleCSPSession::UnwrapKey( CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); } cspValidateIntendedKeyUsage(&unwrappingKey->KeyHeader, CSSM_KEYUSE_UNWRAP); + cspVerifyKeyTimes(unwrappingKey->KeyHeader); } /* validate WrappedKey */ @@ -504,18 +524,26 @@ void AppleCSPSession::UnwrapKey( KeyAttr & ~KEY_ATTR_RETURN_MASK, KeyUsage); unwrappedHdr.LogicalKeySizeInBits = wrappedHdr.LogicalKeySizeInBits; - unwrappedHdr.KeyUsage = wrappedHdr.KeyUsage; + unwrappedHdr.StartDate = wrappedHdr.StartDate; + unwrappedHdr.EndDate = wrappedHdr.EndDate; UnwrappedKey.KeyData.Data = NULL; // ignore possible incoming KeyData UnwrappedKey.KeyData.Length = 0; /* validate wrappedKey format */ if(!isNullUnwrap) { switch(wrapFormat) { -#ifdef USE_SNACC case CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS7: + if(WrappedKey.keyClass() != CSSM_KEYCLASS_SESSION_KEY) { + /* this unwrapping style only for symmetric keys */ + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); + } + break; case CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8: + if(WrappedKey.keyClass() != CSSM_KEYCLASS_PRIVATE_KEY) { + /* this unwrapping style only for private keys */ + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); + } break; -#endif case CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM: UnwrapKeyCms(CCHandle, Context, @@ -543,23 +571,8 @@ void AppleCSPSession::UnwrapKey( unwrappedHdr.BlobType = CSSM_KEYBLOB_RAW; unwrappedHdr.Format = wrapFormat; } -#ifdef USE_SNACC else { - /* decode wrapped blob, then decrypt to UnwrappedKey.KeyData - * using caller's context */ - CSSM_KEYBLOB_FORMAT rawFormat; - if(wrapFormat == CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS7) { - cspDecodePkcs7(WrappedKey, - decodedBlob, - rawFormat, - normAllocator); - } - else { - cspDecodePkcs8(WrappedKey, - decodedBlob, - rawFormat, - normAllocator); - } + decodedBlob = CssmData::overlay(WrappedKey.KeyData); uint32 bytesDecrypted; CssmData *unwrapData = CssmData::overlay(&UnwrappedKey.KeyData); @@ -578,17 +591,31 @@ void AppleCSPSession::UnwrapKey( assert(remData.Length == 0); UnwrappedKey.KeyData.Length = bytesDecrypted; unwrappedHdr.BlobType = CSSM_KEYBLOB_RAW; - unwrappedHdr.Format = rawFormat; + + /* + * Figure out various header fields from resulting blob + */ + switch(wrapFormat) { + case CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS7: + unwrappedHdr.Format = + CSSM_KEYBLOB_RAW_FORMAT_OCTET_STRING; + if(unwrappedHdr.LogicalKeySizeInBits == 0) { + unwrappedHdr.LogicalKeySizeInBits = + bytesDecrypted * 8; + } + /* app has to infer/know algorithm */ + break; + case CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8: + pkcs8InferKeyHeader(UnwrappedKey); + break; + } } -#endif } catch (...) { errorLog0("UnwrapKey: DecryptData() threw exception\n"); - freeCssmData(decodedBlob, normAllocator); freeCssmData(remData, normAllocator); throw; } - freeCssmData(decodedBlob, normAllocator); freeCssmData(remData, normAllocator); /* @@ -601,7 +628,9 @@ void AppleCSPSession::UnwrapKey( */ BinaryKey *binKey = NULL; CSPKeyInfoProvider *provider = infoProvider(UnwrappedKey); - provider->CssmKeyToBinary(&binKey); + /* optional parameter-bearing key */ + CssmKey *paramKey = Context.get(CSSM_ATTRIBUTE_PARAM_KEY); + provider->CssmKeyToBinary(paramKey, UnwrappedKey.KeyHeader.KeyAttr, &binKey); addRefKey(*binKey, UnwrappedKey); delete provider; } diff --git a/AppleCSP/AppleCSP/wrapKeyCms.cpp b/AppleCSP/AppleCSP/wrapKeyCms.cpp index 4a92edfe..61e36418 100644 --- a/AppleCSP/AppleCSP/wrapKeyCms.cpp +++ b/AppleCSP/AppleCSP/wrapKeyCms.cpp @@ -22,8 +22,8 @@ #include "AppleCSPSession.h" #include "AppleCSPUtils.h" +#include "AppleCSPKeys.h" #include "cspdebugging.h" -#include "pkcs_7_8.h" /* * @@ -451,7 +451,9 @@ void AppleCSPSession::UnwrapKeyCms( if(keyStorage == CKS_Ref) { BinaryKey *binKey = NULL; CSPKeyInfoProvider *provider = infoProvider(UnwrappedKey); - provider->CssmKeyToBinary(&binKey); + /* optional parameter-bearing key */ + CssmKey *paramKey = Context.get(CSSM_ATTRIBUTE_PARAM_KEY); + provider->CssmKeyToBinary(paramKey, UnwrappedKey.KeyHeader.KeyAttr, &binKey); addRefKey(*binKey, UnwrappedKey); delete provider; } diff --git a/AppleCSP/BSafeCSP/bsafeKeyGen.cpp b/AppleCSP/BSafeCSP/bsafeKeyGen.cpp index 274a158b..580c37aa 100644 --- a/AppleCSP/BSafeCSP/bsafeKeyGen.cpp +++ b/AppleCSP/BSafeCSP/bsafeKeyGen.cpp @@ -79,7 +79,10 @@ BSafe::BSafeBinaryKey::~BSafeBinaryKey() void BSafe::BSafeBinaryKey::generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format) // input val ignored for now + CSSM_KEYBLOB_FORMAT &format, // input val ignored for now + AppleCSPSession &session, + const CssmKey *paramKey, // optional, unused here + CSSM_KEYATTR_FLAGS &attrFlags) // IN/OUT { assert(mBsKey != NULL); @@ -273,13 +276,15 @@ void BSafe::BSafeKeyPairGenContext::generate( * CSPKeyInfoProvider for asymmetric BSAFE keys. */ BSafe::BSafeKeyInfoProvider::BSafeKeyInfoProvider( - const CssmKey &cssmKey) : - CSPKeyInfoProvider(cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) : + CSPKeyInfoProvider(cssmKey, session) { } CSPKeyInfoProvider *BSafe::BSafeKeyInfoProvider::provider( - const CssmKey &cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) { switch(cssmKey.keyClass()) { case CSSM_KEYCLASS_PUBLIC_KEY: @@ -296,12 +301,14 @@ CSPKeyInfoProvider *BSafe::BSafeKeyInfoProvider::provider( return NULL; } /* OK, we'll handle this one */ - return new BSafeKeyInfoProvider(cssmKey); + return new BSafeKeyInfoProvider(cssmKey, session); } /* cook up a Binary key */ void BSafe::BSafeKeyInfoProvider::CssmKeyToBinary( - BinaryKey **binKey) + CssmKey *paramKey, // optional, ignored + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT + BinaryKey **binKey) { *binKey = NULL; diff --git a/AppleCSP/BSafeCSP/bsafeSymmetric.cpp b/AppleCSP/BSafeCSP/bsafeSymmetric.cpp index e251ac34..d0f30bf1 100644 --- a/AppleCSP/BSafeCSP/bsafeSymmetric.cpp +++ b/AppleCSP/BSafeCSP/bsafeSymmetric.cpp @@ -24,7 +24,7 @@ #include "bsafecspi.h" #include -#define bbprintf(args...) debug("BSafeBuf", ## args) +#define bbprintf(args...) secdebug("BSafeBuf", ## args) #define VERBOSE_DEBUG 0 #if VERBOSE_DEBUG diff --git a/AppleCSP/BSafeCSP/bsafecspi.h b/AppleCSP/BSafeCSP/bsafecspi.h index 536db3d6..f5b2c236 100644 --- a/AppleCSP/BSafeCSP/bsafecspi.h +++ b/AppleCSP/BSafeCSP/bsafecspi.h @@ -74,7 +74,10 @@ private: void generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format); + CSSM_KEYBLOB_FORMAT &format, + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags); /* IN/OUT */ bool isPublic() { return mIsPublic; } uint32 alg() { return mAlg; } @@ -417,12 +420,16 @@ private: { private: BSafeKeyInfoProvider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); public: static CSPKeyInfoProvider *provider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); ~BSafeKeyInfoProvider() { } void CssmKeyToBinary( + CssmKey *paramKey, // optional + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT BinaryKey **binKey); // RETURNED void QueryKeySizeInBits( CSSM_KEY_SIZE &keySize); // RETURNED diff --git a/AppleCSP/CVSVersionInfo.txt b/AppleCSP/CVSVersionInfo.txt index 57d6d591..e4d9558e 100644 --- a/AppleCSP/CVSVersionInfo.txt +++ b/AppleCSP/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:47 mb Exp $ -# $Name: Security-54~1~9 $ +# $Name: $ ProjectName: AppleCSP ProjectVersion: 16 diff --git a/AppleCSP/ComCryption/ascContext.cpp b/AppleCSP/ComCryption/ascContext.cpp index 9bd6a352..0ba7727c 100644 --- a/AppleCSP/ComCryption/ascContext.cpp +++ b/AppleCSP/ComCryption/ascContext.cpp @@ -12,8 +12,8 @@ #include #include -#define abprintf(args...) debug("ascBuf", ## args) /* buffer sizes */ -#define aioprintf(args...) debug("ascIo", ## args) /* all I/O */ +#define abprintf(args...) secdebug("ascBuf", ## args) /* buffer sizes */ +#define aioprintf(args...) secdebug("ascIo", ## args) /* all I/O */ static CssmAllocator *ascAllocator; diff --git a/AppleCSP/CryptKit/.cvsignore b/AppleCSP/CryptKit/.cvsignore deleted file mode 100644 index ec052608..00000000 --- a/AppleCSP/CryptKit/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*Data -*lib diff --git a/AppleCSP/CryptKit/ByteRep.txt b/AppleCSP/CryptKit/ByteRep.txt deleted file mode 100644 index 2ed46109..00000000 --- a/AppleCSP/CryptKit/ByteRep.txt +++ /dev/null @@ -1,293 +0,0 @@ - FEE Portable Byte Representation of Public Key Strings and Signatures - Last Modified 15 March 2001 - -This defines portable data formats shared by the C and Java implementation of FEE. This definition supercedes formats used prior to 20 Feb 2001. - - -Primitive Data Types --------------------- - - int, unsigned int: - 4 bytes, M.S. byte first - - short, feeUnichar, Java char: - 2 bytes, M.S. byte first - - giant, GiantInteger: - - type contents comment - ------ -------- --------------------------------------- - int numBytes abs(numBytes) indicates size of n[] to - follow, in BYTES - sign of numBytes is sign bit of result - byte data n[0], MSB first for each element - - -Curve Parameters (curveParams, Java CurveParams) ------------------------------------------------- - - CURVE_PARAM_VERSION = 1: - - type contents - ------ -------- - int CURVE_PARAM_VERSION = 1 - int minVersion of code to parse this struct = 1 - unsigned q - int k - int spare - giant a - giant b - giant c - giant x1Plus - giant x1Minus - giant cOrderPlus - giant cOrderMinus - giant x1OrderPlus - giant x1OrderMinus - - The last four fields are not always known; a value of (giant)0 - indicates a "not known" condition. In this case, 4 bytes of - zero are written, indicating a giant with a length of zero. - - CURVE_PARAM_VERSION = 2 (20 Jan 1998) - - type contents - ------ -------- - int CURVE_PARAM_VERSION = 2 - int minVersion of code to parse this struct = 2 - byte primeType /* new for version 2 */ - unsigned q - int k - unsigned m /* new for version 2 */ - int spare - giant a - giant b - giant c - giant x1Plus - giant x1Minus - giant cOrderPlus - giant cOrderMinus - giant x1OrderPlus - giant x1OrderMinus - giant basePrime, if primeType == PT_GENERAL /* new */ - - Note that as of version 2, the cOrder* and x1Order* fields are always - known. - - CURVE_PARAM_VERSION = 3 (1 Sep 1998) - - type contents - ------ -------- - int CURVE_PARAM_VERSION = 3 - int minVersion of code to parse this struct = 3 - byte primeType - byte curveType /* new for version 3 */ - unsigned q - int k - unsigned m - int spare - giant a - giant b - giant c - giant x1Plus - giant x1Minus - giant cOrderPlus - giant cOrderMinus - giant x1OrderPlus - giant x1OrderMinus - giant basePrime, if primeType == PT_GENERAL - - -Public Key String ------------------ - - PUBLIC_KEY_STRING_VERSION = 3: - - A public key string is always encoded via enc64(); the raw data before - enc64() is as follows. - - type contents - ------ -------- - int PUBLIC_KEY_STRING_MAGIC (0xfeeddeef) - int PUBLIC_KEY_STRING_VERSION = 3 - int minVersion of code to parse this key = 3 - int spare - curveParams curve parameters - giant plusX (public key, plus curve) - giant minusX (public key, minus curve) - int usageName length in unichars - feeUnichar[] usageName as array of unichars - - PUBLIC_KEY_BLOB_VERSION = 4 (23 Mar 1998) - - New for version 4 - exported blobs for both public and private keys. - Public key strings are merely enc64() encoded versions of public - key blobs and are identical to PUBLIC_KEY_STRING_VERSION 3 public - key strings. - - PUBLIC_KEY_BLOB_MAGIC : 0xfeeddeef - public - 0xfeeddeed - private - minVersion : 3 for public, 4 for private - - type contents - ------ -------- - int PUBLIC_KEY_BLOB_MAGIC - int PUBLIC_KEY_BLOB_VERSION = 4 - int minVersion of code to parse this key = 3 or 4 - int spare - curveParams curve parameters - - public key blob: - giant plusX (public key, plus curve) - giant minusX (public key, minus curve) - private key blob: - int privDataLen - unsigned char privData[] - - both private and public: - - int usageName length in unichars - feeUnichar[] usageName as array of unichars - - PUBLIC_KEY_BLOB_VERSION = 5 (2 Sep 1998) - - Added plusY. - minVersion = 5. - - type contents - ------ -------- - int PUBLIC_KEY_BLOB_MAGIC_{PRIV,PUB} - int PUBLIC_KEY_BLOB_VERSION = 5 - int minVersion of code to parse this key = 5 - int spare - curveParams curve parameters - - public key blob: - giant plusX (public key, plus curve) - giant plusY (y-coord of public key, plus curve, may be zero) - giant minusX (public key, minus curve) - private key blob: - giant privGiant - - both private and public: - - int usageName length in unichars - feeUnichar[] usageName as array of unichars - - PUBLIC_KEY_BLOB_VERSION = 6 (14 Mar 2001) - - Deleted usageName. - - type contents - ------ -------- - int PUBLIC_KEY_BLOB_MAGIC_{PRIV,PUB} - int PUBLIC_KEY_BLOB_VERSION = 5 - int minVersion of code to parse this key = 5 - int spare - curveParams curve parameters - - public key blob: - giant plusX (public key, plus curve) - giant plusY (y-coord of public key, plus curve, may be zero) - giant minusX (public key, minus curve) - private key blob: - giant privGiant - - -Digital Signature, ElGamal style --------------------------------- - - type contents - ------ -------- - int FEE_SIG_MAGIC (0xfee00516) - int FEE_SIG_VERSION = 3 - int minVersion of code to parse this signature = 3 - int spare - int signer length in unichars (DELETED 2/20/01) - feeUnichar[] signer as array of unichars (DELETED 2/20/01) - giant u - giant Pm.x - - FEE_SIG_VERSION = 4 (15 March 2001) - Deleted signer. - - type contents - ------ -------- - int FEE_SIG_MAGIC (0xfee00516) - int FEE_SIG_VERSION = 4 - int minVersion of code to parse this signature = 4 - int spare - giant u - giant Pm.x - -Digital Signature, ECDSA style --------------------------------- - - type contents - ------ -------- - int FEE_ECDSA_MAGIC (0xfee00517) - int FEE_ECDSA_VERSION = 1 - int minVersion of code to parse this signature = 1 - int spare - int signer length in unichars (DELETED 2/20/01) - feeUnichar[] signer as array of unichars (DELETED 2/20/01) - giant s - giant x0 - - FEE_ECDSA_VERSION = 2 (15 March 2001) - Deleted signer. - - type contents - ------ -------- - int FEE_ECDSA_MAGIC (0xfee00517) - int FEE_ECDSA_VERSION = 2 - int minVersion of code to parse this signature = 2 - int spare - giant s - giant x0 - - - -FEED (2:1) CipherText ---------------------- - -This data type uses an optimized form of Giants in that the sign, and hence -the number of 16-bit shorts (i.e., the size of n[]), is implied by the size -of p used in encryption and decryption. For a given curve parameter q (as -in p = 2**q - k), the number of shorts per giant transmitted is ((q/8 + 1)/2). -As in normal giants, the n[] array is transmitted m.s. byte first. During -encoding, unused elements in n[] - i.e., those appearing after -n[abs(sign) - 1] - are zero. Upon decoding, the sign of an incoming n[] -array can be inferred from the number of non-zero shorts. - -One block of ciphertext is formatted as follows. See "Fast Elliptic -Encryption (FEE) Algorithms", by Richard E. Crandall, July 1996, for -descriptions of Xm, Xc, and g. - - type contents - --------------- ----------------- - optimized giant Xm - optimized giant Xc - byte g - - -FEED (1:1) CipherText ---------------------- - -The first cipherblock is a FEED(2:1) encrypted copy of the initial -R and S arrays; this is basically a bunch of random bytes which are -used to cook up the giants R and S at both encrypt and decrypt time. -In 1:1 FEED ciphertext, this is encrypted with the recipient's public -key; the result is padded out to one 1:1 FEED Cipherblock. - -Subsequent cipherblocks are: - - type contents - --------------- ----------------- - optimized giant Xm - byte clueByte - - clueByte contents: - bit 0 : 0 ==> minus - 1 ==> plus - bit 1 : 's' arg to elliptic_add() diff --git a/AppleCSP/CryptKitCSP/CryptKitAsn1.cpp b/AppleCSP/CryptKitCSP/CryptKitAsn1.cpp new file mode 100644 index 00000000..ee68c645 --- /dev/null +++ b/AppleCSP/CryptKitCSP/CryptKitAsn1.cpp @@ -0,0 +1,81 @@ +/* + * CryptKitAsn1.cpp - ASN1 templates for FEE keys and signatures + */ + +#include "CryptKitAsn1.h" + +/* + * Unlike RSA, DSA, and Diffie-Hellman, the integers in these + * objects are indeed signed. + */ +#define SEC_ASN1_SIGNED (SEC_ASN1_SIGNED_INT | SEC_ASN1_INTEGER) + +/* FEECurveParametersASN1 */ +const SEC_ASN1Template FEECurveParametersASN1Template[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(FEECurveParametersASN1) }, + { SEC_ASN1_INTEGER, offsetof(FEECurveParametersASN1,primeType) }, + { SEC_ASN1_INTEGER, offsetof(FEECurveParametersASN1,curveType) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,q) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,k) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,m) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,a) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,b_) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,c) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,x1Plus) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,x1Minus) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,cOrderPlus) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,cOrderMinus) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,x1OrderPlus) }, + { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,x1OrderMinus) }, + { SEC_ASN1_SIGNED | SEC_ASN1_OPTIONAL, + offsetof(FEECurveParametersASN1,basePrime) }, + { 0, } +}; + +/* FEEElGamalSignatureASN1 */ +const SEC_ASN1Template FEEElGamalSignatureASN1Template[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(FEEElGamalSignatureASN1) }, + { SEC_ASN1_SIGNED, offsetof(FEEElGamalSignatureASN1,u) }, + { SEC_ASN1_SIGNED, offsetof(FEEElGamalSignatureASN1,pmX) }, + { 0, } +}; + +/* FEEECDSASignatureASN1 */ +const SEC_ASN1Template FEEECDSASignatureASN1Template[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(FEEECDSASignatureASN1) }, + { SEC_ASN1_SIGNED, offsetof(FEEECDSASignatureASN1,c) }, + { SEC_ASN1_SIGNED, offsetof(FEEECDSASignatureASN1,d) }, + { 0, } +}; + +/* FEEPublicKeyASN1 */ +const SEC_ASN1Template FEEPublicKeyASN1Template[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(FEEPublicKeyASN1) }, + { SEC_ASN1_SIGNED, offsetof(FEEPublicKeyASN1,version) }, + { SEC_ASN1_INLINE, + offsetof(FEEPublicKeyASN1,curveParams), + FEECurveParametersASN1Template }, + { SEC_ASN1_SIGNED, offsetof(FEEPublicKeyASN1,plusX) }, + { SEC_ASN1_SIGNED, offsetof(FEEPublicKeyASN1,minusX) }, + { SEC_ASN1_SIGNED | SEC_ASN1_OPTIONAL, + offsetof(FEEPublicKeyASN1,plusY) }, + { 0, } +}; + +/* FEEPrivateKeyASN1 */ +const SEC_ASN1Template FEEPrivateKeyASN1Template[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(FEEPrivateKeyASN1) }, + { SEC_ASN1_SIGNED, offsetof(FEEPrivateKeyASN1,version) }, + { SEC_ASN1_INLINE, + offsetof(FEEPrivateKeyASN1,curveParams), + FEECurveParametersASN1Template }, + { SEC_ASN1_SIGNED, offsetof(FEEPrivateKeyASN1,privData) }, + { 0, } +}; + + diff --git a/AppleCSP/CryptKitCSP/CryptKitAsn1.h b/AppleCSP/CryptKitCSP/CryptKitAsn1.h new file mode 100644 index 00000000..9283a730 --- /dev/null +++ b/AppleCSP/CryptKitCSP/CryptKitAsn1.h @@ -0,0 +1,133 @@ +/* + * CryptKitAsn1.h - ASN1 templates for FEE objects + */ + +#ifndef _CRYPT_KIT_ASN1_H_ +#define _CRYPT_KIT_ASN1_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + -- FEE Curve parameters (defined in ) + FEEPrimeType ::= INTEGER { FPT_Mersenne(0), FPT_FEE(1), FPT_General(2) } + FEECurveType ::= INTEGER { FCT_Montgomery(0), FCT_Weierstrass(1), + FCT_General(2) } + */ + +/* + FEECurveParameters ::= SEQUENCE + { + primeType FEEPrimeType, + curveType FEECurveType, + q INTEGER, -- unsigned + k INTEGER, -- signed + m INTEGER, + a BigIntegerStr, + bb BigIntegerStr, -- can't use variable/field b + c BigIntegerStr, + x1Plus BigIntegerStr, + x1Minus BigIntegerStr, + cOrderPlus BigIntegerStr, + cOrderMinus BigIntegerStr, + x1OrderPlus BigIntegerStr, + x1OrderMinus BigIntegerStr, + basePrime BigIntegerStr OPTIONAL + -- iff FEEPrimeType == CT_GENERAL +} +*/ +typedef struct { + CSSM_DATA primeType; + CSSM_DATA curveType; + CSSM_DATA q; + CSSM_DATA k; + CSSM_DATA m; + CSSM_DATA a; + CSSM_DATA b_; // can't use variable/field b + CSSM_DATA c; + CSSM_DATA x1Plus; + CSSM_DATA x1Minus; + CSSM_DATA cOrderPlus; + CSSM_DATA cOrderMinus; + CSSM_DATA x1OrderPlus; + CSSM_DATA x1OrderMinus; + CSSM_DATA basePrime; // OPTIONAL +} FEECurveParametersASN1; + +extern const SEC_ASN1Template FEECurveParametersASN1Template[]; + +/* + -- FEE ElGamal-style signature + FEEElGamalSignature ::= SEQUENCE { + u BigIntegerStr, + pmX BigIntegerStr + } +*/ +typedef struct { + CSSM_DATA u; + CSSM_DATA pmX; +} FEEElGamalSignatureASN1; + +extern const SEC_ASN1Template FEEElGamalSignatureASN1Template[]; + +/* + -- FEE ECDSA-style signature + FEEECDSASignature ::= SEQUENCE { + c BigIntegerStr, + d BigIntegerStr + } +*/ +typedef struct { + CSSM_DATA c; + CSSM_DATA d; +} FEEECDSASignatureASN1; + +extern const SEC_ASN1Template FEEECDSASignatureASN1Template[]; + +/* + FEEPublicKey ::= SEQUENCE + { + version INTEGER, + curveParams FEECurveParameters, + plusX BigIntegerStr, + minusX BigIntegerStr, + plusY BigIntegerStr OPTIONAL + -- iff FEECurveType == ct-weierstrass +} +*/ +typedef struct { + CSSM_DATA version; + FEECurveParametersASN1 curveParams; + CSSM_DATA plusX; + CSSM_DATA minusX; + CSSM_DATA plusY; // OPTIONAL +} FEEPublicKeyASN1; + +extern const SEC_ASN1Template FEEPublicKeyASN1Template[]; + +/* + FEEPrivateKey ::= SEQUENCE + { + version INTEGER, + curveParams FEECurveParameters, + privData BigIntegerStr + } +*/ +typedef struct { + CSSM_DATA version; + FEECurveParametersASN1 curveParams; + CSSM_DATA privData; +} FEEPrivateKeyASN1; + +extern const SEC_ASN1Template FEEPrivateKeyASN1Template[]; + +#ifdef __cplusplus +} +#endif + + +#endif /* _CRYPT_KIT_ASN1_H_ */ diff --git a/AppleCSP/CryptKitCSP/CryptKitDER.cpp b/AppleCSP/CryptKitCSP/CryptKitDER.cpp index 82e03a72..a86f0882 100644 --- a/AppleCSP/CryptKitCSP/CryptKitDER.cpp +++ b/AppleCSP/CryptKitCSP/CryptKitDER.cpp @@ -25,14 +25,13 @@ #ifdef CRYPTKIT_CSP_ENABLE -#include -#include #include #include #include #include -#include -#include +#include "CryptKitAsn1.h" +#include + #define PRINT_SIG_GIANTS 0 #define PRINT_CURVE_PARAMS 0 @@ -46,7 +45,6 @@ /* * Trivial exception class associated with a feeReturn. */ -// @@@ This should really be a subclass of exception class feeException { protected: @@ -69,7 +67,7 @@ feeException::feeException( } } -void feeException::throwMe(feeReturn frtn, const char *op = NULL) { throw feeException(frtn, op); } +void feeException::throwMe(feeReturn frtn, const char *op /*= NULL*/) { throw feeException(frtn, op); } /* * ASN1 encoding rules specify that an integer's sign is indicated by the MSB @@ -96,11 +94,6 @@ static unsigned feeSizeOfSnaccGiant( return rtn + 4; } -static unsigned feeSizeofSnaccInt() -{ - return 7; -} - /* PUBLIC... */ unsigned feeSizeOfDERSig( giant g1, @@ -112,32 +105,6 @@ unsigned feeSizeOfDERSig( return rtn + 4; } -static unsigned feeSizeofSnaccCurveParams(const curveParams *cp) -{ - unsigned rtn = 5 * feeSizeofSnaccInt(); // primeType, curveType, q, k, m - rtn += 10 * feeSizeOfSnaccGiant(cp->basePrime); - szprint(("feeSizeofSnaccCurveParams: size %d\n", rtn)); - return rtn; -} - -static unsigned feeSizeOfSnaccPubKey(const curveParams *cp) -{ - unsigned rtn = 11; // version plus sequence overhead - rtn += feeSizeofSnaccCurveParams(cp); - rtn += (3 * feeSizeOfSnaccGiant(cp->basePrime)); - szprint(("feeSizeOfSnaccPubKey: size %d\n", rtn)); - return rtn; -} - -static unsigned feeSizeOfSnaccPrivKey(const curveParams *cp) -{ - unsigned rtn = 11; // version plus sequence overhead - rtn += feeSizeofSnaccCurveParams(cp); - rtn += feeSizeOfSnaccGiant(cp->basePrime); - szprint(("feeSizeOfSnaccPrivKey: size %d\n", rtn)); - return rtn; -} - /* perform 2's complement of byte array, expressed MS byte first */ static void twosComplement( unsigned char *bytePtr, // points to MS byte @@ -160,14 +127,67 @@ static void twosComplement( } /* - * Convert a BigIntegerStr to a (mallocd) giant. + * CSSM_DATA --> unsigned int + */ +static unsigned cssmDataToInt( + const CSSM_DATA &cdata) +{ + if((cdata.Length == 0) || (cdata.Data == NULL)) { + return 0; + } + unsigned len = (unsigned)cdata.Length; + if(len > sizeof(int)) { + feeException::throwMe(FR_BadKeyBlob, "cssmDataToInt"); + } + + unsigned rtn = 0; + uint8 *cp = cdata.Data; + for(unsigned i=0; i CSSM_DATA, mallocing from an SecNssCoder + */ +static void intToCssmData( + unsigned num, + CSSM_DATA &cdata, + SecNssCoder &coder) +{ + unsigned len = 0; + + if(num < 0x100) { + len = 1; + } + else if(num < 0x10000) { + len = 2; + } + else if(num < 0x1000000) { + len = 3; + } + else { + len = 4; + } + cdata.Data = (uint8 *)coder.malloc(len); + cdata.Length = len; + uint8 *cp = &cdata.Data[len - 1]; + for(unsigned i=0; i>= 8; + } +} + +/* + * Convert a decoded ASN integer, as a CSSM_DATA, to a (mallocd) giant. * Only known exception is a feeException. */ -static giant bigIntStrToGiant( - BigIntegerStr &bigInt) +static giant cssmDataToGiant( + const CSSM_DATA &cdata) { - char *rawOcts = bigInt; - unsigned numBytes = bigInt.Len(); + char *rawOcts = (char *)cdata.Data; + unsigned numBytes = cdata.Length; unsigned numGiantDigits; int sign = 1; giant grtn; @@ -253,12 +273,13 @@ abort: } /* - * Convert a giant to an existing BigIntegerString. + * Convert a giant to an CSSM_DATA, mallocing using specified coder. * Only known exception is a feeException. */ -static void giantToBigIntStr( - giant g, - BigIntegerStr &bigInt) + static void giantToCssmData( + giant g, + CSSM_DATA &cdata, + SecNssCoder &coder) { unsigned char doPrepend = 0; unsigned numGiantDigits = abs(g->sign); @@ -266,7 +287,7 @@ static void giantToBigIntStr( giantDigit msGiantBit = 0; if(isZero(g)) { /* special degenerate case */ - bigInt.ReSet("", 1); + intToCssmData(0, cdata, coder); return; } else { @@ -327,129 +348,74 @@ static void giantToBigIntStr( outp++; numBytes--; } - - /* rawBytes are the ASN-compliant contents */ - bigInt.ReSet(reinterpret_cast(outp), numBytes); + cdata.Data = (uint8 *)coder.malloc(numBytes); + memmove(cdata.Data, outp, numBytes); + cdata.Length = numBytes; ffree(rawBytes); + return; } -/* curveParams : CryptKit <--> snacc */ +/* curveParams : CryptKit <--> FEECurveParametersASN1 */ /* Only known exception is a feeException */ -static FEECurveParameters *feeCurveParamsToSnacc( - const curveParams *cp) +static void feeCurveParamsToASN1( + const curveParams *cp, + FEECurveParametersASN1 &asnCp, + SecNssCoder &coder) { #if PRINT_CURVE_PARAMS printf("===encoding curveParams; cp:\n"); printCurveParams(cp); #endif - FEECurveParameters *snaccCp = NULL; + memset(&asnCp, 0, sizeof(asnCp)); try { - snaccCp = new FEECurveParameters(); - AsnIntType val; - switch(cp->primeType) { - case FPT_Mersenne: - val = FEEPrimeType::pt_mersenne; - break; - case FPT_FEE: - val = FEEPrimeType::pt_fee; - break; - case FPT_General: - val = FEEPrimeType::pt_general; - break; - default: - feeException::throwMe(FR_Internal, "bad cp->primeType"); - } - snaccCp->primeType.Set(val); - switch(cp->curveType) { - case FCT_Montgomery: - val = FEECurveType::ct_montgomery; - break; - case FCT_Weierstrass: - val = FEECurveType::ct_weierstrass; - break; - case FCT_General: - val = FEECurveType::ct_general; - break; - default: - feeException::throwMe(FR_Internal, "bad cp->curveType"); - } - snaccCp->curveType.Set(val); - snaccCp->q.Set(cp->q); - snaccCp->k.Set(cp->k); - snaccCp->m.Set(cp->m); - giantToBigIntStr(cp->a, snaccCp->a); - giantToBigIntStr(cp->b, snaccCp->bb); - giantToBigIntStr(cp->c, snaccCp->c); - giantToBigIntStr(cp->x1Plus, snaccCp->x1Plus); - giantToBigIntStr(cp->x1Minus, snaccCp->x1Minus); - giantToBigIntStr(cp->cOrderPlus, snaccCp->cOrderPlus); - giantToBigIntStr(cp->cOrderMinus, snaccCp->cOrderMinus); - giantToBigIntStr(cp->x1OrderPlus, snaccCp->x1OrderPlus); - giantToBigIntStr(cp->x1OrderMinus, snaccCp->x1OrderMinus); + intToCssmData(cp->primeType, asnCp.primeType, coder); + intToCssmData(cp->curveType, asnCp.curveType, coder); + intToCssmData(cp->q, asnCp.q, coder); + intToCssmData(cp->k, asnCp.k, coder); + intToCssmData(cp->m, asnCp.m, coder); + giantToCssmData(cp->a, asnCp.a, coder); + giantToCssmData(cp->b, asnCp.b_, coder); + giantToCssmData(cp->c, asnCp.c, coder); + giantToCssmData(cp->x1Plus, asnCp.x1Plus, coder); + giantToCssmData(cp->x1Minus, asnCp.x1Minus, coder); + giantToCssmData(cp->cOrderPlus, asnCp.cOrderPlus, coder); + giantToCssmData(cp->cOrderMinus, asnCp.cOrderMinus, coder); + giantToCssmData(cp->x1OrderPlus, asnCp.x1OrderPlus, coder); + giantToCssmData(cp->x1OrderMinus, asnCp.x1OrderMinus, coder); if(cp->primeType == FPT_General) { - snaccCp->basePrime = new BigIntegerStr(); - giantToBigIntStr(cp->basePrime, *snaccCp->basePrime); + giantToCssmData(cp->basePrime, asnCp.basePrime, coder); } } catch(const feeException &ferr) { - delete snaccCp; throw; } catch(...) { - delete snaccCp; feeException::throwMe(FR_Memory, "feeCurveParamsToSnacc catchall"); // ??? } - return snaccCp; } -static curveParams *feeCurveParamsFromSnacc( - FEECurveParameters &snaccCp) +static curveParams *feeCurveParamsFromAsn1( + const FEECurveParametersASN1 &asnCp) { curveParams *cp = newCurveParams(); if(cp == NULL) { feeException::throwMe(FR_Memory, "feeCurveParamsFromSnacc alloc cp"); } - AsnIntType val = snaccCp.primeType; - switch(val) { - case FEEPrimeType::pt_mersenne: - cp->primeType = FPT_Mersenne; - break; - case FEEPrimeType::pt_fee: - cp->primeType = FPT_FEE; - break; - case FEEPrimeType::pt_general: - cp->primeType = FPT_General; - break; - default: - feeException::throwMe(FR_BadPubKey, "feeCurveParamsFromSnacc bad primeType"); - } - val = snaccCp.curveType; - switch(val) { - case FEECurveType::ct_montgomery: - cp->curveType = FCT_Montgomery; - break; - case FEECurveType::ct_weierstrass: - cp->curveType = FCT_Weierstrass; - break; - case FEECurveType::ct_general: - cp->curveType = FCT_General; - break; - default: - feeException::throwMe(FR_BadPubKey, "feeCurveParamsFromSnacc bad curveType"); - } - cp->q = snaccCp.q; - cp->k = snaccCp.k; - cp->m = snaccCp.m; - cp->a = bigIntStrToGiant(snaccCp.a); - cp->b = bigIntStrToGiant(snaccCp.bb); - cp->c = bigIntStrToGiant(snaccCp.c); - cp->x1Plus = bigIntStrToGiant(snaccCp.x1Plus); - cp->x1Minus = bigIntStrToGiant(snaccCp.x1Minus); - cp->cOrderPlus = bigIntStrToGiant(snaccCp.cOrderPlus); - cp->cOrderMinus = bigIntStrToGiant(snaccCp.cOrderMinus); - cp->x1OrderPlus = bigIntStrToGiant(snaccCp.x1OrderPlus); - cp->x1OrderMinus = bigIntStrToGiant(snaccCp.x1OrderMinus); - if(snaccCp.basePrime != NULL) { - cp->basePrime = bigIntStrToGiant(*snaccCp.basePrime); + cp->primeType = (feePrimeType)cssmDataToInt(asnCp.primeType); + cp->curveType = (feeCurveType)cssmDataToInt(asnCp.curveType); + cp->q = cssmDataToInt(asnCp.q); + cp->k = cssmDataToInt(asnCp.k); + cp->m = cssmDataToInt(asnCp.m); + cp->a = cssmDataToGiant(asnCp.a); + cp->b = cssmDataToGiant(asnCp.b_); + cp->c = cssmDataToGiant(asnCp.c); + cp->x1Plus = cssmDataToGiant(asnCp.x1Plus); + cp->x1Minus = cssmDataToGiant(asnCp.x1Minus); + cp->cOrderPlus = cssmDataToGiant(asnCp.cOrderPlus); + cp->cOrderMinus = cssmDataToGiant(asnCp.cOrderMinus); + cp->x1OrderPlus = cssmDataToGiant(asnCp.x1OrderPlus); + cp->x1OrderMinus = cssmDataToGiant(asnCp.x1OrderMinus); + if(asnCp.basePrime.Data != NULL) { + cp->basePrime = cssmDataToGiant(asnCp.basePrime); } /* remaining fields inferred */ @@ -475,33 +441,37 @@ feeReturn feeDEREncodeElGamalSignature( unsigned char **encodedSig, // fmallocd and RETURNED unsigned *encodedSigLen) // RETURNED { - FEEElGamalSignature snaccSig; - CssmAutoData oData(CssmAllocator::standard(CssmAllocator::sensitive)); + /* convert to FEEElGamalSignatureASN1 */ + FEEElGamalSignatureASN1 asnSig; + SecNssCoder coder; try { - giantToBigIntStr(u, snaccSig.u); - giantToBigIntStr(PmX, snaccSig.pmX); + giantToCssmData(u, asnSig.u, coder); + giantToCssmData(PmX, asnSig.pmX, coder); } catch(const feeException &ferr) { return ferr.frtn(); } - try { - SC_encodeAsnObj(snaccSig, oData, feeSizeOfDERSig(u, PmX)); - } - catch(...) { - /* FIXME - bad sig? memory? */ - return FR_BadSignatureFormat; + + /* DER encode */ + PRErrorCode perr; + CSSM_DATA encBlob; // mallocd by coder + perr = coder.encodeItem(&asnSig, FEEElGamalSignatureASN1Template, encBlob); + if(perr) { + return FR_Memory; } - *encodedSig = (unsigned char *)fmalloc(oData.length()); - *encodedSigLen = oData.length(); - memmove(*encodedSig, oData.get().Data, oData.length()); + + /* copy out to caller */ + *encodedSig = (unsigned char *)fmalloc(encBlob.Length); + *encodedSigLen = encBlob.Length; + memmove(*encodedSig, encBlob.Data, encBlob.Length); + #if PRINT_SIG_GIANTS printf("feeEncodeElGamalSignature:\n"); printf(" u : "); printGiantHex(u); printf(" PmX : "); printGiantHex(PmX); - printf(" u : "); snaccSig.u.Print(cout); printf("\n"); - printf(" PmX : "); snaccSig.pmX.Print(cout); printf("\n"); #endif + return FR_Success; } @@ -511,34 +481,38 @@ feeReturn feeDEREncodeECDSASignature( unsigned char **encodedSig, // fmallocd and RETURNED unsigned *encodedSigLen) // RETURNED { - FEEECDSASignature snaccSig; - CssmAutoData oData(CssmAllocator::standard(CssmAllocator::sensitive)); + /* convert to FEEECDSASignatureASN1 */ + FEEECDSASignatureASN1 asnSig; + SecNssCoder coder; try { - giantToBigIntStr(c, snaccSig.c); - giantToBigIntStr(d, snaccSig.d); - } + giantToCssmData(c, asnSig.c, coder); + giantToCssmData(d, asnSig.d, coder); + } catch(const feeException &ferr) { return ferr.frtn(); } - try { - SC_encodeAsnObj(snaccSig, oData, feeSizeOfDERSig(c, d)); - } - catch(...) { - /* FIXME - bad sig? memory? */ - return FR_BadSignatureFormat; + + /* DER encode */ + PRErrorCode perr; + CSSM_DATA encBlob; // mallocd by coder + perr = coder.encodeItem(&asnSig, FEEECDSASignatureASN1Template, encBlob); + if(perr) { + return FR_Memory; } - *encodedSig = (unsigned char *)fmalloc(oData.length()); - *encodedSigLen = oData.length(); - memmove(*encodedSig, oData.get().Data, oData.length()); + + /* copy out to caller */ + *encodedSig = (unsigned char *)fmalloc(encBlob.Length); + *encodedSigLen = encBlob.Length; + memmove(*encodedSig, encBlob.Data, encBlob.Length); + #if PRINT_SIG_GIANTS printf("feeEncodeECDSASignature:\n"); printf(" c : "); printGiantHex(*c); printf(" d : "); printGiantHex(*d); - printf(" c : "); snaccSig.c.Print(cout); printf("\n"); - printf(" d : "); snaccSig.d.Print(cout); printf("\n"); #endif return FR_Success; + } feeReturn feeDERDecodeElGamalSignature( @@ -547,17 +521,19 @@ feeReturn feeDERDecodeElGamalSignature( giant *u, // newGiant'd and RETURNED giant *PmX) // newGiant'd and RETURNED { - FEEElGamalSignature snaccSig; - CssmData cData((void *)encodedSig, encodedSigLen); - try { - SC_decodeAsnObj(cData, snaccSig); - } - catch(...) { + FEEElGamalSignatureASN1 asnSig; + SecNssCoder coder; + + memset(&asnSig, 0, sizeof(asnSig)); + PRErrorCode perr = coder.decode(encodedSig, encodedSigLen, + FEEElGamalSignatureASN1Template, &asnSig); + if(perr) { return FR_BadSignatureFormat; } + try { - *u = bigIntStrToGiant(snaccSig.u); - *PmX = bigIntStrToGiant(snaccSig.pmX); + *u = cssmDataToGiant(asnSig.u); + *PmX = cssmDataToGiant(asnSig.pmX); } catch(const feeException &ferr) { return ferr.frtn(); @@ -570,8 +546,6 @@ feeReturn feeDERDecodeElGamalSignature( printf("feeDecodeElGamalSignature:\n"); printf(" u : "); printGiantHex(*u); printf(" PmX : "); printGiantHex(*PmX); - printf(" u : "); snaccSig.u.Print(cout); printf("\n"); - printf(" PmX : "); snaccSig.pmX.Print(cout); printf("\n"); #endif return FR_Success; } @@ -582,17 +556,19 @@ feeReturn feeDERDecodeECDSASignature( giant *c, // newGiant'd and RETURNED giant *d) // newGiant'd and RETURNED { - FEEECDSASignature snaccSig; - CssmData cData((void *)encodedSig, encodedSigLen); - try { - SC_decodeAsnObj(cData, snaccSig); - } - catch(...) { + FEEECDSASignatureASN1 asnSig; + SecNssCoder coder; + + memset(&asnSig, 0, sizeof(asnSig)); + PRErrorCode perr = coder.decode(encodedSig, encodedSigLen, + FEEECDSASignatureASN1Template, &asnSig); + if(perr) { return FR_BadSignatureFormat; } + try { - *c = bigIntStrToGiant(snaccSig.c); - *d = bigIntStrToGiant(snaccSig.d); + *c = cssmDataToGiant(asnSig.c); + *d = cssmDataToGiant(asnSig.d); } catch(const feeException &ferr) { return ferr.frtn(); @@ -602,11 +578,9 @@ feeReturn feeDERDecodeECDSASignature( return FR_Memory; } #if PRINT_SIG_GIANTS - printf("feeDecodeECDSASignature:\n"); - printf(" c : "); printGiantHex(*c); - printf(" d : "); printGiantHex(*d); - printf(" c : "); snaccSig.c.Print(cout); printf("\n"); - printf(" d : "); snaccSig.d.Print(cout); printf("\n"); + printf("feeDERDecodeECDSASignature:\n"); + printf(" u : "); printGiantHex(*u); + printf(" PmX : "); printGiantHex(*PmX); #endif return FR_Success; } @@ -624,36 +598,36 @@ feeReturn feeDEREncodePublicKey( unsigned char **keyBlob, // fmallocd and RETURNED unsigned *keyBlobLen) // RETURNED { - FEEPublicKey snaccKey; + FEEPublicKeyASN1 asnKey; + SecNssCoder coder; + + memset(&asnKey, 0, sizeof(asnKey)); + intToCssmData(version, asnKey.version, coder); - /* set up the SNACC object */ - snaccKey.version.Set(version); try { - snaccKey.curveParams = feeCurveParamsToSnacc(cp); - giantToBigIntStr(plusX, snaccKey.plusX); - giantToBigIntStr(minusX, snaccKey.minusX); + feeCurveParamsToASN1(cp, asnKey.curveParams, coder); + giantToCssmData(plusX, asnKey.plusX, coder); + giantToCssmData(minusX, asnKey.minusX, coder); if(plusY != NULL) { - snaccKey.plusY = new BigIntegerStr(); - giantToBigIntStr(plusY, *snaccKey.plusY); + giantToCssmData(plusY, asnKey.plusY, coder); } } catch(const feeException &ferr) { return ferr.frtn(); } - /* encode the SNACC object */ - CssmAutoData oData(CssmAllocator::standard(CssmAllocator::sensitive)); - - try { - SC_encodeAsnObj(snaccKey, oData, feeSizeOfSnaccPubKey(cp)); - } - catch(...) { - /* FIXME - ???? */ + /* DER encode */ + PRErrorCode perr; + CSSM_DATA encBlob; // mallocd by coder + perr = coder.encodeItem(&asnKey, FEEPublicKeyASN1Template, encBlob); + if(perr) { return FR_Memory; } - *keyBlob = (unsigned char *)fmalloc(oData.length()); - *keyBlobLen = oData.length(); - memmove(*keyBlob, oData.get().Data, oData.length()); + + /* copy out */ + *keyBlob = (unsigned char *)fmalloc(encBlob.Length); + *keyBlobLen = encBlob.Length; + memmove(*keyBlob, encBlob.Data, encBlob.Length); return FR_Success; } @@ -664,31 +638,32 @@ feeReturn feeDEREncodePrivateKey( unsigned char **keyBlob, // fmallocd and RETURNED unsigned *keyBlobLen) // RETURNED { - FEEPrivateKey snaccKey; + FEEPrivateKeyASN1 asnKey; + SecNssCoder coder; + + memset(&asnKey, 0, sizeof(asnKey)); + intToCssmData(version, asnKey.version, coder); - /* set up the SNACC object */ - snaccKey.version.Set(version); try { - snaccKey.curveParams = feeCurveParamsToSnacc(cp); - giantToBigIntStr(privData, snaccKey.privData); + feeCurveParamsToASN1(cp, asnKey.curveParams, coder); + giantToCssmData(privData, asnKey.privData, coder); } catch(const feeException &ferr) { return ferr.frtn(); } - /* encode the SNACC object */ - CssmAutoData oData(CssmAllocator::standard(CssmAllocator::sensitive)); - - try { - SC_encodeAsnObj(snaccKey, oData, feeSizeOfSnaccPrivKey(cp)); - } - catch(...) { - /* FIXME - ???? */ + /* DER encode */ + PRErrorCode perr; + CSSM_DATA encBlob; // mallocd by coder + perr = coder.encodeItem(&asnKey, FEEPrivateKeyASN1Template, encBlob); + if(perr) { return FR_Memory; } - *keyBlob = (unsigned char *)fmalloc(oData.length()); - *keyBlobLen = oData.length(); - memmove(*keyBlob, oData.get().Data, oData.length()); + + /* copy out */ + *keyBlob = (unsigned char *)fmalloc(encBlob.Length); + *keyBlobLen = encBlob.Length; + memmove(*keyBlob, encBlob.Data, encBlob.Length); return FR_Success; } @@ -701,22 +676,24 @@ feeReturn feeDERDecodePublicKey( giant *minusX, giant *plusY) // may be NULL { - FEEPublicKey snaccKey; - CssmData cData((unsigned char *)keyBlob, (size_t)keyBlobLen); - try { - SC_decodeAsnObj(cData, snaccKey); - } - catch(...) { - return FR_BadPubKey; + FEEPublicKeyASN1 asnKey; + SecNssCoder coder; + + memset(&asnKey, 0, sizeof(asnKey)); + PRErrorCode perr = coder.decode(keyBlob, keyBlobLen, + FEEPublicKeyASN1Template, &asnKey); + if(perr) { + return FR_BadKeyBlob; } + try { - *version = snaccKey.version; - *cp = feeCurveParamsFromSnacc(*snaccKey.curveParams); - *plusX = bigIntStrToGiant(snaccKey.plusX); - *minusX = bigIntStrToGiant(snaccKey.minusX); - if(snaccKey.plusY != NULL) { + *version = cssmDataToInt(asnKey.version); + *cp = feeCurveParamsFromAsn1(asnKey.curveParams); + *plusX = cssmDataToGiant(asnKey.plusX); + *minusX = cssmDataToGiant(asnKey.minusX); + if(asnKey.plusY.Data != NULL) { /* optional */ - *plusY = bigIntStrToGiant(*snaccKey.plusY); + *plusY = cssmDataToGiant(asnKey.plusY); } else { *plusY = newGiant(1); @@ -740,18 +717,20 @@ feeReturn feeDERDecodePrivateKey( curveParams **cp, giant *privData) // RETURNED { - FEEPrivateKey snaccKey; - CssmData cData((unsigned char *)keyBlob, (size_t)keyBlobLen); - try { - SC_decodeAsnObj(cData, snaccKey); - } - catch(...) { - return FR_BadPubKey; + FEEPrivateKeyASN1 asnKey; + SecNssCoder coder; + + memset(&asnKey, 0, sizeof(asnKey)); + PRErrorCode perr = coder.decode(keyBlob, keyBlobLen, + FEEPrivateKeyASN1Template, &asnKey); + if(perr) { + return FR_BadKeyBlob; } + try { - *version = snaccKey.version; - *cp = feeCurveParamsFromSnacc(*snaccKey.curveParams); - *privData = bigIntStrToGiant(snaccKey.privData); + *version = cssmDataToInt(asnKey.version); + *cp = feeCurveParamsFromAsn1(asnKey.curveParams); + *privData = cssmDataToGiant(asnKey.privData); } catch(const feeException &ferr) { return ferr.frtn(); diff --git a/AppleCSP/CryptKitCSP/FEECSPUtils.cpp b/AppleCSP/CryptKitCSP/FEECSPUtils.cpp index 31ca5f44..1b557ed2 100644 --- a/AppleCSP/CryptKitCSP/FEECSPUtils.cpp +++ b/AppleCSP/CryptKitCSP/FEECSPUtils.cpp @@ -32,7 +32,7 @@ #include #include -#define feeMiscDebug(args...) debug("feeMisc", ## args) +#define feeMiscDebug(args...) secdebug("feeMisc", ## args) /* Given a FEE error, throw appropriate CssmError */ void CryptKit::throwCryptKit( @@ -105,6 +105,7 @@ feePubKey CryptKit::contextToFeeKey( CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } cspValidateIntendedKeyUsage(&hdr, usage); + cspVerifyKeyTimes(hdr); return cssmKeyToFee(cssmKey, session, mallocdKey); } diff --git a/AppleCSP/CryptKitCSP/FEEKeys.cpp b/AppleCSP/CryptKitCSP/FEEKeys.cpp index 14f5d435..2d48e0f1 100644 --- a/AppleCSP/CryptKitCSP/FEEKeys.cpp +++ b/AppleCSP/CryptKitCSP/FEEKeys.cpp @@ -35,7 +35,7 @@ #include #include -#define feeKeyDebug(args...) debug("feeKey", ## args) +#define feeKeyDebug(args...) secdebug("feeKey", ## args) /*** *** FEE-style BinaryKey @@ -64,12 +64,17 @@ CryptKit::FEEBinaryKey::~FEEBinaryKey() void CryptKit::FEEBinaryKey::generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format) + CSSM_KEYBLOB_FORMAT &format, + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags) /* IN/OUT */ { unsigned char *keyBlob; unsigned len; feeReturn frtn; bool derBlob; + bool freeTheKey = false; + feePubKey keyToEncode = mFeeKey; assert(mFeeKey != NULL); switch(format) { @@ -77,6 +82,26 @@ void CryptKit::FEEBinaryKey::generateKeyBlob( case CSSM_KEYBLOB_RAW_FORMAT_NONE: derBlob = true; break; + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: + { + /* key digest calculation; special case for private keys: cook + * up the associated public key and encode that */ + if(mKeyHeader.KeyClass == CSSM_KEYCLASS_PRIVATE_KEY) { + keyToEncode = feePubKeyAlloc(); + if(keyToEncode == NULL) { + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + frtn = feePubKeyInitPubKeyFromPriv(mFeeKey, keyToEncode); + if(frtn) { + feePubKeyFree(keyToEncode); + throwCryptKit(frtn, "feePubKeyInitPubKeyFromPriv"); + } + freeTheKey = true; + } + /* in any case, DER-encode a public key */ + derBlob = true; + break; + } case CSSM_KEYBLOB_RAW_FORMAT_OCTET_STRING: /* native non-DER-encoded blob */ derBlob = false; @@ -87,20 +112,20 @@ void CryptKit::FEEBinaryKey::generateKeyBlob( CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT : CSSMERR_CSP_INVALID_ATTR_PUBLIC_KEY_FORMAT); } - if(feePubKeyIsPrivate(mFeeKey)) { + if(feePubKeyIsPrivate(keyToEncode)) { if(derBlob) { - frtn = feePubKeyCreateDERPrivBlob(mFeeKey, &keyBlob, &len); + frtn = feePubKeyCreateDERPrivBlob(keyToEncode, &keyBlob, &len); } else { - frtn = feePubKeyCreatePrivBlob(mFeeKey, &keyBlob, &len); + frtn = feePubKeyCreatePrivBlob(keyToEncode, &keyBlob, &len); } } else { if(derBlob) { - frtn = feePubKeyCreateDERPubBlob(mFeeKey, &keyBlob, &len); + frtn = feePubKeyCreateDERPubBlob(keyToEncode, &keyBlob, &len); } else { - frtn = feePubKeyCreatePubBlob(mFeeKey, &keyBlob, &len); + frtn = feePubKeyCreatePubBlob(keyToEncode, &keyBlob, &len); } } if(frtn) { @@ -112,6 +137,10 @@ void CryptKit::FEEBinaryKey::generateKeyBlob( ffree(keyBlob); format = derBlob ? FEE_KEYBLOB_DEFAULT_FORMAT : CSSM_KEYBLOB_RAW_FORMAT_OCTET_STRING; + if(freeTheKey) { + /* free the temp pub key we created here */ + feePubKeyFree(keyToEncode); + } } /*** @@ -249,12 +278,14 @@ void CryptKit::FEEKeyPairGenContext::generate( *** FEE-style CSPKeyInfoProvider. ***/ CryptKit::FEEKeyInfoProvider::FEEKeyInfoProvider( - const CssmKey &cssmKey) : - CSPKeyInfoProvider(cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) : + CSPKeyInfoProvider(cssmKey, session) { } CSPKeyInfoProvider *FEEKeyInfoProvider::provider( - const CssmKey &cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) { switch(cssmKey.algorithm()) { case CSSM_ALGID_FEE: @@ -271,12 +302,14 @@ CSPKeyInfoProvider *FEEKeyInfoProvider::provider( return NULL; } /* OK, we'll handle this one */ - return new FEEKeyInfoProvider(cssmKey); + return new FEEKeyInfoProvider(cssmKey, session); } /* Given a raw key, cook up a Binary key */ void CryptKit::FEEKeyInfoProvider::CssmKeyToBinary( - BinaryKey **binKey) + CssmKey *paramKey, // optional, ignored + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT + BinaryKey **binKey) { *binKey = NULL; feePubKey feeKey = NULL; @@ -307,4 +340,27 @@ void CryptKit::FEEKeyInfoProvider::QueryKeySizeInBits( feePubKeyFree(feeKey); } +/* + * Obtain blob suitable for hashing in CSSM_APPLECSP_KEYDIGEST + * passthrough. + */ +bool CryptKit::FEEKeyInfoProvider::getHashableBlob( + CssmAllocator &allocator, + CssmData &blob) // blob to hash goes here +{ + /* + * The optimized case, a raw key in the "proper" format already. + */ + assert(mKey.blobType() == CSSM_KEYBLOB_RAW); + if((mKey.blobFormat() == CSSM_KEYBLOB_RAW_FORMAT_NONE) && + (mKey.keyClass() == CSSM_KEYCLASS_PUBLIC_KEY)) { + const CssmData &keyBlob = CssmData::overlay(mKey.KeyData); + copyCssmData(keyBlob, blob, allocator); + return true; + } + + /* caller converts to binary and proceeds */ + return false; +} + #endif /* CRYPTKIT_CSP_ENABLE */ diff --git a/AppleCSP/CryptKitCSP/FEEKeys.h b/AppleCSP/CryptKitCSP/FEEKeys.h index 1c7b0532..a1109f84 100644 --- a/AppleCSP/CryptKitCSP/FEEKeys.h +++ b/AppleCSP/CryptKitCSP/FEEKeys.h @@ -29,6 +29,7 @@ #include "AppleCSPContext.h" #include "AppleCSPSession.h" +#include "AppleCSPKeys.h" #include #include @@ -44,8 +45,11 @@ public: void generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format); - + CSSM_KEYBLOB_FORMAT &format, + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags); /* IN/OUT */ + feePubKey feeKey() { return mFeeKey; } private: feePubKey mFeeKey; @@ -88,15 +92,23 @@ class FEEKeyInfoProvider : public CSPKeyInfoProvider { private: FEEKeyInfoProvider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); public: static CSPKeyInfoProvider *provider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); + ~FEEKeyInfoProvider() { } void CssmKeyToBinary( + CssmKey *paramKey, // optional, ignored here + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT BinaryKey **binKey); // RETURNED void QueryKeySizeInBits( CSSM_KEY_SIZE &keySize); // RETURNED + bool getHashableBlob( + CssmAllocator &allocator, + CssmData &hashBlob); }; } /* namespace CryptKit */ diff --git a/AppleCSP/CryptKitCSP/FEESignatureObject.cpp b/AppleCSP/CryptKitCSP/FEESignatureObject.cpp index 519c1f7b..d80604e5 100644 --- a/AppleCSP/CryptKitCSP/FEESignatureObject.cpp +++ b/AppleCSP/CryptKitCSP/FEESignatureObject.cpp @@ -32,7 +32,7 @@ #include #include -#define feeSigObjDebug(args...) debug("feeSig", ##args) +#define feeSigObjDebug(args...) secdebug("feeSig", ##args) CryptKit::FEESigner::~FEESigner() { diff --git a/AppleCSP/DiffieHellman/DH_exchange.cpp b/AppleCSP/DiffieHellman/DH_exchange.cpp index 385f6490..1d1a7c48 100644 --- a/AppleCSP/DiffieHellman/DH_exchange.cpp +++ b/AppleCSP/DiffieHellman/DH_exchange.cpp @@ -24,47 +24,95 @@ #include #include #include "DH_utils.h" +#include "DH_keys.h" #include #include void DeriveKey_DH ( const Context &context, - const CssmData &Param, // other's public key + const CssmData &Param, // other's public key. may be empty CSSM_DATA *keyData, // mallocd by caller // we fill in keyData->Length bytes AppleCSPSession &session) { - bool mallocdKey; + bool mallocdPrivKey; size_t privSize; - /* private DH key from context */ - DH *privKey = contextToDhKey(context, session, CSSM_KEYUSE_DERIVE, - mallocdKey); + /* private DH key from context - required */ + DH *privKey = contextToDhKey(context, session, CSSM_ATTRIBUTE_KEY, + CSSM_KEYCLASS_PRIVATE_KEY, CSSM_KEYUSE_DERIVE, mallocdPrivKey); + if(privKey == NULL) { + CssmError::throwMe(CSSMERR_CSP_MISSING_ATTR_KEY); + } + cspDhDebug("DeriveKey_DH, privKey %p", privKey); privSize = DH_size(privKey); if(privSize < keyData->Length) { /* we've been asked for more bits than this key can generate */ CssmError::throwMe(CSSMERR_CSP_UNSUPPORTED_KEY_SIZE); } - BIGNUM *pubKey = BN_bin2bn(Param.Data, Param.Length, NULL); - if(pubKey == NULL) { - CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + + /* + * Public key ("their" key) can come from two places: + * -- in the context as a CSSM_ATTRIBUTE_PUBLIC_KEY. THis is how + * public keys in X509 for must be used in this function + * -- in the incoming Param, the raw unformatted (PKCS3) form + */ + bool mallocdPubKey = false; + BIGNUM *pubKeyBn = NULL; + bool allocdPubKeyBn = false; + DH *pubKey = contextToDhKey(context, session, CSSM_ATTRIBUTE_PUBLIC_KEY, + CSSM_KEYCLASS_PUBLIC_KEY, CSSM_KEYUSE_DERIVE, mallocdPubKey); + if(pubKey != NULL) { + if(pubKey->pub_key == NULL) { + errorLog0("DeriveKey_DH: public key in context with no pub_key\n"); + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); + } + pubKeyBn = pubKey->pub_key; + cspDhDebug("DeriveKey_DH, pubKey from context %p", pubKey); + } + else { + if((Param.Data == NULL) || (Param.Length == 0)) { + errorLog0("DeriveKey_DH: no pub_key, no Param\n"); + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); + } + pubKeyBn = BN_bin2bn(Param.Data, Param.Length, NULL); + if(pubKeyBn == NULL) { + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + allocdPubKeyBn = true; + cspDhDebug("DeriveKey_DH, no pubKey in context"); } unsigned char *buf = (unsigned char *)session.malloc(privSize); - int rtn = DH_compute_key(buf, pubKey, privKey); - if(rtn >= 0) { + int rtn = DH_compute_key(buf, pubKeyBn, privKey); + if(rtn > 0) { /* * FIXME : I have not found a specification describing *which* * bytes of the value we just computed we are supposed to * use as the actual key bytes. We use the M.S. bytes. + * + * Note that due to modulo arithmetic, we may have gotten fewer + * bytes than we asked for. If so, the caller will have + * to deal with that if they really need privSize bytes. */ - memmove(keyData->Data, buf, keyData->Length); + assert((uint32)rtn <= privSize); + uint32 toMove = keyData->Length; + if((uint32)rtn < toMove) { + toMove = (uint32)rtn; + } + memmove(keyData->Data, buf, toMove); + keyData->Length = toMove; } - if(mallocdKey) { + if(mallocdPrivKey) { DH_free(privKey); } - BN_free(pubKey); + if(mallocdPubKey) { + DH_free(pubKey); + } + if(allocdPubKeyBn) { + BN_free(pubKeyBn); + } session.free(buf); - if(rtn < 0) { + if(rtn <= 0) { throwRsaDsa("DH_compute_key"); } } diff --git a/AppleCSP/DiffieHellman/DH_keys.cpp b/AppleCSP/DiffieHellman/DH_keys.cpp index 02022c5a..3dcb6f4f 100644 --- a/AppleCSP/DiffieHellman/DH_keys.cpp +++ b/AppleCSP/DiffieHellman/DH_keys.cpp @@ -23,19 +23,16 @@ #include "DH_keys.h" #include "DH_utils.h" #include -#include +#include #include #include #include #include #include +#include #include -#include -#include -#include -#include -#define dhKeyDebug(args...) debug("dhKey", ## args) +#define dhKeyDebug(args...) secdebug("dhKey", ## args) /* * FIXME - the CDSA Algorithm Guide claims that the incoming params argument @@ -51,57 +48,100 @@ *** Diffie-Hellman-style BinaryKey ***/ -/* constructor with optional existing RSA key */ +/* constructor with optional existing DSA key */ DHBinaryKey::DHBinaryKey(DH *dhKey) : mDhKey(dhKey) { - mPubKey.Data = NULL; - mPubKey.Length = 0; -} - -DHBinaryKey::DHBinaryKey(const CSSM_DATA *pubBlob) - : mDhKey(NULL) -{ - setPubBlob(pubBlob); } DHBinaryKey::~DHBinaryKey() { if(mDhKey) { - assert(mPubKey.Data == NULL); DH_free(mDhKey); mDhKey = NULL; } - if(mPubKey.Data) { - assert(mDhKey == NULL); - DH_Factory::privAllocator->free(mPubKey.Data); - mPubKey.Data = NULL; - mPubKey.Length = 0; - } } void DHBinaryKey::generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format) + CSSM_KEYBLOB_FORMAT &format, + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags) /* IN/OUT */ { + switch(mKeyHeader.KeyClass) { case CSSM_KEYCLASS_PUBLIC_KEY: { - /* trivial case, just copy the public blob */ - assert(mDhKey == NULL); - assert(mPubKey.Data != NULL); - format = DH_PUB_KEY_FORMAT; - copyCssmData(CssmData::overlay(mPubKey), blob, allocator); + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: + // take default + format = DH_PUB_KEY_FORMAT; + break; + case DH_PUB_KEY_FORMAT: + case CSSM_KEYBLOB_RAW_FORMAT_X509: + // proceed + break; + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: + /* use PKCS3 - caller won't care if we change this...right? */ + format = DH_PUB_KEY_FORMAT; + break; + default: + CssmError::throwMe(CSSMERR_CSP_UNSUPPORTED_KEY_FORMAT); + } + + assert(mDhKey != NULL); + CssmAutoData encodedKey(allocator); + CSSM_RETURN crtn = DHPublicKeyEncode(mDhKey, format, + encodedKey); + if(crtn) { + CssmError::throwMe(crtn); + } + blob = encodedKey.release(); break; } case CSSM_KEYCLASS_PRIVATE_KEY: { + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: + // i.e., use default + format = DH_PRIV_KEY_FORMAT; + break; + case DH_PRIV_KEY_FORMAT: + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + // proceed + break; + + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: + { + /* + * Use public blob; calculate it if we + * don't already have it. + */ + assert(mDhKey != NULL); + if(mDhKey->pub_key == NULL) { + int irtn = DH_generate_key(mDhKey); + if(!irtn) { + throwRsaDsa("DH_generate_key"); + } + } + assert(mDhKey->pub_key != NULL); + setUpData(blob, + BN_num_bytes(mDhKey->pub_key), + *DH_Factory::privAllocator); + BN_bn2bin(mDhKey->pub_key, blob); + format = DH_PUB_KEY_FORMAT; + return; + } + + default: + CssmError::throwMe(CSSMERR_CSP_UNSUPPORTED_KEY_FORMAT); + } assert(mDhKey != NULL); - assert(mPubKey.Data == NULL); - format = DH_PRIV_KEY_FORMAT; CssmAutoData encodedKey(allocator); - CSSM_RETURN crtn = DHPrivateKeyEncode(mDhKey, encodedKey); + CSSM_RETURN crtn = DHPrivateKeyEncode(mDhKey, format, + encodedKey); if(crtn) { CssmError::throwMe(crtn); } @@ -113,25 +153,6 @@ void DHBinaryKey::generateKeyBlob( } } -/* for importing.... */ -void DHBinaryKey::setPubBlob(const CSSM_DATA *pubBlob) -{ - assert(mDhKey == NULL); - assert(mPubKey.Data == NULL); - setUpData(mPubKey, pubBlob->Length, *DH_Factory::privAllocator); - memmove(mPubKey.Data, pubBlob->Data, pubBlob->Length); -} - -/* for creating from a full DH private key... */ -void DHBinaryKey::setPubBlob(DH *privKey) -{ - assert(mDhKey == NULL); - assert(mPubKey.Data == NULL); - setUpData(mPubKey, BN_num_bytes(privKey->pub_key), - *DH_Factory::privAllocator); - BN_bn2bin(privKey->pub_key, mPubKey.Data); -} - /*** *** Diffie-Hellman style AppleKeyPairGenContext ***/ @@ -164,31 +185,6 @@ void DHKeyPairGenContext::generate( } } -/* - * obtain a 32-bit integer from a BigIntegerStr. - */ -static uint32 bigIntStrToInt( - const BigIntegerStr &bint, - CSSM_RETURN toThrow) // throws this if out of range -{ - size_t bytes = bint.Len(); - if(bytes > 4) { - dhKeyDebug("DH integer overflow"); - if(toThrow) { - CssmError::throwMe(toThrow); - } - else { - return 0; - } - } - uint32 rtn = 0; - const unsigned char *uo = (const unsigned char *)bint.Octs(); - for(size_t i=0; i(CSSM_ATTRIBUTE_ALG_PARAMS); - DHParameterBlock algParamBlock; - DHParameter *algParams = NULL; + NSS_DHParameterBlock algParamBlock; + NSS_DHParameter &algParams = algParamBlock.params; uint32 privValueLen = 0; // only nonzero from externally generated // params + SecNssCoder coder; // for temp allocs of decoded parameters if(paramData != NULL) { /* this contains the DER encoding of a DHParameterBlock */ - try { - SC_decodeAsnObj(*paramData, algParamBlock); - } - catch(...) { - /* - * CDSA Extension: the CDSA Algorithm Guide says that the D-H - * parameter block is supposed to be wrapped with its accompanying - * OID. However Openssl does not do this; it just exports - * an encoded DHParameter rather than a DHParameterBlock. - * For compatibility we'll try decoding the parameters as one - * of these. - */ - if(algParamBlock.params) { - delete algParamBlock.params; - algParamBlock.params = NULL; - } - algParamBlock.params = new DHParameter; - try { - SC_decodeAsnObj(*paramData, *algParamBlock.params); - dhKeyDebug("Trying openssl-style DH param decoding"); - } - catch(...) { - dhKeyDebug("openssl-style DH param decoding FAILED"); - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS); - } - } - - algParams = algParamBlock.params; - if(algParams == NULL) { - dhKeyDebug("Bad DH param decoding"); - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS); + CSSM_RETURN crtn; + crtn = DHParamBlockDecode(*paramData, algParamBlock, coder); + if(crtn) { + CssmError::throwMe(crtn); } /* snag the optional private key length field */ - if(algParams->privateValueLength) { - privValueLen = bigIntStrToInt(*algParams->privateValueLength, - CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS); + if(algParams.privateValueLength.Data) { + privValueLen = cssmDataToInt(algParams.privateValueLength); } /* ensure caller's key size matches the incoming params */ @@ -271,10 +240,10 @@ void DHKeyPairGenContext::generate( paramKeyBytes = (privValueLen + 7) / 8; } else { - paramKeyBytes = algParams->prime.Len(); + paramKeyBytes = algParams.prime.Length; /* trim off possible m.s. byte of zero */ const unsigned char *uo = - (const unsigned char *)algParams->prime.Octs(); + (const unsigned char *)algParams.prime.Data; if(*uo == 0) { paramKeyBytes--; } @@ -289,9 +258,8 @@ void DHKeyPairGenContext::generate( else { /* no alg params specified; generate them now */ dhKeyDebug("DH implicit alg param calculation"); - algParamBlock.params = new DHParameter; - algParams = algParamBlock.params; - dhGenParams(keyBits, DH_GENERATOR_DEFAULT, 0, *algParams); + memset(&algParamBlock, 0, sizeof(algParamBlock)); + dhGenParams(keyBits, DH_GENERATOR_DEFAULT, 0, algParams, coder); } /* create key, stuff params into it */ @@ -300,9 +268,10 @@ void DHKeyPairGenContext::generate( CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); } DH *dhKey = rPrivBinKey.mDhKey; - dhKey->p = bigIntStrToBn(algParams->prime); - dhKey->g = bigIntStrToBn(algParams->base); + dhKey->p = cssmDataToBn(algParams.prime); + dhKey->g = cssmDataToBn(algParams.base); dhKey->length = privValueLen; + cspDhDebug("private DH binary key dhKey %p", dhKey); /* generate the key (both public and private capabilities) */ int irtn = DH_generate_key(dhKey); @@ -310,8 +279,17 @@ void DHKeyPairGenContext::generate( throwRsaDsa("DH_generate_key"); } - /* public key just a blob */ - rPubBinKey.setPubBlob(dhKey); + /* public key is a subset */ + rPubBinKey.mDhKey = DH_new(); + if(rPubBinKey.mDhKey == NULL) { + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + DH *pubDhKey = rPubBinKey.mDhKey; + pubDhKey->pub_key = BN_dup(dhKey->pub_key); + /* these params used for X509 style key blobs */ + pubDhKey->p = BN_dup(dhKey->p); + pubDhKey->g = BN_dup(dhKey->g); + cspDhDebug("public DH binary key pubDhKey %p", pubDhKey); } @@ -320,8 +298,15 @@ void DHKeyPairGenContext::generate( *** Diffie-Hellman CSPKeyInfoProvider. ***/ DHKeyInfoProvider::DHKeyInfoProvider( - const CssmKey &cssmKey) : - CSPKeyInfoProvider(cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) : + CSPKeyInfoProvider(cssmKey, session) +{ +} + +CSPKeyInfoProvider *DHKeyInfoProvider::provider( + const CssmKey &cssmKey, + AppleCSPSession &session) { switch(cssmKey.algorithm()) { case CSSM_ALGID_DH: @@ -337,35 +322,31 @@ DHKeyInfoProvider::DHKeyInfoProvider( CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } /* OK, we'll handle this one */ - return; + return new DHKeyInfoProvider(cssmKey, session); } /* Given a raw key, cook up a Binary key */ void DHKeyInfoProvider::CssmKeyToBinary( - BinaryKey **binKey) + CssmKey *paramKey, // optional, ignored here + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT + BinaryKey **binKey) { *binKey = NULL; assert(mKey.blobType() == CSSM_KEYBLOB_RAW); switch(mKey.keyClass()) { case CSSM_KEYCLASS_PUBLIC_KEY: - { - /* trivial case - no DH * */ - DHBinaryKey *dhKey = new DHBinaryKey(&mKey.KeyData); - *binKey = dhKey; - break; - } case CSSM_KEYCLASS_PRIVATE_KEY: - { - /* first cook up an DH key, then drop that into a BinaryKey */ - DH *dhKey = rawCssmKeyToDh(mKey); - DHBinaryKey *dhBinKey = new DHBinaryKey(dhKey); - *binKey = dhBinKey; break; - } default: CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } + + /* first cook up an DH key, then drop that into a BinaryKey */ + DH *dhKey = rawCssmKeyToDh(mKey); + DHBinaryKey *dhBinKey = new DHBinaryKey(dhKey); + *binKey = dhBinKey; + cspDhDebug("CssmKeyToBinary dhKey %p", dhKey); } /* @@ -380,26 +361,58 @@ void DHKeyInfoProvider::QueryKeySizeInBits( if(mKey.blobType() != CSSM_KEYBLOB_RAW) { CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_FORMAT); } + DH *dhKey = rawCssmKeyToDh(mKey); + + /* DH_size requires the p parameter, which some public keys don't have */ + if(dhKey->p != NULL) { + numBits = DH_size(dhKey) * 8; + } + else { + assert(dhKey->pub_key != NULL); + numBits = BN_num_bytes(dhKey->pub_key) * 8; + } + DH_free(dhKey); + keySize.LogicalKeySizeInBits = numBits; + keySize.EffectiveKeySizeInBits = numBits; +} + +/* + * Obtain blob suitable for hashing in CSSM_APPLECSP_KEYDIGEST + * passthrough. + */ +bool DHKeyInfoProvider::getHashableBlob( + CssmAllocator &allocator, + CssmData &blob) // blob to hash goes here +{ + /* + * The optimized case, a raw key in the "proper" format already. + */ + assert(mKey.blobType() == CSSM_KEYBLOB_RAW); + bool useAsIs = false; + switch(mKey.keyClass()) { case CSSM_KEYCLASS_PUBLIC_KEY: - /* trivial case */ - numBits = mKey.KeyData.Length * 8; + if(mKey.blobFormat() == CSSM_KEYBLOB_RAW_FORMAT_PKCS3) { + useAsIs = true; + } break; case CSSM_KEYCLASS_PRIVATE_KEY: - { - DH *dhKey = rawCssmKeyToDh(mKey); - numBits = DH_size(dhKey) * 8; - DH_free(dhKey); break; - } default: - CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); + /* shouldn't be here */ + assert(0); + CssmError::throwMe(CSSMERR_CSP_INTERNAL_ERROR); } - keySize.LogicalKeySizeInBits = numBits; - keySize.EffectiveKeySizeInBits = numBits; + if(useAsIs) { + const CssmData &keyBlob = CssmData::overlay(mKey.KeyData); + copyCssmData(keyBlob, blob, allocator); + return true; + } + + /* caller converts to binary and proceeds */ + return false; } - /* * Generate keygen parameters, stash them in a context attr array for later use * when actually generating the keys. @@ -413,13 +426,13 @@ void DHKeyPairGenContext::generate( Context::Attr * &attrs) // and here { /* generate the params */ - DHParameterBlock algParamBlock; - algParamBlock.params = new DHParameter; - DHParameter *algParams = algParamBlock.params; - dhGenParams(bitSize, DH_GENERATOR_DEFAULT, 0, *algParams); + NSS_DHParameterBlock algParamBlock; + SecNssCoder coder; + NSS_DHParameter &algParams = algParamBlock.params; + dhGenParams(bitSize, DH_GENERATOR_DEFAULT, 0, algParams, coder); /* drop in the required OID */ - algParamBlock.oid.Set(pkcs_3_arc); + algParamBlock.oid = CSSMOID_PKCS3; /* * Here comes the fun part. @@ -433,14 +446,14 @@ void DHKeyPairGenContext::generate( * * First, DER encode. */ - size_t maxSize = sizeofBigInt(algParams->prime) + - sizeofBigInt(algParams->base) - + 30; // includes oid, tag, length - if(algParams->privateValueLength) { - maxSize += sizeofBigInt(*algParams->privateValueLength); - } CssmAutoData aDerData(session()); - SC_encodeAsnObj(algParamBlock, aDerData, maxSize); + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&algParamBlock, NSS_DHParameterBlockTemplate, + aDerData); + if(perr) { + /* only known error... */ + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } /* copy/release that into a mallocd CSSM_DATA. */ CSSM_DATA_PTR derData = (CSSM_DATA_PTR)session().malloc(sizeof(CSSM_DATA)); @@ -488,7 +501,9 @@ void DHKeyPairGenContext::dhGenParams( uint32 keySizeInBits, unsigned g, // probably should be BIGNUM int privValueLength, // optional - DHParameter &algParams) + NSS_DHParameter &algParams, + SecNssCoder &coder) // temp contents of algParams + // mallocd here { /* validate key size */ if((keySizeInBits < DH_MIN_KEY_SIZE) || @@ -502,12 +517,16 @@ void DHKeyPairGenContext::dhGenParams( throwRsaDsa("DSA_generate_parameters"); } - /* stuff dhKey->{p,g,length}] into a caller's DSAAlgParams */ - bnToBigIntStr(dhKey->p, algParams.prime); - bnToBigIntStr(dhKey->g, algParams.base); + /* stuff dhKey->{p,g,length}] into a caller's NSS_DHParameter */ + bnToCssmData(dhKey->p, algParams.prime, coder); + bnToCssmData(dhKey->g, algParams.base, coder); + CSSM_DATA &privValData = algParams.privateValueLength; if(privValueLength) { - algParams.privateValueLength = new BigIntegerStr(); - snaccIntToBigIntegerStr(g, *algParams.privateValueLength); + intToCssmData(privValueLength, privValData, coder); + } + else { + privValData.Data = NULL; + privValData.Length = 0; } DH_free(dhKey); } diff --git a/AppleCSP/DiffieHellman/DH_keys.h b/AppleCSP/DiffieHellman/DH_keys.h index 1ed8a4b5..408a9fb1 100644 --- a/AppleCSP/DiffieHellman/DH_keys.h +++ b/AppleCSP/DiffieHellman/DH_keys.h @@ -25,11 +25,13 @@ #include #include +#include "AppleCSPKeys.h" #include #include #include -#include -#include +#include +#include +#include #define DH_PUB_KEY_FORMAT CSSM_KEYBLOB_RAW_FORMAT_PKCS3 #define DH_PRIV_KEY_FORMAT CSSM_KEYBLOB_RAW_FORMAT_PKCS3 @@ -37,28 +39,28 @@ #define DH_MIN_KEY_SIZE 512 /* FIXME */ #define DH_MAX_KEY_SIZE 2048 +#define cspDhDebug(args...) secdebug("dhDebug", ## args) + /* * Diffie-Hellman version of a BinaryKey. */ class DHBinaryKey : public BinaryKey { public: - DHBinaryKey(DH *dhKey = NULL); // for private key - DHBinaryKey(const CSSM_DATA *pubBlob); // for public key + DHBinaryKey(DH *dhKey = NULL); ~DHBinaryKey(); void generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format); - - void setPubBlob(const CSSM_DATA *pubBlob); - void setPubBlob(DH *privKey); - - /* - * At most one of these is valid - a DH for a private key, - * CSSM_DATA for public. + CSSM_KEYBLOB_FORMAT &format, + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags); /* IN/OUT */ + + /* + * This may contain a fully-capable private key, or a public + * key with as little as the pub_key field set. */ DH *mDhKey; - CSSM_DATA mPubKey; }; class DHKeyPairGenContext : @@ -109,7 +111,8 @@ public: uint32 keySizeInBits, unsigned g, // probably should be BIGNUM int privValueLength, // optional - DHParameter &algParams); + NSS_DHParameter &algParams, + SecNssCoder &coder); // for temp contents of algParams private: /* gross hack to store attributes "returned" from GenParams */ @@ -122,14 +125,25 @@ private: */ class DHKeyInfoProvider : public CSPKeyInfoProvider { -public: +private: DHKeyInfoProvider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); +public: + static CSPKeyInfoProvider *provider( + const CssmKey &cssmKey, + AppleCSPSession &session); + ~DHKeyInfoProvider() { } void CssmKeyToBinary( + CssmKey *paramKey, // optional, ignored here + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT BinaryKey **binKey); // RETURNED void QueryKeySizeInBits( CSSM_KEY_SIZE &keySize); // RETURNED + bool getHashableBlob( + CssmAllocator &allocator, + CssmData &hashBlob); }; #endif /* _DH_KEYS_H_ */ diff --git a/AppleCSP/DiffieHellman/DH_utils.cpp b/AppleCSP/DiffieHellman/DH_utils.cpp index c1ecce3f..4dbf7b3e 100644 --- a/AppleCSP/DiffieHellman/DH_utils.cpp +++ b/AppleCSP/DiffieHellman/DH_utils.cpp @@ -22,44 +22,50 @@ #include "DH_utils.h" #include "DH_keys.h" -#include +#include #include #include -#include +#include #include #include #include -#define dhMiscDebug(args...) debug("dhMisc", ## args) +#define dhMiscDebug(args...) secdebug("dhMisc", ## args) /* * Given a Context: - * -- obtain CSSM key (there must only be one) - * -- validate keyClass - MUST be private! (DH public keys are never found - * in contexts.) + * -- obtain CSSM key with specified attr (there must only be one) + * -- validate keyClass per caller's specification * -- validate keyUsage * -- convert to DH *, allocating the DH key if necessary */ DH *contextToDhKey( - const Context &context, - AppleCSPSession &session, + const Context &context, + AppleCSPSession &session, + CSSM_ATTRIBUTE_TYPE attr, // CSSM_ATTRIBUTE_KEY for private key + // CSSM_ATTRIBUTE_PUBLIC_KEY for public key + CSSM_KEYCLASS keyClass, // CSSM_KEYCLASS_{PUBLIC,PRIVATE}_KEY CSSM_KEYUSE usage, // CSSM_KEYUSE_ENCRYPT, CSSM_KEYUSE_SIGN, etc. bool &mallocdKey) // RETURNED { - CssmKey &cssmKey = - context.get(CSSM_ATTRIBUTE_KEY, CSSMERR_CSP_MISSING_ATTR_KEY); - const CSSM_KEYHEADER &hdr = cssmKey.KeyHeader; + CssmKey *cssmKey = context.get(attr); + if(cssmKey == NULL) { + return NULL; + } + const CSSM_KEYHEADER &hdr = cssmKey->KeyHeader; if(hdr.AlgorithmId != CSSM_ALGID_DH) { CssmError::throwMe(CSSMERR_CSP_ALGID_MISMATCH); } - if(hdr.KeyClass != CSSM_KEYCLASS_PRIVATE_KEY) { + if(hdr.KeyClass != keyClass) { CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } cspValidateIntendedKeyUsage(&hdr, usage); - return cssmKeyToDh(cssmKey, session, mallocdKey); + cspVerifyKeyTimes(hdr); + return cssmKeyToDh(*cssmKey, session, mallocdKey); } + /* - * Convert a CssmKey (Private only!) to an DH * key. May result in the + * Convert a CssmKey to an DH * key. May result in the * creation of a new DH (when cssmKey is a raw key); allocdKey is true * in that case in which case the caller generally has to free the allocd key). */ @@ -76,10 +82,10 @@ DH *cssmKeyToDh( // someone else's key (should never happen) CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); } - assert(hdr->KeyClass == CSSM_KEYCLASS_PRIVATE_KEY); switch(hdr->BlobType) { case CSSM_KEYBLOB_RAW: dhKey = rawCssmKeyToDh(cssmKey); + cspDhDebug("cssmKeyToDh, raw, dhKey %p", dhKey); allocdKey = true; break; case CSSM_KEYBLOB_REFERENCE: @@ -89,11 +95,11 @@ DH *cssmKeyToDh( /* this cast failing means that this is some other * kind of binary key */ if(dhBinKey == NULL) { - dhMiscDebug("cssmKeyToDh: wrong BinaryKey subclass\n"); CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); } assert(dhBinKey->mDhKey != NULL); dhKey = dhBinKey->mDhKey; + cspDhDebug("cssmKeyToDh, ref, dhKey %p", dhKey); break; } default: @@ -103,21 +109,49 @@ DH *cssmKeyToDh( } /* - * Convert a raw CssmKey (Private only!) to a newly alloc'd DH key. + * Convert a raw CssmKey to a newly alloc'd DH key. */ DH *rawCssmKeyToDh( const CssmKey &cssmKey) { const CSSM_KEYHEADER *hdr = &cssmKey.KeyHeader; + bool isPub = false; if(hdr->AlgorithmId != CSSM_ALGID_DH) { // someone else's key (should never happen) CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); } assert(hdr->BlobType == CSSM_KEYBLOB_RAW); - assert(hdr->KeyClass == CSSM_KEYCLASS_PRIVATE_KEY); - if(hdr->Format != DH_PRIV_KEY_FORMAT) { - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT); + /* validate and figure out what we're dealing with */ + switch(hdr->KeyClass) { + case CSSM_KEYCLASS_PUBLIC_KEY: + switch(hdr->Format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS3: + case CSSM_KEYBLOB_RAW_FORMAT_X509: + break; + /* openssh real soon now */ + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSH: + default: + CssmError::throwMe( + CSSMERR_CSP_INVALID_ATTR_PUBLIC_KEY_FORMAT); + } + isPub = true; + break; + case CSSM_KEYCLASS_PRIVATE_KEY: + switch(hdr->Format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS3: // default + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: // SMIME style + break; + /* openssh real soon now */ + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSH: + default: + CssmError::throwMe( + CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT); + } + isPub = false; + break; + default: + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } DH *dhKey = DH_new(); @@ -125,12 +159,18 @@ DH *rawCssmKeyToDh( CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); } CSSM_RETURN crtn; - crtn = DHPrivateKeyDecode(dhKey, - cssmKey.KeyData.Data, - cssmKey.KeyData.Length); + if(isPub) { + crtn = DHPublicKeyDecode(dhKey, hdr->Format, + cssmKey.KeyData.Data, cssmKey.KeyData.Length); + } + else { + crtn = DHPrivateKeyDecode(dhKey, hdr->Format, + cssmKey.KeyData.Data, cssmKey.KeyData.Length); + } if(crtn) { CssmError::throwMe(crtn); } + cspDhDebug("rawCssmKeyToDh, dhKey %p", dhKey); return dhKey; } diff --git a/AppleCSP/DiffieHellman/DH_utils.h b/AppleCSP/DiffieHellman/DH_utils.h index 7a079935..e4483b33 100644 --- a/AppleCSP/DiffieHellman/DH_utils.h +++ b/AppleCSP/DiffieHellman/DH_utils.h @@ -44,7 +44,11 @@ void throwDh( DH *contextToDhKey( const Context &context, AppleCSPSession &session, - CSSM_KEYUSE usage, // CSSM_KEYUSE_ENCRYPT, CSSM_KEYUSE_SIGN, etc. + CSSM_ATTRIBUTE_TYPE attr, // CSSM_ATTRIBUTE_KEY for normal private key + // CSSM_ATTRIBUTE_PUBLIC_KEY for public key + CSSM_KEYCLASS keyClass, // CSSM_KEYCLASS_{PUBLIC,PRIVATE}_KEY + CSSM_KEYUSE usage, // CSSM_KEYUSE_ENCRYPT, + // CSSM_KEYUSE_SIGN, etc. bool &mallocdKey); // RETURNED /* diff --git a/AppleCSP/MiscCSPAlgs/MD5.c b/AppleCSP/MiscCSPAlgs/MD5.c index dacd82ea..3dfc474f 100644 --- a/AppleCSP/MiscCSPAlgs/MD5.c +++ b/AppleCSP/MiscCSPAlgs/MD5.c @@ -91,7 +91,7 @@ static inline void dumpCtx(struct MD5Context *ctx, char *label) static void MD5Transform(uint32 buf[4], uint32 const in[16]); -#if __LITTLE_ENDIAN__ +#ifdef __LITTLE_ENDIAN__ #define byteReverse(buf, len) /* Nothing */ #else static void byteReverse(unsigned char *buf, unsigned longs); @@ -224,40 +224,37 @@ void MD5Final(struct MD5Context *ctx, unsigned char *digest) /* Pad out to 56 mod 64 */ dumpCtx(ctx, "final, before pad"); if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - bzero(p, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - - /* Now fill the next block with 56 bytes */ - bzero(ctx->in, 56); + /* Two lots of padding: Pad the first block to 64 bytes */ + bzero(p, count); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); + + /* Now fill the next block with 56 bytes */ + bzero(ctx->in, 56); } else { /* Pad block to 56 bytes */ - bzero(p, count - 8); + bzero(p, count - 8); } byteReverse(ctx->in, 14); /* Append length in bits and transform */ - #if old_way - /* - * On a little endian machine, this writes the l.s. byte of - * the bit count to ctx->in[56] and the m.s byte of the bit count to - * ctx->in[63]. - */ + #ifdef __LITTLE_ENDIAN__ + /* l.s. byte of bits[0] --> in[56] */ ((uint32 *) ctx->in)[14] = ctx->bits[0]; ((uint32 *) ctx->in)[15] = ctx->bits[1]; - #else // new_way + #else + /* l.s. byte of bits[0] --> in[60] */ intToByteRep(ctx->bits[0], &ctx->in[56]); intToByteRep(ctx->bits[1], &ctx->in[60]); - #endif // new_way - + #endif + dumpCtx(ctx, "last transform"); MD5Transform(ctx->buf, (uint32 *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, MD5_DIGEST_SIZE); dumpCtx(ctx, "final end"); - bzero(ctx, sizeof(ctx)); /* In case it's sensitive */ + bzero(ctx, sizeof(*ctx)); /* In case it's sensitive */ } #ifndef ASM_MD5 diff --git a/AppleCSP/MiscCSPAlgs/MD5.h b/AppleCSP/MiscCSPAlgs/MD5.h index 38fcd841..ca8ec368 100644 --- a/AppleCSP/MiscCSPAlgs/MD5.h +++ b/AppleCSP/MiscCSPAlgs/MD5.h @@ -49,6 +49,7 @@ struct MD5Context { }; #define MD5_DIGEST_SIZE 16 /* in bytes */ +#define MD5_BLOCK_SIZE 64 /* in bytes */ void MD5Init(struct MD5Context *context); void MD5Update(struct MD5Context *context, unsigned char const *buf, diff --git a/AppleCSP/MiscCSPAlgs/SHA1.h b/AppleCSP/MiscCSPAlgs/SHA1.h index 1d31a6ac..f1dd3942 100644 --- a/AppleCSP/MiscCSPAlgs/SHA1.h +++ b/AppleCSP/MiscCSPAlgs/SHA1.h @@ -23,6 +23,9 @@ extern "C" { #endif +#define SHA1_DIGEST_SIZE 20 /* in bytes */ +#define SHA1_BLOCK_SIZE 64 /* in bytes */ + /* * Opaque sha1 object handle. */ diff --git a/AppleCSP/MiscCSPAlgs/SHA1_priv.c b/AppleCSP/MiscCSPAlgs/SHA1_priv.c index 7ca0e398..66f42f10 100644 --- a/AppleCSP/MiscCSPAlgs/SHA1_priv.c +++ b/AppleCSP/MiscCSPAlgs/SHA1_priv.c @@ -210,9 +210,7 @@ static void shsTransform( SHS_INFO *shsInfo ) shsInfo->digest[ 4 ] += E; } -/* __LITTLE_ENDIAN__ is in fact #defined on OS X on PPC.... */ -//#ifdef __LITTLE_ENDIAN__ -#if 0 +#ifdef __LITTLE_ENDIAN__ /* When run on a little-endian CPU we need to perform byte reversal on an array of longwords. It is possible to make the code endianness- @@ -311,5 +309,5 @@ void shsFinal(SHS_INFO *shsInfo) shsInfo->data[ 15 ] = lowBitcount; shsTransform( shsInfo ); - byteReverse( shsInfo->data, SHS_DIGESTSIZE ); + byteReverse( shsInfo->digest, SHS_DIGESTSIZE ); } diff --git a/AppleCSP/MiscCSPAlgs/bfContext.cpp b/AppleCSP/MiscCSPAlgs/bfContext.cpp new file mode 100644 index 00000000..4ed73ac7 --- /dev/null +++ b/AppleCSP/MiscCSPAlgs/bfContext.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * bfContext.cpp - glue between BlockCrytpor and ssleay Blowfish + * implementation + * Written by Doug Mitchell 4/23/2003 + */ + +#include "bfContext.h" + +BlowfishContext::~BlowfishContext() +{ + deleteKey(); +} + +void BlowfishContext::deleteKey() +{ + memset(&mBfKey, 0, sizeof(mBfKey)); + mInitFlag = false; +} + +/* + * Standard CSPContext init, called from CSPFullPluginSession::init(). + * Reusable, e.g., query followed by en/decrypt. + */ +void BlowfishContext::init( + const Context &context, + bool encrypting) +{ + if(mInitFlag && !opStarted()) { + return; + } + + UInt32 keyLen; + UInt8 *keyData = NULL; + bool sameKeySize = false; + + /* obtain key from context */ + symmetricKeyBits(context, CSSM_ALGID_BLOWFISH, + encrypting ? CSSM_KEYUSE_ENCRYPT : CSSM_KEYUSE_DECRYPT, + keyData, keyLen); + if((keyLen < BF_MIN_KEY_SIZE_BYTES) || (keyLen > BF_MAX_KEY_SIZE_BYTES)) { + CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_KEY); + } + + /* + * Delete existing key if key size changed + */ + if(mRawKeySize == keyLen) { + sameKeySize = true; + } + else { + deleteKey(); + } + + /* init key only if key size or key bits have changed */ + if(!sameKeySize || memcmp(mRawKey, keyData, mRawKeySize)) { + BF_set_key(&mBfKey, keyLen, keyData); + + /* save this raw key data */ + memmove(mRawKey, keyData, keyLen); + mRawKeySize = keyLen; + } + + /* Finally, have BlockCryptor do its setup */ + setup(BF_BLOCK, context); + mInitFlag = true; +} + +/* + * Functions called by BlockCryptor + */ +void BlowfishContext::encryptBlock( + const void *plainText, // length implied (one block) + size_t plainTextLen, + void *cipherText, + size_t &cipherTextLen, // in/out, throws on overflow + bool final) // ignored +{ + if(plainTextLen != BF_BLOCK) { + CssmError::throwMe(CSSMERR_CSP_INPUT_LENGTH_ERROR); + } + if(cipherTextLen < BF_BLOCK) { + CssmError::throwMe(CSSMERR_CSP_OUTPUT_LENGTH_ERROR); + } + BF_ecb_encrypt((const unsigned char *)plainText, (unsigned char *)cipherText, + &mBfKey, BF_ENCRYPT); + cipherTextLen = BF_BLOCK; +} + +void BlowfishContext::decryptBlock( + const void *cipherText, // length implied (one block) + void *plainText, + size_t &plainTextLen, // in/out, throws on overflow + bool final) // ignored +{ + if(plainTextLen < BF_BLOCK) { + CssmError::throwMe(CSSMERR_CSP_OUTPUT_LENGTH_ERROR); + } + BF_ecb_encrypt((const unsigned char *)cipherText, (unsigned char *)plainText, + &mBfKey, BF_DECRYPT); + plainTextLen = BF_BLOCK; +} diff --git a/AppleCSP/MiscCSPAlgs/bfContext.h b/AppleCSP/MiscCSPAlgs/bfContext.h new file mode 100644 index 00000000..4de5ab2d --- /dev/null +++ b/AppleCSP/MiscCSPAlgs/bfContext.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * bfContext.h - glue between BlockCrytpor and ssleay Blowfish + * implementation + * Written by Doug Mitchell 4/23/2003 + */ + +#ifndef _BF_CONTEXT_H_ +#define _BF_CONTEXT_H_ + +#include "AppleCSPContext.h" +#include "BlockCryptor.h" +#include +#include + +class BlowfishContext : public BlockCryptor { +public: + BlowfishContext(AppleCSPSession &session) : + BlockCryptor(session), + mInitFlag(false), + mRawKeySize(0) { } + ~BlowfishContext(); + + // called by CSPFullPluginSession + void init(const Context &context, bool encoding = true); + + // As an optimization, we allow reuse of a modified context. + // The main thing we avoid is a redundant key scheduling. We + // save the current raw keys bits in mRawKey and compare on + // re-init. + bool changed(const Context &context) { return true; } + + // called by BlockCryptor + void encryptBlock( + const void *plainText, // length implied (one block) + size_t plainTextLen, + void *cipherText, + size_t &cipherTextLen, // in/out, throws on overflow + bool final); + void decryptBlock( + const void *cipherText, // length implied (one cipher block) + void *plainText, + size_t &plainTextLen, // in/out, throws on overflow + bool final); + +private: + void deleteKey(); + + /* scheduled key */ + BF_KEY mBfKey; + bool mInitFlag; // for easy reuse + + /* + * Raw key bits saved here and checked on re-init to avoid + * extra key schedule + */ + uint8 mRawKey[BF_MAX_KEY_SIZE_BYTES]; + uint32 mRawKeySize; + + +}; /* BlowfishContext */ + +#endif //_BF_CONTEXT_H_ diff --git a/AppleCSP/MiscCSPAlgs/castContext.cpp b/AppleCSP/MiscCSPAlgs/castContext.cpp new file mode 100644 index 00000000..d74c792c --- /dev/null +++ b/AppleCSP/MiscCSPAlgs/castContext.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * castContext.cpp - glue between BlockCrytpor and ssleay CAST128 (CAST5) + * implementation + * + * Written by Doug Mitchell 4/24/2003 + */ + +#include "castContext.h" + +CastContext::~CastContext() +{ + deleteKey(); +} + +void CastContext::deleteKey() +{ + memset(&mCastKey, 0, sizeof(mCastKey)); + mInitFlag = false; +} + +/* + * Standard CSPContext init, called from CSPFullPluginSession::init(). + * Reusable, e.g., query followed by en/decrypt. + */ +void CastContext::init( + const Context &context, + bool encrypting) +{ + if(mInitFlag && !opStarted()) { + return; + } + + UInt32 keyLen; + UInt8 *keyData = NULL; + bool sameKeySize = false; + + /* obtain key from context */ + symmetricKeyBits(context, CSSM_ALGID_CAST, + encrypting ? CSSM_KEYUSE_ENCRYPT : CSSM_KEYUSE_DECRYPT, + keyData, keyLen); + if((keyLen < CAST_MIN_KEY_LENGTH) || (keyLen > CAST_KEY_LENGTH)) { + CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_KEY); + } + + /* + * Delete existing key if key size changed + */ + if(mRawKeySize == keyLen) { + sameKeySize = true; + } + else { + deleteKey(); + } + + /* init key only if key size or key bits have changed */ + if(!sameKeySize || memcmp(mRawKey, keyData, mRawKeySize)) { + CAST_set_key(&mCastKey, keyLen, keyData); + + /* save this raw key data */ + memmove(mRawKey, keyData, keyLen); + mRawKeySize = keyLen; + } + + /* Finally, have BlockCryptor do its setup */ + setup(CAST_BLOCK, context); + mInitFlag = true; +} + +/* + * Functions called by BlockCryptor + */ +void CastContext::encryptBlock( + const void *plainText, // length implied (one block) + size_t plainTextLen, + void *cipherText, + size_t &cipherTextLen, // in/out, throws on overflow + bool final) // ignored +{ + if(plainTextLen != CAST_BLOCK) { + CssmError::throwMe(CSSMERR_CSP_INPUT_LENGTH_ERROR); + } + if(cipherTextLen < CAST_BLOCK) { + CssmError::throwMe(CSSMERR_CSP_OUTPUT_LENGTH_ERROR); + } + CAST_ecb_encrypt((const unsigned char *)plainText, (unsigned char *)cipherText, + &mCastKey, CAST_ENCRYPT); + cipherTextLen = CAST_BLOCK; +} + +void CastContext::decryptBlock( + const void *cipherText, // length implied (one block) + void *plainText, + size_t &plainTextLen, // in/out, throws on overflow + bool final) // ignored +{ + if(plainTextLen < CAST_BLOCK) { + CssmError::throwMe(CSSMERR_CSP_OUTPUT_LENGTH_ERROR); + } + CAST_ecb_encrypt((const unsigned char *)cipherText, (unsigned char *)plainText, + &mCastKey, CAST_DECRYPT); + plainTextLen = CAST_BLOCK; +} diff --git a/AppleCSP/MiscCSPAlgs/castContext.h b/AppleCSP/MiscCSPAlgs/castContext.h new file mode 100644 index 00000000..87f2cb3a --- /dev/null +++ b/AppleCSP/MiscCSPAlgs/castContext.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * castContext.h - glue between BlockCrytpor and ssleay CAST-128 (CAST5) + * implementation + * + * Written by Doug Mitchell 4/24/2003 + * + * Here's what RFC 2144 has to say about CAST128 and CAST5 nomenclature: + * + * In order to avoid confusion when variable keysize operation is + * used, the name CAST-128 is to be considered synonymous with the + * name CAST5; this allows a keysize to be appended without ambiguity. + * Thus, for example, CAST-128 with a 40-bit key is to be referred to + * as CAST5-40; where a 128-bit key is explicitly intended, the + * name CAST5-128 should be used. + * + * This module implements a variable key length, from 40 bits to 128 bits, + * and can thus be said to implement both CAST-128 and CAST5. + */ + +#ifndef _CAST_CONTEXT_H_ +#define _CAST_CONTEXT_H_ + +#include "AppleCSPContext.h" +#include "BlockCryptor.h" +#include +#include + +class CastContext : public BlockCryptor { +public: + CastContext(AppleCSPSession &session) : + BlockCryptor(session), + mInitFlag(false), + mRawKeySize(0) { } + ~CastContext(); + + // called by CSPFullPluginSession + void init(const Context &context, bool encoding = true); + + // As an optimization, we allow reuse of a modified context. + // The main thing we avoid is a redundant key scheduling. We + // save the current raw keys bits in mRawKey and compare on + // re-init. + bool changed(const Context &context) { return true; } + + // called by BlockCryptor + void encryptBlock( + const void *plainText, // length implied (one block) + size_t plainTextLen, + void *cipherText, + size_t &cipherTextLen, // in/out, throws on overflow + bool final); + void decryptBlock( + const void *cipherText, // length implied (one cipher block) + void *plainText, + size_t &plainTextLen, // in/out, throws on overflow + bool final); + +private: + void deleteKey(); + + /* scheduled key */ + CAST_KEY mCastKey; + bool mInitFlag; // for easy reuse + + /* + * Raw key bits saved here and checked on re-init to avoid + * extra key schedule + */ + uint8 mRawKey[CAST_KEY_LENGTH]; + uint32 mRawKeySize; + + +}; /* CastContext */ + +#endif //_CAST_CONTEXT_H_ diff --git a/AppleCSP/MiscCSPAlgs/desContext.cpp b/AppleCSP/MiscCSPAlgs/desContext.cpp index dfa759c8..d17133a6 100644 --- a/AppleCSP/MiscCSPAlgs/desContext.cpp +++ b/AppleCSP/MiscCSPAlgs/desContext.cpp @@ -28,7 +28,7 @@ ModuleNexus desInitMutex; -#define DESDebug(args...) debug("desContext", ## args) +#define DESDebug(args...) secdebug("desContext", ## args) /* * DES encrypt/decrypt. @@ -61,7 +61,7 @@ void DESContext::init( /* init the low-level state */ { StLock _(desInitMutex()); - if(int irtn = desinit(&DesInst, DES_MODE_STD)) { + if(IFDEBUG(int irtn =) desinit(&DesInst, DES_MODE_STD)) { DESDebug("desinit returned %d\n", irtn); CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); } diff --git a/AppleCSP/MiscCSPAlgs/miscAlgFactory.cpp b/AppleCSP/MiscCSPAlgs/miscAlgFactory.cpp index a02d49b8..2adaf144 100644 --- a/AppleCSP/MiscCSPAlgs/miscAlgFactory.cpp +++ b/AppleCSP/MiscCSPAlgs/miscAlgFactory.cpp @@ -33,6 +33,8 @@ #include "SHA1_MD5_Object.h" /* raw digest */ #include "MD2Object.h" #include "NullCryptor.h" +#include "bfContext.h" +#include "castContext.h" #include /* @@ -140,6 +142,19 @@ bool MiscAlgFactory::setup( return true; #endif + case CSSM_ALGID_BLOWFISH: + if(cspCtx == NULL) { + cspCtx = new BlowfishContext(session); + } + return true; + + case CSSM_ALGID_CAST: + case CSSM_ALGID_CAST5: + if(cspCtx == NULL) { + cspCtx = new CastContext(session); + } + return true; + #if NULL_CRYPT_ENABLE case CSSM_ALGID_NONE: if(cspCtx == NULL) { @@ -245,6 +260,25 @@ bool MiscAlgFactory::setup( return true; #endif + case CSSM_ALGID_BLOWFISH: + if(cspCtx == NULL) { + cspCtx = new AppleSymmKeyGenerator(session, + BF_MIN_KEY_SIZE_BYTES * 8, + BF_MAX_KEY_SIZE_BYTES * 8, + true); // must be byte size + } + return true; + + /* Note we require keys to be ALGID_CAST, not ALGID_CAST5 */ + case CSSM_ALGID_CAST: + if(cspCtx == NULL) { + cspCtx = new AppleSymmKeyGenerator(session, + CAST_MIN_KEY_LENGTH * 8, + CAST_KEY_LENGTH * 8, + true); // must be byte size + } + return true; + #if MAF_MAC_ENABLE case CSSM_ALGID_SHA1HMAC: if(cspCtx == NULL) { diff --git a/AppleCSP/MiscCSPAlgs/pkcs12Derive.cpp b/AppleCSP/MiscCSPAlgs/pkcs12Derive.cpp new file mode 100644 index 00000000..17ca47c0 --- /dev/null +++ b/AppleCSP/MiscCSPAlgs/pkcs12Derive.cpp @@ -0,0 +1,430 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ +/* + * pkcs12Derive.cpp - PKCS12 PBE routine + * + * Created 2/28/03 by Doug Mitchell. + */ + +#include +#include +#include + +#include "pkcs12Derive.h" +#include +#include +#include +#include +#include + +/* specify which flavor of bits to generate */ +typedef enum { + PBE_ID_Key = 1, + PBE_ID_IV = 2, + PBE_ID_MAC = 3 +} P12_PBE_ID; + +/* + * implementation dependent hash object + */ + #if 0 +typedef CSSM_CC_HANDLE HashHand; +static HashHand hashCreate(CSSM_CSP_HANDLE cspHand, + CSSM_ALGORITHMS alg) +{ + CSSM_CC_HANDLE hashHand; + CSSM_RETURN crtn = CSSM_CSP_CreateDigestContext(cspHand, + alg, + &hashHand); + if(crtn) { + printf("CSSM_CSP_CreateDigestContext error\n"); + return 0; + } + return hashHand; +} + +static CSSM_RETURN hashInit(HashHand hand) +{ + return CSSM_DigestDataInit(hand); +} + +static CSSM_RETURN hashUpdate(HashHand hand, + const unsigned char *buf, + unsigned bufLen) +{ + const CSSM_DATA cdata = {bufLen, (uint8 *)buf}; + return CSSM_DigestDataUpdate(hand, &cdata, 1); +} + +static CSSM_RETURN hashFinal(HashHand hand, + unsigned char *digest, // mallocd by caller + unsigned *digestLen) // IN/OUT +{ + CSSM_DATA cdata = {(uint32)digestLen, digest}; + return CSSM_DigestDataFinal(hand, &cdata); +} + +static CSSM_RETURN hashDone(HashHand hand) +{ + return CSSM_DeleteContext(hand); +} + #endif + +/* + * Create a "string" (in the loose p12 notation) of specified length + * from the concatention of copies of the specified input string. + */ +static unsigned char *p12StrCat( + const unsigned char *inStr, + unsigned inStrLen, + SecNssCoder &coder, + unsigned outLen, + unsigned char *outStr = NULL) // if not present, we malloc +{ + if(outStr == NULL) { + outStr = (unsigned char *)coder.malloc(outLen); + } + unsigned toMove = outLen; + unsigned char *outp = outStr; + while(toMove) { + unsigned thisMove = inStrLen; + if(thisMove > toMove) { + thisMove = toMove; + } + memmove(outp, inStr, thisMove); + toMove -= thisMove; + outp += thisMove; + } + return outStr; +} + +/* + * PBE generator per PKCS12 v.1 section B.2. + */ +static CSSM_RETURN p12PbeGen( + const CSSM_DATA &pwd, // unicode, double null terminated + const uint8 *salt, + unsigned saltLen, + unsigned iterCount, + P12_PBE_ID pbeId, + CSSM_ALGORITHMS hashAlg, // MS5 or SHA1 only + SecNssCoder &coder, // for temp allocs + /* result goes here, mallocd by caller */ + uint8 *outbuf, + unsigned outbufLen) +{ + CSSM_RETURN ourRtn = CSSM_OK; + unsigned unipassLen = pwd.Length; + unsigned char *unipass = pwd.Data; + + /* + * all variables of the form p12_ represent from the + * PKCS12 spec. E.g., p12_u is u, the length of the digest output. + * Only difference here is: all of our sizes are in BYTES, not + * bits. + */ + unsigned p12_r = iterCount; + unsigned p12_n = outbufLen; + + unsigned p12_u; // hash output size + unsigned p12_v; // hash block size + unsigned char *p12_P = NULL; // catted passwords + unsigned char *p12_S = NULL; // catted salts + CSSM_BOOL isSha1 = CSSM_TRUE; // for DigestCtx + + switch(hashAlg) { + case CSSM_ALGID_MD5: + p12_u = kMD5DigestSize; + p12_v = kMD5BlockSize; + isSha1 = CSSM_FALSE; + break; + case CSSM_ALGID_SHA1: + p12_u = kSHA1DigestSize; + p12_v = kSHA1BlockSize; + break; + default: + return CSSMERR_CSP_INVALID_ALGORITHM; + } + + /* + * 1. Construct a string, D (the diversifier), by + * concatenating v/8 copies of ID. + */ + unsigned char *p12_D = NULL; // diversifier + p12_D = (unsigned char *)coder.malloc(p12_v); + for(unsigned dex=0; dex p12_v) { + BN_bn2bin (Ij, p12_B); + memcpy (p12_I + j, p12_B + 1, p12_v); + /* If less than v bytes pad with zeroes */ + } else if (Ijlen < p12_v) { + memset(p12_I + j, 0, p12_v - Ijlen); + BN_bn2bin(Ij, p12_I + j + p12_v - Ijlen); + } else BN_bn2bin (Ij, p12_I + j); + } + } + + if(ourRtn == CSSM_OK) { + /* + * 7. Concatenate A[1], A[2], ..., A[c] together to form a + * pseudo-random bit string, A. + * + * 8. Use the first n bits of A as the output of this entire + * process. + */ + memmove(outbuf, p12_A, outbufLen); + } + + /* clear all these strings */ + if(p12_D) { + memset(p12_D, 0, p12_v); + } + if(p12_S) { + memset(p12_S, 0, p12_Slen); + } + if(p12_P) { + memset(p12_P, 0, p12_Plen); + } + if(p12_I) { + memset(p12_I, 0, p12_Slen + p12_Plen); + } + if(p12_A) { + memset(p12_A, 0, p12_c * p12_u); + } + if(p12_B) { + memset(p12_B, 0, p12_v); + } + if(hashHand) { + DigestCtxFree(hashHand); + } + BN_free(Bpl1); + BN_free(Ij); + return ourRtn; +} + +/* + * Public P12 derive key function, called out from + * AppleCSPSession::DeriveKey() + * + * On input: + * --------- + * Context parameters: + * Salt + * Iteration Count + * CSSM_CRYPTO_DATA.Param - Unicode passphrase, double-NULL terminated + * Algorithm - CSSM_ALGID_PKCS12_PBE_{ENCR,MAC} + * Passed explicitly from DeriveKey(): + * CSSM_DATA Param - IN/OUT - optional IV - caller mallocs space to + * tell us to generate an IV. The param itself is not + * optional; the presence or absence of allocated data in it + * is our IV indicator (present/absent as well as size) + * KeyData - mallocd by caller, we fill in keyData->Length bytes + */ +void DeriveKey_PKCS12 ( + const Context &context, + const CssmData &Param, // other's public key + CSSM_DATA *keyData) // mallocd by caller + // we fill in keyData->Length bytes +{ + /* + * According to the spec, both passphrase and salt are optional. + * Get them from context if they're present. + */ + CSSM_DATA pwd = {0, NULL}; + CssmCryptoData *cryptData = + context.get(CSSM_ATTRIBUTE_SEED); + if(cryptData) { + pwd.Length = cryptData->Param.Length; + pwd.Data = cryptData->Param.Data; + } + + /* salt from context */ + uint32 saltLen = 0; + uint8 *salt = NULL; + CssmData *csalt = context.get(CSSM_ATTRIBUTE_SALT); + if(csalt) { + salt = csalt->Data; + saltLen = csalt->Length; + } + + /* + * Iteration count, from context, required. + * The spec's ASN1 definition says this is optional with a default + * of one but that's a BER encode/decode issue. Here we require + * a nonzero value. + */ + uint32 iterCount = context.getInt(CSSM_ATTRIBUTE_ITERATION_COUNT, + CSSMERR_CSP_MISSING_ATTR_ITERATION_COUNT); + if(iterCount == 0) { + CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_ITERATION_COUNT); + } + + /* + * Algorithm determines which of {PBE_ID_Key,PBE_ID_MAC} we now + * generate. We'll also do an optional PBE_ID_IV later. + */ + P12_PBE_ID pbeId = PBE_ID_Key; + switch(context.algorithm()) { + case CSSM_ALGID_PKCS12_PBE_ENCR: + pbeId = PBE_ID_Key; + break; + case CSSM_ALGID_PKCS12_PBE_MAC: + pbeId = PBE_ID_MAC; + break; + default: + /* really should not be here */ + assert(0); + CssmError::throwMe(CSSMERR_CSP_INTERNAL_ERROR); + } + + /* Go */ + SecNssCoder tmpCoder; + CSSM_RETURN crtn = p12PbeGen(pwd, + salt, saltLen, + iterCount, + pbeId, + CSSM_ALGID_SHA1, // all we support for now + tmpCoder, + keyData->Data, + keyData->Length); + if(crtn) { + CssmError::throwMe(crtn); + } + + /* + * Optional IV - makes no sense if we just did PBE_ID_MAC, but why + * bother restricting? + */ + if(Param.Data) { + crtn = p12PbeGen(pwd, + salt, saltLen, + iterCount, + PBE_ID_IV, + CSSM_ALGID_SHA1, // all we support for now + tmpCoder, + Param.Data, + Param.Length); + if(crtn) { + CssmError::throwMe(crtn); + } + } +} + diff --git a/AppleCSP/MiscCSPAlgs/pkcs12Derive.h b/AppleCSP/MiscCSPAlgs/pkcs12Derive.h new file mode 100644 index 00000000..f63fc370 --- /dev/null +++ b/AppleCSP/MiscCSPAlgs/pkcs12Derive.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + * pkcs12Derive.cpp - PKCS12 PBE routine + * + * Created 2/28/03 by Doug Mitchell. + */ + +#ifndef _PKCS12_DERIVE_H_ +#define _PKCS12_DERIVE_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void DeriveKey_PKCS12 ( + const Context &context, + const CssmData &Param, // other's public key + CSSM_DATA *keyData); // mallocd by caller + // we fill in keyData->Length bytes + +#ifdef __cplusplus +} +#endif + +#endif /* _PKCS12_DERIVE_H_ */ + diff --git a/AppleCSP/MiscCSPAlgs/rc4Context.cpp b/AppleCSP/MiscCSPAlgs/rc4Context.cpp index 1cde9c37..3d60ea12 100644 --- a/AppleCSP/MiscCSPAlgs/rc4Context.cpp +++ b/AppleCSP/MiscCSPAlgs/rc4Context.cpp @@ -80,8 +80,8 @@ size_t RC4Context::inputSize( } size_t RC4Context::outputSize( - bool final = false, - size_t inSize = 0) // output for given input size + bool final /*= false*/, + size_t inSize /*= 0*/) // output for given input size { return inSize; } diff --git a/AppleCSP/PBKDF2/HMACSHA1.c b/AppleCSP/PBKDF2/HMACSHA1.c index 4a2fbbe9..a6f772eb 100644 --- a/AppleCSP/PBKDF2/HMACSHA1.c +++ b/AppleCSP/PBKDF2/HMACSHA1.c @@ -23,80 +23,14 @@ Written by: Michael Brouwer */ #include "HMACSHA1.h" +#include "pbkdDigest.h" #include #include #include #include // for malloc - maybe we should use CssmAllocator? #include -#pragma mark --- Common digest class --- -typedef struct { - union { - sha1Obj sha1Context; // must be allocd via sha1Alloc - struct MD5Context md5Context; - } dig; - CSSM_BOOL isSha1; -} DigestCtx; - -/* Ops on a DigestCtx */ -static CSSM_RETURN DigestCtxInit( - DigestCtx *ctx, - CSSM_BOOL isSha1) -{ - if(isSha1) { - if(ctx->dig.sha1Context == NULL) { - ctx->dig.sha1Context = sha1Alloc(); - if(ctx->dig.sha1Context == NULL) { - return CSSMERR_CSP_MEMORY_ERROR; - } - } - else { - sha1Reinit(ctx->dig.sha1Context); - } - } - else { - MD5Init(&ctx->dig.md5Context); - } - ctx->isSha1 = isSha1; - return CSSM_OK; -} - -static void DigestCtxFree( - DigestCtx *ctx) -{ - if(ctx->isSha1) { - sha1Free(ctx->dig.sha1Context); - } - memset(ctx, 0, sizeof(DigestCtx)); -} - -static void DigestCtxUpdate( - DigestCtx *ctx, - const void *textPtr, - UInt32 textLen) -{ - if(ctx->isSha1) { - sha1AddData(ctx->dig.sha1Context, (unsigned char *)textPtr, textLen); - } - else { - MD5Update(&ctx->dig.md5Context, (unsigned char *)textPtr, textLen); - } -} - -static void DigestCtxFinal( - DigestCtx *ctx, - void *digest) -{ - if(ctx->isSha1) { - sha1GetDigest(ctx->dig.sha1Context, (unsigned char *)digest); - } - else { - MD5Final(&ctx->dig.md5Context, (unsigned char *)digest); - } -} - -#pragma mark --- HMAC class --- struct hmacContext { DigestCtx digest; diff --git a/AppleCSP/PBKDF2/HMACSHA1.h b/AppleCSP/PBKDF2/HMACSHA1.h index af143b92..bf2da808 100644 --- a/AppleCSP/PBKDF2/HMACSHA1.h +++ b/AppleCSP/PBKDF2/HMACSHA1.h @@ -27,17 +27,15 @@ #include #include +#include +#include #ifdef __cplusplus extern "C" { #endif -#define kHMACSHA1DigestSize 20 -#define kHMACMD5DigestSize 16 - -/* XXX These should really be in SHA1.h */ -#define kSHA1DigestSize 20 -#define kSHA1BlockSize 64 +#define kHMACSHA1DigestSize SHA1_DIGEST_SIZE +#define kHMACMD5DigestSize MD5_DIGEST_SIZE /* This function create an HMACSHA1 digest of kHMACSHA1DigestSizestSize bytes * and outputs it to resultPtr. See RFC 2104 for details. */ diff --git a/AppleCSP/PBKDF2/pbkdDigest.cpp b/AppleCSP/PBKDF2/pbkdDigest.cpp new file mode 100644 index 00000000..79235506 --- /dev/null +++ b/AppleCSP/PBKDF2/pbkdDigest.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ +/* + * pbkdDigest.cpp - SHA1/MD5 digest object for HMAC and PBE routines + */ + +#include "pbkdDigest.h" +#include +#include + +/* Ops on a DigestCtx */ +/* Note caller has to memset(0) the DigestCtx before using */ +CSSM_RETURN DigestCtxInit( + DigestCtx *ctx, + CSSM_BOOL isSha1) +{ + if(isSha1) { + if(ctx->dig.sha1Context == NULL) { + ctx->dig.sha1Context = sha1Alloc(); + if(ctx->dig.sha1Context == NULL) { + return CSSMERR_CSP_MEMORY_ERROR; + } + } + else { + sha1Reinit(ctx->dig.sha1Context); + } + } + else { + MD5Init(&ctx->dig.md5Context); + } + ctx->isSha1 = isSha1; + return CSSM_OK; +} + +void DigestCtxFree( + DigestCtx *ctx) +{ + if(ctx->isSha1) { + sha1Free(ctx->dig.sha1Context); + } + memset(ctx, 0, sizeof(DigestCtx)); +} + +void DigestCtxUpdate( + DigestCtx *ctx, + const void *textPtr, + UInt32 textLen) +{ + if(ctx->isSha1) { + sha1AddData(ctx->dig.sha1Context, (unsigned char *)textPtr, textLen); + } + else { + MD5Update(&ctx->dig.md5Context, (unsigned char *)textPtr, textLen); + } +} + +void DigestCtxFinal( + DigestCtx *ctx, + void *digest) +{ + if(ctx->isSha1) { + sha1GetDigest(ctx->dig.sha1Context, (unsigned char *)digest); + } + else { + MD5Final(&ctx->dig.md5Context, (unsigned char *)digest); + } +} diff --git a/AppleCSP/PBKDF2/pbkdDigest.h b/AppleCSP/PBKDF2/pbkdDigest.h new file mode 100644 index 00000000..f91cf820 --- /dev/null +++ b/AppleCSP/PBKDF2/pbkdDigest.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ +/* + * pbkdDigest.h - SHA1/MD5 digest object for HMAC and PBE routines + */ + +#ifndef _PBKD_DIGEST_H_ +#define _PBKD_DIGEST_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define kSHA1DigestSize SHA1_DIGEST_SIZE +#define kSHA1BlockSize SHA1_BLOCK_SIZE + +#define kMD5DigestSize MD5_DIGEST_SIZE +#define kMD5BlockSize MD5_BLOCK_SIZE + + +typedef struct { + union { + sha1Obj sha1Context; // must be allocd via sha1Alloc + struct MD5Context md5Context; + } dig; + CSSM_BOOL isSha1; +} DigestCtx; + +/* Ops on a DigestCtx */ +CSSM_RETURN DigestCtxInit( + DigestCtx *ctx, + CSSM_BOOL isSha1); +void DigestCtxFree( + DigestCtx *ctx); +void DigestCtxUpdate( + DigestCtx *ctx, + const void *textPtr, + UInt32 textLen); +void DigestCtxFinal( + DigestCtx *ctx, + void *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* _PBKD_DIGEST_H_ */ + diff --git a/AppleCSP/PBKDF2/pbkdf2.c b/AppleCSP/PBKDF2/pbkdf2.c index e6550600..43af0ac6 100644 --- a/AppleCSP/PBKDF2/pbkdf2.c +++ b/AppleCSP/PBKDF2/pbkdf2.c @@ -43,17 +43,12 @@ F (PRF prf, UInt32 hLen, inBlock = outBlock + hLen; /* Set up inBlock to contain Salt || INT (blockNumber). */ memcpy (inBlock, saltPtr, saltLen); -#if TARGET_RT_LITTLE_ENDIAN - inBlock[saltLen + 0] = (UInt8)(blockNumber); - inBlock[saltLen + 1] = (UInt8)(blockNumber >> 8); - inBlock[saltLen + 2] = (UInt8)(blockNumber >> 16); - inBlock[saltLen + 3] = (UInt8)(blockNumber >> 24); -#else /* if TARGET_RT_BIG_ENDIAN */ + inBlock[saltLen + 0] = (UInt8)(blockNumber >> 24); inBlock[saltLen + 1] = (UInt8)(blockNumber >> 16); inBlock[saltLen + 2] = (UInt8)(blockNumber >> 8); inBlock[saltLen + 3] = (UInt8)(blockNumber); -#endif + /* Caculate U1 (result goes to outBlock) and copy it to resultBlockPtr. */ resultBlockPtr = (UInt8*)dataPtr; prf (passwordPtr, passwordLen, inBlock, saltLen + 4, outBlock); diff --git a/AppleCSP/RSA_DSA/RSA_DSA_keys.cpp b/AppleCSP/RSA_DSA/RSA_DSA_keys.cpp index 87428ce0..0fdaa0b8 100644 --- a/AppleCSP/RSA_DSA/RSA_DSA_keys.cpp +++ b/AppleCSP/RSA_DSA/RSA_DSA_keys.cpp @@ -22,7 +22,7 @@ #include "RSA_DSA_keys.h" #include -#include +#include #include #include #include @@ -30,12 +30,11 @@ #include #include "RSA_DSA_utils.h" #include -#include -#include +#include #define RSA_PUB_EXPONENT 0x10001 /* recommended by RSA */ -#define rsaKeyDebug(args...) debug("rsaKey", ## args) +#define rsaKeyDebug(args...) secdebug("rsaKey", ## args) /*** *** RSA-style BinaryKey @@ -58,30 +57,64 @@ RSABinaryKey::~RSABinaryKey() void RSABinaryKey::generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format) + CSSM_KEYBLOB_FORMAT &format, /* IN/OUT */ + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags) /* IN/OUT */ { bool isPub; CSSM_RETURN crtn; + /* + * Here, the incoming default of CSSM_KEYBLOB_RAW_FORMAT_NONE + * is translated to our AppleCSP-custom defaults. App can override. + */ switch(mKeyHeader.KeyClass) { case CSSM_KEYCLASS_PUBLIC_KEY: isPub = true; - format = RSA_PUB_KEY_FORMAT; + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: + format = RSA_PUB_KEY_FORMAT; // default + break; + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: + /* calculate digest on PKCS1 blob */ + format = CSSM_KEYBLOB_RAW_FORMAT_PKCS1; + break; + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: + case CSSM_KEYBLOB_RAW_FORMAT_X509: + break; + default: + CssmError::throwMe(CSSMERR_CSP_UNSUPPORTED_KEY_FORMAT); + } break; case CSSM_KEYCLASS_PRIVATE_KEY: isPub = false; - format = RSA_PRIV_KEY_FORMAT; + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: // default + format = RSA_PRIV_KEY_FORMAT; + break; + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: + /* calculate digest on Public PKCS1 blob */ + format = CSSM_KEYBLOB_RAW_FORMAT_PKCS1; + isPub = true; + break; + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + break; + default: + CssmError::throwMe(CSSMERR_CSP_UNSUPPORTED_KEY_FORMAT); + } break; default: CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } - CssmAutoData encodedKey(allocator); + CssmAutoData encodedKey(allocator); if(isPub) { - crtn = RSAPublicKeyEncode(mRsaKey, encodedKey); + crtn = RSAPublicKeyEncode(mRsaKey, format, encodedKey); } else { - crtn = RSAPrivateKeyEncode(mRsaKey, encodedKey); + crtn = RSAPrivateKeyEncode(mRsaKey, format, encodedKey); } if(crtn) { CssmError::throwMe(crtn); @@ -175,13 +208,15 @@ void RSAKeyPairGenContext::generate( *** RSA-style CSPKeyInfoProvider. ***/ RSAKeyInfoProvider::RSAKeyInfoProvider( - const CssmKey &cssmKey) : - CSPKeyInfoProvider(cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) : + CSPKeyInfoProvider(cssmKey, session) { } CSPKeyInfoProvider *RSAKeyInfoProvider::provider( - const CssmKey &cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) { switch(cssmKey.algorithm()) { case CSSM_ALGID_RSA: @@ -197,12 +232,14 @@ CSPKeyInfoProvider *RSAKeyInfoProvider::provider( return NULL; } /* OK, we'll handle this one */ - return new RSAKeyInfoProvider(cssmKey); + return new RSAKeyInfoProvider(cssmKey, session); } /* Given a raw key, cook up a Binary key */ void RSAKeyInfoProvider::CssmKeyToBinary( - BinaryKey **binKey) + CssmKey *paramKey, // ignored + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT, unused here + BinaryKey **binKey) { *binKey = NULL; RSA *rsaKey = NULL; @@ -230,6 +267,44 @@ void RSAKeyInfoProvider::QueryKeySizeInBits( RSA_free(rsaKey); } +/* + * Obtain blob suitable for hashing in CSSM_APPLECSP_KEYDIGEST + * passthrough. + */ +bool RSAKeyInfoProvider::getHashableBlob( + CssmAllocator &allocator, + CssmData &blob) // blob to hash goes here +{ + /* + * The optimized case, a raw key in the "proper" format already. + * Only public keys in PKCS1 format fit this bill. + */ + assert(mKey.blobType() == CSSM_KEYBLOB_RAW); + bool useAsIs = false; + + switch(mKey.keyClass()) { + case CSSM_KEYCLASS_PUBLIC_KEY: + if(mKey.blobFormat() == CSSM_KEYBLOB_RAW_FORMAT_PKCS1) { + useAsIs = true; + } + break; + case CSSM_KEYCLASS_PRIVATE_KEY: + break; + default: + /* shouldn't be here */ + assert(0); + CssmError::throwMe(CSSMERR_CSP_INTERNAL_ERROR); + } + if(useAsIs) { + const CssmData &keyBlob = CssmData::overlay(mKey.KeyData); + copyCssmData(keyBlob, blob, allocator); + return true; + } + + /* caller converts to binary and proceeds */ + return false; +} + /*** *** DSA key support ***/ @@ -256,37 +331,103 @@ DSABinaryKey::~DSABinaryKey() void DSABinaryKey::generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format) + CSSM_KEYBLOB_FORMAT &format, + AppleCSPSession &session, + const CssmKey *paramKey, /* optional */ + CSSM_KEYATTR_FLAGS &attrFlags) /* IN/OUT */ { bool isPub; CSSM_RETURN crtn; + /* + * Here, the incoming default of CSSM_KEYBLOB_RAW_FORMAT_NONE + * is translated to our AppleCSP-custom defaults. App can override. + */ switch(mKeyHeader.KeyClass) { case CSSM_KEYCLASS_PUBLIC_KEY: isPub = true; - format = DSA_PUB_KEY_FORMAT; + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: + format = DSA_PUB_KEY_FORMAT; // default + break; + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: + case CSSM_KEYBLOB_RAW_FORMAT_X509: + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: + break; + default: + CssmError::throwMe(CSSMERR_CSP_UNSUPPORTED_KEY_FORMAT); + } break; case CSSM_KEYCLASS_PRIVATE_KEY: isPub = false; - format = DSA_PRIV_KEY_FORMAT; + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: + format = DSA_PRIV_KEY_FORMAT; // default + break; + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: + /* + * This is calculated on the public key, which + * is not part of a DSA private key's encoding... + * so first calculate the public key. + */ + dsaKeyPrivToPub(mDsaKey); + isPub = true; + break; + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSL: + break; + default: + CssmError::throwMe(CSSMERR_CSP_UNSUPPORTED_KEY_FORMAT); + } break; default: CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } + /* possible conversion from partial binary key to fully + * formed blob */ + DSA *dsaToEncode = mDsaKey; + DSA *dsaUpgrade = NULL; + if(isPub && + (mDsaKey->p == NULL) && + (paramKey != NULL)) { + /* + * Don't modify BinaryKey; make a copy. + */ + dsaUpgrade = DSA_new(); + if(dsaUpgrade == NULL) { + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + dsaUpgrade->pub_key = BN_dup(mDsaKey->pub_key); + crtn = dsaGetParamsFromKey(dsaUpgrade, *paramKey, session); + if(crtn) { + DSA_free(dsaUpgrade); + CssmError::throwMe(crtn); + } + + /* success - switch keys and inform caller of attr change */ + dsaToEncode = dsaUpgrade; + attrFlags &= ~CSSM_KEYATTR_PARTIAL; + } + CssmAutoData encodedKey(allocator); if(isPub) { - crtn = DSAPublicKeyEncode(mDsaKey, encodedKey); + crtn = DSAPublicKeyEncode(dsaToEncode, format, encodedKey); } else { - crtn = DSAPrivateKeyEncode(mDsaKey, encodedKey); + crtn = DSAPrivateKeyEncode(dsaToEncode, format, encodedKey); + } + if(dsaUpgrade != NULL) { + /* temp key, get rid of it */ + DSA_free(dsaUpgrade); } if(crtn) { CssmError::throwMe(crtn); } blob = encodedKey.release(); } - + /*** *** DSA-style AppleKeyPairGenContext ***/ @@ -348,19 +489,19 @@ void DSAKeyPairGenContext::generate( CSSMERR_CSP_MISSING_ATTR_KEY_LENGTH); CssmData *paramData = context.get(CSSM_ATTRIBUTE_ALG_PARAMS); - DSAAlgParams algParams; + NSS_DSAAlgParams algParams; + SecNssCoder coder; // generated algParams mallocd from here if(paramData != NULL) { - /* this contains the DER encoding of a DSAAlgParams */ - try { - SC_decodeAsnObj(*paramData, algParams); - } - catch(...) { - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS); + /* this contains the DER encoding of a NSS_DSAAlgParams */ + CSSM_RETURN crtn = DSADecodeAlgParams(algParams, paramData->Data, + paramData->Length, coder); + if(crtn) { + CssmError::throwMe(crtn); } } else { /* no alg params specified; generate them now using null (random) seed */ - dsaGenParams(keyBits, NULL, 0, algParams); + dsaGenParams(keyBits, NULL, 0, algParams, coder); } /* create key, stuff params into it */ @@ -369,9 +510,9 @@ void DSAKeyPairGenContext::generate( CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); } DSA *dsaKey = rPrivBinKey.mDsaKey; - dsaKey->p = bigIntStrToBn(algParams.p); - dsaKey->q = bigIntStrToBn(algParams.q); - dsaKey->g = bigIntStrToBn(algParams.g); + dsaKey->p = cssmDataToBn(algParams.p); + dsaKey->q = cssmDataToBn(algParams.q); + dsaKey->g = cssmDataToBn(algParams.g); /* generate the key (both public and private capabilities) */ int irtn = DSA_generate_key(dsaKey); @@ -417,9 +558,10 @@ void DSAKeyPairGenContext::generate( seedLen = seedData->length(); } - /* generate the params */ - DSAAlgParams algParams; - dsaGenParams(bitSize, seed, seedLen, algParams); + /* generate the params, temp alloc from SecNssCoder */ + NSS_DSAAlgParams algParams; + SecNssCoder coder; + dsaGenParams(bitSize, seed, seedLen, algParams, coder); /* * Here comes the fun part. @@ -433,12 +575,8 @@ void DSAKeyPairGenContext::generate( * * First, DER encode. */ - size_t maxSize = sizeofBigInt(algParams.p) + - sizeofBigInt(algParams.q) + - sizeofBigInt(algParams.g) + - 10; CssmAutoData aDerData(session()); - SC_encodeAsnObj(algParams, aDerData, maxSize); + DSAEncodeAlgParams(algParams, aDerData); /* copy/release that into a mallocd CSSM_DATA. */ CSSM_DATA_PTR derData = (CSSM_DATA_PTR)session().malloc(sizeof(CSSM_DATA)); @@ -474,14 +612,15 @@ void DSAKeyPairGenContext::freeGenAttrs() /* * Generate DSA algorithm parameters from optional seed input, returning result - * into DSAAlgParams.[pqg]. This is called from both GenerateParameters and from + * into NSS_DSAAlgParamss.[pqg]. This is called from both GenerateParameters and from * KeyPairGenerate (if no GenerateParameters has yet been called). */ void DSAKeyPairGenContext::dsaGenParams( - uint32 keySizeInBits, - const void *inSeed, // optional - unsigned inSeedLen, - DSAAlgParams &algParams) + uint32 keySizeInBits, + const void *inSeed, // optional + unsigned inSeedLen, + NSS_DSAAlgParams &algParams, + SecNssCoder &coder) // contents of algParams mallocd from here { unsigned char seedBuf[SHA1_DIGEST_SIZE]; void *seedPtr; @@ -520,10 +659,10 @@ void DSAKeyPairGenContext::dsaGenParams( throwRsaDsa("DSA_generate_parameters"); } - /* stuff dsaKey->[pqg] into a caller's DSAAlgParams */ - bnToBigIntStr(dsaKey->p, algParams.p); - bnToBigIntStr(dsaKey->q, algParams.q); - bnToBigIntStr(dsaKey->g, algParams.g); + /* stuff dsaKey->[pqg] into a caller's NSS_DSAAlgParams */ + bnToCssmData(dsaKey->p, algParams.p, coder); + bnToCssmData(dsaKey->q, algParams.q, coder); + bnToCssmData(dsaKey->g, algParams.g, coder); DSA_free(dsaKey); } @@ -532,13 +671,15 @@ void DSAKeyPairGenContext::dsaGenParams( *** DSA-style CSPKeyInfoProvider. ***/ DSAKeyInfoProvider::DSAKeyInfoProvider( - const CssmKey &cssmKey) : - CSPKeyInfoProvider(cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) : + CSPKeyInfoProvider(cssmKey, session) { } CSPKeyInfoProvider *DSAKeyInfoProvider::provider( - const CssmKey &cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session) { switch(cssmKey.algorithm()) { case CSSM_ALGID_DSA: @@ -554,18 +695,26 @@ CSPKeyInfoProvider *DSAKeyInfoProvider::provider( return NULL; } /* OK, we'll handle this one */ - return new DSAKeyInfoProvider(cssmKey); + return new DSAKeyInfoProvider(cssmKey, session); } /* Given a raw key, cook up a Binary key */ void DSAKeyInfoProvider::CssmKeyToBinary( - BinaryKey **binKey) + CssmKey *paramKey, // optional + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT + BinaryKey **binKey) { *binKey = NULL; DSA *dsaKey = NULL; /* first cook up an DSA key, then drop that into a BinaryKey */ - dsaKey = rawCssmKeyToDsa(mKey); + dsaKey = rawCssmKeyToDsa(mKey, mSession, paramKey); + if(dsaKey->p == NULL) { + attrFlags |= CSSM_KEYATTR_PARTIAL; + } + else { + attrFlags &= ~CSSM_KEYATTR_PARTIAL; + } DSABinaryKey *dsaBinKey = new DSABinaryKey(dsaKey); *binKey = dsaBinKey; } @@ -581,8 +730,32 @@ void DSAKeyInfoProvider::QueryKeySizeInBits( if(mKey.blobType() != CSSM_KEYBLOB_RAW) { CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_FORMAT); } - dsaKey = rawCssmKeyToDsa(mKey); - keySize.LogicalKeySizeInBits = BN_num_bits(dsaKey->p); - keySize.EffectiveKeySizeInBits = keySize.LogicalKeySizeInBits; - DSA_free(dsaKey); + dsaKey = rawCssmKeyToDsa(mKey, + mSession, + NULL); // no param key allowed here + if(dsaKey->p != NULL) { + /* normal fully-formed key */ + keySize.LogicalKeySizeInBits = BN_num_bits(dsaKey->p); + keySize.EffectiveKeySizeInBits = keySize.LogicalKeySizeInBits; + DSA_free(dsaKey); + } + else { + /* partial key, get an approximation from pub_key */ + keySize.LogicalKeySizeInBits = BN_num_bits(dsaKey->pub_key); + DSA_free(dsaKey); + /* and indicate this anomaly like so */ + CssmError::throwMe(CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE); + } +} + +/* + * Obtain blob suitable for hashing in CSSM_APPLECSP_KEYDIGEST + * passthrough. + */ +bool DSAKeyInfoProvider::getHashableBlob( + CssmAllocator &allocator, + CssmData &blob) // blob to hash goes here +{ + /* No optimized case for DSA keys */ + return false; } diff --git a/AppleCSP/RSA_DSA/RSA_DSA_keys.h b/AppleCSP/RSA_DSA/RSA_DSA_keys.h index 337dc2a3..08f609e0 100644 --- a/AppleCSP/RSA_DSA/RSA_DSA_keys.h +++ b/AppleCSP/RSA_DSA/RSA_DSA_keys.h @@ -26,16 +26,17 @@ #include #include #include +#include "AppleCSPKeys.h" +#include #include #include #include -#include -#include +#include #define RSA_PUB_KEY_FORMAT CSSM_KEYBLOB_RAW_FORMAT_PKCS1 #define RSA_PRIV_KEY_FORMAT CSSM_KEYBLOB_RAW_FORMAT_PKCS8 -#define DSA_PUB_KEY_FORMAT CSSM_KEYBLOB_RAW_FORMAT_FIPS186 +#define DSA_PUB_KEY_FORMAT CSSM_KEYBLOB_RAW_FORMAT_X509 #define DSA_PRIV_KEY_FORMAT CSSM_KEYBLOB_RAW_FORMAT_FIPS186 #define DSA_MIN_KEY_SIZE 512 @@ -52,7 +53,10 @@ public: void generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format); + CSSM_KEYBLOB_FORMAT &format, + AppleCSPSession &session, + const CssmKey *paramKey, /* optional, unused here */ + CSSM_KEYATTR_FLAGS &attrFlags); /* IN/OUT */ RSA *mRsaKey; }; @@ -94,15 +98,23 @@ class RSAKeyInfoProvider : public CSPKeyInfoProvider { private: RSAKeyInfoProvider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); public: static CSPKeyInfoProvider *provider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); + ~RSAKeyInfoProvider() { } void CssmKeyToBinary( + CssmKey *paramKey, // optional + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT BinaryKey **binKey); // RETURNED void QueryKeySizeInBits( CSSM_KEY_SIZE &keySize); // RETURNED + bool getHashableBlob( + CssmAllocator &allocator, + CssmData &hashBlob); }; /* @@ -115,7 +127,10 @@ public: void generateKeyBlob( CssmAllocator &allocator, CssmData &blob, - CSSM_KEYBLOB_FORMAT &format); + CSSM_KEYBLOB_FORMAT &format, + AppleCSPSession &session, + const CssmKey *paramKey, /* optional */ + CSSM_KEYATTR_FLAGS &attrFlags); /* IN/OUT */ DSA *mDsaKey; }; @@ -167,7 +182,8 @@ public: uint32 keySizeInBits, const void *inSeed, // optional unsigned inSeedLen, - DSAAlgParams &algParams); + NSS_DSAAlgParams &algParams, + SecNssCoder &coder); private: /* gross hack to store attributes "returned" from GenParams */ @@ -182,15 +198,23 @@ class DSAKeyInfoProvider : public CSPKeyInfoProvider { private: DSAKeyInfoProvider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); public: static CSPKeyInfoProvider *provider( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session); + ~DSAKeyInfoProvider() { } void CssmKeyToBinary( + CssmKey *paramKey, // optional + CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT BinaryKey **binKey); // RETURNED void QueryKeySizeInBits( CSSM_KEY_SIZE &keySize); // RETURNED + bool getHashableBlob( + CssmAllocator &allocator, + CssmData &hashBlob); }; #endif /* _RSA_DSA_KEYS_H_ */ diff --git a/AppleCSP/RSA_DSA/RSA_DSA_signature.cpp b/AppleCSP/RSA_DSA/RSA_DSA_signature.cpp index 31976016..35cd0a83 100644 --- a/AppleCSP/RSA_DSA/RSA_DSA_signature.cpp +++ b/AppleCSP/RSA_DSA/RSA_DSA_signature.cpp @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#define rsaSigDebug(args...) debug("rsaSig", ## args) +#define rsaSigDebug(args...) secdebug("rsaSig", ## args) RSASigner::~RSASigner() { @@ -65,6 +65,19 @@ void RSASigner::signerInit( CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PADDING); } } + + /* optional blinding attribute */ + uint32 blinding = context.getInt(CSSM_ATTRIBUTE_RSA_BLINDING); + if(blinding) { + if(RSA_blinding_on(mRsaKey, NULL) <= 0) { + /* actually no legit failures */ + CssmError::throwMe(CSSMERR_CSP_INTERNAL_ERROR); + } + } + else { + RSA_blinding_off(mRsaKey); + } + setInitFlag(true); } @@ -297,7 +310,7 @@ void DSASigner::verify( } irtn = DSA_do_verify((unsigned char *)data, dataLen, dsaSig, mDsaKey); - if(!irtn) { + if(irtn != 1) { throwSigVerify = true; } diff --git a/AppleCSP/RSA_DSA/RSA_DSA_utils.cpp b/AppleCSP/RSA_DSA/RSA_DSA_utils.cpp index da4510ea..30125d47 100644 --- a/AppleCSP/RSA_DSA/RSA_DSA_utils.cpp +++ b/AppleCSP/RSA_DSA/RSA_DSA_utils.cpp @@ -22,16 +22,16 @@ #include "RSA_DSA_utils.h" #include "RSA_DSA_keys.h" -#include +#include +#include #include #include -#include #include #include #include #include -#define rsaMiscDebug(args...) debug("rsaMisc", ## args) +#define rsaMiscDebug(args...) secdebug("rsaMisc", ## args) /* * Given a Context: @@ -57,6 +57,7 @@ RSA *contextToRsaKey( CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } cspValidateIntendedKeyUsage(&hdr, usage); + cspVerifyKeyTimes(hdr); return cssmKeyToRsa(cssmKey, session, mallocdKey); } /* @@ -117,16 +118,31 @@ RSA *rawCssmKeyToRsa( // someone else's key (should never happen) CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); } + /* validate and figure out what we're dealing with */ switch(hdr->KeyClass) { case CSSM_KEYCLASS_PUBLIC_KEY: - if(hdr->Format != RSA_PUB_KEY_FORMAT) { - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PUBLIC_KEY_FORMAT); + switch(hdr->Format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: + case CSSM_KEYBLOB_RAW_FORMAT_X509: + break; + /* openssh real soon now */ + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSH: + default: + CssmError::throwMe( + CSSMERR_CSP_INVALID_ATTR_PUBLIC_KEY_FORMAT); } isPub = true; break; case CSSM_KEYCLASS_PRIVATE_KEY: - if(hdr->Format != RSA_PRIV_KEY_FORMAT) { - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT); + switch(hdr->Format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: // default + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: // openssl style + break; + /* openssh real soon now */ + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSH: + default: + CssmError::throwMe( + CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT); } isPub = false; break; @@ -140,14 +156,12 @@ RSA *rawCssmKeyToRsa( } CSSM_RETURN crtn; if(isPub) { - crtn = RSAPublicKeyDecode(rsaKey, - cssmKey.KeyData.Data, - cssmKey.KeyData.Length); + crtn = RSAPublicKeyDecode(rsaKey, hdr->Format, + cssmKey.KeyData.Data, cssmKey.KeyData.Length); } else { - crtn = RSAPrivateKeyDecode(rsaKey, - cssmKey.KeyData.Data, - cssmKey.KeyData.Length); + crtn = RSAPrivateKeyDecode(rsaKey, hdr->Format, + cssmKey.KeyData.Data, cssmKey.KeyData.Length); } if(crtn) { CssmError::throwMe(crtn); @@ -155,6 +169,46 @@ RSA *rawCssmKeyToRsa( return rsaKey; } +/* + * Given a partially formed DSA public key (with no p, q, or g) and a + * CssmKey representing a supposedly fully-formed DSA key, populate + * the public key's p, g, and q with values from the fully formed key. + */ +CSSM_RETURN dsaGetParamsFromKey( + DSA *partialKey, + const CssmKey ¶mKey, + AppleCSPSession &session) +{ + bool allocdKey; + DSA *dsaParamKey = cssmKeyToDsa(paramKey, session, allocdKey); + if(dsaParamKey == NULL) { + errorLog0("dsaGetParamsFromKey: bad paramKey\n"); + return CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE; + } + CSSM_RETURN crtn = CSSM_OK; + + /* require fully formed other key of course... */ + if((dsaParamKey->p == NULL) || + (dsaParamKey->q == NULL) || + (dsaParamKey->g == NULL)) { + errorLog0("dsaGetParamsFromKey: incomplete paramKey\n"); + crtn = CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE; + goto abort; + } + rsaMiscDebug("dsaGetParamsFromKey: partialKey %p paramKey %p", + partialKey, dsaParamKey); + + partialKey->q = BN_dup(dsaParamKey->q); + partialKey->p = BN_dup(dsaParamKey->p); + partialKey->g = BN_dup(dsaParamKey->g); + +abort: + if(allocdKey) { + DSA_free(dsaParamKey); + } + return crtn; +} + /* * Given a Context: * -- obtain CSSM key (there must only be one) @@ -179,8 +233,62 @@ DSA *contextToDsaKey( CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); } cspValidateIntendedKeyUsage(&hdr, usage); - return cssmKeyToDsa(cssmKey, session, mallocdKey); + cspVerifyKeyTimes(hdr); + DSA *rtnDsa = cssmKeyToDsa(cssmKey, session, mallocdKey); + if((keyClass == CSSM_KEYCLASS_PUBLIC_KEY) && + (rtnDsa->p == NULL)) { + /* + * Special case: this specific key is only partially formed; + * it's missing the DSA parameters p, g, and q. To proceed with this + * key, the caller must pass in another fully formned DSA public key + * in raw form in the context. If it's there we use those parameters. + */ + rsaMiscDebug("contextToDsaKey; partial DSA key %p", rtnDsa); + CssmKey *paramKey = context.get(CSSM_ATTRIBUTE_PARAM_KEY); + if(paramKey == NULL) { + rsaMiscDebug("contextToDsaKey: missing DSA params, no pub key in " + "context"); + if(mallocdKey) { + DSA_free(rtnDsa); + mallocdKey = false; + } + CssmError::throwMe(CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE); + } + + /* + * If this is a ref key, we have to cook up a new DSA key to + * avoid modifying the existing key. If we started with a raw key, + * we can modify it directly since the underlying DSA key has + * a lifetime only as long as this context (and since the context + * contains the parameter-bearing key, the params are valid + * as long as the DSA key). + */ + if(!mallocdKey) { + DSA *existKey = rtnDsa; + rtnDsa = DSA_new(); + if(rtnDsa == NULL) { + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + rtnDsa->pub_key = BN_dup(existKey->pub_key); + rsaMiscDebug("contextToDsaKey; temp partial copy %p", rtnDsa); + mallocdKey = true; + } + + /* + * Add params from paramKey into rtnDsa + */ + CSSM_RETURN crtn = dsaGetParamsFromKey(rtnDsa, *paramKey, session); + if(crtn) { + if(mallocdKey) { + DSA_free(rtnDsa); + mallocdKey = false; + } + CssmError::throwMe(crtn); + } + } + return rtnDsa; } + /* * Convert a CssmKey to an DSA * key. May result in the creation of a new * DSA (when cssmKey is a raw key); allocdKey is true in that case @@ -201,7 +309,7 @@ DSA *cssmKeyToDsa( } switch(hdr->BlobType) { case CSSM_KEYBLOB_RAW: - dsaKey = rawCssmKeyToDsa(cssmKey); + dsaKey = rawCssmKeyToDsa(cssmKey, session, NULL); allocdKey = true; break; case CSSM_KEYBLOB_REFERENCE: @@ -228,7 +336,9 @@ DSA *cssmKeyToDsa( * Convert a raw CssmKey to a newly alloc'd DSA key. */ DSA *rawCssmKeyToDsa( - const CssmKey &cssmKey) + const CssmKey &cssmKey, + AppleCSPSession &session, + const CssmKey *paramKey) // optional { const CSSM_KEYHEADER *hdr = &cssmKey.KeyHeader; bool isPub; @@ -239,16 +349,32 @@ DSA *rawCssmKeyToDsa( // someone else's key (should never happen) CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); } + /* validate and figure out what we're dealing with */ switch(hdr->KeyClass) { case CSSM_KEYCLASS_PUBLIC_KEY: - if(hdr->Format != DSA_PUB_KEY_FORMAT) { - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PUBLIC_KEY_FORMAT); + switch(hdr->Format) { + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: + case CSSM_KEYBLOB_RAW_FORMAT_X509: + break; + /* openssh real soon now */ + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSH: + default: + CssmError::throwMe( + CSSMERR_CSP_INVALID_ATTR_PUBLIC_KEY_FORMAT); } isPub = true; break; case CSSM_KEYCLASS_PRIVATE_KEY: - if(hdr->Format != DSA_PRIV_KEY_FORMAT) { - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT); + switch(hdr->Format) { + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: // default + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSL: // openssl style + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: // SMIME style + break; + /* openssh real soon now */ + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSH: + default: + CssmError::throwMe( + CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT); } isPub = false; break; @@ -262,17 +388,67 @@ DSA *rawCssmKeyToDsa( } CSSM_RETURN crtn; if(isPub) { - crtn = DSAPublicKeyDecode(dsaKey, + crtn = DSAPublicKeyDecode(dsaKey, hdr->Format, cssmKey.KeyData.Data, cssmKey.KeyData.Length); } else { - crtn = DSAPrivateKeyDecode(dsaKey, + crtn = DSAPrivateKeyDecode(dsaKey, hdr->Format, cssmKey.KeyData.Data, cssmKey.KeyData.Length); } if(crtn) { CssmError::throwMe(crtn); } + + /* + * Add in optional external parameters if this is not fully formed. + * This path is only taken from DSAKeyInfoProvider::CssmKeyToBinary, + * e.g., when doing a NULL unwrap of a partially formed DSA public + * key with the "complete the key with these params" option. + */ + if(isPub && (dsaKey->p == NULL) && (paramKey != NULL)) { + rsaMiscDebug("rawCssmKeyToDsa; updating dsaKey %p", dsaKey); + crtn = dsaGetParamsFromKey(dsaKey, *paramKey, session); + if(crtn) { + DSA_free(dsaKey); + CssmError::throwMe(crtn); + } + } return dsaKey; } + +/* + * Given a DSA private key, calculate its public component if it + * doesn't already exist. Used for calculating the key digest of + * an incoming raw private key. + */ +void dsaKeyPrivToPub( + DSA *dsaKey) +{ + assert(dsaKey != NULL); + assert(dsaKey->priv_key != NULL); + + if(dsaKey->pub_key != NULL) { + return; + } + + /* logic copied from DSA_generate_key() */ + dsaKey->pub_key = BN_new(); + if(dsaKey->pub_key == NULL) { + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + BN_CTX *ctx = BN_CTX_new(); + if (ctx == NULL) { + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + int rtn = BN_mod_exp(dsaKey->pub_key, + dsaKey->g, + dsaKey->priv_key, + dsaKey->p, + ctx); + BN_CTX_free(ctx); + if(rtn == 0) { + CssmError::throwMe(CSSMERR_CSP_INTERNAL_ERROR); + } +} diff --git a/AppleCSP/RSA_DSA/RSA_DSA_utils.h b/AppleCSP/RSA_DSA/RSA_DSA_utils.h index e3acd649..0a761d4b 100644 --- a/AppleCSP/RSA_DSA/RSA_DSA_utils.h +++ b/AppleCSP/RSA_DSA/RSA_DSA_utils.h @@ -61,6 +61,16 @@ RSA *cssmKeyToRsa( RSA *rawCssmKeyToRsa( const CssmKey &cssmKey); +/* + * Given a partially formed DSA public key (with no p, q, or g) and a + * CssmKey representing a supposedly fully-formed DSA key, populate + * the public key's p, g, and q with values from the fully formed key. + */ +CSSM_RETURN dsaGetParamsFromKey( + DSA *partialKey, + const CssmKey ¶mKey, + AppleCSPSession &session); + /* * Given a Context: * -- obtain CSSM key (there must only be one) @@ -89,7 +99,17 @@ DSA *cssmKeyToDsa( * Convert a raw CssmKey to a newly alloc'd DSA *. */ DSA *rawCssmKeyToDsa( - const CssmKey &cssmKey); + const CssmKey &cssmKey, + AppleCSPSession &session, + const CssmKey *paramKey); // optional + +/* + * Given a DSA private key, calculate its public component if it + * doesn't already exist. Used for calculating the key digest of + * an incoming raw private key. + */ +void dsaKeyPrivToPub( + DSA *dsaKey); #ifdef __cplusplus } diff --git a/AppleCSP/RSA_DSA/RSA_asymmetric.cpp b/AppleCSP/RSA_DSA/RSA_asymmetric.cpp index 33fa9f0e..38908106 100644 --- a/AppleCSP/RSA_DSA/RSA_asymmetric.cpp +++ b/AppleCSP/RSA_DSA/RSA_asymmetric.cpp @@ -25,8 +25,8 @@ #include #include -#define rsaCryptDebug(args...) debug("rsaCrypt", ## args) -#define rbprintf(args...) debug("rsaBuf", ## args) +#define rsaCryptDebug(args...) secdebug("rsaCrypt", ## args) +#define rbprintf(args...) secdebug("rsaBuf", ## args) RSA_CryptContext::~RSA_CryptContext() { @@ -39,7 +39,7 @@ RSA_CryptContext::~RSA_CryptContext() } /* called by CSPFullPluginSession */ -void RSA_CryptContext::init(const Context &context, bool encoding = true) +void RSA_CryptContext::init(const Context &context, bool encoding /*= true*/) { if(mInitFlag && !opStarted()) { /* reusing - e.g. query followed by encrypt */ @@ -94,6 +94,18 @@ void RSA_CryptContext::init(const Context &context, bool encoding = true) CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PADDING); } + /* optional blinding attribute */ + uint32 blinding = context.getInt(CSSM_ATTRIBUTE_RSA_BLINDING); + if(blinding) { + if(RSA_blinding_on(mRsaKey, NULL) <= 0) { + /* actually no legit failures */ + CssmError::throwMe(CSSMERR_CSP_INTERNAL_ERROR); + } + } + else { + RSA_blinding_off(mRsaKey); + } + /* finally, have BlockCryptor set up its stuff. */ setup(encoding ? plainBlockSize : cipherBlockSize, // blockSizeIn encoding ? cipherBlockSize : plainBlockSize, // blockSizeOut @@ -172,7 +184,7 @@ void RSA_CryptContext::decryptBlock( size_t RSA_CryptContext::outputSize( bool final, // ignored - size_t inSize = 0) // output for given input size + size_t inSize /*= 0*/) // output for given input size { UInt32 rawBytes = inSize + inBufSize(); UInt32 rawBlocks = (rawBytes + inBlockSize() - 1) / inBlockSize(); diff --git a/AppleCSP/open_ssl/LICENSE b/AppleCSP/open_ssl/LICENSE new file mode 100644 index 00000000..c885273f --- /dev/null +++ b/AppleCSP/open_ssl/LICENSE @@ -0,0 +1,60 @@ + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + diff --git a/AppleCSP/open_ssl/bf/COPYRIGHT b/AppleCSP/open_ssl/bf/COPYRIGHT new file mode 100644 index 00000000..68572235 --- /dev/null +++ b/AppleCSP/open_ssl/bf/COPYRIGHT @@ -0,0 +1,46 @@ +Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +All rights reserved. + +This package is an Blowfish implementation written +by Eric Young (eay@cryptsoft.com). + +This library is free for commercial and non-commercial use as long as +the following conditions are aheared to. The following conditions +apply to all code found in this distribution. + +Copyright remains Eric Young's, and as such any Copyright notices in +the code are not to be removed. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by Eric Young (eay@cryptsoft.com) + +THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +The license and distribution terms for any publically available version or +derivative of this code cannot be changed. i.e. this code cannot simply be +copied and put under another distrubution license +[including the GNU Public License.] + +The reason behind this being stated in this direct manner is past +experience in code simply being copied and the attribution removed +from it and then being distributed as part of other packages. This +implementation was a non-trivial and unpaid effort. diff --git a/AppleCSP/open_ssl/bf/README b/AppleCSP/open_ssl/bf/README new file mode 100644 index 00000000..f2712fd0 --- /dev/null +++ b/AppleCSP/open_ssl/bf/README @@ -0,0 +1,8 @@ +This is a quick packaging up of my blowfish code into a library. +It has been lifted from SSLeay. +The copyright notices seem a little harsh because I have not spent the +time to rewrite the conditions from the normal SSLeay ones. + +Basically if you just want to play with the library, not a problem. + +eric 15-Apr-1997 diff --git a/AppleCSP/open_ssl/bf/bf_ecb.c b/AppleCSP/open_ssl/bf/bf_ecb.c new file mode 100644 index 00000000..34199163 --- /dev/null +++ b/AppleCSP/open_ssl/bf/bf_ecb.c @@ -0,0 +1,96 @@ +/* crypto/bf/bf_ecb.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "bf_locl.h" +#include + +/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' + * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, + * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) + */ + +const char *BF_version="Blowfish" OPENSSL_VERSION_PTEXT; + +const char *BF_options(void) + { +#ifdef BF_PTR + return("blowfish(ptr)"); +#elif defined(BF_PTR2) + return("blowfish(ptr2)"); +#else + return("blowfish(idx)"); +#endif + } + +void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, + const BF_KEY *key, int encrypt) + { + BF_LONG l,d[2]; + + n2l(in,l); d[0]=l; + n2l(in,l); d[1]=l; + if (encrypt) + BF_encrypt(d,key); + else + BF_decrypt(d,key); + l=d[0]; l2n(l,out); + l=d[1]; l2n(l,out); + l=d[0]=d[1]=0; + } + diff --git a/AppleCSP/open_ssl/bf/bf_enc.c b/AppleCSP/open_ssl/bf/bf_enc.c new file mode 100644 index 00000000..b380acf9 --- /dev/null +++ b/AppleCSP/open_ssl/bf/bf_enc.c @@ -0,0 +1,306 @@ +/* crypto/bf/bf_enc.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "bf_locl.h" + +/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' + * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, + * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) + */ + +#if (BF_ROUNDS != 16) && (BF_ROUNDS != 20) +#error If you set BF_ROUNDS to some value other than 16 or 20, you will have \ +to modify the code. +#endif + +void BF_encrypt(BF_LONG *data, const BF_KEY *key) + { +#ifndef BF_PTR2 + register BF_LONG l,r; + const register BF_LONG *p,*s; + + p=key->P; + s= &(key->S[0]); + l=data[0]; + r=data[1]; + + l^=p[0]; + BF_ENC(r,l,s,p[ 1]); + BF_ENC(l,r,s,p[ 2]); + BF_ENC(r,l,s,p[ 3]); + BF_ENC(l,r,s,p[ 4]); + BF_ENC(r,l,s,p[ 5]); + BF_ENC(l,r,s,p[ 6]); + BF_ENC(r,l,s,p[ 7]); + BF_ENC(l,r,s,p[ 8]); + BF_ENC(r,l,s,p[ 9]); + BF_ENC(l,r,s,p[10]); + BF_ENC(r,l,s,p[11]); + BF_ENC(l,r,s,p[12]); + BF_ENC(r,l,s,p[13]); + BF_ENC(l,r,s,p[14]); + BF_ENC(r,l,s,p[15]); + BF_ENC(l,r,s,p[16]); +#if BF_ROUNDS == 20 + BF_ENC(r,l,s,p[17]); + BF_ENC(l,r,s,p[18]); + BF_ENC(r,l,s,p[19]); + BF_ENC(l,r,s,p[20]); +#endif + r^=p[BF_ROUNDS+1]; + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; +#else + register BF_LONG l,r,t,*k; + + l=data[0]; + r=data[1]; + k=(BF_LONG*)key; + + l^=k[0]; + BF_ENC(r,l,k, 1); + BF_ENC(l,r,k, 2); + BF_ENC(r,l,k, 3); + BF_ENC(l,r,k, 4); + BF_ENC(r,l,k, 5); + BF_ENC(l,r,k, 6); + BF_ENC(r,l,k, 7); + BF_ENC(l,r,k, 8); + BF_ENC(r,l,k, 9); + BF_ENC(l,r,k,10); + BF_ENC(r,l,k,11); + BF_ENC(l,r,k,12); + BF_ENC(r,l,k,13); + BF_ENC(l,r,k,14); + BF_ENC(r,l,k,15); + BF_ENC(l,r,k,16); +#if BF_ROUNDS == 20 + BF_ENC(r,l,k,17); + BF_ENC(l,r,k,18); + BF_ENC(r,l,k,19); + BF_ENC(l,r,k,20); +#endif + r^=k[BF_ROUNDS+1]; + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; +#endif + } + +#ifndef BF_DEFAULT_OPTIONS + +void BF_decrypt(BF_LONG *data, const BF_KEY *key) + { +#ifndef BF_PTR2 + register BF_LONG l,r; + const register BF_LONG *p,*s; + + p=key->P; + s= &(key->S[0]); + l=data[0]; + r=data[1]; + + l^=p[BF_ROUNDS+1]; +#if BF_ROUNDS == 20 + BF_ENC(r,l,s,p[20]); + BF_ENC(l,r,s,p[19]); + BF_ENC(r,l,s,p[18]); + BF_ENC(l,r,s,p[17]); +#endif + BF_ENC(r,l,s,p[16]); + BF_ENC(l,r,s,p[15]); + BF_ENC(r,l,s,p[14]); + BF_ENC(l,r,s,p[13]); + BF_ENC(r,l,s,p[12]); + BF_ENC(l,r,s,p[11]); + BF_ENC(r,l,s,p[10]); + BF_ENC(l,r,s,p[ 9]); + BF_ENC(r,l,s,p[ 8]); + BF_ENC(l,r,s,p[ 7]); + BF_ENC(r,l,s,p[ 6]); + BF_ENC(l,r,s,p[ 5]); + BF_ENC(r,l,s,p[ 4]); + BF_ENC(l,r,s,p[ 3]); + BF_ENC(r,l,s,p[ 2]); + BF_ENC(l,r,s,p[ 1]); + r^=p[0]; + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; +#else + register BF_LONG l,r,t,*k; + + l=data[0]; + r=data[1]; + k=(BF_LONG *)key; + + l^=k[BF_ROUNDS+1]; +#if BF_ROUNDS == 20 + BF_ENC(r,l,k,20); + BF_ENC(l,r,k,19); + BF_ENC(r,l,k,18); + BF_ENC(l,r,k,17); +#endif + BF_ENC(r,l,k,16); + BF_ENC(l,r,k,15); + BF_ENC(r,l,k,14); + BF_ENC(l,r,k,13); + BF_ENC(r,l,k,12); + BF_ENC(l,r,k,11); + BF_ENC(r,l,k,10); + BF_ENC(l,r,k, 9); + BF_ENC(r,l,k, 8); + BF_ENC(l,r,k, 7); + BF_ENC(r,l,k, 6); + BF_ENC(l,r,k, 5); + BF_ENC(r,l,k, 4); + BF_ENC(l,r,k, 3); + BF_ENC(r,l,k, 2); + BF_ENC(l,r,k, 1); + r^=k[0]; + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; +#endif + } + +void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int encrypt) + { + register BF_LONG tin0,tin1; + register BF_LONG tout0,tout1,xor0,xor1; + register long l=length; + BF_LONG tin[2]; + + if (encrypt) + { + n2l(ivec,tout0); + n2l(ivec,tout1); + ivec-=8; + for (l-=8; l>=0; l-=8) + { + n2l(in,tin0); + n2l(in,tin1); + tin0^=tout0; + tin1^=tout1; + tin[0]=tin0; + tin[1]=tin1; + BF_encrypt(tin,schedule); + tout0=tin[0]; + tout1=tin[1]; + l2n(tout0,out); + l2n(tout1,out); + } + if (l != -8) + { + n2ln(in,tin0,tin1,l+8); + tin0^=tout0; + tin1^=tout1; + tin[0]=tin0; + tin[1]=tin1; + BF_encrypt(tin,schedule); + tout0=tin[0]; + tout1=tin[1]; + l2n(tout0,out); + l2n(tout1,out); + } + l2n(tout0,ivec); + l2n(tout1,ivec); + } + else + { + n2l(ivec,xor0); + n2l(ivec,xor1); + ivec-=8; + for (l-=8; l>=0; l-=8) + { + n2l(in,tin0); + n2l(in,tin1); + tin[0]=tin0; + tin[1]=tin1; + BF_decrypt(tin,schedule); + tout0=tin[0]^xor0; + tout1=tin[1]^xor1; + l2n(tout0,out); + l2n(tout1,out); + xor0=tin0; + xor1=tin1; + } + if (l != -8) + { + n2l(in,tin0); + n2l(in,tin1); + tin[0]=tin0; + tin[1]=tin1; + BF_decrypt(tin,schedule); + tout0=tin[0]^xor0; + tout1=tin[1]^xor1; + l2nn(tout0,tout1,out,l+8); + xor0=tin0; + xor1=tin1; + } + l2n(xor0,ivec); + l2n(xor1,ivec); + } + tin0=tin1=tout0=tout1=xor0=xor1=0; + tin[0]=tin[1]=0; + } + +#endif diff --git a/AppleCSP/open_ssl/bf/bf_locl.h b/AppleCSP/open_ssl/bf/bf_locl.h new file mode 100644 index 00000000..778420b0 --- /dev/null +++ b/AppleCSP/open_ssl/bf/bf_locl.h @@ -0,0 +1,232 @@ +/* crypto/bf/bf_locl.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BF_LOCL_H +#define HEADER_BF_LOCL_H +#include /* BF_PTR, BF_PTR2 */ + +#undef c2l +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#undef c2ln +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ + case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ + case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#undef l2cn +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#if defined(__GNUC__) && defined(__ppc__) +/* alignment tolerant big-endian optimization */ + #define n2l(c,l) { l= *((unsigned long *)c); c += 4; } +#else +/* little endian, etc. */ + #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) +#endif + +#undef l2n +#if defined(__GNUC__) && defined(__ppc__) + /* alignment tolerant big-endian optimization */ + #define l2n(l,c) { *((unsigned long *)c) = l; c += 4; } +#else + /* little endian, etc. */ + #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#endif /* GNU, big endian */ + +/* This is actually a big endian algorithm, the most significant byte + * is used to lookup array 0 */ + +#if defined(BF_PTR2) + +/* + * This is basically a special Intel version. Point is that Intel + * doesn't have many registers, but offers a reach choice of addressing + * modes. So we spare some registers by directly traversing BF_KEY + * structure and hiring the most decorated addressing mode. The code + * generated by EGCS is *perfectly* competitive with assembler + * implementation! + */ +#define BF_ENC(LL,R,KEY,Pi) (\ + LL^=KEY[Pi], \ + t= KEY[BF_ROUNDS+2 + 0 + ((R>>24)&0xFF)], \ + t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \ + t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \ + t+= KEY[BF_ROUNDS+2 + 768 + ((R )&0xFF)], \ + LL^=t \ + ) + +#elif defined(BF_PTR) + +#ifndef BF_LONG_LOG2 +#define BF_LONG_LOG2 2 /* default to BF_LONG being 32 bits */ +#endif +#define BF_M (0xFF<>BF_i)&BF_M gets folded into a single instruction, namely + * rlwinm. So let'em double-check if their compiler does it. + */ + +#define BF_ENC(LL,R,S,P) ( \ + LL^=P, \ + LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \ + *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ + *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ + *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24)&0xff)] + \ + S[0x0100+((int)(R>>16)&0xff)])^ \ + S[0x0200+((int)(R>> 8)&0xff)])+ \ + S[0x0300+((int)(R )&0xff)])&0xffffffffL \ + ) +#endif + +#endif diff --git a/AppleCSP/open_ssl/bf/bf_pi.h b/AppleCSP/open_ssl/bf/bf_pi.h new file mode 100644 index 00000000..9949513c --- /dev/null +++ b/AppleCSP/open_ssl/bf/bf_pi.h @@ -0,0 +1,325 @@ +/* crypto/bf/bf_pi.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +static const BF_KEY bf_init= { + { + 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L, + 0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L, + 0x452821e6L, 0x38d01377L, 0xbe5466cfL, 0x34e90c6cL, + 0xc0ac29b7L, 0xc97c50ddL, 0x3f84d5b5L, 0xb5470917L, + 0x9216d5d9L, 0x8979fb1b + },{ + 0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L, + 0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L, + 0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L, + 0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL, + 0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL, + 0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L, + 0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL, + 0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL, + 0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L, + 0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L, + 0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL, + 0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL, + 0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL, + 0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L, + 0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L, + 0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L, + 0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L, + 0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L, + 0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL, + 0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L, + 0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L, + 0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L, + 0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L, + 0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL, + 0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L, + 0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL, + 0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL, + 0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L, + 0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL, + 0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L, + 0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL, + 0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L, + 0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L, + 0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL, + 0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L, + 0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L, + 0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL, + 0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L, + 0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL, + 0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L, + 0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L, + 0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL, + 0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L, + 0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L, + 0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L, + 0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L, + 0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L, + 0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL, + 0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL, + 0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L, + 0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L, + 0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L, + 0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L, + 0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL, + 0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L, + 0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL, + 0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL, + 0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L, + 0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L, + 0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L, + 0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L, + 0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L, + 0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L, + 0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL, + 0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L, + 0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L, + 0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L, + 0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL, + 0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L, + 0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L, + 0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL, + 0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L, + 0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L, + 0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L, + 0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL, + 0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL, + 0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L, + 0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L, + 0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L, + 0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L, + 0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL, + 0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL, + 0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL, + 0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L, + 0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL, + 0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L, + 0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L, + 0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL, + 0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL, + 0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L, + 0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL, + 0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L, + 0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL, + 0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL, + 0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L, + 0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L, + 0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L, + 0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L, + 0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L, + 0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L, + 0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L, + 0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL, + 0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L, + 0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL, + 0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L, + 0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L, + 0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L, + 0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L, + 0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L, + 0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L, + 0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L, + 0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L, + 0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L, + 0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L, + 0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L, + 0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L, + 0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L, + 0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L, + 0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L, + 0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L, + 0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL, + 0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL, + 0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L, + 0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL, + 0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L, + 0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L, + 0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L, + 0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L, + 0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L, + 0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L, + 0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL, + 0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L, + 0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L, + 0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L, + 0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL, + 0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL, + 0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL, + 0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L, + 0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L, + 0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL, + 0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L, + 0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL, + 0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L, + 0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL, + 0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L, + 0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL, + 0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L, + 0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL, + 0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L, + 0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L, + 0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL, + 0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L, + 0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L, + 0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L, + 0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L, + 0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL, + 0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L, + 0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL, + 0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L, + 0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL, + 0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L, + 0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL, + 0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL, + 0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL, + 0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L, + 0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L, + 0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL, + 0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL, + 0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL, + 0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL, + 0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL, + 0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L, + 0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L, + 0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L, + 0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L, + 0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL, + 0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL, + 0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L, + 0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L, + 0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L, + 0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L, + 0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L, + 0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L, + 0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L, + 0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L, + 0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L, + 0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L, + 0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL, + 0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L, + 0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL, + 0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L, + 0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L, + 0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL, + 0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL, + 0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL, + 0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L, + 0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L, + 0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L, + 0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L, + 0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L, + 0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L, + 0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L, + 0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L, + 0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L, + 0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L, + 0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L, + 0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L, + 0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL, + 0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL, + 0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L, + 0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL, + 0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL, + 0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL, + 0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L, + 0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL, + 0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL, + 0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L, + 0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L, + 0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L, + 0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L, + 0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL, + 0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL, + 0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L, + 0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L, + 0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L, + 0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL, + 0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L, + 0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L, + 0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L, + 0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL, + 0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L, + 0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L, + 0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L, + 0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL, + 0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL, + 0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L, + 0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L, + 0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L, + 0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L, + 0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL, + 0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L, + 0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL, + 0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL, + 0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L, + 0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L, + 0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL, + 0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L, + 0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL, + 0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L, + 0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL, + 0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L, + 0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L, + 0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL, + 0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L, + 0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL, + 0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L, + } + }; + diff --git a/AppleCSP/open_ssl/bf/bf_skey.c b/AppleCSP/open_ssl/bf/bf_skey.c new file mode 100644 index 00000000..4d6a232f --- /dev/null +++ b/AppleCSP/open_ssl/bf/bf_skey.c @@ -0,0 +1,116 @@ +/* crypto/bf/bf_skey.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include +#include "bf_locl.h" +#include "bf_pi.h" + +void BF_set_key(BF_KEY *key, int len, const unsigned char *data) + { + int i; + BF_LONG *p,ri,in[2]; + const unsigned char *d,*end; + + + memcpy((char *)key,(char *)&bf_init,sizeof(BF_KEY)); + p=key->P; + + if (len > ((BF_ROUNDS+2)*4)) len=(BF_ROUNDS+2)*4; + + d=data; + end= &(data[len]); + for (i=0; i<(BF_ROUNDS+2); i++) + { + ri= *(d++); + if (d >= end) d=data; + + ri<<=8; + ri|= *(d++); + if (d >= end) d=data; + + ri<<=8; + ri|= *(d++); + if (d >= end) d=data; + + ri<<=8; + ri|= *(d++); + if (d >= end) d=data; + + p[i]^=ri; + } + + in[0]=0L; + in[1]=0L; + for (i=0; i<(BF_ROUNDS+2); i+=2) + { + BF_encrypt(in,key); + p[i ]=in[0]; + p[i+1]=in[1]; + } + + p=key->S; + for (i=0; i<4*256; i+=2) + { + BF_encrypt(in,key); + p[i ]=in[0]; + p[i+1]=in[1]; + } + } + diff --git a/AppleCSP/open_ssl/bn/bn_lib.c b/AppleCSP/open_ssl/bn/bn_lib.c index 9ec461ff..667dca23 100644 --- a/AppleCSP/open_ssl/bn/bn_lib.c +++ b/AppleCSP/open_ssl/bn/bn_lib.c @@ -536,7 +536,8 @@ void BN_clear(BIGNUM *a) BN_ULONG BN_get_word(BIGNUM *a) { - int i,n; + int i; + unsigned n; BN_ULONG ret=0; n=BN_num_bytes(a); @@ -558,7 +559,8 @@ BN_ULONG BN_get_word(BIGNUM *a) int BN_set_word(BIGNUM *a, BN_ULONG w) { int i,n; - if (bn_expand(a,sizeof(BN_ULONG)*8) == NULL) return(0); + + if (bn_expand(a,(int)(sizeof(BN_ULONG)*8)) == NULL) return(0); n=sizeof(BN_ULONG)/BN_BYTES; a->neg=0; diff --git a/AppleCSP/open_ssl/cast/c_ecb.c b/AppleCSP/open_ssl/cast/c_ecb.c new file mode 100644 index 00000000..0b3da9ad --- /dev/null +++ b/AppleCSP/open_ssl/cast/c_ecb.c @@ -0,0 +1,80 @@ +/* crypto/cast/c_ecb.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cast_lcl.h" +#include + +const char *CAST_version="CAST" OPENSSL_VERSION_PTEXT; + +void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, + CAST_KEY *ks, int enc) + { + CAST_LONG l,d[2]; + + n2l(in,l); d[0]=l; + n2l(in,l); d[1]=l; + if (enc) + CAST_encrypt(d,ks); + else + CAST_decrypt(d,ks); + l=d[0]; l2n(l,out); + l=d[1]; l2n(l,out); + l=d[0]=d[1]=0; + } + diff --git a/AppleCSP/open_ssl/cast/c_enc.c b/AppleCSP/open_ssl/cast/c_enc.c new file mode 100644 index 00000000..33c7066d --- /dev/null +++ b/AppleCSP/open_ssl/cast/c_enc.c @@ -0,0 +1,210 @@ +/* crypto/cast/c_enc.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cast_lcl.h" + +void CAST_encrypt(CAST_LONG *data, CAST_KEY *key) + { + register CAST_LONG l,r,*k,t; + + k= &(key->data[0]); + l=data[0]; + r=data[1]; + + E_CAST( 0,k,l,r,+,^,-); + E_CAST( 1,k,r,l,^,-,+); + E_CAST( 2,k,l,r,-,+,^); + E_CAST( 3,k,r,l,+,^,-); + E_CAST( 4,k,l,r,^,-,+); + E_CAST( 5,k,r,l,-,+,^); + E_CAST( 6,k,l,r,+,^,-); + E_CAST( 7,k,r,l,^,-,+); + E_CAST( 8,k,l,r,-,+,^); + E_CAST( 9,k,r,l,+,^,-); + E_CAST(10,k,l,r,^,-,+); + E_CAST(11,k,r,l,-,+,^); + if(!key->short_key) + { + E_CAST(12,k,l,r,+,^,-); + E_CAST(13,k,r,l,^,-,+); + E_CAST(14,k,l,r,-,+,^); + E_CAST(15,k,r,l,+,^,-); + } + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; + } + +void CAST_decrypt(CAST_LONG *data, CAST_KEY *key) + { + register CAST_LONG l,r,*k,t; + + k= &(key->data[0]); + l=data[0]; + r=data[1]; + + if(!key->short_key) + { + E_CAST(15,k,l,r,+,^,-); + E_CAST(14,k,r,l,-,+,^); + E_CAST(13,k,l,r,^,-,+); + E_CAST(12,k,r,l,+,^,-); + } + E_CAST(11,k,l,r,-,+,^); + E_CAST(10,k,r,l,^,-,+); + E_CAST( 9,k,l,r,+,^,-); + E_CAST( 8,k,r,l,-,+,^); + E_CAST( 7,k,l,r,^,-,+); + E_CAST( 6,k,r,l,+,^,-); + E_CAST( 5,k,l,r,-,+,^); + E_CAST( 4,k,r,l,^,-,+); + E_CAST( 3,k,l,r,+,^,-); + E_CAST( 2,k,r,l,-,+,^); + E_CAST( 1,k,l,r,^,-,+); + E_CAST( 0,k,r,l,+,^,-); + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; + } + +#ifndef __APPLE__ +/* CBC logic not needed here */ +void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + CAST_KEY *ks, unsigned char *iv, int enc) + { + register CAST_LONG tin0,tin1; + register CAST_LONG tout0,tout1,xor0,xor1; + register long l=length; + CAST_LONG tin[2]; + + if (enc) + { + n2l(iv,tout0); + n2l(iv,tout1); + iv-=8; + for (l-=8; l>=0; l-=8) + { + n2l(in,tin0); + n2l(in,tin1); + tin0^=tout0; + tin1^=tout1; + tin[0]=tin0; + tin[1]=tin1; + CAST_encrypt(tin,ks); + tout0=tin[0]; + tout1=tin[1]; + l2n(tout0,out); + l2n(tout1,out); + } + if (l != -8) + { + n2ln(in,tin0,tin1,l+8); + tin0^=tout0; + tin1^=tout1; + tin[0]=tin0; + tin[1]=tin1; + CAST_encrypt(tin,ks); + tout0=tin[0]; + tout1=tin[1]; + l2n(tout0,out); + l2n(tout1,out); + } + l2n(tout0,iv); + l2n(tout1,iv); + } + else + { + n2l(iv,xor0); + n2l(iv,xor1); + iv-=8; + for (l-=8; l>=0; l-=8) + { + n2l(in,tin0); + n2l(in,tin1); + tin[0]=tin0; + tin[1]=tin1; + CAST_decrypt(tin,ks); + tout0=tin[0]^xor0; + tout1=tin[1]^xor1; + l2n(tout0,out); + l2n(tout1,out); + xor0=tin0; + xor1=tin1; + } + if (l != -8) + { + n2l(in,tin0); + n2l(in,tin1); + tin[0]=tin0; + tin[1]=tin1; + CAST_decrypt(tin,ks); + tout0=tin[0]^xor0; + tout1=tin[1]^xor1; + l2nn(tout0,tout1,out,l+8); + xor0=tin0; + xor1=tin1; + } + l2n(xor0,iv); + l2n(xor1,iv); + } + tin0=tin1=tout0=tout1=xor0=xor1=0; + tin[0]=tin[1]=0; + } + +#endif /* __APPLE__ */ diff --git a/AppleCSP/open_ssl/cast/c_skey.c b/AppleCSP/open_ssl/cast/c_skey.c new file mode 100644 index 00000000..76e40005 --- /dev/null +++ b/AppleCSP/open_ssl/cast/c_skey.c @@ -0,0 +1,166 @@ +/* crypto/cast/c_skey.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cast_lcl.h" +#include "cast_s.h" + +#define CAST_exp(l,A,a,n) \ + A[n/4]=l; \ + a[n+3]=(l )&0xff; \ + a[n+2]=(l>> 8)&0xff; \ + a[n+1]=(l>>16)&0xff; \ + a[n+0]=(l>>24)&0xff; + +#define S4 CAST_S_table4 +#define S5 CAST_S_table5 +#define S6 CAST_S_table6 +#define S7 CAST_S_table7 + +void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data) + { + CAST_LONG x[16]; + CAST_LONG z[16]; + CAST_LONG k[32]; + CAST_LONG X[4],Z[4]; + CAST_LONG l,*K; + int i; + + for (i=0; i<16; i++) x[i]=0; + if (len > 16) len=16; + for (i=0; ishort_key=1; + else + key->short_key=0; + + K= &k[0]; + X[0]=((x[ 0]<<24)|(x[ 1]<<16)|(x[ 2]<<8)|x[ 3])&0xffffffffL; + X[1]=((x[ 4]<<24)|(x[ 5]<<16)|(x[ 6]<<8)|x[ 7])&0xffffffffL; + X[2]=((x[ 8]<<24)|(x[ 9]<<16)|(x[10]<<8)|x[11])&0xffffffffL; + X[3]=((x[12]<<24)|(x[13]<<16)|(x[14]<<8)|x[15])&0xffffffffL; + + for (;;) + { + l=X[0]^S4[x[13]]^S5[x[15]]^S6[x[12]]^S7[x[14]]^S6[x[ 8]]; + CAST_exp(l,Z,z, 0); + l=X[2]^S4[z[ 0]]^S5[z[ 2]]^S6[z[ 1]]^S7[z[ 3]]^S7[x[10]]; + CAST_exp(l,Z,z, 4); + l=X[3]^S4[z[ 7]]^S5[z[ 6]]^S6[z[ 5]]^S7[z[ 4]]^S4[x[ 9]]; + CAST_exp(l,Z,z, 8); + l=X[1]^S4[z[10]]^S5[z[ 9]]^S6[z[11]]^S7[z[ 8]]^S5[x[11]]; + CAST_exp(l,Z,z,12); + + K[ 0]= S4[z[ 8]]^S5[z[ 9]]^S6[z[ 7]]^S7[z[ 6]]^S4[z[ 2]]; + K[ 1]= S4[z[10]]^S5[z[11]]^S6[z[ 5]]^S7[z[ 4]]^S5[z[ 6]]; + K[ 2]= S4[z[12]]^S5[z[13]]^S6[z[ 3]]^S7[z[ 2]]^S6[z[ 9]]; + K[ 3]= S4[z[14]]^S5[z[15]]^S6[z[ 1]]^S7[z[ 0]]^S7[z[12]]; + + l=Z[2]^S4[z[ 5]]^S5[z[ 7]]^S6[z[ 4]]^S7[z[ 6]]^S6[z[ 0]]; + CAST_exp(l,X,x, 0); + l=Z[0]^S4[x[ 0]]^S5[x[ 2]]^S6[x[ 1]]^S7[x[ 3]]^S7[z[ 2]]; + CAST_exp(l,X,x, 4); + l=Z[1]^S4[x[ 7]]^S5[x[ 6]]^S6[x[ 5]]^S7[x[ 4]]^S4[z[ 1]]; + CAST_exp(l,X,x, 8); + l=Z[3]^S4[x[10]]^S5[x[ 9]]^S6[x[11]]^S7[x[ 8]]^S5[z[ 3]]; + CAST_exp(l,X,x,12); + + K[ 4]= S4[x[ 3]]^S5[x[ 2]]^S6[x[12]]^S7[x[13]]^S4[x[ 8]]; + K[ 5]= S4[x[ 1]]^S5[x[ 0]]^S6[x[14]]^S7[x[15]]^S5[x[13]]; + K[ 6]= S4[x[ 7]]^S5[x[ 6]]^S6[x[ 8]]^S7[x[ 9]]^S6[x[ 3]]; + K[ 7]= S4[x[ 5]]^S5[x[ 4]]^S6[x[10]]^S7[x[11]]^S7[x[ 7]]; + + l=X[0]^S4[x[13]]^S5[x[15]]^S6[x[12]]^S7[x[14]]^S6[x[ 8]]; + CAST_exp(l,Z,z, 0); + l=X[2]^S4[z[ 0]]^S5[z[ 2]]^S6[z[ 1]]^S7[z[ 3]]^S7[x[10]]; + CAST_exp(l,Z,z, 4); + l=X[3]^S4[z[ 7]]^S5[z[ 6]]^S6[z[ 5]]^S7[z[ 4]]^S4[x[ 9]]; + CAST_exp(l,Z,z, 8); + l=X[1]^S4[z[10]]^S5[z[ 9]]^S6[z[11]]^S7[z[ 8]]^S5[x[11]]; + CAST_exp(l,Z,z,12); + + K[ 8]= S4[z[ 3]]^S5[z[ 2]]^S6[z[12]]^S7[z[13]]^S4[z[ 9]]; + K[ 9]= S4[z[ 1]]^S5[z[ 0]]^S6[z[14]]^S7[z[15]]^S5[z[12]]; + K[10]= S4[z[ 7]]^S5[z[ 6]]^S6[z[ 8]]^S7[z[ 9]]^S6[z[ 2]]; + K[11]= S4[z[ 5]]^S5[z[ 4]]^S6[z[10]]^S7[z[11]]^S7[z[ 6]]; + + l=Z[2]^S4[z[ 5]]^S5[z[ 7]]^S6[z[ 4]]^S7[z[ 6]]^S6[z[ 0]]; + CAST_exp(l,X,x, 0); + l=Z[0]^S4[x[ 0]]^S5[x[ 2]]^S6[x[ 1]]^S7[x[ 3]]^S7[z[ 2]]; + CAST_exp(l,X,x, 4); + l=Z[1]^S4[x[ 7]]^S5[x[ 6]]^S6[x[ 5]]^S7[x[ 4]]^S4[z[ 1]]; + CAST_exp(l,X,x, 8); + l=Z[3]^S4[x[10]]^S5[x[ 9]]^S6[x[11]]^S7[x[ 8]]^S5[z[ 3]]; + CAST_exp(l,X,x,12); + + K[12]= S4[x[ 8]]^S5[x[ 9]]^S6[x[ 7]]^S7[x[ 6]]^S4[x[ 3]]; + K[13]= S4[x[10]]^S5[x[11]]^S6[x[ 5]]^S7[x[ 4]]^S5[x[ 7]]; + K[14]= S4[x[12]]^S5[x[13]]^S6[x[ 3]]^S7[x[ 2]]^S6[x[ 8]]; + K[15]= S4[x[14]]^S5[x[15]]^S6[x[ 1]]^S7[x[ 0]]^S7[x[13]]; + if (K != k) break; + K+=16; + } + + for (i=0; i<16; i++) + { + key->data[i*2]=k[i]; + key->data[i*2+1]=((k[i+16])+16)&0x1f; + } + } + diff --git a/AppleCSP/open_ssl/cast/cast_lcl.h b/AppleCSP/open_ssl/cast/cast_lcl.h new file mode 100644 index 00000000..dcd9798f --- /dev/null +++ b/AppleCSP/open_ssl/cast/cast_lcl.h @@ -0,0 +1,239 @@ +/* crypto/cast/cast_lcl.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifdef WIN32 +#include +#endif + + +#include "openssl/e_os.h" /* OPENSSL_EXTERN */ + +#undef c2l +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#undef c2ln +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ + case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ + case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#undef l2cn +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#if defined(__GNUC__) && defined(__ppc__) +/* alignment tolerant big-endian optimization */ + #define n2l(c,l) { l= *((unsigned long *)c); c += 4; } +#else +/* little endian, etc. */ + #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) +#endif + +#undef l2n +#if defined(__GNUC__) && defined(__ppc__) + /* alignment tolerant big-endian optimization */ + #define l2n(l,c) { *((unsigned long *)c) = l; c += 4; } +#else + /* little endian, etc. */ + #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#endif /* GNU, big endian */ + +#if defined(WIN32) && defined(_MSC_VER) +#define ROTL(a,n) (_lrotl(a,n)) +#else +#define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n)))) +#endif + +#define C_M 0x3fc +#define C_0 22L +#define C_1 14L +#define C_2 6L +#define C_3 2L /* left shift */ + +/* The rotate has an extra 16 added to it to help the x86 asm */ +#if defined(CAST_PTR) +#define E_CAST(n,key,L,R,OP1,OP2,OP3) \ + { \ + int i; \ + t=(key[n*2] OP1 R)&0xffffffffL; \ + i=key[n*2+1]; \ + t=ROTL(t,i); \ + L^= (((((*(CAST_LONG *)((unsigned char *) \ + CAST_S_table0+((t>>C_2)&C_M)) OP2 \ + *(CAST_LONG *)((unsigned char *) \ + CAST_S_table1+((t<>C_0)&C_M)))&0xffffffffL) OP1 \ + *(CAST_LONG *)((unsigned char *) \ + CAST_S_table3+((t>>C_1)&C_M)))&0xffffffffL; \ + } +#elif defined(CAST_PTR2) +#define E_CAST(n,key,L,R,OP1,OP2,OP3) \ + { \ + int i; \ + CAST_LONG u,v,w; \ + w=(key[n*2] OP1 R)&0xffffffffL; \ + i=key[n*2+1]; \ + w=ROTL(w,i); \ + u=w>>C_2; \ + v=w<>C_0; \ + t=(t OP2 *(CAST_LONG *)((unsigned char *)CAST_S_table1+v))&0xffffffffL;\ + v=w>>C_1; \ + u&=C_M; \ + v&=C_M; \ + t=(t OP3 *(CAST_LONG *)((unsigned char *)CAST_S_table2+u)&0xffffffffL);\ + t=(t OP1 *(CAST_LONG *)((unsigned char *)CAST_S_table3+v)&0xffffffffL);\ + L^=(t&0xffffffff); \ + } +#else +#define E_CAST(n,key,L,R,OP1,OP2,OP3) \ + { \ + CAST_LONG a,b,c,d; \ + t=(key[n*2] OP1 R)&0xffffffff; \ + t=ROTL(t,(key[n*2+1])); \ + a=CAST_S_table0[(t>> 8)&0xff]; \ + b=CAST_S_table1[(t )&0xff]; \ + c=CAST_S_table2[(t>>24)&0xff]; \ + d=CAST_S_table3[(t>>16)&0xff]; \ + L^=(((((a OP2 b)&0xffffffffL) OP3 c)&0xffffffffL) OP1 d)&0xffffffffL; \ + } +#endif + +OPENSSL_EXTERN const CAST_LONG CAST_S_table0[256]; +OPENSSL_EXTERN const CAST_LONG CAST_S_table1[256]; +OPENSSL_EXTERN const CAST_LONG CAST_S_table2[256]; +OPENSSL_EXTERN const CAST_LONG CAST_S_table3[256]; +OPENSSL_EXTERN const CAST_LONG CAST_S_table4[256]; +OPENSSL_EXTERN const CAST_LONG CAST_S_table5[256]; +OPENSSL_EXTERN const CAST_LONG CAST_S_table6[256]; +OPENSSL_EXTERN const CAST_LONG CAST_S_table7[256]; diff --git a/AppleCSP/open_ssl/cast/cast_s.h b/AppleCSP/open_ssl/cast/cast_s.h new file mode 100644 index 00000000..c483fd5e --- /dev/null +++ b/AppleCSP/open_ssl/cast/cast_s.h @@ -0,0 +1,585 @@ +/* crypto/cast/cast_s.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +OPENSSL_GLOBAL const CAST_LONG CAST_S_table0[256]={ + 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a, + 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949, + 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675, + 0x6e63a0e0,0x15c361d2,0xc2e7661d,0x22d4ff8e, + 0x28683b6f,0xc07fd059,0xff2379c8,0x775f50e2, + 0x43c340d3,0xdf2f8656,0x887ca41a,0xa2d2bd2d, + 0xa1c9e0d6,0x346c4819,0x61b76d87,0x22540f2f, + 0x2abe32e1,0xaa54166b,0x22568e3a,0xa2d341d0, + 0x66db40c8,0xa784392f,0x004dff2f,0x2db9d2de, + 0x97943fac,0x4a97c1d8,0x527644b7,0xb5f437a7, + 0xb82cbaef,0xd751d159,0x6ff7f0ed,0x5a097a1f, + 0x827b68d0,0x90ecf52e,0x22b0c054,0xbc8e5935, + 0x4b6d2f7f,0x50bb64a2,0xd2664910,0xbee5812d, + 0xb7332290,0xe93b159f,0xb48ee411,0x4bff345d, + 0xfd45c240,0xad31973f,0xc4f6d02e,0x55fc8165, + 0xd5b1caad,0xa1ac2dae,0xa2d4b76d,0xc19b0c50, + 0x882240f2,0x0c6e4f38,0xa4e4bfd7,0x4f5ba272, + 0x564c1d2f,0xc59c5319,0xb949e354,0xb04669fe, + 0xb1b6ab8a,0xc71358dd,0x6385c545,0x110f935d, + 0x57538ad5,0x6a390493,0xe63d37e0,0x2a54f6b3, + 0x3a787d5f,0x6276a0b5,0x19a6fcdf,0x7a42206a, + 0x29f9d4d5,0xf61b1891,0xbb72275e,0xaa508167, + 0x38901091,0xc6b505eb,0x84c7cb8c,0x2ad75a0f, + 0x874a1427,0xa2d1936b,0x2ad286af,0xaa56d291, + 0xd7894360,0x425c750d,0x93b39e26,0x187184c9, + 0x6c00b32d,0x73e2bb14,0xa0bebc3c,0x54623779, + 0x64459eab,0x3f328b82,0x7718cf82,0x59a2cea6, + 0x04ee002e,0x89fe78e6,0x3fab0950,0x325ff6c2, + 0x81383f05,0x6963c5c8,0x76cb5ad6,0xd49974c9, + 0xca180dcf,0x380782d5,0xc7fa5cf6,0x8ac31511, + 0x35e79e13,0x47da91d0,0xf40f9086,0xa7e2419e, + 0x31366241,0x051ef495,0xaa573b04,0x4a805d8d, + 0x548300d0,0x00322a3c,0xbf64cddf,0xba57a68e, + 0x75c6372b,0x50afd341,0xa7c13275,0x915a0bf5, + 0x6b54bfab,0x2b0b1426,0xab4cc9d7,0x449ccd82, + 0xf7fbf265,0xab85c5f3,0x1b55db94,0xaad4e324, + 0xcfa4bd3f,0x2deaa3e2,0x9e204d02,0xc8bd25ac, + 0xeadf55b3,0xd5bd9e98,0xe31231b2,0x2ad5ad6c, + 0x954329de,0xadbe4528,0xd8710f69,0xaa51c90f, + 0xaa786bf6,0x22513f1e,0xaa51a79b,0x2ad344cc, + 0x7b5a41f0,0xd37cfbad,0x1b069505,0x41ece491, + 0xb4c332e6,0x032268d4,0xc9600acc,0xce387e6d, + 0xbf6bb16c,0x6a70fb78,0x0d03d9c9,0xd4df39de, + 0xe01063da,0x4736f464,0x5ad328d8,0xb347cc96, + 0x75bb0fc3,0x98511bfb,0x4ffbcc35,0xb58bcf6a, + 0xe11f0abc,0xbfc5fe4a,0xa70aec10,0xac39570a, + 0x3f04442f,0x6188b153,0xe0397a2e,0x5727cb79, + 0x9ceb418f,0x1cacd68d,0x2ad37c96,0x0175cb9d, + 0xc69dff09,0xc75b65f0,0xd9db40d8,0xec0e7779, + 0x4744ead4,0xb11c3274,0xdd24cb9e,0x7e1c54bd, + 0xf01144f9,0xd2240eb1,0x9675b3fd,0xa3ac3755, + 0xd47c27af,0x51c85f4d,0x56907596,0xa5bb15e6, + 0x580304f0,0xca042cf1,0x011a37ea,0x8dbfaadb, + 0x35ba3e4a,0x3526ffa0,0xc37b4d09,0xbc306ed9, + 0x98a52666,0x5648f725,0xff5e569d,0x0ced63d0, + 0x7c63b2cf,0x700b45e1,0xd5ea50f1,0x85a92872, + 0xaf1fbda7,0xd4234870,0xa7870bf3,0x2d3b4d79, + 0x42e04198,0x0cd0ede7,0x26470db8,0xf881814c, + 0x474d6ad7,0x7c0c5e5c,0xd1231959,0x381b7298, + 0xf5d2f4db,0xab838653,0x6e2f1e23,0x83719c9e, + 0xbd91e046,0x9a56456e,0xdc39200c,0x20c8c571, + 0x962bda1c,0xe1e696ff,0xb141ab08,0x7cca89b9, + 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d, + 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf, + }; +OPENSSL_GLOBAL const CAST_LONG CAST_S_table1[256]={ + 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380, + 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651, + 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba, + 0x99c430ef,0x5f0c0794,0x18dcdb7d,0xa1d6eff3, + 0xa0b52f7b,0x59e83605,0xee15b094,0xe9ffd909, + 0xdc440086,0xef944459,0xba83ccb3,0xe0c3cdfb, + 0xd1da4181,0x3b092ab1,0xf997f1c1,0xa5e6cf7b, + 0x01420ddb,0xe4e7ef5b,0x25a1ff41,0xe180f806, + 0x1fc41080,0x179bee7a,0xd37ac6a9,0xfe5830a4, + 0x98de8b7f,0x77e83f4e,0x79929269,0x24fa9f7b, + 0xe113c85b,0xacc40083,0xd7503525,0xf7ea615f, + 0x62143154,0x0d554b63,0x5d681121,0xc866c359, + 0x3d63cf73,0xcee234c0,0xd4d87e87,0x5c672b21, + 0x071f6181,0x39f7627f,0x361e3084,0xe4eb573b, + 0x602f64a4,0xd63acd9c,0x1bbc4635,0x9e81032d, + 0x2701f50c,0x99847ab4,0xa0e3df79,0xba6cf38c, + 0x10843094,0x2537a95e,0xf46f6ffe,0xa1ff3b1f, + 0x208cfb6a,0x8f458c74,0xd9e0a227,0x4ec73a34, + 0xfc884f69,0x3e4de8df,0xef0e0088,0x3559648d, + 0x8a45388c,0x1d804366,0x721d9bfd,0xa58684bb, + 0xe8256333,0x844e8212,0x128d8098,0xfed33fb4, + 0xce280ae1,0x27e19ba5,0xd5a6c252,0xe49754bd, + 0xc5d655dd,0xeb667064,0x77840b4d,0xa1b6a801, + 0x84db26a9,0xe0b56714,0x21f043b7,0xe5d05860, + 0x54f03084,0x066ff472,0xa31aa153,0xdadc4755, + 0xb5625dbf,0x68561be6,0x83ca6b94,0x2d6ed23b, + 0xeccf01db,0xa6d3d0ba,0xb6803d5c,0xaf77a709, + 0x33b4a34c,0x397bc8d6,0x5ee22b95,0x5f0e5304, + 0x81ed6f61,0x20e74364,0xb45e1378,0xde18639b, + 0x881ca122,0xb96726d1,0x8049a7e8,0x22b7da7b, + 0x5e552d25,0x5272d237,0x79d2951c,0xc60d894c, + 0x488cb402,0x1ba4fe5b,0xa4b09f6b,0x1ca815cf, + 0xa20c3005,0x8871df63,0xb9de2fcb,0x0cc6c9e9, + 0x0beeff53,0xe3214517,0xb4542835,0x9f63293c, + 0xee41e729,0x6e1d2d7c,0x50045286,0x1e6685f3, + 0xf33401c6,0x30a22c95,0x31a70850,0x60930f13, + 0x73f98417,0xa1269859,0xec645c44,0x52c877a9, + 0xcdff33a6,0xa02b1741,0x7cbad9a2,0x2180036f, + 0x50d99c08,0xcb3f4861,0xc26bd765,0x64a3f6ab, + 0x80342676,0x25a75e7b,0xe4e6d1fc,0x20c710e6, + 0xcdf0b680,0x17844d3b,0x31eef84d,0x7e0824e4, + 0x2ccb49eb,0x846a3bae,0x8ff77888,0xee5d60f6, + 0x7af75673,0x2fdd5cdb,0xa11631c1,0x30f66f43, + 0xb3faec54,0x157fd7fa,0xef8579cc,0xd152de58, + 0xdb2ffd5e,0x8f32ce19,0x306af97a,0x02f03ef8, + 0x99319ad5,0xc242fa0f,0xa7e3ebb0,0xc68e4906, + 0xb8da230c,0x80823028,0xdcdef3c8,0xd35fb171, + 0x088a1bc8,0xbec0c560,0x61a3c9e8,0xbca8f54d, + 0xc72feffa,0x22822e99,0x82c570b4,0xd8d94e89, + 0x8b1c34bc,0x301e16e6,0x273be979,0xb0ffeaa6, + 0x61d9b8c6,0x00b24869,0xb7ffce3f,0x08dc283b, + 0x43daf65a,0xf7e19798,0x7619b72f,0x8f1c9ba4, + 0xdc8637a0,0x16a7d3b1,0x9fc393b7,0xa7136eeb, + 0xc6bcc63e,0x1a513742,0xef6828bc,0x520365d6, + 0x2d6a77ab,0x3527ed4b,0x821fd216,0x095c6e2e, + 0xdb92f2fb,0x5eea29cb,0x145892f5,0x91584f7f, + 0x5483697b,0x2667a8cc,0x85196048,0x8c4bacea, + 0x833860d4,0x0d23e0f9,0x6c387e8a,0x0ae6d249, + 0xb284600c,0xd835731d,0xdcb1c647,0xac4c56ea, + 0x3ebd81b3,0x230eabb0,0x6438bc87,0xf0b5b1fa, + 0x8f5ea2b3,0xfc184642,0x0a036b7a,0x4fb089bd, + 0x649da589,0xa345415e,0x5c038323,0x3e5d3bb9, + 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef, + 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1, + }; +OPENSSL_GLOBAL const CAST_LONG CAST_S_table2[256]={ + 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907, + 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90, + 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae, + 0x920e8806,0xf0ad0548,0xe13c8d83,0x927010d5, + 0x11107d9f,0x07647db9,0xb2e3e4d4,0x3d4f285e, + 0xb9afa820,0xfade82e0,0xa067268b,0x8272792e, + 0x553fb2c0,0x489ae22b,0xd4ef9794,0x125e3fbc, + 0x21fffcee,0x825b1bfd,0x9255c5ed,0x1257a240, + 0x4e1a8302,0xbae07fff,0x528246e7,0x8e57140e, + 0x3373f7bf,0x8c9f8188,0xa6fc4ee8,0xc982b5a5, + 0xa8c01db7,0x579fc264,0x67094f31,0xf2bd3f5f, + 0x40fff7c1,0x1fb78dfc,0x8e6bd2c1,0x437be59b, + 0x99b03dbf,0xb5dbc64b,0x638dc0e6,0x55819d99, + 0xa197c81c,0x4a012d6e,0xc5884a28,0xccc36f71, + 0xb843c213,0x6c0743f1,0x8309893c,0x0feddd5f, + 0x2f7fe850,0xd7c07f7e,0x02507fbf,0x5afb9a04, + 0xa747d2d0,0x1651192e,0xaf70bf3e,0x58c31380, + 0x5f98302e,0x727cc3c4,0x0a0fb402,0x0f7fef82, + 0x8c96fdad,0x5d2c2aae,0x8ee99a49,0x50da88b8, + 0x8427f4a0,0x1eac5790,0x796fb449,0x8252dc15, + 0xefbd7d9b,0xa672597d,0xada840d8,0x45f54504, + 0xfa5d7403,0xe83ec305,0x4f91751a,0x925669c2, + 0x23efe941,0xa903f12e,0x60270df2,0x0276e4b6, + 0x94fd6574,0x927985b2,0x8276dbcb,0x02778176, + 0xf8af918d,0x4e48f79e,0x8f616ddf,0xe29d840e, + 0x842f7d83,0x340ce5c8,0x96bbb682,0x93b4b148, + 0xef303cab,0x984faf28,0x779faf9b,0x92dc560d, + 0x224d1e20,0x8437aa88,0x7d29dc96,0x2756d3dc, + 0x8b907cee,0xb51fd240,0xe7c07ce3,0xe566b4a1, + 0xc3e9615e,0x3cf8209d,0x6094d1e3,0xcd9ca341, + 0x5c76460e,0x00ea983b,0xd4d67881,0xfd47572c, + 0xf76cedd9,0xbda8229c,0x127dadaa,0x438a074e, + 0x1f97c090,0x081bdb8a,0x93a07ebe,0xb938ca15, + 0x97b03cff,0x3dc2c0f8,0x8d1ab2ec,0x64380e51, + 0x68cc7bfb,0xd90f2788,0x12490181,0x5de5ffd4, + 0xdd7ef86a,0x76a2e214,0xb9a40368,0x925d958f, + 0x4b39fffa,0xba39aee9,0xa4ffd30b,0xfaf7933b, + 0x6d498623,0x193cbcfa,0x27627545,0x825cf47a, + 0x61bd8ba0,0xd11e42d1,0xcead04f4,0x127ea392, + 0x10428db7,0x8272a972,0x9270c4a8,0x127de50b, + 0x285ba1c8,0x3c62f44f,0x35c0eaa5,0xe805d231, + 0x428929fb,0xb4fcdf82,0x4fb66a53,0x0e7dc15b, + 0x1f081fab,0x108618ae,0xfcfd086d,0xf9ff2889, + 0x694bcc11,0x236a5cae,0x12deca4d,0x2c3f8cc5, + 0xd2d02dfe,0xf8ef5896,0xe4cf52da,0x95155b67, + 0x494a488c,0xb9b6a80c,0x5c8f82bc,0x89d36b45, + 0x3a609437,0xec00c9a9,0x44715253,0x0a874b49, + 0xd773bc40,0x7c34671c,0x02717ef6,0x4feb5536, + 0xa2d02fff,0xd2bf60c4,0xd43f03c0,0x50b4ef6d, + 0x07478cd1,0x006e1888,0xa2e53f55,0xb9e6d4bc, + 0xa2048016,0x97573833,0xd7207d67,0xde0f8f3d, + 0x72f87b33,0xabcc4f33,0x7688c55d,0x7b00a6b0, + 0x947b0001,0x570075d2,0xf9bb88f8,0x8942019e, + 0x4264a5ff,0x856302e0,0x72dbd92b,0xee971b69, + 0x6ea22fde,0x5f08ae2b,0xaf7a616d,0xe5c98767, + 0xcf1febd2,0x61efc8c2,0xf1ac2571,0xcc8239c2, + 0x67214cb8,0xb1e583d1,0xb7dc3e62,0x7f10bdce, + 0xf90a5c38,0x0ff0443d,0x606e6dc6,0x60543a49, + 0x5727c148,0x2be98a1d,0x8ab41738,0x20e1be24, + 0xaf96da0f,0x68458425,0x99833be5,0x600d457d, + 0x282f9350,0x8334b362,0xd91d1120,0x2b6d8da0, + 0x642b1e31,0x9c305a00,0x52bce688,0x1b03588a, + 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5, + 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783, + }; +OPENSSL_GLOBAL const CAST_LONG CAST_S_table3[256]={ + 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298, + 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1, + 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120, + 0xfd059d43,0x6497b7b1,0xf3641f63,0x241e4adf, + 0x28147f5f,0x4fa2b8cd,0xc9430040,0x0cc32220, + 0xfdd30b30,0xc0a5374f,0x1d2d00d9,0x24147b15, + 0xee4d111a,0x0fca5167,0x71ff904c,0x2d195ffe, + 0x1a05645f,0x0c13fefe,0x081b08ca,0x05170121, + 0x80530100,0xe83e5efe,0xac9af4f8,0x7fe72701, + 0xd2b8ee5f,0x06df4261,0xbb9e9b8a,0x7293ea25, + 0xce84ffdf,0xf5718801,0x3dd64b04,0xa26f263b, + 0x7ed48400,0x547eebe6,0x446d4ca0,0x6cf3d6f5, + 0x2649abdf,0xaea0c7f5,0x36338cc1,0x503f7e93, + 0xd3772061,0x11b638e1,0x72500e03,0xf80eb2bb, + 0xabe0502e,0xec8d77de,0x57971e81,0xe14f6746, + 0xc9335400,0x6920318f,0x081dbb99,0xffc304a5, + 0x4d351805,0x7f3d5ce3,0xa6c866c6,0x5d5bcca9, + 0xdaec6fea,0x9f926f91,0x9f46222f,0x3991467d, + 0xa5bf6d8e,0x1143c44f,0x43958302,0xd0214eeb, + 0x022083b8,0x3fb6180c,0x18f8931e,0x281658e6, + 0x26486e3e,0x8bd78a70,0x7477e4c1,0xb506e07c, + 0xf32d0a25,0x79098b02,0xe4eabb81,0x28123b23, + 0x69dead38,0x1574ca16,0xdf871b62,0x211c40b7, + 0xa51a9ef9,0x0014377b,0x041e8ac8,0x09114003, + 0xbd59e4d2,0xe3d156d5,0x4fe876d5,0x2f91a340, + 0x557be8de,0x00eae4a7,0x0ce5c2ec,0x4db4bba6, + 0xe756bdff,0xdd3369ac,0xec17b035,0x06572327, + 0x99afc8b0,0x56c8c391,0x6b65811c,0x5e146119, + 0x6e85cb75,0xbe07c002,0xc2325577,0x893ff4ec, + 0x5bbfc92d,0xd0ec3b25,0xb7801ab7,0x8d6d3b24, + 0x20c763ef,0xc366a5fc,0x9c382880,0x0ace3205, + 0xaac9548a,0xeca1d7c7,0x041afa32,0x1d16625a, + 0x6701902c,0x9b757a54,0x31d477f7,0x9126b031, + 0x36cc6fdb,0xc70b8b46,0xd9e66a48,0x56e55a79, + 0x026a4ceb,0x52437eff,0x2f8f76b4,0x0df980a5, + 0x8674cde3,0xedda04eb,0x17a9be04,0x2c18f4df, + 0xb7747f9d,0xab2af7b4,0xefc34d20,0x2e096b7c, + 0x1741a254,0xe5b6a035,0x213d42f6,0x2c1c7c26, + 0x61c2f50f,0x6552daf9,0xd2c231f8,0x25130f69, + 0xd8167fa2,0x0418f2c8,0x001a96a6,0x0d1526ab, + 0x63315c21,0x5e0a72ec,0x49bafefd,0x187908d9, + 0x8d0dbd86,0x311170a7,0x3e9b640c,0xcc3e10d7, + 0xd5cad3b6,0x0caec388,0xf73001e1,0x6c728aff, + 0x71eae2a1,0x1f9af36e,0xcfcbd12f,0xc1de8417, + 0xac07be6b,0xcb44a1d8,0x8b9b0f56,0x013988c3, + 0xb1c52fca,0xb4be31cd,0xd8782806,0x12a3a4e2, + 0x6f7de532,0x58fd7eb6,0xd01ee900,0x24adffc2, + 0xf4990fc5,0x9711aac5,0x001d7b95,0x82e5e7d2, + 0x109873f6,0x00613096,0xc32d9521,0xada121ff, + 0x29908415,0x7fbb977f,0xaf9eb3db,0x29c9ed2a, + 0x5ce2a465,0xa730f32c,0xd0aa3fe8,0x8a5cc091, + 0xd49e2ce7,0x0ce454a9,0xd60acd86,0x015f1919, + 0x77079103,0xdea03af6,0x78a8565e,0xdee356df, + 0x21f05cbe,0x8b75e387,0xb3c50651,0xb8a5c3ef, + 0xd8eeb6d2,0xe523be77,0xc2154529,0x2f69efdf, + 0xafe67afb,0xf470c4b2,0xf3e0eb5b,0xd6cc9876, + 0x39e4460c,0x1fda8538,0x1987832f,0xca007367, + 0xa99144f8,0x296b299e,0x492fc295,0x9266beab, + 0xb5676e69,0x9bd3ddda,0xdf7e052f,0xdb25701c, + 0x1b5e51ee,0xf65324e6,0x6afce36c,0x0316cc04, + 0x8644213e,0xb7dc59d0,0x7965291f,0xccd6fd43, + 0x41823979,0x932bcdf6,0xb657c34d,0x4edfd282, + 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e, + 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2, + }; +OPENSSL_GLOBAL const CAST_LONG CAST_S_table4[256]={ + 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911, + 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f, + 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00, + 0x2ab722d8,0x386381cb,0xacf6243a,0x69befd7a, + 0xe6a2e77f,0xf0c720cd,0xc4494816,0xccf5c180, + 0x38851640,0x15b0a848,0xe68b18cb,0x4caadeff, + 0x5f480a01,0x0412b2aa,0x259814fc,0x41d0efe2, + 0x4e40b48d,0x248eb6fb,0x8dba1cfe,0x41a99b02, + 0x1a550a04,0xba8f65cb,0x7251f4e7,0x95a51725, + 0xc106ecd7,0x97a5980a,0xc539b9aa,0x4d79fe6a, + 0xf2f3f763,0x68af8040,0xed0c9e56,0x11b4958b, + 0xe1eb5a88,0x8709e6b0,0xd7e07156,0x4e29fea7, + 0x6366e52d,0x02d1c000,0xc4ac8e05,0x9377f571, + 0x0c05372a,0x578535f2,0x2261be02,0xd642a0c9, + 0xdf13a280,0x74b55bd2,0x682199c0,0xd421e5ec, + 0x53fb3ce8,0xc8adedb3,0x28a87fc9,0x3d959981, + 0x5c1ff900,0xfe38d399,0x0c4eff0b,0x062407ea, + 0xaa2f4fb1,0x4fb96976,0x90c79505,0xb0a8a774, + 0xef55a1ff,0xe59ca2c2,0xa6b62d27,0xe66a4263, + 0xdf65001f,0x0ec50966,0xdfdd55bc,0x29de0655, + 0x911e739a,0x17af8975,0x32c7911c,0x89f89468, + 0x0d01e980,0x524755f4,0x03b63cc9,0x0cc844b2, + 0xbcf3f0aa,0x87ac36e9,0xe53a7426,0x01b3d82b, + 0x1a9e7449,0x64ee2d7e,0xcddbb1da,0x01c94910, + 0xb868bf80,0x0d26f3fd,0x9342ede7,0x04a5c284, + 0x636737b6,0x50f5b616,0xf24766e3,0x8eca36c1, + 0x136e05db,0xfef18391,0xfb887a37,0xd6e7f7d4, + 0xc7fb7dc9,0x3063fcdf,0xb6f589de,0xec2941da, + 0x26e46695,0xb7566419,0xf654efc5,0xd08d58b7, + 0x48925401,0xc1bacb7f,0xe5ff550f,0xb6083049, + 0x5bb5d0e8,0x87d72e5a,0xab6a6ee1,0x223a66ce, + 0xc62bf3cd,0x9e0885f9,0x68cb3e47,0x086c010f, + 0xa21de820,0xd18b69de,0xf3f65777,0xfa02c3f6, + 0x407edac3,0xcbb3d550,0x1793084d,0xb0d70eba, + 0x0ab378d5,0xd951fb0c,0xded7da56,0x4124bbe4, + 0x94ca0b56,0x0f5755d1,0xe0e1e56e,0x6184b5be, + 0x580a249f,0x94f74bc0,0xe327888e,0x9f7b5561, + 0xc3dc0280,0x05687715,0x646c6bd7,0x44904db3, + 0x66b4f0a3,0xc0f1648a,0x697ed5af,0x49e92ff6, + 0x309e374f,0x2cb6356a,0x85808573,0x4991f840, + 0x76f0ae02,0x083be84d,0x28421c9a,0x44489406, + 0x736e4cb8,0xc1092910,0x8bc95fc6,0x7d869cf4, + 0x134f616f,0x2e77118d,0xb31b2be1,0xaa90b472, + 0x3ca5d717,0x7d161bba,0x9cad9010,0xaf462ba2, + 0x9fe459d2,0x45d34559,0xd9f2da13,0xdbc65487, + 0xf3e4f94e,0x176d486f,0x097c13ea,0x631da5c7, + 0x445f7382,0x175683f4,0xcdc66a97,0x70be0288, + 0xb3cdcf72,0x6e5dd2f3,0x20936079,0x459b80a5, + 0xbe60e2db,0xa9c23101,0xeba5315c,0x224e42f2, + 0x1c5c1572,0xf6721b2c,0x1ad2fff3,0x8c25404e, + 0x324ed72f,0x4067b7fd,0x0523138e,0x5ca3bc78, + 0xdc0fd66e,0x75922283,0x784d6b17,0x58ebb16e, + 0x44094f85,0x3f481d87,0xfcfeae7b,0x77b5ff76, + 0x8c2302bf,0xaaf47556,0x5f46b02a,0x2b092801, + 0x3d38f5f7,0x0ca81f36,0x52af4a8a,0x66d5e7c0, + 0xdf3b0874,0x95055110,0x1b5ad7a8,0xf61ed5ad, + 0x6cf6e479,0x20758184,0xd0cefa65,0x88f7be58, + 0x4a046826,0x0ff6f8f3,0xa09c7f70,0x5346aba0, + 0x5ce96c28,0xe176eda3,0x6bac307f,0x376829d2, + 0x85360fa9,0x17e3fe2a,0x24b79767,0xf5a96b20, + 0xd6cd2595,0x68ff1ebf,0x7555442c,0xf19f06be, + 0xf9e0659a,0xeeb9491d,0x34010718,0xbb30cab8, + 0xe822fe15,0x88570983,0x750e6249,0xda627e55, + 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4, + }; +OPENSSL_GLOBAL const CAST_LONG CAST_S_table5[256]={ + 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c, + 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac, + 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9, + 0x1ab6a6b8,0xde5ebe39,0xf38ff732,0x8989b138, + 0x33f14961,0xc01937bd,0xf506c6da,0xe4625e7e, + 0xa308ea99,0x4e23e33c,0x79cbd7cc,0x48a14367, + 0xa3149619,0xfec94bd5,0xa114174a,0xeaa01866, + 0xa084db2d,0x09a8486f,0xa888614a,0x2900af98, + 0x01665991,0xe1992863,0xc8f30c60,0x2e78ef3c, + 0xd0d51932,0xcf0fec14,0xf7ca07d2,0xd0a82072, + 0xfd41197e,0x9305a6b0,0xe86be3da,0x74bed3cd, + 0x372da53c,0x4c7f4448,0xdab5d440,0x6dba0ec3, + 0x083919a7,0x9fbaeed9,0x49dbcfb0,0x4e670c53, + 0x5c3d9c01,0x64bdb941,0x2c0e636a,0xba7dd9cd, + 0xea6f7388,0xe70bc762,0x35f29adb,0x5c4cdd8d, + 0xf0d48d8c,0xb88153e2,0x08a19866,0x1ae2eac8, + 0x284caf89,0xaa928223,0x9334be53,0x3b3a21bf, + 0x16434be3,0x9aea3906,0xefe8c36e,0xf890cdd9, + 0x80226dae,0xc340a4a3,0xdf7e9c09,0xa694a807, + 0x5b7c5ecc,0x221db3a6,0x9a69a02f,0x68818a54, + 0xceb2296f,0x53c0843a,0xfe893655,0x25bfe68a, + 0xb4628abc,0xcf222ebf,0x25ac6f48,0xa9a99387, + 0x53bddb65,0xe76ffbe7,0xe967fd78,0x0ba93563, + 0x8e342bc1,0xe8a11be9,0x4980740d,0xc8087dfc, + 0x8de4bf99,0xa11101a0,0x7fd37975,0xda5a26c0, + 0xe81f994f,0x9528cd89,0xfd339fed,0xb87834bf, + 0x5f04456d,0x22258698,0xc9c4c83b,0x2dc156be, + 0x4f628daa,0x57f55ec5,0xe2220abe,0xd2916ebf, + 0x4ec75b95,0x24f2c3c0,0x42d15d99,0xcd0d7fa0, + 0x7b6e27ff,0xa8dc8af0,0x7345c106,0xf41e232f, + 0x35162386,0xe6ea8926,0x3333b094,0x157ec6f2, + 0x372b74af,0x692573e4,0xe9a9d848,0xf3160289, + 0x3a62ef1d,0xa787e238,0xf3a5f676,0x74364853, + 0x20951063,0x4576698d,0xb6fad407,0x592af950, + 0x36f73523,0x4cfb6e87,0x7da4cec0,0x6c152daa, + 0xcb0396a8,0xc50dfe5d,0xfcd707ab,0x0921c42f, + 0x89dff0bb,0x5fe2be78,0x448f4f33,0x754613c9, + 0x2b05d08d,0x48b9d585,0xdc049441,0xc8098f9b, + 0x7dede786,0xc39a3373,0x42410005,0x6a091751, + 0x0ef3c8a6,0x890072d6,0x28207682,0xa9a9f7be, + 0xbf32679d,0xd45b5b75,0xb353fd00,0xcbb0e358, + 0x830f220a,0x1f8fb214,0xd372cf08,0xcc3c4a13, + 0x8cf63166,0x061c87be,0x88c98f88,0x6062e397, + 0x47cf8e7a,0xb6c85283,0x3cc2acfb,0x3fc06976, + 0x4e8f0252,0x64d8314d,0xda3870e3,0x1e665459, + 0xc10908f0,0x513021a5,0x6c5b68b7,0x822f8aa0, + 0x3007cd3e,0x74719eef,0xdc872681,0x073340d4, + 0x7e432fd9,0x0c5ec241,0x8809286c,0xf592d891, + 0x08a930f6,0x957ef305,0xb7fbffbd,0xc266e96f, + 0x6fe4ac98,0xb173ecc0,0xbc60b42a,0x953498da, + 0xfba1ae12,0x2d4bd736,0x0f25faab,0xa4f3fceb, + 0xe2969123,0x257f0c3d,0x9348af49,0x361400bc, + 0xe8816f4a,0x3814f200,0xa3f94043,0x9c7a54c2, + 0xbc704f57,0xda41e7f9,0xc25ad33a,0x54f4a084, + 0xb17f5505,0x59357cbe,0xedbd15c8,0x7f97c5ab, + 0xba5ac7b5,0xb6f6deaf,0x3a479c3a,0x5302da25, + 0x653d7e6a,0x54268d49,0x51a477ea,0x5017d55b, + 0xd7d25d88,0x44136c76,0x0404a8c8,0xb8e5a121, + 0xb81a928a,0x60ed5869,0x97c55b96,0xeaec991b, + 0x29935913,0x01fdb7f1,0x088e8dfa,0x9ab6f6f5, + 0x3b4cbf9f,0x4a5de3ab,0xe6051d35,0xa0e1d855, + 0xd36b4cf1,0xf544edeb,0xb0e93524,0xbebb8fbd, + 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454, + 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f, + }; +OPENSSL_GLOBAL const CAST_LONG CAST_S_table6[256]={ + 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693, + 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f, + 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82, + 0x2cb2cb11,0xb232e75c,0x4b3695f2,0xb28707de, + 0xa05fbcf6,0xcd4181e9,0xe150210c,0xe24ef1bd, + 0xb168c381,0xfde4e789,0x5c79b0d8,0x1e8bfd43, + 0x4d495001,0x38be4341,0x913cee1d,0x92a79c3f, + 0x089766be,0xbaeeadf4,0x1286becf,0xb6eacb19, + 0x2660c200,0x7565bde4,0x64241f7a,0x8248dca9, + 0xc3b3ad66,0x28136086,0x0bd8dfa8,0x356d1cf2, + 0x107789be,0xb3b2e9ce,0x0502aa8f,0x0bc0351e, + 0x166bf52a,0xeb12ff82,0xe3486911,0xd34d7516, + 0x4e7b3aff,0x5f43671b,0x9cf6e037,0x4981ac83, + 0x334266ce,0x8c9341b7,0xd0d854c0,0xcb3a6c88, + 0x47bc2829,0x4725ba37,0xa66ad22b,0x7ad61f1e, + 0x0c5cbafa,0x4437f107,0xb6e79962,0x42d2d816, + 0x0a961288,0xe1a5c06e,0x13749e67,0x72fc081a, + 0xb1d139f7,0xf9583745,0xcf19df58,0xbec3f756, + 0xc06eba30,0x07211b24,0x45c28829,0xc95e317f, + 0xbc8ec511,0x38bc46e9,0xc6e6fa14,0xbae8584a, + 0xad4ebc46,0x468f508b,0x7829435f,0xf124183b, + 0x821dba9f,0xaff60ff4,0xea2c4e6d,0x16e39264, + 0x92544a8b,0x009b4fc3,0xaba68ced,0x9ac96f78, + 0x06a5b79a,0xb2856e6e,0x1aec3ca9,0xbe838688, + 0x0e0804e9,0x55f1be56,0xe7e5363b,0xb3a1f25d, + 0xf7debb85,0x61fe033c,0x16746233,0x3c034c28, + 0xda6d0c74,0x79aac56c,0x3ce4e1ad,0x51f0c802, + 0x98f8f35a,0x1626a49f,0xeed82b29,0x1d382fe3, + 0x0c4fb99a,0xbb325778,0x3ec6d97b,0x6e77a6a9, + 0xcb658b5c,0xd45230c7,0x2bd1408b,0x60c03eb7, + 0xb9068d78,0xa33754f4,0xf430c87d,0xc8a71302, + 0xb96d8c32,0xebd4e7be,0xbe8b9d2d,0x7979fb06, + 0xe7225308,0x8b75cf77,0x11ef8da4,0xe083c858, + 0x8d6b786f,0x5a6317a6,0xfa5cf7a0,0x5dda0033, + 0xf28ebfb0,0xf5b9c310,0xa0eac280,0x08b9767a, + 0xa3d9d2b0,0x79d34217,0x021a718d,0x9ac6336a, + 0x2711fd60,0x438050e3,0x069908a8,0x3d7fedc4, + 0x826d2bef,0x4eeb8476,0x488dcf25,0x36c9d566, + 0x28e74e41,0xc2610aca,0x3d49a9cf,0xbae3b9df, + 0xb65f8de6,0x92aeaf64,0x3ac7d5e6,0x9ea80509, + 0xf22b017d,0xa4173f70,0xdd1e16c3,0x15e0d7f9, + 0x50b1b887,0x2b9f4fd5,0x625aba82,0x6a017962, + 0x2ec01b9c,0x15488aa9,0xd716e740,0x40055a2c, + 0x93d29a22,0xe32dbf9a,0x058745b9,0x3453dc1e, + 0xd699296e,0x496cff6f,0x1c9f4986,0xdfe2ed07, + 0xb87242d1,0x19de7eae,0x053e561a,0x15ad6f8c, + 0x66626c1c,0x7154c24c,0xea082b2a,0x93eb2939, + 0x17dcb0f0,0x58d4f2ae,0x9ea294fb,0x52cf564c, + 0x9883fe66,0x2ec40581,0x763953c3,0x01d6692e, + 0xd3a0c108,0xa1e7160e,0xe4f2dfa6,0x693ed285, + 0x74904698,0x4c2b0edd,0x4f757656,0x5d393378, + 0xa132234f,0x3d321c5d,0xc3f5e194,0x4b269301, + 0xc79f022f,0x3c997e7e,0x5e4f9504,0x3ffafbbd, + 0x76f7ad0e,0x296693f4,0x3d1fce6f,0xc61e45be, + 0xd3b5ab34,0xf72bf9b7,0x1b0434c0,0x4e72b567, + 0x5592a33d,0xb5229301,0xcfd2a87f,0x60aeb767, + 0x1814386b,0x30bcc33d,0x38a0c07d,0xfd1606f2, + 0xc363519b,0x589dd390,0x5479f8e6,0x1cb8d647, + 0x97fd61a9,0xea7759f4,0x2d57539d,0x569a58cf, + 0xe84e63ad,0x462e1b78,0x6580f87e,0xf3817914, + 0x91da55f4,0x40a230f3,0xd1988f35,0xb6e318d2, + 0x3ffa50bc,0x3d40f021,0xc3c0bdae,0x4958c24c, + 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada, + 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3, + }; +OPENSSL_GLOBAL const CAST_LONG CAST_S_table7[256]={ + 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095, + 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5, + 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174, + 0x2a42931c,0x76e38111,0xb12def3a,0x37ddddfc, + 0xde9adeb1,0x0a0cc32c,0xbe197029,0x84a00940, + 0xbb243a0f,0xb4d137cf,0xb44e79f0,0x049eedfd, + 0x0b15a15d,0x480d3168,0x8bbbde5a,0x669ded42, + 0xc7ece831,0x3f8f95e7,0x72df191b,0x7580330d, + 0x94074251,0x5c7dcdfa,0xabbe6d63,0xaa402164, + 0xb301d40a,0x02e7d1ca,0x53571dae,0x7a3182a2, + 0x12a8ddec,0xfdaa335d,0x176f43e8,0x71fb46d4, + 0x38129022,0xce949ad4,0xb84769ad,0x965bd862, + 0x82f3d055,0x66fb9767,0x15b80b4e,0x1d5b47a0, + 0x4cfde06f,0xc28ec4b8,0x57e8726e,0x647a78fc, + 0x99865d44,0x608bd593,0x6c200e03,0x39dc5ff6, + 0x5d0b00a3,0xae63aff2,0x7e8bd632,0x70108c0c, + 0xbbd35049,0x2998df04,0x980cf42a,0x9b6df491, + 0x9e7edd53,0x06918548,0x58cb7e07,0x3b74ef2e, + 0x522fffb1,0xd24708cc,0x1c7e27cd,0xa4eb215b, + 0x3cf1d2e2,0x19b47a38,0x424f7618,0x35856039, + 0x9d17dee7,0x27eb35e6,0xc9aff67b,0x36baf5b8, + 0x09c467cd,0xc18910b1,0xe11dbf7b,0x06cd1af8, + 0x7170c608,0x2d5e3354,0xd4de495a,0x64c6d006, + 0xbcc0c62c,0x3dd00db3,0x708f8f34,0x77d51b42, + 0x264f620f,0x24b8d2bf,0x15c1b79e,0x46a52564, + 0xf8d7e54e,0x3e378160,0x7895cda5,0x859c15a5, + 0xe6459788,0xc37bc75f,0xdb07ba0c,0x0676a3ab, + 0x7f229b1e,0x31842e7b,0x24259fd7,0xf8bef472, + 0x835ffcb8,0x6df4c1f2,0x96f5b195,0xfd0af0fc, + 0xb0fe134c,0xe2506d3d,0x4f9b12ea,0xf215f225, + 0xa223736f,0x9fb4c428,0x25d04979,0x34c713f8, + 0xc4618187,0xea7a6e98,0x7cd16efc,0x1436876c, + 0xf1544107,0xbedeee14,0x56e9af27,0xa04aa441, + 0x3cf7c899,0x92ecbae6,0xdd67016d,0x151682eb, + 0xa842eedf,0xfdba60b4,0xf1907b75,0x20e3030f, + 0x24d8c29e,0xe139673b,0xefa63fb8,0x71873054, + 0xb6f2cf3b,0x9f326442,0xcb15a4cc,0xb01a4504, + 0xf1e47d8d,0x844a1be5,0xbae7dfdc,0x42cbda70, + 0xcd7dae0a,0x57e85b7a,0xd53f5af6,0x20cf4d8c, + 0xcea4d428,0x79d130a4,0x3486ebfb,0x33d3cddc, + 0x77853b53,0x37effcb5,0xc5068778,0xe580b3e6, + 0x4e68b8f4,0xc5c8b37e,0x0d809ea2,0x398feb7c, + 0x132a4f94,0x43b7950e,0x2fee7d1c,0x223613bd, + 0xdd06caa2,0x37df932b,0xc4248289,0xacf3ebc3, + 0x5715f6b7,0xef3478dd,0xf267616f,0xc148cbe4, + 0x9052815e,0x5e410fab,0xb48a2465,0x2eda7fa4, + 0xe87b40e4,0xe98ea084,0x5889e9e1,0xefd390fc, + 0xdd07d35b,0xdb485694,0x38d7e5b2,0x57720101, + 0x730edebc,0x5b643113,0x94917e4f,0x503c2fba, + 0x646f1282,0x7523d24a,0xe0779695,0xf9c17a8f, + 0x7a5b2121,0xd187b896,0x29263a4d,0xba510cdf, + 0x81f47c9f,0xad1163ed,0xea7b5965,0x1a00726e, + 0x11403092,0x00da6d77,0x4a0cdd61,0xad1f4603, + 0x605bdfb0,0x9eedc364,0x22ebe6a8,0xcee7d28a, + 0xa0e736a0,0x5564a6b9,0x10853209,0xc7eb8f37, + 0x2de705ca,0x8951570f,0xdf09822b,0xbd691a6c, + 0xaa12e4f2,0x87451c0f,0xe0f6a27a,0x3ada4819, + 0x4cf1764f,0x0d771c2b,0x67cdb156,0x350d8384, + 0x5938fa0f,0x42399ef3,0x36997b07,0x0e84093d, + 0x4aa93e61,0x8360d87b,0x1fa98b0c,0x1149382c, + 0xe97625a5,0x0614d1b7,0x0e25244b,0x0c768347, + 0x589e8d82,0x0d2059d1,0xa466bb1e,0xf8da0a82, + 0x04f19130,0xba6e4ec0,0x99265164,0x1ee7230d, + 0x50b2ad80,0xeaee6801,0x8db2a283,0xea8bf59e, + }; diff --git a/AppleCSP/open_ssl/openssl/blowfish.h b/AppleCSP/open_ssl/openssl/blowfish.h new file mode 100644 index 00000000..648a7ce7 --- /dev/null +++ b/AppleCSP/open_ssl/openssl/blowfish.h @@ -0,0 +1,129 @@ +/* crypto/bf/blowfish.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BLOWFISH_H +#define HEADER_BLOWFISH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NO_BF +#error BF is disabled. +#endif + +#define BF_ENCRYPT 1 +#define BF_DECRYPT 0 + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! BF_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(WIN16) || defined(__LP32__) || \ + ((defined(__ppc__) || defined(__i386__)) && defined(__APPLE__)) +#define BF_LONG unsigned long +#elif defined(_CRAY) || defined(__ILP64__) +#define BF_LONG unsigned long +#define BF_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#warning BF_LONG really should be explicitly defined\ +#define BF_LONG unsigned int +#endif + +#define BF_ROUNDS 16 +#define BF_BLOCK 8 /* block size in bytes */ +#define BF_MIN_KEY_SIZE_BYTES (32 / 8) +#define BF_MAX_KEY_SIZE_BYTES (448 / 8) /* 56 */ + +typedef struct bf_key_st + { + BF_LONG P[BF_ROUNDS+2]; + BF_LONG S[4*256]; + } BF_KEY; + + +void BF_set_key(BF_KEY *key, int len, const unsigned char *data); + +void BF_encrypt(BF_LONG *data,const BF_KEY *key); +void BF_decrypt(BF_LONG *data,const BF_KEY *key); + +void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, + const BF_KEY *key, int enc); +void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int enc); +void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); +void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num); +const char *BF_options(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/AppleCSP/open_ssl/openssl/cast.h b/AppleCSP/open_ssl/openssl/cast.h new file mode 100644 index 00000000..2c9d0019 --- /dev/null +++ b/AppleCSP/open_ssl/openssl/cast.h @@ -0,0 +1,103 @@ +/* crypto/cast/cast.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CAST_H +#define HEADER_CAST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NO_CAST +#error CAST is disabled. +#endif + +#define CAST_ENCRYPT 1 +#define CAST_DECRYPT 0 + +#define CAST_LONG unsigned long + +#define CAST_BLOCK 8 /* block size in bytes */ +#define CAST_KEY_LENGTH 16 /* MAX key size in bytes */ +#define CAST_MIN_KEY_LENGTH 5 /* MIN key size in bytes */ +typedef struct cast_key_st + { + CAST_LONG data[32]; + int short_key; /* Use reduced rounds for short key */ + } CAST_KEY; + + +void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); +void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key, + int enc); +void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_decrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + CAST_KEY *ks, unsigned char *iv, int enc); +void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/AppleCSP/open_ssl/openssl/opensslconf.h b/AppleCSP/open_ssl/openssl/opensslconf.h index bb00c6ad..4de0f709 100644 --- a/AppleCSP/open_ssl/openssl/opensslconf.h +++ b/AppleCSP/open_ssl/openssl/opensslconf.h @@ -54,8 +54,6 @@ extern "C" { #define NO_MD5 1 #define NO_RIPEMD 1 #define NO_DES 1 -#define NO_BF 1 -#define NO_CAST 1 #define NO_IDEA 1 #define NO_MDC2 1 @@ -77,9 +75,13 @@ typedef uint32 RC4_INT; #undef RC4_INDEX typedef uint32 RC5_32_INT; - typedef uint32 MD2_INT; +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#define BF_PTR +#endif /* HEADER_BF_LOCL_H */ + /* * FIXME - this could certainly use some tweaking */ diff --git a/AppleCSP/open_ssl/opensslUtils/openRsaSnacc.cpp b/AppleCSP/open_ssl/opensslUtils/openRsaSnacc.cpp deleted file mode 100644 index 08108b26..00000000 --- a/AppleCSP/open_ssl/opensslUtils/openRsaSnacc.cpp +++ /dev/null @@ -1,755 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * openRsaSnacc.cpp - glue between openrsa and SNACC - */ -#include "openRsaSnacc.h" -#include "opensslUtils.h" -#include -#include -#include - -// bring in a ton of snacc-related stuff -#include -#include - -// snacc-generated - snacc really should place these in pkcs[78].h -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -#define sslSnaccDebug(args...) debug("sslSnacc", ##args) - -/* - * Convert between SNACC-style BigIntegerStr and openssl-style BIGNUM. - */ -BIGNUM *bigIntStrToBn( - BigIntegerStr &snaccInt) -{ - BIGNUM *bn = BN_new(); - BIGNUM *rtn; - char *rawOcts = snaccInt; - unsigned numBytes = snaccInt.Len(); - - rtn = BN_bin2bn((unsigned char *)rawOcts, numBytes, bn); - if(rtn == NULL) { - BN_free(bn); - CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); - } - return bn; -} - -void bnToBigIntStr( - BIGNUM *bn, - BigIntegerStr &snaccInt) -{ - unsigned numBytes = BN_num_bytes(bn); - unsigned char *buf; - unsigned char *bp; - - /* - * BSAFE is peculiar here. When IT DER-encodes public keys, it often generates - * a publicExponent whose leading bit (m.s. bit in the first byte) is 1. It - * reads these fine, of course. But when it DER-encodes the same value in the - * private key, it hews to DER rules and prepends a leading zero. If WE - * generate a private key with a field with a leading bit set, without the - * (technically) required leading zero, BSAFE pukes....but only when parsing - * private keys, not public keys. Same field (public exponent), different - * requirements for public and private keys. So we're cautious and prepend - * a zero if the leading field is one. - * - * This assumes of course that ALL numbers we're dealing with are positive.... - */ - buf = (unsigned char *)Malloc(numBytes + 1); // extra for possible prepend - if(buf == NULL) { - throw openSslException(CSSMERR_CSP_MEMORY_ERROR); - } - BN_bn2bin(bn, buf + 1); - if(buf[1] & 0x80) { - /* pedantic DER rules for BSAFE - make sure first byte is zero */ - buf[0] = 0; - bp = buf; - numBytes++; - } - else { - /* use what BN_bn2bin gave us */ - bp = buf+1; - } - snaccInt.ReSet((char *)bp, numBytes); - Free(buf); -} - -/* estimate size of encoded BigIntegerStr */ -unsigned sizeofBigInt( - BigIntegerStr &bigInt) -{ - return bigInt.Len() + 4; -} - -/* set up a encoded NULL for AlgorithmIdentifier.parameters, required for RSA */ -static void nullAlgParams( - AlgorithmIdentifier &snaccAlgId) -{ - snaccAlgId.parameters = new AsnAny; - char encodedNull[2] = {NULLTYPE_TAG_CODE, 0}; - CSM_Buffer *cbuf = new CSM_Buffer(encodedNull, 2); - snaccAlgId.parameters->value = cbuf; -} - -/* - * int --> BigIntegerStr - */ -void snaccIntToBigIntegerStr( - int i, - BigIntegerStr &bigInt) -{ - char c[4]; - int dex; - int numChars; - - if(i >= 0x1000000) { - numChars = 4; - } - else if(i > 0x10000) { - numChars = 3; - } - else if(i > 0x100) { - numChars = 2; - } - else { - numChars = 1; - } - /* i ==> DER */ - for(dex=numChars-1; dex>=0; dex--) { - c[dex] = i & 0xff; - i >>= 8; - } - - bigInt.ReSet(c, 4); -} - -/* - * Replacements for d2i_RSAPublicKey, etc. - */ -CSSM_RETURN RSAPublicKeyDecode( - RSA *openKey, - void *p, - size_t length) -{ - RSAPublicKey snaccPubKey; - - CssmData cData(p, length); - try { - SC_decodeAsnObj(cData, snaccPubKey); - } - catch(...) { - return CSSMERR_CSP_INVALID_KEY; - } - try { - openKey->n = bigIntStrToBn(snaccPubKey.modulus); - openKey->e = bigIntStrToBn(snaccPubKey.publicExponent); - } - catch(...) { - /* FIXME - bad sig? memory? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - -CSSM_RETURN RSAPublicKeyEncode( - RSA *openKey, - CssmOwnedData &encodedKey) -{ - /* First convert into a snacc-style public key */ - RSAPublicKey snaccPubKey; - - try { - bnToBigIntStr(openKey->n, snaccPubKey.modulus); - bnToBigIntStr(openKey->e, snaccPubKey.publicExponent); - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - - /* conservative guess for max size of encoded key */ - unsigned maxSize = sizeofBigInt(snaccPubKey.modulus) + - sizeofBigInt(snaccPubKey.publicExponent) + - 20; - - /* DER encode */ - try { - SC_encodeAsnObj(snaccPubKey, encodedKey, maxSize); - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - -CSSM_RETURN RSAPrivateKeyDecode( - RSA *openKey, - void *p, - size_t length) -{ - PrivateKeyInfo snaccPrivKeyInfo; - CssmData cData(p, length); - try { - SC_decodeAsnObj(cData, snaccPrivKeyInfo); - } - catch(...) { - return CSSMERR_CSP_INVALID_KEY; - } - - /* verify alg identifier */ - if(snaccPrivKeyInfo.privateKeyAlgorithm == NULL) { - sslSnaccDebug("RSAPrivateKeyDecode: no privateKeyAlgorithm"); - return CSSMERR_CSP_INVALID_KEY; - } - if(snaccPrivKeyInfo.privateKeyAlgorithm->algorithm != rsaEncryption) { - sslSnaccDebug("RSAPrivateKeyDecode: bad privateKeyAlgorithm"); - return CSSMERR_CSP_ALGID_MISMATCH; - } - - /* - * snaccPrivKeyInfo.privateKey is an octet string which needs - * subsequent decoding - */ - char *rawOcts = snaccPrivKeyInfo.privateKey; - unsigned numBytes = snaccPrivKeyInfo.privateKey.Len(); - RSAPrivateKey snaccPrivKey; - CssmData cData2(rawOcts, numBytes); - try { - SC_decodeAsnObj(cData2, snaccPrivKey); - } - catch(...) { - sslSnaccDebug("RSAPrivateKeyDecode: bad snaccPrivKeyInfo.privateKey"); - return CSSMERR_CSP_INVALID_KEY; - } - - /* convert snaccPrivKey fields to RSA key fields */ - try { - openKey->version = snaccPrivKey.version; - openKey->n = bigIntStrToBn(snaccPrivKey.modulus); - openKey->e = bigIntStrToBn(snaccPrivKey.publicExponent); - openKey->d = bigIntStrToBn(snaccPrivKey.privateExponent); - openKey->p = bigIntStrToBn(snaccPrivKey.prime1); - openKey->q = bigIntStrToBn(snaccPrivKey.prime2); - openKey->dmp1 = bigIntStrToBn(snaccPrivKey.exponent1); - openKey->dmq1 = bigIntStrToBn(snaccPrivKey.exponent2); - openKey->iqmp = bigIntStrToBn(snaccPrivKey.coefficient); - } - catch(...) { - /* FIXME - bad sig? memory? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - -CSSM_RETURN RSAPrivateKeyEncode( - RSA *openKey, - CssmOwnedData &encodedKey) -{ - /* First convert into a snacc-style private key */ - RSAPrivateKey snaccPrivKey; - - try { - snaccPrivKey.version = openKey->version; - bnToBigIntStr(openKey->n, snaccPrivKey.modulus); - bnToBigIntStr(openKey->e, snaccPrivKey.publicExponent); - bnToBigIntStr(openKey->d, snaccPrivKey.privateExponent); - bnToBigIntStr(openKey->p, snaccPrivKey.prime1); - bnToBigIntStr(openKey->q, snaccPrivKey.prime2); - bnToBigIntStr(openKey->dmp1, snaccPrivKey.exponent1); - bnToBigIntStr(openKey->dmq1, snaccPrivKey.exponent2); - bnToBigIntStr(openKey->iqmp, snaccPrivKey.coefficient); - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - - /* conservative guess for max size of encoded key */ - unsigned maxSize = sizeofBigInt(snaccPrivKey.modulus) + - sizeofBigInt(snaccPrivKey.publicExponent) + - sizeofBigInt(snaccPrivKey.privateExponent) + - sizeofBigInt(snaccPrivKey.prime1) + - sizeofBigInt(snaccPrivKey.prime2) + - sizeofBigInt(snaccPrivKey.exponent1) + - sizeofBigInt(snaccPrivKey.exponent2) + - sizeofBigInt(snaccPrivKey.coefficient) + - 64; // includes the to-be-generated algId - - /* DER encode */ - try { - SC_encodeAsnObj(snaccPrivKey, encodedKey, maxSize); - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - - /* that encoding is the privateKey field of a PrivateKeyInfo */ - PrivateKeyInfo snaccPrivKeyInfo; - snaccPrivKeyInfo.version = 0; /* I think.... */ - snaccPrivKeyInfo.privateKeyAlgorithm = new AlgorithmIdentifier; - snaccPrivKeyInfo.privateKeyAlgorithm->algorithm = rsaEncryption; - nullAlgParams(*snaccPrivKeyInfo.privateKeyAlgorithm); - snaccPrivKeyInfo.privateKey.Set((char *)encodedKey.data(), encodedKey.length()); - - /* now encode the privateKeyInfo */ - encodedKey.reset(); - try { - SC_encodeAsnObj(snaccPrivKeyInfo, encodedKey, maxSize); - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - -/* - * Given a message digest and associated algorithm, cook up a PKCS1-style - * DigestInfo and return its DER encoding. This is a necessary step for - * RSA signature (both generating and verifying) - the output of this - * routine is what gets encrypted during signing, and what is expected when - * verifying (i.e., decrypting the signature). - * - * A good guess for the length of the output digestInfo is the size of the - * key being used to sign/verify. The digest can never be larger than that. - */ -CSSM_RETURN generateDigestInfo( - const void *msgDigest, - size_t digestLen, - CSSM_ALGORITHMS digestAlg, // CSSM_ALGID_SHA1, etc. - CssmOwnedData &encodedInfo, - size_t maxEncodedSize) -{ - if(digestAlg == CSSM_ALGID_NONE) { - /* special case, no encode, just copy */ - encodedInfo.copy(msgDigest, digestLen); - return 0; - } - - DigestInfo info; - info.digest.Set((char *)msgDigest, digestLen); - info.digestAlgorithm = new DigestAlgorithmIdentifier; - - switch(digestAlg) { - case CSSM_ALGID_MD5: - info.digestAlgorithm->algorithm = md5; - break; - case CSSM_ALGID_MD2: - info.digestAlgorithm->algorithm = md2; - break; - case CSSM_ALGID_SHA1: - info.digestAlgorithm->algorithm = sha_1; - break; - default: - return CSSMERR_CSP_INVALID_ALGORITHM; - } - nullAlgParams(*info.digestAlgorithm); - try { - SC_encodeAsnObj(info, encodedInfo, maxEncodedSize); - } - catch(...) { - /* FIXME - bad sig? memory? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - -unsigned sizeofAsnBits( - AsnBits &bits) -{ - return (bits.BitLen() * 8) + 4; -} - -unsigned sizeofAsnOcts( - AsnOcts &octs) -{ - return octs.Len() + 4; -} - - -/*** - *** DSA - ***/ - -/* SNACC DSAAlgorithmId <--> DSA->{p,g,q} */ -static DSAAlgorithmId *dsaToSnaccAlgId( - const DSA *openKey) -{ - try { - DSAAlgorithmId *algId = new DSAAlgorithmId; - - algId->algorithm = dsa_bsafe; - algId->params = new DSABsafeParams; - algId->params->keySizeInBits = BN_num_bits(openKey->p); - bnToBigIntStr(openKey->p, algId->params->p); - bnToBigIntStr(openKey->q, algId->params->q); - bnToBigIntStr(openKey->g, algId->params->g); - return algId; - } - catch(...) { - return NULL; - } -} - -static CSSM_RETURN snaccAlgIdToDsa( - DSAAlgorithmId &algId, - DSA *openKey) -{ - if(algId.algorithm != dsa_bsafe) { - sslSnaccDebug("snaccAlgIdToDsa: bad algorithm"); - return CSSMERR_CSP_ALGID_MISMATCH; - } - if(algId.params == NULL) { - sslSnaccDebug("snaccAlgIdToDsa: bad params"); - return CSSMERR_CSP_INVALID_KEY; - } - openKey->p = bigIntStrToBn(algId.params->p); - openKey->q = bigIntStrToBn(algId.params->q); - openKey->g = bigIntStrToBn(algId.params->g); - return 0; -} - -static unsigned sizeOfDsaAlg( - const DSAAlgorithmId &algId) -{ - return sizeofBigInt(algId.params->p) + - sizeofBigInt(algId.params->g) + - sizeofBigInt(algId.params->q) + - 30; -} - -CSSM_RETURN DSAPublicKeyDecode( - DSA *openKey, - unsigned char *p, - unsigned length) -{ - DSAPublicKey snaccPubKey; - CSSM_RETURN rtn; - - CssmData cData(p, length); - try { - SC_decodeAsnObj(cData, snaccPubKey); - rtn = snaccAlgIdToDsa(*snaccPubKey.dsaAlg, openKey); - if(rtn) { - return rtn; - } - - /* inside of snaccPubKey.publicKey is the DER-encoding of a BigIntegerStr */ - char *keyOcts = (char *)snaccPubKey.publicKey.BitOcts(); - CssmData kData(keyOcts, (snaccPubKey.publicKey.BitLen() + 7) / 8); - BigIntegerStr pubKeyOcts; - SC_decodeAsnObj(kData, pubKeyOcts); - openKey->pub_key = bigIntStrToBn(pubKeyOcts); - - if(openKey->pub_key == NULL) { - return CSSMERR_CSP_INVALID_KEY; - } - return 0; - } - catch(...) { - return CSSMERR_CSP_INVALID_KEY; - } -} - -CSSM_RETURN DSAPublicKeyEncode( - DSA *openKey, - CssmOwnedData &encodedKey) -{ - try { - /* First convert into a snacc-style public key */ - DSAPublicKey snaccPubKey; - - snaccPubKey.dsaAlg = dsaToSnaccAlgId(openKey); - if(snaccPubKey.dsaAlg == NULL) { - return CSSMERR_CSP_MEMORY_ERROR; - } - - /* - * publicKey is the DER-encoding of a BigIntegerStr wrapped in - * an AsnBits - */ - BigIntegerStr pubKeyInt; - bnToBigIntStr(openKey->pub_key, pubKeyInt); - unsigned maxSize = sizeofBigInt(pubKeyInt); - SC_encodeAsnObj(pubKeyInt, encodedKey, maxSize); - - /* that encoding goes into DSAPublicKey.publicKey */ - snaccPubKey.publicKey.Set((char *)encodedKey.data(), encodedKey.length() * 8); - - /* conservative guess for max size of encoded key */ - maxSize = sizeOfDsaAlg(*snaccPubKey.dsaAlg) + - sizeofAsnBits(snaccPubKey.publicKey) + - 20; - - /* DER encode */ - encodedKey.reset(); - SC_encodeAsnObj(snaccPubKey, encodedKey, maxSize); - return 0; - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } -} - -CSSM_RETURN DSAPrivateKeyDecode( - DSA *openKey, - unsigned char *p, - unsigned length) -{ - DSAPrivateKey snaccPrivKey; - int rtn; - - CssmData cData(p, length); - try { - SC_decodeAsnObj(cData, snaccPrivKey); - openKey->version = snaccPrivKey.version; - - rtn = snaccAlgIdToDsa(*snaccPrivKey.dsaAlg, openKey); - if(rtn) { - return rtn; - } - - /* snaccPrivKey.privateKey is the DER-encoding of a DSAPrivateKeyOcts... */ - char *keyOcts = snaccPrivKey.privateKey; - CssmData kData(keyOcts, snaccPrivKey.privateKey.Len()); - DSAPrivateKeyOcts privKeyOcts; - SC_decodeAsnObj(kData, privKeyOcts); - - openKey->priv_key = bigIntStrToBn(privKeyOcts.privateKey); - if(openKey->priv_key == NULL) { - return CSSMERR_CSP_INVALID_KEY; - } - return 0; - } - catch(...) { - return CSSMERR_CSP_INVALID_KEY; - } -} - -CSSM_RETURN DSAPrivateKeyEncode( - DSA *openKey, - CssmOwnedData &encodedKey) -{ - try { - /* First convert into a snacc-style private key */ - DSAPrivateKey snaccPrivKey; - - snaccPrivKey.version = openKey->version; - snaccPrivKey.dsaAlg = dsaToSnaccAlgId(openKey); - if(snaccPrivKey.dsaAlg == NULL) { - return CSSMERR_CSP_MEMORY_ERROR; - } - - /* DSAPrivateKey.privateKey is the DER-encoding of one of these... */ - DSAPrivateKeyOcts privKeyOcts; - bnToBigIntStr(openKey->priv_key, privKeyOcts.privateKey); - - /* conservative guess for max size of encoded privKey bits */ - unsigned maxSize = sizeofBigInt(privKeyOcts.privateKey) + - 10; // includes the to-be-generated algId - - /* DER encode */ - SC_encodeAsnObj(privKeyOcts, encodedKey, maxSize); - - /* that encoding goes into DSAPrivateKey.privateKey */ - snaccPrivKey.privateKey.Set((char *)encodedKey.data(), encodedKey.length()); - - /* conservative guess for max size of the whole thing */ - maxSize = maxSize + // what we just did - sizeOfDsaAlg(*snaccPrivKey.dsaAlg) + - 40; - - /* DER encode */ - encodedKey.reset(); - SC_encodeAsnObj(snaccPrivKey, encodedKey, maxSize); - return 0; - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } -} - -CSSM_RETURN DSASigEncode( - DSA_SIG *openSig, - CssmOwnedData &encodedSig) -{ - /* First convert into a snacc-style sig */ - DSASignature snaccSig; - - try { - bnToBigIntStr(openSig->r, snaccSig.r); - bnToBigIntStr(openSig->s, snaccSig.s); - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - - /* conservative guess for max size of encoded key */ - unsigned maxSize = sizeofBigInt(snaccSig.r) + - sizeofBigInt(snaccSig.s) + - 10; - - /* DER encode */ - try { - SC_encodeAsnObj(snaccSig, encodedSig, maxSize); - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - -CSSM_RETURN DSASigDecode( - DSA_SIG *openSig, - const void *p, - unsigned length) -{ - DSASignature snaccSig; - - CssmData cData((char *)p, length); - try { - SC_decodeAsnObj(cData, snaccSig); - } - catch(...) { - return CSSMERR_CSP_INVALID_SIGNATURE; - } - try { - openSig->r = bigIntStrToBn(snaccSig.r); - openSig->s = bigIntStrToBn(snaccSig.s); - } - catch(...) { - /* FIXME - bad sig? memory? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - -CSSM_RETURN DHPrivateKeyDecode( - DH *openKey, - unsigned char *p, - unsigned length) -{ - DHPrivateKey snaccPrivKey; - CssmData cData(p, length); - try { - SC_decodeAsnObj(cData, snaccPrivKey); - } - catch(...) { - return CSSMERR_CSP_INVALID_KEY; - } - - /* verify alg identifier */ - if(snaccPrivKey.dHOid != dhKeyAgreement) { - sslSnaccDebug("DHPrivateKeyDecode: bad privateKeyAlgorithm"); - return CSSMERR_CSP_ALGID_MISMATCH; - } - - DHParameter *params = snaccPrivKey.params; - if(params == NULL) { - /* not optional */ - sslSnaccDebug("DHPrivateKeyDecode: missing key params"); - return CSSMERR_CSP_INVALID_KEY; - } - - /* convert snaccPrivKey fields to DH key fields */ - try { - openKey->priv_key = bigIntStrToBn(snaccPrivKey.secretPart); - openKey->p = bigIntStrToBn(params->prime); - openKey->g = bigIntStrToBn(params->base); - /* TBD - ignore privateValueLength for now */ - } - catch(...) { - /* FIXME - bad sig? memory? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - -CSSM_RETURN DHPrivateKeyEncode( - DH *openKey, - CssmOwnedData &encodedKey) -{ - /* First convert into a snacc-style private key */ - DHPrivateKey snaccPrivKey; - snaccPrivKey.params = new DHParameter; - DHParameter *params = snaccPrivKey.params; - - try { - snaccPrivKey.dHOid.Set(dhKeyAgreement_arc); - bnToBigIntStr(openKey->priv_key, snaccPrivKey.secretPart); - bnToBigIntStr(openKey->p, params->prime); - bnToBigIntStr(openKey->g, params->base); - if(openKey->length) { - /* actually currently not supported */ - params->privateValueLength = new BigIntegerStr(); - snaccIntToBigIntegerStr(openKey->length, *params->privateValueLength); - } - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - - /* conservative guess for max size of encoded key */ - unsigned maxSize = sizeofBigInt(snaccPrivKey.secretPart) + - sizeofBigInt(params->prime) + - sizeofBigInt(params->base) + - 60; // includes dHOid, tags, lenghts - if(openKey->length) { - maxSize += sizeofBigInt(*params->privateValueLength); - } - - /* DER encode */ - try { - SC_encodeAsnObj(snaccPrivKey, encodedKey, maxSize); - } - catch(...) { - /* ? */ - return CSSMERR_CSP_MEMORY_ERROR; - } - return 0; -} - diff --git a/AppleCSP/open_ssl/opensslUtils/openRsaSnacc.h b/AppleCSP/open_ssl/opensslUtils/openRsaSnacc.h deleted file mode 100644 index e524ce7e..00000000 --- a/AppleCSP/open_ssl/opensslUtils/openRsaSnacc.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * openRsaSnacc.h - glue between openrsa and SNACC - */ - -#ifndef _OPEN_RSA_SNACC_H_ -#define _OPEN_RSA_SNACC_H_ - - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Convert between SNACC-style BigIntegerStr and openssl-style BIGNUM. - */ -BIGNUM *bigIntStrToBn( - BigIntegerStr &snaccInt); -void bnToBigIntStr( - BIGNUM *bn, - BigIntegerStr &snaccInt); - - -/* estimate size of encoded BigIntegerStr */ -unsigned sizeofBigInt( - BigIntegerStr &bigInt); - -/* - * int --> BigIntegerStr - */ -void snaccIntToBigIntegerStr( - int i, - BigIntegerStr &bigInt); - -/* - * Replacements for d2i_RSAPublicKey, etc. - */ -CSSM_RETURN RSAPublicKeyDecode( - RSA *openKey, - void *p, - size_t length); -CSSM_RETURN RSAPublicKeyEncode( - RSA *openKey, - CssmOwnedData &encodedKey); -CSSM_RETURN RSAPrivateKeyDecode( - RSA *openKey, - void *p, - size_t length); -CSSM_RETURN RSAPrivateKeyEncode( - RSA *openKey, - CssmOwnedData &encodedKey); - -CSSM_RETURN generateDigestInfo( - const void *messageDigest, - size_t digestLen, - CSSM_ALGORITHMS digestAlg, // CSSM_ALGID_SHA1, etc. - CssmOwnedData &encodedInfo, - size_t maxEncodedSize); - -CSSM_RETURN DSAPublicKeyDecode( - DSA *openKey, - unsigned char *p, - unsigned length); -CSSM_RETURN DSAPublicKeyEncode( - DSA *openKey, - CssmOwnedData &encodedKey); -CSSM_RETURN DSAPrivateKeyDecode( - DSA *openKey, - unsigned char *p, - unsigned length); -CSSM_RETURN DSAPrivateKeyEncode( - DSA *openKey, - CssmOwnedData &encodedKey); - -CSSM_RETURN DSASigEncode( - DSA_SIG *openSig, - CssmOwnedData &encodedSig); -CSSM_RETURN DSASigDecode( - DSA_SIG *openSig, - const void *p, - unsigned length); - -CSSM_RETURN DHPrivateKeyDecode( - DH *openKey, - unsigned char *p, - unsigned length); -CSSM_RETURN DHPrivateKeyEncode( - DH *openKey, - CssmOwnedData &encodedKey); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OPEN_RSA_SNACC_H_ */ diff --git a/AppleCSP/open_ssl/opensslUtils/opensslAsn1.cpp b/AppleCSP/open_ssl/opensslUtils/opensslAsn1.cpp new file mode 100644 index 00000000..27a837ad --- /dev/null +++ b/AppleCSP/open_ssl/opensslUtils/opensslAsn1.cpp @@ -0,0 +1,1686 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * opensslAsn1.h - ANS1 encode/decode of openssl object, libssnasn1 version + */ +#include "opensslAsn1.h" +#include "BinaryKey.h" +#include "AppleCSPUtils.h" +#include "osKeyTemplates.h" +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#define sslAsn1Debug(args...) secdebug("sslAsn1", ##args) + +#ifndef NDEBUG +#include +#include + +static void logAsnErr( + const char *op, + PRErrorCode perr) +{ + printf("Error on %s: %s\n", op, SECErrorString(perr)); +} +#else +#define logAsnErr(op, perr) +#endif + +/* CSSM_DATA --> BIGNUM */ +BIGNUM *cssmDataToBn( + const CSSM_DATA &cdata) +{ + BIGNUM *bn = BN_new(); + BIGNUM *rtn; + + rtn = BN_bin2bn(cdata.Data, cdata.Length, bn); + if(rtn == NULL) { + BN_free(bn); + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + return bn; +} + +/* BIGNUM --> CSSM_DATA, mallocing from a SecNssCoder's PL_ArenaPool */ +void bnToCssmData( + const BIGNUM *bn, + CSSM_DATA &cdata, + SecNssCoder &coder) +{ + assert(bn != NULL); + unsigned numBytes = BN_num_bytes(bn); + cdata.Data = (uint8 *)coder.malloc(numBytes); + if(cdata.Data == NULL) { + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); + } + cdata.Length = numBytes; + BN_bn2bin(bn, cdata.Data); +} + +/* + * CSSM_DATA --> unsigned int + */ +unsigned cssmDataToInt( + const CSSM_DATA &cdata) +{ + if((cdata.Length == 0) || (cdata.Data == NULL)) { + return 0; + } + unsigned len = (unsigned)cdata.Length; + if(len > sizeof(int)) { + logAsnErr("cssmDataToInt: Length error (%u)", len); + CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS); + } + + unsigned rtn = 0; + uint8 *cp = cdata.Data; + for(unsigned i=0; i CSSM_DATA, mallocing from an SecNssCoder + */ +void intToCssmData( + unsigned num, + CSSM_DATA &cdata, + SecNssCoder &coder) +{ + unsigned len = 0; + + if(num < 0x100) { + len = 1; + } + else if(num < 0x10000) { + len = 2; + } + else if(num < 0x1000000) { + len = 3; + } + else { + len = 4; + } + cdata.Data = (uint8 *)coder.malloc(len); + cdata.Length = len; + uint8 *cp = &cdata.Data[len - 1]; + for(unsigned i=0; i>= 8; + } +} + +/* + * Set up a encoded NULL for AlgorithmIdentifier.parameters, + * required for RSA + */ +static void nullAlgParams( + CSSM_X509_ALGORITHM_IDENTIFIER &algId) +{ + static const uint8 encNull[2] = { SEC_ASN1_NULL, 0 }; + CSSM_DATA encNullData; + encNullData.Data = (uint8 *)encNull; + encNullData.Length = 2; + + algId.parameters = encNullData; +} + +#pragma mark - +#pragma mark *** RSA key encode/decode *** + +/* + * DER encode/decode RSA keys in various formats. + * + * Public key, CSSM_KEYBLOB_RAW_FORMAT_PKCS1 + * -- compatible with BSAFE + * -- used for CSSM_KEYBLOB_RAW_FORMAT_DIGEST on both keys + */ +static CSSM_RETURN RSAPublicKeyDecodePKCS1( + SecNssCoder &coder, + RSA *openKey, + void *p, + size_t length) +{ + NSS_RSAPublicKeyPKCS1 nssPubKey; + + memset(&nssPubKey, 0, sizeof(nssPubKey)); + PRErrorCode perr = coder.decode(p, length, + NSS_RSAPublicKeyPKCS1Template, &nssPubKey); + if(perr) { + logAsnErr("decode(RSAPublicKeyPKCS1)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + try { + openKey->n = cssmDataToBn(nssPubKey.modulus); + openKey->e = cssmDataToBn(nssPubKey.publicExponent); + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } + return 0; +} + +static CSSM_RETURN RSAPublicKeyEncodePKCS1( + SecNssCoder &coder, + RSA *openKey, + CssmOwnedData &encodedKey) +{ + /* convert to NSS_RSAPublicKeyPKCS1 */ + NSS_RSAPublicKeyPKCS1 nssPubKey; + + try { + bnToCssmData(openKey->n, nssPubKey.modulus, coder); + bnToCssmData(openKey->e, nssPubKey.publicExponent, coder); + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } + + PRErrorCode prtn; + prtn = SecNssEncodeItemOdata(&nssPubKey, + NSS_RSAPublicKeyPKCS1Template, encodedKey); + if(prtn) { + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +/* + * SubjectPublicKeyInfo, as used by openssl. + * The subjectPublicKey component is a PKCS1-style RSAPublicKey. + */ +static CSSM_RETURN RSAPublicKeyDecodeX509( + SecNssCoder &coder, + RSA *openKey, + void *p, + size_t length) +{ + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO nssPubKeyInfo; + PRErrorCode perr; + + memset(&nssPubKeyInfo, 0, sizeof(nssPubKeyInfo)); + perr = coder.decode(p, length, NSS_SubjectPublicKeyInfoTemplate, + &nssPubKeyInfo); + if(perr) { + logAsnErr("decode(RSA SubjectPublicKeyInfo)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + /* verify alg identifier */ + const CSSM_OID *oid = &nssPubKeyInfo.algorithm.algorithm; + if(!cspCompareCssmData(oid, &CSSMOID_RSA)) { + sslAsn1Debug("RSAPublicKeyDecodeX509: bad OID"); + return CSSMERR_CSP_INVALID_KEY; + } + + /* decode the raw bits */ + CSSM_DATA *pubKey = &nssPubKeyInfo.subjectPublicKey; + /* decoded length was in bits */ + pubKey->Length = (pubKey->Length + 7) / 8; + return RSAPublicKeyDecodePKCS1(coder, openKey, pubKey->Data, + pubKey->Length); +} + +static CSSM_RETURN RSAPublicKeyEncodeX509( + SecNssCoder &coder, + RSA *openKey, + CssmOwnedData &encodedKey) +{ + CssmAutoData aData(CssmAllocator::standard()); + CSSM_RETURN crtn; + + /* First get an encoded PKCS1-style RSAPublicKey */ + crtn = RSAPublicKeyEncodePKCS1(coder, openKey, aData); + if(crtn) { + return crtn; + } + + /* + * That's the AsnBits subjectPublicKey component of a + * SubjectPublicKeyInfo + */ + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO nssPubKeyInfo; + memset(&nssPubKeyInfo, 0, sizeof(nssPubKeyInfo)); + nssPubKeyInfo.subjectPublicKey.Data = (uint8 *)aData.data(); + nssPubKeyInfo.subjectPublicKey.Length = aData.length() * 8; + + CSSM_X509_ALGORITHM_IDENTIFIER &algId = nssPubKeyInfo.algorithm; + algId.algorithm = CSSMOID_RSA; + + /* NULL algorithm paramneters, always in this case */ + nullAlgParams(algId); + + /* DER encode */ + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&nssPubKeyInfo, + NSS_SubjectPublicKeyInfoTemplate, encodedKey); + + if(perr) { + logAsnErr("encode(RSA SubjectPublicKeyInfo)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +/* + * RSA private key, PKCS1 format, used by openssl. + */ +static CSSM_RETURN RSAPrivateKeyDecodePKCS1( + SecNssCoder &coder, + RSA *openKey, + void *p, + size_t length) +{ + NSS_RSAPrivateKeyPKCS1 nssPrivKey; + PRErrorCode perr; + + memset(&nssPrivKey, 0, sizeof(nssPrivKey)); + perr = coder.decode(p, length, NSS_RSAPrivateKeyPKCS1Template, &nssPrivKey); + if(perr) { + logAsnErr("decode(RSAPrivateKeyPKCS)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + /* convert nssPrivKey fields to RSA key fields */ + try { + openKey->version = cssmDataToInt(nssPrivKey.version); + openKey->n = cssmDataToBn(nssPrivKey.modulus); + openKey->e = cssmDataToBn(nssPrivKey.publicExponent); + openKey->d = cssmDataToBn(nssPrivKey.privateExponent); + openKey->p = cssmDataToBn(nssPrivKey.prime1); + openKey->q = cssmDataToBn(nssPrivKey.prime2); + openKey->dmp1 = cssmDataToBn(nssPrivKey.exponent1); + openKey->dmq1 = cssmDataToBn(nssPrivKey.exponent2); + openKey->iqmp = cssmDataToBn(nssPrivKey.coefficient); + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } + return 0; +} + +static CSSM_RETURN RSAPrivateKeyEncodePKCS1( + SecNssCoder &coder, + RSA *openKey, + CssmOwnedData &encodedKey) +{ + NSS_RSAPrivateKeyPKCS1 nssPrivKey; + PRErrorCode perr; + + /* convert to NSS_RSAPrivateKeyPKCS1 */ + try { + intToCssmData(openKey->version, nssPrivKey.version, coder); + bnToCssmData(openKey->n, nssPrivKey.modulus, coder); + bnToCssmData(openKey->e, nssPrivKey.publicExponent, coder); + bnToCssmData(openKey->d, nssPrivKey.privateExponent, coder); + bnToCssmData(openKey->p, nssPrivKey.prime1, coder); + bnToCssmData(openKey->q, nssPrivKey.prime2, coder); + bnToCssmData(openKey->dmp1, nssPrivKey.exponent1, coder); + bnToCssmData(openKey->dmq1, nssPrivKey.exponent2, coder); + bnToCssmData(openKey->iqmp, nssPrivKey.coefficient, coder); + } + catch(...) { + /* ? */ + return CSSMERR_CSP_MEMORY_ERROR; + } + + /* DER encode */ + perr = SecNssEncodeItemOdata(&nssPrivKey, NSS_RSAPrivateKeyPKCS1Template, + encodedKey); + if(perr) { + logAsnErr("encode(RSAPrivateKeyPKCS1)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +/* + * RSA private key, PKCS8, compatible with BSAFE. + */ +static CSSM_RETURN RSAPrivateKeyDecodePKCS8( + SecNssCoder &coder, + RSA *openKey, + void *p, + size_t length) +{ + NSS_PrivateKeyInfo nssPrivKeyInfo; + PRErrorCode perr; + + memset(&nssPrivKeyInfo, 0, sizeof(nssPrivKeyInfo)); + perr = coder.decode(p, length, NSS_PrivateKeyInfoTemplate, &nssPrivKeyInfo); + if(perr) { + logAsnErr("decode(PrivateKeyInfo)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + /* verify alg identifier */ + const CSSM_OID *oid = &nssPrivKeyInfo.algorithm.algorithm; + if(!cspCompareCssmData(oid, &CSSMOID_RSA)) { + sslAsn1Debug("RSAPrivateKeyDecodePKCS8: bad OID"); + return CSSMERR_CSP_INVALID_KEY; + } + + /* + * nssPrivKeyInfo.privateKey is an octet string which needs + * subsequent decoding + */ + CSSM_DATA *privKey = &nssPrivKeyInfo.privateKey; + return RSAPrivateKeyDecodePKCS1(coder, openKey, + privKey->Data, privKey->Length); +} + +static CSSM_RETURN RSAPrivateKeyEncodePKCS8( + SecNssCoder &coder, + RSA *openKey, + CssmOwnedData &encodedKey) +{ + + /* First get PKCS1-style encoding */ + CssmAutoData aData(CssmAllocator::standard()); + CSSM_RETURN crtn = RSAPrivateKeyEncodePKCS1(coder, openKey, aData); + if(crtn) { + return crtn; + } + + /* that encoding is the privateKey field of a NSS_PrivateKeyInfo */ + NSS_PrivateKeyInfo nssPrivKeyInfo; + memset(&nssPrivKeyInfo, 0, sizeof(nssPrivKeyInfo)); + nssPrivKeyInfo.privateKey.Data = (uint8 *)aData.data(); + nssPrivKeyInfo.privateKey.Length = aData.length(); + + CSSM_X509_ALGORITHM_IDENTIFIER &algId = nssPrivKeyInfo.algorithm; + algId.algorithm = CSSMOID_RSA; + + /* NULL algorithm paramneters, always in this case */ + nullAlgParams(algId); + + /* FIXME : attributes? */ + + uint8 vers = 0; + nssPrivKeyInfo.version.Data = &vers; + nssPrivKeyInfo.version.Length = 1; + + /* DER encode */ + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&nssPrivKeyInfo, + NSS_PrivateKeyInfoTemplate, encodedKey); + + if(perr) { + logAsnErr("encode(RSA PrivateKeyInfo)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +CSSM_RETURN RSAPublicKeyDecode( + RSA *openKey, + CSSM_KEYBLOB_FORMAT format, + void *p, + size_t length) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: + return RSAPublicKeyDecodePKCS1(coder, openKey, p, length); + case CSSM_KEYBLOB_RAW_FORMAT_X509: + return RSAPublicKeyDecodeX509(coder, openKey, p, length); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN RSAPublicKeyEncode( + RSA *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: + return RSAPublicKeyEncodePKCS1(coder, openKey, encodedKey); + case CSSM_KEYBLOB_RAW_FORMAT_X509: + return RSAPublicKeyEncodeX509(coder, openKey, encodedKey); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN RSAPrivateKeyDecode( + RSA *openKey, + CSSM_KEYBLOB_FORMAT format, + void *p, + size_t length) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: + return RSAPrivateKeyDecodePKCS1(coder, openKey, p, length); + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + return RSAPrivateKeyDecodePKCS8(coder, openKey, p, length); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN RSAPrivateKeyEncode( + RSA *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: + return RSAPrivateKeyEncodePKCS1(coder, openKey, encodedKey); + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + return RSAPrivateKeyEncodePKCS8(coder, openKey, encodedKey); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +#pragma mark - +#pragma mark *** DSA key encode/decode *** + +/*** + *** DSA + ***/ + +/* NSS_DSAAlgorithmIdBSAFE <--> DSA->{p,g,q} */ +static void dsaToNssAlgIdBSAFE( + const DSA *openKey, + NSS_DSAAlgorithmIdBSAFE &algId, + SecNssCoder &coder) +{ + /* non-standard, BSAFE-specific OID */ + algId.algorithm = CSSMOID_DSA; // not mallocd + unsigned numBits = BN_num_bits(openKey->p); + intToCssmData(numBits, algId.params.keySizeInBits, coder); + bnToCssmData(openKey->p, algId.params.p, coder); + bnToCssmData(openKey->q, algId.params.q, coder); + bnToCssmData(openKey->g, algId.params.g, coder); +} + +static CSSM_RETURN nssAlgIdToDsaBSAFE( + NSS_DSAAlgorithmIdBSAFE &algId, + DSA *openKey) +{ + /* non-standard, BSAFE-specific OID */ + if(!cspCompareCssmData(&algId.algorithm, &CSSMOID_DSA)) { + sslAsn1Debug("nssAlgIdToDsaBSAFE: bad OID"); + return CSSMERR_CSP_INVALID_KEY; + } + openKey->p = cssmDataToBn(algId.params.p); + openKey->q = cssmDataToBn(algId.params.q); + openKey->g = cssmDataToBn(algId.params.g); + return CSSM_OK; +} + +/* NSS_DSAAlgorithmIdX509 <--> DSA->{p,g,q} */ +static void dsaToNssAlgIdX509( + const DSA *openKey, + NSS_DSAAlgorithmIdX509 &algId, + SecNssCoder &coder) +{ + algId.algorithm = CSSMOID_DSA_CMS; // not mallocd + bnToCssmData(openKey->p, algId.params->p, coder); + bnToCssmData(openKey->q, algId.params->q, coder); + bnToCssmData(openKey->g, algId.params->g, coder); +} + +static CSSM_RETURN nssAlgIdToDsaX509( + NSS_DSAAlgorithmIdX509 &algId, + DSA *openKey) +{ + if(!cspCompareCssmData(&algId.algorithm, &CSSMOID_DSA_CMS) && + !cspCompareCssmData(&algId.algorithm, &CSSMOID_DSA_JDK)) { + sslAsn1Debug("nssAlgIdToDsaX509: bad OID"); + return CSSMERR_CSP_INVALID_KEY; + } + /* these might be absent per CMS */ + if(algId.params == NULL) { + return CSSM_OK; + } + openKey->p = cssmDataToBn(algId.params->p); + openKey->q = cssmDataToBn(algId.params->q); + openKey->g = cssmDataToBn(algId.params->g); + return CSSM_OK; +} + +/* + * DSA public keys, FIPS186 format. + * Compatible with BSAFE. + */ +CSSM_RETURN DSAPublicKeyDecodeFIPS186( + SecNssCoder &coder, + DSA *openKey, + void *p, + unsigned length) +{ + NSS_DSAPublicKeyBSAFE nssPubKey; + PRErrorCode perr; + CSSM_RETURN crtn; + + memset(&nssPubKey, 0, sizeof(nssPubKey)); + perr = coder.decode(p, length, NSS_DSAPublicKeyBSAFETemplate, + &nssPubKey); + if(perr) { + logAsnErr("decode(DSAPublicKeyBSAFE)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + /* BSAFE style DSA-specific alg params */ + NSS_DSAAlgorithmIdBSAFE &algId = nssPubKey.dsaAlg; + crtn = nssAlgIdToDsaBSAFE(algId, openKey); + if(crtn) { + return crtn; + } + + /* inside of nssPubKey.publicKey is the DER-encoding of a + * ASN Integer; decoded length was in bits */ + nssPubKey.publicKey.Length = (nssPubKey.publicKey.Length + 7) / 8; + CSSM_DATA pubKeyBytes; + perr = coder.decodeItem(nssPubKey.publicKey, + SEC_UnsignedIntegerTemplate, + &pubKeyBytes); + if(perr) { + logAsnErr("decode(NSS_DSAPublicKeyBSAFE.publicKey)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + openKey->pub_key = cssmDataToBn(pubKeyBytes); + + if(openKey->pub_key == NULL) { + return CSSMERR_CSP_INVALID_KEY; + } + return 0; +} + +CSSM_RETURN DSAPublicKeyEncodeFIPS186( + SecNssCoder &coder, + DSA *openKey, + CssmOwnedData &encodedKey) +{ + try { + /* convert to NSS_DSAPublicKeyBSAFE */ + NSS_DSAPublicKeyBSAFE nssPubKey; + memset(&nssPubKey, 0, sizeof(nssPubKey)); + dsaToNssAlgIdBSAFE(openKey, nssPubKey.dsaAlg, coder); + + /* + * publicKey is the DER-encoding of a ASN INTEGER wrapped in + * an AsnBits + */ + CSSM_DATA pubKeyRaw; + PRErrorCode perr; + bnToCssmData(openKey->pub_key, pubKeyRaw, coder); + perr = coder.encodeItem(&pubKeyRaw, SEC_UnsignedIntegerTemplate, + nssPubKey.publicKey); + if(perr) { + logAsnErr("encodeItem(DSAPublicKeyBSAFE.publicKey)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + nssPubKey.publicKey.Length *= 8; + + /* DER encode */ + SecNssEncodeItemOdata(&nssPubKey, NSS_DSAPublicKeyBSAFETemplate, + encodedKey); + return CSSM_OK; + } + catch(...) { + /* ? */ + return CSSMERR_CSP_MEMORY_ERROR; + } +} + +/* + * DSA private keys, FIPS186 format. + * Compatible with BSAFE. + */ +CSSM_RETURN DSAPrivateKeyDecodeFIPS186( + SecNssCoder &coder, + DSA *openKey, + void *p, + unsigned length) +{ + NSS_DSAPrivateKeyBSAFE nssPrivKeyInfo; + PRErrorCode perr; + + memset(&nssPrivKeyInfo, 0, sizeof(nssPrivKeyInfo)); + perr = coder.decode(p, length, NSS_DSAPrivateKeyBSAFETemplate, + &nssPrivKeyInfo); + if(perr) { + logAsnErr("decode(DSA PrivateKeyInfo)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + CSSM_RETURN crtn = nssAlgIdToDsaBSAFE(nssPrivKeyInfo.dsaAlg, openKey); + if(crtn) { + return crtn; + } + + /* nssPrivKeyInfo.privateKey is the DER-encoding of a + * DSAPrivateKeyOcts... */ + try { + PRErrorCode perr; + NSS_DSAPrivateKeyOcts keyOcts; + + perr = coder.decodeItem(nssPrivKeyInfo.privateKey, + NSS_DSAPrivateKeyOctsTemplate, &keyOcts); + if(perr) { + logAsnErr("decode(DSA PrivateKeyInfoOcts)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + openKey->priv_key = cssmDataToBn(keyOcts.privateKey); + if(openKey->priv_key == NULL) { + return CSSMERR_CSP_INVALID_KEY; + } + return 0; + } + catch(...) { + return CSSMERR_CSP_INVALID_KEY; + } +} + +CSSM_RETURN DSAPrivateKeyEncodeFIPS186( + SecNssCoder &coder, + DSA *openKey, + CssmOwnedData &encodedKey) +{ + try { + /* First convert into a NSS_DSAPrivateKeyBSAFE */ + NSS_DSAPrivateKeyBSAFE nssPrivKey; + intToCssmData(openKey->version, nssPrivKey.version, coder); + dsaToNssAlgIdBSAFE(openKey, nssPrivKey.dsaAlg, coder); + + /* nssPrivKey.privateKey is the DER-encoding of one of these... */ + NSS_DSAPrivateKeyOcts privKeyOcts; + bnToCssmData(openKey->priv_key, privKeyOcts.privateKey, coder); + + /* DER encode the privateKey portion into arena pool memory + * into NSS_DSAPrivateKeyPKCS8.privateKey */ + coder.encodeItem(&privKeyOcts, NSS_DSAPrivateKeyOctsTemplate, + nssPrivKey.privateKey); + + /* DER encode the whole thing */ + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&nssPrivKey, + NSS_DSAPrivateKeyBSAFETemplate, encodedKey); + return 0; + } + catch(...) { + /* ? */ + return CSSMERR_CSP_MEMORY_ERROR; + } +} + +/* + * DSA private keys, PKCS8/SMIME format. + */ +CSSM_RETURN DSAPrivateKeyDecodePKCS8( + SecNssCoder &coder, + DSA *openKey, + void *p, + unsigned length) +{ + NSS_DSAPrivateKeyPKCS8 nssPrivKeyInfo; + PRErrorCode perr; + + memset(&nssPrivKeyInfo, 0, sizeof(nssPrivKeyInfo)); + perr = coder.decode(p, length, NSS_DSAPrivateKeyPKCS8Template, + &nssPrivKeyInfo); + if(perr) { + logAsnErr("decode(DSA NSS_DSAPrivateKeyPKCS8)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + CSSM_RETURN crtn = nssAlgIdToDsaX509(nssPrivKeyInfo.dsaAlg, openKey); + if(crtn) { + return crtn; + } + + /* + * Post-decode, nssPrivKeyInfo.privateKey is the DER-encoding of a + * an ASN integer. + */ + try { + PRErrorCode perr; + CSSM_DATA privKeyInt = {0, NULL}; + + perr = coder.decodeItem(nssPrivKeyInfo.privateKey, + SEC_UnsignedIntegerTemplate, &privKeyInt); + if(perr) { + logAsnErr("decode(DSA nssPrivKeyInfo.privateKey)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + openKey->priv_key = cssmDataToBn(privKeyInt); + if(openKey->priv_key == NULL) { + return CSSMERR_CSP_INVALID_KEY; + } + return 0; + } + catch(...) { + return CSSMERR_CSP_INVALID_KEY; + } +} + +CSSM_RETURN DSAPrivateKeyEncodePKCS8( + SecNssCoder &coder, + DSA *openKey, + CssmOwnedData &encodedKey) +{ + try { + /* First convert into a NSS_DSAPrivateKeyPKCS8 */ + NSS_DSAPrivateKeyPKCS8 nssPrivKey; + NSS_DSAAlgParams algParams; + memset(&nssPrivKey, 0, sizeof(nssPrivKey)); + memset(&algParams, 0, sizeof(algParams)); + nssPrivKey.dsaAlg.params = &algParams; + intToCssmData(openKey->version, nssPrivKey.version, coder); + dsaToNssAlgIdX509(openKey, nssPrivKey.dsaAlg, coder); + + /* pre-encode, nssPrivKey.privateKey is the DER-encoding of + * an ASN integer... */ + CSSM_DATA privKeyInt; + bnToCssmData(openKey->priv_key, privKeyInt, coder); + + /* DER encode the privateKey portion into arena pool memory + * into NSS_DSAPrivateKeyPKCS8.privateKey */ + coder.encodeItem(&privKeyInt, SEC_UnsignedIntegerTemplate, + nssPrivKey.privateKey); + + /* DER encode the whole thing */ + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&nssPrivKey, + NSS_DSAPrivateKeyPKCS8Template, encodedKey); + return 0; + } + catch(...) { + /* ? */ + return CSSMERR_CSP_MEMORY_ERROR; + } +} + +/* + * DSA public key, X509/openssl format. + */ +static CSSM_RETURN DSAPublicKeyDecodeX509( + SecNssCoder &coder, + DSA *openKey, + void *p, + size_t length) +{ + NSS_DSAPublicKeyX509 nssPubKey; + PRErrorCode perr; + CSSM_RETURN crtn; + + memset(&nssPubKey, 0, sizeof(nssPubKey)); + perr = coder.decode(p, length, NSS_DSAPublicKeyX509Template, + &nssPubKey); + if(perr) { + logAsnErr("decode(DSAPublicKeyX509)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + /* X509 style DSA-specific alg params */ + NSS_DSAAlgorithmIdX509 &algId = nssPubKey.dsaAlg; + crtn = nssAlgIdToDsaX509(algId, openKey); + if(crtn) { + return crtn; + } + + /* inside of nssPubKey.publicKey is the DER-encoding of a + * ASN Integer; decoded length was in bits */ + nssPubKey.publicKey.Length = (nssPubKey.publicKey.Length + 7) / 8; + CSSM_DATA pubKeyBytes = {0, NULL}; + perr = coder.decodeItem(nssPubKey.publicKey, + SEC_UnsignedIntegerTemplate, + &pubKeyBytes); + if(perr) { + logAsnErr("decode(NSS_DSAPublicKeyX509.publicKey)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + openKey->pub_key = cssmDataToBn(pubKeyBytes); + + if(openKey->pub_key == NULL) { + return CSSMERR_CSP_INVALID_KEY; + } + return 0; +} + +static CSSM_RETURN DSAPublicKeyEncodeX509( + SecNssCoder &coder, + DSA *openKey, + CssmOwnedData &encodedKey) +{ + try { + /* convert to NSS_DSAPublicKeyX509 */ + NSS_DSAPublicKeyX509 nssPubKey; + NSS_DSAAlgParams algParams; + memset(&nssPubKey, 0, sizeof(nssPubKey)); + memset(&algParams, 0, sizeof(algParams)); + nssPubKey.dsaAlg.params = &algParams; + dsaToNssAlgIdX509(openKey, nssPubKey.dsaAlg, coder); + + /* + * publicKey is the DER-encoding of a ASN INTEGER wrapped in + * an AsnBits + */ + CSSM_DATA pubKeyRaw; + PRErrorCode perr; + bnToCssmData(openKey->pub_key, pubKeyRaw, coder); + perr = coder.encodeItem(&pubKeyRaw, SEC_UnsignedIntegerTemplate, + nssPubKey.publicKey); + if(perr) { + logAsnErr("encodeItem(DSAPublicKeyX509.publicKey)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + nssPubKey.publicKey.Length *= 8; + + /* DER encode */ + SecNssEncodeItemOdata(&nssPubKey, NSS_DSAPublicKeyX509Template, + encodedKey); + return CSSM_OK; + } + catch(...) { + /* ? */ + return CSSMERR_CSP_MEMORY_ERROR; + } +} + +/* + * Encode public key portion only for calculating key digest. + * Note this works just fine on a partial DSA public key, i.e., + * A DSA public key's digest-capable blob is the same whether or + * not the DSA key has its DSA parameters p, q, and g. + */ +static CSSM_RETURN DSAPublicKeyEncodeHashable( + SecNssCoder &coder, + DSA *openKey, + CssmOwnedData &encodedKey) +{ + try { + /* + * publicKey is the DER-encoding of an ASN integer + */ + CSSM_DATA pubKey; + bnToCssmData(openKey->pub_key, pubKey, coder); + PRErrorCode perr; + + perr = SecNssEncodeItemOdata(&pubKey, SEC_UnsignedIntegerTemplate, + encodedKey); + if(perr) { + logAsnErr("encode(DSAPubHashable)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; + } + catch(...) { + /* ? */ + return CSSMERR_CSP_MEMORY_ERROR; + } +} + +/* + * DSA private key, custom openssl format. + */ +static CSSM_RETURN DSAPrivateKeyDecodeOpenssl( + SecNssCoder &coder, + DSA *openKey, + void *p, + size_t length) +{ + NSS_DSAPrivateKeyOpenssl nssPrivKey; + PRErrorCode perr; + + memset(&nssPrivKey, 0, sizeof(nssPrivKey)); + perr = coder.decode(p, length, NSS_DSAPrivateKeyOpensslTemplate, + &nssPrivKey); + if(perr) { + logAsnErr("decode(DSAPrivateKeyOpenssl)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + /* convert nssPrivKey fields to RSA key fields */ + try { + openKey->version = cssmDataToInt(nssPrivKey.version); + openKey->p = cssmDataToBn(nssPrivKey.p); + openKey->q = cssmDataToBn(nssPrivKey.q); + openKey->g = cssmDataToBn(nssPrivKey.g); + openKey->pub_key = cssmDataToBn(nssPrivKey.pub); + openKey->priv_key = cssmDataToBn(nssPrivKey.priv); + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } + return 0; +} + +static CSSM_RETURN DSAPrivateKeyEncodeOpenssl( + SecNssCoder &coder, + DSA *openKey, + CssmOwnedData &encodedKey) +{ + NSS_DSAPrivateKeyOpenssl nssPrivKey; + PRErrorCode perr; + + /* convert to NSS_DSAPrivateKeyOpenssl */ + try { + intToCssmData(openKey->version, nssPrivKey.version, coder); + bnToCssmData(openKey->p, nssPrivKey.p, coder); + bnToCssmData(openKey->q, nssPrivKey.q, coder); + bnToCssmData(openKey->g, nssPrivKey.g, coder); + bnToCssmData(openKey->pub_key, nssPrivKey.pub, coder); + bnToCssmData(openKey->priv_key, nssPrivKey.priv, coder); + } + catch(...) { + /* ? */ + return CSSMERR_CSP_MEMORY_ERROR; + } + + /* DER encode */ + perr = SecNssEncodeItemOdata(&nssPrivKey, NSS_DSAPrivateKeyOpensslTemplate, + encodedKey); + if(perr) { + logAsnErr("encode(DSAPrivateKeyOpenssl)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +CSSM_RETURN DSAPublicKeyDecode( + DSA *openKey, + CSSM_KEYBLOB_FORMAT format, + void *p, + size_t length) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: + return DSAPublicKeyDecodeFIPS186(coder, openKey, p, length); + case CSSM_KEYBLOB_RAW_FORMAT_X509: + return DSAPublicKeyDecodeX509(coder, openKey, p, length); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN DSAPublicKeyEncode( + DSA *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: + return DSAPublicKeyEncodeFIPS186(coder, openKey, encodedKey); + case CSSM_KEYBLOB_RAW_FORMAT_X509: + return DSAPublicKeyEncodeX509(coder, openKey, encodedKey); + case CSSM_KEYBLOB_RAW_FORMAT_DIGEST: + return DSAPublicKeyEncodeHashable(coder, openKey, encodedKey); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN DSAPrivateKeyDecode( + DSA *openKey, + CSSM_KEYBLOB_FORMAT format, + void *p, + size_t length) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: + return DSAPrivateKeyDecodeFIPS186(coder, openKey, p, length); + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSL: + return DSAPrivateKeyDecodeOpenssl(coder, openKey, p, length); + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + return DSAPrivateKeyDecodePKCS8(coder, openKey, p, length); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN DSAPrivateKeyEncode( + DSA *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: + return DSAPrivateKeyEncodeFIPS186(coder, openKey, encodedKey); + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSL: + return DSAPrivateKeyEncodeOpenssl(coder, openKey, encodedKey); + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + return DSAPrivateKeyEncodePKCS8(coder, openKey, encodedKey); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +#pragma mark - +#pragma mark *** DSA Signature encode/decode *** + +CSSM_RETURN DSASigEncode( + DSA_SIG *openSig, + CssmOwnedData &encodedSig) +{ + /* temp allocs from this pool */ + SecNssCoder coder; + /* convert to NSS_DSASignature */ + NSS_DSASignature nssSig; + + try { + bnToCssmData(openSig->r, nssSig.r, coder); + bnToCssmData(openSig->s, nssSig.s, coder); + } + catch(...) { + /* ? */ + return CSSMERR_CSP_MEMORY_ERROR; + } + + PRErrorCode prtn = SecNssEncodeItemOdata(&nssSig, + NSS_DSASignatureTemplate, encodedSig); + if(prtn) { + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +CSSM_RETURN DSASigDecode( + DSA_SIG *openSig, + const void *p, + unsigned length) +{ + NSS_DSASignature nssSig; + SecNssCoder coder; + + memset(&nssSig, 0, sizeof(nssSig)); + PRErrorCode perr = coder.decode(p, length, + NSS_DSASignatureTemplate, &nssSig); + if(perr) { + logAsnErr("decode(DSASigDecode)", perr); + return CSSMERR_CSP_INVALID_SIGNATURE; + } + + try { + openSig->r = cssmDataToBn(nssSig.r); + openSig->s = cssmDataToBn(nssSig.s); + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } + return 0; +} + +#pragma mark - +#pragma mark *** DSA Algorithm Parameters encode/decode *** + +CSSM_RETURN DSAEncodeAlgParams( + NSS_DSAAlgParams &algParams, + CssmOwnedData &encodedParams) +{ + PRErrorCode prtn = SecNssEncodeItemOdata(&algParams, + NSS_DSAAlgParamsTemplate, encodedParams); + if(prtn) { + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +CSSM_RETURN DSADecodeAlgParams( + NSS_DSAAlgParams &algParams, + const void *p, + unsigned len, + SecNssCoder &coder) +{ + + memset(&algParams, 0, sizeof(algParams)); + PRErrorCode perr = coder.decode(p, len, + NSS_DSAAlgParamsTemplate, &algParams); + if(perr) { + logAsnErr("decode(DSAAlgParams)", perr); + return CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS; + } + return CSSM_OK; +} + +#pragma mark - +#pragma mark *** Diffie-Hellman key encode/decode *** + +CSSM_RETURN DHPrivateKeyDecodePKCS3( + SecNssCoder &coder, + DH *openKey, + unsigned char *p, + unsigned length) +{ + NSS_DHPrivateKey nssPrivKey; + PRErrorCode perr; + + memset(&nssPrivKey, 0, sizeof(nssPrivKey)); + perr = coder.decode(p, length, NSS_DHPrivateKeyTemplate, &nssPrivKey); + if(perr) { + logAsnErr("decode(DHPrivateKey)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + /* verify alg identifier */ + const CSSM_OID *oid = &nssPrivKey.dhOid; + if(!cspCompareCssmData(oid, &CSSMOID_DH)) { + sslAsn1Debug("DHPrivateKeyDecode: bad OID"); + return CSSMERR_CSP_ALGID_MISMATCH; + } + + NSS_DHParameter ¶ms = nssPrivKey.params; + + try { + openKey->priv_key = cssmDataToBn(nssPrivKey.secretPart); + openKey->p = cssmDataToBn(params.prime); + openKey->g = cssmDataToBn(params.base); + /* TBD - ignore privateValueLength for now */ + } + catch(...) { + /* FIXME - bad sig? memory? */ + return CSSMERR_CSP_MEMORY_ERROR; + } + return 0; +} + +CSSM_RETURN DHPrivateKeyEncodePKCS3( + SecNssCoder &coder, + DH *openKey, + CssmOwnedData &encodedKey) +{ + /* convert into a NSS_DHPrivateKey */ + NSS_DHPrivateKey nssPrivKey; + NSS_DHParameter ¶ms = nssPrivKey.params; + memset(&nssPrivKey, 0, sizeof(nssPrivKey)); + nssPrivKey.dhOid = CSSMOID_DH; + + + try { + bnToCssmData(openKey->priv_key, nssPrivKey.secretPart, coder); + bnToCssmData(openKey->p, params.prime, coder); + bnToCssmData(openKey->g, params.base, coder); + if(openKey->length) { + /* actually currently not supported in openssl... */ + intToCssmData(openKey->length, params.privateValueLength, coder); + } + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } + + /* DER encode */ + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&nssPrivKey, NSS_DHPrivateKeyTemplate, + encodedKey); + if(perr) { + logAsnErr("encode(DHPrivateKey)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +/* + * NSS_DHAlgorithmIdentifierX942 <--> DH + * NOTE this is incomplete. It's functional on decode, but we throw + * away everything except p and g. On encode, we put zeroes in + * all the fields we don't deal with. Thus the encode side will NOT be + * interoperable with other implementations. + */ +static void dhToNssAlgIdX942( + const DH *openKey, + NSS_DHAlgorithmIdentifierX942 &algId, + SecNssCoder &coder) +{ + /* + * When trying to encode a public key in X509 form, we may in + * fact have nothing here - public keys created and exported in + * PKCS3 have the pub_key value, and that's it. + */ + + memset(&algId, 0, sizeof(algId)); + algId.oid = CSSMOID_ANSI_DH_PUB_NUMBER; // not mallocd + NSS_DHDomainParamsX942 ¶ms = algId.params; + uint8 zero = 0; + CSSM_DATA czero = {1, &zero}; + if(openKey->p != NULL) { + bnToCssmData(openKey->p, params.p, coder); + } + else { + coder.allocCopyItem(czero, params.p); + } + if(openKey->g != NULL) { + bnToCssmData(openKey->g, params.g, coder); + } + else { + coder.allocCopyItem(czero, params.g); + } + /* and we never have a vali0d q */ + coder.allocCopyItem(czero, params.q); + +} + +static CSSM_RETURN nssAlgIdToDhX942( + NSS_DHAlgorithmIdentifierX942 &algId, + DH *openKey) +{ + if(!cspCompareCssmData(&algId.oid, &CSSMOID_ANSI_DH_PUB_NUMBER)) { + sslAsn1Debug("nssAlgIdToDhX942: bad OID"); + return CSSMERR_CSP_INVALID_KEY; + } + openKey->p = cssmDataToBn(algId.params.p); + openKey->g = cssmDataToBn(algId.params.g); + return CSSM_OK; +} + +CSSM_RETURN DHPrivateKeyDecodePKCS8( + SecNssCoder &coder, + DH *openKey, + unsigned char *p, + unsigned length) +{ + NSS_DHPrivateKeyPKCS8 nssPrivKey; + PRErrorCode perr; + + memset(&nssPrivKey, 0, sizeof(nssPrivKey)); + perr = coder.decode(p, length, NSS_DHPrivateKeyPKCS8Template, + &nssPrivKey); + if(perr) { + logAsnErr("decode(DHPrivateKeyPKCS8)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + try { + CSSM_RETURN crtn = nssAlgIdToDhX942(nssPrivKey.algorithm, openKey); + if(crtn) { + return crtn; + } + + /* post-decode private key is a DER encoded integer */ + CSSM_DATA privKeyInt = {0, NULL}; + if(coder.decodeItem(nssPrivKey.privateKey, + SEC_UnsignedIntegerTemplate, + &privKeyInt)) { + logAsnErr("decode(DHPrivateKeyPKCS8 privKey int)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + openKey->priv_key = cssmDataToBn(privKeyInt); + } + catch(...) { + /* FIXME - bad sig? memory? */ + return CSSMERR_CSP_MEMORY_ERROR; + } + return 0; +} + +CSSM_RETURN DHPrivateKeyEncodePKCS8( + SecNssCoder &coder, + DH *openKey, + CssmOwnedData &encodedKey) +{ + /* convert into a NSS_DHPrivateKeyPKCS8 */ + NSS_DHPrivateKeyPKCS8 nssPrivKey; + memset(&nssPrivKey, 0, sizeof(nssPrivKey)); + uint8 vers = 0; + nssPrivKey.version.Length = 1; + nssPrivKey.version.Data = &vers; + NSS_DHAlgorithmIdentifierX942 &alg = nssPrivKey.algorithm; + + try { + + dhToNssAlgIdX942(openKey, alg, coder); + /* pre-encode, nssPrivKey.privateKey is the DER-encoding of + * an ASN integer... */ + CSSM_DATA privKeyInt; + bnToCssmData(openKey->priv_key, privKeyInt, coder); + + /* DER encode the privateKey portion into arena pool memory + * into nssPrivKey.privateKey */ + coder.encodeItem(&privKeyInt, SEC_UnsignedIntegerTemplate, + nssPrivKey.privateKey); + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } + + /* DER encode */ + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&nssPrivKey, NSS_DHPrivateKeyPKCS8Template, + encodedKey); + if(perr) { + logAsnErr("encode(DHPrivateKey)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +/* + * In the PKCS3 form, the public blob is simply the literal + * public key value, not DER encoded. + */ +static CSSM_RETURN DHPublicKeyDecodePKCS3( + DH *openKey, + SecNssCoder &coder, + unsigned char *p, + unsigned length) +{ + try { + CSSM_DATA pubKey = {(uint32)length, (uint8 *)p}; + openKey->pub_key = cssmDataToBn(pubKey); + return CSSM_OK; + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } +} + +static CSSM_RETURN DHPublicKeyEncodePKCS3( + DH *openKey, + SecNssCoder &coder, + CssmOwnedData &encodedKey) +{ + try { + CSSM_DATA pubKey; + bnToCssmData(openKey->pub_key, pubKey, coder); + encodedKey.copy(CssmData::overlay(pubKey)); + return CSSM_OK; + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } +} + +static CSSM_RETURN DHPublicKeyDecodeX509( + DH *openKey, + SecNssCoder &coder, + unsigned char *p, + unsigned length) +{ + NSS_DHPublicKeyX509 nssPubKey; + PRErrorCode perr; + + memset(&nssPubKey, 0, sizeof(nssPubKey)); + perr = coder.decode(p, length, NSS_DHPublicKeyX509Template, + &nssPubKey); + if(perr) { + logAsnErr("decode(DHPublicKeyX509)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + + try { + CSSM_RETURN crtn = nssAlgIdToDhX942(nssPubKey.algorithm, openKey); + if(crtn) { + return crtn; + } + + /* + * Post-decode public key length in bits + * Contents are pub_key as DER-encoded INTEGER + */ + CSSM_DATA &pubKey = nssPubKey.publicKey; + pubKey.Length = (pubKey.Length + 7) / 8; + CSSM_DATA pubKeyInt = {0, NULL}; + if(coder.decodeItem(pubKey, + SEC_UnsignedIntegerTemplate, &pubKeyInt)) { + logAsnErr("decode(DHPublicKeyX509 pub key int)", perr); + return CSSMERR_CSP_INVALID_KEY; + } + openKey->pub_key = cssmDataToBn(pubKeyInt); + } + catch(...) { + /* FIXME - bad sig? memory? */ + return CSSMERR_CSP_MEMORY_ERROR; + } + return 0; +} + +static CSSM_RETURN DHPublicKeyEncodeX509( + DH *openKey, + SecNssCoder &coder, + CssmOwnedData &encodedKey) +{ + /* convert into a NSS_DHPublicKeyX509 */ + NSS_DHPublicKeyX509 nssPubKey; + memset(&nssPubKey, 0, sizeof(nssPubKey)); + NSS_DHAlgorithmIdentifierX942 &alg = nssPubKey.algorithm; + + try { + dhToNssAlgIdX942(openKey, alg, coder); + + /* encode pub_key as integer */ + CSSM_DATA pubKeyInt = {0, NULL}; + bnToCssmData(openKey->pub_key, pubKeyInt, coder); + coder.encodeItem(&pubKeyInt, SEC_UnsignedIntegerTemplate, + nssPubKey.publicKey); + /* specify length in bits */ + nssPubKey.publicKey.Length *= 8; + } + catch(...) { + return CSSMERR_CSP_MEMORY_ERROR; + } + + /* DER encode */ + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&nssPubKey, NSS_DHPublicKeyX509Template, + encodedKey); + if(perr) { + logAsnErr("encode(DHPublicKeyX509)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + +CSSM_RETURN DHPrivateKeyDecode( + DH *openKey, + CSSM_KEYBLOB_FORMAT format, + unsigned char *p, + unsigned length) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS3: + return DHPrivateKeyDecodePKCS3(coder, openKey, p, length); + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + return DHPrivateKeyDecodePKCS8(coder, openKey, p, length); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN DHPrivateKeyEncode( + DH *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS3: + return DHPrivateKeyEncodePKCS3(coder, openKey, encodedKey); + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + return DHPrivateKeyEncodePKCS8(coder, openKey, encodedKey); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN DHPublicKeyDecode( + DH *openKey, + CSSM_KEYBLOB_FORMAT format, + unsigned char *p, + unsigned length) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS3: + return DHPublicKeyDecodePKCS3(openKey, coder, p, length); + case CSSM_KEYBLOB_RAW_FORMAT_X509: + return DHPublicKeyDecodeX509(openKey, coder, p, length); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +CSSM_RETURN DHPublicKeyEncode( + DH *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey) +{ + SecNssCoder coder; + + switch(format) { + case CSSM_KEYBLOB_RAW_FORMAT_PKCS3: + return DHPublicKeyEncodePKCS3(openKey, coder, encodedKey); + case CSSM_KEYBLOB_RAW_FORMAT_X509: + return DHPublicKeyEncodeX509(openKey, coder, encodedKey); + default: + assert(0); + return CSSMERR_CSP_INTERNAL_ERROR; + } +} + +/* + * Encode/decode a NSS_DHParameterBlock. + */ +CSSM_RETURN DHParamBlockDecode( + const CSSM_DATA &encParam, + NSS_DHParameterBlock ¶mBlock, + SecNssCoder &coder) +{ + PRErrorCode perr; + + memset(¶mBlock, 0, sizeof(paramBlock)); + perr = coder.decodeItem(encParam, NSS_DHParameterBlockTemplate, + ¶mBlock); + if(perr == 0) { + return CSSM_OK; + } + + /* + * CDSA Extension: the CDSA Algorithm Guide says that the D-H + * parameter block is supposed to be wrapped with its accompanying + * OID. However Openssl does not do this; it just exports + * an encoded DHParameter rather than a DHParameterBlock. + * For compatibility we'll try decoding the parameters as one + * of these. + */ + memset(¶mBlock, 0, sizeof(paramBlock)); + perr = coder.decodeItem(encParam, NSS_DHParameterTemplate, + ¶mBlock.params); + if(perr == 0) { + return CSSM_OK; + } + return CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS; +} + +#pragma mark - +#pragma mark *** Message Digest *** + +/* + * Given a message digest and associated algorithm, cook up a PKCS1-style + * DigestInfo and return its DER encoding. This is a necessary step for + * RSA signature (both generating and verifying) - the output of this + * routine is what gets encrypted during signing, and what is expected when + * verifying (i.e., decrypting the signature). + * + * A good guess for the length of the output digestInfo is the size of the + * key being used to sign/verify. The digest can never be larger than that. + */ +CSSM_RETURN generateDigestInfo( + const void *msgDigest, + size_t digestLen, + CSSM_ALGORITHMS digestAlg, // CSSM_ALGID_SHA1, etc. + CssmOwnedData &encodedInfo, + size_t maxEncodedSize) +{ + if(digestAlg == CSSM_ALGID_NONE) { + /* special case, no encode, just copy */ + encodedInfo.copy(msgDigest, digestLen); + return 0; + } + + NSS_DigestInfo digestInfo; + CSSM_X509_ALGORITHM_IDENTIFIER &algId = digestInfo.digestAlgorithm; + + memset(&digestInfo, 0, sizeof(digestInfo)); + switch(digestAlg) { + case CSSM_ALGID_MD5: + algId.algorithm = CSSMOID_MD5; + break; + case CSSM_ALGID_MD2: + algId.algorithm = CSSMOID_MD2; + break; + case CSSM_ALGID_SHA1: + algId.algorithm = CSSMOID_SHA1; + break; + default: + return CSSMERR_CSP_INVALID_ALGORITHM; + } + nullAlgParams(algId); + digestInfo.digest.Data = (uint8 *)msgDigest; + digestInfo.digest.Length = digestLen; + + /* DER encode */ + PRErrorCode perr; + perr = SecNssEncodeItemOdata(&digestInfo, NSS_DigestInfoTemplate, + encodedInfo); + if(perr) { + logAsnErr("encode(digestInfo)", perr); + return CSSMERR_CSP_MEMORY_ERROR; + } + return CSSM_OK; +} + diff --git a/AppleCSP/open_ssl/opensslUtils/opensslAsn1.h b/AppleCSP/open_ssl/opensslUtils/opensslAsn1.h new file mode 100644 index 00000000..fd90ace0 --- /dev/null +++ b/AppleCSP/open_ssl/opensslUtils/opensslAsn1.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * opensslAsn1.h - ANS1 encode/decode of openssl object, libssnasn1 version + */ + +#ifndef _OPENSSL_ASN1_H_ +#define _OPENSSL_ASN1_H_ + + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* CSSM_DATA --> BIGNUM */ +BIGNUM *cssmDataToBn( + const CSSM_DATA &cdata); + +/* BIGNUM --> CSSM_DATA, mallocing from a SecNssCoder's PL_ArenaPool */ +void bnToCssmData( + const BIGNUM *bn, + CSSM_DATA &cdata, + SecNssCoder &coder); + +/* CSSM_DATA --> unsigned int */ +unsigned cssmDataToInt( + const CSSM_DATA &cdata); + +/* unsigned int --> CSSM_DATA, mallocing from an SecNssCoder */ +void intToCssmData( + unsigned num, + CSSM_DATA &cdata, + SecNssCoder &coder); + +/* + * DER encode/decode RSA keys in various formats. + */ +CSSM_RETURN RSAPublicKeyDecode( + RSA *openKey, + CSSM_KEYBLOB_FORMAT format, + void *p, + size_t length); +CSSM_RETURN RSAPublicKeyEncode( + RSA *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey); +CSSM_RETURN RSAPrivateKeyDecode( + RSA *openKey, + CSSM_KEYBLOB_FORMAT format, + void *p, + size_t length); +CSSM_RETURN RSAPrivateKeyEncode( + RSA *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey); +CSSM_RETURN generateDigestInfo( + const void *messageDigest, + size_t digestLen, + CSSM_ALGORITHMS digestAlg, // CSSM_ALGID_SHA1, etc. + CssmOwnedData &encodedInfo, + size_t maxEncodedSize); +CSSM_RETURN DSAPublicKeyDecode( + DSA *openKey, + CSSM_KEYBLOB_FORMAT format, + void *p, + size_t length); +CSSM_RETURN DSAPublicKeyEncode( + DSA *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey); +CSSM_RETURN DSAPrivateKeyDecode( + DSA *openKey, + CSSM_KEYBLOB_FORMAT format, + void *p, + size_t length); +CSSM_RETURN DSAPrivateKeyEncode( + DSA *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey); + +CSSM_RETURN DSASigEncode( + DSA_SIG *openSig, + CssmOwnedData &encodedSig); +CSSM_RETURN DSASigDecode( + DSA_SIG *openSig, + const void *p, + unsigned length); + +CSSM_RETURN DSAEncodeAlgParams( + NSS_DSAAlgParams &algParams, + CssmOwnedData &encodedParams); +CSSM_RETURN DSADecodeAlgParams( + NSS_DSAAlgParams &algParams, + const void *p, + unsigned len, + SecNssCoder &coder); + +CSSM_RETURN DHPrivateKeyDecode( + DH *openKey, + CSSM_KEYBLOB_FORMAT format, + unsigned char *p, + unsigned length); +CSSM_RETURN DHPrivateKeyEncode( + DH *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey); +CSSM_RETURN DHPublicKeyDecode( + DH *openKey, + CSSM_KEYBLOB_FORMAT format, + unsigned char *p, + unsigned length); +CSSM_RETURN DHPublicKeyEncode( + DH *openKey, + CSSM_KEYBLOB_FORMAT format, + CssmOwnedData &encodedKey); +CSSM_RETURN DHParamBlockDecode( + const CSSM_DATA &encParam, + NSS_DHParameterBlock ¶mBlock, + SecNssCoder &coder); + +CSSM_RETURN generateDigestInfo( + const void *msgDigest, + size_t digestLen, + CSSM_ALGORITHMS digestAlg, // CSSM_ALGID_SHA1, etc. + CssmOwnedData &encodedInfo, + size_t maxEncodedSize); + +#ifdef __cplusplus +} +#endif + +#endif /* _OPENSSL_ASN1_H_ */ diff --git a/AppleCSP/open_ssl/opensslUtils/opensslUtils.cpp b/AppleCSP/open_ssl/opensslUtils/opensslUtils.cpp index 114b33af..14eedbcc 100644 --- a/AppleCSP/open_ssl/opensslUtils/opensslUtils.cpp +++ b/AppleCSP/open_ssl/opensslUtils/opensslUtils.cpp @@ -35,7 +35,7 @@ #include #include -#define sslUtilsDebug(args...) debug("sslUtils", ## args) +#define sslUtilsDebug(args...) secdebug("sslUtils", ## args) openSslException::openSslException( int irtn, @@ -174,6 +174,10 @@ void throwRsaDsa( case RSA_R_KEY_SIZE_TOO_SMALL: cerr = CSSMERR_CSP_INVALID_ATTR_KEY_LENGTH; break; case RSA_R_PADDING_CHECK_FAILED: + case RSA_R_BLOCK_TYPE_IS_NOT_01: + case RSA_R_BLOCK_TYPE_IS_NOT_02: + case RSA_R_DATA_GREATER_THAN_MOD_LEN: + case RSA_R_BAD_PAD_BYTE_COUNT: cerr = CSSMERR_CSP_INVALID_DATA; break; case RSA_R_RSA_OPERATIONS_NOT_SUPPORTED: cerr = CSSMERR_CSP_FUNCTION_NOT_IMPLEMENTED; break; diff --git a/AppleCSP/open_ssl/opensslUtils/osKeyTemplates.cpp b/AppleCSP/open_ssl/opensslUtils/osKeyTemplates.cpp new file mode 100644 index 00000000..738478fc --- /dev/null +++ b/AppleCSP/open_ssl/opensslUtils/osKeyTemplates.cpp @@ -0,0 +1,140 @@ +/* + * osKeyTemplate.h - ASN1 templates for openssl asymmetric keys + */ + +#include "osKeyTemplates.h" + +/**** + **** DSA support + ****/ + +/* X509 style DSA algorithm parameters */ +const SEC_ASN1Template NSS_DSAAlgParamsTemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAAlgParams) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParams,p) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParams,q) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParams,g) }, + { 0, } +}; + +/* BSAFE style DSA algorithm parameters */ +const SEC_ASN1Template NSS_DSAAlgParamsBSAFETemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAAlgParamsBSAFE) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParamsBSAFE,keySizeInBits) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParamsBSAFE,p) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParamsBSAFE,q) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParamsBSAFE,g) }, + { 0, } +}; + +/* DSA X509-style AlgorithmID */ +const SEC_ASN1Template NSS_DSAAlgorithmIdX509Template[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAAlgorithmIdX509) }, + { SEC_ASN1_OBJECT_ID, offsetof(NSS_DSAAlgorithmIdX509, algorithm) }, + /* per CMS, this is optional */ + { SEC_ASN1_POINTER | SEC_ASN1_OPTIONAL, + offsetof(NSS_DSAAlgorithmIdX509,params), + NSS_DSAAlgParamsTemplate }, + { 0, } +}; + +/* DSA BSAFE-style AlgorithmID */ +const SEC_ASN1Template NSS_DSAAlgorithmIdBSAFETemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAAlgorithmIdBSAFE) }, + { SEC_ASN1_OBJECT_ID, offsetof(NSS_DSAAlgorithmIdBSAFE, algorithm) }, + { SEC_ASN1_INLINE, + offsetof(NSS_DSAAlgorithmIdBSAFE,params), + NSS_DSAAlgParamsBSAFETemplate }, + { 0, } +}; + +/**** + **** DSA public keys + ****/ + +/* DSA public key, openssl/X509 format */ +const SEC_ASN1Template NSS_DSAPublicKeyX509Template[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPublicKeyX509) }, + { SEC_ASN1_INLINE, + offsetof(NSS_DSAPublicKeyX509, dsaAlg), + NSS_DSAAlgorithmIdX509Template }, + { SEC_ASN1_BIT_STRING, + offsetof(NSS_DSAPublicKeyX509, publicKey), }, + { 0, } +}; + +/* DSA public key, BSAFE/FIPS186 format */ +const SEC_ASN1Template NSS_DSAPublicKeyBSAFETemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPublicKeyBSAFE) }, + { SEC_ASN1_INLINE, + offsetof(NSS_DSAPublicKeyBSAFE, dsaAlg), + NSS_DSAAlgorithmIdBSAFETemplate }, + { SEC_ASN1_BIT_STRING, + offsetof(NSS_DSAPublicKeyBSAFE, publicKey), }, + { 0, } +}; + +/**** + **** DSA private keys + ****/ + +/* DSA Private key, openssl custom format */ +const SEC_ASN1Template NSS_DSAPrivateKeyOpensslTemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPrivateKeyOpenssl) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,version) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,p) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,q) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,g) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,pub) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,priv) }, + { 0, } +}; + +/* + * DSA private key, BSAFE/FIPS186 style. + * This is basically a DSA-specific NSS_PrivateKeyInfo. + * + * NSS_DSAPrivateKeyBSAFE.privateKey is an octet string containing + * the DER encoding of this. + */ +const SEC_ASN1Template NSS_DSAPrivateKeyOctsTemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPrivateKeyOcts) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOcts,privateKey) }, + { 0, } +}; + +const SEC_ASN1Template NSS_DSAPrivateKeyBSAFETemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPrivateKeyBSAFE) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyBSAFE,version) }, + { SEC_ASN1_INLINE, + offsetof(NSS_DSAPrivateKeyBSAFE, dsaAlg), + NSS_DSAAlgorithmIdBSAFETemplate }, + { SEC_ASN1_OCTET_STRING, offsetof(NSS_DSAPrivateKeyBSAFE,privateKey) }, + { 0, } +}; + +/* + * DSA Private Key, PKCS8/SMIME style. + */ +const SEC_ASN1Template NSS_DSAPrivateKeyPKCS8Template[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPrivateKeyPKCS8) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyPKCS8,version) }, + { SEC_ASN1_INLINE, + offsetof(NSS_DSAPrivateKeyPKCS8, dsaAlg), + NSS_DSAAlgorithmIdX509Template }, + { SEC_ASN1_OCTET_STRING, offsetof(NSS_DSAPrivateKeyPKCS8,privateKey) }, + { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | + SEC_ASN1_CONTEXT_SPECIFIC | 0, + offsetof(NSS_DSAPrivateKeyPKCS8,attributes), + NSS_SetOfAttributeTemplate }, + { 0, } +}; + +const SEC_ASN1Template NSS_DSASignatureTemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSASignature) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSASignature,r) }, + { SEC_ASN1_INTEGER, offsetof(NSS_DSASignature,s) }, + { 0, } +}; + + diff --git a/AppleCSP/open_ssl/opensslUtils/osKeyTemplates.h b/AppleCSP/open_ssl/opensslUtils/osKeyTemplates.h new file mode 100644 index 00000000..8adfca16 --- /dev/null +++ b/AppleCSP/open_ssl/opensslUtils/osKeyTemplates.h @@ -0,0 +1,187 @@ +/* + * osKeyTemplate.h - ASN1 templates for openssl asymmetric keys + */ + +#ifndef _OS_KEY_TEMPLATES_H_ +#define _OS_KEY_TEMPLATES_H_ + +#include +#include + +/* + * Arrays of SEC_ASN1Templates are always associated with a specific + * C struct. We attempt to use C structs which are defined in CDSA + * if at all possible; these always start with the CSSM_ prefix. + * Otherwise we define the struct here, with an NSS_ prefix. + * In either case, the name of the C struct is listed in comments + * along with the extern declaration of the SEC_ASN1Template array. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*** + *** Note: RSA and Diffie-Hellman keys and structs are in + *** SecurityNssAsn1/keyTemplates.h. + ***/ + +#pragma mark *** DSA *** + +/* + * Note that most of the DSA structs are hand rolled and are not + * expressed in ASN1 in any doc that I'm aware of. + */ + +/**** + **** DSA support + ****/ + +/* + * DSA algorithm parameters. Used in CDSA key generation context as + * well as the parameters in an X509-formatted DSA public key. + */ +typedef struct { + CSSM_DATA p; + CSSM_DATA q; + CSSM_DATA g; +} NSS_DSAAlgParams; + +extern const SEC_ASN1Template NSS_DSAAlgParamsTemplate[]; + +/* + * DSA algorithm parameters, BSAFE style. Only used in FIPS186 format + * public and private keys. + */ +typedef struct { + CSSM_DATA keySizeInBits; + CSSM_DATA p; + CSSM_DATA q; + CSSM_DATA g; +} NSS_DSAAlgParamsBSAFE; + +extern const SEC_ASN1Template NSS_DSAAlgParamsBSAFETemplate[]; + +/* + * DSA X509-style AlgorithmID. Avoids ASN_ANY processing via direct + * insertion of the appropriate parameters. + */ +typedef struct { + CSSM_OID algorithm; + NSS_DSAAlgParams *params; // optional +} NSS_DSAAlgorithmIdX509; + +extern const SEC_ASN1Template NSS_DSAAlgorithmIdX509Template[]; + +/* + * DSA AlgorithmID, BSAFE style. Avoids ASN_ANY + * processing via direct insertion of the appropriate parameters. + */ +typedef struct { + CSSM_OID algorithm; + NSS_DSAAlgParamsBSAFE params; +} NSS_DSAAlgorithmIdBSAFE; + +extern const SEC_ASN1Template NSS_DSAAlgorithmIdBSAFETemplate[]; + +/**** + **** DSA public keys + ****/ + +/* + * DSA public key, openssl/X509 format. + * + * The publicKey is actually the DER encoding of an ASN + * integer, wrapped in a BIT STRING. + */ +typedef struct { + NSS_DSAAlgorithmIdX509 dsaAlg; + CSSM_DATA publicKey; // BIT string - Length in bits +} NSS_DSAPublicKeyX509; + +extern const SEC_ASN1Template NSS_DSAPublicKeyX509Template[]; + +/* + * DSA public key, BSAFE/FIPS186 format. + * The public key is the DER encoding of an ASN integer, wrapped + * in a bit string. + */ +typedef struct { + NSS_DSAAlgorithmIdBSAFE dsaAlg; + CSSM_DATA publicKey; // BIT string - Length in bits +} NSS_DSAPublicKeyBSAFE; + +extern const SEC_ASN1Template NSS_DSAPublicKeyBSAFETemplate[]; + +/**** + **** DSA private keys + ****/ + +/* + * DSA Private key, openssl custom format. + */ +typedef struct { + CSSM_DATA version; + CSSM_DATA p; + CSSM_DATA q; + CSSM_DATA g; + CSSM_DATA pub; + CSSM_DATA priv; +} NSS_DSAPrivateKeyOpenssl; + +extern const SEC_ASN1Template NSS_DSAPrivateKeyOpensslTemplate[]; + +/* + * DSA private key, BSAFE/FIPS186 style. + * This is basically a DSA-specific NSS_PrivateKeyInfo. + * + * NSS_DSAPrivateKeyBSAFE.privateKey is an octet string containing + * the DER encoding of this. + */ +typedef struct { + CSSM_DATA privateKey; +} NSS_DSAPrivateKeyOcts; + +extern const SEC_ASN1Template NSS_DSAPrivateKeyOctsTemplate[]; + +typedef struct { + CSSM_DATA version; + NSS_DSAAlgorithmIdBSAFE dsaAlg; + /* octet string containing a DER-encoded NSS_DSAPrivateKeyOcts */ + CSSM_DATA privateKey; +} NSS_DSAPrivateKeyBSAFE; + +extern const SEC_ASN1Template NSS_DSAPrivateKeyBSAFETemplate[]; + +/* + * DSA Private Key, PKCS8/SMIME style. Doesn't have keySizeInBits + * in the alg params; has version in the top-level struct; the + * private key itself is a DER-encoded integer wrapped in an + * octet string. + */ +typedef struct { + CSSM_DATA version; + NSS_DSAAlgorithmIdX509 dsaAlg; + /* octet string containing DER-encoded integer */ + CSSM_DATA privateKey; + NSS_Attribute **attributes; // optional +} NSS_DSAPrivateKeyPKCS8; + +extern const SEC_ASN1Template NSS_DSAPrivateKeyPKCS8Template[]; + +/* + * DSA Signature. + */ +typedef struct { + CSSM_DATA r; + CSSM_DATA s; +} NSS_DSASignature; + +extern const SEC_ASN1Template NSS_DSASignatureTemplate[]; + +#ifdef __cplusplus +} +#endif + + +#endif /* _OS_KEY_TEMPLATES_H_ */ diff --git a/AppleCSP/open_ssl/rsa/rsa_gen.c b/AppleCSP/open_ssl/rsa/rsa_gen.c index 0a0125d4..6095dfcf 100644 --- a/AppleCSP/open_ssl/rsa/rsa_gen.c +++ b/AppleCSP/open_ssl/rsa/rsa_gen.c @@ -85,7 +85,8 @@ RSA *RSA_generate_key(int bits, unsigned long e_value, { RSA *rsa=NULL; BIGNUM *r0=NULL,*r1=NULL,*r2=NULL,*r3=NULL,*tmp; - int bitsp,bitsq,ok= -1,n=0,i; + int bitsp,bitsq,ok= -1,n=0; + unsigned i; BN_CTX *ctx=NULL,*ctx2=NULL; ctx=BN_CTX_new(); diff --git a/AppleCSPDL/CVSVersionInfo.txt b/AppleCSPDL/CVSVersionInfo.txt index 15e34ab2..2bc0c2db 100644 --- a/AppleCSPDL/CVSVersionInfo.txt +++ b/AppleCSPDL/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:51 mb Exp $ -# $Name: Security-54~1~9 $ +# $Name: $ ProjectName: AppleCSPDL ProjectVersion: 15 diff --git a/AppleCSPDL/SSCSPSession.cpp b/AppleCSPDL/SSCSPSession.cpp index ef698f59..e5954fe6 100644 --- a/AppleCSPDL/SSCSPSession.cpp +++ b/AppleCSPDL/SSCSPSession.cpp @@ -100,11 +100,16 @@ SSCSPSession::setupContext(CSPContext * &cspCtx, SSDatabase SSCSPSession::getDatabase(const Context &context) { - CSSM_DL_DB_HANDLE *aDLDbHandle = context.get(CSSM_ATTRIBUTE_DL_DB_HANDLE); - if (!aDLDbHandle) - return SSDatabase(); + return getDatabase(context.get(CSSM_ATTRIBUTE_DL_DB_HANDLE)); +} - return findSession(aDLDbHandle->DLHandle).findDbHandle(aDLDbHandle->DBHandle); +SSDatabase +SSCSPSession::getDatabase(CSSM_DL_DB_HANDLE *aDLDbHandle) +{ + if (aDLDbHandle) + return findSession(aDLDbHandle->DLHandle).findDbHandle(aDLDbHandle->DBHandle); + else + return SSDatabase(); } @@ -227,8 +232,20 @@ SSCSPSession::DeriveKey(CSSM_CC_HANDLE ccHandle, KeyHandle contextKeyHandle = keyInContext ? lookupKey(*keyInContext).keyHandle() : noKey; KeyHandle keyHandle; - clientSession().deriveKey(database.dbHandle(), context, contextKeyHandle, keyUsage, + switch(context.algorithm()) { + case CSSM_ALGID_KEYCHAIN_KEY: + { + // special interpretation: take DLDBHandle -> DbHandle from params + clientSession().extractMasterKey(database.dbHandle(), context, + getDatabase(param.interpretedAs(CSSMERR_CSP_INVALID_ATTR_DL_DB_HANDLE)).dbHandle(), + keyUsage, keyAttr, cred, owner, keyHandle, derivedKey.header()); + } + break; + default: + clientSession().deriveKey(database.dbHandle(), context, contextKeyHandle, keyUsage, keyAttr, param, cred, owner, keyHandle, derivedKey.header()); + break; + } makeReferenceKey(keyHandle, derivedKey, database, keyAttr, keyLabel); } @@ -283,6 +300,15 @@ SSCSPSession::GenerateKeyPair(CSSM_CC_HANDLE ccHandle, owner = &AclEntryInput::overlay(credAndAclEntry->InitialAclEntry); } + /* + * Public keys must be extractable in the clear - that's the Apple + * policy. The raw CSP is unable to enforce the extractable + * bit since it always sees that as true (it's managed and forced + * true by the SecurityServer). So... + */ + if(!(publicKeyAttr & CSSM_KEYATTR_EXTRACTABLE)) { + CssmError::throwMe(CSSMERR_CSP_INVALID_KEYATTR_MASK); + } KeyHandle pubKeyHandle, privKeyHandle; clientSession().generateKey(database.dbHandle(), context, publicKeyUsage, publicKeyAttr, @@ -330,6 +356,7 @@ SSCSPSession::FreeKey(const AccessCredentials *accessCred, // Find the key in the map. Tell tell the key to free itself // (when the auto_ptr deletes the key it removes itself from the map). + secdebug("freeKey", "CSPDL FreeKey"); auto_ptr ssKey(&mSSCSPDLSession.find(ioKey)); ssKey->free(accessCred, ioKey, deleteKey); } @@ -502,16 +529,68 @@ SSCSPSession::ChangeLoginAcl(const AccessCredentials &AccessCred, // -// Passthroughs (by default, unimplemented) +// Passthroughs // void SSCSPSession::PassThrough(CSSM_CC_HANDLE CCHandle, - const Context &Context, - uint32 PassThroughId, - const void *InData, - void **OutData) + const Context &context, + uint32 passThroughId, + const void *inData, + void **outData) { - unimplemented(); + checkOperation(context.type(), CSSM_ALGCLASS_NONE); + switch (passThroughId) { + case CSSM_APPLESCPDL_CSP_GET_KEYHANDLE: + { + // inData unused, must be NULL + if (inData) + CssmError::throwMe(CSSM_ERRCODE_INVALID_INPUT_POINTER); + + // outData required, must be pointer-to-pointer-to-KeyHandle + KeyHandle &result = Required(reinterpret_cast(outData)); + + // we'll take the key from the context + const CssmKey &key = + context.get(CSSM_ATTRIBUTE_KEY, CSSMERR_CSP_MISSING_ATTR_KEY); + + // all ready + result = lookupKey(key).keyHandle(); + break; + } + case CSSM_APPLECSP_KEYDIGEST: + { + // inData unused, must be NULL + if (inData) + CssmError::throwMe(CSSM_ERRCODE_INVALID_INPUT_POINTER); + + // outData required + Required(outData); + + // take the key from the context, convert to KeyHandle + const CssmKey &key = + context.get(CSSM_ATTRIBUTE_KEY, CSSMERR_CSP_MISSING_ATTR_KEY); + KeyHandle keyHandle = lookupKey(key).keyHandle(); + + // allocate digest holder on app's behalf + CSSM_DATA *digest = alloc(sizeof(CSSM_DATA)); + digest->Data = NULL; + digest->Length = 0; + + // go + try { + clientSession().getKeyDigest(keyHandle, CssmData::overlay(*digest)); + } + catch(...) { + free(digest); + throw; + } + *outData = digest; + break; + } + + default: + CssmError::throwMe(CSSM_ERRCODE_INVALID_PASSTHROUGH_ID); + } } /* Validate requested key attr flags for newly generated keys */ diff --git a/AppleCSPDL/SSCSPSession.h b/AppleCSPDL/SSCSPSession.h index 6b97dad4..fefae7de 100644 --- a/AppleCSPDL/SSCSPSession.h +++ b/AppleCSPDL/SSCSPSession.h @@ -62,7 +62,8 @@ public: void setupContext(CSPContext * &ctx, const Context &context, bool encoding); - + + SSDatabase getDatabase(CSSM_DL_DB_HANDLE *aDLDbHandle); SSDatabase getDatabase(const Context &context); void makeReferenceKey(SecurityServer::KeyHandle inKeyHandle, diff --git a/AppleCSPDL/SSContext.cpp b/AppleCSPDL/SSContext.cpp index 4ea3794e..25495bbd 100644 --- a/AppleCSPDL/SSContext.cpp +++ b/AppleCSPDL/SSContext.cpp @@ -25,7 +25,7 @@ #include "SSKey.h" #include -#define ssCryptDebug(args...) debug("ssCrypt", ## args) +#define ssCryptDebug(args...) secdebug("ssCrypt", ## args) using namespace SecurityServer; @@ -286,11 +286,14 @@ void SSSignatureContext::sign(CssmData &sig) mDigestAlg); } else { - clientSession().generateSignature(tempContext, - mKeyHandle, - (*mDigest)(), - sig, - mDigestAlg); + CssmAutoData d (mDigest->allocator ()); + d.set((*mDigest) ()); + + clientSession().generateSignature(tempContext, + mKeyHandle, + d, + sig, + mDigestAlg); } } @@ -445,7 +448,7 @@ SSCryptContext::final(CssmData &out) if(!inSize) return; const CssmData in(const_cast(mNullDigest.digestPtr()), inSize); - unsigned origOutSize = out.length(); + IFDEBUG(unsigned origOutSize = out.length()); if (encoding()) { clientSession().encrypt(*mContext, mKeyHandle, in, out); } diff --git a/AppleCSPDL/SSDLSession.cpp b/AppleCSPDL/SSDLSession.cpp index fb69ba3d..ce5ca527 100644 --- a/AppleCSPDL/SSDLSession.cpp +++ b/AppleCSPDL/SSDLSession.cpp @@ -172,7 +172,6 @@ SSDLSession::Authenticate(CSSM_DB_HANDLE inDbHandle, CSSM_DB_ACCESS_TYPE inAccessRequest, const AccessCredentials &inAccessCred) { - // @@@ Use securityserver. SSDatabase db = findDbHandle(inDbHandle); db->authenticate(inAccessRequest, &inAccessCred); } @@ -531,6 +530,14 @@ SSDLSession::PassThrough(CSSM_DB_HANDLE inDbHandle, db->changePassphrase(params->accessCredentials); break; } + case CSSM_APPLECSPDL_DB_GET_HANDLE: + { + using SecurityServer::DbHandle; + Required(outOutputParams, CSSM_ERRCODE_INVALID_OUTPUT_POINTER); + DbHandle &dbHandle = *(DbHandle *)outOutputParams; + dbHandle = db->dbHandle(); + break; + } default: { CSSM_RETURN result = CSSM_DL_PassThrough(db->handle(), inPassThroughId, inInputParams, outOutputParams); @@ -546,7 +553,7 @@ SSDLSession::makeDbHandle(SSDatabase &inDb) { StLock _(mDbHandleLock); CSSM_DB_HANDLE aDbHandle = inDb->handle().DBHandle; - bool inserted = mDbHandleMap.insert(DbHandleMap::value_type(aDbHandle, inDb)).second; + IFDEBUG(bool inserted =) mDbHandleMap.insert(DbHandleMap::value_type(aDbHandle, inDb)).second; assert(inserted); return aDbHandle; } @@ -580,7 +587,7 @@ SSDLSession::makeSSUniqueRecord(SSUniqueRecord &uniqueId) { StLock _(mSSUniqueRecordLock); CSSM_HANDLE ref = CSSM_HANDLE(static_cast(uniqueId)); - bool inserted = mSSUniqueRecordMap.insert(SSUniqueRecordMap::value_type(ref, uniqueId)).second; + IFDEBUG(bool inserted =) mSSUniqueRecordMap.insert(SSUniqueRecordMap::value_type(ref, uniqueId)).second; assert(inserted); return createUniqueRecord(ref); } diff --git a/AppleCSPDL/SSDatabase.cpp b/AppleCSPDL/SSDatabase.cpp index 03cf8817..31cffa8a 100644 --- a/AppleCSPDL/SSDatabase.cpp +++ b/AppleCSPDL/SSDatabase.cpp @@ -55,6 +55,14 @@ SSDatabaseImpl::insert(CSSM_DB_RECORDTYPE recordType, return uniqueId; } +void +SSDatabaseImpl::authenticate(CSSM_DB_ACCESS_TYPE inAccessRequest, + const CSSM_ACCESS_CREDENTIALS *inAccessCredentials) +{ + mClientSession.authenticateDb(dbHandle(), inAccessRequest, + AccessCredentials::overlay(inAccessCredentials)); +} + void SSDatabaseImpl::lock() { @@ -94,7 +102,7 @@ SSDatabaseImpl::setSettings(uint32 inIdleTimeout, bool inLockOnSleep) // Reencode the db blob. CssmDataContainer dbb(allocator()); mClientSession.encodeDb(mSSDbHandle, dbb, allocator()); - mDbBlobId->modify(DBBlobRelationID, NULL, &dbb, CSSM_DB_MODIFY_ATTRIBUTE_NONE); + getDbBlobId(NULL)->modify(DBBlobRelationID, NULL, &dbb, CSSM_DB_MODIFY_ATTRIBUTE_NONE); } bool @@ -111,7 +119,7 @@ SSDatabaseImpl::changePassphrase(const CSSM_ACCESS_CREDENTIALS *cred) // Reencode the db blob. CssmDataContainer dbb(allocator()); mClientSession.encodeDb(mSSDbHandle, dbb, allocator()); - mDbBlobId->modify(DBBlobRelationID, NULL, &dbb, CSSM_DB_MODIFY_ATTRIBUTE_NONE); + getDbBlobId(NULL)->modify(DBBlobRelationID, NULL, &dbb, CSSM_DB_MODIFY_ATTRIBUTE_NONE); } DbHandle @@ -121,7 +129,7 @@ SSDatabaseImpl::dbHandle() if (mForked()) { // re-establish the dbHandle with the SecurityServer CssmDataContainer dbb(allocator()); - mDbBlobId->get(NULL, &dbb); + getDbBlobId(&dbb); mSSDbHandle = mClientSession.decodeDb(mIdentifier, AccessCredentials::overlay(accessCredentials()), dbb); } @@ -172,7 +180,7 @@ SSDatabaseImpl::create(const DLDbIdentifier &dlDbIdentifier) mSSDbHandle = mClientSession.createDb(dlDbIdentifier, cred, owner, dbParameters); CssmDataContainer dbb(allocator()); mClientSession.encodeDb(mSSDbHandle, dbb, allocator()); - mDbBlobId = Db::Impl::insert(DBBlobRelationID, NULL, &dbb); + Db::Impl::insert(DBBlobRelationID, NULL, &dbb); } catch(...) { @@ -187,11 +195,8 @@ SSDatabaseImpl::open(const DLDbIdentifier &dlDbIdentifier) mIdentifier = dlDbIdentifier; Db::Impl::open(); - DbCursor cursor(SSDatabase(this)); - cursor->recordType(DBBlobRelationID); CssmDataContainer dbb(allocator()); - if (!cursor->next(NULL, &dbb, mDbBlobId)) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + getDbBlobId(&dbb); mSSDbHandle = mClientSession.decodeDb(dlDbIdentifier, AccessCredentials::overlay(accessCredentials()), dbb); } @@ -202,6 +207,20 @@ SSDatabaseImpl::newDbUniqueRecord() return new SSUniqueRecordImpl(SSDatabase(this)); } +CssmClient::DbUniqueRecord +SSDatabaseImpl::getDbBlobId(CssmDataContainer *dbb) +{ + CssmClient::DbUniqueRecord dbBlobId; + + DbCursor cursor(SSDatabase(this)); + cursor->recordType(DBBlobRelationID); + if (!cursor->next(NULL, dbb, dbBlobId)) + CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + + return dbBlobId; +} + + SSUniqueRecordImpl::SSUniqueRecordImpl(const SSDatabase &db) : DbUniqueRecord::Impl(db) @@ -217,4 +236,3 @@ SSUniqueRecordImpl::database() const { return parent(); } - diff --git a/AppleCSPDL/SSDatabase.h b/AppleCSPDL/SSDatabase.h index eb590ac9..7f4e9c0e 100644 --- a/AppleCSPDL/SSDatabase.h +++ b/AppleCSPDL/SSDatabase.h @@ -50,6 +50,8 @@ public: SSUniqueRecord insert(CSSM_DB_RECORDTYPE recordType, const CSSM_DB_RECORD_ATTRIBUTE_DATA *attributes, const CSSM_DATA *data, bool); + void authenticate(CSSM_DB_ACCESS_TYPE inAccessRequest, + const CSSM_ACCESS_CREDENTIALS *inAccessCredentials); // Passthrough functions (only implemented by AppleCSPDL). void lock(); @@ -66,6 +68,9 @@ public: // New methods not inherited from DbImpl SecurityServer::DbHandle dbHandle(); +protected: + CssmClient::DbUniqueRecord getDbBlobId(CssmDataContainer *dbb); + private: enum { @@ -78,7 +83,6 @@ private: SecurityServer::ClientSession &mClientSession; SecurityServer::DbHandle mSSDbHandle; - CssmClient::DbUniqueRecord mDbBlobId; }; diff --git a/AppleDL/CVSVersionInfo.txt b/AppleDL/CVSVersionInfo.txt index 5b03166f..60b80956 100644 --- a/AppleDL/CVSVersionInfo.txt +++ b/AppleDL/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:52 mb Exp $ -# $Name: Security-54~1~9 $ +# $Name: $ ProjectName: AppleDL ProjectVersion: 13 diff --git a/AppleX509CL/AppleX509CL.mcp b/AppleX509CL/AppleX509CL.mcp deleted file mode 100644 index 687e67756a3914308041ea7b6158945697e6e842..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 103293 zcmeI531Ah~)yHRELN*rJ1VoVsE{H$^3J7r{BrL&1A_2jzdR$FT~m$tTc5w~u%ZeJI>Siax6_s)AW@6Gbi)S{USXYT)r=hG?cKe}rrz#t z>DGRyXo%#A5tfxmTGsOAmbH>L%Wtd2(k9w$@{}=#otSphZt!?0VR+NYixSg5b|3jn zs2Dt#d=WIvvW^ymu7FA)No%3f#I);1lZ)OmtK@fICGUpHAxV8ug+i8f3Hfm3o5-(* zMpz|}-$VWhXe1=*7HE`0mL+8eAU{C<5H#8+u3&Q<^;rV`5O@*wnFRhkcrkPY zco%s!gx!iBBtIUaZAHH&KLI)#{5<)I5XUbbPJR-E9g3wN#75MqSn9O|;@HLF!!;18 zcq5yo3R=bIk=GjhPVzc~uP2xGkc!1V;wz-$yV-~?Qt^-3U`t8Gzh+afpjG@Q@>K@^ zll&BoheH}8Z7lZ)nLh28{9_TWU%<#X$F6se2u|3lQ$cD7x`L)r61QB{3!Y9 z20u-{-r#?eiw}`XMzA?UL90ak{Y-+SEzeQVDv^3gf0Ig5Y{b5# zl1?@)g1{HCkup+=_`oIwt&*$ATMhm&xwM&7@@Y0{1+9`>$u}GP1M)2f|AKt0!G9!g zH~6pQ+YEkze7nY_733WTPbQc84V7fm&^1K6O=1XA&1PF9pcG0b*gzvyW;^2?zjBk_ zSM9@qB!kjOw4&42YQ?GpD4i!K2a>OqIZ_EU9IAlIpmJygG!l&^&~T^%Duc?Q5zt5( zqb}YnYV)>b`uNg7kgg@_6p)P&Dh^ncIyY6@k?QM9_f?+X-Xpr)>CF13leF!Aa6S(=d)P%xR_^j{}!;5PCPF z-^$mlUTsDQU8&*~Yu1?|#wspt?%vVcn(h--%j+AKp?0LnN4VsQ%Gad(GLn|7#2!_1 zYIA+Ep?yGGHg~`iIF0C7B`g8<4txTud(!G6^Ci-<- z%+{Dm`b{X4{Cq!}m)YGH=mRXFY$+uDFXPT^NY1AXkc|Ce;6_Nsb~z^!8S0!V=Q}ws zPKRX7uZLDaGa)%w%z_Ssj)ulVGS18SM#eK4$Cg3jf8t>>w#|X6plOh#k&v7(W$c%6 zUdDGhZ^-y5=YTp$&JofIImgPFUky!!WXzYrVHC6+S^>#8KNpg7znlveLB~OdK$9Rj z?@ob^gd{djf|8J&PfmoULNe~kx$huo26PleRLa~*jYFf!+aWp6oC8VEkAtMA%TV;Bu#7vxqoCRcvk4o9;PO?`f^#0A1MDcj0IY!VN^j@^cA9uL4nw(AG6 z;jii;^;LYjh))267zD3ORq+YnmDz9mRjrq%`r2EQYx%?GrtY1|#vL8~?bh=4-oE~1 zb9zf>x~t!+*7I8y&yw|>J>9+i$%Ttfu^OA!yMHcCb#!!hcO_S*J9@0f^~u_*+F7%- z;QC}!s;@QGp?gAbwD1NqD^3$mVSXH9Ay`$rG(#*cfR?GFHx39O=QrE$oQ>|&L zVKt`ux2n9kA-QHpSATnFT9i1f+Dgx_S+lagQ?09;D?73(Fm!Tx>ZtkcRg2nYW)v8m z6lPepl^M~EZc#eHr^IW$c({MmUMD8*D+4JVXJoM^o9B9SjDu}|LD#2tJiIi z<7eurIZpeXL%I8$GItfMYHwxhmMvYk0#DkW;{sW}?+&8XPm%Chwq4zv@h)nMH9Raw zH%=eG_uV01w^pQD=+)$N(EPpgIlAXObrRN!RA*Z5KuFehcb%K=WrfCC-jUwPoe1fk z-fq^>`?`CrrR{x$tB2KyziLN1>X`PdyE#6TWorMHKF{#vM_qc;jx9+~%Ou!*`69o( zy^B#HU*3;TyK*FJdU`tATT}h*-CYv=W?>&~u7&%YRsU*N*tS~kUn+>Jm$r9RYa>u? z<+E9qD@;vq*LHVyc6U{KLf>2D3+%p4@q1qgkQwNGn-9&mtNB1TiC|ec% zXQJfV-ZX#W$u!Ow*=kDnb{JKh9psl)El!l)uwd@u+6K#oD_eVd+`svgTpxa>*!$Jl zdr&GPe@>A<)u{aDFE8d#F6X`@S95&5k!z75`CI;!xRgzHjZ!ZlY`^)-$8Fua_xgVf zNvp(-77NtzH^h9uxNhEqd-pyde=?2JP_)1>Tq5fgL(u}N&D<|A(KFReW-luWG|I`O znx-c1-mnKY>?&}l5HZo0DbD|c6h-zxrhIS!j!>Sx)O=AoGggq>Zi?#~R%~e9-rgoN z#`Voy%}L^KY@RzGwx#m^E-iOcHLgEX-(qB2!?<}{Zeo(X&Fwtg^&t}?VdzXjDO7@T zB21_|YqF)m$f#BVE_FWj-&eiC$JF=zgq6FhL#2vxu8`GQP<8ILhW9F3%XqFo`~-5Z zN&IATu2b@trK&yGE`BQHqSCq42r930Uw#A$nd_{eV(0S2uRP}(Dp(|Qf#fT)yphKE zc8KTV%Wq$~k5E=}dRWW}EDvjfQgC{s@6LJ%(;=)c2K^3^drcT36KV#z$_wjIDUa+> z5en&0DVFO_-#SW}d440HJbQiWC*Zke^%Gd%-nB;BXfA90M0PG(7-|G54{4tiJ8dvI zD=(}GG_?2SItc4(5dkj}A>l5?;lVBvVWBSNA%QN%!C~%{hWLad;%hOd(6N`dJESx; zyt4uUUabWDLR$(#0$YlM!#YzMTy6i5mK~!4T4ch**(DLu?BGyV`-cazBNEtY{z2^Q z7Hk*x3kqP_IV60gI5c=gAUJfL(!dtE!xlI6{{6!*NOL4|gEXhuCrEQ7@`5y{JU2*l zigSY0r!+T6eMGX>@hNomYEEf>kopR^y){=L6Qnr>xj~v!oD-yerNPy91!>NXzCoHJ z;}fL*5+Tjb3DVsCeS*|SB(T$5LF%(xuw8P4G-v1BAk8Vx57HcgoFMfn4Qx?Pkh=bm zN}c_JG)E#gNOOvPf;2}WFGzFBbAvReI44MbN^^tMMBhKIYH`I8eDBxkml^@8>BfhK0)d)5z_3OAkE$1CrEun0z1tWq&~X^+a)(h zb9T-R(wyS_Ak7iT2~wZZz!n7uDSuRq2vU&<2~sHz4^oi`3sNZ$2~sHz4pOHyBuE_* zU+Xx9{=F)tp+TAz2=G=V;1{G)5E7(P92}&X(%@?Q2dV5B6{I2)9;7abkY)!5soFn0 zNF9;DPV)~^XSZOxgaoPV91^5b92%q|5FDgVX<&hW+lVpG*2$F z_Q5gh(iI-LUcrd|@sDD!im3hziRi4Nkhs=DXo)xxX5}KIOOzE7T_P79T_P13T_O|} zU5-p-bUA_{z2}I8^^V9C5M5cZQ2$h7!OA&N6_+6R*@&Vw0)i1Y4ORtxXPFCL{xrpZY!y@I~I(p%0wO=n|o*=yGHtqstKt z={-jztan7FfauDKh5Dxw3yv-+j*Ko5DlEE0vXJO<$wk&4*?{v>*0)5ap#BlTi2e}~ znU8r-Hr``J^&dL2^RXaBA<@PD5pg9FArU3T;jttVVNoRIA@L){!I9&XhV+Re;@cZe zp}(D_G&Dl80s-Eo1pJ~x3PR#RilZVyWWr;>B@t3Tqyqe2?H}&(j!2+&MSH%NJG%wj z9f=^%mYqXcw3LVVv=j&Xv{M@5(~gL*)ty3r+e&Gu zPiF-Jd`1cQ`Lq;-__P#9`LxJ{`?O0Uq<-Rc{?{04|8SpnL;|fV+Vg$d*)7=aAwDfT zhxl}Ms$?EhQ;!{ay*ewSA8rd3asM?TNR5*5Z%y`C&R-USl;o_D2Z^~?%EM%Q`y^W% z_o}&{8W}pGEGRM&78H>v3ua`(ESM4E?!ut@7GOb96JeBZjhYk+#4j6dj<}Y^PY!;q&#QiAR*y9XN@o!&zU()&{#7} zB+{npnbXYuutBQyDLr#W3>4Gn?Vw`M**i$c?YyBfQB89kIY@~f5ZwzcL6W&sh6uSx zGvV-&jvz7xIf4jAID&}Cgd(usQf_X$4w1=Dn1h5oQ;Z;?oM9wL%srTd$wahW)HrQZ zHqC!%K5t+NlJg8KK|;9$OOTv*UmB}gb|UFF|T@Ru{s>G7%FfmYuQqRmd~21nF=O zETJ+{O>+j8ASL+&OORylz!D)BX(ox2C`VASQGkdS9!2@=W~Sc1gd z1521pMBCj13k$;D_j~2dRq`b~gGqjI?l6)s;T=Ho%RNI!ezAMd@GtdviNA=kk$<5R zNBN~WgF}!&#@~Ge^nj3G;28??i`|1jKxuHboxsoEF+b$@z)q7w31@%J!FFN4YzXJ?>^LfdiUf*pU)orpRUYn+jRH_Udk=cyp1lbR(0L2p7X5V5v7I8cDAN@qg{8GyhTr5 zaVJXs8sS$xKRIvp{3OI2xz+QN3#^`BTVzPedo5m&frRfX>{pFI&3?jxn*Hjm{DKwV z&Qw>MM3(lTKuJANWL|F=)HpF)!Hx5;f?vy&q)!$6WCN?<*EY|)3xgV^c9a)3X5MKS z5RtBT9f~f$+T|V4PssOxeuAz8M!s<-7TCWnU|YTEEmZMvNM1)IX&F?+8<6YB)>>M9rY}_1boQa^iGk#4m_oQcq45r`WE=m zEu-p0Ui43ukJ^Ey{>dG@wH33>bQ@Scm3ElCumvpkIXto8xtqZ6 z0UrU8ioeX}NCmCppOMcnSoF*1%t*uJQ)DxtB={Keqc^tlB3Nr!Gk8{F!Q=GFFxt-sgYJVt`&(GCre<+hr z*41f$D3dSv@HSoXhceN>T>C@WEnuQT{Gse2@Jj6uWzU1_wLg?gU#!ypP%g1>iuQ+c z`5a$^_J?x(RehrGO2X#NU@61K<)0y64cXuyk~cwo)u{Yw^3xz*T~;BV*;@mR0*ij> zV~$zTNWK;t50*Gz2k~jWic87G&l2EIkgtdMgkHtB$v0G}7_WE&Oe__TCR~xT&Xjk@ zgQtSel6S|0Ph@kpygME&adD0%uRgbiUj%*)^9Yf-md!?al{|PCxJBL_4}Juk()J%N zakok4{0s+4aI3sK9xVFXbcZklX_ z#Kku7&lzIIg13Y30nY|^7|ijkPJ?^FT?Stb?l$;K;2wiT|7#6?4&1Bps1e{kgO3LH zgE{Uf{KMK|@K*4-VC*pJ3h;S}g%|aJuLtk6O47dq-vxdhFViPRM?D5Uf9dYp-3*1r z;0spnt`~e5_`*|nuNI77TCZQbd!67k_@Xm+pC$NB;EP*!rvzUI9@xBli{QJ#Z_xHX zK=fat$Dh$a>y3K+89fdBCYhcy>@Edg+S;G21500ACKEHT#NC_aCDh<+z?Y|+Q=7rJ zf~9Rq@cra((c{nPzk=VY$Dc9yqV+aC{)|}+e!Cuj#)v<@10szP{qNM{&zSdtuhiqu zm@k5_(&NvVAA{ee$Dc7zf#0pipRp1bSL^X-Y$f=7?u|ENSK#xCT{|)}29)HG72Y*P9IpbDB~uV{?Oo)`7#x zZ!~y5`KJvQ+sc?iI`BL;pHy_Aoi4iB274kjr0L&!kKI& zHb@f&*nC+KSn7MTg4TrZk$=VD=g1{iNfQrbBX%K86d(Aig4V0yg4*q~sZF{;8mq6dw>9k&>TeBjXV%DZVD{BqgPe z|54DICjBCQK$^BtO(Qfu3v4TBO}iAFFqkpGE;1N@v5O6+F7_~ur%wl$7`zNDwjfPU zgUbxQ0$gq|V~Jg1FurLIHyC@^BQ!p2JXppT(qU51Q3jt5KEU7|V6hSDuy=#U7<>zO ztihsxoWb;ujb2HIQ*Iw<@Uh?t1~-7kMx?{>D|?c`?*t!Y@E5_84Ho?e8!Y+{(fA0d z{}hAgfn~fP9dQbHs=@8xq`{Yirx|=b7@JBuf_}6QGZhf@!Cu z8KVCfgGE2~l{7=@KVRdchJhCtj6H1nSkh4^f{!!!Z15t3F90t#_@m%zgYN_%Z?M$= z1dV6nQ#QIJ&7^(yNd~V0(*{X1&jl}0(3<&vaE-yYgO?i2m}J*#d^Emq*BOjm?PUfx zf|ncI30`6F)!>x|e-%vMNILqL;8h0i1>+NvX5lY3{--eQv(c;Y2Joo{p9fxT@KxX@ zgTDkm&EWgMv{TZoKZBb!o-H<6YcRfGuQQms+ov1c23~LQ8^Ih~((Dg|&oKB7@RxZU6vz}qygBIa!NmsBNo=r9<4Hhn3n>Pm2z!P1Z22JZ&< zXgs$V{91$OfO`$5f9yVkk+u5`7T;j}k~CN9i7zVr8!&w=X`aN$PJ^YtUS}{qVxMoY z=)Az-Yrq#8d^`B{20sbDNaJI~2QD^vE_lFT{K9^N!R%*WV(_(K{6Nw%cY)tz@E-7` z8Xr3re3`+F0rr~>#;5Gd4W_>K6$XD4%y=Z}*l&X0YVaSx_=KeSW591Wcro}L2A>0F zES5B%W7=05d?WZOgTDvH4PwfvId8TeWSt%d&pe@x@!rhuXHG}CN`!<7b2Y=n*$H3pv`1leqWs;7s0^ecq8ZbU5>G*TOyA-sJ zr?2d98GIM`PJ7peqrBZFgk2}NYV*=!1ro= z;sN0A8@veo1B1^3|IpwIz&|n=-?4veu+;NDgZ}`&U*nTTgC8(>J{X^nbkch8PYf2F zKQ&m|jxS0&3H#X(8T=dY&kdG7`h~_PPXRw{@bTbZ8vGjYuM8Ibzc!e-vC$>zWctm< zpA=?4d$+-V0Y9qol5t@AQqq!nVERDeCh!vmi{CzJFk^%LTZ3-`|IT1+VE^9WXTaD< zQjO^Uqrr2*^oOJx@wY!2ycNvYA*trg;HM1!6!>X_>1P|gl4_`n{jA37Gda&0oP_^> z1}_KGPDx8Uz<)LPYVh9-CJyYs8!YyJUgO%~V8#eZwa0@0Y4AGmzYKmo_}>P98vKI6 z^rub#NvbOb?==|PCN#9_=sP}zpi7NAqOIk*K62lBW4qRez8@SZq zE5Kz2e+gV}Fn*V)Fqn2E&?Ra4Vc-!O54Ek#ePqrfa~+xE$lS?pfzr@sXbW^Uv=I{D zY=^c%+ad9#PN)m&hI*jaLcLHQ)DP`|=wq2@$oxX)6*8ZYbCjH$KXw z9rSVN8t8-2C!kM45(C#mH$XQ+;%lFQJ_~WqkaLBcBjns5=L9)d%K1Rf12X=raepa2 zTnp7f%b=5>8i*LNRzNGE6QLzgJ+uls1!{mAp;MvNP!n_-v<7O1)xyE7#b9Y)HFP|50>5diTF;}cYWxQCErV43)Ml(AXu_? zCTnK0Rwip?vNk4bVzL${YhY^a>#yX?p%u_ds2(~JngJaJ&4i{yM?gnIv!L0~H0W?> z4pa$ML35#b&@s@l(0phCv=BNDIt)4h8V!ws#zMoPW@r>N4jK;~2vtBMp|#KiXdQGq zv>uuWO@fFQS@V*$E?MJ}wJllGlC>;535|d@KxaT_LT5o2Ljw?Ylxs`5rj%<{xfYdc zO1YMlYe>14l{tgVjpUkD=0$Qni8(Esev^5LTvN)mq+CPFTuH7U<+@R>7iEqi*NSqD zD03dUK9uW1xgM13K)L>t`H5T`%k`gJ_sJYf<~VZQC)ay&4I$SKGEb802Dx64>kzrl zkn06|7xXRY7WNZ+;Wu(UB6BjiR**T8%=2V^B-aaaogmi-GEb9h1Gy%UYXO<-$aR3s z|79K~bAOrh%UoaP_%gSbd6HcB$lPA$^fJGbxt7f7)m$FC4{{oT6WeMmO)Qb|lwZ|@ ze27@xE7Jl5pS72?M5>>_FU(DFJ9^}k@UfSOS%zYA`9+ELi{^%E>%4UD_P%6uKeu$I zdgZQ8`9AmS^vAVhUl|I1;_?eQr`Xli)hpAfwsdb_H8=89w|DimZ`sC=eZq--8Rh>a9mUkV}bY@W9amCAuZ*~*_-5y5vP}CfsGsc z`cv`%!~ZVXR;j+T%-*=My{o;S8*1CnPw!)WR6AHfeMybkxUoOo+u7cg>fhJH%NjH* zJh^Fjs;8$Ty>=7N5J~{E!JCnAZx=+io!>#EStK?2cfZr+pDy)-NpTo`19l5CM zKu0cLgO~H-<#hY3TU+NEjY(;rjlzswq3blH)!PcN(y)WYJUi z&!*3=-ELdOww-8Fas&*6gls+jseZG`=u-?iUfS{DB=zkYFwYx??L2ETYkz%!(6*;!`jO3-ZsDTec>rR zJ*`{A_KB*`06RN+X3YxLRJfk-DH zeaZSxxn(Rsu)U#vX+Tki&Fw@+Niv}4xfy%)(p8xq0>J7`+amSIu9c|(1%_QneUzTI z?r=kgA4Waop!9Ue`*ea+!S(45)*&SY+oyZewlGZv>52dD7iPj2S+-yN-A`t(aT?MV zXl$-uHm1Idzq@v&`+3`HPe*rent%IZl=`&ZtunncZOQKYvU4o^s<6P0RrPCM6%C0S z5nJHJTEMxF=Ed&MerjIuznmP%3R#@;Ex^_EM14#2+V1X-O@8;$$lWY8O-&74W)Enx zmhf=%u6$*K%!%)#@ipj>zmKNavoh~%qey0gHKoD1PLMS!)~6~?U43dz& z!>I9#3hfv1vy`!0$Y~@qUfA(7bFoJZbqfT1(q`zGg?o15r|5@HcSp8#7-tAMNeuB+ zrtf9rhA+8iL?=NITUm0_0`iMnuf}*6TJ)Dmoc#*O-3u{;vHaqCOo^A*>6=Bp)sO|B zK}{o#+l;^z=JgDf{r8;=V~{46lJAFQnGZ0*TDQmNaLvDE)| zK{$K!Z?uV}^THDns`t!@t%c==E+-XN?VVdZciA)gcd=D`<}-71%A1PkE*~woC|gG# zv`fmJeI=Lu-M?czI2PF2-``VRRke-rqOxyCS7mE=XH`#cciWEE{=TYhZQHBnRnDv8 zMyS53R8M==;2d**(sJ$0nx}1Rdh^^9th?~f0adq|58b5v&rY#ee8lJHPF=TJ`Cr-8 z6D-a9fbgm+R_?UQm(Ea9muEQksw#WL>AUKz`dw9)lpT3XrYu3(NKaW-QxRpOJY^SU z_A93B08iPbOxZBXMtjPZXUa+_8|NuII#X6o*;r56sJT;DuCJ=H$4jkeU#Qwwwz8Yg zHS&7~M^v2gCs)~%PrdCwr?1?#cC~Kd5kFziZmW1@w|$7n&YGYkC#YH6{?y(3MO_#v zOP!l?UFW?0?+-Js%HwuPetdaq|X$?=3DpNZ|VPINS zv&P&V>wl}&682PjwzO{!R6;=^de$_rsSVRnNLdR)gW3~Y`#Zz?BD_{I8Bz6-Q(=fG zJt`d*B4PA&hMGBaf2UB@rzgBsg?LzRU&Jlr&H+R67E@N)Dwh?(f`!;e_O3j?y(d_U zikwh8OMmGV0r}Q>K=@42cV2`YC%UW!5qVikv}Cx1=xJ)#PM9u}fUT39()&of0lhg8Touj<3Q z$Riskf&r<;@GDdtlTd4*Mr%%1zQ4^RUWsS8m-DJhjVuw@i-n9(FVVS_8?~@4 zWJJjEIp3e!Q{`{!uhKcM>m7t%1MK6RH(1Xg&3Okk0#m&azUsAw-!J9yFZWzE(8~Kb zSB=zD;9NCQPx#a@Glz=S6RN0SJumlMHK1MlJXa0SGk{|{bKZjHs*!s3x4Eic3tn``Zs~s9ha-?JhEz*mNY|8mWF3+XRapZ#dg%ljRU zJw{&15HypR=()wk&z0d7^0ojqB7_g%*{kWmcSP*t86{Frc!e?}c%+`t6Tv>Tt0z=Z z!S!iNzvP8y)nA3KegxPjb4J-3b{=r8Rz>Q0Y4*v~Cw{w(ZzK=ERsA0Ervm&ie!GmX z1vS&PdLQ7?T5izJOs~eb%M8x5g(1BZ7wzvBh~Gi7zxU89qki!_NM0HJ6xZ^CxbkBkrK`#`O+Ft(UmL7UBYeb$;c(5^FY7&+aP zuQ%me&F>B74fAKH_g-7pnWlWB$y@Y|sn%wbr?}}>(k63La;uSRGy2jhcR#>jDyjCe zU7hE~s!;7oT&Wk6$X+}K^1ph^uCCB4e(SdVE50#t17ZvO*DP>gCRB>l1DdRp8Y_N9SYW6>-lfm+DnjI(9H-a8wn@ z4OG4$yT1O^x~?4^;kPuq6~#EVz^mB;@!aCo+`EOhE$FXqg=>fEI<1zx%Zf&=lT>y9&`${hR$7%2_Fx3At>v_5Nyz8%27M|MIqWsVOa&Pg!_~qX6I`e&bxpzDx82pfZ zm1vA-1oC|i^<2orgr17C?BaTc#MRHpNhBSdm6JzF@)L6WEzz1(fE=GovJNUhPM))$ zT!7qg{8PQ2OM=Q}0aL zcIrMY#}2oqTda~h9RYr)?sI;4^*P-9+>uN52EPMd_HyL%HF!BMUQV~qy0vw#(U_F> z$?{#sF4DeC8|@zJ*3F~M^HDED{k-jTe!ckiIvTwB;OTSxrERXU-x6gnci1U=rdvM4 z!;%~~spQmpDZj+6pL%4s*n5xmdG!44!c6@R@z#65vXVtl-9MW?yH;kvww-8F`UnI@ z2-$l4Q~hR>(We-4ytL!PN$T5!fC{jTT&CQ9#=3Ru5`D35v{9Cka}MCiMgL~yU#Pvw zv{zL^9Yl1?F;%j!6#b4q^~tDASym~7nzSu){6nsw@eiSb#y{i=8vl?hX#7L2pz#m6 zg2q4O;_)x*CV9y5t876${)sK}?UJ>S8%4{-Ps}&W zf58*=93%fwF()~727F9I87%((Vj*9`jK9C=8(jl% z2kRR$a)9{zi(-WrlUmp*{{CW5cW-|(;7fCs6@Pzm)~sOb?Bf>*0M3xp8mT9AikbadRp}T))QOUko*nYt9?sLGkw&!wlGB z3J2qxm65Sj( zGPXb=7La+Zlj8RvIF{JI^7uUnHBZ~t^yaxISa%iAi{FE=a(z{mJwC+~#j`K0lD8g| zt?af&%kLSR=1x_deR&Upe$LTaDo$U=70M%)wbJVB>+khO!MX4c8i1d(q9&8kT z&iixhquBo_`0ZXjhdd|`LTdd*zt5K0T#}RsAN_8A#b>30TEClLdRtb%n}0a^6SF&e z`Z%teeHFaK3YYq~vC;J`ZhsW~KH>7v?|e2+Kk|^RlfLHeM;HGN_?dom@k_6T z@ARXa{~!2HKf3v1pEB)Nr+$fN{uc9_RNBI3gyP#j#kXzaw-sU^Bfqo({!)IED$ZtO z{`XPDz=gv`CFI6KgIBSGV+P(E%4DLsY3kO$lo{~z8sHK`5+sk|F7?dzfQ5O zvdQF=RXrPi`8oI(X#O>ih#Jj*`W*P8m-MmKj5FgEzwz=vz<<4B+vm)*tV2g@{^(=j zU!?ffEWxFke>A>lOMH^bq`$PDhHo^(9}q5fyNQkVhsJk*68;+$+bX9m)+nv#}r>2{^Enc5;LRvH+-}wKWPr*M%>wjF@W&Ho{1+<|_>p6_oD%<#f>4%WlanU#;0iQURG-nB$ zOFe+d7r!nLeD;^&Jr|5rbP|2D<8_K2R5TK`*i!+*Qx&-ppIvFE36gZ~cAuar#N zv*B~%KkwB18&4#^OY48^5co3wl0I#NCu#ogegnQr^FM=ats6A|E_}y+m*!W>Q}lX# zXn5!h`0qCI-(t8kc3WHm|7s(Tt*q&~{`M2_O}x+f6MW-W>#%`s;{E;u;p=gr@d$L= zCf@JA9{x66pYOE5zlPtW2V|Vr{@nPXQ{msL*wzEH@Y@agxErvU{Z-BXIsW4KbFuj0 z*EE06jah%*xE?+>mGm2qZ~VF8@ka31HUE*1kem7+i_hBMFnq=Y$DiMU@7cE-zLXn3 zyaOBCcNqS?VB^nkDFS~}^LO7zuKl@jF?F+dY5t?5$hDq^d(VcC-6cILeQNyqn>)aF zDz<&xBy!y^4flxszpePzV}B#p{@gel8`^hi`Eu;x`13iU=WZ=u)#?)DEg|A}65?az&8Q)l}}n*XGXhuWVT zPiAbef2{cSnDVSY&sYmz`h)c3N;bxyzfN22`xV>z;|Iu1JpQ2?{sV?D{%`#G6MuyN zpyJ!(#LtaCf1lX0e`5HIm$n{Pt$}**|7res;@IKuk$(S+;#;4ieML!S2kRr!-oI-3 ziTG*Je9dqCCw%E|vdK@w*Y&gx9tPv@if`>%LayV;dY2sQdBwMvZFKZsy!YWJ;r~PP zlT#i27w`ScuiW{-`Oefj%Ze*+L^Zr8_vlGOy;(sNp=d+dYi#7ka z!?SwIAB9gJi2OnsCybsqY=X}iDydBTP1k4PgXh98Rcz~~KNF7HPZn+=#uH_l|KtGt zgsSJl+ZekN__3rtXR #include #include "DecodedCert.h" +#include "DecodedCrl.h" /* * There is one of these per active cached object (cert or CRL). @@ -53,7 +54,7 @@ public: ~CLCachedCert(); DecodedCert &cert() { return mCert; } private: - /* unpacked snacc format */ + /* decoded NSS format */ DecodedCert &mCert; }; @@ -61,12 +62,12 @@ class CLCachedCRL : public CLCachedEntry { public: CLCachedCRL( - CertificateList &c) : mCrl(c) { } + DecodedCrl &c) : mCrl(c) { } ~CLCachedCRL(); - CertificateList &crl() { return mCrl; } + DecodedCrl &crl() { return mCrl; } private: - /* unpacked snacc format */ - CertificateList &mCrl; + /* decoded NSS format */ + DecodedCrl &mCrl; }; /* @@ -86,7 +87,7 @@ private: */ typedef enum { - CLQ_Cert, + CLQ_Cert = 1, CLQ_CRL } CLQueryType; diff --git a/AppleX509CL/CLCertExtensions.cpp b/AppleX509CL/CLCertExtensions.cpp index 416574ba..7cc7d90a 100644 --- a/AppleX509CL/CLCertExtensions.cpp +++ b/AppleX509CL/CLCertExtensions.cpp @@ -17,7 +17,7 @@ /* - * CLCertExtensions.cpp - extensions support. A major component of DecodedCert. + * CLCertExtensions.cpp - extensions support. A major component of DecodedCert. * * Created 9/8/2000 by Doug Mitchell. * Copyright (c) 2000 by Apple Computer. @@ -26,492 +26,91 @@ #include "DecodedCert.h" #include "cldebugging.h" -#include "CertBuilder.h" #include "CLCertExtensions.h" -#include "SnaccUtils.h" +#include "CLFieldsCommon.h" +#include "clNssUtils.h" +#include "clNameUtils.h" #include #include +#include #include #include #include -#include -#include #include +#include -static AsnType *oidToSnaccObj( - const AsnOid &extnId); - -#define MIN_EXTENSIONS 4 // initial size of *mExtensions - -/* - * AsnOid "constants" which we construct and cache on demand to avoid the - * somewhat expensive op of constructing them every time we test for equality - * in oidToSnaccObj(). - */ -class ExtOidCache -{ -public: - ExtOidCache() : - mId_ce_keyUsage(id_ce_keyUsage_arc), - mId_ce_basicConstraints(id_ce_basicConstraints_arc), - mId_ce_extKeyUsage(id_ce_extKeyUsage_arc), - mId_ce_subjectKeyIdentifier(id_ce_subjectKeyIdentifier_arc), - mId_ce_authorityKeyIdentifier(id_ce_authorityKeyIdentifier_arc), - mId_ce_subjectAltName(id_ce_subjectAltName_arc), - mId_ce_certificatePolicies(id_ce_certificatePolicies_arc), - mId_netscape_cert_type(id_netscape_cert_type_arc) - { } - - AsnOid mId_ce_keyUsage; - AsnOid mId_ce_basicConstraints; - AsnOid mId_ce_extKeyUsage; - AsnOid mId_ce_subjectKeyIdentifier; - AsnOid mId_ce_authorityKeyIdentifier; - AsnOid mId_ce_subjectAltName; - AsnOid mId_ce_certificatePolicies; - AsnOid mId_netscape_cert_type; -}; - -static ModuleNexus extOidCache; - -/* - * Decode tbs->Extensions into mExtensions. This involves figuring out - * what kind of object is represented in the octet string in the - * extension, decoding it, and placing the resulting AsnType in a - * new DecodedExten struct. - * - * Called when decoding either a cert (for caching it or getting its fields) - * or a template (only via CertGetAllTemplateFields()). - */ -void DecodedCert::decodeExtensions() -{ - CASSERT(certificateToSign != NULL); - Extensions *extensions = certificateToSign->extensions; - if(extensions == NULL) { - /* OK, no extensions present */ - return; - } - - Extension *snaccExten = extensions->First(); - extensions->SetCurrToFirst(); - - /* traverse extension list */ - while(snaccExten != 0) { - /* - * For this extension->extnId, cook up an approppriate - * AsnType (KeyUsage, etc.); - */ - AsnOid &extnId = snaccExten->extnId; - bool berEncoded = false; - AsnType *snaccObj = oidToSnaccObj(extnId); - if(snaccObj == NULL) { - /* - * We don't know how to deal with this, just take the - * raw bytes, copied from snaccExte. - */ - snaccObj = new AsnOcts(snaccExten->extnValue); - berEncoded = true; - } - else { - /* - * We have a snacc-style object specific to this extension. - * Decode the extensions's extnValue into that object. We don't - * have to know what kind of object it is anymore. - */ - CssmData cData(snaccExten->extnValue, snaccExten->extnValue.Len()); - try { - SC_decodeAsnObj(cData, *snaccObj); - } - catch (...) { - /* - * FIXME - what do we do here? Is it safe to just ignore this - * extension, or is the whole cert invalid? - */ - errorLog0("decodeExtensions: extension decode error\n"); - delete snaccObj; - snaccObj = NULL; - } - } - if(snaccObj != NULL) { - /* add to mExtensions if the decode was successful */ - bool critical = false; // default - if(snaccExten->critical != NULL) { - critical = *snaccExten->critical; - } - addExtension(snaccObj, - snaccExten->extnId, - critical, - berEncoded); - } - extensions->GoNext(); - snaccExten = extensions->Curr(); - } -} - -/* - * Encode mExtensions into tbs->Extensions. - * - * Each extension object, currently stored as some AsnType subclass, - * is BER-encoded and the reesult is stored as an octet string - * (AsnOcts) in a new Extension object in the TBS. - * - * Only called from CertCreateTemplate via encodeTbs(). - */ -#define MAX_EXTEN_SIZE (4 * 1024) /* SWAG for max encoded size */ - -void DecodedCert::encodeExtensions() -{ - CertificateToSign *tbs = certificateToSign; - CASSERT(mState == CS_Building); - CASSERT((tbs != NULL) && (tbs->extensions == NULL)); - - if(mNumExtensions == 0) { - /* no extensions, no error */ - return; - } - tbs->extensions = new Extensions; - Extensions *extns = tbs->extensions; - - /* for each of our DecodedExtens, append an Extension object to - * tbs->extensions */ - unsigned extenDex; - for(extenDex=0; extenDexAppend(); - DecodedExten *decodedExt = &mExtensions[extenDex]; - - /* BER-encode the extension object if appropriate */ - if(decodedExt->berEncoded) { - /* unknown extension type, it's already encoded */ - /* A failure of this dynamic cast is a fata internal error */ - AsnOcts *rawOcts = dynamic_cast(decodedExt->snaccObj); - if(rawOcts == NULL) { - errorLog0("encodeExtensions: dynamic_cast failure!\n"); - CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); - } - snaccExt->extnValue.Set(*rawOcts); - } - else { - CssmAutoData aData(alloc); - try { - SC_encodeAsnObj(*decodedExt->snaccObj, aData, MAX_EXTEN_SIZE); - } - catch (...) { - errorLog0("encodeExtensions: extension encode error\n"); - throw; - } - CssmData &cData = aData.get(); - snaccExt->extnValue.Set((char *)cData.data(), cData.length()); - } - snaccExt->critical = new AsnBool(decodedExt->critical); - snaccExt->extnId.Set(*decodedExt->extnId); - } -} - - -/* - * Add a new DecodedExten to mExtensions. - * Called from decodeExtensions and setField*. - * At this point, the actual extenmsion data is represented by some subclass - * of AsnType - either a specific extension type (e.g. KeyUsage), or as an - * octet string (AsnOcts) for extension types we don't understand (and which - * are encoded by the app). - */ -void DecodedCert::addExtension( - AsnType *snaccObj, // e.g. KeyUsage - const AsnOid &extnId, - bool critical, - bool berEncoded) // i.e., we don't know how to parse -{ - /* cook up a new DecodedExten, reallocing mExtensions is necessary */ - if(mNumExtensions == mSizeofExtensions) { - /* expand by doubling, or initial malloc */ - mSizeofExtensions = mNumExtensions ? - (2 * mNumExtensions) : MIN_EXTENSIONS; - mExtensions = (DecodedExten *)alloc.realloc( - mExtensions, mSizeofExtensions * sizeof(DecodedExten)); - } - DecodedExten *decodedExt = &mExtensions[mNumExtensions++]; - decodedExt->extnId = new AsnOid(extnId); - decodedExt->critical = critical; - decodedExt->snaccObj = snaccObj; - decodedExt->berEncoded = berEncoded; -} - -/* - * Search for DecodedExten by AsnOid or "any unknown extension". - * Called from getField*() and inferKeyUsage. - * Returns NULL if specified extension not found. - */ -DecodedExten *DecodedCert::findDecodedExt( - const AsnOid &extnId, // for known extensions - bool unknown, // otherwise - uint32 index, - uint32 &numFields) const -{ - unsigned dex; - DecodedExten *decodedExt; - DecodedExten *rtnExt = NULL; - unsigned found = 0; - - for(dex=0; dexextnId == extnId)) || - (unknown && decodedExt->berEncoded)) { - - if(found++ == index) { - /* the one we want */ - rtnExt = decodedExt; - } - if((rtnExt != NULL) && (index != 0)) { - /* only determine numFields on search for first one */ - break; - } - } - } - if(rtnExt != NULL) { - /* sucessful return */ - if(index == 0) { - numFields = found; - } - return rtnExt; - } - else { - return NULL; - } -} - -/* - * Common code to pass info from a DecodedExten back to app. - * Called from getField*(). - */ -static void getFieldExtenCommon( - void *cdsaObj, // e.g. CE_KeyUsage - // CSSM_DATA_PTR for berEncoded - const DecodedExten &decodedExt, - CssmOwnedData &fieldValue) -{ - CSSM_X509_EXTENSION_PTR cssmExt; - CssmAllocator &alloc = fieldValue.allocator; - CssmData &fdata = fieldValue.get(); - - cssmExt = (CSSM_X509_EXTENSION_PTR)alloc.malloc(sizeof(CSSM_X509_EXTENSION)); - fdata.Data = (uint8 *)cssmExt; - fdata.Length = sizeof(CSSM_X509_EXTENSION); - CL_snaccOidToCssm(*decodedExt.extnId, - CssmOid::overlay(cssmExt->extnId), - alloc); - if(decodedExt.critical != NULL) { - cssmExt->critical = decodedExt.critical ? CSSM_TRUE : CSSM_FALSE; - } - else { - /* default */ - cssmExt->critical = false; - } - if(decodedExt.berEncoded) { - /* an extension we never parsed or understood */ - cssmExt->format = CSSM_X509_DATAFORMAT_ENCODED; - cssmExt->value.parsedValue = NULL; - cssmExt->BERvalue = *(reinterpret_cast(cdsaObj)); - } - else { - cssmExt->format = CSSM_X509_DATAFORMAT_PARSED; - cssmExt->value.parsedValue = cdsaObj; - cssmExt->BERvalue.Data = NULL; - cssmExt->BERvalue.Length = 0; - } -} - -/* - * Common code for top of setField* and freeField*(). - */ -static CSSM_X509_EXTENSION_PTR verifySetFreeExtension( - const CssmData &fieldValue, - bool berEncoded) // false: value in value.parsedValue - // true : value in BERValue -{ - if(fieldValue.length() != sizeof(CSSM_X509_EXTENSION)) { - errorLog2("Set/FreeExtension: bad length : exp %d got %d\n", - (int)sizeof(CSSM_X509_EXTENSION), (int)fieldValue.length()); - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - CSSM_X509_EXTENSION_PTR cssmExt = - reinterpret_cast(fieldValue.data()); - if(berEncoded) { - if((cssmExt->value.parsedValue != NULL) || (cssmExt->BERvalue.Data == NULL)) { - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - } - else { - if((cssmExt->value.parsedValue == NULL) || (cssmExt->BERvalue.Data != NULL)) { - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - } - return cssmExt; -} - -/* - * Common free code for all extensions. Extension-specific code must - * free anything beyond cdsaExt->Value.parsedValue, then we free everything - * else (except the extension struct itself, which is freed by - * DecodedCert::freeCertFieldData()). - */ -static void freeFieldExtenCommon( - CSSM_X509_EXTENSION_PTR exten, - CssmAllocator &alloc) -{ - alloc.free(exten->extnId.Data); - alloc.free(exten->BERvalue.Data); // may be NULL - alloc.free(exten->value.parsedValue); // may be NULL -} - - -/* - * Cook up an AsnType associated with specified extnId - * When adding oid/type pairs here, also add to: - * -- fieldFuncs[] in CertFields.cpp - * -- and the get/set/free functions in this file. - */ -static AsnType *oidToSnaccObj( - const AsnOid &extnId) -{ - ExtOidCache &oc = extOidCache(); - - if(extnId == oc.mId_ce_keyUsage) { - return new KeyUsage; - } - else if(extnId == oc.mId_ce_basicConstraints) { - return new BasicConstraintsSyntax; - } - else if(extnId == oc.mId_ce_extKeyUsage) { - return new ExtKeyUsageSyntax; - } - else if(extnId == oc.mId_ce_subjectKeyIdentifier) { - return new AsnOcts; - } - else if(extnId == oc.mId_ce_authorityKeyIdentifier) { - return new AuthorityKeyIdentifier; - } - else if(extnId == oc.mId_ce_subjectAltName) { - return new GeneralNames; - } - else if(extnId == oc.mId_ce_certificatePolicies) { - return new CertificatePoliciesSyntax; - } - else if(extnId == oc.mId_netscape_cert_type) { - return new AsnBits; - } - else { - return NULL; - } -} - -/* common code for top of getField* */ -template -bool GetFieldTop( - const DecodedCert &cert, - unsigned index, // which occurrence (0 = first) - uint32 &numFields, // RETURNED - CssmAllocator &alloc, - const AsnOid &fieldId, - SnaccType *&snaccObj, - CdsaType *&cdsaObj, - DecodedExten *&decodedExt) -{ - /* See if we have one of these in our list of DecodedExtens */ - decodedExt = cert.findDecodedExt(fieldId, false, index, numFields); - if(decodedExt == NULL) { - return false; - } - - /* failure of this dynamic_cast is fatal */ - snaccObj = dynamic_cast(decodedExt->snaccObj); - if(snaccObj == NULL) { - errorLog0("GetFieldTop: dynamic_cast failure\n"); - CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); - } - cdsaObj = (CdsaType *)alloc.malloc(sizeof(CdsaType)); - memset(cdsaObj, 0, sizeof(CdsaType)); - return true; -} /*** *** get/set/free functions called out from CertFields.cpp ***/ -/* - * One common free for extensions whose parsed value doesn't go any deeper - * than cssmExt->value.parsedValue. - */ -void freeFieldSimpleExtension ( - CssmOwnedData &fieldValue) -{ - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); - freeFieldExtenCommon(cssmExt, fieldValue.allocator); -} - /*** *** KeyUsage *** CDSA format CE_KeyUsage - *** SNACC format KeyUsage + *** NSS format CSSM_DATA, length 2 *** OID CSSMOID_KeyUsage ***/ void setFieldKeyUsage( - DecodedCert &cert, + DecodedItem &cert, const CssmData &fieldValue) { - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, + false); CE_KeyUsage *cdsaObj = (CE_KeyUsage *)cssmExt->value.parsedValue; - /* brute-force cdsaObj --> snaccObj */ - char bits[sizeof(CE_KeyUsage)]; - bits[0] = static_cast((*cdsaObj) >> 8); - bits[1] = static_cast(*cdsaObj); - memmove(bits, cdsaObj, sizeof(CE_KeyUsage)); - KeyUsage *snaccObj = new KeyUsage(bits, sizeof(CE_KeyUsage) * 8); + /* Alloc an NSS-style key usage in cert.coder's memory */ + SecNssCoder &coder = cert.coder(); + CSSM_DATA *nssObj = (CSSM_DATA *)coder.malloc(sizeof(CSSM_DATA)); + coder.allocItem(*nssObj, 2); + + /* cdsaObj --> nssObj */ + nssObj->Data[0] = (*cdsaObj) >> 8; + nssObj->Data[1] = *cdsaObj; + + /* Adjust length for BIT STRING encoding */ + clCssmBitStringToNss(*nssObj); /* add to mExtensions */ - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_KeyUsageTemplate); } bool getFieldKeyUsage( - const DecodedCert &cert, + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - DecodedExten *decodedExt; - KeyUsage *snaccObj; + const DecodedExten *decodedExt; + CSSM_DATA *nssObj; CE_KeyUsage *cdsaObj; bool brtn; - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, fieldValue.allocator, - id_ce_keyUsage, - snaccObj, + CSSMOID_KeyUsage, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } - unsigned toCopy = (snaccObj->BitLen() + 7) / 8; + /* make a copy - can't modify length in place */ + CSSM_DATA bitString = *nssObj; + clNssBitStringToCssm(bitString); + unsigned toCopy = bitString.Length; if(toCopy > 2) { /* I hope I never see this... */ - errorLog0("getFieldKeyUsage: KeyUsage larger than 2 bytes!\n"); + clErrorLog("getFieldKeyUsage: KeyUsage larger than 2 bytes!"); toCopy = 2; } unsigned char bits[2] = {0, 0}; - memmove(bits, snaccObj->BitOcts(), toCopy); + memmove(bits, bitString.Data, toCopy); *cdsaObj = (((unsigned)bits[0]) << 8) | bits[1]; /* pass back to caller */ @@ -522,70 +121,77 @@ bool getFieldKeyUsage( /*** *** Basic Constraints *** CDSA format: CE_BasicConstraints - *** SNACC format BasicConstraintsSyntax + *** NSS format CE_BasicConstraints *** OID CSSMOID_BasicConstraints ***/ void setFieldBasicConstraints( - DecodedCert &cert, + DecodedItem &cert, const CssmData &fieldValue) { - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); - BasicConstraintsSyntax *snaccObj = new BasicConstraintsSyntax; - CE_BasicConstraints *cdsaObj = (CE_BasicConstraints *)cssmExt->value.parsedValue; + CSSM_X509_EXTENSION_PTR cssmExt = + verifySetFreeExtension(fieldValue, false); + CE_BasicConstraints *cdsaObj = + (CE_BasicConstraints *)cssmExt->value.parsedValue; - /* brute-force cdsaObj --> snaccObj */ - snaccObj->cA = new AsnBool(cdsaObj->cA ? true : false); + /* Alloc an NSS-style BasicConstraints in cert.coder's memory */ + SecNssCoder &coder = cert.coder(); + NSS_BasicConstraints *nssObj = + (NSS_BasicConstraints *)coder.malloc(sizeof(NSS_BasicConstraints)); + memset(nssObj, 0, sizeof(*nssObj)); + + /* cdsaObj --> nssObj */ + ArenaAllocator arenaAlloc(coder); + clCssmBoolToNss(cdsaObj->cA, nssObj->cA, arenaAlloc); if(cdsaObj->pathLenConstraintPresent) { - AsnIntType val = cdsaObj->pathLenConstraint; - snaccObj->pathLenConstraint = new AsnInt(val); + clIntToData(cdsaObj->pathLenConstraint, + nssObj->pathLenConstraint, arenaAlloc); } /* add to mExtensions */ - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_BasicConstraintsTemplate); } bool getFieldBasicConstraints( - const DecodedCert &cert, + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - DecodedExten *decodedExt; - BasicConstraintsSyntax *snaccObj; + const DecodedExten *decodedExt; + NSS_BasicConstraints *nssObj; CE_BasicConstraints *cdsaObj; bool brtn; - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, fieldValue.allocator, - id_ce_basicConstraints, - snaccObj, + CSSMOID_BasicConstraints, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } - if(snaccObj->cA == NULL) { + if(nssObj->cA.Data == NULL) { /* default */ cdsaObj->cA = CSSM_FALSE; } else { - bool val = *snaccObj->cA; - cdsaObj->cA = val ? CSSM_TRUE : CSSM_FALSE; + cdsaObj->cA = clNssBoolToCssm(nssObj->cA); } - if(snaccObj->pathLenConstraint == NULL) { + if(nssObj->pathLenConstraint.Data == NULL) { + /* optional */ cdsaObj->pathLenConstraintPresent = CSSM_FALSE; cdsaObj->pathLenConstraint = 0; } else { cdsaObj->pathLenConstraintPresent = CSSM_TRUE; - AsnIntType val = *snaccObj->pathLenConstraint; - cdsaObj->pathLenConstraint = val; + cdsaObj->pathLenConstraint = clDataToInt(nssObj->pathLenConstraint); } /* pass back to caller */ @@ -596,66 +202,75 @@ bool getFieldBasicConstraints( /*** *** Extended Key Usage *** CDSA format: CE_ExtendedKeyUsage - *** SNACC format ExtKeyUsageSyntax + *** NSS format: NSS_ExtKeyUsage *** OID CSSMOID_ExtendedKeyUsage ***/ void setFieldExtKeyUsage( - DecodedCert &cert, + DecodedItem &cert, const CssmData &fieldValue) { - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); - ExtKeyUsageSyntax *snaccObj = new ExtKeyUsageSyntax; - CE_ExtendedKeyUsage *cdsaObj = (CE_ExtendedKeyUsage *)cssmExt->value.parsedValue; + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, + false); + CE_ExtendedKeyUsage *cdsaObj = + (CE_ExtendedKeyUsage *)cssmExt->value.parsedValue; - /* brute-force cdsaObj --> snaccObj, one 'purpose' (OID) at a time */ - unsigned oidDex; - for(oidDex=0; oidDexnumPurposes; oidDex++) { - KeyPurposeId *snaccPurp = snaccObj->Append(); - CSSM_OID_PTR cdsaPurp = &cdsaObj->purposes[oidDex]; - snaccPurp->Set(reinterpret_cast(cdsaPurp->Data), cdsaPurp->Length); + SecNssCoder &coder = cert.coder(); + NSS_ExtKeyUsage *nssObj = + (NSS_ExtKeyUsage *)coder.malloc(sizeof(NSS_ExtKeyUsage)); + memset(nssObj, 0, sizeof(*nssObj)); + if(cdsaObj->numPurposes != 0) { + nssObj->purposes = + (CSSM_OID **)clNssNullArray(cdsaObj->numPurposes, coder); + } + + /* cdsaObj --> nssObj, one 'purpose' (OID) at a time */ + for(unsigned dex=0; dexnumPurposes; dex++) { + nssObj->purposes[dex] = (CSSM_OID *)coder.malloc(sizeof(CSSM_OID)); + coder.allocCopyItem(cdsaObj->purposes[dex], + *nssObj->purposes[dex]); } /* add to mExtensions */ - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_ExtKeyUsageTemplate); } bool getFieldExtKeyUsage( - const DecodedCert &cert, + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - DecodedExten *decodedExt; - ExtKeyUsageSyntax *snaccObj; + const DecodedExten *decodedExt; + NSS_ExtKeyUsage *nssObj; CE_ExtendedKeyUsage *cdsaObj; bool brtn; + CssmAllocator &alloc = fieldValue.allocator; - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, - fieldValue.allocator, - id_ce_extKeyUsage, - snaccObj, + alloc, + CSSMOID_ExtendedKeyUsage, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } - /* brute force snaccObj --> cdsaObj, one purpose at a time */ - CssmAllocator &alloc = fieldValue.allocator; - cdsaObj->numPurposes = snaccObj->Count(); - cdsaObj->purposes = (CSSM_OID_PTR)alloc.malloc(cdsaObj->numPurposes * - sizeof(CSSM_OID)); - snaccObj->SetCurrToFirst(); - unsigned oidDex; - for(oidDex=0; oidDexnumPurposes; oidDex++) { - CL_snaccOidToCssm(*snaccObj->Curr(), - CssmOid::overlay(cdsaObj->purposes[oidDex]), - alloc); - snaccObj->GoNext(); + /* nssObj --> cdsaObj, one purpose at a time */ + unsigned numPurposes = clNssArraySize((const void **)nssObj->purposes); + cdsaObj->numPurposes = numPurposes; + if(numPurposes) { + unsigned len = numPurposes * sizeof(CSSM_OID); + cdsaObj->purposes = (CSSM_OID_PTR)alloc.malloc(len); + memset(cdsaObj->purposes, 0, len); + } + for(unsigned dex=0; dexpurposes[dex], cdsaObj->purposes[dex]); } + getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); return true; } @@ -678,44 +293,53 @@ void freeFieldExtKeyUsage( /*** *** Subject Key Identifier *** CDSA format: CE_SubjectKeyID, which is just a CSSM_DATA - *** SNACC format AsnOcts *** OID CSSMOID_SubjectKeyIdentifier ***/ void setFieldSubjectKeyId( - DecodedCert &cert, + DecodedItem &cert, const CssmData &fieldValue) { - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, + false); CE_SubjectKeyID *cdsaObj = (CE_SubjectKeyID *)cssmExt->value.parsedValue; - AsnOcts *snaccObj = new AsnOcts((char *)cdsaObj->Data, cdsaObj->Length); - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); + SecNssCoder &coder = cert.coder(); + CSSM_DATA *nssObj = (CSSM_DATA *)coder.malloc(sizeof(CSSM_DATA)); + coder.allocCopyItem(*cdsaObj, *nssObj); + + /* add to mExtensions */ + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_SubjectKeyIdTemplate); } bool getFieldSubjectKeyId( - const DecodedCert &cert, + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - DecodedExten *decodedExt; - AsnOcts *snaccObj; + const DecodedExten *decodedExt; + CSSM_DATA *nssObj; CE_SubjectKeyID *cdsaObj; bool brtn; + CssmAllocator &alloc = fieldValue.allocator; - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, - fieldValue.allocator, - id_ce_subjectKeyIdentifier, - snaccObj, + alloc, + CSSMOID_SubjectKeyIdentifier, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } - CL_AsnOctsToCssmData(*snaccObj, *cdsaObj, fieldValue.allocator); + + /* if this fails, we're out of sync with nssExtenInfo[] in + * CLFieldsCommon.cpp */ + assert(nssObj != NULL); + clAllocCopyData(alloc, *nssObj, *cdsaObj); getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); return true; } @@ -733,322 +357,333 @@ void freeFieldSubjectKeyId ( /*** *** Authority Key Identifier *** CDSA format: CE_AuthorityKeyID - *** SNACC format AuthorityKeyIdentifier + *** NSS format: NSS_AuthorityKeyId *** OID CSSMOID_AuthorityKeyIdentifier ***/ void setFieldAuthorityKeyId( - DecodedCert &cert, + DecodedItem &cert, const CssmData &fieldValue) { - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); - CE_AuthorityKeyID *cdsaObj = (CE_AuthorityKeyID *)cssmExt->value.parsedValue; - AuthorityKeyIdentifier *snaccObj = new AuthorityKeyIdentifier; - - /* - * brute-force a CDSA-style CE_AuthorityKeyID into snacc-style - * AuthorityKeyIdentifier - */ - if(cdsaObj->keyIdentifierPresent) { - /* Just an AsnOcts */ - snaccObj->keyIdentifier = new AsnOcts((char *)cdsaObj->keyIdentifier.Data, - cdsaObj->keyIdentifier.Length); - } - if(cdsaObj->generalNamesPresent ) { - /* GeneralNames, the hard one */ - snaccObj->authorityCertIssuer = CL_cdsaGeneralNamesToSnacc( - *cdsaObj->generalNames); - } - if(cdsaObj->serialNumberPresent) { - /* boils down to BigIntegerStr, or AsnOcts */ - snaccObj->authorityCertSerialNumber = - new CertificateSerialNumber((char *)cdsaObj->serialNumber.Data, - cdsaObj->serialNumber.Length); - } + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, + false); + CE_AuthorityKeyID *cdsaObj = + (CE_AuthorityKeyID *)cssmExt->value.parsedValue; - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); + /* Alloc an NSS-style AuthorityKeyId in cert.coder's memory */ + SecNssCoder &coder = cert.coder(); + NSS_AuthorityKeyId *nssObj = + (NSS_AuthorityKeyId *)coder.malloc(sizeof(NSS_AuthorityKeyId)); + memset(nssObj, 0, sizeof(*nssObj)); + + /* convert caller's CDSA-style CE_AuthorityKeyID to NSS */ + CL_cssmAuthorityKeyIdToNss(*cdsaObj, *nssObj, coder); + + /* add to mExtensions */ + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_AuthorityKeyIdTemplate); } bool getFieldAuthorityKeyId( - const DecodedCert &cert, + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - DecodedExten *decodedExt; - AuthorityKeyIdentifier *snaccObj; + const DecodedExten *decodedExt; + NSS_AuthorityKeyId *nssObj; CE_AuthorityKeyID *cdsaObj; bool brtn; CssmAllocator &alloc = fieldValue.allocator; - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, alloc, - id_ce_authorityKeyIdentifier, - snaccObj, + CSSMOID_AuthorityKeyIdentifier, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } + assert(nssObj != NULL); + + /* nssObj --> cdsaObj */ + CL_nssAuthorityKeyIdToCssm(*nssObj, *cdsaObj, cert.coder(), alloc); - /* brute-force a snacc-style AuthorityKeyIdentifier into CDSA format */ - if(snaccObj->keyIdentifier != NULL) { - /* Just an AsnOcts */ - cdsaObj->keyIdentifierPresent = CSSM_TRUE; - CL_AsnOctsToCssmData(*snaccObj->keyIdentifier, - cdsaObj->keyIdentifier, - alloc); - } - if(snaccObj->authorityCertIssuer != NULL) { - /* GeneralNames, the hard one */ - cdsaObj->generalNamesPresent = CSSM_TRUE; - cdsaObj->generalNames = (CE_GeneralNames *)alloc.malloc(sizeof(CE_GeneralNames)); - CL_snaccGeneralNamesToCdsa(*snaccObj->authorityCertIssuer, - *cdsaObj->generalNames, - alloc); - } - if(snaccObj->authorityCertSerialNumber != NULL) { - /* boils down to BigIntegerStr, or AsnOcts */ - cdsaObj->serialNumberPresent = CSSM_TRUE; - CL_AsnOctsToCssmData(*snaccObj->authorityCertSerialNumber, - cdsaObj->serialNumber, - alloc); - } getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); return true; } -static void freeFieldGeneralNames( - CE_GeneralNames *cdsaObj, - CssmAllocator &alloc) -{ - if(cdsaObj == NULL) { - return; - } - for(unsigned i=0; inumNames; i++) { - alloc.free(cdsaObj->generalName[i].name.Data); - } - if(cdsaObj->numNames) { - memset(cdsaObj->generalName, 0, cdsaObj->numNames * sizeof(CE_GeneralName)); - alloc.free(cdsaObj->generalName); - } - memset(cdsaObj, 0, sizeof(CE_GeneralNames)); -} - void freeFieldAuthorityKeyId ( CssmOwnedData &fieldValue) { CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); CssmAllocator &alloc = fieldValue.allocator; CE_AuthorityKeyID *cdsaObj = (CE_AuthorityKeyID *)cssmExt->value.parsedValue; - alloc.free(cdsaObj->keyIdentifier.Data); - freeFieldGeneralNames(cdsaObj->generalNames, alloc); - alloc.free(cdsaObj->generalNames); - alloc.free(cdsaObj->serialNumber.Data); - memset(cdsaObj, 0, sizeof(CE_AuthorityKeyID)); + CL_freeAuthorityKeyId(*cdsaObj, alloc); freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, BERvalue } /*** - *** Subject alternate name + *** Subject/Issuer alternate name *** CDSA Format: CE_GeneralNames - *** SNACC format: GeneralNames - *** OID: CSSMOID_SubjectAltName + *** NSS format: NSS_GeneralNames + *** OID: CSSMOID_SubjectAltName, CSSMOID_IssuerAltName ***/ -void setFieldSubjAltName( - DecodedCert &cert, +void setFieldSubjIssuerAltName( + DecodedItem &cert, const CssmData &fieldValue) { - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); + CSSM_X509_EXTENSION_PTR cssmExt = + verifySetFreeExtension(fieldValue, false); CE_GeneralNames *cdsaObj = (CE_GeneralNames *)cssmExt->value.parsedValue; - GeneralNames *snaccObj = CL_cdsaGeneralNamesToSnacc(*cdsaObj); - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); + + /* Alloc an NSS-style GeneralNames in cert.coder's memory */ + SecNssCoder &coder = cert.coder(); + NSS_GeneralNames *nssObj = + (NSS_GeneralNames *)coder.malloc(sizeof(NSS_GeneralNames)); + memset(nssObj, 0, sizeof(*nssObj)); + + /* cdsaObj --> nssObj */ + CL_cssmGeneralNamesToNss(*cdsaObj, *nssObj, coder); + + /* add to mExtensions */ + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_GeneralNamesTemplate); } bool getFieldSubjAltName( - const DecodedCert &cert, + DecodedItem &cert, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) +{ + const DecodedExten *decodedExt; + NSS_GeneralNames *nssObj; + CE_GeneralNames *cdsaObj; + bool brtn; + + brtn = cert.GetExtenTop( + index, + numFields, + fieldValue.allocator, + CSSMOID_SubjectAltName, + nssObj, + cdsaObj, + decodedExt); + if(!brtn) { + return false; + } + CL_nssGeneralNamesToCssm(*nssObj, *cdsaObj, + cert.coder(), fieldValue.allocator); + getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); + return true; +} + +bool getFieldIssuerAltName( + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - DecodedExten *decodedExt; - GeneralNames *snaccObj; - CE_GeneralNames *cdsaObj; + const DecodedExten *decodedExt; + NSS_GeneralNames *nssObj; + CE_GeneralNames *cdsaObj; bool brtn; - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, fieldValue.allocator, - id_ce_subjectAltName, - snaccObj, + CSSMOID_IssuerAltName, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } - CL_snaccGeneralNamesToCdsa(*snaccObj, *cdsaObj, fieldValue.allocator); + CL_nssGeneralNamesToCssm(*nssObj, *cdsaObj, + cert.coder(), fieldValue.allocator); getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); return true; } -void freeFieldSubjAltName ( +void freeFieldSubjIssuerAltName ( CssmOwnedData &fieldValue) { CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); CssmAllocator &alloc = fieldValue.allocator; CE_GeneralNames *cdsaObj = (CE_GeneralNames *)cssmExt->value.parsedValue; - freeFieldGeneralNames(cdsaObj, alloc); + CL_freeCssmGeneralNames(cdsaObj, alloc); freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, BERvalue } /*** *** Certificate Policies *** CDSA Format: CE_CertPolicies - *** SNACC format: CertificatePoliciesSyntax + *** NSS format : NSS_CertPolicies *** OID: CSSMOID_CertificatePolicies ***/ #define MAX_IA5_NAME_SIZE 1024 void setFieldCertPolicies( - DecodedCert &cert, + DecodedItem &cert, const CssmData &fieldValue) { - CssmAllocator &alloc = CssmAllocator::standard(); - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); - CertificatePoliciesSyntax *snaccObj = new CertificatePoliciesSyntax; - CE_CertPolicies *cdsaObj = (CE_CertPolicies *)cssmExt->value.parsedValue; + CSSM_X509_EXTENSION_PTR cssmExt = + verifySetFreeExtension(fieldValue, false); + SecNssCoder &coder = cert.coder(); + NSS_CertPolicies *nssObj = + (NSS_CertPolicies *)coder.malloc(sizeof(NSS_CertPolicies)); + memset(nssObj, 0, sizeof(NSS_CertPolicies)); + CE_CertPolicies *cdsaObj = + (CE_CertPolicies *)cssmExt->value.parsedValue; - /* brute-force cdsaObj --> snaccObj */ + if(cdsaObj->numPolicies) { + nssObj->policies = + (NSS_PolicyInformation **)clNssNullArray( + cdsaObj->numPolicies, coder); + } for(unsigned polDex=0; polDexnumPolicies; polDex++) { CE_PolicyInformation *cPolInfo = &cdsaObj->policies[polDex]; - PolicyInformation *sPolInfo = snaccObj->Append(); - sPolInfo->policyIdentifier.Set((char *)cPolInfo->certPolicyId.Data, - cPolInfo->certPolicyId.Length); - if(cPolInfo->numPolicyQualifiers != 0) { - sPolInfo->policyQualifiers = new PolicyInformationSeqOf; + NSS_PolicyInformation *nPolInfo = (NSS_PolicyInformation *) + coder.malloc(sizeof(NSS_PolicyInformation)); + memset(nPolInfo, 0, sizeof(*nPolInfo)); + nssObj->policies[polDex] = nPolInfo; + + coder.allocCopyItem(cPolInfo->certPolicyId, nPolInfo->certPolicyId); + + unsigned numQual = cPolInfo->numPolicyQualifiers; + if(numQual != 0) { + nPolInfo->policyQualifiers = + (NSS_PolicyQualifierInfo **)clNssNullArray(numQual, + coder); } - for(unsigned qualDex=0; qualDexnumPolicyQualifiers; qualDex++) { - CE_PolicyQualifierInfo *cQualInfo = &cPolInfo->policyQualifiers[qualDex]; - PolicyQualifierInfo *sQualInfo = sPolInfo->policyQualifiers->Append(); + for(unsigned qualDex=0; qualDexpolicyQualifiers[qualDex]; + NSS_PolicyQualifierInfo *nQualInfo = + (NSS_PolicyQualifierInfo *)coder.malloc( + sizeof(NSS_PolicyQualifierInfo)); + memset(nQualInfo, 0, sizeof(NSS_PolicyQualifierInfo)); + nPolInfo->policyQualifiers[qualDex] = nQualInfo; - /* OK we're at the lowest level. - * policyQualifierId == id_qt_cps: qualifier is an IA5 string, - * incoming data is its contents. Else incoming data is an encoded - * blob we pass on directly. + /* + * OK we're at the lowest level. + * policyQualifierId == id_qt_cps: qualifier is + * an IA5 string, incoming data is its contents. + * Else incoming data is an encoded blob we pass on directly. */ - sQualInfo->policyQualifierId.Set( - (char *)cQualInfo->policyQualifierId.Data, - cQualInfo->policyQualifierId.Length); - - /* we'll convert this incoming ptr/len.... */ - uint8 *rawData = cQualInfo->qualifier.Data; - unsigned rawDataLen = cQualInfo->qualifier.Length; - /* to this, somehow; it'll be used to build the required AsnAny. */ - CssmAutoData aData(alloc); - - if(sQualInfo->policyQualifierId == id_qt_cps) { - /* build & encode an IA5String */ - IA5String *ia5 = new IA5String((char *)rawData, rawDataLen); - SC_encodeAsnObj(*ia5, aData, MAX_IA5_NAME_SIZE); - delete ia5; + coder.allocCopyItem(cQualInfo->policyQualifierId, + nQualInfo->policyQualifierId); + + if(clCompareCssmData(&cQualInfo->policyQualifierId, + &CSSMOID_QT_CPS)) { + if(coder.encodeItem(&cQualInfo->qualifier, + SEC_IA5StringTemplate, + nQualInfo->qualifier)) { + clErrorLog("setFieldCertPOlicies: IA5 encode error\n"); + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } } else { - /* copy over directly */ - aData.copy(rawData, rawDataLen); + /* uninterpreted, copy over directly */ + coder.allocCopyItem(cQualInfo->qualifier, + nQualInfo->qualifier); } - - /* install the result into CSM_Buffer, which mallocs & copies */ - sQualInfo->qualifier = new AsnAny; - char *cp = aData; - sQualInfo->qualifier->value = new CSM_Buffer(cp, aData.length()); - aData.reset(); } /* for each qualifier */ } /* for each policy */ /* add to mExtensions */ - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_CertPoliciesTemplate); } -bool getFieldCertPolicies( - const DecodedCert &cert, +bool getFieldCertPolicies( + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - DecodedExten *decodedExt; - CertificatePoliciesSyntax *snaccObj; + const DecodedExten *decodedExt; + NSS_CertPolicies *nssObj; CE_CertPolicies *cdsaObj; bool brtn; CssmAllocator &alloc = fieldValue.allocator; - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, fieldValue.allocator, - id_ce_certificatePolicies, - snaccObj, + CSSMOID_CertificatePolicies, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } - - /* brute force CertificatePoliciesSyntax --> CE_CertPolicies */ - cdsaObj->numPolicies = snaccObj->Count(); + assert(nssObj != NULL); + + memset(cdsaObj, 0, sizeof(*cdsaObj)); + cdsaObj->numPolicies = + clNssArraySize((const void **)nssObj->policies); unsigned sz = cdsaObj->numPolicies * sizeof(CE_PolicyInformation); - cdsaObj->policies = (CE_PolicyInformation *)alloc.malloc(sz); - memset(cdsaObj->policies, 0, sz); - snaccObj->SetCurrToFirst(); + if(sz) { + cdsaObj->policies = (CE_PolicyInformation *)alloc.malloc(sz); + memset(cdsaObj->policies, 0, sz); + } + for(unsigned polDex=0; polDexnumPolicies; polDex++) { CE_PolicyInformation *cPolInfo = &cdsaObj->policies[polDex]; - PolicyInformation *sPolInfo = snaccObj->Curr(); - CssmOid &cOid = CssmOid::overlay(cPolInfo->certPolicyId); - CL_snaccOidToCssm(sPolInfo->policyIdentifier, cOid, alloc); - if(sPolInfo->policyQualifiers == NULL) { + NSS_PolicyInformation *nPolInfo = nssObj->policies[polDex]; + clAllocCopyData(alloc, nPolInfo->certPolicyId, + cPolInfo->certPolicyId); + if(nPolInfo->policyQualifiers == NULL) { continue; } - cPolInfo->numPolicyQualifiers = sPolInfo->policyQualifiers->Count(); + + cPolInfo->numPolicyQualifiers = + clNssArraySize((const void **)nPolInfo->policyQualifiers); + sz = cPolInfo->numPolicyQualifiers * + sizeof(CE_PolicyQualifierInfo); cPolInfo->policyQualifiers = (CE_PolicyQualifierInfo *) - alloc.malloc(cPolInfo->numPolicyQualifiers * - sizeof(CE_PolicyQualifierInfo)); - sPolInfo->policyQualifiers->SetCurrToFirst(); - for(unsigned qualDex=0; qualDexnumPolicyQualifiers; qualDex++) { - PolicyQualifierInfo *sQualInfo = sPolInfo->policyQualifiers->Curr(); - CE_PolicyQualifierInfo *cQualInfo = &cPolInfo->policyQualifiers[qualDex]; + alloc.malloc(sz); + memset(cPolInfo->policyQualifiers, 0, sz); + + for(unsigned qualDex=0; qualDexnumPolicyQualifiers; + qualDex++) { + NSS_PolicyQualifierInfo *nQualInfo = + nPolInfo->policyQualifiers[qualDex]; + CE_PolicyQualifierInfo *cQualInfo = + &cPolInfo->policyQualifiers[qualDex]; /* * leaf. - * policyQualifierId == id_qt_cps : IA5String - decode and return - * contents. Else return whole thing. + * policyQualifierId == CSSMOID_QT_CPS : + * IA5String - decode and return contents. + * Else return whole thing. */ - CssmOid &cOid2 = CssmOid::overlay(cQualInfo->policyQualifierId); - CL_snaccOidToCssm(sQualInfo->policyQualifierId, cOid2, alloc); - /* convert this: */ - CSM_Buffer *cbuf = sQualInfo->qualifier->value; - /* to this */ - CssmRemoteData outData(alloc, cQualInfo->qualifier); - if(sQualInfo->policyQualifierId == id_qt_cps) { - IA5String ia5; - CssmAutoData berData(alloc, cbuf->Access(), cbuf->Length()); - /* error is fatal, punt the whole kit'n'kaboodle and leak */ - SC_decodeAsnObj(berData, ia5); - char *src = ia5; - outData.copy(src, ia5.Len()); + clAllocCopyData(alloc, nQualInfo->policyQualifierId, + cQualInfo->policyQualifierId); + CSSM_DATA toCopy = nQualInfo->qualifier; + if(clCompareCssmData(&nQualInfo->policyQualifierId, + &CSSMOID_QT_CPS)) { + /* decode as IA5String to temp memory */ + toCopy.Data = NULL; + toCopy.Length = 0; + if(cert.coder().decodeItem(nQualInfo->qualifier, + SEC_IA5StringTemplate, + &toCopy)) { + clErrorLog("***getCertPolicies: bad IA5String!\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } } - else { - outData.copy(cbuf->Access(), cbuf->Length()); - } - outData.release(); - sPolInfo->policyQualifiers->GoNext(); - } - snaccObj->GoNext(); - } + /* else copy out nQualInfo->qualifier */ + clAllocCopyData(alloc, toCopy, cQualInfo->qualifier); + } /* for each qualifier */ + } /* for each policy info */ getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); return true; } @@ -1062,190 +697,157 @@ void freeFieldCertPolicies ( for(unsigned polDex=0; polDexnumPolicies; polDex++) { CE_PolicyInformation *cPolInfo = &cdsaObj->policies[polDex]; alloc.free(cPolInfo->certPolicyId.Data); - for(unsigned qualDex=0; qualDexnumPolicyQualifiers; qualDex++) { - CE_PolicyQualifierInfo *cQualInfo = &cPolInfo->policyQualifiers[qualDex]; + for(unsigned qualDex=0; + qualDexnumPolicyQualifiers; + qualDex++) { + CE_PolicyQualifierInfo *cQualInfo = + &cPolInfo->policyQualifiers[qualDex]; alloc.free(cQualInfo->policyQualifierId.Data); alloc.free(cQualInfo->qualifier.Data); } alloc.free(cPolInfo->policyQualifiers); } alloc.free(cdsaObj->policies); - freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, BERvalue + freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, + // BERvalue } /*** *** Netscape cert type *** CDSA Format: CE_NetscapeCertType (a uint16) - *** SNACC format: AsnBits + *** NSS format CSSM_DATA, length 2 *** OID: CSSMOID_NetscapeCertType ***/ void setFieldNetscapeCertType( - DecodedCert &cert, + DecodedItem &cert, const CssmData &fieldValue) { - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); - CE_NetscapeCertType *cdsaObj = (CE_NetscapeCertType *)cssmExt->value.parsedValue; + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, + false); + CE_NetscapeCertType *cdsaObj = + (CE_NetscapeCertType *)cssmExt->value.parsedValue; + + /* Alloc an NSS-style key usage in cert.coder's memory */ + SecNssCoder &coder = cert.coder(); + CSSM_DATA *nssObj = (CSSM_DATA *)coder.malloc(sizeof(CSSM_DATA)); + coder.allocItem(*nssObj, 2); + + /* cdsaObj --> nssObj */ + nssObj->Data[0] = (*cdsaObj) >> 8; + nssObj->Data[1] = *cdsaObj; - char bits[sizeof(CE_NetscapeCertType)]; - bits[0] = static_cast((*cdsaObj) >> 8); - bits[1] = static_cast(*cdsaObj); - memmove(bits, cdsaObj, sizeof(CE_NetscapeCertType)); - AsnBits *snaccObj = new AsnBits(bits, sizeof(CE_NetscapeCertType) * 8); + /* Adjust length for BIT STRING encoding */ + clCssmBitStringToNss(*nssObj); /* add to mExtensions */ - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_NetscapeCertTypeTemplate); } bool getFieldNetscapeCertType( - const DecodedCert &cert, + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - DecodedExten *decodedExt; - AsnBits *snaccObj; + const DecodedExten *decodedExt; + CSSM_DATA *nssObj; CE_NetscapeCertType *cdsaObj; bool brtn; - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, fieldValue.allocator, - id_netscape_cert_type, - snaccObj, + CSSMOID_NetscapeCertType, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } - - unsigned toCopy = (snaccObj->BitLen() + 7) / 8; + + /* make a copy - can't modify length in place */ + CSSM_DATA bitString = *nssObj; + clNssBitStringToCssm(bitString); + unsigned toCopy = bitString.Length; if(toCopy > 2) { /* I hope I never see this... */ - errorLog0("getFieldNetscapeCertType: bitstring larger than 2 bytes!\n"); + clErrorLog("getFieldKeyUsage: CertType larger than 2 bytes!"); toCopy = 2; } unsigned char bits[2] = {0, 0}; - memmove(bits, snaccObj->BitOcts(), toCopy); + memmove(bits, bitString.Data, toCopy); *cdsaObj = (((unsigned)bits[0]) << 8) | bits[1]; + + /* pass back to caller */ getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); return true; } /*** - *** unknown extensions - *** CDSA format: raw bytes in a CSSM_DATA. This data is the BER-encoding of - *** some extension struct we don't know about. - *** SNACC format AsnOcts - *** OID CSSMOID_X509V3CertificateExtensionCStruct + *** CRL Distribution points + *** CDSA Format: CE_CRLDistPointsSyntax + *** NSS format: NSS_CRLDistributionPoints + *** OID: CSSMOID_CrlDistributionPoints ***/ - -void setFieldUnknownExt( - DecodedCert &cert, - const CssmData &fieldValue) +void setFieldCrlDistPoints( + DecodedItem &cert, + const CssmData &fieldValue) { - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, true); - AsnOcts *snaccObj = new AsnOcts( - reinterpret_cast(cssmExt->BERvalue.Data), - cssmExt->BERvalue.Length); - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, true); + CSSM_X509_EXTENSION_PTR cssmExt = + verifySetFreeExtension(fieldValue, false); + CE_CRLDistPointsSyntax *cdsaObj = + (CE_CRLDistPointsSyntax *)cssmExt->value.parsedValue; + SecNssCoder &coder = cert.coder(); + NSS_CRLDistributionPoints *nssObj = + (NSS_CRLDistributionPoints *)coder.malloc( + sizeof(NSS_CRLDistributionPoints)); + + CL_cssmDistPointsToNss(*cdsaObj, *nssObj, coder); + cert.addExtension(nssObj, cssmExt->extnId, cssmExt->critical, false, + NSS_CRLDistributionPointsTemplate); } -bool getFieldUnknownExt( - const DecodedCert &cert, +bool getFieldCrlDistPoints( + DecodedItem &cert, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) { - AsnOid noOidLikeThis (1, 2); // a dummy argument - DecodedExten *decodedExt = cert.findDecodedExt(noOidLikeThis, - true, index, numFields); - if(decodedExt == NULL) { - return false; - } - /* failure of this dynamic_cast is fatal */ - AsnOcts *snaccObj = dynamic_cast(decodedExt->snaccObj); - if(snaccObj == NULL) { - errorLog0("getFieldUnknownExt: dynamic_cast failure\n"); - CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); - } - char *octData = *snaccObj; - CssmAutoData encodedBytes(fieldValue.allocator, octData, snaccObj->Len()); - /* easier way to do this...? */ - CssmData cData = encodedBytes.release(); - getFieldExtenCommon(&cData, *decodedExt, fieldValue); - return true; -} - -void freeFieldUnknownExt ( - CssmOwnedData &fieldValue) -{ - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, true); + const DecodedExten *decodedExt; + NSS_CRLDistributionPoints *nssObj; + CE_CRLDistPointsSyntax *cdsaObj; + bool brtn; CssmAllocator &alloc = fieldValue.allocator; - freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, BERvalue -} - - -#if template_pcode - -/*** - *** Subject alternate name - *** CDSA Format: CE_GeneralNames - *** SNACC format: GeneralNames - *** OID: CSSMOID_SubjectAltName - ***/ -void setFieldSomeExt( - DecodedCert &cert, - const CssmData &fieldValue) -{ - CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); - new an approppriate AsnType snaccObj (KeyUsage, etc.); - extension-specific e.g. CE_KeyUsage *cdsaObj = cssmExt->value.parsedValue; - /* brute-force cdsaObj --> snaccObj */ - ... - /* add to mExtensions */ - cert.addExtension(snaccObj, cssmExt->extnId, cssmExt->critical, false); -} - -bool getFieldSomeExt( - const DecodedCert &cert, - unsigned index, // which occurrence (0 = first) - uint32 &numFields, // RETURNED - CssmOwnedData &fieldValue) -{ - DecodedExten *decodedExt; - e.g. ExtKeyUsageSyntax *snaccObj; - e.g. CE_ExtendedKeyUsage *cdsaObj; - bool brtn; - - brtn = GetFieldTop( - cert, + brtn = cert.GetExtenTop( index, numFields, - fieldValue.allocator, - e.g. id_ce_extKeyUsage, - snaccObj, + alloc, + CSSMOID_CrlDistributionPoints, + nssObj, cdsaObj, decodedExt); if(!brtn) { return false; } - - brute force snaccObj --> cdsaObj; + assert(nssObj != NULL); + CL_nssDistPointsToCssm(*nssObj, *cdsaObj, cert.coder(), alloc); getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); return true; } -/* only used if complex structs below cssmExt->value.parsedValue */ -void freeFieldSomeExt ( +void freeFieldCrlDistPoints ( CssmOwnedData &fieldValue) { CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); CssmAllocator &alloc = fieldValue.allocator; - free the stuff in cssmExt->value.parsedValue; + CE_CRLDistPointsSyntax *cdsaObj = + (CE_CRLDistPointsSyntax *)cssmExt->value.parsedValue; + CL_freeCssmDistPoints(cdsaObj, alloc); freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, BERvalue } -#endif + diff --git a/AppleX509CL/CLCertExtensions.h b/AppleX509CL/CLCertExtensions.h index acfc01f9..31d1b957 100644 --- a/AppleX509CL/CLCertExtensions.h +++ b/AppleX509CL/CLCertExtensions.h @@ -28,6 +28,7 @@ #define _CL_CERT_EXTENSIONS_H_ #include "DecodedCert.h" +#include "CLFieldsCommon.h" #ifdef __cplusplus extern "C" { @@ -36,26 +37,21 @@ extern "C" { /* * Functions to map OID --> {get,set,free}field */ -typedef bool (getFieldFcn) ( - const DecodedCert &cert, - unsigned index, // which occurrence (0 = first) - uint32 &numFields, // RETURNED - CssmOwnedData &fieldValue); // RETURNED -typedef void (setFieldFcn) ( - DecodedCert &cert, - const CssmData &fieldValue); -typedef void (freeFieldFcn) ( - CssmOwnedData &fieldValue); - -getFieldFcn getFieldKeyUsage, getFieldBasicConstraints, getFieldExtKeyUsage, +getItemFieldFcn getFieldKeyUsage, getFieldBasicConstraints, + getFieldExtKeyUsage, getFieldSubjectKeyId, getFieldAuthorityKeyId, getFieldSubjAltName, - getFieldCertPolicies, getFieldNetscapeCertType, getFieldUnknownExt; -setFieldFcn setFieldKeyUsage, setFieldBasicConstraints, setFieldExtKeyUsage, - setFieldSubjectKeyId, setFieldAuthorityKeyId, setFieldSubjAltName, - setFieldCertPolicies, setFieldNetscapeCertType, setFieldUnknownExt; -freeFieldFcn freeFieldSimpleExtension, freeFieldExtKeyUsage, freeFieldSubjectKeyId, - freeFieldAuthorityKeyId, freeFieldSubjAltName, freeFieldCertPolicies, - freeFieldUnknownExt; + getFieldIssuerAltName, + getFieldCertPolicies, getFieldNetscapeCertType, getFieldCrlDistPoints, + getFieldUnknownExt; +setItemFieldFcn setFieldKeyUsage, setFieldBasicConstraints, + setFieldExtKeyUsage, + setFieldSubjectKeyId, setFieldAuthorityKeyId, setFieldSubjIssuerAltName, + setFieldCertPolicies, setFieldNetscapeCertType, setFieldCrlDistPoints, + setFieldUnknownExt; +freeFieldFcn freeFieldExtKeyUsage, freeFieldSubjectKeyId, + freeFieldAuthorityKeyId, freeFieldSubjIssuerAltName, + freeFieldCertPolicies, + freeFieldCrlDistPoints, freeFieldUnknownExt; #ifdef __cplusplus } diff --git a/AppleX509CL/CLCrlExtensions.cpp b/AppleX509CL/CLCrlExtensions.cpp new file mode 100644 index 00000000..aa771b8a --- /dev/null +++ b/AppleX509CL/CLCrlExtensions.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * CLCrlExtensions.cpp - CRL extensions support. + */ + +#include "DecodedCrl.h" +#include "CLCrlExtensions.h" +#include "CLCertExtensions.h" +#include "clNssUtils.h" +#include "clNameUtils.h" +#include "CLFieldsCommon.h" +#include +#include +#include +#include +#include + +#include + +/*** + *** get/set/free functions called out from CrlFields.cpp + ***/ +/*** + *** CrlNumber , DeltaCRL + *** CDSA format CE_CrlNumber (a uint32) + *** NSS format CSSM_DATA, length 4 + *** OID CSSMOID_CrlNumber, CSSMOID_DeltaCrlIndicator + ***/ + +/* set function for both */ +void setFieldCrlNumber( + DecodedItem &crl, + const CssmData &fieldValue) +{ + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, + false); + CE_CrlNumber *cdsaObj = (CE_CrlNumber *)cssmExt->value.parsedValue; + + /* CSSM_DATA and its contents in crl.coder's memory */ + ArenaAllocator alloc(crl.coder()); + CSSM_DATA_PTR nssVal = (CSSM_DATA_PTR)alloc.malloc(sizeof(CSSM_DATA)); + clIntToData(*cdsaObj, *nssVal, alloc); + + /* add to mExtensions */ + crl.addExtension(nssVal, cssmExt->extnId, cssmExt->critical, false, + SEC_IntegerTemplate); +} + + +bool getFieldCrlCommon( + DecodedItem &crl, + const CSSM_OID &fieldId, // identifies extension we seek + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) +{ + const DecodedExten *decodedExt; + CSSM_DATA *nssObj; + CE_CrlNumber *cdsaObj; + bool brtn; + + brtn = crl.GetExtenTop( + index, + numFields, + fieldValue.allocator, + fieldId, + nssObj, + cdsaObj, + decodedExt); + if(!brtn) { + return false; + } + *cdsaObj = clDataToInt(*nssObj, CSSMERR_CL_INVALID_CRL_POINTER); + + /* pass back to caller */ + getFieldExtenCommon(cdsaObj, *decodedExt, fieldValue); + return true; +} + +bool getFieldCrlNumber( + DecodedItem &crl, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) +{ + return getFieldCrlCommon(crl, CSSMOID_CrlNumber, index, numFields, + fieldValue); +} + +bool getFieldDeltaCrl( + DecodedItem &crl, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) +{ + return getFieldCrlCommon(crl, CSSMOID_DeltaCrlIndicator, index, + numFields, fieldValue); +} + +void freeFieldIssuingDistPoint ( + CssmOwnedData &fieldValue) +{ + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); + CssmAllocator &alloc = fieldValue.allocator; + CE_IssuingDistributionPoint *cdsaObj = + (CE_IssuingDistributionPoint *)cssmExt->value.parsedValue; + CL_freeCssmIssuingDistPoint(cdsaObj, alloc); + freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, BERvalue +} + +/* HoldInstructionCode - CSSM_OID */ +/* InvalidityDate - CSSM_DATA */ +void freeFieldOidOrData ( + CssmOwnedData &fieldValue) +{ + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, false); + CssmAllocator &alloc = fieldValue.allocator; + CSSM_DATA *cdsaObj = + (CSSM_DATA *)cssmExt->value.parsedValue; + if(cdsaObj) { + alloc.free(cdsaObj->Data); + alloc.free(cdsaObj); + } + freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, BERvalue +} + diff --git a/SecuritySNACCRuntime/tcl-p.c b/AppleX509CL/CLCrlExtensions.h similarity index 53% rename from SecuritySNACCRuntime/tcl-p.c rename to AppleX509CL/CLCrlExtensions.h index 29f7c0eb..fe2772ac 100644 --- a/SecuritySNACCRuntime/tcl-p.c +++ b/AppleX509CL/CLCrlExtensions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. * * The contents of this file constitute Original Code as defined in and are * subject to the Apple Public Source License Version 1.2 (the 'License'). @@ -17,34 +17,33 @@ /* - * file: tcl-p.c - * purpose: check and return via exit code whether the tcl interface needs to be made - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/tcl-p.c,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ - * $Log: tcl-p.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:05 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:16 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:05:50 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/25 22:24:48 rj - * new file + * CLCrlExtensions.h - extern declarations of get/set/free functions + * implemented in CLCrlExtensions.cpp and used + * only in CrlFields.cpp. * + * Created 9/8/2000 by Doug Mitchell. + * Copyright (c) 2000 by Apple Computer. */ -#define COMPILER 1 +#ifndef _CL_CRL_EXTENSIONS_H_ +#define _CL_CRL_EXTENSIONS_H_ -#include "snacc.h" +#include "DecodedCrl.h" +#include "CLCertExtensions.h" -main() -{ -#if TCL - return 0; -#else - return 1; +#ifdef __cplusplus +extern "C" { #endif + +/* + * Functions to map OID --> {get,set,free}field + */ +getItemFieldFcn getFieldCrlNumber, getFieldDeltaCrl; +setItemFieldFcn setFieldCrlNumber; +freeFieldFcn freeFieldIssuingDistPoint, freeFieldOidOrData; + +#ifdef __cplusplus } +#endif + +#endif /* _CL_CRL_EXTENSIONS_H_*/ diff --git a/AppleX509CL/CLFieldsCommon.cpp b/AppleX509CL/CLFieldsCommon.cpp new file mode 100644 index 00000000..8764a486 --- /dev/null +++ b/AppleX509CL/CLFieldsCommon.cpp @@ -0,0 +1,479 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * CLFieldsCommon.h - get/set/free routines common to certs and CRLs + */ + +#include "CLFieldsCommon.h" +#include "clNameUtils.h" +#include "clNssUtils.h" +#include "AppleX509CLSession.h" +#include +#include +#include +#include + +/* + * Table to map an OID to the info needed to decode the + * associated extension + */ +typedef struct { + const CSSM_OID &oid; + unsigned nssObjLen; + const SEC_ASN1Template *templ; +} NssExtenInfo; + +static const NssExtenInfo nssExtenInfo[] = { + { CSSMOID_KeyUsage, + sizeof(CSSM_DATA), + NSS_KeyUsageTemplate }, + { CSSMOID_BasicConstraints, + sizeof(NSS_BasicConstraints), + NSS_BasicConstraintsTemplate }, + { CSSMOID_ExtendedKeyUsage, + sizeof(NSS_ExtKeyUsage), + NSS_ExtKeyUsageTemplate }, + { CSSMOID_SubjectKeyIdentifier, + sizeof(CSSM_DATA), + NSS_SubjectKeyIdTemplate }, + { CSSMOID_AuthorityKeyIdentifier, + sizeof(NSS_AuthorityKeyId), + NSS_AuthorityKeyIdTemplate }, + { CSSMOID_SubjectAltName, + sizeof(NSS_GeneralNames), + NSS_GeneralNamesTemplate }, + { CSSMOID_IssuerAltName, + sizeof(NSS_GeneralNames), + NSS_GeneralNamesTemplate }, + { CSSMOID_CertificatePolicies, + sizeof(NSS_CertPolicies), + NSS_CertPoliciesTemplate }, + { CSSMOID_NetscapeCertType, + sizeof(CSSM_DATA), + NSS_NetscapeCertTypeTemplate }, + { CSSMOID_CrlDistributionPoints, + sizeof(NSS_CRLDistributionPoints), + NSS_CRLDistributionPointsTemplate }, + { CSSMOID_CertIssuer, + sizeof(NSS_GeneralNames), + NSS_GeneralNamesTemplate }, + /* CRL extensions */ + { CSSMOID_CrlNumber, + sizeof(CSSM_DATA), + SEC_IntegerTemplate }, + { CSSMOID_IssuingDistributionPoint, + sizeof(NSS_IssuingDistributionPoint), + NSS_IssuingDistributionPointTemplate }, + { CSSMOID_HoldInstructionCode, + sizeof(CSSM_OID), + SEC_ObjectIDTemplate }, + { CSSMOID_CrlReason, + sizeof(CSSM_DATA), + SEC_EnumeratedTemplate }, + { CSSMOID_DeltaCrlIndicator, + sizeof(CSSM_DATA), + SEC_IntegerTemplate }, + { CSSMOID_InvalidityDate, + sizeof(CSSM_DATA), + SEC_GeneralizedTimeTemplate } +}; + +#define NUM_NSS_EXTEN_INFOS (sizeof(nssExtenInfo) / sizeof(nssExtenInfo[0])) + +/* + * Returns true if we find the OID. + */ +bool clOidToNssInfo( + const CSSM_OID &oid, + unsigned &nssObjLen, // RETURNED + const SEC_ASN1Template *&templ) // RETURNED +{ + for(unsigned dex=0; dex(fieldValue.data()); + if(berEncoded) { + if((cssmExt->value.parsedValue != NULL) || + (cssmExt->BERvalue.Data == NULL)) { + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + } + else { + if(cssmExt->value.parsedValue == NULL) { + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + } + return cssmExt; +} + +/* + * Common free code for all extensions. Extension-specific code must + * free anything beyond cdsaExt->Value.parsedValue, then we free everything + * else (except the extension struct itself, which is freed by + * DecodedCert::freeCertFieldData()). + */ +void freeFieldExtenCommon( + CSSM_X509_EXTENSION_PTR exten, + CssmAllocator &alloc) +{ + alloc.free(exten->extnId.Data); + alloc.free(exten->BERvalue.Data); // may be NULL + alloc.free(exten->value.parsedValue); // may be NULL +} + +/* + * One common free for extensions whose parsed value doesn't go any deeper + * than cssmExt->value.parsedValue. + */ +void freeFieldSimpleExtension ( + CssmOwnedData &fieldValue) +{ + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, + false); + freeFieldExtenCommon(cssmExt, fieldValue.allocator); +} + + +/*** + *** Common code for get/set subject/issuer name (C struct version) + *** Format = CSSM_X509_NAME + *** class Name from sm_x501if + ***/ +bool getField_RDN_NSS ( + const NSS_Name &nssName, + CssmOwnedData &fieldValue) // RETURNED +{ + /* alloc top-level CSSM_X509_NAME */ + CssmAllocator &alloc = fieldValue.allocator; + fieldValue.malloc(sizeof(CSSM_X509_NAME)); + CSSM_X509_NAME_PTR cssmName = (CSSM_X509_NAME_PTR)fieldValue.data(); + + CL_nssNameToCssm(nssName, *cssmName, alloc); + return true; +} + +void freeField_RDN ( + CssmOwnedData &fieldValue) +{ + if(fieldValue.data() == NULL) { + return; + } + if(fieldValue.length() != sizeof(CSSM_X509_NAME)) { + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + CssmAllocator &alloc = fieldValue.allocator; + CSSM_X509_NAME_PTR x509Name = (CSSM_X509_NAME_PTR)fieldValue.data(); + CL_freeX509Name(x509Name, alloc); + + /* top-level x509Name pointer freed by freeCertFieldData() */ +} + +/*** + *** Common code for Issuer Name, Subject Name (normalized and encoded + *** version) + *** Format = CSSM_DATA containing the DER encoding of the normalized name + ***/ +bool getField_normRDN_NSS ( + const CSSM_DATA &derName, + uint32 &numFields, // RETURNED (if successful, 0 or 1) + CssmOwnedData &fieldValue) // RETURNED +{ + if(derName.Data == NULL) { + /* This can happen during CertGetAllTemplateFields() because + * the normalized fields are only set up during cert/CRL decode */ + return false; + } + + /* + * First make a temp decoded copy which we'll be manipulating. + */ + SecNssCoder coder; + NSS_Name decodedName; + + memset(&decodedName, 0, sizeof(decodedName)); + PRErrorCode prtn = coder.decodeItem(derName, NSS_NameTemplate, &decodedName); + if(prtn) { + /* + * Actually should never happen since this same bag of bits successfully + * decoded when the cert as a whole was decoded... + */ + clErrorLog("getField_normRDN decode error\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + + } + + /* normalize */ + CL_normalizeX509NameNSS(decodedName, coder); + + /* encode result */ + prtn = SecNssEncodeItemOdata(&decodedName, NSS_NameTemplate, fieldValue); + if(prtn) { + clErrorLog("getField_normRDN encode error\n"); + CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); + } + numFields = 1; + return true; +} + +/*** + *** Common code for Time fields - Validity not before, Not After, + *** This Update, Next Update + *** Format: CSSM_X509_TIME + ***/ +bool getField_TimeNSS ( + const NSS_Time &nssTime, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + if(!tbsGetCheck(nssTime.item.Data, index)) { + return false; + } + CssmAllocator &alloc = fieldValue.allocator; + fieldValue.malloc(sizeof(CSSM_X509_TIME)); + CSSM_X509_TIME *cssmTime = + (CSSM_X509_TIME *)fieldValue.data(); + if(CL_nssTimeToCssm(nssTime, *cssmTime, alloc)) { + numFields = 1; + return true; + } + else { + return false; + } +} + +void setField_TimeNSS ( + const CssmData &fieldValue, + NSS_Time &nssTime, + SecNssCoder &coder) +{ + CSSM_X509_TIME *cssmTime = + (CSSM_X509_TIME *)fieldValue.data(); + CL_cssmTimeToNss(*cssmTime, nssTime, coder); +} + +void freeField_Time ( + CssmOwnedData &fieldValue) +{ + CSSM_X509_TIME *cssmTime = (CSSM_X509_TIME *)fieldValue.data(); + if(cssmTime == NULL) { + return; + } + if(fieldValue.length() != sizeof(CSSM_X509_TIME)) { + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + CL_freeCssmTime(cssmTime, fieldValue.allocator); +} + +/*** + *** TBS AlgId, Signature AlgId + *** Format = CSSM_X509_ALGORITHM_IDENTIFIER + ***/ +void getField_AlgIdNSS ( + const CSSM_X509_ALGORITHM_IDENTIFIER &srcAlgId, + CssmOwnedData &fieldValue) // RETURNED +{ + CssmAllocator &alloc = fieldValue.allocator; + fieldValue.malloc(sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)); + CSSM_X509_ALGORITHM_IDENTIFIER *destAlgId = + (CSSM_X509_ALGORITHM_IDENTIFIER *)fieldValue.data(); + CL_copyAlgId(srcAlgId, *destAlgId, alloc); +} + +void setField_AlgIdNSS ( + const CssmData &fieldValue, + CSSM_X509_ALGORITHM_IDENTIFIER &dstAlgId, + SecNssCoder &coder) +{ + CSSM_X509_ALGORITHM_IDENTIFIER *srcAlgId = + (CSSM_X509_ALGORITHM_IDENTIFIER *)fieldValue.data(); + /* allocator for this coder */ + ArenaAllocator areanAlloc(coder); + CL_copyAlgId(*srcAlgId, dstAlgId, areanAlloc); +} + +void freeField_AlgId ( + CssmOwnedData &fieldValue) +{ + CSSM_X509_ALGORITHM_IDENTIFIER *cssmAlgId = + (CSSM_X509_ALGORITHM_IDENTIFIER *)fieldValue.data(); + if(cssmAlgId == NULL) { + return; + } + if(fieldValue.length() != sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)) { + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + CssmAllocator &alloc = fieldValue.allocator; + alloc.free(cssmAlgId->algorithm.Data); + alloc.free(cssmAlgId->parameters.Data); + memset(cssmAlgId, 0, sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)); +} + +/* + * Routines for common validity checking for certificateToSign fields. + * + * Call from setField*: verify field isn't already set, optionally validate + * input length + */ +void tbsSetCheck( + void *fieldToSet, + const CssmData &fieldValue, + uint32 expLength, + const char *op) +{ + if(fieldToSet != NULL) { + /* can't add another */ + clErrorLog("setField(%s): field already set", op); + CssmError::throwMe(CSSMERR_CL_INVALID_NUMBER_OF_FIELDS); + } + if((expLength != 0) && (fieldValue.length() != expLength)) { + clErrorLog("setField(%s): bad length : exp %d got %d", + op, (int)expLength, (int)fieldValue.length()); + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } +} + +/* + * Call from getField* for unique fields - detect missing field or + * index out of bounds. + */ +bool tbsGetCheck( + const void *requiredField, + uint32 reqIndex) +{ + if((requiredField == NULL) || (reqIndex != 0)) { + return false; + } + else { + return true; + } +} + +/*** + *** unknown extensions + *** CDSA format: raw bytes in a CSSM_DATA. This data is the BER-encoding of + *** some extension struct we don't know about. + *** NSS format CSSM_DATA + *** OID CSSMOID_X509V3CertificateExtensionCStruct + ***/ + +void setFieldUnknownExt( + DecodedItem &cert, + const CssmData &fieldValue) +{ + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, true); + SecNssCoder &coder = cert.coder(); + CSSM_DATA *rawExtn = (CSSM_DATA *)coder.malloc(sizeof(CSSM_DATA)); + coder.allocCopyItem(cssmExt->BERvalue, *rawExtn); + cert.addExtension(NULL, cssmExt->extnId, cssmExt->critical, + true, NULL /* no template */, rawExtn); +} + +bool getFieldUnknownExt( + DecodedItem &cert, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) +{ + uint8 noOidDataLikeThis[2] = {1, 2}; // a dummy argument + CSSM_OID noOidLikeThis = {2, noOidDataLikeThis}; + const DecodedExten *decodedExt = + cert.DecodedItem::findDecodedExt(noOidLikeThis, + true, index, numFields); + if(decodedExt == NULL) { + return false; + } + getFieldExtenCommon(NULL, *decodedExt, fieldValue); + return true; +} + +void freeFieldUnknownExt ( + CssmOwnedData &fieldValue) +{ + CSSM_X509_EXTENSION_PTR cssmExt = verifySetFreeExtension(fieldValue, true); + CssmAllocator &alloc = fieldValue.allocator; + freeFieldExtenCommon(cssmExt, alloc); // frees extnId, parsedValue, BERvalue +} + +/* setField for read-only OIDs (i.e., the ones in cert/CRL, not TBS) */ +void setField_ReadOnly ( + DecodedItem &item, + const CssmData &fieldValue) +{ + clErrorLog("Attempt to set a read-only field"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_TAG); +} + +bool getField_Unimplemented ( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + clErrorLog("Attempt to get an unimplemented field"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_TAG); +} + + + diff --git a/AppleX509CL/CLFieldsCommon.h b/AppleX509CL/CLFieldsCommon.h new file mode 100644 index 00000000..a31c849d --- /dev/null +++ b/AppleX509CL/CLFieldsCommon.h @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * CLFieldsCommon.h - get/set/free routines common to certs and CRLs + */ + +#ifndef _CL_FIELDS_COMMON_H_ +#define _CL_FIELDS_COMMON_H_ + +#include +#include + +#include "DecodedItem.h" + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * As of the NSS conversion, getField ops do NOT take a const + * DecodedItem argument since many of them use the DecodedItem's + * SecNssCoder for intermediate ops. + */ +typedef bool (getItemFieldFcn) ( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue); // RETURNED +typedef void (setItemFieldFcn) ( + DecodedItem &item, + const CssmData &fieldValue); +typedef void (freeFieldFcn) ( + CssmOwnedData &fieldValue); + +bool clOidToNssInfo( + const CSSM_OID &oid, + unsigned &nssObjLen, // RETURNED + const SEC_ASN1Template *&templ); // RETURNED + +/* + * Routines for common validity checking for certificateToSign fields. + * + * Call from setField*: verify field isn't already set, optionally validate + * input length + */ +void tbsSetCheck( + void *fieldToSet, + const CssmData &fieldValue, + uint32 expLength, + const char *op); + +/* + * Call from getField* for unique fields - detect missing field or + * index out of bounds. + */ +bool tbsGetCheck( + const void *requiredField, + uint32 reqIndex); + +/* common extension get/set/free */ +void getFieldExtenCommon( + void *cdsaObj, // e.g. CE_KeyUsage + // CSSM_DATA_PTR for berEncoded + const DecodedExten &decodedExt, + CssmOwnedData &fieldValue); + +CSSM_X509_EXTENSION_PTR verifySetFreeExtension( + const CssmData &fieldValue, + bool berEncoded); // false: value in value.parsedValue + // true : value in BERValue +void freeFieldExtenCommon( + CSSM_X509_EXTENSION_PTR exten, + CssmAllocator &alloc); + +/* + * Common code for get/set subject/issuer name (C struct version) + */ +bool getField_RDN_NSS ( + const NSS_Name &nssName, + CssmOwnedData &fieldValue); // RETURNED + +void freeField_RDN ( + CssmOwnedData &fieldValue); + +/* get normalized RDN */ +bool getField_normRDN_NSS ( + const CSSM_DATA &derName, + uint32 &numFields, // RETURNED (if successful, 0 or 1) + CssmOwnedData &fieldValue); // RETURNED + +/* + * Common code for Time fields - Validity not before/after, this/next update + * Format: CSSM_X509_TIME + */ +void freeField_Time ( + CssmOwnedData &fieldValue); + +bool getField_TimeNSS ( + const NSS_Time &derTime, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue); // RETURNED +void setField_TimeNSS ( + const CssmData &fieldValue, + NSS_Time &nssTime, + SecNssCoder &coder); + +void getField_AlgIdNSS ( + const CSSM_X509_ALGORITHM_IDENTIFIER &srcAlgId, + CssmOwnedData &fieldValue); // RETURNED +void setField_AlgIdNSS ( + const CssmData &fieldValue, + CSSM_X509_ALGORITHM_IDENTIFIER &dstAlgId, + SecNssCoder &coder); + +void freeField_AlgId ( + CssmOwnedData &fieldValue); + +getItemFieldFcn getFieldUnknownExt, getField_Unimplemented; +setItemFieldFcn setFieldUnknownExt, setField_ReadOnly; +freeFieldFcn freeFieldUnknownExt, freeFieldSimpleExtension; + +#ifdef __cplusplus +} +#endif + +#endif /* _CL_FIELDS_COMMON_H_ */ diff --git a/AppleX509CL/CSPAttacher.cpp b/AppleX509CL/CSPAttacher.cpp index 4569450f..d83c02c4 100644 --- a/AppleX509CL/CSPAttacher.cpp +++ b/AppleX509CL/CSPAttacher.cpp @@ -138,7 +138,7 @@ CSSM_CSP_HANDLE CSPAttacher::getCspHand(bool bareCsp) NULL, // eventHandler NULL); // AppNotifyCallbackCtx if(crtn) { - errorLog2("AppleX509CLSession::cspAttach: error (%d) loading %s\n", + clErrorLog("AppleX509CLSession::cspAttach: error (%d) loading %s", (int)crtn, modName); CssmError::throwMe(crtn); } @@ -154,7 +154,7 @@ CSSM_CSP_HANDLE CSPAttacher::getCspHand(bool bareCsp) NULL, // reserved &cspHand); if(crtn) { - errorLog2("AppleX509CLSession::cspAttach: error (%d) attaching to %s\n", + clErrorLog("AppleX509CLSession::cspAttach: error (%d) attaching to %s", (int)crtn, modName); CssmError::throwMe(crtn); } diff --git a/AppleX509CL/CVSVersionInfo.txt b/AppleX509CL/CVSVersionInfo.txt index d3d54cb9..2f45cd47 100644 --- a/AppleX509CL/CVSVersionInfo.txt +++ b/AppleX509CL/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:52 mb Exp $ -# $Name: Security-54~1~9 $ +# $Name: $ ProjectName: AppleX509CL ProjectVersion: 3 diff --git a/AppleX509CL/CertBuilder.cpp b/AppleX509CL/CertBuilder.cpp deleted file mode 100644 index 3842f4af..00000000 --- a/AppleX509CL/CertBuilder.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * CertBuilder.cpp - sublasses of various snacc-generated cert-related - * classes. - * - * Created 9/1/2000 by Doug Mitchell. - * Copyright (c) 2000 by Apple Computer. - */ - -#include "CertBuilder.h" -#include -#include -#include "cldebugging.h" - -#define BUF_ENC_EXTRA 64 - -/* - * Name is a complex structure which boils down to an arbitrarily - * large array of (usually) printable names. We facilitate the - * construction of the array, one AttributeTypeAndDistinguishedValue - * per RelativeDistinguishedName. This is the format commonly used - * in the real world, though it's legal to have multiple ATDVs - * per RDN - we just don't do it here. - * - * Typically the object manipulated here is inserted into a - * CertificateToSign object, as issuer or subject. - */ -void NameBuilder::addATDV( - const AsnOid &type, // id_at_commonName, etc. from sm_x501if - const char *value, // the bytes - size_t valueLen, - DirectoryString::ChoiceIdEnum stringType, - // printableStringCid, etc. - // from sm_x520sa - bool primaryDistinguished) -{ - /* cook up the RDN sequence first time thru */ - if(rDNSequence == NULL) { - rDNSequence = new RDNSequence; - choiceId = rDNSequenceCid; // no others available - } - - /* one RelativeDistinguishedName and one ATDV */ - RelativeDistinguishedName *rdn = rDNSequence->Append(); - AttributeTypeAndDistinguishedValue *atdv = rdn->Append(); - - /* - * fill in the ATDV - * FIXME - AttributeTypeAndDistinguishedValueSetOf??? What's that? - */ - atdv->type = type; - if(!primaryDistinguished) { - /* default is true, only encode if not default */ - atdv->primaryDistinguished = new AsnBool(primaryDistinguished); - } - - /* DirectoryString from sm_x520sa */ - DirectoryString dirStr; - dirStr.choiceId = stringType; - switch(stringType) { - case DirectoryString::teletexStringCid: - dirStr.teletexString = new TeletexString(value, valueLen); - break; - case DirectoryString::printableStringCid: - dirStr.printableString = new PrintableString(value, valueLen); - break; - case DirectoryString::universalStringCid: - dirStr.universalString = new UniversalString(value, valueLen); - break; - case DirectoryString::bmpStringCid: - dirStr.bmpString = new BMPString(value, valueLen); - break; - case DirectoryString::utf8StringCid: - dirStr.utf8String = new UTF8String(value, valueLen); - break; - } - - /* - * As far as I can tell, atdv->value.value is a CSM_Buffer containing - * the encoded dirStr. First malloc a dest buffer... - */ - size_t bufLen = valueLen + BUF_ENC_EXTRA; - char *buf = (char *)calloc(1, bufLen); - if(buf == NULL) { - CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); - } - - /* encode dirStr --> abuf */ - AsnBuf abuf; - abuf.Init(buf, bufLen); - abuf.ResetInWriteRvsMode(); - AsnLen bytesEnc; - #if SNACC_ENABLE_PDU - dirStr.BEncPdu(abuf, bytesEnc); - if(bytesEnc > bufLen) - #else - bytesEnc = dirStr.BEnc(abuf); - if(abuf.WriteError() || (bytesEnc > bufLen)) - #endif /* SNACC_ENABLE_PDU */ - { - #ifndef NDEBUG - printf("Whoops! Buffer overflow\n"); - #endif - /* throw */ - } - - /* install the result into CSM_Buffer, which mallocs & copies */ - atdv->value.value = new CSM_Buffer(abuf.DataPtr(), abuf.DataLen()); - free(buf); -} - -void NameBuilder::addX509Name ( - const CSSM_X509_NAME *x509Name) -{ - /* - * The main job here is extracting attr/value pairs in CSSM format - * from x509Name, and converting them into arguments for addATDV. - * Note that we're taking the default for primaryDistinguished, - * because the CDSA CSSM_X509_TYPE_VALUE_PAIR struct doesn't allow for - * it. - */ - for(unsigned rdnDex=0; rdnDexnumberOfRDNs; rdnDex++) { - CSSM_X509_RDN_PTR rdn = &x509Name->RelativeDistinguishedName[rdnDex]; - if(rdn->numberOfPairs != 1) { - errorLog0("setField_RDN: only one a/v pair per RDN supported\n"); - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - - CSSM_X509_TYPE_VALUE_PAIR_PTR atv = rdn->AttributeTypeAndValue; - AsnOid oid; - oid.Set(reinterpret_cast(atv->type.Data), atv->type.Length); - - DirectoryString::ChoiceIdEnum stringType; - switch(atv->valueType) { - case BER_TAG_T61_STRING: - stringType = DirectoryString::teletexStringCid; - break; - case BER_TAG_PRINTABLE_STRING: - stringType = DirectoryString::printableStringCid; - break; - case BER_TAG_PKIX_UNIVERSAL_STRING: - stringType = DirectoryString::universalStringCid; - break; - case BER_TAG_PKIX_BMP_STRING: - stringType = DirectoryString::bmpStringCid; - break; - case BER_TAG_PKIX_UTF8_STRING: - stringType = DirectoryString::utf8StringCid; - break; - default: - errorLog1("setField_RDN: illegal tag(%d)\n", atv->valueType); - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - addATDV(oid, - reinterpret_cast(atv->value.Data), - atv->value.Length, - stringType); - } -} - - -/* - * Custom AsnOid, used for converting CssmOid to AsnOid. The Snacc class - * declaration doesn't provide a means to construct from, or set by, - * pre-encoded OID bytes (which are available in a CssmOid). - */ -OidBuilder::OidBuilder(const CSSM_OID &coid) -{ - oid = Asn1Alloc (coid.Length); - memcpy(oid, coid.Data, coid.Length); - octetLen = coid.Length; -} - diff --git a/AppleX509CL/CertBuilder.h b/AppleX509CL/CertBuilder.h deleted file mode 100644 index e65eb48d..00000000 --- a/AppleX509CL/CertBuilder.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * CertBuilder.h - sublasses of various snacc-generated cert-related - * classes. - * - * Created 9/1/2000 by Doug Mitchell. - * Copyright (c) 2000 by Apple Computer. - */ - -#ifndef _CERT_BUILDER_H_ -#define _CERT_BUILDER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* - * Name is a complex structure which boils down to an arbitrarily - * large array of (usually) printable names. We facilitate the - * construction of the array, one AttributeTypeAndDistinguishedValue - * per RelativeDistinguishedName. This is the format commonly used - * in the real world, though it's legal to have multiple ATDVs - * per RDN - we just don't do it here. - * - * Typically the object manipulated here is inserted into a - * CertificateToSign object, as issuer or subject. - */ -class NameBuilder : public Name // Name from sm_x501if -{ -public: - void addATDV( - const AsnOid &type, // id_at_commonName, etc. - // from sm_x520sa - const char *value, // the bytes - size_t valueLen, - DirectoryString::ChoiceIdEnum stringType, // printableStringCid, etc. - // from sm_x520sa - bool primaryDistinguished = true); - - void addX509Name ( - const CSSM_X509_NAME *x509Name); -}; - - -/* - * Custom AsnOid, used for converting CssmOid to AsnOid. The Snacc class - * declaration doesn't provide a means to construct from, or set by, - * pre-encoded OID bytes (which are available in a CssmOid). - */ -class OidBuilder : public AsnOid -{ -public: - OidBuilder(const CSSM_OID &coid); - ~OidBuilder() { } -}; - -#endif /* _CERT_BUILDER_H_ */ - diff --git a/AppleX509CL/CertFields.cpp b/AppleX509CL/CertFields.cpp index 5d3f6227..c875e819 100644 --- a/AppleX509CL/CertFields.cpp +++ b/AppleX509CL/CertFields.cpp @@ -17,112 +17,53 @@ /* - * CertFields.cpp - convert between snacc-based Certificate components and CDSA-style + * CertFields.cpp - convert between NSS-based Certificate components and CDSA-style * fields. A major component of DecodedCert. * * Created 9/1/2000 by Doug Mitchell. * Copyright (c) 2000 by Apple Computer. - * - * The code in this file is dreadfully gross. There is no practical way to do this - * work (converting between C++ snacc types and C CSDA types) without the kind - * of brute force code you see here. */ #include "DecodedCert.h" #include "cldebugging.h" -#include "CertBuilder.h" #include "CLCertExtensions.h" -#include "SnaccUtils.h" +#include "clNssUtils.h" +#include "clNameUtils.h" +#include "CLFieldsCommon.h" #include #include #include #include -#include - -/* - * Routines for common validity checking for certificateToSign fields. - * - * Call from setField*: verify field isn't already set, optionally validate - * input length - */ -static void tbsSetCheck( - void *fieldToSet, - const CssmData &fieldValue, - uint32 expLength, - const char *op) -{ - if(fieldToSet != NULL) { - /* can't add another */ - errorLog1("setField(%s): field already set\n", op); - CssmError::throwMe(CSSMERR_CL_INVALID_NUMBER_OF_FIELDS); - } - if((expLength != 0) && (fieldValue.length() != expLength)) { - errorLog3("setField(%s): bad length : exp %d got %d\n", - op, (int)expLength, (int)fieldValue.length()); - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } -} - -/* - * Call from getField* for unique fields - detect missing field or index out of bounds. - */ -static bool tbsGetCheck( - void *requiredField, - uint32 reqIndex) -{ - if((requiredField == NULL) || (reqIndex != 0)) { - return false; - } - else { - return true; - } -} /*** *** Version *** Format = DER-encoded int (max of four bytes in this case) ***/ static bool getField_Version ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(!tbsGetCheck(cert.certificateToSign->version, index)) { + const DecodedCert &cert = dynamic_cast(item); + const CSSM_DATA &vers = cert.mCert.tbs.version; + if(!tbsGetCheck(vers.Data, index)) { + /* not present, optional */ return false; } - - /* cook up big-endian char array representation */ - int ivers = *cert.certificateToSign->version; - uint32 uvers = static_cast(ivers); - uint8 chars[sizeof(uint32)]; - for(uint32 i=0; i>= 8; - } - fieldValue.copy(chars, sizeof(uint32)); + fieldValue.copy(vers.Data, vers.Length); numFields = 1; return true; } static void setField_Version ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - tbsSetCheck(cert.certificateToSign->version, fieldValue, 0, "version"); - - /* get big-endian int from *fieldValue.Data */ - if(fieldValue.length() > sizeof(unsigned)) { - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - uint32 vers = 0; - uint8 *cp = fieldValue; - for(unsigned i=0; iversion = new Version((int)vers); - cert.certificateToSign->version->Set((int)vers); + DecodedCert &cert = dynamic_cast(item); + CSSM_DATA &vers = cert.mCert.tbs.version; + tbsSetCheck(vers.Data, fieldValue, 0, "version"); + cert.coder().allocCopyItem(fieldValue, vers); } @@ -132,17 +73,19 @@ static void setField_Version ( *** Format = DER-encoded int (always four bytes in this case) ***/ static bool getField_Version ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { + const DecodedCert &cert = dynamic_cast(item); tbsGetCheck(cert.certificateToSign->version, index); } static void setField_Version ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { + DecodedCert &cert = dynamic_cast(item); tbsSetCheck(cert.certificateToSign->version, fieldValue, sizeof(uint32), "version"); @@ -158,247 +101,53 @@ static void freeField_Version ( *** Format = DER-encoded int, variable length ***/ static bool getField_SerialNumber ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(index > 0) { + const DecodedCert &cert = dynamic_cast(item); + const CSSM_DATA &sn = cert.mCert.tbs.serialNumber; + if(!tbsGetCheck(sn.Data, index)) { return false; } - - char *cp = cert.certificateToSign->serialNumber; - uint32 len = cert.certificateToSign->serialNumber.Len(); - fieldValue.copy(cp, len); + fieldValue.copy(sn.Data, sn.Length); numFields = 1; return true; } static void setField_SerialNumber ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - cert.certificateToSign->serialNumber.Set(fieldValue, fieldValue.Length); + DecodedCert &cert = dynamic_cast(item); + CSSM_DATA &sn = cert.mCert.tbs.serialNumber; + tbsSetCheck(sn.Data, fieldValue, 0, "SerialNumber"); + cert.coder().allocCopyItem(fieldValue, sn); } -/*** - *** Issuer Name, Subject Name (C struct version) +/*** issuer/subject *** Format = CSSM_X509_NAME *** class Name from sm_x501if ***/ - -/* first, the common code */ -static bool getField_RDN ( - const Name &name, - uint32 &numFields, // RETURNED (if successful, 0 or 1) - CssmOwnedData &fieldValue) // RETURNED -{ - RDNSequence *rdns = name.rDNSequence; - int numRdns = rdns->Count(); - if((rdns == NULL) || (numRdns == 0)) { - /* not technically an error */ - return false; - } - - /* alloc top-level CSSM_X509_NAME and its RelativeDistinguishedName array */ - CssmAllocator &alloc = fieldValue.allocator; - fieldValue.malloc(sizeof(CSSM_X509_NAME)); - CSSM_X509_NAME_PTR x509Name = (CSSM_X509_NAME_PTR)fieldValue.data(); - memset(x509Name, 0, sizeof(CSSM_X509_NAME)); - x509Name->numberOfRDNs = numRdns; - x509Name->RelativeDistinguishedName = - (CSSM_X509_RDN_PTR)alloc.malloc(sizeof(CSSM_X509_RDN) * numRdns); - CSSM_X509_RDN_PTR currRdn = x509Name->RelativeDistinguishedName; - memset(currRdn, 0, sizeof(CSSM_X509_RDN) * numRdns); - - rdns->SetCurrElmt(0); - for(int rdnDex=0; rdnDexCurr(); - if(rdn == NULL) { - /* not sure how this can happen... */ - dprintf1("getField_RDN: NULL rdn at index %d\n", rdnDex); - - /* next snacc RDN but keep CDSA position unchanged */ - rdns->GoNext(); // snacc format - x509Name->numberOfRDNs--; // since we're skipping one - continue; - } - int numAttrs = rdn->Count(); - if(numAttrs == 0) { - dprintf1("getField_RDN: zero numAttrs at index %d\n", rdnDex); - rdns->GoNext(); - x509Name->numberOfRDNs--; // since we're skipping one - continue; - } - - /* alloc CSSM_X509_TYPE_VALUE_PAIR array for this rdn */ - currRdn->numberOfPairs = numAttrs; - currRdn->AttributeTypeAndValue = (CSSM_X509_TYPE_VALUE_PAIR_PTR) - alloc.malloc(sizeof(CSSM_X509_TYPE_VALUE_PAIR) * numAttrs); - CSSM_X509_TYPE_VALUE_PAIR_PTR currAttr = currRdn->AttributeTypeAndValue; - memset(currAttr, 0, sizeof(CSSM_X509_TYPE_VALUE_PAIR) * numAttrs); - - /* descend into array of attribute/values */ - rdn->SetCurrElmt(0); - for(int attrDex=0; attrDexCurr(); - if(att == NULL) { - /* not sure how this can happen... */ - dprintf1("getField_RDN: NULL att at index %d\n", attrDex); - rdn->GoNext(); - currRdn->numberOfPairs--; - continue; - } - - /* - * Convert snacc-style AttributeTypeAndDistinguishedValue to - * CSSM-style CSSM_X509_TYPE_VALUE_PAIR - * - * Hopefully 'value' is one of the types defined in DirectoryString, - * defined in sm_x520sa. Some certs use IA5String, which is not - * technically legal and is not handled by DirectoryString, so - * we have to handle that ourself. See e.g. the Thawte serverbasic - * cert, which has an email address in IA5String format. - */ - CSM_Buffer *cbuf = att->value.value; - AsnBuf buf; - AsnLen len = cbuf->Length(); - AsnTag tag; - AsnLen elmtLen; - ENV_TYPE env; - char *valData; - int valLength; - DirectoryString *dirStr = NULL; - - buf.InstallData(cbuf->Access(), len); - try { - tag = BDecTag (buf, len, env); - elmtLen = BDecLen (buf, len, env); - } - catch(...) { - errorLog0("getField_RDN: malformed DirectoryString (1)\n"); - /* FIXME - throw? Discard the whole cert? What? */ - rdn->GoNext(); - currRdn->numberOfPairs--; - continue; - } - - /* current buf ptr is at the string value's contents. */ - if((tag == MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) || - (tag == MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) { - /* any other printable types not handled by DirectoryString here */ - valData = buf.DataPtr(); - valLength = buf.DataLen(); - // workaround - delete dirStr; - dirStr = NULL; - } - else { - /* from sm_x520sa.h */ - AsnLen dec; - dirStr = new DirectoryString; - try { - dirStr->BDecContent(buf, tag, elmtLen, dec, env); - } - catch(...) { - errorLog0("getField_RDN: malformed DirectoryString (1)\n"); - /* FIXME - throw? Discard the whole cert? What? */ - rdn->GoNext(); - currRdn->numberOfPairs--; - continue; - } - AsnOcts *octs = NULL; - switch(dirStr->choiceId) { - case DirectoryString::printableStringCid: - octs = dirStr->printableString; - break; - case DirectoryString::teletexStringCid: - octs = dirStr->teletexString; - break; - case DirectoryString::universalStringCid: - octs = dirStr->universalString; - break; - case DirectoryString::bmpStringCid: - octs = dirStr->bmpString; - break; - case DirectoryString::utf8StringCid: - octs = dirStr->utf8String; - break; - default: - /* should never happen unless DirectoryString changes */ - errorLog1("getField_RDN: Bad DirectoryString::choiceId (%d)\n", - (int)dirStr->choiceId); - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - valData = *octs; - valLength = octs->Len(); - } /* normal DirectoryString */ - - /* OK, set up outgoing CSSM_X509_TYPE_VALUE_PAIR */ - CssmOid &oid = CssmOid::overlay(currAttr->type); - CL_snaccOidToCssm(att->type, oid, alloc); - currAttr->valueType = tag >> 24; - currAttr->value.Data = (uint8 *)alloc.malloc(valLength); - currAttr->value.Length = valLength; - memcpy(currAttr->value.Data, valData, valLength); - - rdn->GoNext(); // snacc format - currAttr++; // CDSA format - delete dirStr; - } /* for eact attr in rdn */ - - rdns->GoNext(); // snacc format - currRdn++; // CDSA format - } /* for each rdn in rdns */ - numFields = 1; - return true; -} - -/* common for issuer and subject */ -static void freeField_RDN ( - CssmOwnedData &fieldValue) -{ - if(fieldValue.data() == NULL) { - return; - } - if(fieldValue.length() != sizeof(CSSM_X509_NAME)) { - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - CssmAllocator &alloc = fieldValue.allocator; - CSSM_X509_NAME_PTR x509Name = (CSSM_X509_NAME_PTR)fieldValue.data(); - for(unsigned rdnDex=0; rdnDexnumberOfRDNs; rdnDex++) { - CSSM_X509_RDN_PTR rdn = &x509Name->RelativeDistinguishedName[rdnDex]; - for(unsigned atvDex=0; atvDexnumberOfPairs; atvDex++) { - CSSM_X509_TYPE_VALUE_PAIR_PTR atv = &rdn->AttributeTypeAndValue[atvDex]; - alloc.free(atv->type.Data); - alloc.free(atv->value.Data); - memset(atv, 0, sizeof(CSSM_X509_TYPE_VALUE_PAIR)); - } - alloc.free(rdn->AttributeTypeAndValue); - memset(rdn, 0, sizeof(CSSM_X509_RDN)); - } - alloc.free(x509Name->RelativeDistinguishedName); - memset(x509Name, 0, sizeof(CSSM_X509_NAME)); - - /* top-level x509Name pointer freed by freeCertFieldData() */ -} - -/*** issuer ***/ static bool getField_Issuer ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - bool brtn; - - if(!tbsGetCheck(cert.certificateToSign->issuer, index)) { + if(index != 0) { return false; } + + bool brtn; + + const DecodedCert &cert = dynamic_cast(item); try { - brtn = getField_RDN(*cert.certificateToSign->issuer, numFields, fieldValue); + brtn = getField_RDN_NSS(cert.mCert.tbs.issuer, fieldValue); + if(brtn) { + numFields = 1; + } } catch (...) { freeField_RDN(fieldValue); @@ -408,30 +157,36 @@ static bool getField_Issuer ( } static void setField_Issuer ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - tbsSetCheck(cert.certificateToSign->issuer, fieldValue, sizeof(CSSM_X509_NAME), + DecodedCert &cert = dynamic_cast(item); + const CSSM_X509_NAME *cssmName = (const CSSM_X509_NAME *)fieldValue.Data; + NSS_Name &nssName = cert.mCert.tbs.issuer; + tbsSetCheck(nssName.rdns, fieldValue, sizeof(CSSM_X509_NAME), "IssuerName"); - NameBuilder *issuer = new NameBuilder; - cert.certificateToSign->issuer = issuer; - const CSSM_X509_NAME *x509Name = (const CSSM_X509_NAME *)fieldValue.Data; - issuer->addX509Name(x509Name); + CL_cssmNameToNss(*cssmName, nssName, cert.coder()); } /*** subject ***/ static bool getField_Subject ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(!tbsGetCheck(cert.certificateToSign->subject, index)) { + if(index != 0) { return false; } + bool brtn; + + const DecodedCert &cert = dynamic_cast(item); try { - brtn = getField_RDN(*cert.certificateToSign->subject, numFields, fieldValue); + brtn = getField_RDN_NSS(cert.mCert.tbs.subject, fieldValue); + if(brtn) { + numFields = 1; + } } catch (...) { freeField_RDN(fieldValue); @@ -441,160 +196,127 @@ static bool getField_Subject ( } static void setField_Subject ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - tbsSetCheck(cert.certificateToSign->subject, fieldValue, sizeof(CSSM_X509_NAME), + DecodedCert &cert = dynamic_cast(item); + const CSSM_X509_NAME *cssmName = (const CSSM_X509_NAME *)fieldValue.Data; + NSS_Name &nssName = cert.mCert.tbs.subject; + tbsSetCheck(nssName.rdns, fieldValue, sizeof(CSSM_X509_NAME), "SubjectName"); - NameBuilder *subject = new NameBuilder; - cert.certificateToSign->subject = subject; - const CSSM_X509_NAME *x509Name = (const CSSM_X509_NAME *)fieldValue.Data; - subject->addX509Name(x509Name); + CL_cssmNameToNss(*cssmName, nssName, cert.coder()); } /*** *** Issuer Name, Subject Name (normalized and encoded version) *** Format = CSSM_DATA containing the DER encoding of the normalized name - *** class Name from sm_x501if ***/ - -/* first, the common code */ -static bool getField_normRDN ( - const Name &name, - uint32 &numFields, // RETURNED (if successful, 0 or 1) - CssmOwnedData &fieldValue) // RETURNED -{ - /* - * First step is to make a copy of the existing name. The easiest way to do - * this is to encode and decode. - */ - CssmAllocator &alloc = fieldValue.allocator; - CssmAutoData encodedName1(alloc); - /* FIXME - should SC_encodeAsnObj() take a const AsnType & ? */ - SC_encodeAsnObj(const_cast(name), encodedName1, MAX_RDN_SIZE); - Name decodedName; - SC_decodeAsnObj(encodedName1, decodedName); - - /* normalize */ - CL_normalizeX509Name(decodedName, alloc); - - /* encode result */ - SC_encodeAsnObj(decodedName, fieldValue, MAX_RDN_SIZE); - numFields = 1; - return true; -} - static bool getFieldSubjectNorm( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(!tbsGetCheck(cert.certificateToSign->subject, index)) { + if(index != 0) { return false; } - return getField_normRDN(*cert.certificateToSign->subject, numFields, fieldValue); + const DecodedCert &cert = dynamic_cast(item); + return getField_normRDN_NSS(cert.mCert.tbs.derSubject, numFields, + fieldValue); } static bool getFieldIssuerNorm( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(!tbsGetCheck(cert.certificateToSign->issuer, index)) { + if(index != 0) { return false; } - return getField_normRDN(*cert.certificateToSign->issuer, numFields, fieldValue); + const DecodedCert &cert = dynamic_cast(item); + return getField_normRDN_NSS(cert.mCert.tbs.derIssuer, numFields, fieldValue); } - /*** - *** TBS AlgId, Signature AlgId - *** Format = CSSM_X509_ALGORITHM_IDENTIFIER - *** - *** common code: + *** Issuer Name, Subject Name (encoded, NON-normalized version) + *** Format = CSSM_DATA containing the DER encoding of the name ***/ -static void getField_AlgId ( - const AlgorithmIdentifier *snaccAlgId, - CssmOwnedData &fieldValue) // RETURNED -{ - CssmAllocator &alloc = fieldValue.allocator; - fieldValue.malloc(sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)); - CSSM_X509_ALGORITHM_IDENTIFIER *cssmAlgId = - (CSSM_X509_ALGORITHM_IDENTIFIER *)fieldValue.data(); - CL_snaccAlgIdToCssm (*snaccAlgId, *cssmAlgId, alloc); -} - -static void setField_AlgId ( - AlgorithmIdentifier *snaccAlgId, - const CssmData &fieldValue) +static bool getFieldSubjectStd( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED { - CSSM_X509_ALGORITHM_IDENTIFIER *cssmAlgId = - (CSSM_X509_ALGORITHM_IDENTIFIER *)fieldValue.data(); - if(cssmAlgId->algorithm.Data == NULL) { - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + if(index != 0) { + return false; } - CL_cssmAlgIdToSnacc(*cssmAlgId, *snaccAlgId); + const DecodedCert &cert = dynamic_cast(item); + fieldValue.copy(cert.mCert.tbs.derSubject); + numFields = 1; + return true; } -static void freeField_AlgId ( - CssmOwnedData &fieldValue) +static bool getFieldIssuerStd( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED { - CSSM_X509_ALGORITHM_IDENTIFIER *cssmAlgId = - (CSSM_X509_ALGORITHM_IDENTIFIER *)fieldValue.data(); - if(cssmAlgId == NULL) { - return; - } - if(fieldValue.length() != sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)) { - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + if(index != 0) { + return false; } - CssmAllocator &alloc = fieldValue.allocator; - alloc.free(cssmAlgId->algorithm.Data); - alloc.free(cssmAlgId->parameters.Data); - memset(cssmAlgId, 0, sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)); + const DecodedCert &cert = dynamic_cast(item); + fieldValue.copy(cert.mCert.tbs.derIssuer); + numFields = 1; + return true; } - +/*** + *** TBS AlgId, Signature AlgId + *** Format = CSSM_X509_ALGORITHM_IDENTIFIER + ***/ /* TBS AlgId */ static bool getField_TbsAlgId ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - AlgorithmIdentifier *snaccAlgId = cert.certificateToSign->signature; - if(!tbsGetCheck(snaccAlgId, index)) { + const DecodedCert &cert = dynamic_cast(item); + const CSSM_X509_ALGORITHM_IDENTIFIER &srcAlgId = cert.mCert.tbs.signature; + if(!tbsGetCheck(srcAlgId.algorithm.Data, index)) { return false; } - getField_AlgId(snaccAlgId, fieldValue); + getField_AlgIdNSS(srcAlgId, fieldValue); numFields = 1; return true; } static void setField_TbsAlgId ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - tbsSetCheck(cert.certificateToSign->signature, fieldValue, + DecodedCert &cert = dynamic_cast(item); + CSSM_X509_ALGORITHM_IDENTIFIER &dstAlgId = cert.mCert.tbs.signature; + tbsSetCheck(dstAlgId.algorithm.Data, fieldValue, sizeof(CSSM_X509_ALGORITHM_IDENTIFIER), "TBS_AlgId"); - AlgorithmIdentifier *snaccAlgId = new AlgorithmIdentifier; - cert.certificateToSign->signature = snaccAlgId; - setField_AlgId(snaccAlgId, fieldValue); + setField_AlgIdNSS(fieldValue, dstAlgId, cert.coder()); } /* Cert AlgId - read only */ static bool getField_CertAlgId ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - AlgorithmIdentifier *snaccAlgId = cert.algorithmIdentifier; - if(!tbsGetCheck(snaccAlgId, index)) { + const DecodedCert &cert = dynamic_cast(item); + const CSSM_X509_ALGORITHM_IDENTIFIER &srcAlgId = cert.mCert.signatureAlgorithm; + if(!tbsGetCheck(srcAlgId.algorithm.Data, index)) { return false; } - getField_AlgId(snaccAlgId, fieldValue); + getField_AlgIdNSS(srcAlgId, fieldValue); numFields = 1; return true; } @@ -604,143 +326,50 @@ static bool getField_CertAlgId ( *** Format: CSSM_X509_TIME ***/ -/*** common code ***/ -static void getField_Time ( - const Time *snaccTime, - CssmOwnedData &fieldValue) // RETURNED -{ - CssmAllocator &alloc = fieldValue.allocator; - fieldValue.malloc(sizeof(CSSM_X509_TIME)); - CSSM_X509_TIME *cssmTime = - (CSSM_X509_TIME *)fieldValue.data(); - memset(cssmTime, 0, sizeof(CSSM_X509_TIME)); - - char *timeStr = NULL; - int timeStrLen = 0; - switch(snaccTime->choiceId) { - case Time::utcTimeCid: - cssmTime->timeType = BER_TAG_UTC_TIME; - timeStr = *snaccTime->utcTime; // an AsnOct - timeStrLen = snaccTime->utcTime->Len(); - break; - case Time::generalizedTimeCid: - timeStr = *snaccTime->generalizedTime; // an AsnOct - timeStrLen = snaccTime->generalizedTime->Len(); - cssmTime->timeType = BER_TAG_GENERALIZED_TIME; - break; - default: - /* snacc error, should never happen */ - cssmTime->timeType = BER_TAG_OCTET_STRING; - timeStr = *snaccTime->generalizedTime; // an AsnOct - timeStrLen = snaccTime->generalizedTime->Len(); - break; - } - - cssmTime->time.Data = reinterpret_cast(alloc.malloc(timeStrLen)); - cssmTime->time.Length = timeStrLen; - memcpy(cssmTime->time.Data, timeStr, timeStrLen); -} - -static void setField_Time ( - Time *snaccTime, - const CssmData &fieldValue) -{ - CSSM_X509_TIME *cssmTime = - (CSSM_X509_TIME *)fieldValue.data(); - const char *tStr = reinterpret_cast(cssmTime->time.Data); - size_t tLen = cssmTime->time.Length; - - switch(cssmTime->timeType) { - case BER_TAG_GENERALIZED_TIME: - snaccTime->choiceId = Time::generalizedTimeCid; - snaccTime->generalizedTime = new GeneralizedTime(tStr, tLen); - break; - case BER_TAG_UTC_TIME: - snaccTime->choiceId = Time::utcTimeCid; - snaccTime->utcTime = new UTCTime(tStr, tLen); - break; - default: - errorLog1("setField_Time: bad time tag (%d)\n", cssmTime->timeType); - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } -} - -static void freeField_Time ( - CssmOwnedData &fieldValue) -{ - CSSM_X509_TIME *cssmTime = (CSSM_X509_TIME *)fieldValue.data(); - if(cssmTime == NULL) { - return; - } - if(fieldValue.length() != sizeof(CSSM_X509_TIME)) { - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - fieldValue.allocator.free(cssmTime->time.Data); - memset(cssmTime, 0, sizeof(CSSM_X509_TIME)); -} - /*** not before ***/ static bool getField_NotBefore ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(!tbsGetCheck(cert.certificateToSign->validity, index)) { - return false; - } - if(cert.certificateToSign->validity->notBefore == NULL) { - return false; - } - getField_Time(cert.certificateToSign->validity->notBefore, fieldValue); - numFields = 1; - return true; + const DecodedCert &cert = dynamic_cast(item); + const NSS_Time &srcTime = cert.mCert.tbs.validity.notBefore; + return getField_TimeNSS(srcTime, index, numFields, fieldValue); } static void setField_NotBefore ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - /* anything could need mallocing except TBS */ - if(cert.certificateToSign->validity == NULL) { - cert.certificateToSign->validity = new Validity; - } - tbsSetCheck(cert.certificateToSign->validity->notBefore, fieldValue, + DecodedCert &cert = dynamic_cast(item); + NSS_Time &dstTime = cert.mCert.tbs.validity.notBefore; + tbsSetCheck(dstTime.item.Data, fieldValue, sizeof(CSSM_X509_TIME), "NotBefore"); - cert.certificateToSign->validity->notBefore = new Time; - setField_Time(cert.certificateToSign->validity->notBefore, fieldValue); + setField_TimeNSS(fieldValue, dstTime, cert.coder()); } /*** not after ***/ static bool getField_NotAfter ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(!tbsGetCheck(cert.certificateToSign->validity, index)) { - return false; - } - if(cert.certificateToSign->validity->notAfter == NULL) { - return false; - } - getField_Time(cert.certificateToSign->validity->notAfter, fieldValue); - numFields = 1; - return true; + const DecodedCert &cert = dynamic_cast(item); + const NSS_Time &srcTime = cert.mCert.tbs.validity.notAfter; + return getField_TimeNSS(srcTime, index, numFields, fieldValue); } static void setField_NotAfter ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - /* anything could need mallocing except TBS */ - if(cert.certificateToSign->validity == NULL) { - cert.certificateToSign->validity = new Validity; - } - tbsSetCheck(cert.certificateToSign->validity->notAfter, fieldValue, + DecodedCert &cert = dynamic_cast(item); + NSS_Time &dstTime = cert.mCert.tbs.validity.notAfter; + tbsSetCheck(dstTime.item.Data, fieldValue, sizeof(CSSM_X509_TIME), "NotAfter"); - cert.certificateToSign->validity->notAfter = new Time; - setField_Time(cert.certificateToSign->validity->notAfter, fieldValue); + setField_TimeNSS(fieldValue, dstTime, cert.coder()); } /*** @@ -752,53 +381,65 @@ static void setField_NotAfter ( *** beware. ***/ static bool getField_SubjectUniqueId ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - UniqueIdentifier *id = cert.certificateToSign->subjectUniqueIdentifier; - if(!tbsGetCheck(id, index)) { + const DecodedCert &cert = dynamic_cast(item); + const CSSM_DATA &srcBits = cert.mCert.tbs.subjectID; + if(!tbsGetCheck(srcBits.Data, index)) { return false; } - SC_asnBitsToCssmData(*id, fieldValue); + + /* That CSSM_DATA is a decoded BITSTRING; its length is in bits */ + CSSM_DATA tmp = srcBits; + tmp.Length = (tmp.Length + 7) / 8; + fieldValue.copy(tmp.Data, tmp.Length); numFields = 1; return true; } static void setField_SubjectUniqueId ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - tbsSetCheck(cert.certificateToSign->subjectUniqueIdentifier, fieldValue, 0, - "SubjectUniqueID"); - cert.certificateToSign->subjectUniqueIdentifier = new UniqueIdentifier( - reinterpret_cast(fieldValue.Data), fieldValue.Length * 8); + DecodedCert &cert = dynamic_cast(item); + CSSM_DATA &dstBits = cert.mCert.tbs.subjectID; + tbsSetCheck(dstBits.Data, fieldValue, 0, "SubjectUniqueID"); + cert.coder().allocCopyItem(fieldValue, dstBits); + dstBits.Length *= 8; } static bool getField_IssuerUniqueId ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - UniqueIdentifier *id = cert.certificateToSign->issuerUniqueIdentifier; - if(!tbsGetCheck(id, index)) { + const DecodedCert &cert = dynamic_cast(item); + const CSSM_DATA &srcBits = cert.mCert.tbs.issuerID; + if(!tbsGetCheck(srcBits.Data, index)) { return false; } - SC_asnBitsToCssmData(*id, fieldValue); + + /* That CSSM_DATA is a decoded BITSTRING; its length is in bits */ + CSSM_DATA tmp = srcBits; + tmp.Length = (tmp.Length + 7) / 8; + fieldValue.copy(tmp.Data, tmp.Length); numFields = 1; return true; } static void setField_IssuerUniqueId ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - tbsSetCheck(cert.certificateToSign->issuerUniqueIdentifier, fieldValue, 0, - "IssuerniqueID"); - cert.certificateToSign->issuerUniqueIdentifier = new UniqueIdentifier( - reinterpret_cast(fieldValue.Data), fieldValue.Length * 8); + DecodedCert &cert = dynamic_cast(item); + CSSM_DATA &dstBits = cert.mCert.tbs.issuerID; + tbsSetCheck(dstBits.Data, fieldValue, 0, "IssuerUniqueID"); + cert.coder().allocCopyItem(fieldValue, dstBits); + dstBits.Length *= 8; } /*** @@ -806,70 +447,54 @@ static void setField_IssuerUniqueId ( *** Format = CSSM_X509_SUBJECT_PUBLIC_KEY_INFO ***/ static bool getField_PublicKeyInfo ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(!tbsGetCheck(cert.certificateToSign->subjectPublicKeyInfo, index)) { - return false; - } - SubjectPublicKeyInfo *snaccKeyInfo = cert.certificateToSign->subjectPublicKeyInfo; - AlgorithmIdentifier *snaccAlgId = snaccKeyInfo->algorithm; - if(snaccAlgId == NULL) { - errorLog0("getField_PublicKeyInfo: cert has pubKeyInfo but no algorithm!\n"); + const DecodedCert &cert = dynamic_cast(item); + const CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &srcInfo = + cert.mCert.tbs.subjectPublicKeyInfo; + if(!tbsGetCheck(srcInfo.subjectPublicKey.Data, index)) { return false; } + CssmAllocator &alloc = fieldValue.allocator; fieldValue.malloc(sizeof(CSSM_X509_SUBJECT_PUBLIC_KEY_INFO)); - CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *cssmKeyInfo = + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *dstInfo = (CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *)fieldValue.data(); - memset(cssmKeyInfo, 0, sizeof(CSSM_X509_SUBJECT_PUBLIC_KEY_INFO)); - CL_snaccAlgIdToCssm(*snaccAlgId, cssmKeyInfo->algorithm, alloc); - - /* - * key info - the actual public key blob - is stored in the cert as a bit string; - * snacc will give us the actual bits which are invariably yet another DER - * encoding (e.g., PKCS1 for RSA public keys). - */ - size_t keyLen = (snaccKeyInfo->subjectPublicKey.BitLen() + 7) / 8; - cssmKeyInfo->subjectPublicKey.Data = (uint8 *)alloc.malloc(keyLen); - cssmKeyInfo->subjectPublicKey.Length = keyLen; - memcpy(cssmKeyInfo->subjectPublicKey.Data, - snaccKeyInfo->subjectPublicKey.BitOcts(), - keyLen); + + CL_copySubjPubKeyInfo(srcInfo, true, // length in bits here + *dstInfo, false, // length in bytes + alloc); + numFields = 1; return true; } static void setField_PublicKeyInfo ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - /* This fails if setField_PublicKeyStruct has already been called */ - tbsSetCheck(cert.certificateToSign->subjectPublicKeyInfo, fieldValue, + DecodedCert &cert = dynamic_cast(item); + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &dstKeyInfo = + cert.mCert.tbs.subjectPublicKeyInfo; + tbsSetCheck(dstKeyInfo.subjectPublicKey.Data, fieldValue, sizeof(CSSM_X509_SUBJECT_PUBLIC_KEY_INFO), "PubKeyInfo"); - CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *cssmKeyInfo = + + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *srcKeyInfo = (CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *)fieldValue.Data; - if((cssmKeyInfo->subjectPublicKey.Data == NULL) || - (cssmKeyInfo->subjectPublicKey.Length == 0)) { + if((srcKeyInfo->subjectPublicKey.Data == NULL) || + (srcKeyInfo->subjectPublicKey.Length == 0)) { CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); } - SubjectPublicKeyInfo *snaccKeyInfo = new SubjectPublicKeyInfo; - cert.certificateToSign->subjectPublicKeyInfo = snaccKeyInfo; - snaccKeyInfo->algorithm = new AlgorithmIdentifier; - - /* common code to convert algorithm info (algID and parameters) */ - const CSSM_X509_ALGORITHM_IDENTIFIER *cssmAlgId = &cssmKeyInfo->algorithm; - CL_cssmAlgIdToSnacc(*cssmAlgId, *snaccKeyInfo->algorithm); - - /* actual public key blob - AsnBits */ - snaccKeyInfo->subjectPublicKey.Set(reinterpret_cast - (cssmKeyInfo->subjectPublicKey.Data), - cssmKeyInfo->subjectPublicKey.Length * 8); - + ArenaAllocator arenaAlloc(cert.coder()); + CL_copySubjPubKeyInfo(*srcKeyInfo, false, // length in bytes here + dstKeyInfo, true, // length in bits + arenaAlloc); } + static void freeField_PublicKeyInfo ( CssmOwnedData &fieldValue) { @@ -879,9 +504,7 @@ static void freeField_PublicKeyInfo ( return; } CssmAllocator &alloc = fieldValue.allocator; - CSSM_X509_ALGORITHM_IDENTIFIER *algId = &cssmKeyInfo->algorithm; - alloc.free(algId->algorithm.Data); - alloc.free(algId->parameters.Data); + CL_freeCssmAlgId(&cssmKeyInfo->algorithm, alloc); alloc.free(cssmKeyInfo->subjectPublicKey.Data); memset(cssmKeyInfo, 0, sizeof(CSSM_X509_SUBJECT_PUBLIC_KEY_INFO));} @@ -890,12 +513,14 @@ static void freeField_PublicKeyInfo ( *** Format = CSSM_KEY ***/ static bool getField_PublicKeyStruct ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if(!tbsGetCheck(cert.certificateToSign->subjectPublicKeyInfo, index)) { + const DecodedCert &cert = dynamic_cast(item); + if(!tbsGetCheck(cert.mCert.tbs.subjectPublicKeyInfo.subjectPublicKey.Data, + index)) { return false; } CSSM_KEY_PTR cssmKey = cert.extractCSSMKey(fieldValue.allocator); @@ -905,40 +530,21 @@ static bool getField_PublicKeyStruct ( } static void setField_PublicKeyStruct ( - DecodedCert &cert, + DecodedItem &item, const CssmData &fieldValue) { - /* This fails if setField_PublicKeyInfo has already been called */ - tbsSetCheck(cert.certificateToSign->subjectPublicKeyInfo, fieldValue, - sizeof(CSSM_KEY), "PubKey"); + DecodedCert &cert = dynamic_cast(item); + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &dstKeyInfo = + cert.mCert.tbs.subjectPublicKeyInfo; + tbsSetCheck(dstKeyInfo.subjectPublicKey.Data, fieldValue, + sizeof(CSSM_KEY), "PubKeyStruct"); + CSSM_KEY_PTR cssmKey = (CSSM_KEY_PTR)fieldValue.data(); if((cssmKey->KeyData.Data == NULL) || (cssmKey->KeyData.Data == 0)) { CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); } - - SubjectPublicKeyInfo *snaccKeyInfo = new SubjectPublicKeyInfo; - cert.certificateToSign->subjectPublicKeyInfo = snaccKeyInfo; - snaccKeyInfo->algorithm = new AlgorithmIdentifier; - CL_cssmAlgToSnaccOid(cssmKey->KeyHeader.AlgorithmId, - snaccKeyInfo->algorithm->algorithm); - - /* NULL algorithm paramneters, always in this case */ - CL_nullAlgParams(*snaccKeyInfo->algorithm); - - /* actual public key blob - AsnBits */ - /*** - *** Note: ideally we'd like to just convert an incoming ref key to a raw - *** key here if necessary, but this occurs during CertCreateTemplate, - *** when we don't have a CSP handle. This conversion is the caller's - *** responsibility. - ***/ - if(cssmKey->KeyHeader.BlobType != CSSM_KEYBLOB_RAW) { - errorLog0("CL SetField: must specify RAW key blob\n"); - CssmError::throwMe(CSSM_ERRCODE_INVALID_FIELD_POINTER); - } - snaccKeyInfo->subjectPublicKey.Set(reinterpret_cast - (cssmKey->KeyData.Data), cssmKey->KeyData.Length * 8); + CL_CSSMKeyToSubjPubKeyInfoNSS(*cssmKey, dstKeyInfo, cert.coder()); } static void freeField_PublicKeyStruct ( @@ -954,16 +560,17 @@ static void freeField_PublicKeyStruct ( *** read-only ***/ static bool getField_Signature ( - const DecodedCert &cert, + DecodedItem &item, unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED CssmOwnedData &fieldValue) // RETURNED { - if((index > 0) || // max of one sig - (cert.signatureValue.BitLen() == 0)) { // no sig - must be TBS only + const DecodedCert &cert = dynamic_cast(item); + const CSSM_DATA &sigBits = cert.mCert.signature; + if(!tbsGetCheck(sigBits.Data, index)) { return false; } - SC_asnBitsToCssmData(cert.signatureValue, fieldValue); + fieldValue.copy(sigBits.Data, (sigBits.Length + 7) / 8); numFields = 1; return true; } @@ -972,22 +579,13 @@ static bool getField_Signature ( *** end of field-specific triplets ***/ -/* setField for read-only OIDs (i.e., the ones in cert, not TBS) */ -static void setField_ReadOnly ( - DecodedCert &cert, - const CssmData &fieldValue) -{ - errorLog0("Attempt to set a read-only field\n"); - CssmError::throwMe(CSSMERR_CL_UNKNOWN_TAG); -} - /* * Table to map OID to {get,set,free}field */ typedef struct { const CSSM_OID *fieldId; - getFieldFcn *getFcn; - setFieldFcn *setFcn; + getItemFieldFcn *getFcn; + setItemFieldFcn *setFcn; freeFieldFcn *freeFcn; // OPTIONAL - NULL means just free the // top-level data } oidToFieldFuncs; @@ -1024,11 +622,15 @@ static const oidToFieldFuncs fieldFuncTable[] = { getFieldIssuerNorm, &setField_ReadOnly, NULL }, { &CSSMOID_X509V1SubjectName, getFieldSubjectNorm, &setField_ReadOnly, NULL }, + { &CSSMOID_X509V1IssuerNameStd, + getFieldIssuerStd, &setField_ReadOnly, NULL }, + { &CSSMOID_X509V1SubjectNameStd, + getFieldSubjectStd, &setField_ReadOnly, NULL }, /* * Extensions, implemented in CertExtensions.cpp * When adding new ones, also add to: - * -- oidToSnaccObj() in CertExtensions.cpp + * -- clOidToNssInfo() in CLFieldsCommon.cpp * -- get/set/free functions in CertExtensions.{cpp,h} */ { &CSSMOID_KeyUsage, &getFieldKeyUsage, &setFieldKeyUsage, @@ -1042,30 +644,32 @@ static const oidToFieldFuncs fieldFuncTable[] = { { &CSSMOID_AuthorityKeyIdentifier, &getFieldAuthorityKeyId, &setFieldAuthorityKeyId, &freeFieldAuthorityKeyId } , { &CSSMOID_SubjectAltName, &getFieldSubjAltName, - &setFieldSubjAltName, &freeFieldSubjAltName } , + &setFieldSubjIssuerAltName, &freeFieldSubjIssuerAltName } , + { &CSSMOID_IssuerAltName, &getFieldIssuerAltName, + &setFieldSubjIssuerAltName, &freeFieldSubjIssuerAltName } , { &CSSMOID_CertificatePolicies, &getFieldCertPolicies, &setFieldCertPolicies, &freeFieldCertPolicies } , { &CSSMOID_NetscapeCertType, &getFieldNetscapeCertType, &setFieldNetscapeCertType, &freeFieldSimpleExtension } , + { &CSSMOID_CrlDistributionPoints, &getFieldCrlDistPoints, + &setFieldCrlDistPoints, &freeFieldCrlDistPoints }, { &CSSMOID_X509V3CertificateExtensionCStruct, &getFieldUnknownExt, - &setFieldUnknownExt, &freeFieldUnknownExt } + &setFieldUnknownExt, &freeFieldUnknownExt }, }; #define NUM_KNOWN_FIELDS (sizeof(fieldFuncTable) / sizeof(oidToFieldFuncs)) -#define NUM_STD_CERT_FIELDS 13 /* not including extensions */ - +#define NUM_STD_CERT_FIELDS 17 /* not including extensions */ /* map an OID to an oidToFieldFuncs */ static const oidToFieldFuncs *oidToFields( - const CssmOid &fieldId) + const CssmOid &fieldId) { - const oidToFieldFuncs *funcPtr = fieldFuncTable; - + const oidToFieldFuncs *fieldTable = fieldFuncTable; for(unsigned i=0; ifieldId)) { - return funcPtr; + if(fieldId == CssmData::overlay(*fieldTable->fieldId)) { + return fieldTable; } - funcPtr++; + fieldTable++; } CssmError::throwMe(CSSMERR_CL_UNKNOWN_TAG); } @@ -1086,16 +690,15 @@ bool DecodedCert::getCertFieldData( const CssmOid &fieldId, // which field unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED - CssmOwnedData &fieldValue) const // RETURNED + CssmOwnedData &fieldValue) // RETURNED { - CASSERT(certificateToSign != NULL); switch(mState) { - case CS_Empty: - case CS_Building: - errorLog0("DecodedCert::getCertField: can't parse undecoded cert!\n"); + case IS_Empty: + case IS_Building: + clErrorLog("DecodedCert::getCertField: can't parse undecoded cert!"); CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); - case CS_DecodedCert: - case CS_DecodedTBS: + case IS_DecodedAll: + case IS_DecodedTBS: break; } const oidToFieldFuncs *fieldFuncs = oidToFields(fieldId); @@ -1111,16 +714,15 @@ void DecodedCert::setCertField( const CssmOid &fieldId, // which field const CssmData &fieldValue) { - CASSERT(certificateToSign != NULL); switch(mState) { - case CS_Empty: // first time thru - mState = CS_Building; + case IS_Empty: // first time thru + mState = IS_Building; break; - case CS_Building: // subsequent passes + case IS_Building: // subsequent passes break; - case CS_DecodedCert: - case CS_DecodedTBS: - errorLog0("DecodedCert::setCertField: can't build on a decoded cert!\n"); + case IS_DecodedAll: + case IS_DecodedTBS: + clErrorLog("DecodedCert::setCertField: can't build on a decoded cert!"); CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); } if((fieldValue.data() == NULL) || (fieldValue.length() == 0)) { @@ -1161,8 +763,8 @@ void DecodedCert::getAllParsedCertFields( CSSM_FIELD_PTR &CertFields) // RETURNED { /* this is the max - some might be missing */ - uint32 maxFields = NUM_STD_CERT_FIELDS + mNumExtensions; - CSSM_FIELD_PTR outFields = (CSSM_FIELD_PTR)alloc.malloc(maxFields * sizeof(CSSM_FIELD)); + uint32 maxFields = NUM_STD_CERT_FIELDS + mDecodedExtensions.numExtensions(); + CSSM_FIELD_PTR outFields = (CSSM_FIELD_PTR)mAlloc.malloc(maxFields * sizeof(CSSM_FIELD)); /* * We'll be copying oids and values for fields we find into @@ -1173,7 +775,7 @@ void DecodedCert::getAllParsedCertFields( CSSM_FIELD_PTR currOutField; uint32 currOidDex; const CSSM_OID *currOid; - CssmAutoData aData(alloc); // for malloc/copy of outgoing data + CssmAutoData aData(mAlloc); // for malloc/copy of outgoing data /* query for each OID we know about */ for(currOidDex=0; currOidDexFieldValue = aData.release(); aData.copy(*currOid); @@ -1208,10 +810,10 @@ void DecodedCert::getAllParsedCertFields( numFields, // shouldn't change aData); if(!brtn) { - errorLog0("getAllParsedCertFields: index screwup\n"); + clErrorLog("getAllParsedCertFields: index screwup"); CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); } - CASSERT(numOutFields < maxFields); + assert(numOutFields < maxFields); currOutField = &outFields[numOutFields]; currOutField->FieldValue = aData.release(); aData.copy(*currOid); diff --git a/AppleX509CL/CrlFields.cpp b/AppleX509CL/CrlFields.cpp new file mode 100644 index 00000000..8ae54a7e --- /dev/null +++ b/AppleX509CL/CrlFields.cpp @@ -0,0 +1,725 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * CrlFields.cpp - convert between NSS-based NSS_Crl components and CDSA-style + * fields. A major component of DecodedCrl. + * + * Created 8/29/2002 by Doug Mitchell. + * Copyright (c) 2002 by Apple Computer. + */ + +#include "DecodedCrl.h" +#include +#include "cldebugging.h" +#include "CLCrlExtensions.h" +#include "CLCertExtensions.h" +#include "CLFieldsCommon.h" +#include "clNssUtils.h" +#include "clNameUtils.h" +#include +#include +#include +#include +#include + +static void CL_freeCssmExtensions( + CSSM_X509_EXTENSIONS &extens, + CssmAllocator &alloc); + +/*** + *** Version + *** Format = DER-encoded int (max of four bytes in this case) + ***/ +static bool getField_Version ( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + const DecodedCrl &crl = dynamic_cast(item); + const CSSM_DATA &vers = crl.mCrl.tbs.version; + if(!tbsGetCheck(vers.Data, index)) { + /* not present, optional */ + return false; + } + fieldValue.copy(vers.Data, vers.Length); + numFields = 1; + return true; +} + +static void setField_Version ( + DecodedItem &item, + const CssmData &fieldValue) +{ + DecodedCrl &crl = dynamic_cast(item); + CSSM_DATA &vers = crl.mCrl.tbs.version; + tbsSetCheck(vers.Data, fieldValue, 0, "version"); + crl.coder().allocCopyItem(fieldValue, vers); +} + +/*** issuer + *** Format = CSSM_X509_NAME + *** class Name from sm_x501if + ***/ +static bool getField_Issuer ( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + if(index != 0) { + return false; + } + + bool brtn; + + const DecodedCrl &crl = dynamic_cast(item); + try { + brtn = getField_RDN_NSS(crl.mCrl.tbs.issuer, fieldValue); + if(brtn) { + numFields = 1; + } + } + catch (...) { + freeField_RDN(fieldValue); + throw; + } + return brtn; +} + +static void setField_Issuer ( + DecodedItem &item, + const CssmData &fieldValue) +{ + DecodedCrl &crl = dynamic_cast(item); + const CSSM_X509_NAME *cssmName = (const CSSM_X509_NAME *)fieldValue.Data; + NSS_Name &nssName = crl.mCrl.tbs.issuer; + tbsSetCheck(nssName.rdns, fieldValue, sizeof(CSSM_X509_NAME), + "IssuerName"); + CL_cssmNameToNss(*cssmName, nssName, crl.coder()); +} + +/*** + *** This/Next update + *** Format: CSSM_X509_TIME + ***/ +static bool getField_ThisUpdate ( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + const DecodedCrl &crl = dynamic_cast(item); + const NSS_Time &srcTime = crl.mCrl.tbs.thisUpdate; + return getField_TimeNSS(srcTime, index, numFields, fieldValue); +} + +static void setField_ThisUpdate ( + DecodedItem &item, + const CssmData &fieldValue) +{ + DecodedCrl &crl = dynamic_cast(item); + NSS_Time &dstTime = crl.mCrl.tbs.thisUpdate; + tbsSetCheck(dstTime.item.Data, fieldValue, + sizeof(CSSM_X509_TIME), "NotBefore"); + setField_TimeNSS(fieldValue, dstTime, crl.coder()); +} + +static bool getField_NextUpdate ( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + const DecodedCrl &crl = dynamic_cast(item); + const NSS_Time &srcTime = crl.mCrl.tbs.nextUpdate; + return getField_TimeNSS(srcTime, index, numFields, fieldValue); +} + +static void setField_NextUpdate ( + DecodedItem &item, + const CssmData &fieldValue) +{ + DecodedCrl &crl = dynamic_cast(item); + NSS_Time &dstTime = crl.mCrl.tbs.nextUpdate; + tbsSetCheck(dstTime.item.Data, fieldValue, + sizeof(CSSM_X509_TIME), "NotBefore"); + setField_TimeNSS(fieldValue, dstTime, crl.coder()); +} + +/*** + *** Issuer Name (normalized and encoded version) + *** Format = CSSM_DATA containing the DER encoding of the normalized name + ***/ +static bool getFieldIssuerNorm( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + if(index != 0) { + return false; + } + const DecodedCrl &crl = dynamic_cast(item); + return getField_normRDN_NSS(crl.mCrl.tbs.derIssuer, numFields, + fieldValue); +} + +/*** + *** TBS AlgId + *** Format = CSSM_X509_ALGORITHM_IDENTIFIER + ***/ +static bool getField_CrlTbsAlgId ( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + const DecodedCrl &crl = dynamic_cast(item); + const CSSM_X509_ALGORITHM_IDENTIFIER &srcAlgId = + crl.mCrl.signatureAlgorithm; + if(!tbsGetCheck(srcAlgId.algorithm.Data, index)) { + return false; + } + getField_AlgIdNSS(srcAlgId, fieldValue); + numFields = 1; + return true; +} + +/* + * Support for entries in revocation list + */ +static void nssRevokedEntryToCssm( + NSS_RevokedCert &nssEntry, + CSSM_X509_REVOKED_CERT_ENTRY &cssmEntry, + CssmAllocator &alloc) +{ + clAllocCopyData(alloc, nssEntry.userCertificate, cssmEntry.certificateSerialNumber); + CL_nssTimeToCssm(nssEntry.revocationDate, cssmEntry.revocationDate, alloc); + + /* CSSM_X509_EXTENSIONS extensions */ + NSS_CertExtension **nssExtens = nssEntry.extensions; + if(nssExtens == NULL) { + /* done */ + return; + } + + /* + * First we have to decode the NSS-style Extensions into a + * DecodedExtensions object. For cert- and CRL-wide extensions, this + * is done at the construction of Decoded{Cert,Crl}. However for + * per-CRL-entry entensions, this is (currently) the only place + * this decoding is done. + */ + SecNssCoder coder; + DecodedExtensions decodedExtens(coder, alloc); + decodedExtens.decodeFromNss(nssExtens); + + /* convert to CDSA style */ + decodedExtens.convertToCdsa(cssmEntry.extensions, alloc); +} + +static void freeCssmEntry( + CSSM_X509_REVOKED_CERT_ENTRY_PTR cssmEntry, + CssmAllocator &alloc) +{ + if(cssmEntry == NULL) { + return; + } + if(cssmEntry->certificateSerialNumber.Data) { + alloc.free(cssmEntry->certificateSerialNumber.Data); + cssmEntry->certificateSerialNumber.Data = NULL; + cssmEntry->certificateSerialNumber.Length = 0; + } + CL_freeCssmTime(&cssmEntry->revocationDate, alloc); + + /* CSSM_X509_EXTENSIONS extensions */ + CL_freeCssmExtensions(cssmEntry->extensions, alloc); + + memset(cssmEntry, 0, sizeof(CSSM_X509_REVOKED_CERT_ENTRY)); +} + +static void nssRevokedListToCssm( + NSS_RevokedCert **nssList, // may be NULL + CSSM_X509_REVOKED_CERT_LIST_PTR cssmList, + CssmAllocator &alloc) +{ + unsigned numEntries = clNssArraySize((const void **)nssList); + cssmList->numberOfRevokedCertEntries = numEntries; + if(numEntries == 0) { + cssmList->revokedCertEntry = NULL; + return; + } + cssmList->revokedCertEntry = (CSSM_X509_REVOKED_CERT_ENTRY_PTR)alloc.malloc( + sizeof(CSSM_X509_REVOKED_CERT_ENTRY) * numEntries); + memset(cssmList->revokedCertEntry, 0, + sizeof(CSSM_X509_REVOKED_CERT_ENTRY) * numEntries); + for(unsigned dex=0; dexrevokedCertEntry[dex]; + nssRevokedEntryToCssm(*nssEntry, *cssmEntry, alloc); + } +} + + +static void freeCssmRevokedList( + CSSM_X509_REVOKED_CERT_LIST_PTR cssmList, + CssmAllocator &alloc) +{ + if(cssmList == NULL) { + return; + } + for(unsigned dex=0; dexnumberOfRevokedCertEntries; dex++) { + CSSM_X509_REVOKED_CERT_ENTRY_PTR cssmEntry = + &cssmList->revokedCertEntry[dex]; + freeCssmEntry(cssmEntry, alloc); + } + if(cssmList->revokedCertEntry) { + alloc.free(cssmList->revokedCertEntry); + } + memset(cssmList, 0, sizeof(CSSM_X509_REVOKED_CERT_LIST)); +} + +/*** + *** SignedCRL + *** Format: CSSM_X509_SIGNED_CRL (the whole enchilada, parsed) + ***/ +static bool getField_SignedCrl ( + DecodedItem &item, + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + CssmAllocator &alloc = fieldValue.allocator; + + const DecodedCrl &nssCrl = dynamic_cast(item); + const NSS_TBSCrl &nssTbs = nssCrl.mCrl.tbs; + fieldValue.malloc(sizeof(CSSM_X509_SIGNED_CRL)); + CSSM_X509_SIGNED_CRL &cssmCrl = *((CSSM_X509_SIGNED_CRL *)fieldValue.data()); + + memset(&cssmCrl, 0, sizeof(CSSM_X509_SIGNED_CRL)); + CSSM_X509_TBS_CERTLIST &cssmTbs = cssmCrl.tbsCertList; + + /* version */ + clAllocCopyData(alloc, nssTbs.version, cssmTbs.version); + + /* CSSM_X509_ALGORITHM_IDENTIFIER signature - in TBS and CRL */ + CL_copyAlgId(nssTbs.signature, cssmTbs.signature, alloc); + CL_copyAlgId(nssCrl.mCrl.signatureAlgorithm, + cssmCrl.signature.algorithmIdentifier, alloc); + + /* CSSM_X509_NAME issuer */ + CL_nssNameToCssm(nssTbs.issuer, cssmTbs.issuer, alloc); + + /* CSSM_X509_TIME thisUpdate, nextUpdate */ + CL_nssTimeToCssm(nssTbs.thisUpdate, cssmTbs.thisUpdate, alloc); + CL_nssTimeToCssm(nssTbs.nextUpdate, cssmTbs.nextUpdate, alloc); + + /* CSSM_X509_REVOKED_CERT_LIST_PTR revokedCertificates */ + if(nssTbs.revokedCerts != NULL) { + cssmTbs.revokedCertificates = (CSSM_X509_REVOKED_CERT_LIST_PTR) + alloc.malloc(sizeof(CSSM_X509_REVOKED_CERT_LIST)); + memset(cssmTbs.revokedCertificates, 0, sizeof(CSSM_X509_REVOKED_CERT_LIST)); + nssRevokedListToCssm(nssTbs.revokedCerts, + cssmTbs.revokedCertificates, alloc); + } + + /* CSSM_X509_EXTENSIONS extensions */ + const DecodedExtensions &decodedExtens = nssCrl.decodedExtens(); + decodedExtens.convertToCdsa(cssmTbs.extensions, alloc); + + /* raw signature - stored in bits - note signature.algId set above */ + CSSM_DATA nssSig = nssCrl.mCrl.signature; + nssSig.Length = (nssSig.Length + 7) / 8; + clAllocCopyData(alloc, nssSig, cssmCrl.signature.encrypted); + numFields = 1; + return true; +} + +static void setField_SignedCrl ( + DecodedItem &item, + const CssmData &fieldValue) +{ + /* TBD - writing CRLs not supported now */ + CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED); +} + +void freeField_SignedCrl ( + CssmOwnedData &fieldValue) +{ + CSSM_X509_SIGNED_CRL *cssmCrl = + (CSSM_X509_SIGNED_CRL *)fieldValue.data(); + + if(cssmCrl == NULL) { + return; + } + if(fieldValue.length() != sizeof(CSSM_X509_SIGNED_CRL)) { + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + CssmAllocator &alloc = fieldValue.allocator; + CSSM_X509_TBS_CERTLIST_PTR cssmTbs = &cssmCrl->tbsCertList; + if(cssmTbs == NULL) { + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + + /* run down the fields */ + if(cssmTbs->version.Data) { + alloc.free(cssmTbs->version.Data); + } + + /* CSSM_X509_ALGORITHM_IDENTIFIER signature - in TBS and CRL */ + CL_freeCssmAlgId(&cssmTbs->signature, alloc); + CL_freeCssmAlgId(&cssmCrl->signature.algorithmIdentifier, alloc); + + /* issuer, thisUpdate, nextUpdate */ + CL_freeX509Name(&cssmTbs->issuer, alloc); + CL_freeCssmTime(&cssmTbs->thisUpdate, alloc); + CL_freeCssmTime(&cssmTbs->nextUpdate, alloc); + + /* CSSM_X509_REVOKED_CERT_LIST_PTR revokedCertificates */ + freeCssmRevokedList(cssmTbs->revokedCertificates, alloc); + alloc.free(cssmTbs->revokedCertificates); + + /* CSSM_X509_EXTENSIONS extensions */ + CL_freeCssmExtensions(cssmTbs->extensions, alloc); + + /* raw signature - note signature.algId freed above */ + alloc.free(cssmCrl->signature.encrypted.Data); + + memset(cssmCrl, 0, sizeof(CSSM_X509_SIGNED_CRL)); +} + +/* + * Table to map OID to {get,set,free}field + */ +typedef struct { + const CSSM_OID *fieldId; + getItemFieldFcn *getFcn; + setItemFieldFcn *setFcn; + freeFieldFcn *freeFcn; // OPTIONAL - NULL means just free the + // top-level data +} oidToFieldFuncs; + + +static const oidToFieldFuncs crlFieldTable[] = { + /* this first one, which returns everything in a parsed format, + * is intended to be normally the only field used */ + { &CSSMOID_X509V2CRLSignedCrlCStruct, + &getField_SignedCrl, &setField_SignedCrl, &freeField_SignedCrl }, + { &CSSMOID_X509V2CRLVersion, + &getField_Version, &setField_Version, NULL }, + { &CSSMOID_X509V1CRLIssuerNameCStruct, + &getField_Issuer, &setField_Issuer, &freeField_RDN }, + { &CSSMOID_X509V1CRLThisUpdate, + &getField_ThisUpdate, &setField_ThisUpdate, &freeField_Time }, + { &CSSMOID_X509V1CRLNextUpdate, + &getField_NextUpdate, &setField_NextUpdate, &freeField_Time }, + { &CSSMOID_X509V1IssuerName, + getFieldIssuerNorm, &setField_ReadOnly, NULL }, + { &CSSMOID_X509V1SignatureAlgorithmTBS, + &getField_CrlTbsAlgId, &setField_ReadOnly, &freeField_AlgId }, + // ...etc.. + /* + * Extensions, implemented in CrlExtensions.cpp + * When adding new ones, also add to: + * -- clOidToNssInfo() in CLFieldsCommon.cpp + * -- get/set/free functions in CrlExtensions.{cpp,h} + * -- DecodedExten::parse in DecodedExtensions.cpp + */ + { &CSSMOID_CrlNumber, + &getFieldCrlNumber, &setFieldCrlNumber, freeFieldSimpleExtension }, + { &CSSMOID_DeltaCrlIndicator, + &getFieldDeltaCrl, &setFieldCrlNumber, freeFieldSimpleExtension }, + { &CSSMOID_CertIssuer, // get/set not implemented + &getField_Unimplemented, &setField_ReadOnly, + &freeFieldSubjIssuerAltName}, + { &CSSMOID_CrlReason, // get/set not implemented + &getField_Unimplemented, &setField_ReadOnly, + freeFieldSimpleExtension}, + { &CSSMOID_IssuingDistributionPoint, // get/set not implemented + &getField_Unimplemented, &setField_ReadOnly, + &freeFieldIssuingDistPoint}, + { &CSSMOID_HoldInstructionCode, // get/set not implemented + &getField_Unimplemented, &setField_ReadOnly, + &freeFieldOidOrData}, + { &CSSMOID_InvalidityDate, // get/set not implemented + &getField_Unimplemented, &setField_ReadOnly, + &freeFieldOidOrData}, + + /* in common with CertExtensions */ + { &CSSMOID_AuthorityKeyIdentifier, &getFieldAuthorityKeyId, + &setFieldAuthorityKeyId, &freeFieldAuthorityKeyId } , + { &CSSMOID_X509V3CertificateExtensionCStruct, &getFieldUnknownExt, + &setFieldUnknownExt, &freeFieldUnknownExt }, + { &CSSMOID_SubjectAltName, &getFieldSubjAltName, + &setFieldSubjIssuerAltName, &freeFieldSubjIssuerAltName } , + { &CSSMOID_IssuerAltName, &getFieldIssuerAltName, + &setFieldSubjIssuerAltName, &freeFieldSubjIssuerAltName } , + // etc.. +}; + +#define NUM_KNOWN_FIELDS (sizeof(crlFieldTable) / sizeof(oidToFieldFuncs)) +#define NUM_STD_CRL_FIELDS 2 /* TBD not including extensions */ + +/* map an OID to an oidToFieldFuncs */ +static const oidToFieldFuncs *oidToFields( + const CssmOid &fieldId) +{ + const oidToFieldFuncs *fieldTable = crlFieldTable; + for(unsigned i=0; ifieldId)) { + return fieldTable; + } + fieldTable++; + } + CssmError::throwMe(CSSMERR_CL_UNKNOWN_TAG); +} + +/* + * Common routine to free OID-specific field data. Used in the + * public DecodedCrl::freeCrlFieldData and when freeing + * extensions in a CSSM_X509_TBS_CERTLIST. + */ +static void CL_freeCrlFieldData( + const CssmOid &fieldId, + CssmOwnedData &fieldValue, + bool reset = true) +{ + if((fieldValue.data() == NULL) || (fieldValue.length() == 0)) { + CssmError::throwMe(CSSM_ERRCODE_INVALID_FIELD_POINTER); + } + const oidToFieldFuncs *fieldFuncs = oidToFields(fieldId); + if(fieldFuncs->freeFcn != NULL) { + /* optional - simple cases handled below */ + fieldFuncs->freeFcn(fieldValue); + } + if(reset) { + fieldValue.reset(); + fieldValue.release(); + } +} + +/* + * Common routime to free a CSSM_X509_EXTENSIONS. Used to free + * CSSM_X509_TBS_CERTLIST.extensions and + * CSSM_X509_REVOKED_CERT_ENTRY.extensions. + * We just cook up a CssmOid and a CssmOwnedData for each extension + * and pass to CL_freeCrlFieldData(). + */ +static void CL_freeCssmExtensions( + CSSM_X509_EXTENSIONS &extens, + CssmAllocator &alloc) +{ + for(uint32 dex=0; dexformat) { + case CSSM_X509_DATAFORMAT_ENCODED: + fieldOid = &CSSMOID_X509V3CertificateExtensionCStruct; + break; + case CSSM_X509_DATAFORMAT_PARSED: + case CSSM_X509_DATAFORMAT_PAIR: + fieldOid = &exten->extnId; + break; + default: + clErrorLog("CL_freeCssmExtensions: bad exten->format (%d)", + (int)exten->format); + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + + const CssmOid &fieldId = CssmOid::overlay(*fieldOid); + CssmData cData((uint8 *)exten, sizeof(CSSM_X509_EXTENSION)); + CssmRemoteData fieldValue(alloc, cData); + CL_freeCrlFieldData(fieldId, fieldValue, false); + fieldValue.release(); // but no free (via reset() */ + } + alloc.free(extens.extensions); + memset(&extens, 0, sizeof(CSSM_X509_EXTENSIONS)); +} + + + +/*** + *** Public functions + ***/ + +/* + * Obtain the index'th occurrence of field specified by fieldId in specified cert. + * Format of the returned field depends on fieldId. + * Returns total number of fieldId fields in the cert if index is 0. + * FieldValue assumed to be empty on entry. + * Returns true if specified field was found, else returns false. + */ +bool DecodedCrl::getCrlFieldData( + const CssmOid &fieldId, // which field + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue) // RETURNED +{ + switch(mState) { + case IS_Empty: + case IS_Building: + clErrorLog("DecodedCrl::getCrlField: can't parse undecoded CRL!"); + CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); + case IS_DecodedAll: + case IS_DecodedTBS: + break; + } + const oidToFieldFuncs *fieldFuncs = oidToFields(fieldId); + return fieldFuncs->getFcn(*this, index, numFields, fieldValue); +} + +/* + * Set the field specified by fieldId in the specified Cert. + * Note no index - individual field routines either append (for extensions) + * or if field already set ::throwMe(for all others) + */ +void DecodedCrl::setCrlField( + const CssmOid &fieldId, // which field + const CssmData &fieldValue) +{ + switch(mState) { + case IS_Empty: // first time thru + mState = IS_Building; + break; + case IS_Building: // subsequent passes + break; + case IS_DecodedAll: + case IS_DecodedTBS: + clErrorLog("DecodedCrl::setCrlField: can't build on a decoded CRL!"); + CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); + } + if((fieldValue.data() == NULL) || (fieldValue.length() == 0)) { + CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); + } + const oidToFieldFuncs *fieldFuncs = oidToFields(fieldId); + const CssmData &value = CssmData::overlay(fieldValue); + fieldFuncs->setFcn(*this, value); +} + +/* + * Free the fieldId-specific data referred to by fieldValue->Data. + * No state from DecodedCrl needed; use the routine shared with + * CL_freeCssmExtensions(). + */ +void DecodedCrl::freeCrlFieldData( + const CssmOid &fieldId, + CssmOwnedData &fieldValue) +{ + CL_freeCrlFieldData(fieldId, fieldValue); +} + + +/* + * Common means to get all fields from a decoded CRL. Used in + * CrlGetAllTemplateFields and CrlGetAllFields. + */ +void DecodedCrl::getAllParsedCrlFields( + uint32 &NumberOfFields, // RETURNED + CSSM_FIELD_PTR &CrlFields) // RETURNED +{ + /* this is the max - some might be missing */ + uint32 maxFields = NUM_STD_CRL_FIELDS + mDecodedExtensions.numExtensions(); + CSSM_FIELD_PTR outFields = (CSSM_FIELD_PTR)mAlloc.malloc( + maxFields * sizeof(CSSM_FIELD)); + + /* + * We'll be copying oids and values for fields we find into + * outFields; current number of valid fields found in numOutFields. + */ + memset(outFields, 0, maxFields * sizeof(CSSM_FIELD)); + uint32 numOutFields = 0; + CSSM_FIELD_PTR currOutField; + uint32 currOidDex; + const CSSM_OID *currOid; + CssmAutoData aData(mAlloc); // for malloc/copy of outgoing data + + /* query for each OID we know about */ + for(currOidDex=0; currOidDexfieldId; + uint32 numFields; // for THIS oid + + /* + * Return false if field not there, which is not an error here. + * Actual exceptions are fatal. + */ + if(!fieldFuncs->getFcn(*this, + 0, // index - looking for first one + numFields, + aData)) { + continue; + } + + /* got some data for this oid - copy it and oid to outgoing CrlFields */ + assert(numOutFields < maxFields); + currOutField = &outFields[numOutFields]; + currOutField->FieldValue = aData.release(); + aData.copy(*currOid); + currOutField->FieldOid = aData.release(); + numOutFields++; + + /* if more fields are available for this OID, snag them too */ + for(uint32 fieldDex=1; fieldDexgetFcn(*this, + fieldDex, + numFields, // shouldn't change + aData); + if(!brtn) { + clErrorLog("getAllParsedCrlFields: index screwup"); + CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); + } + assert(numOutFields < maxFields); + currOutField = &outFields[numOutFields]; + currOutField->FieldValue = aData.release(); + aData.copy(*currOid); + currOutField->FieldOid = aData.release(); + numOutFields++; + } /* multiple fields for currOid */ + } /* for each known OID */ + + NumberOfFields = numOutFields; + CrlFields = outFields; +} + +void +DecodedCrl::describeFormat( + CssmAllocator &alloc, + uint32 &NumberOfFields, + CSSM_OID_PTR &OidList) +{ + /* malloc in app's space, do deep copy (including ->Data) */ + CSSM_OID_PTR oidList = (CSSM_OID_PTR)alloc.malloc( + NUM_KNOWN_FIELDS * sizeof(CSSM_OID)); + memset(oidList, 0, NUM_KNOWN_FIELDS * sizeof(CSSM_OID)); + for(unsigned i=0; i #include +#include +// ??? #include "clExtensionTemplates.h" DecodedCert::DecodedCert( AppleX509CLSession &session) - : alloc(session), - mSession(session) + : DecodedItem(session) { - certificateToSign = new CertificateToSign; - reset(); + memset(&mCert, 0, sizeof(mCert)); } /* one-shot constructor, decoding from DER-encoded data */ DecodedCert::DecodedCert( AppleX509CLSession &session, const CssmData &encodedCert) - : alloc(session), - mSession(session) + : DecodedItem(session) { - reset(); - SC_decodeAsnObj(encodedCert, *this); - decodeExtensions(); - mState = CS_DecodedCert; + memset(&mCert, 0, sizeof(mCert)); + PRErrorCode prtn = mCoder.decode(encodedCert.data(), encodedCert.length(), + NSS_SignedCertTemplate, &mCert); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + mDecodedExtensions.decodeFromNss(mCert.tbs.extensions); + mState = IS_DecodedAll; } DecodedCert::~DecodedCert() { - /* free all extensions */ - unsigned dex; - - for(dex=0; dexextnId; - delete exten->snaccObj; - } - alloc.free(mExtensions); - reset(); } /* decode TBSCert and its extensions */ void DecodedCert::decodeTbs( const CssmData &encodedTbs) { - CASSERT(mState == CS_Empty); - CASSERT(certificateToSign != NULL); - try { - SC_decodeAsnObj(encodedTbs, *certificateToSign); + assert(mState == IS_Empty); + + memset(&mCert, 0, sizeof(mCert)); + PRErrorCode prtn = mCoder.decode(encodedTbs.data(), encodedTbs.length(), + NSS_TBSCertificateTemplate, &mCert.tbs); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); } - catch (...) { - errorLog0("decodeTbs: tbs.BDec failure\n"); - /* FIXME - leave in bad state? delete and clear? let's be cautious...*/ - delete certificateToSign; - certificateToSign = new CertificateToSign; + mDecodedExtensions.decodeFromNss(mCert.tbs.extensions); + mState = IS_DecodedTBS; +} + +void DecodedCert::encodeExtensions() +{ + NSS_TBSCertificate &tbs = mCert.tbs; + assert(mState == IS_Building); + assert(tbs.extensions == NULL); + + if(mDecodedExtensions.numExtensions() == 0) { + /* no extensions, no error */ + return; } - decodeExtensions(); - mState = CS_DecodedTBS; + mDecodedExtensions.encodeToNss(tbs.extensions); } /* @@ -97,23 +99,25 @@ void DecodedCert::encodeTbs( CssmOwnedData &encodedTbs) { encodeExtensions(); - CASSERT(mState == CS_Building); - if(certificateToSign == NULL) { - errorLog0("DecodedCert::encodeTbs: no TBS\n"); - CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); - } - + assert(mState == IS_Building); + /* enforce required fields - could go deeper, maybe we should */ - if((certificateToSign->signature == NULL) || - (certificateToSign->issuer == NULL) || - (certificateToSign->validity == NULL) || - (certificateToSign->subject == NULL) || - (certificateToSign->subjectPublicKeyInfo == NULL)) { - errorLog0("DecodedCert::encodeTbs: incomplete TBS\n"); + NSS_TBSCertificate &tbs = mCert.tbs; + if((tbs.signature.algorithm.Data == NULL) || + (tbs.issuer.rdns == NULL) || + (tbs.subject.rdns == NULL) || + (tbs.subjectPublicKeyInfo.subjectPublicKey.Data == NULL)) { + clErrorLog("DecodedCert::encodeTbs: incomplete TBS"); /* an odd, undocumented error return */ CssmError::throwMe(CSSMERR_CL_NO_FIELD_VALUES); } - SC_encodeAsnObj(*certificateToSign, encodedTbs, MAX_TEMPLATE_SIZE); + + PRErrorCode prtn; + prtn = SecNssEncodeItemOdata(&tbs, NSS_TBSCertificateTemplate, + encodedTbs); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } } /* @@ -127,56 +131,72 @@ void DecodedCert::encodeTbs( CSSM_KEYUSE DecodedCert::inferKeyUsage() const { CSSM_KEYUSE keyUse = 0; - DecodedExten *decodedExten; + const DecodedExten *decodedExten; uint32 numFields; - decodedExten = findDecodedExt(id_ce_keyUsage, false, 0, numFields); + /* Basic KeyUsage */ + decodedExten = DecodedItem::findDecodedExt(CSSMOID_KeyUsage, false, + 0, numFields); if(decodedExten) { - KeyUsage *ku = dynamic_cast(decodedExten->snaccObj); - if(ku == NULL) { - errorLog0("inferKeyUsage: dynamic_cast failure(1)\n"); - CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); - } - if(ku->GetBit(KeyUsage::digitalSignature)) { + CSSM_DATA *ku = (CSSM_DATA *)decodedExten->nssObj(); + assert(ku != NULL); + CE_KeyUsage kuse = clBitStringToKeyUsage(*ku); + if(kuse & CE_KU_DigitalSignature) { keyUse |= CSSM_KEYUSE_VERIFY; } - if(ku->GetBit(KeyUsage::nonRepudiation)) { + if(kuse & CE_KU_NonRepudiation) { keyUse |= CSSM_KEYUSE_VERIFY; } - if(ku->GetBit(KeyUsage::keyEncipherment)) { + if(kuse & CE_KU_KeyEncipherment) { keyUse |= CSSM_KEYUSE_WRAP; } - if(ku->GetBit(KeyUsage::keyAgreement)) { + if(kuse & CE_KU_KeyAgreement) { keyUse |= CSSM_KEYUSE_DERIVE; } - if(ku->GetBit(KeyUsage::keyCertSign)) { + if(kuse & CE_KU_KeyCertSign) { keyUse |= CSSM_KEYUSE_VERIFY; } - if(ku->GetBit(KeyUsage::cRLSign)) { + if(kuse & CE_KU_CRLSign) { keyUse |= CSSM_KEYUSE_VERIFY; } - if(ku->GetBit(KeyUsage::dataEncipherment)) { + if(kuse & CE_KU_DataEncipherment) { keyUse |= CSSM_KEYUSE_ENCRYPT; } } - decodedExten = findDecodedExt(id_ce_extKeyUsage, false, 0, numFields); + + /* Extended key usage */ + decodedExten = DecodedItem::findDecodedExt(CSSMOID_ExtendedKeyUsage, + false, 0, numFields); if(decodedExten) { - ExtKeyUsageSyntax *eku = - dynamic_cast(decodedExten->snaccObj); - if(eku == NULL) { - errorLog0("inferKeyUsage: dynamic_cast failure(2)\n"); - CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); - } - unsigned numOids = eku->Count(); - eku->SetCurrToFirst(); - unsigned oidDex; - for(oidDex=0; oidDexCurr(); - if(*purp == id_kp_codeSigning) { - keyUse |= CSSM_KEYUSE_VERIFY; + NSS_ExtKeyUsage *euse = (NSS_ExtKeyUsage *)decodedExten->nssObj(); + assert(euse != NULL); + unsigned numUses = clNssArraySize((const void **)euse->purposes); + for(unsigned dex=0; dexpurposes[dex]; + if(clCompareCssmData(thisUse, &CSSMOID_ExtendedKeyUsageAny)) { + /* we're done */ + keyUse = CSSM_KEYUSE_ANY; + break; + } + else if(clCompareCssmData(thisUse, &CSSMOID_ServerAuth)) { + keyUse |= (CSSM_KEYUSE_VERIFY | CSSM_KEYUSE_ENCRYPT); + } + else if(clCompareCssmData(thisUse, &CSSMOID_ClientAuth)) { + keyUse |= (CSSM_KEYUSE_VERIFY | CSSM_KEYUSE_ENCRYPT); + } + else if(clCompareCssmData(thisUse, &CSSMOID_ExtendedUseCodeSigning)) { + keyUse |= CSSM_KEYUSE_VERIFY; + } + else if(clCompareCssmData(thisUse, &CSSMOID_EmailProtection)) { + keyUse |= + (CSSM_KEYUSE_VERIFY | CSSM_KEYUSE_WRAP | CSSM_KEYUSE_DERIVE); + } + else if(clCompareCssmData(thisUse, &CSSMOID_TimeStamping)) { + keyUse |= CSSM_KEYUSE_VERIFY; + } + else if(clCompareCssmData(thisUse, &CSSMOID_OCSPSigning)) { + keyUse |= CSSM_KEYUSE_VERIFY; } - /* I don't think the other purposes are useful... */ - eku->GoNext(); } } if(keyUse == 0) { @@ -194,12 +214,8 @@ CSSM_KEYUSE DecodedCert::inferKeyUsage() const CSSM_KEY_PTR DecodedCert::extractCSSMKey( CssmAllocator &alloc) const { - CASSERT(certificateToSign != NULL); - SubjectPublicKeyInfo *snaccKeyInfo = certificateToSign->subjectPublicKeyInfo; - if((snaccKeyInfo == NULL) || - (snaccKeyInfo->algorithm == NULL)) { - CssmError::throwMe(CSSMERR_CL_NO_FIELD_VALUES); - } - return CL_extractCSSMKey(*snaccKeyInfo, alloc, this); + const CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &keyInfo = + mCert.tbs.subjectPublicKeyInfo; + return CL_extractCSSMKeyNSS(keyInfo, alloc, this); } diff --git a/AppleX509CL/DecodedCert.h b/AppleX509CL/DecodedCert.h index 0afd60c9..484e6064 100644 --- a/AppleX509CL/DecodedCert.h +++ b/AppleX509CL/DecodedCert.h @@ -17,44 +17,14 @@ /* - * DecodedCert.h - object representing a snacc-decoded cert, with extensions - * parsed and decoded (still in snacc format). + * DecodedCert.h - object representing an NSS-decoded cert, with extensions + * parsed and decoded (still in NSS format). * * Created 9/1/2000 by Doug Mitchell. * Copyright (c) 2000 by Apple Computer. * - * This object is how we store certs, both when caching them (explicitly or - * during a search), and as an intermediate stage during template (TBS, or - * to-be-signed cert) construction. This is a subclass of the SNACC-generated class - * Certificate; the main functionality we add is the parsing and decoding of - * Extensions. Extensions are not decoded in class Certificate beyond the level - * of the X.509 Extension object, which just contains the ID (an OID), the - * critical flag, and an octet string containing an ID-specific thing. - * - * When we decode a cert or a TBS, we also parse the Extension objects, decoding - * then into specific SNACC classes like KeyUsage or BasicConstriantsSyntax. We - * keep these decoded extensions in a list of DecodedExten structs. GetCertField - * ops which access extensions access these DecodedExten structs. - * - * When creating a cert template (TBS), each incoming field associated with an - * extension is translated into an object like a (SNACC) KeyUsage and stored in - * our DecodedExten list. - * - * When encoding a TBS, we BER-encode each of the SNACC objects (KeyUsage, etc.) - * in our list of DecodedExtens, wrapthe result in an Octet string (actually an - * AsnOcts) and store it in the SNACC-generated CertificateToSign's extensions - * list. - * - * Support for extensions which we don't understand is handled as follows. When - * setting cert fields for such extensions during template construction, the app - * has to BER-encode the underlying extension. We just wrap this in an octet string - * (AsnOcts) and store the result in a DecodedExten without further ado. When - * encoding the TBS, this octet string is just copied into the CertificateToSign's - * Extension list without further ado. When decoding a cert, if we find an - * extension we don't understand, the SNACC object stored in the DecodedExten - * is just a copy of the AsnOcts (which is the BER encoding of the underlying - * mystery extension wrapped in an Octet string). We pass back the Octet string's - * contents (*not* the BER-encoded octet string) during a GetCertField op. + * See DecodedItem.h for details on the care and feeding of this + * module. */ #ifndef _DECODED_CERT_H_ @@ -63,39 +33,13 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* state of a DecodedCert */ -typedef enum { - CS_Empty, - CS_DecodedCert, // can't set fields in this state - CS_DecodedTBS, // ditto - CS_Building // in the process of setting fields -} CertState; - -/* means for holding decoded extensions */ -typedef struct { - AsnOid *extnId; - bool critical; - AsnType *snaccObj; // KeyUsage, BasicConstraintsSyntax, etc. - bool berEncoded; // indicates unknown extension which we - // do not BER-decode when parsing a cert -} DecodedExten; +#include "DecodedItem.h" +#include +#include -class AppleX509CLSession; - -class DecodedCert : public Certificate +class DecodedCert : public DecodedItem { + NOCOPY(DecodedCert) public: /* construct empty cert, no decoded extensions */ DecodedCert( @@ -108,6 +52,8 @@ public: ~DecodedCert(); + void encodeExtensions(); + /* decode TBSCert and its extensions */ void decodeTbs( const CssmData &encodedTbs); @@ -130,7 +76,7 @@ public: const CssmOid &fieldId, // which field unsigned index, // which occurrence (0 = first) uint32 &numFields, // RETURNED - CssmOwnedData &fieldValue) const; // RETURNED + CssmOwnedData &fieldValue); // RETURNED /* * Set the field specified by fieldId in TBS. @@ -166,62 +112,8 @@ public: CssmAllocator &alloc) const; CSSM_KEYUSE inferKeyUsage() const; - -private: - - /*** - *** Extensions support (CertExtensions.cpp) - ***/ - - /* decode extensions ==> mExtensions */ - void decodeExtensions(); - - /* encode mExtensions ==> tbs->Extensions */ - void encodeExtensions(); - - /* called from decodeExtensions and setField* */ - void addExtension( - AsnType *snaccThing, // e.g. KeyUsage - const AsnOid &extnId, - bool critical, - bool berEncoded); - -public: - - /* as above, CSSM-centric OID */ - void addExtension( - AsnType *snaccThing, // e.g. KeyUsage - const CSSM_OID &extnId, - bool critical, - bool berEncoded) - { - AsnOid snaccOid(reinterpret_cast(extnId.Data), extnId.Length); - addExtension(snaccThing, snaccOid, critical, berEncoded); - } - - /* called from getField* and inferKeyUsage */ - /* returns NULL if not found */ - DecodedExten *findDecodedExt( - const AsnOid &extnId, // for known extensions - bool unknown, // otherwise - uint32 index, - uint32 &numFields) const; - -private: - CertState mState; - DecodedExten *mExtensions; - unsigned mNumExtensions; // # valid DecodedExtens - unsigned mSizeofExtensions; // mallocd size in DecodedExten - CssmAllocator &alloc; - AppleX509CLSession &mSession; - void reset() - { - mState = CS_Empty; - mExtensions = NULL; - mNumExtensions = 0; - mSizeofExtensions = 0; - } + NSS_Certificate mCert; }; #endif /* _DECODED_CERT_H_ */ diff --git a/AppleX509CL/DecodedCrl.cpp b/AppleX509CL/DecodedCrl.cpp new file mode 100644 index 00000000..71a33122 --- /dev/null +++ b/AppleX509CL/DecodedCrl.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * DecodedCrl.cpp - object representing a decoded CRL, in NSS format, + * with extensions parsed and decoded (still in NSS format). + * + * Created 8/28/2002 by Doug Mitchell. + */ + +#include "DecodedCrl.h" +#include "cldebugging.h" +#include "AppleX509CLSession.h" +#include "CSPAttacher.h" +#include + +DecodedCrl::DecodedCrl( + AppleX509CLSession &session) + : DecodedItem(session) +{ + memset(&mCrl, 0, sizeof(mCrl)); +} + +/* one-shot constructor, decoding from DER-encoded data */ +DecodedCrl::DecodedCrl( + AppleX509CLSession &session, + const CssmData &encodedCrl) + : DecodedItem(session) +{ + memset(&mCrl, 0, sizeof(mCrl)); + PRErrorCode prtn = mCoder.decode(encodedCrl.data(), encodedCrl.length(), + NSS_SignedCrlTemplate, &mCrl); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + mDecodedExtensions.decodeFromNss(mCrl.tbs.extensions); + mState = IS_DecodedAll; +} + +DecodedCrl::~DecodedCrl() +{ +} + +/* decode mCrl.tbs and its extensions */ +void DecodedCrl::decodeCts( + const CssmData &encodedCts) +{ + assert(mState == IS_Empty); + memset(&mCrl, 0, sizeof(mCrl)); + PRErrorCode prtn = mCoder.decode(encodedCts.data(), encodedCts.length(), + NSS_TBSCrlTemplate, &mCrl.tbs); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + mDecodedExtensions.decodeFromNss(mCrl.tbs.extensions); + mState = IS_DecodedTBS; +} + +void DecodedCrl::encodeExtensions() +{ + NSS_TBSCrl &tbs = mCrl.tbs; + assert(mState == IS_Building); + assert(tbs.extensions == NULL); + + if(mDecodedExtensions.numExtensions() == 0) { + /* no extensions, no error */ + return; + } + mDecodedExtensions.encodeToNss(tbs.extensions); +} + +/* + * FIXME : how to determine max encoding size at run time!? + */ +#define MAX_TEMPLATE_SIZE (16 * 1024) + +/* encode TBS component; only called from CrlCreateTemplate */ +void DecodedCrl::encodeCts( + CssmOwnedData &encodedCts) +{ + encodeExtensions(); + assert(mState == IS_Building); + + /* enforce required fields - could go deeper, maybe we should */ + NSS_TBSCrl &tbs = mCrl.tbs; + if((tbs.signature.algorithm.Data == NULL) || + (tbs.issuer.rdns == NULL)) { + clErrorLog("DecodedCrl::encodeTbs: incomplete TBS"); + /* an odd, undocumented error return */ + CssmError::throwMe(CSSMERR_CL_NO_FIELD_VALUES); + } + + PRErrorCode prtn; + prtn = SecNssEncodeItemOdata(&tbs, NSS_TBSCrlTemplate, + encodedCts); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } +} + diff --git a/AppleX509CL/DecodedCrl.h b/AppleX509CL/DecodedCrl.h new file mode 100644 index 00000000..7f428089 --- /dev/null +++ b/AppleX509CL/DecodedCrl.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * DecodedCrl.h - object representing a decoded cert in NSS form, with + * extensions parsed and decoded (still in NSS format). + * + * Created 8/28/2002 by Doug Mitchell. + * + * See DecodedItem.h for details on the care and feeding of this + * module. + */ + +#ifndef _DECODED_CRL_H_ +#define _DECODED_CRL_H_ + +#include +#include + +#include "DecodedItem.h" +#include + +class DecodedCrl : /* for now public CertificateList, */ public DecodedItem +{ + NOCOPY(DecodedCrl) +public: + /* construct empty CRL, no decoded extensions */ + DecodedCrl( + AppleX509CLSession &session); + + /* one-shot constructor, decoding from DER-encoded data */ + DecodedCrl( + AppleX509CLSession &session, + const CssmData &encodedCrl); + + ~DecodedCrl(); + + /* decode CRLToSign and its extensions */ + void decodeCts( + const CssmData &encodedCTS); + + /* encode TBSCert and its extensions */ + void encodeExtensions(); + void encodeCts( + CssmOwnedData &encodedTbs); + + /*** + *** field accessors (in CrlFields.cpp) + ***/ + + /* + * Obtain the index'th occurrence of field specified by fieldId. + * Format of the returned field depends on fieldId. + * Returns total number of fieldId fields in the cert if index is 0. + * Returns true if specified field was found, else returns false. + */ + bool getCrlFieldData( + const CssmOid &fieldId, // which field + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmOwnedData &fieldValue); // RETURNED + + /* + * Set the field specified by fieldId in TBS. + * Note no index - individual field routines either append (for extensions) + * or throw if field already set (for all others) + */ + void setCrlField( + const CssmOid &fieldId, // which field + const CssmData &fieldValue); + + /* + * Free the fieldId-specific data referred to by fieldValue.get().data(). + */ + static void freeCrlFieldData( + const CssmOid &fieldId, + CssmOwnedData &fieldValue); + + void getAllParsedCrlFields( + uint32 &NumberOfFields, // RETURNED + CSSM_FIELD_PTR &CertFields); // RETURNED + + static void describeFormat( + CssmAllocator &alloc, + uint32 &NumberOfFields, + CSSM_OID_PTR &OidList); + + NSS_Crl mCrl; + +}; + +#endif /* _DECODED_CRL_H_ */ diff --git a/AppleX509CL/DecodedExtensions.cpp b/AppleX509CL/DecodedExtensions.cpp new file mode 100644 index 00000000..b2709b1e --- /dev/null +++ b/AppleX509CL/DecodedExtensions.cpp @@ -0,0 +1,462 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * DecodedItem.cpp - class representing the common portions of + * NSS-format decoded certs and CRLs, with extensions parsed and + * decoded (still in NSS format). + */ + +#include "DecodedItem.h" +#include "cldebugging.h" +#include "AppleX509CLSession.h" +#include "CSPAttacher.h" +#include "CLFieldsCommon.h" +#include "clNssUtils.h" +#include "clNameUtils.h" +#include +#include + +#define MIN_EXTENSIONS 4 // initial size of *mExtensions + +DecodedExten::DecodedExten( + const CSSM_OID &extnId, // copied + bool critical, + void *nssObj, // NSS_KeyUsage, NSS_BasicConstraints, + // etc. NOT COPIED, exists in same + // memory space as coder + bool berEncoded, // indicates unknown extension which we + // do not BER-decode when parsing a cert + const SEC_ASN1Template *templ, // to decode/encode if !berEncoded + SecNssCoder &coder, // all local allocs from here + const CSSM_DATA *rawExtn) // NSS_CertExtension.value, copied to + // mRawExtn + : mCritical(critical), + mNssObj(nssObj), + mBerEncoded(berEncoded), + mTempl(templ), + mCoder(coder), + mRawExtn(NULL) +{ + coder.allocCopyItem(extnId, mExtnId); + if(rawExtn) { + mRawExtn = (CSSM_DATA *)coder.malloc(sizeof(CSSM_DATA)); + coder.allocCopyItem(*rawExtn, *mRawExtn); + } +} + +DecodedExten::~DecodedExten() +{ + /* the only stuff we allocated was in the coder pool and will be freed + * when coder is freed */ +} + +/* + * Convert this extension to a CSSM_X509_EXTENSION, in the specified + * (app-level) alloc space, after its contents have + * been converted to a native CDSA object (CE_KeyUsage, etc.). + */ +void DecodedExten::convertToCdsa( + void *cdsaObj, // e.g. CE_KeyUsage + // CSSM_DATA_PTR for berEncoded + CSSM_X509_EXTENSION_PTR cssmExt, // contents RETURNED + CssmAllocator &alloc) const +{ + clAllocCopyData(alloc, mExtnId, cssmExt->extnId); + cssmExt->critical = mCritical ? CSSM_TRUE : CSSM_FALSE; + + /* + * in either case copy the raw extension data if we have it (we may not + * have it if this was created via setField). + */ + if(mRawExtn) { + clAllocCopyData(alloc, *mRawExtn, cssmExt->BERvalue); + } + else { + cssmExt->BERvalue.Data = NULL; + cssmExt->BERvalue.Length = 0; + } + if(mBerEncoded) { + /* an extension we never parsed or understood */ + assert(cdsaObj == NULL); + cssmExt->format = CSSM_X509_DATAFORMAT_ENCODED; + cssmExt->value.parsedValue = NULL; + } + else { + /* caller sees parsed version plus raw BER-encoded bytes */ + assert(cdsaObj != NULL); + if(mRawExtn) { + /* normal decode & parse case */ + cssmExt->format = CSSM_X509_DATAFORMAT_PAIR; + } + else { + /* setField */ + cssmExt->format = CSSM_X509_DATAFORMAT_PARSED; + } + /* in app alloc's space, mallocd by getField*() */ + cssmExt->value.parsedValue = cdsaObj; + } +} + +/* + * Convert a DecodedExten to a CSSM_X509_EXTENSION. This includes + * the mapping of the extnId to a known CDSA type and type and doing the + * actual NSS-to-CDSA conversion. At the time this function is + * called, the DecodedExten either has a valid mNssObj, or it's an + * unknown extension type in which case mNssObj is an AsnOcts containing + * the opaquely DER-encoded extension value. + * + * Currently only used when decoding a CRL and converting it en masse + * to CDSA. + */ +template +void nssToCssm( + const DecodedExten &decodedExt, + NssType *&nssObj, // RETURNED + CdsaType *&cdsaObj, // mallocd and RETURNED + CssmAllocator &alloc) +{ + nssObj = (NssType *)(decodedExt.nssObj()); + assert(nssObj != NULL); + cdsaObj = (CdsaType *)alloc.malloc(sizeof(CdsaType)); + memset(cdsaObj, 0, sizeof(CdsaType)); +} + +void DecodedExten::parse( + CSSM_X509_EXTENSION_PTR cssmExt, // mallocd by caller, RETURNED + CssmAllocator &alloc) const +{ + void *vCdsaObj = NULL; + if(mBerEncoded) { + /* non-understood extension */ + convertToCdsa(NULL, cssmExt, alloc); + return; + } + if(clCompareCssmData(&mExtnId, &CSSMOID_AuthorityKeyIdentifier)) { + CE_AuthorityKeyID *cdsaObj; + NSS_AuthorityKeyId *nssObj; + nssToCssm( + *this, + nssObj, + cdsaObj, + alloc); + CL_nssAuthorityKeyIdToCssm(*nssObj, *cdsaObj, mCoder, alloc); + vCdsaObj = cdsaObj; + } + /* same encoding (uint32) for all of these: */ + else if(clCompareCssmData(&mExtnId, &CSSMOID_CrlNumber) || + clCompareCssmData(&mExtnId, &CSSMOID_DeltaCrlIndicator) || + clCompareCssmData(&mExtnId, &CSSMOID_CrlReason)) { + CE_CrlNumber *cdsaObj; + CSSM_DATA *nssObj; + nssToCssm( + *this, + nssObj, + cdsaObj, + alloc); + *cdsaObj = clDataToInt(*nssObj); + vCdsaObj = cdsaObj; + } + /* same encoding (GeneralNames) for all of these: */ + else if(clCompareCssmData(&mExtnId, &CSSMOID_IssuerAltName) || + clCompareCssmData(&mExtnId, &CSSMOID_SubjectAltName) || + clCompareCssmData(&mExtnId, &CSSMOID_CertIssuer)) { + CE_GeneralNames *cdsaObj; + NSS_GeneralNames *nssObj; + nssToCssm( + *this, + nssObj, + cdsaObj, + alloc); + CL_nssGeneralNamesToCssm(*nssObj, *cdsaObj, mCoder, alloc); + vCdsaObj = cdsaObj; + } + else if(clCompareCssmData(&mExtnId, &CSSMOID_IssuingDistributionPoint)) { + CE_IssuingDistributionPoint *cdsaObj; + NSS_IssuingDistributionPoint *nssObj; + nssToCssm( + *this, + nssObj, + cdsaObj, + alloc); + CL_nssIssuingDistPointToCssm(nssObj, cdsaObj, mCoder, alloc); + vCdsaObj = cdsaObj; + } + + /* + * cert entry extensions + */ + else if(clCompareCssmData(&mExtnId, &CSSMOID_HoldInstructionCode)) { + /* value is just an OID */ + CSSM_OID *cdsaObj; + CSSM_DATA *nssObj; + nssToCssm( + *this, + nssObj, + cdsaObj, + alloc); + clAllocCopyData(alloc, *nssObj, *cdsaObj); + vCdsaObj = cdsaObj; + } + else if(clCompareCssmData(&mExtnId, &CSSMOID_InvalidityDate)) { + /* GeneralizedTime */ + CSSM_DATA *cdsaObj; + CSSM_DATA *nssObj; + nssToCssm( + *this, + nssObj, + cdsaObj, + alloc); + clAllocCopyData(alloc, *nssObj, *cdsaObj); + vCdsaObj = cdsaObj; + } + else { + /* if we get here, this routine is not keeping up with + * clOidToNssInfo() */ + assert(0); + CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); + } + convertToCdsa(vCdsaObj, cssmExt, alloc); +} + + +#pragma mark ------ DecodedExtensions ------ + +/* + * A variable-size array of DecodedExtens. + * Used for storing cert and CRL extensions as well as per-CRL-entry + * extensions. + */ +DecodedExtensions::DecodedExtensions( + SecNssCoder &coder, + CssmAllocator &alloc) + : mCoder(coder), + mAlloc(alloc), + mExtensions(NULL), + mNumExtensions(0), + mSizeofExtensions(0) +{ + +} + +DecodedExtensions::~DecodedExtensions() +{ + for(unsigned i=0; iextnId, cook up an approppriate + * NSS-specific type (NSS_KeyUsage, etc.); + */ + CSSM_DATA &rawExtn = nssExten->value; + bool berEncoded = false; + bool found; // we understand this OID + unsigned nssObjLen; // size of associated NSS object + const SEC_ASN1Template *templ = NULL; // template for decoding + void *nssObj = NULL; // decode destination + found = clOidToNssInfo(nssExten->extnId, nssObjLen, templ); + if(!found) { + /* + * We don't know how to deal with this. + */ + berEncoded = true; + } + else { + /* + * Create NSS-style object specific to this extension, just + * by knowing its length and ASN template. + * Decode the extensions's extnValue into that object. We don't + * have to know what kind of object it is anymore. + */ + assert(templ != NULL); + nssObj = mCoder.malloc(nssObjLen); + memset(nssObj, 0, nssObjLen); + PRErrorCode prtn; + prtn = mCoder.decodeItem(rawExtn, templ, nssObj); + if(prtn) { + /* + * FIXME - what do we do here? For now flag it + * as an non-understood extension... + */ + clErrorLog("decodeExtensions: extension decode error\n"); + nssObj = NULL; + berEncoded = true; + } + } + if((nssObj != NULL) || berEncoded) { + /* append if the decode was successful */ + addExtension(nssExten->extnId, + clNssBoolToCssm(nssExten->critical), + nssObj, + berEncoded, + templ, + &rawExtn); + } + } +} + +/* + * Encode into a NSS-style Extensions. + * + * Each extension object, currently stored as some AsnType subclass, + * is BER-encoded and the result is stored as an octet string + * (AsnOcts) in a new Extension object in the TBS. + * + * Called from {Crl,Cert}CreateTemplate via encode{Tbs,Cts}(). + */ +void DecodedExtensions::encodeToNss( + NSS_CertExtension **&extensions) +{ + assert(extensions == NULL); + + if(mNumExtensions == 0) { + /* no extensions, no error */ + return; + } + + /* malloc a NULL_terminated array of NSS_CertExtension pointers */ + unsigned len = (mNumExtensions + 1) * sizeof(NSS_CertExtension *); + extensions = (NSS_CertExtension **)mCoder.malloc(len); + memset(extensions, 0, len); + + /* grind thru our DecodedExtens, creating an NSS_CertExtension for + * each one */ + for(unsigned extenDex=0; extenDexberEncoded()) { + /* unknown extension type, it's already encoded */ + const CSSM_DATA *srcBer = (const CSSM_DATA *)decodedExt->rawExtn(); + assert(srcBer != NULL); + mCoder.allocCopyItem(*srcBer, thisNssExten->value); + } + else { + PRErrorCode prtn; + prtn = mCoder.encodeItem(decodedExt->nssObj(), + decodedExt->templ(), thisNssExten->value); + if(prtn) { + clErrorLog("encodeToNss: extension encode error"); + CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); + } + } + ArenaAllocator arenaAlloc(mCoder); + if(decodedExt->critical()) { + /* optional, default false */ + clCssmBoolToNss(CSSM_TRUE, thisNssExten->critical, arenaAlloc); + } + mCoder.allocCopyItem(decodedExt->extnId(), thisNssExten->extnId); + } +} + +/* add/retrieve entries */ +void DecodedExtensions::addExtension( + const CSSM_OID &extnId, // copied + bool critical, + void *nssObj, // NSS_KeyUsage, NSS_BasicConstraints, + // etc. NOT COPIED, exists in same + // memory space as coder + bool berEncoded, // indicates unknown extension which we + // do not BER-decode when parsing a cert + const SEC_ASN1Template *templ, // required if !berEncoded + const CSSM_DATA *rawExtn) // NSS_CertExtension.value, copied, + // optional (not present during a + // SetField op) +{ + if(mNumExtensions == mSizeofExtensions) { + /* expand by doubling, or initial malloc */ + mSizeofExtensions = mNumExtensions ? + (2 * mNumExtensions) : MIN_EXTENSIONS; + mExtensions = (DecodedExten **)mAlloc.realloc( + mExtensions, mSizeofExtensions * sizeof(DecodedExten)); + } + mExtensions[mNumExtensions++] = new DecodedExten(extnId, + critical, nssObj, berEncoded, templ, mCoder, rawExtn); +} + +const DecodedExten *DecodedExtensions::getExtension( + unsigned extenDex) const +{ + assert(extenDex < mNumExtensions); + return mExtensions[extenDex]; +} + +/* Convert to CSSM_X509_EXTENSIONS */ +/* Currently only used when decoding a CRL and converting it en masse + * to CDSA */ +void DecodedExtensions::convertToCdsa( + CSSM_X509_EXTENSIONS &cssmExtens, + CssmAllocator &alloc) const +{ + memset(&cssmExtens, 0, sizeof(cssmExtens)); + if(mNumExtensions == NULL) { + return; + } + cssmExtens.extensions = (CSSM_X509_EXTENSION_PTR)alloc.malloc( + sizeof(CSSM_X509_EXTENSION) * mNumExtensions); + memset(cssmExtens.extensions, 0, + sizeof(CSSM_X509_EXTENSION) * mNumExtensions); + cssmExtens.numberOfExtensions = mNumExtensions; + for(unsigned dex=0; dexparse(&cssmExtens.extensions[dex], alloc); + } + catch(...) { + /* FIXME - what now? */ + clFieldLog("DecodedExtensions:convertToCdsa: extension " + "decode error"); + } + } +} + diff --git a/AppleX509CL/DecodedExtensions.h b/AppleX509CL/DecodedExtensions.h new file mode 100644 index 00000000..7c46ff8b --- /dev/null +++ b/AppleX509CL/DecodedExtensions.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * DecodedExtensions.h - Intermediate representation of extensions. + */ + +#ifndef _DECODED_EXTENSIONS_H_ +#define _DECODED_EXTENSIONS_H_ + +#include +#include + +#include +#include + +#include "cldebugging.h" + +class DecodedExten +{ + NOCOPY(DecodedExten) +public: + + /* member variables only set on construct */ + DecodedExten( + const CSSM_OID &extnId, // copied + bool critical, + void *nssObj, // NSS_KeyUsage, NSS_BasicConstraints, + // etc. NOT COPIED, exists in same + // memory space as coder + bool berEncoded, // indicates unknown extension + // which we do not BER-decode + // when parsing a cert + const SEC_ASN1Template *templ, // to decode/encode if !berEncoded + SecNssCoder &coder, // all local allocs from here + const CSSM_DATA *rawExtn=NULL); // NSS_CertExtension.value, copied to + // mRawExtn, optional (not present + // during a SetField op) + ~DecodedExten(); + + /* + * Convert this extension to a CSSM_X509_EXTENSION, after its contents + * have been converted to a native CDSA object (CE_KeyUsage, etc.). + * This is the final step of a getField op involving an extension. + */ + void convertToCdsa( + void *cdsaObj, // e.g. CE_KeyUsage + // CSSM_DATA_PTR for berEncoded + CSSM_X509_EXTENSION_PTR cssmExt, // contents mallocd in alloc's space + // and RETURNED + CssmAllocator &alloc) const; + + /* + * Convert a DecodedExten to a CSSM_X509_EXTENSION. This includes + * the mapping of the extnId to a known CDSA type and type and doing the + * actual NSS-to-CDSA conversion. + */ + void parse( + CSSM_X509_EXTENSION_PTR cssmExt, // mallocd by caller, contents + // mallocd in alloc's space, + // RETURNED + CssmAllocator &alloc) const; + + const CSSM_OID &extnId() const { return mExtnId; } + bool critical() const { return mCritical; } + void *nssObj() const { return mNssObj; } + bool berEncoded() const { return mBerEncoded; } + const SEC_ASN1Template *templ() const { return mTempl; } + CSSM_DATA *rawExtn() const { return mRawExtn; } +private: + CSSM_OID mExtnId; + bool mCritical; + void *mNssObj; // NSS_KeyUsage, NSS_BasicConstraints, etc. + bool mBerEncoded; // indicates unknown extension which we + // do not BER-decode when parsing a cert + const SEC_ASN1Template *mTempl; + // used for decode/encode + SecNssCoder &mCoder; + CSSM_DATA *mRawExtn; // optional BER-encoded extension data, not + // present if created via SetField() +}; + +/* + * A variable-size array of DecodedExtens. + * Used for storing cert and CRL extensions as well as per-CRL-entry + * extensions. + */ +class DecodedExtensions +{ + NOCOPY(DecodedExtensions) +public: + DecodedExtensions( + SecNssCoder &coder, // for local allocs + CssmAllocator &alloc); // for user space (copyout) allocs + ~DecodedExtensions(); + + /* Initialize by decoding an NSS-style NSS_CertExtension array */ + void decodeFromNss( + NSS_CertExtension **extensions); + + /* Encode into a NSS-style NSS_CertExtension array, allocating + * both the array pointers and the NSS_Extension elements themselves */ + void encodeToNss( + NSS_CertExtension **&extensions); + + /* add/retrieve entries */ + void addExtension( + const CSSM_OID &extnId, // copied + bool critical, + void *nssObj, // NSS_BasicConstraints, + // etc. NOT COPIED, exists in same + // memory space as coder + bool berEncoded, // indicates unknown extension + // which we do not BER-decode + // when parsing a cert + const SEC_ASN1Template *templ, // required if !berEncoded + const CSSM_DATA *rawExtn=NULL); // NSS_CertExtension.value, copied, + // optional (not present during a + // SetField op) + const DecodedExten *getExtension( + unsigned extenDex) const; + + /* + * Convert to CSSM_X509_EXTENSIONS, including conversion to + * native CDSA C structs. Only used on CRL side, on a getField + * returning the entire parsed CRL. */ + void convertToCdsa( + CSSM_X509_EXTENSIONS &cssmExtens, + CssmAllocator &alloc) const; + + unsigned numExtensions() const { return mNumExtensions; } + +private: + SecNssCoder &mCoder; + CssmAllocator &mAlloc; + DecodedExten **mExtensions; + unsigned mNumExtensions; // # valid DecodedExtens + unsigned mSizeofExtensions; // mallocd size in mExtensions +}; + +#endif /* _DECODED_EXTENSIONS_H_ */ diff --git a/AppleX509CL/DecodedItem.cpp b/AppleX509CL/DecodedItem.cpp new file mode 100644 index 00000000..17ba9869 --- /dev/null +++ b/AppleX509CL/DecodedItem.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * DecodedItem.cpp - class representing the common portions of NSS-style + * certs and CRLs, with extensions parsed and decoded (still in NSS + * format). + */ + +#include "DecodedItem.h" +#include "cldebugging.h" +#include "AppleX509CLSession.h" +#include "CSPAttacher.h" +#include "CLFieldsCommon.h" +#include "clNssUtils.h" +#include + + +DecodedItem::DecodedItem( + AppleX509CLSession &session) + : mState(IS_Empty), + mAlloc(session), + mSession(session), + mDecodedExtensions(mCoder, session) +{ +} + +DecodedItem::~DecodedItem() +{ + /* nothing for now */ +} + +/* + * Search for DecodedExten by AsnOid or "any unknown extension". + * Called from getField*() and inferKeyUsage. + * Returns NULL if specified extension not found. + */ +const DecodedExten *DecodedItem::findDecodedExt( + const CSSM_OID &extnId, // for known extensions + bool unknown, // otherwise + uint32 index, + uint32 &numFields) const +{ + unsigned dex; + const DecodedExten *rtnExt = NULL; + unsigned found = 0; + + for(dex=0; dexberEncoded() && + (clCompareCssmData(&decodedExt->extnId(), &extnId)) + ) || + (unknown && decodedExt->berEncoded()) + ) { + + if(found++ == index) { + /* the one we want */ + rtnExt = decodedExt; + } + if((rtnExt != NULL) && (index != 0)) { + /* only determine numFields on search for first one */ + break; + } + } + } + if(rtnExt != NULL) { + /* sucessful return */ + if(index == 0) { + numFields = found; + } + return rtnExt; + } + else { + return NULL; + } +} + diff --git a/AppleX509CL/DecodedItem.h b/AppleX509CL/DecodedItem.h new file mode 100644 index 00000000..e496bca3 --- /dev/null +++ b/AppleX509CL/DecodedItem.h @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * DecodedItem.h - class representing the common portions of NSS-format + * decoded certs and CRLs, with extensions parsed and decoded (still in + * NSS format). + * + * When a DecodedItem (cert or CRL) is quiescent and cached in the CL + * (either by an explicit cache call like CSSM_CL_CertCache or + * CSSM_CL_CrlCache(), or during a succession of GetFirst/GetNext field + * ops), the item is stored in the CL in what we call NSS form. NSS is + * the module we use to perform DER encoding and decoding; NSS form + * refers to structs defining Certs, CRLs, and extensions which are + * directly encodable and decodable by the NSS library. NSS structs are + * similar to their CDSA counterparts, sometimes identical, usually + * subtly different (due to requirements of the NSS module). + * + * Decoding a cert or a CRL: + * ------------------------- + * + * When an app decodes a cert or CRL for any reason, the following phases + * are executed: + * + * PHASE I + * ------- + * + * Basic BER-decode if the incoming CSSM_DATA blob. This happens in the + * constructors for DecodedCert and DecodedCrl. A modified/restricted + * version of this occurs in DecodedCert::decodeTbs(), which is used + * during a CSSM_CL_CertGetAllTemplateFields() call. + * + * PHASE II + * -------- + * + * Extensions are converted from untyped blobs - which is how they look + * after PHASE I - to NSS-style C structs. This is done by examining + * the ExtnId of each cert's or CRL's extensions and doing a BER decode + * specific to that extension type. This is performed in + * DecodedExtensions.decodeFromNss() which is called immediately after + * the top-level decode performed in PHASE I. + * + * It is at this point that a cert or CRL can be cached in the CL's + * cacheMap or queryMap (see AppleX509CLSession.{h,cpp}. We call this + * state "NSS Form". + * + * PHASE III (CRLs only) + * -------------------- + * + * This occurs when an app is actually fetching a full CRL in + * CDSA form. Individual entries in a CRL's revocation list also + * contain per-entry extension lists. These are converted from + * untyped blobs to meaningful NSS-style extension structs as + * in PHASE II prior to the conversion to CDSA form in PHASE IV. + * + * PHASE IV + * --------- + * + * This occurs when an app is actually fetching fields in CDSA form. + * This involves converting objects from NSS form to CDSA form + * (if necessary) and copying to the session allocator's memory space. + * + * The rationale behind this phased approach - in particular, the + * reason that in-memory items are stored in NSS form - is that this + * minimizes the number of copies between the intiial parse of a cert + * or CRL and the final GetField op. Since a GetField op inherently + * requires a copy (from internal memory to the session allocator's + * space), and conversion from NSS to CDSA form is basically a bunch of + * copies as well, we might as well just stop with the item in CRL + * format as soon as PHASE II is complete. Note that completion of + * PHASE II is in fact required before caching a cert since that enables + * us to have access to extension-specific info while a cert is + * cached. The KeyUsage and ExtendedKeyUsage extensions are used in + * this manner to get key info from a TBS cert. + * + * + * Creating and encoding a cert: + * ----------------------------- + * + * Creating a cert (creating CRLs is not supported in this release) + * follows more or less the reverse procedure, as follows: + * + * PHASE I + * ------- + * + * During a CSSM_CL_CertCreateTemplate() op, all fields which the + * app wishes to specify are passed into the CL in CDSA form. These + * fields are converted to NSS form in a temporary DecodedCert. This + * includes extensions (in NSS form). + * + * PHASE II + * -------- + * + * Extensions in NSS form are encoded and bundled up into the final, + * BER-encode ready NSS_CertExtension array form. This occurs + * in DecodedCert::encodeExtensions(), called from the top of + * DecodedCert::encodeTbs(). We're still processing an app's + * CSSM_CL_CertCreateTemplate() call at this point. + * + * PHASE III + * --------- + * + * Final DER-encoding of a TBS cert is performed in + * DecodedCert::encodeTbs(). The resulting CSSM_DATA is + * passed back to the app as what CDSA calls a template. + * This completes the CSSM_CL_CertCreateTemplate() call. + * + * PHASE IV + * -------- + * + * The TBS cert blob is signed and the resulting DER-encoded + * cert is passed back to the app. + */ + +#ifndef _DECODED_ITEM_H_ +#define _DECODED_ITEM_H_ + +#include +#include + +#include "cldebugging.h" +#include "DecodedExtensions.h" +#include + +/* state of a DecodedItem */ +typedef enum { + IS_Empty, + IS_DecodedAll, // can't set fields in this state + IS_DecodedTBS, // ditto + IS_Building // in the process of setting fields +} ItemState; + + +class AppleX509CLSession; + +class DecodedItem +{ +public: + DecodedItem( + AppleX509CLSession &session); + + virtual ~DecodedItem(); + + SecNssCoder &coder() { return mCoder; } + + static void describeFormat( + CssmAllocator &alloc, + uint32 &NumberOfFields, + CSSM_OID_PTR &OidList); + +public: + /*** + *** Extensions support + ***/ + + /* called from decodeExtensions and setField* */ + void addExtension( + void *nssThing, // e.g. NSS_KeyUsage + const CSSM_OID &extnId, + bool critical, + bool berEncoded, + const SEC_ASN1Template *templ, // to decode/encode if !berEncoded + const CSSM_DATA *rawExtn=NULL) // Extension.extnValue, copied, only for + // setField*() + { mDecodedExtensions.addExtension(extnId, critical, nssThing, + berEncoded, templ, rawExtn); + } + + const DecodedExten *findDecodedExt( + const CSSM_OID &extnId, // for known extensions + bool unknown, // otherwise + uint32 index, + uint32 &numFields) const; + + const DecodedExtensions &decodedExtens() const + { return mDecodedExtensions; } + + /* + * Common code for get extension field routines. + * Given an OID identifying an extension and an index, see if + * we have the specified extension in mDecodedExtensions and + * return the NSS and CDSA style objects as well as the + * DecodedExten. + */ + template + bool GetExtenTop( + unsigned index, // which occurrence (0 = first) + uint32 &numFields, // RETURNED + CssmAllocator &alloc, + const CSSM_OID &fieldId, // identifies extension we seek + NssType *&nssObj, // RETURNED + CdsaType *&cdsaObj, // mallocd and RETURNED + const DecodedExten *&decodedExt) const // RETURNED + { + /* See if we have one of these in our list of DecodedExtens */ + decodedExt = findDecodedExt(fieldId, false, index, numFields); + if(decodedExt == NULL) { + return false; + } + nssObj = (NssType *)decodedExt->nssObj(); + cdsaObj = (CdsaType *)alloc.malloc(sizeof(CdsaType)); + memset(cdsaObj, 0, sizeof(CdsaType)); + return true; + } + +protected: + ItemState mState; + CssmAllocator &mAlloc; + SecNssCoder mCoder; // from which all local allocs come + AppleX509CLSession &mSession; + DecodedExtensions mDecodedExtensions; + +}; + + +#endif /* _DECODED_ITEM_H_ */ diff --git a/AppleX509CL/Session_CRL.cpp b/AppleX509CL/Session_CRL.cpp index 89902a33..73ac4db8 100644 --- a/AppleX509CL/Session_CRL.cpp +++ b/AppleX509CL/Session_CRL.cpp @@ -21,13 +21,15 @@ // #include "AppleX509CLSession.h" +#include "clNssUtils.h" +#include "clNameUtils.h" void AppleX509CLSession::CrlDescribeFormat( uint32 &NumberOfFields, CSSM_OID_PTR &OidList) { - unimplemented(); + DecodedCrl::describeFormat(*this, NumberOfFields, OidList); } @@ -37,7 +39,8 @@ AppleX509CLSession::CrlGetAllFields( uint32 &NumberOfCrlFields, CSSM_FIELD_PTR &CrlFields) { - unimplemented(); + class DecodedCrl decodedCrl(*this, Crl); + decodedCrl.getAllParsedCrlFields(NumberOfCrlFields, CrlFields); } @@ -48,8 +51,48 @@ AppleX509CLSession::CrlGetFirstFieldValue( uint32 &NumberOfMatchedFields, CSSM_DATA_PTR &Value) { - unimplemented(); - return CSSM_INVALID_HANDLE; + NumberOfMatchedFields = 0; + Value = NULL; + CssmAutoData aData(*this); + + DecodedCrl *decodedCrl = new DecodedCrl(*this, Crl); + uint32 numMatches; + + /* this returns false if field not there, throws on bad OID */ + bool brtn; + try { + brtn = decodedCrl->getCrlFieldData(CrlField, + 0, // index + numMatches, + aData); + } + catch (...) { + delete decodedCrl; + throw; + } + if(!brtn) { + delete decodedCrl; + return CSSM_INVALID_HANDLE; + } + + /* cook up a CLCachedCRL, stash it in cache */ + CLCachedCRL *cachedCrl = new CLCachedCRL(*decodedCrl); + cacheMap.addEntry(*cachedCrl, cachedCrl->handle()); + + /* cook up a CLQuery, stash it */ + CLQuery *query = new CLQuery( + CLQ_CRL, + CrlField, + numMatches, + false, // isFromCache + cachedCrl->handle()); + queryMap.addEntry(*query, query->handle()); + + /* success - copy field data to outgoing Value */ + Value = (CSSM_DATA_PTR)malloc(sizeof(CSSM_DATA)); + *Value = aData.release(); + NumberOfMatchedFields = numMatches; + return query->handle(); } @@ -58,8 +101,36 @@ AppleX509CLSession::CrlGetNextFieldValue( CSSM_HANDLE ResultsHandle, CSSM_DATA_PTR &Value) { - unimplemented(); - return false; + /* fetch & validate the query */ + CLQuery *query = queryMap.lookupEntry(ResultsHandle); + if(query == NULL) { + CssmError::throwMe(CSSMERR_CL_INVALID_RESULTS_HANDLE); + } + if(query->queryType() != CLQ_CRL) { + clErrorLog("CrlGetNextFieldValue: bad queryType (%d)", + (int)query->queryType()); + CssmError::throwMe(CSSMERR_CL_INVALID_RESULTS_HANDLE); + } + if(query->nextIndex() >= query->numFields()) { + return false; + } + + /* fetch the associated cached CRL */ + CLCachedCRL *cachedCrl = lookupCachedCRL(query->cachedObject()); + uint32 dummy; + CssmAutoData aData(*this); + if(!cachedCrl->crl().getCrlFieldData(query->fieldId(), + query->nextIndex(), + dummy, + aData)) { + return false; + } + + /* success - copy field data to outgoing Value */ + Value = (CSSM_DATA_PTR)malloc(sizeof(CSSM_DATA)); + *Value = aData.release(); + query->incrementIndex(); + return true; } @@ -69,24 +140,95 @@ AppleX509CLSession::IsCertInCrl( const CssmData &Crl, CSSM_BOOL &CertFound) { - unimplemented(); -} - + /* + * Decode the two entities. Note that doing it this way incurs + * the unnecessary (for our purposes) overhead of decoding + * extensions, but doing it this way is so spiffy that I can't + * resist. + */ + DecodedCert decodedCert(*this, Cert); + DecodedCrl decodedCrl(*this, Crl); + + NSS_TBSCertificate &tbsCert = decodedCert.mCert.tbs; + NSS_TBSCrl &tbsCrl = decodedCrl.mCrl.tbs; + + /* trivial case - empty CRL */ + unsigned numCrlEntries = + clNssArraySize((const void **)tbsCrl.revokedCerts); + if(numCrlEntries == 0) { + clFieldLog("IsCertInCrl: empty CRL"); + CertFound = CSSM_FALSE; + return; + } + /* + * Get normalized and encoded versions of issuer names. + * Since the decoded entities are local, we can normalize in place. + */ + CssmAutoData encCertIssuer(*this); + CssmAutoData encCrlIssuer(*this); + try { + /* snag a handy temp allocator */ + SecNssCoder &coder = decodedCert.coder(); + CL_normalizeX509NameNSS(tbsCert.issuer, coder); + PRErrorCode prtn = SecNssEncodeItemOdata(&tbsCert.issuer, + NSS_NameTemplate, encCertIssuer); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } + + CL_normalizeX509NameNSS(tbsCrl.issuer, coder); + prtn = SecNssEncodeItemOdata(&tbsCrl.issuer, + NSS_NameTemplate, encCrlIssuer); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } + } + catch(...) { + clFieldLog("IsCertInCrl: normalize failure"); + throw; + } -#if __MWERKS__ -#pragma mark Cached -#endif + /* issuer names match? */ + CertFound = CSSM_FALSE; + if(encCertIssuer.get() != encCrlIssuer.get()) { + clFieldLog("IsCertInCrl: issuer name mismatch"); + return; + } + + /* is this cert's serial number in the CRL? */ + CSSM_DATA &certSerial = tbsCert.serialNumber; + for(unsigned dex=0; dexuserCertificate; + if(clCompareCssmData(&certSerial, &revokedSerial)) { + /* success */ + CertFound = CSSM_TRUE; + break; + } + } +} + +#pragma mark --- Cached --- void AppleX509CLSession::CrlCache( const CssmData &Crl, CSSM_HANDLE &CrlHandle) { - unimplemented(); + DecodedCrl *decodedCrl = new DecodedCrl(*this, Crl); + + /* cook up a CLCachedCRL, stash it in cache */ + CLCachedCRL *cachedCrl = new CLCachedCRL(*decodedCrl); + cacheMap.addEntry(*cachedCrl, cachedCrl->handle()); + CrlHandle = cachedCrl->handle(); } - +/* + * FIXME - CrlRecordIndex not supported, it'll require mods to + * the DecodedCrl::getCrlFieldData mechanism + */ CSSM_HANDLE AppleX509CLSession::CrlGetFirstCachedFieldValue( CSSM_HANDLE CrlHandle, @@ -95,8 +237,42 @@ AppleX509CLSession::CrlGetFirstCachedFieldValue( uint32 &NumberOfMatchedFields, CSSM_DATA_PTR &Value) { - unimplemented(); - return CSSM_INVALID_HANDLE; + if(CrlRecordIndex != NULL) { + /* not yet */ + CssmError::throwMe(CSSMERR_CL_INVALID_CRL_INDEX); + } + + /* fetch the associated cached CRL */ + CLCachedCRL *cachedCrl = lookupCachedCRL(CrlHandle); + if(cachedCrl == NULL) { + CssmError::throwMe(CSSMERR_CL_INVALID_CACHE_HANDLE); + } + + CssmAutoData aData(*this); + uint32 numMatches; + + /* this returns false if field not there, throws on bad OID */ + if(!cachedCrl->crl().getCrlFieldData(CrlField, + 0, // index + numMatches, + aData)) { + return CSSM_INVALID_HANDLE; + } + + /* cook up a CLQuery, stash it */ + CLQuery *query = new CLQuery( + CLQ_CRL, + CrlField, + numMatches, + true, // isFromCache + cachedCrl->handle()); + queryMap.addEntry(*query, query->handle()); + + /* success - copy field data to outgoing Value */ + Value = (CSSM_DATA_PTR)malloc(sizeof(CSSM_DATA)); + *Value = aData.release(); + NumberOfMatchedFields = numMatches; + return query->handle(); } @@ -105,8 +281,8 @@ AppleX509CLSession::CrlGetNextCachedFieldValue( CSSM_HANDLE ResultsHandle, CSSM_DATA_PTR &Value) { - unimplemented(); - return false; + /* Identical to, so just call... */ + return CrlGetNextFieldValue(ResultsHandle, Value); } @@ -125,7 +301,13 @@ void AppleX509CLSession::CrlAbortCache( CSSM_HANDLE CrlHandle) { - unimplemented(); + /* fetch the associated cached CRL, remove from map, delete it */ + CLCachedCRL *cachedCrl = lookupCachedCRL(CrlHandle); + if(cachedCrl == NULL) { + CssmError::throwMe(CSSMERR_CL_INVALID_CACHE_HANDLE); + } + cacheMap.removeEntry(cachedCrl->handle()); + delete cachedCrl; } @@ -133,14 +315,31 @@ void AppleX509CLSession::CrlAbortQuery( CSSM_HANDLE ResultsHandle) { - unimplemented(); + /* fetch & validate the query */ + CLQuery *query = queryMap.lookupEntry(ResultsHandle); + if(query == NULL) { + CssmError::throwMe(CSSMERR_CL_INVALID_RESULTS_HANDLE); + } + if(query->queryType() != CLQ_CRL) { + clErrorLog("CrlAbortQuery: bad queryType (%d)", (int)query->queryType()); + CssmError::throwMe(CSSMERR_CL_INVALID_RESULTS_HANDLE); + } + + if(!query->fromCache()) { + /* the associated cached CRL was created just for this query; dispose */ + CLCachedCRL *cachedCrl = lookupCachedCRL(query->cachedObject()); + if(cachedCrl == NULL) { + /* should never happen */ + CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); + } + cacheMap.removeEntry(cachedCrl->handle()); + delete cachedCrl; + } + queryMap.removeEntry(query->handle()); + delete query; } - - -#if __MWERKS__ -#pragma mark Template -#endif +#pragma mark --- Template --- void AppleX509CLSession::CrlCreateTemplate( @@ -196,12 +395,16 @@ AppleX509CLSession::CrlGetAllCachedRecordFields( unimplemented(); } +/* + * These are functionally identical to the corresponding + * Cert functions. + */ void AppleX509CLSession::CrlVerifyWithKey( CSSM_CC_HANDLE CCHandle, const CssmData &CrlToBeVerified) { - unimplemented(); + CertVerifyWithKey(CCHandle, CrlToBeVerified); } @@ -209,11 +412,12 @@ void AppleX509CLSession::CrlVerify( CSSM_CC_HANDLE CCHandle, const CssmData &CrlToBeVerified, - const CssmData &SignerCert, + const CssmData *SignerCert, const CSSM_FIELD *VerifyScope, uint32 ScopeSize) { - unimplemented(); + CertVerify(CCHandle, CrlToBeVerified, SignerCert, VerifyScope, + ScopeSize); } void diff --git a/AppleX509CL/Session_CSR.cpp b/AppleX509CL/Session_CSR.cpp index b61c1c0e..c6c09364 100644 --- a/AppleX509CL/Session_CSR.cpp +++ b/AppleX509CL/Session_CSR.cpp @@ -22,15 +22,16 @@ #include "AppleX509CLSession.h" #include "DecodedCert.h" -#include "SnaccUtils.h" +#include "clNameUtils.h" +#include "clNssUtils.h" #include "cldebugging.h" #include "CSPAttacher.h" -#include "CertBuilder.h" +#include "clNssUtils.h" +#include #include #include #include -#include -#include +#include /* * Generate a DER-encoded CSR. @@ -41,96 +42,110 @@ void AppleX509CLSession::generateCsr( CSSM_DATA_PTR &csrPtr) { /* - * We use the full CertificationRequest here; we encode the - * CertificationRequestInfo component separately to calculate - * its signature, then we encode the whole CertificationRequest + * We use the full NSSCertRequest here; we encode the + * NSSCertRequestInfo component separately to calculate + * its signature, then we encode the whole NSSCertRequest * after dropping in the signature and SignatureAlgorithmIdentifier. - * - * CertificationRequestInfo, CertificationRequest from pkcs10 */ - CertificationRequest certReq; - CertificationRequestInfo *reqInfo = new CertificationRequestInfo; - certReq.certificationRequestInfo = reqInfo; + NSSCertRequest certReq; + NSSCertRequestInfo &reqInfo = certReq.reqInfo; + PRErrorCode prtn; + + memset(&certReq, 0, sizeof(certReq)); /* * Step 1: convert CSSM_APPLE_CL_CSR_REQUEST to CertificationRequestInfo. + * All allocs via local arena pool. */ - reqInfo->version.Set(0); - - /* subject Name */ - NameBuilder *subject = new NameBuilder; - reqInfo->subject = subject; - subject->addX509Name(csrReq->subjectNameX509); + SecNssCoder coder; + ArenaAllocator alloc(coder); + clIntToData(0, reqInfo.version, alloc); - /* SubjectPublicKeyInfo, AlgorithmIdentifier from sm_x509af */ - SubjectPublicKeyInfo *snaccKeyInfo = new SubjectPublicKeyInfo; - reqInfo->subjectPublicKeyInfo = snaccKeyInfo; - AlgorithmIdentifier *snaccAlgId = new AlgorithmIdentifier; - snaccKeyInfo->algorithm = snaccAlgId; - CL_cssmAlgToSnaccOid(csrReq->subjectPublicKey->KeyHeader.AlgorithmId, - snaccAlgId->algorithm); - /* FIXME - for now assume NULL alg params */ - CL_nullAlgParams(*snaccAlgId); + /* subject Name, required */ + if(csrReq->subjectNameX509 == NULL) { + CssmError::throwMe(CSSMERR_CL_INVALID_POINTER); + } + CL_cssmNameToNss(*csrReq->subjectNameX509, reqInfo.subject, coder); - /* actual public key blob - AsnBits */ - snaccKeyInfo->subjectPublicKey.Set(reinterpret_cast - (csrReq->subjectPublicKey->KeyData.Data), - csrReq->subjectPublicKey->KeyData.Length * 8); + /* key --> CSSM_X509_SUBJECT_PUBLIC_KEY_INFO */ + CL_CSSMKeyToSubjPubKeyInfoNSS(*csrReq->subjectPublicKey, + reqInfo.subjectPublicKeyInfo, coder); /* attributes - see sm_x501if - we support one, CSSMOID_ChallengePassword, * as a printable string */ if(csrReq->challengeString) { - Attribute *attr = reqInfo->attributes.Append(); - /* attr->type is an OID */ - attr->type.Set(challengePassword_arc); - /* one value, spec'd as AsnAny, we have to encode first. */ - PrintableString snaccStr(csrReq->challengeString); - CssmAutoData encChallenge(*this); - SC_encodeAsnObj(snaccStr, encChallenge, - strlen(csrReq->challengeString) + 32); - /* AttributeValue is an AsnAny as far as SNACC is concerned */ - AttributeValue *av = attr->values.Append(); - CSM_Buffer *cbuf = new CSM_Buffer((char *)encChallenge.data(), - encChallenge.length()); - av->value = cbuf; + /* alloc a NULL_terminated array of NSS_Attribute pointers */ + reqInfo.attributes = (NSS_Attribute **)coder.malloc(2 * sizeof(NSS_Attribute *)); + reqInfo.attributes[1] = NULL; + + /* alloc one NSS_Attribute */ + reqInfo.attributes[0] = (NSS_Attribute *)coder.malloc(sizeof(NSS_Attribute)); + NSS_Attribute *attr = reqInfo.attributes[0]; + memset(attr, 0, sizeof(NSS_Attribute)); + + /* NULL_terminated array of attrValues */ + attr->attrValue = (CSSM_DATA **)coder.malloc(2 * sizeof(CSSM_DATA *)); + attr->attrValue[1] = NULL; + + /* one value - we're almost there */ + attr->attrValue[0] = (CSSM_DATA *)coder.malloc(sizeof(CSSM_DATA)); + + /* attrType is an OID, temp, use static OID */ + attr->attrType = CSSMOID_ChallengePassword; + + /* one value, spec'd as AsnAny, we have to encode first. */ + CSSM_DATA strData; + strData.Data = (uint8 *)csrReq->challengeString; + strData.Length = strlen(csrReq->challengeString); + prtn = coder.encodeItem(&strData, SEC_PrintableStringTemplate, + *attr->attrValue[0]); + if(prtn) { + clErrorLog("generateCsr: error encoding challengeString\n"); + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } } /* - * Step 2: DER-encode the CertificationRequestInfo. + * Step 2: DER-encode the NSSCertRequestInfo prior to signing. */ - CssmAutoData encReqInfo(*this); - SC_encodeAsnObj(*reqInfo, encReqInfo, 8 * 1024); // totally wild guess + CSSM_DATA encReqInfo; + prtn = coder.encodeItem(&reqInfo, NSS_CertRequestInfoTemplate, encReqInfo); + if(prtn) { + clErrorLog("generateCsr: error encoding CertRequestInfo\n"); + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } /* - * Step 3: sign the encoded CertificationRequestInfo. + * Step 3: sign the encoded NSSCertRequestInfo. */ CssmAutoData sig(*this); - signData(CCHandle, encReqInfo, sig); + CssmData &infoData = CssmData::overlay(encReqInfo); + signData(CCHandle, infoData, sig); /* - * Step 4: finish up CertificationRequest - signatureAlgorithm, signature + * Step 4: finish up NSSCertRequest - signatureAlgorithm, signature */ - certReq.signatureAlgorithm = new SignatureAlgorithmIdentifier; - certReq.signatureAlgorithm->algorithm.Set(reinterpret_cast( - csrReq->signatureOid.Data), csrReq->signatureOid.Length); + certReq.signatureAlgorithm.algorithm = csrReq->signatureOid; /* FIXME - for now assume NULL alg params */ - CL_nullAlgParams(*certReq.signatureAlgorithm); - certReq.signature.Set((char *)sig.data(), sig.length() * 8); + CL_nullAlgParams(certReq.signatureAlgorithm); + certReq.signature.Data = (uint8 *)sig.data(); + certReq.signature.Length = sig.length() * 8; /* - * Step 5: DER-encode the finished CertificationRequestSigned. + * Step 5: DER-encode the finished NSSCertRequest into app space. */ CssmAutoData encCsr(*this); - SC_encodeAsnObj(certReq, encCsr, - encReqInfo.length() + // size of the thing we signed - sig.length() + // size of signature - 100); // sigAlgId plus encoding overhead - + prtn = SecNssEncodeItemOdata(&certReq, NSS_CertRequestTemplate, encCsr); + if(prtn) { + clErrorLog("generateCsr: error encoding CertRequestInfo\n"); + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } + /* TBD - enc64 the result, when we have this much working */ csrPtr = (CSSM_DATA_PTR)malloc(sizeof(CSSM_DATA)); - csrPtr->Data = (uint8 *)malloc(encCsr.length()); + csrPtr->Data = (uint8 *)encCsr.data(); csrPtr->Length = encCsr.length(); - memmove(csrPtr->Data, encCsr.data(), encCsr.length()); + encCsr.release(); } /* @@ -144,40 +159,43 @@ void AppleX509CLSession::verifyCsr( * the whole thing and getting a CSSM_KEY from the * SubjectPublicKeyInfo. */ - CertificationRequest certReq; - const CssmData &csrEnc = CssmData::overlay(*csrPtr); - SC_decodeAsnObj(csrEnc, certReq); - CertificationRequestInfo *certReqInfo = certReq.certificationRequestInfo; - if(certReqInfo == NULL) { + NSSCertRequest certReq; + SecNssCoder coder; + PRErrorCode prtn; + + memset(&certReq, 0, sizeof(certReq)); + prtn = coder.decodeItem(*csrPtr, NSS_CertRequestTemplate, &certReq); + if(prtn) { CssmError::throwMe(CSSMERR_CL_INVALID_DATA); } - CSSM_KEY_PTR cssmKey = CL_extractCSSMKey(*certReqInfo->subjectPublicKeyInfo, + + NSSCertRequestInfo &reqInfo = certReq.reqInfo; + CSSM_KEY_PTR cssmKey = CL_extractCSSMKeyNSS(reqInfo.subjectPublicKeyInfo, *this, // alloc NULL); // no DecodedCert /* * 2. Obtain signature algorithm and parameters. */ - SignatureAlgorithmIdentifier *snaccAlgId = certReq.signatureAlgorithm; - if(snaccAlgId == NULL) { - CssmError::throwMe(CSSMERR_CL_INVALID_DATA); - } - CSSM_ALGORITHMS vfyAlg = CL_snaccOidToCssmAlg(snaccAlgId->algorithm); + CSSM_X509_ALGORITHM_IDENTIFIER sigAlgId = certReq.signatureAlgorithm; + CSSM_ALGORITHMS vfyAlg = CL_oidToAlg(sigAlgId.algorithm); /* * 3. Extract the raw bits to be verified and the signature. We * decode the CSR as a CertificationRequestSigned for this, which * avoids the decode of the CertificationRequestInfo. */ - CertificationRequestSigned certReqSigned; - SC_decodeAsnObj(csrEnc, certReqSigned); + NSS_SignedCertRequest certReqSigned; + memset(&certReqSigned, 0, sizeof(certReqSigned)); + prtn = coder.decodeItem(*csrPtr, NSS_SignedCertRequestTemplate, &certReqSigned); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_INVALID_DATA); + } - CSM_Buffer *cbuf = certReqSigned.certificationRequestInfo.value; - char *cbufData = const_cast(cbuf->Access()); - CssmData toVerify(cbufData, cbuf->Length()); - AsnBits sigBits = certReqSigned.signature; - size_t sigBytes = (sigBits.BitLen() + 7) / 8; - CssmData sig(const_cast(sigBits.BitOcts()), sigBytes); + CSSM_DATA sigBytes = certReqSigned.signature; + sigBytes.Length = (sigBytes.Length + 7 ) / 8; + CssmData &sigCdata = CssmData::overlay(sigBytes); + CssmData &toVerify = CssmData::overlay(certReqSigned.certRequestBlob); /* * 4. Attach to CSP, cook up signature context, verify signature. @@ -193,6 +211,7 @@ void AppleX509CLSession::verifyCsr( if(crtn) { CssmError::throwMe(crtn); } - verifyData(ccHand, toVerify, sig); + verifyData(ccHand, toVerify, sigCdata); CL_freeCSSMKey(cssmKey, *this); } + diff --git a/AppleX509CL/Session_Cert.cpp b/AppleX509CL/Session_Cert.cpp index 4d90b15e..1f1e2208 100644 --- a/AppleX509CL/Session_Cert.cpp +++ b/AppleX509CL/Session_Cert.cpp @@ -22,6 +22,7 @@ #include "AppleX509CLSession.h" #include "DecodedCert.h" +#include "DecodedCrl.h" #include "CLCachedEntry.h" #include "cldebugging.h" #include @@ -40,7 +41,7 @@ AppleX509CLSession::CertGetAllFields( uint32 &NumberOfFields, CSSM_FIELD_PTR &CertFields) { - class DecodedCert decodedCert(*this, Cert); + DecodedCert decodedCert(*this, Cert); decodedCert.getAllParsedCertFields(NumberOfFields, CertFields); } @@ -107,6 +108,10 @@ AppleX509CLSession::CertGetNextFieldValue( if(query == NULL) { CssmError::throwMe(CSSMERR_CL_INVALID_RESULTS_HANDLE); } + if(query->queryType() != CLQ_Cert) { + clErrorLog("CertGetNextFieldValue: bad queryType (%d)", (int)query->queryType()); + CssmError::throwMe(CSSMERR_CL_INVALID_RESULTS_HANDLE); + } if(query->nextIndex() >= query->numFields()) { return false; } @@ -199,7 +204,7 @@ AppleX509CLSession::CertAbortCache( /* fetch the associated cached cert, remove from map, delete it */ CLCachedCert *cachedCert = lookupCachedCert(CertHandle); if(cachedCert == NULL) { - errorLog0("CertAbortCache: cachedCert not found\n"); + clErrorLog("CertAbortCache: cachedCert not found"); CssmError::throwMe(CSSMERR_CL_INVALID_CACHE_HANDLE); } cacheMap.removeEntry(cachedCert->handle()); @@ -218,13 +223,17 @@ AppleX509CLSession::CertAbortQuery( if(query == NULL) { CssmError::throwMe(CSSMERR_CL_INVALID_RESULTS_HANDLE); } - + if(query->queryType() != CLQ_Cert) { + clErrorLog("CertAbortQuery: bad queryType (%d)", (int)query->queryType()); + CssmError::throwMe(CSSMERR_CL_INVALID_RESULTS_HANDLE); + } + if(!query->fromCache()) { /* the associated cached cert was created just for this query; dispose */ CLCachedCert *cachedCert = lookupCachedCert(query->cachedObject()); if(cachedCert == NULL) { /* should never happen */ - errorLog0("CertAbortQuery: cachedCert not found\n"); + clErrorLog("CertAbortQuery: cachedCert not found"); CssmError::throwMe(CSSMERR_CL_INTERNAL_ERROR); } cacheMap.removeEntry(cachedCert->handle()); @@ -254,7 +263,7 @@ AppleX509CLSession::CertCreateTemplate( * when we sign the cert; maybe we should do it here. */ /* - * We have the CertificateToSign in snacc format. Encode. + * We have the CertificateToSign in NSS format. Encode. */ CssmRemoteData rData(*this, CertTemplate); cert.encodeTbs(rData); @@ -287,14 +296,18 @@ AppleX509CLSession::FreeFields( thisOid = &thisField->FieldOid; /* oid-specific handling of value */ - /* TBD - if this fails, call tbd DecodedCRL::freeCertFieldData */ /* BUG - the CssmRemoteData constructor clears the referent, * iff the referent is a CSSSM_DATA (as opposed to a CssmData). */ CssmData &cData = CssmData::overlay(thisField->FieldValue); CssmRemoteData rData(*this, cData); - DecodedCert::freeCertFieldData(CssmOid::overlay(*thisOid), rData); - + try { + DecodedCert::freeCertFieldData(CssmOid::overlay(*thisOid), rData); + } + catch(...) { + /* CRL field? */ + DecodedCrl::freeCrlFieldData(CssmOid::overlay(*thisOid), rData); + } /* and the oid itself */ free(thisOid->Data); thisOid->Data = NULL; @@ -306,15 +319,17 @@ AppleX509CLSession::FreeFields( void AppleX509CLSession::FreeFieldValue( const CssmData &CertOrCrlOid, - CssmData *Value) + CssmData &Value) { - if(Value == NULL) { - CssmError::throwMe(CSSM_ERRCODE_INVALID_FIELD_POINTER); + CssmRemoteData cd(*this, Value); + try { + DecodedCert::freeCertFieldData(CertOrCrlOid, cd); + } + catch(...) { + /* CRL field? */ + DecodedCrl::freeCrlFieldData(CertOrCrlOid, cd); } - CssmRemoteData cd(*this, *Value); - /* TBD - if this fails, call tbd DecodedCRL::freeCertFieldData */ - DecodedCert::freeCertFieldData(CertOrCrlOid, cd); - free(Value); + free(&Value); } void @@ -350,8 +365,8 @@ AppleX509CLSession::PassThrough( /* * Create a Cert Signing Request (CSR). * Input is a CSSM_APPLE_CL_CSR_REQUEST. - * Output is a PEM-encoded CertSigningRequest (SNACC type - * CertificationRequest from pkcs10). + * Output is a PEM-encoded CertSigningRequest (NSS type + * NSS_SignedCertRequest from pkcs10). */ if(InputParams == NULL) { CssmError::throwMe(CSSMERR_CL_INVALID_INPUT_POINTER); diff --git a/AppleX509CL/Session_Crypto.cpp b/AppleX509CL/Session_Crypto.cpp index 90467ecd..bcce4930 100644 --- a/AppleX509CL/Session_Crypto.cpp +++ b/AppleX509CL/Session_Crypto.cpp @@ -25,14 +25,14 @@ #include "AppleX509CLSession.h" #include "DecodedCert.h" -#include "SnaccUtils.h" #include "cldebugging.h" #include "CSPAttacher.h" -#include "CertBuilder.h" +#include "clNssUtils.h" +#include +#include #include #include #include -#include /* * Given a DER-encoded cert, obtain a fully usable CSSM_KEY representing @@ -59,7 +59,7 @@ AppleX509CLSession::CertVerifyWithKey( CssmAutoData tbs(*this); CssmAutoData algId(*this); CssmAutoData sig(*this); - CL_certDecodeComponents(CertToBeVerified, tbs, algId, sig); + CL_certCrlDecodeComponents(CertToBeVerified, tbs, algId, sig); verifyData(CCHandle, tbs, sig); } @@ -87,7 +87,7 @@ AppleX509CLSession::CertVerify( CssmAutoData tbs(*this); // in DER format CssmAutoData algId(*this); // in DER format CssmAutoData sig(*this); // in DER format - CL_certDecodeComponents(CertToBeVerified, tbs, algId, sig); + CL_certCrlDecodeComponents(CertToBeVerified, tbs, algId, sig); /* these must be explicitly freed upon exit */ CSSM_KEY_PTR signerPubKey = NULL; @@ -120,15 +120,15 @@ AppleX509CLSession::CertVerify( CSSM_ATTRIBUTE_KEY, &attr); if(crtn) { - errorLog0("CertVerify: valid CCHandle but no key!\n"); + clErrorLog("CertVerify: valid CCHandle but no key!\n"); CssmError::throwMe(CSSMERR_CL_INVALID_CONTEXT_HANDLE); } /* require match */ - CASSERT(signerPubKey != NULL); + assert(signerPubKey != NULL); CSSM_KEY_PTR contextPubKey = attr->Attribute.Key; if(contextPubKey->KeyHeader.AlgorithmId != signerPubKey->KeyHeader.AlgorithmId) { - errorLog0("CertVerify: AlgorithmId mismatch!\n"); + clErrorLog("CertVerify: AlgorithmId mismatch!\n"); CssmError::throwMe(CSSMERR_CL_INVALID_CONTEXT_HANDLE); } @@ -140,16 +140,25 @@ AppleX509CLSession::CertVerify( else { /* * All we have is signer cert. We already have its public key; - * get signature alg from CertToBeVerified's Cert.algID (which - * we currently have in DER form). + * get signature alg from CertToBeVerified's Cert.algID, which + * we currently have in DER form. Decode it into temp memory. */ - CASSERT(SignerCert != NULL); - CASSERT(signerPubKey != NULL); + assert(SignerCert != NULL); + assert(signerPubKey != NULL); - AlgorithmIdentifier snaccAlgId; - //CL_decodeAlgId(algId, snaccAlgId); - SC_decodeAsnObj(algId, snaccAlgId); - CSSM_ALGORITHMS vfyAlg = CL_snaccOidToCssmAlg(snaccAlgId.algorithm); + CSSM_X509_ALGORITHM_IDENTIFIER cssmAlgId; + SecNssCoder coder; + PRErrorCode prtn; + + CssmData &algIdData = algId.get(); + memset(&cssmAlgId, 0, sizeof(cssmAlgId)); + prtn = coder.decode(algIdData.data(), algIdData.length(), + NSS_AlgorithmIDTemplate, &cssmAlgId); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + + CSSM_ALGORITHMS vfyAlg = CL_oidToAlg(cssmAlgId.algorithm); /* attach to CSP, cook up a context */ cspHand = getGlobalCspHand(true); @@ -216,28 +225,51 @@ AppleX509CLSession::CertSign( CSSM_ATTRIBUTE_KEY, &attr); if(crtn) { - errorLog0("CertSign: valid CCHandle but no signing key!\n"); + clErrorLog("CertSign: valid CCHandle but no signing key!\n"); CssmError::throwMe(CSSMERR_CL_INVALID_CONTEXT_HANDLE); } CSSM_KEY_PTR signingKey = attr->Attribute.Key; if(signingKey == NULL) { - errorLog0("CertSign: valid CCHandle, NULL signing key!\n"); + clErrorLog("CertSign: valid CCHandle, NULL signing key!\n"); CssmError::throwMe(CSSMERR_CL_INVALID_CONTEXT_HANDLE); } - AlgorithmIdentifier snaccAlgId; CssmAutoData encAlgId(*this); CssmAutoData rawSig(*this); CssmAutoData fullCert(*this); try { - /* CSSM alg --> snacc-style AlgorithmIdentifier object */ - CL_cssmAlgToSnaccOid(context->AlgorithmType, - snaccAlgId.algorithm); + /* + * FIXME: we really should break up the template and ensure that its + * signature algId matches the one we're signing with, or just use + * that algId here....for now, this is up to the app to make sure. + */ + + /* temp allocs/encode into here */ + SecNssCoder coder; + + /* CSSM alg --> CSSM_X509_ALGORITHM_IDENTIFIER */ + CSSM_X509_ALGORITHM_IDENTIFIER algId; + memset(&algId, 0, sizeof(algId)); + const CSSM_OID *oid = cssmAlgToOid(context->AlgorithmType); + + if(oid == NULL) { + clErrorLog("CertSIgn: unknown alg (%u)\n", + (unsigned)context->AlgorithmType); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + algId.algorithm = *oid; + /* NULL params - FIXME - is this OK? */ - CL_nullAlgParams(snaccAlgId); + CL_nullAlgParams(algId); /* DER-encode the algID */ - SC_encodeAsnObj(snaccAlgId, encAlgId, 128); - /* sign TBS --> sig */ + PRErrorCode prtn; + prtn = SecNssEncodeItemOdata(&algId, NSS_AlgorithmIDTemplate, + encAlgId); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } + + /* sign TBS --> rawSig */ signData(CCHandle, CertTemplate, rawSig); /* put it all together */ CL_certEncodeComponents(CertTemplate, encAlgId, rawSig, fullCert); @@ -273,7 +305,7 @@ AppleX509CLSession::signData( CSSM_ALGID_NONE, // DigestAlgorithm, &cSig); if(crtn) { - errorLog1("AppleX509CLSession::CSSM_SignData: %s\n", + clErrorLog("AppleX509CLSession::CSSM_SignData: %s\n", cssmErrorString(crtn).c_str()); CssmError::throwMe(crtn); } @@ -298,8 +330,6 @@ void AppleX509CLSession::verifyData( CSSM_ALGID_NONE, // Digest alg &sig); if(crtn) { - // errorLog1("AppleX509CLSession::verifyData: %s\n", - // cssmErrorString(crtn).c_str()); if(crtn == CSSMERR_CSP_VERIFY_FAILED) { /* CSP and CL report this differently */ CssmError::throwMe(CSSMERR_CL_VERIFICATION_FAILURE); diff --git a/AppleX509CL/SnaccUtils.cpp b/AppleX509CL/SnaccUtils.cpp deleted file mode 100644 index 409caaf5..00000000 --- a/AppleX509CL/SnaccUtils.cpp +++ /dev/null @@ -1,934 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * CertSNACC.cpp - snacc-related cert functions - * - * Created 9/1/2000 by Doug Mitchell. - * Copyright (c) 2000 by Apple Computer. - */ - -#include "SnaccUtils.h" -#include "CSPAttacher.h" -#include "cldebugging.h" -#include -#include -#include -#include -#include - -#define DEBUG_DECODE 0 -#if DEBUG_DECODE -#define ddprintf(x) printf x -#else -#define ddprintf(x) -#endif - -/* - * AsnOid "constants" which we construct and cache on demand to avoid the - * somewhat expensive op of constructing them every time we test for equality - * in CL_snaccOidToCssmAlg. - */ -class AlgOidCache -{ -public: - AlgOidCache() : - mRsaEncryption(rsaEncryption_arc), - mMd2WithRSAEncryption(md2WithRSAEncryption_arc), - mMd5WithRSAEncryption(md5WithRSAEncryption_arc), - mSha1withRSAEncryption(sha1withRSAEncryption_arc), - mId_dsa(id_dsa_arc), - mId_dsa_with_sha1(id_dsa_with_sha1_arc), - mAppleFee(appleFee_arc), - mAppleAsc(appleAsc_arc), - mAppleFeeMD5(appleFeeMD5_arc), - mAppleFeeSHA1(appleFeeSHA1_arc), - mAppleFeed(appleFeed_arc), - mAppleFeedExp(appleFeedExp_arc), - mAppleECDSA(appleECDSA_arc) - { } - - AsnOid mRsaEncryption; - AsnOid mMd2WithRSAEncryption; - AsnOid mMd5WithRSAEncryption; - AsnOid mSha1withRSAEncryption; - AsnOid mId_dsa; - AsnOid mId_dsa_with_sha1; - AsnOid mAppleFee; - AsnOid mAppleAsc; - AsnOid mAppleFeeMD5; - AsnOid mAppleFeeSHA1; - AsnOid mAppleFeed; - AsnOid mAppleFeedExp; - AsnOid mAppleECDSA; -}; - -static ModuleNexus algOidCache; - -/* - * To ensure a secure means of signing and verifying TBSCert blobs, we - * provide these functions to encode and decode just the top-level - * elements of a certificate. Snacc doesn't allow you to specify, for - * example, a fully encoded TBSCert prior to encoding the whole cert after - * signing it - you have to decode the TBSCert, put it and the other - * components into a Cert, and then encode the whole thing. Unfortunately - * there is no guarantee that when you decode and re-encode a TBSCert blob, - * you get the same thing you started with (although with DER rules, as - * opposed to BER rules, you should). Thus when signing, we sign the TBSCert - * and encode the signed cert here without ever decoding the TBSCert (or, - * at least, without using the decoded version to get the encoded TBS blob). - */ - -void -CL_certDecodeComponents( - const CssmData &signedCert, // DER-encoded - CssmOwnedData &TBSCert, // still DER-encoded - CssmOwnedData &algId, // ditto - CssmOwnedData &rawSig) // raw bits (not an encoded AsnBits) -{ - CssmAutoData encodedSig(rawSig.allocator); - - /* drop signedCert into an AsnBuf for processing */ - AsnBuf buf; - buf.InstallData(reinterpret_cast(signedCert.data()), signedCert.length()); - - /* based on snacc-generated Certificate::BDec() and BDecContent() */ - AsnTag tag; - AsnLen bytesDecoded = 0; - AsnLen decLen; // from BDecLen - AsnLen totalLen; // including tag and ASN length - char *elemStart; // ptr to start of element, including tag - - ENV_TYPE env; - try { - tag = BDecTag (buf, bytesDecoded, env); - if (tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) { - errorLog1("CL_CertDecodeComponents: bad first-level tag (0x%x)\n", tag); - CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); - } - decLen = BDecLen (buf, bytesDecoded, env); // of total - /* FIXME - we should be able to ensure right here that we have enough */ - - /* First element, TBSCert */ - /* Note we need to include the tag and content in the outgoing blobs */ - elemStart = buf.DataPtr() + bytesDecoded; - tag = BDecTag (buf, bytesDecoded, env); - if(tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) { - errorLog1("CL_CertDecodeComponents: bad TBSCert tag (0x%x)\n", tag); - CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); - } - - decLen = BDecLen (buf, bytesDecoded, env); // DER 'length' - /* buf now at first content byte; simulate grabbing content */ - totalLen = decLen + (bytesDecoded - (elemStart - buf.DataPtr())); - buf.Skip(decLen); - bytesDecoded += decLen; - TBSCert.copy(elemStart, totalLen); - ddprintf(("CL_certDecodeComponents: TBS len %d; data %02x %02x %02x %02x...\n", - totalLen, ((uint8 *)elemStart)[0], ((uint8 *)elemStart)[1], - ((uint8 *)elemStart)[2], ((uint8 *)elemStart)[3])); - - /* next element, algId */ - elemStart = buf.DataPtr() + bytesDecoded; - tag = BDecTag (buf, bytesDecoded, env); - if(tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) { - errorLog1("CL_CertDecodeComponents: bad AlgId tag (0x%x)\n", tag); - CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); - } - decLen = BDecLen (buf, bytesDecoded, env); - totalLen = decLen + (bytesDecoded - (elemStart - buf.DataPtr())); - buf.Skip(decLen); - bytesDecoded += decLen; - algId.copy(elemStart, totalLen); - ddprintf(("CL_certDecodeComponents: algId len %d; data %02x %02x %02x...\n", - totalLen, ((uint8 *)elemStart)[0], ((uint8 *)elemStart)[1], - ((uint8 *)elemStart)[2])); - - /* next element, signature */ - elemStart = buf.DataPtr() + bytesDecoded; - tag = BDecTag (buf, bytesDecoded, env); - if((tag != MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)) && - (tag != MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE))) { - errorLog1("CL_CertDecodeComponents: bad sig tag 0x%x\n", tag); - CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); - } - decLen = BDecLen (buf, bytesDecoded, env); - totalLen = decLen + (bytesDecoded - (elemStart - buf.DataPtr())); - encodedSig.copy(elemStart, totalLen); - ddprintf(("CL_certDecodeComponents: encodedSig len %d; data %02x %02x " - "%02x %02x...\n", - totalLen, ((uint8 *)elemStart)[0], ((uint8 *)elemStart)[1], - ((uint8 *)elemStart)[2], ((uint8 *)elemStart)[3])); - - /* - * encodedSig is a DER-encoded AsnBits. Decode for caller. - */ - SC_decodeAsnBitsToCssmData(encodedSig.get(), rawSig); - ddprintf(("CL_certDecodeComponents: rawSig len %d\n", rawSig.length())); - /* - * OK, if we get here, we can skip the remaining stuff from - * Certificate::BDecContent(), which involves getting to the end - * of indefinte-length data. - */ - } - catch(...) { - errorLog0("CL_CertDecodeComponents: throw during decode\n"); - TBSCert.reset(); - algId.reset(); - rawSig.reset(); - CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); - } -} - -/* - * Given pre-DER-encoded blobs, do the final encode step for a signed cert. - */ -void -CL_certEncodeComponents( - const CssmData &TBSCert, // DER-encoded - const CssmData &algId, // ditto - const CssmData &rawSig, // raw bits, not encoded - CssmOwnedData &signedCert) // DER-encoded -{ - /* first BER-encode the signature */ - AsnBits snaccSig(reinterpret_cast(rawSig.data()), - rawSig.length() * 8); - CssmAutoData encodedSig(signedCert.allocator); - SC_encodeAsnObj(snaccSig, encodedSig, rawSig.length() + 10); - - /* - * OK, we have all three cert components already DER-encoded. The encoded - * cert is just (tag | contentLength | TBSCert | algId | encodedSig). - * To avoid an unneccessary copy at the end of the encode, figure out - * the length of tag and contentLength. The tag is known to be one byte. - */ - size_t contentLen = TBSCert.length() + algId.length() + encodedSig.length(); - size_t lenLen = SC_lengthOfLength(contentLen); - size_t totalLen = 1 /* tag */ + lenLen /* length bytes */ + contentLen; - signedCert.malloc(totalLen); - - /* tag */ - char *cp = (char *)signedCert.data(); - *cp++ = UNIV | CONS | SEQ_TAG_CODE; - - /* length */ - SC_encodeLength(contentLen, cp, lenLen); - cp += lenLen; - - /* concatenate the existing components */ - memcpy(cp, TBSCert.data(), TBSCert.length()); - cp += TBSCert.length(); - memcpy(cp, algId.data(), algId.length()); - cp += algId.length(); - memcpy(cp, encodedSig.data(), encodedSig.length()); - CASSERT((cp + encodedSig.length()) == - ((char *)signedCert.data() + signedCert.length())); -} - -/* malloc/copy a CsmmOid from a snacc-style AsnOid. */ -void CL_snaccOidToCssm( - const AsnOid &inOid, - CssmOid &outOid, - CssmAllocator &alloc) -{ - outOid.Data = (uint8 *)alloc.malloc(inOid.Len()); - outOid.Length = inOid.Len(); - const char *cp = inOid; - memcpy(outOid.Data, cp, outOid.Length); -} - -/* convert algorithm identifier from CSSM format to snacc format */ -void CL_cssmAlgIdToSnacc ( - const CSSM_X509_ALGORITHM_IDENTIFIER &cssmAlgId, - AlgorithmIdentifier &snaccAlgId) -{ - snaccAlgId.algorithm.Set(reinterpret_cast( - cssmAlgId.algorithm.Data), cssmAlgId.algorithm.Length); - if(cssmAlgId.parameters.Data != NULL) { - /* optional parameters, raw bytes */ - /* FIXME - is that right? SHould we encode as a bit string? - * I've never seen this "ANY" type field used... */ - snaccAlgId.parameters = new AsnAny; - CSM_Buffer *cbuf = new CSM_Buffer( - reinterpret_cast(cssmAlgId.parameters.Data), - cssmAlgId.parameters.Length); - snaccAlgId.parameters->value = cbuf; - } - else { - CL_nullAlgParams(snaccAlgId); - } -} - -/* convert algorithm indentifier from snacc format to CSSM format */ -void CL_snaccAlgIdToCssm ( - const AlgorithmIdentifier &snaccAlgId, - CSSM_X509_ALGORITHM_IDENTIFIER &cssmAlgId, - CssmAllocator &alloc) -{ - memset(&cssmAlgId, 0, sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)); - - /* algorithm - required */ - CssmOid &outOid = CssmOid::overlay(cssmAlgId.algorithm); - CL_snaccOidToCssm(snaccAlgId.algorithm, outOid, alloc); - - /* parameters as AsnAny - optional - for now just pass back the raw bytes */ - if(snaccAlgId.parameters != NULL) { - CSM_Buffer *cbuf = snaccAlgId.parameters->value; - cssmAlgId.parameters.Data = (uint8 *)alloc.malloc(cbuf->Length()); - cssmAlgId.parameters.Length = cbuf->Length(); - memmove(cssmAlgId.parameters.Data, cbuf->Access(), - cssmAlgId.parameters.Length); - } -} - -/* convert between uint32-style CSSM algorithm and snacc-style AsnOid */ -CSSM_ALGORITHMS CL_snaccOidToCssmAlg( - const AsnOid &oid) -{ - AlgOidCache &oc = algOidCache(); - - CSSM_ALGORITHMS cssmAlg = 0; - if(oid == oc.mRsaEncryption) { - cssmAlg = CSSM_ALGID_RSA; - } - else if(oid == oc.mMd2WithRSAEncryption) { - cssmAlg = CSSM_ALGID_MD2WithRSA; - } - else if(oid == oc.mMd5WithRSAEncryption) { - cssmAlg = CSSM_ALGID_MD5WithRSA; - } - else if(oid == oc.mSha1withRSAEncryption) { - cssmAlg = CSSM_ALGID_SHA1WithRSA; - } - else if(oid == oc.mId_dsa) { - cssmAlg = CSSM_ALGID_DSA; - } - else if(oid == oc.mId_dsa_with_sha1) { - cssmAlg = CSSM_ALGID_SHA1WithDSA; - } - else if(oid == oc.mAppleFee) { - cssmAlg = CSSM_ALGID_FEE; - } - else if(oid == oc.mAppleAsc) { - cssmAlg = CSSM_ALGID_ASC; - } - else if(oid == oc.mAppleFeeMD5) { - cssmAlg = CSSM_ALGID_FEE_MD5; - } - else if(oid == oc.mAppleFeeSHA1) { - cssmAlg = CSSM_ALGID_FEE_SHA1; - } - else if(oid == oc.mAppleFeed) { - cssmAlg = CSSM_ALGID_FEED; - } - else if(oid == oc.mAppleFeedExp) { - cssmAlg = CSSM_ALGID_FEEDEXP; - } - else if(oid == oc.mAppleECDSA) { - cssmAlg = CSSM_ALGID_SHA1WithECDSA; - } - /* etc. */ - else { - errorLog0("snaccOidToCssmAlg: unknown alg\n"); - #ifndef NDEBUG - printf("Bogus OID: "); oid.Print(cout); - printf("\n"); - #endif - CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); - } - return cssmAlg; -} - -void CL_cssmAlgToSnaccOid( - CSSM_ALGORITHMS cssmAlg, - AsnOid &oid) -{ - switch(cssmAlg) { - case CSSM_ALGID_RSA: - oid.ReSet(rsaEncryption_arc); - break; - case CSSM_ALGID_MD2WithRSA: - oid.ReSet(md2WithRSAEncryption_arc); - break; - case CSSM_ALGID_MD5WithRSA: - oid.ReSet(md5WithRSAEncryption_arc); - break; - case CSSM_ALGID_SHA1WithRSA: - oid.ReSet(sha1withRSAEncryption_arc); - break; - case CSSM_ALGID_DSA: - oid.ReSet(id_dsa_arc); - break; - case CSSM_ALGID_SHA1WithDSA: - oid.ReSet(id_dsa_with_sha1_arc); - break; - case CSSM_ALGID_FEE: - oid.ReSet(appleFee_arc); - break; - case CSSM_ALGID_ASC: - oid.ReSet(appleAsc_arc); - break; - case CSSM_ALGID_FEE_MD5: - oid.ReSet(appleFeeMD5_arc); - break; - case CSSM_ALGID_FEE_SHA1: - oid.ReSet(appleFeeSHA1_arc); - break; - case CSSM_ALGID_FEED: - oid.ReSet(appleFeed_arc); - break; - case CSSM_ALGID_FEEDEXP: - oid.ReSet(appleFeedExp_arc); - break; - case CSSM_ALGID_SHA1WithECDSA: - oid.ReSet(appleECDSA_arc); - break; - /* etc. */ - default: - errorLog1("cssmAlgToSnaccOid: unknown alg (%d)\n", (int)cssmAlg); - CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); - } -} - -/* set up a encoded NULL for AlgorithmIdentifier.parameters */ -void CL_nullAlgParams( - AlgorithmIdentifier &snaccAlgId) -{ - snaccAlgId.parameters = new AsnAny; - char encodedNull[2] = {NULLTYPE_TAG_CODE, 0}; - CSM_Buffer *cbuf = new CSM_Buffer(encodedNull, 2); - snaccAlgId.parameters->value = cbuf; -} - -/* AsnOcts --> CSSM_DATA */ -void CL_AsnOctsToCssmData( - const AsnOcts &octs, - CSSM_DATA &cdata, - CssmAllocator &alloc) -{ - const char *cp = octs; - CssmAutoData aData(alloc, (uint8 *)cp, octs.Len()); - cdata = aData.release(); -} - -#define MAX_NAME_SIZE (4 * 1024) - -/* snacc-style GeneralNames --> CE_GeneralNames */ -/* GeneralNames from sm_x509cmn.h */ -void CL_snaccGeneralNamesToCdsa( - GeneralNames &snaccObj, - CE_GeneralNames &cdsaObj, - CssmAllocator &alloc) -{ - cdsaObj.numNames = snaccObj.Count(); - if(cdsaObj.numNames == 0) { - cdsaObj.generalName = NULL; - return; - } - cdsaObj.generalName = (CE_GeneralName *)alloc.malloc( - cdsaObj.numNames * sizeof(CE_GeneralName)); - snaccObj.SetCurrToFirst(); - CssmAutoData aData(alloc); - for(unsigned i=0; ichoiceId) { - case GeneralName::otherNameCid: - /* OTHER_NAME, AsnOid */ - currCdsaName->nameType = GNT_OtherName; - src = *currSnaccName->otherName; - len = currSnaccName->otherName->Len(); - break; - case GeneralName::rfc822NameCid: - /* IA5String, AsnOcts */ - currCdsaName->nameType = GNT_RFC822Name; - src = *currSnaccName->rfc822Name; - len = currSnaccName->rfc822Name->Len(); - break; - case GeneralName::dNSNameCid: - /* IA5String, AsnOcts */ - currCdsaName->nameType = GNT_DNSName; - src = *currSnaccName->dNSName; - len = currSnaccName->dNSName->Len(); - break; - case GeneralName::x400AddressCid: - /* ORAddress from sm_x411mtsas */ - currCdsaName->nameType = GNT_X400Address; - toBeEncoded = currSnaccName->x400Address; - break; - case GeneralName::directoryNameCid: - /* Name from sm_x501if */ - /* We actually have to to deal with this in CertFields.cpp; - * it'll be easy to support this (with a mod to - * CE_GeneralName). - */ - currCdsaName->nameType = GNT_DirectoryName; - toBeEncoded = currSnaccName->directoryName; - break; - case GeneralName::ediPartyNameCid: - /* EDIPartyName from sm_x509cmn */ - currCdsaName->nameType = GNT_EdiPartyName; - toBeEncoded = currSnaccName->ediPartyName; - break; - case GeneralName::uniformResourceIdentifierCid: - /* IA5String, AsnOcts */ - currCdsaName->nameType = GNT_URI; - src = *currSnaccName->uniformResourceIdentifier; - len = currSnaccName->uniformResourceIdentifier->Len(); - break; - case GeneralName::iPAddressCid: - /* AsnOcts */ - currCdsaName->nameType = GNT_IPAddress; - src = *currSnaccName->iPAddress; - len = currSnaccName->iPAddress->Len(); - break; - case GeneralName::registeredIDCid: - /* AsnOid */ - currCdsaName->nameType = GNT_RegisteredID; - src = *currSnaccName->registeredID; - len = currSnaccName->registeredID->Len(); - break; - } - if(src == NULL) { - /* punt - encode the complex object and give caller the encoded - * bytes */ - CASSERT(toBeEncoded != NULL); - SC_encodeAsnObj(*toBeEncoded, aData, MAX_NAME_SIZE); - src = aData; - len = aData.length(); - aData.release(); - freeSrc = true; - currCdsaName->berEncoded = CSSM_TRUE; - } - else { - CASSERT(toBeEncoded == NULL); - currCdsaName->berEncoded = CSSM_FALSE; - } - - /* src --> currCdsaName->name */ - currCdsaName->name.Data = (uint8 *)alloc.malloc(len); - currCdsaName->name.Length = len; - memmove(currCdsaName->name.Data, src, len); - if(freeSrc) { - alloc.free(src); - } - snaccObj.GoNext(); - } -} - -/* CE_GeneralNames --> snacc-style GeneralNames */ -/* GeneralNames from sm_x509cmn.h */ -GeneralNames *CL_cdsaGeneralNamesToSnacc( - CE_GeneralNames &cdsaObj) -{ - GeneralNames *snaccObj = new GeneralNames; - bool abortFlag = false; // true --> invalid incoming field - CssmAllocator &alloc = CssmAllocator::standard(); - - for(unsigned i=0; i(currCdsaName->name.Data); - unsigned rawDataLen = currCdsaName->name.Length; - GeneralName *currSnaccName = snaccObj->Append(); - CssmData &berCdata = CssmData::overlay(currCdsaName->name); - CssmRemoteData berData(alloc, berCdata); - switch(currCdsaName->nameType) { - case GNT_OtherName: - /* OTHER_NAME, AsnOid */ - if(currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::otherNameCid; - currSnaccName->otherName = new AsnOid(rawData, rawDataLen); - break; - - case GNT_RFC822Name: - /* IA5String */ - if(currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::rfc822NameCid; - currSnaccName->rfc822Name = new IA5String(rawData, rawDataLen); - break; - case GNT_DNSName: - /* IA5String */ - if(currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::dNSNameCid; - currSnaccName->rfc822Name = new IA5String(rawData, rawDataLen); - break; - - case GNT_X400Address: - /* ORAddress from sm_x411mtsas */ - if(!currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::x400AddressCid; - currSnaccName->x400Address = new ORAddress; - try { - SC_decodeAsnObj(berData, *currSnaccName->x400Address); - } - catch(...) { - abortFlag = true; - } - break; - case GNT_DirectoryName: - /* Name from sm_x501if */ - /* We actually have to to deal with this in CertFields.cpp; - * it'll be easy to support this (with a mod to - * CE_GeneralName). - */ - if(!currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::directoryNameCid; - currSnaccName->directoryName = new Name; - try { - SC_decodeAsnObj(berData, *currSnaccName->directoryName); - } - catch(...) { - abortFlag = true; - } - break; - - case GNT_EdiPartyName: - /* EDIPartyName from sm_x509cmn */ - if(!currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::ediPartyNameCid; - currSnaccName->ediPartyName = new EDIPartyName; - try { - SC_decodeAsnObj(berData, *currSnaccName->ediPartyName); - } - catch(...) { - abortFlag = true; - } - break; - - case GNT_URI: - /* IA5String */ - if(currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::uniformResourceIdentifierCid; - currSnaccName->uniformResourceIdentifier = - new IA5String(rawData, rawDataLen); - break; - - case GNT_IPAddress: - /* AsnOcts */ - if(currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::iPAddressCid; - currSnaccName->iPAddress = new AsnOcts(rawData, rawDataLen); - break; - case GNT_RegisteredID: - /* AsnOid */ - if(currCdsaName->berEncoded) { - abortFlag = true; - break; - } - currSnaccName->choiceId = GeneralName::registeredIDCid; - currSnaccName->registeredID = new AsnOid(rawData, rawDataLen); - break; - } - berData.release(); - if(abortFlag) { - break; - } - } - if(abortFlag) { - delete snaccObj; - CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); - } - return snaccObj; -} - -void CL_normalizeString( - char *strPtr, - int &strLen) -{ - char *pCh = strPtr; // working ptr - char *pD = pCh; // start of good string chars - char *pEos = pCh + strLen - 1; - - if(strLen == 0) { - return; - } - - /* adjust if Length included NULL terminator */ - while(*pEos == 0) { - pEos--; - } - - /* Remove trailing spaces */ - while(isspace(*pEos)) { - pEos--; - } - - /* Point to one past last non-space character */ - pEos++; - - /* upper case */ - while(pCh < pEos) { - *pCh = toupper(*pCh); - pCh++; - } - - /* clean out whitespace */ - /* - * 1. skip all leading whitespace - */ - pCh = pD; - while(isspace(*pCh) && (pCh < pEos)) { - pCh++; - } - - /* - * 2. eliminate multiple whitespace. - * pCh points to first non-white char. - * pD still points to start of string - */ - char ch; - while(pCh < pEos) { - ch = *pCh++; - *pD++ = ch; // normal case - if( isspace(ch) ){ - /* skip 'til next nonwhite */ - while(isspace(*pCh) && (pCh < pEos)) { - pCh++; - } - } - }; - - strLen = pD - strPtr; -} - -/* - * Normalize an RDN. Per RFC2459 (4.1.2.4), printable strings are case - * insensitive and we're supposed to ignore leading and trailing - * whitespace, and collapse multiple whitespace characters into one. - */ -void CL_normalizeX509Name( - Name &name, - CssmAllocator &alloc) -{ - RDNSequence *rdns = name.rDNSequence; - int numRdns = rdns->Count(); - if((rdns == NULL) || (numRdns == 0)) { - /* not technically an error */ - return; - } - - rdns->SetCurrElmt(0); - for(int rdnDex=0; rdnDexCurr(); - if(rdn == NULL) { - /* not sure how this can happen... */ - dprintf1("clNormalizeX509Name: NULL rdn at index %d\n", rdnDex); - rdns->GoNext(); - continue; - } - int numAttrs = rdn->Count(); - if(numAttrs == 0) { - dprintf1("clNormalizeX509Name: zero numAttrs at index %d\n", rdnDex); - rdns->GoNext(); - continue; - } - - /* descend into array of attribute/values */ - rdn->SetCurrElmt(0); - for(int attrDex=0; attrDexCurr(); - if(att == NULL) { - /* not sure how this can happen... */ - dprintf1("clNormalizeX509Name: NULL att at index %d\n", attrDex); - rdn->GoNext(); - continue; - } - - /* - * att->value is an AsnAny (CSM_Buffer) containing an encoded - * string - supposedly a DirectoryString, but some certs put an - * IA5String here which is not handled by DirectoryString. - * - * (See e.g. the Thawte serverbasic cert, which has an email - * address in IA5String format.) In the IA5String case we skip the - * normalization. - * - * Anyway, figure out what's there, snag the raw string, normalize the - * string, cook up an appropriate DirectoryString for it, encode the - * result, and put the encoding back in att->value. - */ - CSM_Buffer *cbuf = att->value.value; - DirectoryString dirStr; - char *cbufData = const_cast(cbuf->Access()); - CssmData encodedStr(cbufData, cbuf->Length()); - - /* avoid exception if this is an IA5String... */ - char tagByte = cbufData[0]; - if((tagByte == (UNIV | PRIM | IA5STRING_TAG_CODE)) || - (tagByte == (UNIV | CONS | IA5STRING_TAG_CODE))) { - /* can't normalize */ - return; - } - try { - SC_decodeAsnObj(encodedStr, dirStr); - } - catch (...) { - /* can't normalize */ - errorLog0("clNormalizeX509Name: malformed DirectoryString (1)\n"); - return; - } - - /* normalize, we don't need to know what kind of string it is */ - char *strPtr = *dirStr.teletexString; - int newLen = dirStr.teletexString->Len(); - CL_normalizeString(strPtr, newLen); - - /* set new AsnOcts data from normalized version, freeing old */ - dirStr.teletexString->ReSet(strPtr, newLen); - - /* encode result */ - CssmAutoData normEncoded(alloc); - SC_encodeAsnObj(dirStr, normEncoded, newLen + 8); - - /* set new AsnAny data */ - cbuf->Set((char *)normEncoded.data(), normEncoded.length()); - - rdn->GoNext(); - } /* for each attribute/value */ - rdns->GoNext(); - } /* for each RDN */ -} - -/* - * Obtain a CSSM_KEY from a SubjectPublicKeyInfo, inferring as much as we can - * from required fields (subjectPublicKeyInfo) and extensions (for - * KeyUse, obtained from the optional DecodedCert). - */ -CSSM_KEY_PTR CL_extractCSSMKey( - SubjectPublicKeyInfo &snaccKeyInfo, - CssmAllocator &alloc, - const DecodedCert *decodedCert) // optional -{ - CSSM_KEY_PTR cssmKey = (CSSM_KEY_PTR) alloc.malloc(sizeof(CSSM_KEY)); - memset(cssmKey, 0, sizeof(CSSM_KEY)); - CSSM_KEYHEADER &hdr = cssmKey->KeyHeader; - CssmRemoteData keyData(alloc, cssmKey->KeyData); - try { - hdr.HeaderVersion = CSSM_KEYHEADER_VERSION; - /* CspId blank */ - hdr.BlobType = CSSM_KEYBLOB_RAW; - hdr.AlgorithmId = CL_snaccOidToCssmAlg(snaccKeyInfo.algorithm->algorithm); - - /* - * Format inferred from AlgorithmId. I have never seen these defined - * anywhere, e.g., whart's the format of an RSA public key in a cert? - * X509 certainly doesn't say. However. the following two cases are known - * to be correct. - */ - switch(hdr.AlgorithmId) { - case CSSM_ALGID_RSA: - hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_PKCS1; - break; - case CSSM_ALGID_DSA: - hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_FIPS186; - break; - case CSSM_ALGID_FEE: - /* CSSM_KEYBLOB_RAW_FORMAT_NONE --> DER encoded */ - hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_NONE; - break; - default: - /* punt */ - hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_NONE; - } - hdr.KeyClass = CSSM_KEYCLASS_PUBLIC_KEY; - - /* KeyUsage inferred from extensions */ - if(decodedCert) { - hdr.KeyUsage = decodedCert->inferKeyUsage(); - } - else { - hdr.KeyUsage = CSSM_KEYUSE_ANY; - } - - /* start/end date unknown, leave zero */ - hdr.WrapAlgorithmId = CSSM_ALGID_NONE; - hdr.WrapMode = CSSM_ALGMODE_NONE; - - /* - * subjectPublicKeyInfo.subjectPublicKey (AsnBits) ==> KeyData - */ - SC_asnBitsToCssmData(snaccKeyInfo.subjectPublicKey, keyData); - keyData.release(); - - /* - * LogicalKeySizeInBits - ask the CSP - */ - CSSM_CSP_HANDLE cspHand = getGlobalCspHand(true); - CSSM_KEY_SIZE keySize; - CSSM_RETURN crtn; - crtn = CSSM_QueryKeySizeInBits(cspHand, CSSM_INVALID_HANDLE, cssmKey, &keySize); - if(crtn) { - CssmError::throwMe(crtn); - } - cssmKey->KeyHeader.LogicalKeySizeInBits = - keySize.LogicalKeySizeInBits; - } - catch (...) { - alloc.free(cssmKey); - throw; - } - return cssmKey; -} - -void CL_freeCSSMKey( - CSSM_KEY_PTR cssmKey, - CssmAllocator &alloc, - bool freeTop) -{ - if(cssmKey == NULL) { - return; - } - alloc.free(cssmKey->KeyData.Data); - memset(cssmKey, 0, sizeof(CSSM_KEY)); - if(freeTop) { - alloc.free(cssmKey); - } -} - diff --git a/AppleX509CL/SnaccUtils.h b/AppleX509CL/SnaccUtils.h deleted file mode 100644 index 6c408473..00000000 --- a/AppleX509CL/SnaccUtils.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * SnaccUtils.h - snacc-related cert functions - * - * Created 9/1/2000 by Doug Mitchell. - * Copyright (c) 2000 by Apple Computer. - */ - -#ifndef _SNACC_UTILS_H_ -#define _SNACC_UTILS_H_ - -#include -#include -#include -#include -#include "DecodedCert.h" - -/* ghastly requirements of snacc-generated cert code */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -void -CL_certDecodeComponents( - const CssmData &signedCert, // DER-encoded - CssmOwnedData &TBSCert, // still DER-encoded - CssmOwnedData &algId, // ditto - CssmOwnedData &sig); // ditto - -void -CL_certEncodeComponents( - const CssmData &TBSCert, // DER-encoded - const CssmData &algId, // ditto - const CssmData &rawSig, // the raw bits, not encoded - CssmOwnedData &signedCert); // DER-encoded - -void CL_snaccOidToCssm( - const AsnOid &inOid, - CssmOid &outOid, - CssmAllocator &alloc); - -/* convert algorithm identifier between CSSM and snacc formats */ -void CL_cssmAlgIdToSnacc ( - const CSSM_X509_ALGORITHM_IDENTIFIER &cssmAlgId, - AlgorithmIdentifier &snaccAlgId); - -void CL_snaccAlgIdToCssm ( - const AlgorithmIdentifier &snaccAlgId, - CSSM_X509_ALGORITHM_IDENTIFIER &cssmAlgId, - CssmAllocator &alloc); - -/* convert between uint32-style CSSM algorithm and snacc-style AsnOid */ -CSSM_ALGORITHMS CL_snaccOidToCssmAlg( - const AsnOid &oid); - -void CL_cssmAlgToSnaccOid( - CSSM_ALGORITHMS cssmAlg, - AsnOid &oid); - -/* set up a encoded NULL for AlgorithmIdentifier.parameters */ -void CL_nullAlgParams( - AlgorithmIdentifier &snaccAlgId); - -/* AsnOcts --> CSSM_DATA */ -void CL_AsnOctsToCssmData( - const AsnOcts &octs, - CSSM_DATA &cdata, - CssmAllocator &alloc); - -/* snacc-style GeneralNames --> CE_GeneralNames */ -/* GeneralNames from sm_x509cmn.h */ -void CL_snaccGeneralNamesToCdsa( - GeneralNames &snaccObj, - CE_GeneralNames &cdsaObj, - CssmAllocator &alloc); - -/* CE_GeneralNames --> snacc-style GeneralNames */ -GeneralNames *CL_cdsaGeneralNamesToSnacc( - CE_GeneralNames &cdsaObj); - -#define MAX_RDN_SIZE (4 * 1024) - -void CL_normalizeString( - char *strPtr, - int &strLen); -void CL_normalizeX509Name( - Name &name, - CssmAllocator &alloc); - -/* - * Obtain a CSSM_KEY from a SubjectPublicKeyInfo, inferring as much as we can - * from required fields (subjectPublicKeyInfo) and extensions (for - * KeyUse, obtained from the optional DecodedCert). - */ -CSSM_KEY_PTR CL_extractCSSMKey( - SubjectPublicKeyInfo &snaccKeyInfo, - CssmAllocator &alloc, - const DecodedCert *decodedCert); // optional - -/* - * Free key obtained in CL_extractCSSMKey(). - */ -void CL_freeCSSMKey( - CSSM_KEY_PTR cssmKey, - CssmAllocator &alloc, - bool freeTop = true); // delete the actual key - // as well as contents - -#ifdef __cplusplus -} -#endif - -#endif /* _SNACC_UTILS_H_ */ - diff --git a/AppleX509CL/clNameUtils.cpp b/AppleX509CL/clNameUtils.cpp new file mode 100644 index 00000000..737a8a25 --- /dev/null +++ b/AppleX509CL/clNameUtils.cpp @@ -0,0 +1,741 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/* + * clNameUtils.cpp - support for Name, GeneralizedName, all sorts of names + */ + +#include "clNameUtils.h" +#include "clNssUtils.h" +#include "cldebugging.h" +#include + +#pragma mark ----- NSS_Name <--> CSSM_X509_NAME ----- + +/* + * NSS_ATV --> CSSM_X509_TYPE_VALUE_PAIR + */ + +void CL_nssAtvToCssm( + const NSS_ATV &nssObj, + CSSM_X509_TYPE_VALUE_PAIR &cssmObj, + CssmAllocator &alloc) +{ + /* tag and decoded data */ + cssmObj.valueType = nssObj.value.tag; + clAllocCopyData(alloc, nssObj.value.item, cssmObj.value); + /* the OID */ + clAllocCopyData(alloc, nssObj.type, cssmObj.type); +} + +/* NSS_RDN --> CSSM_X509_RDN */ +void CL_nssRdnToCssm( + const NSS_RDN &nssObj, + CSSM_X509_RDN &cssmObj, + CssmAllocator &alloc, + SecNssCoder &coder) // conversion requires further decoding +{ + memset(&cssmObj, 0, sizeof(cssmObj)); + unsigned numAtvs = clNssArraySize((const void **)nssObj.atvs); + if(numAtvs == 0) { + return; + } + + size_t len = numAtvs * sizeof(CSSM_X509_TYPE_VALUE_PAIR); + cssmObj.AttributeTypeAndValue = + (CSSM_X509_TYPE_VALUE_PAIR_PTR)alloc.malloc(len); + cssmObj.numberOfPairs = numAtvs; + CSSM_X509_TYPE_VALUE_PAIR_PTR cssmAtvs = cssmObj.AttributeTypeAndValue; + memset(cssmAtvs, 0, len); + + for(unsigned dex=0; dex CSSM_X509_NAME */ +void CL_nssNameToCssm( + const NSS_Name &nssObj, + CSSM_X509_NAME &cssmObj, + CssmAllocator &alloc) +{ + memset(&cssmObj, 0, sizeof(cssmObj)); + unsigned numRdns = clNssArraySize((const void **)nssObj.rdns); + if(numRdns == 0) { + /* not technically an error */ + return; + } + + size_t len = numRdns * sizeof(CSSM_X509_RDN); + cssmObj.RelativeDistinguishedName = (CSSM_X509_RDN_PTR)alloc.malloc(len); + cssmObj.numberOfRDNs = numRdns; + CSSM_X509_RDN_PTR cssmRdns = cssmObj.RelativeDistinguishedName; + memset(cssmRdns, 0, len); + + SecNssCoder coder; // conversion requires further decoding + + for(unsigned dex=0; dex NSS_ATV + */ +void CL_cssmAtvToNss( + const CSSM_X509_TYPE_VALUE_PAIR &cssmObj, + NSS_ATV &nssObj, + SecNssCoder &coder) +{ + memset(&nssObj, 0, sizeof(nssObj)); + + /* copy the OID */ + coder.allocCopyItem(cssmObj.type, nssObj.type); + + /* tag and value */ + nssObj.value.tag = cssmObj.valueType; + coder.allocCopyItem(cssmObj.value, nssObj.value.item); +} + +/* CSSM_X509_RDN --> NSS_RDN */ +void CL_cssmRdnToNss( + const CSSM_X509_RDN &cssmObj, + NSS_RDN &nssObj, + SecNssCoder &coder) +{ + memset(&nssObj, 0, sizeof(nssObj)); + + /* alloc NULL-terminated array of ATV pointers */ + unsigned numAtvs = cssmObj.numberOfPairs; + unsigned size = (numAtvs + 1) * sizeof(void *); + nssObj.atvs = (NSS_ATV **)coder.malloc(size); + memset(nssObj.atvs, 0, size); + + /* grind thru the elements */ + for(unsigned atvDex=0; atvDex NSS_Name */ +void CL_cssmNameToNss( + const CSSM_X509_NAME &cssmObj, + NSS_Name &nssObj, + SecNssCoder &coder) +{ + memset(&nssObj, 0, sizeof(nssObj)); + + /* alloc NULL-terminated array of RDN pointers */ + unsigned numRdns = cssmObj.numberOfRDNs; + nssObj.rdns = (NSS_RDN **)clNssNullArray(numRdns, coder); + + /* grind thru the elements */ + for(unsigned rdnDex=0; rdnDexatvs); + if(numAttrs == 0) { + clFieldLog("clNormalizeX509Name: zero numAttrs at index %d", rdnDex); + continue; + } + + /* descend into array of attribute/values */ + for(unsigned attrDex=0; attrDexatvs[attrDex]; + assert(attr != NULL); + + /* + * attr->value is an ASN_ANY containing an encoded + * string. We only normalize Prinatable String types. + * If we find one, decode it, normalize it, encode the + * result, and put the encoding back in attr->value. + * We temporarily "leak" the original string, which only + * has a lifetime of the incoming SecNssCoder. + */ + NSS_TaggedItem &attrVal = attr->value; + if(attrVal.tag != SEC_ASN1_PRINTABLE_STRING) { + /* skip it */ + continue; + } + + /* normalize */ + char *strPtr = (char *)attrVal.item.Data; + int newLen = attrVal.item.Length; + CL_normalizeString(strPtr, newLen); + + /* possible length adjustment */ + attrVal.item.Length = newLen; + } /* for each attribute/value */ + } /* for each RDN */ +} + +#pragma mark ----- CE_GeneralNames <--> NSS_GeneralNames ----- + +void CL_nssGeneralNameToCssm( + NSS_GeneralName &nssObj, + CE_GeneralName &cdsaObj, + SecNssCoder &coder, // for temp decoding + CssmAllocator &alloc) // destination +{ + memset(&cdsaObj, 0, sizeof(cdsaObj)); + PRErrorCode prtn; + + /* for caller's CE_GeneralName */ + CSSM_BOOL berEncoded = CSSM_FALSE; + CE_GeneralNameType cdsaTag; + + /* + * At this point, depending on the decoded object's tag, we either + * have the final bytes to copy out, or we need to decode further. + * After this switch, if doCopy is true, give the caller a copy + * of nssObj.item. + */ + bool doCopy = true; + switch(nssObj.tag) { + case NGT_OtherName: // ASN_ANY -> CE_OtherName + { + cdsaTag = GNT_OtherName; + + /* decode to coder memory */ + CE_OtherName *nssOther = + (CE_OtherName *)coder.malloc(sizeof(CE_OtherName)); + memset(nssOther, 0, sizeof(CE_OtherName)); + prtn = coder.decodeItem(nssObj.item, + NSS_GenNameOtherNameTemplate, + nssOther); + if(prtn) { + clErrorLog("CL_nssGeneralNameToCssm: error decoding " + "OtherName\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + + /* copy out to caller */ + clAllocData(alloc, cdsaObj.name, sizeof(CE_OtherName)); + clCopyOtherName(*nssOther, *((CE_OtherName *)cdsaObj.name.Data), + alloc); + doCopy = false; + break; + } + case NGT_RFC822Name: // IA5String, done + cdsaTag = GNT_RFC822Name; + break; + case NGT_DNSName: // IA5String + cdsaTag = GNT_DNSName; + break; + case NGT_X400Address: // ASY_ANY, leave alone + cdsaTag = GNT_X400Address; + berEncoded = CSSM_TRUE; + break; + case NGT_DirectoryName: // ASN_ANY --> NSS_Name + { + cdsaTag = GNT_DirectoryName; + + /* Decode to coder memory */ + NSS_Name *nssName = (NSS_Name *)coder.malloc(sizeof(NSS_Name)); + memset(nssName, 0, sizeof(NSS_Name)); + prtn = coder.decodeItem(nssObj.item, NSS_NameTemplate, nssName); + if(prtn) { + clErrorLog("CL_nssGeneralNameToCssm: error decoding " + "NSS_Name\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + + /* convert & copy out to caller */ + clAllocData(alloc, cdsaObj.name, sizeof(CSSM_X509_NAME)); + CL_nssNameToCssm(*nssName, + *((CSSM_X509_NAME *)cdsaObj.name.Data), alloc); + doCopy = false; + break; + } + case NGT_EdiPartyName: // ASN_ANY, leave alone + cdsaTag = GNT_EdiPartyName; + berEncoded = CSSM_TRUE; + break; + case NGT_URI: // IA5String + cdsaTag = GNT_URI; + break; + case NGT_IPAddress: // OCTET_STRING + cdsaTag = GNT_IPAddress; + break; + case NGT_RegisteredID: // OID + cdsaTag = GNT_RegisteredID; + break; + default: + clErrorLog("CL_nssGeneralNameToCssm: bad name tag\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + + cdsaObj.nameType = cdsaTag; + cdsaObj.berEncoded = berEncoded; + if(doCopy) { + clAllocCopyData(alloc, nssObj.item, cdsaObj.name); + } +} + +void CL_nssGeneralNamesToCssm( + const NSS_GeneralNames &nssObj, + CE_GeneralNames &cdsaObj, + SecNssCoder &coder, // for temp decoding + CssmAllocator &alloc) // destination +{ + memset(&cdsaObj, 0, sizeof(cdsaObj)); + unsigned numNames = clNssArraySize((const void **)nssObj.names); + if(numNames == 0) { + return; + } + + /* + * Decode each name element, currently a raw ASN_ANY blob. + * Then convert each result into CDSA form. + * This array of (NSS_GeneralName)s is temporary, it doesn't + * persist outside of this routine other than the fact that it's + * mallocd by the coder arena pool. + */ + NSS_GeneralName *names = + (NSS_GeneralName *)coder.malloc(sizeof(NSS_GeneralName) * numNames); + memset(names, 0, sizeof(NSS_GeneralName) * numNames); + cdsaObj.generalName = (CE_GeneralName *)alloc.malloc( + sizeof(CE_GeneralName) * numNames); + cdsaObj.numNames = numNames; + + for(unsigned dex=0; dexnumNames; i++) { + /* + * Two special cases here. + */ + CE_GeneralName *genName = &cdsaObj->generalName[i]; + switch(genName->nameType) { + case GNT_DirectoryName: + if((!genName->berEncoded) && // we're flexible + (genName->name.Length == + sizeof(CSSM_X509_NAME))) { // paranoia + CL_freeX509Name((CSSM_X509_NAME_PTR)genName->name.Data, alloc); + } + break; + + case GNT_OtherName: + if((!genName->berEncoded) && // we're flexible + (genName->name.Length == + sizeof(CE_OtherName))) { // paranoia + CE_OtherName *con = (CE_OtherName *)genName->name.Data; + CL_freeOtherName(con, alloc); + } + break; + default: + break; + } + /* and always free this */ + alloc.free(cdsaObj->generalName[i].name.Data); + } + if(cdsaObj->numNames) { + memset(cdsaObj->generalName, 0, cdsaObj->numNames * sizeof(CE_GeneralName)); + alloc.free(cdsaObj->generalName); + } + memset(cdsaObj, 0, sizeof(CE_GeneralNames)); +} + +void CL_freeCssmDistPoints( + CE_CRLDistPointsSyntax *cssmDps, + CssmAllocator &alloc) +{ + if(cssmDps == NULL) { + return; + } + for(unsigned dex=0; dexnumDistPoints; dex++) { + CE_CRLDistributionPoint *cssmDp = &cssmDps->distPoints[dex]; + if(cssmDp->distPointName) { + CL_freeCssmDistPointName(cssmDp->distPointName, alloc); + alloc.free(cssmDp->distPointName); + } + if(cssmDp->crlIssuer) { + CL_freeCssmGeneralNames(cssmDp->crlIssuer, alloc); + alloc.free(cssmDp->crlIssuer); + } + } + memset(cssmDps->distPoints, 0, + cssmDps->numDistPoints * sizeof(CE_CRLDistributionPoint)); + alloc.free(cssmDps->distPoints); + memset(cssmDps, 0, sizeof(*cssmDps)); +} + +void CL_freeCssmDistPointName( + CE_DistributionPointName *cssmDpn, + CssmAllocator &alloc) +{ + if(cssmDpn == NULL) { + return; + } + switch(cssmDpn->nameType) { + case CE_CDNT_FullName: + CL_freeCssmGeneralNames(cssmDpn->fullName, alloc); + alloc.free(cssmDpn->fullName); + break; + case CE_CDNT_NameRelativeToCrlIssuer: + CL_freeX509Rdn(cssmDpn->rdn, alloc); + alloc.free(cssmDpn->rdn); + break; + } + memset(cssmDpn, 0, sizeof(*cssmDpn)); +} + +/* free contents of an CSSM_X509_NAME */ +void CL_freeX509Name( + CSSM_X509_NAME_PTR x509Name, + CssmAllocator &alloc) +{ + if(x509Name == NULL) { + return; + } + for(unsigned rdnDex=0; rdnDexnumberOfRDNs; rdnDex++) { + CSSM_X509_RDN_PTR rdn = &x509Name->RelativeDistinguishedName[rdnDex]; + CL_freeX509Rdn(rdn, alloc); + } + alloc.free(x509Name->RelativeDistinguishedName); + memset(x509Name, 0, sizeof(CSSM_X509_NAME)); +} + +void CL_freeX509Rdn( + CSSM_X509_RDN_PTR rdn, + CssmAllocator &alloc) +{ + if(rdn == NULL) { + return; + } + for(unsigned atvDex=0; atvDexnumberOfPairs; atvDex++) { + CSSM_X509_TYPE_VALUE_PAIR_PTR atv = + &rdn->AttributeTypeAndValue[atvDex]; + alloc.free(atv->type.Data); + alloc.free(atv->value.Data); + memset(atv, 0, sizeof(CSSM_X509_TYPE_VALUE_PAIR)); + } + alloc.free(rdn->AttributeTypeAndValue); + memset(rdn, 0, sizeof(CSSM_X509_RDN)); +} + +void CL_freeOtherName( + CE_OtherName *cssmOther, + CssmAllocator &alloc) +{ + if(cssmOther == NULL) { + return; + } + alloc.free(cssmOther->typeId.Data); + alloc.free(cssmOther->value.Data); + memset(cssmOther, 0, sizeof(*cssmOther)); +} + +void CL_freeCssmIssuingDistPoint( + CE_IssuingDistributionPoint *cssmIdp, + CssmAllocator &alloc) +{ + CL_freeCssmDistPointName(cssmIdp->distPointName, alloc); +} + diff --git a/AppleX509CL/clNameUtils.h b/AppleX509CL/clNameUtils.h new file mode 100644 index 00000000..072b6065 --- /dev/null +++ b/AppleX509CL/clNameUtils.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/* + * clNameUtils.h - support for Name, GeneralizedName, all sorts of names + */ + +#ifndef _CL_NAME_UTILS_H_ +#define _CL_NAME_UTILS_H_ + +#include +#include +#include +#include +#include +#include + +void CL_nssAtvToCssm( + const NSS_ATV &nssObj, + CSSM_X509_TYPE_VALUE_PAIR &cssmObj, + CssmAllocator &alloc + #if !NSS_TAGGED_ITEMS + , SecNssCoder &coder + #endif + ); +void CL_nssRdnToCssm( + const NSS_RDN &nssObj, + CSSM_X509_RDN &cssmObj, + CssmAllocator &alloc, + SecNssCoder &coder); +void CL_nssNameToCssm( + const NSS_Name &nssObj, + CSSM_X509_NAME &cssmObj, + CssmAllocator &alloc); + +void CL_cssmAtvToNss( + const CSSM_X509_TYPE_VALUE_PAIR &cssmObj, + NSS_ATV &nssObj, + SecNssCoder &coder); +void CL_cssmRdnToNss( + const CSSM_X509_RDN &cssmObj, + NSS_RDN &nssObj, + SecNssCoder &coder); +void CL_cssmNameToNss( + const CSSM_X509_NAME &cssmObj, + NSS_Name &nssObj, + SecNssCoder &coder); + +void CL_normalizeString( + char *strPtr, + int &strLen); // IN/OUT +void CL_normalizeX509NameNSS( + NSS_Name &nssName, + SecNssCoder &coder); + +void CL_nssGeneralNameToCssm( + NSS_GeneralName &nssObj, + CE_GeneralName &cdsaObj, + SecNssCoder &coder, // for temp decoding + CssmAllocator &alloc); // destination + +void CL_nssGeneralNamesToCssm( + const NSS_GeneralNames &nssObj, + CE_GeneralNames &cdsaObj, + SecNssCoder &coder, // for temp decoding + CssmAllocator &alloc); // destination +void CL_cssmGeneralNameToNss( + CE_GeneralName &cdsaObj, + NSS_GeneralName &nssObj, // actually an NSSTaggedItem + SecNssCoder &coder); // for temp decoding +void CL_cssmGeneralNamesToNss( + const CE_GeneralNames &cdsaObj, + NSS_GeneralNames &nssObj, + SecNssCoder &coder); + +void clCopyOtherName( + const CE_OtherName &src, + CE_OtherName &dst, + CssmAllocator &alloc); + +void CL_freeAuthorityKeyId( + CE_AuthorityKeyID &cdsaObj, + CssmAllocator &alloc); +void CL_freeCssmGeneralNames( + CE_GeneralNames *cdsaObj, + CssmAllocator &alloc); +void CL_freeCssmDistPointName( + CE_DistributionPointName *cssmDpn, + CssmAllocator &alloc); +void CL_freeCssmDistPoints( + CE_CRLDistPointsSyntax *cssmDps, + CssmAllocator &alloc); +void CL_freeX509Name( + CSSM_X509_NAME_PTR x509Name, + CssmAllocator &alloc); +void CL_freeX509Rdn( + CSSM_X509_RDN_PTR rdn, + CssmAllocator &alloc); +void CL_freeOtherName( + CE_OtherName *cssmOther, + CssmAllocator &alloc); +void CL_freeCssmIssuingDistPoint( + CE_IssuingDistributionPoint *cssmIdp, + CssmAllocator &alloc); + + +#endif /* _CL_NAME_UTILS_H_ */ diff --git a/AppleX509CL/clNssUtils.cpp b/AppleX509CL/clNssUtils.cpp new file mode 100644 index 00000000..7997c716 --- /dev/null +++ b/AppleX509CL/clNssUtils.cpp @@ -0,0 +1,997 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/* + * clNssUtils.cpp - support for libnssasn1-based ASN1 encode/decode + */ + +#include "clNssUtils.h" +#include "clNameUtils.h" +#include "CSPAttacher.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma mark ----- ArenaAllocator ----- + +/* + * Avoid inlining this for debuggability + */ +void *ArenaAllocator::malloc(size_t len) throw(std::bad_alloc) +{ + try { + return mCoder.malloc(len); + } + catch (...) { + throw std::bad_alloc(); + } +} + +/* intentionally not implemented, should never be called */ +void ArenaAllocator::free(void *p) throw() +{ + throw std::bad_alloc(); +} + +void *ArenaAllocator::realloc(void *p, size_t len) throw(std::bad_alloc) +{ + throw std::bad_alloc(); +} + +#pragma mark ----- Malloc/Copy/Compare CSSM_DATA ----- + +/* + * Misc. alloc/copy with arbitrary CssmAllocator + */ +/* malloc d.Data, set d.Length */ +void clAllocData( + CssmAllocator &alloc, + CSSM_DATA &dst, + size_t len) +{ + if(len == 0) { + dst.Data = NULL; + } + else { + dst.Data = (uint8 *)alloc.malloc(len); + } + dst.Length = len; +} + +/* malloc and copy */ +void clAllocCopyData( + CssmAllocator &alloc, + const CSSM_DATA &src, + CSSM_DATA &dst) +{ + clAllocData(alloc, dst, src.Length); + if(dst.Length != 0) { + memmove(dst.Data, src.Data, src.Length); + } +} + +/* + * Compare two CSSM_DATAs (or two CSSM_OIDs), return true if identical. + */ +bool clCompareCssmData( + const CSSM_DATA *data1, + const CSSM_DATA *data2) +{ + if((data1 == NULL) || (data1->Data == NULL) || + (data2 == NULL) || (data2->Data == NULL) || + (data1->Length != data2->Length)) { + return false; + } + if(data1->Length != data2->Length) { + return false; + } + if(memcmp(data1->Data, data2->Data, data1->Length) == 0) { + return true; + } + else { + return false; + } +} + +#pragma mark ----- CSSM_DATA <--> uint32 ----- + +uint32 clDataToInt( + const CSSM_DATA &cdata, + CSSM_RETURN toThrow) /* = CSSMERR_CL_INVALID_CERT_POINTER */ +{ + if((cdata.Length == 0) || (cdata.Data == NULL)) { + return 0; + } + uint32 len = cdata.Length; + if(len > sizeof(uint32)) { + CssmError::throwMe(toThrow); + } + + uint32 rtn = 0; + uint8 *cp = cdata.Data; + for(uint32 i=0; i>= 8; + } +} + +#pragma mark ----- CSSM_BOOL <--> CSSM_DATA ----- +/* + * A Bool is encoded as one byte of either 0 or 0xff + * Default of NSS boolean not present is false + */ +CSSM_BOOL clNssBoolToCssm( + const CSSM_DATA &nssBool) +{ + if((nssBool.Data != NULL) && (nssBool.Data[0] == 0xff)) { + return CSSM_TRUE; + } + else { + return CSSM_FALSE; + } +} + +void clCssmBoolToNss( + CSSM_BOOL cBool, + CSSM_DATA &nssBool, + CssmAllocator &alloc) +{ + uint32 num = cBool ? 0xff : 0; + clIntToData(num, nssBool, alloc); +} + +#pragma mark ----- Bit String manipulation ----- + +/* + * Adjust the length of a CSSM_DATA representing a pre-encoded + * bit string. On entry the length field is the number of bytes + * of data; en exit, the number if bits. Trailing zero bits + * are counted as unused (which is how KeyUsage and NetscapeCertType + * extensions are encoded). + */ +void clCssmBitStringToNss( + CSSM_DATA &b) +{ + int numBits = b.Length * 8; + + /* start at end of bit array, scanning backwards looking + * for the first set bit */ + bool foundSet = false; + for(int dex=b.Length-1; dex>=0; dex--) { + unsigned bitMask = 0x01; + uint8 byte = b.Data[dex]; + for(unsigned bdex=0; bdex<8; bdex++) { + if(byte & bitMask) { + foundSet = true; + break; + } + else { + bitMask <<= 1; + numBits--; + } + } + if(foundSet) { + break; + } + } + /* !foundSet --> numBits = 0 */ + assert(((numBits > 0) & foundSet) || ((numBits == 0) && !foundSet)); + b.Length = (uint32)numBits; +} + +/* + * On entry, Length is bit count; on exit, a byte count. + * The job here is to ensure that bits marked as "unused" in the + * BER encoding are cleared. Encoding rules say they are undefined in + * the actual encoding. + */ +void clNssBitStringToCssm( + CSSM_DATA &b) +{ + uint32 byteCount = (b.Length + 7) / 8; + unsigned partialBits = b.Length & 0x7; + b.Length = byteCount; + if(partialBits == 0) { + return; + } + + /* mask off unused bits */ + unsigned unusedBits = 8 - partialBits; + uint8 *bp = b.Data + b.Length - 1; + /* mask = (2 ** unusedBits) - 1 */ + unsigned mask = (1 << unusedBits) - 1; + *bp &= ~mask; +} + +#pragma mark ----- NSS array manipulation ----- +/* + * How many items in a NULL-terminated array of pointers? + */ +unsigned clNssArraySize( + const void **array) +{ + unsigned count = 0; + if (array) { + while (*array++) { + count++; + } + } + return count; +} + +/* malloc a NULL-ed array of pointers of size num+1 */ +void **clNssNullArray( + uint32 num, + SecNssCoder &coder) +{ + unsigned len = (num + 1) * sizeof(void *); + void **p = (void **)coder.malloc(len); + memset(p, 0, len); + return p; +} + +/* + * GIven a CSSM_DATA containing a decoded BIT_STRING, + * convert to a KeyUsage. + */ +CE_KeyUsage clBitStringToKeyUsage( + const CSSM_DATA &cdata) +{ + unsigned toCopy = (cdata.Length + 7) / 8; + if(toCopy > 2) { + /* I hope I never see this... */ + clErrorLog("clBitStringToKeyUsage: KeyUsage larger than 2 bytes!"); + toCopy = 2; + } + unsigned char bits[2] = {0, 0}; + memmove(bits, cdata.Data, toCopy); + CE_KeyUsage usage = (((unsigned)bits[0]) << 8) | bits[1]; + return usage; +} + +CSSM_ALGORITHMS CL_oidToAlg( + const CSSM_OID &oid) +{ + CSSM_ALGORITHMS alg; + bool found = cssmOidToAlg(&oid, &alg); + if(!found) { + clErrorLog("CL_oidToAlg: unknown alg\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + return alg; +} + +#pragma mark ----- copy CSSM_X509_ALGORITHM_IDENTIFIER ----- + +/* + * Copy CSSM_X509_ALGORITHM_IDENTIFIER, same format (NSS and CSSM). + */ +void CL_copyAlgId( + const CSSM_X509_ALGORITHM_IDENTIFIER &srcAlgId, + CSSM_X509_ALGORITHM_IDENTIFIER &dstAlgId, + CssmAllocator &alloc) +{ + clAllocCopyData(alloc, srcAlgId.algorithm, dstAlgId.algorithm); + clAllocCopyData(alloc, srcAlgId.parameters, dstAlgId.parameters); +} + +void CL_freeCssmAlgId( + CSSM_X509_ALGORITHM_IDENTIFIER *cdsaObj, // optional + CssmAllocator &alloc) +{ + if(cdsaObj == NULL) { + return; + } + alloc.free(cdsaObj->algorithm.Data); + alloc.free(cdsaObj->parameters.Data); + memset(cdsaObj, 0, sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)); +} + + +#pragma mark ----- CSSM_X509_TIME <--> NSS format ----- + +/* + * Map the tag associated with a choice of DirectoryString elements to + * a template array for encoding/decoding that string type. + * Contrary to RFC2459, we allow the IA5String type, which is actually + * used in the real world (cf. the email address in Thawte's serverbasic + * cert). + */ + +/* The template chooser does the work here */ + +bool CL_nssTimeToCssm( + const NSS_TaggedItem &nssTime, + CSSM_X509_TIME &cssmObj, + CssmAllocator &alloc) +{ + cssmObj.timeType = nssTime.tag; + clAllocCopyData(alloc, nssTime.item, cssmObj.time); + return true; +} + +/* + * CSSM time to NSS time. + */ +void CL_cssmTimeToNss( + const CSSM_X509_TIME &cssmTime, + NSS_TaggedItem &nssTime, + SecNssCoder &coder) +{ + nssTime.tag = cssmTime.timeType; + coder.allocCopyItem(cssmTime.time, nssTime.item); +} + +void CL_freeCssmTime( + CSSM_X509_TIME *cssmTime, + CssmAllocator &alloc) +{ + if(cssmTime == NULL) { + return; + } + if(cssmTime->time.Data) { + alloc.free(cssmTime->time.Data); + } + memset(cssmTime, 0, sizeof(CSSM_X509_TIME)); +} + + +#pragma mark ----- CSSM_X509_SUBJECT_PUBLIC_KEY_INFO <--> CSSM_KEY ----- + +/* + * Copy a CSSM_X509_SUBJECT_PUBLIC_KEY_INFO. + * + * Same format (NSS and CSSM), EXCEPT: + * + * Objects which have just been NSS decoded or are about to be + * NSS encoded have the subjectPublicKey.Length field in BITS + * since this field is wrapped in a BIT STRING upon encoding. + * + * Caller tells us which format (bits or bytes) + * to use for each of {src, dst}. + */ +void CL_copySubjPubKeyInfo( + const CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &srcInfo, + bool srcInBits, + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &dstInfo, + bool dstInBits, + CssmAllocator &alloc) +{ + CL_copyAlgId(srcInfo.algorithm, dstInfo.algorithm, alloc); + + CSSM_DATA srcKey = srcInfo.subjectPublicKey; + if(srcInBits) { + srcKey.Length = (srcKey.Length + 7) / 8; + } + clAllocCopyData(alloc, srcKey, dstInfo.subjectPublicKey); + if(dstInBits) { + dstInfo.subjectPublicKey.Length *= 8; + } +} + +/* + * Obtain a CSSM_KEY from a CSSM_X509_SUBJECT_PUBLIC_KEY_INFO, + * inferring as much as we can from required fields + * (CSSM_X509_SUBJECT_PUBLIC_KEY_INFO) and extensions (for + * KeyUse, obtained from the optional DecodedCert). + */ +CSSM_KEY_PTR CL_extractCSSMKeyNSS( + const CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &keyInfo, + CssmAllocator &alloc, + const DecodedCert *decodedCert) // optional +{ + CSSM_KEY_PTR cssmKey = (CSSM_KEY_PTR) alloc.malloc(sizeof(CSSM_KEY)); + memset(cssmKey, 0, sizeof(CSSM_KEY)); + CSSM_KEYHEADER &hdr = cssmKey->KeyHeader; + CssmRemoteData keyData(alloc, cssmKey->KeyData); + try { + hdr.HeaderVersion = CSSM_KEYHEADER_VERSION; + /* CspId blank */ + hdr.BlobType = CSSM_KEYBLOB_RAW; + hdr.AlgorithmId = CL_oidToAlg(keyInfo.algorithm.algorithm); + hdr.KeyAttr = CSSM_KEYATTR_MODIFIABLE | CSSM_KEYATTR_EXTRACTABLE; + + /* + * Format inferred from AlgorithmId. I have never seen these defined + * anywhere, e.g., what's the format of an RSA public key in a cert? + * X509 certainly doesn't say. However. the following two cases are + * known to be correct. + */ + switch(hdr.AlgorithmId) { + case CSSM_ALGID_RSA: + hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_PKCS1; + break; + case CSSM_ALGID_DSA: + case CSSM_ALGID_DH: + hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_X509; + break; + case CSSM_ALGID_FEE: + /* CSSM_KEYBLOB_RAW_FORMAT_NONE --> DER encoded */ + hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_NONE; + break; + default: + /* punt */ + hdr.Format = CSSM_KEYBLOB_RAW_FORMAT_NONE; + } + hdr.KeyClass = CSSM_KEYCLASS_PUBLIC_KEY; + + /* KeyUsage inferred from extensions */ + if(decodedCert) { + hdr.KeyUsage = decodedCert->inferKeyUsage(); + } + else { + hdr.KeyUsage = CSSM_KEYUSE_ANY; + } + + /* start/end date unknown, leave zero */ + hdr.WrapAlgorithmId = CSSM_ALGID_NONE; + hdr.WrapMode = CSSM_ALGMODE_NONE; + + switch(hdr.AlgorithmId) { + case CSSM_ALGID_DSA: + case CSSM_ALGID_DH: + { + /* + * Just encode the whole subject public key info blob. + * NOTE we're assuming that the keyInfo.subjectPublicKey + * field is in the NSS_native BITSTRING format, i.e., + * its Length field is in bits and we don't have to adjust. + */ + PRErrorCode prtn = SecNssEncodeItemOdata(&keyInfo, + NSS_SubjectPublicKeyInfoTemplate, keyData); + if(prtn) { + clErrorLog("extractCSSMKey: error on reencode\n"); + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } + break; + } + default: + /* + * RSA, FEE for now. + * keyInfo.subjectPublicKey (in BITS) ==> KeyData + */ + keyData.copy(keyInfo.subjectPublicKey.Data, + (keyInfo.subjectPublicKey.Length + 7) / 8); + } + keyData.release(); + + /* + * LogicalKeySizeInBits - ask the CSP + */ + CSSM_CSP_HANDLE cspHand = getGlobalCspHand(true); + CSSM_KEY_SIZE keySize; + CSSM_RETURN crtn; + crtn = CSSM_QueryKeySizeInBits(cspHand, CSSM_INVALID_HANDLE, cssmKey, + &keySize); + switch(crtn) { + default: + CssmError::throwMe(crtn); + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: + /* + * This is how the CSP indicates a "partial" public key, + * with a valid public key value but no alg-specific + * parameters (currently, DSA only). + */ + hdr.KeyAttr |= CSSM_KEYATTR_PARTIAL; + /* and drop thru */ + case CSSM_OK: + cssmKey->KeyHeader.LogicalKeySizeInBits = + keySize.LogicalKeySizeInBits; + break; + } + } + catch (...) { + alloc.free(cssmKey); + throw; + } + return cssmKey; +} + +/* + * Set up a encoded NULL for CSSM_X509_ALGORITHM_IDENTIFIER.parameters. + */ +void CL_nullAlgParams( + CSSM_X509_ALGORITHM_IDENTIFIER &algId) +{ + static const uint8 encNull[2] = { SEC_ASN1_NULL, 0 }; + CSSM_DATA encNullData; + encNullData.Data = (uint8 *)encNull; + encNullData.Length = 2; + + algId.parameters = encNullData; +} + +/* + * Convert a CSSM_KEY to a CSSM_X509_SUBJECT_PUBLIC_KEY_INFO. The + * CSSM key must be in raw format and with a specific blob format. + * -- RSA keys have to be CSSM_KEYBLOB_RAW_FORMAT_PKCS1 + * -- DSA keys have to be CSSM_KEYBLOB_RAW_FORMAT_X509 + */ +void CL_CSSMKeyToSubjPubKeyInfoNSS( + const CSSM_KEY &cssmKey, + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &nssKeyInfo, + SecNssCoder &coder) +{ + const CSSM_KEYHEADER &hdr = cssmKey.KeyHeader; + if(hdr.BlobType != CSSM_KEYBLOB_RAW) { + clErrorLog("CL SetField: must specify RAW key blob\n"); + CssmError::throwMe(CSSMERR_CSP_KEY_BLOB_TYPE_INCORRECT); + } + memset(&nssKeyInfo, 0, sizeof(nssKeyInfo)); + + /* algorithm and format dependent from here... */ + switch(hdr.AlgorithmId) { + case CSSM_ALGID_RSA: + if(hdr.Format != CSSM_KEYBLOB_RAW_FORMAT_PKCS1) { + clErrorLog("CL SetField: RSA key must be in PKCS1 format\n"); + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_FORMAT); + } + /* and fall thru */ + default: + { + /* Key header's algorithm --> OID */ + const CSSM_OID *oid = cssmAlgToOid(hdr.AlgorithmId); + if(oid == NULL) { + clErrorLog("CL SetField: Unknown key algorithm\n"); + CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); + } + CSSM_X509_ALGORITHM_IDENTIFIER &algId = nssKeyInfo.algorithm; + coder.allocCopyItem(*oid, algId.algorithm); + + /* NULL algorithm parameters, always in this case */ + CL_nullAlgParams(algId); + + /* Copy key bits, destination is a BIT STRING */ + coder.allocCopyItem(cssmKey.KeyData, nssKeyInfo.subjectPublicKey); + nssKeyInfo.subjectPublicKey.Length *= 8; + break; + } + case CSSM_ALGID_DSA: + if(hdr.Format != CSSM_KEYBLOB_RAW_FORMAT_X509) { + clErrorLog("CL SetField: DSA key must be in X509 format\n"); + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_FORMAT); + } + + /* + * All we do is decode the whole key blob into the + * SubjectPublicKeyInfo. + */ + if(coder.decodeItem(cssmKey.KeyData, + NSS_SubjectPublicKeyInfoTemplate, + &nssKeyInfo)) { + clErrorLog("CL SetField: Error decoding DSA public key\n"); + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_FORMAT); + } + break; + } +} + +void CL_freeCSSMKey( + CSSM_KEY_PTR cssmKey, + CssmAllocator &alloc, + bool freeTop) +{ + if(cssmKey == NULL) { + return; + } + alloc.free(cssmKey->KeyData.Data); + memset(cssmKey, 0, sizeof(CSSM_KEY)); + if(freeTop) { + alloc.free(cssmKey); + } +} + +#pragma mark ----- CE_AuthorityKeyID <--> NSS_AuthorityKeyId ----- + +void CL_cssmAuthorityKeyIdToNss( + const CE_AuthorityKeyID &cdsaObj, + NSS_AuthorityKeyId &nssObj, + SecNssCoder &coder) +{ + memset(&nssObj, 0, sizeof(nssObj)); + if(cdsaObj.keyIdentifierPresent) { + nssObj.keyIdentifier = (CSSM_DATA_PTR)coder.malloc(sizeof(CSSM_DATA)); + coder.allocCopyItem(cdsaObj.keyIdentifier, *nssObj.keyIdentifier); + } + if(cdsaObj.generalNamesPresent ) { + /* GeneralNames, the hard one */ + CL_cssmGeneralNamesToNss(*cdsaObj.generalNames, + nssObj.genNames, coder); + } + if(cdsaObj.serialNumberPresent) { + coder.allocCopyItem(cdsaObj.serialNumber,nssObj.serialNumber); + } +} + +void CL_nssAuthorityKeyIdToCssm( + const NSS_AuthorityKeyId &nssObj, + CE_AuthorityKeyID &cdsaObj, + SecNssCoder &coder, // for temp decoding + CssmAllocator &alloc) +{ + if(nssObj.keyIdentifier != NULL) { + cdsaObj.keyIdentifierPresent = CSSM_TRUE; + clAllocCopyData(alloc, *nssObj.keyIdentifier, cdsaObj.keyIdentifier); + } + if(nssObj.genNames.names != NULL) { + /* GeneralNames, the hard one */ + cdsaObj.generalNamesPresent = CSSM_TRUE; + cdsaObj.generalNames = + (CE_GeneralNames *)alloc.malloc(sizeof(CE_GeneralNames)); + CL_nssGeneralNamesToCssm(nssObj.genNames, + *cdsaObj.generalNames, + coder, + alloc); + } + if(nssObj.serialNumber.Data != NULL) { + cdsaObj.serialNumberPresent = CSSM_TRUE; + clAllocCopyData(alloc, nssObj.serialNumber, cdsaObj.serialNumber); + } +} + +#pragma mark ----- decode/encode CE_DistributionPointName ----- + +/* This is always a DER-encoded blob at the NSS level */ +void CL_decodeDistributionPointName( + const CSSM_DATA &nssBlob, + CE_DistributionPointName &cssmDpn, + SecNssCoder &coder, + CssmAllocator &alloc) +{ + memset(&cssmDpn, 0, sizeof(CE_DistributionPointName)); + if(nssBlob.Length == 0) { + clErrorLog("***CL_decodeDistributionPointName: bad PointName\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + unsigned char tag = nssBlob.Data[0] & SEC_ASN1_TAGNUM_MASK; + switch(tag) { + case NSS_DIST_POINT_FULL_NAME_TAG: + { + /* decode to temp coder memory */ + NSS_GeneralNames gnames; + gnames.names = NULL; + if(coder.decodeItem(nssBlob, NSS_DistPointFullNameTemplate, + &gnames)) { + clErrorLog("***Error decoding DistPointFullName\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + + cssmDpn.nameType = CE_CDNT_FullName; + cssmDpn.fullName = (CE_GeneralNames *)alloc.malloc( + sizeof(CE_GeneralNames)); + + /* copy out to caller */ + CL_nssGeneralNamesToCssm(gnames, + *cssmDpn.fullName, coder, alloc); + break; + } + case NSS_DIST_POINT_RDN_TAG: + { + /* decode to temp coder memory */ + NSS_RDN rdn; + memset(&rdn, 0, sizeof(rdn)); + if(coder.decodeItem(nssBlob, NSS_DistPointRDNTemplate, + &rdn)) { + clErrorLog("***Error decoding DistPointRDN\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + + cssmDpn.nameType = CE_CDNT_NameRelativeToCrlIssuer; + cssmDpn.rdn = (CSSM_X509_RDN_PTR)alloc.malloc( + sizeof(CSSM_X509_RDN)); + + /* copy out to caller */ + CL_nssRdnToCssm(rdn, *cssmDpn.rdn, alloc, coder); + break; + } + default: + clErrorLog("***Bad CE_DistributionPointName tag\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } +} + +void CL_encodeDistributionPointName( + CE_DistributionPointName &cpoint, + CSSM_DATA &npoint, + SecNssCoder &coder) +{ + const SEC_ASN1Template *templ = NULL; + NSS_GeneralNames gnames; + NSS_RDN rdn; + void *encodeSrc = NULL; + + /* + * Our job is to convert one of two incoming aggregate types + * into NSS format, then encode the result into npoint. + */ + switch(cpoint.nameType) { + case CE_CDNT_FullName: + CL_cssmGeneralNamesToNss(*cpoint.fullName, + gnames, coder); + encodeSrc = &gnames; + templ = NSS_DistPointFullNameTemplate; + break; + + case CE_CDNT_NameRelativeToCrlIssuer: + CL_cssmRdnToNss(*cpoint.rdn, rdn, coder); + encodeSrc = &rdn; + templ = NSS_DistPointRDNTemplate; + break; + default: + clErrorLog("CL_encodeDistributionPointName: bad nameType\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_TAG); + } + if(coder.encodeItem(encodeSrc, templ, npoint)) { + clErrorLog("CL_encodeDistributionPointName: encode error\n"); + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } +} + + +#pragma mark --- CE_CRLDistPointsSyntax <--> NSS_CRLDistributionPoints --- + +void CL_cssmDistPointsToNss( + const CE_CRLDistPointsSyntax &cdsaObj, + NSS_CRLDistributionPoints &nssObj, + SecNssCoder &coder) +{ + memset(&nssObj, 0, sizeof(nssObj)); + unsigned numPoints = cdsaObj.numDistPoints; + if(numPoints == 0) { + return; + } + nssObj.distPoints = + (NSS_DistributionPoint **)clNssNullArray(numPoints, coder); + for(unsigned dex=0; dexdistPointName) { + /* encode and drop into ASN_ANY slot */ + npoint->distPointName = (CSSM_DATA *) + coder.malloc(sizeof(CSSM_DATA)); + CL_encodeDistributionPointName(*cpoint->distPointName, + *npoint->distPointName, coder); + + } + + if(cpoint->reasonsPresent) { + /* bit string, presumed max length 8 bits */ + coder.allocItem(npoint->reasons, 1); + npoint->reasons.Data[0] = cpoint->reasons; + /* adjust for bit string length */ + npoint->reasons.Length = 8; + } + + if(cpoint->crlIssuer) { + CL_cssmGeneralNamesToNss(*cpoint->crlIssuer, + npoint->crlIssuer, coder); + } + } +} + +void CL_nssDistPointsToCssm( + const NSS_CRLDistributionPoints &nssObj, + CE_CRLDistPointsSyntax &cdsaObj, + SecNssCoder &coder, // for temp decoding + CssmAllocator &alloc) +{ + memset(&cdsaObj, 0, sizeof(cdsaObj)); + unsigned numPoints = clNssArraySize((const void **)nssObj.distPoints); + if(numPoints == 0) { + return; + } + + unsigned len = sizeof(CE_CRLDistributionPoint) * numPoints; + cdsaObj.distPoints = (CE_CRLDistributionPoint *)alloc.malloc(len); + memset(cdsaObj.distPoints, 0, len); + cdsaObj.numDistPoints = numPoints; + + for(unsigned dex=0; dex 8) { + clErrorLog("***CL_nssDistPointsToCssm: Malformed reasons\n"); + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + cpoint.reasonsPresent = CSSM_TRUE; + if(npoint.reasons.Length != 0) { + cpoint.reasons = npoint.reasons.Data[0]; + } + } + + if(npoint.crlIssuer.names != NULL) { + /* Cook up a new CE_GeneralNames */ + cpoint.crlIssuer = + (CE_GeneralNames *)alloc.malloc(sizeof(CE_GeneralNames)); + CL_nssGeneralNamesToCssm(npoint.crlIssuer, *cpoint.crlIssuer, + coder, alloc); + } + } +} + +#pragma mark ----- IssuingDistributionPoint ----- + +void CL_nssIssuingDistPointToCssm( + NSS_IssuingDistributionPoint *nssIdp, + CE_IssuingDistributionPoint *cssmIdp, + SecNssCoder &coder, + CssmAllocator &alloc) +{ + /* All fields optional */ + memset(cssmIdp, 0, sizeof(*cssmIdp)); + if(nssIdp->distPointName) { + CE_DistributionPointName *cssmDp = (CE_DistributionPointName *) + alloc.malloc(sizeof(CE_DistributionPointName)); + + /* + * This one is currently still encoded; we have to peek + * at its tag and decode accordingly. + */ + CL_decodeDistributionPointName(*nssIdp->distPointName, + *cssmDp, coder, alloc); + cssmIdp->distPointName = cssmDp; + } + if(nssIdp->onlyUserCerts) { + cssmIdp->onlyUserCertsPresent = CSSM_TRUE; + cssmIdp->onlyUserCerts = clNssBoolToCssm(*nssIdp->onlyUserCerts); + } + if(nssIdp->onlyCACerts) { + cssmIdp->onlyCACertsPresent = CSSM_TRUE; + cssmIdp->onlyCACerts = clNssBoolToCssm(*nssIdp->onlyCACerts); + } + if(nssIdp->onlySomeReasons) { + cssmIdp->onlySomeReasonsPresent = CSSM_TRUE; + if(nssIdp->onlySomeReasons->Length > 0) { + cssmIdp->onlySomeReasons = *nssIdp->onlySomeReasons->Data; + } + else { + cssmIdp->onlySomeReasons = 0; + } + } + if(nssIdp->indirectCRL) { + cssmIdp->indirectCrlPresent = CSSM_TRUE; + cssmIdp->indirectCrl = clNssBoolToCssm(*nssIdp->indirectCRL); + } +} + +#pragma mark ----- Top-level Cert/CRL encode and decode ----- + +/* + * To ensure a secure means of signing and verifying TBSCert blobs, we + * provide these functions to encode and decode just the top-level + * elements of a certificate. Unfortunately there is no guarantee + * that when you decode and re-encode a TBSCert blob, you get the + * same thing you started with (although with DER rules, as opposed + * to BER rules, you should). Thus when signing, we sign the TBSCert + * and encode the signed cert here without ever decoding the TBSCert (or, + * at least, without using the decoded version to get the encoded TBS blob). + */ + +void CL_certCrlDecodeComponents( + const CssmData &signedItem, // DER-encoded cert or CRL + CssmOwnedData &tbsBlob, // still DER-encoded + CssmOwnedData &algId, // ditto + CssmOwnedData &rawSig) // raw bits (not an encoded AsnBits) +{ + /* BER-decode into temp memory */ + NSS_SignedCertOrCRL nssObj; + SecNssCoder coder; + PRErrorCode prtn; + + memset(&nssObj, 0, sizeof(nssObj)); + prtn = coder.decode(signedItem.data(), signedItem.length(), + NSS_SignedCertOrCRLTemplate, &nssObj); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); + } + + /* tbsBlob and algId are raw ASN_ANY including tags, which we pass + * back to caller intact */ + tbsBlob.copy(nssObj.tbsBlob.Data, nssObj.tbsBlob.Length); + algId.copy(nssObj.signatureAlgorithm.Data, + nssObj.signatureAlgorithm.Length); + + /* signature is a bit string which we do in fact decode */ + rawSig.copy(nssObj.signature.Data, + (nssObj.signature.Length + 7) / 8); +} + + +/* + * Given pre-DER-encoded blobs, do the final encode step for a signed cert. + */ +void +CL_certEncodeComponents( + const CssmData &TBSCert, // DER-encoded + const CssmData &algId, // ditto + const CssmData &rawSig, // raw bits, not encoded + CssmOwnedData &signedCert) // DER-encoded +{ + NSS_SignedCertOrCRL nssObj; + nssObj.tbsBlob.Data = TBSCert.Data; + nssObj.tbsBlob.Length = TBSCert.Length; + nssObj.signatureAlgorithm.Data = algId.Data; + nssObj.signatureAlgorithm.Length = algId.Length; + nssObj.signature.Data = rawSig.Data; + nssObj.signature.Length = rawSig.Length * 8; // BIT STRING + + PRErrorCode prtn; + + prtn = SecNssEncodeItemOdata(&nssObj, + NSS_SignedCertOrCRLTemplate,signedCert); + if(prtn) { + CssmError::throwMe(CSSMERR_CL_MEMORY_ERROR); + } + +} diff --git a/AppleX509CL/clNssUtils.h b/AppleX509CL/clNssUtils.h new file mode 100644 index 00000000..f6939637 --- /dev/null +++ b/AppleX509CL/clNssUtils.h @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/* + * clNssUtils.h - support for libnssasn1-based ASN1 encode/decode + */ + +#ifndef _CL_NSS_UTILS_H_ +#define _CL_NSS_UTILS_H_ + +#include +#include +#include +#include "DecodedCert.h" + +/* + * A CssmAllocator which is actually based upon a PLArenaPool. This only + * mallocs, it doesn't have a free - all memory allocated with this + * object is freed when the SecNssCoder associated with this object is + * freed. It's used to malloc the fields in DecodedCert.mCert and + * DecodedCrl.mCrl. + */ +class ArenaAllocator : public Security::CssmAllocator +{ + NOCOPY(ArenaAllocator) +public: + ArenaAllocator(SecNssCoder &coder) + : mCoder(coder) { } + ~ArenaAllocator() { } + void *malloc(size_t) throw(std::bad_alloc) ; + void free(void *) throw() ; + void *realloc(void *, size_t) throw(std::bad_alloc); +private: + SecNssCoder &mCoder; +}; + +/* + * Misc. alloc/copy with arbitrary CssmAllocator + */ + +/* malloc d.Data, set d.Length */ +void clAllocData( + CssmAllocator &alloc, + CSSM_DATA &dst, + size_t len); + +/* malloc and copy */ +void clAllocCopyData( + CssmAllocator &alloc, + const CSSM_DATA &src, + CSSM_DATA &dst); + +/* return true if two CSSM_DATAs (or two CSSM_OIDs) compare equal */ +bool clCompareCssmData( + const CSSM_DATA *data1, + const CSSM_DATA *data2); + +/* + * CSSM_DATA --> uint32 + */ +uint32 clDataToInt( + const CSSM_DATA &cdata, + CSSM_RETURN toThrow = CSSMERR_CL_INVALID_CERT_POINTER); +void clIntToData( + uint32 num, + CSSM_DATA &cdata, + CssmAllocator &alloc); + +/* CSSM_BOOL <--> CSSM_DATA */ +CSSM_BOOL clNssBoolToCssm( + const CSSM_DATA &nssBool); +void clCssmBoolToNss( + CSSM_BOOL cBool, + CSSM_DATA &nssBool, + CssmAllocator &alloc); + +/* Bit String */ +void clCssmBitStringToNss( + CSSM_DATA &b); +void clNssBitStringToCssm( + CSSM_DATA &b); + +/* How many items in a NULL-terminated array of pointers? */ +unsigned clNssArraySize( + const void **array); + +/* malloc a NULL-ed array of pointers of size num+1 */ +void **clNssNullArray( + uint32 num, + SecNssCoder &coder); + +CE_KeyUsage clBitStringToKeyUsage( + const CSSM_DATA &cdata); + +CSSM_ALGORITHMS CL_oidToAlg( + const CSSM_OID &oid); + +void CL_copyAlgId( + const CSSM_X509_ALGORITHM_IDENTIFIER &srcAlgId, + CSSM_X509_ALGORITHM_IDENTIFIER &destAlgId, + CssmAllocator &alloc); +void CL_freeCssmAlgId( + CSSM_X509_ALGORITHM_IDENTIFIER *cdsaObj, // optional + CssmAllocator &alloc); + + +bool CL_nssTimeToCssm( + const NSS_Time &derTime, + CSSM_X509_TIME &cssmObj, + CssmAllocator &alloc); +void CL_cssmTimeToNss( + const CSSM_X509_TIME &cssmTime, + NSS_Time &nssTime, + SecNssCoder &coder); +void CL_freeCssmTime( + CSSM_X509_TIME *cssmTime, + CssmAllocator &alloc); + +void CL_nullAlgParams( + CSSM_X509_ALGORITHM_IDENTIFIER &algId); + +void CL_copySubjPubKeyInfo( + const CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &srcInfo, + bool srcInBits, + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &dstInfo, + bool dstInBits, + CssmAllocator &alloc); +CSSM_KEY_PTR CL_extractCSSMKeyNSS( + const CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &keyInfo, + CssmAllocator &alloc, + const DecodedCert *decodedCert); // optional +void CL_CSSMKeyToSubjPubKeyInfoNSS( + const CSSM_KEY &cssmKey, + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &nssKeyInfo, + SecNssCoder &coder); +void CL_freeCSSMKey( + CSSM_KEY_PTR cssmKey, + CssmAllocator &alloc, + bool freeTop = true); // delete the actual key + // as well as contents + +void CL_cssmAuthorityKeyIdToNss( + const CE_AuthorityKeyID &cdsaObj, + NSS_AuthorityKeyId &nssObj, + SecNssCoder &coder); +void CL_nssAuthorityKeyIdToCssm( + const NSS_AuthorityKeyId &nssObj, + CE_AuthorityKeyID &cdsaObj, + SecNssCoder &coder, // for temp decoding + CssmAllocator &alloc); + +void CL_decodeDistributionPointName( + const CSSM_DATA &nssBlob, + CE_DistributionPointName &cssmDpn, + SecNssCoder &coder, + CssmAllocator &alloc); +void CL_encodeDistributionPointName( + CE_DistributionPointName &cpoint, + CSSM_DATA &npoint, + SecNssCoder &coder); +void CL_cssmDistPointsToNss( + const CE_CRLDistPointsSyntax &cdsaObj, + NSS_CRLDistributionPoints &nssObj, + SecNssCoder &coder); +void CL_nssDistPointsToCssm( + const NSS_CRLDistributionPoints &nssObj, + CE_CRLDistPointsSyntax &cdsaObj, + SecNssCoder &coder, // for temp decoding + CssmAllocator &alloc); + +void CL_nssIssuingDistPointToCssm( + NSS_IssuingDistributionPoint *nssIdp, + CE_IssuingDistributionPoint *cssmIdp, + SecNssCoder &coder, + CssmAllocator &alloc); + +void CL_certCrlDecodeComponents( + const CssmData &signedItem, // DER-encoded cert or CRL + CssmOwnedData &tbsBlob, // still DER-encoded + CssmOwnedData &algId, // ditto + CssmOwnedData &rawSig); // raw bits (not an encoded AsnBits) +void +CL_certEncodeComponents( + const CssmData &TBSCert, // DER-encoded + const CssmData &algId, // ditto + const CssmData &rawSig, // raw bits, not encoded + CssmOwnedData &signedCert); // DER-encoded + +#endif /* _CL_NSS_UTILS_H_ */ diff --git a/AppleX509CL/cldebugging.c b/AppleX509CL/cldebugging.c deleted file mode 100644 index 2cf9653f..00000000 --- a/AppleX509CL/cldebugging.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - File: cldebugging.c - - Contains: Debugging support. - - Written by: Doug Mitchell - - Copyright: (c) 1998 by Apple Computer, Inc., all rights reserved. - - Change History (most recent first): - - 03/10/98 dpm Created. - -*/ - -#include "cldebugging.h" - -#if !LOG_VIA_PRINTF - -#include -#include -#include - -/* common log macros */ - -/* this one needs a writable string */ -static void logCom(unsigned char *str) { - c2pstr((char *)str); - DebugStr(str); -} - -/* remaining ones can take constant strings */ -void dblog0(char *str) { - Str255 outStr; - strcpy((char *)outStr, str); - logCom(outStr); -} - -void dblog1(char *str, void *arg1) { - Str255 outStr; - sprintf((char *)outStr, str, arg1); - logCom(outStr); -} - -void dblog2(char *str, void * arg1, void * arg2) { - Str255 outStr; - sprintf((char *)outStr, str, arg1, arg2); - logCom(outStr); -} - -void dblog3(char *str, void * arg1, void * arg2, void * arg3) { - Str255 outStr; - sprintf((char *)outStr, str, arg1, arg2, arg3); - logCom(outStr); -} - -void dblog4(char *str, void * arg1, void * arg2, void * arg3, void * arg4) { - Str255 outStr; - sprintf((char *)outStr, str, arg1, arg2, arg3, arg4); - logCom(outStr); -} - -#endif /* !LOG_VIA_PRINTF */ - -#if DEBUG_ENABLE -volatile void _panic(const char *str) -{ - printf(str); - exit(1); -} -#endif - -//int foobarSymbol; diff --git a/AppleX509CL/cldebugging.h b/AppleX509CL/cldebugging.h index 8ac7add8..553e1d63 100644 --- a/AppleX509CL/cldebugging.h +++ b/AppleX509CL/cldebugging.h @@ -20,138 +20,19 @@ File: cldebugging.h Contains: Debugging macros. - - Written by: Doug Mitchell - - Copyright: (c) 1998 by Apple Computer, Inc., all rights reserved. - - Change History (most recent first): - - 06/02/98 dpm Added DEBUG_THREAD_YIELD. - 03/10/98 dpm Created. - */ #ifndef _CLDEBUGGING_H_ #define _CLDEBUGGING_H_ +#include + #ifdef NDEBUG -#define DEBUG_ENABLE 0 -#define ERROR_LOG_ENABLE 0 +/* this actually compiles to nothing */ +#define clErrorLog(args...) secdebug("clError", ## args) #else -#define DEBUG_ENABLE 1 -#define ERROR_LOG_ENABLE 1 -#endif - -/* any other way? */ -#define LOG_VIA_PRINTF 1 - -#if DEBUG_ENABLE || ERROR_LOG_ENABLE - -#include -#include - -#if !LOG_VIA_PRINTF - -#error Hey, figure out a debug mechanism - -#include -#include -#include - -/* common log macros */ - -/* remaining ones can take constant strings */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern void dblog0(char *str); -extern void dblog1(char *str, void * arg1); -extern void dblog2(char *str, void * arg1, void * arg2); -extern void dblog3(char *str, void * arg1, void * arg2, void * arg3); -extern void dblog4(char *str, void * arg1, void * arg2, void * arg3, void * arg4); - -#ifdef __cplusplus -} -#endif - - -#else /* LOG_VIA_PRINTF */ - -#define dblog0(str) printf(str) -#define dblog1(str, arg1) printf(str, arg1) -#define dblog2(str, arg1, arg2) printf(str, arg1, arg2) -#define dblog3(str, arg1, arg2, arg3) printf(str, arg1, arg2, arg3) -#define dblog4(str, arg1, arg2, arg3, arg4) printf(str, arg1, arg2, arg3, arg4) - -#endif /* LOG_VIA_PRINTF */ - -#else /* log macros disabled */ - -#define dblog0(str) -#define dblog1(str, arg1) -#define dblog2(str, arg1, arg2) -#define dblog3(str, arg1, arg2, arg3) -#define dblog4(str, arg1, arg2, arg3, arg4) - -#endif /* DEBUG_ENABLE || ERROR_LOG_ENABLE */ - -#if DEBUG_ENABLE - -#define dprintf0(str) dblog0(str) -#define dprintf1(str, arg1) dblog1(str, arg1) -#define dprintf2(str, arg1, arg2) dblog2(str, arg1, arg2) -#define dprintf3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3) -#define dprintf4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4) - -#ifdef __cplusplus -extern "C" { -#endif - -extern volatile void _panic(const char *str); - -#ifdef __cplusplus -} +#define clErrorLog(args...) printf(args) #endif - -#define CASSERT(expression) \ - ((expression) ? (void)0 : \ - (dprintf1 ("Assertion failed: " #expression \ - ", file " __FILE__ ", line %d.\n", __LINE__), \ - _panic("Assertion Failure"))) - -#else /* DEBUG_ENABLE */ - -#define dprintf0(str) -#define dprintf1(str, arg1) -#define dprintf2(str, arg1, arg2) -#define dprintf3(str, arg1, arg2, arg3) -#define dprintf4(str, arg1, arg2, arg3, arg4) - -#define CASSERT(expression) - -#endif /* DEBUG_ENABLE */ - -/* - * Error logging. This may well be platform dependent. - */ -#if ERROR_LOG_ENABLE -#define errorLog0(str) dblog0(str) -#define errorLog1(str, arg1) dblog1(str, arg1) -#define errorLog2(str, arg1, arg2) dblog2(str, arg1, arg2) -#define errorLog3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3) -#define errorLog4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4) - -#else /* ERROR_LOG_ENABLE */ - -#define errorLog0(str) -#define errorLog1(str, arg1) -#define errorLog2(str, arg1, arg2) -#define errorLog3(str, arg1, arg2, arg3) -#define errorLog4(str, arg1, arg2, arg3, arg4) - -#endif /* ERROR_LOG_ENABLE */ +#define clFieldLog(args...) secdebug("clField", ## args) #endif /* _CLDEBUGGING_H_ */ diff --git a/AppleX509TP/AppleTPSession.cpp b/AppleX509TP/AppleTPSession.cpp index bd6764e2..5e409bb4 100644 --- a/AppleX509TP/AppleTPSession.cpp +++ b/AppleX509TP/AppleTPSession.cpp @@ -21,6 +21,10 @@ */ #include "AppleTPSession.h" +#include "TPCertInfo.h" +#include "TPCrlInfo.h" +#include "tpCrlVerify.h" +#include "tpdebugging.h" AppleTPSession::AppleTPSession( CSSM_MODULE_HANDLE theHandle, @@ -33,22 +37,10 @@ AppleTPSession::AppleTPSession( : TPPluginSession(theHandle, plug, version, subserviceId, subserviceType,attachFlags, upcalls) { - /* TBD session stuff here... - mCspHand = CSSM_INVALID_HANDLE; - mCspDlHand = CSSM_INVALID_HANDLE; - ...*/ } AppleTPSession::~AppleTPSession() { - /* TBD - if(mCspHand != CSSM_INVALID_HANDLE) { - CSSM_ModuleDetach(mCspHand); - } - if(mCspDlHand != CSSM_INVALID_HANDLE) { - CSSM_ModuleDetach(mCspDlHand); - } - */ } void AppleTPSession::CertCreateTemplate(CSSM_CL_HANDLE CLHandle, @@ -63,10 +55,100 @@ void AppleTPSession::CrlVerify(CSSM_CL_HANDLE CLHandle, CSSM_CSP_HANDLE CSPHandle, const CSSM_ENCODED_CRL &CrlToBeVerified, const CSSM_CERTGROUP &SignerCertGroup, - const CSSM_TP_VERIFY_CONTEXT &VerifyContext, - CSSM_TP_VERIFY_CONTEXT_RESULT &RevokerVerifyResult) + const CSSM_TP_VERIFY_CONTEXT *VerifyContext, + CSSM_TP_VERIFY_CONTEXT_RESULT *RevokerVerifyResult) { - CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED); + /* verify input args */ + if(RevokerVerifyResult != NULL) { + /* not yet, but probably someday */ + CssmError::throwMe(CSSMERR_TP_INVALID_REQUEST_INPUTS); + } + switch(CrlToBeVerified.CrlType) { + case CSSM_CRL_TYPE_X_509v1: + case CSSM_CRL_TYPE_X_509v2: + break; + default: + CssmError::throwMe(CSSMERR_TP_INVALID_CRL_TYPE); + } + switch(CrlToBeVerified.CrlEncoding) { + case CSSM_CRL_ENCODING_BER: + case CSSM_CRL_ENCODING_DER: + break; + default: + CssmError::throwMe(CSSMERR_TP_INVALID_CRL_ENCODING); + } + + /* optional arguments */ + CSSM_TIMESTRING cssmTimeStr = NULL; + const CSSM_TP_CALLERAUTH_CONTEXT *cred = NULL; + uint32 NumberOfAnchorCerts = 0; + CSSM_DATA_PTR AnchorCerts = NULL; + CSSM_DL_DB_LIST_PTR DBList = NULL; + CSSM_APPLE_TP_ACTION_FLAGS actionFlags = 0; + CSSM_APPLE_TP_ACTION_DATA *actionData = NULL; + + if(VerifyContext != NULL) { + cred = VerifyContext->Cred; + actionData = + (CSSM_APPLE_TP_ACTION_DATA *)VerifyContext->ActionData.Data; + if(actionData != NULL) { + switch(actionData->Version) { + case CSSM_APPLE_TP_ACTION_VERSION: + if(VerifyContext->ActionData.Length != + sizeof(CSSM_APPLE_TP_ACTION_DATA)) { + CssmError::throwMe(CSSMERR_TP_INVALID_ACTION_DATA); + } + break; + /* handle backwards versions here if we ever go + * beyond version 0 */ + default: + CssmError::throwMe(CSSMERR_TP_INVALID_ACTION_DATA); + } + actionFlags = actionData->ActionFlags; + } + } + if(cred != NULL) { + cssmTimeStr = cred->VerifyTime; + NumberOfAnchorCerts = cred->NumberOfAnchorCerts; + AnchorCerts = cred->AnchorCerts; + DBList = cred->DBList; + } + + /* this must be parseable, throw immediately if not */ + TPCrlInfo crlToVerify(CLHandle, CSPHandle, &CrlToBeVerified.CrlBlob, + TIC_NoCopy, cssmTimeStr); + + /* required at the API but in fact may be empty */ + TPCertGroup inCertGroup(SignerCertGroup, CLHandle, CSPHandle, *this, + cssmTimeStr, // optional 'this' time + false, // firstCertMustBeValid + TGO_Group); + + /* common CRL verify parameters */ + TPCrlVerifyContext vfyCtx(*this, + CLHandle, + CSPHandle, + cssmTimeStr, + NumberOfAnchorCerts, + AnchorCerts, + &inCertGroup, + NULL, // no CRLs, we're on our own + NULL, // gatheredCerts, none so far + DBList, + kCrlNone, // policy, varies per policy + actionFlags, + 0); // crlOptFlags, varies per policy + + /* + * We assert the doCrlVerify flag to ensure CRL verification + * if intermediate certs which verifyWithContext() gathers to + * verify this CRL. + */ + CSSM_RETURN crtn = crlToVerify.verifyWithContext(vfyCtx, NULL, true); + if(crtn) { + tpCrlDebug("CrlVerify failure"); + CssmError::throwMe(crtn); + } } void AppleTPSession::CertReclaimKey(const CSSM_CERTGROUP &CertGroup, @@ -84,8 +166,8 @@ void AppleTPSession::CertSign(CSSM_CL_HANDLE CLHandle, CSSM_CC_HANDLE CCHandle, const CssmData &CertTemplateToBeSigned, const CSSM_CERTGROUP &SignerCertGroup, - const CSSM_TP_VERIFY_CONTEXT &SignerVerifyContext, - CSSM_TP_VERIFY_CONTEXT_RESULT &SignerVerifyResult, + const CSSM_TP_VERIFY_CONTEXT *SignerVerifyContext, + CSSM_TP_VERIFY_CONTEXT_RESULT *SignerVerifyResult, CssmData &SignedCert) { CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED); @@ -171,8 +253,8 @@ void AppleTPSession::CrlSign(CSSM_CL_HANDLE CLHandle, CSSM_CC_HANDLE CCHandle, const CSSM_ENCODED_CRL &CrlToBeSigned, const CSSM_CERTGROUP &SignerCertGroup, - const CSSM_TP_VERIFY_CONTEXT &SignerVerifyContext, - CSSM_TP_VERIFY_CONTEXT_RESULT &SignerVerifyResult, + const CSSM_TP_VERIFY_CONTEXT *SignerVerifyContext, + CSSM_TP_VERIFY_CONTEXT_RESULT *SignerVerifyResult, CssmData &SignedCrl) { CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED); diff --git a/AppleX509TP/AppleTPSession.h b/AppleX509TP/AppleTPSession.h index aabb7012..72512783 100644 --- a/AppleX509TP/AppleTPSession.h +++ b/AppleX509TP/AppleTPSession.h @@ -66,8 +66,8 @@ public: CSSM_CSP_HANDLE CSPHandle, const CSSM_ENCODED_CRL &CrlToBeVerified, const CSSM_CERTGROUP &SignerCertGroup, - const CSSM_TP_VERIFY_CONTEXT &VerifyContext, - CSSM_TP_VERIFY_CONTEXT_RESULT &RevokerVerifyResult); + const CSSM_TP_VERIFY_CONTEXT *VerifyContext, + CSSM_TP_VERIFY_CONTEXT_RESULT *RevokerVerifyResult); void CertReclaimKey(const CSSM_CERTGROUP &CertGroup, uint32 CertIndex, CSSM_LONG_HANDLE KeyCacheHandle, @@ -88,8 +88,8 @@ public: CSSM_CC_HANDLE CCHandle, const CssmData &CertTemplateToBeSigned, const CSSM_CERTGROUP &SignerCertGroup, - const CSSM_TP_VERIFY_CONTEXT &SignerVerifyContext, - CSSM_TP_VERIFY_CONTEXT_RESULT &SignerVerifyResult, + const CSSM_TP_VERIFY_CONTEXT *SignerVerifyContext, + CSSM_TP_VERIFY_CONTEXT_RESULT *SignerVerifyResult, CssmData &SignedCert); void TupleGroupToCertGroup(CSSM_CL_HANDLE CLHandle, const CSSM_TUPLEGROUP &TupleGroup, @@ -141,8 +141,8 @@ public: CSSM_CC_HANDLE CCHandle, const CSSM_ENCODED_CRL &CrlToBeSigned, const CSSM_CERTGROUP &SignerCertGroup, - const CSSM_TP_VERIFY_CONTEXT &SignerVerifyContext, - CSSM_TP_VERIFY_CONTEXT_RESULT &SignerVerifyResult, + const CSSM_TP_VERIFY_CONTEXT *SignerVerifyContext, + CSSM_TP_VERIFY_CONTEXT_RESULT *SignerVerifyResult, CssmData &SignedCrl); void CertGroupPrune(CSSM_CL_HANDLE CLHandle, const CSSM_DL_DB_LIST &DBList, @@ -175,13 +175,27 @@ public: private: void CertGroupConstructPriv(CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - const CSSM_DL_DB_LIST &DBList, - const void *ConstructParams, - const CSSM_CERTGROUP &CertGroupFrag, - CSSM_BOOL ignoreExpired, - const char *cssmTimeStr, // May be NULL - TPCertGroup *&CertGroup); + CSSM_CSP_HANDLE cspHand, + TPCertGroup &inCertGroup, + const CSSM_DL_DB_LIST *DBList, // optional here + const char *cssmTimeStr, // optional + uint32 numAnchorCerts, // optional + const CSSM_DATA *anchorCerts, + + /* currently, only CSSM_TP_ACTION_FETCH_CERT_FROM_NET is + * interesting */ + CSSM_APPLE_TP_ACTION_FLAGS actionFlags, + /* + * Certs to be freed by caller (i.e., TPCertInfo which we allocate + * as a result of using a cert from anchorCerts of dbList) are added + * to this group. + */ + TPCertGroup &certsToBeFreed, + + /* returned */ + CSSM_BOOL &verifiedToRoot, // end of chain self-verifies + CSSM_BOOL &verifiedToAnchor, // end of chain in anchors + TPCertGroup &outCertGroup); // RETURNED /* in tpCredRequest.cp */ CSSM_X509_NAME * buildX509Name(const CSSM_APPLE_TP_NAME_OID *nameArray, @@ -213,7 +227,6 @@ private: void SubmitCsrRequest( const CSSM_TP_REQUEST_SET &RequestInput, - const CSSM_TP_CALLERAUTH_CONTEXT *CallerAuthContext, sint32 &EstimatedTime, CssmData &ReferenceIdentifier); diff --git a/AppleX509TP/CVSVersionInfo.txt b/AppleX509TP/CVSVersionInfo.txt index 4331425e..5d71b6ed 100644 --- a/AppleX509TP/CVSVersionInfo.txt +++ b/AppleX509TP/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:53 mb Exp $ -# $Name: Security-54~1~9 $ +# $Name: $ ProjectName: AppleX509TP ProjectVersion: 3 diff --git a/AppleX509TP/TPCertInfo.cpp b/AppleX509TP/TPCertInfo.cpp index c282ac21..75fcd77c 100644 --- a/AppleX509TP/TPCertInfo.cpp +++ b/AppleX509TP/TPCertInfo.cpp @@ -26,109 +26,124 @@ #include "tpdebugging.h" #include "tpTime.h" #include "certGroupUtils.h" +#include "TPDatabase.h" +#include "TPNetwork.h" #include #include #include #include #include /* for memcmp */ -#include /* for Mutex */ +#include /* for Mutex */ #include #include #include -#define tpTimeDbg(args...) debug("tpTime", ## args) +#define tpTimeDbg(args...) secdebug("tpTime", ## args) +#define tpCertInfoDbg(args...) secdebug("tpCert", ## args) -/* - * No default constructor - this is the only way. - * This caches the cert and fetches subjectName and issuerName - * to ensure the incoming certData is well-constructed. - */ -TPCertInfo::TPCertInfo( - const CSSM_DATA *certData, - CSSM_CL_HANDLE clHand, - const char *cssmTimeStr, // = NULL - bool copyCertData) : // true: we copy, we free - // false - caller owns - mClHand(clHand), - mCacheHand(CSSM_INVALID_HANDLE), - mSubjectName(NULL), - mIssuerName(NULL), - mIndex(0), - mIsAnchor(false), - mIsFromDb(false), - mNumStatusCodes(0), - mStatusCodes(NULL), - mUniqueRecord(NULL) +static const TPClItemCalls tpCertClCalls = { - CSSM_RETURN crtn; + CSSM_CL_CertGetFirstCachedFieldValue, + CSSM_CL_CertAbortQuery, + CSSM_CL_CertCache, + CSSM_CL_CertAbortCache, + CSSM_CL_CertVerify, + &CSSMOID_X509V1ValidityNotBefore, + &CSSMOID_X509V1ValidityNotAfter, + CSSMERR_TP_INVALID_CERT_POINTER, + CSSMERR_TP_CERT_EXPIRED, + CSSMERR_TP_CERT_NOT_VALID_YET +}; - mDlDbHandle.DBHandle = 0; - mDlDbHandle.DLHandle = 0; - - if(copyCertData) { - mCertData = tpMallocCopyCssmData(CssmAllocator::standard(), certData); - } - else { - mCertData = const_cast(certData); - } - mWeOwnTheData = copyCertData; - - /* cache the cert */ - mClHand = clHand; - crtn = CSSM_CL_CertCache(clHand, mCertData, &mCacheHand); - if(crtn) { - /* bad cert */ - CssmError::throwMe(crtn); - } +TPClItemInfo::TPClItemInfo( + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const TPClItemCalls &clCalls, + const CSSM_DATA *itemData, + TPItemCopy copyItemData, + const char *verifyTime) // may be NULL + : + mClHand(clHand), + mCspHand(cspHand), + mClCalls(clCalls), + mWeOwnTheData(false), + mCacheHand(0), + mIssuerName(NULL), + mItemData(NULL), + mSigAlg(CSSM_ALGID_NONE), + mIsExpired(false), + mIsNotValidYet(false), + mIndex(0) +{ + try { + cacheItem(itemData, copyItemData); + /* + * Fetch standard fields... + * Issue name assumes same OID for Certs and CRLs! + */ + CSSM_RETURN crtn = fetchField(&CSSMOID_X509V1IssuerName, &mIssuerName); + if(crtn) { + CssmError::throwMe(crtn); + } + + /* + * Signing algorithm, infer from TBS algId + * Note this assumesÊthat the OID for fetching this field is the + * same for CRLs and Certs. + */ + CSSM_DATA_PTR algField; + crtn = fetchField(&CSSMOID_X509V1SignatureAlgorithmTBS, &algField); + if(crtn) { + releaseResources(); + CssmError::throwMe(crtn); + } + if(algField->Length != sizeof(CSSM_X509_ALGORITHM_IDENTIFIER)) { + tpErrorLog("TPClItemInfo: bad CSSM_X509_ALGORITHM_IDENTIFIER\n"); + CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); + } + CSSM_X509_ALGORITHM_IDENTIFIER *algId = + (CSSM_X509_ALGORITHM_IDENTIFIER *)algField->Data; + bool algFound = cssmOidToAlg(&algId->algorithm, &mSigAlg); + if(!algFound) { + tpErrorLog("TPClItemInfo: unknown signature algorithm\n"); + CssmError::throwMe(CSSMERR_TP_UNKNOWN_FORMAT); + } + freeField(&CSSMOID_X509V1SignatureAlgorithmTBS, algField); - /* fetch subject name */ - crtn = fetchField(&CSSMOID_X509V1SubjectName, &mSubjectName); - if(crtn) { - /* bad cert */ - releaseResources(); - CssmError::throwMe(crtn); + fetchNotBeforeAfter(); + calculateCurrent(verifyTime); } - - /* fetch issuer name */ - crtn = fetchField(&CSSMOID_X509V1IssuerName, &mIssuerName); - if(crtn) { - /* bad cert */ + catch(...) { releaseResources(); - CssmError::throwMe(crtn); + throw; } - - /* calculate other commonly used fields */ - mIsRoot = tpCompareCssmData(mSubjectName, mIssuerName) ? true : false; - calculateCurrent(cssmTimeStr); } - -/* frees mSubjectName, mIssuerName, mCacheHand via mClHand */ -TPCertInfo::~TPCertInfo() + +TPClItemInfo::~TPClItemInfo() { + tpCertInfoDbg("TPClItemInfo destruct this %p", this); releaseResources(); } -void TPCertInfo::releaseResources() +void TPClItemInfo::releaseResources() { - if(mWeOwnTheData && (mCertData != NULL)) { - tpFreeCssmData(CssmAllocator::standard(), mCertData, CSSM_TRUE); - } - if(mSubjectName) { - freeField(&CSSMOID_X509V1SubjectName, mSubjectName); + if(mWeOwnTheData && (mItemData != NULL)) { + tpFreeCssmData(CssmAllocator::standard(), mItemData, CSSM_TRUE); + mWeOwnTheData = false; + mItemData = NULL; } if(mIssuerName) { freeField(&CSSMOID_X509V1IssuerName, mIssuerName); + mIssuerName = NULL; } - if(mCacheHand != CSSM_INVALID_HANDLE) { - CSSM_CL_CertAbortCache(mClHand, mCacheHand); - } - if(mStatusCodes) { - free(mStatusCodes); + if(mCacheHand != 0) { + mClCalls.abortCache(mClHand, mCacheHand); + mCacheHand = 0; } } /* fetch arbitrary field from cached cert */ -CSSM_RETURN TPCertInfo::fetchField( +CSSM_RETURN TPClItemInfo::fetchField( const CSSM_OID *fieldOid, CSSM_DATA_PTR *fieldData) // mallocd by CL and RETURNED { @@ -138,7 +153,9 @@ CSSM_RETURN TPCertInfo::fetchField( CSSM_HANDLE resultHand = 0; *fieldData = NULL; - crtn = CSSM_CL_CertGetFirstCachedFieldValue( + assert(mClCalls.getField != NULL); + assert(mCacheHand != 0); + crtn = mClCalls.getField( mClHand, mCacheHand, fieldOid, @@ -149,15 +166,15 @@ CSSM_RETURN TPCertInfo::fetchField( return crtn; } if(NumberOfFields != 1) { - errorLog1("TPCertInfo::fetchField: numFields %d, expected 1\n", + tpErrorLog("TPCertInfo::fetchField: numFields %d, expected 1\n", (int)NumberOfFields); } - CSSM_CL_CertAbortQuery(mClHand, resultHand); + mClCalls.abortQuery(mClHand, resultHand); return CSSM_OK; } /* free arbitrary field obtained from fetchField() */ -CSSM_RETURN TPCertInfo::freeField( +CSSM_RETURN TPClItemInfo::freeField( const CSSM_OID *fieldOid, CSSM_DATA_PTR fieldData) { @@ -165,38 +182,178 @@ CSSM_RETURN TPCertInfo::freeField( } -/* accessors */ -CSSM_CL_HANDLE TPCertInfo::clHand() +/* + * Verify with an issuer cert - works on certs and CRLs. + * Issuer/subject name match already performed by caller. + * Optional paramCert is used to provide parameters when issuer + * has a partial public key. + */ +CSSM_RETURN TPClItemInfo::verifyWithIssuer( + TPCertInfo *issuerCert, + TPCertInfo *paramCert /* = NULL */) const { - return mClHand; -} + CSSM_RETURN crtn; -CSSM_HANDLE TPCertInfo::cacheHand() -{ - return mCacheHand; -} + assert(mClHand != 0); + assert(issuerCert->isIssuerOf(*this)); + assert(mCspHand != 0); + + /* + * Special case: detect partial public key right now; don't even + * bother trying the cert verify in that case. + */ + if(issuerCert->hasPartialKey() && (paramCert == NULL)) { + /* caller deals with this later */ + tpVfyDebug("verifyWithIssuer PUBLIC_KEY_INCOMPLETE"); + return CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE; + } + + CSSM_CC_HANDLE ccHand; + crtn = CSSM_CSP_CreateSignatureContext(mCspHand, + mSigAlg, + NULL, // Access Creds + issuerCert->pubKey(), + &ccHand); + if(crtn != CSSM_OK) { + tpErrorLog("verifyWithIssuer: CreateSignatureContext error\n"); + CssmError::throwMe(crtn); + } + if(paramCert != NULL) { + assert(issuerCert->hasPartialKey()); + + /* add in parameter-bearing key */ + CSSM_CONTEXT_ATTRIBUTE newAttr; + + newAttr.AttributeType = CSSM_ATTRIBUTE_PARAM_KEY; + newAttr.AttributeLength = sizeof(CSSM_KEY); + newAttr.Attribute.Key = paramCert->pubKey(); + crtn = CSSM_UpdateContextAttributes(ccHand, 1, &newAttr); + if(crtn) { + tpErrorLog("verifyWithIssuer: CSSM_UpdateContextAttributes error\n"); + CssmError::throwMe(crtn); + } + } + crtn = mClCalls.itemVerify(mClHand, + ccHand, + mItemData, + NULL, // issuer cert + NULL, // VerifyScope + 0); // ScopeSize -const CSSM_DATA *TPCertInfo::certData() -{ - CASSERT(mCertData != NULL); - return mCertData; + switch(crtn) { + case CSSM_OK: // success + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: // caller handles + tpVfyDebug("verifyWithIssuer GOOD"); + break; + default: + /* all others appear here as general cert verify error */ + crtn = CSSMERR_TP_VERIFICATION_FAILURE; + tpVfyDebug("verifyWithIssuer BAD"); + break; + } + CSSM_DeleteContext(ccHand); + return crtn; } -const CSSM_DATA *TPCertInfo::subjectName() +CSSM_RETURN TPClItemInfo::cacheItem( + const CSSM_DATA *itemData, + TPItemCopy copyItemData) { - CASSERT(mSubjectName != NULL); - return mSubjectName; + switch(copyItemData) { + case TIC_NoCopy: + mItemData = const_cast(itemData); + break; + case TIC_CopyData: + mItemData = tpMallocCopyCssmData(CssmAllocator::standard(), itemData); + mWeOwnTheData = true; + break; + default: + assert(0); + CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); + } + + /* cache the cert/CRL in the CL */ + return mClCalls.cacheItem(mClHand, mItemData, &mCacheHand); } -const CSSM_DATA *TPCertInfo::issuerName() +/* + * Calculate not before/after times as struct tm. Only throws on + * gross error (CSSMERR_TP_INVALID_CERT_POINTER, etc.). + * + * Only differences between Cert and CRL flavors of this are the + * OIDs used to fetch the appropriate before/after times, both of + * which are expressed as CSSM_X509_TIME structs for both Certs + * and CRLS. + */ +void TPClItemInfo::fetchNotBeforeAfter() { - CASSERT(mIssuerName != NULL); - return mIssuerName; + CSSM_DATA_PTR notBeforeField = NULL; + CSSM_DATA_PTR notAfterField = NULL; + CSSM_RETURN crtn = CSSM_OK; + CSSM_X509_TIME *xTime; + + assert(cacheHand() != CSSM_INVALID_HANDLE); + crtn = fetchField(mClCalls.notBeforeOid, ¬BeforeField); + if(crtn) { + tpErrorLog("fetchNotBeforeAfter: GetField error\n"); + CssmError::throwMe(mClCalls.invalidItemRtn); + } + + /* subsequent errors to errOut */ + xTime = (CSSM_X509_TIME *)notBeforeField->Data; + if(timeStringToTm((char *)xTime->time.Data, xTime->time.Length, &mNotBefore)) { + tpErrorLog("fetchNotBeforeAfter: malformed notBefore time\n"); + crtn = mClCalls.invalidItemRtn; + goto errOut; + } + + crtn = fetchField(mClCalls.notAfterOid, ¬AfterField); + if(crtn) { + /* + * Tolerate a missing NextUpdate in CRL only + */ + if(mClCalls.notAfterOid == &CSSMOID_X509V1ValidityNotAfter) { + tpErrorLog("fetchNotBeforeAfter: GetField error\n"); + crtn = mClCalls.invalidItemRtn; + goto errOut; + } + else { + /* + * Fake NextUpdate to be "at the end of time" + */ + timeStringToTm(CSSM_APPLE_CRL_END_OF_TIME, + strlen(CSSM_APPLE_CRL_END_OF_TIME), + &mNotAfter); + } + } + else { + xTime = (CSSM_X509_TIME *)notAfterField->Data; + if(timeStringToTm((char *)xTime->time.Data, xTime->time.Length, &mNotAfter)) { + tpErrorLog("fetchNotBeforeAfter: malformed notAfter time\n"); + crtn = mClCalls.invalidItemRtn; + goto errOut; + } + } + crtn = CSSM_OK; +errOut: + if(notAfterField) { + freeField(mClCalls.notAfterOid, notAfterField); + } + if(notBeforeField) { + freeField(mClCalls.notBeforeOid, notBeforeField); + } + if(crtn != CSSM_OK) { + CssmError::throwMe(crtn); + } } /* - * Verify validity (not before/after). Only throws on gross error - * (CSSMERR_TP_INVALID_CERT_POINTER, etc.). + * Verify validity (not before/after) by comparing the reference + * time (verifyString if present, or "now" if NULL) to the + * not before/after fields fetched from the item at construction. + * + * Called implicitly at construction; can be called again any time + * to re-establish validity (e.g. after fetching an item from a cache). * * We use some stdlib time calls over in tpTime.c; the stdlib function * gmtime() is not thread-safe, so we do the protection here. Note that @@ -205,109 +362,192 @@ const CSSM_DATA *TPCertInfo::issuerName() */ ModuleNexus tpTimeLock; -void TPCertInfo::calculateCurrent( - const char *cssmTimeStr /* = NULL */) +CSSM_RETURN TPClItemInfo::calculateCurrent( + const char *verifyString) { - CSSM_DATA_PTR notBeforeField = NULL; - CSSM_DATA_PTR notAfterField = NULL; - CSSM_RETURN crtn = CSSM_OK; - CSSM_X509_TIME *xNotAfter; + struct tm refTime; - CASSERT(mCacheHand != CSSM_INVALID_HANDLE); - crtn = fetchField(&CSSMOID_X509V1ValidityNotBefore, ¬BeforeField); - if(crtn) { - errorLog0("TPCertInfo::calculateCurrent: GetField error"); - CssmError::throwMe(crtn); - } - - /* subsequent errors to errOut */ - struct tm now; - if(cssmTimeStr != NULL) { + if(verifyString != NULL) { /* caller specifies verification time base */ - if(timeStringToTm(cssmTimeStr, strlen(cssmTimeStr), &now)) { - errorLog0("TPCertInfo::calculateCurrent: timeStringToTm error"); - CssmError::throwMe(CSSMERR_TP_INVALID_TIMESTRING); + if(timeStringToTm(verifyString, strlen(verifyString), &refTime)) { + tpErrorLog("calculateCurrent: timeStringToTm error\n"); + return CSSMERR_TP_INVALID_TIMESTRING; } } else { /* time base = right now */ StLock _(tpTimeLock()); - nowTime(&now); + nowTime(&refTime); } - struct tm notBefore; - CSSM_X509_TIME *xNotBefore = (CSSM_X509_TIME *)notBeforeField->Data; - - if(timeStringToTm((char *)xNotBefore->time.Data, xNotBefore->time.Length, - ¬Before)) { - errorLog0("TPCertInfo::calculateCurrent: malformed notBefore time\n"); - crtn = CSSMERR_TP_INVALID_CERT_POINTER; - goto errOut; - } - if(compareTimes(&now, ¬Before) < 0) { - mNotValidYet = true; + if(compareTimes(&refTime, &mNotBefore) < 0) { + mIsNotValidYet = true; tpTimeDbg("\nTP_CERT_NOT_VALID_YET:\n now y:%d m:%d d:%d h:%d m:%d", - now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, - now.tm_min); + refTime.tm_year, refTime.tm_mon, refTime.tm_mday, + refTime.tm_hour, refTime.tm_min); tpTimeDbg(" notBefore y:%d m:%d d:%d h:%d m:%d", - notBefore.tm_year, notBefore.tm_mon, notBefore.tm_mday, - notBefore.tm_hour, notBefore.tm_min); + mNotBefore.tm_year, mNotBefore.tm_mon, mNotBefore.tm_mday, + mNotBefore.tm_hour, mNotBefore.tm_min); + return mClCalls.notValidYetRtn; } else { - mNotValidYet = false; - } - - struct tm notAfter; - crtn = fetchField(&CSSMOID_X509V1ValidityNotAfter, ¬AfterField); - if(crtn) { - errorLog0("TPCertInfo::calculateCurrent: GetField error"); - goto errOut; + mIsNotValidYet = false; } - xNotAfter = (CSSM_X509_TIME *)notAfterField->Data; - if(timeStringToTm((char *)xNotAfter->time.Data, xNotAfter->time.Length, - ¬After)) { - errorLog0("TPCertInfo::calculateCurrent: malformed notAfter time\n"); - crtn = CSSMERR_TP_INVALID_CERT_POINTER; - goto errOut; - } - else if(compareTimes(&now, ¬After) > 0) { - crtn = CSSMERR_TP_CERT_EXPIRED; + if(compareTimes(&refTime, &mNotAfter) > 0) { + mIsExpired = true; tpTimeDbg("\nTP_CERT_EXPIRED: \n now y:%d m:%d d:%d " "h:%d m:%d", - now.tm_year, now.tm_mon, now.tm_mday, - now.tm_hour, now.tm_min); + refTime.tm_year, refTime.tm_mon, refTime.tm_mday, + refTime.tm_hour, refTime.tm_min); tpTimeDbg(" notAfter y:%d m:%d d:%d h:%d m:%d", - notAfter.tm_year, notAfter.tm_mon, notAfter.tm_mday, - notAfter.tm_hour, notAfter.tm_min); - mExpired = true; + mNotAfter.tm_year, mNotAfter.tm_mon, mNotAfter.tm_mday, + mNotAfter.tm_hour, mNotAfter.tm_min); + return mClCalls.expiredRtn; } else { - mExpired = false; - } - crtn = CSSM_OK; -errOut: - if(notAfterField) { - freeField(&CSSMOID_X509V1ValidityNotAfter, notAfterField); + mIsExpired = false; + return CSSM_OK; } - if(notBeforeField) { - freeField(&CSSMOID_X509V1ValidityNotBefore, notBeforeField); +} + + +/* + * No default constructor - this is the only way. + * This caches the cert and fetches subjectName, issuerName, and + * mPublicKey to ensure the incoming certData is well-constructed. + */ +TPCertInfo::TPCertInfo( + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const CSSM_DATA *certData, + TPItemCopy copyCertData, // true: we copy, we free + // false - caller owns + const char *verifyTime) // may be NULL + : + TPClItemInfo(clHand, cspHand, tpCertClCalls, certData, + copyCertData, verifyTime), + mSubjectName(NULL), + mPublicKey(NULL), + mIsAnchor(false), + mIsFromDb(false), + mIsFromNet(false), + mNumStatusCodes(0), + mStatusCodes(NULL), + mUniqueRecord(NULL), + mUsed(false), + mIsLeaf(false), + mIsRoot(TRS_Unknown) +{ + CSSM_RETURN crtn; + + tpCertInfoDbg("TPCertInfo construct this %p", this); + mDlDbHandle.DLHandle = 0; + mDlDbHandle.DBHandle = 0; + + /* fetch subject name */ + crtn = fetchField(&CSSMOID_X509V1SubjectName, &mSubjectName); + if(crtn) { + /* bad cert */ + releaseResources(); + CssmError::throwMe(crtn); } - if(crtn != CSSM_OK) { + + /* this cert's public key */ + crtn = CSSM_CL_CertGetKeyInfo(clHand, certData, &mPublicKey); + if(crtn) { + /* bad cert */ + releaseResources(); CssmError::throwMe(crtn); } + + /* calculate other commonly used fields */ + if(tpCompareCssmData(mSubjectName, issuerName())) { + /* + * Per Radar 3374978, perform complete signature verification + * lazily - just check subject/issuer match here. + */ + tpAnchorDebug("TPCertInfo potential anchor"); + mIsRoot = TRS_NamesMatch; + } + else { + mIsRoot = TRS_NotRoot; + } +} + +/* frees mSubjectName, mIssuerName, mCacheHand via mClHand */ +TPCertInfo::~TPCertInfo() +{ + tpCertInfoDbg("TPCertInfo destruct this %p", this); + releaseResources(); +} + +void TPCertInfo::releaseResources() +{ + if(mSubjectName) { + freeField(&CSSMOID_X509V1SubjectName, mSubjectName); + mSubjectName = NULL; + } + if(mStatusCodes) { + free(mStatusCodes); + mStatusCodes = NULL; + } + if(mPublicKey) { + /* allocated by CL */ + tpFreePluginMemory(clHand(), mPublicKey->KeyData.Data); + tpFreePluginMemory(clHand(), mPublicKey); + mPublicKey = NULL; + } + TPClItemInfo::releaseResources(); } -CSSM_RETURN TPCertInfo::isCurrent( - CSSM_BOOL allowExpired) +const CSSM_DATA *TPCertInfo::subjectName() { - if(mNotValidYet) { - return CSSMERR_TP_CERT_NOT_VALID_YET; + assert(mSubjectName != NULL); + return mSubjectName; +} + +/* + * Perform semi-lazy evaluation of "rootness". Subject and issuer names + * compared at constructor. + */ +bool TPCertInfo::isSelfSigned() +{ + switch(mIsRoot) { + case TRS_NotRoot: // known not to be root + return false; + case TRS_IsRoot: + return true; + case TRS_Unknown: // actually shouldn't happen, but to be safe... + case TRS_NamesMatch: + default: + /* do the signature verify */ + if(verifyWithIssuer(this) == CSSM_OK) { + tpAnchorDebug("isSelfSigned anchor verified"); + mIsRoot = TRS_IsRoot; + return true; + } + else { + tpAnchorDebug("isSelfSigned anchor vfy FAIL"); + mIsRoot = TRS_NotRoot; + return false; + } } - if(allowExpired || !mExpired) { - return CSSM_OK; +} + +/* + * Am I the issuer of the specified subject item? Returns true if so. + * Works for subject certs as well as CRLs. + */ +bool TPCertInfo::isIssuerOf( + const TPClItemInfo &subject) +{ + assert(mSubjectName != NULL); + assert(subject.issuerName() != NULL); + if(tpCompareCssmData(mSubjectName, subject.issuerName())) { + return true; } else { - return CSSMERR_TP_CERT_EXPIRED; + return false; } } @@ -319,38 +559,149 @@ void TPCertInfo::addStatusCode(CSSM_RETURN code) mStatusCodes[mNumStatusCodes - 1] = code; } +/* + * Indicate whether this cert's public key is a CSSM_KEYATTR_PARTIAL + * key. + */ +bool TPCertInfo::hasPartialKey() +{ + if(mPublicKey->KeyHeader.KeyAttr & CSSM_KEYATTR_PARTIAL) { + return true; + } + else { + return false; + } +} + /*** *** TPCertGroup class ***/ + +/* build empty group */ TPCertGroup::TPCertGroup( CssmAllocator &alloc, - unsigned numCerts) : + TPGroupOwner whoOwns) : mAlloc(alloc), - mNumCerts(0) + mCertInfo(NULL), + mNumCerts(0), + mSizeofCertInfo(0), + mWhoOwns(whoOwns) { - mCertInfo = (TPCertInfo **)alloc.malloc(numCerts * sizeof(TPCertInfo *)); - mSizeofCertInfo = numCerts; + tpCertInfoDbg("TPCertGroup simple construct this %p", this); + /* nothing for now */ } /* - * Deletes all TPCertInfo's. + * Construct from unordered, untrusted CSSM_CERTGROUP. Resulting + * TPCertInfos are more or less in the same order as the incoming + * certs, though incoming certs are discarded if they don't parse. + * No verification of any sort is performed. + */ +TPCertGroup::TPCertGroup( + const CSSM_CERTGROUP &CertGroupFrag, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + CssmAllocator &alloc, + const char *verifyTime, // may be NULL + bool firstCertMustBeValid, + TPGroupOwner whoOwns) : + mAlloc(alloc), + mCertInfo(NULL), + mNumCerts(0), + mSizeofCertInfo(0), + mWhoOwns(whoOwns) +{ + tpCertInfoDbg("TPCertGroup hard construct this %p", this); + + /* verify input args */ + if(cspHand == CSSM_INVALID_HANDLE) { + CssmError::throwMe(CSSMERR_TP_INVALID_CSP_HANDLE); + } + if(clHand == CSSM_INVALID_HANDLE) { + CssmError::throwMe(CSSMERR_TP_INVALID_CL_HANDLE); + } + if(firstCertMustBeValid) { + if( (CertGroupFrag.NumCerts == 0) || + (CertGroupFrag.GroupList.CertList[0].Data == NULL) || + (CertGroupFrag.GroupList.CertList[0].Length == 0)) { + CssmError::throwMe(CSSMERR_TP_INVALID_CERTIFICATE); + } + } + if(CertGroupFrag.CertGroupType != CSSM_CERTGROUP_DATA) { + CssmError::throwMe(CSSMERR_TP_INVALID_CERTGROUP); + } + switch(CertGroupFrag.CertType) { + case CSSM_CERT_X_509v1: + case CSSM_CERT_X_509v2: + case CSSM_CERT_X_509v3: + break; + default: + CssmError::throwMe(CSSMERR_TP_UNKNOWN_FORMAT); + } + switch(CertGroupFrag.CertEncoding) { + case CSSM_CERT_ENCODING_BER: + case CSSM_CERT_ENCODING_DER: + break; + default: + CssmError::throwMe(CSSMERR_TP_UNKNOWN_FORMAT); + } + + /* + * Add remaining input certs to mCertInfo. + */ + TPCertInfo *certInfo = NULL; + for(unsigned certDex=0; certDexindex(certDex); + appendCert(certInfo); + } +} + +/* + * Deletes contents of mCertInfo[] if appropriate. */ TPCertGroup::~TPCertGroup() { - unsigned i; - for(i=0; i here, but + * gdb is so lame that it doesn't even let one examine the contents + * of an array<> (or just about anything else in the STL). I prefer + * debuggability over saving a few lines of trivial code. + */ void TPCertGroup::appendCert( TPCertInfo *certInfo) // appends to end of mCertInfo { if(mNumCerts == mSizeofCertInfo) { - /* FIXME - do we need the realloc workaround we used to have in TPSession? */ - mSizeofCertInfo *= 2; + if(mSizeofCertInfo == 0) { + /* appending to empty array */ + mSizeofCertInfo = 1; + } + else { + mSizeofCertInfo *= 2; + } mCertInfo = (TPCertInfo **)mAlloc.realloc(mCertInfo, mSizeofCertInfo * sizeof(TPCertInfo *)); } @@ -384,11 +735,6 @@ TPCertInfo *TPCertGroup::removeCertAtIndex( return rtn; } -unsigned TPCertGroup::numCerts() -{ - return mNumCerts; -} - TPCertInfo *TPCertGroup::firstCert() { if(mNumCerts == 0) { @@ -403,8 +749,7 @@ TPCertInfo *TPCertGroup::firstCert() TPCertInfo *TPCertGroup::lastCert() { if(mNumCerts == 0) { - /* the caller really should not do this... */ - CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); + return NULL; } else { return mCertInfo[mNumCerts - 1]; @@ -428,7 +773,7 @@ CSSM_CERTGROUP_PTR TPCertGroup::buildCssmCertGroup() cgrp->GroupList.CertList = (CSSM_DATA_PTR)mAlloc.calloc(mNumCerts, sizeof(CSSM_DATA)); for(unsigned i=0; icertData(), + tpCopyCssmData(mAlloc, mCertInfo[i]->itemData(), &cgrp->GroupList.CertList[i]); } return cgrp; @@ -456,6 +801,9 @@ CSSM_TP_APPLE_EVIDENCE_INFO *TPCertGroup::buildCssmEvidenceInfo() if(certInfo->isAnchor()) { evInfo->StatusBits |= CSSM_CERT_STATUS_IS_IN_ANCHORS; } + else if(certInfo->isFromNet()) { + evInfo->StatusBits |= CSSM_CERT_STATUS_IS_FROM_NET; + } else { evInfo->StatusBits |= CSSM_CERT_STATUS_IS_IN_INPUT_CERTS; } @@ -484,7 +832,7 @@ CSSM_TP_APPLE_EVIDENCE_INFO *TPCertGroup::buildCssmEvidenceInfo() /* Given a status for basic construction of a cert group and a status * of (optional) policy verification, plus the implicit notBefore/notAfter * status in the certs, calculate a global return code. This just - * encapsulates a policy for CertGroupeConstruct and CertGroupVerify. + * encapsulates a policy for CertGroupConstruct and CertGroupVerify. */ CSSM_RETURN TPCertGroup::getReturnCode( CSSM_RETURN constructStatus, @@ -517,3 +865,558 @@ CSSM_RETURN TPCertGroup::getReturnCode( } return policyStatus; } + +/* set all TPCertINfo.mUsed flags false */ +void TPCertGroup::setAllUnused() +{ + for(unsigned dex=0; dexused(false); + } +} + +/* + * Search unused incoming certs to find an issuer of specified cert or CRL. + * WARNING this assumes a valid "used" state for all certs in this group. + * If partialIssuerKey is true on return, caller must re-verify signature + * of subject later when sufficient info is available. + */ +TPCertInfo *TPCertGroup::findIssuerForCertOrCrl( + const TPClItemInfo &subject, + bool &partialIssuerKey) +{ + partialIssuerKey = false; + for(unsigned certDex=0; certDexused()) { + continue; + } + + /* subject/issuer names match? */ + if(certInfo->isIssuerOf(subject)) { + /* yep, do a sig verify */ + tpVfyDebug("findIssuerForCertOrCrl issuer/subj match checking sig"); + CSSM_RETURN crtn = subject.verifyWithIssuer(certInfo); + switch(crtn) { + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: + /* issuer OK, check sig later */ + partialIssuerKey = true; + /* and fall thru */ + case CSSM_OK: + /* YES */ + certInfo->used(true); + return certInfo; + default: + /* just skip this one and keep looking */ + tpVfyDebug("findIssuerForCertOrCrl issuer/subj match BAD SIG"); + break; + } + } /* names match */ + } + /* not found */ + return NULL; +} + +/* + * Construct ordered, verified cert chain from a variety of inputs. + * Time validity is ignored and needs to be checked by caller (it's + * stored in each TPCertInfo we add to ourself during construction). + * The only error returned is CSSMERR_APPLETP_INVALID_ROOT, meaning + * we verified back to a supposed root cert which did not in fact + * self-verify. Other interesting status is returned via the + * verifiedToRoot and verifiedToAnchor flags. + * + * NOTE: is it the caller's responsibility to call setAllUnused() for both + * incoming cert groups (inCertGroup and gatheredCerts). We don't do that + * here because we may call ourself recursively. + */ +CSSM_RETURN TPCertGroup::buildCertGroup( + const TPClItemInfo &subjectItem, // Cert or CRL + TPCertGroup *inCertGroup, // optional + const CSSM_DL_DB_LIST *dbList, // optional + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const char *verifyTime, // optional, for establishing + // validity of new TPCertInfos + /* trusted anchors, optional */ + /* FIXME - maybe this should be a TPCertGroup */ + uint32 numAnchorCerts, + const CSSM_DATA *anchorCerts, + + /* + * Certs to be freed by caller (i.e., TPCertInfo which we allocate + * as a result of using a cert from anchorCerts or dbList) are added + * to this group. + */ + TPCertGroup &certsToBeFreed, + + /* + * Other certificates gathered during the course of this operation, + * currently consisting of certs fetched from DBs and from the net. + * This is not used when called by AppleTPSession::CertGroupConstructPriv; + * it's an optimization for the case when we're building a cert group + * for TPCrlInfo::verifyWithContext - we avoid re-fetching certs from + * the net which are needed to verify both the subject cert and a CRL. + */ + TPCertGroup *gatheredCerts, + + /* + * Indicates that subjectItem is the last element in this cert group. + * If true, that cert will be tested for "root-ness", including + * -- subject/issuer compare + * -- signature self-verify + * -- anchor compare + */ + CSSM_BOOL subjectIsInGroup, + + /* currently, only CSSM_TP_ACTION_FETCH_CERT_FROM_NET is interesting */ + CSSM_APPLE_TP_ACTION_FLAGS actionFlags, + + /* returned */ + CSSM_BOOL &verifiedToRoot, // end of chain self-verifies + CSSM_BOOL &verifiedToAnchor) // end of chain in anchors +{ + const TPClItemInfo *thisSubject = &subjectItem; + CSSM_RETURN crtn = CSSM_OK; + TPCertInfo *issuerCert = NULL; + unsigned certDex; + TPCertInfo *anchorInfo = NULL; + bool foundPartialIssuer = false; + + tpVfyDebug("buildCertGroup top"); + + /* possible expired root which we'll only use if we can't find + * a better one */ + TPCertInfo *expiredRoot = NULL; + + verifiedToRoot = CSSM_FALSE; + verifiedToAnchor = CSSM_FALSE; + + /*** main loop to seach inCertGroup and dbList *** + * + * Exit loop on: + * -- find a root cert in the chain + * -- memory error + * -- or no more certs to add to chain. + */ + for(;;) { + /* + * Top of loop: thisSubject is the item we're trying to verify. + */ + + /* is thisSubject a root cert? */ + if(subjectIsInGroup) { + TPCertInfo *subjCert = lastCert(); + assert(subjCert != NULL); + if(subjCert->isSelfSigned()) { + /* We're at the end of the chain. */ + verifiedToRoot = CSSM_TRUE; + + /* + * Special case if this root is expired (and it's not the + * leaf): remove it from the outgoing cert group, save it, + * and try to proceed with anchor cert processing. + */ + if(subjCert->isExpired() && (mNumCerts > 1)) { + tpDebug("buildCertGroup: EXPIRED ROOT, looking for good one"); + mNumCerts--; + expiredRoot = subjCert; + thisSubject = lastCert(); + } + break; + } + } + + /* + * Search unused incoming certs to find an issuer. + * Both cert groups are optional. + * We'll add issuer to outCertGroup below. + */ + if(inCertGroup != NULL) { + bool partial = false; + issuerCert = inCertGroup->findIssuerForCertOrCrl(*thisSubject, + partial); + if(issuerCert) { + if(partial) { + /* deal with this later */ + foundPartialIssuer = true; + tpDebug("buildCertGroup: PARTIAL Cert FOUND in inCertGroup"); + } + else { + tpDebug("buildCertGroup: Cert FOUND in inCertGroup"); + } + } + } + if((issuerCert == NULL) && (gatheredCerts != NULL)) { + bool partial = false; + issuerCert = gatheredCerts->findIssuerForCertOrCrl(*thisSubject, + partial); + if(issuerCert) { + if(partial) { + /* deal with this later */ + foundPartialIssuer = true; + tpDebug("buildCertGroup: PARTIAL Cert FOUND in gatheredCerts"); + } + else { + tpDebug("buildCertGroup: Cert FOUND in gatheredCerts"); + } + } + } + + if((issuerCert == NULL) && (dbList != NULL)) { + /* Issuer not in incoming cert group. Search DBList. */ + bool partial = false; + issuerCert = tpDbFindIssuerCert(mAlloc, + clHand, + cspHand, + thisSubject, + dbList, + verifyTime, + partial); + if(issuerCert) { + /* caller must free */ + certsToBeFreed.appendCert(issuerCert); + if(partial) { + /* deal with this later */ + foundPartialIssuer = true; + tpDebug("buildCertGroup: PARTIAL Cert FOUND in dbList"); + } + else { + tpDebug("buildCertGroup: Cert FOUND in dbList"); + } + } + } /* Issuer not in incoming cert group */ + + if(issuerCert == NULL) { + /* end of search, broken chain */ + break; + } + + /* + * One way or the other, we've found a cert which verifies subjectCert. + * Add the issuer to outCertGroup and make it the new thisSubject for + * the next pass. + */ + appendCert(issuerCert); + thisSubject = issuerCert; + subjectIsInGroup = CSSM_TRUE; + issuerCert = NULL; + } /* main loop */ + + /* + * This can be NULL if we're evaluating a CRL (and we haven't + * gotten very far). + */ + TPCertInfo *endCert = lastCert(); + + if(numAnchorCerts == 0) { + /* we're probably done */ + goto post_anchor; + } + assert(anchorCerts != NULL); + + /*** anchor cert handling ***/ + /* + * Case 1: last cert in output is a root cert. See if + * the root cert is in AnchorCerts. This also applies to + * the expiredRoot case; we report a different error for + * "we trust the root but it's expired" versus "we don't + * trust the root". + * Note that the above loop did the actual root self-verify test. + * FIXME - shouldn't we be searching for a match in AnchorCerts + * whether or not endCert is a root!!? + */ + if((endCert && endCert->isSelfSigned()) || expiredRoot) { + + TPCertInfo *theRoot; + if(expiredRoot) { + /* this is NOT in our outgoing cert group (yet) */ + theRoot = expiredRoot; + } + else { + theRoot = endCert; + } + /* see if that root cert is identical to one of the anchor certs */ + for(certDex=0; certDexitemData(), &anchorCerts[certDex])) { + /* one fully successful return */ + verifiedToAnchor = CSSM_TRUE; + theRoot->isAnchor(true); + theRoot->index(certDex); + if(expiredRoot) { + /* verified to anchor but caller will see + * CSSMERR_TP_CERT_EXPIRED */ + appendCert(expiredRoot); + } + /* one more thing: partial public key processing needed? */ + if(foundPartialIssuer) { + return verifyWithPartialKeys(subjectItem); + } + else { + return CSSM_OK; + } + } + } + + if(!expiredRoot) { + /* verified to a root cert which is not an anchor */ + /* Generally maps to CSSMERR_TP_INVALID_ANCHOR_CERT by caller */ + /* one more thing: partial public key processing needed? */ + if(foundPartialIssuer) { + return verifyWithPartialKeys(subjectItem); + } + else { + return CSSM_OK; + } + } + /* else try finding a good anchor */ + } + + /* + * Case 2: try to validate thisSubject with anchor certs + */ + for(certDex=0; certDexisIssuerOf(*thisSubject)) { + /* not this anchor */ + tpAnchorDebug("buildCertGroup anchor not issuer"); + delete anchorInfo; + anchorInfo = NULL; + continue; + } + + crtn = thisSubject->verifyWithIssuer(anchorInfo); + switch(crtn) { + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: + /* + * A bit of a corner case. Found an issuer in AnchorCerts, but + * we can't do a signature verify since the issuer has a partial + * public key. Proceed but return + * CSSMERR_TP_CERTIFICATE_CANT_OPERATE. + */ + crtn = CSSMERR_TP_CERTIFICATE_CANT_OPERATE; + anchorInfo->addStatusCode(CSSMERR_TP_CERTIFICATE_CANT_OPERATE); + foundPartialIssuer = true; + /* drop thru */ + case CSSM_OK: + /* The other normal fully successful return. */ + verifiedToAnchor = CSSM_TRUE; + if(anchorInfo->isSelfSigned()) { + verifiedToRoot = CSSM_TRUE; + } + + /* + * Add this anchor cert to the output group + * and to certsToBeFreed. + */ + appendCert(anchorInfo); + anchorInfo->isAnchor(true); + anchorInfo->index(certDex); + certsToBeFreed.appendCert(anchorInfo); + tpDebug("buildCertGroup: Cert FOUND by signer in AnchorList"); + /* one more thing: partial public key processing needed? */ + if(foundPartialIssuer) { + return verifyWithPartialKeys(subjectItem); + } + else { + return crtn; + } + + default: + /* continue to next anchor */ + tpVfyDebug("buildCertGroup found issuer in anchor, BAD SIG"); + delete anchorInfo; + anchorInfo = NULL; + break; + } + } /* for each anchor */ + /* regardless of anchor search status... */ + crtn = CSSM_OK; +post_anchor: + if(expiredRoot) { + /* + * One remaining special case: expiredRoot found in input certs, but + * no luck resolving the problem with the anchors. Go ahead and append + * the expired root and return. + */ + tpDebug("buildCertGroup: accepting EXPIRED root"); + appendCert(expiredRoot); + if(foundPartialIssuer) { + return verifyWithPartialKeys(subjectItem); + } + else { + return CSSM_OK; + } + } + + /* + * If we haven't verified to a root, and net fetch of certs is enabled, + * try to get the issuer of the last cert in the chain from the net. + * If that succeeds, then call ourself recursively to perform the + * whole search again (including comparing to or verifying against + * anchor certs). + */ + if(!verifiedToRoot && !verifiedToAnchor && + (endCert != NULL) && + (actionFlags & CSSM_TP_ACTION_FETCH_CERT_FROM_NET)) { + TPCertInfo *issuer = NULL; + CSSM_RETURN cr = tpFetchIssuerFromNet(*endCert, + clHand, + cspHand, + verifyTime, + issuer); + switch(cr) { + case CSSMERR_TP_CERTGROUP_INCOMPLETE: + /* no issuerAltName, no reason to log this */ + break; + default: + /* gross error */ + endCert->addStatusCode(cr); + break; + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: + /* use this one but re-verify later */ + foundPartialIssuer = true; + /* and drop thru */ + case CSSM_OK: + tpDebug("buildCertGroup: Cert FOUND from Net; recursing"); + + /* add this fetched cert to constructed group */ + appendCert(issuer); + issuer->isFromNet(true); + certsToBeFreed.appendCert(issuer); + + /* and go again */ + cr = buildCertGroup(*issuer, + inCertGroup, + dbList, + clHand, + cspHand, + verifyTime, + numAnchorCerts, + anchorCerts, + certsToBeFreed, + gatheredCerts, + CSSM_TRUE, // subjectIsInGroup + actionFlags, + verifiedToRoot, + verifiedToAnchor); + if(cr) { + return cr; + } + + /* one more thing: partial public key processing needed? */ + if(foundPartialIssuer) { + return verifyWithPartialKeys(subjectItem); + } + else { + return CSSM_OK; + } + } + } + /* regardless of outcome, check for partial keys to log per-cert status */ + CSSM_RETURN partRtn = CSSM_OK; + if(foundPartialIssuer) { + partRtn = verifyWithPartialKeys(subjectItem); + } + if(crtn) { + return crtn; + } + else { + return partRtn; + } +} + +/* + * Called from buildCertGroup as final processing of a constructed + * group when CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE has been + * detected. Perform partial public key processing. + * + * We don't have to verify every element, just the ones whose + * issuers have partial public keys. + * + * Returns: + * CSSMERR_TP_CERTIFICATE_CANT_OPERATE in the case of an issuer cert + * with a partial public key which can't be completed. + * CSSMERR_TP_INVALID_CERT_AUTHORITY if sig verify failed with + * a (supposedly) completed partial key + */ +CSSM_RETURN TPCertGroup::verifyWithPartialKeys( + const TPClItemInfo &subjectItem) // Cert or CRL +{ + TPCertInfo *lastFullKeyCert = NULL; + tpDebug("verifyWithPartialKeys top"); + + /* start from the end - it's easier */ + for(int dex=mNumCerts-1; dex >= 0; dex--) { + TPCertInfo *thisCert = mCertInfo[dex]; + + /* + * If this is the start of the cert chain, and it's not being + * used to verify subjectItem, then we're done. + */ + if(dex == 0) { + if((void *)thisCert == (void *)&subjectItem) { + tpDebug("verifyWithPartialKeys: success at leaf cert"); + return CSSM_OK; + } + } + if(!thisCert->hasPartialKey()) { + /* + * Good to know. Record this and move on. + */ + lastFullKeyCert = thisCert; + tpDebug("full key cert found at index %d", dex); + continue; + } + if(lastFullKeyCert == NULL) { + /* + * No full keys between here and the end! + */ + tpDebug("UNCOMPLETABLE cert at index %d", dex); + thisCert->addStatusCode(CSSMERR_TP_CERTIFICATE_CANT_OPERATE); + return CSSMERR_TP_CERTIFICATE_CANT_OPERATE; + } + + /* do the verify - of next cert in chain or of subjectItem */ + const TPClItemInfo *subject; + if(dex == 0) { + subject = &subjectItem; + tpDebug("...verifying subject item with partial cert 0"); + } + else { + subject = mCertInfo[dex - 1]; + tpDebug("...verifying with partial cert %d", dex); + } + CSSM_RETURN crtn = subject->verifyWithIssuer(thisCert, + lastFullKeyCert); + if(crtn) { + tpDebug("CERT VERIFY ERROR with partial cert at index %d", dex); + thisCert->addStatusCode(CSSMERR_TP_CERTIFICATE_CANT_OPERATE); + return CSSMERR_TP_INVALID_CERT_AUTHORITY; + } + } + + /* we just verified subjectItem - right? */ + assert((void *)mCertInfo[0] != (void *)&subjectItem); + tpDebug("verifyWithPartialKeys: success at subjectItem"); + return CSSM_OK; +} diff --git a/AppleX509TP/TPCertInfo.h b/AppleX509TP/TPCertInfo.h index e6b5d918..447bac95 100644 --- a/AppleX509TP/TPCertInfo.h +++ b/AppleX509TP/TPCertInfo.h @@ -31,40 +31,97 @@ #include #include -/*** Interim hack, disable not before/not after checking during cert chain processing ***/ -/*** code #ifdef'd with this gets ripped out later ***/ -#define TP_CERT_CURRENT_CHECK_INLINE 0 - /* protects TP-wide access to time() and gmtime() */ extern ModuleNexus tpTimeLock; +/* + * Prototypes for functions which are isomorphic between certs and CRLs at the + * CL API. + */ +typedef CSSM_RETURN (*clGetFirstFieldFcn)( + CSSM_CL_HANDLE CLHandle, + CSSM_HANDLE ItemHandle, // cached cert or CRL + const CSSM_OID *ItemField, + CSSM_HANDLE_PTR ResultsHandle, + uint32 *NumberOfMatchedFields, + CSSM_DATA_PTR *Value); +typedef CSSM_RETURN (*clAbortQueryFcn)( + CSSM_CL_HANDLE CLHandle, + CSSM_HANDLE ResultsHandle); // from clGetFirstFieldFcn +typedef CSSM_RETURN (*clCacheItemFcn)( + CSSM_CL_HANDLE CLHandle, + const CSSM_DATA *Item, // raw cert or CRL + CSSM_HANDLE_PTR CertHandle); +typedef CSSM_RETURN (*clAbortCacheFcn)( + CSSM_CL_HANDLE CLHandle, + CSSM_HANDLE ItemHandle); // from clCacheItemFcn +typedef CSSM_RETURN (*clItemVfyFcn)( + CSSM_CL_HANDLE CLHandle, + CSSM_CC_HANDLE CCHandle, + const CSSM_DATA *CrlOrCertToBeVerified, + const CSSM_DATA *SignerCert, + const CSSM_FIELD *VerifyScope, + uint32 ScopeSize); + +typedef struct { + /* CL/cert-specific functions */ + clGetFirstFieldFcn getField; + clAbortQueryFcn abortQuery; + clCacheItemFcn cacheItem; + clAbortCacheFcn abortCache; + clItemVfyFcn itemVerify; + /* CL/cert-specific OIDs */ + const CSSM_OID *notBeforeOid; + const CSSM_OID *notAfterOid; + /* CL/cert specific errors */ + CSSM_RETURN invalidItemRtn; // CSSMERR_TP_INVALID_{CERT,CRL}_POINTER + CSSM_RETURN expiredRtn; + CSSM_RETURN notValidYetRtn; +} TPClItemCalls; + +class TPCertInfo; + /* - * Class representing one certificate. The raw cert data usually comes from - * a client (via incoming cert groups in CertGroupConstruct() and CertGroupVerify()); - * In this case, we don't own the raw data and don't copy or free it. Caller can - * optionally specify that we copy (and own and eventnually free) the raw cert data. - * The constructor throws on any error (bad cert data); subsequent to successful - * construction, no CSSM errors are thrown and it's guaranteed that the cert is - * basically good and successfully cached in the CL, and that we have a locally - * cached subject and issuer name (in normalized encoded format). - */ -class TPCertInfo + * On construction of a TPClItemInfo, specifies whether or not to + * copy the incoming item data (in which we free it upon destruction) + * or to use caller's data as is (in which case the caller maintains + * the data). + */ +typedef enum { + TIC_None = 0, // never used + TIC_NoCopy, // caller maintains + TIC_CopyData // we copy and free +} TPItemCopy; + +/* + * State of a cert's mIsRoot flag. We do signature self-verify on demand. + */ +typedef enum { + TRS_Unknown, // initial state + TRS_NamesMatch, // subject == issuer, but no sig verify yet + TRS_NotRoot, // subject != issuer, OR sig verify failed + TRS_IsRoot // it's a root +} TPRootState; + +/* + * Base class for TPCertInfo and TPCrlInfo. Encapsulates caching of + * an entity within the CL, field lookup/free, and signature verify, + * all of which use similar functions at the CL API. + */ +class TPClItemInfo { + NOCOPY(TPClItemInfo) public: - /* - * No default constructor - this is the only way. - * This caches the cert and fetches subjectName and issuerName - * to ensure the incoming certData is well-constructed. - */ - TPCertInfo( - const CSSM_DATA *certData, + TPClItemInfo( CSSM_CL_HANDLE clHand, - const char *cssmTimeStr = NULL, // NULL ==> time base = right now - bool copyCertData = false); // true: we copy, we free - // false - caller owns - - /* frees mSubjectName, mIssuerName, mCacheHand via mClHand */ - ~TPCertInfo(); + CSSM_CSP_HANDLE cspHand, + const TPClItemCalls &clCalls, + const CSSM_DATA *itemData, + TPItemCopy copyItemData, + const char *verifyTime); // may be NULL + + ~TPClItemInfo(); + void releaseResources(); /* * Fetch arbitrary field from cached cert. @@ -79,25 +136,120 @@ public: CSSM_RETURN freeField( const CSSM_OID *fieldOid, CSSM_DATA_PTR fieldData); + + /* + * Verify with an issuer cert - works on certs and CRLs. + * Issuer/subject name match already performed by caller. + * May return CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE without + * performing a signature op, in which case it is the caller's + * resposibility to complete this operation later when + * sufficient information is available. + * + * Optional paramCert is used to provide parameters when issuer + * has a partial public key. + */ + CSSM_RETURN verifyWithIssuer( + TPCertInfo *issuerCert, + TPCertInfo *paramCert = NULL) const; + + /* accessors */ + CSSM_CL_HANDLE clHand() const { return mClHand; } + CSSM_CSP_HANDLE cspHand() const { return mCspHand; } + CSSM_HANDLE cacheHand() const { return mCacheHand; } + const CSSM_DATA *itemData() const { return mItemData; } + const CSSM_DATA *issuerName() const { return mIssuerName; }; + unsigned index() const { return mIndex; } + void index(unsigned dex) { mIndex = dex; } + bool isExpired() { return mIsExpired; } + bool isNotValidYet() { return mIsNotValidYet; } + + /* + * Calculate validity (not before/after). Returns + * CSSMERR_{TP_CERT,APPLETP_CRL}_NOT_VALID_YET + * CSSMERR_xxx_T_EXPIRED + * CSSM_OK + * CSSMERR_xxx_INVALID_CERT_POINTER, other "bogus cert" errors + */ + CSSM_RETURN calculateCurrent( + const char *verifyString = NULL); + +private: + + /* Tell CL to parse and cache the item */ + CSSM_RETURN cacheItem( + const CSSM_DATA *itemData, + TPItemCopy copyItemData); + + + /* fetch not before/after fields */ + void fetchNotBeforeAfter(); + + CSSM_CL_HANDLE mClHand; // always valid + CSSM_CSP_HANDLE mCspHand; // always valid + const TPClItemCalls &mClCalls; + bool mWeOwnTheData; // if true, we have to free + // mCertData + /* following four valid subsequent to cacheItem(), generally + * called by subclass's constructor */ + CSSM_HANDLE mCacheHand; + CSSM_DATA_PTR mIssuerName; + CSSM_DATA *mItemData; + CSSM_ALGORITHMS mSigAlg; + + /* calculated implicitly at construction */ + struct tm mNotBefore; + struct tm mNotAfter; + + /* also calculated at construction, but can be recalculated at will */ + bool mIsExpired; + bool mIsNotValidYet; + + unsigned mIndex; +}; + +/* + * Class representing one certificate. The raw cert data usually comes from + * a client (via incoming cert groups in CertGroupConstruct() and + * CertGroupVerify()); in this case, we don't own the raw data and + * don't copy or free it. Caller can optionally specify that we copy + * (and own and eventually free) the raw cert data. Currently this is + * only done when we find a cert in a DlDb. The constructor throws + * on any error (bad cert data); subsequent to successful construction, no CSSM + * errors are thrown and it's guaranteed that the cert is basically good and + * successfully cached in the CL, and that we have a locally cached subject + * and issuer name (in normalized encoded format). + */ +class TPCertInfo : public TPClItemInfo +{ + NOCOPY(TPCertInfo) +public: + /* + * No default constructor - this is the only way. + * This caches the cert and fetches subjectName and issuerName + * to ensure the incoming certData is well-constructed. + */ + TPCertInfo( + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const CSSM_DATA *certData, + TPItemCopy copyCertData, + + const char *verifyTime); // may be NULL + /* frees mSubjectName, mIssuerName, mCacheHand via mClHand */ + ~TPCertInfo(); + /* accessors */ - CSSM_CL_HANDLE clHand(); - CSSM_HANDLE cacheHand(); - const CSSM_DATA *certData(); const CSSM_DATA *subjectName(); - const CSSM_DATA *issuerName(); - bool isSelfSigned() { return mIsRoot; } - bool isExpired() { return mExpired; } - bool isNotValidYet() { return mNotValidYet; } + bool isSelfSigned(); - unsigned index() { return mIndex; } - void index(unsigned dex) { mIndex = dex; } bool isAnchor() { return mIsAnchor; } void isAnchor(bool a) { mIsAnchor = a; } + bool isFromNet() { return mIsFromNet; } + void isFromNet(bool n) { mIsFromNet = n; }; unsigned numStatusCodes() { return mNumStatusCodes; } CSSM_RETURN *statusCodes() { return mStatusCodes; } - void addStatusCode(CSSM_RETURN code); CSSM_DL_DB_HANDLE dlDbHandle() { return mDlDbHandle; } void dlDbHandle(CSSM_DL_DB_HANDLE hand) { mDlDbHandle = hand; } @@ -105,66 +257,155 @@ public: { return mUniqueRecord; } void uniqueRecord(CSSM_DB_UNIQUE_RECORD_PTR rec) { mUniqueRecord = rec; } - - /* - * Verify validity (not before/after). Returns - * CSSMERR_TP_CERT_NOT_VALID_YET - * CSSMERR_TP_CERT_EXPIRED - * CSSM_OK - * CSSMERR_TP_INVALID_CERT_POINTER, other "bogus cert" errors + CSSM_KEY_PTR pubKey() { return mPublicKey; } + bool used() { return mUsed; } + void used(bool u) { mUsed = u; } + bool isLeaf() { return mIsLeaf; } + void isLeaf(bool l) { mIsLeaf = l; } + /* + * Am I the issuer of the specified subject item? Returns true if so. + * Works for subject certs as well as CRLs. */ - CSSM_RETURN isCurrent( - CSSM_BOOL allowExpired = CSSM_FALSE); + bool isIssuerOf( + const TPClItemInfo &subject); + void addStatusCode( + CSSM_RETURN code); + + /* + * Indicate whether this cert's public key is a CSSM_KEYATTR_PARTIAL + * key. + */ + bool hasPartialKey(); + private: - CSSM_DATA *mCertData; // always valid - bool mWeOwnTheData; // if true, we have to free mCertData - CSSM_CL_HANDLE mClHand; // always valid - CSSM_HANDLE mCacheHand; // always valid + /* obtained from CL at construction */ CSSM_DATA_PTR mSubjectName; // always valid - CSSM_DATA_PTR mIssuerName; // always valid + CSSM_KEY_PTR mPublicKey; /* maintained by caller, default at constructor 0/false */ - unsigned mIndex; bool mIsAnchor; bool mIsFromDb; + bool mIsFromNet; unsigned mNumStatusCodes; CSSM_RETURN *mStatusCodes; CSSM_DL_DB_HANDLE mDlDbHandle; CSSM_DB_UNIQUE_RECORD_PTR mUniqueRecord; - - /* calculated implicitly at construction */ - bool mExpired; - bool mNotValidYet; - bool mIsRoot; // i.e., subject == issuer + bool mUsed; // e.g., used in current loop + bool mIsLeaf; // first in chain + TPRootState mIsRoot; // subject == issuer - void releaseResources(); - void calculateCurrent( - const char *cssmTimeStr = NULL); // set mExpired, mNotValidYet - + void releaseResources(); }; +/* Describe who owns the items in a TP{Cert,Crl}Group */ +typedef enum { + TGO_None = 0, // not used + TGO_Group, // TP{Cert,Crl}Group owns the items + TGO_Caller // caller owns the items +} TPGroupOwner; + /* - * TP's private Cert Group class. Provides a list of TPCertInfo pointers, to which - * caller can append additional elements, access an element at an arbitrary position, - * and remover an element at an arbitrrary position. + * TP's private Cert Group class. Provides a list of TPCertInfo pointers, + * to which caller can append additional elements, access an element at + * an arbitrary position, and remover an element at an arbitrrary position. */ class TPCertGroup { + NOCOPY(TPCertGroup) public: /* - * No default constructor - use this to cook up an instance with - * space for numCerts TPCertInfos. + * No default constructor. + * This one creates an empty TPCertGroup. */ TPCertGroup( CssmAllocator &alloc, - unsigned numCerts); + TPGroupOwner whoOwns); // if TGO_Group, we delete + /* + * Construct from unordered, untrusted CSSM_CERTGROUP. Resulting + * TPCertInfos are more or less in the same order as the incoming + * certs, though incoming certs are discarded if they don't parse. + * No verification of any sort is performed. + */ + TPCertGroup( + const CSSM_CERTGROUP &CertGroupFrag, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + CssmAllocator &alloc, + const char *verifyString, // may be NULL + bool firstCertMustBeValid, + TPGroupOwner whoOwns); + /* * Deletes all TPCertInfo's. */ ~TPCertGroup(); + /* + * Construct ordered, verified cert chain from a variety of inputs. + * Time validity is ignored and needs to be checked by caller (it's + * stored in each TPCertInfo we add to ourself during construction). + * The only error returned is CSSMERR_APPLETP_INVALID_ROOT, meaning + * we verified back to a supposed root cert which did not in fact + * self-verify. Other interesting status is returned via the + * verifiedToRoot and verifiedToAnchor flags. + * + * NOTE: is it the caller's responsibility to call setAllUnused() + * for both incoming cert groups (inCertGroup and gatheredCerts). + * We don't do that here because we may call ourself recursively. + * + * subjectItem may or may not be in the cert group (currently, it + * is in the group if it's a cert and it's not if it's a CRL, but + * we don't rely on that). + */ + CSSM_RETURN buildCertGroup( + const TPClItemInfo &subjectItem, // Cert or CRL + TPCertGroup *inCertGroup, // optional + const CSSM_DL_DB_LIST *dbList, // optional + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const char *verifyString, // optional, for establishing + // validity of new TPCertInfos + /* trusted anchors, optional */ + /* FIXME - maybe this should be a TPCertGroup */ + uint32 numAnchorCerts, + const CSSM_DATA *anchorCerts, + + /* + * Certs to be freed by caller (i.e., TPCertInfo which we allocate + * as a result of using a cert from anchorCerts or dbList) are added + * to this group. + */ + TPCertGroup &certsToBeFreed, + + /* + * Other certificates gathered during the course of this operation, + * currently consisting of certs fetched from DBs and from the net. + * This is not used when called by AppleTPSession::CertGroupConstructPriv; + * it's an optimization for the case when we're building a cert group + * for TPCrlInfo::verifyWithContext - we avoid re-fetching certs from + * the net which are needed to verify both the subject cert and a CRL. + */ + TPCertGroup *gatheredCerts, + + /* + * Indicates that subjectItem is the last element in this cert group. + * If true, that cert will be tested for "root-ness", including + * -- subject/issuer compare + * -- signature self-verify + * -- anchor compare + */ + CSSM_BOOL subjectIsInGroup, + + /* currently, only CSSM_TP_ACTION_FETCH_CERT_FROM_NET is + * interesting */ + CSSM_APPLE_TP_ACTION_FLAGS actionFlags, + + /* returned */ + CSSM_BOOL &verifiedToRoot, // end of chain self-verifies + CSSM_BOOL &verifiedToAnchor); // end of chain in anchors + /* add/remove/access TPTCertInfo's. */ void appendCert( TPCertInfo *certInfo); // appends to end of mCertInfo @@ -173,8 +414,9 @@ public: TPCertInfo *removeCertAtIndex( unsigned index); // doesn't delete the cert, just // removes it from our list - unsigned numCerts(); // how many do we have? - + unsigned numCerts() const // how many do we have? + { return mNumCerts; } + /* * Convenience accessors for first and last cert, only valid when we have * at least one cert. @@ -203,10 +445,40 @@ public: CssmAllocator &alloc() {return mAlloc; } + /* set all TPCertInfo.mUsed flags false */ + void setAllUnused(); + private: + + /* + * Search unused incoming certs to find an issuer of specified + * cert or CRL. + * WARNING this assumes a valied "used" state for all certs + * in this group. + * If partialIssuerKey is true on return, caller must re-verify signature + * of subject later when sufficient info is available. + */ + TPCertInfo *findIssuerForCertOrCrl( + const TPClItemInfo &subject, + bool &partialIssuerKey); + + /* + * Called from buildCertGroup as final processing of a constructed + * group when CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE has been + * detected. Perform partial public key processing. + * Returns: + * CSSMERR_TP_CERTIFICATE_CANT_OPERATE - can't complete partial key + * CSSMERR_TP_INVALID_CERT_AUTHORITY - sig verify failed with + * (supposedly) completed partial key + */ + CSSM_RETURN verifyWithPartialKeys( + const TPClItemInfo &subjectItem); // Cert or CRL + CssmAllocator &mAlloc; TPCertInfo **mCertInfo; // just an array of pointers unsigned mNumCerts; // valid certs in certInfo unsigned mSizeofCertInfo; // mallocd space in certInfo + TPGroupOwner mWhoOwns; // if TGO_Group, we delete certs + // upon destruction }; #endif /* _TP_CERT_INFO_H_ */ diff --git a/AppleX509TP/TPCrlInfo.cpp b/AppleX509TP/TPCrlInfo.cpp new file mode 100644 index 00000000..bae007ad --- /dev/null +++ b/AppleX509TP/TPCrlInfo.cpp @@ -0,0 +1,723 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * TPCrlInfo.h - TP's private CRL and CRL group + * + * Written 9/30/2002 by Doug Mitchell. + */ + +#include "TPCrlInfo.h" +#include "tpdebugging.h" +#include "certGroupUtils.h" +#include "tpCrlVerify.h" +#include "tpPolicies.h" +#include +#include +#include +#include +#include /* for memcmp */ +#include + +/* + * Replacement for CSSM_CL_CrlGetFirstCachedFieldValue for use with + * TPCrlItemInfo's generic getFirstCachedField mechanism. + */ +static CSSM_RETURN tpGetFirstCachedFieldValue (CSSM_CL_HANDLE CLHandle, + CSSM_HANDLE CrlHandle, + const CSSM_OID *CrlField, + CSSM_HANDLE_PTR ResultsHandle, + uint32 *NumberOfMatchedFields, + CSSM_DATA_PTR *Value) +{ + return CSSM_CL_CrlGetFirstCachedFieldValue(CLHandle, + CrlHandle, + NULL, // const CSSM_DATA *CrlRecordIndex, + CrlField, + ResultsHandle, + NumberOfMatchedFields, + Value); +} + +static const TPClItemCalls tpCrlClCalls = +{ + tpGetFirstCachedFieldValue, + CSSM_CL_CrlAbortQuery, + CSSM_CL_CrlCache, + CSSM_CL_CrlAbortCache, + CSSM_CL_CrlVerify, + &CSSMOID_X509V1CRLThisUpdate, + &CSSMOID_X509V1CRLNextUpdate, + CSSMERR_TP_INVALID_CRL_POINTER, + CSSMERR_APPLETP_CRL_EXPIRED, + CSSMERR_APPLETP_CRL_NOT_VALID_YET +}; + + +/* + * No default constructor - this is the only way. + * This caches the cert and fetches subjectName and issuerName + * to ensure the incoming certData is well-constructed. + */ +TPCrlInfo::TPCrlInfo( + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const CSSM_DATA *crlData, + TPItemCopy copyCrlData, // true: we copy, we free + // false - caller owns + const char *verifyTime) // = NULL + + : TPClItemInfo(clHand, cspHand, tpCrlClCalls, crlData, + copyCrlData, verifyTime), + mRefCount(0), + mToBeDeleted(false), + mFromWhere(CFW_Nowhere), + mX509Crl(NULL), + mCrlFieldToFree(NULL), + mVerifyState(CVS_Unknown), + mVerifyError(CSSMERR_TP_INTERNAL_ERROR) +{ + CSSM_RETURN crtn; + + mUri.Data = NULL; + mUri.Length = 0; + + /* fetch parsed CRL */ + crtn = fetchField(&CSSMOID_X509V2CRLSignedCrlCStruct, &mCrlFieldToFree); + if(crtn) { + /* bad CRL */ + releaseResources(); + CssmError::throwMe(crtn); + } + if(mCrlFieldToFree->Length != sizeof(CSSM_X509_SIGNED_CRL)) { + tpErrorLog("fetchField(SignedCrlCStruct) length error\n"); + releaseResources(); + CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); + } + mX509Crl = (CSSM_X509_SIGNED_CRL *)mCrlFieldToFree->Data; + /* any other other commonly used fields? */ +} + +TPCrlInfo::~TPCrlInfo() +{ + releaseResources(); +} + +void TPCrlInfo::releaseResources() +{ + if(mCrlFieldToFree) { + freeField(&CSSMOID_X509V2CRLSignedCrlCStruct, mCrlFieldToFree); + mCrlFieldToFree = NULL; + } + if(mUri.Data) { + CssmAllocator::standard().free(mUri.Data); + mUri.Data = NULL; + mUri.Length = 0; + } + TPClItemInfo::releaseResources(); +} + +void TPCrlInfo::uri(const CSSM_DATA &uri) +{ + tpCopyCssmData(CssmAllocator::standard(), &uri, &mUri); +} + +/* + * List of extensions we understand and can accept as critical. + */ +static const CSSM_OID *const TPGoodCrlExtens[] = +{ + &CSSMOID_CrlNumber, + /* Note NOT CSSMOID_DeltaCrlIndicator! That's fatal */ + &CSSMOID_CrlReason, + &CSSMOID_CertIssuer, + &CSSMOID_IssuingDistributionPoint, + &CSSMOID_HoldInstructionCode, + &CSSMOID_InvalidityDate, + &CSSMOID_AuthorityKeyIdentifier, + &CSSMOID_SubjectAltName, + &CSSMOID_IssuerAltName +}; + +#define NUM_KNOWN_EXTENS (sizeof(TPGoodCrlExtens) / sizeof(CSSM_OID_PTR)) + +/* + * Do our best to understand all the entries in a CSSM_X509_EXTENSIONS, + * which may be per-CRL or per-entry. + * + * For now, we just ensure that for every critical extension, + * we actually understand it and can deal it. + */ +CSSM_RETURN TPCrlInfo::parseExtensions( + TPCrlVerifyContext &vfyCtx, + bool isPerEntry, + uint32 entryIndex, // if isPerEntry + const CSSM_X509_EXTENSIONS &extens, + TPCertInfo *forCert, // optional + bool &isIndirectCrl) // RETURNED +{ + isIndirectCrl = false; + for(uint32 dex=0; dexcritical) { + /* critical: is it in our list of understood extensions? */ + unsigned i; + for(i=0; iextnId, TPGoodCrlExtens[i])) { + /* we're cool with this one */ + break; + } + } + if(i == NUM_KNOWN_EXTENS) { + tpCrlDebug("parseExtensions: Unknown Critical Extension\n"); + return CSSMERR_APPLETP_UNKNOWN_CRL_EXTEN; + } + } + + /* Specific extension handling. */ + if(tpCompareOids(&exten->extnId, + &CSSMOID_IssuingDistributionPoint)) { + /* + * If this assertion fails, we're out of sync with the CL + */ + assert(exten->format == CSSM_X509_DATAFORMAT_PAIR); + CE_IssuingDistributionPoint *idp = + (CE_IssuingDistributionPoint *) + exten->value.parsedValue; + + /* + * Snag indirectCrl flag for caller in any case + */ + if(idp->indirectCrlPresent && idp->indirectCrl) { + isIndirectCrl = true; + } + if(forCert != NULL) { + /* If no target cert, i.e., we're just verifying a CRL, + * skip the remaining IDP checks. */ + + /* verify onlyCACerts/onlyUserCerts */ + bool isUserCert; + if(forCert->isLeaf() && + !(vfyCtx.actionFlags && CSSM_TP_ACTION_LEAF_IS_CA)) { + isUserCert = true; + } + else { + isUserCert = false; + } + if((idp->onlyUserCertsPresent) && (idp->onlyUserCerts)) { + if(!isUserCert) { + tpCrlDebug("parseExtensions: onlyUserCerts, " + "!leaf\n"); + return CSSMERR_APPLETP_IDP_FAIL; + } + } + if((idp->onlyCACertsPresent) && (idp->onlyCACerts)) { + if(isUserCert) { + tpCrlDebug("parseExtensions: onlyCACerts, leaf\n"); + return CSSMERR_APPLETP_IDP_FAIL; + } + } + } /* IDP */ + } /* have target cert */ + } + + return CSSM_OK; +} + +/* + * The heavyweight "perform full verification of this CRL" op. + * Must verify to an anchor cert in tpVerifyContext. + * Intermediate certs can come from signerCerts or dBList. + */ +CSSM_RETURN TPCrlInfo::verifyWithContext( + TPCrlVerifyContext &tpVerifyContext, + TPCertInfo *forCert, // optional + bool doCrlVerify) +{ + /* + * Step 1: this CRL must be current. Caller might have re-evaluated + * expired/notValidYet since our construction via calculateCurrent(). + */ + if(isExpired()) { + return CSSMERR_APPLETP_CRL_EXPIRED; + } + if(isNotValidYet()) { + return CSSMERR_APPLETP_CRL_NOT_VALID_YET; + } + + /* subsequent verify state is cached */ + switch(mVerifyState) { + case CVS_Good: + return CSSM_OK; + case CVS_Bad: + return mVerifyError; + case CVS_Unknown: + break; + default: + tpErrorLog("verifyWithContext: bad verifyState\n"); + return CSSMERR_TP_INTERNAL_ERROR; + } + + /* + * Step 2: parse & understand all critical CRL extensions. + */ + CSSM_RETURN crtn; + bool isIndirectCrl; + crtn = parseExtensions(tpVerifyContext, + false, + 0, + mX509Crl->tbsCertList.extensions, + forCert, + isIndirectCrl); + if(crtn) { + mVerifyState = CVS_Bad; + if(forCert) { + forCert->addStatusCode(crtn); + } + return crtn; + } + CSSM_X509_REVOKED_CERT_LIST_PTR revoked = + mX509Crl->tbsCertList.revokedCertificates; + if(revoked != NULL) { + for(uint32 dex=0; dexnumberOfRevokedCertEntries; dex++) { + bool dummyIsIndirect; // can't be set here + crtn = parseExtensions(tpVerifyContext, + true, + dex, + revoked->revokedCertEntry[dex].extensions, + forCert, + dummyIsIndirect); + if(crtn) { + mVerifyState = CVS_Bad; + if(forCert) { + forCert->addStatusCode(crtn); + } + return crtn; + } + } + } + + /* + * Step 3: obtain a fully verified cert chain which verifies this CRL. + */ + CSSM_BOOL verifiedToRoot; + CSSM_BOOL verifiedToAnchor; + + TPCertGroup outCertGroup(tpVerifyContext.alloc, + TGO_Caller); // CRLs owned by inCertGroup + + /* set up for disposal of TPCertInfos created by + * CertGroupConstructPriv */ + TPCertGroup certsToBeFreed(tpVerifyContext.alloc, TGO_Group); + + if(tpVerifyContext.signerCerts) { + /* start from scratch with this group */ + tpVerifyContext.signerCerts->setAllUnused(); + } + crtn = outCertGroup.buildCertGroup( + *this, // subject item + tpVerifyContext.signerCerts, // inCertGroup, optional + tpVerifyContext.dbList, // optional + tpVerifyContext.clHand, + tpVerifyContext.cspHand, + tpVerifyContext.verifyTime, + tpVerifyContext.numAnchorCerts, + tpVerifyContext.anchorCerts, + certsToBeFreed, + tpVerifyContext.gatheredCerts, + CSSM_FALSE, // subjectIsInGroup + tpVerifyContext.actionFlags, + verifiedToRoot, + verifiedToAnchor); + if(crtn) { + tpCrlDebug("TPCrlInfo::verifyWithContext buildCertGroup failure " + "index %u", index()); + if(forCert) { + forCert->addStatusCode(crtn); + } + return crtn; + } + if(!verifiedToAnchor) { + /* required */ + mVerifyState = CVS_Bad; + if(verifiedToRoot) { + /* verified to root which is not an anchor */ + tpCrlDebug("TPCrlInfo::verifyWithContext root, no anchor, " + "index %u", index()); + crtn = CSSMERR_APPLETP_CRL_INVALID_ANCHOR_CERT; + } + else { + /* partial chain, no root, not verifiable by anchor */ + tpCrlDebug("TPCrlInfo::verifyWithContext no root, no anchor, " + "index %u", index()); + crtn = CSSMERR_APPLETP_CRL_NOT_TRUSTED; + } + if(forCert) { + forCert->addStatusCode(crtn); + } + return crtn; + } + + /* + * Step 4: policy verification on the returned cert group + * We need to (temporarily) assert the "leaf cert is a CA" flag + * here. + */ + outCertGroup.certAtIndex(0)->isLeaf(true); + crtn = tp_policyVerify(kCrlPolicy, + tpVerifyContext.alloc, + tpVerifyContext.clHand, + tpVerifyContext.cspHand, + &outCertGroup, + verifiedToRoot, + tpVerifyContext.actionFlags | CSSM_TP_ACTION_LEAF_IS_CA, + NULL, // sslOpts + NULL); // policyOpts, not currently used + if(crtn) { + tpCrlDebug(" ...verifyWithContext policy FAILURE CRL %u", + index()); + if(forCert) { + forCert->addStatusCode(CSSMERR_APPLETP_CRL_POLICY_FAIL); + } + mVerifyState = CVS_Bad; + return crtn; + } + + /* + * Step 5: recursively perform CRL verification on the certs + * gathered to verify this CRL. + * Only performed if this CRL is an indirect CRL or the caller + * explicitly told us to do this (i.e., caller is verifying a + * CRL, not a cert chain). + */ + if(isIndirectCrl || doCrlVerify) { + tpCrlDebug("verifyWithContext recursing to " + "tpVerifyCertGroupWithCrls"); + crtn = tpVerifyCertGroupWithCrls(outCertGroup, + tpVerifyContext); + if(crtn) { + tpCrlDebug(" ...verifyWithContext CRL reverify FAILURE CRL %u", + index()); + if(forCert) { + forCert->addStatusCode(crtn); + } + mVerifyState = CVS_Bad; + return crtn; + } + } + + tpCrlDebug(" ...verifyWithContext CRL %u SUCCESS", index()); + mVerifyState = CVS_Good; + return crtn; +} + +/* + * Do I have the same issuer as the specified subject cert? Returns + * true if so. + */ +bool TPCrlInfo::hasSameIssuer( + const TPCertInfo &subject) +{ + assert(subject.issuerName() != NULL); + if(tpCompareCssmData(issuerName(), subject.issuerName())) { + return true; + } + else { + return false; + } +} + +/* + * Determine if specified cert has been revoked. Assumes that + * the current CRL has been fully verified. + * + * Assumes current CRL is verified good and that issuer names of + * the cert and CRL match. + * + * This duplicates similar logic in the CL, but to avoid re-parsing + * the subject cert (which we have parsed and cached), we just do it + * here. + * + * Possible errors are + * CSSMERR_TP_CERT_REVOKED + * CSSMERR_TP_CERT_SUSPENDED + * TBD + * + * Error status is added to subjectCert. + */ +CSSM_RETURN TPCrlInfo::isCertRevoked( + TPCertInfo &subjectCert) +{ + assert(mVerifyState == CVS_Good); + CSSM_X509_TBS_CERTLIST_PTR tbs = &mX509Crl->tbsCertList; + + /* trivial case - empty CRL */ + if((tbs->revokedCertificates == NULL) || + (tbs->revokedCertificates->numberOfRevokedCertEntries == 0)) { + tpCrlDebug(" isCertRevoked: empty CRL at index %u", index()); + return CSSM_OK; + } + + /* is subject cert's serial number in this CRL? */ + CSSM_DATA_PTR subjSerial = NULL; + CSSM_RETURN crtn; + crtn = subjectCert.fetchField(&CSSMOID_X509V1SerialNumber, &subjSerial); + if(crtn) { + /* should never happen */ + tpErrorLog("TPCrlInfo:isCertRevoked: error fetching serial number\n"); + subjectCert.addStatusCode(crtn); + return crtn; + } + /* subsequent errors to errOut: */ + + uint32 numEntries = tbs->revokedCertificates->numberOfRevokedCertEntries; + CSSM_X509_REVOKED_CERT_ENTRY_PTR entries = + tbs->revokedCertificates->revokedCertEntry; + crtn = CSSM_OK; + for(uint32 dex=0; dexcertificateSerialNumber)) { + /* + * It's in there. + * FIXME: we're assuming that we don't have to compare + * the "current verification time" (the verifyTime argument + * to both our and the TPCertInfo's constructor) to this + * entry's revocationDate. That would imply that a CRL could + * contain a future revocation, and I don't think that + * X509//RFC2459 intends this. + */ + /* + * REQUIRED TBD: parse the entry's extensions, specifically to + * get a reason. This will entail a bunch of new TP/cert specific + * CSSM_RETURNS. + * For now, just flag it revoked. + */ + crtn = CSSMERR_TP_CERT_REVOKED; + tpCrlDebug(" isCertRevoked: cert %u REVOKED by CRL %u", + subjectCert.index(), index()); + break; + } + } + + subjectCert.freeField(&CSSMOID_X509V1SerialNumber, subjSerial); + if(crtn) { + subjectCert.addStatusCode(crtn); + } + return crtn; +} + +/*** + *** TPCrlGroup class + ***/ + +/* build empty group */ +TPCrlGroup::TPCrlGroup( + CssmAllocator &alloc, + TPGroupOwner whoOwns) : + mAlloc(alloc), + mCrlInfo(NULL), + mNumCrls(0), + mSizeofCrlInfo(0), + mWhoOwns(whoOwns) +{ + /* nothing for now */ +} + +/* + * Construct from unordered, untrusted CSSM_CRLGROUP. Resulting + * TPCrlInfos are more or less in the same order as the incoming + * CRLs, though incoming CRLs are discarded if they don't parse. + * No verification of any sort is performed. + */ +TPCrlGroup::TPCrlGroup( + const CSSM_CRLGROUP *cssmCrlGroup, // optional + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + CssmAllocator &alloc, + const char *verifyTime, // may be NULL + TPGroupOwner whoOwns) : + mAlloc(alloc), + mCrlInfo(NULL), + mNumCrls(0), + mSizeofCrlInfo(0), + mWhoOwns(whoOwns) +{ + /* verify input args */ + if((cssmCrlGroup == NULL) || (cssmCrlGroup->NumberOfCrls == 0)) { + return; + } + if(cspHand == CSSM_INVALID_HANDLE) { + CssmError::throwMe(CSSMERR_TP_INVALID_CSP_HANDLE); + } + if(clHand == CSSM_INVALID_HANDLE) { + CssmError::throwMe(CSSMERR_TP_INVALID_CL_HANDLE); + } + if(cssmCrlGroup->CrlGroupType != CSSM_CRLGROUP_DATA) { + CssmError::throwMe(CSSMERR_TP_INVALID_CERTGROUP); + } + switch(cssmCrlGroup->CrlType) { + case CSSM_CRL_TYPE_X_509v1: + case CSSM_CRL_TYPE_X_509v2: + break; + default: + CssmError::throwMe(CSSMERR_TP_UNKNOWN_FORMAT); + } + switch(cssmCrlGroup->CrlEncoding) { + case CSSM_CRL_ENCODING_BER: + case CSSM_CRL_ENCODING_DER: + break; + default: + CssmError::throwMe(CSSMERR_TP_UNKNOWN_FORMAT); + } + + /* + * Add remaining input certs to mCrlInfo. + */ + TPCrlInfo *crlInfo = NULL; + for(unsigned crlDex=0; crlDexNumberOfCrls; crlDex++) { + try { + crlInfo = new TPCrlInfo(clHand, + cspHand, + &cssmCrlGroup->GroupCrlList.CrlList[crlDex], + TIC_NoCopy, // don't copy data + verifyTime); + } + catch (...) { + /* just ignore this CRL */ + continue; + } + crlInfo->index(crlDex); + appendCrl(*crlInfo); + } +} + +/* + * Deletes all TPCrlInfo's if appropriate. + */ +TPCrlGroup::~TPCrlGroup() +{ + if(mWhoOwns == TGO_Group) { + unsigned i; + for(i=0; i here, but + * gdb is so lame that it doesn't even let one examine the contents + * of an array<> (or just about anything else in the STL). I prefer + * debuggability over saving a few lines of trivial code. + */ +void TPCrlGroup::appendCrl( + TPCrlInfo &crlInfo) +{ + if(mNumCrls == mSizeofCrlInfo) { + if(mSizeofCrlInfo == 0) { + /* appending to empty array */ + mSizeofCrlInfo = 1; + } + else { + mSizeofCrlInfo *= 2; + } + mCrlInfo = (TPCrlInfo **)mAlloc.realloc(mCrlInfo, + mSizeofCrlInfo * sizeof(TPCrlInfo *)); + } + mCrlInfo[mNumCrls++] = &crlInfo; +} + +TPCrlInfo *TPCrlGroup::crlAtIndex( + unsigned index) +{ + if(index > (mNumCrls - 1)) { + CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); + } + return mCrlInfo[index]; +} + +TPCrlInfo &TPCrlGroup::removeCrlAtIndex( + unsigned index) // doesn't delete the cert, just + // removes it from our list +{ + if(index > (mNumCrls - 1)) { + CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); + } + TPCrlInfo &rtn = *mCrlInfo[index]; + + /* removed requested element and compact remaining array */ + unsigned i; + for(i=index; i<(mNumCrls - 1); i++) { + mCrlInfo[i] = mCrlInfo[i+1]; + } + mNumCrls--; + return rtn; +} + +void TPCrlGroup::removeCrl( + TPCrlInfo &crlInfo) +{ + for(unsigned dex=0; dexhasSameIssuer(subject)) { + return crl; + } + } + return NULL; +} diff --git a/AppleX509TP/TPCrlInfo.h b/AppleX509TP/TPCrlInfo.h new file mode 100644 index 00000000..7dd91d09 --- /dev/null +++ b/AppleX509TP/TPCrlInfo.h @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * TPCrlInfo.h - TP's private CRL and CRL group classes + * + * Written 9/25/2001 by Doug Mitchell. + */ + +#ifndef _TP_CRL_INFO_H_ +#define _TP_CRL_INFO_H_ + +#include +#include +#include +#include +#include +#include "TPCertInfo.h" +#include "tpCrlVerify.h" + +/* + * Verification state of a TPCrlInfo. Verification refers to the process + * of cert chain validation from the CRL to a trusted root. Since this + * is a rather heavyweight operation, this is done on demand, when a given + * CRL is "believed to be" the appropriate one for a given cert. It + * is separate from not before/after verification, which is performed + * on the fly as needed. + */ +typedef enum { + CVS_Unknown, // initial default state + CVS_Good, // known good + CVS_Bad // known bad +} TPCrlVerifyState; + +/* + * Indicates where a particular CRL came from. Currently only used + * in the tpCrlVerify module. + */ +typedef enum { + CFW_Nowhere, // default, never returned + CFW_InGroup, // from incoming TPCrlGroup + CFW_DlDb, // verifyContext.dbList + CFW_LocalCache, // tpGlobalCrlCache + CFW_Net, // tpFetchCrlFromNet + /* probably others */ +} TPCrlFromWhere; + + +/* + * Class representing one CRL. The raw CRL data usually comes from + * a client (via incoming CSSM_TP_VERIFY_CONTEXT.Crls); in this case, we + * don't own the raw data and don't copy or free it. Caller can + * optionally specify that we copy (and own and eventually free) the raw cert data. + * Currently this is only done when we find a CRL in a DlDb. The constructor throws + * on any error (bad CRL data); subsequent to successful construction, no CSSM + * errors are thrown and it's guaranteed that the CRL is basically readable and + * successfully cached in the CL, and that we have a locally cached + * CSSM_X509_SIGNED_CRL and issuer name (in normalized encoded format). + */ +class TPCrlInfo : public TPClItemInfo +{ + NOCOPY(TPCrlInfo) +public: + /* + * No default constructor - this is the only way. + */ + TPCrlInfo( + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const CSSM_DATA *crlData, + TPItemCopy copyCrlData, + const char *verifyTime); // NULL ==> time = right now + + /* frees mIssuerName, mCacheHand, mX509Crl via mClHand */ + ~TPCrlInfo(); + + /* + * The heavyweight "perform full verification" op. + * If doCrlVerify is true, we'll do an eventually recursive + * CRL verification test on the cert group we construct + * here to verify the CRL in question. This recursive + * verifdy is also done if the CRL is an indirect CRL. + * Currently, the doCrlVerifyFlag will be set false in the + * normal case of verifying a cert chain; in that case the + * various certs needed to verify the CRL are assumed to + * be a subset of the cert chain being verified, and CRL + * verification of that cert chain is being performed + * elsewhere. The caller would set doCrlVerify true when + * the top-level op is simply a CRL verify. + */ + CSSM_RETURN verifyWithContext( + TPCrlVerifyContext &tpVerifyContext, + TPCertInfo *forCert, // optional + bool doCrlVerify = false); + + /* + * Do I have the same issuer as the specified subject cert? + * Returns true if so. + */ + bool TPCrlInfo::hasSameIssuer( + const TPCertInfo &subject); + + /* + * Determine if specified cert has been revoked. Assumes that + * the current CRL has been fully verified. + */ + CSSM_RETURN isCertRevoked( + TPCertInfo &subjectCert); + + /* accessors */ + const CSSM_X509_SIGNED_CRL *x509Crl() { return mX509Crl; } + TPCrlVerifyState verifyState() { return mVerifyState; } + + const CSSM_DATA *uri() { return &mUri; } + void uri(const CSSM_DATA &uri); + + /* + * Ref count info maintained by caller (currently only in + * tpCrlVfy.cpp's global cache module). + */ + int mRefCount; + bool mToBeDeleted; + + /* used only by tpCrlVerify */ + TPCrlFromWhere mFromWhere; + + +private: + CSSM_X509_SIGNED_CRL *mX509Crl; + CSSM_DATA_PTR mCrlFieldToFree; + TPCrlVerifyState mVerifyState; + CSSM_RETURN mVerifyError; // only if mVerifyState = CVS_Bad + CSSM_DATA mUri; // if fetched from net + + void releaseResources(); + CSSM_RETURN parseExtensions( + TPCrlVerifyContext &tpVerifyContext, + bool isPerEntry, + uint32 entryIndex, // if isPerEntry + const CSSM_X509_EXTENSIONS &extens, + TPCertInfo *forCert, // optional + bool &isIndirectCrl);// RETURNED + +}; + +/* + * TP's private CRL Group class. + */ +class TPCrlGroup +{ + NOCOPY(TPCrlGroup) +public: + /* construct empty CRL group */ + TPCrlGroup( + CssmAllocator &alloc, + TPGroupOwner whoOwns); // if TGO_Group, we delete + + /* + * Construct from unordered, untrusted CSSM_CRLGROUP. Resulting + * TPCrlInfos are more or less in the same order as the incoming + * CRLs, though incoming CRLs are discarded if they don't parse. + * No verification of any sort is performed. + */ + TPCrlGroup( + const CSSM_CRLGROUP *cssmCrlGroup, // optional + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + CssmAllocator &alloc, + const char *cssmTimeStr, // may be NULL + TPGroupOwner whoOwns); + + /* + * Deletes all TPCrlInfo's. + */ + ~TPCrlGroup(); + + /* add/remove/access TPCrlInfo's. */ + void appendCrl( + TPCrlInfo &crlInfo); // appends to end of mCertInfo + TPCrlInfo *crlAtIndex( + unsigned index); + TPCrlInfo &removeCrlAtIndex( + unsigned index); // doesn't delete the cert, just + // removes it from our list + void removeCrl( + TPCrlInfo &crlInfo); // ditto + + /* + * Convenience accessors for first and last CRL, only valid when we have + * at least one cert. + */ + TPCrlInfo *firstCrl(); + TPCrlInfo *lastCrl(); + + /* + * Find a CRL whose issuer matches specified subject cert. + * Returned CRL has not necessarily been verified. + */ + TPCrlInfo *findCrlForCert( + TPCertInfo &subject); + + CssmAllocator &alloc() { return mAlloc; } + unsigned numCrls() { return mNumCrls; } + +private: + CssmAllocator &mAlloc; + TPCrlInfo **mCrlInfo; // just an array of pointers + unsigned mNumCrls; // valid certs in certInfo + unsigned mSizeofCrlInfo; // mallocd space in certInfo + TPGroupOwner mWhoOwns; // if TGO_Group, we delete CRLs + // upon destruction +}; +#endif /* _TP_CRL_INFO_H_ */ + diff --git a/AppleX509TP/TPDatabase.cpp b/AppleX509TP/TPDatabase.cpp new file mode 100644 index 00000000..ba471d05 --- /dev/null +++ b/AppleX509TP/TPDatabase.cpp @@ -0,0 +1,706 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * TPDatabase.cpp - TP's DL/DB access functions. + * + * Created 10/9/2002 by Doug Mitchell. + */ + +#include +#include +#include /* private API */ +#include /* private SecInferLabelFromX509Name() */ +#include +#include +#include "TPDatabase.h" +#include "tpdebugging.h" +#include "certGroupUtils.h" +#include "TPCertInfo.h" +#include "TPCrlInfo.h" +#include "tpCrlVerify.h" +#include "tpTime.h" + + +/* + * Given a DL/DB, look up cert by subject name. Subsequent + * certs can be found using the returned result handle. + */ +static CSSM_DB_UNIQUE_RECORD_PTR tpCertLookup( + CSSM_DL_DB_HANDLE dlDb, + const CSSM_DATA *subjectName, // DER-encoded + CSSM_HANDLE_PTR resultHand, // RETURNED + CSSM_DATA_PTR cert) // RETURNED +{ + CSSM_QUERY query; + CSSM_SELECTION_PREDICATE predicate; + CSSM_DB_UNIQUE_RECORD_PTR record = NULL; + + cert->Data = NULL; + cert->Length = 0; + + /* SWAG until cert schema nailed down */ + predicate.DbOperator = CSSM_DB_EQUAL; + predicate.Attribute.Info.AttributeNameFormat = + CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + predicate.Attribute.Info.Label.AttributeName = "Subject"; + predicate.Attribute.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + predicate.Attribute.Value = const_cast(subjectName); + predicate.Attribute.NumberOfValues = 1; + + query.RecordType = CSSM_DL_DB_RECORD_X509_CERTIFICATE; + query.Conjunctive = CSSM_DB_NONE; + query.NumSelectionPredicates = 1; + query.SelectionPredicate = &predicate; + query.QueryLimits.TimeLimit = 0; // FIXME - meaningful? + query.QueryLimits.SizeLimit = 1; // FIXME - meaningful? + query.QueryFlags = 0; // FIXME - used? + + CSSM_DL_DataGetFirst(dlDb, + &query, + resultHand, + NULL, // don't fetch attributes + cert, + &record); + return record; +} + +/* + * Search a list of DBs for a cert which verifies specified subject item. + * Just a boolean return - we found it, or not. If we did, we return + * TPCertInfo associated with the raw cert. + * A true partialIssuerKey on return indicates that caller must deal + * with partial public key processing later. + */ +TPCertInfo *tpDbFindIssuerCert( + CssmAllocator &alloc, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const TPClItemInfo *subjectItem, + const CSSM_DL_DB_LIST *dbList, + const char *verifyTime, // may be NULL + bool &partialIssuerKey) // RETURNED +{ + uint32 dbDex; + CSSM_HANDLE resultHand; + CSSM_DATA cert; + CSSM_DL_DB_HANDLE dlDb; + CSSM_DB_UNIQUE_RECORD_PTR record; + TPCertInfo *issuerCert = NULL; + bool foundIt; + + partialIssuerKey = false; + if(dbList == NULL) { + return NULL; + } + for(dbDex=0; dbDexNumHandles; dbDex++) { + dlDb = dbList->DLDBHandle[dbDex]; + cert.Data = NULL; + cert.Length = 0; + record = tpCertLookup(dlDb, + subjectItem->issuerName(), + &resultHand, + &cert); + /* remember we have to: + * -- abort this query regardless, and + * -- free the CSSM_DATA cert regardless, and + * -- free the unique record if we don't use it + * (by placing it in issuerCert)... + */ + if(record != NULL) { + /* Found one */ + assert(cert.Data != NULL); + issuerCert = new TPCertInfo(clHand, cspHand, &cert, TIC_CopyData, verifyTime); + /* we're done with raw cert data */ + /* FIXME this assumes that alloc is the same as the + * allocator associated with DlDB...OK? */ + tpFreeCssmData(alloc, &cert, CSSM_FALSE); + cert.Data = NULL; + cert.Length = 0; + + /* Does it verify the subject cert? */ + CSSM_RETURN crtn = subjectItem->verifyWithIssuer(issuerCert); + switch(crtn) { + case CSSM_OK: + break; + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: + partialIssuerKey = true; + break; + default: + delete issuerCert; + issuerCert = NULL; + CSSM_DL_FreeUniqueRecord(dlDb, record); + + /* + * Verify fail. Continue searching this DB. Break on + * finding the holy grail or no more records found. + */ + for(;;) { + cert.Data = NULL; + cert.Length = 0; + CSSM_RETURN crtn = CSSM_DL_DataGetNext(dlDb, + resultHand, + NULL, // no attrs + &cert, + &record); + if(crtn) { + /* no more, done with this DB */ + assert(cert.Data == NULL); + break; + } + assert(cert.Data != NULL); + + /* found one - does it verify subject? */ + issuerCert = new TPCertInfo(clHand, cspHand, &cert, TIC_CopyData, + verifyTime); + /* we're done with raw cert data */ + tpFreeCssmData(alloc, &cert, CSSM_FALSE); + cert.Data = NULL; + cert.Length = 0; + + /* FIXME - figure out allowExpire, etc. */ + crtn = subjectItem->verifyWithIssuer(issuerCert); + foundIt = false; + switch(crtn) { + case CSSM_OK: + foundIt = true; + break; + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: + partialIssuerKey = true; + foundIt = true; + break; + default: + break; + } + if(foundIt) { + /* yes! */ + break; + } + delete issuerCert; + CSSM_DL_FreeUniqueRecord(dlDb, record); + issuerCert = NULL; + } /* searching subsequent records */ + } /* switch verify */ + + if(issuerCert != NULL) { + /* successful return */ + tpDebug("tpDbFindIssuer: found cert record %p", record); + CSSM_DL_DataAbortQuery(dlDb, resultHand); + issuerCert->dlDbHandle(dlDb); + issuerCert->uniqueRecord(record); + return issuerCert; + } + } /* tpCertLookup, i.e., CSSM_DL_DataGetFirst, succeeded */ + else { + assert(cert.Data == NULL); + } + /* in any case, abort the query for this db */ + CSSM_DL_DataAbortQuery(dlDb, resultHand); + + } /* main loop searching dbList */ + + /* issuer not found */ + return NULL; +} + +/* + * Given a DL/DB, look up CRL by issuer name and validity time. + * Subsequent CRLs can be found using the returned result handle. + */ +#define SEARCH_BY_DATE 1 + +static CSSM_DB_UNIQUE_RECORD_PTR tpCrlLookup( + CSSM_DL_DB_HANDLE dlDb, + const CSSM_DATA *issuerName, // DER-encoded + CSSM_TIMESTRING verifyTime, // may be NULL, implies "now" + CSSM_HANDLE_PTR resultHand, // RETURNED + CSSM_DATA_PTR crl) // RETURNED +{ + CSSM_QUERY query; + CSSM_SELECTION_PREDICATE pred[3]; + CSSM_DB_UNIQUE_RECORD_PTR record = NULL; + char timeStr[CSSM_TIME_STRLEN + 1]; + + crl->Data = NULL; + crl->Length = 0; + + /* Three predicates...first, the issuer name */ + pred[0].DbOperator = CSSM_DB_EQUAL; + pred[0].Attribute.Info.AttributeNameFormat = + CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + pred[0].Attribute.Info.Label.AttributeName = "Issuer"; + pred[0].Attribute.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + pred[0].Attribute.Value = const_cast(issuerName); + pred[0].Attribute.NumberOfValues = 1; + + /* now before/after. Cook up an appropriate time string. */ + if(verifyTime != NULL) { + /* Caller spec'd tolerate any format */ + int rtn = tpTimeToCssmTimestring(verifyTime, strlen(verifyTime), timeStr); + if(rtn) { + tpErrorLog("tpCrlLookup: Invalid VerifyTime string\n"); + return NULL; + } + } + else { + /* right now */ + StLock _(tpTimeLock()); + timeAtNowPlus(0, TIME_CSSM, timeStr); + } + CSSM_DATA timeData; + timeData.Data = (uint8 *)timeStr; + timeData.Length = CSSM_TIME_STRLEN; + + #if SEARCH_BY_DATE + pred[1].DbOperator = CSSM_DB_LESS_THAN; + pred[1].Attribute.Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + pred[1].Attribute.Info.Label.AttributeName = "NextUpdate"; + pred[1].Attribute.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + pred[1].Attribute.Value = &timeData; + pred[1].Attribute.NumberOfValues = 1; + + pred[2].DbOperator = CSSM_DB_GREATER_THAN; + pred[2].Attribute.Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + pred[2].Attribute.Info.Label.AttributeName = "ThisUpdate"; + pred[2].Attribute.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + pred[2].Attribute.Value = &timeData; + pred[2].Attribute.NumberOfValues = 1; + #endif + + query.RecordType = CSSM_DL_DB_RECORD_X509_CRL; + query.Conjunctive = CSSM_DB_AND; + #if SEARCH_BY_DATE + query.NumSelectionPredicates = 3; + #else + query.NumSelectionPredicates = 1; + #endif + query.SelectionPredicate = pred; + query.QueryLimits.TimeLimit = 0; // FIXME - meaningful? + query.QueryLimits.SizeLimit = 1; // FIXME - meaningful? + query.QueryFlags = 0; // FIXME - used? + + CSSM_DL_DataGetFirst(dlDb, + &query, + resultHand, + NULL, // don't fetch attributes + crl, + &record); + return record; +} + +/* + * Search a list of DBs for a CRL from the specified issuer and (optional) + * TPCrlVerifyContext.verifyTime. + * Just a boolean return - we found it, or not. If we did, we return a + * TPCrlInfo which has been verified with the specified TPCrlVerifyContext. + */ +TPCrlInfo *tpDbFindIssuerCrl( + TPCrlVerifyContext &vfyCtx, + const CSSM_DATA &issuer, + TPCertInfo &forCert) +{ + uint32 dbDex; + CSSM_HANDLE resultHand; + CSSM_DATA crl; + CSSM_DL_DB_HANDLE dlDb; + CSSM_DB_UNIQUE_RECORD_PTR record; + TPCrlInfo *issuerCrl = NULL; + CSSM_DL_DB_LIST_PTR dbList = vfyCtx.dbList; + CSSM_RETURN crtn; + + if(dbList == NULL) { + return NULL; + } + for(dbDex=0; dbDexNumHandles; dbDex++) { + dlDb = dbList->DLDBHandle[dbDex]; + crl.Data = NULL; + crl.Length = 0; + record = tpCrlLookup(dlDb, + &issuer, + vfyCtx.verifyTime, + &resultHand, + &crl); + /* remember we have to: + * -- abort this query regardless, and + * -- free the CSSM_DATA crl regardless, and + * -- free the unique record if we don't use it + * (by placing it in issuerCert)... + */ + if(record != NULL) { + /* Found one */ + assert(crl.Data != NULL); + issuerCrl = new TPCrlInfo(vfyCtx.clHand, + vfyCtx.cspHand, + &crl, + TIC_CopyData, + vfyCtx.verifyTime); + /* we're done with raw CRL data */ + /* FIXME this assumes that vfyCtx.alloc is the same as the + * allocator associated with DlDB...OK? */ + tpFreeCssmData(vfyCtx.alloc, &crl, CSSM_FALSE); + crl.Data = NULL; + crl.Length = 0; + + /* and we're done with the record */ + CSSM_DL_FreeUniqueRecord(dlDb, record); + + /* Does it verify with specified context? */ + crtn = issuerCrl->verifyWithContext(vfyCtx, &forCert); + if(crtn) { + + delete issuerCrl; + issuerCrl = NULL; + + /* + * Verify fail. Continue searching this DB. Break on + * finding the holy grail or no more records found. + */ + for(;;) { + crl.Data = NULL; + crl.Length = 0; + crtn = CSSM_DL_DataGetNext(dlDb, + resultHand, + NULL, // no attrs + &crl, + &record); + if(crtn) { + /* no more, done with this DB */ + assert(crl.Data == NULL); + break; + } + assert(crl.Data != NULL); + + /* found one - is it any good? */ + issuerCrl = new TPCrlInfo(vfyCtx.clHand, + vfyCtx.cspHand, + &crl, + TIC_CopyData, + vfyCtx.verifyTime); + /* we're done with raw CRL data */ + /* FIXME this assumes that vfyCtx.alloc is the same as the + * allocator associated with DlDB...OK? */ + tpFreeCssmData(vfyCtx.alloc, &crl, CSSM_FALSE); + crl.Data = NULL; + crl.Length = 0; + + CSSM_DL_FreeUniqueRecord(dlDb, record); + + crtn = issuerCrl->verifyWithContext(vfyCtx, &forCert); + if(crtn == CSSM_OK) { + /* yes! */ + break; + } + delete issuerCrl; + issuerCrl = NULL; + } /* searching subsequent records */ + } /* verify fail */ + /* else success! */ + + if(issuerCrl != NULL) { + /* successful return */ + CSSM_DL_DataAbortQuery(dlDb, resultHand); + tpDebug("tpDbFindIssuerCrl: found CRL record %p", record); + return issuerCrl; + } + } /* tpCrlLookup, i.e., CSSM_DL_DataGetFirst, succeeded */ + else { + assert(crl.Data == NULL); + } + /* in any case, abort the query for this db */ + CSSM_DL_DataAbortQuery(dlDb, resultHand); + + } /* main loop searching dbList */ + + /* issuer not found */ + return NULL; +} + +/* + * Update an existing DLDB to be CRL-capable. + */ +static CSSM_RETURN tpAddCrlSchema( + CSSM_DL_DB_HANDLE dlDbHand) +{ + return CSSM_DL_CreateRelation(dlDbHand, + CSSM_DL_DB_RECORD_X509_CRL, + "CSSM_DL_DB_RECORD_X509_CRL", + Security::KeychainCore::Schema::X509CrlSchemaAttributeCount, + Security::KeychainCore::Schema::X509CrlSchemaAttributeList, + Security::KeychainCore::Schema::X509CrlSchemaIndexCount, + Security::KeychainCore::Schema::X509CrlSchemaIndexList); +} + +/* + * Search extensions for specified OID, assumed to have underlying + * value type of uint32; returns the value and true if found. + */ +static bool tpSearchNumericExtension( + const CSSM_X509_EXTENSIONS *extens, + const CSSM_OID *oid, + uint32 *val) +{ + for(uint32 dex=0; dexnumberOfExtensions; dex++) { + const CSSM_X509_EXTENSION *exten = &extens->extensions[dex]; + if(!tpCompareOids(&exten->extnId, oid)) { + continue; + } + if(exten->format != CSSM_X509_DATAFORMAT_PAIR) { + tpErrorLog("***Malformed CRL extension\n"); + continue; + } + *val = *((uint32 *)exten->value.parsedValue); + return true; + } + return false; +} + +/* + * Store a CRL in a DLDB. + * We store the following attributes: + * + * CrlType + * CrlEncoding + * PrintName (Inferred from issuer) + * Issuer + * ThisUpdate + * NextUpdate + * URI (if present) + * CrlNumber (if present) + * DeltaCrlNumber (if present) + */ +#define MAX_CRL_ATTRS 9 + +CSSM_RETURN tpDbStoreCrl( + TPCrlInfo &crl, + CSSM_DL_DB_HANDLE &dlDbHand) +{ + CSSM_DB_ATTRIBUTE_DATA attrs[MAX_CRL_ATTRS]; + CSSM_DB_RECORD_ATTRIBUTE_DATA recordAttrs; + CSSM_DB_ATTRIBUTE_DATA_PTR attr = &attrs[0]; + CSSM_DATA crlTypeData; + CSSM_DATA crlEncData; + CSSM_RETURN crtn; + CSSM_DB_UNIQUE_RECORD_PTR recordPtr; + CSSM_CRL_ENCODING crlEnc = CSSM_CRL_ENCODING_DER; + const CSSM_X509_TBS_CERTLIST *tbsCrl; + CSSM_CRL_TYPE crlType; + CSSM_DATA thisUpdateData = {0, NULL}; + CSSM_DATA nextUpdateData = {0, NULL}; + char thisUpdate[CSSM_TIME_STRLEN+1]; + char nextUpdate[CSSM_TIME_STRLEN+1]; + uint32 crlNumber; + uint32 deltaCrlNumber; + CSSM_DATA crlNumberData; + CSSM_DATA deltaCrlNumberData; + bool crlNumberPresent = false; + bool deltaCrlPresent = false; + + tbsCrl = &(crl.x509Crl()->tbsCertList); + + /* CrlType inferred from version */ + if(tbsCrl->version.Length == 0) { + /* should never happen... */ + crlType = CSSM_CRL_TYPE_X_509v1; + } + else { + uint8 vers = tbsCrl->version.Data[tbsCrl->version.Length - 1]; + switch(vers) { + case 0: + crlType = CSSM_CRL_TYPE_X_509v1; + break; + case 1: + crlType = CSSM_CRL_TYPE_X_509v2; + break; + default: + tpErrorLog("***Unknown version in CRL (%u)\n", vers); + crlType = CSSM_CRL_TYPE_X_509v1; + break; + } + } + crlTypeData.Data = (uint8 *)&crlType; + crlTypeData.Length = sizeof(CSSM_CRL_TYPE); + /* encoding more-or-less assumed here */ + crlEncData.Data = (uint8 *)&crlEnc; + crlEncData.Length = sizeof(CSSM_CRL_ENCODING); + + /* printName inferred from issuer */ + CSSM_DATA printName; + const CSSM_DATA *printNamePtr; + printNamePtr = SecInferLabelFromX509Name(&tbsCrl->issuer); + if(printNamePtr) { + printName = *(const_cast(printNamePtr)); + } + else { + printName.Data = (uint8 *)"X509 CRL"; + printName.Length = 8; + } + + /* cook up CSSM_TIMESTRING versions of this/next update */ + int rtn = tpTimeToCssmTimestring((const char *)tbsCrl->thisUpdate.time.Data, + tbsCrl->thisUpdate.time.Length, + thisUpdate); + if(rtn) { + tpErrorLog("***Badly formatted thisUpdate\n"); + } + else { + thisUpdateData.Data = (uint8 *)thisUpdate; + thisUpdateData.Length = CSSM_TIME_STRLEN; + } + if(tbsCrl->nextUpdate.time.Data != NULL) { + rtn = tpTimeToCssmTimestring((const char *)tbsCrl->nextUpdate.time.Data, + tbsCrl->nextUpdate.time.Length, + nextUpdate); + if(rtn) { + tpErrorLog("***Badly formatted nextUpdate\n"); + } + else { + nextUpdateData.Data = (uint8 *)nextUpdate; + nextUpdateData.Length = CSSM_TIME_STRLEN; + } + } + else { + /* + * NextUpdate not present; fake it by using "virtual end of time" + */ + tpTimeToCssmTimestring(CSSM_APPLE_CRL_END_OF_TIME, + strlen(CSSM_APPLE_CRL_END_OF_TIME), nextUpdate); + nextUpdateData.Data = (uint8 *)nextUpdate; + nextUpdateData.Length = CSSM_TIME_STRLEN; + } + + /* optional CrlNumber and DeltaCrlNumber */ + if(tpSearchNumericExtension(&tbsCrl->extensions, + &CSSMOID_CrlNumber, + &crlNumber)) { + crlNumberData.Data = (uint8 *)&crlNumber; + crlNumberData.Length = sizeof(uint32); + crlNumberPresent = true; + } + if(tpSearchNumericExtension(&tbsCrl->extensions, + &CSSMOID_DeltaCrlIndicator, + &deltaCrlNumber)) { + deltaCrlNumberData.Data = (uint8 *)&deltaCrlNumber; + deltaCrlNumberData.Length = sizeof(uint32); + deltaCrlPresent = true; + } + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "CrlType"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &crlTypeData; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "CrlEncoding"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &crlEncData; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "PrintName"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &printName; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "Issuer"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = const_cast(crl.issuerName()); + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "ThisUpdate"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &thisUpdateData; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "NextUpdate"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &nextUpdateData; + attr++; + + /* now the optional attributes */ + CSSM_DATA uri = *crl.uri(); + if(uri.Data != NULL) { + /* ensure URI string does not contain NULL */ + if(uri.Data[uri.Length - 1] == 0) { + uri.Length--; + } + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "URI"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &uri; + attr++; + } + if(crlNumberPresent) { + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "CrlNumber"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &crlNumberData; + attr++; + } + if(deltaCrlPresent) { + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "DeltaCrlNumber"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &deltaCrlNumberData; + attr++; + } + + recordAttrs.DataRecordType = CSSM_DL_DB_RECORD_X509_CRL; + recordAttrs.SemanticInformation = 0; + recordAttrs.NumberOfAttributes = attr - attrs; + recordAttrs.AttributeData = attrs; + + crtn = CSSM_DL_DataInsert(dlDbHand, + CSSM_DL_DB_RECORD_X509_CRL, + &recordAttrs, + crl.itemData(), + &recordPtr); + if(crtn == CSSMERR_DL_INVALID_RECORDTYPE) { + /* gross hack of inserting this "new" schema that Keychain + * didn't specify */ + crtn = tpAddCrlSchema(dlDbHand); + if(crtn == CSSM_OK) { + /* Retry with a fully capable DLDB */ + crtn = CSSM_DL_DataInsert(dlDbHand, + CSSM_DL_DB_RECORD_X509_CRL, + &recordAttrs, + crl.itemData(), + &recordPtr); + } + } + if(crtn) { + tpErrorLog("CSSM_DL_DataInsert: %s", cssmErrorString(crtn).c_str()); + } + else { + CSSM_DL_FreeUniqueRecord(dlDbHand, recordPtr); + } + + return crtn; +} diff --git a/AppleX509TP/TPDatabase.h b/AppleX509TP/TPDatabase.h new file mode 100644 index 00000000..85268e69 --- /dev/null +++ b/AppleX509TP/TPDatabase.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * TPDatabase.h - TP's DL/DB access functions. + * + * Created 10/9/2002 by Doug Mitchell. + */ + +#ifndef _TP_DATABASE_H_ +#define _TP_DATABASE_H_ + +#include +#include +#include "TPCertInfo.h" + +#ifdef __cplusplus +extern "C" { +#endif + +TPCertInfo *tpDbFindIssuerCert( + CssmAllocator &alloc, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const TPClItemInfo *subjectItem, + const CSSM_DL_DB_LIST *dbList, + const char *verifyTime, // may be NULL + bool &partialIssuerKey); // RETURNED + +/* + * Search a list of DBs for a CRL from the specified issuer and (optional) + * TPCrlVerifyContext.verifyTime. + * Just a boolean return - we found it, or not. If we did, we return a + * TPCrlInfo which has been verified with the specified TPCrlVerifyContext. + */ +class TPCrlInfo; +class TPCrlVerifyContext; + +TPCrlInfo *tpDbFindIssuerCrl( + TPCrlVerifyContext &vfyCtx, + const CSSM_DATA &issuer, + TPCertInfo &forCert); + +/* + * Store a CRL in a DLDB. + */ +CSSM_RETURN tpDbStoreCrl( + TPCrlInfo &crl, + CSSM_DL_DB_HANDLE &dlDb); + +#ifdef __cplusplus +} +#endif + +#endif /* _TP_DATABASE_H_ */ \ No newline at end of file diff --git a/AppleX509TP/TPNetwork.cpp b/AppleX509TP/TPNetwork.cpp new file mode 100644 index 00000000..630661cc --- /dev/null +++ b/AppleX509TP/TPNetwork.cpp @@ -0,0 +1,534 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * TPNetwork.h - LDAP, HTTP and (eventually) other network tools + * + * Written 10/3/2002 by Doug Mitchell. + */ + +#include "TPNetwork.h" +#include "tpdebugging.h" +#include +#include +#include +#include +/* Unix-y fork and file stuff */ +#include +#include +#include +#include +#include + +/* normally, crlrefresh exec'd from here */ +#define CRL_FETCH_TOOL "/usr/bin/crlrefresh" + +/* !NDEBUG, this env var optionally points to crlrefresh */ +#define CRL_FETCH_ENV "TP_CRLREFRESH" + +#define CRL_RBUF_SIZE 1024 /* read this much at a time from pipe */ + +typedef enum { + LT_Crl = 1, + LT_Cert +} LF_Type; + +static CSSM_RETURN tpFetchViaNet( + const CSSM_DATA &url, + LF_Type lfType, + CssmAllocator &alloc, + CSSM_DATA &attrBlob) // mallocd and RETURNED +{ + char *arg1; + int status; + + switch(lfType) { + case LT_Crl: + arg1 = "f"; + break; + case LT_Cert: + arg1 = "F"; + break; + default: + return CSSMERR_TP_INTERNAL_ERROR; + } + + /* create pipe to catch CRL_FETCH_TOOL's output */ + int pipeFds[2]; + status = pipe(pipeFds); + if(status) { + tpErrorLog("tpFetchViaNet: pipe error %d\n", errno); + return CSSMERR_TP_REQUEST_LOST; + } + + pid_t pid = fork(); + if(pid < 0) { + tpErrorLog("tpFetchViaNet: fork error %d\n", errno); + return CSSMERR_TP_REQUEST_LOST; + } + if(pid == 0) { + /* child: run CRL_FETCH_TOOL */ + + /* don't assume URL string is NULL terminated */ + char *urlStr; + if(url.Data[url.Length - 1] == '\0') { + urlStr = (char *)url.Data; + } + else { + urlStr = (char *)alloc.malloc(url.Length + 1); + memmove(urlStr, url.Data, url.Length); + urlStr[url.Length] = '\0'; + } + + /* set up pipeFds[1] as stdout for CRL_FETCH_TOOL */ + status = dup2(pipeFds[1], STDOUT_FILENO); + if(status < 0) { + tpErrorLog("tpFetchViaNet: dup2 error %d\n", errno); + _exit(1); + } + close(pipeFds[0]); + close(pipeFds[1]); + + char *crlFetchTool = CRL_FETCH_TOOL; + #ifndef NDEBUG + char *cft = getenv(CRL_FETCH_ENV); + if(cft) { + crlFetchTool = cft; + } + #endif /* NDEBUG */ + + /* here we go */ + execl(crlFetchTool, CRL_FETCH_TOOL, arg1, urlStr, NULL); + + /* only get here on error */ + Syslog::error("TPNetwork: exec returned %d errno %d", status, errno); + /* we are the child... */ + _exit(1); + } + + /* parent - resulting blob comes in on pipeFds[0] */ + close(pipeFds[1]); + int thisRead = 0; + int totalRead = 0; + char inBuf[CRL_RBUF_SIZE]; + attrBlob.Data = NULL; + attrBlob.Length = 0; // buf size until complete, then actual size of + // good data + CSSM_RETURN crtn = CSSM_OK; + + do { + thisRead = read(pipeFds[0], inBuf, CRL_RBUF_SIZE); + if(thisRead < 0) { + switch(errno) { + case EINTR: + /* try some more */ + continue; + default: + tpErrorLog("tpFetchViaNet: read from child error %d\n", errno); + crtn = CSSMERR_TP_REQUEST_LOST; + break; + } + if(crtn) { + break; + } + } + if(thisRead == 0) { + /* normal termination */ + attrBlob.Length = totalRead; + break; + } + if(attrBlob.Length < (unsigned)(totalRead + thisRead)) { + uint32 newLen = attrBlob.Length + CRL_RBUF_SIZE; + attrBlob.Data = (uint8 *)alloc.realloc(attrBlob.Data, newLen); + attrBlob.Length = newLen; + + } + memmove(attrBlob.Data + totalRead, inBuf, thisRead); + totalRead += thisRead; + } while(1); + + close(pipeFds[0]); + + /* ensure child exits */ + pid_t rtnPid; + do { + rtnPid = wait4(pid, &status, 0 /* options */, NULL /* rusage */); + if(rtnPid == pid) { + if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) { + tpErrorLog("tpFetchViaNet: bad exit status from child\n"); + crtn = CSSMERR_TP_REQUEST_LOST; + } + /* done */ + break; + } + else if(rtnPid < 0) { + if(errno == EINTR) { + /* try again */ + continue; + } + /* hosed */ + tpErrorLog("tpFetchViaNet: wait4 error %d\n", errno); + crtn = CSSMERR_TP_REQUEST_LOST; + break; + } + else { + tpErrorLog("tpFetchViaNet: wait4 returned %d\n", rtnPid); + crtn = CSSMERR_TP_REQUEST_LOST; + } + } while(1); + + return crtn; +} + +static CSSM_RETURN tpCrlViaNet( + const CSSM_DATA &url, + TPCrlVerifyContext &vfyCtx, + TPCertInfo &forCert, // for verifyWithContext + TPCrlInfo *&rtnCrl) +{ + TPCrlInfo *crl = NULL; + CSSM_DATA crlData; + CSSM_RETURN crtn; + CssmAllocator &alloc = CssmAllocator::standard(); + + crtn = tpFetchViaNet(url, LT_Crl, alloc, crlData); + if(crtn) { + return crtn; + } + try { + crl = new TPCrlInfo(vfyCtx.clHand, + vfyCtx.cspHand, + &crlData, + TIC_CopyData, + vfyCtx.verifyTime); // cssmTimeStr FIMXE - do we need this? + } + catch(...) { + alloc.free(crlData.Data); + rtnCrl = NULL; + return CSSMERR_APPLETP_CRL_NOT_FOUND; + } + alloc.free(crlData.Data); + + /* full CRL verify */ + crtn = crl->verifyWithContext(vfyCtx, &forCert); + if(crtn == CSSM_OK) { + crl->uri(url); + } + else { + delete crl; + crl = NULL; + } + rtnCrl = crl; + return crtn; +} + +static CSSM_RETURN tpIssuerCertViaNet( + const CSSM_DATA &url, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const char *verifyTime, + TPCertInfo &subject, + TPCertInfo *&rtnCert) +{ + TPCertInfo *issuer = NULL; + CSSM_DATA certData; + CSSM_RETURN crtn; + CssmAllocator &alloc = CssmAllocator::standard(); + + crtn = tpFetchViaNet(url, LT_Cert, alloc, certData); + if(crtn) { + tpErrorLog("tpIssuerCertViaNet: net fetch failed\n"); + return CSSMERR_APPLETP_CERT_NOT_FOUND_FROM_ISSUER; + } + try { + issuer = new TPCertInfo(clHand, + cspHand, + &certData, + TIC_CopyData, + verifyTime); + } + catch(...) { + tpErrorLog("tpIssuerCertViaNet: bad cert via net fetch\n"); + alloc.free(certData.Data); + rtnCert = NULL; + return CSSMERR_APPLETP_BAD_CERT_FROM_ISSUER; + } + alloc.free(certData.Data); + + /* subject/issuer match? */ + if(!issuer->isIssuerOf(subject)) { + tpErrorLog("tpIssuerCertViaNet: wrong issuer cert via net fetch\n"); + crtn = CSSMERR_APPLETP_BAD_CERT_FROM_ISSUER; + } + else { + /* yep, do a sig verify */ + crtn = subject.verifyWithIssuer(issuer); + if(crtn) { + tpErrorLog("tpIssuerCertViaNet: sig verify fail for cert via net " + "fetch\n"); + crtn = CSSMERR_APPLETP_BAD_CERT_FROM_ISSUER; + } + } + if(crtn) { + assert(issuer != NULL); + delete issuer; + issuer = NULL; + } + rtnCert = issuer; + return crtn; +} + +/* + * Fetch a CRL or a cert via a GeneralNames. + * Shared by cert and CRL code to avoid duplicating GeneralNames traversal + * code, despite the awkward interface for this function. + */ +static CSSM_RETURN tpFetchViaGeneralNames( + const CE_GeneralNames *names, + TPCertInfo &forCert, + TPCrlVerifyContext *verifyContext, // only for CRLs + CSSM_CL_HANDLE clHand, // only for certs + CSSM_CSP_HANDLE cspHand, // only for certs + const char *verifyTime, // only for certs, optional + /* exactly one must be non-NULL, that one is returned */ + TPCertInfo **certInfo, + TPCrlInfo **crlInfo) +{ + assert(certInfo || crlInfo); + assert(!certInfo || !crlInfo); + CSSM_RETURN crtn; + + for(unsigned nameDex=0; nameDexnumNames; nameDex++) { + CE_GeneralName *name = &names->generalName[nameDex]; + switch(name->nameType) { + case GNT_URI: + if(name->name.Length < 5) { + continue; + } + if(strncmp((char *)name->name.Data, "ldap:", 5) && + strncmp((char *)name->name.Data, "http:", 5) && + strncmp((char *)name->name.Data, "https:", 6)) { + /* eventually handle other schemes here */ + continue; + } + if(certInfo) { + tpDebug(" fetching cert via net"); + crtn = tpIssuerCertViaNet(name->name, + clHand, + cspHand, + verifyTime, + forCert, + *certInfo); + } + else { + tpDebug(" fetching CRL via net"); + assert(verifyContext != NULL); + crtn = tpCrlViaNet(name->name, + *verifyContext, + forCert, + *crlInfo); + } + switch(crtn) { + case CSSM_OK: + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: // caller handles + return crtn; + default: + break; + } + /* not found/no good; try again */ + break; + default: + tpCrlDebug(" tpFetchCrlFromNet: unknown" + "nameType (%u)", (unsigned)name->nameType); + break; + } /* switch nameType */ + } /* for each name */ + if(certInfo) { + return CSSMERR_TP_CERTGROUP_INCOMPLETE; + } + else { + return CSSMERR_APPLETP_CRL_NOT_FOUND; + } +} + +/* + * Fetch CRL(s) from specified cert if the cert has a cRlDistributionPoint + * extension. + * + * Return values: + * CSSM_OK - found and returned fully verified CRL + * CSSMERR_APPLETP_CRL_NOT_FOUND - no CRL in cRlDistributionPoint + * Anything else - gross error, typically from last LDAP/HTTP attempt + * + * FIXME - this whole mechanism sort of falls apart if verifyContext.verifyTime + * is non-NULL. How are we supposed to get the CRL which was valid at + * a specified time in the past? + */ +CSSM_RETURN tpFetchCrlFromNet( + TPCertInfo &cert, + TPCrlVerifyContext &vfyCtx, + TPCrlInfo *&crl) // RETURNED +{ + /* does the cert have a cRlDistributionPoint? */ + CSSM_DATA_PTR fieldValue; // mallocd by CL + + if(vfyCtx.verifyTime != NULL) { + tpErrorLog("***tpFetchCrlFromNet: don't know how to time travel\n"); + return CSSMERR_APPLETP_CRL_NOT_FOUND; + } + CSSM_RETURN crtn = cert.fetchField(&CSSMOID_CrlDistributionPoints, + &fieldValue); + switch(crtn) { + case CSSM_OK: + break; + case CSSMERR_CL_NO_FIELD_VALUES: + /* field not present */ + return CSSMERR_APPLETP_CRL_NOT_FOUND; + default: + /* gross error */ + return crtn; + } + if(fieldValue->Length != sizeof(CSSM_X509_EXTENSION)) { + tpErrorLog("tpFetchCrlFromNet: malformed CSSM_FIELD"); + return CSSMERR_TP_UNKNOWN_FORMAT; + } + CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)fieldValue->Data; + CE_CRLDistPointsSyntax *dps = + (CE_CRLDistPointsSyntax *)cssmExt->value.parsedValue; + TPCrlInfo *rtnCrl = NULL; + + /* default return if we don't find anything */ + crtn = CSSMERR_APPLETP_CRL_NOT_FOUND; + for(unsigned dex=0; dexnumDistPoints; dex++) { + CE_CRLDistributionPoint *dp = &dps->distPoints[dex]; + if(dp->distPointName == NULL) { + continue; + } + /* + * FIXME if this uses an indirect CRL, we need to follow the + * crlIssuer field... TBD. + */ + switch(dp->distPointName->nameType) { + case CE_CDNT_NameRelativeToCrlIssuer: + /* not yet */ + tpErrorLog("tpFetchCrlFromNet: " + "CE_CDNT_NameRelativeToCrlIssuerÊnot implemented\n"); + break; + + case CE_CDNT_FullName: + { + CE_GeneralNames *names = dp->distPointName->fullName; + crtn = tpFetchViaGeneralNames(names, + cert, + &vfyCtx, + 0, // clHand, use the one in vfyCtx + 0, // cspHand, ditto + NULL, // verifyTime - in vfyCtx + NULL, + &rtnCrl); + break; + } /* CE_CDNT_FullName */ + + default: + /* not yet */ + tpErrorLog("tpFetchCrlFromNet: " + "unknown distPointName->nameType (%u)\n", + (unsigned)dp->distPointName->nameType); + break; + } /* switch distPointName->nameType */ + if(crtn) { + /* i.e., tpFetchViaGeneralNames SUCCEEDED */ + break; + } + } /* for each distPoints */ + + cert.freeField(&CSSMOID_CrlDistributionPoints, fieldValue); + if(crtn == CSSM_OK) { + assert(rtnCrl != NULL); + crl = rtnCrl; + } + return crtn; +} + +/* + * Fetch issuer cert of specified cert if the cert has an issuerAltName + * with a URI. If non-NULL cert is returned, it has passed subject/issuer + * name comparison and signature verification with target cert. + * + * Return values: + * CSSM_OK - found and returned issuer cert + * CSSMERR_TP_CERTGROUP_INCOMPLETE - no URL in issuerAltName + * CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE - found and returned issuer + * cert, but signature verification needs subsequent retry. + * Anything else - gross error, typically from last LDAP/HTTP attempt + */ +CSSM_RETURN tpFetchIssuerFromNet( + TPCertInfo &subject, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const char *verifyTime, + TPCertInfo *&issuer) // RETURNED +{ + /* does the cert have a issuerAltName? */ + CSSM_DATA_PTR fieldValue; // mallocd by CL + + if(verifyTime != NULL) { + tpErrorLog("***tpFetchIssuerFromNet: don't know how to time travel\n"); + return CSSMERR_TP_CERTGROUP_INCOMPLETE; + } + CSSM_RETURN crtn = subject.fetchField(&CSSMOID_IssuerAltName, + &fieldValue); + switch(crtn) { + case CSSM_OK: + break; + case CSSMERR_CL_NO_FIELD_VALUES: + /* field not present */ + return CSSMERR_TP_CERTGROUP_INCOMPLETE; + default: + /* gross error */ + return crtn; + } + if(fieldValue->Length != sizeof(CSSM_X509_EXTENSION)) { + tpPolicyError("tpFetchIssuerFromNet: malformed CSSM_FIELD"); + return CSSMERR_TP_UNKNOWN_FORMAT; + } + CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)fieldValue->Data; + CE_GeneralNames *names = (CE_GeneralNames *)cssmExt->value.parsedValue; + TPCertInfo *rtnCert = NULL; + + crtn = tpFetchViaGeneralNames(names, + subject, + NULL, // verifyContext + clHand, + cspHand, + verifyTime, + &rtnCert, + NULL); + subject.freeField(&CSSMOID_IssuerAltName, fieldValue); + switch(crtn) { + case CSSM_OK: + case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE: + issuer = rtnCert; + break; + default: + break; + } + return crtn; +} + + diff --git a/AppleX509TP/TPNetwork.h b/AppleX509TP/TPNetwork.h new file mode 100644 index 00000000..aa17d186 --- /dev/null +++ b/AppleX509TP/TPNetwork.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * TPNetwork.h - LDAP (and eventually) other network tools + * + * Written 10/3/2002 by Doug Mitchell. + */ + +#ifndef _TP_NETWORK_H_ +#define _TP_NETWORK_H_ + +#include +#include "TPCertInfo.h" +#include "TPCrlInfo.h" + +extern "C" { + +/* + * Fetch CRL(s) for specified cert if the cert has a cRlDistributionPoint + * extension. If a non-NULL CRL is returned, it has passed verification + * with specified TPCrlVerifyContext. + * The common, trivial failure of "no URI in a cRlDistributionPoint + * extension" is indicated by CSSMERR_APPLETP_CRL_NOT_FOUND. + */ +extern CSSM_RETURN tpFetchCrlFromNet( + TPCertInfo &cert, + TPCrlVerifyContext &verifyContext, + TPCrlInfo *&crl); // RETURNED + +/* + * Fetch issuer cert of specified cert if the cert has an issuerAltName + * with a URI. If non-NULL cert is returned, it has passed subject/issuer + * name comparison and signature verification with target cert. + * The common, trivial failure of "no URI in an issuerAltName + * extension" is indicated by CSSMERR_TP_CERTGROUP_INCOMPLETE. + * A CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE return indicates that + * subsequent signature verification is needed. + */ +extern CSSM_RETURN tpFetchIssuerFromNet( + TPCertInfo &subject, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const char *verifyTime, + TPCertInfo *&issuer); // RETURNED + +} + +#endif /* TP_NETWORK_H_ */ diff --git a/AppleX509TP/certGroupUtils.cpp b/AppleX509TP/certGroupUtils.cpp index 71632442..b4a183c4 100644 --- a/AppleX509TP/certGroupUtils.cpp +++ b/AppleX509TP/certGroupUtils.cpp @@ -30,19 +30,11 @@ #include #include "certGroupUtils.h" -#include "cldebugging.h" +#include "tpdebugging.h" #include "tpTime.h" #include /* for memcmp */ -#if 0 -void *tpCalloc(CssmAllocator &alloc, uint32 num, uint32 size) -{ - void *p = alloc.malloc(num * size); - memset(p, 0, num* size); - return p; -} -#endif /* * Copy one CSSM_DATA to another, mallocing destination. @@ -116,17 +108,20 @@ CSSM_BOOL tpCompareCssmData( } /* - * Compare two OIDs, return CSSM_TRUE if identical. + * Free memory via specified plugin's app-level allocator */ -CSSM_BOOL tpCompareOids( - const CSSM_OID *oid1, - const CSSM_OID *oid2) -{ - /* - * This should break if/when CSSM_OID is not the same as - * CSSM_DATA, which is exactly what we want. - */ - return tpCompareCssmData(oid1, oid2); +void tpFreePluginMemory( + CSSM_HANDLE hand, + void *p) +{ + CSSM_API_MEMORY_FUNCS memFuncs; + CSSM_RETURN crtn = CSSM_GetAPIMemoryFunctions(hand, &memFuncs); + if(crtn) { + tpErrorLog("CSSM_GetAPIMemoryFunctions failure\n"); + /* oh well, leak and continue */ + return; + } + memFuncs.free_func(p, memFuncs.AllocRef); } /* @@ -143,7 +138,7 @@ CSSM_DATA_PTR tp_CertGetPublicKey( *valueToFree = NULL; crtn = cert->fetchField(&CSSMOID_X509V1SubjectPublicKeyCStruct, &val); if(crtn) { - errorLog0("Error on CSSM_CL_CertGetFirstFieldValue(PublicKeyCStruct)\n"); + tpErrorLog("Error on CSSM_CL_CertGetFirstFieldValue(PublicKeyCStruct)\n"); return NULL; } *valueToFree = val; @@ -171,7 +166,7 @@ CSSM_X509_ALGORITHM_IDENTIFIER_PTR tp_CertGetAlgId( *valueToFree = NULL; crtn = cert->fetchField(&CSSMOID_X509V1SignatureAlgorithm, &val); if(crtn) { - errorLog0("Error on fetchField(CSSMOID_X509V1SignatureAlgorithm)\n"); + tpErrorLog("Error on fetchField(CSSMOID_X509V1SignatureAlgorithm)\n"); return NULL; } *valueToFree = val; @@ -185,61 +180,6 @@ void tp_CertFreeAlgId( CSSM_CL_FreeFieldValue(clHand, &CSSMOID_X509V1SignatureAlgorithm, value); } -/* - * Compare two DER-encoded normalized names. - */ -CSSM_BOOL tpIsSameName( - const CSSM_DATA *name1, - const CSSM_DATA *name2) -{ - return tpCompareCssmData(name1, name2); -} - - -/* - * Given a TP handle, a CSP handle, a CL handle, and two certs, verify - * subjectCert with issuerCert. If checkIssuerExpired is CSSM_TRUE, - * we'll do a not before/after check of the issuer only if the - * signature verify passes. The rationale is that we're not interested - * in this condition for potential issuers which fail the sig verify. - * - * Returns: - * CSSM_OK - * CSSMERR_TP_VERIFICATION_FAILURE -- sig verify failure - * CSSMERR_TP_CERT_EXPIRED - * CSSMERR_TP_CERT_NOT_VALID_YET - */ -CSSM_RETURN tp_VerifyCert( - CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - TPCertInfo *subjectCert, - TPCertInfo *issuerCert, - CSSM_BOOL checkIssuerCurrent, - CSSM_BOOL allowExpired) // to be deleted -{ - CSSM_RETURN crtn; - - crtn = CSSM_CL_CertVerify(clHand, - CSSM_INVALID_HANDLE, - subjectCert->certData(), - issuerCert->certData(), - NULL, // VerifyScope - 0); // ScopeSize - if(crtn == CSSM_OK) { - #if TP_CERT_CURRENT_CHECK_INLINE - if(checkIssuerCurrent) { - /* also verify validity of issuer */ - crtn = issuerCert->isCurrent(allowExpired); - } - #endif - } - else { - /* general cert verify failure */ - crtn = CSSMERR_TP_VERIFICATION_FAILURE; - } - return crtn; -} - /* * Determine if two certs - passed in encoded form - are equivalent. */ @@ -250,164 +190,6 @@ CSSM_BOOL tp_CompareCerts( return tpCompareCssmData(cert1, cert2); } -#if TP_DL_ENABLE -/* - * Given a DL/DB, look up cert by subject name. Subsequent - * certs can be found using the returned result handle. - */ -static CSSM_DB_UNIQUE_RECORD_PTR tpCertLookup( - CSSM_DL_DB_HANDLE dlDb, - const CSSM_DATA *subjectName, // DER-encoded - CSSM_HANDLE_PTR resultHand, - CSSM_DATA_PTR cert) // RETURNED -{ - CSSM_QUERY query; - CSSM_SELECTION_PREDICATE predicate; - CSSM_DB_UNIQUE_RECORD_PTR record = NULL; - - cert->Data = NULL; - cert->Length = 0; - - /* SWAG until cert schema nailed down */ - predicate.DbOperator = CSSM_DB_EQUAL; - predicate.Attribute.Info.AttributeNameFormat = - CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - predicate.Attribute.Info.Label.AttributeName = "Subject"; - predicate.Attribute.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; - predicate.Attribute.Value = const_cast(subjectName); - predicate.Attribute.NumberOfValues = 1; - - query.RecordType = CSSM_DL_DB_RECORD_X509_CERTIFICATE; - query.Conjunctive = CSSM_DB_NONE; - query.NumSelectionPredicates = 1; - query.SelectionPredicate = &predicate; - query.QueryLimits.TimeLimit = 0; // FIXME - meaningful? - query.QueryLimits.SizeLimit = 1; // FIXME - meaningful? - query.QueryFlags = 0; // FIXME - used? - - CSSM_DL_DataGetFirst(dlDb, - &query, - resultHand, - NULL, // don't fetch attributes - cert, - &record); - return record; -} - -/* - * Search a list of DBs for a cert which verifies specified subject cert. - * Just a boolean return - we found it, or not. If we did, we return - * TPCertInfo associated with the raw cert. - * - * Special case of subject cert expired indicated by *subjectExpired - * returned as something other than CSSM_OK. - */ -TPCertInfo *tpFindIssuer( - CssmAllocator &alloc, - CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - TPCertInfo *subjectCert, - const CSSM_DATA *issuerName, // TBD - passed for convenience - const CSSM_DL_DB_LIST *dbList, - const char *cssmTimeStr, // may be NULL - CSSM_RETURN *issuerExpired) // RETURNED -{ - uint32 dbDex; - CSSM_HANDLE resultHand; - CSSM_DATA_PTR cert; // we malloc - CSSM_DL_DB_HANDLE dlDb; - CSSM_DB_UNIQUE_RECORD_PTR record; - TPCertInfo *issuerCert = NULL; - - *issuerExpired = CSSM_OK; - if(dbList == NULL) { - return NULL; - } - cert = (CSSM_DATA_PTR)alloc.malloc(sizeof(CSSM_DATA)); - cert->Data = NULL; - cert->Length = 0; - - for(dbDex=0; dbDexNumHandles; dbDex++) { - dlDb = dbList->DLDBHandle[dbDex]; - record = tpCertLookup(dlDb, - issuerName, - &resultHand, - cert); - /* remember we have to abort this query regardless...*/ - if(record != NULL) { - /* Found one. Does it verify the subject cert? */ - issuerCert = new TPCertInfo(cert, clHand, cssmTimeStr, CSSM_TRUE); - if(tp_VerifyCert(clHand, - cspHand, - subjectCert, - issuerCert, - CSSM_FALSE, // check current, ignored - CSSM_FALSE)) { // allowExpired, ignored - - delete issuerCert; - issuerCert = NULL; - - /* special case - abort immediately if issuerExpired has expired */ - if((*issuerExpired) != CSSM_OK) { - CSSM_DL_DataAbortQuery(dlDb, resultHand); - goto abort; - } - - /* - * Verify fail. Continue searching this DB. Break on - * finding the holy grail or no more records found. - */ - for(;;) { - tpFreeCssmData(alloc, cert, CSSM_FALSE); - CSSM_RETURN crtn = CSSM_DL_DataGetNext(dlDb, - resultHand, - NULL, // no attrs - cert, - &record); - if(crtn) { - /* no more, done with this DB */ - break; - } - - /* found one - does it verify subject? */ - issuerCert = new TPCertInfo(cert, clHand, cssmTimeStr, - CSSM_TRUE); - if(tp_VerifyCert(clHand, - cspHand, - subjectCert, - issuerCert, - CSSM_FALSE, - CSSM_FALSE)) { - /* yes! */ - break; - } - delete issuerCert; - issuerCert = NULL; - } /* searching subsequent records */ - } /* verify fail */ - /* else success! */ - - if(issuerCert != NULL) { - /* successful return */ - CSSM_DL_DataAbortQuery(dlDb, resultHand); - issuerCert->dlDbHandle(dlDb); - issuerCert->uniqueRecord(record); - return issuerCert; - } - } /* tpCertLookup, i.e., CSSM_DL_DataGetFirst, succeeded */ - - /* in any case, abort the query for this db */ - CSSM_DL_DataAbortQuery(dlDb, resultHand); - - } /* main loop searching dbList */ - -abort: - /* issuer not found */ - tpFreeCssmData(alloc, cert, CSSM_TRUE); - return NULL; -} - -#endif /* TP_DL_ENABLE */ /* * Given a aignature OID, return the corresponding CSSM_ALGID for the @@ -427,6 +209,9 @@ CSSM_ALGORITHMS tpOidToAldId( else if(tpCompareOids(oid, &CSSMOID_SHA1WithRSA)) { return CSSM_ALGID_SHA1WithRSA; } + else if(tpCompareOids(oid, &CSSMOID_SHA1WithRSA_OIW)) { + return CSSM_ALGID_SHA1WithRSA; + } else if(tpCompareOids(oid, &CSSMOID_SHA1WithDSA)) { *keyAlg = CSSM_ALGID_DSA; return CSSM_ALGID_SHA1WithDSA; @@ -457,10 +242,217 @@ void tpToLower( unsigned strLen) { for(unsigned i=0; i= MAX_DNS_COMP_LEN. + * Returns true if a component was found. + */ +static bool tpNextDnsComp( + const char *inBuf, + uint32 &inBufLen, // IN/OUT + char *outBuf, // component RETURNED here + uint32 &outBufLen) // RETURNED length of component +{ + outBufLen = 0; + if(inBufLen == 0) { + return false; + } + + /* skip over leading '.' */ + if(*inBuf == '.') { + inBuf++; + if(--inBufLen == 0) { + return false; + } + } + + /* copy chars until out of data or next '.' found */ + do { + if(*inBuf == '.') { + break; + } + *outBuf++ = *inBuf++; + inBufLen--; + outBufLen++; + if(outBufLen >= MAX_DNS_COMP_LEN) { + /* abort */ + break; + } + } while(inBufLen != 0); + if(outBufLen) { + return true; + } + else { + return false; } } +/* + * Find location of specified substring in given bigstring. Returns + * pointer to start of substring in bigstring, else returns NULL. + */ +static const char *tpSubStr( + const char *bigstr, + uint32 bigstrLen, + const char *substr, + uint32 substrLen) +{ + /* stop searching substrLen chars before end of bigstr */ + const char *endBigStr = bigstr + bigstrLen - substrLen; + for( ; bigstr <= endBigStr; ) { + if(*bigstr == *substr) { + /* first char match - remainder? */ + if(substrLen == 1) { + /* don't count on memcmp(a,b,0) */ + return bigstr; + } + if(!memcmp(bigstr+1, substr+1, substrLen - 1)) { + return bigstr; + } + } + bigstr++; + } + return NULL; +} + +/* + * Compare two DNS components, with full wildcard check. We assume + * that no '.' chars exist (per the processing performed in + * tpNextDnsComp()). Returns CSSM_TRUE on match, else CSSM_FALSE. + */ +static CSSM_BOOL tpCompareComps( + const char *hostComp, // no wildcards + uint32 hostCompLen, + const char *certComp, // wildcards OK here + uint32 certCompLen) +{ + const char *endCertComp = certComp + certCompLen; + const char *endHostComp = hostComp + hostCompLen; + do { + /* wild card in cert name? */ + const char *wildCard = tpSubStr(certComp, certCompLen, + "*", 1); + if(wildCard == NULL) { + /* no, require perfect literal match right now */ + if((hostCompLen == certCompLen) && + !memcmp(hostComp, certComp, certCompLen)) { + return CSSM_TRUE; + } + else { + return CSSM_FALSE; + } + } + + if(wildCard != certComp) { + /* + * Require literal match of hostComp with certComp + * up until (but not including) the wildcard + */ + uint32 subStrLen = wildCard - certComp; + if(subStrLen > hostCompLen) { + /* out of host name chars */ + return CSSM_FALSE; + } + if(memcmp(certComp, hostComp, subStrLen)) { + return CSSM_FALSE; + } + /* OK, skip over substring */ + hostComp += subStrLen; + hostCompLen -= subStrLen; + /* start parsing at the wildcard itself */ + certComp = wildCard; + certCompLen -= subStrLen; + continue; + } + + /* + * Currently looking at a wildcard. + * + * Find substring in hostComp which matches from the char after + * the wildcard up to whichever of these comes next: + * + * -- end of certComp + * -- another wildcard + */ + wildCard++; + if(wildCard == endCertComp) { + /* + * -- Wild card at end of cert's DNS + * -- nothing else to match - rest of hostComp is the wildcard + * match + * -- done, success + */ + return CSSM_TRUE; + } + + const char *afterSubStr; // in certComp + afterSubStr = tpSubStr(wildCard, endCertComp - wildCard, + "*", 1); + if(afterSubStr == NULL) { + /* no more wildcards - use end of certComp */ + afterSubStr = endCertComp; + } + uint32 subStrLen = afterSubStr - wildCard; + const char *foundSub = tpSubStr(hostComp, hostCompLen, + wildCard, subStrLen); + if(foundSub == NULL) { + /* No match of explicit chars */ + return CSSM_FALSE; + } + + /* found it - skip past this substring */ + hostComp = foundSub + subStrLen; + hostCompLen = endHostComp - hostComp; + certComp = afterSubStr; + certCompLen = endCertComp - afterSubStr; + + } while((hostCompLen != 0) || (certCompLen != 0)); + if((hostCompLen == 0) && (certCompLen == 0)) { + return CSSM_TRUE; + } + else { + /* end of one but not the other */ + return CSSM_FALSE; + } +} /* * Compare hostname, is presented to the TP in @@ -469,56 +461,106 @@ void tpToLower( * Limited wildcard checking is performed here. * * The incoming hostname is assumed to have been processed by tpToLower(); - * we'll perform that processing on serverName here. + * we'll perform that processing on certName here. * * Returns CSSM_TRUE on match, else CSSM_FALSE. */ CSSM_BOOL tpCompareHostNames( const char *hostName, // spec'd by app, tpToLower'd uint32 hostNameLen, - char *serverName, // from cert, we tpToLower - uint32 serverNameLen) + char *certName, // from cert, we tpToLower + uint32 certNameLen) { - tpToLower(serverName, serverNameLen); + tpToLower(certName, certNameLen); /* tolerate optional NULL terminators for both */ if(hostName[hostNameLen - 1] == '\0') { hostNameLen--; } - if(serverName[serverNameLen - 1] == '\0') { - serverNameLen--; + if(certName[certNameLen - 1] == '\0') { + certNameLen--; } /* case 1: exact match */ - if((serverNameLen == hostNameLen) && - !memcmp(serverName, hostName, serverNameLen)) { + if((certNameLen == hostNameLen) && + !memcmp(certName, hostName, certNameLen)) { return CSSM_TRUE; } - /* case 2: handle optional '*' in cert's server name */ - if(serverName[0] == '*') { - /* last (serverNameLen - 1) chars have to match */ - unsigned effectLen = serverNameLen - 1; // skip '*' - if(serverNameLen < effectLen) { - errorLog0("tp_verifySslOpts: subject/server name wildcard " - "mismatch (1)"); - return CSSM_FALSE; - } - else if(memcmp(serverName+1, // skip '*' - hostName + hostNameLen - effectLen, - effectLen)) { - errorLog0("tp_verifySslOpts: subject/server name wildcard " - "mismatch (2)"); + /* + * Case 2: Compare one component at a time, handling wildcards in + * cert's server name. The characters implicitly matched by a + * wildcard span only one component of a dnsName. + */ + do { + /* get next component from each dnsName */ + char hostComp[MAX_DNS_COMP_LEN]; + char certComp[MAX_DNS_COMP_LEN]; + uint32 hostCompLen; + uint32 certCompLen; + + bool foundHost = tpNextDnsComp(hostName, hostNameLen, + hostComp, hostCompLen); + bool foundCert = tpNextDnsComp(certName, certNameLen, + certComp, certCompLen); + if(foundHost != foundCert) { + /* unequal number of components */ + tpPolicyError("tpCompareHostNames: wildcard mismatch (1)"); return CSSM_FALSE; } - else { - /* wildcard match */ + if(!foundHost) { + /* normal successful termination */ return CSSM_TRUE; } + + /* compare individual components */ + if(!tpCompareComps(hostComp, hostCompLen, + certComp, certCompLen)) { + tpPolicyError("tpCompareHostNames: wildcard mismatch (2)"); + return CSSM_FALSE; + } + + /* skip over this component */ + hostName += hostCompLen; + certName += certCompLen; + } while(1); + /* NOT REACHED */ + //assert(0): + return CSSM_FALSE; +} + +/* + * Compare email address, is presented to the TP in + * CSSM_APPLE_TP_SMIME_OPTIONS.SenderEmail, to a string obtained + * from the sender's cert (i.e., from subjectAltName or Subject DN). + * + * Returns CSSM_TRUE on match, else CSSM_FALSE. + * + * Incomiong appEmail string has already been tpNormalizeAddrSpec'd. + * We do that for certEmail string here. + */ +CSSM_BOOL tpCompareEmailAddr( + const char *appEmail, // spec'd by app, normalized + uint32 appEmailLen, + char *certEmail, // from cert, we normalize + uint32 certEmailLen) +{ + tpNormalizeAddrSpec(certEmail, certEmailLen); + + /* tolerate optional NULL terminators for both */ + if(appEmail[appEmailLen - 1] == '\0') { + appEmailLen--; + } + if(certEmail[certEmailLen - 1] == '\0') { + certEmailLen--; + } + if((certEmailLen == appEmailLen) && + !memcmp(certEmail, appEmail, certEmailLen)) { + return CSSM_TRUE; } else { /* mismatch */ - errorLog0("tp_verifySslOpts: subject/server name mismatch"); + tpPolicyError("tpCompareEmailAddr: app/cert email addrs mismatch"); return CSSM_FALSE; } } diff --git a/AppleX509TP/certGroupUtils.h b/AppleX509TP/certGroupUtils.h index 5208ed64..07104af9 100644 --- a/AppleX509TP/certGroupUtils.h +++ b/AppleX509TP/certGroupUtils.h @@ -28,10 +28,6 @@ #include #include #include "TPCertInfo.h" -/* - * Cheetah version of TP doesn't work with DLs. - */ -#define TP_DL_ENABLE 1 #ifdef __cplusplus extern "C" { @@ -56,9 +52,16 @@ void tpFreeCssmData( CSSM_BOOL tpCompareCssmData( const CSSM_DATA *data1, const CSSM_DATA *data2); -CSSM_BOOL tpCompareOids( - const CSSM_OID *oid1, - const CSSM_OID *oid2); + +/* + * This should break if/when CSSM_OID is not the same as + * CSSM_DATA, which is exactly what we want. + */ +#define tpCompareOids(oid1, oid2) tpCompareCssmData(oid1, oid2) + +void tpFreePluginMemory( + CSSM_HANDLE hand, + void *p); CSSM_DATA_PTR tp_CertGetPublicKey( TPCertInfo *cert, @@ -74,31 +77,6 @@ void tp_CertFreeAlgId( CSSM_CL_HANDLE clHand, CSSM_DATA_PTR value); -#if TP_DL_ENABLE -TPCertInfo *tpFindIssuer( - CssmAllocator &alloc, - CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - TPCertInfo *subjectCert, - const CSSM_DATA *issuerName, // passed for convenience - const CSSM_DL_DB_LIST *dbList, - const char *cssmTimeStr, // may be NULL - CSSM_RETURN *issuerExpired); // RETURNED - -#endif /* TP_DL_ENABLE*/ - -CSSM_BOOL tpIsSameName( - const CSSM_DATA *pName1, - const CSSM_DATA *pName2); - -CSSM_RETURN tp_VerifyCert( - CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - TPCertInfo *subjectCert, - TPCertInfo *issuerCert, - CSSM_BOOL checkIssuerCurrent, - CSSM_BOOL allowExpired); - CSSM_BOOL tp_CompareCerts( const CSSM_DATA *cert1, const CSSM_DATA *cert2); @@ -114,12 +92,21 @@ void tpToLower( char *str, unsigned strLen); +void tpNormalizeAddrSpec( + char *addr, + unsigned addrLen); + CSSM_BOOL tpCompareHostNames( const char *hostName, // spec'd by app, tpToLower'd uint32 hostNameLen, - char *serverName, // from cert, we tpToLower - uint32 serverNameLen); - + char *certName, // from cert, we tpToLower + uint32 certNameLen); + +CSSM_BOOL tpCompareEmailAddr( + const char *appEmail, // spec'd by app, tpToLower'd + uint32 appEmailLen, + char *certEmail, // from cert, we tpToLower + uint32 certEmailLen); #ifdef __cplusplus } diff --git a/AppleX509TP/rootCerts.cpp b/AppleX509TP/rootCerts.cpp index 84a15931..15bc3a5e 100644 --- a/AppleX509TP/rootCerts.cpp +++ b/AppleX509TP/rootCerts.cpp @@ -30,7 +30,11 @@ */ #include "rootCerts.h" + +#if TP_ROOT_CERT_ENABLE + #include "certGroupUtils.h" +#include "tpdebugging.h" #include #include #include @@ -69,13 +73,13 @@ const tpRootCert *TPRootStore::rootCerts( Security::KeychainCore::Trust::gStore(); trustStore.getCssmRootCertificates(roots); if(roots.type() != CSSM_CERTGROUP_DATA) { - debug("tpAnchor", "Bad certGroup Type (%d)\n", + secdebug("tpAnchor", "Bad certGroup Type (%d)\n", (int)roots.type()); return NULL; } numTpRoots = roots.count(); if(numTpRoots == 0) { - debug("tpAnchor", "empty certGroup\n"); + secdebug("tpAnchor", "empty certGroup\n"); return NULL; } @@ -100,7 +104,7 @@ const tpRootCert *TPRootStore::rootCerts( &numFields, &field); if(crtn) { - debug("tpAnchor", "GetFirstFieldValue error on cert %u", + secdebug("tpAnchor", "GetFirstFieldValue error on cert %u", (unsigned)certNum); continue; } @@ -113,7 +117,7 @@ const tpRootCert *TPRootStore::rootCerts( CSSM_KEY_PTR key; crtn = CSSM_CL_CertGetKeyInfo(clHand, certData, &key); if(crtn) { - debug("tpAnchor", "CSSM_CL_CertGetKeyInfo error on cert %u", + secdebug("tpAnchor", "CSSM_CL_CertGetKeyInfo error on cert %u", (unsigned)certNum); /* clear out this tpRoot? */ continue; @@ -128,7 +132,7 @@ const tpRootCert *TPRootStore::rootCerts( CSSM_API_MEMORY_FUNCS memFuncs; crtn = CSSM_GetAPIMemoryFunctions(clHand, &memFuncs); if(crtn) { - debug("tpAnchor", "CSSM_GetAPIMemoryFunctions error"); + secdebug("tpAnchor", "CSSM_GetAPIMemoryFunctions error"); /* Oh well.. */ continue; } @@ -145,3 +149,154 @@ const tpRootCert *TPRootStore::rootCerts( mRootCerts = tpRoots; return mRootCerts; } + +/* + * Compare a root cert to a list of known embedded roots. + */ +CSSM_BOOL tp_isKnownRootCert( + TPCertInfo *rootCert, // raw cert to compare + CSSM_CL_HANDLE clHand) +{ + const CSSM_DATA *subjectName = NULL; + CSSM_DATA_PTR publicKey = NULL; + unsigned dex; + CSSM_BOOL brtn = CSSM_FALSE; + CSSM_DATA_PTR valToFree = NULL; + const tpRootCert *roots; + unsigned numRoots; + + roots = TPRootStore::tpGlobalRoots().rootCerts(clHand, numRoots); + + subjectName = rootCert->subjectName(); + publicKey = tp_CertGetPublicKey(rootCert, &valToFree); + if(publicKey == NULL) { + tpPolicyError("tp_isKnownRootCert: error retrieving public " + "key info!"); + goto errOut; + } + + /* + * Grind thru the list of known certs, demanding perfect match of + * both fields + */ + for(dex=0; dexclHand(), valToFree); + return brtn; +} + +/* + * Attempt to verify specified cert (from the end of a chain) with one of + * our known roots. + */ +CSSM_BOOL tp_verifyWithKnownRoots( + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + TPCertInfo *certToVfy) // last in chain, not root +{ + CSSM_KEY rootKey; // pub key manufactured from tpRootCert info + CSSM_CC_HANDLE ccHand; // signature context + CSSM_RETURN crtn; + unsigned dex; + const tpRootCert *rootInfo; + CSSM_BOOL brtn = CSSM_FALSE; + CSSM_KEYHEADER *hdr = &rootKey.KeyHeader; + CSSM_X509_ALGORITHM_IDENTIFIER_PTR algId; + CSSM_DATA_PTR valToFree = NULL; + CSSM_ALGORITHMS sigAlg; + const tpRootCert *rootCerts = NULL; + unsigned numRootCerts = 0; + + memset(&rootKey, 0, sizeof(CSSM_KEY)); + + /* + * Get signature algorithm from subject key + */ + algId = tp_CertGetAlgId(certToVfy, &valToFree); + if(algId == NULL) { + /* bad cert */ + return CSSM_FALSE; + } + /* subsequest errors to errOut: */ + + /* map to key and signature algorithm */ + sigAlg = tpOidToAldId(&algId->algorithm, &hdr->AlgorithmId); + if(sigAlg == CSSM_ALGID_NONE) { + tpPolicyError("tp_verifyWithKnownRoots: unknown sig alg"); + goto errOut; + } + + /* Set up other constant key fields */ + hdr->BlobType = CSSM_KEYBLOB_RAW; + switch(hdr->AlgorithmId) { + case CSSM_ALGID_RSA: + hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_PKCS1; + break; + case CSSM_ALGID_DSA: + hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_FIPS186; + break; + case CSSM_ALGID_FEE: + hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_OCTET_STRING; + break; + default: + /* punt */ + hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_NONE; + } + hdr->KeyClass = CSSM_KEYCLASS_PUBLIC_KEY; + hdr->KeyAttr = CSSM_KEYATTR_MODIFIABLE | CSSM_KEYATTR_EXTRACTABLE; + hdr->KeyUsage = CSSM_KEYUSE_VERIFY; + + rootCerts = TPRootStore::tpGlobalRoots().rootCerts(clHand, numRootCerts); + for(dex=0; dexsubjectName, certToVfy->issuerName())) { + /* not this root */ + continue; + } + + /* only variation in key in the loop - raw key bits and size */ + rootKey.KeyData = rootInfo->publicKey; + hdr->LogicalKeySizeInBits = rootInfo->keySize; + crtn = CSSM_CSP_CreateSignatureContext(cspHand, + sigAlg, + NULL, // AcccedCred + &rootKey, + &ccHand); + if(crtn) { + tpPolicyError("tp_verifyWithKnownRoots: " + "CSSM_CSP_CreateSignatureContext err"); + CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); + } + crtn = CSSM_CL_CertVerify(clHand, + ccHand, + certToVfy->itemData(), + NULL, // no signer cert + NULL, // VerifyScope + 0); // ScopeSize + CSSM_DeleteContext(ccHand); + if(crtn == CSSM_OK) { + /* success! */ + brtn = CSSM_TRUE; + break; + } + } +errOut: + if(valToFree != NULL) { + tp_CertFreeAlgId(clHand, valToFree); + } + return brtn; +} + +#endif /* TP_ROOT_CERT_ENABLE */ + diff --git a/AppleX509TP/rootCerts.h b/AppleX509TP/rootCerts.h index f0a980f2..ec514882 100644 --- a/AppleX509TP/rootCerts.h +++ b/AppleX509TP/rootCerts.h @@ -30,21 +30,22 @@ #ifndef _TP_ROOT_CERTS_H_ #define _TP_ROOT_CERTS_H_ -#include -#include -#include - /* * As of 3/18/02, use of the built-in root certs is disabled by default. - * Their use is enabled at in CSSM_TP_CertGroupVerify by the use of a - * private bit in CSSM_APPLE_TP_ACTION_DATA.ActionFlags. - * The presence of the root certs at all (at compile time) is controlled - * TP_ROOT_CERT_ENABLE. + * Their use is enabled at in CSSM_TP_CertGroupVerify by the use of the + * CSSM_TP_USE_INTERNAL_ROOT_CERTS bit in + * CSSM_APPLE_TP_ACTION_DATA.ActionFlags. The presence of the root certs + * at all (at compile time) is controlled TP_ROOT_CERT_ENABLE. */ -#define TP_ROOT_CERT_ENABLE 1 +#define TP_ROOT_CERT_ENABLE 0 #if TP_ROOT_CERT_ENABLE +#include +#include +#include +#include "TPCertInfo.h" + /* * Each one of these represents one known root cert. */ @@ -71,6 +72,23 @@ private: Mutex mLock; }; + +/* + * Compare a root cert to a list of known embedded roots. + */ +extern "C" { + +CSSM_BOOL tp_isKnownRootCert( + TPCertInfo *rootCert, // raw cert to compare + CSSM_CL_HANDLE clHand); + +CSSM_BOOL tp_verifyWithKnownRoots( + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + TPCertInfo *certToVfy); // last in chain, not root + +} + #endif /* TP_ROOT_CERT_ENABLE */ #endif /* _TP_ROOT_CERTS_H_ */ diff --git a/AppleX509TP/tpCertGroup.cpp b/AppleX509TP/tpCertGroup.cpp index fe705d51..7f765e63 100644 --- a/AppleX509TP/tpCertGroup.cpp +++ b/AppleX509TP/tpCertGroup.cpp @@ -25,9 +25,11 @@ #include "AppleTPSession.h" #include "certGroupUtils.h" #include "TPCertInfo.h" +#include "TPCrlInfo.h" #include "tpPolicies.h" #include "tpdebugging.h" #include "rootCerts.h" +#include "tpCrlVerify.h" #include #include @@ -86,258 +88,115 @@ void AppleTPSession::CertGroupConstruct(CSSM_CL_HANDLE clHand, const CSSM_CERTGROUP &CertGroupFrag, CSSM_CERTGROUP_PTR &CertGroup) { - TPCertGroup *tpCertGroup; - CertGroupConstructPriv(clHand, - cspHand, - DBList, - ConstructParams, - CertGroupFrag, - CSSM_FALSE, // allowExpired - NULL, // cssmTimeStr - tpCertGroup); - CertGroup = tpCertGroup->buildCssmCertGroup(); - delete tpCertGroup; + TPCertGroup outCertGroup(*this, TGO_Caller); + TPCertGroup inCertGroup(CertGroupFrag, + clHand, + cspHand, + *this, + NULL, // cssmTimeStr + true, // firstCertMustBeValid + TGO_Group); + + /* set up for disposal of TPCertInfos created by CertGroupConstructPriv */ + TPCertGroup certsToBeFreed(*this, TGO_Group); + + CSSM_RETURN constructReturn = CSSM_OK; + CSSM_BOOL verifiedToRoot; // not used + CSSM_BOOL verifiedToAnchor; // not used + + try { + CertGroupConstructPriv(clHand, + cspHand, + inCertGroup, + &DBList, + NULL, // cssmTimeStr + /* no anchors */ + 0, NULL, + 0, // actionFlags + certsToBeFreed, + verifiedToRoot, + verifiedToAnchor, + outCertGroup); + } + catch(const CssmError &cerr) { + constructReturn = cerr.cssmError(); + /* abort if no certs found */ + if(outCertGroup.numCerts() == 0) { + CssmError::throwMe(constructReturn); + } + } + CertGroup = outCertGroup.buildCssmCertGroup(); + if(constructReturn) { + CssmError::throwMe(constructReturn); + } } /* * Private version of CertGroupConstruct, used by CertGroupConstruct and - * CertGroupVerify. Returns a TP-style TPCertGroup for further processing. + * CertGroupVerify. Populates a TP-style TPCertGroup for further processing. * This only throws CSSM-style exceptions in the following cases: * * -- input parameter errors * -- the first (leaf) cert is bad (doesn't parse, expired, not valid yet). + * -- root found but it doesn't self-verify * * All other cert-related errors simply result in the bad cert being ignored. * Other exceptions are gross system errors like malloc failure. */ void AppleTPSession::CertGroupConstructPriv(CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - const CSSM_DL_DB_LIST &DBList, - const void *ConstructParams, - const CSSM_CERTGROUP &CertGroupFrag, - CSSM_BOOL allowExpired, - const char *cssmTimeStr, // May be NULL - TPCertGroup *&CertGroup) -{ - TPCertGroup *inCertGroup; // unordered input certs - TPCertGroup *outCertGroup; // ordered, verified output certs + CSSM_CSP_HANDLE cspHand, + TPCertGroup &inCertGroup, + const CSSM_DL_DB_LIST *DBList, // optional here + const char *cssmTimeStr, // optional + + /* trusted anchors, optional */ + /* FIXME - maybe this should be a TPCertGroup */ + uint32 numAnchorCerts, + const CSSM_DATA *anchorCerts, + + /* currently, only CSSM_TP_ACTION_FETCH_CERT_FROM_NET is + * interesting */ + CSSM_APPLE_TP_ACTION_FLAGS actionFlags, + /* + * Certs to be freed by caller (i.e., TPCertInfo which we allocate + * as a result of using a cert from anchorCerts of dbList) are added + * to this group. + */ + TPCertGroup &certsToBeFreed, - /* - * subjectCert refers to the cert we're currently trying to verify. It's either - * an element in inCertGroup (if we're verifying a cert from the incoming - * CertGroupFrag) or dbSubject (if we're verifying a cert which came from a DB). - * - * Similarly, issuerCert, when non-NULL, points to a cert which has just - * been located as a verifiable issuer of subjectCert. It points to either - * an element in inCertGroup or to dbIssuer. - */ + /* returned */ + CSSM_BOOL &verifiedToRoot, // end of chain self-verifies + CSSM_BOOL &verifiedToAnchor, // end of chain in anchors + TPCertGroup &outCertGroup) // RETURNED +{ TPCertInfo *subjectCert; // the one we're working on - TPCertInfo *issuerCert = NULL; // verified as next one in chain - TPCertInfo *certInfo; // working cert - unsigned certDex; // index into certInfo - CSSM_RETURN crtn; CSSM_RETURN outErr = CSSM_OK; - /* verify input args */ - if(cspHand == CSSM_INVALID_HANDLE) { - CssmError::throwMe(CSSMERR_TP_INVALID_CSP_HANDLE); - } - if(clHand == CSSM_INVALID_HANDLE) { - CssmError::throwMe(CSSMERR_TP_INVALID_CL_HANDLE); - } - if( (CertGroupFrag.NumCerts == 0) || // list is empty - (CertGroupFrag.CertGroupType != CSSM_CERTGROUP_DATA) || - (CertGroupFrag.GroupList.CertList[0].Data == NULL) || // first cert empty - (CertGroupFrag.GroupList.CertList[0].Length == 0)) { // first cert empty - CssmError::throwMe(CSSMERR_CL_INVALID_CERTGROUP_POINTER); - } - switch(CertGroupFrag.CertType) { - case CSSM_CERT_X_509v1: - case CSSM_CERT_X_509v2: - case CSSM_CERT_X_509v3: - break; - default: - CssmError::throwMe(CSSMERR_TP_UNKNOWN_FORMAT); - } - switch(CertGroupFrag.CertEncoding) { - case CSSM_CERT_ENCODING_BER: - case CSSM_CERT_ENCODING_DER: - break; - default: - CssmError::throwMe(CSSMERR_TP_UNKNOWN_FORMAT); - } - - /* - * Set up incoming and outgoing TPCertGrorups. - */ - inCertGroup = new TPCertGroup(*this, CertGroupFrag.NumCerts - 1); - outCertGroup = new TPCertGroup(*this, CertGroupFrag.NumCerts); - - /* - * Parse first (leaf) cert. Note that this cert is special: if it's bad we abort - * immediately; otherwise it goes directly into outCertGroup. - */ - try { - certInfo = new TPCertInfo( - &CertGroupFrag.GroupList.CertList[0], - clHand, - cssmTimeStr); - certInfo->index(0); - } - catch(const CssmError &cerr) { - outErr = CSSMERR_TP_INVALID_CERTIFICATE; - goto abort; - } - catch(...) { - /* everything else is way fatal */ - throw; - } - - /* Add to outCertGroup even if it's not current */ - outCertGroup->appendCert(certInfo); - - #if TP_CERT_CURRENT_CHECK_INLINE - /* verify this first one is current */ - outErr = certInfo->isCurrent(allowExpired); - if(outErr) { - goto abort; - } - #endif - /* this'll be the first subject cert in the main loop */ - subjectCert = certInfo; - - /* - * Add remaining input certs to inCertGroup. Note that this lets us - * skip bad incoming certs right away. - */ - for(certDex=1; certDexindex(certDex); - inCertGroup->appendCert(certInfo); - } - - /*** main loop *** - * - * On entry, we have two TPCertGroups. InCertGroup contains n-1 certs, where n - * is the size of the CertGroupFrag passed to us by the caller. The certs in - * inCertGroup are unordered but are known to be parseable, CL-cacheable certs. - * OutGroupCert contains one cert, the incoming leaf cert. - * - * The job in this loop is to build an ordered, verified cert chain in - * outCertGroup out of certs from inCertGroup and/or DBList. As good certs - * are found in inCertGroup, they're removed from that TPCertGroup. On exit - * we delete inCertGroup, which deletes all the remaining TPCertInfo's in it. - * The constructed outCertGroup is returned to the caller. - * - * Exit loop on: - * -- find a root cert in the chain - * -- memory error - * -- or no more certs to add to chain. - */ - for(;;) { - /* top of loop: subjectCert is the cert we're trying to verify. */ - - /* is this a root cert? */ - if(subjectCert->isSelfSigned()) { - /* - * Verify this alleged root cert. We're at the end of the chain no - * matter what happens here. - * Note we already validated before/after when this was tested - * as issuer (or, if it's the leaf cert, before we entered this loop). - */ - outErr = tp_VerifyCert(clHand, - cspHand, - subjectCert, - subjectCert, - CSSM_FALSE, // checkIssuerCurrent - CSSM_TRUE); // allowExpired, don't care - break; - } - - /* Search unused incoming certs to find an issuer */ - for(certDex=0; certDexnumCerts(); certDex++) { - certInfo = inCertGroup->certAtIndex(certDex); - - /* potential issuer - names match? */ - if(tpIsSameName(subjectCert->issuerName(), certInfo->subjectName())) { - /* yep, do a sig verify with "not before/after" check */ - crtn = tp_VerifyCert(clHand, - cspHand, - subjectCert, - certInfo, - CSSM_TRUE, - allowExpired); - switch(crtn) { - case CSSM_OK: - /* YES! We'll add it to outCertGroup below...*/ - issuerCert = certInfo; - inCertGroup->removeCertAtIndex(certDex); - goto issuerLoopEnd; - case CSSMERR_TP_CERT_NOT_VALID_YET: - case CSSMERR_TP_CERT_EXPIRED: - /* special case - abort immediateley (note the cert - * sig verify succeeded.) */ - /*** for now we include this in the evidence ***/ - outCertGroup->appendCert(subjectCert); - outErr = crtn; - goto abort; - default: - /* just skip this one and keep looking */ - break; - } - } /* names match */ - } /* searching inCertGroup for issuer */ - -issuerLoopEnd: + subjectCert = inCertGroup.certAtIndex(0); - #if TP_DL_ENABLE - if(issuerCert == NULL) { - /* Issuer not in incoming cert group. Search DBList. */ - CSSM_BOOL subjectExpired = CSSM_FALSE; - issuerCert = tpFindIssuer(*this, - clHand, - cspHand, - subjectCert, - subjectCert->issuerName(), - &DBList, - cssmTimeStr, - &subjectExpired); - if(subjectExpired) { - /* special case - abort immediately */ - outErr = subjectExpired; - goto abort; - } - } /* Issuer not in incoming cert group */ - #endif /* TP_DL_ENABLE */ - - if(issuerCert == NULL) { - /* end of search, broken chain */ - break; - } - - /* - * One way or the other, we've found a cert which verifies subjectCert. - * Add the issuer to outCertGroup and make it the new subjectCert for - * the next pass. - */ - outCertGroup->appendCert(issuerCert); - subjectCert = issuerCert; - issuerCert = NULL; - } /* main loop */ + /* Append leaf cert to outCertGroup */ + outCertGroup.appendCert(subjectCert); + subjectCert->isLeaf(true); + outCertGroup.setAllUnused(); -abort: - delete inCertGroup; - CertGroup = outCertGroup; + outErr = outCertGroup.buildCertGroup( + *subjectCert, + &inCertGroup, + DBList, + clHand, + cspHand, + cssmTimeStr, + numAnchorCerts, + anchorCerts, + certsToBeFreed, + NULL, // gatheredCerts - none here + CSSM_TRUE, // subjectIsInGroup - enables root check on + // subject cert + actionFlags, + verifiedToRoot, + verifiedToAnchor); if(outErr) { CssmError::throwMe(outErr); } @@ -401,6 +260,11 @@ abort: * CSSMERR_TP_INVALID_REQUEST_INPUTS : no incoming VerifyContext. * CSSMERR_TP_CERT_EXPIRED and CSSMERR_TP_CERT_NOT_VALID_YET: see comments * for CertGroupConstruct. + * CSSMERR_TP_CERTIFICATE_CANT_OPERATE : issuer cert was found with a partial + * public key, rendering full verification impossible. + * CSSMERR_TP_INVALID_CERT_AUTHORITY : issuer cert was found with a partial + * public key and which failed to perform subsequent signature + * verification. *---------------------------------------------------------------------------*/ void AppleTPSession::CertGroupVerify(CSSM_CL_HANDLE clHand, @@ -409,26 +273,27 @@ void AppleTPSession::CertGroupVerify(CSSM_CL_HANDLE clHand, const CSSM_TP_VERIFY_CONTEXT *VerifyContext, CSSM_TP_VERIFY_CONTEXT_RESULT_PTR VerifyContextResult) { - unsigned i; - TPCertInfo *lastCert; CSSM_BOOL verifiedToRoot = CSSM_FALSE; - TPPolicy policy; + CSSM_BOOL verifiedToAnchor = CSSM_FALSE; CSSM_RETURN constructReturn = CSSM_OK; CSSM_RETURN policyReturn = CSSM_OK; - CSSM_RETURN crtn; const CSSM_TP_CALLERAUTH_CONTEXT *cred; - CSSM_OID_PTR oid = NULL; - TPCertGroup *tpCertGroup = NULL; // created by - // CertGroupConstructPriv - TPCertInfo *certInfo = NULL; CSSM_BOOL allowExpired = CSSM_FALSE; CSSM_BOOL allowExpiredRoot = CSSM_FALSE; /* declare volatile as compiler workaround to avoid caching in CR4 */ const CSSM_APPLE_TP_ACTION_DATA * volatile actionData = NULL; - const CSSM_APPLE_TP_SSL_OPTIONS *sslOpts = NULL; - const CSSM_DATA *fieldVal; CSSM_TIMESTRING cssmTimeStr; + CSSM_APPLE_TP_ACTION_FLAGS actionFlags = 0; + CSSM_TP_STOP_ON tpStopOn = 0; + /* keep track of whether we did policy checking; if not, we do defaults */ + bool didCertPolicy = false; + bool didRevokePolicy = false; + + if(VerifyContextResult) { + memset(VerifyContextResult, 0, sizeof(*VerifyContextResult)); + } + /* verify input args, skipping the ones checked by CertGroupConstruct */ if((VerifyContext == NULL) || (VerifyContext->Cred == NULL)) { /* the spec says that this is optional but we require it */ @@ -436,61 +301,6 @@ void AppleTPSession::CertGroupVerify(CSSM_CL_HANDLE clHand, } cred = VerifyContext->Cred; - /* Check out requested policies */ - switch(cred->Policy.NumberOfPolicyIds) { - case 0: - /* default */ - policy = kTPDefault; - break; - case 1: - if(cred->Policy.PolicyIds == NULL) { - CssmError::throwMe(CSSMERR_TP_INVALID_POLICY_IDENTIFIERS); - } - fieldVal = &cred->Policy.PolicyIds->FieldValue; - oid = &cred->Policy.PolicyIds->FieldOid; - if(tpCompareOids(oid, &CSSMOID_APPLE_ISIGN)) { - policy = kTPiSign; - /* no options */ - if(fieldVal->Data != NULL) { - CssmError::throwMe(CSSMERR_TP_INVALID_POLICY_IDENTIFIERS); - } - } - else if(tpCompareOids(oid, &CSSMOID_APPLE_X509_BASIC)) { - policy = kTPx509Basic; - /* no options */ - if(fieldVal->Data != NULL) { - CssmError::throwMe(CSSMERR_TP_INVALID_POLICY_IDENTIFIERS); - } - } - else if(tpCompareOids(oid, &CSSMOID_APPLE_TP_SSL)) { - policy = kTP_SSL; - /* SSL-specific options */ - sslOpts = (CSSM_APPLE_TP_SSL_OPTIONS *)fieldVal->Data; - if(sslOpts != NULL) { - switch(sslOpts->Version) { - case CSSM_APPLE_TP_SSL_OPTS_VERSION: - if(fieldVal->Length != - sizeof(CSSM_APPLE_TP_SSL_OPTIONS)) { - CssmError::throwMe( - CSSMERR_TP_INVALID_POLICY_IDENTIFIERS); - } - break; - /* handle backwards compatibility here if necessary */ - default: - CssmError::throwMe(CSSMERR_TP_INVALID_POLICY_IDENTIFIERS); - } - } - } - else { - /* unknown TP OID */ - CssmError::throwMe(CSSMERR_TP_INVALID_POLICY_IDENTIFIERS); - } - break; - default: - /* only zero or one allowed */ - CssmError::throwMe(CSSMERR_TP_INVALID_POLICY_IDENTIFIERS); - } - /* Optional ActionData affecting all policies */ actionData = (CSSM_APPLE_TP_ACTION_DATA * volatile)VerifyContext->ActionData.Data; if(actionData != NULL) { @@ -501,11 +311,12 @@ void AppleTPSession::CertGroupVerify(CSSM_CL_HANDLE clHand, CssmError::throwMe(CSSMERR_TP_INVALID_ACTION_DATA); } break; - /* handle backwards versions here if we ever go byond version 0 */ + /* handle backwards versions here if we ever go beyond version 0 */ default: CssmError::throwMe(CSSMERR_TP_INVALID_ACTION_DATA); } - if(actionData->ActionFlags & CSSM_TP_ACTION_ALLOW_EXPIRED) { + actionFlags = actionData->ActionFlags; + if(actionFlags & CSSM_TP_ACTION_ALLOW_EXPIRED) { allowExpired = CSSM_TRUE; } if(actionData->ActionFlags & CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT) { @@ -516,177 +327,318 @@ void AppleTPSession::CertGroupVerify(CSSM_CL_HANDLE clHand, /* optional, may be NULL */ cssmTimeStr = cred->VerifyTime; + tpStopOn = cred->VerificationAbortOn; + switch(tpStopOn) { + /* the only two we support */ + case CSSM_TP_STOP_ON_NONE: + case CSSM_TP_STOP_ON_FIRST_FAIL: + break; + /* default maps to stop on first fail */ + case CSSM_TP_STOP_ON_POLICY: + tpStopOn = CSSM_TP_STOP_ON_FIRST_FAIL; + break; + default: + CssmError::throwMe(CSSMERR_TP_INVALID_STOP_ON_POLICY); + } + /* now the args we can't deal with */ if(cred->CallerCredentials != NULL) { CssmError::throwMe(CSSMERR_TP_INVALID_CALLERAUTH_CONTEXT_POINTER); } - /* FIXME - ANY OTHERS? */ + /* ...any others? */ /* get verified (possibly partial) outCertGroup - error is fatal */ /* BUT: we still return partial evidence if asked to...from now on. */ + TPCertGroup outCertGroup(*this, + TGO_Caller); // certs are owned by inCertGroup + TPCertGroup inCertGroup(CertGroupToBeVerified, clHand, cspHand, *this, + cssmTimeStr, // optional 'this' time + true, // firstCertMustBeValid + TGO_Group); + + /* set up for disposal of TPCertInfos created by CertGroupConstructPriv */ + TPCertGroup certsToBeFreed(*this, TGO_Group); + try { CertGroupConstructPriv( clHand, cspHand, - *cred->DBList, // not optional to Construct! - NULL, - CertGroupToBeVerified, - allowExpired, + inCertGroup, + cred->DBList, cssmTimeStr, - tpCertGroup); + cred->NumberOfAnchorCerts, + cred->AnchorCerts, + actionFlags, + certsToBeFreed, + verifiedToRoot, + verifiedToAnchor, + outCertGroup); } catch(const CssmError &cerr) { constructReturn = cerr.cssmError(); /* abort if no certs found */ - if((tpCertGroup == NULL) || (tpCertGroup->numCerts() == 0)) { + if(outCertGroup.numCerts() == 0) { CssmError::throwMe(constructReturn); } /* else press on, collecting as much info as we can */ } /* others are way fatal */ - CASSERT(tpCertGroup != NULL); - CASSERT(tpCertGroup->numCerts() >= 1); + assert(outCertGroup.numCerts() >= 1); + + /* Infer interim status from return values */ + if((constructReturn != CSSMERR_TP_CERTIFICATE_CANT_OPERATE) && + (constructReturn != CSSMERR_TP_INVALID_CERT_AUTHORITY)) { + /* these returns do not get overridden */ + if(verifiedToAnchor) { + /* full success; anchor doesn't have to be root */ + constructReturn = CSSM_OK; + } + else if(verifiedToRoot) { + /* verified to root which is not an anchor */ + constructReturn = CSSMERR_TP_INVALID_ANCHOR_CERT; + } + else { + /* partial chain, no root, not verifiable by anchor */ + constructReturn = CSSMERR_TP_NOT_TRUSTED; + } + } + + /* + * CSSMERR_TP_NOT_TRUSTED and CSSMERR_TP_INVALID_ANCHOR_CERT + * are both special cases which can result in full success + * when CSSM_TP_USE_INTERNAL_ROOT_CERTS is enabled. + */ + #if TP_ROOT_CERT_ENABLE + if(actionFlags & CSSM_TP_USE_INTERNAL_ROOT_CERTS) { + // The secret "enable root cert check" flag + + TPCertInfo *lastCert = outCertGroup.lastCert(); + if(constructReturn == CSSMERR_TP_NOT_TRUSTED) { + /* + * See if last (non-root) cert can be verified by + * an embedded root */ + assert(lastCert != NULL); + CSSM_BOOL brtn = tp_verifyWithKnownRoots(clHand, + cspHand, + lastCert); + if(brtn) { + /* success with no incoming root, actually common (successful) case */ + constructReturn = CSSM_OK; + } + } + else if(constructReturn == CSSMERR_TP_INVALID_ANCHOR_CERT) { + /* is the end cert the same as one of our trusted roots? */ + assert(lastCert != NULL); + bool brtn = tp_isKnownRootCert(lastCert, clHand); + if(brtn) { + constructReturn = CSSM_OK; + } + } + } + #endif /* TP_ROOT_CERT_ENABLE */ - /* subsequent errors and returns to out: */ - /* - * Case 1: last cert in outCertGroup is a root cert. See if - * the root cert is in AnchorCerts. - * Note that TP_CertGroupConstruct did the actual root - * self-verify test. + * Parameters passed to tp_policyVerify() and which vary per policy + * in the loop below */ - lastCert = tpCertGroup->lastCert(); - if(lastCert->isSelfSigned()) { - verifiedToRoot = CSSM_TRUE; + TPPolicy tpPolicy; + const CSSM_APPLE_TP_SSL_OPTIONS *sslOpts; + CSSM_RETURN thisPolicyRtn = CSSM_OK; // returned from tp_policyVerify() + + /* common CRL verify parameters */ + TPCrlGroup *crlGroup = NULL; + try { + crlGroup = new TPCrlGroup(&VerifyContext->Crls, + clHand, cspHand, + *this, // alloc + cssmTimeStr, + TGO_Group); + } + catch(const CssmError &cerr) { + CSSM_RETURN cr = cerr.cssmError(); + /* I don't see a straightforward way to report this error, + * other than adding it to the leaf cert's status... */ + outCertGroup.certAtIndex(0)->addStatusCode(cr); + tpDebug("CertGroupVerify: error constructing CrlGroup; continuing\n"); + } + /* others are way fatal */ + + TPCrlVerifyContext crlVfyContext(*this, + clHand, + cspHand, + cssmTimeStr, + cred->NumberOfAnchorCerts, + cred->AnchorCerts, + &inCertGroup, + crlGroup, + /* + * This may consist of certs gathered from the net (which is the purpose + * of this argument) and from DLDBs (a side-effect optimization). + */ + &certsToBeFreed, + cred->DBList, + kCrlNone, // policy, varies per policy + actionFlags, + 0); // crlOptFlags, varies per policy + + /* true if we're to execute tp_policyVerify at end of loop */ + bool doPolicyVerify; + + /* grind thru each policy */ + for(uint32 polDex=0; polDexPolicy.NumberOfPolicyIds; polDex++) { + if(cred->Policy.PolicyIds == NULL) { + policyReturn = CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + break; + } + CSSM_FIELD_PTR policyId = &cred->Policy.PolicyIds[polDex]; + const CSSM_DATA *fieldVal = &policyId->FieldValue; + const CSSM_OID *oid = &policyId->FieldOid; + thisPolicyRtn = CSSM_OK; + doPolicyVerify = false; + sslOpts = NULL; - /* see if that root cert is identical to one of the anchor certs */ - for(i=0; iNumberOfAnchorCerts; i++) { - if(tp_CompareCerts(lastCert->certData(), &cred->AnchorCerts[i])) { - /* one fully successful return */ - goto out; + /* first the basic cert policies */ + if(tpCompareOids(oid, &CSSMOID_APPLE_TP_SSL)) { + tpPolicy = kTP_SSL; + doPolicyVerify = true; + /* and do the tp_policyVerify() call below */ + } + + else if(tpCompareOids(oid, &CSSMOID_APPLE_X509_BASIC)) { + /* no options */ + if(fieldVal->Data != NULL) { + policyReturn = CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + break; } + tpPolicy = kTPx509Basic; + doPolicyVerify = true; } - - /* verified to a root cert which is not an anchor */ - constructReturn = CSSMERR_TP_INVALID_ANCHOR_CERT; - goto out; - } - /* try to validate lastCert with anchor certs */ - for(i=0; iNumberOfAnchorCerts; i++) { - try { - certInfo = new TPCertInfo(&cred->AnchorCerts[i], - clHand, - cssmTimeStr); + else if(tpCompareOids(oid, &CSSMOID_APPLE_TP_SMIME)) { + tpPolicy = kTP_SMIME; + doPolicyVerify = true; } - catch(...) { - /* bad anchor cert - ignore it */ - continue; + + else if(tpCompareOids(oid, &CSSMOID_APPLE_TP_EAP)) { + /* treated here exactly the same as SSL */ + tpPolicy = kTP_SSL; + doPolicyVerify = true; } - if(!tpIsSameName(lastCert->issuerName(), certInfo->subjectName())) { - /* not this anchor */ - delete certInfo; - continue; + + else if(tpCompareOids(oid, &CSSMOID_APPLE_ISIGN)) { + /* no options */ + if(fieldVal->Data != NULL) { + policyReturn = CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + break; + } + tpPolicy = kTPiSign; + doPolicyVerify = true; } - crtn = tp_VerifyCert(clHand, - cspHand, - lastCert, - certInfo, - CSSM_TRUE, // check not/before of anchor - allowExpired); - switch(crtn) { - case CSSM_OK: - /* The other normal fully successful return. */ - if(certInfo->isSelfSigned()) { - verifiedToRoot = CSSM_TRUE; - } - - /* - * One more thing: add this anchor cert to the Evidence chain - */ - try { - tpCertGroup->appendCert(certInfo); - certInfo->isAnchor(true); - certInfo->index(i); + + /* now revocation policies */ + else if(tpCompareOids(oid, &CSSMOID_APPLE_TP_REVOCATION_CRL)) { + /* CRL-specific options */ + const CSSM_APPLE_TP_CRL_OPTIONS *crlOpts; + crlOpts = (CSSM_APPLE_TP_CRL_OPTIONS *)fieldVal->Data; + thisPolicyRtn = CSSM_OK; + if(crlOpts != NULL) { + switch(crlOpts->Version) { + case CSSM_APPLE_TP_CRL_OPTS_VERSION: + if(fieldVal->Length != + sizeof(CSSM_APPLE_TP_CRL_OPTIONS)) { + thisPolicyRtn = + CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + break; + } + break; + /* handle backwards compatibility here if necessary */ + default: + thisPolicyRtn = CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + break; } - catch(...) { - /* shoot - must be memory error */ - verifiedToRoot = CSSM_FALSE; - delete certInfo; - constructReturn = CSSMERR_TP_MEMORY_ERROR; + if(thisPolicyRtn != CSSM_OK) { + policyReturn = thisPolicyRtn; + break; } - goto out; - - #if TP_CERT_CURRENT_CHECK_INLINE - case CSSMERR_TP_CERT_NOT_VALID_YET: - case CSSMERR_TP_CERT_EXPIRED: - /* special case - abort immediateley */ - delete certInfo; - constructReturn = crtn; - goto out; - #endif /* TP_CERT_CURRENT_CHECK_INLINE */ - - default: - /* continue to next anchor */ - delete certInfo; + } + crlVfyContext.policy = kCrlBasic; + crlVfyContext.crlOpts = crlOpts; + + thisPolicyRtn = tpVerifyCertGroupWithCrls(outCertGroup, + crlVfyContext); + didRevokePolicy = true; + } + /* etc. - add more policies here */ + else { + /* unknown TP policy OID */ + policyReturn = CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + break; + } + + /* common tp_policyVerify call */ + if(doPolicyVerify) { + thisPolicyRtn = tp_policyVerify(tpPolicy, + *this, + clHand, + cspHand, + &outCertGroup, + verifiedToRoot, + actionFlags, + fieldVal, + cred->Policy.PolicyControl); // not currently used + didCertPolicy = true; + } + + if(thisPolicyRtn) { + /* Policy error. First remember the error if it's the first policy + * error we'veÊseen. */ + if(policyReturn == CSSM_OK) { + policyReturn = thisPolicyRtn; + } + /* Keep going? */ + if(tpStopOn == CSSM_TP_STOP_ON_FIRST_FAIL) { + /* Nope; we're done with policy evaluation */ break; + } } - } /* for each anchor */ + } /* for each policy */ - /* partial chain, no root, not verifiable by anchor */ - constructReturn = CSSMERR_TP_NOT_TRUSTED; - - /* common exit - error or success */ -out: - /* - * Do further policy verification if appropriate. - * - * SSL: CSSMERR_TP_NOT_TRUSTED and CSSMERR_TP_INVALID_ANCHOR_CERT - * are both special cases which can result in full success. + /* + * Upon completion of the above loop, perform default policy ops if + * appropriate. */ - #if TP_ROOT_CERT_ENABLE - if((policy == kTP_SSL) && - (constructReturn == CSSMERR_TP_NOT_TRUSTED) && - (actionData != NULL) && - (actionData->ActionFlags & 0x80000000)) {// The secret "enable root cert check" flag - /* see if last cert can be verified by an embedded SSL root */ - certInfo = tpCertGroup->lastCert(); - CSSM_BOOL brtn = tp_verifyWithSslRoots(clHand, - cspHand, - certInfo); - if(brtn) { - /* SSL success with no incoming root */ - /* note unknown incoming root (INVALID_ANCHOR_CERT) is handled - * below, after tp_policyVerify */ - constructReturn = CSSM_OK; - } - } - #endif /* TP_ROOT_CERT_ENABLE */ - if(tpCertGroup->numCerts() != 0) { - /* policy check if we saw even one cert */ - policyReturn = tp_policyVerify(policy, - *this, - clHand, - cspHand, - tpCertGroup, - verifiedToRoot, - actionData, - sslOpts, - cred->Policy.PolicyControl); // not currently used - #if TP_ROOT_CERT_ENABLE - if((policyReturn == CSSM_OK) && - (constructReturn == CSSMERR_TP_INVALID_ANCHOR_CERT) && - (policy == kTP_SSL) && - (actionData != NULL) && - (actionData->ActionFlags & 0x80000000)) { - /* The secret "enable root cert check" flag... */ - /* SSL - found a good anchor, move to full success */ - constructReturn = CSSM_OK; + if((policyReturn == CSSM_OK) || (tpStopOn == CSSM_TP_STOP_ON_NONE)) { + if(!didCertPolicy) { + policyReturn = tp_policyVerify(kTPDefault, + *this, + clHand, + cspHand, + &outCertGroup, + verifiedToRoot, + actionFlags, + NULL, // policyFieldData + cred->Policy.PolicyControl); // not currently used } - #endif - } + if( !didRevokePolicy && // no revoke policy yet + ( (policyReturn == CSSM_OK || // default cert policy OK + (tpStopOn == CSSM_TP_STOP_ON_NONE)) // keep going anyway + ) + ) { - /* return evidence - i.e., current chain - if asked to */ + crlVfyContext.policy = TP_CRL_POLICY_DEFAULT; + crlVfyContext.crlOpts = NULL; + CSSM_RETURN thisPolicyRtn = tpVerifyCertGroupWithCrls(outCertGroup, + crlVfyContext); + if((thisPolicyRtn != CSSM_OK) && (policyReturn == CSSM_OK)) { + policyReturn = thisPolicyRtn; + } + + } + } /* default policy opts */ + + delete crlGroup; + + /* return evidence - i.e., constructed chain - if asked to */ if(VerifyContextResult != NULL) { /* * VerifyContextResult->Evidence[0] : CSSM_TP_APPLE_EVIDENCE_HEADER @@ -698,7 +650,8 @@ out: (CSSM_EVIDENCE_PTR)calloc(3, sizeof(CSSM_EVIDENCE)); CSSM_TP_APPLE_EVIDENCE_HEADER *hdr = - (CSSM_TP_APPLE_EVIDENCE_HEADER *)malloc(sizeof(CSSM_TP_APPLE_EVIDENCE_HEADER)); + (CSSM_TP_APPLE_EVIDENCE_HEADER *)malloc( + sizeof(CSSM_TP_APPLE_EVIDENCE_HEADER)); hdr->Version = CSSM_TP_APPLE_EVIDENCE_VERSION; CSSM_EVIDENCE_PTR ev = &VerifyContextResult->Evidence[0]; ev->EvidenceForm = CSSM_EVIDENCE_FORM_APPLE_HEADER; @@ -706,18 +659,16 @@ out: ev = &VerifyContextResult->Evidence[1]; ev->EvidenceForm = CSSM_EVIDENCE_FORM_APPLE_CERTGROUP; - ev->Evidence = tpCertGroup->buildCssmCertGroup(); + ev->Evidence = outCertGroup.buildCssmCertGroup(); ev = &VerifyContextResult->Evidence[2]; ev->EvidenceForm = CSSM_EVIDENCE_FORM_APPLE_CERT_INFO; - ev->Evidence = tpCertGroup->buildCssmEvidenceInfo(); + ev->Evidence = outCertGroup.buildCssmEvidenceInfo(); } - CSSM_RETURN outErr = tpCertGroup->getReturnCode(constructReturn, + CSSM_RETURN outErr = outCertGroup.getReturnCode(constructReturn, allowExpired, allowExpiredRoot, policyReturn); - /* delete (internal use only) TPCertGroup */ - delete tpCertGroup; if(outErr) { CssmError::throwMe(outErr); } diff --git a/AppleX509TP/tpCredRequest.cpp b/AppleX509TP/tpCredRequest.cpp index 71b6e6f8..b5dd7efe 100644 --- a/AppleX509TP/tpCredRequest.cpp +++ b/AppleX509TP/tpCredRequest.cpp @@ -35,7 +35,7 @@ #include #include -#define tpCredDebug(args...) debug("tpCred", ## args) +#define tpCredDebug(args...) secdebug("tpCred", ## args) /* * Build up a CSSM_X509_NAME from an arbitrary list of name/OID pairs. @@ -47,6 +47,11 @@ CSSM_X509_NAME * AppleTPSession::buildX509Name( { CSSM_X509_NAME *top = (CSSM_X509_NAME *)malloc(sizeof(CSSM_X509_NAME)); top->numberOfRDNs = numNames; + if(numNames == 0) { + /* legal! */ + top->RelativeDistinguishedName = NULL; + return top; + } top->RelativeDistinguishedName = (CSSM_X509_RDN_PTR)malloc(sizeof(CSSM_X509_RDN) * numNames); CSSM_X509_RDN_PTR rdn; @@ -211,6 +216,7 @@ void AppleTPSession::refKeyToRaw( tpCredDebug("AppleTPSession::refKeyToRaw: context err"); CssmError::throwMe(crtn); } + crtn = CSSM_WrapKey(ccHand, &creds, refKey, @@ -424,7 +430,6 @@ CSSM_DATA_PTR AppleTPSession::getCertFromMap( */ void AppleTPSession::SubmitCsrRequest( const CSSM_TP_REQUEST_SET &RequestInput, - const CSSM_TP_CALLERAUTH_CONTEXT *CallerAuthContext, sint32 &EstimatedTime, // RETURNED CssmData &ReferenceIdentifier) // RETURNED { @@ -445,10 +450,6 @@ void AppleTPSession::SubmitCsrRequest( (certReq->signatureOid.Data == NULL)) { CssmError::throwMe(CSSMERR_TP_INVALID_REQUEST_INPUTS); } - if((certReq->subjectNames == NULL) || - (certReq->numSubjectNames == 0)) { - CssmError::throwMe(CSSMERR_TP_INVALID_NAME); - } /* convert ref public key to raw per CL requirements */ const CSSM_KEY *subjectPubKey = certReq->certPublicKey; @@ -485,7 +486,7 @@ void AppleTPSession::SubmitCsrRequest( CSSM_RETURN crtn; crtn = CSSM_CSP_CreateSignatureContext(certReq->cspHand, certReq->signatureAlg, - (CallerAuthContext ? CallerAuthContext->CallerCredentials : NULL), + NULL, // AccessCred certReq->issuerPrivateKey, &sigHand); if(crtn) { @@ -575,7 +576,7 @@ void AppleTPSession::SubmitCredRequest( if(tpCompareCssmData(&tpPolicy->PolicyIds->FieldOid, &CSSMOID_APPLE_TP_CSR_GEN)) { /* break out to CSR-specific code */ - SubmitCsrRequest(RequestInput, CallerAuthContext, EstimatedTime, ReferenceIdentifier); + SubmitCsrRequest(RequestInput, EstimatedTime, ReferenceIdentifier); return; } else if(!tpCompareCssmData(&tpPolicy->PolicyIds->FieldOid, @@ -591,10 +592,6 @@ void AppleTPSession::SubmitCredRequest( (certReq->issuerPrivateKey == NULL)) { CssmError::throwMe(CSSMERR_TP_INVALID_REQUEST_INPUTS); } - if((certReq->subjectNames == NULL) || - (certReq->numSubjectNames == 0)) { - CssmError::throwMe(CSSMERR_TP_INVALID_NAME); - } if((certReq->numExtensions != 0) & (certReq->extensions == NULL)) { CssmError::throwMe(CSSMERR_TP_INVALID_POINTER); } diff --git a/AppleX509TP/tpCrlVerify.cpp b/AppleX509TP/tpCrlVerify.cpp new file mode 100644 index 00000000..66612fb3 --- /dev/null +++ b/AppleX509TP/tpCrlVerify.cpp @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * tpCrlVerify.cpp - routines to verify CRLs and to verify certs against CRLs. + * + * Written 9/26/02 by Doug Mitchell. + */ + +#include "tpCrlVerify.h" +#include "TPCertInfo.h" +#include "TPCrlInfo.h" +#include "tpdebugging.h" +#include "TPNetwork.h" +#include "TPDatabase.h" +#include +#include + +/* crlrefresh does this now */ +#define WRITE_FETCHED_CRLS_TO_DB 0 + +/* + * For now, a process-wide memory resident CRL cache. + * We are responsible for deleting the CRLs which get added to this + * cache. Currently the only time we add a CRL to this cache is + * when we fetch one from the net. We ref count CRLs in this cache + * to allow multi-threaded access. + */ +class TPCRLCache : private TPCrlGroup +{ +public: + TPCRLCache(); + ~TPCRLCache() { } + TPCrlInfo *search( + TPCertInfo &cert, + TPCrlVerifyContext &vfyCtx); + void add( + TPCrlInfo &crl); + void remove( + TPCrlInfo &crl); + void release( + TPCrlInfo &crl); + +private: + /* Protects ref count of all members of the cache */ + Mutex mLock; +}; + +TPCRLCache::TPCRLCache() + : TPCrlGroup(CssmAllocator::standard(), TGO_Group) +{ + +} + +TPCrlInfo *TPCRLCache::search( + TPCertInfo &cert, + TPCrlVerifyContext &vfyCtx) +{ + StLock _(mLock); + TPCrlInfo *crl = findCrlForCert(cert); + if(crl) { + /* reevaluate validity */ + crl->calculateCurrent(vfyCtx.verifyTime); + crl->mRefCount++; + } + return crl; +} + +/* bumps ref count - caller is going to be using the CRL */ +void TPCRLCache::add( + TPCrlInfo &crl) +{ + StLock _(mLock); + crl.mRefCount++; + appendCrl(crl); +} + +/* we delete on this one if --refCount == 0 */ +void TPCRLCache::remove( + TPCrlInfo &crl) +{ + StLock _(mLock); + removeCrl(crl); + release(crl); + assert(crl.mRefCount > 0); + crl.mRefCount--; + if(crl.mRefCount == 0) { + delete &crl; + } + else { + /* in use, flag for future delete */ + crl.mToBeDeleted = true; + } +} + +/* only delete if refCount zero AND flagged for deletion */ +void TPCRLCache::release( + TPCrlInfo &crl) +{ + StLock _(mLock); + assert(crl.mRefCount > 0); + crl.mRefCount--; + if(crl.mToBeDeleted & (crl.mRefCount == 0)) { + delete &crl; + } +} + +static ModuleNexus tpGlobalCrlCache; + +/* + * Find CRL for specified cert. Only returns a fully verified CRL. + * Cert-specific errors such as CSSMERR_APPLETP_CRL_NOT_FOUND will be added + * to cert's return codes. + */ +static CSSM_RETURN tpFindCrlForCert( + TPCertInfo &subject, + TPCrlInfo *&foundCrl, // RETURNED + TPCrlVerifyContext &vfyCtx) +{ + + TPCrlInfo *crl = NULL; + foundCrl = NULL; + CSSM_APPLE_TP_CRL_OPT_FLAGS crlOptFlags = 0; + + if(vfyCtx.crlOpts) { + crlOptFlags = vfyCtx.crlOpts->CrlFlags; + } + + /* Search inputCrls for a CRL for subject cert */ + if(vfyCtx.inputCrls != NULL) { + crl = vfyCtx.inputCrls->findCrlForCert(subject); + if(crl && (crl->verifyWithContext(vfyCtx, &subject) == CSSM_OK)) { + foundCrl = crl; + crl->mFromWhere = CFW_InGroup; + tpCrlDebug(" ...CRL found in CrlGroup"); + return CSSM_OK; + } + } + + /* local process-wide cache */ + crl = tpGlobalCrlCache().search(subject, vfyCtx); + if(crl) { + if(crl->verifyWithContext(vfyCtx, &subject) == CSSM_OK) { + foundCrl = crl; + crl->mFromWhere = CFW_LocalCache; + tpCrlDebug(" ...CRL found in local cache"); + return CSSM_OK; + } + else { + tpGlobalCrlCache().remove(*crl); + } + } + + /* + * Try DL/DB. + * Note tpDbFindIssuerCrl() returns a verified CRL. + */ + crl = tpDbFindIssuerCrl(vfyCtx, *subject.issuerName(), subject); + if(crl) { + foundCrl = crl; + crl->mFromWhere = CFW_DlDb; + tpCrlDebug(" ...CRL found in DlDb"); + return CSSM_OK; + } + + /* Last resort: try net if enabled */ + CSSM_RETURN crtn = CSSMERR_APPLETP_CRL_NOT_FOUND; + crl = NULL; + if(crlOptFlags & CSSM_TP_ACTION_FETCH_CRL_FROM_NET) { + crtn = tpFetchCrlFromNet(subject, vfyCtx, crl); + } + + if(crtn) { + subject.addStatusCode(crtn); + tpCrlDebug(" ...tpFindCrlForCert: CRL not found"); + return crtn; + } + + /* got one from net - add to global cache */ + assert(crl != NULL); + tpGlobalCrlCache().add(*crl); + crl->mFromWhere = CFW_Net; + tpCrlDebug(" ...CRL found from net"); + +#if WRITE_FETCHED_CRLS_TO_DB + /* and to DLDB if enabled */ + if((vfyCtx.crlOpts != NULL) && (vfyCtx.crlOpts->crlStore != NULL)) { + crtn = tpDbStoreCrl(*crl, *vfyCtx.crlOpts->crlStore); + if(crtn) { + /* let's not let this affect the CRL verification...just log + * the per-cert error. */ + subject.addStatusCode(crtn); + } + else { + tpCrlDebug(" ...CRL written to DB"); + } + } +#endif /* WRITE_FETCHED_CRLS_TO_DB */ + + foundCrl = crl; + return CSSM_OK; +} + +/* + * Dispose of a CRL obtained from tpFindCrlForCert(). + */ +static void tpDisposeCrl( + TPCrlInfo &crl, + TPCrlVerifyContext &vfyCtx) +{ + switch(crl.mFromWhere) { + case CFW_Nowhere: + default: + assert(0); + CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); + case CFW_InGroup: + /* nothing to do, handled by TPCrlGroup */ + return; + case CFW_DlDb: + /* cooked up specially for this call */ + delete &crl; + return; + case CFW_LocalCache: // cache hit + case CFW_Net: // fetched from net & added to cache + tpGlobalCrlCache().release(crl); + return; + /* probably others */ + } +} + +/* + * Perform CRL verification on a cert group. + * The cert group has already passed basic issuer/subject and signature + * verification. The status of the incoming CRLs is completely unknown. + * + * FIXME - No mechanism to get CRLs from net with non-NULL verifyTime. + * How are we supposed to get the CRL which was valid at a specified + * time in the past? + */ +CSSM_RETURN tpVerifyCertGroupWithCrls( + TPCertGroup &certGroup, // to be verified + TPCrlVerifyContext &vfyCtx) +{ + CSSM_RETURN crtn; + CSSM_RETURN ourRtn = CSSM_OK; + + switch(vfyCtx.policy) { + case kCrlNone: + return CSSM_OK; + case kCrlBasic: + break; + default: + return CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + } + + assert(vfyCtx.clHand != 0); + tpCrlDebug("tpVerifyCertGroupWithCrls numCerts %u", certGroup.numCerts()); + CSSM_APPLE_TP_CRL_OPT_FLAGS optFlags = 0; + if(vfyCtx.crlOpts != NULL) { + optFlags = vfyCtx.crlOpts->CrlFlags; + } + + /* found & verified CRLs we need to release */ + TPCrlGroup foundCrls(vfyCtx.alloc, TGO_Caller); + + try { + + unsigned certDex; + TPCrlInfo *crl = NULL; + + /* main loop, verify each cert */ + for(certDex=0; certDexisAnchor() ? "anchor " : "", cert->index()); + if(cert->isSelfSigned()) { + /* CRL meaningless for a root cert */ + continue; + } + crl = NULL; + do { + /* find a CRL for this cert by hook or crook */ + crtn = tpFindCrlForCert(*cert, crl, vfyCtx); + if(crtn) { + if(!(optFlags & CSSM_TP_ACTION_REQUIRE_CRL_PER_CERT)) { + /* + * This is the only place where "Best Attempt" + * tolerates an error + */ + tpCrlDebug(" ...cert %u: no CRL; skipping", + cert->index()); + crtn = CSSM_OK; + } + break; + } + /* Keep track; we'll release all when done. */ + assert(crl != NULL); + foundCrls.appendCrl(*crl); + + /* revoked? */ + crtn = crl->isCertRevoked(*cert); + if(crtn) { + break; + } + tpCrlDebug(" ...cert %u VERIFIED by CRL", cert->index()); + } while(0); + + /* done processing one cert */ + if(crtn) { + tpCrlDebug(" ...cert at index %u FAILED crl vfy", + cert->index()); + if(ourRtn == CSSM_OK) { + ourRtn = crtn; + } + /* continue on to next cert */ + } /* error on one cert */ + } /* for each cert */ + } + catch(const CssmError &cerr) { + if(ourRtn == CSSM_OK) { + ourRtn = cerr.cssmError(); + } + } + /* other exceptions fatal */ + + /* release all found CRLs */ + for(unsigned dex=0; dex +#include + +class TPCertInfo; +class TPCertGroup; +class TPCrlInfo; +class TPCrlGroup; + +/* + * Enumerated CRL policies enforced by this module. + */ +typedef enum { + kCrlNone, /* no CRL checking */ + kCrlBasic, +} TPCrlPolicy; + +/* Module-specific default policy */ +#define TP_CRL_POLICY_DEFAULT kCrlNone + +/* + * Various parameters widely used in any operation involing the + * verification of CRLs and of a cert against a CRL. Most fields + * are generally optional for a given operation except. + */ +class TPCrlVerifyContext { + NOCOPY(TPCrlVerifyContext) +public: + TPCrlVerifyContext( + CssmAllocator &_alloc, + CSSM_CL_HANDLE _clHand, + CSSM_CSP_HANDLE _cspHand, + CSSM_TIMESTRING _verifyTime, + uint32 _numAnchorCerts, + const CSSM_DATA *_anchorCerts, + TPCertGroup *_signerCerts, + TPCrlGroup *_inputCrls, + TPCertGroup *_gatheredCerts, + CSSM_DL_DB_LIST_PTR _dbList, + TPCrlPolicy _policy, + CSSM_APPLE_TP_ACTION_FLAGS _actionFlags, + CSSM_APPLE_TP_CRL_OPTIONS *_crlOpts) + : alloc(_alloc), + clHand(_clHand), + cspHand(_cspHand), + verifyTime(_verifyTime), + numAnchorCerts(_numAnchorCerts), + anchorCerts(_anchorCerts), + signerCerts(_signerCerts), + inputCrls(_inputCrls), + gatheredCerts(_gatheredCerts), + dbList(_dbList), + policy(_policy), + actionFlags(_actionFlags), + crlOpts(_crlOpts) + { } + + ~TPCrlVerifyContext() { } + + CssmAllocator &alloc; + CSSM_CL_HANDLE clHand; + CSSM_CSP_HANDLE cspHand; + + /* + * NULL means "verify for this momemt", otherwise indicates + * time at which an entity is to be verified. + */ + CSSM_TIMESTRING verifyTime; + + /* trusted anchors */ + /* FIXME - maybe this should be a TPCertGroup */ + uint32 numAnchorCerts; + const CSSM_DATA *anchorCerts; + + /* + * Intermediate CRL signing certs. Optional. + * This could come from the raw cert group to be verified + * in CertGroupVerify(), or the explicit SignerCertGroup in + * CrlVerify(). These certs have not been verified in any + * way other than to ensure that they parse and have been cached + * by the CL. + */ + TPCertGroup *signerCerts; + + /* Raw CRLs provided by caller, state unknown, optional */ + TPCrlGroup *inputCrls; + + /* + * Other certificates gathered during the course of this operation, + * currently consisting of certs fetched from DBs and from the net. + * This is currently set to AppleTPSession::CertGroupVerify's + * certsToBeFreed, to include certs fetched from the net (a + * significant optimization) and from DLDB (a side effect, also + * a slight optimization). + */ + TPCertGroup *gatheredCerts; + + /* can contain certs and/or CRLs */ + CSSM_DL_DB_LIST_PTR dbList; + + TPCrlPolicy policy; + CSSM_APPLE_TP_ACTION_FLAGS actionFlags; + const CSSM_APPLE_TP_CRL_OPTIONS *crlOpts; +}; + +extern "C" { + +CSSM_RETURN tpVerifyCertGroupWithCrls( + TPCertGroup &certGroup, // to be verified + TPCrlVerifyContext &tpVerifyContext); + +} + +#endif /* _TP_CRL_VERIFY_H_ */ diff --git a/AppleX509TP/tpPolicies.cpp b/AppleX509TP/tpPolicies.cpp index 476a4705..67423dfd 100644 --- a/AppleX509TP/tpPolicies.cpp +++ b/AppleX509TP/tpPolicies.cpp @@ -38,6 +38,7 @@ #include #include + /* * Our private per-extension info. One of these per (understood) extension per * cert. @@ -54,13 +55,14 @@ typedef struct { */ typedef struct { - /* extensions pertinent to iSign */ + /* extensions we're interested in */ iSignExtenInfo authorityId; iSignExtenInfo subjectId; iSignExtenInfo keyUsage; iSignExtenInfo extendKeyUsage; iSignExtenInfo basicConstraints; iSignExtenInfo netscapeCertType; + iSignExtenInfo subjectAltName; /* flag indicating presence of a critical extension we don't understand */ CSSM_BOOL foundUnknownCritical; @@ -78,7 +80,7 @@ static CSSM_RETURN tpSetupExtension( iSignExtenInfo *extnInfo) // which component of certInfo { if(extnData->Length != sizeof(CSSM_X509_EXTENSION)) { - errorLog0("tpSetupExtension: malformed CSSM_FIELD\n"); + tpPolicyError("tpSetupExtension: malformed CSSM_FIELD"); return CSSMERR_TP_UNKNOWN_FORMAT; } CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)extnData->Data; @@ -147,7 +149,7 @@ static CSSM_RETURN iSignSearchUnknownExtensions( } if(fieldValue->Length != sizeof(CSSM_X509_EXTENSION)) { - errorLog0("iSignSearchUnknownExtensions: malformed CSSM_FIELD\n"); + tpPolicyError("iSignSearchUnknownExtensions: malformed CSSM_FIELD"); return CSSMERR_TP_UNKNOWN_FORMAT; } CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)fieldValue->Data; @@ -168,11 +170,13 @@ static CSSM_RETURN iSignSearchUnknownExtensions( &fieldValue); if(crtn) { /* should never happen */ - errorLog0("searchUnknownExtensions: GetNextCachedFieldValue error\n"); + tpPolicyError("searchUnknownExtensions: GetNextCachedFieldValue" + "error"); break; } if(fieldValue->Length != sizeof(CSSM_X509_EXTENSION)) { - errorLog0("iSignSearchUnknownExtensions: malformed CSSM_FIELD\n"); + tpPolicyError("iSignSearchUnknownExtensions: " + "malformed CSSM_FIELD"); crtn = CSSMERR_TP_UNKNOWN_FORMAT; break; } @@ -253,6 +257,13 @@ static CSSM_RETURN iSignGetCertInfo( if(crtn) { return crtn; } + crtn = iSignFetchExtension(alloc, + tpCert, + &CSSMOID_SubjectAltName, + &certInfo->subjectAltName); + if(crtn) { + return crtn; + } /* now look for extensions we don't understand - the only thing we're interested * in is the critical flag. */ @@ -290,216 +301,58 @@ static void iSignFreeCertInfo( CSSM_CL_FreeFieldValue(clHand, &CSSMOID_NetscapeCertType, certInfo->netscapeCertType.valToFree); } -} - -#if TP_ROOT_CERT_ENABLE -/* - * Common code for comparing a root to a list of known embedded roots. - */ -static CSSM_BOOL tp_isKnownRootCert( - TPCertInfo *rootCert, // raw cert to compare - const tpRootCert *knownRoots, - unsigned numKnownRoots) -{ - const CSSM_DATA *subjectName = NULL; - CSSM_DATA_PTR publicKey = NULL; - unsigned dex; - CSSM_BOOL brtn = CSSM_FALSE; - CSSM_DATA_PTR valToFree = NULL; - - subjectName = rootCert->subjectName(); - publicKey = tp_CertGetPublicKey(rootCert, &valToFree); - if(publicKey == NULL) { - errorLog0("tp_isKnownRootCert: error retrieving public key info!\n"); - goto errOut; - } - - /* - * Grind thru the list of known certs, demanding perfect match of - * both fields - */ - for(dex=0; dexsubjectAltName.present) { + CSSM_CL_FreeFieldValue(clHand, &CSSMOID_SubjectAltName, + certInfo->subjectAltName.valToFree); } -errOut: - tp_CertFreePublicKey(rootCert->clHand(), valToFree); - return brtn; } -/* - * See if specified root cert is a known (embedded) iSign root cert. - * Returns CSSM_TRUE if the cert is a known root cert. - * - * Note as of 6/12/02, we do not distinguish between internally - * cached iSign roots and SSL roots. Maybe someday we will do so again, - * so let's leave these two functions separate. +/* + * See if cert's Subject.{commonName,EmailAddress} matches caller-specified + * string. Returns CSSM_TRUE if match, else returns CSSM_FALSE. + * Also indicates whether *any* of the specified fields were found, regardless + * of match state. */ -static CSSM_BOOL tp_isIsignRootCert( - CSSM_CL_HANDLE clHand, - TPCertInfo *rootCert) // raw cert from cert group -{ - const tpRootCert *roots; - unsigned numRoots; - roots = TPRootStore::tpGlobalRoots().rootCerts(clHand, numRoots); - return tp_isKnownRootCert(rootCert, roots, numRoots); -} +typedef enum { + SN_CommonName, // CSSMOID_CommonName, host name format + SN_Email // CSSMOID_EmailAddress +} SubjSubjNameSearchType; -/* - * See if specified root cert is a known (embedded) SSL root cert. - * Returns CSSM_TRUE if the cert is a known root cert. - */ -static CSSM_BOOL tp_isSslRootCert( - CSSM_CL_HANDLE clHand, - TPCertInfo *rootCert) // raw cert from cert group +static CSSM_BOOL tpCompareSubjectName( + TPCertInfo &cert, + SubjSubjNameSearchType searchType, + const char *callerStr, // already tpToLower'd + uint32 callerStrLen, + bool &fieldFound) { - const tpRootCert *roots; - unsigned numRoots; - roots = TPRootStore::tpGlobalRoots().rootCerts(clHand, numRoots); - return tp_isKnownRootCert(rootCert, roots, numRoots); -} - -/* - * Attempt to verify specified cert (from the end of a chain) with one of - * our known SSL roots. - */ -CSSM_BOOL tp_verifyWithSslRoots( - CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - TPCertInfo *certToVfy) // last in chain, not root -{ - CSSM_KEY rootKey; // pub key manufactured from tpRootCert info - CSSM_CC_HANDLE ccHand; // signature context - CSSM_RETURN crtn; - unsigned dex; - const tpRootCert *rootInfo; - CSSM_BOOL brtn = CSSM_FALSE; - CSSM_KEYHEADER *hdr = &rootKey.KeyHeader; - CSSM_X509_ALGORITHM_IDENTIFIER_PTR algId; - CSSM_DATA_PTR valToFree = NULL; - CSSM_ALGORITHMS sigAlg; - const tpRootCert *rootCerts = NULL; - unsigned numRootCerts = 0; - - memset(&rootKey, 0, sizeof(CSSM_KEY)); - - /* - * Get signature algorithm from subject key - */ - algId = tp_CertGetAlgId(certToVfy, &valToFree); - if(algId == NULL) { - /* bad cert */ - return CSSM_FALSE; - } - /* subsequest errors to errOut: */ - - /* map to key and signature algorithm */ - sigAlg = tpOidToAldId(&algId->algorithm, &hdr->AlgorithmId); - if(sigAlg == CSSM_ALGID_NONE) { - errorLog0("tp_verifyWithSslRoots: unknown sig alg\n"); - goto errOut; - } + char *certName = NULL; // from cert's subject name + uint32 certNameLen = 0; + CSSM_DATA_PTR subjNameData = NULL; + CSSM_RETURN crtn; + CSSM_BOOL ourRtn = CSSM_FALSE; + const CSSM_OID *oidSrch; - /* Set up other constant key fields */ - hdr->BlobType = CSSM_KEYBLOB_RAW; - switch(hdr->AlgorithmId) { - case CSSM_ALGID_RSA: - hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_PKCS1; - break; - case CSSM_ALGID_DSA: - hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_FIPS186; + fieldFound = false; + switch(searchType) { + case SN_CommonName: + oidSrch = &CSSMOID_CommonName; break; - case CSSM_ALGID_FEE: - hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_OCTET_STRING; + case SN_Email: + oidSrch = &CSSMOID_EmailAddress; break; default: - /* punt */ - hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_NONE; - } - hdr->KeyClass = CSSM_KEYCLASS_PUBLIC_KEY; - hdr->KeyAttr = CSSM_KEYATTR_MODIFIABLE | CSSM_KEYATTR_EXTRACTABLE; - hdr->KeyUsage = CSSM_KEYUSE_VERIFY; - - rootCerts = TPRootStore::tpGlobalRoots().rootCerts(clHand, numRootCerts); - for(dex=0; dexsubjectName, certToVfy->issuerName())) { - /* not this root */ - continue; - } - - /* only variation in key in the loop - raw key bits and size */ - rootKey.KeyData = rootInfo->publicKey; - hdr->LogicalKeySizeInBits = rootInfo->keySize; - crtn = CSSM_CSP_CreateSignatureContext(cspHand, - sigAlg, - NULL, // AcccedCred - &rootKey, - &ccHand); - if(crtn) { - errorLog0("tp_verifyWithSslRoots: CSSM_CSP_CreateSignatureContext err\n"); - CssmError::throwMe(CSSMERR_TP_INTERNAL_ERROR); - } - crtn = CSSM_CL_CertVerify(clHand, - ccHand, - certToVfy->certData(), - NULL, // no signer cert - NULL, // VerifyScope - 0); // ScopeSize - CSSM_DeleteContext(ccHand); - if(crtn == CSSM_OK) { - /* success! */ - brtn = CSSM_TRUE; - break; - } - } -errOut: - if(valToFree != NULL) { - tp_CertFreeAlgId(clHand, valToFree); + assert(0); + return CSSM_FALSE; } - return brtn; -} -#endif /* TP_ROOT_CERT_ENABLE */ - -/* - * See if cert's Subject.commonName matches caller-specified hostname. - * Returns CSSM_TRUE if match, else returns CSSM_FALSE. - */ -static CSSM_BOOL tpCompareCommonName( - TPCertInfo &cert, - const char *hostName, - uint32 hostNameLen) -{ - char *commonName = NULL; // from cert's subject name - uint32 commonNameLen = 0; - CSSM_DATA_PTR subjNameData = NULL; - CSSM_RETURN crtn; - CSSM_BOOL ourRtn = CSSM_FALSE; - crtn = cert.fetchField(&CSSMOID_X509V1SubjectNameCStruct, &subjNameData); if(crtn) { /* should never happen, we shouldn't be here if there is no subject */ - errorLog0("tp_verifySslOpts: error retrieving subject name"); + tpPolicyError("tp_verifySslOpts: error retrieving subject name"); return CSSM_FALSE; } CSSM_X509_NAME_PTR x509name = (CSSM_X509_NAME_PTR)subjNameData->Data; if((x509name == NULL) || (subjNameData->Length != sizeof(CSSM_X509_NAME))) { - errorLog0("tp_verifySslOpts: malformed CSSM_X509_NAME"); + tpPolicyError("tp_verifySslOpts: malformed CSSM_X509_NAME"); cert.freeField(&CSSMOID_X509V1SubjectNameCStruct, subjNameData); return CSSM_FALSE; } @@ -514,11 +367,20 @@ static CSSM_BOOL tpCompareCommonName( rdnp = &x509name->RelativeDistinguishedName[rdnDex]; for(pairDex=0; pairDexnumberOfPairs; pairDex++) { ptvp = &rdnp->AttributeTypeAndValue[pairDex]; - if(tpCompareOids(&ptvp->type, &CSSMOID_CommonName)) { - commonName = (char *)ptvp->value.Data; - commonNameLen = ptvp->value.Length; - ourRtn = tpCompareHostNames(hostName, hostNameLen, - commonName, commonNameLen); + if(tpCompareOids(&ptvp->type, oidSrch)) { + fieldFound = true; + certName = (char *)ptvp->value.Data; + certNameLen = ptvp->value.Length; + switch(searchType) { + case SN_CommonName: + ourRtn = tpCompareHostNames(callerStr, callerStrLen, + certName, certNameLen); + break; + case SN_Email: + ourRtn = tpCompareEmailAddr(callerStr, callerStrLen, + certName, certNameLen); + break; + } if(ourRtn) { /* success */ break; @@ -593,73 +455,104 @@ static CSSM_BOOL tpCompIpAddrStr( } /* - * See if cert's subjectAltName matches caller-specified hostname, either - * as a dnsName or an iPAddress. + * See if cert's subjectAltName contains an element matching caller-specified + * string, hostname, in the following forms: + * + * SAN_HostName : dnsName, iPAddress + * SAN_Email : RFC822Name + * + * Returns CSSM_TRUE if match, else returns CSSM_FALSE. * - * Returns CSSM_TRUE if match, else returns CSSM_FALSE. Also indicates - * whether or not a dnsName was found (in which case the subject's - * common name should NOT be a candidate for verification). + * Also indicates whether or not a dnsName (search type HostName) or + * RFC822Name (search type SAM_Email) was found, regardless of result + * of comparison. + * + * The appStr/appStrLen args are optional - if NULL/0, only the + * search for dnsName/RFC822Name is done. */ +typedef enum { + SAN_HostName, + SAN_Email +} SubjAltNameSearchType; + static CSSM_BOOL tpCompareSubjectAltName( - TPCertInfo &cert, - const char *hostName, - uint32 hostNameLen, - bool &dnsNameFound) // RETURNED + const iSignExtenInfo &subjAltNameInfo, + const char *appStr, + uint32 appStrLen, + SubjAltNameSearchType searchType, + bool &dnsNameFound, // RETURNED, SAN_HostName case + bool &emailFound) // RETURNED, SAN_Email case { - CSSM_DATA_PTR subjAltNameData = NULL; - CSSM_RETURN crtn; - CSSM_BOOL ourRtn = CSSM_FALSE; - dnsNameFound = false; - crtn = cert.fetchField(&CSSMOID_SubjectAltName, &subjAltNameData); - if(crtn) { + emailFound = false; + if(!subjAltNameInfo.present) { /* common failure, no subjectAltName found */ return CSSM_FALSE; } - CSSM_X509_EXTENSION_PTR exten = - (CSSM_X509_EXTENSION_PTR)subjAltNameData->Data; - /* Paranoid check of extension integrity */ - if((exten == NULL) || - (subjAltNameData->Length != sizeof(CSSM_X509_EXTENSION)) || - (exten->format != CSSM_X509_DATAFORMAT_PARSED) || - (exten->value.parsedValue == NULL)) { - errorLog0("tpCompareSubjectAltName: malformed CSSM_X509_EXTENSION"); - cert.freeField(&CSSMOID_SubjectAltName, subjAltNameData); - return CSSM_FALSE; - } - CE_GeneralNames *names = (CE_GeneralNames *)exten->value.parsedValue; - char *serverName; - unsigned serverNameLen; + CE_GeneralNames *names = &subjAltNameInfo.extnData->subjectAltName; + CSSM_BOOL ourRtn = CSSM_FALSE; + char *certName; + unsigned certNameLen; - /* Search thru the CE_GeneralNames looking for a DNSName or IP Address */ + /* Search thru the CE_GeneralNames looking for the appropriate attribute */ for(unsigned dex=0; dexnumNames; dex++) { CE_GeneralName *name = &names->generalName[dex]; - switch(name->nameType) { - case GNT_IPAddress: - ourRtn = tpCompIpAddrStr(hostName, hostNameLen, &name->name); - break; - - case GNT_DNSName: - if(name->berEncoded) { - errorLog0("tpCompareSubjectAltName: malformed " - "CE_GeneralName (1)\n"); + switch(searchType) { + case SAN_HostName: + switch(name->nameType) { + case GNT_IPAddress: + if(appStr == NULL) { + /* nothing to do here */ + break; + } + ourRtn = tpCompIpAddrStr(appStr, appStrLen, &name->name); + break; + + case GNT_DNSName: + if(name->berEncoded) { + tpErrorLog("tpCompareSubjectAltName: malformed " + "CE_GeneralName (1)\n"); + break; + } + certName = (char *)name->name.Data; + if(certName == NULL) { + tpErrorLog("tpCompareSubjectAltName: malformed " + "CE_GeneralName (2)\n"); + break; + } + certNameLen = name->name.Length; + dnsNameFound = true; + if(appStr != NULL) { + /* skip if caller passed in NULL */ + ourRtn = tpCompareHostNames(appStr, appStrLen, + certName, certNameLen); + } + break; + + default: + /* not interested, proceed to next name */ + break; + } + break; /* from case HostName */ + + case SAN_Email: + if(name->nameType != GNT_RFC822Name) { + /* not interested */ break; } - serverName = (char *)name->name.Data; - if(serverName == NULL) { - errorLog0("tpCompareSubjectAltName: malformed " - "CE_GeneralName (2)\n"); + certName = (char *)name->name.Data; + if(certName == NULL) { + tpErrorLog("tpCompareSubjectAltName: malformed " + "GNT_RFC822Name\n"); break; } - serverNameLen = name->name.Length; - ourRtn = tpCompareHostNames(hostName, hostNameLen, - serverName, serverNameLen); - dnsNameFound = true; - break; - - default: - /* not interested, proceed to next name */ + certNameLen = name->name.Length; + emailFound = true; + if(appStr != NULL) { + ourRtn = tpCompareEmailAddr(appStr, appStrLen, certName, + certNameLen); + } break; } if(ourRtn) { @@ -667,7 +560,6 @@ static CSSM_BOOL tpCompareSubjectAltName( break; } } - cert.freeField(&CSSMOID_SubjectAltName, subjAltNameData); return ourRtn; } @@ -699,12 +591,26 @@ static CSSM_BOOL tpIsNumeric( */ static CSSM_RETURN tp_verifySslOpts( TPCertGroup &certGroup, - const CSSM_APPLE_TP_SSL_OPTIONS *sslOpts) + const CSSM_DATA *sslFieldOpts, + const iSignCertInfo &leafCertInfo) { - if(sslOpts == NULL) { + /* first validate optional SSL options */ + if((sslFieldOpts == NULL) || (sslFieldOpts->Data == NULL)) { /* optional */ return CSSM_OK; } + CSSM_APPLE_TP_SSL_OPTIONS *sslOpts; + sslOpts = (CSSM_APPLE_TP_SSL_OPTIONS *)sslFieldOpts->Data; + switch(sslOpts->Version) { + case CSSM_APPLE_TP_SSL_OPTS_VERSION: + if(sslFieldOpts->Length != sizeof(CSSM_APPLE_TP_SSL_OPTIONS)) { + return CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + } + break; + /* handle backwards compatibility here if necessary */ + default: + return CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + } unsigned hostNameLen = sslOpts->ServerNameLen; @@ -728,8 +634,11 @@ static CSSM_RETURN tp_verifySslOpts( /* First check subjectAltName... */ bool dnsNameFound = false; - match = tpCompareSubjectAltName(*leaf, hostName, hostNameLen, - dnsNameFound); + bool dummy; + match = tpCompareSubjectAltName(leafCertInfo.subjectAltName, + hostName, hostNameLen, + SAN_HostName, dnsNameFound, dummy); + /* * Then common name, if * -- no match from subjectAltName, AND @@ -737,7 +646,9 @@ static CSSM_RETURN tp_verifySslOpts( * -- hostName is not strictly numeric form (1.2.3.4) */ if(!match && !dnsNameFound && !tpIsNumeric(hostName, hostNameLen)) { - match = tpCompareCommonName(*leaf, hostName, hostNameLen); + bool fieldFound; + match = tpCompareSubjectName(*leaf, SN_CommonName, hostName, hostNameLen, + fieldFound); } certGroup.alloc().free(hostName); if(match) { @@ -749,6 +660,239 @@ static CSSM_RETURN tp_verifySslOpts( } } +/* + * Verify SMIME options. + */ +#define CE_CIPHER_MASK (~(CE_KU_EncipherOnly | CE_KU_DecipherOnly)) + +static CSSM_RETURN tp_verifySmimeOpts( + TPCertGroup &certGroup, + const CSSM_DATA *smimeFieldOpts, + const iSignCertInfo &leafCertInfo) +{ + /* + * First validate optional S/MIME options. + */ + CSSM_APPLE_TP_SMIME_OPTIONS *smimeOpts = NULL; + if(smimeFieldOpts != NULL) { + smimeOpts = (CSSM_APPLE_TP_SMIME_OPTIONS *)smimeFieldOpts->Data; + } + if(smimeOpts != NULL) { + switch(smimeOpts->Version) { + case CSSM_APPLE_TP_SMIME_OPTS_VERSION: + if(smimeFieldOpts->Length != + sizeof(CSSM_APPLE_TP_SMIME_OPTIONS)) { + return CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + } + break; + /* handle backwards compatibility here if necessary */ + default: + return CSSMERR_TP_INVALID_POLICY_IDENTIFIERS; + } + } + + TPCertInfo *leaf = certGroup.certAtIndex(0); + assert(leaf != NULL); + + /* Verify optional email address */ + unsigned emailLen = 0; + if(smimeOpts != NULL) { + emailLen = smimeOpts->SenderEmailLen; + } + bool emailFoundInSAN = false; + if(emailLen != 0) { + if(smimeOpts->SenderEmail == NULL) { + return CSSMERR_TP_INVALID_POINTER; + } + + /* normalize caller's email string */ + char *email = (char *)certGroup.alloc().malloc(emailLen); + memmove(email, smimeOpts->SenderEmail, emailLen); + tpNormalizeAddrSpec(email, emailLen); + + CSSM_BOOL match = false; + + /* + * First check subjectAltName. The emailFound bool indicates + * that *some* email address was found, regardless of a match + * condition. + */ + bool dummy; + match = tpCompareSubjectAltName(leafCertInfo.subjectAltName, + email, emailLen, + SAN_Email, dummy, emailFoundInSAN); + + /* + * Then subject DN, CSSMOID_EmailAddress, if no match from + * subjectAltName + */ + bool emailFoundInDn = false; + if(!match) { + match = tpCompareSubjectName(*leaf, SN_Email, email, emailLen, + emailFoundInDn); + } + certGroup.alloc().free(email); + + /* + * Error here only if no match found but there was indeed *some* + * email address in the cert. + */ + if(!match && (emailFoundInSAN || emailFoundInDn)) { + leaf->addStatusCode(CSSMERR_APPLETP_SMIME_EMAIL_ADDRS_NOT_FOUND); + tpPolicyError("SMIME email addrs in cert but no match"); + return CSSMERR_TP_VERIFY_ACTION_FAILED; + } + } + + /* + * Going by the letter of the law, here's what RFC 2632 has to say + * about the legality of an empty Subject Name: + * + * ...the subject DN in a user's (i.e. end-entity) certificate MAY + * be an empty SEQUENCE in which case the subjectAltName extension + * will include the subject's identifier and MUST be marked as + * critical. + * + * OK, first examine the leaf cert's subject name. + */ + CSSM_RETURN crtn; + CSSM_DATA_PTR subjNameData = NULL; + crtn = leaf->fetchField(&CSSMOID_X509V1SubjectNameCStruct, &subjNameData); + if(crtn) { + /* This should really never happen */ + tpPolicyError("SMIME policy: error fetching subjectName"); + leaf->addStatusCode(CSSMERR_TP_INVALID_CERTIFICATE); + return CSSMERR_TP_INVALID_CERTIFICATE; + } + /* must do a leaf->freeField(&CSSMOID_X509V1SubjectNameCStruct on exit */ + + const CSSM_X509_NAME *x509Name = (const CSSM_X509_NAME *)subjNameData->Data; + if(x509Name->numberOfRDNs == 0) { + /* + * Empty subject name. If we haven't already seen a valid + * email address in the subject alternate name (by looking + * for a specific address specified by app), try to find + * one now. + */ + if(!emailFoundInSAN && // haven't found one, and + (emailLen == 0)) { // didn't even look yet + bool dummy; + tpCompareSubjectAltName(leafCertInfo.subjectAltName, + NULL, 0, // email, emailLen, + SAN_Email, dummy, + emailFoundInSAN); // the variable we're updating + } + if(!emailFoundInSAN) { + tpPolicyError("SMIME policy fail: empty subject name and " + "no Email Addrs in SubjectAltName"); + leaf->addStatusCode(CSSMERR_APPLETP_SMIME_NO_EMAIL_ADDRS); + leaf->freeField(&CSSMOID_X509V1SubjectNameCStruct, subjNameData); + return CSSMERR_TP_VERIFY_ACTION_FAILED; + } + + /* + * One more thing: this leaf must indeed have a subjAltName + * extension and it must be critical. We would not have gotten this + * far if the subjAltName extension was not actually present.... + */ + assert(leafCertInfo.subjectAltName.present); + if(!leafCertInfo.subjectAltName.critical) { + tpPolicyError("SMIME policy fail: empty subject name and " + "no Email Addrs in SubjectAltName"); + leaf->addStatusCode(CSSMERR_APPLETP_SMIME_SUBJ_ALT_NAME_NOT_CRIT); + leaf->freeField(&CSSMOID_X509V1SubjectNameCStruct, subjNameData); + return CSSMERR_TP_VERIFY_ACTION_FAILED; + } + } + leaf->freeField(&CSSMOID_X509V1SubjectNameCStruct, subjNameData); + + /* + * Enforce the usage of the key associated with the leaf cert. + * Cert's KeyUsage must be a superset of what the app is trying to do. + * Note the {en,de}cipherONly flags are handledÊseparately.... + */ + const iSignExtenInfo &kuInfo = leafCertInfo.keyUsage; + if(kuInfo.present) { + CE_KeyUsage certKu = *((CE_KeyUsage *)kuInfo.extnData); + CE_KeyUsage appKu = smimeOpts->IntendedUsage; + CE_KeyUsage intersection = certKu & appKu; + if((intersection & CE_CIPHER_MASK) != (appKu & CE_CIPHER_MASK)) { + tpPolicyError("SMIME KeyUsage err: appKu 0x%x certKu 0x%x", + appKu, certKu); + leaf->addStatusCode(CSSMERR_APPLETP_SMIME_BAD_KEY_USE); + return CSSMERR_TP_VERIFY_ACTION_FAILED; + } + + /* Now the en/de cipher only bits - for keyAgreement only */ + if(appKu & CE_KU_KeyAgreement) { + /* + * 1. App wants to use this for key agreement; it must + * say what it wants to do with the derived key. + * In this context, the app's XXXonly bit means that + * it wants to use the key for that op - not necessarliy + * "only". + */ + if((appKu & (CE_KU_EncipherOnly | CE_KU_DecipherOnly)) == 0) { + tpPolicyError("SMIME KeyUsage err: KeyAgreement with " + "no Encipher or Decipher"); + leaf->addStatusCode(CSSMERR_APPLETP_SMIME_BAD_KEY_USE); + return CSSMERR_TP_VERIFY_ACTION_FAILED; + } + + /* + * 2. If cert restricts to encipher only make sure the + * app isn't trying to decipher. + */ + if((certKu & CE_KU_EncipherOnly) && + (appKu & CE_KU_DecipherOnly)) { + tpPolicyError("SMIME KeyUsage err: cert EncipherOnly, " + "app wants to decipher"); + leaf->addStatusCode(CSSMERR_APPLETP_SMIME_BAD_KEY_USE); + return CSSMERR_TP_VERIFY_ACTION_FAILED; + } + + /* + * 3. If cert restricts to decipher only make sure the + * app isn't trying to encipher. + */ + if((certKu & CE_KU_DecipherOnly) && + (appKu & CE_KU_EncipherOnly)) { + tpPolicyError("SMIME KeyUsage err: cert DecipherOnly, " + "app wants to encipher"); + leaf->addStatusCode(CSSMERR_APPLETP_SMIME_BAD_KEY_USE); + return CSSMERR_TP_VERIFY_ACTION_FAILED; + } + } + } + + /* + * Ensure that, if an extendedKeyUsage extension is present in the + * leaf, that either emailProtection or anyExtendedKeyUsage usages is present + */ + const iSignExtenInfo &ekuInfo = leafCertInfo.extendKeyUsage; + if(ekuInfo.present) { + bool foundGoodEku = false; + CE_ExtendedKeyUsage *eku = (CE_ExtendedKeyUsage *)ekuInfo.extnData; + assert(eku != NULL); + for(unsigned i=0; inumPurposes; i++) { + if(tpCompareOids(&eku->purposes[i], &CSSMOID_EmailProtection)) { + foundGoodEku = true; + break; + } + if(tpCompareOids(&eku->purposes[i], &CSSMOID_ExtendedKeyUsageAny)) { + foundGoodEku = true; + break; + } + } + if(!foundGoodEku) { + leaf->addStatusCode(CSSMERR_APPLETP_SMIME_BAD_EXT_KEY_USE); + return CSSMERR_TP_VERIFY_ACTION_FAILED; + } + } + + return CSSM_OK; +} + /* * RFC2459 says basicConstraints must be flagged critical for * CA certs, but Verisign doesn't work that way. @@ -773,6 +917,14 @@ static CSSM_RETURN tp_verifySslOpts( */ #define KEY_USAGE_REQUIRED_FOR_ROOT 0 +/* + * RFC 2632, "S/MIME Version 3 Certificate Handling", section + * 4.4.2, says that KeyUsage extensions MUST be flagged critical, + * but Thawte's intermediate cert (common namd "Thawte Personal + * Freemail Issuing CA" does not meet this requirement. + */ +#define SMIME_KEY_USAGE_MUST_BE_CRITICAL 0 + /* * Public routine to perform TP verification on a constructed * cert group. @@ -792,9 +944,9 @@ CSSM_RETURN tp_policyVerify( CSSM_CSP_HANDLE cspHand, TPCertGroup *certGroup, CSSM_BOOL verifiedToRoot, // last cert is good root - const CSSM_APPLE_TP_ACTION_DATA *actionData, - const CSSM_APPLE_TP_SSL_OPTIONS *sslOpts, - void *policyOpts) // future options + CSSM_APPLE_TP_ACTION_FLAGS actionFlags, + const CSSM_DATA *policyFieldData, // optional + void *policyOpts) // future options { iSignCertInfo *certInfo = NULL; uint32 numCerts; @@ -803,8 +955,8 @@ CSSM_RETURN tp_policyVerify( uint16 actUsage; unsigned certDex; CSSM_BOOL cA = CSSM_FALSE; // init for compiler warning - CSSM_BOOL isLeaf; // end entity - CSSM_BOOL isRoot; // root cert + bool isLeaf; // end entity + bool isRoot; // root cert CE_ExtendedKeyUsage *extendUsage; CE_AuthorityKeyID *authorityId; CSSM_RETURN outErr = CSSM_OK; // for gross, non-policy errors @@ -825,11 +977,11 @@ CSSM_RETURN tp_policyVerify( if(policy == kTPiSign) { if(!verifiedToRoot) { /* no way, this requires a root cert */ - return CSSMERR_TP_INVALID_CERTGROUP; + return CSSMERR_TP_VERIFY_ACTION_FAILED; } if(numCerts <= 1) { /* nope, not for iSign */ - return CSSMERR_TP_INVALID_CERTGROUP; + return CSSMERR_TP_VERIFY_ACTION_FAILED; } } @@ -861,17 +1013,20 @@ CSSM_RETURN tp_policyVerify( if(thisCertInfo->foundUnknownCritical) { /* illegal for all policies */ - errorLog0("tp_policyVerify: critical flag in unknown extension\n"); + tpPolicyError("tp_policyVerify: critical flag in unknown " + "extension"); thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_UNKNOWN_CRITICAL_EXTEN); policyFail = CSSM_TRUE; } /* * Note it's possible for both of these to be true, for a - * of length one (kTPx509Basic only!) + * of length one (kTPx509Basic, kCrlPolicy only!) + * FIXME: should this code work of the last cert in the chain is + * NOT a root? */ - isLeaf = (certDex == 0) ? CSSM_TRUE : CSSM_FALSE; - isRoot = (certDex == (numCerts - 1)) ? CSSM_TRUE : CSSM_FALSE; + isLeaf = thisTpCertInfo->isLeaf(); + isRoot = thisTpCertInfo->isSelfSigned(); /* * BasicConstraints.cA @@ -879,11 +1034,15 @@ CSSM_RETURN tp_policyVerify( * for which it is optional (with default values of false * for leaf and true for root). * kTPx509Basic, - * kTP_SSL: always optional, default of false for leaf and + * kTP_SSL, + * kTP_SMIME always optional, default of false for leaf and * true for others * All: cA must be false for leaf, true for others */ if(!thisCertInfo->basicConstraints.present) { + /* + * No basicConstraints present; infer a cA value if appropriate. + */ if(isLeaf) { /* cool, use default; note that kTPx509Basic with * certGroup length of one may take this case */ @@ -897,21 +1056,25 @@ CSSM_RETURN tp_policyVerify( switch(policy) { case kTPx509Basic: case kTP_SSL: + case kCrlPolicy: + case kTP_SMIME: /* - * not present, not leaf, not root, kTPx509Basic + * not present, not leaf, not root.... * ....RFC2459 says this can not be a CA */ cA = CSSM_FALSE; break; case kTPiSign: /* required for iSign in this position */ - errorLog0("tp_policyVerify: no basicConstraints\n"); + tpPolicyError("tp_policyVerify: no " + "basicConstraints"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode( CSSMERR_APPLETP_NO_BASIC_CONSTRAINTS); break; default: /* not reached */ + assert(0); break; } } @@ -922,7 +1085,8 @@ CSSM_RETURN tp_policyVerify( /* disabled for verisign compatibility */ if(!thisCertInfo->basicConstraints.critical) { /* per RFC 2459 */ - errorLog0("tp_policyVerify: basicConstraints marked not critical\n"); + tpPolicyError("tp_policyVerify: basicConstraints marked " + "not critical"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_TP_VERIFY_ACTION_FAILED); } @@ -943,7 +1107,8 @@ CSSM_RETURN tp_policyVerify( * etc. */ if(certDex > (bcp->pathLenConstraint + 1)) { - errorLog0("tp_policyVerify: pathLenConstraint exceeded\n"); + tpPolicyError("tp_policyVerify: pathLenConstraint " + "exceeded"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode( CSSMERR_APPLETP_PATH_LEN_CONSTRAINT); @@ -952,15 +1117,20 @@ CSSM_RETURN tp_policyVerify( } if(isLeaf) { - /* special case to allow a chain of length 1, leaf and root - * both true (kTPx509Basic, kTP_SSL only) */ - if(cA && !isRoot) { - errorLog0("tp_policyVerify: cA true for leaf\n"); + /* + * Special cases to allow a chain of length 1, leaf and root + * both true, and for caller to override the "leaf can't be a CA" + * requirement when a CA cert is explicitly being evaluated as the + * leaf. + */ + if(cA && !isRoot && + !(actionFlags & CSSM_TP_ACTION_LEAF_IS_CA)) { + tpPolicyError("tp_policyVerify: cA true for leaf"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_INVALID_CA); } } else if(!cA) { - errorLog0("tp_policyVerify: cA false for non-leaf\n"); + tpPolicyError("tp_policyVerify: cA false for non-leaf"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_INVALID_CA); } @@ -969,18 +1139,20 @@ CSSM_RETURN tp_policyVerify( * Authority Key Identifier optional * iSign : only allowed in !root. * If present, must not be critical. - * kTPx509Basic : - * kTP_SSL : ignored (though used later for chain verification) + * kTPx509Basic, + * kTP_SSL, + * kTP_SMIME : ignored (though used later for chain verification) */ if((policy == kTPiSign) && thisCertInfo->authorityId.present) { if(isRoot) { - errorLog0("tp_policyVerify: authorityId in root\n"); + tpPolicyError("tp_policyVerify: authorityId in root"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_INVALID_AUTHORITY_ID); } if(thisCertInfo->authorityId.critical) { /* illegal per RFC 2459 */ - errorLog0("tp_policyVerify: authorityId marked critical\n"); + tpPolicyError("tp_policyVerify: authorityId marked " + "critical"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_INVALID_AUTHORITY_ID); } @@ -990,11 +1162,12 @@ CSSM_RETURN tp_policyVerify( * Subject Key Identifier optional * iSign : can't be critical. * kTPx509Basic, - * kTP_SSL : ignored (though used later for chain verification) + * kTP_SSL, + * kTP_SMIME : ignored (though used later for chain verification) */ if(thisCertInfo->subjectId.present) { if((policy == kTPiSign) && thisCertInfo->subjectId.critical) { - errorLog0("tp_policyVerify: subjectId marked critical\n"); + tpPolicyError("tp_policyVerify: subjectId marked critical"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_INVALID_SUBJECT_ID); } @@ -1007,8 +1180,12 @@ CSSM_RETURN tp_policyVerify( * Exception : if leaf, and keyUsage not present, * netscape-cert-type must be present, with * Object Signing bit set - * kTPx509Basic : non-leaf : usage = keyCertSign + * kTPx509Basic, + * kTP_SSL, + * kTP_SMIME, : non-leaf : usage = keyCertSign * Leaf: don't care + * kCrlPolicy : Leaf: usage = CRLSign + * kTP_SMIME : if present, must be critical */ if(thisCertInfo->keyUsage.present) { /* @@ -1017,12 +1194,18 @@ CSSM_RETURN tp_policyVerify( * We only require that one bit to be set, we ignore others. */ if(isLeaf) { - if(policy == kTPiSign) { - expUsage = CE_KU_DigitalSignature; - } - else { - /* hack to accept whatever's there */ - expUsage = thisCertInfo->keyUsage.extnData->keyUsage; + switch(policy) { + case kTPiSign: + expUsage = CE_KU_DigitalSignature; + break; + case kCrlPolicy: + /* if present, this bit must be set */ + expUsage = CE_KU_CRLSign; + break; + default: + /* hack to accept whatever's there */ + expUsage = thisCertInfo->keyUsage.extnData->keyUsage; + break; } } else { @@ -1031,11 +1214,24 @@ CSSM_RETURN tp_policyVerify( } actUsage = thisCertInfo->keyUsage.extnData->keyUsage; if(!(actUsage & expUsage)) { - errorLog2("tp_policyVerify: bad keyUsage (leaf %s; usage 0x%x)\n", + tpPolicyError("tp_policyVerify: bad keyUsage (leaf %s; " + "usage 0x%x)", (certDex == 0) ? "TRUE" : "FALSE", actUsage); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_INVALID_KEY_USAGE); } + + if((policy == kTP_SMIME) && !thisCertInfo->keyUsage.critical) { + /* + * Per Radar 3410245, allow this for intermediate certs. + */ + if(SMIME_KEY_USAGE_MUST_BE_CRITICAL || isLeaf || isRoot) { + tpPolicyError("tp_policyVerify: key usage, !critical, SMIME"); + policyFail = CSSM_TRUE; + thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_SMIME_KEYUSAGE_NOT_CRITICAL); + } + } + } else if(policy == kTPiSign) { /* @@ -1047,13 +1243,15 @@ CSSM_RETURN tp_policyVerify( thisCertInfo->netscapeCertType.extnData->netscapeCertType; if(!(ct & CE_NCT_ObjSign)) { - errorLog0("tp_policyVerify: netscape-cert-type, !ObjectSign\n"); + tpPolicyError("tp_policyVerify: netscape-cert-type, " + "!ObjectSign"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_INVALID_KEY_USAGE); } } else if(!isRoot) { - errorLog0("tp_policyVerify: !isRoot, no keyUsage, !(leaf and netscapeCertType)\n"); + tpPolicyError("tp_policyVerify: !isRoot, no keyUsage, " + "!(leaf and netscapeCertType)"); policyFail = CSSM_TRUE; thisTpCertInfo->addStatusCode(CSSMERR_APPLETP_INVALID_KEY_USAGE); } @@ -1069,7 +1267,8 @@ CSSM_RETURN tp_policyVerify( if((policy == kTPiSign) && certInfo[0].extendKeyUsage.present) { extendUsage = &certInfo[0].extendKeyUsage.extnData->extendedKeyUsage; if(extendUsage->numPurposes != 1) { - errorLog1("tp_policyVerify: bad extendUsage->numPurposes (%d)\n", + tpPolicyError("tp_policyVerify: bad extendUsage->numPurposes " + "(%d)", (int)extendUsage->numPurposes); policyFail = CSSM_TRUE; (certGroup->certAtIndex(0))->addStatusCode( @@ -1077,7 +1276,7 @@ CSSM_RETURN tp_policyVerify( } if(!tpCompareOids(extendUsage->purposes, &CSSMOID_ExtendedUseCodeSigning)) { - errorLog0("tp_policyVerify: bad extendKeyUsage\n"); + tpPolicyError("tp_policyVerify: bad extendKeyUsage"); policyFail = CSSM_TRUE; (certGroup->certAtIndex(0))->addStatusCode( CSSMERR_APPLETP_INVALID_EXTENDED_KEY_USAGE); @@ -1101,7 +1300,7 @@ CSSM_RETURN tp_policyVerify( } if(!tpCompareCssmData(&authorityId->keyIdentifier, &certInfo[certDex+1].subjectId.extnData->subjectKeyID)) { - errorLog0("tp_policyVerify: bad key ID linkage\n"); + tpPolicyError("tp_policyVerify: bad key ID linkage"); policyFail = CSSM_TRUE; (certGroup->certAtIndex(certDex))->addStatusCode( CSSMERR_APPLETP_INVALID_ID_LINKAGE); @@ -1114,34 +1313,22 @@ CSSM_RETURN tp_policyVerify( * we return both errors? */ if(policy == kTP_SSL) { - CSSM_RETURN cerr = tp_verifySslOpts(*certGroup, sslOpts); + CSSM_RETURN cerr = tp_verifySslOpts(*certGroup, policyFieldData, + certInfo[0]); if(cerr) { policyFail = CSSM_TRUE; } } - /* iSign, SSL: compare root against known root certs */ - /* FIXME - this goes away soon */ - #if TP_ROOT_CERT_ENABLE - if((outErr == CSSM_OK) && // skip if we have a gross error (other than policy failure) - (actionData != NULL) && - (actionData->ActionFlags & 0x80000000)) { // The secret "enable root cert check" flag - TPCertInfo *lastCert = certGroup->lastCert(); - if(policy == kTPiSign) { - bool brtn = tp_isIsignRootCert(clHand, lastCert); - if(!brtn) { - policyFail = CSSM_TRUE; - } - } - else if(verifiedToRoot && (policy == kTP_SSL)) { - /* note SSL doesn't require root here */ - bool brtn = tp_isSslRootCert(clHand, lastCert); - if(!brtn) { - outErr = CSSMERR_TP_INVALID_ANCHOR_CERT; - } + /* S/MIME */ + if(policy == kTP_SMIME) { + CSSM_RETURN cerr = tp_verifySmimeOpts(*certGroup, policyFieldData, + certInfo[0]); + if(cerr) { + policyFail = CSSM_TRUE; } } - #endif /* TP_ROOT_CERT_ENABLE */ + if(policyFail && (outErr == CSSM_OK)) { /* only error in this function was policy failure */ outErr = CSSMERR_TP_VERIFY_ACTION_FAILED; diff --git a/AppleX509TP/tpPolicies.h b/AppleX509TP/tpPolicies.h index 26f3ac20..4af91492 100644 --- a/AppleX509TP/tpPolicies.h +++ b/AppleX509TP/tpPolicies.h @@ -34,19 +34,22 @@ extern "C" { #endif /* __cplusplus */ -CSSM_BOOL tp_verifyWithSslRoots( - CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - TPCertInfo *certToVfy); // last in chain, not root +/* + * Private CSSM_APPLE_TP_ACTION_FLAGS value to enable implicit + * root certs. + */ +#define CSSM_TP_USE_INTERNAL_ROOT_CERTS 0x80000000 /* - * Enumerated policies enforced by this module. + * Enumerated certificate policies enforced by this module. */ typedef enum { kTPDefault, /* no extension parsing, just sig and expiration */ kTPx509Basic, /* basic X.509/RFC2459 */ kTPiSign, /* Apple code signing */ - kTP_SSL /* SecureTransport/SSL */ + kTP_SSL, /* SecureTransport/SSL */ + kCrlPolicy, /* cert chain verification via CRL */ + kTP_SMIME /* S/MIME */ } TPPolicy; /* @@ -60,9 +63,9 @@ CSSM_RETURN tp_policyVerify( CSSM_CSP_HANDLE cspHand, TPCertGroup *certGroup, CSSM_BOOL verifiedToRoot, // last cert is good root - const CSSM_APPLE_TP_ACTION_DATA *actionData, - const CSSM_APPLE_TP_SSL_OPTIONS *sslOpts, - void *policyOpts); // future options + CSSM_APPLE_TP_ACTION_FLAGS actionFlags, + const CSSM_DATA *policyFieldData, // optional + void *policyControl); // future use #ifdef __cplusplus } diff --git a/AppleX509TP/tpTime.c b/AppleX509TP/tpTime.c index b6075a7b..55e6835c 100644 --- a/AppleX509TP/tpTime.c +++ b/AppleX509TP/tpTime.c @@ -106,14 +106,17 @@ int timeStringToTm( * 2-digit year. * 0 <= year < 50 : assume century 21 * 50 <= year < 70 : illegal per PKIX + * ...though we allow this as of 10/10/02...dmitch * 70 < year <= 99 : assume century 20 */ if(x < 50) { x += 2000; } + /* else if(x < 70) { return 1; } + */ else { /* century 20 */ x += 1900; @@ -246,8 +249,8 @@ int compareTimes( /* * Create a time string, in either UTC (2-digit) or or Generalized (4-digit) * year format. Caller mallocs the output string whose length is at least - * (UTC_TIME_STRLEN+1) or (GENERALIZED_TIME_STRLEN+1) respectively. - * Caller must hold tpTimeLock. + * (UTC_TIME_STRLEN+1), (GENERALIZED_TIME_STRLEN+1), or (CSSM_TIME_STRLEN+1) + * respectively. Caller must hold tpTimeLock. */ void timeAtNowPlus(unsigned secFromNow, TpTimeSpec timeSpec, @@ -260,21 +263,90 @@ void timeAtNowPlus(unsigned secFromNow, baseTime += (time_t)secFromNow; utc = *gmtime(&baseTime); - if(timeSpec == TIME_UTC) { - /* UTC - 2 year digits - code which parses this assumes that - * (2-digit) years between 0 and 49 are in century 21 */ - if(utc.tm_year >= 100) { - utc.tm_year -= 100; - } - sprintf(outStr, "%02d%02d%02d%02d%02d%02dZ", - utc.tm_year /* + 1900 */, utc.tm_mon + 1, - utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec); + switch(timeSpec) { + case TIME_UTC: + /* UTC - 2 year digits - code which parses this assumes that + * (2-digit) years between 0 and 49 are in century 21 */ + if(utc.tm_year >= 100) { + utc.tm_year -= 100; + } + sprintf(outStr, "%02d%02d%02d%02d%02d%02dZ", + utc.tm_year /* + 1900 */, utc.tm_mon + 1, + utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec); + break; + case TIME_GEN: + sprintf(outStr, "%04d%02d%02d%02d%02d%02dZ", + /* note year is relative to 1900, hopefully it'll have + * four valid digits! */ + utc.tm_year + 1900, utc.tm_mon + 1, + utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec); + break; + case TIME_CSSM: + sprintf(outStr, "%04d%02d%02d%02d%02d%02d", + /* note year is relative to 1900, hopefully it'll have + * four valid digits! */ + utc.tm_year + 1900, utc.tm_mon + 1, + utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec); + break; } - else { - sprintf(outStr, "%04d%02d%02d%02d%02d%02dZ", - /* note year is relative to 1900, hopefully it'll have - * four valid digits! */ - utc.tm_year + 1900, utc.tm_mon + 1, - utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec); +} + +/* + * Convert a time string, which can be in any of three forms (UTC, + * generalized, or CSSM_TIMESTRING) into a CSSM_TIMESTRING. Caller + * mallocs the result, which must be at least (CSSM_TIME_STRLEN+1) bytes. + * Returns nonzero if incoming time string is badly formed. + */ +int tpTimeToCssmTimestring( + const char *inStr, // not necessarily NULL terminated + unsigned inStrLen, // not including possible NULL + char *outTime) +{ + if((inStrLen == 0) || (inStr == NULL)) { + return 1; + } + outTime[0] = '\0'; + switch(inStrLen) { + case UTC_TIME_STRLEN: + { + /* infer century and prepend to output */ + char tmp[3]; + int year; + tmp[0] = inStr[0]; + tmp[1] = inStr[1]; + tmp[2] = '\0'; + year = atoi(tmp); + + /* + * 0 <= year < 50 : assume century 21 + * 50 <= year < 70 : illegal per PKIX + * 70 < year <= 99 : assume century 20 + */ + if(year < 50) { + /* century 21 */ + strcpy(outTime, "20"); + } + else if(year < 70) { + return 1; + } + else { + /* century 20 */ + strcpy(outTime, "19"); + } + memmove(outTime + 2, inStr, inStrLen - 1); // don't copy the Z + break; + } + case CSSM_TIME_STRLEN: + memmove(outTime, inStr, inStrLen); // trivial case + break; + case GENERALIZED_TIME_STRLEN: + memmove(outTime, inStr, inStrLen - 1); // don't copy the Z + break; + + default: + return 1; } + outTime[CSSM_TIME_STRLEN] = '\0'; + return 0; } + diff --git a/AppleX509TP/tpTime.h b/AppleX509TP/tpTime.h index c4cc1722..f8914189 100644 --- a/AppleX509TP/tpTime.h +++ b/AppleX509TP/tpTime.h @@ -66,18 +66,30 @@ extern int compareTimes( /* * Create a time string, in either UTC (2-digit) or or Generalized (4-digit) * year format. Caller mallocs the output string whose length is at least - * (UTC_TIME_STRLEN+1) or (GENERALIZED_TIME_STRLEN+1) respectively. - * Caller must hold tpTimeLock. + * (UTC_TIME_STRLEN+1), (GENERALIZED_TIME_STRLEN+1), or (CSSM_TIME_STRLEN+1) + * respectively. Caller must hold tpTimeLock. */ typedef enum { TIME_UTC, - TIME_GEN + TIME_GEN, + TIME_CSSM } TpTimeSpec; void timeAtNowPlus(unsigned secFromNow, TpTimeSpec timeSpec, char *outStr); +/* + * Convert a time string, which can be in any of three forms (UTC, + * generalized, or CSSM_TIMESTRING) into a CSSM_TIMESTRING. Caller + * mallocs the result, which must be at least (CSSM_TIME_STRLEN+1) bytes. + * Returns nonzero if incoming time string is badly formed. + */ +int tpTimeToCssmTimestring( + const char *inStr, // not necessarily NULL terminated + unsigned inStrLen, // not including possible NULL + char *outTime); // caller mallocs + #ifdef __cplusplus } #endif diff --git a/AppleX509TP/tpdebugging.c b/AppleX509TP/tpdebugging.c deleted file mode 100644 index 0c6a504b..00000000 --- a/AppleX509TP/tpdebugging.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - File: tpdebugging.c - - Contains: Debugging support. - - Written by: Doug Mitchell - - Copyright: (c) 1998 by Apple Computer, Inc., all rights reserved. - - Change History (most recent first): - - 03/10/98 dpm Created. - -*/ - -#include "tpdebugging.h" - -#if !LOG_VIA_PRINTF - -#include -#include -#include - -/* common log macros */ - -/* this one needs a writable string */ -static void logCom(unsigned char *str) { - c2pstr((char *)str); - DebugStr(str); -} - -/* remaining ones can take constant strings */ -void dblog0(char *str) { - Str255 outStr; - strcpy((char *)outStr, str); - logCom(outStr); -} - -void dblog1(char *str, void *arg1) { - Str255 outStr; - sprintf((char *)outStr, str, arg1); - logCom(outStr); -} - -void dblog2(char *str, void * arg1, void * arg2) { - Str255 outStr; - sprintf((char *)outStr, str, arg1, arg2); - logCom(outStr); -} - -void dblog3(char *str, void * arg1, void * arg2, void * arg3) { - Str255 outStr; - sprintf((char *)outStr, str, arg1, arg2, arg3); - logCom(outStr); -} - -void dblog4(char *str, void * arg1, void * arg2, void * arg3, void * arg4) { - Str255 outStr; - sprintf((char *)outStr, str, arg1, arg2, arg3, arg4); - logCom(outStr); -} - -#endif /* !LOG_VIA_PRINTF */ - -//int foobarSymbol; diff --git a/AppleX509TP/tpdebugging.h b/AppleX509TP/tpdebugging.h index c98e7543..1924b475 100644 --- a/AppleX509TP/tpdebugging.h +++ b/AppleX509TP/tpdebugging.h @@ -35,127 +35,19 @@ #ifndef _TPDEBUGGING_H_ #define _TPDEBUGGING_H_ +#include + #ifdef NDEBUG -#define DEBUG_ENABLE 0 -#define ERROR_LOG_ENABLE 0 +/* this actually compiles to nothing */ +#define tpErrorLog(args...) secdebug("tpError", ## args) #else -#define DEBUG_ENABLE 1 -#define ERROR_LOG_ENABLE 1 -#endif - -/* any other way? */ -#define LOG_VIA_PRINTF 1 - -#if DEBUG_ENABLE || ERROR_LOG_ENABLE - -#include -#include - -#if !LOG_VIA_PRINTF - -#error Hey, figure out a debug mechanism - -#include -#include -#include - -/* common log macros */ - -/* remaining ones can take constant strings */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern void dblog0(char *str); -extern void dblog1(char *str, void * arg1); -extern void dblog2(char *str, void * arg1, void * arg2); -extern void dblog3(char *str, void * arg1, void * arg2, void * arg3); -extern void dblog4(char *str, void * arg1, void * arg2, void * arg3, void * arg4); - -#ifdef __cplusplus -} -#endif - - -#else /* LOG_VIA_PRINTF */ - -#define dblog0(str) printf(str) -#define dblog1(str, arg1) printf(str, arg1) -#define dblog2(str, arg1, arg2) printf(str, arg1, arg2) -#define dblog3(str, arg1, arg2, arg3) printf(str, arg1, arg2, arg3) -#define dblog4(str, arg1, arg2, arg3, arg4) printf(str, arg1, arg2, arg3, arg4) - -#endif /* LOG_VIA_PRINTF */ - -#else /* log macros disabled */ - -#define dblog0(str) -#define dblog1(str, arg1) -#define dblog2(str, arg1, arg2) -#define dblog3(str, arg1, arg2, arg3) -#define dblog4(str, arg1, arg2, arg3, arg4) - -#endif /* DEBUG_ENABLE || ERROR_LOG_ENABLE */ - -#if DEBUG_ENABLE - -#define dprintf0(str) dblog0(str) -#define dprintf1(str, arg1) dblog1(str, arg1) -#define dprintf2(str, arg1, arg2) dblog2(str, arg1, arg2) -#define dprintf3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3) -#define dprintf4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4) - -#ifdef __cplusplus -extern "C" { +#define tpErrorLog(args...) printf(args) #endif -static inline volatile void _panic(const char *str) -{ - printf(str); - exit(1); -} - -#ifdef __cplusplus -} -#endif - -#define CASSERT(expression) \ - ((expression) ? (void)0 : \ - (dprintf1 ("Assertion failed: " #expression \ - ", file " __FILE__ ", line %d.\n", __LINE__), \ - _panic("Assertion Failure"))) - -#else /* DEBUG_ENABLE */ - -#define dprintf0(str) -#define dprintf1(str, arg1) -#define dprintf2(str, arg1, arg2) -#define dprintf3(str, arg1, arg2, arg3) -#define dprintf4(str, arg1, arg2, arg3, arg4) - -#define CASSERT(expression) - -#endif /* DEBUG_ENABLE */ - -/* - * Error logging. This may well be platform dependent. - */ -#if ERROR_LOG_ENABLE -#define errorLog0(str) dblog0(str) -#define errorLog1(str, arg1) dblog1(str, arg1) -#define errorLog2(str, arg1, arg2) dblog2(str, arg1, arg2) -#define errorLog3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3) -#define errorLog4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4) - -#else /* ERROR_LOG_ENABLE */ - -#define errorLog0(str) -#define errorLog1(str, arg1) -#define errorLog2(str, arg1, arg2) -#define errorLog3(str, arg1, arg2, arg3) -#define errorLog4(str, arg1, arg2, arg3, arg4) - -#endif /* ERROR_LOG_ENABLE */ +#define tpDebug(args...) secdebug("tpDebug", ## args) +#define tpCrlDebug(args...) secdebug("tpCrlDebug", ## args) +#define tpPolicyError(args...) secdebug("tpPolicy", ## args) +#define tpVfyDebug(args...) secdebug("tpVfyDebug", ## args) +#define tpAnchorDebug(args...) secdebug("tpAnchorDebug", ## args) #endif /* _TPDEBUGGING_H_ */ diff --git a/CertTool/cdsaUtils/cdsaUtils.c b/CdsaUtils/cuCdsaUtils.cpp similarity index 66% rename from CertTool/cdsaUtils/cdsaUtils.c rename to CdsaUtils/cuCdsaUtils.cpp index 952f8fe0..ee64d747 100644 --- a/CertTool/cdsaUtils/cdsaUtils.c +++ b/CdsaUtils/cuCdsaUtils.cpp @@ -1,60 +1,35 @@ /* - File: cdsaUtils.c + * Copyright (c) 2001-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: cuCdsaUtils.cpp Description: common CDSA access utilities - Author: dmitch - - Copyright: © Copyright 2001 Apple Computer, Inc. All rights reserved. - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple - Computer, Inc. ("Apple") in consideration of your agreement to - the following terms, and your use, installation, modification - or redistribution of this Apple software constitutes acceptance - of these terms. If you do not agree with these terms, please - do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following - terms, and subject to these terms, Apple grants you a personal, - non-exclusive license, under Apple's copyrights in this - original Apple software (the "Apple Software"), to use, - reproduce, modify and redistribute the Apple Software, with - or without modifications, in source and/or binary forms; - provided that if you redistribute the Apple Software in - its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all - such redistributions of the Apple Software. Neither the - name, trademarks, service marks or logos of Apple Computer, - Inc. may be used to endorse or promote products derived from the - Apple Software without specific prior written permission from - Apple. Except as expressly stated in this notice, no other - rights or licenses, express or implied, are granted by Apple - herein, including but not limited to any patent rights that - may be infringed by your derivative works or by other works - in which the Apple Software may be incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. - APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, - REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE - OR IN COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, - INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION - AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED - AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING - NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Author: dmitch */ -#include "cdsaUtils.h" +#include "cuCdsaUtils.h" #include #include #include +#include /* for cssmPerror() */ +#include /* for cssmPerror() */ #include static CSSM_VERSION vers = {2, 0}; @@ -553,100 +528,9 @@ CSSM_RETURN cuCspGenKeyPair(CSSM_CSP_HANDLE cspHand, return ocrtn; } -/* - * Add a certificate to an open DLDB. - */ -CSSM_RETURN cuAddCertToDb( - CSSM_DL_DB_HANDLE dlDbHand, - const CSSM_DATA *cert, - CSSM_CERT_TYPE certType, - CSSM_CERT_ENCODING certEncoding, - const char *printName, // C string - const CSSM_DATA *publicKeyHash) -{ - CSSM_DB_ATTRIBUTE_DATA attrs[6]; - CSSM_DB_RECORD_ATTRIBUTE_DATA recordAttrs; - CSSM_DB_ATTRIBUTE_DATA_PTR attr = &attrs[0]; - CSSM_DATA certTypeData; - CSSM_DATA certEncData; - CSSM_DATA printNameData; - CSSM_RETURN crtn; - CSSM_DB_UNIQUE_RECORD_PTR recordPtr; - - /* issuer and serial number required, fake 'em */ - CSSM_DATA issuer = {6, (uint8 *)"issuer"}; - CSSM_DATA serial = {6, (uint8 *)"serial"}; - - /* we spec six attributes, skipping alias */ - certTypeData.Data = (uint8 *)&certType; - certTypeData.Length = sizeof(CSSM_CERT_TYPE); - certEncData.Data = (uint8 *)&certEncoding; - certEncData.Length = sizeof(CSSM_CERT_ENCODING); - printNameData.Data = (uint8 *)printName; - printNameData.Length = strlen(printName) + 1; - - attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - attr->Info.Label.AttributeName = "CertType"; - attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; - attr->NumberOfValues = 1; - attr->Value = &certTypeData; - - attr++; - attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - attr->Info.Label.AttributeName = "CertEncoding"; - attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; - attr->NumberOfValues = 1; - attr->Value = &certEncData; - - attr++; - attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - attr->Info.Label.AttributeName = "PrintName"; - attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; - attr->NumberOfValues = 1; - attr->Value = &printNameData; - - attr++; - attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - attr->Info.Label.AttributeName = "PublicKeyHash"; - attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; - attr->NumberOfValues = 1; - attr->Value = (CSSM_DATA_PTR)publicKeyHash; - - attr++; - attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - attr->Info.Label.AttributeName = "Issuer"; - attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; - attr->NumberOfValues = 1; - attr->Value = &issuer; - - attr++; - attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - attr->Info.Label.AttributeName = "SerialNumber"; - attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; - attr->NumberOfValues = 1; - attr->Value = &serial; - - recordAttrs.DataRecordType = CSSM_DL_DB_RECORD_X509_CERTIFICATE; - recordAttrs.SemanticInformation = 0; - recordAttrs.NumberOfAttributes = 6; - recordAttrs.AttributeData = attrs; - - crtn = CSSM_DL_DataInsert(dlDbHand, - CSSM_DL_DB_RECORD_X509_CERTIFICATE, - &recordAttrs, - cert, - &recordPtr); - if(crtn) { - cuPrintError("CSSM_DL_DataInsert", crtn); - } - else { - CSSM_DL_FreeUniqueRecord(dlDbHand, recordPtr); - } - return crtn; -} /* - * Add a certificate to an open DLDB. + * Add a certificate to an open Keychain. */ CSSM_RETURN cuAddCertToKC( SecKeychainRef keychain, @@ -669,19 +553,131 @@ CSSM_RETURN cuAddCertToKC( } /* - * This prototype does not exist in public Security headers in 10.1, but the - * function is in fact exported from the Security framework. A future release - * will include a public prototype for this function. + * Convert a CSSM_DATA_PTR, referring to a DER-encoded int, to an + * unsigned. */ -#if 1 -extern void cssmPerror(const char *how, CSSM_RETURN error); -#else -#include -#endif +unsigned cuDER_ToInt(const CSSM_DATA *DER_Data) +{ + uint32 rtn = 0; + unsigned i = 0; + + while(i < DER_Data->Length) { + rtn |= DER_Data->Data[i]; + if(++i == DER_Data->Length) { + break; + } + rtn <<= 8; + } + return rtn; +} + /* * Log CSSM error. */ -void cuPrintError(char *op, CSSM_RETURN err) +void cuPrintError(const char *op, CSSM_RETURN err) { cssmPerror(op, err); } + +/* + * Verify a CRL against system anchors and intermediate certs. + */ +CSSM_RETURN cuCrlVerify( + CSSM_TP_HANDLE tpHand, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const CSSM_DATA *crlData, + CSSM_DL_DB_HANDLE_PTR certKeychain, // intermediate certs + const CSSM_DATA *anchors, + uint32 anchorCount) +{ + /* main job is building a CSSM_TP_VERIFY_CONTEXT and its components */ + CSSM_TP_VERIFY_CONTEXT vfyCtx; + CSSM_TP_CALLERAUTH_CONTEXT authCtx; + + memset(&vfyCtx, 0, sizeof(CSSM_TP_VERIFY_CONTEXT)); + memset(&authCtx, 0, sizeof(CSSM_TP_CALLERAUTH_CONTEXT)); + + /* CSSM_TP_CALLERAUTH_CONTEXT components */ + /* + typedef struct cssm_tp_callerauth_context { + CSSM_TP_POLICYINFO Policy; + CSSM_TIMESTRING VerifyTime; + CSSM_TP_STOP_ON VerificationAbortOn; + CSSM_TP_VERIFICATION_RESULTS_CALLBACK CallbackWithVerifiedCert; + uint32 NumberOfAnchorCerts; + CSSM_DATA_PTR AnchorCerts; + CSSM_DL_DB_LIST_PTR DBList; + CSSM_ACCESS_CREDENTIALS_PTR CallerCredentials; + } CSSM_TP_CALLERAUTH_CONTEXT, *CSSM_TP_CALLERAUTH_CONTEXT_PTR; + */ + CSSM_FIELD policyId; + CSSM_APPLE_TP_CRL_OPTIONS crlOpts; + policyId.FieldOid = CSSMOID_APPLE_TP_REVOCATION_CRL; + policyId.FieldValue.Data = (uint8 *)&crlOpts; + policyId.FieldValue.Length = sizeof(crlOpts); + crlOpts.Version = CSSM_APPLE_TP_CRL_OPTS_VERSION; + /* perhaps this should be user-specifiable */ + crlOpts.CrlFlags = CSSM_TP_ACTION_FETCH_CRL_FROM_NET; + crlOpts.crlStore = NULL; + + authCtx.Policy.NumberOfPolicyIds = 1; + authCtx.Policy.PolicyIds = &policyId; + authCtx.Policy.PolicyControl = NULL; + + authCtx.VerifyTime = NULL; + authCtx.VerificationAbortOn = CSSM_TP_STOP_ON_POLICY; + authCtx.CallbackWithVerifiedCert = NULL; + + /* anchors */ + authCtx.NumberOfAnchorCerts = anchorCount; + authCtx.AnchorCerts = const_cast(anchors); + + /* DBList of intermediate certs */ + CSSM_DL_DB_HANDLE handles[1]; + unsigned numDbs = 0; + if(certKeychain != NULL) { + handles[0] = *certKeychain; + numDbs++; + } + CSSM_DL_DB_LIST dlDbList; + dlDbList.DLDBHandle = certKeychain; + dlDbList.NumHandles = (certKeychain ? 1 : 0); + + authCtx.DBList = &dlDbList; + authCtx.CallerCredentials = NULL; + + /* CSSM_TP_VERIFY_CONTEXT */ + vfyCtx.ActionData.Data = NULL; + vfyCtx.ActionData.Length = 0; + vfyCtx.Action = CSSM_TP_ACTION_DEFAULT; + vfyCtx.Cred = &authCtx; + + /* cook up CSSM_ENCODED_CRL */ + CSSM_ENCODED_CRL encCrl; + encCrl.CrlType = CSSM_CRL_TYPE_X_509v2; + encCrl.CrlEncoding = CSSM_CRL_ENCODING_DER; + encCrl.CrlBlob = *crlData; + + /* CDSA API requires a SignerCertGroup; for us, all the certs are in + * certKeyChain... */ + CSSM_CERTGROUP certGroup; + certGroup.CertType = CSSM_CERT_X_509v1; + certGroup.CertEncoding = CSSM_CERT_ENCODING_DER; + certGroup.NumCerts = 0; + certGroup.GroupList.CertList = NULL; + certGroup.CertGroupType = CSSM_CERTGROUP_DATA; + + CSSM_RETURN crtn = CSSM_TP_CrlVerify(tpHand, + clHand, + cspHand, + &encCrl, + &certGroup, + &vfyCtx, + NULL); // RevokerVerifyResult + if(crtn) { + cuPrintError("CSSM_TP_CrlVerify", crtn); + } + return crtn; +} + diff --git a/CdsaUtils/cuCdsaUtils.h b/CdsaUtils/cuCdsaUtils.h new file mode 100644 index 00000000..682885ee --- /dev/null +++ b/CdsaUtils/cuCdsaUtils.h @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2001-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: cuCdsaUtils.h + + Description: common CDSA access utilities + + Author: dmitch +*/ + +#ifndef _COMMON_CDSA_UTILS_H_ +#define _COMMON_CDSA_UTILS_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* common memory allocators shared by app and CSSM */ +extern void * cuAppMalloc (uint32 size, void *allocRef); +extern void cuAppFree (void *mem_ptr, void *allocRef); +extern void * cuAppRealloc (void *ptr, uint32 size, void *allocRef); +extern void * cuAppCalloc (uint32 num, uint32 size, void *allocRef); + +#define APP_MALLOC(s) cuAppMalloc(s, NULL) +#define APP_FREE(p) cuAppFree(p, NULL) +#define APP_REALLOC(p, s) cuAppRealloc(p, s, NULL) +#define APP_CALLOC(n, s) cuAppRealloc(n, s, NULL) + +extern CSSM_BOOL cuCompareCssmData( + const CSSM_DATA *d1, + const CSSM_DATA *d2); + +/* OID flavor of same, which will break when an OID is not a CSSM_DATA */ +#define cuCompareOid(o1, o2) cuCompareCssmData(o1, o2) + +void cuPrintError(const char *op, CSSM_RETURN err); + +/* Init CSSM; returns CSSM_FALSE on error. Reusable. */ +extern CSSM_BOOL cuCssmStartup(); + +/* Attach to CSP. Returns zero on error. */ +extern CSSM_CSP_HANDLE cuCspStartup( + CSSM_BOOL bareCsp); // true ==> CSP, false ==> CSP/DL + +/* Attach to DL side of CSPDL. */ +extern CSSM_DL_HANDLE cuDlStartup(); + +/* Attach to CL, TP */ +extern CSSM_CL_HANDLE cuClStartup(); +extern CSSM_TP_HANDLE cuTpStartup(); + +/* Open a DB, ensure it's empty. */ +CSSM_DB_HANDLE cuDbStartup( + CSSM_DL_HANDLE dlHand, // from dlStartup() + const char *dbName); + +/* Attach to existing DB or create an empty new one. */ +CSSM_DB_HANDLE cuDbStartupByName(CSSM_DL_HANDLE dlHand, + char *dbName, + CSSM_BOOL doCreate, + CSSM_BOOL quiet); + +/* + * Derive symmetric key using PBE. + */ +extern CSSM_RETURN cuCspDeriveKey(CSSM_CSP_HANDLE cspHand, + uint32 keyAlg, // CSSM_ALGID_RC5, etc. + const char *keyLabel, + unsigned keyLabelLen, + uint32 keyUsage, // CSSM_KEYUSE_ENCRYPT, etc. + uint32 keySizeInBits, + CSSM_DATA_PTR password, // in PKCS-5 lingo + CSSM_DATA_PTR salt, // ditto + uint32 iterationCnt, // ditto + CSSM_KEY_PTR key); + +/* + * Generate key pair of arbitrary algorithm. + */ +extern CSSM_RETURN cuCspGenKeyPair(CSSM_CSP_HANDLE cspHand, + CSSM_DL_DB_HANDLE *dlDbHand, // optional + uint32 algorithm, + const char *keyLabel, + unsigned keyLabelLen, + uint32 keySize, // in bits + CSSM_KEY_PTR pubKey, // mallocd by caller + CSSM_KEYUSE pubKeyUsage, // CSSM_KEYUSE_ENCRYPT, etc. + CSSM_KEYATTR_FLAGS pubAttrs, // CSSM_KEYATTR_EXTRACTABLE, etc. + CSSM_KEY_PTR privKey, // mallocd by caller + CSSM_KEYUSE privKeyUsage, // CSSM_KEYUSE_DECRYPT, etc. + CSSM_KEYATTR_FLAGS privAttrs); // CSSM_KEYATTR_EXTRACTABLE, etc. + +/* Convert a reference key to a raw key. */ +CSSM_RETURN cuRefKeyToRaw(CSSM_CSP_HANDLE cspHand, + const CSSM_KEY *refKey, + CSSM_KEY_PTR rawKey); // RETURNED + +/* + * Add a certificate to a keychain. + */ +CSSM_RETURN cuAddCertToKC( + SecKeychainRef keychain, + const CSSM_DATA *cert, + CSSM_CERT_TYPE certType, + CSSM_CERT_ENCODING certEncoding, + const char *printName, // C string + const CSSM_DATA *keyLabel); // ?? + +/* + * Convert a CSSM_DATA_PTR, referring to a DER-encoded int, to an + * unsigned. + */ +unsigned cuDER_ToInt( + const CSSM_DATA *DER_Data); + +/* + * Verify a CRL against system anchors and intermediate certs. + */ +CSSM_RETURN cuCrlVerify( + CSSM_TP_HANDLE tpHand, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + const CSSM_DATA *crlData, + CSSM_DL_DB_HANDLE_PTR certKeychain, // intermediate certs + const CSSM_DATA *anchors, + uint32 anchorCount); + +#ifdef __cplusplus +} +#endif + +#endif /* _COMMON_CDSA_UTILS_H_ */ \ No newline at end of file diff --git a/CdsaUtils/cuDbUtils.cpp b/CdsaUtils/cuDbUtils.cpp new file mode 100644 index 00000000..de78a602 --- /dev/null +++ b/CdsaUtils/cuDbUtils.cpp @@ -0,0 +1,559 @@ +/* + * Copyright (c) 2002-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. + * Please obtain a copy of the License at http://www.apple.com/publicsource + * and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights + * and limitations under the License. + */ + +/* + File: cuDbUtils.cpp + + Description: CDSA DB access utilities + + Author: dmitch +*/ + +#include "cuCdsaUtils.h" +#include "cuTimeStr.h" +#include "cuDbUtils.h" +#include "cuPrintCert.h" +#include +#include +#include +#include /* private SecInferLabelFromX509Name() */ +#include /* for cssmPerror() */ +#include +#include +#include +#include +#include /* private API */ + +/* + * Add a certificate to an open DLDB. + */ +CSSM_RETURN cuAddCertToDb( + CSSM_DL_DB_HANDLE dlDbHand, + const CSSM_DATA *cert, + CSSM_CERT_TYPE certType, + CSSM_CERT_ENCODING certEncoding, + const char *printName, // C string + const CSSM_DATA *publicKeyHash) +{ + CSSM_DB_ATTRIBUTE_DATA attrs[6]; + CSSM_DB_RECORD_ATTRIBUTE_DATA recordAttrs; + CSSM_DB_ATTRIBUTE_DATA_PTR attr = &attrs[0]; + CSSM_DATA certTypeData; + CSSM_DATA certEncData; + CSSM_DATA printNameData; + CSSM_RETURN crtn; + CSSM_DB_UNIQUE_RECORD_PTR recordPtr; + + /* issuer and serial number required, fake 'em */ + CSSM_DATA issuer = {6, (uint8 *)"issuer"}; + CSSM_DATA serial = {6, (uint8 *)"serial"}; + + /* we spec six attributes, skipping alias */ + certTypeData.Data = (uint8 *)&certType; + certTypeData.Length = sizeof(CSSM_CERT_TYPE); + certEncData.Data = (uint8 *)&certEncoding; + certEncData.Length = sizeof(CSSM_CERT_ENCODING); + printNameData.Data = (uint8 *)printName; + printNameData.Length = strlen(printName) + 1; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "CertType"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &certTypeData; + + attr++; + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "CertEncoding"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &certEncData; + + attr++; + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "PrintName"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &printNameData; + + attr++; + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "PublicKeyHash"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = (CSSM_DATA_PTR)publicKeyHash; + + attr++; + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "Issuer"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &issuer; + + attr++; + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "SerialNumber"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &serial; + + recordAttrs.DataRecordType = CSSM_DL_DB_RECORD_X509_CERTIFICATE; + recordAttrs.SemanticInformation = 0; + recordAttrs.NumberOfAttributes = 6; + recordAttrs.AttributeData = attrs; + + crtn = CSSM_DL_DataInsert(dlDbHand, + CSSM_DL_DB_RECORD_X509_CERTIFICATE, + &recordAttrs, + cert, + &recordPtr); + if(crtn) { + cuPrintError("CSSM_DL_DataInsert", crtn); + } + else { + CSSM_DL_FreeUniqueRecord(dlDbHand, recordPtr); + } + return crtn; +} + +static CSSM_RETURN cuAddCrlSchema( + CSSM_DL_DB_HANDLE dlDbHand); + +static void cuInferCrlLabel( + const CSSM_X509_NAME *x509Name, + CSSM_DATA *label) // not mallocd; contents are from the x509Name +{ + /* use private API for common "infer label" logic */ + const CSSM_DATA *printValue = SecInferLabelFromX509Name(x509Name); + if(printValue == NULL) { + /* punt! */ + label->Data = (uint8 *)"X509 CRL"; + label->Length = 8; + } + else { + *label = *printValue; + } +} + +/* + * Search extensions for specified OID, assumed to have underlying + * value type of uint32; returns the value and true if found. + */ +static bool cuSearchNumericExtension( + const CSSM_X509_EXTENSIONS *extens, + const CSSM_OID *oid, + uint32 *val) +{ + for(uint32 dex=0; dexnumberOfExtensions; dex++) { + const CSSM_X509_EXTENSION *exten = &extens->extensions[dex]; + if(!cuCompareOid(&exten->extnId, oid)) { + continue; + } + if(exten->format != CSSM_X509_DATAFORMAT_PAIR) { + printf("***Malformed extension\n"); + continue; + } + *val = *((uint32 *)exten->value.parsedValue); + return true; + } + return false; +} + +/* + * Add a CRL to an existing DL/DB. + */ +#define MAX_CRL_ATTRS 9 + +CSSM_RETURN cuAddCrlToDb( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_CL_HANDLE clHand, + const CSSM_DATA *crl, + const CSSM_DATA *URI) // optional +{ + CSSM_DB_ATTRIBUTE_DATA attrs[MAX_CRL_ATTRS]; + CSSM_DB_RECORD_ATTRIBUTE_DATA recordAttrs; + CSSM_DB_ATTRIBUTE_DATA_PTR attr = &attrs[0]; + CSSM_DATA crlTypeData; + CSSM_DATA crlEncData; + CSSM_DATA printNameData; + CSSM_RETURN crtn; + CSSM_DB_UNIQUE_RECORD_PTR recordPtr; + CSSM_DATA_PTR issuer; // mallocd by CL + CSSM_DATA_PTR crlValue; // ditto + uint32 numFields; + CSSM_HANDLE result; + CSSM_CRL_ENCODING crlEnc = CSSM_CRL_ENCODING_DER; + const CSSM_X509_SIGNED_CRL *signedCrl; + const CSSM_X509_TBS_CERTLIST *tbsCrl; + CSSM_CRL_TYPE crlType; + CSSM_DATA thisUpdateData = {0, NULL}; + CSSM_DATA nextUpdateData = {0, NULL}; + char *thisUpdate, *nextUpdate; + unsigned timeLen; + uint32 crlNumber; + uint32 deltaCrlNumber; + CSSM_DATA crlNumberData; + CSSM_DATA deltaCrlNumberData; + bool crlNumberPresent = false; + bool deltaCrlPresent = false; + CSSM_DATA attrUri; + + /* get normalized issuer name as Issuer attr */ + crtn = CSSM_CL_CrlGetFirstFieldValue(clHand, + crl, + &CSSMOID_X509V1IssuerName, + &result, + &numFields, + &issuer); + if(crtn) { + cuPrintError("CSSM_CL_CrlGetFirstFieldValue(Issuer)", crtn); + return crtn; + } + CSSM_CL_CrlAbortQuery(clHand, result); + + /* get parsed CRL from the CL */ + crtn = CSSM_CL_CrlGetFirstFieldValue(clHand, + crl, + &CSSMOID_X509V2CRLSignedCrlCStruct, + &result, + &numFields, + &crlValue); + if(crtn) { + cuPrintError("CSSM_CL_CrlGetFirstFieldValue(Issuer)", crtn); + return crtn; + } + CSSM_CL_CrlAbortQuery(clHand, result); + if(crlValue == NULL) { + printf("***CSSM_CL_CrlGetFirstFieldValue: value error (1)\n"); + return CSSMERR_CL_INVALID_CRL_POINTER; + } + if((crlValue->Data == NULL) || + (crlValue->Length != sizeof(CSSM_X509_SIGNED_CRL))) { + printf("***CSSM_CL_CrlGetFirstFieldValue: value error (2)\n"); + return CSSMERR_CL_INVALID_CRL_POINTER; + } + signedCrl = (const CSSM_X509_SIGNED_CRL *)crlValue->Data; + tbsCrl = &signedCrl->tbsCertList; + + /* CrlType inferred from version */ + if(tbsCrl->version.Length == 0) { + /* should never happen... */ + crlType = CSSM_CRL_TYPE_X_509v1; + } + else { + uint8 vers = tbsCrl->version.Data[tbsCrl->version.Length - 1]; + switch(vers) { + case 0: + crlType = CSSM_CRL_TYPE_X_509v1; + break; + case 1: + crlType = CSSM_CRL_TYPE_X_509v2; + break; + default: + printf("***Unknown version in CRL (%u)\n", vers); + crlType = CSSM_CRL_TYPE_X_509v1; + break; + } + } + crlTypeData.Data = (uint8 *)&crlType; + crlTypeData.Length = sizeof(CSSM_CRL_TYPE); + /* encoding more-or-less assumed here */ + crlEncData.Data = (uint8 *)&crlEnc; + crlEncData.Length = sizeof(CSSM_CRL_ENCODING); + + /* printName inferred from issuer */ + cuInferCrlLabel(&tbsCrl->issuer, &printNameData); + + /* cook up CSSM_TIMESTRING versions of this/next update */ + thisUpdate = cuX509TimeToCssmTimestring(&tbsCrl->thisUpdate, &timeLen); + if(thisUpdate == NULL) { + printf("***Badly formatted thisUpdate\n"); + } + else { + thisUpdateData.Data = (uint8 *)thisUpdate; + thisUpdateData.Length = timeLen; + } + if(tbsCrl->nextUpdate.time.Data != NULL) { + nextUpdate = cuX509TimeToCssmTimestring(&tbsCrl->nextUpdate, &timeLen); + if(nextUpdate == NULL) { + printf("***Badly formatted nextUpdate\n"); + } + else { + nextUpdateData.Data = (uint8 *)nextUpdate; + nextUpdateData.Length = timeLen; + } + } + else { + /* + * NextUpdate not present; fake it by using "virtual end of time" + */ + CSSM_X509_TIME tempTime = { 0, // timeType, not used + { strlen(CSSM_APPLE_CRL_END_OF_TIME), + (uint8 *)CSSM_APPLE_CRL_END_OF_TIME} }; + nextUpdate = cuX509TimeToCssmTimestring(&tempTime, &timeLen); + nextUpdateData.Data = (uint8 *)nextUpdate; + nextUpdateData.Length = CSSM_TIME_STRLEN; + } + + /* optional CrlNumber and DeltaCrlNumber */ + if(cuSearchNumericExtension(&tbsCrl->extensions, + &CSSMOID_CrlNumber, + &crlNumber)) { + crlNumberData.Data = (uint8 *)&crlNumber; + crlNumberData.Length = sizeof(uint32); + crlNumberPresent = true; + } + if(cuSearchNumericExtension(&tbsCrl->extensions, + &CSSMOID_DeltaCrlIndicator, + &deltaCrlNumber)) { + deltaCrlNumberData.Data = (uint8 *)&deltaCrlNumber; + deltaCrlNumberData.Length = sizeof(uint32); + deltaCrlPresent = true; + } + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "CrlType"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &crlTypeData; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "CrlEncoding"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &crlEncData; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "PrintName"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &printNameData; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "Issuer"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = issuer; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "ThisUpdate"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &thisUpdateData; + attr++; + + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "NextUpdate"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &nextUpdateData; + attr++; + + /* now the optional attributes */ + if(crlNumberPresent) { + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "CrlNumber"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &crlNumberData; + attr++; + } + if(deltaCrlPresent) { + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "DeltaCrlNumber"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_UINT32; + attr->NumberOfValues = 1; + attr->Value = &deltaCrlNumberData; + attr++; + } + if(URI) { + /* ensure URI string does not contain NULL */ + attrUri = *URI; + if((attrUri.Length != 0) && + (attrUri.Data[attrUri.Length - 1] == 0)) { + attrUri.Length--; + } + attr->Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr->Info.Label.AttributeName = "URI"; + attr->Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + attr->NumberOfValues = 1; + attr->Value = &attrUri; + attr++; + } + recordAttrs.DataRecordType = CSSM_DL_DB_RECORD_X509_CRL; + recordAttrs.SemanticInformation = 0; + recordAttrs.NumberOfAttributes = attr - attrs; + recordAttrs.AttributeData = attrs; + + crtn = CSSM_DL_DataInsert(dlDbHand, + CSSM_DL_DB_RECORD_X509_CRL, + &recordAttrs, + crl, + &recordPtr); + if(crtn == CSSMERR_DL_INVALID_RECORDTYPE) { + /* gross hack of inserting this "new" schema that Keychain didn't specify */ + crtn = cuAddCrlSchema(dlDbHand); + if(crtn == CSSM_OK) { + /* Retry with a fully capable DLDB */ + crtn = CSSM_DL_DataInsert(dlDbHand, + CSSM_DL_DB_RECORD_X509_CRL, + &recordAttrs, + crl, + &recordPtr); + } + } + if(crtn) { + cuPrintError("CSSM_DL_DataInsert", crtn); + } + else { + CSSM_DL_FreeUniqueRecord(dlDbHand, recordPtr); + } + + /* free all the stuff we allocated to get here */ + CSSM_CL_FreeFieldValue(clHand, &CSSMOID_X509V1IssuerName, issuer); + CSSM_CL_FreeFieldValue(clHand, &CSSMOID_X509V2CRLSignedCrlCStruct, crlValue); + free(thisUpdate); + free(nextUpdate); + return crtn; +} + + +/* + * Update an existing DLDB to be CRL-capable. + */ +static CSSM_RETURN cuAddCrlSchema( + CSSM_DL_DB_HANDLE dlDbHand) +{ + return CSSM_DL_CreateRelation(dlDbHand, + CSSM_DL_DB_RECORD_X509_CRL, + "CSSM_DL_DB_RECORD_X509_CRL", + Security::KeychainCore::Schema::X509CrlSchemaAttributeCount, + Security::KeychainCore::Schema::X509CrlSchemaAttributeList, + Security::KeychainCore::Schema::X509CrlSchemaIndexCount, + Security::KeychainCore::Schema::X509CrlSchemaIndexList); +} + +/* + * Search DB for all records of type CRL or cert, calling appropriate + * parse/print routine for each record. + */ +CSSM_RETURN cuDumpCrlsCerts( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_CL_HANDLE clHand, + CSSM_BOOL isCert, + unsigned &numItems, // returned + CSSM_BOOL verbose) +{ + CSSM_QUERY query; + CSSM_DB_UNIQUE_RECORD_PTR record = NULL; + CSSM_HANDLE resultHand; + CSSM_RETURN crtn; + CSSM_DATA certCrl; + const char *itemStr; + + numItems = 0; + itemStr = isCert ? "Certificate" : "CRL"; + + /* just search by recordType, no predicates, no attributes */ + if(isCert) { + query.RecordType = CSSM_DL_DB_RECORD_X509_CERTIFICATE; + } + else { + query.RecordType = CSSM_DL_DB_RECORD_X509_CRL; + } + query.Conjunctive = CSSM_DB_NONE; + query.NumSelectionPredicates = 0; + query.SelectionPredicate = NULL; + query.QueryLimits.TimeLimit = 0; // FIXME - meaningful? + query.QueryLimits.SizeLimit = 1; // FIXME - meaningful? + query.QueryFlags = 0; // CSSM_QUERY_RETURN_DATA...FIXME - used? + + certCrl.Data = NULL; + certCrl.Length = 0; + crtn = CSSM_DL_DataGetFirst(dlDbHand, + &query, + &resultHand, + NULL, // no attrs + &certCrl, + &record); + switch(crtn) { + case CSSM_OK: + break; // proceed + case CSSMERR_DL_ENDOFDATA: + /* no data, otherwise OK */ + return CSSM_OK; + case CSSMERR_DL_INVALID_RECORDTYPE: + /* invalid record type just means "this hasn't been set up + * for certs yet". */ + return crtn; + default: + cuPrintError("DataGetFirst", crtn); + return crtn; + } + + /* got one; print it */ + printf("%s %u:\n", itemStr, numItems); + if(isCert) { + printCert(certCrl.Data, certCrl.Length, verbose); + } + else { + printCrl(certCrl.Data, certCrl.Length, verbose); + } + CSSM_DL_FreeUniqueRecord(dlDbHand, record); + APP_FREE(certCrl.Data); + certCrl.Data = NULL; + certCrl.Length = 0; + numItems++; + + /* get the rest */ + for(;;) { + crtn = CSSM_DL_DataGetNext(dlDbHand, + resultHand, + NULL, + &certCrl, + &record); + switch(crtn) { + case CSSM_OK: + printf("%s %u:\n", itemStr, numItems); + if(isCert) { + printCert(certCrl.Data, certCrl.Length, verbose); + } + else { + printCrl(certCrl.Data, certCrl.Length, verbose); + } + CSSM_DL_FreeUniqueRecord(dlDbHand, record); + APP_FREE(certCrl.Data); + certCrl.Data = NULL; + certCrl.Length = 0; + numItems++; + break; // and go again + case CSSMERR_DL_ENDOFDATA: + /* normal termination */ + return CSSM_OK; + default: + cuPrintError("DataGetNext", crtn); + return crtn; + } + } + /* NOT REACHED */ +} + diff --git a/CdsaUtils/cuDbUtils.h b/CdsaUtils/cuDbUtils.h new file mode 100644 index 00000000..70931a50 --- /dev/null +++ b/CdsaUtils/cuDbUtils.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2002-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: cuDbUtils.h + + Description: CDSA DB access utilities + + Author: dmitch +*/ + +#ifndef _CU_DB_UTILS_H_ +#define _CU_DB_UTILS_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Add a certificate to an open DLDB. + */ +CSSM_RETURN cuAddCertToDb( + CSSM_DL_DB_HANDLE dlDbHand, + const CSSM_DATA *cert, + CSSM_CERT_TYPE certType, + CSSM_CERT_ENCODING certEncoding, + const char *printName, // C string + const CSSM_DATA *publicKeyHash); // ?? + +/* + * Add a CRL to an open DL/DB. + */ +CSSM_RETURN cuAddCrlToDb( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_CL_HANDLE clHand, + const CSSM_DATA *crl, + const CSSM_DATA *URI); // optional + +/* + * Search DB for all records of type CRL or cert, calling appropriate + * parse/print routine for each record. + */ +CSSM_RETURN cuDumpCrlsCerts( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_CL_HANDLE clHand, + CSSM_BOOL isCert, + unsigned &numItems, // returned + CSSM_BOOL verbose); + +#ifdef __cplusplus +} +#endif + +#endif /* _CU_DB_UTILS_H_ */ \ No newline at end of file diff --git a/CertTool/cdsaUtils/cuEnc64.c b/CdsaUtils/cuEnc64.c similarity index 85% rename from CertTool/cdsaUtils/cuEnc64.c rename to CdsaUtils/cuEnc64.c index 2e69af83..59dfbdc9 100644 --- a/CertTool/cdsaUtils/cuEnc64.c +++ b/CdsaUtils/cuEnc64.c @@ -1,36 +1,26 @@ -/* Copyright (c) 1998 Apple Computer, Inc. All rights reserved. - * - * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT - * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE - * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE COMPUTER, INC. AND THE - * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE COMPUTER, - * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL - * EXPOSE YOU TO LIABILITY. - *************************************************************************** - * - * enc64.c - encode/decode in 64-char IA5 format, per RFC 1421 +/* + * Copyright (c) 1998-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * Revision History - * ---------------- - * 11/27/98 dmitch - * Added ECDSA_VERIFY_ONLY dependencies. - * 10/06/98 ap - * Changed to compile with C++. - * 12 Dec 96 Doug Mitchell at NeXT - * Newlines optional in dec64() and isValidEnc64(). - * 9 Oct 96 Doug Mitchell at NeXT - * Created. + * cuEnc64.c - encode/decode in 64-char IA5 format, per RFC 1421 */ #include "cuEnc64.h" #include -/* - * 11/27/98 dmitch: The ECDSA_VERIFY_ONLY symbol, when #defined, disables all - * of the code in this module except that which is necessary for ECDSA - * siggnature verification. - */ - #ifndef NULL #define NULL ((void *)0) #endif /* NULL */ @@ -112,14 +102,14 @@ static void encChunk(const unsigned char *inp, * is returned in *outlen. */ -unsigned char *enc64(const unsigned char *inbuf, +unsigned char *cuEnc64(const unsigned char *inbuf, unsigned inlen, unsigned *outlen) // RETURNED { - return enc64WithLines(inbuf, inlen, 0, outlen); + return cuEnc64WithLines(inbuf, inlen, 0, outlen); } -unsigned char *enc64WithLines(const unsigned char *inbuf, +unsigned char *cuEnc64WithLines(const unsigned char *inbuf, unsigned inlen, unsigned linelen, unsigned *outlen) @@ -129,7 +119,7 @@ unsigned char *enc64WithLines(const unsigned char *inbuf, unsigned olen = 0; // actual output size unsigned char *outbuf; unsigned char endbuf[3]; - int i; + unsigned i; unsigned char *outp; unsigned numLines; unsigned thisLine; @@ -240,7 +230,7 @@ static unsigned char *stringCleanse(const unsigned char *inbuf, * * All whitespace in input is ignored. */ -unsigned char *dec64(const unsigned char *inbuf, +unsigned char *cuDec64(const unsigned char *inbuf, unsigned inlen, unsigned *outlen) { @@ -359,7 +349,7 @@ errorOut: * This doesn't do a full enc64 parse job; it scans for legal characters * and proper sync when a possible pad is found. */ -int isValidEnc64(const unsigned char *inbuf, +int cuIsValidEnc64(const unsigned char *inbuf, unsigned inlen) { int padChars = 0; // running count of PAD chars diff --git a/CdsaUtils/cuEnc64.h b/CdsaUtils/cuEnc64.h new file mode 100644 index 00000000..77cb958b --- /dev/null +++ b/CdsaUtils/cuEnc64.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1998-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * cuEnc64.h - encode/decode in 64-char IA5 format, per RFC 1421 + */ + +#ifndef _CU_ENC64_H_ +#define _CU_ENC64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Given input buffer inbuf, length inlen, decode from 64-char IA5 format to + * binary. Result is malloced and returned; its length is returned in *outlen. + * NULL return indicates corrupted input. + */ +unsigned char *cuEnc64(const unsigned char *inbuf, + unsigned inlen, + unsigned *outlen); // RETURNED + +/* + * Enc64, with embedded newlines every lineLen in result. A newline is + * the UNIX \n. Result is mallocd. + */ +unsigned char *cuEnc64WithLines(const unsigned char *inbuf, + unsigned inlen, + unsigned linelen, + unsigned *outlen); // RETURNED + +/* + * Given input buffer inbuf, length inlen, decode from 64-char IA5 format to + * binary. Result is malloced and returned; its length is returned in *outlen. + * NULL return indicates corrupted input. All whitespace in inbuf is + * ignored. + */ +unsigned char *cuDec64(const unsigned char *inbuf, + unsigned inlen, + unsigned *outlen); + +/* + * Determine if specified input data is valid enc64 format. Returns 1 + * if valid, 0 if not. + */ +int cuIsValidEnc64(const unsigned char *inbuf, + unsigned inbufLen); + +#ifdef __cplusplus +} +#endif + +#endif /*_CU_ENC64_H_*/ diff --git a/CdsaUtils/cuFileIo.c b/CdsaUtils/cuFileIo.c new file mode 100644 index 00000000..010a1e58 --- /dev/null +++ b/CdsaUtils/cuFileIo.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2001-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: cuFileIo.c + + Description: simple file read/write utilities +*/ + +#include +#include +#include +#include +#include +#include +#include +#include "cuFileIo.h" + +int writeFile( + const char *fileName, + const unsigned char *bytes, + unsigned numBytes) +{ + int rtn; + int fd; + + fd = open(fileName, O_RDWR | O_CREAT | O_TRUNC, 0600); + if(fd <= 0) { + return errno; + } + rtn = lseek(fd, 0, SEEK_SET); + if(rtn < 0) { + return errno; + } + rtn = write(fd, bytes, (size_t)numBytes); + if(rtn != (int)numBytes) { + if(rtn >= 0) { + printf("writeFile: short write\n"); + } + rtn = EIO; + } + else { + rtn = 0; + } + close(fd); + return rtn; +} + +/* + * Read entire file. + */ +int readFile( + const char *fileName, + unsigned char **bytes, // mallocd and returned + unsigned *numBytes) // returned +{ + int rtn; + int fd; + char *buf; + struct stat sb; + unsigned size; + + *numBytes = 0; + *bytes = NULL; + fd = open(fileName, O_RDONLY, 0); + if(fd <= 0) { + return errno; + } + rtn = fstat(fd, &sb); + if(rtn) { + goto errOut; + } + size = sb.st_size; + buf = malloc(size); + if(buf == NULL) { + rtn = ENOMEM; + goto errOut; + } + rtn = lseek(fd, 0, SEEK_SET); + if(rtn < 0) { + goto errOut; + } + rtn = read(fd, buf, (size_t)size); + if(rtn != (int)size) { + if(rtn >= 0) { + printf("readFile: short read\n"); + } + rtn = EIO; + } + else { + rtn = 0; + *bytes = buf; + *numBytes = size; + } +errOut: + close(fd); + return rtn; +} diff --git a/CdsaUtils/cuFileIo.h b/CdsaUtils/cuFileIo.h new file mode 100644 index 00000000..bb3de3f8 --- /dev/null +++ b/CdsaUtils/cuFileIo.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2001-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: cuFileIo.h + + Description: simple file read/write utilities +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +int readFile( + const char *fileName, + unsigned char **bytes, // mallocd and returned + unsigned *numBytes); // returned + +int writeFile( + const char *fileName, + const unsigned char *bytes, + unsigned numBytes); + +#ifdef __cplusplus +} +#endif diff --git a/CertTool/cdsaUtils/oidParser.cpp b/CdsaUtils/cuOidParser.cpp similarity index 86% rename from CertTool/cdsaUtils/oidParser.cpp rename to CdsaUtils/cuOidParser.cpp index a25a9be0..105218c7 100644 --- a/CertTool/cdsaUtils/oidParser.cpp +++ b/CdsaUtils/cuOidParser.cpp @@ -1,13 +1,32 @@ /* - * oidParser.cpp - parse an Intel-style OID, with the assistance of dumpasn1.cfg + * Copyright (c) 2002-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. + * Please obtain a copy of the License at http://www.apple.com/publicsource + * and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights + * and limitations under the License. + */ + +/* + * cuOidParser.cpp - parse an Intel-style OID, with the assistance + * of dumpasn1.cfg */ #include #include #include #include -#include "oidParser.h" -#include "fileIo.h" +#include "cuOidParser.h" +#include "cuFileIo.h" #include #include #include @@ -116,7 +135,6 @@ static CSSM_DATA_PTR readConfig() return configData; } else { - printf("""warning: no OID parser config file\n"); free(configData); return NULL; } diff --git a/CdsaUtils/cuOidParser.h b/CdsaUtils/cuOidParser.h new file mode 100644 index 00000000..fcadc5a7 --- /dev/null +++ b/CdsaUtils/cuOidParser.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2002-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * cuOidParser.cpp - parse an Intel-style OID, with the assistance of + * dumpasn1.cfg. + * + * The config file is looked for in the following locations: + * + * current working directory (.) + * parent directory (..) + * The directory specified by the environment variable LOCAL_BUILD_DIR + * + * OidParser will still work if the config file is not found, but OIDs + * will be dispayed in raw hex format. + */ + +#ifndef _OID_PARSER_H_ +#define _OID_PARSER_H_ + +#include + +/* + * Generated strings go into a client-allocated char array of + * this size. + */ +#define OID_PARSER_STRING_SIZE 120 + +class OidParser +{ +private: + CSSM_DATA_PTR configData; // contents of dumpasn1.cfg +public: + /* costruct with noConfig true - skip reading config file */ + OidParser(bool noConfig=false); + ~OidParser(); + + /* + * Parse an Intel-style OID, generating a C string in + * caller-supplied buffer. + */ + void oidParse( + const unsigned char *oidp, + unsigned oidLen, + char *strBuf); + +}; + +#endif /* _OID_PARSER_H_ */ diff --git a/CdsaUtils/cuPem.cpp b/CdsaUtils/cuPem.cpp new file mode 100644 index 00000000..6675ef60 --- /dev/null +++ b/CdsaUtils/cuPem.cpp @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: cuPem.h + + Description: PEM encode/decode routines + + Author: dmitch + +*/ + +#include "cuPem.h" +#include +#include +#include +#include +#include "cuEnc64.h" + +#define PEM_SCAN_LEN 8192 + +/* + * Determine if specified blob appears to be PEM format. + * Returns 1 if so, 0 if not. + */ +int isPem( + const unsigned char *inData, + unsigned inDataLen) +{ + /* + * 1. The entire blob must be printable ASCII. + */ + const unsigned char *cp = inData; + for(unsigned dex=0; dex PEM_SCAN_LEN) { + len = PEM_SCAN_LEN; + } + memcpy(buf, inData, len); + buf[len] = '\0'; + const char *p = strstr((const char *)buf, "-----BEGIN "); + if(p == NULL) { + return 0; + } + + /* + * Now the last PEM_SCAN_LEN chars or inDataLen, whichever is less. + */ + if(inDataLen > PEM_SCAN_LEN) { + memcpy(buf, inData + inDataLen - PEM_SCAN_LEN, PEM_SCAN_LEN); + buf[PEM_SCAN_LEN] = '\0'; + } + /* else we already have whole blob in buf[] */ + p = strstr((const char *)buf, "-----END "); + if(p == NULL) { + return 0; + } + /* success */ + return 1; +} + +int pemEncode( + const unsigned char *inData, + unsigned inDataLen, + unsigned char **outData, + unsigned *outDataLen, + const char *headerString) +{ + unsigned char *enc; + unsigned encLen; + + /* First base64 encode */ + enc = cuEnc64WithLines(inData, inDataLen, 64, &encLen); + if(enc == NULL) { + /* malloc error is actually the only known failure */ + printf("***pemEncode: Error encoding file. Aborting.\n"); + return -1; + } + + /* estimate outsize - just be sloppy, way conservative */ + unsigned outSize = encLen + (2 * strlen(headerString)) + 200; + *outData = (unsigned char *)malloc(outSize); + sprintf((char *)*outData, "-----BEGIN %s-----\n%s-----END %s-----\n", + headerString, (char *)enc, headerString); + *outDataLen = strlen((char *)*outData); + + if((*outData)[*outDataLen - 1] == '\0') { + (*outDataLen)--; + } + free(enc); + return 0; +} + +int pemDecode( + const unsigned char *inData, + unsigned inDataLen, + unsigned char **outData, + unsigned *outDataLen) +{ + char *cp; + char *curr1, *curr2; + char *startPem = NULL; + char *endPem = NULL; + unsigned char *out; + unsigned outLen; + int ourRtn = 0; + char *freeCp = NULL; + + /* make the whole thing a NULL-terminated string */ + if(inData[inDataLen - 1] != '\0') { + cp = freeCp = (char *)malloc(inDataLen + 1); + memmove(cp, inData, inDataLen); + cp[inDataLen] = '\0'; + inDataLen++; + } + else { + /* already is */ + cp = (char *)inData; + } + + /* cp is start of NULL-terminated buffer, size inDataLen */ + /* skip over everything until "-----" */ + curr1 = strstr(cp, "-----"); + if(curr1 == NULL) { + printf("***pemDecode: no terminator found\n"); + ourRtn = -1; + goto abort; + } + + /* find end of separator line, handling both flavors of terminator */ + cp = curr1; + curr1 = strchr(cp, '\n'); + curr2 = strchr(cp, '\r'); + if((curr1 == NULL) & (curr2 == NULL)) { + printf("***pemDecode: Bad PEM format (1)\n"); + ourRtn = -1; + goto abort; + } + if(curr1 == NULL) { + startPem = curr2; + } + else { + startPem = curr1; + } + + /* startPem points to end of separator line */ + /* locate ending terminator and lop it off */ + curr1 = strstr(startPem, "-----"); + if(curr1 == NULL) { + printf("***pemDecode: Bad PEM format (2)\n"); + ourRtn = -1; + goto abort; + } + endPem = curr1; + /* endPem points to last PEM data plus one */ + + out = cuDec64((unsigned char *)startPem, endPem-startPem, &outLen); + if(out == NULL) { + printf("Bad PEM format (3)\n"); + ourRtn = -1; + goto abort; + } + *outData = out; + *outDataLen = outLen; +abort: + if(freeCp) { + free(freeCp); + } + return ourRtn; +} + diff --git a/CdsaUtils/cuPem.h b/CdsaUtils/cuPem.h new file mode 100644 index 00000000..58a08fde --- /dev/null +++ b/CdsaUtils/cuPem.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: cuPem.h + + Description: PEM encode/decode routines + + Author: dmitch +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +int isPem( + const unsigned char *inData, + unsigned inDataLen); + +int pemEncode( + const unsigned char *inData, + unsigned inFileLen, + unsigned char **outData, + unsigned *outDataLen, + const char *headerString); + +int pemDecode( + const unsigned char *inData, + unsigned inFileLen, + unsigned char **outData, + unsigned *outDataLen); + +#ifdef __cplusplus +} +#endif diff --git a/CertTool/cdsaUtils/printCert.cpp b/CdsaUtils/cuPrintCert.cpp similarity index 52% rename from CertTool/cdsaUtils/printCert.cpp rename to CdsaUtils/cuPrintCert.cpp index 1a01990a..3c738740 100644 --- a/CertTool/cdsaUtils/printCert.cpp +++ b/CdsaUtils/cuPrintCert.cpp @@ -1,17 +1,35 @@ /* - * Parse a cert, dump contents. + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. */ -#include "cdsaUtils.h" + +/* + * cuPrintCert.cpp - Parse a cert or CRL, dump contents. + */ +#include "cuCdsaUtils.h" #include #include #include +#include #include #include #include #include -#include "printCert.h" -#include "oidParser.h" -#include "timeStr.h" +#include "cuPrintCert.h" +#include "cuOidParser.h" +#include "cuTimeStr.h" #include static char *months[] = { @@ -19,31 +37,12 @@ static char *months[] = { "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -/* - * Convert a CSSM_DATA_PTR, referring to a DER-encoded int, to a - * uint32. - */ -static uint32 DER_ToInt(const CSSM_DATA *DER_Data) -{ - uint32 rtn = 0; - uint32 i = 0; - - while(i < DER_Data->Length) { - rtn |= DER_Data->Data[i]; - if(++i == DER_Data->Length) { - break; - } - rtn <<= 8; - } - return rtn; -} - -static void printTime(const CSSM_X509_TIME *cssmTime) +static void printTimeStr(const CSSM_DATA *cssmTime) { struct tm tm; /* ignore cssmTime->timeType for now */ - if(appTimeStringToTm((char *)cssmTime->time.Data, cssmTime->time.Length, &tm)) { + if(cuTimeStringToTm((char *)cssmTime->Data, cssmTime->Length, &tm)) { printf("***Bad time string format***\n"); return; } @@ -57,6 +56,13 @@ static void printTime(const CSSM_X509_TIME *cssmTime) } + +static void printTime(const CSSM_X509_TIME *cssmTime) +{ + /* ignore cssmTime->timeType for now */ + printTimeStr(&cssmTime->time); +} + static void printDataAsHex( const CSSM_DATA *d, unsigned maxToPrint = 0) // optional, 0 means print it all @@ -204,14 +210,14 @@ static void printDerThing( { switch(tagType) { case BER_TAG_INTEGER: - printf("%u\n", (unsigned)DER_ToInt(thing)); + printf("%d\n", cuDER_ToInt(thing)); return; case BER_TAG_BOOLEAN: if(thing->Length != 1) { - printf("***malformed BER_TAG_BOOLEAN: length %d data ", + printf("***malformed BER_TAG_BOOLEAN: length %u data ", (unsigned)thing->Length); } - printf("%u\n", (unsigned)DER_ToInt(thing)); + printf("%u\n", cuDER_ToInt(thing)); return; case BER_TAG_PRINTABLE_STRING: case BER_TAG_IA5_STRING: @@ -243,12 +249,12 @@ static void printDerThing( } static void printSigAlg( - CSSM_X509_ALGORITHM_IDENTIFIER *sigAlg, - OidParser &parser) + const CSSM_X509_ALGORITHM_IDENTIFIER *sigAlg, + OidParser &parser) { printOid(parser, &sigAlg->algorithm); if(sigAlg->parameters.Data != NULL) { - printf(" alg params : "); + printf(" alg params : "); printDataAsHex(&sigAlg->parameters, 8); } } @@ -272,61 +278,69 @@ static CSSM_BOOL compareOids( } } -static CSSM_RETURN printName( - const CSSM_X509_NAME_PTR x509Name, +static void printRdn( + const CSSM_X509_RDN *rdnp, OidParser &parser) { CSSM_X509_TYPE_VALUE_PAIR *ptvp; - CSSM_X509_RDN_PTR rdnp; - unsigned rdnDex; unsigned pairDex; char *fieldName; + for(pairDex=0; pairDexnumberOfPairs; pairDex++) { + ptvp = &rdnp->AttributeTypeAndValue[pairDex]; + if(compareOids(&ptvp->type, &CSSMOID_CountryName)) { + fieldName = "Country "; + } + else if(compareOids(&ptvp->type, &CSSMOID_OrganizationName)) { + fieldName = "Org "; + } + else if(compareOids(&ptvp->type, &CSSMOID_LocalityName)) { + fieldName = "Locality "; + } + else if(compareOids(&ptvp->type, &CSSMOID_OrganizationalUnitName)) { + fieldName = "OrgUnit "; + } + else if(compareOids(&ptvp->type, &CSSMOID_CommonName)) { + fieldName = "Common Name "; + } + else if(compareOids(&ptvp->type, &CSSMOID_Surname)) { + fieldName = "Surname "; + } + else if(compareOids(&ptvp->type, &CSSMOID_Title)) { + fieldName = "Title "; + } + else if(compareOids(&ptvp->type, &CSSMOID_Surname)) { + fieldName = "Surname "; + } + else if(compareOids(&ptvp->type, &CSSMOID_StateProvinceName)) { + fieldName = "State "; + } + else if(compareOids(&ptvp->type, &CSSMOID_CollectiveStateProvinceName)) { + fieldName = "Coll. State "; + } + else if(compareOids(&ptvp->type, &CSSMOID_EmailAddress)) { + /* deprecated, used by Thawte */ + fieldName = "Email addrs "; + } + else { + fieldName = "Other name "; + } + printf(" %s : ", fieldName); + printDerThing(ptvp->valueType, &ptvp->value, parser); + } /* for each type/value pair */ +} + +static CSSM_RETURN printName( + const CSSM_X509_NAME *x509Name, + OidParser &parser) +{ + CSSM_X509_RDN_PTR rdnp; + unsigned rdnDex; + for(rdnDex=0; rdnDexnumberOfRDNs; rdnDex++) { rdnp = &x509Name->RelativeDistinguishedName[rdnDex]; - for(pairDex=0; pairDexnumberOfPairs; pairDex++) { - ptvp = &rdnp->AttributeTypeAndValue[pairDex]; - if(compareOids(&ptvp->type, &CSSMOID_CountryName)) { - fieldName = "Country "; - } - else if(compareOids(&ptvp->type, &CSSMOID_OrganizationName)) { - fieldName = "Org "; - } - else if(compareOids(&ptvp->type, &CSSMOID_LocalityName)) { - fieldName = "Locality "; - } - else if(compareOids(&ptvp->type, &CSSMOID_OrganizationalUnitName)) { - fieldName = "OrgUnit "; - } - else if(compareOids(&ptvp->type, &CSSMOID_CommonName)) { - fieldName = "Common Name "; - } - else if(compareOids(&ptvp->type, &CSSMOID_Surname)) { - fieldName = "Surname "; - } - else if(compareOids(&ptvp->type, &CSSMOID_Title)) { - fieldName = "Title "; - } - else if(compareOids(&ptvp->type, &CSSMOID_Surname)) { - fieldName = "Surname "; - } - else if(compareOids(&ptvp->type, &CSSMOID_StateProvinceName)) { - fieldName = "State "; - } - else if(compareOids(&ptvp->type, &CSSMOID_CollectiveStateProvinceName)) { - fieldName = "Coll. State "; - } - else if(compareOids(&ptvp->type, &CSSMOID_EmailAddress)) { - /* deprecated, used by Thawte */ - fieldName = "Email addrs "; - } - else { - fieldName = "Other name "; - } - printf(" %s : ", fieldName); - printDerThing(ptvp->valueType, &ptvp->value, parser); - } /* for each type/value pair */ - } /* for each RDN */ + printRdn(rdnp, parser); + } return CSSM_OK; } @@ -334,7 +348,7 @@ static CSSM_RETURN printName( static void printKeyHeader( const CSSM_KEYHEADER &hdr) { - printf(" Algorithm : "); + printf(" Algorithm : "); switch(hdr.AlgorithmId) { case CSSM_ALGID_RSA: printf("RSA\n"); @@ -345,12 +359,15 @@ static void printKeyHeader( case CSSM_ALGID_FEE: printf("FEE\n"); break; + case CSSM_ALGID_DH: + printf("Diffie-Hellman\n"); + break; default: - printf("Unknown(%d(d), 0x%x)\n", (unsigned)hdr.AlgorithmId, - (unsigned)hdr.AlgorithmId); + printf("Unknown(%u(d), 0x%x)\n", (unsigned)hdr.AlgorithmId, + (unsigned)hdr.AlgorithmId); } - printf(" Key Size : %u bits\n", (unsigned)hdr.LogicalKeySizeInBits); - printf(" Key Use : "); + printf(" Key Size : %u bits\n", (unsigned)hdr.LogicalKeySizeInBits); + printf(" Key Use : "); CSSM_KEYUSE usage = hdr.KeyUsage; if(usage & CSSM_KEYUSE_ANY) { printf("CSSM_KEYUSE_ANY "); @@ -390,8 +407,8 @@ static void printKeyHeader( * Print contents of a CE_GeneralNames as best we can. */ static void printGeneralNames( - CE_GeneralNames *generalNames, - OidParser &parser) + const CE_GeneralNames *generalNames, + OidParser &parser) { unsigned i; CE_GeneralName *name; @@ -400,19 +417,19 @@ static void printGeneralNames( name = &generalNames->generalName[i]; switch(name->nameType) { case GNT_RFC822Name: - printf(" RFC822Name : "); + printf(" RFC822Name : "); printString(&name->name); break; case GNT_DNSName: - printf(" DNSName : "); + printf(" DNSName : "); printString(&name->name); break; case GNT_URI: - printf(" URI : "); + printf(" URI : "); printString(&name->name); break; case GNT_IPAddress: - printf(" IP Address : "); + printf(" IP Address : "); for(unsigned i=0; iname.Length; i++) { printf("%d", name->name.Data[i]); if(i < (name->name.Length - 1)) { @@ -422,44 +439,71 @@ static void printGeneralNames( printf("\n"); break; case GNT_RegisteredID: - printf(" RegisteredID : "); + printf(" RegisteredID : "); printOid(parser, &name->name); break; case GNT_X400Address: /* ORAddress, a very complicated struct - punt */ - printf(" X400Address : "); + printf(" X400Address : "); printBlobBytes("Sequence", "bytes", name->name.Length, &name->name); break; case GNT_DirectoryName: - /* encoded Name (i.e. CSSM_X509_NAME) */ - printf(" Dir Name : "); - printBlobBytes("Byte string", "bytes", name->name.Length, &name->name); + if(!name->berEncoded) { + /* CL parsed it for us into an CSSM_X509_NAME */ + if(name->name.Length != sizeof(CSSM_X509_NAME)) { + printf("***MALFORMED GNT_DirectoryName\n"); + break; + } + const CSSM_X509_NAME *x509Name = + (const CSSM_X509_NAME *)name->name.Data; + printf(" Dir Name :\n"); + printName(x509Name, parser); + } + else { + /* encoded Name (i.e. CSSM_X509_NAME) */ + printf(" Dir Name : "); + printBlobBytes("Byte string", "bytes", + name->name.Length, &name->name); + } break; case GNT_EdiPartyName: /* sequence EDIPartyName */ - printf(" EdiPartyName : "); + printf(" EdiPartyName : "); printBlobBytes("Sequence", "bytes", name->name.Length, &name->name); break; case GNT_OtherName: - printf(" OtherName : "); - printOid(parser, &name->name); + { + printf(" OtherName :\n"); + if(name->name.Length != sizeof(CE_OtherName)) { + printf("***Malformed CE_OtherName\n"); + break; + } + CE_OtherName *other = (CE_OtherName *)name->name.Data; + printf(" typeID : "); + printOid(parser, &other->typeId); + printf(" value : "); + printDataAsHex(&other->value, 0); break; + } } } } -static int printExtensionCommon( - const CSSM_DATA &value, - OidParser &parser, - bool expectParsed = true) +static int printCdsaExtensionCommon( + const CSSM_X509_EXTENSION *cssmExt, + OidParser &parser, + bool expectParsed, + CSSM_BOOL verbose, + bool extraIndent = false) { - if(value.Length != sizeof(CSSM_X509_EXTENSION)) { - printf("***malformed CSSM_FIELD (1)\n"); - return 1; + if(extraIndent) { + printf(" Extension : "); printOid(parser, &cssmExt->extnId); + printf(" Critical : %s\n", cssmExt->critical ? "TRUE" : "FALSE"); + } + else { + printf("Extension struct : "); printOid(parser, &cssmExt->extnId); + printf(" Critical : %s\n", cssmExt->critical ? "TRUE" : "FALSE"); } - CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)value.Data; - printf("Extension struct : "); printOid(parser, &cssmExt->extnId); - printf(" Critical : %s\n", cssmExt->critical ? "TRUE" : "FALSE"); switch(cssmExt->format) { case CSSM_X509_DATAFORMAT_ENCODED: if(expectParsed) { @@ -483,6 +527,28 @@ static int printExtensionCommon( return 1; } break; + case CSSM_X509_DATAFORMAT_PAIR: + /* both parsed and encoded forms present */ + if(!expectParsed) { + printf("Bad CSSM_X509_EXTENSION; expected FORMAT_ENCODED\n"); + return 1; + } + if((cssmExt->BERvalue.Data == NULL) || + (cssmExt->value.parsedValue == NULL)) { + printf("***Malformed CSSM_X509_EXTENSION (3)\n"); + return 1; + } + if(verbose) { + /* also print some of the encoded form */ + if(extraIndent) { + printf(" Unparsed data : "); + } + else { + printf(" Unparsed data : "); + } + printDataAsHex(&cssmExt->BERvalue, 8); + } + break; default: printf("***Unknown CSSM_X509_EXTENSION.format\n"); return 1; @@ -490,6 +556,21 @@ static int printExtensionCommon( return 0; } +static int printExtensionCommon( + const CSSM_DATA &value, + OidParser &parser, + CSSM_BOOL verbose, + bool expectParsed = true) +{ + if(value.Length != sizeof(CSSM_X509_EXTENSION)) { + printf("***malformed CSSM_FIELD (1)\n"); + return 1; + } + CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)value.Data; + return printCdsaExtensionCommon(cssmExt, parser, expectParsed, verbose); +} + + static void printKeyUsage( const CSSM_DATA &value) { @@ -497,7 +578,7 @@ static void printKeyUsage( CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)value.Data; usage = *((CE_KeyUsage *)cssmExt->value.parsedValue); - printf(" usage : "); + printf(" usage : "); if(usage & CE_KU_DigitalSignature) { printf("DigitalSignature "); } @@ -534,10 +615,9 @@ static void printBasicConstraints( { CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)value.Data; CE_BasicConstraints *bc = (CE_BasicConstraints *)cssmExt->value.parsedValue; - printf(" CA : %s\n", bc->cA ? "TRUE" : "FALSE"); + printf(" CA : %s\n", bc->cA ? "TRUE" : "FALSE"); if(bc->pathLenConstraintPresent) { - printf(" pathLenConstr : %u\n", - (unsigned)bc->pathLenConstraint); + printf(" pathLenConstr : %u\n", (unsigned)bc->pathLenConstraint); } } @@ -549,29 +629,39 @@ static void printExtKeyUsage( CE_ExtendedKeyUsage *eku = (CE_ExtendedKeyUsage *)cssmExt->value.parsedValue; unsigned oidDex; for(oidDex=0; oidDexnumPurposes; oidDex++) { - printf(" purpose %2d : ", oidDex); + printf(" purpose %2d : ", oidDex); printOid(parser, &eku->purposes[oidDex]); } } -static void printAuthorityKeyId( - const CSSM_DATA &value, - OidParser &parser) +static void printCssmAuthorityKeyId( + const CE_AuthorityKeyID *akid, + OidParser &parser) { - CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)value.Data; - CE_AuthorityKeyID *akid = (CE_AuthorityKeyID *)cssmExt->value.parsedValue; if(akid->keyIdentifierPresent) { - printf(" keyIdentifier : "); printDataAsHex(&akid->keyIdentifier, 8); + printf(" Auth KeyID : "); + printDataAsHex(&akid->keyIdentifier, +8); } if(akid->generalNamesPresent) { printGeneralNames(akid->generalNames, parser); } if(akid->serialNumberPresent) { - printf(" serialNumber : "); printDataAsHex(&akid->serialNumber, 8); + printf(" serialNumber : "); + printDataAsHex(&akid->serialNumber, 8); } } -static void printSubjectAltName( +static void printAuthorityKeyId( + const CSSM_DATA &value, + OidParser &parser) +{ + CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)value.Data; + CE_AuthorityKeyID *akid = (CE_AuthorityKeyID *)cssmExt->value.parsedValue; + printCssmAuthorityKeyId(akid, parser); +} + +static void printSubjectIssuerAltName( const CSSM_DATA &value, OidParser &parser) { @@ -580,6 +670,88 @@ static void printSubjectAltName( printGeneralNames(san, parser); } +static void printDistPointName( + const CE_DistributionPointName *dpn, + OidParser &parser) +{ + switch(dpn->nameType) { + case CE_CDNT_FullName: + printGeneralNames(dpn->fullName, parser); + break; + case CE_CDNT_NameRelativeToCrlIssuer: + printRdn(dpn->rdn, parser); + break; + default: + printf("***BOGUS CE_DistributionPointName.nameType\n"); + break; + } +} + +static void printDistPoint( + const CE_CRLDistributionPoint *dp, + OidParser &parser) +{ + if(dp->distPointName) { + printf(" Dist pt Name :\n"); + printDistPointName(dp->distPointName, parser); + } + printf(" reasonsPresent : %s\n", dp->reasonsPresent ? "TRUE" : "FALSE"); + if(dp->reasonsPresent) { + /* FIXME - parse */ + printf(" reasons : 0x%X\n", dp->reasons); + } + if(dp->crlIssuer) { + printf(" CRLIssuer :\n"); + printGeneralNames(dp->crlIssuer, parser); + } +} + +static void printDistributionPoints( + const CSSM_DATA &value, + OidParser &parser) +{ + CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)value.Data; + CE_CRLDistPointsSyntax *dps = (CE_CRLDistPointsSyntax *)cssmExt->value.parsedValue; + + for(unsigned dex=0; dexnumDistPoints; dex++) { + printf(" Dist pt %d :\n", dex); + printDistPoint(&dps->distPoints[dex], parser); + } +} + +static void printValueOrNotPresent( + CSSM_BOOL present, + CSSM_BOOL value) +{ + if(!present) { + printf("\n"); + } + else if(value) { + printf("TRUE\n"); + } + else { + printf("FALSE"); + } +} + +static void printIssuingDistributionPoint( + const CE_IssuingDistributionPoint *idp, + OidParser &parser) +{ + if(idp->distPointName) { + printf(" Dist pt :\n"); + printDistPointName(idp->distPointName, parser); + } + printf(" Only user certs : "); + printValueOrNotPresent(idp->onlyUserCertsPresent, idp->onlyUserCerts); + printf(" Only CA certs : "); + printValueOrNotPresent(idp->onlyCACertsPresent, idp->onlyCACerts); + printf(" Only some reason: "); + printValueOrNotPresent(idp->onlySomeReasonsPresent, idp->onlySomeReasons); + printf(" Indirectl CRL : "); + printValueOrNotPresent(idp->indirectCrlPresent, idp->indirectCrl); +} + static void printCertPolicies( const CSSM_DATA &value, OidParser &parser) @@ -588,19 +760,19 @@ static void printCertPolicies( CE_CertPolicies *cdsaObj = (CE_CertPolicies *)cssmExt->value.parsedValue; for(unsigned polDex=0; polDexnumPolicies; polDex++) { CE_PolicyInformation *cPolInfo = &cdsaObj->policies[polDex]; - printf(" Policy %2d : ID ", polDex); + printf(" Policy %2d : ID ", polDex); printOid(parser, &cPolInfo->certPolicyId); for(unsigned qualDex=0; qualDexnumPolicyQualifiers; qualDex++) { CE_PolicyQualifierInfo *cQualInfo = &cPolInfo->policyQualifiers[qualDex]; - printf(" Qual %2d : ID ", qualDex); + printf(" Qual %2d : ID ", qualDex); printOid(parser, &cQualInfo->policyQualifierId); if(cuCompareCssmData(&cQualInfo->policyQualifierId, &CSSMOID_QT_CPS)) { - printf(" CPS : "); + printf(" CPS : "); printString(&cQualInfo->qualifier); } else { - printf(" unparsed : "); + printf(" unparsed : "); printDataAsHex(&cQualInfo->qualifier, 8); } } @@ -614,7 +786,7 @@ static void printNetscapeCertType( CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)value.Data; certType = *((CE_NetscapeCertType *)cssmExt->value.parsedValue); - printf(" certType : "); + printf(" certType : "); if(certType & CE_NCT_SSL_Client) { printf("SSL_Client "); } @@ -653,8 +825,7 @@ void printCertField( if(cuCompareCssmData(thisOid, &CSSMOID_X509V1Version)) { if(verbose) { - printf("Version : %u\n", - (unsigned)DER_ToInt(thisData)); + printf("Version : %u\n", cuDER_ToInt(thisData)); } } else if(cuCompareCssmData(thisOid, &CSSMOID_X509V1SerialNumber)) { @@ -773,40 +944,43 @@ void printCertField( } else { printKeyHeader(cssmKey->KeyHeader); + if(verbose) { + printf(" Key Blob : "); + printDataAsHex(&cssmKey->KeyData, 8); + } } } else if(cuCompareCssmData(thisOid, &CSSMOID_X509V1Signature)) { - printf("Signature : %u bytes : ", - (unsigned)thisData->Length); + printf("Signature : %u bytes : ", (unsigned)thisData->Length); printDataAsHex(thisData, 8); } else if(cuCompareCssmData(thisOid, &CSSMOID_X509V3CertificateExtensionCStruct)) { - if(printExtensionCommon(*thisData, parser, false)) { + if(printExtensionCommon(*thisData, parser, verbose, false)) { return; } CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)thisData->Data; - printf(" Unparsed data : "); printDataAsHex(&cssmExt->BERvalue, 8); + printf(" Unparsed data : "); printDataAsHex(&cssmExt->BERvalue, 8); } else if(cuCompareCssmData(thisOid, &CSSMOID_KeyUsage)) { - if(printExtensionCommon(*thisData, parser)) { + if(printExtensionCommon(*thisData, parser, verbose)) { return; } printKeyUsage(*thisData); } else if(cuCompareCssmData(thisOid, &CSSMOID_BasicConstraints)) { - if(printExtensionCommon(*thisData, parser)) { + if(printExtensionCommon(*thisData, parser, verbose)) { return; } printBasicConstraints(*thisData); } else if(cuCompareCssmData(thisOid, &CSSMOID_ExtendedKeyUsage)) { - if(printExtensionCommon(*thisData, parser)) { + if(printExtensionCommon(*thisData, parser, verbose)) { return; } printExtKeyUsage(*thisData, parser); } else if(cuCompareCssmData(thisOid, &CSSMOID_SubjectKeyIdentifier)) { - if(printExtensionCommon(*thisData, parser)) { + if(printExtensionCommon(*thisData, parser, verbose)) { return; } CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)thisData->Data; @@ -815,33 +989,45 @@ void printCertField( printf("****Malformed extension (no parsedValue)\n"); } else { - printf(" Subject KeyID : "); printDataAsHex(cdata, 8); + printf(" Subject KeyID : "); printDataAsHex(cdata, 8); } } else if(cuCompareCssmData(thisOid, &CSSMOID_AuthorityKeyIdentifier)) { - if(printExtensionCommon(*thisData, parser)) { + if(printExtensionCommon(*thisData, parser, verbose)) { return; } printAuthorityKeyId(*thisData, parser); } else if(cuCompareCssmData(thisOid, &CSSMOID_SubjectAltName)) { - if(printExtensionCommon(*thisData, parser)) { + if(printExtensionCommon(*thisData, parser, verbose)) { + return; + } + printSubjectIssuerAltName(*thisData, parser); + } + else if(cuCompareCssmData(thisOid, &CSSMOID_IssuerAltName)) { + if(printExtensionCommon(*thisData, parser, verbose)) { return; } - printSubjectAltName(*thisData, parser); + printSubjectIssuerAltName(*thisData, parser); } else if(cuCompareCssmData(thisOid, &CSSMOID_CertificatePolicies)) { - if(printExtensionCommon(*thisData, parser)) { + if(printExtensionCommon(*thisData, parser, verbose)) { return; } printCertPolicies(*thisData, parser); } else if(cuCompareCssmData(thisOid, &CSSMOID_NetscapeCertType)) { - if(printExtensionCommon(*thisData, parser)) { + if(printExtensionCommon(*thisData, parser, verbose)) { return; } printNetscapeCertType(*thisData); } + else if(cuCompareCssmData(thisOid, &CSSMOID_CrlDistributionPoints)) { + if(printExtensionCommon(*thisData, parser, verbose)) { + return; + } + printDistributionPoints(*thisData, parser); + } else if(cuCompareCssmData(thisOid, &CSSMOID_X509V1IssuerName)) { if(verbose) { printf("Normalized Issuer : "); @@ -855,10 +1041,214 @@ void printCertField( } } else { - printf("other field: : "); printOid(parser, thisOid); + printf("Other field: : "); printOid(parser, thisOid); + } +} + +void printCrlExten( + const CSSM_X509_EXTENSION *exten, + CSSM_BOOL verbose, + OidParser &parser) +{ + const CSSM_OID *oid = &exten->extnId; + const void *thisData = exten->value.parsedValue; + + if(exten->format == CSSM_X509_DATAFORMAT_ENCODED) { + if(printCdsaExtensionCommon(exten, parser, false, verbose)) { + return; + } + printf(" Unparsed data : "); printDataAsHex(&exten->BERvalue, 8); + } + else if(exten->format != CSSM_X509_DATAFORMAT_PAIR) { + printf("***Badly formatted CSSM_X509_EXTENSION\n"); + return; + } + else if(cuCompareCssmData(oid, &CSSMOID_AuthorityKeyIdentifier)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose)) { + return; + } + printCssmAuthorityKeyId((CE_AuthorityKeyID *)thisData, parser); + } + else if(cuCompareCssmData(oid, &CSSMOID_IssuerAltName)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose)) { + return; + } + printGeneralNames((CE_GeneralNames *)thisData, parser); + } + else if(cuCompareCssmData(oid, &CSSMOID_CrlNumber)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose)) { + return; + } + printf(" CRL Number : %u\n", *((unsigned *)thisData)); + } + else if(cuCompareCssmData(oid, &CSSMOID_DeltaCrlIndicator)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose)) { + return; + } + printf(" Delta CRL Base : %u\n", *((unsigned *)thisData)); + } + else if(cuCompareCssmData(oid, &CSSMOID_IssuingDistributionPoint)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose)) { + return; + } + printIssuingDistributionPoint((CE_IssuingDistributionPoint *)thisData, + parser); + } + else { + /* should never happen - we're out of sync with the CL */ + printf("UNKNOWN EXTENSION : "); printOid(parser, oid); } } +void printCrlEntryExten( + const CSSM_X509_EXTENSION *exten, + CSSM_BOOL verbose, + OidParser &parser) +{ + const CSSM_OID *oid = &exten->extnId; + const void *thisData = exten->value.parsedValue; + + if(exten->format == CSSM_X509_DATAFORMAT_ENCODED) { + if(printCdsaExtensionCommon(exten, parser, false, verbose, true)) { + return; + } + printf(" Unparsed data: "); printDataAsHex(&exten->BERvalue, 8); + } + else if(exten->format != CSSM_X509_DATAFORMAT_PAIR) { + printf("***Badly formatted CSSM_X509_EXTENSION\n"); + return; + } + else if(cuCompareCssmData(oid, &CSSMOID_CrlReason)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose, true)) { + return; + } + CE_CrlReason *cr = (CE_CrlReason *)thisData; + char *reason = "UNKNOWN"; + switch(*cr) { + case CE_CR_Unspecified: + reason = "CE_CR_Unspecified"; break; + case CE_CR_KeyCompromise: + reason = "CE_CR_KeyCompromise"; break; + case CE_CR_CACompromise: + reason = "CE_CR_CACompromise"; break; + case CE_CR_AffiliationChanged: + reason = "CE_CR_AffiliationChanged"; break; + case CE_CR_Superseded: + reason = "CE_CR_Superseded"; break; + case CE_CR_CessationOfOperation: + reason = "CE_CR_CessationOfOperation"; break; + case CE_CR_CertificateHold: + reason = "CE_CR_CertificateHold"; break; + case CE_CR_RemoveFromCRL: + reason = "CE_CR_RemoveFromCRL"; break; + default: + break; + } + printf(" CRL Reason : %s\n", reason); + } + else if(cuCompareCssmData(oid, &CSSMOID_HoldInstructionCode)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose, true)) { + return; + } + printf(" Hold Instr : "); + printOid(parser, (CSSM_OID_PTR)thisData); + } + else if(cuCompareCssmData(oid, &CSSMOID_InvalidityDate)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose, true)) { + return; + } + printf(" Invalid Date : "); + printTimeStr((CSSM_DATA_PTR)thisData); + } + else if(cuCompareCssmData(oid, &CSSMOID_CertIssuer)) { + if(printCdsaExtensionCommon(exten, parser, true, verbose, true)) { + return; + } + printGeneralNames((CE_GeneralNames *)thisData, parser); + } + else { + /* should never happen - we're out of sync with the CL */ + printf("UNKNOWN EXTENSION : "); printOid(parser, oid); + } +} + +void printCrlFields( + const CSSM_X509_SIGNED_CRL *signedCrl, + CSSM_BOOL verbose, + OidParser &parser) +{ + unsigned i; + const CSSM_X509_TBS_CERTLIST *tbsCrl = &signedCrl->tbsCertList; + + if(tbsCrl->version.Data) { + printf("Version : %d\n", cuDER_ToInt(&tbsCrl->version)); + } + + printf("TBS Sig Algorithm : "); + const CSSM_X509_ALGORITHM_IDENTIFIER *algId = &tbsCrl->signature; + printSigAlg(algId, parser); + + printf("Issuer Name :\n"); + printName(&tbsCrl->issuer, parser); + + printf("This Update : "); + printTime(&tbsCrl->thisUpdate); + printf("Next Update : "); + if(tbsCrl->nextUpdate.time.Data) { + printTime(&tbsCrl->nextUpdate); + } + else { + printf("\n"); + } + + CSSM_X509_REVOKED_CERT_LIST_PTR certList = tbsCrl->revokedCertificates; + if(certList) { + if(verbose) { + printf("Num Revoked Certs : %d\n", + (int)certList->numberOfRevokedCertEntries); + for(i=0; inumberOfRevokedCertEntries; i++) { + CSSM_X509_REVOKED_CERT_ENTRY_PTR entry; + entry = &certList->revokedCertEntry[i]; + printf("Revoked Cert %d :\n", (int)i); + printf(" Serial number : "); + printDataAsHex(&entry->certificateSerialNumber, 0); + printf(" Revocation time : "); + printTime(&entry->revocationDate); + const CSSM_X509_EXTENSIONS *cssmExtens = &entry->extensions; + uint32 numExtens = cssmExtens->numberOfExtensions; + if(numExtens == 0) { + continue; + } + printf(" Num Extensions : %u\n", (unsigned)numExtens); + for(unsigned dex=0; dexextensions[dex], verbose, + parser); + } + } + } + else { + printf("Num Revoked Certs : %d (use verbose option to see)\n", + (int)certList->numberOfRevokedCertEntries); + } + } + + const CSSM_X509_EXTENSIONS *crlExtens = &tbsCrl->extensions; + if(crlExtens->numberOfExtensions) { + printf("Num CRL Extensions : %d\n", + (int)crlExtens->numberOfExtensions); + for(i=0; inumberOfExtensions; i++) { + printCrlExten(&crlExtens->extensions[i], verbose, parser); + } + } + + const CSSM_X509_SIGNATURE *sig = &signedCrl->signature; + if(sig->encrypted.Data) { + printf("Signature : %u bytes : ", (unsigned)sig->encrypted.Length); + printDataAsHex(&sig->encrypted, 8); + } +} + + /* connect to CSSM/CL lazily, once */ static CSSM_CL_HANDLE clHand = 0; @@ -876,7 +1266,8 @@ int printCert( if(clHand == 0) { clHand = cuClStartup(); if(clHand == 0) { - printf("***Error connecting to CSSM cert module; aborting cert display\n"); + printf("***Error connecting to CSSM cert module; aborting cert " + "display\n"); return 0; } } @@ -904,6 +1295,75 @@ int printCert( return 0; } +/* parse CRL */ +/* This one's easier, we just get one field - the whole parsed CRL */ +int printCrl( + const unsigned char *crlData, + unsigned crlLen, + CSSM_BOOL verbose) +{ + CSSM_DATA_PTR value; // mallocd by CL + uint32 numFields; + OidParser parser; + CSSM_DATA crl; + CSSM_HANDLE result; + + if(clHand == 0) { + clHand = cuClStartup(); + if(clHand == 0) { + printf("***Error connecting to CSSM cert module; aborting CRL" + "display\n"); + return 0; + } + } + crl.Data = (uint8 *)crlData; + crl.Length = crlLen; + + CSSM_RETURN crtn = CSSM_CL_CrlGetFirstFieldValue(clHand, + &crl, + &CSSMOID_X509V2CRLSignedCrlCStruct, + &result, + &numFields, + &value); + if(crtn) { + cuPrintError("CSSM_CL_CrlGetFirstFieldValue", crtn); + return crtn; + } + if(numFields != 1) { + printf("***CSSM_CL_CrlGetFirstFieldValue: numFields error\n"); + printf(" expected 1, got %d\n", (int)numFields); + return 1; + } + crtn = CSSM_CL_CrlAbortQuery(clHand, result); + if(crtn) { + cuPrintError("CSSM_CL_CertAbortQuery", crtn); + return crtn; + } + + if(value == NULL) { + printf("***CSSM_CL_CrlGetFirstFieldValue: value error (1)\n"); + return 1; + } + if((value->Data == NULL) || + (value->Length != sizeof(CSSM_X509_SIGNED_CRL))) { + printf("***CSSM_CL_CrlGetFirstFieldValue: value error (2)\n"); + return 1; + } + const CSSM_X509_SIGNED_CRL *signedCrl = + (const CSSM_X509_SIGNED_CRL *)value->Data; + printCrlFields(signedCrl, verbose, parser); + + crtn = CSSM_CL_FreeFieldValue(clHand, + &CSSMOID_X509V2CRLSignedCrlCStruct, + value); + if(crtn) { + cuPrintError("CSSM_CL_FreeFieldValue", crtn); + return crtn; + } + return 0; +} + + void printCertShutdown() { if(clHand != 0) { diff --git a/CdsaUtils/cuPrintCert.h b/CdsaUtils/cuPrintCert.h new file mode 100644 index 00000000..dfdf7001 --- /dev/null +++ b/CdsaUtils/cuPrintCert.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. + * Please obtain a copy of the License at http://www.apple.com/publicsource + * and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights + * and limitations under the License. + */ + +/* + * cuPrintCert.h - text-based cert/CRL parser using CL + */ + +#ifndef _PRINT_CERT_H_ +#define _PRINT_CERT_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* print one field */ +void printCertField( + const CSSM_FIELD &field, + OidParser &parser, + CSSM_BOOL verbose); + +/* parse cert & print it */ +int printCert( + const unsigned char *certData, + unsigned certLen, + CSSM_BOOL verbose); + +/* print parsed CRL */ +void printCrlFields( + const CSSM_X509_SIGNED_CRL *signedCrl, + OidParser &parser); + +/* parse CRL & print it */ +int printCrl( + const unsigned char *crlData, + unsigned crlLen, + CSSM_BOOL verbose); + + +void printCertShutdown(); + +#ifdef __cplusplus +} +#endif + +#endif /* _PRINT_CERT_H_ */ diff --git a/CdsaUtils/cuTimeStr.cpp b/CdsaUtils/cuTimeStr.cpp new file mode 100644 index 00000000..eb630bee --- /dev/null +++ b/CdsaUtils/cuTimeStr.cpp @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/* + * cuTimeStr.cpp - time string routines + */ +#include "cuTimeStr.h" +#include "cuCdsaUtils.h" +#include +#include +#include +#include +#include + +/* + * Given a string containing either a UTC-style or "generalized time" + * time string, convert to a struct tm (in GMT/UTC). Returns nonzero on + * error. + */ +int cuTimeStringToTm( + const char *str, + unsigned len, + struct tm *tmp) +{ + char szTemp[5]; + unsigned isUtc; + unsigned x; + unsigned i; + char *cp; + + if((str == NULL) || (len == 0) || (tmp == NULL)) { + return 1; + } + + /* tolerate NULL terminated or not */ + if(str[len - 1] == '\0') { + len--; + } + switch(len) { + case UTC_TIME_STRLEN: // 2-digit year, not Y2K compliant + isUtc = 1; + break; + case GENERALIZED_TIME_STRLEN: // 4-digit year + isUtc = 0; + break; + default: // unknown format + return 1; + } + + cp = (char *)str; + + /* check that all characters except last are digits */ + for(i=0; i<(len - 1); i++) { + if ( !(isdigit(cp[i])) ) { + return 1; + } + } + + /* check last character is a 'Z' */ + if(cp[len - 1] != 'Z' ) { + return 1; + } + + /* YEAR */ + szTemp[0] = *cp++; + szTemp[1] = *cp++; + if(!isUtc) { + /* two more digits */ + szTemp[2] = *cp++; + szTemp[3] = *cp++; + szTemp[4] = '\0'; + } + else { + szTemp[2] = '\0'; + } + x = atoi( szTemp ); + if(isUtc) { + /* + * 2-digit year. + * 0 <= year < 50 : assume century 21 + * 50 <= year < 70 : illegal per PKIX, though we tolerate + * 70 < year <= 99 : assume century 20 + */ + if(x < 50) { + x += 2000; + } + /* + else if(x < 70) { + return 1; + } + */ + else { + /* century 20 */ + x += 1900; + } + } + /* by definition - tm_year is year - 1900 */ + tmp->tm_year = x - 1900; + + /* MONTH */ + szTemp[0] = *cp++; + szTemp[1] = *cp++; + szTemp[2] = '\0'; + x = atoi( szTemp ); + /* in the string, months are from 1 to 12 */ + if((x > 12) || (x <= 0)) { + return 1; + } + /* in a tm, 0 to 11 */ + tmp->tm_mon = x - 1; + + /* DAY */ + szTemp[0] = *cp++; + szTemp[1] = *cp++; + szTemp[2] = '\0'; + x = atoi( szTemp ); + /* 1..31 in both formats */ + if((x > 31) || (x <= 0)) { + return 1; + } + tmp->tm_mday = x; + + /* HOUR */ + szTemp[0] = *cp++; + szTemp[1] = *cp++; + szTemp[2] = '\0'; + x = atoi( szTemp ); + if((x > 23) || (x < 0)) { + return 1; + } + tmp->tm_hour = x; + + /* MINUTE */ + szTemp[0] = *cp++; + szTemp[1] = *cp++; + szTemp[2] = '\0'; + x = atoi( szTemp ); + if((x > 59) || (x < 0)) { + return 1; + } + tmp->tm_min = x; + + /* SECOND */ + szTemp[0] = *cp++; + szTemp[1] = *cp++; + szTemp[2] = '\0'; + x = atoi( szTemp ); + if((x > 59) || (x < 0)) { + return 1; + } + tmp->tm_sec = x; + return 0; +} + +#define MAX_TIME_STR_LEN 30 + +static Mutex timeMutex; // protects time(), gmtime() + +char *cuTimeAtNowPlus(int secFromNow, + timeSpec spec) +{ + struct tm utc; + char *outStr; + time_t baseTime; + + timeMutex.lock(); + baseTime = time(NULL); + baseTime += (time_t)secFromNow; + utc = *gmtime(&baseTime); + timeMutex.unlock(); + + outStr = (char *)APP_MALLOC(MAX_TIME_STR_LEN); + + switch(spec) { + case TIME_UTC: + /* UTC - 2 year digits - code which parses this assumes that + * (2-digit) years between 0 and 49 are in century 21 */ + if(utc.tm_year >= 100) { + utc.tm_year -= 100; + } + sprintf(outStr, "%02d%02d%02d%02d%02d%02dZ", + utc.tm_year /* + 1900 */, utc.tm_mon + 1, + utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec); + break; + case TIME_GEN: + sprintf(outStr, "%04d%02d%02d%02d%02d%02dZ", + /* note year is relative to 1900, hopefully it'll + * have four valid digits! */ + utc.tm_year + 1900, utc.tm_mon + 1, + utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec); + break; + case TIME_CSSM: + sprintf(outStr, "%04d%02d%02d%02d%02d%02d", + /* note year is relative to 1900, hopefully it'll have + * four valid digits! */ + utc.tm_year + 1900, utc.tm_mon + 1, + utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec); + break; + } + return outStr; +} + +/* + * Convert a CSSM_X509_TIME, which can be in any of three forms (UTC, + * generalized, or CSSM_TIMESTRING) into a CSSM_TIMESTRING. Caller + * must free() the result. Returns NULL if x509time is badly formed. + */ +char *cuX509TimeToCssmTimestring( + const CSSM_X509_TIME *x509Time, + unsigned *rtnLen) // for caller's convenience +{ + int len = x509Time->time.Length; + const char *inStr = (char *)x509Time->time.Data; + // not NULL terminated! + char *rtn; + + *rtnLen = 0; + if((len == 0) || (inStr == NULL)) { + return NULL; + } + rtn = (char *)malloc(CSSM_TIME_STRLEN + 1); + rtn[0] = '\0'; + switch(len) { + case UTC_TIME_STRLEN: + { + /* infer century and prepend to output */ + char tmp[3]; + int year; + tmp[0] = inStr[0]; + tmp[1] = inStr[1]; + tmp[2] = '\0'; + year = atoi(tmp); + + /* + * 0 <= year < 50 : assume century 21 + * 50 <= year < 70 : illegal per PKIX + * 70 < year <= 99 : assume century 20 + */ + if(year < 50) { + /* century 21 */ + strcpy(rtn, "20"); + } + else if(year < 70) { + free(rtn); + return NULL; + } + else { + /* century 20 */ + strcpy(rtn, "19"); + } + memmove(rtn + 2, inStr, len - 1); // don't copy the Z + break; + } + case CSSM_TIME_STRLEN: + memmove(rtn, inStr, len); // trivial case + break; + case GENERALIZED_TIME_STRLEN: + memmove(rtn, inStr, len - 1); // don't copy the Z + break; + + default: + free(rtn); + return NULL; + } + rtn[CSSM_TIME_STRLEN] = '\0'; + *rtnLen = CSSM_TIME_STRLEN; + return rtn; +} + diff --git a/CdsaUtils/cuTimeStr.h b/CdsaUtils/cuTimeStr.h new file mode 100644 index 00000000..497a51d3 --- /dev/null +++ b/CdsaUtils/cuTimeStr.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. + * Please obtain a copy of the License at http://www.apple.com/publicsource + * and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights + * and limitations under the License. + */ + +/* + * cuTimeStr.h = Time string utilities. + */ + +#ifndef _TIME_STR_H_ +#define _TIME_STR_H_ + +#include +#include + +#define UTC_TIME_STRLEN 13 +#define CSSM_TIME_STRLEN 14 /* no trailing 'Z' */ +#define GENERALIZED_TIME_STRLEN 15 + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Given a string containing either a UTC-style or "generalized time" + * time string, convert to a struct tm (in GMT/UTC). Returns nonzero on + * error. + */ +int cuTimeStringToTm( + const char *str, + unsigned len, + struct tm *tmp); + +typedef enum { + TIME_UTC, + TIME_CSSM, + TIME_GEN +} timeSpec; + +/* + * Return an APP_MALLOCd time string, specified format and time relative + * to 'now' in seconds. + */ +char *cuTimeAtNowPlus( + int secFromNow, + timeSpec spec); + +/* + * Convert a CSSM_X509_TIME, which can be in any of three forms (UTC, + * generalized, or CSSM_TIMESTRING) into a CSSM_TIMESTRING. Caller + * must free() the result. Returns NULL if x509time is badly formed. + */ +char *cuX509TimeToCssmTimestring( + const CSSM_X509_TIME *x509Time, + unsigned *rtnLen); // for caller's convenience + +#ifdef __cplusplus +} +#endif + +#endif /* _TIME_STR_H_ */ \ No newline at end of file diff --git a/CertTool/CertTool.cpp b/CertTool/CertTool.cpp new file mode 100644 index 00000000..daba8178 --- /dev/null +++ b/CertTool/CertTool.cpp @@ -0,0 +1,1581 @@ +/* + * Copyright (c) 2002-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: CertTool.cpp + + Description: certificate manipulation tool + + Author: dmitch +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "CertUI.h" +#include +#include +#include + +/* + * Workaround flags. + */ + +/* SecKeychainGetCSPHandle implemented? */ +#define SEC_KEYCHAIN_GET_CSP 1 + +/* SecKeyCreatePair() implemented */ +#define SEC_KEY_CREATE_PAIR 1 + +/* munge Label attr if manually generating or importing keys */ +#define MUNGE_LABEL_ATTR 1 + +#define KC_DB_PATH "Library/Keychains" /* relative to home */ + +/* + * defaults for undocumented 'Z' option + */ +#define ZDEF_KEY_LABEL "testCert" +#define ZDEF_KEY_ALG CSSM_ALGID_RSA +#define ZDEF_KEY_SIZE 512 +#define ZDEF_KEY_USAGE (kKeyUseSigning | kKeyUseEncrypting) +#define ZDEF_SIG_ALG CSSM_ALGID_SHA1WithRSA +#define ZDEF_SIG_OID CSSMOID_SHA1WithRSA +#define ZDEF_COMMON_NAME "localhost" +#define ZDEF_ORG_NAME "Apple Computer - DEBUG ONLY" +#define ZDEF_COUNTRY "US" +#define ZDEF_STATE "Washington" +#define ZDEF_CHALLENGE "someChallenge" + + CSSM_BOOL verbose = CSSM_FALSE; + +static void usage(char **argv) +{ + printf("usage:\n"); + printf(" Create a keypair and cert: %s c [options]\n", argv[0]); + printf(" Create a CSR: %s r outFileName [options]\n", + argv[0]); + printf(" Verify a CSR: %s v infileName [options]\n", argv[0]); + printf(" Import a certificate: %s i inFileName [options]\n", argv[0]); + printf(" Display a certificate: %s d inFileName [options]\n", argv[0]); + printf(" Import a CRL: %s I inFileName [options]\n", argv[0]); + printf(" Display a CRL: %s D inFileName [options]\n", argv[0]); + printf(" Display certs and CRLs in keychain: %s y [options]\n", argv[0]); + printf("Options:\n"); + printf(" k=keychainName\n"); + printf(" c (create the keychain)\n"); + printf(" p=passphrase (specify passphrase at keychain creation)\n"); + printf(" o=outFileName (create cert command only)\n"); + printf(" v (verbose)\n"); + printf(" d (infile/outfile in DER format; default is PEM)\n"); + printf(" r=privateKeyFileName (optional; for Import Certificate only)\n"); + printf(" f=[18f] (private key format = PKCS1/PKCS8/FIPS186; default is PKCS1\n" + " (openssl) for RSA, openssl for DSA, PKCS8 for Diffie-Hellman\n"); + #if SEC_KEY_CREATE_PAIR + printf(" a (create key with default ACL)\n"); + #endif + printf(" h(elp)\n"); + exit(1); +} + +static void printError(const char *errDescription,const char *errLocation,OSStatus crtn) +{ + // Show error in text form. If verbose, show location and decimal and hex error values + int len=64+(errLocation?strlen(errLocation):0); + if (verbose) + { + char *buf=(char *)malloc(len); + if (errDescription) + fprintf(stderr,"%s : ",errDescription); + // sprintf(buf," %s : %d [0x%x] : ", errLocation,(int)crtn,(unsigned int)crtn); + // cuPrintError(buf, crtn); + cuPrintError(errLocation, crtn); + free(buf); + } + else + { + if (errDescription) + fprintf(stderr,"%s\n",errDescription); + else + if (errLocation) + fprintf(stderr,"%s\n",errLocation); + else + fprintf(stderr,"Error: %d [0x%x]\n",(int)crtn,(unsigned int)crtn); + } +} + +#if SEC_KEY_CREATE_PAIR +/* + * Generate a key pair using the SecKeyCreatePair. + */ +static OSStatus generateSecKeyPair( + SecKeychainRef kcRef, + CSSM_ALGORITHMS keyAlg, // e.g., CSSM_ALGID_RSA + uint32 keySizeInBits, + CU_KeyUsage keyUsage, // CUK_Signing, etc. + CSSM_BOOL verbose, + CSSM_KEY_PTR *pubKeyPtr, // RETURNED, owned by Sec layer + CSSM_KEY_PTR *privKeyPtr, // RETURNED, owned by Sec layer + SecKeyRef *pubSecKey, // caller must release + SecKeyRef *privSecKey) // caller must release +{ + OSStatus ortn; + CSSM_KEYUSE pubKeyUse = 0; + CSSM_KEYUSE privKeyUse = 0; + + if(keyUsage & kKeyUseSigning) { + pubKeyUse |= CSSM_KEYUSE_VERIFY; + privKeyUse |= CSSM_KEYUSE_SIGN; + } + if(keyUsage & kKeyUseEncrypting) { + pubKeyUse |= (CSSM_KEYUSE_ENCRYPT | CSSM_KEYUSE_WRAP); + privKeyUse |= (CSSM_KEYUSE_DECRYPT | CSSM_KEYUSE_UNWRAP); + } + ortn = SecKeyCreatePair(kcRef, + keyAlg, keySizeInBits, + 0, // contextHandle + pubKeyUse, + CSSM_KEYATTR_PERMANENT | CSSM_KEYATTR_EXTRACTABLE | + CSSM_KEYATTR_RETURN_REF, + privKeyUse, + CSSM_KEYATTR_SENSITIVE | CSSM_KEYATTR_RETURN_REF | + CSSM_KEYATTR_PERMANENT |CSSM_KEYATTR_EXTRACTABLE, + NULL, // FIXME - initialAccess + pubSecKey, + privSecKey); + if(ortn) { + printError("***Error creating key pair", + "SecKeyCreatePair", ortn); + cuPrintError("", ortn); + return ortn; + } + + /* extract CSSM keys for caller */ + ortn = SecKeyGetCSSMKey(*pubSecKey, const_cast(pubKeyPtr)); + if(ortn) { + printError("***Error extracting public key", + "SecKeyGetCSSMKey", ortn); + cuPrintError("", ortn); + } + else ortn = SecKeyGetCSSMKey(*privSecKey, const_cast(privKeyPtr)); + if(ortn) { + printError("***Error extracting private key", + "SecKeyGetCSSMKey", ortn); + cuPrintError("", ortn); + } + if(ortn) { + CFRelease(*pubSecKey); + *pubSecKey = NULL; + CFRelease(*privSecKey); + *privSecKey = NULL; + } + return ortn; +} +#endif + +/* + * Workaround to manually generate a key pair and munge its DB attributes + * to include the hash of the public key in the private key's Label attr. + */ +#if MUNGE_LABEL_ATTR + +/* + * Find private key by label, modify its Label attr to be the + * hash of the associated public key. + */ +static CSSM_RETURN setPubKeyHash( + CSSM_CSP_HANDLE cspHand, + CSSM_DL_DB_HANDLE dlDbHand, + const char *keyLabel) // look up by this +{ + CSSM_QUERY query; + CSSM_SELECTION_PREDICATE predicate; + CSSM_DB_UNIQUE_RECORD_PTR record = NULL; + CSSM_RETURN crtn; + CSSM_DATA labelData; + CSSM_HANDLE resultHand; + + labelData.Data = (uint8 *)keyLabel; + labelData.Length = strlen(keyLabel) + 1; // incl. NULL + query.RecordType = CSSM_DL_DB_RECORD_PRIVATE_KEY; + query.Conjunctive = CSSM_DB_NONE; + query.NumSelectionPredicates = 1; + predicate.DbOperator = CSSM_DB_EQUAL; + + predicate.Attribute.Info.AttributeNameFormat = + CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + predicate.Attribute.Info.Label.AttributeName = "Label"; + predicate.Attribute.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + /* hope this cast is OK */ + predicate.Attribute.Value = &labelData; + query.SelectionPredicate = &predicate; + + query.QueryLimits.TimeLimit = 0; // FIXME - meaningful? + query.QueryLimits.SizeLimit = 1; // FIXME - meaningful? + query.QueryFlags = 0; // CSSM_QUERY_RETURN_DATA; // FIXME - used? + + /* build Record attribute with one attr */ + CSSM_DB_RECORD_ATTRIBUTE_DATA recordAttrs; + CSSM_DB_ATTRIBUTE_DATA attr; + attr.Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr.Info.Label.AttributeName = "Label"; + attr.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + + recordAttrs.DataRecordType = CSSM_DL_DB_RECORD_PRIVATE_KEY; + recordAttrs.NumberOfAttributes = 1; + recordAttrs.AttributeData = &attr; + + CSSM_DATA recordData = {NULL, 0}; + crtn = CSSM_DL_DataGetFirst(dlDbHand, + &query, + &resultHand, + &recordAttrs, + &recordData, + &record); + /* abort only on success */ + if(crtn != CSSM_OK) { + printError("***setPubKeyHash: can't find private key","CSSM_DL_DataGetFirst",crtn); + return crtn; + } + + CSSM_KEY_PTR keyToDigest = (CSSM_KEY_PTR)recordData.Data; + CSSM_DATA_PTR keyDigest = NULL; + CSSM_CC_HANDLE ccHand; + crtn = CSSM_CSP_CreatePassThroughContext(cspHand, + keyToDigest, + &ccHand); + if(crtn) { + printError("***Error calculating public key hash. Aborting.", + "CSSM_CSP_CreatePassThroughContext", crtn); + return crtn; + } + crtn = CSSM_CSP_PassThrough(ccHand, + CSSM_APPLECSP_KEYDIGEST, + NULL, + (void **)&keyDigest); + if(crtn) { + printError("***Error calculating public key hash. Aborting.", + "CSSM_CSP_PassThrough(PUBKEYHASH)", crtn); + return -1; + } + CSSM_FreeKey(cspHand, NULL, keyToDigest, CSSM_FALSE); + CSSM_DeleteContext(ccHand); + + /* + * Replace Label attr data with hash. + * NOTE: the module which allocated this attribute data - a DL - + * was loaded and attached by the Sec layer, not by us. Thus + * we can't use the memory allocator functions *we* used when + * attaching to the CSPDL - we have to use the ones + * which the Sec layer registered with the DL. + */ + CSSM_API_MEMORY_FUNCS memFuncs; + crtn = CSSM_GetAPIMemoryFunctions(dlDbHand.DLHandle, &memFuncs); + if(crtn) { + printError("***Error ","CSSM_GetAPIMemoryFunctions(DLHandle)",crtn); + /* oh well, leak and continue */ + } + else { + memFuncs.free_func(attr.Value->Data, memFuncs.AllocRef); + memFuncs.free_func(attr.Value, memFuncs.AllocRef); + } + attr.Value = keyDigest; + + /* modify key attributes */ + crtn = CSSM_DL_DataModify(dlDbHand, + CSSM_DL_DB_RECORD_PRIVATE_KEY, + record, + &recordAttrs, + NULL, // DataToBeModified + CSSM_DB_MODIFY_ATTRIBUTE_REPLACE); + if(crtn) { + printError("***Error setting public key hash. Aborting.", + "CSSM_DL_DataModify(PUBKEYHASH)", crtn); + return crtn; + } + crtn = CSSM_DL_DataAbortQuery(dlDbHand, resultHand); + if(crtn) { + printError("***Error while stopping query", + "CSSM_DL_DataAbortQuery", crtn); + /* let's keep going in this case */ + } + crtn = CSSM_DL_FreeUniqueRecord(dlDbHand, record); + if(crtn) { + printError("***Error while freeing record", + "CSSM_DL_FreeUniqueRecord", crtn); + /* let's keep going in this case */ + crtn = CSSM_OK; + } + + /* free resources */ + cuAppFree(keyDigest->Data, NULL); + return CSSM_OK; +} +#endif /* MUNGE_LABEL_ATTR */ + +/* + * Generate a key pair using the CSPDL. + */ +static OSStatus generateKeyPair( + CSSM_CSP_HANDLE cspHand, + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_ALGORITHMS keyAlg, // e.g., CSSM_ALGID_RSA + uint32 keySizeInBits, + const char *keyLabel, // C string + CU_KeyUsage keyUsage, // CUK_Signing, etc. + CSSM_BOOL verbose, + CSSM_KEY_PTR *pubKeyPtr, // mallocd, created, RETURNED + CSSM_KEY_PTR *privKeyPtr) // mallocd, created, RETURNED +{ + CSSM_KEY_PTR pubKey = reinterpret_cast( + APP_MALLOC(sizeof(CSSM_KEY))); + CSSM_KEY_PTR privKey = reinterpret_cast( + APP_MALLOC(sizeof(CSSM_KEY))); + if((pubKey == NULL) || (privKey == NULL)) { + return memFullErr; + } + + CSSM_RETURN crtn; + CSSM_KEYUSE pubKeyUse = 0; + CSSM_KEYUSE privKeyUse = 0; + + if(keyUsage & kKeyUseSigning) { + pubKeyUse |= CSSM_KEYUSE_VERIFY; + privKeyUse |= CSSM_KEYUSE_SIGN; + } + if(keyUsage & kKeyUseEncrypting) { + pubKeyUse |= (CSSM_KEYUSE_ENCRYPT | CSSM_KEYUSE_WRAP); + privKeyUse |= (CSSM_KEYUSE_DECRYPT | CSSM_KEYUSE_UNWRAP); + } + + crtn = cuCspGenKeyPair(cspHand, + &dlDbHand, + keyAlg, + keyLabel, + strlen(keyLabel) + 1, + keySizeInBits, + pubKey, + pubKeyUse, + CSSM_KEYATTR_EXTRACTABLE | CSSM_KEYATTR_RETURN_REF, + privKey, + privKeyUse, + CSSM_KEYATTR_SENSITIVE | CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_PERMANENT | + CSSM_KEYATTR_EXTRACTABLE); + if(crtn) { + APP_FREE(pubKey); + APP_FREE(privKey); + return paramErr; + } + if(verbose) { + printf("...%u bit key pair generated.\n", + (unsigned)keySizeInBits); + } + + #if MUNGE_LABEL_ATTR + /* bind private key to cert by public key hash */ + crtn = setPubKeyHash(cspHand, + dlDbHand, + keyLabel); + if(crtn) { + printError("***Error setting public key hash. Continuing at peril.", + "setPubKeyHash", crtn); + } + #endif /* MUNGE_LABEL_ATTR */ + + *pubKeyPtr = pubKey; + *privKeyPtr = privKey; + return noErr; +} + +static OSStatus verifyCsr( + CSSM_CL_HANDLE clHand, + const char *fileName, + CSSM_BOOL pemFormat) +{ + unsigned char *csr = NULL; + unsigned csrLen; + CSSM_DATA csrData; + unsigned char *der = NULL; + unsigned derLen = 0; + + if(readFile(fileName, &csr, &csrLen)) { + printf("***Error reading CSR from file %s. Aborting.\n", + fileName); + return ioErr; + } + if(pemFormat) { + int rtn = pemDecode(csr, csrLen, &der, &derLen); + if(rtn) { + printf("***%s: Bad PEM formatting. Aborting.\n", fileName); + return ioErr; + } + csrData.Data = der; + csrData.Length = derLen; + } + else { + csrData.Data = csr; + csrData.Length = csrLen; + } + + CSSM_RETURN crtn = CSSM_CL_PassThrough(clHand, + 0, // CCHandle + CSSM_APPLEX509CL_VERIFY_CSR, + &csrData, + NULL); + if(crtn) { + printError("***Error verifying CSR","Verify CSR",crtn); + } + else { + printf("...CSR verified successfully.\n"); + } + if(der) { + free(der); + } + if(csr) { + free(csr); + } + return crtn; +} + +typedef enum { + CC_Cert, + CC_CRL +} CertOrCrl; + +static OSStatus displayCertCRL( + const char *fileName, + CSSM_BOOL pemFormat, + CertOrCrl certOrCrl, + CSSM_BOOL verbose) +{ + unsigned char *rawData = NULL; + unsigned rawDataSize; + unsigned char *derData = NULL; + unsigned derDataSize; + int rtn; + + rtn = readFile(fileName, &rawData, &rawDataSize); + if(rtn) { + printf("Error reading %s; aborting.\n", fileName); + return ioErr; + } + if(pemFormat && isPem(rawData, rawDataSize)) { + /* + * Here we cut the user some slack. See if the thing is actually + * PEM encoded and assume DER-encoded if it's not. + */ + rtn = pemDecode(rawData, rawDataSize, &derData, &derDataSize); + if(rtn) { + printf("***%s: Bad PEM formatting. Aborting.\n", fileName); + return ioErr; + } + rawData = derData; + rawDataSize = derDataSize; + } + if(certOrCrl == CC_Cert) { + printCert(rawData, rawDataSize, verbose); + } + else { + printCrl(rawData, rawDataSize, verbose); + } + if(derData != NULL) { + free(derData); + } + return noErr; +} + +static CSSM_RETURN importPrivateKey( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_CSP_HANDLE cspHand, + const char *privKeyFileName, + CSSM_ALGORITHMS keyAlg, + CSSM_BOOL pemFormat, // of the file + CSSM_KEYBLOB_FORMAT keyFormat) // of the key blob itself, NONE means use + // default +{ + unsigned char *derKey = NULL; + unsigned derKeyLen; + unsigned char *pemKey = NULL; + unsigned pemKeyLen; + CSSM_KEY wrappedKey; + CSSM_KEY unwrappedKey; + CSSM_ACCESS_CREDENTIALS creds; + CSSM_CC_HANDLE ccHand = 0; + CSSM_RETURN crtn; + CSSM_DATA labelData; + CSSM_KEYHEADER_PTR hdr = &wrappedKey.KeyHeader; + CSSM_DATA descData = {0, NULL}; + CSSM_CSP_HANDLE rawCspHand = 0; + const char *privKeyLabel = NULL; + + /* + * Validate specified format for clarity + */ + switch(keyAlg) { + case CSSM_ALGID_RSA: + switch(keyFormat) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: + keyFormat = CSSM_KEYBLOB_RAW_FORMAT_PKCS1; // default + break; + case CSSM_KEYBLOB_RAW_FORMAT_PKCS1: + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + break; + default: + printf("***RSA Private key must be in PKCS1 or PKCS8 format\n"); + return CSSMERR_CSSM_INTERNAL_ERROR; + } + privKeyLabel = "Imported RSA key"; + break; + case CSSM_ALGID_DSA: + switch(keyFormat) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: + keyFormat = CSSM_KEYBLOB_RAW_FORMAT_OPENSSL; // default + break; + case CSSM_KEYBLOB_RAW_FORMAT_FIPS186: + case CSSM_KEYBLOB_RAW_FORMAT_OPENSSL: + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + break; + default: + printf("***DSA Private key must be in openssl, FIPS186, " + "or PKCS8 format\n"); + return CSSMERR_CSSM_INTERNAL_ERROR; + } + privKeyLabel = "Imported DSA key"; + break; + case CSSM_ALGID_DH: + switch(keyFormat) { + case CSSM_KEYBLOB_RAW_FORMAT_NONE: + keyFormat = CSSM_KEYBLOB_RAW_FORMAT_PKCS8; // default + break; + case CSSM_KEYBLOB_RAW_FORMAT_PKCS8: + break; + default: + printf("***Diffie-Hellman Private key must be in PKCS8 format.\n"); + return CSSMERR_CSSM_INTERNAL_ERROR; + } + privKeyLabel = "Imported Diffie-Hellman key"; + break; + } + if(readFile(privKeyFileName, &pemKey, &pemKeyLen)) { + printf("***Error reading private key from file %s. Aborting.\n", + privKeyFileName); + return CSSMERR_CSSM_INTERNAL_ERROR; + } + /* subsequent errors to done: */ + if(pemFormat) { + int rtn = pemDecode(pemKey, pemKeyLen, &derKey, &derKeyLen); + if(rtn) { + printf("***%s: Bad PEM formatting. Aborting.\n", privKeyFileName); + crtn = CSSMERR_CSP_INVALID_KEY; + goto done; + } + } + else { + derKey = pemKey; + derKeyLen = pemKeyLen; + } + + /* importing a raw key into the CSPDL involves a NULL unwrap */ + memset(&unwrappedKey, 0, sizeof(CSSM_KEY)); + memset(&wrappedKey, 0, sizeof(CSSM_KEY)); + + /* set up the imported key to look like a CSSM_KEY */ + hdr->HeaderVersion = CSSM_KEYHEADER_VERSION; + hdr->BlobType = CSSM_KEYBLOB_RAW; + hdr->AlgorithmId = keyAlg; + hdr->KeyClass = CSSM_KEYCLASS_PRIVATE_KEY; + hdr->KeyAttr = CSSM_KEYATTR_EXTRACTABLE; + hdr->KeyUsage = CSSM_KEYUSE_ANY; + hdr->Format = keyFormat; + wrappedKey.KeyData.Data = derKey; + wrappedKey.KeyData.Length = derKeyLen; + + /* get key size in bits from raw CSP */ + rawCspHand = cuCspStartup(CSSM_TRUE); + if(rawCspHand == 0) { + printf("***Error attaching to CSP. Aborting.\n"); + crtn = CSSMERR_CSSM_INTERNAL_ERROR; + goto done; + } + CSSM_KEY_SIZE keySize; + crtn = CSSM_QueryKeySizeInBits(rawCspHand, NULL, &wrappedKey, &keySize); + if(crtn) { + printError("***Error finding size of key","CSSM_QueryKeySizeInBits",crtn); + goto done; + } + hdr->LogicalKeySizeInBits = keySize.LogicalKeySizeInBits; + + memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS)); + crtn = CSSM_CSP_CreateSymmetricContext(cspHand, + CSSM_ALGID_NONE, // unwrapAlg + CSSM_ALGMODE_NONE, // unwrapMode + &creds, + NULL, // unwrappingKey + NULL, // initVector + CSSM_PADDING_NONE, // unwrapPad + 0, // Params + &ccHand); + if(crtn) { + printError("***Error creating context","CSSM_CSP_CreateSymmetricContext",crtn); + goto done; + } + + /* add DL/DB to context */ + CSSM_CONTEXT_ATTRIBUTE newAttr; + newAttr.AttributeType = CSSM_ATTRIBUTE_DL_DB_HANDLE; + newAttr.AttributeLength = sizeof(CSSM_DL_DB_HANDLE); + newAttr.Attribute.Data = (CSSM_DATA_PTR)&dlDbHand; + crtn = CSSM_UpdateContextAttributes(ccHand, 1, &newAttr); + if(crtn) { + printError("***Error updating context attributes","CSSM_UpdateContextAttributes",crtn); + goto done; + } + + /* do the NULL unwrap */ + labelData.Data = (uint8 *)privKeyLabel; + labelData.Length = strlen(privKeyLabel) + 1; + crtn = CSSM_UnwrapKey(ccHand, + NULL, // PublicKey + &wrappedKey, + CSSM_KEYUSE_ANY, + CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_PERMANENT | CSSM_KEYATTR_SENSITIVE | + CSSM_KEYATTR_EXTRACTABLE, + &labelData, + NULL, // CredAndAclEntry + &unwrappedKey, + &descData); // required + if(crtn != CSSM_OK) { + cuPrintError("CSSM_UnwrapKey", crtn); + goto done; + } + + /* one more thing: bind this private key to its public key */ + crtn = setPubKeyHash(cspHand, dlDbHand, privKeyLabel); + + /* We don't need the unwrapped key any more */ + CSSM_FreeKey(cspHand, + NULL, // access cred + &unwrappedKey, + CSSM_FALSE); // delete + +done: + if(ccHand) { + CSSM_DeleteContext(ccHand); + } + if(derKey) { + free(derKey); + } + if(pemFormat && pemKey) { + free(pemKey); + } + if(rawCspHand) { + CSSM_ModuleDetach(rawCspHand); + } + return crtn; +} + +static OSStatus importCert( + SecKeychainRef kcRef, + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_CSP_HANDLE cspHand, + CSSM_CL_HANDLE clHand, + const char *fileName, + const char *privKeyFileName, // optional for importing priv key + CSSM_BOOL pemFormat, // format of files + CSSM_KEYBLOB_FORMAT privKeyFormat) // optional format of priv key +{ + unsigned char *cert = NULL; + unsigned certLen; + CSSM_DATA certData; + unsigned char *der = NULL; + unsigned derLen = 0; + + if(readFile(fileName, &cert, &certLen)) { + printf("***Error reading certificate from file %s. Aborting.\n", + fileName); + return ioErr; + } + if(pemFormat) { + int rtn = pemDecode(cert, certLen, &der, &derLen); + if(rtn) { + printf("***%s: Bad PEM formatting. Aborting.\n", fileName); + return ioErr; + } + certData.Data = der; + certData.Length = derLen; + } + else { + certData.Data = cert; + certData.Length = certLen; + } + + SecCertificateRef certRef; + OSStatus ortn = SecCertificateCreateFromData( + &certData, + CSSM_CERT_X_509v3, + CSSM_CERT_ENCODING_DER, + &certRef); + if(ortn) { + printError("***Error creating certificate","SecCertificateCreateFromData",ortn); + cuPrintError("", ortn); + return ortn; + } + ortn = SecCertificateAddToKeychain(certRef, kcRef); + if(ortn) { + printError("***Error adding certificate to keychain","SecCertificateAddToKeychain",ortn); + return ortn; + } + + if(privKeyFileName) { + /* Importing private key requires algorithm, from cert */ + CSSM_RETURN crtn; + CSSM_KEY_PTR pubKey; + crtn = CSSM_CL_CertGetKeyInfo(clHand, &certData, &pubKey); + if(crtn) { + printError("***Error obtaining public key from cert. Aborting","CSSM_CL_CertGetKeyInfo",crtn); + return crtn; + } + crtn = importPrivateKey(dlDbHand, cspHand, privKeyFileName, + pubKey->KeyHeader.AlgorithmId, pemFormat, privKeyFormat); + if(crtn) { + printError("***Error importing private key. Aborting","importPrivateKey",crtn); + return crtn; + } + /* this was mallocd by the CL */ + cuAppFree(pubKey->KeyData.Data, NULL); + cuAppFree(pubKey, NULL); + } + printf("...certificate successfully imported.\n"); + if(der) { + free(der); + } + if(cert) { + free(cert); + } + return noErr; +} + +static OSStatus importCRL( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_CL_HANDLE clHand, + const char *fileName, + CSSM_BOOL pemFormat) +{ + unsigned char *crl = NULL; + unsigned crlLen; + CSSM_DATA crlData; + unsigned char *der = NULL; + unsigned derLen = 0; + + if(readFile(fileName, &crl, &crlLen)) { + printf("***Error reading CRL from file %s. Aborting.\n", + fileName); + return ioErr; + } + if(pemFormat) { + int rtn = pemDecode(crl, crlLen, &der, &derLen); + if(rtn) { + printf("***%s: Bad PEM formatting. Aborting.\n", fileName); + return ioErr; + } + crlData.Data = der; + crlData.Length = derLen; + } + else { + crlData.Data = crl; + crlData.Length = crlLen; + } + CSSM_RETURN crtn = cuAddCrlToDb(dlDbHand, clHand, &crlData, NULL); + if(crtn) { + printError("***Error adding CRL to keychain. Aborting","cuAddCrlToDb",crtn); + } + else { + printf("...CRL successfully imported.\n"); + } + if(der) { + free(der); + } + if(crl) { + free(crl); + } + return noErr; +} + +static OSStatus createCertCsr( + CSSM_BOOL createCsr, // true: CSR, false: Cert + CSSM_TP_HANDLE tpHand, // eventually, a SecKeychainRef + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + CSSM_KEY_PTR subjPubKey, + CSSM_KEY_PTR signerPrivKey, + CSSM_ALGORITHMS sigAlg, + const CSSM_OID *sigOid, + CU_KeyUsage keyUsage, // kKeyUseSigning, etc. + /* + * Issuer's RDN is obtained from the issuer cert, if present, or is + * assumed to be the same as the subject name (i.e., we're creating + * a self-signed root cert). + */ + const CSSM_DATA *issuerCert, + CSSM_BOOL useAllDefaults, + CSSM_DATA_PTR certData) // cert or CSR: mallocd and RETURNED +{ + CE_DataAndType exts[2]; + CE_DataAndType *extp = exts; + unsigned numExts; + + CSSM_DATA refId; // mallocd by CSSM_TP_SubmitCredRequest + CSSM_APPLE_TP_CERT_REQUEST certReq; + CSSM_TP_REQUEST_SET reqSet; + sint32 estTime; + CSSM_BOOL confirmRequired; + CSSM_TP_RESULT_SET_PTR resultSet; + CSSM_ENCODED_CERT *encCert; + CSSM_APPLE_TP_NAME_OID subjectNames[MAX_NAMES]; + uint32 numNames; + CSSM_TP_CALLERAUTH_CONTEXT CallerAuthContext; + CSSM_FIELD policyId; + + /* Note a lot of the CSSM_APPLE_TP_CERT_REQUEST fields are not + * used for the createCsr option, but we'll fill in as much as is practical + * for either case. + */ + if(issuerCert != NULL) { + printf("createCertCsr: issuerCert not implemented\n"); + return unimpErr; + } + + numExts = 0; + + char challengeBuf[400]; + if(createCsr) { + if(useAllDefaults) { + strcpy(challengeBuf, ZDEF_CHALLENGE); + } + else { + while(1) { + getStringWithPrompt("Enter challenge string: ", + challengeBuf, sizeof(challengeBuf)); + if(challengeBuf[0] != '\0') { + break; + } + } + } + certReq.challengeString = challengeBuf; + } + else { + /* creating cert */ + certReq.challengeString = NULL; + + /* KeyUsage extension */ + extp->type = DT_KeyUsage; + extp->critical = CSSM_FALSE; + extp->extension.keyUsage = 0; + if(keyUsage & kKeyUseSigning) { + extp->extension.keyUsage |= + (CE_KU_DigitalSignature | CE_KU_KeyCertSign); + } + if(keyUsage & kKeyUseEncrypting) { + extp->extension.keyUsage |= + (CE_KU_KeyEncipherment | CE_KU_DataEncipherment); + } + extp++; + numExts++; + + /* BasicConstraints */ + extp->type = DT_BasicConstraints; + extp->critical = CSSM_TRUE; + extp->extension.basicConstraints.cA = CSSM_TRUE; + extp->extension.basicConstraints.pathLenConstraintPresent = CSSM_FALSE; + extp++; + numExts++; + } + + /* name array, get from user. */ + if(useAllDefaults) { + subjectNames[0].string = ZDEF_COMMON_NAME; + subjectNames[0].oid = &CSSMOID_CommonName; + subjectNames[1].string = ZDEF_ORG_NAME; + subjectNames[1].oid = &CSSMOID_OrganizationName; + subjectNames[2].string = ZDEF_COUNTRY; + subjectNames[2].oid = &CSSMOID_CountryName; + subjectNames[3].string = ZDEF_STATE; + subjectNames[3].oid = &CSSMOID_StateProvinceName; + numNames = 4; + } + else { + getNameOids(subjectNames, &numNames); + } + + /* certReq */ + certReq.cspHand = cspHand; + certReq.clHand = clHand; + certReq.serialNumber = 0x12345678; // TBD - random? From user? + certReq.numSubjectNames = numNames; + certReq.subjectNames = subjectNames; + + /* TBD - if we're passed in a signing cert, certReq.issuerNameX509 will + * be obtained from that cert. For now we specify "self-signed" cert + * by not providing an issuer name at all. */ + certReq.numIssuerNames = 0; // root for now + certReq.issuerNames = NULL; + certReq.issuerNameX509 = NULL; + certReq.certPublicKey = subjPubKey; + certReq.issuerPrivateKey = signerPrivKey; + certReq.signatureAlg = sigAlg; + certReq.signatureOid = *sigOid; + certReq.notBefore = 0; // TBD - from user + certReq.notAfter = 60 * 60 * 24 * 30; // seconds from now + certReq.numExtensions = numExts; + certReq.extensions = exts; + + reqSet.NumberOfRequests = 1; + reqSet.Requests = &certReq; + + /* a CSSM_TP_CALLERAUTH_CONTEXT to specify an OID */ + memset(&CallerAuthContext, 0, sizeof(CSSM_TP_CALLERAUTH_CONTEXT)); + memset(&policyId, 0, sizeof(CSSM_FIELD)); + if(createCsr) { + policyId.FieldOid = CSSMOID_APPLE_TP_CSR_GEN; + } + else { + policyId.FieldOid = CSSMOID_APPLE_TP_LOCAL_CERT_GEN; + } + CallerAuthContext.Policy.NumberOfPolicyIds = 1; + CallerAuthContext.Policy.PolicyIds = &policyId; + + #if SEC_KEY_CREATE_PAIR + /* from SUJag */ + CssmClient::AclFactory factory; + CallerAuthContext.CallerCredentials = + const_cast(factory.promptCred()); + #endif /* SEC_KEY_CREATE_PAIR */ + + CSSM_RETURN crtn = CSSM_TP_SubmitCredRequest(tpHand, + NULL, // PreferredAuthority + CSSM_TP_AUTHORITY_REQUEST_CERTISSUE, + &reqSet, + &CallerAuthContext, + &estTime, + &refId); + + /* before proceeding, free resources allocated thus far */ + if(!useAllDefaults) { + freeNameOids(subjectNames, numNames); + } + + if(crtn) { + printError("***Error submitting credential request","CSSM_TP_SubmitCredRequest",crtn); + return crtn; + } + crtn = CSSM_TP_RetrieveCredResult(tpHand, + &refId, + NULL, // CallerAuthCredentials + &estTime, + &confirmRequired, + &resultSet); + if(crtn) { + printError("***Error retreiving credential request","CSSM_TP_RetrieveCredResult",crtn); + return crtn; + } + if(resultSet == NULL) { + printf("***CSSM_TP_RetrieveCredResult returned NULL result set.\n"); + return ioErr; + } + encCert = (CSSM_ENCODED_CERT *)resultSet->Results; + *certData = encCert->CertBlob; + + /* free resources allocated by TP */ + APP_FREE(refId.Data); + APP_FREE(encCert); + APP_FREE(resultSet); + return noErr; +} + +/* dump all certs & CRLs in a DL/DB */ +static OSStatus dumpCrlsCerts( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_CL_HANDLE clHand, + CSSM_BOOL verbose) +{ + CSSM_RETURN crtn; + unsigned numItems; + + crtn = cuDumpCrlsCerts(dlDbHand, clHand, CSSM_TRUE, numItems, verbose); + if(crtn && (crtn != CSSMERR_DL_INVALID_RECORDTYPE)) { + /* invalid record type just means "this hasn't been set up + * for certs yet". */ + return noErr; + } + printf("...%u certificates found\n", numItems); + crtn = cuDumpCrlsCerts(dlDbHand, clHand, CSSM_FALSE, numItems, verbose); + if(crtn && (crtn != CSSMERR_DL_INVALID_RECORDTYPE)) { + /* invalid record type just means "this hasn't been set up + * for CRLs yet". */ + return noErr; + } + printf("...%u CRLs found\n", numItems); + return noErr; +} + + +typedef enum { + CO_Nop, + CO_CreateCert, + CO_CreateCSR, + CO_VerifyCSR, + CO_ImportCert, + CO_DisplayCert, + CO_ImportCRL, + CO_DisplayCRL, + CO_DumpDb // display certs & CRLs from a DB +} CertOp; + +int realmain (int argc, char **argv) +{ + SecKeychainRef kcRef = nil; + char kcPath[MAXPATHLEN + 1]; + UInt32 kcPathLen = MAXPATHLEN + 1; + CSSM_BOOL createKc = CSSM_FALSE; + OSStatus ortn; + CSSM_DL_DB_HANDLE dlDbHand = {0, 0}; + CSSM_CSP_HANDLE cspHand = 0; + CSSM_TP_HANDLE tpHand = 0; + CSSM_CL_HANDLE clHand = 0; + CSSM_KEY_PTR pubKey; + CSSM_KEY_PTR privKey; + int arg; + char *argp; + CSSM_ALGORITHMS keyAlg; + CSSM_ALGORITHMS sigAlg; + const CSSM_OID *sigOid; + CSSM_DATA certData = {0, NULL}; + CSSM_RETURN crtn; + CU_KeyUsage keyUsage = 0; + bool isRoot; + CSSM_DATA keyLabel; + CSSM_BOOL createCsr = CSSM_FALSE; // else create cert + int optArgs = 0; + UInt32 pwdLen = 0; + Boolean promptUser = true; + char *allocdPassPhrase = NULL; + OSStatus ourRtn = noErr; + + /* command line arguments */ + char *fileName = NULL; + CSSM_BOOL pemFormat = CSSM_TRUE; + CertOp op = CO_Nop; + uint32 keySizeInBits; + char *kcName = NULL; + CSSM_BOOL useAllDefaults = CSSM_FALSE; // undoc'd cmd option + char *passPhrase = NULL; + const char *privKeyFileName = NULL; // optional openssl-style private key + CSSM_KEYBLOB_FORMAT privKeyFormat = CSSM_KEYBLOB_RAW_FORMAT_NONE; + #if SEC_KEY_CREATE_PAIR + SecKeyRef pubSecKey = NULL; + SecKeyRef privSecKey = NULL; + #endif + CSSM_BOOL useSecKey = CSSM_FALSE; // w/default ACL + + if(argc < 2) { + usage(argv); + } + switch(argv[1][0]) { + case 'c': + op = CO_CreateCert; + optArgs = 2; + break; + case 'r': + if(argc < 3) { + usage(argv); + } + op = CO_CreateCSR; + createCsr = CSSM_TRUE; + fileName = argv[2]; + optArgs = 3; + break; + case 'v': + if(argc < 3) { + usage(argv); + } + op = CO_VerifyCSR; + fileName = argv[2]; + optArgs = 3; + break; + case 'i': + if(argc < 3) { + usage(argv); + } + optArgs = 3; + op = CO_ImportCert; + fileName = argv[2]; + break; + case 'd': + if(argc < 3) { + usage(argv); + } + op = CO_DisplayCert; + fileName = argv[2]; + optArgs = 3; + break; + case 'I': + if(argc < 3) { + usage(argv); + } + optArgs = 3; + op = CO_ImportCRL; + fileName = argv[2]; + break; + case 'D': + if(argc < 3) { + usage(argv); + } + op = CO_DisplayCRL; + fileName = argv[2]; + optArgs = 3; + break; + case 'y': + op = CO_DumpDb; + optArgs = 2; + break; + default: + usage(argv); + } + for(arg=optArgs; arg - - - - - CertTool.html - - - -
-

-CertTool

- -
-

-Last Update 5/20/02

- -

-Table Of Contents

-1.
Introduction -
2. Generating a Self-Signed -Certificate -
3. Generating -a Certificate Signing Request (CSR) -
4. Verifying a CSR -
5. Importing -a Certificate from a Certificate Authority -
6. Displaying a Certificate -
7. Certificate Authorities -and CSRs -
  -

-1. Introduction

- -
CertTool is a UNIX command-line program which is used to create -key pairs, certificates, and certificate signing requests; to import externally -generated certificates into a Keychain, and to display the contents of -certificates. Currently. the primary use of CertTool is to perform the -certificate-related administration required to configure an SSL server -based on Mac OS X's SecureTransport library. Each supported CertTool operation -is described below in detail. -

The reader of this document, and the user of CertTool, is assumed to -be familiar with the following: -

    -
  • -General principles of public key cryptography
  • - -
  • -The concepts of certificates and trust
  • - -
  • -General operation of the Secure Socket Layer (SSL) protocol
  • - -
  • -General operation of the Mac OS X Keychain
  • - -
  • -The Mac OS X SecureTransport library
  • -
-No programming knowledge is assumed or required. An excellent primer on -the topics of public key cryptography, certificates, and SSL can be found -at http://httpd.apache.org/docs-2.0/ssl/ssl_intro.html. -

Note: in all examples of usage of the command line tool which follow, -the user's input is shown in bold. Running CertTool with no command-line -arguments results in usage info being displayed. -
 

- -

-2. Generating a -Self-Signed Certificate

- -
This command generates a key pair and a self-signed (root) -certificate and places them in a keychain. The root cert is signed by the -private key generated during this command. The cert generated by this command -is totally untrustworth and cannot be used in the "real world"; the primary -use of this command is to facilitate early development of SSL server applications -based on SecureTransport. In particular, "real world" SSL clients (e.g., -web browsers) will complain to varying degrees when they attempt to connect -to an SSL server which presents a cert which is generated by this command. -Some broswers, after a fair amount of handholding, will allow you to conditionally -"trust" this cert. -

The format of this command is -

# CertTool c [options] -

The available options are: -

k=keyChainName -
Where "KeyChainName" is the name of the keychain into which -keys and the cert will be added. If no keychain is specified, keys and -certs are added to the default keychain. The specified keychain must exist -unless you specify the 'c' option.
-c -
Specifies that the designated key is to be created.
-
-This an interactive command; you will be prompted for a number of different -items which are used to generate the keypair and the cert. A sample sesion -follows. -
  -
# CertTool k=certkc -
Enter key and certificate label: testCert -

Please specify parameters for the key pair you will generate. -

  r  RSA -
  d  DSA -
  f  FEE -

Select key algorithm by letter: r -

Valid key sizes for RSA are 512..2048; default is 512 -
Enter key size in bits or CR for default: 512 -

You have selected algorithm RSA, key size 512 bits. -
OK (y/anything)? y -
Enter cert/key usage (s=signing, b=signing AND encrypting): b -
...Generating key pair... -

<<Note: you will be prompted for the Keychain's passphrase -by the Keychain system at this point if the specified keychain is not open.>> -

Please specify the algorithm with which your certificate will be signed. -

  5  RSA with MD5 -
  s  RSA with SHA1 -

Select signature algorithm by letter: s -

You have selected algorithm RSA with SHA1. -
OK (y/anything)? y -
...creating certificate... -

You will now specify the various components of the certificate's -
Relative Distinguished Name (RDN). An RDN has a number of -
components, all of which are optional, but at least one of -
which must be present. -

Note that if you are creating a certificate for use in an -
SSL/TLS server, the Common Name component of the RDN must match -
exactly the host name of the server. This must not be an IP -
address, but the actual domain name, e.g. www.apple.com. -

Entering a CR for a given RDN component results in no value for -
that component. -

Common Name       (e.g, www.apple.com) -: 10.0.61.5 -
Country                  -(e.g, US) : -
Organization            -(e.g, Apple Computer, Inc.) : Apple -
Organization Unit     (e.g, Apple Data Security) -: -
State/Province          -(e.g., California) : California -

You have specified: -
  Common Name       : 10.0.61.5 -
  Organization            -: Apple -
  State/Province         -: California -
Is this OK (y/anything)? y -
..cert stored in Keychain. -
#

-The "Common Name" portion of the RDN - in the above case, "10.0.61.5" - -MUST match the host name of the machine you'll running sslServer on. (In -this case the test machine doesn't have an actual hostname; it's DHCP'd -behind a firewall which is why "10.0.61.5" was specified for Common Name.) -This is part of SSL's certificate verification; it prevents an attack using -DNS spoofing. -

A brief note about cert/key usage: the normal configuration of SecureTransport -is that the server cert specified in SSLSetCertificate() is capable of -both signing and encryption. If this cert is only capable of signing, then -you must create a second keychain ontaining a cert which is capable of -encryption, and pass that to SSLSetEncryptionCertificate(). -
  -
 

- -

-3. Generating -a Certificate Signing Request (CSR)

- -
A CSR is the standard means by which an administrator of a -web server provides information to a Certificate Authority (CA) in order -to obtain a valid certificate which is signed by the CA. This type of cert -is used in the real world; certs signed by CAs such as Verisign or Thawte -are recognized by all web browsers when performing SSL transactions. -

The general procedure for obtaining a "real" cert is: -
  -

    -
  • -Generate a key pair
  • - -
  • -Generate a CSR
  • - -
  • -Provide the CSR and some other information and/or documentation to the -CA
  • - -
  • -CA sends you a certificate which is signed by the CA.
  • - -
  • -You import that certificate, obtained from the CA, into your keychain. -The items in that keychain can now be used in SecureTranspoert's SSLSetCertificate() -call.
  • -
-This command performs the first two steps in the above procedure. See Section -5 for information on importing the resulting certificate into your -keychain. -

The format of this command is -

# CertTool r outFileName [options] -

The resulting CSR will be written to "outFileName". -

The available options are: -

k=keyChainName -

Where "KeyChainName" is the name of the keychain into which -keys and the cert will be added. If no keychain is specified, keys and -certs are added to the default keychain. The specified keychain must exist -unless you specify the 'c' option.
-d -
The 'd' option tells CertTool to create the CSR in DER-encoded -format. The default is PEM-encoded, which is what most CAs expect. PEM -encoded data consists of printable ASCII text which can, for example, be -pasted into an email message. DER-encoded data is nonprintable binary data.
-c -
Specifies that the designated key is to be created.
-This an interactive command; you will be prompted for a number of different -items which are used to generate the keypair and the CSR. The prompts given, -and the format of the data you must supply, are identical to the data shown -in the sample session in Section 2. -

See Section 7 for more information on using CSRs and about CAs. -
  -
 

- -

-4. Verifying a CSR

- -
A CSR contains, among other things, the public key which was -generated in Section -3. The CSR is signed with the associated private key. Thus the inteegrity -of a CSR can be verified by extracting its public key and verifying the -signature of the CSR. This command performs this integrity check. -

The format of this command is -

# CertTool v inFileName [options] -

The resulting CSR will be written to "outFileName". -

The only available option is the 'd' flag, which as described in Section -3, indiciates that the CSR is in DER format rather than the default -PEM format. -

A typical (successful) run of this command is like so: -

# CertTool v myCsr.pem -
...CSR verified successfully. -

A large number of things can go wrong of the verification fails; suffice -it to say that if you see anything other than the above success message, -you have a bad or corrupted CSR. -
  -

 
-
- -

-5. Importing -a Certificate from a Certificate Authority

- -
Once you have negotiated with your CA, and provided them with -the CSR generated in Section -3 as well as any other information, documentation, and payment thay -require, the CA will provide you with a certificate. Use this command to -add that certificate to the keychain containing the keypair you generated -in Section 3. -You currently also have to specify the string you provided as "key and -certificate label" when executing this command. <Note this requirement -will go away soon.> -

The format of this command is -

# CertTool i inFileName label [options] -

The cert to import is obtained from "inFileName". The label argument -is the string you provided to the prompt "Enter key and certificate label:" -in Section 3. -

The available options are: -

k=keyChainName -

Where "KeyChainName" is the name of the keychain to which the -cert will be added. If no keychain is specified, the cert is added to the -default keychain. The specified keychain must exist, and it must contain -the keypair you generated in Section -3. If the keychain is not open when this command is executed, you will -be prompted by the Keychain system for its passphrase.
-d -
Specifies DER format as described above. The default is PEM -format.
-
- -

-6. Displaying a Certificate

- -
This displays the contents of an existing certificate, obtained -from a file. -

The format of this command is -

# CertTool d inFileName [options] -

The cert to display is obtained from "inFileName". -

The only available option is the 'd' flag, specifying DER format as -described above. The default is PEM format -
 

- -

-7. Certificate Authorities -and CSRs

- -
As mentioned above, the general procedure for obtaining a "real" -cert is: -
    -
  • -Generate a key pair
  • - -
  • -Generate a CSR
  • - -
  • -Provide the CSR and some other information and/or documentation to the -CA
  • - -
  • -CA sends you a certificate which is signed by the CA.
  • - -
  • -You import that certificate, obtained from the CA, into your keychain. -The items in that keychain can now be used in SecureTranspoert's SSLSetCertificate() -call.
  • -
-
- -
One CA with an excellent web-based interface for obtaining -a cert is Verisign (http://www.verisign.com/products/site/index.html). -You can get a free 14-day trial certificate using nothing but CertTool, -Verisign's web site, and email. You need to provide some personal information; -then you paste in the CSR generated in Section -3 into a form on the web site. A few minutes later Verisign emails -you a certificate, which you import into your keychain per Section -5.  The whole process takes less than 10 minutes. The free certificate -obtained in this manner is signed by a temporary root cert which is not -recognized by any browsers, but Verisign also provides a measn of installing -this temporary root cert into your browser, directly from their web site. -Typically one would use the free, temporary cert to perform initial configuration -of a server and to ring out the general SSL infrastructure. Once you feel -comfortable with the operation of the server, then it's time to buy a "real" -certificate which will allow your web server to be recognized by any browser. -

Thawte has a similar, very friendly service at http://www.thawte.com/.

- -
Note that, for early web server development and/or testing, -you can skip the entire procedure described above and just generate your -own self-signed root cert as described in section 1. No CA is involved; -no CSR is generated; no cert needs to be imported - CertTool generates -a cert for you and immediately adds it to your keychain. Bear in mind that -this option requires tolerance of the various SSL clients you'll be testing -with, none of whom recognize your root cert.
- - - + CertTool.html

CertTool

Last Update 10/10/02

Table Of Contents

1. Introduction
2. Generating a Self-Signed Certificate
3. Generating a Certificate Signing Request (CSR)
4. Verifying a CSR
5. Importing a Certificate from a Certificate Authority
6. Displaying a Certificate
7. Certificate Authorities and CSRs
8. Importing a CRL
9. Displaying a CRL

1. Introduction

CertTool is a UNIX command-line program which is used to create key pairs, certificates, and certificate signing requests; to import externally generated certificates into a Keychain, and to display the contents of certificates. Currently. the primary use of CertTool is to perform the certificate-related administration required to configure an SSL server based on Mac OS X's SecureTransport library. Each supported CertTool operation is described below in detail.

The reader of this document, and the user of CertTool, is assumed to be familiar with the following:

  • General principles of public key cryptography
  • The concepts of certificates and trust
  • General operation of the Secure Socket Layer (SSL) protocol
  • General operation of the Mac OS X Keychain
  • The Mac OS X SecureTransport library
No programming knowledge is assumed or required. An excellent primer on the topics of public key cryptography, certificates, and SSL can be found at http://httpd.apache.org/docs-2.0/ssl/ssl_intro.html.

Note: in all examples of usage of the command line tool which follow, the user's input is shown in bold. Running CertTool with no command-line arguments results in usage info being displayed.
 

2. Generating a Self-Signed Certificate

This command generates a key pair and a self-signed (root) certificate and places them in a keychain. The root cert is signed by the private key generated during this command. The cert generated by this command is totally untrustworth and cannot be used in the "real world"; the primary use of this command is to facilitate early development of SSL server applications based on SecureTransport. In particular, "real world" SSL clients (e.g., web browsers) will complain to varying degrees when they attempt to connect to an SSL server which presents a cert which is generated by this command. Some broswers, after a fair amount of handholding, will allow you to conditionally "trust" this cert.

The format of this command is

# CertTool c [options]

The available options are:

k=keyChainName
Where "KeyChainName" is the name of the keychain into which keys and the cert will be added. If no keychain is specified, keys and certs are added to the default keychain. The specified keychain must exist unless you specify the 'c' option.
c
Specifies that the designated keychain is to be created.
This an interactive command; you will be prompted for a number of different items which are used to generate the keypair and the cert. A sample sesion follows.
 
# CertTool k=certkc
Enter key and certificate label: testCert

Please specify parameters for the key pair you will generate.

  r  RSA
  d  DSA
  f  FEE

Select key algorithm by letter: r

Valid key sizes for RSA are 512..2048; default is 512
Enter key size in bits or CR for default: 512

You have selected algorithm RSA, key size 512 bits.
OK (y/anything)? y
Enter cert/key usage (s=signing, b=signing AND encrypting): b
...Generating key pair...

<<Note: you will be prompted for the Keychain's passphrase by the Keychain system at this point if the specified keychain is not open.>>

Please specify the algorithm with which your certificate will be signed.

  5  RSA with MD5
  s  RSA with SHA1

Select signature algorithm by letter: s

You have selected algorithm RSA with SHA1.
OK (y/anything)? y
...creating certificate...

You will now specify the various components of the certificate's
Relative Distinguished Name (RDN). An RDN has a number of
components, all of which are optional, but at least one of
which must be present.

Note that if you are creating a certificate for use in an
SSL/TLS server, the Common Name component of the RDN must match
exactly the host name of the server. This must not be an IP
address, but the actual domain name, e.g. www.apple.com.

Entering a CR for a given RDN component results in no value for
that component.

Common Name       (e.g, www.apple.com) : 10.0.61.5
Country                  (e.g, US) :
Organization            (e.g, Apple Computer, Inc.) : Apple
Organization Unit     (e.g, Apple Data Security) :
State/Province          (e.g., California) : California

You have specified:
  Common Name       : 10.0.61.5
  Organization            : Apple
  State/Province         : California
Is this OK (y/anything)? y
..cert stored in Keychain.
#

The "Common Name" portion of the RDN - in the above case, "10.0.61.5" - MUST match the host name of the machine you'll running sslServer on. (In this case the test machine doesn't have an actual hostname; it's DHCP'd behind a firewall which is why "10.0.61.5" was specified for Common Name.) This is part of SSL's certificate verification; it prevents an attack using DNS spoofing.

A brief note about cert/key usage: the normal configuration of SecureTransport is that the server cert specified in SSLSetCertificate() is capable of both signing and encryption. If this cert is only capable of signing, then you must create a second keychain ontaining a cert which is capable of encryption, and pass that to SSLSetEncryptionCertificate().
 
 

3. Generating a Certificate Signing Request (CSR)

A CSR is the standard means by which an administrator of a web server provides information to a Certificate Authority (CA) in order to obtain a valid certificate which is signed by the CA. This type of cert is used in the real world; certs signed by CAs such as Verisign or Thawte are recognized by all web browsers when performing SSL transactions.

The general procedure for obtaining a "real" cert is:
 

  • Generate a key pair
  • Generate a CSR
  • Provide the CSR and some other information and/or documentation to the CA
  • CA sends you a certificate which is signed by the CA.
  • You import that certificate, obtained from the CA, into your keychain. The items in that keychain can now be used in SecureTranspoert's SSLSetCertificate() call.
This command performs the first two steps in the above procedure. See Section 5 for information on importing the resulting certificate into your keychain.

The format of this command is

# CertTool r outFileName [options]

The resulting CSR will be written to "outFileName".

The available options are:

k=keyChainName

Where "KeyChainName" is the name of the keychain into which keys and the cert will be added. If no keychain is specified, keys and certs are added to the default keychain. The specified keychain must exist unless you specify the 'c' option.
d
The 'd' option tells CertTool to create the CSR in DER-encoded format. The default is PEM-encoded, which is what most CAs expect. PEM encoded data consists of printable ASCII text which can, for example, be pasted into an email message. DER-encoded data is nonprintable binary data.
c
Specifies that the designated keychain is to be created.
This an interactive command; you will be prompted for a number of different items which are used to generate the keypair and the CSR. The prompts given, and the format of the data you must supply, are identical to the data shown in the sample session in Section 2.

See Section 7 for more information on using CSRs and about CAs.
 
 

4. Verifying a CSR

A CSR contains, among other things, the public key which was generated in Section 3. The CSR is signed with the associated private key. Thus the inteegrity of a CSR can be verified by extracting its public key and verifying the signature of the CSR. This command performs this integrity check.

The format of this command is

# CertTool v inFileName [options]

The resulting CSR will be written to "outFileName".

The only available option is the 'd' flag, which as described in Section 3, indiciates that the CSR is in DER format rather than the default PEM format.

A typical (successful) run of this command is like so:

# CertTool v myCsr.pem
...CSR verified successfully.

A large number of things can go wrong of the verification fails; suffice it to say that if you see anything other than the above success message, you have a bad or corrupted CSR.
 

 

5. Importing a Certificate from a Certificate Authority

Once you have negotiated with your CA, and provided them with the CSR generated in Section 3 as well as any other information, documentation, and payment thay require, the CA will provide you with a certificate. Use this command to add that certificate to the keychain containing the keypair you generated in Section 3

The format of this command is

# CertTool i inFileName  [options]

The cert to import is obtained from "inFileName".

The available options are:

k=keyChainName

Where "KeyChainName" is the name of the keychain to which the cert will be added. If no keychain is specified, the cert is added to the default keychain. The specified keychain should contain the keypair you generated in Section 3. (Note you can import a certificate into a keychain which does not contain keys you generated but there will be no linkage between the imported certificate and a private key if you do this.) If the keychain is not open when this command is executed, you will be prompted by the Keychain system for its passphrase.
d
Specifies DER format as described above. The default is PEM format.

c
Specifies that the designated keychain is to be created.

6. Displaying a Certificate

This displays the contents of an existing certificate, obtained from a file.

The format of this command is

# CertTool d inFileName [options]

The cert to display is obtained from "inFileName".

The only available option is the 'd' flag, specifying DER format as described above. The default is PEM format
 

7. Certificate Authorities and CSRs

As mentioned above, the general procedure for obtaining a "real" cert is:
  • Generate a key pair
  • Generate a CSR
  • Provide the CSR and some other information and/or documentation to the CA
  • CA sends you a certificate which is signed by the CA.
  • You import that certificate, obtained from the CA, into your keychain. The items in that keychain can now be used in SecureTranspoert's SSLSetCertificate() call.
One CA with an excellent web-based interface for obtaining a cert is Verisign (http://www.verisign.com/products/site/index.html). You can get a free 14-day trial certificate using nothing but CertTool, Verisign's web site, and email. You need to provide some personal information; then you paste in the CSR generated in Section 3 into a form on the web site. A few minutes later Verisign emails you a certificate, which you import into your keychain per Section 5.  The whole process takes less than 10 minutes. The free certificate obtained in this manner is signed by a temporary root cert which is not recognized by any browsers, but Verisign also provides a measn of installing this temporary root cert into your browser, directly from their web site. Typically one would use the free, temporary cert to perform initial configuration of a server and to ring out the general SSL infrastructure. Once you feel comfortable with the operation of the server, then it's time to buy a "real" certificate which will allow your web server to be recognized by any browser.

Thawte has a similar, very friendly service at http://www.thawte.com/.

Note that, for early web server development and/or testing, you can skip the entire procedure described above and just generate your own self-signed root cert as described in section 1. No CA is involved; no CSR is generated; no cert needs to be imported - CertTool generates a cert for you and immediately adds it to your keychain. Bear in mind that this option requires tolerance of the various SSL clients you'll be testing with, none of whom recognize your root cert.
 

5. Importing a CRL

This command is used to add a Certificate Revocation List (CRL) to a keychain.

The format of this command is

# CertTool I inFileName [options]

The CRL to import is obtained from "inFileName". 

The available options are:

k=keyChainName

Where "KeyChainName" is the name of the keychain to which the CRL will be added. If no keychain is specified, the cert is added to the default keychain.  If the keychain is not open when this command is executed, you will be prompted by the Keychain system for its passphrase.
d
Specifies DER format as described above. The default is PEM format.
c
Specifies that the designated keychain is to be created.


6. Displaying a CRL

This displays the contents of an existing Certificate Revocation List (CRL) , obtained from a file.

The format of this command is

# CertTool D inFileName [options]

The cert to display is obtained from "inFileName".

The only available option is the 'd' flag, specifying DER format as described above. The default is PEM format
 


\ No newline at end of file diff --git a/CertTool/CertTool/CertTool.cpp b/CertTool/CertTool/CertTool.cpp deleted file mode 100644 index a1bda8f7..00000000 --- a/CertTool/CertTool/CertTool.cpp +++ /dev/null @@ -1,1233 +0,0 @@ -/* - File: CertTool.cpp - - Description: certificate manipulation tool - - Author: dmitch - - Copyright: © Copyright 2002 Apple Computer, Inc. All rights reserved. - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple - Computer, Inc. ("Apple") in consideration of your agreement to - the following terms, and your use, installation, modification - or redistribution of this Apple software constitutes acceptance - of these terms. If you do not agree with these terms, please - do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following - terms, and subject to these terms, Apple grants you a personal, - non-exclusive license, under Apple's copyrights in this - original Apple software (the "Apple Software"), to use, - reproduce, modify and redistribute the Apple Software, with - or without modifications, in source and/or binary forms; - provided that if you redistribute the Apple Software in - its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all - such redistributions of the Apple Software. Neither the - name, trademarks, service marks or logos of Apple Computer, - Inc. may be used to endorse or promote products derived from the - Apple Software without specific prior written permission from - Apple. Except as expressly stated in this notice, no other - rights or licenses, express or implied, are granted by Apple - herein, including but not limited to any patent rights that - may be infringed by your derivative works or by other works - in which the Apple Software may be incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. - APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, - REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE - OR IN COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, - INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION - AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED - AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING - NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "CertUI.h" -#include -#include -#include - -/* will change soon */ -#include - -/* - * Workaround flags. - */ - -/* SecKeychainGetCSPHandle implemented? */ -#define SEC_KEYCHAIN_GET_CSP 0 - -/* SecCertificateAddToKeychain fully functional? */ -#define SEC_CERT_ADD_TO_KC 1 - -/* SecKeyCreatePair() implemented */ -#define SEC_KEY_CREATE_PAIR 0 - -#if !SEC_KEY_CREATE_PAIR -/* munge Label attr if manually generating keys */ -#define MUNGE_LABEL_ATTR 1 -#endif - -#define KC_DB_PATH "Library/Keychains" /* relative to home */ - -/* - * defaults for undocumented 'Z' option - */ -#define ZDEF_KEY_LABEL "testCert" -#define ZDEF_KEY_ALG CSSM_ALGID_RSA -#define ZDEF_KEY_SIZE 512 -#define ZDEF_KEY_USAGE (kKeyUseSigning | kKeyUseEncrypting) -#define ZDEF_SIG_ALG CSSM_ALGID_SHA1WithRSA -#define ZDEF_SIG_OID CSSMOID_SHA1WithRSA -#define ZDEF_COMMON_NAME "10.0.61.5" -#define ZDEF_ORG_NAME "Apple Computer - DEBUG ONLY" -#define ZDEF_COUNTRY "US" -#define ZDEF_STATE "Washington" -#define ZDEF_CHALLENGE "someChallenge" - -static void usage(char **argv) -{ - printf("usage:\n"); - printf(" Create a keypair and cert: %s c [options]\n", argv[0]); - printf(" Create a CSR: %s r outFileName [options]\n", - argv[0]); - printf(" Verify a CSR: %s v infileName [options]\n", argv[0]); - #if SEC_CERT_ADD_TO_KC - printf(" Import a certificate: %s i inFileName [options]\n", argv[0]); - #else - /* this one needs the printName */ - printf(" Import a certificate: %s i inFileName printName [options]\n", - argv[0]); - #endif - printf(" Display a certificate: %s d inFileName [options]\n", argv[0]); - printf("Options:\n"); - printf(" k=keychainName\n"); - printf(" c(reate the keychain)\n"); - printf(" v(erbose)\n"); - printf(" d (CSR in DER format; default is PEM)\n"); - printf(" h(elp)\n"); - exit(1); -} - -#if SEC_KEY_CREATE_PAIR -/* #error Work needed to generate key pair using Keychain. */ -#else - -/* - * Workaround to manually generate a key pair and munge its DB attributes - * to include the hash of the public key in the private key's Label attr. - */ -#if MUNGE_LABEL_ATTR - -/* Convert a reference key to a raw key. */ -static CSSM_RETURN refKeyToRaw( - CSSM_CSP_HANDLE cspHand, - const CSSM_KEY *refKey, - CSSM_KEY_PTR rawKey) // RETURNED -{ - CSSM_CC_HANDLE ccHand; - CSSM_RETURN crtn; - CSSM_ACCESS_CREDENTIALS creds; - - memset(rawKey, 0, sizeof(CSSM_KEY)); - memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS)); - crtn = CSSM_CSP_CreateSymmetricContext(cspHand, - CSSM_ALGID_NONE, - CSSM_ALGMODE_NONE, - &creds, // passPhrase - NULL, // wrapping key - NULL, // init vector - CSSM_PADDING_NONE, // Padding - 0, // Params - &ccHand); - if(crtn) { - showError(crtn, "refKeyToRaw: context err"); - return crtn; - } - crtn = CSSM_WrapKey(ccHand, - &creds, - refKey, - NULL, // DescriptiveData - rawKey); - if(crtn != CSSM_OK) { - showError(crtn, "refKeyToRaw: CSSM_WrapKey"); - return crtn; - } - CSSM_DeleteContext(ccHand); - return CSSM_OK; -} - -/* - * Find private key by label, modify its Label attr to be the - * hash of the associated public key. - */ -static CSSM_RETURN setPubKeyHash( - CSSM_CSP_HANDLE cspHand, - CSSM_DL_DB_HANDLE dlDbHand, - const CSSM_KEY *pubKey, // to get hash - CSSM_KEY_PTR privKey, // its record gets updated - const char *keyLabel) // look up by this -{ - CSSM_QUERY query; - CSSM_SELECTION_PREDICATE predicate; - CSSM_DB_UNIQUE_RECORD_PTR record = NULL; - CSSM_RETURN crtn; - CSSM_DATA labelData; - CSSM_HANDLE resultHand; - - labelData.Data = (uint8 *)keyLabel; - labelData.Length = strlen(keyLabel) + 1; // incl. NULL - query.RecordType = CSSM_DL_DB_RECORD_PRIVATE_KEY; - query.Conjunctive = CSSM_DB_NONE; - query.NumSelectionPredicates = 1; - predicate.DbOperator = CSSM_DB_EQUAL; - - predicate.Attribute.Info.AttributeNameFormat = - CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - predicate.Attribute.Info.Label.AttributeName = "Label"; - predicate.Attribute.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; - /* hope this cast is OK */ - predicate.Attribute.Value = &labelData; - query.SelectionPredicate = &predicate; - - query.QueryLimits.TimeLimit = 0; // FIXME - meaningful? - query.QueryLimits.SizeLimit = 1; // FIXME - meaningful? - query.QueryFlags = 0; // CSSM_QUERY_RETURN_DATA; // FIXME - used? - - /* build Record attribute with one attr */ - CSSM_DB_RECORD_ATTRIBUTE_DATA recordAttrs; - CSSM_DB_ATTRIBUTE_DATA attr; - attr.Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; - attr.Info.Label.AttributeName = "Label"; - attr.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; - - recordAttrs.DataRecordType = CSSM_DL_DB_RECORD_PRIVATE_KEY; - recordAttrs.NumberOfAttributes = 1; - recordAttrs.AttributeData = &attr; - - crtn = CSSM_DL_DataGetFirst(dlDbHand, - &query, - &resultHand, - &recordAttrs, - NULL, // hopefully optional ...theData, - &record); - /* abort only on success */ - if(crtn != CSSM_OK) { - showError(crtn, "CSSM_DL_DataGetFirst"); - printf("***setPubKeyHash: can't find private key\n"); - return crtn; - } - - /* do NULL unwrap of public key for use with raw CSP */ - CSSM_KEY rawPubKey; - crtn = refKeyToRaw(cspHand, pubKey, &rawPubKey); - if(crtn) { - printf("***Error converting public key to raw format\n"); - return crtn; - } - - /* connect to raw CSP */ - CSSM_CSP_HANDLE rawCspHand = cuCspStartup(CSSM_TRUE); - if(rawCspHand == 0) { - printf("***Error connecting to raw CSP; aborting.\n"); - return -1; - } - - /* calculate hash of pub key */ - CSSM_DATA_PTR keyDigest = NULL; - CSSM_CC_HANDLE ccHand; - crtn = CSSM_CSP_CreatePassThroughContext(rawCspHand, - &rawPubKey, - &ccHand); - if(ccHand == 0) { - showError(crtn, "CSSM_CSP_CreatePassThroughContext"); - printf("***Error calculating public key hash. Aborting.\n"); - return -1; - } - crtn = CSSM_CSP_PassThrough(ccHand, - CSSM_APPLECSP_KEYDIGEST, - NULL, - (void **)&keyDigest); - if(crtn) { - showError(crtn, "CSSM_CSP_PassThrough(PUBKEYHASH)"); - printf("***Error calculating public key hash. Aborting.\n"); - return -1; - } - CSSM_FreeKey(cspHand, NULL, &rawPubKey, CSSM_FALSE); - CSSM_DeleteContext(ccHand); - CSSM_ModuleDetach(rawCspHand); - - /* - * Replace Label attr data with hash. - * NOTE: the module which allocated this attribute data - a DL - - * was loaded and attached by the Sec layer, not by us. Thus - * we can't use the memory allocator functions *we* used when - * attaching to the CSPDL - we have to use the ones - * which the Sec layer registered with the DL. - */ - CSSM_API_MEMORY_FUNCS memFuncs; - crtn = CSSM_GetAPIMemoryFunctions(dlDbHand.DLHandle, &memFuncs); - if(crtn) { - showError(crtn, "CSSM_GetAPIMemoryFunctions(DLHandle)"); - /* oh well, leak and continue */ - } - else { - memFuncs.free_func(attr.Value->Data, memFuncs.AllocRef); - memFuncs.free_func(attr.Value, memFuncs.AllocRef); - } - attr.Value = keyDigest; - - /* modify key attributes */ - crtn = CSSM_DL_DataModify(dlDbHand, - CSSM_DL_DB_RECORD_PRIVATE_KEY, - record, - &recordAttrs, - NULL, // DataToBeModified - CSSM_DB_MODIFY_ATTRIBUTE_REPLACE); - if(crtn) { - showError(crtn, "CSSM_DL_DataModify(PUBKEYHASH)"); - printf("***Error setting public key hash. Aborting.\n"); - return crtn; - } - crtn = CSSM_DL_DataAbortQuery(dlDbHand, resultHand); - if(crtn) { - showError(crtn, "CSSM_DL_DataAbortQuery"); - /* let's keep going in this case */ - } - crtn = CSSM_DL_FreeUniqueRecord(dlDbHand, record); - if(crtn) { - showError(crtn, "CSSM_DL_FreeUniqueRecord"); - /* let's keep going in this case */ - crtn = CSSM_OK; - } - - /* free resources */ - cuAppFree(keyDigest->Data, NULL); - return CSSM_OK; -} -#endif /* MUNGE_LABEL_ATTR */ - -/* Still on the !SEC_KEY_CREATE_PAIR workaround */ - -/* - * Generate a key pair using the CSPDL. - */ -static OSStatus generateKeyPair( - CSSM_CSP_HANDLE cspHand, - CSSM_DL_DB_HANDLE dlDbHand, - CSSM_ALGORITHMS keyAlg, // e.g., CSSM_ALGID_RSA - uint32 keySizeInBits, - const char *keyLabel, // C string - CU_KeyUsage keyUsage, // CUK_Signing, etc. - CSSM_BOOL verbose, - const CSSM_KEY **pubKeyPtr, // mallocd, created, RETURNED - const CSSM_KEY **privKeyPtr) // mallocd, created, RETURNED -{ - CSSM_KEY_PTR pubKey = reinterpret_cast( - APP_MALLOC(sizeof(CSSM_KEY))); - CSSM_KEY_PTR privKey = reinterpret_cast( - APP_MALLOC(sizeof(CSSM_KEY))); - if((pubKey == NULL) || (privKey == NULL)) { - return memFullErr; - } - - CSSM_RETURN crtn; - CSSM_KEYUSE pubKeyUse = 0; - CSSM_KEYUSE privKeyUse = 0; - - if(keyUsage & kKeyUseSigning) { - pubKeyUse |= CSSM_KEYUSE_VERIFY; - privKeyUse |= CSSM_KEYUSE_SIGN; - } - if(keyUsage & kKeyUseEncrypting) { - pubKeyUse |= (CSSM_KEYUSE_ENCRYPT | CSSM_KEYUSE_WRAP); - privKeyUse |= (CSSM_KEYUSE_DECRYPT | CSSM_KEYUSE_UNWRAP); - } - - crtn = cuCspGenKeyPair(cspHand, - &dlDbHand, - keyAlg, - keyLabel, - strlen(keyLabel) + 1, - keySizeInBits, - pubKey, - pubKeyUse, - CSSM_KEYATTR_EXTRACTABLE | CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_PERMANENT, - privKey, - privKeyUse, - CSSM_KEYATTR_SENSITIVE | CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_PERMANENT); - if(crtn) { - APP_FREE(pubKey); - APP_FREE(privKey); - return paramErr; - } - if(verbose) { - printf("...%u bit key pair generated.\n", - (unsigned)keySizeInBits); - } - - #if MUNGE_LABEL_ATTR - /* bind private key to cert by public key hash */ - crtn = setPubKeyHash(cspHand, - dlDbHand, - pubKey, - privKey, - keyLabel); - if(crtn) { - printf("***Error setting public key hash. Continuing at peril.\n"); - } - #endif /* MUNGE_LABEL_ATTR */ - - *pubKeyPtr = pubKey; - *privKeyPtr = privKey; - return noErr; -} -#endif /* SEC_KEY_CREATE_PAIR */ - -static void verifyCsr( - CSSM_CL_HANDLE clHand, - const char *fileName, - CSSM_BOOL pemFormat) -{ - unsigned char *csr = NULL; - unsigned csrLen; - CSSM_DATA csrData; - unsigned char *der = NULL; - unsigned derLen = 0; - - if(readFile(fileName, &csr, &csrLen)) { - printf("***Error reading CSR from file %s. Aborting.\n", - fileName); - return; - } - if(pemFormat) { - int rtn = pemDecode(csr, csrLen, &der, &derLen); - if(rtn) { - printf("***%s: Bad PEM formatting. Aborting.\n", fileName); - return; - } - csrData.Data = der; - csrData.Length = derLen; - } - else { - csrData.Data = csr; - csrData.Length = csrLen; - } - - CSSM_RETURN crtn = CSSM_CL_PassThrough(clHand, - 0, // CCHandle - CSSM_APPLEX509CL_VERIFY_CSR, - &csrData, - NULL); - if(crtn) { - cuPrintError("Verify CSR", crtn); - } - else { - printf("...CSR verified successfully.\n"); - } - if(der) { - free(der); - } - if(csr) { - free(csr); - } -} - -static void displayCert( - const char *fileName, - CSSM_BOOL pemFormat) -{ - unsigned char *rawCert = NULL; - unsigned rawCertSize; - unsigned char *derCert = NULL; - unsigned derCertSize; - int rtn; - - rtn = readFile(fileName, &rawCert, &rawCertSize); - if(rtn) { - printf("Error reading %s; aborting.\n", fileName); - return; - } - if(pemFormat) { - rtn = pemDecode(rawCert, rawCertSize, &derCert, &derCertSize); - if(rtn) { - printf("***%s: Bad PEM formatting. Aborting.\n", fileName); - return; - } - printCert(derCert, derCertSize, CSSM_TRUE); - free(derCert); - } - else { - printCert(rawCert, rawCertSize, CSSM_TRUE); - } -} - -static void importCert( - SecKeychainRef kcRef, // if SEC_CERT_ADD_TO_KC - CSSM_DL_DB_HANDLE dlDbHand, // otherwise - const char *fileName, - CSSM_BOOL pemFormat, - /* cruft needed by cuAddCertToDb */ - const char *printName) // C string -{ - unsigned char *cert = NULL; - unsigned certLen; - CSSM_DATA certData; - unsigned char *der = NULL; - unsigned derLen = 0; - #if !SEC_CERT_ADD_TO_KC - CSSM_DATA pubKeyHash = {3, (uint8 *)"foo"}; - #endif - - if(readFile(fileName, &cert, &certLen)) { - printf("***Error reading certificate from file %s. Aborting.\n", - fileName); - return; - } - if(pemFormat) { - int rtn = pemDecode(cert, certLen, &der, &derLen); - if(rtn) { - printf("***%s: Bad PEM formatting. Aborting.\n", fileName); - return; - } - certData.Data = der; - certData.Length = derLen; - } - else { - certData.Data = cert; - certData.Length = certLen; - } - - #if SEC_CERT_ADD_TO_KC - SecCertificateRef certRef; - OSStatus ortn = SecCertificateCreateFromData( - &certData, - CSSM_CERT_X_509v3, - CSSM_CERT_ENCODING_DER, - &certRef); - if(ortn) { - printf("***SecCertificateCreateFromData returned %d; aborting.\n", - (int)ortn); - return; - } - ortn = SecCertificateAddToKeychain(certRef, kcRef); - if(ortn) { - printf("***SecCertificateAddToKeychain returned %d; aborting.\n", - (int)ortn); - return; - } - #else - CSSM_RETURN crtn = cuAddCertToDb(dlDbHand, - &certData, - CSSM_CERT_X_509v3, - CSSM_CERT_ENCODING_DER, - printName, // printName - &pubKeyHash); - if(crtn) { - printf("***Error adding cert to keychain. Aborting.\n"); - return; - } - #endif /* SEC_CERT_ADD_TO_KC */ - - printf("...certificate successfully imported.\n"); - if(der) { - free(der); - } - if(cert) { - free(cert); - } -} - - -static OSStatus createCertCsr( - CSSM_BOOL createCsr, // true: CSR, false: Cert - CSSM_TP_HANDLE tpHand, // eventually, a SecKeychainRef - CSSM_CL_HANDLE clHand, - CSSM_CSP_HANDLE cspHand, - const CSSM_KEY *subjPubKey, - const CSSM_KEY *signerPrivKey, - CSSM_ALGORITHMS sigAlg, - const CSSM_OID *sigOid, - CU_KeyUsage keyUsage, // kKeyUseSigning, etc. - /* - * Issuer's RDN is obtained from the issuer cert, if present, or is - * assumed to be the same as the subject name (i.e., we're creating - * a self-signed root cert). - */ - const CSSM_DATA *issuerCert, - CSSM_BOOL useAllDefaults, - CSSM_DATA_PTR certData) // mallocd and RETURNED -{ - CE_DataAndType exts[2]; - CE_DataAndType *extp = exts; - unsigned numExts; - - CSSM_DATA refId; // mallocd by CSSM_TP_SubmitCredRequest - CSSM_APPLE_TP_CERT_REQUEST certReq; - CSSM_TP_REQUEST_SET reqSet; - sint32 estTime; - CSSM_BOOL confirmRequired; - CSSM_TP_RESULT_SET_PTR resultSet; - CSSM_ENCODED_CERT *encCert; - CSSM_APPLE_TP_NAME_OID subjectNames[MAX_NAMES]; - uint32 numNames; - CSSM_TP_CALLERAUTH_CONTEXT CallerAuthContext; - CSSM_FIELD policyId; - - /* Note a lot of the CSSM_APPLE_TP_CERT_REQUEST fields are not - * used for the createCsr option, but we'll fill in as much as is practical - * for either case. - */ - if(issuerCert != NULL) { - printf("createCertCsr: issuerCert not implemented\n"); - return unimpErr; - } - - numExts = 0; - - char challengeBuf[400]; - if(createCsr) { - if(useAllDefaults) { - strcpy(challengeBuf, ZDEF_CHALLENGE); - } - else { - while(1) { - getStringWithPrompt("Enter challenge string: ", - challengeBuf, sizeof(challengeBuf)); - if(challengeBuf[0] != '\0') { - break; - } - } - } - certReq.challengeString = challengeBuf; - } - else { - /* creating cert */ - certReq.challengeString = NULL; - - /* KeyUsage extension */ - extp->type = DT_KeyUsage; - extp->critical = CSSM_FALSE; - extp->extension.keyUsage = 0; - if(keyUsage & kKeyUseSigning) { - extp->extension.keyUsage |= - (CE_KU_DigitalSignature | CE_KU_KeyCertSign); - } - if(keyUsage & kKeyUseEncrypting) { - extp->extension.keyUsage |= - (CE_KU_KeyEncipherment | CE_KU_DataEncipherment); - } - extp++; - numExts++; - - /* BasicConstraints */ - extp->type = DT_BasicConstraints; - extp->critical = CSSM_TRUE; - extp->extension.basicConstraints.cA = CSSM_TRUE; - extp->extension.basicConstraints.pathLenConstraintPresent = CSSM_FALSE; - extp++; - numExts++; - } - - /* name array, get from user. */ - if(useAllDefaults) { - subjectNames[0].string = ZDEF_COMMON_NAME; - subjectNames[0].oid = &CSSMOID_CommonName; - subjectNames[1].string = ZDEF_ORG_NAME; - subjectNames[1].oid = &CSSMOID_OrganizationName; - subjectNames[2].string = ZDEF_COUNTRY; - subjectNames[2].oid = &CSSMOID_CountryName; - subjectNames[3].string = ZDEF_STATE; - subjectNames[3].oid = &CSSMOID_StateProvinceName; - numNames = 4; - } - else { - getNameOids(subjectNames, &numNames); - } - - /* certReq */ - certReq.cspHand = cspHand; - certReq.clHand = clHand; - certReq.serialNumber = 0x12345678; // TBD - random? From user? - certReq.numSubjectNames = numNames; - certReq.subjectNames = subjectNames; - - /* TBD - if we're passed in a signing cert, certReq.issuerNameX509 will - * be obtained from that cert. For now we specify "self-signed" cert - * by not providing an issuer name at all. */ - certReq.numIssuerNames = 0; // root for now - certReq.issuerNames = NULL; - certReq.issuerNameX509 = NULL; - certReq.certPublicKey = subjPubKey; - certReq.issuerPrivateKey = signerPrivKey; - certReq.signatureAlg = sigAlg; - certReq.signatureOid = *sigOid; - certReq.notBefore = 0; // TBD - from user - certReq.notAfter = 60 * 60 * 24 * 30; // seconds from now - certReq.numExtensions = numExts; - certReq.extensions = exts; - - reqSet.NumberOfRequests = 1; - reqSet.Requests = &certReq; - - /* a CSSM_TP_CALLERAUTH_CONTEXT to specify an OID */ - memset(&CallerAuthContext, 0, sizeof(CSSM_TP_CALLERAUTH_CONTEXT)); - memset(&policyId, 0, sizeof(CSSM_FIELD)); - if(createCsr) { - policyId.FieldOid = CSSMOID_APPLE_TP_CSR_GEN; - } - else { - policyId.FieldOid = CSSMOID_APPLE_TP_LOCAL_CERT_GEN; - } - CallerAuthContext.Policy.NumberOfPolicyIds = 1; - CallerAuthContext.Policy.PolicyIds = &policyId; - CssmClient::AclFactory factory; - CallerAuthContext.CallerCredentials = const_cast(factory.promptCred()); - - CSSM_RETURN crtn = CSSM_TP_SubmitCredRequest(tpHand, - NULL, // PreferredAuthority - CSSM_TP_AUTHORITY_REQUEST_CERTISSUE, - &reqSet, - &CallerAuthContext, - &estTime, - &refId); - - /* before proceeding, free resources allocated thus far */ - if(!useAllDefaults) { - freeNameOids(subjectNames, numNames); - } - - if(crtn) { - cuPrintError("CSSM_TP_SubmitCredRequest", crtn); - return crtn; - } - crtn = CSSM_TP_RetrieveCredResult(tpHand, - &refId, - NULL, // CallerAuthCredentials - &estTime, - &confirmRequired, - &resultSet); - if(crtn) { - cuPrintError("CSSM_TP_RetrieveCredResult", crtn); - return crtn; - } - if(resultSet == NULL) { - printf("***CSSM_TP_RetrieveCredResult returned NULL result set.\n"); - return ioErr; - } - encCert = (CSSM_ENCODED_CERT *)resultSet->Results; - *certData = encCert->CertBlob; - - /* free resources allocated by TP */ - APP_FREE(refId.Data); - APP_FREE(encCert); - APP_FREE(resultSet); - return noErr; -} - -typedef enum { - CO_Nop, - CO_CreateCert, - CO_CreateCSR, - CO_VerifyCSR, - CO_ImportCert, - CO_DisplayCert -} CertOp; - -int main(int argc, char **argv) -{ - SecKeychainRef kcRef = nil; - char kcPath[MAXPATHLEN + 1]; - UInt32 kcPathLen = MAXPATHLEN + 1; - CSSM_BOOL createKc = CSSM_FALSE; - OSStatus ortn; - CSSM_DL_DB_HANDLE dlDbHand = {0, 0}; - CSSM_CSP_HANDLE cspHand = 0; - CSSM_TP_HANDLE tpHand = 0; - CSSM_CL_HANDLE clHand = 0; - const CSSM_KEY *pubKey; - const CSSM_KEY *privKey; - int arg; - char *argp; - CSSM_BOOL verbose = CSSM_FALSE; - CSSM_ALGORITHMS keyAlg; - CSSM_ALGORITHMS sigAlg; - const CSSM_OID *sigOid; - CSSM_DATA certData = {0, NULL}; - CSSM_RETURN crtn; - CU_KeyUsage keyUsage = 0; - bool isRoot; - CSSM_DATA keyLabel; - #if SEC_KEY_CREATE_PAIR - CSSM_KEYUSE pubKeyUse = 0; - CSSM_KEYUSE privKeyUse = 0; - CSSM_KEYATTR_FLAGS pubKeyAttrs; - CSSM_KEYATTR_FLAGS privKeyAttrs; - CFStringRef description = NULL; - SecAccessRef access = NULL; - CFArrayRef acls = NULL; - SecACLRef acl = NULL; - bool aclFound = false; - CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR promptSelector = - { - CSSM_ACL_KEYCHAIN_PROMPT_CURRENT_VERSION, 0 - }; - SecKeyRef pubKeyRef = 0, privKeyRef = 0; - #elif !MUNGE_LABEL_ATTR - CSSM_DATA pubKeyHash = {3, (uint8 *)"foo"}; - #endif - CSSM_BOOL createCsr = CSSM_FALSE; // else create cert - int optArgs = 0; - - /* command line arguments */ - char *fileName = NULL; - CSSM_BOOL pemFormat = CSSM_TRUE; - char *certPrintName = NULL; - CertOp op = CO_Nop; - uint32 keySizeInBits; - char *kcName = NULL; - CSSM_BOOL useAllDefaults = CSSM_FALSE; // undoc'd cmd option - - if(argc < 2) { - usage(argv); - } - switch(argv[1][0]) { - case 'c': - op = CO_CreateCert; - optArgs = 2; - break; - case 'r': - if(argc < 3) { - usage(argv); - } - op = CO_CreateCSR; - createCsr = CSSM_TRUE; - fileName = argv[2]; - optArgs = 3; - break; - case 'v': - if(argc < 3) { - usage(argv); - } - op = CO_VerifyCSR; - fileName = argv[2]; - optArgs = 3; - break; - case 'i': - #if SEC_CERT_ADD_TO_KC - if(argc < 3) { - usage(argv); - } - optArgs = 3; - #else - if(argc < 4) { - usage(argv); - } - certPrintName = argv[3]; - optArgs = 4; - #endif /* SEC_CERT_ADD_TO_KC */ - op = CO_ImportCert; - fileName = argv[2]; - break; - case 'd': - if(argc < 3) { - usage(argv); - } - op = CO_DisplayCert; - fileName = argv[2]; - optArgs = 3; - break; - default: - usage(argv); - } - for(arg=optArgs; arg -#include - -#ifdef __cplusplus -extern "C" { - -/* Dump error info. */ -void showError( - OSStatus ortn, - const char *errStr); - -/* - * Safe gets(). - * -- guaranteed no buffer overflow - * -- guaranteed NULL-terminated string - * -- handles empty string (i.e., response is just CR) properly - */ -void getString( - char *buf, - unsigned bufSize); - -/* - * Prompt and safe getString. - */ -void getStringWithPrompt( - const char *prompt, // need not end in newline - char *buf, - unsigned bufSize); - -/* - * Used to interactively cook up an array of CSSM_APPLE_TP_NAME_OIDs, representing - * a cert's RDN. - */ -typedef struct { - const CSSM_OID *oid; // e.g., CSSMOID_CommonName - const char *description; // e.g., "Common Name" - const char *example; // e.g., "www.apple.com" -} NameOidInfo; - -#define MAX_NAMES 5 - -/* Fill in a CSSM_APPLE_TP_NAME_OID array. */ -void getNameOids( - CSSM_APPLE_TP_NAME_OID *subjectNames, // size MAX_NAMES mallocd by caller - uint32 *numNames); // RETURNED - -/* - * Free strings mallocd in getNameOids. - */ -void freeNameOids( - CSSM_APPLE_TP_NAME_OID *subjectNames, - uint32 numNames); - -/* get key size and algorithm for subject key */ -void getKeyParams( - CSSM_ALGORITHMS &keyAlg, - uint32 &keySizeInBits); - -/* given a signing key, obtain signing algorithm (int and oid format) */ -OSStatus getSigAlg( - const CSSM_KEY *signingKey, - CSSM_ALGORITHMS &sigAlg, - const CSSM_OID * &sigOid); - -/* - * Obtain key usage. - */ - -/* these are OR-able bitfields */ -typedef unsigned CU_KeyUsage; -#define kKeyUseSigning 0x01 -#define kKeyUseEncrypting 0x02 - -CU_KeyUsage getKeyUsage(bool isRoot); - -#endif -#ifdef __cplusplus -} -#endif - -#endif /* _CREATECERT_CERT_UI_H_ */ diff --git a/CertTool/CertTool/CertUI.cpp b/CertTool/CertUI.cpp similarity index 79% rename from CertTool/CertTool/CertUI.cpp rename to CertTool/CertUI.cpp index 087122f8..00c117ec 100644 --- a/CertTool/CertTool/CertUI.cpp +++ b/CertTool/CertUI.cpp @@ -1,54 +1,27 @@ +/* + * Copyright (c) 2002-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + /* File: CertUI.cpp Description: stdio-based routines to get cert info from user. - Author: dmitch - - Copyright: © Copyright 2002 Apple Computer, Inc. All rights reserved. - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple - Computer, Inc. ("Apple") in consideration of your agreement to - the following terms, and your use, installation, modification - or redistribution of this Apple software constitutes acceptance - of these terms. If you do not agree with these terms, please - do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following - terms, and subject to these terms, Apple grants you a personal, - non-exclusive license, under Apple's copyrights in this - original Apple software (the "Apple Software"), to use, - reproduce, modify and redistribute the Apple Software, with - or without modifications, in source and/or binary forms; - provided that if you redistribute the Apple Software in - its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all - such redistributions of the Apple Software. Neither the - name, trademarks, service marks or logos of Apple Computer, - Inc. may be used to endorse or promote products derived from the - Apple Software without specific prior written permission from - Apple. Except as expressly stated in this notice, no other - rights or licenses, express or implied, are granted by Apple - herein, including but not limited to any patent rights that - may be infringed by your derivative works or by other works - in which the Apple Software may be incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. - APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, - REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE - OR IN COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, - INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION - AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED - AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING - NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Author: dmitch */ #include "CertUI.h" @@ -60,7 +33,7 @@ #include #include #include -#include +#include #include void showError( @@ -87,6 +60,10 @@ void getString( for(dex=0; dexdescription, nameOidIn->example); fflush(stdout); @@ -287,7 +262,7 @@ static const AlgInfo feeSigAlgInfo[] = static const AlgInfo dsaSigAlgInfo[] = { - { CSSM_ALGID_SHA1WithDSA, "DSA with SHA1", 's', &CSSMOID_APPLE_FEE_MD5 }, + { CSSM_ALGID_SHA1WithDSA, "DSA with SHA1", 's', &CSSMOID_SHA1WithDSA }, { CSSM_ALGID_NONE, NULL, 0, NULL } }; diff --git a/CertTool/CertUI.h b/CertTool/CertUI.h new file mode 100644 index 00000000..7fcc9256 --- /dev/null +++ b/CertTool/CertUI.h @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2002-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + File: CertUI.h + + Description: stdio-based routines to get cert info from user. + + Author: dmitch +*/ + +#ifndef _CREATECERT_CERT_UI_H_ +#define _CREATECERT_CERT_UI_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { + +enum AbortException {kEOFException}; + +/* Dump error info. */ +void showError( + OSStatus ortn, + const char *errStr); + +/* + * Safe gets(). + * -- guaranteed no buffer overflow + * -- guaranteed NULL-terminated string + * -- handles empty string (i.e., response is just CR) properly + */ +void getString( + char *buf, + unsigned bufSize); + +/* + * Prompt and safe getString. + */ +void getStringWithPrompt( + const char *prompt, // need not end in newline + char *buf, + unsigned bufSize); + +/* + * Used to interactively cook up an array of CSSM_APPLE_TP_NAME_OIDs, representing + * a cert's RDN. + */ +typedef struct { + const CSSM_OID *oid; // e.g., CSSMOID_CommonName + const char *description; // e.g., "Common Name" + const char *example; // e.g., "www.apple.com" +} NameOidInfo; + +#define MAX_NAMES 5 + +/* Fill in a CSSM_APPLE_TP_NAME_OID array. */ +void getNameOids( + CSSM_APPLE_TP_NAME_OID *subjectNames, // size MAX_NAMES mallocd by caller + uint32 *numNames); // RETURNED + +/* + * Free strings mallocd in getNameOids. + */ +void freeNameOids( + CSSM_APPLE_TP_NAME_OID *subjectNames, + uint32 numNames); + +/* get key size and algorithm for subject key */ +void getKeyParams( + CSSM_ALGORITHMS &keyAlg, + uint32 &keySizeInBits); + +/* given a signing key, obtain signing algorithm (int and oid format) */ +OSStatus getSigAlg( + const CSSM_KEY *signingKey, + CSSM_ALGORITHMS &sigAlg, + const CSSM_OID * &sigOid); + +/* + * Obtain key usage. + */ + +/* these are OR-able bitfields */ +typedef unsigned CU_KeyUsage; +#define kKeyUseSigning 0x01 +#define kKeyUseEncrypting 0x02 + +CU_KeyUsage getKeyUsage(bool isRoot); + +#endif +#ifdef __cplusplus +} +#endif + +#endif /* _CREATECERT_CERT_UI_H_ */ diff --git a/CertTool/cdsaUtils/cuEnc64.h b/CertTool/cdsaUtils/cuEnc64.h deleted file mode 100644 index 5527d8b9..00000000 --- a/CertTool/cdsaUtils/cuEnc64.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (c) 1998 Apple Computer, Inc. All rights reserved. - * - * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT - * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE - * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE COMPUTER, INC. AND THE - * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE COMPUTER, - * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL - * EXPOSE YOU TO LIABILITY. - *************************************************************************** - * - * enc64.h - encode/decode in 64-char IA5 format, per RFC 1421 - * - * Revision History - * ---------------- - * 9 Oct 96 Doug Mitchell at NeXT - * Created. - */ - -#ifndef _CK_ENC64_H_ -#define _CK_ENC64_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Given input buffer inbuf, length inlen, decode from 64-char IA5 format to - * binary. Result is malloced and returned; its length is returned in *outlen. - * NULL return indicates corrupted input. - */ -unsigned char *enc64(const unsigned char *inbuf, - unsigned inlen, - unsigned *outlen); // RETURNED - -/* - * Enc64, with embedded newlines every lineLen in result. A newline is - * the UNIX \n. Result is mallocd. - */ -unsigned char *enc64WithLines(const unsigned char *inbuf, - unsigned inlen, - unsigned linelen, - unsigned *outlen); // RETURNED - -/* - * Given input buffer inbuf, length inlen, decode from 64-char IA5 format to - * binary. Result is malloced and returned; its length is returned in *outlen. - * NULL return indicates corrupted input. All whitespace in inbuf is - * ignored. - */ -unsigned char *dec64(const unsigned char *inbuf, - unsigned inlen, - unsigned *outlen); - -/* - * Determine if specified input data is valid enc64 format. Returns 1 - * if valid, 0 if not. - */ -int isValidEnc64(const unsigned char *inbuf, - unsigned inbufLen); - -#ifdef __cplusplus -} -#endif - -#endif /*_CK_ENC64_H_*/ diff --git a/CertTool/cdsaUtils/fileIo.c b/CertTool/cdsaUtils/fileIo.c deleted file mode 100644 index 087513ae..00000000 --- a/CertTool/cdsaUtils/fileIo.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - File: fileIo.c - - Description: simple file read/write utilities - - Author: dmitch - - Copyright: © Copyright 2001 Apple Computer, Inc. All rights reserved. - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple - Computer, Inc. ("Apple") in consideration of your agreement to - the following terms, and your use, installation, modification - or redistribution of this Apple software constitutes acceptance - of these terms. If you do not agree with these terms, please - do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following - terms, and subject to these terms, Apple grants you a personal, - non-exclusive license, under Apple's copyrights in this - original Apple software (the "Apple Software"), to use, - reproduce, modify and redistribute the Apple Software, with - or without modifications, in source and/or binary forms; - provided that if you redistribute the Apple Software in - its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all - such redistributions of the Apple Software. Neither the - name, trademarks, service marks or logos of Apple Computer, - Inc. may be used to endorse or promote products derived from the - Apple Software without specific prior written permission from - Apple. Except as expressly stated in this notice, no other - rights or licenses, express or implied, are granted by Apple - herein, including but not limited to any patent rights that - may be infringed by your derivative works or by other works - in which the Apple Software may be incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. - APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, - REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE - OR IN COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, - INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION - AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED - AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING - NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#include -#include -#include -#include -#include -#include -#include -#include "fileIo.h" - -int writeFile( - const char *fileName, - const unsigned char *bytes, - unsigned numBytes) -{ - int rtn; - int fd; - - fd = open(fileName, O_RDWR | O_CREAT | O_TRUNC, 0600); - if(fd <= 0) { - return errno; - } - rtn = lseek(fd, 0, SEEK_SET); - if(rtn < 0) { - return errno; - } - rtn = write(fd, bytes, (size_t)numBytes); - if(rtn != (int)numBytes) { - if(rtn >= 0) { - printf("writeFile: short write\n"); - } - rtn = EIO; - } - else { - rtn = 0; - } - close(fd); - return rtn; -} - -/* - * Read entire file. - */ -int readFile( - const char *fileName, - unsigned char **bytes, // mallocd and returned - unsigned *numBytes) // returned -{ - int rtn; - int fd; - char *buf; - struct stat sb; - unsigned size; - - *numBytes = 0; - *bytes = NULL; - fd = open(fileName, O_RDONLY, 0); - if(fd <= 0) { - return errno; - } - rtn = fstat(fd, &sb); - if(rtn) { - goto errOut; - } - size = sb.st_size; - buf = malloc(size); - if(buf == NULL) { - rtn = ENOMEM; - goto errOut; - } - rtn = lseek(fd, 0, SEEK_SET); - if(rtn < 0) { - goto errOut; - } - rtn = read(fd, buf, (size_t)size); - if(rtn != (int)size) { - if(rtn >= 0) { - printf("readFile: short read\n"); - } - rtn = EIO; - } - else { - rtn = 0; - *bytes = buf; - *numBytes = size; - } -errOut: - close(fd); - return rtn; -} diff --git a/CertTool/cdsaUtils/fileIo.h b/CertTool/cdsaUtils/fileIo.h deleted file mode 100644 index 3db7233e..00000000 --- a/CertTool/cdsaUtils/fileIo.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - File: fileIo.h - - Description: simple file read/write utilities - - Author: dmitch - - Copyright: © Copyright 2001 Apple Computer, Inc. All rights reserved. - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple - Computer, Inc. ("Apple") in consideration of your agreement to - the following terms, and your use, installation, modification - or redistribution of this Apple software constitutes acceptance - of these terms. If you do not agree with these terms, please - do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following - terms, and subject to these terms, Apple grants you a personal, - non-exclusive license, under Apple's copyrights in this - original Apple software (the "Apple Software"), to use, - reproduce, modify and redistribute the Apple Software, with - or without modifications, in source and/or binary forms; - provided that if you redistribute the Apple Software in - its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all - such redistributions of the Apple Software. Neither the - name, trademarks, service marks or logos of Apple Computer, - Inc. may be used to endorse or promote products derived from the - Apple Software without specific prior written permission from - Apple. Except as expressly stated in this notice, no other - rights or licenses, express or implied, are granted by Apple - herein, including but not limited to any patent rights that - may be infringed by your derivative works or by other works - in which the Apple Software may be incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. - APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, - REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE - OR IN COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, - INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION - AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED - AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING - NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -int readFile( - const char *fileName, - unsigned char **bytes, // mallocd and returned - unsigned *numBytes); // returned - -int writeFile( - const char *fileName, - const unsigned char *bytes, - unsigned numBytes); - -#ifdef __cplusplus -} -#endif diff --git a/CertTool/cdsaUtils/oidParser.h b/CertTool/cdsaUtils/oidParser.h deleted file mode 100644 index 46ce10ad..00000000 --- a/CertTool/cdsaUtils/oidParser.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * oidParser.cpp - parse an Intel-style OID, with the assistance of dumpasn1.cfg. - * The config file islooked dfor int e following locations: - * - * current working directory (.) - * parent directory (..) - * The directory specified by the environment variable LOCAL_BUILD_DIR - * - * OidParser will still work if the config file is not found, but OIDs will be - * dispayed in raw hex format. - */ - -#ifndef _OID_PARSER_H_ -#define _OID_PARSER_H_ - -#include - -/* - * Generated strings go into a client-allocated char array of - * this size. - */ -#define OID_PARSER_STRING_SIZE 120 - -class OidParser -{ -private: - CSSM_DATA_PTR configData; // contents of dumpasn1.cfg -public: - /* costruct with noConfig true - skip reading config file */ - OidParser(bool noConfig=false); - ~OidParser(); - - /* - * Parse an Intel-style OID, generating a C string in - * caller-supplied buffer. - */ - void oidParse( - const unsigned char *oidp, - unsigned oidLen, - char *strBuf); - -}; - -#endif /* _OID_PARSER_H_ */ diff --git a/CertTool/cdsaUtils/pem.cpp b/CertTool/cdsaUtils/pem.cpp deleted file mode 100644 index aa2595a7..00000000 --- a/CertTool/cdsaUtils/pem.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - File: pem.h - - Description: PEM encode/decode routines - - Author: dmitch - - Copyright: © Copyright 2002 Apple Computer, Inc. All rights reserved. - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple - Computer, Inc. ("Apple") in consideration of your agreement to - the following terms, and your use, installation, modification - or redistribution of this Apple software constitutes acceptance - of these terms. If you do not agree with these terms, please - do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following - terms, and subject to these terms, Apple grants you a personal, - non-exclusive license, under Apple's copyrights in this - original Apple software (the "Apple Software"), to use, - reproduce, modify and redistribute the Apple Software, with - or without modifications, in source and/or binary forms; - provided that if you redistribute the Apple Software in - its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all - such redistributions of the Apple Software. Neither the - name, trademarks, service marks or logos of Apple Computer, - Inc. may be used to endorse or promote products derived from the - Apple Software without specific prior written permission from - Apple. Except as expressly stated in this notice, no other - rights or licenses, express or implied, are granted by Apple - herein, including but not limited to any patent rights that - may be infringed by your derivative works or by other works - in which the Apple Software may be incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. - APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, - REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE - OR IN COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, - INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION - AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED - AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING - NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "pem.h" -#include -#include -#include -#include "cuEnc64.h" - -int pemEncode( - const unsigned char *inData, - unsigned inDataLen, - unsigned char **outData, - unsigned *outDataLen, - const char *headerString) -{ - unsigned char *enc; - unsigned encLen; - - /* First base64 encode */ - enc = enc64WithLines(inData, inDataLen, 64, &encLen); - if(enc == NULL) { - /* malloc error is actually the only known failure */ - printf("***pemEncode: Error encoding file. Aborting.\n"); - return -1; - } - - /* estimate outsize - just be sloppy, way conservative */ - unsigned outSize = encLen + (2 * strlen(headerString)) + 200; - *outData = (unsigned char *)malloc(outSize); - sprintf((char *)*outData, "-----BEGIN %s-----\n%s-----END %s-----\n", - headerString, (char *)enc, headerString); - *outDataLen = strlen((char *)*outData); - - if((*outData)[*outDataLen - 1] == '\0') { - (*outDataLen)--; - } - free(enc); - return 0; -} - -int pemDecode( - const unsigned char *inData, - unsigned inDataLen, - unsigned char **outData, - unsigned *outDataLen) -{ - char *cp; - int freeCp = 0; - char *curr1, *curr2; - char *startPem = NULL; - char *endPem = NULL; - unsigned char *out; - unsigned outLen; - int ourRtn = 0; - - /* make the whole thing a NULL-terminated string */ - if(inData[inDataLen - 1] != '\0') { - cp = (char *)malloc(inDataLen + 1); - memmove(cp, inData, inDataLen); - cp[inDataLen] = '\0'; - inDataLen++; - freeCp = 1; - } - else { - /* already is */ - cp = (char *)inData; - } - - /* cp is start of NULL-terminated buffer, size inDataLen */ - /* skip over everything until "-----" */ - curr1 = strstr(cp, "-----"); - if(curr1 == NULL) { - printf("***pemDecode: no terminator found\n"); - ourRtn = -1; - goto abort; - } - - /* find end of separator line, handling both flavors of terminator */ - cp = curr1; - curr1 = strchr(cp, '\n'); - curr2 = strchr(cp, '\r'); - if((curr1 == NULL) & (curr2 == NULL)) { - printf("***pemDecode: Bad PEM format (1)\n"); - ourRtn = -1; - goto abort; - } - if(curr1 == NULL) { - startPem = curr2; - } - else { - startPem = curr1; - } - - /* startPem points to end of separator line */ - /* locate ending terminator and lop it off */ - curr1 = strstr(startPem, "-----"); - if(curr1 == NULL) { - printf("***pemDecode: Bad PEM format (2)\n"); - ourRtn = -1; - goto abort; - } - endPem = curr1; - /* endPem points to last PEM data plus one */ - - out = dec64((unsigned char *)startPem, endPem-startPem, &outLen); - if(out == NULL) { - printf("Bad PEM format (3)\n"); - ourRtn = -1; - goto abort; - } - *outData = out; - *outDataLen = outLen; -abort: - if(freeCp) { - free(cp); - } - return ourRtn; -} - diff --git a/CertTool/cdsaUtils/pem.h b/CertTool/cdsaUtils/pem.h deleted file mode 100644 index 02bbf5d7..00000000 --- a/CertTool/cdsaUtils/pem.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - File: pem.h - - Description: PEM encode/decode routines - - Author: dmitch - - Copyright: © Copyright 2002 Apple Computer, Inc. All rights reserved. - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple - Computer, Inc. ("Apple") in consideration of your agreement to - the following terms, and your use, installation, modification - or redistribution of this Apple software constitutes acceptance - of these terms. If you do not agree with these terms, please - do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following - terms, and subject to these terms, Apple grants you a personal, - non-exclusive license, under Apple's copyrights in this - original Apple software (the "Apple Software"), to use, - reproduce, modify and redistribute the Apple Software, with - or without modifications, in source and/or binary forms; - provided that if you redistribute the Apple Software in - its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all - such redistributions of the Apple Software. Neither the - name, trademarks, service marks or logos of Apple Computer, - Inc. may be used to endorse or promote products derived from the - Apple Software without specific prior written permission from - Apple. Except as expressly stated in this notice, no other - rights or licenses, express or implied, are granted by Apple - herein, including but not limited to any patent rights that - may be infringed by your derivative works or by other works - in which the Apple Software may be incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. - APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, - REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE - OR IN COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, - INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION - AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED - AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING - NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -int pemEncode( - const unsigned char *inData, - unsigned inFileLen, - unsigned char **outData, - unsigned *outDataLen, - const char *headerString); - -int pemDecode( - const unsigned char *inData, - unsigned inFileLen, - unsigned char **outData, - unsigned *outDataLen); - -#ifdef __cplusplus -} -#endif diff --git a/CertTool/cdsaUtils/printCert.h b/CertTool/cdsaUtils/printCert.h deleted file mode 100644 index 99fe5928..00000000 --- a/CertTool/cdsaUtils/printCert.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * parseCert.h - text-based cert parser using CL - */ - -#ifndef _PARSE_CERT_H_ -#define _PARSE_CERT_H_ - -#include -#include "oidParser.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* print one field */ -void printCertField( - const CSSM_FIELD &field, - OidParser &parser, - CSSM_BOOL verbose); - -int printCert( - const unsigned char *certData, - unsigned certLen, - CSSM_BOOL verbose); - -void printCertShutdown(); - -#ifdef __cplusplus -} -#endif - -#endif /* _PARSE_CERT_H_ */ diff --git a/CertTool/cdsaUtils/timeStr.cpp b/CertTool/cdsaUtils/timeStr.cpp deleted file mode 100644 index 0ce02bb5..00000000 --- a/CertTool/cdsaUtils/timeStr.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "timeStr.h" -#include -#include -#include -#include - -/* - * Given a string containing either a UTC-style or "generalized time" - * time string, convert to a struct tm (in GMT/UTC). Returns nonzero on - * error. - */ -int appTimeStringToTm( - const char *str, - unsigned len, - struct tm *tmp) -{ - char szTemp[5]; - unsigned isUtc; - unsigned x; - unsigned i; - char *cp; - - if((str == NULL) || (len == 0) || (tmp == NULL)) { - return 1; - } - - /* tolerate NULL terminated or not */ - if(str[len - 1] == '\0') { - len--; - } - switch(len) { - case UTC_TIME_STRLEN: // 2-digit year, not Y2K compliant - isUtc = 1; - break; - case GENERALIZED_TIME_STRLEN: // 4-digit year - isUtc = 0; - break; - default: // unknown format - return 1; - } - - cp = (char *)str; - - /* check that all characters except last are digits */ - for(i=0; i<(len - 1); i++) { - if ( !(isdigit(cp[i])) ) { - return 1; - } - } - - /* check last character is a 'Z' */ - if(cp[len - 1] != 'Z' ) { - return 1; - } - - /* YEAR */ - szTemp[0] = *cp++; - szTemp[1] = *cp++; - if(!isUtc) { - /* two more digits */ - szTemp[2] = *cp++; - szTemp[3] = *cp++; - szTemp[4] = '\0'; - } - else { - szTemp[2] = '\0'; - } - x = atoi( szTemp ); - if(isUtc) { - /* - * 2-digit year. - * 0 <= year < 50 : assume century 21 - * 50 <= year < 70 : illegal per PKIX - * 70 < year <= 99 : assume century 20 - */ - if(x < 50) { - x += 2000; - } - else if(x < 70) { - return 1; - } - else { - /* century 20 */ - x += 1900; - } - } - /* by definition - tm_year is year - 1900 */ - tmp->tm_year = x - 1900; - - /* MONTH */ - szTemp[0] = *cp++; - szTemp[1] = *cp++; - szTemp[2] = '\0'; - x = atoi( szTemp ); - /* in the string, months are from 1 to 12 */ - if((x > 12) || (x <= 0)) { - return 1; - } - /* in a tm, 0 to 11 */ - tmp->tm_mon = x - 1; - - /* DAY */ - szTemp[0] = *cp++; - szTemp[1] = *cp++; - szTemp[2] = '\0'; - x = atoi( szTemp ); - /* 1..31 in both formats */ - if((x > 31) || (x <= 0)) { - return 1; - } - tmp->tm_mday = x; - - /* HOUR */ - szTemp[0] = *cp++; - szTemp[1] = *cp++; - szTemp[2] = '\0'; - x = atoi( szTemp ); - if((x > 23) || (x < 0)) { - return 1; - } - tmp->tm_hour = x; - - /* MINUTE */ - szTemp[0] = *cp++; - szTemp[1] = *cp++; - szTemp[2] = '\0'; - x = atoi( szTemp ); - if((x > 59) || (x < 0)) { - return 1; - } - tmp->tm_min = x; - - /* SECOND */ - szTemp[0] = *cp++; - szTemp[1] = *cp++; - szTemp[2] = '\0'; - x = atoi( szTemp ); - if((x > 59) || (x < 0)) { - return 1; - } - tmp->tm_sec = x; - return 0; -} - diff --git a/CertTool/cdsaUtils/timeStr.h b/CertTool/cdsaUtils/timeStr.h deleted file mode 100644 index 2baac982..00000000 --- a/CertTool/cdsaUtils/timeStr.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _TIME_STR_H_ -#define _TIME_STR_H_ - -#include - -#define UTC_TIME_STRLEN 13 -#define GENERALIZED_TIME_STRLEN 15 - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Given a string containing either a UTC-style or "generalized time" - * time string, convert to a struct tm (in GMT/UTC). Returns nonzero on - * error. - */ -int appTimeStringToTm( - const char *str, - unsigned len, - struct tm *tmp); - -#ifdef __cplusplus -} -#endif - -#endif /* _TIME_STR_H_ */ \ No newline at end of file diff --git a/CertTool/certtool.1 b/CertTool/certtool.1 new file mode 100644 index 00000000..17f9ab38 --- /dev/null +++ b/CertTool/certtool.1 @@ -0,0 +1,436 @@ +.de EX +.nf +.ft CW +.RS + +.. +.de EE +.br +.fi +.ft 1 +.RE +.PP +.. +.de BL +.TP +\(bu +.. +.TH CERTTOOL 1 "March 19, 2003" "Apple Computer, Inc." +.SH NAME +certtool \- create key pairs, certificates and certificate signing requests for +use with Keychains +.SH SYNOPSIS +.B certtool +command [command-args] [options] +.PP +.B certtool +c [options] +.PP +.B certtool +r outFileName [options] +.PP +.B certtool +v infileName [options] +.PP +.B certtool +i inFileName [options] +.PP +.B certtool +d inFileName [options] +.PP +.B certtool +I inFileName [options] +.PP +.B certtool +D inFileName [options] +.PP +.B certtool +y [options] +.SH CERTTOOL COMMAND SUMMARY +.B c +Create keypair and Certificate +.PP +.B r +Create CSR +.PP +.B v +Verify CSR +.PP +.B i +Import Certificate +.PP +.B d +Display Certificate +.PP +.B I +Import CRL +.PP +.B D +Display CRL +.PP +.B I +Import a CRL +.PP +.B y +Display all certs and CRLs in keychain +.PP +.SH "CERTTOOL OPTION SUMMARY" +.TP +.B c +Create the keychain, if one is needed. +.TP +.B d +Create a CSR in DER format; default is PEM +.TP +.B k=keychainName +Specify the Keychain to use for the operation. If keychainName starts with a '/', an absolute path is assumed; otherwise, the specified filename is relative to the user's Library/Keychains directory. +.TP +.B p=passphrase +Specify the keychain passphrase when creating +.TP +.B r=privateKeyFileName +Optional private key, for Import Certificate only +.TP +.B f=[18f] +Private Key Format = PKCS1/PKCS8/FIPS186; default is PKCS1 (openssl) +.TP +.B a +Generate private key with default ACL +.TP +.B h +Print usage message +.TP +.B v +Execute in verbose mode. +.SH "DESCRIPTION" +.B Certtool +is a UNIX command-line program which is used to create key pairs, certificates, +and certificate signing requests; to import externally generated certificates +and Certificate Revocation Lists (CRLs) into a Keychain, and to display the +contents of certificates and CRLs. Currently, the primary use of CertTool is +to perform the certificate-related administration required to configure an +SSL server based on Mac OS X's SecureTransport library. +.SH EXAMPLES +.PP +.B "Generating a Self-Signed Certificate" +.PP +This command generates a key pair and a self-signed (root) certificate +and places them in a keychain. The root cert is signed by the private +key generated during this command. The cert generated by this command +is totally untrustworthy and cannot be used in the "real world"; the +primary use of this command is to facilitate early development of SSL +server applications based on SecureTransport. In particular, +"real world" SSL clients (e.g., web browsers) will complain to +varying degrees when they attempt to connect to an SSL server which +presents a cert which is generated by this command. Some broswers, +after a fair amount of handholding, will allow you to conditionally +"trust" this cert. +.EX +# CertTool c [options] +.EE +The available options are: +.TP +k=keyChainName +.PP +Where "keyChainName" is the name of the keychain into which keys and the cert +will be added. If no keychain is specified, keys and certs are added to the +default keychain. The specified keychain must exist unless you specify the 'c' +option. +.TP +c +.PP +Specifies that the designated keychain is to be created. +.PP +This an interactive command; you will be prompted for a number of different +items which are used to generate the keypair and the cert. A sample session +follows. +.EX +# CertTool k=certkc +Enter key and certificate label: testCert + +Please specify parameters for the key pair you will generate. + + r RSA + d DSA + f FEE + +Select key algorithm by letter: r + +Valid key sizes for RSA are 512..2048; default is 512 +Enter key size in bits or CR for default: 512 + +You have selected algorithm RSA, key size 512 bits. +OK (y/anything)? y +Enter cert/key usage (s=signing, b=signing AND encrypting): b + ...Generating key pair... + +.EE +Note: you will be prompted for the Keychain's passphrase by the Keychain +system at this point if the specified keychain is not open and you have not specified the passphrase via the 'p' option. +.EX +Please specify the algorithm with which your certificate will be signed. + + 5 RSA with MD5 + s RSA with SHA1 + +Select signature algorithm by letter: s + +You have selected algorithm RSA with SHA1. +OK (y/anything)? y +...creating certificate... +.EE +You will now specify the various components of the certificate's +Relative Distinguished Name (RDN). An RDN has a number of +components, all of which are optional, but at least one of +which must be present. +.PP +Note that if you are creating a certificate for use in an +SSL/TLS server, the Common Name component of the RDN must match +exactly the host name of the server. This must not be an IP +address, but the actual domain name, e.g. www.apple.com. +Entering a CR for a given RDN component results in no value for +that component. +.EX +Common Name (e.g, www.apple.com) : 10.0.61.5 +Country (e.g, US) : +Organization (e.g, Apple Computer, Inc.) : Apple +Organization Unit (e.g, Apple Data Security) : +State/Province (e.g., California) : California + +You have specified: + Common Name : 10.0.61.5 + Organization : Apple + State/Province : California +Is this OK (y/anything)? y +..cert stored in Keychain. +# +.EE +The "Common Name" portion of the RDN - in the above case, "10.0.61.5" - MUST +match the host name of the machine you'll running sslServer on. (In this case +the test machine doesn't have an actual hostname; it's DHCP'd behind a firewall +which is why "10.0.61.5" was specified for Common Name.) This is part of SSL's +certificate verification; it prevents an attack using DNS spoofing. +.PP +A brief note about cert/key usage: the normal configuration of SecureTransport +is that the server cert specified in SSLSetCertificate() is capable of both +signing and encryption. If this cert is only capable of signing, then you must +create a second keychain ontaining a cert which is capable of encryption, and +pass that to SSLSetEncryptionCertificate(). +.PP +.B "Generating a Certificate Signing Request (CSR)" +.PP +A CSR is the standard means by which an administrator of a web server provides +information to a Certificate Authority (CA) in order to obtain a valid +certificate which is signed by the CA. This type of cert is used in the real +world; certs signed by CAs such as Verisign or Thawte are recognized by all web +browsers when performing SSL transactions. +.PP +The general procedure for obtaining a "real" cert is: +.BL +Generate a key pair +.BL +Generate a CSR +.BL +Provide the CSR and some other information and/or documentation to the CA +.BL +CA sends you a certificate which is signed by the CA. +.BL +You import that certificate, obtained from the CA, into your keychain. +.PP +The +items in that keychain can now be used in SecureTransport's SSLSetCertificate() +call. +.PP +This command performs the first two steps in the above procedure. See the +section below entitled "Importing a Certificate" for information on +importing the resulting certificate into your keychain. The format of +this command is +.EX +# CertTool r outFileName [options] +.EE +The resulting CSR will be written to "outFileName". +The available options are: +.EX +k=keyChainName +.EE +Where "KeyChainName" is the name of the keychain into which keys and the cert +will be added. If no keychain is specified, keys and certs are added to the +default keychain. The specified keychain must exist unless you specify the 'c' +option. +.EX + d +.EE +The 'd' option tells CertTool to create the CSR in DER-encoded format. The +default is PEM-encoded, which is what most CAs expect. PEM encoded data consists +of printable ASCII text which can, for example, be pasted into an email message. +DER-encoded data is nonprintable binary data. +.EX + c +.EE +Specifies that the designated keychain is to be created. +.PP +This an interactive command; you will be prompted for a number of different +items which are used to generate the keypair and the CSR. The prompts given, and +the format of the data you must supply, are identical to the data shown in the +sample session in Section 2. +.PP +.B "Verifying a CSR" +.PP +A CSR contains, among other things, the public key which was generated in +as described above. The CSR is signed with the associated private key. Thus the +integrity of a CSR can be verified by extracting its public key and verifying the signature of the CSR. This command performs this integrity check. The format of this command is +.EX +# CertTool v inFileName [options] +.EE +The only available option is the 'd' flag, which as described above in the +section entitled "Generating a Certificate Signing Request", indiciates +that the CSR is in DER format rather than the default PEM format. +A typical (successful) run of this command is like so: +.EX +# CertTool v myCsr.pem + ...CSR verified successfully. +.EE +A large number of things can go wrong if the verification fails; suffice it to +say that if you see anything other than the above success message, you have a +bad or corrupted CSR. +.PP +.B "Importing a Certificate from a Certificate Authority" +.PP +Once you have negotiated with your CA, and provided them with the CSR generated +as described above as well as any other information, documentation, and payment they +require, the CA will provide you with a certificate. Use this command to add +that certificate to the keychain containing the keypair you generated previously. +.PP +The format of this command is +.EX +# CertTool i inFileName [options] +.EE +The cert to import is obtained from "inFileName". The available options are: +.EX +k=keyChainName +.EE +Where "keyChainName" is the name of the keychain to which the cert will be +added. If no keychain is specified, the cert is added to the default keychain. +The specified keychain typically contains the keypair you generated previously. +(Note you can import a certificate into a keychain which does not contain keys +you generated but there will be no linkage between the imported certificate and +a private key if you do this.) If the keychain is not open when this command is +executed, you will be prompted by the Keychain system for its passphrase. +.EX +r=privateKeyFileName +.EE +Where "privateKeyFileName" is the name of the optional private key file to imported along with the certificate. This option is used to import cert/key pairs which are generated by other means, such as OpenSSL. +.EX +f=privateKeyFormat +.EE +Where "privateKeyFormat" is the format of the private key specified with the 'r' option. The formats are: '1' for PKCS1 (OpenSSL format), '8' (PKCS8), and 'f' (FIPS186, BSAFE format). The default is OpenSSL format for both RSA and DSA keys. +.EX + d +.EE +Specifies DER format as described above. The default is PEM format. +.EX + c +.EE +Specifies that the designated keychain is to be created. +.PP +.B "Displaying a Certificate" +.PP +This displays the contents of an existing certificate, obtained from a file. +The format of this command is +.EX +# CertTool d inFileName [options] +.EE +The cert to display is obtained from "inFileName". +The only available option is the 'd' flag, specifying DER format as described above. The default is PEM format. Actually, in the absence of this option, certtool will correctly determine the format of the certificate (PEM or DER). +.PP +.B "Importing a CRL" +.PP +This command is used to add a Certificate Revocation List (CRL) to a keychain. +The format of this command is +.EX +# CertTool I inFileName [options] +.EE +The CRL to import is obtained from "inFileName". The available options are: +.EX +k=keyChainName +.EE +Where "KeyChainName" is the name of the keychain to which the CRL will be added. +If no keychain is specified, the cert is added to the default keychain. If the +keychain is not open when this command is executed, you will be prompted by the +Keychain system for its passphrase. +.EX + d +.EE +Specifies DER format as described above. The default is PEM format. +.EX + c +.EE +Specifies that the designated keychain is to be created. +.PP +.B "Displaying a CRL" +.PP +This displays the contents of an existing Certificate Revocation List (CRL), +obtained from a file. The format of this command is +.EX +# CertTool D inFileName [options] +.EE +The cert to display is obtained from "inFileName". +The only available option is the 'd' flag, specifying DER format as described +above. The default is PEM format. +.PP +.B "Displaying Certificates and CRLs in a keychain" +.PP +This displays the contents of all certificates and CRLs in a keychain. The format of this command is +.EX +# CertTool y [options] +.EE +The available options are: +.EX +k=keyChainName +.EE +Where "KeyChainName" is the name of the keychain to display. +.EX +v +.EE +Specifies verbose mode. +.PP +.B "Certificate Authorities and CSRs" +.PP +As mentioned above, the general procedure for obtaining a "real" cert is: +.BL +Generate a key pair +.BL +Generate a CSR +.BL +Provide the CSR and some other information and/or documentation to the CA +.BL +CA sends you a certificate which is signed by the CA. +.BL +You import that certificate, obtained from the CA, into your keychain. +.PP +The items in that keychain can now be used in SecureTranspoert's SSLSetCertificate() +call. +.PP +One CA with an excellent web-based interface for obtaining a cert is Verisign +(http://www.verisign.com/products/site/index.html). You can get a free 14-day +trial certificate using nothing but CertTool, Verisign's web site, and email. +You need to provide some personal information; then you paste in the CSR +generated as described in the section entitled "Generating a Certificate +Signing Request" into a form on the web site. A few minutes later Verisign +emails you a certificate, which you import into your keychain. +The whole process takes less than 10 minutes. The free certificate obtained in +this manner is signed by a temporary root cert which is not recognized by any +browsers, but Verisign also provides a means of installing this temporary root +cert into your browser, directly from their web site. Typically one would use +the free, temporary cert to perform initial configuration of a server and to +ring out the general SSL infrastructure. Once you feel comfortable with the +operation of the server, then it's time to buy a "real" certificate which will +allow your web server to be recognized by any browser. +.PP +Thawte has a similar, very friendly service at http://www.thawte.com/. +Note that, for early web server development and/or testing, you can skip the entire procedure described above and just generate your own self-signed root cert as described above. No CA is involved; no CSR is generated; no cert needs to be imported - CertTool generates a cert for you and immediately adds it to your keychain. Bear in mind that this option requires tolerance of the various SSL clients you'll be testing with, none of whom recognize your root cert. +.SH FILES +.B /System/Library/Keychains/X509Anchors +System root certificate database +.SH SEE ALSO +.BR openssl ( 1 ) diff --git a/CertTool/cdsaUtils/dumpasn1.cfg b/CertTool/dumpasn1.cfg similarity index 99% rename from CertTool/cdsaUtils/dumpasn1.cfg rename to CertTool/dumpasn1.cfg index 71d18743..dc7b0e6b 100644 --- a/CertTool/cdsaUtils/dumpasn1.cfg +++ b/CertTool/dumpasn1.cfg @@ -1175,8 +1175,8 @@ Warning OID = 06 05 2B 0E 03 02 0D Comment = Oddball OIW OID. Incorrectly used by JDK 1.1 in place of (1 3 14 3 2 27) # Their response was that they know it's wrong, but noone uses SHA0 so it won't -# cause any problems, right? -Description = dsaWithSHA (1 3 14 3 2 13) +# cause any problems, right? Note: BSAFE uses this as well! +Description = dsaWithSHA-bsafe (1 3 14 3 2 13) Warning # The various mdWithRSASIsignature OIDs are for the ANSI X9.31 draft and use @@ -2106,7 +2106,7 @@ Description = invalidityDate (2 5 29 24) OID = 06 03 55 1D 19 Comment = X.509 id-ce (2 5 29). Deprecated, use (2 5 29 31) instead -Description = cRLDistributionPoints (2 5 29 25) +Description = cRLDistributionPoints (2 5 29 25) deprecated Warning OID = 06 03 55 1D 1A @@ -2912,4 +2912,14 @@ OID = 06 0B 60 86 48 01 86 F8 4D 02 02 05 51 Comment = CDSA SHA1 with ECDSA Description = sha1WithECDSA (OID 2 16 840 1 113741 2 2 5 81) +# Microsoft Cert Authority Renewal Version +OID = 06 09 2B 06 01 04 01 82 37 15 01 +Comment = Microsoft Cert Authority Renewal Version +Description = certSrv-ca-version (OID 1 3 6 1 4 1 311 21 1) + +# Fictitious US DOD CRL entry extension +OID = 06 09 60 86 48 01 65 02 01 0C 02 +Comment = Fictitious US DOD CRL entry extension +Description = id-test-extension (OID 2 16 840 1 101 2 1 12 2) + # End of Fahnenstange diff --git a/CrlRefresh/crlRefresh.cpp b/CrlRefresh/crlRefresh.cpp new file mode 100644 index 00000000..5ddf4af0 --- /dev/null +++ b/CrlRefresh/crlRefresh.cpp @@ -0,0 +1,1202 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + * Examine the CRLs in the system CRL cache, looking for expired CRLs + * for which we don't have current valid entries. Perform net fetch for + * all such entries to get up-to-date entries. Purge entries older + * than specified date (i.e., "stale" CRLs). + * + * Terminology used here: + * + * 'nowTime' is the absolute current time. + * 'updateTime' is the time at which we evaluate a CRL's NextUpdate + * attribute to determine whether a CRL has expired. This is + * generally subsequent to nowTime. + * 'expired' means that a CRL's NextUpdate time has passed, relative + * to updateTime, and that we need to fetch a new CRL to replace + * the expired CRL. + * 'expireOverlap' is (nowTime - updateTime) in seconds. It's the + * distance into the future at which we evaluate a CRL's expiration + * status. + * 'stale' means that a CRL is so old that it should be deleted from + * the cache. + * 'staleTime' is maximum age (relative to nowTime) that a CRL can + * achieve in cache before being deemed stale. StaleTime is always + * greater than expireOverlap (i.e., if a CRL is stale, it MUST be + * expired, but a CRL can be expired without being stale). + * + * CRLs are only deleted from cache if they are stale; multiple + * CRLs from one CA may exist in cache at a given time but (generally) + * only one of them is not expired. + * + * expireOverlap and staleTime have defaults which can be overridden + * via command line arguments. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ldapFetch.h" +#include +#include +#include +#include +#include + +#define DEFAULT_STALE_DAYS 10 +#define DEFAULT_EXPIRE_OVERLAP_SECONDS 3600 + +#define SECONDS_PER_DAY (60 * 60 * 24) + +#define CRL_CACHE_DB "/var/db/crls/crlcache.db" +#define X509_CERT_DB "/System/Library/Keychains/X509Certificates" + +#ifdef NDEBUG +#define DEBUG_PRINT 0 +#else +#define DEBUG_PRINT 1 +#endif + +#if DEBUG_PRINT +#define dprintf(args...) fprintf(stderr, args) +#else +#define dprintf(args...) +#endif + +static void usage(char **argv) +{ + printf("Usage\n"); + printf("Refresh : %s r [options]\n", argv[0]); + printf("Fetch CRL : %s f URI [options]\n", argv[0]); + printf("Fetch cert : %s F URI [options]\n", argv[0]); + printf("Refresh options:\n"); + printf(" s=stale_period in DAYS; default=%d\n", DEFAULT_STALE_DAYS); + printf(" o=expire_overlap in SECONDS; default=%d\n", + DEFAULT_EXPIRE_OVERLAP_SECONDS); + printf(" p (Purge all entries, ensuring refresh with fresh CRLs)\n"); + printf(" f (Full crypto CRL verification)\n"); + printf(" k=keychainName (default=%s\n", CRL_CACHE_DB); + printf(" v(erbose)\n"); + printf("Fetch options:\n"); + printf(" F=outFileName (default is stdout)\n"); + printf(" n (no write to cache after fetch)\n"); + exit(1); +} + +/* + * Print string. Null terminator is not assumed. + */ +static void printString( + const CSSM_DATA *str) +{ + unsigned i; + char *cp = (char *)str->Data; + for(i=0; iLength; i++) { + printf("%c", *cp++); + } +} + +/* declare a CSSM_DB_ATTRIBUTE_INFO with NAME_AS_STRING */ +#define DB_ATTRIBUTE(name, type) \ + { CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \ + {#name}, \ + CSSM_DB_ATTRIBUTE_FORMAT_ ## type \ + } + +/* The CRL DB attributes we care about*/ +/* Keep these positions in sync with ATTR_DEX_xxx, below */ +static const CSSM_DB_ATTRIBUTE_INFO x509CrlRecordAttrs[] = { + DB_ATTRIBUTE(CrlType, UINT32), // 0 + DB_ATTRIBUTE(CrlEncoding, UINT32), // 1 + DB_ATTRIBUTE(PrintName, BLOB), // 2 + DB_ATTRIBUTE(Issuer, BLOB), // 3 + DB_ATTRIBUTE(NextUpdate, BLOB), // 4 + DB_ATTRIBUTE(URI, BLOB), // 5 + + /* we don't use these */ + // DB_ATTRIBUTE(ThisUpdate, BLOB), // 4 + // DB_ATTRIBUTE(DeltaCrlNumber, UINT32) + // DB_ATTRIBUTE(Alias, BLOB), + // DB_ATTRIBUTE(CrlNumber, UINT32), +}; + +#define NUM_CRL_ATTRS \ + (sizeof(x509CrlRecordAttrs) / sizeof(x509CrlRecordAttrs[0])) + +#define ATTR_DEX_CRL_TYPE 0 +#define ATTR_DEX_CRL_ENC 1 +#define ATTR_DEX_PRINT_NAME 2 +#define ATTR_DEX_ISSUER 3 +#define ATTR_DEX_NEXT_UPDATE 4 +#define ATTR_DEX_URI 5 + +/* free attribute(s) allocated by DL */ +static void freeAttrs( + CSSM_DB_ATTRIBUTE_DATA *attrs, + unsigned numAttrs) +{ + unsigned i; + + for(i=0; iNumberOfValues; j++) { + CSSM_DATA_PTR data = &attrData->Value[j]; + if(data == NULL) { + /* fault of DL, who said there was a value here */ + printf("***freeAttrs screwup: NULL data\n"); + return; + } + APP_FREE(data->Data); + data->Data = NULL; + data->Length = 0; + } + APP_FREE(attrData->Value); + attrData->Value = NULL; + } +} + +/* + * Compare two CSSM_TIMESTRINGs. Returns: + * -1 if t1 < t2 + * 0 if t1 == t2 + * 1 if t1 > t2 + */ +int compareTimes( + const char *t1, + const char *t2) +{ + for(unsigned dex=0; dex *t2) { + return 1; + } + if(*t1 < *t2) { + return -1; + } + /* else same, on to next byte */ + } + /* equal */ + return 0; +} + +/* + * everything we know or care about a CRL. + */ +class CrlInfo +{ +public: + CrlInfo( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_DB_ATTRIBUTE_DATA *attrData, // [NUM_CRL_ATTRS] + CSSM_DB_UNIQUE_RECORD_PTR record, + CSSM_DATA_PTR crlBlob); // optional + ~CrlInfo(); + + CSSM_DATA_PTR fetchValidAttr( + unsigned attrDex); + int fetchIntAttr( + unsigned dex, + uint32 &rtn); + + bool isSameIssuer( + CrlInfo *other); + + /* print the printable name + '\n' to stdout */ + void printName(); + + void validateTimes( + const char *updateTime, + const char *staleTime, + unsigned dex); + + /* state inferred from attributes, and maintained by + * owner (not by us) */ + bool mIsBadlyFormed; // general parse error + bool mIsExpired; // compare to 'now' + bool mIsStale; // compared to "staleTime' + bool mRefreshed; // already refreshed + + /* + * Actual CRL, optionally fetched from DB if doing a full crypto verify + */ + CSSM_DATA mCrlBlob; + + + /* accessors for read-only member vars */ + CSSM_DL_DB_HANDLE dlDbHand() { return mDlDbHand; } + CSSM_DB_ATTRIBUTE_DATA_PTR attrData() { return &mAttrData[0]; } + CSSM_DB_UNIQUE_RECORD_PTR record() { return mRecord; }; + +private: + /* member variables which are read-only subsequent to construction */ + CSSM_DL_DB_HANDLE mDlDbHand; + + /* + * array of attr data + * contents APP_MALLOCd by DL + * contents APP_FREEd by our destructor + */ + CSSM_DB_ATTRIBUTE_DATA mAttrData[NUM_CRL_ATTRS]; + + /* + * For possible use in CSSM_DL_DataDelete + * Our destructor does CSSM_DL_FreeUniqueRecord + */ + CSSM_DB_UNIQUE_RECORD_PTR mRecord; +}; + +CrlInfo::CrlInfo( + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_DB_ATTRIBUTE_DATA *attrData, // [NUM_CRL_ATTRS] + CSSM_DB_UNIQUE_RECORD_PTR record, + CSSM_DATA_PTR crlBlob) // optional + : mIsBadlyFormed(false), + mIsExpired(false), + mIsStale(false), + mRefreshed(false), + mDlDbHand(dlDbHand), + mRecord(record) +{ + if(crlBlob) { + mCrlBlob = *crlBlob; + } + else { + mCrlBlob.Data = NULL; + mCrlBlob.Length = 0; + } + memmove(mAttrData, attrData, + sizeof(CSSM_DB_ATTRIBUTE_DATA) * NUM_CRL_ATTRS); +} + +CrlInfo::~CrlInfo() +{ + freeAttrs(&mAttrData[0], NUM_CRL_ATTRS); + CSSM_DL_FreeUniqueRecord(mDlDbHand, mRecord); + if(mCrlBlob.Data) { + APP_FREE(mCrlBlob.Data); + } +} + +/* + * Is attribute at specified index present with one value? Returns the + * value if so, else returns NULL. + */ +CSSM_DATA_PTR CrlInfo::fetchValidAttr( + unsigned attrDex) +{ + if(mAttrData[attrDex].NumberOfValues != 1) { + return NULL; + } + return mAttrData[attrDex].Value; +} + +/* + * Fetch uint32 attr if it's there at specified attr index. + * Returns non zero if it's not there and flags the CRL as bad. + */ +int CrlInfo::fetchIntAttr( + unsigned dex, + uint32 &rtn) +{ + CSSM_DATA *val = fetchValidAttr(dex); + if((val == NULL) || (val->Length != sizeof(uint32))) { + dprintf("***Badly formed uint32 attr at dex %u\n", dex); + mIsBadlyFormed = true; + return 1; + } + rtn = cuDER_ToInt(val); + return 0; +} + + +/* + * See if two CRLs have same issuer. Requires (and verifies) that both + * issuer attrs are well formed. + */ +bool CrlInfo::isSameIssuer( + CrlInfo *other) +{ + CSSM_DATA_PTR thisIssuer = fetchValidAttr(ATTR_DEX_ISSUER); + if(thisIssuer == NULL) { + return false; + } + CSSM_DATA_PTR otherIssuer = other->fetchValidAttr(ATTR_DEX_ISSUER); + if(otherIssuer == NULL) { + return false; + } + return cuCompareCssmData(thisIssuer, otherIssuer) ? true : false; +} + +/* Print a CRL's PrintName attr */ +void CrlInfo::printName() +{ + CSSM_DATA_PTR val = fetchValidAttr(ATTR_DEX_PRINT_NAME); + if(val == NULL) { + printf("X509 CRL\n"); + } + else { + printString(val); + printf("\n"); + } +} + +/* + * Given time strings representing 'update time' and 'stale time', + * calculate mIsExpired and mIsStale. + */ +void CrlInfo::validateTimes( + const char *updateTime, // now - expireOverlap + const char *staleTime, // now - staleTime + unsigned dex) // for debug info +{ + CSSM_DATA *nextUpdateData = fetchValidAttr(ATTR_DEX_NEXT_UPDATE); + if((nextUpdateData == NULL) || + (nextUpdateData->Length != CSSM_TIME_STRLEN)) { + printf("***Badly formed NextUpdate attr on CRL %u\n", dex); + mIsBadlyFormed = true; + return; + } + #if DEBUG_PRINT + printf("Crl %u NextUpdate : ", dex); printString(nextUpdateData); + printf("\n"); + #endif + char *nextUpdate = (char *)nextUpdateData->Data; + if(compareTimes(nextUpdate, updateTime) < 0) { + dprintf("...CRL %u is expired\n", dex); + mIsExpired = true; + if(compareTimes(nextUpdate, staleTime) < 0) { + dprintf("...CRL %u is stale\n", dex); + mIsStale = true; + } + /* note it can't be stale and not expired */ + } +} + +/* + * Fetch attrs for all CRLs from DB. CRL blobs themselves are not fetched + * unless the fetchBlobs argument is asserted. + */ +static CSSM_RETURN fetchAllCrls( + CSSM_DL_DB_HANDLE dlDbHand, + bool fetchBlobs, // fetch actual CRL data + CrlInfo **&rtnCrlInfo, // RETURNED + unsigned &numCrls) // RETURNED +{ + CSSM_QUERY query; + CSSM_DB_RECORD_ATTRIBUTE_DATA recordAttrs; + CSSM_DB_UNIQUE_RECORD_PTR record = NULL; + CSSM_RETURN crtn; + CSSM_HANDLE resultHand; + unsigned attrDex; + CSSM_DB_ATTRIBUTE_DATA attrData[NUM_CRL_ATTRS]; + CSSM_DATA_PTR crlDataPtr = NULL; + CSSM_DATA crlData; + + numCrls = 0; + rtnCrlInfo = NULL; + + /* build an ATTRIBUTE_DATA array from list attrs */ + memset(attrData, 0, sizeof(CSSM_DB_ATTRIBUTE_DATA) * NUM_CRL_ATTRS); + for(attrDex=0; attrDexfetchIntAttr(ATTR_DEX_CRL_TYPE, i)) { + continue; + } + switch(i) { + case CSSM_CRL_TYPE_X_509v1: + case CSSM_CRL_TYPE_X_509v2: + /* OK */ + break; + default: + printf("***bad CRL type (%u) on CRL %u\n", (unsigned)i, dex); + crl->mIsBadlyFormed = true; + continue; + } + + /* ditto for encoding */ + if(crl->fetchIntAttr(ATTR_DEX_CRL_ENC, i)) { + continue; + } + switch(i) { + case CSSM_CRL_ENCODING_BER: + case CSSM_CRL_ENCODING_DER: + /* OK */ + break; + default: + printf("***bad CRL encoding (%u) on CRL %u\n", + (unsigned)i, dex); + crl->mIsBadlyFormed = true; + continue; + } + /* any other grounds for deletion? */ + } +} + +/* + * Perform full crypto CRL validation. + * We use the system-wide intermediate cert keychain here, but do + * NOT use the CRL cache we're working on (or any other), since + * we dont' really want to trust anything at this point. + */ +static void cryptoValidateCrls( + CrlInfo **crlInfo, + unsigned numCrls, + bool verbose, + CSSM_TP_HANDLE tpHand, + CSSM_CSP_HANDLE cspHand, + CSSM_CL_HANDLE clHand, + CSSM_DL_HANDLE dlHand) +{ + CrlInfo *crl; + const CSSM_DATA *anchors; + uint32 anchorCount; + OSStatus ortn; + + /* just snag these once */ + ortn = SecTrustGetCSSMAnchorCertificates(&anchors, &anchorCount); + if(ortn) { + printf("SecTrustGetCSSMAnchorCertificates returned %u\n", (int)ortn); + return; + } + + /* and the system-wide intermediate certs */ + CSSM_DL_DB_HANDLE certDb; + CSSM_DL_DB_HANDLE_PTR certDbPtr = NULL; + CSSM_RETURN crtn = CSSM_DL_DbOpen(dlHand, + X509_CERT_DB, + NULL, // DbLocation + CSSM_DB_ACCESS_READ, + NULL, // CSSM_ACCESS_CREDENTIALS *AccessCred + NULL, // void *OpenParameters + &certDb.DBHandle); + if(crtn) { + cuPrintError("CSSM_DL_DbOpen", crtn); + printf("***Error opening intermediate cert file %s.\n", X509_CERT_DB); + /* Oh well, keep trying */ + } + else { + certDb.DLHandle = dlHand; + certDbPtr = &certDb; + } + + for(unsigned dex=0; dexmCrlBlob, + certDbPtr, + anchors, + anchorCount); + switch(crtn) { + case CSSMERR_APPLETP_CRL_EXPIRED: + /* special case, we'll handle this via its attrs */ + case CSSM_OK: + break; + default: + if(verbose) { + printf("...CRL %u FAILED crypto verify\n", dex); + } + crl->mIsBadlyFormed = true; + break; + } + } + CSSM_DL_DbClose(certDb); +} + +/* + * Calculate expired/stale state for all CRLs. + */ +int calcCurrent( + CrlInfo **crlInfo, + unsigned numCrls, + int expireOverlapSeconds, + int staleTimeSeconds) +{ + if(expireOverlapSeconds > staleTimeSeconds) { + printf("***ExpireOverlap greater than StaleTime; aborting.\n"); + return 1; + } + char *updateTime = cuTimeAtNowPlus(expireOverlapSeconds, TIME_CSSM); + char *staleTime = cuTimeAtNowPlus(-staleTimeSeconds, TIME_CSSM); + + dprintf("updateTime : %s\n", updateTime); + dprintf("staleTime : %s\n", staleTime); + + for(unsigned dex=0; dexvalidateTimes(updateTime, staleTime, dex); + } + APP_FREE(updateTime); + APP_FREE(staleTime); + return 0; +} + +/* + * Mark all CRLs as stale (i.e., force them to be deleted later). + */ +static void purgeAllCrls( + CrlInfo **crlInfo, + unsigned numCrls, + bool verbose) +{ + for(unsigned dex=0; dexmIsExpired = true; + crl->mIsStale = true; + } +} + +/* + * Delete all stale and badly formed CRLs from cache. + */ +static void deleteBadCrls( + CrlInfo **crlInfo, + unsigned numCrls, + bool verbose) +{ + CrlInfo *crl; + + for(unsigned dex=0; dexmIsBadlyFormed || crl->mIsStale) { + if(verbose || DEBUG_PRINT) { + printf("...deleting CRL %u from ", dex); + crl->printName(); + } + CSSM_RETURN crtn = CSSM_DL_DataDelete(crl->dlDbHand(), + crl->record()); + if(crtn) { + cuPrintError("CSSM_DL_DataDelete", crtn); + } + } + } +} + +/* + * For each expired CRL, fetch a new one if we don't have a current + * CRL from the same place. + */ +static void refreshExpiredCrls( + CrlInfo **crlInfo, + unsigned numCrls, + CSSM_CL_HANDLE clHand, + bool verbose) +{ + CrlInfo *crl; + bool haveCurrent; + CSSM_DATA newCrl; + + for(unsigned dex=0; dexmIsExpired || crl->mRefreshed) { + continue; + } + + /* do we have one for the same issuer that's current? */ + haveCurrent = false; + for(unsigned i=0; imIsBadlyFormed) { + /* forget this one */ + continue; + } + if(checkCrl->mIsExpired && !checkCrl->mRefreshed) { + continue; + } + if(crl->isSameIssuer(checkCrl)) { + /* have a match; this one's OK */ + dprintf("up-to-date CRL at dex %u matching expired CRL %u\n", + i, dex); + haveCurrent = true; + break; + } + } + if(haveCurrent) { + continue; + } + + /* + * Not all CRLs have a URI attribute, which is required for + * refresh + */ + CSSM_DATA_PTR uri = crl->fetchValidAttr(ATTR_DEX_URI); + if(uri == NULL) { + dprintf("Expired CRL with no URI at dex %u\n", dex); + continue; + } + + /* fetch a new one */ + if(verbose || DEBUG_PRINT) { + printf("...fetching new CRL from net to update CRL %u from ", + dex); + crl->printName(); + } + CSSM_RETURN crtn = netFetch(*uri, LT_Crl, newCrl); + if(crtn) { + cuPrintError("netFetch", crtn); + continue; + } + + /* store it in the DB */ + crtn = cuAddCrlToDb(crl->dlDbHand(), clHand, &newCrl, uri); + + /* + * One special error case - UNIQUE_INDEX_DATA indicates that + * the CRL we just fetched is already in the cache. This + * can occur when expireOverlap is sufficiently large that + * we decide to fetch before a CRL is actually expired. In + * this case process as usual, avoiding any further updates + * from this CA/URI. + */ + switch(crtn) { + case CSSM_OK: + dprintf("...refreshed CRL added to DB to account " + "for expired CRL %u\n", dex); + break; + case CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA: + dprintf("...refreshed CRL is a dup of CRL %u; skipping\n", + dex); + break; + default: + continue; + } + + + /* + * In case there are other CRLs still to be discovered + * in our list which are a) expired, and b) from this same issuer, + * we flag the current (expired) CRL as refreshed to ensure that + * we don't do this fetch again. A lot easier than cooking up + * a new CrlInfo object for the CRL we just fetched. + */ + crl->mRefreshed = true; + } +} + +/* + * Open an existing keychain or create a new one. + * This is a known "insecure" keychain/DB, since you don't need + * to unlock it to add or remove CRLs to/from it. Thus if + * we create it we use the filename as password. + */ +CSSM_RETURN openDatabase( + CSSM_DL_HANDLE dlHand, + const char *dbFileName, + bool verbose, + CSSM_DB_HANDLE &dbHand, // RETURNED + bool &didCreate) // RETURNED +{ + didCreate = false; + + /* try to open existing DB */ + CSSM_RETURN crtn = CSSM_DL_DbOpen(dlHand, + dbFileName, + NULL, // DbLocation + CSSM_DB_ACCESS_READ | CSSM_DB_ACCESS_WRITE, + NULL, // CSSM_ACCESS_CREDENTIALS *AccessCred + NULL, // void *OpenParameters + &dbHand); + switch(crtn) { + case CSSM_OK: + return CSSM_OK; + case CSSMERR_DL_DATASTORE_DOESNOT_EXIST: + /* proceed to create it */ + break; + default: + cuPrintError("CSSM_DL_DbOpen", crtn); + return crtn; + } + + /* create new one */ + if(verbose) { + printf("...creating database %s\n", dbFileName); + } + CSSM_DBINFO dbInfo; + memset(&dbInfo, 0, sizeof(CSSM_DBINFO)); + + CssmAllocator &alloc = CssmAllocator::standard(); + CssmClient::AclFactory::PasswordChangeCredentials pCreds((StringData(dbFileName)), alloc); + const AccessCredentials* aa = pCreds; + + // @@@ Create a nice wrapper for building the default AclEntryPrototype. + TypedList subject(alloc, CSSM_ACL_SUBJECT_TYPE_ANY); + AclEntryPrototype protoType(subject); + AuthorizationGroup &authGroup = protoType.authorization(); + CSSM_ACL_AUTHORIZATION_TAG tag = CSSM_ACL_AUTHORIZATION_ANY; + authGroup.NumberOfAuthTags = 1; + authGroup.AuthTags = &tag; + + const ResourceControlContext rcc(protoType, const_cast(aa)); + + crtn = CSSM_DL_DbCreate(dlHand, + dbFileName, + NULL, // DbLocation + &dbInfo, + CSSM_DB_ACCESS_PRIVILEGED, + &rcc, // CredAndAclEntry + NULL, // OpenParameters + &dbHand); + if(crtn) { + cuPrintError("CSSM_DL_DbCreate", crtn); + return crtn; + } + else { + /* one more thing: make it world writable by convention */ + if(chmod(dbFileName, 0666)) { + perror(dbFileName); + crtn = CSSMERR_DL_DB_LOCKED; + } + didCreate = true; + } + return crtn; +} + +/* + * Add CRL fetched from net to local cache, used only by fetchItemFromNet. + * Note we're not dealing with fetched certs here; they are not + * stored on the fly. + */ +static int writeFetchedItem( + LF_Type lfType, + const CSSM_DATA *itemData, + const CSSM_DATA *uriData) +{ + if(lfType == LT_Cert) { + return 0; + } + + /* + * The awkward part of this operation is that we have to open a DLDB + * (whose filename can only be hard coded at this point) and attach + * to the CL. + */ + CSSM_DL_DB_HANDLE dlDbHand = {0, 0}; + CSSM_CL_HANDLE clHand = 0; + CSSM_RETURN crtn; + bool didCreate; + int ourRtn = 0; + + clHand = cuClStartup(); + if(clHand == 0) { + return 1; + } + /* subsequent errors to done: */ + dlDbHand.DLHandle = cuDlStartup(); + if(dlDbHand.DLHandle == 0) { + ourRtn = 1; + goto done; + } + crtn = openDatabase(dlDbHand.DLHandle, + CRL_CACHE_DB, + false, // verbose + dlDbHand.DBHandle, + didCreate); + if(crtn) { + dprintf("***Error opening keychain %s. Aborting.\n", CRL_CACHE_DB); + ourRtn = 1; + goto done; + } + + /* store it in the DB */ + crtn = cuAddCrlToDb(dlDbHand, clHand, itemData, uriData); + + /* + * One special error case - UNIQUE_INDEX_DATA indicates that + * the CRL we just fetched is already in the cache. This + * can occur as a result of a race condition between searching + * for a CRL in the cache (currently done by the TP, who execs us) + * and the fetch we just completed, if multiple tasks or threads are + * searching for the same CRL. + * Eventually this will be handled more robustly by all of the searching + * and fetching being done in a daemon. + */ + switch(crtn) { + case CSSM_OK: + dprintf("...fetched CRL added to DB\n"); + break; + case CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA: + dprintf("...fetched CRL is a dup; skipping\n"); + break; + default: + /* specific error logged by cuAddCrlToDb() */ + dprintf("Error writing CRL to cache\n"); + ourRtn = 1; + break; + } +done: + if(dlDbHand.DBHandle) { + CSSM_DL_DbClose(dlDbHand); + } + if(dlDbHand.DLHandle) { + CSSM_ModuleDetach(dlDbHand.DLHandle); + } + if(clHand) { + CSSM_ModuleDetach(clHand); + } + return ourRtn; +} +/* + * Fetch a CRL or Cert from net; write it to a file. + */ +int fetchItemFromNet( + LF_Type lfType, + const char *URI, + char *outFileName, // NULL indicates write to stdout + bool writeToCache) +{ + const CSSM_DATA uriData = {strlen(URI) + 1, (uint8 *)URI}; + CSSM_DATA item; + CSSM_RETURN crtn; + int irtn; + + dprintf("fetchItemFromNet %s outFile %s\n", + URI, outFileName ? outFileName : "stdout"); + + /* netFetch deals with NULL-terminated string */ + uriData.Data[uriData.Length - 1] = 0; + crtn = netFetch(uriData, lfType, item); + if(crtn) { + cuPrintError("netFetch", crtn); + return 1; + } + dprintf("fetchItemFromNet netFetch complete, %u bytes read\n", + (unsigned)item.Length); + if(outFileName == NULL) { + irtn = write(STDOUT_FILENO, item.Data, item.Length); + if(irtn != (int)item.Length) { + irtn = errno; + perror("write"); + } + else { + irtn = 0; + } + } + else { + irtn = writeFile(outFileName, item.Data, item.Length); + if(irtn) { + perror(outFileName); + } + } + if((irtn == 0) && writeToCache) { + irtn = writeFetchedItem(lfType, &item, &uriData); + } + free(item.Data); + dprintf("fetchItemFromNet returning %d\n", irtn); + return irtn; +} + +int main(int argc, char **argv) +{ + CSSM_RETURN crtn; + CSSM_DL_DB_HANDLE dlDbHand; + CSSM_CL_HANDLE clHand; + CSSM_CSP_HANDLE cspHand = 0; + CSSM_TP_HANDLE tpHand = 0; + int arg; + char *argp; + bool didCreate = false; + int optArg; + + /* user-specified variables */ + bool verbose = false; + bool purgeAll = false; + bool fullCryptoValidation = false; + int staleDays = DEFAULT_STALE_DAYS; + int expireOverlapSeconds = + DEFAULT_EXPIRE_OVERLAP_SECONDS; + char *dbFileName = CRL_CACHE_DB; + /* fetch options */ + LF_Type lfType = LT_Crl; + char *outFileName = NULL; + bool writeToCache = true; + char *uri = NULL; + + if(argc < 2) { + usage(argv); + } + switch(argv[1][0]) { + case 'F': + lfType = LT_Cert; + /* and drop thru */ + case 'f': + if(argc < 3) { + usage(argv); + } + uri = argv[2]; + optArg = 3; + break; + case 'r': + optArg = 2; + break; + default: + usage(argv); + } + /* refresh options */ + for(arg=optArg; arg +#include +#include +#include +#include +#include + +#define DEBUG_PRINT 1 +#if DEBUG_PRINT +#define dprintf(args...) printf(args) +#else +#define dprintf(args...) +#endif + +/* + * LDAP attribute names, used if not present in URI. + */ +#define LDAP_ATTR_CERT "cacertificate;binary" +#define LDAP_ATTR_CRL "certificaterevocationlist;binary" + +/* + * Default LDAP options. + */ +#define LDAP_REFERRAL_DEFAULT LDAP_OPT_ON + +static CSSM_RETURN ldapRtnToCssm( + int rtn) +{ + switch(rtn) { + case LDAP_SERVER_DOWN: + case LDAP_TIMEOUT: + case LDAP_CONNECT_ERROR: + return CSSMERR_APPLETP_CRL_SERVER_DOWN; + case LDAP_PARAM_ERROR: + case LDAP_FILTER_ERROR: + return CSSMERR_APPLETP_CRL_BAD_URI; + default: + return CSSMERR_APPLETP_CRL_NOT_FOUND; + } +} + +CSSM_RETURN ldapFetch( + const CSSM_DATA &url, + LF_Type lfType, + CSSM_DATA &fetched) // mallocd and RETURNED +{ + BerValue **value = NULL; + LDAPURLDesc *urlDesc = NULL; + int rtn; + LDAPMessage *msg = NULL; + LDAP *ldap = NULL; + LDAPMessage *entry = NULL; + bool mallocdString = false; + char *urlStr; + int numEntries; + CSSM_RETURN ourRtn = CSSM_OK; + /* attr input to ldap_search_s() */ + char *attrArray[2]; + char **attrArrayP = NULL; + + /* don't assume URL string is NULL terminated */ + if(url.Data[url.Length - 1] == '\0') { + urlStr = (char *)url.Data; + } + else { + urlStr = (char *)malloc(url.Length + 1); + memmove(urlStr, url.Data, url.Length); + urlStr[url.Length] = '\0'; + mallocdString = true; + } + + /* break up the URL into something usable */ + rtn = ldap_url_parse(urlStr, &urlDesc); + if(rtn) { + dprintf("ldap_url_parse returned %d", rtn); + return CSSMERR_APPLETP_CRL_BAD_URI; + } + + /* + * Determine what attr we're looking for. + */ + if((urlDesc->lud_attrs != NULL) && // attrs present in URL + (urlDesc->lud_attrs[0] != NULL) && // at least one attr present + (urlDesc->lud_attrs[1] == NULL)) { + /* + * Exactly one attr present in the caller-specified URL; + * assume that this is exactly what we want. + */ + attrArrayP = &urlDesc->lud_attrs[0]; + } + else { + /* use caller-specified attr */ + switch(lfType) { + case LT_Crl: + attrArray[0] = (char *)LDAP_ATTR_CRL; + break; + case LT_Cert: + attrArray[0] = (char *)LDAP_ATTR_CERT; + break; + default: + printf("***ldapFetch screwup: bogus lfType (%d)\n", + (int)lfType); + return CSSMERR_CSSM_INTERNAL_ERROR; + } + attrArray[1] = NULL; + attrArrayP = &attrArray[0]; + } + + /* establish connection */ + rtn = ldap_initialize(&ldap, urlStr); + if(rtn) { + dprintf("ldap_initialize returned %d\n", rtn); + return ldapRtnToCssm(rtn); + } + /* subsequent errors to cleanup: */ + rtn = ldap_simple_bind_s(ldap, NULL, NULL); + if(rtn) { + dprintf("ldap_simple_bind_s returned %d\n", rtn); + ourRtn = ldapRtnToCssm(rtn); + goto cleanup; + } + + rtn = ldap_set_option(ldap, LDAP_OPT_REFERRALS, LDAP_REFERRAL_DEFAULT); + if(rtn) { + dprintf("ldap_set_option(referrals) returned %d\n", rtn); + ourRtn = ldapRtnToCssm(rtn); + goto cleanup; + } + + rtn = ldap_search_s( + ldap, + urlDesc->lud_dn, + LDAP_SCOPE_SUBTREE, + urlDesc->lud_filter, + urlDesc->lud_attrs, + 0, // attrsonly + &msg); + if(rtn) { + dprintf("ldap_search_s returned %d\n", rtn); + ourRtn = ldapRtnToCssm(rtn); + goto cleanup; + } + + /* + * We require exactly one entry (for now). + */ + numEntries = ldap_count_entries(ldap, msg); + if(numEntries != 1) { + dprintf("tpCrlViaLdap: numEntries %d\n", numEntries); + ourRtn = CSSMERR_APPLETP_CRL_NOT_FOUND; + goto cleanup; + } + + entry = ldap_first_entry(ldap, msg); + value = ldap_get_values_len(ldap, msg, attrArrayP[0]); + if(value == NULL) { + dprintf("Error on ldap_get_values_len\n"); + ourRtn = CSSMERR_APPLETP_CRL_NOT_FOUND; + goto cleanup; + } + + fetched.Length = value[0]->bv_len; + fetched.Data = (uint8 *)malloc(fetched.Length); + memmove(fetched.Data, value[0]->bv_val, fetched.Length); + + ldap_value_free_len(value); + ourRtn = CSSM_OK; +cleanup: + if(msg) { + ldap_msgfree(msg); + } + if(mallocdString) { + free(urlStr); + } + ldap_free_urldesc(urlDesc); + rtn = ldap_unbind(ldap); + if(rtn) { + dprintf("Error %d on ldap_unbind\n", rtn); + /* oh well */ + } + return ourRtn; +} + +/* fetch via HTTP */ +CSSM_RETURN httpFetch( + const CSSM_DATA &url, + CSSM_DATA &fetched) // mallocd and RETURNED +{ + /* trim off possible NULL terminator */ + CSSM_DATA theUrl = url; + if(theUrl.Data[theUrl.Length - 1] == '\0') { + theUrl.Length--; + } + CFURLRef cfUrl = CFURLCreateWithBytes(NULL, + theUrl.Data, theUrl.Length, + kCFStringEncodingUTF8, // right? + //kCFStringEncodingASCII, // right? + NULL); // this is absolute path + if(cfUrl == NULL) { + dprintf("CFURLCreateWithBytes returned NULL\n"); + return CSSMERR_APPLETP_CRL_BAD_URI; + } + CFDataRef urlData = NULL; + SInt32 errorCode; + Boolean brtn = CFURLCreateDataAndPropertiesFromResource(NULL, + cfUrl, + &urlData, + NULL, // no properties + NULL, + &errorCode); + CFRelease(cfUrl); + if(!brtn) { + dprintf("CFURLCreateDataAndPropertiesFromResource err: %d\n", + (int)errorCode); + if(urlData) { + return CSSMERR_APPLETP_CRL_BAD_URI; + } + } + if(urlData == NULL) { + dprintf("CFURLCreateDataAndPropertiesFromResource: no data\n"); + return CSSMERR_APPLETP_CRL_BAD_URI; + } + CFIndex len = CFDataGetLength(urlData); + fetched.Data = (uint8 *)malloc(len); + fetched.Length = len; + memmove(fetched.Data, CFDataGetBytePtr(urlData), len); + CFRelease(urlData); + return CSSM_OK; +} + +/* Fetch from net, we figure out the schema */ +CSSM_RETURN netFetch( + const CSSM_DATA &url, + LF_Type lfType, + CSSM_DATA &fetched) // mallocd and RETURNED +{ + if(url.Length < 5) { + return CSSMERR_APPLETP_CRL_BAD_URI; + } + if(!strncmp((char *)url.Data, "ldap:", 5)) { + return ldapFetch(url, lfType, fetched); + } + if(!strncmp((char *)url.Data, "http:", 5) || + !strncmp((char *)url.Data, "https:", 6)) { + return httpFetch(url, fetched); + } + return CSSMERR_APPLETP_CRL_BAD_URI; +} + diff --git a/CrlRefresh/ldapFetch.h b/CrlRefresh/ldapFetch.h new file mode 100644 index 00000000..23f36da5 --- /dev/null +++ b/CrlRefresh/ldapFetch.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + * ldapFetch.h - fetch an entity via LDAP + */ + +#ifndef _LDAP_FETCH_H_ +#define _LDAP_FETCH_H_ + +#include + +typedef enum { + LT_Crl = 1, + LT_Cert +} LF_Type; + +/* fetch via LDAP */ +CSSM_RETURN ldapFetch( + const CSSM_DATA &url, + LF_Type lfType, + CSSM_DATA &fetched); // mallocd and RETURNED + +/* fetch via HTTP */ +CSSM_RETURN httpFetch( + const CSSM_DATA &url, + CSSM_DATA &fetched); // mallocd and RETURNED + +/* Fetch from net, we figure out the schema */ +CSSM_RETURN netFetch( + const CSSM_DATA &url, + LF_Type lfType, + CSSM_DATA &fetched); // mallocd and RETURNED + +#endif /* _LDAP_FETCH_H_ */ \ No newline at end of file diff --git a/Documentation/AppleTP_Spec.doc b/Documentation/AppleTP_Spec.doc index 419c7ce193daf82227338aac0dea60563f2cace0..cc1eb67e6ccedf62b1114f387c7ad1f84fdbb19a 100644 GIT binary patch literal 51200 zcmeI534C2;ng37HCT(bADOL96u$8nVw`o~~ve-0DX(4S&l2RDZa+BO7mnQeddvCgc zI#tnOMje&qKZ?$Xf}^9tfGdv6ASxh&B8vhJo4{WMWGRaUto?s~&wI|f=cGvqh&uj1 zx$W-O6KrxTyQAqqV4+3$J#EUKC8c~9^5-x@@(VkU!Hp@IMDO3!NbSYcSb%st+eNL9YrzI{e?G1hsQV8BiWD&4h?@pIiB?fQ)_ zxqbIcau=f=kKxfLd434T>o~S@4AUL6zvo>FTOR{W^wF`7@?1?fI{kh>q!C%jfZeZu?hYW&}mz3+Q7yhq2MVIt-KhZJZU z8XCy>orU3I$zPQp$aZh?SLAz!xwmvU*ImlybLjy;o$K+JWQy6ooZm5&>CX0MyVH79 z+nOfZ>Y<)=DdRT{_oe*#N7nlb8XFh*U7P%#!EC9!zqWRMs?o3M=*|yiYHK_Dvqirr z-#t8-$(8(`OtHI=?aCDWu6(KAFZE}1OVy}GUG_$e$d)$w`Chv@cAM)iQYOE1)x~rC z-h9DQw{`fZ`$Gfi5;q1@er;{-f>dKotar&S(M0I6>cV2I?x3MV>a#zX&gKT_UDS3} z*_G)}ug_9r(8T7BjumS=SFLT%6iO!*^20-?WeVBeO;MTk{)YZ+cfSucx`zt|h(VDm zXsD1KOcyr!bwl}LG20c~%~K;i3WyQQGF;5`h}MuVQ}7*OiuvBshIAp5^3|0v6CG+= zwOkeUWO}nXvXLVb5qdDw-Ji~7yNh8DO2!gHVu>sRlr8z$L0CoOR`e-7B0x_{!d>xY7@1h^w=>gg^lqrbqihgNB-Y=z#>xwCV zX|{mWK+sZp9h9Zt!?}E+hYs}kec}~0z8l7Iaz>K6i*#9psU;U=$QvsnnFCphB00j9 z^Or348N;4|OcBB;VX2fE9D=^3yx(2ONJ!KE`t(4yr```MRKY$&pUwHjQkps;aGB=T zQcE(FE{fGiW}=xX3}$oa08*z*l$wE>Fksp*yx5qZ2KVNN88!_?##FDrAa#T^R!62gpJUKU(w-5QMZ6W`TjPb0uDRjC zE(V2qWBOgfTz8SFdQLBf(VOE6NGbu)l7gELNVL$ph1y6%72j0CCN&0~ui0ac^7!W|&V*U)+={r8m~rTDta@&eiQJ$IMgbQZXAW zYg)OawT0PbnTct=d(hk(K4@-DKIn+DGukzT6?(ssFT=_T@{@SlisTva{v%PJgabW6k+oDYLN@v}T87Yuj5oR=0MpUDes{ zCo;5~l*~DvL~e zbwfUDzbQ-lp#qpC&q2pH{aiPYNi&5M{0xm}e#g|BQ?^es>$x>-vl$d(SezEm^tg(g zf6FRYi@vB_t`&a6-8x>3J@;-rvZF6zo?2#kAW zK?Id;!uVp2mjz+f*j(l)lk)49JL@pkb2^*N1rwf;Ei|BPR0 zR>WMsba``AXG?01P5&AlGkc)q=;Ie~?7~_-?%Xt#@oPdRjs|G$>1$z$^VZL=U%#M! z{Soi9v@N;re2=<1O8SCCC$QLkIdb62<9-0uD8Ya)yI2p@Lt*tHXO{+VXg(}LFPBVs4WG}=28nk|t zj1z>=D$FuQ%-ha@v1%69Mq|6Gt#x_x8EcoXT-p|RIkl_I=1W0R=E$~Qce%W$Y;d>= z$`mfoP)JEQy60vJc@Yj8rotl2Ma9KBv>D1{;?ntT%a;Un@$0g^H~^U<%;x6TV)k6K zk4$ z?7)q?C}}iY>}p#o(w>$c7)A-{RN2%z*9v>8sW|K{h9+F7nYm%e8QHRpi^o|WBy(5> zaNL=2jbR>k1*Y7g83`=p2UK#|T^i0w-;78En?eljU36im zCM^CJGH)Nw%CYFmbf@KJX{;n_2)4;Il-H6C~=bTZb*$Ptie;BgEgK!>&bW4LKV!2tk6G{&$ zrBSoF9*dB0Dtg-^TI^`2JK~pMrlShSE6jxh!}w@$bTE^J)saLkb1EU3HOk~)1P>#l z7-JY5Zc-jwuZ9XoqK6@shZcD83FX~zVw3qGOVXuuN?+yC+bK!bHmzFK+M?J;Q*-C? zwv{$9h%ij!Bh4p;H3BsfYAp?-F-O3a^gZlGP#%*++nTj4r>|Px-m)Z|7dG@`S>Q+3 zhqOnp7?+r2UMT9|ruM?v7svbVC?8S)b*cf!r;(GyGZ-auOhnoQft>kEg_6fygBu~V zU0_xOa_eRhbh=z8v&2y7s6!_wBh5K@EeHg}hB-ZuhmmZi>@l|qZZnOlG(n6&GiqsA z=8oe?1*&Mh3z!(k8Pls%lwsa`#?Nd_cPs7$@x%vCk;f_~0+TNw9ofGAk~7=#-KKuc z^n+BY&1o4;$~3Ex>BAZ(01ZihsrO5X}$AK-U zEnk93*0OeKTl&-G{0vX#qoTf{vw&P+4b ziykiMWvpO2l37?bX%K95k{4Bgx7UFH`gM(FDKK7vOle{iYm-&cw}?{V?9_|P7HRfi zbcTykY~rNI=Rr^!u;4QT1m6bp#4MFmfe?vGNWe4akDr>68#8+DBtgrGje^b?iO8mg zI-yguji+5`E#UHE8lH5bBIZzXqheHQ7}y~_&zr;PGVWc=2KdVowM>@&rCf z4!14Lz9ECgh>ObTV;s0C=#|VsZ+&E0y&fusl^bGn3nFzF38kBs{dVWin{!eOLUV1W z_^9u)wdE!sXd?Y5;%^|J5C(6dZxDJmGKmT5LPus!7-x(}AdAD@-4;wv`784lM#jp6 zH%ihA-RUA0bWeuJym|P{$f{8GE^aDKaPy&z>~hdt?gk?r229MA=n@B8shXsjO{LPJ z&MP?&#r$RSg0+CIAox`-djq3qW>&VOrIMgTGo#5F^PJG%zJ(@R+S_Hwg^`h_mCeiA z+ATn`&|jYDW+WeODM3|X&SteR$V?Ih#}(-x=xqqNvQ90V<2W)3d{%TDa6vUVI>NxdBCt?pWOxo>kyUX7kdf<*lpRTNe6Fu{MaV zt~1V;=*jk&%V~7ADmRT%0Icyl{q<9s13DonXOeR{*&1_WUj3kgH;`f zzKMk-W4jSe2%FyCa_Z`qj!qbQ)#}a;Gy_&-#A;59G)oz8ETyDsj`01qz#MOu3Td{g zN#X1$Er8dqk>e38w3&q@*E4jf1?q$jCq*TgehfCU$xpM^6)f_w0Q&NcSTE+$O{Z143-j}Oo4VVZ3f z=!OzT5D}cz9K{2Q`TB8;SPAOIC&~y!N zsjJuwe}pcoR{Z6cMx)JGH}$dXk(>e<)ShfFrX?eITyk>My3nXC8LJ&|rWqoPbF^NR zXepK1q7eg!-KYWZ(}P{vzTs?1F@Qj|2aGc>VCsO)O&22v8`D}vcHD^{q!^n9T-K7hN^iZc)_yjnb?D+5<&E;cq8CBOll%QBjn zq(Vn8(3PExl^KyT>0;3ppYQ;+TJWcLAdMeIzc4IAin+Ln4RzhH0uQBO*5t4)nAP)x zgABECsoD{!Y7qpx#FVBf%#HyYlOv2aD?%BfsLgctX&mX-B*WFLJeD`G zY)VdUk*E!&@u(RR34aht)1|4vjV$@d-Hw>R2GfS#si@?7xYOR6gopyGYZ^BZHi&u< zF`R=S)!lnzvUXjh@=2C5#i0dWIp;S^X!z9*O1VLAB?jQ6kuohHAo$J^Wh4(&5gP4fnoDmR9r` ztB|ZRJ37QWC;^tRFqNS<25lLqc2zjV9y9+KXGH{R#K;({T#kg5D{dUMm*zoX`Dj($ zh(e68r&}xaNN@qYMpbjm;RxACm<;ffhB2_dppmo#s=X(#O@FQzF>*5thqOoBTT*?g zdVg*zo#L)5!|aZHa7UEwN*7YS`QQ$EkVc^+3#>YZ9^YteKPIhHv9Sr5+_pDjmH6f% zhEs1#B(P2?1&c0jGoMT&4YVnddLLeNUQSu{IC0j5sI)ez1l$u}b&Y9-q#7fVfsHKP zjnSgLY35#N??%Lfw(&IXTD#z#DPJd@fqxckVF}g(oI~SVpjyF+Fi2rH8Up>%jrtIi zxsbctSumPRl1bK+X}ExEBKKc&S`=Qk@z7kkW2DT5Kjee4>}vL>CQe(EF_mb$sZ0Qw z69XkGS%^Dz8jH{!kc?o}p%b;!#3rg}1x_XR!Lb*yht}%4*a?l(y)b%)J!x{}Y%X%U zw3^K~ftgE1HEJP2lVE|69&3o?MVkYy>LM+b^4r24hosYU7GAU!M*%IjEv&oAMzcUj z+Ezr6ZN?C_l+0^Ij+(WXl{niXLrHZ(900pP`%kq<0pn>;aZp>biaF&tlL|2|joJ>w zp{w0Z_0W7LND^aj^;IgE$1H?n;;x8v;65Y<>$altJ0nbeellCmLnz~7KBpaMe&Pu$+CO~AN3DO>-MVQ-r~Owlk; zXdVq(7;w=JZ3}BuX<@BSqZPFh)!q?{sIV8($&)k|eJ``v92s&}L^O*))^h*wnqe22 zf>=fBPgs@pSmVA!!^j^Pt>Io)#9ZWyB34Y;$vp&av(%17?a&UKgkktdn?3wfaN(Al z1I(mQ2#v!~f?cGHZE394u_FimR`s?L7wtVUCROJdz_4GKc1_Y4MMB(e$B6PK>k0%V z2>oF_!)l?2olF_F3SIbTsa3VDE~fi3VMURmGl@nII2lhWyOj0E@|Bf{5yJ+eC)<}T zr3cEsB*A#-0r6VGc*R1rMWlL6M{1LKI#zCZ=->x82xzl3+mcH~c06VpGyye~wAU(; zG!*v8hHP_N_|zJCEm2!)%bLw*^M#Son{p&k(lRTG9#M-eC?VBgB54sRu|eN3MiYTC z^KIRp`6x@mD>UL_I7wWYw$MAn1>R)PRuU&A;g-n0Oiqj7r~#B4##kZCE>1ZZ44k8X z5V+~WW(YR)LNBv&OlBl0C1-b)TQm;TBfX`K z__gqh5r=Ikj@irXDT&rPzxo}lYZy;Za5Dp@QHTveZPYZLyMjYTWU#}bq{xxQX=br@ zus1gF_QIl87c*L`3C25B+a|(o$QBu`K&@D;U<@_j*F~`|QLC&Uh=S+VNl=z*szWeB zL&c^T>VPtl9mGp0a;{u>ED~H2u`Lq~>P&nFgq{_((4pmd&ePbpIR+eqdN4bXjsj&` zec`cF!5Y!gA}yNE!h)Ua4NYV1FI(ZEJvo*tR7n=RpiVcX$9L5 zIpVmF1Zmze!BnivrZTB|-h4`EUbgc=NlEdUggrS;Xu$YWh1V!;khl_D>a4eTi*{=@4$?OwucQy<>-VtLu0)jHLNN z8W5Ek7L)8pibW#7c6#j*yiK)aw3owpGT*N`$pn4C`5nx6RtIb`6znO+x?jSKJTx#& z)RR6kGVXl@q(suIZD?u;S-Xbummog>VcITR292y?3}iEcF%`woO@=0se;pOb;;c4Nn~|rargs&Up{;JsN(!fk zMT+hc`y(Ws&}4yMvm$*Cr8l#Lgg<0jsX1~aElFyAjTNRX^1(?5n`)R)ndh~j>tBjtoG!s-F7dFttqVGVq7ojw3l`ZG^6>Ne-5hv^M^ESKC zx>E2$U{k52jl?<^Mi>Rja-7i87isYas# zTBwKGU_x_fpqy@*pNbAN$6r#Rx54{kR<`z?V8}@g+n&broTbW!v-;EQwYzt+sQ~R1 zZBjG^RT_#iq`HTOuvCuVZJPypdr%LSV>!dL(YaBKp7Huk4}3(!uwGGL0gn_ifi`sG z88+Po%xvR>2Ej!;G$Tnp1WbaFU0y8^$HY~DmNt@&h>}YQgm1@b|F(&#%7z8p($R6e z)*ymvnc9N)GU%haoLpH$v}9t-%;lsCkP#lG5;dutp*N~of5W#nVhvLX19^>v_5oSq zK$lzoAabri4kM+P;evUjY<-(zX3kb*kxfN5F^oYa_A{Z2+ysL)5?gYEf0*W@O%g#R zLEJju<+!O#wpa)1v@1e(QFCiU&;ivxCp6XFD=i`~yPfn}RrnqjFS%GiAlQLXE^^_* z-VDolOEqEE)z%p4U7%50zUNxo+ISbQ*5bOhPtx|gyC;ge>)o1_Zes!B5LW0HnV9gJ zZ1*Gvx)IJq<6QBaI7gp|V;zJw;u76~Nn%l@rP1S*<2=~wZC#aVTjB+!bPw+X^`h2LR`jd{Ik1m`wuL+G0&QIBVcdgs5~_v` z#0>)txiYhHxY(fOLVv|DtH_v%>2=~5z3XY!;Ao?J&4PDZB~1&Ptxb7&y@P>wrVy=L zSx7Ft~FD20lixRjkd10UH)p#DUq^vATk`&VEhK%YyY%ETGDxIPO_bj4koWCrldJg!@HBPF)=P! zAoM4Kbw90_X3b+w^Ok#oZH2gfnl)ksh>?p|uxt*t4!S8Txp#sw4dZWcp_#<;Vgh{^ zykr)Hb%W`Jnv7JYpP{!+qdTmX_UT>hRQP^PJUDIjXx~TZy>=ClcfAaNq79}cUMxVf zs;iNNMKz%A$}N#>%JMj>riFQ>NA7Gp0U3+mvyJT(dp9K(A(ADd8OTxwY5`^?a#h62 z6cbAD@x|Q62Zqh~$-TrI&dHjH9Wl$x{$>BTe9!IAlpvrE1N)d-Xk)x2r+31=62|Np zBn_e8z*{a@gsoDoZZo4c4%nLcU?$B_FjPS}z_lLoLQ3NGbJ%F1g#2=Xo&;5f%kZ`; z32<-@q4zooX-nKBXki)zJGxA9W3I1s<3@w9aI(3Y#HOg4^NXr?_OVnVU?+=X=aZGF^@((t)u20J@43Kxuu^-u$X0IY5{lOY=VVv(= zx@OadjFjlmlq#1Twk6!v7Tb`wV`FeK^|}RJ7*V0y%2T%YgRIulBWvC~Z^1F@{?hD5 zvJ#-^PWgl+^IA%Bq|-0L#D5S#GdkT3ehxreR$^p}?*XI)_i#jm%!xF}~s%WiIdHTA;ld`Z1blKt@r<_C__L$q21tfZi#haY3-?@niSNA44EE64XnZS7g}nk~*l4gqH#)d8|4l?!_=&BF z&jbY~C@_8s@H>wuf;8v?-5>|@U<-H-%;eYf_Tv}*mV%SO71Q_?J1`S*+YO|^Ja8g- z3s~|7ek~9T@k@N~18p-sZw)vP`~$cWd=2~r{2a{KjdH-jpb@lzv%uxxb6^YD3SI;= zXL(*LI17B7pIf{V+z9Rk4}ix&A3v8k2%hDa|0eI@d9%R&VEUe(cQ{x9dO;r;1bJ{d z_-`g?c~YcsUUuLPcM1b<=it!vnyp;=J19$ zg*(kB@99m}m%e@b-q#DB?CVWe#cd}~qN+*Wa{bPy#(%W2e>OJ$yTJo3Q{e%yFFdd_ zehB#>124P_{0rC?=g6(`i!JesC*l{6#V>vnzewasT#Q{nqO@^d+#jzrktfldaXuMm zX?MpfO+9Ei=|BGc@_+mI#UK8s_ia9J{oCUd zoLV`p1qs^YLV3UpyX9_9tH?x{#g^YN&-)_y61Wmv1?~a&f<5^4+r7Z#gFWx%7oK_IvBw_!&BOQKbLUTy`)@t=b?-M{ zx%!Kr|LkY}^4$wLWD}-p`?``Uia5-5=_%o!to>=AlWlqX|rDn z({GB-E{V<#M#IgOZ2l$2Hz6Xg@5R`%{970x`XnwMj&5@@&WnWj{&IW;B=U@XF?I_Q zdCGM%qt7`1vZ}WMuL3n|*MU_aIX6AgU*U8@e??g*jL;o>$+nfe?g0)4hl1H)31|o1 zKyrK_vU?hkEN8&mK@nU6E(c!)*8|D;Y~)(Mw!I!m-X-hb0ylymfycp%U>9WnP#_&} zDi{ERAO~IoyYoxvNBKMhqv?p7x&LDj>WYUrm#%m-cnCZKs?ZzzfX(3D;4*M0corPM z&u*Up)_^=HfRBKC!OLK;L-A+8BCupOIt}!Je()ji&)}iMJnvUvzdC#ja2|LExMB`I z62NHL=56Ia|2TbWo5z1$Mi)6@$B>411T@?q8i|Id0nzXtAlk+0 z7Sc!b*hZ_P&+nr%P7(^?+4z%$)F$#IlD(FT*SECS(tMSeUVS~rR=obhx$pqE7o2st=e-qt3S0(m0KWp;z#l<7Kb7ABK9KUf z4}zb~!>#~#fM>uKux38`2K0j8fR|r*_Q~Hq^1!`!-SLwj-SGYIe)Fpj+%NZmM#el5u!h&Sh+_(h_$v6~am5<8F2^`pspLKl>6ee(kjsd3Q(tVHt%_LSW2 zhrAvJ;yf@?PTz*Ct_4?uhruJ@F)*b8+W;Jd3^#x`gLZHR_&aa~a{MFkQ*axQoX2JS zNaT7ISPf1ClKD{HU*i1cqtF|m>uAs01nvgE0=pf9eE?2B*7ME*KLd|}$HBCPo_GB5 z#I?X8a3(klWWhNgcLMW07y=i9FN5iCVg3e}HF@5r!R*D@FW_A8+h)Ö?bJl?|0 zyA)Xk?>ou!-Ve6Dux*Q`cKv(dkr%c-^1?mAKQ8X_wsE!XuH?U;+(p_g9@+T1#k)mk zw|JJuO_LTStU0I3d+_NXq8HBaE?PJ;E;xD&F|ZM=gnhka?9eQPRUxf^3$0%U7cTI; zi@@baFm~Vt@O$th#z157Fld1OX%LRd<(&Tlgky8(o0(V`hc!UsvkrU<+y-8ZG4f7) z`rpNqB`y*L{K*#y8(^HJjWbUoS>htmpTtF?1&KU~i?Q>>$!0#lZI#XkP;`)3fqVng z5B(KyJHNle+eh>2Uux_nqa$T=G4l9I@_7;Rc}*av$DAlT;JNVg)MJl6_{*RF?3Np^ z|IW2vx#~Zz_|&DBJa^%RAO7G!o`2!H-$g8-Ac9m?AIvmeRegwkFShSy`_9;RFW)vd zzJ(LgEwZ~S?0coY%Q1tQk+;2A-nQj>M|Aei={rp*^U>K0(b*9%hNYA}^mS3> zaX30#ADw+6I=eGEdptUOB0BSfaXPdgj8EMs>*h|i0ME%v-&p!rdA<6~ex zb7MG1ws8Jf%jk3EWz3hK20uTU`2ze7JPEdgH=Tkl0J7i<;65;`)$@)3r-NbeW$<6% z_h8-%;sxM?;0xe8;68BBO6&=63-}56Dfq*SFFgD7?;iX0BM;sG%lq#)a0t%0bN5}h z|MV8TitE1fUoU*)tJhpbP!W<|etDAQV_hlgR#kloHg;9@SL|D6cU86i&R13SGW&j? zeSgTle{J8>8MUhFdi(CO?@R3a=l1=Seb1Ht2{h8FcHVB^(pgR~RaKvAvHt=4{)l~l z)V{xNwS2?Ae`Mb`+xI7}p_uwxA}SjD3+%6=Ns+Gd_7OElA{f zoUw^MiHn505G9G9Xj~KWAJ-Ea`dAELZ`rSLnGEIe8RT&bcmZq$e+2giGAY@*3j8Pd z8u&W+2Dlb{8+-@c2yOy5gC7IQqU7-9t=@AOyZZOE_vE7wJ^D+a?!fp(DY#lam3078$d8zG;@pa4Trl({ynX(hy7yMbJJi2pi~H;Q zE6HldcN&4iOUa+2zYp*qdnHJx>tmd@)-IEW%t^wpf+8MCdA>QsEsn~qL)wj*_uYT}^1FxPsqmjz_}j9(Ff3XA7HFk6 ziGn9-pcg%}z0&^bZMC=3%k%eG2l;Ey13bm-fEBd3Fu1H{a-&zVsDgWq+^zAJc^Ojm zP*%?C^L%f6<@l;!AsCZN$S{6*wwosvA*02ssj;yUPiHs8~@H~GNr+bg`w&iy!{ z#O?5%&L;cpb#eDNo9yoKv?@wh9o?G}rJEYvtBKO>65X5T?os2cDXiqppf!79#jtB( z?*rJeatM(xhNFo{)^CY6`~ojVt!2+3sPH~eA@2Vr-;=z#+?nhh$~Vied{=wBa+qT0 zQ=x(QK=*e6HsR03QOEfX{)e!A;;kunp`ol{}yc+ym|h+9}%xhQRy4e}JpNNian# z_&&G^G$H~mpbe}6=Yf9!SAwsBo4~E$C*bGc*Wej&@O1KmHgFcW9DEME2(&Y|6`Tcr z1a1Yt22X>=H!#{@8R!5X2Umg{!M)%C@EDkdeC!F9f>VIxWe_|EYM7tT0PDa{!JXh) zfHC6D0{emKaME62A21j6fkE(b@G0;hcoa0u^1Mah6D&tw1)c?y;pRQS!Qd>g7W@u8 z3o^U2`v6=Ct_HLB@Vw)|Vz3N+3)~1MA=}m9RG?kHmx51${r93=@K(?dE(Vu^KY%Id zf>~gH@D*?~xE2Zg9=IF)64ao+-Uz-0z6-SL;U=&J`~jS^AFB(X2;K#DLAUGy{ta9K zz74Ji7aj;Lz@6ZJaMnTO1s5Mod%%8&uqp#`pa`x3UkClDodNJ(@Ii1H_yV{A{1{w0 zn+OT`Hn=A!GtKHyNWydHi4 z=Y#hH>C8*O{Xi>2FM-Jov>Ob8E5Nm2RtkOsv%%5e6X0_2HSk~HdT={<8A!#Q3D$vs z0v`td4!#Z^2EPHD8lf-v75Fu1Ks}uR{s~+N?gaOPk1l}Dpb3@P3f6%k@Coou@HN!n z_2AK?7(;Nu(d_I1AAd8n1)l*|gD-<`0)VX6PQFom)!BTV63(7h?%_U#xl_;O3|)rQRQkS~S z-x~4ctC871h4a_Y#{x3xd+uxKQeMUanK7+NeojjX7<}+I?wWm9l>7rBNcTj{K6nU7zZY%A) zdXwJ1`q&?<-^RIiVCCzqnJEix{dF=sGF8M|9BcNzY#4iFn>BmiN}9bdi$;%ZquI(3 zWDSWK72$f^x;@I;x}B`8+k>o1uO7QPD<)xqCO$5E<2EfzSzteyJx6iZJ$E+Ov`k4yD=tNVINriqEdB7~TKM!cQIStSLy=EE6BMbGV-=Z#qRC=s zhNT8Az2NDY(9K$U!P69b!P94RO-q$4s<%TqB1n~urh z<6~2;um)^;Srr|-jFnd7vGKF%(A21ip{W!xH1##H>F1|My!H9%6!ZD%ubE9Z&WMWI zID?`#&iIqq^y*m=PhCBW;;x?cC$s71-J>Em?@p1McYj^j^xC~6HobOlioJI4SHY$l z@sUg#PC_Buj%31cvI(D$)P?LD8|9NsrDd@AM{TI^Y9?2(%&CuD=6EPf_gorx+`eei zW)`&Sc>M-^_4X4cNjK|UpYV7gVz_#q-#dq9Vu0Q*JS>g&ldW7@7!|w`xkjHap$|cusTK*c$#+rSChT>?)n}j3_jB%cF~P%CVNkh zXnB}$;`oXb_-yrcQ@-kb)!Xdt-^j`wKe^FEp1r^kr@Uh3Sb~#`1CoO8EV2W{`^=i& zB8}4n2~LR>5S(t`&Z3)rW?Q5s+^tcvxKuoT;_nbq(w+!OpLk8Nmla&~!1Zp|fC}B2 z7rL`&u0<2ye`yN*aXTt-7gG|6s&(hV_kC*1i*5b8e(|GIy~7Xt$~~~J_c0#Gg46Sl z0I}Z3fSB$kpy};SAU=HpNbPL}aHq$XM6;lMj^aV>d`1m<%Q(s$?&LU~@3%1^}4y$vxL9*;IGK?o8A1ab1&mZX}GU*^~L?kRim!CL@gPkusKD~MV_bTjs%hz`83eVp&{etf|UvIXoXr!{G zyLFWQ)^Xx9L4gShOi*Bg0uvONpuhwLCMYmLfe8vsP+)=r6BKwQ3hd1Pue|HlyFQuP zXV;7V1^>VP#jE81^SiO;qsw>h2lC5@fc$;M1FC`I0g4e^2KE4-2l8F72D^f5f&BOD z!0teC1Nr;60r~$#qZ59;(l~FvnLm@qUs@^D`^$6PDc|#a`M>W`9-v63j*6@4cu3VQ zRxhVx9`~m~>dUK$9ZV-nC0P^#P^t%tEgq__5jVNm4hNAk z`fUEee$QRNUWP92Y!2?uhiYl|^p$rIMajo?@&>Qc>KEUt9plNw%hBE^4{|BPw`)ee zp);OxlxA=0uizNcV7&Q0v)-kwf^+nKp7uhD_WJ#lUPi?I;!gOs-q@w`I)V01n(U6Z z|0`9TgqKehT%UYL@YS{Fn1KGTrvIm@;-LNtBu_g*hxmn%F7F&Yc~zg?&|YEPs7bP`BUl_@BX!PPrTg|=YJgvR51E_t46ht)ZLoDN9+~UzhMgeKN6It#{d8T literal 283136 zcmeF42Vh*)mHwYBOSWvwoo?Wn;@Dsd+mrwyU|E)JfmteyXW0`Z=@+Qm`(EEk^RlQdGFS9 z&pG$pbML$NJKvsj`#V2;$aY+ z0;hBH4DfWoqw3#ZF$LO#4F86MFlY@1`OXHTwBVQm|7pzc#Lq*6x*GqpmYDSollTmR zo7`uxR$u;k(Dcc+FJJiYHE)G4_Q6Q|_dl?IMbH_ff*nDBkWPg3F)Dx03?|ixN5y-k zLi4ELPc>}%K#dE3A+^s2-N72ZyMmEmfO3cqrBf@+-#)x#T7M1P zSNQ2*251B`!7P9Z2=wc4grUP!@%L-2yi4g3M>FegJZz4AOs7+ao~7x0yq&Y z0#5^r!4hy1I2kMj%Rm!21uO?Ez)El`I1QW*&HzsbXM(f9+29%A9PmtVE;tWdAJJen z*DYWTXa!>0bznVc1LuPazy|PaunBAiTfnnGJLmwNU@O=LE(8~Wi@_ye2s{To7d#Ja z2bY2r*a5mgH;@$cfL^c@^nuI3F3=AKfcPN;?gq~XSs;#8n~m_j8|(pl!S})C;0o{p z@Ir7UcoEnK(k`}WdhVq)!O9xZwvL+gk)p|D9c^2CLJb^n`qUS1KEEz_7I1&>UKP+w z1g~|UZ#6!dym0@1$f`fC#F_ABxPL$4^vAu)?n2=#nMqvL=kHB%R|+@P?h#i!$RAhY zMElDT@S>SP@M4(msv~K;FbLkZCOWBtfQe-KI5F4;2*h~%e5HRtKI>d9McV z0AB__1&@QdRP#L053U2(gD-%az_%&JcfgGZ->sk#0c-*p@KW#z@JVnHLOBe+3hsa= zHM4`@8gMPb`5)j*;7{Ps;1mS46}$j^14wyI0<~Z=r~~z23YZESz%(!&%m9sGCYS|g z17H7nT+auGfJ4Dy;BasRI1(HM7J#F{G2mDbf`#BXa6Ev?f)l|a@HDU(ECH*)$zUm1 z2AaSrU^!R;R)SN(Y2ZrW6j$QoZ0Xa#G*I1^U4N7z7zG1fCDFAP0uQ2-pqwfW2T8Tn?@PF90tD(i1P@`_15gv;W`s_t_7s z|DTDR>_ZLwU+w?rQvcv;ABLb6sFwsYWqLw@n;$O z7jOSF>32W(!zb5nzD=KO`)_aE)UtU^+op9_tZ8juy1KRfg^im=23peD;au3zmkWn? zro+LJfgR~=nCS_-biYwgH}vI(U4YbJn962Tqk7!Z(Xny+n&!^t+|n?e>e?B0Wd?^+ zeS>|2y<*;Ien)0gh=rX;FDX0V?UQUpr5 zXJ;Qpqi!QPGUwYByK~F-mgWr`THBkqcCO#vvUyWy>qVX0w{*6LE!lMUQXgwD93III zhC5S6nx0I5e`b&B*GDO`>D;icE$6cv^C@rHyrHe-;_Ypl)@}~BWcvHMMjP#`31UOr z%{}(Bt()QxrMvn_VJz*36i>HPgWaJg&*kZCMkJ+bO+LvusfhfF5;u}P4mY>0iOSg& zc0!@}Ho>#$ushw;Hz@iHhUavoyGF8o!=tBU`nq$e{@$jY=ekn3aDBP1k(?;GBMm7O zK9}wq?#m2@ovYU@4d2k2Ra3g;Dg9NJ+gi2Fwp9N}+6tj)Y9}j&dz!D~70Z`~o3?J) z@WL@QRKsU8{ow%27uD37cu2X!0K1j`(tIP(x|=WD-g?oNw)WPh@WP$x!ElHcOAii< zN8p3L!S24U)Ucy`YB+p@xSf{JtuVcJs1H84N;!4+DFY+Za7J9(*E^WuX;Zkk(zJu|uxn=~YeFn;Dfms>!VVcvq`dIHVb@@053Qi)B3UQuS4C_u z5~p0Esu*MmyLKYit}Sy)Px)DtusahDW`>cF-RaP%lg(s?a};mQYNs_k??%KA7dzrR znUOT6!l8^4rX`NYe9OjM0K2NOa$z?8{1G(@Ezp%hm>ma6jwzs1C6F{neY%Fjo{>T0 zNtbd@stdj#qmdoRRQxcn8M;#a{YrP#CD}JH)Sn)JPpmO$hGZtDg_e32%!S5GG)pQj zp{pGvXi>shX%v#{OZDgST&^~6Y;5lD4>JftHqW)=l~N?Ojte~FjZuc}>D)*^Y~9yG zTMRBUeu5dZX{Ws+nwo||1PCkUa*A>Y-I-)pxNJZV#WUG%RGhI!%m8W&c+na}$rB=* z?oDO8`_nncv@YF|VFbeI-yx>}LzJ`$7qZk8w$Zsb+9dQ}$_YYPpysV+o<){Yy)eDI z4{CO$!##aa4{5YoQjAVCis}ljOj zXSyI`dSI_Doe+A)qrPYu#gddYjp`E2O^}C5++b`OF`tq}OpXw57RadR9 zEg8U@4%_M18yg#EtZZ5tv#pmwYrU}DIM1p4Tw|l_ayMTPp6v>3%oK41^?(svwfCTQ zcBHy?IrQu2PoKlpmhPjcht~7FnR^F6BgAeaSr#l@C$9AQ1 zXn^kYP#SIStP_`^GzxtE^Dr_z zBKaB&*Q`b^+!NjEmnnsWCA2h}0$qVM)!N>^9c9zDXSL|fu>^XFH^AP$v%w>9p_h6xT)2%y07pk)Oo+2&=S~!g?4ff>* zpnQ_>n>KfD?`+@N(b>A@Y}hEl46a7-2UJsG`%^TcqZI_v4U z%~?Y)X@WI817f7fKFjwp)Ht2ZX0njYNR#T;z>984G|Y?)_hNGO#yzQvJ*MG&gSWRn zYinyqCpu}%*3J$zI9+gFTWm`X$(qz9oEnCkBfFtR>Z!#Qti@YqbpDNv&K6G%i(GE} zM7e07$aE`eco=W@(cQgqSN zh{&NH+YrTBJKikH7YC|2A{%|lh;ByRIDL!mKYRIeUG5Zyo&^lk>Py9w5(|t(!aRfE zBe`cdhO<$!=#uY6T*_9zsL1pUF73g5+BsDMo>!%P$@8I3Uh!P3L3(dj+L`&*&=i*c zdo=Dz_G;X7Iz;>vD{e`Y%&K9AKha3aM8sz&#b@Pf3OkHLojA9}WHy_NkbuNA_qdgx`|Q?M7ckOH!&FaOSXj6xz8^=lGJ6nd^FKI0h4HfG{<% zqpx>_ak8Y*I>d-^yc&zx-1T5tly^#lEaT1r#?lfgGn`aSQ)DRYM{kiN>XfxF@K@>PD21p~!0TF|xoVXRZy zCUD-7l=L)&kxv7S=e!kWv%-3V8mf4@**MOXYVnAS*x?bhJKYQBnfVbMuc|cWh;a2| zQ0-KwvxK6AA%^!LA#nL>CTr!S2@_i+ayr3s$55Wph#ZCug)W=MM*Cf4+!hPmP%4{K z!ze?%ap}PvJe+TP*M`2uQ5@D~`S7vUNr{tD=@2K4E5mhC-aIz)SI@gu$b3H+RJia@Ht{uS|k#r>*th>;ir)t9zO)Ek- zsPS5;HQ&NUmBqHIgY6JELjPB;0owt}BxFKVJxg>=N6qYD!QqrYi} zl(SD|3Pq_zjg%Y>nwP^dq>aR*k(D#D$5_N>D>?HAuczw(d-_wo&N<_frsNF2oKGZQ zNcF8rTU@;6?GZQX7{qy!8&nfAls1D9rboFyAXncz=qQm!V=*Ty$}De^H-($M-;Z#5&ge*fh*VyXx|$sovv_8m_XyE~b~J2Z zT$g0gs6BYKFrkdqU3r&=j%WR7-8H&vKIxxlBy$!G72O4KS*ZB9@a&EvIjc>yXzuSn zJEXLWBWXu5%0aGCBuvF9%d3XMYAnfn+{WbOv>~)FmYEYCt!s&Xd=DQeIro~Kas3*;g z^fG&)zRkr?#jU%9!CvzSA>^wMFTe(Aa~2%V$E@cQ-~KjQ$6m2@yTbNfg_=wyO^aGU3n}~%WeW{S8rzBV9wl$aPP5X@UV&d8g zcCywh6qP1d9~UoXL`Mwg)b8%N)4r#iDi}zYc8xn#dxQA-g~&&4Gx`Yrv5ZvmSk5mMgW_PCJKu} zw5f}@qRKewGIPd7-g(kHlFDKp)B0}ABP|zKG-=d00^{e9Mo0DGQ5(q)W#n~>#w{%y zAPgXXls!C57^tt5!=*0$r<sgKF^o>Q5W0R9saK*6sDOmwNsjazm3-hANi7GWUZWdYg^ySiL`^KWwB?UcP zoF9%sz=Q_C*EYCIqR_ZjdJ3ZWzRb-NkO`DYxK!Pgg$?2IvPmGkS9G*_?*vsd#|Qp* zu4SSR(w+=z2KxF_`N5n#xjZ)YMk?NbFBlC-6nw&F-9gk?g@w*OgK&(_qK>|lwo^*Z zv?fm*sav`>v~u=?VH0q)*-vaeNE{mOqfFD$^jk9a%!`+9fEI&s6>Y`Qb||H z;B0}21PKRn)T+8W9ZTZ;SS#N!(da7wKvj$%+PDT8#)(14m*+yy z9mWC*FGFoc6Lo5$>W*wGI~u7us)4=l zYZ%!Ddx95|8){-MWsum&B2dTB-`9f#JF8eCi-jTY z`j}=6GtSn5(!=3KC-lw3!&+vfEhnG6EH^w##+V)*TiTMt z_c6^c`$sBb8H^6Cs=F3PtQXa}jXzCgo!frmbNv#8W>OmV;3{sN6b`+y#tZwLrjVKr^OXz7M z*7RkyQNCQi%;I>>Cv}%lHwE5SaY#~u%Qak>Yd$!|&UZ6f-sQRwr43)2)_+Dg0vkad zrekd$FCW>7rV8r{BHihxQ{$k>jT}p4q9S$C){acBf-U$IOmaPG+^Vepj7ZP?ngxaj zB@Qkmy)TxDT!yqvtm-3iRckn#A+on6`C`oyL}I>$-oa1$Al8MoN@cOGoid2*sK_?9 z*`_4b5`!6O%-Q_P6+BDM_t@UrxwU;$qOHz8yC=%UHNW!v1>y|mH!qTJd&x8}{BtVs>0mOP`eag)uTBcJ(oG&yW0 z>~FWO&igUl)IwxIB^IVZL`gL2E7DbY|D<30QNEt0& zlBbkRge2j(j_ev&Qw^_&ccSaNm*rADXfd=X6&r>c*eO73vP_vk8cW@~YzQZjTDAu& zL<(_JdhbY1b1mV<5mrSqfJyC=G%`Z9Tteky3D_bXr*oY#OmfVU3`91ByjwOy7DbF& z1NVj0j%xw3B5hygr7Am*m=EmF4EDmFi7Z9&HaYjS_R6HuYv=rQN8A>s8V9X)Oz$;a zv2!UZkwt(`C!X41p`CJ-EQXLuXK62`LrS)EzUV zZkZn{H68UL=o_cQD89cZ1)(^3X=jM*qM2@T^Gd32K0IAl(eSQUOz*|=rP=eQEmu2e z1VtHP9?h0t$*4$&XfRE;#D+5ly;>s<7b~vZl8_{j)`AoY6F^z}DOb2Bjw`2QSd}HmqfztSj5I$g%ifKh4;q6J#LHz8+dufLQn73OrWDh z)G3gY<4vbky%rxgLFDYLCcmUMS!BRW!hv*(Hh_B~ zzmXLix85PZRgl^0+?_^$+S*UoC*+2^aau-&v*{Djg)zQc0W*mD5h+lY*$i{+(n;ulKTuI| z7CQlNXBa3#<(j%&Gv{*s$y@5OZM-PaWt_RRVC;pN#Q^fOrsZKf^6qT$^(aY3E}HGy z-GGUbZfIy>vKY_Sa>gj9pK``2XPw0@`c%!7H*t3*cc1R=G6_tJ`gz*%lRxAgt&r{3 zh=LatEQaeK(NFXYeS3MZyy?`2mpA#08BfJiY~sym>cKIk4Tf5rj&f5rO?f@ohQhaT*5^P_Hayr%;z9Z%qyTG)2d;kI8(*2L^egULHJhLFRD%>zki=`(vJWaoOxA;GsF6a5hnQX&3|GK%33=)o z9dr|cnjh^?Vd7=ggbijxshW`k2yY{ts2Y(#!$`?R4GuUK$QYj3REdjr9hPeRSHxoP^CbX0#yoBDNv$`? zR4GuUK$QYj3REdjr9hPeRSHxoP^CbX0#yoBDNv$`?R4GuUK$QYj3REdjr9hPe ze+v}g9G-JQ3hV$~U>J;m--6$R!#Jqxcn*fy05*d6aVX3O!88trnGW`FILuyf6?h}K z4qOl3$Jtb00Y6}Y@vp(hXL0TU_!+nl%;Suzqrhq4954d*f`0&S0-pt61IKf2)zd&0 z>;JJ|Ht@l@LGVTJP0q8r9oz+e1Nu1|EDJJ+1i?P=HE>jCpQ@a`n=8t__h zBltP^-J=gZ@Mv&v@M!Sp1NYu@??d-K@aRKa1zcDDcQ;4A#s409^xj7UABl^gmIKpqjF$5k1e?#V!T=o8XUo zl9?97DJaeapG+{dJCm7~{*ee(J1dy=vhPgN0dD%9^RnfC3ThBC&Kl9-Ztiz2{LFp6 zYB_7I1`#>(f3y8t;ejlWUU)zFGLU}wKDt3VLi$0vL3%+tLHau ze|h)MZ~yP#|K$6(eDmwS|LPY%_irEl;Cruo=hbg})9YUOcQ1M2-rQheBqx75S^H@>d_oUwv0sb@kultFHbAir`W_T=~}3AHkRV{R0d2Ll^2t+^wts zpew_T?(+_J|L5-WGWWTQPZ#rkE=cJC-Q~c)x}bIv?Y~5F`DEHfI{LZjVCiJ(W9ee) zVd-A!-B*Lxfd2%4NVH9vAHPcmEB)i~WU$gd9!Lgz(mx8SP>^ZClV2t?E&b!?$zV_9 zM?QX?r2ovxb6)nAKL_r5>J)c9#k4}>SL%YASJGAIHA18$K`kBW%us<)zN?S zQh7}NYG?kcFMstJUDefpmM@pq)AKTarmkwyChoq|06O)zuKxRZX{xJldRWqUiu>H^ zKC|xgYWMjw_qpN`h1uyoujJFEcjKeJd>_hR{W5>`tNc~NV?NxB$Nkm&^H*R0t-p7} z@BG#N{MAu;E%@2|)#tc6QF8ge)usiq{CKkQ9!~zaujG$kB%e(1$6d)d1wZ~L`J|u( z1!a38KMrncrAtuQ+fyH`v{^5^rq1+$t|Og5m+!0t$$wH;94Yym6v^L)NdB(m`^DfL z;8hkj(!^Fw}KCX zo4|LL1i?LE=SiGJ41Nmk0jrjACMoz7xCML{JOWN!PM)9*oDaHIVt0cVfmec8f!fn3 z8(0gjIXwtI0!}!SxZwBT&){QcV{?EL&%y2mH*rqzPr!Anurt7C!56?y;7i~u;2YpQ z&Dbp9pIWeK!Cm0j;9hVaxF7uCxBlNF!EYbrpMCuy$lrI*fAxpoKFGaCI6wHekK7a7 z6FicC{zzor-xJ(<>kn`JuUiBDrY}E#Zg9rb7Z0otCQpg3XV+e)N71jXQ)_}+Le!pn zQjNv{jSZJg4sQQVJQAQCz4dS70zXO!+NEpN#uIJdlWE(fU=U=$o4`jvxpqG$(e^iT z{qNwC#X<0C@NIZNyzonKD(&A3{_xntzxnmuKfCRR4}b65U;pw=pZUaxZ+Q2+9)8DL z(fqG?@eB532X=NnPt|wY^P#++KPRurx8|?5<*#<-wfW8Yt8R=YOJ#TdYES;^cloO+ zvYlLRQ}b6cvgiTsj)e|2~M>KFN|`z$9Ja4x6a z`5N!ZU!9fD{p|eJtrqV#zRcotv6trc|1z#lcrkQ*33w@Z8F)E(1^7Gg_uwDEKZ1V( zuLQ3GuLiFHuLZ9IuLo}cSAjQzH-R^Uw}5{JZv}4y{{r3)t_JS_*MN6|cY$lcb>MpN zui)L_J>b3Iec=7z2Jiv!L2x7Z5cn|o2>2-Y82C8&1o$NQH}EO&Y492FS@1dVdGG~r z6Zm)VMerZsOW@1kE8wf(Kf%|)*TK!;8{nJZTj1N^JK(>-E#SN0d*Bz~hXA7Q{}JCm z20sB3<=eo2gP#I*KDUFPfjhv@!JXhPa8`}QKPmcFT2IyA++aTE`_|wHn8it|wd7tK zAeO5hoF<>*6#G6- zsP7HJV1)}?6V#tjvuY6oO*tc06IwA=7ma}u4`%a}81t_CO)&qubAnZiYG&%>dGwn< zeEyuE_EM#BPSG?@b!pTVrZH(ME|0{~^@P#iIYINPhxWhIrF1AK;iiKgYA`}ghbjLS zuCt)meGUaXxwjT-4DvMj*A%RV3J(QM+-#s`8E7y{*iO>h>%!JUU5&hr21|ouMYWox zgs;z2E$zfvi-8p6b^;=N_0YsuvLL-K*$FoY?b;P){TD z}!u|WjN&Indvb#{YI(Mae_4#|Gq(AOWbr*`;;I0C$l!N`{2zb#< z?2`HDnIk!?Jw&Ha$q!S3H=ahH|4ekoDuq26)Ht0rDL9Gi+TcV!Cv#7AJB-hIcRdB_ zh?jLg%8{#c!4A*`20;cq1Re&D0Dsu@B;7+Fbn!U16%~I1TO;b2RDFk9YX$KJw$2)UjknShaHap z4(tG3;H}_opo4bk1fK$*2G2g4Gw#7L$C77=PZeAOwl55VOToLqwcu;uE)X0?*}+z@ z4Ge=3u;ut5cox_Weg^IUkAPR5fUN~4(eAZi0q6m51>%K|fZM?Ar_oN}DA2f=axQ^s z!Rx?v;1SROYfJ-cz{pbkxZt0`Tfs-*shhz!z>mRCz)w#>XM@|pB-C9kSO|^-?*Z=x zSFC`};ML$Y;G?I~CxIVs#Jz6sn3?gAH`0jnKdA>ty;a49P0rap6g}==~yPaAlJ` zjY-GlRV4jnU6R-1%21&$Pda?5I@XV`%ahJ4S(j4zCfhMdHKRdaVK(JD&JCZ>09#c5`}SfERs&L?#XM%SEcx&RK5pr ze_US4a+XSGBITI~%}a%u2=A3D+rhe@tm9K%o+A3BRJ%BSIDqiu(n;2MNO$TjE zkVQ}bt&9uy&42P^gEufPC^kMg_SnDeF~Wx!6a1}=6IvM$JQZVw>sB#-1sXHF1sRzK z+}}Pv_vudlZy#4h?qI09@wW?CBup0%l+G*{fRBCtj=xdrPNkF|A%VgYKJh!1@{)g` zuonJKTnm3EuBpFM7^YHQ(l3R1{Uz?iW%jvGQ2Hd( zFBLbLSE(=uaDSZdp;Q@?^-ZQUZU;{KKS0wF{E7nOM&%`4n@d|Qe? zlXRE}%}a$T)$YmkpX%#m9iQs*6wxQ8+QrfT0K$(;Ct0rwZ9Oh-DVmpR$0B)^)q7FB zS}q`Bsk|!OcV#YBo>FlSR{I{PemKy4|Bw0t9Y3JCFq5kOzbCjhpz8mtyiVY$9v5hB z%)uTTEL&x3W~=@`tsyG!#q^%Mcx3PI5Yhhj`8$=uRLbiw;VX*E>~r_kihWlTxidbU z>K*7-_5bCW$5W${6dX*?*;~jo=0l%yzDWE0o$+D*n(kDhnEL6$njXwMm2z(l$L6k< zE-cUZFi-r>TMOFsiRV?RUKbu$xnASLRPQ7u?uk)je49S8be>qOiRNC3f39FPYM~S; zXTRqV`vDQ+oN-5uc%Gi|uHtt9RFou@x90RdW{cLy_4jhCq|9GES)EsdnNv<_Ww}Q|LuF? zeR83;d1}+C)TY(`f2_A`JjKS}DQv-N|L=u@@4}v34-VQLrBz6ISq-wC=O`cj?Gp;a z=+1cin!6MF8zq#-3lw9r?GmFM7JB|U2+rh|W@Oey&$NS)b}`XT2HIglJ4I;MhrP`f zo&_?&GXMn-Rsn7YBo(xRwLs}>7aYac?gRHdoi{kw1OXG?)e&i?Ipg- z)4{vSdUx5LZ*b4;ZRTC1Fqar9(%I?W_*Dr*V(6XX-C&RqN@ZH21aaQ8gY${2GUi;F zRI&@nC+Biho(+k3mk>_xQa2__torCpW0fSu=XAm=wf?BI?RzsD8p0%TJu4`V8|=v{dW0lAE|nrJMx~ z#F;%@r`Zz)jwXfmnN4Z6D}ZPs z%37;m$S;$iEW8uvq>>nSY~tJ6ubcR_aA_yu<`Z8#2<(JngD%f?E>GGtfJ#^A zQcbz`P|Hc9D0P)U<=yLkSxsgI+qk;{&D6?12GS>6iP4FyZRAcnx%WC+9KvtOSC-r) z=RMq2XzlSZWOk}aV6hK9-Fw=Laa`{H}k6l&7{33 zyaw@-Je_)HppkZ-FfO$+G?Jg%O>H6iDQ(4;6xT+%CrjaLDs3aW4DfG+dW&i?ZKOq8 zXhZ2(Nlzx?vMjOGl4@VYnjWPwL|kiaqgtJdWo^6AwP$gOH5sVfU(}#SYJ%gzsbCYh z4D5kct0|%QTj`6()nW_a7ST{TN4?KFS2M|Y%C+K3cJ$CcQ9xW5_e)bqPi?)!eWrq= z#>JJ6GVT^_E{}2;pN{l*&e2pHJd@H{U!oF-%S_j&NJDz5c&eTQYvGCu!CX>NJE`|G zS#8bBvsz#6o@LvC^0IOdHLuLMwd@J=?ci`|IZ=6j0qG`Xx)%Psp7I`+Xd`KP-+!sJ zUT>+~zDH0Gt0(Ha28b_etGuyhw^SsFAvR9h(QqDeB`LTZ+GrmT#germs%z(y-8>WB z4MAb|89~pmdhLAze(hKBcYzoRSWz0=<`;7pFyi` zAqUB!G)Idoi7bs?N+ye7_849Z>7A?$s)y{SMp{zsEy|d@$~v$V=1Mwu}*zG)rwD~J+=`mDaDoRc?>bim9SLZ zX1WrVi^(po?0l69P7iM9O8oZq9@!%5YsT8Q3qsZQF~WA#$Of?59*%Sv^Bn0?I3waB+zDm_qX0i)e=A)oI;E}~VIp@+-W z@{fd6xTWkHHxuqG%@0SF;9#XtzGi=954o=)3F472Q})t%tZ?NnHHK0OM~5qeLo0BH zr4ojuPOtSVbQ|a4RKJtaKeAZfLoFYomp_f&1HV+3lcWXjrNxVD-EtCfJ>{t+ z&%Y*2d9FXSOp99V9;_ExERyAN1y8=<@owuSI%;hSx#FX?P7bqTCOc>2wABu6sBBBDrv7pp?GVo zWZB(`x5VO-yl-BS5#%$=s6n1CS??O%Xhf;8Mi!}V4ZbqzT6(_8^u=?6Um;6}qD5sn z+PGDAeJ8(1u~_7#Fb}IdZW@&iVhNO%==K`baABDc@&FaHmMrF?@DH5Su@@^wBY^A6 z_Jrq?({k!igU$31+Ng$fe^FpRd2gut@k*XH^(EiKTAhpBE~kv;y(mXTKfOL9mCCXqeIcij|AmM&}iDcm@}NT$y1#oMAGMZ2r0%M5*uC0 z^CvD)3(I=TFdn^}&*|uH?Yn8?xC^+_sCAG7D#m(mcDq&=Psn>9FN<~@T?UQhcQBr? zGMl$bW6Mp^*isy&F`Ils%6}Kn)<PJXw-P$(V0tjm^y~Y$Yi4 zclp*F+m5n|4WrjI zx0R&~UM{6sG$W&$gygAz@;s~5qN-_v!k$EJW0I`8$X9B!zQ(yTD7Duhg_>iIYgNVc zzG#~(QwyvAkVP|@*z2ijD|Y!hQkRU_e$5>bXJ#mwJhnq{oJy(EdVQzg(noQ6n!}Xl zQmMNw{%~sBs}FNpjWq zNp8fo#zi(u825dewN@&zj+RxYnFOUa97&$~KlOepsg)x|+J&^yY;Pe|e1ERI&5x`y zo4ho*)NCG3vlhn(E8$|viqF}~J3=cIseZCYa;#~{{}ov^!m}c4JG9#4sayZC zm()G3P~j5mKR&{;5|(yMc>RaMSJ!{|IehVCb^S*vk9BqZM|J&&x9w^*@?9tFHg~ORWE?p8r=p|8Jt_ z|9xmx;`~3HfYTWN{Uy);yLu64l(9#})$D|z_tI3p>iK_vedqsOx-bY*;977UxEcHc zOk#JOTA(+)F9N&49?)@o5Ojha;7)KCcpSX;gdq40sH5HM!LgtZyd8)aJ`Vl|%;PP< z`9S9m&t6RWocDJXcq4cZ_$_GUO~097J!k`$v(w58z}4U#;4|>m_rUkT9pLBS7wmO% z5BMdR&Rd2vz)9d_@L})~@G{Q*dpUSBcnkO}`+R>6{0#gN91gD@0mQTK0QZ6WL5lso zcYybT_kquX&w(AdySqR)cp{x(1@HHOUa%Lu8hj1h0gmTY$!*}3 z;0Ewt;C^s2uQi?uhQNEk-JlNnIUbw=J`7mG;?5LH?#G(EPM(*Syzll}on&##?z>tf zeHR`_)J^cmxVW_??iWd?dJbTDT1}X?$#zV(3y#8k8>sX{-Wy2@qCd*u^JVnC0^bb~B7m@J^m;XS^&~Sh}Q>yNNi}x{&l7E;}to1lJ zXNGGB-Rk*(*!IT;L2DSFA^x{GhWHd?hQFn8#Ae0|PsLc`1FM4IgFs`7w*-G%=LG(q z@~X`FzkL(AL+CNot#^z3h+Zwr4T_$#VSBgazgVBV>e`|NOR?tdG1D%I=w)pR zE!=mv`Yu8BU4rUfqBrtpdi7m`@jHB1_Y&3K724ZCd%BgfrmK62W`pWpqS~p;b4ztE z(G0r?X-~T9UZUEytTw3bCFh7MD2yBogu4xiE3Bc>RzJNy+o^fiN<@0Y9Cph zR%tuG>I^{bhHSg-Y6sI)pgmKy53Obk=eqqcW9`TyXww;dc zj?OsT;-2?YlL5+=+|9R_+_aDHD82{n4y*lSbw}qAYR6dZwyK?K{dr)Ax_xN(x>Qsj zJB3gs9-+RGb+(=DaXZz~TlaMy+YbIsqeN;+t<FbP4oqZXfv^kTyYxi>P zlCFJzt(C;nk`>zr*zZI?b`N@a*G0F>TwJxgac}WG)wM^yPNx*lWoXId>4LVixIb5L z3L*L^fx@eWYB<58hLdz8725ZBfDU@l4JNjtPf(+8x}- zoeWniIUi&?oGhLld#2iCo-adtJi?m9kdqoDGdiI}Cnro9^Si#_>EeoXFp2S}4r^Cw z+ap|8+Le1e=NBvCF;1$bO~#*OTsh4e;?={s;#bM2&Wj#@{#9*M<2h)8uLsw1s#gu% zuqi5MAyp>l=`#-seIr;Hyw8Q!F5b3x`Pj0Gvg#qUCwPi~I)z5kDycdHsMd;Ic*5?- zNVU=_yB{ZvKWX<9Tpv;4q|y1*ZF}&k353*+<)zNh)&4#HoZlM4O^3c~TzeL-MVN^; zDV@q8oM-xzAPm1lX%cj6)TKdP4Z%A(AYT-I+dmz8e^U2o&v*4zIul0cRcqHn z^;VmMr#XHzYewgKtAEw5@9KGVLbk=ynGWZ3Zw6c_Zc_iJlBmzL-L~iPRPyW3Sg?}X zxvOR$*dFhb=vQ*Iop#~3(<_osm44i(*~u}s_O2%QFnwE0?}?tG?9VoJtq#}T$~lEO zWRvqD$;nP8uAy!<=&NJ7Ckvz0x#5@A$a~!B=xcl9Z+7zI&v@6_n|E@K!6bClWk}mv zQvDoxO~&iI68hZi?nyIl=St^Zbp^j9%qp;yxVHqqci%d3_XvJ}WzxH8(^C89T|%nm zz1eosTMd0oX)Q66H0%`2OQ@U9M=Gv=%AHhZB`H6z{Tk|{nY`E1>lN=^)K}~D^<|Xe zU!l$U_~z!6D2-MWD9iZ+^9xt0hxtL#>R4(tMO0?9Wlbvr>*x!BC)wNu^9ZJd6Z_3&%e@ead2xn1-HJp>C z)7vD z38wo6;w8@|_USDyNKaOFdEO8wmE#P~wc|Xzy)`MY;J6rjzaQxZIMjM?{d>*-; zj@~YHI`J*!id9&1IvRc=rxPpx@~0Ck#nPHrEqfm2G7czrX5$t|ziS+SoQKzIrpA@OILzp&ko3$*>Z&j}Dh3r>UAtYd+|F9U9>lv$}soDbj&T{q?fpbh@9F^^4?R zysRO4mTzN~e}4EYTB7vXivDa-JBPO1S(flf#j`9GrX1Ia({2r359f)(FLo{WUHYa< zXI$C|z1I+4qg};raqTWjUWcA4->Yc#ZuxRmKJV0@zq_~Q7J6-y9G#&n4laL&uFt)6 zAK_0=wLBJu4@RfqDi?o}?G5C0+a#T2`&lHWTt6m>SrC>wSG8OVe~g%wxbE<<5-rP} zWNWc|Xf=P5ZDq>eMcCzxMU3*ER(8^COsh&1`EM*gjljpBs9x?oS;@7hNV)T5wf>|$ zhgIV6uMvOzDXw;R;vD~v|F9R(`){_;C)wV9=Tdl5W6+cFTbehnoQ_yX zils*$HSm8O&rgkbyA~_xROnTUXHhgft^#jsY*d-EYiKhYqZZdx<;pLLlrFz4dh1JS zXk%GR=fSh5K_OYbs==|&W6?$LTKO%oBf{nAkgf2~E?}PDTH34&PS^R*U2s%+t4=AD z8Y@o5dshb+TuV7m!&Z<+I?t7{1|2>L%8yX?v%!V@YA0k3K8xcLz7x&i$m1g)jb=-d z9;dq_Iu(~|`6RBz`*moA_I!~`#rp_r>6!26gur=ad?&rcxE_D-4fsaNwd3!i@)hR* z^D*2M99=>F#6_j(E9_oV<&g!<*tfJ(8yk9?P85uktk7%#b{pg=d+~be?ZLwG$xyysD)<9sZXG zbqCKi%OsDfe120XO*0bH%7|hM-&5VlVhWppjluBfWP5 z{i{WHy%@_(-q-oiy_C22NObi)Qj>jVXU0xM_fLYO2GMoWlb66@Pp3q+!3j{V*o>O@ zdCsEM&L`aQj;h_%pm6r*gfcSZN2nh_)>fc9B`dY0P<&K8+m*v+MT^geEvle9zvwi~ zTBy@OJ_{=J1oNDZxU^;~VV9Jtg;DHYN3jbDyQl)iX5^oXza<0yoZrP`^ie$PE{!qh zc&Hg2l0!FWc22rWlH9^?TW8ShctZ31lB`iI6AN#>rL>aPUx?%Vii0}zO$X)JjGW8? znjO%*n_8idkUL3Hd22O=?9Capk+{j$afrJVLmsQCF1B*Wk*j9wv@*cbvl$?*w@@l} zu5T}CX%@z>YLGS^aOKMK(TjxpF6266RJ9l`1yILux(}YJUu{{$_o5@KtdfN!w0krn|2%bxK z%hzw?ivibyTGJu@*XJmcb1kJAtuD&ffF9Z$T;yuAiS$-;rIWZtDd}3p-Gyys=ND^! zNqt8z_obIKH>Ladp)@IL|xl#}7 z&mgurKArNcwzhNHrID4VeA`_-QThDI>Q+Y0f?3Pm^ztWYhbj-#HiOne96X6bjx~D z@4!a0yppFl+pMHkHjO}cogm#unra*4AEmBUL&=o4xjc8dcCj@{T3;c#*}xN9HPz_) z_AKR=yr?I)K2lUaocgso{%V0c)U$1kI9)xKaa%{kN1Nb+CR#bx<;|4SxI=T2Y8zWS zpgB^tiL3|N9BM<)hqGuOt+|nuXq}Dms_2Y=llXJFQXPy#;(cT+eaW%%lKhLOL{m%K zuZU_$=rzf;N;sQ)o1y$B!b*N6(QBx8yNfGnl%$I!_gK zMU>4#*$zi@>q-2&sS7E)I7~XCpVpHFZ70tgb?uCHX>jRBNu{j`6Xn&TXkDS7i5JzS zZ^VOE4snfHzO!9@#23mzwSQc;zbX(goB%DGzatw6)phdTzZ>tYhNdqXTXj-?B3)hv{h3 z57r;rnmmmR?2Qhii0CXS6PK8Fo8>f%ak0v5vyQR=#J5_@+3sp-Yh$d$(mYxCV6vm5 z%5FXy^$A`c`k}d~rZ-k?rPgfHmM)hyEsoa6LNqe1EWS7ITHLy(E#fvFPl-Z_(CEoD zy*N#}%IIzFV^)P)P@@Wy0CB16S z`wK~1RGZ)e)J-Aw1dQK}-yU9g8RVy*t-M9E$EhB9=jdX1#Q8V_1 z^(Pyk%!}Ym)mAmI6=Z(pjcM4p^y;B2_d?S1)(6dU7TYj&Q)#s-*J>+?mS#1JF8SO) znUa@9Sz7~+#(o`5Ya~-zA?e#jnr{pD6;|!2+@?b>-BBxV=6jfD`ZW`pNLr-VOc!W% zh3O92bhg^q^orUq*6Ff!>Y+gsZP7$6n_MrrjWFwwd-XWt%gruF%|v<5vNgoYO%#xf zsSlRM5nrnuveG2Kvb`pwuO-E@UDR_a)>;=!>8TfxzMtu6D{bRjOIop?I;u`eql30; zcWHR-Zna%Y2=x|O+FreY^-*zuY7%7pAWPmXZLOJ7I~tEmb~ga=e*-14akI35t!mQ> z(?S|IQ%>X3IfRiNuhdjGQEDgDkQ7=Ai88+C8m-7GlYi01Le`?vw5I7)lX}O)dZPQ1 zkK|L?HR5q=eesOEEz(cT#89hw%T{B2{nE-;txVRKrk6Ua?=y*0o+|Zvmx_A&QAW@0 z{8BAU8YQjPo|h9_>8WM9DVKT}qpb0Q^<%1?JZ+}SjUH;*J>)rzPMDtWNz5wjhr5;P zB;u^6Y|>$pU9HfSW>bB&4qCMk&7@(}cXzomn$4nj0yjV8+6=fsWrRuq$rVSE18Qeqp^BrE-9H*BrP3_Yqp2@ z-fWhbTQiPpOs`JPmrwS%YNhtm%0cm!b`+3K?L)ddi4~6%E^s-Ur7nt2L!+pLyqv19 zQ`@NZ)$STwsCSSYNQU?DOq?qI^()y2T@Gq*=?Oop^n9L6YI3xlV(J}%v9{WQg_Z?w zysCAKe)NAiB_5)D(p9@$jXme42yL21)}mxeb(>90g|@!Ve0ipoWDTm%R-YxkD!QnD zwf6(O<`NB*hPch7rj;vIlUXAlx6M2qdC8()9NR!?8pA1 zviMoLL@P2)V@!AQCQg%$+~)2|@}@hvmt>e8w-Jl_2DOE_w(yM#c}7*5VJM`q#aDY; z>9l`|LaL17?-3-`*I8|=@tt~Qjkw1?wK^ojs4ui$Se$G8CXUk^C~I9=#9`7p1C&`U zHY1|C+STM+^;a*cv6W~fi(K!4NQ+x&wTPu3_d;Xe7+4*(o#``ac)c~EUU3jl<>{pB z`zNg%7Jtu(^r*?4^ti><3JvuUU6e?p{1)Qw!M9*GnMO@5w5Ifs_gf_VQRCq> z>C3yJ8cLe|cwrV6hQgSfYoy?x7&kTIRhHeQ-q1XR!{lrnqfvr$Ph?T~ae?X3U4$0j^t<&y@*S_G7OjjbMR8e3TgY1@N^xm3wKK1HEl*o1=`5%w z8(Dqj#V*tZTxkrd` zBkHZuUDc`lW`Ep06-sE(qF{MDKl z*hVcocxHB++D0QZ(NorfT5ASW&>gjbjUKIZk}+EeZdyjUiC4T=OMRqtj(SE*Rh*k+ zG~Z0R;>>nF#WUVBBD+RutF1*#X(zJ=)Z?lYO2OM+;z`wNHS{r#)F?_c^%m4DEI&!6 zdMLGqe5pHKpR8QEkp+{1*-jG78&GWAr#TWoa@06OR+9J7&Zk^vhxoFaH%c`aB$T9I zw&Nh0tBp_7P8+$SQMXEEE7^y6rc^bK^u7tLgO}ct)|aH%C{NsIz7!iN=`9hpKn)s3 zHeoX*+DKll#O-ib@@`DwT5>f+DjMlbh59zOR*$Q8n@b%fT{d1-9d{El?QEBr|K)p^ zU#Eo@iF*L?fqZt7d3h37JI%6%u%|koy~b(Q<~EX(^`(AHbP%VjB}EIridG{Zr6tdg z`N`EAs@&2|x-y>IMjfP!2AOGTCVrvk#ac$argV_sJ+;u|HWNCjEzR;ZD^*%dyePZX zMwO=3jDouR#kAuYdUPkl|m#??_ddtK3eUIxMB=4h+9`m8C z(iTVf(S+{gh-I}=P8zSOpGyZnqde+ytd9}5NOIEAQ(YH-YLcxMP-x|3d@UZB1=lF1 z+}+ z>lRNV)0msgS~T6El4!0!?pf4MN}+{ZTPRN(ttY9HXI-sioTRdwXHfl(ym+S16-pjJ zajM=u5;qkqt+ez8N+r6hs8pK+bLRtje4X!d1nz2@X?NKsHZ8&4%|G>w_0%QEn$ z^sMM@@5HK46PI1!_)z(qRUzMdFLlu`)lytJLVR(sT26JB7Lw*t-zB~Z`aGd`uX>pPXdN+64DC-iT0)K=R``->-~msEnR>&4IKiOO$&k=Qog zK;F{Xrdx;MwWNPKNmUz9nx!SpV|*iuC>On{rm>*7QZ|URgXpH(i#ufTcDirX)1HfJ z>ZxW>Yqh4{Y*Rd?re13g_DDS6BEC43_EY+%E45Bll#^uJm_eMUR?$d#2jwwYQSWJ* z$M>hQ5#)bST6$vratA5%c~^Go)4eK^LH1b{WRNU{!`7`$YS0^ zDOxGNYBLN6n~!!j_hiMWo<=|E9O*f;fTd?+zl5}odTH^7+1`E}D4W?zC;HnP=ib`c zMCd)vn`(FBcl@Qz)K;UeMWn$rN)-oLKPjG)7gnvNk$<88(Z;@-p|!q5D^5kLF5>hT zjKMVS5)WjYS6uBqO!?)<5%m?DagwtD^r$%NvCPh0hd$O^~&N1m2pd?jU}Pt zG*L#@pL$d25%ZlMPF~5kQhoiJ2&3_rG_pyC+RRo9Y+*&t1!yYC$SCDCzA_Eb&OP

;w>TP2)`CKVqlUyW5{ zO{w27sWLuR|1(N^Xso08%`4r%8P5Ka=1-%$mbtwL{CHbBe#oV%wAClbyCONV-b}nA zTBvmjpG%|3t6^H$`ZJY9`cQN+8k+Cd^QK9!ct8>+KZ^P^>z(B*H>)6v+-NO`#=#x% zL@OG?ECBV=l5feamAY_G1S_Ft0L8=8;R>U-VkvKpGUcC-YhrTfy|Cg%@s2{t#x@Oa z{xDe@N>RFBv{xF^<)VS4)@x+RrYth0p%zz*NKcPMrP3J6Y9oE)Ed}%ZNOt4(h2kFR zL1|@aNR9QCr{Bft z;vLHJE7|qNXQh?wHF(?YeWOp7T#c@`S}L!Yz0{?%Ap8K|T0MRsEV6a|-wVmGAk%r+LpxA#S9E2e!)lK4?6CmG_K*wcBC2_kb0zbXm2w zTYEuFrpyb&(|AjyE?PmS^3}3NSL?fL-TSAr_|_Yq@}WE)=xq=Ct@kY+;9Boq>6zXJ z`=}wyus=zqBjNS^ZwL>e9s8J&%5lCN#l06%Dm3Km1pbBYuy`+ zHZGTRN*hQvOi!z?QGc4W1m(Gq%_JQ;?ACut2S`gd!=;^E71z<~!)8gN=_b`;7ic8!@Oz4BDqcx4bXkL-(D=2D^t*^V-(A`IGf_l#nerarqi8ju^{w*2Dp#Y9*Q$C4=@#%~ z$Cs}`2k1TH`Qdrwr}jOMKBhK!4ezj7d%vHY^v1#$Tst2bsU>eYNqseyJCJ(3S5z zB=cVQK&@-mx%vkA4*Xk#$vfip4DpQ-df$_a{9XCh>5(-`(X4o z@4fIr<+pjiOX_Jj>b&4R^imt(ANAmp9&xkge{9C-Mi)-JcX!!vdYjkEdKdYtkCru5 zxB~hbSEKU1NKNox>@QJ{F8=+>%5U@jnEdp1)KXGBszggDO!*T1814Ec_-hh8@?!UW zKX!1XcOC6*-mep0c3rKL-dmxF^hD|1NwhaW`SMhLm(;(-`(w(hw|K>=dW%=z(&^Jm zwvW%fH23>AQ!S6L1@ppl;qQ}OF8(dvFOt{etYSY6o+uZ#P-W`~SUF&OUcPC!U(r@wlH+OyCrZ;!*CpUX%_c7$~Jl&a(QM1GS64PugSc;&S$|!k4#)KOep8_$At}9r{f4UB=Hx^_1l(|EByR z8bz8_C>!`%tX#95E5DuivEaCcU##$U;@hJfi)$s*yeVQ8!#+jg%y5B~PMSKY&vdc>~a)uj9&`vz*yD(y6* zy{a^xuzep+#&(@o#tO0>r!+RXgm}tJdqe4aVtYgBo%>3ALn+J!v~?+K!tX~=y0=oF zy^_&asT7QM<$4IEpj}eRN#YM8ekpGAl#8ji%uCCSM!5F{3(;Y=zS-8V%9|p~YV2Ht zEN1Ph^dRrHSKd|WNJ5wI1?0Wc2+Yq}%8HS%PB#1D$e?CnSwF9Gz#=7n*T`Ndq1~rJ0fbn z+TJ_R%HTFQ(pCbmDo&10P7S~GdJ;vl}K5vh%8YV2UvK8; z4)rdB@>RLjF2*PFIBR}N{yll!HM=kWqU>pVi$qki5qWpn(Zf&SdyPcpNBb^(SzKx_ zi^7}?rAmz$Ey)_Ss->hzvcy}^IE(DDV{8k`kQkGuq*ad+h(8x3BFU9KI|DvfVNpMB15IIN5n z@=f?t^z30*K>z0IA+$-kG0q3j$%-Qj((j~jLpaeg-4L1&&2|7SM|VF`S51`udU#3e zGK%f2JXV`F6rr4EjHLm*?8?6^T_%YXe`^h|Bv*cPn|t5kq(k0&y~AT3C;61b-;y4` z!?Zk6wS>@WC7X{^I`Tl-m|Rk3++fzMV#^EXJzknAvbi3~#8mi9^9%BdY5pn=mDe%` z)*6Vpt`16DQma)yk~5{g%;^-%b1qaGJL9k1%#)`)FKO+ZBwwqs z)i26_p?L?jiKr1j)x66nc4~Yl8B+5nqM6rTU5-}LzuI%xD12;zEFAc5&d0-xPyXNa zjIf(2r+KLAD7E)aO?G{W+Q+X4(Y#8ltCh8QI~1^fNxT%lO=$j0&Exk&W8*iyKdkv* zaglmmKM!O*isnV*d068?n>+IFzNig-yGiOs(LB=R;vTh*Xlk=D;#Y;xvv@90>w4|| zQ~$<+{LflFW2=y~X4d*4Ti@Vk)^|Cb9naHwu8=*VnMLDrzp~8i4da`*|FZY_Vn3l| zQ1*{{#15#U)g|gzv*>dtCSSUE zPbr$8To#wj8+t1H`N%b{)@ns@fO5NpYt>BqCQB}ij#lQl#`Vl_@y1-^YCF8OmBH0M*k+{G^Yh*vuUN6MpKF> z9-L^7P4viX(4JZi-U37?y>BL)sFwUUqPMhWL;ZqeMy2TDne602XqGHtE%|CS=UDn$ zDs_}kr4zOE#zz~Wo5|0w2+-Ru$+gkSZwdB#O~2 z{AjyB-Hdc@bo|&%EVZ}#)gfwXvL#KG>{G?xl3H z`qs`ex_@-^eQfl7LiBxN^nFb9t+lBN-xPf>jJ{V#-!0L%w1&d1kG{1xjDBy3zB{7t zBctzUN8j2xMd6-@^q+~%uWRi;qwnp}w`PR(TmB(^%i`DfK=iG3E&44f*SG9TeGf<9 zspxx8^u0IwJ}b0v?d)Ev@Gp$MFRih4d&WuP81*``&BV>~(16k&(mnPbi`HVAjC*d8 zgzNp?U}iJr_g)g?Mz#%CM`1G z^>#|dR?TwDBGZ(mB#oT1)BQgDbYy($>fV zd+D8fm0#4d`D$5MTCJoqXr9-0XEWcIyk!3aH)n&r^jq7AtG%eqztQ6SFR?$P+3~*L zuT5SNZy}DI!+aVcwfbLjsFA$sd}*^ZJaHrvQut{$0G?}$&;^i zrlS|;(3gncy~g*eg*1MXg{Xc^YrGdh(?j4Y^;_!A)z@kd&yby6HxO36rF67u(-YwZ zalK#jq#nz{h&!@KRXZuEUlxBz*O^buI81r!=`PoQ8=op)$(wp?^;s&ne}l(+gv^(v zH_7F7+DR@7V;reCJ{K?BvO!gb$+VKa;9l?>aQt-g0B3@8z-z(v;70ICa4Yx)Xq*uQhk(W446qJ73tS0a z0$vJU3qA?H1deG8g5$t2cqRBM_#s#`GYHm$9bgxDKlnKK5AZE;2Y3wp+pHk?GWa>T z2h_|Cg8ASGa01u}+CeYa1@?iLgKNOQg1R~I1Go&l09*?`2L24@%ngD*FaUl8ehp5U z7X+)oH^BG6UEo)sZa#Gfv%muI4A25D0^Q){;9tNez^B1I;9l^YL*QlbkKhg9ec%J& zCU7&DbZ8LNgEPT7U>mpuWWfj+1up`x0dD~B1s?^=52FmA4-9~pfLDMIf{%hvf-i#m zz=L4J5kas8{2h2Ds67%M11|%w1MdXagFC?8;P9hpJ8%X#2kZp>U>|rHxDLDrd`0)Gcy3vLGA0jD2_ zEP>a8H-g8H4}w2}btfRV;3eQ?;I-hb;3MFZ;NQW2fJedOVAYApI(QD~0sjK70p9_) zfIovti-O=-a02)^_%t}?X~-hz1Eb)L;Ge-)z>mNci{S_GE${;B(;L!MDM8!G17#8D$6OgFC@J;D{#53Hrbw zcm?<;@P6;W$UF9ojyZwK!M9|1Rkd%+*Tnia$W zo51tH^TA8NE5Vz;4|Q6@HOx-cpUtA|1A3n=yw2o3LFI5z|r6Ya1uBfoB@`D zw}7{TuYo(jTJRGv{6N|R%mt@__kxSTQ{Xu;=pe>A7zJJn{sqhhN4`GGri0IcFMtQY zdpg$M@Mu3aJd%<_XTF~nd(giz!-N9I}FIaOZV*m^sPalBY!B{XI90yi| ztHFK~vh4GqCw8hW_~*7k%=$X|C&n87DflZ`x_W+tXQT0lKj5BdwDr8p{#HDv-=K4x z+H;s%UWKMm-;VJ&d@b(EXDY+X-=*xe^B9+xyOuYJbCey*UG+ySmy%{wN3L~N zSVZBzCUZVfZ#8diUb^~qjlSu+=i=X31#My8)xJ$GWXQi0ybD|e-VNRZ{uR6z{2%ad z;NQW;;C@Huc3xEXvNd;xqB+ycG?z6@>!w}G#KuY#|EuY+%Z+rc-% z9pGEwPVjB;9q?VS27C{EAKV4*25Z3&zz@Ma;78zI@MCZvxF0+Keg}RAUf#HI_f9rd_CJL^X zT95n`kVc-7;T7A_GctbtDQzFVvL#0SPS|zY?;MQPAXmp+JJ`1i{3H3>UP~?4=l-@| zg)ZuG5hG)lO+?ez~lQ=jYA^L&f9tNjS-mB+aBjXb-3 zrXF8v%#R{U_9$pbev~|2!=Ja(pN(4lpmMDim-|-iB-)LVUt>K_-*wb0^+i2T-*k3j zdoEf%it0(r9mqw$j>ca0C7x^47d}(3FB*-k(Pc~1ab(4>UGIt7KF9j_R9oW0>!`gw zF4<;RXL_x)!0VpICfm^`#I-3bG?S9&%cI+V0s{3MQ$r_HR^Mui2!&;@) zO1T_saq;Hp@?YVo=V7n+gwCt$YC=bnQ}pfja1P_@&p{eg`}ew@>}tWAc~0whJzk{- z@&LXZ1K~kqDV33tYMvYW?l zajk~Ks99KL^-r;fj4-W5_87ivLyeU_SJd@&2%3m8$2l%qJ7YIlc*AIyt@gu=ol+J1 zu4@TlAC6j@XJv&g`6IdVVkz_rO19AfRrS?+>TY$dquN-tHybOVx~;-HM7y$k|0*7h z=IGi_^hWpsj&l$4sasr8#&CF zuCBZ5zogYT?L3ZNR%*I>l-7visfxc<^k&C?bdOZ{XhbxfxaH;j6G(1*NU{kuL771y5>*Pj;GpBL8$y^i|*ygzzv`~B$~itjHJ-=8S1PZrld z#Py7(;@aIS?>}8!pDC`-7T4#C>x*%n-&}lus<^JxXCjSwM?mt5F-EREuYS{+$5{{7 zBVt6&=N)}AD&JgVaW&jA*)j59(2Ehm8a#dSyM5>m%d_pM(dr@#y5SJ^=piE6}_{JQn#d_KkH)t;kgr^W9?;3Q3CHe zlHA8BH;THqQ7+>mxtlWDC&enT-aeg1g#3RlHMI@ZH(dKk_w*r?KSv~KpR91*3cqdU z{z6JziPBrm4_pN|?%!0>g>GpRBN7?0YFaKQQ#_u|IEZnjEZqXqx6NX7&!LXX;cIRD zCO=GEDAo(3wkZOKD`)K`OnXUU-vkBOishVx>#-JmJ-q3HgS6)yn@0^y>z&TG>`Pas zjmN96{~-FNdKEvST1=+Z&qO}TBlR@V&pVYTt(QtMDZPk16;dZWQ=}XF&B#$9Nw%VW z&E4`x9c-P6v{p*ld{SMdA-&S{NU*14gqvclaLbDwtIED4Z(?Q8G$Q?weZ~zm6=^eg zv|63J(M`=r6BQ31pHw24#vIaa-!_}KN|NV}x$rr(%rRcv;~t)b5#erUyjvrdeabn? z8xiEfmmpSw?d^$qD(BMr!M}_a>?g;{Ov+{{jlbl0aFknKX)tOgXWxb%h?vH%Q@6q= zqV*i(NrTV_U+;URQuWCpZH#@NmU|d+V-`<2dd;H}RV1SD7!65289Iq?MSpKYIbGMa zFI*9hRc8IW7V(6AukTj$ma%o^U@=0>)tpi+G0#@8&Y|ykC#0C#ntMAeqa5EkrtfZ^ zo6^|)#xRPE2I-o&tzcT!GqqkhRXFO*Z86`rqbD2-w!OSa8LeJt3kP?KU-ry%@V-&c z7Lk6WV$bNYXuqiE^vHYEcJY_+HE~osd+_bxuAZ!M7QPUsVtw?54PDrnsn$ge*4-+W zvj^{bB8WU}CJQv-IU6*r-eC>Y2}6dok*2+=mS_5MmWY94Etl|X@Vm-;a(+Fo)XZY+ zF3Y8btrx9h>7>FwJmYALG^J7BkRw@JTQ2yEx>`s+<3#FR_uIJ`j6)q&(rbr1A8+3ef-tB>TlE8 z&H~4mPoK**#=P8ZdES=h(1-Sm`unSWWPkObm6CRH1arAm-c%Rq-dxYhwZ_o&q|-qS zo>U|BIivGWg<_08nr2V>9nU0PIiLO1mbb0FA?3M`Nl%gR#E|xEm5?^!k*No!r$hLz z{T|fYxgHc=D5vnObuiYD6lOY=o-{S1964g=@=1CyHtW;iZ~3V3{vu|b`{ylGt;+{z zRi_D`ZAWuNr5cPqaY(k3mfDH8I{Q4L_+1~OBmNV-^*i(T?}K%ER;k2Uan&_FTB5e@cw7&ch#5l1)sk-9-xFGV0j;c~?_|#ozLY)k z5jBf;ms)pg*b*^fR^${Zx3MNc1z|1hxW}eXKH55#&`4kMn)XpQf*UtZv&4Ju{|-MY zb2o;roT2)+=Auq5a027>Tt&<61c&a-s%b>hXn{e{;t#SB*!X?A6}k+4qhncZStW$t zRk1_S{UhqubMWR2UgFye;MRVdpSRL2r0RJ`^*sE(#52ji@5_ANuEFzzsoTk{D>Qym zEyFn7CsOvwl)(C+&KP|He)vHLRG! zh22Prq4d!n(n8Hcr>g8g3f@!Mdtpq};FwB*>70Nny;*Y4j#73jCqp{A?@tM*7jG*( zVIogB^N|CFF00H`I;z1WZPpf2bF!q#vY>ttdRY^4#mI?j&fyam+C$tm{fbNrYftdw z66;pmSGD(a#*?&R%ho%uP0O?v(|n&E^>~;yBTtywH_s_WG&_>s+>6mv%>_3fud}g@ zR%WZV(sWwQd6Zh;LQ-!g_4DCvuSNdEuJ><{SK9TyHvdh|cru@~RnKF!s+3It?tj0J zbtkWDSu1lNywS>9YOZsfgaxv`HQUvvuI-?Ab?PMQrcJYR{!?#tAxcs^#*mg^_vL%- z+P?hH&^C?s<@-#%efeqKp*DxqV(ea6uX|;q%e7XN!m?d&-M|#~gzl?t*BvFwXj-@4 z>iO{UU$D&Ar@;5+eO^12W}H#jyUVz!wHxBkbyKMKru&R**Pzzv@k4pXxn3o<4%DmUe!^`julM_7X@ml*Y1=70a2=YL!Lul~9I zSO4tx-!lJKvkP0smifO{u`ToeE%X2O*0e42|LO=wTju}HQne@5wh?TZ|7$ncGXLK) z|KF2Y+m`vimcY#|P+R8z|NQy?c_r_%KHxG zvC#gU((Kaba$kp9*2$k!h6Q>2*1PLIr$=s-^-l8d++tlO&-#6A`3IMus@pDUKR{#u zb7-WY|GCf9qdF<=;p|c<&v>sF<~?^mw&_NG>9IF!HP6dmeA`}(NVr!)`}M8LPts2H z%hh;~LhLRXMfvYz%_2sQ`(C8r`uko|?zL^iX~#q4F}nPGv4h22((aQR$m@|NqrHEf z5mV2O?T8s(uC*7U-foXuc(W1J#i;=G`ncZilXRwl@?spd=*e1R#gn>oPWCv@j%6(} zT0XT^><+24RihU91#=Tum|X|f$3dEj_2zneKpfYpMe6MV8P0R{DXbBN-^Kfz@4Sd# zyI#xMJ18W-GxGcWj45S7ivPZ*$@uTahIXX+`KtU0Ba|eHZ_0OT z>Ax|MUlVPnIPt0M%>^~@+(7ov&s(6e^smI7_Y|M5OY9cXua>MOD8X2xo$qikB2OPi zdguFwE+nnCJdXDuTGTUy^wR4*t$wefjE;-yGIqUo>IcC3!`Z_is(~owQLdZ)>|zzrvDR^WE`bBlGVmq>3C{H zJs#wG=WJ-wHR#>(TMBQSdOTtTDb`;7D?$I=xxY8Qbhcrf9N^hdJLhfKNUwEmv@vCu z=(B!2S&LKEE59vLyZmbOAxld1vD(sjXm%f3NWDoa*eUl|Fd}K={X(4D1rIqE`Z3C6 zcz!k0XGWP!k%sGQb*4~jmA4z-JKdpzD=Ftb=n8VAI7_QU%QT^Xo|@hCQp{| z>*(q^2Tv63)cLrMsD0a&8^r*7N1jUZ5sI_t8lQ@AHU3~XG&mLEFGcw}msR0oa7VU7 z1C2*2s@1+~PxZ#u0^Y4RwtRmt{zcre+H<~o)EYWbtrFJLAZFz46Zp!lKQAGJP=4*Se?e@OXTQN?Y5zggp-_ie9pHEM+ zY-Pl>F{AM8@m~4N!pLCB^Gg{Pdk2&l+Gx@p-|5Z2NMR~>!g^zzyor=vKQhk&n9QBs z@;vlc`dpO;eBNIDx=aN7hNt`>*Bs@OnFfvK>x;7#G&}%jB1GYsUM+SyxYdG2&E9+ptWl z{^!-=Kw{SI-!A>(Mg7v9IHNmqww^|+wbYh$FW!t6=!cYargsJKUo(2vg=l7aUk#?+ z!`pXrTiY;rwWndLpT$0puJHaQC~7fUyU_wqg2MKvM9tYQv|MK%wfZN!&%QssW?asl z^H!Zt4cf;O-KEaVJ!6%R%q|_vv#+UBi)b;U0_@M&ZALSx-(qoAtsaWfclEx}-8%52ir2k+G~z^%R(Oc9 z+x2yqcR7-cT^#!iT63Cko!^nQ0?j0z5C2TLlKU^DyR_q=J7u0lIi@pCT7Vvq`rXYKJRDJQugAhq?L97 zIct-fy1zD7Q;vjw-N9-(^s#rh#Z*e#0(XiW)q7)aY?RuaB9_qIweBgfg-pxm-19Vx zYn;ODDFIX9c>0XGSHqoRM($ieiQ}Ga+DcA(X&%S3vw)tw+i~CBB@6JGi#frfya(OW zA^(fmzn+L`UU4R-XN^o}|E;z0+Z5HeGJ5Xe&=Yu@&77S=kk>C%Rlkd1rsdey(La zX{qNh^F5#6W9N&2-oqutrL3^r*bEDP4&xVyS?goQIdy@bhp;Fv`t%1U-f)|gO1$C9TDU0 zOGjTT$%H;@uphoF$)J&sSuk+nOW zx7;)99+rrX8Z@4EMD^ap_Z)A*W!wurotB?Q?H#|4fl1VRCg0;sbh)8)Y5Vxeu@G96 zp4(F>lTq+1rz}KVV)ruHFUxY;_jIC&DnE%-jv#f8cp<0b$#XhySK<-dSLRkd&gbOX zRP4)#wos&xKqtFs-Jduk`%7& zv}I$AnQF@0Jq(Wdb9lnBy!oz=I5#S|qxG9k?TuAX>6giTR>B0Q4%)Te=B8#E^bv7n z9rcd4!}--REz4Wh9n?mHHPU+MsX-A&e3ru8PoUqu8g%RyHSIV&w`FqZhJHair<&U1SG>$)O+lLXX z=Ynl$uf`5CV?G$Y*HR|CWM!XI?CvyIxywA@9&PiGYUI{_3+|F4Gq|VEGFGT+7UkT$ zXXDg&+due2$irAyb7mm-liS)}DYCXb65P#5@wS)g+7hutNDV;RaWCi0yq0qJRAM>L zQs|%?X~tfOu+hjzA|=ySw)y@9o`Tcc3u(`V+}s!tp;g#}&MIOANTt@ZnXB`vAvq;GZX6?RdHV;2yE886s-kDu zzqV_nm-xvtD5N$2O)Vg}pE`A%ynsO(;t!dBMhEk2a zGoA02_aCsLp0$hM+DI+^!Gl#!jM$ z@1Z;~e)c?)2O= z7S*;E{O+^%qq!Nm-d`La)AM{{oX3ezYAT5rxVs{FhdN!y z8FhuHtLyZj4aU$HW2ohrTnZjX`o^7?wj3qX^Bi4?N|Y6Qh|R5{IY|xf3Jv}$Kb0$} zdv)71*N(F?eCu#%#gQLUKz?6|36u6o$rX(?A%8OsV+YJ+oOhgGxa(hOv6Q}-Yle)f z$kP}>K@V#3p=rBk%6<$QckIevq<^EQ#JpK95WCvkVd@^dN*lLQi=fgLo|!`lOwGF4 zQW51PabjCWneAO?D{@Tji!m399+lGur?VzK@>+Vw-yI*-chzfb1@8yVXl;={wepL- zmUhHD$M>5%U)|N^oaR*OT#2nJi!yRLXw0;^Hd*GZQ`BDluaJyc_Vu0Dp{JHOsyp=3>^~xcSPFAG9e&nPR;amo z0#?LVh&V?{)`fK_xRTnSGFzD?U$tG7uMr<0aW2~+&c#Wirj2LJ!?6y_OL*D4i{~Rn9-9G4lZWBR0Jl)lelq^3ICx6bdh)jH$ucsKToRzIUG zbnL|LEc-09GIt=Q_&&jP7IDY^HNK2vTpb|s5@!Vq8No@{w52Vj))Swuq#xrgN;i>` zMnB2D;v}N#SOZ3lP%19QQn@crBwMiihNbVm1s{zur#2P5P!A1d#5_vmEPo>Jo{McE zbTVg66QM2nP}qbVkG`Eo-4T4YoH2WKG%MFFX@4{fYZK#KEi&B+YU+noS-nes6c)ne z2`@q)wku=wt{tZCaol^Ryt);`iNB3O^k-sO1dG3yO3WWt%1qsy~{aBU1@wZ?tm%v|J{eizi6M7#NU`gs=v5Ht%zdq$2N+A+;!- zn#N$t)xPYZsau1^l*`fY4A8R=r|^Gpr=$7BS+}K-ZM(T#)N775dlqu3g77$SM**I+)8lj(IJKhvl4Q2G8!DuL?R(i$0H;oZ6Ri%yv+U z+mp71Jk36G?q*tAe!@=f%rES#!DEBwj-w9pqQ$JVwDNv?%S-f(Qd1t3;%v6JxNS{4 zNok?^hL#$f)^Y2e`;bu5Yqa27^43uYadb=3-V2Jg-L!tDd61N!#z;i8ih3*StLgpR zTqAV68#&dpy5urJD`__2FUxorYAHM-=h?G(MtivuVit3|S^S$$dni$k zfeM@RQ8$ZO&@A$db}-V?Oj5Fatb^?nt(K&>9MiKRvo^wmVG8IZ=0BAFY4KzBM!;iMA<86wY6e4svL6U zSWBtJc5#(jj?q~k??G;fvb#}R$BML=>$(+_SOlC-*4t96mEek{p(glAmF zEHEfEEUaxs&1`|{9ty8~$9Rl#?WNXoF(b}1SM5b>TZyk+vDpMa4~`kFFpx4QYkg2- zNObvTWt~G^V-me>{nPwM$xxk=)Sh^fJ>`655hXVt`%dmJO{$yuo@da`Bt1E!d_}uR zMK_*G4V0n5TaDRRZJ(}g)tFC)rX`;Z-e8NEi;-%a3rdyBLdT5l7NxQjY8_r3^>N=` zP*U}!*7l~6bb@b$4s$O0NM*f6x)@5$O+U$u#N(Y+1`UQ}aHc$$@`NmwmP3Ct6 z`s}=r%jy)CS*q0*B_;cYrPV5|Rmr{>44rDXh}Gibxw_gF_ET4F)R?DH+BV8B7hDb( zi*scM@S9qU^^EqD=g8-b&tuC}pA|0GQ4T97L-$VeK<9c=Y&ZQZ~G@d@Uu#2ew zRAT(e&Frfcd0PeN2^*)JEO=_zQ{mE6bS=2kMEA~oAGik-Puy@+um!sKB!G%MfSr+-B z?GkMmw%hbXUc zQwMM+jO8>3?`gr2O69jPdoYgIL-caRAAcQI1^19$O|JDl=Z*X|h$kOus=U+sD*WVM zX1>=wZ^0Dd>;Y0U%2#-@uSJ^7qjdE>*^T%lcd$+|=il5*u7tHc_8Z+=(;MAgEsZ^9 zXXoh*FW<;@UuLXpnM<$bvu$w{b+5g5Eq2Y+@|M+y+c;tIeg zx(_be#_33}*30`D+IVv>@4gwn+vR$3zb9#}xJ>t9jEuQ7Gd#}9b9+h9^*ZXq6cKz~SWWS1jf<4#`np(si zV}sd0^*qW12O)MeB})Su(d$LV^qHqZYcGy4Rwd zOAW~9)sA(`l%lXVP9?oqkCh)Q`8(U$JF?t}+dK##bXV_#Q25?l;j`%cDZkU&s}dq1UH07Z@Gyt#V&C2z`~llGpd`<%OZqpXjUzcShp+1>+s zHP1Ba*Ai#Tt*YBDX@6zo-MkNyo4cbtd$HE(iat|cu005M{SNfi1W&y%zpg_MZnW1i zcJtoN^Xhf6i}&GzPt=yg#s;Wgp2mAg(=OfzDX+VDrBrwEdX=a5so6g%_uAB-cBV!i zcV&ahaSoliq+PsslGmT{V&4avslSWY5po}zc;{oJ9#vk?n~kU~c8k^P+j@I&;_XwY zL-NRP-14!*W)y8<%cr*LO$uYt0a9Dl(}HY~@ikkd-Y#Cpb83-#eeBNZ`V`iPvM()} zLdWyd;@7U%vi2_Cv~xGfHh1o>LynGzlkSU*a-Z(Qd`}dX_Tr`zRCM+G(beng=yTYq zKM4J40kT+a`jMvk+VmXi-bkBvf9LI_IIgBH{cM9C2;CX&ppL$58ufJ0wqiu8Iear8 z^{;04<4;Jtqh4H3ANKkB`ta?=UdQjye=}*HuI^>Ly{M;}qc-ta*-G<2b>J(}azl4+ zygTuhY~+YL8|+T}WRYX%Tq!vD+PZxce6&`3)Z;oc^1Nd={v}9Ici|3}@=LXL^~IUR zY3FOq1^!4IE3qSb^?2wzMX!F6PfEmjoMzh$mzq^FR@IZ}JjSYaJ`r&rx)yQTxyebq zXI{pJ_S&`B(C)Tx6dT%Sv=`OVCQ>|t+R{pyy%(IfRtnK}^(2HT7$v3NNc?F*FP-Z= z_1<)sdF^rI4ELF=t5KEJn2oCZJafv%QI&`BbbTqH_0BnATC-G((N?FS3k7(dU|1HcSBeyoCT&7 z!+xaoKCNxXi3qM&$G!tSgQq}|;R$>Mzw5E0pUR26)$xph{`?;EKz04(NgijRXzy#L zoMD4=2I~rf^UgA@9F{6AUha-wN~^f45hpUn`cv5Ow1{aftE}!Pf5o&i7t!)6vtD_Q zb7O7qt_SK@;JicocUX*<@!6HU@HnXa=8QCEHCo$}y;c8)I2*@xotU3%tBjsXD|fc1 zyM4SLHlkRUu2IffF4lIn8QA8wQq0Kb*PT8561sOLsvYfq=(6)s zdq(lh?xb8R4wRO)w%o4sK60$hg(B*LySa^1Un|GKE0#eVDt{E^V6M+CD3DyqL$Ysnb0?t^@gOtQR|a(g{=k-pmtv zE5&-896$?{qb5dKP(x_5j<#xxmn%iF*5jDy1)aIRpjFKEs|B?3;qYU9AUw@9(stD9 z<>NS$yX~3tl*n@+t<-VF-`RXv^3224_{vJS>(8!+yW%4M=$4n=m55lis+2dp3&N7O z2tF1Z-}Rx%ylWkL6mrLQ(w{ASVay0g!4{KcXiLFt& z>$;04KURK;^%{FGyz^|c#J%R_Z6*Kp%$;cAo!X6s&Q4>h|J%-ts(<|7)y%M4DQ8%y zy3;DjI@OInR{k!9;^gMB;?U@OgkD~;{wozJb<;Xf zNEE$yL+VROL4&b&l=i;ZhpFEjbt~XJa&oE1Hn&YS{im^mC}Ieh_e_8 zdV{FhEQR;m3a(SB+qhaP1uCIK6LQRl@BAPrFV@Ih?Fvi#BvQ~fNeL$HnPS+<)wp8a zFtu`8kDSEs@&1s_Calr#t;0a(NE)6f60b)b+TE z-Vyp;E8|j0tX5`Ad8VH4`h03#xq$7bPldFWto`Wi$C74d2pdL%HCXu@v*Tr=Gl+Hmfe7>*soNc5L5Br8}igz2T0J zDLmaue#s-i-7eL>+Tk@~Tk6qUc`Bqu_^asiAP8Kz|p{@#AqrsGq}j%Y5@;8sOz*hao%DT3pN*ZC5j zS&>U9b#OHZ^R+x`-1cjXk62@#nDa4ZYiOdb(40f53v&k>8{hipG61zEU)z}SiZr*kw5qj~iy>EV}@X1~`s>xbL=g~Pmw(^$!tz2C~ zO=E1ysj6kF^zGYHXtm6ACvL4cpz3K&y!9e^K181!%bVd1QG4Cz1@yxD^YItyldYhV zX{5aQ3d1*Y%~Cyjhw_=^JBV7i!s=DahSvebb(`X9WEp?op}6i;Tz4t1ql)W}#Z})_ zpC40PM-T~C7XvJ!r?njG!+FK8jo*BMsa*@Hgv@@^pq>-njo#oySiL57WB}RfgM?R%5Wrat~ zqX&~0Z&(PzKg?35F&-8TXAyeAx}#d%!Txg3z2*1WIA`{VJQv?~Z);mVKDR4}?Mo}! zqfqlw&Ub7SudOww{S>cFt4PuiJFa2w%9HL)avWL%%MxB!3!u3n+1HTF2ePW#pXcV+ zNoVW2cjN8a{2|WD+lR5-xovmkh?uF%uWqGO$576SP82@JYC`AHw$2osjsH1&BQ&Vh zZg<8`y$FxPc)pP(-*mQuFSH;jrT4_~ledubH#J1%m_FX4Y11K4m2yjIuB<(fa+Hbe zD$OV@<-ye@2FAw|qn`Qx6iBu~xP@utL9W?AmE zgD2^mVaswSxif{+$i-)ZB7G<2lE$_=sJcNndMWleId6!$T1bPS;@J0^B9`chne6qp zTI~J~d9UONJCi)a-L{iJ%CCvfWm+aig=0sZ*_ow!ZOrQ2{Z*~`B@I+-mvNIUm-AC| zmcs;JioGeeSnSVnWUIH>SB}M~XXIo1pO|ID*UYGWM*TBV%qT~ey$uW+F?i#LR}LEH z|9pk&GE&O2-+^br&{CES1IL5K;K-&dn-3lZ>%geyEISxn18x960QUfzIqL>?2D^e| z!HM8xFb{kjtOjeqUEmq89_-pZ%XSCngA2e{!0q5(a3A`-tGxCz_~9tXYq zWZBl>P;eMH8O#IMfE&Qm;5o4KR^$N=00)Cr;A(IaxD`AMeh2#X&9Wh2H?SW#0=xlS z0Nx4S1y+Gu!FRxp{jzK%SPm`*-vd7bleW&X$zU#62(AZT0^bJrfM0_b!EODs?7QGM z;7L##kY$6xc3>B9G?)oa1q;DS@NTdgdK1d>MQdJPDo#ZyEwEgMR}b1fK;r zf;+%k&@?p5dVmAK!QeP>5?Bh(0V}{ez$M^=;5zU{Fm@Zt08R&sz&pWvz~{gh!L8s< z@CpzjWhVK5Dx02YF?z@^|a@Kf+x@Emvn^xQGawgMx- zDDX4zFxYx0=m5MK%mJ5!tHC<(M=-8T{@~-_KfvwaPVf|X7K|Q28-j)4Ebtz13Ahs6 z2<`&+fW1d%+5X`D;Dg{(;9Bs)&RO;sFlm=8I~=?NTnOF=J_2q6w}9Kh9bi3p0UR=l zaR^QX^T0>JC&3TFkHBBSMlgIdbp~Gmw}S0=&9X8$1-u1Z3N8cR20sD)c7soVbHQ7| z-QYfO{%fF3a22=?JOI{%b+08aaOv)(18xSlfF1XMpMg()>v14|oY|1QYgz zmw`vYZ@_>tlo8AZ3&7jKJHe;HHDCjH1@s=vvtS@7gOT7hU=o-H7K0VweDGfIA+Q=; z2W|zw0qeo*$MFtm1IL2XzzXm#@IG(}_$c@>_$hc2JPii#MIFHua5Oj@oC9tIw}PL6 zM?k;5;SXRDI2ZgoxCGn*ehMB0zXZPr&x7WDplxs&SPlLF{tWirm$HI`!C~NIU^Vy> z_%2uj)`GG7L9bv1co+D0a2dE9d=gv(z5wn6kAUy*503)f4#=`zU>rCYOajxv8^Cd3 zHaG*E3C;$e2VVx?0&Bs*1G8)gZ~}M}xB$EpJO-Wsy$@onf$c#V90N`O6JAf-gR8)` z;BN3Rcm})(UIyI{h8KWs!1>?;@HOx)@Cw-a5O@I?0Y-z}!PgI^O+c^lv?mw=MuRpm z6PO|978fx~2dBnf>20^Y2u!2+U}L?}6)kBdfq|TcMwTC&BN5 zx~mupwgLNt1HfXi6np?&3a$ayg5UH*W`Les^DI~eJ_zn;L6-n)hM>=an}#Ak!G7pj z`-9!l8^pB*)EhnwJ_ghut}HMR`7DkEM}g^J26#h(bzJ)+t7m{WfQiU!@jB$~Snz=Y z%3d)PYy(~frPsk*!C>%9@F-B$ifaq}nCt!EHss>>!2Zag1Hc{NTVMe4;Y4r+{Qg=n z6Q2HAa6P>HHt<*Y@GD^V3BiwNay=fL1m+ibH`i6*L*PnqRRMW-bJp$ubM&MJO`Fh@ z&%)m}ZXBFJZFOej$8*ow_#AADF&93WdA`0D%Q$~P`W7I*Td zdt)eps~TJCvZY_P(Abvo($T88g^z9F$;*)+Tja|;)+$0)cF#&kfB!c2@A%I>zwy`c z&c^;F^r71Ky4AeLT)WP_C`&3)@gSGx0qB<(UH(c77_x>kU;avuvv$jiH>Rk-f5%JF z9JO*9-qdo@Z(q)fH@wN>`C#!%YOGCFiW*JbxapOt8-2y+tWo4qYEF%n-iz19zT9%r z*vM(@%f9AgzNRnArdMOik=`uYaP~`^UY-4tuliJa)#d8S>%BL<>W9dA!-kfNzW>*} zjvF@kx(`*qJ_en#DhcK?mA^=0w-+}hvD=F#;WHhR7(=15b1LWqwPuwjHwIteuy)iUtr~Ouv71V=sR+e~D9L6N*)`L^>h7E7_p7^G zfv%edmh{^6>XKf*`sz#r*Y@2sufMjhufKZJzQC2?MVllc2g12+%aG@rkDkjeC` z(~0frq0$%83oD0iN^0d$lj>h5smA1W+ptaKb=xqL>k4_XmJrpiSyeJK!<{emijgf$6(B_`848aiRZu^Z8AjRj#G3 z#3nEBC zoK4&%Yg@CjVY&Z{AF#+9H+ChH(muGYHT4;b(^_fB4A$9Kl~!(Z^Sw>m-n?z|u(8?p z{50a`UOh*GomZ{yz6%(2Ge*jC(ev7%P6La;;n0{q3XOaW^ikEv;P&ma?3>_M;Mbt% zaD1b{M<9;NK_Z^>N4B>s&D|MaL9iJ72K*LuW^1ZvXZjuXrC!*QI=! z(-*+k!MDI#psnemag-4xo73*l%YNYN_{(jFZ(JKV3VaHz108KrbMSNf26zIj1KOyD zfeD}uXs?PP9{X2)n^J}>J{K|=bUy{9(tKUDiD&z0$ z?Cz=Y{ek@ZlI(%v`w7!B*wNY9Y_82*m*n4vR56{1M$|3(B{Bd{q^d4YOFb2F1j0NMsUSMyq54ZrlO!*To z#Sdm;~Cu;ot}`8B763f}_Axa5R_(rh^&a4PYji1&#s7 zg5!Yu9Zmozf|I}-!JELF!M}i$!E7)G%mwqne6RqV0!{^|fz!bmU?DgYECP$cSzrk` z8!QFOz;bX7cndfeoCj8b^TAue+rZnwE7bWNTt5P=|9gw8pF95jAMX7d_;+wIcprE_ zxCE>M9{`tv4}uSY4};6VXTe8-=`}&19n*ca->)aF8^Dd=bKoX$Gx$9C0{9~M2Ixw< zxAWXL!5!dR;7;&u@E!17um*e&d>`Be?gneY55Nz>J>W;+UhrdZAGjYp0Db~~3VsHD z4ju##frr5(;1}SR;8E}x_!amy_zn0icpN+deg~cezXwl&KY*vfGhiKf7CZ-@2kXHf z!3*F|;6?CfumSu9yafIV{svwKuYiq!xkFY0O`sWc1KmLn&=d3my+I$a73d540qLhd z*8#<6zYpT`U@!y>1>1ma!FB*8C)=LuaIgc|5$puYU<4Qmb_TnEQD8LK6|{h^^yijm z{{9vih%$@v$-b@rkV7*))ts@^HQ{+iEmx+K)9^Nn7%XQ7$A~YFaHFwL$&apCa|Lprx)?=5_gwf0&CmvbO4&!OxIIPn*_Ttw8+~tiyS3Q>v zzUts?!syc0*}lCl+^^S#(~s<)y#XAYHJ43;Ww1_iMVTQD;=fg=fpVYT=Juw)gR|BN z>o;DJr!*8_J(xm6{vRg|8F$`Yq}6{!gP;}GGfTES#wLgpf83{e zUjA$kT2~D{+F*}tC!TLA?ZNXsHno~N?etI_ko8;BD{Fdez#StToW>91>4C-5=5N&0 z^mI#yr$=Y6negdsL}@f{MznWhV3g@aV{6PU-gCBp=tgJ^wcKeVUY+r! z{gHa0jw`J?+yKlrTc@@}I^#^P$D| z5u?lGS-+1h|KRddb=&0+q+yJ*#u1~T5q5Fcj~MMU^{7rtdl>C7Vn<$>_uT!&scIBg zcU)e|)jaPmci*0v_q+Xn6)jVrJ3X1dU9Vh?;}@sM(dU)!!*~@V$H>uAaQ(>9Dfil= zAw@%uJVuwF&r;;*^GYdl^bO?oNRx4Wzs`uM7dg`rGrauwM2^0NHycr1L>RBvmi1z| zrugKqCUW%SdGC#)rEU4tRuMV6(pHUH=;C z@+XXTkSM+>do#Nbj3+UWUlVPnnA553%>^~@+(7ov&r8!-`d4CDdm>2JCALv8swHa) zo@(4ecX2F1UkG`BEbZi}lt%aH1HDyZH5j`h#a6zM`)zql;6b#g=aCq}rSr7q*qaJ1y3%R6PqR~{`ccMlUafs5XIZq-7=ApILkMnJ0-bT?u zwyz(m`8xRP@2gRUS)igS5Nv`iB%e-33o2prG1nLJryUeMK;=}#2x)cLrM2w>Zl8^sfP zN1jTGClu#cHIA@;b@oDb101tnKmMgCU+1!_IghD(N47%)jYle~)xK&^^~M&>xn&Lc zfAJdf0%)fmZ&dA3{xvXCDBr@9g=_8@%h#R#G zxzgF0NuCt&MdWp@*myIUwchdxvzYUn3GEHutP*VxpVX9wubjboGBwbE}~S` z+R0Y%$uaykm%Ow*Y40&Iq^Bab!ZF*B&Yol4E0@ye@?>Z|MqD@AvvVwU1T9|aj_>s5 zU!*XVI}ve9Th2sE@9D$Fl%LF<-SRv<-_*P&Wv_vr`hr1}#kSM>^rmbA|BnR5PxoJ$ zyI8iUZTuTapK0fCPpof@L*jaW94YnV>i?$cj@pQ3Z>l5fr04zD^8C?xX^-Il!?7nB zW7PM{I(=!_aAJys?HnTB#j{iBeIFR^f`?pJfcu~J}Cr%TNoUNx(Pc5}2 z-HSJ)1^S^SIn%!a_^%l~`$9BxPqG+HyGPXe=q+qBP*>OrhasyySy}zu9fL+TZhwZo zR^E=0Wt(_rakfn!iSHyRY=27Bob5u(wLk4OBKXeWSL40*r`L?}xO3jBo7*yWsWXO> zh2loW+BjsVW2Kok=-etYATNg&I%(LPI>s*_-9UEUNj?#Q-6)j98_Ze;*j52 zM>&?KKu1JWIi}R*8*-{%`P=5Oj9iU8Y;4>}&wcOCQ;aQnCM{(zdLFLhPYb+h$xV%8 z=RMn~jZ~)P<(NVZCsV?yl(Yrz6giq+oGcNgo=d$gq4B$q=bA=?&&?o(SzM>^kJAMB zHU*And`da2Q3{O&yMhwOJ=?UEoU~IP$FsA5_UY}oZ#=&R%sOIDxG3*I$C&&tcK3U_ zqIt#nik@3BJv$+>)dh-7If3a=rN(0U(|%!`o~D z$H1aIl@@aFUL|H?oa1gOVnnbreWj)@298- zQAVQ-M$eu~YaT`^JnvdQc1$iew&`+fMO%52hOKy7UdCg%+CTC&Eu_jjOWcoqJfc>*ufe`HT6}P5Pm?j4w)8a->QG7^ zOAkruO01x^Sp^+=Vt7O!w=W%it&}sU!+4hVO^lm0=UvDAIpo%vl$rlpXh!C}%-uYQRy7WWO?&yyZ|fS++S)j`gXI&>HJ?F^0_FGjog( zZr@q{=qXF%__MZs;7M^}ki2>^ZSHwH#v)FuqiIeN5zam5KpR%%Do>mTluza%)yS>= z7WED3Q{gccs+t8gY~HhRg19ve{t)soqWd~CsE%8oqBKk6!QG5HZhM*T82hMAo^kBVLP=#S z2i=EtwbHvm8}@(n@#ZbjendEX3QjMrNQ;(6sbc?xR$&jSkB6Qoby&}4uFk85&pbv zF+)%n32xVibYr!>75yUQiLsd9k#pkEDeT))+ z40Ba~v-h+W*_vt`YOQKK>b_E6q}H03Cr+HQ{VJm*1HqX*4JOK`K5nh-T~AtwQ600m({oL(dY*7po^xpG)}Rk^!X8TFR9R==*!zxO z=N2)ebR4?kQGGVbOrEeW&B6YbPo!1Fvw71|vy8s;%_V&AXpwkzPs@8Ovwd%`*vk{4 z7X8sIg*jQ{M7foS{A!DiDeLC>C_WvsF04brmDC26*~%_$_D#Fs?{>Ogy(~9wTxOCPaN>sL7PftNo*&_ZIo^@ z&-kQwr0;X`wvRgdjPpCCvga;zyc>0>enwen8DjN0=uL|A1Tkmuwq9_ZMU>f+c=DHh zV86!rw*E><=T^3n8u_xklv+=Gx{`iH3bjyHIhXyUB#KjQoco9FZVmh7QgJbs%6)kv z$tO>IlD_*g`lO&3bMoJo{McEbTVg66X{L)P_kYtk32celJ!OBb@qmhyA54LPzLFG^NVY+ZnEVjkMU%+0y3 zGwNfDU)AIMu4TbdV4vAui*kAi9aYIB{kFGIb+2k$&tFZtU7}L;ZMn6rU>&7H?bXh_ zkE52exEDILed7$x(yA@kTj`_@^^ll7M(G@5Qb4M|xk)R@s+CSGR5C`Y>L$yW&9{=S zlsS|Cr5VpA+INMReE{XwpQZW*QStkFKN)=Fa@%-f zR{lxrhUfpuJ(lFT&8HW%!p-FwC9eGz=Zn~ewvKgt3+XP%b(aeLcOxC`I-X}$kpR+x zHao|>mc+wy&N72%_s(th&eNjLVWKSBn;WOWrzi zLr1q1EiDJd+HP7u(>zGZPh;eCS}4_9Szk@>=jPJE@h->r+$XtA&`O&7`O7liirScy z)S#SOko}4>D{(@`NG-OR=QdS1YiDIj&Yn>!1dw_EMRD=tVpq z8u1x*Rw=SAzaLWBF%r*vo~ktuul%q8RxCE!A{_ZKGjRlmG`F9Zkgls5Qf{)Cgq~-8 z)v~q6EupNlXfe5~ryNT6GbqbMKF@@|9-ZH}H7$X44gQ(NwAxTmV%iN5b3%Eb>DwA| zNG*j&Uki5h>Qdyo?_tQ=3|?Wm6&BX<5Qx=Y&mEv$p`z`Ij7P*Sqx|J z&H9`LhwV7$8Ire&vRBS(Ye~DdM`#|g<0eM7tJHGO&iZ%{-bs|*joLa^q{U=M&^qfF z56Y6CX`ywUKcr9Md)2*Kt&4>9!6?|;Kh1wSrX;l| zo@7rsUs(kGn2&uY_m?K+OP0X%OlOjZoKYQJyGTVho=V>G?BK1-xl?VQu5Q(sPll!? zpRHJ6&BZg7oeN5p%0kDC?G~l76lxt_t!Lb~7nD?eskOc7E~wxep~IYuK2lk4kuHW( zbJI^UBkXZ%1Tklj#_Sbm%5y1Cj1_x6G|41S)e)-CVGFsePGOntFKq|*if>q2t-@NB z?A5{0X=VNHc(|XdU12|U)kckZ8l`BX{BptNP;i`4I)LBQVytJhpFBrC=PoN-ruy7z zxsFm=+6dh{%>$k5Md_qS&%(83L))3g=X0rj`X%^TNN!g@)kht#axiD9Qc%cAX*%9p z4z+ir*O>cOWJ!yR*zWU2~9yOlUk;lL5$Ae zpo{oTon5IdeOX4&X_i79p;DT)Qu_;QZnB+jOJ1k(W=PO9+GAzOmXagK$Vlsxo?pBd ztvDzjBP%Gct?TGAznQ$F43<|NNxEZl>ag`p#oqI&utqy$S3k85aY|x^zj->c?d6#F ze8reA??`>DNmn?jbZEZLRh0j7tQb|%_sX9Y^oQ-{`sM}szrMNtCFggJv?r?^(x5d| zBAuS|Mpyl3QSY#>IF3S^Nh>~S@3g-!M^jFQP8{;gvd9l@muSPV{U+Ls(JKv@cd{HM z`?gwo^o#bK$+VU}8HX`u5=U1`JHF)sa&&F&m03qBp(}uLo~_VHqP=~~yd7ilPO52) z!(@e(7Ns4Z3ad)UGwDoC!xZKHw!N((H?s{KwT>QTf@4#S%rxwAdqhe~XJI;r3f)V7 zlQe~}{5WoUdhX84&Kv(BbCZ; zWA@O@p2~;l<;s4HbyyYL>3KD|*55g?rs*2SO88BucUtkaYR$_e7p=eh@@3|G)w>-^ z*#o5ZH&!O+Q=SEs%$*DmQIC4(oUUnVypzFQ#j)S))|$H!+||_BV|I3)&hYY$T-`me zmbvs=KHC;Y)%6LFT~oEZW%c2&_FMJ58FZj^aMd7tbqzUyV{Daw5)@r${CzdL-_Lt9eQE%a$Kr`NjM zC%(Ji=2{rrHum?MsQ;WD$lt4|{^IZF8KgoVeDb6cB zmhUp?p6|+xeFn|>4%V2LJ35m_5`0=&qdcwF1mz*Ib~B$brT>>aKrY?NI6sC@o%86* z+|s$cRPUNf$g1ER%0YDvEy?OVN|niZiL`_S7uH8DbT@UcMLCxmP&^eHyK`noua>Hq zuPjCvnn)R)YskCX@{uRciJ7Ex4(G2^_VtgUjQ|&;A{cjA_m;VGm>U_x0rDj+Jlb{XDE}Zx1eaqYU@u zG%aamwjZp5x02|KIpFQ2chu2xx#1B`BQ$Uwac%vtNTTGwpyyPTB@_( z?B}x>FP3jSBlBtKz}^k*T=}70Fl5yVC?slP{`L3&n4%WO&T?}++q#W+bKjj)L|1lm zKVR(Tei}Mxyqo)eO1FUej?b<|N==1+)SDeWQnTwnvEp=7{+zV;MBV4y%^hWZocxv1 zYD4XJbFb!^M*UjKew?kU+b(H;ZR6eC50YD>-P}G?U#>j}cl{3Z)dY=Pm|xeS2RGX5 z8oRmg=6UtH=6v)%Op8=&Vw?M`U(&FJy1tA1LCWhcZYkAW++OABeQNek%Dp!Ar=7{M zi~Fu@P&w`5elXu5D^=e~UVp}meIID1{w{7u$bD$yosW@vRCzsbHlnuJEm*H_>+Qjb zw@;xC$s@mU%f}9zQM9xzpW3Q--lvtes<&sz78zf&Me6P1c08vRsn^HuoUc#ujVSxl zk|}iD#T~zPy_U6iai^WzNw&FjdmVB#_H4h%I2@ln%=biLX)ksvK}A=;A6>n^jy|XK zFkDS-`jT9mex#|sHa&;BJJ)uG5G!b#k74)s-cE|+YUb7KJ4@L_2Ju#y{_M(|7OxYUERxidr?m{N9~)jvX$n4>cCf` z<%aIucz5b8*~k%hHrSo|$s)(jxl(ZQwRQU@_-L*6sK<3?boa@Bkg>SxxgQ3V%_I^@+p7?!xaD5V;XFIOWCnE00 z?z}gsjux~v>6zzivy*twye=uOtMI(*Xcdb&g_c!)z4zo@qb(fC+@+<4rf^*GjP{~h z+C+*+QCnImv-e{5RV#&PyLuAB6pWHnZzTSdveu^ldT$zKp!S>2aG%LWz{A47`4rkt zT_QBAj%y8S%%f@h=b2NED6CGk_3L3gU0(`l+jZ8I)-26gTb*fci}lV`7;TAr0`0om z=e46~71QdX9Z-w0KGm)~w&ioo#kqw?-8!t4`gOW0q^+%gZe`VK7go;DLn|qU{YdM5 zTHBtJm(ca<*mt03@DwOAJb{nkcjrj@shr4L9piBI=l7TgTAt)duCIo6cIOsewZS=q zbp^qBXRJG=-D>WRUrMXEs^QvQT7L=~o)$5!WtG+a(5 z`W5(;_V2J5YbSOkFFXz^zd0j~S&i1VWN+2K!SxLLLEju(Q(I;9R9d;SJ>Bi&{g7(f z^{w+_XwWtcKZt3J*r=&3V=meU?CtO`ao3VL#Y#f*{@#_AcNT4Hc(45$YVtQrYlrS- zFkj1Ep%ZzB>r>kIw7P4bi?v-_&ow_=DQ4vJ>&_m23Ej)Pw4>c$lmDDiJhM9~*P1bE zS!>JfI`1RL+FU52Zn&GfE&FuM90!wQ54g?n@`juy^wn^cZ2P>tUxpg5CT0Y_o;XwO zdrB>7@Z`f zj@-0&CoSiSu^b?cUG2+rpgBjR^sNuCBUd|mti8|8M~Bqu9-j7VEsh@7H{`3@xSDxF zZ>3m|^LH&!F(-GF1vP{=>u7VOB3Zm#DT=io$3!pa%=HDWVy<5;pp_4YAL|1#Ft3AY zJ8Jdvah#d@o;gp6JO|QB9asF#Ei8HFp>3eD67Kr*Bz~25%Rjp1W!DcqR;?=K4ex@m zH3LnmbllvyshNF-Ew~Eot@f^h1etXYX0AuQT31iyP6qxh2M0i z)X6&4Ete(sPx1$GU8OCrRrL5wS|H?-v{czQ6!uHk@z11almE+E|T|UVXxQm9;?qdSm}-+Hs)$*Tiryv4 z)ur%$TfucISFc(K}p$W+!!gqcUloxAc_DX2QlSsjpFeR82W{P1a56)oAr&dnu zk(0<<-r&8EvM2G`nr)q1u%lcdox^h>#&r)?HT@Lnbf^DAF3*9Uq=vCu>$HCSAW<%N`t-@)%sDigzE-rCuASW@7O5QQ}(hR*RBb4Jx7BCO@e#s4L%Xr zPVTN%Cu%1Dqme55Y$z8TGxoBL==!_L=eURm~ z;U{1nZBzYalo_TKGHecGvN|`%r<6UPwutrRt%}x&bt20j6yF1yu#8K%uE-^nI=C8y z`C1-5z3kT*AF;+fG3R5-*3d*<^FN1D$uXAkZ1@^1qEyv=AT6~|y?T#JY6o+29o*G- zxn(7n-~x^`y;iDQtsA2>y!VFW^cDV5mOT9~_q65o;s~D^`BeLPLwG!gM^54f%Gu-> z*#1uJP0>;xloz`J&du8{BtkFVwfD_0=8qBmYb~Sm=$sx~DWUzXTwOvEnH#ss%68gQL?>mQ(TQKrTaWm*P6Axb9e7^-cBpF~xO6 zaXqZKPAsl+4WFA_T#XIm_o>BoR&gCxT;Et+jhy0h|H9}$0G;2@#-H(ea&dJ<*zekh zysGhgT~u84Yw^2$)~ouZ*X6}^PH{cAxSm&B4=l%XGl^d7^KUP%u3T3rNs3X%shdg7 zgW!O24|$Kgd?6B2ITQ0%Ie~QV{s-lzpOsKb?a&vNAwzvCyo%H8FXb{N*ASD=;Lg|3 ziq$yXj~4l~w;m)tGkn$LB7<{jXDZ=Iub$vKgH|QDx!9k$-R2?b`gI8Oz#B%ti<1J+rxOcjSnesoNg6QmSJpT}3AfpJO$l^JrUV3eLv=OhkXj zp%F0;sOuLqjOQC!@=a$e_(BVPA-yM#pS*>fzo{WA$Mo?YO`8sZs+3zwb7k#;l%t%D z;*NTkcARN^lADf#7Nq**^Q6RzXQaoajH>X23ksLl#acs9n0ba=O@3c7W0E^7v6Wet zJMG{}`exX&+)1w0=`?cjnV?ADNx7u4?d(+Dpc}mudz_p%#9S?;L3my0=jO<-=%~qF zZ>za0E@`+*p0G3di@R+nfs|hppUbpNj0(q&Ig%!8zcqV91?&d)1Y^K{;0W*rZ~=HH zco$d&ZUx@~J90|kNU$7S488|`1}1HtWs|{Nun=4iz68Dv?g76BFM``R8t}W|H{eN7 z8o;?PU^}o2I2z0Zr-FrGC3rVj4L$?9w?G%*4DdE^CGc#uS3t`^&N~8&z|X-S!0QHO z*#z(d@BnxmJO#QBrVT)UFdV!dOav!@`QY8)6X46>tKdoSG5!0!DyQ z;Ah}ru=P&R0eCZ*11<+wgLUAKU|gB}!NTgO7kKz|&v@*l%CP4>$x&1Rn=ifG>kJ z;CtW)VBCJt7dRhW1TF?20UrgQ0@s2sg8RWQz+L-8E1)~)9`*)%fkS}jBF+Fa!SP@Y zSO^w@rQi$TR&Xcy0T^^3?Ep>$ZwBuG?*hL9zXN>^g6DzZU<5c8oCsQ9550q{!F6CQ zcm%8ie+I9B9tSgi!M5P7;2q%W;7+g+^go1t03*S!U=Q$(LunJxdpzw4MuJ_z;oxZS z5%3AH=LFgW^u&&}1zXyn>om}93%&f088baI|4s#qz>KCiTlf0j$S82zR_G_-N$`81 z4l9O&ZNUEE0I(P=1s?#Hf<|Za-q8XN18auBtH4b|k(*#Y^sN2C?&u5R+5#_e{VPy! z_%QewP=C0xz(C})I1(HMrh^&a4F%S5?T@UU0p0*6BCo~kkhf#O2MQ>A#Za&fco~#l z2agAX!7st1Kv^rUE%0Nm_k-Jzi{AqeA^#o*2OyUY1m6O8f)?b(N#N7)|Ledkc>ML? z26*{bz~A7@8^InEf9K;MdY!1%y55f{++#&5s z+Ib`PMywqhVW6DnH!n|N3bSw5a$VC~&YOob!*(x5vO{Z$ci+GEX>*LcwWA$_rS9ZS z_r_2HSGu;;WlO(op|LIFWeXqM!jt8M|DE#1_|yNDvhp95jotC-j=zolJN|PAaP4~< zsQv5s*2exNG>Q1z{2o?;I`^V1sYJztT$%@XHHCB2rUK{&z z3kN9YIgNeU*L=*^^i0|GYD_@Vn?)PWereOIvtRO6pGvQ~cwKp&SxVJkfi#BzAjoQxdzqXc9itF^Mr$sXCc{l~js~-0?!oMYCVZ zOLE5xCgUTWB{K$(n|4X{ucQ?vdhYp6Nj>+xN%=&rq{h%ZNoN^*KNbPN?tOEj>MIidm^2VM3k6#y5Er(ZS3@~{Zr;y z%6fMzHTB9iPAIJ`<;DgL4kt|cWQ%;x&;C7LTo4oy#F2e6QuEAtQuFevQZtGCU91kp$5-+G&Dq3VvbHrV8D&EPs@S%)nx^snYYR!580E}dAkv}FAfY^-6$ zdaSTyT{AW;S*{Fy5!?pu1X{G-Ixbd#l4WZo^tC5Q7Oq=ZxoKgQ<`6IuTn3&19W7rc zvf}b3@JsLn&=NKf8~|K((JFQhcozHx{E3y57A$17EM#~eLPO{CfW3wlU-}@HdKi4;&8(DlmX+(VArFie&o#Xp{#rGb& z#P`dJ=UK1J^Z7*aec0~tecOS za-!eIX7A+c_qSc1@i#VGHzmG*wfO$jk$xYWz3pRhf7MZO|6{BCJ}$d^YJ7j7`2L;Z zy~m2*PnecXDDm8EuAUydB>z4(J8610!LxSX#MN}}$=@57-En+;&n}Jh$DWW)_$>8o zD!w1Ucb}hBT)P#&UvOglet7iuhre);91$ZyqI@&1uZ zvI+gT|7ouJp?xm@J~lh%?705|SMQgL^eIo6>t*d_T1K zzQ+aeeO;0Mn3eJV;-frWvhl=kv z6z!PtUf!?8HPY!p;z#sYRf6?5^=R(it$S0m8bdSK^vBKo?-;DP+Jv?I>Z7ZFm)=_c zm%THAudAx||GAl(4(ZGw6gVxV6e%$+Q$diXX*xiM*aRr3|Mn)iZ98RhPZUID@Bxab4{>+`4k&_%h)g1ikpK6$*V(!ECb>5O@jZQV^ZDgW zdt7_%wbx#I?Q?7gLJ%BDIwj0qa+QavgQ>Wae*JI6Z&F@r+K+F567=?&)|!XAF}0;}JL z)$l+wpt9iXsf!gb`cv5m8(D4{|LrVcE`68@pWKn zIJOill(d(u9mL0^iGwf21_q`_H|F6RpWV?WFHG}}_B&qX)2S5@dHTzjQeKe_u4jmU zbR{p}R-S8R#D2wALW(_$qURq>%yc=if|E)lR=R`A4=G%CBu2V}N$$D}Um1y!uAm}1 zN{rx$LD;_&F+vgD2-zLjh}a$2h}ad_h}a$2NZ1|NNZ1|NNZ1|NNXWi%HxiPLlgL!H zO(P*B;wX~XNZ1vPgk8}{*d2|8-O)(c9oR_N9oR_N71&7F71&7F9oR_N9gT$D(MZ@G z*httFjf7o+jeL~bjdb17$k!E(d|lDV*B#i%#}`{%xw``!`MLue`MLrd`MRQ!uRE}j zuRE}juR9v~x&s^ex&s^ex}%Y=E3lETD_HJEysl^j><(-M?2bmjuE0jXu4n}84r~PM zjz&Pzbt7PRU?X66U?X66U?X5xU?U*uyAjY>b4Ctp-sm*OENkB6u197~y#eO$hBf~W zk8s^1jBs}_x_t&59DJHKke~Da#0WQNrg_cc1J(KEC@t=KM1#*jekfBnaxFeD;dUYX zYWmUB9~pRLKh5;`(UT`|w`}&nfU3`rGmYmAZ{fgzDP1MplZwhc&MX<-la#T0GR31Sa?h!lF0L8j zOGrgI*e^rC4U_TZoykCh=C>@QkIV~#f2RVn60Bebukv9d0kPm;`Cq~gbCvZV{+orq zoV{)uepTXe>|fRNUFTV|Kdz4G+E`CO5~RS>;2H2Nz*DQXc zTl~Hn^@S}Et_^eo@xlLu#qa-urSA)eGmkt1A8fD`dex&R=!(-{M$Ahh2J}n zZ}r1K6Fgb@jt0kp(?Ab+0z40%J%%vH;>!)L2J7F*-VSgLesDK}dgOzIuLSX-OUx(k zSdOQI_kj<9i@~Mf3UDR33ZN%d1{}L13m^LDhXa0Hk%bRcKe{#xANpf-Z5BTCLwDUB zn1!!9FbiLIU>3gaz$|=S+L7S$F$-T;U>3gaz$|>-k%g~2vhZ~WX5s4&%)-|dS@^nx z+nt54J1`4hcVyw~iY$EHk%bTadX?p87QU{)EPUwY$amG(EPCC6S@cNvLf!8Q%%Vp* zoCU8tvgmb37QL>>qSqB!^tvO9UUy{CgO1M9g?@|W?lWgW&*<7LdfkyluRAb{9{RGg z=yeBX(W5=0`HETeXa{G}8#;fX-p--UHshx$cD=-V* z@cE2c@R&b2i(Pl{Ru?`yzu6SUA8G3S+Wba+c<|S+v%iG}Z>0H+tarkE_Avj?&2Lo0 zf9~HEuUYVN7@%i!D&1KfR#jCks;(Koyf@j>)1FGkJHp1UL`(bT_LjJ=tE!sX5@A!r zd6{r?Hb`qC(~@rQQh=~C-k$8}3++~OA`|uyp*hhO-`1W=hpEl(x~{Qt&BmsNjdh81 z&x&-ax9gNdx_xusV44fU?QQKXZDD&RZ0Sv>6UiQuR6fL+T61}o=#MUs*0}#6{>Amr3_mWo7o}Mc_Y} zQ{D}}4ekT?1HV^8tK20uHlEn*Bv^A9yy>d$qc)`KtCM zO7GR`wpO!G2bX|Lf%IOjZfh0$EkJs%Rb!F6QYhctcFd(4bKpVR77CM_{#ed)(=QZ0H?KlrUdH_~^ImR!bJH(W zo~D6D2%J)2rNuU-13YNepnfD!;Gao zW1)GWFk|7p-17V_&U5Sdw=T~J@}wyJUq<+0>EzZcqT8@Aqud`R>k75w2zd>Qo7;9# zy>j`pX!zW?xn(X?o)N;k^k1#^9id+rE&t2ScYFbPQm9`4!1r@`VCXr`oA*PFdeznl z(#Y(8gmnVV6Z*klJ6AZLdBRBZg#!-w$DT7>#~k4wW!@lf*T2==;f^Kj!v~r}Tu48e z0o<>j|NXi%`0M9vggYqiZcWaG8zD>!50uUn7l42L{*J#<=+0;bq|NjOx#?oH@dtpZF z1sc8bd%>%HCtLSdJLN3TznUqJMlp@m`4oFK?~ImveK<6C=-Z!Pp5b9$tvjzguhHst z>YUN*H9X8~cXCJkS4NHDZTia6d1bN2n)_({^L8xM`Mp3X505qcj$#e|`foyG9qXN} z{86mYQhwwOLsR}oyaT12w8>KJmDgf4itTm8NK_pjYxte~7Svk~hllxlyOUq$or_;- zne)@xn-!6<)HFX<19PF*?nFG^KNe~X?-wKAxrp1-qJ)F~!eM+63p02%%1Iy3J$5Q= z8Sfxv_v{mO_>O%XUovjVPO~C3=P?ZtFSRVUt>$=AyDg143U|7drygzox@`+BF0pn z5@W{YPX;qDKQ34@FE&{_6OPJmPB<VFr~Gh}SgHx_ydqiO!68d74Q9vY5p$xefqijiEw$3F;ut+bEg*ia7_anM^Kt)!<$H5n z)83L!$(JZRHI;4+m!(>IJMmL;{b=pdqfTW=4D_VhKdIKp8w5-GgGswC`|XaEL9D4i z9&B2CF=H}2)OKEZ=#I0_W*^6UgRYe&N8j<%030@fjydF~l9c@LJ3st*^}bWj|41e8 zKL69_G`5xxxu+e%Y*yhL7iKlqh^E;}m%@VGfMq_X<4GI27~s+rTn*S_5nKmUhZ})x z)whB@!8ZZhD}sA~(k>+rl}Wxus1PoUIa<}FI=gy%66pous$@%b7zCkuji{ib($H~f zXvbq`RJwe*Rq(h!1rkNbDmXdQp4{Sm!YsGO1fF8;J$+$As-wN7FIVN)SDd_R*~Oc2n% zI#)i+QoUQkHSIkuZHW%{Vr9c{Utv_2wYV?F5l6-1sGW~k7`Qkp=a4?UxVk3jUBdm~ z*nj^VCceO(uRJc^zwox0JAe9%Q=9#H#h%X%oO+vk+m>jhw6!-;N9|A4QNK-KJ{Ps` z3MQR@3pB-LP<`OIP5r@c*7g>+1ZCWtC7BTQ|H_pmhuqO$8_ZlxWN5o#@$8^sXJzS? zU%6!9*|q&axU;h4%3IDFcoI5SUNC#$x}7`s-Ldl%2kzK;^PxL-{`~MA{j-9~`Q)+W zUBTYF&VFdeNiRNi&;rV^q(7)6ueSc3LFKN?f4gJX9nb98^~ei57C*@QoL@TlYfYOf zP9V-ym5p+h5cW8g3;DG8q=9>n(R1oC7rC{V=ds-!$*XB+X|QC;S-~XAx_CF&!^%xr z2g^+zqHm7`d*cHahz*c{_pjTSpNNnl%H#*|M(TRG2<9t##d9O z(`@`=(_l>ZIz!EGCI@FUpV9neWiU#4s7OonV zvze|rSL!f79ci^-b#y(}<3?0lNvF6}+%X;(5N`KpV!^XSIp^9~@ENY(NBm3F^@sdC z9ejC)JRY^YN>{&%^X=%<^T(m-`s?aH;)VL&Y&;*|9~Dk?ADYh4Ytd(<-)h>qjR)69 zM<1`y(U;4or*b?2y?l9|y(kvEpY$HMIOftFn$AdN7|Xpz%1<>1ePe%iIA?n~*UJGtQYCYI=$mn1ce)O4 z^~y~7${pT&ug5#2`9#k3g-bsFd_}^2{{p<_@y6HHy2fxr*wqn#&Hq2&|375MKw^;4 zor#vVc(T1Ef4+IzzGPIeb)3XloeT`<^qt<|X; z($X{7irRe;@5rRWOmA0LD&3Q4eIp5HLUu8PE%9WSh-cc_@z9(I+mo9UY>Q|OH>Xpb z#tEs8j?{Lk#I5a_mR>eTq>>B5xRopuc2XIl#!0$4lj!laD760~oWH%jr!Cdn7rH$ZqwVI1_}VjT*i1cI;vJNyE0NZ=6E=x#PlY}4%+^eG zxV$}0-+`b#@vTsndiN%oM^S;+aEtbesPHXp9I;I)1et%nE;BH-`UMeEZYv6VS325B zir}fPL^52qG^7n%I}#ZPqkug~p2bgvmsrm75|86S$59WO3<=2$pO*k?HMll^cOf@USnb8rbO4 z9Bh@rbsw>87`_mygHn}Hr10j)+KE`2h|MvWU5xtcMnC*I!Sg&E?-Jy6-A+=tTn2y6KvRaF@* zNr|qAAdr%6V0tvXDPgHd=n)Fx+73NUca_rocR`t-DWFm*DhOK&+xa>iGc<7pl-E)P`5h&LE~VQy2imct_GG_UH$r| z73uu9pT`Jj= z*wGV}W>~O|>+2g&Ufr~@p=o`X7h%2Yg@?Scs;V}<#o3;$^&snJHyC7&mEcV$5?<_u zhp7)b`G`1dYFH4~tu|3e{j7mG2|K0o(A`?%T}~Fkz^w_yB6QcNU_A|Piud%2T|2g< zu)DM&#QknNwY}?qQJSjCH)~eWUz^+({ZO% zrQ_Qp*@!$*vpzO=qC-eSaoM=B(zo>dRkpP=r{>6n_GC1m zID*lky>J*9Rv<~0#>)$&z!wN3TahdA{@t>e@xC^>TbMI3uL-uq?oTmyt$xAKo;`h063MZWxr|`wEb5kpPF~)-CRr{gbr1MHpIJLnjrC2D> z;f*xt9cQd4rbAqd#-og2QjQM`>0($2R;vO1E*u^xC#6h zdt~nczX6B8p8cYr4eSD+20sNq1CN6H55*397;E5Q31|eDfg8b>!871lpf&dw28+ze zp9)?)ll!FbMPB3PrIz=k@WmM8Rp3O>!m?cgyc6sK?*;DzrFbXlyR7rT!Jr;22j2$Y0iQaO^%?LV z;0xfJN85K*tFu#$KU_%UANzI(-*J1=E}=1{^VtseeA*y?Y``N7ys+O zoO9MY-@ci6z(x3g=@h|wZ6@zCh2hVm6o?SV3_O-#Yn>jl~ee!SJ zc9oc0NAcZe-YwhH_ z8wcp`ELS=i&(X<#KRyhT|LR-5eGa0HJ_D`+dTail!B!lcI=~me_25qM4KSC*_JhEi zzzN`%<5@ce_k#z(DCG zb&N@12lzKof~md~lmV?z{N+#2jre=!$=^Np>tFriXAk`Nhxh*1x9__1KX3ioSNNK7 z@b~d6VO%b+Scr2>dBr;SKk5Eo>;C`B{h#e5)FC-C>uh&^wfp}~_x~mLf1#5|Y4`u% z-2Xe>f0I|gbLUU!zmrns6)(~8%PU@oWDMRQj|P38GQ>Nrn*ZkGuoa)Q>A^{XzT(w} z_d|leBu^Wir@=ONmBH^I$@=MPd>fMP=}PC_mLbg4;6&p3x1XlRUtaJIQB=KM?>$9r~mEoS1c0I=y?vxLfvX3?16DgDGvXpQs-nc%A zm1(Pk-VMEydnxz6@ignXzIJ*tyj~NzXW#iub5sbWlVa^Tw`L8lX1deDvu4UCI!)m% z)bbM95|y>qg;IU&`J}vhE+uT58p?xXJ~7RoWD7^pFAa4Ukbi@tt=?>%aM!A#%D0s~ z^ySbtj$MSC2WknWR?w4)?%ngP+&#^e!q=mUP#xSIDL;7zsy;pZiI(DvdU8{mD$x{Z zAkUc1oF|-Ti{~A^{IX_*`b?#?=HIE1 z%0qNJl^E88((q0;CzZrFc`Zk4zgFUx!lg}wn@N2673s^eNtfpem!7ta*m?j+2SeL|!6K zd8j4mAx4i@@{ZFVmQl)H>Z!I-S*;9JaI7AK{NrIu9tD%Qj(jV^Mw);6k@yI9t?vt4_R++(c|jP5TS zLyp9P1Hs{7EjR;ghgM4+EyTB?L!T?-EVxB9l+2L?S;3Wh%65)w#YN7yr-rjS!dU%G zW{o2~wRN-m9}o5&7FROLxLdS2Gsf<{<9(b#3*q;7NN%}RDlMLkh|j0s1>8T2dlf-|8_ zGxyX+`fiD2nfxKQ@l15zi&XV>U45h4_}R-lg_J~+?2w0{o^FB5LdJLNDMPuu3jQl0 z-_H~3XwK?_Yux__xIT(jZ6FQxL-AalD~U7>eJNWS!PFtV7BV_n8B`DX&sWisYHv}- z`m3}9OJOFdkKS*rgonX{G5pucpv~i?I)Sqz_-|+R*fu^J-0EsFD=ejSHTc6#aU(#I zm@2)MOjM905M@e(rg|pAnTM69o%(vJ z6>A)CzP$E0g;=@0c=USiPmE$EEL6A2u7t&6mQ$xMK;U8*o02VA%pXvvF~j7rxQ><>S2v>dJO z&jjB=4=r4x@48erL#0{xrWOmy+n)KGN2?qL9gEfSFHyJ!c=t|*I}7K&ZvhTg3dL*o zm*Dc?E_#A^G_HD_!xrTHEY3Di>C`v<{*_&kCmn`xT+dRzen=J(?_TL;6W3YxJE^kPm$g3decYhSz%U-}ZUxvUi#$Jo!vsd}57pLi8NNGB)SkEqk za`t&FL<_hnxVrD9>p9`L~2AUg|xIw5Y}2jP@dpMSZzgc{EO` zC##1R>Vu<=Wux=s*IkV~Kl=96mlXLH;b40f>${@(v0)*KtM`pO6WpT+r6j9;TNLB# z$6Yy#aZxd8xu1*en4k zKjgAS;fuT#p~AuPp5*0|caazD@!S$TR`4P(PT`A3auX;VtnicE_+vV!W&KKj>9jx} zaVnQzfWB?dTCY35r^KCme%M?4<(~%6fEU3_0KpiSn%t|gI_afKIH#%`Saj0yE!I${GSgrj*YO|duzv8L76UsQufA9tT}Odz_D{> zP&T#n3{fJwb8=-Y7#E!fb7utyTzAhK!s{M9exwha@1#*tRD;-pn6@?qlRCz48n}Jn z_DNTdzbX81`TWwqpi<>MC0xz;O{ih4-ML@v;36|H&}Rj$<`-o*1KKGqPA?VvZkEGQT8iYQf=KqZ6Iq}hkJeqcbl-JsU_4t znk$=Su!}b8<*C+AltLWTAz&J@EreKXWL?%eS(3MJDE0#4+q#0Tv_>HNW^UX2Qr4k` zAIf}EcIQ49Ds*L7Oq)yNdF?kA3RJni#aCRRvaL>95A!_H3Wa6)mo>MS)-Wr-LW?i* z`=R1npVV`mXL%$O^-Nh_leBo~RsqerEN;>INw$BBAN1Y;+5K%DQ!#YcRv=Z@{QD}2 zxJ%#3*2+RwHkf_7Cr>gA&rv+{&&W69BO8OP(M?hRuj5`LYa|<8e^RfOwc4*~sV|4D zRLi!m9-PZLT8HxeQ~g-$I*P53{=U|Qv=S$2VDGXT5OM8SqmJv9n{?DkO_Z8ga13FqJ@SMe?Sw(X9p!JI37`{#Eg; z)LTa$VXy(%-+I#8=B(cq{~tl7{BO3uq|9pckC62iFLTzhe!mRKQ;Rmyz|;Cj3iYxQ z_*##Ty3(t7=o!_rIxm#XZK!3{?vC9OH=n*ZvhCBnVx%LcT|YJN8?A0@jMsROW;#(H z+*xuND<5U_*=fOJObhpfXS8x?o<d4>nY~RMKx%fB7q9>ua7fqKb`m@<{0<-&|U04XBN~?bM)$H8FW; ziUy)%6Hlx)%!_FnG2_lhL)y9bgOHA9qnqe8F)Eu<*y#F@#@0SK=~U951QlvQo%6$5 z!}$hskw=wzGN~=q$9yZxH^X#tD?z@$lW)zT?Wk2zd6t>iokmaV^=d`w`0ByZB~Rp7 zO@CLdXgig7CLS!_<0nlh@6oc7G~^eO&1<}) zuRLNj=g}-CO^dB2wr0MnwfVZ9L>ZN~N{}FgT17rD=4awP1ea1WrI4WxnnRoSjIXV7 z*DP7HZtA42+#zgtS~2R%IF0v)gT^@RJQ;}4_bkD}v`qvL%# z9`u`*XLPLpP5blF^|R6SBhm5E==fVZo>3AV%XK9FYEFB6_rL>{Y+PBv+r93CUvtE&j9(#acCG_&5VI`q(D@@-C2BHu41S>%zcnuO%3KY1SJ zk1+WoiQ2|`vZyF($p75S^+}Z4OOSlYG0nBAVtQXh^OaT$`+0I1u~$;lde&uEkh=Pa zcttWmo^JAM?{FS_U1%06rAq7NovtO1vgyf(U6Mqch!d>$ zi8^&q%crb#eO*-wdH>40Tl{T3T=cV%TK<~qxf=V_Z^X66Mdl?gDQaWi6!KLnSs5*@ zPM)MnttaYv8viuc17q+ePumQRLVZmQ-4s)+2}2QTGdRFeJ^^h?A+2< z)o(fpWuu8=n+BnIZ;Es@DovucimkfT)AtqHtYYe^qDvpot;{NKni8MHF-aQooV65n z-`abxsIF>j?-{N7Ngt6#w}JNYKK-%+N`hGrQLf5qz2hCFHr>@(qmyZSrprlN(;fxY zQ2k5m+KM|oH}zZPS4}UfcJe~yu(Wc0wkuuRSl{X7c{6_E(oSs#Ai8RdmR=_cn{=`} zvS~KB=N;6flXB(uz%AsazSoEEiCR=VpgZy%S1XG`;x6yQxu@fu9WE8s$2`YXVp&X; zlg2W8YiK8Fu0&?7b2s+352mxOcGf($~HQ?N`X|j+ji{rEy5JQQtJ#DxOwfvA*lI$Dw+odc5d%hKs9qH|`x-50YN1 z9R=dK6fK$SW9D1Ze8I;NqMZ^byjm#6tUHERmwJU{RVTB~qaB5Eb$OGl(kN^MRBtvt zer7Nb>=E=ssRM{L()sM@ehK|z1>R$Si@yoM`|#@2E{NQkYeq7X?p;FZhhh(?P=S6n zCD=dg;c08|JMN@7Tg04xBAhIq9qI>L#`D9F9?znc4c(13j@ec`V#eTxwNW|qsZcgZj~V!+eLI-V`w$gcBd_TjL(3}4YJ|`@Zu<<&TyIscItr-P zik-hJ>UvTgZD-UM3FCK1eTnnejj}srCUx5we0dBZrDYV__f(FY@O!gjgqsL0mr;kI z`?e+{O$w*72YXQN55n*sN;7Yia+ksb8kfeAi$+PmcV@5Pb>T0Ge-Qn0EW5p?k&3lZ z;T>TUXb&4Da&wYh&&yw1Cx|Vq=Qq+dq_dvxiQ+N zu$0h_3ER1FI(3sxb7c8b%)8V|QhZ;-2Plp91np+j8+mlmSgjqidW-gz(B?#R^l1f3 zqa7s*a}r!sh(6x$v~b;JF|H3TrDST8d10ZH%(7kBZ&Z}lc$UtyT@M}e=27Ni-t)Fc zqc{h?k2H#M>O|i_VlH&wNh2oN9Q|!!9_gQ{`bjGsJ@=>(Yy(wL3a6LUlT>d=&>w<5%|IZ+O z;?%{<#!vFap1WPBdx>#^`}2Fgo^~`;{J!A(aMoDqRTJj#`LeRyS>n_E<||D17UJdZ zCG+X|J$P2m(RY}MlZtT$Yf-FW?TBe7osKo3?T0%i9KIjU^3=|<6QJvn$n8Qq%I+ms zG{D%ANcgerC{zB$ca$l`!je}ldjjP$4k+el-#|JwtSO31PQYq0@+e@TDhPFN@Cnk5 zQIA=yK91HC_X}(2r}5aP*yk9H3QMOSQ-(yKQh%#xIIYN8S-(#HBbPNK&*E*Y^3Mz( zqa_NL$nOWSy+g&y4v&nw|3G1iah*8rf#5tiPZU1OwcPg^o5r@Q>SDrcwyW4`#ZpJf z%aK#XN0mpRQ}J?*zDLFHnc5M%mr>h#j`lr?gNyHb^0^ltr~Qr>%VS>nRJ4Ohx%k~j z*OJ#yO0@gvtMr&+@g;7zp6oZ%x$Ajz z95Xb{aeUcJBW^x$l-X#jqrm8+zw8bt8f`ne-3?rK;9G!Gof!=Z+! z6X@w9?;AUdw6t^ja-?_+ogqej_5Pue(yF4jj#aBrzsN1)*kejR$c;IZxr6LW#oy>8 zo>r^2GK))~^KE9v_B8X>Vs@A3$Z52<1{KnlJBeFNTjm>C!6TGpA*DKz*+!vsMte_y z<~!P$pgHKF?mZK-#ubwhvng5OnMVx%FXwr7$M=z(Kgu|8AoZCrs$Q$P(de8Vqs?rN zIt6{Lm`6Bk zq6M7sG>_i&Nv=99O{z{xhN3@n@ap>DK zwC`EtK(Y50=q)&APt@v)EQaf_W!friIXzC+MXlkDbCw?UrxX^;jFYcgakZ5pt^4M` zPi?ZZeCw%y>sszw=|uX8Z1K%J*D8}Nrn32sqcpYjn0jUu4IC@o%wjtsz2#S9nE4L) zl}7(WamG8}U8S&^IA-tH`^D-gz3j+(BiBlv%y)Tc)k}FT!^gjh(XopDA=|ukgD`k2 zR>6>#lik?hQ>&!Pxt_DPl49ZX^!)XN zGOPCrVl1aU)^n}+A^G{-O0m9Z)-?`WOzxKyt6h$-PA!f>hdDYg{aI1{{F5rTW~hT6j$wxSS^Ap2vEU?9 z(n`Orcjc!v)s@3mMMqu_n>UK=w6_t+2fC4b^j@@LZ_%6KWW=V}$%H+mNG*(FdMm`y z^xaZ4lj0PcH27Tntv=v=bLJ0`N8Wojg``ohRUfIP9knM%t8&h`${|Cp@`RITfTd?EK=QXxD&~u`g|xH^O^}{ESb8f91ida%hcR z-WIDV>9oktPWecNNE%wHXQF8>IcY`j6v8$FdxN1yMdflBArxDCpVWTx;`4i}Y?qu?v|1?Nc;wJJ{BKp8 zwWPO{GkMQh4fMu7t#NsuBdsrK?C@_L)!LNulQ*%2H19x-Ij!WbRHl)Gp4oV$J}3_b zql;F^^yCfXt+2LwR?C@2SnoGvYkXRhQ(K#FrMOLbYRy=CZ^TvJ8`8?CRWNJWE!1); zrO>Vq$+0FkZtTTzY}7JZW#3h+aZw%`qOew?B~>)usl?{bmEpch9cSjN{b?F8K%U-d;6u@U==N=6;bbFsNPpgIW=|+ z^$5@!soF%^gLDpyZ+tj~_R;#JdWrmO{Qg|Ek$T>AN~Ag%hnVb9|5QIRFF37#s{f0p zH2+lDBpDQ|6AtilPyNlLjC`TjLHV_WRsU5VSVq0qySVC&>gnQ3(MM1X5@nPs@}>?(#7~g z{-wGyAGPI<3L0HRS$of|q`0osAB`hUrQOA0k`W!Wo-}Cl7B%XcU!^3t*r+Noyt|xr3GkwQXb+O|9(}IE`Dc*eEL+zELZ6b zrNdixGUYHCZSuj!L-Wbg%s_S>Nn24wbXKb3ag%OSoMbUBt|o;15fxTFS*>PrQE_Vr zODxHgh7-yNXTB0350<0j?ArK)EsN6oADaGb1uqw%iZrDYuMcYMg} zPN_@JQ2UBjmY$a<891cY-IEqz(oZ_|1lKP#s+%Ts3TJ0Gre zn?SneNo4zbG@h)6GP|54Hoek&hT9lt5;j|UjnJcyLfJ7$Z*f(-sm;{WeQnjFC0YHB zitKa$MDG%|z9?<0)6v-b(bPMB6}9taeFOIuR_&>E70{rXHmQcL)ov6#g)l4V_u?(}l69nID^cPi@saruD>qR< zeN1DdB#!vnb|J_UT)Zl~x}R%n_k--4y>o2 z`*BvW)hCy8)M$~W?KKM67?mAQtp^!DXuLK}TRu~2C*yJT-PJ(+uiaBNZc zSO3U;D!oQj&~xJ%SzAPlTJEUTyk@I8zOKy2em(i>9mL`^-{X|0O1+ZQ(r%>hWA?nB zE7ih!qk5~g=b6M-dTNl407_ArD^3iyW~Vxgcda>(_RiXa zv<}e3Tvhkfda@OXnv$lnNSV)D(s7@qR_n^6y(FTo`dn5s8Y)+&lalp{TusN~n(iUK zH=QNRt(xbmM~b3lgXNPxu3D*eQbsq337+dWUxxR2OCR?&~Rooa^@*NptIUeM)t+eU5&tGh3cXCCwZ(W^2rnToqk3 zzS{l(FS$em`wD{ZHT8s19!g!*7Z=*MK`j1iN@epgQO#JeD1LvRNu5rfsC~7+ zOnqGKYW-XF*C?sEmHK?6qqIsXtwy1<>1Riwp*sfrS4K>pNy2N_h(^UEmdYbZ*N;!~ z8y0_0isY#EIgNQ1R~{M~BU&htX8Co*-HvU+bTZAF>fkNOA#c6bc%*$QDyinfx%=MK zoBe!Y3bO-+v3{wI(3w07_nuF^8TIi9xrX#M<2xapVmCnW{QA+3DHl&^@3xq~i?fuplS(JxtVaiQ& zUCpRZj_#WFSL-YbHm0>WdUZOkHXT(XllV8^LRFqa+exJ6bvw_c(zhk8MFrJSd?rtj7%7>vm3x+|I9I!2 zYe`p}xt{-Ob#EDwUZb?tt3*plC({Nr;;Ix%L9$GIBc4>PmO>w0i8C}BXwubZk0-MRNQWoS@TG5o3NeBl7Etkk}H~_h#PIzWHTl05>X4pkTB8- zwQpHpZK)@1y+2Aen3b%Tm?q!la%-g())TLpFdA{yZquow(NNS;9k-FLedj34|FXTy zu2V-jvLk@_KsGz|d07&dI?2*N*u&kbpyp}T<~Ea)_N8%5bkHcSmJ}@{)6_<0k=^Pn zKV~P_%uh2k$);?dJB2!^<&&(m)Dl16@?tHcQByL=ubs#Wrtx09Egr7tzw#58nwBal zruLNHnrl-t3T|`Mku(&&#L?nq<58v)7*K>suM~VA&tzC7hx!xV2HdZOK78}_jLT2@S z_i1TE#)+~~t2J#-sBcCoeNjUaQkKFMPG&a}M)q=z5RK@%dWX_F=%Ep%2`(&ky{?g2 zkiO4ibm*ZJ>q$xUQ5{4dqnaPRB{9>E($*Gda^49QluW!!IZj#&FG=%}EYKWLF~yy#f81$4-oB!G*?eqx zU$I$+W_%jaY_{y>Mz)PL=hSF!GoB78FPbRLO6r*}5%twEJu`h>)Ux@b#v!$)YH2g% zEpC;%P#Z5GH_zE+)L(t2&b5JmM?{O0<;Gc(XR^@dzFEjd(%e?f)kVzuq4&_K4P@ID z9~p<*`dNKcGq3%Ki`7E5V?%vhBd5JLMzu^bUr3RL!l<@c@58Lk#^kw4Oryed%IvN6 z#*H?jOKxgDC0QuDr!0MquKs@hqmdyurGy(hjsMkBny+-iKgvgKC+RPq%zn#GqxgwD zQU5l(NLDvqP2Q5(CR_E+hFtq}E>&$lX_}TKkMWHtqS9%nn&yJyO6eftZPCq2B}pKy z!=#yw;>JH3sU}ftwXAlwncOfPW;^;wcD+S>u_x`P^woyyab}OxXkjC@I8UvjnQ}Ab zvA&{~H%-#(VA2s}e^FZ5aalTr%B-|yi&Cp7hH4|Lu&hdIi<$7L>?*ced@4t+cA5QD zt2WY@*HVgl$}cI{0|(pNJEn3^T8!#x^pnhyoHGqrayDz15QQ{Ki#JU7_VYmL%vL(l z-*%k)8OB;dZ>RR6wQ85$<1cBZw(5gV^j{&&#%bfEc*^39^nN3o`)0=yd7O$?EyU@_ zn}ccIB_2pI=J_@HD(E4)N}u(5zG(`wGD*vnW?;S3Bxoo1q_b;O7JsRX{>@YBq2e@A zM(chWO(jRncDgrtEpw*ADNem9zf%PheHh zKDaB$wYcZJcK*&Fr2J-moLYRXYH3$#DdHH_y3lUL7n$#sI|}+8&OabEeS^q6+3#jF zX`yt*J=wM6Q_?|ovN`|ocNoO*qqF@+Hx%?n*RGb)J!Ut#bY_L0qs+6zBiJQU9(mBIe5LMdbiEw4|8xpR?eLTh<&S}Od)T%1Tl}7L?Y+`7 z?FRdWJKpR3+U1w8y&3WotY8PLr-*ip&1C=7QyeD+KV&a^8EHJ|yv)npUNZADFLgT@ zZCJ zB!_aAt|3dZ^d603D>>?2QqnjTM?Pw%yGi%zbW&<+6v{Mqt$nNa%2H+Xl_a`Q9rZAa zhn{<@kKeg`(j4`Fb2iU`A?R^b7X~)7XuATP@)!H+|GRknT<7siXc2qvi;%)%%=VuMmd~^>lyAmG1pq})oR6dtv0xvzU4S#EW3H1igxop4j+uZoA>*q zo`9oH;G1v7_Dg==g%j^RQZ$@)^IBOSCV!35(uVT=mM?ZSDn5$Dg75KuiDGo|`zuG^ z&3hmDX?IkyFS{vB@eyLP` z9|6x4-^HsQaxXG|v!(@u}wR7pI{ud zJ-g4*4^LpB9;)-wN@VM-5gVIkc~Ut+N_lF>y(XJ_FjFxAiKN4tQ49B`V`H6 zB^fj}`f;oJOpn?--oIeVYeL*EcJse=D%;eWjGs zY;c;vY6U^_PFpSXyVbNiIt^8{s-d+zzy4%4JXyqKEz7R%dw)fGS29O) zW7*!d9w@&8g_8Z-EXEnmwUTEZ2ibd?k=m?A);2$nmw$u38&~T(Hb0lGQgzY1)>iIB zPwn>6bF&f2uCF>L;X%>R{2PlW)Y|4>qFqaBaa&37-rom9dCj6l4L!?W zL-qbN z{4z#*v+_`BI(`JoX~kF)!1rC*mnF;8BgNnT8!57*+uD1x>m9Q7Y7dXrffUwOR@Hm_ z8>V%?lo0Y(vh_Gg09l~aYpj1ZXw zR;{w-HSYqmvot zM2+lIt-I*U57|4mUZd7C?>y1WORpA3E6HEIbJr+*Kwe*X`EPSRkY4rI|6RchyOwgA zg{s`Oo7zNsBQ%!i-1~!Qg`wWn%36Fqp=?|dFJ;GDvtMc*zk_xYN65>|)_=uC8g>0T zkc}u>7tOB28V}mqk>C5GHuUYLUe|}@kt7%Qh~}cHt;UF76++Llz7F#1wf(1l$ARq6 z@|w~dOcK&OQoLW6Us>PkWOjC)&U1zI5v?p5mwV4L^8hry$&O#PpD$}C)JP}&M9j4#aGB#->mR2T8$_tcdX5dGv+Azt&=ezmj7I;}|SZ8|DlDJ|Yij9H{> z?Wi3dErgVZoMf!6fNI7k{XuJ)rjv-Pl(&2>vgP!YkjChDLQa6vl4&6nu^mi`CmtMY zj@69F%aES(2CoC6lXlliCn_cXHOMXbY-n6ipHV4VcqTnL3C(g#sP%Jsa}K4irBY6* zRXR~iJ3dwsx|aOBM}T&_sqsQ;+Ol4BZMO%rV-WG|(X#K;iVd<{A& zRc;%Im-183-Qyxp9??NLX&qdv@A^S z`OHX8<-_@rpV;0M+sz@W+HQdDj&`uSW1P~eV#=x zEIuE9jy9PHm#igaX$AQ!3}17arS$0i!VdDCK`pexs-r9$I!=v_dqqdRSw{Ewi;f3G z$GOq*py;@Nbd+zZ!dFMf+0k)nbgYYxk{SxPGCJzrFuGnH9UG(LKGE?l(NS+sQMms{ z?_Z40uXDYBM#qiOQ7gi_mVHP^Y5Y2NMo0Oz=vs1CN9mV3>Mhqg#-ro*=(r;~9uwO0 z^}M}Q;ocD)H^t0v&p1gOqcKjpnYeid5>V1Zvd8wZ$QRT4xaSu2aP8mC-StvS9}`z) z7(*p5?CW`c_UCh1#f;cOiTkwk)wE)1oZ63O`Q%#Xci$aSo!=&cTjt2&%Meo zYT0_VdDtno^f&u1=<7nWeaTApbGSLp7wkuSUt6u?egD2TSw*~tICKs3U_#3KU)BlD zJ-AY7D;Dv(We%>uzaw0-2f+*Cdhhe35zE4eJJR$j^Mo@F zm#j0Jm~oi$REufPmmg1+ulk!tY>kZh-)J;_(`;GVNv@ef8@WhlGmcaopNsF?(m^#Q zmeESK$4T=Bn*-ZuU|gL4#u9mAdV9U7X1l*_ytj94XcU*s&~Dphz~@)Oc?e~!SE%nu zXO=Ht)|XYgzj8G{uYtW z3(%*;GhiFw3)8`j*)s<|)IVb%{pS*{v#@){f?ywTDoBD8OM;*k{2V+14&vkC$APQB zwcy*}y8!YAW#B+?FgO{U1~!5g@G)>PxD(t3eg~cg2bTxIq2NsLPVi-LGq?xb3qDy9 z1XqK*z;{9YxFA>swuASBYrxmR55P~r@4z3xxXK`y3Z{d-zu957udm@z*4Xgw1BI?wcv5^Bsg#)d4R>>IItUB0X`3I01tp) zgQ`hEum_kA4g=NTD6j&&8N3s`3!DvhgB!r@VE?Khm;-vid%-ure}iR{gJ30S23x^3 z;EUit!FRzg!E@loDM4@tcnCZSVtn;|CU_l~3)X=3U<=p^`oX)w#o$U%J`KJAXMmmH zGH^Y32~3+F1nr;`{22TeykSNVECJsJKL8Jd$3Xc^XaJ^wS>TPJ4r~Ce;N9Tk;7i~p z@F;j3ymgNt*aZF+oDV(&J_~LIcY~5WgP;N|2FHO@!08|jdO;u91wH`I2cHIC05yA2 z2G9;V!Mnh@;B(*$;0Ew@@H_AnSpB*nXaN5L-U~|if!Dw};Dg{2a0U1!cm(XdFKq{o z0>^b>;UftyTNVXzrp?B=io8$G$=a)+JldPOTgpcd2rN`^c!$I zr~@AZmw+#UJHa==x52`r;4g3{I0w8Jd<1+Hd=gv@z5u=tehTh78eReAi=ic01da#w zpaHB0r-C@x3OYd={0F!Jd>won%s2)*fYZR+z%Fn$_yzbim~bqz4$K0x!O7q>Q2R#s z9b5rE4eka%0Z)KGf|o$War9fTH+VbP1-=Tt4hF!K<7o#l2OJC*fUms?nt<^qKu<6S z91NC&HQ*!Q<2qjg4Zt|;SFhnU8ob5>|7<)kF3|5p@Mf?Dbb^KwuE90q8K=OF6VXk; zqu@6{`m3-f*b5vD7K0>6gAao9z*XRC@K6=99E_VxSg;$M4{n`?90PamfxH5r-;=Qu z9EFZ`G&mHULAW}?pEu+4dBfYp5Qoz@wx%L8PqXm z3vXb|tpOj5pz&AO6YK?E1hF?D=fOMJV3H8Zh9Or`WjSB__W(II&ks14`Jd@o&j{VW*%Nwx;$R8uaHwt89 zlXdu5=Fw((kiFno>>+vslB`Rz_SzdbYz5iAA}tF+i%Ve@bMOoy?H$X~SY$zVM}r)O=UG>Zk($6OoJ@g>srzGVPpSz37TJt3<_9z$l6*)?k&aMym$~ zqpTiK6opfbERR^JCzg+A(Q00tc214uRP&;uDVUiGQgimpJp(W`0uoFtgjWPg^#{O1OfnE#xTP?(`f zR8ytgWSHX&{w$eWpPhEjra!xq-1@ANQIL_6sSYaglbSM^Qbdy{pBhZ+$)}W*LKI4> z8j9tWYzp(N=w~H+&y&;6dH#7*Df39=W(&6&O2vbyW^V?W$DNm&aaLPa5Qnt0yV?%V)10QwEdRF-1wdGWNP| z#vo5zH$%z1a`x)qb1y?xWC1?J zT~IeSsK2v+)N=og1E|OY17pd=5%3DUjq$rLu4DNDq77erfL~2;slWcPuK5J2JJtk`ME55}*PokY@#aL=r_Z+Qxlz1(4z%l|qU(yecKzWf zJPV#nl>Wz~>wONj>**&1ORha@VK9@Uo^Ob*PmiuIch@z+mC^O>OD+7J92LI5PS-WT zyEy84=Y;{kn&635c70QH{n&}o^NZ~H?vw2LqTRY)7<_BBUH>4uzCDWfV03@O+F(hH zaGN;lv!h+^x+XY%U9dzSX?-h4rSn}EZ((rjsdgQlXX)2$2$p~qvLf^x=%#m-?Y`j zZ{|3jcqJ~Mg~5%{b+RK^GLie|aMbgwqjvdOr{%XhW${n!3YJvy{8El`VEdfAt_hmD z?fJ7D^*oHyzc6jrbE0}(ozZno@S`3J|NdTk{vbzvAn?iPdTtc|$Ap{4{drOR1w5B4 z+sYjl|D7C_U%JoAb1p}v|IWAD^DlAK^BSMtPP=|nbiLr6cKt+@es#aaUwM|r-}9r^ z9ygt9*H3bsLHd(je_a?%jgDb-oEP=u%J&3I_8{Lq|Hb0Xa_KA#)<)sd(fx+#`u^y8 zeH1?+zT<=FXz6J5J%TbPGato8= zX_62}l1>TJrCfbwY7{p*^y}D&+ojy$wDAQ;3(I|CMOle{1#_>(K}?S4IdO7x8l}WI z4!F{lm&8h9m1UK3w_@Q$|FXY+otiV@77W|wn3mz5;%efVQ?n8CTM1PF567=?&+;KDdoLayP5rhvoM`T5(x$_SD4+ z82u`prs<+`=QnwI`!KH^$3}rGDsCNjJ+J@j5B5KTv6*f7tweksSQ?Hk1q&q&ENgnP zduE*YQfy#gdURtRPWW1Akt=1$@`^caXO~mtJgP+&Z7Gn`rra+ZT+a~y=t|puT6wO; z7yA`kY$^84mofKv{G2&&nlOHR$nUuJWLIxb*wfdQIDXE`Rm+yuubmSnTf=3k zmfp@pvWHj$18bKab*eg{o>coM)yDcu`h!WkF8l3{l|ihjKOSsad@(8!LUiYqhweD* zY`m`C8+5HKIr@&5(7{V5_|9P&>%U4;^26`^@Z;6{PCfr4m3TM(>2u4tS3cyPy5wBI z;;-vwQl~Ya>{3{;8%RuE2+*2?ivbJ1yu}F*HE2`%)x$*v9hHWTOG7&zJEPL&%dLXP{V9+r zqAA|VnfBzCu%|5%T5gSrmfm!GPhZ%O>S%B23)iGtdpp=FKok{EMN@T~+IzUGjFk{S z)nAwTg+RBD0*dse=vwC!z{ZAE%Qmh!dDXJP8rO1nEqFUKzN7JUU&>Inj5^k^r>TZ( zee?7%?&;s4l*Mqw2eoqj;f-quP2C zN3~lA$H^Rba1>AVbA-;pdpL?$Y*@+i#LH-}Pz^;gEVs8Ob*_AtrFyr7YubBS+7cZI zjBFV0D~#&0HkIy-voWPu9JTWiivkx%?%4VB!*}%03M%K5$C7sid+$2?p&ci^_|!oQD8rKe zppv}W`gaDEyDtCjj$L;=vt!pIFYH+SAl@1;9sISXO%*2)XR69Zxk?CooXUlKT71&L zy~pS|^_Yv?TFmp-J}Mob=M<(#&h=qCckSCp9VYF1=mq3wuqh{AL;pLd6Y&;b5*)Yq zR@LYAy(;hGIM=TH-|HK({QC_lKi5is9RpPl*4U7~yBMyo;rtlRrS#YE9)I0^182IU zUBx>X$mIX8J+V?JH7xcaZMA#1no#=Fp0w9~{}>c_{EFM)fbnJc`cI|X@{3JFFu5hG z@@0}sXEdMD{AA;kjl=6RzKl`ulXypAuMpNOu`p*259;m=3`mOFuh6-F{x*N&j`I=o zf_}x0GcAbwKM6@N7jeEjw41p{Nv3ade-_7IaipR_O;otAeV_deF$}Pu<0d~H>9s*R zx*qHC?RVSg^bU^tjpew2a0mPlpL6n`@!#w_;QG_VpINCC@_(KVzC8I)M=!6^)o;<) z?C8_;$D!%^>!#Tl7T=qV=i~dM!aYAR+fF{-&~!zgk$%U~&TTxnJUaS#g^oUbpPtI` zGloiEo~d`R4}kRk_$^C!XgVX6VJ!DjlwaC{|ILRkYQKl?e)b046F+U5mgT=QZi45i z(?;S+i}?HanO519?#=Y%tCZpL-egNpdny_42;)gK|3s#JOEPTiO0=|ZZf}X}QPt`= z(N6AajrX9R_HL;T7u75PH4DS$zOc1Zs!UbY!s;4Sp=Vfy8jtbhPnune7_GAZj94x!CY)-Vrx3!aF zRK&W*#x)z88aCD?(mgBEsot(r66yBMeS>K(2)DPjx3q;&1Fb&Iyow~1P*=LWGoJ1X z=Xa$tnfB)BZi*bKQACWKD7~3Pt0)fn66t87pgG(2csfxXswzGb6{>Amr3_mWo7%T~EA zmCTSzOV3~#lzY4*lL|AvU0tbkPonjWB%BGUMc5KghKYElofXpb z#tEs8j?{KdiCWt;ExiyYm0S?Utz?<7lgbb^PSVYpM31jUA^L~&x3~ASr8I9A(QQVR zNWvm5u8N0Lhj7ZG>V=MmqqSzl*Phg2GxcbRcTk?LL|SZ@346Au!k&0$YoYV`{uq#P^KKRenhMAr?c|zbU&0R@d zkgj+}tVS@`H52L1_9T*k(D5EpO+ZZ;Fdn8;DbiD-bcVQ{4YK++b%OSIGjnJ0Y%-yu z(`43OgO#dHwzLtuPIV45CU(f1C~7PbHjy^w_SIjuG!te^xV^ojLrj!O#M8{EU?Pp?HCh#2z$l}r!5iHqsBGcR9DmMa|;9*}{t9Ba0<0=AZ9u6r5f_N2<#ea1uFynx<{kA&}J#u@r~uQD;ok5D5n;6A=VbG7RX^@TP>N zBB4hpgp(g7xM)soLnK#KO_Ee8BvI;MZgr|mU$Q5@qw4>+clNPaU3DD4Ps>xeZjs7Zf?WPXxx@8Mu@USNop1xM#-kh zWbQ2@+mgK)hzS{cVS}wwVLEUqgHk`=-+Auy+zY*?QFKe-dGbBaIrp4^{O#7P~kFCbwNg|E}GGlJ0;bWJI9{DT`X1I zn7*NL+42T|hJ?`!S-NXc#*EpTOj|{1s4&;Rsk*Ut$roEv%j(nB&1rvzGkU46&fd)W z-t66+Q>>-2x@mb`x}_oA=toXyG$|~fUs_t#y~@TOo#CNbSDG>CnJ2~Doyi1h&z~h3 zH2sJ=OgB{csXC_$c|J#AB7TRuJc!$h)^(@ZNGB&N<-L2NC>Tdl; zRyU$g^l-9SPB$9^=J-HFa?iXnZyIPmQyhWbQ3Y7xwdgRX|I6Alt(d58Kf}$_f1oQ@ zp6~x;`Z?5R){+*2EY3<~+T4X)&&Fvx^${pwMu;1i&9nyT;4!4_R296?uWro-pAJE$ zzqNA(>OHHNWtN<+`)WocFz!_kC3~?AbnfUwsE1;gFx~$gqK0{BAPFT~KHK^8X zK?lvK(w%{SI&)%MThBN=!>ek{+9kEAs&w`2a_e4*I@YbCB}b=UmSg9YDm%?czh4qC zagIPO%`LFRE&Y`h{c|h&ulkmit?pdW)uu;1xBL{wq%H$r0e6A#0L`+V4h~<=j9D;g zD*vRxG%#}-|8hVl=mML;!$32kUj&z5!RiE{3M>MjW>9nrr~t#^zdVt|Kf*chg%got z@5bgtibWEC4WAQVb>y7*#9+9#_{11*H1gO7!&OJ_AilQTDTVR}<`w1miS}E%8+XyE zjCCgx4AJV?oMFav7#2@hzC4(`1bPa zocP2T&xsU^B>t0oi?3jeHyWuRa!$C}6gS%Qjx6c;Lau{GcRLQheCmABbvm@I1xvw- zxvVAtZUeW2d%(S*kXN>vd4C0%4ywTt@H}_{{FE7sTfxKN5%BD_Zsz<^eoviv_sHOz zukPFX;&Z#6-1(aw+aDa*`jdfy`+v0QzJYtUe*e37ZM^N4^?lu4?b#Mc7A-hEGLkG> zXkintE0aZO3s+jW%EIe-i&8K5gOa7BX1l6&J9Z*?y8jfKnaN@0SB9aqd zTl_hZoDU=sX^{9t_^D05n;k&jd0lNfo?p}bfqghf|4X(4`b>jH4}tAK?vL+-ug&8< zD0l??8tewofT^EHpM!wl~~-)7;n7M`)N(lk=H zg?C%H+d`+Wj#~U3g{GyFMQ0HFWYH(ljNX-!%l|jshr>j;Kob!Y9!bP2#&|stpObCs zLcAt|K4735)Hj@bzU1)GeaQX~kk23DTd@gUu$fhlevB>O!vBW{nBD*)eZTm`dtvs7 zPed$3e6dK*7%zGxd00U7SD@{iKs1(P@gA@b1oW13t{iHMH$iJ4 z`pYq0&ghSVCxG}tPSSFqmGkSDK^qW{$hr6-umgx+4DqO2p z$sSo=obbkH<6ik>@3I|#ywcxsV8LiJR&Ir;ddZonNK~kbOWI3r9@#ar>ym9HJN?bc zvcl8qb%b*%H>c!gZyZiu?vt24kusFZe+ux`UwDVo{>QzxhK9;YUkOSDb$bWM!>Kak zeI4gX?Np$>2(<2IuQ@QgJxB8{nQL&w)Or|hADv*0%4^LVrBroa{KT|C8S8@t?G-q< zvO5;-tk%|At@8HKnx}GSl{>84Q`~0_Wvx}>_SGoosMZ$oIVJ~ltwydDN!%LQZVw~3 zPed!ZDHKeTS4C_c=WAtPx!BIPvnx11*hN+j>nahYeQ=j4)~ub0hoM%9b-Pddb`PJs z=z$bN>(LIEnrvxbCru5=OIW}YZM1N(lZn;{QEO|(X2%y%In?=1CY7&vo=3EAun(8C z8)wL!TI<}4mX2Gr4sHJG;s?3#%L!l3_|5@azv4@GuhHYW6Vjt;~N^kc1 zs&}+2%4_XH^js@J5+$u#{Un`ra8Gfp3D@-&lP5{F^3~pwYSGZgBT6geOM=6kBN_+t zDLMY8ae-UQC^)V)!n>(O`lJI|iKBezCVo-<8Lu2);o0oFbZ&k<8mNx%Y;~neUDj&fP3JG^HcWS*)xkSi9o$(r=LPFl3_p7shqRhBpmt7gB5Vfk+elsg z@TQM0abC0^ex33`(qCGpj{b*_Z*ib=ma&t|Vl+<`y@>{LtFv0DkJ$UVAeYbhe4c5lY z-EXk#k(b@pc(HxrKQ#1{#xMTSG4XqAex={(>q+h`>EFl$&5@A@9(?b}1K+&)zPpdz z-t7(cwf41}8x|e5JLn4hzt~^w_b0#3r*AMZ*Lr{7ym{n-Z@=l#0mp^*&#jH-_1E6l zc+}_qjc4kkQ7d;JvtemzzP)kxuF2W%j2?TaRvL}N(}Y&;yL)WoQ=i(rY|xqS3_9)p zf3=lUHnw|%=d|`Mw|W=$TAjuIpxay6yK`o6_F0D6|8af{m&YHb71)JYTXl@n>o2a< z{4n~N#$jfe`_BRP=Masr4d?SOuH2hb3PAYfe*WFZzyA~O7;Z;T?#(InUufltv~n0q zox1U?3ooqA{9)&8_s4H_{j# z)srJ<94&3gr}Ve~sK#SQoHEUH^QV0{MVb+SBhbGi4MR%`R-Nc?^+#WDt!eKOAnJcl z;OhuFx?%s~ZzChGj32AlRr8I;1vhYK9sh*$*H=B?e;>WduhsvqzdU|h{rzX9d0zef zC*Kh7*RIDkutDMP1Sqy{)#KyWbbYA%3E-hWjNEwnmGRfntH3)_Ctl-^N8azazUW)$ z{7k&(*O5jud}w~}Z-YKh5VB1AYqT1NMt^tJcNr@czvAD0{JWojUxT#Ge}&RqzrO0`ksB{t(|GEteT~Nn|YDNeyy?E?6CkI7N8mzcEhhcEIWp^b!7A=Y(IcY@8LS@iUD_#9tTA^_IVP zPvg{)&s)onY^2G(?hJqS@)tGET(z#Ti?NP1;ZwoDdsqvJNui39B zG>(nG-o4(R{oZ{%yW4&}G5B79-1o)M@5>v_k&oK1j~zMxk z@@l`1KH9HGJThEA3lH&k#Do6*$S?c#;g|aLs1N(^NBwr=je>i`+x`0^?(p9qd8c0= zb**2IeoNz51b6fo9sZa` z;roXi{)Er^_s1Oa>q&iY|D+rJ`{Ne(lC;WQaU;Fj+Ro?&UC;2$fI5u40=-2VbdAs8$hwIb)x$%GSaZHSb>#^Z_Zn&-w z*Dc|CO}M@wT>IY6ndkfUsgL#Rnyuc?nrZ*OHr$^KaFbv6`|JMLuV+1?@q428S)cRg z&iabqKl@L;pR@nTuTMKVT#paeZ4USJ8^ZP5e*YO^zMgTO-~ZVUHr}E3pZQ*=(=$Kn z_n-By#%FZ@S$`0&|K!(m&Is2|xPIB;&wbF_Klcazed>H~Z)&T5Uw^7!&wHz1&wsN2 ze*U`f{c<1Q`PcgQXK(cDh6TS~82IDDuESjz_-5n%-p(fYko0& z4}7`zL*DMSK`yU7+ke0IK)8M&T>sSJS^|^VLf)3)lbY_iqU8-Wc@FjX`hTxZB5b zW6(>#*m3xmo#y?#?CJjf4(=9=sZwdT(%dO$}yTbKj;rhqn`oI19>d9~o z_Tkk*ufO(0@8{Ml{rb9#!}Xhv54oPNO5eWzeSZI!16_VO=n0Io+3`0#%&%`83)inY z-QW0azy9jq`}Nn3@#~uco!|8P{{77t`SsVQ{P|yhgI|B+Wqy5Y(C2SI%lYB$XNT+0 z`R}(K=lI_CB>(=-hTD&K-s1P)8T9G9&h_8l75aa7)4$(-s>9tL+I#Q2oL=vJPq=iFx{{7A% zcOQJBKmWleg=?@MAACvp{@QT8FI+$8&wuD1|Nfyr@atVcpM3Z%|NSGc^7|jT&%fUt z=zsTmr|;btyFc>LXE}X78oq!0bN>C~U-94XS@G*9r~Ue=Q~i2xkc)e-_wS$nOTYg1 zI=_DAig5jeK+1QYV`jWl1!oR-5JGoH6|%q0cPwFS&e3Yb?GFkdWSey@P} zGw#&ng19Xk*D?Q4wDZq7%(18BFvp%*!2Ci1GgH9y3z+K*nEMKtuM{xf&S8#QmBSE` zjy6W&=ey&45u0XXCrWjm|8Rsk{-n@y;)LU$P{2H;fO%#CGgZKddnI4PzP1-IJAsk* zOB{9lLV!tJcl-?n%*#W|NlP3bIegfTbW}}~9RG=;o$ux_k0$q7$LG->C}8f+VTkp! zk)E(2AL$8K7BJ5%V5Adj6g#0?z`UU7T_df{J2{4I6eoNkr|JoRl*62OLJo7{;|rKq z7cjq3!2APuYLq{*kgvzwp11Ru59aMW=B@(f-W=wn0_T&?C}8^Bsp$lAEg5}Ix`jJ6 zoKGt3&PhMa@p&wCuXD>|R~IlR7BIIIFuzj36!QL9S?ZdkJg%9y^SHGIOs{}>Ne*-J zQNiE%a?}YY%QDvbI{C7^os;(#Fn?UY{AB_2?>P($)LCDTe^>!CR>1sn0aNhd7PEo6exTU9@SoUqS@ty-w})7SE!5n_jTbJdTH z)6dCa&Oj=yuiuX_XFRHaiTXMD;b%Otfcd#F_90BaN(axI-nD^!|WVtgw z9DiDXN&GYZOva`Lr=JKMQt8WQInf#M{T$A!eYxG%H*uix%K25y3uF$>fqFfAN{yy((UD?;awn}hXa6d9G=ulXme2n60_INxhDn-O>GAx=@J?Y1o*wU)y`THC0_MS-hOApZ-2%G-(Y zPLhi$>BAb&PZiPM)O7_+G4`oq>{I`dybKV#8cFsROhdEyw zsWvWF`7-*j-j~B%&Yhb6VGS^Yx!@6bUl&B%o#g$3jRnll=j}ZE*c|5B(JrTUp1rw% z5r(yKJ^Nb)OcCp`a_MrK=6ypEgRq*Jjh%JPtgnso=W2F&W3=xHXI4QoI&XX+Z-<%lr z+1Odr&1ksgt2sVf{wBwH%XbTy@8#`WByUh7P4UG=7Zxy|%x&&PpUPoaUC!p>;@>Rp zJXk#S_uQ#z8&;pQk!~$GeCwkNm~%p3i8HruE?}Z(o;YEvBH!99Z{45cytP-r+*H84 zD(~w#Rw0KEnechelM0xkujee~eLd&KysziHtbmD`oHQ<0=rbC!R-e(CRr?%fTTa7E ziU{$NA`5!S3yXGMU$j$1^p|`-AJ-*+NjtT zXxpL&Nb|L=@Rql|q-f_AMPGLmFdr{q{vsdyc6n&Ev2TB50dq_N^OOQ+Jnw7!g*iUk z3(so%r3Fk8O>BQd0rP>puN_5SI|?4#QS`OrxkWqg&BwLlL;2Wu+*iO9KHH8z$hFpv zujPGFdy>foRVW$%?7S@>`_4NHm@gMF(#AClyYt%x%#U)IT}S3HyAr`<2}Dszwgt6|2v1dtnfE3E8d&&-p%N_{>GO)!isu!P z-Sf`ONBX>{746IxFok#eyh0y7?~c5ktDls&b9FKHs~2^n3K+!>HEy})zZEclm*afRcXF7$$K^143;j$zUls-IEmphseyM=@{i3fwEMN+a zM9pC4bzfWX&$UJ7?b>hTeO)WPTBFakf0e_u3Lm?*sep;LJ898YF<;Y#4>0}Qyq)P7 zO{8|F_ZKj?bEl@&sf5hrV*2-U8crAXYr4?t)Bm2gGgGWC%}f+9+w;C=3jdiJ&1}A? z*3598DONOQ{yB%4U7Pnc`-}o+z@6Hh&K@dYqW(#Ao|S&CY0=rgE!z2Z4%03&rR|*s z%$+&T?P9*#pDtkTFWQM-LBhFR&~WaQyq&qz^LD6<&G?53*=+1{Zzh9h5nf<#x*C(*XCm1T*Mj!B)iQVs(*?}$=Hpr@?9SqAbC|_n%iCFutAU9=i@#aGysv1dh-IiF&*Yto z@@!n)_vGz#3*V;u;R5Cpc{@wT<}gc-DPW4ZSbA~+GsT@6&o33;`_k_eeSIZwr}yhQ zOs~*my=a>foqGk3_3z2s>HkjNSHG|+{r{1}42rQ2im?yY=Y0(>EZQmb^We4u=F>$x zpUYvEU!KD(D<-Px-sN8@VBVa=96XT294!3jgTI~oy$3&&w{s}w2Gd*|Ds1YiH$d?uZXl1hi7{#)`axI?VTrc62^LO>bOZU^3o!XyCGJpB>B2w zQ{K)E(>V=qDCYEr!ZzLT)}o#F7wr_b>4yJV!2EOG4*QNWpXA0T0VA$Ub-6djc~5@b zjmnDDVV+sEb3@TrVNY-TPyrM3*olTWGGBH5!yc$i2H6dj!Mwcie_p;^z!dq+m*1Sj zu&*kk&nxDDsg3;=F^8Y%^9qf<4ijzV5T=+@_H1S2V)s@yu2+69pVL zqxj1I$lJN;h`g_x9#Oy?SHP^}jz*d?Z#Nb8^rjsJOc9&k)DJL;>u!2kPWhYUYt^WF z({B_o;;1^zy#-9n+YI}P*^D$h?1RfFfAhMW8aJO?z!cua&6^9DONw@`E?}-JU<&X3 z=E!wPQf~gmqMe(Ic3xM&6e|cf7u@nHorF-cu&+8gZ-*U&8TYbxFry*62Qz76|6qPc zTD>-dw?t~B**FL&{IWh0+wQF*iTZyge9>}ei6)=S*x>d1o&C|Q}Z}YL=`kfr+ zb-$d$ysq$IU-#Jp=68#Blr5}f-q`DjPC~bQEm~@JeP$T4?=#~cc7SFuZz%NG8;&Vp zKEj>a48Ea=zupkFM3T5S{7v4@8;cn2jl~SUQ9M@b>y0lj+WBg@lYEjlHN!}gZ}X-z z3z)*@vY*wdF>EK+Zw%Xs79_#2`_(c0tw{MdZ_V3z^NS0Z8*`YqM9QbW-f~I-Bik)% zq`uw~vj+*Ew_yzm#+M z+uoM9!(QPmCVKnN6)>A}P5btpIShM?Gf82WaW<~oV&*OJ>TUAbYSMjMf%9#Jb-3*} z^Kso)$lz_?pye7r-}b+XzJ64+Q&^dI6#3qFY|qV$;P?MD|d&0OMcFF2eX z^4Xl;Uc_IwZz)Ai(cU_X9lci#KO;?9rr-ru*HJ2gppUtx*f zS5(Ek?=3|;QJRuR#Qy#apZ7nfxU(&9=ly>fVA5Q?znFJU2Jn^>%m<#8xATEc0n;sD zzLDd@83P$V-|;B!)aY|ZVLk6Cvif(NQ?wH!yF?$(FUb2UvfpY@g9iR7g7gAZDox9E~U<%H>3rke@ zgzqZs#fNXt+xf7vd^JwsFt1DsK2qTPk+A~iF-1GC3NVTCAGt4w;jD|yPvF!G$0zN0 z`shSxC+&**X!M$fFrr4yqvo`Xyq#@DJG%;)$Q#4H?$2R9c52?v$D*}L_VLowT4)ckq zX;WXHh_wf4?4M9}w}#I>&Agp^PAy>86fo-wn7E@b_4UakbC^$F6XfFk(Zl~_wB`xt zPu`XH^~ulV?R+Z6@2Rg(DL+;l*Qef?xAUpr%wg`G&GEUnpbuxaWb?%-E?HmqMy;Ok zxmS^04WE1eG{@)O=&z=+-y7GmQ#+rg?|M6*es^UOSIXJj6KjE>rT!i% zn_9FJ&Z(tVMt@^E)wXEok@j1I)ocAdN@v>^Fh1r6tF!t$S|{ADx-^@MKnGS{^>>WH zTnkK`A=ss2thm>i!I9ER9He~-~wyQ>y6oKJKZykY&F zWH33;KgMD34D|O{oyuFZbCSbgt@ZafgUQ=*TpRb>s(#~So!?uGE65{yL4S`on0#C( z+iwldF6Qru1}9AaP}fx>d}77_VI!;7jWmC78scykC!9Bb0ADD9<_cl1U+y{pkU^}C}x_;eTY zcEPIG@agM~#>DTfx`j{QZ8X+gj>>5M09@8xKKe;Mfy>j69)0sjlUtk*D@=cg%uKy^ z)lGZ?EB11p!6$Gz|MFE=@d@fZ`$MA(e0p7@vGMVvpW)M+8jUS~X3yTiO9cLGfBJf(anpxJ|Al*h(rDcBF8lSr zHyXFTYt?Ps`*x%8%bQl|iDskmhE4YCcN>j2ZPHx+_@5h%w`?B$CZB%TXuR$8(eLmH zn!fV{!ToEa(Rj}Zqkqe%BN~nO{kwf)lz0BM{W{)geE6?d{T;u8{YSrQ_s(iG?)mEI zKXUIGjmD=xJ^CX)ox|DEAG2S7uF<&vW9s)`8RZv0K6*c&t`uJlU#_sy+_JnlGte6V z#>O{w+x=!|(7d$Wnx9{3Ufep^ZVtN5={6_*w+4Lg%|3f#Z0lTerMuib#Cr@l{+}0G z%yehl%|pD^ptIN<=#>DQc5i657Y}xN-Nl9W;$V&L_S(%(zu9Wew|e{9&Bf(~>2|N# zoog=J+b~v|GxM!}pY8|hX{NQ!_gd5Q?PhCnwz<%y z(WPE@c9{VjY)|Ta1pRhsk@ssfTl}sTXtmp1=BLFj%?<|id}x1XW`A?3)f)&2!&rlw zr=2FlSle8hU*5-u1zMkPuW4@Fy?gtb=Jrjy*ECza38XXA63uMrYZ%iC z&Z7D<0`W|9V{^LIr@PtKpw%3#EHM^Po)t;-^V0G(Lw9m@7NO%@i{VZ-ceiJ{i?fE# zu>Ga^)?kh|lQdh?{XwtgOxENMO?jW1YRyq+fp@EjQ`B>3ZVqBD4q!ki0+m)ojMx~R z87~@EkZYk0tL)s}JhyqU-Rm#+_4!I6V&oUj{v*V0Ee@O|j0I_ambrlU;fh16nqxb< zu(NR=PZeym*d4^t)2rH@S?0Yf3+-MQwT(k0;T1N`{q6ZB&@ql=*4x*0`po4_yV(b? z`B_QSf%ej%IoInhcw-104~SpXc6V;BGt;4=4ZF6|$_6;0*90W=g?RkYz!(}}=)1Ub zs0B0hyRh{Nje=RPWuxI&31;(Pr+vs;-`8um7u#5=ksjRNA1wFU{bxs!)))>kk?o#H zzQ212WDr_ONoQsmvNd`6&9Wv+vfS=+W`CLg3@pHJNq;zys-q<6Q7!_^_$Zx^wjGf(pcN65t}ox*9cG-y*4Bg z8_q9B<8~v?R&R7_<8Ds)EdJBx6gjl>b{9~RTe<}RO)wT^=(GU-&aQGI6~BuplywK6#- z=3fAF7zF#$Uuw^E5akMgH9Nt4cKZ7@LHnTr_RItsE!(QFlISsLUpH`(3aUdC^~N>Y zA>TSJ#jBwy+U{$j+!i?Z_u5OmYD?qj!%6(Oyl8e+oF?XA4tTnW_JA&Ck<7F;yUT7S z2_b*-)Td51Hy>-JHu{h3~88Udef&!b5W$uegUnz*CgcUn@@zVb@Huvgk86h8|Ymzwgt>%v z!^Q34H}bq3WPUv$YTyGfL&yPCU1%~gx|Bb(Yo52bHFq-YoAA3Zr|_Psgcavw*`ejd zK}XVzo3kIox<w1avvT`1--b62or@@j*2mp>rYQe_|Od7+D>$eWk@*I9%u zoRuVc=I~B7jmtFS_}Bxu+SHM0AyF0{6K2-BNr(KUd2><&GnmIE8ukY(3RQeol5TRs zm@XKf@1O?Tll$Nk*Yy($29W;e!xoF}LrJ4mw1nv>7gM6OMWz}Fa?9L0*y_w%e1yL9 z*|DLv;3vH$aI(3rJ@})3VnSxCGI~T^-oKHdIqq0NsJ)vu?AZWb@R-J{fkj>Kyc0nC z{ROe_gh53Jk<_iCJUbWBBuC6o6%H2eEy%-wLRc-i|LPEu5es7(cZH)tPnJHEx{gNh&~1)DVu%BvzKjAE3e}n>%B4ye4%PTsCzP z(3GZQ^7tWm%9;pMq4bu7D*91!A<;VcP4n{|+zqC9a?E5P2$;DHQQACm)?kfJ=x4>+ z6`f%!Lqk#%dpGXfv1jv@drUx}S3PhS)N+3rChRXS$<{W<`^)%%=)^c@Nd>kCGm{gT z8<+X0yKoS~lQIe^e1eJP!&od8p9t*l%Fv}S{4_PSVKC^~kcxq{WLfs1lB%QGyJ63s zOSfKl*`CeKwnyPHm(z*}PFhSS#@>gs!-X6QzTGmeQGZ?@zQWj6bXOHv^(~}l9%gak z6uF6o{9&a@2F^LALlr@E;Vo0XIB9c;*W}oxZF*=Qlw8CyYh2c8e=OYUyLn_-v?xo_ zMy}=61(h4@BRq*0h7Ye6@e=~ohl2>wodQBrR{>(D1#Od{eV!DXU;u}*Oi>4107kCUKHyl5cjNZOsa!Au^ zvSvvS4>88&YY}5~7bjc~p>Eyn$2Uujb{B9A)MAXvL59SjU z432dh_tH{lV+FHpT^x-6XE_9N%K)u0k!xPx?#YR>0L>WzgQ?6Q@ zmsaSC>9$9d-DM=mbTG%$+{Xcy4j6VO5;-d+7o?vOVhc$*4u=7uggp7pwQ}fV2+If% zdi-S>>k#)de=^EJ+f}i^wZK@;%D1?pHGe=kxA81god`a!LNJSCqlb#sVsl(8DU9ZpO5DDmn-xV+td-5c0rj)YGQ5%06_XvDrIs)pbc`yejETyXx`x(1V zO3y7$;+^qICsR|~AxsY{T_!)wTnauIV$chY2I*;>&=oh_OBw^&SH{KAl@~G^YW7iQ z?fJRMv5Vo1`L=63l)HYi5qoZg!N?hDy#TeBoB-4mY3`6!i;*9bI^Evinx6}3sTF+Q zJ(eR#jp5icPs#nKacO;5#}{wdv1!|8dxYf$^QW;XaHb5ojHVtYoGl zd890)F3|L(BuPi3%dsUiwv3n|Tps>JJ0mr*yx0-LgwB`I)@N z5Qd8HuWC9g@L4GiY+q>4jj*)0cO$yO9deEQNv0j0WKY9y0JfS+2>CFR+iLQ<#@LA` z16czRyeC-(<|-&wk<(E%GA6s2#6pwG8^XsnD943vQl#oDRm`1t9%(FGrL&Y#=t(MB zuN%mHm9n~ zZa_Vytr@kp5@LT*@`6^7_B)3$Imv0ugMs?e%6V^Nj+P=-p#96J#; zw?jtIf*ETDw1&Oe-|2~?4V5*`155{mL=3j09axemyEFA4I0e-5j@Kxn9Q3**$cEwp z9CG2fxWgzMr8G>(HOD>Y#QcZ&2h|@ zj5LW4_f$Q9Ne&K$)g>lC1(`c&__C^&gc^@x$f1YlR;D`e5j->z<3D3Ig?(!k1tE51 z;U&!)$|;zrrDl0=~@9M1Vp6X z%!5jlaOu)Qqh-sj{sFGk(sYkj6`k(Ux*^l0Cw&CiIt5FX4rj`Ip#>BJ#>S!|X=no5 z-=Vy~{Oe#lgrK=Tb3HQUWb_ZX!i`~(8xeyTQo*gZlxo`-p(H-7<^$Mb)cQaf-vZC}B`i#ZRnb|obr{uUi=FF!+NgpoU$$fGm1{l4*=LY|98p9}WpLv8u#Q%~r&6uU_aSu`~5g6CpaScYL0S4Hb!6zXS zWVMYP94!%bn6D_2QgFgL7)8s&=DV+%(Yl9TlE@N6LV0; zW%Y9mkw@^_K&3x`TprdiqS{i9Er)D0a@g7&@;Ss~v(WHa86s2lB)xN|nGva`T@g3F z+iI1F8hAT}gBGf3{KjZ$u*UiuC&xxmChMd~E^HA+Fx_Y*mj8`NzDTDcx5NxE%z(8{ zbs0Pq^}OIE1E!$F69lYga3Knmlb$h>RwTi@=TTEtf(w;tVw6;twwY8UnGdjM!6w+9 zCTrL@)&qU-`AVm>U6{8{e`@ShR$u3rxpy9AZOc?SuB@w!iQ9}YRHpV-%wYlsTP{$Py6P4ari!?^h`Cuuj*`_H>bE%W zF@YOxM5vHZI1-oc)b8G$mq;pOL(Z#lbVDo7yoI3)T2j-Rp6-$LH^0cHHW+L}mh@LJ zu+wdEDhUr(EM}*g8#a;#+s41$yVf)}@d2^ivumgwA~OwjjVWN1!+6b8ny9!#;Dbn} z9#iTJx2o@p%N9crYm;#|sz(}yVUz8k{06C!Ofj~Qe0JH3yyK#olDp2O!F1z8T3$1f z$inLIr?9}GQNJB)a}hE44UCcC|8r7OWP^jf9iEQ$!$+1nIWo~ZkVju80 z8ay zIZ?y8>-f)=%{i(@R0TO?m*6tunfk))#w{0O6KF+Q<11YYZ`p3%uH8EKFk!Z7OU5ly zQUK{?f0kKI3M!f(Em@h4^FiY*n--AXwBn7J$1$ZDGq^LYrPj153pJxB4X+R?){2+C z8B-xBR_e)ol@q-mDww1`oxXul6N)ATB5a1EXMC`r)~YX)({>o9DCr)DMz6fV^Sjfo z1Gd|AY_r+*kQAm0ftYK6=t3tVpciN?AECaRD-b4FeTLvSV8QfRs=zXc!9kTdaX%xv ztR-4gQ)=504XH0VqaqQEq3Fucj}Re0V@Otpf?3xfVY(hcxV@g0~z?_0|I~W zAsY80FZe<(t|+UzEA-2N}ZOtkQ2mI++LIpXl`T`10 zQl+V^`b`tK%?1;Q;zKsdK@S?SJYse2+G_5UE`Pu|@xdsEWCz?$*RqBsCY5j`OHGx5 zJ;XDi^h!l-2b#~9dPzTf>y)7P_Jpa=ydoFG z+o}mc#sl8S`_hBz%AcAV^R)Z+m5Utgg-tx2=8MO6W5#x<`SapW7vS?a(0cQR;${^|9vO+&y6vP3T%%pg?Q-q=GKQZ3gF zT?p=U=UI@}qNdgJu65Q_^2!)inzwrx=Bf%wa`97sKB#N!G%_Rj!t^RFP<(>7XmvT% z1zGKn`xd_VE-g+~_ySvHG#j?5K~ytw3&jdA92Bo-Ks}4+-U8P5RYwWR=y3_ zp;*v$lR#n!QF9H=8n_p|pk-L^hRWJRBgT==#5hrl9*S#q!xB`L(uiT}j8pDiQriwX zr=l>NQPhNmCzv+s>PcSJPz)rCITXyy43<+!B#dcy2J3EqFGKro}&G355Og*txB_fN&l6};_7iSD7O zYmp>1tKBYI66YlpUX87;@Ce3UrDZbpCOhLem+gu5W8iGYS(FHUZ*T8h+=M{yAD@U0 zGi3!ZHjdFO2^3j6=7T&;=XzsDxsEb>E|gcfBg`D7ZC{n2&GywM#pY7X>Y1c|o4pFk zA4XD&tZfOB?^`3`aZ_h0nrL-vIu}s_vHA8;%|UpvzIdS8zk8}^zqF3X$fS*GNR3;u zJN`71(oAZA;s!Fp(&buZ*PN%8F+Io_h3#~!s6;=)FGAkAn)uJzHf40lo%Oo&)|8}1 zMe+0GUag>83RQwGjT&jAl)URJjhYx(II@mx&WMI^piMaiod+7Y&nXOm@53;9Sc?U= z5r+MfYEILy3_E+~LLJx)dDWN$v7C+TZqMBs%Fg|=kOP}{P?4FF6Sbfc*|7D8U5~DN z;T77i4n^PHhR{fkvBy1%;fZczVYfL+TD{lUMcE{oOfc!pG!eMXVNEnt6Nv!sJ^Qml zGd&z@sNEnd3X8TZ2$jSnNfe0zSDw!4?C(CKdc)B&r#GgijSWaD!L?V(!<{BsSuKf@ z4GiUECWrbxxy{fSM^80BL{)_BsBN|kwNT=r@<-V&?I?TDm%{>sX@H(l>$Ac~s$?@z;061sZhqA;|5q~ z!%TU4+c%;?c&S&Ktx!{08v!xPLMU78ELvHN>?F!Tw%EvOyRf2Srp!csXg(@oI1JD8 zUtQa%L6zhk>>yMU!nnJ8%7ieIj@j~MT2!n0N4Ya&FteW5LV;M+(XiVV%q%ZfO6#;m z7{O-zHijrU_8|HKnP$hIT2!PS3`W!q^5~=`q+~QjaTAR=nrRPp82UIK7TWMjYmbE7 z2R)#Ig+R=g`DPel9vrcdtYvD$4#XJs>8X&hh*Yr=`*U&e&MO2b$Ld_5nFxaf{mLR~ z#aFJTXr+7+4-a)z7zkBTr>6QKgLa52cWP0TB@R7hPbG5f&$;cX6Y3UNMLdzj+D!eZ17@Z*lM?Lni#vn zYw+T7Y%D?YZFh@p`LG-&AiIajwNzdx3^pZ`68x?=y&}AQUCS$cZT&&qCATLgs1(zi zClKqNtL;@3_1ZoH_ZiRJ@&vpoZeYvidIjXR!nBr@gLd396$_rRPDVO_lOtK|AEH&y zdfGlGXL!}{X{}t#6~6JrlFz<>)>6d7wOMOynC1$y=1UcFbd;!wN|Z7t~P;MtbP>*Df%@*qp5H-L@*T2d&7ixSVWaeBcf5sL!p(A8iCcV z80)!DD0pGh=v4TnAGEJ#aibnCxB=7C1G3&Il z9b`gldTo?BhkeB9hbNVEjyn{JXIOG)cL>k1WJ=`@O5N_H2cjoiJlLI|4Lj1=6xBYo z(b{R!P$Y(2mxF{G@Rpj57}#=bkS?P{sAe=EC#|W@*i4$~m_rElLKY9>b|RhxOO_%- z6l>EvH5J;ctPF(pptQ>@K!9uPP?bNDr0%p-e;}lBElD)hze4>`2*N7))YNoqcCSx= zDy*0s+a0UZHY5SF{I2aaB`yuy9YPwKyhDr8oo?DLnPE@vHES1@o+2lpkTpu< zu!3*6{=uWZYKAJO#wzfq^^1}A*YI&5aJixpByKT+?lK_R#&6#Tef7TJ*J?vd8TE@&#zD6 z;b&*k_~bl`Wl2l>>V0+QAL21-nsIf*Gbp%}&@zp0)p=toUDz3d2HA!hLxsIKfM^@9 zJ9V0A?gk*6a z?Ak$ht@nd{h&(hgMnles3fkMf1*^FXgAFl;JI%iRM&><;2~Vnff7+Ymy)Z8j>8XEq zBNM5SI`pj}_<#zssSt%L0-nj9<4RdfV(e~}`YP<$yTqnV>7a~>Hq>vdZ5@(}1P7@I zK{{SI?%uP_c0yPqvc}PaU1N$2A+=WNX4fDU7-^B0OjhFOiZ9<8Ou6#&CrAZFOLBqw zqml82l?{=|#t^|SU9QcE6Jw^cd+>o0;(Ef*QL$gqvhwBP^ku)UA>Wi*W(VPZEwId* zQ%$$5_YpxVQeotl3RTX~_`-c!(@2`c*m=;$wg{8-YOKlF#7ChAKLJrB2n`fn2Dj3V)%WlWB+PsWo6e!vA{-h$HhGrtW3#PC}W(Z z!@HEub54ak?irzop^;E$>9Ady)}Uibj4f9}aZE_8!%>N$WfS3H&*BLw*lW<0$LTx# z#<5w{750rrvY#o!69@s{a7!WE6e1yQJ(4e8fEDDhvk1xzCn+j1?Zq-&p|E`TJywxL z6SmOWM>g1u1u;ikXUoY_{giPe>w+G!RqmjihH7L?+Q~MvF+}RfEkr>b=tL@wV@W$% zkTnaO=%rojR%s9hrjr*`IVr`DA=YkBn{zphHhZW9b_~eFkE}dQ3`^Ym@|bMO z5qirizCn~_U z)Ue7rlrHA1Ke);pjhZ^G4X$mMw+US`Ao*1wivLwMTPli6vrZDqF3w*w@Qfr_65+&Jt4<9A+!E zf>%gk?Nfdv88%Isl2hgt4YY90NjXx_UY(V^uCQ4x+F@TP^qoEP?Ztf@xe*nUrqp&L zkNY;S=()*= z$IYHvLftaZD83Hay0KlI0mp*P_v1NsqOpzNqU@Lmu&E?;$re7LqMYQ4QLa2|9-14v zm|Zu+r4uJ*e^CuVqBIB6IOh90ADX@KW2AED78XXXrCUuY+A4q+A3WM&`CrzV8zdO{ zq{W7PI@e@Ds|zs1+Cic?EekfH)JmC4YGiM5}AmB%j_bqn|5!&%8?}Lwb$bAx=ZML zgV|+n>-r`I&?Hr3Au25821TU9Y^us<4}+=~NA2p)h67Ao9SH;NDN1E(w1lgy8M5;) z-Trohk~DmEK%phbj7{A{B#M)h7aynG3!zw8ur}Qr;6wyiN@0jT%BQh`=`q%Pk}soK zmb$Tio$o5kD~a9N?k^6t`arc;F^)q=lF(j6v}FW4&Li#woNM*>1IB@P7(HKBv*RF@ z>to4QNl(0G*6A^Hu&E(xElp{?q?+g(I^pIru$p9bD42a_>>(sH`f}h5hH8A0eSW4t zVYux4Sc_hnt=6oi`q-^4qejat#qp#HW;YJE%Ngkm-Qlc+=;b5i{cs=2%=QJ2IW4PT0{5sU*n!q*xyd z5LR^w-8lrpf(r}iEC-xZCkzoKLcj36DjGQyF`nWgOO`B>vp>@ZcSC3v`rz%5jsS18 zp_UoYzbRVOPK+cOK04T^QZ;LZVvs^2)!DbKq+!${BF zKHeH+!A;SBwL-fn31A7AWU;n73gcp+u3x8DSd??mJQ!`Iqb#go!%h?ci$9?F3=xGQ zY1teMCkGCbm#`{yOUY0G05SW6^<#bNDfd!xVQ$6nwizp5AC|Bq1iOQ{wc=o%;iUz& zMgUVpez4VD6|kYc0%0oL0Z-I7NXUKn*4A*`su;l9aHyv%CnG;@T7UoY97%Y*LqB(riE-=69o1myIN#bfF4O6-Nsv(; z%&|7sBFR_71cV946VR%SSV{=6)<$LaNA&V5TQZ5kiC#jMme6k#@T&G@_7+44 zSyG#{u<1LRADG@5OGgOE0mJB&U}#i_vq)0?aOzh4F9hAC^}xc4E6h0# zm_(1gZe61}v(bvHhvv@&bli*z$wsMUx3wNo)%|XirWWYKh?od*vB{+u8p0vcCYH>^ zrYlm&(1OcDo>sV0o4E|>yeEnv87jFx61bozMN+taGODe7Km3nMk`ZCKyF1cyc- z!>j#O^mU=!x$}*`&z=k}00~^7YZ{8fiET80x&L&+RoZJGX%VcZ zYdy^|6HnCw(XI&*npdY_V{}CoDOaWTXwhoi(a8P%)LGdniTiBpY7OZySo1R_66NM~zATE5G}ivklCMQqxlk!r7_m~B;0|IqQwMdeTFh$dk6E=L9h6J#|r?CvP zdrksVqq2qTD=AAUZms&6YVZjz+$r2G2uOme;^d8EVlCUGAa5cNIUG8H^2YE7Et$}< z+%>E$lRIx`7Q;;)N*PR%T}r}h&=!Bj%tF+>=4xg(qw0*&H|6$r#)u>!AvKIV-Q|ky zS;oR-cGxG1-_p$tUFSQgOH^4r>Qr7>wl5){&Ezn!x_$_|Y3cRK? zrj$H0z`%!L0G%sC*X_BaR`7DOP}l45KJ zEyChr4E@kb9lQ|cH|`RU;&l(jRE#J7kcpskU?Jr2jS}*34xxf4laJ&~B;Io$MUFBW zO7A5xbZJ5>RobBi!aPOaD{_}Y&P8EEk5?#!V`dJ=4aUW(Q!9IrQ-u3B!^%hu$YfH; z{<1d3_$-)om<3ydP<{%3Jf49?6+hx8T35(xPPfli;*^w#hf{p(qY-LRMvf*}iUf1& zPdLUf879*LkfE|!hG8jxYiSdaKQYy0Q&pcKDH5D3{T!i()Qtpa7N>BT$6GcL{DWZ& z9!)w`QlitC1{qQEuJrS4c*)~3W_O*Gw5lapIp?X}+=cBNj9rLVSQ99FD5JDAMHyc2 zq|sUF2~U)#uaGi~4)2cyZ6#`hrR2^BP zflHG!Fx(aU1@=KVGxv(E~oEUQ%(;lg5SMZe)4E?WA=@T6worNnO+?;T{ z7PE5w{RoBfnYdx;y#Ne`ck1MiXKs9KAwH@z&3JIkX@b))$4%WS*3gO0(Qh)2^dnku z{Um%&C|1W;#&*U-O?=|2dGIh{ddfCV3^a(vVX0&EjHPA*-eM(c!hOxd3obkdq2(+DlLDTwFCaM9${KsP40#}* zy^2T;##J|ToF&92$HJL;TI#l%Yq%YP>li?s*m11JX7ja-Qbcx2Eieqh1l!;H9x4Eg`6f*4jSiFdlbkF+4MRb4F0( z_Uez!w`5)aylU4MNF{FT9$LE%B{kpNZi}+b%Pb8}Iht8D+!*D>4|nj2i7Zozst>ty zZ8Xs=vnA2CCRw!FYaI&Vnjh!}k&upg$jsEGIxQPw$9a z;}Ss*^YdC4*=l*ycBHg(rJ{73Vat%Cl0liIlqLMcgqH6P=O3739wk|Oi26c9lN%nvtOvDr$w^7Lw*Ns>VD7q56 z;mGT3&p1kTpv)fyaeUH#>e0&=$WW<3^_25 zp%Com$AsHCU4B<33!!&iQv0E_5_CVy5hxEdlx@Me(2EN-ZDMmtfNvlbb7;c~ zVdw&x=y-gJ?R67XJY~$mGQK?M=qagxRXVkCSP+BSAF{gHPTM_Y;WkERvU#~5v8w5y zVdJM(k2UV$lA?3WxW~XzyOM(DoVU0JCvGr)_6(e-h;3RGdNW3nHsZQ)=(QDIw`UO@ zD}M;5OdEEgvj8Fe&Ay-=Y3(4)cc^8w9M>G|$?*Zap-r8D2;^f&v>(V_%RfAT-H=IC zACvJ7O{hsLt$v95gv3R9hjb zZv0J>Y!#k!Dec97(;W%1A!u-N4^pfl?E3Ox97vvOM+xs#ffVj&Szn>3xays# z2cj3{T6K`J>p)xhq_eoU0BWO;AOdq3@w>>Pw;I1&AI6@V>!ug#a;T`b$(oYZR1T>+ zq!Aih`;@dn9OKHvVRQ#|{Pw?b5-~wsFfbuih7;y*x1dkG5i)qABGH1065}F4WG<~` z?oiLecXOE{tc+!Y(uZrBVer1$r;~mj#!Wk&2F=Sy(M{*)nRf?^c+jN90qhcpkaZ zS8TMnULs~J3Y(;7m~f3+xM@*MIzrob$%%ossKq6mb)6#1~gWnJe-72=BHLGoZG85=Iiu75`z&#fBu1(B= zWgw3h0q^)o~6(?#ID_GIOTfp(B_&RG^sKn#qw(3WxOS2DnC=4Ch-RF0qN? z4pKqVRGzcwkujB!B6%ULuM{5}u5?-oSwTMr#AupKIXe-%ilD@*EaSzA^Qgk#7yVtgRkj&iqTSEptS?rlW3B_l(((U z(-uSYt1mOjfGs2cH(1#uTmzF7KSPe_Kpm|kQe=NEXuS8GS z32!?{!kPLJ73mwdEQwY&8mEbKk6Ho+Egp%HnbFWC#I#N=CJU+EovC)tz3)T*I*!9^ zPE)f1C8j$b?`k27m_ZLhII@LyZlh=@T7n12DF| z_13gmFt*01VX)~`DmQ}mlO7)LPnaN@LN`BB;-FSSRC$F_InB2vV3mA^AEjtxV!*{R zK6^+WIkU}P4Ag?X&y!lc-9{n|u&wxw!QGmuwA^peh@l6&OYiZH;1HrjQo0F?0U0D6 z($3}}h8E-#^s>sz+yNW6oe~>W_Lti}Z_S3k@EeSzg(U@XFs79lYb8|Baj+z7I@T1Q2+~skY*V@Ooh5CxlmWa zja5T0WtK4GOfX{PDU8%#{I+SsMHY1pLjm-*WQ3Q1(MX_OL@?rK4u-y%Rk0O4nP-mp zr~X?p4^(tRA?9}(MlQAd4hg1+=K?LGd9~23c_tx1nm_Q@=updgKen`vB!K^f7YVpd z#P8Q4R3$brVMvN`7zNID0W~C%SjjME_R|8g>Jw05y6+Om_;p&b>7J`_*h{*{E&Zdps?AB- z)WuMu8lE6EZylu5cxaUVSbN=RY0>(2sr6%iXixJ@TIazP(#ifnD#+u9Z5He9oZFMZ zOnMNkbrpVc8iGrGHdWVTIVL_D06^VsWK8QsF51{3W!3z0NdKQ;R@33ZJIz-c_2uJU< z^w-Tq4zd|0y-4E9Ojy{g9o!(9ThEQMfykWUs7GvDx8BvfOsfnTnp1e{vN+2IBPq`0 zM4=6%t|XJHB^rW(x>}c?7gA?t=uH5}w(i>4yp&gKdr_iF`pA?l_Vr@Dh@qT#ZNbpy zbfig7kl|&^B^bHoavcat=*b7vzvX0?mmUNrv}O`*q5(Z1s-fV^2vJp-4w&m)=g6BH z)G5+4ZE~(=P|O2Cw5df5r71>mX?zjQnsgDuO?DSW3kQ|c43G#N;2@tIjy5|L6dorh zkflT!qKbtOYfQ0FvxW)BdyegNuGJ$#OwYil!M{?wL!%7q)R`M1i9i;s1@cvlL7chytpJl+M!lH$_R;|g@q^PRC=Vs!$LR75N8Fo$hqR`6PmJk zqqWqyi@|0f*!uAPm3d$I6g0kK-I*Mx;&XVk) zK#{e{D9l!9i;cHeq1ai1<`)@n=ww0g^|C(Lkd;f*^UeryvdnQvafz9xVGxp>$2NWg?T0MBET>o`~550a6x zGx@es6rB;>#d>+*v{BLgb%WviF5Ne=NXLGe+&|pE=qV8Nhip}=$wp+~D76QpBvP5Z zLiw`{suBout2GsRBJSVh2&O2BA^OR^>EUMBmIkUtQ_`nG)p*sU*R~j>48wRcE;DaDB7f2 z2Efc~n`Z)GTuyWG)%3RLjo_A}D&oiT|kqP?3+|*t{NPz;z< z_iBpCTu)PizP}gsk>14|7Qtebx{uwmbYY4_O;L)?w)jkk_uNf{V`|TUJ9-1SPi2(H zR2tS>$(!p>*(GH7z*@5#xY}rBw9djNQJ7)_ z9+!ql%3`=q9cB;-b~PS%(WP)5lFGxwtt%u})jf@f^}(b7zzuJR5Vv#?k@adqPexWhuhK z72cg<(U9HZxwzOB>$~GNGTEO>^T93_C?CdIaz}$TTQVseRIN%?FZRSo?H_3F;)OG$ zR=ie~DG9rTWlBj36+wq#myEb>#?Au33j}BAZ_0 zKGo<^@xqIA&Z9ps?dlN)^{=8_{{MY$#d9@}n2ak3j^_CS*wuyfx$i)mDc-Z7V`)dJ3I zH14xwbu>B^jk;B}x-JYRFP&3FINYA^@5XV}0aA{->y$7*TB)Kjz4w5HOEa+yR=W^P z(2ksxP^H#0b!SREVp!pC{r9yq)m4CuwpFrXAGXqvhsgb|HS;qaKr|O z5yf>-Jt)wis1#I4PQ|GYREYDSSnUCGCR_8ob1~9pxWzvSgAU0K>C50w#(ICvXN(nw zc$(-}0w~320cx18aD$E|t#p`JCD=&`e6@?fK^3)Nd=Ql<143if56;ta4E%u~WLzLh z7+26PZWZ82)C2PtFg-{?r4q8}CW?U3q6%LE-t`cZ$N0Y}O4cL<{nBmoIsiL9(zj4yL9csK+f#2A{ovt@36zd5*kbUD9scMhXQw zr?=KgSfQJSY3f{}S)s9MpyUK%n;CK?&Zw-3`qGH8hozdr%hiEUyH=w?RncD$+soz)#QeS`w8?Z+vrL@Iti!* zvQ^*Y1Wp<-go4}8!Y3)BC>)0!x28&KAR0zRRHANLTx(ocEfmCf+3cr!plU^GGLSk` z4VPn~!xoN%=oQ(=pE^`($Ta_&d;q};gf!WIsQ+@+t5>+;0p% zui7`x4$4y5r1;K=%tWyT!pv6+;^DSg3pj$_gXU2$C>BlXMkkDlEAoKDDKOYiFrith z=B*Or!^?iOI|Er>k`HW*7TkU#xSfpyMi3LVNPAtivD~@Eh*hFmbvHTWSm;ccMNjf1pZz z#g6zks9O23er6Ajo3iiNp|IZqqAIEaQ|j}Vqr#K*+x%CPyT-GYPlEG)Rw=-X&Vvhd@1~y&XI$99%_E!g3`A9yJrH z3MsP|G}WJ?1qv(Z zardDn-CUd4g5we1Z4lq{67yXlg0tHC5OXRAVyFB=%y`D;a2RNhRBkTY53bCjza}$e z+-9`PrmMFpKtqzpiVe(H-02K#nbmO1`W%*YnbpbO0zfbRj#5Szz2=ZS;W$A#bfUAx ze@JCK?A*%fLni_l#)m@LeZZhpMbLD7569-|Y@Rp+)MJ1;`b$p*TLOXg&Ah8<4NOh) zY^BMhN!^hrNfU-4`Pne9r5zfs7Fx#1aI`PghOt-(k;bS~zF2Lgwd9cq|H_*tDsnE8IBj` z3<0kW&SgJMoQJ?8dlcY#!-0y?Ns^zV{1;KDX20gMhFA2M<>t3Ao%Lw|y%{_~`Lw>{ zIPODtFzv|Fi&}V#2kT4M#W@6D=-2CzK$eb*ul@+)5uli+@RZ_7WEf0U2cXHIhQhu? zbEr178)N8J2h{;p?G0oqX9}dXq6UbhTaHz1SbL+`OXznoN}*pE!_uR2+0{L-*Q9oU z?fU8D4j(Lo3a|P?9;gs&Ew*)bR_NB>7FYFvG~IAhm-9;F0Sp|uYjlEn%xw;SZJ;@1 z6H8dCvSn`u#nII%4J@ed3p=z#9VQjcg!gE(>_yA8X#EXgO;5qe`~q?HlDSwk4!QjW z%={DzSD3H*3{rgyAtFgRf!}=|5Za0kuy`9Asr*R?0W)AY#YLvQn4= zNu;@XvUHXXmA*&*-2R4QKo?LN82G{g*R;{erWK`G`j$duoilNu1b#;%1zb(YrcELN zK|@1)OBCPkt)rq^uU~;UarK7-Jr{!Uwp~uPS4pfu2<&_JnjOsk-&!)jcAsbvQXA47 zBnPx6C%e^ITq`|jgR}HdtjpD<-@#)OyaVV@P96vLfyCDex;Qe*oidr&CAXM{iH4_FgIFTm-_bbC=Bs~2 zc=2>FD_V8SWfk&F_VOZ*Ixd&L95*_9Du|>;N~M$XBDGqc-sQlAY*-BVRa9x*^k|CO zD$2$ErkP!O4Ia$mQ05 zy3P9@^?DZ922sX@z_6G`obE3rwQBh|frQ8$zBDz4$f@e&Z?~^l{LgzFAm0XiSLwJd zaMww`7iw>VP9k>DsCr=IFp6=iVyTv?!eu`Jyo;ETjFiAaHn}`$8H;#>phx9}+Q6-< zU6D*%S~Mz)z%Whv+#jsS(euP8ZBVdbNTP*;ZcD}z(y}%S4@)=Ey(q5@(ai_;J{a8X z;2sdpnVTEqvN%Ve6cVJ6lAV(}t;#6!W+{F_gJXZViHGg4OOjNqtO@8w z;fXWJwD>zIvs{DEvln%Sg(g#oVjvZ!N-V-aLd3B^2qFbUC6}<)WV;M|8a#SoE;v#I ziZ?J_z6-F#(0Y=1i^}8=v1?kw5jpy?>)1;`K@N`|LyYwhjG)8eb)bbTm=Ln$f%dS( zbCSXsWH0SWjjOb^mRUK3kXnaUdaF#E9j=_F0wp@Yg;NWG2s*S!r%9+~%N3Y9^K-8g zzk-${K{V^g`#G_uDE#Db+h&1rf@<1%AvZBhKN5j1iA#Zsl@7K!Wxp0TOXQHjd3d*L zRi+YIgbSVuFNN>K(>E4YwuH*2aV4o@!y;yT_AvTD_*x~kAYcmTlmL#7;K&iON68(h z(%Qaho;Va6Z_OLzyTEdLhFGLez z2~Lftmf{qbTqXuxCOI51tws~3Av_f;)PmB2pLoluPAg#Y{HgOc$`1r}vtetRW2;ZE z-I^_`Bj+&o z;*lf+DmxGFsb@NUky?Zcy4@=0*kKj}QQu_3C({#sKRF~tWRJE;gNagEn*kxr1 z$Z2WAiZ^H0V8T2b*Uh+(zNglXbc;KBVHT3q;r-IVJX^Bfk7~xVu}rY@MTjD7jgkcy z+ezuBjsiwcOGLJEy&p31aYv3$r!e<7EU5}O_xZ&%W*j4vApBYd*r56FtO}k-^<{h8 z?KOCbVN5PsTEzc5X2f^#U?+{K7>2#(j_qkUy4%EO>Q7%TGyN6b|IA`Du#ySHVYB;Cf)j;#?Op85}k@k&@TQ^LoLmDQM|$CGOSDhN=hEsZ%l>zD^ED;VqZ6;25mYvJi&$qD9NJ4Ip`dxcC| zYj*8^-b&%NP3m#2yNy+n3;$(7(|A0b&aYrAf?kmsB+S% zC~g2T8c1=@Fs`U{5C}uj4Y-GLrJz9f&{BZZT8xLBfwb0x&6jh#c+u{W^2YVr;&opX zwNiYvOH>P7$uRK{(po-WgCpr-^FXyqY6sSgPue)F;y)!cu#7I@2|jw`;XSoPm3^EB zxdG;)AYz)beTtgg+zEi09X4PZFJ|iXkPy|PwO;7g;+P}IFE>f=ZkgG?n-f{uJ!8b- z*Fd5)R0(!^wX%Xy8VEe8eI+{81#g2Qa}F+oQ?_rtC=`|YFLGgBzoUaInbb;$Vv2fB zTPvz4&R~uhRJcJphSUtoN$)6;nw@NFZPw#YtXjz0*q&OMTUQxdFIwx-hGI@{X;`5y z5Ts&4*%K2Niw=U`!ala)7^x^l3^=gis0@P)Lyr+Yqp&_DAj5PrMc<^BZTcltAt;m^ z;@E{o&|S#72xzPY#W+}><7&E{`I}Wk?_ge5@-)CK!F(>^jub}G`3 z3|?>1PjZlihx>@WK2h1o%$i5Rd8b;p^UzQ`=fn=7c*$feDx=}jVo2^X_&{Q-@4#V9 zd=L@}S5RHBN$KjqT_FMvxbS?)0H;uR*m5N+p(;;*aItD=QgP->9A<}ZsRt!WjrK`-RYgHv<0y!dT@*xemuzL#B?F|()?OPxGJ-A{F$&m*yKzNu1S?Wi|)ANDvk%56MtwJ^mJODAGs(FlA*Vq2B^~i=C)6~=jwQ@!BY0D0?rHg4$BKbabC|%0___yyAMQqiE zd-SW|vL#lTg?A_Pxhk~-qUGILHo=diuzG%$Z?)V8qXQx&u{j{rfoi=#%6t0xcHBrwPWP`H8 zDneQvBU#9AAG*L>l|1RM_T({m{z)J)q0;skVpS9F|_ z1}tchwe7@3Y>Sd`)o(yf9I*q+7AR7TAC!dANb!)C<>Ii;U_&wczF_vsGnl_!=TZO1H+$`(yowOoQ>^Ii#h)#}?#ovtVD(CM7l|(rkZ5!U+ zt8AR-*P=0f?!(v#rU7)#D`^ZzUU)aK#F4&?pc0a7zX~TS z-Y!DPaT_vpBXaJ0FvKc(hg$IXnG$ z;&O37*`+A@%~@OaB(h^1%ePf_q#CkzY>n0cX0B}Dev&bFz^rEEf8-7lyApdgdpqvb z*^a#_mm=olOs(|x9JGiRfXxRk z#_?{wO&_eRH5+RIqlukO5!L8UKf`A7j~vT~(St+!U=4XBa@s`)?rG#;DV#6 z<5#c0%`;ZGU+LKnn#sZ|x+I4{+TJHx$FHeTP(Rl$6HD>l-NI@NQjo065-rEj_%yZ_ z-qNvw#4=`I(7 z_M9&cM9-Q96=uQ63Q6^6+xIceqT%`&;uUJNU19-*Bxo3!hS&x~12 zlWY_ya$j?s^7vXlN&EC*YzXZkbMBn}Zq_G5Msj5`k0%;o&*XM5Kr!I|PQl{?QQk9yN%J$m|`}2sU(=08{gvw0# zL+*=7GW@B^gkwn#H&rCzgnB#5-*Uw`BwR`KnqacjCUR@jCyF(1O0kX9dh}Lre%I81 zk|WUKqkbt%hk2y){!SykIl1Ma+)@{<_=i0aI<8;4Iz47h7a&4rb4~qYYhB7wD=kM=Y=cT9<;_)|9W|&f3sCGs z8r_GCVkNo*?+>LY)}Zk()Mt(IQ^;~~ zGkU>|Hu1D8WPH;S!6F=bsNB%Z5xW`6nz!?AQLj{Y`jgpaM3j6;@gC9VA$>k?6_Z3n zoG*3XsGX(xQKre0-8&IsP6&%Fb#+IHbH(odB&R$w0G~*5xG_P@Y*+tZ(P*|CS*4~D zJM-#I!FifUL``0yYA;V+d*FcdG`oh`#{K7B+kaM zlj^qKiR(wN8T9J%lGqBi`u-H2*qqmHvZzvgMLuM|1%0qg%n0!jmi~@ze$m3bUkOgO z*=XG%_49o+Rk9;2?jI;Xz&qouOMc&6hO$$?ovgFC76(Eew85-1+>dk?t?+uOA;|dx#Pq~B#H~A^y_)4Rc55xU8=rEme)1= zQI{>UwK5uW>b7lO|1#&B<^{d;3o>Fp%p!{{yb^cbO|7X;!A zc})4K%h*eNW&1ye!_ffes#+VDKZ*{9u;cMTIBy>LBsPmXDGb?eY5);@A4Y1dFWj{v!oU zUai;6$(_d;(cWg8sVLZn?zD(z~A(5JxkO(^o9U=tDSSNfe5*d z#5!fH+ld6gKm=i(34-bG_NAG7wlCM`dgZ4s3BoAp*#jy$D#}Lt{c=J0u6<#G6KBnV zdv=b*diAzYb=H^Ln@YDh4u-V$JcyP{!a3Bp&-69Y=jg?k=vAUGkxJMIawf6W%DTa1 zzfyOge6yh}6C}y_Cw+dZ&lAc|T@lL9q)7t$Vbh9=Ex zZ&<(im8-U_pSO1N8vZucarnB2V-56?D-u^LqrvDy-_YlFqmTLY&rH)up3c-gQ>XmY zW%Q{#hw#KA;Z&iF-#uc*(<1TgeEQw$ZKmq(F3*3YAzsf#@*b_c`Ua$>_Mn>-(+)=1 z%QO5JXDr`#^`wFcfjG;e*T?w#J`0fKHg&(xNHRiqkmQh&M2Kl{%k^o{2f0mMA_>c! zm!+IX1kSHCNz&$WIFc-h%-ol0!o+H2Br@5h(1sypFxR=urQ3#-**ByNUAXAoEzCCR z+ubgD@l%=mv|OH}m;^_OWHoUsH8n-HDq0*{oGCi0gFMCydH+fJI6_9yUT2g%@?=`S zu1nK$yansKm4yVgg+cCw9o4#lD=o$q7u1(&+*|Z%qg3{a1oc*xj0M&4q)3`8&s|V& zP;a-Yl^cBVsaTQ!q=|emxo|qOuZJtNgtya1@*lE4Yqzy+qrLLjel3|$(yrazdkcu+ zIyHWyiQ!1yf$&3yuvxBW_N)6{`s`7D>Waj0O-c+AV!zS|(|T;IhZDnfL&WFCVZ`TQ zji_JkJ{&vbwjeCH5xHl#teR%yDE2O!7QY_Rt($13M`YxJ*|`Bb?@9IikacOUch<$lYwA$8Wp`C5p&rsRv7>-Wpc-*c6q&FQkSwm_d{kx3xE^BuS z$vgFVo$^zck^Y|Thf}0SQvFJk{<+KAyVcv9)X=-j{X8qL{BXJ*+^Zj3^wo^k8vZVf zAurEiAD5Rn*efvOwM$&dsSTA7+tefC{wp}i6XWIpGry#M=dl3k-k@Q=)ueW`?jYUU zQc`f^cm9md>{FHv@w{d#^By(3e1rcMprVHCyn@I&c@ z%nV}o2JLvNVDf+C@XqW19z4B96ByrzMNgVR(*Yl&#=hPeC&*wBpL{Tsg z&ALiq+;!ei0>}y8NP@~1S6;cNo`iB#{rCIYWZjh`78=cTqOPSPi=Ke z7G?4VZl?{2pZ>FoF)OjBtD93xdLX`6hQm;ow9#^?o@DN+So*!Yiski-VXj^&R%l)90lsR==-6jOR6{VgR8EEG;Iy#lz#fc&f zM3Z>aq6kCG(25m6zeHWtm|Tt59q7L~h5p?dj4bb&JC&chBDs1ZC09tLUylBR_9bn} z9wMihWaxsGT=$gUqTZOU-y*rneU@HKC4z#Tv8Ud}()g@cpPsYaucHc@Ms=t2&YhYc zqZ4XG{q501*}&9ZnZW)#5=mW-oA`-nt$gjxEQKt8x5n0O;xa*Z(5pM4*F9~|WbV0T zojx0tpSoOJwmqhjvA7^?emTAVvoVd^GxxOpiyFG!7O-|AR1utmE){0#6YM!bB!`p; z4sT_!mmkpQUHTkRe(H)8=x*Kuo`+(zROjUt3VHbHLJMjuRE}XvJ%+?II z&P3for0*M%%*8+Rh=%h?eN08HvL%t4{Xcwl3*qDKqj%li=fL;O9-$5*2^B6HnJrFxg9jvrjXbUd+fd`*k zIdH6lUCCRAH7Q!W$%f@}i|b0zTL%yH9v3~1q`5NMswimLZvxl z+xmQuQrXJ|^A^g-s)|_q_55hQQN2B`hBhWHg~c#rpk(3gJiJ(-1CCmyMpJ3(;bR`! zh<0KWDb{IT?b&Gm(#Dk|X&)fVu%4tFu>L>_>wnQ0{#KuVqEz;BNxP*aC27d1U(XNg z5309k)X)dD+Oe0LNl>)dv9+Tg47HPtyxx+Zr_`n-&ZGH^$%9xPD@Q=%s2t}?vQ;3L zBsiWWi5Jkbk=kR{>SicHJ$kPJHMVE2|uRZu(BUx-^tGL#=enzP2egQO4Fb2_Tz~%>ETeZ4ws)G&FUY} z6WB%u z<(w2LCkn9|eX^4w#REF%H;E1+%YHpSQr4?CMp7^LB04xKA(UL%4oduBrb$!sP-hNW zZ;1}S%(uOa5H9yof!U#R=g#p_7jBRpq*MrnqWcVS%lpfk1O&7_69oq?cm4xj0csWL zAJ-L@mfEo!yH&C{8p$l(d#M=0Upr#MO@3eG#g`k7lI3BXwH)I_Z<)nErBn*1nQ^V0 zzi~ei9by(VWSYg7)YK}oL3PZX|EHKYb5xvtn*xWpKH7Ln7{prFrMh&S!Nv@f97p^gSNDWGI&8{e1qh?4AN^;e|t8k6lAvGw;)iAMe zjWI)NP?D>VB|>Y*rfcZ?3t)-p?uES8Y~8j=?aj<hn5%4(k(< zol?>Dachat!ne4q#=8h5RoL;Yw2~K#y|dpihEZ8&hN2RU*Pum$xFz{FCJ;^pD(2AsPi9x${7N;zMjxgu~)pdPaqQ1&~ zR4ToUF=`|_zhiZeXqu}iQGfbYqJ;<})*%gjL#S7U%1{~MTakuZ-A3h9m1s1EKVDXm zoeC;9XmJ=3MkLUY1}#^c6$YKAJ-lj%s^3x8?;=4f4Vnof!^ouWXsgR!YE=Xs6-Fg> zYpgCys1Xr#bQqmL9itI~RvWZ5)Px!ct8XQ`kMIp6fo4{Q+EAN7YZK_GsO2$XOfo9R zw^~h&j-X@1*gPm(7&Qi+9>#@nB|n9q`p!Doxln7+;xImpFXKRfN=cV-`o*J2uFAuN zFd>1C6Mxds;&4g0Bn2(Yfo8P0ofttUsO|DR=%wM(6tp4_Iw?#_K`Zm1lf&c`v?>pJ zS-30(9gzpUJY1fFLdz_^8TnRML{QO1vXBd%5~d{336h;$XkDm_prT7acG4|h8LmvA z=ZPgM{~lQ2zphxl=;WUY_!UR`cR)hCrR#dp>xCB2s&Nk9G&2MrD&B2^TNCY zI+RBZp`iee#zs7942@P-rG#U`BZHRfJnH-edb!3F(K)KSAS_5h^Lex|ER3M@C7C$qwC@e~#QzQ|&(8XbK3R;;5T@se0pjCO$rD16bIwB9+6q-`d>OAPOuq=W$hB{F? zmkZa1Yg5q6@}SGZ@(8*>_+B1MUBurNVMPL+B6zMItqdy*@W@v*#o@Yeoz+#TaAlYx z-N{n2JX{~HPoU#8>WUP!SToY96!gj*XeKm=<_LN{x~$nN+j1tX4yzOBxNubt_cLKl zSd)TI%d5LKtW80u=RsRSOA0z84|+qmAqBlU54tX_i=fwOOfxm7rpLTKtWQC&$%AeP z8zSf`*^OCwE#DY!OrYbW&1q?$9yW%JDIU#n4u$tgcGQveoC*E!Sfvn-l1` zFgFKU9Bv9XrJ(cV2c$9D61GIp%^Guq>~|V^bGSKyjth;l4QXg=XiY)q=Sln4ur&o; zkOyrGZ7Jx&Jm|KtEd^ba2i+dFN6<~OHV^u;@UjSclQeK?9`xnm zLR`@Net5Tw5y*w%#l|2Mh7H$ocF6;`sBIqkbja4}uyd-pmu7r}+vJ+;n!X=Tk-xhAOx+)c}mYqmzN~v~}x)W%% z>_pnuWpr5b_6XW74os6zk(Q0!VRs5TJrDZo@ahzFhRs*8*Ov)Bp(h2sIuE)h?1`Ya z$!gq?gKsA64SQ42bve*W!@jVuL_38kzn$RT#K^YyhTgKJ!cwJ#5njE{L`1%5ChQOU z^Pn{;=xf4j@}Sz?PU;>A2lAlWqD`QEp)U`r9n1vUANup4<5JLr;b0zAdsj)_JHj1# zQ2A^LbRZ1mLFKb0&^yDOc~C9I6X;#xt~{uGwgmdx@Y+16f~FC4d>9Oa2^X$0I!cyX@<^14~0VswBDdoQqa4@ z-FeWu6!e~OPaaf0Thi}uhu_YFPEA4I7~Yr%y($HLQ+QJzR1w>x%Hmj_jZBI)<7;jMYlYf{j+g}3EF75Po- zzCFA>4>~)6-V_dp!^uiByAGXfV;&LS5#EtN=O*jW%M4l+ekc46Yj(}7CGwV8!_J{) z<>NoUGrTKWv;R&SYIU#HImUMal{LY$O4j=ZEer1s?>6XRK}+(WC&PQfdy$jG5bl&3eyYrUX|Gtj)Wu8sNNg(>rk!hi*F6@3-7bKih`u$49X9g z-wE#z?~m%fF9%9I=S=wB@VgO4?;C>ARoZI%fVEt$mP-vIMK(0552$WU_+a>8)baxIe1!$-nL4Ehe?zrgBxOy=F{_p0#G@KJ*v7BrtnBfXHl5w;Dg~I>$hBY z`E)K0p9v2q)L=zdq!vP`Ginrt-w%Ia)Oc99HyJftkA7cecvR!_QNMqXhFab0bQJq@ zi7w2yy7N@)N^yt1p@+j4Y*dFO{rNmvsdHjqw0=J)*mA48*r@&osyiioE_^BK_lr4D zPB=D)&xc3k=MR<1&kH&+d_j*%I|m=hq1A(ejtO7XW7X(>x!Oq4${xrn3ttLfHfXJ& z`5bIe-dAkQRT{HL)t1pz z8OZ~(Fx8;N;oITcRyUp(i0EX;{GITfXjDEgq@kn3cl9rp$raYG+euDPm4-jjKd19| zLkepBmWJ=yu^VLayGF^eZetBvBG?ZijNDE}{c5!6{tv?UqA|PWkD=c;41XAY6xDSe zrN>+peiVL~@aQ@lv)kAoS=}FpA5&MO_@UwzxpXcHC&CG<8(Yz_Jn5{mC#>#I!cU{R zC(Me*Q2mZX_@v=g24~l;+Pd!W$Z0yal8hxVWS<>M2>RHc`OhChAe2Tz7~JYMv~pN9ARm#NEt9%}x2>fV*1j*2wlJU)L%at4*%lVpZ`r*`Ty@*wj}&s=4OpRPq%75LZMdeS0IhPhy6o>jttH-Yj z+m$wlTQ0q;{5@gWrB9YG4%be~6f26Wv?^S!bVQh`v^rd)bYz&NbX1rnCMOo5B@JZwyl=Wy-5UZbWSQOT^=?~sw|luW=yIo zo)H!+y*eyWIx{R)dQE7WG)fehKWUW4Ja^J-iysclC;ivrm0`uC|4{D}m5vG1C;h5; zX;?VvO!4*Mx=CkB7KZVY&Q&Z7zcsn2cv4uP^qR0}a&hrhVU5yhVXe~Xp+)J8aD&q2 zVT01`p?Pv~>GaU5bVk^!^y<*2bY|E#xpe%D@bby!#g~QEN~eVzCs!3u4A(2YG_0Cj zRXQo$s&sOA#pF@ruMaPq{Oi({Vb|m{YVBsF^FoKxhVZJ%XDY4^JCxRkS1O$wb}C&K zwp>^_H#WGxVm>&sD1Urf6)<&dunE#4&PJyO!#8Y#F<|Yf3m0MnrFfn z_KcbNv+&KmRkN$Z50%!2_<_>e@Q1yW`El>u*~Q^2`>SS+3g1y$ z8{V&UYk8fy#6zPc2eu+Q1sGaD|M3B{63k3K z7f2zsF(o^L17#OGf@XI46GN;WN|lE4vwwsw)eBN|6=QSsg?npJ7EF&<>xv-k;W@+~ zKFvb1{YW22rR#978CI8~AfxOiY7NK)jo>r-JG9PJL6{qP$W>RWPDYS#fM5smbU|dQxS~-r0wA`^$$>yob}E_2 z64^uSF`|Bqk11Nu6@-3@oWT)d(@LezLS?hYra62$IlE{yKhyU)I_Xy4lGq)y`DLBbb(| zGbIOdi6Dl7{$2uPNNeziD=H;S6^lql05pLlT$n)xT|+UAAqui`rMLjbb!5Tz97s|p z9$UCZ1=yMA0y?yxOHAT5wj6DAx?#y=DaP2iqY-#(K=L)%Xy}?{ZwXL$sZr05bgnqZ zQe^wd9|3(PTAza{i%qwD8e2|l)LCFq+rQ;5H3HXq?Xc%yN}UqX;A`MBL>H2N^6lsY zW!8^a>S(9>iR^VA4YHVOZ1JeIeu^ce{OqGcDC%7pB-@&G=&eO{lGZ|Id6;jqm3X00 z0Q*opR*~f5V(nIH<7{TAuMD3o3(G1q#o9frERr8`snWVIsj@2bsHCJy_tPt@b-%Q- zy6DlcQd?Iu!kns%yt{EqCx#hHuLtjV#ea3MER5!g8fog&L&`!~Bt@%2}k1rx{_^C|W2RRhfA#l#eb^ zU!_WQs$eu_n#KSfIhOl*6S-F;yz~cQy|lYRt6paIwHr5TX8&ZE>H0c_8M(-r0+V&O zS&RB}d3k7k>aubr3Z$nl%gfX}LzWv7+y;FqPM0f+^PaYV)p(xiLW!3vO4luo z>snP$$_nI_7s#t9kXPw>8TFx2`}dDi6OC{HsG z<;aV8d1rW&*k^^3@janEBOMG=At`!N?rwdxauHoJHBW>(XxgVwVKey^Nb%6U63`( z2^Acbh;OO9h%PzhBD&<{X=Yer@=_*#8$+y{wMm{C4)T&d&Z%GPI7OEvFQJR+pwl2l zXK9k>C3H^FC6Nus*XWnvmdZ1u`<`HpO{VUap zb)}`DLTOp3R9YUYlvachN-IOPws5M#Or;~jHA+W?(Mm^$8XYmK2_u!(hEduY9u<}; z9UZQ%2{QL%mDYxFH6@vnFs6n>nsaLI)ZWkKHFp-jGfbAwH-;-}o+w@rE)&kBVZ73c zP_DExOi?;Al+`?4G&0oJJfnU~YMxQlqPA9J4QrH^hp9>{!c|Hu!!)H;VY<>0VTRJ` zaJACWVV2UGFuS%$?aWs?DlAYsIxJLL6Ba2}GcqhyIw~~P$}omzrA47mX>qu+wzQ}$ z%vD+*me6kc8XE4A6EbaZG?IyS6QIzFsWIw7o7dP%rWsUi%u zXXJFwt25CTv0I|2A1-5ty`go>I?b>T!f5rMk{5NSEQ9|#jJDZf!*LG^HXcH z$nC1d?@|Q}M!cI#Gk^Lr7!W=u(vV1+Ir|B$P(67iRwMEcT~-iy#%#L=S68PKY`ptxCIw_eaLlE$sCjNWMZ zBw0J7_o+m#KvL?3xv{?LVt!qOzA}2Br$jWmro}fe^xuev&E9TZ(tJhIb&~bGZ>%r1 zn=A9xMOxFn;8%p#_4y4~U%0;NGJi#HJ0m&7iFo0!2(P@pE(8S=dq_MYM&ts^Au{g~ z8g+P~`_kN|{}=djeic<@Y-wtpU0}SduXtWwccIWr;T6mIo{P{|EQs&A2z|xE!MTbH za;0d9KhO1q|9RolR9~@QYO$ObzNgr3m>inFC5vBoA^M@s6kfJUR$pr_LSK=Q%G`bt z`igw>%;AgBm#ySQ!_QyXzO>4Y7D5-QAKJ~zMlA9ddQL&+%PykrExU-ex9lR?-m;5m zd&@4O?JbK1@gmsXvWsYY%PykrExSmz7aJ9;@`bZfSsRt~HSI$6mg+0+>>~Jw7D@-D zi{Kx!MQPVX@DGs>yDqGMh!k3ks4j_bT(GryCam;Wis3bz$eW}1!lovN30@bWuS~ct zg_k-ki}r0U0AA|LTdlho{CY#u7bkTtuPC};vXSshcwOke^m@6>ztYXlaPB{n6ES4G zpqI&^b_ZO)E<#^J8#?%l+G>z zT3ssJ6h@U5>8$_aGHQ)3qkK)-?ZtnoH&{@swv1Y1%BVHA?C+G0E2q}v@+#erFQ2D$ zLV26gOUmz3IY8P#%cmAqjSh3B-mcB;hM7~UbnblShbyLp z#+?MbOb^o0Fonvt&1Q&e?2+c{NF%T3cs z*%>-zIaB8xXXz~nbM&PAT%8vT5AAv;|5iO) zzazX-hN2_9Ds+ZjdZzp~Jwtwb*d1Q2XS(->^xz&5aec`R)ZQOM1TRn4Z)6vYw;*YS1%C;hTDz=utf}^zHB+J(=?-JZqz; zarD%Te)98#xcw8wv7ZT78Q-VDwau$GY5%=^P1kK5`ibC}dj z)(e@thC@A!C~e!_zh{_^)Npm>)-L_jyIy_WSg0Gz8(DgD-Hf_b=Y<0pWl#JJTO^FO z=YfVVQv<*F4Q&nSd?jm3^kl~HXoWGAtN9VaJ$ecK`I?cH+^ioo8J=I`%2)H!?ChK3 z3bZzLMDw15U3E7c=(y{=RBT9bwkV z&z3n~SD~wFRcB}KLA@(|U-$WX+gHA>vq2X>vWfbs`RH}Zo0VM_2W_cgma_V(@@ zuARdbYxnNg%Vc-=oxiDfRJ82g)5U9`&tK*}mB_}%-TDQA^A>ubJo=sF^On%>d5m16 z-`8u6e!C^~SC8Km4kR;`+QrplH)g%^Pmn)Z8YJ)!4dumHd@@l)rvX{T!=t zcep#$7M;^^$FurQz$*@V0pYqrg5sMjerj*A^6^>iu@AaYhoSq3eM4*0iI&Di57+lJo!H#h(l~H@#Z#W! zczAPP>yZ^twKQ(-Yp!W&+|XLz)7|u^YG$>X8QXef`?0}Oy@TCNht5%<{p9vzEsfic zZSLECthwgUx%QKNN2zvp`?2!PeeEY(k5HoZNK0eiQ5vcIVzSa(zVNt&zg+1$6|bnB5t54WG}Zra?pp|z!P$LaQy8(Mn@TaRq+ z8#vx{V*9bqiHvqbE5kT+uIU6Al0#d4N1s$buTU2iJ?-0%F&Y}&eyn$J$LX`(O;e~w zS1Xd}Ai z;NNRt@6^D`dk2xAf#UZ9THMb0S|`8j*FZi`z<+5)pJk<=(5J!VETUtalK$VLP!uG~Ir(r4bg=&gQ;D z=jae?gaK(kiKg5yS}jI#5Gq6uQlhftpr(CCJr5JUC%A&xMF zzYgQCt0pBeX|Bj;2T#>_X=-*iA?}z1ddsSJJUH1_*t4Pa(7BdI#C7l#;)=>)Vcqz} zvk2nUT+>`LaNHHKxdxh0qv-^qiWnolw8eMCmA@;VLJ1H`YHVmd+tN4^VMpAdA=4dg zyU1?tV{m&#ISHP#9%`YSeMcptr7`QlSSnuX=FXK;s%R#UvbryFD!Gd5dnMnYqjSKG z=6_LlAErCZj>gu~T!UCQooGFRxrwR4_?h$=X-lIkIFwuTuupl=1#AaTQHCiSB>}4) zr>Tj$ItAl4or+BS7)F!>MW=UE*G)lByG9mvNVcU0!oH|;BDe`}xfEccJYnqj!n4w+ z2q@-q#9x(`SV+hFj{dvdiWEjBa%kV|7J}@WinT%Z97*OUtT(e9`i&B}GN2q-bGJ@R z)Tlwbw9%D@d}cQ4@?i#y-4g_Yb_b5TkATWBtz##s;iHM?!1rpDMW~CcZQs#3u0GC0 zS15=A>L>^5;{=FV4b#a3!iPF^5$C$nK`OOg>*@y#rF3LP%gFk+N=WahXa2y2~IF6R$A;5knTuQ{ci+S>vnX;h~ zAG84lqMSQKPG8(k7>ds@0mZ;XU_KascN2GbiWmhxs1;@b_?ez|n*qH9DTDPks3|e( zX)lS*h>U7adj%As4=k!1DCL$zDJ%!|nbsH(mN2MN`^i#93eBL^*&U}>Iu_*63@#zG zgI>rJo+YZ|^9#Nh_porsX-v5LWk?GpoOYn;v_!VZg-(=U?t~wdbKjeBq5aEf5-2Pap&Se%bv`%`_zq0;8c9i7C501kgf_aHoOaQS z3kJ{zugkGT-Y~NYhy;UN^T52j33T8muKYZx>z$%rNIHD;50)8ypm{jw{PVvI5&rwM z>$Ug}Ul2}m7}(j~!SQqt#F4>bfP`xr_p}9zpf&@$SIMAoOB z8$8ET2Iq1MQc#r1iSk~H@7z0#sRRi?GO(ePlkR2c>;Kb0?$$tRF*uMM`GbHitI){t zfex|?LbT2a1%2Tf3PO$xsTYn(1k}Zu2H_n9(u~zRSnNC+IL-)cy*XCH$RK{2ko33j z=qCi3&Ddhmg?gwzXyBuv^zj1VVHLhcg{v6{s30pYi@wh4oCwZ9D0=xX66av>6yEya zseeGhJXiOgfM_lxCX_Va-{Z{0`sc@0+! z0m27{i)b&rW)0=*DcmP4RXq2-T>~pdP9eX@SmkpN-yk;MXy_TO_ORLz<4oVtnOJN% zi&VlA?vY#SA)&F9x)Vg6YqpoCE;9frHE9FC?1Q5BG$hxpkW z%=BRF>lWC^aB;(B|F<7wR%ks^OiQSx?#)tX>EY{acid?WTZ27^16V&ercs4=D$%+C z%xt}T8596J#L;JXa$L?`cs)f#-5!E9pR;{OE3p04#f^djV*kMLDrg?tMyEZc&I}w^ z&)kXj1IM*ef>t+bKv#A*;V$ktjcdr-jeA6R$7zr4kc-pDDh-IcmM#(QFm^X#YAYqZ zlGq27eo)Sbx?`as?Nn%mbr&^|C}`_GhTDI)0oVxV1i9#?FIboxF=@a-4gKLB9wF)I z6fIN2{Xd6dUAz`@@3r9p6T&n%572{o#Hr^}=id4U`!xp z#=R8$US!*)9gSr;F3Hq@hjfm{dJE8omiUXDx}WQdJC8g9S=1OtN)++ziUr`+88 z5*x8$Ikw|8!|NlK;R_#^CGa~VfGrCxLI9n#_=%#gS{{`+C6P+yYZVG*pjVty!{Z-< zD|##4R(+=!bH@8b6M3-2yIhlh-O{)ce~Trrf3SYoH^%8$tays%Sq8JrBmUzW=nR^3o3)(_sC^>K(x-^||E?}L!5BDQt ze}O4_Dp(-PjGDhb1A;5s4HS&H2hI!#O=2&DazM^%P3U*XPuwPTsl`+wDvj|L-QrRc z2zCsLBXtgmEy}fM0f8dqnn)>fg(Rc-Esf0f%(3Ws^SrtGS320 zjHN85GD`OOlxT3cQJuqj}K8Eev#Ji1>j}2L?DjJl4cFkEB3h!UC*q&{L0N`8_1? zH7qTAeQXpWPU@aI7HTe&xv###F_tjgQt)(KDZv1JaR((C9&`tDBnzqxoL6oQyoguqUBkDTaLDKCVaYGMO&?W4S}JIwxL95o7=?p&kQq>2X%L z5PL2|0CU`Wm`s-pRT4UtfqQVpRR?OqDoVOeLK_Af^9z~do)W&8%d)i=Hc){g&VfQB;@Z1FJModq!z%qa{N>C~A`ORji)chf^@+JtJFa%o!Nu9v7fdIk)JRuiRdT`$n!RFp| z)1#kw(8Sh32?@Y|ob2L+B11lAFc5PR`;6sc3ye9-Sz;?ARu#6N4x`MI)Qkc2&SP__plCr`;UD-8< z>g<_AOKRYFKog=1Xc_hl>cJEK#;Y_QY%%B?QVFlgu`dRz(ZTvYk% z>PTl`OMU3U9aQs`J~iAQpe1~RvpUN_9$EyO@eBA)dD@}fgmQj10ACnv9Um}uuNgWx z_DGxSKf;Wwh35Fc5qP?RVz^^OXgEm2nvLyCkIgwf=>wXw(!qhl`Er*GF8BymJjL){ z@nqsX$|bYS%U_#IXlqS5V{#!i(}0ies*pS=<5WUTflvdACGMuypnXT#ZL)O-Ybjhs z&f0i13E#NyDBdqvF-{cOwbi2z9!0_%W~B+{ID@{8iC2xBKmk8zfu9ijPI%6oAZR*) zq+u@Io0jJ$ex#l@%V;>Q`vzmm=IK-tRmH?CmTDht8 zUN9y`&w=CBUWcAysbk8ed@MVwz|>bwXaW3(7EB1x0gZvvSM{=k3v>ryB4p2kv}AkGSJR#lp>yGw8M^(Ly^r1-4ZQD-sJ`i98 zbSiK_9!{>rTE}QGn9fW$of26MUFirXJflRgQCqL~S1Q4dWQ8x?e4*zAKhx4!$)+!^ zDdNV0t*5=|#4|08b5J=19&?Z3XJ*ALdQb(yC#VA4&nqCDK67zKW5;P<3N{`_gy{{D zrKF4NYnt5LmU=?C%#7XDZ#({x)61Rr-%!9AgCDsn4{!V!r?BcUf<0V>_Uj0dLF7c zySdLcVm$!kLWt>~=WZR8a7A+U<$F9Cfc3jI)0GH6H6P;{?}?EBEn_<69Jx^3=M@V>(F@6!DirZxfhHOxFZS#3yocYG^l~A1AdY3i%}AL z=4Te&Wp#4J!h{8j^YPc*=WuV!iH#qJSGD7`)Y;+$OJShfURWOsj?eW70ahD^QYN=Ar7%Ig4*~Fw#%r<$rI}S8jZmss*LlOHs3SyGXf2s z`X9;nAL)D66@Tt`;ar=Z8PX}{DOapo-Mpl+W$oHUYvwmBS+aET+J>gJYnL=Px2#>T zWWnOqTUvG2x?WEtj_zB2-JN^))ZNi_pifVuteDz3w_$2s*S^l)U3zF@#nf$WE%i&M zUbnJp`IT#KTHW^YEomZ*8knWAo;%-8{8!>h1mg` zq$eeo&!f0%MYRi8@88|o)73w>^FUWefA4{~PUZ5xezn`3-dGE zv!<(0rbtib^zLiBYk#5!FCr;A4~8#^lZ@~SZi`xWAL#4fq8aB!XpV;9_L2x)2oc)Y z@uHQWeALnc)THaBSvZCD0k`EW(&#eu;L}h@_DwV)vtPm%fIv@T6W7IwDca>+o2Ws zrggmscE7fFUw_A*))&XR={F*WMk{2nXXTRl%jen6Z(PH^wC460kZUF6pf=o$GMq_zNr28PKwCRI_9!;@ViTS`v=XBuKjbBw6Hl$H<8*@8rGS}+wgjh zJ3zxVJ#@<}XE~i{2}CU9+&w!qshwV=NB(%jTrCZ=lcNgRm-A#VS-fQK(j`qxm(E|> zIDb*0ii?&mnY*a5scF&Dg-weanied{EtQ>mG@iofIEUvB@!p;z#fNWw=%$U=!UBh~dyb0vKZ^BbF%%wN1{abZ!d zZ)}{qh&WWk!bMA#EMBlUcdn0BVad|@a~l>kH7!}%Fn`H{h4~U4DU5oXyKqTU)6#~8 ziA73Z~zIxl1t*>0YWn(rJ^&2eH^S9T-VMFIp z{A^!Gz257p(;_)T8{V*;-)t7dbNI&ocUZ~%m~qx`curO_OX6+&Ixf)EUyz~&r|4)- zdm$xf7_`n~6wfoKpC|kOh^f9Hh5sLuSxNE>Ikgug>HiL)&ByCJQv2eY$_sMfMK9F* z_wRa<&EDt3C^ds`d};blmi^CR`i`c{p<9}XYm~pIIqb5mz@}#9@?=+Y*sAGm&7|`o zM{03NaZlUw_B6ALx#0}#P&8u)Fdxg|S}A~J7RTW#rcsPL9*SYS`;?Dj?4Bjtwrks( zH|lWp?Q6Df+Y~Y{-?VPc=Jopf`mJp*->AR$+PkkapMBEaeVzI2KiYe*GoSsXz1ceR z&}4h7b>^X~?T~in$(?ozJM-kd)^1VR@pEU-JoD>c{m0Y)@~{8)@7LYh{ICBDp(0Se delta 27179 zcmb7t2YgjU+WySF=_HUq=M)yN6$9<~(nmK4;FH%gH;V-uyni zUU=jw(QjnGkraEEjOlTBVtKt=ViA`DjTYfIZj{fc6Bg5L`QzoKb(|i1^8 z3lS@C+z`?e7Z4jOWkuD9dU1kqiGOVoRkW84B5R21p&K`DROE%HR+V=^XqF&xA^KH3 z5S~|2E235Ow>Q4_SM^Qw530zB=qhJatcpmKvV4F2iiaZ_w}|Pn?=?xrqzJPnRjQ6c zt0Syl@ohwleqH+@*-n|i;LAoDm#<96JZzBR-XVitImC2Z`gQsKn*L}JU9mN?NyWX9 zJwh=(rzg6+zB1@kxdYI(6Eis&K7he=T@rrWXy;PMH?`|x)N#(PeGjg-qb ze0Kne60LpnL_KoVUU3@@HCCkgs5a>GI2zP7)OgWcUKbNX!Uv*Ha|zMnQA17??R+Jo zDrkOc5Bh5VilNpKslGJ^^s1~^rlB?vQ6k4s!%ZyuylkieXkM%|hlvOgGW20D7;=)R zBPXgng^Ng6IJ3-9lSO;uRs@WgYx;IY?HTM3)svNMBsFDy&D&vQ(?m0QNl~Ljj7tqI zT5HIiM2fGi7=9|3vjvKDhaid7h->5F#qh&QVgun#N&}5>Hn;K7>UDEeS zSF{63-|Cz;Kd$2z?M!@HD{k?qiC@-oEjQ?lv^-+s<0k$SVrtnf-!#A#6JOJDaupND zX+_Cz>9|#;j#EC?hEjgg_pJ@y#_+Yx*Ldmz6Ccw2sSoMC%D>uW#Vsi zoMwuy{Y)*;{uPb4|6Io%8fm=aV6mU%JEiLq>NHa0oqLO?3GY1D#G6fgQOCE0iI8Hr zC8!0u$rPY6Q9%c?l0>59+f(WJx1slWN#FN* zS@ZSzAf$nQO|+tZ?eu+mZ|z8Wk%>>3_*+fypK0QEwOs!%^!3EPZvFROyLW8t|L9?`iL1zrZ-}HUPv-&>6wC=%oX#T-RG<`@w(}zsc_d|Q?`=RUf z{jeAv4-eP)a8qT&pVE3l!#~mtBfikUNYmIx?hudDP%`o@9gpg4;#DTTtocX%QOjp; z(nXqCW@6*u*uQJOvEOOFai%IK>{a(6F|mjCY~n~0o06FHo)(;RRSQmeRnw=uuH&gD zM^jBzOu9=F9oF#%E2|e6v=Xm>j15H_HqVv-TUpK_l>)j%Q!h_#B^! z`YRie6F+R?4>Wz{A9TEGwKlZMII#K=jju6nVa<>Fe(iH1&A9eY z8dzr<*ShOk@%jcPHr;G}FLR%(`8O13`3>9j{YKLUHZInD8}Bml<0gK>#AXED6soF$ zO*Ks1$;6{gyxGL}ns}!+w7FQvTTI>Gd05}y)muAsml+SXHq`i5msk%r{isVOnh0#J348;9V^ZKk2=1`jC}WIX!?Dox9nV@?{|Ho+rqBDn)qvt z?|x1>8WOwT)WF`;dJ@@Zaj|mx6KN*ygP8i?i9!PuYXv9GfOK+|#!s5Mde98jr_6|Xs!;QvGULRl z&vg->`av&99=@te=wWkzx>(IDwQzW@y=HvQbe})GsM|uC zUPOlpe|0IgqNr+N;q9*~#VMq3)sLXGhW953zZB6@97DRg#j&XM3km*v)xs8!D6wD@ z0*hLMBmY?0YQhd7qJ|>v1Jholf3i4My`Cbhd_6@~J{Nd)iIL(iA*y_B@z^4yNl!UU zmNI;e<&WJAJY+nIeUK3zV**bxMbBG2Zm-4T4m12EhQGn^|5*KTKUzG5^}5c%HnnE= zN}_7e;12LyBY+aBdMCs0X85BFf05yzGW<)6S4&fPND3IJ)|n9oAZ_Xl4-K9})h1X) z)ox?>9Sq;b@MjtRM~1)8@J~XP5T9ZR@m&}`p5b{6zlO9QbzCXvA;xnQ4>G#$9|peK z$f9%;HZc4ygNKN)j}Z8Z|9mqanlh7#z;kIBuP*agpKAF`OE&$xMxRJUk@ueCOo` z&v;&u;yKUa?QAX+dow)5@bwJ;*5WlIEM9X0(x!XYRBb4vb6+dL3e>7&1!~n}cyop` z!?ns8{yx&C@#2Bh%RsGfkT!;Ev2mq#Xr?t#d%hK@UBvK}4F87V*DYR$HPSj+4Buq= z>o^R5Pvar#esw;zgu3UfK;1uByk0Mh*BiocHcr%I<3zoD#!o%Mw6l6YSiC--|2#td z2u7%F1?sy)CLFE5#o`TmTmA+^8NQj}_b~h=hQHr} z0mgrV@w-Df9BueC!`VR8@KuXrBLd^UX)M@{@Jgc5Kx?4UIEEi&IL&OPNE^2?v)^uP zX0&DaNXy@tjhKx$T0GR4jp2dmmJpa@6*ZY*@g{RE-qfA_kmIJ`TD)0%%ipX!!&w_@ zmZ5Nr{}`2$P!wwZMh=pqtU%Hgq|FeEZ5N$m%-_vv>rGH|gEmi6Pd-&=uHw@sjq zQ`a(_DN1$ca_C9jX$_1&4HusHVh zw4>*-x95)e7lpt!o@e+LHi6x;!s1<6JL}SjjsMvD^KyXwKTlDYJ=TdXrx^Y=(q?SH z{-EXm&hmHlS-fi$!)v%W+J9H(X;1p0zz(Ko0K1r8!@*9bhxeRq4fkYIYERXYbwlp?pyj{SEm1VgTT2o#FVMiTUF&6_|7>Mg%{%=sxZ^)^*8deo zco%8oDfV`~62ktj=jecR;KtDb!x?V67WJ$F+YQfNr1x4q12Ji-K`(?EZy;OkV8hrm zfX!l?PP4*;1|e;n!@jZS+#pupgBCJ;yU~M84m!YaJX4_kqv4>q20aCW$;}{l#X|V2 z4F7~V^f#+0<2Gv`gY_V6UV9nH_@mX6@qvejLKe^KJ2? z*6`rR82%c=X`C<(eDD_x|DJHO{>L`D=jjl4bi9v(~MzsbSyhK$gN z3AC~6gW+s-i#Hfvo4`v9uSkbqH+taEh!~5HXvuKux~dA${znXEgz+u`_)LZ`W;mPg zM;vGPUl{*q45#tKbXUAx@f;nQ4E_*xKX^K_Gb4<%ibl?4_zsgk3x0Q>;0dIUS$tGi zBMW>~FNUvTxZ4h(Cp79Zn2dLLm*aVt>5g=8F0(zu*;*lU62oalWL7(wtQ}XG~M8XiSC`7&D6D7a0D$#qom4%K%<7c^Mej#PW}8&TzKPGcGN}2yVZ} zSUqk8!^a>^jg)XUuaBc*ba5J>OrIW~V-1g=!|?eGFEV%tlf?J~MiJJ1tv~SKEt!{lyeadXm^{lGn_S3n_kje}I{7ZP{-68|6JRspWY(RgL|a8u zR#^Ti%%LeS+3q^!Wyb%i%?w__xsHa!G`1j|*4QJ6X|zBvIi7Y4!`ajEG#Zjku}>?o z4ozd-74P|UDI&+W)v^4yH7DGx|8Hx>2&qhfwS2rM^r~Ze7t24ryXBvLE5oV#nG8(t z%WyUwPsjeZmxCGZ&FLjEWgX2jI&G1bk=PExiE;H{{Lf)UlvCFw0B^zs++h_(ox^gLvz+m- zVf-H>ZAMkR|MeWrVGk!kaOnMiF^4VNokYp7Vq*z4@u33B`bsN*#7rFxus%#;vn!=ivzc9)27qaoAush*q{a?sD zEo7b+-oq5_Wr|ooF1&8>qPmv9s4>GoWH>EYOa_WVY@e>^TT3W@-U<}6>A0l6onA{C zSpE|CQ41we!bZ%J|FwEbXsuujmwcpgwf-;p)Dm!Z!)v8Dzu^fiiAS3142zT{tf-gJ zaO>h@82=>OsF$!s?9zr7Uz)=9f0lyD-3MHnZ583r2x=ULv2BKfBc4OcQGYJ~@*WKD zXLG!KAj2;qZRV8aH2A2J!1!Ov1WK7e=>#iKI@J{b{~Bw!luFAKDGsrClUZpQ!#_4@ zEVpmJ!|-5ve*0$N>isVf9%Y1!OyDxZ-JSye6`d@;qO0X!fyqgg%2VL!$8a`BtY8m3 zp%udo69%FcY`R==fZ=TEy}~Ox@Uvd9;z!FLVsiuzxOgQL8ep78BMoILT<`zjT#q+~ zhp78eJ>l^?|K8xV|Bus1p5e7ryv89MO7ie^qpaa| zV;Rmi9oMm?+q$WYA3e)$r0eD|d;wekuiFA9(>>O)X>=Ven_T>HrpR5Qp_lv>U;eaCh#|==nIQ)7-I1atk^fuiFWfIXv2KQUx2i!R-6^{GO#hU z*eF5~ZG4=isjr*j+UR->o=rOqj#bm9qgK%-_AIdJX@4Z3mas%{J{#`Ind_d z&fyGaGv}S(S^TcXmjAAn4DXG!sREpiGY(<=$I&>i@8Woz=V|$QtEim%w8_EUvye6= zboV@lms|e3?_)Tdn(uapaE!JU9l#SZiYnYOoCvFpFvj`qZy2SRFt)oR9dI1S^BlsF zJe?+-?F;R2_Yw%FF@|iNL)u-i01r9sEx~a&p+Iol+{3W*Kh}Uls~4llxoYuynp^yy zRt&%2X5b!o{D6L(8ziUo_VGJ9~fx`4vc34?lU3rA7;2aKoS0t#SgMau!A!g?)Eqbv^V>KVfcS1$)gFCcAlaFiA)W;8tdiQ$LgqyMlt zPQ`k9a5C28KQ`U+9}BYa{}|PuF>q`x6L^3LJZSObZ7qJhBg1cDcz1?l{BWNaj+eSP z#($jG^*qH{T`!Gux;D*TM4l*ig>iIulQnjN&6X$K+@n-ZGAD4f*VBn(y>|cSB%35o zzGMxYWYg|RR(}ufwz+w5kL7=8l6B~z=?s5_;bhoUU+AHy8Q}#>z#(JLQyet*1aQdM z8)9+LSmQWK^YEVyKTgs->^|WVPEMO?7YC6o|Idma<39u*@maznZc!7yh~aNq1CLy> zc%@t4;IDMo_Ap#I!}3?oW&HaX{y>Nk-em-L6oVohoAz>mqtjjvPOq{2r?)WN9Y5gE zX}60)&!Y*J|IylpKSYH8VFY&)BK!k}e`pOn=B{pG;IT6nKND}-1WrMpNnrR)tLMx@ zi$9K?akPKDfP$jO>o9^lVGusf;%D*PueuNnoON>mM{!=EoW_3$ zJeh43Jvqk;JoO2saj^V?5KpmIeU3e_;`F=D0EX3br;Q%;`*UX*{uIO6_NLQGm-vN3HO;RB=<4hY}s-^mf?tRb;6rV!l_y=7P_$Piv zr_HKN^Dq zcH`)(LLWK%@X0nlOtu$6Zp1!31RS8tXvhNK=PoSdzl{{+w_;N+BP9IbI@_(5De3UE% zW>~svC{j!8m{xwyjCWhLI z;pQTOa^DCd`w!w1|6LUOzeVaazGu1DPrt;l8P$8Qe=<^AQ4jy|??DP5`X`k8zrzm% zoPdct{PcqlYjOU2BU0U#J&ps`oBYFLdV~%`VWYRgNX4@ z$X*blSFC?NFlgz!)E{~pNq_^oDq;9FxT{}9;4 zFIKL;hL`6h{xQIwM_+l~zYMZaJ-wfQEig#Te9pfehC!V*1*sl~-xDJDOMk1FZVOOa zq4{U?}LgZ^H<71#kKjNFwjKh;(UJsehp-K z=xXJxm7DyP|6cRHj0|Ma0GMC-r**6R6%#kku6TW8jnITS!F-6w;G$q*U}-@~AUi9+ zO`v#AVZq`+Rv^8oX#Rl0!h*s;TVT0GfyKFbdF0ok+?*hgU|?pjs5r2&Br7kscxfOf zH*0o&K~ZsTc2R0ztkE$pKX-}N0X4(3vPX_Fclmis1EJhm%4$|&FtE5Vw>UR{c3^fe zKUkQR7s$(pkgm|qN*{Nmt};y`gh zAbUO-oSjuUVblAva>?dV;WDi9g>vby zcxBt^itamxp&Wg(a{Z1lpUkW*yJv#0veiysxV%)^X5R*1XzZLI9EOf8Dva!4QBm8X z?1BZsKz?vZNl~D9DUvzCS-JVaoIq}VV0K=?Oq9?v*q)Or@K_QUjJ&9vWS0~cA_pjn z!eDm6{Q1HBoIptt6+>=un?OzpO1S_kicuoj#kmFfMZg20IayQ{#dA~@7!Teo3Iy{P z@8y|R(#Y|1}Y!>=#8rAWR;u0`pF-Kw)6wMPp#bg z%@kR&{kxr&ovwXaL*6*kFjj{7&NQnkKavfHFHO(ODk|#Uy{KS*ux~b%UvjIs<#CuX z{jZ*B8ZV!2ATOQysExenckWM<8=9hje2u^N(2Foy@QWq~3=IvO5$$D@)^!v~uWKGd zTGCnri)?z!OBZHOT(3aYHRo`9`SFgzD>)vDubes3S=2kn z7*EOTX=eFHc#z>QG5k*qCmXuB|ATUT`^<~oWR&ci4s?*p7?#5-W205ZkWFML5v7j7 zdf6u=Y%gT2D$t4Gtm^dbENeTj43QD(X^KN<14B8ey0VWVoq{y2s*fX`#&8nRUS+~w z9cM*Pxv)1Db;^}F$`zCuNU`{fhvUC)Zsf{Ta)or^3Um7Qk~M#4)60eMr_QolZSQwG!#-1jGh zk7D>N#;+a-e${bSqCl=dYGq_#AcoWI0w=t;tmsH>i*hnhc z=8+CsO%{GIK15!5YlDhA2z zz47#;tUbuA<$=5a4*hl=u4FAI?!Rd{4oXQOOO2>F(bu6>G5?0sZ?+(hDy-Xh0 zIxqGA-K9AW&R=t4hsffNc(_veTgNPIgOyS^qsMN~l&QBnoT~#cEYRrwi{iX_bSF98 z5!XZCJx-OOa_6noAgimX1y6{|@OWid4-lKdxD~$rM6&iWS={XO81(Gv$TewV{=)wy{xTZVqPqGCNLMX!$y;6{UZyr4zsBf{7>lJ_9p~w>vX>*r$yBE!1wjfN3SOY#M+(}G zM=+g&atba{@C^kmCm@(aK^X<-DEJozO(x3rPTE*Gz!^D7_R1TUubdS%4~a|4y#}Jc zkYmP9qN(NaFg!9ZRZ~3Tr|@?fe=p*A(QuG+AClE3*d60sa5k$rjzwGIJHAU8RqNd6Q zU8*S!5}Ri=JngYcdz^?@wC31uOALEW_*EWg1jLIYCkw((h=Sb|JW0Vj2*xTdD)@S$ zUIeYc6VYiCu_p>Ck5*sQXSA4K&>Dyaj8;Wi8$Au`3nCQqK%<7LociWdw!?=bf_Om!F&qJrlWd}O_%lE5{tx>Wd|jd zh9{SXkiibQDKWq3C^|A)#4oIM5}gdKgJ^_Z%m`R(G6ObxQ!tH!Z@fVXiLFR3UU!xYndWbX&i><=0wyY%HM10 zW5gIn>-Y=WSTUB-I;nd5kksFxpkWSz9u!QXU~vvwdM(u>efY)NDN1s(n2h|jMgNCI zSf|$;Q^iz|mMBswf6nWq;a?QQ1rfBSU@!ukhnZrgk(!D;^uY$a%|o`xHnb_&VCas~ z$I@~{j-gG1Cw)~Oo(ZBMTnVBfTqi^IXCdf@z*?It<|?V6m<``sP+#>*Y@V3MXf1z1 z%M*EqHVZ$kI!IZ2nAE>I3nssq1(Q`~qFTbGWr-V%ben^^C@vV!2oz_BKr{u-*zD`Oxp`8c#|^ zsgeT^S}f5TIOWjnJVe1CDflM^(Yf5(YO&grYOAE0dj78wYi^=7^Jr_u+M8%e&MIhj z_U57_&*!2f|4g^v|H9fPu}Mj-7wb()rg$35MA=QW)`m7hY!;ib8pkY%))=qmr*LQC zTo~Fq7luyGg`t-yxJp6fJlQbRP?ZY(NNWYnk>YM@$4W94lnN*tjxVUU;m4RsE1e9Y zS&wM6mpC53g|=PEVe)2k>vjz4W%x#XhmqUPXtaRB+W_GZEf&pgyHOhMJUI_;y@SAQ zQ*qesyU)zs5f~-Ob|=`TJ-~3WQ|vVQ@3S;eX=S!c>>?Uwr28(tOm%jQOaK+vmfTofMn}HYQ+PKPDbjMS2oN+D#d21IjUF?6^2(j6G;+ zO0Ks!As+G;CmobrJEwg39-cEp&$dghCLVpZU8`8}__N)U zKM_wq`$Te%IPa`0l!HSNAWGR4Qri&r7Ej8q&~s6aMoz2xM)$>wVSgJLCN}s-BfP`E z2;oNmPK2BM7Z8?35VatJs0$*9x-f#Mg%Lz8iufzS;>Z|;C6QH962(K2?T}s+ITqpK z$fY4fOCt9mTpD=^;j*YUva2YK8Z8Hl+oKlAPGUvWPT5(6qAnm@8TD6$tD<8Nu8wYp za82}BglnUhB3u_&rFEjXH(sI}Cm~D}EfLlf$p~wSRtT{wKv+k#j+e5LXooPACIW~? ziVTFK#Nc@8OBan0juVaJW%xDGCSFFwinj4GI!)Yyu)XMlu!HD|u%qY}@2{RNvg7^r zhlueAhl&aD;nB&WLwtD5Adwm$4YyjvFO_FR&-kTbJ4N^Scfxv$9`Wx)XNX(lzZbPb zq7I@4qIvxHvY+S_|9y0l=!meR=p26?d$+ygughMdX8iRk1H|z78{xgglmr=8L$pWu zFVQT)hmmJ?f*-4a{s>dW0EF$tK!j;x5W<0C2*MenUxMG)PGllX6Jrpz7h@525TS7i z;nmZ`q=azfU}8cfrsZ^msbXkC3>IvC5H=Hi6JmTxVk*MsVj6ycucnxbu$GvIu#uR9 zu(8NZNRd@VUcx5y;rR(a`Z7dL!gZJ&jj)@@LfBo*Ot>E2UfhPTidE|D!_7oN>67F7z5T+I_PPR&KK zMJViDajWV+i5S&==^1@#r~iVQA80((k9ug!>Ld(BG`t{GGB_QhV#30K{Xo=cjp>6Y zlvYQ16raV^`vzbk8s1%n7?rA8gSW93&CQAIxf%y$aCI};0 z$@pmNkLFN1Ek@fTRC{#AY0NFeSS3uLjFwKqQkj_SlF+`j3SYGLoa&Gs!L^&w#9d>Q zRL^|m1zk#eOtgAN)K!k(h=Oug1$mKzKT?5QsV7jvIvC6!<6K#as_}ei1OjD4;wMj& zkam?eHdt*%M}Vs~VXO$KSm+`HE%E2d5)RC>(E|5$Stn6=E-0!xr2(F~DtITWJkmu;Y4r-rc!|b}1p)>8)Yvx7ryP-lsiB(VF%` z&S=B>t7+;9R#s&ME8wI5 zoGt5QGq60oPX4c?S}GOQoo6@5g{>om43|eic-w6o@`m%( zL^-wmRFqS&UPd}Em&t0*^@(y+`KbtnMEUSPv*7BZ_?(~D$q47cjj}{uaJFueGh?uq zDrtZh>i#X+=ggcknJz&-u^F%TFPy2fMgB7`rVky$!{zfi3(MrBGqZNe;qqn_FJV^@ z6Il!FhH|tjtz6$bU+k9A5f{Xb??t3DdZV0H4Sm&E*Ptwu)15xMkcU5)$tli@Wir7@ z-z#&XE|69XG|uQ86&ZDKtx%0KtFfGcTIvJi1>d-f|&I zUK5=z)RO-Y9WVNPaU%R;vi!RUyVO*EE~;FnFy?X#Xz6mfz3&atFd)k3VWITd@i~(c& z4Ffu{|Cn*Zg>09d(H}o$B->TcPBr4)!_zZI3Rzl1X_2MPv~+35;e9jlrlvG~!tj20 h0au!<^vKeZ8$VzF>Bk?wzxL%<|NhU{-+cSs{{d2&U@iav diff --git a/Documentation/DebuggingAids.cwk b/Documentation/DebuggingAids.cwk index fd1340157199ad45ff84b336ce3a5bdffa485c7b..8194b3ab5958579ae98c6048302d6d6c726f5bb6 100644 GIT binary patch literal 62061 zcmeIb31D2snI~S|t=p0<`N9X-&$ndDlI2^*HdsEejV&8Vc7j4MtyW8FbhOglvMdzh zkUL-|32{ygA(iv$GxogdAkN$t0O$cjixy|3DJJ+TZW{>b-vb zS~iei?<`B(s_s|cS5;qqcU8T9T~z!N)3mQ?Ut#fs#(RZA&ady~Rb)oE)9lRt3qKmZ zG-M3^2VbZP4dIhpP4_QH}u#)d{wC-Ess1@QgkNT(CYfi#=HtX^i-9qNra>3B31>v8%L>5Ma&vV3?+w4^hb0|bdb z%ir%F;d~Em86513Z*ARQ*O`ows{p5DjOXv2S@q0-ObgyG4FRq;) zEv@^VEq#!DBGc2Kc2?BoNOv+GVaw2x zN%V&JM-<9_-L>B5aZt5t8aP%TzBCVh zuKGO0{0i9HZ{6DPZ$P)p9rxV=Lno&`Dj(ncv-K0)2KpW{j{V^LTKu^m%*e!-xzkLD z+!emrlx=I>&S?Hc^1OOT|LkC;#?VC3R6=VV(b<$i*bk&)1daL-Kyqd{o{)s@I_p=zF-ze1!Gk8oiFJ(Cf$+d;M|q zLBb;s*!PF*`?nNc(5Kf0AJXf>&3awrdG0@7VWe zw0`1Y9e3jU^?K6f%7;mlrQjKJzMlpH*bvzpd}Hf3EMB{!-uPSooX{rEkuF*3Y$cItTRHd6)9V`G|dg*uFn% z-+!g=^QPJNrS`qnzHicg=I^ubr?r0m3wphvTgP9JRyi$vRNoim{#Kyd@pl zu4anPzs9lGf2;l0{JXv{U1Hy_QTVc*`VK3jhclJ4Si%w`lS4-QkEr`3)=UhU2MLs# zEBRI)G9UJ8j-n<6oR4`m9}VJ!3g~moLWa>v`U#cg;arl3GdB-sV;&CeI)@%uTEs*^ z;m6&vU~@s7tAqW7Tk~-Kdmhe{L7YgfiG)mP$o!c*R%Ce|&I;7z&;y$f&=dK%9ZNEL z08Qkfyqa$XTNS)9NMS)|9!_7dA9#?!=mj6m>*ww~oPW;4c{+##pQKXuW&!UM7_0DI z!F~$w$iulm59gsgoG0>dejLOpiU)Cu`toqzl!r5thx7hCoDb&Vd<8W*Rsatin0wLB z^7{FgAWm_K)u_8&jVdn9!*Ng(hK7I2!&#Jv^M>G9#nC*R4_F*eUWgI_noFV<=U#WL zlI|c*>FnTGrKB*&DodNtJ_HZ&r*1!`yYq0aK}`-15uLOjFaZn(1j&WhU59W*N~RUgS~^{06_pUcDfVII!Uf;f|R2XQ91<>9#YP)tu z&j-hv$|w_tN4m@FnLeCeE8FVtP?KZJQ@yqyVab_G0;>>tM5ND>F#d&g{$q14o!CB#;{>;K00yt&Cv1V1|;rvY=jvL=S z9?s@Wb7V35x?n%E?+o@c`xALMZm#9cYqpzfd1GDnonSwgJsRu>YngyI#;PVT_qoS| z{mfg=i#`ypOa{d930BoX2`j$MV)q3p;H;-kNA(e-LNU@*vKl zwRt$tqJ}hk+2Eq*f;fxaOwSw3Jiwxhx5K*KUnn!JQCKw0h(*vRf%U!HE!nVjaB3FCySG31vP(b>GAYu zX`Z)P`pY2AOMf4vXIY+STXrZ9$6d8~^eh|9!}-hLSj+xP5U1A7guQ-hXXfE73HDP< zKcC|P%nuN?Y8kt9k1Tvs=n3qZWnb8~;|r@7zR((o?*WdS$ngrVu)dYellKDd#f5JO z^dl{CkcZP0yb1*;I2QL}@j_<6SCQZZ$3n)-7rZ}T#T;Ac@zY!+Fk{}v_sA{SQ+x;C zBX7Z{_n_mk$Zhy^4Eq+hM*bC_uq!h0aJU4YpaGR{i5$Zx?Db78!&IDSU|BQDA`juy zJ;uyFC3T-RX6~s-7u9Hls0 z5}oOa>OF}}rZ4X7jQ0)3Q)y?oCqCe0dH_#5-ASiusDIE&uqN(oi>7*ODqhzU%{ZB) z)0qt74yTd>-B&o*CWo9(4pN6sQ*kGecGAiIxYL6X>MD4iu&aL%r-9LdSlmf=InCR) zHyyZ&07Z^EX^ak%22*hykHzBYbTZ{E=!|zI2I5Y7q`xEC2YNt7EILq2;^JLh@mQwT z$qc0ioM>O44li?zB|AAtSDmvf^Sv}$^!3F%?T~d&YodR!Z^Vgqb~?+qDIJ{JNOCCU z#FG7kiN1KsiKe=T`r`wcv{Sux$DS=$wbnS%flenCw-~i@InJ=?#u*&SfWmB_peEgu z9O~;NbECu2k-Ca~T^MU9m5yTqm=&lbv+UCF+_>59hei6G>i1lB;bAA^#JEqnGjTes|Qm5XW!3G=|rI^s1>e>9d#qPsR|62|Jn zeAqS$T^Je2$b5i}!@<;0ER(Kv29g;9yM_iZ)#QK(3eC4B2M$9k<9#EwDpWr?kUS=9 zX(v4cIBAUbIXuS9_U%-=onn|+Uo@SL<3oSEzXKiDI`K@bP6axgfaY|>d!mPx&Y@UO z*inUTN_0D|!--6+C!Vg@*Ks(J97>a<=)ed@f=r=_XbPR^PacMTfv-H-?Zn(TnU0}E zUuW9s7;y&sqA?iZTWEfX44Pzy<6>`dXDB@s?WsGFJ$#k92aL{ptq=2Se|Sqlrq0IIq6I^6Q^<1)Jp%<++91wpj8DnRM^Yv zp@DRwdjQOVIXGRZc)YbQnc12g!qp~cMa|_EyIfbmX;~J~BtV_DKmyQ5G8ON<+(`nG z8cyh>0I=5BS?4q-GqfM@#3iLO35^vMgQa7x3EYE#WBC3=EZLWY4*_?;8FX?u+L!1A z8^9|P>VQ`nasfWco#}=OPM|xU*&98wCqB@f>8Wld%vmZZ?wHlJPDc`s3hJBa8o?C1 zqJ8OjO-+TUS$6_V_xHgO;7}kwZ?ee&5CV}~zXa-r1}s}tD^qc?4P`XO%_3qbc$dS` zL|+ufU+X}1dxVoo)m?~Pns&ktq65$d@iSyKvk!b#_z8v`}bNPjVQu zNr^`pj-ncMFl1Pg4njo(&s^qHCtc#|oGs8mMuWj5*hr&I_aDc1_asiCNO_k;BDw#rw$wUX$&Ht zm{n9;TE~?2OOHCkFoHzq!1w6a50fbgLewRbXa{Ubcn|8jQ_+5k zluamX+-LzSgX#69H&iIa)p2-hMw{iEyAmnfAu?~1(|lmh9vDa){@p zgqCLYiSkP$k|3=1C1Yx%WK{eJBB|W5LNSrwVjLVcuC9Txp+C{xBN85t!vpk3dnE?> z8`F8m`?{8+zrN@|6!&$&;iMr+^i2Wz*hmMc>S!%kIpR`HV-(LKrq`JyH<3@kol54R z`kIC)ZD@x`GzC!}Vb<9>)m6L>+HK*IcXY>77!@WxkU?;W4{}zn=3u}$uAL6J#a_`t zxHS>a)~t|4W_6Ot^hZY=SI0r2s>gt42zA|^9f<)rjxI2=uHq^c3Hhs$bFa$Eswh*9 zIOG|{tvU%S9axD_40&lv2Ib=r8xRKuVtqqkz{Xf-I(lfxy(_0)XGoLn*(`wpZbRy- zAH$tV>BnoG$A$*L9VA3x6a3jw+*za%X%V4Nl7p<2PrG0>%}`ydTy9sY`(ei!PNsU( zxKRnZFbKuTNE$_9Kyl$gJy!*?qjo0gSaJ}Z(*jc+iA*XAC9ztE*{V}%Sn0$No{$AF zoMe+(B4NyHWRc3<8jvHlhfcOGOEF!VN z5NSXCB6-E06>&p_YX#Mh^(Ud|$rNpB(V!E9VyMGK`{W>9H|{7qvgn9dRU(Z9Nh>v% z0gJwe`GWSS12comgz)K(Gb4knR<_drLq#D!h{5JifYT`bl)$2g#I{{J$bm&5T_*Q< zZAB?Hy;kM8VFQO?7aQAp;%)f6xw@tNr2R)(qW{;Na?Kr z;n`#vkU)B&iWeU^oWSB%avv94j*mT*y<>EZg|aapKwc??B_T;a_8d}lPLh0r6b3QH^P8Ovg7^#E4~ zl9Shv94v-9Rm5>*1P_pX_wt`;XB8=pr$b8vB`UReUgc#2IE=uy-K_A&x=F zYTsiZ`f&+rx&J&cUsUT@fofg4AeCw_<1q)!6{Twd zng}w5@N^5&2CK>(MvIqm*AGxn2QDcy;#5n7Wc-HCVoi`@($xh=Hw4B(8DzN@Phq_T z6$VF0zp94DW@Ni9Ttd1`^2y2L7kbb1z`7`7EWWTRLMjZ!#O{X(GiTQ(I|tddX?114 zZF_4Qu^&SQbhv(C2-22iHd9$^iA13xa*w1f>FkF@cV#M?JeS~ZA-EREEf`msup8CM z1v5AR-q?r$GP(QYWoIHhP3o+B0oTO-z!jOfQ0Yw^onxt*faPbh(?TT{@?9VjYX_ev z(qNYDMRd;!pIl1~lfE=IFnXNodaSn@7)5T;j&!mQ+9!FaINZS~LX^ZB5Jtu5<^mYx zgEQ6e^H}9E^M`_PN=#ohuBK~vYnIxp)M5anbGm95OT$dGJr-x32-jF=_9N#?AZy|B zi|oQk7*clMT<$UmNPl+ki<%(5220v>Jl+r8O2@D^>gaWv z1>cH5iG0b6@iK7@EGmB_n%u173W}R}B4`){GZL)5xdRO1bUQcQ!XbGFGE6p#^J4`MoQ4#2z~_6ui)Maw`pR(jI$zWr^x_BFR|aBwd@ZjtXv zB7N1Ro*z7JP?r#d2q`pCQ5edwNrZ${b_5_lYD%Je$lYnP*(L+AdS7c{)>I`!r;+3g zjX6Zo(fC<`=Bmmp*{4P7X7eA!K(xL)o@P&11SlZBv_BBfxC6izU*#1+#}Nu*@yEYx_dYw zZS4XRj7|?><7_QJ7?Fgx%OrootF_jM&Xi84r)Xh#MO!ywz&wb z8|>m{lSbX8 ztYxL_t&bBg^k6|X+aD64y$~r=l4|S;GC6hPbw~_FWNB<6K)G@vH&)HmxK6IMtcGW> zot5=XZr(52=I*gjD49fme0j2Kc_-`~GZRI0_XMD3M1jpQ+mT>v*KLp#Ap`JT+}lCo zhFv}XMi`+sq;w)rV&*B41E!8mZjcH3`v;X8E{P>BNm#W`!A-3EQ?d!D*RQT-7`jPT z&cdj3NOzl*Cpwt&Xdnr7MK19oY+|U!EESit=@?@20tM>A?v3(^A z4EHVb)Z*z9RRGc+np)Ay-RK;pqa`!Zz$U8hPQWh>q?r)QzUetEjT@L`7V;T8-RxAj z5eb&yAPcl(bts!4=>%4Wx{Dx5IM*d^QY4!|+*-G^$XRI*wvIG~A=ij52cBYwn3zkh zXoqMe4mV;re3Rhet)@DYvhqZdt2q!wfmj5ui8EK8j=(9@Rb1;Xlz3p04NKY=EZc5P zAt@3WqPJn5#%bCIKa62zYXYl7GK3qF*nNQk!$P-lJIdLHljXGi>^8(KAPGGtVysKc zrm37fEoV5OwP&!B@Hh+2?2X5fV_`E2uP&9Y1B zcURv~GMv>RbwD27pBRv>0Obw_=+q-{h>)j7utRQp@YoU>0mp(~u^BF3X>}JEzUe?n zpu4Lp5lb-Z;eoHS6A4U$$A=ISluC4x=QUPsWIQ)-Ra@0e=D^dL$h)3u~TcI3GSt|v*p$s&CfJ(6u5*=(jga1Xo-n>n^$OuhnIS1ro3 zVS}At^<&Xk-{Unk&S*uc4^sWuqO>#m7*206b?kVRQcBfWBOt}aVdLd^+lX!L{zL{J zmo2NQD9vq+t+mH-Gz?nbFz`lX?VZv|&Hy)GH}E)mzS%vP^+e=uuXz%X_(O|D#HPfB zdz6jj!gjOR<{~}FP&;@cjI&iAf z?He&P9fuW!7>J>Sdh3RqLTl%$G1gMIfyU~`)Kh^QvhxmYy1YV`VXC6U0q6C`2Jpqb zn?ORBBsBI=*1-`sH~oTYEBj$?Orc-aEkR*WUBv-8&fCciaq`K)d;B=i8FG8G+bF~Xn+UG_I`koP#ObcBry|CTY^seVIkxHf=ZVixt7L_OyKv*Fs68HzOLFk}K9 zvd+qeIh-C-O}HfX^h(ZDAoOkqTKMEt5+h(kL3B%9QdH(6JGtIXM{*1R?%fW6z5@AD-t^oH7Mf z1IhY*H|JCjG6*8n$_*`w^z?8#DWb%3l&oNcOM5Wvage@9ucI#P= z-W$Vv8b)*#241A0mmtx)7M_{)#gEhyr-KO|BR2YllG?S%cte2YA`EHG!%-$8V4Uv8 zK`_uej)^{Zq(1WR>rpLfhGT$prj| z(5X8WOhXXwF={970t4|(iI^;5;n^vP6~YmD#^J;=Bz|EkcDc}>=tN7pNuIfBX2cEM zx{B?Z4IRKuR&D5@2OUDi#BMik-PXD#c-)J{CGW_=i7)z=V_~RYHYu~)wVI2-#-gGc zp0D5)?n&_W^j%uWbRvV-Sa&9ex@le8=wUW&Xk*q67cV)SZ?AKxL++q*EF5yrhIGlg zmMvv4WG&_J_qG?Je**nV(OwgP4G zqxX-9aNILt>*HZVxIYcy&Etk_vE#Nks48XAD)&#+I(vq2xVfAWG!yOXrGoE=GV*Rc z%?n!-u&-+ddeaqKmwRhKpo(Thoc_BC&aY+_%KyD1LiPsS#fY8RSgtVaoJJkoo#x!^W<4%( z&>oyQW|GwdSkq}g)j(uyl^vbFI3hKZBD+0qrw-GhaG9(U$jI;0KIARg?IBJSX288+ z9C`DD+v0NiX6&NsU3xBiAP?aUBorOWB%zaVG)#3mp{{f|_H@IY0Yu)9d@YF_tXfFs z{X%r!$f1LrX41yAh6}0A5d<*XHTvg`ILPB_Dw@6H9ZJOA--G**K~(dF-BwkpNxW|b zp3uXV2~{2 zk!F0xt=qm=2sd%Rl$SijBe$tG+olhKXp?@QLfvyW%m*HC-X{7}C_}soInUMNZw3BV zqu%%8ZRDsO1eX66Z^h7?(mx{?3#HUAZGWDhBP>FE!`HJu>(%f>84L4c^jppMVn)g}+Bo?|bov|B&LhB+1B6Q}mD$CO*Hxi@snHDATwBdGViL^W@@=EpwOq+;vK zubO_QoKH13Sf)J0E`)LNExa7{P37UpQ+RT4*j$-%5>&q#S0{^|U0CAcye9#l$vaWy zUYcq>J=14LA$87%2Y5I7YWOyr4@h!@eFNFXXV!?7h#Xb(u0Kh}^mtoRGA{o0?k#58 zaNn}aCZ`+ltkO2cBn%r=9XyMMcw%}R5h8}WM>md`evYa9{07R0Ujw0-elB7X5AytA z$ay}4zayykz0`v|^K+k=gtvm?7t_o4Aiuz96z(sI_0$B(jxIL3V=-q-(=O%%Sj%CN z;BpQ+X>&_(5AlzPtLhrWv)jcW{5lpDj3)cx&bfUdJni831+eGvJ#bT5sJAJwhn01W zYwA`qmLQH>F^Z>`d&XzvYfrS64H(alMrV2(8xIA z*o3KXx*-fX@EbQ2$8}k8JUb)gJX?vssi^n8)RjDUB`{rALYvc<-<9~qaXweVma6S< z#Auh|>W#%tt8BCQPtFnh;@pe0H}WzMk@ZVT?!v{As(DANt_ZNpkK4!W`a?J<8$^hz zi1p*JLB9GcT3L+2$%Z?9Z1^;YLTr2X80vj5)yn7gn`~U8PV4KBW5WrI_8>YsL9L`F z@rI+k6R8fEpWGFUXo9b1^vT){szSxfo|oD53-{e3pvh@GLZm3DR`o*R;Y7F##D$2z zA@2>q0e(O4ev$-9H?m^*5<*W77vE*`kCk}z6}hLgmybvBSSkKtMo(DY*f;PGU;Gk2 zOU+Z2et4)o<${PpvK(Fn$8r()uCX?B zsVR`hlDTu@XrZ-_62mvAU-CNd<&Ii>+`1>gS z9>(7zgy+0Ur6=aNpXR6V0YVGPsApLYvd-c`_66Wq_KFg>xYXQm0q7MdA9<#lqK^b* zrW?_o(Ot2?sKa4mhZ~UC6nM~5fzs_p>_~;C(1VtEZB>V7!@U=I&zkI^S}%on)a? z%#;9>%eP8_E;3Wi)B-#xKzKD75>P2r2{dA+nQ28UPzx+G1(XTY>Q%9sZl-(CsgRE! z8ZnocOMK9x9B2p+qMTu&)6qA-kc;ff_8c-Z%}gJ(BmkXdX8E9{0qATq+XpQRKrc0y z`k)g6(96taJ}7zVr)rLwW1-*+9!8i8oonWL(CN^fT&QCl3k6>cb;sZHJTuROPKEsa z&_!5j%^ycbldX&vm<7@nSm0_E`jws`9oq9kv(SV3WCR-MT^E@}K4?%zi_KyST?qWi zkiYgk6Kz9giCN-7r@}5R&9dGO!Jk(9pq`A(Y-w9#YJ5;nMuurv$SgHWeNazE<}!gU zGs}F?pp0rwt%WXt7V+!uem*ZZ%RT5U=v^+f&eU1xBG4(1x)Y0>C*#(edJmc}qZMYw zI5L`IWz=9Aq%E*8M^8oqEjBC7N)LJ&XtI2^ZC9C9K4?%ztIcW)U1{b(D~odGyT+{X zpmU)SxzM#{tq)onfUYy^e9*E0biG;cgH8xQ8%?7RS{{IIFdHni!8qV_t`sgem;0cX z2A~_wMhjhq`CjH~o$xATHknNxbS~hzcC^`S9!Ew~EuXJ2S4dl6nR#X|Y$vNZ#pX(L zr3ak~s%787`m2c9Vz&68^KzgeJZiMbLa(GPBYI_f4w9oEpm_!Sw;y_qxyFM|H4X3$erStn@j+Jxw7u1|`k<=<&^FWNgRTxh z510c!=$ZiZpgCxvd*R79AR_sxdYyTl4|;h3`g-$v3*83`Tpxg5Yp(U6Q%z$I^iu5n zwvQvD=^~@Bd4qX_v;`J8xf~glPzC95!GE2(&VvSJ6gF=(Z}dSo=14GPt~b|P=ymYj zK^Yw~hkVdY0SVq zO`CK8I>iUgm`ngV)dw9iLjmYCAM~&}9DpKc^Tr)E!vQFAHV=Bl90@>Y_@E>IhzN4 zi+PI&rDqQ#LT8~z%~21!T%dD((6^em2B3})dW*Rw07cH`jr%t9wg7a#5BhfV_5gH& z5Bd)CjsSF_5Bg5?&H!|g2c2NvW!~j+QuTQ;^m&%$dwhRl1+dje4G zPYHkfcu`}hhz0KSffG+c(rRJD9=B+fd>(JRkbD_E2-0nf^ymjcM z0u7r#F@M4}J0fcV9(d0+do6oLJ+u1vnfKc@`=9us(zXtdn0_Cj@FvWxy!F07i}2{w z4+!)apm>rJ{>g5DKo^-i%pKm!dLv*{5Os{XOrUe|nClM;Rd$L)fZ#Q!V8o@5|{a#zH z7Q%>>#yA2E6sqnARgE&P%IE}e_~^?AEmdFiL#1tnx!XM8@p+}Rtw*bQ7WxSs ze(8=)5k};URtuj$0h~f}k2#4NYQw{RsI-lkPnxd~3cfsy?8<8^&@dik_XSb~Xo-bp zrC*K*2!BLo^Z;hGO4_cJasCu7ip;0Y$L)+h;)mLvKV$Bcp7{{@HPTjkmIt0s#p&+} zfmT7@L7fbl&zZX{w8X6Qwfz*v4Vin*-2yE}Tb+^i{276M9;cI>(e0S8f85Us^b6nz zp;dtT#+3&Mhw*6fPf5?m(6i4L%;%-;edbREdOM)Lp6z_^2R~#NQE)@@;}po6 zc^>J@=3arie6~=-2QL?yhs=Ezs-D4xehJVpIP_)Pv+9Nm8}Sj!f6kt9{Uxzb7kV7fLi~uqSEX&xt9(_){hIljZTr<6uVNx! zHg^h7iYU9CTUvJ>t62CW6FxR^%8$(bcm3NF-!){_9Gwt7f z>WLXN~5$uwoEHg_` zPB7Id%S{c+3bPdDM6+yGs9>t8N4eNID7TxPD0i4$vqFW9W)8}$&D>d`;xf}PD_r!C zX2Gn;v_=z~RaCgq?44Cwu*@u;RTf!n)}mZu)}gF6>rvL2##s}=ft9l+g66teH%0C@ z8)yAPWV6{c>vtG^2Fl51(X8J`)|=I{UWi<2u9)>g!D=&Y)>z4E^M={s$Sku8WsO-g zI}%x7wxL{Twxe8RcA#8ru0pxd>_&OeG|i3_E;21B7n@d;OH3QeYI9(A;k3o(+S$dC zOU+i43(eKD%OW$(l_+PLEwjrCXPN6z&NgqHJ#pHV=Jm6m!-M@hXTN~nu0dIEq9|9G zj@d7iEHT%kTy74btTQ*D++g-!T2OeI*>`E#a@Z8gBJ3`75B*cWnbPyM@BYY`#MWe|sk-t0??+9fw{q#T=0TLtn@{%6sQxSS zKwo9e^X8uZvSsDwVU$(o-u|i8-!q>ZC|)|*+&56ZwA`FTS!KR3ScdY$D5sb|d(+nv z88adExqs<1WtoS*|DVjeh93F5ADWNd^k+X!n!=mD^1W}HsW&%a+=81w|M-(wZJ45+ zW|LU$EO^iG)}32ga94}^3VI4SGT4>8@Yq$n7>@DcISL(!KwXGj5v$M?pZyDZC;VIl zUJ-g4W+Z&E4LlWY&%nz`*ZC}shHP4H5PM}{!;-dho2S9N;=Ry!ivnPo1kWvqVwIXFKuO~sp6@UMd%A<2|Liywen`$ZgoJYRjatP!2K%{h&-w5rw3XR5vfs}(d~wB)I}Y0~#UIDX@|x!w zgsij>k8jwub#2b}md7`&H_?_na4A^mYcn?oa*5!g!0Qr1@_M6u_>y^&Z`h^DQb4E& z@uaYr4e-jJsSCl@6kk4lHasR07dGx;Jkf1FE1<3U@FHL4V7!SEFL z$sfEd1zAYYf{TcymL)%WlWoKHE3M7(r*5(ke{Z=EVtH1dGgDfyjuWJsZB_|XPQCaE z$k^Kv&eMzWA^Lo%ze0H8suUET{RUB8h{z{P8@;8UYJ9#&XN!(SbzJVSV{n|kjl+XN z@Zc;c@WugQOHI9u=4F6FGbS9Ff*rF+1gA1MAgDIWOUd3gVYl6o3r{D8ptI$_1tpqeJ{Z)u=lFidZ`OlKF>=vbcS_YMErPRx9+#nOpMO8(@L$ASX`iZVSihy zLa@K0aq5c4sVf<$u2kzn7z0!*&1K`%P0%{hLJEcE@^R`a+&bZbI#tVqkldPJotd4R z9ar&k$JIJJZpiXQtjTNZ;}whpJG{ahpDYdb8^^{9ispi66tFbM&Kc^+;jmY?*480H zxOLK3sPc$;2gD~0J^Frtop9Xlf*!C*<>9>*mx5>c5~}=xaZo3CxLHCXj-3bN9*}KY zsBp;YpVf^}rLWG@4H9DUJRbP!tZq<79-h^WoI0x;IdxVya_W4#K~4+J9uHIxq|W1k zZ(NTDzB*4ggd=t$uD<-1dx%2hZ{)rw*Qbo#+c65-$RgVYYj9p00UgjA2|E*vA*I&f|;Npz^@S zXIPTfd3^Tq#nTO)ukg>Co3GBBo3GBBo3GB3xz-7MXuQ-QL|OvHiLM6&_q zBy)MCfxDlAvdT=YEC}I8Un_a*SuK3T?dGz|Ba!!+*|7NrGpF(gkyYkW%(>7^Ls?>q zQI?vyC@V}+r=iH1K9YqNDJs>&P&Flq|xW3@nF334zO|C@t!@>GG4nd@+Q7$m15~~r5@CU1?C~N zgiK}RX)AZDCu}J&@H$`a((ik$CIzjVV{`N=!mnwPK=bFN!l=QWaL9Xcx7?&Du&@GP z6r<$5R|RqwQ~-HLP&)~8D8l^9B@=`l<6fuAP`D5~%_!l|Lz4@BX(r=-TUq_!XQ$R- z^%}xAi=fpl2lli;tHBGMU5L7U!Cx{KJ?}*rO~!&B4ZXl=ITv(pGS+n$bO^6=m6ur@ z`XQ@s!0t8QZ7RTzui#6@n&Haph6_JdD1=p?Bo~~;!dGxAIbB&EHfg2f!AiWLy{bR@ zgNy}_lB@IOVXWz1@t2*~mBEh7FWgv8=znmu8?0_HiFoB-c3y$8E(8ZXf5_bjcOn;9 z52^FIgMtAs^jOeD{J+32l^1>pN|vTF*ae=KjOE7Vofm3)zInNN-ggnkauxCY7hx<{ zIUc?UW9fN<;ZLVsn3qppZeA*TITvCy-&m4w!Q(p@VjTAA8%tKn7;D=_7|S}TP|rme z%jV{xV;5m8S)qf64_?@@u*wcDk1oJ~S>13|{zAtT`re|8=zEJUqVFxbh`zVzBKqE< zi|BicTt&PHzPIQi`re|8=zEJUlJBLDa!vUHI49d>)<=0`Exb^p`Nnbwy9oKAY^8Hb z7a>37;iSASLVig7kk^IH52=N+N91^W4i{`~9x`9oy%d?(GVZ+LQ`j_Nx9ko0dxc(d zOfZJAuJt;+fMa2dkm>Tx3l&B7+{PRK75Sj{WxBL8=VHj~E#6qXljgFL@CDNiXhQD3 z%?0J*#L%xevm4CV@4P!!bgHjlDe^)@)_GlovGVlr0`7fzenS{`!R!m%Ycn`!$0)fw z`|!lzYsg%Q9k)_*TlfoRZD?2c9cH<5Th4VCM{40kmqb>uHGbT>z*I*LqpXSCiE?S= z5tPdc2rVz9x1CrN#+}nEi`Z&X5%DXFdLmEZyVq=0Rm4`4i`Z&P(JxR=EoQ6P#bx+B zt+*cL^x`&@mlThnoKbu?%9+LALOH91eO_9^J})a_Z*xl6+uRcN=9I9vdAPTxz|1dY zKMP9P&%#pnv#5*|R+RI+p`^U0;3>1l;a+>#X@WHt&kvVPGPU!2aA3Kj`mU0>rs0N? z&~MG^8>WZ;r&-m()4sxv>d-%#g4q1fznKZ0EV<@e2nLd`6M0H;b?f$KoKnodf|qrF zfj{>(-Qwl)AJEV{>{Ca01{B_N^@07Ygg?hgGfr4|no_tHwQLOYuG3T70Xf4tMFT zz&Ytk+;z1Y-!E8;Q+tQ*>&+oJgsAB-G1G}}J$B(+jy)z} zZZy5fE&6dUZqf{zH<^@4n~WJUht04#Vn)nO_%_;`&CTX5=BRnAxy8KAyd8Icyc6H7 zdbfFxd9S(E+=i3V+wn~#e9s8qqqqa#3ObH&NPL*z9>I5UK8^1Od=}s6xEJ4I_?Yuvfwm#z@Uc@LLa9H+H)9I#YHigwC#XU_#^eL(^4R~|VZ299lu zb|mp=%hdU>ib{xsCl1EXja59+#lgejI^##i!z?Rm!ViDNGvmSBx(S7C3H+eFdpYiV zd17&%`Ee>KFZor~`uV42 zCYNsQiN|{R%YWzU2L7#CejDnX2mnki-pU_JPsGlHG=D-9e_QsdRCL5S7Z+Ffa8{n9 zugxV}@jDeM{7TF@5Kz6RY}GbAbC|z6b*`aIdlu(hLz#HlmKc7cUVftTT%!#X?~JDK z6Kfo(%lY~_ReE1LTKz5T0 zD)tQF$BLq~33#xVJbD%pbijMzf#lh$m;Gs)iInV*;^~d}9g~;c*fszi#arJ(A z*5)n9K<2*>*Yj_ke=FV$0`gl;Rd@_Hqn*VSwf1Lr)zYTigC*`;#rlH$BbqlB2s@ zb~H3qvIEvOr`w%o72}nOJa#fUbGx1-@6-QGswJ_gJFZ6044?WPu7*#23uP}58rUU=y#CqP zjPAzfba&$p)HSEc1r-g+RG#T%x*O9cl>F{S&YxIE$F6^t{3WTq?GzWM*WE~dB}X5{ zVDX8(SW+3ZzSr?;IHjGp-_+FbFE zN5^JU3wAV6vJ}Yf7S))R!=i?_KS>*HJk63b z+|fYIZaAh&*i<=uN)3DBpFKKu87Ia+N}aN#Aty&wR$3BDxlz8vVoR-2?L|46oFH8Fz%>AJ zoVdO1DtYh;48`c?6DY2xSZGkxdY4jih=!RyK~3ju>5w?LmgB>xC``2kdKGeme`+D> zF*sN4fi08+az4oY9TTBtO#3BuHQ$OAAyC;qm!U7QvNd_sFb=JsgIkUrk7S}xkgCpXxWqp zXL;}>T=W9UUv>2QXRm*jZ72uMi(1ZkQBpe^C^2#=HiH&HiK+{xmhg|7Euxb-6uP#_ zIUz2Wv%S{O$nrA?I_m9a}hAnA(D_%fQ6 zvhDDxdr;P*he`^W%vLkuCmp!`Ni`jDkq-d79@tYTQO=7ok6uBon%rUVRnON{x#?*( znD8S=h<@t}xDel>fs3x0F+eqhT%%;jQ@YpW=)sfSjpW+s8AcV_70sHez!r4E?N7Qe zS|nQ%MtU`Z&`BO0BdzR7gMs$XRHXe$sy|1g1a5=2fum=WqhWTBh|=3$N|m53(OT5c zKtX%kXVMZ}3!{FirO{u|p4f_HvXy?Ke|Z7@(bp29y%8qk6tX49VLgcvFQc}ll)4^3 zxs@Dcj_LG&D&6tFfqN;{+PqJAbv$zf_bIYYCjmmWPs zJw7_dQP_r-%1^|F{LRNuG?8k071|{ma+c~l)GKqQ^ee7Mq4g4vLQ#)Qp7NTda*SeD z80*=a#(3gTLHS3{b4>MCkXVGRX)iEu^CpnCnqiyzr8;r&BvU}vkT0w!>EsIM#(}k# zzL^4K)Z$Ro4b@e0oSvB6%m!b2W~K{C3^`S$%_>S=naTmRbB#_q{Mp|2OG$*1sL@_| zM1m+p3WB|m9FoG;gpto)ezE|gR%meSZfrbFG1FXV>~t{gPktVx36i>Vc0(?x;&Nsj zf=KkVuu%1yZl?D;)X@pRqfT_auKHf;uzFR!hL;jd_x;D{^1Tp65jjP&NKRAb+4d(d zqgPbjYdlTg-<+miauSRm%&tix@ikXc&q?13!)rNSK#0bP7n;-XJDh>WMEbv$dzuM;=9;$h}y;Ykv{PonTv8FIrd|}(*-3B17tg5(UaXb>Mubg}pF*s!pRiVd{Bke=0q7?zBi!L}gc)TBlkQOU6#u z_7s=B>nD1uk3n^IlIuGfsOa<>lq6+N&%}77K1lNv#!>noE<*@Oj#6g2hN8zOKQ%jG zPwb0cic1yxDPp*F+LCK4%9-_UCP9OOX_%uZ*0|n6Jq%0Emh&Yas1Y2LxsdCLR8J^1 z&5*PW;heehnov$xW$V5(gC0HwD?rI;LQjOa%6ZW6Id4+QS&&1cXE?Xm4CwVd@M9kVxd`R2eW`k?h)<`%zZ-UZr{>)ODUGNjzsE<{Bpf(a;{Vn_E=E@{}2+?a7V$TE~*SVIEJp@`}-A6q-4QL6#Yi=8Tjt zwNGcKbkd`;o(v*HX{Ij1?O*>aG?m#92ceJB$jHo!I?SAbEGG_oA!c&)?=kq*$ei63 z2Nu|*=>?hZb5cTUCn)vmW7L1Dp2IizR^Lwm|4r0Uu7;^KT>I*pn5zwy6lJBWW^VKB zZaKT7;Zj~}R?i&-ZAsa1O|2TK8Cz4Ot_#-OPYH1!jYBr7{gImtHKd>RCUL*Ot#KnH zq5o6nMZSLwA!sT2LXSgEZ+e;|(#LUZ>N%}USM}H zv(Wyy=43tRs}YSnqOEc7L$iBq3^u2cP%;Wo>hwqC2AzZQgS!UwcI1s(H}wRqijR(Q zJW7Bg^tRIr-2n<$(`UGIB=6``h{zc$FLl+eK1#i-a+aJT2H{z3<(cw=CI5(r_0Q-T z>?2B?DbXItPkIKvpB+9$h8+N5i*=#Q$*IF_Je?eEs#J%&>1i5^ZW9rMc`ps8@id(n z>o+}}99?riv52?4_nYXpiu08e55aBt)Ms!dS=vmFnH;703N%cwm>j(i*Q?NE8lB*# zrYbzPecC7U>gk9%O}TmPRL6`}oc{MoT1Fs$Uxa*hb+RF;#2GQq^9H@h zY9pjq=gm&(PgJ3F;YB|~Y~};pv!tysGi56ZlvxXTM849;(|4#ow=rpNwJxWj-L5zbh1RX?^hU7DN3I} zjMCf-5rKRiJ;R{Koih-vo*$#gT1+|9oW>RS&KRb-71w>5wbSEi_NePIT@O;H4xZ#v zpGM0%@|h*+Wn5Ryqns#}(KD3Crl+YC%$Vs-8Ee2P^C8TjLOr(n9%>IgGSg3L$P2@# z)~YU%EOK0RikhTs;kBz@8ng9^hQb_;F@wg-TBf<0YiXuJccBY59i2UrEZM;!^~?>a z2VCXyREu?t^K0&>Q=_(U&ynXqbXkPc)oBZ!84;)Pw7#puqg_(B*p58cD9L?t@=7B< zON}w&-AAgvW;L>&0e>|URh^~XsvUFA&==9`;Zs~K zza4#-F;ihIBJGSwbj8RpcQmY^^(ck3i`a}!PrFx&O}*hPsQ=L;&rj-sxwHKNsMKWjoyT9r=NKuA=GL9LG$NwrAr*jjItpXm4q`@EJ{LiB3=_tKcx!Va{T#&C&6Ii(rc4! zwHkLMN{b}n98? zqi3oVk3G|Kv#m;-*Bp(uK)-MW=$cJ`K;F}0soBi+IB#mZa!^+io1Shs)^Log1g`aC zGyWVMO!^@Tj49;YH=DWkE)V9uUdOECUtsMDs(2raM8j(IRjdLQ;n39sSI&U^rzL7UHG1jwjBMb*B zL!#7Gf-vhmMa6LVqMc}JjpcxBj?vq4pKYNABC3ljGMzQenYn}}?=(@Gy2~zJWu3^5 z2D(4ud<$JJ!eB66un9{NQDQ9rIkIk#auQz$#^qob*4(UQ$pz5!$x+kY`0ps)<6d+E z`+(`A!(Usn{~lM&Vt0{Us>9TG&GShFJ+bP%W)}4OoC+fn^@5XRp29U2Cq-{hJK>}l zUkTF{I<1C%xfv|;7Cj%La5xsnr@!NwIq{f<>|^2D_HX4gHAiZ|cwr5$P-lfSdbGPc5SexYMDwswKTS#ml(JnWazAXE2}Q z`irw;Pvin?DP9VnGt>FeidduPApZlzOrt*n2(?4jwL&BXV#|q z2ikTlUqAnf&1DN6vI(CczE zsO!vh&c}Ej~AUA`{2*%f}qW-HrBfz+4p&=is2`Z2QnT>Kz=#%J%8W* z$a^O%U7&j-mtE%Vcmv?wHsEiY~NTfpckbVzwe%j@92wm`+Id~ zyCQeu=u_3DbYs2CYOn4ks?cB}o_2@wgfwp3|I75pKQX`ZH01K|HRbt(m1mp$4n6LB zOb)b-40>kpD$=5J%(K!PKoG&TA~B5N;i}@H)@faIpT9R#SUgkS;#76w*lYp%OKdtcxx9od3-G! zm(`&z=qyvV?B8`To=PK)@*(NE83Ti*Pm-W zX@}4FbGPvqN4ZPSHd#n!$#Rz*8|!6FyBXgAx$L1=(Xty3VMj96AH@oM@6Kc@aZ_?2 z6YXnxb*!6SbaJ$4Y#H=zUbk{%y?l7lHSB9^ZruY?E2q=-^k*Nw;sx#Dn#r?LZxMe! z$N3*~*XBj0cD{&mK412l0-aNVT4T{Z?9IK}lqWDP&*>l!dCljz0T!P4rS9|j4HL-) zLj9{UVvRF3Pjz04SF-W`@)tzo=}y2t|8L&odkNF?bm%qrLsqNV@u ztzES?H`cqRux|azx)rM$8`t3ufpx1^2Q}In3`VP4y{@rw{fgCV*T1Ip-YNSlr1X&c zF1UZ}o$O~UXpZ)K2RwhQ1K)aJf9s*G`}btGqF%%^{qg?#e6!);cK>W3x*SiHh=&_6Cm#|_aoroEDybDn9P!zrF4 zrk|twKSZb>m&5;$=`1w)l??6Uvh@Fi(gx>s4y}Flh4OJF@Tynp!NJZ~S@b^FjC>J% z&uih^TlT+<@NL6o{*k7a8U@cZ&$}!e=TNhBqj#!#-lqOzO>gkLTWXn-GCgezoM~nk zbLVrg`O|b0z~C&;*ULDQ%+B$A4gFJe2hN|Nd-@cdqMM$1$F|$sn)cx4>Yi<_2XK>h z+h6Y7*1QYv|Esm_TGY4wyFOX)lYgmC7X0LY)29l4^85PSz)!xQ&kX!jsotdh?R)et i>~H@U?e|wNjGcYq`R9KByWjruSHJ$vL%;g{mj4YP2@l`^ delta 12280 zcmb7Kdw5jUwO{AVJIREZJb_HeArJB-kq2xA#7C&Vlxi+cV#O zoVC_oYwfkyUVERt=e^(C&OWS8cetLWwsmdmcxgO}-D7|C@br0Ec4t!-pf++$P9EMh z)oyoI*$-bgHDiJ(n^UVQn|WYkiH)eP9#oX2kcSkGkq_Fxs3QSU(NYZ2Yz^Lq^_R)+vLZ#Y;}um1?zAwP~&Xp%I@y?4JWd@N|KprYFR4emKD3lv6yJ?GgkDZ{?InsXWOB^L!S1o z<=vq8HrKE&MpW5AZebSUd;sy%mGmAt?9PT=uv`Et{MnvzHvS&MJ&pipuDq(=f?hUd`xnGxr?vJF!Jr$DBvq~@5=_Ql+%v`-ZBjK6v$TG{Nm-P~#bxL+D z>rwgc-6ZkeJLP-!LGhlV>=z|qO14yFN|pY8PBNJCu6)lamSyfH3D4al-}3^p%rBK? zL8B}SYxHtL(ii?hzE6EymeYR8%M{V{V-irbRhEGE%kj4D02idig`Wd=4e#)6AD8gVNv0vMeYG%I?y0+b93ywCzK5%82kV1&70HfS>&sD9LK z2z_5eK&-aFSDEx`mj(V)3;cgfxQ&NUoeyT345yH5yFaBjID(hcmiqH1k$s!V)ZSx( z?>6Z%9Sx@T`z-ViTHtS4;P2`16tut`mc54(n8yYq$BkwK$K4kA6BhVs3;Y!e{O2az z88YF{-4=L^92kE&PR@N6#GRG~hb{1DP}j#BfyGeN`CAM9+a}!QBpa43g&rbuxh(J* zsH+&(hv7l4G7Dm>$;h?S0>4X#!$OE)hG6%@CcXQc7WhkWNCh2x1o8i@1^znfdIu2j zz$YcvRYKG=hQN~^OAiA7Q5}94>gllrJcD~L@4;czt8@Vz{%w;!X024{3QdYn~n(quK8G+AG>z)x70u9pP763(94^fV!@9)-NSIgJmXTno?B_<-zV!C|HQ89PnrTN_3bw%^jGX+DI&%iX zm4&7kb=^PmWgtTQ$N1&HWGa#WilxCv`aC`cn)4>SV6I7DaG3?Z#sXhw3M*J|q1kMK zZ%LVm!hW-H;fMu3fx14Ou!%5wTxc1ZLW>Vgz0%|}wa=uV`mP23feufh_tSo3BBs4% zHkghnlpccV>E#vl(@&W6(;qhJi*}gsA_STA&=hgybh8(IXu<;x>G+Sa49vA4t~VJ4 zZZzRDcAD@RVGH~d)b+56-H{z zM=kZ|EcKW5IyyG?id2Uuv1hrRg0GOpUFWAsE{+L!q+!P}fabW(mDz zKQRTA=^>Uoc-iNm*DZu?oaBS0zdZGc-T+&r3hY5dkAbL|u)tq3;j?Z-oeO@LXjVG( zg1)lcq{qjP!3TRoLooJ-5)OqbZ;&%9MVMNZCrw0^YWARNiUn>N%c?mR_)Ql2drUYs zp~kGiM$`~o-D=WTuc4HQIATFq6srE24#!GZ(`_=U`Kw7^V~Gv5={*F-zBavGLyv2* z+Yy@`4o{@{Y{JWrEQs{31`X;8On6-&-2m_!3)~U`=_EEMPM8&YRi*{<2l0W3wVpp1 z0sy;}SMhOZKKMk$3dvhT9p4A{p+{sP;r_%iM#$~$2vd>?B> zQ%~5&Q3JO?CxvpcFvmsAC# zy;@=*HagU+^@pS3crY2(qA@KL>kZdwkv=Us5XQ^!NMtA+*CGk6Cm!h^NNV9|Y_xxX zeNnYxm#Wokt;4ZszZL^=94#Wz{zRQN78}(%GfB z8%%oF#$bx%0H~!II2F1d4;w=z8p3?hSW+7fhT^eAy|z5HHyoAB*S0Tj+qeR)`yx@^ zsbIW+bQpRj3|VM3rX`XQi0=tQnc&bU><{~j!5ouXC(t=9+}FpgU$3=|ihf6V=f^~Q zNLRImUfsTZsaWh>o%TvF9tUq&Dje+vNA#|uR|^k?g#sX`tqsLSqe+-J0!O!N@S$I#!Auo#*MJOskvY~0I+A|at`+HVtD6}%=HNrgs-f^m!zcaovK z7z(%t*o6d_&k$luJT|QL55;i zaK0~+7+^Cu4iZ@qv=VQ>aB-JSX<6u#GFWyGr&sM%S*m| z4F#k9qgcOC**6xBBck^p%AySxt0cxmuAp!VtOeY*a!JwS4c6i$!WouWG~x3dM4?z5 z>$6w|rpCZ3sPzRSJSO(XV!d2+0_!{mr*%6wsTdr-RpEZT-5i{zk8u+3M*7FW!Axzw z1(ezB*J}$K{{?@i9T*9Xy|Dhe`Fvx>B_1;+HctRM7im4_b&CgV&O7fk~y!YaCN~Gdh`=^taF`5x)&~iSg`x@dU=nbWRYE5 z+@u+BB4r*nRu?cx;!=eLy4;G39qL-be%4jblWQN_% zmBV|MVB#c~z}YC1G7X$p;9TSuxGA8`k~nmMUmGcO33+s$Uh)FR-rtnXzT6aGfz1K7 zaC5-r73ei==jQzR**a+sD<8mqYBAl0<-dxOH-dx1q1JBGY0am>wkRAku zrqMJf{|L;Z0wgyywi*4LPSY(o&jq+5Dze}*IF6kH^XHJ>MEU}0+E$C8nKV;xPzXUj z3$qHW!lm|?b-_7M2Fxf&^vFhKR3_SihNhCAdj>naHNc)i`YF=8NS-UXASx36R!!A< zgK`KGngJIOxEiXl;4-BWR4j0{RBOR;!`j$^D+BBV(hre-f%Msx#a+3&VvW=&=o_d3 z+=XJg~a3UNE z7(=v>7V5Z0(qI6G1-FP6S#SZ4W5MkKmO?tdy_h|_y@R%#Uume3MdZYJNl z7=qfUO~7^ZpAca=aO1;5SkXK`nOlDWm z6*{h!3aRD-L91w$fy<*>A*l7LVz%q5B6j^%0d@@OKd!O}+CUpbgVnf*&7(%#PMLx_ zsnddMy1=Ym)Mddna~x~j8DQ&>hLLVZdTggf&{o>2H&_Qjm*NsREhvENfdik}Q;euG(@;uql%7KG^(N>Jh=TrT?% zLZ*ZQY&Oy=q)5mjXpF`#YB0@Ub`4!~5pKGU%cpDUTKnsK^?~4OD5_Es`z@GHA{F-r z*dnB@y%s?S=zw5`h8R-bV5TAHARW92S8CvHpc^j2m9ev6{ud-~xR}+2i`dF=AZ0YT zm2MRczDi%!O;>H;Zll{S!qphK+v)a;aJ4!vlkT89_M35_xa&I1S5Gi=gN=3dtf7189%B{s3*2lf7VWBW+05*G zNxz3rZGo!?hVRsUbcBxRD>A=3;ygJHr*8-+_tL#+SIz%TVMjF41&TZGQrsHfr#HMe zjboYpSO<|-^cT;cA%ydr<8R8I<9(hOHXD@)oDF-yCyjNLhisJ^*eSGsu0PPC_j(HM zE}t@b)+Cge!$%$(=Hip@8R*KlH%_bXJE|7dD_zVJ;PAHhz zagzJEFe|ncIxf8_$;SQVQDM5LV1Z`Qt_iIk5uCnGU(+pc)Wiv%Dt&{F0mptc;AKA@ zz;cS@iEw8IhHu{hqfH&2Tl$N$Kj$A_IZLH7P{VnQP5q0 z9f$0VyK7C?2hc6Hq0E&n;G$KQMPEM*;kANfPi`>ULE@_BzXOmfCu6`*gO z$*d}-`;eE=6K683r_-Znyj4Z?IPwzuChHp9m~!GAT2U4NdPLa({@Ln=R$SZJ>TqIk zvuy+NTWoug-)cLC{5IPJ^4pyp8*_5(h?8UYI5{@%Kr0d;#mASOveN4H8Qtk=lUvd8d`2kM` z@`Ii^$Zzm;BfrrzhWsXPW^Eqb?^9sWa^!hbi9DaGkQY!ja;%8Rr&6s?QD)E_CtQ|oD^Pf?fA4CEWB#HTnur8=MD%%a&o#nV9ZkT=qN2M}o=c6$|3YPcepb@& zw;@orBd@3B$mh`I$Qx({^2_N8->|G=RK>BK{gBn}+`djdT_A`Lq-H0@{VVo!0xmgt~nNId-*@)>Yi2%_8rz ztcG$rj=YL3jm~0EMw?Rh@6aMzfGH#PrOP^6JMra&lW{Q@Fx5o~w-r}Ayx@}yxrArQ zlEZMyKlwSwdL)d0BuhHfG9*l%OYpk5211$Q^D<3{`I>DqoG;)Ay4h)E2eu7)w!Um3SAqeZJ(1=#uy+y{;BN-!fDx<#Co@nW!1;%aMY0xuE0v@TXFM zP1+p5Dgd+T?Kw{lbrC`iY1*ZcAH)vxjI5G1&ftyTgm|XEgpVQ7K;cM4gVi3|c`AaRO?n zg9V$z#PvOQ6|}{CF@Xl5;e%Oncua<-GF-uCB=m&)JHk0|NZeQXe*y512fk|%JXOGO zDXFLyw~%sEd_HomMB|hC_=>+l5DtE@p998NLQ%&QM9QTqJ)bCGulg;&E#?bHc195{8w zp9{bt138B}zySv~N;$Pnh5>v1YRd|x@0Jou>#jcv%iJb*ZUjE!I+ zRFJ`S`Dz?oHM8j6fKoet``$)Zeztz55P&FkMd$hs;CHdJ*Oxh97uzIz^ZLSZ-~Jyc z+|Jig4)c6vPpy*_hoT4{Ecg}86BZxh?K?NFM(}RLv4R{QWfFf_-gWqCJKMS6!T$4J zKbw7^o9)=|%D`q(IS-c90*W01{n3F@Wr7VH?8!yIQTQm*1fK_Z@MrF`H(kXR-7uoG zuy5VaBUqK(_%i4}xN%UK7~g)=yI!C=Sg&u1@&<1ro?0|#BL}YpeKz`&jf>^e_w8n{ z-MfQ*aKwcMpB@?Xv~bd5Dt5E=j8l#}Cus6B>_GiD@0bEVO{=2Au40)-``DXD^I9g{ z%BM7UqCoi*HNT*$UUIxprMyk{Go{LVl=&jh<^6?Zf`6EUrk+}|RBU<&mA9Gq{lRw6HlJqS) zjXn5-*kT{Y@;nZkpP-Z2eG(yt{2RfLq$THm+rKeeW{a~0svZC=yXjq(qY&)pwRetG`y UUwr=AryqRy(O*CQ-@kqGe@A!K3IG5A diff --git a/Keychain/ACL.cpp b/Keychain/ACL.cpp index e1473f5e..03b49606 100644 --- a/Keychain/ACL.cpp +++ b/Keychain/ACL.cpp @@ -27,7 +27,6 @@ #include #include #include -#include "keychainacl.h" #include @@ -123,8 +122,10 @@ ACL::ACL(Access &acc, string description, const CSSM_ACL_KEYCHAIN_PROMPT_SELECTO // // Destroy an ACL // -ACL::~ACL() +ACL::~ACL() throw() { + // release subject form (if any) + chunkFree(mSubjectForm, allocator); } @@ -134,8 +135,8 @@ ACL::~ACL() bool ACL::authorizes(AclAuthorization right) const { return mAuthorizations.find(right) != mAuthorizations.end() - || - mAuthorizations.find(CSSM_ACL_AUTHORIZATION_ANY) != mAuthorizations.end(); + || mAuthorizations.find(CSSM_ACL_AUTHORIZATION_ANY) != mAuthorizations.end() + || mAuthorizations.empty(); } @@ -170,7 +171,7 @@ void ACL::addApplication(TrustedApplication *app) void ACL::modify() { if (mState == unchanged) { - debug("SecAccess", "ACL %p marked modified", this); + secdebug("SecAccess", "ACL %p marked modified", this); mState = modified; } } @@ -191,6 +192,41 @@ void ACL::remove() } +// +// Produce CSSM-layer form (ACL prototype) copies of our content. +// Note that the result is chunk-allocated, and becomes the responsibility +// of the caller. +// +void ACL::copyAclEntry(AclEntryPrototype &proto, CssmAllocator &alloc) +{ + proto.clearPod(); // preset + + // carefully copy the subject + makeSubject(); + assert(mSubjectForm); + proto = AclEntryPrototype(*mSubjectForm, mDelegate); // shares subject + ChunkCopyWalker w(alloc); + walk(w, proto.subject()); // copy subject in-place + + // the rest of a prototype + assert(mEntryTag.size() <= CSSM_MODULE_STRING_SIZE); // no kidding + strcpy(proto.tag(), mEntryTag.c_str()); + AuthorizationGroup tags(mAuthorizations, allocator); + proto.authorization() = tags; +} + +void ACL::copyAclOwner(AclOwnerPrototype &proto, CssmAllocator &alloc) +{ + proto.clearPod(); + + makeSubject(); + assert(mSubjectForm); + proto = AclOwnerPrototype(*mSubjectForm, mDelegate); // shares subject + ChunkCopyWalker w(alloc); + walk(w, proto.subject()); // copy subject in-place +} + + // // (Re)place this ACL's setting into the AclBearer specified. // If update, assume this is an update operation and the ACL was @@ -210,12 +246,12 @@ void ACL::setAccess(AclBearer &target, bool update, if (isOwner()) { switch (action) { case unchanged: - debug("SecAccess", "ACL %p owner unchanged", this); + secdebug("SecAccess", "ACL %p owner unchanged", this); return; case inserted: // means modify the initial owner case modified: { - debug("SecAccess", "ACL %p owner modified", this); + secdebug("SecAccess", "ACL %p owner modified", this); makeSubject(); assert(mSubjectForm); AclOwnerPrototype proto(*mSubjectForm, mDelegate); @@ -231,10 +267,10 @@ void ACL::setAccess(AclBearer &target, bool update, // simple cases switch (action) { case unchanged: // ignore - debug("SecAccess", "ACL %p handle 0x%lx unchanged", this, entryHandle()); + secdebug("SecAccess", "ACL %p handle 0x%lx unchanged", this, entryHandle()); return; case deleted: // delete - debug("SecAccess", "ACL %p handle 0x%lx deleted", this, entryHandle()); + secdebug("SecAccess", "ACL %p handle 0x%lx deleted", this, entryHandle()); target.deleteAcl(entryHandle(), cred); return; default: @@ -252,11 +288,11 @@ void ACL::setAccess(AclBearer &target, bool update, AclEntryInput input(proto); switch (action) { case inserted: // insert - debug("SecAccess", "ACL %p inserted", this); + secdebug("SecAccess", "ACL %p inserted", this); target.addAcl(input, cred); break; case modified: // update - debug("SecAccess", "ACL %p handle 0x%lx modified", this, entryHandle()); + secdebug("SecAccess", "ACL %p handle 0x%lx modified", this, entryHandle()); target.changeAcl(entryHandle(), input, cred); break; default: @@ -290,13 +326,13 @@ void ACL::parse(const TypedList &subject) uint32 count = subject[2]; // parse final (PROMPT) element - const TypedList &end = subject[count + 2]; // last choice + TypedList &end = subject[count + 2]; // last choice if (end.type() != CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT) throw ParseError(); // not PROMPT at end parsePrompt(end); // check for leading ANY - const TypedList &first = subject[3]; + TypedList &first = subject[3]; if (first.type() == CSSM_ACL_SUBJECT_TYPE_ANY) { mForm = allowAllForm; return; @@ -310,10 +346,11 @@ void ACL::parse(const TypedList &subject) return; default: mForm = customForm; + mSubjectForm = chunkCopy(&subject); return; } } catch (const ParseError &) { - debug("SecAccess", "acl compile failed; marking custom"); + secdebug("SecAccess", "acl compile failed; marking custom"); mForm = customForm; mAppList.clear(); } @@ -322,7 +359,8 @@ void ACL::parse(const TypedList &subject) void ACL::parsePrompt(const TypedList &subject) { assert(subject.length() == 3); - mPromptSelector = *subject[1].data().interpretedAs(); + mPromptSelector = + *subject[1].data().interpretedAs(CSSM_ERRCODE_INVALID_ACL_SUBJECT_VALUE); mPromptDescription = subject[2].toString(); } @@ -332,11 +370,9 @@ void ACL::parsePrompt(const TypedList &subject) // void ACL::makeSubject() { - // release previous value, if any - chunkFree(mSubjectForm, allocator); - switch (form()) { case allowAllForm: + chunkFree(mSubjectForm, allocator); // release previous if (mPromptDescription.empty()) { // no description -> pure ANY mSubjectForm = new(allocator) TypedList(allocator, CSSM_ACL_SUBJECT_TYPE_ANY); @@ -354,6 +390,7 @@ void ACL::makeSubject() return; case appListForm: { // threshold(1 of n+1) of { app1, ..., appn, PROMPT } + chunkFree(mSubjectForm, allocator); // release previous uint32 appCount = mAppList.size(); mSubjectForm = new(allocator) TypedList(allocator, CSSM_ACL_SUBJECT_TYPE_THRESHOLD, new(allocator) ListElement(1), @@ -368,7 +405,8 @@ void ACL::makeSubject() } return; case customForm: - assert(false); // @@@ not yet + assert(mSubjectForm); // already set; keep it + return; default: assert(false); // unexpected } diff --git a/Keychain/ACL.h b/Keychain/ACL.h index 26b2d0d0..48de787f 100644 --- a/Keychain/ACL.h +++ b/Keychain/ACL.h @@ -22,6 +22,7 @@ #define _SECURITY_ACL_H_ #include +#include #include #include #include @@ -42,6 +43,8 @@ class TrustedApplication; class ACL : public SecCFObject { NOCOPY(ACL) public: + SECCFFUNCTIONS(ACL, SecACLRef, errSecInvalidItemRef) + // create from CSSM layer ACL entry ACL(Access &acc, const AclEntryInfo &info, CssmAllocator &alloc = CssmAllocator::standard()); @@ -53,7 +56,7 @@ public: // create from "standard form" arguments (with empty application list) ACL(Access &acc, string description, const CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR &promptSelector, CssmAllocator &alloc = CssmAllocator::standard()); - virtual ~ACL(); + virtual ~ACL() throw(); CssmAllocator &allocator; @@ -82,15 +85,13 @@ public: void setAuthorization(CSSM_ACL_AUTHORIZATION_TAG auth) { mAuthorizations.clear(); mAuthorizations.insert(auth); } - typedef vector< RefPointer > ApplicationList; + typedef vector< SecPointer > ApplicationList; ApplicationList &applications() { assert(form() == appListForm); return mAppList; } void addApplication(TrustedApplication *app); - CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR &promptSelector() - { assert(form() == appListForm || form() == allowAllForm); return mPromptSelector; } - string &promptDescription() - { assert(form() == appListForm || form() == allowAllForm); return mPromptDescription; } + CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR &promptSelector() { return mPromptSelector; } + string &promptDescription() { return mPromptDescription; } CSSM_ACL_HANDLE entryHandle() const { return mCssmHandle; } @@ -98,8 +99,12 @@ public: bool isOwner() const { return mCssmHandle == ownerHandle; } void makeOwner() { mCssmHandle = ownerHandle; } - void modify(); - void remove(); + void modify(); // mark modified (update on commit) + void remove(); // mark removed (delete on commit) + + // produce chunk copies of CSSM forms; caller takes ownership + void copyAclEntry(AclEntryPrototype &proto, CssmAllocator &alloc = CssmAllocator::standard()); + void copyAclOwner(AclOwnerPrototype &proto, CssmAllocator &alloc = CssmAllocator::standard()); public: void setAccess(AclBearer &target, bool update = false, diff --git a/Keychain/Access.cpp b/Keychain/Access.cpp index ae7db557..54bea152 100644 --- a/Keychain/Access.cpp +++ b/Keychain/Access.cpp @@ -23,9 +23,11 @@ #include "SecBridge.h" #include #include +#include #include using namespace KeychainCore; +using namespace CssmClient; // @@ -35,11 +37,11 @@ using namespace KeychainCore; // Access::Access() { - RefPointer owner = new ACL(*this); + SecPointer owner = new ACL(*this); owner->setAuthorization(CSSM_ACL_AUTHORIZATION_CHANGE_ACL); addOwner(owner); - RefPointer any = new ACL(*this); + SecPointer any = new ACL(*this); add(any); } @@ -71,12 +73,12 @@ void Access::makeStandard(const string &descriptor, const ACL::ApplicationList & const AclAuthorizationSet &limitedRights, const AclAuthorizationSet &freeRights) { // owner "entry" - RefPointer owner = new ACL(*this, descriptor, ACL::defaultSelector); + SecPointer owner = new ACL(*this, descriptor, ACL::defaultSelector); owner->setAuthorization(CSSM_ACL_AUTHORIZATION_CHANGE_ACL); addOwner(owner); // unlimited entry - RefPointer unlimited = new ACL(*this, descriptor, ACL::defaultSelector); + SecPointer unlimited = new ACL(*this, descriptor, ACL::defaultSelector); if (freeRights.empty()) { unlimited->authorizations().clear(); unlimited->authorizations().insert(CSSM_ACL_AUTHORIZATION_ENCRYPT); @@ -86,7 +88,7 @@ void Access::makeStandard(const string &descriptor, const ACL::ApplicationList & add(unlimited); // limited entry - RefPointer limited = new ACL(*this, descriptor, ACL::defaultSelector); + SecPointer limited = new ACL(*this, descriptor, ACL::defaultSelector); if (limitedRights.empty()) { limited->authorizations().clear(); limited->authorizations().insert(CSSM_ACL_AUTHORIZATION_DECRYPT); @@ -127,17 +129,24 @@ Access::Access(const CSSM_ACL_OWNER_PROTOTYPE &owner, } -Access::~Access() +Access::~Access() throw() { } +// Convert a SecPointer to a SecACLRef. +static SecACLRef +convert(const SecPointer &acl) +{ + return *acl; +} + // // Return all ACL components in a newly-made CFArray. // CFArrayRef Access::copySecACLs() const { - return makeCFArray(gTypes().acl, mAcls); + return makeCFArray(convert, mAcls); } CFArrayRef Access::copySecACLs(CSSM_ACL_AUTHORIZATION_TAG action) const @@ -146,7 +155,7 @@ CFArrayRef Access::copySecACLs(CSSM_ACL_AUTHORIZATION_TAG action) const for (Map::const_iterator it = mAcls.begin(); it != mAcls.end(); it++) if (it->second->authorizes(action)) choices.push_back(it->second); - return choices.empty() ? NULL : makeCFArray(gTypes().acl, choices); + return choices.empty() ? NULL : makeCFArray(convert, choices); } @@ -200,6 +209,38 @@ void Access::addApplicationToRight(AclAuthorization right, TrustedApplication *a } +// +// Yield new (copied) CSSM level owner and acls values, presumably +// for use at CSSM layer operations. +// Caller is responsible for releasing the beasties when done. +// +void Access::copyOwnerAndAcl(CSSM_ACL_OWNER_PROTOTYPE * &ownerResult, + uint32 &aclCount, CSSM_ACL_ENTRY_INFO * &aclsResult) +{ + CssmAllocator& alloc = CssmAllocator::standard(); + int count = mAcls.size() - 1; // one will be owner, others are acls + AclOwnerPrototype owner; + CssmAutoPtr acls = new(alloc) AclEntryInfo[count]; + AclEntryInfo *aclp = acls; // -> next unfilled acl element + for (Map::const_iterator it = mAcls.begin(); it != mAcls.end(); it++) { + SecPointer acl = it->second; + if (acl->isOwner()) { + acl->copyAclOwner(owner, alloc); + } else { + aclp->handle() = acl->entryHandle(); + acl->copyAclEntry(*aclp, alloc); + ++aclp; + } + } + assert((aclp - acls) == count); // all ACL elements filled + + // commit output + ownerResult = new(alloc) AclOwnerPrototype(owner); + aclCount = count; + aclsResult = acls.release(); +} + + // // Retrieve the description from a randomly chosen ACL within this Access. // In the conventional case where all ACLs have the same descriptor, this @@ -265,10 +306,10 @@ void Access::compile(const CSSM_ACL_OWNER_PROTOTYPE &owner, // add acl entries const AclEntryInfo *acl = AclEntryInfo::overlay(acls); for (uint32 n = 0; n < aclCount; n++) { - debug("SecAccess", "%p compiling entry %ld", this, acl[n].handle()); + secdebug("SecAccess", "%p compiling entry %ld", this, acl[n].handle()); mAcls[acl[n].handle()] = new ACL(*this, acl[n]); } - debug("SecAccess", "%p %ld entries compiled", this, mAcls.size()); + secdebug("SecAccess", "%p %ld entries compiled", this, mAcls.size()); } diff --git a/Keychain/Access.h b/Keychain/Access.h index 59f90802..ca2acd7b 100644 --- a/Keychain/Access.h +++ b/Keychain/Access.h @@ -39,6 +39,8 @@ using CssmClient::AclBearer; class Access : public SecCFObject { NOCOPY(Access) public: + SECCFFUNCTIONS(Access, SecAccessRef, errSecInvalidItemRef) + class Maker { NOCOPY(Maker) static const size_t keySize = 16; // number of (random) bytes @@ -75,8 +77,7 @@ public: // make from CSSM layer information (presumably retrieved by caller) Access(const CSSM_ACL_OWNER_PROTOTYPE &owner, uint32 aclCount, const CSSM_ACL_ENTRY_INFO *acls); - - virtual ~Access(); + virtual ~Access() throw(); public: CFArrayRef copySecACLs() const; @@ -101,6 +102,9 @@ public: void addApplicationToRight(AclAuthorization right, TrustedApplication *app); + void copyOwnerAndAcl(CSSM_ACL_OWNER_PROTOTYPE * &owner, + uint32 &aclCount, CSSM_ACL_ENTRY_INFO * &acls); + protected: void makeStandard(const string &description, const ACL::ApplicationList &trusted, const AclAuthorizationSet &limitedRights = AclAuthorizationSet(), @@ -112,7 +116,7 @@ protected: private: static const CSSM_ACL_HANDLE ownerHandle = ACL::ownerHandle; - typedef map > Map; + typedef map > Map; Map mAcls; // set of ACL entries }; diff --git a/Keychain/CCallbackMgr.cp b/Keychain/CCallbackMgr.cp index 9ab09043..5fc770bd 100644 --- a/Keychain/CCallbackMgr.cp +++ b/Keychain/CCallbackMgr.cp @@ -71,7 +71,7 @@ CCallbackMgr *CCallbackMgr::mCCallbackMgr; CCallbackMgr::CCallbackMgr() : // register for receiving Keychain events via CF - Observer(kSecEventNotificationName, NULL, CFNotificationSuspensionBehaviorDeliverImmediately) + Observer(Listener::databaseNotifications, Listener::allEvents) { } @@ -135,15 +135,11 @@ void CCallbackMgr::AlertClients(SecKeychainEvent inEvent, const Keychain &inKeychain, const Item &inItem) { - debug("kcnotify", "dispatch event %d pid %d keychain %p item %p", + secdebug("kcnotify", "dispatch event %ld pid %d keychain %p item %p", inEvent, inPid, &inKeychain, !!inItem ? &*inItem : NULL); // Deal with events that we care about ourselves first. - if (inEvent == kSecDefaultChangedEvent) - globals().defaultKeychain.reload(true); - else if (inEvent == kSecKeychainListChangedEvent) - globals().storageManager.reload(true); - else if (inEvent == kSecDeleteEvent && inKeychain.get() && inItem.get()) + if (inEvent == kSecDeleteEvent && inKeychain.get() && inItem.get()) inKeychain->didDeleteItem(inItem.get()); // Iterate through callbacks, looking for those registered for inEvent @@ -157,11 +153,13 @@ void CCallbackMgr::AlertClients(SecKeychainEvent inEvent, SecKeychainCallbackInfo cbInfo; cbInfo.version = 0; // @@@ kKeychainAPIVersion; - cbInfo.item = inItem ? gTypes().item.handle(*inItem) : 0; - cbInfo.keychain = inKeychain ? gTypes().keychain.handle(*inKeychain) : 0; + cbInfo.item = inItem ? inItem->handle() : 0; + cbInfo.keychain = inKeychain ? inKeychain->handle() : 0; cbInfo.pid = inPid; ix->mCallback(inEvent, &cbInfo, ix->mContext); + if (cbInfo.item) CFRelease(cbInfo.item); + if (cbInfo.keychain) CFRelease(cbInfo.keychain); } } @@ -177,43 +175,37 @@ void CCallbackMgr::AlertClients(SecKeychainEvent inEvent, * If it wasn't 'us', we should remove our cached reference to the item that was deleted. * ***********************************************************************************/ -void CCallbackMgr::Event(CFNotificationCenterRef center, - CFStringRef name, - const void *object, - CFDictionaryRef userInfo) +void CCallbackMgr::Event (Listener::Domain domain, Listener::Event whichEvent, NameValueDictionary &dictionary) { // Decode from userInfo the event type, 'keychain' CFDict, and 'item' CFDict - CCFValue event(CFDictionaryGetValue( userInfo, kSecEventTypeKey )); - SecKeychainEvent thisEvent = 0; - if (!event.hasValue()) - return; + SecKeychainEvent thisEvent = whichEvent; - thisEvent = sint32( event ); - - CFNumberRef pid = reinterpret_cast - (CFDictionaryGetValue(userInfo, kSecEventPidKey)); pid_t thisPid; - if (!pid || !CFNumberGetValue(pid, kCFNumberSInt32Type, &thisPid)) + const NameValuePair* pidRef = dictionary.FindByName (PID_KEY); + if (pidRef == 0) { thisPid = 0; - } - - CFDictionaryRef kc = reinterpret_cast - (CFDictionaryGetValue(userInfo, kSecEventKeychainKey)); - Keychain thisKeychain; - if (kc) - { - thisKeychain = globals().storageManager.keychain - (DLDbListCFPref::cfDictionaryRefToDLDbIdentifier(kc)); - } + } + else + { + thisPid = *reinterpret_cast(pidRef->Value ().data ()); + } - CFDataRef item = reinterpret_cast - (CFDictionaryGetValue(userInfo, kSecEventItemKey)); + Keychain thisKeychain = 0; + + // make sure we have a database identifier + if (dictionary.FindByName (SSUID_KEY) != 0) + { + DLDbIdentifier dbid = NameValueDictionary::MakeDLDbIdentifierFromNameValueDictionary (dictionary); + thisKeychain = globals().storageManager.keychain (dbid); + } + + const NameValuePair* item = dictionary.FindByName (ITEM_KEY); Item thisItem; + if (item && thisKeychain) { - const CssmData pkData(const_cast(CFDataGetBytePtr(item)), CFDataGetLength(item)); - PrimaryKey pk(pkData); + PrimaryKey pk(item->Value ()); thisItem = thisKeychain->item(pk); } diff --git a/Keychain/CCallbackMgr.h b/Keychain/CCallbackMgr.h index 401dc351..be58f280 100644 --- a/Keychain/CCallbackMgr.h +++ b/Keychain/CCallbackMgr.h @@ -60,7 +60,7 @@ typedef list::iterator CallbackInfoListIterator; typedef list::const_iterator ConstCallbackInfoListIterator; -class CCallbackMgr : Observer +class CCallbackMgr : private Observer { public: @@ -79,11 +79,8 @@ public: private: - virtual void Event ( CFNotificationCenterRef center, - CFStringRef name, - const void* object, - CFDictionaryRef userInfo ); - + void Event (Listener::Domain domain, Listener::Event whichEvent, NameValueDictionary &dictionary); + static void AlertClients( SecKeychainEvent inEvent, pid_t inPid, const Keychain& inKeychain, const Item &inItem); diff --git a/Keychain/Certificate.cpp b/Keychain/Certificate.cpp index 4cdbff24..60129d9d 100644 --- a/Keychain/Certificate.cpp +++ b/Keychain/Certificate.cpp @@ -21,8 +21,15 @@ #include #include #include +#include #include +#include #include +#include +#include +#include +#include "CLFieldsCommon.h" + using namespace KeychainCore; @@ -38,7 +45,8 @@ Certificate::Certificate(const CSSM_DATA &data, CSSM_CERT_TYPE type, CSSM_CERT_E mType(type), mEncoding(encoding), mCL(clForType(type)), - mCertHandle(0) + mCertHandle(0), + mV1SubjectPublicKeyCStructValue(NULL) { } @@ -47,7 +55,8 @@ Certificate::Certificate(const Keychain &keychain, const PrimaryKey &primaryKey, ItemImpl(keychain, primaryKey, uniqueId), mHaveTypeAndEncoding(false), mCL(NULL), - mCertHandle(0) + mCertHandle(0), + mV1SubjectPublicKeyCStructValue(NULL) { } @@ -56,7 +65,8 @@ Certificate::Certificate(const Keychain &keychain, const PrimaryKey &primaryKey) ItemImpl(keychain, primaryKey), mHaveTypeAndEncoding(false), mCL(NULL), - mCertHandle(0) + mCertHandle(0), + mV1SubjectPublicKeyCStructValue(NULL) { // @@@ In this case we don't know the type... } @@ -67,13 +77,17 @@ Certificate::Certificate(Certificate &certificate) : mType(certificate.mType), mEncoding(certificate.mEncoding), mCL(certificate.mCL), - mCertHandle(0) + mCertHandle(0), + mV1SubjectPublicKeyCStructValue(NULL) { } -Certificate::~Certificate() +Certificate::~Certificate() throw() { - if (mCertHandle) + if (mV1SubjectPublicKeyCStructValue) + releaseFieldValue(CSSMOID_X509V1SubjectPublicKeyCStruct, mV1SubjectPublicKeyCStructValue); + + if (mCertHandle && mCL) CSSM_CL_CertAbortCache(mCL->handle(), mCertHandle); } @@ -83,7 +97,7 @@ Certificate::certHandle() const CSSM_DATA *cert = &data(); if (!mCertHandle) { - if (CSSM_RETURN retval = CSSM_CL_CertCache(mCL->handle(), cert, &mCertHandle)) + if (CSSM_RETURN retval = CSSM_CL_CertCache(clHandle(), cert, &mCertHandle)) CssmError::throwMe(retval); } @@ -94,13 +108,13 @@ Certificate::certHandle() CSSM_DATA_PTR * Certificate::copyFieldValues(const CSSM_OID &field) { - CSSM_CL_HANDLE clHandle = mCL->handle(); + CSSM_CL_HANDLE clh = clHandle(); CSSM_DATA_PTR fieldValue, *fieldValues; CSSM_HANDLE resultsHandle = 0; uint32 numberOfFields = 0; CSSM_RETURN result; - result = CSSM_CL_CertGetFirstCachedFieldValue(clHandle, certHandle(), &field, &resultsHandle, &numberOfFields, &fieldValue); + result = CSSM_CL_CertGetFirstCachedFieldValue(clh, certHandle(), &field, &resultsHandle, &numberOfFields, &fieldValue); if (result) { if (result == CSSMERR_CL_NO_FIELD_VALUES) @@ -115,7 +129,7 @@ Certificate::copyFieldValues(const CSSM_OID &field) for (uint32 value = 1; value < numberOfFields; ++value) { - CSSM_RETURN cresult = CSSM_CL_CertGetNextCachedFieldValue(clHandle, resultsHandle, &fieldValues[value]); + CSSM_RETURN cresult = CSSM_CL_CertGetNextCachedFieldValue(clh, resultsHandle, &fieldValues[value]); if (cresult) { fieldValues[value] = NULL; @@ -138,10 +152,10 @@ Certificate::releaseFieldValues(const CSSM_OID &field, CSSM_DATA_PTR *fieldValue { if (fieldValues) { - CSSM_CL_HANDLE clHandle = mCL->handle(); + CSSM_CL_HANDLE clh = clHandle(); for (int ix = 0; fieldValues[ix]; ++ix) - CSSM_CL_FreeFieldValue(clHandle, &field, fieldValues[ix]); + CSSM_CL_FreeFieldValue(clh, &field, fieldValues[ix]); delete[] fieldValues; } @@ -165,13 +179,13 @@ Certificate::addParsedAttribute(const CSSM_DB_ATTRIBUTE_INFO &info, const CSSM_O CSSM_DATA_PTR Certificate::copyFirstFieldValue(const CSSM_OID &field) { - CSSM_CL_HANDLE clHandle = mCL->handle(); + CSSM_CL_HANDLE clh = clHandle(); CSSM_DATA_PTR fieldValue; CSSM_HANDLE resultsHandle = 0; uint32 numberOfFields = 0; CSSM_RETURN result; - result = CSSM_CL_CertGetFirstCachedFieldValue(clHandle, certHandle(), &field, &resultsHandle, &numberOfFields, &fieldValue); + result = CSSM_CL_CertGetFirstCachedFieldValue(clh, certHandle(), &field, &resultsHandle, &numberOfFields, &fieldValue); if (result) { if (result == CSSMERR_CL_NO_FIELD_VALUES) @@ -180,7 +194,7 @@ Certificate::copyFirstFieldValue(const CSSM_OID &field) CssmError::throwMe(result); } - result = CSSM_CL_CertAbortQuery(clHandle, resultsHandle); + result = CSSM_CL_CertAbortQuery(clh, resultsHandle); if (result) { @@ -196,8 +210,8 @@ Certificate::releaseFieldValue(const CSSM_OID &field, CSSM_DATA_PTR fieldValue) { if (fieldValue) { - CSSM_CL_HANDLE clHandle = mCL->handle(); - CSSM_CL_FreeFieldValue(clHandle, &field, fieldValue); + CSSM_CL_HANDLE clh = clHandle(); + CSSM_CL_FreeFieldValue(clh, &field, fieldValue); } } @@ -211,22 +225,12 @@ Certificate::releaseFieldValue(const CSSM_OID &field, CSSM_DATA_PTR fieldValue) value of the BIT STRING subjectPublicKey (excluding the tag, length, and number of unused bits). */ -void -Certificate::publicKeyHash(CssmData &digestData) +const CssmData & +Certificate::publicKeyHash() { -#if 0 - CSSM_DATA_PTR *keysPtr = copyFieldValues(CSSMOID_X509V1SubjectPublicKey); + if (mPublicKeyHash.Length) + return mPublicKeyHash; - if (keysPtr && keysPtr[0]) - { - CssmData &key = CssmData::overlay(*keysPtr[0]); - CssmClient::CSP csp(gGuidAppleCSP); - CssmClient::Digest digest(csp, CSSM_ALGID_SHA1); - digest.digest(key, digestData); - } - - releaseFieldValues(CSSMOID_X509V1SubjectPublicKey, keysPtr); -#else CSSM_DATA_PTR keyPtr = copyFirstFieldValue(CSSMOID_CSSMKeyStruct); if (keyPtr && keyPtr->Data) { @@ -236,55 +240,178 @@ Certificate::publicKeyHash(CssmData &digestData) void *outData; CssmData *cssmData; - /* Given a CSSM_KEY_PTR in any format, obtain the SSHA-1 hash of the - * associated key blob. - * Key is specified in CSSM_CSP_CreatePassThroughContext. - * Hash is allocated bythe CSP, in the App's memory, and returned - * in *outData. */ + /* Given a CSSM_KEY_PTR in any format, obtain the SHA-1 hash of the + * associated key blob. + * Key is specified in CSSM_CSP_CreatePassThroughContext. + * Hash is allocated by the CSP, in the App's memory, and returned + * in *outData. */ passThrough.key(key); passThrough(CSSM_APPLECSP_KEYDIGEST, NULL, &outData); cssmData = reinterpret_cast(outData); - assert(cssmData->Length <= digestData.Length); - digestData.Length = cssmData->Length; - memcpy(digestData.Data, cssmData->Data, cssmData->Length); + + assert(cssmData->Length <= sizeof(mPublicKeyHashBytes)); + mPublicKeyHash.Data = mPublicKeyHashBytes; + mPublicKeyHash.Length = cssmData->Length; + memcpy(mPublicKeyHash.Data, cssmData->Data, cssmData->Length); csp.allocator().free(cssmData->Data); csp.allocator().free(cssmData); } - + releaseFieldValue(CSSMOID_CSSMKeyStruct, keyPtr); -#endif + + return mPublicKeyHash; +} + +/* + * Given an CSSM_X509_NAME, Find the first name/value pair with + * a printable value which matches the specified OID (e.g., CSSMOID_CommonName). + * Returns NULL if none found. + */ +static const CSSM_DATA * +findPrintableField( + const CSSM_X509_NAME &x509Name, + const CSSM_OID *tvpType) // NULL means "any printable field" +{ + for(uint32 rdnDex=0; rdnDexnumberOfPairs; tvpDex++) { + const CSSM_X509_TYPE_VALUE_PAIR *tvpPtr = + &rdnPtr->AttributeTypeAndValue[tvpDex]; + + /* type/value pair: match caller's specified type? */ + if((tvpType != NULL) && + ((tvpPtr->type.Length != tvpType->Length) || + memcmp(tvpPtr->type.Data, tvpType->Data, tvpType->Length))) { + continue; + } + + /* printable? */ + switch(tvpPtr->valueType) { + case BER_TAG_PRINTABLE_STRING: + case BER_TAG_IA5_STRING: + case BER_TAG_T61_STRING: + case BER_TAG_PKIX_UTF8_STRING: + /* success */ + return &tvpPtr->value; + default: + break; + } + } /* for each pair */ + } /* for each RDN */ + + /* no printable component of specified type found */ + return NULL; +} + +/* + * Infer printable label for a given an CSSM_X509_NAME. Returns NULL + * if no appropriate printable name found. + */ +const CSSM_DATA *SecInferLabelFromX509Name( + const CSSM_X509_NAME *x509Name) +{ + const CSSM_DATA *printValue; + /* + * Search order (take the first one found with a printable + * value): + * -- common name + * -- Orgnaizational Unit + * -- Organization + * -- field of any kind + */ + printValue = findPrintableField(*x509Name, &CSSMOID_CommonName); + if(printValue != NULL) { + return printValue; + } + printValue = findPrintableField(*x509Name, &CSSMOID_OrganizationalUnitName); + if(printValue != NULL) { + return printValue; + } + printValue = findPrintableField(*x509Name, &CSSMOID_OrganizationName); + if(printValue != NULL) { + return printValue; + } + /* take anything */ + return findPrintableField(*x509Name, NULL); } void -Certificate::addLabel() +Certificate::inferLabel(bool addLabel, CFStringRef *rtnString) { - // Set label attribute for this certificate, based on the X509 subject name. - const CSSM_OID &fieldOid = CSSMOID_X509V1SubjectNameCStruct; - CSSM_DATA_PTR fieldValue = copyFirstFieldValue(fieldOid); - if (fieldValue && fieldValue->Data) + // Set PrintName and optionally the Alias attribute for this certificate, based on the + // X509 SubjectAltName and SubjectName. + const CSSM_DATA *printName = NULL; + std::vector emailAddresses; + CSSM_DATA puntData; + + // Find the SubjectAltName fields, if any, and extract all the GNT_RFC822Name entries from all of them + const CSSM_OID &sanOid = CSSMOID_SubjectAltName; + CSSM_DATA_PTR *sanValues = copyFieldValues(sanOid); + const CSSM_OID &snOid = CSSMOID_X509V1SubjectNameCStruct; + CSSM_DATA_PTR snValue = copyFirstFieldValue(snOid); + + getEmailAddresses(sanValues, snValue, emailAddresses); + + if (snValue && snValue->Data) { - CSSM_X509_NAME_PTR x509Name = (CSSM_X509_NAME_PTR)fieldValue->Data; - CSSM_X509_TYPE_VALUE_PAIR *ptvp=0; - CSSM_X509_RDN_PTR rdnp; - unsigned int rdnDex, pairDex; - - // iterate through all RDN pairs; ptvp points to last entry when done - if (x509Name->numberOfRDNs) { - rdnp = &x509Name->RelativeDistinguishedName[x509Name->numberOfRDNs-1]; - if (rdnp->numberOfPairs) - ptvp = &rdnp->AttributeTypeAndValue[rdnp->numberOfPairs-1]; + const CSSM_X509_NAME &x509Name = *(const CSSM_X509_NAME *)snValue->Data; + printName = SecInferLabelFromX509Name(&x509Name); + } + + if (printName == NULL) + { + /* If the we couldn't find a label use the emailAddress instead. */ + if (!emailAddresses.empty()) + printName = &emailAddresses[0]; + else + { + /* punt! */ + puntData.Data = (uint8 *)"X509 Certificate"; + puntData.Length = 16; + printName = &puntData; } - if (ptvp) + } + + /* If we couldn't find an email address just use the printName which might be the url or something else useful. */ + if (emailAddresses.empty()) + emailAddresses.push_back(CssmData::overlay(*printName)); + + /* Do a check to see if a '\0' was at the end of printName and strip it. */ + CssmData cleanedUpPrintName(printName->Data, printName->Length); + if (cleanedUpPrintName.Length && cleanedUpPrintName.Data[cleanedUpPrintName.Length - 1] == '\0') + cleanedUpPrintName.Length--; + + /* What do we do with the inferred label - return it or add it mDbAttributes? */ + if (addLabel) + { + mDbAttributes->add(Schema::kX509CertificatePrintName, cleanedUpPrintName); + CssmDbAttributeData &attrData = mDbAttributes->add(Schema::kX509CertificateAlias); + + /* Add the email addresses to attrData and normalize them. */ + uint32 ix = 0; + for (std::vector::const_iterator it = emailAddresses.begin(); it != emailAddresses.end(); ++it, ++ix) { - CSSM_BER_TAG btag = ptvp->valueType; - if (btag==BER_TAG_PRINTABLE_STRING || btag==BER_TAG_IA5_STRING || - btag==BER_TAG_T61_STRING || btag==BER_TAG_PKIX_UTF8_STRING) - { - mDbAttributes->add(Schema::attributeInfo(kSecLabelItemAttr), ptvp->value); - } + /* Add the email address using the allocator from mDbAttributes. */ + attrData.add(*it, *mDbAttributes); + /* Normalize the emailAddresses in place since attrData already copied it. */ + normalizeEmailAddress(attrData.Value[ix]); } - releaseFieldValue(fieldOid, fieldValue); } + + if (rtnString) + { + /* Encoding is kCFStringEncodingUTF8 since the string is either + PRINTABLE_STRING, IA5_STRING, T61_STRING or PKIX_UTF8_STRING. */ + *rtnString = CFStringCreateWithBytes(NULL, cleanedUpPrintName.Data, + (CFIndex)cleanedUpPrintName.Length, kCFStringEncodingUTF8, true); + } + + // Clean up + if (snValue) + releaseFieldValue(snOid, snValue); + if (sanValues) + releaseFieldValues(sanOid, sanValues); } void @@ -312,13 +439,8 @@ Certificate::populateAttributes() mDbAttributes->add(Schema::attributeInfo(kSecCertTypeItemAttr), mType); mDbAttributes->add(Schema::attributeInfo(kSecCertEncodingItemAttr), mEncoding); - - uint8 digestBytes[20]; - CssmData digestData(digestBytes, 20); - publicKeyHash(digestData); - - mDbAttributes->add(Schema::attributeInfo(kSecPublicKeyHashItemAttr), digestData); - addLabel(); + mDbAttributes->add(Schema::attributeInfo(kSecPublicKeyHashItemAttr), publicKeyHash()); + inferLabel(true); } const CssmData & @@ -371,6 +493,115 @@ Certificate::encoding() return mEncoding; } +const CSSM_X509_ALGORITHM_IDENTIFIER * +Certificate::algorithmID() +{ + if (!mV1SubjectPublicKeyCStructValue) + mV1SubjectPublicKeyCStructValue = copyFirstFieldValue(CSSMOID_X509V1SubjectPublicKeyCStruct); + + CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *info = (CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *)mV1SubjectPublicKeyCStructValue->Data; + CSSM_X509_ALGORITHM_IDENTIFIER *algid = &info->algorithm; + return algid; +} + +CFStringRef +Certificate::commonName() +{ + CFStringRef rtnString; + const CSSM_OID &fieldOid = CSSMOID_X509V1SubjectNameCStruct; + CSSM_DATA_PTR fieldValue = copyFirstFieldValue(fieldOid); + CSSM_X509_NAME_PTR x509Name = (CSSM_X509_NAME_PTR)fieldValue->Data; + const CSSM_DATA *printValue = NULL; + if (fieldValue && fieldValue->Data) + printValue = findPrintableField(*x509Name, &CSSMOID_CommonName); + + if (printValue == NULL) + rtnString = NULL; + else + { + /* Encoding is kCFStringEncodingUTF8 since the string is either + PRINTABLE_STRING, IA5_STRING, T61_STRING or PKIX_UTF8_STRING. */ + rtnString = CFStringCreateWithBytes(NULL, printValue->Data, + (CFIndex)printValue->Length, kCFStringEncodingUTF8, true); + } + + releaseFieldValue(CSSMOID_X509V1SubjectNameCStruct, fieldValue); + + return rtnString; +} + +/* + * Return a CFString containing the first email addresses for this certificate, based on the + * X509 SubjectAltName and SubjectName. + */ +CFStringRef +Certificate::copyFirstEmailAddress() +{ + CFStringRef rtnString; + + const CSSM_OID &sanOid = CSSMOID_SubjectAltName; + CSSM_DATA_PTR *sanValues = copyFieldValues(sanOid); + const CSSM_OID &snOid = CSSMOID_X509V1SubjectNameCStruct; + CSSM_DATA_PTR snValue = copyFirstFieldValue(snOid); + std::vector emailAddresses; + + getEmailAddresses(sanValues, snValue, emailAddresses); + if (emailAddresses.empty()) + rtnString = NULL; + else + { + /* Encoding is kCFStringEncodingUTF8 since the string is either + PRINTABLE_STRING, IA5_STRING, T61_STRING or PKIX_UTF8_STRING. */ + rtnString = CFStringCreateWithBytes(NULL, emailAddresses[0].Data, + (CFIndex)emailAddresses[0].Length, kCFStringEncodingUTF8, true); + } + + // Clean up + if (snValue) + releaseFieldValue(snOid, snValue); + if (sanValues) + releaseFieldValues(sanOid, sanValues); + + return rtnString; +} + +/* + * Return a CFArray containing the email addresses for this certificate, based on the + * X509 SubjectAltName and SubjectName. + */ +CFArrayRef +Certificate::copyEmailAddresses() +{ + CFMutableArrayRef array = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + std::vector emailAddresses; + + // Find the SubjectAltName fields, if any, and extract all the GNT_RFC822Name entries from all of them + const CSSM_OID &sanOid = CSSMOID_SubjectAltName; + CSSM_DATA_PTR *sanValues = copyFieldValues(sanOid); + + const CSSM_OID &snOid = CSSMOID_X509V1SubjectNameCStruct; + CSSM_DATA_PTR snValue = copyFirstFieldValue(snOid); + + getEmailAddresses(sanValues, snValue, emailAddresses); + + for (std::vector::const_iterator it = emailAddresses.begin(); it != emailAddresses.end(); ++it) + { + /* Encoding is kCFStringEncodingUTF8 since the string is either + PRINTABLE_STRING, IA5_STRING, T61_STRING or PKIX_UTF8_STRING. */ + CFStringRef string = CFStringCreateWithBytes(NULL, it->Data, static_cast(it->Length), kCFStringEncodingUTF8, true); + CFArrayAppendValue(array, string); + CFRelease(string); + } + + // Clean up + if (snValue) + releaseFieldValue(snOid, snValue); + if (sanValues) + releaseFieldValues(sanOid, sanValues); + + return array; +} + void Certificate::getSubject(CSSM_X509_NAME &outSubject) { @@ -409,9 +640,15 @@ Certificate::update() } Item -Certificate::copyTo(const Keychain &keychain) +Certificate::copyTo(const Keychain &keychain, Access *newAccess) { - return ItemImpl::copyTo(keychain); + /* Certs can't have access controls. */ + if (newAccess) + MacOSError::throwMe(errSecNoAccessForItem); + + Item item(new Certificate(data(), type(), encoding())); + keychain->add(item); + return item; } void @@ -447,6 +684,7 @@ Certificate::add(Keychain &keychain) Schema::X509CertificateSchemaAttributeList, Schema::X509CertificateSchemaIndexCount, Schema::X509CertificateSchemaIndexList); + keychain->resetSchema(); mUniqueId = db->insert(recordType, mDbAttributes.get(), mData.get()); } @@ -456,3 +694,191 @@ Certificate::add(Keychain &keychain) return mPrimaryKey; } + +SecPointer +Certificate::publicKey() +{ + SecPointer keyItem; + // Return a CSSM_DATA_PTR with the value of the first field specified by field. + // Caller must call releaseFieldValue to free the storage allocated by this call. + // call OSStatus SecKeyGetCSSMKey(SecKeyRef key, const CSSM_KEY **cssmKey); to retrieve + + CSSM_DATA_PTR keyPtr = copyFirstFieldValue(CSSMOID_CSSMKeyStruct); + if (keyPtr && keyPtr->Data) + { + CssmClient::CSP csp(gGuidAppleCSP); + CssmKey *cssmKey = reinterpret_cast(keyPtr->Data); + CssmClient::Key key(csp, *cssmKey); + keyItem = new KeyItem(key); + // Clear out KeyData since KeyItem() takes over ownership of the key, and we don't want it getting released. + cssmKey->KeyData.Data = NULL; + cssmKey->KeyData.Length = 0; + } + + releaseFieldValue(CSSMOID_CSSMKeyStruct, keyPtr); + + return keyItem; +} + +KCCursor +Certificate::cursorForIssuerAndSN(const StorageManager::KeychainList &keychains, const CssmData &issuer, const CssmData &serialNumber) +{ + CssmAutoData fieldValue(CssmAllocator::standard(CssmAllocator::normal)); + uint32 numFields; + + // We need to decode issuer, normalize it, then re-encode it + if (!getField_normRDN_NSS(issuer, numFields, fieldValue)) + MacOSError::throwMe(errSecDataNotAvailable); + + // Code basically copied from SecKeychainSearchCreateFromAttributes and SecKeychainSearchCopyNext: + KCCursor cursor(keychains, kSecCertificateItemClass, NULL); + cursor->conjunctive(CSSM_DB_AND); + cursor->add(CSSM_DB_EQUAL, Schema::kX509CertificateIssuer, fieldValue.get()); + cursor->add(CSSM_DB_EQUAL, Schema::kX509CertificateSerialNumber, serialNumber); + + return cursor; +} + +KCCursor +Certificate::cursorForSubjectKeyID(const StorageManager::KeychainList &keychains, const CssmData &subjectKeyID) +{ + KCCursor cursor(keychains, kSecCertificateItemClass, NULL); + cursor->conjunctive(CSSM_DB_AND); + cursor->add(CSSM_DB_EQUAL, Schema::kX509CertificateSubjectKeyIdentifier, subjectKeyID); + + return cursor; +} + +KCCursor +Certificate::cursorForEmail(const StorageManager::KeychainList &keychains, const char *emailAddress) +{ + KCCursor cursor(keychains, kSecCertificateItemClass, NULL); + if (emailAddress) + { + cursor->conjunctive(CSSM_DB_AND); + CssmSelectionPredicate &pred = cursor->add(CSSM_DB_EQUAL, Schema::kX509CertificateAlias, emailAddress); + /* Normalize the emailAddresses in place since cursor already copied it. */ + normalizeEmailAddress(pred.Attribute.Value[0]); + } + + return cursor; +} + +SecPointer +Certificate::findByIssuerAndSN(const StorageManager::KeychainList &keychains, const CssmData &issuer, const CssmData &serialNumber) +{ + Item item; + if (!cursorForIssuerAndSN(keychains, issuer, serialNumber)->next(item)) + CssmError::throwMe(errSecItemNotFound); + + return static_cast(&*item); +} + +SecPointer +Certificate::findBySubjectKeyID(const StorageManager::KeychainList &keychains, const CssmData &subjectKeyID) +{ + Item item; + if (!cursorForSubjectKeyID(keychains, subjectKeyID)->next(item)) + CssmError::throwMe(errSecItemNotFound); + + return static_cast(&*item); +} + +SecPointer +Certificate::findByEmail(const StorageManager::KeychainList &keychains, const char *emailAddress) +{ + Item item; + if (!cursorForEmail(keychains, emailAddress)->next(item)) + CssmError::throwMe(errSecItemNotFound); + + return static_cast(&*item); +} + +/* Normalize emailAddresses in place. */ +void +Certificate::normalizeEmailAddress(CSSM_DATA &emailAddress) +{ + /* Do a check to see if a '\0' was at the end of emailAddress and strip it. */ + if (emailAddress.Length && emailAddress.Data[emailAddress.Length - 1] == '\0') + emailAddress.Length--; + bool foundAt = false; + for (uint32 ix = 0; ix < emailAddress.Length; ++ix) + { + uint8 ch = emailAddress.Data[ix]; + if (foundAt) + { + if ('A' <= ch && ch <= 'Z') + emailAddress.Data[ix] = ch + 'a' - 'A'; + } + else if (ch == '@') + foundAt = true; + } +} + +void +Certificate::getEmailAddresses(CSSM_DATA_PTR *sanValues, CSSM_DATA_PTR snValue, std::vector &emailAddresses) +{ + // Get the email addresses for this certificate, based on the + // X509 SubjectAltName and SubjectName. + + // Find the SubjectAltName fields, if any, and extract all the GNT_RFC822Name entries from all of them + if (sanValues) + { + for (CSSM_DATA_PTR *sanIx = sanValues; *sanIx; ++sanIx) + { + CSSM_DATA_PTR sanValue = *sanIx; + if (sanValue && sanValue->Data) + { + CSSM_X509_EXTENSION *cssmExt = (CSSM_X509_EXTENSION *)sanValue->Data; + CE_GeneralNames *parsedValue = (CE_GeneralNames *)cssmExt->value.parsedValue; + + /* Grab all the values that are of type GNT_RFC822Name. */ + for (uint32 i = 0; i < parsedValue->numNames; ++i) + { + if (parsedValue->generalName[i].nameType == GNT_RFC822Name) + { + if (parsedValue->generalName[i].berEncoded) // can't handle this + continue; + + emailAddresses.push_back(CssmData::overlay(parsedValue->generalName[i].name)); + } + } + } + } + } + + if (emailAddresses.empty() && snValue && snValue->Data) + { + const CSSM_X509_NAME &x509Name = *(const CSSM_X509_NAME *)snValue->Data; + for (uint32 rdnDex = 0; rdnDex < x509Name.numberOfRDNs; rdnDex++) + { + const CSSM_X509_RDN *rdnPtr = + &x509Name.RelativeDistinguishedName[rdnDex]; + for (uint32 tvpDex = 0; tvpDex < rdnPtr->numberOfPairs; tvpDex++) + { + const CSSM_X509_TYPE_VALUE_PAIR *tvpPtr = + &rdnPtr->AttributeTypeAndValue[tvpDex]; + + /* type/value pair: match caller's specified type? */ + if (((tvpPtr->type.Length != CSSMOID_EmailAddress.Length) || + memcmp(tvpPtr->type.Data, CSSMOID_EmailAddress.Data, CSSMOID_EmailAddress.Length))) { + continue; + } + + /* printable? */ + switch (tvpPtr->valueType) + { + case BER_TAG_PRINTABLE_STRING: + case BER_TAG_IA5_STRING: + case BER_TAG_T61_STRING: + case BER_TAG_PKIX_UTF8_STRING: + /* success */ + emailAddresses.push_back(CssmData::overlay(tvpPtr->value)); + break; + default: + break; + } + } /* for each pair */ + } /* for each RDN */ + } +} diff --git a/Keychain/Certificate.h b/Keychain/Certificate.h index 99ec2d40..ed052059 100644 --- a/Keychain/Certificate.h +++ b/Keychain/Certificate.h @@ -23,19 +23,25 @@ #include +#include // @@@ This should not be here. #include #include + namespace Security { namespace KeychainCore { +class KeyItem; + class Certificate : public ItemImpl { NOCOPY(Certificate) public: + SECCFFUNCTIONS(Certificate, SecCertificateRef, errSecInvalidItemRef) + static CL clForType(CSSM_CERT_TYPE type); // new item constructor @@ -48,36 +54,53 @@ public: Certificate(const Keychain &keychain, const PrimaryKey &primaryKey); Certificate(Certificate &certificate); - virtual ~Certificate(); + virtual ~Certificate() throw(); virtual void update(); - virtual Item copyTo(const Keychain &keychain); + virtual Item copyTo(const Keychain &keychain, Access *newAccess = NULL); virtual void didModify(); // Forget any attributes and data we just wrote to the db const CssmData &data(); CSSM_CERT_TYPE type(); CSSM_CERT_ENCODING encoding(); + CFStringRef commonName(); + CFStringRef copyFirstEmailAddress(); + CFArrayRef copyEmailAddresses(); void getSubject(CSSM_X509_NAME &outSubject); void getIssuer(CSSM_X509_NAME &outName); + const CSSM_X509_ALGORITHM_IDENTIFIER *algorithmID(); CSSM_CL_HANDLE clHandle(); + void inferLabel(bool addLabel, CFStringRef *rtnString = NULL); + SecPointer publicKey(); + const CssmData &publicKeyHash(); + + static KCCursor cursorForIssuerAndSN(const StorageManager::KeychainList &keychains, const CssmData &issuer, const CssmData &serialNumber); + static KCCursor cursorForSubjectKeyID(const StorageManager::KeychainList &keychains, const CssmData &subjectKeyID); + static KCCursor cursorForEmail(const StorageManager::KeychainList &keychains, const char *emailAddress); + + static SecPointer findByIssuerAndSN(const StorageManager::KeychainList &keychains, const CssmData &issuer, const CssmData &serialNumber); + static SecPointer findBySubjectKeyID(const StorageManager::KeychainList &keychains, const CssmData &subjectKeyID); + static SecPointer findByEmail(const StorageManager::KeychainList &keychains, const char *emailAddress); + + static void normalizeEmailAddress(CSSM_DATA &emailAddress); + static void getEmailAddresses(CSSM_DATA_PTR *sanValues, CSSM_DATA_PTR snValue, std::vector &emailAddresses); bool operator < (Certificate &other); bool operator == (Certificate &other); -protected: - virtual PrimaryKey add(Keychain &keychain); - CSSM_HANDLE certHandle(); +public: + CSSM_DATA_PTR copyFirstFieldValue(const CSSM_OID &field); + void releaseFieldValue(const CSSM_OID &field, CSSM_DATA_PTR fieldValue); CSSM_DATA_PTR *copyFieldValues(const CSSM_OID &field); void releaseFieldValues(const CSSM_OID &field, CSSM_DATA_PTR *fieldValues); - void addParsedAttribute(const CSSM_DB_ATTRIBUTE_INFO &info, const CSSM_OID &field); +protected: + virtual PrimaryKey add(Keychain &keychain); + CSSM_HANDLE certHandle(); - CSSM_DATA_PTR copyFirstFieldValue(const CSSM_OID &field); - void releaseFieldValue(const CSSM_OID &field, CSSM_DATA_PTR fieldValue); + void addParsedAttribute(const CSSM_DB_ATTRIBUTE_INFO &info, const CSSM_OID &field); - void publicKeyHash(CssmData &digestData); - void addLabel(); void populateAttributes(); private: @@ -86,6 +109,9 @@ private: CSSM_CERT_ENCODING mEncoding; CssmClient::CL mCL; CSSM_HANDLE mCertHandle; + CssmData mPublicKeyHash; + uint8 mPublicKeyHashBytes[20]; + CSSM_DATA_PTR mV1SubjectPublicKeyCStructValue; // Hack to prevent algorithmID() from leaking. }; } // end namespace KeychainCore diff --git a/Keychain/CertificateRequest.cpp b/Keychain/CertificateRequest.cpp index 01815b18..6ea5c5bc 100644 --- a/Keychain/CertificateRequest.cpp +++ b/Keychain/CertificateRequest.cpp @@ -26,6 +26,6 @@ CertificateRequest::CertificateRequest(int a) { } -CertificateRequest::~CertificateRequest() +CertificateRequest::~CertificateRequest() throw() { } diff --git a/Keychain/CertificateRequest.h b/Keychain/CertificateRequest.h index 5cec874c..9718f227 100644 --- a/Keychain/CertificateRequest.h +++ b/Keychain/CertificateRequest.h @@ -22,6 +22,7 @@ #define _SECURITY_CERTIFICATEREQUEST_H_ #include +#include namespace Security { @@ -33,8 +34,10 @@ class CertificateRequest : public SecCFObject { NOCOPY(CertificateRequest) public: + SECCFFUNCTIONS(CertificateRequest, SecCertificateRequestRef, errSecInvalidItemRef) + CertificateRequest(int a); - virtual ~CertificateRequest(); + virtual ~CertificateRequest() throw(); private: }; diff --git a/Keychain/DLDBListCFPref.cpp b/Keychain/DLDBListCFPref.cpp index f7ee77d1..5bce8449 100644 --- a/Keychain/DLDBListCFPref.cpp +++ b/Keychain/DLDBListCFPref.cpp @@ -22,13 +22,24 @@ #include "DLDBListCFPref.h" #include +#include +#include #include +#include +#include +#include +#include #include using namespace CssmClient; static const double kDLDbListCFPrefRevertInterval = 30.0; +// normal debug calls, which get stubbed out for deployment builds +#define x_debug(str) secdebug("KClogin",(str)) +#define x_debug1(fmt,arg1) secdebug("KClogin",(fmt),(arg1)) +#define x_debug2(fmt,arg1,arg2) secdebug("KClogin",(fmt),(arg1),(arg2)) + #define kKeyGUID CFSTR("GUID") #define kKeySubserviceId CFSTR("SubserviceId") #define kKeySubserviceType CFSTR("SubserviceType") @@ -38,8 +49,49 @@ static const double kDLDbListCFPrefRevertInterval = 30.0; #define kKeyMajorVersion CFSTR("MajorVersion") #define kKeyMinorVersion CFSTR("MinorVersion") #define kDefaultDLDbListKey CFSTR("DLDBSearchList") -#define kDefaultDomain CFSTR("com.apple.security") +#define kDefaultKeychainKey CFSTR("DefaultKeychain") +#define kLoginKeychainKey CFSTR("LoginKeychain") +#define kUserDefaultPath "~/Library/Preferences/com.apple.security.plist" +#define kSystemDefaultPath "/Library/Preferences/com.apple.security.plist" +#define kCommonDefaultPath "/Library/Preferences/com.apple.security-common.plist" +#define kLoginKeychainPathPrefix "~/Library/Keychains/" +#define kUserLoginKeychainPath "~/Library/Keychains/login.keychain" +#define kSystemLoginKeychainPath "/Library/Keychains/System.keychain" + + +// A utility class for managing password database lookups +const time_t kPasswordCacheExpire = 30; // number of seconds cached password db info is valid + +PasswordDBLookup::PasswordDBLookup () : mValid (false), mCurrent (0), mTime (0) +{ +} + +void PasswordDBLookup::lookupInfoOnUID (uid_t uid) +{ + time_t currentTime = time (NULL); + + if (!mValid || uid != mCurrent || currentTime - mTime >= kPasswordCacheExpire) + { + struct passwd* pw = getpwuid(uid); + if (pw == NULL) + { + UnixError::throwMe (EPERM); + } + + mDirectory = pw->pw_dir; + mName = pw->pw_name; + mValid = true; + mCurrent = uid; + mTime = currentTime; + + x_debug2("PasswordDBLookup::lookupInfoOnUID: uid=%d caching home=%s", uid, pw->pw_dir); + + endpwent(); + } +} + +PasswordDBLookup *DLDbListCFPref::mPdbLookup = NULL; //------------------------------------------------------------------------------------- // @@ -47,80 +99,370 @@ static const double kDLDbListCFPrefRevertInterval = 30.0; // //------------------------------------------------------------------------------------- -DLDbListCFPref::DLDbListCFPref(CFStringRef theDLDbListKey,CFStringRef prefsDomain) : - mPrefsDomain(prefsDomain?prefsDomain:kDefaultDomain),mDLDbListKey(theDLDbListKey?theDLDbListKey:kDefaultDLDbListKey) +DLDbListCFPref::DLDbListCFPref(SecPreferencesDomain domain) : mDomain(domain), mPropertyList(NULL), mChanged(false), + mSearchListSet(false), mDefaultDLDbIdentifierSet(false), mLoginDLDbIdentifierSet(false) { - loadOrCreate(); + x_debug2("New DLDbListCFPref %p for domain %d", this, domain); + loadPropertyList(true); +} + +void DLDbListCFPref::set(SecPreferencesDomain domain) +{ + save(); + + mDomain = domain; + + x_debug2("DLDbListCFPref %p domain set to %d", this, domain); + + if (loadPropertyList(true)) + resetCachedValues(); } DLDbListCFPref::~DLDbListCFPref() { save(); + + x_debug1("~DLDbListCFPref %p", this); + + if (mPropertyList) + CFRelease(mPropertyList); } -void DLDbListCFPref::loadOrCreate() +bool +DLDbListCFPref::loadPropertyList(bool force) { - - CFRef theArray(static_cast(::CFPreferencesCopyValue(mDLDbListKey, mPrefsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost))); - if (!theArray) - return; + string prefsPath; - if (::CFGetTypeID(theArray)!=::CFArrayGetTypeID()) + switch (mDomain) { - ::CFPreferencesSetValue(mDLDbListKey, NULL, mPrefsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - return; - } - - CFIndex top=::CFArrayGetCount(theArray); - // Each entry is a CFDictionary; peel it off & add it to the array - for (CFIndex idx=0;idx(::CFArrayGetValueAtIndex(theArray,idx)); - DLDbIdentifier theDLDbIdentifier=cfDictionaryRefToDLDbIdentifier(theDict); - push_back(theDLDbIdentifier); + mPrefsPath = prefsPath; + if (mPropertyList) + { + CFRelease(mPropertyList); + mPropertyList = NULL; + } + + mPrefsTimeStamp = now; } - - - mPrefsTimeStamp=CFAbsoluteTimeGetCurrent(); + else if (!force) + { + if (now - mPrefsTimeStamp < kDLDbListCFPrefRevertInterval) + return false; + + mPrefsTimeStamp = now; + } + + struct stat st; + if (stat(mPrefsPath.c_str(), &st)) + { + if (errno == ENOENT) + { + if (mPropertyList) + { + if (CFDictionaryGetCount(mPropertyList) == 0) + return false; + CFRelease(mPropertyList); + } + + mPropertyList = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + return true; + } + } + else + { + if (mPropertyList) + { + if (mTimespec.tv_sec == st.st_mtimespec.tv_sec + && mTimespec.tv_nsec == st.st_mtimespec.tv_nsec) + return false; + } + + mTimespec = st.st_mtimespec; + } + + CFMutableDictionaryRef thePropertyList = NULL; + CFMutableDataRef xmlData = NULL; + CFStringRef errorString = NULL; + int fd = -1; + + do + { + fd = open(mPrefsPath.c_str(), O_RDONLY, 0); + if (fd < 0) + break; + + off_t theSize = lseek(fd, 0, SEEK_END); + if (theSize <= 0) + break; + + if (lseek(fd, 0, SEEK_SET)) + break; + + xmlData = CFDataCreateMutable(NULL, CFIndex(theSize)); + if (!xmlData) + break; + CFDataSetLength(xmlData, CFIndex(theSize)); + void *buffer = reinterpret_cast(CFDataGetMutableBytePtr(xmlData)); + if (!buffer) + break; + ssize_t bytesRead = read(fd, buffer, theSize); + if (bytesRead != theSize) + break; + + thePropertyList = CFMutableDictionaryRef(CFPropertyListCreateFromXMLData(NULL, xmlData, kCFPropertyListMutableContainers, &errorString)); + if (!thePropertyList) + break; + + if (CFGetTypeID(thePropertyList) != CFDictionaryGetTypeID()) + { + CFRelease(thePropertyList); + thePropertyList = NULL; + break; + } + } while (0); + + if (fd >= 0) + close(fd); + if (xmlData) + CFRelease(xmlData); + if (errorString) + CFRelease(errorString); + + if (!thePropertyList) + { + thePropertyList = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + } + if (mPropertyList) + { + if (CFEqual(mPropertyList, thePropertyList)) + { + // The new property list is the same as the old one, so nothing has changed. + CFRelease(thePropertyList); + return false; + } + CFRelease(mPropertyList); + } + mPropertyList = thePropertyList; + return true; } -void DLDbListCFPref::save() +void +DLDbListCFPref::writePropertyList() { - if (!hasChanged()) - return; - // Make a temporary CFArray with the contents of the vector - CFRef theArray(::CFArrayCreateMutable(kCFAllocatorDefault,size(),&kCFTypeArrayCallBacks)); - for (DLDbList::const_iterator ix=begin();ix!=end();ix++) + if (!mPropertyList || CFDictionaryGetCount(mPropertyList) == 0) { - CFRef aDict(dlDbIdentifierToCFDictionaryRef(*ix)); - ::CFArrayAppendValue(theArray,aDict); + // There is nothing in the mPropertyList dictionary, + // so we don't need a prefs file. + unlink(mPrefsPath.c_str()); } + else + { + CFDataRef xmlData = CFPropertyListCreateXMLData(NULL, mPropertyList); + if (!xmlData) + return; // Bad out of memory or something evil happened let's act like CF and do nothing. + + mode_t mode = 0666; + int fd = open(mPrefsPath.c_str(), O_WRONLY|O_CREAT|O_TRUNC, mode); + if (fd >= 0) + { + const void *buffer = CFDataGetBytePtr(xmlData); + size_t toWrite = CFDataGetLength(xmlData); + /* ssize_t bytesWritten = */ write(fd, buffer, toWrite); + // Emulate CFPreferences by not checking for any errors. + + fsync(fd); + struct stat st; + if (!fstat(fd, &st)) + mTimespec = st.st_mtimespec; - ::CFPreferencesSetValue(mDLDbListKey, theArray, mPrefsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - ::CFPreferencesSynchronize(mPrefsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + close(fd); + } - changed(false); + CFRelease(xmlData); + } + + mPrefsTimeStamp = CFAbsoluteTimeGetCurrent(); } -void DLDbListCFPref::clearDefaultKeychain() +void +DLDbListCFPref::resetCachedValues() { - ::CFPreferencesSetValue(mDLDbListKey, NULL, mPrefsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - ::CFPreferencesSynchronize(mPrefsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - - changed(false); + // Unset the login and default Keychain. + mLoginDLDbIdentifier = mDefaultDLDbIdentifier = DLDbIdentifier(); + + // Clear the searchList. + mSearchList.clear(); + + changed(false); + + // Note that none of our cached values are valid + mSearchListSet = mDefaultDLDbIdentifierSet = mLoginDLDbIdentifierSet = false; + + mPrefsTimeStamp = CFAbsoluteTimeGetCurrent(); } +void DLDbListCFPref::save() +{ + if (!hasChanged()) + return; + + // Resync from disc to make sure we don't clobber anyone elses changes. + // @@@ This is probably already done by the next layer up so we don't + // really need to do it here again. + loadPropertyList(true); + + // Do the searchList first since it might end up invoking defaultDLDbIdentifier() which can set + // mLoginDLDbIdentifierSet and mDefaultDLDbIdentifierSet to true. + if (mSearchListSet) + { + // Make a temporary CFArray with the contents of the vector + if (mSearchList.size() == 1 && mSearchList[0] == defaultDLDbIdentifier() && mSearchList[0] == LoginDLDbIdentifier()) + { + // The only element in the search list is the default keychain, which is a + // post Jaguar style login keychain, so omit the entry from the prefs file. + CFDictionaryRemoveValue(mPropertyList, kDefaultDLDbListKey); + } + else + { + CFMutableArrayRef searchArray = CFArrayCreateMutable(kCFAllocatorDefault, mSearchList.size(), &kCFTypeArrayCallBacks); + for (DLDbList::const_iterator ix=mSearchList.begin();ix!=mSearchList.end();ix++) + { + CFDictionaryRef aDict = dlDbIdentifierToCFDictionaryRef(*ix); + CFArrayAppendValue(searchArray, aDict); + CFRelease(aDict); + } + + CFDictionarySetValue(mPropertyList, kDefaultDLDbListKey, searchArray); + CFRelease(searchArray); + } + } + + if (mLoginDLDbIdentifierSet) + { + // Make a temporary CFArray with the login keychain + CFArrayRef loginArray = NULL; + if (!mLoginDLDbIdentifier) + { + loginArray = CFArrayCreate(kCFAllocatorDefault, NULL, 0, &kCFTypeArrayCallBacks); + } + else if (!(mLoginDLDbIdentifier == LoginDLDbIdentifier()) + && !(mLoginDLDbIdentifier == JaguarLoginDLDbIdentifier())) + { + CFDictionaryRef aDict = dlDbIdentifierToCFDictionaryRef(mLoginDLDbIdentifier); + const void *value = reinterpret_cast(aDict); + loginArray = CFArrayCreate(kCFAllocatorDefault, &value, 1, &kCFTypeArrayCallBacks); + CFRelease(aDict); + } + + if (loginArray) + { + CFDictionarySetValue(mPropertyList, kLoginKeychainKey, loginArray); + CFRelease(loginArray); + } + else + CFDictionaryRemoveValue(mPropertyList, kLoginKeychainKey); + } + + if (mDefaultDLDbIdentifierSet) + { + // Make a temporary CFArray with the default keychain + CFArrayRef defaultArray = NULL; + if (!mDefaultDLDbIdentifier) + { + defaultArray = CFArrayCreate(kCFAllocatorDefault, NULL, 0, &kCFTypeArrayCallBacks); + } + else if (!(mDefaultDLDbIdentifier == LoginDLDbIdentifier())) + { + CFDictionaryRef aDict = dlDbIdentifierToCFDictionaryRef(mDefaultDLDbIdentifier); + const void *value = reinterpret_cast(aDict); + defaultArray = CFArrayCreate(kCFAllocatorDefault, &value, 1, &kCFTypeArrayCallBacks); + CFRelease(aDict); + } + + if (defaultArray) + { + CFDictionarySetValue(mPropertyList, kDefaultKeychainKey, defaultArray); + CFRelease(defaultArray); + } + else + CFDictionaryRemoveValue(mPropertyList, kDefaultKeychainKey); + } + + writePropertyList(); + changed(false); +} //---------------------------------------------------------------------- // Conversions //---------------------------------------------------------------------- +DLDbIdentifier DLDbListCFPref::LoginDLDbIdentifier() +{ + CSSM_VERSION theVersion={}; + CssmSubserviceUid ssuid(gGuidAppleCSPDL,&theVersion,0,CSSM_SERVICE_DL|CSSM_SERVICE_CSP); + CssmNetAddress *dbLocation=NULL; + + switch (mDomain) { + case kSecPreferencesDomainUser: + return DLDbIdentifier(ssuid, ExpandTildesInPath(kUserLoginKeychainPath).c_str(), dbLocation); + default: + assert(false); + case kSecPreferencesDomainSystem: + case kSecPreferencesDomainCommon: + return DLDbIdentifier(ssuid, kSystemLoginKeychainPath, dbLocation); + } +} + +DLDbIdentifier DLDbListCFPref::JaguarLoginDLDbIdentifier() +{ + CSSM_VERSION theVersion={}; + CssmSubserviceUid ssuid(gGuidAppleCSPDL,&theVersion,0,CSSM_SERVICE_DL|CSSM_SERVICE_CSP); + CssmNetAddress *dbLocation=NULL; + + switch (mDomain) { + case kSecPreferencesDomainUser: + { + string basepath = ExpandTildesInPath(kLoginKeychainPathPrefix) + getPwInfo(kUsername); + return DLDbIdentifier(ssuid,basepath.c_str(),dbLocation); + } + case kSecPreferencesDomainSystem: + case kSecPreferencesDomainCommon: + return DLDbIdentifier(ssuid, kSystemLoginKeychainPath, dbLocation); + default: + assert(false); + return DLDbIdentifier(); + } +} + DLDbIdentifier DLDbListCFPref::cfDictionaryRefToDLDbIdentifier(CFDictionaryRef theDict) { // We must get individual values from the dictionary and store in basic types + if (CFGetTypeID(theDict) != CFDictionaryGetTypeID()) + throw std::logic_error("wrong type in property list"); // GUID CCFValue vGuid(::CFDictionaryGetValue(theDict,kKeyGUID)); @@ -156,29 +498,60 @@ DLDbIdentifier DLDbListCFPref::cfDictionaryRefToDLDbIdentifier(CFDictionaryRef t return DLDbIdentifier(ssuid,ExpandTildesInPath(dbName).c_str(),dbLocation); } -string DLDbListCFPref::HomeDir() +void DLDbListCFPref::clearPWInfo () { - const char *home = getenv("HOME"); - if (!home) + if (mPdbLookup != NULL) { - // If $HOME is unset get the current users home directory from the passwd file. - struct passwd *pw = getpwuid(getuid()); - if (pw) - home = pw->pw_dir; + delete mPdbLookup; + mPdbLookup = NULL; } - return home ? home : ""; +} + +string DLDbListCFPref::getPwInfo(PwInfoType type) +{ + // Get our effective uid + uid_t uid = geteuid(); + // If we are setuid root use the real uid instead + if (!uid) uid = getuid(); + + // get the password entries + if (mPdbLookup == NULL) + { + mPdbLookup = new PasswordDBLookup (); + } + + mPdbLookup->lookupInfoOnUID (uid); + + string result; + switch (type) + { + case kHomeDir: + result = mPdbLookup->getDirectory (); + break; + case kUsername: + result = mPdbLookup->getName (); + break; + } + + return result; } string DLDbListCFPref::ExpandTildesInPath(const string &inPath) { if ((short)inPath.find("~/",0,2) == 0) - return HomeDir() + inPath.substr(1); + return getPwInfo(kHomeDir) + inPath.substr(1); else return inPath; } string DLDbListCFPref::StripPathStuff(const string &inPath) { + if (inPath.find("/private/var/automount/Network/",0,31) == 0) + return inPath.substr(22); + if (inPath.find("/private/automount/Servers/",0,27) == 0) + return "/Network" + inPath.substr(18); + if (inPath.find("/automount/Servers/",0,19) == 0) + return "/Network" + inPath.substr(10); if (inPath.find("/private/automount/Network/",0,27) == 0) return inPath.substr(18); if (inPath.find("/automount/Network/",0,19) == 0) @@ -191,7 +564,7 @@ string DLDbListCFPref::StripPathStuff(const string &inPath) string DLDbListCFPref::AbbreviatedPath(const string &inPath) { string path = StripPathStuff(inPath); - string home = StripPathStuff(HomeDir() + "/"); + string home = StripPathStuff(getPwInfo(kHomeDir) + "/"); size_t homeLen = home.length(); if (homeLen > 1 && path.find(home.c_str(), 0, homeLen) == 0) @@ -257,18 +630,213 @@ CFDictionaryRef DLDbListCFPref::dlDbIdentifierToCFDictionaryRef(const DLDbIdenti ::CFRetain(aDict); return aDict; } + bool DLDbListCFPref::revert(bool force) { + // If the prefs have not been refreshed in the last kDLDbListCFPrefRevertInterval + // seconds or we are asked to force a reload, then reload. + if (!loadPropertyList(force)) + return false; + + resetCachedValues(); + return true; +} - // if the prefs have not been refreshed in the last 5 seconds force a reload - if (force || CFAbsoluteTimeGetCurrent() - mPrefsTimeStamp > kDLDbListCFPrefRevertInterval) +void +DLDbListCFPref::add(const DLDbIdentifier &dldbIdentifier) +{ + for (vector::const_iterator ix = searchList().begin(); ix != mSearchList.end(); ++ix) { - clear(); - ::CFPreferencesSynchronize(mPrefsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - loadOrCreate(); - return true; // @@@ Be smarter about when something *really* changed + if (*ix==dldbIdentifier) // already in list + return; } - return false; + mSearchList.push_back(dldbIdentifier); + changed(true); } +void +DLDbListCFPref::remove(const DLDbIdentifier &dldbIdentifier) +{ + // Make sure mSearchList is set + searchList(); + for (vector::iterator ix = mSearchList.begin(); ix != mSearchList.end(); ++ix) + { + if (*ix==dldbIdentifier) // found in list + { + mSearchList.erase(ix); + changed(true); + break; + } + } +} + +const vector & +DLDbListCFPref::searchList() +{ + if (!mSearchListSet) + { + CFArrayRef searchList = reinterpret_cast(CFDictionaryGetValue(mPropertyList, kDefaultDLDbListKey)); + if (searchList && CFGetTypeID(searchList) != CFArrayGetTypeID()) + searchList = NULL; + + if (searchList) + { + CFIndex top = CFArrayGetCount(searchList); + // Each entry is a CFDictionary; peel it off & add it to the array + for (CFIndex idx = 0; idx < top; ++idx) + { + CFDictionaryRef theDict = reinterpret_cast(CFArrayGetValueAtIndex(searchList, idx)); + try + { + mSearchList.push_back(cfDictionaryRefToDLDbIdentifier(theDict)); + } + catch (...) + { + // Drop stuff that doesn't parse on the floor. + } + } + + // If there were entries specified, but they were invalid revert to using the + // default keychain in the searchlist. + if (top > 0 && mSearchList.size() == 0) + searchList = NULL; + } + + // The default when no search list is specified is to only search the + // default keychain. + if (!searchList && static_cast(defaultDLDbIdentifier())) + mSearchList.push_back(mDefaultDLDbIdentifier); + + mSearchListSet = true; + } + + return mSearchList; +} + +void +DLDbListCFPref::searchList(const vector &searchList) +{ + vector newList(searchList); + mSearchList.swap(newList); + mSearchListSet = true; + changed(true); +} + +void +DLDbListCFPref::defaultDLDbIdentifier(const DLDbIdentifier &dlDbIdentifier) +{ + if (!(defaultDLDbIdentifier() == dlDbIdentifier)) + { + mDefaultDLDbIdentifier = dlDbIdentifier; + changed(true); + } +} + +const DLDbIdentifier & +DLDbListCFPref::defaultDLDbIdentifier() +{ + if (!mDefaultDLDbIdentifierSet) + { + CFArrayRef defaultArray = reinterpret_cast(CFDictionaryGetValue(mPropertyList, kDefaultKeychainKey)); + if (defaultArray && CFGetTypeID(defaultArray) != CFArrayGetTypeID()) + defaultArray = NULL; + + if (defaultArray && CFArrayGetCount(defaultArray) > 0) + { + CFDictionaryRef defaultDict = reinterpret_cast(CFArrayGetValueAtIndex(defaultArray, 0)); + try + { + x_debug("Getting default DLDbIdentifier from defaultDict"); + mDefaultDLDbIdentifier = cfDictionaryRefToDLDbIdentifier(defaultDict); + x_debug1("Now we think the default keychain is %s", (mDefaultDLDbIdentifier) ? mDefaultDLDbIdentifier.dbName() : ""); + } + catch (...) + { + // If defaultArray doesn't parse fall back on the default way of getting the default keychain + defaultArray = NULL; + } + } + + if (!defaultArray) + { + // If the Panther style login keychain actually exists we use that otherwise no + // default is set. + mDefaultDLDbIdentifier = loginDLDbIdentifier(); + x_debug1("Now we think the default keychain is %s", (mDefaultDLDbIdentifier) ? mDefaultDLDbIdentifier.dbName() : ""); + + struct stat st; + int st_result = stat(mDefaultDLDbIdentifier.dbName(), &st); + if (st_result) + { + x_debug2("stat() of %s returned %d", mDefaultDLDbIdentifier.dbName(), st_result); + mDefaultDLDbIdentifier = DLDbIdentifier(); + x_debug1("After DLDbIdentifier(), we think the default keychain is %s", static_cast(mDefaultDLDbIdentifier) ? mDefaultDLDbIdentifier.dbName() : ""); + } + } + + mDefaultDLDbIdentifierSet = true; + } + + return mDefaultDLDbIdentifier; +} + +void +DLDbListCFPref::loginDLDbIdentifier(const DLDbIdentifier &dlDbIdentifier) +{ + if (!(loginDLDbIdentifier() == dlDbIdentifier)) + { + mLoginDLDbIdentifier = dlDbIdentifier; + changed(true); + } +} + +const DLDbIdentifier & +DLDbListCFPref::loginDLDbIdentifier() +{ + if (!mLoginDLDbIdentifierSet) + { + CFArrayRef loginArray = reinterpret_cast(CFDictionaryGetValue(mPropertyList, kLoginKeychainKey)); + if (loginArray && CFGetTypeID(loginArray) != CFArrayGetTypeID()) + loginArray = NULL; + + if (loginArray && CFArrayGetCount(loginArray) > 0) + { + CFDictionaryRef loginDict = reinterpret_cast(CFArrayGetValueAtIndex(loginArray, 0)); + try + { + x_debug("Getting login DLDbIdentifier from loginDict"); + mLoginDLDbIdentifier = cfDictionaryRefToDLDbIdentifier(loginDict); + x_debug1("We think the login keychain is %s", static_cast(mLoginDLDbIdentifier) ? mLoginDLDbIdentifier.dbName() : ""); + } + catch (...) + { + // If loginArray doesn't parse fall back on the default way of getting the login keychain. + loginArray = NULL; + } + } + + if (!loginArray) + { + // If the jaguar login keychain actually exists we use that otherwise no + // login keychain is set. + x_debug("No loginDict found, calling JaguarLoginDLDbIdentifier()"); + mLoginDLDbIdentifier = JaguarLoginDLDbIdentifier(); + x_debug1("After JaguarLoginDLDbIdentifier(), we think the login keychain is %s", static_cast(mLoginDLDbIdentifier) ? mLoginDLDbIdentifier.dbName() : ""); + + struct stat st; + int st_result = stat(mLoginDLDbIdentifier.dbName(), &st); + if (st_result) + { + // Jaguar login Keychain didn't exist, so assume new style one. + x_debug2("stat() of %s returned %d", mLoginDLDbIdentifier.dbName(), st_result); + mLoginDLDbIdentifier = LoginDLDbIdentifier(); + x_debug1("After LoginDLDbIdentifier(), we think the login keychain is %s", static_cast(mLoginDLDbIdentifier) ? mLoginDLDbIdentifier.dbName() : ""); + } + } + + mLoginDLDbIdentifierSet = true; + } + + return mLoginDLDbIdentifier; +} diff --git a/Keychain/DLDBListCFPref.h b/Keychain/DLDBListCFPref.h index ba74d7a8..c3199500 100644 --- a/Keychain/DLDBListCFPref.h +++ b/Keychain/DLDBListCFPref.h @@ -22,6 +22,7 @@ #ifndef _SECURITY_DLDBLISTCFPREF_H_ #define _SECURITY_DLDBLISTCFPREF_H_ +#include #include #include #include @@ -31,38 +32,87 @@ #include #include - namespace Security { -class DLDbListCFPref : public CssmClient::DLDbList +class PasswordDBLookup { +protected: + string mDirectory; + string mName; + bool mValid; + uid_t mCurrent; + time_t mTime; + public: - DLDbListCFPref(CFStringRef theDLDbListKey=NULL,CFStringRef prefsDomain=NULL); + PasswordDBLookup (); + + void lookupInfoOnUID (uid_t uid); + const string& getDirectory () {return mDirectory;} + const string& getName () {return mName;} +}; + +class DLDbListCFPref +{ +public: + DLDbListCFPref(SecPreferencesDomain domain = kSecPreferencesDomainUser); ~DLDbListCFPref(); + + void set(SecPreferencesDomain domain); void save(); - CssmClient::DLDbList& list() { return *this; } // eventually, it should check mod dates of CFPrefs file, etc. - + vector& list() { return mSearchList; } + static DLDbIdentifier cfDictionaryRefToDLDbIdentifier(CFDictionaryRef theDict); static CFDictionaryRef dlDbIdentifierToCFDictionaryRef(const DLDbIdentifier& dldbIdentifier); bool revert(bool force); - void clearDefaultKeychain(); - + + void add(const DLDbIdentifier &); + void remove(const DLDbIdentifier &); + const vector &searchList(); + void searchList(const vector &); + void defaultDLDbIdentifier(const DLDbIdentifier &); + const DLDbIdentifier &defaultDLDbIdentifier(); + void loginDLDbIdentifier(const DLDbIdentifier &); + const DLDbIdentifier &loginDLDbIdentifier(); + + DLDbIdentifier LoginDLDbIdentifier(); + DLDbIdentifier JaguarLoginDLDbIdentifier(); + static string ExpandTildesInPath(const string &inPath); static string StripPathStuff(const string &inPath); static string AbbreviatedPath(const string &inPath); - static string HomeDir(); -private: - // Private member variables - CFStringRef mPrefsDomain; - CFStringRef mDLDbListKey; +protected: + SecPreferencesDomain mDomain; + bool hasChanged() const { return mChanged; } + void changed(bool hasChanged) { mChanged = hasChanged; } - // Private member functions - void loadOrCreate(); + enum PwInfoType + { + kHomeDir, + kUsername + }; + + static PasswordDBLookup *mPdbLookup; + static string getPwInfo(PwInfoType type); + static void clearPWInfo (); + + void resetCachedValues(); + bool loadPropertyList(bool force); + void writePropertyList(); + +private: CFAbsoluteTime mPrefsTimeStamp; + struct timespec mTimespec; + CFMutableDictionaryRef mPropertyList; + + string mPrefsPath, mHomeDir, mUserName; + vector mSearchList; + DLDbIdentifier mDefaultDLDbIdentifier; + DLDbIdentifier mLoginDLDbIdentifier; + bool mChanged, mSearchListSet, mDefaultDLDbIdentifierSet, mLoginDLDbIdentifierSet; }; class CCFValue diff --git a/Keychain/DefaultKeychain.cpp b/Keychain/DefaultKeychain.cpp deleted file mode 100644 index 8f05bad4..00000000 --- a/Keychain/DefaultKeychain.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - File: DefaultKeychain.cpp - - Contains: User preference for default keychain - - Copyright: 2000 by Apple Computer, Inc., all rights reserved. - - To Do: -*/ - -#include "DefaultKeychain.h" - -#include "CCallbackMgr.h" -#include "KCEventNotifier.h" -#include "Keychains.h" -#include "Globals.h" -#include "KCExceptions.h" - -using namespace KeychainCore; -using namespace CssmClient; - -DefaultKeychain::DefaultKeychain() : mPref(CFSTR("DefaultKeychain")) -{ -} - -// Set/Get via DLDbIdentifier -void DefaultKeychain::dLDbIdentifier(const DLDbIdentifier& keychainID) -{ - DLDbList& theList=mPref.list(); - if (theList.size()>0 && keychainID==theList[0]) // already the default keychain - return; - theList.clear(); - mPref.add(keychainID); // destructor will save - mPref.save(); - KCEventNotifier::PostKeychainEvent(kSecDefaultChangedEvent, keychainID); - defaultID = keychainID; -} - -// unset default -void DefaultKeychain::unset() -{ - DLDbList& theList=mPref.list(); - theList.clear(); - mPref.clearDefaultKeychain(); - KCEventNotifier::PostKeychainEvent(kSecDefaultChangedEvent); -} - -void DefaultKeychain::reload(bool force) -{ - if (!defaultID || mPref.revert(force)) - { - DLDbList& theList=mPref.list(); - if (theList.size()==0) - MacOSError::throwMe(errSecNoDefaultKeychain); - defaultID = theList[0]; - } -} - -DLDbIdentifier DefaultKeychain::dLDbIdentifier() -{ - reload(); - return defaultID; -} - -// Set/Get via Keychain -void DefaultKeychain::keychain(const Keychain& keychain) -{ - DefaultKeychain::dLDbIdentifier(keychain->dLDbIdentifier()); // call the main "set" routine -} - -Keychain DefaultKeychain::keychain() // was: GetTimedDefaultKC -{ - return globals().storageManager.keychain(dLDbIdentifier()); -} - -bool DefaultKeychain::isSet() -{ - return mPref.list().size() != 0; -} diff --git a/Keychain/DefaultKeychain.h b/Keychain/DefaultKeychain.h deleted file mode 100644 index 8dad503a..00000000 --- a/Keychain/DefaultKeychain.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2000-2002 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - -// -// DefaultKeychain.h - Default Keychain singleton -// -#ifndef _SECURITY_DEFAULTKEYCHAIN_H_ -#define _SECURITY_DEFAULTKEYCHAIN_H_ - -#include -#include - -namespace Security -{ - -namespace KeychainCore -{ - -//--------------------------------------------------------------------------------- -// Default keychain -// -// Note that this is strictly a user preference setting, indicating which keychain -// should be used to add items to. No validity checking should be done on it in -// this class, since it may not be available right now (e.g. on a network volume) -//---------------------------------------------------------------------------------- - -class Keychain; - -class DefaultKeychain -{ -public: - DefaultKeychain(); - - // Set/Get via DLDbIdentifier - void dLDbIdentifier(const DLDbIdentifier& keychainID); - DefaultKeychain &operator =(const DLDbIdentifier& keychainID) - { dLDbIdentifier(keychainID); return *this; } - - void reload(bool force = false); - DLDbIdentifier dLDbIdentifier(); - operator DLDbIdentifier () { return dLDbIdentifier(); } - - // Remove if passed in DLDbIdentifier is currently the default - void remove(const DLDbIdentifier& keychainID); - - // Set/Get via Keychain - void keychain(const Keychain& keychain); - DefaultKeychain &operator =(const Keychain& inKeychain) { keychain(inKeychain); return *this; } - - Keychain keychain(); - operator Keychain () { return keychain(); } - - void unset(); // Who needs a default keychain anyway. - bool isSet(); -private: - DLDbListCFPref mPref; - DLDbIdentifier defaultID; -}; - -} // end namespace KeychainCore - -} // end namespace Security - -#endif // !_SECURITY_DEFAULTKEYCHAIN_H_ diff --git a/Keychain/ExecCLITool.cpp b/Keychain/ExecCLITool.cpp new file mode 100644 index 00000000..b2e94ec5 --- /dev/null +++ b/Keychain/ExecCLITool.cpp @@ -0,0 +1,313 @@ + +#include +#include "ExecCLITool.h" +#include +#include + +#pragma mark -------------------- ExecCLITool implementation -------------------- + +ExecCLITool::ExecCLITool() : dataRead(NULL),dataLength(0),dataToWrite(NULL),dataToWriteLength(0) +{ + stdinpipe[0]=0, stdinpipe[1]=0; + stdoutpipe [0]=0, stdoutpipe [1]=0; +} + +ExecCLITool::~ExecCLITool() +{ + if (dataRead) + free(dataRead); + reset(); +} + +int ExecCLITool::run(const char *toolPath, const char *toolEnvVar, ...) +{ + try + { + reset(); + initialize(); + + // try to run the tool + switch (pid_t pid = fork()) + { + case 0: // child + { + VAArgList arglist; + va_list params; + va_start(params, toolEnvVar); + arglist.set(toolPath,params); + va_end(params); + child(toolPath,toolEnvVar,arglist); + } + break; + case -1: // error (in parent) + UnixError::throwMe(); + break; + default: // parent + parent(pid); + break; + } + } + catch (...) + { + closeAllPipes(); + return errno; + } + + closeAllPipes(); + return 0; +} + +void ExecCLITool::reset() +{ + closeAllPipes(); +#if 0 + if (dataToWrite) + { + free(dataToWrite); + dataToWrite = NULL; + } + dataToWriteLength = 0; +#endif +} + +void ExecCLITool::input(const char *data,unsigned int length) +{ + if (dataToWrite) + { + ::free(dataToWrite); + dataToWrite = NULL; + } + dataToWriteLength=length; + if (!data) + return; + + dataToWrite=reinterpret_cast(malloc(length)); + ::memmove(dataToWrite, data, dataToWriteLength); +} + +void ExecCLITool::input(CFStringRef theString, bool appendNULL) +{ + // Used mainly for preserving UTF-8 passwords + // hdiutil et al require the NULL to be sent as part of the password string from STDIN + Boolean isExternalRepresentation = false; + CFStringEncoding encoding = kCFStringEncodingUTF8; + CFIndex usedBufLen = 0; + UInt8 lossByte = 0; + + if (!theString) + MacOSError::throwMe(paramErr); + + CFRange stringRange = CFRangeMake(0,CFStringGetLength(theString)); + // Call once first just to get length + CFIndex length = CFStringGetBytes(theString, stringRange, encoding, lossByte, + isExternalRepresentation, NULL, 0, &usedBufLen); + + if (dataToWrite) + ::free(dataToWrite); + dataToWriteLength=usedBufLen; + if (appendNULL) + { + dataToWriteLength++; + dataToWriteLength++; +} + + dataToWrite=reinterpret_cast(malloc(dataToWriteLength)); + length = CFStringGetBytes(theString, stringRange, encoding, lossByte, isExternalRepresentation, + reinterpret_cast(dataToWrite), dataToWriteLength, &usedBufLen); + + if (appendNULL) + { + dataToWrite[dataToWriteLength-1]=0; + dataToWrite[dataToWriteLength]='\n'; + } +} + +void ExecCLITool::initialize() +{ + dataLength = 0; // ignore any previous output on new run + + if (!dataRead) // Allocate buffer for child's STDOUT return + { + dataRead = (char *)malloc(256); + if (!dataRead) + UnixError::throwMe(); + } + + // Create pipe to catch tool output + if (pipe(stdoutpipe)) // for reading data from child into parent + UnixError::throwMe(); + + if (pipe(stdinpipe)) // for writing data from parent to child + UnixError::throwMe(); +} + +void ExecCLITool::child(const char *toolPath, const char *toolEnvVar, VAArgList& arglist) +{ + // construct path to tool + try + { + char toolExecutable[PATH_MAX + 1]; + const char *path = toolEnvVar ? getenv(toolEnvVar) : NULL; + if (!path) + path = toolPath; + snprintf(toolExecutable, sizeof(toolExecutable), "%s", toolPath); + + close(stdoutpipe[0]); // parent read + close(STDOUT_FILENO); + if (dup2(stdoutpipe[1], STDOUT_FILENO) < 0) + UnixError::throwMe(); + close(stdoutpipe[1]); + + close(stdinpipe[1]); // parent write + close(STDIN_FILENO); + if (dup2(stdinpipe[0], STDIN_FILENO) < 0) + UnixError::throwMe(); + close(stdinpipe[0]); + + // std::cerr << "execl(\"" << toolExecutable << "\")" << std::endl; + execv(toolPath, const_cast(arglist.get())); + // std::cerr << "execl of " << toolExecutable << " failed, errno=" << errno << std::endl; + } + catch (...) + { + int err = errno; +// closeAllPipes(); + _exit(err); + } + + // Unconditional suicide follows. + _exit(1); +} + +void ExecCLITool::parent(pid_t pid) +{ + static const int timeout = 300; + static const bool dontNeedToWait = false; + + close(stdinpipe[0]); // child read + close(stdoutpipe[1]); // child write + + parentWriteInput(); + + parentReadOutput(); + + struct timespec rqtp = {0,}; + rqtp.tv_nsec = 100000000; // 10^8 nanoseconds = 1/10th of a second + for (int nn = timeout; nn > 0; nanosleep(&rqtp, NULL), nn--) + { + if (dontNeedToWait) + break; + int status; + switch (waitpid(pid, &status, WNOHANG)) + { + case 0: // child still running + break; + case -1: // error + switch (errno) + { + case EINTR: + case EAGAIN: // transient + continue; + case ECHILD: // no such child (dead; already reaped elsewhere) + CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); + default: + UnixError::throwMe(); + } + default: + // std::cerr << "waitpid succeeded, pid=" << rc << std::endl; + return; + } + } +} + +void ExecCLITool::parentReadOutput() +{ + // parent - resulting blob comes in on stdoutpipe[0] + unsigned int totalRead = 0; + char buffer[kReadBufSize]; + + for (;;) + { + int thisRead = read(stdoutpipe[0], buffer, kReadBufSize); + if (thisRead < 0) + { + if (errno==EINTR) // try some more + continue; +// std::cerr << "abnormal read end:" << errno << std::endl; + break; + } + if (thisRead == 0) // normal termination + { + dataLength = totalRead; +// std::cerr << "Normal read end" << std::endl; + break; + } + + // Resize dataRead if necessary + if (kReadBufSize < (totalRead + (unsigned int)thisRead)) + { + uint32 newLen = dataLength + kReadBufSize; + dataRead = (char *)realloc(dataRead, newLen); + dataLength = newLen; + } + + // Append the data to dataRead + memmove(dataRead + totalRead, buffer, thisRead); + totalRead += thisRead; + } + close(stdoutpipe[0]); + +} + +void ExecCLITool::parentWriteInput() +{ + if (dataToWriteLength>0) + { + int bytesWritten = write(stdinpipe[1],dataToWrite,dataToWriteLength); + if (bytesWritten < 0) + UnixError::throwMe(); + } + close(stdinpipe[1]); +} + +void ExecCLITool::closeAllPipes() +{ + for (int ix=0;ix<2;ix++) + if (stdoutpipe[ix]) + { + close(stdoutpipe[ix]); + stdoutpipe[ix]=0; + } + + for (int ix=0;ix<2;ix++) + if (stdinpipe[ix]) + { + close(stdinpipe[ix]); + stdinpipe[ix]=0; + } +} + +#pragma mark -------------------- VAArgList implementation -------------------- + +int VAArgList::set(const char *path,va_list params) +{ + va_list params2; + va_copy(params2, params); + + // Count up the number of arguments + int nn = 1; + while (va_arg(params,const char *) != NULL) + nn++; + argn = nn; + argv = (ArgvArgPtr *)malloc((nn + 1) * sizeof(*argv)); + if (argv == NULL) + return 0; + + nn = 1; + argv[0]=path; + while ((argv[nn]=va_arg(params2,const char *)) != NULL) + nn++; + mSet = true; + return 0; +} + diff --git a/Keychain/ExecCLITool.h b/Keychain/ExecCLITool.h new file mode 100644 index 00000000..4bf91fe8 --- /dev/null +++ b/Keychain/ExecCLITool.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +#ifndef _H_EXECCLITOOL +#define _H_EXECCLITOOL + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class VAArgList +{ +public: + VAArgList() {}; + ~VAArgList() { if (argv) free(argv); } + + typedef const char * ArgvArgPtr; + + int VAArgList::set(const char *path,va_list params); + + const char* const*get() { return argv; } + + int size() { return argn; } + +private: + ArgvArgPtr *argv; // array for list of pointers + int argn; // count of elements in argv + bool mSet; // params have been passed in +}; + +class ExecCLITool +{ +public: + ExecCLITool(); + ~ExecCLITool(); + + int run(const char *toolPath, const char *toolEnvVar, ...); + void input(const char *data,unsigned int length); + void input(CFStringRef theString, bool appendNULL=false); + const char * data() const { return dataRead; } + unsigned int length() const { return dataLength; } + +protected: + + void child(const char *toolPath, const char *toolEnvVar, VAArgList& arglist); + void parent(pid_t pid); + void parentReadOutput(); + void parentWriteInput(); + void closeAllPipes(); + void initialize(); + void reset(); + + int stdoutpipe[2]; // for reading data from child into parent (child uses stdout) + int stdinpipe [2]; // for writing data from parent to child (child uses stdin) + + char *dataRead; + unsigned int dataLength; + + char *dataToWrite; + unsigned int dataToWriteLength; + + static const unsigned int kReadBufSize = 1024; + +}; + + +#endif //_H_EXECCLITOOL + + diff --git a/Keychain/FileVaultSPI.cpp b/Keychain/FileVaultSPI.cpp new file mode 100644 index 00000000..34329b5c --- /dev/null +++ b/Keychain/FileVaultSPI.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ +/* + * FileVaultSPI.cpp + * Security + * + * Created by john on Wed Jul 09 2003. + * Copyright (c) 2003 Apple. All rights reserved. + * + */ + +#include "FileVaultSPI.h" +#include "SFFileVault.h" +#include +#include + +#pragma mark -------------------- SecFileVault implementation -------------------- + +OSStatus SecFileVaultCreate (CFStringRef password, bool enableMasterPassword, CFURLRef dmgout, CFStringRef volumeName, + CFStringRef sizeSpec) +{ + // Note that we do not need the master keychain password, since we can encrypt the + // image key with the public key. + BEGIN_SECAPI + + SFFileVault sffv; + CFURLRef certificate = NULL; + if (enableMasterPassword) + sffv.getCertificate(&certificate); + + sffv.create(password, certificate, dmgout, volumeName, sizeSpec); + if (certificate) //@@@ leak if error thrown + CFRelease(certificate); + + END_SECAPI +} + +OSStatus SecFileVaultUserMount (CFStringRef password, CFURLRef dmgin, CFURLRef mountpoint, CFStringRef *devicepath) +{ + BEGIN_SECAPI + + SFFileVault sffv; + sffv.mount(password, NULL, dmgin, mountpoint, devicepath); + + END_SECAPI +} + +OSStatus SecFileVaultMasterMount(CFURLRef dmgin, CFURLRef mountpoint, CFStringRef *devicepath) +{ + BEGIN_SECAPI + + SFFileVault sffv; + sffv.mastermount(dmgin,mountpoint,devicepath); + + END_SECAPI +} + +OSStatus SecFileVaultUnmount(CFURLRef mountpoint, CFStringRef devicepath) +{ + BEGIN_SECAPI + + SFFileVault sffv; + sffv.unmount(mountpoint,devicepath); + + END_SECAPI +} + +OSStatus SecFileVaultUserChangePassword(CFStringRef password, CFStringRef devicepath) +{ + BEGIN_SECAPI + + SFFileVault fv; + fv.userChangePassword(password, devicepath); + + END_SECAPI +} + +OSStatus SecFileVaultMakeMasterPassword(CFStringRef masterPasswordPassword) +{ + BEGIN_SECAPI + + SFFileVault fv; + SecKeychainRef keychainRef; + fv.makeMasterPassword(masterPasswordPassword,&keychainRef); + + END_SECAPI +} + +Boolean SecFileVaultMasterPasswordEnabled(SecKeychainRef *keychainRef) +{ + BEGIN_SECAPI + + SFFileVault fv; + return fv.masterPasswordEnabled(keychainRef); + + END_SECAPI1(false) +} + +OSStatus SecFileVaultChangeMasterPasswordPassword(CFStringRef oldPassword,CFStringRef newPassword) +{ + BEGIN_SECAPI + + SFFileVault fv; + fv.changeMasterPasswordPassword(oldPassword,newPassword); + + END_SECAPI +} + +#pragma mark -------------------- SecFileVault extended implementation -------------------- + +OSStatus SecFileVaultMount(CFStringRef password, CFURLRef certificate, CFURLRef dmgin, CFURLRef mountpoint, + CFStringRef *devicepath) +{ + BEGIN_SECAPI + + SFFileVault sffv; + sffv.mount(password, certificate, dmgin, mountpoint, devicepath); + + END_SECAPI +} + + +OSStatus SecFileVaultCreateUsingCertificate (CFStringRef password, CFURLRef certificate, CFURLRef dmgout, CFStringRef volumeName, + CFStringRef sizeSpec) +{ + BEGIN_SECAPI + + SFFileVault sffv; + sffv.create(password, certificate, dmgout, volumeName, sizeSpec); + + END_SECAPI +} + + diff --git a/Keychain/FileVaultSPI.h b/Keychain/FileVaultSPI.h new file mode 100644 index 00000000..bd50492b --- /dev/null +++ b/Keychain/FileVaultSPI.h @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/*! + @header FileVaultSPI + The functions provided in FileVaultSPI implement code for Loginwindow to use when mounting + FileVault home directories. Functions are also provided to allow recovery of an image with + a recovery key pair (Master "Password") +*/ + +#ifndef _SECURITY_FILEVAULTSPI_H_ +#define _SECURITY_FILEVAULTSPI_H_ + +#include +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#pragma mark -------------------- SecFileVault functions -------------------- + +/*! + @function SecFileVaultCreate + @abstract Creates a FileVault disk image. If you want to enable a recovery key and already have a certificate to use, you can call SecFileVaultCreateUsingCertificate. + @param password The password for the image. This should be the same as the user's login password. + @param enableMasterPassword If set, the first identity in the special keychain will be used as the master key for the disk image. + @param dmgout The file name and path for the FileVault disk image. + @param volumeName The volume name for the mounted FileVault disk image (e.g. MYVOL). + @param sizeSpec The size of the resulting FileVault disk image. See man hdiutil (e.g. CFSTR("20g")). + @result A result code. See "Security Error Codes" (SecBase.h). +*/ + +OSStatus SecFileVaultCreate (CFStringRef password, bool enableMasterPassword, CFURLRef dmgout, CFStringRef volumeName, + CFStringRef sizeSpec); + +/*! + @function SecFileVaultMount + @abstract Used when logging in to mount a FileVault disk image. + @param password The password for the image. This will be the same as the user's login password. + @param enableMasterPassword If set, the first identity in the special keychain will be used as the master key for the disk image. + @param dmgout The file name for the FileVault disk image. This will be the same as was specified with SecFileVaultCreate. + @param mountpoint The mountpoint for the mounted FileVault disk image. This will be passed to "hdiutil mount" as the mountpoint parameter + @param devicepath The devicepath for the mounted FileVault disk image. Caller is responsible for freeing this string + @result A result code. See "Security Error Codes" (SecBase.h). +*/ + +OSStatus SecFileVaultUserMount (CFStringRef password, CFURLRef dmgin, CFURLRef mountpoint,CFStringRef *devicepath); + +/*! + @function SecFileVaultMasterMount + @abstract To change the password for a FileVault disk image, the image must be mounted. After calling this, you can call SecFileVaultUserChangePassword to change the user's password. This is the same as SecFileVaultMount, except that the master key identity will be used to unlock the image. + @param dmgin The file name for the FileVault disk image. + @param mountpoint The mountpoint for the mounted FileVault disk image. This will be passed to "hdiutil mount" as the mountpoint parameter + @param devicepath The devicepath for the mounted FileVault disk image. Caller is responsible for freeing this string + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecFileVaultMasterMount(CFURLRef dmgin, CFURLRef mountpoint,CFStringRef *devicepath); + +/*! + @function SecFileVaultUnmount + @abstract Unmount a FileVault disk image. This will be called on logout. This is the inverse operation to SecFileVaultMount or SecFileVaultMasterMount. Essentially "hdiutil unmount -force ", followed by "hdiutil detach ". + @param mountpoint The mountpoint for the mounted FileVault disk image. + @param devicepath The devicepath for the mounted FileVault disk image. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecFileVaultUnmount(CFURLRef mountpoint,CFStringRef devicepath); + +/*! + @function SecFileVaultUserChangePassword + @abstract Change the user password for a FileVault disk image to that given as the parameter. This should be called when changing the user's account password info, or when resetting a user's forgotten password with . The image must have already been mounted with either SecFileVaultMount or SecFileVaultMasterMount. + @param mountpoint The mountpoint for the mounted FileVault disk image. + @param devicepath The devicepath for the mounted FileVault disk image. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecFileVaultUserChangePassword(CFStringRef password, CFStringRef devicepath); + +/*! + @function SecFileVaultMakeMasterPassword + @abstract This will create a special keychain in a special location if necessary and will generate a self-signed public/private key pair. This is what to call if the user pushes an "Enable Master Password" button (irrevocable). + @param masterPasswordPassword The password to use for the special keychain that will contain the key pair. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecFileVaultMakeMasterPassword(CFStringRef masterPasswordPassword); + +/*! + @function SecFileVaultMasterPasswordEnabled + @abstract This will return "true" if FileVault Master recovery keychain exists, and false if not. Note that this a machine-wide setting. + @param keychainRef Returns a reference to the keychain, which you must release. Pass in NULL if you do not need a reference to the keychain + @result "true" or "false". +*/ +Boolean SecFileVaultMasterPasswordEnabled(SecKeychainRef *keychainRef); + +/*! + @function SecFileVaultChangeMasterPasswordPassword + @abstract This will change the keychain password for the special Master Password keychain. This has the same effect as changing the password for this keychain with Keychain Access. + @param oldPassword The current password for the special Master Password keychain containing the recovery key pair. + @param newPassword The new password for the special Master Password keychain containing the recovery key pair. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecFileVaultChangeMasterPasswordPassword(CFStringRef oldPassword,CFStringRef newPassword); + +#pragma mark -------------------- SecFileVault extended functions -------------------- + +/*! + @function SecFileVaultMount + @abstract Used when logging in to mount a FileVault disk image. + @param password The password for the image. This will be the same as the user's login password. + @param certificate A certificate file in DER encoding (.cer extension). + @param dmgout The file name for the FileVault disk image. This will be the same as was specified with SecFileVaultCreate. + @param mountpoint The mountpoint for the mounted FileVault disk image. This will be passed to "hdiutil mount" as the mountpoint parameter + @param devicepath The devicepath for the mounted FileVault disk image. Caller is responsible for freeing this string + @result A result code. See "Security Error Codes" (SecBase.h). +*/ + +OSStatus SecFileVaultMount (CFStringRef password, CFURLRef certificate, CFURLRef dmgin, CFURLRef mountpoint, + CFStringRef *devicepath); + +/*! + @function SecFileVaultCreateUsingCertificate + @abstract Creates a FileVault disk image. + @param password The password for the image. This should be the same as the user's login password. + @param certificate A certificate file in DER encoding (.cer extension). + @param dmgout The file name and path for the FileVault disk image. + @param volumeName The volume name for the mounted FileVault disk image (e.g. MYVOL). + @param sizeSpec The size of the resulting FileVault disk image. See man hdiutil (e.g. CFSTR("20g")). + @result A result code. See "Security Error Codes" (SecBase.h). +*/ + +OSStatus SecFileVaultCreateUsingCertificate (CFStringRef password, CFURLRef certificate, CFURLRef dmgout, + CFStringRef volumeName, CFStringRef sizeSpec); + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SECURITY_FILEVAULTSPI_H_ */ diff --git a/Keychain/Globals.h b/Keychain/Globals.h index 7ebc9651..a094dcea 100644 --- a/Keychain/Globals.h +++ b/Keychain/Globals.h @@ -25,7 +25,6 @@ #undef check #endif #include -#include #include @@ -45,10 +44,10 @@ public: // Public globals StorageManager storageManager; - DefaultKeychain defaultKeychain; + //DefaultKeychain defaultKeychain; Mutex apiLock; private: - + // Other "globals" bool mUI; CssmClient::AclFactory mACLFactory; diff --git a/Keychain/Identity.cpp b/Keychain/Identity.cpp index 1f5b1652..46d6d9ba 100644 --- a/Keychain/Identity.cpp +++ b/Keychain/Identity.cpp @@ -20,26 +20,44 @@ // #include +#include +#include + using namespace KeychainCore; -Identity::Identity(const RefPointer &privateKey, - const RefPointer &certificate) : +Identity::Identity(const SecPointer &privateKey, + const SecPointer &certificate) : mPrivateKey(privateKey), mCertificate(certificate) { } -Identity::~Identity() +Identity::Identity(const StorageManager::KeychainList &keychains, const SecPointer &certificate) : + mCertificate(certificate) +{ + // Find a key whose label matches the publicKeyHash of the public key in the certificate. + KCCursor keyCursor(keychains, CSSM_DL_DB_RECORD_PRIVATE_KEY, NULL); + keyCursor->add(CSSM_DB_EQUAL, KeySchema::Label, certificate->publicKeyHash()); + + Item key; + if (!keyCursor->next(key)) + MacOSError::throwMe(errSecItemNotFound); + + SecPointer keyItem(static_cast(&*key)); + mPrivateKey = keyItem; +} + +Identity::~Identity() throw() { } -RefPointer +SecPointer Identity::privateKey() const { return mPrivateKey; } -RefPointer +SecPointer Identity::certificate() const { return mCertificate; diff --git a/Keychain/Identity.h b/Keychain/Identity.h index 8e1acdd6..107b6547 100644 --- a/Keychain/Identity.h +++ b/Keychain/Identity.h @@ -35,16 +35,19 @@ class Identity : public SecCFObject { NOCOPY(Identity) public: - Identity(const RefPointer &privateKey, - const RefPointer &certificate); - virtual ~Identity(); + SECCFFUNCTIONS(Identity, SecIdentityRef, errSecInvalidItemRef) - RefPointer privateKey() const; - RefPointer certificate() const; + Identity(const SecPointer &privateKey, + const SecPointer &certificate); + Identity(const StorageManager::KeychainList &keychains, const SecPointer &certificate); + virtual ~Identity() throw(); + + SecPointer privateKey() const; + SecPointer certificate() const; private: - RefPointer mPrivateKey; - RefPointer mCertificate; + SecPointer mPrivateKey; + SecPointer mCertificate; }; } // end namespace KeychainCore diff --git a/Keychain/IdentityCursor.cpp b/Keychain/IdentityCursor.cpp index dbe5dde7..92907dad 100644 --- a/Keychain/IdentityCursor.cpp +++ b/Keychain/IdentityCursor.cpp @@ -70,12 +70,12 @@ IdentityCursor::IdentityCursor(const StorageManager::KeychainList &searchList, C mKeyCursor->add(CSSM_DB_EQUAL, KeySchema::Unwrap, true); } -IdentityCursor::~IdentityCursor() +IdentityCursor::~IdentityCursor() throw() { } bool -IdentityCursor::next(RefPointer &identity) +IdentityCursor::next(SecPointer &identity) { for (;;) { @@ -100,7 +100,7 @@ IdentityCursor::next(RefPointer &identity) Item cert; if (mCertificateCursor->next(cert)) { - RefPointer certificate(static_cast(cert.get())); + SecPointer certificate(static_cast(cert.get())); identity = new Identity(mCurrentKey, certificate); return true; } diff --git a/Keychain/IdentityCursor.h b/Keychain/IdentityCursor.h index c025e165..baee33ef 100644 --- a/Keychain/IdentityCursor.h +++ b/Keychain/IdentityCursor.h @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include #include @@ -40,15 +42,17 @@ class IdentityCursor : public SecCFObject { NOCOPY(IdentityCursor) public: + SECCFFUNCTIONS(IdentityCursor, SecIdentitySearchRef, errSecInvalidSearchRef) + IdentityCursor(const StorageManager::KeychainList &searchList, CSSM_KEYUSE keyUsage); - virtual ~IdentityCursor(); - bool next(RefPointer &identity); + virtual ~IdentityCursor() throw(); + bool next(SecPointer &identity); private: StorageManager::KeychainList mSearchList; KCCursor mKeyCursor; KCCursor mCertificateCursor; - RefPointer mCurrentKey; + SecPointer mCurrentKey; }; } // end namespace KeychainCore diff --git a/Keychain/Item.cpp b/Keychain/Item.cpp index bcb557a5..a8c89692 100644 --- a/Keychain/Item.cpp +++ b/Keychain/Item.cpp @@ -30,11 +30,12 @@ #include "KCEventNotifier.h" #include "cssmdatetime.h" #include -#include #include #include #include +#define SENDACCESSNOTIFICATIONS 1 + using namespace KeychainCore; using namespace CSSMDateTimeUtils; @@ -124,7 +125,7 @@ ItemImpl::ItemImpl(ItemImpl &item) : item.modifiedData()->Length)); } -ItemImpl::~ItemImpl() +ItemImpl::~ItemImpl() throw() { if (mKeychain && *mPrimaryKey) mKeychain->removeItem(*mPrimaryKey, this); @@ -262,7 +263,7 @@ ItemImpl::add(Keychain &keychain) AclFactory aclFactory; const AccessCredentials *nullCred = aclFactory.nullCred(); - RefPointer access = mAccess; + SecPointer access = mAccess; if (!access) { // create default access controls for the new item CssmDbAttributeData *data = mDbAttributes->find(Schema::attributeInfo(kSecLabelItemAttr)); @@ -275,7 +276,7 @@ ItemImpl::add(Keychain &keychain) CssmDbAttributeData *data = mDbAttributes->find(Schema::attributeInfo(kSecServiceItemAttr)); if (data && data->Value[0].Length == 6 && !memcmp("iTools", data->Value[0].Data, 6)) { - typedef vector > AclSet; + typedef vector > AclSet; AclSet acls; access->findAclsForRight(CSSM_ACL_AUTHORIZATION_DECRYPT, acls); for (AclSet::const_iterator it = acls.begin(); it != acls.end(); it++) @@ -323,11 +324,22 @@ ItemImpl::add(Keychain &keychain) } Item -ItemImpl::copyTo(const Keychain &keychain, Access *newAccess /* = NULL */) +ItemImpl::copyTo(const Keychain &keychain, Access *newAccess) { Item item(*this); if (newAccess) item->setAccess(newAccess); + else + { + /* Attempt to copy the access from the current item to the newly created one. */ + SSGroup myGroup = group(); + if (myGroup) + { + SecPointer access = new Access(*myGroup); + item->setAccess(access); + } + } + keychain->add(item); return item; } @@ -447,11 +459,16 @@ ItemImpl::setAccess(Access *newAccess) CssmClient::DbUniqueRecord ItemImpl::dbUniqueRecord() { + if (!isPersistant()) // is there no database attached? + { + MacOSError::throwMe(errSecNotAvailable); + } + if (!mUniqueId) { - DbCursor cursor(mPrimaryKey->createCursor(mKeychain)); - if (!cursor->next(NULL, NULL, mUniqueId)) - MacOSError::throwMe(errSecInvalidItemRef); + DbCursor cursor(mPrimaryKey->createCursor(mKeychain)); + if (!cursor->next(NULL, NULL, mUniqueId)) + MacOSError::throwMe(errSecInvalidItemRef); } return mUniqueId; @@ -625,21 +642,24 @@ ItemImpl::getContent(SecItemClass *itemClass, SecKeychainAttributeList *attrList *outData=itemData.data(); itemData.Data=NULL; - *length=itemData.length(); + if (length) *length=itemData.length(); itemData.Length=0; } } else if (attrList != NULL) { getLocalContent (*attrList); - *outData = NULL; - *length = 0; + if (outData) *outData = NULL; + if (length) *length = 0; } // inform anyone interested that we are doing this #if SENDACCESSNOTIFICATIONS if (outData) { + secdebug("kcnotify", "ItemImpl::getContent(0x%x, 0x%x, 0x%x, 0x%x) retrieved content", + (unsigned int)itemClass, (unsigned int)attrList, (unsigned int)length, (unsigned int)outData); + KCEventNotifier::PostKeychainEvent(kSecDataAccessEvent, mKeychain, this); } #endif @@ -758,10 +778,13 @@ ItemImpl::getAttributesAndData(SecKeychainAttributeInfo *info, SecItemClass *ite *outData=itemData.data(); itemData.Data=NULL; - *length=itemData.length(); + if (length) *length=itemData.length(); itemData.Length=0; #if SENDACCESSNOTIFICATIONS + secdebug("kcnotify", "ItemImpl::getAttributesAndData(0x%x, 0x%x, 0x%x, 0x%x, 0x%x) retrieved data", + (unsigned int)info, (unsigned int)itemClass, (unsigned int)attrList, (unsigned int)length, (unsigned int)outData); + KCEventNotifier::PostKeychainEvent(kSecDataAccessEvent, mKeychain, this); #endif } @@ -818,7 +841,7 @@ ItemImpl::getAttributeFrom(CssmDbAttributeData *data, SecKeychainAttribute &attr { static const uint32 zero = 0; uint32 length; - const void *buf; + const void *buf = NULL; // Temporary storage for buf. SInt64 macLDT; @@ -924,6 +947,8 @@ ItemImpl::getData(CssmDataContainer& outData) getContent(NULL, &outData); #if SENDACCESSNOTIFICATIONS + secdebug("kcnotify", "ItemImpl::getData retrieved data"); + //%%% be done elsewhere, but here is good for now KCEventNotifier::PostKeychainEvent(kSecDataAccessEvent, mKeychain, this); #endif @@ -1023,7 +1048,7 @@ Item::Item() { } -Item::Item(ItemImpl *impl) : RefPointer(impl) +Item::Item(ItemImpl *impl) : SecPointer(impl) { } @@ -1050,7 +1075,7 @@ Item::Item(SecItemClass itemClass, SecKeychainAttributeList *attrList, UInt32 le } Item::Item(const Keychain &keychain, const PrimaryKey &primaryKey, const CssmClient::DbUniqueRecord &uniqueId) - : RefPointer( + : SecPointer( primaryKey->recordType() == CSSM_DL_DB_RECORD_X509_CERTIFICATE ? new Certificate(keychain, primaryKey, uniqueId) : (primaryKey->recordType() == CSSM_DL_DB_RECORD_PUBLIC_KEY @@ -1062,7 +1087,7 @@ Item::Item(const Keychain &keychain, const PrimaryKey &primaryKey, const CssmCli } Item::Item(const Keychain &keychain, const PrimaryKey &primaryKey) - : RefPointer( + : SecPointer( primaryKey->recordType() == CSSM_DL_DB_RECORD_X509_CERTIFICATE ? new Certificate(keychain, primaryKey) : (primaryKey->recordType() == CSSM_DL_DB_RECORD_PUBLIC_KEY @@ -1074,7 +1099,7 @@ Item::Item(const Keychain &keychain, const PrimaryKey &primaryKey) } Item::Item(ItemImpl &item) - : RefPointer( + : SecPointer( item.recordType() == CSSM_DL_DB_RECORD_X509_CERTIFICATE ? new Certificate(safer_cast(item)) : (item.recordType() == CSSM_DL_DB_RECORD_PUBLIC_KEY diff --git a/Keychain/Item.h b/Keychain/Item.h index 8c0e9c24..1ce52279 100644 --- a/Keychain/Item.h +++ b/Keychain/Item.h @@ -39,9 +39,12 @@ class Keychain; class ItemImpl : public SecCFObject { public: + SECCFFUNCTIONS(ItemImpl, SecKeychainItemRef, errSecInvalidItemRef) + friend class Item; friend class KeychainImpl; protected: + // new item constructors ItemImpl(SecItemClass itemClass, OSType itemCreator, UInt32 length, const void* data); @@ -68,7 +71,7 @@ protected: static const CSSM_DATA &defaultAttributeValue(const CSSM_DB_ATTRIBUTE_INFO &info); public: - virtual ~ItemImpl(); + virtual ~ItemImpl() throw(); bool isPersistant() const; bool isModified() const; @@ -116,7 +119,7 @@ protected: // new item members auto_ptr mData; auto_ptr mDbAttributes; - RefPointer mAccess; + SecPointer mAccess; // db item members CssmClient::DbUniqueRecord mUniqueId; @@ -125,7 +128,7 @@ protected: }; -class Item : public RefPointer +class Item : public SecPointer { public: Item(); diff --git a/Keychain/KCCursor.cpp b/Keychain/KCCursor.cpp index 11f88e2d..f602a0e5 100644 --- a/Keychain/KCCursor.cpp +++ b/Keychain/KCCursor.cpp @@ -39,7 +39,8 @@ using namespace CSSMDateTimeUtils; // KCCursorImpl::KCCursorImpl(const StorageManager::KeychainList &searchList, SecItemClass itemClass, const SecKeychainAttributeList *attrList) : mSearchList(searchList), - mCurrent(mSearchList.begin()) + mCurrent(mSearchList.begin()), + mAllFailed(true) { recordType(Schema::recordTypeFor(itemClass)); @@ -82,7 +83,8 @@ KCCursorImpl::KCCursorImpl(const StorageManager::KeychainList &searchList, SecIt KCCursorImpl::KCCursorImpl(const StorageManager::KeychainList &searchList, const SecKeychainAttributeList *attrList) : mSearchList(searchList), - mCurrent(mSearchList.begin()) + mCurrent(mSearchList.begin()), + mAllFailed(true) { if (!attrList) // No additional selectionPredicates: we are done return; @@ -134,7 +136,7 @@ KCCursorImpl::KCCursorImpl(const StorageManager::KeychainList &searchList, const } } -KCCursorImpl::~KCCursorImpl() +KCCursorImpl::~KCCursorImpl() throw() { } @@ -143,6 +145,7 @@ KCCursorImpl::next(Item &item) { DbAttributes dbAttributes; DbUniqueRecord uniqueId; + OSStatus status = 0; for (;;) { @@ -150,6 +153,11 @@ KCCursorImpl::next(Item &item) { if (mCurrent == mSearchList.end()) { + // If we got always failed when calling mDbCursor->next return the error from + // the last call to mDbCursor->next now + if (mAllFailed && status) + CssmError::throwMe(status); + // No more keychains to search so we are done. return false; } @@ -161,14 +169,14 @@ KCCursorImpl::next(Item &item) try { gotRecord = mDbCursor->next(&dbAttributes, NULL, uniqueId); + mAllFailed = false; } catch(const CssmCommonError &err) { - OSStatus status = err.osStatus(); - if (status != CSSMERR_DL_DATASTORE_DOESNOT_EXIST - && status != CSSMERR_DL_INVALID_RECORDTYPE) - throw; - + // Catch the last error we get and move on to the next keychain + // This error will be returned when we reach the end of our keychain list + // iff all calls to KCCursorImpl::next failed + status = err.osStatus(); gotRecord = false; } diff --git a/Keychain/KCCursor.h b/Keychain/KCCursor.h index 8dd9bfd5..b0827b19 100644 --- a/Keychain/KCCursor.h +++ b/Keychain/KCCursor.h @@ -33,34 +33,37 @@ class KCCursorImpl : public SecCFObject, public CssmAutoQuery { NOCOPY(KCCursorImpl) public: + SECCFFUNCTIONS(KCCursorImpl, SecKeychainSearchRef, errSecInvalidSearchRef) + friend class KCCursor; protected: KCCursorImpl(const StorageManager::KeychainList &searchList, SecItemClass itemClass, const SecKeychainAttributeList *attrList); KCCursorImpl(const StorageManager::KeychainList &searchList, const SecKeychainAttributeList *attrList); public: - virtual ~KCCursorImpl(); + virtual ~KCCursorImpl() throw(); bool next(Item &item); private: StorageManager::KeychainList mSearchList; StorageManager::KeychainList::iterator mCurrent; CssmClient::DbCursor mDbCursor; + bool mAllFailed; }; -class KCCursor : public RefPointer +class KCCursor : public SecPointer { public: KCCursor() {} - KCCursor(KCCursorImpl *impl) : RefPointer(impl) {} + KCCursor(KCCursorImpl *impl) : SecPointer(impl) {} KCCursor(const StorageManager::KeychainList &searchList, const SecKeychainAttributeList *attrList) - : RefPointer(new KCCursorImpl(searchList, attrList)) {} + : SecPointer(new KCCursorImpl(searchList, attrList)) {} KCCursor(const StorageManager::KeychainList &searchList, SecItemClass itemClass, const SecKeychainAttributeList *attrList) - : RefPointer(new KCCursorImpl(searchList, itemClass, attrList)) {} + : SecPointer(new KCCursorImpl(searchList, itemClass, attrList)) {} typedef KCCursorImpl Impl; }; diff --git a/Keychain/KCEventNotifier.cpp b/Keychain/KCEventNotifier.cpp index 48ad8818..384a210d 100644 --- a/Keychain/KCEventNotifier.cpp +++ b/Keychain/KCEventNotifier.cpp @@ -30,10 +30,10 @@ To Do: */ +#include "ssclient.h" #include "KCEventNotifier.h" #include "KCExceptions.h" #include "Keychains.h" -#include using namespace KeychainCore; @@ -56,39 +56,31 @@ void KCEventNotifier::PostKeychainEvent(SecKeychainEvent whichEvent, const DLDbIdentifier &dlDbIdentifier, const PrimaryKey &primaryKey) { - CFRef mutableDict(::CFDictionaryCreateMutable(kCFAllocatorDefault,0, - &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); - KCThrowIfMemFail_(CFMutableDictionaryRef(mutableDict)); - - SInt32 theEvent = SInt32(whichEvent); - CFRef theEventData(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &theEvent)); - KCThrowIfMemFail_(CFNumberRef(theEventData)); - CFDictionarySetValue(mutableDict, kSecEventTypeKey, theEventData); + NameValueDictionary nvd; pid_t thePid = getpid(); - CFRef thePidData(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &thePid)); - KCThrowIfMemFail_(CFNumberRef(thePidData)); - CFDictionarySetValue(mutableDict, kSecEventPidKey, thePidData); + nvd.Insert (new NameValuePair (PID_KEY, CssmData (reinterpret_cast(&thePid), sizeof (pid_t)))); if (dlDbIdentifier) { - CFRef dict(DLDbListCFPref::dlDbIdentifierToCFDictionaryRef(dlDbIdentifier)); - KCThrowIfMemFail_(CFDictionaryRef(dict)); - CFDictionarySetValue(mutableDict, kSecEventKeychainKey, dict); + NameValueDictionary::MakeNameValueDictionaryFromDLDbIdentifier (dlDbIdentifier, nvd); } + CssmData* pKey = primaryKey; + if (primaryKey) { - CFRef data(CFDataCreate(kCFAllocatorDefault, primaryKey->Data, primaryKey->Length)); - KCThrowIfMemFail_(CFDataRef(data)); - CFDictionarySetValue(mutableDict, kSecEventItemKey, data); + nvd.Insert (new NameValuePair (ITEM_KEY, *pKey)); } + // flatten the dictionary + CssmData data; + nvd.Export (data); + + SecurityServer::ClientSession cs (CssmAllocator::standard(), CssmAllocator::standard()); + cs.postNotification (Listener::databaseNotifications, whichEvent, data); + + secdebug("kcnotify", "KCEventNotifier::PostKeychainEvent posted event %u", (unsigned int) whichEvent); - // 'name' has to be globally unique (could be KCLockEvent, etc.) - // 'object' is just information or a context that can be used. - // 'userInfo' has info on event (i.e. which DL/DB(kc - see John's Dict), the event, - // item(cssmdbuniqueRec)) - CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), - kSecEventNotificationName, NULL, mutableDict, false); + free (data.data ()); } diff --git a/Keychain/KCEventNotifier.h b/Keychain/KCEventNotifier.h index 30092c0c..7eb92393 100644 --- a/Keychain/KCEventNotifier.h +++ b/Keychain/KCEventNotifier.h @@ -25,6 +25,7 @@ #include #include #include +#include "dictionary.h" namespace Security { @@ -32,12 +33,6 @@ namespace Security namespace KeychainCore { -#define kSecEventNotificationName CFSTR("com.apple.securitycore.kcevent") -#define kSecEventTypeKey CFSTR("type") -#define kSecEventPidKey CFSTR("pid") -#define kSecEventKeychainKey CFSTR("keychain") -#define kSecEventItemKey CFSTR("item") - class Keychain; class KCEventNotifier diff --git a/Keychain/KCEventObserver.cpp b/Keychain/KCEventObserver.cpp index 09943893..416c2637 100644 --- a/Keychain/KCEventObserver.cpp +++ b/Keychain/KCEventObserver.cpp @@ -34,55 +34,25 @@ using namespace Security; -Observer::Observer() +void Observer::EventReceived (Listener::Domain domain, Listener::Event event, const void* data, size_t dataLength) { -} -// -// Upon creation of this object, add this observer for this instance of KeychainCore -// -Observer::Observer( CFStringRef name, const void *object, - CFNotificationSuspensionBehavior suspensionBehavior ) -{ - add( name, object, suspensionBehavior ); -} + secdebug("kcnotify", "Security::Observer::EventReceived got event %u", (unsigned int) event); -// -// Upon destruction of this object, remove 'this' observer for this instance of KeychainCore -// -Observer::~Observer() -{ - ::CFNotificationCenterRemoveEveryObserver( CFNotificationCenterGetDistributedCenter(), this ); + // make a NameValueDictionary from the data we received + CssmData dt ((void*) data, dataLength); + NameValueDictionary nvd (dt); + Event (domain, event, nvd); } -// -// 'callback' is passed in to CFNotificationCenterAddObserver() when this object -// is constructed when KeychainCore is created. 'callback' is called by CF whenever an event happens. -// -void Observer::callback(CFNotificationCenterRef center, - void* observer, - CFStringRef name, - const void* object, - CFDictionaryRef userInfo) + + +Observer::Observer (Listener::Domain whichDomain, Listener::EventMask whichEvents) { - // 'Event' is where this KeychainCore notifies it's clients of the kc event that just happened. - // - try - { - reinterpret_cast(observer)->Event( center, name, object, userInfo ); - } - catch(...) - { - // @@@ do a log to console(); - } + RequestEvents (whichDomain, whichEvents); } -// -// Add 'this' observer to CF for this instance of KeychainCore -// -void Observer::add( CFStringRef name, - const void* object, - CFNotificationSuspensionBehavior suspensionBehavior ) + + +Observer::~Observer () { - ::CFNotificationCenterAddObserver( CFNotificationCenterGetDistributedCenter(), - this, callback, name, object, suspensionBehavior ); } diff --git a/Keychain/KCEventObserver.h b/Keychain/KCEventObserver.h index 5d760199..cfe58f95 100644 --- a/Keychain/KCEventObserver.h +++ b/Keychain/KCEventObserver.h @@ -22,38 +22,23 @@ #ifndef _SECURITY_KCEVENTOBSERVER_H_ #define _SECURITY_KCEVENTOBSERVER_H_ -#include -#include +#include "dictionary.h" +#include "eventlistener.h" +#include "notifications.h" + namespace Security { -class Observer +class Observer : private SecurityServer::EventListener { +protected: + void EventReceived (Listener::Domain domain, Listener::Event event, const void* data, size_t dataLength); + public: - Observer (); - - Observer ( CFStringRef name, - const void* object, - CFNotificationSuspensionBehavior suspensionBehavior = - CFNotificationSuspensionBehaviorHold ); - - virtual ~Observer (); - - static void callback ( CFNotificationCenterRef center, - void* observer, - CFStringRef name, - const void* object, - CFDictionaryRef userInfo ); - - void add ( CFStringRef name, - const void* object, - CFNotificationSuspensionBehavior suspensionBehavior ); - - virtual void Event ( CFNotificationCenterRef center, - CFStringRef name, - const void* object, - CFDictionaryRef userInfo ) = 0; + Observer (Listener::Domain whichDomain, Listener::EventMask whichEvents); + virtual ~Observer (); + virtual void Event (Listener::Domain domain, Listener::Event whichEvent, NameValueDictionary &dictionary) = 0; }; } // end namespace Security diff --git a/Keychain/KeyItem.cpp b/Keychain/KeyItem.cpp index 3147b06e..5e41c74f 100644 --- a/Keychain/KeyItem.cpp +++ b/Keychain/KeyItem.cpp @@ -25,52 +25,146 @@ #include #include #include +#include #include +#include "clNssUtils.h" +#include "KCEventNotifier.h" // @@@ This needs to be shared. -static CSSM_DB_NAME_ATTR(kSecKeyLabel, 6, "Label", 0, NULL, BLOB); static CSSM_DB_NAME_ATTR(kSecKeyPrintName, 1, "PrintName", 0, NULL, BLOB); +static CSSM_DB_NAME_ATTR(kSecKeyLabel, 6, "Label", 0, NULL, BLOB); +static CSSM_DB_NAME_ATTR(kSecApplicationTag, 7, "ApplicationTag", 0, NULL, BLOB); using namespace KeychainCore; KeyItem::KeyItem(const Keychain &keychain, const PrimaryKey &primaryKey, const CssmClient::DbUniqueRecord &uniqueId) : ItemImpl(keychain, primaryKey, uniqueId), - mKey(NULL) + mKey() { } KeyItem::KeyItem(const Keychain &keychain, const PrimaryKey &primaryKey) : ItemImpl(keychain, primaryKey), - mKey(NULL) + mKey() { } KeyItem::KeyItem(KeyItem &keyItem) : ItemImpl(keyItem), - mKey(NULL) + mKey() { + // @@@ this doesn't work for keys that are not in a keychain. } -KeyItem::~KeyItem() +KeyItem::KeyItem(const CssmClient::Key &key) : + ItemImpl(key->keyClass() + CSSM_DL_DB_RECORD_PUBLIC_KEY, (OSType)0, (UInt32)0, (const void*)NULL), + mKey(key) +{ + if (key->keyClass() > CSSM_KEYCLASS_SESSION_KEY) + MacOSError::throwMe(paramErr); +} + +KeyItem::~KeyItem() throw() { - if (mKey) - { - CssmClient::SSDbUniqueRecord uniqueId(ssDbUniqueRecord()); - uniqueId->database()->csp()->freeKey(*mKey); - uniqueId->allocator().free(mKey); - } } void KeyItem::update() { - MacOSError::throwMe(unimpErr); + ItemImpl::update(); } Item -KeyItem::copyTo(const Keychain &keychain) +KeyItem::copyTo(const Keychain &keychain, Access *newAccess) { - MacOSError::throwMe(unimpErr); + if (!keychain->database()->dl()->subserviceMask() & CSSM_SERVICE_CSP) + MacOSError::throwMe(errSecInvalidKeychain); + + /* Get the destination keychains db. */ + SSDb ssDb(safe_cast(&(*keychain->database()))); + + /* Make sure mKey is valid. */ + key(); + + // Generate a random label to use initially + CssmClient::CSP appleCsp(gGuidAppleCSP); + CssmClient::Random random(appleCsp, CSSM_ALGID_APPLE_YARROW); + uint8 labelBytes[20]; + CssmData label(labelBytes, sizeof(labelBytes)); + random.generate(label, label.Length); + + /* Set up the ACL for the new key. */ + SecPointer access; + if (newAccess) + access = newAccess; + else + access = new Access(*mKey); + + /* Generate a random 3DES wrapping Key. */ + CssmClient::GenerateKey genKey(csp(), CSSM_ALGID_3DES_3KEY, 192); + CssmClient::Key wrappingKey(genKey(KeySpec(CSSM_KEYUSE_WRAP | CSSM_KEYUSE_UNWRAP, + CSSM_KEYATTR_EXTRACTABLE /* | CSSM_KEYATTR_RETURN_DATA */))); + + /* Extract the key by wrapping it with the wrapping key. */ + CssmClient::WrapKey wrap(csp(), CSSM_ALGID_3DES_3KEY_EDE); + wrap.key(wrappingKey); + wrap.cred(getCredentials(CSSM_ACL_AUTHORIZATION_EXPORT_WRAPPED, kSecCredentialTypeDefault)); + wrap.mode(CSSM_ALGMODE_ECBPad); + wrap.padding(CSSM_PADDING_PKCS7); + CssmClient::Key wrappedKey(wrap(mKey)); + + /* Unwrap the new key into the new Keychain. */ + CssmClient::UnwrapKey unwrap(keychain->csp(), CSSM_ALGID_3DES_3KEY_EDE); + unwrap.key(wrappingKey); + unwrap.mode(CSSM_ALGMODE_ECBPad); + unwrap.padding(CSSM_PADDING_PKCS7); + + /* Setup the dldbHandle in the context. */ + unwrap.add(CSSM_ATTRIBUTE_DL_DB_HANDLE, ssDb->handle()); + + /* Set up an initial aclEntry so we can change it after the unwrap. */ + Access::Maker maker; + ResourceControlContext rcc; + maker.initialOwner(rcc, NULL); + unwrap.aclEntry(rcc.input()); + + /* Unwrap the key. */ + uint32 usage = mKey->usage(); + /* Work around csp brokeness where it sets all usage bits in the Keyheader when CSSM_KEYUSE_ANY is set. */ + if (usage & CSSM_KEYUSE_ANY) + usage = CSSM_KEYUSE_ANY; + + CssmClient::Key unwrappedKey(unwrap(wrappedKey, KeySpec(usage, + (mKey->attributes() | CSSM_KEYATTR_PERMANENT) & ~(CSSM_KEYATTR_ALWAYS_SENSITIVE | CSSM_KEYATTR_NEVER_EXTRACTABLE), + label))); + + /* Look up unwrapped key in the DLDB. */ + DbUniqueRecord uniqueId; + SSDbCursor dbCursor(ssDb, 1); + dbCursor->recordType(recordType()); + dbCursor->add(CSSM_DB_EQUAL, kSecKeyLabel, label); + CssmClient::Key copiedKey; + if (!dbCursor->nextKey(NULL, copiedKey, uniqueId)) + MacOSError::throwMe(errSecItemNotFound); + + /* Copy the Label, PrintName and ApplicationTag attributes from the old key to the new one. */ + dbUniqueRecord(); + DbAttributes oldDbAttributes(mUniqueId->database(), 3); + oldDbAttributes.add(kSecKeyLabel); + oldDbAttributes.add(kSecKeyPrintName); + oldDbAttributes.add(kSecApplicationTag); + mUniqueId->get(&oldDbAttributes, NULL); + uniqueId->modify(recordType(), &oldDbAttributes, NULL, CSSM_DB_MODIFY_ATTRIBUTE_REPLACE); + + /* Set the acl and owner on the unwrapped key. */ + access->setAccess(*unwrappedKey, maker); + + /* Return a keychain items which represents the new key. */ + Item item(keychain->item(recordType(), uniqueId)); + + KCEventNotifier::PostKeychainEvent(kSecAddEvent, keychain, item); + + return item; } void @@ -91,20 +185,66 @@ KeyItem::ssDbUniqueRecord() return CssmClient::SSDbUniqueRecord(safe_cast(impl)); } -const CssmKey & -KeyItem::cssmKey() +CssmClient::Key & +KeyItem::key() { if (!mKey) { CssmClient::SSDbUniqueRecord uniqueId(ssDbUniqueRecord()); CssmDataContainer dataBlob(uniqueId->allocator()); uniqueId->get(NULL, &dataBlob); - mKey = reinterpret_cast(dataBlob.Data); - dataBlob.Data = NULL; - dataBlob.Length = 0; + mKey = CssmClient::Key(uniqueId->database()->csp(), *reinterpret_cast(dataBlob.Data)); } - return *mKey; + return mKey; +} + +CssmClient::CSP +KeyItem::csp() +{ + return key()->csp(); +} + + +const CSSM_X509_ALGORITHM_IDENTIFIER& +KeyItem::algorithmIdentifier() +{ +#if 0 + CssmKey *mKey; + CSSM_KEY_TYPE algorithm + CSSM_KEY_PTR cssmKey = (CSSM_KEY_PTR)thisData->Data; +cssmKey->KeyHeader + static void printKeyHeader( + const CSSM_KEYHEADER &hdr) +{ + printf(" Algorithm : "); + switch(hdr.AlgorithmId) { +CSSM_X509_ALGORITHM_IDENTIFIER algID; + +CSSM_OID *CL_algToOid( + CSSM_ALGORITHMS algId) +typedef struct cssm_x509_algorithm_identifier { + CSSM_OID algorithm; + CSSM_DATA parameters; +} CSSM_X509_ALGORITHM_IDENTIFIER, *CSSM_X509_ALGORITHM_IDENTIFIER_PTR; +#endif + + abort(); +} + +unsigned int +KeyItem::strengthInBits(const CSSM_X509_ALGORITHM_IDENTIFIER *algid) +{ + // @@@ Make a context with key based on algid and use that to get the effective keysize and not just the logical one. + CSSM_KEY_SIZE keySize = {}; + CSSM_RETURN rv = CSSM_QueryKeySizeInBits (csp()->handle(), + NULL, + key(), + &keySize); + if (rv) + return 0; + + return keySize.LogicalKeySizeInBits; } const AccessCredentials * @@ -113,6 +253,9 @@ KeyItem::getCredentials( SecCredentialType credentialType) { // @@@ Fix this to actually examine the ACL for this key and consider operation and do the right thing. + //AutoAclEntryInfoList aclInfos; + //key()->getAcl(aclInfos); + AclFactory factory; switch (credentialType) { @@ -137,9 +280,9 @@ KeyItem::createPair( uint32 publicKeyAttr, CSSM_KEYUSE privateKeyUsage, uint32 privateKeyAttr, - RefPointer initialAccess, - RefPointer &outPublicKey, - RefPointer &outPrivateKey) + SecPointer initialAccess, + SecPointer &outPublicKey, + SecPointer &outPrivateKey) { bool freeKeys = false; bool deleteContext = false; @@ -301,9 +444,9 @@ KeyItem::importPair( Keychain keychain, const CSSM_KEY &publicWrappedKey, const CSSM_KEY &privateWrappedKey, - RefPointer initialAccess, - RefPointer &outPublicKey, - RefPointer &outPrivateKey) + SecPointer initialAccess, + SecPointer &outPublicKey, + SecPointer &outPrivateKey) { bool freePublicKey = false; bool freePrivateKey = false; @@ -473,3 +616,144 @@ KeyItem::importPair( if (deleteContext) CSSM_DeleteContext(ccHandle); } + +KeyItem * +KeyItem::generate(Keychain keychain, + CSSM_ALGORITHMS algorithm, + uint32 keySizeInBits, + CSSM_CC_HANDLE contextHandle, + CSSM_KEYUSE keyUsage, + uint32 keyAttr, + SecPointer initialAccess) +{ + CssmClient::CSP appleCsp(gGuidAppleCSP); + CssmClient::CSP csp(NULL); + SSDb ssDb(NULL); + uint8 labelBytes[20]; + CssmData label(labelBytes, sizeof(labelBytes)); + bool freeKey = false; + bool deleteContext = false; + const CSSM_DATA *plabel = NULL; + KeyItem *outKey; + + if (keychain) + { + if (!keychain->database()->dl()->subserviceMask() & CSSM_SERVICE_CSP) + MacOSError::throwMe(errSecInvalidKeychain); + + ssDb = SSDb(safe_cast(&(*keychain->database()))); + csp = keychain->csp(); + + // Generate a random label to use initially + CssmClient::Random random(appleCsp, CSSM_ALGID_APPLE_YARROW); + random.generate(label, label.Length); + plabel = &label; + } + else + { + // Not a persistant key so create it in the regular csp + csp = appleCsp; + } + + // Create a Access::Maker for the initial owner of the private key. + ResourceControlContext *prcc = NULL, rcc; + const AccessCredentials *cred = NULL; + Access::Maker maker; + if (keychain && initialAccess) + { + memset(&rcc, 0, sizeof(rcc)); + // @@@ Potentially provide a credential argument which allows us to generate keys in the csp. Currently the CSP let's anyone do this, but we might restrict this in the future, f.e. a smartcard could require out of band pin entry before a key can be generated. + maker.initialOwner(rcc); + // Create the cred we need to manipulate the keys until we actually set a new access control for them. + cred = maker.cred(); + prcc = &rcc; + } + + CSSM_KEY cssmKey; + + CSSM_CC_HANDLE ccHandle = 0; + + try + { + CSSM_RETURN status; + if (contextHandle) + ccHandle = contextHandle; + else + { + status = CSSM_CSP_CreateKeyGenContext(csp->handle(), algorithm, keySizeInBits, NULL, NULL, NULL, NULL, NULL, &ccHandle); + if (status) + CssmError::throwMe(status); + deleteContext = true; + } + + if (ssDb) + { + CSSM_DL_DB_HANDLE dldbHandle = ssDb->handle(); + CSSM_DL_DB_HANDLE_PTR dldbHandlePtr = &dldbHandle; + CSSM_CONTEXT_ATTRIBUTE contextAttributes = { CSSM_ATTRIBUTE_DL_DB_HANDLE, sizeof(dldbHandle), { (char *)dldbHandlePtr } }; + status = CSSM_UpdateContextAttributes(ccHandle, 1, &contextAttributes); + if (status) + CssmError::throwMe(status); + + keyAttr |= CSSM_KEYATTR_PERMANENT; + } + + // Generate the key + status = CSSM_GenerateKey(ccHandle, keyUsage, keyAttr, plabel, prcc, &cssmKey); + if (status) + CssmError::throwMe(status); + + if (ssDb) + { + freeKey = true; + // Find the keys we just generated in the DL to get SecKeyRef's to them + // so we can change the label to be the hash of the public key, and + // fix up other attributes. + + // Look up key in the DLDB. + DbAttributes dbAttributes; + DbUniqueRecord uniqueId; + SSDbCursor dbCursor(ssDb, 1); + dbCursor->recordType(CSSM_DL_DB_RECORD_SYMMETRIC_KEY); + dbCursor->add(CSSM_DB_EQUAL, kSecKeyLabel, label); + CssmClient::Key key; + if (!dbCursor->nextKey(&dbAttributes, key, uniqueId)) + MacOSError::throwMe(errSecItemNotFound); + + // Finally fix the acl and owner of the key to the specified access control settings. + if (initialAccess) + initialAccess->setAccess(*key, maker); + + // Create keychain items which will represent the keys. + outKey = safe_cast(&(*keychain->item(CSSM_DL_DB_RECORD_SYMMETRIC_KEY, uniqueId))); + } + else + { + CssmClient::Key tempKey(csp, cssmKey); + outKey = new KeyItem(tempKey); + } + } + catch (...) + { + if (freeKey) + { + // Delete the keys if something goes wrong so we don't end up with inaccesable keys in the database. + CSSM_FreeKey(csp->handle(), cred, &cssmKey, TRUE); + } + + if (deleteContext) + CSSM_DeleteContext(ccHandle); + + throw; + } + + if (freeKey) + { + CSSM_FreeKey(csp->handle(), NULL, &cssmKey, FALSE); + } + + if (deleteContext) + CSSM_DeleteContext(ccHandle); + + return outKey; +} diff --git a/Keychain/KeyItem.h b/Keychain/KeyItem.h index 553a56a9..386c461a 100644 --- a/Keychain/KeyItem.h +++ b/Keychain/KeyItem.h @@ -34,6 +34,8 @@ class KeyItem : public ItemImpl { NOCOPY(KeyItem) public: + SECCFFUNCTIONS(KeyItem, SecKeyRef, errSecInvalidItemRef) + // db item contstructor KeyItem(const Keychain &keychain, const PrimaryKey &primaryKey, const CssmClient::DbUniqueRecord &uniqueId); @@ -42,14 +44,20 @@ public: KeyItem(KeyItem &keyItem); - virtual ~KeyItem(); + KeyItem(const CssmClient::Key &key); + + virtual ~KeyItem() throw(); virtual void update(); - virtual Item copyTo(const Keychain &keychain); + virtual Item copyTo(const Keychain &keychain, Access *newAccess = NULL); virtual void didModify(); CssmClient::SSDbUniqueRecord ssDbUniqueRecord(); - const CssmKey &cssmKey(); + CssmClient::Key &key(); + CssmClient::CSP csp(); + + const CSSM_X509_ALGORITHM_IDENTIFIER& algorithmIdentifier(); + unsigned int strengthInBits(const CSSM_X509_ALGORITHM_IDENTIFIER *algid); const AccessCredentials *getCredentials( CSSM_ACL_AUTHORIZATION_TAG operation, @@ -64,22 +72,32 @@ public: uint32 publicKeyAttr, CSSM_KEYUSE privateKeyUsage, uint32 privateKeyAttr, - RefPointer initialAccess, - RefPointer &outPublicKey, - RefPointer &outPrivateKey); + SecPointer initialAccess, + SecPointer &outPublicKey, + SecPointer &outPrivateKey); static void importPair( Keychain keychain, const CSSM_KEY &publicCssmKey, const CSSM_KEY &privateCssmKey, - RefPointer initialAccess, - RefPointer &outPublicKey, - RefPointer &outPrivateKey); + SecPointer initialAccess, + SecPointer &outPublicKey, + SecPointer &outPrivateKey); + + static KeyItem *generate( + Keychain keychain, + CSSM_ALGORITHMS algorithm, + uint32 keySizeInBits, + CSSM_CC_HANDLE contextHandle, + CSSM_KEYUSE keyUsage, + uint32 keyAttr, + SecPointer initialAccess); protected: virtual PrimaryKey add(Keychain &keychain); private: - CssmKey *mKey; + CssmClient::Key mKey; + const CSSM_X509_ALGORITHM_IDENTIFIER *algid; }; } // end namespace KeychainCore diff --git a/Keychain/Keychains.cpp b/Keychain/Keychains.cpp index e818051b..ae053cf8 100644 --- a/Keychain/Keychains.cpp +++ b/Keychain/Keychains.cpp @@ -211,8 +211,9 @@ KeychainImpl::KeychainImpl(const Db &db) { } -KeychainImpl::~KeychainImpl() +KeychainImpl::~KeychainImpl() throw() { + globals().storageManager.removeKeychain(dLDbIdentifier(), this); } bool @@ -251,18 +252,8 @@ KeychainImpl::create(UInt32 passwordLength, const void *inPassword) // @@@ Share this instance const CssmData password(const_cast(inPassword), passwordLength); - AclFactory::PasswordChangeCredentials pCreds (password, alloc); - const AccessCredentials* aa = pCreds; - - // @@@ Create a nice wrapper for building the default AclEntryPrototype. - TypedList subject(alloc, CSSM_ACL_SUBJECT_TYPE_ANY); - AclEntryPrototype protoType(subject); - AuthorizationGroup &authGroup = protoType.authorization(); - CSSM_ACL_AUTHORIZATION_TAG tag = CSSM_ACL_AUTHORIZATION_ANY; - authGroup.NumberOfAuthTags = 1; - authGroup.AuthTags = &tag; - - const ResourceControlContext rcc(protoType, const_cast(aa)); + AclFactory::PasswordChangeCredentials pCreds (password, alloc); + AclFactory::AnyResourceContext rcc(pCreds); create(&rcc); } @@ -277,25 +268,8 @@ void KeychainImpl::create(ConstStringPtr inPassword) void KeychainImpl::create() { - CssmAllocator &alloc = CssmAllocator::standard(); - // @@@ Share this instance -#ifdef OBSOLETE - KeychainAclFactory aclFactory(alloc); - - const AccessCredentials *cred = aclFactory.keychainPromptUnlockCredentials(); -#endif - AclFactory aclFactor; - const AccessCredentials *cred = aclFactor.unlockCred (); - - // @@@ Create a nice wrapper for building the default AclEntryPrototype. - TypedList subject(alloc, CSSM_ACL_SUBJECT_TYPE_ANY); - AclEntryPrototype protoType(subject); - AuthorizationGroup &authGroup = protoType.authorization(); - CSSM_ACL_AUTHORIZATION_TAG tag = CSSM_ACL_AUTHORIZATION_ANY; - authGroup.NumberOfAuthTags = 1; - authGroup.AuthTags = &tag; - - const ResourceControlContext rcc(protoType, const_cast(cred)); + AclFactory aclFactory; + AclFactory::AnyResourceContext rcc(aclFactory.unlockCred()); create(&rcc); } @@ -317,6 +291,8 @@ KeychainImpl::create(const ResourceControlContext *rcc) mDb->resourceControlContext(NULL); mDb->dbInfo(NULL); // Clear the schema (to not break an open call later) globals().storageManager.created(Keychain(this)); + + KCEventNotifier::PostKeychainEvent (kSecKeychainListChangedEvent, this, NULL); } void @@ -541,7 +517,18 @@ KeychainImpl::makePrimaryKey(CSSM_DB_RECORDTYPE recordType, DbUniqueRecord &uniq const CssmAutoDbRecordAttributeInfo & KeychainImpl::primaryKeyInfosFor(CSSM_DB_RECORDTYPE recordType) { - return keychainSchema()->primaryKeyInfosFor(recordType); + try { + return keychainSchema()->primaryKeyInfosFor(recordType); + } catch (const CssmCommonError &error) { + switch (error.cssmError()) { + case errSecNoSuchClass: + case CSSMERR_DL_INVALID_RECORDTYPE: + resetSchema(); + return keychainSchema()->primaryKeyInfosFor(recordType); + default: + throw; + } + } } void KeychainImpl::gatherPrimaryKeyAttributes(DbAttributes& primaryKeyAttrs) @@ -557,17 +544,32 @@ void KeychainImpl::gatherPrimaryKeyAttributes(DbAttributes& primaryKeyAttrs) Item KeychainImpl::item(const PrimaryKey& primaryKey) { + // @@@ This retry code isn't really the right way to do this, + // we need to redo the locking structure here in the future. + bool tried = false; + for (;;) { - StLock _(mDbItemMapLock); - DbItemMap::iterator it = mDbItemMap.find(primaryKey); - if (it != mDbItemMap.end()) { - return Item(it->second); + StLock _(mDbItemMapLock); + DbItemMap::iterator it = mDbItemMap.find(primaryKey); + if (it != mDbItemMap.end()) + { + return Item(it->second); + } } - } - // Create an item with just a primary key - return Item(this, primaryKey); + try + { + // Create an item with just a primary key + return Item(this, primaryKey); + } + catch (const MacOSError &e) + { + if (tried || e.osStatus() != errSecDuplicateItem) + throw; + tried = true; + } + } } Item @@ -599,6 +601,12 @@ KeychainImpl::keychainSchema() return mKeychainSchema; } +void KeychainImpl::resetSchema() +{ + mKeychainSchema = NULL; // re-fetch it from db next time +} + + // Called from DbItemImpl's constructor (so it is only paritally constructed), add it to the map. void KeychainImpl::addItem(const PrimaryKey &primaryKey, ItemImpl *dbItemImpl) @@ -610,7 +618,7 @@ KeychainImpl::addItem(const PrimaryKey &primaryKey, ItemImpl *dbItemImpl) // @@@ There is a race condition here when being called in multiple threads // We might have added an item using add and received a notification at the same time //assert(true); - throw errSecDuplicateItem; + MacOSError::throwMe(errSecDuplicateItem); //mDbItemMap.erase(it); // @@@ What to do here? } @@ -622,7 +630,7 @@ void KeychainImpl::didDeleteItem(const ItemImpl *inItemImpl) { // Sent sent by CCallbackMgr. - debug("kcnotify", "%p notified that item %p was deleted", this, inItemImpl); + secdebug("kcnotify", "%p notified that item %p was deleted", this, inItemImpl); PrimaryKey primaryKey = inItemImpl->primaryKey(); StLock _(mDbItemMapLock); DbItemMap::iterator it = mDbItemMap.find(primaryKey); @@ -643,7 +651,18 @@ KeychainImpl::removeItem(const PrimaryKey &primaryKey, const ItemImpl *inItemImp void KeychainImpl::getAttributeInfoForItemID(CSSM_DB_RECORDTYPE itemID, SecKeychainAttributeInfo **Info) { - keychainSchema()->getAttributeInfoForRecordType(itemID, Info); + try { + keychainSchema()->getAttributeInfoForRecordType(itemID, Info); + } catch (const CssmCommonError &error) { + switch (error.cssmError()) { + case errSecNoSuchClass: + case CSSMERR_DL_INVALID_RECORDTYPE: + resetSchema(); + keychainSchema()->getAttributeInfoForRecordType(itemID, Info); + default: + throw; + } + } } void @@ -657,7 +676,18 @@ KeychainImpl::freeAttributeInfo(SecKeychainAttributeInfo *Info) CssmDbAttributeInfo KeychainImpl::attributeInfoFor(CSSM_DB_RECORDTYPE recordType, UInt32 tag) { - return keychainSchema()->attributeInfoFor(recordType, tag); + try { + return keychainSchema()->attributeInfoFor(recordType, tag); + } catch (const CssmCommonError &error) { + switch (error.cssmError()) { + case errSecNoSuchClass: + case CSSMERR_DL_INVALID_RECORDTYPE: + resetSchema(); + return keychainSchema()->attributeInfoFor(recordType, tag); + default: + throw; + } + } } @@ -665,8 +695,8 @@ Keychain Keychain::optional(SecKeychainRef handle) { if (handle) - return gTypes().keychain.required(handle); + return KeychainImpl::required(handle); else - return globals().defaultKeychain; + return globals().storageManager.defaultKeychain(); } diff --git a/Keychain/Keychains.h b/Keychain/Keychains.h index 832bf8a7..4d585c1d 100644 --- a/Keychain/Keychains.h +++ b/Keychain/Keychains.h @@ -96,6 +96,8 @@ class KeychainImpl : public SecCFObject { NOCOPY(KeychainImpl) public: + SECCFFUNCTIONS(KeychainImpl, SecKeychainRef, errSecInvalidKeychain) + friend class Keychain; friend class ItemImpl; protected: @@ -107,7 +109,7 @@ protected: PrimaryKey &newPK); public: - virtual ~KeychainImpl(); + virtual ~KeychainImpl() throw(); bool operator ==(const KeychainImpl &) const; @@ -164,6 +166,7 @@ public: void getAttributeInfoForItemID(CSSM_DB_RECORDTYPE itemID, SecKeychainAttributeInfo **Info); static void freeAttributeInfo(SecKeychainAttributeInfo *Info); KeychainSchema keychainSchema(); + void resetSchema(); void didDeleteItem(const ItemImpl *inItemImpl); private: @@ -179,18 +182,18 @@ private: }; -class Keychain : public RefPointer +class Keychain : public SecPointer { public: Keychain() {} - Keychain(KeychainImpl *impl) : RefPointer(impl) {} + Keychain(KeychainImpl *impl) : SecPointer(impl) {} static Keychain optional(SecKeychainRef handle); private: friend class StorageManager; Keychain(const CssmClient::Db &db) - : RefPointer(new KeychainImpl(db)) {} + : SecPointer(new KeychainImpl(db)) {} typedef KeychainImpl Impl; }; diff --git a/Keychain/Policies.cpp b/Keychain/Policies.cpp index 2cdbc9be..85006650 100644 --- a/Keychain/Policies.cpp +++ b/Keychain/Policies.cpp @@ -30,7 +30,7 @@ Policy::Policy(TP supportingTp, const CssmOid &policyOid) // value is as yet unimplemented } -Policy::~Policy() +Policy::~Policy() throw() { } diff --git a/Keychain/Policies.h b/Keychain/Policies.h index b15ad516..4ea7cfc3 100644 --- a/Keychain/Policies.h +++ b/Keychain/Policies.h @@ -23,6 +23,7 @@ #define _SECURITY_POLICY_H_ #include +#include #include #include @@ -42,15 +43,18 @@ class Policy : public SecCFObject { NOCOPY(Policy) public: + SECCFFUNCTIONS(Policy, SecPolicyRef, errSecInvalidItemRef) + Policy(TP supportingTp, const CssmOid &policyOid); public: - virtual ~Policy(); + virtual ~Policy() throw(); TP &tp() { return mTp; } const TP &tp() const { return mTp; } const CssmOid &oid() const { return mOid; } const CssmData &value() const { return mValue; } + CssmOwnedData &value() { return mValue; } bool operator < (const Policy& other) const; bool operator == (const Policy& other) const; diff --git a/Keychain/PolicyCursor.cpp b/Keychain/PolicyCursor.cpp index 576aefed..8532f1c5 100644 --- a/Keychain/PolicyCursor.cpp +++ b/Keychain/PolicyCursor.cpp @@ -19,6 +19,7 @@ // PolicyCursor.cpp // #include +#include #include #include @@ -39,6 +40,9 @@ static const CssmOid *theOidList[] = { static_cast(&CSSMOID_APPLE_ISIGN), static_cast(&CSSMOID_APPLE_X509_BASIC), static_cast(&CSSMOID_APPLE_TP_SSL), + static_cast(&CSSMOID_APPLE_TP_SMIME), + static_cast(&CSSMOID_APPLE_TP_EAP), + static_cast(&CSSMOID_APPLE_TP_REVOCATION_CRL), NULL // sentinel }; @@ -60,7 +64,7 @@ PolicyCursor::PolicyCursor(const CSSM_OID* oid, const CSSM_DATA* value) // // Destroy // -PolicyCursor::~PolicyCursor() +PolicyCursor::~PolicyCursor() throw() { } @@ -68,7 +72,7 @@ PolicyCursor::~PolicyCursor() // // Crank the iterator // -bool PolicyCursor::next(RefPointer &policy) +bool PolicyCursor::next(SecPointer &policy) { while (theOidList[mSearchPos]) { if (mOidGiven && mOid != *theOidList[mSearchPos]) { diff --git a/Keychain/PolicyCursor.h b/Keychain/PolicyCursor.h index bdfc2c94..7cd349ba 100644 --- a/Keychain/PolicyCursor.h +++ b/Keychain/PolicyCursor.h @@ -22,7 +22,7 @@ #define _SECURITY_POLICYCURSOR_H_ #include -#include +#include #include #include #include @@ -39,9 +39,11 @@ class PolicyCursor : public SecCFObject { NOCOPY(PolicyCursor) public: + SECCFFUNCTIONS(PolicyCursor, SecPolicySearchRef, errSecInvalidSearchRef) + PolicyCursor(const CSSM_OID* oid, const CSSM_DATA* value); - virtual ~PolicyCursor(); - bool next(RefPointer &policy); + virtual ~PolicyCursor() throw(); + bool next(SecPointer &policy); private: //CFArrayRef mKeychainSearchList; diff --git a/Keychain/Refs.h b/Keychain/Refs.h deleted file mode 100644 index a3464d21..00000000 --- a/Keychain/Refs.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - -#if 0 -// -// Refs.h -// -#ifndef _H_REFS -#define _H_REFS - -#include -#include - -namespace Security -{ - -namespace KeychainCore -{ - -class ReferencedObject : public RefCount -{ -public: - ReferencedObject() : mHandle(0) {} - virtual ~ReferencedObject() {} - - void addedRef(CSSM_HANDLE handle) { mHandle = handle; } - void removedRef(CSSM_HANDLE handle) { mHandle = 0; } - CSSM_HANDLE handle() const { return mHandle; } - - void killRef(); - -private: - CSSM_HANDLE mHandle; -}; - - -class RefObject : public HandleObject, public RefCount -{ -public: - RefObject(ReferencedObject &object) : mObject(&object) - { - if (mObject) - mObject->addedRef(reinterpret_cast(HandleObject::handle())); - } - - void ref() const { RefCount::ref(); } - unsigned int unref() const { return RefCount::unref(); } - - RefPointer mObject; -}; - - -inline void ReferencedObject::killRef() -{ - delete &killHandle(mHandle); - mHandle = 0; -} - - -template -class Ref -{ -public: - static _Handle handle(const _Object &object) - { - if (!object) - return 0; - - _Handle handle = reinterpret_cast<_Handle>(object->handle()); // Return the existing handle if it exists - if (handle) - { - retain(handle); - return handle; - } - - RefObject *ref = new RefObject(*object); - ref->ref(); - return reinterpret_cast<_Handle>(ref->HandleObject::handle()); - } - - static void retain(_Handle handle) - { findHandle(CSSM_HANDLE(handle), _ErrorCode).ref(); } - - static void release(_Handle handle) - { - RefObject &ref = findHandle(CSSM_HANDLE(handle), _ErrorCode); - if (ref.unref() == 0) - { - if (ref.mObject) - ref.mObject->removedRef(CSSM_HANDLE(handle)); - - delete &killHandle(CSSM_HANDLE(handle), _ErrorCode); - } - } - - static _Object required(_Handle handle) - { - RefObject &ref = findHandle(CSSM_HANDLE(handle), _ErrorCode); - if (!ref.mObject) - MacOSError::throwMe(_ErrorCode); - _ObjectImpl *impl = dynamic_cast<_ObjectImpl *>(&(*ref.mObject)); - if (!impl) - MacOSError::throwMe(_ErrorCode); - return _Object(impl); - } -}; - -}; // end namespace KeychainCore - -} // end namespace Security - -#endif // _H_REFS -#endif diff --git a/Keychain/SFFileVault.cpp b/Keychain/SFFileVault.cpp new file mode 100644 index 00000000..bb740ab7 --- /dev/null +++ b/Keychain/SFFileVault.cpp @@ -0,0 +1,408 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/* + * SFFileVault.cpp + * testFileVaultSPI + * + * Created by john on Mon Jul 14 2003. + * + */ + +//#include + +#include "SFFileVault.h" +#include "ExecCLITool.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "SecFileVaultCert.h" + +#pragma mark -------------------- Environment Variables -------------------- + +#define HDIUTIL_PATH "/usr/bin/hdiutil" // environment var -> HDIUTIL_PATH +#define HDID_PATH "/usr/bin/hdid" // environment var -> HDID_PATH +#define MOUNT_HFS_PATH "/sbin/mount_hfs" // environment var -> MOUNT_HFS_PATH +#define UMOUNT_PATH "/sbin/umount" // environment var -> UMOUNT_PATH + +// _defaultMasterKeychainPath // environment var -> FILEVAULT_MASTER_PATH + +const char * const SFFileVault:: _defaultMasterKeychainPath = "/System/Library/Keychains/"; +const char * const SFFileVault::_masterKeychainName = "FileVaultMaster"; + +#pragma mark -------------------- SFFileVault implementation -------------------- + +OSStatus SFFileVault::mount(CFStringRef password, CFURLRef certificate, CFURLRef dmgin, + CFURLRef mountpoint, CFStringRef *devicepath) +{ + // /usr/bin/hdid -nomount -stdinpass -plist thevol.dmg + // /sbin/mount_hfs /dev/disk3s2 /tmp/THEVOL + + const Boolean resolveAgainstBase = true; + char imageFileString[PATH_MAX + 1]; + if (!CFURLGetFileSystemRepresentation(dmgin, resolveAgainstBase, reinterpret_cast(imageFileString), PATH_MAX)) + MacOSError::throwMe(paramErr); + + // @@@ Not implemented yet + if (certificate) + MacOSError::throwMe(unimpErr); + + ExecCLITool rt; + rt.input(password,true); // include trailing NULL + rt.run(HDID_PATH,"HDID_PATH", "-nomount", "-stdinpass", "-plist", imageFileString, NULL); + + CFRef devicePathString = extractDevicepath(rt); // parse stdout from hdid --> should be plist + if (!devicePathString) + MacOSError::throwMe(paramErr); + const char *devpath = CFStringGetCStringPtr(devicePathString, kCFStringEncodingMacRoman); + if (!devpath) + MacOSError::throwMe(ioErr); + + char mountpointString[PATH_MAX + 1]; + if (!CFURLGetFileSystemRepresentation(mountpoint, resolveAgainstBase, reinterpret_cast(mountpointString), PATH_MAX)) + MacOSError::throwMe(paramErr); + + rt.run(MOUNT_HFS_PATH,"MOUNT_HFS_PATH", devpath, mountpointString, NULL); + *devicepath = CFStringCreateCopy(NULL, devicePathString); + + return noErr; +} + +OSStatus SFFileVault::mastermount(CFURLRef dmgin, CFURLRef mountpoint, CFStringRef *devicepath) +{ + // convenience call to call mount with master cert + CFStringRef password = NULL; + CFURLRef certificate = NULL; + getCertificate(&certificate); + OSStatus status = mount(password, certificate, dmgin, mountpoint, devicepath); + return status; +} + +OSStatus SFFileVault::unmount(CFURLRef mountpoint, CFStringRef devicepath) +{ + // To unmount, we do: + // /sbin/umount -f /sbin/umount -f /tmp/THEVOL + // /usr/bin/hdiutil detach /usr/bin/hdiutil detach /dev/disk3s2 + + ExecCLITool rt; + + Boolean resolveAgainstBase = true; + char mountpointString[PATH_MAX + 1]; + if (!CFURLGetFileSystemRepresentation(mountpoint, resolveAgainstBase, reinterpret_cast(mountpointString), PATH_MAX)) + MacOSError::throwMe(paramErr); + +// OSStatus status = rt.run(HDIUTIL_PATH,"HDIUTIL_PATH", "unmount", "-force", mtpt, NULL); + /* OSStatus status = */ rt.run(UMOUNT_PATH,"UMOUNT_PATH", "-f", mountpointString, NULL); + + const char *devpath = CFStringGetCStringPtr(devicepath, kCFStringEncodingMacRoman); + if (!devpath) + MacOSError::throwMe(paramErr); + + return rt.run(HDIUTIL_PATH,"HDIUTIL_PATH", "detach", devpath, NULL); +} + +OSStatus SFFileVault::userChangePassword(CFStringRef password, CFStringRef devicepath) +{ + // @@@ Not implemented yet, but code will be something like below + MacOSError::throwMe(unimpErr); + + ExecCLITool rt; + + const char *devpath = CFStringGetCStringPtr(devicepath, kCFStringEncodingMacRoman); + if (!devpath) + MacOSError::throwMe(paramErr); + + rt.input(password,true); // include trailing NULL + return rt.run(HDIUTIL_PATH,"HDIUTIL_PATH", "chpass", devpath, NULL); + + return noErr; +} + +OSStatus SFFileVault::makeMasterPassword(CFStringRef masterPasswordPassword, SecKeychainRef *keychainRef) +{ + /* + OSStatus SecFileVaultMakeMasterPassword(CFStringRef masterPasswordPassword); + + *** In the real code, this will be done directly rather than exec'ing a tool, since there are too many parameters to specify + *** this needs to be done as root, since the keychain will be a system keychain + /usr/bin/certtool y c k=/System/Library/Keychains/FileVaultMaster.keychain p= + /usr/bin/certtool c k=/System/Library/Keychains/FileVaultMaster.keychain o=/System/Library/Keychains/FileVaultMaster.cer + Two steps: create the keychain, then create the keypair + */ + + char masterKeychainPath[PATH_MAX + 1]; + const char *envPath = getenv("FILEVAULT_MASTER_PATH"); // must set to full path or kc will end up in ~/Library/Keychains/ + if (!envPath) + envPath = _defaultMasterKeychainPath; + snprintf(masterKeychainPath, sizeof(masterKeychainPath), "%s%s.keychain", envPath, _masterKeychainName); +// std::cout << "Masterkeychain path: " << masterKeychainPath << std::endl; + + const char *mpass = CFStringGetCStringPtr(masterPasswordPassword, kCFStringEncodingMacRoman); + if (!mpass) + MacOSError::throwMe(paramErr); + const UInt32 passwordLength = strlen(mpass); + + // don't add to searchlist + KeychainCore::Keychain keychain = KeychainCore::globals().storageManager.make(Required(&masterKeychainPath),false); + + try + { + keychain->create(passwordLength, mpass); + } + catch (const MacOSError &err) + { + if (err.osStatus()!=errSecDuplicateKeychain) + throw; + } + catch (const CssmCommonError &err) + { + if (err.cssmError()!=CSSMERR_DL_DATASTORE_ALREADY_EXISTS) + throw; + } + + RequiredParam(keychainRef)=keychain->handle(); + + // @@@ Need better identification for the certificate + SecFileVaultCert fvc; + CFStringRef hostName = CFSTR("com.apple.fv"); + CFStringRef userName = CFSTR("User Name"); + CFDataRef certData = NULL; //CFRef<> + OSStatus status = fvc.createPair(hostName,userName,*keychainRef,&certData); + if (status) + MacOSError::throwMe(status); + // Write out cert file + status = writeCertificateFile(certData); + if (status) + MacOSError::throwMe(status); + + return noErr; +} + +OSStatus SFFileVault::create(CFStringRef password, CFURLRef certificate, CFURLRef dmgout, + CFStringRef volumeName, CFStringRef sizeSpec) +{ + // /usr/bin/hdiutil create -encryption -stdinpass -type SPARSE -fs "HFS+" -volname -size 20g + + ExecCLITool rt; + + // Construct the "-volname" parameter + if (!volumeName) + MacOSError::throwMe(paramErr); + const char *volname = CFStringGetCStringPtr(volumeName, kCFStringEncodingMacRoman); + if (!volname) + MacOSError::throwMe(paramErr); + + // Construct the "-size" parameter + if (!sizeSpec) + MacOSError::throwMe(paramErr); + const char *sizestr = CFStringGetCStringPtr(sizeSpec, kCFStringEncodingMacRoman); + if (!sizestr) + MacOSError::throwMe(paramErr); + + // Construct the file name parameter + CFRef fileString = CFURLCopyFileSystemPath(dmgout, kCFURLPOSIXPathStyle); + if (!fileString) + MacOSError::throwMe(paramErr); + const char *fname = CFStringGetCStringPtr(fileString, kCFStringEncodingMacRoman); + if (!fname) + MacOSError::throwMe(paramErr); + + // Construct the "-certificate" parameter + const char *certificateParamString = certificate?"-certificate":"-layout"; // @@@ what is a safe empty param? + CFStringRef certificateFileString = certificate?CFURLCopyFileSystemPath(certificate, kCFURLPOSIXPathStyle):NULL; + if (certificate && !certificateFileString) + MacOSError::throwMe(paramErr); + const char *certFileString = certificate?CFStringGetCStringPtr(certificateFileString, kCFStringEncodingMacRoman):"SPUD"; + if (certificate && !certFileString) + MacOSError::throwMe(paramErr); + + rt.input(password,true); // include trailing NULL + OSStatus status = rt.run(HDIUTIL_PATH,"HDIUTIL_PATH", "create", "-encryption", "CEncryptedEncoding", + "-stdinpass", "-type", "SPARSE", "-fs", "HFS+", "-volname", volname, "-size", sizestr, + certificateParamString, certFileString, fname, NULL); + + if (certificateFileString) + CFRelease(certificateFileString); + + return status; +} + +Boolean SFFileVault::masterPasswordEnabled(SecKeychainRef *keychainRef) +{ + char masterKeychain[PATH_MAX + 1]; + snprintf(masterKeychain, sizeof(masterKeychain), "%s.keychain", getKeychainPath()); //@@@ leak + + SecKeychainRef tmpKeychainRef=KeychainCore::globals().storageManager.make(masterKeychain, false)->handle(); + if (tmpKeychainRef == NULL) + return false; + + if (keychainRef) + *keychainRef = tmpKeychainRef; + else + CFRelease(tmpKeychainRef); + return true; +} + +OSStatus SFFileVault::changeMasterPasswordPassword(CFStringRef oldPassword,CFStringRef newPassword) +{ + // Essentially SecKeychainChangePassword for the FileVault Master Password keychain + SecKeychainRef keychainRef; + if (!masterPasswordEnabled(&keychainRef)) + MacOSError::throwMe(errSecNoSuchKeychain); + + std::string oldpw = cfString(oldPassword); //UInt32 + std::string newpw = cfString(newPassword); + + KeychainCore::Keychain keychain = KeychainCore::Keychain::optional(keychainRef); + keychain->changePassphrase (oldpw.length(), oldpw.c_str(), newpw.length(), newpw.c_str()); + CFRelease(keychainRef); + return noErr; +} + +/* + Shouldn't cfString being using code like this? + + const Boolean isExternalRepresentation = false; + const CFStringEncoding encoding = kCFStringEncodingUTF8; + CFIndex usedBufLen = 0; + UInt8 lossByte = 0; + + if (!theString) + MacOSError::throwMe(paramErr); + + CFRange stringRange = CFRangeMake(0,CFStringGetLength(theString)); + // Call once first just to get length + CFIndex length = CFStringGetBytes(theString, stringRange, encoding, lossByte, + isExternalRepresentation, NULL, 0, &usedBufLen); +*/ + +#pragma mark -------------------- Helpers -------------------- + +#define SYSTEM_ENTITIES_KEY CFSTR("system-entities") +#define CONTENT_HINT_KEY CFSTR("content-hint") +#define DEV_ENTRY_KEY CFSTR("dev-entry") +#define APPLE_HFS_KEY CFSTR("Apple_HFS") + +CFStringRef SFFileVault::extractDevicepath(const ExecCLITool& rt) +{ + CFRef tableData = CFDataCreate(NULL,reinterpret_cast(rt.data()),rt.length()); + CFStringRef errorString = NULL; + CFRef devTable = static_cast(CFPropertyListCreateFromXMLData(NULL, + tableData, kCFPropertyListImmutable, &errorString)); + if (errorString != NULL) + { + CFRelease(errorString); + return NULL; + } + + CFRef sysEntities = static_cast(CFDictionaryGetValue(devTable,SYSTEM_ENTITIES_KEY)); + if (sysEntities == NULL) + return NULL; + + CFIndex dictionaryCount = CFArrayGetCount(sysEntities); + for (CFIndex ix=0;ix < dictionaryCount;ix++) + { + CFRef dict = static_cast(CFArrayGetValueAtIndex(sysEntities, ix)); + CFRef deviceEntryString = static_cast(CFDictionaryGetValue(dict,CONTENT_HINT_KEY)); + if (CFEqual(deviceEntryString, APPLE_HFS_KEY)) // found it + return static_cast(CFDictionaryGetValue(dict,DEV_ENTRY_KEY)); + } + return NULL; +} + +OSStatus SFFileVault::getCertificate(CFURLRef *certificateFile) +{ + //@@@ to be done + MacOSError::throwMe(unimpErr); + // do a find in the master keychain + char masterKeychain[PATH_MAX + 1]; + snprintf(masterKeychain, sizeof(masterKeychain), "%s.keychain", getKeychainPath()); //@@@ leak + + // don't add to searchlist + KeychainCore::Keychain keychain = KeychainCore::globals().storageManager.make(Required(&masterKeychain),false); + KeychainCore::StorageManager::KeychainList keychains; + KeychainCore::globals().storageManager.optionalSearchList(keychain, keychains); + + // Code basically copied from SecKeychainSearchCreateFromAttributes and SecKeychainSearchCopyNext: + KeychainCore::KCCursor cursor(keychains, kSecCertificateItemClass, NULL); + KeychainCore::Item item; + if (!cursor->next(item)) + CssmError::throwMe(errSecItemNotFound); + +// KeychainCore::Certificate *certificate = static_cast(&*item); +// CSSM_DATA_PTR certData = static_cast(certificate->data()); + + return noErr; +} + +OSStatus SFFileVault::writeCertificateFile(CFDataRef certData) +{ + const char *certFile = getCertificateFileName(); + OSStatus status = writeFile(certFile, CFDataGetBytePtr(certData), CFDataGetLength(certData)); + if (certFile) + ::free(const_cast(certFile)); + return status; +} + +const char *SFFileVault::getKeychainPath() +{ + // Append ".keychain to get keychain name; append .cer to get certificate + char masterKeychainPath[PATH_MAX + 1]; + const char *envPath = getenv("FILEVAULT_MASTER_PATH"); // must set to full path or kc will end up in ~/Library/Keychains/ + if (!envPath) + envPath = _defaultMasterKeychainPath; + snprintf(masterKeychainPath, sizeof(masterKeychainPath), "%s%s", envPath, _masterKeychainName); +// std::cout << "Masterkeychain path: " << masterKeychainPath << std::endl; + size_t sz = strlen(masterKeychainPath)+1; + char *path = static_cast(malloc(sz)); + strncpy(path,masterKeychainPath,sz); + return static_cast(path); +} + +const char *SFFileVault::getCertificateFileName() +{ + char certFile[PATH_MAX + 1]; + snprintf(certFile, sizeof(certFile), "%s.cer", getKeychainPath()); + size_t sz = strlen(certFile)+1; + char *path = static_cast(malloc(sz)); + strncpy(path,certFile,sz); + return static_cast(path); +} + +int SFFileVault::writeFile(const char *fileName, const unsigned char *bytes, unsigned int numBytes) +{ + int fd = open(fileName, O_RDWR | O_CREAT | O_TRUNC, 0600); + if (fd <= 0) + return errno; + + if (lseek(fd, 0, SEEK_SET) < 0) + return errno; + + int rtn = write(fd, bytes, (size_t)numBytes); + rtn = (rtn != static_cast(numBytes))?EIO:0; + close(fd); + return rtn; +} + +#pragma mark -------------------- Unused -------------------- + diff --git a/Keychain/SFFileVault.h b/Keychain/SFFileVault.h new file mode 100644 index 00000000..71e2a8cc --- /dev/null +++ b/Keychain/SFFileVault.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/* + * SFFileVault.h + * testFileVaultSPI + * + * Created by john on Mon Jul 14 2003. + * + */ + +#include +#include + +class ExecCLITool; + +class SFFileVault +{ +public: + SFFileVault() {}; + ~SFFileVault() {}; + + OSStatus mount(CFStringRef password, CFURLRef certificate, CFURLRef dmgin, + CFURLRef mountpoint,CFStringRef *devicepath); + OSStatus mastermount(CFURLRef dmgin, CFURLRef mountpoint, CFStringRef *devicepath); + OSStatus unmount(CFURLRef mountpoint,CFStringRef devicepath); + + OSStatus userChangePassword(CFStringRef password, CFStringRef devicepath); + OSStatus makeMasterPassword(CFStringRef masterPasswordPassword, SecKeychainRef *keychain); + OSStatus create(CFStringRef password, CFURLRef certificate, CFURLRef dmgout, + CFStringRef volumeName, CFStringRef sizeSpec); + Boolean masterPasswordEnabled(SecKeychainRef *keychainRef); + OSStatus changeMasterPasswordPassword(CFStringRef oldPassword,CFStringRef newPassword); + + OSStatus getCertificate(CFURLRef *certificate); + +private: + CFStringRef extractDevicepath(const ExecCLITool& rt); + const char *getKeychainPath(); + const char *getCertificateFileName(); + OSStatus writeCertificateFile(CFDataRef certData); + int writeFile(const char *fileName, const unsigned char *bytes, unsigned int numBytes); + + static const char * const _defaultMasterKeychainPath; + static const char * const _masterKeychainName ; +}; diff --git a/Keychain/Schema.h b/Keychain/Schema.h index d8e62ecb..6c22aa07 100644 --- a/Keychain/Schema.h +++ b/Keychain/Schema.h @@ -61,6 +61,21 @@ extern const CSSM_DB_SCHEMA_INDEX_INFO X509CertificateSchemaIndexList[]; extern const uint32 X509CertificateSchemaAttributeCount; extern const uint32 X509CertificateSchemaIndexCount; +// CRL attributes and schema +extern const CSSM_DB_ATTRIBUTE_INFO kX509CrlCrlType; +extern const CSSM_DB_ATTRIBUTE_INFO kX509CrlCrlEncoding; +extern const CSSM_DB_ATTRIBUTE_INFO kX509CrlPrintName; +extern const CSSM_DB_ATTRIBUTE_INFO kX509CrlAlias; +extern const CSSM_DB_ATTRIBUTE_INFO kX509CrlIssuer; +extern const CSSM_DB_ATTRIBUTE_INFO kX509CrlSerialNumber; +extern const CSSM_DB_ATTRIBUTE_INFO kX509CrlThisUpdate; +extern const CSSM_DB_ATTRIBUTE_INFO kX509CrlNextUpdate; + +extern const CSSM_DB_SCHEMA_ATTRIBUTE_INFO X509CrlSchemaAttributeList[]; +extern const CSSM_DB_SCHEMA_INDEX_INFO X509CrlSchemaIndexList[]; +extern const uint32 X509CrlSchemaAttributeCount; +extern const uint32 X509CrlSchemaIndexCount; + // UserTrust records attributes and schema extern const CSSM_DB_ATTRIBUTE_INFO kUserTrustTrustedCertificate; extern const CSSM_DB_ATTRIBUTE_INFO kUserTrustTrustedPolicy; diff --git a/Keychain/Schema.m4 b/Keychain/Schema.m4 index bd6e653f..82696d6d 100644 --- a/Keychain/Schema.m4 +++ b/Keychain/Schema.m4 @@ -272,7 +272,7 @@ startNewClass(X509Certificate) newAttribute(`UISs', CertType, kSecCertTypeItemAttr, "CertType", 0, NULL, UINT32) newAttribute(` Ss', CertEncoding, kSecCertEncodingItemAttr, "CertEncoding", 0, NULL, UINT32) newAttribute(` Ss', PrintName, kSecLabelItemAttr, "PrintName", 0, NULL, BLOB) -newAttribute(` Ss', Alias, kSecAliasItemAttr, "Alias", 0, NULL, BLOB) +newAttribute(` ISs', Alias, kSecAliasItemAttr, "Alias", 0, NULL, BLOB) newAttribute(` ISs', Subject, kSecSubjectItemAttr, "Subject", 0, NULL, BLOB) newAttribute(`UISs', Issuer, kSecIssuerItemAttr, "Issuer", 0, NULL, BLOB) newAttribute(`UISs', SerialNumber, kSecSerialNumberItemAttr, "SerialNumber", 0, NULL, BLOB) @@ -280,6 +280,19 @@ newAttribute(` ISs', SubjectKeyIdentifier, kSecSubjectKeyIdentifierItemAttr, "Su newAttribute(` ISs', PublicKeyHash, kSecPublicKeyHashItemAttr, "PublicKeyHash", 0, NULL, BLOB) endNewClass() +startNewClass(X509Crl) +newAttribute(`UISs', CrlType, kSecCrlTypeItemAttr, "CrlType", 0, NULL, UINT32) +newAttribute(` Ss', CrlEncoding, kSecCrlEncodingItemAttr, "CrlEncoding", 0, NULL, UINT32) +newAttribute(` Ss', PrintName, kSecLabelItemAttr, "PrintName", 0, NULL, BLOB) +newAttribute(` Ss', Alias, kSecAliasItemAttr, "Alias", 0, NULL, BLOB) +newAttribute(`UISs', Issuer, kSecIssuerItemAttr, "Issuer", 0, NULL, BLOB) +newAttribute(`UISs', ThisUpdate, kSecThisUpdateItemAttr, "ThisUpdate", 0, NULL, BLOB) +newAttribute(`UISs', NextUpdate, kSecNextUpdateItemAttr, "NextUpdate", 0, NULL, BLOB) +newAttribute(` Ss', URI, kSecUriItemAttr, "URI", 0, NULL, BLOB) +newAttribute(` ISs', CrlNumber, kSecCrlNumberItemAttr, "CrlNumber", 0, NULL, UINT32) +newAttribute(` ISs', DeltaCrlNumber, kSecDeltaCrlNumberItemAttr, "DeltaCrlNumber", 0, NULL, UINT32) +endNewClass() + startNewClass(UserTrust) newAttribute(`UISs', TrustedCertificate, kSecTrustCertAttr, "TrustedCertificate", 0, NULL, BLOB) newAttribute(`UISs', TrustedPolicy, kSecTrustPolicyAttr, "TrustedPolicy", 0, NULL, BLOB) diff --git a/Keychain/SecACL.cpp b/Keychain/SecACL.cpp index 1a79e249..d0dc80c1 100644 --- a/Keychain/SecACL.cpp +++ b/Keychain/SecACL.cpp @@ -16,6 +16,8 @@ */ #include +#include +#include #include "SecBridge.h" @@ -31,7 +33,7 @@ SecACLGetTypeID(void) { BEGIN_SECAPI - return gTypes().acl.typeId; + return gTypes().ACL.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -45,11 +47,18 @@ OSStatus SecACLCreateFromSimpleContents(SecAccessRef accessRef, SecACLRef *newAcl) { BEGIN_SECAPI - RefPointer access = gTypes().access.required(accessRef); - RefPointer acl = new ACL(*access, cfString(description), *promptSelector); - setApplications(acl, applicationList); + SecPointer access = Access::required(accessRef); + SecPointer acl = new ACL(*access, cfString(description), *promptSelector); + if (applicationList) { + // application-list + prompt + acl->form(ACL::appListForm); + setApplications(acl, applicationList); + } else { + // allow-any + acl->form(ACL::allowAllForm); + } access->add(acl.get()); - Required(newAcl) = gTypes().acl.handle(*acl); + Required(newAcl) = acl->handle(); END_SECAPI } @@ -59,11 +68,17 @@ OSStatus SecACLCreateFromSimpleContents(SecAccessRef accessRef, OSStatus SecACLRemove(SecACLRef aclRef) { BEGIN_SECAPI - gTypes().acl.required(aclRef)->remove(); + ACL::required(aclRef)->remove(); END_SECAPI } +static SecTrustedApplicationRef +convert(const SecPointer &trustedApplication) +{ + return *trustedApplication; +} + /*! */ OSStatus SecACLCopySimpleContents(SecACLRef aclRef, @@ -71,7 +86,7 @@ OSStatus SecACLCopySimpleContents(SecACLRef aclRef, CFStringRef *promptDescription, CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR *promptSelector) { BEGIN_SECAPI - RefPointer acl = gTypes().acl.required(aclRef); + SecPointer acl = ACL::required(aclRef); switch (acl->form()) { case ACL::allowAllForm: Required(applicationList) = NULL; @@ -82,7 +97,7 @@ OSStatus SecACLCopySimpleContents(SecACLRef aclRef, break; case ACL::appListForm: Required(applicationList) = - makeCFArray(gTypes().trustedApplication, acl->applications()); + makeCFArray(convert, acl->applications()); Required(promptDescription) = makeCFString(acl->promptDescription()); Required(promptSelector) = acl->promptSelector(); break; @@ -97,7 +112,7 @@ OSStatus SecACLSetSimpleContents(SecACLRef aclRef, CFStringRef description, const CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR *promptSelector) { BEGIN_SECAPI - RefPointer acl = gTypes().acl.required(aclRef); + SecPointer acl = ACL::required(aclRef); acl->promptDescription() = description ? cfString(description) : ""; acl->promptSelector() = promptSelector ? *promptSelector : ACL::defaultSelector; if (applicationList) { @@ -123,7 +138,7 @@ static void setApplications(ACL *acl, CFArrayRef applicationList) //@@@ should really use STL iterator overlay on CFArray. By hand... CFIndex count = CFArrayGetCount(applicationList); for (CFIndex n = 0; n < count; n++) - appList.push_back(gTypes().trustedApplication.required( + appList.push_back(TrustedApplication::required( SecTrustedApplicationRef(CFArrayGetValueAtIndex(applicationList, n)))); } @@ -135,7 +150,7 @@ OSStatus SecACLGetAuthorizations(SecACLRef acl, CSSM_ACL_AUTHORIZATION_TAG *tags, uint32 *tagCount) { BEGIN_SECAPI - AclAuthorizationSet auths = gTypes().acl.required(acl)->authorizations(); + AclAuthorizationSet auths = ACL::required(acl)->authorizations(); if (Required(tagCount) < auths.size()) { // overflow *tagCount = auths.size(); // report size required CssmError::throwMe(paramErr); @@ -149,7 +164,7 @@ OSStatus SecACLSetAuthorizations(SecACLRef aclRef, CSSM_ACL_AUTHORIZATION_TAG *tags, uint32 tagCount) { BEGIN_SECAPI - RefPointer acl = gTypes().acl.required(aclRef); + SecPointer acl = ACL::required(aclRef); if (acl->isOwner()) // can't change rights of the owner ACL MacOSError::throwMe(errSecInvalidOwnerEdit); AclAuthorizationSet &auths = acl->authorizations(); diff --git a/Keychain/SecAccess.cpp b/Keychain/SecAccess.cpp index e4a4665e..f71cd286 100644 --- a/Keychain/SecAccess.cpp +++ b/Keychain/SecAccess.cpp @@ -26,7 +26,7 @@ CFTypeID SecAccessGetTypeID(void) { BEGIN_SECAPI - return gTypes().access.typeId; + return gTypes().Access.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -42,18 +42,18 @@ OSStatus SecAccessCreate(CFStringRef descriptor, CFArrayRef trustedList, SecAcce { BEGIN_SECAPI Required(descriptor); - RefPointer access; + SecPointer access; if (trustedList) { CFIndex length = CFArrayGetCount(trustedList); ACL::ApplicationList trusted; for (CFIndex n = 0; n < length; n++) - trusted.push_back(gTypes().trustedApplication.required( + trusted.push_back(TrustedApplication::required( SecTrustedApplicationRef(CFArrayGetValueAtIndex(trustedList, n)))); access = new Access(cfString(descriptor), trusted); } else { access = new Access(cfString(descriptor)); } - Required(accessRef) = gTypes().access.handle(*access); + Required(accessRef) = access->handle(); END_SECAPI } @@ -66,8 +66,8 @@ OSStatus SecAccessCreateFromOwnerAndACL(const CSSM_ACL_OWNER_PROTOTYPE *owner, { BEGIN_SECAPI Required(accessRef); // preflight - RefPointer access = new Access(Required(owner), aclCount, &Required(acls)); - *accessRef = gTypes().access.handle(*access); + SecPointer access = new Access(Required(owner), aclCount, &Required(acls)); + *accessRef = access->handle(); END_SECAPI } @@ -79,10 +79,8 @@ OSStatus SecAccessGetOwnerAndACL(SecAccessRef accessRef, uint32 *aclCount, CSSM_ACL_ENTRY_INFO_PTR *acls) { BEGIN_SECAPI -#if 0 - gTypes().access.required(accessRef)->copyOwnerAndAcl( + Access::required(accessRef)->copyOwnerAndAcl( Required(owner), Required(aclCount), Required(acls)); -#endif END_SECAPI } @@ -93,7 +91,7 @@ OSStatus SecAccessCopyACLList(SecAccessRef accessRef, CFArrayRef *aclList) { BEGIN_SECAPI - Required(aclList) = gTypes().access.required(accessRef)->copySecACLs(); + Required(aclList) = Access::required(accessRef)->copySecACLs(); END_SECAPI } @@ -105,6 +103,6 @@ OSStatus SecAccessCopySelectedACLList(SecAccessRef accessRef, CFArrayRef *aclList) { BEGIN_SECAPI - Required(aclList) = gTypes().access.required(accessRef)->copySecACLs(action); + Required(aclList) = Access::required(accessRef)->copySecACLs(action); END_SECAPI } diff --git a/Keychain/SecAccessPriv.h b/Keychain/SecAccessPriv.h new file mode 100644 index 00000000..46e418fc --- /dev/null +++ b/Keychain/SecAccessPriv.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/*! + @header SecAccessPriv + SecAccessPriv implements a way to set and manipulate access control rules and + restrictions on SecKeychainItems. The functions here are private. +*/ + +#ifndef _SECURITY_SECACCESS_PRIV_H_ +#define _SECURITY_SECACCESS_PRIV_H_ + +#include +#include +#include + + +#if defined(__cplusplus) +extern "C" { +#endif + +/*! + @function SecKeychainAddIToolsPassword + @abstract Creates a new iTools password using the access control list from iToolsTrustedApps.plist. + @param keychain A reference to the keychain to which to add the password. Pass NULL to add the password to the default keychain. + @param accountNameLength The length of the buffer pointed to by accountName. + @param accountName A pointer to a string containing the account name associated with this password. + @param passwordLength The length of the buffer pointed to by passwordData. + @param passwordData A pointer to a buffer containing the password data to be stored in the keychain. + @param itemRef On return, a reference to the new keychain item. + @result A result code. See "Security Error Codes" (SecBase.h). + @discussion The SecKeychainAddIToolsPassword function adds a new iTools password to the specified keychain with an ACL composed of a list of trusted applications. A required parameter to identify the password is the accountName, which is an application-defined string. The servicename will always be "iTools". SecKeychainAddIToolsPassword optionally returns a reference to the newly added item. +*/ + +OSStatus SecKeychainAddIToolsPassword(SecKeychainRef keychain, UInt32 accountNameLength, const char *accountName, + UInt32 passwordLength, const void *passwordData, SecKeychainItemRef *itemRef); + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SECURITY_SECACCESS_PRIV_H_ */ diff --git a/Keychain/SecBase.h b/Keychain/SecBase.h index 92baede0..f9acecfc 100644 --- a/Keychain/SecBase.h +++ b/Keychain/SecBase.h @@ -158,14 +158,14 @@ typedef struct SecKeychainAttributeInfo SecKeychainAttributeInfo; /*! @enum Security Error Codes @abstract Represents the result codes. -@constant errSecNotAvailable No trust results are available. +@constant errSecNotAvailable No keychain is available. @constant errSecReadOnly Read only error. @constant errSecAuthFailed Authorization/Authentication failed. @constant errSecNoSuchKeychain The keychain does not exist. @constant errSecInvalidKeychain The keychain is not valid. @constant errSecDuplicateKeychain A keychain with the same name already exists. -@constant errSecDuplicateCallback More than one callback of the same name exists. -@constant errSecInvalidCallback The callback is not valid. +@constant errSecDuplicateCallback The specified callback is already installed. +@constant errSecInvalidCallback The specified callback is not valid. @constant errSecDuplicateItem The item already exists. @constant errSecItemNotFound The item cannot be found. @constant errSecBufferTooSmall The buffer is too small. @@ -190,44 +190,56 @@ typedef struct SecKeychainAttributeInfo SecKeychainAttributeInfo; @constant errSecPolicyNotFound The policy specified cannot be found. @constant errSecInvalidTrustSetting The trust setting is invalid. @constant errSecNoAccessForItem The specified item has no access control. +@constant errSecInvalidOwnerEdit Invalid attempt to change the owner of this item. +@constant errSecTrustNotAvailable No trust results are available. @discussion The assigned error space is discontinuous: -25240..-25279, -25290..25329. */ + +/* + Note: the comments that appear after these errors are used to create SecErrorMessages.strings. + The comments must not be multi-line, and should be in a form meaningful to an end user. If + a different or additional comment is needed, it can be put in the header doc format, or on a + line that does not start with errZZZ. +*/ + enum { - errSecNotAvailable = -25291, - errSecReadOnly = -25292, - errSecAuthFailed = -25293, - errSecNoSuchKeychain = -25294, - errSecInvalidKeychain = -25295, - errSecDuplicateKeychain = -25296, - errSecDuplicateCallback = -25297, - errSecInvalidCallback = -25298, - errSecDuplicateItem = -25299, - errSecItemNotFound = -25300, - errSecBufferTooSmall = -25301, - errSecDataTooLarge = -25302, - errSecNoSuchAttr = -25303, - errSecInvalidItemRef = -25304, - errSecInvalidSearchRef = -25305, - errSecNoSuchClass = -25306, - errSecNoDefaultKeychain = -25307, - errSecInteractionNotAllowed = -25308, - errSecReadOnlyAttr = -25309, - errSecWrongSecVersion = -25310, - errSecKeySizeNotAllowed = -25311, - errSecNoStorageModule = -25312, - errSecNoCertificateModule = -25313, - errSecNoPolicyModule = -25314, - errSecInteractionRequired = -25315, - errSecDataNotAvailable = -25316, - errSecDataNotModifiable = -25317, - errSecCreateChainFailed = -25318, + errSecNotAvailable = -25291, /* No keychain is available. You may need to restart your computer. */ + errSecReadOnly = -25292, /* This keychain cannot be modified. */ + errSecAuthFailed = -25293, /* The user name or passphrase you entered is not correct. */ + errSecNoSuchKeychain = -25294, /* The specified keychain could not be found. */ + errSecInvalidKeychain = -25295, /* The specified keychain is not a valid keychain file. */ + errSecDuplicateKeychain = -25296, /* A keychain with the same name already exists. */ + errSecDuplicateCallback = -25297, /* The specified callback function is already installed. */ + errSecInvalidCallback = -25298, /* The specified callback function is not valid. */ + errSecDuplicateItem = -25299, /* The specified item already exists in the keychain. */ + errSecItemNotFound = -25300, /* The specified item could not be found in the keychain. */ + errSecBufferTooSmall = -25301, /* There is not enough memory available to use the specified item. */ + errSecDataTooLarge = -25302, /* This item contains information which is too large or in a format that cannot be displayed. */ + errSecNoSuchAttr = -25303, /* The specified attribute does not exist. */ + errSecInvalidItemRef = -25304, /* The specified item is no longer valid. It may have been deleted from the keychain. */ + errSecInvalidSearchRef = -25305, /* Unable to search the current keychain. */ + errSecNoSuchClass = -25306, /* The specified item does not appear to be a valid keychain item. */ + errSecNoDefaultKeychain = -25307, /* A default keychain could not be found. */ + errSecInteractionNotAllowed = -25308, /* User interaction is not allowed. */ + errSecReadOnlyAttr = -25309, /* The specified attribute could not be modified. */ + errSecWrongSecVersion = -25310, /* This keychain was created by a different version of the system software and cannot be opened. */ + errSecKeySizeNotAllowed = -25311, /* This item specifies a key size which is too large. */ + errSecNoStorageModule = -25312, /* A required component (data storage module) could not be loaded. You may need to restart your computer. */ + errSecNoCertificateModule = -25313, /* A required component (certificate module) could not be loaded. You may need to restart your computer. */ + errSecNoPolicyModule = -25314, /* A required component (policy module) could not be loaded. You may need to restart your computer. */ + errSecInteractionRequired = -25315, /* User interaction is required, but is currently not allowed. */ + errSecDataNotAvailable = -25316, /* The contents of this item cannot be retrieved. */ + errSecDataNotModifiable = -25317, /* The contents of this item cannot be modified. */ + errSecCreateChainFailed = -25318, /* One or more certificates required to validate this certificate cannot be found. */ + errSecInvalidPrefsDomain = -25319, /* The specified preferences domain is not valid. */ - errSecACLNotSimple = -25240, - errSecPolicyNotFound = -25241, - errSecInvalidTrustSetting = -25242, - errSecNoAccessForItem = -25243, - errSecInvalidOwnerEdit = -25244 + errSecACLNotSimple = -25240, /* The specified access control list is not in standard (simple) form. */ + errSecPolicyNotFound = -25241, /* The specified policy cannot be found. */ + errSecInvalidTrustSetting = -25242, /* The specified trust setting is invalid. */ + errSecNoAccessForItem = -25243, /* The specified item has no access control. */ + errSecInvalidOwnerEdit = -25244, /* Invalid attempt to change the owner of this item. */ + errSecTrustNotAvailable = -25245 /* No trust results are available. */ }; #if defined(__cplusplus) diff --git a/Keychain/SecCFTypes.cpp b/Keychain/SecCFTypes.cpp index 820a85b4..eaa73b85 100644 --- a/Keychain/SecCFTypes.cpp +++ b/Keychain/SecCFTypes.cpp @@ -20,25 +20,96 @@ // #include +#include -using namespace KeychainCore; +namespace Security +{ + +namespace KeychainCore +{ + +SecCFTypes & +gTypes() +{ + static ModuleNexus nexus; + + return nexus(); +} -ModuleNexus Security::KeychainCore::gTypes; +} // end namespace KeychainCore + +} // end namespace Security + +using namespace KeychainCore; SecCFTypes::SecCFTypes() : - access("SecAccess"), - acl("SecACL"), - certificate("SecCertificate"), - certificateRequest("SecCertificateRequest"), - identity("SecIdentity"), - identityCursor("SecIdentitySearch"), - item("SecKeychainItem"), - cursor("SecKeychainSearch"), - keychain("SecKeychain"), - keyItem("SecKey"), - policy("SecPolicy"), - policyCursor("SecPolicySearch"), - trust("SecTrust"), - trustedApplication("SecTrustedApplication") + Access("SecAccess"), + ACL("SecACL"), + Certificate("SecCertificate"), + CertificateRequest("SecCertificateRequest"), + Identity("SecIdentity"), + IdentityCursor("SecIdentitySearch"), + ItemImpl("SecKeychainItem"), + KCCursorImpl("SecKeychainSearch"), + KeychainImpl("SecKeychain"), + KeyItem("SecKey"), + Policy("SecPolicy"), + PolicyCursor("SecPolicySearch"), + Trust("SecTrust"), + TrustedApplication("SecTrustedApplication") +{ +} + +// +// CFClass +// +CFClass::CFClass(const char *name) +{ + // initialize the CFRuntimeClass structure + version = 0; + className = name; + init = NULL; + copy = NULL; + finalize = finalizeType; + equal = equalType; + hash = hashType; + copyFormattingDesc = copyFormattingDescType; + copyDebugDesc = copyDebugDescType; + + // register + typeID = _CFRuntimeRegisterClass(this); + assert(typeID != _kCFRuntimeNotATypeID); +} + +void +CFClass::finalizeType(CFTypeRef cf) +{ + SecCFObject *obj = SecCFObject::optional(cf); + if (!obj->isNew()) + obj->~SecCFObject(); +} + +Boolean +CFClass::equalType(CFTypeRef cf1, CFTypeRef cf2) +{ + // CF checks for pointer equality and ensures type equality already + return SecCFObject::optional(cf1)->equal(*SecCFObject::optional(cf2)); +} + +CFHashCode +CFClass::hashType(CFTypeRef cf) +{ + return SecCFObject::optional(cf)->hash(); +} + +CFStringRef +CFClass::copyFormattingDescType(CFTypeRef cf, CFDictionaryRef dict) +{ + return SecCFObject::optional(cf)->copyFormattingDesc(dict); +} + +CFStringRef +CFClass::copyDebugDescType(CFTypeRef cf) { + return SecCFObject::optional(cf)->copyDebugDesc(); } diff --git a/Keychain/SecCFTypes.h b/Keychain/SecCFTypes.h index 5a101db8..a9f62e9d 100644 --- a/Keychain/SecCFTypes.h +++ b/Keychain/SecCFTypes.h @@ -21,38 +21,8 @@ #ifndef _SECURITY_SECCFTYPES_H_ #define _SECURITY_SECCFTYPES_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include -//#include -#include -//#include -#include -//#include -#include -//#include -//#include -//#include -//#include -#include -#include -//#include - -#include -#include +#include +#include namespace Security { @@ -60,24 +30,38 @@ namespace Security namespace KeychainCore { -/* Singleton that registers all the CFClass<> instances with the CFRuntime. +class CFClass : protected CFRuntimeClass +{ +public: + CFClass(const char *name); + +private: + static void finalizeType(CFTypeRef cf); + static Boolean equalType(CFTypeRef cf1, CFTypeRef cf2); + static CFHashCode hashType(CFTypeRef cf); + static CFStringRef copyFormattingDescType(CFTypeRef cf, CFDictionaryRef dict); + static CFStringRef copyDebugDescType(CFTypeRef cf); + +public: + CFTypeID typeID; +}; + +/* Singleton that registers all the CFClass instances with the CFRuntime. To make something a CFTypeRef you need to make the actual object inheirit from SecCFObject and provide implementation of the virtual functions in that class. In addition to that you need to define an opque type for the C API like: typedef struct __OpaqueYourObject *YourObjectRef; - and in the C++ headers you define something like: - typedef CFClass YourObjectClass; - - Add an instance of the YourObjectClass to the public section of SecCFTypes below to get it registered with the CFRuntime. - YourObjectClass yourObject; + Add an instance of CFClass to the public section of SecCFTypes below to get it registered with the CFRuntime. + CFClass yourObject; - In your C++ code you should use RefPointer to refer to instances of your class. RefPointers are just like autopointers and implement * and -> semantics. They refcount the underlying object. So to create an instance or your new object you would do something like: + XXX + In your C++ code you should use SecPointer to refer to instances of your class. SecPointers are just like autopointers and implement * and -> semantics. They refcount the underlying object. So to create an instance or your new object you would do something like: - RefPointer instance(new YourObject()); + SecPointer instance(new YourObject()); - RefPointers have copy semantics and if you subclass RefPointer and define a operator < on the subclass you can even safely store instances of your class in stl containers. + SecPointers have copy semantics and if you subclass SecPointer and define a operator < on the subclass you can even safely store instances of your class in stl containers. Use then like this: instance->somemethod(); @@ -87,15 +71,15 @@ namespace KeychainCore YourObject *object = instance.get(); In the API glue you will need to use: - RefPointer instance; + SecPointer instance; [...] get the instance somehow - return gTypes().yourObject.handle(*instance); + return instance->handle(); to return an opaque handle (the is a CFTypeRef) to your object. when you obtain an object as input use: SecYourObjectRef ref; - RefPointer instance = gTypes().yourObject.required(ref); - to get a RefPointer to an instance of your object fro the external CFTypeRef. + SecPointer instance = YourObject::required(ref); + to get a SecPointer to an instance of your object from the external CFTypeRef. */ class SecCFTypes { @@ -103,41 +87,24 @@ public: SecCFTypes(); public: - /* Add new instances of CFClass<> here that you want registered with the CF runtime. */ - - /* @@@ Error should be errSecInvalidAccessRef */ - CFClass access; - /* @@@ Error should be errSecInvalidTrustedApplicationRef */ - CFClass acl; - /* @@@ Error should be errSecInvalidCertificateRef */ - CFClass certificate; - /* @@@ Error should be errSecInvalidCertificateRequestRef */ - CFClass certificateRequest; - /* @@@ Error should be errSecInvalidIdentityRef */ - CFClass identity; - CFClass identityCursor; - CFClass item; - CFClass cursor; - CFClass keychain; - /* @@@ Error should be errSecInvalidKeyRef */ - CFClass keyItem; - /* @@@ Error should be errSecInvalidPolicyRef */ - CFClass policy; - /* @@@ Error should be errSecInvalidPolicySearchRef */ - CFClass policyCursor; - /* @@@ Error should be errSecInvalidTrustRef */ - CFClass trust; - /* @@@ Error should be errSecInvalidTrustedApplicationRef */ - CFClass trustedApplication; - -public: - Mutex mapLock; - typedef std::map Map; - Map map; + /* Add new instances of CFClass here that you want registered with the CF runtime. */ + CFClass Access; + CFClass ACL; + CFClass Certificate; + CFClass CertificateRequest; + CFClass Identity; + CFClass IdentityCursor; + CFClass ItemImpl; + CFClass KCCursorImpl; + CFClass KeychainImpl; + CFClass KeyItem; + CFClass Policy; + CFClass PolicyCursor; + CFClass Trust; + CFClass TrustedApplication; }; - -extern ModuleNexus gTypes; +extern SecCFTypes &gTypes(); } // end namespace KeychainCore diff --git a/Keychain/SecCertificate.cpp b/Keychain/SecCertificate.cpp index 97e8de07..de95f462 100644 --- a/Keychain/SecCertificate.cpp +++ b/Keychain/SecCertificate.cpp @@ -16,16 +16,19 @@ */ #include +#include +#include +#include +#include #include "SecBridge.h" - CFTypeID SecCertificateGetTypeID(void) { BEGIN_SECAPI - return gTypes().certificate.typeId; + return gTypes().Certificate.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -36,8 +39,8 @@ SecCertificateCreateFromData(const CSSM_DATA *data, CSSM_CERT_TYPE type, CSSM_CE { BEGIN_SECAPI - RefPointer certificatePtr(new Certificate(Required(data), type, encoding)); - Required(certificate) = gTypes().certificate.handle(*certificatePtr); + SecPointer certificatePtr(new Certificate(Required(data), type, encoding)); + Required(certificate) = certificatePtr->handle(); END_SECAPI } @@ -48,7 +51,7 @@ SecCertificateAddToKeychain(SecCertificateRef certificate, SecKeychainRef keycha { BEGIN_SECAPI - Item item(gTypes().certificate.required(certificate)); + Item item(Certificate::required(certificate)); Keychain::optional(keychain)->add(item); END_SECAPI @@ -59,7 +62,7 @@ SecCertificateGetData(SecCertificateRef certificate, CSSM_DATA_PTR data) { BEGIN_SECAPI - Required(data) = gTypes().certificate.required(certificate)->data(); + Required(data) = Certificate::required(certificate)->data(); END_SECAPI } @@ -70,7 +73,7 @@ SecCertificateGetType(SecCertificateRef certificate, CSSM_CERT_TYPE *certificate { BEGIN_SECAPI - Required(certificateType) = gTypes().certificate.required(certificate)->type(); + Required(certificateType) = Certificate::required(certificate)->type(); END_SECAPI } @@ -81,7 +84,7 @@ SecCertificateGetSubject(SecCertificateRef certificate, CSSM_X509_NAME* subject) { BEGIN_SECAPI - gTypes().certificate.required(certificate)->getSubject(Required(subject)); + Certificate::required(certificate)->getSubject(Required(subject)); END_SECAPI } @@ -92,7 +95,7 @@ SecCertificateGetIssuer(SecCertificateRef certificate, CSSM_X509_NAME* issuer) { BEGIN_SECAPI - gTypes().certificate.required(certificate)->getIssuer(Required(issuer)); + Certificate::required(certificate)->getIssuer(Required(issuer)); END_SECAPI } @@ -103,7 +106,164 @@ SecCertificateGetCLHandle(SecCertificateRef certificate, CSSM_CL_HANDLE *clHandl { BEGIN_SECAPI - Required(clHandle) = gTypes().certificate.required(certificate)->clHandle(); + Required(clHandle) = Certificate::required(certificate)->clHandle(); + + END_SECAPI +} + +/* + * Private API to infer a display name for a SecCertificateRef which + * may or may not be in a keychain. + */ +OSStatus +SecCertificateInferLabel(SecCertificateRef certificate, CFStringRef *label) +{ + BEGIN_SECAPI + + Certificate::required(certificate)->inferLabel(false, + &Required(label)); + + END_SECAPI +} + +OSStatus +SecCertificateCopyPublicKey(SecCertificateRef certificate, SecKeyRef *key) +{ + BEGIN_SECAPI + + Required(key) = Certificate::required(certificate)->publicKey()->handle(); + + END_SECAPI +} + +OSStatus +SecCertificateGetAlgorithmID(SecCertificateRef certificate, const CSSM_X509_ALGORITHM_IDENTIFIER **algid) +{ + BEGIN_SECAPI + + Required(algid) = Certificate::required(certificate)->algorithmID(); + + END_SECAPI +} + +OSStatus +SecCertificateGetCommonName(SecCertificateRef certificate, CFStringRef *commonName) +{ + BEGIN_SECAPI + + Required(commonName) = Certificate::required(certificate)->commonName(); + + END_SECAPI +} + +OSStatus +SecCertificateGetEmailAddress(SecCertificateRef certificate, CFStringRef *emailAddress) +{ + BEGIN_SECAPI + + Required(emailAddress) = Certificate::required(certificate)->copyFirstEmailAddress(); + + END_SECAPI +} + +OSStatus +SecCertificateCopyEmailAddresses(SecCertificateRef certificate, CFArrayRef *emailAddresses) +{ + BEGIN_SECAPI + + Required(emailAddresses) = Certificate::required(certificate)->copyEmailAddresses(); END_SECAPI } + +OSStatus +SecCertificateFindByIssuerAndSN(CFTypeRef keychainOrArray,const CSSM_DATA *issuer, + const CSSM_DATA *serialNumber, SecCertificateRef *certificate) +{ + BEGIN_SECAPI + + StorageManager::KeychainList keychains; + globals().storageManager.optionalSearchList(keychainOrArray, keychains); + Required(certificate) = Certificate::findByIssuerAndSN(keychains, CssmData::required(issuer), CssmData::required(serialNumber))->handle(); + + END_SECAPI +} + +OSStatus +SecCertificateFindBySubjectKeyID(CFTypeRef keychainOrArray, const CSSM_DATA *subjectKeyID, + SecCertificateRef *certificate) +{ + BEGIN_SECAPI + + StorageManager::KeychainList keychains; + globals().storageManager.optionalSearchList(keychainOrArray, keychains); + Required(certificate) = Certificate::findBySubjectKeyID(keychains, CssmData::required(subjectKeyID))->handle(); + + END_SECAPI +} + +OSStatus +SecCertificateFindByEmail(CFTypeRef keychainOrArray, const char *emailAddress, SecCertificateRef *certificate) +{ + BEGIN_SECAPI + + StorageManager::KeychainList keychains; + globals().storageManager.optionalSearchList(keychainOrArray, keychains); + Required(certificate) = Certificate::findByEmail(keychains, emailAddress)->handle(); + + END_SECAPI +} + +OSStatus +SecKeychainSearchCreateForCertificateByIssuerAndSN(CFTypeRef keychainOrArray, const CSSM_DATA *issuer, + const CSSM_DATA *serialNumber, SecKeychainSearchRef *searchRef) +{ + BEGIN_SECAPI + + secdebug("kcsearch", "SecKeychainSearchCreateForCertificateByIssuerAndSN(%p)", + keychainOrArray); + Required(searchRef); + + StorageManager::KeychainList keychains; + globals().storageManager.optionalSearchList(keychainOrArray, keychains); + KCCursor cursor(Certificate::cursorForIssuerAndSN(keychains, CssmData::required(issuer), CssmData::required(serialNumber))); + *searchRef = cursor->handle(); + + END_SECAPI +} + +OSStatus +SecKeychainSearchCreateForCertificateBySubjectKeyID(CFTypeRef keychainOrArray, const CSSM_DATA *subjectKeyID, + SecKeychainSearchRef *searchRef) +{ + BEGIN_SECAPI + + secdebug("kcsearch", "SecKeychainSearchCreateForCertificateBySubjectKeyID(%p)", + keychainOrArray); + Required(searchRef); + + StorageManager::KeychainList keychains; + globals().storageManager.optionalSearchList(keychainOrArray, keychains); + KCCursor cursor(Certificate::cursorForSubjectKeyID(keychains, CssmData::required(subjectKeyID))); + *searchRef = cursor->handle(); + + END_SECAPI +} + +OSStatus +SecKeychainSearchCreateForCertificateByEmail(CFTypeRef keychainOrArray, const char *emailAddress, + SecKeychainSearchRef *searchRef) +{ + BEGIN_SECAPI + + secdebug("kcsearch", "SecKeychainSearchCreateForCertificateByEmail(%p, %s)", + keychainOrArray, emailAddress); + Required(searchRef); + + StorageManager::KeychainList keychains; + globals().storageManager.optionalSearchList(keychainOrArray, keychains); + KCCursor cursor(Certificate::cursorForEmail(keychains, emailAddress)); + *searchRef = cursor->handle(); + + END_SECAPI +} diff --git a/Keychain/SecCertificate.h b/Keychain/SecCertificate.h index 5d716c71..84806e21 100644 --- a/Keychain/SecCertificate.h +++ b/Keychain/SecCertificate.h @@ -143,6 +143,7 @@ OSStatus SecCertificateGetIssuer(SecCertificateRef certificate, CSSM_X509_NAME * */ OSStatus SecCertificateGetCLHandle(SecCertificateRef certificate, CSSM_CL_HANDLE *clHandle); + #if defined(__cplusplus) } #endif diff --git a/Keychain/SecCertificatePriv.h b/Keychain/SecCertificatePriv.h new file mode 100644 index 00000000..645660cf --- /dev/null +++ b/Keychain/SecCertificatePriv.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +#ifndef _SECURITY_SECCERTIFICATEPRIV_H_ +#define _SECURITY_SECCERTIFICATEPRIV_H_ + +#include +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +/*! + @function SecCertificateGetPublicKey + @abstract Retrieves the public key for a given certificate. + @param certificate A reference to the certificate from which to retrieve the data. + @param data On return, a pointer to the data for the certificate specified. The caller must allocate the space for a CSSM_DATA structure before calling this function. This data pointer is only guaranteed to remain valid as long as the certificate remains unchanged and valid. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecCertificateCopyPublicKey(SecCertificateRef certificate, SecKeyRef *key); + +OSStatus SecCertificateGetAlgorithmID(SecCertificateRef certificate,const CSSM_X509_ALGORITHM_IDENTIFIER **algid); + +OSStatus SecCertificateGetCommonName(SecCertificateRef certificate, CFStringRef *commonName); + +/* @@@ Obsoleted by SecCertificateCopyEmailAddresses(), also really should of been named + SecCertificateCopyEmailAddress() since the returned address is not autoreleased. */ +OSStatus SecCertificateGetEmailAddress(SecCertificateRef certificate, CFStringRef *emailAddress); + +OSStatus SecCertificateCopyEmailAddresses(SecCertificateRef certificate, CFArrayRef *emailAddresses); + +/* + * Private API to infer a display name for a SecCertificateRef which + * may or may not be in a keychain. + */ +OSStatus SecCertificateInferLabel(SecCertificateRef certificate, CFStringRef *label); + + +/* + * Subset of the above, useful for both certs and CRLs. + * Infer printable label for a given an CSSM_X509_NAME. Returns NULL + * if no appropriate printable name found. + */ +const CSSM_DATA *SecInferLabelFromX509Name( + const CSSM_X509_NAME *x509Name); + +/* Convenience functions for searching +*/ + +OSStatus SecCertificateFindByIssuerAndSN(CFTypeRef keychainOrArray, const CSSM_DATA *issuer, + const CSSM_DATA *serialNumber, SecCertificateRef *certificate); + +OSStatus SecCertificateFindBySubjectKeyID(CFTypeRef keychainOrArray, const CSSM_DATA *subjectKeyID, + SecCertificateRef *certificate); + +OSStatus SecCertificateFindByEmail(CFTypeRef keychainOrArray, const char *emailAddress, + SecCertificateRef *certificate); + + +/* These should go to SecKeychainSearchPriv.h. */ +OSStatus SecKeychainSearchCreateForCertificateByIssuerAndSN(CFTypeRef keychainOrArray, const CSSM_DATA *issuer, + const CSSM_DATA *serialNumber, SecKeychainSearchRef *searchRef); + +OSStatus SecKeychainSearchCreateForCertificateBySubjectKeyID(CFTypeRef keychainOrArray, const CSSM_DATA *subjectKeyID, + SecKeychainSearchRef *searchRef); + +OSStatus SecKeychainSearchCreateForCertificateByEmail(CFTypeRef keychainOrArray, const char *emailAddress, + SecKeychainSearchRef *searchRef); + + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SECURITY_SECCERTIFICATEPRIV_H_ */ diff --git a/Keychain/SecCertificateRequest.cpp b/Keychain/SecCertificateRequest.cpp index 5b9e7147..bab12cc5 100644 --- a/Keychain/SecCertificateRequest.cpp +++ b/Keychain/SecCertificateRequest.cpp @@ -25,7 +25,7 @@ SecCertificateRequestGetTypeID(void) { BEGIN_SECAPI - return gTypes().certificateRequest.typeId; + return gTypes().CertificateRequest.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } diff --git a/Keychain/SecFileVaultCert.cpp b/Keychain/SecFileVaultCert.cpp new file mode 100644 index 00000000..02a27529 --- /dev/null +++ b/Keychain/SecFileVaultCert.cpp @@ -0,0 +1,564 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ + +/* + * SecFileVaultCert.cpp - Certificate support for FileVault + */ + +#include "SecFileVaultCert.h" +#include "srCdsaUtils.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace KeychainCore; + +#pragma mark -------------------- SecFileVaultCert public implementation -------------------- + +SecFileVaultCert::SecFileVaultCert() +{ +} + +SecFileVaultCert::~SecFileVaultCert() +{ +} + +OSStatus SecFileVaultCert::createPair(CFStringRef hostName,CFStringRef userName,SecKeychainRef keychainRef, CFDataRef *cert) +{ + SecCertificateRef certRef = NULL; + CSSM_DL_DB_HANDLE dlDbHand = {0, 0}; + CSSM_CSP_HANDLE cspHand = 0; + CSSM_TP_HANDLE tpHand = 0; + CSSM_CL_HANDLE clHand = 0; + CSSM_KEY_PTR pubKey = NULL; + CSSM_KEY_PTR privKey = NULL; + CSSM_DATA certData = {0, NULL}; + char *hostStr = NULL; + char *userStr = NULL; + OSStatus ortn; + CSSM_OID algOid = SR_CERT_SIGNATURE_ALG_OID; + + KeychainCore::Keychain keychain = KeychainCore::Keychain::optional(keychainRef); + + hostStr = srCfStrToCString(hostName); + userStr = srCfStrToCString(userName); + if (!hostStr || !userStr) // probably not ASCII capable + MacOSError::throwMe(paramErr); + + // open keychain, connect to all the CDSA modules we'll need + + dlDbHand = keychain->database()->handle(); + cspHand = keychain->csp()->handle(); + + tpHand = srTpStartup(); + if (tpHand == 0) + MacOSError::throwMe(ioErr); + + clHand = srClStartup(); + if (clHand == 0) + MacOSError::throwMe(ioErr); + + // generate key pair, private key stored in keychain + ortn = generateKeyPair(cspHand, dlDbHand, SR_KEY_ALGORITHM, SR_KEY_SIZE_IN_BITS, + "FileVault Master Password Key", &pubKey, &privKey); + if (ortn) + MacOSError::throwMe(ortn); + + // generate the cert + ortn = createRootCert(tpHand,clHand,cspHand,pubKey,privKey,hostStr,userStr, + SR_CERT_SIGNATURE_ALGORITHM,&algOid,&certData); + if (ortn) + MacOSError::throwMe(ortn); + + // store the cert in the same DL/DB as the key pair [see SecCertificateCreateFromData] + + SecPointer certificatePtr(new Certificate(Required(&certData), CSSM_CERT_X_509v3, CSSM_CERT_ENCODING_DER)); + Required(&certRef) = certificatePtr->handle(); + + // Add the certificate item to the keychain [see SecCertificateAddToKeychain] + KeychainCore::Item item(Certificate::required(certRef)); + keychain->add(item); + + CFRelease(certRef); + + // return the cert to caller + *cert = CFDataCreate(NULL, certData.Data, certData.Length); + + // cleanup + if (hostStr) + free(hostStr); + if (userStr) + free(userStr); + if (tpHand) + CSSM_ModuleDetach(tpHand); + if (clHand) + CSSM_ModuleDetach(clHand); + if (pubKey) + { + CSSM_FreeKey(cspHand, + NULL, // access cred + pubKey, + CSSM_FALSE); // delete + APP_FREE(pubKey); + } + if (privKey) + { + CSSM_FreeKey(cspHand, + NULL, // access cred + privKey, + CSSM_FALSE); // delete + APP_FREE(privKey); + } + + return ortn; +} + +#pragma mark -------------------- SecFileVaultCert private implementation -------------------- + +OSStatus SecFileVaultCert::createRootCert( + CSSM_TP_HANDLE tpHand, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + CSSM_KEY_PTR subjPubKey, + CSSM_KEY_PTR signerPrivKey, + const char *hostName, // CSSMOID_CommonName + const char *userName, // CSSMOID_Description + CSSM_ALGORITHMS sigAlg, + const CSSM_OID *sigOid, + CSSM_DATA_PTR certData) // mallocd and RETURNED +{ + CE_DataAndType exts[2]; + CE_DataAndType *extp = exts; + unsigned numExts; + CSSM_DATA refId; // mallocd by + // CSSM_TP_SubmitCredRequest + CSSM_APPLE_TP_CERT_REQUEST certReq; + CSSM_TP_REQUEST_SET reqSet; + sint32 estTime; + CSSM_BOOL confirmRequired; + CSSM_TP_RESULT_SET_PTR resultSet; + CSSM_ENCODED_CERT *encCert; + CSSM_APPLE_TP_NAME_OID subjectNames[2]; + CSSM_TP_CALLERAUTH_CONTEXT CallerAuthContext; + CSSM_FIELD policyId; + + numExts = 0; + + certReq.challengeString = NULL; + + /* KeyUsage extension */ + extp->type = DT_KeyUsage; + extp->critical = CSSM_FALSE; + extp->extension.keyUsage = CE_KU_DigitalSignature | + CE_KU_KeyCertSign | + CE_KU_KeyEncipherment | + CE_KU_DataEncipherment; + extp++; + numExts++; + + /* BasicConstraints */ + extp->type = DT_BasicConstraints; + extp->critical = CSSM_TRUE; + extp->extension.basicConstraints.cA = CSSM_TRUE; + extp->extension.basicConstraints.pathLenConstraintPresent = CSSM_FALSE; + extp++; + numExts++; + + /* name array */ + subjectNames[0].string = hostName; + subjectNames[0].oid = &CSSMOID_CommonName; + subjectNames[1].string = userName; + subjectNames[1].oid = &CSSMOID_Description; + + /* certReq */ + certReq.cspHand = cspHand; + certReq.clHand = clHand; + randUint32(certReq.serialNumber); // random serial number + certReq.numSubjectNames = 2; + certReq.subjectNames = subjectNames; + + certReq.numIssuerNames = 0; // root for now + certReq.issuerNames = NULL; + certReq.issuerNameX509 = NULL; + certReq.certPublicKey = subjPubKey; + certReq.issuerPrivateKey = signerPrivKey; + certReq.signatureAlg = sigAlg; + certReq.signatureOid = *sigOid; + certReq.notBefore = 0; + certReq.notAfter = 60 * 60 * 24 * 365; // seconds from now, one year + certReq.numExtensions = numExts; + certReq.extensions = exts; + + reqSet.NumberOfRequests = 1; + reqSet.Requests = &certReq; + + /* a CSSM_TP_CALLERAUTH_CONTEXT to specify an OID */ + memset(&CallerAuthContext, 0, sizeof(CSSM_TP_CALLERAUTH_CONTEXT)); + memset(&policyId, 0, sizeof(CSSM_FIELD)); + policyId.FieldOid = CSSMOID_APPLE_TP_LOCAL_CERT_GEN; + + CallerAuthContext.Policy.NumberOfPolicyIds = 1; + CallerAuthContext.Policy.PolicyIds = &policyId; + + CSSM_RETURN crtn = CSSM_TP_SubmitCredRequest(tpHand, + NULL, // PreferredAuthority + CSSM_TP_AUTHORITY_REQUEST_CERTISSUE, + &reqSet, + &CallerAuthContext, + &estTime, + &refId); + + if(crtn) { + printError("***Error submitting credential request", + "CSSM_TP_SubmitCredRequest", crtn); + return crtn; + } + crtn = CSSM_TP_RetrieveCredResult(tpHand, + &refId, + NULL, // CallerAuthCredentials + &estTime, + &confirmRequired, + &resultSet); + if(crtn) { + printError("***Error retreiving credential request", + "CSSM_TP_RetrieveCredResult", crtn); + return crtn; + } + if(resultSet == NULL) { + printf("***CSSM_TP_RetrieveCredResult returned NULL result set.\n"); + return ioErr; + } + encCert = (CSSM_ENCODED_CERT *)resultSet->Results; + *certData = encCert->CertBlob; + + /* free resources allocated by TP */ + APP_FREE(refId.Data); + APP_FREE(encCert); + APP_FREE(resultSet); + return noErr; +} + +/* Convert a reference key to a raw key. */ +CSSM_RETURN SecFileVaultCert::refKeyToRaw( + CSSM_CSP_HANDLE cspHand, + const CSSM_KEY *refKey, + CSSM_KEY_PTR rawKey) // RETURNED +{ + CSSM_CC_HANDLE ccHand; + CSSM_RETURN crtn; + CSSM_ACCESS_CREDENTIALS creds; + + memset(rawKey, 0, sizeof(CSSM_KEY)); + memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS)); + crtn = CSSM_CSP_CreateSymmetricContext(cspHand, + CSSM_ALGID_NONE, + CSSM_ALGMODE_NONE, + &creds, // passPhrase + NULL, // wrapping key + NULL, // init vector + CSSM_PADDING_NONE, // Padding + 0, // Params + &ccHand); + if(crtn) { + printError("refKeyToRaw: context err", + "CSSM_CSP_CreateSymmetricContext", crtn); + return crtn; + } + + crtn = CSSM_WrapKey(ccHand, + &creds, + refKey, + NULL, // DescriptiveData + rawKey); + if(crtn != CSSM_OK) { + printError("refKeyToRaw: wrap err", "CSSM_WrapKey", crtn); + return crtn; + } + CSSM_DeleteContext(ccHand); + return CSSM_OK; +} + +/* + * Find private key by label, modify its Label attr to be the + * hash of the associated public key. + */ +CSSM_RETURN SecFileVaultCert::setPubKeyHash( + CSSM_CSP_HANDLE cspHand, + CSSM_DL_DB_HANDLE dlDbHand, + const CSSM_KEY *pubOrPrivKey, // to get hash; raw or ref/CSPDL + const char *keyLabel) // look up by this +{ + CSSM_QUERY query; + CSSM_SELECTION_PREDICATE predicate; + CSSM_DB_UNIQUE_RECORD_PTR record = NULL; + CSSM_RETURN crtn; + CSSM_DATA labelData; + CSSM_HANDLE resultHand; + + labelData.Data = (uint8 *)keyLabel; + labelData.Length = strlen(keyLabel) + 1; // incl. NULL + query.RecordType = CSSM_DL_DB_RECORD_PRIVATE_KEY; + query.Conjunctive = CSSM_DB_NONE; + query.NumSelectionPredicates = 1; + predicate.DbOperator = CSSM_DB_EQUAL; + + predicate.Attribute.Info.AttributeNameFormat = + CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + predicate.Attribute.Info.Label.AttributeName = "Label"; + predicate.Attribute.Info.AttributeFormat = + CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + predicate.Attribute.Value = &labelData; + query.SelectionPredicate = &predicate; + + query.QueryLimits.TimeLimit = 0; + query.QueryLimits.SizeLimit = 1; + query.QueryFlags = 0; + + /* build Record attribute with one attr */ + CSSM_DB_RECORD_ATTRIBUTE_DATA recordAttrs; + CSSM_DB_ATTRIBUTE_DATA attr; + attr.Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_STRING; + attr.Info.Label.AttributeName = "Label"; + attr.Info.AttributeFormat = CSSM_DB_ATTRIBUTE_FORMAT_BLOB; + + recordAttrs.DataRecordType = CSSM_DL_DB_RECORD_PRIVATE_KEY; + recordAttrs.NumberOfAttributes = 1; + recordAttrs.AttributeData = &attr; + + crtn = CSSM_DL_DataGetFirst(dlDbHand, + &query, + &resultHand, + &recordAttrs, + NULL, // hopefully optional ...theData, + &record); + /* abort only on success */ + if(crtn != CSSM_OK) { + printError("***setPubKeyHash: can't find private key", + "CSSM_DL_DataGetFirst", crtn); + return crtn; + } + + /* + * If specified key is a ref key, do NULL unwrap for use with raw CSP. + * If the CSPDL and SecurityServer support the key digest passthrough + * this is unnecessary. + */ + CSSM_KEY rawKeyToDigest; + if(pubOrPrivKey->KeyHeader.BlobType == CSSM_KEYBLOB_REFERENCE) { + crtn = refKeyToRaw(cspHand, pubOrPrivKey, &rawKeyToDigest); + if(crtn) { + printError("***Error converting public key to raw format", + "setPubKeyHash", crtn); + return crtn; + } + } + else { + /* use as is */ + rawKeyToDigest = *pubOrPrivKey; + } + + /* connect to raw CSP */ + CSSM_CSP_HANDLE rawCspHand = srCspStartup(CSSM_TRUE); + if(rawCspHand == 0) { + printf("***Error connecting to raw CSP; aborting.\n"); + return -1; + } + + /* calculate hash of pub key from private or public part */ + CSSM_DATA_PTR keyDigest = NULL; + CSSM_CC_HANDLE ccHand; + crtn = CSSM_CSP_CreatePassThroughContext(rawCspHand, + &rawKeyToDigest, + &ccHand); + if(ccHand == 0) { + printError("***Error calculating public key hash. Aborting:", + "CSSM_CSP_CreatePassThroughContext", crtn); + return -1; + } + crtn = CSSM_CSP_PassThrough(ccHand, + CSSM_APPLECSP_KEYDIGEST, + NULL, + (void **)&keyDigest); + if(crtn) { + printError("***Error calculating public key hash. Aborting:", + "CSSM_CSP_PassThrough(PUBKEYHASH)", crtn); // <<<<<<<<<<<<<<<<<<< + return crtn; + } + if(pubOrPrivKey->KeyHeader.BlobType == CSSM_KEYBLOB_REFERENCE) { + /* created in refKeyToRaw().... */ + CSSM_FreeKey(cspHand, NULL, &rawKeyToDigest, CSSM_FALSE); + } + CSSM_DeleteContext(ccHand); + CSSM_ModuleDetach(rawCspHand); + + /* + * Replace Label attr data with hash. + * NOTE: the module which allocated this attribute data - a DL - + * was loaded and attached by the Sec layer, not by us. Thus + * we can't use the memory allocator functions *we* used when + * attaching to the CSPDL - we have to use the ones + * which the Sec layer registered with the DL. + */ + CSSM_API_MEMORY_FUNCS memFuncs; + crtn = CSSM_GetAPIMemoryFunctions(dlDbHand.DLHandle, &memFuncs); + if(crtn) { + printError("***Error ", "CSSM_GetAPIMemoryFunctions(DLHandle)", + crtn); + /* oh well, leak and continue */ + } + else { + memFuncs.free_func(attr.Value->Data, memFuncs.AllocRef); + memFuncs.free_func(attr.Value, memFuncs.AllocRef); + } + attr.Value = keyDigest; + + /* modify key attributes */ + crtn = CSSM_DL_DataModify(dlDbHand, + CSSM_DL_DB_RECORD_PRIVATE_KEY, + record, + &recordAttrs, + NULL, // DataToBeModified + CSSM_DB_MODIFY_ATTRIBUTE_REPLACE); + if(crtn) { + printError("***Error setting public key hash. Aborting", + "CSSM_DL_DataModify(PUBKEYHASH)", crtn); + return crtn; + } + crtn = CSSM_DL_DataAbortQuery(dlDbHand, resultHand); + if(crtn) { + printError("***Error while stopping query", + "CSSM_DL_DataAbortQuery", crtn); + /* let's keep going in this case */ + } + crtn = CSSM_DL_FreeUniqueRecord(dlDbHand, record); + if(crtn) { + printError("***Error while freeing record", + "CSSM_DL_FreeUniqueRecord", crtn); + /* let's keep going in this case */ + crtn = CSSM_OK; + } + + /* free resources */ + srAppFree(keyDigest->Data, NULL); //*** + return CSSM_OK; +} + +/* + * Generate a key pair using the CSPDL. + */ +OSStatus SecFileVaultCert::generateKeyPair( + CSSM_CSP_HANDLE cspHand, + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_ALGORITHMS keyAlg, // e.g., CSSM_ALGID_RSA + uint32 keySizeInBits, + const char *keyLabel, // C string + CSSM_KEY_PTR *pubKeyPtr, // mallocd, created, RETURNED + CSSM_KEY_PTR *privKeyPtr) // mallocd, created, RETURNED +{ + CSSM_KEY_PTR pubKey = reinterpret_cast( + APP_MALLOC(sizeof(CSSM_KEY))); + CSSM_KEY_PTR privKey = reinterpret_cast( + APP_MALLOC(sizeof(CSSM_KEY))); + if((pubKey == NULL) || (privKey == NULL)) { + return memFullErr; + } + + CSSM_RETURN crtn; + CSSM_KEYUSE pubKeyUse; + CSSM_KEYUSE privKeyUse; + + pubKeyUse = CSSM_KEYUSE_VERIFY | CSSM_KEYUSE_ENCRYPT | + CSSM_KEYUSE_WRAP; + privKeyUse = CSSM_KEYUSE_SIGN | CSSM_KEYUSE_DECRYPT | + CSSM_KEYUSE_UNWRAP; + + crtn = srCspGenKeyPair(cspHand, + &dlDbHand, + keyAlg, + keyLabel, + strlen(keyLabel) + 1, + keySizeInBits, + pubKey, + pubKeyUse, + CSSM_KEYATTR_EXTRACTABLE | CSSM_KEYATTR_RETURN_REF, + privKey, + privKeyUse, + CSSM_KEYATTR_SENSITIVE | CSSM_KEYATTR_RETURN_REF | + CSSM_KEYATTR_PERMANENT | CSSM_KEYATTR_EXTRACTABLE); + + if(crtn) { + APP_FREE(pubKey); + APP_FREE(privKey); + return paramErr; + } + + /* bind private key to cert by public key hash */ + crtn = setPubKeyHash(cspHand, + dlDbHand, + pubKey, + keyLabel); + if(crtn) { + printError("***Error setting public key hash. Continuing at peril", + "setPubKeyHash", crtn); + } + + *pubKeyPtr = pubKey; + *privKeyPtr = privKey; + return noErr; +} + +#pragma mark -------------------- utility functions -------------------- + +void SecFileVaultCert::printError(const char *errDescription,const char *errLocation,OSStatus crtn) +{ + int len = 1; // trailing NULL in any case + if(errDescription) { + len += strlen(errDescription); + } + if(errLocation) { + len += strlen(errLocation); + } + char *buf = (char *)malloc(len); + buf[0] = 0; + if(errDescription) { + strcpy(buf, errDescription); + } + if(errLocation) { + strcat(buf, errLocation); + } + cssmPerror(buf, crtn); + free(buf); +} + +// Fill a uint32 with random data +void SecFileVaultCert::randUint32(uint32 &u) +{ + int dev = open("/dev/random", O_RDONLY); + if(dev < 0) { + return; + } + read(dev, &u, sizeof(u)); + close(dev); +} diff --git a/Keychain/SecFileVaultCert.h b/Keychain/SecFileVaultCert.h new file mode 100644 index 00000000..64f3a44d --- /dev/null +++ b/Keychain/SecFileVaultCert.h @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please + * obtain a copy of the License at http://www.apple.com/publicsource and + * read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + */ +/* + * SecFileVaultCert.h + */ + +#ifndef _SEC_FILEVAULTCERT_H_ +#define _SEC_FILEVAULTCERT_H_ + +#include +#include + +#include +#include + +class SecFileVaultCert +{ +public: + SecFileVaultCert(); + ~SecFileVaultCert(); + + OSStatus createPair(CFStringRef hostName,CFStringRef userName,SecKeychainRef kcRef, CFDataRef *cert); + +private: + + OSStatus generateKeyPair( + CSSM_CSP_HANDLE cspHand, + CSSM_DL_DB_HANDLE dlDbHand, + CSSM_ALGORITHMS keyAlg, // e.g., CSSM_ALGID_RSA + uint32 keySizeInBits, + const char *keyLabel, // C string + CSSM_KEY_PTR *pubKeyPtr, // mallocd, created, RETURNED + CSSM_KEY_PTR *privKeyPtr); + + OSStatus createRootCert( + CSSM_TP_HANDLE tpHand, + CSSM_CL_HANDLE clHand, + CSSM_CSP_HANDLE cspHand, + CSSM_KEY_PTR subjPubKey, + CSSM_KEY_PTR signerPrivKey, + const char *hostName, // CSSMOID_CommonName + const char *userName, // CSSMOID_Description + CSSM_ALGORITHMS sigAlg, + const CSSM_OID *sigOid, + CSSM_DATA_PTR certData); // mallocd and RETURNED + void printError(const char *errDescription,const char *errLocation,OSStatus crtn); + void randUint32(uint32 &u); + + CSSM_RETURN refKeyToRaw( + CSSM_CSP_HANDLE cspHand, + const CSSM_KEY *refKey, + CSSM_KEY_PTR rawKey); + + CSSM_RETURN setPubKeyHash( + CSSM_CSP_HANDLE cspHand, + CSSM_DL_DB_HANDLE dlDbHand, + const CSSM_KEY *pubOrPrivKey, // to get hash; raw or ref/CSPDL + const char *keyLabel); // look up by this +}; + +#pragma mark ----- Certificate Management ----- + +/* + * Create a key pair and a self-signed certificate. The private key and + * the cert are stored in the specified keychain; a copy of the cert is + * also returned. + * + * Arguments + * --------- + * + * hostName : The name of this host, e.g., "crypto.apple.com". This + * must match exactly the string later passed as peerHostName + * to SR_SecureTransportConfigure() (see below). This must be + * convertable to an ASCII C string. + * + * userName : e.g., "James P. Sullivan". Must be convertable to an + * ASCII C string. + * + * keychainName : the keychain where the certificate will be stored. + * + * cert : the root cert which can be distributed to peers (where it will be + * imported via SR_CertificateImport(), below). This is not sensitive + * data; it can be bandied about freely. Caller must CFRelease this. + */ +OSStatus SR_CertificateAndKeyCreate( + CFStringRef hostName, + CFStringRef userName, + SecKeychainRef keychain, + CFDataRef *cert); // RETURNED + +/* + * Import a peer's certificate into specified keychain. + */ +OSStatus SR_CertificateImport( + SecKeychainRef keychain, + CFDataRef cert); + +#pragma mark ----- Operating parameters ----- + +/* + * These are some constants which are used in the SecRendezvous + * library. Clients of the library don't have to know about these, + * but they might be useful or interesting. + */ + +/* + * The two TLS ciphersuites we support - the first one for + * authenticated connections, the second for unauthenticated. + * + * Subsequent to calling SR_SecureTransportConfigure(), an app + * can determine which of these ciphersuites was actually + * negotiated by calling SSLGetNegotiatedCipher(). + */ +#define SR_CIPHER_AUTHENTICATED SSL_RSA_WITH_RC4_128_SHA +#define SR_CIPHER_UNAUTHENTICATED SSL_DH_anon_WITH_RC4_128_MD5 + +/* + * Parameters used to create key pairs and certificates in + * SR_CertificateAndKeyCreate(). + */ +#define SR_KEY_ALGORITHM CSSM_ALGID_RSA +#define SR_KEY_SIZE_IN_BITS 1024 + +/* + * The CSSM_ALGORITHMS and OID values defining the signature + * algorithm in the generated certificate. + */ +#define SR_CERT_SIGNATURE_ALGORITHM CSSM_ALGID_SHA1WithRSA +#define SR_CERT_SIGNATURE_ALG_OID CSSMOID_SHA1WithRSA + +#endif /* _SEC_FILEVAULTCERT_H_ */ + diff --git a/Keychain/SecIdentity.cpp b/Keychain/SecIdentity.cpp index 1f8b6297..acfd73b5 100644 --- a/Keychain/SecIdentity.cpp +++ b/Keychain/SecIdentity.cpp @@ -16,16 +16,19 @@ */ #include +#include #include "SecBridge.h" - +#include +#include +#include CFTypeID SecIdentityGetTypeID(void) { BEGIN_SECAPI - return gTypes().identity.typeId; + return gTypes().Identity.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -38,8 +41,8 @@ SecIdentityCopyCertificate( { BEGIN_SECAPI - RefPointer certificatePtr(gTypes().identity.required(identityRef)->certificate()); - Required(certificateRef) = gTypes().certificate.handle(*certificatePtr); + SecPointer certificatePtr(Identity::required(identityRef)->certificate()); + Required(certificateRef) = certificatePtr->handle(); END_SECAPI } @@ -52,8 +55,23 @@ SecIdentityCopyPrivateKey( { BEGIN_SECAPI - RefPointer keyItemPtr(gTypes().identity.required(identityRef)->privateKey()); - Required(privateKeyRef) = gTypes().keyItem.handle(*keyItemPtr); + SecPointer keyItemPtr(Identity::required(identityRef)->privateKey()); + Required(privateKeyRef) = keyItemPtr->handle(); + + END_SECAPI +} + +OSStatus +SecIdentityCreateWithCertificate(CFTypeRef keychainOrArray, SecCertificateRef certificateRef, + SecIdentityRef *identityRef) +{ + BEGIN_SECAPI + + SecPointer certificatePtr(Certificate::required(certificateRef)); + StorageManager::KeychainList keychains; + globals().storageManager.optionalSearchList(keychainOrArray, keychains); + SecPointer identityPtr(new Identity(keychains, certificatePtr)); + Required(identityRef) = identityPtr->handle(); END_SECAPI } diff --git a/SecuritySNACCRuntime/c++-lib/inc/policy.h b/Keychain/SecIdentityPriv.h similarity index 66% rename from SecuritySNACCRuntime/c++-lib/inc/policy.h rename to Keychain/SecIdentityPriv.h index d69d0b20..e879e15e 100644 --- a/SecuritySNACCRuntime/c++-lib/inc/policy.h +++ b/Keychain/SecIdentityPriv.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. * * The contents of this file constitute Original Code as defined in and are * subject to the Apple Public Source License Version 1.2 (the 'License'). @@ -15,31 +15,20 @@ * specific language governing rights and limitations under the License. */ +#ifndef _SECURITY_SECIDENTITYPRIV_H_ +#define _SECURITY_SECIDENTITYPRIV_H_ -/* - * file: policy.h - * - */ +#include -/* - * enable the snacc compiler's Tcl interface generating code? - * set it to 0 or 1. - */ -#ifndef NO_TCL -#define NO_TCL 0 +#if defined(__cplusplus) +extern "C" { #endif -/* - * enable code for meta code generation? - * the Tcl code needs it. - */ -#ifndef NO_META -#define NO_META NO_TCL -#endif +OSStatus SecIdentityCreateWithCertificate(CFTypeRef keychainOrArray, SecCertificateRef certificateRef, + SecIdentityRef *identityRef); -/* - * enable code for CORBA IDL generation? - */ -#ifndef IDL -#define IDL 1 +#if defined(__cplusplus) +} #endif + +#endif /* !_SECURITY_SECIDENTITYPRIV_H_ */ diff --git a/Keychain/SecIdentitySearch.cpp b/Keychain/SecIdentitySearch.cpp index ffb810eb..bd95b1d9 100644 --- a/Keychain/SecIdentitySearch.cpp +++ b/Keychain/SecIdentitySearch.cpp @@ -16,6 +16,8 @@ */ #include +#include +#include #include "SecBridge.h" @@ -25,7 +27,7 @@ SecIdentitySearchGetTypeID(void) { BEGIN_SECAPI - return gTypes().identityCursor.typeId; + return gTypes().IdentityCursor.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -43,8 +45,8 @@ SecIdentitySearchCreate( StorageManager::KeychainList keychains; globals().storageManager.optionalSearchList(keychainOrArray, keychains); - RefPointer identityCursor(new IdentityCursor (keychains, keyUsage)); - *searchRef = gTypes().identityCursor.handle(*identityCursor); + SecPointer identityCursor(new IdentityCursor (keychains, keyUsage)); + *searchRef = identityCursor->handle(); END_SECAPI } @@ -58,11 +60,11 @@ SecIdentitySearchCopyNext( BEGIN_SECAPI RequiredParam(identityRef); - RefPointer identityPtr; - if (!gTypes().identityCursor.required(searchRef)->next(identityPtr)) + SecPointer identityPtr; + if (!IdentityCursor::required(searchRef)->next(identityPtr)) return errSecItemNotFound; - *identityRef = gTypes().identity.handle(*identityPtr); + *identityRef = identityPtr->handle(); END_SECAPI } diff --git a/Keychain/SecKey.cpp b/Keychain/SecKey.cpp index bf9cc3e1..1bba809a 100644 --- a/Keychain/SecKey.cpp +++ b/Keychain/SecKey.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "SecBridge.h" @@ -28,7 +29,7 @@ SecKeyGetTypeID(void) { BEGIN_SECAPI - return gTypes().keyItem.typeId; + return gTypes().KeyItem.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -50,8 +51,8 @@ SecKeyCreatePair( BEGIN_SECAPI Keychain keychain = Keychain::optional(keychainRef); - RefPointer theAccess(initialAccess ? gTypes().access.required(initialAccess) : new Access("")); - RefPointer pubItem, privItem; + SecPointer theAccess(initialAccess ? Access::required(initialAccess) : new Access("")); + SecPointer pubItem, privItem; KeyItem::createPair(keychain, algorithm, @@ -67,9 +68,9 @@ SecKeyCreatePair( // Return the generated keys. if (publicKeyRef) - *publicKeyRef = gTypes().keyItem.handle(*pubItem); + *publicKeyRef = pubItem->handle(); if (privateKeyRef) - *privateKeyRef = gTypes().keyItem.handle(*privItem); + *privateKeyRef = privItem->handle(); END_SECAPI } @@ -79,7 +80,7 @@ SecKeyGetCSSMKey(SecKeyRef key, const CSSM_KEY **cssmKey) { BEGIN_SECAPI - Required(cssmKey) = &gTypes().keyItem.required(key)->cssmKey(); + Required(cssmKey) = KeyItem::required(key)->key(); END_SECAPI } @@ -89,6 +90,39 @@ SecKeyGetCSSMKey(SecKeyRef key, const CSSM_KEY **cssmKey) // Private APIs // +OSStatus +SecKeyGetCSPHandle(SecKeyRef keyRef, CSSM_CSP_HANDLE *cspHandle) +{ + BEGIN_SECAPI + + SecPointer keyItem(KeyItem::required(keyRef)); + Required(cspHandle) = keyItem->csp()->handle(); + + END_SECAPI +} + +OSStatus +SecKeyGetAlgorithmID(SecKeyRef keyRef, const CSSM_X509_ALGORITHM_IDENTIFIER **algid) +{ + BEGIN_SECAPI + + SecPointer keyItem(KeyItem::required(keyRef)); + Required(algid) = &keyItem->algorithmIdentifier(); + + END_SECAPI +} + +OSStatus +SecKeyGetStrengthInBits(SecKeyRef keyRef, const CSSM_X509_ALGORITHM_IDENTIFIER *algid, unsigned int *strength) +{ + BEGIN_SECAPI + + SecPointer keyItem(KeyItem::required(keyRef)); + Required(strength) = keyItem->strengthInBits(algid); + + END_SECAPI +} + OSStatus SecKeyGetCredentials( SecKeyRef keyRef, @@ -98,7 +132,7 @@ SecKeyGetCredentials( { BEGIN_SECAPI - RefPointer keyItem(gTypes().keyItem.required(keyRef)); + SecPointer keyItem(KeyItem::required(keyRef)); Required(outCredentials) = keyItem->getCredentials(operation, credentialType); END_SECAPI @@ -116,8 +150,8 @@ SecKeyImportPair( BEGIN_SECAPI Keychain keychain = Keychain::optional(keychainRef); - RefPointer theAccess(initialAccess ? gTypes().access.required(initialAccess) : new Access("")); - RefPointer pubItem, privItem; + SecPointer theAccess(initialAccess ? Access::required(initialAccess) : new Access("")); + SecPointer pubItem, privItem; KeyItem::importPair(keychain, Required(publicCssmKey), @@ -128,9 +162,63 @@ SecKeyImportPair( // Return the generated keys. if (publicKey) - *publicKey = gTypes().keyItem.handle(*pubItem); + *publicKey = pubItem->handle(); if (privateKey) - *privateKey = gTypes().keyItem.handle(*privItem); + *privateKey = privItem->handle(); + + END_SECAPI +} + +OSStatus +SecKeyGenerate( + SecKeychainRef keychainRef, + CSSM_ALGORITHMS algorithm, + uint32 keySizeInBits, + CSSM_CC_HANDLE contextHandle, + CSSM_KEYUSE keyUsage, + uint32 keyAttr, + SecAccessRef initialAccess, + SecKeyRef* keyRef) +{ + BEGIN_SECAPI + + Keychain keychain; + SecPointer theAccess; + + if (keychainRef) + keychain = KeychainImpl::required(keychainRef); + if (initialAccess) + theAccess = Access::required(initialAccess); + + KeyItem *item = KeyItem::generate(keychain, + algorithm, + keySizeInBits, + contextHandle, + keyUsage, + keyAttr, + theAccess); + + // Return the generated key. + if (keyRef) + *keyRef = item->handle(); + + END_SECAPI +} + + +OSStatus SecKeyCreate(const CSSM_KEY *cssmKey, + SecKeyRef* keyRef) +{ + BEGIN_SECAPI + + Required(cssmKey); + CssmClient::CSP csp(cssmKey->KeyHeader.CspId); + CssmClient::Key key(csp, *cssmKey); + KeyItem *item = new KeyItem(key); + + // Return the generated key. + if (keyRef) + *keyRef = item->handle(); END_SECAPI } diff --git a/Keychain/SecKeyPriv.h b/Keychain/SecKeyPriv.h index 973d1db2..971c0179 100644 --- a/Keychain/SecKeyPriv.h +++ b/Keychain/SecKeyPriv.h @@ -62,6 +62,23 @@ enum }; +/*! + @function SecKeyGetCSPHandle + @abstract Returns the CSSM_CSP_HANDLE attachment for the given key reference. The handle is valid until the key reference is released. + @param keyRef A key reference. + @param cspHandle On return, a pointer to the CSSM_CSP_HANDLE for the given keychain. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus +SecKeyGetCSPHandle(SecKeyRef keyRef, CSSM_CSP_HANDLE *cspHandle); + +OSStatus +SecKeyGetAlgorithmID(SecKeyRef key, const CSSM_X509_ALGORITHM_IDENTIFIER **algid); + +OSStatus +SecKeyGetStrengthInBits(SecKeyRef key, const CSSM_X509_ALGORITHM_IDENTIFIER *algid, unsigned int *strength); + + /*! @function SecKeyGetCredentials @abstract For a given key return a const CSSM_ACCESS_CREDENTIALS * which will allow the key to be used. @@ -96,6 +113,32 @@ OSStatus SecKeyImportPair( SecKeyRef* publicKey, SecKeyRef* privateKey); +/*! + @function SecKeyGenerate + @abstract Generate a symmetric key and optionally stores it in the keychain specified by the keychainRef parameter. + @param keychainRef(optional) A reference to the keychain in which to store the private and public key items. Specify NULL to generate a transient key. + @param algorithm An algorithm for the key pair. This parameter is ignored if contextHandle is non 0. + @param keySizeInBits A key size for the key pair. This parameter is ignored if contextHandle is non 0. + @param contextHandle(optional) An optional CSSM_CC_HANDLE or 0. If this argument is not 0 the algorithm and keySizeInBits parameters are ignored. If extra parameters are needed to generate a key (some algortihms require this) you should create a context using CSSM_CSP_CreateKeyGenContext(), using the CSPHandle obtained by calling SecKeychainGetCSPHandle(). Then use CSSM_UpdateContextAttributes() to add additional parameters and dispose of the context using CSSM_DeleteContext after calling this function. + @param keyUsage A bit mask indicating all permitted uses for the new key. The bit mask values are defined in cssmtype.h + @param keyAttr A bit mask defining attribute values for the new key. The bit mask values are equivalent to a CSSM_KEYATTR_FLAGS and are defined in cssmtype.h + @param initialAccess(optional) A SecAccess object that determines the initial access rights to the key. This parameter is ignored if the keychainRef is NULL. + @param key Output pointer to the keychain item reference of the geerated key. Use the SecKeyGetCSSMKey function to obtain the CSSM_KEY. The caller must call CFRelease on this value if it is returned. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecKeyGenerate( + SecKeychainRef keychainRef, + CSSM_ALGORITHMS algorithm, + uint32 keySizeInBits, + CSSM_CC_HANDLE contextHandle, + CSSM_KEYUSE keyUsage, + uint32 keyAttr, + SecAccessRef initialAccess, + SecKeyRef* keyRef); + +OSStatus SecKeyCreate(const CSSM_KEY *key, + SecKeyRef* keyRef); + #if defined(__cplusplus) } diff --git a/Keychain/SecKeychain.cpp b/Keychain/SecKeychain.cpp index a90e4ad4..53d05c19 100644 --- a/Keychain/SecKeychain.cpp +++ b/Keychain/SecKeychain.cpp @@ -17,19 +17,22 @@ #include #include +#include #include #include #include "SecBridge.h" #include "CCallbackMgr.h" #include "Schema.h" - +#include +#include CFTypeID SecKeychainGetTypeID(void) { BEGIN_SECAPI - return gTypes().keychain.typeId; + secdebug("kc", "SecKeychainGetTypeID()"); + return gTypes().KeychainImpl.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -38,6 +41,7 @@ SecKeychainGetTypeID(void) OSStatus SecKeychainGetVersion(UInt32 *returnVers) { + secdebug("kc", "SecKeychainGetVersion(%p)", returnVers); if (!returnVers) return noErr; @@ -51,7 +55,8 @@ SecKeychainOpen(const char *pathName, SecKeychainRef *keychainRef) { BEGIN_SECAPI - RequiredParam(keychainRef)=gTypes().keychain.handle(*globals().storageManager.make(pathName)); + secdebug("kc", "SecKeychainOpen(\"%s\", %p)", pathName, keychainRef); + RequiredParam(keychainRef)=globals().storageManager.make(pathName, false)->handle(); END_SECAPI } @@ -63,6 +68,7 @@ SecKeychainCreate(const char *pathName, UInt32 passwordLength, const void *passw { BEGIN_SECAPI + secdebug("kc", "SecKeychainCreate(\"%s\", %lu, %p, %d, %p, %p)", pathName, passwordLength, password, promptUser, initialAccess, keychainRef); KCThrowParamErrIf_(!pathName); Keychain keychain = globals().storageManager.make(pathName); @@ -75,7 +81,7 @@ SecKeychainCreate(const char *pathName, UInt32 passwordLength, const void *passw KCThrowParamErrIf_(!password); keychain->create(passwordLength, password); } - RequiredParam(keychainRef)=gTypes().keychain.handle(*keychain); + RequiredParam(keychainRef)=keychain->handle(); END_SECAPI } @@ -86,6 +92,8 @@ SecKeychainDelete(SecKeychainRef keychainOrArray) { BEGIN_SECAPI + secdebug("kc", "SecKeychainDelete(%p)", keychainOrArray); + KCThrowIf_(!keychainOrArray, errSecInvalidKeychain); StorageManager::KeychainList keychains; globals().storageManager.optionalSearchList(keychainOrArray, keychains); globals().storageManager.remove(keychains, true); @@ -99,6 +107,7 @@ SecKeychainSetSettings(SecKeychainRef keychainRef, const SecKeychainSettings *ne { BEGIN_SECAPI + secdebug("kc", "SecKeychainSetSettings(%p, %p)", keychainRef, newSettings); Keychain keychain = Keychain::optional(keychainRef); if (newSettings->version==SEC_KEYCHAIN_SETTINGS_VERS1) { @@ -116,6 +125,7 @@ SecKeychainCopySettings(SecKeychainRef keychainRef, SecKeychainSettings *outSett { BEGIN_SECAPI + secdebug("kc", "SecKeychainCopySettings(%p, %p)", keychainRef, outSettings); Keychain keychain = Keychain::optional(keychainRef); if (outSettings->version==SEC_KEYCHAIN_SETTINGS_VERS1) { @@ -136,9 +146,10 @@ SecKeychainUnlock(SecKeychainRef keychainRef, UInt32 passwordLength, void *passw { BEGIN_SECAPI + secdebug("kc", "SecKeychainUnlock(%p, %lu, %p, %d)", keychainRef, passwordLength, password, usePassword); Keychain keychain = Keychain::optional(keychainRef); - - if(usePassword) + + if (usePassword) keychain->unlock(CssmData(password,passwordLength)); else keychain->unlock(); @@ -152,6 +163,7 @@ SecKeychainLock(SecKeychainRef keychainRef) { BEGIN_SECAPI + secdebug("kc", "SecKeychainLock(%p)", keychainRef); Keychain keychain = Keychain::optional(keychainRef); keychain->lock(); @@ -164,18 +176,53 @@ SecKeychainLockAll(void) { BEGIN_SECAPI + secdebug("kc", "SecKeychainLockAll()"); globals().storageManager.lockAll(); END_SECAPI } +OSStatus SecKeychainResetLogin(UInt32 passwordLength, const void* password, Boolean resetSearchList) +{ + BEGIN_SECAPI + KCThrowParamErrIf_(password==NULL); + // + // Get the current user (using fallback method if necessary) + // + char* uName = getenv("USER"); + string userName = uName ? uName : ""; + if ( userName.length() == 0 ) + { + uid_t uid = geteuid(); + if (!uid) uid = getuid(); + struct passwd *pw = getpwuid(uid); // fallback case... + if (pw) + userName = pw->pw_name; + endpwent(); + } + if ( userName.length() == 0 ) // did we ultimately get one? + MacOSError::throwMe(errAuthorizationInternal); + // + // Clears the plist and moves aside (renames) an existing login.keychain + // + globals().storageManager.resetKeychain(resetSearchList); + // + // Creates a login keychain and sets it to the default. + // + globals().storageManager.login(userName.length(), userName.c_str(), passwordLength, password); + Keychain keychain = globals().storageManager.loginKeychain(); + globals().storageManager.defaultKeychain(keychain); + END_SECAPI +} + OSStatus SecKeychainCopyDefault(SecKeychainRef *keychainRef) { BEGIN_SECAPI - RequiredParam(keychainRef)=gTypes().keychain.handle(*globals().defaultKeychain.keychain()); + secdebug("kc", "SecKeychainCopyDefault(%p)", keychainRef); + RequiredParam(keychainRef)=globals().storageManager.defaultKeychain()->handle(); END_SECAPI } @@ -186,15 +233,17 @@ SecKeychainSetDefault(SecKeychainRef keychainRef) { BEGIN_SECAPI - globals().defaultKeychain.keychain(Keychain::optional(keychainRef)); + secdebug("kc", "SecKeychainSetDefault(%p)", keychainRef); + globals().storageManager.defaultKeychain(Keychain::optional(keychainRef)); END_SECAPI } -OSStatus SecKeychainCopySearchList(CFArrayRef* searchList) +OSStatus SecKeychainCopySearchList(CFArrayRef *searchList) { BEGIN_SECAPI + secdebug("kc", "SecKeychainCopySearchList(%p)", searchList); RequiredParam(searchList); StorageManager &smr = globals().storageManager; StorageManager::KeychainList keychainList; @@ -208,6 +257,7 @@ OSStatus SecKeychainSetSearchList(CFArrayRef searchList) { BEGIN_SECAPI + secdebug("kc", "SecKeychainSetSearchList(%p)", searchList); RequiredParam(searchList); StorageManager &smr = globals().storageManager; StorageManager::KeychainList keychainList; @@ -217,11 +267,79 @@ OSStatus SecKeychainSetSearchList(CFArrayRef searchList) END_SECAPI } +OSStatus SecKeychainCopyDomainDefault(SecPreferencesDomain domain, SecKeychainRef *keychainRef) +{ + BEGIN_SECAPI + + secdebug("kc", "SecKeychainCopyDefault(%p)", keychainRef); + RequiredParam(keychainRef)=globals().storageManager.defaultKeychain(domain)->handle(); + + END_SECAPI +} + +OSStatus SecKeychainSetDomainDefault(SecPreferencesDomain domain, SecKeychainRef keychainRef) +{ + BEGIN_SECAPI + + secdebug("kc", "SecKeychainSetDefault(%p)", keychainRef); + globals().storageManager.defaultKeychain(domain, Keychain::optional(keychainRef)); + + END_SECAPI +} + +OSStatus SecKeychainCopyDomainSearchList(SecPreferencesDomain domain, CFArrayRef *searchList) +{ + BEGIN_SECAPI + + secdebug("kc", "SecKeychainCopyDomainSearchList(%p)", searchList); + RequiredParam(searchList); + StorageManager &smr = globals().storageManager; + StorageManager::KeychainList keychainList; + smr.getSearchList(domain, keychainList); + *searchList = smr.convertFromKeychainList(keychainList); + + END_SECAPI +} + +OSStatus SecKeychainSetDomainSearchList(SecPreferencesDomain domain, CFArrayRef searchList) +{ + BEGIN_SECAPI + + secdebug("kc", "SecKeychainSetDomainSearchList(%p)", searchList); + RequiredParam(searchList); + StorageManager &smr = globals().storageManager; + StorageManager::KeychainList keychainList; + smr.convertToKeychainList(searchList, keychainList); + smr.setSearchList(domain, keychainList); + + END_SECAPI +} + +OSStatus SecKeychainSetPreferenceDomain(SecPreferencesDomain domain) +{ + BEGIN_SECAPI + + globals().storageManager.domain(domain); + + END_SECAPI +} + +OSStatus SecKeychainGetPreferenceDomain(SecPreferencesDomain *domain) +{ + BEGIN_SECAPI + + *domain = globals().storageManager.domain(); + + END_SECAPI +} + + OSStatus SecKeychainGetStatus(SecKeychainRef keychainRef, SecKeychainStatus *keychainStatus) { BEGIN_SECAPI + secdebug("kc", "SecKeychainGetStatus(%p): %p", keychainRef, keychainStatus); RequiredParam(keychainStatus) = (SecKeychainStatus)Keychain::optional(keychainRef)->status(); END_SECAPI @@ -229,11 +347,13 @@ SecKeychainGetStatus(SecKeychainRef keychainRef, SecKeychainStatus *keychainStat OSStatus -SecKeychainGetPath(SecKeychainRef keychainRef, UInt32 * ioPathLength, char *pathName) +SecKeychainGetPath(SecKeychainRef keychainRef, UInt32 *ioPathLength, char *pathName) { BEGIN_SECAPI + secdebug("kc", "SecKeychainGetPath(%p, %p, %p)", keychainRef, ioPathLength, pathName); RequiredParam(pathName); + RequiredParam(ioPathLength); const char *name = Keychain::optional(keychainRef)->name(); UInt32 nameLen = strlen(name); @@ -253,6 +373,7 @@ SecKeychainListGetCount(void) { BEGIN_SECAPI + secdebug("kc", "SecKeychainListGetCount()"); return globals().storageManager.size(); END_SECAPI1(0) @@ -265,8 +386,9 @@ SecKeychainListCopyKeychainAtIndex(UInt16 index, SecKeychainRef *keychainRef) { BEGIN_SECAPI + secdebug("kc", "SecKeychainListCopyKeychainAtIndex(%d, %p)", index, keychainRef); KeychainCore::StorageManager &smgr=KeychainCore::globals().storageManager; - RequiredParam(keychainRef)=gTypes().keychain.handle(*smgr[index]); + RequiredParam(keychainRef)=smgr[index]->handle(); END_SECAPI } @@ -278,6 +400,7 @@ SecKeychainListRemoveKeychain(SecKeychainRef *keychainRef) { BEGIN_SECAPI + secdebug("kc", "SecKeychainListRemoveKeychain(%p)", keychainRef); Required(keychainRef); Keychain keychain = Keychain::optional(*keychainRef); StorageManager::KeychainList keychainList; @@ -294,6 +417,7 @@ SecKeychainAttributeInfoForItemID(SecKeychainRef keychainRef, UInt32 itemID, Sec { BEGIN_SECAPI + secdebug("kc", "SecKeychainAttributeInfoForItemID(%p, %lu, %p)", keychainRef, itemID, info); Keychain keychain = Keychain::optional(keychainRef); keychain->getAttributeInfoForItemID(itemID, info); @@ -306,6 +430,7 @@ SecKeychainFreeAttributeInfo(SecKeychainAttributeInfo *info) { BEGIN_SECAPI + secdebug("kc", "SecKeychainFreeAttributeInfo(%p)", info); KeychainImpl::freeAttributeInfo(info); END_SECAPI @@ -317,6 +442,7 @@ SecKeychainAddCallback(SecKeychainCallback callbackFunction, SecKeychainEventMas { BEGIN_SECAPI + secdebug("kc", "SecKeychainAddCallback(%p, %08lx, %p)", callbackFunction, eventMask, userContext); RequiredParam(callbackFunction); CCallbackMgr::AddCallback(callbackFunction,eventMask,userContext); @@ -329,32 +455,35 @@ SecKeychainRemoveCallback(SecKeychainCallback callbackFunction) { BEGIN_SECAPI + secdebug("kc", "SecKeychainRemoveCallback(%p)", callbackFunction); RequiredParam(callbackFunction); CCallbackMgr::RemoveCallback(callbackFunction); END_SECAPI } - OSStatus SecKeychainAddInternetPassword(SecKeychainRef keychainRef, UInt32 serverNameLength, const char *serverName, UInt32 securityDomainLength, const char *securityDomain, UInt32 accountNameLength, const char *accountName, UInt32 pathLength, const char *path, UInt16 port, SecProtocolType protocol, SecAuthenticationType authenticationType, UInt32 passwordLength, const void *passwordData, SecKeychainItemRef *itemRef) { BEGIN_SECAPI + secdebug("kc", "SecKeychainAddInternetPassword(%p)", keychainRef); KCThrowParamErrIf_(passwordLength!=0 && passwordData==NULL); // @@@ Get real itemClass Item item(kSecInternetPasswordItemClass, 'aapl', passwordLength, passwordData); if (serverName && serverNameLength) - item->setAttribute(Schema::attributeInfo(kSecServerItemAttr), - CssmData(const_cast(reinterpret_cast(serverName)), serverNameLength)); + { + CssmData server(const_cast(reinterpret_cast(serverName)), serverNameLength); + item->setAttribute(Schema::attributeInfo(kSecServerItemAttr), server); + // use server name as default label + item->setAttribute(Schema::attributeInfo(kSecLabelItemAttr), server); + } if (accountName && accountNameLength) { CssmData account(const_cast(reinterpret_cast(accountName)), accountNameLength); item->setAttribute(Schema::attributeInfo(kSecAccountItemAttr), account); - // @@@ We should probably leave setting of label up to lower level code. - item->setAttribute(Schema::attributeInfo(kSecLabelItemAttr), account); } if (securityDomain && securityDomainLength) @@ -369,9 +498,24 @@ SecKeychainAddInternetPassword(SecKeychainRef keychainRef, UInt32 serverNameLeng item->setAttribute(Schema::attributeInfo(kSecPathItemAttr), CssmData(const_cast(reinterpret_cast(path)), pathLength)); - Keychain::optional(keychainRef)->add(item); - if (itemRef) - *itemRef = gTypes().item.handle(*item); + Keychain keychain = nil; + try + { + keychain = Keychain::optional(keychainRef); + if ( !keychain->exists() ) + { + MacOSError::throwMe(errSecNoSuchKeychain); // Might be deleted or not available at this time. + } + } + catch(...) + { + keychain = globals().storageManager.defaultKeychainUI(item); + } + + keychain->add(item); + + if (itemRef) + *itemRef = item->handle(); END_SECAPI } @@ -383,6 +527,7 @@ SecKeychainFindInternetPassword(CFTypeRef keychainOrArray, UInt32 serverNameLeng { BEGIN_SECAPI + secdebug("kc", "SecKeychainFindInternetPassword(%p)", keychainOrArray); StorageManager::KeychainList keychains; globals().storageManager.optionalSearchList(keychainOrArray, keychains); KCCursor cursor(keychains, kSecInternetPasswordItemClass, NULL); @@ -444,7 +589,7 @@ SecKeychainFindInternetPassword(CFTypeRef keychainOrArray, UInt32 serverNameLeng } if (itemRef) - *itemRef=gTypes().item.handle(*item); + *itemRef=item->handle(); END_SECAPI } @@ -452,28 +597,45 @@ SecKeychainFindInternetPassword(CFTypeRef keychainOrArray, UInt32 serverNameLeng OSStatus SecKeychainAddGenericPassword(SecKeychainRef keychainRef, UInt32 serviceNameLength, const char *serviceName, UInt32 accountNameLength, const char *accountName, UInt32 passwordLength, const void *passwordData, SecKeychainItemRef *itemRef) - { BEGIN_SECAPI + secdebug("kc", "SecKeychainAddGenericPassword(%p)", keychainRef); KCThrowParamErrIf_(passwordLength!=0 && passwordData==NULL); // @@@ Get real itemClass Item item(kSecGenericPasswordItemClass, 'aapl', passwordLength, passwordData); if (serviceName && serviceNameLength) - item->setAttribute(Schema::attributeInfo(kSecServiceItemAttr), CssmData(const_cast(reinterpret_cast(serviceName)), serviceNameLength)); + { + CssmData service(const_cast(reinterpret_cast(serviceName)), serviceNameLength); + item->setAttribute(Schema::attributeInfo(kSecServiceItemAttr), service); + // use service name as default label + item->setAttribute(Schema::attributeInfo(kSecLabelItemAttr), service); + } if (accountName && accountNameLength) { CssmData account(const_cast(reinterpret_cast(accountName)), accountNameLength); item->setAttribute(Schema::attributeInfo(kSecAccountItemAttr), account); - // @@@ We should probably leave setting of label up to lower level code. - item->setAttribute(Schema::attributeInfo(kSecLabelItemAttr), account); } - Keychain::optional(keychainRef)->add(item); + Keychain keychain = nil; + try + { + keychain = Keychain::optional(keychainRef); + if ( !keychain->exists() ) + { + MacOSError::throwMe(errSecNoSuchKeychain); // Might be deleted or not available at this time. + } + } + catch(...) + { + keychain = globals().storageManager.defaultKeychainUI(item); + } + + keychain->add(item); if (itemRef) - *itemRef = gTypes().item.handle(*item); + *itemRef = item->handle(); END_SECAPI } @@ -483,8 +645,11 @@ OSStatus SecKeychainFindGenericPassword(CFTypeRef keychainOrArray, UInt32 serviceNameLength, const char *serviceName, UInt32 accountNameLength, const char *accountName, UInt32 *passwordLength, void **passwordData, SecKeychainItemRef *itemRef) { + Debug::trace (kSecTraceSecurityFrameworkSecKeychainFindGenericPasswordBegin); + BEGIN_SECAPI + secdebug("kc", "SecKeychainFindGenericPassword(%p)", keychainOrArray); StorageManager::KeychainList keychains; globals().storageManager.optionalSearchList(keychainOrArray, keychains); KCCursor cursor(keychains, kSecGenericPasswordItemClass, NULL); @@ -517,7 +682,7 @@ SecKeychainFindGenericPassword(CFTypeRef keychainOrArray, UInt32 serviceNameLeng } if (itemRef) - *itemRef=gTypes().item.handle(*item); + *itemRef=item->handle(); END_SECAPI } @@ -528,6 +693,7 @@ SecKeychainSetUserInteractionAllowed(Boolean state) { BEGIN_SECAPI + secdebug("kc", "SecKeychainSetUserInteractionAllowed(%d)", state); globals().setUserInteractionAllowed(state); END_SECAPI @@ -539,6 +705,7 @@ SecKeychainGetUserInteractionAllowed(Boolean *state) { BEGIN_SECAPI + secdebug("kc", "SecKeychainGetUserInteractionAllowed()"); Required(state)=globals().getUserInteractionAllowed(); END_SECAPI @@ -550,6 +717,7 @@ SecKeychainGetDLDBHandle(SecKeychainRef keychainRef, CSSM_DL_DB_HANDLE *dldbHand { BEGIN_SECAPI + secdebug("kc", "SecKeychainGetDLDBHandle(%p, %p)", keychainRef, dldbHandle); RequiredParam(dldbHandle); Keychain keychain = Keychain::optional(keychainRef); @@ -564,6 +732,7 @@ SecKeychainGetCSPHandle(SecKeychainRef keychainRef, CSSM_CSP_HANDLE *cspHandle) { BEGIN_SECAPI + secdebug("kc", "SecKeychainGetCSPHandle(%p, %p)", keychainRef, cspHandle); RequiredParam(cspHandle); Keychain keychain = Keychain::optional(keychainRef); @@ -578,6 +747,7 @@ SecKeychainCopyAccess(SecKeychainRef keychainRef, SecAccessRef *accessRef) { BEGIN_SECAPI + secdebug("kc", "SecKeychainCopyAccess(%p, %p)", keychainRef, accessRef); MacOSError::throwMe(unimpErr);//%%%for now END_SECAPI @@ -589,6 +759,7 @@ SecKeychainSetAccess(SecKeychainRef keychainRef, SecAccessRef accessRef) { BEGIN_SECAPI + secdebug("kc", "SecKeychainSetAccess(%p, %p)", keychainRef, accessRef); MacOSError::throwMe(unimpErr);//%%%for now END_SECAPI @@ -603,6 +774,8 @@ SecKeychainChangePassword(SecKeychainRef keychainRef, UInt32 oldPasswordLength, { BEGIN_SECAPI + secdebug("kc", "SecKeychainChangePassword(%p, %lu, %p, %lu, %p)", keychainRef, + oldPasswordLength, oldPassword, newPasswordLength, newPassword); Keychain keychain = Keychain::optional(keychainRef); keychain->changePassphrase (oldPasswordLength, oldPassword, newPasswordLength, newPassword); @@ -615,9 +788,8 @@ SecKeychainCopyLogin(SecKeychainRef *keychainRef) { BEGIN_SECAPI - // NOTE: operates on default Keychain! It shouldn't... we want to - // have code that operates of a login keychain. - RequiredParam(keychainRef)=gTypes().keychain.handle(*globals().defaultKeychain.keychain()); + secdebug("kc", "SecKeychainCopyLogin(%p)", keychainRef); + RequiredParam(keychainRef)=globals().storageManager.loginKeychain()->handle(); END_SECAPI } @@ -628,6 +800,7 @@ SecKeychainLogin(UInt32 nameLength, void* name, UInt32 passwordLength, void* pas { BEGIN_SECAPI + secdebug("kc", "SecKeychainLogin(%lu, %p, %lu, %p)", nameLength, name, passwordLength, password); globals().storageManager.login(nameLength, name, passwordLength, password); END_SECAPI @@ -639,7 +812,61 @@ SecKeychainLogout() { BEGIN_SECAPI + secdebug("kc", "SecKeychainLogout()"); globals().storageManager.logout(); END_SECAPI } + +static CFStringRef copyErrorMessageFromBundle(OSStatus status,CFStringRef tableName); + +// caller MUST release the string, since it is gotten with "CFCopyLocalizedStringFromTableInBundle" +// intended use of reserved param is to pass in CFStringRef with name of the Table for lookup +// Will look by default in "SecErrorMessages.strings" in the resources of Security.framework. + + +CFStringRef SecCopyErrorMessageString(OSStatus status, void *reserved) +{ + BEGIN_SECAPI + + return copyErrorMessageFromBundle(status,CFSTR("SecErrorMessages")); + + END_SECAPI1(NULL) +} + +CFStringRef copyErrorMessageFromBundle(OSStatus status,CFStringRef tableName) +{ + CFStringRef errorString = nil; + CFStringRef keyString = nil; + CFURLRef bundleURL = NULL; + CFBundleRef secBundle = NULL; + + // Make a CFURLRef from the CFString representation of the bundleÕs path. + bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, + CFSTR("/System/Library/Frameworks/Security.framework/"),kCFURLPOSIXPathStyle,true); // Resources/ + if (!bundleURL) + goto xit; + + // Make a bundle instance using the URLRef. + secBundle = CFBundleCreate(kCFAllocatorDefault,bundleURL); + if (!secBundle) + goto xit; + + // Convert status to Int32 string representation, e.g. "-25924" + keyString = CFStringCreateWithFormat (kCFAllocatorDefault,NULL,CFSTR("%d"),status); + if (!keyString) + goto xit; + + errorString = CFCopyLocalizedStringFromTableInBundle(keyString,tableName,secBundle,NULL); + +xit: + if (bundleURL) + CFRelease(bundleURL); + if (secBundle) + CFRelease(secBundle); + if (keyString) + CFRelease(keyString); + + return errorString; +} + diff --git a/Keychain/SecKeychain.h b/Keychain/SecKeychain.h index cb1d26ce..3edd1dba 100644 --- a/Keychain/SecKeychain.h +++ b/Keychain/SecKeychain.h @@ -27,7 +27,6 @@ #include #include - #if defined(__cplusplus) extern "C" { #endif @@ -48,6 +47,7 @@ enum #define SEC_KEYCHAIN_SETTINGS_VERS1 1 + /*! @typedef SecKeychainSettings @abstract Contains keychain settings. @@ -78,17 +78,28 @@ typedef FourCharCode SecAuthenticationType; @constant kSecAuthenticationTypeMSN Specifies Microsoft Network default authentication. @constant kSecAuthenticationTypeDPA Specifies Distributed Password authentication. @constant kSecAuthenticationTypeRPA Specifies Remote Password authentication. + @constant kSecAuthenticationTypeHTTPBasic Specifies HTTP Basic authentication. @constant kSecAuthenticationTypeHTTPDigest Specifies HTTP Digest Access authentication. + @constant kSecAuthenticationTypeHTMLForm Specifies HTML form based authentication. @constant kSecAuthenticationTypeDefault Specifies the default authentication type. */ +#ifdef __LITTLE_ENDIAN__ +#define AUTH_TYPE_FIX_(x) \ + ((x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x & 0xff) << 24) +#else +#define AUTH_TYPE_FIX_(x) (x) +#endif + enum { - kSecAuthenticationTypeNTLM = 'ntlm', - kSecAuthenticationTypeMSN = 'msna', - kSecAuthenticationTypeDPA = 'dpaa', - kSecAuthenticationTypeRPA = 'rpaa', - kSecAuthenticationTypeHTTPDigest = 'httd', - kSecAuthenticationTypeDefault = 'dflt' + kSecAuthenticationTypeNTLM = AUTH_TYPE_FIX_ ('ntlm'), + kSecAuthenticationTypeMSN = AUTH_TYPE_FIX_ ('msna'), + kSecAuthenticationTypeDPA = AUTH_TYPE_FIX_ ('dpaa'), + kSecAuthenticationTypeRPA = AUTH_TYPE_FIX_ ('rpaa'), + kSecAuthenticationTypeHTTPBasic = AUTH_TYPE_FIX_ ('http'), + kSecAuthenticationTypeHTTPDigest = AUTH_TYPE_FIX_ ('httd'), + kSecAuthenticationTypeHTMLForm = AUTH_TYPE_FIX_ ('form'), + kSecAuthenticationTypeDefault = AUTH_TYPE_FIX_ ('dflt') }; /*! @@ -101,7 +112,7 @@ typedef FourCharCode SecProtocolType; @enum ProtocolTypeConstants @abstract Defines the protocol type associated with an AppleShare or Internet password. @constant kSecProtocolTypeFTP Indicates FTP. - @constant kSecProtocolTypeFTPAccount Indicates FTP Account. + @constant kSecProtocolTypeFTPAccount Indicates FTP Account (client side), usage deprecated. @constant kSecProtocolTypeHTTP Indicates HTTP. @constant kSecProtocolTypeIRC Indicates IRC. @constant kSecProtocolTypeNNTP Indicates NNTP. @@ -111,26 +122,60 @@ typedef FourCharCode SecProtocolType; @constant kSecProtocolTypeIMAP Indicates IMAP. @constant kSecProtocolTypeLDAP Indicates LDAP. @constant kSecProtocolTypeAppleTalk Indicates AFP over AppleTalk. - @constant kSecProtocolTypeAFP Indicates AFP. + @constant kSecProtocolTypeAFP Indicates AFP over TCP. @constant kSecProtocolTypeTelnet Indicates Telnet. @constant kSecProtocolTypeSSH Indicates SSH. + @constant kSecProtocolTypeFTPS Indicates FTPS (FTP over TLS/SSL). + @constant kSecProtocolTypeHTTPS Indicates HTTPS (HTTP over TLS/SSL). + @constant kSecProtocolTypeHTTPProxy Indicates HTTP proxy. + @constant kSecProtocolTypeHTTPSProxy Indicates HTTPS proxy. + @constant kSecProtocolTypeFTPProxy Indicates FTP proxy. + @constant kSecProtocolTypeSMB Indicates SMB. + @constant kSecProtocolTypeRTSP Indicates RTSP. + @constant kSecProtocolTypeRTSPProxy Indicates RTSP proxy. + @constant kSecProtocolTypeDAAP Indicates DAAP. + @constant kSecProtocolTypeEPPC Indicates EPPC (Remote Apple Events). + @constant kSecProtocolTypeIPP Indicates IPP. + @constant kSecProtocolTypeNNTPS Indicates NNTPS (NNTP over TLS/SSL). + @constant kSecProtocolTypeLDAPS Indicates LDAPS (LDAP over TLS/SSL). + @constant kSecProtocolTypeTelnetS Indicates Telnet over TLS/SSL. + @constant kSecProtocolTypeIMAPS Indicates IMAPS (IMAP4 over TLS/SSL). + @constant kSecProtocolTypeIRCS Indicates IRCS (IRC over TLS/SSL). + @constant kSecProtocolTypePOP3S Indicates POP3S (POP3 over TLS/SSL). */ enum { - kSecProtocolTypeFTP = 'ftp ', - kSecProtocolTypeFTPAccount = 'ftpa', - kSecProtocolTypeHTTP = 'http', - kSecProtocolTypeIRC = 'irc ', - kSecProtocolTypeNNTP = 'nntp', - kSecProtocolTypePOP3 = 'pop3', - kSecProtocolTypeSMTP = 'smtp', - kSecProtocolTypeSOCKS = 'sox ', - kSecProtocolTypeIMAP = 'imap', - kSecProtocolTypeLDAP = 'ldap', - kSecProtocolTypeAppleTalk = 'atlk', - kSecProtocolTypeAFP = 'afp ', - kSecProtocolTypeTelnet = 'teln', - kSecProtocolTypeSSH = 'ssh ' + kSecProtocolTypeFTP = 'ftp ', + kSecProtocolTypeFTPAccount = 'ftpa', + kSecProtocolTypeHTTP = 'http', + kSecProtocolTypeIRC = 'irc ', + kSecProtocolTypeNNTP = 'nntp', + kSecProtocolTypePOP3 = 'pop3', + kSecProtocolTypeSMTP = 'smtp', + kSecProtocolTypeSOCKS = 'sox ', + kSecProtocolTypeIMAP = 'imap', + kSecProtocolTypeLDAP = 'ldap', + kSecProtocolTypeAppleTalk = 'atlk', + kSecProtocolTypeAFP = 'afp ', + kSecProtocolTypeTelnet = 'teln', + kSecProtocolTypeSSH = 'ssh ', + kSecProtocolTypeFTPS = 'ftps', + kSecProtocolTypeHTTPS = 'htps', + kSecProtocolTypeHTTPProxy = 'htpx', + kSecProtocolTypeHTTPSProxy = 'htsx', + kSecProtocolTypeFTPProxy = 'ftpx', + kSecProtocolTypeSMB = 'smb ', + kSecProtocolTypeRTSP = 'rtsp', + kSecProtocolTypeRTSPProxy = 'rtsx', + kSecProtocolTypeDAAP = 'daap', + kSecProtocolTypeEPPC = 'eppc', + kSecProtocolTypeIPP = 'ipp ', + kSecProtocolTypeNNTPS = 'ntps', + kSecProtocolTypeLDAPS = 'ldps', + kSecProtocolTypeTelnetS = 'tels', + kSecProtocolTypeIMAPS = 'imps', + kSecProtocolTypeIRCS = 'ircs', + kSecProtocolTypePOP3S = 'pops' }; /*! @@ -234,7 +279,9 @@ OSStatus SecKeychainGetVersion(UInt32 *returnVers); #pragma mark ÑÑÑÑ Keychain Management ÑÑÑÑ /*! @function SecKeychainOpen - @abstract Opens a keychain. + @abstract Create a SecKeychainRef for a keychain at pathName. This keychain might + not currently exist, use SecKeychainGetStatus if you want to confirm the existence + of this keychain. @param pathName The POSIX path to a keychain. @param keychain On return, a pointer to the keychain reference. The memory that keychain occupies must be released by calling CFRelease when finished with it. @result A result code. See "Security Error Codes" (SecBase.h). In addition, paramErr (-50) may be returned if the keychain parameter is invalid (NULL). @@ -242,7 +289,7 @@ OSStatus SecKeychainGetVersion(UInt32 *returnVers); OSStatus SecKeychainOpen(const char *pathName, SecKeychainRef *keychain); /*! - @function SecKeychainCreateNew + @function SecKeychainCreate @abstract Creates a new keychain. @param pathName The POSIX path to a keychain file. @param passwordLength An unsigned 32-bit integer representing the length of the password buffer. @@ -256,11 +303,11 @@ OSStatus SecKeychainCreate(const char *pathName, UInt32 passwordLength, const vo /*! @function SecKeychainDelete - @abstract Deletes a keychain from the default searchlist, and removes the keychain itself if it is a file. - @param keychain A pointer to a keychain reference. - @result A result code. See "Security Error Codes" (SecBase.h). In addition, paramErr (-50) may be returned if the keychain parameter is invalid (NULL). + @abstract Removes one or more keychains from the current keychain searchlist, and deletes the keychain storage (if the keychains are file-based). + @param keychainOrArray A single keychain reference or a reference to an array of keychains to delete. + @result A result code. See "Security Error Codes" (SecBase.h). In addition, errSecInvalidKeychain (-25295) may be returned if the keychain parameter is invalid (NULL). */ -OSStatus SecKeychainDelete(SecKeychainRef keychain); +OSStatus SecKeychainDelete(SecKeychainRef keychainOrArray); /*! @function SecKeychainSetSettings @@ -334,11 +381,31 @@ OSStatus SecKeychainCopySearchList(CFArrayRef *searchList); /*! @function SecKeychainSetSearchList @abstract Specifies the list of keychains to use in a keychain search list. - @param searchList The list of keychains to use in a search list when the SecKeychainCopySearchList function is called. + @param searchList The list of keychains to use in a search list when the SecKeychainCopySearchList function is called. An empty array clears the search list. @result A result code. See "Security Error Codes" (SecBase.h). In addition, paramErr (-50) may be returned if the keychain list is not specified (NULL). */ OSStatus SecKeychainSetSearchList(CFArrayRef searchList); + +/* + * New versions of {Copy,Get}{SearchList,Default} that address multiple preference domains. + * These calls subsume the old forms with domain == kPreferenceDomainUser. + */ +typedef enum { + kSecPreferencesDomainUser, // user domain + kSecPreferencesDomainSystem, // system (daemon) domain + kSecPreferencesDomainCommon, // preferences to be merged to everyone + kSecPreferencesDomainAlternate // alternate user +} SecPreferencesDomain; + +OSStatus SecKeychainCopyDomainDefault(SecPreferencesDomain domain, SecKeychainRef *keychain); +OSStatus SecKeychainSetDomainDefault(SecPreferencesDomain domain, SecKeychainRef keychain); +OSStatus SecKeychainCopyDomainSearchList(SecPreferencesDomain domain, CFArrayRef *searchList); +OSStatus SecKeychainSetDomainSearchList(SecPreferencesDomain domain, CFArrayRef searchList); +OSStatus SecKeychainSetPreferenceDomain(SecPreferencesDomain domain); +OSStatus SecKeychainGetPreferenceDomain(SecPreferencesDomain *domain); + + /*! @function SecKeychainGetStatus @abstract Retrieves status information for the specified keychain. @@ -363,7 +430,7 @@ OSStatus SecKeychainGetPath(SecKeychainRef keychain, UInt32 *ioPathLength, char @function SecKeychainAttributeInfoForItemID @abstract Obtains tags for all possible attributes for a given item class. @param keychain A keychain reference. - @param itemID The relation identifier of the item tags. + @param itemID The relation identifier of the item tags (an itemID is a CSSM_DB_RECORDTYPE defined in cssmtype.h). @param info On return, a pointer to the keychain attribute information. User should call the SecKeychainFreeAttributeInfo function to release the structure when done with it. @result A result code. See "Security Error Codes" (SecBase.h). In addition, paramErr (-50) may be returned if not enough valid parameters were supplied (NULL). @discussion Warning, this call returns more attributes than are support by the old style Keychain API and passing them into older calls will yield an invalid attribute error. The recommended call to retrieve the attribute values is the SecKeychainItemCopyAttributesAndData function. @@ -418,82 +485,79 @@ OSStatus SecKeychainRemoveCallback(SecKeychainCallback callbackFunction); #pragma mark ÑÑÑÑ High Level Keychain Manager Calls ÑÑÑÑ /*! @function SecKeychainAddInternetPassword - @abstract Adds an internet password as a keychain item to the specified keychain. - @param keychain A reference to keychain in which to store an internet password. - @param serverNameLength The length of the buffer pointed to by server name. - @param serverName A pointer to a string containing the server name. - @param securityDomainLength The length of the buffer pointed to by security domain. - @param securityDomain A pointer to a string containing the security domain. This parameter is optional, as not all protocols will require it. - @param accountNameLength The length of the buffer pointed to by account name. - @param accountName A pointer to a string containing the account name. + @abstract Adds an Internet password to the specified keychain. + @param keychain A reference to a keychain in which to store an Internet password. Pass NULL to specify the user's default keychain. + @param serverNameLength The length of the buffer pointed to by serverName. + @param serverName A pointer to a string containing the server name associated with this password. + @param securityDomainLength The length of the buffer pointed to by securityDomain. + @param securityDomain A pointer to a string containing the security domain associated with this password, or NULL if there is no relevant security domain. + @param accountNameLength The length of the buffer pointed to by accountName. + @param accountName A pointer to a string containing the account name associated with this password. @param pathLength The length of the buffer pointed to by path. - @param path A pointer to a string containing the path. - @param port The TCP/IP port number. + @param path A pointer to a string containing the path associated with this password, or NULL if there is no relevant path string. + @param port The TCP/IP port number. If no specific port number is associated with this item, pass 0. @param protocol The protocol associated with this password. See SecProtocolType for a description of possible values. - @param authenticationType The authentication scheme used. See SecAuthenticationType for a description of possible values. Pass the constant kSecAuthenticationTypeDefault, to specify the default authentication scheme. + @param authenticationType The authentication scheme used. See SecAuthenticationType for a description of possible values. Pass the constant kSecAuthenticationTypeDefault to specify the default authentication scheme. @param passwordLength The length of the buffer pointed to by passwordData. - @param passwordData A pointer to a buffer which will hold the returned password data. Before calling SecKeychainAddInternetPassword, allocate enough memory for the buffer to hold the data you want to store. - @param itemRef On return, a pointer to the new keychain item. + @param passwordData A pointer to a buffer containing the password data to be stored in the keychain. + @param itemRef On return, a reference to the new keychain item. @result A result code. See "Security Error Codes" (SecBase.h). - @discussion The SecKeychainAddInternetPassword function adds a new internet server password to the default keychain. Required parameters to identify the password are serverName and accountName (you cannot pass NULL for both parameters). In addition, some protocols may require an optional securityDomain when authentication is requested. SecKeychainAddInternetPassword optionally returns a reference to the newly added item. + @discussion The SecKeychainAddInternetPassword function adds a new Internet server password to the specified keychain. Required parameters to identify the password are serverName and accountName (you cannot pass NULL for both parameters). In addition, some protocols may require an optional securityDomain when authentication is requested. SecKeychainAddInternetPassword optionally returns a reference to the newly added item. */ OSStatus SecKeychainAddInternetPassword(SecKeychainRef keychain, UInt32 serverNameLength, const char *serverName, UInt32 securityDomainLength, const char *securityDomain, UInt32 accountNameLength, const char *accountName, UInt32 pathLength, const char *path, UInt16 port, SecProtocolType protocol, SecAuthenticationType authenticationType, UInt32 passwordLength, const void *passwordData, SecKeychainItemRef *itemRef); /*! @function SecKeychainFindInternetPassword - @abstract Finds an internet password based on the attributes passed. - @param keychainOrArray An reference to an array of keychains to search, a single keychain or NULL to search the user's default keychain search list. - @param serverNameLength The length of the buffer pointed to by server name. + @abstract Finds an Internet password based on the attributes passed. + @param keychainOrArray A reference to an array of keychains to search, a single keychain, or NULL to search the user's default keychain search list. + @param serverNameLength The length of the buffer pointed to by serverName. @param serverName A pointer to a string containing the server name. - @param securityDomainLength The length of the buffer pointed to by security domain. + @param securityDomainLength The length of the buffer pointed to by securityDomain. @param securityDomain A pointer to a string containing the security domain. This parameter is optional, as not all protocols will require it. - @param accountNameLength The length of the buffer pointed to by account name. + @param accountNameLength The length of the buffer pointed to by accountName. @param accountName A pointer to a string containing the account name. @param pathLength The length of the buffer pointed to by path. @param path A pointer to a string containing the path. - @param port The TCP/IP port number. + @param port The TCP/IP port number. Pass 0 to ignore the port number. @param protocol The protocol associated with this password. See SecProtocolType for a description of possible values. - @param authenticationType The authentication scheme used. See SecAuthenticationType for a description of possible values. Pass the constant kSecAuthenticationTypeDefault, to specify the default authentication scheme. - @param passwordLength The length of the buffer pointed to by passwordData. - @param passwordData A pointer to a buffer which will hold the returned password data. Before calling SecKeychainFindInternetPassword, allocate enough memory for the buffer to hold the data you want to store. - @param itemRef The item reference of the internet password. + @param authenticationType The authentication scheme used. See SecAuthenticationType for a description of possible values. Pass the constant kSecAuthenticationTypeDefault to specify the default authentication scheme. + @param passwordLength On return, the length of the buffer pointed to by passwordData. + @param passwordData On return, a pointer to a data buffer containing the password. Your application must call SecKeychainItemFreeContent(NULL, passwordData) to release this data buffer when it is no longer needed. Pass NULL if you are not interested in retrieving the password data at this time, but simply want to find the item reference. + @param itemRef On return, a reference to the keychain item which was found. @result A result code. See "Security Error Codes" (SecBase.h). - @discussion The SecKeychainFindInternetPassword function finds the first internet password item which matches the attributes you provide. The buffer specified in the passwordData parameter must be large enough to hold the password data, otherwise SecKeychainFindInternetPassword returns the result code errSecBufferTooSmall. In this case, your application must allocate a new buffer of sufficient size before calling SecKeychainFindInternetPassword again. SecKeychainFindInternetPassword optionally returns a reference to the found item. - + @discussion The SecKeychainFindInternetPassword function finds the first Internet password item which matches the attributes you provide. Most attributes are optional; you should pass only as many as you need to narrow the search sufficiently for your application's intended use. SecKeychainFindInternetPassword optionally returns a reference to the found item. */ OSStatus SecKeychainFindInternetPassword(CFTypeRef keychainOrArray, UInt32 serverNameLength, const char *serverName, UInt32 securityDomainLength, const char *securityDomain, UInt32 accountNameLength, const char *accountName, UInt32 pathLength, const char *path, UInt16 port, SecProtocolType protocol, SecAuthenticationType authenticationType, UInt32 *passwordLength, void **passwordData, SecKeychainItemRef *itemRef); /*! @function SecKeychainAddGenericPassword @abstract Adds a generic password to the specified keychain. - @param keychain A reference to keychain in which to store a generic password. - @param serviceNameLength The length of the buffer pointed to by service name. - @param serviceName A pointer to a string containing the service name. - @param accountNameLength The length of the buffer pointed to by account name. - @param accountName A pointer to a string containing the account name. + @param keychain A reference to the keychain in which to store a generic password. Pass NULL to specify the user's default keychain. + @param serviceNameLength The length of the buffer pointed to by serviceName. + @param serviceName A pointer to a string containing the service name associated with this password. + @param accountNameLength The length of the buffer pointed to by accountName. + @param accountName A pointer to a string containing the account name associated with this password. @param passwordLength The length of the buffer pointed to by passwordData. - @param passwordData A pointer to a buffer which will hold the returned password data. Before calling SecKeychainAddInternetPassword, allocate enough memory for the buffer to hold the data you want to store. - @param itemRef On return, a pointer to the new keychain item reference. - @result A result code. See "Security Error Codes" (SecBase.h). + @param passwordData A pointer to a buffer containing the password data to be stored in the keychain. + @param itemRef On return, a reference to the new keychain item. + @result A result code. See "Security Error Codes" (SecBase.h). @discussion The SecKeychainAddGenericPassword function adds a new generic password to the default keychain. Required parameters to identify the password are serviceName and accountName, which are application-defined strings. SecKeychainAddGenericPassword optionally returns a reference to the newly added item. - - You can use SecKeychainAddGenericPassword to add passwords for accounts other than Internet or Appleshare. For example, you might add passwords for your database or scheduling programs. */ OSStatus SecKeychainAddGenericPassword(SecKeychainRef keychain, UInt32 serviceNameLength, const char *serviceName, UInt32 accountNameLength, const char *accountName, UInt32 passwordLength, const void *passwordData, SecKeychainItemRef *itemRef); /*! @function SecKeychainFindGenericPassword @abstract Find a generic password based on the attributes passed. - @param keychainOrArray An reference to an array of keychains to search, a single keychain or NULL to search the user's default keychain search list. - @param serviceNameLength The length of the buffer pointed to by service name. + @param keychainOrArray A reference to an array of keychains to search, a single keychain, or NULL to search the user's default keychain search list. + @param serviceNameLength The length of the buffer pointed to by serviceName. @param serviceName A pointer to a string containing the service name. - @param accountNameLength The length of the buffer pointed to by account name. + @param accountNameLength The length of the buffer pointed to by accountName. @param accountName A pointer to a string containing the account name. - @param passwordLength The length of the buffer pointed to by passwordData. - @param passwordData A pointer to a buffer which will hold the returned password data. Before calling SecKeychainAddInternetPassword, allocate enough memory for the buffer to hold the data you want to store. - @param itemRef On return, a pointer to the new keychain item reference. + @param passwordLength On return, the length of the buffer pointed to by passwordData. + @param passwordData On return, a pointer to a data buffer containing the password. Your application must call SecKeychainItemFreeContent(NULL, passwordData) to release this data buffer when it is no longer needed. Pass NULL if you are not interested in retrieving the password data at this time, but simply want to find the item reference. + @param itemRef On return, a reference to the keychain item which was found. @result A result code. See "Security Error Codes" (SecBase.h). - @discussion The SecKeychainFindGenericPassword function finds the first generic password item which matches the attributes you provide. The buffer specified in the passwordData parameter must be large enough to hold the password data, otherwise SecKeychainFindGenericPassword returns the result code errSecBufferTooSmall. In this case, your application must allocate a new buffer of sufficient size before calling SecKeychainFindGenericPassword again. SecKeychainFindGenericPassword optionally returns a reference to the found item. + @discussion The SecKeychainFindGenericPassword function finds the first generic password item which matches the attributes you provide. Most attributes are optional; you should pass only as many as you need to narrow the search sufficiently for your application's intended use. SecKeychainFindGenericPassword optionally returns a reference to the found item. */ OSStatus SecKeychainFindGenericPassword(CFTypeRef keychainOrArray, UInt32 serviceNameLength, const char *serviceName, UInt32 accountNameLength, const char *accountName, UInt32 *passwordLength, void **passwordData, SecKeychainItemRef *itemRef); diff --git a/Keychain/SecKeychainAPI.cpp b/Keychain/SecKeychainAPI.cpp index 50378ea2..aad191ef 100644 --- a/Keychain/SecKeychainAPI.cpp +++ b/Keychain/SecKeychainAPI.cpp @@ -29,7 +29,18 @@ NOTE: Any function with Create or Copy in the name returns an object that must be released. */ +#if !defined(SECURITY_USE_LEGACY_HEADER) +#define SECURITY_USE_LEGACY_HEADER +#define UNDEFINE_SECURITY_USE_LEGACY_HEADER +#endif + #include + +#ifdef UNDEFINE_SECURITY_USE_LEGACY_HEADER +#undef SECURITY_USE_LEGACY_HEADER +#undef UNDEFINE_SECURITY_USE_LEGACY_HEADER +#endif + #include #include @@ -71,3 +82,4 @@ OSStatus SecKeychainCopySearchNextItem(SecKeychainSearchRef searchRef, SecKeycha return SecKeychainSearchCopyNext(searchRef, itemRef); } + diff --git a/Keychain/SecKeychainAPI.h b/Keychain/SecKeychainAPI.h index 8442041f..5070fbc9 100644 --- a/Keychain/SecKeychainAPI.h +++ b/Keychain/SecKeychainAPI.h @@ -27,7 +27,9 @@ #ifndef _SECURITY_SECKEYCHAINAPI_H_ #define _SECURITY_SECKEYCHAINAPI_H_ +#if !defined(SECURITY_USE_LEGACY_HEADER) #warning including obsolete header file SecKeychainAPI.h Use #include instead +#endif #include #include diff --git a/Keychain/SecKeychainAPIPriv.h b/Keychain/SecKeychainAPIPriv.h index de264485..4328555e 100644 --- a/Keychain/SecKeychainAPIPriv.h +++ b/Keychain/SecKeychainAPIPriv.h @@ -36,6 +36,56 @@ enum kSecProtectedDataItemAttr = 'prot', /* Item's data is protected (encrypted) (Boolean) */ }; +/* Temporary: CRL attributes */ +enum +{ + kSecCrlTypeItemAttr = 'crtp', + kSecCrlEncodingItemAttr = 'cren', + kSecThisUpdateItemAttr = 'crtu', + kSecNextUpdateItemAttr = 'crnu', + kSecUriItemAttr = 'curi', // URI from which it came + kSecCrlNumberItemAttr = 'crnm', + kSecDeltaCrlNumberItemAttr = 'dlcr' +}; + +/* + Note: the comments that appear after these errors are used to create SecErrorMessages.strings. + The comments must not be multi-line, and should be in a form meaningful to an end user. If + a different or additional comment is needed, it can be put in the header doc format, or on a + line that does not start with errZZZ. +*/ + +/* Definitions for miscellaneous OS errors that can be returned (with appropriate error strings) */ +enum +{ + errSecMisc_dskFulErr = -34, /* The disk is full. */ + errSecMisc_nsvErr = -35, /* The disk couldn't be found. It may have been ejected. */ + errSecMisc_bdNamErr = -37, /* Tried to open a file whose name contains an illegal character. */ + errSecMisc_fnfErr = -43, /* The file could not be found. */ + errSecMisc_wPrErr = -44, /* The disk is write-protected. */ + errSecMisc_fLckdErr = -45, /* The file is locked. */ + errSecMisc_vLckdErr = -46, /* The volume is locked. */ + errSecMisc_fBsyErr = -47, /* The file is busy. It may be in use by another application. */ + errSecMisc_dupFNErr = -48, /* A file with the same name already exists. */ + errSecMisc_opWrErr = -49, /* The file is already open with write permission. */ + errSecMisc_volOffLinErr = -53, /* The volume is no longer available. It may have been ejected. */ + errSecMisc_permErr = -54, /* The file could not be opened. It may be in use by another application. */ + errSecMisc_extFSErr = -58, /* This volume does not appear to be compatible. */ + errSecMisc_wrPermErr = -61, /* Could not write to the file. It may have been opened with insufficient access privileges. */ + errSecMisc_offLinErr = -65, /* The storage device is no longer available. It may have been ejected. */ + errSecMisc_memFullErr = -108, /* There was not enough memory to perform the operation. */ + errSecMisc_dirNFErr = -120, /* The directory could not be found. */ + errSecMisc_volGoneErr = -124, /* The server volume is no longer available. It may have been disconnected. */ + errSecMisc_resNotFound = -192, /* A required resource could not be found. */ + errSecMisc_resFNotFound = -193, /* A required resource is missing or damaged. */ + errSecMisc_icNoURLErr = -673, /* The specified location (URL) is an unknown type, or does not contain enough information. */ + errSecMisc_icConfigNotFoundErr = -674, /* A helper application to open the specified URL could not be found. */ + errSecMisc_cantGetFlavorErr = -1854, /* The location (URL) of this item is missing or improperly formatted. */ + errSecMisc_afpAccessDenied = -5000, /* Access to this item was denied. */ + errSecMisc_afpUserNotAuth = -5023, /* Authentication failed. The password for this server may have changed since the item was added to the keychain. */ + errSecMisc_afpPwdPolicyErr = -5046 /* This AppleShare IP server is configured to not allow users to save passwords for automatic login. Contact the server administrator for more information. */ +}; + UInt16 SecKeychainListGetCount(void); @@ -53,6 +103,10 @@ OSStatus SecKeychainLogin(UInt32 nameLength, void* name, UInt32 passwordLength, OSStatus SecKeychainLogout(); +OSStatus SecKeychainResetLogin(UInt32 passwordLength, const void* password, Boolean resetSearchList); + +CFStringRef SecCopyErrorMessageString(OSStatus status, void *reserved); + #if defined(__cplusplus) } #endif diff --git a/Keychain/SecKeychainAddIToolsPassword.c b/Keychain/SecKeychainAddIToolsPassword.c new file mode 100644 index 00000000..523b649a --- /dev/null +++ b/Keychain/SecKeychainAddIToolsPassword.c @@ -0,0 +1,195 @@ +/* + * SecKeychainAddIToolsPassword.c + * + * Created by jhurley on Thu Jun 19 2003. + * Copyright (c) 2003 Apple. All rights reserved. + * + * Based on Keychain item access control example + * Created by Perry Kiehtreiber on Wed Jun 19 2002 + * Modified by Ken McLeod, Mon Apr 21 2003 -- added "always allow" ACL support + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static CFArrayRef CopyTrustedAppListFromBundle(); +static SecAccessRef createAccess(CFStringRef accessLabel,const int allowAny); + +OSStatus SecKeychainAddIToolsPassword(SecKeychainRef keychain, UInt32 accountNameLength, const char *accountName, + UInt32 passwordLength, const void *passwordData, SecKeychainItemRef *itemRef) +{ + OSStatus err; + SecKeychainItemRef item = nil; + const char *serviceUTF8 = "iTools"; + CFStringRef itemLabel = CFSTR("iTools"); + const int allowAny = 0; + + // create initial access control settings for the item + SecAccessRef access = createAccess(itemLabel, allowAny); + + // below is the lower-layer equivalent to the SecKeychainAddGenericPassword() function; + // it does the same thing (except specify the access controls) + + // set up attribute vector (each attribute consists of {tag, length, pointer}) + SecKeychainAttribute attrs[] = + { + { kSecLabelItemAttr, strlen(serviceUTF8), (char *)serviceUTF8 }, // use the service string as the name of this item for display purposes + { kSecAccountItemAttr, accountNameLength, (char *)accountName }, + { kSecServiceItemAttr, strlen(serviceUTF8), (char *)serviceUTF8 } + }; + SecKeychainAttributeList attributes = { sizeof(attrs) / sizeof(attrs[0]), attrs }; + + err = SecKeychainItemCreateFromContent(kSecGenericPasswordItemClass, + &attributes, + passwordLength, + (const char *)passwordData, + keychain, + access, + &item); + + if (access) + CFRelease(access); + if (item) + CFRelease(item); + return noErr; +} + +SecAccessRef createAccess(CFStringRef accessLabel,const int allowAny) +{ + OSStatus err; + SecAccessRef access=nil; + CFMutableArrayRef trustedApplications=nil; + + if (!allowAny) // use default access ("confirm access") + { + // make an exception list of applications you want to trust, + // which are allowed to access the item without requiring user confirmation + SecTrustedApplicationRef myself=NULL, someOther=NULL; + CFArrayRef trustedAppListFromBundle=NULL; + + trustedApplications=CFArrayCreateMutable(kCFAllocatorDefault,0,&kCFTypeArrayCallBacks); + err = SecTrustedApplicationCreateFromPath(NULL, &myself); + if (!err) + CFArrayAppendValue(trustedApplications,myself); + + trustedAppListFromBundle=CopyTrustedAppListFromBundle(); + if (trustedAppListFromBundle) + { + int ix,top; + char buffer[MAXPATHLEN]; + top = CFArrayGetCount(trustedAppListFromBundle); + for (ix=0;ix +#include +#include +#include + #include "SecBridge.h" #include "KCExceptions.h" #include "Access.h" @@ -32,14 +36,15 @@ RefPointer aclBearer(CFTypeRef itemRef) { // well, exactly what kind of something are you? CFTypeID id = CFGetTypeID(itemRef); - if (id == gTypes().item.typeId) { + if (id == gTypes().ItemImpl.typeID) { // keychain item. If it's in a protected group, return the group key - if (SSGroup group = gTypes().item.required(SecKeychainItemRef(itemRef))->group()) + if (SSGroup group = ItemImpl::required(SecKeychainItemRef(itemRef))->group()) return &*group; - } else if (id == gTypes().keyItem.typeId) { - // key item - //@@@ not hooked up yet - } else if (id == gTypes().keychain.typeId) { + } else if (id == gTypes().KeyItem.typeID) { + // key item, return the key itself. + if (CssmClient::Key key = KeyItem::required(SecKeyRef(itemRef))->key()) + return &*key; + } else if (id == gTypes().KeychainImpl.typeID) { // keychain (this yields the database ACL) //@@@ not hooked up yet } @@ -53,7 +58,8 @@ SecKeychainItemGetTypeID(void) { BEGIN_SECAPI - return gTypes().item.typeId; + secdebug("kcitem", "SecKeychainItemGetTypeID()"); + return gTypes().ItemImpl.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -65,13 +71,30 @@ SecKeychainItemCreateFromContent(SecItemClass itemClass, SecKeychainAttributeLis SecAccessRef initialAccess, SecKeychainItemRef *itemRef) { BEGIN_SECAPI + secdebug("kcitem", "SecKeychainItemCreateFromContent(%lu, %p, %lu, %p, %p, %p)", + itemClass, attrList, length, data, keychainRef, initialAccess); KCThrowParamErrIf_(length!=0 && data==NULL); Item item(itemClass, attrList, length, data); if (initialAccess) - item->setAccess(gTypes().access.required(initialAccess)); - Keychain::optional(keychainRef)->add(item); + item->setAccess(Access::required(initialAccess)); + + Keychain keychain = nil; + try + { + keychain = Keychain::optional(keychainRef); + if ( !keychain->exists() ) + { + MacOSError::throwMe(errSecNoSuchKeychain); // Might be deleted or not available at this time. + } + } + catch(...) + { + keychain = globals().storageManager.defaultKeychainUI(item); + } + + keychain->add(item); if (itemRef) - *itemRef = gTypes().item.handle(*item); + *itemRef = item->handle(); END_SECAPI } @@ -80,7 +103,8 @@ OSStatus SecKeychainItemModifyContent(SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, UInt32 length, const void *data) { BEGIN_SECAPI - Item item = gTypes().item.required(itemRef); + secdebug("kcitem", "SecKeychainItemModifyContent(%p, %p, %lu, %p)", itemRef, attrList, length, data); + Item item = ItemImpl::required(itemRef); item->modifyContent(attrList, length, data); END_SECAPI } @@ -90,7 +114,9 @@ OSStatus SecKeychainItemCopyContent(SecKeychainItemRef itemRef, SecItemClass *itemClass, SecKeychainAttributeList *attrList, UInt32 *length, void **outData) { BEGIN_SECAPI - Item item = gTypes().item.required(itemRef); + secdebug("kcitem", "SecKeychainItemCopyContent(%p, %p, %p, %p, %p)", + itemRef, itemClass, attrList, length, outData); + Item item = ItemImpl::required(itemRef); item->getContent(itemClass, attrList, length, outData); END_SECAPI } @@ -100,6 +126,7 @@ OSStatus SecKeychainItemFreeContent(SecKeychainAttributeList *attrList, void *data) { BEGIN_SECAPI + secdebug("kcitem", "SecKeychainItemFreeContent(%p, %p)", attrList, data); ItemImpl::freeContent(attrList, data); END_SECAPI } @@ -109,7 +136,8 @@ OSStatus SecKeychainItemModifyAttributesAndData(SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, UInt32 length, const void *data) { BEGIN_SECAPI - Item item = gTypes().item.required(itemRef); + secdebug("kcitem", "SecKeychainItemModifyAttributesAndData(%p, %p, %lu, %p)", itemRef, attrList, length, data); + Item item = ItemImpl::required(itemRef); item->modifyAttributesAndData(attrList, length, data); END_SECAPI } @@ -119,7 +147,8 @@ OSStatus SecKeychainItemCopyAttributesAndData(SecKeychainItemRef itemRef, SecKeychainAttributeInfo *info, SecItemClass *itemClass, SecKeychainAttributeList **attrList, UInt32 *length, void **outData) { BEGIN_SECAPI - Item item = gTypes().item.required(itemRef); + secdebug("kcitem", "SecKeychainItemCopyAttributesAndData(%p, %p, %p, %p, %p, %p)", itemRef, info, itemClass, attrList, length, outData); + Item item = ItemImpl::required(itemRef); item->getAttributesAndData(info, itemClass, attrList, length, outData); END_SECAPI } @@ -129,6 +158,7 @@ OSStatus SecKeychainItemFreeAttributesAndData(SecKeychainAttributeList *attrList, void *data) { BEGIN_SECAPI + secdebug("kcitem", "SecKeychainItemFreeAttributesAndData(%p, %p)", attrList, data); ItemImpl::freeAttributesAndData(attrList, data); END_SECAPI } @@ -138,7 +168,8 @@ OSStatus SecKeychainItemDelete(SecKeychainItemRef itemRef) { BEGIN_SECAPI - Item item = gTypes().item.required( itemRef ); + secdebug("kcitem", "SecKeychainItemFreeAttributesAndData(%p)", itemRef); + Item item = ItemImpl::required( itemRef ); Keychain keychain = item->keychain(); KCThrowIf_( !keychain, errSecInvalidItemRef ); @@ -151,7 +182,8 @@ OSStatus SecKeychainItemCopyKeychain(SecKeychainItemRef itemRef, SecKeychainRef* keychainRef) { BEGIN_SECAPI - Required(keychainRef) = gTypes().keychain.handle(*gTypes().item.required(itemRef)->keychain()); + secdebug("kcitem", "SecKeychainItemCopyKeychain(%p, %p)", itemRef, keychainRef); + Required(keychainRef) = ItemImpl::required(itemRef)->keychain()->handle(); END_SECAPI } @@ -161,18 +193,22 @@ SecKeychainItemCreateCopy(SecKeychainItemRef itemRef, SecKeychainRef destKeychai SecAccessRef initialAccess, SecKeychainItemRef *itemCopy) { BEGIN_SECAPI - Item copy = gTypes().item.required(itemRef)->copyTo(Keychain::optional(destKeychainRef)); + secdebug("kcitem", "SecKeychainItemCreateCopy(%p, %p, %p, %p)", + itemRef, destKeychainRef, initialAccess, itemCopy); + + Item copy = ItemImpl::required(itemRef)->copyTo(Keychain::optional(destKeychainRef), Access::optional(initialAccess)); if (itemCopy) - *itemCopy = gTypes().item.handle(*copy); + *itemCopy = copy->handle(); END_SECAPI } OSStatus -SecKeychainItemGetUniqueRecordID(SecKeychainItemRef keyItemRef, CSSM_DB_UNIQUE_RECORD* uniqueRecordID) +SecKeychainItemGetUniqueRecordID(SecKeychainItemRef itemRef, const CSSM_DB_UNIQUE_RECORD **uniqueRecordID) { BEGIN_SECAPI - uniqueRecordID = gTypes().item.required(keyItemRef)->dbUniqueRecord(); + secdebug("kcitem", "SecKeychainItemGetUniqueRecordID(%p, %p)", itemRef, uniqueRecordID); + Required(uniqueRecordID) = ItemImpl::required(itemRef)->dbUniqueRecord(); END_SECAPI } @@ -181,7 +217,8 @@ OSStatus SecKeychainItemGetDLDBHandle(SecKeychainItemRef itemRef, CSSM_DL_DB_HANDLE* dldbHandle) { BEGIN_SECAPI - *dldbHandle = gTypes().item.required(itemRef)->keychain()->database()->handle(); + secdebug("kcitem", "SecKeychainItemGetDLDBHandle(%p, %p)", itemRef, dldbHandle); + *dldbHandle = ItemImpl::required(itemRef)->keychain()->database()->handle(); END_SECAPI } @@ -190,9 +227,10 @@ OSStatus SecAccessCreateFromObject(CFTypeRef sourceRef, SecAccessRef *accessRef) { BEGIN_SECAPI + secdebug("kcitem", "SecAccessCreateFromObject(%p, %p)", sourceRef, accessRef); Required(accessRef); // preflight - RefPointer access = new Access(*aclBearer(sourceRef)); - *accessRef = gTypes().access.handle(*access); + SecPointer access = new Access(*aclBearer(sourceRef)); + *accessRef = access->handle(); END_SECAPI } @@ -202,7 +240,8 @@ OSStatus SecAccessCreateFromObject(CFTypeRef sourceRef, OSStatus SecAccessModifyObject(SecAccessRef accessRef, CFTypeRef sourceRef) { BEGIN_SECAPI - gTypes().access.required(accessRef)->setAccess(*aclBearer(sourceRef), true); + secdebug("kcitem", "SecAccessModifyObject(%p, %p)", accessRef, sourceRef); + Access::required(accessRef)->setAccess(*aclBearer(sourceRef), true); END_SECAPI } @@ -211,9 +250,10 @@ SecKeychainItemCopyAccess(SecKeychainItemRef itemRef, SecAccessRef* accessRef) { BEGIN_SECAPI + secdebug("kcitem", "SecKeychainItemCopyAccess(%p, %p)", itemRef, accessRef); Required(accessRef); // preflight - RefPointer access = new Access(*aclBearer(reinterpret_cast(itemRef))); - *accessRef = gTypes().access.handle(*access); + SecPointer access = new Access(*aclBearer(reinterpret_cast(itemRef))); + *accessRef = access->handle(); END_SECAPI } @@ -224,7 +264,8 @@ SecKeychainItemSetAccess(SecKeychainItemRef itemRef, SecAccessRef accessRef) { BEGIN_SECAPI - gTypes().access.required(accessRef)->setAccess(*aclBearer(reinterpret_cast(itemRef)), true); + secdebug("kcitem", "SecKeychainItemSetAccess(%p, %p)", itemRef, accessRef); + Access::required(accessRef)->setAccess(*aclBearer(reinterpret_cast(itemRef)), true); END_SECAPI } diff --git a/Keychain/SecKeychainItem.h b/Keychain/SecKeychainItem.h index a10fb44b..f6f0612a 100644 --- a/Keychain/SecKeychainItem.h +++ b/Keychain/SecKeychainItem.h @@ -139,6 +139,7 @@ typedef UInt8 SecAFPServerSignature[16]; */ typedef UInt8 SecPublicKeyHash[20]; +#pragma mark ÑÑÑÑ Keychain Item Management ÑÑÑÑ /*! @function SecKeychainItemGetTypeID @abstract Returns the type identifier of SecKeychainItem instances. @@ -149,7 +150,7 @@ CFTypeID SecKeychainItemGetTypeID(void); /*! @function SecKeychainItemModifyAttributesAndData @abstract Updates an existing keychain item after changing its attributes or data. - @param itemRef A reference of the keychain item to modify. + @param itemRef A reference to the keychain item to modify. @param attrList The list of attributes to set. @param length The length of the buffer pointed to by data. @param data Pointer to a buffer containing the data to store. @@ -158,7 +159,6 @@ CFTypeID SecKeychainItemGetTypeID(void); */ OSStatus SecKeychainItemModifyAttributesAndData(SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, UInt32 length, const void *data); -#pragma mark ÑÑÑÑ Keychain Item Management ÑÑÑÑ /*! @function SecKeychainItemCreateFromContent @abstract Creates a new keychain item from the supplied parameters. @@ -177,7 +177,7 @@ OSStatus SecKeychainItemCreateFromContent(SecItemClass itemClass, SecKeychainAtt /*! @function SecKeychainItemModifyContent - @abstract Updates an existing keychain item after changing its attributes or data. + @abstract Updates an existing keychain item after changing its attributes or data. This call should only be used in conjunction with SecKeychainItemCopyContent(). @param itemRef A reference to the keychain item to modify. @param attrList The list of attributes to set. @param length The length of the buffer pointed to by data. @@ -188,12 +188,12 @@ OSStatus SecKeychainItemModifyContent(SecKeychainItemRef itemRef, const SecKeych /*! @function SecKeychainItemCopyContent - @abstract Copies the data and/or attributes stored in the given keychain item. + @abstract Copies the data and/or attributes stored in the given keychain item. It is recommended that you use SecKeychainItemCopyAttributesAndData(). You must call SecKeychainItemFreeContent when you no longer need the attributes and data. If you want to modify the attributes returned here, use SecKeychainModifyContent(). @param itemRef A reference to the keychain item to modify. @param itemClass The item's class. You should pass NULL if it is not required. - @param attrList The list of attributes to get in this item on input, on output the attributes are filled in. You must call SecKeychainItemFreeContent when you no longer need the attributes and data. + @param attrList The list of attributes to get in this item on input, on output the attributes are filled in. You must call SecKeychainItemFreeContent when you no longer need the attributes. @param length On return, the length of the buffer pointed to by outData. - @param outData On return, a pointer to a buffer containing the data in this item. You must call SecKeychainItemFreeContent when you no longer need the attributes and data. + @param outData On return, a pointer to a buffer containing the data in this item. You must call SecKeychainItemFreeContent when you no longer need the data. @result A result code. See "Security Error Codes" (SecBase.h). In addition, paramErr (-50) may be returned if not enough valid parameters are supplied. */ OSStatus SecKeychainItemCopyContent(SecKeychainItemRef itemRef, SecItemClass *itemClass, SecKeychainAttributeList *attrList, UInt32 *length, void **outData); @@ -208,13 +208,13 @@ OSStatus SecKeychainItemFreeContent(SecKeychainAttributeList *attrList, void *da /*! @function SecKeychainItemCopyAttributesAndData - @abstract Copies the data and/or attributes stored in the given keychain item. You must call SecKeychainItemFreeAttributesAndData() when you no longer need the attributes and data. - @param itemRef A reference of the keychain item to modify. + @abstract Copies the data and/or attributes stored in the given keychain item. You must call SecKeychainItemFreeAttributesAndData() when you no longer need the attributes and data. If you want to modify the attributes returned here, use SecKeychainModifyAttributesAndData(). + @param itemRef A reference to the keychain item to copy. @param info List of tags of attributes to retrieve. @param itemClass The item's class. You should pass NULL if not required. - @param attrList The list of attributes to get in this item on input, on output the attributes are filled in. You must call SecKeychainItemFreeAttributesAndData() when you no longer need the attributes and data. + @param attrList on output, an attribute list with the attributes specified by info. You must call SecKeychainItemFreeAttributesAndData() when you no longer need this list. @param length on output the actual length of the data. - @param outData Pointer to a buffer containing the data in this item. Pass NULL if not required. You must call SecKeychainItemFreeAttributesAndData() when you no longer need the attributes and data. + @param outData Pointer to a buffer containing the data in this item. Pass NULL if not required. You must call SecKeychainItemFreeAttributesAndData() when you no longer need the data. @result A result code. See "Security Error Codes" (SecBase.h). In addition, paramErr (-50) may be returned if not enough valid parameters are supplied. */ OSStatus SecKeychainItemCopyAttributesAndData(SecKeychainItemRef itemRef, SecKeychainAttributeInfo *info, SecItemClass *itemClass, SecKeychainAttributeList **attrList, UInt32 *length, void **outData); @@ -261,10 +261,10 @@ OSStatus SecKeychainItemCreateCopy(SecKeychainItemRef itemRef, SecKeychainRef de #pragma mark ÑÑÑÑ CSSM Bridge Functions ÑÑÑÑ /*! - @function SecKeychainItemGetDLDBHandle - @abstract Returns the CSSM_DL_DB_HANDLE for a given key reference. - @param keyItemRef A keychain item key reference. The key item must be of class type kSecAppleKeyItemClass. - @param dldbHandle keychainRef On return, a CSSM_DL_DB_HANDLE for the given key. The handle is valid until the keychain reference is released. + @function SecKeychainItemGetDLDBHandle + @abstract Returns the CSSM_DL_DB_HANDLE for a given keychain item reference. + @param keyItemRef A keychain item reference. + @param dldbHandle On return, a CSSM_DL_DB_HANDLE for the keychain database containing the given item. The handle is valid until the keychain reference is released. @result A result code. See "Security Error Codes" (SecBase.h). */ OSStatus SecKeychainItemGetDLDBHandle(SecKeychainItemRef keyItemRef, CSSM_DL_DB_HANDLE *dldbHandle); @@ -276,7 +276,7 @@ OSStatus SecKeychainItemGetDLDBHandle(SecKeychainItemRef keyItemRef, CSSM_DL_DB_ @param uniqueRecordID On return, a pointer to a CSSM_DB_UNIQUE_RECORD structure for the given item. The unique record is valid until the item reference is released. @result A result code. See "Security Error Codes" (SecBase.h). */ -OSStatus SecKeychainItemGetUniqueRecordID(SecKeychainItemRef itemRef, CSSM_DB_UNIQUE_RECORD *uniqueRecordID); +OSStatus SecKeychainItemGetUniqueRecordID(SecKeychainItemRef itemRef, const CSSM_DB_UNIQUE_RECORD **uniqueRecordID); #pragma mark ÑÑÑÑ Keychain Item Access Management ÑÑÑÑ /*! diff --git a/Keychain/SecKeychainSearch.cpp b/Keychain/SecKeychainSearch.cpp index 16111cc8..3e36bdd6 100644 --- a/Keychain/SecKeychainSearch.cpp +++ b/Keychain/SecKeychainSearch.cpp @@ -16,6 +16,8 @@ */ #include +#include +#include #include "SecBridge.h" @@ -24,7 +26,8 @@ SecKeychainSearchGetTypeID(void) { BEGIN_SECAPI - return gTypes().cursor.typeId; + secdebug("kcsearch", "SecKeychainSearchGetTypeID()"); + return gTypes().KCCursorImpl.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -35,12 +38,14 @@ SecKeychainSearchCreateFromAttributes(CFTypeRef keychainOrArray, SecItemClass it { BEGIN_SECAPI + secdebug("kcsearch", "SecKeychainSearchCreateFromAttributes(%p, %lu, %p, %p)", + keychainOrArray, itemClass, attrList, searchRef); Required(searchRef); // Make sure that searchRef is an invalid SearchRef StorageManager::KeychainList keychains; globals().storageManager.optionalSearchList(keychainOrArray, keychains); KCCursor cursor(keychains, itemClass, attrList); - *searchRef = gTypes().cursor.handle(*cursor); + *searchRef = cursor->handle(); END_SECAPI } @@ -51,12 +56,13 @@ SecKeychainSearchCopyNext(SecKeychainSearchRef searchRef, SecKeychainItemRef *it { BEGIN_SECAPI + secdebug("kcsearch", "SecKeychainSearchCopyNext(%p, %p)", searchRef, itemRef); RequiredParam(itemRef); Item item; - if (!gTypes().cursor.required(searchRef)->next(item)) + if (!KCCursorImpl::required(searchRef)->next(item)) return errSecItemNotFound; - *itemRef=gTypes().item.handle(*item); + *itemRef=item->handle(); END_SECAPI } diff --git a/Keychain/SecPolicy.cpp b/Keychain/SecPolicy.cpp index aad3d9c9..e4e6627a 100644 --- a/Keychain/SecPolicy.cpp +++ b/Keychain/SecPolicy.cpp @@ -16,15 +16,11 @@ */ #include +#include +#include #include "SecBridge.h" -static inline Policy *Required(SecPolicyRef policyRef) -{ - return gTypes().policy.required(policyRef); -} - - // // CF boilerplate // @@ -32,7 +28,7 @@ CFTypeID SecPolicyGetTypeID(void) { BEGIN_SECAPI - return gTypes().policy.typeId; + return gTypes().Policy.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -44,7 +40,7 @@ OSStatus SecPolicyGetOID(SecPolicyRef policyRef, CSSM_OID* oid) { BEGIN_SECAPI - Required(oid) = Required(policyRef)->oid(); + Required(oid) = Policy::required(policyRef)->oid(); END_SECAPI } @@ -53,7 +49,15 @@ OSStatus SecPolicyGetValue(SecPolicyRef policyRef, CSSM_DATA* value) { BEGIN_SECAPI - Required(value) = Required(policyRef)->value(); + Required(value) = Policy::required(policyRef)->value(); + END_SECAPI +} + +OSStatus +SecPolicySetValue(SecPolicyRef policyRef, const CSSM_DATA *value) +{ + BEGIN_SECAPI + Policy::required(policyRef)->value() = value ? (*value) : CssmData(); END_SECAPI } @@ -62,6 +66,6 @@ OSStatus SecPolicyGetTPHandle(SecPolicyRef policyRef, CSSM_TP_HANDLE* tpHandle) { BEGIN_SECAPI - Required(tpHandle) = Required(policyRef)->tp()->handle(); + Required(tpHandle) = Policy::required(policyRef)->tp()->handle(); END_SECAPI } diff --git a/Keychain/SecPolicyPriv.h b/Keychain/SecPolicyPriv.h new file mode 100644 index 00000000..c8682dc2 --- /dev/null +++ b/Keychain/SecPolicyPriv.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/*! + @header SecPolicy + The functions provided in SecPolicy implement a representation of a particular trust policy. +*/ + +#ifndef _SECURITY_SECPOLICYPRIV_H_ +#define _SECURITY_SECPOLICYPRIV_H_ + +#include + + +#if defined(__cplusplus) +extern "C" { +#endif + + +/*! + @function SecPolicySetValue + @abstract Sets a policy's value. + @param policyRef A policy reference. + @param value The value to be set into the policy object, replacing any previous value. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecPolicySetValue(SecPolicyRef policyRef, const CSSM_DATA *value); + + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SECURITY_SECPOLICYPRIV_H_ */ diff --git a/Keychain/SecPolicySearch.cpp b/Keychain/SecPolicySearch.cpp index 982c5893..6fbf8613 100644 --- a/Keychain/SecPolicySearch.cpp +++ b/Keychain/SecPolicySearch.cpp @@ -16,6 +16,8 @@ */ #include +#include +#include #include "SecBridge.h" @@ -26,7 +28,7 @@ SecPolicySearchGetTypeID(void) { BEGIN_SECAPI - return gTypes().policyCursor.typeId; + return gTypes().PolicyCursor.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -41,8 +43,8 @@ SecPolicySearchCreate( { BEGIN_SECAPI Required(searchRef); // preflight - RefPointer cursor(new PolicyCursor(oid, value)); - *searchRef = gTypes().policyCursor.handle(*cursor); + SecPointer cursor(new PolicyCursor(oid, value)); + *searchRef = cursor->handle(); END_SECAPI } @@ -55,9 +57,9 @@ SecPolicySearchCopyNext( BEGIN_SECAPI RequiredParam(policyRef); - RefPointer policy; - if (!gTypes().policyCursor.required(searchRef)->next(policy)) + SecPointer policy; + if (!PolicyCursor::required(searchRef)->next(policy)) return errSecPolicyNotFound; - *policyRef = gTypes().policy.handle(*policy); + *policyRef = policy->handle(); END_SECAPI } diff --git a/Keychain/SecRuntime.cpp b/Keychain/SecRuntime.cpp index ec87f19f..a8c01a92 100644 --- a/Keychain/SecRuntime.cpp +++ b/Keychain/SecRuntime.cpp @@ -20,121 +20,93 @@ // #include -#include + +#ifndef NDEBUG +#include +#endif using namespace KeychainCore; // // SecCFObject // -SecCFObject::~SecCFObject() +SecCFObject * +SecCFObject::optional(CFTypeRef cfTypeRef) throw() { + if (!cfTypeRef) + return NULL; + + return const_cast(reinterpret_cast(reinterpret_cast(cfTypeRef) + kAlignedRuntimeSize)); } -bool -SecCFObject::equal(SecCFObject &other) +SecCFObject * +SecCFObject::required(CFTypeRef cfTypeRef, OSStatus error) { - return this == &other; + SecCFObject *object = optional(cfTypeRef); + if (!object) + MacOSError::throwMe(error); + + return object; } -CFHashCode -SecCFObject::hash() +void * +SecCFObject::allocate(size_t size, CFTypeID typeID) throw(std::bad_alloc) { - return CFHashCode(this); -} + void *p = const_cast(_CFRuntimeCreateInstance(NULL, typeID, + size + kAlignedRuntimeSize - sizeof(CFRuntimeBase), NULL)); + if (p == NULL) + throw std::bad_alloc(); + reinterpret_cast(p)->isNew = true; -// -// SecCFType -// -SecCFType::SecCFType(SecCFObject *obj) : - mObject(obj) -{ -} + void *q = reinterpret_cast(reinterpret_cast(p) + kAlignedRuntimeSize); -SecCFType::~SecCFType() -{ - mObject = NULL; + secdebug("sec", "SecCFObject allocated %p of type %lu", q, typeID); + + return q; } -// -// CFClassBase -// -CFClassBase::CFClassBase(const char *name) +void +SecCFObject::operator delete(void *object) throw() { - // initialize the CFRuntimeClass structure - version = 0; - className = name; - init = NULL; - copy = NULL; - finalize = finalizeType; - equal = equalType; - hash = hashType; - copyFormattingDesc = NULL; - copyDebugDesc = NULL; - - // register - typeId = _CFRuntimeRegisterClass(this); - assert(typeId != _kCFRuntimeNotATypeID); + secdebug("sec", "SecCFObject operator delete %p", object); + CFTypeRef cfType = reinterpret_cast(reinterpret_cast(object) - kAlignedRuntimeSize); + CFRelease(cfType); } - -void -CFClassBase::finalizeType(CFTypeRef cf) + +SecCFObject::~SecCFObject() throw() { - const SecCFType *type = reinterpret_cast(cf); - StLock _(gTypes().mapLock); - gTypes().map.erase(type->mObject.get()); - type->~SecCFType(); + secdebug("sec", "SecCFObject::~SecCFObject %p", this); } - -Boolean -CFClassBase::equalType(CFTypeRef cf1, CFTypeRef cf2) + +bool +SecCFObject::equal(SecCFObject &other) { - const SecCFType *t1 = reinterpret_cast(cf1); - const SecCFType *t2 = reinterpret_cast(cf2); - // CF checks for pointer equality and ensures type equality already - return t1->mObject->equal(*t2->mObject); + return this == &other; } CFHashCode -CFClassBase::hashType(CFTypeRef cf) +SecCFObject::hash() { - return reinterpret_cast(cf)->mObject->hash(); + return CFHashCode(this); } -const SecCFType * -CFClassBase::makeNew(SecCFObject *obj) +CFStringRef +SecCFObject::copyFormattingDesc(CFDictionaryRef dict) { - void *p = const_cast(_CFRuntimeCreateInstance(NULL, typeId, - sizeof(SecCFType) - sizeof(CFRuntimeBase), NULL)); - new (p) SecCFType(obj); - return reinterpret_cast(p); + return NULL; } -const SecCFType * -CFClassBase::handle(SecCFObject *obj) +CFStringRef +SecCFObject::copyDebugDesc() { - SecCFTypes::Map &map = gTypes().map; - StLock _(gTypes().mapLock); - SecCFTypes::Map::const_iterator it = map.find(obj); - if (it == map.end()) - { - const SecCFType *p = makeNew(obj); - map[obj] = p; - return p; - } - else - { - CFRetain(it->second); - return it->second; - } + return NULL; } -SecCFObject * -CFClassBase::required(const SecCFType *type, OSStatus errorCode) +CFTypeRef +SecCFObject::handle(bool retain) throw() { - if (!type) - MacOSError::throwMe(errorCode); - - return type->mObject.get(); + CFTypeRef cfType = *this; + if (retain && !isNew()) CFRetain(cfType); + return cfType; } diff --git a/Keychain/SecRuntime.h b/Keychain/SecRuntime.h index 529e4da1..cec4b74a 100644 --- a/Keychain/SecRuntime.h +++ b/Keychain/SecRuntime.h @@ -22,8 +22,9 @@ #define _SECURITY_SECRUNTIME_H_ #include -#include +#include +#include namespace Security { @@ -31,80 +32,158 @@ namespace Security namespace KeychainCore { -class SecCFObject : public RefCount +#define SECCFFUNCTIONS(OBJTYPE, APIPTR, ERRCODE) \ +\ +void *operator new(size_t size) throw(std::bad_alloc) \ +{ return SecCFObject::allocate(size, gTypes().OBJTYPE.typeID); } \ +\ +operator APIPTR() const \ +{ return (APIPTR)(this->operator CFTypeRef()); } \ +\ +APIPTR handle(bool retain = true) \ +{ return (APIPTR)SecCFObject::handle(retain); } \ +\ +static OBJTYPE *required(APIPTR ptr) \ +{ return static_cast(SecCFObject::required(ptr, ERRCODE)); } \ +\ +static OBJTYPE *optional(APIPTR ptr) \ +{ return static_cast(SecCFObject::optional(ptr)); } + +#define SECALIGNUP(SIZE, ALIGNMENT) (((SIZE - 1) & ~(ALIGNMENT - 1)) + ALIGNMENT) + +struct SecRuntimeBase: CFRuntimeBase { + bool isNew; +}; + +class SecCFObject +{ +private: + void *operator new(size_t) throw(std::bad_alloc); + + // Align up to a multiple of 16 bytes + static const size_t kAlignedRuntimeSize = SECALIGNUP(sizeof(SecRuntimeBase), 16); + public: - virtual ~SecCFObject(); + // For use by SecPointer only. Returns true once the first time it's called after the object has been created. + bool isNew() + { + SecRuntimeBase *base = reinterpret_cast(reinterpret_cast(this) - kAlignedRuntimeSize); + bool isNew = base->isNew; + base->isNew = false; + return isNew; + } + + static SecCFObject *optional(CFTypeRef) throw(); + static SecCFObject *required(CFTypeRef, OSStatus error); + static void *allocate(size_t size, CFTypeID typeID) throw(std::bad_alloc); + + virtual ~SecCFObject() throw(); + + void operator delete(void *object) throw(); + operator CFTypeRef() const throw() + { + return reinterpret_cast(reinterpret_cast(this) - kAlignedRuntimeSize); + } + + // This bumps up the retainCount by 1, by calling CFRetain(), iff retain is true + CFTypeRef handle(bool retain = true) throw(); + virtual bool equal(SecCFObject &other); virtual CFHashCode hash(); + virtual CFStringRef copyFormattingDesc(CFDictionaryRef dict); + virtual CFStringRef copyDebugDesc(); }; - -class SecCFType : public CFRuntimeBase +// +// A pointer type for SecCFObjects. +// T must be derived from SecCFObject. +// +class SecPointerBase { public: - SecCFType(SecCFObject *obj); - ~SecCFType(); + SecPointerBase() : ptr(NULL) + {} + SecPointerBase(const SecPointerBase& p) + { + if (p.ptr) + CFRetain(p.ptr->operator CFTypeRef()); + ptr = p.ptr; + } + SecPointerBase(SecCFObject *p) + { + if (p && !p->isNew()) + CFRetain(p->operator CFTypeRef()); + ptr = p; + } + ~SecPointerBase() + { + if (ptr) + CFRelease(ptr->operator CFTypeRef()); + } + SecPointerBase& operator = (const SecPointerBase& p) + { + if (p.ptr) + CFRetain(p.ptr->operator CFTypeRef()); + if (ptr) + CFRelease(ptr->operator CFTypeRef()); + ptr = p.ptr; + return *this; + } - RefPointer mObject; +protected: + void assign(SecCFObject * p) + { + if (p && !p->isNew()) + CFRetain(p->operator CFTypeRef()); + if (ptr) + CFRelease(ptr->operator CFTypeRef()); + ptr = p; + } + + SecCFObject *ptr; }; - -class CFClassBase : protected CFRuntimeClass +template +class SecPointer : public SecPointerBase { -protected: - CFClassBase(const char *name); - - const SecCFType *makeNew(SecCFObject *obj); - const SecCFType *handle(SecCFObject *obj); - SecCFObject *required(const SecCFType *type, OSStatus errorCode); - -private: - static void finalizeType(CFTypeRef cf); - static Boolean equalType(CFTypeRef cf1, CFTypeRef cf2); - static CFHashCode hashType(CFTypeRef cf); - public: - CFTypeID typeId; + SecPointer() : SecPointerBase() {} + SecPointer(const SecPointer& p) : SecPointerBase(p) {} + SecPointer(T *p): SecPointerBase(p) {} + SecPointer &operator =(T *p) { this->assign(p); return *this; } + + // dereference operations + T* get () const { return static_cast(ptr); } // mimic auto_ptr + operator T * () const { return static_cast(ptr); } + T * operator -> () const { return static_cast(ptr); } + T & operator * () const { return *static_cast(ptr); } }; +template +bool operator <(const SecPointer &r1, const SecPointer &r2) +{ + T *p1 = r1.get(), *p2 = r2.get(); + return p1 && p2 ? *p1 < *p2 : p1 < p2; +} -template -class CFClass : public CFClassBase +template +bool operator ==(const SecPointer &r1, const SecPointer &r2) { -public: - CFClass(const char *name) : CFClassBase(name) {} - - APITypePtr handle(Object &obj) - { - return APITypePtr(CFClassBase::handle(&obj)); - } - - Object *required(APITypePtr type) - { - Object *object = dynamic_cast(CFClassBase::required - (reinterpret_cast(type), ErrorCode)); - if (!object) - MacOSError::throwMe(ErrorCode); - - return object; - } - - // CF generator functions - APITypePtr operator () (Object *obj) - { return handle(*obj); } - - APITypePtr operator () (const RefPointer &obj) - { return handle(*obj); } - - Object * operator () (APITypePtr ref) - { return required(ref); } -}; + T *p1 = r1.get(), *p2 = r2.get(); + return p1 && p2 ? *p1 == *p2 : p1 == p2; +} + +template +bool operator !=(const SecPointer &r1, const SecPointer &r2) +{ + T *p1 = r1.get(), *p2 = r2.get(); + return p1 && p2 ? *p1 != *p2 : p1 != p2; +} } // end namespace KeychainCore } // end namespace Security - #endif // !_SECURITY_SECRUNTIME_H_ diff --git a/Keychain/SecTrust.cpp b/Keychain/SecTrust.cpp index 0133ea0e..61d60f94 100644 --- a/Keychain/SecTrust.cpp +++ b/Keychain/SecTrust.cpp @@ -16,17 +16,10 @@ */ #include +#include #include - #include "SecBridge.h" - -static inline Trust *Required(SecTrustRef trustRef) -{ - return gTypes().trust.required(trustRef); -} - - // // CF boilerplate // @@ -34,7 +27,7 @@ CFTypeID SecTrustGetTypeID(void) { BEGIN_SECAPI - return gTypes().trust.typeId; + return gTypes().Trust.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -49,20 +42,28 @@ OSStatus SecTrustCreateWithCertificates( SecTrustRef *trustRef) { BEGIN_SECAPI - Required(trustRef); // preflight - RefPointer trust(new Trust(certificates, policies)); - *trustRef = gTypes().trust.handle(*trust); + Required(trustRef); + *trustRef = (new Trust(certificates, policies))->handle(); END_SECAPI } +OSStatus +SecTrustSetPolicies(SecTrustRef trustRef, CFTypeRef policies) +{ + BEGIN_SECAPI + Trust::required(trustRef)->policies(policies); + END_SECAPI +} + + OSStatus SecTrustSetParameters( SecTrustRef trustRef, CSSM_TP_ACTION action, CFDataRef actionData) { BEGIN_SECAPI - Trust *trust = gTypes().trust.required(trustRef); + Trust *trust = Trust::required(trustRef); trust->action(action); trust->actionData(actionData); END_SECAPI @@ -72,7 +73,7 @@ OSStatus SecTrustSetParameters( OSStatus SecTrustSetAnchorCertificates(SecTrustRef trust, CFArrayRef anchorCertificates) { BEGIN_SECAPI - Required(trust)->anchors(anchorCertificates); + Trust::required(trust)->anchors(anchorCertificates); END_SECAPI } @@ -82,7 +83,7 @@ OSStatus SecTrustSetKeychains(SecTrustRef trust, CFTypeRef keychainOrArray) BEGIN_SECAPI StorageManager::KeychainList keychains; globals().storageManager.optionalSearchList(keychainOrArray, keychains); - Required(trust)->searchLibs() = keychains; + Trust::required(trust)->searchLibs() = keychains; END_SECAPI } @@ -90,7 +91,7 @@ OSStatus SecTrustSetKeychains(SecTrustRef trust, CFTypeRef keychainOrArray) OSStatus SecTrustSetVerifyDate(SecTrustRef trust, CFDateRef verifyDate) { BEGIN_SECAPI - Required(trust)->time(verifyDate); + Trust::required(trust)->time(verifyDate); END_SECAPI } @@ -98,7 +99,7 @@ OSStatus SecTrustSetVerifyDate(SecTrustRef trust, CFDateRef verifyDate) OSStatus SecTrustEvaluate(SecTrustRef trustRef, SecTrustResultType *resultP) { BEGIN_SECAPI - Trust *trust = Required(trustRef); + Trust *trust = Trust::required(trustRef); trust->evaluate(); if (resultP) *resultP = trust->result(); @@ -115,7 +116,7 @@ OSStatus SecTrustGetResult( CFArrayRef *certChain, CSSM_TP_APPLE_EVIDENCE_INFO **statusChain) { BEGIN_SECAPI - Trust *trust = Required(trustRef); + Trust *trust = Trust::required(trustRef); if (result) *result = trust->result(); if (certChain && statusChain) @@ -130,14 +131,28 @@ OSStatus SecTrustGetResult( OSStatus SecTrustGetCssmResult(SecTrustRef trust, CSSM_TP_VERIFY_CONTEXT_RESULT_PTR *result) { BEGIN_SECAPI - Required(result) = Required(trust)->cssmResult(); + Required(result) = Trust::required(trust)->cssmResult(); + END_SECAPI +} + +// +// Retrieve CSSM_LEVEL TP return code +// +OSStatus SecTrustGetCssmResultCode(SecTrustRef trustRef, OSStatus *result) +{ + BEGIN_SECAPI + Trust *trust = Trust::required(trustRef); + if (trust->result() == kSecTrustResultInvalid) + return paramErr; + else + Required(result) = trust->cssmResultCode(); END_SECAPI } OSStatus SecTrustGetTPHandle(SecTrustRef trust, CSSM_TP_HANDLE *handle) { BEGIN_SECAPI - Required(handle) = Required(trust)->getTPHandle(); + Required(handle) = Trust::required(trust)->getTPHandle(); END_SECAPI } @@ -172,8 +187,8 @@ OSStatus SecTrustGetUserTrust(SecCertificateRef certificate, { BEGIN_SECAPI Required(trustSetting) = Trust::gStore().find( - gTypes().certificate.required(certificate), - gTypes().policy.required(policy)); + Certificate::required(certificate), + Policy::required(policy)); END_SECAPI } @@ -191,8 +206,8 @@ OSStatus SecTrustSetUserTrust(SecCertificateRef certificate, MacOSError::throwMe(errSecInvalidTrustSetting); } Trust::gStore().assign( - gTypes().certificate.required(certificate), - gTypes().policy.required(policy), + Certificate::required(certificate), + Policy::required(policy), trustSetting); END_SECAPI } diff --git a/Keychain/SecTrust.h b/Keychain/SecTrust.h index 72730122..523da7c4 100644 --- a/Keychain/SecTrust.h +++ b/Keychain/SecTrust.h @@ -79,7 +79,8 @@ CFTypeID SecTrustGetTypeID(void); @function SecTrustCreateWithCertificates @abstract Creates a trust based on the given certificates and policies. @param certificates The group of certificates to verify. - @param policies An array of one or more policies. + @param policies An array of one or more policies. You may pass a SecPolicyRef + to represent a single policy. @param trustRef On return, a pointer to the trust management reference. @result A result code. See "Security Error Codes" (SecBase.h). */ diff --git a/Keychain/SecTrustPriv.h b/Keychain/SecTrustPriv.h new file mode 100644 index 00000000..0f1c6e23 --- /dev/null +++ b/Keychain/SecTrustPriv.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/*! + @header SecTrustPriv + Private part of SecTrust.h +*/ + +#ifndef _SECURITY_SECTRUST_PRIV_H_ +#define _SECURITY_SECTRUST_PRIV_H_ + +#include + + +#if defined(__cplusplus) +extern "C" { +#endif + +/*! + @function SecTrustSetPolicies + @abstract Set (replace) set of policies to evaluate + @param trust The SecTrust object to manipulate + @param policies An array of one or more policies. A Single SecPolicyRef may also + be passed, representing an array of one policy. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecTrustSetPolicies(SecTrustRef trust, CFTypeRef policies); + + +/*! + @function SecTrustGetCssmVerifyResult + @abstract Gets the actual CSSM return code from the last attempted SecTrustEvaluate call. + @param trust A reference to a trust. + @param result On return, the CSSM_RETURN produced by the last invocation of the TP. + @result A result code. See "Security Error Codes" (SecBase.h). +*/ +OSStatus SecTrustGetCssmResultCode(SecTrustRef trust, OSStatus *result); + + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SECURITY_SECTRUST_PRIV_H_ */ diff --git a/Keychain/SecTrustedApplication.cpp b/Keychain/SecTrustedApplication.cpp index aa36207b..1ab4cec5 100644 --- a/Keychain/SecTrustedApplication.cpp +++ b/Keychain/SecTrustedApplication.cpp @@ -15,7 +15,9 @@ * specific language governing rights and limitations under the License. */ -#include +#include +#include +#include #include "SecBridge.h" @@ -25,7 +27,7 @@ SecTrustedApplicationGetTypeID(void) { BEGIN_SECAPI - return gTypes().trustedApplication.typeId; + return gTypes().TrustedApplication.typeID; END_SECAPI1(_kCFRuntimeNotATypeID) } @@ -35,9 +37,9 @@ OSStatus SecTrustedApplicationCreateFromPath(const char *path, SecTrustedApplicationRef *appRef) { BEGIN_SECAPI - RefPointer app = + SecPointer app = path ? new TrustedApplication(path) : new TrustedApplication; - Required(appRef) = gTypes().trustedApplication.handle(*app); + Required(appRef) = app->handle(); END_SECAPI } @@ -47,7 +49,7 @@ OSStatus SecTrustedApplicationCopyData(SecTrustedApplicationRef appRef, CFDataRef *dataRef) { BEGIN_SECAPI - const CssmData &data = gTypes().trustedApplication.required(appRef)->data(); + const CssmData &data = TrustedApplication::required(appRef)->data(); Required(dataRef) = CFDataCreate(NULL, (const UInt8 *)data.data(), data.length()); END_SECAPI } @@ -56,7 +58,85 @@ OSStatus SecTrustedApplicationSetData(SecTrustedApplicationRef appRef, CFDataRef dataRef) { BEGIN_SECAPI - gTypes().trustedApplication.required(appRef)->data(cfData(dataRef)); + TrustedApplication::required(appRef)->data(cfData(dataRef)); END_SECAPI } + +OSStatus +SecTrustedApplicationValidateWithPath(SecTrustedApplicationRef appRef, const char *path) +{ + BEGIN_SECAPI + TrustedApplication &app = *TrustedApplication::required(appRef); + if (!app.sameSignature(path ? path : app.path())) + return CSSMERR_CSP_VERIFY_FAILED; + END_SECAPI +} + + +OSStatus +SecTrustedApplicationMakeEquivalent(SecTrustedApplicationRef oldRef, + SecTrustedApplicationRef newRef, UInt32 flags) +{ + BEGIN_SECAPI + if (flags & ~kSecApplicationValidFlags) + return paramErr; + SecurityServer::ClientSession ss(CssmAllocator::standard(), CssmAllocator::standard()); + TrustedApplication *oldApp = TrustedApplication::required(oldRef); + TrustedApplication *newApp = TrustedApplication::required(newRef); + ss.addCodeEquivalence(oldApp->signature(), newApp->signature(), oldApp->path(), + flags & kSecApplicationFlagSystemwide); + END_SECAPI +} + +OSStatus +SecTrustedApplicationRemoveEquivalence(SecTrustedApplicationRef appRef, UInt32 flags) +{ + BEGIN_SECAPI + if (flags & ~kSecApplicationValidFlags) + return paramErr; + SecurityServer::ClientSession ss(CssmAllocator::standard(), CssmAllocator::standard()); + TrustedApplication *app = TrustedApplication::required(appRef); + ss.removeCodeEquivalence(app->signature(), app->path(), + flags & kSecApplicationFlagSystemwide); + END_SECAPI +} + + +/* + * Check to see if an application at a given path is a candidate for + * pre-emptive code equivalency establishment + */ +OSStatus +SecTrustedApplicationIsUpdateCandidate(const char *installroot, const char *path) +{ + BEGIN_SECAPI + + // strip installroot + if (installroot) { + size_t rootlen = strlen(installroot); + if (!strncmp(installroot, path, rootlen)) + path += rootlen - 1; // keep the slash + } + + // look up in database + static ModuleNexus paths; + if (!paths()[path]) + return CSSMERR_DL_RECORD_NOT_FOUND; // whatever + END_SECAPI +} + + +/* + * Point the system at another system root for equivalence use. + * This is for system update installers (only)! + */ +OSStatus +SecTrustedApplicationUseAlternateSystem(const char *systemRoot) +{ + BEGIN_SECAPI + Required(systemRoot); + SecurityServer::ClientSession ss(CssmAllocator::standard(), CssmAllocator::standard()); + ss.setAlternateSystemRoot(systemRoot); + END_SECAPI +} diff --git a/Keychain/SecTrustedApplicationPriv.h b/Keychain/SecTrustedApplicationPriv.h new file mode 100644 index 00000000..945a64a3 --- /dev/null +++ b/Keychain/SecTrustedApplicationPriv.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/*! + @header SecTrustedApplicationPriv + Not (yet?) public functions related to SecTrustedApplicationRef objects +*/ + +#ifndef _SECURITY_SECTRUSTEDAPPLICATIONPRIV_H_ +#define _SECURITY_SECTRUSTEDAPPLICATIONPRIV_H_ + +#include + + +#if defined(__cplusplus) +extern "C" { +#endif + + +/* + * Determine whether the application at path satisfies the trust expressed in appRef. + */ +OSStatus +SecTrustedApplicationValidateWithPath(SecTrustedApplicationRef appRef, const char *path); + + +/* + * Administrative editing of the system's application equivalence database + */ +enum { + kSecApplicationFlagSystemwide = 0x1, + kSecApplicationValidFlags = kSecApplicationFlagSystemwide +}; + +OSStatus +SecTrustedApplicationMakeEquivalent(SecTrustedApplicationRef oldRef, + SecTrustedApplicationRef newRef, UInt32 flags); + +OSStatus +SecTrustedApplicationRemoveEquivalence(SecTrustedApplicationRef appRef, UInt32 flags); + + +/* + * Check to see if an application at a given path is a candidate for + * pre-emptive code equivalency establishment + */ +OSStatus +SecTrustedApplicationIsUpdateCandidate(const char *installroot, const char *path); + + +/* + * Point the system at another system root for equivalence use. + * This is for system update installers (only)! + */ +OSStatus +SecTrustedApplicationUseAlternateSystem(const char *systemRoot); + + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SECURITY_SECTRUSTEDAPPLICATIONPRIV_H_ */ diff --git a/Keychain/Security.h b/Keychain/Security.h index 71710132..38fcbae3 100644 --- a/Keychain/Security.h +++ b/Keychain/Security.h @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -57,6 +58,7 @@ #include #include +#include #include #include diff --git a/Keychain/StorageManager.cpp b/Keychain/StorageManager.cpp index ed3a7875..8a1a72df 100644 --- a/Keychain/StorageManager.cpp +++ b/Keychain/StorageManager.cpp @@ -28,29 +28,54 @@ #include #include +#include +#include #include #include #include #include -#include #include #include #include #include +#include +#include +#include #include "KCCursor.h" #include "Globals.h" -#include "DefaultKeychain.h" using namespace CssmClient; using namespace KeychainCore; +// normal debug calls, which get stubbed out for deployment builds +#define x_debug(str) secdebug("KClogin",(str)) +#define x_debug1(fmt,arg1) secdebug("KClogin",(fmt),(arg1)) +#define x_debug2(fmt,arg1,arg2) secdebug("KClogin",(fmt),(arg1),(arg2)) + +//----------------------------------------------------------------------------------- + StorageManager::StorageManager() : - mSavedList(), - mKeychains(), - mSearchList() + mSavedList(kSecPreferencesDomainUser), + mCommonList(kSecPreferencesDomainCommon), + mDomain(kSecPreferencesDomainUser), + mKeychains() { - _doReload(); + // get session attributes + SessionAttributeBits sessionAttrs; + if (OSStatus err = SessionGetInfo(callerSecuritySession, + NULL, &sessionAttrs)) + CssmError::throwMe(err); + + // If this is the root session, switch to system preferences. + // (In SecurityServer debug mode, you'll get a (fake) root session + // that has graphics access. Ignore that to help testing.) + if ((sessionAttrs & sessionIsRoot) + IFDEBUG( && !(sessionAttrs & sessionHasGraphicAccess))) { + secdebug("storagemgr", "switching to system preferences"); + mDomain = kSecPreferencesDomainSystem; + mSavedList.set(kSecPreferencesDomainSystem); + } } // Create KC if it doesn't exist @@ -64,6 +89,9 @@ StorageManager::keychain(const DLDbIdentifier &dLDbIdentifier) Keychain StorageManager::_keychain(const DLDbIdentifier &dLDbIdentifier) { + if (!dLDbIdentifier) + return Keychain(); + KeychainMap::iterator it = mKeychains.find(dLDbIdentifier); if (it != mKeychains.end()) return it->second; @@ -79,43 +107,111 @@ StorageManager::_keychain(const DLDbIdentifier &dLDbIdentifier) dl->subserviceId(dLDbIdentifier.ssuid().subserviceId()); dl->version(dLDbIdentifier.ssuid().version()); Db db(dl, dLDbIdentifier.dbName()); - Keychain keychain(db); + Keychain keychain(db); // Add the keychain to the cache. - mKeychains.insert(KeychainMap::value_type(dLDbIdentifier, keychain)); + mKeychains.insert(KeychainMap::value_type(dLDbIdentifier, &*keychain)); + return keychain; } +// Called from KeychainImpl's destructor remove it from the map. +void +StorageManager::removeKeychain(const DLDbIdentifier &dLDbIdentifier, KeychainImpl *keychainImpl) +{ + // @@@ Work out locking StLock _(mLock); + KeychainMap::iterator it = mKeychains.find(dLDbIdentifier); + if (it != mKeychains.end() && it->second == keychainImpl) + mKeychains.erase(it); +} + +// if a database is key-unlockable, authenticate it with any matching unlock keys found in the KC list +void StorageManager::setDefaultCredentials(const Db &db) +{ + try { + CssmAutoData index(db->allocator()); + if (!db->getUnlockKeyIndex(index.get())) + return; // no suggested index (probably not a CSPDL) + + TrackingAllocator alloc(CssmAllocator::standard()); + + KCCursor search(createCursor(CSSM_DL_DB_RECORD_SYMMETRIC_KEY, NULL)); + CssmAutoData keyLabel(CssmAllocator::standard()); + keyLabel = StringData("SYSKC**"); + keyLabel.append(index); + static const CSSM_DB_ATTRIBUTE_INFO infoLabel = { + CSSM_DB_ATTRIBUTE_NAME_AS_STRING, + {"Label"}, + CSSM_DB_ATTRIBUTE_FORMAT_BLOB + }; + search->add(CSSM_DB_EQUAL, infoLabel, keyLabel.get()); + + // could run a loop below to catch *all* eligible keys, + // but that's stretching it; and beware CSP scope if you add this... + AutoCredentials cred(alloc); + Item keyItem; + if (search->next(keyItem)) { + CssmClient::Key key = dynamic_cast(*keyItem).key(); + + // create AccessCredentials from that key. Still allow interactive unlock + const CssmKey &masterKey = key; + CSSM_CSP_HANDLE cspHandle = key->csp()->handle(); + cred += TypedList(alloc, CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK, + new(alloc) ListElement(CSSM_WORDID_SYMMETRIC_KEY), + new(alloc) ListElement(CssmData::wrap(cspHandle)), + new(alloc) ListElement(CssmData::wrap(masterKey))); + cred += TypedList(alloc, CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK, + new(alloc) ListElement(CSSM_SAMPLE_TYPE_KEYCHAIN_PROMPT)); + + secdebug("storagemgr", "authenticating %s for default key credentials", db->name()); + db->authenticate(db->accessRequest(), &cred); + } + } catch (...) { + secdebug("storagemgr", "setDefaultCredentials for %s abandoned due to exception", db->name()); + } +} + // Create KC if it doesn't exist, add it to the search list if it exists and is not already on it. Keychain -StorageManager::makeKeychain(const DLDbIdentifier &dLDbIdentifier) +StorageManager::makeKeychain(const DLDbIdentifier &dLDbIdentifier, bool add) { - Keychain keychain(keychain(dLDbIdentifier)); + Keychain keychain; + bool post = false; { StLock _(mLock); - if (find(mSearchList.begin(), mSearchList.end(), keychain) != mSearchList.end()) + keychain = _keychain(dLDbIdentifier); + + if (add) { - // This keychain is already on our search list. - return keychain; + mSavedList.revert(false); + DLDbList searchList = mSavedList.searchList(); + if (find(searchList.begin(), searchList.end(), dLDbIdentifier) != searchList.end()) + return keychain; // Keychain is already in the searchList. + + mCommonList.revert(false); + searchList = mCommonList.searchList(); + if (find(searchList.begin(), searchList.end(), dLDbIdentifier) != searchList.end()) + return keychain; // Keychain is already in the commonList don't add it to the searchList. + + // If the keychain doesn't exist don't bother adding it to the search list yet. + if (!keychain->exists()) + return keychain; + + // The keychain exists and is not in our search list add it to the search + // list and the cache. + mSavedList.revert(true); + mSavedList.add(dLDbIdentifier); + mSavedList.save(); + post = true; } - - // If the keychain doesn't exist don't bother adding it to the search list yet. - if (!keychain->exists()) - return keychain; - - // The keychain exists and is not in our search list add it to the search - // list and the cache. Then inform mMultiDLDb. - mSavedList.revert(true); - mSavedList.add(dLDbIdentifier); - mSavedList.save(); - - // @@@ Will happen again when kSecKeychainListChangedEvent notification is received. - _doReload(); } - // Make sure we are not holding mLock when we post this event. - KCEventNotifier::PostKeychainEvent(kSecKeychainListChangedEvent); + if (post) + { + // Make sure we are not holding mLock when we post this event. + KCEventNotifier::PostKeychainEvent(kSecKeychainListChangedEvent); + } return keychain; } @@ -124,108 +220,178 @@ void StorageManager::created(const Keychain &keychain) // Be notified a Keychain just got created. { DLDbIdentifier dLDbIdentifier = keychain->dLDbIdentifier(); + bool defaultChanged = false; { StLock _(mLock); - // If we don't have a default Keychain yet. Make the newly created keychain the default. - DefaultKeychain &defaultKeychain = globals().defaultKeychain; - if (!defaultKeychain.isSet()) - defaultKeychain.dLDbIdentifier(dLDbIdentifier); - - // Add the keychain to the search list and the cache. Then inform mMultiDLDb. mSavedList.revert(true); + // If we don't have a default Keychain yet. Make the newly created keychain the default. + if (!mSavedList.defaultDLDbIdentifier()) + { + mSavedList.defaultDLDbIdentifier(dLDbIdentifier); + defaultChanged = true; + } + + // Add the keychain to the search list prefs. mSavedList.add(dLDbIdentifier); mSavedList.save(); - - // @@@ Will happen again when kSecKeychainListChangedEvent notification is received. - _doReload(); } - // Make sure we are not holding mLock when we post this event. + // Make sure we are not holding mLock when we post these events. KCEventNotifier::PostKeychainEvent(kSecKeychainListChangedEvent); + + if (defaultChanged) + { + KCEventNotifier::PostKeychainEvent(kSecDefaultChangedEvent, dLDbIdentifier); + } } KCCursor StorageManager::createCursor(SecItemClass itemClass, const SecKeychainAttributeList *attrList) { - StLock _(mLock); - return KCCursor(mSearchList, itemClass, attrList); + KeychainList searchList; + getSearchList(searchList); + return KCCursor(searchList, itemClass, attrList); } KCCursor StorageManager::createCursor(const SecKeychainAttributeList *attrList) { - StLock _(mLock); - return KCCursor(mSearchList, attrList); + KeychainList searchList; + getSearchList(searchList); + return KCCursor(searchList, attrList); } void StorageManager::lockAll() { - // Make a snapshot of all known keychains while holding mLock. - KeychainList keychainList; + SecurityServer::ClientSession ss(CssmAllocator::standard(), CssmAllocator::standard()); + ss.lockAll (false); +} + +Keychain +StorageManager::defaultKeychain() +{ + Keychain theKeychain; + { + StLock _(mLock); + mSavedList.revert(false); + DLDbIdentifier defaultDLDbIdentifier(mSavedList.defaultDLDbIdentifier()); + if (defaultDLDbIdentifier) + { + theKeychain = _keychain(defaultDLDbIdentifier); + } + } + + if (theKeychain /* && theKeychain->exists() */) + return theKeychain; + + MacOSError::throwMe(errSecNoDefaultKeychain); +} + +void +StorageManager::defaultKeychain(const Keychain &keychain) +{ + DLDbIdentifier oldDefaultId; + DLDbIdentifier newDefaultId(keychain->dLDbIdentifier()); { StLock _(mLock); - for (KeychainMap::iterator ix = mKeychains.begin(); ix != mKeychains.end(); ix++) - keychainList.push_back(ix->second); + oldDefaultId = mSavedList.defaultDLDbIdentifier(); + mSavedList.revert(true); + mSavedList.defaultDLDbIdentifier(newDefaultId); + mSavedList.save(); } - // Lock each active keychain after having released mLock since locking keychains - // will send notifications. - for (KeychainList::iterator ix = keychainList.begin(); ix != keychainList.end(); ++ix) + if (!(oldDefaultId == newDefaultId)) { - Keychain keychain = *ix; - if (keychain->isActive()) - keychain->lock(); + // Make sure we are not holding mLock when we post this event. + KCEventNotifier::PostKeychainEvent(kSecDefaultChangedEvent, newDefaultId); } } -void -StorageManager::_doReload() +Keychain +StorageManager::defaultKeychain(SecPreferencesDomain domain) { - KeychainList newList; - newList.reserve(mSavedList.size()); - for (CssmClient::DLDbList::iterator ix = mSavedList.begin(); ix != mSavedList.end(); ++ix) + if (domain == mDomain) + return defaultKeychain(); + else { - Keychain keychain(_keychain(*ix)); - newList.push_back(keychain); + DLDbIdentifier defaultDLDbIdentifier(DLDbListCFPref(domain).defaultDLDbIdentifier()); + if (defaultDLDbIdentifier) + return keychain(defaultDLDbIdentifier); + + MacOSError::throwMe(errSecNoDefaultKeychain); } - mSearchList.swap(newList); } void -StorageManager::reload(bool force) +StorageManager::defaultKeychain(SecPreferencesDomain domain, const Keychain &keychain) { - StLock _(mLock); - _reload(force); + if (domain == mDomain) + defaultKeychain(keychain); + else + DLDbListCFPref(domain).defaultDLDbIdentifier(keychain->dLDbIdentifier()); +} + +Keychain +StorageManager::loginKeychain() +{ + Keychain theKeychain; + { + StLock _(mLock); + mSavedList.revert(false); + DLDbIdentifier loginDLDbIdentifier(mSavedList.loginDLDbIdentifier()); + if (loginDLDbIdentifier) + { + theKeychain = _keychain(loginDLDbIdentifier); + } + } + + if (theKeychain && theKeychain->exists()) + return theKeychain; + + MacOSError::throwMe(errSecNoSuchKeychain); } void -StorageManager::_reload(bool force) +StorageManager::loginKeychain(Keychain keychain) { - // Reinitialize list from CFPrefs if changed. When force is true force a prefs revert now. - if (mSavedList.revert(force)) - _doReload(); + StLock _(mLock); + mSavedList.revert(true); + mSavedList.loginDLDbIdentifier(keychain->dLDbIdentifier()); + mSavedList.save(); } size_t StorageManager::size() { StLock _(mLock); - _reload(); - return mSearchList.size(); + mSavedList.revert(false); + mCommonList.revert(false); + return mSavedList.searchList().size() + mCommonList.searchList().size(); } Keychain StorageManager::at(unsigned int ix) { StLock _(mLock); - _reload(); - if (ix >= mSearchList.size()) - MacOSError::throwMe(errSecInvalidKeychain); + mSavedList.revert(false); + DLDbList dLDbList = mSavedList.searchList(); + if (ix < dLDbList.size()) + { + return _keychain(dLDbList[ix]); + } + else + { + ix -= dLDbList.size(); + mCommonList.revert(false); + DLDbList commonList = mCommonList.searchList(); + if (ix >= commonList.size()) + MacOSError::throwMe(errSecInvalidKeychain); - return mSearchList.at(ix); + return _keychain(commonList[ix]); + } } Keychain @@ -234,13 +400,105 @@ StorageManager::operator[](unsigned int ix) return at(ix); } +void StorageManager::rename(Keychain keychain, const char* newName) +{ + // This is not a generic purpose rename method for keychains. + // The keychain doesn't remain in the cache. + // + bool changedDefault = false; + DLDbIdentifier newDLDbIdentifier; + { + StLock _(mLock); + mSavedList.revert(true); + DLDbIdentifier defaultId = mSavedList.defaultDLDbIdentifier(); + + // Find the keychain object for the given ref + DLDbIdentifier dLDbIdentifier = keychain->dLDbIdentifier(); + + // Remove it from the saved list + mSavedList.remove(dLDbIdentifier); + if (dLDbIdentifier == defaultId) + changedDefault=true; + + // Actually rename the database on disk. + keychain->database()->rename(newName); + + newDLDbIdentifier = keychain->dLDbIdentifier(); + + // Now update the keychain map to use the newDLDbIdentifier + KeychainMap::iterator it = mKeychains.find(dLDbIdentifier); + if (it != mKeychains.end()) + { + mKeychains.erase(it); + mKeychains.insert(KeychainMap::value_type(newDLDbIdentifier, keychain)); + } + + // If this was the default keychain change it accordingly + if (changedDefault) + mSavedList.defaultDLDbIdentifier(newDLDbIdentifier); + + mSavedList.save(); + } + + // @@@ We need a kSecKeychainRenamedEvent so other clients can close this keychain and move on with life. + //KCEventNotifier::PostKeychainEvent(kSecKeychainRenamedEvent); + + // Make sure we are not holding mLock when we post these events. + KCEventNotifier::PostKeychainEvent(kSecKeychainListChangedEvent); + + if (changedDefault) + KCEventNotifier::PostKeychainEvent(kSecDefaultChangedEvent, newDLDbIdentifier); +} + +void StorageManager::renameUnique(Keychain keychain, CFStringRef newName) +{ + bool doneCreating = false; + int index = 1; + do + { + char newNameCString[MAXPATHLEN]; + if ( CFStringGetCString(newName, newNameCString, MAXPATHLEN, kCFStringEncodingUTF8) ) // make sure it fits in MAXPATHLEN, etc. + { + // Construct the new name... + // + CFMutableStringRef newNameCFStr = NULL; + newNameCFStr = CFStringCreateMutable(NULL, MAXPATHLEN); + if ( newNameCFStr ) + { + CFStringAppendFormat(newNameCFStr, NULL, CFSTR("%s%d"), &newNameCString, index); + CFStringAppend(newNameCFStr, CFSTR(kKeychainSuffix)); // add .keychain + char toUseBuff2[MAXPATHLEN]; + if ( CFStringGetCString(newNameCFStr, toUseBuff2, MAXPATHLEN, kCFStringEncodingUTF8) ) // make sure it fits in MAXPATHLEN, etc. + { + struct stat filebuf; + if ( lstat(toUseBuff2, &filebuf) ) + { + rename(keychain, toUseBuff2); + doneCreating = true; + } + else + index++; + } + else + doneCreating = true; // failure to get c string. + CFRelease(newNameCFStr); + } + else + doneCreating = false; // failure to create mutable string. + } + else + doneCreating = false; // failure to get the string (i.e. > MAXPATHLEN?) + } + while (!doneCreating && index != INT_MAX); +} + void StorageManager::remove(const KeychainList &kcsToRemove, bool deleteDb) { bool unsetDefault = false; { StLock _(mLock); mSavedList.revert(true); - DLDbIdentifier defaultId = globals().defaultKeychain.dLDbIdentifier(); + DLDbIdentifier defaultId = mSavedList.defaultDLDbIdentifier(); for (KeychainList::const_iterator ix = kcsToRemove.begin(); ix != kcsToRemove.end(); ++ix) { // Find the keychain object for the given ref @@ -262,41 +520,159 @@ void StorageManager::remove(const KeychainList &kcsToRemove, bool deleteDb) mKeychains.erase(it); } } + + if (unsetDefault) + mSavedList.defaultDLDbIdentifier(DLDbIdentifier()); + mSavedList.save(); - _doReload(); } - // Make sure we are not holding mLock when we post this event. + // Make sure we are not holding mLock when we post these events. KCEventNotifier::PostKeychainEvent(kSecKeychainListChangedEvent); if (unsetDefault) - { - // Make sure we are not holding mLock when we call this since it posts an event. - globals().defaultKeychain.unset(); - } + KCEventNotifier::PostKeychainEvent(kSecDefaultChangedEvent); } void StorageManager::getSearchList(KeychainList &keychainList) { - // Make a copy of the searchList StLock _(mLock); - StorageManager::KeychainList searchList(mSearchList); + mSavedList.revert(false); + mCommonList.revert(false); + + // Merge mSavedList and common list + DLDbList dLDbList = mSavedList.searchList(); + DLDbList commonList = mCommonList.searchList(); + KeychainList result; + result.reserve(dLDbList.size() + commonList.size()); + + for (DLDbList::const_iterator it = dLDbList.begin(); it != dLDbList.end(); ++it) + { + Keychain keychain(_keychain(*it)); + result.push_back(keychain); + } + + for (DLDbList::const_iterator it = commonList.begin(); it != commonList.end(); ++it) + { + Keychain keychain(_keychain(*it)); + result.push_back(keychain); + } - // Return the copy of the list. - keychainList.swap(searchList); + keychainList.swap(result); } void StorageManager::setSearchList(const KeychainList &keychainList) { - // Make a copy of the passed in searchList - StorageManager::KeychainList keychains(keychainList); + DLDbList commonList = mCommonList.searchList(); + + // Strip out the common list part from the end of the search list. + KeychainList::const_iterator it_end = keychainList.end(); + DLDbList::const_reverse_iterator end_common = commonList.rend(); + for (DLDbList::const_reverse_iterator it_common = commonList.rbegin(); it_common != end_common; ++it_common) + { + // Eliminate common entries from the end of the passed in keychainList. + if (it_end == keychainList.begin()) + break; + + --it_end; + if (!((*it_end)->dLDbIdentifier() == *it_common)) + { + ++it_end; + break; + } + } + + /* it_end now points one past the last element in keychainList which is not in commonList. */ + DLDbList searchList, oldSearchList(mSavedList.searchList()); + for (KeychainList::const_iterator it = keychainList.begin(); it != it_end; ++it) + { + searchList.push_back((*it)->dLDbIdentifier()); + } + + { + // Set the current searchlist to be what was passed in, the old list will be freed + // upon exit of this stackframe. + StLock _(mLock); + mSavedList.revert(true); + mSavedList.searchList(searchList); + mSavedList.save(); + } - // Set the current searchlist to be what was passed in, the old list will be freed - // upon exit of this stackframe. + if (!(oldSearchList == searchList)) + { + // Make sure we are not holding mLock when we post this event. + KCEventNotifier::PostKeychainEvent(kSecKeychainListChangedEvent); + } +} + +void +StorageManager::getSearchList(SecPreferencesDomain domain, KeychainList &keychainList) +{ + if (domain == mDomain) + { + StLock _(mLock); + mSavedList.revert(false); + convertList(keychainList, mSavedList.searchList()); + } + else + { + convertList(keychainList, DLDbListCFPref(domain).searchList()); + } +} + +void +StorageManager::setSearchList(SecPreferencesDomain domain, const KeychainList &keychainList) +{ + DLDbList searchList; + convertList(searchList, keychainList); + + if (domain == mDomain) + { + DLDbList oldSearchList(mSavedList.searchList()); + { + // Set the current searchlist to be what was passed in, the old list will be freed + // upon exit of this stackframe. + StLock _(mLock); + mSavedList.revert(true); + mSavedList.searchList(searchList); + mSavedList.save(); + } + + if (!(oldSearchList == searchList)) + { + // Make sure we are not holding mLock when we post this event. + KCEventNotifier::PostKeychainEvent(kSecKeychainListChangedEvent); + } + } + else + { + DLDbListCFPref(domain).searchList(searchList); + } +} + +void +StorageManager::domain(SecPreferencesDomain domain) +{ StLock _(mLock); - mSearchList.swap(keychains); + if (domain == mDomain) + return; // no change + +#if !defined(NDEBUG) + switch (domain) + { + case kSecPreferencesDomainSystem: + secdebug("storagemgr", "switching to system domain"); break; + case kSecPreferencesDomainUser: + secdebug("storagemgr", "switching to user domain (uid %d)", getuid()); break; + default: + secdebug("storagemgr", "switching to weird prefs domain %d", domain); break; + } +#endif + + mDomain = domain; + mSavedList.set(domain); } void @@ -309,8 +685,8 @@ StorageManager::optionalSearchList(CFTypeRef keychainOrArray, KeychainList &keyc CFTypeID typeID = CFGetTypeID(keychainOrArray); if (typeID == CFArrayGetTypeID()) convertToKeychainList(CFArrayRef(keychainOrArray), keychainList); - else if (typeID == gTypes().keychain.typeId) - keychainList.push_back(gTypes().keychain.required(SecKeychainRef(keychainOrArray))); + else if (typeID == gTypes().KeychainImpl.typeID) + keychainList.push_back(KeychainImpl::required(SecKeychainRef(keychainOrArray))); else MacOSError::throwMe(paramErr); } @@ -323,10 +699,9 @@ StorageManager::convertToKeychainList(CFArrayRef keychainArray, KeychainList &ke assert(keychainArray); CFIndex count = CFArrayGetCount(keychainArray); KeychainList keychains(count); - CFClass &kcClass = gTypes().keychain; for (CFIndex ix = 0; ix < count; ++ix) { - keychains[ix] = kcClass.required(SecKeychainRef(CFArrayGetValueAtIndex(keychainArray, ix))); + keychains[ix] = KeychainImpl::required(SecKeychainRef(CFArrayGetValueAtIndex(keychainArray, ix))); } keychainList.swap(keychains); @@ -337,10 +712,9 @@ StorageManager::convertFromKeychainList(const KeychainList &keychainList) { CFRef keychainArray(CFArrayCreateMutable(NULL, keychainList.size(), &kCFTypeArrayCallBacks)); - CFClass &kcClass = gTypes().keychain; for (KeychainList::const_iterator ix = keychainList.begin(); ix != keychainList.end(); ++ix) { - SecKeychainRef keychainRef = kcClass.handle(**ix); + SecKeychainRef keychainRef = (*ix)->handle(); CFArrayAppendValue(keychainArray, keychainRef); CFRelease(keychainRef); } @@ -350,10 +724,66 @@ StorageManager::convertFromKeychainList(const KeychainList &keychainList) return keychainArray; } +void StorageManager::convertList(DLDbList &ids, const KeychainList &kcs) +{ + DLDbList result; + result.reserve(kcs.size()); + for (KeychainList::const_iterator ix = kcs.begin(); ix != kcs.end(); ++ix) + { + result.push_back((*ix)->dLDbIdentifier()); + } + ids.swap(result); +} +void StorageManager::convertList(KeychainList &kcs, const DLDbList &ids) +{ + KeychainList result; + result.reserve(ids.size()); + for (DLDbList::const_iterator ix = ids.begin(); ix != ids.end(); ++ix) + { + Keychain keychain(_keychain(*ix)); + result.push_back(keychain); + } + kcs.swap(result); +} #pragma mark ÑÑÑÑ Login Functions ÑÑÑÑ +void StorageManager::login(AuthorizationRef authRef, UInt32 nameLength, const char* name) +{ + AuthorizationItemSet* info = NULL; + OSStatus result = AuthorizationCopyInfo(authRef, NULL, &info); // get the results of the copy rights call. + Boolean created = false; + if ( result == noErr && info->count ) + { + // Grab the password from the auth context (info) and create the keychain... + // + AuthorizationItem* currItem = info->items; + for (UInt32 index = 1; index <= info->count; index++) //@@@plugin bug won't return a specific context. + { + if (strcmp(currItem->name, kAuthorizationEnvironmentPassword) == 0) + { + // creates the login keychain with the specified password + try + { + login(nameLength, name, currItem->valueLength, currItem->value); + created = true; + } + catch(...) + { + } + break; + } + currItem++; + } + } + if ( info ) + AuthorizationFreeItemSet(info); + + if ( !created ) + MacOSError::throwMe(errAuthorizationInternal); +} + void StorageManager::login(ConstStringPtr name, ConstStringPtr password) { if ( name == NULL || password == NULL ) @@ -364,53 +794,38 @@ void StorageManager::login(ConstStringPtr name, ConstStringPtr password) void StorageManager::login(UInt32 nameLength, const void *name, UInt32 passwordLength, const void *password) { - // @@@ set up the login session on behalf of loginwindow - // @@@ (this code should migrate into loginwindow) -#if 0 - debug("KClogin", "setting up login session"); - if (OSStatus ssnErr = SessionCreate(sessionKeepCurrentBootstrap, - sessionHasGraphicAccess | sessionHasTTY)) - debug("KClogin", "session setup failed status=%ld", ssnErr); -#endif + x_debug("StorageManager::login: entered"); + mSavedList.revert(true); + if (passwordLength != 0 && password == NULL) + { + x_debug("StorageManager::login: invalid argument (NULL password)"); + MacOSError::throwMe(paramErr); + } - if (name == NULL || (passwordLength != 0 && password == NULL)) - MacOSError::throwMe(paramErr); + DLDbIdentifier loginDLDbIdentifier(mSavedList.loginDLDbIdentifier()); + x_debug1("StorageManager::login: loginDLDbIdentifier is %s", (loginDLDbIdentifier) ? loginDLDbIdentifier.dbName() : ""); + if (!loginDLDbIdentifier) + MacOSError::throwMe(errSecNoSuchKeychain); - // Make sure name is zero terminated - string theName(reinterpret_cast(name), nameLength); - Keychain keychain = make(theName.c_str()); + Keychain theKeychain(keychain(loginDLDbIdentifier)); try { - keychain->unlock(CssmData(const_cast(password), passwordLength)); - debug("KClogin", "keychain unlock successful"); + x_debug2("Attempting to unlock login keychain %s with %d-character password", (theKeychain) ? theKeychain->name() : "", (unsigned int)passwordLength); + theKeychain->unlock(CssmData(const_cast(password), passwordLength)); + x_debug("Login keychain unlocked successfully"); } catch(const CssmError &e) { if (e.osStatus() != CSSMERR_DL_DATASTORE_DOESNOT_EXIST) throw; - debug("KClogin", "creating login keychain"); - keychain->create(passwordLength, password); + x_debug1("Creating login keychain %s", (loginDLDbIdentifier) ? loginDLDbIdentifier.dbName() : ""); + theKeychain->create(passwordLength, password); + x_debug("Login keychain created successfully"); + // Set the prefs for this new login keychain. + loginKeychain(theKeychain); // Login Keychain does not lock on sleep nor lock after timeout by default. - keychain->setSettings(INT_MAX, false); + theKeychain->setSettings(INT_MAX, false); } -#if 0 - // @@@ Create a authorization credential for the current user. - debug("KClogin", "creating login authorization"); - const AuthorizationItem envList[] = - { - { kAuthorizationEnvironmentUsername, nameLength, const_cast(name), 0 }, - { kAuthorizationEnvironmentPassword, passwordLength, const_cast(password), 0 }, - { kAuthorizationEnvironmentShared, 0, NULL, 0 } - }; - const AuthorizationEnvironment environment = - { - sizeof(envList) / sizeof(*envList), - const_cast(envList) - }; - if (OSStatus authErr = AuthorizationCreate(NULL, &environment, - kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize, NULL)) - debug("KClogin", "failed to create login auth, status=%ld", authErr); -#endif } void StorageManager::logout() @@ -420,18 +835,85 @@ void StorageManager::logout() void StorageManager::changeLoginPassword(ConstStringPtr oldPassword, ConstStringPtr newPassword) { - globals().defaultKeychain.keychain()->changePassphrase(oldPassword, newPassword); + loginKeychain()->changePassphrase(oldPassword, newPassword); + secdebug("KClogin", "Changed login keychain password successfully"); } void StorageManager::changeLoginPassword(UInt32 oldPasswordLength, const void *oldPassword, UInt32 newPasswordLength, const void *newPassword) { - globals().defaultKeychain.keychain()->changePassphrase(oldPasswordLength, oldPassword, newPasswordLength, newPassword); + loginKeychain()->changePassphrase(oldPasswordLength, oldPassword, newPasswordLength, newPassword); + secdebug("KClogin", "Changed login keychain password successfully"); +} + +// Clear out the keychain search list and rename the existing login.keychain. +// +void StorageManager::resetKeychain(Boolean resetSearchList) +{ + // Clear the keychain search list. + // + CFArrayRef emptySearchList = nil; + try + { + if ( resetSearchList ) + { + emptySearchList = CFArrayCreate(NULL, NULL, 0, NULL); + StorageManager::KeychainList keychainList; + convertToKeychainList(emptySearchList, keychainList); + setSearchList(keychainList); + } + // Get a reference to the existing login keychain... + // If we don't have one, we throw (not requiring a rename). + // + Keychain keychain = loginKeychain(); + // + // Rename the existing login.keychain (i.e. put it aside). + // + CFMutableStringRef newName = NULL; + newName = CFStringCreateMutable(NULL, 0); + CFStringRef currName = NULL; + currName = CFStringCreateWithCString(NULL, keychain->name(), kCFStringEncodingUTF8); + if ( newName && currName ) + { + CFStringAppend(newName, currName); + CFStringRef kcSuffix = CFSTR(kKeychainSuffix); + if ( CFStringHasSuffix(newName, kcSuffix) ) // remove the .keychain extension + { + CFRange suffixRange = CFStringFind(newName, kcSuffix, 0); + CFStringFindAndReplace(newName, kcSuffix, CFSTR(""), suffixRange, 0); + } + CFStringAppend(newName, CFSTR(kKeychainRenamedSuffix)); // add "_renamed" + try + { + renameUnique(keychain, newName); + } + catch(...) + { + // we need to release 'newName' & 'currName' + } + } // else, let the login call report a duplicate + if ( newName ) + CFRelease(newName); + if ( currName ) + CFRelease(currName); + } + catch(...) + { + // We either don't have a login keychain, or there was a + // failure to rename the existing one. + } + if ( emptySearchList ) + CFRelease(emptySearchList); } #pragma mark ÑÑÑÑ File Related ÑÑÑÑ Keychain StorageManager::make(const char *pathName) +{ + return make(pathName, true); +} + +Keychain StorageManager::make(const char *pathName, bool add) { string fullPathName; if ( pathName[0] == '/' ) @@ -439,18 +921,30 @@ Keychain StorageManager::make(const char *pathName) else { // Get Home directory from environment. - const char *homeDir = getenv("HOME"); - if (homeDir == NULL) - { - // If $HOME is unset get the current users home directory from the passwd file. - struct passwd *pw = getpwuid(getuid()); - if (!pw) - MacOSError::throwMe(paramErr); - - homeDir = pw->pw_dir; + switch (mDomain) { + case kSecPreferencesDomainUser: + { + const char *homeDir = getenv("HOME"); + if (homeDir == NULL) + { + // If $HOME is unset get the current user's home directory from the passwd file. + uid_t uid = geteuid(); + if (!uid) uid = getuid(); + struct passwd *pw = getpwuid(uid); + if (!pw) + MacOSError::throwMe(paramErr); + homeDir = pw->pw_dir; + } + fullPathName = homeDir; + } + break; + case kSecPreferencesDomainSystem: + fullPathName = ""; + break; + default: + assert(false); // invalid domain for this } - fullPathName = homeDir; fullPathName += "/Library/Keychains/"; fullPathName += pathName; } @@ -459,20 +953,197 @@ Keychain StorageManager::make(const char *pathName) const CSSM_VERSION *version = NULL; uint32 subserviceId = 0; CSSM_SERVICE_TYPE subserviceType = CSSM_SERVICE_DL | CSSM_SERVICE_CSP; - const CssmSubserviceUid ssuid(gGuidAppleCSPDL, version, + const CssmSubserviceUid ssuid(gGuidAppleCSPDL, version, subserviceId, subserviceType); DLDbIdentifier dLDbIdentifier(ssuid, fullPathName.c_str(), DbLocation); - return makeKeychain(dLDbIdentifier); + return makeKeychain(dLDbIdentifier, add); } -KeychainSchema -StorageManager::keychainSchemaFor(const CssmClient::Db &db) +Keychain StorageManager::makeLoginAuthUI(Item &item) { - // @@@ Locking - KeychainSchema schema(db); - pair result = mKeychainSchemaSet.insert(db); - if (result.second) - return schema; - return *result.first; + // Create a login/default keychain for the user using UI. + // The user can cancel out of the operation, or create a new login keychain. + // If auto-login is turned off, the user will be asked for their login password. + // + OSStatus result = noErr; + Keychain keychain = NULL; // We return this keychain. + // + // Set up the Auth ref to bring up UI. + // + AuthorizationRef authRef = NULL; + result = AuthorizationCreate(NULL, NULL, kAuthorizationFlagDefaults, &authRef); + if ( result != noErr ) + MacOSError::throwMe(errAuthorizationInternal); + AuthorizationEnvironment envir; + envir.count = 5; // 5 hints are used. + AuthorizationItem* authEnvirItemArrayPtr = (AuthorizationItem*)malloc(sizeof(AuthorizationItem) * envir.count); + if ( !authEnvirItemArrayPtr ) + { + if ( authRef ) + AuthorizationFree(authRef, kAuthorizationFlagDefaults); + MacOSError::throwMe(errAuthorizationInternal); + } + envir.items = authEnvirItemArrayPtr; + AuthorizationItem* currItem = authEnvirItemArrayPtr; + // + // 1st Hint (optional): The keychain item's account attribute string. + // When item is specified, we assume an 'add' operation is being attempted. + char buff[255]; + UInt32 actLen; + SecKeychainAttribute attr = { kSecAccountItemAttr, 255, &buff }; + try + { + item->getAttribute(attr, &actLen); + } + catch(...) + { + actLen = 0; // This item didn't have the account attribute, so don't display one in the UI. + } + currItem->name = AGENT_HINT_ATTR_NAME; // name str that identifies this hint as attr name + if ( actLen ) // Fill in the hint if we have a 'srvr' attr + { + if ( actLen > 255 ) + buff[255] = 0; + else + buff[actLen] = 0; + currItem->valueLength = strlen(buff)+1; + currItem->value = buff; + } + else + { + currItem->valueLength = 0; + currItem->value = NULL; + } + currItem->flags = 0; + // + // 2nd Hint (optional): The item's keychain full path. + // + currItem++; + char* currDefaultName = NULL; + try + { + currDefaultName = (char*)globals().storageManager.defaultKeychain()->name(); // Use the name if we have it. + currItem->name = AGENT_HINT_LOGIN_KC_NAME; // Name str that identifies this hint as kc path + currItem->valueLength = strlen(currDefaultName); + currItem->value = (void*)currDefaultName; + currItem->flags = 0; + currItem++; + } + catch(...) + { + envir.count--; + } + + // + // 3rd Hint (optional): If curr default keychain is unavailable. + // This is determined by the parent not existing. + // + currItem->name = AGENT_HINT_LOGIN_KC_EXISTS_IN_KC_FOLDER; + Boolean loginUnavail = false; + try + { + Keychain defaultKC = defaultKeychain(); + if ( !defaultKC->exists() ) + loginUnavail = true; + } + catch(...) // login.keychain not present + { + } + currItem->valueLength = sizeof(Boolean); + currItem->value = (void*)&loginUnavail; + currItem->flags = 0; + // + // 4th Hint (required) userName + // + currItem++; + currItem->name = AGENT_HINT_LOGIN_KC_USER_NAME; + char* uName = getenv("USER"); + string userName = uName ? uName : ""; + if ( userName.length() == 0 ) + { + uid_t uid = geteuid(); + if (!uid) uid = getuid(); + struct passwd *pw = getpwuid(uid); // fallback case... + if (pw) + userName = pw->pw_name; + endpwent(); + } + if ( userName.length() != 0 ) // did we ultimately get one? + { + currItem->value = (void*)userName.c_str(); + currItem->valueLength = userName.length(); + } + else // trouble getting user name; can't continue... + { + if ( authRef ) + AuthorizationFree(authRef, kAuthorizationFlagDefaults); + free(authEnvirItemArrayPtr); + MacOSError::throwMe(errAuthorizationInternal); + } + currItem->flags = 0; + // + // 5th Hint (optional) flags if user has more than 1 keychain (used for a later warning when reset to default). + // + currItem++; // last hint... + currItem->name = AGENT_HINT_LOGIN_KC_USER_HAS_OTHER_KCS_STR; + Boolean moreThanOneKCExists = false; + { + StLock _(mLock); + if (mSavedList.searchList().size() > 1) + moreThanOneKCExists = true; + } + currItem->value = &moreThanOneKCExists; + currItem->valueLength = sizeof(Boolean); + currItem->flags = 0; + // + // Set up the auth rights and make the auth call. + // + AuthorizationItem authItem = { LOGIN_KC_CREATION_RIGHT, 0 , NULL, 0}; + AuthorizationRights rights = { 1, &authItem }; + result = AuthorizationCopyRights(authRef, &rights, &envir, kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights, NULL); + free(authEnvirItemArrayPtr); // done with the auth items. + if ( result == errAuthorizationSuccess ) // On success, revert to defaults. + { + try + { + resetKeychain(true); // Clears the plist, moves aside existing login.keychain + login(authRef, userName.length(), userName.c_str()); // Creates a login.keychain + keychain = loginKeychain(); // Return it. + defaultKeychain(keychain); // Set it to the default. + } + catch(...) + { + // Reset failed, login.keychain creation failed, or setting it to default. + // We need to release 'authRef'... + } + } + if ( authRef ) + AuthorizationFree(authRef, kAuthorizationFlagDefaults); + if ( result ) + MacOSError::throwMe(result); // Any other error means we don't return a keychain. + return keychain; } +Keychain StorageManager::defaultKeychainUI(Item &item) +{ + Keychain returnedKeychain = NULL; + try + { + returnedKeychain = globals().storageManager.defaultKeychain(); // If we have one, return it. + if ( returnedKeychain->exists() ) + return returnedKeychain; + } + catch(...) // We could have one, but it isn't available (i.e. on a un-mounted volume). + { + } + if ( globals().getUserInteractionAllowed() ) + { + returnedKeychain = makeLoginAuthUI(item); // If no Keychains Ä is present, one will be created. + if ( !returnedKeychain ) + MacOSError::throwMe(errSecInvalidKeychain); // Something went wrong... + } + else + MacOSError::throwMe(errSecInteractionNotAllowed); // If UI isn't allowed, return an error. + + return returnedKeychain; +} diff --git a/Keychain/StorageManager.h b/Keychain/StorageManager.h index 2961b450..f187fe87 100644 --- a/Keychain/StorageManager.h +++ b/Keychain/StorageManager.h @@ -23,9 +23,14 @@ #define _SECURITY_STORAGEMANAGER_H_ #include +#include #include #include #include +#include +#include + +#define kKeychainRenamedSuffix "_renamed" namespace Security { @@ -38,6 +43,7 @@ class StorageManager NOCOPY(StorageManager) public: typedef vector KeychainList; + typedef vector DLDbList; StorageManager(); ~StorageManager() {} @@ -45,7 +51,9 @@ public: //bool onlist(const Keychain & keychain); // These will call addAndNotify() if the specified keychain already exists - Keychain make(const char *fullPathName); + Keychain make(const char *fullPathName); + Keychain make(const char *fullPathName, bool add); + Keychain makeLoginAuthUI(Item &item); void created(const Keychain &keychain); // Be notified a Keychain just got created. // Misc @@ -68,7 +76,7 @@ public: Keychain _keychain(const DLDbIdentifier &dLDbIdentifier); // Create KC if it doesn't exist, add it to the search list if it exists and is not already on it. - Keychain makeKeychain(const DLDbIdentifier &dLDbIdentifier); + Keychain makeKeychain(const DLDbIdentifier &dLDbIdentifier, bool add = true); // Keychain list maintenance @@ -78,6 +86,12 @@ public: void getSearchList(KeychainList &keychainList); void setSearchList(const KeychainList &keychainList); + + void getSearchList(SecPreferencesDomain domain, KeychainList &keychainList); + void setSearchList(SecPreferencesDomain domain, const KeychainList &keychainList); + + void rename(Keychain keychain, const char* newName); + void renameUnique(Keychain keychain, CFStringRef newName); // Iff keychainOrArray is NULL return the default KeychainList in keychainList otherwise // if keychainOrArray is a CFArrayRef containing SecKeychainRef's convernt it to KeychainList, @@ -91,35 +105,47 @@ public: static CFArrayRef convertFromKeychainList(const KeychainList &keychainList); // Login keychain support + void login(AuthorizationRef authRef, UInt32 nameLength, const char* name); void login(ConstStringPtr name, ConstStringPtr password); void login(UInt32 nameLength, const void *name, UInt32 passwordLength, const void *password); void logout(); void changeLoginPassword(ConstStringPtr oldPassword, ConstStringPtr newPassword); void changeLoginPassword(UInt32 oldPasswordLength, const void *oldPassword, UInt32 newPasswordLength, const void *newPassword); - // Reload mSearchList from mList if the searchList on disk has changed. - void reload(bool force = false); + void resetKeychain(Boolean resetSearchList); -private: - typedef map KeychainMap; - typedef set KeychainSchemaSet; + Keychain defaultKeychain(); + Keychain defaultKeychainUI(Item &item); + void defaultKeychain(const Keychain &keychain); - // Reload mSearchList from mList and add new keychains to mKeychains if not already there - // Assumes mLock is already locked. - void _doReload(); + Keychain loginKeychain(); + void loginKeychain(Keychain keychain); + + Keychain defaultKeychain(SecPreferencesDomain domain); + void defaultKeychain(SecPreferencesDomain domain, const Keychain &keychain); + + SecPreferencesDomain domain() { return mDomain; } + void domain(SecPreferencesDomain newDomain); + + // To be called by KeychainImpl destructor only. + void removeKeychain(const DLDbIdentifier &dLDbIdentifier, KeychainImpl *keychainImpl); + +private: + typedef map KeychainMap; - // Reload mSearchList from mList if the searchList on disk has changed. - // Assumes mLock is already locked. - void _reload(bool force = false); + static void convertList(DLDbList &ids, const KeychainList &kcs); + void convertList(KeychainList &kcs, const DLDbList &ids); // Only add if not there yet. Writes out CFPref and broadcasts KCPrefListChanged notification void addAndNotify(const Keychain& keychainToAdd); - KeychainSchema keychainSchemaFor(const CssmClient::Db &db); + + // set default credentials for opening a keychain + void setDefaultCredentials(const CssmClient::Db &db); - DLDbListCFPref mSavedList; + DLDbListCFPref mSavedList; + DLDbListCFPref mCommonList; + SecPreferencesDomain mDomain; // current domain (in mSavedList and cache fields) KeychainMap mKeychains; // the cache of Keychains - KeychainList mSearchList; - KeychainSchemaSet mKeychainSchemaSet; Mutex mLock; }; diff --git a/Keychain/Trust.cpp b/Keychain/Trust.cpp index 14cb813d..dfe46b35 100644 --- a/Keychain/Trust.cpp +++ b/Keychain/Trust.cpp @@ -34,13 +34,23 @@ using namespace KeychainCore; ModuleNexus Trust::gStore; +// +// @@@ For some reason, the C++ type system won't resolve an operator from Security namespace. +// Drag it in here explicitly (the hard way). Someone bored might want to investigate which +// language rules ambiguates the Security::operator == inside the Security::KeychainCore namespace. +// +inline bool operator == (const CSSM_DL_DB_HANDLE &h1, const CSSM_DL_DB_HANDLE &h2) +{ + return Security::operator == (h1, h2); +} + + // // Construct a Trust object with suitable defaults. // Use setters for additional arguments before calling evaluate(). // Trust::Trust(CFTypeRef certificates, CFTypeRef policies) : mTP(gGuidAppleX509TP), mAction(CSSM_TP_ACTION_DEFAULT), - mVerifyTime(NULL), mCerts(cfArrayize(certificates)), mPolicies(cfArrayize(policies)), mResult(kSecTrustResultInvalid) { @@ -52,7 +62,7 @@ Trust::Trust(CFTypeRef certificates, CFTypeRef policies) // // Clean up a Trust object // -Trust::~Trust() +Trust::~Trust() throw() { clearResults(); } @@ -64,7 +74,7 @@ Trust::~Trust() CSSM_TP_VERIFY_CONTEXT_RESULT_PTR Trust::cssmResult() { if (mResult == kSecTrustResultInvalid) - MacOSError::throwMe(errSecNotAvailable); + MacOSError::throwMe(errSecTrustNotAvailable); return &mTpResult; } @@ -72,20 +82,20 @@ CSSM_TP_VERIFY_CONTEXT_RESULT_PTR Trust::cssmResult() // SecCertificateRef -> CssmData CssmData cfCertificateData(SecCertificateRef certificate) { - return gTypes().certificate.required(certificate)->data(); + return Certificate::required(certificate)->data(); } // SecPolicyRef -> CssmField (CFDataRef/NULL or oid/value of a SecPolicy) CssmField cfField(SecPolicyRef item) { - RefPointer policy = gTypes().policy.required(SecPolicyRef(item)); + SecPointer policy = Policy::required(SecPolicyRef(item)); return CssmField(policy->oid(), policy->value()); } // SecKeychain -> CssmDlDbHandle CSSM_DL_DB_HANDLE cfKeychain(SecKeychainRef ref) { - Keychain keychain = gTypes().keychain.required(ref); + Keychain keychain = KeychainImpl::required(ref); return keychain->database()->handle(); } @@ -132,13 +142,22 @@ void Trust::evaluate() vector dlDbList; for (StorageManager::KeychainList::const_iterator it = mSearchLibs.begin(); it != mSearchLibs.end(); it++) - dlDbList.push_back((*it)->database()->handle()); + { + try + { + dlDbList.push_back((*it)->database()->handle()); + } + catch (...) + { + } + } context.setDlDbList(dlDbList.size(), &dlDbList[0]); // verification time char timeString[15]; if (mVerifyTime) { - CssmUniformDate(mVerifyTime).convertTo(timeString, sizeof(timeString)); + CssmUniformDate(static_cast(mVerifyTime)).convertTo( + timeString, sizeof(timeString)); context.time(timeString); } @@ -159,10 +178,10 @@ void Trust::evaluate() && mTpResult[1].form() == CSSM_EVIDENCE_FORM_APPLE_CERTGROUP && mTpResult[2].form() == CSSM_EVIDENCE_FORM_APPLE_CERT_INFO) { evaluateUserTrust(*mTpResult[1].as(), - mTpResult[2].as()); + mTpResult[2].as(), anchors); } else { // unexpected evidence information. Can't use it - debug("trusteval", "unexpected evidence ignored"); + secdebug("trusteval", "unexpected evidence ignored"); } } @@ -195,31 +214,34 @@ SecTrustResultType Trust::diagnoseOutcome() // settings and set mResult accordingly. // void Trust::evaluateUserTrust(const CertGroup &chain, - const CSSM_TP_APPLE_EVIDENCE_INFO *infoList) + const CSSM_TP_APPLE_EVIDENCE_INFO *infoList, CFCopyRef anchors) { // extract cert chain as Certificate objects - //@@@ once new Evidence is in, use it to build the Certificates mCertChain.resize(chain.count()); for (uint32 n = 0; n < mCertChain.size(); n++) { const TPEvidenceInfo &info = TPEvidenceInfo::overlay(infoList[n]); if (info.recordId()) { - debug("trusteval", "evidence %ld from DLDB source", n); - assert(false); // from DL/DB search - not yet implemented + Keychain keychain = keychainByDLDb(info.DlDbHandle); + DbUniqueRecord uniqueId(keychain->database()->newDbUniqueRecord()); + secdebug("trusteval", "evidence #%ld from keychain \"%s\"", n, keychain->name()); + *static_cast(uniqueId) = info.UniqueRecord; + uniqueId->activate(); // transfers ownership + mCertChain[n] = safe_cast(keychain->item(CSSM_DL_DB_RECORD_X509_CERTIFICATE, uniqueId).get()); } else if (info.status(CSSM_CERT_STATUS_IS_IN_INPUT_CERTS)) { - debug("trusteval", "evidence %ld from input cert %ld", n, info.index()); + secdebug("trusteval", "evidence %ld from input cert %ld", n, info.index()); assert(info.index() < uint32(CFArrayGetCount(mCerts))); SecCertificateRef cert = SecCertificateRef(CFArrayGetValueAtIndex(mCerts, info.index())); - mCertChain[n] = gTypes().certificate.required(cert); + mCertChain[n] = Certificate::required(cert); } else if (info.status(CSSM_CERT_STATUS_IS_IN_ANCHORS)) { - debug("trusteval", "evidence %ld from anchor cert %ld", n, info.index()); - assert(info.index() < uint32(CFArrayGetCount(mAnchors))); - SecCertificateRef cert = SecCertificateRef(CFArrayGetValueAtIndex(mAnchors, + secdebug("trusteval", "evidence %ld from anchor cert %ld", n, info.index()); + assert(info.index() < uint32(CFArrayGetCount(anchors))); + SecCertificateRef cert = SecCertificateRef(CFArrayGetValueAtIndex(anchors, info.index())); - mCertChain[n] = gTypes().certificate.required(cert); + mCertChain[n] = Certificate::required(cert); } else { // unknown source; make a new Certificate for it - debug("trusteval", "evidence %ld from unknown source", n); + secdebug("trusteval", "evidence %ld from unknown source", n); mCertChain[n] = new Certificate(chain.blobCerts()[n], CSSM_CERT_X_509v3, CSSM_CERT_ENCODING_BER); @@ -228,12 +250,19 @@ void Trust::evaluateUserTrust(const CertGroup &chain, // now walk the chain, leaf-to-root, checking for user settings TrustStore &store = gStore(); - RefPointer policy = - gTypes().policy.required(SecPolicyRef(CFArrayGetValueAtIndex(mPolicies, 0))); + SecPointer policy = + Policy::required(SecPolicyRef(CFArrayGetValueAtIndex(mPolicies, 0))); for (mResultIndex = 0; mResult == kSecTrustResultUnspecified && mResultIndex < mCertChain.size(); mResultIndex++) - mResult = store.find(mCertChain[mResultIndex], policy); + { + if (!mCertChain[mResultIndex]) + { + assert(false); + continue; + } + mResult = store.find(mCertChain[mResultIndex], policy); + } } @@ -255,20 +284,29 @@ void Trust::releaseTPEvidence(TPVerifyResult &result, CssmAllocator &allocator) && result[1].form() == CSSM_EVIDENCE_FORM_APPLE_CERTGROUP && result[2].form() == CSSM_EVIDENCE_FORM_APPLE_CERT_INFO) { // proper format + CertGroup& certs = *result[1].as(); + CSSM_TP_APPLE_EVIDENCE_INFO *evidence = result[2].as(); + uint32 count = certs.count(); allocator.free(result[0].data()); // just a struct - result[1].as()->destroy(allocator); // CertGroup contents + certs.destroy(allocator); // certgroup contents allocator.free(result[1].data()); // the CertGroup itself + for (uint32 n = 0; n < count; n++) + allocator.free(evidence[n].StatusCodes); allocator.free(result[2].data()); // array of (flat) info structs } else { - debug("trusteval", "unrecognized Apple TP evidence format"); + secdebug("trusteval", "unrecognized Apple TP evidence format"); // drop it -- better leak than kill } } else { // unknown format -- blindly assume flat blobs - debug("trusteval", "destroying unknown TP evidence format"); + secdebug("trusteval", "destroying unknown TP evidence format"); for (uint32 n = 0; n < result.count(); n++) + { allocator.free(result[n].data()); + } } + + allocator.free (result.Evidence); } } @@ -285,14 +323,45 @@ void Trust::clearResults() } +// Convert a SecPointer to a CF object. +static SecCertificateRef +convert(const SecPointer &certificate) +{ + return *certificate; +} + // // Build evidence information // void Trust::buildEvidence(CFArrayRef &certChain, TPEvidenceInfo * &statusChain) { if (mResult == kSecTrustResultInvalid) - MacOSError::throwMe(errSecNotAvailable); + MacOSError::throwMe(errSecTrustNotAvailable); certChain = mEvidenceReturned = - makeCFArray(gTypes().certificate, mCertChain); + makeCFArray(convert, mCertChain); statusChain = mTpResult[2].as(); } + + +// +// Given a DL_DB_HANDLE, locate the Keychain object (from the search list) +// +Keychain Trust::keychainByDLDb(const CSSM_DL_DB_HANDLE &handle) const +{ + for (StorageManager::KeychainList::const_iterator it = mSearchLibs.begin(); + it != mSearchLibs.end(); it++) + { + try + { + if ((*it)->database()->handle() == handle) + return *it; + } + catch (...) + { + } + } + + // could not find in search list - internal error + assert(false); + return Keychain(); +} diff --git a/Keychain/Trust.h b/Keychain/Trust.h index 2eec4e34..05048ff5 100644 --- a/Keychain/Trust.h +++ b/Keychain/Trust.h @@ -47,14 +47,17 @@ class Trust : public SecCFObject { NOCOPY(Trust) public: + SECCFFUNCTIONS(Trust, SecTrustRef, errSecInvalidItemRef) + Trust(CFTypeRef certificates, CFTypeRef policies); - virtual ~Trust(); + virtual ~Trust() throw(); - // set more input parameters + // set (or reset) more input parameters + void policies(CFTypeRef policies) { mPolicies.take(cfArrayize(policies)); } void action(CSSM_TP_ACTION action) { mAction = action; } void actionData(CFDataRef data) { mActionData = data; } void time(CFDateRef verifyTime) { mVerifyTime = verifyTime; } - void anchors(CFArrayRef anchorList) { mAnchors = cfArrayize(anchorList); } + void anchors(CFArrayRef anchorList) { mAnchors.take(cfArrayize(anchorList)); } StorageManager::KeychainList &searchLibs() { return mSearchLibs; } // perform evaluation @@ -65,6 +68,7 @@ public: CSSM_TP_VERIFY_CONTEXT_RESULT_PTR cssmResult(); SecTrustResultType result() const { return mResult; } + OSStatus cssmResultCode() const { return mTpReturn; } TP getTPHandle() const { return mTP; } // an independent release function for TP evidence results @@ -74,8 +78,11 @@ public: private: SecTrustResultType diagnoseOutcome(); void evaluateUserTrust(const CertGroup &certs, - const CSSM_TP_APPLE_EVIDENCE_INFO *info); + const CSSM_TP_APPLE_EVIDENCE_INFO *info, + CFCopyRef anchors); void clearResults(); + + Keychain keychainByDLDb(const CSSM_DL_DB_HANDLE &handle) const; private: TP mTP; // our TP @@ -95,7 +102,7 @@ private: OSStatus mTpReturn; // return code from TP Verify TPVerifyResult mTpResult; // result of latest TP verify - vector< RefPointer > mCertChain; // distilled certificate chain + vector< SecPointer > mCertChain; // distilled certificate chain // information returned to caller but owned by us CFRef mEvidenceReturned; // evidence chain returned diff --git a/Keychain/TrustItem.cpp b/Keychain/TrustItem.cpp index 6bfe1c79..a78a0628 100644 --- a/Keychain/TrustItem.cpp +++ b/Keychain/TrustItem.cpp @@ -22,6 +22,10 @@ #include #include +#include +#include +#include + namespace Security { namespace KeychainCore { @@ -37,16 +41,16 @@ UserTrustItem::UserTrustItem(Certificate *cert, Policy *policy, const TrustData reinterpret_cast(&trustData)), mCertificate(cert), mPolicy(policy) { - debug("usertrust", "create %p (%p,%p) = %d", this, cert, policy, trustData.trust); + secdebug("usertrust", "create %p (%p,%p) = %d", this, cert, policy, trustData.trust); } // // Destroy it // -UserTrustItem::~UserTrustItem() +UserTrustItem::~UserTrustItem() throw() { - debug("usertrust", "destroy %p", this); + secdebug("usertrust", "destroy %p", this); } @@ -81,7 +85,7 @@ PrimaryKey UserTrustItem::add(Keychain &keychain) try { mUniqueId = db->insert(recordType, mDbAttributes.get(), mData.get()); - debug("usertrust", "%p inserted", this); + secdebug("usertrust", "%p inserted", this); } catch (const CssmError &e) { @@ -89,32 +93,84 @@ PrimaryKey UserTrustItem::add(Keychain &keychain) throw; // Create the cert relation and try again. - debug("usertrust", "adding schema relation for user trusts"); + secdebug("usertrust", "adding schema relation for user trusts"); db->createRelation(CSSM_DL_DB_RECORD_USER_TRUST, "CSSM_DL_DB_RECORD_USER_TRUST", Schema::UserTrustSchemaAttributeCount, Schema::UserTrustSchemaAttributeList, Schema::UserTrustSchemaIndexCount, Schema::UserTrustSchemaIndexList); + keychain->resetSchema(); mUniqueId = db->insert(recordType, mDbAttributes.get(), mData.get()); - debug("usertrust", "%p inserted now", this); + secdebug("usertrust", "%p inserted now", this); } mPrimaryKey = keychain->makePrimaryKey(recordType, mUniqueId); mKeychain = keychain; - return mPrimaryKey; } void UserTrustItem::populateAttributes() { - const CssmData &certData = mCertificate->data(); + CssmAutoData encodedIndex(CssmAllocator::standard()); + makeCertIndex(mCertificate, encodedIndex); const CssmOid &policyOid = mPolicy->oid(); - mDbAttributes->add(Schema::attributeInfo(kSecTrustCertAttr), certData); + + mDbAttributes->add(Schema::attributeInfo(kSecTrustCertAttr), encodedIndex.get()); mDbAttributes->add(Schema::attributeInfo(kSecTrustPolicyAttr), policyOid); } +// +// An ad-hoc hold-and-destroy accessor for a single-valued certificate field +// +class CertField { +public: + CertField(Certificate *cert, const CSSM_OID &inField) + : certificate(cert), field(inField) + { mData = certificate->copyFirstFieldValue(field); } + + ~CertField() { certificate->releaseFieldValue(field, mData); } + + Certificate * const certificate; + const CSSM_OID &field; + + operator bool () const { return mData && mData->Data; } + CssmData &data() const { return CssmData::overlay(*mData); } + +private: + CSSM_DATA_PTR mData; +}; + + +// +// Construct a trust item index. +// This is an ASN.1 sequence of issuer and serial number. +// +struct IssuerAndSN { + CSSM_DATA issuer; + CSSM_DATA serial; +}; + +static const SEC_ASN1Template issuerAndSNTemplate[] = { + { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(IssuerAndSN) }, + { SEC_ASN1_OCTET_STRING, offsetof(IssuerAndSN, issuer) }, + { SEC_ASN1_OCTET_STRING, offsetof(IssuerAndSN, serial) }, + { 0 } +}; + +void UserTrustItem::makeCertIndex(Certificate *cert, CssmOwnedData &encodedIndex) +{ + CertField issuer(cert, CSSMOID_X509V1IssuerName); + CertField serial(cert, CSSMOID_X509V1SerialNumber); + IssuerAndSN index; + index.issuer = issuer.data(); + index.serial = serial.data(); + if (SecNssEncodeItemOdata(&index, issuerAndSNTemplate, encodedIndex)) + CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); +} + + } // end namespace KeychainCore } // end namespace Security diff --git a/Keychain/TrustItem.h b/Keychain/TrustItem.h index 9046ee05..c1aef1ad 100644 --- a/Keychain/TrustItem.h +++ b/Keychain/TrustItem.h @@ -58,9 +58,12 @@ public: public: // new item constructor UserTrustItem(Certificate *cert, Policy *policy, const TrustData &trust); - virtual ~UserTrustItem(); + virtual ~UserTrustItem() throw(); TrustData trust(); + +public: + static void makeCertIndex(Certificate *cert, CssmOwnedData &index); protected: virtual PrimaryKey add(Keychain &keychain); @@ -68,8 +71,8 @@ protected: void populateAttributes(); private: - RefPointer mCertificate; - RefPointer mPolicy; + SecPointer mCertificate; + SecPointer mPolicy; }; diff --git a/Keychain/TrustStore.cpp b/Keychain/TrustStore.cpp index fdc3588a..dae7d41e 100644 --- a/Keychain/TrustStore.cpp +++ b/Keychain/TrustStore.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -69,14 +70,19 @@ void TrustStore::assign(Certificate *cert, Policy *policy, SecTrustUserSetting t TrustData trustData = { UserTrustItem::currentVersion, trust }; if (Item item = findItem(cert, policy)) { // user has a trust setting in a keychain - modify that - item->modifyContent(NULL, sizeof(trustData), &trustData); + if (trust == kSecTrustResultUnspecified) + item->keychain()->deleteItem(item); + else + item->modifyContent(NULL, sizeof(trustData), &trustData); } else { // no trust entry: make one - Item item = new UserTrustItem(cert, policy, trustData); - if (Keychain location = cert->keychain()) - location->add(item); // in the cert's keychain - else - Keychain::optional(NULL)->add(item); // in the default keychain + if (trust != kSecTrustResultUnspecified) { + Item item = new UserTrustItem(cert, policy, trustData); + if (Keychain location = cert->keychain()) + location->add(item); // in the cert's keychain + else + Keychain::optional(NULL)->add(item); // in the default keychain + } } } @@ -90,10 +96,11 @@ Item TrustStore::findItem(Certificate *cert, Policy *policy) { try { SecKeychainAttribute attrs[2]; - const CssmData &data = cert->data(); + CssmAutoData certIndex(CssmAllocator::standard()); + UserTrustItem::makeCertIndex(cert, certIndex); attrs[0].tag = kSecTrustCertAttr; - attrs[0].length = data.length(); - attrs[0].data = data.data(); + attrs[0].length = certIndex.length(); + attrs[0].data = certIndex.data(); const CssmOid &policyOid = policy->oid(); attrs[1].tag = kSecTrustPolicyAttr; attrs[1].length = policyOid.length(); @@ -105,7 +112,7 @@ Item TrustStore::findItem(Certificate *cert, Policy *policy) return item; else return NULL; - } catch (const CssmError &error) { + } catch (const CssmCommonError &error) { if (error.cssmError() == CSSMERR_DL_INVALID_RECORDTYPE) return NULL; // no trust schema, no records, no error throw; @@ -125,12 +132,12 @@ CFArrayRef TrustStore::copyRootCertificates() } if (!mCFRoots) { uint32 count = mRoots.size(); - debug("anchors", "building %ld CF-style anchor certificates", count); + secdebug("anchors", "building %ld CF-style anchor certificates", count); vector roots(count); for (uint32 n = 0; n < count; n++) { - RefPointer cert = new Certificate(mRoots[n], + SecPointer cert = new Certificate(mRoots[n], CSSM_CERT_X_509v3, CSSM_CERT_ENCODING_BER); - roots[n] = gTypes().certificate.handle(*cert); + roots[n] = cert->handle(); } mCFRoots = CFArrayCreate(NULL, (const void **)&roots[0], count, &kCFTypeArrayCallBacks); @@ -153,7 +160,7 @@ void TrustStore::getCssmRootCertificates(CertGroup &rootCerts) void TrustStore::refreshRootCertificates() { if (mRootsValid) { - debug("anchors", "clearing %ld cached anchor certificates", mRoots.size()); + secdebug("anchors", "clearing %ld cached anchor certificates", mRoots.size()); // throw out the CF version if (mCFRoots) { @@ -185,7 +192,7 @@ void TrustStore::loadRootCertificates() static const char anchorLibrary[] = "/System/Library/Keychains/X509Anchors"; // open anchor database and formulate query (x509v3 certs) - debug("anchors", "Loading anchors from %s", anchorLibrary); + secdebug("anchors", "Loading anchors from %s", anchorLibrary); DL dl(gGuidAppleFileDL); Db db(dl, anchorLibrary); DbCursor search(db); @@ -203,7 +210,7 @@ void TrustStore::loadRootCertificates() ContainerList certs; for (;;) { DbUniqueRecord id; - last = certs.insert(certs.end()); + last = certs.insert(certs.end(), CssmDataContainer()); if (!search->next(NULL, &*last, id)) break; } @@ -222,7 +229,7 @@ void TrustStore::loadRootCertificates() mRoots.push_back(CssmData(base, it->length())); base += it->length(); } - debug("anchors", "%ld anchors loaded", mRoots.size()); + secdebug("anchors", "%ld anchors loaded", mRoots.size()); mRootsValid = true; // ready to roll } diff --git a/Keychain/TrustedApplication.cpp b/Keychain/TrustedApplication.cpp index b2a532cd..3c1037a7 100644 --- a/Keychain/TrustedApplication.cpp +++ b/Keychain/TrustedApplication.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include using namespace KeychainCore; @@ -60,7 +61,8 @@ TrustedApplication::TrustedApplication(const char *path) RefPointer object(OSXCode::at(path)); auto_ptr signature(signer.sign(*object)); mSignature = *signature; - mData = CssmData(const_cast(path), strlen(path) + 1); + string basePath = object->canonicalPath(); + mData = CssmData(const_cast(basePath.c_str()), basePath.length() + 1); } TrustedApplication::TrustedApplication() @@ -75,7 +77,7 @@ TrustedApplication::TrustedApplication() mData.copy(path.c_str(), path.length() + 1); // including trailing null } -TrustedApplication::~TrustedApplication() +TrustedApplication::~TrustedApplication() throw() { } @@ -85,6 +87,15 @@ TrustedApplication::signature() const return mSignature; } +const char * +TrustedApplication::path() const +{ + if (mData) + return mData.get().interpretedAs(); + else + return NULL; +} + bool TrustedApplication::sameSignature(const char *path) { @@ -116,6 +127,42 @@ TypedList TrustedApplication::makeSubject(CssmAllocator &allocator) return TypedList(allocator, CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE, new(allocator) ListElement(CSSM_ACL_CODE_SIGNATURE_OSX), - new(allocator) ListElement(mSignature.get()), - new(allocator) ListElement(mData.get())); + new(allocator) ListElement(allocator, mSignature.get()), + new(allocator) ListElement(allocator, mData.get())); +} + + +// +// On a completely different note... +// Read a simple text file from disk and cache the lines in a set. +// This is used during re-prebinding to cut down on the number of +// equivalency records being generated. +// This feature is otherwise completely unconnected to anything else here. +// +PathDatabase::PathDatabase(const char *path) +{ + if (FILE *f = fopen(path, "r")) { + mQualifyAll = false; + char path[PATH_MAX+1]; + while (fgets(path, sizeof(path), f)) { + path[strlen(path)-1] = '\0'; // strip NL + mPaths.insert(path); + } + fclose(f); + secdebug("equivdb", "read %ld paths from %s", mPaths.size(), path); + } else { + mQualifyAll = true; + secdebug("equivdb", "cannot open %s, will qualify all application paths", path); + } +} + + +bool PathDatabase::lookup(const string &path) +{ + string::size_type lastSlash = path.rfind('/'); + string::size_type bundleCore = path.find("/Contents/MacOS/"); + if (lastSlash != string::npos && bundleCore != string::npos) + if (bundleCore + 15 == lastSlash) + path = path.substr(0, bundleCore); + return mPaths.find(path) != mPaths.end(); } diff --git a/Keychain/TrustedApplication.h b/Keychain/TrustedApplication.h index 2b367fce..8f2dff7e 100644 --- a/Keychain/TrustedApplication.h +++ b/Keychain/TrustedApplication.h @@ -22,6 +22,7 @@ #define _SECURITY_TRUSTEDAPPLICATION_H_ #include +#include #include #include @@ -40,23 +41,27 @@ namespace KeychainCore { class TrustedApplication : public SecCFObject { NOCOPY(TrustedApplication) public: + SECCFFUNCTIONS(TrustedApplication, SecTrustedApplicationRef, errSecInvalidItemRef) + TrustedApplication(const TypedList &subject); TrustedApplication(const CssmData &signature, const CssmData &comment); TrustedApplication(const char *path); TrustedApplication(); // for current application - virtual ~TrustedApplication(); + virtual ~TrustedApplication() throw(); const CssmData &signature() const; // data (aka "comment") access const CssmData &data() const { return mData; } + const char *path() const; template void data(const Data &data) { mData = data; } TypedList makeSubject(CssmAllocator &allocator); -protected: bool sameSignature(const char *path); // return true if object at path has same signature + +protected: void calcSignature(const char *path, CssmOwnedData &signature); // generate a signature private: @@ -64,6 +69,25 @@ private: CssmAutoData mData; }; + +// +// A simple implementation of a caching path database in the system. +// +class PathDatabase { +public: + PathDatabase(const char *path = "/var/db/CodeEquivalenceCandidates"); + + bool operator [] (const std::string &path) + { return mQualifyAll || lookup(path); } + +private: + bool mQualifyAll; + set mPaths; + + bool lookup(const std::string &path); +}; + + } // end namespace KeychainCore } // end namespace Security diff --git a/Keychain/generateErrStrings.pl b/Keychain/generateErrStrings.pl new file mode 100644 index 00000000..8652bd87 --- /dev/null +++ b/Keychain/generateErrStrings.pl @@ -0,0 +1,83 @@ +#!/usr/bin/perl +# +# generatorX.pl - create error strings files from the Security header files +# +# John Hurley, Summer 2003. Based on generator.pl, Perry The Cynic, Fall 1999. +# +# Usage: +# perl generatorX.pl input-directory output-directory +# +# Currently supported files are SecBase.h, SecureTransport.h and Authorization.h +# +# perl generatorX.pl `pwd` `pwd` SecBase2.h SecureTransport2.h Authorization.h +# +# Input will be like: +# +# errSSLProtocol = -9800, /* SSL protocol error */ +# errSSLNegotiation = -9801, /* Cipher Suite negotiation failure */ +# +# Output should be like (in Unicode): +# +# /* errSSLProtocol */ +# "-9800" = "SSL protocol error"; +# +# /* errSSLNegotiation */ +# "-9801" = "Cipher Suite negotiation failure"; +# +# Note that the list of errors must be numerically unique across all input files, or the strings file +# will be invalid.Comments that span multiple lines will be ignored, as will lines with no comment. C++ +# style comments are not supported. +# + +use Encode; + +$SOURCEDIR=$ARGV[0]; # directory with error headers +$TARGETDIR=$ARGV[1]; # where to put the output file +@INPUTFILES=@ARGV[2 .. 9999]; # list of input files + +$TABLES="$TARGETDIR/SecErrorMessages.strings"; # error strings + +$tabs = "\t\t\t"; # argument indentation (noncritical) +$warning = "This file was automatically generated. Do not edit on penalty of futility!"; + +# +# Parse error headers and build array of all relevant lines +# + +open(ERR, "cat " . join(" ", @INPUTFILES) . "|") or die "Cannot open error header files"; +$/=undef; # still gulping +$_ = ; +@errorlines = m{(?:^\s*)(err[Sec|Authorization|SSL]\w+)(?:\s*=\s*)(-?\d+)(?:\s*,?\s*)(?:/\*\s*)(.*)(?:\*/)(?:$\s*)}gm; +close(ERR); + +$nFull = $#errorlines / 3; + +# +# Now we will generate the error name tables. +# + +open(OUT, ">$TABLES") or die "Cannot write $TABLES: $^E"; +select OUT; + +# Print warning comment +$msg = "//\n// Security error code tables.\n// $warning\n//\n"; + +# Print the error messages +while ($errx = shift @errorlines) +{ + $value = shift @errorlines; # or die; + $str = shift @errorlines; # or die; + $str =~ s/\s*$//; # drop trailing white space + if ( $value != 0) # can't output duplicate error codes + { + $msg = $msg . "\n/* $errx */\n\"$value\" = \"$str\";\n"; + } +}; +$msg = $msg . "\n"; +$output = encode("UTF-16", $msg, Encode::FB_PERLQQ); +print "$output"; + +close(OUT); +select(STDOUT); + +#print "$nFull errors available to error translation functions.\n"; diff --git a/Keychain/iToolsTrustedApps.plist b/Keychain/iToolsTrustedApps.plist new file mode 100644 index 00000000..d3c5c8e3 --- /dev/null +++ b/Keychain/iToolsTrustedApps.plist @@ -0,0 +1,12 @@ + + + + + /Applications/Mail.app + /Applications/iChat.app + /Applications/iSync.app + /Applications/System Preferences.app + /System/Library/PrivateFrameworks/InstantMessage.framework/iChatAgent.app + /System/Library/CoreServices/SyncServer.app + + diff --git a/Keychain/srCdsaUtils.cpp b/Keychain/srCdsaUtils.cpp new file mode 100644 index 00000000..a5f1b65b --- /dev/null +++ b/Keychain/srCdsaUtils.cpp @@ -0,0 +1,553 @@ +/* + File: srCdsaUtils.cpp + + Description: common CDSA access utilities + + Author: dmitch + + Copyright: © Copyright 2001 Apple Computer, Inc. All rights reserved. + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Computer, Inc. ("Apple") in consideration of your agreement to + the following terms, and your use, installation, modification + or redistribution of this Apple software constitutes acceptance + of these terms. If you do not agree with these terms, please + do not use, install, modify or redistribute this Apple software. + + In consideration of your agreement to abide by the following + terms, and subject to these terms, Apple grants you a personal, + non-exclusive license, under Apple's copyrights in this + original Apple software (the "Apple Software"), to use, + reproduce, modify and redistribute the Apple Software, with + or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in + its entirety and without modifications, you must retain + this notice and the following text and disclaimers in all + such redistributions of the Apple Software. Neither the + name, trademarks, service marks or logos of Apple Computer, + Inc. may be used to endorse or promote products derived from the + Apple Software without specific prior written permission from + Apple. Except as expressly stated in this notice, no other + rights or licenses, express or implied, are granted by Apple + herein, including but not limited to any patent rights that + may be infringed by your derivative works or by other works + in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. + APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, + REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE + OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, + INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION + AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING + NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE + HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "srCdsaUtils.h" +#include +#include +#include +#include /* for cssmPerror() */ +#include /* for cssmPerror() */ +#include + +static CSSM_VERSION vers = {2, 0}; +static const CSSM_GUID testGuid = { 0xFADE, 0, 0, { 1,2,3,4,5,6,7,0 }}; + +/* + * Standard app-level memory functions required by CDSA. + */ +void * srAppMalloc (uint32 size, void *allocRef) { + return( malloc(size) ); +} + +void srAppFree (void *mem_ptr, void *allocRef) { + free(mem_ptr); + return; +} + +void * srAppRealloc (void *ptr, uint32 size, void *allocRef) { + return( realloc( ptr, size ) ); +} + +void * srAppCalloc (uint32 num, uint32 size, void *allocRef) { + return( calloc( num, size ) ); +} + +static CSSM_API_MEMORY_FUNCS memFuncs = { + srAppMalloc, + srAppFree, + srAppRealloc, + srAppCalloc, + NULL + }; + +CSSM_BOOL srCompareCssmData(const CSSM_DATA *d1, + const CSSM_DATA *d2) +{ + if(d1->Length != d2->Length) { + return CSSM_FALSE; + } + if(memcmp(d1->Data, d2->Data, d1->Length)) { + return CSSM_FALSE; + } + return CSSM_TRUE; +} + +/* + * Init CSSM; returns CSSM_FALSE on error. Reusable. + */ +static CSSM_BOOL cssmInitd = CSSM_FALSE; + +CSSM_BOOL srCssmStartup() +{ + CSSM_RETURN crtn; + CSSM_PVC_MODE pvcPolicy = CSSM_PVC_NONE; + + if(cssmInitd) { + return CSSM_TRUE; + } + crtn = CSSM_Init (&vers, + CSSM_PRIVILEGE_SCOPE_NONE, + &testGuid, + CSSM_KEY_HIERARCHY_NONE, + &pvcPolicy, + NULL /* reserved */); + if(crtn != CSSM_OK) + { + srPrintError("CSSM_Init", crtn); + return CSSM_FALSE; + } + else { + cssmInitd = CSSM_TRUE; + return CSSM_TRUE; + } +} + +/* + * Attach to CSP. Returns zero on error. + */ +CSSM_CSP_HANDLE srCspStartup( + CSSM_BOOL bareCsp) // true ==> CSP, false ==> CSP/DL +{ + CSSM_CSP_HANDLE cspHand; + CSSM_RETURN crtn; + const CSSM_GUID *guid; + + /* common CSSM init */ + if(srCssmStartup() == CSSM_FALSE) { + return 0; + } + if(bareCsp) { + guid = &gGuidAppleCSP; + } + else { + guid = &gGuidAppleCSPDL; + } + crtn = CSSM_ModuleLoad(guid, + CSSM_KEY_HIERARCHY_NONE, + NULL, // eventHandler + NULL); // AppNotifyCallbackCtx + if(crtn) { + srPrintError("CSSM_ModuleLoad()", crtn); + return 0; + } + crtn = CSSM_ModuleAttach (guid, + &vers, + &memFuncs, // memFuncs + 0, // SubserviceID + CSSM_SERVICE_CSP, + 0, // AttachFlags + CSSM_KEY_HIERARCHY_NONE, + NULL, // FunctionTable + 0, // NumFuncTable + NULL, // reserved + &cspHand); + if(crtn) { + srPrintError("CSSM_ModuleAttach()", crtn); + return 0; + } + return cspHand; +} + +/* Attach to DL side of CSPDL */ +CSSM_DL_HANDLE srDlStartup() +{ + CSSM_DL_HANDLE dlHand = 0; + CSSM_RETURN crtn; + + if(srCssmStartup() == CSSM_FALSE) { + return 0; + } + crtn = CSSM_ModuleLoad(&gGuidAppleCSPDL, + CSSM_KEY_HIERARCHY_NONE, + NULL, // eventHandler + NULL); // AppNotifyCallbackCtx + if(crtn) { + srPrintError("CSSM_ModuleLoad(Apple CSPDL)", crtn); + return 0; + } + crtn = CSSM_ModuleAttach (&gGuidAppleCSPDL, + &vers, + &memFuncs, // memFuncs + 0, // SubserviceID + CSSM_SERVICE_DL, + 0, // AttachFlags + CSSM_KEY_HIERARCHY_NONE, + NULL, // FunctionTable + 0, // NumFuncTable + NULL, // reserved + &dlHand); + if(crtn) { + srPrintError("CSSM_ModuleAttach(Apple CSPDL)", crtn); + return 0; + } + return dlHand; +} + +CSSM_CL_HANDLE srClStartup() +{ + CSSM_CL_HANDLE clHand; + CSSM_RETURN crtn; + + if(srCssmStartup() == CSSM_FALSE) { + return 0; + } + crtn = CSSM_ModuleLoad(&gGuidAppleX509CL, + CSSM_KEY_HIERARCHY_NONE, + NULL, // eventHandler + NULL); // AppNotifyCallbackCtx + if(crtn) { + srPrintError("CSSM_ModuleLoad(AppleCL)", crtn); + return 0; + } + crtn = CSSM_ModuleAttach (&gGuidAppleX509CL, + &vers, + &memFuncs, // memFuncs + 0, // SubserviceID + CSSM_SERVICE_CL, // SubserviceFlags - Where is this used? + 0, // AttachFlags + CSSM_KEY_HIERARCHY_NONE, + NULL, // FunctionTable + 0, // NumFuncTable + NULL, // reserved + &clHand); + if(crtn) { + srPrintError("CSSM_ModuleAttach(AppleCL)", crtn); + return 0; + } + else { + return clHand; + } +} + +CSSM_TP_HANDLE srTpStartup() +{ + CSSM_TP_HANDLE tpHand; + CSSM_RETURN crtn; + + if(srCssmStartup() == CSSM_FALSE) { + return 0; + } + crtn = CSSM_ModuleLoad(&gGuidAppleX509TP, + CSSM_KEY_HIERARCHY_NONE, + NULL, // eventHandler + NULL); // AppNotifyCallbackCtx + if(crtn) { + srPrintError("CSSM_ModuleLoad(AppleTP)", crtn); + return 0; + } + crtn = CSSM_ModuleAttach (&gGuidAppleX509TP, + &vers, + &memFuncs, // memFuncs + 0, // SubserviceID + CSSM_SERVICE_TP, // SubserviceFlags + 0, // AttachFlags + CSSM_KEY_HIERARCHY_NONE, + NULL, // FunctionTable + 0, // NumFuncTable + NULL, // reserved + &tpHand); + if(crtn) { + srPrintError("CSSM_ModuleAttach(AppleTP)", crtn); + return 0; + } + else { + return tpHand; + } +} + +/* + * Given a context specified via a CSSM_CC_HANDLE, add a new + * CSSM_CONTEXT_ATTRIBUTE to the context as specified by AttributeType, + * AttributeLength, and an untyped pointer. + */ +CSSM_RETURN srAddContextAttribute(CSSM_CC_HANDLE CCHandle, + uint32 AttributeType, + uint32 AttributeLength, + const void *AttributePtr) +{ + CSSM_CONTEXT_ATTRIBUTE newAttr; + CSSM_RETURN crtn; + + newAttr.AttributeType = AttributeType; + newAttr.AttributeLength = AttributeLength; + newAttr.Attribute.Data = (CSSM_DATA_PTR)AttributePtr; + crtn = CSSM_UpdateContextAttributes(CCHandle, 1, &newAttr); + if(crtn) { + srPrintError("CSSM_UpdateContextAttributes", crtn); + } + return crtn; +} + + +/* + * Derive symmetric key. + * Note in the X CSP, we never return an IV. + */ +CSSM_RETURN srCspDeriveKey(CSSM_CSP_HANDLE cspHand, + uint32 keyAlg, // CSSM_ALGID_RC5, etc. + const char *keyLabel, + unsigned keyLabelLen, + uint32 keyUsage, // CSSM_KEYUSE_ENCRYPT, etc. + uint32 keySizeInBits, + CSSM_DATA_PTR password, // in PKCS-5 lingo + CSSM_DATA_PTR salt, // ditto + uint32 iterationCnt, // ditto + CSSM_KEY_PTR key) +{ + CSSM_RETURN crtn; + CSSM_CC_HANDLE ccHand; + uint32 keyAttr; + CSSM_DATA dummyLabel; + CSSM_PKCS5_PBKDF2_PARAMS pbeParams; + CSSM_DATA pbeData; + CSSM_ACCESS_CREDENTIALS creds; + + memset(key, 0, sizeof(CSSM_KEY)); + memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS)); + crtn = CSSM_CSP_CreateDeriveKeyContext(cspHand, + CSSM_ALGID_PKCS5_PBKDF2, + keyAlg, + keySizeInBits, + &creds, + NULL, // BaseKey + iterationCnt, + salt, + NULL, // seed + &ccHand); + if(crtn) { + srPrintError("CSSM_CSP_CreateDeriveKeyContext", crtn); + return crtn; + } + keyAttr = CSSM_KEYATTR_EXTRACTABLE | CSSM_KEYATTR_RETURN_REF | + CSSM_KEYATTR_SENSITIVE; + dummyLabel.Length = keyLabelLen; + dummyLabel.Data = (uint8 *)keyLabel; + + /* passing in password is pretty strange....*/ + pbeParams.Passphrase = *password; + pbeParams.PseudoRandomFunction = CSSM_PKCS5_PBKDF2_PRF_HMAC_SHA1; + pbeData.Data = (uint8 *)&pbeParams; + pbeData.Length = sizeof(pbeParams); + crtn = CSSM_DeriveKey(ccHand, + &pbeData, + keyUsage, + keyAttr, + &dummyLabel, + NULL, // cred and acl + key); + if(crtn) { + srPrintError("CSSM_DeriveKey", crtn); + return crtn; + } + crtn = CSSM_DeleteContext(ccHand); + if(crtn) { + srPrintError("CSSM_DeleteContext", crtn); + } + return crtn; +} + +/* + * Generate key pair of arbitrary algorithm. + */ + +/* CSP DL currently does not perform DSA generate params; let CSP do it implicitly */ +#define DO_DSA_GEN_PARAMS 0 + +CSSM_RETURN srCspGenKeyPair(CSSM_CSP_HANDLE cspHand, + CSSM_DL_DB_HANDLE *dlDbHand, // optional + uint32 algorithm, + const char *keyLabel, + unsigned keyLabelLen, + uint32 keySize, // in bits + CSSM_KEY_PTR pubKey, // mallocd by caller + CSSM_KEYUSE pubKeyUsage, // CSSM_KEYUSE_ENCRYPT, etc. + CSSM_KEYATTR_FLAGS pubAttrs, // CSSM_KEYATTR_EXTRACTABLE, etc. + CSSM_KEY_PTR privKey, // mallocd by caller + CSSM_KEYUSE privKeyUsage, // CSSM_KEYUSE_DECRYPT, etc. + CSSM_KEYATTR_FLAGS privAttrs) // CSSM_KEYATTR_EXTRACTABLE, etc. +{ + CSSM_RETURN crtn; + CSSM_RETURN ocrtn; + CSSM_CC_HANDLE ccHand; + CSSM_DATA keyLabelData; + + keyLabelData.Data = (uint8 *)keyLabel, + keyLabelData.Length = keyLabelLen; + memset(pubKey, 0, sizeof(CSSM_KEY)); + memset(privKey, 0, sizeof(CSSM_KEY)); + + crtn = CSSM_CSP_CreateKeyGenContext(cspHand, + algorithm, + keySize, + NULL, // Seed + NULL, // Salt + NULL, // StartDate + NULL, // EndDate + NULL, // Params + &ccHand); + if(crtn) { + srPrintError("CSSM_CSP_CreateKeyGenContext", crtn); + return crtn; + } + + /* post-context-create algorithm-specific stuff */ + switch(algorithm) { + #if DO_DSA_GEN_PARAMS + case CSSM_ALGID_DSA: + /* + * extra step - generate params - this just adds some + * info to the context + */ + { + CSSM_DATA dummy = {0, NULL}; + crtn = CSSM_GenerateAlgorithmParams(ccHand, + keySize, &dummy); + if(crtn) { + srPrintError("CSSM_GenerateAlgorithmParams", crtn); + CSSM_DeleteContext(ccHand); + return crtn; + } + srAppFree(dummy.Data, NULL); + } + break; + #endif /* DO_DSA_GEN_PARAMS */ + default: + break; + } + + /* optionally specify DL/DB storage location */ + if(dlDbHand) { + crtn = srAddContextAttribute(ccHand, + CSSM_ATTRIBUTE_DL_DB_HANDLE, + sizeof(CSSM_ATTRIBUTE_DL_DB_HANDLE), + dlDbHand); + if(crtn) { + CSSM_DeleteContext(ccHand); + return crtn; + } + } + ocrtn = CSSM_GenerateKeyPair(ccHand, + pubKeyUsage, + pubAttrs, + &keyLabelData, + pubKey, + privKeyUsage, + privAttrs, + &keyLabelData, // same labels + NULL, // CredAndAclEntry + privKey); + if(ocrtn) { + srPrintError("CSSM_GenerateKeyPair", ocrtn); + } + crtn = CSSM_DeleteContext(ccHand); + if(crtn) { + srPrintError("CSSM_DeleteContext", crtn); + if(ocrtn == CSSM_OK) { + /* error on CSSM_GenerateKeyPair takes precedence */ + ocrtn = crtn; + } + } + return ocrtn; +} + + +/* + * Add a certificate to an open Keychain. + */ +CSSM_RETURN srAddCertToKC( + SecKeychainRef keychain, + const CSSM_DATA *cert, + CSSM_CERT_TYPE certType, + CSSM_CERT_ENCODING certEncoding, + const char *printName, // C string + const CSSM_DATA *keyLabel) // ?? +{ + SecCertificateRef certificate; + + OSStatus rslt = SecCertificateCreateFromData(cert, certType, certEncoding, &certificate); + if (!rslt) + { + rslt = SecCertificateAddToKeychain(certificate, keychain); + CFRelease(certificate); + } + + return rslt; +} + +/* + * Convert a CSSM_DATA_PTR, referring to a DER-encoded int, to an + * unsigned. + */ +unsigned srDER_ToInt(const CSSM_DATA *DER_Data) +{ + uint32 rtn = 0; + unsigned i = 0; + + while(i < DER_Data->Length) { + rtn |= DER_Data->Data[i]; + if(++i == DER_Data->Length) { + break; + } + rtn <<= 8; + } + return rtn; +} + +/* + * Log CSSM error. + */ +void srPrintError(char *op, CSSM_RETURN err) +{ + cssmPerror(op, err); +} + +/* + * Convert a CFString into a C string as safely as we can. Caller must + * free the result. + */ +char *srCfStrToCString( + CFStringRef cfStr) +{ + CFIndex len = CFStringGetLength(cfStr) + 1; + char *cstr = (char *)malloc(len); + if(cstr == NULL) { + return NULL; + } + if(!CFStringGetCString(cfStr, cstr, len, kCFStringEncodingASCII)) { + printf("***CFStringGetCString error\n"); + free(cstr); + return NULL; + } + return cstr; +} + diff --git a/CertTool/cdsaUtils/cdsaUtils.h b/Keychain/srCdsaUtils.h similarity index 75% rename from CertTool/cdsaUtils/cdsaUtils.h rename to Keychain/srCdsaUtils.h index 20099582..4133a3c1 100644 --- a/CertTool/cdsaUtils/cdsaUtils.h +++ b/Keychain/srCdsaUtils.h @@ -1,5 +1,5 @@ /* - File: cdsaUtils.h + File: srCdsaUtils.h Description: common CDSA access utilities @@ -56,56 +56,50 @@ #include #include +#include #ifdef __cplusplus extern "C" { #endif /* common memory allocators shared by app and CSSM */ -extern void * cuAppMalloc (uint32 size, void *allocRef); -extern void cuAppFree (void *mem_ptr, void *allocRef); -extern void * cuAppRealloc (void *ptr, uint32 size, void *allocRef); -extern void * cuAppCalloc (uint32 num, uint32 size, void *allocRef); +extern void * srAppMalloc (uint32 size, void *allocRef); +extern void srAppFree (void *mem_ptr, void *allocRef); +extern void * srAppRealloc (void *ptr, uint32 size, void *allocRef); +extern void * srAppCalloc (uint32 num, uint32 size, void *allocRef); -#define APP_MALLOC(s) cuAppMalloc(s, NULL) -#define APP_FREE(p) cuAppFree(p, NULL) -#define APP_REALLOC(p, s) cuAppRealloc(p, s, NULL) -#define APP_CALLOC(n, s) cuAppRealloc(n, s, NULL) +#define APP_MALLOC(s) srAppMalloc(s, NULL) +#define APP_FREE(p) srAppFree(p, NULL) +#define APP_REALLOC(p, s) srAppRealloc(p, s, NULL) +#define APP_CALLOC(n, s) srAppRealloc(n, s, NULL) -extern CSSM_BOOL cuCompareCssmData( +extern CSSM_BOOL srCompareCssmData( const CSSM_DATA *d1, const CSSM_DATA *d2); -void cuPrintError(char *op, CSSM_RETURN err); + +/* OID flavor of same, which will break when an OID is not a CSSM_DATA */ +#define srCompareOid(o1, o2) srCompareCssmData(o1, o2) + +void srPrintError(char *op, CSSM_RETURN err); /* Init CSSM; returns CSSM_FALSE on error. Reusable. */ -extern CSSM_BOOL cuCssmStartup(); +extern CSSM_BOOL srCssmStartup(); /* Attach to CSP. Returns zero on error. */ -extern CSSM_CSP_HANDLE cuCspStartup( +extern CSSM_CSP_HANDLE srCspStartup( CSSM_BOOL bareCsp); // true ==> CSP, false ==> CSP/DL /* Attach to DL side of CSPDL. */ -extern CSSM_DL_HANDLE cuDlStartup(); +extern CSSM_DL_HANDLE srDlStartup(); /* Attach to CL, TP */ -extern CSSM_CL_HANDLE cuClStartup(); -extern CSSM_TP_HANDLE cuTpStartup(); - -/* Open a DB, ensure it's empty. */ -CSSM_DB_HANDLE cuDbStartup( - CSSM_DL_HANDLE dlHand, // from dlStartup() - const char *dbName); - -/* Attach to existing DB or create an empty new one. */ -CSSM_DB_HANDLE cuDbStartupByName(CSSM_DL_HANDLE dlHand, - char *dbName, - CSSM_BOOL doCreate, - CSSM_BOOL quiet); +extern CSSM_CL_HANDLE srClStartup(); +extern CSSM_TP_HANDLE srTpStartup(); /* * Derive symmetric key using PBE. */ -extern CSSM_RETURN cuCspDeriveKey(CSSM_CSP_HANDLE cspHand, +extern CSSM_RETURN srCspDeriveKey(CSSM_CSP_HANDLE cspHand, uint32 keyAlg, // CSSM_ALGID_RC5, etc. const char *keyLabel, unsigned keyLabelLen, @@ -119,7 +113,7 @@ extern CSSM_RETURN cuCspDeriveKey(CSSM_CSP_HANDLE cspHand, /* * Generate key pair of arbitrary algorithm. */ -extern CSSM_RETURN cuCspGenKeyPair(CSSM_CSP_HANDLE cspHand, +extern CSSM_RETURN srCspGenKeyPair(CSSM_CSP_HANDLE cspHand, CSSM_DL_DB_HANDLE *dlDbHand, // optional uint32 algorithm, const char *keyLabel, @@ -133,25 +127,14 @@ extern CSSM_RETURN cuCspGenKeyPair(CSSM_CSP_HANDLE cspHand, CSSM_KEYATTR_FLAGS privAttrs); // CSSM_KEYATTR_EXTRACTABLE, etc. /* Convert a reference key to a raw key. */ -CSSM_RETURN cuRefKeyToRaw(CSSM_CSP_HANDLE cspHand, +CSSM_RETURN srRefKeyToRaw(CSSM_CSP_HANDLE cspHand, const CSSM_KEY *refKey, CSSM_KEY_PTR rawKey); // RETURNED -/* - * Add a certificate to an open DLDB. - */ -CSSM_RETURN cuAddCertToDb( - CSSM_DL_DB_HANDLE dlDbHand, - const CSSM_DATA *cert, - CSSM_CERT_TYPE certType, - CSSM_CERT_ENCODING certEncoding, - const char *printName, // C string - const CSSM_DATA *publicKeyHash); // ?? - /* * Add a certificate to a keychain. */ -CSSM_RETURN cuAddCertToKC( +CSSM_RETURN srAddCertToKC( SecKeychainRef keychain, const CSSM_DATA *cert, CSSM_CERT_TYPE certType, @@ -159,6 +142,16 @@ CSSM_RETURN cuAddCertToKC( const char *printName, // C string const CSSM_DATA *keyLabel); // ?? +/* + * Convert a CSSM_DATA_PTR, referring to a DER-encoded int, to an + * unsigned. + */ +unsigned srDER_ToInt( + const CSSM_DATA *DER_Data); + +char *srCfStrToCString( + CFStringRef cfStr); + #ifdef __cplusplus } #endif diff --git a/Network/connectionpool.cpp b/Network/connectionpool.cpp index c43f2603..bea735d4 100644 --- a/Network/connectionpool.cpp +++ b/Network/connectionpool.cpp @@ -39,7 +39,7 @@ Connection *ConnectionPool::get(const HostTarget &host) // take it and use it Connection *connection = it->second; mConnections.erase(it); - debug("connpool", "Connection %p retrieved from pool", connection); + secdebug("connpool", "Connection %p retrieved from pool", connection); return connection; } // none available @@ -53,7 +53,7 @@ Connection *ConnectionPool::get(const HostTarget &host) void ConnectionPool::retain(Connection *connection) { //@@@ threading, of course :-) - debug("connpool", "Connection %p retained in connection pool", connection); + secdebug("connpool", "Connection %p retained in connection pool", connection); mConnections.insert(ConnectionMap::value_type(connection->hostTarget, connection)); //mConnections[connection->hostTarget] = connection; } @@ -71,7 +71,7 @@ bool ConnectionPool::remove(Connection *connection) for (Iter it = range.first; it != range.second; it++) if (it->second == connection) { mConnections.erase(it); - debug("connpool", "Connection %p removed from connection pool", connection); + secdebug("connpool", "Connection %p removed from connection pool", connection); return true; } return false; @@ -83,7 +83,7 @@ bool ConnectionPool::remove(Connection *connection) // void ConnectionPool::purge() { - IFDEBUG(debug("connpool", "Connection pool purging %ld connections", mConnections.size())); + secdebug("connpool", "Connection pool purging %ld connections", mConnections.size()); for (ConnectionMap::iterator it = mConnections.begin(); it != mConnections.end(); it++) delete it->second; mConnections.erase(mConnections.begin(), mConnections.end()); diff --git a/Network/connectionpool.h b/Network/connectionpool.h index 6dd7e1d1..704b9771 100644 --- a/Network/connectionpool.h +++ b/Network/connectionpool.h @@ -56,4 +56,4 @@ private: } // end namespace Security -#endif _H_CONNECTIONPOOL +#endif /* _H_CONNECTIONPOOL */ diff --git a/Network/ftp-protocol.cpp b/Network/ftp-protocol.cpp index ae945682..4e700136 100644 --- a/Network/ftp-protocol.cpp +++ b/Network/ftp-protocol.cpp @@ -433,14 +433,14 @@ bool FTPProtocol::FTPConnection::validate() // void FTPProtocol::FTPDataConnection::start(Sink &sink) { - debug("ftp", "data connection starts download"); + secdebug("ftp", "data connection starts download"); setup(); mode(sink); } void FTPProtocol::FTPDataConnection::start(Source &source) { - debug("ftp", "data connection starts upload"); + secdebug("ftp", "data connection starts upload"); setup(); mode(source); } @@ -461,7 +461,7 @@ int FTPProtocol::FTPDataConnection::fileDesc() const void FTPProtocol::FTPDataConnection::transit(Event event, char *input, size_t length) { assert(event == autoReadDone || event == autoWriteDone || event == endOfInput); - debug("ftp", "data transfer complete"); + secdebug("ftp", "data transfer complete"); close(); // close data path finish(); // proceed with state protocol } @@ -496,9 +496,9 @@ void FTPProtocol::FTPDataConnection::finish() } else if (mTransferDone && mConnectionDone) { connection.finish(); } else if (mConnectionDone) { - debug("ftp", "holding for data transfer completion"); + secdebug("ftp", "holding for data transfer completion"); } else { - debug("ftp", "holding for control message"); + secdebug("ftp", "holding for control message"); } } diff --git a/Network/ftp-proxy-protocol.cpp b/Network/ftp-proxy-protocol.cpp index 9ce4ef34..7290b8bf 100644 --- a/Network/ftp-proxy-protocol.cpp +++ b/Network/ftp-proxy-protocol.cpp @@ -32,7 +32,7 @@ namespace Network { FTPProxyProtocol::FTPProxyProtocol(Manager &mgr, const HostTarget &proxy) : FTPProtocol(mgr), host(proxy.defaultPort(defaultFtpPort)) { - debug("uaproxy", "%p ftp proxy for %s", this, host.urlForm().c_str()); + secdebug("uaproxy", "%p ftp proxy for %s", this, host.urlForm().c_str()); } diff --git a/Network/http-protocol.cpp b/Network/http-protocol.cpp index 6a94d92f..34450cf0 100644 --- a/Network/http-protocol.cpp +++ b/Network/http-protocol.cpp @@ -318,11 +318,11 @@ void HTTPProtocol::HTTPConnection::transit(Event event, char *input, size_t leng if (length == 0 || endOfMatch == input) // no valid number fail(Transfer::remoteFailure); if (chunkLength) { - debug("http", "reading chunk of %ld bytes", chunkLength); + secdebug("http", "reading chunk of %ld bytes", chunkLength); mode(sink(), chunkLength); state = chunkDownload; } else { - debug("http", "final chunk marker"); + secdebug("http", "final chunk marker"); state = chunkTrailer; observe(Observer::protocolReceive, "** END OF DATA **"); } @@ -361,7 +361,7 @@ void HTTPProtocol::HTTPConnection::transit(Event event, char *input, size_t leng case idle: { // the only asynchronous event in idle mode is a connection drop - debug("http", + secdebug("http", "%p event %d while idle; destroying connection", this, event); abort(); state = dead; diff --git a/Network/http-proxy-protocol.cpp b/Network/http-proxy-protocol.cpp index b35cb159..28a0de93 100644 --- a/Network/http-proxy-protocol.cpp +++ b/Network/http-proxy-protocol.cpp @@ -32,7 +32,7 @@ namespace Network { HTTPProxyProtocol::HTTPProxyProtocol(Manager &mgr, const HostTarget &proxy) : HTTPProtocol(mgr), host(proxy.defaultPort(defaultHttpPort)) { - debug("uaproxy", "%p http proxy for %s", this, host.urlForm().c_str()); + secdebug("uaproxy", "%p http proxy for %s", this, host.urlForm().c_str()); } diff --git a/Network/multiobserver.h b/Network/multiobserver.h index a0ad9423..c1e53850 100644 --- a/Network/multiobserver.h +++ b/Network/multiobserver.h @@ -60,4 +60,4 @@ private: } // end namespace Security -#endif _H_MULTIPLEXOBSERVER +#endif /* _H_MULTIPLEXOBSERVER */ diff --git a/Network/netconnection.cpp b/Network/netconnection.cpp index f3edb070..89088abf 100644 --- a/Network/netconnection.cpp +++ b/Network/netconnection.cpp @@ -37,7 +37,7 @@ namespace Network { Connection::Connection(Protocol &proto, const HostTarget &host) : protocol(proto), hostTarget(host), mTransfer(NULL), mRetainMe(false), mRestarting(false) { - debug("netconn", + secdebug("netconn", "connection %p created for %s", this, hostTarget.urlForm().c_str()); } @@ -48,7 +48,7 @@ Connection::Connection(Protocol &proto, const HostTarget &host) Connection::~Connection() { assert(!isDocked()); - debug("netconn", "connection %p destroyed", this); + secdebug("netconn", "connection %p destroyed", this); } @@ -61,7 +61,7 @@ void Connection::dock(Transfer *xfer) assert(!xfer->isDocked()); mTransfer = xfer; xfer->mConnection = this; - debug("netconn", "connection %p docked xfer %p", this, xfer); + secdebug("netconn", "connection %p docked xfer %p", this, xfer); } @@ -80,7 +80,7 @@ void Connection::undock() bool retain = mRetainMe && mTransfer->shareConnections(); // physically sever our relationship with the Transfer - debug("netconn", "connection %p undocking xfer %p", this, mTransfer); + secdebug("netconn", "connection %p undocking xfer %p", this, mTransfer); mTransfer->mConnection = NULL; mTransfer = NULL; @@ -121,7 +121,7 @@ void Connection::restart() { if (mRestarting) { Transfer *transfer = mTransfer; - debug("netconn", "%p restarting xfer %p", this, transfer); + secdebug("netconn", "%p restarting xfer %p", this, transfer); // throw outselves out retain(false); diff --git a/Network/netconnection.h b/Network/netconnection.h index 247d7abc..b34347c5 100644 --- a/Network/netconnection.h +++ b/Network/netconnection.h @@ -152,4 +152,4 @@ private: } // end namespace Security -#endif _H_NETCONNECTION +#endif /* _H_NETCONNECTION */ diff --git a/Network/neterror.h b/Network/neterror.h index 33c85bc1..29b2d56e 100644 --- a/Network/neterror.h +++ b/Network/neterror.h @@ -47,4 +47,4 @@ public: } // end namespace Security -#endif _H_NETERROR +#endif /* _H_NETERROR */ diff --git a/Network/netmanager.cpp b/Network/netmanager.cpp index 433d9e95..4b2dc50b 100644 --- a/Network/netmanager.cpp +++ b/Network/netmanager.cpp @@ -80,10 +80,10 @@ void Manager::start(Transfer *xfer) xfer->mState = Transfer::active; xfer->observe(Observer::transferStarting); mActiveTransfers++; - debug("netmanager", "%ld active transfers", mActiveTransfers); + secdebug("netmanager", "%ld active transfers", mActiveTransfers); } catch (...) { xfer->mState = Transfer::failed; - debug("netmanager", "Transfer %p failed to start", xfer); + secdebug("netmanager", "Transfer %p failed to start", xfer); throw; } } @@ -104,17 +104,17 @@ void Manager::abort(Transfer *xfer) switch (xfer->state()) { case Transfer::active: try { - debug("netmanager", "xfer %p request abort", xfer); + secdebug("netmanager", "xfer %p request abort", xfer); xfer->abort(); } catch (...) { - debug("netmanager", "xfer %p failed to abort; forcing the issue", xfer); + secdebug("netmanager", "xfer %p failed to abort; forcing the issue", xfer); xfer->Transfer::abort(); } break; case Transfer::finished: case Transfer::failed: // no longer running; ignore cancel request - debug("netmanager", "xfer %p abort ignored (already done)", xfer); + secdebug("netmanager", "xfer %p abort ignored (already done)", xfer); break; default: assert(false); // mustn't call in this state @@ -133,7 +133,7 @@ void Manager::done(Transfer *xfer) assert(xfer->state() == Transfer::finished || xfer->state() == Transfer::failed); assert(mActiveTransfers > 0); mActiveTransfers--; - debug("netmanager", "%ld active transfers", mActiveTransfers); + secdebug("netmanager", "%ld active transfers", mActiveTransfers); } @@ -182,7 +182,7 @@ Connection *Manager::pickConnection(const HostTarget &host) return connection; // good to go } // if validate returned false, the connection has self-destructed (so ignore it) - debug("netmanager", "%p connection %p failed to validate", + secdebug("netmanager", "%p connection %p failed to validate", this, connection); } return NULL; // no joy, caller must make a new one @@ -222,13 +222,13 @@ void Manager::clearTimer(Timer *timer) void Manager::runTimers() { while (Timer *top = static_cast(mTimers.pop(Time::now()))) { - debug("netmanager", "%p timer %p executing at %.3f", + secdebug("netmanager", "%p timer %p executing at %.3f", this, top, Time::now().internalForm()); try { top->action(); - debug("machsrvtime", "%p timer %p done", this, top); + secdebug("machsrvtime", "%p timer %p done", this, top); } catch (...) { - debug("machsrvtime", + secdebug("machsrvtime", "%p server timer %p failed with exception", this, top); } } @@ -242,7 +242,7 @@ void Manager::step() { prepare(); if (!mEngine.isEmpty()) { - debug("mgrstep", "operations step"); + secdebug("mgrstep", "operations step"); mEngine(); } } @@ -253,7 +253,7 @@ void Manager::step() // void Manager::run(Time::Absolute stopTime) { - debug("netmanager", + secdebug("netmanager", "starting run with %ld active transfers", mActiveTransfers); while (mActiveTransfers > 0) { prepare(); @@ -262,7 +262,7 @@ void Manager::run(Time::Absolute stopTime) if (Time::now() > stopTime) break; } - debug("netmanager", "ending run"); + secdebug("netmanager", "ending run"); } void Manager::run() @@ -278,7 +278,7 @@ void Manager::prepare() { // clear the morgue if (!mMorgue.empty()) { - debug("netmanager", + secdebug("netmanager", "clearing morgue of %ld connections", mMorgue.size()); for (set::iterator it = mMorgue.begin(); it != mMorgue.end(); it++) delete *it; diff --git a/Network/netmanager.h b/Network/netmanager.h index e51426a3..3226a9b7 100644 --- a/Network/netmanager.h +++ b/Network/netmanager.h @@ -141,4 +141,4 @@ private: } // end namespace Security -#endif _H_NETMANAGER +#endif /* _H_NETMANAGER */ diff --git a/Network/networkchooser.h b/Network/networkchooser.h index 66560b30..b4f412a1 100644 --- a/Network/networkchooser.h +++ b/Network/networkchooser.h @@ -72,4 +72,4 @@ private: } // end namespace Security -#endif _H_CHOOSER +#endif /* _H_CHOOSER */ diff --git a/Network/observer.h b/Network/observer.h index d036f0b5..9cd254d2 100644 --- a/Network/observer.h +++ b/Network/observer.h @@ -81,4 +81,4 @@ private: } // end namespace Security -#endif _H_OBSERVER +#endif /* _H_OBSERVER */ diff --git a/Network/parameters.h b/Network/parameters.h index a5671860..b5d310a1 100644 --- a/Network/parameters.h +++ b/Network/parameters.h @@ -60,10 +60,10 @@ public: TypedValue value; if (getParams(key, value)) { result = value; - debug("paramsource", "%p key=0x%lx retrieved", this, key); + secdebug("paramsource", "%p key=0x%lx retrieved", this, key); return true; } else { - debug("paramsource", "%p key=0x%lx not found", this, key); + secdebug("paramsource", "%p key=0x%lx not found", this, key); return false; } } diff --git a/Network/protocol.h b/Network/protocol.h index e3dd0d02..564f17ca 100644 --- a/Network/protocol.h +++ b/Network/protocol.h @@ -73,4 +73,4 @@ private: } // end namespace Security -#endif _H_PROTOCOL +#endif /* _H_PROTOCOL */ diff --git a/Network/target.h b/Network/target.h index d1e94b33..b1ee1b82 100644 --- a/Network/target.h +++ b/Network/target.h @@ -98,4 +98,4 @@ public: } // end namespace Security -#endif _H_TARGET +#endif /* _H_TARGET */ diff --git a/Network/transfer.cpp b/Network/transfer.cpp index c74f9137..fef24b82 100644 --- a/Network/transfer.cpp +++ b/Network/transfer.cpp @@ -41,7 +41,7 @@ Transfer::Transfer(Protocol &proto, const Target &tgt, Operation op, IPPort defP mShareConnections(proto.manager.reuseConnections()), mErrorStatus(defaultOSStatusError) { - debug("netxfer", "%p created for protocol %p(%s) target %s operation %d", + secdebug("netxfer", "%p created for protocol %p(%s) target %s operation %d", this, &proto, proto.name(), target.urlForm().c_str(), mOperation); parameters(protocol.manager); // inherit environment from manager object @@ -50,7 +50,7 @@ Transfer::Transfer(Protocol &proto, const Target &tgt, Operation op, IPPort defP Transfer::~Transfer() { - debug("netxfer", "transfer %p destroyed", this); + secdebug("netxfer", "transfer %p destroyed", this); } @@ -109,7 +109,7 @@ void Transfer::observe(Observer::Events events, const void *info) // void Transfer::finish() { - debug("xferengine", "transfer %p is finishing up", this); + secdebug("xferengine", "transfer %p is finishing up", this); mState = finished; if (isDocked()) mConnection->undock(); @@ -123,7 +123,7 @@ void Transfer::finish() // void Transfer::fail() { - debug("xferengine", "transfer %p is failing", this); + secdebug("xferengine", "transfer %p is failing", this); mState = failed; if (isDocked()) mConnection->undock(); diff --git a/Network/transfer.h b/Network/transfer.h index ab929de8..9523ee8a 100644 --- a/Network/transfer.h +++ b/Network/transfer.h @@ -145,4 +145,4 @@ private: } // end namespace Security -#endif _H_TRANSFER +#endif /* _H_TRANSFER */ diff --git a/Network/xfercore.cpp b/Network/xfercore.cpp index f57aabc1..f665a271 100644 --- a/Network/xfercore.cpp +++ b/Network/xfercore.cpp @@ -58,10 +58,10 @@ void TransferEngine::remove(Client *client) { #ifndef NDEBUG if (!client->mReadBuffer.isEmpty()) - debug("xferengine", "xfer %p(%d) HAD %ld BYTES READ LEFT", + secdebug("xferengine", "xfer %p(%d) HAD %ld BYTES READ LEFT", client, client->fileDesc(), client->mReadBuffer.length()); if (!client->mWriteBuffer.isEmpty()) - debug("xferengine", "xfer %p(%d) HAD %ld BYTES WRITE LEFT", + secdebug("xferengine", "xfer %p(%d) HAD %ld BYTES WRITE LEFT", client, client->fileDesc(), client->mWriteBuffer.length()); #endif //NDEBUG if (client->io.fd () != -1) { // did we have a live socket? @@ -79,7 +79,7 @@ void TransferEngine::remove(Client *client) // void TransferEngine::Client::mode(InputMode newMode) { - debug("xferengine", "xfer %p(%d) switching to mode %d", this, fileDesc(), newMode); + secdebug("xferengine", "xfer %p(%d) switching to mode %d", this, fileDesc(), newMode); switch (newMode) { case rawInput: case lineInput: @@ -99,7 +99,7 @@ void TransferEngine::Client::mode(Sink &sink, size_t byteCount) mMode = autoReadInput; mSink = &sink; mResidualReadCount = byteCount; - debug("xferengine", "xfer %p(%d) switching to autoReadInput (%ld bytes)", + secdebug("xferengine", "xfer %p(%d) switching to autoReadInput (%ld bytes)", this, fileDesc(), byteCount); } @@ -109,7 +109,7 @@ void TransferEngine::Client::mode(Source &source, size_t byteCount) mAutoCopyOut = true; mSource = &source; mResidualWriteCount = byteCount; - debug("xferengine", "xfer %p(%d) enabling autoCopyOut mode (%ld bytes)", + secdebug("xferengine", "xfer %p(%d) enabling autoCopyOut mode (%ld bytes)", this, fileDesc(), byteCount); enable(output); } @@ -133,7 +133,7 @@ void TransferEngine::Client::vprintf(const char *format, va_list args) #if !defined(NDEBUG) char buffer[1024]; vsnprintf(buffer, sizeof(buffer), format, args); - debug("engineio", "%p(%d) <-- %s", this, fileDesc(), buffer); + secdebug("engineio", "%p(%d) <-- %s", this, fileDesc(), buffer); #endif //NDEBUG startOutput(); } @@ -153,7 +153,7 @@ void TransferEngine::Client::vprintfe(const char *format, va_list args) #if !defined(NDEBUG) char buffer[1024]; vsnprintf(buffer, sizeof(buffer), format, args); - debug("engineio", "%p(%d) <-- %s[CRNL]", this, fileDesc(), buffer); + secdebug("engineio", "%p(%d) <-- %s[CRNL]", this, fileDesc(), buffer); #endif //NDEBUG startOutput(); } @@ -169,7 +169,7 @@ void TransferEngine::Client::vprintfe(const char *format, va_list args) void TransferEngine::Client::flushOutput(bool autoFlush) { mAutoFlush = autoFlush; - debug("engineio", "%p(%d) output flush %s", this, fileDesc(), autoFlush? "on" : "off"); + secdebug("engineio", "%p(%d) output flush %s", this, fileDesc(), autoFlush? "on" : "off"); if (mAutoFlush) startOutput(); } @@ -205,7 +205,7 @@ void TransferEngine::Client::startOutput() void TransferEngine::Client::flushInput() { if (!mReadBuffer.isEmpty()) { - debug("engineio", "flushing %ld bytes of input", mReadBuffer.length()); + secdebug("engineio", "flushing %ld bytes of input", mReadBuffer.length()); mReadBuffer.clear(); mInputFlushed = true; // inhibit normal buffer ops } @@ -225,7 +225,7 @@ size_t TransferEngine::Client::autoCopy() len = mResidualWriteCount; void *addr; mWriteBuffer.locatePut(addr, len); mSource->produce(addr, len); - debug("xferengine", "xfer %p(%d) autoCopyOut source delivered %ld bytes", + secdebug("xferengine", "xfer %p(%d) autoCopyOut source delivered %ld bytes", this, fileDesc(), len); mWriteBuffer.usePut(len); return len; @@ -247,7 +247,7 @@ void TransferEngine::Client::notify(int fd, Type type) if (mMode == connecting) { Socket s; s = fd; // Socket(fd) means something different... int error = s.error(); - debug("xferengine", "xfer %p(%d) connect (errno %d)", + secdebug("xferengine", "xfer %p(%d) connect (errno %d)", this, fd, error); transit(connectionDone, NULL, error); return; @@ -259,13 +259,13 @@ void TransferEngine::Client::notify(int fd, Type type) switch (mSource->state()) { case Source::stalled: // ah well, maybe later - debug("xferengine", "xfer %p(%d) autoCopyOut source is stalled", this, fd); + secdebug("xferengine", "xfer %p(%d) autoCopyOut source is stalled", this, fd); break; case Source::endOfData: mAutoCopyOut = false; // done - debug("xferengine", "xfer %p(%d) autoCopyOut end of data", this, fd); + secdebug("xferengine", "xfer %p(%d) autoCopyOut end of data", this, fd); if (mResidualWriteCount > 0) - debug("xferengine", "xfer %p(%d) has %ld autoCopy bytes left", + secdebug("xferengine", "xfer %p(%d) has %ld autoCopy bytes left", this, fd, mResidualWriteCount); transit(autoWriteDone); if (!isActive()) @@ -277,17 +277,17 @@ void TransferEngine::Client::notify(int fd, Type type) } } if (mWriteBuffer.isEmpty()) { // output possible, no output pending - debug("xferengine", "xfer %p(%d) disabling output (empty)", this, fd); + secdebug("xferengine", "xfer %p(%d) disabling output (empty)", this, fd); disable(output); } else { // stuff some more size_t length = mWriteBuffer.write(*this); - debug("xferengine", "xfer %p(%d) writing %ld bytes", this, fd, length); + secdebug("xferengine", "xfer %p(%d) writing %ld bytes", this, fd, length); } } if (type & Selector::input) { - IFDEBUG(debug("xferengine", "xfer %p(%d) input ready %d bytes", - this, fd, io.iocget(FIONREAD))); + secdebug("xferengine", "xfer %p(%d) input ready %d bytes", + this, fd, io.iocget(FIONREAD)); do { mInputFlushed = false; // preset normal @@ -325,13 +325,13 @@ void TransferEngine::Client::notify(int fd, Type type) { // we should never be here. Selector gave us "read but not write" while connecting. FUBAR Socket s; s = fd; - debug("xferengine", + secdebug("xferengine", "fd %d input while connecting (errno=%d, type=%d)", fd, s.error(), type); UnixError::throwMe(ECONNREFUSED); // likely interpretation } default: - debug("xferengine", "mode error in input sequencer (mode=%d)", mMode); + secdebug("xferengine", "mode error in input sequencer (mode=%d)", mMode); assert(false); } if (!io) // client has unhooked; clear buffer and exit loop @@ -352,8 +352,8 @@ void TransferEngine::Client::rawInputTransit() // just shove it at the user char *addr; size_t length = mReadBuffer.length(); mReadBuffer.locateGet(addr, length); - IFDEBUG(debug("engineio", "%p(%d) --> %d bytes RAW", - this, fileDesc(), io.iocget(FIONREAD))); + secdebug("engineio", "%p(%d) --> %d bytes RAW", + this, fileDesc(), io.iocget(FIONREAD)); transit(inputAvailable, addr, length); if (!mInputFlushed) mReadBuffer.useGet(length); @@ -371,11 +371,11 @@ bool TransferEngine::Client::lineInputTransit() if (nl > line && nl[-1] == '\r') { // proper \r\n termination nl[-1] = '\0'; // terminate for transit convenience - debug("engineio", "%p(%d) --> %s", this, fileDesc(), line); + secdebug("engineio", "%p(%d) --> %s", this, fileDesc(), line); transit(inputAvailable, line, nl - line - 1); } else { // improper, tolerate nl[0] = '\0'; // terminate for transit convenience - debug("engineio", "%p(%d) [IMPROPER] --> %s", this, fileDesc(), line); + secdebug("engineio", "%p(%d) [IMPROPER] --> %s", this, fileDesc(), line); transit(inputAvailable, line, nl - line); } if (!mInputFlushed) @@ -385,13 +385,13 @@ bool TransferEngine::Client::lineInputTransit() void TransferEngine::Client::autoReadInputTransit() { - debug("xferengine", "xfer %p(%d) %ld pending %d available", + secdebug("xferengine", "xfer %p(%d) %ld pending %d available", this, fileDesc(), mReadBuffer.length(), io.iocget(FIONREAD)); void *data; size_t length = mReadBuffer.length(); if (mResidualReadCount && mResidualReadCount < length) length = mResidualReadCount; mReadBuffer.locateGet(data, length); - debug("engineio", "%p(%d) --> %ld bytes autoReadInput", this, fileDesc(), length); + secdebug("engineio", "%p(%d) --> %ld bytes autoReadInput", this, fileDesc(), length); mSink->consume(data, length); if (!mInputFlushed) mReadBuffer.useGet(length); diff --git a/SecureTransport/CVSVersionInfo.txt b/SecureTransport/CVSVersionInfo.txt index 09f28708..e0a4f43d 100644 --- a/SecureTransport/CVSVersionInfo.txt +++ b/SecureTransport/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:58 mb Exp $ -# $Name: Security-54~1~9 $ +# $Name: $ ProjectName: SecureTransport ProjectVersion: 3 diff --git a/SecureTransport/README b/SecureTransport/README index 0442b1f0..3be86f2a 100644 --- a/SecureTransport/README +++ b/SecureTransport/README @@ -42,5 +42,4 @@ -- Server untested with Windows clients. --- Client authentication is not tested. diff --git a/SecureTransport/SecureTransport.pbproj/project.pbxproj b/SecureTransport/SecureTransport.pbproj/project.pbxproj index d33b01c0..1c8755f1 100644 --- a/SecureTransport/SecureTransport.pbproj/project.pbxproj +++ b/SecureTransport/SecureTransport.pbproj/project.pbxproj @@ -10,6 +10,7 @@ 48499A08FFCB05657F000001, 48499A09FFCB05657F000001, ); + hasScannedForEncodings = 1; isa = PBXProject; mainGroup = 00E4CE34FF9B8B71D0A17CE7; productRefGroup = 00E4CE35FF9B8CA8D0A17CE7; @@ -63,7 +64,6 @@ isa = PBXAggregateTarget; name = World; productName = World; - shouldUseHeadermap = 0; }; 00E4CE38FF9B8CA8D0A17CE7 = { buildPhases = ( @@ -128,7 +128,6 @@ "; - shouldUseHeadermap = 0; }; 00E4CE39FF9B8CA8D0A17CE7 = { buildActionMask = 2147483647; @@ -312,120 +311,140 @@ refType = 4; }; 00E4CE43FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = appleCdsa.h; path = privateInc/appleCdsa.h; refType = 4; }; 00E4CE45FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = appleSession.h; path = privateInc/appleSession.h; refType = 4; }; 00E4CE46FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = cipherSpecs.h; path = privateInc/cipherSpecs.h; refType = 4; }; 00E4CE47FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = cryptType.h; path = privateInc/cryptType.h; refType = 4; }; 00E4CE48FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslDigests.h; path = privateInc/sslDigests.h; refType = 4; }; 00E4CE4DFF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = ssl.h; path = privateInc/ssl.h; refType = 4; }; 00E4CE4EFF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = ssl2.h; path = privateInc/ssl2.h; refType = 4; }; 00E4CE4FFF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslAlertMessage.h; path = privateInc/sslAlertMessage.h; refType = 4; }; 00E4CE50FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslMemory.h; path = privateInc/sslMemory.h; refType = 4; }; 00E4CE51FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslBER.h; path = privateInc/sslBER.h; refType = 4; }; 00E4CE52FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslBuildFlags.h; path = privateInc/sslBuildFlags.h; refType = 4; }; 00E4CE53FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslContext.h; path = privateInc/sslContext.h; refType = 4; }; 00E4CE54FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslDebug.h; path = privateInc/sslDebug.h; refType = 4; }; 00E4CE57FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslHandshake.h; path = privateInc/sslHandshake.h; refType = 4; }; 00E4CE58FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslKeychain.h; path = privateInc/sslKeychain.h; refType = 4; }; 00E4CE59FF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslPriv.h; path = privateInc/sslPriv.h; refType = 4; }; 00E4CE5AFF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslRecord.h; path = privateInc/sslRecord.h; refType = 4; }; 00E4CE5BFF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslSession.h; path = privateInc/sslSession.h; refType = 4; }; 00E4CE5DFF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = sslUtils.h; path = privateInc/sslUtils.h; refType = 4; }; 00E4CE5EFF9B8EABD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = symCipher.h; path = privateInc/symCipher.h; @@ -652,11 +671,13 @@ }; }; 00E4CE7EFF9B8F1DD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = appleCdsa.cpp; refType = 4; }; 00E4CE81FF9B8F1DD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslKeychain.cpp; refType = 4; @@ -678,81 +699,97 @@ }; }; 00E4CE86FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2CipherMap.cpp; refType = 4; }; 00E4CE87FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2Message.cpp; refType = 4; }; 00E4CE88FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2Protocol.cpp; refType = 4; }; 00E4CE89FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2Record.cpp; refType = 4; }; 00E4CE8AFF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslCert.cpp; refType = 4; }; 00E4CE8BFF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslChangeCipher.cpp; refType = 4; }; 00E4CE8CFF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslHandshakeFinish.cpp; refType = 4; }; 00E4CE8DFF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslHandshakeHello.cpp; refType = 4; }; 00E4CE8FFF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslKeyExchange.cpp; refType = 4; }; 00E4CE90FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslHandshake.cpp; refType = 4; }; 00E4CE91FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = cipherSpecs.cpp; refType = 4; }; 00E4CE94FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = symCipher.cpp; refType = 4; }; 00E4CE95FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslDigests.cpp; refType = 4; }; 00E4CE97FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslNullCipher.cpp; refType = 4; }; 00E4CE99FF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslMemory.cpp; refType = 4; }; 00E4CE9AFF9B8FE5D0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslUtils.cpp; refType = 4; @@ -886,37 +923,44 @@ }; }; 00E4CEB0FF9B909FD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslAlertMessage.cpp; refType = 4; }; 00E4CEB1FF9B909FD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslContext.cpp; refType = 4; }; 00E4CEB2FF9B909FD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslRecord.cpp; refType = 4; }; 00E4CEB3FF9B909FD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslSession.cpp; refType = 4; }; 00E4CEB4FF9B909FD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = sslTransport.cpp; refType = 4; }; 00E4CEB5FF9B909FD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = CipherSuite.h; path = SecureTransport/CipherSuite.h; refType = 4; }; 00E4CEB6FF9B909FD0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; name = SecureTransport.h; path = SecureTransport/SecureTransport.h; @@ -985,6 +1029,7 @@ target = 00E4CE38FF9B8CA8D0A17CE7; }; 00E4CEBFFF9B9A4ED0A17CE7 = { + fileEncoding = 30; isa = PBXFileReference; path = secureTransport.exp; refType = 4; @@ -1008,11 +1053,13 @@ //013 //014 0145E21BFFEED50A7F000001 = { + fileEncoding = 30; isa = PBXFileReference; path = ModuleAttacher.cpp; refType = 4; }; 0145E21CFFEED50A7F000001 = { + fileEncoding = 30; isa = PBXFileReference; path = ModuleAttacher.h; refType = 4; @@ -1102,6 +1149,7 @@ //9D3 //9D4 9D1B441201F5ED1200003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = "securetransport++.h"; refType = 4; @@ -1119,32 +1167,38 @@ refType = 4; }; 9D1B441401F5ED1200003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = Entries; refType = 4; }; 9D1B441501F5ED1200003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = Repository; refType = 4; }; 9D1B441601F5ED1200003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = Root; refType = 4; }; 9D1B441701F5ED1200003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = Template; refType = 4; }; 9D1B441801F5ED1200003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = tls_hmac.h; path = privateInc/tls_hmac.h; refType = 4; }; 9D1B441901F5ED1200003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = tls_ssl.h; path = privateInc/tls_ssl.h; @@ -1193,26 +1247,31 @@ }; }; 9D1B442101F5ED3000003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = appleSession.cpp; refType = 4; }; 9D1B442201F5ED3000003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = "securetransport++.cpp"; refType = 4; }; 9D1B442301F5ED3000003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = ssl3Callouts.cpp; refType = 4; }; 9D1B442401F5ED3000003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = tls_hmac.cpp; refType = 4; }; 9D1B442501F5ED3000003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = tls1Callouts.cpp; refType = 4; @@ -1260,6 +1319,7 @@ }; }; 9D1B443001F5EE8D00003D05 = { + fileEncoding = 30; isa = PBXFileReference; path = sslBER_Dummy.cpp; refType = 4; @@ -1271,6 +1331,7 @@ }; }; 9DD49D99030C714000003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = SecureTransportPriv.h; path = privateInc/SecureTransportPriv.h; diff --git a/SecureTransport/SecureTransport/CipherSuite.h b/SecureTransport/SecureTransport/CipherSuite.h index f933c1d2..55ce16d8 100644 --- a/SecureTransport/SecureTransport/CipherSuite.h +++ b/SecureTransport/SecureTransport/CipherSuite.h @@ -21,8 +21,6 @@ Contains: SSL Cipher Suite definitions. - Written by: Doug Mitchell, based in Netscape SSLRef 3.0 - Copyright: (c) 1999 by Apple Computer, Inc., all rights reserved. */ diff --git a/SecureTransport/SecureTransport/SecureTransport.h b/SecureTransport/SecureTransport/SecureTransport.h index 44de1721..7e43d996 100644 --- a/SecureTransport/SecureTransport/SecureTransport.h +++ b/SecureTransport/SecureTransport/SecureTransport.h @@ -85,7 +85,8 @@ typedef enum { kSSLProtocol3Only, /* use SSL 3.0 only, fail if peer tries to * negotiate 2.0 */ kTLSProtocol1, /* TLS 1.0 preferred, lower versions OK */ - kTLSProtocol1Only /* TLS 1.0 only */ + kTLSProtocol1Only, /* TLS 1.0 only */ + kSSLProtocolAll /* all supported versions */ } SSLProtocol; /* State of an SSLSession */ @@ -152,14 +153,20 @@ typedef OSStatus /************************************************* *** OSStatus values unique to SecureTransport *** *************************************************/ - + +/* + Note: the comments that appear after these errors are used to create SecErrorMessages.strings. + The comments must not be multi-line, and should be in a form meaningful to an end user. If + a different or additional comment is needed, it can be put in the header doc format, or on a + line that does not start with errZZZ. +*/ + enum { errSSLProtocol = -9800, /* SSL protocol error */ errSSLNegotiation = -9801, /* Cipher Suite negotiation failure */ errSSLFatalAlert = -9802, /* Fatal alert */ errSSLWouldBlock = -9803, /* I/O would block (not fatal) */ - errSSLSessionNotFound = -9804, /* attempt to restore an unknown - * session */ + errSSLSessionNotFound = -9804, /* attempt to restore an unknown session */ errSSLClosedGraceful = -9805, /* connection closed gracefully */ errSSLClosedAbort = -9806, /* connection closed via error */ errSSLXCertChainInvalid = -9807, /* Invalid certificate chain */ @@ -171,10 +178,39 @@ enum { errSSLNoRootCert = -9813, /* cert chain not verified by root */ errSSLCertExpired = -9814, /* chain had an expired cert */ errSSLCertNotYetValid = -9815, /* chain had a cert not yet valid */ - errSSLClosedNoNotify = -9816, /* server closed session with no - * notification */ + errSSLClosedNoNotify = -9816, /* server closed session with no notification */ errSSLBufferOverflow = -9817, /* insufficient buffer provided */ errSSLBadCipherSuite = -9818, /* bad SSLCipherSuite */ + + /* fatal errors detected by peer */ + errSSLPeerUnexpectedMsg = -9819, /* unexpected message received */ + errSSLPeerBadRecordMac = -9820, /* bad MAC */ + errSSLPeerDecryptionFail = -9821, /* decryption failed */ + errSSLPeerRecordOverflow = -9822, /* record overflow */ + errSSLPeerDecompressFail = -9823, /* decompression failure */ + errSSLPeerHandshakeFail = -9824, /* handshake failure */ + errSSLPeerBadCert = -9825, /* misc. bad certificate */ + errSSLPeerUnsupportedCert = -9826, /* bad unsupported cert format */ + errSSLPeerCertRevoked = -9827, /* certificate revoked */ + errSSLPeerCertExpired = -9828, /* certificate expired */ + errSSLPeerCertUnknown = -9829, /* unknown certificate */ + errSSLIllegalParam = -9830, /* illegal parameter */ + errSSLPeerUnknownCA = -9831, /* unknown Cert Authority */ + errSSLPeerAccessDenied = -9832, /* access denied */ + errSSLPeerDecodeError = -9833, /* decoding error */ + errSSLPeerDecryptError = -9834, /* decryption error */ + errSSLPeerExportRestriction = -9835, /* export restriction */ + errSSLPeerProtocolVersion = -9836, /* bad protocol version */ + errSSLPeerInsufficientSecurity = -9837, /* insufficient security */ + errSSLPeerInternalError = -9838, /* internal error */ + errSSLPeerUserCancelled = -9839, /* user canceled */ + errSSLPeerNoRenegotiation = -9840, /* no renegotiation allowed */ + + /* more errors detected by us */ + errSSLDecryptionFail = -9845, /* decryption failure */ + errSSLBadRecordMac = -9846, /* bad MAC */ + errSSLRecordOverflow = -9847, /* Record Overflow */ + errSSLBadConfiguration = -9848, /* configuration error */ errSSLLast = -9849 /* end of range, to be deleted */ }; @@ -217,18 +253,54 @@ OSStatus SSLSetIOFuncs (SSLContextRef context, SSLReadFunc read, SSLWriteFunc write); + +/* + * Set allowed SSL protocol versions. Optional. + * Specifying kSSLProtocolAll for SSLSetProtocolVersionEnabled results in + * specified 'enable' boolean to be applied to all supported protocols. + * The default is "all supported protocols are enabled". + * This can only be called when no session is active. + * + * Legal values for protocol are : + * kSSLProtocol2 + * kSSLProtocol3 + * kTLSProtocol1 + * kSSLProtocolAll + */ +OSStatus +SSLSetProtocolVersionEnabled (SSLContextRef context, + SSLProtocol protocol, + Boolean enable); +/* + * Obtain a value specified in SSLSetProtocolVersionEnabled. + */ +OSStatus +SSLGetProtocolVersionEnabled(SSLContextRef context, + SSLProtocol protocol, + Boolean *enable); /* RETURNED */ + /* * Get/set SSL protocol version; optional. Default is kSSLProtocolUnknown, * in which case the highest possible version (currently kTLSProtocol1) * is attempted, but a lower version is accepted if the peer requires it. * * SSLSetProtocolVersion can not be called when a session is active. + * + * This is deprecated in favor of SSLSetProtocolVersionEnabled. */ OSStatus SSLSetProtocolVersion (SSLContextRef context, SSLProtocol version); +/* + * Obtain the protocol version specified in SSLSetProtocolVersion. + * This is deprecated in favor of SSLGetProtocolVersionEnabled. + * If SSLSetProtocolVersionEnabled() has been called for this session, + * SSLGetProtocolVersion() may return paramErr if the protocol enable + * state can not be represented by the SSLProtocol enums (e.g., + * SSL2 and TLS1 enabled, SSL3 disabled). + */ OSStatus SSLGetProtocolVersion (SSLContextRef context, SSLProtocol *protocol); /* RETURNED */ @@ -275,6 +347,10 @@ OSStatus SSLSetConnection (SSLContextRef context, SSLConnectionRef connection); +OSStatus +SSLGetConnection (SSLContextRef context, + SSLConnectionRef *connection); + /* * Specify the fully qualified doman name of the peer, e.g., "store.apple.com." * Optional; used to verify the common name field in peer's certificate. @@ -456,12 +532,12 @@ SSLGetTrustedRoots (SSLContextRef context, * Request peer certificates. Valid anytime, subsequent to * a handshake attempt. * - * The certs argument is a CFArray containing CFDataRefs, each - * of which is one DER-encoded cert. The entire array is created - * by the SecureTransport library and must be released by the caller. - * The cert at the end of the returned array is the subject (end - * entity) cert; the root cert (or the closest cert to it) is in - * index 0 of the returned array. + * The certs argument is a CFArray containing SecCertificateRefs. + * The entire array is created by the SecureTransport library + * and must be released by the caller. The cert at index 0 of + * the returned array is the subject (end entity) cert; the + * root cert (or the closest cert to it) is at the end of the + * returned array. */ OSStatus SSLGetPeerCertificates (SSLContextRef context, @@ -580,6 +656,35 @@ OSStatus SSLGetClientCertificateState (SSLContextRef context, SSLClientCertificateState *clientState); +/* + * Specify Diffie-Hellman parameters. Optional; if we are configured to allow + * for D-H ciphers and a D-H cipher is negotiated, and this function has not + * been called, a set of process-wide parameters will be calculated. However + * that can take a long time (30 seconds). + */ +OSStatus SSLSetDiffieHellmanParams (SSLContextRef context, + const void *dhParams, + size_t dhParamsLen); + +/* + * Return parameter block specified in SSLSetDiffieHellmanParams. + * Returned data is not copied and belongs to the SSLContextRef. + */ +OSStatus SSLGetDiffieHellmanParams (SSLContextRef context, + const void **dhParams, + size_t *dhParamsLen); +/* + * Enable/Disable RSA blinding. This feature thwarts a known timing + * attack to which RSA keys are vulnerable; enabling it is a tradeoff + * between performance and security. The default for RSA blinding is + * enabled. + */ +OSStatus SSLSetRsaBlinding (SSLContextRef context, + Boolean blinding); + +OSStatus SSLGetRsaBlinding (SSLContextRef context, + Boolean *blinding); + /******************************* ******** I/O Functions ******** *******************************/ diff --git a/SecureTransport/appleCdsa.cpp b/SecureTransport/appleCdsa.cpp index 987d1e97..8ef468b3 100644 --- a/SecureTransport/appleCdsa.cpp +++ b/SecureTransport/appleCdsa.cpp @@ -47,6 +47,9 @@ #include #include #include +#include +#include +#include /* X.509 includes, from cssmapi */ #include /* x.509 function and type defs */ @@ -223,6 +226,26 @@ OSStatus detachFromAll(SSLContext *ctx) return noErr; } +/* + * Add a CSSM_ATTRIBUTE_RSA_BLINDING attribute to + * specified crypto context. + */ +static CSSM_RETURN sslAddBlindingAttr( + CSSM_CC_HANDLE ccHand) +{ + CSSM_CONTEXT_ATTRIBUTE newAttr; + CSSM_RETURN crtn; + + newAttr.AttributeType = CSSM_ATTRIBUTE_RSA_BLINDING; + newAttr.AttributeLength = sizeof(uint32); + newAttr.Attribute.Uint32 = 1; + crtn = CSSM_UpdateContextAttributes(ccHand, 1, &newAttr); + if(crtn) { + stPrintCdsaError("CSSM_UpdateContextAttributes", crtn); + } + return crtn; +} + #pragma mark - #pragma mark *** CSSM_DATA routines *** @@ -284,105 +307,33 @@ OSStatus stSetUpCssmData( return noErr; } -#pragma mark - -#pragma mark *** Public CSP Functions *** - -/* - * Raw RSA sign/verify. - * - * Initial X port: CSP doesns't support this, so we'll do sign/verify via - * raw RSA encrypt/decrypt here. - */ -#define SIGN_VFY_VIA_ENCR_DECR 0 - -#if SIGN_VFY_VIA_ENCR_DECR - -OSStatus sslRsaRawSign( - SSLContext *ctx, - const CSSM_KEY *privKey, - CSSM_CSP_HANDLE cspHand, - const UInt8 *plainText, - UInt32 plainTextLen, - UInt8 *sig, // mallocd by caller; RETURNED - UInt32 sigLen, // available - UInt32 *actualBytes) // RETURNED -{ - /* Raw RSA sign with no digest is the same as raw RSA encrypt. */ - /* Force CSSM_KEYUSE_ANY in case CL provided keyuse bits more specific - * than we really want */ - OSStatus serr; - CSSM_KEYUSE savedKeyUse = privKey->KeyHeader.KeyUsage; - privKey->KeyHeader.KeyUsage = CSSM_KEYUSE_ANY; - serr = sslRsaEncrypt(ctx, - privKey, - cspHand, - plainText, - plainTextLen, - sig, - sigLen, - actualBytes); - privKey->KeyHeader.KeyUsage = savedKeyUse; - return serr; -} - -OSStatus sslRsaRawVerify( - SSLContext *ctx, - const CSSM_KEY *pubKey, - CSSM_CSP_HANDLE cspHand, - const UInt8 *plainText, - UInt32 plainTextLen, - const UInt8 *sig, - UInt32 sigLen) -{ - /* - * Raw RSA verify with no digest is just a comparison of the incoming - * plaintext with (signature, decrypted via raw RSA decrypt). - */ - - UInt32 actualBytes; - OSStatus serr; - UInt8 *digest; - - /* Force CSSM_KEYUSE_ANY in case CL provided keyuse bits more specific - * than we really want */ - CSSM_KEYUSE savedKeyUse = pubKey->KeyHeader.KeyUsage; - pubKey->KeyHeader.KeyUsage = CSSM_KEYUSE_ANY; - - /* malloc space for decrypting the signature */ - digest = sslMalloc(plainTextLen); - if(digest == NULL) { - return memFullErr; - } +static OSStatus sslKeyToSigAlg( + const CSSM_KEY *cssmKey, + CSSM_ALGORITHMS &sigAlg) /* RETURNED */ - /* decrypt signature */ - serr = sslRsaDecrypt(ctx, - pubKey, - cspHand, - sig, - sigLen, - digest, - plainTextLen, - &actualBytes); - pubKey->KeyHeader.KeyUsage = savedKeyUse; - if(serr) { - goto errOut; - } - if((actualBytes != plainTextLen) || - (memcmp(plainText, digest, plainTextLen))) { - sslErrorLog("sslRsaRawVerify: sig miscompare\n"); - serr = errSSLCrypto; - } - else { - serr = noErr; +{ + OSStatus ortn = noErr; + switch(cssmKey->KeyHeader.AlgorithmId) { + case CSSM_ALGID_RSA: + sigAlg = CSSM_ALGID_RSA; + break; + case CSSM_ALGID_DSA: + sigAlg = CSSM_ALGID_DSA; + break; + default: + ortn = errSSLBadConfiguration; + break; } -errOut: - sslFree(digest); - return serr; + return ortn; } -#else /* OS9 and future post-cheetah version */ +#pragma mark - +#pragma mark *** Public CSP Functions *** -OSStatus sslRsaRawSign( +/* + * Raw RSA/DSA sign/verify. + */ +OSStatus sslRawSign( SSLContext *ctx, const CSSM_KEY *privKey, CSSM_CSP_HANDLE cspHand, @@ -394,7 +345,7 @@ OSStatus sslRsaRawSign( { CSSM_CC_HANDLE sigHand = 0; CSSM_RETURN crtn; - OSStatus serr; + OSStatus serr; CSSM_DATA sigData; CSSM_DATA ptextData; @@ -409,8 +360,13 @@ OSStatus sslRsaRawSign( } *actualBytes = 0; + CSSM_ALGORITHMS sigAlg; + serr = sslKeyToSigAlg(privKey, sigAlg); + if(serr) { + return serr; + } crtn = CSSM_CSP_CreateSignatureContext(cspHand, - CSSM_ALGID_RSA, + sigAlg, NULL, // passPhrase privKey, &sigHand); @@ -418,6 +374,17 @@ OSStatus sslRsaRawSign( stPrintCdsaError("CSSM_CSP_CreateSignatureContext (1)", crtn); return errSSLCrypto; } + + if((ctx->rsaBlindingEnable) && + (privKey->KeyHeader.AlgorithmId == CSSM_ALGID_RSA)) { + /* + * Turn on RSA blinding to defeat timing attacks + */ + crtn = sslAddBlindingAttr(sigHand); + if(crtn) { + return crtn; + } + } ptextData.Data = (uint8 *)plainText; ptextData.Length = plainTextLen; @@ -429,7 +396,7 @@ OSStatus sslRsaRawSign( crtn = CSSM_SignData(sigHand, &ptextData, 1, - CSSM_ALGID_NONE, // digestAlg + CSSM_ALGID_NONE, // digestAlg for raw sign &sigData); if(crtn) { stPrintCdsaError("CSSM_SignData", crtn); @@ -445,7 +412,7 @@ OSStatus sslRsaRawSign( return serr; } -OSStatus sslRsaRawVerify( +OSStatus sslRawVerify( SSLContext *ctx, const CSSM_KEY *pubKey, CSSM_CSP_HANDLE cspHand, @@ -456,7 +423,7 @@ OSStatus sslRsaRawVerify( { CSSM_CC_HANDLE sigHand = 0; CSSM_RETURN crtn; - OSStatus serr; + OSStatus serr; CSSM_DATA sigData; CSSM_DATA ptextData; @@ -465,12 +432,17 @@ OSStatus sslRsaRawVerify( (cspHand == 0) || (plainText == NULL) || (sig == NULL)) { - sslErrorLog("sslRsaRawVerify: bad arguments\n"); + sslErrorLog("sslRawVerify: bad arguments\n"); return errSSLInternal; } + CSSM_ALGORITHMS sigAlg; + serr = sslKeyToSigAlg(pubKey, sigAlg); + if(serr) { + return serr; + } crtn = CSSM_CSP_CreateSignatureContext(cspHand, - CSSM_ALGID_RSA, + sigAlg, NULL, // passPhrase pubKey, &sigHand); @@ -501,7 +473,6 @@ OSStatus sslRsaRawVerify( } return serr; } -#endif /* SIGN_VFY_VIA_ENCR_DECR */ /* * Encrypt/Decrypt @@ -520,7 +491,7 @@ OSStatus sslRsaEncrypt( CSSM_DATA ptextData; CSSM_DATA remData = {0, NULL}; CSSM_CC_HANDLE cryptHand = 0; - OSStatus serr = errSSLInternal; + OSStatus serr = errSSLInternal; CSSM_RETURN crtn; uint32 bytesMoved = 0; CSSM_ACCESS_CREDENTIALS creds; @@ -533,6 +504,7 @@ OSStatus sslRsaEncrypt( sslErrorLog("sslRsaEncrypt: bad pubKey/cspHand\n"); return errSSLInternal; } + assert(pubKey->KeyHeader.KeyClass == CSSM_KEYCLASS_PUBLIC_KEY); #if RSA_PUB_KEY_USAGE_HACK ((CSSM_KEY_PTR)pubKey)->KeyHeader.KeyUsage |= CSSM_KEYUSE_ENCRYPT; @@ -552,24 +524,6 @@ OSStatus sslRsaEncrypt( ptextData.Data = (uint8 *)plainText; ptextData.Length = plainTextLen; - if(pubKey->KeyHeader.KeyClass == CSSM_KEYCLASS_PRIVATE_KEY) { - /* - * Special case, encrypting with private key (i.e., raw sign). Add - * the required context attr. - */ - CSSM_CONTEXT_ATTRIBUTE modeAttr; - - modeAttr.AttributeType = CSSM_ATTRIBUTE_MODE; - modeAttr.AttributeLength = sizeof(uint32); - modeAttr.Attribute.Uint32 = CSSM_ALGMODE_PRIVATE_KEY; - crtn = CSSM_UpdateContextAttributes(cryptHand, 1, &modeAttr); - if(crtn) { - stPrintCdsaError("CSSM_UpdateContextAttributes", crtn); - CSSM_DeleteContext(cryptHand); - return errSSLCrypto; - } - } - /* * Have CSP malloc ciphertext */ @@ -647,7 +601,7 @@ OSStatus sslRsaDecrypt( CSSM_DATA ctextData; CSSM_DATA remData = {0, NULL}; CSSM_CC_HANDLE cryptHand = 0; - OSStatus serr = errSSLInternal; + OSStatus serr = errSSLInternal; CSSM_RETURN crtn; uint32 bytesMoved = 0; CSSM_ACCESS_CREDENTIALS creds; @@ -660,6 +614,7 @@ OSStatus sslRsaDecrypt( sslErrorLog("sslRsaDecrypt: bad privKey/cspHand\n"); return errSSLInternal; } + assert(privKey->KeyHeader.KeyClass == CSSM_KEYCLASS_PRIVATE_KEY); memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS)); crtn = CSSM_CSP_CreateAsymmetricContext(cspHand, CSSM_ALGID_RSA, @@ -674,21 +629,14 @@ OSStatus sslRsaDecrypt( ctextData.Data = (uint8 *)cipherText; ctextData.Length = cipherTextLen; - if(privKey->KeyHeader.KeyClass == CSSM_KEYCLASS_PUBLIC_KEY) { + if((ctx->rsaBlindingEnable) && + (privKey->KeyHeader.AlgorithmId == CSSM_ALGID_RSA)) { /* - * Special case, decrypting with public key (i.e., raw verify). Add - * the required context attr. + * Turn on RSA blinding to defeat timing attacks */ - CSSM_CONTEXT_ATTRIBUTE modeAttr; - - modeAttr.AttributeType = CSSM_ATTRIBUTE_MODE; - modeAttr.AttributeLength = sizeof(uint32); - modeAttr.Attribute.Uint32 = CSSM_ALGMODE_PUBLIC_KEY; - crtn = CSSM_UpdateContextAttributes(cryptHand, 1, &modeAttr); + crtn = sslAddBlindingAttr(cryptHand); if(crtn) { - stPrintCdsaError("CSSM_UpdateContextAttributes", crtn); - CSSM_DeleteContext(cryptHand); - return errSSLCrypto; + return crtn; } } @@ -764,6 +712,37 @@ UInt32 sslKeyLengthInBytes(const CSSM_KEY *key) return (((key->KeyHeader.LogicalKeySizeInBits) + 7) / 8); } +/* + * Obtain maximum size of signature in bytes. A bit of a kludge; we could + * ask the CSP to do this but that would be kind of expensive. + */ +OSStatus sslGetMaxSigSize( + const CSSM_KEY *privKey, + UInt32 &maxSigSize) +{ + OSStatus ortn = noErr; + assert(privKey != NULL); + assert(privKey->KeyHeader.KeyClass == CSSM_KEYCLASS_PRIVATE_KEY); + switch(privKey->KeyHeader.AlgorithmId) { + case CSSM_ALGID_RSA: + maxSigSize = sslKeyLengthInBytes(privKey); + break; + case CSSM_ALGID_DSA: + { + /* DSA sig is DER sequence of two 160-bit integers */ + UInt32 sizeOfOneInt; + sizeOfOneInt = (160 / 8) + // the raw contents + 1 + // possible leading zero + 2; // tag + length (assume DER, not BER) + maxSigSize = (2 * sizeOfOneInt) + 5; + break; + } + default: + ortn = errSSLBadConfiguration; + break; + } + return ortn; +} /* * Get raw key bits from an RSA public key. */ @@ -1001,171 +980,114 @@ OSStatus sslPubKeyFromCert( } } -#if ST_MANAGES_TRUSTED_ROOTS - /* - * Given a CSSM_CERTGROUP which fails due to CSSM_TP_INVALID_ANCHOR - * (chain verifies to an unknown root): - * - * -- find the root cert - * -- add it to newRootCertKc if present (else error) - * -- add it to trustedCerts - * -- re-verify certgroup, demand full success + * Release each element in a CFArray. */ -static OSStatus sslHandleNewRoot( - SSLContext *ctx, - CSSM_CERTGROUP_PTR certGroup) +static void sslReleaseArray( + CFArrayRef a) { - int i; - CSSM_DATA_PTR rootCert; - CSSM_BOOL expired; - OSStatus serr; - CSSM_BOOL brtn; - - assert(ctx != NULL); - assert(certGroup != NULL); - - if(ctx->newRootCertKc == NULL) { - /* no place to add this; done */ - return errSSLUnknownRootCert; + CFIndex num = CFArrayGetCount(a); + for(CFIndex dex=0; dexNumCerts; i++) { - rootCert = &certGroup->CertList[i]; - if(sslVerifyCert(ctx, rootCert, rootCert, ctx->cspHand, &expired)) { - break; - } - } - if(i == certGroup->NumCerts) { - /* Huh! no root cert!? We should not have been called! */ - sslErrorLog("sslHandleNewRoot: no root cert!\n"); - return errSSLInternal; - } - - /* - * Add to newRootCertKc. This may well fail due to user interaction. - */ - serr = sslAddNewRoot(ctx, rootCert); - if(serr) { - return serr; - } - - /* - * Just to be sure...reverify the whole cert chain. - */ - brtn = CSSM_TP_CertGroupVerify( - ctx->tpHand, - ctx->clHand, - ctx->cspHand, - NULL, // DBList - NULL, // PolicyIdentifiers - 0, // NumberofPolicyIdentifiers - CSSM_TP_STOP_ON_POLICY, - certGroup, - ctx->trustedCerts, // AnchorCerts - ctx->numTrustedCerts, - NULL, // VerifyScope - 0, // ScopeSize - 0, // Action - 0, // Data - NULL, // evidence - NULL); // evidenceSize - if(brtn == CSSM_FALSE) { - sslErrorLog("sslHandleNewRoot: adding new root did not help!\n"); - return errSSLUnknownRootCert; - } - return noErr; } -#endif /* ST_MANAGES_TRUSTED_ROOTS */ - /* * Verify a chain of DER-encoded certs. * First cert in a chain is root; this must also be present * in ctx->trustedCerts. + * + * If arePeerCerts is true, host name verification is enabled and we + * save the resulting SecTrustRef in ctx->peerSecTrust. Otherwise + * we're just validating our own certs; no host name checking and + * peerSecTrust is transient. */ -OSStatus sslVerifyCertChain( + OSStatus sslVerifyCertChain( SSLContext *ctx, const SSLCertificate &certChain, - bool verifyHostName /* = true */) + bool arePeerCerts /* = true */) { UInt32 numCerts; - CSSM_CERTGROUP certGroup; int i; - OSStatus serr; + OSStatus serr; SSLCertificate *c = (SSLCertificate *)&certChain; CSSM_RETURN crtn; - CSSM_TP_VERIFY_CONTEXT vfyCtx; - CSSM_TP_CALLERAUTH_CONTEXT authCtx; - CSSM_FIELD policyId; - CSSM_DL_DB_LIST dbList; CSSM_APPLE_TP_SSL_OPTIONS sslOpts; - CSSM_APPLE_TP_ACTION_DATA actionData; + CSSM_APPLE_TP_ACTION_DATA tpActionData; + SecPolicyRef policy = NULL; + SecPolicySearchRef policySearch = NULL; + CFDataRef actionData = NULL; + CSSM_DATA sslOptsData; + CFMutableArrayRef anchors = NULL; + SecCertificateRef cert; // only lives in CFArrayRefs + SecTrustResultType secTrustResult; + CFMutableArrayRef kcList = NULL; + SecTrustRef theTrust = NULL; - if(!ctx->enableCertVerify) { - /* trivial case, this is caller's responsibility */ - return noErr; + if(ctx->peerSecTrust && arePeerCerts) { + /* renegotiate - start with a new SecTrustRef */ + CFRelease(ctx->peerSecTrust); + ctx->peerSecTrust = NULL; } + numCerts = SSLGetCertificateChainLength(&certChain); if(numCerts == 0) { /* nope */ return errSSLBadCert; } - #if 0 - serr = attachToAll(ctx); - if(serr) { - return serr; - } - #endif /* - * SSLCertificate chain --> CSSM TP cert group. + * SSLCertificate chain --> CFArrayRef of SecCertificateRefs. * TP Cert group has root at the end, opposite of * SSLCertificate chain. */ - certGroup.GroupList.CertList = - (CSSM_DATA_PTR)sslMalloc(numCerts * sizeof(CSSM_DATA)); - if(certGroup.GroupList.CertList == NULL) { + CFMutableArrayRef certGroup = CFArrayCreateMutable(NULL, numCerts, + &kCFTypeArrayCallBacks); + if(certGroup == NULL) { return memFullErr; } - certGroup.CertGroupType = CSSM_CERTGROUP_DATA; - certGroup.CertType = CSSM_CERT_X_509v3; - certGroup.CertEncoding = CSSM_CERT_ENCODING_DER; - certGroup.NumCerts = numCerts; - - memset(certGroup.GroupList.CertList, 0, numCerts * sizeof(CSSM_DATA)); + /* subsequent errors to errOut: */ for(i=numCerts-1; i>=0; i--) { - SSLBUF_TO_CSSM(&c->derCert, &certGroup.GroupList.CertList[i]); + CSSM_DATA cdata; + SSLBUF_TO_CSSM(&c->derCert, &cdata); + serr = SecCertificateCreateFromData(&cdata, CSSM_CERT_X_509v3, + CSSM_CERT_ENCODING_DER, &cert); + if(serr) { + goto errOut; + } + /* + * Can't set a value at index i when there is an empty element + * at i=1! + */ + secdebug("sslcert", "Adding cert %p", cert); + CFArrayInsertValueAtIndex(certGroup, 0, cert); c = c->next; } - memset(&vfyCtx, 0, sizeof(CSSM_TP_VERIFY_CONTEXT)); - vfyCtx.Action = CSSM_TP_ACTION_DEFAULT; - vfyCtx.Cred = &authCtx; - - /* CSSM_TP_CALLERAUTH_CONTEXT components */ /* - typedef struct cssm_tp_callerauth_context { - CSSM_TP_POLICYINFO Policy; - CSSM_TIMESTRING VerifyTime; - CSSM_TP_STOP_ON VerificationAbortOn; - CSSM_TP_VERIFICATION_RESULTS_CALLBACK CallbackWithVerifiedCert; - uint32 NumberOfAnchorCerts; - CSSM_DATA_PTR AnchorCerts; - CSSM_DL_DB_LIST_PTR DBList; - CSSM_ACCESS_CREDENTIALS_PTR CallerCredentials; - } CSSM_TP_CALLERAUTH_CONTEXT, *CSSM_TP_CALLERAUTH_CONTEXT_PTR; - */ - - /* SSL-specific FieldValue */ + * Cook up an SSL-specific SecPolicyRef. This will persists as part + * of the SecTrustRef object we'll be creating. + */ + serr = SecPolicySearchCreate(CSSM_CERT_X_509v3, + &CSSMOID_APPLE_TP_SSL, + NULL, + &policySearch); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecPolicySearchCreate rtn %d\n", + (int)serr); + goto errOut; + } + serr = SecPolicySearchCopyNext(policySearch, &policy); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecPolicySearchCopyNext rtn %d\n", + (int)serr); + goto errOut; + } sslOpts.Version = CSSM_APPLE_TP_SSL_OPTS_VERSION; - if(verifyHostName) { + if(arePeerCerts) { sslOpts.ServerNameLen = ctx->peerDomainNameLen; sslOpts.ServerName = ctx->peerDomainName; } @@ -1173,88 +1095,160 @@ OSStatus sslVerifyCertChain( sslOpts.ServerNameLen = 0; sslOpts.ServerName = NULL; } + sslOptsData.Data = (uint8 *)&sslOpts; + sslOptsData.Length = sizeof(sslOpts); + serr = SecPolicySetValue(policy, &sslOptsData); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecPolicySetValue rtn %d\n", + (int)serr); + goto errOut; + } - /* TP-wide ActionData */ - actionData.Version = CSSM_APPLE_TP_ACTION_VERSION; - if(ctx->numTrustedCerts != 0) { - /* use our anchors */ - actionData.ActionFlags = 0; + /* now a SecTrustRef */ + serr = SecTrustCreateWithCertificates(certGroup, policy, &theTrust); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecTrustCreateWithCertificates " + "rtn %d\n", (int)serr); + goto errOut; } - else { - /* secret root-cert-enable */ - actionData.ActionFlags = 0x80000000; + + /* anchors - default, or ours? */ + if(ctx->numTrustedCerts != 0) { + anchors = CFArrayCreateMutable(NULL, ctx->numTrustedCerts, + &kCFTypeArrayCallBacks); + if(anchors == NULL) { + serr = memFullErr; + goto errOut; + } + for(i=0; i<(int)ctx->numTrustedCerts; i++) { + serr = SecCertificateCreateFromData(&ctx->trustedCerts[i], + CSSM_CERT_X_509v3, CSSM_CERT_ENCODING_DER, &cert); + if(serr) { + goto errOut; + } + secdebug("sslcert", "Adding cert %p", cert); + CFArraySetValueAtIndex(anchors, i, cert); + } + serr = SecTrustSetAnchorCertificates(theTrust, anchors); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecTrustSetAnchorCertificates " + "rtn %d\n", (int)serr); + goto errOut; + } } + tpActionData.Version = CSSM_APPLE_TP_ACTION_VERSION; + tpActionData.ActionFlags = 0; if(ctx->allowExpiredCerts) { - actionData.ActionFlags |= CSSM_TP_ACTION_ALLOW_EXPIRED; + tpActionData.ActionFlags |= CSSM_TP_ACTION_ALLOW_EXPIRED; } if(ctx->allowExpiredRoots) { - actionData.ActionFlags |= CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT; + tpActionData.ActionFlags |= CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT; } - vfyCtx.ActionData.Data = (uint8 *)&actionData; - vfyCtx.ActionData.Length = sizeof(actionData); - - /* zero or one policy here */ - policyId.FieldOid = CSSMOID_APPLE_TP_SSL; - policyId.FieldValue.Data = (uint8 *)&sslOpts; - policyId.FieldValue.Length = sizeof(sslOpts); - authCtx.Policy.NumberOfPolicyIds = 1; - authCtx.Policy.PolicyIds = &policyId; + actionData = CFDataCreate(NULL, (UInt8 *)&tpActionData, sizeof(tpActionData)); - authCtx.VerifyTime = NULL; - authCtx.VerificationAbortOn = CSSM_TP_STOP_ON_POLICY; - authCtx.CallbackWithVerifiedCert = NULL; - authCtx.NumberOfAnchorCerts = ctx->numTrustedCerts; - authCtx.AnchorCerts = ctx->trustedCerts; - memset(&dbList, 0, sizeof(CSSM_DL_DB_LIST)); - authCtx.DBList = &dbList; - authCtx.CallerCredentials = NULL; + serr = SecTrustSetParameters(theTrust, CSSM_TP_ACTION_DEFAULT, + actionData); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecTrustSetParameters rtn %d\n", + (int)serr); + goto errOut; + } + #if 0 + /* Disabled for Radar 3421314 */ /* - * Here we go; hand it over to TP. Note trustedCerts are our - * known good Anchor certs; they're already formatted properly. - * Unlike most other Apple code, we demand full success here, - * implying that the last cert in the chain is indeed an Anchor - * cert. We already know that all of our anchor certs are - * roots, so on successful return, we'll know the incoming - * chain has a root, it verifies to that root, and that that - * root is in trustedCerts. + * Avoid searching user keychains for intermediate certs by specifying + * an empty array of keychains */ - crtn = CSSM_TP_CertGroupVerify(ctx->tpHand, - ctx->clHand, - ctx->cspHand, - &certGroup, - &vfyCtx, - NULL); // no evidence needed + kcList = CFArrayCreateMutable(NULL, 0, NULL); + if(kcList == NULL) { + sslErrorLog("***sslVerifyCertChain: error creating null kcList\n"); + serr = memFullErr; + goto errOut; + } + serr = SecTrustSetKeychains(theTrust, kcList); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecTrustSetKeychains rtn %d\n", + (int)serr); + goto errOut; + } + #endif + + /* + * Save this no matter what if we're evaluating peer certs. + * We do a retain here so we can unconditionally release theTrust + * at the end of this routine in case of previous error or + * !arePeerCerts. + */ + if(arePeerCerts) { + ctx->peerSecTrust = theTrust; + CFRetain(theTrust); + } - serr = noErr; + if(!ctx->enableCertVerify) { + /* trivial case, this is caller's responsibility */ + serr = noErr; + goto errOut; + } + + /* + * Here we go; hand it over to SecTrust/TP. + */ + serr = SecTrustEvaluate(theTrust, &secTrustResult); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecTrustEvaluate rtn %d\n", + (int)serr); + goto errOut; + } + switch(secTrustResult) { + case kSecTrustResultUnspecified: + /* cert chain valid, no special UserTrust assignments */ + case kSecTrustResultProceed: + /* cert chain valid AND user explicitly trusts this */ + crtn = CSSM_OK; + break; + case kSecTrustResultDeny: + case kSecTrustResultConfirm: + /* + * Cert chain may well have verified OK, but user has flagged + * one of these certs as untrustable. + */ + crtn = CSSMERR_TP_NOT_TRUSTED; + break; + default: + { + OSStatus osCrtn; + serr = SecTrustGetCssmResultCode(theTrust, &osCrtn); + if(serr) { + sslErrorLog("***sslVerifyCertChain: SecTrustGetCssmResultCode" + " rtn %d\n", (int)serr); + goto errOut; + } + crtn = osCrtn; + } + } if(crtn) { /* get some detailed error info */ switch(crtn) { case CSSMERR_TP_INVALID_ANCHOR_CERT: /* root found but we don't trust it */ if(ctx->allowAnyRoot) { + serr = noErr; sslErrorLog("***Warning: accepting unknown root cert\n"); - break; - } - #if ST_MANAGES_TRUSTED_ROOTS - if(ctx->newRootCertKc != NULL) { - /* see if user wants to handle new root */ - serr = sslHandleNewRoot(ctx, &certGroup); } else { serr = errSSLUnknownRootCert; } - #else - serr = errSSLUnknownRootCert; - #endif /* ST_MANAGES_TRUSTED_ROOTS */ break; case CSSMERR_TP_NOT_TRUSTED: /* no root, not even in implicit SSL roots */ if(ctx->allowAnyRoot) { sslErrorLog("***Warning: accepting unverified cert chain\n"); - break; + serr = noErr; + } + else { + serr = errSSLNoRootCert; } - serr = errSSLNoRootCert; break; case CSSMERR_TP_CERT_EXPIRED: assert(!ctx->allowExpiredCerts); @@ -1264,87 +1258,280 @@ OSStatus sslVerifyCertChain( serr = errSSLCertNotYetValid; break; default: - stPrintCdsaError( - "sslVerifyCertChain: CSSM_TP_CertGroupVerify returned", crtn); + stPrintCdsaError("sslVerifyCertChain: SecTrustEvaluate returned", + crtn); serr = errSSLXCertChainInvalid; break; } - } /* brtn FALSE */ + } /* SecTrustEvaluate error */ +errOut: /* - * don't free individual certs - caller still owns them - * don't free struct - on stack + * Free up resources - certGroup, policy, etc. Note that most of these + * will actually persist as long as the current SSLContext does since + * peerSecTrust holds references to these. */ - sslFree(certGroup.GroupList.CertList); + if(policy) { + CFRelease(policy); + } + if(policySearch) { + CFRelease(policySearch); + } + if(actionData) { + CFRelease(actionData); + } + if(anchors) { + sslReleaseArray(anchors); + CFRelease(anchors); + } + if(certGroup) { + sslReleaseArray(certGroup); + CFRelease(certGroup); + } + if(kcList) { + /* empty, no contents to release */ + CFRelease(kcList); + } + if(theTrust) { + CFRelease(theTrust); + } return serr; } -#if ST_MANAGES_TRUSTED_ROOTS +#ifndef NDEBUG +void stPrintCdsaError(const char *op, CSSM_RETURN crtn) +{ + cssmPerror(op, crtn); +} + +char *stCssmErrToStr(CSSM_RETURN err) +{ + string errStr = cssmErrorString(err); + return const_cast(errStr.c_str()); +} +#endif + +#pragma mark - +#pragma mark *** Diffie-Hellman support *** /* - * Given a DER-encoded cert, obtain its DER-encoded subject name. + * Generate a Diffie-Hellman key pair. Algorithm parameters always + * come from the server, so on client side we have the parameters + * as two SSLBuffers. On server side we have the pre-encoded block + * which comes from ServerDhParams. */ -CSSM_DATA_PTR sslGetCertSubjectName( - SSLContext *ctx, - const CSSM_DATA_PTR cert) +OSStatus sslDhGenKeyPairClient( + SSLContext *ctx, + const SSLBuffer &prime, + const SSLBuffer &generator, + CSSM_KEY_PTR publicKey, // RETURNED + CSSM_KEY_PTR privateKey) // RETURNED { - uint32 NumberOfFields = 0; - CSSM_HANDLE ResultsHandle = 0; - CSSM_DATA_PTR pEncodedName = NULL; - CSSM_RETURN crtn; - - /* ensure connection to CL */ - if(attachToCl(ctx)) { - return NULL; + assert((prime.data != NULL) && (generator.data != NULL)); + if(prime.data && !generator.data) { + return errSSLProtocol; } - crtn = CSSM_CL_CertGetFirstFieldValue( - ctx->clHand, - cert, - &CSSMOID_X509V1SubjectName, - &ResultsHandle, - &NumberOfFields, - &pEncodedName); - if(crtn) { - stPrintCdsaError("CertGetFirstFieldValue", crtn); + if(!prime.data && generator.data) { + return errSSLProtocol; } - CSSM_CL_CertAbortQuery(ctx->clHand, ResultsHandle); - return pEncodedName; + + SSLBuffer sParam; + OSStatus ortn = sslEncodeDhParams(&prime, &generator, &sParam); + if(ortn) { + sslErrorLog("***sslDhGenerateKeyPairClient: DH param error\n"); + return ortn; + } + ortn = sslDhGenerateKeyPair(ctx, sParam, prime.length * 8, publicKey, privateKey); + SSLFreeBuffer(sParam, ctx); + return ortn; } -#endif /* ST_MANAGES_TRUSTED_ROOTS */ -#if (SSL_DEBUG && ST_MANAGES_TRUSTED_ROOTS) -void verifyTrustedRoots(SSLContext *ctx, - CSSM_DATA_PTR certs, - unsigned numCerts) -{ - int i; - CSSM_DATA_PTR cert; - CSSM_BOOL expired; +OSStatus sslDhGenerateKeyPair( + SSLContext *ctx, + const SSLBuffer ¶mBlob, + UInt32 keySizeInBits, + CSSM_KEY_PTR publicKey, // RETURNED + CSSM_KEY_PTR privateKey) // RETURNED +{ + CSSM_RETURN crtn; + CSSM_CC_HANDLE ccHandle; + CSSM_DATA labelData = {8, (uint8 *)"tempKey"}; + OSStatus ortn = noErr; + CSSM_DATA cParamBlob; + + assert(ctx != NULL); + assert(ctx->cspHand != 0); - for(i=0; icspHand, - &expired)) { - sslErrorLog("Bad trusted cert!\n"); - } + memset(publicKey, 0, sizeof(CSSM_KEY)); + memset(privateKey, 0, sizeof(CSSM_KEY)); + SSLBUF_TO_CSSM(¶mBlob, &cParamBlob); + + crtn = CSSM_CSP_CreateKeyGenContext(ctx->cspHand, + CSSM_ALGID_DH, + keySizeInBits, + NULL, // Seed + NULL, // Salt + NULL, // StartDate + NULL, // EndDate + &cParamBlob, + &ccHandle); + if(crtn) { + stPrintCdsaError("DH CSSM_CSP_CreateKeyGenContext", crtn); + return errSSLCrypto; } + + crtn = CSSM_GenerateKeyPair(ccHandle, + CSSM_KEYUSE_DERIVE, // only legal use of a Diffie-Hellman key + CSSM_KEYATTR_RETURN_DATA | CSSM_KEYATTR_EXTRACTABLE, + &labelData, + publicKey, + /* private key specification */ + CSSM_KEYUSE_DERIVE, + CSSM_KEYATTR_RETURN_REF, + &labelData, // same labels + NULL, // CredAndAclEntry + privateKey); + if(crtn) { + stPrintCdsaError("DH CSSM_GenerateKeyPair", crtn); + ortn = errSSLCrypto; + } + CSSM_DeleteContext(ccHandle); + return ortn; } -#endif -#ifndef NDEBUG -void stPrintCdsaError(const char *op, CSSM_RETURN crtn) +/* + * Perform Diffie-Hellman key exchange. + * Valid on entry: + * ctx->dhPrivate + * ctx->dhPeerPublic + * + * This generates deriveSizeInBits of key-exchanged data. + */ + +/* the alg isn't important; we just want to be able to cook up lots of bits */ +#define DERIVE_KEY_ALG CSSM_ALGID_RC5 +#define DERIVE_KEY_MAX_BYTES 255 + +OSStatus sslDhKeyExchange( + SSLContext *ctx, + uint32 deriveSizeInBits, + SSLBuffer *exchanged) { - cssmPerror(op, crtn); + CSSM_RETURN crtn; + CSSM_ACCESS_CREDENTIALS creds; + CSSM_CC_HANDLE ccHandle; + CSSM_DATA labelData = {8, (uint8 *)"tempKey"}; + CSSM_KEY derivedKey; + OSStatus ortn = noErr; + + assert(ctx != NULL); + assert(ctx->cspHand != 0); + assert(ctx->dhPrivate != NULL); + if(ctx->dhPeerPublic.length == 0) { + /* comes from peer, don't panic */ + sslErrorLog("cdsaDhKeyExchange: null peer public key\n"); + return errSSLProtocol; + } + if(deriveSizeInBits > (DERIVE_KEY_MAX_BYTES * 8)) { + sslErrorLog("cdsaDhKeyExchange: deriveSizeInBits %u bits\n", + (unsigned)deriveSizeInBits); + return errSSLProtocol; + } + + memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS)); + memset(&derivedKey, 0, sizeof(CSSM_KEY)); + + crtn = CSSM_CSP_CreateDeriveKeyContext(ctx->cspHand, + CSSM_ALGID_DH, + DERIVE_KEY_ALG, + deriveSizeInBits, + &creds, + ctx->dhPrivate, // BaseKey + 0, // IterationCount + 0, // Salt + 0, // Seed + &ccHandle); + if(crtn) { + stPrintCdsaError("DH CSSM_CSP_CreateDeriveKeyContext", crtn); + return errSSLCrypto; + } + + /* public key passed in as CSSM_DATA *Param */ + CSSM_DATA theirPubKeyData; + SSLBUF_TO_CSSM(&ctx->dhPeerPublic, &theirPubKeyData); + + crtn = CSSM_DeriveKey(ccHandle, + &theirPubKeyData, + CSSM_KEYUSE_ANY, + CSSM_KEYATTR_RETURN_DATA | CSSM_KEYATTR_EXTRACTABLE, + &labelData, + NULL, // cread/acl + &derivedKey); + if(crtn) { + stPrintCdsaError("DH CSSM_DeriveKey", crtn); + ortn = errSSLCrypto; + } + else { + CSSM_TO_SSLBUF(&derivedKey.KeyData, exchanged); + } + CSSM_DeleteContext(ccHandle); + return ortn; } -char *stCssmErrToStr(CSSM_RETURN err) +/* + * After ciphersuite negotiation is complete, verify that we have + * the capability of actually performing the negotiated cipher. + * Currently we just verify that we have a cert and private signing + * key, if needed, and that the signing key's algorithm matches the + * expected key exchange method. + * This is currnetly only called from FindCipherSpec(), after + * it sets ctx->selectedCipherSpec to a (supposedly) valid value. + */ +OSStatus sslVerifyNegotiatedCipher( + SSLContext *ctx) { - string errStr = cssmErrorString(err); - return const_cast(errStr.c_str()); + if(ctx->protocolSide == SSL_ClientSide) { + return noErr; + } + CSSM_ALGORITHMS requireAlg = CSSM_ALGID_NONE; + + switch (ctx->selectedCipherSpec->keyExchangeMethod) { + case SSL_RSA: + case SSL_RSA_EXPORT: + case SSL_DH_RSA: + case SSL_DH_RSA_EXPORT: + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + requireAlg = CSSM_ALGID_RSA; + break; + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + case SSL_DH_DSS: + case SSL_DH_DSS_EXPORT: + requireAlg = CSSM_ALGID_DSA; + break; + case SSL_DH_anon: + case SSL_DH_anon_EXPORT: + /* CSSM_ALGID_NONE, no signing key */ + break; + default: + /* needs update per cipherSpecs.cpp */ + assert(0); + return errSSLInternal; + } + if(requireAlg == CSSM_ALGID_NONE) { + return noErr; + } + + /* private signing key required */ + if(ctx->signingPrivKey == NULL) { + sslErrorLog("sslVerifyNegotiatedCipher: no signing key\n"); + return errSSLBadConfiguration; + } + if(ctx->signingPrivKey->KeyHeader.AlgorithmId != requireAlg) { + sslErrorLog("sslVerifyNegotiatedCipher: signing key alg mismatch\n"); + return errSSLBadConfiguration; + } + return noErr; } -#endif - diff --git a/SecureTransport/cipherSpecs.cpp b/SecureTransport/cipherSpecs.cpp index e5b7fab8..5562ac9e 100644 --- a/SecureTransport/cipherSpecs.cpp +++ b/SecureTransport/cipherSpecs.cpp @@ -35,11 +35,13 @@ #include "sslMemory.h" #include "sslDebug.h" #include "sslUtils.h" +#include "sslPriv.h" +#include "appleCdsa.h" #include #include -#define ENABLE_3DES 1 /* normally enabled, our first preference */ -#define ENABLE_RC4 1 /* normally enabled, the most common one */ +#define ENABLE_3DES 1 /* normally enabled */ +#define ENABLE_RC4 1 /* normally enabled, our first preference */ #define ENABLE_DES 1 /* normally enabled */ #define ENABLE_RC2 1 /* normally enabled */ @@ -54,6 +56,16 @@ #define ENABLE_RSA_3DES_SHA ENABLE_3DES #define ENABLE_RSA_3DES_MD5 ENABLE_3DES +#if APPLE_DH +#define ENABLE_DH_ANON 1 +#define ENABLE_DH_EPHEM_RSA 1 +#define ENABLE_DH_EPHEM_DSA 1 +#else +#define ENABLE_DH_ANON 0 +#define ENABLE_DH_EPHEM_RSA 0 +#define ENABLE_DH_EPHEM_DSA 0 +#endif /* APPLE_DH */ + extern "C" { extern const SSLSymmetricCipher SSLCipherNull; /* in sslNullCipher.cpp */ } @@ -203,42 +215,42 @@ const SSLCipherSpec SSL_NULL_WITH_NULL_NULL_CipherSpec = static const SSLCipherSpec KnownCipherSpecs[] = { /*** domestic only ***/ - #if ENABLE_RSA_3DES_SHA + #if ENABLE_RSA_RC4_SHA_NONEXPORT { - SSL_RSA_WITH_3DES_EDE_CBC_SHA, + SSL_RSA_WITH_RC4_128_SHA, NotExportable, SSL_RSA, &HashHmacSHA1, - &SSLCipher3DES_CBC + &SSLCipherRC4_128 }, - #endif - #if ENABLE_RSA_3DES_MD5 + #endif + #if ENABLE_RSA_RC4_MD5_NONEXPORT { - SSL_RSA_WITH_3DES_EDE_CBC_MD5, + SSL_RSA_WITH_RC4_128_MD5, NotExportable, SSL_RSA, &HashHmacMD5, - &SSLCipher3DES_CBC + &SSLCipherRC4_128 }, - #endif - #if ENABLE_RSA_RC4_SHA_NONEXPORT + #endif + #if ENABLE_RSA_3DES_SHA { - SSL_RSA_WITH_RC4_128_SHA, + SSL_RSA_WITH_3DES_EDE_CBC_SHA, NotExportable, SSL_RSA, &HashHmacSHA1, - &SSLCipherRC4_128 + &SSLCipher3DES_CBC }, - #endif - #if ENABLE_RSA_RC4_MD5_NONEXPORT + #endif + #if ENABLE_RSA_3DES_MD5 { - SSL_RSA_WITH_RC4_128_MD5, + SSL_RSA_WITH_3DES_EDE_CBC_MD5, NotExportable, SSL_RSA, &HashHmacMD5, - &SSLCipherRC4_128 + &SSLCipher3DES_CBC }, - #endif + #endif #if ENABLE_RSA_DES_SHA_NONEXPORT { SSL_RSA_WITH_DES_CBC_SHA, @@ -267,16 +279,6 @@ static const SSLCipherSpec KnownCipherSpecs[] = &SSLCipherRC4_40 }, #endif - #if APPLE_DH - /* Apple CSP doesn't support D-H yet */ - { - SSL_DH_anon_WITH_RC4_128_MD5, - NotExportable, - SSL_DH_anon, - &HashHmacMD5, - &SSLCipherRC4_128 - }, - #endif #if ENABLE_RSA_DES_SHA_EXPORT { SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, @@ -311,7 +313,92 @@ static const SSLCipherSpec KnownCipherSpecs[] = SSL_RSA, &HashHmacMD5, &SSLCipherNull - } + }, + #if ENABLE_DH_EPHEM_RSA + { + SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, + NotExportable, + SSL_DHE_RSA, + &HashHmacSHA1, + &SSLCipher3DES_CBC + }, + { + SSL_DHE_RSA_WITH_DES_CBC_SHA, + NotExportable, + SSL_DHE_RSA, + &HashHmacSHA1, + &SSLCipherDES_CBC + }, + { + SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, + Exportable, + SSL_DHE_RSA, + &HashHmacSHA1, + &SSLCipherDES40_CBC + }, + + #endif /* ENABLE_DH_EPHEM_RSA */ + #if ENABLE_DH_EPHEM_DSA + { + SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, + NotExportable, + SSL_DHE_DSS, + &HashHmacSHA1, + &SSLCipher3DES_CBC + }, + { + SSL_DHE_DSS_WITH_DES_CBC_SHA, + NotExportable, + SSL_DHE_DSS, + &HashHmacSHA1, + &SSLCipherDES_CBC + }, + { + SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, + Exportable, + SSL_DHE_DSS, + &HashHmacSHA1, + &SSLCipherDES40_CBC + }, + + #endif /* ENABLE_DH_EPHEM_DSA */ + #if ENABLE_DH_ANON + { + SSL_DH_anon_WITH_RC4_128_MD5, + NotExportable, + SSL_DH_anon, + &HashHmacMD5, + &SSLCipherRC4_128 + }, + { + SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, + NotExportable, + SSL_DH_anon, + &HashHmacSHA1, + &SSLCipher3DES_CBC + }, + { + SSL_DH_anon_WITH_DES_CBC_SHA, + NotExportable, + SSL_DH_anon, + &HashHmacSHA1, + &SSLCipherDES_CBC + }, + { + SSL_DH_anon_EXPORT_WITH_RC4_40_MD5, + Exportable, + SSL_DH_anon, + &HashHmacMD5, + &SSLCipherRC4_40 + }, + { + SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA, + Exportable, + SSL_DH_anon, + &HashHmacSHA1, + &SSLCipherDES40_CBC + }, + #endif /* APPLE_DH */ }; static const unsigned CipherSpecCount = sizeof(KnownCipherSpecs) / sizeof(SSLCipherSpec); @@ -527,6 +614,8 @@ FindCipherSpec(SSLContext *ctx) } if (ctx->selectedCipherSpec == NULL) /* Not found */ return errSSLNegotiation; - return noErr; + + /* make sure we're configured to handle this one */ + return sslVerifyNegotiatedCipher(ctx); } diff --git a/SecureTransport/privateInc/SecureTransportPriv.h b/SecureTransport/privateInc/SecureTransportPriv.h index 0d9e0d4c..2c5f2dd2 100644 --- a/SecureTransport/privateInc/SecureTransportPriv.h +++ b/SecureTransport/privateInc/SecureTransportPriv.h @@ -30,6 +30,8 @@ #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -72,6 +74,34 @@ OSStatus SSLInternal_PRF( void *out, // mallocd by caller, length >= outLen size_t outLen); +/* + * Obtain a SecTrustRef representing peer certificates. Valid anytime, + * subsequent to a handshake attempt. The returned SecTrustRef is valid + * only as long as the SSLContextRef is. + */ +OSStatus +SSLGetPeerSecTrust (SSLContextRef context, + SecTrustRef *secTrust); /* RETURNED */ + +/* + * Obtain resumable session info. Can be called anytime subsequent to + * handshake attempt. + * + * if sessionWasResumed is True on return, the session is indeed a + * resumed session; the sessionID (an opaque blob generated by the + * server) is returned in *sessionID. The length of the sessionID + * is returned in *sessionIDLength. Caller must allocate the + * sessionID buffer; it max size is MAX_SESSION_ID_LENGTH bytes. + */ +#define MAX_SESSION_ID_LENGTH 32 + +OSStatus +SSLGetResumableSessionInfo ( + SSLContextRef context, + Boolean *sessionWasResumed, // RETURNED + void *sessionID, // RETURNED, mallocd by caller + size_t *sessionIDLength); // IN/OUT + #ifdef __cplusplus } #endif diff --git a/SecureTransport/privateInc/appleCdsa.h b/SecureTransport/privateInc/appleCdsa.h index fc2b64f9..548af4fb 100644 --- a/SecureTransport/privateInc/appleCdsa.h +++ b/SecureTransport/privateInc/appleCdsa.h @@ -88,12 +88,12 @@ extern OSStatus sslPubKeyFromCert( extern OSStatus sslVerifyCertChain( SSLContext *ctx, const SSLCertificate &certChain, - bool verifyHostName = true); + bool arePeerCerts = true); /* - * Raw RSA sign/verify. + * Raw RSA/DSA sign/verify. */ -OSStatus sslRsaRawSign( +OSStatus sslRawSign( SSLContext *ctx, const CSSM_KEY *privKey, CSSM_CSP_HANDLE cspHand, @@ -103,7 +103,7 @@ OSStatus sslRsaRawSign( UInt32 sigLen, // available UInt32 *actualBytes); // RETURNED -OSStatus sslRsaRawVerify( +OSStatus sslRawVerify( SSLContext *ctx, const CSSM_KEY *pubKey, CSSM_CSP_HANDLE cspHand, @@ -140,6 +140,11 @@ OSStatus sslRsaDecrypt( extern UInt32 sslKeyLengthInBytes( const CSSM_KEY *key); +/* Obtain max signature size in bytes. */ +extern OSStatus sslGetMaxSigSize( + const CSSM_KEY *privKey, + UInt32 &maxSigSize); + /* * Get raw key bits from an RSA public key. */ @@ -179,6 +184,25 @@ void stAppFree (void *mem_ptr, void *allocRef); void * stAppRealloc (void *ptr, uint32 size, void *allocRef); void * stAppCalloc (uint32 num, uint32 size, void *allocRef); +OSStatus sslDhGenKeyPairClient( + SSLContext *ctx, + const SSLBuffer &prime, + const SSLBuffer &generator, + CSSM_KEY_PTR publicKey, // RETURNED + CSSM_KEY_PTR privateKey); // RETURNED +OSStatus sslDhGenerateKeyPair( + SSLContext *ctx, + const SSLBuffer ¶mBlob, + UInt32 keySizeInBits, + CSSM_KEY_PTR publicKey, // RETURNED + CSSM_KEY_PTR privateKey); // RETURNED +OSStatus sslDhKeyExchange( + SSLContext *ctx, + uint32 deriveSizeInBits, + SSLBuffer *exchanged); +OSStatus sslVerifyNegotiatedCipher( + SSLContext *ctx); + /* * Convert between SSLBuffer and CSSM_DATA, which are after all identical. * No mallocs, just copy the pointer and length. diff --git a/SecureTransport/privateInc/cryptType.h b/SecureTransport/privateInc/cryptType.h index 93da7ac7..be6006c4 100644 --- a/SecureTransport/privateInc/cryptType.h +++ b/SecureTransport/privateInc/cryptType.h @@ -174,6 +174,13 @@ typedef struct { extern const SSLCipherMapping SSL2CipherMap[]; extern const unsigned SSL2CipherMapCount; +/* Default size of server-generated Diffie-Hellman parameters and keys */ +#ifdef NDEBUG +#define SSL_DH_DEFAULT_PRIME_SIZE 1024 /* in bits */ +#else +#define SSL_DH_DEFAULT_PRIME_SIZE 512 /* in bits */ +#endif + #ifdef __cplusplus } #endif diff --git a/SecureTransport/privateInc/sslAlertMessage.h b/SecureTransport/privateInc/sslAlertMessage.h index 9b751f43..3100b083 100644 --- a/SecureTransport/privateInc/sslAlertMessage.h +++ b/SecureTransport/privateInc/sslAlertMessage.h @@ -44,11 +44,11 @@ typedef enum SSL_AlertUnexpectedMsg = 10, SSL_AlertBadRecordMac = 20, SSL_AlertDecryptionFail = 21, /* TLS */ - SSL_AlertRecordOverflow = 22, /* TLS */ + SSL_AlertRecordOverflow = 22, /* TLS */ SSL_AlertDecompressFail = 30, SSL_AlertHandshakeFail = 40, SSL_AlertNoCert = 41, - SSL_AlertBadCert = 42, /* SSLv3 only */ + SSL_AlertBadCert = 42, /* SSLv3 only */ SSL_AlertUnsupportedCert = 43, SSL_AlertCertRevoked = 44, SSL_AlertCertExpired = 45, @@ -74,11 +74,6 @@ OSStatus SSLSendAlert( AlertLevel level, AlertDescription desc, SSLContext *ctx); -OSStatus SSLEncodeAlert( - SSLRecord &rec, - AlertLevel level, - AlertDescription desc, - SSLContext *ctx); OSStatus SSLFatalSessionAlert( AlertDescription desc, SSLContext *ctx); diff --git a/SecureTransport/privateInc/sslBER.h b/SecureTransport/privateInc/sslBER.h index 02dd3ee6..2ebc444d 100644 --- a/SecureTransport/privateInc/sslBER.h +++ b/SecureTransport/privateInc/sslBER.h @@ -62,6 +62,23 @@ OSStatus sslEncodeRsaBlob( const SSLBuffer *exponent, SSLBuffer *blob); /* data mallocd and RETURNED */ +/* + * Given a DER encoded DHParameter, extract the prime and generator. + * modulus and public exponent. + */ +OSStatus sslDecodeDhParams( + const SSLBuffer *blob, /* PKCS-1 encoded */ + SSLBuffer *prime, /* data mallocd and RETURNED */ + SSLBuffer *generator); /* data mallocd and RETURNED */ + +/* + * Given a prime and generator, cook up a BER-encoded DHParameter blob. + */ +OSStatus sslEncodeDhParams( + const SSLBuffer *prime, + const SSLBuffer *generator, + SSLBuffer *blob); /* data mallocd and RETURNED */ + #ifdef __cplusplus } #endif diff --git a/SecureTransport/privateInc/sslBuildFlags.h b/SecureTransport/privateInc/sslBuildFlags.h index e0fe84cb..9a0c3cfd 100644 --- a/SecureTransport/privateInc/sslBuildFlags.h +++ b/SecureTransport/privateInc/sslBuildFlags.h @@ -58,20 +58,6 @@ extern "C" { */ #define RSA_PUB_KEY_USAGE_HACK 1 -/* - * CSSM_KEYs obtained from Keychain require a SecKeychainRef to be freed/released. - * True on 9, false on X. - */ -#define ST_KC_KEYS_NEED_REF 0 - -/* - * We manage trusted certs and pass them to the TP. - * -- OS 9 - true - * -- OS 10, 10.1 - false - * -- Jaguar - TBD. SSLSetNewRootKC and SSLSetTrustedRootCertKC deleted for now. - */ -#define ST_MANAGES_TRUSTED_ROOTS 0 - /* debugging flags */ #ifdef NDEBUG #define SSL_DEBUG 0 diff --git a/SecureTransport/privateInc/sslContext.h b/SecureTransport/privateInc/sslContext.h index 0a82dbd7..7126fb90 100644 --- a/SecureTransport/privateInc/sslContext.h +++ b/SecureTransport/privateInc/sslContext.h @@ -112,35 +112,38 @@ struct SSLContext IOContext ioCtx; /* - * For the first two, SSL_Version_Undetermined means "get the best we - * can, up to macProtocolVersion". + * Prior to successful protocol negotiation, negProtocolVersion + * is SSL_Version_Undetermined. Subsequent to successful + * negotiation, negProtocolVersion contains the actual over-the-wire + * protocol value. + * + * The Boolean versionEnable flags are set by + * SSLSetProtocolVersionEnabled or SSLSetProtocolVersion and + * remain invariant once negotiation has started. If there + * were a large number of these and/or we were adding new + * protocol versions on a regular basis, we'd probably want + * to implement these as a word of flags. For now, in the + * real world, this is the most straightfoprward implementation. */ - SSLProtocolVersion reqProtocolVersion; /* requested by app */ SSLProtocolVersion negProtocolVersion; /* negotiated */ - SSLProtocolVersion maxProtocolVersion; /* max allowed by app */ - SSLProtocolSide protocolSide; + SSLProtocolVersion clientReqProtocol; /* requested by client in hello msg */ + Boolean versionSsl2Enable; + Boolean versionSsl3Enable; + Boolean versionTls1Enable; + SSLProtocolSide protocolSide; + const struct _SslTlsCallouts *sslTslCalls; /* selects between SSLv3 and TLSv1 */ /* crypto state in CDSA-centric terms */ - CSSM_KEY_PTR signingPrivKey;/* our private signing key */ + CSSM_KEY_PTR signingPrivKey; /* our private signing key */ CSSM_KEY_PTR signingPubKey; /* our public signing key */ CSSM_CSP_HANDLE signingKeyCsp; /* associated DL/CSP */ - #if ST_KC_KEYS_NEED_REF - SecKeychainRef signingKeyRef; /* for signingPrivKey */ - #else - void *signingKeyRef; /* TBD */ - #endif /* ST_KC_KEYS_NEED_REF */ - CSSM_KEY_PTR encryptPrivKey;/* our private encrypt key, for + CSSM_KEY_PTR encryptPrivKey; /* our private encrypt key, for * server-initiated key exchange */ CSSM_KEY_PTR encryptPubKey; /* public version of above */ CSSM_CSP_HANDLE encryptKeyCsp; - #if ST_KC_KEYS_NEED_REF - SecKeychainRef encryptKeyRef; /* for signingPrivKey */ - #else - void *encryptKeyRef; /* TBD */ - #endif /* ST_KC_KEYS_NEED_REF */ CSSM_KEY_PTR peerPubKey; CSSM_CSP_HANDLE peerPubKeyCsp; /* may not be needed, we figure this @@ -154,6 +157,9 @@ struct SSLContext SSLCertificate *encryptCert; SSLCertificate *peerCert; + /* peer certs as SecTrustRef */ + SecTrustRef peerSecTrust; + /* * trusted root certs; specific to this implementation, we'll store * them conveniently...these will be used as AnchorCerts in a TP @@ -162,15 +168,6 @@ struct SSLContext uint32 numTrustedCerts; CSSM_DATA_PTR trustedCerts; - /* - * Keychain to which newly encountered root certs are attempted - * to be added. AccessCreds untyped for now. - */ - #if ST_MANAGES_TRUSTED_ROOTS - SecKeychainRef newRootCertKc; - void *accessCreds; - #endif /* ST_MANAGES_TRUSTED_ROOTS */ - /* for symmetric cipher and RNG */ CSSM_CSP_HANDLE cspHand; @@ -178,20 +175,21 @@ struct SSLContext CSSM_TP_HANDLE tpHand; CSSM_CL_HANDLE clHand; - /* FIXME - how will we represent this? */ - void *dhAnonParams; - void *peerDHParams; + #if APPLE_DH + SSLBuffer dhParamsPrime; + SSLBuffer dhParamsGenerator; + SSLBuffer dhParamsEncoded; /* prime + generator */ + SSLBuffer dhPeerPublic; + SSLBuffer dhExchangePublic; + CSSM_KEY_PTR dhPrivate; + #endif /* APPLE_DH */ Boolean allowExpiredCerts; Boolean allowExpiredRoots; Boolean enableCertVerify; SSLBuffer sessionID; - - SSLBuffer dhPeerPublic; - SSLBuffer dhExchangePublic; - SSLBuffer dhPrivate; - + SSLBuffer peerID; SSLBuffer resumableSession; @@ -235,7 +233,7 @@ struct SSLContext unsigned ssl2ChallengeLength; unsigned ssl2ConnectionIDLength; - unsigned ssl2SessionMatch; + unsigned sessionMatch; /* Record layer fields */ SSLBuffer partialReadBuffer; @@ -247,6 +245,8 @@ struct SSLContext uint32 receivedDataPos; Boolean allowAnyRoot; // don't require known roots + Boolean sentFatalAlert; // this session terminated by fatal alert + Boolean rsaBlindingEnable; }; #ifdef __cplusplus diff --git a/SecureTransport/privateInc/sslDebug.h b/SecureTransport/privateInc/sslDebug.h index 99d4f297..9ac8ae88 100644 --- a/SecureTransport/privateInc/sslDebug.h +++ b/SecureTransport/privateInc/sslDebug.h @@ -34,26 +34,32 @@ #include /* log changes in handshake state */ -#define sslHdskStateDebug(args...) debug("sslHdskState", ## args) +#define sslHdskStateDebug(args...) secdebug("sslHdskState", ## args) /* log handshake and alert messages */ -#define sslHdskMsgDebug(args...) debug("sslHdskMsg", ## args) +#define sslHdskMsgDebug(args...) secdebug("sslHdskMsg", ## args) /* log negotiated handshake parameters */ -#define sslLogNegotiateDebug(args...) debug("sslLogNegotiate", ## args) +#define sslLogNegotiateDebug(args...) secdebug("sslLogNegotiate", ## args) /* log received protocol messsages */ -#define sslLogRxProtocolDebug(msgType) debug("sslLogRxProtocol", \ +#define sslLogRxProtocolDebug(msgType) secdebug("sslLogRxProtocol", \ "---received protoMsg %s", msgType) /* log resumable session info */ -#define sslLogResumSessDebug(args...) debug("sslResumSession", ## args) +#define sslLogResumSessDebug(args...) secdebug("sslResumSession", ## args) /* log low-level session info in appleSession.cpp */ -#define sslLogSessCacheDebug(args...) debug("sslSessionCache", ## args) +#define sslLogSessCacheDebug(args...) secdebug("sslSessionCache", ## args) /* log record-level I/O (SSLRead, SSLWrite) */ -#define sslLogRecordIo(args...) debug("sslRecordIo", ## args) +#define sslLogRecordIo(args...) secdebug("sslRecordIo", ## args) + +/* cert-related info */ +#define sslCertDebug(args...) secdebug("sslCert", ## args) + +/* Diffie-Hellman */ +#define sslDhDebug(args...) secdebug("sslDh", ## args) #ifdef NDEBUG diff --git a/SecureTransport/privateInc/sslHandshake.h b/SecureTransport/privateInc/sslHandshake.h index 2530a4c0..0eafc913 100644 --- a/SecureTransport/privateInc/sslHandshake.h +++ b/SecureTransport/privateInc/sslHandshake.h @@ -80,8 +80,8 @@ typedef enum SSL2_HdskStateServerHello, SSL2_HdskStateServerVerify, SSL2_HdskStateServerFinished, - SSL2_HdskStateServerReady, /* ready for I/O; server side */ - SSL2_HdskStateClientReady /* ready for I/O; client side */ + SSL_HdskStateServerReady, /* ready for I/O; server side */ + SSL_HdskStateClientReady /* ready for I/O; client side */ } SSLHandshakeState; typedef struct @@ -118,15 +118,13 @@ OSStatus SSLProcessServerHello(SSLBuffer message, SSLContext *ctx); OSStatus SSLEncodeClientHello(SSLRecord &clientHello, SSLContext *ctx); OSStatus SSLProcessClientHello(SSLBuffer message, SSLContext *ctx); OSStatus SSLInitMessageHashes(SSLContext *ctx); -OSStatus SSLEncodeRSAPremasterSecret(SSLContext *ctx); -OSStatus SSLEncodeDHPremasterSecret(SSLContext *ctx); -OSStatus SSLInitPendingCiphers(SSLContext *ctx); /** sslKeyExchange.c **/ OSStatus SSLEncodeServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx); OSStatus SSLProcessServerKeyExchange(SSLBuffer message, SSLContext *ctx); OSStatus SSLEncodeKeyExchange(SSLRecord &keyExchange, SSLContext *ctx); OSStatus SSLProcessKeyExchange(SSLBuffer keyExchange, SSLContext *ctx); +OSStatus SSLInitPendingCiphers(SSLContext *ctx); /** sslHandshakeFinish.c **/ OSStatus SSLEncodeFinishedMessage(SSLRecord &finished, SSLContext *ctx); diff --git a/SecureTransport/privateInc/sslKeychain.h b/SecureTransport/privateInc/sslKeychain.h index 132c8921..071afd7d 100644 --- a/SecureTransport/privateInc/sslKeychain.h +++ b/SecureTransport/privateInc/sslKeychain.h @@ -54,48 +54,8 @@ parseIncomingCerts( SSLCertificate **destCert, /* &ctx->{localCert,encryptCert} */ CSSM_KEY_PTR *pubKey, /* &ctx->signingPubKey, etc. */ CSSM_KEY_PTR *privKey, /* &ctx->signingPrivKey, etc. */ - CSSM_CSP_HANDLE *cspHand /* &ctx->signingKeyCsp, etc. */ - #if ST_KC_KEYS_NEED_REF - , - SecKeychainRef *privKeyRef); /* &ctx->signingKeyRef, etc. */ - #else - ); - #endif ST_KC_KEYS_NEED_REF + CSSM_CSP_HANDLE *cspHand); /* &ctx->signingKeyCsp, etc. */ -/* - * Add Apple built-in root certs to ctx->trustedCerts. - */ -OSStatus -addBuiltInCerts ( - SSLContextRef ctx); - -#if ST_MANAGES_TRUSTED_ROOTS - -/* - * Given an open Keychain: - * -- Get raw cert data, add to array of CSSM_DATAs in - * ctx->trustedCerts - * -- verify that each of these is a valid (self-verifying) - * root cert - * -- add each subject name to acceptableDNList - */ -OSStatus -parseTrustedKeychain( - SSLContextRef ctx, - SecKeychainRef keyChainRef); - -/* - * Given a newly encountered root cert (obtained from a peer's cert chain), - * add it to newRootCertKc if the user so allows, and if so, add it to - * trustedCerts. - */ -OSStatus -sslAddNewRoot( - SSLContext *ctx, - const CSSM_DATA_PTR rootCert); - -#endif /* ST_MANAGES_TRUSTED_ROOTS */ - #ifdef __cplusplus } #endif diff --git a/SecureTransport/privateInc/sslMemory.h b/SecureTransport/privateInc/sslMemory.h index 1b9982bd..f978c037 100644 --- a/SecureTransport/privateInc/sslMemory.h +++ b/SecureTransport/privateInc/sslMemory.h @@ -58,6 +58,10 @@ UInt8 *sslAllocCopy(const UInt8 *src, UInt32 len); OSStatus SSLAllocCopyBuffer( const SSLBuffer &src, SSLBuffer **dst); // buffer itself and data mallocd and returned +OSStatus SSLCopyBufferFromData( + const void *src, + UInt32 len, + SSLBuffer &dst); // data mallocd and returned OSStatus SSLCopyBuffer( const SSLBuffer &src, SSLBuffer &dst); // dataÊmallocd and returned diff --git a/SecureTransport/privateInc/sslPriv.h b/SecureTransport/privateInc/sslPriv.h index e99ff061..35455959 100644 --- a/SecureTransport/privateInc/sslPriv.h +++ b/SecureTransport/privateInc/sslPriv.h @@ -38,8 +38,8 @@ extern "C" { #endif -/* Apple CSP doesn't support D-H yet */ -#define APPLE_DH 0 +/* Diffie-Hellman support */ +#define APPLE_DH 1 /* * For ease of porting, we'll keep this around for internal use. @@ -69,11 +69,8 @@ typedef enum typedef enum { - /* These values never appear in the actual protocol */ + /* This value never appears in the actual protocol */ SSL_Version_Undetermined = 0, - SSL_Version_3_0_With_2_0_Hello = 100, - SSL_Version_3_0_Only = 101, - TLS_Version_1_0_Only = 202, /* actual protocol values */ SSL_Version_2_0 = 0x0002, SSL_Version_3_0 = 0x0300, diff --git a/SecureTransport/privateInc/sslUtils.h b/SecureTransport/privateInc/sslUtils.h index 6d1b539b..c033c9af 100644 --- a/SecureTransport/privateInc/sslUtils.h +++ b/SecureTransport/privateInc/sslUtils.h @@ -79,7 +79,15 @@ OSStatus sslRand( SSLContext *ctx, SSLBuffer *buf); - +OSStatus sslVerifyProtVersion( + SSLContext *ctx, + SSLProtocolVersion peerVersion, + SSLProtocolVersion *negVersion); + +OSStatus sslGetMaxProtVersion( + SSLContext *ctx, + SSLProtocolVersion *version); // RETURNED + #define SET_SSL_BUFFER(buf, d, l) do { (buf).data = (d); (buf).length = (l); } while (0) #ifdef __cplusplus diff --git a/SecureTransport/secureTransport.exp b/SecureTransport/secureTransport.exp index 81618ffa..81f5155b 100644 --- a/SecureTransport/secureTransport.exp +++ b/SecureTransport/secureTransport.exp @@ -4,6 +4,8 @@ _SSLGetSessionState _SSLSetIOFuncs _SSLSetProtocolVersion _SSLGetProtocolVersion +_SSLSetProtocolVersionEnabled +_SSLGetProtocolVersionEnabled _SSLSetConnection _SSLGetNegotiatedProtocolVersion _SSLSetAllowsExpiredCerts diff --git a/SecureTransport/securetransport++.cpp b/SecureTransport/securetransport++.cpp index 8400da6a..18626b0b 100644 --- a/SecureTransport/securetransport++.cpp +++ b/SecureTransport/securetransport++.cpp @@ -37,7 +37,7 @@ SecureTransportCore::SecureTransportCore() : mAtEnd(false) try { MacOSError::check(SSLSetIOFuncs(mContext, sslReadFunc, sslWriteFunc)); MacOSError::check(SSLSetConnection(mContext, this)); - debug("ssl", "%p constructed", this); + secdebug("ssl", "%p constructed", this); } catch (...) { SSLDisposeContext(mContext); throw; @@ -51,7 +51,7 @@ SecureTransportCore::SecureTransportCore() : mAtEnd(false) SecureTransportCore::~SecureTransportCore() { SSLDisposeContext(mContext); // ignore error (can't do anything if error) - debug("ssl", "%p destroyed", this); + secdebug("ssl", "%p destroyed", this); } @@ -66,7 +66,7 @@ void SecureTransportCore::open() switch (OSStatus err = SSLHandshake(mContext)) { case noErr: case errSSLWouldBlock: - debug("ssl", "%p open, state=%d", this, state()); + secdebug("ssl", "%p open, state=%d", this, state()); return; default: MacOSError::throwMe(err); @@ -83,7 +83,7 @@ void SecureTransportCore::close() switch (state()) { case kSSLHandshake: case kSSLConnected: - debug("ssl", "%p closed", this); + secdebug("ssl", "%p closed", this); SSLClose(mContext); break; default: @@ -147,7 +147,7 @@ bool SecureTransportCore::continueHandshake() { if (state() == kSSLHandshake) { // still in handshake mode; prod it along - debug("ssl", "%p continuing handshake", this); + secdebug("ssl", "%p continuing handshake", this); switch (OSStatus err = SSLHandshake(mContext)) { case noErr: case errSSLWouldBlock: @@ -155,7 +155,7 @@ bool SecureTransportCore::continueHandshake() default: MacOSError::throwMe(err); } - IFDEBUG(if (state() != kSSLHandshake) debug("ssl", "%p handshake complete", this)); + IFDEBUG(if (state() != kSSLHandshake) secdebug("ssl", "%p handshake complete", this)); return state() == kSSLHandshake; } else return false; @@ -261,11 +261,11 @@ OSStatus SecureTransportCore::sslReadFunc(SSLConnectionRef connection, try { size_t lengthRequested = *length; *length = stc->ioRead(data, lengthRequested); - debug("sslconio", "%p read %ld of %ld bytes", stc, *length, lengthRequested); + secdebug("sslconio", "%p read %ld of %ld bytes", stc, *length, lengthRequested); if (*length == lengthRequested) // full deck return noErr; else if (stc->ioAtEnd()) { - debug("sslconio", "%p end of source input, returning %ld bytes", + secdebug("sslconio", "%p end of source input, returning %ld bytes", stc, *length); return errSSLClosedGraceful; } else @@ -291,7 +291,7 @@ OSStatus SecureTransportCore::sslWriteFunc(SSLConnectionRef connection, try { size_t lengthRequested = *length; *length = stc->ioWrite(data, lengthRequested); - debug("sslconio", "%p wrote %ld of %ld bytes", stc, *length, lengthRequested); + secdebug("sslconio", "%p wrote %ld of %ld bytes", stc, *length, lengthRequested); return *length == lengthRequested ? OSStatus(noErr) : OSStatus(errSSLWouldBlock); } catch (const CssmCommonError &err) { *length = 0; diff --git a/SecureTransport/ssl2Message.cpp b/SecureTransport/ssl2Message.cpp index 756a40f3..28579a99 100644 --- a/SecureTransport/ssl2Message.cpp +++ b/SecureTransport/ssl2Message.cpp @@ -38,7 +38,7 @@ SSL2ProcessClientHello(SSLBuffer msg, SSLContext *ctx) unsigned i, j, cipherKindCount, sessionIDLen, challengeLen; SSL2CipherKind cipherKind; SSLCipherSuite matchingCipher, selectedCipher; - SSLProtocolVersion version; + SSLProtocolVersion negVersion; if (msg.length < 27) { sslErrorLog("SSL2ProcessClientHello: msg len error 1\n"); @@ -47,21 +47,24 @@ SSL2ProcessClientHello(SSLBuffer msg, SSLContext *ctx) charPtr = msg.data; - version = (SSLProtocolVersion)SSLDecodeInt(charPtr, 2); - if (version > ctx->maxProtocolVersion) { - version = ctx->maxProtocolVersion; + ctx->clientReqProtocol = (SSLProtocolVersion)SSLDecodeInt(charPtr, 2); + err = sslVerifyProtVersion(ctx, ctx->clientReqProtocol, &negVersion); + if(err) { + return err; } - /* FIXME - I think this needs work for a SSL_Version_2_0 server, to ensure that - * the client isn't establishing a v3 session. */ - if (ctx->negProtocolVersion == SSL_Version_Undetermined) - { - /* FIXME - this ifndef should not be necessary */ + + /* + * Note we can be here, processing a v2 client hello, even if + * we don't support SSL2. That can happen if the client is + * sending a v2 hello with an attempt to upgrade. + */ + if (ctx->negProtocolVersion == SSL_Version_Undetermined) { #ifndef NDEBUG sslLogNegotiateDebug("===SSL2 server: negVersion was undetermined; " - "is %s", protocolVersStr(version)); + "is %s", protocolVersStr(negVersion)); #endif - ctx->negProtocolVersion = version; - if(version >= TLS_Version_1_0) { + ctx->negProtocolVersion = negVersion; + if(negVersion >= TLS_Version_1_0) { ctx->sslTslCalls = &Tls1Callouts; } else { @@ -69,17 +72,6 @@ SSL2ProcessClientHello(SSLBuffer msg, SSLContext *ctx) assert(ctx->sslTslCalls == &Ssl3Callouts); } } - else if (ctx->negProtocolVersion == SSL_Version_3_0_With_2_0_Hello) - { if (version < SSL_Version_3_0) { - sslErrorLog("SSL2ProcessClientHello: version error\n"); - return errSSLProtocol; - } - /* FIXME - I don't think path is ever taken - we NEVER set any - * protocol var to SSL_Version_3_0_With_2_0_Hello... */ - sslLogNegotiateDebug("===SSL2 server: negVersion was " - "3_0_With_2_0_Hello; is 3_0"); - ctx->negProtocolVersion = version; - } charPtr += 2; cipherKindCount = SSLDecodeInt(charPtr, 2); @@ -103,6 +95,7 @@ SSL2ProcessClientHello(SSLBuffer msg, SSLContext *ctx) cipherList = charPtr; selectedCipher = SSL_NO_SUCH_CIPHERSUITE; + assert(ctx->negProtocolVersion >= SSL_Version_2_0); // i.e., not undetermined if (ctx->negProtocolVersion >= SSL_Version_3_0) { /* If we're negotiating an SSL 3.0 session, use SSL 3.0 suites first */ for (i = 0; i < cipherKindCount; i++) { @@ -206,11 +199,10 @@ SSL2ProcessClientHello(SSLBuffer msg, SSLContext *ctx) * The SSL v2 spec says that the challenge string sent by the client can be * between 16 and 32 bytes. However all Netscape enterprise servers actually * require a 16 byte challenge. Q.v. cdnow.com, store.apple.com. - * Unfortunately this means that when we're trying to do a - * SSL_Version_3_0_With_2_0_Hello negotiation, we have to limit ourself to - * a 16-byte clientRandom, which we have to concatenate to 16 bytes of - * zeroes if we end up with a 3.0 or 3.1 connection. Thus we lose 16 bytes - * of entropy. + * Unfortunately this means that when we're trying to do an + * SSL2 hello with possible upgrade, we have to limit ourself to a + * 16-byte clientRandom, which we have to concatenate to 16 bytes of zeroes + * if we end up with a 3.0 or 3.1 connection. Thus we lose 16 bytes of entropy. */ #define SSL2_CHALLENGE_LEN 16 @@ -224,28 +216,20 @@ SSL2EncodeClientHello(SSLBuffer &msg, SSLContext *ctx) int sessionIDLen; UInt16 version; SSLBuffer sessionIdentifier, randomData; - - switch (ctx->negProtocolVersion) - { case SSL_Version_Undetermined: - case SSL_Version_3_0_With_2_0_Hello: - /* go for it, see if server can handle upgrading */ - useSSL3Ciphers = 1; - /* could be SSLv3 or TLSv1 */ - version = ctx->maxProtocolVersion; - break; - case SSL_Version_2_0: - useSSL3Ciphers = 0; - version = SSL_Version_2_0; - break; - case SSL_Version_3_0_Only: - case SSL_Version_3_0: - case TLS_Version_1_0_Only: - case TLS_Version_1_0: - default: - assert("Bad protocol version for sending SSL 2 Client Hello"); - return errSSLInternal; - } - /* FIXME - this ifndef should not be necessary */ + SSLProtocolVersion maxVersion; + + assert(ctx->versionSsl2Enable); + err = sslGetMaxProtVersion(ctx, &maxVersion); + if(err) { + /* we don't have a protocol enabled */ + return err; + } + version = maxVersion; + if(version > SSL_Version_2_0) { + /* see if server can handle upgrading */ + useSSL3Ciphers = 1; + } + #ifndef NDEBUG sslLogNegotiateDebug("===SSL client: proclaiming %s capable", protocolVersStr((SSLProtocolVersion)version)); @@ -263,6 +247,10 @@ SSL2EncodeClientHello(SSLBuffer &msg, SSLContext *ctx) break; } + if(totalCipherCount == 0) { + sslErrorLog("SSL2EncodeClientHello: no valid ciphers for SSL2"); + return errSSLBadConfiguration; + } sessionIDLen = 0; sessionIdentifier.data = 0; if (ctx->resumableSession.data != 0) @@ -385,9 +373,9 @@ SSL2ProcessClientMasterKey(SSLBuffer msg, SSLContext *ctx) decryptCspHand = ctx->signingKeyCsp; } else { - /* really should not happen... */ + /* app configuration error */ sslErrorLog("SSL2ProcessClientMasterKey: No server key!\n"); - return badReqErr; + return errSSLBadConfiguration; } localKeyModulusLen = sslKeyLengthInBytes(decryptKey); @@ -575,7 +563,7 @@ SSL2ProcessServerHello(SSLBuffer msg, SSLContext *ctx) if (sessionIDMatch != 0) { if (certLen != 0 || cipherSpecsLen != 0 /* || certType != 0 */ ) return errSSLProtocol; - ctx->ssl2SessionMatch = 1; + ctx->sessionMatch = 1; ctx->ssl2ConnectionIDLength = connectionIDLen; memcpy(ctx->serverRandom, charPtr, connectionIDLen); @@ -659,12 +647,12 @@ SSL2EncodeServerHello(SSLBuffer &msg, SSLContext *ctx) if ((err = sslRand(ctx, &randomData)) != 0) return err; - if (ctx->ssl2SessionMatch != 0) + if (ctx->sessionMatch != 0) { if ((err = SSLAllocBuffer(msg, 11 + ctx->sessionID.length, ctx)) != 0) return err; charPtr = msg.data; *charPtr++ = SSL2_MsgServerHello; - *charPtr++ = ctx->ssl2SessionMatch; + *charPtr++ = ctx->sessionMatch; *charPtr++ = 0; /* cert type */ charPtr = SSLEncodeInt(charPtr, ctx->negProtocolVersion, 2); charPtr = SSLEncodeInt(charPtr, 0, 2); /* cert len */ @@ -699,10 +687,9 @@ SSL2EncodeServerHello(SSLBuffer &msg, SSLContext *ctx) return err; charPtr = msg.data; *charPtr++ = SSL2_MsgServerHello; - *charPtr++ = ctx->ssl2SessionMatch; + *charPtr++ = ctx->sessionMatch; *charPtr++ = SSL2_CertTypeX509; /* cert type */ - /* FIXME - this ifndef should not be necessary */ #ifndef NDEBUG sslLogNegotiateDebug("===SSL2 server: sending vers info %s", protocolVersStr((SSLProtocolVersion)ctx->negProtocolVersion)); diff --git a/SecureTransport/ssl2Protocol.cpp b/SecureTransport/ssl2Protocol.cpp index d58f767d..93a008e7 100644 --- a/SecureTransport/ssl2Protocol.cpp +++ b/SecureTransport/ssl2Protocol.cpp @@ -160,7 +160,6 @@ SSL2ProcessMessage(SSLRecord &rec, SSLContext *ctx) if (err == 0) { - /* FIXME - use requested or negotiated protocol version here? */ if ((msg == SSL2_MsgClientHello) && (ctx->negProtocolVersion >= SSL_Version_3_0)) { /* Promote this message to SSL 3 protocol */ @@ -181,46 +180,32 @@ SSL2AdvanceHandshake(SSL2MessageType msg, SSLContext *ctx) switch (msg) { case SSL2_MsgKickstart: - if (ctx->negProtocolVersion == SSL_Version_3_0_With_2_0_Hello || - ctx->negProtocolVersion == SSL_Version_Undetermined) + assert(ctx->negProtocolVersion == SSL_Version_Undetermined); + assert(ctx->versionSsl2Enable); + if (ctx->versionSsl3Enable || ctx->versionTls1Enable) { + /* prepare for possible v3 upgrade */ if ((err = SSLInitMessageHashes(ctx)) != 0) return err; + } if ((err = SSL2PrepareAndQueueMessage(SSL2EncodeClientHello, ctx)) != 0) return err; - switch (ctx->negProtocolVersion) - { case SSL_Version_Undetermined: - SSLChangeHdskState(ctx, SSL_HdskStateServerHelloUnknownVersion); - break; - case SSL_Version_3_0_With_2_0_Hello: - assert((ctx->reqProtocolVersion == SSL_Version_3_0) || - (ctx->reqProtocolVersion == TLS_Version_1_0)); - ctx->negProtocolVersion = ctx->reqProtocolVersion; - sslLogNegotiateDebug("===SSL client kickstart: negVersion " - "is %d_%d", - ctx->negProtocolVersion >> 8, ctx->negProtocolVersion & 0xff); - SSLChangeHdskState(ctx, SSL_HdskStateServerHello); - break; - case SSL_Version_2_0: - SSLChangeHdskState(ctx, SSL2_HdskStateServerHello); - break; - case SSL_Version_3_0_Only: - case SSL_Version_3_0: - case TLS_Version_1_0_Only: - case TLS_Version_1_0: - default: - assert("Bad protocol version for sending SSL 2 Client Hello"); - break; - } + if (ctx->versionSsl3Enable || ctx->versionTls1Enable) { + SSLChangeHdskState(ctx, SSL_HdskStateServerHelloUnknownVersion); + } + else { + /* v2 only */ + SSLChangeHdskState(ctx, SSL2_HdskStateServerHello); + } break; case SSL2_MsgClientHello: if ((err = SSL2CompareSessionIDs(ctx)) != 0) return err; - if (ctx->ssl2SessionMatch == 0) + if (ctx->sessionMatch == 0) if ((err = SSL2GenerateSessionID(ctx)) != 0) return err; if ((err = SSL2PrepareAndQueueMessage(SSL2EncodeServerHello, ctx)) != 0) return err; - if (ctx->ssl2SessionMatch == 0) + if (ctx->sessionMatch == 0) { SSLChangeHdskState(ctx, SSL2_HdskStateClientMasterKey); break; } @@ -238,7 +223,7 @@ SSL2AdvanceHandshake(SSL2MessageType msg, SSLContext *ctx) SSLChangeHdskState(ctx, SSL2_HdskStateClientFinished); break; case SSL2_MsgServerHello: - if (ctx->ssl2SessionMatch == 0) + if (ctx->sessionMatch == 0) { if ((err = SSL2PrepareAndQueueMessage(SSL2EncodeClientMasterKey, ctx)) != 0) return err; } @@ -260,7 +245,7 @@ SSL2AdvanceHandshake(SSL2MessageType msg, SSLContext *ctx) ctx->readCipher.ready = 1; /* original code never got out of SSL2_MsgClientFinished state */ assert(ctx->protocolSide == SSL_ServerSide); - SSLChangeHdskState(ctx, SSL2_HdskStateServerReady); + SSLChangeHdskState(ctx, SSL_HdskStateServerReady); if (ctx->peerID.data != 0) SSLAddSessionData(ctx); break; @@ -277,7 +262,7 @@ SSL2AdvanceHandshake(SSL2MessageType msg, SSLContext *ctx) ctx->readCipher.ready = 1; /* original code never got out of SSL2_MsgServerFinished state */ assert(ctx->protocolSide == SSL_ClientSide); - SSLChangeHdskState(ctx, SSL2_HdskStateClientReady); + SSLChangeHdskState(ctx, SSL_HdskStateClientReady); if (ctx->peerID.data != 0) SSLAddSessionData(ctx); break; @@ -308,12 +293,15 @@ SSL2PrepareAndQueueMessage(EncodeSSL2MessageFunc encodeFunc, SSLContext *ctx) return err; } - if (ctx->negProtocolVersion == SSL_Version_3_0_With_2_0_Hello || - ctx->negProtocolVersion == SSL_Version_Undetermined) + assert((ctx->negProtocolVersion == SSL_Version_Undetermined) || + (ctx->negProtocolVersion == SSL_Version_2_0)); + if((ctx->negProtocolVersion == SSL_Version_Undetermined) && + (ctx->versionSsl3Enable || ctx->versionTls1Enable)) { + /* prepare for possible V3/TLS1 upgrade */ if ((err = SSLHashSHA1.update(ctx->shaState, rec.contents)) != 0 || (err = SSLHashMD5.update(ctx->md5State, rec.contents)) != 0) return err; - + } err = SSLFreeBuffer(rec.contents, ctx); return err; } @@ -323,7 +311,7 @@ SSL2CompareSessionIDs(SSLContext *ctx) { OSStatus err; SSLBuffer sessionIdentifier; - ctx->ssl2SessionMatch = 0; + ctx->sessionMatch = 0; if (ctx->resumableSession.data == 0) return noErr; @@ -334,7 +322,7 @@ SSL2CompareSessionIDs(SSLContext *ctx) if (sessionIdentifier.length == ctx->sessionID.length && memcmp(sessionIdentifier.data, ctx->sessionID.data, sessionIdentifier.length) == 0) - ctx->ssl2SessionMatch = 1; + ctx->sessionMatch = 1; if ((err = SSLFreeBuffer(sessionIdentifier, ctx)) != 0) return err; @@ -346,7 +334,7 @@ OSStatus SSL2InstallSessionKey(SSLContext *ctx) { OSStatus err; - assert(ctx->ssl2SessionMatch != 0); + assert(ctx->sessionMatch != 0); assert(ctx->resumableSession.data != 0); if ((err = SSLInstallSessionFromData(ctx->resumableSession, ctx)) != 0) return err; diff --git a/SecureTransport/ssl2Record.cpp b/SecureTransport/ssl2Record.cpp index 6cfaafad..40ea26a8 100644 --- a/SecureTransport/ssl2Record.cpp +++ b/SecureTransport/ssl2Record.cpp @@ -64,7 +64,6 @@ SSL2ReadRecord(SSLRecord &rec, SSLContext *ctx) switch (ctx->negProtocolVersion) { case SSL_Version_Undetermined: - case SSL_Version_3_0_With_2_0_Hello: case SSL_Version_2_0: break; case SSL_Version_3_0: /* We've negotiated a 3.0 session; @@ -72,10 +71,6 @@ SSL2ReadRecord(SSLRecord &rec, SSLContext *ctx) case TLS_Version_1_0: SSLFatalSessionAlert(SSL_AlertUnexpectedMsg, ctx); return errSSLProtocol; - case SSL_Version_3_0_Only: /* We haven't yet negotiated, but - * we don't want to support 2.0; just - * die without an alert */ - return errSSLProtocol; default: sslErrorLog("bad protocolVersion in ctx->protocolVersion"); return errSSLInternal; @@ -84,11 +79,11 @@ SSL2ReadRecord(SSLRecord &rec, SSLContext *ctx) if (!ctx->partialReadBuffer.data || ctx->partialReadBuffer.length < 3) { if (ctx->partialReadBuffer.data) if ((err = SSLFreeBuffer(ctx->partialReadBuffer, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSL2SendError(SSL2_ErrNoCipher, ctx); return err; } if ((err = SSLAllocBuffer(ctx->partialReadBuffer, DEFAULT_BUFFER_SIZE, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSL2SendError(SSL2_ErrNoCipher, ctx); return err; } } diff --git a/SecureTransport/ssl3Callouts.cpp b/SecureTransport/ssl3Callouts.cpp index 65b84571..92b1f540 100644 --- a/SecureTransport/ssl3Callouts.cpp +++ b/SecureTransport/ssl3Callouts.cpp @@ -185,7 +185,7 @@ static OSStatus ssl3DecryptRecord( *payload, &ctx->readCipher, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertDecryptionFail, ctx); return err; } @@ -195,10 +195,10 @@ static OSStatus ssl3DecryptRecord( if (ctx->readCipher.symCipher->blockSize > 0) { /* padding can't be equal to or more than a block */ if (payload->data[payload->length - 1] >= ctx->readCipher.symCipher->blockSize) - { SSLFatalSessionAlert(SSL_AlertUnexpectedMsg, ctx); + { SSLFatalSessionAlert(SSL_AlertDecryptionFail, ctx); sslErrorLog("DecryptSSLRecord: bad padding length (%d)\n", (unsigned)payload->data[payload->length - 1]); - return errSSLProtocol; + return errSSLDecryptionFail; } content.length -= 1 + payload->data[payload->length - 1]; /* Remove block size padding */ @@ -210,7 +210,7 @@ static OSStatus ssl3DecryptRecord( if ((err = SSLVerifyMac(type, content, payload->data + content.length, ctx)) != 0) { SSLFatalSessionAlert(SSL_AlertBadRecordMac, ctx); - return err; + return errSSLBadRecordMac; } *payload = content; /* Modify payload buffer to indicate content length */ diff --git a/SecureTransport/sslAlertMessage.cpp b/SecureTransport/sslAlertMessage.cpp index bfdbdc15..3ac69ab1 100644 --- a/SecureTransport/sslAlertMessage.cpp +++ b/SecureTransport/sslAlertMessage.cpp @@ -26,6 +26,7 @@ #include "sslContext.h" #include "sslSession.h" #include "sslDebug.h" +#include "sslUtils.h" #include @@ -35,6 +36,41 @@ static void SSLLogAlertMsg(AlertDescription msg, bool sent); #endif +static OSStatus SSLEncodeAlert( + SSLRecord &rec, + AlertLevel level, + AlertDescription desc, + SSLContext *ctx); + +/* + * If a peer sends us any kind of a bad cert alert, we may need to adjust + * ctx->clientCertState accordingly. + */ +static void +SSLDetectCertRejected( + SSLContext *ctx, + AlertDescription desc) +{ + if(ctx->protocolSide == SSL_ServerSide) { + return; + } + if(ctx->clientCertState != kSSLClientCertSent) { + return; + } + switch(desc) { + case SSL_AlertBadCert: + case SSL_AlertUnsupportedCert: + case SSL_AlertCertRevoked: + case SSL_AlertCertExpired: + case SSL_AlertCertUnknown: + case SSL_AlertUnknownCA: + ctx->clientCertState = kSSLClientCertRejected; + break; + default: + break; + } +} + OSStatus SSLProcessAlert(SSLRecord rec, SSLContext *ctx) { OSStatus err = noErr; @@ -54,38 +90,101 @@ SSLProcessAlert(SSLRecord rec, SSLContext *ctx) charPtr = rec.contents.data; remaining = rec.contents.length; + bool fatal = false; + while (remaining > 0) { level = (AlertLevel)*charPtr++; desc = (AlertDescription)*charPtr++; - sslHdskMsgDebug("alert msg recieved level %d desc %d\n", + sslHdskMsgDebug("alert msg recieved level %d desc %d", (int)level, (int)desc); remaining -= 2; SSLLogAlertMsg(desc, false); - /* - * Ignore sessionID-related failures here; - * the important thing is the alert. - */ - if (level == SSL_AlertLevelFatal) - { - SSLDeleteSessionData(ctx); - sslErrorLog("***Fatal alert %d received\n", desc); - return errSSLFatalAlert; + if (level == SSL_AlertLevelFatal) { + /* explicit fatal errror */ + fatal = true; + sslHdskMsgDebug("***Fatal alert %d received\n", desc); } - - switch (desc) - { case SSL_AlertUnexpectedMsg: + SSLDetectCertRejected(ctx, desc); + + switch (desc) { + /* A number of these are fatal by implication */ + case SSL_AlertUnexpectedMsg: + err = errSSLPeerUnexpectedMsg; + fatal = true; + break; case SSL_AlertBadRecordMac: + err = errSSLPeerBadRecordMac; + fatal = true; + break; + case SSL_AlertDecryptionFail: + err = errSSLPeerDecryptionFail; + fatal = true; + break; + case SSL_AlertRecordOverflow: + err = errSSLPeerRecordOverflow; + fatal = true; + break; case SSL_AlertDecompressFail: + err = errSSLPeerDecompressFail; + fatal = true; + break; case SSL_AlertHandshakeFail: + err = errSSLPeerHandshakeFail; + fatal = true; + break; case SSL_AlertIllegalParam: - /* These must always be fatal; if we got here, the level is warning; - * die anyway - */ - SSLDeleteSessionData(ctx); - err = errSSLFatalAlert; + err = errSSLIllegalParam; + fatal = true; + break; + case SSL_AlertBadCert: + err = errSSLPeerBadCert; + break; + case SSL_AlertUnsupportedCert: + err = errSSLPeerUnsupportedCert; + break; + case SSL_AlertCertRevoked: + err = errSSLPeerCertRevoked; + break; + case SSL_AlertCertExpired: + err = errSSLPeerCertExpired; + break; + case SSL_AlertCertUnknown: + err = errSSLPeerCertUnknown; + break; + case SSL_AlertUnknownCA: + err = errSSLPeerUnknownCA; + break; + case SSL_AlertAccessDenied: + err = errSSLPeerAccessDenied; + break; + case SSL_AlertDecodeError: + err = errSSLPeerDecodeError; + break; + case SSL_AlertDecryptError: + err = errSSLPeerDecryptError; + break; + case SSL_AlertExportRestriction: + err = errSSLPeerExportRestriction; + break; + case SSL_AlertProtocolVersion: + err = errSSLPeerProtocolVersion; break; + case SSL_AlertInsufficientSecurity: + err = errSSLPeerInsufficientSecurity; + break; + case SSL_AlertInternalError: + err = errSSLPeerInternalError; + break; + case SSL_AlertUserCancelled: + err = errSSLPeerUserCancelled; + break; + case SSL_AlertNoRenegotiation: + err = errSSLPeerNoRenegotiation; + break; + /* unusual cases.... */ case SSL_AlertCloseNotify: + /* the clean "we're done" case */ SSLClose(ctx); err = noErr; break; @@ -110,19 +209,24 @@ SSLProcessAlert(SSLRecord rec, SSLContext *ctx) } } break; - case SSL_AlertBadCert: - case SSL_AlertUnsupportedCert: - case SSL_AlertCertRevoked: - case SSL_AlertCertExpired: - case SSL_AlertCertUnknown: - err = noErr; - break; default: - /* Unknown alert, but not fatal; ignore it */ + /* Unknown alert, ignore if not fatal */ + if(level == SSL_AlertLevelFatal) { + err = errSSLFatalAlert; + } + else { + err = noErr; + } break; } + if(fatal) { + /* don't bother processing any more */ + break; + } } - + if(fatal) { + SSLDeleteSessionData(ctx); + } return err; } @@ -131,8 +235,21 @@ SSLSendAlert(AlertLevel level, AlertDescription desc, SSLContext *ctx) { SSLRecord rec; OSStatus err; - assert((ctx->negProtocolVersion != SSL_Version_2_0)); - + switch(ctx->negProtocolVersion) { + case SSL_Version_Undetermined: + /* Too early in negotiation to send an alert */ + return noErr; + case SSL_Version_2_0: + /* shouldn't be here */ + assert(0); + return errSSLInternal; + default: + break; + } + if(ctx->sentFatalAlert) { + /* no more alerts allowed */ + return noErr; + } if ((err = SSLEncodeAlert(rec, level, desc, ctx)) != 0) return err; assert(ctx->sslTslCalls != NULL); @@ -141,23 +258,19 @@ SSLSendAlert(AlertLevel level, AlertDescription desc, SSLContext *ctx) return err; if ((err = SSLFreeBuffer(rec.contents, ctx)) != 0) return err; - + if(desc == SSL_AlertCloseNotify) { + /* no more alerts allowed */ + ctx->sentFatalAlert = true; + } return noErr; } -OSStatus +static OSStatus SSLEncodeAlert(SSLRecord &rec, AlertLevel level, AlertDescription desc, SSLContext *ctx) { OSStatus err; - rec.contentType = SSL_RecordTypeAlert; - assert((ctx->negProtocolVersion != SSL_Version_2_0)); - if(ctx->negProtocolVersion == SSL_Version_Undetermined) { - /* error while negotiating */ - rec.protocolVersion = ctx->maxProtocolVersion; - } - else { - rec.protocolVersion = ctx->negProtocolVersion; - } + rec.protocolVersion = ctx->negProtocolVersion; + rec.contentType = SSL_RecordTypeAlert; rec.contents.length = 2; if ((err = SSLAllocBuffer(rec.contents, 2, ctx)) != 0) return err; @@ -172,10 +285,36 @@ SSLFatalSessionAlert(AlertDescription desc, SSLContext *ctx) { OSStatus err1, err2; if(desc != SSL_AlertCloseNotify) { - sslErrorLog("SSLFatalSessionAlert: desc %d\n", desc); + sslHdskMsgDebug("SSLFatalSessionAlert: desc %d\n", desc); } SSLChangeHdskState(ctx, SSL_HdskStateErrorClose); + if(ctx->negProtocolVersion < TLS_Version_1_0) { + /* translate to SSL3 if necessary */ + switch(desc) { + case SSL_AlertDecryptionFail: + case SSL_AlertRecordOverflow: + case SSL_AlertAccessDenied: + case SSL_AlertDecodeError: + case SSL_AlertDecryptError: + case SSL_AlertExportRestriction: + case SSL_AlertProtocolVersion: + case SSL_AlertInsufficientSecurity: + case SSL_AlertUserCancelled: + case SSL_AlertNoRenegotiation: + desc = SSL_AlertHandshakeFail; + break; + case SSL_AlertUnknownCA: + desc = SSL_AlertUnsupportedCert; + break; + case SSL_AlertInternalError: + desc = SSL_AlertCloseNotify; + break; + default: + /* send as is */ + break; + } + } /* Make session unresumable; I'm not stopping if I get an error, because I'd like to attempt to send the alert anyway */ err1 = SSLDeleteSessionData(ctx); @@ -183,6 +322,8 @@ SSLFatalSessionAlert(AlertDescription desc, SSLContext *ctx) /* Second, send the alert */ err2 = SSLSendAlert(SSL_AlertLevelFatal, desc, ctx); + ctx->sentFatalAlert = true; + /* If they both returned errors, arbitrarily return the first */ return err1 != 0 ? err1 : err2; } diff --git a/SecureTransport/sslBER.cpp b/SecureTransport/sslBER.cpp index 82352585..bc48fa33 100644 --- a/SecureTransport/sslBER.cpp +++ b/SecureTransport/sslBER.cpp @@ -31,58 +31,12 @@ #include "sslMemory.h" #include "sslDebug.h" #include "sslBER.h" +#include "appleCdsa.h" -#include -#include -#include -#include /* for RSAPublicKey */ -#include #include #include - -/* convert between SSLBuffer and snacc-style BigIntegerStr */ - -static void snaccIntToData( - const BigIntegerStr &snaccInt, - SSLBuffer *outData) // already mallocd -{ - const char *scp = snaccInt; - uint8 *cp = (uint8 *)scp; - uint32 len = snaccInt.Len(); - - if (*cp == 0x00) { - /* skip over this place-holding m.s. byte */ - cp++; - len--; - } - - memmove(outData->data, cp, len); - outData->length = len; -} - -static void dataToSnaccInt( - const SSLBuffer *inData, - BigIntegerStr &snaccInt) -{ - uint8 *cp; - int msbIsSet = 0; - - if (inData->data[0] & 0x80) { - /* m.s. bit of BER data must be zero! */ - cp = (uint8 *)malloc(inData->length + 1); - *cp = 0; - memmove(cp+1, inData->data, inData->length); - msbIsSet = 1; - } - else { - cp = inData->data; - } - snaccInt.Set(reinterpret_cast(cp), - inData->length + msbIsSet); - if(msbIsSet) { - free(cp); - } -} +#include +#include /* * Given a PKCS-1 encoded RSA public key, extract the @@ -105,28 +59,24 @@ OSStatus sslDecodeRsaBlob( assert(exponent != NULL); /* DER-decode the blob */ - RSAPublicKey snaccPubKey; - CssmData cssmBlob(blob->data, blob->length); - try { - SC_decodeAsnObj(cssmBlob, snaccPubKey); - } - catch(...) { - return errSSLBadCert; - } + NSS_RSAPublicKeyPKCS1 nssPubKey; + SecNssCoder coder; - /* malloc & convert components */ - srtn = SSLAllocBuffer(*modulus, snaccPubKey.modulus.Len(), NULL); - if(srtn) { - return srtn; + memset(&nssPubKey, 0, sizeof(nssPubKey)); + PRErrorCode perr = coder.decode(blob->data, blob->length, + NSS_RSAPublicKeyPKCS1Template, &nssPubKey); + if(perr) { + return errSSLBadCert; } - snaccIntToData(snaccPubKey.modulus, modulus); - srtn = SSLAllocBuffer(*exponent, snaccPubKey.publicExponent.Len(), - NULL); + + /* malloc & copy components */ + srtn = SSLCopyBufferFromData(nssPubKey.modulus.Data, + nssPubKey.modulus.Length, *modulus); if(srtn) { return srtn; } - snaccIntToData(snaccPubKey.publicExponent, exponent); - return noErr; + return SSLCopyBufferFromData(nssPubKey.publicExponent.Data, + nssPubKey.publicExponent.Length, *exponent); } /* @@ -142,29 +92,110 @@ OSStatus sslEncodeRsaBlob( blob->data = NULL; blob->length = 0; - /* Cook up a snacc-style RSAPublic key */ - RSAPublicKey snaccPubKey; - dataToSnaccInt(modulus, snaccPubKey.modulus); - dataToSnaccInt(exponent, snaccPubKey.publicExponent); + /* convert to NSS_RSAPublicKeyPKCS1 */ + NSS_RSAPublicKeyPKCS1 nssPubKey; + SSLBUF_TO_CSSM(modulus, &nssPubKey.modulus); + SSLBUF_TO_CSSM(exponent, &nssPubKey.publicExponent); + + /* DER encode */ + SecNssCoder coder; + CSSM_DATA encBlob; + PRErrorCode perr; + perr = coder.encodeItem(&nssPubKey, NSS_RSAPublicKeyPKCS1Template, encBlob); + if(perr) { + return memFullErr; - /* estimate max size, BER-encode */ - size_t maxSize = 2 * (modulus->length + exponent->length); - CssmAllocator &alloc = CssmAllocator::standard(); - CssmAutoData cblob(alloc); - try { - SC_encodeAsnObj(snaccPubKey, cblob, maxSize); } - catch(...) { - /* right...? */ - return memFullErr; + /* copy out to caller */ + return SSLCopyBufferFromData(encBlob.Data, encBlob.Length, *blob); +} + +/* + * Given a DER encoded DHParameterBlock, extract the prime and generator. + * modulus and public exponent. + * This will work with either PKCS-1 encoded DHParameterBlock or + * openssl-style DHParameter. + */ +OSStatus sslDecodeDhParams( + const SSLBuffer *blob, /* PKCS-1 encoded */ + SSLBuffer *prime, /* data mallocd and RETURNED */ + SSLBuffer *generator) /* data mallocd and RETURNED */ +{ + assert(blob != NULL); + assert(prime != NULL); + assert(generator != NULL); + + PRErrorCode perr; + NSS_DHParameterBlock paramBlock; + SecNssCoder coder; + CSSM_DATA cblob; + + memset(¶mBlock, 0, sizeof(paramBlock)); + SSLBUF_TO_CSSM(blob, &cblob); + + /* + * Since the common case here is to decode a parameter block coming + * over the wire, which is in openssl format, let's try that format first. + */ + perr = coder.decodeItem(cblob, NSS_DHParameterTemplate, + ¶mBlock.params); + if(perr) { + /* + * OK, that failed when trying as a CDSA_formatted parameter + * block DHParameterBlock). Openssl uses a subset of that, + * a DHParameter. Try that instead. + */ + memset(¶mBlock, 0, sizeof(paramBlock)); + perr = coder.decodeItem(cblob, NSS_DHParameterBlockTemplate, + ¶mBlock); + if(perr) { + /* Ah well, we tried. */ + sslErrorLog("sslDecodeDhParams: both CDSA and openssl format" + "failed\n"); + return errSSLCrypto; + } } + + /* copy out components */ + NSS_DHParameter ¶m = paramBlock.params; + OSStatus ortn = SSLCopyBufferFromData(param.prime.Data, + param.prime.Length, *prime); + if(ortn) { + return ortn; + } + return SSLCopyBufferFromData(param.base.Data, + param.base.Length, *generator); +} + +/* + * Given a prime and generator, cook up a BER-encoded DHParameter blob. + */ +OSStatus sslEncodeDhParams( + const SSLBuffer *prime, + const SSLBuffer *generator, + SSLBuffer *blob) /* data mallocd and RETURNED */ +{ + assert((prime != NULL) && (generator != NULL)); + blob->data = NULL; + blob->length = 0; + + /* convert to NSS_DHParameter */ + NSS_DHParameter dhParams; + SSLBUF_TO_CSSM(prime, &dhParams.prime); + SSLBUF_TO_CSSM(generator, &dhParams.base); + dhParams.privateValueLength.Data = NULL; + dhParams.privateValueLength.Length = 0; - /* copy to caller's SSLBuffer */ - OSStatus srtn = SSLAllocBuffer(*blob, cblob.length(), NULL); - if(srtn) { - return srtn; + /* DER encode */ + SecNssCoder coder; + CSSM_DATA encBlob; + PRErrorCode perr; + perr = coder.encodeItem(&dhParams, NSS_DHParameterTemplate, encBlob); + if(perr) { + return memFullErr; + } - memmove(blob->data, cblob.data(), cblob.length()); - return noErr; + /* copy out to caller */ + return SSLCopyBufferFromData(encBlob.Data, encBlob.Length, *blob); } diff --git a/SecureTransport/sslCert.cpp b/SecureTransport/sslCert.cpp index 7bf7b1b1..c9277f2e 100644 --- a/SecureTransport/sslCert.cpp +++ b/SecureTransport/sslCert.cpp @@ -152,12 +152,38 @@ SSLProcessCertificate(SSLBuffer message, SSLContext *ctx) return noErr; } else { + AlertDescription desc; + if(ctx->negProtocolVersion == SSL_Version_3_0) { + /* this one's for SSL3 only */ + desc = SSL_AlertBadCert; + } + else { + desc = SSL_AlertCertUnknown; + } + SSLFatalSessionAlert(desc, ctx); return errSSLXCertChainInvalid; } } - if((err = sslVerifyCertChain(ctx, *ctx->peerCert)) != 0) + if((err = sslVerifyCertChain(ctx, *ctx->peerCert)) != 0) { + AlertDescription desc; + switch(err) { + case errSSLUnknownRootCert: + case errSSLNoRootCert: + desc = SSL_AlertUnknownCA; + break; + case errSSLCertExpired: + case errSSLCertNotYetValid: + desc = SSL_AlertCertExpired; + break; + case errSSLXCertChainInvalid: + default: + desc = SSL_AlertCertUnknown; + break; + } + SSLFatalSessionAlert(desc, ctx); return err; - + } + /* peer's certificate is the last one in the chain */ cert = ctx->peerCert; while (cert->next != 0) @@ -323,7 +349,7 @@ SSLEncodeCertificateVerify(SSLRecord &certVerify, SSLContext *ctx) SSLEncodeInt(certVerify.contents.data+1, len+2, 3); SSLEncodeInt(certVerify.contents.data+4, len, 2); - err = sslRsaRawSign(ctx, + err = sslRawSign(ctx, ctx->signingPrivKey, ctx->signingKeyCsp, hashData, // data to sign @@ -390,7 +416,7 @@ SSLProcessCertificateVerify(SSLBuffer message, SSLContext *ctx) /* * The CSP does the decrypt & compare for us in one shot */ - err = sslRsaRawVerify(ctx, + err = sslRawVerify(ctx, ctx->peerPubKey, ctx->peerPubKeyCsp, // FIXME - maybe we just use cspHand? hashData, // data to verify @@ -398,6 +424,7 @@ SSLProcessCertificateVerify(SSLBuffer message, SSLContext *ctx) message.data + 2, // signature signatureLen); if(err) { + SSLFatalSessionAlert(SSL_AlertDecryptError, ctx); goto fail; } err = noErr; diff --git a/SecureTransport/sslChangeCipher.cpp b/SecureTransport/sslChangeCipher.cpp index 391a8f23..7de0d2a6 100644 --- a/SecureTransport/sslChangeCipher.cpp +++ b/SecureTransport/sslChangeCipher.cpp @@ -77,7 +77,7 @@ SSLProcessChangeCipherSpec(SSLRecord rec, SSLContext *ctx) /* Install new cipher spec on read side */ if ((err = SSLDisposeCipherSuite(&ctx->readCipher, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } ctx->readCipher = ctx->readPending; diff --git a/SecureTransport/sslContext.cpp b/SecureTransport/sslContext.cpp index 203bc534..835f6550 100644 --- a/SecureTransport/sslContext.cpp +++ b/SecureTransport/sslContext.cpp @@ -38,6 +38,7 @@ #include "sslUtils.h" #include "cipherSpecs.h" #include "appleSession.h" +#include "sslBER.h" #include #include #include @@ -81,9 +82,11 @@ static OSStatus sslFreeTrustedRoots( } /* - * Default attempted version. + * Default version enables. */ -#define DEFAULT_MAX_VERSION TLS_Version_1_0 +#define DEFAULT_SSL2_ENABLE true +#define DEFAULT_SSL3_ENABLE true +#define DEFAULT_TLS1_ENABLE true OSStatus SSLNewContext (Boolean isServer, @@ -106,17 +109,18 @@ SSLNewContext (Boolean isServer, ctx->state = SSL_HdskStateUninit; ctx->clientCertState = kSSLClientCertNone; - /* different defaults for client and server ... */ + ctx->versionSsl2Enable = DEFAULT_SSL2_ENABLE; + ctx->versionSsl3Enable = DEFAULT_SSL3_ENABLE; + ctx->versionTls1Enable = DEFAULT_TLS1_ENABLE; + ctx->negProtocolVersion = SSL_Version_Undetermined; + if(isServer) { ctx->protocolSide = SSL_ServerSide; - ctx->reqProtocolVersion = DEFAULT_MAX_VERSION; } else { ctx->protocolSide = SSL_ClientSide; - ctx->reqProtocolVersion = SSL_Version_Undetermined; } - ctx->negProtocolVersion = SSL_Version_Undetermined; - ctx->maxProtocolVersion = DEFAULT_MAX_VERSION; + /* Default value so we can send and receive hello msgs */ ctx->sslTslCalls = &Ssl3Callouts; @@ -148,8 +152,8 @@ SSLNewContext (Boolean isServer, /* Initial cert verify state: verify with default system roots */ ctx->enableCertVerify = true; - /* snag root certs from Keychain, tolerate error */ - addBuiltInCerts(ctx); + /* Default for RSA blinding is ENABLED */ + ctx->rsaBlindingEnable = true; *contextPtr = ctx; return noErr; @@ -177,7 +181,10 @@ SSLDisposeContext (SSLContext *ctx) sslDeleteCertificateChain(ctx->peerCert, ctx); ctx->localCert = ctx->encryptCert = ctx->peerCert = NULL; SSLFreeBuffer(ctx->partialReadBuffer, ctx); - + if(ctx->peerSecTrust) { + CFRelease(ctx->peerSecTrust); + ctx->peerSecTrust = NULL; + } wait = ctx->recordWriteQueue; while (wait) { SSLFreeBuffer(wait->data, ctx); @@ -188,10 +195,15 @@ SSLDisposeContext (SSLContext *ctx) wait = next; } + #if APPLE_DH + SSLFreeBuffer(ctx->dhParamsPrime, ctx); + SSLFreeBuffer(ctx->dhParamsGenerator, ctx); + SSLFreeBuffer(ctx->dhParamsEncoded, ctx); SSLFreeBuffer(ctx->dhPeerPublic, ctx); SSLFreeBuffer(ctx->dhExchangePublic, ctx); - SSLFreeBuffer(ctx->dhPrivate, ctx); - + sslFreeKey(ctx->cspHand, &ctx->dhPrivate, NULL); + #endif /* APPLE_DH */ + CloseHash(SSLHashSHA1, ctx->shaState, ctx); CloseHash(SSLHashMD5, ctx->md5State, ctx); @@ -266,8 +278,8 @@ SSLGetSessionState (SSLContextRef context, case SSL_HdskStateNoNotifyClose: rtnState = kSSLAborted; break; - case SSL2_HdskStateServerReady: - case SSL2_HdskStateClientReady: + case SSL_HdskStateServerReady: + case SSL_HdskStateClientReady: rtnState = kSSLConnected; break; default: @@ -313,6 +325,17 @@ SSLSetConnection (SSLContextRef ctx, return noErr; } +OSStatus +SSLGetConnection (SSLContextRef ctx, + SSLConnectionRef *connection) +{ + if((ctx == NULL) || (connection == NULL)) { + return paramErr; + } + *connection = ctx->ioCtx.ioRef; + return noErr; +} + OSStatus SSLSetPeerDomainName (SSLContextRef ctx, const char *peerName, @@ -371,13 +394,96 @@ SSLGetPeerDomainName (SSLContextRef ctx, return noErr; } +/* concert between private SSLProtocolVersion and public SSLProtocol */ +static SSLProtocol convertProtToExtern(SSLProtocolVersion prot) +{ + switch(prot) { + case SSL_Version_Undetermined: + return kSSLProtocolUnknown; + case SSL_Version_2_0: + return kSSLProtocol2; + case SSL_Version_3_0: + return kSSLProtocol3; + case TLS_Version_1_0: + return kTLSProtocol1; + default: + sslErrorLog("convertProtToExtern: bad prot\n"); + return kSSLProtocolUnknown; + } + /* not reached but make compiler happy */ + return kSSLProtocolUnknown; +} + +OSStatus +SSLSetProtocolVersionEnabled(SSLContextRef ctx, + SSLProtocol protocol, + Boolean enable) /* RETURNED */ +{ + if(ctx == NULL) { + return paramErr; + } + if(sslIsSessionActive(ctx)) { + /* can't do this with an active session */ + return badReqErr; + } + switch(protocol) { + case kSSLProtocol2: + ctx->versionSsl2Enable = enable; + break; + case kSSLProtocol3: + ctx->versionSsl3Enable = enable; + break; + case kTLSProtocol1: + ctx->versionTls1Enable = enable; + break; + case kSSLProtocolAll: + ctx->versionTls1Enable = ctx->versionSsl3Enable = + ctx->versionSsl2Enable = enable; + break; + default: + return paramErr; + } + return noErr; +} + +OSStatus +SSLGetProtocolVersionEnabled(SSLContextRef ctx, + SSLProtocol protocol, + Boolean *enable) /* RETURNED */ +{ + if(ctx == NULL) { + return paramErr; + } + switch(protocol) { + case kSSLProtocol2: + *enable = ctx->versionSsl2Enable; + break; + case kSSLProtocol3: + *enable = ctx->versionSsl3Enable; + break; + case kTLSProtocol1: + *enable = ctx->versionTls1Enable; + break; + case kSSLProtocolAll: + if(ctx->versionTls1Enable && ctx->versionSsl3Enable && + ctx->versionSsl2Enable) { + *enable = true; + } + else { + *enable = false; + } + break; + default: + return paramErr; + } + return noErr; +} + +/* deprecated */ OSStatus SSLSetProtocolVersion (SSLContextRef ctx, SSLProtocol version) { - SSLProtocolVersion versInt; - SSLProtocolVersion versMax; - if(ctx == NULL) { return paramErr; } @@ -386,68 +492,48 @@ SSLSetProtocolVersion (SSLContextRef ctx, return badReqErr; } - /* convert external representation to private */ + /* convert external representation to three booleans */ switch(version) { case kSSLProtocolUnknown: - versInt = SSL_Version_Undetermined; - versMax = DEFAULT_MAX_VERSION; + ctx->versionSsl2Enable = DEFAULT_SSL2_ENABLE; + ctx->versionSsl3Enable = DEFAULT_SSL3_ENABLE; + ctx->versionTls1Enable = DEFAULT_TLS1_ENABLE; break; case kSSLProtocol2: - versInt = versMax = SSL_Version_2_0; + ctx->versionSsl2Enable = true; + ctx->versionSsl3Enable = false; + ctx->versionTls1Enable = false; break; case kSSLProtocol3: - /* this tells us to do our best but allows 2.0 */ - versInt = SSL_Version_Undetermined; - versMax = SSL_Version_3_0; + /* this tells us to do our best, up to 3.0, but allows 2.0 */ + ctx->versionSsl2Enable = true; + ctx->versionSsl3Enable = true; + ctx->versionTls1Enable = false; break; case kSSLProtocol3Only: - versInt = SSL_Version_3_0_Only; - versMax = SSL_Version_3_0; + ctx->versionSsl2Enable = false; + ctx->versionSsl3Enable = true; + ctx->versionTls1Enable = false; break; case kTLSProtocol1: - /* this tells us to do our best but allows 2.0 */ - versInt = SSL_Version_Undetermined; - versMax = TLS_Version_1_0; + case kSSLProtocolAll: + /* this tells us to do our best, up to TLS, but allows 2.0 or 3.0 */ + ctx->versionSsl2Enable = true; + ctx->versionSsl3Enable = true; + ctx->versionTls1Enable = true; break; case kTLSProtocol1Only: - versInt = TLS_Version_1_0_Only; - versMax = TLS_Version_1_0; + ctx->versionSsl2Enable = false; + ctx->versionSsl3Enable = false; + ctx->versionTls1Enable = true; break; default: return paramErr; } - ctx->reqProtocolVersion = ctx->negProtocolVersion = versInt; - ctx->maxProtocolVersion = versMax; return noErr; } -static SSLProtocol convertProtToExtern(SSLProtocolVersion prot) -{ - switch(prot) { - case SSL_Version_Undetermined: - return kSSLProtocolUnknown; - case SSL_Version_3_0_Only: - return kSSLProtocol3Only; - case SSL_Version_2_0: - return kSSLProtocol2; - case SSL_Version_3_0: - return kSSLProtocol3; - case TLS_Version_1_0_Only: - return kTLSProtocol1Only; - case TLS_Version_1_0: - return kTLSProtocol1; - /* this can happen in an intermediate state while negotiation - * is active...right? */ - case SSL_Version_3_0_With_2_0_Hello: - return kSSLProtocolUnknown; - default: - sslErrorLog("convertProtToExtern: bad prot\n"); - return kSSLProtocolUnknown; - } - /* not reached but make compiler happy */ - return kSSLProtocolUnknown; -} - +/* deprecated */ OSStatus SSLGetProtocolVersion (SSLContextRef ctx, SSLProtocol *protocol) /* RETURNED */ @@ -455,8 +541,52 @@ SSLGetProtocolVersion (SSLContextRef ctx, if(ctx == NULL) { return paramErr; } - *protocol = convertProtToExtern(ctx->reqProtocolVersion); - return noErr; + + /* translate array of booleans to public value; not all combinations + * are legal (i.e., meaningful) for this call */ + if(ctx->versionTls1Enable) { + if(ctx->versionSsl2Enable) { + if(ctx->versionSsl3Enable) { + /* traditional 'all enabled' */ + *protocol = kTLSProtocol1; + return noErr; + } + else { + /* SSL2 true, SSL3 false, TLS1 true - invalid here */ + return paramErr; + } + } + else if(ctx->versionSsl3Enable) { + /* SSL2 false, SSL3 true, TLS1 true - invalid here */ + return paramErr; + } + else { + *protocol = kTLSProtocol1Only; + return noErr; + } + } + else { + /* TLS1 false */ + if(ctx->versionSsl3Enable) { + *protocol = ctx->versionSsl2Enable ? + kSSLProtocol3 : kSSLProtocol3Only; + return noErr; + } + else if(ctx->versionSsl2Enable) { + *protocol = kSSLProtocol2; + return noErr; + } + else { + /* + * Bogus state - no enables - the API does provide a way + * to get into this state. Other than this path, the app + * will discover this bogon when attempting to do the + * handshake; sslGetMaxProtVersion will detect this. + */ + return paramErr; + } + } + /* NOT REACHED */ } OSStatus @@ -477,6 +607,8 @@ SSLSetEnableCertVerify (SSLContextRef ctx, if(ctx == NULL) { return paramErr; } + sslCertDebug("SSLSetEnableCertVerify %s", + enableVerify ? "true" : "false"); if(sslIsSessionActive(ctx)) { /* can't do this with an active session */ return badReqErr; @@ -503,6 +635,8 @@ SSLSetAllowsExpiredCerts(SSLContextRef ctx, if(ctx == NULL) { return paramErr; } + sslCertDebug("SSLSetAllowsExpiredCerts %s", + allowExpired ? "true" : "false"); if(sslIsSessionActive(ctx)) { /* can't do this with an active session */ return badReqErr; @@ -529,6 +663,8 @@ SSLSetAllowsExpiredRoots(SSLContextRef ctx, if(ctx == NULL) { return paramErr; } + sslCertDebug("SSLSetAllowsExpiredRoots %s", + allowExpired ? "true" : "false"); if(sslIsSessionActive(ctx)) { /* can't do this with an active session */ return badReqErr; @@ -555,6 +691,7 @@ OSStatus SSLSetAllowsAnyRoot( if(ctx == NULL) { return paramErr; } + sslCertDebug("SSLSetAllowsAnyRoot %s", anyRoot ? "true" : "false"); ctx->allowAnyRoot = anyRoot; return noErr; } @@ -593,6 +730,8 @@ SSLSetTrustedRoots (SSLContextRef ctx, return badReqErr; } numCerts = numIncoming = CFArrayGetCount(trustedRoots); + sslCertDebug("SSLSetTrustedRoot numCerts %d replaceExist %s", + (int)numCerts, replaceExisting ? "true" : "false"); if(!replaceExisting) { if(ctx->trustedCerts != NULL) { /* adding to existing store */ @@ -787,67 +926,9 @@ SSLSetEncryptionCertificate (SSLContextRef ctx, &ctx->encryptCert, &ctx->encryptPubKey, &ctx->encryptPrivKey, - &ctx->encryptKeyCsp - #if ST_KC_KEYS_NEED_REF - , - &ctx->encryptKeyRef); - #else - ); - #endif -} - -#if ST_MANAGES_TRUSTED_ROOTS - -/* - * Add (optional, additional) trusted root certs. - */ -OSStatus -SSLSetTrustedRootCertKC (SSLContextRef ctx, - KCRef keyChainRef, - Boolean deleteExisting) -{ - /* - * -- free trustedCerts if deleteExisting - * -- Get raw cert data, add to ctx->trustedCerts - * -- verify that each of these is a valid (self-verifying) - * root cert - * -- add each subject name to acceptableDNList - */ - if((ctx == NULL) || (keyChainRef == nil)) { - return paramErr; - } - if(sslIsSessionActive(ctx)) { - /* can't do this with an active session */ - return badReqErr; - } - if(deleteExisting) { - sslFreeTrustedRoots(ctx); - } - return parseTrustedKeychain(ctx, keyChainRef); + &ctx->encryptKeyCsp); } -OSStatus -SSLSetNewRootKC (SSLContextRef ctx, - KCRef keyChainRef, - void *accessCreds) -{ - if((ctx == NULL) || (keyChainRef == nil)) { - return paramErr; - } - if(sslIsSessionActive(ctx)) { - /* can't do this with an active session */ - return badReqErr; - } - if(ctx->newRootCertKc != NULL) { - /* can't do this multiple times */ - return badReqErr; - } - ctx->newRootCertKc = keyChainRef; - ctx->accessCreds = accessCreds; - return noErr; -} -#endif /* ST_MANAGES_TRUSTED_ROOTS */ - OSStatus SSLSetPeerID (SSLContext *ctx, const void *peerID, @@ -981,6 +1062,92 @@ SSLGetPeerCertificates (SSLContextRef ctx, return noErr; } +/* + * Specify Diffie-Hellman parameters. Optional; if we are configured to allow + * for D-H ciphers and a D-H cipher is negotiated, and this function has not + * been called, a set of process-wide parameters will be calculated. However + * that can take a long time (30 seconds). + */ +OSStatus SSLSetDiffieHellmanParams( + SSLContextRef ctx, + const void *dhParams, + size_t dhParamsLen) +{ + if(ctx == NULL) { + return paramErr; + } + if(sslIsSessionActive(ctx)) { + return badReqErr; + } + SSLFreeBuffer(ctx->dhParamsPrime, ctx); + SSLFreeBuffer(ctx->dhParamsGenerator, ctx); + SSLFreeBuffer(ctx->dhParamsEncoded, ctx); + + OSStatus ortn; + ortn = SSLCopyBufferFromData(dhParams, dhParamsLen, + ctx->dhParamsEncoded); + if(ortn) { + return ortn; + } + + /* decode for use by server over the wire */ + SSLBuffer sParams; + sParams.data = (UInt8 *)dhParams; + sParams.length = dhParamsLen; + return sslDecodeDhParams(&sParams, &ctx->dhParamsPrime, + &ctx->dhParamsGenerator); +} + +/* + * Return parameter block specified in SSLSetDiffieHellmanParams. + * Returned data is not copied and belongs to the SSLContextRef. + */ +OSStatus SSLGetDiffieHellmanParams( + SSLContextRef ctx, + const void **dhParams, + size_t *dhParamsLen) +{ + if(ctx == NULL) { + return paramErr; + } + *dhParams = ctx->dhParamsEncoded.data; + *dhParamsLen = ctx->dhParamsEncoded.length; + return noErr; +} + +OSStatus SSLSetRsaBlinding( + SSLContextRef ctx, + Boolean blinding) +{ + if(ctx == NULL) { + return paramErr; + } + ctx->rsaBlindingEnable = blinding; + return noErr; +} + +OSStatus SSLGetRsaBlinding( + SSLContextRef ctx, + Boolean *blinding) +{ + if(ctx == NULL) { + return paramErr; + } + *blinding = ctx->rsaBlindingEnable; + return noErr; +} + +OSStatus SSLGetPeerSecTrust( + SSLContextRef ctx, + SecTrustRef *secTrust) /* RETURNED */ +{ + if(ctx == NULL) { + return paramErr; + } + *secTrust = ctx->peerSecTrust; + return noErr; +} + OSStatus SSLInternalMasterSecret( SSLContextRef ctx, void *secret, // mallocd by caller, SSL_MASTER_SECRET_SIZE @@ -1029,5 +1196,33 @@ OSStatus SSLInternalClientRandom( return noErr; } +OSStatus +SSLGetResumableSessionInfo( + SSLContextRef ctx, + Boolean *sessionWasResumed, // RETURNED + void *sessionID, // RETURNED, mallocd by caller + size_t *sessionIDLength) // IN/OUT +{ + if((ctx == NULL) || (sessionWasResumed == NULL) || + (sessionID == NULL) || (sessionIDLength == NULL) || + (*sessionIDLength < MAX_SESSION_ID_LENGTH)) { + return paramErr; + } + if(ctx->sessionMatch) { + assert(ctx->sessionID.data != NULL); + *sessionWasResumed = true; + if(ctx->sessionID.length > *sessionIDLength) { + /* really should never happen - means ID > 32 */ + return paramErr; + } + memmove(sessionID, ctx->sessionID.data, ctx->sessionID.length); + *sessionIDLength = ctx->sessionID.length; + } + else { + *sessionWasResumed = false; + *sessionIDLength = 0; + } + return noErr; +} diff --git a/SecureTransport/sslHandshake.cpp b/SecureTransport/sslHandshake.cpp index 2ef0abe2..2e908d00 100644 --- a/SecureTransport/sslHandshake.cpp +++ b/SecureTransport/sslHandshake.cpp @@ -56,7 +56,7 @@ SSLProcessHandshakeRecord(SSLRecord rec, SSLContext *ctx) { if ((err = SSLReallocBuffer(ctx->fragmentedMessageCache, ctx->fragmentedMessageCache.length + rec.contents.length, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } memcpy(ctx->fragmentedMessageCache.data + ctx->fragmentedMessageCache.length, @@ -93,7 +93,7 @@ SSLProcessHandshakeRecord(SSLRecord rec, SSLContext *ctx) if (message.type != SSL_HdskHelloRequest) { if ((err = SSLHashSHA1.update(ctx->shaState, messageData)) != 0 || (err = SSLHashMD5.update(ctx->md5State, messageData)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } @@ -106,7 +106,7 @@ SSLProcessHandshakeRecord(SSLRecord rec, SSLContext *ctx) { /* If there isn't a cache, allocate one */ if (ctx->fragmentedMessageCache.data == 0) { if ((err = SSLAllocBuffer(ctx->fragmentedMessageCache, remaining, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } @@ -117,7 +117,7 @@ SSLProcessHandshakeRecord(SSLRecord rec, SSLContext *ctx) } else if (ctx->fragmentedMessageCache.data != 0) { if ((err = SSLFreeBuffer(ctx->fragmentedMessageCache, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } @@ -156,7 +156,13 @@ SSLProcessHandshakeMessage(SSLHandshakeMsg message, SSLContext *ctx) err = SSLProcessCertificate(message.contents, ctx); if(ctx->protocolSide == SSL_ServerSide) { if(err) { - ctx->clientCertState = kSSLClientCertRejected; + /* + * Error could be from no cert (when we require one) + * or invalid cert + */ + if(ctx->peerCert != NULL) { + ctx->clientCertState = kSSLClientCertRejected; + } } else if(ctx->peerCert != NULL) { /* @@ -220,7 +226,7 @@ SSLProcessHandshakeMessage(SSLHandshakeMsg message, SSLContext *ctx) break; } - if (err) + if (err && !ctx->sentFatalAlert) { if (err == errSSLProtocol) SSLFatalSessionAlert(SSL_AlertIllegalParam, ctx); else if (err == errSSLNegotiation) @@ -257,28 +263,38 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) break; case SSL_HdskClientHello: assert(ctx->protocolSide == SSL_ServerSide); + ctx->sessionMatch = 0; if (ctx->sessionID.data != 0) /* If session ID != 0, client is trying to resume */ { if (ctx->resumableSession.data != 0) - { if ((err = SSLRetrieveSessionID(ctx->resumableSession, + { + SSLProtocolVersion sessionProt; + if ((err = SSLRetrieveSessionID(ctx->resumableSession, &sessionIdentifier, ctx)) != 0) return err; - if (sessionIdentifier.length == ctx->sessionID.length && - memcmp(sessionIdentifier.data, ctx->sessionID.data, - ctx->sessionID.length) == 0) + if ((err = SSLRetrieveSessionProtocolVersion(ctx->resumableSession, + &sessionProt, ctx)) != 0) + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); + return err; + } + if ((sessionIdentifier.length == ctx->sessionID.length) && + (memcmp(sessionIdentifier.data, ctx->sessionID.data, + ctx->sessionID.length) == 0) && + (sessionProt == ctx->negProtocolVersion)) { /* Everything matches; resume the session */ sslLogResumSessDebug("===RESUMING SSL3 server-side session"); if ((err = SSLInstallSessionFromData(ctx->resumableSession, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } + ctx->sessionMatch = 1; if ((err = SSLPrepareAndQueueMessage(SSLEncodeServerHello, ctx)) != 0) return err; if ((err = SSLInitPendingCiphers(ctx)) != 0 || (err = SSLFreeBuffer(sessionIdentifier, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } if ((err = @@ -288,7 +304,7 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) /* Install new cipher spec on write side */ if ((err = SSLDisposeCipherSuite(&ctx->writeCipher, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } ctx->writeCipher = ctx->writePending; @@ -311,12 +327,12 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) } if ((err = SSLFreeBuffer(sessionIdentifier, ctx)) != 0 || (err = SSLDeleteSessionData(ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } if ((err = SSLFreeBuffer(ctx->sessionID, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } @@ -332,7 +348,7 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) if (err == 0) { if((err = sslRand(ctx, &ctx->sessionID)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } @@ -355,6 +371,12 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) break; #endif /* APPLE_DH */ default: /* everything else */ + if(ctx->localCert == NULL) { + /* no cert but configured for, and negotiated, a + * ciphersuite which requires one */ + sslErrorLog("SSLAdvanceHandshake: No server key!\n"); + return errSSLBadConfiguration; + } if ((err = SSLPrepareAndQueueMessage(SSLEncodeCertificate, ctx)) != 0) return err; @@ -367,32 +389,36 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) * private key), but conceptually in this code, we do it if * enabled by the presence of encryptPrivKey. */ - #if SSL_SERVER_KEYEXCH_HACK - /* - * This is currently how we work with Netscape. It requires - * a CSP which can handle private keys which can both - * sign and decrypt. - */ - if((ctx->selectedCipherSpec->keyExchangeMethod != SSL_RSA) && - (ctx->encryptPrivKey != NULL)) { - err = SSLPrepareAndQueueMessage(SSLEncodeServerKeyExchange, ctx); - if(err) { - return err; - } + { + bool doServerKeyExch = false; + switch(ctx->selectedCipherSpec->keyExchangeMethod) { + case SSL_RSA_EXPORT: + #if !SSL_SERVER_KEYEXCH_HACK + /* the "proper" way - app decides. */ + case SSL_RSA: + #endif + if(ctx->encryptPrivKey != NULL) { + doServerKeyExch = true; + } + break; + case SSL_DH_anon: + case SSL_DH_anon_EXPORT: + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + doServerKeyExch = true; + break; + default: + break; } - #else /* !SSL_SERVER_KEYEXCH_HACK */ - /* - * This is, I believe the "right" way, but Netscape doesn't - * work this way. - */ - if (ctx->encryptPrivKey != NULL) { + if(doServerKeyExch) { err = SSLPrepareAndQueueMessage(SSLEncodeServerKeyExchange, ctx); if(err) { return err; } } - #endif /* SSL_SERVER_KEYEXCH_HACK */ - + } if (ctx->tryClientAuth) { if ((err = SSLPrepareAndQueueMessage(SSLEncodeCertificateRequest, ctx)) != 0) @@ -410,24 +436,34 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) } break; case SSL_HdskServerHello: + ctx->sessionMatch = 0; if (ctx->resumableSession.data != 0 && ctx->sessionID.data != 0) - { if ((err = SSLRetrieveSessionID(ctx->resumableSession, + { + SSLProtocolVersion sessionProt; + if ((err = SSLRetrieveSessionID(ctx->resumableSession, &sessionIdentifier, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); + return err; + } + if ((err = SSLRetrieveSessionProtocolVersion(ctx->resumableSession, + &sessionProt, ctx)) != 0) + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } - if (sessionIdentifier.length == ctx->sessionID.length && - memcmp(sessionIdentifier.data, ctx->sessionID.data, - ctx->sessionID.length) == 0) + if ((sessionIdentifier.length == ctx->sessionID.length) && + (memcmp(sessionIdentifier.data, ctx->sessionID.data, + ctx->sessionID.length) == 0) && + (sessionProt == ctx->negProtocolVersion)) { /* Everything matches; resume the session */ sslLogResumSessDebug("===RESUMING SSL3 client-side session"); if ((err = SSLInstallSessionFromData(ctx->resumableSession, ctx)) != 0 || (err = SSLInitPendingCiphers(ctx)) != 0 || (err = SSLFreeBuffer(sessionIdentifier, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } + ctx->sessionMatch = 1; SSLChangeHdskState(ctx, SSL_HdskStateChangeCipherSpec); break; } @@ -436,7 +472,7 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) "session"); } if ((err = SSLFreeBuffer(sessionIdentifier, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } @@ -549,7 +585,7 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) assert(ctx->sslTslCalls != NULL); if ((err = ctx->sslTslCalls->generateMasterSecret(ctx)) != 0 || (err = SSLInitPendingCiphers(ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } memset(ctx->preMasterSecret.data, 0, ctx->preMasterSecret.length); @@ -568,7 +604,7 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) } /* Install new cipher spec on write side */ if ((err = SSLDisposeCipherSuite(&ctx->writeCipher, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } ctx->writeCipher = ctx->writePending; @@ -591,7 +627,7 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) assert(ctx->sslTslCalls != NULL); if ((err = ctx->sslTslCalls->generateMasterSecret(ctx)) != 0 || (err = SSLInitPendingCiphers(ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } memset(ctx->preMasterSecret.data, 0, ctx->preMasterSecret.length); @@ -616,7 +652,7 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) /* Install new cipher spec on write side */ if ((err = SSLDisposeCipherSuite(&ctx->writeCipher, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } ctx->writeCipher = ctx->writePending; @@ -630,10 +666,10 @@ SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx) ctx->writeCipher.ready = 1; } if (ctx->protocolSide == SSL_ServerSide) { - SSLChangeHdskState(ctx, SSL2_HdskStateServerReady); + SSLChangeHdskState(ctx, SSL_HdskStateServerReady); } else { - SSLChangeHdskState(ctx, SSL2_HdskStateClientReady); + SSLChangeHdskState(ctx, SSL_HdskStateClientReady); } if (ctx->peerID.data != 0) SSLAddSessionData(ctx); @@ -659,7 +695,7 @@ SSLPrepareAndQueueMessage(EncodeMessageFunc msgFunc, SSLContext *ctx) if (rec.contentType == SSL_RecordTypeHandshake) { if ((err = SSLHashSHA1.update(ctx->shaState, rec.contents)) != 0 || (err = SSLHashMD5.update(ctx->md5State, rec.contents)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); goto fail; } SSLLogHdskMsg((SSLHandshakeType)rec.contents.data[0], 1); @@ -685,7 +721,7 @@ SSL3ReceiveSSL2ClientHello(SSLRecord rec, SSLContext *ctx) if ((err = SSLHashSHA1.update(ctx->shaState, rec.contents)) != 0 || (err = SSLHashMD5.update(ctx->md5State, rec.contents)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } @@ -746,10 +782,10 @@ char *hdskStateToStr(SSLHandshakeState state) return "SSL2_ServerVerify"; case SSL2_HdskStateServerFinished: return "SSL2_ServerFinished"; - case SSL2_HdskStateServerReady: - return "SSL2_ServerReady"; - case SSL2_HdskStateClientReady: - return "SSL2_ClientReady"; + case SSL_HdskStateServerReady: + return "SSL_ServerReady"; + case SSL_HdskStateClientReady: + return "SSL_ClientReady"; default: sprintf(badStr, "Unknown state (%d(d)", state); return badStr; diff --git a/SecureTransport/sslHandshakeHello.cpp b/SecureTransport/sslHandshakeHello.cpp index 74a7681c..9264e42a 100644 --- a/SecureTransport/sslHandshakeHello.cpp +++ b/SecureTransport/sslHandshakeHello.cpp @@ -64,6 +64,10 @@ SSLEncodeServerHello(SSLRecord &serverHello, SSLContext *ctx) } #endif /* SSL_IE_NULL_RESUME_BUG */ + /* this was set to a known quantity in SSLProcessClientHello */ + assert(ctx->negProtocolVersion != SSL_Version_Undetermined); + /* should not be here in this case */ + assert(ctx->negProtocolVersion != SSL_Version_2_0); sslLogNegotiateDebug("===SSL3 server: sending version %d_%d", ctx->negProtocolVersion >> 8, ctx->negProtocolVersion & 0xff); sslLogNegotiateDebug("...sessionIDLen = %d", sessionIDLen); @@ -112,7 +116,7 @@ SSLEncodeServerHello(SSLRecord &serverHello, SSLContext *ctx) OSStatus SSLProcessServerHello(SSLBuffer message, SSLContext *ctx) { OSStatus err; - SSLProtocolVersion protocolVersion; + SSLProtocolVersion protocolVersion, negVersion; unsigned int sessionIDLen; UInt8 *p; @@ -126,11 +130,13 @@ SSLProcessServerHello(SSLBuffer message, SSLContext *ctx) protocolVersion = (SSLProtocolVersion)SSLDecodeInt(p, 2); p += 2; - if (protocolVersion > ctx->maxProtocolVersion) { - return errSSLNegotiation; + /* FIXME this should probably send appropriate alerts */ + err = sslVerifyProtVersion(ctx, protocolVersion, &negVersion); + if(err) { + return err; } - ctx->negProtocolVersion = protocolVersion; - switch(protocolVersion) { + ctx->negProtocolVersion = negVersion; + switch(negVersion) { case SSL_Version_3_0: ctx->sslTslCalls = &Ssl3Callouts; break; @@ -141,7 +147,7 @@ SSLProcessServerHello(SSLBuffer message, SSLContext *ctx) return errSSLNegotiation; } sslLogNegotiateDebug("===SSL3 client: negVersion is %d_%d", - (protocolVersion >> 8) & 0xff, protocolVersion & 0xff); + (negVersion >> 8) & 0xff, negVersion & 0xff); memcpy(ctx->serverRandom, p, 32); p += 32; @@ -184,7 +190,7 @@ SSLEncodeClientHello(SSLRecord &clientHello, SSLContext *ctx) UInt16 sessionIDLen; assert(ctx->protocolSide == SSL_ClientSide); - + sessionIDLen = 0; if (ctx->resumableSession.data != 0) { if ((err = SSLRetrieveSessionID(ctx->resumableSession, @@ -196,7 +202,11 @@ SSLEncodeClientHello(SSLRecord &clientHello, SSLContext *ctx) length = 39 + 2*(ctx->numValidCipherSpecs) + sessionIDLen; - clientHello.protocolVersion = ctx->maxProtocolVersion; + err = sslGetMaxProtVersion(ctx, &clientHello.protocolVersion); + if(err) { + /* we don't have a protocol enabled */ + return err; + } clientHello.contentType = SSL_RecordTypeHandshake; if ((err = SSLAllocBuffer(clientHello.contents, length + 4, ctx)) != 0) return err; @@ -204,10 +214,10 @@ SSLEncodeClientHello(SSLRecord &clientHello, SSLContext *ctx) p = clientHello.contents.data; *p++ = SSL_HdskClientHello; p = SSLEncodeInt(p, length, 3); - p = SSLEncodeInt(p, ctx->maxProtocolVersion, 2); + p = SSLEncodeInt(p, clientHello.protocolVersion, 2); sslLogNegotiateDebug("===SSL3 client: proclaiming max protocol " "%d_%d capable ONLY", - ctx->maxProtocolVersion >> 8, ctx->maxProtocolVersion & 0xff); + clientHello.protocolVersion >> 8, clientHello.protocolVersion & 0xff); if ((err = SSLEncodeRandom(p, ctx)) != 0) { SSLFreeBuffer(clientHello.contents, ctx); return err; @@ -239,7 +249,7 @@ SSLEncodeClientHello(SSLRecord &clientHello, SSLContext *ctx) OSStatus SSLProcessClientHello(SSLBuffer message, SSLContext *ctx) { OSStatus err; - SSLProtocolVersion clientVersion; + SSLProtocolVersion negVersion; UInt16 cipherListLen, cipherCount, desiredSpec, cipherSpec; UInt8 sessionIDLen, compressionCount; UInt8 *charPtr; @@ -250,12 +260,13 @@ SSLProcessClientHello(SSLBuffer message, SSLContext *ctx) return errSSLProtocol; } charPtr = message.data; - clientVersion = (SSLProtocolVersion)SSLDecodeInt(charPtr, 2); + ctx->clientReqProtocol = (SSLProtocolVersion)SSLDecodeInt(charPtr, 2); charPtr += 2; - if(clientVersion > ctx->maxProtocolVersion) { - clientVersion = ctx->maxProtocolVersion; + err = sslVerifyProtVersion(ctx, ctx->clientReqProtocol, &negVersion); + if(err) { + return err; } - switch(clientVersion) { + switch(negVersion) { case SSL_Version_3_0: ctx->sslTslCalls = &Ssl3Callouts; break; @@ -265,9 +276,9 @@ SSLProcessClientHello(SSLBuffer message, SSLContext *ctx) default: return errSSLNegotiation; } - ctx->negProtocolVersion = clientVersion; + ctx->negProtocolVersion = negVersion; sslLogNegotiateDebug("===SSL3 server: negVersion is %d_%d", - clientVersion >> 8, clientVersion & 0xff); + negVersion >> 8, negVersion & 0xff); memcpy(ctx->clientRandom, charPtr, SSL_CLIENT_SRVR_RAND_SIZE); charPtr += 32; @@ -276,7 +287,8 @@ SSLProcessClientHello(SSLBuffer message, SSLContext *ctx) sslErrorLog("SSLProcessClientHello: msg len error 2\n"); return errSSLProtocol; } - if (sessionIDLen > 0 && ctx->peerID.data != 0) + /* FIXME peerID is never set on server side.... */ + if (sessionIDLen > 0 && ctx->peerID.data != 0) { /* Don't die on error; just treat it as an uncacheable session */ err = SSLAllocBuffer(ctx->sessionID, sessionIDLen, ctx); if (err == 0) diff --git a/SecureTransport/sslKeyExchange.cpp b/SecureTransport/sslKeyExchange.cpp index 6ea3fab5..bcf5c9c5 100644 --- a/SecureTransport/sslKeyExchange.cpp +++ b/SecureTransport/sslKeyExchange.cpp @@ -34,10 +34,145 @@ #include "sslUtils.h" #include "appleCdsa.h" #include "sslDigests.h" +#include "ModuleAttacher.h" +#include "sslBER.h" #include #include +#include +#include + +#pragma mark - +#pragma mark *** forward static declarations *** +static OSStatus SSLGenServerDHParamsAndKey(SSLContext *ctx); +static OSStatus SSLEncodeDHKeyParams(SSLContext *ctx, UInt8 *charPtr); +static OSStatus SSLDecodeDHKeyParams(SSLContext *ctx, UInt8 *&charPtr, + UInt32 length); + +#define DH_PARAM_DUMP 0 +#if DH_PARAM_DUMP + +static void dumpBuf(const char *name, SSLBuffer &buf) +{ + printf("%s:\n", name); + UInt8 *cp = buf.data; + UInt8 *endCp = cp + buf.length; + + do { + for(unsigned i=0; i<16; i++) { + printf("%02x ", *cp++); + if(cp == endCp) { + break; + } + } + if(cp == endCp) { + break; + } + printf("\n"); + } while(cp < endCp); + printf("\n"); +} +#else +#define dumpBuf(n, b) +#endif /* DH_PARAM_DUMP */ + +#if APPLE_DH + +#pragma mark - +#pragma mark *** local D-H parameter generator *** +/* + * Process-wide server-supplied Diffie-Hellman parameters. + * This might be overridden by some API_supplied parameters + * in the future. + */ +class ServerDhParams +{ +public: + ServerDhParams(); + ~ServerDhParams(); + const SSLBuffer &prime() { return mPrime; } + const SSLBuffer &generator() { return mGenerator; } + const SSLBuffer ¶mBlock() { return mParamBlock; } + +private: + /* these two for sending over the wire */ + SSLBuffer mPrime; + SSLBuffer mGenerator; + /* this one for sending to the CSP at key gen time */ + SSLBuffer mParamBlock; +}; + +ServerDhParams::ServerDhParams() +{ + mPrime.data = NULL; + mPrime.length = 0; + mGenerator.data = NULL; + mGenerator.length = 0; + mParamBlock.data = NULL; + mParamBlock.length = 0; + + CSSM_CSP_HANDLE cspHand; + CSSM_CL_HANDLE clHand; // not used here, just for + // attachToModules() + CSSM_TP_HANDLE tpHand; // ditto + CSSM_RETURN crtn; + + crtn = attachToModules(&cspHand, &clHand, &tpHand); + if(crtn) { + MacOSError::throwMe(errSSLModuleAttach); + } + + CSSM_CC_HANDLE ccHandle; + CSSM_DATA cParams = {0, NULL}; + + crtn = CSSM_CSP_CreateKeyGenContext(cspHand, + CSSM_ALGID_DH, + SSL_DH_DEFAULT_PRIME_SIZE, + NULL, // Seed + NULL, // Salt + NULL, // StartDate + NULL, // EndDate + &cParams, // Params, may be NULL + &ccHandle); + if(crtn) { + stPrintCdsaError("ServerDhParams CSSM_CSP_CreateKeyGenContext", crtn); + MacOSError::throwMe(errSSLCrypto); + } + + /* explicitly generate params and save them */ + sslDhDebug("^^^generating Diffie-Hellman parameters..."); + crtn = CSSM_GenerateAlgorithmParams(ccHandle, + SSL_DH_DEFAULT_PRIME_SIZE, &cParams); + if(crtn) { + stPrintCdsaError("ServerDhParams CSSM_GenerateAlgorithmParams", crtn); + CSSM_DeleteContext(ccHandle); + MacOSError::throwMe(errSSLCrypto); + } + CSSM_TO_SSLBUF(&cParams, &mParamBlock); + OSStatus ortn = sslDecodeDhParams(&mParamBlock, &mPrime, &mGenerator); + if(ortn) { + sslErrorLog("ServerDhParams: param decode error\n"); + MacOSError::throwMe(ortn); + } + CSSM_DeleteContext(ccHandle); +} + +ServerDhParams::~ServerDhParams() +{ + sslFree(mPrime.data); + sslFree(mGenerator.data); + sslFree(mParamBlock.data); +} + +/* the single global thing */ +static ModuleNexus serverDhParams; + +#endif /* APPLE_DH */ + +#pragma mark - +#pragma mark *** RSA key exchange *** + /* * Client RSA Key Exchange msgs actually start with a two-byte * length field, contrary to the first version of RFC 2246, dated @@ -48,138 +183,6 @@ typedef CSSM_KEY_PTR SSLRSAPrivateKey; -static OSStatus SSLEncodeRSAServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx); -static OSStatus SSLEncodeRSAKeyParams(SSLBuffer *keyParams, SSLRSAPrivateKey *key, SSLContext *ctx); -static OSStatus SSLProcessRSAServerKeyExchange(SSLBuffer message, SSLContext *ctx); -static OSStatus SSLDecodeRSAKeyExchange(SSLBuffer keyExchange, SSLContext *ctx); -static OSStatus SSLEncodeRSAKeyExchange(SSLRecord &keyExchange, SSLContext *ctx); -#if APPLE_DH -static OSStatus SSLEncodeDHanonServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx); -static OSStatus SSLEncodeDHanonKeyExchange(SSLRecord &keyExchange, SSLContext *ctx); -static OSStatus SSLDecodeDHanonKeyExchange(SSLBuffer keyExchange, SSLContext *ctx); -static OSStatus SSLProcessDHanonServerKeyExchange(SSLBuffer message, SSLContext *ctx); -#endif - -OSStatus -SSLEncodeServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx) -{ OSStatus err; - - switch (ctx->selectedCipherSpec->keyExchangeMethod) - { case SSL_RSA: - case SSL_RSA_EXPORT: - if ((err = SSLEncodeRSAServerKeyExchange(keyExch, ctx)) != 0) - return err; - break; - #if APPLE_DH - case SSL_DH_anon: - if ((err = SSLEncodeDHanonServerKeyExchange(keyExch, ctx)) != 0) - return err; - break; - #endif - default: - return unimpErr; - } - - return noErr; -} - -static OSStatus -SSLEncodeRSAServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx) -{ OSStatus err; - UInt8 *charPtr; - int length; - UInt32 outputLen, localKeyModulusLen; - UInt8 hashes[36]; - SSLBuffer exportKey,clientRandom,serverRandom,hashCtx, hash; - - exportKey.data = 0; - hashCtx.data = 0; - - /* we have a public key here... */ - assert(ctx->encryptPubKey != NULL); - assert(ctx->protocolSide == SSL_ServerSide); - - if ((err = SSLEncodeRSAKeyParams(&exportKey, &ctx->encryptPubKey, ctx)) != 0) - goto fail; - - assert(ctx->signingPubKey != NULL); - localKeyModulusLen = sslKeyLengthInBytes(ctx->signingPubKey); - - length = exportKey.length + 2 + localKeyModulusLen; - /* RSA ouputs a block as long as the modulus */ - - assert((ctx->negProtocolVersion == SSL_Version_3_0) || - (ctx->negProtocolVersion == TLS_Version_1_0)); - keyExch.protocolVersion = ctx->negProtocolVersion; - keyExch.contentType = SSL_RecordTypeHandshake; - if ((err = SSLAllocBuffer(keyExch.contents, length+4, ctx)) != 0) - goto fail; - - charPtr = keyExch.contents.data; - *charPtr++ = SSL_HdskServerKeyExchange; - charPtr = SSLEncodeInt(charPtr, length, 3); - - memcpy(charPtr, exportKey.data, exportKey.length); - charPtr += exportKey.length; - - clientRandom.data = ctx->clientRandom; - clientRandom.length = SSL_CLIENT_SRVR_RAND_SIZE; - serverRandom.data = ctx->serverRandom; - serverRandom.length = SSL_CLIENT_SRVR_RAND_SIZE; - - hash.data = &hashes[0]; - hash.length = 16; - if ((err = ReadyHash(SSLHashMD5, hashCtx, ctx)) != 0) - goto fail; - if ((err = SSLHashMD5.update(hashCtx, clientRandom)) != 0) - goto fail; - if ((err = SSLHashMD5.update(hashCtx, serverRandom)) != 0) - goto fail; - if ((err = SSLHashMD5.update(hashCtx, exportKey)) != 0) - goto fail; - if ((err = SSLHashMD5.final(hashCtx, hash)) != 0) - goto fail; - if ((err = SSLFreeBuffer(hashCtx, ctx)) != 0) - goto fail; - - hash.data = &hashes[16]; - hash.length = 20; - if ((err = ReadyHash(SSLHashSHA1, hashCtx, ctx)) != 0) - goto fail; - if ((err = SSLHashSHA1.update(hashCtx, clientRandom)) != 0) - goto fail; - if ((err = SSLHashSHA1.update(hashCtx, serverRandom)) != 0) - goto fail; - if ((err = SSLHashSHA1.update(hashCtx, exportKey)) != 0) - goto fail; - if ((err = SSLHashSHA1.final(hashCtx, hash)) != 0) - goto fail; - if ((err = SSLFreeBuffer(hashCtx, ctx)) != 0) - goto fail; - - charPtr = SSLEncodeInt(charPtr, localKeyModulusLen, 2); - err = sslRsaRawSign(ctx, - ctx->signingPrivKey, - ctx->signingKeyCsp, - hashes, - 36, - charPtr, - length, - &outputLen); - if(err) { - goto fail; - } - assert(outputLen == localKeyModulusLen); - - err = noErr; - -fail: - SSLFreeBuffer(hashCtx, ctx); - SSLFreeBuffer(exportKey, ctx); - - return err; -} - static OSStatus SSLEncodeRSAKeyParams(SSLBuffer *keyParams, SSLRSAPrivateKey *key, SSLContext *ctx) { OSStatus err; @@ -197,8 +200,10 @@ SSLEncodeRSAKeyParams(SSLBuffer *keyParams, SSLRSAPrivateKey *key, SSLContext *c return err; } - if ((err = SSLAllocBuffer(*keyParams, modulus.length + exponent.length + 4, ctx)) != 0) + if ((err = SSLAllocBuffer(*keyParams, + modulus.length + exponent.length + 4, ctx)) != 0) { return err; + } charPtr = keyParams->data; charPtr = SSLEncodeInt(charPtr, modulus.length, 2); memcpy(charPtr, modulus.data, modulus.length); @@ -212,196 +217,311 @@ SSLEncodeRSAKeyParams(SSLBuffer *keyParams, SSLRSAPrivateKey *key, SSLContext *c return noErr; } -#if APPLE_DH static OSStatus -SSLEncodeDHanonServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx) -{ OSStatus err; - UInt32 length; - UInt8 *charPtr; - SSLRandomCtx random; - int rsaErr; - -#if RSAREF - length = 6 + ctx->dhAnonParams.primeLen + ctx->dhAnonParams.generatorLen + - ctx->dhExchangePublic.length; - - assert((ctx->negProtocolVersion == SSL_Version_3_0) || - (ctx->negProtocolVersion == TLS_Version_1_0)); - keyExch.protocolVersion = ctx->negProtocolVersion; - keyExch.contentType = SSL_RecordTypeHandshake; - if ((err = SSLAllocBuffer(keyExch.contents, length+4, ctx)) != 0) +SSLEncodeRSAPremasterSecret(SSLContext *ctx) +{ SSLBuffer randData; + OSStatus err; + SSLProtocolVersion maxVersion; + + if ((err = SSLAllocBuffer(ctx->preMasterSecret, + SSL_RSA_PREMASTER_SECRET_SIZE, ctx)) != 0) return err; - charPtr = keyExch.contents.data; - *charPtr++ = SSL_HdskServerKeyExchange; - charPtr = SSLEncodeInt(charPtr, length, 3); - - charPtr = SSLEncodeInt(charPtr, ctx->dhAnonParams.primeLen, 2); - memcpy(charPtr, ctx->dhAnonParams.prime, ctx->dhAnonParams.primeLen); - charPtr += ctx->dhAnonParams.primeLen; - - charPtr = SSLEncodeInt(charPtr, ctx->dhAnonParams.generatorLen, 2); - memcpy(charPtr, ctx->dhAnonParams.generator, ctx->dhAnonParams.generatorLen); - charPtr += ctx->dhAnonParams.generatorLen; - - if ((err = SSLAllocBuffer(ctx->dhExchangePublic, - ctx->peerDHParams.primeLen, ctx)) != 0) - return err; - if ((err = SSLAllocBuffer(ctx->dhPrivate, - ctx->dhExchangePublic.length - 16, ctx)) != 0) + assert((ctx->negProtocolVersion == SSL_Version_3_0) || + (ctx->negProtocolVersion == TLS_Version_1_0)); + sslGetMaxProtVersion(ctx, &maxVersion); + SSLEncodeInt(ctx->preMasterSecret.data, maxVersion, 2); + randData.data = ctx->preMasterSecret.data+2; + randData.length = SSL_RSA_PREMASTER_SECRET_SIZE - 2; + if ((err = sslRand(ctx, &randData)) != 0) return err; + return noErr; +} - if ((err = ReadyRandom(&random, ctx)) != 0) - return err; +/* + * Generate a server key exchange message signed by our RSA or DSA private key. + */ +static OSStatus +SSLEncodeSignedServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx) +{ OSStatus err; + UInt8 *charPtr; + int outputLen; + UInt8 hashes[SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN]; + SSLBuffer exchangeParams,clientRandom,serverRandom,hashCtx, hash; + UInt8 *dataToSign; + UInt32 dataToSignLen; + bool isRsa = true; + UInt32 maxSigLen; + UInt32 actSigLen; + SSLBuffer signature; + + assert(ctx->protocolSide == SSL_ServerSide); + assert(ctx->signingPubKey != NULL); + assert((ctx->negProtocolVersion == SSL_Version_3_0) || + (ctx->negProtocolVersion == TLS_Version_1_0)); + exchangeParams.data = 0; + hashCtx.data = 0; + signature.data = 0; + + /* Set up parameter block to hash ==> exchangeParams */ + switch(ctx->selectedCipherSpec->keyExchangeMethod) { + case SSL_RSA: + case SSL_RSA_EXPORT: + /* + * Parameter block = encryption public key. + * If app hasn't supplied a separate encryption cert, abort. + */ + if(ctx->encryptPubKey == NULL) { + sslErrorLog("RSAServerKeyExchange: no encrypt cert\n"); + return errSSLBadConfiguration; + } + err = SSLEncodeRSAKeyParams(&exchangeParams, + &ctx->encryptPubKey, ctx); + break; + + #if APPLE_DH + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + isRsa = false; + /* and fall through */ + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + { + /* + * Parameter block = {prime, generator, public key} + * Obtain D-H parameters (if we don't have them) and a key pair. + */ + err = SSLGenServerDHParamsAndKey(ctx); + if(err) { + return err; + } + UInt32 len = ctx->dhParamsPrime.length + + ctx->dhParamsGenerator.length + + ctx->dhExchangePublic.length + 6 /* 3 length fields */; + err = SSLAllocBuffer(exchangeParams, len, ctx); + if(err) { + goto fail; + } + err = SSLEncodeDHKeyParams(ctx, exchangeParams.data); + break; + } + #endif /* APPLE_DH */ + default: + /* shouldn't be here */ + assert(0); + return errSSLInternal; + } + if(err) { + goto fail; + } + + /* cook up hash(es) for raw sign */ + clientRandom.data = ctx->clientRandom; + clientRandom.length = SSL_CLIENT_SRVR_RAND_SIZE; + serverRandom.data = ctx->serverRandom; + serverRandom.length = SSL_CLIENT_SRVR_RAND_SIZE; - if ((rsaErr = R_SetupDHAgreement(ctx->dhExchangePublic.data, ctx->dhPrivate.data, - ctx->dhPrivate.length, &ctx->dhAnonParams, &random)) != 0) - { err = SSLUnknownErr; - return err; + if(isRsa) { + /* skip this if signing with DSA */ + dataToSign = hashes; + dataToSignLen = SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN; + hash.data = &hashes[0]; + hash.length = SSL_MD5_DIGEST_LEN; + + if ((err = ReadyHash(SSLHashMD5, hashCtx, ctx)) != 0) + goto fail; + if ((err = SSLHashMD5.update(hashCtx, clientRandom)) != 0) + goto fail; + if ((err = SSLHashMD5.update(hashCtx, serverRandom)) != 0) + goto fail; + if ((err = SSLHashMD5.update(hashCtx, exchangeParams)) != 0) + goto fail; + if ((err = SSLHashMD5.final(hashCtx, hash)) != 0) + goto fail; + if ((err = SSLFreeBuffer(hashCtx, ctx)) != 0) + goto fail; } + else { + /* DSA - just use the SHA1 hash */ + dataToSign = &hashes[SSL_MD5_DIGEST_LEN]; + dataToSignLen = SSL_SHA1_DIGEST_LEN; + } + hash.data = &hashes[SSL_MD5_DIGEST_LEN]; + hash.length = SSL_SHA1_DIGEST_LEN; + if ((err = ReadyHash(SSLHashSHA1, hashCtx, ctx)) != 0) + goto fail; + if ((err = SSLHashSHA1.update(hashCtx, clientRandom)) != 0) + goto fail; + if ((err = SSLHashSHA1.update(hashCtx, serverRandom)) != 0) + goto fail; + if ((err = SSLHashSHA1.update(hashCtx, exchangeParams)) != 0) + goto fail; + if ((err = SSLHashSHA1.final(hashCtx, hash)) != 0) + goto fail; + if ((err = SSLFreeBuffer(hashCtx, ctx)) != 0) + goto fail; - charPtr = SSLEncodeInt(charPtr, ctx->dhExchangePublic.length, 2); - memcpy(charPtr, ctx->dhExchangePublic.data, ctx->dhExchangePublic.length); - charPtr += ctx->dhExchangePublic.length; + /* preallocate a buffer for signing */ + err = sslGetMaxSigSize(ctx->signingPrivKey, maxSigLen); + if(err) { + goto fail; + } + err = SSLAllocBuffer(signature, maxSigLen, ctx); + if(err) { + goto fail; + } + + err = sslRawSign(ctx, + ctx->signingPrivKey, + ctx->signingKeyCsp, + dataToSign, // one or two hashes + dataToSignLen, + signature.data, + maxSigLen, + &actSigLen); + if(err) { + goto fail; + } + assert(actSigLen <= maxSigLen); + + /* package it all up */ + outputLen = exchangeParams.length + 2 + actSigLen; + keyExch.protocolVersion = ctx->negProtocolVersion; + keyExch.contentType = SSL_RecordTypeHandshake; + if ((err = SSLAllocBuffer(keyExch.contents, outputLen+4, ctx)) != 0) + goto fail; -#elif BSAFE - { A_DH_KEY_AGREE_PARAMS *params; - unsigned int outputLen; - - if ((rsaErr = B_GetAlgorithmInfo((POINTER*)¶ms, ctx->dhAnonParams, AI_DHKeyAgree)) != 0) - return SSLUnknownErr; - if ((err = ReadyRandom(&random, ctx)) != 0) - return err; - if ((err = SSLAllocBuffer(ctx->dhExchangePublic, 128, ctx)) != 0) - return err; - if ((rsaErr = B_KeyAgreePhase1(ctx->dhAnonParams, ctx->dhExchangePublic.data, - &outputLen, 128, random, NO_SURR)) != 0) - { err = SSLUnknownErr; - return err; - } - ctx->dhExchangePublic.length = outputLen; - - length = 6 + params->prime.len + params->base.len + ctx->dhExchangePublic.length; - - assert((ctx->negProtocolVersion == SSL_Version_3_0) || - (ctx->negProtocolVersion == TLS_Version_1_0)); - keyExch.protocolVersion = ctx->negProtocolVersion; - keyExch.contentType = SSL_RecordTypeHandshake; - if ((err = SSLAllocBuffer(keyExch.contents, length+4, ctx)) != 0) - return err; - - charPtr = keyExch.contents.data; - *charPtr++ = SSL_HdskServerKeyExchange; - charPtr = SSLEncodeInt(charPtr, length, 3); - - charPtr = SSLEncodeInt(charPtr, params->prime.len, 2); - memcpy(charPtr, params->prime.data, params->prime.len); - charPtr += params->prime.len; - - charPtr = SSLEncodeInt(charPtr, params->base.len, 2); - memcpy(charPtr, params->base.data, params->base.len); - charPtr += params->base.len; - - charPtr = SSLEncodeInt(charPtr, ctx->dhExchangePublic.length, 2); - memcpy(charPtr, ctx->dhExchangePublic.data, ctx->dhExchangePublic.length); - charPtr += ctx->dhExchangePublic.length; - } -#endif /* RSAREF / BSAFE */ - - assert(charPtr == keyExch.contents.data + keyExch.contents.length); + charPtr = keyExch.contents.data; + *charPtr++ = SSL_HdskServerKeyExchange; + charPtr = SSLEncodeInt(charPtr, outputLen, 3); - return noErr; -} - -#endif /* APPLE_DH */ - -OSStatus -SSLProcessServerKeyExchange(SSLBuffer message, SSLContext *ctx) -{ OSStatus err; + memcpy(charPtr, exchangeParams.data, exchangeParams.length); + charPtr += exchangeParams.length; + charPtr = SSLEncodeInt(charPtr, actSigLen, 2); + memcpy(charPtr, signature.data, actSigLen); + assert((charPtr + actSigLen) == + (keyExch.contents.data + keyExch.contents.length)); - switch (ctx->selectedCipherSpec->keyExchangeMethod) - { case SSL_RSA: - case SSL_RSA_EXPORT: - if ((err = SSLProcessRSAServerKeyExchange(message, ctx)) != 0) - return err; - break; - #if APPLE_DH - case SSL_DH_anon: - if ((err = SSLProcessDHanonServerKeyExchange(message, ctx)) != 0) - return err; - break; - #endif - default: - return unimpErr; - } + err = noErr; - return noErr; +fail: + SSLFreeBuffer(hashCtx, ctx); + SSLFreeBuffer(exchangeParams, ctx); + SSLFreeBuffer(signature, ctx); + return err; } +/* + * Decode and verify a server key exchange message signed by server's + * public key. + */ static OSStatus -SSLProcessRSAServerKeyExchange(SSLBuffer message, SSLContext *ctx) +SSLDecodeSignedServerKeyExchange(SSLBuffer message, SSLContext *ctx) { OSStatus err; - SSLBuffer tempPubKey, hashOut, hashCtx, clientRandom, serverRandom; + SSLBuffer hashOut, hashCtx, clientRandom, serverRandom; UInt16 modulusLen, exponentLen, signatureLen; - UInt8 *charPtr, *modulus, *exponent, *signature; - UInt8 hash[36]; + UInt8 *modulus, *exponent, *signature; + UInt8 hashes[SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN]; SSLBuffer signedHashes; - - signedHashes.data = 0; + UInt8 *dataToSign; + UInt32 dataToSignLen; + bool isRsa = true; + + assert(ctx->protocolSide == SSL_ClientSide); + signedHashes.data = 0; hashCtx.data = 0; if (message.length < 2) { - sslErrorLog("SSLProcessRSAServerKeyExchange: msg len error 2\n"); - return errSSLProtocol; - } - charPtr = message.data; - modulusLen = SSLDecodeInt(charPtr, 2); - modulus = charPtr + 2; - charPtr += 2+modulusLen; - if (message.length < (unsigned)(4 + modulusLen)) { - sslErrorLog("SSLProcessRSAServerKeyExchange: msg len error 2\n"); + sslErrorLog("SSLDecodeSignedServerKeyExchange: msg len error 1\n"); return errSSLProtocol; } - exponentLen = SSLDecodeInt(charPtr, 2); - exponent = charPtr + 2; - charPtr += 2+exponentLen; - if (message.length < (unsigned)(6 + modulusLen + exponentLen)) { - sslErrorLog("SSLProcessRSAServerKeyExchange: msg len error 2\n"); - return errSSLProtocol; - } - signatureLen = SSLDecodeInt(charPtr, 2); - signature = charPtr + 2; - if (message.length != (unsigned)(6 + modulusLen + exponentLen + signatureLen)) { - sslErrorLog("SSLProcessRSAServerKeyExchange: msg len error 3\n"); - return errSSLProtocol; - } - + + /* first extract the key-exchange-method-specific parameters */ + UInt8 *charPtr = message.data; + UInt8 *endCp = charPtr + message.length; + switch(ctx->selectedCipherSpec->keyExchangeMethod) { + case SSL_RSA: + case SSL_RSA_EXPORT: + modulusLen = SSLDecodeInt(charPtr, 2); + charPtr += 2; + if((charPtr + modulusLen) > endCp) { + sslErrorLog("signedServerKeyExchange: msg len error 2\n"); + return errSSLProtocol; + } + modulus = charPtr; + charPtr += modulusLen; + + exponentLen = SSLDecodeInt(charPtr, 2); + charPtr += 2; + if((charPtr + exponentLen) > endCp) { + sslErrorLog("signedServerKeyExchange: msg len error 3\n"); + return errSSLProtocol; + } + exponent = charPtr; + charPtr += exponentLen; + break; + #if APPLE_DH + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + isRsa = false; + /* and fall through */ + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + err = SSLDecodeDHKeyParams(ctx, charPtr, message.length); + if(err) { + return err; + } + break; + #endif /* APPLE_DH */ + default: + assert(0); + return errSSLInternal; + } + + /* this is what's hashed */ + SSLBuffer signedParams; + signedParams.data = message.data; + signedParams.length = charPtr - message.data; + + signatureLen = SSLDecodeInt(charPtr, 2); + charPtr += 2; + if((charPtr + signatureLen) != endCp) { + sslErrorLog("signedServerKeyExchange: msg len error 4\n"); + return errSSLProtocol; + } + signature = charPtr; + clientRandom.data = ctx->clientRandom; clientRandom.length = SSL_CLIENT_SRVR_RAND_SIZE; serverRandom.data = ctx->serverRandom; serverRandom.length = SSL_CLIENT_SRVR_RAND_SIZE; - tempPubKey.data = message.data; - tempPubKey.length = modulusLen + exponentLen + 4; - hashOut.data = hash; - - hashOut.length = 16; - if ((err = ReadyHash(SSLHashMD5, hashCtx, ctx)) != 0) - goto fail; - if ((err = SSLHashMD5.update(hashCtx, clientRandom)) != 0) - goto fail; - if ((err = SSLHashMD5.update(hashCtx, serverRandom)) != 0) - goto fail; - if ((err = SSLHashMD5.update(hashCtx, tempPubKey)) != 0) - goto fail; - if ((err = SSLHashMD5.final(hashCtx, hashOut)) != 0) - goto fail; - - /* - * SHA hash goes right after the MD5 hash - */ - hashOut.data = hash + 16; - hashOut.length = 20; + + if(isRsa) { + /* skip this if signing with DSA */ + dataToSign = hashes; + dataToSignLen = SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN; + hashOut.data = hashes; + hashOut.length = SSL_MD5_DIGEST_LEN; + + if ((err = ReadyHash(SSLHashMD5, hashCtx, ctx)) != 0) + goto fail; + if ((err = SSLHashMD5.update(hashCtx, clientRandom)) != 0) + goto fail; + if ((err = SSLHashMD5.update(hashCtx, serverRandom)) != 0) + goto fail; + if ((err = SSLHashMD5.update(hashCtx, signedParams)) != 0) + goto fail; + if ((err = SSLHashMD5.final(hashCtx, hashOut)) != 0) + goto fail; + } + else { + /* DSA - just use the SHA1 hash */ + dataToSign = &hashes[SSL_MD5_DIGEST_LEN]; + dataToSignLen = SSL_SHA1_DIGEST_LEN; + } + hashOut.data = hashes + SSL_MD5_DIGEST_LEN; + hashOut.length = SSL_SHA1_DIGEST_LEN; if ((err = SSLFreeBuffer(hashCtx, ctx)) != 0) goto fail; @@ -411,44 +531,56 @@ SSLProcessRSAServerKeyExchange(SSLBuffer message, SSLContext *ctx) goto fail; if ((err = SSLHashSHA1.update(hashCtx, serverRandom)) != 0) goto fail; - if ((err = SSLHashSHA1.update(hashCtx, tempPubKey)) != 0) + if ((err = SSLHashSHA1.update(hashCtx, signedParams)) != 0) goto fail; if ((err = SSLHashSHA1.final(hashCtx, hashOut)) != 0) goto fail; - err = sslRsaRawVerify(ctx, + err = sslRawVerify(ctx, ctx->peerPubKey, ctx->peerPubKeyCsp, - hash, /* plaintext */ - 36, /* plaintext length */ + dataToSign, /* plaintext */ + dataToSignLen, /* plaintext length */ signature, signatureLen); if(err) { - sslErrorLog("SSLProcessRSAServerKeyExchange: sslRsaRawVerify returned %d\n", - (int)err); + sslErrorLog("SSLDecodeSignedServerKeyExchange: sslRawVerify " + "returned %d\n", (int)err); goto fail; } /* Signature matches; now replace server key with new key */ - { - SSLBuffer modBuf; - SSLBuffer expBuf; - - /* first free existing peerKey */ - sslFreeKey(ctx->peerPubKeyCsp, - &ctx->peerPubKey, - NULL); /* no KCItem */ + switch(ctx->selectedCipherSpec->keyExchangeMethod) { + case SSL_RSA: + case SSL_RSA_EXPORT: + { + SSLBuffer modBuf; + SSLBuffer expBuf; - /* and cook up a new one from raw bits */ - modBuf.data = modulus; - modBuf.length = modulusLen; - expBuf.data = exponent; - expBuf.length = exponentLen; - err = sslGetPubKeyFromBits(ctx, - &modBuf, - &expBuf, - &ctx->peerPubKey, - &ctx->peerPubKeyCsp); + /* first free existing peerKey */ + sslFreeKey(ctx->peerPubKeyCsp, + &ctx->peerPubKey, + NULL); /* no KCItem */ + + /* and cook up a new one from raw bits */ + modBuf.data = modulus; + modBuf.length = modulusLen; + expBuf.data = exponent; + expBuf.length = exponentLen; + err = sslGetPubKeyFromBits(ctx, + &modBuf, + &expBuf, + &ctx->peerPubKey, + &ctx->peerPubKeyCsp); + break; + } + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + break; /* handled above */ + default: + assert(0); /* handled above */ } fail: SSLFreeBuffer(signedHashes, ctx); @@ -456,143 +588,9 @@ fail: return err; } -#if APPLE_DH -static OSStatus -SSLProcessDHanonServerKeyExchange(SSLBuffer message, SSLContext *ctx) -{ OSStatus err; - UInt8 *charPtr; - unsigned int totalLength; - - if (message.length < 6) { - sslErrorLog("SSLProcessDHanonServerKeyExchange error: msg len %d\n", - message.length); - return errSSLProtocol; - } - charPtr = message.data; - totalLength = 0; - -#if RSAREF - { SSLBuffer alloc; - UInt8 *prime, *generator, *publicVal; - - ctx->peerDHParams.primeLen = SSLDecodeInt(charPtr, 2); - charPtr += 2; - prime = charPtr; - charPtr += ctx->peerDHParams.primeLen; - totalLength += ctx->peerDHParams.primeLen; - if (message.length < 6 + totalLength) - return errSSLProtocol; - - ctx->peerDHParams.generatorLen = SSLDecodeInt(charPtr, 2); - charPtr += 2; - generator = charPtr; - charPtr += ctx->peerDHParams.generatorLen; - totalLength += ctx->peerDHParams.generatorLen; - if (message.length < 6 + totalLength) - return errSSLProtocol; - - ctx->dhPeerPublic.length = SSLDecodeInt(charPtr, 2); - charPtr += 2; - publicVal = charPtr; - charPtr += ctx->dhPeerPublic.length; - totalLength += ctx->dhPeerPublic.length; - if (message.length != 6 + totalLength) - return errSSLProtocol; - - assert(charPtr == message.data + message.length); - - if ((err = SSLAllocBuffer(alloc, ctx->peerDHParams.primeLen + - ctx->peerDHParams.generatorLen, ctx)) != 0) - return err; - - ctx->peerDHParams.prime = alloc.data; - memcpy(ctx->peerDHParams.prime, prime, ctx->peerDHParams.primeLen); - ctx->peerDHParams.generator = alloc.data + ctx->peerDHParams.primeLen; - memcpy(ctx->peerDHParams.generator, generator, ctx->peerDHParams.generatorLen); - - if ((err = SSLAllocBuffer(ctx->dhPeerPublic, - ctx->dhPeerPublic.length, ctx)) != 0) - return err; - - memcpy(ctx->dhPeerPublic.data, publicVal, ctx->dhPeerPublic.length); - } -#elif BSAFE - { int rsaErr; - unsigned char *publicVal; - A_DH_KEY_AGREE_PARAMS params; - B_ALGORITHM_METHOD *chooser[] = { &AM_DH_KEY_AGREE, 0 }; - - params.prime.len = SSLDecodeInt(charPtr, 2); - charPtr += 2; - params.prime.data = charPtr; - charPtr += params.prime.len; - totalLength += params.prime.len; - if (message.length < 6 + totalLength) - return errSSLProtocol; - - params.base.len = SSLDecodeInt(charPtr, 2); - charPtr += 2; - params.base.data = charPtr; - charPtr += params.base.len; - totalLength += params.base.len; - if (message.length < 6 + totalLength) - return errSSLProtocol; - - ctx->dhPeerPublic.length = SSLDecodeInt(charPtr, 2); - if ((err = SSLAllocBuffer(ctx->dhPeerPublic, ctx->dhPeerPublic.length, ctx)) != 0) - return err; - - charPtr += 2; - publicVal = charPtr; - charPtr += ctx->dhPeerPublic.length; - totalLength += ctx->dhPeerPublic.length; - memcpy(ctx->dhPeerPublic.data, publicVal, ctx->dhPeerPublic.length); - if (message.length != 6 + totalLength) - return errSSLProtocol; - - params.exponentBits = 8 * ctx->dhPeerPublic.length - 1; - - if ((rsaErr = B_CreateAlgorithmObject(&ctx->peerDHParams)) != 0) - return SSLUnknownErr; - if ((rsaErr = B_SetAlgorithmInfo(ctx->peerDHParams, AI_DHKeyAgree, (POINTER)¶ms)) != 0) - return SSLUnknownErr; - if ((rsaErr = B_KeyAgreeInit(ctx->peerDHParams, (B_KEY_OBJ) 0, chooser, NO_SURR)) != 0) - return SSLUnknownErr; - } -#endif - - return noErr; -} - -#endif - -OSStatus -SSLProcessKeyExchange(SSLBuffer keyExchange, SSLContext *ctx) -{ OSStatus err; - - switch (ctx->selectedCipherSpec->keyExchangeMethod) - { case SSL_RSA: - case SSL_RSA_EXPORT: - if ((err = SSLDecodeRSAKeyExchange(keyExchange, ctx)) != 0) - return err; - break; - #if APPLE_DH - case SSL_DH_anon: - if ((err = SSLDecodeDHanonKeyExchange(keyExchange, ctx)) != 0) - return err; - break; - #endif - default: - return unimpErr; - } - - return noErr; -} - static OSStatus SSLDecodeRSAKeyExchange(SSLBuffer keyExchange, SSLContext *ctx) { OSStatus err; - SSLBuffer result; UInt32 outputLen, localKeyModulusLen; CSSM_KEY_PTR *key; SSLProtocolVersion version; @@ -645,122 +643,78 @@ SSLDecodeRSAKeyExchange(SSLBuffer keyExchange, SSLContext *ctx) (ctx->negProtocolVersion >= TLS_Version_1_0)) { /* TLS only - skip the length bytes */ src = keyExchange.data + 2; - } - else { - sslErrorLog("SSLDecodeRSAKeyExchange: length error (exp %u got %u)\n", - (unsigned)localKeyModulusLen, (unsigned)keyExchange.length); - return errSSLProtocol; - } - err = SSLAllocBuffer(result, localKeyModulusLen, ctx); - if(err != 0) { - return err; - } - - err = sslRsaDecrypt(ctx, - *key, - cspHand, - src, - localKeyModulusLen, - result.data, - 48, - &outputLen); - if(err) { - goto fail; - } - - if (outputLen != 48) - { - sslErrorLog("SSLDecodeRSAKeyExchange: outputLen error\n"); - err = errSSLProtocol; - goto fail; - } - result.length = outputLen; - - version = (SSLProtocolVersion)SSLDecodeInt(result.data, 2); - /* Modify this check to check against our maximum version with - * protocol revisions */ - if (version > ctx->negProtocolVersion && version < SSL_Version_3_0) { - sslErrorLog("SSLDecodeRSAKeyExchange: version error\n"); - err = errSSLProtocol; - goto fail; - } - if ((err = SSLAllocBuffer(ctx->preMasterSecret, - SSL_RSA_PREMASTER_SECRET_SIZE, ctx)) != 0) - goto fail; - memcpy(ctx->preMasterSecret.data, result.data, - SSL_RSA_PREMASTER_SECRET_SIZE); - - err = noErr; -fail: - SSLFreeBuffer(result, ctx); - return err; -} - -#if APPLE_DH -static OSStatus -SSLDecodeDHanonKeyExchange(SSLBuffer keyExchange, SSLContext *ctx) -{ OSStatus err; - unsigned int publicLen; - int rsaResult; - - publicLen = SSLDecodeInt(keyExchange.data, 2); - -#if RSAREF - if (keyExchange.length != publicLen + 2 || - publicLen != ctx->dhAnonParams.primeLen) + } + else { + sslErrorLog("SSLDecodeRSAKeyExchange: length error (exp %u got %u)\n", + (unsigned)localKeyModulusLen, (unsigned)keyExchange.length); return errSSLProtocol; - - if ((err = SSLAllocBuffer(ctx->preMasterSecret, ctx->dhAnonParams.primeLen, ctx)) != 0) - return err; - - if ((rsaResult = R_ComputeDHAgreedKey (ctx->preMasterSecret.data, ctx->dhPeerPublic.data, - ctx->dhPrivate.data, ctx->dhPrivate.length, &ctx->dhAnonParams)) != 0) - { err = SSLUnknownErr; + } + err = SSLAllocBuffer(ctx->preMasterSecret, SSL_RSA_PREMASTER_SECRET_SIZE, ctx); + if(err != 0) { return err; - } - -#elif BSAFE - { unsigned int amount; - if (keyExchange.length != publicLen + 2) - return errSSLProtocol; - - if ((err = SSLAllocBuffer(ctx->preMasterSecret, 128, ctx)) != 0) - return err; - - if ((rsaResult = B_KeyAgreePhase2(ctx->dhAnonParams, ctx->preMasterSecret.data, - &amount, 128, keyExchange.data+2, publicLen, NO_SURR)) != 0) - return err; - - ctx->preMasterSecret.length = amount; - } -#endif - - return noErr; -} -#endif /* APPLE_DH */ + } -OSStatus -SSLEncodeKeyExchange(SSLRecord &keyExchange, SSLContext *ctx) -{ OSStatus err; - - assert(ctx->protocolSide == SSL_ClientSide); + /* + * From this point on, to defend against the Bleichenbacher attack + * and its Klima-Pokorny-Rosa variant, any errors we detect are *not* + * reported to the caller or the peer. If we detect any error during + * decryption (e.g., bad PKCS1 padding) or in the testing of the version + * number in the premaster secret, we proceed by generating a random + * premaster secret, with the correct version number, and tell our caller + * that everything is fine. This session will fail as soon as the + * finished messages are sent, since we will be using a bogus premaster + * secret (and hence bogus session and MAC keys). Meanwhile we have + * not provided any side channel information relating to the cause of + * the failure. + * + * See http://eprint.iacr.org/2003/052/ for more info. + */ + err = sslRsaDecrypt(ctx, + *key, + cspHand, + src, + localKeyModulusLen, // ciphertext len + ctx->preMasterSecret.data, + SSL_RSA_PREMASTER_SECRET_SIZE, // plaintext buf available + &outputLen); - switch (ctx->selectedCipherSpec->keyExchangeMethod) - { case SSL_RSA: - case SSL_RSA_EXPORT: - if ((err = SSLEncodeRSAKeyExchange(keyExchange, ctx)) != 0) - return err; - break; - #if APPLE_DH - case SSL_DH_anon: - if ((err = SSLEncodeDHanonKeyExchange(keyExchange, ctx)) != 0) - return err; - break; - #endif - default: - return unimpErr; + if(err != noErr) { + /* possible Bleichenbacher attack */ + sslLogNegotiateDebug("SSLDecodeRSAKeyExchange: RSA decrypt fail"); + } + else if(outputLen != SSL_RSA_PREMASTER_SECRET_SIZE) { + sslLogNegotiateDebug("SSLDecodeRSAKeyExchange: premaster secret size error"); + err = errSSLProtocol; // not passed back to caller } + if(err == noErr) { + /* + * Two legal values here - the one we actually negotiated (which is + * technically incorrect but not uncommon), and the one the client + * sent as its preferred version in the client hello msg. + */ + version = (SSLProtocolVersion)SSLDecodeInt(ctx->preMasterSecret.data, 2); + if((version != ctx->negProtocolVersion) && + (version != ctx->clientReqProtocol)) { + /* possible Klima-Pokorny-Rosa attack */ + sslLogNegotiateDebug("SSLDecodeRSAKeyExchange: version error"); + err = errSSLProtocol; + } + } + if(err != noErr) { + /* + * Obfuscate failures for defense against Bleichenbacher and + * Klima-Pokorny-Rosa attacks. + */ + SSLEncodeInt(ctx->preMasterSecret.data, ctx->negProtocolVersion, 2); + SSLBuffer tmpBuf; + tmpBuf.data = ctx->preMasterSecret.data + 2; + tmpBuf.length = SSL_RSA_PREMASTER_SECRET_SIZE - 2; + /* must ignore failures here */ + sslRand(ctx, &tmpBuf); + } + + /* in any case, save premaster secret (good or bogus) and proceed */ return noErr; } @@ -772,6 +726,7 @@ SSLEncodeRSAKeyExchange(SSLRecord &keyExchange, SSLContext *ctx) UInt8 *dst; bool encodeLen = false; + assert(ctx->protocolSide == SSL_ClientSide); if ((err = SSLEncodeRSAPremasterSecret(ctx)) != 0) return err; @@ -826,13 +781,312 @@ SSLEncodeRSAKeyExchange(SSLRecord &keyExchange, SSLContext *ctx) return noErr; } -#if APPLE_DH + +#if APPLE_DH + +#pragma mark - +#pragma mark *** Diffie-Hellman key exchange *** + +/* + * Diffie-Hellman setup, server side. On successful return, the + * following SSLContext members are valid: + * + * dhParamsPrime + * dhParamsGenerator + * dhPrivate + * dhExchangePublic + */ +static OSStatus +SSLGenServerDHParamsAndKey( + SSLContext *ctx) +{ + OSStatus ortn; + assert(ctx->protocolSide == SSL_ServerSide); + + /* + * Obtain D-H parameters if we don't have them. + */ + if(ctx->dhParamsPrime.data == NULL) { + assert(ctx->dhParamsGenerator.data == NULL); + const SSLBuffer &pr = serverDhParams().prime(); + ortn = SSLCopyBuffer(pr, ctx->dhParamsPrime); + if(ortn) { + return ortn; + } + const SSLBuffer &gen = serverDhParams().generator(); + ortn = SSLCopyBuffer(gen, ctx->dhParamsGenerator); + if(ortn) { + return ortn; + } + const SSLBuffer &block = serverDhParams().paramBlock(); + ortn = SSLCopyBuffer(block, ctx->dhParamsEncoded); + if(ortn) { + return ortn; + } + } + + /* generate per-session D-H key pair */ + sslFreeKey(ctx->cspHand, &ctx->dhPrivate, NULL); + SSLFreeBuffer(ctx->dhExchangePublic, ctx); + ctx->dhPrivate = (CSSM_KEY *)sslMalloc(sizeof(CSSM_KEY)); + CSSM_KEY pubKey; + ortn = sslDhGenerateKeyPair(ctx, + ctx->dhParamsEncoded, + ctx->dhParamsPrime.length * 8, + &pubKey, ctx->dhPrivate); + if(ortn) { + return ortn; + } + CSSM_TO_SSLBUF(&pubKey.KeyData, &ctx->dhExchangePublic); + return noErr; +} + +/* + * Encode DH params and public key in caller-supplied buffer. + */ +static OSStatus +SSLEncodeDHKeyParams( + SSLContext *ctx, + UInt8 *charPtr) +{ + assert(ctx->protocolSide == SSL_ServerSide); + assert(ctx->dhParamsPrime.data != NULL); + assert(ctx->dhParamsGenerator.data != NULL); + assert(ctx->dhExchangePublic.data != NULL); + + charPtr = SSLEncodeInt(charPtr, ctx->dhParamsPrime.length, 2); + memcpy(charPtr, ctx->dhParamsPrime.data, ctx->dhParamsPrime.length); + charPtr += ctx->dhParamsPrime.length; + + charPtr = SSLEncodeInt(charPtr, ctx->dhParamsGenerator.length, 2); + memcpy(charPtr, ctx->dhParamsGenerator.data, + ctx->dhParamsGenerator.length); + charPtr += ctx->dhParamsGenerator.length; + + charPtr = SSLEncodeInt(charPtr, ctx->dhExchangePublic.length, 2); + memcpy(charPtr, ctx->dhExchangePublic.data, + ctx->dhExchangePublic.length); + + dumpBuf("server prime", ctx->dhParamsPrime); + dumpBuf("server generator", ctx->dhParamsGenerator); + dumpBuf("server pub key", ctx->dhExchangePublic); + return noErr; +} + +/* + * Decode DH params and server public key. + */ +static OSStatus +SSLDecodeDHKeyParams( + SSLContext *ctx, + UInt8 *&charPtr, // IN/OUT + UInt32 length) +{ + OSStatus err = noErr; + + assert(ctx->protocolSide == SSL_ClientSide); + UInt8 *endCp = charPtr + length; + + /* Allow reuse via renegotiation */ + SSLFreeBuffer(ctx->dhParamsPrime, ctx); + SSLFreeBuffer(ctx->dhParamsGenerator, ctx); + SSLFreeBuffer(ctx->dhPeerPublic, ctx); + + /* Prime, with a two-byte length */ + UInt32 len = SSLDecodeInt(charPtr, 2); + charPtr += 2; + if((charPtr + len) > endCp) { + return errSSLProtocol; + } + err = SSLAllocBuffer(ctx->dhParamsPrime, len, ctx); + if(err) { + return err; + } + memmove(ctx->dhParamsPrime.data, charPtr, len); + charPtr += len; + + /* Generator, with a two-byte length */ + len = SSLDecodeInt(charPtr, 2); + charPtr += 2; + if((charPtr + len) > endCp) { + return errSSLProtocol; + } + err = SSLAllocBuffer(ctx->dhParamsGenerator, len, ctx); + if(err) { + return err; + } + memmove(ctx->dhParamsGenerator.data, charPtr, len); + charPtr += len; + + /* peer public key, with a two-byte length */ + len = SSLDecodeInt(charPtr, 2); + charPtr += 2; + err = SSLAllocBuffer(ctx->dhPeerPublic, len, ctx); + if(err) { + return err; + } + memmove(ctx->dhPeerPublic.data, charPtr, len); + charPtr += len; + + dumpBuf("client peer pub", ctx->dhPeerPublic); + dumpBuf("client prime", ctx->dhParamsPrime); + dumpBuf("client generator", ctx->dhParamsGenerator); + + return err; +} + +/* + * Given the server's Diffie-Hellman parameters, generate our + * own DH key pair, and perform key exchange using the server's + * public key and our private key. The result is the premaster + * secret. + * + * SSLContext members valid on entry: + * dhParamsPrime + * dhParamsGenerator + * dhPeerPublic + * + * SSLContext members valid on successful return: + * dhPrivate + * dhExchangePublic + * preMasterSecret + */ +static OSStatus +SSLGenClientDHKeyAndExchange(SSLContext *ctx) +{ + OSStatus ortn; + + assert(ctx->protocolSide == SSL_ClientSide); + if((ctx->dhParamsPrime.data == NULL) || + (ctx->dhParamsGenerator.data == NULL) || + (ctx->dhPeerPublic.data == NULL)) { + sslErrorLog("SSLGenClientDHKeyAndExchange: incomplete server params\n"); + return errSSLProtocol; + } + + /* generate two keys */ + CSSM_KEY pubKey; + ctx->dhPrivate = (CSSM_KEY *)sslMalloc(sizeof(CSSM_KEY)); + ortn = sslDhGenKeyPairClient(ctx, + ctx->dhParamsPrime, ctx->dhParamsGenerator, + &pubKey, ctx->dhPrivate); + if(ortn) { + sslFree(ctx->dhPrivate); + ctx->dhPrivate = NULL; + return ortn; + } + + /* do the exchange, size of prime */ + ortn = sslDhKeyExchange(ctx, ctx->dhParamsPrime.length * 8, + &ctx->preMasterSecret); + if(ortn) { + return ortn; + } + CSSM_TO_SSLBUF(&pubKey.KeyData, &ctx->dhExchangePublic); + return noErr; +} + +static OSStatus +SSLEncodeDHanonServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx) +{ + OSStatus ortn = noErr; + + assert((ctx->negProtocolVersion == SSL_Version_3_0) || + (ctx->negProtocolVersion == TLS_Version_1_0)); + assert(ctx->protocolSide == SSL_ServerSide); + + /* + * Obtain D-H parameters (if we don't have them) and a key pair. + */ + ortn = SSLGenServerDHParamsAndKey(ctx); + if(ortn) { + return ortn; + } + + UInt32 length = 6 + + ctx->dhParamsPrime.length + + ctx->dhParamsGenerator.length + ctx->dhExchangePublic.length; + + keyExch.protocolVersion = ctx->negProtocolVersion; + keyExch.contentType = SSL_RecordTypeHandshake; + if ((ortn = SSLAllocBuffer(keyExch.contents, length+4, ctx)) != 0) + return ortn; + + UInt8 *charPtr = keyExch.contents.data; + *charPtr++ = SSL_HdskServerKeyExchange; + charPtr = SSLEncodeInt(charPtr, length, 3); + + /* encode prime, generator, our public key */ + return SSLEncodeDHKeyParams(ctx, charPtr); +} + + +static OSStatus +SSLDecodeDHanonServerKeyExchange(SSLBuffer message, SSLContext *ctx) +{ + OSStatus err = noErr; + + assert(ctx->protocolSide == SSL_ClientSide); + if (message.length < 6) { + sslErrorLog("SSLDecodeDHanonServerKeyExchange error: msg len %u\n", + (unsigned)message.length); + return errSSLProtocol; + } + UInt8 *charPtr = message.data; + err = SSLDecodeDHKeyParams(ctx, charPtr, message.length); + if(err == noErr) { + if((message.data + message.length) != charPtr) { + err = errSSLProtocol; + } + } + return err; +} + +static OSStatus +SSLDecodeDHClientKeyExchange(SSLBuffer keyExchange, SSLContext *ctx) +{ + OSStatus ortn = noErr; + unsigned int publicLen; + + assert(ctx->protocolSide == SSL_ServerSide); + if(ctx->dhParamsPrime.data == NULL) { + /* should never happen */ + assert(0); + return errSSLInternal; + } + + /* this message simply contains the client's public DH key */ + UInt8 *charPtr = keyExchange.data; + publicLen = SSLDecodeInt(charPtr, 2); + charPtr += 2; + if((keyExchange.length != publicLen + 2) || + (publicLen > ctx->dhParamsPrime.length)) { + return errSSLProtocol; + } + SSLFreeBuffer(ctx->dhPeerPublic, ctx); // allow reuse via renegotiation + ortn = SSLAllocBuffer(ctx->dhPeerPublic, publicLen, ctx); + if(ortn) { + return ortn; + } + memmove(ctx->dhPeerPublic.data, charPtr, publicLen); + + /* DH Key exchange, result --> premaster secret */ + SSLFreeBuffer(ctx->preMasterSecret, ctx); + ortn = sslDhKeyExchange(ctx, ctx->dhParamsPrime.length * 8, + &ctx->preMasterSecret); + + dumpBuf("server peer pub", ctx->dhPeerPublic); + dumpBuf("server premaster", ctx->preMasterSecret); + return ortn; +} + static OSStatus -SSLEncodeDHanonKeyExchange(SSLRecord &keyExchange, SSLContext *ctx) +SSLEncodeDHClientKeyExchange(SSLRecord &keyExchange, SSLContext *ctx) { OSStatus err; unsigned int outputLen; - if ((err = SSLEncodeDHPremasterSecret(ctx)) != 0) + assert(ctx->protocolSide == SSL_ClientSide); + if ((err = SSLGenClientDHKeyAndExchange(ctx)) != 0) return err; outputLen = ctx->dhExchangePublic.length + 2; @@ -846,115 +1100,138 @@ SSLEncodeDHanonKeyExchange(SSLRecord &keyExchange, SSLContext *ctx) return err; keyExchange.contents.data[0] = SSL_HdskClientKeyExchange; - SSLEncodeInt(keyExchange.contents.data+1, ctx->dhExchangePublic.length+2, 3); - - SSLEncodeInt(keyExchange.contents.data+4, ctx->dhExchangePublic.length, 2); - memcpy(keyExchange.contents.data+6, ctx->dhExchangePublic.data, ctx->dhExchangePublic.length); + SSLEncodeInt(keyExchange.contents.data+1, + ctx->dhExchangePublic.length+2, 3); + SSLEncodeInt(keyExchange.contents.data+4, + ctx->dhExchangePublic.length, 2); + memcpy(keyExchange.contents.data+6, ctx->dhExchangePublic.data, + ctx->dhExchangePublic.length); + + dumpBuf("client pub key", ctx->dhExchangePublic); + dumpBuf("client premaster", ctx->preMasterSecret); return noErr; } -#endif +#endif /* APPLE_DH */ + +#pragma mark - +#pragma mark *** Public Functions *** OSStatus -SSLEncodeRSAPremasterSecret(SSLContext *ctx) -{ SSLBuffer randData; - OSStatus err; +SSLEncodeServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx) +{ OSStatus err; - if ((err = SSLAllocBuffer(ctx->preMasterSecret, - SSL_RSA_PREMASTER_SECRET_SIZE, ctx)) != 0) - return err; + switch (ctx->selectedCipherSpec->keyExchangeMethod) + { case SSL_RSA: + case SSL_RSA_EXPORT: + #if APPLE_DH + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + #endif /* APPLE_DH */ + if ((err = SSLEncodeSignedServerKeyExchange(keyExch, ctx)) != 0) + return err; + break; + #if APPLE_DH + case SSL_DH_anon: + case SSL_DH_anon_EXPORT: + if ((err = SSLEncodeDHanonServerKeyExchange(keyExch, ctx)) != 0) + return err; + break; + #endif + default: + return unimpErr; + } - assert((ctx->negProtocolVersion == SSL_Version_3_0) || - (ctx->negProtocolVersion == TLS_Version_1_0)); - SSLEncodeInt(ctx->preMasterSecret.data, ctx->maxProtocolVersion, 2); - randData.data = ctx->preMasterSecret.data+2; - randData.length = SSL_RSA_PREMASTER_SECRET_SIZE - 2; - if ((err = sslRand(ctx, &randData)) != 0) - return err; return noErr; } -#if APPLE_DH - OSStatus -SSLEncodeDHPremasterSecret(SSLContext *ctx) +SSLProcessServerKeyExchange(SSLBuffer message, SSLContext *ctx) { - #if !APPLE_DH - return unimpErr; - #else - - OSStatus err; - int rsaResult; - SSLRandomCtx rsaRandom; - -/* Given the server's Diffie-Hellman parameters, prepare a public & private value, - * then use the public value provided by the server and our private value to - * generate a shared key (the premaster secret). Save our public value in - * ctx->dhExchangePublic to send to the server so it can calculate the matching - * key on its end - */ - if ((err = ReadyRandom(&rsaRandom, ctx)) != 0) - return err; + OSStatus err; -#if RSAREF - { privateValue.data = 0; - - if ((err = SSLAllocBuffer(ctx->dhExchangePublic, ctx->peerDHParams.primeLen, ctx)) != 0) - goto fail; - if ((err = SSLAllocBuffer(privateValue, ctx->dhExchangePublic.length - 16, ctx)) != 0) - goto fail; - - if ((rsaResult = R_SetupDHAgreement(ctx->dhExchangePublic.data, privateValue.data, - privateValue.length, &ctx->peerDHParams, &rsaRandom)) != 0) - { err = SSLUnknownErr; - goto fail; - } - - if ((err = SSLAllocBuffer(ctx->preMasterSecret, ctx->peerDHParams.primeLen, ctx)) != 0) - goto fail; - - if ((rsaResult = R_ComputeDHAgreedKey (ctx->preMasterSecret.data, ctx->dhPeerPublic.data, - privateValue.data, privateValue.length, &ctx->peerDHParams)) != 0) - { err = SSLUnknownErr; - goto fail; - } + switch (ctx->selectedCipherSpec->keyExchangeMethod) { + case SSL_RSA: + case SSL_RSA_EXPORT: + #if APPLE_DH + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + #endif + err = SSLDecodeSignedServerKeyExchange(message, ctx); + break; + #if APPLE_DH + case SSL_DH_anon: + case SSL_DH_anon_EXPORT: + err = SSLDecodeDHanonServerKeyExchange(message, ctx); + break; + #endif + default: + err = unimpErr; + break; } -#elif BSAFE - { unsigned int outputLen; - - if ((err = SSLAllocBuffer(ctx->dhExchangePublic, 128, ctx)) != 0) - goto fail; - if ((rsaResult = B_KeyAgreePhase1(ctx->peerDHParams, ctx->dhExchangePublic.data, - &outputLen, 128, rsaRandom, NO_SURR)) != 0) - { err = SSLUnknownErr; - goto fail; - } - ctx->dhExchangePublic.length = outputLen; - if ((err = SSLAllocBuffer(ctx->preMasterSecret, 128, ctx)) != 0) - goto fail; - if ((rsaResult = B_KeyAgreePhase2(ctx->peerDHParams, ctx->preMasterSecret.data, - &outputLen, 128, ctx->dhPeerPublic.data, ctx->dhPeerPublic.length, - NO_SURR)) != 0) - { err = SSLUnknownErr; - goto fail; - } - ctx->preMasterSecret.length = outputLen; + + return err; +} + +OSStatus +SSLEncodeKeyExchange(SSLRecord &keyExchange, SSLContext *ctx) +{ OSStatus err; + + assert(ctx->protocolSide == SSL_ClientSide); + + switch (ctx->selectedCipherSpec->keyExchangeMethod) { + case SSL_RSA: + case SSL_RSA_EXPORT: + err = SSLEncodeRSAKeyExchange(keyExchange, ctx); + break; + #if APPLE_DH + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + case SSL_DH_anon: + case SSL_DH_anon_EXPORT: + err = SSLEncodeDHClientKeyExchange(keyExchange, ctx); + break; + #endif + default: + err = unimpErr; } - #endif - err = noErr; -fail: -#if RSAREF - SSLFreeBuffer(privateValue, ctx); - R_RandomFinal(&rsaRandom); -#elif BSAFE - B_DestroyAlgorithmObject(&rsaRandom); -#endif return err; - #endif } -#endif /* APPLE_DH */ +OSStatus +SSLProcessKeyExchange(SSLBuffer keyExchange, SSLContext *ctx) +{ OSStatus err; + + switch (ctx->selectedCipherSpec->keyExchangeMethod) + { case SSL_RSA: + case SSL_RSA_EXPORT: + if ((err = SSLDecodeRSAKeyExchange(keyExchange, ctx)) != 0) + return err; + break; + #if APPLE_DH + case SSL_DH_anon: + case SSL_DHE_DSS: + case SSL_DHE_DSS_EXPORT: + case SSL_DHE_RSA: + case SSL_DHE_RSA_EXPORT: + case SSL_DH_anon_EXPORT: + if ((err = SSLDecodeDHClientKeyExchange(keyExchange, ctx)) != 0) + return err; + break; + #endif + default: + return unimpErr; + } + + return noErr; +} OSStatus SSLInitPendingCiphers(SSLContext *ctx) diff --git a/SecureTransport/sslKeychain.cpp b/SecureTransport/sslKeychain.cpp index 9ad65d54..06b3d5aa 100644 --- a/SecureTransport/sslKeychain.cpp +++ b/SecureTransport/sslKeychain.cpp @@ -37,23 +37,7 @@ #include #include #include -#include -/* these are to be replaced by Security/Security.h */ -#include -#include -#include -#include -#include -#include - -#if ST_MANAGES_TRUSTED_ROOTS -static OSStatus -addCertData( - SSLContext *ctx, - KCItemRef kcItem, - CSSM_DATA_PTR certData, - Boolean *goodCert); /* RETURNED */ -#endif /* ST_MANAGES_TRUSTED_ROOTS */ +#include /* * Given an array of certs (as SecIdentityRefs, specified by caller @@ -104,13 +88,7 @@ parseIncomingCerts( SSLCertificate **destCert, /* &ctx->{localCert,encryptCert} */ CSSM_KEY_PTR *pubKey, /* &ctx->signingPubKey, etc. */ CSSM_KEY_PTR *privKey, /* &ctx->signingPrivKey, etc. */ - CSSM_CSP_HANDLE *cspHand /* &ctx->signingKeyCsp, etc. */ - #if ST_KC_KEYS_NEED_REF - , - SecKeychainRef *privKeyRef) /* &ctx->signingKeyRef, etc. */ - #else - ) - #endif /* ST_KC_KEYS_NEED_REF */ + CSSM_CSP_HANDLE *cspHand) /* &ctx->signingKeyCsp, etc. */ { CFIndex numCerts; CFIndex cert; @@ -270,318 +248,4 @@ errOut: return ortn; } -/* - * Add Apple built-in root certs to ctx->trustedCerts. - */ -OSStatus addBuiltInCerts (SSLContextRef ctx) -{ - #if ST_MANAGES_TRUSTED_ROOTS - OSStatus ortn; - KCRef kc = nil; - - ortn = KCDispatch(kKCGetRootCertificateKeychain, &kc); - if(ortn) { - sslErrorLog("KCDispatch(kKCGetRootCertificateKeychain) returned %d\n", - ortn); - return ortn; - } - return parseTrustedKeychain(ctx, kc); - #else - /* nothing for now */ - return noErr; - #endif /* ST_MANAGES_TRUSTED_ROOTS */ -} - -#if ST_MANAGES_TRUSTED_ROOTS - -/* - * Given an open Keychain: - * -- Get raw cert data, add to array of CSSM_DATAs in - * ctx->trustedCerts - * -- verify that each of these is a valid (self-verifying) - * root cert - * -- add each subject name to acceptableDNList - */ -OSStatus -parseTrustedKeychain (SSLContextRef ctx, - KCRef keyChainRef) -{ - CFMutableArrayRef kcCerts = NULL; /* all certs in one keychain */ - uint32 numGoodCerts = 0; /* # of good root certs */ - CSSM_DATA_PTR certData = NULL; /* array of CSSM_DATAs */ - CFIndex certDex; /* index into kcCerts */ - CFIndex certsPerKc; /* # of certs in this KC */ - OSStatus ortn; - KCItemRef kcItem; /* one cert */ - Boolean goodCert; - - assert(ctx != NULL); - if(keyChainRef == NULL) { - return paramErr; - } - - ortn = KCFindX509Certificates(keyChainRef, - NULL, // name, XXX - NULL, // emailAddress, XXX - kCertSearchAny, // options - &kcCerts); // results - switch(ortn) { - case noErr: - break; // proceed - case errKCItemNotFound: - return noErr; // no certs; done - default: - sslErrorLog("parseTrustedKeychains: KCFindX509Certificates returned %d\n", - ortn); - return ortn; - } - if(kcCerts == NULL) { - sslErrorLog("parseTrustedKeychains: no certs in KC\n"); - return noErr; - } - - /* Note kcCerts must be released on any exit, successful or - * otherwise. */ - - certsPerKc = CFArrayGetCount(kcCerts); - - /* - * This array gets allocd locally; we'll add it to - * ctx->trustedCerts when we're done. - */ - certData = sslMalloc(certsPerKc * sizeof(CSSM_DATA)); - if(certData == NULL) { - ortn = memFullErr; - goto errOut; - } - memset(certData, 0, certsPerKc * sizeof(CSSM_DATA)); - - /* - * Build up local certData one root cert at a time. - * Some certs might not pass muster, hence the numGoodCerts - * which may or may not increment each time thru. - */ - for(certDex=0; certDextrustedCerts, add new root certs */ - ctx->trustedCerts = sslRealloc(ctx->trustedCerts, - ctx->numTrustedCerts * sizeof(CSSM_DATA), - (ctx->numTrustedCerts + numGoodCerts) * sizeof(CSSM_DATA)); - if(ctx->trustedCerts == NULL) { - ortn = memFullErr; - goto errOut; - } - for(certDex=0; certDextrustedCerts[ctx->numTrustedCerts + certDex] = certData[certDex]; - } - ctx->numTrustedCerts += numGoodCerts; - ortn = noErr; - - #if SSL_DEBUG - verifyTrustedRoots(ctx, ctx->trustedCerts, ctx->numTrustedCerts); - #endif - -errOut: - sslFree(certData); - if(kcCerts != NULL) { - CFRelease(kcCerts); - } - return ortn; -} - -/* - * Given a (supposedly) root cert as a KCItemRef: - * -- verify that the cert self-verifies - * -- add its DER-encoded data *certData. - * -- Add its subjectName to acceptableDNList. - * -- If all is well, return True in *goodCert. - * - * The actual CSSM_DATA.Data is mallocd via CSSM_Malloc. - */ -static OSStatus -addCertData( - SSLContext *ctx, - KCItemRef kcItem, - CSSM_DATA_PTR certData, - Boolean *goodCert) /* RETURNED */ -{ - UInt32 certSize; - OSStatus ortn; - CSSM_BOOL subjectExpired; - - assert(ctx != NULL); - assert(certData != NULL); - assert(kcItem != NULL); - assert(goodCert != NULL); - - *goodCert = false; - - /* how big is the cert? */ - ortn = KCGetData (kcItem, 0, NULL, &certSize); - if(ortn != noErr) { - sslErrorLog("addCertData: KCGetData(1) returned %d\n", ortn); - return ortn; - } - - /* Allocate the buffer. */ - ortn = stSetUpCssmData(certData, certSize); - if(ortn) { - return ortn; - } - - /* Get the data. */ - ortn = KCGetData (kcItem, certSize, certData->Data, &certSize); - if(ortn) { - sslErrorLog("addCertData: KCGetData(2) returned %d\n", ortn); - stFreeCssmData(certData, CSSM_FALSE); - return ortn; - } - - /* - * Do actual cert verify, which - * KCIsRootCertificate does not do. A failure isn't - * fatal; we just don't add the cert to the array in - * that case. - * - * FIXME - we assume here that our common cspHand can - * do this cert verify; if not, we have some API work to - * do (to let the caller specify which CSP to use with - * trusted certs). - */ - if(!sslVerifyCert(ctx, - certData, - certData, - ctx->cspHand, - &subjectExpired)) { - sslErrorLog("addCertData: cert does not self-verify!\n"); - stFreeCssmData(certData, CSSM_FALSE); - return noErr; - } - - /* FIXME - needs update for MANAGES_TRUSTED_ROOTS */ - /* Add this cert's subject name to (poss. existing) acceptableDNList */ - CSSM_DATA_PTR dnData = sslGetCertSubjectName(ctx, certData); - if(dnData) { - DNListElem *dn = sslMalloc(sizeof(DNListElem)); - if(dn == NULL) { - return memFullErr; - } - dn->next = ctx->acceptableDNList; - ctx->acceptableDNList = dn; - - /* move actual data to dn; free the CSSM_DATA struct (must be - * via CSSM_Free()!) */ - CSSM_TO_SSLBUF(dnData, &dn->derDN); - sslFree(dnData); - } - - *goodCert = true; - return noErr; -} - -/* - * Given a newly encountered root cert (obtained from a peer's cert chain), - * add it to newRootCertKc if the user so allows, and if so, add it to - * trustedCerts. - */ -OSStatus -sslAddNewRoot( - SSLContext *ctx, - const CSSM_DATA_PTR rootCert) -{ - KCRef defaultKc; - Boolean bDefaultKcExists; - KCItemRef certRef = NULL; - OSStatus ortn; - CSSM_DATA_PTR newTrustee; - OSStatus serr; - - assert(ctx != NULL); - assert(rootCert != NULL); - assert(ctx->newRootCertKc != NULL); /* caller verifies this */ - - /* - * Get default KC, temporarily set new default. - */ - ortn = KCGetDefaultKeychain(&defaultKc); - if(ortn) { - bDefaultKcExists = false; - } - else { - bDefaultKcExists = true; - } - ortn = KCSetDefaultKeychain(ctx->newRootCertKc); - if(ortn) { - sslErrorLog("sslAddNewRoot: KCSetDefaultKeychain returned %d\n", ortn); - return errSSLUnknownRootCert; - } - - /* - * Add cert to newRootCertKc. This may well fail due to user - * interaction ("Do you want to add this root cert...?"). - */ - ortn = KCAddX509Certificate(rootCert->Data, rootCert->Length, &certRef); - - /* restore default KC in any case */ - if(bDefaultKcExists) { - KCSetDefaultKeychain(defaultKc); - } - if(ortn) { - sslErrorLog("sslAddNewRoot: KCAddX509Certificate returned %d\n", ortn); - return errSSLUnknownRootCert; - } - - /* - * OK, user accepted new root. Now add to our private stash of - * trusted roots. Realloc the whole pile... - */ - ctx->trustedCerts = (CSSM_DATA_PTR)sslRealloc(ctx->trustedCerts, - (ctx->numTrustedCerts * sizeof(CSSM_DATA)), - ((ctx->numTrustedCerts + 1) * sizeof(CSSM_DATA))); - if(ctx->trustedCerts == NULL) { - return memFullErr; - } - - /* Now add a copy of the new root. */ - newTrustee = &ctx->trustedCerts[ctx->numTrustedCerts]; - newTrustee->Data = NULL; - newTrustee->Length = 0; - serr = stSetUpCssmData(newTrustee, rootCert->Length); - if(serr) { - return serr; - } - BlockMove(rootCert->Data, newTrustee->Data, rootCert->Length); - (ctx->numTrustedCerts)++; - return noErr; -} - -#endif /* ST_MANAGES_TRUSTED_ROOTS */ diff --git a/SecureTransport/sslMemory.cpp b/SecureTransport/sslMemory.cpp index e2ace159..1ffbe4a9 100644 --- a/SecureTransport/sslMemory.cpp +++ b/SecureTransport/sslMemory.cpp @@ -138,14 +138,23 @@ OSStatus SSLAllocCopyBuffer( return serr; } -OSStatus SSLCopyBuffer( - const SSLBuffer &src, +OSStatus SSLCopyBufferFromData( + const void *src, + UInt32 len, SSLBuffer &dst) // data mallocd and returned { - dst.data = sslAllocCopy(src.data, src.length); + dst.data = sslAllocCopy((const UInt8 *)src, len); if(dst.data == NULL) { return memFullErr; } - dst.length = src.length; + dst.length = len; return noErr; } + +OSStatus SSLCopyBuffer( + const SSLBuffer &src, + SSLBuffer &dst) // data mallocd and returned +{ + return SSLCopyBufferFromData(src.data, src.length, dst); +} + diff --git a/SecureTransport/sslRecord.cpp b/SecureTransport/sslRecord.cpp index b9a31be5..9abd8d4f 100644 --- a/SecureTransport/sslRecord.cpp +++ b/SecureTransport/sslRecord.cpp @@ -62,40 +62,43 @@ SSLReadRecord(SSLRecord &rec, SSLContext *ctx) if (!ctx->partialReadBuffer.data || ctx->partialReadBuffer.length < 5) { if (ctx->partialReadBuffer.data) if ((err = SSLFreeBuffer(ctx->partialReadBuffer, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } if ((err = SSLAllocBuffer(ctx->partialReadBuffer, DEFAULT_BUFFER_SIZE, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } - if (ctx->negProtocolVersion == SSL_Version_Undetermined || - ctx->negProtocolVersion == SSL_Version_3_0_With_2_0_Hello) + if (ctx->negProtocolVersion == SSL_Version_Undetermined) { if (ctx->amountRead < 1) { readData.length = 1 - ctx->amountRead; readData.data = ctx->partialReadBuffer.data + ctx->amountRead; len = readData.length; err = sslIoRead(readData, &len, ctx); if(err != 0) - { if (err == errSSLWouldBlock) - ctx->amountRead += len; - else + { if (err == errSSLWouldBlock) { + ctx->amountRead += len; + return err; + } + else { + /* abort */ SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); - return err; + return errSSLClosedAbort; + } } ctx->amountRead += len; } - + } + /* * In undetermined cases, if the first byte isn't in the range of SSL 3.0 * record types, this is an SSL 2.0 record */ switch (ctx->negProtocolVersion) { case SSL_Version_Undetermined: - case SSL_Version_3_0_With_2_0_Hello: if (ctx->partialReadBuffer.data[0] < SSL_RecordTypeV3_Smallest || ctx->partialReadBuffer.data[0] > SSL_RecordTypeV3_Largest) return SSL2ReadRecord(rec, ctx); @@ -124,7 +127,7 @@ SSLReadRecord(SSLRecord &rec, SSLContext *ctx) * the handshake */ if((ctx->amountRead == 0) && /* nothing pending */ (len == 0) && /* nothing new */ - (ctx->state == SSL2_HdskStateClientReady)) { /* handshake done */ + (ctx->state == SSL_HdskStateClientReady)) { /* handshake done */ /* * This means that the server has disconnected without * sending a closure alert notice. This is technically @@ -169,13 +172,13 @@ SSLReadRecord(SSLRecord &rec, SSLContext *ctx) charPtr += 2; if (contentLen > (16384 + 2048)) /* Maximum legal length of an * SSLCipherText payload */ - { SSLFatalSessionAlert(SSL_AlertUnexpectedMsg, ctx); + { SSLFatalSessionAlert(SSL_AlertRecordOverflow, ctx); return errSSLProtocol; } if (ctx->partialReadBuffer.length < 5 + contentLen) { if ((err = SSLReallocBuffer(ctx->partialReadBuffer, 5 + contentLen, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } } @@ -219,7 +222,7 @@ SSLReadRecord(SSLRecord &rec, SSLContext *ctx) /* Allocate a buffer to return the plaintext in and return it */ if ((err = SSLAllocBuffer(rec.contents, cipherFragment.length, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); + { SSLFatalSessionAlert(SSL_AlertInternalError, ctx); return err; } memcpy(rec.contents.data, cipherFragment.data, cipherFragment.length); diff --git a/SecureTransport/sslSession.cpp b/SecureTransport/sslSession.cpp index 69be5370..f6a9e5ab 100644 --- a/SecureTransport/sslSession.cpp +++ b/SecureTransport/sslSession.cpp @@ -190,8 +190,6 @@ SSLInstallSessionFromData(const SSLBuffer sessionData, SSLContext *ctx) uint32 certLen; session = (ResumableSession*)sessionData.data; - - assert(ctx->negProtocolVersion == session->protocolVersion); /* * For SSLv3 and TLSv1, we know that selectedCipher has already been specified in diff --git a/SecureTransport/sslTransport.cpp b/SecureTransport/sslTransport.cpp index ea5ef2e6..91cf61d5 100644 --- a/SecureTransport/sslTransport.cpp +++ b/SecureTransport/sslTransport.cpp @@ -92,8 +92,8 @@ SSLWrite( */ sslIoTrace("SSLWrite", dataLength, 0, badReqErr); return badReqErr; - case SSL2_HdskStateServerReady: - case SSL2_HdskStateClientReady: + case SSL_HdskStateServerReady: + case SSL_HdskStateClientReady: break; } @@ -311,16 +311,6 @@ SSLHandshake(SSLContext *ctx) if (ctx->state == SSL_HdskStateErrorClose) return errSSLClosedAbort; - if(ctx->protocolSide == SSL_ServerSide) { - /* some things the caller really has to have done by now... */ - if((ctx->localCert == NULL) || - (ctx->signingPrivKey == NULL) || - (ctx->signingPubKey == NULL) || - (ctx->signingKeyCsp == 0)) { - sslErrorLog("SSLHandshake: insufficient init\n"); - return badReqErr; - } - } if(ctx->validCipherSpecs == NULL) { /* build list of legal cipherSpecs */ err = sslBuildCipherSpecArray(ctx); @@ -367,7 +357,7 @@ SSLHandshakeProceed(SSLContext *ctx) static OSStatus SSLInitConnection(SSLContext *ctx) -{ OSStatus err; +{ OSStatus err = noErr; if (ctx->protocolSide == SSL_ClientSide) { SSLChangeHdskState(ctx, SSL_HdskStateClientUninit); @@ -383,34 +373,43 @@ SSLInitConnection(SSLContext *ctx) } /* - * If we have a cached resumable session, blow it off if it's a higher - * version than the max currently allowed. Note that this means that once - * a process negotiates a given version with a given server/port, it won't - * be able to negotiate a higher version. We might want to revisit this. + * If we have a cached resumable session, blow it off if it's a version + * which is not currently enabled. */ + Boolean cachedV3OrTls1 = false; + if (ctx->resumableSession.data != 0) { SSLProtocolVersion savedVersion; + Boolean enable; if ((err = SSLRetrieveSessionProtocolVersion(ctx->resumableSession, &savedVersion, ctx)) != 0) { return err; } - if(savedVersion > ctx->maxProtocolVersion) { + switch(savedVersion) { + case SSL_Version_2_0: + enable = ctx->versionSsl2Enable; + break; + case SSL_Version_3_0: + enable = ctx->versionSsl3Enable; + cachedV3OrTls1 = true; // avoid V2 hello + break; + case TLS_Version_1_0: + enable = ctx->versionTls1Enable; + cachedV3OrTls1 = true; + break; + default: + assert(0); + return errSSLInternal; + } + if(!enable) { sslLogResumSessDebug("===Resumable session protocol mismatch"); SSLFreeBuffer(ctx->resumableSession, ctx); + cachedV3OrTls1 = false; } else { sslLogResumSessDebug("===attempting to resume session"); - /* - * A bit of a special case for server side here. If currently - * configged to allow for SSL3/TLS1 with an SSL2 hello, we - * don't want to preclude the possiblity of an SSL2 hello... - * so we'll just leave the negProtocolVersion alone in the server case. - */ - if(ctx->protocolSide == SSL_ClientSide) { - ctx->negProtocolVersion = savedVersion; - } } } @@ -419,28 +418,18 @@ SSLInitConnection(SSLContext *ctx) * pretending we just received a hello request */ if (ctx->state == SSL_HdskStateClientUninit && ctx->writeCipher.ready == 0) - { switch (ctx->negProtocolVersion) - { case SSL_Version_Undetermined: - case SSL_Version_3_0_With_2_0_Hello: - case SSL_Version_2_0: - if ((err = SSL2AdvanceHandshake( - SSL2_MsgKickstart, ctx)) != 0) - return err; - break; - case SSL_Version_3_0_Only: - case SSL_Version_3_0: - case TLS_Version_1_0_Only: - case TLS_Version_1_0: - if ((err = SSLAdvanceHandshake(SSL_HdskHelloRequest, ctx)) != 0) - return err; - break; - default: - sslErrorLog("Bad protocol version\n"); - return errSSLInternal; - } + { + assert(ctx->negProtocolVersion == SSL_Version_Undetermined); + if(ctx->versionSsl2Enable && !cachedV3OrTls1) { + /* SSL2 client hello with possible upgrade */ + err = SSL2AdvanceHandshake(SSL2_MsgKickstart, ctx); + } + else { + err = SSLAdvanceHandshake(SSL_HdskHelloRequest, ctx); + } } - return noErr; + return err; } static OSStatus @@ -468,7 +457,6 @@ SSLServiceWriteQueue(SSLContext *ctx) } if (err) return err; - assert(ctx->recordWriteQueue == 0 || ctx->recordWriteQueue->sent == 0); } return werr; diff --git a/SecureTransport/sslUtils.cpp b/SecureTransport/sslUtils.cpp index 45c93d0a..191d9fce 100644 --- a/SecureTransport/sslUtils.cpp +++ b/SecureTransport/sslUtils.cpp @@ -17,7 +17,7 @@ /* - File: sslutil.c + File: sslutils.ccpp Contains: Misc. SSL utility functions @@ -120,12 +120,9 @@ const char *protocolVersStr(SSLProtocolVersion prot) { switch(prot) { case SSL_Version_Undetermined: return "SSL_Version_Undetermined"; - case SSL_Version_3_0_With_2_0_Hello: return "SSL_Version_3_0_With_2_0_Hello"; - case SSL_Version_3_0_Only: return "SSL_Version_3_0_Only"; case SSL_Version_2_0: return "SSL_Version_2_0"; case SSL_Version_3_0: return "SSL_Version_3_0"; case TLS_Version_1_0: return "TLS_Version_1_0"; - case TLS_Version_1_0_Only: return "TLS_Version_1_0_Only"; default: sslErrorLog("protocolVersStr: bad prot\n"); return "BAD PROTOCOL"; } return NULL; /* NOT REACHED */ @@ -201,3 +198,104 @@ OSStatus sslRand(SSLContext *ctx, SSLBuffer *buf) return serr; } +/* + * Given a protocol version sent by peer, determine if we accept that version + * and downgrade if appropriate (which can not be done for the client side). + */ +OSStatus sslVerifyProtVersion( + SSLContext *ctx, + SSLProtocolVersion peerVersion, // sent by peer + SSLProtocolVersion *negVersion) // final negotiated version if return success +{ + OSStatus ortn = noErr; + + switch(peerVersion) { + case SSL_Version_2_0: + if(ctx->versionSsl2Enable) { + *negVersion = SSL_Version_2_0; + } + else { + /* SSL2 is the best peer can do but we don't support it */ + ortn = errSSLNegotiation; + } + break; + case SSL_Version_3_0: + if(ctx->versionSsl3Enable) { + *negVersion = SSL_Version_3_0; + } + /* downgrade if possible */ + else if(ctx->protocolSide == SSL_ClientSide) { + /* client side - no more negotiation possible */ + ortn = errSSLNegotiation; + } + else if(ctx->versionSsl2Enable) { + /* server downgrading to SSL2 */ + *negVersion = SSL_Version_2_0; + } + else { + /* Peer requested SSL3, we don't support SSL2 or SSL3 */ + ortn = errSSLNegotiation; + } + break; + case TLS_Version_1_0: + if(ctx->versionTls1Enable) { + *negVersion = TLS_Version_1_0; + } + /* downgrade if possible */ + else if(ctx->protocolSide == SSL_ClientSide) { + /* + * Client side - no more negotiation possible + * Note this actually implies a pretty serious server + * side violation; it's sending back a protocol version + * HIGHER than we requested + */ + ortn = errSSLNegotiation; + } + else if(ctx->versionSsl3Enable) { + /* server downgrading to SSL3 */ + *negVersion = SSL_Version_3_0; + } + else if(ctx->versionSsl2Enable) { + /* server downgrading to SSL2 */ + *negVersion = SSL_Version_2_0; + } + else { + /* we appear not to support any protocol */ + sslErrorLog("sslVerifyProtVersion: no protocols supported\n"); + ortn = errSSLNegotiation; + } + break; + default: + ortn = errSSLNegotiation; + break; + + } + return ortn; +} + +/* + * Determine max enabled protocol, i.e., the one we try to negotiate for. + * Only returns an error (paramErr) if NO protocols are enabled, which can + * in fact happen by malicious or ignorant use of SSLSetProtocolVersionEnabled(). + */ +OSStatus sslGetMaxProtVersion( + SSLContext *ctx, + SSLProtocolVersion *version) // RETURNED +{ + OSStatus ortn = noErr; + if(ctx->versionTls1Enable) { + *version = TLS_Version_1_0; + } + else if(ctx->versionSsl3Enable) { + *version = SSL_Version_3_0; + } + else if(ctx->versionSsl2Enable) { + *version = SSL_Version_2_0; + } + else { + ortn = paramErr; + } + return ortn; +} + + \ No newline at end of file diff --git a/SecureTransport/tls1Callouts.cpp b/SecureTransport/tls1Callouts.cpp index a1c4c305..e27ffe1b 100644 --- a/SecureTransport/tls1Callouts.cpp +++ b/SecureTransport/tls1Callouts.cpp @@ -275,8 +275,8 @@ static OSStatus tls1DecryptRecord( if ((ctx->readCipher.symCipher->blockSize > 0) && ((payload->length % ctx->readCipher.symCipher->blockSize) != 0)) { - SSLFatalSessionAlert(SSL_AlertUnexpectedMsg, ctx); - return errSSLProtocol; + SSLFatalSessionAlert(SSL_AlertRecordOverflow, ctx); + return errSSLRecordOverflow; } /* Decrypt in place */ @@ -284,8 +284,8 @@ static OSStatus tls1DecryptRecord( *payload, &ctx->readCipher, ctx)) != 0) - { SSLFatalSessionAlert(SSL_AlertCloseNotify, ctx); - return err; + { SSLFatalSessionAlert(SSL_AlertDecryptError, ctx); + return errSSLDecryptionFail; } /* Locate content within decrypted payload */ @@ -300,17 +300,17 @@ static OSStatus tls1DecryptRecord( * has a special case here dealing with some kind of bug related to * even size packets...beware... */ if(padSize > payload->length) { - SSLFatalSessionAlert(SSL_AlertUnexpectedMsg, ctx); + SSLFatalSessionAlert(SSL_AlertDecodeError, ctx); sslErrorLog("tls1DecryptRecord: bad padding length (%d)\n", (unsigned)payload->data[payload->length - 1]); - return errSSLProtocol; + return errSSLDecryptionFail; } padChars = payload->data + payload->length - padSize; while(padChars < (payload->data + payload->length)) { if(*padChars++ != padSize) { - SSLFatalSessionAlert(SSL_AlertUnexpectedMsg, ctx); + SSLFatalSessionAlert(SSL_AlertDecodeError, ctx); sslErrorLog("tls1DecryptRecord: bad padding value\n"); - return errSSLProtocol; + return errSSLDecryptionFail; } } /* Remove block size padding and its one-byte length */ @@ -323,7 +323,7 @@ static OSStatus tls1DecryptRecord( if ((err = SSLVerifyMac(type, content, payload->data + content.length, ctx)) != 0) { SSLFatalSessionAlert(SSL_AlertBadRecordMac, ctx); - return err; + return errSSLBadRecordMac; } *payload = content; /* Modify payload buffer to indicate content length */ diff --git a/SecureTransport/tls_hmac.cpp b/SecureTransport/tls_hmac.cpp index 636dcf9c..d18b9883 100644 --- a/SecureTransport/tls_hmac.cpp +++ b/SecureTransport/tls_hmac.cpp @@ -95,6 +95,7 @@ static OSStatus HMAC_Alloc( &cssmKey, &href->ccHand); if(crtn) { + stPrintCdsaError("CSSM_CSP_CreateMacContext", crtn); return errSSLCrypto; } @@ -132,6 +133,7 @@ static OSStatus HMAC_Init( crtn = CSSM_GenerateMacInit(hmacCtx->ccHand); if(crtn) { + stPrintCdsaError("CSSM_GenerateMacInit", crtn); return errSSLCrypto; } return noErr; @@ -156,6 +158,7 @@ static OSStatus HMAC_Update( cdata.Length = dataLen; crtn = CSSM_GenerateMacUpdate(hmacCtx->ccHand, &cdata, 1); if(crtn) { + stPrintCdsaError("CSSM_GenerateMacUpdate", crtn); return errSSLCrypto; } return noErr; @@ -182,6 +185,7 @@ static OSStatus HMAC_Final( cdata.Length = *hmacLen; crtn = CSSM_GenerateMacFinal(hmacCtx->ccHand, &cdata); if(crtn) { + stPrintCdsaError("CSSM_GenerateMacFinal", crtn); return errSSLCrypto; } *hmacLen = cdata.Length; diff --git a/Security.exp b/Security.exp index 52e01cbd..6eb9eee7 100644 --- a/Security.exp +++ b/Security.exp @@ -6,6 +6,11 @@ _gGuidAppleFileDL _gGuidAppleX509CL _gGuidAppleX509TP _cssmPerror +_cssmOidToAlg +_cssmAlgToOid +_security_ktrace +___security_debug +___security_debugging _MDS_Initialize _MDS_Terminate _MDS_Install @@ -16,8 +21,11 @@ _SSLGetSessionState _SSLSetIOFuncs _SSLSetProtocolVersion _SSLGetProtocolVersion +_SSLSetProtocolVersionEnabled +_SSLGetProtocolVersionEnabled _SSLSetCertificate _SSLSetConnection +_SSLGetConnection _SSLGetNegotiatedProtocolVersion _SSLGetNumberSupportedCiphers _SSLGetSupportedCiphers @@ -31,6 +39,7 @@ _SSLGetAllowsExpiredRoots _SSLSetEnableCertVerify _SSLGetEnableCertVerify _SSLGetPeerCertificates +_SSLGetPeerSecTrust _SSLSetTrustedRoots _SSLGetTrustedRoots _SSLSetPeerID @@ -49,6 +58,8 @@ _SSLSetAllowsAnyRoot _SSLGetAllowsAnyRoot _SSLAddDistinguishedName _SSLSetClientSideAuthenticate +_SSLSetRsaBlinding +_SSLGetRsaBlinding _SessionGetInfo _SessionCreate _checkpw @@ -58,4 +69,11 @@ _SSLInternalServerRandom _SSLInternalClientRandom _SSLInternal_PRF _SSLGetClientCertificateState -_SecKeyImportPair \ No newline at end of file +_SSLSetDiffieHellmanParams +_SSLGetDiffieHellmanParams +_SSLGetResumableSessionInfo +_NSS_DSAPublicKeyX509Template +_SecKeyImportPair +___authorization_bind +_SecCopyErrorMessageString + diff --git a/Security.order b/Security.order new file mode 100644 index 00000000..954965d7 --- /dev/null +++ b/Security.order @@ -0,0 +1,6655 @@ +Security:single module:__mh_dylib_header +Security:single module:_ucsp_client_setup +Security:single module:__Z27__MIG_check__Reply__setup_tP16__Reply__setup_t +Security:single module:__ZN8Security14SecurityServer13ClientSession6GlobalC4Ev +Security:single module:__ZN8Security12MachPlusPlus5Error5checkEi +Security:single module:__ZN8Security12MachPlusPlus4Port13requestNotifyEjij +Security:single module:__ZNSs4_Rep10_M_destroyERKSaIcE +Security:single module:__ZN8Security17ModuleNexusCommon6createEPFPvvE +Security:single module:__ZN8Security5Mutex6unlockEv +Security:single module:__ZN8Security5MutexD1Ev +Security:single module:__ZN8Security5MutexD4Ev +Security:single module:__ZdlPv +Security:single module:__ZN8Security14SecurityServer13ClientSession8activateEv +Security:single module:__ZN8Security14SecurityServer13ClientSession14getSessionInfoERmS2_ +Security:single module:_ucsp_client_getSessionInfo +Security:single module:__ZN8Security12MachPlusPlus10MachServer15runServerThreadEb +Security:single module:__ZN8Security5Mutex4lockEv +Security:single module:__Z36__MIG_check__Reply__getSessionInfo_tP25__Reply__getSessionInfo_t +Security:single module:_SessionGetInfo +Security:single module:__ZN8Security12MachPlusPlus10MachServer12processTimerEv +Security:single module:__ZN8Security4Time3nowEv +Security:single module:_ucsp_client_authorizationCreate +Security:single module:__Z41__MIG_check__Reply__authorizationCreate_tP30__Reply__authorizationCreate_t +Security:single module:__ZN8Security14SecurityServer13ClientSession10authCreateEPK20AuthorizationItemSetS4_mRNS0_17AuthorizationBlobE +Security:single module:__ZN20DefaultCssmAllocator4freeEPv +Security:single module:_AuthorizationCreate +Security:single module:__ZN20DefaultCssmAllocator6mallocEm +Security:single module:_AuthorizationMakeExternalForm +Security:single module:__ZN8Security14SecurityServer13ClientSession15authExternalizeERKNS0_17AuthorizationBlobER25AuthorizationExternalForm +Security:single module:_ucsp_client_authorizationExternalize +Security:single module:__Z46__MIG_check__Reply__authorizationExternalize_tP35__Reply__authorizationExternalize_t +Security:single module:_ucsp_client_authorizationInternalize +Security:single module:__Z46__MIG_check__Reply__authorizationInternalize_tP35__Reply__authorizationInternalize_t +Security:single module:__ZN8Security14SecurityServer13ClientSession15authInternalizeERK25AuthorizationExternalFormRNS0_17AuthorizationBlobE +Security:single module:_AuthorizationCreateFromExternalForm +Security:single module:_SessionCreate +Security:single module:__ZN8Security14SecurityServer13ClientSession12setupSessionEmm +Security:single module:_cdsa_notify_server +Security:single module:__Xmach_notify_dead_name +Security:single module:_cdsa_mach_notify_dead_name +Security:single module:__ZN8Security12MachPlusPlus10MachServer26releaseDeferredAllocationsEv +Security:single module:__ZN8Security15ThreadStoreSlotD2Ev +Security:single module:__ZN8Security15ThreadStoreSlotD4Ev +Security:single module:__ZN8Security11CodeSigning13GenericBundleD2Ev +Security:single module:__ZN8Security11CodeSigning13GenericBundleD4Ev +Security:single module:__Znwm +Security:single module:__ZN8Security5MutexC1Eb +Security:single module:__ZN8Security5MutexC4Eb +Security:single module:__ZN8Security14SecurityServer13ClientSession6GlobalC1Ev +Security:single module:__ZN8Security15ThreadStoreSlotC2EPFvPvE +Security:single module:__ZN8Security15ThreadStoreSlotC4EPFvPvE +Security:single module:__ZNK8Security12MachPlusPlus9Bootstrap6lookupEPKc +Security:single module:__ZN8Security12MachPlusPlus11ReceivePortC2EPKcRKNS0_9BootstrapE +Security:single module:__ZN8Security12MachPlusPlus11ReceivePortC4EPKcRKNS0_9BootstrapE +Security:single module:__ZNK8Security12MachPlusPlus9Bootstrap15checkInOptionalEPKc +Security:single module:_ucsp_client_setupNew +Security:single module:__Z30__MIG_check__Reply__setupNew_tP19__Reply__setupNew_t +Security:single module:_ucsp_client_setupSession +Security:single module:__Z34__MIG_check__Reply__setupSession_tP23__Reply__setupSession_t +Security:single module:_ucsp_client_setupThread +Security:single module:__ZNK8Security12MachPlusPlus10MachServer12notifyIfDeadENS0_4PortEb +Security:single module:__Z33__MIG_check__Reply__setupThread_tP22__Reply__setupThread_t +Security:single module:__ZN8Security18DevRandomGenerator6randomEPvm +Security:single module:__ZN8Security12UnixPlusPlus8FileDesc4readEPvm +Security:single module:_AuthorizationCopyRights +Security:single module:__ZN8Security14SecurityServer13ClientSession14authCopyRightsERKNS0_17AuthorizationBlobEPK20AuthorizationItemSetS7_mPPS5_ +Security:single module:_ucsp_client_authorizationCopyRights +Security:single module:__ZNK10__cxxabiv120__si_class_type_info12__do_dyncastEiNS_17__class_type_info10__sub_kindEPKS1_PKvS4_S6_RNS1_16__dyncast_resultE +Security:single module:__ZNKSt9type_infoeqERKS_ +Security:single module:__ZN8Security10CssmClient7ContextC2ERKNS0_3CSPEm +Security:single module:__ZN8Security10CssmClient7ContextC4ERKNS0_3CSPEm +Security:single module:__ZN8Security10CssmClient10ObjectImplC2ERKNS0_6ObjectE +Security:single module:__ZN8Security10CssmClient10ObjectImplC4ERKNS0_6ObjectE +Security:single module:__ZN8Security10CssmClient10ObjectImpl8addChildEv +Security:single module:__ZN8Security10CssmClient6Digest6digestEPKNS_8CssmDataEmRS2_ +Security:single module:__ZN8Security10CssmClient6Digest8activateEv +Security:single module:___dynamic_cast +Security:single module:__ZN8Security10CssmClient14AttachmentImpl8activateEv +Security:single module:_CSSM_CSP_CreateDigestContext +Security:single module:__ZN8Security12HandleObject5State6locateEml +Security:single module:__ZN8Security5Mutex7tryLockEv +Security:single module:__ZN8Security13CountingMutex11finishEnterEv +Security:single module:__ZN8Security7Context7Builder4makeEv +Security:single module:__ZN8Security28CssmMemoryFunctionsAllocator6mallocEm +Security:single module:__ZN8Security28CssmAllocatorMemoryFunctions11relayMallocEmPv +Security:single module:__ZN13HandleContext5MakerclEmm +Security:single module:__ZN8Security12HandleObject5State4makeEPS0_ +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE8allocateEm +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE5_LockC4Ev +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE5_LockD4Ev +Security:single module:__ZN8Security7ContextC2Emm +Security:single module:__ZN8Security7ContextC4Emm +Security:single module:__ZN8Security7Context7Builder4doneERP22cssm_context_attributeRm +Security:single module:__ZN13HandleContext14validateChangeEm +Security:single module:__Z16cssm_EventNotifymmyPK12cssm_context +Security:single module:__ZNK10__cxxabiv121__vmi_class_type_info12__do_dyncastEiNS_17__class_type_info10__sub_kindEPKS1_PKvS4_S6_RNS1_16__dyncast_resultE +Security:single module:__ZN8Security16CSPPluginSession11EventNotifyEmyRKNS_7ContextE +Security:single module:__ZN15AppleCSPSession13contextCreateEyRKN8Security7ContextE +Security:single module:__ZN8Security13CountingMutex4exitEv +Security:single module:__ZN8Security28CssmMemoryFunctionsAllocator4freeEPv +Security:single module:__ZN8Security28CssmAllocatorMemoryFunctions9relayFreeEPvS1_ +Security:single module:__ZN8Security10CssmClient10ObjectImpl5checkEl +Security:single module:_CSSM_DigestData +Security:single module:__ZN13HandleContext7tryLockEv +Security:single module:__ZN8Security13CountingMutex8tryEnterEv +Security:single module:__Z15cssm_DigestDatamyPK12cssm_contextPK9cssm_datamPS2_ +Security:single module:__ZThn40_N8Security20CSPFullPluginSession10DigestDataEyRKNS_7ContextEPKNS_8CssmDataEmRS4_ +Security:single module:__ZN8Security20CSPFullPluginSession10DigestDataEyRKNS_7ContextEPKNS_8CssmDataEmRS4_ +Security:single module:__ZN8Security20CSPFullPluginSession14DigestDataInitEyRKNS_7ContextE +Security:single module:__ZN8Security20CSPFullPluginSession4initEymRKNS_7ContextEb +Security:single module:__ZN8Security20CSPFullPluginSession14checkOperationEmm +Security:single module:__ZN15AppleCSPSession12setupContextERPN8Security20CSPFullPluginSession10CSPContextERKNS0_7ContextEb +Security:single module:__ZN15RSA_DSA_Factory5setupER15AppleCSPSessionRPN8Security20CSPFullPluginSession10CSPContextERKNS2_7ContextE +Security:single module:__ZN14MiscAlgFactory5setupER15AppleCSPSessionRPN8Security20CSPFullPluginSession10CSPContextERKNS2_7ContextE +Security:single module:__ZN13DigestContext4initERKN8Security7ContextEb +Security:single module:__ZN10SHA1Object10digestInitEv +Security:single module:_shsInit +Security:single module:__ZN8Security20CSPFullPluginSession16DigestDataUpdateEyPKNS_8CssmDataEm +Security:single module:__ZN8Security20CSPFullPluginSession16getStagedContextEymb +Security:single module:__ZN13DigestContext6updateERKN8Security8CssmDataE +Security:single module:__ZN10SHA1Object12digestUpdateEPKvm +Security:single module:__ZN8Security20CSPFullPluginSession15DigestDataFinalEyRNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext5finalERNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN13DigestContext10outputSizeEbm +Security:single module:__ZNK10SHA1Object17digestSizeInBytesEv +Security:single module:__ZN13DigestContext5finalERN8Security8CssmDataE +Security:single module:__ZN10SHA1Object11digestFinalEPv +Security:single module:_shsUpdate +Security:single module:_shsFinal +Security:single module:_shsTransform +Security:single module:__ZN8Security10CssmClient7ContextD2Ev +Security:single module:__ZN8Security10CssmClient7ContextD4Ev +Security:single module:__ZN8Security10CssmClient7Context10deactivateEv +Security:single module:_CSSM_DeleteContext +Security:single module:__ZN8Security16CSPPluginSession13contextDeleteEyRKNS_7ContextEPNS0_13PluginContextE +Security:single module:__ZN15AppleCSPContextD2Ev +Security:single module:__ZN15AppleCSPContextD4Ev +Security:single module:__ZN8Security16CSPPluginSession13PluginContextD2Ev +Security:single module:__ZN8Security16CSPPluginSession13PluginContextD4Ev +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE10deallocateEPvm +Security:single module:__ZN13HandleContextD1Ev +Security:single module:__ZN13HandleContextD4Ev +Security:single module:__ZN8Security12HandleObjectD2Ev +Security:single module:__ZN8Security12HandleObjectD4Ev +Security:single module:__ZN8Security12HandleObject5State5eraseEPS0_ +Security:single module:__ZN8Security10CssmClient10ObjectImplD2Ev +Security:single module:__ZN8Security10CssmClient10ObjectImplD4Ev +Security:single module:__ZN8Security10CssmClient10ObjectImpl11removeChildEv +Security:single module:__ZN8Security13CssmAllocator8standardEm +Security:single module:__ZN8Security12MachPlusPlus10MachServer16longTermActivityEv +Security:single module:__ZNK8Security12MachPlusPlus9Bootstrap14lookupOptionalEPKc +Security:single module:__ZN8Security12MachPlusPlus11StBootstrapC1ERKNS0_9BootstrapERKNS0_8TaskPortE +Security:single module:__ZN8Security12MachPlusPlus11StBootstrapC4ERKNS0_9BootstrapERKNS0_8TaskPortE +Security:single module:__ZN8Security14SecurityServer13ClientSessionC2ERNS_13CssmAllocatorES3_ +Security:single module:__ZN8Security14SecurityServer13ClientSessionC4ERNS_13CssmAllocatorES3_ +Security:single module:__ZN8Security11CodeSigning7OSXCode4mainEv +Security:single module:__ZN8Security11CodeSigning7OSXCode7getPathEPK7__CFURL +Security:single module:__ZNSsC1EPKcRKSaIcE +Security:single module:__ZNSsC4EPKcRKSaIcE +Security:single module:__ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag +Security:single module:__ZNSs4_Rep9_S_createEmRKSaIcE +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE9_S_refillEm +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE14_S_chunk_allocEmRi +Security:single module:__ZNSs12_Alloc_hiderC4EPcRKSaIcE +Security:single module:__ZNK8Security11CodeSigning14ExecutableTool6encodeEv +Security:single module:__ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_ +Security:single module:__ZNSsC4Ev +Security:single module:__ZNSs7reserveEm +Security:single module:__ZNKSs13get_allocatorEv +Security:single module:__ZNSs4_Rep8_M_cloneERKSaIcEm +Security:single module:__ZNKSs7_M_iendEv +Security:single module:__ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_PKcS4_ +Security:single module:__ZNKSs9_M_ibeginEv +Security:single module:__ZNSs7replaceEmmPKcm +Security:single module:__ZNSs15_M_replace_safeIPKcEERSsN9__gnu_cxx17__normal_iteratorIPcSsEES6_T_S7_ +Security:single module:__ZNSs9_M_mutateEmmm +Security:single module:__ZNSs6appendERKSs +Security:single module:__ZNSs15_M_replace_safeIN9__gnu_cxx17__normal_iteratorIPcSsEEEERSsS3_S3_T_S5_ +Security:single module:__ZNSs13_S_copy_charsEPcN9__gnu_cxx17__normal_iteratorIS_SsEES2_ +Security:single module:__ZNSs6assignERKSs +Security:single module:__ZNSs4_Rep7_M_grabERKSaIcES2_ +Security:single module:__ZNK8Security12MachPlusPlus8TaskPort3pidEv +Security:single module:__ZN8Security11CodeSigning7OSXCode6decodeEPKc +Security:single module:_security_ktrace +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerC2EPKcRKNS0_9BootstrapE +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerC4EPKcRKNS0_9BootstrapE +Security:single module:__ZN8Security12MachPlusPlus10MachServerC2EPKcRKNS0_9BootstrapE +Security:single module:__ZN8Security12MachPlusPlus10MachServerC4EPKcRKNS0_9BootstrapE +Security:single module:__ZN8Security12MachPlusPlus11ReceivePortC1EPKcRKNS0_9BootstrapE +Security:single module:__ZN8Security11CodeSigning13GenericBundleC2EPKc +Security:single module:__ZN8Security11CodeSigning13GenericBundleC4EPKc +Security:single module:__ZNK8Security11CodeSigning13GenericBundle6encodeEv +Security:single module:__ZN8Security11CodeSigning13GenericBundleC1EPKc +Security:single module:__ZN8Security5Debug5debugEPKcS2_z +Security:single module:__ZN8Security5Debug6Target3getEv +Security:single module:__ZN8Security5Debug6Target7messageEPKcS3_Pc +Security:single module:__ZNK8Security5Debug6Target8SelectorclEPKc +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServer3runEmi +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServer10cfCallbackEP12__CFMachPortPvlS4_ +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServer10oneRequestEP17mach_msg_header_t +Security:single module:__ZN8Security5Debug12makeTypeNameERKSt9type_info +Security:single module:___cxa_demangle +Security:single module:___cxa_dyn_string_init +Security:single module:_cp_demangle_type +Security:single module:_demangling_new +Security:single module:___cxa_dyn_string_new +Security:single module:_result_push +Security:single module:_string_list_new +Security:single module:_demangle_type +Security:single module:_substitution_start +Security:single module:_current_template_arg_list +Security:single module:_demangle_type_ptr +Security:single module:_demangle_class_enum_type +Security:single module:_demangle_name +Security:single module:_demangle_unqualified_name +Security:single module:_demangle_source_name +Security:single module:_demangle_number +Security:single module:_demangle_number_literally +Security:single module:___cxa_dyn_string_append_char +Security:single module:___cxa_dyn_string_resize +Security:single module:___cxa_dyn_string_delete +Security:single module:_demangle_identifier +Security:single module:___cxa_dyn_string_clear +Security:single module:___cxa_dyn_string_insert +Security:single module:_substitution_add +Security:single module:___cxa_dyn_string_substring +Security:single module:_pop_to_template_arg_list +Security:single module:___cxa_dyn_string_insert_char +Security:single module:_result_pop +Security:single module:___cxa_dyn_string_copy +Security:single module:_demangling_delete +Security:single module:_string_list_delete +Security:single module:__ZNK8Security12MachPlusPlus17MachRunLoopServer12notifyIfDeadENS0_4PortE +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServer16blockNewRequestsEb +Security:single module:_demangle_builtin_type +Security:single module:___cxa_dyn_string_insert_cstr +Security:single module:__ZN8Security12MachPlusPlus10MachServer15releaseWhenDoneERNS_13CssmAllocatorEPv +Security:single module:__ZN8Security12MachPlusPlus10deallocateEjm +Security:single module:_checkpw_internal +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServer20cfInvalidateCallbackEP12__CFMachPortPv +Security:single module:_AuthorizationFree +Security:single module:__ZN8Security14SecurityServer13ClientSession11authReleaseERKNS0_17AuthorizationBlobEm +Security:single module:_ucsp_client_authorizationRelease +Security:single module:__Z42__MIG_check__Reply__authorizationRelease_tP31__Reply__authorizationRelease_t +Security:single module:__Z45__MIG_check__Reply__authorizationCopyRights_tP34__Reply__authorizationCopyRights_t +Security:single module:_AuthorizationCopyInfo +Security:single module:__ZN8Security14SecurityServer13ClientSession12authCopyInfoERKNS0_17AuthorizationBlobEPKcRP20AuthorizationItemSet +Security:single module:_ucsp_client_authorizationCopyInfo +Security:single module:__Z43__MIG_check__Reply__authorizationCopyInfo_tP32__Reply__authorizationCopyInfo_t +Security:single module:__Xmach_notify_no_senders +Security:single module:_cdsa_mach_notify_no_senders +Security:single module:__Xmach_notify_port_deleted +Security:single module:_cdsa_mach_notify_port_deleted +Security:single module:__ZN8Security12MachPlusPlus10MachServer17notifyPortDeletedENS0_4PortE +Security:single module:__ZN8Security10CssmClient7CSPImplC1ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient7CSPImplC4ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient14AttachmentImplC2ERKNS_4GuidEm +Security:single module:__ZN8Security10CssmClient14AttachmentImplC4ERKNS_4GuidEm +Security:single module:__ZN8Security10CssmClient8CssmImpl8standardEv +Security:single module:__ZN8Security5MutexC2Eb +Security:single module:__ZN8Security10CssmClient8CssmImpl12StandardCssm3getEv +Security:single module:__ZN8Security10CssmClient8CssmImplC1Eb +Security:single module:__ZN8Security10CssmClient8CssmImplC4Eb +Security:single module:__ZN8Security10CssmClient10ObjectImplC2Ev +Security:single module:__ZN8Security10CssmClient10ObjectImplC4Ev +Security:single module:__ZN8Security10CssmClient8CssmImpl5setupEv +Security:single module:__ZN8Security10CssmClient8CssmImpl10autoModuleERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient10ModuleImplC1ERKNS_4GuidERKNS0_4CssmE +Security:single module:__ZN8Security10CssmClient10ModuleImplC4ERKNS_4GuidERKNS0_4CssmE +Security:single module:__ZN8Security10CssmClient14AttachmentImpl4makeEm +Security:single module:_SecKeychainFindGenericPassword +Security:single module:__ZN8Security12KeychainCore7GlobalsC1Ev +Security:single module:__ZN8Security12KeychainCore7GlobalsC4Ev +Security:single module:__ZN8Security12KeychainCore14StorageManagerC1Ev +Security:single module:__ZN8Security12KeychainCore14StorageManagerC4Ev +Security:single module:__ZN8Security14DLDbListCFPrefC1E20SecPreferencesDomain +Security:single module:__ZN8Security14DLDbListCFPrefC4E20SecPreferencesDomain +Security:single module:__ZN8Security14DLDbListCFPref16loadPropertyListEb +Security:single module:__ZN8Security14DLDbListCFPref18ExpandTildesInPathERKSs +Security:single module:__ZNKSs4findEPKcmm +Security:single module:__ZN8Security14DLDbListCFPref9getPwInfoENS0_10PwInfoTypeE +Security:single module:__ZN8Security16PasswordDBLookupC1Ev +Security:single module:__ZN8Security16PasswordDBLookupC4Ev +Security:single module:__ZN8Security16PasswordDBLookup15lookupInfoOnUIDEj +Security:single module:__ZNSs6assignEPKcm +Security:single module:__ZNSsC1ERKSsmm +Security:single module:__ZNSsC4ERKSsmm +Security:single module:__ZNKSs8_M_checkEm +Security:single module:__ZNKSs7_M_foldEmm +Security:single module:__ZNSs12_S_constructIN9__gnu_cxx17__normal_iteratorIPcSsEEEES2_T_S4_RKSaIcESt20forward_iterator_tag +Security:single module:__ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_ERKS6_S8_ +Security:single module:__ZNSsC1ERKSs +Security:single module:__ZNSsC4ERKSs +Security:single module:__ZN8Security10CssmClient10AclFactoryC1Ev +Security:single module:__ZN8Security10CssmClient10AclFactoryC4Ev +Security:single module:__ZN8Security12KeychainCore14StorageManager18optionalSearchListEPKvRSt6vectorINS0_8KeychainESaIS5_EE +Security:single module:__ZN8Security12KeychainCore14StorageManager13getSearchListERSt6vectorINS0_8KeychainESaIS3_EE +Security:single module:__ZN8Security14DLDbListCFPref6revertEb +Security:single module:__ZN8Security14DLDbListCFPref10searchListEv +Security:single module:__ZN8Security14DLDbListCFPref31cfDictionaryRefToDLDbIdentifierEPK14__CFDictionary +Security:single module:__ZN8Security4GuidC1EPKc +Security:single module:__ZN8Security4GuidC4EPKc +Security:single module:__ZN8Security17CssmSubserviceUidC1ERK9cssm_guidPK12cssm_versionmm +Security:single module:__ZN8Security17CssmSubserviceUidC4ERK9cssm_guidPK12cssm_versionmm +Security:single module:__ZN8Security6DbNameC1EPKcPK16cssm_net_address +Security:single module:__ZN8Security6DbNameC4EPKcPK16cssm_net_address +Security:single module:__ZN8Security14DLDbListCFPref21defaultDLDbIdentifierEv +Security:single module:__ZN8Security14DLDbListCFPref19loginDLDbIdentifierEv +Security:single module:__ZN8Security14DLDbListCFPref25JaguarLoginDLDbIdentifierEv +Security:single module:__ZN8Security12KeychainCore14StorageManager9_keychainERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security10CssmClient10ModuleImplC1ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient10ModuleImplC4ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplC1ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplC4ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient9CSPDLImplC2ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient9CSPDLImplC4ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient7CSPImplC2ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient7CSPImplC4ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient14AttachmentImplC2ERKNS0_6ModuleEm +Security:single module:__ZN8Security10CssmClient14AttachmentImplC4ERKNS0_6ModuleEm +Security:single module:__ZN8Security10CssmClient6DLImplC2ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient6DLImplC4ERKNS0_6ModuleE +Security:single module:__ZThn64_N8Security10CssmClient9CSPDLImpl12subserviceIdEm +Security:single module:__ZN8Security10CssmClient9CSPDLImpl12subserviceIdEm +Security:single module:__ZN8Security10CssmClient14AttachmentImpl12subserviceIdEm +Security:single module:__ZThn128_N8Security10CssmClient11SSCSPDLImpl5newDbEPKcPK16cssm_net_address +Security:single module:__ZN8Security10CssmClient11SSCSPDLImpl5newDbEPKcPK16cssm_net_address +Security:single module:__ZN8Security10CssmClient8SSDbImplC1ERKNS0_7SSCSPDLEPKcPK16cssm_net_address +Security:single module:__ZN8Security10CssmClient8SSDbImplC4ERKNS0_7SSCSPDLEPKcPK16cssm_net_address +Security:single module:__ZN8Security10CssmClient6DbImplC2ERKNS0_2DLEPKcPK16cssm_net_address +Security:single module:__ZN8Security10CssmClient6DbImplC4ERKNS0_2DLEPKcPK16cssm_net_address +Security:single module:__ZN8Security12KeychainCore6gTypesEv +Security:single module:__ZN8Security12KeychainCore10SecCFTypesC1Ev +Security:single module:__ZN8Security12KeychainCore10SecCFTypesC4Ev +Security:single module:__ZN8Security12KeychainCore7CFClassC1EPKc +Security:single module:__ZN8Security12KeychainCore7CFClassC4EPKc +Security:single module:__ZN8Security12KeychainCore11SecCFObject8allocateEmm +Security:single module:__ZN8Security12KeychainCore12KeychainImplC1ERKNS_10CssmClient2DbE +Security:single module:__ZN8Security12KeychainCore12KeychainImplC4ERKNS_10CssmClient2DbE +Security:single module:__ZNK8Security17CssmSubserviceUidltERK19cssm_subservice_uid +Security:single module:__ZNK8Security17CssmSubserviceUideqERK19cssm_subservice_uid +Security:single module:__ZNKSs7compareERKSs +Security:single module:__ZN8Security12KeychainCore12KCCursorImplC1ERKSt6vectorINS0_8KeychainESaIS3_EEmPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore12KCCursorImplC4ERKSt6vectorINS0_8KeychainESaIS3_EEmPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore6Schema13recordTypeForEm +Security:single module:__ZN8Security12KeychainCore6Schema13attributeInfoEm +Security:single module:__ZN8Security13CssmAutoQuery3addEmRK22cssm_db_attribute_infoRKNS_12CssmPolyDataE +Security:single module:__ZN20DefaultCssmAllocator7reallocEPvm +Security:single module:__ZN8Security12KeychainCore4ItemC1Ev +Security:single module:__ZN8Security12KeychainCore4ItemC4Ev +Security:single module:__ZN8Security12KeychainCore12KCCursorImpl4nextERNS0_4ItemE +Security:single module:__ZN8Security10CssmClient12DbAttributesC1Ev +Security:single module:__ZN8Security10CssmClient12DbAttributesC4Ev +Security:single module:__ZThn20_N8Security10CssmClient8SSDbImpl11newDbCursorERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient8SSDbImpl11newDbCursorERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14SSDbCursorImplC1ERKNS0_2DbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14SSDbCursorImplC4ERKNS0_2DbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplC2ERKNS0_2DbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplC4ERKNS0_2DbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient12DbCursorImplC2ERKNS0_6ObjectERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient12DbCursorImplC4ERKNS0_6ObjectERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security13CssmAutoQueryC2ERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security13CssmAutoQueryC4ERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14SSDbCursorImpl4nextEPNS0_12DbAttributesEPNS_17CssmDataContainerERNS0_14DbUniqueRecordE +Security:single module:__ZN8Security10CssmClient14SSDbCursorImpl4nextEPNS0_12DbAttributesEPNS_17CssmDataContainerERNS0_14DbUniqueRecordEPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient14DbDbCursorImpl4nextEPNS0_12DbAttributesEPNS_17CssmDataContainerERNS0_14DbUniqueRecordE +Security:single module:__ZThn24_N8Security10CssmClient8SSDbImpl17newDbUniqueRecordEv +Security:single module:__ZN8Security10CssmClient8SSDbImpl17newDbUniqueRecordEv +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImplC1ERKNS0_2DbE +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImplC4ERKNS0_2DbE +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImplC2ERKNS0_2DbE +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImplC4ERKNS0_2DbE +Security:single module:__ZN8Security10CssmClient6DbImpl8activateEv +Security:single module:__ZN8Security10CssmClient8SSDbImpl4openEv +Security:single module:__ZN8Security10CssmClient6DbImpl4openEv +Security:single module:__ZNK8Security10CssmClient14AttachmentImpl6moduleEv +Security:single module:__ZN8Security10CssmClient10ModuleImpl8activateEv +Security:single module:__ZNK8Security10CssmClient10ModuleImpl7sessionEv +Security:single module:__ZN8Security10CssmClient8CssmImpl8activateEv +Security:single module:_CSSM_Init +Security:single module:__ZN11CssmManagerC1Ev +Security:single module:__ZN11CssmManagerC4Ev +Security:single module:__ZN12MdsComponentC2ERKN8Security4GuidE +Security:single module:__ZN12MdsComponentC4ERKN8Security4GuidE +Security:single module:__ZN17AttachmentFactoryC2Ev +Security:single module:__ZN17AttachmentFactoryC4Ev +Security:single module:__ZN8Security12ModuleLoaderC1Ev +Security:single module:__ZN8Security12ModuleLoaderC4Ev +Security:single module:__ZN14AppleCSPPluginC1Ev +Security:single module:__ZN14AppleCSPPluginC4Ev +Security:single module:__ZN8Security10CssmPluginC2Ev +Security:single module:__ZN8Security10CssmPluginC4Ev +Security:single module:__ZN15CryptKitFactoryC1EPN8Security13CssmAllocatorES2_ +Security:single module:__ZN15CryptKitFactoryC4EPN8Security13CssmAllocatorES2_ +Security:single module:_initCryptKit +Security:single module:_fallocRegister +Security:single module:__ZN13AscAlgFactoryC1EPN8Security13CssmAllocatorES2_ +Security:single module:__ZN13AscAlgFactoryC4EPN8Security13CssmAllocatorES2_ +Security:single module:_comMallocRegister +Security:single module:__ZN15RSA_DSA_FactoryC1EPN8Security13CssmAllocatorES2_ +Security:single module:__ZN15RSA_DSA_FactoryC4EPN8Security13CssmAllocatorES2_ +Security:single module:_CRYPTO_set_mem_functions +Security:single module:_CRYPTO_set_locked_mem_functions +Security:single module:_ERR_load_RSA_strings +Security:single module:_ERR_load_BN_strings +Security:single module:_ERR_load_DSA_strings +Security:single module:__ZN10DH_FactoryC1EPN8Security13CssmAllocatorES2_ +Security:single module:__ZN10DH_FactoryC4EPN8Security13CssmAllocatorES2_ +Security:single module:_ERR_load_DH_strings +Security:single module:__ZN11AppleFileDLC1Ev +Security:single module:__ZN11AppleFileDLC4Ev +Security:single module:__ZN8Security20AppleDatabaseManagerC1EPKNS_22AppleDatabaseTableNameE +Security:single module:__ZN8Security20AppleDatabaseManagerC4EPKNS_22AppleDatabaseTableNameE +Security:single module:__ZN8Security15DatabaseManagerC2Ev +Security:single module:__ZN8Security15DatabaseManagerC4Ev +Security:single module:__ZN11CSPDLPluginC1Ev +Security:single module:__ZN11CSPDLPluginC4Ev +Security:single module:__ZN14SSCSPDLSessionC1Ev +Security:single module:__ZN14SSCSPDLSessionC4Ev +Security:single module:__ZN8Security7KeyPoolC2Ev +Security:single module:__ZN8Security7KeyPoolC4Ev +Security:single module:__ZN11AppleX509CLC1Ev +Security:single module:__ZN11AppleX509CLC4Ev +Security:single module:__ZN7AppleTPC1Ev +Security:single module:__ZN7AppleTPC4Ev +Security:single module:__ZN11CssmManager10initializeERK12cssm_versionmRKN8Security4GuidEmRm +Security:single module:__ZN11CssmManager12checkVersionERK12cssm_version +Security:single module:_CSSM_ModuleLoad +Security:single module:__ZN11CssmManager10loadModuleERKN8Security4GuidEmRKNS0_14ModuleCallbackE +Security:single module:__ZN12MdsComponentC1ERKN8Security4GuidE +Security:single module:__ZNK12MdsComponent7getInfoEv +Security:single module:__ZN12MdsComponent3MDSC1Ev +Security:single module:__ZN12MdsComponent3MDSC4Ev +Security:single module:__ZN8Security12ModuleLoaderclEPKc +Security:single module:__ZN6ModuleC1EP11CssmManagerRK12MdsComponentPN8Security6PluginE +Security:single module:__ZN6ModuleC4EP11CssmManagerRK12MdsComponentPN8Security6PluginE +Security:single module:__ZN8Security10CssmPlugin10moduleLoadERKNS_4GuidES3_RKNS_14ModuleCallbackE +Security:single module:__ZN8Security10CssmPlugin4loadEv +Security:single module:__ZN12MdsComponentD1Ev +Security:single module:__ZN12MdsComponentD4Ev +Security:single module:__ZN8Security17ModuleCallbackSet6insertERKNS_14ModuleCallbackE +Security:single module:__ZN8Security10CssmClient8CssmImpl9catchExitEv +Security:single module:__ZThn64_NK8Security10CssmClient9CSPDLImpl9allocatorEv +Security:single module:__ZNK8Security10CssmClient9CSPDLImpl9allocatorEv +Security:single module:__ZNK8Security10CssmClient10ObjectImpl9allocatorEv +Security:single module:__ZN8Security28CssmAllocatorMemoryFunctionsC1ERNS_13CssmAllocatorE +Security:single module:__ZN8Security28CssmAllocatorMemoryFunctionsC4ERNS_13CssmAllocatorE +Security:single module:_CSSM_ModuleAttach +Security:single module:__ZN11CssmManager9getModuleERKN8Security4GuidE +Security:single module:__ZN6Module6attachERK12cssm_versionmmRK17cssm_memory_funcsmmP19cssm_func_name_addrm +Security:single module:__ZNK17AttachmentFactory18attachmentMakerForEm +Security:single module:__ZN10AttachmentC2EP6ModuleRK12cssm_versionmmRK17cssm_memory_funcsmm +Security:single module:__ZN10AttachmentC4EP6ModuleRK12cssm_versionmmRK17cssm_memory_funcsmm +Security:single module:__ZN8Security12HandleObject5StateC1Ev +Security:single module:__ZN8Security12HandleObject5StateC4Ev +Security:single module:__ZN8Security10CssmPlugin12moduleAttachEmRKNS_4GuidES3_S3_S3_RK12cssm_versionmmmmRK12cssm_upcallsRP17cssm_module_funcs +Security:single module:__ZN11CSPDLPlugin11makeSessionEmRK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN11SSDLSessionC1EmR11CSPDLPluginRK12cssm_versionmmmRK12cssm_upcallsRN8Security15DatabaseManagerER14SSCSPDLSession +Security:single module:__ZN11SSDLSessionC4EmR11CSPDLPluginRK12cssm_versionmmmRK12cssm_upcallsRN8Security15DatabaseManagerER14SSCSPDLSession +Security:single module:__ZN8Security15DLPluginSessionC2EmRNS_10CssmPluginERK12cssm_versionmmmRK12cssm_upcallsRNS_15DatabaseManagerE +Security:single module:__ZN8Security15DLPluginSessionC4EmRNS_10CssmPluginERK12cssm_versionmmmRK12cssm_upcallsRNS_15DatabaseManagerE +Security:single module:__ZN8Security13PluginSessionC2EmRNS_10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN8Security13PluginSessionC4EmRNS_10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN8Security15DatabaseSessionC2ERNS_15DatabaseManagerE +Security:single module:__ZN8Security15DatabaseSessionC4ERNS_15DatabaseManagerE +Security:single module:__ZN8Security10CssmClient6DLImplC1ERKNS0_6ModuleE +Security:single module:__ZN8Security14SecurityServer13ClientSessionC1ERNS_13CssmAllocatorES3_ +Security:single module:__ZN8Security10CssmClient10ObjectImpl9allocatorERNS_13CssmAllocatorE +Security:single module:__ZN8Security15DLPluginSession9constructEv +Security:single module:_CSSM_DL_DbOpen +Security:single module:__Z11cssm_DbOpenmPKcPK16cssm_net_addressmPK23cssm_access_credentialsPKvPm +Security:single module:__ZThn40_N11SSDLSession6DbOpenEPKcPK16cssm_net_addressmPKN8Security17AccessCredentialsEPKvRm +Security:single module:__ZN11SSDLSession6DbOpenEPKcPK16cssm_net_addressmPKN8Security17AccessCredentialsEPKvRm +Security:single module:__ZN14SSDatabaseImplC1ERN8Security14SecurityServer13ClientSessionERKNS0_10CssmClient2DLEPKcPK16cssm_net_address +Security:single module:__ZN14SSDatabaseImplC4ERN8Security14SecurityServer13ClientSessionERKNS0_10CssmClient2DLEPKcPK16cssm_net_address +Security:single module:__ZN14SSDatabaseImpl4openERKN8Security14DLDbIdentifierE +Security:single module:__ZN11AppleFileDL11makeSessionEmRK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN8Security15DLPluginSessionC1EmRNS_10CssmPluginERK12cssm_versionmmmRK12cssm_upcallsRNS_15DatabaseManagerE +Security:single module:__ZN8Security15DatabaseSession6DbOpenEPKcPK16cssm_net_addressmPKNS_17AccessCredentialsEPKvRm +Security:single module:__ZN8Security15DatabaseManager6dbOpenERNS_15DatabaseSessionERKNS_6DbNameEmPKNS_17AccessCredentialsEPKv +Security:single module:__ZN8Security15DatabaseManager3getERKNS_6DbNameE +Security:single module:__ZN8Security20AppleDatabaseManager4makeERKNS_6DbNameE +Security:single module:__ZN8Security13AppleDatabaseC1ERKNS_6DbNameEPKNS_22AppleDatabaseTableNameE +Security:single module:__ZN8Security13AppleDatabaseC4ERKNS_6DbNameEPKNS_22AppleDatabaseTableNameE +Security:single module:__ZN8Security8DatabaseC2ERKNS_6DbNameE +Security:single module:__ZN8Security8DatabaseC4ERKNS_6DbNameE +Security:single module:__ZN8Security6DbNameC1ERKS0_ +Security:single module:__ZN8Security6DbNameC4ERKS0_ +Security:single module:__ZN8Security10AtomicFileC1ERKSs +Security:single module:__ZN8Security10AtomicFileC4ERKSs +Security:single module:__ZN8Security10AtomicFile9pathSplitERKSsRSsS3_ +Security:single module:__ZNKSs5rfindEcm +Security:single module:__ZN8Security10DbModifierC1ERNS_10AtomicFileERKNS_13AppleDatabaseE +Security:single module:__ZN8Security10DbModifierC4ERNS_10AtomicFileERKNS_13AppleDatabaseE +Security:single module:__ZN8Security6DbNameD1Ev +Security:single module:__ZN8Security6DbNameD4Ev +Security:single module:__ZN8Security8Database7_dbOpenERNS_15DatabaseSessionEmPKNS_17AccessCredentialsEPKv +Security:single module:__ZN8Security13AppleDatabase13makeDbContextERNS_15DatabaseSessionEmPKNS_17AccessCredentialsEPKv +Security:single module:__ZN8Security14AppleDbContextC1ERNS_8DatabaseERNS_15DatabaseSessionEmPKNS_17AccessCredentialsEPKv +Security:single module:__ZN8Security14AppleDbContextC4ERNS_8DatabaseERNS_15DatabaseSessionEmPKNS_17AccessCredentialsEPKv +Security:single module:__ZN8Security9DbContextC2ERNS_8DatabaseERNS_15DatabaseSessionEmPK23cssm_access_credentials +Security:single module:__ZN8Security9DbContextC4ERNS_8DatabaseERNS_15DatabaseSessionEmPK23cssm_access_credentials +Security:single module:__ZN8Security13AppleDatabase6dbOpenERNS_9DbContextE +Security:single module:__ZN8Security10DbModifier12openDatabaseEv +Security:single module:__ZN8Security10DbModifier6commitEv +Security:single module:__ZN8Security10DbModifier12getDbVersionEv +Security:single module:__ZN8Security10AtomicFile4readEv +Security:single module:__ZN8Security18AtomicBufferedFileC1ERKSs +Security:single module:__ZN8Security18AtomicBufferedFileC4ERKSs +Security:single module:__ZN8Security18AtomicBufferedFile4openEv +Security:single module:__ZN8Security10AtomicFile5ropenEPKcit +Security:single module:__ZN8Security9DbVersionC1ERKNS_13AppleDatabaseERKNS_10RefPointerINS_18AtomicBufferedFileEEE +Security:single module:__ZN8Security9DbVersionC4ERKNS_13AppleDatabaseERKNS_10RefPointerINS_18AtomicBufferedFileEEE +Security:single module:__ZN8Security18AtomicBufferedFile4readExxRx +Security:single module:__ZN8Security18AtomicBufferedFile5closeEv +Security:single module:__ZN8Security10AtomicFile6rcloseEi +Security:single module:__ZN8Security9DbVersion4openEv +Security:single module:__ZN8Security5TableC1ERKNS_11ReadSectionE +Security:single module:__ZN8Security5TableC4ERKNS_11ReadSectionE +Security:single module:__ZN8Security10MetaRecordC1Em +Security:single module:__ZN8Security10MetaRecordC4Em +Security:single module:__ZN8Security9DbVersion9findTableEm +Security:single module:__ZN8Security10MetaRecord22setRecordAttributeInfoERK29cssm_db_record_attribute_info +Security:single module:__ZN8Security10MetaRecord15createAttributeEPKSsPKNS_8CssmDataEmm +Security:single module:__ZN8Security13MetaAttribute6createEmmm +Security:single module:__ZNK8Security5Table17getRecordsSectionEv +Security:single module:__ZNK8Security10MetaRecord12unpackRecordERKNS_11ReadSectionERNS_13CssmAllocatorEP29cssm_db_record_attribute_dataPNS_8CssmDataEm +Security:single module:__ZNK8Security10MetaRecord13metaAttributeERK22cssm_db_attribute_info +Security:single module:__ZNK8Security10MetaRecord14attributeIndexERK22cssm_db_attribute_info +Security:single module:__ZNK8Security13MetaAttribute15unpackAttributeERKNS_11ReadSectionERNS_13CssmAllocatorERmRP9cssm_data +Security:single module:__ZNK8Security13MetaAttribute20unpackNumberOfValuesERKNS_11ReadSectionERmS4_ +Security:single module:__ZN8Security11UInt32ValueC1ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11UInt32ValueC4ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11UInt32ValueD1Ev +Security:single module:__ZN8Security11UInt32ValueD4Ev +Security:single module:__ZN8Security7DbValueD2Ev +Security:single module:__ZN8Security7DbValueD4Ev +Security:single module:__ZN8Security11StringValueC1ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11StringValueC4ERKNS_11ReadSectionERm +Security:single module:__ZN8Security9BlobValueC2ERKNS_11ReadSectionERm +Security:single module:__ZN8Security9BlobValueC4ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11StringValueD1Ev +Security:single module:__ZN8Security11StringValueD4Ev +Security:single module:__ZN8Security9BlobValueD2Ev +Security:single module:__ZN8Security9BlobValueD4Ev +Security:single module:__ZN8Security17TrackingAllocatorD1Ev +Security:single module:__ZN8Security17TrackingAllocatorD4Ev +Security:single module:__ZN8Security13CssmAllocatorD2Ev +Security:single module:__ZN8Security13CssmAllocatorD4Ev +Security:single module:__ZNSsC1EPKcmRKSaIcE +Security:single module:__ZNSsC4EPKcmRKSaIcE +Security:single module:__ZN8Security5Table16readIndexSectionEv +Security:single module:__ZN8Security12DbConstIndexC1ERKNS_5TableERKNS_11ReadSectionE +Security:single module:__ZN8Security12DbConstIndexC4ERKNS_5TableERKNS_11ReadSectionE +Security:single module:__ZN8Security7DbIndexC2ERKNS_10MetaRecordEmb +Security:single module:__ZN8Security7DbIndexC4ERKNS_10MetaRecordEmb +Security:single module:__ZN8Security7DbIndex15appendAttributeEm +Security:single module:__ZN8Security15DatabaseSession15insertDbContextERNS_9DbContextE +Security:single module:__ZN14SSDatabaseImpl11getDbBlobIdEPN8Security17CssmDataContainerE +Security:single module:__ZThn20_N8Security10CssmClient6DbImpl11newDbCursorEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient6DbImpl11newDbCursorEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplC1ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplC4ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient12DbCursorImplC2ERKNS0_6ObjectEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient12DbCursorImplC4ERKNS0_6ObjectEmRNS_13CssmAllocatorE +Security:single module:__ZThn24_N14SSDatabaseImpl17newDbUniqueRecordEv +Security:single module:__ZN14SSDatabaseImpl17newDbUniqueRecordEv +Security:single module:__ZN18SSUniqueRecordImplC1ERK10SSDatabase +Security:single module:__ZN18SSUniqueRecordImplC4ERK10SSDatabase +Security:single module:_CSSM_DL_DataGetFirst +Security:single module:__Z17cssm_DataGetFirst17cssm_dl_db_handlePK10cssm_queryPmP29cssm_db_record_attribute_dataP9cssm_dataPP21cssm_db_unique_record +Security:single module:__ZN8Security15DatabaseSession12DataGetFirstEmPKNS_7DLQueryEP29cssm_db_record_attribute_dataPNS_8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN8Security15DatabaseSession13findDbContextEm +Security:single module:__ZN8Security13AppleDatabase12dataGetFirstERNS_9DbContextEPKNS_7DLQueryEP29cssm_db_record_attribute_dataPNS_8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN8Security10DbModifier12createCursorEPK10cssm_query +Security:single module:__ZN8Security18AtomicBufferedFileD1Ev +Security:single module:__ZN8Security18AtomicBufferedFileD4Ev +Security:single module:__ZNK8Security9DbVersion12createCursorEPK10cssm_query +Security:single module:__ZNK8Security9DbVersion9findTableEm +Security:single module:__ZNK8Security5Table12createCursorEPK10cssm_queryRKNS_9DbVersionE +Security:single module:__ZN8Security12LinearCursorC1EPK10cssm_queryRKNS_9DbVersionERKNS_5TableE +Security:single module:__ZN8Security12LinearCursorC4EPK10cssm_queryRKNS_9DbVersionERKNS_5TableE +Security:single module:__ZN8Security12LinearCursor4nextERmP29cssm_db_record_attribute_dataPNS_8CssmDataERNS_13CssmAllocatorERNS_8RecordIdE +Security:single module:__ZThn44_N8Security15DLPluginSession6mallocEm +Security:single module:__ZN8Security15DLPluginSession6mallocEm +Security:single module:__ZN8Security13PluginSession6mallocEm +Security:single module:__ZN10Attachment12upcallMallocEmm +Security:single module:__ZN8Security12HandleObject5State4findEml +Security:single module:__ZN8Security13AppleDatabase18createUniqueRecordERNS_9DbContextEmRKNS_8RecordIdE +Security:single module:__ZN8Security13AppleDatabase18updateUniqueRecordERNS_9DbContextEmRKNS_8RecordIdER21cssm_db_unique_record +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImpl8activateEv +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplD0Ev +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplD4Ev +Security:single module:__ZN8Security10CssmClient14DbDbCursorImpl10deactivateEv +Security:single module:_CSSM_DL_DataAbortQuery +Security:single module:__Z19cssm_DataAbortQuery17cssm_dl_db_handlem +Security:single module:__ZN8Security15DatabaseSession14DataAbortQueryEmm +Security:single module:__ZN8Security13AppleDatabase14dataAbortQueryERNS_9DbContextEm +Security:single module:__ZN8Security12LinearCursorD0Ev +Security:single module:__ZN8Security12LinearCursorD4Ev +Security:single module:__ZN8Security6CursorD2Ev +Security:single module:__ZN8Security6CursorD4Ev +Security:single module:__ZN8Security13CssmAutoQueryD2Ev +Security:single module:__ZN8Security13CssmAutoQueryD4Ev +Security:single module:__ZN8Security13CssmAutoQuery5clearEv +Security:single module:__ZN18SSUniqueRecordImplD0Ev +Security:single module:__ZN18SSUniqueRecordImplD4Ev +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImplD2Ev +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImplD4Ev +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImpl10deactivateEv +Security:single module:_CSSM_DL_FreeUniqueRecord +Security:single module:__Z21cssm_FreeUniqueRecord17cssm_dl_db_handleP21cssm_db_unique_record +Security:single module:__ZN8Security15DatabaseSession16FreeUniqueRecordEmR21cssm_db_unique_record +Security:single module:__ZN8Security13AppleDatabase16freeUniqueRecordERNS_9DbContextER21cssm_db_unique_record +Security:single module:__ZThn44_N8Security15DLPluginSession4freeEPv +Security:single module:__ZN8Security15DLPluginSession4freeEPv +Security:single module:__ZN10Attachment10upcallFreeEmPv +Security:single module:__ZN8Security14SecurityServer13ClientSession8decodeDbERKNS_14DLDbIdentifierEPKNS_17AccessCredentialsERKNS_8CssmDataE +Security:single module:__ZN8Security25DatabaseAccessCredentialsC1EPKNS_17AccessCredentialsERNS_13CssmAllocatorE +Security:single module:__ZN8Security25DatabaseAccessCredentialsC4EPKNS_17AccessCredentialsERNS_13CssmAllocatorE +Security:single module:_ucsp_client_decodeDb +Security:single module:__ZN8Security9ObjectAclC2ERNS_13CssmAllocatorE +Security:single module:__ZN8Security9ObjectAclC4ERNS_13CssmAllocatorE +Security:single module:__Z30__MIG_check__Reply__decodeDb_tP19__Reply__decodeDb_t +Security:single module:__ZN11SSDLSession12makeDbHandleER10SSDatabase +Security:single module:__ZThn40_N11SSDLSession12DataGetFirstEmPKN8Security7DLQueryEP29cssm_db_record_attribute_dataPNS0_8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN11SSDLSession12DataGetFirstEmPKN8Security7DLQueryEP29cssm_db_record_attribute_dataPNS0_8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN11SSDLSession12findDbHandleEm +Security:single module:__ZNK8Security12DbConstIndex12matchesQueryERK10cssm_queryRPNS_10DbQueryKeyE +Security:single module:__Znam +Security:single module:__ZN8Security10DbQueryKeyC1ERKNS_12DbConstIndexE +Security:single module:__ZN8Security10DbQueryKeyC4ERKNS_12DbConstIndexE +Security:single module:__ZN8Security9BlobValueC1ERK9cssm_data +Security:single module:__ZN8Security9BlobValueC4ERK9cssm_data +Security:single module:__ZNK8Security9BlobValue4packERNS_12WriteSectionERm +Security:single module:__ZN8Security9BlobValueD1Ev +Security:single module:__ZdaPv +Security:single module:__ZN8Security11IndexCursorC1EPNS_10DbQueryKeyERKNS_9DbVersionERKNS_5TableEPKNS_12DbConstIndexE +Security:single module:__ZN8Security11IndexCursorC4EPNS_10DbQueryKeyERKNS_9DbVersionERKNS_5TableEPKNS_12DbConstIndexE +Security:single module:__ZNK8Security12DbConstIndex12performQueryERKNS_10DbQueryKeyERPKNS_6EndianImEES8_ +Security:single module:__ZNK8Security15DbKeyComparatorclEmm +Security:single module:__ZN8Security9BlobValueC1ERKNS_11ReadSectionERm +Security:single module:__ZNK8Security9BlobValue8evaluateERKS0_m +Security:single module:__ZN8Security9BlobValue8evaluateERKNS_8CssmDataES3_mNS0_10ComparatorE +Security:single module:__ZN8Security9BlobValue10ComparatorclEPKhS3_m +Security:single module:__ZN8Security9BlobValue10ComparatorD1Ev +Security:single module:__ZN8Security9BlobValue10ComparatorD4Ev +Security:single module:__ZN8Security9BlobValueD0Ev +Security:single module:__ZN8Security11IndexCursor4nextERmP29cssm_db_record_attribute_dataPNS_8CssmDataERNS_13CssmAllocatorERNS_8RecordIdE +Security:single module:__ZNK8Security12DbConstIndex16getRecordSectionEPKNS_6EndianImEE +Security:single module:__ZNK8Security5Table16getRecordSectionEm +Security:single module:__ZN11SSDLSession18makeSSUniqueRecordER14SSUniqueRecord +Security:single module:__ZN11SSDLSession18createUniqueRecordEm +Security:single module:__ZN8Security12KeychainCore12KeychainImpl4itemEmRNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl14makePrimaryKeyEmRNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security10CssmClient12DbAttributesC1ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient12DbAttributesC4ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl26gatherPrimaryKeyAttributesERNS_10CssmClient12DbAttributesE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl18primaryKeyInfosForEm +Security:single module:__ZN8Security12KeychainCore12KeychainImpl14keychainSchemaEv +Security:single module:__ZN8Security12KeychainCore18KeychainSchemaImplC1ERKNS_10CssmClient2DbE +Security:single module:__ZN8Security12KeychainCore18KeychainSchemaImplC4ERKNS_10CssmClient2DbE +Security:single module:__ZThn20_N8Security10CssmClient8SSDbImpl11newDbCursorEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient8SSDbImpl11newDbCursorEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14SSDbCursorImplC1ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14SSDbCursorImplC4ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplC2ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security29CssmAutoDbRecordAttributeData3addERK22cssm_db_attribute_info +Security:single module:__ZN8Security29CssmAutoDbRecordAttributeData21getAttributeReferenceERK22cssm_db_attribute_info +Security:single module:__ZN8Security29CssmAutoDbRecordAttributeData13findAttributeERK22cssm_db_attribute_info +Security:single module:__ZN8Security19CssmDbAttributeData12deleteValuesERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImplD0Ev +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImplD4Ev +Security:single module:__ZN8Security18SelectionPredicateC1ERKNS_10MetaRecordERK24cssm_selection_predicate +Security:single module:__ZN8Security18SelectionPredicateC4ERKNS_10MetaRecordERK24cssm_selection_predicate +Security:single module:__ZN8Security11UInt32ValueC1ERK9cssm_data +Security:single module:__ZN8Security11UInt32ValueC4ERK9cssm_data +Security:single module:__ZNK8Security18SelectionPredicate8evaluateERKNS_11ReadSectionE +Security:single module:_CSSM_DL_DataGetNext +Security:single module:__Z16cssm_DataGetNext17cssm_dl_db_handlemP29cssm_db_record_attribute_dataP9cssm_dataPP21cssm_db_unique_record +Security:single module:__ZThn40_N11SSDLSession11DataGetNextEmmP29cssm_db_record_attribute_dataPN8Security8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN11SSDLSession11DataGetNextEmmP29cssm_db_record_attribute_dataPN8Security8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN8Security15DatabaseSession11DataGetNextEmmP29cssm_db_record_attribute_dataPNS_8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN8Security13AppleDatabase11dataGetNextERNS_9DbContextEmP29cssm_db_record_attribute_dataPNS_8CssmDataERP21cssm_db_unique_record +Security:single module:__ZThn40_N11SSDLSession16FreeUniqueRecordEmR21cssm_db_unique_record +Security:single module:__ZN11SSDLSession16FreeUniqueRecordEmR21cssm_db_unique_record +Security:single module:__ZN11SSDLSession18killSSUniqueRecordER21cssm_db_unique_record +Security:single module:__ZN11SSDLSession17parseUniqueRecordERK21cssm_db_unique_record +Security:single module:__ZN11SSDLSession16freeUniqueRecordER21cssm_db_unique_record +Security:single module:__ZN8Security18SelectionPredicateD1Ev +Security:single module:__ZN8Security18SelectionPredicateD4Ev +Security:single module:__ZN8Security11UInt32ValueD0Ev +Security:single module:__ZN8Security29CssmAutoDbRecordAttributeDataD2Ev +Security:single module:__ZN8Security29CssmAutoDbRecordAttributeDataD4Ev +Security:single module:__ZN8Security29CssmAutoDbRecordAttributeData5clearEv +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplD2Ev +Security:single module:__Z21CompareAttributeInfosRK22cssm_db_attribute_infoS1_ +Security:single module:__ZNK8Security12KeychainCore18KeychainSchemaImpl18primaryKeyInfosForEm +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImpl3getEPNS0_12DbAttributesEPNS_17CssmDataContainerE +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImpl3getEPNS0_12DbAttributesEPNS_17CssmDataContainerEPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImpl3getEPNS0_12DbAttributesEPNS_17CssmDataContainerE +Security:single module:_CSSM_DL_DataGetFromUniqueRecordId +Security:single module:__Z30cssm_DataGetFromUniqueRecordId17cssm_dl_db_handlePK21cssm_db_unique_recordP29cssm_db_record_attribute_dataP9cssm_data +Security:single module:__ZThn40_N11SSDLSession25DataGetFromUniqueRecordIdEmRK21cssm_db_unique_recordP29cssm_db_record_attribute_dataPN8Security8CssmDataE +Security:single module:__ZN11SSDLSession25DataGetFromUniqueRecordIdEmRK21cssm_db_unique_recordP29cssm_db_record_attribute_dataPN8Security8CssmDataE +Security:single module:__ZN11SSDLSession18findSSUniqueRecordERK21cssm_db_unique_record +Security:single module:__ZN8Security15DatabaseSession25DataGetFromUniqueRecordIdEmRK21cssm_db_unique_recordP29cssm_db_record_attribute_dataPNS_8CssmDataE +Security:single module:__ZN8Security13AppleDatabase25dataGetFromUniqueRecordIdERNS_9DbContextERK21cssm_db_unique_recordP29cssm_db_record_attribute_dataPNS_8CssmDataE +Security:single module:__ZN8Security13AppleDatabase17parseUniqueRecordERK21cssm_db_unique_recordRm +Security:single module:__ZN8Security10DbModifier9getRecordEmRKNS_8RecordIdEP29cssm_db_record_attribute_dataPNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZNK8Security9DbVersion9getRecordEmRKNS_8RecordIdEP29cssm_db_record_attribute_dataPNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZNK8Security5Table9getRecordERKNS_8RecordIdEP29cssm_db_record_attribute_dataPNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore14PrimaryKeyImplC1ERKNS_10CssmClient12DbAttributesE +Security:single module:__ZN8Security12KeychainCore14PrimaryKeyImplC4ERKNS_10CssmClient12DbAttributesE +Security:single module:__ZN8Security12KeychainCore14PrimaryKeyImpl9putUInt32ERPhm +Security:single module:__ZN8Security12KeychainCore4ItemC1ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore4ItemC4ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZNK8Security12KeychainCore14PrimaryKeyImpl10recordTypeEv +Security:single module:__ZNK8Security12KeychainCore14PrimaryKeyImpl9getUInt32ERPhRm +Security:single module:__ZN8Security12KeychainCore8ItemImplC1ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore8ItemImplC4ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl7addItemERKNS0_10PrimaryKeyEPNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore11SecCFObject6handleEb +Security:single module:__ZN8Security12KeychainCore7CFClass12finalizeTypeEPKv +Security:single module:__ZN8Security12KeychainCore11SecCFObject8optionalEPKv +Security:single module:__ZN8Security12KeychainCore12KCCursorImplD1Ev +Security:single module:__ZN8Security12KeychainCore12KCCursorImplD4Ev +Security:single module:__ZThn40_N11SSDLSession14DataAbortQueryEmm +Security:single module:__ZN11SSDLSession14DataAbortQueryEmm +Security:single module:__ZN8Security11IndexCursorD0Ev +Security:single module:__ZN8Security11IndexCursorD4Ev +Security:single module:__ZN8Security12KeychainCore11SecCFObjectD2Ev +Security:single module:__ZN8Security12KeychainCore11SecCFObjectD4Ev +Security:single module:__ZN8Security12KeychainCore12KeychainImplD1Ev +Security:single module:__ZN8Security12KeychainCore12KeychainImplD4Ev +Security:single module:__ZNK8Security10CssmClient6DbImpl14dlDbIdentifierEv +Security:single module:__ZNK8Security10CssmClient14AttachmentImpl13subserviceUidEv +Security:single module:__ZThn64_NK8Security10CssmClient9CSPDLImpl14subserviceMaskEv +Security:single module:__ZNK8Security10CssmClient9CSPDLImpl14subserviceMaskEv +Security:single module:__ZN8Security12KeychainCore14StorageManager14removeKeychainERKNS_14DLDbIdentifierEPNS0_12KeychainImplE +Security:single module:__ZN8Security10CssmClient8SSDbImplD0Ev +Security:single module:__ZN8Security10CssmClient8SSDbImplD4Ev +Security:single module:__ZN8Security10CssmClient6DbImplD2Ev +Security:single module:__ZN8Security10CssmClient6DbImplD4Ev +Security:single module:__ZN8Security10CssmClient6DbImpl10deactivateEv +Security:single module:__ZThn64_N8Security10CssmClient11SSCSPDLImplD0Ev +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplD0Ev +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplD4Ev +Security:single module:__ZN8Security10CssmClient9CSPDLImplD2Ev +Security:single module:__ZN8Security10CssmClient9CSPDLImplD4Ev +Security:single module:__ZN8Security10CssmClient6DLImplD2Ev +Security:single module:__ZN8Security10CssmClient6DLImplD4Ev +Security:single module:__ZN8Security10CssmClient14AttachmentImplD2Ev +Security:single module:__ZN8Security10CssmClient14AttachmentImplD4Ev +Security:single module:__ZN8Security10CssmClient14AttachmentImpl10deactivateEv +Security:single module:__ZN8Security10CssmClient7CSPImplD2Ev +Security:single module:__ZN8Security10CssmClient7CSPImplD4Ev +Security:single module:__ZN8Security10CssmClient10ModuleImplD0Ev +Security:single module:__ZN8Security10CssmClient10ModuleImplD4Ev +Security:single module:__ZN8Security10CssmClient10ModuleImpl10deactivateEv +Security:single module:_SecKeychainItemCopyContent +Security:single module:__ZN8Security12KeychainCore11SecCFObject8requiredEPKvl +Security:single module:__ZN8Security12KeychainCore4ItemC1EPNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore4ItemC4EPNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore8ItemImpl10getContentEPmP24SecKeychainAttributeListS2_PPv +Security:single module:__ZN8Security12KeychainCore8ItemImpl14dbUniqueRecordEv +Security:single module:__ZNK8Security12KeychainCore8ItemImpl12isPersistantEv +Security:single module:__ZN8Security12KeychainCore8ItemImpl10getContentEPNS_10CssmClient12DbAttributesEPNS_17CssmDataContainerE +Security:single module:__ZN8Security12KeychainCore8ItemImpl16useSecureStorageERKNS_10CssmClient2DbE +Security:single module:__ZNK8Security12KeychainCore8ItemImpl10recordTypeEv +Security:single module:__ZN8Security12KeychainCore7Globals11credentialsEv +Security:single module:__ZNK8Security10CssmClient10AclFactory10promptCredEv +Security:single module:__ZN8Security10CssmClient7StaticsC1Ev +Security:single module:__ZN8Security10CssmClient7StaticsC4Ev +Security:single module:__ZN8Security15AutoCredentialsC1ERNS_13CssmAllocatorEm +Security:single module:__ZN8Security15AutoCredentialsC4ERNS_13CssmAllocatorEm +Security:single module:__ZN8Security15AutoCredentials4initEv +Security:single module:__ZN8Security15AutoCredentials9getSampleEm +Security:single module:__ZN8Security9TypedListC1ERNS_13CssmAllocatorEl +Security:single module:__ZN8Security9TypedListC4ERNS_13CssmAllocatorEl +Security:single module:__ZN8Security11ListElementC1El +Security:single module:__ZN8Security11ListElementC4El +Security:single module:__ZN8Security8CssmList6appendEPNS_11ListElementE +Security:single module:__ZN8Security11ListElementC1ERKNS_8CssmListE +Security:single module:__ZN8Security11ListElementC4ERKNS_8CssmListE +Security:single module:__ZN8Security9TypedListC1ERNS_13CssmAllocatorElPNS_11ListElementE +Security:single module:__ZN8Security9TypedListC4ERNS_13CssmAllocatorElPNS_11ListElementE +Security:single module:__ZN8Security10CssmClient11SSGroupImpl7isGroupERK9cssm_data +Security:single module:__ZN8Security10CssmClient11SSGroupImplC1ERKNS0_4SSDbERK9cssm_data +Security:single module:__ZN8Security10CssmClient11SSGroupImplC4ERKNS0_4SSDbERK9cssm_data +Security:single module:__ZN8Security10CssmClient7KeyImplC2ERKNS0_3CSPE +Security:single module:__ZN8Security10CssmClient7KeyImplC4ERKNS0_3CSPE +Security:single module:__ZN5SSKeyC1ER11SSDLSessionRN8Security7CssmKeyER10SSDatabaseRK14SSUniqueRecordmRNS2_8CssmDataE +Security:single module:__ZN5SSKeyC4ER11SSDLSessionRN8Security7CssmKeyER10SSDatabaseRK14SSUniqueRecordmRNS2_8CssmDataE +Security:single module:__ZN8Security13ReferencedKeyC2ERNS_7KeyPoolE +Security:single module:__ZN8Security13ReferencedKeyC4ERNS_7KeyPoolE +Security:single module:__ZN8Security7KeyPool3addERNS_13ReferencedKeyE +Security:single module:__ZN8Security13ReferencedKey12keyReferenceEv +Security:single module:__ZNK18SSUniqueRecordImpl8databaseEv +Security:single module:__ZNK8Security14CssmDLPolyDatacv9cssm_dateEv +Security:single module:__ZN8Security13ReferencedKey16makeReferenceKeyERNS_13CssmAllocatorEmR8cssm_key +Security:single module:__ZN8Security10CssmClient7KeyImpl8activateEv +Security:single module:__ZN8Security10CssmClient11SSGroupImpl14decodeDataBlobERK9cssm_dataPK23cssm_access_credentialsRNS_13CssmAllocatorERS2_ +Security:single module:__ZN8Security10CssmClient5CryptC2ERKNS0_3CSPEm +Security:single module:__ZN8Security10CssmClient5CryptC4ERKNS0_3CSPEm +Security:single module:__ZN8Security10CssmClient5Crypt3keyERKNS0_3KeyE +Security:single module:__ZN8Security10CssmClient5Crypt4credEPKNS_17AccessCredentialsE +Security:single module:__ZN8Security10CssmClient7Decrypt7decryptEPKNS_8CssmDataEmPS2_m +Security:single module:__ZN8Security10CssmClient7Decrypt4initEv +Security:single module:__ZN8Security10CssmClient5Crypt8activateEv +Security:single module:__ZNK10__cxxabiv117__class_type_info12__do_dyncastEiNS0_10__sub_kindEPKS0_PKvS3_S5_RNS0_16__dyncast_resultE +Security:single module:__ZN12SSCSPSessionC1EmR11CSPDLPluginRK12cssm_versionmmmRK12cssm_upcallsR14SSCSPDLSessionRN8Security10CssmClient3CSPE +Security:single module:__ZN12SSCSPSessionC4EmR11CSPDLPluginRK12cssm_versionmmmRK12cssm_upcallsR14SSCSPDLSessionRN8Security10CssmClient3CSPE +Security:single module:__ZN8Security16CSPPluginSession9constructEv +Security:single module:_CSSM_CSP_CreateSymmetricContext +Security:single module:__ZN8Security11ListElement4listEv +Security:single module:__ZN8Security11ListElement4lastEv +Security:single module:__ZN12SSCSPSession13contextCreateEyRKN8Security7ContextE +Security:single module:_CSSM_DecryptDataInit +Security:single module:__Z20cssm_DecryptDataInitmyPK12cssm_contexty +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15DecryptDataInitEyRKNS_7ContextEy +Security:single module:__ZN8Security20CSPFullPluginSession15DecryptDataInitEyRKNS_7ContextEy +Security:single module:__ZN12SSCSPSession12setupContextERPN8Security20CSPFullPluginSession10CSPContextERKNS0_7ContextEb +Security:single module:__ZN9SSFactory5setupER12SSCSPSessionRPN8Security20CSPFullPluginSession10CSPContextERKNS2_7ContextEb +Security:single module:__ZN14SSCryptContextC1ER12SSCSPSession +Security:single module:__ZN14SSCryptContextC4ER12SSCSPSession +Security:single module:__ZN9SSContextC2ER12SSCSPSession +Security:single module:__ZN9SSContextC4ER12SSCSPSession +Security:single module:__ZN14SSCryptContext4initERKN8Security7ContextEb +Security:single module:__ZN9SSContext4initERKN8Security7ContextEb +Security:single module:__ZN9SSContext11clearOutBufEv +Security:single module:__ZN8Security7Context4findEmPK22cssm_context_attributej +Security:single module:__ZN12SSCSPSession9lookupKeyERKN8Security7CssmKeyE +Security:single module:__ZN14SSCSPDLSession9lookupKeyERKN8Security7CssmKeyE +Security:single module:__ZNK8Security7KeyPool7findKeyERK8cssm_key +Security:single module:__ZN8Security13ReferencedKey12keyReferenceERK8cssm_key +Security:single module:__ZNK8Security7KeyPool16findKeyReferenceEm +Security:single module:__ZN5SSKey9keyHandleEv +Security:single module:__ZN5SSKey13clientSessionEv +Security:single module:__ZN14SSDatabaseImpl8dbHandleEv +Security:single module:__ZN8Security14SecurityServer13ClientSession9decodeKeyEmRKNS_8CssmDataERNS_7CssmKey6HeaderE +Security:single module:_ucsp_client_decodeKey +Security:single module:__ZN8Security4n2hiERNS_7CssmKey6HeaderE +Security:single module:__Z31__MIG_check__Reply__decodeKey_tP20__Reply__decodeKey_t +Security:single module:_CSSM_DecryptDataUpdate +Security:single module:__Z22cssm_DecryptDataUpdatemyPK9cssm_datamPS_mPm +Security:single module:__ZThn40_N8Security20CSPFullPluginSession17DecryptDataUpdateEyPKNS_8CssmDataEmPS1_mRm +Security:single module:__ZN8Security20CSPFullPluginSession17DecryptDataUpdateEyPKNS_8CssmDataEmPS1_mRm +Security:single module:__ZN8Security20CSPFullPluginSession6WriterC1EPNS_8CssmDataEmS3_ +Security:single module:__ZN8Security20CSPFullPluginSession6WriterC4EPNS_8CssmDataEmS3_ +Security:single module:__ZN14SSCryptContext10outputSizeEbm +Security:single module:__ZN8Security20CSPFullPluginSession6Writer8allocateEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security20CSPFullPluginSession10makeBufferEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext6updateEPKNS_8CssmDataEmRNS0_6WriterE +Security:single module:__ZN8Security20CSPFullPluginSession6Writer9nextBlockERPvRm +Security:single module:__ZN14SSCryptContext9inputSizeEm +Security:single module:__ZN14SSCryptContext6updateEPvRmS0_S1_ +Security:single module:__ZN8Security20CSPFullPluginSession6Writer3useEm +Security:single module:__ZN8Security20CSPFullPluginSession6Writer5closeEv +Security:single module:__ZN8Security10CssmClient7Decrypt5finalERNS_8CssmDataE +Security:single module:_CSSM_DecryptDataFinal +Security:single module:__Z21cssm_DecryptDataFinalmyP9cssm_data +Security:single module:__ZThn40_N8Security20CSPFullPluginSession16DecryptDataFinalEyRNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession16DecryptDataFinalEyRNS_8CssmDataE +Security:single module:__ZN9SSContext13clientSessionEv +Security:single module:__ZN8Security14SecurityServer13ClientSession7decryptERKNS_7ContextEmRKNS_8CssmDataERS5_RNS_13CssmAllocatorE +Security:single module:__ZN8Security11SendContextC1ERKNS_7ContextE +Security:single module:__ZN8Security11SendContextC4ERKNS_7ContextE +Security:single module:_ucsp_client_decrypt +Security:single module:__ZN8Security10CssmClient7Decrypt7decryptEPKNS_8CssmDataEmPS2_mRS2_ +Security:single module:_CSSM_DecryptData +Security:single module:__Z16cssm_DecryptDatamyPK12cssm_contextPK9cssm_datamPS2_mPmS5_y +Security:single module:__ZThn40_N8Security20CSPFullPluginSession11DecryptDataEyRKNS_7ContextEPKNS_8CssmDataEmPS4_mRmRS4_y +Security:single module:__ZN8Security20CSPFullPluginSession11DecryptDataEyRKNS_7ContextEPKNS_8CssmDataEmPS4_mRmRS4_y +Security:single module:__ZN11DES3Context4initERKN8Security7ContextEb +Security:single module:__ZN15AppleCSPContext16symmetricKeyBitsERKN8Security7ContextEmmRPhRm +Security:single module:_cspValidateIntendedKeyUsage +Security:single module:_cspValidateKeyUsageBits +Security:single module:_cspVerifyKeyTimes +Security:single module:__Z17cspGetUniformDateRK9cssm_date +Security:single module:_desinit +Security:single module:_dessetkey +Security:single module:__ZN12BlockCryptor5setupEmRKN8Security7ContextE +Security:single module:__ZN12BlockCryptor5setupEmmbbNS_7BC_ModeEPKN8Security8CssmDataE +Security:single module:__ZN12BlockCryptor10outputSizeEbm +Security:single module:__ZN12BlockCryptor9inputSizeEm +Security:single module:__ZN12BlockCryptor6updateEPvRmS0_S1_ +Security:single module:__ZN11DES3Context12decryptBlockEPKvPvRmb +Security:single module:_dedes +Security:single module:_permute +Security:single module:_round +Security:single module:_endes +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext5finalERNS0_6WriterERNS_13CssmAllocatorE +Security:single module:__ZN12BlockCryptor5finalERN8Security8CssmDataE +Security:single module:__ZN8Security10CssmClient9UnwrapKeyclERKNS_7CssmKeyERKNS0_7KeySpecERS2_PNS_8CssmDataEPS3_ +Security:single module:_CSSM_UnwrapKey +Security:single module:__Z14cssm_UnwrapKeymyPK12cssm_contextPK8cssm_keyS4_mmPK9cssm_dataPK29cssm_resource_control_contextPS2_PS5_y +Security:single module:__ZN15AppleCSPSession9UnwrapKeyEyRKN8Security7ContextEPKNS0_7CssmKeyERS5_mmPKNS0_8CssmDataEPK29cssm_resource_control_contextRS4_RS8_y +Security:single module:_cspParseKeyAttr +Security:single module:_cspValidateKeyAttr +Security:single module:_setKeyHeader +Security:single module:_copyData +Security:single module:_freeCssmData +Security:single module:__ZN8Security10CssmClient7KeyImplC1ERKNS0_3CSPERK8cssm_keyb +Security:single module:__ZN8Security10CssmClient7KeyImplC4ERKNS0_3CSPERK8cssm_keyb +Security:single module:__ZN8Security7CssmKeyC2ERK8cssm_key +Security:single module:__ZN8Security7CssmKeyC4ERK8cssm_key +Security:single module:__ZN8Security10CssmClient7KeyImplD0Ev +Security:single module:__ZN8Security10CssmClient7KeyImplD4Ev +Security:single module:__ZN8Security10CssmClient7KeyImpl10deactivateEv +Security:single module:_CSSM_FreeKey +Security:single module:__Z12cssm_FreeKeymPK23cssm_access_credentialsP8cssm_keyl +Security:single module:__ZN15AppleCSPSession7FreeKeyEPKN8Security17AccessCredentialsERNS0_7CssmKeyEl +Security:single module:__ZN8Security20CSPFullPluginSession7FreeKeyEPKNS_17AccessCredentialsERNS_7CssmKeyEl +Security:single module:__ZN8Security10CssmClient9AclBearerD2Ev +Security:single module:__ZN8Security10CssmClient9AclBearerD4Ev +Security:single module:__ZN8Security10CssmClient9VerifyMac6verifyEPKNS_8CssmDataEmRS3_ +Security:single module:__ZN8Security10CssmClient10MacContext8activateEv +Security:single module:_CSSM_CSP_CreateMacContext +Security:single module:_CSSM_VerifyMac +Security:single module:__Z14cssm_VerifyMacmyPK12cssm_contextPK9cssm_datamS4_ +Security:single module:__ZThn40_N8Security20CSPFullPluginSession9VerifyMacEyRKNS_7ContextEPKNS_8CssmDataEmRS5_ +Security:single module:__ZN8Security20CSPFullPluginSession9VerifyMacEyRKNS_7ContextEPKNS_8CssmDataEmRS5_ +Security:single module:__ZN8Security20CSPFullPluginSession13VerifyMacInitEyRKNS_7ContextE +Security:single module:__ZN16MacLegacyContext4initERKN8Security7ContextEb +Security:single module:_hmacLegacyAlloc +Security:single module:_hmacLegacyInit +Security:single module:_sha1Alloc +Security:single module:__ZN8Security20CSPFullPluginSession15VerifyMacUpdateEyPKNS_8CssmDataEm +Security:single module:__ZN16MacLegacyContext6updateERKN8Security8CssmDataE +Security:single module:_hmacLegacyUpdate +Security:single module:_sha1AddData +Security:single module:_sha1Digest +Security:single module:_sha1Reinit +Security:single module:__ZN8Security20CSPFullPluginSession14VerifyMacFinalEyRKNS_8CssmDataE +Security:single module:__ZN16MacLegacyContext5finalERKN8Security8CssmDataE +Security:single module:_hmacLegacyFinal +Security:single module:__ZN16MacLegacyContextD0Ev +Security:single module:__ZN16MacLegacyContextD4Ev +Security:single module:_hmacLegacyFree +Security:single module:_sha1Free +Security:single module:__ZN11DES3ContextD0Ev +Security:single module:__ZN11DES3ContextD4Ev +Security:single module:_desdone +Security:single module:__ZN12BlockCryptorD2Ev +Security:single module:__ZN12BlockCryptorD4Ev +Security:single module:__ZN8Security12MachPlusPlus10MachServer8setTimerEPNS1_5TimerENS_4Time8AbsoluteE +Security:single module:__ZN8Security19NameValueDictionaryC1Ev +Security:single module:__ZN8Security19NameValueDictionaryC4Ev +Security:single module:__ZN8Security19NameValueDictionary41MakeNameValueDictionaryFromDLDbIdentifierERKNS_14DLDbIdentifierERS0_ +Security:single module:__ZN8Security13NameValuePairC1EmRKNS_8CssmDataE +Security:single module:__ZN8Security13NameValuePairC4EmRKNS_8CssmDataE +Security:single module:__ZN8Security13NameValuePair9CloneDataERKNS_8CssmDataE +Security:single module:__ZN8Security19NameValueDictionary6InsertEPNS_13NameValuePairE +Security:single module:__ZN8Security19NameValueDictionary6ExportERNS_8CssmDataE +Security:single module:__ZNK8Security19NameValueDictionary13CountElementsEv +Security:single module:__ZN8Security19NameValueDictionary10GetElementEi +Security:single module:__ZNK8Security13NameValuePair6ExportERNS_8CssmDataE +Security:single module:__ZN8Security19NameValueDictionaryD1Ev +Security:single module:__ZN8Security19NameValueDictionaryD4Ev +Security:single module:__ZN8Security13NameValuePairD1Ev +Security:single module:__ZN8Security13NameValuePairD4Ev +Security:single module:__ZN8Security9ObjectAcl10importBlobEPKvS2_ +Security:single module:__ZN8Security9ObjectAcl5Entry10importBlobERNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security9ObjectAcl13importSubjectERNS_23LowLevelMemoryUtilities6ReaderES3_ +Security:single module:__ZN8Security9ObjectAcl4makeEmRNS_23LowLevelMemoryUtilities6ReaderES3_ +Security:single module:__ZN8Security9ObjectAcl8makerForEl +Security:single module:__ZNK8Security13AnyAclSubject5Maker4makeEhRNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security9ObjectAcl8AclEntry10importBlobERNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security9ObjectAcl5EntryD2Ev +Security:single module:__ZN8Security9ObjectAcl5EntryD4Ev +Security:single module:__ZN8Security4h2niERNS_7CssmKey6HeaderE +Security:single module:_CSSM_UpdateContextAttributes +Security:single module:__ZN13HandleContext15mergeAttributesEPK22cssm_context_attributem +Security:single module:__ZN8Security16CSPPluginSession13contextUpdateEyRKNS_7ContextERPNS0_13PluginContextE +Security:single module:__ZN8Security10CssmClient9UnwrapKeyclERKNS_7CssmKeyERKNS0_7KeySpecERS2_PNS_8CssmDataE +Security:single module:__ZN15AppleCSPSession12UnwrapKeyCmsEyRKN8Security7ContextERKNS0_7CssmKeyEPK29cssm_resource_control_contextRS4_RNS0_8CssmDataEy13cspKeyStorage +Security:single module:_setUpCssmData +Security:single module:_inferFormat +Security:single module:__ZN15AppleCSPSession12infoProviderERKN8Security7CssmKeyE +Security:single module:__ZN18RSAKeyInfoProvider8providerERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN24SymmetricKeyInfoProvider8providerERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN24SymmetricKeyInfoProviderC1ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN24SymmetricKeyInfoProviderC4ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN24SymmetricKeyInfoProvider15CssmKeyToBinaryEPN8Security7CssmKeyERmPP9BinaryKey +Security:single module:__ZN18SymmetricBinaryKeyC1Ej +Security:single module:__ZN18SymmetricBinaryKeyC4Ej +Security:single module:_copyCssmData +Security:single module:__ZN15AppleCSPSession9addRefKeyER9BinaryKeyRN8Security7CssmKeyE +Security:single module:_setUpData +Security:single module:__ZN22SensitiveCssmAllocator4freeEPv +Security:single module:__ZNK8Security19ThresholdAclSubject5Maker4makeEhRNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security19ThresholdAclSubjectC1EmmRKSt6vectorINS_10RefPointerINS_10AclSubjectEEESaIS4_EE +Security:single module:__ZN8Security19ThresholdAclSubjectC4EmmRKSt6vectorINS_10RefPointerINS_10AclSubjectEEESaIS4_EE +Security:single module:__ZNK8Security23CodeSignatureAclSubject5Maker4makeEhRNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security11CodeSigning9OSXSigner7restoreEmPKvm +Security:single module:__ZN8Security23CodeSignatureAclSubjectC1ERNS_13CssmAllocatorEPKNS_11CodeSigning9SignatureEPKvm +Security:single module:__ZN8Security23CodeSignatureAclSubjectC4ERNS_13CssmAllocatorEPKNS_11CodeSigning9SignatureEPKvm +Security:single module:__ZN8Security12CssmAutoData5resetEv +Security:single module:__ZN8Security9ObjectAcl8validateElPKNS_17AccessCredentialsEPNS_24AclValidationEnvironmentE +Security:single module:__ZNK8Security9ObjectAcl8getRangeEPKcRSt4pairISt17_Rb_tree_iteratorIS3_IKSsNS0_8AclEntryEERKS7_PS8_ESB_E +Security:single module:__ZNK8Security9ObjectAcl8AclEntry10authorizesEl +Security:single module:__ZNK8Security9ObjectAcl8AclEntry8validateERKNS_20AclValidationContextE +Security:single module:__ZNK8Security16SimpleAclSubject8validateERKNS_20AclValidationContextE +Security:single module:__ZNK8Security9TypedList8isProperEv +Security:single module:__ZNK8Security11ListElement4wordEv +Security:single module:__ZNK8Security19ThresholdAclSubject8validateERKNS_20AclValidationContextERKNS_9TypedListE +Security:single module:__ZNK8Security23CodeSignatureAclSubject8validateERKNS_20AclValidationContextE +Security:single module:__ZN8Security11CodeSigning9OSXSigner4signERKNS0_8SignableE +Security:single module:__ZNK8Security11CodeSigning14ExecutableTool12scanContentsERNS0_6Signer5StateE +Security:single module:__ZN8Security11CodeSigning7OSXCode8scanFileEPKcRNS0_6Signer5StateE +Security:single module:__ZN8Security11CodeSigning9OSXSigner8Digester17enumerateContentsEPKvm +Security:single module:__ZN8Security10CssmClient6Digest6digestEPKNS_8CssmDataEm +Security:single module:__ZN14AppleCSPPlugin11makeSessionEmRK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN15AppleCSPSessionC1EmR14AppleCSPPluginRK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN15AppleCSPSessionC4EmR14AppleCSPPluginRK12cssm_versionmmmRK12cssm_upcalls +Security:single module:_CSSM_DigestDataInit +Security:single module:__Z19cssm_DigestDataInitmyPK12cssm_context +Security:single module:__ZThn40_N8Security20CSPFullPluginSession14DigestDataInitEyRKNS_7ContextE +Security:single module:_CSSM_DigestDataUpdate +Security:single module:__Z21cssm_DigestDataUpdatemyPK9cssm_datam +Security:single module:__ZThn40_N8Security20CSPFullPluginSession16DigestDataUpdateEyPKNS_8CssmDataEm +Security:single module:__ZN8Security10CssmClient6DigestclERNS_8CssmDataE +Security:single module:_CSSM_DigestDataFinal +Security:single module:__Z20cssm_DigestDataFinalmyP9cssm_data +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15DigestDataFinalEyRNS_8CssmDataE +Security:single module:__ZNK8Security12UnixPlusPlus6UnixDb3getERKNS_8CssmDataERS2_i +Security:single module:__ZN8Security15CssmManagedDataD2Ev +Security:single module:__ZN8Security15CssmManagedDataD4Ev +Security:single module:__ZN8Security20AclValidationContextD2Ev +Security:single module:__ZN8Security20AclValidationContextD4Ev +Security:single module:__ZN8Security24AclValidationEnvironmentD2Ev +Security:single module:__ZN8Security24AclValidationEnvironmentD4Ev +Security:single module:__ZN8Security10CssmClient7Context8overrideERKNS_7ContextE +Security:single module:_CSSM_SetContext +Security:single module:__ZNK8Security7Context14copyAttributesERP22cssm_context_attributeRmRNS_13CssmAllocatorE +Security:single module:__ZN15AppleCSPSession12lookupRefKeyERKN8Security7CssmKeyE +Security:single module:__ZN15AppleCSPSession12lookupKeyRefEm +Security:single module:__Z29__MIG_check__Reply__decrypt_tP18__Reply__decrypt_t +Security:single module:__ZN8Security10DataOutputD1Ev +Security:single module:__ZN8Security10DataOutputD4Ev +Security:single module:__ZN14SSCryptContext5finalERN8Security8CssmDataE +Security:single module:__ZN9SSContext10copyOutBufERN8Security8CssmDataE +Security:single module:__ZN14SSCryptContextD0Ev +Security:single module:__ZN14SSCryptContextD4Ev +Security:single module:__ZN8Security10CssmClient7KeyImplD2Ev +Security:single module:__ZThn40_N12SSCSPSession7FreeKeyEPKN8Security17AccessCredentialsERNS0_7CssmKeyEl +Security:single module:__ZN12SSCSPSession7FreeKeyEPKN8Security17AccessCredentialsERNS0_7CssmKeyEl +Security:single module:__ZN5SSKey4freeEPKN8Security17AccessCredentialsERNS0_7CssmKeyEl +Security:single module:__ZN8Security13ReferencedKey16freeReferenceKeyERNS_13CssmAllocatorER8cssm_key +Security:single module:__ZN8Security14SecurityServer13ClientSession10releaseKeyEm +Security:single module:_ucsp_client_releaseKey +Security:single module:__ZN18SymmetricBinaryKeyD0Ev +Security:single module:__ZN18SymmetricBinaryKeyD4Ev +Security:single module:__ZN8Security9ObjectAclD2Ev +Security:single module:__ZN8Security9ObjectAclD4Ev +Security:single module:__ZN8Security10AclSubjectD2Ev +Security:single module:__ZN8Security10AclSubjectD4Ev +Security:single module:__ZN8Security23CodeSignatureAclSubjectD0Ev +Security:single module:__ZN8Security23CodeSignatureAclSubjectD4Ev +Security:single module:__Z32__MIG_check__Reply__releaseKey_tP21__Reply__releaseKey_t +Security:single module:__ZN5SSKeyD0Ev +Security:single module:__ZN5SSKeyD4Ev +Security:single module:__ZN8Security13ReferencedKeyD2Ev +Security:single module:__ZN8Security13ReferencedKeyD4Ev +Security:single module:__ZN8Security7KeyPool5eraseERNS_13ReferencedKeyE +Security:single module:__ZN8Security7KeyPool5eraseEm +Security:single module:__ZN8Security12KeychainCore15KCEventNotifier17PostKeychainEventEmRKNS0_8KeychainERKNS0_4ItemE +Security:single module:__ZNK8Security12KeychainCore8ItemImpl10primaryKeyEv +Security:single module:__ZN8Security12KeychainCore15KCEventNotifier17PostKeychainEventEmRKNS_14DLDbIdentifierERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security14SecurityServer13ClientSession16postNotificationEmmRKNS_8CssmDataE +Security:single module:_ucsp_client_postNotification +Security:single module:__Z38__MIG_check__Reply__postNotification_tP27__Reply__postNotification_t +Security:single module:__ZN8Security14SecurityServer13ClientSessionD1Ev +Security:single module:__ZN8Security14SecurityServer13ClientSessionD4Ev +Security:single module:__ZN8Security10CssmClient9DeriveKeyclEPNS_8CssmDataERKNS0_7KeySpecE +Security:single module:__ZN8Security10CssmClient9DeriveKey8activateEv +Security:single module:_CSSM_CSP_CreateDeriveKeyContext +Security:single module:__ZN8Security10CssmClient7KeyImplC1ERKNS0_3CSPE +Security:single module:_CSSM_DeriveKey +Security:single module:__Z14cssm_DeriveKeymyPK12cssm_contextP9cssm_datammPKS2_PK29cssm_resource_control_contextP8cssm_key +Security:single module:__ZN15AppleCSPSession9DeriveKeyEyRKN8Security7ContextERNS0_8CssmDataEmmPKS4_PK29cssm_resource_control_contextRNS0_7CssmKeyE +Security:single module:__ZN15AppleCSPSession16DeriveKey_PBKDF2ERKN8Security7ContextERKNS0_8CssmDataEP9cssm_data +Security:single module:_pbkdf2 +Security:single module:_F +Security:single module:_hmacsha1 +Security:single module:_hmacInit +Security:single module:_DigestCtxInit +Security:single module:_DigestCtxUpdate +Security:single module:_DigestCtxFinal +Security:single module:_sha1GetDigest +Security:single module:_DigestCtxFree +Security:single module:_freeData +Security:single module:__ZN8Security7CssmKeyC1EmPv +Security:single module:__ZN8Security7CssmKeyC4EmPv +Security:single module:__ZN8Security10CssmClient9UnwrapKeyclERKNS_7CssmKeyERKNS0_7KeySpecE +Security:single module:_fmalloc +Security:single module:__Z8ckMallocj +Security:single module:_spinit +Security:single module:_perminit +Security:single module:__ZN8Security16CSPPluginSession13PluginContext7changedERKNS_7ContextE +Security:single module:__ZN10MacContext4initERKN8Security7ContextEb +Security:single module:_hmacAlloc +Security:single module:__ZN10MacContext6updateERKN8Security8CssmDataE +Security:single module:_hmacUpdate +Security:single module:__ZN10MacContext5finalERKN8Security8CssmDataE +Security:single module:_hmacFinal +Security:single module:__ZN10MacContextD0Ev +Security:single module:__ZN10MacContextD4Ev +Security:single module:_hmacFree +Security:single module:_SecKeychainItemFreeContent +Security:single module:__ZN8Security12KeychainCore8ItemImpl11freeContentEP24SecKeychainAttributeListPv +Security:single module:_SecKeychainItemRelease +Security:single module:__ZN8Security12KeychainCore8ItemImplD1Ev +Security:single module:__ZN8Security12KeychainCore8ItemImplD4Ev +Security:single module:__ZN8Security12KeychainCore14PrimaryKeyImplC1ERK9cssm_data +Security:single module:__ZN8Security12KeychainCore14PrimaryKeyImplC4ERK9cssm_data +Security:single module:__ZN8Security12KeychainCore12KeychainImpl10removeItemERKNS0_10PrimaryKeyEPKNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore18KeychainSchemaImplD1Ev +Security:single module:__ZN8Security12KeychainCore18KeychainSchemaImplD4Ev +Security:single module:__ZN8Security10CssmClient6DbImpl5closeEv +Security:single module:_CSSM_DL_DbClose +Security:single module:__Z12cssm_DbClose17cssm_dl_db_handle +Security:single module:__ZThn40_N11SSDLSession7DbCloseEm +Security:single module:__ZN11SSDLSession7DbCloseEm +Security:single module:__ZN11SSDLSession12killDbHandleEm +Security:single module:__ZN8Security15DatabaseSession7DbCloseEm +Security:single module:__ZN8Security15DatabaseManager7dbCloseERNS_9DbContextE +Security:single module:__ZN8Security8Database8_dbCloseERNS_9DbContextE +Security:single module:__ZN8Security13AppleDatabase7dbCloseEv +Security:single module:__ZN8Security10DbModifier13closeDatabaseEv +Security:single module:__ZN8Security9DbVersionD1Ev +Security:single module:__ZN8Security9DbVersionD4Ev +Security:single module:__ZN8Security5TableD1Ev +Security:single module:__ZN8Security5TableD4Ev +Security:single module:__ZN8Security10MetaRecordD1Ev +Security:single module:__ZN8Security10MetaRecordD4Ev +Security:single module:__ZN8Security13MetaAttributeD2Ev +Security:single module:__ZN8Security13MetaAttributeD4Ev +Security:single module:__ZN8Security15DatabaseManager14removeIfUnusedERNS_8DatabaseE +Security:single module:__ZN8Security8Database13hasDbContextsEv +Security:single module:__ZN8Security13AppleDatabaseD0Ev +Security:single module:__ZN8Security13AppleDatabaseD4Ev +Security:single module:__ZN8Security10DbModifierD1Ev +Security:single module:__ZN8Security10DbModifierD4Ev +Security:single module:__ZN8Security10AtomicFileD1Ev +Security:single module:__ZN8Security10AtomicFileD4Ev +Security:single module:__ZN8Security8DatabaseD2Ev +Security:single module:__ZN8Security8DatabaseD4Ev +Security:single module:__ZN8Security14AppleDbContextD0Ev +Security:single module:__ZN8Security14AppleDbContextD4Ev +Security:single module:__ZN8Security9DbContextD2Ev +Security:single module:__ZN8Security9DbContextD4Ev +Security:single module:__ZN14SSDatabaseImplD0Ev +Security:single module:__ZN14SSDatabaseImplD4Ev +Security:single module:__ZN8Security14SecurityServer13ClientSession9releaseDbEm +Security:single module:_ucsp_client_releaseDb +Security:single module:__Z31__MIG_check__Reply__releaseDb_tP20__Reply__releaseDb_t +Security:single module:__ZN8Security9CssmError7throwMeEl +Security:single module:___cxa_allocate_exception +Security:single module:__ZN8Security9CssmErrorC1El +Security:single module:__ZN8Security9CssmErrorC4El +Security:single module:__ZN8Security15CssmCommonErrorC2Ev +Security:single module:__ZN8Security15CssmCommonErrorC4Ev +Security:single module:___cxa_throw +Security:single module:___cxa_get_globals +Security:single module:__Z21get_globals_init_oncev +Security:single module:__Z16get_globals_initv +Security:single module:__Unwind_RaiseException +Security:single module:save_world +Security:single module:_uw_init_context_1 +Security:single module:_uw_frame_state_for +Security:single module:__Unwind_Find_FDE +Security:single module:__Unwind_Find_registered_FDE +Security:single module:_examine_objects +Security:single module:_search_object +Security:single module:_init_object +Security:single module:_classify_object_over_fdes +Security:single module:_get_cie_encoding +Security:single module:_read_uleb128 +Security:single module:_read_sleb128 +Security:single module:_read_encoded_value_with_base +Security:single module:_base_from_object +Security:single module:_size_of_encoded_value +Security:single module:_add_fdes +Security:single module:_fde_split +Security:single module:_fde_single_encoding_compare +Security:single module:_frame_heapsort +Security:single module:_extract_cie_info +Security:single module:_read_uleb128 +Security:single module:_read_sleb128 +Security:single module:_execute_cfa_program +Security:single module:_size_of_encoded_value +Security:single module:_uw_update_context_1 +Security:single module:_base_of_encoded_value +Security:single module:_read_encoded_value_with_base +Security:single module:___gxx_personality_v0 +Security:single module:__Unwind_GetLanguageSpecificData +Security:single module:_uw_update_context +Security:single module:__Z17parse_lsda_headerP15_Unwind_ContextPKhP16lsda_header_info +Security:single module:__Unwind_GetRegionStart +Security:single module:__Z12read_uleb128PKhPj +Security:single module:__Z21base_of_encoded_valuehP15_Unwind_Context +Security:single module:__Unwind_GetIP +Security:single module:__Z28read_encoded_value_with_basehjPKhPj +Security:single module:__Z12read_sleb128PKhPi +Security:single module:__Z15get_ttype_entryP16lsda_header_infoj +Security:single module:__Z21size_of_encoded_valueh +Security:single module:__Z16get_adjusted_ptrPKSt9type_infoS1_PPv +Security:single module:__ZNKSt9type_info14__is_pointer_pEv +Security:single module:__ZNK10__cxxabiv117__class_type_info10__do_catchEPKSt9type_infoPPvj +Security:single module:__ZNK10__cxxabiv117__class_type_info11__do_upcastEPKS0_PPv +Security:single module:__ZNK10__cxxabiv120__si_class_type_info11__do_upcastEPKNS_17__class_type_infoEPKvRNS1_15__upcast_resultE +Security:single module:__ZNK10__cxxabiv117__class_type_info11__do_upcastEPKS0_PKvRNS0_15__upcast_resultE +Security:single module:__Unwind_RaiseException_Phase2 +Security:single module:__Unwind_SetGR +Security:single module:__Unwind_SetIP +Security:single module:_uw_install_context_1 +Security:single module:_init_dwarf_reg_size_table +Security:single module:eh_rest_world_r10 +Security:single module:rest_world_eh_r7r8 +Security:single module:__Unwind_Resume +Security:single module:___cxa_begin_catch +Security:single module:__ZNK8Security15CssmCommonError9cssmErrorEl +Security:single module:__ZNK8Security9CssmError9cssmErrorEv +Security:single module:__ZN8Security9CssmError5mergeEll +Security:single module:___cxa_end_catch +Security:single module:___cxa_get_globals_fast +Security:single module:__Unwind_DeleteException +Security:single module:__Z23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception +Security:single module:__ZN8Security15CssmCommonErrorD2Ev +Security:single module:__ZN8Security15CssmCommonErrorD4Ev +Security:single module:__ZNSt9exceptionD2Ev +Security:single module:__ZNSt9exceptionD4Ev +Security:single module:___cxa_free_exception +Security:single module:_CSSM_ModuleDetach +Security:single module:__ZN8Security12HandleObject5State5eraseERN9__gnu_cxx19_Hashtable_iteratorISt4pairIKmPS0_EmNS2_4hashImEESt10_Select1stIS7_ESt8equal_toImESaIS6_EEE +Security:single module:__ZN10Attachment6detachEb +Security:single module:__ZN8Security10CssmPlugin12moduleDetachEm +Security:single module:__ZN8Security13PluginSession6detachEv +Security:single module:__ZN11SSDLSessionD0Ev +Security:single module:__ZN11SSDLSessionD4Ev +Security:single module:__ZN8Security15DatabaseSessionD2Ev +Security:single module:__ZN8Security15DatabaseSessionD4Ev +Security:single module:__ZN8Security13PluginSessionD2Ev +Security:single module:__ZN8Security13PluginSessionD4Ev +Security:single module:__ZN6Module6detachEP10Attachment +Security:single module:__ZN10AttachmentD2Ev +Security:single module:__ZN10AttachmentD4Ev +Security:single module:__ZN8Security5MutexD2Ev +Security:single module:__ZN8Security10CssmClient6DLImplD0Ev +Security:single module:_CSSM_ModuleUnload +Security:single module:__ZN11CssmManager12unloadModuleERKN8Security4GuidERKNS0_14ModuleCallbackE +Security:single module:__ZN6Module6unloadERKN8Security14ModuleCallbackE +Security:single module:__ZN8Security10CssmPlugin12moduleUnloadERKNS_4GuidES3_RKNS_14ModuleCallbackE +Security:single module:__ZN8Security10CssmPlugin6unloadEv +Security:single module:__ZN8Security17ModuleCallbackSet5eraseERKNS_14ModuleCallbackE +Security:single module:__ZN6ModuleD0Ev +Security:single module:__ZN6ModuleD4Ev +Security:single module:__ZN12MdsComponentD2Ev +Security:single module:__ZN8Security10CssmClient11GenerateMac4signEPKNS_8CssmDataEmRS2_ +Security:single module:_CSSM_GenerateMac +Security:single module:__Z16cssm_GenerateMacmyPK12cssm_contextPK9cssm_datamPS2_ +Security:single module:__ZThn40_N8Security20CSPFullPluginSession11GenerateMacEyRKNS_7ContextEPKNS_8CssmDataEmRS4_ +Security:single module:__ZN8Security20CSPFullPluginSession11GenerateMacEyRKNS_7ContextEPKNS_8CssmDataEmRS4_ +Security:single module:__ZN8Security20CSPFullPluginSession15GenerateMacInitEyRKNS_7ContextE +Security:single module:__ZN8Security20CSPFullPluginSession17GenerateMacUpdateEyPKNS_8CssmDataEm +Security:single module:__ZN8Security20CSPFullPluginSession16GenerateMacFinalEyRNS_8CssmDataE +Security:single module:__ZN10MacContext10outputSizeEbm +Security:single module:__ZN10MacContext5finalERN8Security8CssmDataE +Security:single module:__ZN11GAESContextC1ER15AppleCSPSession +Security:single module:__ZN11GAESContextC4ER15AppleCSPSession +Security:single module:__ZN11GladmanInit9genTablesEv +Security:single module:_gen_tabs +Security:single module:__ZN11GAESContext4initERKN8Security7ContextEb +Security:single module:__ZN11GAESContext9deleteKeyEv +Security:single module:_set_key +Security:single module:__ZN11GAESContext12decryptBlockEPKvPvRmb +Security:single module:_rDecrypt +Security:single module:__ZN8Security10CssmClient7Encrypt7encryptEPKNS_8CssmDataEmPS2_mRS2_ +Security:single module:_CSSM_EncryptData +Security:single module:__Z16cssm_EncryptDatamyPK12cssm_contextPK9cssm_datamPS2_mPmS5_y +Security:single module:__ZThn40_N8Security20CSPFullPluginSession11EncryptDataEyRKNS_7ContextEPKNS_8CssmDataEmPS4_mRmRS4_y +Security:single module:__ZN8Security20CSPFullPluginSession11EncryptDataEyRKNS_7ContextEPKNS_8CssmDataEmPS4_mRmRS4_y +Security:single module:__ZN11GAESContext12encryptBlockEPKvmPvRmb +Security:single module:_rEncrypt +Security:single module:_SecTrustedApplicationIsUpdateCandidate +Security:single module:__ZN8Security12MachPlusPlus7MessageD1Ev +Security:single module:__ZN8Security12MachPlusPlus7MessageD4Ev +Security:single module:__ZN8Security12MachPlusPlus10MachServer10LoadThread6actionEv +Security:single module:__ZN8Security12MachPlusPlus10MachServer12removeThreadEPNS_6ThreadE +Security:single module:__ZN8Security6Thread6runnerEPv +Security:single module:__ZN8Security6ThreadD2Ev +Security:single module:__ZN8Security6ThreadD4Ev +Security:single module:__Z16get_globals_dtorPv +Security:single module:_SecTrustedApplicationCreateFromPath +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC1EPKc +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC4EPKc +Security:single module:__ZN8Security11CodeSigning9OSXSignerC1Ev +Security:single module:__ZN8Security11CodeSigning9OSXSignerC4Ev +Security:single module:__ZN8Security11CodeSigning7OSXCode2atEPKc +Security:single module:__ZNK8Security11CodeSigning13GenericBundle12scanContentsERNS0_6Signer5StateE +Security:single module:__ZNK8Security11CodeSigning13GenericBundle13canonicalPathEv +Security:single module:__ZN8Security11CodeSigning13GenericBundleD0Ev +Security:single module:__ZN8Security10CssmClient7CSPImplD0Ev +Security:single module:__ZN15AppleCSPSessionD0Ev +Security:single module:__ZN15AppleCSPSessionD4Ev +Security:single module:__ZN11GAESContextD0Ev +Security:single module:__ZN11GAESContextD4Ev +Security:single module:_SecTrustedApplicationMakeEquivalent +Security:single module:__ZNK8Security12KeychainCore18TrustedApplication9signatureEv +Security:single module:__ZNK8Security12KeychainCore18TrustedApplication4pathEv +Security:single module:__ZN8Security14SecurityServer13ClientSession18addCodeEquivalenceERKNS_8CssmDataES4_PKcb +Security:single module:_ucsp_client_addCodeEquivalence +Security:single module:__ZN8Security12UnixPlusPlus6UnixDb3putERKNS_8CssmDataES4_i +Security:single module:__ZN8Security12UnixPlusPlus6UnixDb5flushEi +Security:single module:__Z40__MIG_check__Reply__addCodeEquivalence_tP29__Reply__addCodeEquivalence_t +Security:single module:_SecKeychainCopySearchList +Security:single module:__ZN8Security12KeychainCore14StorageManager23convertFromKeychainListERKSt6vectorINS0_8KeychainESaIS3_EE +Security:single module:_SecKeychainSearchCreateFromAttributes +Security:single module:__ZN8Security12KeychainCore14StorageManager21convertToKeychainListEPK9__CFArrayRSt6vectorINS0_8KeychainESaIS6_EE +Security:single module:_SecKeychainSearchCopyNext +Security:single module:__ZN8Security12KeychainCore6Schema12itemClassForEm +Security:single module:__ZN8Security12KeychainCore7CFClass8hashTypeEPKv +Security:single module:__ZN8Security12KeychainCore11SecCFObject4hashEv +Security:single module:__ZN8Security12KeychainCore7CFClass9equalTypeEPKvS3_ +Security:single module:__ZN8Security12KeychainCore11SecCFObject5equalERS1_ +Security:single module:__ZN8Security12MachPlusPlus10MachServer10clearTimerEPNS1_5TimerE +Security:single module:_SSLNewContext +Security:single module:_sslMalloc +Security:single module:_attachToAll +Security:single module:_attachToModules +Security:single module:__ZN14ModuleAttacher14loadAllModulesERmS0_S0_ +Security:single module:__ZN14ModuleAttacher10loadModuleEmPK9cssm_guidPKc +Security:single module:__ZN14ModuleAttacher8initCssmEv +Security:single module:__ZN11AppleX509CL11makeSessionEmRK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN18AppleX509CLSessionC1EmRN8Security10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN18AppleX509CLSessionC4EmRN8Security10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN8Security15CLPluginSession9constructEv +Security:single module:__ZN7AppleTP11makeSessionEmRK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN14AppleTPSessionC1EmRN8Security10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN14AppleTPSessionC4EmRN8Security10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN8Security15TPPluginSession9constructEv +Security:single module:_SSLSetAllowsExpiredCerts +Security:single module:_sslIsSessionActive +Security:single module:_SSLSetAllowsExpiredRoots +Security:single module:_SSLSetAllowsAnyRoot +Security:single module:_SSLSetEnableCertVerify +Security:single module:_SSLSetPeerDomainName +Security:single module:_SSLSetProtocolVersion +Security:single module:_SSLGetSessionState +Security:single module:_SSLSetIOFuncs +Security:single module:_SSLSetConnection +Security:single module:_SSLDisposeContext +Security:single module:_sslDeleteCertificateChain +Security:single module:_SSLFreeBuffer +Security:single module:_sslFree +Security:single module:_sslFreeKey +Security:single module:_CloseHash +Security:single module:_SSLDisposeCipherSuite +Security:single module:__Z11ssl3FreeMacP13CipherContext +Security:single module:__Z19sslFreeTrustedRootsP10SSLContext +Security:single module:__Z13sslFreeDnListP10SSLContext +Security:single module:_detachFromAll +Security:single module:_sslCleanupSession +Security:single module:__ZN12SessionCache7cleanupEv +Security:single module:_SSLHandshake +Security:single module:_sslBuildCipherSpecArray +Security:single module:__Z19SSLHandshakeProceedP10SSLContext +Security:single module:__Z17SSLInitConnectionP10SSLContext +Security:single module:_SSL2AdvanceHandshake +Security:single module:_SSLInitMessageHashes +Security:single module:_ReadyHash +Security:single module:_SSLAllocBuffer +Security:single module:__Z12HashSHA1InitR9SSLBufferP10SSLContext +Security:single module:__Z12cdsaHashInitR9SSLBufferP10SSLContextm +Security:single module:_attachToCsp +Security:single module:_stAppMalloc +Security:single module:_stAppFree +Security:single module:__Z11HashMD5InitR9SSLBufferP10SSLContext +Security:single module:__ZN9MD5Object10digestInitEv +Security:single module:_MD5Init +Security:single module:_SSL2PrepareAndQueueMessage +Security:single module:_SSL2EncodeClientHello +Security:single module:_sslGetMaxProtVersion +Security:single module:_SSLEncodeInt +Security:single module:_sslRand +Security:single module:__ZN8Security18DevRandomGeneratorC1Eb +Security:single module:__ZN8Security18DevRandomGeneratorC4Eb +Security:single module:__ZN8Security12UnixPlusPlus8FileDesc4openEPKcit +Security:single module:_ssl3WriteRecord +Security:single module:_SSL2WriteRecord +Security:single module:__Z9NullCrypt9SSLBufferS_P13CipherContextP10SSLContext +Security:single module:_IncrementUInt64 +Security:single module:__Z14cdsaHashUpdateR9SSLBufferRKS_ +Security:single module:__ZN9MD5Object12digestUpdateEPKvm +Security:single module:_MD5Update +Security:single module:_MD5Transform +Security:single module:__Z20SSLServiceWriteQueueP10SSLContext +Security:single module:_sslIoWrite +Security:single module:_SSLReadRecord +Security:single module:_sslIoRead +Security:single module:_SSLDecodeInt +Security:single module:__Z17ssl3DecryptRecordhP9SSLBufferP10SSLContext +Security:single module:__Z25SSLProcessProtocolMessageR9SSLRecordP10SSLContext +Security:single module:_SSLProcessHandshakeRecord +Security:single module:__Z26SSLProcessHandshakeMessage15SSLHandshakeMsgP10SSLContext +Security:single module:_SSLProcessServerHello +Security:single module:_sslVerifyProtVersion +Security:single module:_FindCipherSpec +Security:single module:_sslVerifyNegotiatedCipher +Security:single module:_SSLAdvanceHandshake +Security:single module:__Z17tls1DecryptRecordhP9SSLBufferP10SSLContext +Security:single module:_SSLProcessCertificate +Security:single module:_sslVerifyCertChain +Security:single module:_SSLGetCertificateChainLength +Security:single module:_SecCertificateCreateFromData +Security:single module:__ZN8Security12KeychainCore11CertificateC1ERK9cssm_datamm +Security:single module:__ZN8Security12KeychainCore11CertificateC4ERK9cssm_datamm +Security:single module:__ZN8Security12KeychainCore8ItemImplC2EmP24SecKeychainAttributeListmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImplC4EmP24SecKeychainAttributeListmPKv +Security:single module:__ZN8Security12KeychainCore11Certificate9clForTypeEm +Security:single module:__ZN8Security10CssmClient6CLImplC1ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient6CLImplC4ERKNS_4GuidE +Security:single module:_SecPolicySearchCreate +Security:single module:__ZN8Security12KeychainCore12PolicyCursorC1EPK9cssm_dataS4_ +Security:single module:__ZN8Security12KeychainCore12PolicyCursorC4EPK9cssm_dataS4_ +Security:single module:_SecPolicySearchCopyNext +Security:single module:__ZN8Security12KeychainCore12PolicyCursor4nextERNS0_10SecPointerINS0_6PolicyEEE +Security:single module:__ZN8Security10CssmClient6TPImplC1ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient6TPImplC4ERKNS_4GuidE +Security:single module:__ZN8Security12KeychainCore6PolicyC1ENS_10CssmClient2TPERKNS_8CssmDataE +Security:single module:__ZN8Security12KeychainCore6PolicyC4ENS_10CssmClient2TPERKNS_8CssmDataE +Security:single module:_SecPolicySetValue +Security:single module:_SecTrustCreateWithCertificates +Security:single module:__ZN8Security12KeychainCore5TrustC1EPKvS3_ +Security:single module:__ZN8Security12KeychainCore5TrustC4EPKvS3_ +Security:single module:_SecTrustSetParameters +Security:single module:_SecTrustSetKeychains +Security:single module:_SecTrustEvaluate +Security:single module:__ZN8Security12KeychainCore5Trust8evaluateEv +Security:single module:__ZN8Security12KeychainCore5Trust12clearResultsEv +Security:single module:__Z17cfCertificateDataP23OpaqueSecCertificateRef +Security:single module:__ZN8Security12KeychainCore11Certificate4dataEv +Security:single module:__ZN8Security9CertGroupC1Emmm +Security:single module:__ZN8Security9CertGroupC4Emmm +Security:single module:__ZN8Security10CssmClient20TPBuildVerifyContextC1EmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient20TPBuildVerifyContextC4EmRNS_13CssmAllocatorE +Security:single module:__Z7cfFieldP18OpaqueSecPolicyRef +Security:single module:__ZN8Security12KeychainCore10TrustStoreC1ERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore10TrustStoreC4ERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore10TrustStore20copyRootCertificatesEv +Security:single module:__ZN8Security12KeychainCore10TrustStore20loadRootCertificatesEv +Security:single module:__ZN8Security12KeychainCore10TrustStore23refreshRootCertificatesEv +Security:single module:__ZN8Security10CssmClient6DLImplC1ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient6DLImplC4ERKNS_4GuidE +Security:single module:__ZThn64_N8Security10CssmClient6DLImpl5newDbEPKcPK16cssm_net_address +Security:single module:__ZN8Security10CssmClient6DLImpl5newDbEPKcPK16cssm_net_address +Security:single module:__ZN8Security10CssmClient6DbImplC1ERKNS0_2DLEPKcPK16cssm_net_address +Security:single module:__ZThn24_N8Security10CssmClient6DbImpl17newDbUniqueRecordEv +Security:single module:__ZN8Security10CssmClient6DbImpl17newDbUniqueRecordEv +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImplC1ERKNS0_2DbE +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImplD0Ev +Security:single module:__ZN8Security10CssmClient6DbImplD0Ev +Security:single module:__ZN8Security10CssmClient6TPImpl15certGroupVerifyERKNS_9CertGroupERKNS_15TPVerifyContextEPNS_14TPVerifyResultE +Security:single module:__ZN8Security10CssmClient6TPImpl7setupCLEv +Security:single module:__ZN8Security10CssmClient6TPImpl8setupCSPEv +Security:single module:_CSSM_TP_CertGroupVerify +Security:single module:__Z20cssm_CertGroupVerifymmmPK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_result +Security:single module:__ZThn40_N14AppleTPSession15CertGroupVerifyEmmRK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_result +Security:single module:__ZN14AppleTPSession15CertGroupVerifyEmmRK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_result +Security:single module:__ZN11TPCertGroupC1ERN8Security13CssmAllocatorE12TPGroupOwner +Security:single module:__ZN11TPCertGroupC4ERN8Security13CssmAllocatorE12TPGroupOwner +Security:single module:__ZN11TPCertGroupC1ERK14cssm_certgroupmmRN8Security13CssmAllocatorEPKcb12TPGroupOwner +Security:single module:__ZN11TPCertGroupC4ERK14cssm_certgroupmmRN8Security13CssmAllocatorEPKcb12TPGroupOwner +Security:single module:__ZN10TPCertInfoC1EmmPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN10TPCertInfoC4EmmPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN12TPClItemInfoC2EmmRK13TPClItemCallsPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN12TPClItemInfoC4EmmRK13TPClItemCallsPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN12TPClItemInfo9cacheItemEPK9cssm_data10TPItemCopy +Security:single module:_CSSM_CL_CertCache +Security:single module:__Z14cssm_CertCachemPK9cssm_dataPm +Security:single module:__ZThn40_N18AppleX509CLSession9CertCacheERKN8Security8CssmDataERm +Security:single module:__ZN18AppleX509CLSession9CertCacheERKN8Security8CssmDataERm +Security:single module:__ZN11DecodedCertC1ER18AppleX509CLSessionRKN8Security8CssmDataE +Security:single module:__ZN11DecodedCertC4ER18AppleX509CLSessionRKN8Security8CssmDataE +Security:single module:__ZN11DecodedItemC2ER18AppleX509CLSession +Security:single module:__ZN11DecodedItemC4ER18AppleX509CLSession +Security:single module:__ZN11SecNssCoderC1Ej +Security:single module:__ZN11SecNssCoderC4Ej +Security:single module:_PORT_NewArena +Security:single module:_PORT_ZAlloc +Security:single module:_PR_Calloc +Security:single module:_PR_NewLock +Security:single module:_PR_Malloc +Security:single module:_PL_InitArenaPool +Security:single module:_PR_CeilingLog2 +Security:single module:__ZN17DecodedExtensionsC1ER11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:__ZN17DecodedExtensionsC4ER11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:__ZN11SecNssCoder6decodeEPKvmPK23sec_ASN1Template_structPv +Security:single module:_SEC_ASN1Decode +Security:single module:_SEC_ASN1DecoderStart +Security:single module:_PORT_ArenaZAlloc +Security:single module:_PORT_ArenaAlloc +Security:single module:_PR_Lock +Security:single module:_PL_ArenaAllocate +Security:single module:_LockArena +Security:single module:_UnlockArena +Security:single module:_PR_Unlock +Security:single module:_sec_asn1d_push_state +Security:single module:_sec_asn1d_zalloc +Security:single module:_sec_asn1d_alloc +Security:single module:_sec_asn1d_init_state_based_on_template +Security:single module:_sec_asn1d_scrub_state +Security:single module:_SEC_ASN1DecoderUpdate +Security:single module:_sec_asn1d_parse_identifier +Security:single module:_sec_asn1d_confirm_identifier +Security:single module:_sec_asn1d_parse_length +Security:single module:_sec_asn1d_parse_more_length +Security:single module:_sec_asn1d_prepare_for_contents +Security:single module:_PORT_ArenaMark +Security:single module:_sec_asn1d_notify_before +Security:single module:_SEC_ASN1GetSubtemplate +Security:single module:_sec_asn1d_parse_leaf +Security:single module:_sec_asn1d_prepare_for_end_of_contents +Security:single module:_sec_asn1d_pop_state +Security:single module:_sec_asn1d_free_child +Security:single module:_sec_asn1d_absorb_child +Security:single module:_PORT_ArenaRelease +Security:single module:_sec_asn1d_next_in_sequence +Security:single module:_sec_asn1d_notify_after +Security:single module:_sec_asn1d_record_any_header +Security:single module:_sec_asn1d_add_to_subitems +Security:single module:_sec_asn1d_next_substring +Security:single module:_sec_asn1d_concat_substrings +Security:single module:_sec_asn1d_reuse_encoding +Security:single module:__Z14NSS_ATVChooserPviPKcS_ +Security:single module:_NSS_TaggedTemplateChooser +Security:single module:_sec_asn1d_next_in_group +Security:single module:_sec_asn1d_concat_group +Security:single module:_NSS_TimeChooser +Security:single module:_sec_asn1d_parse_bit_string +Security:single module:_sec_asn1d_parse_more_bit_string +Security:single module:_SEC_ASN1DecoderFinish +Security:single module:_PORT_FreeArena +Security:single module:_PL_FinishArenaPool +Security:single module:_FreeArenaList +Security:single module:_PR_Free +Security:single module:_PORT_ZFree +Security:single module:_PR_DestroyLock +Security:single module:__ZN17DecodedExtensions13decodeFromNssEPP17NSS_CertExtension +Security:single module:__Z14clNssArraySizePPKv +Security:single module:_clOidToNssInfo +Security:single module:__Z17clCompareCssmDataPK9cssm_dataS1_ +Security:single module:__ZN11SecNssCoder6mallocEm +Security:single module:__Z15clNssBoolToCssmRK9cssm_data +Security:single module:__ZN17DecodedExtensions12addExtensionERK9cssm_databPvbPK23sec_ASN1Template_structPS1_ +Security:single module:__ZN8Security13PluginSession7reallocEPvm +Security:single module:__ZN10Attachment13upcallReallocEmPvm +Security:single module:__ZN8Security28CssmMemoryFunctionsAllocator7reallocEPvm +Security:single module:__ZN8Security28CssmAllocatorMemoryFunctions12relayReallocEPvmS1_ +Security:single module:__ZN12DecodedExtenC1ERK9cssm_databPvbPK23sec_ASN1Template_structR11SecNssCoderPS1_ +Security:single module:__ZN12DecodedExtenC4ERK9cssm_databPvbPK23sec_ASN1Template_structR11SecNssCoderPS1_ +Security:single module:__ZN11SecNssCoder13allocCopyItemEPKvmR9cssm_data +Security:single module:__ZN11SecNssCoder9allocItemER9cssm_datam +Security:single module:__ZN13CLCachedEntryC2Ev +Security:single module:__ZN13CLCachedEntryC4Ev +Security:single module:__ZN12TPClItemInfo10fetchFieldEPK9cssm_dataPPS0_ +Security:single module:_CSSM_CL_CertGetFirstCachedFieldValue +Security:single module:__Z33cssm_CertGetFirstCachedFieldValuemmPK9cssm_dataPmS2_PPS_ +Security:single module:__ZThn40_N18AppleX509CLSession28CertGetFirstCachedFieldValueEmRKN8Security8CssmDataERmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession28CertGetFirstCachedFieldValueEmRKN8Security8CssmDataERmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession16lookupCachedCertEm +Security:single module:__ZN11DecodedCert16getCertFieldDataERKN8Security8CssmDataEjRmRNS0_13CssmOwnedDataE +Security:single module:__Z11oidToFieldsRKN8Security8CssmDataE +Security:single module:__Z18getFieldIssuerNormR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:_getField_normRDN_NSS +Security:single module:__Z23CL_normalizeX509NameNSSR8NSS_NameR11SecNssCoder +Security:single module:__Z18CL_normalizeStringPcRi +Security:single module:__Z21SecNssEncodeItemOdataPKvPK23sec_ASN1Template_structRN8Security13CssmOwnedDataE +Security:single module:__Z16SecNssEncodeItemPKvPK23sec_ASN1Template_structRN8Security13CssmAllocatorER9cssm_data +Security:single module:_SEC_ASN1Encode +Security:single module:_SEC_ASN1EncoderStart +Security:single module:_sec_asn1e_push_state +Security:single module:_sec_asn1e_init_state_based_on_template +Security:single module:_sec_asn1e_scrub_state +Security:single module:_SEC_ASN1EncoderUpdate +Security:single module:_sec_asn1e_write_header +Security:single module:_sec_asn1e_contents_length +Security:single module:_SEC_ASN1LengthLength +Security:single module:_sec_asn1e_write_identifier_bytes +Security:single module:_sec_asn1e_write_part +Security:single module:_sec_asn1e_encode_item_count +Security:single module:_sec_asn1e_write_length_bytes +Security:single module:_SEC_ASN1EncodeLength +Security:single module:_sec_asn1e_notify_before +Security:single module:_sec_asn1e_write_contents +Security:single module:_sec_asn1e_write_contents_bytes +Security:single module:_sec_asn1e_after_contents +Security:single module:_sec_asn1e_next_in_sequence +Security:single module:_sec_asn1e_notify_after +Security:single module:_sec_asn1e_next_in_group +Security:single module:_SEC_ASN1EncoderFinish +Security:single module:_sec_asn1e_encode_item_store +Security:single module:__ZN11SecNssCoderD1Ev +Security:single module:__ZN11SecNssCoderD4Ev +Security:single module:__ZN7CLQueryC1E11CLQueryTypeRKN8Security8CssmDataEjbm +Security:single module:__ZN7CLQueryC4E11CLQueryTypeRKN8Security8CssmDataEjbm +Security:single module:__ZN8Security12CssmAutoData7releaseEv +Security:single module:_CSSM_CL_CertAbortQuery +Security:single module:__Z19cssm_CertAbortQuerymm +Security:single module:__ZThn40_N18AppleX509CLSession14CertAbortQueryEm +Security:single module:__ZN18AppleX509CLSession14CertAbortQueryEm +Security:single module:__ZN7CLQueryD1Ev +Security:single module:__ZN7CLQueryD4Ev +Security:single module:__Z17getField_TbsAlgIdR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:_tbsGetCheck +Security:single module:_getField_AlgIdNSS +Security:single module:__Z12CL_copyAlgIdRK30cssm_x509_algorithm_identifierRS_RN8Security13CssmAllocatorE +Security:single module:__Z15clAllocCopyDataRN8Security13CssmAllocatorERK9cssm_dataRS2_ +Security:single module:__Z11clAllocDataRN8Security13CssmAllocatorER9cssm_datam +Security:single module:_cssmOidToAlg +Security:single module:_compareCssmData +Security:single module:__ZN12TPClItemInfo9freeFieldEPK9cssm_dataPS0_ +Security:single module:_CSSM_CL_FreeFieldValue +Security:single module:__Z19cssm_FreeFieldValuemPK9cssm_dataPS_ +Security:single module:__ZThn40_N18AppleX509CLSession14FreeFieldValueERKN8Security8CssmDataERS1_ +Security:single module:__ZN18AppleX509CLSession14FreeFieldValueERKN8Security8CssmDataERS1_ +Security:single module:__ZN11DecodedCert17freeCertFieldDataERKN8Security8CssmDataERNS0_13CssmOwnedDataE +Security:single module:_freeField_AlgId +Security:single module:__ZN8Security14CssmRemoteData5resetEv +Security:single module:__ZN8Security14CssmRemoteData7releaseEv +Security:single module:__ZN12TPClItemInfo19fetchNotBeforeAfterEv +Security:single module:__Z18getField_NotBeforeR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:_getField_TimeNSS +Security:single module:__Z16CL_nssTimeToCssmRK14NSS_TaggedItemR14cssm_x509_timeRN8Security13CssmAllocatorE +Security:single module:_timeStringToTm +Security:single module:__Z17getField_NotAfterR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:_freeField_Time +Security:single module:__Z15CL_freeCssmTimeP14cssm_x509_timeRN8Security13CssmAllocatorE +Security:single module:__ZN12TPClItemInfo16calculateCurrentEPKc +Security:single module:_nowTime +Security:single module:_compareTimes +Security:single module:__Z19getFieldSubjectNormR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:_CSSM_CL_CertGetKeyInfo +Security:single module:__Z19cssm_CertGetKeyInfomPK9cssm_dataPP8cssm_key +Security:single module:__ZThn40_N18AppleX509CLSession14CertGetKeyInfoERKN8Security8CssmDataERP8cssm_key +Security:single module:__ZN18AppleX509CLSession14CertGetKeyInfoERKN8Security8CssmDataERP8cssm_key +Security:single module:__ZNK11DecodedCert14extractCSSMKeyERN8Security13CssmAllocatorE +Security:single module:__Z20CL_extractCSSMKeyNSSRK33cssm_x509_subject_public_key_infoRN8Security13CssmAllocatorEPK11DecodedCert +Security:single module:__Z11CL_oidToAlgRK9cssm_data +Security:single module:__ZNK11DecodedCert13inferKeyUsageEv +Security:single module:__ZNK11DecodedItem14findDecodedExtERK9cssm_databmRm +Security:single module:__ZNK17DecodedExtensions12getExtensionEj +Security:single module:__Z21clBitStringToKeyUsageRK9cssm_data +Security:single module:_getGlobalCspHand +Security:single module:__ZN11CSPAttacher10getCspHandEb +Security:single module:_CSSM_QueryKeySizeInBits +Security:single module:__Z23cssm_QueryKeySizeInBitsmyPK12cssm_contextPK8cssm_keyP13cssm_key_size +Security:single module:__ZThn40_N8Security20CSPFullPluginSession18QueryKeySizeInBitsEyPKNS_7ContextEPKNS_7CssmKeyER13cssm_key_size +Security:single module:__ZN8Security20CSPFullPluginSession18QueryKeySizeInBitsEyPKNS_7ContextEPKNS_7CssmKeyER13cssm_key_size +Security:single module:__ZN15AppleCSPSession10getKeySizeERKN8Security7CssmKeyER13cssm_key_size +Security:single module:__ZN18RSAKeyInfoProviderC4ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN18RSAKeyInfoProvider18QueryKeySizeInBitsER13cssm_key_size +Security:single module:_rawCssmKeyToRsa +Security:single module:_RSA_new +Security:single module:_RSA_new_method +Security:single module:_RSA_PKCS1_SSLeay +Security:single module:_CRYPTO_malloc +Security:single module:__Z8osMallocm +Security:single module:_RSA_eay_init +Security:single module:_CRYPTO_new_ex_data +Security:single module:_RSAPublicKeyDecode +Security:single module:_BN_new +Security:single module:_BN_bin2bn +Security:single module:_bn_expand2 +Security:single module:_RSA_size +Security:single module:_BN_num_bits +Security:single module:_RSA_free +Security:single module:_CRYPTO_add_lock +Security:single module:_CRYPTO_free_ex_data +Security:single module:_RSA_eay_finish +Security:single module:_BN_clear_free +Security:single module:_CRYPTO_free +Security:single module:__Z6osFreePv +Security:single module:__ZN11DecodedCertD1Ev +Security:single module:__ZN11DecodedCertD4Ev +Security:single module:__ZN11DecodedItemD2Ev +Security:single module:__ZN11DecodedItemD4Ev +Security:single module:__ZN17DecodedExtensionsD1Ev +Security:single module:__ZN17DecodedExtensionsD4Ev +Security:single module:__ZN12DecodedExtenD1Ev +Security:single module:__ZN12DecodedExtenD4Ev +Security:single module:_tpCompareCssmData +Security:single module:__ZN11TPCertGroup10appendCertEP10TPCertInfo +Security:single module:__ZN14AppleTPSession22CertGroupConstructPrivEmmR11TPCertGroupPK15cssm_dl_db_listPKcmPK9cssm_datamS1_RlSA_S1_ +Security:single module:__ZN11TPCertGroup11certAtIndexEj +Security:single module:__ZN11TPCertGroup12setAllUnusedEv +Security:single module:__ZN11TPCertGroup14buildCertGroupERK12TPClItemInfoPS_PK15cssm_dl_db_listmmPKcmPK9cssm_dataRS_S3_lmRlSD_ +Security:single module:__ZN11TPCertGroup8lastCertEv +Security:single module:__ZN11TPCertGroup22findIssuerForCertOrCrlERK12TPClItemInfoRb +Security:single module:__ZN10TPCertInfo10isIssuerOfERK12TPClItemInfo +Security:single module:_tpDbFindIssuerCert +Security:single module:__Z19cssm_CertAbortCachemm +Security:single module:__ZThn40_N18AppleX509CLSession14CertAbortCacheEm +Security:single module:__ZN18AppleX509CLSession14CertAbortCacheEm +Security:single module:__ZN12CLCachedCertD0Ev +Security:single module:__ZN12CLCachedCertD4Ev +Security:single module:__ZN11DecodedCertD0Ev +Security:single module:_CSSM_CL_CertAbortCache +Security:single module:__ZN12TPClItemInfo16releaseResourcesEv +Security:single module:__ZN10TPCertInfoD4Ev +Security:single module:__ZN12TPClItemInfoD2Ev +Security:single module:__ZN12TPClItemInfoD4Ev +Security:single module:__ZNK12TPClItemInfo16verifyWithIssuerEP10TPCertInfoS1_ +Security:single module:__ZN10TPCertInfo13hasPartialKeyEv +Security:single module:_CSSM_CSP_CreateSignatureContext +Security:single module:_CSSM_CL_CertVerify +Security:single module:__Z15cssm_CertVerifymyPK9cssm_dataS1_PK10cssm_fieldm +Security:single module:__ZThn40_N18AppleX509CLSession10CertVerifyEyRKN8Security8CssmDataEPS2_PK10cssm_fieldm +Security:single module:__ZN18AppleX509CLSession10CertVerifyEyRKN8Security8CssmDataEPS2_PK10cssm_fieldm +Security:single module:__Z26CL_certCrlDecodeComponentsRKN8Security8CssmDataERNS_13CssmOwnedDataES4_S4_ +Security:single module:__ZN18AppleX509CLSession10verifyDataEyRKN8Security8CssmDataES3_ +Security:single module:_CSSM_VerifyData +Security:single module:__Z15cssm_VerifyDatamyPK12cssm_contextPK9cssm_datammS4_ +Security:single module:__ZThn40_N8Security20CSPFullPluginSession10VerifyDataEyRKNS_7ContextEPKNS_8CssmDataEmmRS5_ +Security:single module:__ZN8Security20CSPFullPluginSession10VerifyDataEyRKNS_7ContextEPKNS_8CssmDataEmmRS5_ +Security:single module:__ZN8Security20CSPFullPluginSession14VerifyDataInitEyRKNS_7ContextE +Security:single module:__ZN16SignatureContext4initERKN8Security7ContextEb +Security:single module:__ZN9RSASigner10signerInitERKN8Security7ContextEb +Security:single module:__ZN9RSASigner14keyFromContextERKN8Security7ContextE +Security:single module:_contextToRsaKey +Security:single module:_cssmKeyToRsa +Security:single module:_RSA_blinding_off +Security:single module:__ZN8Security20CSPFullPluginSession16VerifyDataUpdateEyPKNS_8CssmDataEm +Security:single module:__ZN16SignatureContext6updateERKN8Security8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession15VerifyDataFinalEyRKNS_8CssmDataE +Security:single module:__ZN16SignatureContext5finalERKN8Security8CssmDataE +Security:single module:__ZN9RSASigner6verifyEPKvmS1_m +Security:single module:_generateDigestInfo +Security:single module:_RSA_public_decrypt +Security:single module:_RSA_eay_public_decrypt +Security:single module:_BN_init +Security:single module:_BN_CTX_new +Security:single module:_BN_MONT_CTX_new +Security:single module:_BN_MONT_CTX_set +Security:single module:_BN_copy +Security:single module:_BN_set_word +Security:single module:_BN_set_bit +Security:single module:_BN_mod_inverse +Security:single module:_BN_CTX_start +Security:single module:_BN_CTX_get +Security:single module:_BN_div +Security:single module:_BN_ucmp +Security:single module:_BN_lshift +Security:single module:_bn_div_words +Security:single module:_BN_num_bits_word +Security:single module:_bn_mul_words +Security:single module:_BN_sub +Security:single module:_BN_usub +Security:single module:_BN_rshift +Security:single module:_BN_CTX_end +Security:single module:_BN_mul +Security:single module:_BN_add +Security:single module:_BN_uadd +Security:single module:_bn_add_words +Security:single module:_bn_mul_normal +Security:single module:_BN_mod +Security:single module:_BN_sub_word +Security:single module:_BN_free +Security:single module:_BN_mod_exp_mont +Security:single module:_BN_mod_mul_montgomery +Security:single module:_bn_mul_recursive +Security:single module:_bn_cmp_words +Security:single module:_bn_sub_words +Security:single module:_bn_mul_comba8 +Security:single module:_BN_from_montgomery +Security:single module:_bn_mul_add_words +Security:single module:_BN_value_one +Security:single module:_BN_is_bit_set +Security:single module:_BN_sqr +Security:single module:_bn_sqr_recursive +Security:single module:_bn_sqr_comba8 +Security:single module:_BN_bn2bin +Security:single module:_RSA_padding_check_PKCS1_type_1 +Security:single module:_BN_CTX_free +Security:single module:__Z14CL_freeCSSMKeyP8cssm_keyRN8Security13CssmAllocatorEb +Security:single module:__ZN16SignatureContextD0Ev +Security:single module:__ZN16SignatureContextD4Ev +Security:single module:__ZN9RSASignerD0Ev +Security:single module:__ZN9RSASignerD4Ev +Security:single module:_BN_MONT_CTX_free +Security:single module:__ZN10TPCertInfoD1Ev +Security:single module:__ZN10TPCertInfo16releaseResourcesEv +Security:single module:_tpFreePluginMemory +Security:single module:_CSSM_GetAPIMemoryFunctions +Security:single module:__ZN10TPCrlGroupC4EPK13cssm_crlgroupmmRN8Security13CssmAllocatorEPKc12TPGroupOwner +Security:single module:_tp_policyVerify +Security:single module:__Z16iSignGetCertInfoRN8Security13CssmAllocatorEP10TPCertInfoP13iSignCertInfo +Security:single module:__Z19iSignFetchExtensionRN8Security13CssmAllocatorEP10TPCertInfoPK9cssm_dataP14iSignExtenInfo +Security:single module:_getFieldAuthorityKeyId +Security:single module:__Z26CL_nssAuthorityKeyIdToCssmRK18NSS_AuthorityKeyIdR17CE_AuthorityKeyIDR11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:_getFieldExtenCommon +Security:single module:__ZNK12DecodedExten13convertToCdsaEPvP19cssm_x509_extensionRN8Security13CssmAllocatorE +Security:single module:__Z16tpSetupExtensionRN8Security13CssmAllocatorEP9cssm_dataP14iSignExtenInfo +Security:single module:_getFieldSubjectKeyId +Security:single module:_getFieldKeyUsage +Security:single module:__Z20clNssBitStringToCssmR9cssm_data +Security:single module:_getFieldExtKeyUsage +Security:single module:_getFieldBasicConstraints +Security:single module:_getFieldNetscapeCertType +Security:single module:_getFieldSubjAltName +Security:single module:__Z28iSignSearchUnknownExtensionsP10TPCertInfoP13iSignCertInfo +Security:single module:_getFieldUnknownExt +Security:single module:_freeFieldUnknownExt +Security:single module:_verifySetFreeExtension +Security:single module:_freeFieldExtenCommon +Security:single module:_CSSM_CL_CertGetNextCachedFieldValue +Security:single module:__Z32cssm_CertGetNextCachedFieldValuemmPP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession27CertGetNextCachedFieldValueEmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession27CertGetNextCachedFieldValueEmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession21CertGetNextFieldValueEmRP9cssm_data +Security:single module:__Z16tp_verifySslOptsR11TPCertGroupPK9cssm_dataRK13iSignCertInfo +Security:single module:_tpToLower +Security:single module:__Z23tpCompareSubjectAltNameRK14iSignExtenInfoPKcm21SubjAltNameSearchTypeRbS5_ +Security:single module:__Z11tpIsNumericPKcj +Security:single module:__Z20tpCompareSubjectNameR10TPCertInfo22SubjSubjNameSearchTypePKcmRb +Security:single module:__Z16getField_SubjectR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:_getField_RDN_NSS +Security:single module:__Z16CL_nssNameToCssmRK8NSS_NameR14cssm_x509_nameRN8Security13CssmAllocatorE +Security:single module:__Z15CL_nssRdnToCssmRK7NSS_RDNR13cssm_x509_rdnRN8Security13CssmAllocatorER11SecNssCoder +Security:single module:__Z15CL_nssAtvToCssmRK7NSS_ATVR25cssm_x509_type_value_pairRN8Security13CssmAllocatorE +Security:single module:_tpCompareHostNames +Security:single module:_freeField_RDN +Security:single module:__Z15CL_freeX509NameP14cssm_x509_nameRN8Security13CssmAllocatorE +Security:single module:__Z14CL_freeX509RdnP13cssm_x509_rdnRN8Security13CssmAllocatorE +Security:single module:__Z17iSignFreeCertInfomP13iSignCertInfo +Security:single module:_freeFieldAuthorityKeyId +Security:single module:__Z21CL_freeAuthorityKeyIdR17CE_AuthorityKeyIDRN8Security13CssmAllocatorE +Security:single module:__Z23CL_freeCssmGeneralNamesP15CE_GeneralNamesRN8Security13CssmAllocatorE +Security:single module:_freeFieldSubjectKeyId +Security:single module:_freeFieldSimpleExtension +Security:single module:_freeFieldExtKeyUsage +Security:single module:_tpVerifyCertGroupWithCrls +Security:single module:__ZN10TPCrlGroupD1Ev +Security:single module:__ZN10TPCrlGroupD4Ev +Security:single module:__ZN11TPCertGroup18buildCssmCertGroupEv +Security:single module:_tpCopyCssmData +Security:single module:__ZN11TPCertGroup21buildCssmEvidenceInfoEv +Security:single module:__ZN11TPCertGroup13getReturnCodeEllll +Security:single module:__ZN11TPCertGroupD1Ev +Security:single module:__ZN11TPCertGroupD4Ev +Security:single module:__ZN8Security12KeychainCore5Trust15diagnoseOutcomeEv +Security:single module:__ZN8Security12KeychainCore5Trust17evaluateUserTrustERKNS_9CertGroupEPK27CSSM_TP_APPLE_EVIDENCE_INFONS_9CFCopyRefIPK9__CFArrayEE +Security:single module:__ZN8Security12KeychainCore10TrustStore4findEPNS0_11CertificateEPNS0_6PolicyE +Security:single module:__ZN8Security12KeychainCore10TrustStore8findItemEPNS0_11CertificateEPNS0_6PolicyE +Security:single module:__ZN8Security12KeychainCore14StorageManager12createCursorEmPK24SecKeychainAttributeList +Security:single module:__ZNK8Security9CssmError8osStatusEv +Security:single module:_stAppRealloc +Security:single module:_sslPubKeyFromCert +Security:single module:_SSLProcessServerHelloDone +Security:single module:_SSLPrepareAndQueueMessage +Security:single module:_SSLEncodeKeyExchange +Security:single module:__Z23SSLEncodeRSAKeyExchangeR9SSLRecordP10SSLContext +Security:single module:__Z27SSLEncodeRSAPremasterSecretP10SSLContext +Security:single module:_sslKeyLengthInBytes +Security:single module:_sslRsaEncrypt +Security:single module:_CSSM_CSP_CreateAsymmetricContext +Security:single module:__ZN16RSA_CryptContext4initERKN8Security7ContextEb +Security:single module:__ZN16RSA_CryptContext10outputSizeEbm +Security:single module:__ZN16RSA_CryptContext12encryptBlockEPKvmPvRmb +Security:single module:_RSA_public_encrypt +Security:single module:_RSA_eay_public_encrypt +Security:single module:_RSA_padding_add_PKCS1_type_2 +Security:single module:_RAND_bytes +Security:single module:_cspGetRandomBytes +Security:single module:__ZN8Security18DevRandomGeneratorC2Eb +Security:single module:__ZN16RSA_CryptContextD0Ev +Security:single module:__ZN16RSA_CryptContextD4Ev +Security:single module:_stFreeCssmData +Security:single module:__Z24tls1GenerateMasterSecretP10SSLContext +Security:single module:_SSLInternal_PRF +Security:single module:__Z8tlsPHashP10SSLContextPK13HMACReferencePKhjPhjS6_j +Security:single module:__Z10HMAC_AllocPK13HMACReferenceP10SSLContextPKvjPP11HMACContext +Security:single module:_sslSetUpSymmKey +Security:single module:__Z9HMAC_HmacP11HMACContextPKvjPvPj +Security:single module:__Z9HMAC_InitP11HMACContext +Security:single module:_CSSM_GenerateMacInit +Security:single module:__Z20cssm_GenerateMacInitmyPK12cssm_context +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15GenerateMacInitEyRKNS_7ContextE +Security:single module:__Z11HMAC_UpdateP11HMACContextPKvj +Security:single module:_CSSM_GenerateMacUpdate +Security:single module:__Z22cssm_GenerateMacUpdatemyPK9cssm_datam +Security:single module:__ZThn40_N8Security20CSPFullPluginSession17GenerateMacUpdateEyPKNS_8CssmDataEm +Security:single module:__Z10HMAC_FinalP11HMACContextPvPj +Security:single module:_CSSM_GenerateMacFinal +Security:single module:__Z21cssm_GenerateMacFinalmyP9cssm_data +Security:single module:__ZThn40_N8Security20CSPFullPluginSession16GenerateMacFinalEyRNS_8CssmDataE +Security:single module:_MD5Final +Security:single module:_SSLInitPendingCiphers +Security:single module:_SSLEncodeChangeCipherSpec +Security:single module:__Z11tls1FreeMacP13CipherContext +Security:single module:_SSLEncodeFinishedMessage +Security:single module:_CloneHashState +Security:single module:__Z13cdsaHashCloneRK9SSLBufferRS_ +Security:single module:_CSSM_DigestDataClone +Security:single module:__Z20cssm_DigestDataClonemyy +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15DigestDataCloneEyy +Security:single module:__ZN8Security20CSPFullPluginSession15DigestDataCloneEyy +Security:single module:__ZN13DigestContext5cloneERN8Security13CssmAllocatorE +Security:single module:__ZNK10SHA1Object11digestCloneEv +Security:single module:__ZNK9MD5Object11digestCloneEv +Security:single module:__Z22tls1ComputeFinishedMacP10SSLContext9SSLBufferS1_S1_h +Security:single module:__Z13cdsaHashFinalR9SSLBufferS0_ +Security:single module:__ZNK9MD5Object17digestSizeInBytesEv +Security:single module:__ZN9MD5Object11digestFinalEPv +Security:single module:__Z9HMAC_FreeP11HMACContext +Security:single module:__Z14tls1ComputeMach9SSLBufferS_P13CipherContext9sslUint64P10SSLContext +Security:single module:_SSLEncodeUInt64 +Security:single module:_CDSASymmEncrypt +Security:single module:_CSSM_EncryptDataUpdate +Security:single module:__Z22cssm_EncryptDataUpdatemyPK9cssm_datamPS_mPm +Security:single module:__ZThn40_N8Security20CSPFullPluginSession17EncryptDataUpdateEyPKNS_8CssmDataEmPS1_mRm +Security:single module:__ZN8Security20CSPFullPluginSession17EncryptDataUpdateEyPKNS_8CssmDataEmPS1_mRm +Security:single module:__ZN10RC4Context10outputSizeEbm +Security:single module:__ZN10RC4Context9inputSizeEm +Security:single module:__ZN10RC4Context6updateEPvRmS0_S1_ +Security:single module:_RC4 +Security:single module:_SSLProcessChangeCipherSpec +Security:single module:_CDSASymmDecrypt +Security:single module:_SSLVerifyMac +Security:single module:_SSLProcessFinished +Security:single module:_SSLWrite +Security:single module:_SSLGetBufferedReadSize +Security:single module:_SSLRead +Security:single module:_SSLClose +Security:single module:_SSLSendAlert +Security:single module:__Z14SSLEncodeAlertR9SSLRecord10AlertLevel16AlertDescriptionP10SSLContext +Security:single module:__ZN8Security12KeychainCore5TrustD1Ev +Security:single module:__ZN8Security12KeychainCore5TrustD4Ev +Security:single module:__ZN8Security12KeychainCore5Trust17releaseTPEvidenceERNS_14TPVerifyResultERNS_13CssmAllocatorE +Security:single module:__ZN8Security9CertGroup7destroyERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore6PolicyD1Ev +Security:single module:__ZN8Security12KeychainCore6PolicyD4Ev +Security:single module:__ZN8Security12KeychainCore11CertificateD1Ev +Security:single module:__ZN8Security12KeychainCore11CertificateD4Ev +Security:single module:__ZN8Security10CssmClient6CLImplD0Ev +Security:single module:__ZN8Security10CssmClient6CLImplD4Ev +Security:single module:__ZN8Security12KeychainCore8ItemImplD2Ev +Security:single module:__ZN8Security10CssmClient6TPImplD0Ev +Security:single module:__ZN8Security10CssmClient6TPImplD4Ev +Security:single module:__ZN18AppleX509CLSessionD0Ev +Security:single module:__ZN18AppleX509CLSessionD4Ev +Security:single module:__ZN14AppleTPSessionD0Ev +Security:single module:__ZN14AppleTPSessionD4Ev +Security:single module:__Z13cdsaHashCloseR9SSLBufferP10SSLContext +Security:single module:_CDSASymmFinish +Security:single module:__Z16disposeCipherCtxP13CipherContext +Security:single module:__ZN10RC4ContextD0Ev +Security:single module:__ZN10RC4ContextD4Ev +Security:single module:__ZN8Security12KeychainCore12PolicyCursorD1Ev +Security:single module:__ZN8Security12KeychainCore12PolicyCursorD4Ev +Security:single module:__Z15sslReleaseArrayPK9__CFArray +Security:single module:_attachToCl +Security:single module:__Z23tls1GenerateKeyMaterial9SSLBufferP10SSLContext +Security:single module:__Z11tls1InitMacP13CipherContextP10SSLContext +Security:single module:_CDSASymmInit +Security:single module:_stSetUpCssmData +Security:single module:_CSSM_EncryptDataInit +Security:single module:__Z20cssm_EncryptDataInitmyPK12cssm_contexty +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15EncryptDataInitEyRKNS_7ContextEy +Security:single module:__ZN8Security20CSPFullPluginSession15EncryptDataInitEyRKNS_7ContextEy +Security:single module:__ZN10RC4Context4initERKN8Security7ContextEb +Security:single module:_RC4_set_key +Security:single module:_SSLReallocBuffer +Security:single module:_sslRealloc +Security:single module:__ZN8Security18DevRandomGenerator10addEntropyEPKvm +Security:single module:__ZN8Security12UnixPlusPlus8FileDesc5writeEPKvm +Security:single module:dyld_stub_binding_helper +Security:single module:cfm_stub_binding_helper +Security:single module:__dyld_func_lookup +Security:single module:___initialize_Cplusplus +Security:single module:__ZN8Security10CssmClient5CryptC1ERKNS0_3CSPEm +Security:single module:__ZN8Security10CssmClient7Encrypt4initEv +Security:single module:__ZN8Security10CssmClient7Encrypt5finalERNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient7Encrypt7encryptEPKNS_8CssmDataEmPS2_m +Security:single module:__ZN8Security10CssmClient11PassThrough8activateEv +Security:single module:__ZN8Security10CssmClient11PassThroughclEmPKvPPv +Security:single module:__ZN8Security10CssmClient6Random4seedERKNS_14CssmCryptoDataE +Security:single module:__ZN8Security10CssmClient6Random4sizeEm +Security:single module:__ZN8Security10CssmClient6Random8activateEv +Security:single module:__ZN8Security10CssmClient6Random8generateERNS_8CssmDataEm +Security:single module:__ZN8Security10CssmClient7CSPImpl7freeKeyERNS_7CssmKeyEPKNS_17AccessCredentialsEb +Security:single module:__ZN8Security10CssmClient7CSPImplC1ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient7CSPImplC2ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient7CSPImplD1Ev +Security:single module:__ZN8Security10CssmClient7Context13getOutputSizeER20cssm_query_size_datamb +Security:single module:__ZN8Security10CssmClient7Context13getOutputSizeEmb +Security:single module:__ZN8Security10CssmClient7Context4initEv +Security:single module:__ZN8Security10CssmClient7Context9algorithmEm +Security:single module:__ZN8Security10CssmClient7ContextC1ERKNS0_3CSPEm +Security:single module:__ZN8Security10CssmClient7ContextD0Ev +Security:single module:__ZN8Security10CssmClient7ContextD1Ev +Security:single module:__ZN8Security10CssmClient10ModuleImplC2ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient10ModuleImplC2ERKNS_4GuidERKNS0_4CssmE +Security:single module:__ZN8Security10CssmClient10ModuleImplD1Ev +Security:single module:__ZN8Security10CssmClient10ModuleImplD2Ev +Security:single module:__ZN8Security10CssmClient10ObjectImplC1ERKNS0_6ObjectE +Security:single module:__ZN8Security10CssmClient10ObjectImplC1Ev +Security:single module:__ZN8Security10CssmClient10ObjectImplD0Ev +Security:single module:__ZN8Security10CssmClient10ObjectImplD1Ev +Security:single module:__ZN8Security10CssmClient14AttachmentImplC1ERKNS0_6ModuleEm +Security:single module:__ZN8Security10CssmClient14AttachmentImplC1ERKNS_4GuidEm +Security:single module:__ZN8Security10CssmClient14AttachmentImplD0Ev +Security:single module:__ZN8Security10CssmClient14AttachmentImplD1Ev +Security:single module:__ZN8Security10CssmClient8CssmImpl10deactivateEv +Security:single module:__ZN8Security10CssmClient8CssmImpl12StandardCssm7setCssmEPS1_ +Security:single module:__ZN8Security10CssmClient8CssmImpl12StandardCssm9unsetCssmEPS1_ +Security:single module:__ZN8Security10CssmClient8CssmImpl12StandardCssmD1Ev +Security:single module:__ZN8Security10CssmClient8CssmImpl12StandardCssmD2Ev +Security:single module:__ZN8Security10CssmClient8CssmImpl12StandardCssmD4Ev +Security:single module:__ZN8Security10CssmClient8CssmImpl13atExitHandlerEv +Security:single module:__ZN8Security10CssmClient8CssmImplC1Ev +Security:single module:__ZN8Security10CssmClient8CssmImplC2Eb +Security:single module:__ZN8Security10CssmClient8CssmImplC2Ev +Security:single module:__ZN8Security10CssmClient8CssmImplC4Ev +Security:single module:__ZN8Security10CssmClient8CssmImplD0Ev +Security:single module:__ZN8Security10CssmClient8CssmImplD1Ev +Security:single module:__ZN8Security10CssmClient8CssmImplD2Ev +Security:single module:__ZN8Security10CssmClient8CssmImplD4Ev +Security:single module:__ZNK8Security10CssmClient10ObjectImpleqERKS1_ +Security:single module:__ZNK8Security10CssmClient10ObjectImplltERKS1_ +Security:single module:__ZNK8Security10CssmClient14AttachmentImpl14subserviceMaskEv +Security:single module:__ZNK8Security10CssmClient5Error4whatEv +Security:single module:__ZNK8Security10CssmClient5Error9cssmErrorEv +Security:single module:__ZN8Security10CssmClient12DbAttributesC2ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient12DbAttributesC2Ev +Security:single module:__ZN8Security10CssmClient12DbCursorImpl9allocatorERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient12DbCursorImplC1ERKNS0_6ObjectERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient12DbCursorImplC1ERKNS0_6ObjectEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14DbDbCursorImpl8activateEv +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplC1ERKNS0_2DbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14DbDbCursorImplD1Ev +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImpl12deleteRecordEv +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImpl6modifyEmPK29cssm_db_record_attribute_dataPK9cssm_datam +Security:single module:__ZN8Security10CssmClient18DbUniqueRecordImplD1Ev +Security:single module:__ZN8Security10CssmClient6DLImpl10getDbNamesEPPc +Security:single module:__ZN8Security10CssmClient6DLImpl12freeNameListEPPc +Security:single module:__ZN8Security10CssmClient6DLImplC2ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient6DLImplD1Ev +Security:single module:__ZN8Security10CssmClient6DbImpl11getSettingsERmRb +Security:single module:__ZN8Security10CssmClient6DbImpl11newDbCursorERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient6DbImpl11passThroughEmPKvPPv +Security:single module:__ZN8Security10CssmClient6DbImpl11setSettingsEmb +Security:single module:__ZN8Security10CssmClient6DbImpl12authenticateEmPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient6DbImpl14createRelationEmPKcmPK29cssm_db_schema_attribute_infomPK25cssm_db_schema_index_info +Security:single module:__ZN8Security10CssmClient6DbImpl15destroyRelationEm +Security:single module:__ZN8Security10CssmClient6DbImpl16changePassphraseEPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient6DbImpl17getUnlockKeyIndexERNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient6DbImpl4lockEv +Security:single module:__ZN8Security10CssmClient6DbImpl4nameERPc +Security:single module:__ZN8Security10CssmClient6DbImpl6createEv +Security:single module:__ZN8Security10CssmClient6DbImpl6insertEmPK29cssm_db_record_attribute_dataPK9cssm_data +Security:single module:__ZN8Security10CssmClient6DbImpl6renameEPKc +Security:single module:__ZN8Security10CssmClient6DbImpl6unlockERK9cssm_data +Security:single module:__ZN8Security10CssmClient6DbImpl6unlockEv +Security:single module:__ZN8Security10CssmClient6DbImpl8deleteDbEv +Security:single module:__ZN8Security10CssmClient6DbImpl8isLockedEv +Security:single module:__ZN8Security10CssmClient6DbImplD1Ev +Security:single module:__ZNK8Security10CssmClient12DbCursorImpl9allocatorEv +Security:single module:__ZThn20_N8Security10CssmClient6DbImpl11newDbCursorERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient8DLDbList3addERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security10CssmClient8DLDbList6removeERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security10CssmClient8DLDbList4saveEv +Security:single module:__ZN8Security10CssmClient11GenerateKeyC2ERKNS0_3CSPEmm +Security:single module:__ZN8Security10CssmClient11GenerateKeyC1ERKNS0_3CSPEmm +Security:single module:__ZN8Security10CssmClient11GenerateKeyC4ERKNS0_3CSPEmm +Security:single module:__ZN8Security10CssmClient11GenerateKey8databaseERKNS0_2DbE +Security:single module:__ZN8Security10CssmClient11GenerateKey8activateEv +Security:single module:__ZN8Security10CssmClient11GenerateKeyclERKNS0_7KeySpecE +Security:single module:__ZN8Security10CssmClient11GenerateKeyclERNS_7CssmKeyERKNS0_7KeySpecE +Security:single module:__ZN8Security10CssmClient11GenerateKeyclERNS0_3KeyERKNS0_7KeySpecES3_S6_ +Security:single module:__ZN8Security10CssmClient11GenerateKeyclERNS_7CssmKeyERKNS0_7KeySpecES3_S6_ +Security:single module:__ZN8Security10CssmClient18KeychainAclFactoryC2ERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient18KeychainAclFactoryC1ERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient18KeychainAclFactoryC4ERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient18KeychainAclFactoryD2Ev +Security:single module:__ZN8Security10CssmClient18KeychainAclFactoryD1Ev +Security:single module:__ZN8Security10CssmClient18KeychainAclFactoryD4Ev +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory15nullCredentialsEv +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory25keychainPromptCredentialsEv +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory31keychainPromptUnlockCredentialsEv +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory25passwordChangeCredentialsERKNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory25passwordUnlockCredentialsERKNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory19keychainPromptOwnerERKNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory8anyOwnerEv +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory7releaseEPNS_13AclEntryInputE +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory7commentERNS_9TypedListE +Security:single module:__ZN8Security10CssmClient18KeychainAclFactory9uncommentERNS_9TypedListE +Security:single module:__ZN8Security10CssmClient7KeyImpl11changeOwnerERK24cssm_acl_owner_prototypePK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient7KeyImpl9changeAclERK13cssm_acl_editPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient7KeyImpl9deleteKeyEPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient7KeyImplC1ERKNS0_3CSPERK9cssm_data +Security:single module:__ZN8Security10CssmClient7KeyImplC2ERKNS0_3CSPERK8cssm_keyb +Security:single module:__ZN8Security10CssmClient7KeyImplC2ERKNS0_3CSPERK9cssm_data +Security:single module:__ZN8Security10CssmClient7KeyImplC4ERKNS0_3CSPERK9cssm_data +Security:single module:__ZN8Security10CssmClient7KeyImplD1Ev +Security:single module:__ZNK8Security10CssmClient7KeyImpl10sizeInBitsEv +Security:single module:__ZNK8Security10CssmClient7KeyImpl6getAclERNS_20AutoAclEntryInfoListEPKc +Security:single module:__ZNK8Security10CssmClient7KeyImpl8getOwnerERNS_21AutoAclOwnerPrototypeE +Security:single module:__ZThn20_N8Security10CssmClient7KeyImpl11changeOwnerERK24cssm_acl_owner_prototypePK23cssm_access_credentials +Security:single module:__ZThn20_N8Security10CssmClient7KeyImpl9changeAclERK13cssm_acl_editPK23cssm_access_credentials +Security:single module:__ZThn20_N8Security10CssmClient7KeyImplD0Ev +Security:single module:__ZThn20_N8Security10CssmClient7KeyImplD1Ev +Security:single module:__ZThn20_NK8Security10CssmClient7KeyImpl6getAclERNS_20AutoAclEntryInfoListEPKc +Security:single module:__ZThn20_NK8Security10CssmClient7KeyImpl8getOwnerERNS_21AutoAclOwnerPrototypeE +Security:single module:__ZN8Security10CssmClient11GenerateMac4initEv +Security:single module:__ZN8Security10CssmClient11GenerateMac4signEPKNS_8CssmDataEm +Security:single module:__ZN8Security10CssmClient11GenerateMacclERNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient9VerifyMac4initEv +Security:single module:__ZN8Security10CssmClient9VerifyMac6verifyEPKNS_8CssmDataEm +Security:single module:__ZN8Security10CssmClient9VerifyMacclERKNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplC2ERKSt6vectorINS_14DLDbIdentifierESaIS3_EEbRKNS0_4CssmE +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplC1ERKSt6vectorINS_14DLDbIdentifierESaIS3_EEbRKNS0_4CssmE +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplC4ERKSt6vectorINS_14DLDbIdentifierESaIS3_EEbRKNS0_4CssmE +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplC2ERKSt6vectorINS_14DLDbIdentifierESaIS3_EEb +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplC1ERKSt6vectorINS_14DLDbIdentifierESaIS3_EEb +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplC4ERKSt6vectorINS_14DLDbIdentifierESaIS3_EEb +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplD2Ev +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplD1Ev +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplD0Ev +Security:single module:__ZN8Security10CssmClient13MultiDLDbImplD4Ev +Security:single module:__ZN8Security10CssmClient13MultiDLDbImpl8databaseERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security10CssmClient13MultiDLDbImpl4listERKSt6vectorINS_14DLDbIdentifierESaIS3_EE +Security:single module:__ZN8Security10CssmClient13MultiDLDbImpl11newDbCursorERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZThn20_N8Security10CssmClient13MultiDLDbImpl11newDbCursorERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient13MultiDLDbImpl11newDbCursorEmRNS_13CssmAllocatorE +Security:single module:__ZThn20_N8Security10CssmClient13MultiDLDbImpl11newDbCursorEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient13MultiDLDbImpl8activateEv +Security:single module:__ZN8Security10CssmClient13MultiDLDbImpl10deactivateEv +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplC2ERKNS0_9MultiDLDbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplC1ERKNS0_9MultiDLDbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplC4ERKNS0_9MultiDLDbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplC2ERKNS0_9MultiDLDbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplC1ERKNS0_9MultiDLDbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplC4ERKNS0_9MultiDLDbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplD2Ev +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplD1Ev +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplD0Ev +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImplD4Ev +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImpl4nextEPNS0_12DbAttributesEPNS_17CssmDataContainerERNS0_14DbUniqueRecordE +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImpl8activateEv +Security:single module:__ZN8Security10CssmClient21MultiDLDbDbCursorImpl10deactivateEv +Security:single module:__ZN8Security11CodeSigning9OSXSigner6verifyERKNS0_8SignableEPKNS0_9SignatureE +Security:single module:__ZN8Security11CodeSigning9OSXSignerC2Ev +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplC1ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplC2ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplC2ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplC4ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplD1Ev +Security:single module:__ZN8Security10CssmClient11SSCSPDLImplD2Ev +Security:single module:__ZN8Security10CssmClient11SSGroupImpl14encodeDataBlobEPK9cssm_dataPK23cssm_access_credentialsRNS_17CssmDataContainerE +Security:single module:__ZN8Security10CssmClient11SSGroupImplC1ERKNS0_4SSDbEPK29cssm_resource_control_context +Security:single module:__ZN8Security10CssmClient11SSGroupImplC2ERKNS0_4SSDbEPK29cssm_resource_control_context +Security:single module:__ZN8Security10CssmClient11SSGroupImplC2ERKNS0_4SSDbERK9cssm_data +Security:single module:__ZN8Security10CssmClient11SSGroupImplC4ERKNS0_4SSDbEPK29cssm_resource_control_context +Security:single module:__ZN8Security10CssmClient14SSDbCursorImpl10deactivateEv +Security:single module:__ZN8Security10CssmClient14SSDbCursorImpl7nextKeyEPNS0_12DbAttributesERNS0_3KeyERNS0_14DbUniqueRecordE +Security:single module:__ZN8Security10CssmClient14SSDbCursorImpl8activateEv +Security:single module:__ZN8Security10CssmClient14SSDbCursorImplC2ERKNS0_2DbERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14SSDbCursorImplC2ERKNS0_2DbEmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImpl12deleteRecordEPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImpl12deleteRecordEv +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImpl5groupEv +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImpl6modifyEmPK29cssm_db_record_attribute_dataPK9cssm_datam +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImpl6modifyEmPK29cssm_db_record_attribute_dataPK9cssm_datamPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImplC2ERKNS0_2DbE +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImplD1Ev +Security:single module:__ZN8Security10CssmClient20SSDbUniqueRecordImplD2Ev +Security:single module:__ZN8Security10CssmClient8SSDbImpl6createEv +Security:single module:__ZN8Security10CssmClient8SSDbImpl6insertEmPK29cssm_db_record_attribute_dataPK9cssm_dataPK29cssm_resource_control_context +Security:single module:__ZN8Security10CssmClient8SSDbImpl6insertEmPK29cssm_db_record_attribute_dataPK9cssm_dataRKNS0_7SSGroupEPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient8SSDbImplC2ERKNS0_7SSCSPDLEPKcPK16cssm_net_address +Security:single module:__ZN8Security10CssmClient8SSDbImplD1Ev +Security:single module:__ZN8Security10CssmClient8SSDbImplD2Ev +Security:single module:__ZN8Security10CssmClient9CSPDLImpl9allocatorERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient9CSPDLImplC1ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient9CSPDLImplC1ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient9CSPDLImplC2ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient9CSPDLImplC4ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient9CSPDLImplD0Ev +Security:single module:__ZN8Security10CssmClient9CSPDLImplD1Ev +Security:single module:__ZNK8Security10CssmClient11SSGroupImpl5labelEv +Security:single module:__ZNK8Security10CssmClient9CSPDLImpleqERKS1_ +Security:single module:__ZNK8Security10CssmClient9CSPDLImplltERKS1_ +Security:single module:__ZThn64_N8Security10CssmClient11SSCSPDLImpl5newDbEPKcPK16cssm_net_address +Security:single module:__ZThn64_N8Security10CssmClient11SSCSPDLImplD1Ev +Security:single module:__ZThn64_N8Security10CssmClient9CSPDLImpl9allocatorERNS_13CssmAllocatorE +Security:single module:__ZThn64_N8Security10CssmClient9CSPDLImplD0Ev +Security:single module:__ZThn64_N8Security10CssmClient9CSPDLImplD1Ev +Security:single module:__ZN8Security10CssmClient14SigningContext8activateEv +Security:single module:__ZN8Security10CssmClient4Sign4signEPKNS_8CssmDataEmRS2_ +Security:single module:__ZN8Security10CssmClient4Sign4initEv +Security:single module:__ZN8Security10CssmClient4Sign4signEPKNS_8CssmDataEm +Security:single module:__ZN8Security10CssmClient4SignclERNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient6Verify6verifyEPKNS_8CssmDataEmRS3_ +Security:single module:__ZN8Security10CssmClient6Verify4initEv +Security:single module:__ZN8Security10CssmClient6Verify6verifyEPKNS_8CssmDataEm +Security:single module:__ZN8Security10CssmClient6VerifyclERKNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient7WrapKey8activateEv +Security:single module:__ZN8Security10CssmClient7WrapKeyclERKNS_7CssmKeyERS2_PKNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient7WrapKeyclERNS0_3KeyEPKNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient9DeriveKeyclEPNS_8CssmDataERKNS0_7KeySpecERNS_7CssmKeyE +Security:single module:__ZN8Security10CssmClient9UnwrapKeyclERKNS_7CssmKeyERKNS0_7KeySpecEPNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient9UnwrapKeyclERKNS_7CssmKeyERKNS0_7KeySpecERNS0_3KeyE +Security:single module:__ZN8Security10CssmClient9UnwrapKeyclERKNS_7CssmKeyERKNS0_7KeySpecERNS0_3KeyEPNS_8CssmDataE +Security:single module:__ZN8Security10CssmClient9UnwrapKeyclERKNS_7CssmKeyERKNS0_7KeySpecERS2_ +Security:single module:__ZN8Security10CssmClient9UnwrapKeyclERKNS_7CssmKeyERKNS0_7KeySpecERS2_PS3_ +Security:single module:__ZN8Security13ReferencedKeyC1ERNS_7KeyPoolE +Security:single module:__ZN8Security13ReferencedKeyD0Ev +Security:single module:__ZN8Security13ReferencedKeyD1Ev +Security:single module:__ZN8Security16CSPPluginSession13PluginContextD0Ev +Security:single module:__ZN8Security16CSPPluginSession13PluginContextD1Ev +Security:single module:__ZN8Security16CSPPluginSession13contextCreateEyRKNS_7ContextE +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext10outputSizeEbm +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext15minimumProgressERmS2_ +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext18setDigestAlgorithmEm +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext4initERKNS_7ContextEb +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext5cloneERNS_13CssmAllocatorE +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext5finalERKNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext5finalERNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext6updateEPvRmS2_S3_ +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext6updateERKNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext8generateERKNS_7ContextERNS_7CssmKeyES6_ +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext8generateERKNS_7ContextEmRNS_8CssmDataERmRPNS2_4AttrE +Security:single module:__ZN8Security20CSPFullPluginSession10CSPContext9inputSizeEm +Security:single module:__ZN8Security20CSPFullPluginSession10getKeySizeERKNS_7CssmKeyER13cssm_key_size +Security:single module:__ZN8Security20CSPFullPluginSession11GenerateKeyEyRKNS_7ContextEmmPKNS_8CssmDataEPK29cssm_resource_control_contextRNS_7CssmKeyEy +Security:single module:__ZN8Security20CSPFullPluginSession11GetKeyOwnerERKNS_7CssmKeyER24cssm_acl_owner_prototype +Security:single module:__ZN8Security20CSPFullPluginSession11GetLoginAclEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZN8Security20CSPFullPluginSession11PassThroughEyRKNS_7ContextEmPKvPPv +Security:single module:__ZN8Security20CSPFullPluginSession12ChangeKeyAclERKNS_17AccessCredentialsERK13cssm_acl_editRKNS_7CssmKeyE +Security:single module:__ZN8Security20CSPFullPluginSession12GetTimeValueEmRNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession12SignDataInitEyRKNS_7ContextE +Security:single module:__ZN8Security20CSPFullPluginSession12VerifyDeviceERKNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession13GetLoginOwnerER24cssm_acl_owner_prototype +Security:single module:__ZN8Security20CSPFullPluginSession13SignDataFinalEyRNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession14ChangeKeyOwnerERKNS_17AccessCredentialsERKNS_7CssmKeyERK24cssm_acl_owner_prototype +Security:single module:__ZN8Security20CSPFullPluginSession14ChangeLoginAclERKNS_17AccessCredentialsERK13cssm_acl_edit +Security:single module:__ZN8Security20CSPFullPluginSession14GenerateRandomEyRKNS_7ContextERNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession14SignDataUpdateEyPKNS_8CssmDataEm +Security:single module:__ZN8Security20CSPFullPluginSession15GenerateKeyPairEyRKNS_7ContextEmmPKNS_8CssmDataERNS_7CssmKeyEmmS6_PK29cssm_resource_control_contextS8_y +Security:single module:__ZN8Security20CSPFullPluginSession15RetrieveCounterERNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession16ChangeLoginOwnerERKNS_17AccessCredentialsERK24cssm_acl_owner_prototype +Security:single module:__ZN8Security20CSPFullPluginSession16EncryptDataFinalEyRNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession16RetrieveUniqueIdERNS_8CssmDataE +Security:single module:__ZN8Security20CSPFullPluginSession23GenerateAlgorithmParamsEyRKNS_7ContextEmRNS_8CssmDataERmRP22cssm_context_attribute +Security:single module:__ZN8Security20CSPFullPluginSession24GetOperationalStatisticsERNS_24CSPOperationalStatisticsE +Security:single module:__ZN8Security20CSPFullPluginSession29ObtainPrivateKeyFromPublicKeyERKNS_7CssmKeyERS1_ +Security:single module:__ZN8Security20CSPFullPluginSession5LoginERKNS_17AccessCredentialsEPKNS_8CssmDataEPKv +Security:single module:__ZN8Security20CSPFullPluginSession6LogoutEv +Security:single module:__ZN8Security20CSPFullPluginSession7WrapKeyEyRKNS_7ContextERKNS_17AccessCredentialsERKNS_7CssmKeyEPKNS_8CssmDataERS7_y +Security:single module:__ZN8Security20CSPFullPluginSession8SignDataEyRKNS_7ContextEPKNS_8CssmDataEmmRS4_ +Security:single module:__ZN8Security20CSPFullPluginSession9DeriveKeyEyRKNS_7ContextERNS_8CssmDataEmmPKS4_PK29cssm_resource_control_contextRNS_7CssmKeyE +Security:single module:__ZN8Security20CSPFullPluginSession9GetKeyAclERKNS_7CssmKeyEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZN8Security20CSPFullPluginSession9QuerySizeEyRKNS_7ContextElmPNS_13QuerySizeDataE +Security:single module:__ZN8Security20CSPFullPluginSession9UnwrapKeyEyRKNS_7ContextEPKNS_7CssmKeyERS5_mmPKNS_8CssmDataEPK29cssm_resource_control_contextRS4_RS8_y +Security:single module:__ZN8Security7KeyPool7freeKeyERNS_13CssmAllocatorER8cssm_key +Security:single module:__ZN8Security7KeyPoolC1Ev +Security:single module:__ZN8Security7KeyPoolD0Ev +Security:single module:__ZN8Security7KeyPoolD1Ev +Security:single module:__ZN8Security7KeyPoolD2Ev +Security:single module:__ZN8Security7KeyPoolD4Ev +Security:single module:__ZThn40_N8Security16CSPPluginSession11EventNotifyEmyRKNS_7ContextE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession11GenerateKeyEyRKNS_7ContextEmmPKNS_8CssmDataEPK29cssm_resource_control_contextRNS_7CssmKeyEy +Security:single module:__ZThn40_N8Security20CSPFullPluginSession11GetKeyOwnerERKNS_7CssmKeyER24cssm_acl_owner_prototype +Security:single module:__ZThn40_N8Security20CSPFullPluginSession11GetLoginAclEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZThn40_N8Security20CSPFullPluginSession11PassThroughEyRKNS_7ContextEmPKvPPv +Security:single module:__ZThn40_N8Security20CSPFullPluginSession12ChangeKeyAclERKNS_17AccessCredentialsERK13cssm_acl_editRKNS_7CssmKeyE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession12GetTimeValueEmRNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession12SignDataInitEyRKNS_7ContextE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession12VerifyDeviceERKNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession13GetLoginOwnerER24cssm_acl_owner_prototype +Security:single module:__ZThn40_N8Security20CSPFullPluginSession13SignDataFinalEyRNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession13VerifyMacInitEyRKNS_7ContextE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession14ChangeKeyOwnerERKNS_17AccessCredentialsERKNS_7CssmKeyERK24cssm_acl_owner_prototype +Security:single module:__ZThn40_N8Security20CSPFullPluginSession14ChangeLoginAclERKNS_17AccessCredentialsERK13cssm_acl_edit +Security:single module:__ZThn40_N8Security20CSPFullPluginSession14GenerateRandomEyRKNS_7ContextERNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession14SignDataUpdateEyPKNS_8CssmDataEm +Security:single module:__ZThn40_N8Security20CSPFullPluginSession14VerifyDataInitEyRKNS_7ContextE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession14VerifyMacFinalEyRKNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15GenerateKeyPairEyRKNS_7ContextEmmPKNS_8CssmDataERNS_7CssmKeyEmmS6_PK29cssm_resource_control_contextS8_y +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15RetrieveCounterERNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15VerifyDataFinalEyRKNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession15VerifyMacUpdateEyPKNS_8CssmDataEm +Security:single module:__ZThn40_N8Security20CSPFullPluginSession16ChangeLoginOwnerERKNS_17AccessCredentialsERK24cssm_acl_owner_prototype +Security:single module:__ZThn40_N8Security20CSPFullPluginSession16EncryptDataFinalEyRNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession16RetrieveUniqueIdERNS_8CssmDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession16VerifyDataUpdateEyPKNS_8CssmDataEm +Security:single module:__ZThn40_N8Security20CSPFullPluginSession23GenerateAlgorithmParamsEyRKNS_7ContextEmRNS_8CssmDataERmRP22cssm_context_attribute +Security:single module:__ZThn40_N8Security20CSPFullPluginSession24GetOperationalStatisticsERNS_24CSPOperationalStatisticsE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession29ObtainPrivateKeyFromPublicKeyERKNS_7CssmKeyERS1_ +Security:single module:__ZThn40_N8Security20CSPFullPluginSession5LoginERKNS_17AccessCredentialsEPKNS_8CssmDataEPKv +Security:single module:__ZThn40_N8Security20CSPFullPluginSession6LogoutEv +Security:single module:__ZThn40_N8Security20CSPFullPluginSession7FreeKeyEPKNS_17AccessCredentialsERNS_7CssmKeyEl +Security:single module:__ZThn40_N8Security20CSPFullPluginSession7WrapKeyEyRKNS_7ContextERKNS_17AccessCredentialsERKNS_7CssmKeyEPKNS_8CssmDataERS7_y +Security:single module:__ZThn40_N8Security20CSPFullPluginSession8SignDataEyRKNS_7ContextEPKNS_8CssmDataEmmRS4_ +Security:single module:__ZThn40_N8Security20CSPFullPluginSession9DeriveKeyEyRKNS_7ContextERNS_8CssmDataEmmPKS4_PK29cssm_resource_control_contextRNS_7CssmKeyE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession9GetKeyAclERKNS_7CssmKeyEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZThn40_N8Security20CSPFullPluginSession9QuerySizeEyRKNS_7ContextElmPNS_13QuerySizeDataE +Security:single module:__ZThn40_N8Security20CSPFullPluginSession9UnwrapKeyEyRKNS_7ContextEPKNS_7CssmKeyERS5_mmPKNS_8CssmDataEPK29cssm_resource_control_contextRS4_RS8_y +Security:single module:__ZN8Security20CSPFullPluginSession6Writer3putEPvm +Security:single module:__ZN8Security20CSPFullPluginSession6WriterC2EPNS_8CssmDataEmS3_ +Security:single module:__ZN8Security20CSPFullPluginSession6setKeyERNS_7CssmKeyERKNS_7ContextEmmm +Security:single module:__ZN8Security10CssmPluginC1Ev +Security:single module:__ZN8Security10CssmPluginD0Ev +Security:single module:__ZN8Security10CssmPluginD1Ev +Security:single module:__ZN8Security10CssmPluginD2Ev +Security:single module:__ZN8Security10CssmPluginD4Ev +Security:single module:__ZNK8Security10CssmPlugin12sendCallbackEmmm +Security:single module:__ZN8Security15DLPluginSession7reallocEPvm +Security:single module:__ZThn44_N8Security15DLPluginSession7reallocEPvm +Security:single module:__ZN8Security13PluginSessionC1EmRNS_10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN8Security13PluginSessionD0Ev +Security:single module:__ZN8Security13PluginSessionD1Ev +Security:single module:__ZNK8Security13PluginSession12sendCallbackEmmm +Security:single module:__ZNK8Security13AnyAclSubject5Maker4makeERKNS_9TypedListE +Security:single module:__ZNK8Security13AnyAclSubject6toListERNS_13CssmAllocatorE +Security:single module:__ZNK8Security13AnyAclSubject8validateERKNS_20AclValidationContextE +Security:single module:__ZN8Security23CodeSignatureAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6Writer7CounterES4_ +Security:single module:__ZN8Security23CodeSignatureAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6WriterES3_ +Security:single module:__ZN8Security23CodeSignatureAclSubjectC1ERNS_13CssmAllocatorEPKNS_11CodeSigning9SignatureE +Security:single module:__ZN8Security23CodeSignatureAclSubjectC2ERNS_13CssmAllocatorEPKNS_11CodeSigning9SignatureE +Security:single module:__ZN8Security23CodeSignatureAclSubjectC2ERNS_13CssmAllocatorEPKNS_11CodeSigning9SignatureEPKvm +Security:single module:__ZN8Security23CodeSignatureAclSubjectC4ERNS_13CssmAllocatorEPKNS_11CodeSigning9SignatureE +Security:single module:__ZN8Security23CodeSignatureAclSubjectD1Ev +Security:single module:__ZN8Security23CodeSignatureAclSubjectD2Ev +Security:single module:__ZNK8Security23CodeSignatureAclSubject5Maker4makeERKNS_9TypedListE +Security:single module:__ZNK8Security23CodeSignatureAclSubject6toListERNS_13CssmAllocatorE +Security:single module:__ZNK8Security17CommentAclSubject8validateERKNS_20AclValidationContextE +Security:single module:__ZNK8Security17CommentAclSubject6toListERNS_13CssmAllocatorE +Security:single module:__ZNK8Security17CommentAclSubject5Maker4makeERKNS_9TypedListE +Security:single module:__ZNK8Security17CommentAclSubject5Maker4makeEhRNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security17CommentAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6Writer7CounterES4_ +Security:single module:__ZN8Security17CommentAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6WriterES3_ +Security:single module:__ZN8Security18PasswordAclSubjectC2ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security18PasswordAclSubjectC1ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security18PasswordAclSubjectC4ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security18PasswordAclSubjectC2ERNS_13CssmAllocatorERNS_15CssmManagedDataE +Security:single module:__ZN8Security18PasswordAclSubjectC1ERNS_13CssmAllocatorERNS_15CssmManagedDataE +Security:single module:__ZN8Security18PasswordAclSubjectC4ERNS_13CssmAllocatorERNS_15CssmManagedDataE +Security:single module:__ZNK8Security18PasswordAclSubject8validateERKNS_20AclValidationContextERKNS_9TypedListE +Security:single module:__ZNK8Security18PasswordAclSubject6toListERNS_13CssmAllocatorE +Security:single module:__ZNK8Security18PasswordAclSubject5Maker4makeERKNS_9TypedListE +Security:single module:__ZNK8Security18PasswordAclSubject5Maker4makeEhRNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security18PasswordAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6Writer7CounterES4_ +Security:single module:__ZN8Security18PasswordAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6WriterES3_ +Security:single module:__ZNK8Security17ProcessAclSubject8validateERKNS_20AclValidationContextE +Security:single module:__ZNK8Security17ProcessAclSubject6toListERNS_13CssmAllocatorE +Security:single module:__ZNK8Security17ProcessAclSubject5Maker4makeERKNS_9TypedListE +Security:single module:__ZNK8Security17ProcessAclSubject5Maker4makeEhRNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security17ProcessAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6Writer7CounterES4_ +Security:single module:__ZN8Security17ProcessAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6WriterES3_ +Security:single module:__ZNK8Security17ProcessAclSubject11Environment6getuidEv +Security:single module:__ZNK8Security17ProcessAclSubject11Environment6getgidEv +Security:single module:___tcf_0 +Security:single module:__ZN8Security19ThresholdAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6Writer7CounterES4_ +Security:single module:__ZN8Security19ThresholdAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6WriterES3_ +Security:single module:__ZN8Security19ThresholdAclSubjectC2EmmRKSt6vectorINS_10RefPointerINS_10AclSubjectEEESaIS4_EE +Security:single module:__ZNK8Security19ThresholdAclSubject5Maker4makeERKNS_9TypedListE +Security:single module:__ZNK8Security19ThresholdAclSubject6toListERNS_13CssmAllocatorE +Security:single module:__ZN8Security10DbModifier11createTableEPNS_10MetaRecordE +Security:single module:__ZN8Security10DbModifier11deleteTableEm +Security:single module:__ZN8Security10DbModifier11insertTableERKNS_25CssmDbRecordAttributeInfoEPK25cssm_db_record_index_infoPK27cssm_db_parsing_module_info +Security:single module:__ZN8Security10DbModifier11insertTableEmRKSsmPK29cssm_db_schema_attribute_infomPK25cssm_db_schema_index_info +Security:single module:__ZN8Security10DbModifier12deleteRecordEmRKNS_8RecordIdE +Security:single module:__ZN8Security10DbModifier12insertRecordEmPK29cssm_db_record_attribute_dataPKNS_8CssmDataE +Security:single module:__ZN8Security10DbModifier12updateRecordEmRKNS_8RecordIdEPK29cssm_db_record_attribute_dataPKNS_8CssmDataEm +Security:single module:__ZN8Security10DbModifier14createDatabaseERK11cssm_dbinfoPK20cssm_acl_entry_inputt +Security:single module:__ZN8Security10DbModifier14deleteDatabaseEv +Security:single module:__ZN8Security10DbModifier14modifyDatabaseEv +Security:single module:__ZN8Security10DbModifier16writeAuthSectionEm +Security:single module:__ZN8Security10DbModifier17insertTableSchemaERKNS_25CssmDbRecordAttributeInfoEPK25cssm_db_record_index_info +Security:single module:__ZN8Security10DbModifier18writeSchemaSectionEm +Security:single module:__ZN8Security10DbModifier8rollbackEv +Security:single module:__ZN8Security10DbModifier9findTableEm +Security:single module:__ZN8Security10DbModifierC2ERNS_10AtomicFileERKNS_13AppleDatabaseE +Security:single module:__ZN8Security10DbModifierD2Ev +Security:single module:__ZN8Security11IndexCursorC2EPNS_10DbQueryKeyERKNS_9DbVersionERKNS_5TableEPKNS_12DbConstIndexE +Security:single module:__ZN8Security11IndexCursorD1Ev +Security:single module:__ZN8Security11IndexCursorD2Ev +Security:single module:__ZN8Security11MultiCursor4nextERmP29cssm_db_record_attribute_dataPNS_8CssmDataERNS_13CssmAllocatorERNS_8RecordIdE +Security:single module:__ZN8Security11MultiCursorC1EPK10cssm_queryRKNS_9DbVersionE +Security:single module:__ZN8Security11MultiCursorC2EPK10cssm_queryRKNS_9DbVersionE +Security:single module:__ZN8Security11MultiCursorC4EPK10cssm_queryRKNS_9DbVersionE +Security:single module:__ZN8Security11MultiCursorD0Ev +Security:single module:__ZN8Security11MultiCursorD1Ev +Security:single module:__ZN8Security11MultiCursorD2Ev +Security:single module:__ZN8Security11MultiCursorD4Ev +Security:single module:__ZN8Security12LinearCursorC2EPK10cssm_queryRKNS_9DbVersionERKNS_5TableE +Security:single module:__ZN8Security12LinearCursorD1Ev +Security:single module:__ZN8Security12LinearCursorD2Ev +Security:single module:__ZN8Security13AppleDatabase10dataDeleteERNS_9DbContextERK21cssm_db_unique_record +Security:single module:__ZN8Security13AppleDatabase10dataInsertERNS_9DbContextEmPK29cssm_db_record_attribute_dataPKNS_8CssmDataE +Security:single module:__ZN8Security13AppleDatabase10dataModifyERNS_9DbContextEmR21cssm_db_unique_recordPK29cssm_db_record_attribute_dataPKNS_8CssmDataEm +Security:single module:__ZN8Security13AppleDatabase10getDbOwnerERNS_9DbContextER24cssm_acl_owner_prototype +Security:single module:__ZN8Security13AppleDatabase11changeDbAclERNS_9DbContextERKNS_17AccessCredentialsERK13cssm_acl_edit +Security:single module:__ZN8Security13AppleDatabase11passThroughERNS_9DbContextEmPKvPPv +Security:single module:__ZN8Security13AppleDatabase12authenticateERNS_9DbContextEmRKNS_17AccessCredentialsE +Security:single module:__ZN8Security13AppleDatabase13changeDbOwnerERNS_9DbContextERKNS_17AccessCredentialsERK24cssm_acl_owner_prototype +Security:single module:__ZN8Security13AppleDatabase14createRelationERNS_9DbContextEmPKcmRK29cssm_db_schema_attribute_infomRK25cssm_db_schema_index_info +Security:single module:__ZN8Security13AppleDatabase15destroyRelationERNS_9DbContextEm +Security:single module:__ZN8Security13AppleDatabase8dbCreateERNS_9DbContextERK11cssm_dbinfoPK20cssm_acl_entry_input +Security:single module:__ZN8Security13AppleDatabase8dbDeleteERNS_15DatabaseSessionEPKNS_17AccessCredentialsE +Security:single module:__ZN8Security13AppleDatabase8getDbAclERNS_9DbContextEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZN8Security13AppleDatabaseC2ERKNS_6DbNameEPKNS_22AppleDatabaseTableNameE +Security:single module:__ZN8Security13AppleDatabaseD1Ev +Security:single module:__ZN8Security13AppleDatabaseD2Ev +Security:single module:__ZN8Security13ModifiedTable10writeTableERNS_14AtomicTempFileEm +Security:single module:__ZN8Security13ModifiedTable11modifyTableEv +Security:single module:__ZN8Security13ModifiedTable12deleteRecordERKNS_8RecordIdE +Security:single module:__ZN8Security13ModifiedTable12insertRecordEmPK29cssm_db_record_attribute_dataPKNS_8CssmDataE +Security:single module:__ZN8Security13ModifiedTable12updateRecordERKNS_8RecordIdEPK29cssm_db_record_attribute_dataPKNS_8CssmDataEm +Security:single module:__ZN8Security13ModifiedTable16nextRecordNumberEv +Security:single module:__ZN8Security13ModifiedTable17writeIndexSectionERNS_12WriteSectionEm +Security:single module:__ZN8Security13ModifiedTable20createMutableIndexesEv +Security:single module:__ZN8Security13ModifiedTable9findIndexEmRKNS_10MetaRecordEb +Security:single module:__ZN8Security13ModifiedTableC1EPKNS_5TableE +Security:single module:__ZN8Security13ModifiedTableC1EPNS_10MetaRecordE +Security:single module:__ZN8Security13ModifiedTableC2EPKNS_5TableE +Security:single module:__ZN8Security13ModifiedTableC2EPNS_10MetaRecordE +Security:single module:__ZN8Security13ModifiedTableC4EPKNS_5TableE +Security:single module:__ZN8Security13ModifiedTableC4EPNS_10MetaRecordE +Security:single module:__ZN8Security13ModifiedTableD1Ev +Security:single module:__ZN8Security13ModifiedTableD2Ev +Security:single module:__ZN8Security13ModifiedTableD4Ev +Security:single module:__ZN8Security14AppleDbContextC2ERNS_8DatabaseERNS_15DatabaseSessionEmPKNS_17AccessCredentialsEPKv +Security:single module:__ZN8Security14AppleDbContextD1Ev +Security:single module:__ZN8Security14AppleDbContextD2Ev +Security:single module:__ZN8Security20AppleDatabaseManagerC2EPKNS_22AppleDatabaseTableNameE +Security:single module:__ZN8Security5TableC2ERKNS_11ReadSectionE +Security:single module:__ZN8Security5TableD2Ev +Security:single module:__ZN8Security6CursorD0Ev +Security:single module:__ZN8Security6CursorD1Ev +Security:single module:__ZN8Security9DbVersionC2ERKNS_13AppleDatabaseERKNS_10RefPointerINS_18AtomicBufferedFileEEE +Security:single module:__ZN8Security9DbVersionD2Ev +Security:single module:__ZNK8Security13AppleDatabase10recordNameEm +Security:single module:__ZNK8Security13AppleDatabase19getDbNameFromHandleERKNS_9DbContextE +Security:single module:__ZNK8Security13ModifiedTable13getMetaRecordEv +Security:single module:__ZNK8Security13ModifiedTable17recordNumberCountEv +Security:single module:__ZNK8Security5Table11popFreeListERm +Security:single module:__ZNK8Security5Table14matchesTableIdEm +Security:single module:__ZN8Security10AtomicFile13performDeleteEv +Security:single module:__ZN8Security10AtomicFile5writeEv +Security:single module:__ZN8Security10AtomicFile6createEt +Security:single module:__ZN8Security10AtomicFile6mkpathERKSst +Security:single module:__ZN8Security10AtomicFile6renameERKSs +Security:single module:__ZN8Security10AtomicFileC2ERKSs +Security:single module:__ZN8Security10AtomicFileD2Ev +Security:single module:__ZN8Security14AtomicTempFile5closeEv +Security:single module:__ZN8Security14AtomicTempFile5fsyncEv +Security:single module:__ZN8Security14AtomicTempFile5writeENS_10AtomicFile10OffsetTypeExPKhm +Security:single module:__ZN8Security14AtomicTempFile5writeENS_10AtomicFile10OffsetTypeExPKmm +Security:single module:__ZN8Security14AtomicTempFile5writeENS_10AtomicFile10OffsetTypeExm +Security:single module:__ZN8Security14AtomicTempFile6commitEv +Security:single module:__ZN8Security14AtomicTempFile6createEt +Security:single module:__ZN8Security14AtomicTempFile8rollbackEv +Security:single module:__ZN8Security14AtomicTempFileC1ERNS_10AtomicFileERKNS_10RefPointerINS_16AtomicLockedFileEEE +Security:single module:__ZN8Security14AtomicTempFileC1ERNS_10AtomicFileERKNS_10RefPointerINS_16AtomicLockedFileEEEt +Security:single module:__ZN8Security14AtomicTempFileC2ERNS_10AtomicFileERKNS_10RefPointerINS_16AtomicLockedFileEEE +Security:single module:__ZN8Security14AtomicTempFileC2ERNS_10AtomicFileERKNS_10RefPointerINS_16AtomicLockedFileEEEt +Security:single module:__ZN8Security14AtomicTempFileC4ERNS_10AtomicFileERKNS_10RefPointerINS_16AtomicLockedFileEEE +Security:single module:__ZN8Security14AtomicTempFileC4ERNS_10AtomicFileERKNS_10RefPointerINS_16AtomicLockedFileEEEt +Security:single module:__ZN8Security14AtomicTempFileD1Ev +Security:single module:__ZN8Security14AtomicTempFileD2Ev +Security:single module:__ZN8Security14AtomicTempFileD4Ev +Security:single module:__ZN8Security16AtomicLockedFile4lockEt +Security:single module:__ZN8Security16AtomicLockedFile5rlinkEPKcS2_R4stat +Security:single module:__ZN8Security16AtomicLockedFile6uniqueEt +Security:single module:__ZN8Security16AtomicLockedFile6unlockEv +Security:single module:__ZN8Security16AtomicLockedFile6xcreatEPKctRl +Security:single module:__ZN8Security16AtomicLockedFile8myrenameEPKcS2_ +Security:single module:__ZN8Security16AtomicLockedFileC1ERNS_10AtomicFileE +Security:single module:__ZN8Security16AtomicLockedFileC2ERNS_10AtomicFileE +Security:single module:__ZN8Security16AtomicLockedFileC4ERNS_10AtomicFileE +Security:single module:__ZN8Security16AtomicLockedFileD1Ev +Security:single module:__ZN8Security16AtomicLockedFileD2Ev +Security:single module:__ZN8Security16AtomicLockedFileD4Ev +Security:single module:__ZN8Security18AtomicBufferedFileC2ERKSs +Security:single module:__ZN8Security18AtomicBufferedFileD2Ev +Security:single module:__ZNK8Security10AtomicFile4modeEv +Security:single module:__ZN8Security17ModuleCallbackSet6Runner6actionEv +Security:single module:__ZNK8Security14ModuleCallbackclEmRKNS_4GuidEmm +Security:single module:__ZNK8Security17ModuleCallbackSetclEmRKNS_4GuidEmm +Security:single module:__ZN8Security7Context15deleteAttributeEm +Security:single module:__ZN8Security7Context7postIPCEPvP22cssm_context_attribute +Security:single module:__ZN8Security7ContextC1Emm +Security:single module:__ZN8Security10AclSubject10exportBlobERNS_23LowLevelMemoryUtilities6Writer7CounterES4_ +Security:single module:__ZN8Security10AclSubject10exportBlobERNS_23LowLevelMemoryUtilities6WriterES3_ +Security:single module:__ZN8Security10AclSubject10importBlobERNS_23LowLevelMemoryUtilities6ReaderES3_ +Security:single module:__ZN8Security10AclSubject5Maker5crackERKNS_8CssmListEmPPNS_11ListElementEz +Security:single module:__ZN8Security10AclSubject5Maker7getWordERKNS_11ListElementEii +Security:single module:__ZN8Security10AclSubject5MakerC1El +Security:single module:__ZN8Security10AclSubject5MakerC2El +Security:single module:__ZN8Security10AclSubject5MakerC4El +Security:single module:__ZN8Security10AclSubject5MakerD0Ev +Security:single module:__ZN8Security10AclSubject5MakerD1Ev +Security:single module:__ZN8Security10AclSubject5MakerD2Ev +Security:single module:__ZN8Security10AclSubject5MakerD4Ev +Security:single module:__ZN8Security10AclSubjectD0Ev +Security:single module:__ZN8Security10AclSubjectD1Ev +Security:single module:__ZN8Security20AclValidationContextD0Ev +Security:single module:__ZN8Security20AclValidationContextD1Ev +Security:single module:__ZN8Security24AclValidationEnvironmentD0Ev +Security:single module:__ZN8Security24AclValidationEnvironmentD1Ev +Security:single module:__ZN8Security9ObjectAcl10changedAclEv +Security:single module:__ZN8Security9ObjectAcl10cssmGetAclEPKcRmRPNS_12AclEntryInfoE +Security:single module:__ZN8Security9ObjectAcl10exportBlobERNS_8CssmDataES2_ +Security:single module:__ZN8Security9ObjectAcl12cssmGetOwnerERNS_17AclOwnerPrototypeE +Security:single module:__ZN8Security9ObjectAcl13cssmChangeAclERKNS_7AclEditEPKNS_17AccessCredentialsEPNS_24AclValidationEnvironmentE +Security:single module:__ZN8Security9ObjectAcl13validateOwnerElPKNS_17AccessCredentialsEPNS_24AclValidationEnvironmentE +Security:single module:__ZN8Security9ObjectAcl14cssmSetInitialERKNS_10RefPointerINS_10AclSubjectEEE +Security:single module:__ZN8Security9ObjectAcl14cssmSetInitialERKNS_17AclEntryPrototypeE +Security:single module:__ZN8Security9ObjectAcl14instantiateAclEv +Security:single module:__ZN8Security9ObjectAcl15cssmChangeOwnerERKNS_17AclOwnerPrototypeEPKNS_17AccessCredentialsEPNS_24AclValidationEnvironmentE +Security:single module:__ZN8Security9ObjectAcl15findEntryHandleEm +Security:single module:__ZN8Security9ObjectAcl4makeERKNS_9TypedListE +Security:single module:__ZN8Security9ObjectAcl5Entry4initERKNS_10RefPointerINS_10AclSubjectEEEb +Security:single module:__ZN8Security9ObjectAcl5EntryD0Ev +Security:single module:__ZN8Security9ObjectAcl5EntryD1Ev +Security:single module:__ZN8Security9ObjectAcl8AclEntryC1ERKNS_10RefPointerINS_10AclSubjectEEE +Security:single module:__ZN8Security9ObjectAcl8AclEntryC1ERKNS_17AclEntryPrototypeE +Security:single module:__ZN8Security9ObjectAcl8AclEntryC2ERKNS_10RefPointerINS_10AclSubjectEEE +Security:single module:__ZN8Security9ObjectAcl8AclEntryC2ERKNS_17AclEntryPrototypeE +Security:single module:__ZN8Security9ObjectAcl8AclEntryC4ERKNS_10RefPointerINS_10AclSubjectEEE +Security:single module:__ZN8Security9ObjectAcl8AclEntryC4ERKNS_17AclEntryPrototypeE +Security:single module:__ZN8Security9ObjectAclC1ERKNS_17AclEntryPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security9ObjectAclC1ERNS_13CssmAllocatorE +Security:single module:__ZN8Security9ObjectAclC2ERKNS_17AclEntryPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security9ObjectAclC4ERKNS_17AclEntryPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security9ObjectAclD0Ev +Security:single module:__ZN8Security9ObjectAclD1Ev +Security:single module:__ZNK8Security10AclSubject9debugDumpEv +Security:single module:__ZNK8Security9ObjectAcl10OwnerEntry10authorizesEl +Security:single module:__ZNK8Security9ObjectAcl10OwnerEntry8validateERKNS_20AclValidationContextE +Security:single module:__ZNK8Security9ObjectAcl8AclEntry11toEntryInfoER24cssm_acl_entry_prototypeRNS_13CssmAllocatorE +Security:single module:__ZNK8Security9ObjectAcl9debugDumpEPKc +Security:single module:__ZN8Security18AuthorizationGroupC2ERKSt3setIlSt4lessIlESaIlEERNS_13CssmAllocatorE +Security:single module:__ZN8Security18AuthorizationGroupC1ERKSt3setIlSt4lessIlESaIlEERNS_13CssmAllocatorE +Security:single module:__ZN8Security18AuthorizationGroupC4ERKSt3setIlSt4lessIlESaIlEERNS_13CssmAllocatorE +Security:single module:__ZN8Security18AuthorizationGroup7destroyERNS_13CssmAllocatorE +Security:single module:__ZNK8Security18AuthorizationGroup8containsEl +Security:single module:__ZNK8Security18AuthorizationGroupcvSt3setIlSt4lessIlESaIlEEEv +Security:single module:__ZN8Security17AclEntryPrototypeC2ERKNS_17AclOwnerPrototypeE +Security:single module:__ZN8Security17AclEntryPrototypeC1ERKNS_17AclOwnerPrototypeE +Security:single module:__ZN8Security17AclEntryPrototypeC4ERKNS_17AclOwnerPrototypeE +Security:single module:__ZN8Security17AclEntryPrototype3tagEPKc +Security:single module:__ZN8Security21AutoAclOwnerPrototype4makeEv +Security:single module:__ZN8Security21AutoAclOwnerPrototypeD2Ev +Security:single module:__ZN8Security21AutoAclOwnerPrototypeD1Ev +Security:single module:__ZN8Security21AutoAclOwnerPrototypeD4Ev +Security:single module:__ZN8Security21AutoAclOwnerPrototype9allocatorERNS_13CssmAllocatorE +Security:single module:__ZN8Security20AutoAclEntryInfoListD2Ev +Security:single module:__ZN8Security20AutoAclEntryInfoListD1Ev +Security:single module:__ZN8Security20AutoAclEntryInfoListD4Ev +Security:single module:__ZN8Security20AutoAclEntryInfoList9allocatorERNS_13CssmAllocatorE +Security:single module:__ZN22SensitiveCssmAllocator7reallocEPvm +Security:single module:__ZN8Security13CssmAllocatorD0Ev +Security:single module:__ZN8Security13CssmAllocatorD1Ev +Security:single module:__ZN8Security17TrackingAllocatorD0Ev +Security:single module:__ZN8Security17TrackingAllocatorD2Ev +Security:single module:__ZN8Security28CssmAllocatorMemoryFunctions11relayCallocEmmPv +Security:single module:__ZN8Security28CssmAllocatorMemoryFunctionsC2ERNS_13CssmAllocatorE +Security:single module:__ZN8Security8CssmHeapdlEPvm +Security:single module:__ZN8Security8CssmHeapdlEPvmPNS_13CssmAllocatorE +Security:single module:__ZN8Security8CssmHeapnwEmPNS_13CssmAllocatorE +Security:single module:__ZNK8Security13CssmAllocatoreqERKS0_ +Security:single module:__ZN8Security15AutoCredentialsC1ERNS_13CssmAllocatorE +Security:single module:__ZN8Security15AutoCredentialsC2ERNS_13CssmAllocatorE +Security:single module:__ZN8Security15AutoCredentialsC2ERNS_13CssmAllocatorEm +Security:single module:__ZN8Security15AutoCredentialsC4ERNS_13CssmAllocatorE +Security:single module:__ZNK8Security11SampleGroup7collectElRSt4listINS_10CssmSampleESaIS2_EE +Security:single module:__ZN8Security12CssmDateDataC1ERK9cssm_date +Security:single module:__ZN8Security12CssmDateDataC2ERK9cssm_date +Security:single module:__ZN8Security12CssmDateDataC4ERK9cssm_date +Security:single module:__ZN8Security12CssmGuidDataC1ERK9cssm_guid +Security:single module:__ZN8Security12CssmGuidDataC2ERK9cssm_guid +Security:single module:__ZN8Security12CssmGuidDataC4ERK9cssm_guid +Security:single module:__ZN8Security13CssmOwnedData3setERNS_15CssmManagedDataE +Security:single module:__ZN8Security15CssmManagedDataD0Ev +Security:single module:__ZN8Security15CssmManagedDataD1Ev +Security:single module:__ZN8SecurityeqERK9cssm_dataS2_ +Security:single module:__ZNK8Security14CssmDLPolyDatacvNS_4GuidEEv +Security:single module:__ZN8Security8CssmDateC2EPKcS2_S2_ +Security:single module:__ZN8Security8CssmDateC1EPKcS2_S2_ +Security:single module:__ZN8Security8CssmDateC4EPKcS2_S2_ +Security:single module:__ZN8Security8CssmDateC2Eiii +Security:single module:__ZN8Security8CssmDateC1Eiii +Security:single module:__ZN8Security8CssmDateC4Eiii +Security:single module:__ZNK8Security8CssmDate4yearEv +Security:single module:__ZNK8Security8CssmDate5monthEv +Security:single module:__ZNK8Security8CssmDate3dayEv +Security:single module:__ZN8Security8CssmDate6assignEPciPKc +Security:single module:__ZN8Security15CssmUniformDateC2EPK8__CFDate +Security:single module:__ZN8Security15CssmUniformDateC1EPK8__CFDate +Security:single module:__ZN8Security15CssmUniformDateC4EPK8__CFDate +Security:single module:__ZNK8Security15CssmUniformDatecvPK8__CFDateEv +Security:single module:__ZN8Security15CssmUniformDateC2ERKNS_8CssmDateE +Security:single module:__ZN8Security15CssmUniformDateC1ERKNS_8CssmDateE +Security:single module:__ZN8Security15CssmUniformDateC4ERKNS_8CssmDateE +Security:single module:__ZNK8Security15CssmUniformDatecvNS_8CssmDateEEv +Security:single module:__ZN8Security15CssmUniformDateC2ERK9cssm_data +Security:single module:__ZN8Security15CssmUniformDateC1ERK9cssm_data +Security:single module:__ZN8Security15CssmUniformDateC4ERK9cssm_data +Security:single module:__ZNK8Security15CssmUniformDate9convertToERNS_13CssmOwnedDataE +Security:single module:__ZN8Security15CssmUniformDateC2EPKc +Security:single module:__ZN8Security15CssmUniformDateC1EPKc +Security:single module:__ZN8Security15CssmUniformDateC4EPKc +Security:single module:__ZNK8Security15CssmUniformDate9convertToEPcm +Security:single module:__ZN8Security15CssmUniformDate13setFromStringEPKcS2_m +Security:single module:__ZN8Security13CssmAutoQueryC1ERK10cssm_queryRNS_13CssmAllocatorE +Security:single module:__ZN8Security13CssmAutoQueryD1Ev +Security:single module:__ZN8Security19CssmDbAttributeData11deleteValueERKNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security19CssmDbAttributeData12deleteValuesERKS0_RNS_13CssmAllocatorE +Security:single module:__ZN8Security19CssmDbAttributeData3addERKS0_RNS_13CssmAllocatorE +Security:single module:__ZN8Security25CssmDbRecordAttributeData4findERK22cssm_db_attribute_info +Security:single module:__ZN8Security29CssmAutoDbRecordAttributeData3addERK22cssm_db_attribute_infoRKNS_12CssmPolyDataE +Security:single module:__ZN8Security29CssmAutoDbRecordAttributeDataD1Ev +Security:single module:__ZNK8Security19CssmDbAttributeDataltERKS0_ +Security:single module:__ZNK8Security19CssmDbAttributeInfoeqERKS0_ +Security:single module:__ZNK8Security19CssmDbAttributeInfoltERKS0_ +Security:single module:__ZNK8Security25CssmDbRecordAttributeDataltERKS0_ +Security:single module:__ZN8Security8ErrorMapC2Ev +Security:single module:__ZN8Security8ErrorMapC1Ev +Security:single module:__ZN8Security8ErrorMapC4Ev +Security:single module:_cssmPerror +Security:single module:__ZN8Security15cssmErrorStringEl +Security:single module:__ZN8Security15cssmErrorStringERKNS_15CssmCommonErrorE +Security:single module:__ZN8Security11ListElement4dataEv +Security:single module:__ZN8Security11ListElement5clearERNS_13CssmAllocatorE +Security:single module:__ZN8Security11ListElement9typedListEv +Security:single module:__ZN8Security11ListElementC1ERKNS_8CssmDataE +Security:single module:__ZN8Security11ListElementC1ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security11ListElementC1ERNS_13CssmAllocatorERKSs +Security:single module:__ZN8Security11ListElementC2ERKNS_8CssmDataE +Security:single module:__ZN8Security11ListElementC2ERKNS_8CssmListE +Security:single module:__ZN8Security11ListElementC2ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security11ListElementC2ERNS_13CssmAllocatorERKSs +Security:single module:__ZN8Security11ListElementC2El +Security:single module:__ZN8Security11ListElementC4ERKNS_8CssmDataE +Security:single module:__ZN8Security11ListElementC4ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security11ListElementC4ERNS_13CssmAllocatorERKSs +Security:single module:__ZN8Security8CssmList4snipEv +Security:single module:__ZN8Security8CssmList5clearERNS_13CssmAllocatorE +Security:single module:__ZN8Security8CssmList6insertEPNS_11ListElementES2_ +Security:single module:__ZN8Security8CssmList6removeEPNS_11ListElementE +Security:single module:__ZN8Security9TypedListC1ERNS_13CssmAllocatorElPNS_11ListElementES4_ +Security:single module:__ZN8Security9TypedListC1ERNS_13CssmAllocatorElPNS_11ListElementES4_S4_ +Security:single module:__ZN8Security9TypedListC1ERNS_13CssmAllocatorElPNS_11ListElementES4_S4_S4_ +Security:single module:__ZN8Security9TypedListC2ERNS_13CssmAllocatorEl +Security:single module:__ZN8Security9TypedListC2ERNS_13CssmAllocatorElPNS_11ListElementE +Security:single module:__ZN8Security9TypedListC2ERNS_13CssmAllocatorElPNS_11ListElementES4_ +Security:single module:__ZN8Security9TypedListC2ERNS_13CssmAllocatorElPNS_11ListElementES4_S4_ +Security:single module:__ZN8Security9TypedListC2ERNS_13CssmAllocatorElPNS_11ListElementES4_S4_S4_ +Security:single module:__ZN8Security9TypedListC4ERNS_13CssmAllocatorElPNS_11ListElementES4_ +Security:single module:__ZN8Security9TypedListC4ERNS_13CssmAllocatorElPNS_11ListElementES4_S4_ +Security:single module:__ZN8Security9TypedListC4ERNS_13CssmAllocatorElPNS_11ListElementES4_S4_S4_ +Security:single module:__ZNK8Security11ListElement4dataEv +Security:single module:__ZNK8Security11ListElement4listEv +Security:single module:__ZNK8Security11ListElement9typedListEv +Security:single module:__ZNK8Security8CssmList6lengthEv +Security:single module:__ZNK8Security8CssmListixEj +Security:single module:__ZNK8Security9TypedList11checkProperEl +Security:single module:__ZN8Security6Daemon9incarnateEv +Security:single module:__ZN8Security6Daemon11executeSelfEPPc +Security:single module:__ZN8Security15DatabaseManager10getDbNamesERNS_15DatabaseSessionE +Security:single module:__ZN8Security15DatabaseManager12freeNameListERNS_15DatabaseSessionER14cssm_name_list +Security:single module:__ZN8Security15DatabaseManager8dbCreateERNS_15DatabaseSessionERKNS_6DbNameERK11cssm_dbinfomPK29cssm_resource_control_contextPKv +Security:single module:__ZN8Security15DatabaseManager8dbDeleteERNS_15DatabaseSessionERKNS_6DbNameEPKNS_17AccessCredentialsE +Security:single module:__ZN8Security15DatabaseManagerC1Ev +Security:single module:__ZN8Security15DatabaseManagerD0Ev +Security:single module:__ZN8Security15DatabaseManagerD1Ev +Security:single module:__ZN8Security15DatabaseManagerD2Ev +Security:single module:__ZN8Security15DatabaseManagerD4Ev +Security:single module:__ZN8Security8Database9_dbCreateERNS_15DatabaseSessionERK11cssm_dbinfomPK29cssm_resource_control_contextPKv +Security:single module:__ZN8Security8DatabaseC1ERKNS_6DbNameE +Security:single module:__ZN8Security8DatabaseD0Ev +Security:single module:__ZN8Security8DatabaseD1Ev +Security:single module:__ZN8Security15DatabaseSession10DataDeleteEmRK21cssm_db_unique_record +Security:single module:__ZN8Security15DatabaseSession10DataInsertEmmPK29cssm_db_record_attribute_dataPKNS_8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN8Security15DatabaseSession10DataModifyEmmR21cssm_db_unique_recordPK29cssm_db_record_attribute_dataPKNS_8CssmDataEm +Security:single module:__ZN8Security15DatabaseSession10GetDbNamesERP14cssm_name_list +Security:single module:__ZN8Security15DatabaseSession10GetDbOwnerEmR24cssm_acl_owner_prototype +Security:single module:__ZN8Security15DatabaseSession11ChangeDbAclEmRKNS_17AccessCredentialsERK13cssm_acl_edit +Security:single module:__ZN8Security15DatabaseSession11PassThroughEmmPKvPPv +Security:single module:__ZN8Security15DatabaseSession12AuthenticateEmmRKNS_17AccessCredentialsE +Security:single module:__ZN8Security15DatabaseSession12FreeNameListER14cssm_name_list +Security:single module:__ZN8Security15DatabaseSession13ChangeDbOwnerEmRKNS_17AccessCredentialsERK24cssm_acl_owner_prototype +Security:single module:__ZN8Security15DatabaseSession14CreateRelationEmmPKcmRK29cssm_db_schema_attribute_infomRK25cssm_db_schema_index_info +Security:single module:__ZN8Security15DatabaseSession15DestroyRelationEmm +Security:single module:__ZN8Security15DatabaseSession19GetDbNameFromHandleEmPPc +Security:single module:__ZN8Security15DatabaseSession8DbCreateEPKcPK16cssm_net_addressRK11cssm_dbinfomPK29cssm_resource_control_contextPKvRm +Security:single module:__ZN8Security15DatabaseSession8DbDeleteEPKcPK16cssm_net_addressPKNS_17AccessCredentialsE +Security:single module:__ZN8Security15DatabaseSession8GetDbAclEmPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZN8Security15DatabaseSession8closeAllEv +Security:single module:__ZN8Security15DatabaseSessionC1ERNS_15DatabaseManagerE +Security:single module:__ZN8Security15DatabaseSessionD0Ev +Security:single module:__ZN8Security15DatabaseSessionD1Ev +Security:single module:__ZThn4_N8Security15DatabaseSessionD0Ev +Security:single module:__ZThn4_N8Security15DatabaseSessionD1Ev +Security:single module:__ZN8Security9DbContextC1ERNS_8DatabaseERNS_15DatabaseSessionEmPK23cssm_access_credentials +Security:single module:__ZN8Security9DbContextD0Ev +Security:single module:__ZN8Security9DbContextD1Ev +Security:single module:__ZN8Security10DbQueryKeyC2ERKNS_12DbConstIndexE +Security:single module:__ZN8Security12DbConstIndexC1ERKNS_5TableEmb +Security:single module:__ZN8Security12DbConstIndexC2ERKNS_5TableERKNS_11ReadSectionE +Security:single module:__ZN8Security12DbConstIndexC2ERKNS_5TableEmb +Security:single module:__ZN8Security12DbConstIndexC4ERKNS_5TableEmb +Security:single module:__ZN8Security14DbMutableIndex10writeIndexERNS_12WriteSectionEm +Security:single module:__ZN8Security14DbMutableIndex12insertRecordEmRKNS_11ReadSectionE +Security:single module:__ZN8Security14DbMutableIndex12removeRecordEm +Security:single module:__ZN8Security14DbMutableIndex17insertRecordMultiEmRKNS_11ReadSectionEmRNS_12WriteSectionEm +Security:single module:__ZN8Security14DbMutableIndex18insertRecordSingleEmRKNS_11ReadSectionE +Security:single module:__ZN8Security14DbMutableIndexC1ERKNS_10MetaRecordEmb +Security:single module:__ZN8Security14DbMutableIndexC1ERKNS_12DbConstIndexE +Security:single module:__ZN8Security14DbMutableIndexC2ERKNS_10MetaRecordEmb +Security:single module:__ZN8Security14DbMutableIndexC2ERKNS_12DbConstIndexE +Security:single module:__ZN8Security14DbMutableIndexC4ERKNS_10MetaRecordEmb +Security:single module:__ZN8Security14DbMutableIndexC4ERKNS_12DbConstIndexE +Security:single module:__ZN8Security14DbMutableIndexD1Ev +Security:single module:__ZN8Security14DbMutableIndexD2Ev +Security:single module:__ZN8Security14DbMutableIndexD4Ev +Security:single module:__ZN8Security7DbIndexC1ERKNS_10MetaRecordEmb +Security:single module:__ZNK8Security10DbIndexKeyltERKS0_ +Security:single module:__ZN8Security14CssmNetAddressC1ERK16cssm_net_address +Security:single module:__ZN8Security14CssmNetAddressC1EmRKNS_8CssmDataE +Security:single module:__ZN8Security14CssmNetAddressC2ERK16cssm_net_address +Security:single module:__ZN8Security14CssmNetAddressC2EmRKNS_8CssmDataE +Security:single module:__ZN8Security14CssmNetAddressC4ERK16cssm_net_address +Security:single module:__ZN8Security14CssmNetAddressC4EmRKNS_8CssmDataE +Security:single module:__ZN8Security14CssmNetAddressD1Ev +Security:single module:__ZN8Security14CssmNetAddressD2Ev +Security:single module:__ZN8Security14CssmNetAddressD4Ev +Security:single module:__ZN8Security6DbNameC2EPKcPK16cssm_net_address +Security:single module:__ZN8Security6DbNameC2ERKS0_ +Security:single module:__ZN8Security6DbNameD2Ev +Security:single module:__ZN8Security6DbNameaSERKS0_ +Security:single module:__ZN8Security7DbQueryC2Ev +Security:single module:__ZN8Security7DbQueryC1Ev +Security:single module:__ZN8Security7DbQueryC4Ev +Security:single module:__ZN8Security7DbQueryD2Ev +Security:single module:__ZN8Security7DbQueryD1Ev +Security:single module:__ZN8Security7DbQueryD0Ev +Security:single module:__ZN8Security7DbQueryD4Ev +Security:single module:__ZN8Security11BigNumValue7compareEPKhS2_i +Security:single module:__ZN8Security11BigNumValueC1ERK9cssm_data +Security:single module:__ZN8Security11BigNumValueC1ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11BigNumValueC2ERK9cssm_data +Security:single module:__ZN8Security11BigNumValueC2ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11BigNumValueC4ERK9cssm_data +Security:single module:__ZN8Security11BigNumValueC4ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11BigNumValueD0Ev +Security:single module:__ZN8Security11BigNumValueD1Ev +Security:single module:__ZN8Security11BigNumValueD2Ev +Security:single module:__ZN8Security11BigNumValueD4Ev +Security:single module:__ZN8Security11DoubleValueC1ERK9cssm_data +Security:single module:__ZN8Security11DoubleValueC1ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11DoubleValueC2ERK9cssm_data +Security:single module:__ZN8Security11DoubleValueC2ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11DoubleValueC4ERK9cssm_data +Security:single module:__ZN8Security11DoubleValueC4ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11DoubleValueD0Ev +Security:single module:__ZN8Security11DoubleValueD1Ev +Security:single module:__ZN8Security11DoubleValueD2Ev +Security:single module:__ZN8Security11DoubleValueD4Ev +Security:single module:__ZN8Security11SInt32ValueC1ERK9cssm_data +Security:single module:__ZN8Security11SInt32ValueC1ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11SInt32ValueC2ERK9cssm_data +Security:single module:__ZN8Security11SInt32ValueC2ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11SInt32ValueC4ERK9cssm_data +Security:single module:__ZN8Security11SInt32ValueC4ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11SInt32ValueD0Ev +Security:single module:__ZN8Security11SInt32ValueD1Ev +Security:single module:__ZN8Security11SInt32ValueD2Ev +Security:single module:__ZN8Security11SInt32ValueD4Ev +Security:single module:__ZN8Security11StringValue10ComparatorclEPKhS3_m +Security:single module:__ZN8Security11StringValueC1ERK9cssm_data +Security:single module:__ZN8Security11StringValueC2ERK9cssm_data +Security:single module:__ZN8Security11StringValueC2ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11StringValueC4ERK9cssm_data +Security:single module:__ZN8Security11StringValueD0Ev +Security:single module:__ZN8Security11StringValueD2Ev +Security:single module:__ZN8Security11UInt32ValueC2ERK9cssm_data +Security:single module:__ZN8Security11UInt32ValueC2ERKNS_11ReadSectionERm +Security:single module:__ZN8Security11UInt32ValueD2Ev +Security:single module:__ZN8Security13TimeDateValueC1ERK9cssm_data +Security:single module:__ZN8Security13TimeDateValueC1ERKNS_11ReadSectionERm +Security:single module:__ZN8Security13TimeDateValueC2ERK9cssm_data +Security:single module:__ZN8Security13TimeDateValueC2ERKNS_11ReadSectionERm +Security:single module:__ZN8Security13TimeDateValueC4ERK9cssm_data +Security:single module:__ZN8Security13TimeDateValueC4ERKNS_11ReadSectionERm +Security:single module:__ZN8Security13TimeDateValueD0Ev +Security:single module:__ZN8Security13TimeDateValueD1Ev +Security:single module:__ZN8Security13TimeDateValueD2Ev +Security:single module:__ZN8Security13TimeDateValueD4Ev +Security:single module:__ZN8Security16MultiUInt32ValueC1ERK9cssm_data +Security:single module:__ZN8Security16MultiUInt32ValueC1ERKNS_11ReadSectionERm +Security:single module:__ZN8Security16MultiUInt32ValueC2ERK9cssm_data +Security:single module:__ZN8Security16MultiUInt32ValueC2ERKNS_11ReadSectionERm +Security:single module:__ZN8Security16MultiUInt32ValueC4ERK9cssm_data +Security:single module:__ZN8Security16MultiUInt32ValueC4ERKNS_11ReadSectionERm +Security:single module:__ZN8Security16MultiUInt32ValueD0Ev +Security:single module:__ZN8Security16MultiUInt32ValueD1Ev +Security:single module:__ZN8Security16MultiUInt32ValueD2Ev +Security:single module:__ZN8Security16MultiUInt32ValueD4Ev +Security:single module:__ZN8Security7DbValueD0Ev +Security:single module:__ZN8Security7DbValueD1Ev +Security:single module:__ZN8Security9BlobValue10ComparatorD0Ev +Security:single module:__ZN8Security9BlobValue10ComparatorD2Ev +Security:single module:__ZN8Security9BlobValueC2ERK9cssm_data +Security:single module:__ZNK8Security11BigNumValue8evaluateERKS0_m +Security:single module:__ZNK8Security11DoubleValue4packERNS_12WriteSectionERm +Security:single module:__ZNK8Security11SInt32Value4packERNS_12WriteSectionERm +Security:single module:__ZNK8Security11StringValue8evaluateERKS0_m +Security:single module:__ZNK8Security11UInt32Value4packERNS_12WriteSectionERm +Security:single module:__ZNK8Security13TimeDateValue10rangeValueEmm +Security:single module:__ZNK8Security13TimeDateValue11isValidDateEv +Security:single module:__ZNK8Security13TimeDateValue4packERNS_12WriteSectionERm +Security:single module:__ZNK8Security16MultiUInt32Value4packERNS_12WriteSectionERm +Security:single module:__ZNK8Security16MultiUInt32Value8evaluateERKS0_m +Security:single module:__ZN8Security5Debug10SyslogSink3putEPKcj +Security:single module:__ZN8Security5Debug10SyslogSink4dumpEPKc +Security:single module:__ZN8Security5Debug10SyslogSink9configureEPKc +Security:single module:__ZN8Security5Debug4dumpEPKcz +Security:single module:__ZN8Security5Debug6Target10terminatorEv +Security:single module:__ZN8Security5Debug6Target18setFromEnvironmentEv +Security:single module:__ZN8Security5Debug6Target2toEP7__sFILE +Security:single module:__ZN8Security5Debug6Target2toEPKc +Security:single module:__ZN8Security5Debug6Target2toEPNS1_4SinkE +Security:single module:__ZN8Security5Debug6Target2toEi +Security:single module:__ZN8Security5Debug6Target4Sink4dumpEPKc +Security:single module:__ZN8Security5Debug6Target4Sink9configureEPKc +Security:single module:__ZN8Security5Debug6Target4SinkD0Ev +Security:single module:__ZN8Security5Debug6Target4SinkD1Ev +Security:single module:__ZN8Security5Debug6Target4SinkD2Ev +Security:single module:__ZN8Security5Debug6Target4SinkD4Ev +Security:single module:__ZN8Security5Debug6Target4dumpEPKc +Security:single module:__ZN8Security5Debug6Target4dumpEPKcPc +Security:single module:__ZN8Security5Debug6Target8SelectorC1Ev +Security:single module:__ZN8Security5Debug6Target8SelectorC2Ev +Security:single module:__ZN8Security5Debug6Target8SelectorC4Ev +Security:single module:__ZN8Security5Debug6Target8SelectoraSEPKc +Security:single module:__ZN8Security5Debug6Target9configureEPKc +Security:single module:__ZN8Security5Debug6Target9configureEv +Security:single module:__ZN8Security5Debug6Target9debuggingEPKc +Security:single module:__ZN8Security5Debug6TargetC1Ev +Security:single module:__ZN8Security5Debug6TargetC2Ev +Security:single module:__ZN8Security5Debug6TargetC4Ev +Security:single module:__ZN8Security5Debug6TargetD0Ev +Security:single module:__ZN8Security5Debug6TargetD1Ev +Security:single module:__ZN8Security5Debug6TargetD2Ev +Security:single module:__ZN8Security5Debug6TargetD4Ev +Security:single module:__ZN8Security5Debug6vdebugEPKcS2_Pc +Security:single module:__ZN8Security5Debug7dumpingEPKc +Security:single module:__ZN8Security5Debug8FileSink3putEPKcj +Security:single module:__ZN8Security5Debug8FileSink4dumpEPKc +Security:single module:__ZN8Security5Debug8FileSink9configureEPKc +Security:single module:__ZN8Security5Debug8dumpDataEPKcPKvm +Security:single module:__ZN8Security5Debug8dumpDataEPKvm +Security:single module:__ZN8Security5Debug9debuggingEPKc +Security:single module:___security_debug +Security:single module:___security_debugging +Security:single module:__ZN8Security11GlobalNexus5ErrorD0Ev +Security:single module:__ZN8Security11GlobalNexus5ErrorD1Ev +Security:single module:__ZN8Security11GlobalNexus5ErrorD2Ev +Security:single module:__ZN8Security11GlobalNexus5ErrorD4Ev +Security:single module:__ZN8Security16ProcessNexusBaseC1EPKc +Security:single module:__ZN8Security16ProcessNexusBaseC2EPKc +Security:single module:__ZN8Security16ProcessNexusBaseC4EPKc +Security:single module:__ZN8Security12HandleObject4lockEv +Security:single module:__ZN8Security12HandleObject5StateC2Ev +Security:single module:__ZN8Security12HandleObject7tryLockEv +Security:single module:__ZN8Security12HandleObjectD0Ev +Security:single module:__ZN8Security12HandleObjectD1Ev +Security:single module:__ZN8Security6Syslog4openEPKcii +Security:single module:__ZN8Security6Syslog6outputEiPKcPc +Security:single module:__ZN8Security6Syslog6syslogEiPKcz +Security:single module:__ZN8Security6Syslog9emergencyEPKcz +Security:single module:__ZN8Security6Syslog5alertEPKcz +Security:single module:__ZN8Security6Syslog8criticalEPKcz +Security:single module:__ZN8Security6Syslog5errorEPKcz +Security:single module:__ZN8Security6Syslog7warningEPKcz +Security:single module:__ZN8Security6Syslog6noticeEPKcz +Security:single module:__ZN8Security6Syslog4infoEPKcz +Security:single module:__ZN8Security6Syslog5debugEPKcz +Security:single module:__ZN8Security6Syslog4maskEv +Security:single module:__ZN8Security6Syslog4uptoEi +Security:single module:__ZN8Security6Syslog6enableEi +Security:single module:__ZN8Security6Syslog7disableEi +Security:single module:__ZN8Security12MachPlusPlus11StBootstrapC2ERKNS0_9BootstrapERKNS0_8TaskPortE +Security:single module:__ZN8Security12MachPlusPlus11StBootstrapD1Ev +Security:single module:__ZN8Security12MachPlusPlus11StBootstrapD2Ev +Security:single module:__ZN8Security12MachPlusPlus11StBootstrapD4Ev +Security:single module:__ZN8Security12MachPlusPlus4Port12cancelNotifyEi +Security:single module:__ZN8Security12MachPlusPlus4Port7getRefsEj +Security:single module:__ZN8Security12MachPlusPlus5Error7throwMeEi +Security:single module:__ZN8Security12MachPlusPlus5ErrorC1Ei +Security:single module:__ZN8Security12MachPlusPlus5ErrorC2Ei +Security:single module:__ZN8Security12MachPlusPlus5ErrorC4Ei +Security:single module:__ZN8Security12MachPlusPlus5ErrorD0Ev +Security:single module:__ZN8Security12MachPlusPlus5ErrorD1Ev +Security:single module:__ZN8Security12MachPlusPlus5ErrorD2Ev +Security:single module:__ZN8Security12MachPlusPlus5ErrorD4Ev +Security:single module:__ZN8Security12MachPlusPlus7Message11sendReceiveEjijj +Security:single module:__ZN8Security12MachPlusPlus7Message4sendEijj +Security:single module:__ZN8Security12MachPlusPlus7Message5checkEi +Security:single module:__ZN8Security12MachPlusPlus7Message7receiveEjijj +Security:single module:__ZN8Security12MachPlusPlus7MessageC1EPvm +Security:single module:__ZN8Security12MachPlusPlus7MessageC1Em +Security:single module:__ZN8Security12MachPlusPlus7MessageC2EPvm +Security:single module:__ZN8Security12MachPlusPlus7MessageC2Em +Security:single module:__ZN8Security12MachPlusPlus7MessageC4EPvm +Security:single module:__ZN8Security12MachPlusPlus7MessageC4Em +Security:single module:__ZN8Security12MachPlusPlus7MessageD0Ev +Security:single module:__ZN8Security12MachPlusPlus7MessageD2Ev +Security:single module:__ZN8Security12MachPlusPlus8TaskPort6forPidEi +Security:single module:__ZN8Security12MachPlusPlus8allocateEm +Security:single module:__ZN8Security12MachPlusPlus9Bootstrap6subsetENS0_4PortE +Security:single module:__ZNK8Security12MachPlusPlus5Error8osStatusEv +Security:single module:__ZNK8Security12MachPlusPlus5Error9cssmErrorEv +Security:single module:__ZNK8Security12MachPlusPlus7PortSet7membersEv +Security:single module:__ZNK8Security12MachPlusPlus7PortSet8containsENS0_4PortE +Security:single module:__ZNK8Security12MachPlusPlus9Bootstrap10registerAsEjPKc +Security:single module:__ZNK8Security12MachPlusPlus9Bootstrap7checkInEPKc +Security:single module:__Xmach_notify_port_destroyed +Security:single module:__Xmach_notify_send_once +Security:single module:_notify_server_routine +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServer12alsoListenOnENS0_4PortE +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServer12stopListenOnENS0_4PortE +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerC1EPKc +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerC1EPKcRKNS0_9BootstrapE +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerC2EPKc +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerC4EPKc +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerD0Ev +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerD1Ev +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerD2Ev +Security:single module:__ZN8Security12MachPlusPlus17MachRunLoopServerD4Ev +Security:single module:__ZN8Security12MachPlusPlus10MachServer14NoReplyHandler6handleEP17mach_msg_header_tS4_ +Security:single module:__ZN8Security12MachPlusPlus10MachServer14notifyDeadNameENS0_4PortE +Security:single module:__ZN8Security12MachPlusPlus10MachServer14notifySendOnceENS0_4PortE +Security:single module:__ZN8Security12MachPlusPlus10MachServer15notifyNoSendersENS0_4PortEj +Security:single module:__ZN8Security12MachPlusPlus10MachServer19notifyPortDestroyedENS0_4PortE +Security:single module:__ZN8Security12MachPlusPlus10MachServer3addENS0_4PortE +Security:single module:__ZN8Security12MachPlusPlus10MachServer3addERNS1_7HandlerE +Security:single module:__ZN8Security12MachPlusPlus10MachServer3runEmi +Security:single module:__ZN8Security12MachPlusPlus10MachServer5setupEPKc +Security:single module:__ZN8Security12MachPlusPlus10MachServer6removeENS0_4PortE +Security:single module:__ZN8Security12MachPlusPlus10MachServer6removeERNS1_7HandlerE +Security:single module:__ZN8Security12MachPlusPlus10MachServer9addThreadEPNS_6ThreadE +Security:single module:__ZN8Security12MachPlusPlus10MachServerC1EPKc +Security:single module:__ZN8Security12MachPlusPlus10MachServerC1EPKcRKNS0_9BootstrapE +Security:single module:__ZN8Security12MachPlusPlus10MachServerC2EPKc +Security:single module:__ZN8Security12MachPlusPlus10MachServerC4EPKc +Security:single module:__ZN8Security12MachPlusPlus10MachServerD0Ev +Security:single module:__ZN8Security12MachPlusPlus10MachServerD1Ev +Security:single module:__ZN8Security12MachPlusPlus10MachServerD2Ev +Security:single module:__ZN8Security12MachPlusPlus10MachServerD4Ev +Security:single module:__ZNK8Security12MachPlusPlus10MachServer14notifyIfUnusedENS0_4PortEb +Security:single module:_cdsa_mach_notify_port_destroyed +Security:single module:_cdsa_mach_notify_send_once +Security:single module:__ZN8Security13MetaAttributeD0Ev +Security:single module:__ZN8Security13MetaAttributeD1Ev +Security:single module:__ZNK8Security13MetaAttribute13packAttributeERNS_12WriteSectionERmmPK9cssm_data +Security:single module:__ZNK8Security13MetaAttribute14copyValueBytesEmRKNS_11ReadSectionERNS_12WriteSectionERm +Security:single module:__ZNK8Security13MetaAttribute17getNumberOfValuesERKNS_11ReadSectionE +Security:single module:__ZNK8Security13MetaAttribute18packNumberOfValuesERNS_12WriteSectionEmRm +Security:single module:__ZN8Security10MetaRecordC1ERK29cssm_db_record_attribute_info +Security:single module:__ZN8Security10MetaRecordC1EmmPK29cssm_db_schema_attribute_info +Security:single module:__ZN8Security10MetaRecordC2ERK29cssm_db_record_attribute_info +Security:single module:__ZN8Security10MetaRecordC2Em +Security:single module:__ZN8Security10MetaRecordC2EmmPK29cssm_db_schema_attribute_info +Security:single module:__ZN8Security10MetaRecordC4ERK29cssm_db_record_attribute_info +Security:single module:__ZN8Security10MetaRecordC4EmmPK29cssm_db_schema_attribute_info +Security:single module:__ZN8Security10MetaRecordD2Ev +Security:single module:__ZNK8Security10MetaRecord10packRecordERNS_12WriteSectionEPK29cssm_db_record_attribute_dataPKNS_8CssmDataE +Security:single module:__ZNK8Security10MetaRecord12updateRecordERKNS_11ReadSectionERNS_12WriteSectionEPKNS_25CssmDbRecordAttributeDataEPKNS_8CssmDataEm +Security:single module:__ZN8Security11CodeSigning13GenericBundle12lookupSymbolEPKc +Security:single module:__ZN8Security11CodeSigning13GenericBundleD1Ev +Security:single module:__ZN8Security11CodeSigning14LoadableBundle4loadEv +Security:single module:__ZN8Security11CodeSigning14LoadableBundle6unloadEv +Security:single module:__ZNK8Security11CodeSigning14ExecutableTool13canonicalPathEv +Security:single module:__ZNK8Security11CodeSigning14LoadableBundle8isLoadedEv +Security:single module:__ZN8Security18SelectionPredicateC2ERKNS_10MetaRecordERK24cssm_selection_predicate +Security:single module:__ZN8Security18SelectionPredicateD2Ev +Security:single module:__ZN8Security12NestingMutex4lockEv +Security:single module:__ZN8Security12NestingMutex6unlockEv +Security:single module:__ZN8Security12NestingMutex7tryLockEv +Security:single module:__ZN8Security12NestingMutexC1Ev +Security:single module:__ZN8Security12NestingMutexC2Ev +Security:single module:__ZN8Security12NestingMutexC4Ev +Security:single module:__ZN8Security12ThreadRunner6actionEv +Security:single module:__ZN8Security12ThreadRunnerC1EPFvvE +Security:single module:__ZN8Security12ThreadRunnerC2EPFvvE +Security:single module:__ZN8Security12ThreadRunnerC4EPFvvE +Security:single module:__ZN8Security13CountingMutex10finishExitEv +Security:single module:__ZN8Security13CountingMutex5enterEv +Security:single module:__ZN8Security15ThreadStoreSlotC1EPFvPvE +Security:single module:__ZN8Security15ThreadStoreSlotD1Ev +Security:single module:__ZN8Security6Thread3runEv +Security:single module:__ZN8Security6Thread5yieldEv +Security:single module:__ZN8Security6Thread8Identity11getIdStringEPc +Security:single module:__ZN8Security6ThreadD0Ev +Security:single module:__ZN8Security6ThreadD1Ev +Security:single module:__ZN8Security10MacOSError7throwMeEi +Security:single module:__ZN8Security10MacOSErrorC1Ei +Security:single module:__ZN8Security10MacOSErrorC2Ei +Security:single module:__ZN8Security10MacOSErrorC4Ei +Security:single module:__ZN8Security15CryptoDataClassD0Ev +Security:single module:__ZN8Security15CryptoDataClassD1Ev +Security:single module:__ZN8Security15CryptoDataClassD2Ev +Security:single module:__ZN8Security15CryptoDataClassD4Ev +Security:single module:__ZN8Security15CssmCommonErrorC1ERKS0_ +Security:single module:__ZN8Security15CssmCommonErrorC1Ev +Security:single module:__ZN8Security15CssmCommonErrorC2ERKS0_ +Security:single module:__ZN8Security15CssmCommonErrorC4ERKS0_ +Security:single module:__ZN8Security15CssmCommonErrorD0Ev +Security:single module:__ZN8Security15CssmCommonErrorD1Ev +Security:single module:__ZN8Security17CssmSubserviceUidC2ERK9cssm_guidPK12cssm_versionmm +Security:single module:__ZN8Security4GuidC2EPKc +Security:single module:__ZN8Security7CssmKeyC1ERK8cssm_key +Security:single module:__ZN8Security7CssmKeyC1ERK9cssm_data +Security:single module:__ZN8Security7CssmKeyC2ERK9cssm_data +Security:single module:__ZN8Security7CssmKeyC2EmPv +Security:single module:__ZN8Security7CssmKeyC4ERK9cssm_data +Security:single module:__ZN8Security9CssmErrorC2El +Security:single module:__ZN8Security9UnixError4makeEi +Security:single module:__ZN8Security9UnixError7throwMeEi +Security:single module:__ZN8Security9UnixErrorC1Ei +Security:single module:__ZN8Security9UnixErrorC1Ev +Security:single module:__ZN8Security9UnixErrorC2Ei +Security:single module:__ZN8Security9UnixErrorC2Ev +Security:single module:__ZN8Security9UnixErrorC4Ei +Security:single module:__ZN8Security9UnixErrorC4Ev +Security:single module:__ZNK8Security10MacOSError4whatEv +Security:single module:__ZNK8Security10MacOSError8osStatusEv +Security:single module:__ZNK8Security10MacOSError9cssmErrorEv +Security:single module:__ZNK8Security15CssmCommonError13debugDiagnoseEPKv +Security:single module:__ZNK8Security15CssmCommonError8osStatusEv +Security:single module:__ZNK8Security15CssmCommonError9unixErrorEv +Security:single module:__ZNK8Security4Guid8toStringEPc +Security:single module:__ZNK8Security8CssmData8toStringEv +Security:single module:__ZNK8Security9CssmError4whatEv +Security:single module:__ZNK8Security9UnixError4whatEv +Security:single module:__ZNK8Security9UnixError8osStatusEv +Security:single module:__ZNK8Security9UnixError9cssmErrorEv +Security:single module:__ZNK8Security9UnixError9unixErrorEv +Security:single module:__ZN8Security11DataWalkers15ChunkFreeWalker4freeEv +Security:single module:__ZN15AttachmentMakerD0Ev +Security:single module:__ZN15AttachmentMakerD1Ev +Security:single module:__ZN15AttachmentMakerD2Ev +Security:single module:__ZN15AttachmentMakerD4Ev +Security:single module:__ZN17AttachmentFactoryC1Ev +Security:single module:__ZN10Attachment12upcallCallocEmmm +Security:single module:__ZN10Attachment16upcallCcToHandleEyPm +Security:single module:__ZN10Attachment19upcallGetModuleInfoEmP9cssm_guidP12cssm_versionPmS4_S4_S4_P17cssm_memory_funcsP19cssm_func_name_addrm +Security:single module:__ZN10AttachmentC1EP6ModuleRK12cssm_versionmmRK17cssm_memory_funcsmm +Security:single module:__ZN10AttachmentD0Ev +Security:single module:__ZN10AttachmentD1Ev +Security:single module:__ZThn12_N10AttachmentD0Ev +Security:single module:__ZThn12_N10AttachmentD1Ev +Security:single module:_CSSM_GetModuleGUIDFromHandle +Security:single module:_CSSM_GetPrivilege +Security:single module:_CSSM_GetSubserviceUIDFromHandle +Security:single module:_CSSM_Introduce +Security:single module:_CSSM_ListAttachedModuleManagers +Security:single module:_CSSM_SetPrivilege +Security:single module:_CSSM_Terminate +Security:single module:_CSSM_Unintroduce +Security:single module:__ZN13HandleContext4lockEv +Security:single module:__ZN13HandleContextD0Ev +Security:single module:__ZN13HandleContextD2Ev +Security:single module:__ZN12MdsComponent3MDSC2Ev +Security:single module:__ZN12MdsComponent3MDSD1Ev +Security:single module:__ZN12MdsComponent3MDSD2Ev +Security:single module:__ZN12MdsComponent3MDSD4Ev +Security:single module:__ZN12MdsComponentD0Ev +Security:single module:__ZN11CssmManager11unIntroduceERKN8Security4GuidE +Security:single module:__ZN11CssmManager9introduceERKN8Security4GuidEm +Security:single module:__ZN11CssmManager9terminateEv +Security:single module:__ZN11CssmManagerC2Ev +Security:single module:__ZN11CssmManagerD0Ev +Security:single module:__ZN11CssmManagerD1Ev +Security:single module:__ZN11CssmManagerD2Ev +Security:single module:__ZN11CssmManagerD4Ev +Security:single module:__ZN6Module13spiEventRelayEPK9cssm_guidPvmmm +Security:single module:__ZN6Module8spiEventEmRKN8Security4GuidEmm +Security:single module:__ZN6ModuleC2EP11CssmManagerRK12MdsComponentPN8Security6PluginE +Security:single module:__ZN6ModuleD1Ev +Security:single module:__ZN6ModuleD2Ev +Security:single module:_cssmAlgToOid +Security:single module:_CSSM_AC_AuthCompute +Security:single module:_CSSM_AC_PassThrough +Security:single module:_CSSM_CL_CertCreateTemplate +Security:single module:_CSSM_CL_CertDescribeFormat +Security:single module:_CSSM_CL_CertGetAllFields +Security:single module:_CSSM_CL_CertGetAllTemplateFields +Security:single module:_CSSM_CL_CertGetFirstFieldValue +Security:single module:_CSSM_CL_CertGetNextFieldValue +Security:single module:_CSSM_CL_CertGroupFromVerifiedBundle +Security:single module:_CSSM_CL_CertGroupToSignedBundle +Security:single module:_CSSM_CL_CertSign +Security:single module:_CSSM_CL_CertVerifyWithKey +Security:single module:_CSSM_CL_CrlAbortCache +Security:single module:_CSSM_CL_CrlAbortQuery +Security:single module:_CSSM_CL_CrlAddCert +Security:single module:_CSSM_CL_CrlCache +Security:single module:_CSSM_CL_CrlCreateTemplate +Security:single module:_CSSM_CL_CrlDescribeFormat +Security:single module:_CSSM_CL_CrlGetAllCachedRecordFields +Security:single module:_CSSM_CL_CrlGetAllFields +Security:single module:_CSSM_CL_CrlGetFirstCachedFieldValue +Security:single module:_CSSM_CL_CrlGetFirstFieldValue +Security:single module:_CSSM_CL_CrlGetNextCachedFieldValue +Security:single module:_CSSM_CL_CrlGetNextFieldValue +Security:single module:_CSSM_CL_CrlRemoveCert +Security:single module:_CSSM_CL_CrlSetFields +Security:single module:_CSSM_CL_CrlSign +Security:single module:_CSSM_CL_CrlVerify +Security:single module:_CSSM_CL_CrlVerifyWithKey +Security:single module:_CSSM_CL_FreeFields +Security:single module:_CSSM_CL_IsCertInCachedCrl +Security:single module:_CSSM_CL_IsCertInCrl +Security:single module:_CSSM_CL_PassThrough +Security:single module:_CSSM_CSP_ChangeLoginAcl +Security:single module:_CSSM_CSP_ChangeLoginOwner +Security:single module:_CSSM_CSP_CreateKeyGenContext +Security:single module:_CSSM_CSP_CreatePassThroughContext +Security:single module:_CSSM_CSP_CreateRandomGenContext +Security:single module:_CSSM_CSP_GetLoginAcl +Security:single module:_CSSM_CSP_GetLoginOwner +Security:single module:_CSSM_CSP_GetOperationalStatistics +Security:single module:_CSSM_CSP_Login +Security:single module:_CSSM_CSP_Logout +Security:single module:_CSSM_CSP_ObtainPrivateKeyFromPublicKey +Security:single module:_CSSM_CSP_PassThrough +Security:single module:_CSSM_ChangeKeyAcl +Security:single module:_CSSM_ChangeKeyOwner +Security:single module:_CSSM_DL_Authenticate +Security:single module:_CSSM_DL_ChangeDbAcl +Security:single module:_CSSM_DL_ChangeDbOwner +Security:single module:_CSSM_DL_CreateRelation +Security:single module:_CSSM_DL_DataDelete +Security:single module:_CSSM_DL_DataInsert +Security:single module:_CSSM_DL_DataModify +Security:single module:_CSSM_DL_DbCreate +Security:single module:_CSSM_DL_DbDelete +Security:single module:_CSSM_DL_DestroyRelation +Security:single module:_CSSM_DL_FreeNameList +Security:single module:_CSSM_DL_GetDbAcl +Security:single module:_CSSM_DL_GetDbNameFromHandle +Security:single module:_CSSM_DL_GetDbNames +Security:single module:_CSSM_DL_GetDbOwner +Security:single module:_CSSM_DL_PassThrough +Security:single module:_CSSM_DecryptDataInitP +Security:single module:_CSSM_DecryptDataP +Security:single module:_CSSM_DeleteContextAttributes +Security:single module:_CSSM_EncryptDataFinal +Security:single module:_CSSM_EncryptDataInitP +Security:single module:_CSSM_EncryptDataP +Security:single module:_CSSM_FreeContext +Security:single module:_CSSM_GenerateAlgorithmParams +Security:single module:_CSSM_GenerateKey +Security:single module:_CSSM_GenerateKeyP +Security:single module:_CSSM_GenerateKeyPair +Security:single module:_CSSM_GenerateKeyPairP +Security:single module:_CSSM_GenerateRandom +Security:single module:_CSSM_GetContext +Security:single module:_CSSM_GetContextAttribute +Security:single module:_CSSM_GetKeyAcl +Security:single module:_CSSM_GetKeyOwner +Security:single module:_CSSM_GetTimeValue +Security:single module:_CSSM_QuerySize +Security:single module:_CSSM_RetrieveCounter +Security:single module:_CSSM_RetrieveUniqueId +Security:single module:_CSSM_SignData +Security:single module:_CSSM_SignDataFinal +Security:single module:_CSSM_SignDataInit +Security:single module:_CSSM_SignDataUpdate +Security:single module:_CSSM_TP_ApplyCrlToDb +Security:single module:_CSSM_TP_CertCreateTemplate +Security:single module:_CSSM_TP_CertGetAllTemplateFields +Security:single module:_CSSM_TP_CertGroupConstruct +Security:single module:_CSSM_TP_CertGroupPrune +Security:single module:_CSSM_TP_CertGroupToTupleGroup +Security:single module:_CSSM_TP_CertReclaimAbort +Security:single module:_CSSM_TP_CertReclaimKey +Security:single module:_CSSM_TP_CertRemoveFromCrlTemplate +Security:single module:_CSSM_TP_CertRevoke +Security:single module:_CSSM_TP_CertSign +Security:single module:_CSSM_TP_ConfirmCredResult +Security:single module:_CSSM_TP_CrlCreateTemplate +Security:single module:_CSSM_TP_CrlSign +Security:single module:_CSSM_TP_CrlVerify +Security:single module:_CSSM_TP_FormRequest +Security:single module:_CSSM_TP_FormSubmit +Security:single module:_CSSM_TP_PassThrough +Security:single module:_CSSM_TP_ReceiveConfirmation +Security:single module:_CSSM_TP_RetrieveCredResult +Security:single module:_CSSM_TP_SubmitCredRequest +Security:single module:_CSSM_TP_TupleGroupToCertGroup +Security:single module:_CSSM_UnwrapKeyP +Security:single module:_CSSM_VerifyDataFinal +Security:single module:_CSSM_VerifyDataInit +Security:single module:_CSSM_VerifyDataUpdate +Security:single module:_CSSM_VerifyDevice +Security:single module:_CSSM_VerifyMacFinal +Security:single module:_CSSM_VerifyMacInit +Security:single module:_CSSM_VerifyMacUpdate +Security:single module:_CSSM_WrapKey +Security:single module:_CSSM_WrapKeyP +Security:single module:__Z14sslKeyToSigAlgPK8cssm_keyRm +Security:single module:__Z18sslAddBlindingAttry +Security:single module:_attachToTp +Security:single module:_sslDhGenKeyPairClient +Security:single module:_sslDhGenerateKeyPair +Security:single module:_sslDhKeyExchange +Security:single module:_sslGetMaxSigSize +Security:single module:_sslGetPubKeyBits +Security:single module:_sslGetPubKeyFromBits +Security:single module:_sslRawSign +Security:single module:_sslRawVerify +Security:single module:_sslRsaDecrypt +Security:single module:_stAppCalloc +Security:single module:_stMallocCssmData +Security:single module:__ZN12SessionCache10deletePrivEPK9SSLBuffer +Security:single module:__ZN12SessionCache10deletePrivESt15_Deque_iteratorIP17SessionCacheEntryRS2_PS2_E +Security:single module:__ZN12SessionCache10lookupPrivEPK9SSLBuffer +Security:single module:__ZN12SessionCache11deleteEntryE9SSLBuffer +Security:single module:__ZN12SessionCache11lookupEntryE9SSLBufferPS0_ +Security:single module:__ZN12SessionCache8addEntryE9SSLBufferS0_ +Security:single module:__ZN12SessionCacheD1Ev +Security:single module:__ZN12SessionCacheD2Ev +Security:single module:__ZN12SessionCacheD4Ev +Security:single module:__ZN17SessionCacheEntry11sessionDataERK9SSLBuffer +Security:single module:__ZN17SessionCacheEntry7isStaleERKN8Security4Time8AbsoluteE +Security:single module:__ZN17SessionCacheEntry7isStaleEv +Security:single module:__ZN17SessionCacheEntryC1ERK9SSLBufferS2_RKN8Security4Time8AbsoluteE +Security:single module:__ZN17SessionCacheEntryC2ERK9SSLBufferS2_RKN8Security4Time8AbsoluteE +Security:single module:__ZN17SessionCacheEntryC4ERK9SSLBufferS2_RKN8Security4Time8AbsoluteE +Security:single module:__ZN17SessionCacheEntryD1Ev +Security:single module:__ZN17SessionCacheEntryD2Ev +Security:single module:__ZN17SessionCacheEntryD4Ev +Security:single module:__ZNK17SessionCacheEntry8matchKeyERK9SSLBuffer +Security:single module:_sslAddSession +Security:single module:_sslDeleteSession +Security:single module:_sslGetSession +Security:single module:_SSLGetEnabledCiphers +Security:single module:_SSLGetNumberEnabledCiphers +Security:single module:_SSLGetNumberSupportedCiphers +Security:single module:_SSLGetSupportedCiphers +Security:single module:_SSLSetEnabledCiphers +Security:single module:__Z25cipherSpecsToCipherSuitesmPK13SSLCipherSpecPmS2_ +Security:single module:__Z12HashNullInitR9SSLBufferP10SSLContext +Security:single module:__Z13HashNullCloneRK9SSLBufferRS_ +Security:single module:__Z13HashNullCloseR9SSLBufferP10SSLContext +Security:single module:__Z13HashNullFinalR9SSLBufferS0_ +Security:single module:__Z14HashNullUpdateR9SSLBufferRKS_ +Security:single module:_SSLEncodeCertificate +Security:single module:_SSLEncodeCertificateRequest +Security:single module:_SSLEncodeCertificateVerify +Security:single module:_SSLProcessCertificateRequest +Security:single module:_SSLProcessCertificateVerify +Security:single module:_SSLEncodeServerHelloDone +Security:single module:_SSLEncodeClientHello +Security:single module:_SSLEncodeServerHello +Security:single module:_SSLProcessClientHello +Security:single module:__Z15SSLEncodeRandomPhP10SSLContext +Security:single module:_SSLEncodeServerKeyExchange +Security:single module:_SSLProcessKeyExchange +Security:single module:_SSLProcessServerKeyExchange +Security:single module:__Z20SSLDecodeDHKeyParamsP10SSLContextRPhm +Security:single module:__Z20SSLEncodeDHKeyParamsP10SSLContextPh +Security:single module:__Z21SSLEncodeRSAKeyParamsP9SSLBufferPP8cssm_keyP10SSLContext +Security:single module:__Z23SSLDecodeRSAKeyExchange9SSLBufferP10SSLContext +Security:single module:__Z26SSLGenServerDHParamsAndKeyP10SSLContext +Security:single module:__Z28SSLDecodeDHClientKeyExchange9SSLBufferP10SSLContext +Security:single module:__Z28SSLEncodeDHClientKeyExchangeR9SSLRecordP10SSLContext +Security:single module:__Z28SSLGenClientDHKeyAndExchangeP10SSLContext +Security:single module:__Z32SSLDecodeDHanonServerKeyExchange9SSLBufferP10SSLContext +Security:single module:__Z32SSLDecodeSignedServerKeyExchange9SSLBufferP10SSLContext +Security:single module:__Z32SSLEncodeDHanonServerKeyExchangeR9SSLRecordP10SSLContext +Security:single module:__Z32SSLEncodeSignedServerKeyExchangeR9SSLRecordP10SSLContext +Security:single module:__ZN14ServerDhParamsC1Ev +Security:single module:__ZN14ServerDhParamsC2Ev +Security:single module:__ZN14ServerDhParamsC4Ev +Security:single module:__ZN14ServerDhParamsD1Ev +Security:single module:__ZN14ServerDhParamsD2Ev +Security:single module:__ZN14ServerDhParamsD4Ev +Security:single module:__ZN14ModuleAttacher10getCspHandEv +Security:single module:__ZN14ModuleAttacher12unloadModuleEmPK9cssm_guid +Security:single module:__ZN14ModuleAttacher9getClHandEv +Security:single module:__ZN14ModuleAttacher9getTpHandEv +Security:single module:__ZN14ModuleAttacherD1Ev +Security:single module:__ZN14ModuleAttacherD2Ev +Security:single module:__ZN14ModuleAttacherD4Ev +Security:single module:__Z10NullFinishP13CipherContextP10SSLContext +Security:single module:__Z8NullInitPhS_P13CipherContextP10SSLContext +Security:single module:_SSL2EncodeClientFinished +Security:single module:_SSL2EncodeClientMasterKey +Security:single module:_SSL2EncodeServerFinished +Security:single module:_SSL2EncodeServerHello +Security:single module:_SSL2EncodeServerVerify +Security:single module:_SSL2ProcessClientFinished +Security:single module:_SSL2ProcessClientHello +Security:single module:_SSL2ProcessClientMasterKey +Security:single module:_SSL2ProcessServerFinished +Security:single module:_SSL2ProcessServerHello +Security:single module:_SSL2ProcessServerVerify +Security:single module:_SSL2CompareSessionIDs +Security:single module:_SSL2GenerateSessionID +Security:single module:_SSL2InitCiphers +Security:single module:_SSL2InstallSessionKey +Security:single module:_SSL2ProcessMessage +Security:single module:_SSL2ReadRecord +Security:single module:_SSL2SendError +Security:single module:__Z13SSL2VerifyMACR9SSLBufferPhP10SSLContext +Security:single module:__Z16SSL2CalculateMACR9SSLBufferS0_mRK13HashReferenceS0_P10SSLContext +Security:single module:__Z17SSL2DecryptRecordR9SSLBufferP10SSLContext +Security:single module:_SSLFatalSessionAlert +Security:single module:_SSLProcessAlert +Security:single module:__Z21SSLDetectCertRejectedP10SSLContext16AlertDescription +Security:single module:_SSLAllocCopyBuffer +Security:single module:_SSLCopyBuffer +Security:single module:_SSLCopyBufferFromData +Security:single module:_sslAllocCopy +Security:single module:_sslDecodeRsaBlob +Security:single module:_sslEncodeRsaBlob +Security:single module:_sslDecodeDhParams +Security:single module:_sslEncodeDhParams +Security:single module:_SSLAddDistinguishedName +Security:single module:_SSLGetAllowsAnyRoot +Security:single module:_SSLGetAllowsExpiredCerts +Security:single module:_SSLGetAllowsExpiredRoots +Security:single module:_SSLGetClientCertificateState +Security:single module:_SSLGetConnection +Security:single module:_SSLGetDiffieHellmanParams +Security:single module:_SSLGetEnableCertVerify +Security:single module:_SSLGetNegotiatedCipher +Security:single module:_SSLGetNegotiatedProtocolVersion +Security:single module:_SSLGetPeerCertificates +Security:single module:_SSLGetPeerDomainName +Security:single module:_SSLGetPeerDomainNameLength +Security:single module:_SSLGetPeerID +Security:single module:_SSLGetPeerSecTrust +Security:single module:_SSLGetProtocolVersion +Security:single module:_SSLGetProtocolVersionEnabled +Security:single module:_SSLGetResumableSessionInfo +Security:single module:_SSLGetRsaBlinding +Security:single module:_SSLGetTrustedRoots +Security:single module:_SSLInternalClientRandom +Security:single module:_SSLInternalMasterSecret +Security:single module:_SSLInternalServerRandom +Security:single module:_SSLSetCertificate +Security:single module:_SSLSetClientSideAuthenticate +Security:single module:_SSLSetDiffieHellmanParams +Security:single module:_SSLSetEncryptionCertificate +Security:single module:_SSLSetPeerID +Security:single module:_SSLSetProtocolVersionEnabled +Security:single module:_SSLSetRsaBlinding +Security:single module:_SSLSetTrustedRoots +Security:single module:__Z19convertProtToExtern18SSLProtocolVersion +Security:single module:_SSL3ReceiveSSL2ClientHello +Security:single module:__Z16secCertToSslCertP10SSLContextP23OpaqueSecCertificateRefPP14SSLCertificate +Security:single module:_parseIncomingCerts +Security:single module:_SSLAddSessionData +Security:single module:_SSLGetSessionData +Security:single module:_SSLDeleteSessionData +Security:single module:_SSLRetrieveSessionID +Security:single module:_SSLRetrieveSessionProtocolVersion +Security:single module:_SSLInstallSessionFromData +Security:single module:_sslTime +Security:single module:_AuthorizationFreeItemSet +Security:single module:_AuthorizationRightGet +Security:single module:_AuthorizationRightRemove +Security:single module:_AuthorizationRightSet +Security:single module:_AuthorizationExecuteWithPrivileges +Security:single module:__Z9argVectorPKcS0_S0_PKPc +Security:single module:_AuthorizationCopyPrivilegedReference +Security:single module:__Z16cssm_PassThroughmmmyPK15cssm_dl_db_listmPKvPPv +Security:single module:__Z16cssm_AuthComputemPK15cssm_tuplegroupS1_mPK9cssm_listS4_S4_PS_ +Security:single module:__ZN8Security15ACPluginSession9constructEv +Security:single module:__Z12cssm_CrlSignmyPK9cssm_dataPK10cssm_fieldmPS_ +Security:single module:__Z13cssm_CertSignmyPK9cssm_dataPK10cssm_fieldmPS_ +Security:single module:__Z13cssm_CrlCachemPK9cssm_dataPm +Security:single module:__Z14cssm_CrlVerifymyPK9cssm_dataS1_PK10cssm_fieldm +Security:single module:__Z15cssm_CrlAddCertmyPK9cssm_datamPK10cssm_fieldS1_PS_ +Security:single module:__Z15cssm_FreeFieldsmmPP10cssm_field +Security:single module:__Z16cssm_IsCertInCrlmPK9cssm_dataS1_Pl +Security:single module:__Z16cssm_PassThroughmymPKvPPv +Security:single module:__Z17cssm_CrlSetFieldsmmPK10cssm_fieldPK9cssm_dataPS2_ +Security:single module:__Z18cssm_CrlAbortCachemm +Security:single module:__Z18cssm_CrlAbortQuerymm +Security:single module:__Z18cssm_CrlRemoveCertmPK9cssm_dataS1_PS_ +Security:single module:__Z20cssm_CrlGetAllFieldsmPK9cssm_dataPmPP10cssm_field +Security:single module:__Z21cssm_CertGetAllFieldsmPK9cssm_dataPmPP10cssm_field +Security:single module:__Z21cssm_CrlVerifyWithKeymyPK9cssm_data +Security:single module:__Z22cssm_CertVerifyWithKeymyPK9cssm_data +Security:single module:__Z22cssm_CrlCreateTemplatemmPK10cssm_fieldP9cssm_data +Security:single module:__Z22cssm_CrlDescribeFormatmPmPP9cssm_data +Security:single module:__Z22cssm_IsCertInCachedCrlmPK9cssm_datamPlPS_ +Security:single module:__Z23cssm_CertCreateTemplatemmPK10cssm_fieldP9cssm_data +Security:single module:__Z23cssm_CertDescribeFormatmPmPP9cssm_data +Security:single module:__Z25cssm_CrlGetNextFieldValuemmPP9cssm_data +Security:single module:__Z26cssm_CertGetNextFieldValuemmPP9cssm_data +Security:single module:__Z26cssm_CrlGetFirstFieldValuemPK9cssm_dataS1_PmS2_PPS_ +Security:single module:__Z27cssm_CertGetFirstFieldValuemPK9cssm_dataS1_PmS2_PPS_ +Security:single module:__Z28cssm_CertGroupToSignedBundlemyPK14cssm_certgroupPK23cssm_cert_bundle_headerP9cssm_data +Security:single module:__Z29cssm_CertGetAllTemplateFieldsmPK9cssm_dataPmPP10cssm_field +Security:single module:__Z31cssm_CrlGetNextCachedFieldValuemmPP9cssm_data +Security:single module:__Z32cssm_CertGroupFromVerifiedBundlemyPK16cssm_cert_bundlePK9cssm_dataPP14cssm_certgroup +Security:single module:__Z32cssm_CrlGetAllCachedRecordFieldsmmPK9cssm_dataPmPP10cssm_field +Security:single module:__Z32cssm_CrlGetFirstCachedFieldValuemmPK9cssm_dataS1_PmS2_PPS_ +Security:single module:__Z10cssm_LoginmPK23cssm_access_credentialsPK9cssm_dataPKv +Security:single module:__Z11cssm_Logoutm +Security:single module:__Z12cssm_WrapKeymyPK12cssm_contextPK23cssm_access_credentialsPK8cssm_keyPK9cssm_dataPS5_y +Security:single module:__Z13cssm_SignDatamyPK12cssm_contextPK9cssm_datammPS2_ +Security:single module:__Z14cssm_GetKeyAclmPK8cssm_keyPA68_KcPmPP19cssm_acl_entry_info +Security:single module:__Z14cssm_QuerySizemyPK12cssm_contextlmP20cssm_query_size_data +Security:single module:__Z16cssm_GenerateKeymyPK12cssm_contextmmPK9cssm_dataPK29cssm_resource_control_contextP8cssm_keyy +Security:single module:__Z16cssm_GetKeyOwnermPK8cssm_keyP24cssm_acl_owner_prototype +Security:single module:__Z16cssm_GetLoginAclmPA68_KcPmPP19cssm_acl_entry_info +Security:single module:__Z16cssm_PassThroughmyPK12cssm_contextmPKvPPv +Security:single module:__Z17cssm_ChangeKeyAclmPK23cssm_access_credentialsPK13cssm_acl_editPK8cssm_key +Security:single module:__Z17cssm_GetTimeValuemmP9cssm_data +Security:single module:__Z17cssm_SignDataInitmyPK12cssm_context +Security:single module:__Z17cssm_VerifyDevicemPK9cssm_data +Security:single module:__Z18cssm_GetLoginOwnermP24cssm_acl_owner_prototype +Security:single module:__Z18cssm_SignDataFinalmyP9cssm_data +Security:single module:__Z18cssm_VerifyMacInitmyPK12cssm_context +Security:single module:__Z19cssm_ChangeKeyOwnermPK23cssm_access_credentialsPK8cssm_keyPK24cssm_acl_owner_prototype +Security:single module:__Z19cssm_ChangeLoginAclmPK23cssm_access_credentialsPK13cssm_acl_edit +Security:single module:__Z19cssm_GenerateRandommyPK12cssm_contextP9cssm_data +Security:single module:__Z19cssm_SignDataUpdatemyPK9cssm_datam +Security:single module:__Z19cssm_VerifyDataInitmyPK12cssm_context +Security:single module:__Z19cssm_VerifyMacFinalmyPK9cssm_data +Security:single module:__Z20cssm_GenerateKeyPairmyPK12cssm_contextmmPK9cssm_dataP8cssm_keymmS4_PK29cssm_resource_control_contextS6_y +Security:single module:__Z20cssm_RetrieveCountermP9cssm_data +Security:single module:__Z20cssm_VerifyDataFinalmyPK9cssm_data +Security:single module:__Z20cssm_VerifyMacUpdatemyPK9cssm_datam +Security:single module:__Z21cssm_ChangeLoginOwnermPK23cssm_access_credentialsPK24cssm_acl_owner_prototype +Security:single module:__Z21cssm_EncryptDataFinalmyP9cssm_data +Security:single module:__Z21cssm_RetrieveUniqueIdmP9cssm_data +Security:single module:__Z21cssm_VerifyDataUpdatemyPK9cssm_datam +Security:single module:__Z28cssm_GenerateAlgorithmParamsmyPK12cssm_contextmP9cssm_dataPmPP22cssm_context_attribute +Security:single module:__Z29cssm_GetOperationalStatisticsmP31cssm_csp_operational_statistics +Security:single module:__Z34cssm_ObtainPrivateKeyFromPublicKeymPK8cssm_keyPS_ +Security:single module:__Z13cssm_DbCreatemPKcPK16cssm_net_addressPK11cssm_dbinfomPK29cssm_resource_control_contextPKvPm +Security:single module:__Z13cssm_DbDeletemPKcPK16cssm_net_addressPK23cssm_access_credentials +Security:single module:__Z13cssm_GetDbAcl17cssm_dl_db_handlePA68_KcPmPP19cssm_acl_entry_info +Security:single module:__Z15cssm_DataDelete17cssm_dl_db_handlePK21cssm_db_unique_record +Security:single module:__Z15cssm_DataInsert17cssm_dl_db_handlemPK29cssm_db_record_attribute_dataPK9cssm_dataPP21cssm_db_unique_record +Security:single module:__Z15cssm_DataModify17cssm_dl_db_handlemP21cssm_db_unique_recordPK29cssm_db_record_attribute_dataPK9cssm_datam +Security:single module:__Z15cssm_GetDbNamesmPP14cssm_name_list +Security:single module:__Z15cssm_GetDbOwner17cssm_dl_db_handleP24cssm_acl_owner_prototype +Security:single module:__Z16cssm_ChangeDbAcl17cssm_dl_db_handlePK23cssm_access_credentialsPK13cssm_acl_edit +Security:single module:__Z16cssm_PassThrough17cssm_dl_db_handlemPKvPPv +Security:single module:__Z17cssm_Authenticate17cssm_dl_db_handlemPK23cssm_access_credentials +Security:single module:__Z17cssm_FreeNameListmP14cssm_name_list +Security:single module:__Z18cssm_ChangeDbOwner17cssm_dl_db_handlePK23cssm_access_credentialsPK24cssm_acl_owner_prototype +Security:single module:__Z19cssm_CreateRelation17cssm_dl_db_handlemPKcmPK29cssm_db_schema_attribute_infomPK25cssm_db_schema_index_info +Security:single module:__Z20cssm_DestroyRelation17cssm_dl_db_handlem +Security:single module:__Z24cssm_GetDbNameFromHandle17cssm_dl_db_handlePPc +Security:single module:__Z12cssm_CrlSignmmyPK16cssm_encoded_crlPK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_resultP9cssm_data +Security:single module:__Z13cssm_CertSignmmyPK9cssm_dataPK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_resultPS_ +Security:single module:__Z14cssm_CrlVerifymmmPK16cssm_encoded_crlPK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_result +Security:single module:__Z15cssm_CertRevokemmmPK9cssm_dataPK14cssm_certgroupS4_PK22cssm_tp_verify_contextP29cssm_tp_verify_context_resultmPS_ +Security:single module:__Z15cssm_FormSubmitmmPK9cssm_dataPK20cssm_tp_authority_idS4_P23cssm_access_credentials +Security:single module:__Z16cssm_FormRequestmPK20cssm_tp_authority_idmP9cssm_data +Security:single module:__Z16cssm_PassThroughmmyPK15cssm_dl_db_listmPKvPPv +Security:single module:__Z17cssm_ApplyCrlToDbmmmPK16cssm_encoded_crlPK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_result +Security:single module:__Z19cssm_CertGroupPrunemmPK15cssm_dl_db_listPK14cssm_certgroupPPS2_ +Security:single module:__Z19cssm_CertReclaimKeymPK14cssm_certgroupmymPK29cssm_resource_control_context +Security:single module:__Z21cssm_CertReclaimAbortmy +Security:single module:__Z22cssm_ConfirmCredResultmPK9cssm_dataPK26cssm_tp_callerauth_contextPK24cssm_tp_confirm_responsePK20cssm_tp_authority_id +Security:single module:__Z22cssm_CrlCreateTemplatemmmPK10cssm_fieldP9cssm_data +Security:single module:__Z22cssm_SubmitCredRequestmPK20cssm_tp_authority_idmPK19cssm_tp_request_setPK26cssm_tp_callerauth_contextPlP9cssm_data +Security:single module:__Z23cssm_CertCreateTemplatemmmPK10cssm_fieldP9cssm_data +Security:single module:__Z23cssm_CertGroupConstructmmmPK15cssm_dl_db_listPKvPK14cssm_certgroupPPS4_ +Security:single module:__Z23cssm_RetrieveCredResultmPK9cssm_dataPK26cssm_tp_callerauth_contextPlS5_PP18cssm_tp_result_set +Security:single module:__Z24cssm_ReceiveConfirmationmPK9cssm_dataPP24cssm_tp_confirm_responsePl +Security:single module:__Z26cssm_CertGroupToTupleGroupmmPK14cssm_certgroupPP15cssm_tuplegroup +Security:single module:__Z26cssm_TupleGroupToCertGroupmmPK15cssm_tuplegroupPP14cssm_certgroup +Security:single module:__Z29cssm_CertGetAllTemplateFieldsmmPK9cssm_dataPmPP10cssm_field +Security:single module:__Z30cssm_CertRemoveFromCrlTemplatemmmPK9cssm_dataPK14cssm_certgroupS4_PK22cssm_tp_verify_contextP29cssm_tp_verify_context_resultPS_ +Security:single module:__ZN8Security14SecurityServer13ClientSession11contactNameEPKc +Security:single module:__ZN8Security14SecurityServer13ClientSession6GlobalC2Ev +Security:single module:__ZN8Security14SecurityServer13ClientSession9terminateEv +Security:single module:__ZN8Security14SecurityServer13ClientSessionD0Ev +Security:single module:__ZN8Security14SecurityServer13ClientSessionD2Ev +Security:single module:__ZNK8Security14SecurityServer13ClientSession11contactNameEv +Security:single module:__ZN8Security10DataOutputD2Ev +Security:single module:__ZN8Security11SendContextC2ERKNS_7ContextE +Security:single module:__ZN8Security14SecurityServer13ClientSession10getDbOwnerEmRNS_17AclOwnerPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession11changeDbAclEmRKNS_17AccessCredentialsERKNS_7AclEditE +Security:single module:__ZN8Security14SecurityServer13ClientSession11changeOwnerENS0_7AclKindEmRKNS_17AccessCredentialsERKNS_17AclOwnerPrototypeE +Security:single module:__ZN8Security14SecurityServer13ClientSession11generateKeyEmRKNS_7ContextEmmPKNS_17AccessCredentialsEPKNS_13AclEntryInputERmRNS_7CssmKey6HeaderE +Security:single module:__ZN8Security14SecurityServer13ClientSession11generateKeyEmRKNS_7ContextEmmmmPKNS_17AccessCredentialsEPKNS_13AclEntryInputERmRNS_7CssmKey6HeaderESB_SE_ +Security:single module:__ZN8Security14SecurityServer13ClientSession11generateMacERKNS_7ContextEmRKNS_8CssmDataERS5_RNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession11getKeyOwnerEmRNS_17AclOwnerPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession12changeKeyAclEmRKNS_17AccessCredentialsERKNS_7AclEditE +Security:single module:__ZN8Security14SecurityServer13ClientSession12getKeyDigestEmRNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession13changeDbOwnerEmRKNS_17AccessCredentialsERKNS_17AclOwnerPrototypeE +Security:single module:__ZN8Security14SecurityServer13ClientSession13getOutputSizeERKNS_7ContextEmmb +Security:single module:__ZN8Security14SecurityServer13ClientSession14authenticateDbEmmPKNS_17AccessCredentialsE +Security:single module:__ZN8Security14SecurityServer13ClientSession14changeKeyOwnerEmRKNS_17AccessCredentialsERKNS_17AclOwnerPrototypeE +Security:single module:__ZN8Security14SecurityServer13ClientSession14generateRandomERNS_8CssmDataE +Security:single module:__ZN8Security14SecurityServer13ClientSession15getDbParametersEmRNS0_12DBParametersE +Security:single module:__ZN8Security14SecurityServer13ClientSession15setDbParametersEmRKNS0_12DBParametersE +Security:single module:__ZN8Security14SecurityServer13ClientSession15verifySignatureERKNS_7ContextEmRKNS_8CssmDataES7_m +Security:single module:__ZN8Security14SecurityServer13ClientSession16changePassphraseEmPKNS_17AccessCredentialsE +Security:single module:__ZN8Security14SecurityServer13ClientSession16extractMasterKeyEmRKNS_7ContextEmmmPKNS_17AccessCredentialsEPKNS_13AclEntryInputERmRNS_7CssmKey6HeaderERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession16stopNotificationENS_12MachPlusPlus4PortE +Security:single module:__ZN8Security14SecurityServer13ClientSession17generateSignatureERKNS_7ContextEmRKNS_8CssmDataERS5_RNS_13CssmAllocatorEm +Security:single module:__ZN8Security14SecurityServer13ClientSession18authorizationdbGetEPKcRNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession18authorizationdbSetERKNS0_17AuthorizationBlobEPKcjPKv +Security:single module:__ZN8Security14SecurityServer13ClientSession18queryKeySizeInBitsEm +Security:single module:__ZN8Security14SecurityServer13ClientSession19getDbSuggestedIndexEmRNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession19requestNotificationENS_12MachPlusPlus4PortEmm +Security:single module:__ZN8Security14SecurityServer13ClientSession20dispatchNotificationEPK17mach_msg_header_tPFlmmPKvmPvES7_ +Security:single module:__ZN8Security14SecurityServer13ClientSession21authorizationdbRemoveERKNS0_17AuthorizationBlobEPKc +Security:single module:__ZN8Security14SecurityServer13ClientSession21removeCodeEquivalenceERKNS_8CssmDataEPKcb +Security:single module:__ZN8Security14SecurityServer13ClientSession22setAlternateSystemRootEPKc +Security:single module:__ZN8Security14SecurityServer13ClientSession4lockEm +Security:single module:__ZN8Security14SecurityServer13ClientSession6getAclENS0_7AclKindEmPKcRmRPNS_12AclEntryInfoERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession6unlockEm +Security:single module:__ZN8Security14SecurityServer13ClientSession6unlockEmRKNS_8CssmDataE +Security:single module:__ZN8Security14SecurityServer13ClientSession7encryptERKNS_7ContextEmRKNS_8CssmDataERS5_RNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession7lockAllEb +Security:single module:__ZN8Security14SecurityServer13ClientSession7wrapKeyERKNS_7ContextEmmPKNS_17AccessCredentialsEPKNS_8CssmDataERNS_7CssmKeyERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession8createDbERKNS_14DLDbIdentifierEPKNS_17AccessCredentialsEPKNS_13AclEntryInputERKNS0_12DBParametersE +Security:single module:__ZN8Security14SecurityServer13ClientSession8encodeDbEmRNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession8getDbAclEmPKcRmRPNS_12AclEntryInfoERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession8getOwnerENS0_7AclKindEmRNS_17AclOwnerPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession8isLockedEm +Security:single module:__ZN8Security14SecurityServer13ClientSession9changeAclENS0_7AclKindEmRKNS_17AccessCredentialsERKNS_7AclEditE +Security:single module:__ZN8Security14SecurityServer13ClientSession9deriveKeyEmRKNS_7ContextEmmmRNS_8CssmDataEPKNS_17AccessCredentialsEPKNS_13AclEntryInputERmRNS_7CssmKey6HeaderERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession9encodeKeyEmRNS_8CssmDataEPNS0_6KeyUIDERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession9getKeyAclEmPKcRmRPNS_12AclEntryInfoERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession9unwrapKeyEmRKNS_7ContextEmmRKNS_7CssmKeyEmmPKNS_17AccessCredentialsEPKNS_13AclEntryInputERNS_8CssmDataERmRNS5_6HeaderERNS_13CssmAllocatorE +Security:single module:__ZN8Security14SecurityServer13ClientSession9verifyMacERKNS_7ContextEmRKNS_8CssmDataES7_ +Security:single module:__ZN8Security25DatabaseAccessCredentials12mapKeySampleERmRNS_7CssmKeyE +Security:single module:__ZN8Security25DatabaseAccessCredentialsC2EPKNS_17AccessCredentialsERNS_13CssmAllocatorE +Security:single module:__ZN8Security9chunkCopyERNS_8CssmListERNS_13CssmAllocatorE +Security:single module:__ZN8Security13NameValuePairC1ERKNS_8CssmDataE +Security:single module:__ZN8Security13NameValuePairC2ERKNS_8CssmDataE +Security:single module:__ZN8Security13NameValuePairC2EmRKNS_8CssmDataE +Security:single module:__ZN8Security13NameValuePairC4ERKNS_8CssmDataE +Security:single module:__ZN8Security13NameValuePairD2Ev +Security:single module:__ZN8Security19NameValueDictionary12RemoveByNameEm +Security:single module:__ZN8Security19NameValueDictionary41MakeDLDbIdentifierFromNameValueDictionaryERKS0_ +Security:single module:__ZN8Security19NameValueDictionaryC1ERKNS_8CssmDataE +Security:single module:__ZN8Security19NameValueDictionaryC2ERKNS_8CssmDataE +Security:single module:__ZN8Security19NameValueDictionaryC2Ev +Security:single module:__ZN8Security19NameValueDictionaryC4ERKNS_8CssmDataE +Security:single module:__ZN8Security19NameValueDictionaryD2Ev +Security:single module:__ZNK8Security19NameValueDictionary10FindByNameEm +Security:single module:__ZNK8Security19NameValueDictionary18FindPositionByNameEm +Security:single module:__ZN8Security14SecurityServer13EventListenerC2ERNS_13CssmAllocatorES3_ +Security:single module:__ZN8Security14SecurityServer13EventListenerC1ERNS_13CssmAllocatorES3_ +Security:single module:__ZN8Security14SecurityServer13EventListenerC4ERNS_13CssmAllocatorES3_ +Security:single module:__ZN8Security14SecurityServer13EventListenerD2Ev +Security:single module:__ZN8Security14SecurityServer13EventListenerD1Ev +Security:single module:__ZN8Security14SecurityServer13EventListenerD0Ev +Security:single module:__ZN8Security14SecurityServer13EventListenerD4Ev +Security:single module:__ZN8Security14SecurityServer13EventListener8CallbackEP12__CFMachPortPvlS4_ +Security:single module:__ZN8Security14SecurityServer13EventListener10InitializeEv +Security:single module:__ZN8Security14SecurityServer13EventListener14HandleCallbackEP12__CFMachPortPvl +Security:single module:__ZN8Security14SecurityServer13EventListener14ProcessMessageEmmPKvmPv +Security:single module:__ZN8Security14SecurityServer13EventListener13RequestEventsEmm +Security:single module:__ZN8Security14SecurityServer13EventListener13EventReceivedEmmPKvm +Security:single module:__Z28__MIG_check__Reply__getAcl_tP17__Reply__getAcl_t +Security:single module:__Z28__MIG_check__Reply__lockDb_tP17__Reply__lockDb_t +Security:single module:__Z29__MIG_check__Reply__encrypt_tP18__Reply__encrypt_t +Security:single module:__Z29__MIG_check__Reply__lockAll_tP18__Reply__lockAll_t +Security:single module:__Z29__MIG_check__Reply__wrapKey_tP18__Reply__wrapKey_t +Security:single module:__Z30__MIG_check__Reply__createDb_tP19__Reply__createDb_t +Security:single module:__Z30__MIG_check__Reply__encodeDb_tP19__Reply__encodeDb_t +Security:single module:__Z30__MIG_check__Reply__getOwner_tP19__Reply__getOwner_t +Security:single module:__Z30__MIG_check__Reply__isLocked_tP19__Reply__isLocked_t +Security:single module:__Z30__MIG_check__Reply__setOwner_tP19__Reply__setOwner_t +Security:single module:__Z30__MIG_check__Reply__teardown_tP19__Reply__teardown_t +Security:single module:__Z30__MIG_check__Reply__unlockDb_tP19__Reply__unlockDb_t +Security:single module:__Z31__MIG_check__Reply__changeAcl_tP20__Reply__changeAcl_t +Security:single module:__Z31__MIG_check__Reply__deriveKey_tP20__Reply__deriveKey_t +Security:single module:__Z31__MIG_check__Reply__encodeKey_tP20__Reply__encodeKey_t +Security:single module:__Z31__MIG_check__Reply__unwrapKey_tP20__Reply__unwrapKey_t +Security:single module:__Z31__MIG_check__Reply__verifyMac_tP20__Reply__verifyMac_t +Security:single module:__Z32__MIG_check__Reply__getDbIndex_tP21__Reply__getDbIndex_t +Security:single module:__Z33__MIG_check__Reply__generateKey_tP22__Reply__generateKey_t +Security:single module:__Z33__MIG_check__Reply__generateMac_tP22__Reply__generateMac_t +Security:single module:__Z34__MIG_check__Reply__getKeyDigest_tP23__Reply__getKeyDigest_t +Security:single module:__Z35__MIG_check__Reply__getOutputSize_tP24__Reply__getOutputSize_t +Security:single module:__Z36__MIG_check__Reply__authenticateDb_tP25__Reply__authenticateDb_t +Security:single module:__Z36__MIG_check__Reply__generateRandom_tP25__Reply__generateRandom_t +Security:single module:__Z37__MIG_check__Reply__generateKeyPair_tP26__Reply__generateKeyPair_t +Security:single module:__Z37__MIG_check__Reply__getDbParameters_tP26__Reply__getDbParameters_t +Security:single module:__Z37__MIG_check__Reply__setDbParameters_tP26__Reply__setDbParameters_t +Security:single module:__Z37__MIG_check__Reply__verifySignature_tP26__Reply__verifySignature_t +Security:single module:__Z38__MIG_check__Reply__changePassphrase_tP27__Reply__changePassphrase_t +Security:single module:__Z38__MIG_check__Reply__extractMasterKey_tP27__Reply__extractMasterKey_t +Security:single module:__Z38__MIG_check__Reply__stopNotification_tP27__Reply__stopNotification_t +Security:single module:__Z39__MIG_check__Reply__generateSignature_tP28__Reply__generateSignature_t +Security:single module:__Z40__MIG_check__Reply__authorizationdbGet_tP29__Reply__authorizationdbGet_t +Security:single module:__Z40__MIG_check__Reply__authorizationdbSet_tP29__Reply__authorizationdbSet_t +Security:single module:__Z40__MIG_check__Reply__queryKeySizeInBits_tP29__Reply__queryKeySizeInBits_t +Security:single module:__Z41__MIG_check__Reply__requestNotification_tP30__Reply__requestNotification_t +Security:single module:__Z43__MIG_check__Reply__authorizationdbRemove_tP32__Reply__authorizationdbRemove_t +Security:single module:__Z43__MIG_check__Reply__removeCodeEquivalence_tP32__Reply__removeCodeEquivalence_t +Security:single module:__Z44__MIG_check__Reply__setAlternateSystemRoot_tP33__Reply__setAlternateSystemRoot_t +Security:single module:__Z44__MIG_check__Reply__unlockDbWithPassphrase_tP33__Reply__unlockDbWithPassphrase_t +Security:single module:_ucsp_client_authenticateDb +Security:single module:_ucsp_client_authorizationdbGet +Security:single module:_ucsp_client_authorizationdbRemove +Security:single module:_ucsp_client_authorizationdbSet +Security:single module:_ucsp_client_changeAcl +Security:single module:_ucsp_client_changePassphrase +Security:single module:_ucsp_client_createDb +Security:single module:_ucsp_client_deriveKey +Security:single module:_ucsp_client_encodeDb +Security:single module:_ucsp_client_encodeKey +Security:single module:_ucsp_client_encrypt +Security:single module:_ucsp_client_extractMasterKey +Security:single module:_ucsp_client_generateKey +Security:single module:_ucsp_client_generateKeyPair +Security:single module:_ucsp_client_generateMac +Security:single module:_ucsp_client_generateRandom +Security:single module:_ucsp_client_generateSignature +Security:single module:_ucsp_client_getAcl +Security:single module:_ucsp_client_getDbIndex +Security:single module:_ucsp_client_getDbParameters +Security:single module:_ucsp_client_getKeyDigest +Security:single module:_ucsp_client_getOutputSize +Security:single module:_ucsp_client_getOwner +Security:single module:_ucsp_client_isLocked +Security:single module:_ucsp_client_lockAll +Security:single module:_ucsp_client_lockDb +Security:single module:_ucsp_client_queryKeySizeInBits +Security:single module:_ucsp_client_removeCodeEquivalence +Security:single module:_ucsp_client_requestNotification +Security:single module:_ucsp_client_setAlternateSystemRoot +Security:single module:_ucsp_client_setDbParameters +Security:single module:_ucsp_client_setOwner +Security:single module:_ucsp_client_stopNotification +Security:single module:_ucsp_client_teardown +Security:single module:_ucsp_client_unlockDb +Security:single module:_ucsp_client_unlockDbWithPassphrase +Security:single module:_ucsp_client_unwrapKey +Security:single module:_ucsp_client_verifyMac +Security:single module:_ucsp_client_verifySignature +Security:single module:_ucsp_client_wrapKey +Security:single module:__ZN8Security12KeychainCore12CallbackInfoC2Ev +Security:single module:__ZN8Security12KeychainCore12CallbackInfoC1Ev +Security:single module:__ZN8Security12KeychainCore12CallbackInfoC4Ev +Security:single module:__ZN8Security12KeychainCore12CallbackInfoC2EPFlmP23SecKeychainCallbackInfoPvEmS4_ +Security:single module:__ZN8Security12KeychainCore12CallbackInfoC1EPFlmP23SecKeychainCallbackInfoPvEmS4_ +Security:single module:__ZN8Security12KeychainCore12CallbackInfoC4EPFlmP23SecKeychainCallbackInfoPvEmS4_ +Security:single module:__ZN8Security12KeychainCore12CallbackInfoD2Ev +Security:single module:__ZN8Security12KeychainCore12CallbackInfoD1Ev +Security:single module:__ZN8Security12KeychainCore12CallbackInfoD4Ev +Security:single module:__ZNK8Security12KeychainCore12CallbackInfoeqERKS1_ +Security:single module:__ZNK8Security12KeychainCore12CallbackInfoneERKS1_ +Security:single module:__ZN8Security12KeychainCore12CCallbackMgrC2Ev +Security:single module:__ZN8Security12KeychainCore12CCallbackMgrC1Ev +Security:single module:__ZN8Security12KeychainCore12CCallbackMgrC4Ev +Security:single module:__ZN8Security12KeychainCore12CCallbackMgrD2Ev +Security:single module:__ZN8Security12KeychainCore12CCallbackMgrD1Ev +Security:single module:__ZN8Security12KeychainCore12CCallbackMgrD0Ev +Security:single module:__ZN8Security12KeychainCore12CCallbackMgrD4Ev +Security:single module:__ZN8Security12KeychainCore12CCallbackMgr8InstanceEv +Security:single module:__ZN8Security12KeychainCore12CCallbackMgr11AddCallbackEPFlmP23SecKeychainCallbackInfoPvEmS4_ +Security:single module:__ZN8Security12KeychainCore12CCallbackMgr14RemoveCallbackEPFlmP23SecKeychainCallbackInfoPvE +Security:single module:__ZN8Security12KeychainCore12CCallbackMgr12AlertClientsEmiRKNS0_8KeychainERKNS0_4ItemE +Security:single module:__ZN8Security12KeychainCore12CCallbackMgr5EventEmmRNS_19NameValueDictionaryE +Security:single module:__ZN8Security17CSSMDateTimeUtils25GetCurrentMacLongDateTimeERx +Security:single module:__ZN8Security17CSSMDateTimeUtils22TimeStringToMacSecondsERK9cssm_dataRm +Security:single module:__ZN8Security17CSSMDateTimeUtils27TimeStringToMacLongDateTimeERK9cssm_dataRx +Security:single module:__ZN8Security17CSSMDateTimeUtils22MacSecondsToTimeStringEmmPv +Security:single module:__ZN8Security17CSSMDateTimeUtils27MacLongDateTimeToTimeStringERKxmPv +Security:single module:__ZN8Security14DLDbListCFPref10searchListERKSt6vectorINS_14DLDbIdentifierESaIS2_EE +Security:single module:__ZN8Security14DLDbListCFPref11clearPWInfoEv +Security:single module:__ZN8Security14DLDbListCFPref14StripPathStuffERKSs +Security:single module:__ZN8Security14DLDbListCFPref15AbbreviatedPathERKSs +Security:single module:__ZN8Security14DLDbListCFPref17resetCachedValuesEv +Security:single module:__ZN8Security14DLDbListCFPref17writePropertyListEv +Security:single module:__ZN8Security14DLDbListCFPref19LoginDLDbIdentifierEv +Security:single module:__ZN8Security14DLDbListCFPref19loginDLDbIdentifierERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security14DLDbListCFPref21defaultDLDbIdentifierERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security14DLDbListCFPref31dlDbIdentifierToCFDictionaryRefERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security14DLDbListCFPref3addERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security14DLDbListCFPref3setE20SecPreferencesDomain +Security:single module:__ZN8Security14DLDbListCFPref4saveEv +Security:single module:__ZN8Security14DLDbListCFPref6removeERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security14DLDbListCFPrefC2E20SecPreferencesDomain +Security:single module:__ZN8Security14DLDbListCFPrefD1Ev +Security:single module:__ZN8Security14DLDbListCFPrefD2Ev +Security:single module:__ZN8Security14DLDbListCFPrefD4Ev +Security:single module:__ZN8Security16PasswordDBLookupC2Ev +Security:single module:__ZN8Security12KeychainCore7GlobalsC2Ev +Security:single module:__ZN8Security12KeychainCore4ItemC1ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore4ItemC1ERNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore4ItemC1EmP24SecKeychainAttributeListmPKv +Security:single module:__ZN8Security12KeychainCore4ItemC1EmmmPKv +Security:single module:__ZN8Security12KeychainCore4ItemC2EPNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore4ItemC2ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore4ItemC2ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore4ItemC2ERNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore4ItemC2EmP24SecKeychainAttributeListmPKv +Security:single module:__ZN8Security12KeychainCore4ItemC2EmmmPKv +Security:single module:__ZN8Security12KeychainCore4ItemC2Ev +Security:single module:__ZN8Security12KeychainCore4ItemC4ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore4ItemC4ERNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore4ItemC4EmP24SecKeychainAttributeListmPKv +Security:single module:__ZN8Security12KeychainCore4ItemC4EmmmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImpl12getAttributeER20SecKeychainAttributePm +Security:single module:__ZN8Security12KeychainCore8ItemImpl12setAttributeER20SecKeychainAttribute +Security:single module:__ZN8Security12KeychainCore8ItemImpl12setAttributeERKNS_19CssmDbAttributeInfoERKNS_12CssmPolyDataE +Security:single module:__ZN8Security12KeychainCore8ItemImpl13modifyContentEPK24SecKeychainAttributeListmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImpl15getLocalContentER24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore8ItemImpl16getAttributeFromEPNS_19CssmDbAttributeDataER20SecKeychainAttributePm +Security:single module:__ZN8Security12KeychainCore8ItemImpl20getAttributesAndDataEP24SecKeychainAttributeInfoPmPP24SecKeychainAttributeListS4_PPv +Security:single module:__ZN8Security12KeychainCore8ItemImpl21defaultAttributeValueERK22cssm_db_attribute_info +Security:single module:__ZN8Security12KeychainCore8ItemImpl21freeAttributesAndDataEP24SecKeychainAttributeListPv +Security:single module:__ZN8Security12KeychainCore8ItemImpl23modifyAttributesAndDataEPK24SecKeychainAttributeListmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImpl3addERNS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore8ItemImpl5groupEv +Security:single module:__ZN8Security12KeychainCore8ItemImpl6copyToERKNS0_8KeychainEPNS0_6AccessE +Security:single module:__ZN8Security12KeychainCore8ItemImpl6updateEv +Security:single module:__ZN8Security12KeychainCore8ItemImpl7getDataERNS_17CssmDataContainerE +Security:single module:__ZN8Security12KeychainCore8ItemImpl7setDataEmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImpl8getClassER20SecKeychainAttributePm +Security:single module:__ZN8Security12KeychainCore8ItemImpl9didModifyEv +Security:single module:__ZN8Security12KeychainCore8ItemImpl9setAccessEPNS0_6AccessE +Security:single module:__ZN8Security12KeychainCore8ItemImplC1ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore8ItemImplC1ERS1_ +Security:single module:__ZN8Security12KeychainCore8ItemImplC1EmP24SecKeychainAttributeListmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImplC1EmmmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImplC2ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore8ItemImplC2ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore8ItemImplC2ERS1_ +Security:single module:__ZN8Security12KeychainCore8ItemImplC2EmmmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImplC4ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore8ItemImplC4ERS1_ +Security:single module:__ZN8Security12KeychainCore8ItemImplC4EmmmPKv +Security:single module:__ZN8Security12KeychainCore8ItemImplD0Ev +Security:single module:__ZNK8Security12KeychainCore8ItemImpl10isModifiedEv +Security:single module:__ZNK8Security12KeychainCore8ItemImpl12modifiedDataEv +Security:single module:__ZNK8Security12KeychainCore8ItemImpl18modifiedAttributesEv +Security:single module:__ZNK8Security12KeychainCore8ItemImpl8keychainEv +Security:single module:__ZNK8Security12KeychainCore8ItemImplltERKS1_ +Security:single module:__ZN8Security12KeychainCore12KCCursorImplC1ERKSt6vectorINS0_8KeychainESaIS3_EEPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore12KCCursorImplC2ERKSt6vectorINS0_8KeychainESaIS3_EEPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore12KCCursorImplC2ERKSt6vectorINS0_8KeychainESaIS3_EEmPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore12KCCursorImplC4ERKSt6vectorINS0_8KeychainESaIS3_EEPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore12KCCursorImplD0Ev +Security:single module:__ZN8Security12KeychainCore12KCCursorImplD2Ev +Security:single module:__ZN8Security8Observer13EventReceivedEmmPKvm +Security:single module:__ZN8Security8ObserverC2Emm +Security:single module:__ZN8Security8ObserverC1Emm +Security:single module:__ZN8Security8ObserverC4Emm +Security:single module:__ZN8Security8ObserverD2Ev +Security:single module:__ZN8Security8ObserverD1Ev +Security:single module:__ZN8Security8ObserverD0Ev +Security:single module:__ZN8Security8ObserverD4Ev +Security:single module:__ZN8Security25GetKeychainErrFromCSSMErrEl +Security:single module:__ZN8Security13StKCAttributeC2EP20SecKeychainAttribute +Security:single module:__ZN8Security13StKCAttributeC1EP20SecKeychainAttribute +Security:single module:__ZN8Security13StKCAttributeC4EP20SecKeychainAttribute +Security:single module:__ZN8Security13StKCAttributeD2Ev +Security:single module:__ZN8Security13StKCAttributeD1Ev +Security:single module:__ZN8Security13StKCAttributeD0Ev +Security:single module:__ZN8Security13StKCAttributeD4Ev +Security:single module:__ZN8Security8StKCItemC2EPP24OpaqueSecKeychainItemRefPl +Security:single module:__ZN8Security8StKCItemC1EPP24OpaqueSecKeychainItemRefPl +Security:single module:__ZN8Security8StKCItemC4EPP24OpaqueSecKeychainItemRefPl +Security:single module:__ZN8Security8StKCItemD2Ev +Security:single module:__ZN8Security8StKCItemD1Ev +Security:single module:__ZN8Security8StKCItemD0Ev +Security:single module:__ZN8Security8StKCItemD4Ev +Security:single module:__ZN8Security12KeychainCore12KeychainImpl10deleteItemERNS0_4ItemE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl11getSettingsERmRb +Security:single module:__ZN8Security12KeychainCore12KeychainImpl11setSettingsEmb +Security:single module:__ZN8Security12KeychainCore12KeychainImpl12authenticateEPK23cssm_access_credentials +Security:single module:__ZN8Security12KeychainCore12KeychainImpl12createCursorEPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore12KeychainImpl12createCursorEmPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore12KeychainImpl13didDeleteItemEPKNS0_8ItemImplE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl16attributeInfoForEmm +Security:single module:__ZN8Security12KeychainCore12KeychainImpl16changePassphraseEPKhS3_ +Security:single module:__ZN8Security12KeychainCore12KeychainImpl16changePassphraseEmPKvmS3_ +Security:single module:__ZN8Security12KeychainCore12KeychainImpl17freeAttributeInfoEP24SecKeychainAttributeInfo +Security:single module:__ZN8Security12KeychainCore12KeychainImpl25getAttributeInfoForItemIDEmPP24SecKeychainAttributeInfo +Security:single module:__ZN8Security12KeychainCore12KeychainImpl3addERNS0_4ItemE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl3cspEv +Security:single module:__ZN8Security12KeychainCore12KeychainImpl4itemERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl4lockEv +Security:single module:__ZN8Security12KeychainCore12KeychainImpl4openEv +Security:single module:__ZN8Security12KeychainCore12KeychainImpl6createEPKNS_22ResourceControlContextE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl6createEPKh +Security:single module:__ZN8Security12KeychainCore12KeychainImpl6createEmPKv +Security:single module:__ZN8Security12KeychainCore12KeychainImpl6createEv +Security:single module:__ZN8Security12KeychainCore12KeychainImpl6existsEv +Security:single module:__ZN8Security12KeychainCore12KeychainImpl6unlockEPKh +Security:single module:__ZN8Security12KeychainCore12KeychainImpl6unlockERKNS_8CssmDataE +Security:single module:__ZN8Security12KeychainCore12KeychainImpl6unlockEv +Security:single module:__ZN8Security12KeychainCore12KeychainImpl9didUpdateEPNS0_8ItemImplERNS0_10PrimaryKeyES5_ +Security:single module:__ZN8Security12KeychainCore12KeychainImplC2ERKNS_10CssmClient2DbE +Security:single module:__ZN8Security12KeychainCore12KeychainImplD0Ev +Security:single module:__ZN8Security12KeychainCore12KeychainImplD2Ev +Security:single module:__ZN8Security12KeychainCore18KeychainSchemaImplC2ERKNS_10CssmClient2DbE +Security:single module:__ZN8Security12KeychainCore18KeychainSchemaImplD2Ev +Security:single module:__ZN8Security12KeychainCore8Keychain8optionalEP20OpaqueSecKeychainRef +Security:single module:__ZNK8Security12KeychainCore12KeychainImpl6statusEv +Security:single module:__ZNK8Security12KeychainCore12KeychainImpl8isActiveEv +Security:single module:__ZNK8Security12KeychainCore12KeychainImpleqERKS1_ +Security:single module:__ZNK8Security12KeychainCore18KeychainSchemaImpl12hasAttributeEmm +Security:single module:__ZNK8Security12KeychainCore18KeychainSchemaImpl16attributeInfoForEmm +Security:single module:__ZNK8Security12KeychainCore18KeychainSchemaImpl18attributeFormatForEmm +Security:single module:__ZNK8Security12KeychainCore18KeychainSchemaImpl18relationInfoMapForEm +Security:single module:__ZNK8Security12KeychainCore18KeychainSchemaImpl29getAttributeInfoForRecordTypeEmPP24SecKeychainAttributeInfo +Security:single module:__ZNK8Security12KeychainCore18KeychainSchemaImpleqERKS1_ +Security:single module:__ZNK8Security12KeychainCore18KeychainSchemaImplltERKS1_ +Security:single module:__ZN8Security12KeychainCore14PrimaryKeyImpl12createCursorERKNS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore14PrimaryKeyImplC2ERK9cssm_data +Security:single module:__ZN8Security12KeychainCore14PrimaryKeyImplC2ERKNS_10CssmClient12DbAttributesE +Security:single module:_SecKeychainCopySearchNextItem +Security:single module:_SecKeychainRelease +Security:single module:_SecKeychainSearchRelease +Security:single module:__ZN8Security12KeychainCore14StorageManager11convertListERSt6vectorINS0_8KeychainESaIS3_EERKS2_INS_14DLDbIdentifierESaIS7_EE +Security:single module:__ZN8Security12KeychainCore14StorageManager11convertListERSt6vectorINS_14DLDbIdentifierESaIS3_EERKS2_INS0_8KeychainESaIS7_EE +Security:single module:__ZN8Security12KeychainCore14StorageManager12createCursorEPK24SecKeychainAttributeList +Security:single module:__ZN8Security12KeychainCore14StorageManager12makeKeychainERKNS_14DLDbIdentifierEb +Security:single module:__ZN8Security12KeychainCore14StorageManager12renameUniqueENS0_8KeychainEPK10__CFString +Security:single module:__ZN8Security12KeychainCore14StorageManager13getSearchListE20SecPreferencesDomainRSt6vectorINS0_8KeychainESaIS4_EE +Security:single module:__ZN8Security12KeychainCore14StorageManager13loginKeychainENS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore14StorageManager13loginKeychainEv +Security:single module:__ZN8Security12KeychainCore14StorageManager13resetKeychainEh +Security:single module:__ZN8Security12KeychainCore14StorageManager13setSearchListE20SecPreferencesDomainRKSt6vectorINS0_8KeychainESaIS4_EE +Security:single module:__ZN8Security12KeychainCore14StorageManager13setSearchListERKSt6vectorINS0_8KeychainESaIS3_EE +Security:single module:__ZN8Security12KeychainCore14StorageManager15defaultKeychainE20SecPreferencesDomain +Security:single module:__ZN8Security12KeychainCore14StorageManager15defaultKeychainE20SecPreferencesDomainRKNS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore14StorageManager15defaultKeychainERKNS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore14StorageManager15defaultKeychainEv +Security:single module:__ZN8Security12KeychainCore14StorageManager15makeLoginAuthUIERNS0_4ItemE +Security:single module:__ZN8Security12KeychainCore14StorageManager17defaultKeychainUIERNS0_4ItemE +Security:single module:__ZN8Security12KeychainCore14StorageManager19changeLoginPasswordEPKhS3_ +Security:single module:__ZN8Security12KeychainCore14StorageManager19changeLoginPasswordEmPKvmS3_ +Security:single module:__ZN8Security12KeychainCore14StorageManager21setDefaultCredentialsERKNS_10CssmClient2DbE +Security:single module:__ZN8Security12KeychainCore14StorageManager2atEj +Security:single module:__ZN8Security12KeychainCore14StorageManager4makeEPKc +Security:single module:__ZN8Security12KeychainCore14StorageManager4makeEPKcb +Security:single module:__ZN8Security12KeychainCore14StorageManager4sizeEv +Security:single module:__ZN8Security12KeychainCore14StorageManager5loginEPK22AuthorizationOpaqueRefmPKc +Security:single module:__ZN8Security12KeychainCore14StorageManager5loginEPKhS3_ +Security:single module:__ZN8Security12KeychainCore14StorageManager5loginEmPKvmS3_ +Security:single module:__ZN8Security12KeychainCore14StorageManager6domainE20SecPreferencesDomain +Security:single module:__ZN8Security12KeychainCore14StorageManager6logoutEv +Security:single module:__ZN8Security12KeychainCore14StorageManager6removeERKSt6vectorINS0_8KeychainESaIS3_EEb +Security:single module:__ZN8Security12KeychainCore14StorageManager6renameENS0_8KeychainEPKc +Security:single module:__ZN8Security12KeychainCore14StorageManager7createdERKNS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore14StorageManager7lockAllEv +Security:single module:__ZN8Security12KeychainCore14StorageManager8keychainERKNS_14DLDbIdentifierE +Security:single module:__ZN8Security12KeychainCore14StorageManagerC2Ev +Security:single module:__ZN8Security12KeychainCore14StorageManagerixEj +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCoreC2Ev +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCoreC1Ev +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCoreC4Ev +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCoreD2Ev +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCoreD1Ev +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCoreD0Ev +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCoreD4Ev +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore4openEv +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore5closeEv +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore4readEPvm +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore5writeEPKvm +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore17continueHandshakeEv +Security:single module:__ZNK8Security10IPPlusPlus19SecureTransportCore5stateEv +Security:single module:__ZNK8Security10IPPlusPlus19SecureTransportCore7versionEv +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore7versionE11SSLProtocol +Security:single module:__ZNK8Security10IPPlusPlus19SecureTransportCore19numSupportedCiphersEv +Security:single module:__ZNK8Security10IPPlusPlus19SecureTransportCore16supportedCiphersEPmRm +Security:single module:__ZNK8Security10IPPlusPlus19SecureTransportCore17numEnabledCiphersEv +Security:single module:__ZNK8Security10IPPlusPlus19SecureTransportCore14enabledCiphersEPmRm +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore14enabledCiphersEPmm +Security:single module:__ZNK8Security10IPPlusPlus19SecureTransportCore18allowsExpiredCertsEv +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore18allowsExpiredCertsEb +Security:single module:__ZNK8Security10IPPlusPlus19SecureTransportCore18allowsUnknownRootsEv +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore18allowsUnknownRootsEb +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore6peerIdEPKvm +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore11sslReadFuncEPKvPvPm +Security:single module:__ZN8Security10IPPlusPlus19SecureTransportCore12sslWriteFuncEPKvS3_Pm +Security:single module:__ZN8Security10IPPlusPlus11SocksServer4makeEjRKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus17SocksClientSocket4openERKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus17SocksClientSocket4openERKNS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus17SocksClientSocket4openERKNS0_4HostEt +Security:single module:__ZN8Security10IPPlusPlus17SocksClientSocket5setFdEiRKNS0_13IPSockAddressES4_ +Security:single module:__ZN8Security10IPPlusPlus17SocksServerSocket4openERKNS0_13IPSockAddressEi +Security:single module:__ZN8Security10IPPlusPlus17SocksServerSocket7receiveERNS0_17SocksClientSocketE +Security:single module:__ZNK8Security10IPPlusPlus11SocksServer7Support12localAddressERKNS0_6SocketE +Security:single module:__ZNK8Security10IPPlusPlus11SocksServer7Support11peerAddressERKNS0_6SocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks46Server7connectERNS0_17SocksClientSocketERKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socks46Server7connectERNS0_17SocksClientSocketERKNS0_4HostEt +Security:single module:__ZN8Security10IPPlusPlus6Socks46Server4bindERNS0_17SocksServerSocketERKNS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus6Socks46Server7receiveERNS0_17SocksServerSocketERNS0_17SocksClientSocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks47MessageC2ENS1_7CommandERKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socks47MessageC1ENS1_7CommandERKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socks47MessageC4ENS1_7CommandERKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socks47Message4sendERNS0_6SocketEPKc +Security:single module:__ZN8Security10IPPlusPlus6Socks47MessageC2ERNS0_6SocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks47MessageC1ERNS0_6SocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks47MessageC4ERNS0_6SocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks56Server4openERNS0_6SocketERNS0_11SocksServer7SupportE +Security:single module:__ZN8Security10IPPlusPlus6Socks56Server7connectERNS0_17SocksClientSocketERKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socks56Server7connectERNS0_17SocksClientSocketERKNS0_4HostEt +Security:single module:__ZN8Security10IPPlusPlus6Socks56Server4bindERNS0_17SocksServerSocketERKNS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus6Socks56Server7receiveERNS0_17SocksServerSocketERNS0_17SocksClientSocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC2ENS1_7CommandENS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC1ENS1_7CommandENS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC4ENS1_7CommandENS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC2ENS1_7CommandEPKct +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC1ENS1_7CommandEPKct +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC4ENS1_7CommandEPKct +Security:single module:__ZN8Security10IPPlusPlus6Socks57Message4sendERNS0_6SocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC2ERNS0_6SocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC1ERNS0_6SocketE +Security:single module:__ZN8Security10IPPlusPlus6Socks57MessageC4ERNS0_6SocketE +Security:single module:__ZN8Security10BufferFifoD2Ev +Security:single module:__ZN8Security10BufferFifoD1Ev +Security:single module:__ZN8Security10BufferFifoD0Ev +Security:single module:__ZN8Security10BufferFifoD4Ev +Security:single module:__ZN8Security10BufferFifo11clearBufferEv +Security:single module:__ZN8Security10BufferFifo7consumeEPKvm +Security:single module:__ZN8Security10BufferFifo3popEv +Security:single module:__ZN8Security9ConstData4BlobC2EPKvmb +Security:single module:__ZN8Security9ConstData4BlobC1EPKvmb +Security:single module:__ZN8Security9ConstData4BlobC4EPKvmb +Security:single module:__ZN8Security10IPPlusPlus9InetReplyC2EPKc +Security:single module:__ZN8Security10IPPlusPlus9InetReplyC1EPKc +Security:single module:__ZN8Security10IPPlusPlus9InetReplyC4EPKc +Security:single module:__ZN8Security10IPPlusPlus9InetReply7analyzeEv +Security:single module:__ZN8Security10IPPlusPlus9InetReply12ContinuationclEPKc +Security:single module:__ZN8Security10IPPlusPlus9InetReply12ContinuationclERKS1_ +Security:single module:__ZN8Security10IPPlusPlus9IPAddressC2EPKc +Security:single module:__ZN8Security10IPPlusPlus9IPAddressC1EPKc +Security:single module:__ZN8Security10IPPlusPlus9IPAddressC4EPKc +Security:single module:__ZNK8Security10IPPlusPlus9IPAddresscvSsEv +Security:single module:__ZN8Security10IPPlusPlus13IPSockAddressC2Ev +Security:single module:__ZN8Security10IPPlusPlus13IPSockAddressC1Ev +Security:single module:__ZN8Security10IPPlusPlus13IPSockAddressC4Ev +Security:single module:__ZN8Security10IPPlusPlus13IPSockAddressC2ERKNS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus13IPSockAddressC1ERKNS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus13IPSockAddressC4ERKNS0_9IPAddressEt +Security:single module:__ZNK8Security10IPPlusPlus13IPSockAddresscvSsEv +Security:single module:__ZNK8Security10IPPlusPlus13IPSockAddress8defaultsERKS1_ +Security:single module:__ZNK8Security10IPPlusPlus13IPSockAddress8defaultsERKNS0_9IPAddressEt +Security:single module:__ZNK8Security10IPPlusPlus13IPSockAddress8defaultsEt +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC2Ev +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC1Ev +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC4Ev +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC2EPKc +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC1EPKc +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC4EPKc +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC2ERKSs +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC1ERKSs +Security:single module:__ZN8Security10IPPlusPlus13UNSockAddressC4ERKSs +Security:single module:__ZNK8Security10IPPlusPlus13UNSockAddress4pathEv +Security:single module:__ZN8Security10IPPlusPlus6SocketC2Ei +Security:single module:__ZN8Security10IPPlusPlus6SocketC1Ei +Security:single module:__ZN8Security10IPPlusPlus6SocketC4Ei +Security:single module:__ZN8Security10IPPlusPlus6SocketC2Eiii +Security:single module:__ZN8Security10IPPlusPlus6SocketC1Eiii +Security:single module:__ZN8Security10IPPlusPlus6SocketC4Eiii +Security:single module:__ZN8Security10IPPlusPlus6Socket4openEiii +Security:single module:__ZN8Security10IPPlusPlus6Socket7prepareEiiii +Security:single module:__ZN8Security10IPPlusPlus6Socket4bindERKNS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus6Socket4bindERKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socket4bindERKNS0_13UNSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socket6listenEi +Security:single module:__ZN8Security10IPPlusPlus6Socket6acceptERS1_ +Security:single module:__ZN8Security10IPPlusPlus6Socket6acceptERS1_RNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socket6acceptERS1_RNS0_13UNSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socket7connectERKNS0_13IPSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socket7connectERKNS0_9IPAddressEt +Security:single module:__ZN8Security10IPPlusPlus6Socket7connectERKNS0_13UNSockAddressE +Security:single module:__ZN8Security10IPPlusPlus6Socket8shutdownEi +Security:single module:__ZNK8Security10IPPlusPlus6Socket12localAddressEv +Security:single module:__ZNK8Security10IPPlusPlus6Socket11peerAddressEv +Security:single module:__ZNK8Security10IPPlusPlus6Socket9getOptionEPvRiii +Security:single module:__ZNK8Security10IPPlusPlus6Socket9setOptionEPKviii +Security:single module:__ZN8Security10IPPlusPlus6Socket7connectERKNS0_4HostEt +Security:single module:__ZN8Security10IPPlusPlus15TCPClientSocket4openERKNS0_13IPSockAddressEi +Security:single module:__ZN8Security10IPPlusPlus15TCPClientSocket4openERKNS0_9IPAddressEti +Security:single module:__ZN8Security10IPPlusPlus15TCPClientSocket4openERKNS0_4HostEti +Security:single module:__ZN8Security10IPPlusPlus15TCPClientSocketD2Ev +Security:single module:__ZN8Security10IPPlusPlus15TCPClientSocketD1Ev +Security:single module:__ZN8Security10IPPlusPlus15TCPClientSocketD4Ev +Security:single module:__ZN8Security10IPPlusPlus15TCPServerSocket4openERKNS0_13IPSockAddressEi +Security:single module:__ZN8Security10IPPlusPlus15TCPServerSocketclERNS0_15TCPClientSocketE +Security:single module:__ZN8Security10IPPlusPlus15TCPServerSocket7receiveERNS0_15TCPClientSocketE +Security:single module:__ZN8Security10IPPlusPlus15TCPServerSocketD2Ev +Security:single module:__ZN8Security10IPPlusPlus15TCPServerSocketD1Ev +Security:single module:__ZN8Security10IPPlusPlus15TCPServerSocketD4Ev +Security:single module:__ZN8Security12UnixPlusPlus8SelectorC2Ev +Security:single module:__ZN8Security12UnixPlusPlus8SelectorC1Ev +Security:single module:__ZN8Security12UnixPlusPlus8SelectorC4Ev +Security:single module:__ZN8Security12UnixPlusPlus8SelectorD2Ev +Security:single module:__ZN8Security12UnixPlusPlus8SelectorD1Ev +Security:single module:__ZN8Security12UnixPlusPlus8SelectorD0Ev +Security:single module:__ZN8Security12UnixPlusPlus8SelectorD4Ev +Security:single module:__ZN8Security12UnixPlusPlus8Selector3addEiRNS1_6ClientEj +Security:single module:__ZN8Security12UnixPlusPlus8Selector6removeEi +Security:single module:__ZN8Security12UnixPlusPlus8Selector3setEij +Security:single module:__ZN8Security12UnixPlusPlus8SelectorclEv +Security:single module:__ZN8Security12UnixPlusPlus8SelectorclENS_4Time8AbsoluteE +Security:single module:__ZN8Security12UnixPlusPlus8Selector10singleStepENS_4Time8IntervalE +Security:single module:__ZNK8Security6Source5stateEv +Security:single module:__ZN8Security6Source7getSizeEv +Security:single module:__ZN8Security4Sink7setSizeEm +Security:single module:__ZN8Security10NullSource7produceEPvRm +Security:single module:__ZNK8Security10NullSource5stateEv +Security:single module:__ZN8Security8NullSink7consumeEPKvm +Security:single module:__ZN8Security10FileSource7produceEPvRm +Security:single module:__ZN8Security10FileSource7getSizeEv +Security:single module:__ZN8Security8FileSink7consumeEPKvm +Security:single module:__ZN8Security12MemorySource7produceEPvRm +Security:single module:__ZN8Security12MemorySource7getSizeEv +Security:single module:__ZNK8Security12MemorySource5stateEv +Security:single module:__ZN8Security10MemorySink7consumeEPKvm +Security:single module:__ZN8Security10MemorySink7setSizeEm +Security:single module:__ZN8Security10MemorySink4growEm +Security:single module:__ZN8Security4Time10resolutionENS0_8AbsoluteE +Security:single module:__ZN8Security4Time8AbsoluteC1ERK7timeval +Security:single module:__ZN8Security4Time8AbsoluteC1ERK8timespec +Security:single module:__ZN8Security4Time8AbsoluteC2ERK7timeval +Security:single module:__ZN8Security4Time8AbsoluteC2ERK8timespec +Security:single module:__ZN8Security4Time8AbsoluteC4ERK7timeval +Security:single module:__ZN8Security4Time8AbsoluteC4ERK8timespec +Security:single module:__ZNK8Security4Time8Absolutecv7timevalEv +Security:single module:__ZNK8Security4Time8Absolutecv8timespecEv +Security:single module:__ZNK8Security4Time8Interval15timevalIntervalEv +Security:single module:__ZN8Security12GenericValueD2Ev +Security:single module:__ZN8Security12GenericValueD1Ev +Security:single module:__ZN8Security12GenericValueD0Ev +Security:single module:__ZN8Security12GenericValueD4Ev +Security:single module:__ZN8Security12UnixPlusPlus7sigMaskENS0_6SigSetEi +Security:single module:__ZN8Security12UnixPlusPlus8FileDesc4mmapEimixPv +Security:single module:__ZN8Security12UnixPlusPlus8FileDesc4seekExi +Security:single module:__ZN8Security12UnixPlusPlus8FileDesc5closeEv +Security:single module:__ZN8Security12UnixPlusPlus8FileDesc6fdopenEPKc +Security:single module:__ZNK8Security12UnixPlusPlus8FileDesc5fcntlEiPv +Security:single module:__ZNK8Security12UnixPlusPlus8FileDesc5fcntlEii +Security:single module:__ZNK8Security12UnixPlusPlus8FileDesc5flagsEi +Security:single module:__ZNK8Security12UnixPlusPlus8FileDesc5flagsEv +Security:single module:__ZNK8Security12UnixPlusPlus8FileDesc5fstatER4stat +Security:single module:__ZNK8Security12UnixPlusPlus8FileDesc5ioctlEiPv +Security:single module:__ZNK8Security12UnixPlusPlus8FileDesc7setFlagEib +Security:single module:__ZNK8Security12UnixPlusPlus8FileDesc8fileSizeEv +Security:single module:__ZN8Security7Network5mkstrEPK10__CFString +Security:single module:__ZN8Security7Network3URLC2Ev +Security:single module:__ZN8Security7Network3URLC1Ev +Security:single module:__ZN8Security7Network3URLC4Ev +Security:single module:__ZN8Security7Network3URLC2EPKc +Security:single module:__ZN8Security7Network3URLC1EPKc +Security:single module:__ZN8Security7Network3URLC4EPKc +Security:single module:__ZN8Security7Network3URLC2EPKcRKS1_ +Security:single module:__ZN8Security7Network3URLC1EPKcRKS1_ +Security:single module:__ZN8Security7Network3URLC4EPKcRKS1_ +Security:single module:__ZN8Security7Network3URLD2Ev +Security:single module:__ZN8Security7Network3URLD1Ev +Security:single module:__ZN8Security7Network3URLD4Ev +Security:single module:__ZNK8Security7Network3URLcvSsEv +Security:single module:__ZNK8Security7Network3URL6schemeEv +Security:single module:__ZNK8Security7Network3URL4hostEv +Security:single module:__ZNK8Security7Network3URL4portEt +Security:single module:__ZNK8Security7Network3URL8usernameEv +Security:single module:__ZNK8Security7Network3URL8passwordEv +Security:single module:__ZNK8Security7Network3URL4pathEv +Security:single module:__ZNK8Security7Network3URL12resourceSpecEv +Security:single module:__ZNK8Security7Network3URL8fullPathEv +Security:single module:__ZNK8Security7Network3URL8basenameEv +Security:single module:__ZNK8Security7Network3URL9extensionEv +Security:single module:__ZN8Security7Network3URL11recreateURLEPKc +Security:single module:__ZN8Security10IPPlusPlus4HostC2EPKc +Security:single module:__ZN8Security10IPPlusPlus4HostC1EPKc +Security:single module:__ZN8Security10IPPlusPlus4HostC4EPKc +Security:single module:__ZNK8Security10IPPlusPlus4HosteqERKS1_ +Security:single module:__ZNK8Security10IPPlusPlus4HostltERKS1_ +Security:single module:__ZNK8Security10IPPlusPlus4HostleERKS1_ +Security:single module:__ZNK8Security10IPPlusPlus14IPv4NumberHost4nameEv +Security:single module:__ZNK8Security10IPPlusPlus14IPv4NumberHost9addressesEv +Security:single module:__ZN8Security10IPPlusPlus9NamedHostC2EPKc +Security:single module:__ZN8Security10IPPlusPlus9NamedHostC1EPKc +Security:single module:__ZN8Security10IPPlusPlus9NamedHostC4EPKc +Security:single module:__ZNK8Security10IPPlusPlus9NamedHost4nameEv +Security:single module:__ZNK8Security10IPPlusPlus9NamedHost9addressesEv +Security:single module:__ZN8Security9HeaderMap12CanonicalKeyC2EPKcc +Security:single module:__ZN8Security9HeaderMap12CanonicalKeyC1EPKcc +Security:single module:__ZN8Security9HeaderMap12CanonicalKeyC4EPKcc +Security:single module:__ZN8Security9HeaderMap3addEPKcS2_ +Security:single module:__ZN8Security9HeaderMap3addEPKc +Security:single module:__ZN8Security9HeaderMap3addERKNS0_12CanonicalKeyEPKc +Security:single module:__ZNK8Security9HeaderMap4findEPKcS2_ +Security:single module:__ZN8Security9HeaderMapixEPKc +Security:single module:__ZN8Security9HeaderMap5mergeESsRSsSs +Security:single module:__ZNK8Security9HeaderMap7collectEPKc +Security:single module:__ZNK8Security9HeaderMap13collectLengthEPKc +Security:single module:__ZN8Security6BufferC2Em +Security:single module:__ZN8Security6BufferC1Em +Security:single module:__ZN8Security6BufferC4Em +Security:single module:__ZN8Security6BufferC2EPvmbb +Security:single module:__ZN8Security6BufferC1EPvmbb +Security:single module:__ZN8Security6BufferC4EPvmbb +Security:single module:__ZN8Security6BufferD2Ev +Security:single module:__ZN8Security6BufferD1Ev +Security:single module:__ZN8Security6BufferD4Ev +Security:single module:__ZN8Security6Buffer7shuffleEm +Security:single module:__ZN8Security6Buffer6printfEPKcz +Security:single module:__ZN8Security6Buffer7vprintfEPKcPc +Security:single module:__ZN8Security12UnixPlusPlus5FDSetD2Ev +Security:single module:__ZN8Security12UnixPlusPlus5FDSetD1Ev +Security:single module:__ZN8Security12UnixPlusPlus5FDSetD4Ev +Security:single module:__ZN8Security12UnixPlusPlus5FDSet4growEii +Security:single module:__ZN8Security12UnixPlusPlus5FDSet4growERPiii +Security:single module:__ZN8Security12UnixPlusPlus5FDSet3setEib +Security:single module:__ZN8Security12UnixPlusPlus5FDSet4makeEi +Security:single module:__ZN8Security12ModuleLoaderC2Ev +Security:single module:__ZN8Security14LoadablePluginC2EPKc +Security:single module:__ZN8Security14LoadablePluginC1EPKc +Security:single module:__ZN8Security14LoadablePluginC4EPKc +Security:single module:__ZN8Security14LoadablePlugin4loadEv +Security:single module:__ZThn4_N8Security14LoadablePlugin4loadEv +Security:single module:__ZN8Security14LoadablePlugin6unloadEv +Security:single module:__ZThn4_N8Security14LoadablePlugin6unloadEv +Security:single module:__ZNK8Security14LoadablePlugin8isLoadedEv +Security:single module:__ZThn4_NK8Security14LoadablePlugin8isLoadedEv +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcherC2Ev +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcherC1Ev +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcherC4Ev +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcherD2Ev +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcherD1Ev +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcherD0Ev +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcherD4Ev +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcher10ioCallbackEPvjjS2_ +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcher15systemWillSleepEv +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcher14systemIsWakingEv +Security:single module:__ZN8Security12MachPlusPlus12PowerWatcher19systemWillPowerDownEv +Security:single module:__ZN8Security12MachPlusPlus16PortPowerWatcherC2Ev +Security:single module:__ZN8Security12MachPlusPlus16PortPowerWatcherC1Ev +Security:single module:__ZN8Security12MachPlusPlus16PortPowerWatcherC4Ev +Security:single module:__ZN8Security12MachPlusPlus16PortPowerWatcherD2Ev +Security:single module:__ZN8Security12MachPlusPlus16PortPowerWatcherD1Ev +Security:single module:__ZN8Security12MachPlusPlus16PortPowerWatcherD0Ev +Security:single module:__ZN8Security12MachPlusPlus16PortPowerWatcherD4Ev +Security:single module:__ZN8Security12MachPlusPlus16PortPowerWatcher6handleEP17mach_msg_header_t +Security:single module:__ZThn16_N8Security12MachPlusPlus16PortPowerWatcher6handleEP17mach_msg_header_t +Security:single module:_checkpw +Security:single module:__Z17cssm_DataGetFirst17cssm_dl_db_handlePK10cssm_queryPmP29cssm_db_record_attribute_dataP9cssm_dataPP21cssm_db_unique_record +Security:single module:__Z15cssm_DataModify17cssm_dl_db_handlemP21cssm_db_unique_recordPK29cssm_db_record_attribute_dataPK9cssm_datam +Security:single module:__Z24cssm_GetDbNameFromHandle17cssm_dl_db_handlePPc +Security:single module:__Z19cssm_DataAbortQuery17cssm_dl_db_handlem +Security:single module:__Z20cssm_DestroyRelation17cssm_dl_db_handlem +Security:single module:__Z15cssm_DataDelete17cssm_dl_db_handlePK21cssm_db_unique_record +Security:single module:__Z15cssm_DataInsert17cssm_dl_db_handlemPK29cssm_db_record_attribute_dataPK9cssm_dataPP21cssm_db_unique_record +Security:single module:__Z30cssm_DataGetFromUniqueRecordId17cssm_dl_db_handlePK21cssm_db_unique_recordP29cssm_db_record_attribute_dataP9cssm_data +Security:single module:__Z19cssm_CreateRelation17cssm_dl_db_handlemPKcmPK29cssm_db_schema_attribute_infomPK25cssm_db_schema_index_info +Security:single module:__Z21cssm_FreeUniqueRecord17cssm_dl_db_handleP21cssm_db_unique_record +Security:single module:__Z11cssm_DbOpenmPKcPK16cssm_net_addressmPK23cssm_access_credentialsPKvPm +Security:single module:__Z16cssm_DataGetNext17cssm_dl_db_handlemP29cssm_db_record_attribute_dataP9cssm_dataPP21cssm_db_unique_record +Security:single module:__Z15cssm_GetDbNamesmPP14cssm_name_list +Security:single module:__Z12cssm_DbClose17cssm_dl_db_handle +Security:single module:__Z17cssm_FreeNameListmP14cssm_name_list +Security:single module:_MDS_Initialize +Security:single module:_MDS_Terminate +Security:single module:_MDS_Install +Security:single module:_MDS_Uninstall +Security:single module:__ZN8Security9MDSModule3getEv +Security:single module:__ZN8Security9MDSModuleC2Ev +Security:single module:__ZN8Security9MDSModuleC1Ev +Security:single module:__ZN8Security9MDSModuleC4Ev +Security:single module:__ZN8Security9MDSModuleD2Ev +Security:single module:__ZN8Security9MDSModuleD1Ev +Security:single module:__ZN8Security9MDSModuleD4Ev +Security:single module:__ZN8Security9MDSModule13lastScanIsNowEv +Security:single module:__ZN8Security9MDSModule17timeSinceLastScanEv +Security:single module:__ZN8Security9MDSModule9getDbPathEPc +Security:single module:__ZN8Security9MDSModule9setDbPathEPKc +Security:single module:__ZN8Security23MDSRecordTypeToRelationEm +Security:single module:__ZN8Security27MDSRecordTypeNameToRelationEPKc +Security:single module:__ZN8Security12doFilesExistEPKcS1_b +Security:single module:__ZN8Security15doesDirectExistEPKc +Security:single module:__ZN8Security9createDirEPKct +Security:single module:__ZN8Security10MDSSessionC2EPKNS_4GuidERK17cssm_memory_funcs +Security:single module:__ZN8Security10MDSSessionC1EPKNS_4GuidERK17cssm_memory_funcs +Security:single module:__ZN8Security10MDSSessionC4EPKNS_4GuidERK17cssm_memory_funcs +Security:single module:__ZN8Security10MDSSessionD2Ev +Security:single module:__ZN8Security10MDSSessionD1Ev +Security:single module:__ZThn80_N8Security10MDSSessionD1Ev +Security:single module:__ZThn4_N8Security10MDSSessionD1Ev +Security:single module:__ZN8Security10MDSSessionD0Ev +Security:single module:__ZThn80_N8Security10MDSSessionD0Ev +Security:single module:__ZThn4_N8Security10MDSSessionD0Ev +Security:single module:__ZN8Security10MDSSessionD4Ev +Security:single module:__ZN8Security10MDSSession9terminateEv +Security:single module:__ZN8Security10MDSSession7installEv +Security:single module:__ZN8Security10MDSSession9uninstallEv +Security:single module:__ZN8Security10MDSSession6dbOpenEPKc +Security:single module:__ZN8Security10MDSSession6DbOpenEPKcPK16cssm_net_addressmPKNS_17AccessCredentialsEPKvRm +Security:single module:__ZN8Security10MDSSession10GetDbNamesERP14cssm_name_list +Security:single module:__ZN8Security10MDSSession12FreeNameListER14cssm_name_list +Security:single module:__ZN8Security10MDSSession19GetDbNameFromHandleEmPPc +Security:single module:__ZN8Security10MDSSession10obtainLockEPKcRii +Security:single module:__ZN8Security10MDSSession11releaseLockERi +Security:single module:__ZN8Security10MDSSession10dbFullPathEPKcPc +Security:single module:__ZN8Security8isBundleEPK6dirent +Security:single module:__ZN8Security16checkUserBundlesEPKc +Security:single module:__ZN8Security12safeCopyFileEPKcS1_ +Security:single module:__ZN8Security13copySystemDbsEPKc +Security:single module:__ZN8Security10MDSSession15updateDataBasesEv +Security:single module:__ZN8Security10MDSSession20removeRecordsForGuidEPKcm +Security:single module:__ZN8Security10MDSSession22systemDatabasesPresentEb +Security:single module:__ZN8Security10MDSSession20createSystemDatabaseEPKcPKNS_12RelationInfoEjltRm +Security:single module:__ZN8Security10MDSSession21createSystemDatabasesElt +Security:single module:__ZN8Security10MDSSession11DbFilesInfoC2ERS0_PKc +Security:single module:__ZN8Security10MDSSession11DbFilesInfoC1ERS0_PKc +Security:single module:__ZN8Security10MDSSession11DbFilesInfoC4ERS0_PKc +Security:single module:__ZN8Security10MDSSession11DbFilesInfoD2Ev +Security:single module:__ZN8Security10MDSSession11DbFilesInfoD1Ev +Security:single module:__ZN8Security10MDSSession11DbFilesInfoD4Ev +Security:single module:__ZN8Security10MDSSession11DbFilesInfo9objDbHandEv +Security:single module:__ZN8Security10MDSSession11DbFilesInfo12directDbHandEv +Security:single module:__ZN8Security10MDSSession11DbFilesInfo18updateSystemDbInfoEPKcS3_ +Security:single module:__ZN8Security10MDSSession11DbFilesInfo9TbdRecordC2ERK9cssm_data +Security:single module:__ZN8Security10MDSSession11DbFilesInfo9TbdRecordC1ERK9cssm_data +Security:single module:__ZN8Security10MDSSession11DbFilesInfo9TbdRecordC4ERK9cssm_data +Security:single module:__ZN8Security10MDSSession11DbFilesInfo19checkOutdatedPluginERK9cssm_dataS4_RSt6vectorIPNS1_9TbdRecordESaIS7_EE +Security:single module:__ZN8Security10MDSSession11DbFilesInfo21removeOutdatedPluginsEv +Security:single module:__ZN8Security10MDSSession11DbFilesInfo18updateForBundleDirEPKc +Security:single module:__ZN8Security10MDSSession11DbFilesInfo13lookupForPathEPKc +Security:single module:__ZN8Security10MDSSession11DbFilesInfo15updateForBundleEPKc +Security:single module:__ZN8Security10MDSSession11DbFilesInfo10autoCommitEl +Security:single module:__ZN8Security12isNumericStrEPKcb +Security:single module:__ZN8Security8hexDigitEh +Security:single module:__ZN8Security8strToHexEPKc +Security:single module:__ZN8Security18MDSAttrNameToValueEPKcPKNS_16MDSNameValuePairERm +Security:single module:__ZN8Security13MDSAttrParserC2EPKcRNS_10MDSSessionEmm +Security:single module:__ZN8Security13MDSAttrParserC1EPKcRNS_10MDSSessionEmm +Security:single module:__ZN8Security13MDSAttrParserC4EPKcRNS_10MDSSessionEmm +Security:single module:__ZN8Security13MDSAttrParserD2Ev +Security:single module:__ZN8Security13MDSAttrParserD1Ev +Security:single module:__ZN8Security13MDSAttrParserD0Ev +Security:single module:__ZN8Security13MDSAttrParserD4Ev +Security:single module:__ZN8Security13MDSAttrParser10parseAttrsEv +Security:single module:__ZN8Security13MDSAttrParser12logFileErrorEPKcPK7__CFURLPK10__CFStringPl +Security:single module:__ZN8Security13MDSAttrParser13parseCssmInfoEPNS_13MDSDictionaryE +Security:single module:__ZN8Security13MDSAttrParser17parsePluginCommonEPNS_13MDSDictionaryE +Security:single module:__ZN8Security13MDSAttrParser19parsePluginSpecificEPNS_13MDSDictionaryE +Security:single module:__ZN8Security13MDSAttrParser17parseObjectRecordEPNS_13MDSDictionaryE +Security:single module:__ZN8Security13MDSAttrParser14parseMdsRecordEPNS_13MDSDictionaryEPKNS_12RelationInfoEm +Security:single module:__ZN8Security13MDSAttrParser26parseCspCapabilitiesRecordEPNS_13MDSDictionaryE +Security:single module:__ZN8Security13MDSAttrParser23parseTpPolicyOidsRecordEPNS_13MDSDictionaryE +Security:single module:__ZN8Security19MDSRawValueToDbAttrEPKvmmPKcR22cssm_db_attribute_datam +Security:single module:__ZN8Security20MDSFreeDbRecordAttrsEP22cssm_db_attribute_dataj +Security:single module:__ZN8Security20MDSCFStringToCStringEPK10__CFString +Security:single module:__ZN8Security14MDSCopyCstringEPKc +Security:single module:__ZN8Security14MDSCfTypeToIntEPKvPKNS_16MDSNameValuePairEPKcRm +Security:single module:__ZN8Security15MDSInsertRecordEPK22cssm_db_attribute_datajmRNS_10MDSSessionEm +Security:single module:__ZN8Security17MDSStringToUint32EPK10__CFStringPKNS_16MDSNameValuePairERm +Security:single module:__ZN8Security13MDSDictionaryC2EPK7__CFURLPKc +Security:single module:__ZN8Security13MDSDictionaryC1EPK7__CFURLPKc +Security:single module:__ZN8Security13MDSDictionaryC4EPK7__CFURLPKc +Security:single module:__ZN8Security13MDSDictionaryC2EPK14__CFDictionary +Security:single module:__ZN8Security13MDSDictionaryC1EPK14__CFDictionary +Security:single module:__ZN8Security13MDSDictionaryC4EPK14__CFDictionary +Security:single module:__ZN8Security13MDSDictionaryD2Ev +Security:single module:__ZN8Security13MDSDictionaryD1Ev +Security:single module:__ZN8Security13MDSDictionaryD4Ev +Security:single module:__ZN8Security13MDSDictionary6lookupEPKcbm +Security:single module:__ZN8Security13MDSDictionary6lookupEPK10__CFStringbm +Security:single module:__ZN8Security13MDSDictionary14lookupToDbAttrEPKcR22cssm_db_attribute_datamPKNS_16MDSNameValuePairE +Security:single module:__ZN8Security13MDSDictionary16lookupAttributesEPKNS_12RelationInfoEP22cssm_db_attribute_dataRm +Security:single module:__ZN8Security13MDSDictionary18lookupWithIndirectEPKcP10__CFBundlemRb +Security:single module:__ZN8Security27ProtectedPasswordAclSubjectC2ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security27ProtectedPasswordAclSubjectC1ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security27ProtectedPasswordAclSubjectC4ERNS_13CssmAllocatorERKNS_8CssmDataE +Security:single module:__ZN8Security27ProtectedPasswordAclSubjectC2ERNS_13CssmAllocatorERNS_15CssmManagedDataE +Security:single module:__ZN8Security27ProtectedPasswordAclSubjectC1ERNS_13CssmAllocatorERNS_15CssmManagedDataE +Security:single module:__ZN8Security27ProtectedPasswordAclSubjectC4ERNS_13CssmAllocatorERNS_15CssmManagedDataE +Security:single module:__ZNK8Security27ProtectedPasswordAclSubject8validateERKNS_20AclValidationContextERKNS_9TypedListE +Security:single module:__ZNK8Security27ProtectedPasswordAclSubject6toListERNS_13CssmAllocatorE +Security:single module:__ZNK8Security27ProtectedPasswordAclSubject5Maker4makeERKNS_9TypedListE +Security:single module:__ZNK8Security27ProtectedPasswordAclSubject5Maker4makeEhRNS_23LowLevelMemoryUtilities6ReaderES4_ +Security:single module:__ZN8Security27ProtectedPasswordAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6Writer7CounterES4_ +Security:single module:__ZN8Security27ProtectedPasswordAclSubject10exportBlobERNS_23LowLevelMemoryUtilities6WriterES3_ +Security:single module:__Z13HMAC_FreeNullP11HMACContext +Security:single module:__Z13HMAC_HmacNullP11HMACContextPKvjPvPj +Security:single module:__Z13HMAC_InitNullP11HMACContext +Security:single module:__Z14HMAC_AllocNullPK13HMACReferenceP10SSLContextPKvjPP11HMACContext +Security:single module:__Z14HMAC_FinalNullP11HMACContextPvPj +Security:single module:__Z15HMAC_UpdateNullP11HMACContextPKvj +Security:single module:__Z11ssl3InitMacP13CipherContextP10SSLContext +Security:single module:__Z14ssl3ComputeMach9SSLBufferS_P13CipherContext9sslUint64P10SSLContext +Security:single module:__Z21ssl3ComputeCertVfyMacP10SSLContext9SSLBufferS1_S1_ +Security:single module:__Z22ssl3ComputeFinishedMacP10SSLContext9SSLBufferS1_S1_h +Security:single module:__Z23ssl3GenerateKeyMaterial9SSLBufferP10SSLContext +Security:single module:__Z24ssl3GenerateMasterSecretP10SSLContext +Security:single module:__Z26ssl3GenerateExportKeyAndIvP10SSLContext9SSLBufferS1_S1_S1_S1_S1_ +Security:single module:__Z28ssl3CalculateFinishedMessageP10SSLContext9SSLBufferS1_S1_m +Security:single module:__Z21tls1ComputeCertVfyMacP10SSLContext9SSLBufferS1_S1_ +Security:single module:__Z26tls1GenerateExportKeyAndIvP10SSLContext9SSLBufferS1_S1_S1_S1_S1_ +Security:single module:__ZN8Security12KeychainCore8IdentityC2ERKNS0_10SecPointerINS0_7KeyItemEEERKNS2_INS0_11CertificateEEE +Security:single module:__ZN8Security12KeychainCore8IdentityC1ERKNS0_10SecPointerINS0_7KeyItemEEERKNS2_INS0_11CertificateEEE +Security:single module:__ZN8Security12KeychainCore8IdentityC4ERKNS0_10SecPointerINS0_7KeyItemEEERKNS2_INS0_11CertificateEEE +Security:single module:__ZN8Security12KeychainCore8IdentityC2ERKSt6vectorINS0_8KeychainESaIS3_EERKNS0_10SecPointerINS0_11CertificateEEE +Security:single module:__ZN8Security12KeychainCore8IdentityC1ERKSt6vectorINS0_8KeychainESaIS3_EERKNS0_10SecPointerINS0_11CertificateEEE +Security:single module:__ZN8Security12KeychainCore8IdentityC4ERKSt6vectorINS0_8KeychainESaIS3_EERKNS0_10SecPointerINS0_11CertificateEEE +Security:single module:__ZN8Security12KeychainCore8IdentityD2Ev +Security:single module:__ZN8Security12KeychainCore8IdentityD1Ev +Security:single module:__ZN8Security12KeychainCore8IdentityD0Ev +Security:single module:__ZN8Security12KeychainCore8IdentityD4Ev +Security:single module:__ZNK8Security12KeychainCore8Identity10privateKeyEv +Security:single module:__ZNK8Security12KeychainCore8Identity11certificateEv +Security:single module:__ZN8Security12KeychainCore10SecCFTypesC2Ev +Security:single module:__ZN8Security12KeychainCore7CFClass17copyDebugDescTypeEPKv +Security:single module:__ZN8Security12KeychainCore7CFClass22copyFormattingDescTypeEPKvPK14__CFDictionary +Security:single module:__ZN8Security12KeychainCore7CFClassC2EPKc +Security:single module:__ZN8Security12KeychainCore11SecCFObject13copyDebugDescEv +Security:single module:__ZN8Security12KeychainCore11SecCFObject18copyFormattingDescEPK14__CFDictionary +Security:single module:__ZN8Security12KeychainCore11SecCFObjectD0Ev +Security:single module:__ZN8Security12KeychainCore11SecCFObjectD1Ev +Security:single module:__ZN8Security12KeychainCore11SecCFObjectdlEPv +Security:single module:_SecAccessGetTypeID +Security:single module:_SecAccessCreate +Security:single module:_SecAccessCreateFromOwnerAndACL +Security:single module:_SecAccessGetOwnerAndACL +Security:single module:_SecAccessCopyACLList +Security:single module:_SecAccessCopySelectedACLList +Security:single module:_SecCertificateAddToKeychain +Security:single module:_SecCertificateCopyPublicKey +Security:single module:_SecCertificateFindByEmail +Security:single module:_SecCertificateFindByIssuerAndSN +Security:single module:_SecCertificateFindBySubjectKeyID +Security:single module:_SecCertificateGetAlgorithmID +Security:single module:_SecCertificateGetCLHandle +Security:single module:_SecCertificateGetCommonName +Security:single module:_SecCertificateGetData +Security:single module:_SecCertificateGetEmailAddress +Security:single module:_SecCertificateGetIssuer +Security:single module:_SecCertificateGetSubject +Security:single module:_SecCertificateGetType +Security:single module:_SecCertificateGetTypeID +Security:single module:_SecCertificateInferLabel +Security:single module:_SecCertificateRequestGetTypeID +Security:single module:_SecCertificateRequestCreate +Security:single module:_SecCertificateRequestSetPrivateKey +Security:single module:_SecCertificateRequestSetAttribute +Security:single module:_SecCertificateRequestSubmit +Security:single module:_SecCertificateRequestCreateFromItem +Security:single module:_SecCertificateRequestGetType +Security:single module:_SecCertificateRequestGetResult +Security:single module:_SecCertificateBundleImport +Security:single module:_SecCertifcateBundleExport +Security:single module:_SecIdentityGetTypeID +Security:single module:_SecIdentityCopyCertificate +Security:single module:_SecIdentityCopyPrivateKey +Security:single module:_SecIdentityCreateWithCertificate +Security:single module:_SecIdentitySearchGetTypeID +Security:single module:_SecIdentitySearchCreate +Security:single module:_SecIdentitySearchCopyNext +Security:single module:_SecKeyGetTypeID +Security:single module:_SecKeyCreatePair +Security:single module:_SecKeyGetCSSMKey +Security:single module:_SecKeyGetCSPHandle +Security:single module:_SecKeyGetAlgorithmID +Security:single module:_SecKeyGetStrengthInBits +Security:single module:_SecKeyGetCredentials +Security:single module:_SecKeyImportPair +Security:single module:_SecKeyGenerate +Security:single module:_SecKeyCreate +Security:single module:_SecCopyErrorMessageString +Security:single module:_SecKeychainAddCallback +Security:single module:_SecKeychainAddGenericPassword +Security:single module:_SecKeychainAddInternetPassword +Security:single module:_SecKeychainAttributeInfoForItemID +Security:single module:_SecKeychainChangePassword +Security:single module:_SecKeychainCopyAccess +Security:single module:_SecKeychainCopyDefault +Security:single module:_SecKeychainCopyDomainDefault +Security:single module:_SecKeychainCopyDomainSearchList +Security:single module:_SecKeychainCopyLogin +Security:single module:_SecKeychainCopySettings +Security:single module:_SecKeychainCreate +Security:single module:_SecKeychainDelete +Security:single module:_SecKeychainFindInternetPassword +Security:single module:_SecKeychainFreeAttributeInfo +Security:single module:_SecKeychainGetCSPHandle +Security:single module:_SecKeychainGetDLDBHandle +Security:single module:_SecKeychainGetPath +Security:single module:_SecKeychainGetPreferenceDomain +Security:single module:_SecKeychainGetStatus +Security:single module:_SecKeychainGetTypeID +Security:single module:_SecKeychainGetUserInteractionAllowed +Security:single module:_SecKeychainGetVersion +Security:single module:_SecKeychainListCopyKeychainAtIndex +Security:single module:_SecKeychainListGetCount +Security:single module:_SecKeychainListRemoveKeychain +Security:single module:_SecKeychainLock +Security:single module:_SecKeychainLockAll +Security:single module:_SecKeychainLogin +Security:single module:_SecKeychainLogout +Security:single module:_SecKeychainOpen +Security:single module:_SecKeychainRemoveCallback +Security:single module:_SecKeychainResetLogin +Security:single module:_SecKeychainSetAccess +Security:single module:_SecKeychainSetDefault +Security:single module:_SecKeychainSetDomainDefault +Security:single module:_SecKeychainSetDomainSearchList +Security:single module:_SecKeychainSetPreferenceDomain +Security:single module:_SecKeychainSetSearchList +Security:single module:_SecKeychainSetSettings +Security:single module:_SecKeychainSetUserInteractionAllowed +Security:single module:_SecKeychainUnlock +Security:single module:__Z26copyErrorMessageFromBundlelPK10__CFString +Security:single module:_SecKeychainItemCopyAccess +Security:single module:_SecKeychainItemCopyAttributesAndData +Security:single module:_SecKeychainItemCopyKeychain +Security:single module:_SecKeychainItemCreateCopy +Security:single module:_SecKeychainItemCreateFromContent +Security:single module:_SecKeychainItemDelete +Security:single module:_SecKeychainItemFreeAttributesAndData +Security:single module:_SecKeychainItemGetDLDBHandle +Security:single module:_SecKeychainItemGetTypeID +Security:single module:_SecKeychainItemGetUniqueRecordID +Security:single module:_SecKeychainItemModifyAttributesAndData +Security:single module:_SecKeychainItemModifyContent +Security:single module:_SecKeychainItemSetAccess +Security:single module:__Z21SecAccessModifyObjectP18OpaqueSecAccessRefPKv +Security:single module:__Z25SecAccessCreateFromObjectPKvPP18OpaqueSecAccessRef +Security:single module:__Z9aclBearerPKv +Security:single module:_SecKeychainSearchGetTypeID +Security:single module:_SecPolicyGetOID +Security:single module:_SecPolicyGetTPHandle +Security:single module:_SecPolicyGetTypeID +Security:single module:_SecPolicyGetValue +Security:single module:_SecPolicySearchGetTypeID +Security:single module:_SecTrustCopyAnchorCertificates +Security:single module:_SecTrustGetCSSMAnchorCertificates +Security:single module:_SecTrustGetCssmResult +Security:single module:_SecTrustGetCssmResultCode +Security:single module:_SecTrustGetResult +Security:single module:_SecTrustGetTPHandle +Security:single module:_SecTrustGetTypeID +Security:single module:_SecTrustGetUserTrust +Security:single module:_SecTrustSetAnchorCertificates +Security:single module:_SecTrustSetPolicies +Security:single module:_SecTrustSetUserTrust +Security:single module:_SecTrustSetVerifyDate +Security:single module:_SecTrustedApplicationCopyData +Security:single module:_SecTrustedApplicationGetTypeID +Security:single module:_SecTrustedApplicationRemoveEquivalence +Security:single module:_SecTrustedApplicationSetData +Security:single module:_SecTrustedApplicationUseAlternateSystem +Security:single module:_SecTrustedApplicationValidateWithPath +Security:single module:__ZN8Security12KeychainCore14IdentityCursorC2ERKSt6vectorINS0_8KeychainESaIS3_EEm +Security:single module:__ZN8Security12KeychainCore14IdentityCursorC1ERKSt6vectorINS0_8KeychainESaIS3_EEm +Security:single module:__ZN8Security12KeychainCore14IdentityCursorC4ERKSt6vectorINS0_8KeychainESaIS3_EEm +Security:single module:__ZN8Security12KeychainCore14IdentityCursorD2Ev +Security:single module:__ZN8Security12KeychainCore14IdentityCursorD1Ev +Security:single module:__ZN8Security12KeychainCore14IdentityCursorD0Ev +Security:single module:__ZN8Security12KeychainCore14IdentityCursorD4Ev +Security:single module:__ZN8Security12KeychainCore14IdentityCursor4nextERNS0_10SecPointerINS0_8IdentityEEE +Security:single module:__ZN8Security12KeychainCore12PolicyCursorC2EPK9cssm_dataS4_ +Security:single module:__ZN8Security12KeychainCore12PolicyCursorD0Ev +Security:single module:__ZN8Security12KeychainCore12PolicyCursorD2Ev +Security:single module:_SecInferLabelFromX509Name +Security:single module:__Z18findPrintableFieldRK14cssm_x509_namePK9cssm_data +Security:single module:__ZN8Security12KeychainCore11Certificate10certHandleEv +Security:single module:__ZN8Security12KeychainCore11Certificate10commonNameEv +Security:single module:__ZN8Security12KeychainCore11Certificate10getSubjectER14cssm_x509_name +Security:single module:__ZN8Security12KeychainCore11Certificate10inferLabelEbPPK10__CFString +Security:single module:__ZN8Security12KeychainCore11Certificate11algorithmIDEv +Security:single module:__ZN8Security12KeychainCore11Certificate11findByEmailERKSt6vectorINS0_8KeychainESaIS3_EEPKc +Security:single module:__ZN8Security12KeychainCore11Certificate12emailAddressEv +Security:single module:__ZN8Security12KeychainCore11Certificate13publicKeyHashEv +Security:single module:__ZN8Security12KeychainCore11Certificate15copyFieldValuesERK9cssm_data +Security:single module:__ZN8Security12KeychainCore11Certificate17findByIssuerAndSNERKSt6vectorINS0_8KeychainESaIS3_EERKNS_8CssmDataESA_ +Security:single module:__ZN8Security12KeychainCore11Certificate17releaseFieldValueERK9cssm_dataPS2_ +Security:single module:__ZN8Security12KeychainCore11Certificate18addParsedAttributeERK22cssm_db_attribute_infoRK9cssm_data +Security:single module:__ZN8Security12KeychainCore11Certificate18findBySubjectKeyIDERKSt6vectorINS0_8KeychainESaIS3_EERKNS_8CssmDataE +Security:single module:__ZN8Security12KeychainCore11Certificate18populateAttributesEv +Security:single module:__ZN8Security12KeychainCore11Certificate18releaseFieldValuesERK9cssm_dataPPS2_ +Security:single module:__ZN8Security12KeychainCore11Certificate19copyFirstFieldValueERK9cssm_data +Security:single module:__ZN8Security12KeychainCore11Certificate3addERNS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore11Certificate4typeEv +Security:single module:__ZN8Security12KeychainCore11Certificate6copyToERKNS0_8KeychainEPNS0_6AccessE +Security:single module:__ZN8Security12KeychainCore11Certificate6updateEv +Security:single module:__ZN8Security12KeychainCore11Certificate8clHandleEv +Security:single module:__ZN8Security12KeychainCore11Certificate8encodingEv +Security:single module:__ZN8Security12KeychainCore11Certificate9didModifyEv +Security:single module:__ZN8Security12KeychainCore11Certificate9getIssuerER14cssm_x509_name +Security:single module:__ZN8Security12KeychainCore11Certificate9publicKeyEv +Security:single module:__ZN8Security12KeychainCore11CertificateC1ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore11CertificateC1ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore11CertificateC1ERS1_ +Security:single module:__ZN8Security12KeychainCore11CertificateC2ERK9cssm_datamm +Security:single module:__ZN8Security12KeychainCore11CertificateC2ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore11CertificateC2ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore11CertificateC2ERS1_ +Security:single module:__ZN8Security12KeychainCore11CertificateC4ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore11CertificateC4ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore11CertificateC4ERS1_ +Security:single module:__ZN8Security12KeychainCore11CertificateD0Ev +Security:single module:__ZN8Security12KeychainCore11CertificateD2Ev +Security:single module:__ZN8Security12KeychainCore11CertificateeqERS1_ +Security:single module:__ZN8Security12KeychainCore11CertificateltERS1_ +Security:single module:__ZN8Security12KeychainCore6PolicyC2ENS_10CssmClient2TPERKNS_8CssmDataE +Security:single module:__ZN8Security12KeychainCore6PolicyD0Ev +Security:single module:__ZN8Security12KeychainCore6PolicyD2Ev +Security:single module:__ZNK8Security12KeychainCore6PolicyeqERKS1_ +Security:single module:__ZNK8Security12KeychainCore6PolicyltERKS1_ +Security:single module:__ZN8Security12KeychainCore6AccessC2Ev +Security:single module:__ZN8Security12KeychainCore6AccessC1Ev +Security:single module:__ZN8Security12KeychainCore6AccessC4Ev +Security:single module:__ZN8Security12KeychainCore6AccessC2ERKSsRKSt6vectorINS0_10SecPointerINS0_18TrustedApplicationEEESaIS7_EE +Security:single module:__ZN8Security12KeychainCore6AccessC1ERKSsRKSt6vectorINS0_10SecPointerINS0_18TrustedApplicationEEESaIS7_EE +Security:single module:__ZN8Security12KeychainCore6AccessC4ERKSsRKSt6vectorINS0_10SecPointerINS0_18TrustedApplicationEEESaIS7_EE +Security:single module:__ZN8Security12KeychainCore6AccessC2ERKSs +Security:single module:__ZN8Security12KeychainCore6AccessC1ERKSs +Security:single module:__ZN8Security12KeychainCore6AccessC4ERKSs +Security:single module:__ZN8Security12KeychainCore6AccessC2ERKSsRKSt6vectorINS0_10SecPointerINS0_18TrustedApplicationEEESaIS7_EERKSt3setIlSt4lessIlESaIlEESI_ +Security:single module:__ZN8Security12KeychainCore6AccessC1ERKSsRKSt6vectorINS0_10SecPointerINS0_18TrustedApplicationEEESaIS7_EERKSt3setIlSt4lessIlESaIlEESI_ +Security:single module:__ZN8Security12KeychainCore6AccessC4ERKSsRKSt6vectorINS0_10SecPointerINS0_18TrustedApplicationEEESaIS7_EERKSt3setIlSt4lessIlESaIlEESI_ +Security:single module:__ZN8Security12KeychainCore6Access12makeStandardERKSsRKSt6vectorINS0_10SecPointerINS0_18TrustedApplicationEEESaIS7_EERKSt3setIlSt4lessIlESaIlEESI_ +Security:single module:__ZN8Security12KeychainCore6AccessC2ERNS_10CssmClient9AclBearerE +Security:single module:__ZN8Security12KeychainCore6AccessC1ERNS_10CssmClient9AclBearerE +Security:single module:__ZN8Security12KeychainCore6AccessC4ERNS_10CssmClient9AclBearerE +Security:single module:__ZN8Security12KeychainCore6AccessC2ERK24cssm_acl_owner_prototypemPK19cssm_acl_entry_info +Security:single module:__ZN8Security12KeychainCore6AccessC1ERK24cssm_acl_owner_prototypemPK19cssm_acl_entry_info +Security:single module:__ZN8Security12KeychainCore6AccessC4ERK24cssm_acl_owner_prototypemPK19cssm_acl_entry_info +Security:single module:__ZN8Security12KeychainCore6AccessD2Ev +Security:single module:__ZN8Security12KeychainCore6AccessD1Ev +Security:single module:__ZN8Security12KeychainCore6AccessD0Ev +Security:single module:__ZN8Security12KeychainCore6AccessD4Ev +Security:single module:__Z7convertRKN8Security12KeychainCore10SecPointerINS0_3ACLEEE +Security:single module:__ZNK8Security12KeychainCore6Access11copySecACLsEv +Security:single module:__ZNK8Security12KeychainCore6Access11copySecACLsEl +Security:single module:__ZN8Security12KeychainCore6Access9setAccessERNS_10CssmClient9AclBearerEb +Security:single module:__ZN8Security12KeychainCore6Access9setAccessERNS_10CssmClient9AclBearerERNS1_5MakerE +Security:single module:__ZN8Security12KeychainCore6Access10editAccessERNS_10CssmClient9AclBearerEbPKNS_17AccessCredentialsE +Security:single module:__ZN8Security12KeychainCore6Access21addApplicationToRightElPNS0_18TrustedApplicationE +Security:single module:__ZN8Security12KeychainCore6Access15copyOwnerAndAclERP24cssm_acl_owner_prototypeRmRP19cssm_acl_entry_info +Security:single module:__ZNK8Security12KeychainCore6Access17promptDescriptionEv +Security:single module:__ZN8Security12KeychainCore6Access3addEPNS0_3ACLE +Security:single module:__ZN8Security12KeychainCore6Access8addOwnerEPNS0_3ACLE +Security:single module:__ZN8Security12KeychainCore6Access7compileERK24cssm_acl_owner_prototypemPK19cssm_acl_entry_info +Security:single module:__ZN8Security12KeychainCore6Access5MakerC2ERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore6Access5MakerC1ERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore6Access5MakerC4ERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore6Access5Maker12initialOwnerERNS_22ResourceControlContextEPKNS_17AccessCredentialsE +Security:single module:__ZN8Security12KeychainCore6Access5Maker4credEv +Security:single module:__ZN8Security12KeychainCore18CertificateRequestC2Ei +Security:single module:__ZN8Security12KeychainCore18CertificateRequestC1Ei +Security:single module:__ZN8Security12KeychainCore18CertificateRequestC4Ei +Security:single module:__ZN8Security12KeychainCore18CertificateRequestD2Ev +Security:single module:__ZN8Security12KeychainCore18CertificateRequestD1Ev +Security:single module:__ZN8Security12KeychainCore18CertificateRequestD0Ev +Security:single module:__ZN8Security12KeychainCore18CertificateRequestD4Ev +Security:single module:__ZN8Security12KeychainCore7KeyItemC2ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore7KeyItemC1ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore7KeyItemC4ERKNS0_8KeychainERKNS0_10PrimaryKeyERKNS_10CssmClient14DbUniqueRecordE +Security:single module:__ZN8Security12KeychainCore7KeyItemC2ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore7KeyItemC1ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore7KeyItemC4ERKNS0_8KeychainERKNS0_10PrimaryKeyE +Security:single module:__ZN8Security12KeychainCore7KeyItemC2ERS1_ +Security:single module:__ZN8Security12KeychainCore7KeyItemC1ERS1_ +Security:single module:__ZN8Security12KeychainCore7KeyItemC4ERS1_ +Security:single module:__ZN8Security12KeychainCore7KeyItemC2ERKNS_10CssmClient3KeyE +Security:single module:__ZN8Security12KeychainCore7KeyItemC1ERKNS_10CssmClient3KeyE +Security:single module:__ZN8Security12KeychainCore7KeyItemC4ERKNS_10CssmClient3KeyE +Security:single module:__ZN8Security12KeychainCore7KeyItemD2Ev +Security:single module:__ZN8Security12KeychainCore7KeyItemD1Ev +Security:single module:__ZN8Security12KeychainCore7KeyItemD0Ev +Security:single module:__ZN8Security12KeychainCore7KeyItemD4Ev +Security:single module:__ZN8Security12KeychainCore7KeyItem6updateEv +Security:single module:__ZN8Security12KeychainCore7KeyItem6copyToERKNS0_8KeychainEPNS0_6AccessE +Security:single module:__ZN8Security12KeychainCore7KeyItem9didModifyEv +Security:single module:__ZN8Security12KeychainCore7KeyItem3addERNS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore7KeyItem16ssDbUniqueRecordEv +Security:single module:__ZN8Security12KeychainCore7KeyItem3keyEv +Security:single module:__ZN8Security12KeychainCore7KeyItem3cspEv +Security:single module:__ZN8Security12KeychainCore7KeyItem19algorithmIdentifierEv +Security:single module:__ZN8Security12KeychainCore7KeyItem14strengthInBitsEPK30cssm_x509_algorithm_identifier +Security:single module:__ZN8Security12KeychainCore7KeyItem14getCredentialsElm +Security:single module:__ZN8Security12KeychainCore7KeyItem10createPairENS0_8KeychainEmmymmmmNS0_10SecPointerINS0_6AccessEEERNS3_IS1_EES7_ +Security:single module:__ZN8Security12KeychainCore7KeyItem10importPairENS0_8KeychainERK8cssm_keyS5_NS0_10SecPointerINS0_6AccessEEERNS6_IS1_EESA_ +Security:single module:__ZN8Security12KeychainCore7KeyItem8generateENS0_8KeychainEmmymmNS0_10SecPointerINS0_6AccessEEE +Security:single module:__Z10cfKeychainP20OpaqueSecKeychainRef +Security:single module:__Z7convertRKN8Security12KeychainCore10SecPointerINS0_11CertificateEEE +Security:single module:__ZN8Security12KeychainCore5Trust10cssmResultEv +Security:single module:__ZN8Security12KeychainCore5Trust13buildEvidenceERPK9__CFArrayRPNS_14TPEvidenceInfoE +Security:single module:__ZN8Security12KeychainCore5TrustC2EPKvS3_ +Security:single module:__ZN8Security12KeychainCore5TrustD0Ev +Security:single module:__ZN8Security12KeychainCore5TrustD2Ev +Security:single module:__ZNK8Security12KeychainCore5Trust14keychainByDLDbERK17cssm_dl_db_handle +Security:single module:__ZN8Security12KeychainCore12PathDatabaseC1EPKc +Security:single module:__ZN8Security12KeychainCore12PathDatabaseC2EPKc +Security:single module:__ZN8Security12KeychainCore12PathDatabaseC4EPKc +Security:single module:__ZN8Security12KeychainCore18TrustedApplication11makeSubjectERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore18TrustedApplication13calcSignatureEPKcRNS_13CssmOwnedDataE +Security:single module:__ZN8Security12KeychainCore18TrustedApplication13sameSignatureEPKc +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC1ERKNS_8CssmDataES4_ +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC1ERKNS_9TypedListE +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC1Ev +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC2EPKc +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC2ERKNS_8CssmDataES4_ +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC2ERKNS_9TypedListE +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC2Ev +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC4ERKNS_8CssmDataES4_ +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC4ERKNS_9TypedListE +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationC4Ev +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationD0Ev +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationD1Ev +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationD2Ev +Security:single module:__ZN8Security12KeychainCore18TrustedApplicationD4Ev +Security:single module:__ZN8Security10CssmClient20TPBuildVerifyContextC2EmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient6TPImpl3useERNS0_2CLE +Security:single module:__ZN8Security10CssmClient6TPImpl3useERNS0_3CSPE +Security:single module:__ZN8Security10CssmClient6TPImpl6usedCLEv +Security:single module:__ZN8Security10CssmClient6TPImpl7usedCSPEv +Security:single module:__ZN8Security10CssmClient6TPImplC1ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient6TPImplC2ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient6TPImplC2ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient6TPImplC4ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient6TPImplD1Ev +Security:single module:__ZN8Security10CssmClient6TPImplD2Ev +Security:single module:__ZN8Security10CssmClient14BuildCertGroupC1EmmmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14BuildCertGroupC2EmmmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient14BuildCertGroupC4EmmmRNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient6CLImplC1ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient6CLImplC2ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient6CLImplC2ERKNS_4GuidE +Security:single module:__ZN8Security10CssmClient6CLImplC4ERKNS0_6ModuleE +Security:single module:__ZN8Security10CssmClient6CLImplD1Ev +Security:single module:__ZN8Security10CssmClient6CLImplD2Ev +Security:single module:__ZN8Security14TPEvidenceInfo7destroyERNS_13CssmAllocatorE +Security:single module:__ZN8Security18EncodedCertificateC1EmmPK9cssm_data +Security:single module:__ZN8Security18EncodedCertificateC2EmmPK9cssm_data +Security:single module:__ZN8Security18EncodedCertificateC4EmmPK9cssm_data +Security:single module:__ZN8Security9CertGroupC2Emmm +Security:single module:_SecACLGetTypeID +Security:single module:_SecACLCreateFromSimpleContents +Security:single module:_SecACLRemove +Security:single module:__Z7convertRKN8Security12KeychainCore10SecPointerINS0_18TrustedApplicationEEE +Security:single module:_SecACLCopySimpleContents +Security:single module:_SecACLSetSimpleContents +Security:single module:__Z15setApplicationsPN8Security12KeychainCore3ACLEPK9__CFArray +Security:single module:_SecACLGetAuthorizations +Security:single module:_SecACLSetAuthorizations +Security:single module:__ZN8Security12KeychainCore3ACLC2ERNS0_6AccessERKNS_12AclEntryInfoERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC1ERNS0_6AccessERKNS_12AclEntryInfoERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC4ERNS0_6AccessERKNS_12AclEntryInfoERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC2ERNS0_6AccessERKNS_17AclOwnerPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC1ERNS0_6AccessERKNS_17AclOwnerPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC4ERNS0_6AccessERKNS_17AclOwnerPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC2ERNS0_6AccessERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC1ERNS0_6AccessERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC4ERNS0_6AccessERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC2ERNS0_6AccessESsRK33cssm_acl_keychain_prompt_selectorRNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC1ERNS0_6AccessESsRK33cssm_acl_keychain_prompt_selectorRNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLC4ERNS0_6AccessESsRK33cssm_acl_keychain_prompt_selectorRNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACLD2Ev +Security:single module:__ZN8Security12KeychainCore3ACLD1Ev +Security:single module:__ZN8Security12KeychainCore3ACLD0Ev +Security:single module:__ZN8Security12KeychainCore3ACLD4Ev +Security:single module:__ZNK8Security12KeychainCore3ACL10authorizesEl +Security:single module:__ZN8Security12KeychainCore3ACL14addApplicationEPNS0_18TrustedApplicationE +Security:single module:__ZN8Security12KeychainCore3ACL6modifyEv +Security:single module:__ZN8Security12KeychainCore3ACL6removeEv +Security:single module:__ZN8Security12KeychainCore3ACL12copyAclEntryERNS_17AclEntryPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACL12copyAclOwnerERNS_17AclOwnerPrototypeERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore3ACL9setAccessERNS_10CssmClient9AclBearerEbPKNS_17AccessCredentialsE +Security:single module:__ZN8Security12KeychainCore3ACL5parseERKNS_9TypedListE +Security:single module:__ZN8Security12KeychainCore3ACL11parsePromptERKNS_9TypedListE +Security:single module:__ZN8Security12KeychainCore3ACL11makeSubjectEv +Security:single module:__ZN8Security8cfStringEPK10__CFString +Security:single module:__ZN8Security12KeychainCore10TrustStore23getCssmRootCertificatesERNS_9CertGroupE +Security:single module:__ZN8Security12KeychainCore10TrustStore6assignEPNS0_11CertificateEPNS0_6PolicyE18SecTrustResultType +Security:single module:__ZN8Security12KeychainCore10TrustStoreC2ERNS_13CssmAllocatorE +Security:single module:__ZN8Security12KeychainCore10TrustStoreD0Ev +Security:single module:__ZN8Security12KeychainCore10TrustStoreD1Ev +Security:single module:__ZN8Security12KeychainCore10TrustStoreD2Ev +Security:single module:__ZN8Security12KeychainCore10TrustStoreD4Ev +Security:single module:__ZN8Security10CssmClient10AclFactory18AnyResourceContextC1EPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient10AclFactory18AnyResourceContextC2EPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient10AclFactory18AnyResourceContextC4EPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient10AclFactory19KeychainCredentialsD0Ev +Security:single module:__ZN8Security10CssmClient10AclFactory19KeychainCredentialsD1Ev +Security:single module:__ZN8Security10CssmClient10AclFactory19KeychainCredentialsD2Ev +Security:single module:__ZN8Security10CssmClient10AclFactory19KeychainCredentialsD4Ev +Security:single module:__ZN8Security10CssmClient10AclFactory25PasswordChangeCredentialsC1ERKNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient10AclFactory25PasswordChangeCredentialsC2ERKNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient10AclFactory25PasswordChangeCredentialsC4ERKNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient10AclFactory27PassphraseUnlockCredentialsC1ERKNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient10AclFactory27PassphraseUnlockCredentialsC2ERKNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient10AclFactory27PassphraseUnlockCredentialsC4ERKNS_8CssmDataERNS_13CssmAllocatorE +Security:single module:__ZN8Security10CssmClient10AclFactoryC2Ev +Security:single module:__ZN8Security10CssmClient10AclFactoryD0Ev +Security:single module:__ZN8Security10CssmClient10AclFactoryD1Ev +Security:single module:__ZN8Security10CssmClient10AclFactoryD2Ev +Security:single module:__ZN8Security10CssmClient10AclFactoryD4Ev +Security:single module:__ZN8Security10CssmClient7StaticsC2Ev +Security:single module:__ZN8Security10CssmClient9AclBearer6addAclERKNS_13AclEntryInputEPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient9AclBearer9changeAclEmRKNS_13AclEntryInputEPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient9AclBearer9deleteAclEPKcPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient9AclBearer9deleteAclEmPK23cssm_access_credentials +Security:single module:__ZN8Security10CssmClient9AclBearerD0Ev +Security:single module:__ZN8Security10CssmClient9AclBearerD1Ev +Security:single module:__ZNK8Security10CssmClient10AclFactory10unlockCredEv +Security:single module:__ZNK8Security10CssmClient10AclFactory8nullCredEv +Security:single module:__ZN8Security12KeychainCore13UserTrustItemC2EPNS0_11CertificateEPNS0_6PolicyERKNS1_9TrustDataE +Security:single module:__ZN8Security12KeychainCore13UserTrustItemC1EPNS0_11CertificateEPNS0_6PolicyERKNS1_9TrustDataE +Security:single module:__ZN8Security12KeychainCore13UserTrustItemC4EPNS0_11CertificateEPNS0_6PolicyERKNS1_9TrustDataE +Security:single module:__ZN8Security12KeychainCore13UserTrustItemD2Ev +Security:single module:__ZN8Security12KeychainCore13UserTrustItemD1Ev +Security:single module:__ZN8Security12KeychainCore13UserTrustItemD0Ev +Security:single module:__ZN8Security12KeychainCore13UserTrustItemD4Ev +Security:single module:__ZN8Security12KeychainCore13UserTrustItem5trustEv +Security:single module:__ZN8Security12KeychainCore13UserTrustItem3addERNS0_8KeychainE +Security:single module:__ZN8Security12KeychainCore13UserTrustItem18populateAttributesEv +Security:single module:__ZN8Security10IPPlusPlus7FdMover7ElementnwEmm +Security:single module:__ZN8Security10IPPlusPlus7FdMover7ElementdlEPvm +Security:single module:__ZN8Security10IPPlusPlus7FdMover7ElementC2Eii +Security:single module:__ZN8Security10IPPlusPlus7FdMover7ElementC1Eii +Security:single module:__ZN8Security10IPPlusPlus7FdMover7ElementC4Eii +Security:single module:__ZN8Security10IPPlusPlus7FdMover7MessageC2EPKvm +Security:single module:__ZN8Security10IPPlusPlus7FdMover7MessageC1EPKvm +Security:single module:__ZN8Security10IPPlusPlus7FdMover7MessageC4EPKvm +Security:single module:__ZN8Security10IPPlusPlus7FdMover7Message3setEPNS1_7ElementE +Security:single module:__ZN8Security10IPPlusPlus7FdMover4sendEPKvmRKSt6vectorINS_12UnixPlusPlus8FileDescESaIS6_EE +Security:single module:__ZN8Security10IPPlusPlus7FdMover7receiveEPvmRSt6vectorINS_12UnixPlusPlus8FileDescESaIS5_EE +Security:single module:_AuthorizationBindPrivilegedPort +Security:single module:__Z11startServerv +Security:single module:___authorization_bind +Security:single module:__ZN8Security12UnixPlusPlus6UnixDb4openEPKcii6DBTYPE +Security:single module:__ZN8Security12UnixPlusPlus6UnixDb4openERKSsii6DBTYPE +Security:single module:__ZN8Security12UnixPlusPlus6UnixDb5closeEv +Security:single module:__ZN8Security12UnixPlusPlus6UnixDb5eraseERKNS_8CssmDataEi +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC1EPKcii6DBTYPE +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC1ERKSsii6DBTYPE +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC1Ev +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC2EPKcii6DBTYPE +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC2ERKSsii6DBTYPE +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC2Ev +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC4EPKcii6DBTYPE +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC4ERKSsii6DBTYPE +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbC4Ev +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbD0Ev +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbD1Ev +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbD2Ev +Security:single module:__ZN8Security12UnixPlusPlus6UnixDbD4Ev +Security:single module:__ZNK8Security12UnixPlusPlus6UnixDb3getERKNS_8CssmDataERNS_13CssmOwnedDataEi +Security:single module:__ZNK8Security12UnixPlusPlus6UnixDb4nextERNS_8CssmDataES3_i +Security:single module:_SecKeychainAddIToolsPassword +Security:single module:_createAccess +Security:single module:_CopyTrustedAppListFromBundle +Security:single module:__Unwind_FindEnclosingFunction +Security:single module:__Unwind_ForcedUnwind +Security:single module:__Unwind_ForcedUnwind_Phase2 +Security:single module:__Unwind_GetDataRelBase +Security:single module:__Unwind_GetGR +Security:single module:__Unwind_GetTextRelBase +Security:single module:___frame_state_for +Security:single module:_execute_stack_op +Security:single module:__ZN10__cxxabiv117__class_type_infoD0Ev +Security:single module:__ZN10__cxxabiv117__class_type_infoD1Ev +Security:single module:__ZN10__cxxabiv117__class_type_infoD2Ev +Security:single module:__ZN10__cxxabiv117__class_type_infoD4Ev +Security:single module:__ZN10__cxxabiv120__si_class_type_infoD0Ev +Security:single module:__ZN10__cxxabiv120__si_class_type_infoD1Ev +Security:single module:__ZN10__cxxabiv120__si_class_type_infoD2Ev +Security:single module:__ZN10__cxxabiv120__si_class_type_infoD4Ev +Security:single module:__ZN10__cxxabiv121__vmi_class_type_infoD0Ev +Security:single module:__ZN10__cxxabiv121__vmi_class_type_infoD1Ev +Security:single module:__ZN10__cxxabiv121__vmi_class_type_infoD2Ev +Security:single module:__ZN10__cxxabiv121__vmi_class_type_infoD4Ev +Security:single module:__ZNK10__cxxabiv117__class_type_info20__do_find_public_srcEiPKvPKS0_S2_ +Security:single module:__ZNK10__cxxabiv120__si_class_type_info20__do_find_public_srcEiPKvPKNS_17__class_type_infoES2_ +Security:single module:__ZNK10__cxxabiv121__vmi_class_type_info11__do_upcastEPKNS_17__class_type_infoEPKvRNS1_15__upcast_resultE +Security:single module:__ZNK10__cxxabiv121__vmi_class_type_info20__do_find_public_srcEiPKvPKNS_17__class_type_infoES2_ +Security:single module:__ZNKSt9type_info10__do_catchEPKS_PPvj +Security:single module:__ZNKSt9type_info11__do_upcastEPKN10__cxxabiv117__class_type_infoEPPv +Security:single module:__ZNKSt9type_info15__is_function_pEv +Security:single module:__ZNSt10bad_typeidD0Ev +Security:single module:__ZNSt10bad_typeidD1Ev +Security:single module:__ZNSt10bad_typeidD2Ev +Security:single module:__ZNSt10bad_typeidD4Ev +Security:single module:__ZNSt8bad_castD0Ev +Security:single module:__ZNSt8bad_castD1Ev +Security:single module:__ZNSt8bad_castD2Ev +Security:single module:__ZNSt8bad_castD4Ev +Security:single module:__ZNSt9type_infoD0Ev +Security:single module:__ZNSt9type_infoD1Ev +Security:single module:__ZNSt9type_infoD2Ev +Security:single module:__ZNSt9type_infoD4Ev +Security:single module:___cxa_bad_cast +Security:single module:___cxa_bad_typeid +Security:single module:___cxa_pure_virtual +Security:single module:__Z20check_exception_specP16lsda_header_infoPKSt9type_infoPvi +Security:single module:___cxa_call_unexpected +Security:single module:__ZSt18uncaught_exceptionv +Security:single module:__ZNKSaIcE7addressERKc +Security:single module:__ZNKSaIcE7addressERc +Security:single module:__ZNKSaIcE8max_sizeEv +Security:single module:__ZNKSaIwE7addressERKw +Security:single module:__ZNKSaIwE7addressERw +Security:single module:__ZNKSaIwE8max_sizeEv +Security:single module:__ZNSaIcE10deallocateEPcm +Security:single module:__ZNSaIcE7destroyEPc +Security:single module:__ZNSaIcE8allocateEmPKv +Security:single module:__ZNSaIcE9constructEPcRKc +Security:single module:__ZNSaIcEC1ERKS_ +Security:single module:__ZNSaIcEC1Ev +Security:single module:__ZNSaIcEC2ERKS_ +Security:single module:__ZNSaIcEC2Ev +Security:single module:__ZNSaIcEC4ERKS_ +Security:single module:__ZNSaIcEC4Ev +Security:single module:__ZNSaIcED1Ev +Security:single module:__ZNSaIcED2Ev +Security:single module:__ZNSaIcED4Ev +Security:single module:__ZNSaIwE10deallocateEPwm +Security:single module:__ZNSaIwE7destroyEPw +Security:single module:__ZNSaIwE8allocateEmPKv +Security:single module:__ZNSaIwE9constructEPwRKw +Security:single module:__ZNSaIwEC1ERKS_ +Security:single module:__ZNSaIwEC1Ev +Security:single module:__ZNSaIwEC2ERKS_ +Security:single module:__ZNSaIwEC2Ev +Security:single module:__ZNSaIwEC4ERKS_ +Security:single module:__ZNSaIwEC4Ev +Security:single module:__ZNSaIwED1Ev +Security:single module:__ZNSaIwED2Ev +Security:single module:__ZNSaIwED4Ev +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE10reallocateEPvmm +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE11_S_round_upEm +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE17_S_freelist_indexEm +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE5_LockC1Ev +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE5_LockC2Ev +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE5_LockD1Ev +Security:single module:__ZNSt24__default_alloc_templateILb1ELi0EE5_LockD2Ev +Security:single module:__ZSt21__throw_bad_exceptionv +Security:single module:__ZSt17__throw_bad_allocv +Security:single module:__ZSt16__throw_bad_castv +Security:single module:__ZSt18__throw_bad_typeidv +Security:single module:__ZSt19__throw_logic_errorPKc +Security:single module:__ZSt20__throw_domain_errorPKc +Security:single module:__ZSt24__throw_invalid_argumentPKc +Security:single module:__ZSt20__throw_length_errorPKc +Security:single module:__ZSt20__throw_out_of_rangePKc +Security:single module:__ZSt21__throw_runtime_errorPKc +Security:single module:__ZSt19__throw_range_errorPKc +Security:single module:__ZSt22__throw_overflow_errorPKc +Security:single module:__ZSt23__throw_underflow_errorPKc +Security:single module:__ZN10__cxxabiv111__terminateEPFvvE +Security:single module:__ZSt9terminatev +Security:single module:__ZN10__cxxabiv112__unexpectedEPFvvE +Security:single module:__ZSt10unexpectedv +Security:single module:__ZSt13set_terminatePFvvE +Security:single module:__ZSt14set_unexpectedPFvvE +Security:single module:__ZN9__gnu_cxxeqIPKcSsEEbRKNS_17__normal_iteratorIT_T0_EES8_ +Security:single module:__ZN9__gnu_cxxeqIPcSsEEbRKNS_17__normal_iteratorIT_T0_EES7_ +Security:single module:__ZNKSs12find_last_ofEPKcm +Security:single module:__ZNKSs12find_last_ofEPKcmm +Security:single module:__ZNKSs12find_last_ofERKSsm +Security:single module:__ZNKSs12find_last_ofEcm +Security:single module:__ZNKSs13find_first_ofEPKcm +Security:single module:__ZNKSs13find_first_ofEPKcmm +Security:single module:__ZNKSs13find_first_ofERKSsm +Security:single module:__ZNKSs13find_first_ofEcm +Security:single module:__ZNKSs16find_last_not_ofEPKcm +Security:single module:__ZNKSs16find_last_not_ofEPKcmm +Security:single module:__ZNKSs16find_last_not_ofERKSsm +Security:single module:__ZNKSs16find_last_not_ofEcm +Security:single module:__ZNKSs17find_first_not_ofEPKcm +Security:single module:__ZNKSs17find_first_not_ofEPKcmm +Security:single module:__ZNKSs17find_first_not_ofERKSsm +Security:single module:__ZNKSs17find_first_not_ofEcm +Security:single module:__ZNKSs2atEm +Security:single module:__ZNKSs3endEv +Security:single module:__ZNKSs4_Rep12_M_is_leakedEv +Security:single module:__ZNKSs4_Rep12_M_is_sharedEv +Security:single module:__ZNKSs4copyEPcmm +Security:single module:__ZNKSs4dataEv +Security:single module:__ZNKSs4findEPKcm +Security:single module:__ZNKSs4findERKSsm +Security:single module:__ZNKSs4findEcm +Security:single module:__ZNKSs4rendEv +Security:single module:__ZNKSs4sizeEv +Security:single module:__ZNKSs5beginEv +Security:single module:__ZNKSs5c_strEv +Security:single module:__ZNKSs5emptyEv +Security:single module:__ZNKSs5rfindEPKcm +Security:single module:__ZNKSs5rfindEPKcmm +Security:single module:__ZNKSs5rfindERKSsm +Security:single module:__ZNKSs6_M_repEv +Security:single module:__ZNKSs6lengthEv +Security:single module:__ZNKSs6rbeginEv +Security:single module:__ZNKSs6substrEmm +Security:single module:__ZNKSs7_M_dataEv +Security:single module:__ZNKSs7compareEPKc +Security:single module:__ZNKSs7compareEmmPKc +Security:single module:__ZNKSs7compareEmmPKcm +Security:single module:__ZNKSs7compareEmmRKSs +Security:single module:__ZNKSs7compareEmmRKSsmm +Security:single module:__ZNKSs8capacityEv +Security:single module:__ZNKSs8max_sizeEv +Security:single module:__ZNKSsixEm +Security:single module:__ZNSs10_M_replaceIN9__gnu_cxx17__normal_iteratorIPKcSsEEEERSsNS1_IPcSsEES7_T_S8_St18input_iterator_tag +Security:single module:__ZNSs10_M_replaceIN9__gnu_cxx17__normal_iteratorIPcSsEEEERSsS3_S3_T_S5_St18input_iterator_tag +Security:single module:__ZNSs10_M_replaceIPKcEERSsN9__gnu_cxx17__normal_iteratorIPcSsEES6_T_S7_St18input_iterator_tag +Security:single module:__ZNSs10_M_replaceIPcEERSsN9__gnu_cxx17__normal_iteratorIS0_SsEES4_T_S5_St18input_iterator_tag +Security:single module:__ZNSs12_Alloc_hiderC1EPcRKSaIcE +Security:single module:__ZNSs12_Alloc_hiderC2EPcRKSaIcE +Security:single module:__ZNSs12_M_leak_hardEv +Security:single module:__ZNSs12_S_constructEmcRKSaIcE +Security:single module:__ZNSs12_S_constructIN9__gnu_cxx17__normal_iteratorIPKcSsEEEEPcT_S6_RKSaIcESt20forward_iterator_tag +Security:single module:__ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag +Security:single module:__ZNSs12_S_empty_repEv +Security:single module:__ZNSs13_S_copy_charsEPcN9__gnu_cxx17__normal_iteratorIPKcSsEES4_ +Security:single module:__ZNSs13_S_copy_charsEPcPKcS1_ +Security:single module:__ZNSs13_S_copy_charsEPcS_S_ +Security:single module:__ZNSs15_M_replace_safeIN9__gnu_cxx17__normal_iteratorIPKcSsEEEERSsNS1_IPcSsEES7_T_S8_ +Security:single module:__ZNSs15_M_replace_safeIPcEERSsN9__gnu_cxx17__normal_iteratorIS0_SsEES4_T_S5_ +Security:single module:__ZNSs2atEm +Security:single module:__ZNSs3endEv +Security:single module:__ZNSs4_Rep10_M_disposeERKSaIcE +Security:single module:__ZNSs4_Rep10_M_refcopyEv +Security:single module:__ZNSs4_Rep10_M_refdataEv +Security:single module:__ZNSs4_Rep13_M_set_leakedEv +Security:single module:__ZNSs4_Rep15_M_set_sharableEv +Security:single module:__ZNSs4_RepixEm +Security:single module:__ZNSs4rendEv +Security:single module:__ZNSs4swapERSs +Security:single module:__ZNSs5beginEv +Security:single module:__ZNSs5clearEv +Security:single module:__ZNSs5eraseEN9__gnu_cxx17__normal_iteratorIPcSsEE +Security:single module:__ZNSs5eraseEN9__gnu_cxx17__normal_iteratorIPcSsEES2_ +Security:single module:__ZNSs5eraseEmm +Security:single module:__ZNSs6appendEPKc +Security:single module:__ZNSs6appendEPKcm +Security:single module:__ZNSs6appendERKSsmm +Security:single module:__ZNSs6appendEmc +Security:single module:__ZNSs6assignEPKc +Security:single module:__ZNSs6assignERKSsmm +Security:single module:__ZNSs6assignEmc +Security:single module:__ZNSs6insertEN9__gnu_cxx17__normal_iteratorIPcSsEEc +Security:single module:__ZNSs6insertEN9__gnu_cxx17__normal_iteratorIPcSsEEmc +Security:single module:__ZNSs6insertEmPKc +Security:single module:__ZNSs6insertEmPKcm +Security:single module:__ZNSs6insertEmRKSs +Security:single module:__ZNSs6insertEmRKSsmm +Security:single module:__ZNSs6insertEmmc +Security:single module:__ZNSs6rbeginEv +Security:single module:__ZNSs6resizeEm +Security:single module:__ZNSs6resizeEmc +Security:single module:__ZNSs7_M_dataEPc +Security:single module:__ZNSs7_M_leakEv +Security:single module:__ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_NS0_IPKcSsEES5_ +Security:single module:__ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_PKc +Security:single module:__ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_PKcm +Security:single module:__ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_RKSs +Security:single module:__ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_S1_S1_ +Security:single module:__ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_S2_S2_ +Security:single module:__ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_mc +Security:single module:__ZNSs7replaceEmmPKc +Security:single module:__ZNSs7replaceEmmRKSs +Security:single module:__ZNSs7replaceEmmRKSsmm +Security:single module:__ZNSs7replaceEmmmc +Security:single module:__ZNSs9push_backEc +Security:single module:__ZNSsC1ERKSaIcE +Security:single module:__ZNSsC1ERKSsmmRKSaIcE +Security:single module:__ZNSsC1EmcRKSaIcE +Security:single module:__ZNSsC1Ev +Security:single module:__ZNSsC1IN9__gnu_cxx17__normal_iteratorIPKcSsEEEET_S5_RKSaIcE +Security:single module:__ZNSsC1IN9__gnu_cxx17__normal_iteratorIPcSsEEEET_S4_RKSaIcE +Security:single module:__ZNSsC1IPKcEET_S2_RKSaIcE +Security:single module:__ZNSsC1IPcEET_S1_RKSaIcE +Security:single module:__ZNSsC2EPKcRKSaIcE +Security:single module:__ZNSsC2EPKcmRKSaIcE +Security:single module:__ZNSsC2ERKSaIcE +Security:single module:__ZNSsC2ERKSs +Security:single module:__ZNSsC2ERKSsmm +Security:single module:__ZNSsC2ERKSsmmRKSaIcE +Security:single module:__ZNSsC2EmcRKSaIcE +Security:single module:__ZNSsC2Ev +Security:single module:__ZNSsC2IN9__gnu_cxx17__normal_iteratorIPKcSsEEEET_S5_RKSaIcE +Security:single module:__ZNSsC2IN9__gnu_cxx17__normal_iteratorIPcSsEEEET_S4_RKSaIcE +Security:single module:__ZNSsC2IPKcEET_S2_RKSaIcE +Security:single module:__ZNSsC2IPcEET_S1_RKSaIcE +Security:single module:__ZNSsC4ERKSaIcE +Security:single module:__ZNSsC4ERKSsmmRKSaIcE +Security:single module:__ZNSsC4EmcRKSaIcE +Security:single module:__ZNSsC4IN9__gnu_cxx17__normal_iteratorIPKcSsEEEET_S5_RKSaIcE +Security:single module:__ZNSsC4IN9__gnu_cxx17__normal_iteratorIPcSsEEEET_S4_RKSaIcE +Security:single module:__ZNSsC4IPKcEET_S2_RKSaIcE +Security:single module:__ZNSsC4IPcEET_S1_RKSaIcE +Security:single module:__ZNSsD1Ev +Security:single module:__ZNSsD2Ev +Security:single module:__ZNSsD4Ev +Security:single module:__ZNSsaSEPKc +Security:single module:__ZNSsaSERKSs +Security:single module:__ZNSsaSEc +Security:single module:__ZNSsixEm +Security:single module:__ZNSspLEPKc +Security:single module:__ZNSspLERKSs +Security:single module:__ZNSspLEc +Security:single module:__ZSt13__destroy_auxIPSsEvT_S1_12__false_type +Security:single module:__ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_ES3_RKS6_ +Security:single module:___cxa_rethrow +Security:single module:__ZSt15set_new_handlerPFvvE +Security:single module:__ZNSt9bad_allocD2Ev +Security:single module:__ZNSt9bad_allocD1Ev +Security:single module:__ZNSt9bad_allocD0Ev +Security:single module:__ZNSt9bad_allocD4Ev +Security:single module:__ZNKSt9type_info6beforeERKS_ +Security:single module:__ZN10__cxxabiv123__fundamental_type_infoD2Ev +Security:single module:__ZN10__cxxabiv123__fundamental_type_infoD1Ev +Security:single module:__ZN10__cxxabiv123__fundamental_type_infoD0Ev +Security:single module:__ZN10__cxxabiv123__fundamental_type_infoD4Ev +Security:single module:__ZN10__cxxabiv117__array_type_infoD2Ev +Security:single module:__ZN10__cxxabiv117__array_type_infoD1Ev +Security:single module:__ZN10__cxxabiv117__array_type_infoD0Ev +Security:single module:__ZN10__cxxabiv117__array_type_infoD4Ev +Security:single module:__ZN10__cxxabiv120__function_type_infoD2Ev +Security:single module:__ZN10__cxxabiv120__function_type_infoD1Ev +Security:single module:__ZN10__cxxabiv120__function_type_infoD0Ev +Security:single module:__ZN10__cxxabiv120__function_type_infoD4Ev +Security:single module:__ZN10__cxxabiv116__enum_type_infoD2Ev +Security:single module:__ZN10__cxxabiv116__enum_type_infoD1Ev +Security:single module:__ZN10__cxxabiv116__enum_type_infoD0Ev +Security:single module:__ZN10__cxxabiv116__enum_type_infoD4Ev +Security:single module:__ZN10__cxxabiv117__pbase_type_infoD2Ev +Security:single module:__ZN10__cxxabiv117__pbase_type_infoD1Ev +Security:single module:__ZN10__cxxabiv117__pbase_type_infoD0Ev +Security:single module:__ZN10__cxxabiv117__pbase_type_infoD4Ev +Security:single module:__ZN10__cxxabiv119__pointer_type_infoD2Ev +Security:single module:__ZN10__cxxabiv119__pointer_type_infoD1Ev +Security:single module:__ZN10__cxxabiv119__pointer_type_infoD0Ev +Security:single module:__ZN10__cxxabiv119__pointer_type_infoD4Ev +Security:single module:__ZN10__cxxabiv129__pointer_to_member_type_infoD2Ev +Security:single module:__ZN10__cxxabiv129__pointer_to_member_type_infoD1Ev +Security:single module:__ZN10__cxxabiv129__pointer_to_member_type_infoD0Ev +Security:single module:__ZN10__cxxabiv129__pointer_to_member_type_infoD4Ev +Security:single module:__ZNK10__cxxabiv119__pointer_type_info14__is_pointer_pEv +Security:single module:__ZNK10__cxxabiv120__function_type_info15__is_function_pEv +Security:single module:__ZNK10__cxxabiv117__pbase_type_info10__do_catchEPKSt9type_infoPPvj +Security:single module:__ZNK10__cxxabiv119__pointer_type_info15__pointer_catchEPKNS_17__pbase_type_infoEPPvj +Security:single module:__ZNK10__cxxabiv129__pointer_to_member_type_info15__pointer_catchEPKNS_17__pbase_type_infoEPPvj +Security:single module:___isctype +Security:single module:_cp_demangle +Security:single module:_demangle_CV_qualifiers +Security:single module:_demangle_array_type +Security:single module:_demangle_bare_function_type +Security:single module:_demangle_call_offset +Security:single module:_demangle_char +Security:single module:_demangle_ctor_dtor_name +Security:single module:_demangle_discriminator +Security:single module:_demangle_encoding +Security:single module:_demangle_expr_primary +Security:single module:_demangle_expression +Security:single module:_demangle_function_type +Security:single module:_demangle_literal +Security:single module:_demangle_local_name +Security:single module:_demangle_mangled_name +Security:single module:_demangle_nested_name +Security:single module:_demangle_nv_offset +Security:single module:_demangle_operator_name +Security:single module:_demangle_prefix +Security:single module:_demangle_scope_expression +Security:single module:_demangle_special_name +Security:single module:_demangle_substitution +Security:single module:_demangle_template_arg +Security:single module:_demangle_template_args +Security:single module:_demangle_template_param +Security:single module:_demangle_v_offset +Security:single module:_int_to_dyn_string +Security:single module:_push_template_arg_list +Security:single module:_result_add_separated_char +Security:single module:_result_get_caret +Security:single module:_result_previous_char_is_space +Security:single module:_result_set_caret +Security:single module:_result_shift_caret +Security:single module:_substitution_get +Security:single module:_template_arg_list_add_arg +Security:single module:_template_arg_list_delete +Security:single module:_template_arg_list_get_arg +Security:single module:_template_arg_list_new +Security:single module:__ZNKSt9exception4whatEv +Security:single module:__ZNSt13bad_exceptionD0Ev +Security:single module:__ZNSt13bad_exceptionD1Ev +Security:single module:__ZNSt13bad_exceptionD2Ev +Security:single module:__ZNSt13bad_exceptionD4Ev +Security:single module:__ZNSt9exceptionD0Ev +Security:single module:__ZNSt9exceptionD1Ev +Security:single module:__ZNSt11logic_errorC2ERKSs +Security:single module:__ZNSt11logic_errorC1ERKSs +Security:single module:__ZNSt11logic_errorC4ERKSs +Security:single module:__ZNSt11logic_errorD2Ev +Security:single module:__ZNSt11logic_errorD1Ev +Security:single module:__ZNSt11logic_errorD0Ev +Security:single module:__ZNSt11logic_errorD4Ev +Security:single module:__ZNKSt11logic_error4whatEv +Security:single module:__ZNSt12domain_errorC2ERKSs +Security:single module:__ZNSt12domain_errorC1ERKSs +Security:single module:__ZNSt12domain_errorC4ERKSs +Security:single module:__ZNSt16invalid_argumentC2ERKSs +Security:single module:__ZNSt16invalid_argumentC1ERKSs +Security:single module:__ZNSt16invalid_argumentC4ERKSs +Security:single module:__ZNSt12length_errorC2ERKSs +Security:single module:__ZNSt12length_errorC1ERKSs +Security:single module:__ZNSt12length_errorC4ERKSs +Security:single module:__ZNSt12out_of_rangeC2ERKSs +Security:single module:__ZNSt12out_of_rangeC1ERKSs +Security:single module:__ZNSt12out_of_rangeC4ERKSs +Security:single module:__ZNSt13runtime_errorC2ERKSs +Security:single module:__ZNSt13runtime_errorC1ERKSs +Security:single module:__ZNSt13runtime_errorC4ERKSs +Security:single module:__ZNSt13runtime_errorD2Ev +Security:single module:__ZNSt13runtime_errorD1Ev +Security:single module:__ZNSt13runtime_errorD0Ev +Security:single module:__ZNSt13runtime_errorD4Ev +Security:single module:__ZNKSt13runtime_error4whatEv +Security:single module:__ZNSt11range_errorC2ERKSs +Security:single module:__ZNSt11range_errorC1ERKSs +Security:single module:__ZNSt11range_errorC4ERKSs +Security:single module:__ZNSt14overflow_errorC2ERKSs +Security:single module:__ZNSt14overflow_errorC1ERKSs +Security:single module:__ZNSt14overflow_errorC4ERKSs +Security:single module:__ZNSt15underflow_errorC2ERKSs +Security:single module:__ZNSt15underflow_errorC1ERKSs +Security:single module:__ZNSt15underflow_errorC4ERKSs +Security:single module:__ZN11SecNssCoder10encodeItemEPKvPK23sec_ASN1Template_structR9cssm_data +Security:single module:__ZN11SecNssCoderC2Ej +Security:single module:__ZN11SecNssCoderD2Ev +Security:single module:___fixdfdi +Security:single module:___floatdidf +Security:single module:__ZN11AppleFileDLC2Ev +Security:single module:__ZN11AppleFileDLD0Ev +Security:single module:__ZN11AppleFileDLD1Ev +Security:single module:__ZN11AppleFileDLD2Ev +Security:single module:__ZN11AppleFileDLD4Ev +Security:single module:__ZN11AppleX509CLC2Ev +Security:single module:__ZN11AppleX509CLD0Ev +Security:single module:__ZN11AppleX509CLD1Ev +Security:single module:__ZN11AppleX509CLD2Ev +Security:single module:__ZN11AppleX509CLD4Ev +Security:single module:__ZN11CSPDLPluginC2Ev +Security:single module:__ZN11CSPDLPluginD0Ev +Security:single module:__ZN11CSPDLPluginD1Ev +Security:single module:__ZN11CSPDLPluginD2Ev +Security:single module:__ZN11CSPDLPluginD4Ev +Security:single module:__ZN13YarrowContext4initERKN8Security7ContextEb +Security:single module:__ZN13YarrowContext5finalERN8Security8CssmDataE +Security:single module:__ZN13YarrowContextC1ER15AppleCSPSession +Security:single module:__ZN13YarrowContextC2ER15AppleCSPSession +Security:single module:__ZN13YarrowContextC4ER15AppleCSPSession +Security:single module:__ZN13YarrowContextD0Ev +Security:single module:__ZN13YarrowContextD1Ev +Security:single module:__ZN13YarrowContextD2Ev +Security:single module:__ZN13YarrowContextD4Ev +Security:single module:__ZN14AppleCSPPluginC2Ev +Security:single module:__ZN14AppleCSPPluginD0Ev +Security:single module:__ZN14AppleCSPPluginD1Ev +Security:single module:__ZN14AppleCSPPluginD2Ev +Security:single module:__ZN14AppleCSPPluginD4Ev +Security:single module:__ZN15AppleCSPSession10addEntropyEmPKh +Security:single module:__ZN15AppleCSPSession11PassThroughEyRKN8Security7ContextEmPKvPPv +Security:single module:__ZN15AppleCSPSession14getRandomBytesEmPh +Security:single module:__ZN15AppleCSPSession5setupERPN8Security20CSPFullPluginSession10CSPContextERKNS0_7ContextE +Security:single module:__ZN15AppleCSPSessionC2EmR14AppleCSPPluginRK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN15AppleCSPSessionD1Ev +Security:single module:__ZN15AppleCSPSessionD2Ev +Security:single module:__ZN7AppleTPC2Ev +Security:single module:__ZN7AppleTPD0Ev +Security:single module:__ZN7AppleTPD1Ev +Security:single module:__ZN7AppleTPD2Ev +Security:single module:__ZN7AppleTPD4Ev +Security:single module:_getField_Unimplemented +Security:single module:_setFieldUnknownExt +Security:single module:_setField_AlgIdNSS +Security:single module:_setField_ReadOnly +Security:single module:_setField_TimeNSS +Security:single module:_tbsSetCheck +Security:single module:___deregister_frame +Security:single module:___deregister_frame_info +Security:single module:___deregister_frame_info_bases +Security:single module:___register_frame +Security:single module:___register_frame_info +Security:single module:___register_frame_info_bases +Security:single module:___register_frame_info_table +Security:single module:___register_frame_info_table_bases +Security:single module:___register_frame_table +Security:single module:_fde_mixed_encoding_compare +Security:single module:_fde_unencoded_compare +Security:single module:_linear_search_fdes +Security:single module:_live_image_destructor +Security:single module:rest_world +Security:single module:___cxa_dyn_string_append +Security:single module:___cxa_dyn_string_append_cstr +Security:single module:___cxa_dyn_string_copy_cstr +Security:single module:___cxa_dyn_string_eq +Security:single module:___cxa_dyn_string_prepend +Security:single module:___cxa_dyn_string_prepend_cstr +Security:single module:___cxa_dyn_string_release +Security:single module:_NSS_Get_SEC_AnyTemplate +Security:single module:_NSS_Get_SEC_BMPStringTemplate +Security:single module:_NSS_Get_SEC_BooleanTemplate +Security:single module:_NSS_Get_SEC_BitStringTemplate +Security:single module:_NSS_Get_SEC_IA5StringTemplate +Security:single module:_NSS_Get_SEC_GeneralizedTimeTemplate +Security:single module:_NSS_Get_SEC_IntegerTemplate +Security:single module:_NSS_Get_SEC_NullTemplate +Security:single module:_NSS_Get_SEC_ObjectIDTemplate +Security:single module:_NSS_Get_SEC_OctetStringTemplate +Security:single module:_NSS_Get_SEC_PointerToAnyTemplate +Security:single module:_NSS_Get_SEC_PointerToOctetStringTemplate +Security:single module:_NSS_Get_SEC_SetOfAnyTemplate +Security:single module:_NSS_Get_SEC_UTCTimeTemplate +Security:single module:_NSS_Get_SEC_UTF8StringTemplate +Security:single module:_NSS_PutEnv +Security:single module:_PORT_Alloc +Security:single module:_PORT_ArenaGrow +Security:single module:_PORT_ArenaStrdup +Security:single module:_PORT_ArenaUnmark +Security:single module:_PORT_Free +Security:single module:_PORT_GetError +Security:single module:_PORT_Realloc +Security:single module:_PORT_SetError +Security:single module:_PORT_SetUCS2_ASCIIConversionFunction +Security:single module:_PORT_SetUCS2_UTF8ConversionFunction +Security:single module:_PORT_SetUCS4_UTF8ConversionFunction +Security:single module:_PORT_Strdup +Security:single module:_PORT_UCS2_ASCIIConversion +Security:single module:_PORT_UCS2_UTF8Conversion +Security:single module:_PORT_UCS4_UTF8Conversion +Security:single module:_PR_GetError +Security:single module:_PR_GetOSError +Security:single module:_PR_Realloc +Security:single module:_PR_SetError +Security:single module:_PR_getThreadErrInfo +Security:single module:_PR_initThreadKey +Security:single module:_SEC_ASN1DecodeInteger +Security:single module:_SEC_ASN1DecodeItem +Security:single module:_SEC_ASN1DecoderClearFilterProc +Security:single module:_SEC_ASN1DecoderClearNotifyProc +Security:single module:_SEC_ASN1DecoderSetFilterProc +Security:single module:_SEC_ASN1DecoderSetNotifyProc +Security:single module:_sec_asn1d_after_choice +Security:single module:_sec_asn1d_before_choice +Security:single module:_sec_asn1d_during_choice +Security:single module:_sec_asn1d_parse_end_of_contents +Security:single module:_sec_asn1d_parse_more_identifier +Security:single module:_sec_asn1d_uinteger +Security:single module:_SEC_ASN1EncodeInteger +Security:single module:_SEC_ASN1EncodeItem +Security:single module:_SEC_ASN1EncodeUnsignedInteger +Security:single module:_SEC_ASN1EncoderClearNotifyProc +Security:single module:_SEC_ASN1EncoderClearStreaming +Security:single module:_SEC_ASN1EncoderClearTakeFromBuf +Security:single module:_SEC_ASN1EncoderSetNotifyProc +Security:single module:_SEC_ASN1EncoderSetStreaming +Security:single module:_SEC_ASN1EncoderSetTakeFromBuf +Security:single module:_sec_asn1e_allocate_item +Security:single module:_sec_asn1e_integer +Security:single module:_sec_asn1e_which_choice +Security:single module:_sec_asn1e_write_end_of_contents_bytes +Security:single module:___fixunsdfdi +Security:single module:__ZN18AppleX509CLSession15lookupCachedCRLEm +Security:single module:__ZN18AppleX509CLSessionC2EmRN8Security10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN18AppleX509CLSessionD1Ev +Security:single module:__ZN18AppleX509CLSessionD2Ev +Security:single module:__ZN11SSDLSession10DataDeleteEmRK21cssm_db_unique_record +Security:single module:__ZN11SSDLSession10DataInsertEmmPK29cssm_db_record_attribute_dataPKN8Security8CssmDataERP21cssm_db_unique_record +Security:single module:__ZN11SSDLSession10DataModifyEmmR21cssm_db_unique_recordPK29cssm_db_record_attribute_dataPKN8Security8CssmDataEm +Security:single module:__ZN11SSDLSession10GetDbNamesERP14cssm_name_list +Security:single module:__ZN11SSDLSession10GetDbOwnerEmR24cssm_acl_owner_prototype +Security:single module:__ZN11SSDLSession11ChangeDbAclEmRKN8Security17AccessCredentialsERK13cssm_acl_edit +Security:single module:__ZN11SSDLSession11PassThroughEmmPKvPPv +Security:single module:__ZN11SSDLSession12AuthenticateEmmRKN8Security17AccessCredentialsE +Security:single module:__ZN11SSDLSession12FreeNameListER14cssm_name_list +Security:single module:__ZN11SSDLSession13ChangeDbOwnerEmRKN8Security17AccessCredentialsERK24cssm_acl_owner_prototype +Security:single module:__ZN11SSDLSession14CreateRelationEmmPKcmRK29cssm_db_schema_attribute_infomRK25cssm_db_schema_index_info +Security:single module:__ZN11SSDLSession15DestroyRelationEmm +Security:single module:__ZN11SSDLSession19GetDbNameFromHandleEmPPc +Security:single module:__ZN11SSDLSession8DbCreateEPKcPK16cssm_net_addressRK11cssm_dbinfomPK29cssm_resource_control_contextPKvRm +Security:single module:__ZN11SSDLSession8DbDeleteEPKcPK16cssm_net_addressPKN8Security17AccessCredentialsE +Security:single module:__ZN11SSDLSession8GetDbAclEmPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZN11SSDLSessionC2EmR11CSPDLPluginRK12cssm_versionmmmRK12cssm_upcallsRN8Security15DatabaseManagerER14SSCSPDLSession +Security:single module:__ZN11SSDLSessionD1Ev +Security:single module:__ZN11SSDLSessionD2Ev +Security:single module:__ZThn40_N11SSDLSession10DataDeleteEmRK21cssm_db_unique_record +Security:single module:__ZThn40_N11SSDLSession10DataInsertEmmPK29cssm_db_record_attribute_dataPKN8Security8CssmDataERP21cssm_db_unique_record +Security:single module:__ZThn40_N11SSDLSession10DataModifyEmmR21cssm_db_unique_recordPK29cssm_db_record_attribute_dataPKN8Security8CssmDataEm +Security:single module:__ZThn40_N11SSDLSession10GetDbNamesERP14cssm_name_list +Security:single module:__ZThn40_N11SSDLSession10GetDbOwnerEmR24cssm_acl_owner_prototype +Security:single module:__ZThn40_N11SSDLSession11ChangeDbAclEmRKN8Security17AccessCredentialsERK13cssm_acl_edit +Security:single module:__ZThn40_N11SSDLSession11PassThroughEmmPKvPPv +Security:single module:__ZThn40_N11SSDLSession12AuthenticateEmmRKN8Security17AccessCredentialsE +Security:single module:__ZThn40_N11SSDLSession12FreeNameListER14cssm_name_list +Security:single module:__ZThn40_N11SSDLSession13ChangeDbOwnerEmRKN8Security17AccessCredentialsERK24cssm_acl_owner_prototype +Security:single module:__ZThn40_N11SSDLSession14CreateRelationEmmPKcmRK29cssm_db_schema_attribute_infomRK25cssm_db_schema_index_info +Security:single module:__ZThn40_N11SSDLSession15DestroyRelationEmm +Security:single module:__ZThn40_N11SSDLSession19GetDbNameFromHandleEmPPc +Security:single module:__ZThn40_N11SSDLSession8DbCreateEPKcPK16cssm_net_addressRK11cssm_dbinfomPK29cssm_resource_control_contextPKvRm +Security:single module:__ZThn40_N11SSDLSession8DbDeleteEPKcPK16cssm_net_addressPKN8Security17AccessCredentialsE +Security:single module:__ZThn40_N11SSDLSession8GetDbAclEmPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZThn40_N11SSDLSessionD0Ev +Security:single module:__ZThn40_N11SSDLSessionD1Ev +Security:single module:__ZThn44_N11SSDLSessionD0Ev +Security:single module:__ZThn44_N11SSDLSessionD1Ev +Security:single module:__ZN12SSCSPSession11GenerateKeyEyRKN8Security7ContextEmmPKNS0_8CssmDataEPK29cssm_resource_control_contextRNS0_7CssmKeyEy +Security:single module:__ZN12SSCSPSession11GetKeyOwnerERKN8Security7CssmKeyER24cssm_acl_owner_prototype +Security:single module:__ZN12SSCSPSession11GetLoginAclEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZN12SSCSPSession11PassThroughEyRKN8Security7ContextEmPKvPPv +Security:single module:__ZN12SSCSPSession11getDatabaseEP17cssm_dl_db_handle +Security:single module:__ZN12SSCSPSession11getDatabaseERKN8Security7ContextE +Security:single module:__ZN12SSCSPSession12ChangeKeyAclERKN8Security17AccessCredentialsERK13cssm_acl_editRKNS0_7CssmKeyE +Security:single module:__ZN12SSCSPSession12GetTimeValueEmRN8Security8CssmDataE +Security:single module:__ZN12SSCSPSession12VerifyDeviceERKN8Security8CssmDataE +Security:single module:__ZN12SSCSPSession13GetLoginOwnerER24cssm_acl_owner_prototype +Security:single module:__ZN12SSCSPSession14ChangeKeyOwnerERKN8Security17AccessCredentialsERKNS0_7CssmKeyERK24cssm_acl_owner_prototype +Security:single module:__ZN12SSCSPSession14ChangeLoginAclERKN8Security17AccessCredentialsERK13cssm_acl_edit +Security:single module:__ZN12SSCSPSession14GenerateRandomEyRKN8Security7ContextERNS0_8CssmDataE +Security:single module:__ZN12SSCSPSession15GenerateKeyPairEyRKN8Security7ContextEmmPKNS0_8CssmDataERNS0_7CssmKeyEmmS6_PK29cssm_resource_control_contextS8_y +Security:single module:__ZN12SSCSPSession15RetrieveCounterERN8Security8CssmDataE +Security:single module:__ZN12SSCSPSession15validateKeyAttrEm +Security:single module:__ZN12SSCSPSession16ChangeLoginOwnerERKN8Security17AccessCredentialsERK24cssm_acl_owner_prototype +Security:single module:__ZN12SSCSPSession16RetrieveUniqueIdERN8Security8CssmDataE +Security:single module:__ZN12SSCSPSession16makeReferenceKeyEmRN8Security7CssmKeyER10SSDatabasemPKNS0_8CssmDataE +Security:single module:__ZN12SSCSPSession18QueryKeySizeInBitsEyRKN8Security7ContextERKNS0_7CssmKeyER13cssm_key_size +Security:single module:__ZN12SSCSPSession24GetOperationalStatisticsERN8Security24CSPOperationalStatisticsE +Security:single module:__ZN12SSCSPSession29ObtainPrivateKeyFromPublicKeyERKN8Security7CssmKeyERS1_ +Security:single module:__ZN12SSCSPSession5LoginERKN8Security17AccessCredentialsEPKNS0_8CssmDataEPKv +Security:single module:__ZN12SSCSPSession6LogoutEv +Security:single module:__ZN12SSCSPSession7WrapKeyEyRKN8Security7ContextERKNS0_17AccessCredentialsERKNS0_7CssmKeyEPKNS0_8CssmDataERS7_y +Security:single module:__ZN12SSCSPSession9DeriveKeyEyRKN8Security7ContextERNS0_8CssmDataEmmPKS4_PK29cssm_resource_control_contextRNS0_7CssmKeyE +Security:single module:__ZN12SSCSPSession9GetKeyAclERKN8Security7CssmKeyEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZN12SSCSPSession9UnwrapKeyEyRKN8Security7ContextEPKNS0_7CssmKeyERS5_mmPKNS0_8CssmDataEPK29cssm_resource_control_contextRS4_RS8_y +Security:single module:__ZN12SSCSPSessionC2EmR11CSPDLPluginRK12cssm_versionmmmRK12cssm_upcallsR14SSCSPDLSessionRN8Security10CssmClient3CSPE +Security:single module:__ZThn40_N12SSCSPSession11GenerateKeyEyRKN8Security7ContextEmmPKNS0_8CssmDataEPK29cssm_resource_control_contextRNS0_7CssmKeyEy +Security:single module:__ZThn40_N12SSCSPSession11GetKeyOwnerERKN8Security7CssmKeyER24cssm_acl_owner_prototype +Security:single module:__ZThn40_N12SSCSPSession11GetLoginAclEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZThn40_N12SSCSPSession11PassThroughEyRKN8Security7ContextEmPKvPPv +Security:single module:__ZThn40_N12SSCSPSession12ChangeKeyAclERKN8Security17AccessCredentialsERK13cssm_acl_editRKNS0_7CssmKeyE +Security:single module:__ZThn40_N12SSCSPSession12GetTimeValueEmRN8Security8CssmDataE +Security:single module:__ZThn40_N12SSCSPSession12VerifyDeviceERKN8Security8CssmDataE +Security:single module:__ZThn40_N12SSCSPSession13GetLoginOwnerER24cssm_acl_owner_prototype +Security:single module:__ZThn40_N12SSCSPSession14ChangeKeyOwnerERKN8Security17AccessCredentialsERKNS0_7CssmKeyERK24cssm_acl_owner_prototype +Security:single module:__ZThn40_N12SSCSPSession14ChangeLoginAclERKN8Security17AccessCredentialsERK13cssm_acl_edit +Security:single module:__ZThn40_N12SSCSPSession14GenerateRandomEyRKN8Security7ContextERNS0_8CssmDataE +Security:single module:__ZThn40_N12SSCSPSession15GenerateKeyPairEyRKN8Security7ContextEmmPKNS0_8CssmDataERNS0_7CssmKeyEmmS6_PK29cssm_resource_control_contextS8_y +Security:single module:__ZThn40_N12SSCSPSession15RetrieveCounterERN8Security8CssmDataE +Security:single module:__ZThn40_N12SSCSPSession16ChangeLoginOwnerERKN8Security17AccessCredentialsERK24cssm_acl_owner_prototype +Security:single module:__ZThn40_N12SSCSPSession16RetrieveUniqueIdERN8Security8CssmDataE +Security:single module:__ZThn40_N12SSCSPSession24GetOperationalStatisticsERN8Security24CSPOperationalStatisticsE +Security:single module:__ZThn40_N12SSCSPSession29ObtainPrivateKeyFromPublicKeyERKN8Security7CssmKeyERS1_ +Security:single module:__ZThn40_N12SSCSPSession5LoginERKN8Security17AccessCredentialsEPKNS0_8CssmDataEPKv +Security:single module:__ZThn40_N12SSCSPSession6LogoutEv +Security:single module:__ZThn40_N12SSCSPSession7WrapKeyEyRKN8Security7ContextERKNS0_17AccessCredentialsERKNS0_7CssmKeyEPKNS0_8CssmDataERS7_y +Security:single module:__ZThn40_N12SSCSPSession9DeriveKeyEyRKN8Security7ContextERNS0_8CssmDataEmmPKS4_PK29cssm_resource_control_contextRNS0_7CssmKeyE +Security:single module:__ZThn40_N12SSCSPSession9GetKeyAclERKN8Security7CssmKeyEPA68_KcRmRP19cssm_acl_entry_info +Security:single module:__ZThn40_N12SSCSPSession9UnwrapKeyEyRKN8Security7ContextEPKNS0_7CssmKeyERS5_mmPKNS0_8CssmDataEPK29cssm_resource_control_contextRS4_RS8_y +Security:single module:__ZN14SSCSPDLSession16makeReferenceKeyER12SSCSPSessionmRN8Security7CssmKeyER10SSDatabasemPKNS2_8CssmDataE +Security:single module:__ZN14SSCSPDLSessionC2Ev +Security:single module:__ZN20CSPDLDatabaseManager4makeERKN8Security6DbNameE +Security:single module:__ZN10DH_Factory5setupER15AppleCSPSessionRPN8Security20CSPFullPluginSession10CSPContextERKNS2_7ContextE +Security:single module:__ZN10DH_FactoryC2EPN8Security13CssmAllocatorES2_ +Security:single module:__ZN10DH_FactoryD0Ev +Security:single module:__ZN10DH_FactoryD1Ev +Security:single module:__ZN10DH_FactoryD2Ev +Security:single module:__ZN10DH_FactoryD4Ev +Security:single module:__Z13throwComcrypt14comcryptReturnPKc +Security:single module:__Z6ccFreePv +Security:single module:__Z8ccMallocj +Security:single module:__ZN10ASCContext10outputSizeEbm +Security:single module:__ZN10ASCContext15minimumProgressERmS0_ +Security:single module:__ZN10ASCContext4initERKN8Security7ContextEb +Security:single module:__ZN10ASCContext5finalERN8Security8CssmDataE +Security:single module:__ZN10ASCContext6updateEPvRmS0_S1_ +Security:single module:__ZN10ASCContext9inputSizeEm +Security:single module:__ZN10ASCContextD0Ev +Security:single module:__ZN10ASCContextD1Ev +Security:single module:__ZN10ASCContextD2Ev +Security:single module:__ZN10ASCContextD4Ev +Security:single module:__ZN13AscAlgFactory5setupER15AppleCSPSessionRPN8Security20CSPFullPluginSession10CSPContextERKNS2_7ContextE +Security:single module:__ZN13AscAlgFactoryC2EPN8Security13CssmAllocatorES2_ +Security:single module:__ZN15AppleCSPContextD0Ev +Security:single module:__ZN15AppleCSPContextD1Ev +Security:single module:__ZN18SymmetricBinaryKey15generateKeyBlobERN8Security13CssmAllocatorERNS0_8CssmDataERmR15AppleCSPSessionPKNS0_7CssmKeyES5_ +Security:single module:__ZN18SymmetricBinaryKeyC2Ej +Security:single module:__ZN18SymmetricBinaryKeyD1Ev +Security:single module:__ZN18SymmetricBinaryKeyD2Ev +Security:single module:__ZN22AppleKeyPairGenContext8generateERKN8Security7ContextER15AppleCSPSessionRNS0_7CssmKeyEP9BinaryKeyS7_S9_ +Security:single module:__ZN22AppleSymmKeyGenContext14generateSymKeyERKN8Security7ContextER15AppleCSPSessionRNS0_7CssmKeyE +Security:single module:__ZN15AppleCSPSession7WrapKeyEyRKN8Security7ContextERKNS0_17AccessCredentialsERKNS0_7CssmKeyEPKNS0_8CssmDataERS7_y +Security:single module:__Z6ckFreePv +Security:single module:__Z9ckReallocPvj +Security:single module:__ZN15CryptKitFactory5setupER15AppleCSPSessionRPN8Security20CSPFullPluginSession10CSPContextERKNS2_7ContextE +Security:single module:__ZN15CryptKitFactoryC2EPN8Security13CssmAllocatorES2_ +Security:single module:__ZN15CryptKitFactoryD0Ev +Security:single module:__ZN15CryptKitFactoryD1Ev +Security:single module:__ZN15CryptKitFactoryD2Ev +Security:single module:__ZN15CryptKitFactoryD4Ev +Security:single module:__Z9osReallocPvm +Security:single module:__ZN15RSA_DSA_FactoryC2EPN8Security13CssmAllocatorES2_ +Security:single module:__ZN15RSA_DSA_FactoryD0Ev +Security:single module:__ZN15RSA_DSA_FactoryD1Ev +Security:single module:__ZN15RSA_DSA_FactoryD2Ev +Security:single module:__ZN15RSA_DSA_FactoryD4Ev +Security:single module:__ZN11DHBinaryKeyC2EP5dh_st +Security:single module:__ZN11DHBinaryKeyC1EP5dh_st +Security:single module:__ZN11DHBinaryKeyC4EP5dh_st +Security:single module:__ZN11DHBinaryKeyD2Ev +Security:single module:__ZN11DHBinaryKeyD1Ev +Security:single module:__ZN11DHBinaryKeyD0Ev +Security:single module:__ZN11DHBinaryKeyD4Ev +Security:single module:__ZN11DHBinaryKey15generateKeyBlobERN8Security13CssmAllocatorERNS0_8CssmDataERmR15AppleCSPSessionPKNS0_7CssmKeyES5_ +Security:single module:__ZN19DHKeyPairGenContext8generateERKN8Security7ContextERNS0_7CssmKeyES5_ +Security:single module:__ZN19DHKeyPairGenContext8generateERKN8Security7ContextER9BinaryKeyS5_Rm +Security:single module:__ZN17DHKeyInfoProviderC2ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN17DHKeyInfoProviderC1ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN17DHKeyInfoProviderC4ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN17DHKeyInfoProvider8providerERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN17DHKeyInfoProvider15CssmKeyToBinaryEPN8Security7CssmKeyERmPP9BinaryKey +Security:single module:__ZN17DHKeyInfoProvider18QueryKeySizeInBitsER13cssm_key_size +Security:single module:__ZN17DHKeyInfoProvider15getHashableBlobERN8Security13CssmAllocatorERNS0_8CssmDataE +Security:single module:__ZN19DHKeyPairGenContext8generateERKN8Security7ContextEmRNS0_8CssmDataERmRPNS1_4AttrE +Security:single module:__ZN19DHKeyPairGenContext12freeGenAttrsEv +Security:single module:__ZN19DHKeyPairGenContext11dhGenParamsEmjiR15NSS_DHParameterR11SecNssCoder +Security:single module:__ZN12DSABinaryKey15generateKeyBlobERN8Security13CssmAllocatorERNS0_8CssmDataERmR15AppleCSPSessionPKNS0_7CssmKeyES5_ +Security:single module:__ZN12DSABinaryKeyC1EP6dsa_st +Security:single module:__ZN12DSABinaryKeyC2EP6dsa_st +Security:single module:__ZN12DSABinaryKeyC4EP6dsa_st +Security:single module:__ZN12DSABinaryKeyD0Ev +Security:single module:__ZN12DSABinaryKeyD1Ev +Security:single module:__ZN12DSABinaryKeyD2Ev +Security:single module:__ZN12DSABinaryKeyD4Ev +Security:single module:__ZN12RSABinaryKey15generateKeyBlobERN8Security13CssmAllocatorERNS0_8CssmDataERmR15AppleCSPSessionPKNS0_7CssmKeyES5_ +Security:single module:__ZN12RSABinaryKeyC1EP6rsa_st +Security:single module:__ZN12RSABinaryKeyC2EP6rsa_st +Security:single module:__ZN12RSABinaryKeyC4EP6rsa_st +Security:single module:__ZN12RSABinaryKeyD0Ev +Security:single module:__ZN12RSABinaryKeyD1Ev +Security:single module:__ZN12RSABinaryKeyD2Ev +Security:single module:__ZN12RSABinaryKeyD4Ev +Security:single module:__ZN18DSAKeyInfoProvider15CssmKeyToBinaryEPN8Security7CssmKeyERmPP9BinaryKey +Security:single module:__ZN18DSAKeyInfoProvider15getHashableBlobERN8Security13CssmAllocatorERNS0_8CssmDataE +Security:single module:__ZN18DSAKeyInfoProvider18QueryKeySizeInBitsER13cssm_key_size +Security:single module:__ZN18DSAKeyInfoProvider8providerERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN18DSAKeyInfoProviderC1ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN18DSAKeyInfoProviderC2ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN18DSAKeyInfoProviderC4ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN18RSAKeyInfoProvider15CssmKeyToBinaryEPN8Security7CssmKeyERmPP9BinaryKey +Security:single module:__ZN18RSAKeyInfoProvider15getHashableBlobERN8Security13CssmAllocatorERNS0_8CssmDataE +Security:single module:__ZN18RSAKeyInfoProviderC1ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN18RSAKeyInfoProviderC2ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN20DSAKeyPairGenContext12dsaGenParamsEmPKvjR16NSS_DSAAlgParamsR11SecNssCoder +Security:single module:__ZN20DSAKeyPairGenContext12freeGenAttrsEv +Security:single module:__ZN20DSAKeyPairGenContext8generateERKN8Security7ContextER9BinaryKeyS5_Rm +Security:single module:__ZN20DSAKeyPairGenContext8generateERKN8Security7ContextERNS0_7CssmKeyES5_ +Security:single module:__ZN20DSAKeyPairGenContext8generateERKN8Security7ContextEmRNS0_8CssmDataERmRPNS1_4AttrE +Security:single module:__ZN20RSAKeyPairGenContext8generateERKN8Security7ContextER9BinaryKeyS5_Rm +Security:single module:__ZN20RSAKeyPairGenContext8generateERKN8Security7ContextERNS0_7CssmKeyES5_ +Security:single module:__ZN24SymmetricKeyInfoProvider15getHashableBlobERN8Security13CssmAllocatorERNS0_8CssmDataE +Security:single module:__ZN24SymmetricKeyInfoProvider18QueryKeySizeInBitsER13cssm_key_size +Security:single module:__ZN24SymmetricKeyInfoProviderC2ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN8CryptKit12FEEBinaryKeyC2EPv +Security:single module:__ZN8CryptKit12FEEBinaryKeyC1EPv +Security:single module:__ZN8CryptKit12FEEBinaryKeyC4EPv +Security:single module:__ZN8CryptKit12FEEBinaryKeyD2Ev +Security:single module:__ZN8CryptKit12FEEBinaryKeyD1Ev +Security:single module:__ZN8CryptKit12FEEBinaryKeyD0Ev +Security:single module:__ZN8CryptKit12FEEBinaryKeyD4Ev +Security:single module:__ZN8CryptKit12FEEBinaryKey15generateKeyBlobERN8Security13CssmAllocatorERNS1_8CssmDataERmR15AppleCSPSessionPKNS1_7CssmKeyES6_ +Security:single module:__ZN8CryptKit20FEEKeyPairGenContext8generateERKN8Security7ContextERNS1_7CssmKeyES6_ +Security:single module:__ZN8CryptKit20FEEKeyPairGenContext8generateERKN8Security7ContextER9BinaryKeyS6_Rm +Security:single module:__ZN8CryptKit18FEEKeyInfoProviderC2ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN8CryptKit18FEEKeyInfoProviderC1ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN8CryptKit18FEEKeyInfoProviderC4ERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN8CryptKit18FEEKeyInfoProvider8providerERKN8Security7CssmKeyER15AppleCSPSession +Security:single module:__ZN8CryptKit18FEEKeyInfoProvider15CssmKeyToBinaryEPN8Security7CssmKeyERmPP9BinaryKey +Security:single module:__ZN8CryptKit18FEEKeyInfoProvider18QueryKeySizeInBitsER13cssm_key_size +Security:single module:__ZN8CryptKit18FEEKeyInfoProvider15getHashableBlobERN8Security13CssmAllocatorERNS1_8CssmDataE +Security:single module:_cspAddEntropy +Security:single module:_copyCssmHeader +Security:single module:_cspCompareCssmData +Security:single module:_cspGenSha1Hash +Security:single module:_requestedKeyFormat +Security:single module:__ZN14AppleTPSession10CertRevokeEmmPKN8Security8CssmDataERK14cssm_certgroupS6_RK22cssm_tp_verify_contextR29cssm_tp_verify_context_resultmRS1_ +Security:single module:__ZN14AppleTPSession10FormSubmitEmRKN8Security8CssmDataEPK20cssm_tp_authority_idS6_PNS0_17AccessCredentialsE +Security:single module:__ZN14AppleTPSession11FormRequestEPK20cssm_tp_authority_idmRN8Security8CssmDataE +Security:single module:__ZN14AppleTPSession11PassThroughEmyPK15cssm_dl_db_listmPKvPPv +Security:single module:__ZN14AppleTPSession12ApplyCrlToDbEmmRK16cssm_encoded_crlRK14cssm_certgroupPK22cssm_tp_verify_contextR29cssm_tp_verify_context_result +Security:single module:__ZN14AppleTPSession14CertGroupPruneEmRK15cssm_dl_db_listRK14cssm_certgroupRPS3_ +Security:single module:__ZN14AppleTPSession14CertReclaimKeyERK14cssm_certgroupmymPK29cssm_resource_control_context +Security:single module:__ZN14AppleTPSession16CertReclaimAbortEy +Security:single module:__ZN14AppleTPSession17ConfirmCredResultERKN8Security8CssmDataEPK26cssm_tp_callerauth_contextRK24cssm_tp_confirm_responsePK20cssm_tp_authority_id +Security:single module:__ZN14AppleTPSession17CrlCreateTemplateEmmPK10cssm_fieldRN8Security8CssmDataE +Security:single module:__ZN14AppleTPSession18CertCreateTemplateEmmPK10cssm_fieldRN8Security8CssmDataE +Security:single module:__ZN14AppleTPSession19ReceiveConfirmationERKN8Security8CssmDataERP24cssm_tp_confirm_responseRl +Security:single module:__ZN14AppleTPSession21CertGroupToTupleGroupEmRK14cssm_certgroupRP15cssm_tuplegroup +Security:single module:__ZN14AppleTPSession21TupleGroupToCertGroupEmRK15cssm_tuplegroupRP14cssm_certgroup +Security:single module:__ZN14AppleTPSession24CertGetAllTemplateFieldsEmRKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZN14AppleTPSession25CertRemoveFromCrlTemplateEmmPKN8Security8CssmDataERK14cssm_certgroupS6_RK22cssm_tp_verify_contextR29cssm_tp_verify_context_resultRS1_ +Security:single module:__ZN14AppleTPSession7CrlSignEmyRK16cssm_encoded_crlRK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_resultRN8Security8CssmDataE +Security:single module:__ZN14AppleTPSession8CertSignEmyRKN8Security8CssmDataERK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_resultRS1_ +Security:single module:__ZN14AppleTPSession9CrlVerifyEmmRK16cssm_encoded_crlRK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_result +Security:single module:__ZN14AppleTPSessionC2EmRN8Security10CssmPluginERK12cssm_versionmmmRK12cssm_upcalls +Security:single module:__ZN14AppleTPSessionD1Ev +Security:single module:__ZN14AppleTPSessionD2Ev +Security:single module:__ZThn40_N14AppleTPSession10CertRevokeEmmPKN8Security8CssmDataERK14cssm_certgroupS6_RK22cssm_tp_verify_contextR29cssm_tp_verify_context_resultmRS1_ +Security:single module:__ZThn40_N14AppleTPSession10FormSubmitEmRKN8Security8CssmDataEPK20cssm_tp_authority_idS6_PNS0_17AccessCredentialsE +Security:single module:__ZThn40_N14AppleTPSession11FormRequestEPK20cssm_tp_authority_idmRN8Security8CssmDataE +Security:single module:__ZThn40_N14AppleTPSession11PassThroughEmyPK15cssm_dl_db_listmPKvPPv +Security:single module:__ZThn40_N14AppleTPSession12ApplyCrlToDbEmmRK16cssm_encoded_crlRK14cssm_certgroupPK22cssm_tp_verify_contextR29cssm_tp_verify_context_result +Security:single module:__ZThn40_N14AppleTPSession14CertGroupPruneEmRK15cssm_dl_db_listRK14cssm_certgroupRPS3_ +Security:single module:__ZThn40_N14AppleTPSession14CertReclaimKeyERK14cssm_certgroupmymPK29cssm_resource_control_context +Security:single module:__ZThn40_N14AppleTPSession16CertReclaimAbortEy +Security:single module:__ZThn40_N14AppleTPSession17ConfirmCredResultERKN8Security8CssmDataEPK26cssm_tp_callerauth_contextRK24cssm_tp_confirm_responsePK20cssm_tp_authority_id +Security:single module:__ZThn40_N14AppleTPSession17CrlCreateTemplateEmmPK10cssm_fieldRN8Security8CssmDataE +Security:single module:__ZThn40_N14AppleTPSession18CertCreateTemplateEmmPK10cssm_fieldRN8Security8CssmDataE +Security:single module:__ZThn40_N14AppleTPSession19ReceiveConfirmationERKN8Security8CssmDataERP24cssm_tp_confirm_responseRl +Security:single module:__ZThn40_N14AppleTPSession21CertGroupToTupleGroupEmRK14cssm_certgroupRP15cssm_tuplegroup +Security:single module:__ZThn40_N14AppleTPSession21TupleGroupToCertGroupEmRK15cssm_tuplegroupRP14cssm_certgroup +Security:single module:__ZThn40_N14AppleTPSession24CertGetAllTemplateFieldsEmRKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZThn40_N14AppleTPSession25CertRemoveFromCrlTemplateEmmPKN8Security8CssmDataERK14cssm_certgroupS6_RK22cssm_tp_verify_contextR29cssm_tp_verify_context_resultRS1_ +Security:single module:__ZThn40_N14AppleTPSession7CrlSignEmyRK16cssm_encoded_crlRK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_resultRN8Security8CssmDataE +Security:single module:__ZThn40_N14AppleTPSession8CertSignEmyRKN8Security8CssmDataERK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_resultRS1_ +Security:single module:__ZThn40_N14AppleTPSession9CrlVerifyEmmRK16cssm_encoded_crlRK14cssm_certgroupPK22cssm_tp_verify_contextP29cssm_tp_verify_context_result +Security:single module:__Z18NSS_genNameChooserPviPKcS_ +Security:single module:__Z11clDataToIntRK9cssm_datal +Security:single module:__Z11clIntToDatamR9cssm_dataRN8Security13CssmAllocatorE +Security:single module:__Z14clNssNullArraymR11SecNssCoder +Security:single module:__Z15clCssmBoolToNsslR9cssm_dataRN8Security13CssmAllocatorE +Security:single module:__Z16CL_cssmTimeToNssRK14cssm_x509_timeR14NSS_TaggedItemR11SecNssCoder +Security:single module:__Z16CL_freeCssmAlgIdP30cssm_x509_algorithm_identifierRN8Security13CssmAllocatorE +Security:single module:__Z16CL_nullAlgParamsR30cssm_x509_algorithm_identifier +Security:single module:__Z20clCssmBitStringToNssR9cssm_data +Security:single module:__Z21CL_copySubjPubKeyInfoRK33cssm_x509_subject_public_key_infobRS_bRN8Security13CssmAllocatorE +Security:single module:__Z22CL_cssmDistPointsToNssRK22CE_CRLDistPointsSyntaxR25NSS_CRLDistributionPointsR11SecNssCoder +Security:single module:__Z22CL_nssDistPointsToCssmRK25NSS_CRLDistributionPointsR22CE_CRLDistPointsSyntaxR11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:__Z23CL_certEncodeComponentsRKN8Security8CssmDataES2_S2_RNS_13CssmOwnedDataE +Security:single module:__Z26CL_cssmAuthorityKeyIdToNssRK17CE_AuthorityKeyIDR18NSS_AuthorityKeyIdR11SecNssCoder +Security:single module:__Z28CL_nssIssuingDistPointToCssmP28NSS_IssuingDistributionPointP27CE_IssuingDistributionPointR11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:__Z29CL_CSSMKeyToSubjPubKeyInfoNSSRK8cssm_keyR33cssm_x509_subject_public_key_infoR11SecNssCoder +Security:single module:__Z30CL_decodeDistributionPointNameRK9cssm_dataR24CE_DistributionPointNameR11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:__Z30CL_encodeDistributionPointNameR24CE_DistributionPointNameR9cssm_dataR11SecNssCoder +Security:single module:__ZN14ArenaAllocator4freeEPv +Security:single module:__ZN14ArenaAllocator6mallocEm +Security:single module:__ZN14ArenaAllocator7reallocEPvm +Security:single module:__Z15CL_cssmAtvToNssRK25cssm_x509_type_value_pairR7NSS_ATVR11SecNssCoder +Security:single module:__Z15CL_cssmRdnToNssRK13cssm_x509_rdnR7NSS_RDNR11SecNssCoder +Security:single module:__Z15clCopyOtherNameRK12CE_OtherNameRS_RN8Security13CssmAllocatorE +Security:single module:__Z16CL_cssmNameToNssRK14cssm_x509_nameR8NSS_NameR11SecNssCoder +Security:single module:__Z16CL_freeOtherNameP12CE_OtherNameRN8Security13CssmAllocatorE +Security:single module:__Z21CL_freeCssmDistPointsP22CE_CRLDistPointsSyntaxRN8Security13CssmAllocatorE +Security:single module:__Z23CL_cssmGeneralNameToNssR14CE_GeneralNameR14NSS_TaggedItemR11SecNssCoder +Security:single module:__Z23CL_nssGeneralNameToCssmR14NSS_TaggedItemR14CE_GeneralNameR11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:__Z24CL_cssmGeneralNamesToNssRK15CE_GeneralNamesR16NSS_GeneralNamesR11SecNssCoder +Security:single module:__Z24CL_freeCssmDistPointNameP24CE_DistributionPointNameRN8Security13CssmAllocatorE +Security:single module:__Z24CL_nssGeneralNamesToCssmRK16NSS_GeneralNamesR15CE_GeneralNamesR11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:__Z27CL_freeCssmIssuingDistPointP27CE_IssuingDistributionPointRN8Security13CssmAllocatorE +Security:single module:__ZN12DecodedExtenC2ERK9cssm_databPvbPK23sec_ASN1Template_structR11SecNssCoderPS1_ +Security:single module:__ZN12DecodedExtenD2Ev +Security:single module:__ZN17DecodedExtensions11encodeToNssERPP17NSS_CertExtension +Security:single module:__ZN17DecodedExtensionsC2ER11SecNssCoderRN8Security13CssmAllocatorE +Security:single module:__ZN17DecodedExtensionsD2Ev +Security:single module:__ZNK12DecodedExten5parseEP19cssm_x509_extensionRN8Security13CssmAllocatorE +Security:single module:__ZNK17DecodedExtensions13convertToCdsaER20cssm_x509_extensionsRN8Security13CssmAllocatorE +Security:single module:__ZN11DecodedItemC1ER18AppleX509CLSession +Security:single module:__ZN11DecodedItemD0Ev +Security:single module:__ZN11DecodedItemD1Ev +Security:single module:_PL_ArenaFinish +Security:single module:_PL_ArenaGrow +Security:single module:_PL_ArenaRelease +Security:single module:_PL_CompactArenaPool +Security:single module:_PL_FreeArenaPool +Security:single module:_sec_port_ucs4_utf8_conversion_function +Security:single module:_sec_port_ucs2_utf8_conversion_function +Security:single module:___cmpdi2 +Security:single module:__ZN18AppleX509CLSession17CertVerifyWithKeyEyRKN8Security8CssmDataE +Security:single module:__ZN18AppleX509CLSession8CertSignEyRKN8Security8CssmDataEPK10cssm_fieldmRS1_ +Security:single module:__ZN18AppleX509CLSession8signDataEyRKN8Security8CssmDataERNS0_13CssmOwnedDataE +Security:single module:__ZThn40_N18AppleX509CLSession17CertVerifyWithKeyEyRKN8Security8CssmDataE +Security:single module:__ZThn40_N18AppleX509CLSession8CertSignEyRKN8Security8CssmDataEPK10cssm_fieldmRS1_ +Security:single module:__ZN18AppleX509CLSession17CrlDescribeFormatERmRP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession17CrlDescribeFormatERmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession15CrlGetAllFieldsERKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZThn40_N18AppleX509CLSession15CrlGetAllFieldsERKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZN18AppleX509CLSession21CrlGetFirstFieldValueERKN8Security8CssmDataES3_RmRP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession21CrlGetFirstFieldValueERKN8Security8CssmDataES3_RmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession20CrlGetNextFieldValueEmRP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession20CrlGetNextFieldValueEmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession11IsCertInCrlERKN8Security8CssmDataES3_Rl +Security:single module:__ZThn40_N18AppleX509CLSession11IsCertInCrlERKN8Security8CssmDataES3_Rl +Security:single module:__ZN18AppleX509CLSession8CrlCacheERKN8Security8CssmDataERm +Security:single module:__ZThn40_N18AppleX509CLSession8CrlCacheERKN8Security8CssmDataERm +Security:single module:__ZN18AppleX509CLSession27CrlGetFirstCachedFieldValueEmPKN8Security8CssmDataERS2_RmRP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession27CrlGetFirstCachedFieldValueEmPKN8Security8CssmDataERS2_RmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession26CrlGetNextCachedFieldValueEmRP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession26CrlGetNextCachedFieldValueEmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession17IsCertInCachedCrlERKN8Security8CssmDataEmRlRS1_ +Security:single module:__ZThn40_N18AppleX509CLSession17IsCertInCachedCrlERKN8Security8CssmDataEmRlRS1_ +Security:single module:__ZN18AppleX509CLSession13CrlAbortCacheEm +Security:single module:__ZThn40_N18AppleX509CLSession13CrlAbortCacheEm +Security:single module:__ZN18AppleX509CLSession13CrlAbortQueryEm +Security:single module:__ZThn40_N18AppleX509CLSession13CrlAbortQueryEm +Security:single module:__ZN18AppleX509CLSession17CrlCreateTemplateEmPK10cssm_fieldRN8Security8CssmDataE +Security:single module:__ZThn40_N18AppleX509CLSession17CrlCreateTemplateEmPK10cssm_fieldRN8Security8CssmDataE +Security:single module:__ZN18AppleX509CLSession12CrlSetFieldsEmPK10cssm_fieldRKN8Security8CssmDataERS4_ +Security:single module:__ZThn40_N18AppleX509CLSession12CrlSetFieldsEmPK10cssm_fieldRKN8Security8CssmDataERS4_ +Security:single module:__ZN18AppleX509CLSession10CrlAddCertEyRKN8Security8CssmDataEmPK10cssm_fieldS3_RS1_ +Security:single module:__ZThn40_N18AppleX509CLSession10CrlAddCertEyRKN8Security8CssmDataEmPK10cssm_fieldS3_RS1_ +Security:single module:__ZN18AppleX509CLSession13CrlRemoveCertERKN8Security8CssmDataES3_RS1_ +Security:single module:__ZThn40_N18AppleX509CLSession13CrlRemoveCertERKN8Security8CssmDataES3_RS1_ +Security:single module:__ZN18AppleX509CLSession27CrlGetAllCachedRecordFieldsEmRKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZThn40_N18AppleX509CLSession27CrlGetAllCachedRecordFieldsEmRKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZN18AppleX509CLSession16CrlVerifyWithKeyEyRKN8Security8CssmDataE +Security:single module:__ZThn40_N18AppleX509CLSession16CrlVerifyWithKeyEyRKN8Security8CssmDataE +Security:single module:__ZN18AppleX509CLSession9CrlVerifyEyRKN8Security8CssmDataEPS2_PK10cssm_fieldm +Security:single module:__ZThn40_N18AppleX509CLSession9CrlVerifyEyRKN8Security8CssmDataEPS2_PK10cssm_fieldm +Security:single module:__ZN18AppleX509CLSession7CrlSignEyRKN8Security8CssmDataEPK10cssm_fieldmRS1_ +Security:single module:__ZThn40_N18AppleX509CLSession7CrlSignEyRKN8Security8CssmDataEPK10cssm_fieldmRS1_ +Security:single module:__ZN18AppleX509CLSession10FreeFieldsEmRP10cssm_field +Security:single module:__ZN18AppleX509CLSession11PassThroughEymPKvPPv +Security:single module:__ZN18AppleX509CLSession16CertGetAllFieldsERKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZN18AppleX509CLSession18CertCreateTemplateEmPK10cssm_fieldRN8Security8CssmDataE +Security:single module:__ZN18AppleX509CLSession18CertDescribeFormatERmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession22CertGetFirstFieldValueERKN8Security8CssmDataES3_RmRP9cssm_data +Security:single module:__ZN18AppleX509CLSession23CertGroupToSignedBundleEyRK14cssm_certgroupPK23cssm_cert_bundle_headerRN8Security8CssmDataE +Security:single module:__ZN18AppleX509CLSession24CertGetAllTemplateFieldsERKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZN18AppleX509CLSession27CertGroupFromVerifiedBundleEyRK16cssm_cert_bundlePKN8Security8CssmDataERP14cssm_certgroup +Security:single module:__ZThn40_N18AppleX509CLSession10FreeFieldsEmRP10cssm_field +Security:single module:__ZThn40_N18AppleX509CLSession11PassThroughEymPKvPPv +Security:single module:__ZThn40_N18AppleX509CLSession16CertGetAllFieldsERKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZThn40_N18AppleX509CLSession18CertCreateTemplateEmPK10cssm_fieldRN8Security8CssmDataE +Security:single module:__ZThn40_N18AppleX509CLSession18CertDescribeFormatERmRP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession21CertGetNextFieldValueEmRP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession22CertGetFirstFieldValueERKN8Security8CssmDataES3_RmRP9cssm_data +Security:single module:__ZThn40_N18AppleX509CLSession23CertGroupToSignedBundleEyRK14cssm_certgroupPK23cssm_cert_bundle_headerRN8Security8CssmDataE +Security:single module:__ZThn40_N18AppleX509CLSession24CertGetAllTemplateFieldsERKN8Security8CssmDataERmRP10cssm_field +Security:single module:__ZThn40_N18AppleX509CLSession27CertGroupFromVerifiedBundleEyRK16cssm_cert_bundlePKN8Security8CssmDataERP14cssm_certgroup +Security:single module:__ZN11CLCachedCRLD0Ev +Security:single module:__ZN11CLCachedCRLD1Ev +Security:single module:__ZN11CLCachedCRLD2Ev +Security:single module:__ZN11CLCachedCRLD4Ev +Security:single module:__ZN12CLCachedCertD1Ev +Security:single module:__ZN12CLCachedCertD2Ev +Security:single module:__ZN13CLCachedEntryC1Ev +Security:single module:__ZN7CLQueryC2E11CLQueryTypeRKN8Security8CssmDataEjbm +Security:single module:__ZN7CLQueryD2Ev +Security:single module:__ZN14SSDatabaseImpl11getSettingsERmRb +Security:single module:__ZN14SSDatabaseImpl11setSettingsEmb +Security:single module:__ZN14SSDatabaseImpl12authenticateEmPK23cssm_access_credentials +Security:single module:__ZN14SSDatabaseImpl16changePassphraseEPK23cssm_access_credentials +Security:single module:__ZN14SSDatabaseImpl4lockEv +Security:single module:__ZN14SSDatabaseImpl6createERKN8Security14DLDbIdentifierE +Security:single module:__ZN14SSDatabaseImpl6insertEmPK29cssm_db_record_attribute_dataPK9cssm_datab +Security:single module:__ZN14SSDatabaseImpl6unlockERK9cssm_data +Security:single module:__ZN14SSDatabaseImpl6unlockEv +Security:single module:__ZN14SSDatabaseImpl8isLockedEv +Security:single module:__ZN14SSDatabaseImplC2ERN8Security14SecurityServer13ClientSessionERKNS0_10CssmClient2DLEPKcPK16cssm_net_address +Security:single module:__ZN14SSDatabaseImplD1Ev +Security:single module:__ZN14SSDatabaseImplD2Ev +Security:single module:__ZN18SSUniqueRecordImplC2ERK10SSDatabase +Security:single module:__ZN18SSUniqueRecordImplD1Ev +Security:single module:__ZN18SSUniqueRecordImplD2Ev +Security:single module:__ZN5SSKey11changeOwnerERKN8Security17AccessCredentialsERKNS0_17AclOwnerPrototypeE +Security:single module:__ZN5SSKey6getAclEPKcRmRPN8Security12AclEntryInfoERNS3_13CssmAllocatorE +Security:single module:__ZN5SSKey8getOwnerER24cssm_acl_owner_prototypeRN8Security13CssmAllocatorE +Security:single module:__ZN5SSKey9changeAclERKN8Security17AccessCredentialsERKNS0_7AclEditE +Security:single module:__ZN5SSKeyC1ER12SSCSPSessionmRN8Security7CssmKeyER10SSDatabasemPKNS2_8CssmDataE +Security:single module:__ZN5SSKeyC2ER11SSDLSessionRN8Security7CssmKeyER10SSDatabaseRK14SSUniqueRecordmRNS2_8CssmDataE +Security:single module:__ZN5SSKeyC2ER12SSCSPSessionmRN8Security7CssmKeyER10SSDatabasemPKNS2_8CssmDataE +Security:single module:__ZN5SSKeyC4ER12SSCSPSessionmRN8Security7CssmKeyER10SSDatabasemPKNS2_8CssmDataE +Security:single module:__ZN5SSKeyD1Ev +Security:single module:__ZN5SSKeyD2Ev +Security:single module:_comcryptAlloc +Security:single module:_comcryptBlock +Security:single module:_comcryptData +Security:single module:_comcryptInit +Security:single module:_comcryptMaxInBufSize +Security:single module:_comcryptMaxOutBufSize +Security:single module:_comcryptObjFree +Security:single module:_deComcryptBlock +Security:single module:_deComcryptData +Security:single module:__ZN15AppleCSPSession10WrapKeyCmsEyRKN8Security7ContextERKNS0_17AccessCredentialsERKNS0_7CssmKeyERNS0_8CssmDataEbPKSA_RS7_y +Security:single module:__ZN15AppleCSPSession19pkcs8InferKeyHeaderERN8Security7CssmKeyE +Security:single module:_pkcs8RawKeyFormat +Security:single module:_DeriveKey_PKCS12 +Security:single module:__Z9p12PbeGenRK9cssm_dataPKhjj10P12_PBE_IDmR11SecNssCoderPhj +Security:single module:__Z9p12StrCatPKhjR11SecNssCoderjPh +Security:single module:__Z12DeriveKey_DHRKN8Security7ContextERKNS_8CssmDataEP9cssm_dataR15AppleCSPSession +Security:single module:__ZN8CryptKit13throwCryptKitE9feeReturnPKc +Security:single module:__ZN8CryptKit15contextToFeeKeyERKN8Security7ContextER15AppleCSPSessionmmmRb +Security:single module:__ZN8CryptKit12cssmKeyToFeeERKN8Security7CssmKeyER15AppleCSPSessionRb +Security:single module:__ZN8CryptKit15rawCssmKeyToFeeERKN8Security7CssmKeyE +Security:single module:__ZN8CryptKit15feeRandCallbackEPvPhj +Security:single module:__ZN16SignatureContext10outputSizeEbm +Security:single module:__ZN16SignatureContext18setDigestAlgorithmEm +Security:single module:__ZN16SignatureContext5finalERN8Security8CssmDataE +Security:single module:__ZN16SignatureContextD1Ev +Security:single module:__ZN16SignatureContextD2Ev +Security:single module:__ZN8CryptKit11FEEDContextD2Ev +Security:single module:__ZN8CryptKit11FEEDContextD1Ev +Security:single module:__ZN8CryptKit11FEEDContextD0Ev +Security:single module:__ZN8CryptKit11FEEDContextD4Ev +Security:single module:__ZN8CryptKit11FEEDContext4initERKN8Security7ContextEb +Security:single module:__ZN8CryptKit11FEEDContext12encryptBlockEPKvmPvRmb +Security:single module:__ZN8CryptKit11FEEDContext12decryptBlockEPKvPvRmb +Security:single module:__ZN8CryptKit11FEEDContext9inputSizeEm +Security:single module:__ZN8CryptKit11FEEDContext10outputSizeEbm +Security:single module:__ZN8CryptKit11FEEDContext15minimumProgressERmS1_ +Security:single module:__ZN8CryptKit14FEEDExpContextD2Ev +Security:single module:__ZN8CryptKit14FEEDExpContextD1Ev +Security:single module:__ZN8CryptKit14FEEDExpContextD0Ev +Security:single module:__ZN8CryptKit14FEEDExpContextD4Ev +Security:single module:__ZN8CryptKit14FEEDExpContext4initERKN8Security7ContextEb +Security:single module:__ZN8CryptKit14FEEDExpContext12encryptBlockEPKvmPvRmb +Security:single module:__ZN8CryptKit14FEEDExpContext12decryptBlockEPKvPvRmb +Security:single module:__ZN8CryptKit9FEESignerD2Ev +Security:single module:__ZN8CryptKit9FEESignerD1Ev +Security:single module:__ZN8CryptKit9FEESignerD0Ev +Security:single module:__ZN8CryptKit9FEESignerD4Ev +Security:single module:__ZN8CryptKit9FEESigner14keyFromContextERKN8Security7ContextE +Security:single module:__ZN8CryptKit9FEESigner10signerInitERKN8Security7ContextEb +Security:single module:__ZN8CryptKit12FEERawSigner4signEPKvmPvPm +Security:single module:__ZN8CryptKit12FEERawSigner6verifyEPKvmS2_m +Security:single module:__ZN8CryptKit12FEERawSigner10maxSigSizeEv +Security:single module:__ZN8CryptKit14FEEECDSASigner4signEPKvmPvPm +Security:single module:__ZN8CryptKit14FEEECDSASigner6verifyEPKvmS2_m +Security:single module:__ZN8CryptKit14FEEECDSASigner10maxSigSizeEv +Security:single module:_ffree +Security:single module:_fmallocWithData +Security:single module:_frealloc +Security:single module:_deserializeGiant +Security:single module:_feeReturnString +Security:single module:_giant_with_data +Security:single module:_mem_from_giant +Security:single module:_printCurveParams +Security:single module:_printGiant +Security:single module:_printGiantExp +Security:single module:_printGiantHex +Security:single module:_printKey +Security:single module:_serializeGiant +Security:single module:_terminateCryptKit +Security:single module:_CRYPTO_free_locked +Security:single module:_CRYPTO_get_locked_mem_functions +Security:single module:_CRYPTO_get_mem_debug_functions +Security:single module:_CRYPTO_get_mem_debug_options +Security:single module:_CRYPTO_get_mem_functions +Security:single module:_CRYPTO_malloc_locked +Security:single module:_CRYPTO_realloc +Security:single module:_CRYPTO_remalloc +Security:single module:_CRYPTO_set_mem_debug_functions +Security:single module:_CRYPTO_set_mem_debug_options +Security:single module:__ZN16RSA_CryptContext12decryptBlockEPKvPvRmb +Security:single module:__ZN16RSA_CryptContextD1Ev +Security:single module:__ZN16RSA_CryptContextD2Ev +Security:single module:__ZN9DSASigner10maxSigSizeEv +Security:single module:__ZN9DSASigner10signerInitERKN8Security7ContextEb +Security:single module:__ZN9DSASigner14keyFromContextERKN8Security7ContextE +Security:single module:__ZN9DSASigner4signEPKvmPvPm +Security:single module:__ZN9DSASigner6verifyEPKvmS1_m +Security:single module:__ZN9DSASignerD0Ev +Security:single module:__ZN9DSASignerD1Ev +Security:single module:__ZN9DSASignerD2Ev +Security:single module:__ZN9DSASignerD4Ev +Security:single module:__ZN9RSASigner10maxSigSizeEv +Security:single module:__ZN9RSASigner4signEPKvmPvPm +Security:single module:__ZN9RSASignerD1Ev +Security:single module:__ZN9RSASignerD2Ev +Security:single module:__ZN9MD2Object10digestInitEv +Security:single module:__ZN9MD2Object12digestUpdateEPKvm +Security:single module:__ZN9MD2Object11digestFinalEPv +Security:single module:__ZNK9MD2Object11digestCloneEv +Security:single module:__ZNK9MD2Object17digestSizeInBytesEv +Security:single module:_BN_clear +Security:single module:_BN_clear_bit +Security:single module:_BN_cmp +Security:single module:_BN_dup +Security:single module:_BN_get_word +Security:single module:_BN_mask_bits +Security:single module:_BN_options +Security:single module:_DHParamBlockDecode +Security:single module:_DHPrivateKeyDecode +Security:single module:_DHPrivateKeyEncode +Security:single module:_DHPublicKeyDecode +Security:single module:_DHPublicKeyEncode +Security:single module:_DSADecodeAlgParams +Security:single module:_DSAEncodeAlgParams +Security:single module:_DSAPrivateKeyDecode +Security:single module:_DSAPrivateKeyEncode +Security:single module:_DSAPublicKeyDecode +Security:single module:_DSAPublicKeyEncode +Security:single module:_DSASigDecode +Security:single module:_DSASigEncode +Security:single module:_RSAPrivateKeyDecode +Security:single module:_RSAPrivateKeyEncode +Security:single module:_RSAPublicKeyEncode +Security:single module:__Z16dhToNssAlgIdX942PK5dh_stR29NSS_DHAlgorithmIdentifierX942R11SecNssCoder +Security:single module:__Z21DHPublicKeyDecodeX509P5dh_stR11SecNssCoderPhj +Security:single module:__Z21DHPublicKeyEncodeX509P5dh_stR11SecNssCoderRN8Security13CssmOwnedDataE +Security:single module:__Z22DSAPublicKeyDecodeX509R11SecNssCoderP6dsa_stPvm +Security:single module:__Z22DSAPublicKeyEncodeX509R11SecNssCoderP6dsa_stRN8Security13CssmOwnedDataE +Security:single module:__Z22RSAPublicKeyEncodeX509R11SecNssCoderP6rsa_stRN8Security13CssmOwnedDataE +Security:single module:__Z23DHPrivateKeyDecodePKCS3R11SecNssCoderP5dh_stPhj +Security:single module:__Z23DHPrivateKeyDecodePKCS8R11SecNssCoderP5dh_stPhj +Security:single module:__Z23DHPrivateKeyEncodePKCS3R11SecNssCoderP5dh_stRN8Security13CssmOwnedDataE +Security:single module:__Z23DHPrivateKeyEncodePKCS8R11SecNssCoderP5dh_stRN8Security13CssmOwnedDataE +Security:single module:__Z24DSAPrivateKeyDecodePKCS8R11SecNssCoderP6dsa_stPvj +Security:single module:__Z24DSAPrivateKeyEncodePKCS8R11SecNssCoderP6dsa_stRN8Security13CssmOwnedDataE +Security:single module:__Z24RSAPrivateKeyDecodePKCS1R11SecNssCoderP6rsa_stPvm +Security:single module:__Z24RSAPrivateKeyEncodePKCS1R11SecNssCoderP6rsa_stRN8Security13CssmOwnedDataE +Security:single module:__Z24RSAPrivateKeyEncodePKCS8R11SecNssCoderP6rsa_stRN8Security13CssmOwnedDataE +Security:single module:__Z25DSAPublicKeyDecodeFIPS186R11SecNssCoderP6dsa_stPvj +Security:single module:__Z25DSAPublicKeyEncodeFIPS186R11SecNssCoderP6dsa_stRN8Security13CssmOwnedDataE +Security:single module:__Z26DSAPrivateKeyDecodeFIPS186R11SecNssCoderP6dsa_stPvj +Security:single module:__Z26DSAPrivateKeyDecodeOpensslR11SecNssCoderP6dsa_stPvm +Security:single module:__Z26DSAPrivateKeyEncodeFIPS186R11SecNssCoderP6dsa_stRN8Security13CssmOwnedDataE +Security:single module:__Z26DSAPrivateKeyEncodeOpensslR11SecNssCoderP6dsa_stRN8Security13CssmOwnedDataE +Security:single module:_bnToCssmData +Security:single module:_cssmDataToBn +Security:single module:_cssmDataToInt +Security:single module:_intToCssmData +Security:single module:_DH_new_method +Security:single module:_DH_set_default_method +Security:single module:_DH_get_default_method +Security:single module:_DH_set_method +Security:single module:_DH_new +Security:single module:_DH_free +Security:single module:_DH_get_ex_new_index +Security:single module:_DH_set_ex_data +Security:single module:_DH_get_ex_data +Security:single module:_DH_size +Security:single module:_generate_key +Security:single module:_compute_key +Security:single module:_DH_generate_key +Security:single module:_DH_compute_key +Security:single module:_DH_OpenSSL +Security:single module:_dh_bn_mod_exp +Security:single module:_dh_init +Security:single module:_dh_finish +Security:single module:_DH_generate_parameters +Security:single module:_contextToDhKey +Security:single module:_cssmKeyToDh +Security:single module:_rawCssmKeyToDh +Security:single module:_CRYPTO_mem_ctrl +Security:single module:_RAND_add +Security:single module:_RAND_pseudo_bytes +Security:single module:_SHA1 +Security:single module:__ZN16openSslExceptionC1EiPKc +Security:single module:__ZN16openSslExceptionC2EiPKc +Security:single module:__ZN16openSslExceptionC4EiPKc +Security:single module:_logSslErrInfo +Security:single module:_throwOpensslErr +Security:single module:_throwRsaDsa +Security:single module:_DSA_new_method +Security:single module:_DSA_set_default_method +Security:single module:_DSA_get_default_method +Security:single module:_DSA_new +Security:single module:_DSA_set_method +Security:single module:_DSA_free +Security:single module:_DSA_get_ex_new_index +Security:single module:_DSA_set_ex_data +Security:single module:_DSA_get_ex_data +Security:single module:_DSA_dup_DH +Security:single module:_DSA_generate_key +Security:single module:_DSA_generate_parameters +Security:single module:_RSA_blinding_on +Security:single module:_RSA_flags +Security:single module:_RSA_get_default_method +Security:single module:_RSA_get_ex_data +Security:single module:_RSA_get_ex_new_index +Security:single module:_RSA_get_method +Security:single module:_RSA_memory_lock +Security:single module:_RSA_private_decrypt +Security:single module:_RSA_private_encrypt +Security:single module:_RSA_set_default_method +Security:single module:_RSA_set_ex_data +Security:single module:_RSA_set_method +Security:single module:_RSA_generate_key +Security:single module:_contextToDsaKey +Security:single module:_cssmKeyToDsa +Security:single module:_dsaGetParamsFromKey +Security:single module:_dsaKeyPrivToPub +Security:single module:_rawCssmKeyToDsa +Security:single module:_feePubKeyAlloc +Security:single module:_feePubKeyFree +Security:single module:_feePubKeyInitFromPrivDataKeyBits +Security:single module:_feePubKeyInitFromPrivDataDepth +Security:single module:_feePubKeyInitFromKey +Security:single module:_feePubKeyInitFromKeyString +Security:single module:_feePubKeyCreateKeyString +Security:single module:_feePubKeyCreatePubBlob +Security:single module:_feePubKeyCreatePrivBlob +Security:single module:_feePubKeyInitPubKeyFromPriv +Security:single module:_feePubKeyIsEqual +Security:single module:_feePubKeyIsPrivate +Security:single module:_feePubKeyCreatePad +Security:single module:_feePubKeyCreateSignature +Security:single module:_feePubKeyVerifySignature +Security:single module:_feePubKeyCreateECDSASignature +Security:single module:_feePubKeyVerifyECDSASignature +Security:single module:_feePubKeyBitsize +Security:single module:_feePubKeyPlusCurve +Security:single module:_feePubKeyMinusCurve +Security:single module:_feePubKeyCurveParams +Security:single module:_feePubKeyPrivData +Security:single module:_feePubKeyAlgorithmName +Security:single module:_pubKeyInstAlloc +Security:single module:_pubKeyInstFree +Security:single module:_feeGenPrivate +Security:single module:_printPubKey +Security:single module:_createKeyBlob +Security:single module:_feePubKeyInitFromKeyBlob +Security:single module:_feePubKeyInitFromPubBlob +Security:single module:_feePubKeyInitFromPrivBlob +Security:single module:_feePubKeyCreateDERPubBlob +Security:single module:_feePubKeyCreateDERPrivBlob +Security:single module:_feePubKeyInitFromDERPubBlob +Security:single module:_feePubKeyInitFromDERPrivBlob +Security:single module:__ZN11GAESContextC2ER15AppleCSPSession +Security:single module:__ZN11GAESContextD1Ev +Security:single module:__ZN11GAESContextD2Ev +Security:single module:__ZN16AESKeyGenContext8generateERKN8Security7ContextERNS0_7CssmKeyES5_ +Security:single module:__ZN10AESContextD2Ev +Security:single module:__ZN10AESContextD1Ev +Security:single module:__ZN10AESContextD0Ev +Security:single module:__ZN10AESContextD4Ev +Security:single module:__ZN10AESContext8aesErrorEiPKc +Security:single module:__ZN10AESContext9deleteKeyEv +Security:single module:__ZN10AESContext4initERKN8Security7ContextEb +Security:single module:__ZN10AESContext12encryptBlockEPKvmPvRmb +Security:single module:__ZN10AESContext12decryptBlockEPKvPvRmb +Security:single module:__ZN10DESContext12decryptBlockEPKvPvRmb +Security:single module:__ZN10DESContext12encryptBlockEPKvmPvRmb +Security:single module:__ZN10DESContext4initERKN8Security7ContextEb +Security:single module:__ZN10DESContextD0Ev +Security:single module:__ZN10DESContextD1Ev +Security:single module:__ZN10DESContextD2Ev +Security:single module:__ZN10DESContextD4Ev +Security:single module:__ZN11DES3Context12encryptBlockEPKvmPvRmb +Security:single module:__ZN11DES3ContextD1Ev +Security:single module:__ZN11DES3ContextD2Ev +Security:single module:__ZN10MacContextD1Ev +Security:single module:__ZN10MacContextD2Ev +Security:single module:__ZN16MacLegacyContext10outputSizeEbm +Security:single module:__ZN16MacLegacyContext5finalERN8Security8CssmDataE +Security:single module:__ZN16MacLegacyContextD1Ev +Security:single module:__ZN16MacLegacyContextD2Ev +Security:single module:__ZN10RC2ContextD2Ev +Security:single module:__ZN10RC2ContextD1Ev +Security:single module:__ZN10RC2ContextD0Ev +Security:single module:__ZN10RC2ContextD4Ev +Security:single module:__ZN10RC2Context4initERKN8Security7ContextEb +Security:single module:__ZN10RC2Context12encryptBlockEPKvmPvRmb +Security:single module:__ZN10RC2Context12decryptBlockEPKvPvRmb +Security:single module:__ZN10RC4Context15minimumProgressERmS0_ +Security:single module:__ZN10RC4Context5finalERN8Security8CssmDataE +Security:single module:__ZN10RC4ContextD1Ev +Security:single module:__ZN10RC4ContextD2Ev +Security:single module:__ZN10RC5ContextD2Ev +Security:single module:__ZN10RC5ContextD1Ev +Security:single module:__ZN10RC5ContextD0Ev +Security:single module:__ZN10RC5ContextD4Ev +Security:single module:__ZN10RC5Context4initERKN8Security7ContextEb +Security:single module:__ZN10RC5Context12encryptBlockEPKvmPvRmb +Security:single module:__ZN10RC5Context12decryptBlockEPKvPvRmb +Security:single module:__ZN11CastContextD2Ev +Security:single module:__ZN11CastContextD1Ev +Security:single module:__ZN11CastContextD0Ev +Security:single module:__ZN11CastContextD4Ev +Security:single module:__ZN11CastContext9deleteKeyEv +Security:single module:__ZN11CastContext4initERKN8Security7ContextEb +Security:single module:__ZN11CastContext12encryptBlockEPKvmPvRmb +Security:single module:__ZN11CastContext12decryptBlockEPKvPvRmb +Security:single module:__ZN15BlowfishContextD2Ev +Security:single module:__ZN15BlowfishContextD1Ev +Security:single module:__ZN15BlowfishContextD0Ev +Security:single module:__ZN15BlowfishContextD4Ev +Security:single module:__ZN15BlowfishContext9deleteKeyEv +Security:single module:__ZN15BlowfishContext4initERKN8Security7ContextEb +Security:single module:__ZN15BlowfishContext12encryptBlockEPKvmPvRmb +Security:single module:__ZN15BlowfishContext12decryptBlockEPKvPvRmb +Security:single module:__ZN10TPCertInfo11subjectNameEv +Security:single module:__ZN10TPCertInfo13addStatusCodeEl +Security:single module:__ZN10TPCertInfoC2EmmPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN10TPCertInfoD2Ev +Security:single module:__ZN11TPCertGroup17removeCertAtIndexEj +Security:single module:__ZN11TPCertGroup21verifyWithPartialKeysERK12TPClItemInfo +Security:single module:__ZN11TPCertGroup9firstCertEv +Security:single module:__ZN11TPCertGroupC2ERK14cssm_certgroupmmRN8Security13CssmAllocatorEPKcb12TPGroupOwner +Security:single module:__ZN11TPCertGroupC2ERN8Security13CssmAllocatorE12TPGroupOwner +Security:single module:__ZN11TPCertGroupD2Ev +Security:single module:__ZN12TPClItemInfoC1EmmRK13TPClItemCallsPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN12TPClItemInfoD1Ev +Security:single module:__ZN14AppleTPSession18CertGroupConstructEmmRK15cssm_dl_db_listPKvRK14cssm_certgroupRPS5_ +Security:single module:__ZThn40_N14AppleTPSession18CertGroupConstructEmmRK15cssm_dl_db_listPKvRK14cssm_certgroupRPS5_ +Security:single module:__ZN14AppleTPSession13buildX509NameEPK22CSSM_APPLE_TP_NAME_OIDj +Security:single module:__ZN14AppleTPSession12freeX509NameEP14cssm_x509_name +Security:single module:__ZN14AppleTPSession13buildX509TimeEj +Security:single module:__ZN14AppleTPSession12freeX509TimeEP14cssm_x509_time +Security:single module:__Z8intToDERmR9cssm_dataRN8Security13CssmAllocatorE +Security:single module:__Z8DERToIntRK9cssm_data +Security:single module:__ZN14AppleTPSession11refKeyToRawEmPK8cssm_keyPS0_ +Security:single module:__ZN14AppleTPSession16makeCertTemplateEmmmPK14cssm_x509_nameS2_PK14cssm_x509_timeS5_PK8cssm_keyRK9cssm_dataPSA_SC_P19cssm_x509_extensionjRPS9_ +Security:single module:__ZN14AppleTPSession12addCertToMapEPK9cssm_dataPS0_ +Security:single module:__ZN14AppleTPSession14getCertFromMapEPK9cssm_data +Security:single module:__ZN14AppleTPSession16SubmitCsrRequestERK19cssm_tp_request_setRlRN8Security8CssmDataE +Security:single module:__ZN14AppleTPSession17SubmitCredRequestEPK20cssm_tp_authority_idmRK19cssm_tp_request_setPK26cssm_tp_callerauth_contextRlRN8Security8CssmDataE +Security:single module:__ZThn40_N14AppleTPSession17SubmitCredRequestEPK20cssm_tp_authority_idmRK19cssm_tp_request_setPK26cssm_tp_callerauth_contextRlRN8Security8CssmDataE +Security:single module:__ZN14AppleTPSession18RetrieveCredResultERKN8Security8CssmDataEPK26cssm_tp_callerauth_contextRlS7_RP18cssm_tp_result_set +Security:single module:__ZThn40_N14AppleTPSession18RetrieveCredResultERKN8Security8CssmDataEPK26cssm_tp_callerauth_contextRlS7_RP18cssm_tp_result_set +Security:single module:__Z26tpGetFirstCachedFieldValuemmPK9cssm_dataPmS2_PPS_ +Security:single module:__ZN10TPCrlGroup10crlAtIndexEj +Security:single module:__ZN10TPCrlGroup14findCrlForCertER10TPCertInfo +Security:single module:__ZN10TPCrlGroup16removeCrlAtIndexEj +Security:single module:__ZN10TPCrlGroup7lastCrlEv +Security:single module:__ZN10TPCrlGroup8firstCrlEv +Security:single module:__ZN10TPCrlGroup9appendCrlER9TPCrlInfo +Security:single module:__ZN10TPCrlGroup9removeCrlER9TPCrlInfo +Security:single module:__ZN10TPCrlGroupC1EPK13cssm_crlgroupmmRN8Security13CssmAllocatorEPKc12TPGroupOwner +Security:single module:__ZN10TPCrlGroupC1ERN8Security13CssmAllocatorE12TPGroupOwner +Security:single module:__ZN10TPCrlGroupC2EPK13cssm_crlgroupmmRN8Security13CssmAllocatorEPKc12TPGroupOwner +Security:single module:__ZN10TPCrlGroupC2ERN8Security13CssmAllocatorE12TPGroupOwner +Security:single module:__ZN10TPCrlGroupC4ERN8Security13CssmAllocatorE12TPGroupOwner +Security:single module:__ZN10TPCrlGroupD2Ev +Security:single module:__ZN9TPCrlInfo13hasSameIssuerERK10TPCertInfo +Security:single module:__ZN9TPCrlInfo13isCertRevokedER10TPCertInfo +Security:single module:__ZN9TPCrlInfo15parseExtensionsER18TPCrlVerifyContextbmRK20cssm_x509_extensionsP10TPCertInfoRb +Security:single module:__ZN9TPCrlInfo16releaseResourcesEv +Security:single module:__ZN9TPCrlInfo17verifyWithContextER18TPCrlVerifyContextP10TPCertInfob +Security:single module:__ZN9TPCrlInfo3uriERK9cssm_data +Security:single module:__ZN9TPCrlInfoC1EmmPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN9TPCrlInfoC2EmmPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN9TPCrlInfoC4EmmPK9cssm_data10TPItemCopyPKc +Security:single module:__ZN9TPCrlInfoD1Ev +Security:single module:__ZN9TPCrlInfoD2Ev +Security:single module:__ZN9TPCrlInfoD4Ev +Security:single module:__ZN11DecodedCert16encodeExtensionsEv +Security:single module:__ZN11DecodedCert9decodeTbsERKN8Security8CssmDataE +Security:single module:__ZN11DecodedCert9encodeTbsERN8Security13CssmOwnedDataE +Security:single module:__ZN11DecodedCertC1ER18AppleX509CLSession +Security:single module:__ZN11DecodedCertC2ER18AppleX509CLSession +Security:single module:__ZN11DecodedCertC2ER18AppleX509CLSessionRKN8Security8CssmDataE +Security:single module:__ZN11DecodedCertC4ER18AppleX509CLSession +Security:single module:__ZN11DecodedCertD2Ev +Security:single module:__Z10CL_reallocPvmS_ +Security:single module:__Z7CL_freePvS_ +Security:single module:__Z9CL_callocmmPv +Security:single module:__Z9CL_mallocmPv +Security:single module:__ZN11CSPAttacherD1Ev +Security:single module:__ZN11CSPAttacherD2Ev +Security:single module:__ZN11CSPAttacherD4Ev +Security:single module:__Z16getField_VersionR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z16setField_VersionR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z15getField_IssuerR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z15setField_IssuerR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z19getField_ThisUpdateR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z19setField_ThisUpdateR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z19getField_NextUpdateR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z19setField_NextUpdateR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z18getFieldIssuerNormR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z20getField_CrlTbsAlgIdR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z21nssRevokedEntryToCssmR15NSS_RevokedCertR28cssm_x509_revoked_cert_entryRN8Security13CssmAllocatorE +Security:single module:__Z13freeCssmEntryP28cssm_x509_revoked_cert_entryRN8Security13CssmAllocatorE +Security:single module:__Z20nssRevokedListToCssmPP15NSS_RevokedCertP27cssm_x509_revoked_cert_listRN8Security13CssmAllocatorE +Security:single module:__Z19freeCssmRevokedListP27cssm_x509_revoked_cert_listRN8Security13CssmAllocatorE +Security:single module:__Z18getField_SignedCrlR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z18setField_SignedCrlR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z19freeField_SignedCrlRN8Security13CssmOwnedDataE +Security:single module:__Z11oidToFieldsRKN8Security8CssmDataE +Security:single module:__Z19CL_freeCrlFieldDataRKN8Security8CssmDataERNS_13CssmOwnedDataEb +Security:single module:__Z21CL_freeCssmExtensionsR20cssm_x509_extensionsRN8Security13CssmAllocatorE +Security:single module:__ZN10DecodedCrl15getCrlFieldDataERKN8Security8CssmDataEjRmRNS0_13CssmOwnedDataE +Security:single module:__ZN10DecodedCrl11setCrlFieldERKN8Security8CssmDataES3_ +Security:single module:__ZN10DecodedCrl16freeCrlFieldDataERKN8Security8CssmDataERNS0_13CssmOwnedDataE +Security:single module:__ZN10DecodedCrl21getAllParsedCrlFieldsERmRP10cssm_field +Security:single module:__ZN10DecodedCrl14describeFormatERN8Security13CssmAllocatorERmRP9cssm_data +Security:single module:__ZN10DecodedCrlC2ER18AppleX509CLSession +Security:single module:__ZN10DecodedCrlC1ER18AppleX509CLSession +Security:single module:__ZN10DecodedCrlC4ER18AppleX509CLSession +Security:single module:__ZN10DecodedCrlC2ER18AppleX509CLSessionRKN8Security8CssmDataE +Security:single module:__ZN10DecodedCrlC1ER18AppleX509CLSessionRKN8Security8CssmDataE +Security:single module:__ZN10DecodedCrlC4ER18AppleX509CLSessionRKN8Security8CssmDataE +Security:single module:__ZN10DecodedCrlD2Ev +Security:single module:__ZN10DecodedCrlD1Ev +Security:single module:__ZN10DecodedCrlD0Ev +Security:single module:__ZN10DecodedCrlD4Ev +Security:single module:__ZN10DecodedCrl9decodeCtsERKN8Security8CssmDataE +Security:single module:__ZN10DecodedCrl16encodeExtensionsEv +Security:single module:__ZN10DecodedCrl9encodeCtsERN8Security13CssmOwnedDataE +Security:single module:__Z15getField_IssuerR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z15setField_IssuerR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z16getField_VersionR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z16setField_SubjectR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z16setField_VersionR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z17getFieldIssuerStdR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z17setField_NotAfterR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z17setField_TbsAlgIdR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z18getFieldSubjectStdR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z18getField_CertAlgIdR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z18getField_SignatureR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z18setField_NotBeforeR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z21getField_SerialNumberR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z21setField_SerialNumberR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z22getField_PublicKeyInfoR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z22setField_PublicKeyInfoR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z23freeField_PublicKeyInfoRN8Security13CssmOwnedDataE +Security:single module:__Z23getField_IssuerUniqueIdR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z23setField_IssuerUniqueIdR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z24getField_PublicKeyStructR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z24getField_SubjectUniqueIdR11DecodedItemjRmRN8Security13CssmOwnedDataE +Security:single module:__Z24setField_PublicKeyStructR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z24setField_SubjectUniqueIdR11DecodedItemRKN8Security8CssmDataE +Security:single module:__Z25freeField_PublicKeyStructRN8Security13CssmOwnedDataE +Security:single module:__ZN11DecodedCert12setCertFieldERKN8Security8CssmDataES3_ +Security:single module:__ZN11DecodedCert14describeFormatERN8Security13CssmAllocatorERmRP9cssm_data +Security:single module:__ZN11DecodedCert22getAllParsedCertFieldsERmRP10cssm_field +Security:single module:__ZN18AppleX509CLSession11generateCsrEyPK25CSSM_APPLE_CL_CSR_REQUESTRP9cssm_data +Security:single module:__ZN18AppleX509CLSession9verifyCsrEPK9cssm_data +Security:single module:__ZN12SSMACContext10outputSizeEbm +Security:single module:__ZN12SSMACContext4initERKN8Security7ContextEb +Security:single module:__ZN12SSMACContext5finalERKN8Security8CssmDataE +Security:single module:__ZN12SSMACContext5finalERN8Security8CssmDataE +Security:single module:__ZN12SSMACContext6genMacERN8Security8CssmDataE +Security:single module:__ZN12SSMACContext6updateERKN8Security8CssmDataE +Security:single module:__ZN12SSMACContextC1ER12SSCSPSession +Security:single module:__ZN12SSMACContextC2ER12SSCSPSession +Security:single module:__ZN12SSMACContextC4ER12SSCSPSession +Security:single module:__ZN14SSCryptContext15minimumProgressERmS0_ +Security:single module:__ZN14SSCryptContextC2ER12SSCSPSession +Security:single module:__ZN14SSCryptContextD1Ev +Security:single module:__ZN14SSCryptContextD2Ev +Security:single module:__ZN15SSDigestContext10outputSizeEbm +Security:single module:__ZN15SSDigestContext4initERKN8Security7ContextEb +Security:single module:__ZN15SSDigestContext5finalERN8Security8CssmDataE +Security:single module:__ZN15SSDigestContext6updateERKN8Security8CssmDataE +Security:single module:__ZN15SSDigestContextC1ER12SSCSPSession +Security:single module:__ZN15SSDigestContextC2ER12SSCSPSession +Security:single module:__ZN15SSDigestContextC4ER12SSCSPSession +Security:single module:__ZN15SSDigestContextD0Ev +Security:single module:__ZN15SSDigestContextD1Ev +Security:single module:__ZN15SSDigestContextD2Ev +Security:single module:__ZN15SSDigestContextD4Ev +Security:single module:__ZN15SSRandomContext10outputSizeEbm +Security:single module:__ZN15SSRandomContext4initERKN8Security7ContextEb +Security:single module:__ZN15SSRandomContext5finalERN8Security8CssmDataE +Security:single module:__ZN15SSRandomContextC1ER12SSCSPSession +Security:single module:__ZN15SSRandomContextC2ER12SSCSPSession +Security:single module:__ZN15SSRandomContextC4ER12SSCSPSession +Security:single module:__ZN18SSSignatureContext10outputSizeEbm +Security:single module:__ZN18SSSignatureContext18setDigestAlgorithmEm +Security:single module:__ZN18SSSignatureContext4initERKN8Security7ContextEb +Security:single module:__ZN18SSSignatureContext4signERN8Security8CssmDataE +Security:single module:__ZN18SSSignatureContext5finalERKN8Security8CssmDataE +Security:single module:__ZN18SSSignatureContext5finalERN8Security8CssmDataE +Security:single module:__ZN18SSSignatureContext6updateERKN8Security8CssmDataE +Security:single module:__ZN18SSSignatureContextC1ER12SSCSPSession +Security:single module:__ZN18SSSignatureContextC2ER12SSCSPSession +Security:single module:__ZN18SSSignatureContextC4ER12SSCSPSession +Security:single module:__ZN18SSSignatureContextD0Ev +Security:single module:__ZN18SSSignatureContextD1Ev +Security:single module:__ZN18SSSignatureContextD2Ev +Security:single module:__ZN18SSSignatureContextD4Ev +Security:single module:__ZN9SSContextC1ER12SSCSPSession +Security:single module:_key_perm +Security:single module:_keybyte +Security:single module:_keynybble +Security:single module:_keyHash +Security:single module:_mallocCodeBufs +Security:single module:_initCodeBufs +Security:single module:_freeCodeBufs +Security:single module:_serializeInt +Security:single module:_deserializeInt +Security:single module:_initSigSequence +Security:single module:_sigMunge +Security:single module:_ascMalloc +Security:single module:_ascFree +Security:single module:_BN_add_word +Security:single module:_BN_div_word +Security:single module:_BN_mod_word +Security:single module:_BN_mul_word +Security:single module:_sha1DigestLen +Security:single module:__ZN12BlockCryptor15minimumProgressERmS0_ +Security:single module:__ZN12BlockCryptorD0Ev +Security:single module:__ZN12BlockCryptorD1Ev +Security:single module:_initFromRS +Security:single module:_feeFEEDNewWithPubKey +Security:single module:_feeFEEDFree +Security:single module:_feeFEEDPlainBlockSize +Security:single module:_feeFEEDCipherBlockSize +Security:single module:_feeFEEDCipherBufSize +Security:single module:_feeFEEDCipherTextSize +Security:single module:_feeFEEDPlainTextSize +Security:single module:_feeFEEDEncryptBlock +Security:single module:_feeFEEDDecryptBlock +Security:single module:_feeFEEDEncrypt +Security:single module:_feeFEEDDecrypt +Security:single module:_feeFEEDExpNewWithPubKey +Security:single module:_feeFEEDExpFree +Security:single module:_feeFEEDExpPlainBlockSize +Security:single module:_feeFEEDExpCipherBlockSize +Security:single module:_feeFEEDExpCipherBufSize +Security:single module:_feeFEEDExpCipherTextSize +Security:single module:_feeFEEDExpPlainTextSize +Security:single module:_feeFEEDExpEncryptBlock +Security:single module:_feeFEEDExpDecryptBlock +Security:single module:_feeFEEDExpEncrypt +Security:single module:_feeFEEDExpDecrypt +Security:single module:_feeECDSASign +Security:single module:_feeECDSAVerify +Security:single module:_ECDSA_encode +Security:single module:_ECDSA_decode +Security:single module:_feeECDSASigSize +Security:single module:_sinstAlloc +Security:single module:_feeSigNewWithKey +Security:single module:_feeSigFree +Security:single module:_feeSigPm +Security:single module:_feeSigSign +Security:single module:_feeSigData +Security:single module:_feeSigParse +Security:single module:_borrowPointProj +Security:single module:_returnPointProj +Security:single module:_feeSigVerify +Security:single module:_feeSigVerifyNoProj +Security:single module:_feeSigSize +Security:single module:_CKRaise +Security:single module:_createRandomSeed +Security:single module:_borrowGiant +Security:single module:_returnGiant +Security:single module:_freeGiant +Security:single module:_newGiant +Security:single module:_copyGiant +Security:single module:_bitlen +Security:single module:_bitval +Security:single module:_gsign +Security:single module:_gtrimSign +Security:single module:_isone +Security:single module:_isZero +Security:single module:_gcompg +Security:single module:_gtog +Security:single module:_int_to_giant +Security:single module:_negg +Security:single module:_iaddg +Security:single module:_imulg +Security:single module:_normal_addg +Security:single module:_normal_subg +Security:single module:_reverse_subg +Security:single module:_addg +Security:single module:_subg +Security:single module:_bdivg +Security:single module:_binvaux +Security:single module:_absg +Security:single module:_gshiftleft +Security:single module:_gshiftright +Security:single module:_extractbits +Security:single module:_gmersennemod +Security:single module:_mulg +Security:single module:_grammarSquare +Security:single module:_clearGiant +Security:single module:_make_recip +Security:single module:_divg_via_recip +Security:single module:_modg_via_recip +Security:single module:_modg +Security:single module:_divg +Security:single module:_DSA_SIG_new +Security:single module:_DSA_SIG_free +Security:single module:_DSA_do_sign +Security:single module:_DSA_sign_setup +Security:single module:_DSA_do_verify +Security:single module:_MD2_Update +Security:single module:_md2_block +Security:single module:_MD2_options +Security:single module:_MD2_Init +Security:single module:_MD2_Final +Security:single module:_ERR_get_state +Security:single module:_ERR_add_error_data +Security:single module:_ERR_load_ERR_strings +Security:single module:_ERR_load_strings +Security:single module:_ERR_free_strings +Security:single module:_ERR_put_error +Security:single module:_ERR_clear_error +Security:single module:_ERR_get_error +Security:single module:_ERR_get_error_line +Security:single module:_ERR_get_error_line_data +Security:single module:_ERR_peek_error +Security:single module:_ERR_peek_error_line +Security:single module:_ERR_peek_error_line_data +Security:single module:_ERR_error_string +Security:single module:_ERR_get_string_table +Security:single module:_ERR_get_err_state_table +Security:single module:_ERR_lib_error_string +Security:single module:_ERR_func_error_string +Security:single module:_ERR_reason_error_string +Security:single module:_ERR_remove_state +Security:single module:_ERR_get_next_error_library +Security:single module:_ERR_set_error_data +Security:single module:_err_hash +Security:single module:_err_cmp +Security:single module:_pid_hash +Security:single module:_pid_cmp +Security:single module:_get_error_values +Security:single module:_CRYPTO_get_add_lock_callback +Security:single module:_CRYPTO_get_id_callback +Security:single module:_CRYPTO_get_locking_callback +Security:single module:_CRYPTO_get_new_lockid +Security:single module:_CRYPTO_lock +Security:single module:_CRYPTO_num_locks +Security:single module:_CRYPTO_set_add_lock_callback +Security:single module:_CRYPTO_set_id_callback +Security:single module:_CRYPTO_set_locking_callback +Security:single module:_CRYPTO_thread_id +Security:single module:_CRYPTO_dup_ex_data +Security:single module:_CRYPTO_get_ex_data +Security:single module:_CRYPTO_get_ex_new_index +Security:single module:_CRYPTO_set_ex_data +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_delete +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_delete_ptr +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_dup +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_find +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_free +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_insert +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_new +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_new_null +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_num +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_pop +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_pop_free +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_push +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_set +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_shift +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_sort +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_unshift +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_value +Security:single module:_sk_CRYPTO_EX_DATA_FUNCS_zero +Security:single module:_BN_CTX_init +Security:single module:_BN_MONT_CTX_copy +Security:single module:_BN_MONT_CTX_init +Security:single module:_BN_exp +Security:single module:_BN_mod_exp +Security:single module:_BN_mod_exp_mont_word +Security:single module:_BN_mod_exp_recp +Security:single module:_BN_mod_exp_simple +Security:single module:_BN_mod_mul +Security:single module:_BN_rand_range +Security:single module:_BN_rand +Security:single module:_BN_pseudo_rand +Security:single module:_BN_bntest_rand +Security:single module:_bnrand +Security:single module:_BN_generate_prime +Security:single module:_BN_is_prime_fasttest +Security:single module:_witness +Security:single module:_probable_prime +Security:single module:_probable_prime_dh +Security:single module:_probable_prime_dh_safe +Security:single module:_BN_is_prime +Security:single module:_dsa_do_sign +Security:single module:_dsa_sign_setup +Security:single module:_dsa_do_verify +Security:single module:_DSA_OpenSSL +Security:single module:_dsa_init +Security:single module:_dsa_finish +Security:single module:_dsa_mod_exp +Security:single module:_dsa_bn_mod_exp +Security:single module:_BN_lshift1 +Security:single module:_BN_rshift1 +Security:single module:_BN_BLINDING_new +Security:single module:_BN_BLINDING_free +Security:single module:_BN_BLINDING_update +Security:single module:_BN_BLINDING_convert +Security:single module:_BN_BLINDING_invert +Security:single module:_BN_gcd +Security:single module:_euclid +Security:single module:_RSA_eay_mod_exp +Security:single module:_RSA_eay_private_decrypt +Security:single module:_RSA_eay_private_encrypt +Security:single module:_bn_mul_high +Security:single module:_bn_mul_low_normal +Security:single module:_bn_mul_low_recursive +Security:single module:_bn_mul_part_recursive +Security:single module:_intToByteRep +Security:single module:_shortToByteRep +Security:single module:_giantToByteRep +Security:single module:_keyToByteRep +Security:single module:_curveParamsToByteRep +Security:single module:_sigToByteRep +Security:single module:_lengthOfByteRepGiant +Security:single module:_lengthOfByteRepKey +Security:single module:_lengthOfByteRepCurveParams +Security:single module:_lengthOfByteRepSig +Security:single module:_byteRepToInt +Security:single module:_byteRepToShort +Security:single module:_byteRepToGiant +Security:single module:_byteRepToKey +Security:single module:_byteRepToCurveParams +Security:single module:_byteRepToSig +Security:single module:_arrayToGiant +Security:single module:_newCurveParams +Security:single module:_allocRecipGiants +Security:single module:_curveParamsForDepth +Security:single module:_curveParamsCopy +Security:single module:_freeCurveParams +Security:single module:_curveParamsEquivalent +Security:single module:_lesserX1Order +Security:single module:_curveParamsInferFields +Security:single module:_feeKeyBitsToDepth +Security:single module:_encChunk +Security:single module:_enc64 +Security:single module:_enc64WithLines +Security:single module:_stringCleanse +Security:single module:_dec64 +Security:single module:_isValidEnc64 +Security:single module:__ZN12feeExceptionC2E9feeReturnPKc +Security:single module:__ZN12feeExceptionC1E9feeReturnPKc +Security:single module:__ZN12feeExceptionC4E9feeReturnPKc +Security:single module:__ZN12feeException7throwMeE9feeReturnPKc +Security:single module:_feeSizeOfDERSig +Security:single module:_feeDEREncodeElGamalSignature +Security:single module:_feeDEREncodeECDSASignature +Security:single module:_feeDERDecodeElGamalSignature +Security:single module:_feeDERDecodeECDSASignature +Security:single module:_feeDEREncodePublicKey +Security:single module:_feeDEREncodePrivateKey +Security:single module:_feeDERDecodePublicKey +Security:single module:_feeDERDecodePrivateKey +Security:single module:__Z13cssmDataToIntRK9cssm_data +Security:single module:__Z13intToCssmDatajR9cssm_dataR11SecNssCoder +Security:single module:__Z15cssmDataToGiantRK9cssm_data +Security:single module:__Z15giantToCssmDataP11giantstructR9cssm_dataR11SecNssCoder +Security:single module:__Z20feeCurveParamsToASN1PK11curveParamsR22FEECurveParametersASN1R11SecNssCoder +Security:single module:__Z22feeCurveParamsFromAsn1RK22FEECurveParametersASN1 +Security:single module:_feeHashAlloc +Security:single module:_feeHashReinit +Security:single module:_feeHashFree +Security:single module:_feeHashAddData +Security:single module:_feeHashDigest +Security:single module:_feeHashDigestLen +Security:single module:_which_curve +Security:single module:_new_public +Security:single module:_new_public_with_key +Security:single module:_free_key +Security:single module:_set_priv_key_giant +Security:single module:_key_equal +Security:single module:_make_base +Security:single module:_make_base_prim +Security:single module:_sequalg +Security:single module:_elliptic_simple +Security:single module:_elliptic +Security:single module:_elliptic_add +Security:single module:_make_pad +Security:single module:_ell_even +Security:single module:_ell_odd +Security:single module:_keys_inconsistent +Security:single module:_signature_compare +Security:single module:_numer_double +Security:single module:_numer_plus +Security:single module:_denom_double +Security:single module:_denom_times +Security:single module:_numer_times +Security:single module:_feepowermodg +Security:single module:_curveOrderJustify +Security:single module:_curveOrderJustifyWithRecip +Security:single module:_lesserX1OrderJustify +Security:single module:_calcX1OrderPlusRecip +Security:single module:_x1OrderPlusJustify +Security:single module:_x1OrderPlusMod +Security:single module:_feemod +Security:single module:_calcGiantSizes +Security:single module:_giantMinBytes +Security:single module:_giantMaxDigits +Security:single module:_binvg_cp +Security:single module:_binvg_x1OrderPlus +Security:single module:_makeKey +Security:single module:_rijndaelBlockEncrypt +Security:single module:_rijndaelBlockDecrypt +Security:single module:_RC2_encrypt +Security:single module:_RC2_decrypt +Security:single module:_RC2_set_key +Security:single module:_RC5_32_encrypt +Security:single module:_RC5_32_decrypt +Security:single module:_RC5_32_set_key +Security:single module:_CAST_ecb_encrypt +Security:single module:_CAST_set_key +Security:single module:_BF_ecb_encrypt +Security:single module:_BF_options +Security:single module:_BF_set_key +Security:single module:_timeAtNowPlus +Security:single module:_tpTimeToCssmTimestring +Security:single module:__Z13tpNextDnsCompPKcRmPcS1_ +Security:single module:__Z14tpCompareCompsPKcmS0_m +Security:single module:__Z8tpSubStrPKcmS0_m +Security:single module:_tpCompareEmailAddr +Security:single module:_tpFreeCssmData +Security:single module:_tpMallocCopyCssmData +Security:single module:_tpNormalizeAddrSpec +Security:single module:_tpOidToAldId +Security:single module:_tp_CertFreeAlgId +Security:single module:_tp_CertFreePublicKey +Security:single module:_tp_CertGetAlgId +Security:single module:_tp_CertGetPublicKey +Security:single module:_tp_CompareCerts +Security:single module:__Z11tpCrlLookup17cssm_dl_db_handlePK9cssm_dataPcPmPS0_ +Security:single module:__Z12tpCertLookup17cssm_dl_db_handlePK9cssm_dataPmPS0_ +Security:single module:__Z14tpAddCrlSchema17cssm_dl_db_handle +Security:single module:__Z24tpSearchNumericExtensionPK20cssm_x509_extensionsPK9cssm_dataPm +Security:single module:_tpDbFindIssuerCrl +Security:single module:_tpDbStoreCrl +Security:single module:__Z13tpFetchViaNetRK9cssm_data7LF_TypeRN8Security13CssmAllocatorERS_ +Security:single module:__Z11tpCrlViaNetRK9cssm_dataR18TPCrlVerifyContextR10TPCertInfoRP9TPCrlInfo +Security:single module:__Z18tpIssuerCertViaNetRK9cssm_datammPKcR10TPCertInfoRPS4_ +Security:single module:__Z22tpFetchViaGeneralNamesPK15CE_GeneralNamesR10TPCertInfoP18TPCrlVerifyContextmmPKcPPS2_PP9TPCrlInfo +Security:single module:_tpFetchCrlFromNet +Security:single module:_tpFetchIssuerFromNet +Security:single module:__Z12tpDisposeCrlR9TPCrlInfoR18TPCrlVerifyContext +Security:single module:__Z16tpFindCrlForCertR10TPCertInfoRP9TPCrlInfoR18TPCrlVerifyContext +Security:single module:__ZN10TPCRLCache3addER9TPCrlInfo +Security:single module:__ZN10TPCRLCache6removeER9TPCrlInfo +Security:single module:__ZN10TPCRLCache6searchER10TPCertInfoR18TPCrlVerifyContext +Security:single module:__ZN10TPCRLCache7releaseER9TPCrlInfo +Security:single module:__ZN10TPCRLCacheC1Ev +Security:single module:__ZN10TPCRLCacheC2Ev +Security:single module:__ZN10TPCRLCacheC4Ev +Security:single module:__Z15tpCompIpAddrStrPKcjPK9cssm_data +Security:single module:__Z18tp_verifySmimeOptsR11TPCertGroupPK9cssm_dataRK13iSignCertInfo +Security:single module:_freeFieldCertPolicies +Security:single module:_freeFieldCrlDistPoints +Security:single module:_freeFieldSubjIssuerAltName +Security:single module:_getFieldCertPolicies +Security:single module:_getFieldCrlDistPoints +Security:single module:_getFieldIssuerAltName +Security:single module:_setFieldAuthorityKeyId +Security:single module:_setFieldBasicConstraints +Security:single module:_setFieldCertPolicies +Security:single module:_setFieldCrlDistPoints +Security:single module:_setFieldExtKeyUsage +Security:single module:_setFieldKeyUsage +Security:single module:_setFieldNetscapeCertType +Security:single module:_setFieldSubjIssuerAltName +Security:single module:_setFieldSubjectKeyId +Security:single module:_setFieldCrlNumber +Security:single module:__Z17getFieldCrlCommonR11DecodedItemRK9cssm_datajRmRN8Security13CssmOwnedDataE +Security:single module:_getFieldCrlNumber +Security:single module:_getFieldDeltaCrl +Security:single module:_freeFieldIssuingDistPoint +Security:single module:_freeFieldOidOrData +Security:single module:_bn_mul_comba4 +Security:single module:_bn_sqr_comba4 +Security:single module:_bn_sqr_words +Security:single module:_pmod +Security:single module:_feeRandAllocWithSeed +Security:single module:_feeRandAlloc +Security:single module:_feeRandFree +Security:single module:_feeRandNextNum +Security:single module:_feeRandBytes +Security:single module:_feeRandAddEntropy +Security:single module:_newPointProj +Security:single module:_freePointProj +Security:single module:_ptopProj +Security:single module:_ellDoubleProj +Security:single module:_ellAddProj +Security:single module:_ellNegProj +Security:single module:_ellSubProj +Security:single module:_ellMulProjSimple +Security:single module:_ellMulProj +Security:single module:_normalizeProj +Security:single module:_jacobi_symbol +Security:single module:_powFp2 +Security:single module:_powermodg +Security:single module:_sqrtmod +Security:single module:_findPointProj +Security:single module:_giantAddDigits +Security:single module:_giantAddDouble +Security:single module:_giantSubDigits +Security:single module:_giantMulDigits +Security:single module:_VectorMultiply +Security:single module:_lh_new +Security:single module:_lh_insert +Security:single module:_expand +Security:single module:_getrn +Security:single module:_lh_free +Security:single module:_lh_delete +Security:single module:_lh_retrieve +Security:single module:_lh_doall +Security:single module:_lh_doall_arg +Security:single module:_lh_strhash +Security:single module:_lh_num_items +Security:single module:_contract +Security:single module:_BUF_MEM_grow +Security:single module:_BUF_MEM_new +Security:single module:_BUF_MEM_free +Security:single module:_BUF_strdup +Security:single module:_sk_insert +Security:single module:_sk_set_cmp_func +Security:single module:_sk_dup +Security:single module:_sk_new +Security:single module:_sk_delete_ptr +Security:single module:_sk_delete +Security:single module:_sk_find +Security:single module:_sk_push +Security:single module:_sk_unshift +Security:single module:_sk_shift +Security:single module:_sk_pop +Security:single module:_sk_zero +Security:single module:_sk_pop_free +Security:single module:_sk_free +Security:single module:_sk_num +Security:single module:_sk_value +Security:single module:_sk_set +Security:single module:_sk_sort +Security:single module:_bn_sqr_normal +Security:single module:_BN_div_recp +Security:single module:_BN_reciprocal +Security:single module:_BN_RECP_CTX_init +Security:single module:_BN_RECP_CTX_new +Security:single module:_BN_RECP_CTX_free +Security:single module:_BN_RECP_CTX_set +Security:single module:_BN_mod_mul_reciprocal +Security:single module:_BN_mod_exp2_mont +Security:single module:_RSA_padding_add_PKCS1_type_1 +Security:single module:_RSA_padding_check_PKCS1_type_2 +Security:single module:_RSA_padding_add_SSLv23 +Security:single module:_RSA_padding_check_SSLv23 +Security:single module:_RSA_padding_add_none +Security:single module:_RSA_padding_check_none +Security:single module:_rijndaelKeySched +Security:single module:_rijndaelEncrypt +Security:single module:_rijndaelDecrypt +Security:single module:_KeyAddition +Security:single module:_ShiftRow +Security:single module:_Substitution +Security:single module:_MixColumn +Security:single module:_InvMixColumn +Security:single module:_CAST_encrypt +Security:single module:_CAST_decrypt +Security:single module:_BF_encrypt +Security:single module:_BF_decrypt +Security:single module:_BF_cbc_encrypt diff --git a/Security.pbproj/project.pbxproj b/Security.pbproj/project.pbxproj index 3fd220cf..c3972482 100644 --- a/Security.pbproj/project.pbxproj +++ b/Security.pbproj/project.pbxproj @@ -10,6 +10,8 @@ 01FA81B1FFF2B54C11CD283A, 01FA8239FFF2B54C11CD283A, 0AD5441E0003C2C511CD296C, + C2EE0104044B56E700CA2E77, + C2EE0105044B56E700CA2E77, ); isa = PBXGroup; name = "Support Files"; @@ -121,7 +123,7 @@ ); buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 54.1.9; + DYLIB_CURRENT_VERSION = 163; FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\""; HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/BSafe.framework/Headers\" \"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/BSafe.framework/Headers\" \"$(SRCROOT)/AppleCSP\" \"$(SRCROOT)/AppleCSP/open_ssl\""; LIBRARY_STYLE = STATIC; @@ -143,7 +145,6 @@ productInstallPath = /usr/local/lib; productName = AppleCSP; productReference = 014880C7005EAE4D11CD283A; - shouldUseHeadermap = 1; }; 014880CF005EAE4D11CD283A = { buildActionMask = 2147483647; @@ -159,7 +160,6 @@ 014880F4005EB04411CD283A, 014880F5005EB04411CD283A, 014880F6005EB04411CD283A, - 014880F7005EB04411CD283A, 014880F8005EB04411CD283A, 014880F9005EB04411CD283A, 014880FA005EB04411CD283A, @@ -191,7 +191,6 @@ 169195B60094A63C7F000001, 169195B70094A63C7F000001, 169195DB0094A7427F000001, - 169195DC0094A7427F000001, 169195F40094A8577F000001, 169195F50094A8577F000001, 169195F60094A8577F000001, @@ -237,6 +236,21 @@ 9D29188B026B56DA00003D05, 9D29188D026B56DA00003D05, 9D291891026B8BBD00003D05, + 05F88FC50410032C00003D05, + 05F88FC70410032C00003D05, + 05F88FCB0410035B00003D05, + 05553B6D042F88F800003D05, + 05553B71042F892F00003D05, + 05553B75042F90DD00003D05, + 05D098CF043C6DD200003D05, + 057C0BB80456E16900BA3D3B, + 057C0BB90456E16900BA3D3B, + 057C0BBC0456E18300BA3D3B, + 057C0BC10457129200BA3D3B, + 057C0BCD04581E3300BA3D3B, + 057C0BCE04581E3300BA3D3B, + 057C0BD804581E6800BA3D3B, + 057C0BE00458299B00BA3D3B, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -253,7 +267,6 @@ 0148810D005EB04411CD283A, 0148810E005EB04411CD283A, 0148810F005EB04411CD283A, - 01488110005EB04411CD283A, 01488111005EB04411CD283A, 01488112005EB04411CD283A, 01488113005EB04411CD283A, @@ -332,7 +345,6 @@ 169195D50094A6FD7F000001, 169195D60094A6FD7F000001, 169195DD0094A7427F000001, - 169195DE0094A7427F000001, 256C38B20094AE787F000001, 256C38B30094AE787F000001, 256C38B70094B96F7F000001, @@ -365,6 +377,21 @@ 9D29188A026B56DA00003D05, 9D29188C026B56DA00003D05, 9D291890026B8BBD00003D05, + 05F88FC40410032C00003D05, + 05F88FC60410032C00003D05, + 05F88FCA0410035B00003D05, + 05553B6C042F88F800003D05, + 05553B70042F892F00003D05, + 05553B74042F90DD00003D05, + 05D098D1043C6DE300003D05, + 057C0BB60456E16900BA3D3B, + 057C0BB70456E16900BA3D3B, + 057C0BBA0456E16900BA3D3B, + 057C0BC00457129200BA3D3B, + 057C0BCA04581E3300BA3D3B, + 057C0BCB04581E3300BA3D3B, + 057C0BCC04581E3300BA3D3B, + 057C0BDF0458299B00BA3D3B, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -392,7 +419,7 @@ ); buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 54.1.9; + DYLIB_CURRENT_VERSION = 163; LIBRARY_STYLE = STATIC; OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; OTHER_CFLAGS = "-DVDADER_RULES"; @@ -412,7 +439,6 @@ productInstallPath = /usr/local/lib; productName = AppleCSPDL; productReference = 014880C9005EAE4D11CD283A; - shouldUseHeadermap = 1; }; 014880D5005EAE4D11CD283A = { buildActionMask = 2147483647; @@ -471,7 +497,7 @@ ); buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 54.1.9; + DYLIB_CURRENT_VERSION = 163; LIBRARY_STYLE = STATIC; OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; OTHER_CFLAGS = ""; @@ -491,7 +517,6 @@ productInstallPath = /usr/local/lib; productName = AppleFileDL; productReference = 014880C8005EAE4D11CD283A; - shouldUseHeadermap = 1; }; 014880DB005EAE4D11CD283A = { buildActionMask = 2147483647; @@ -532,7 +557,8 @@ ); buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 54.1.9; + DYLIB_CURRENT_VERSION = 163; + FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\""; LIBRARY_STYLE = STATIC; OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; OTHER_CFLAGS = "-DVDADER_RULES"; @@ -552,13 +578,11 @@ productInstallPath = /usr/local/lib; productName = AppleX509CL; productReference = 014880CA005EAE4D11CD283A; - shouldUseHeadermap = 1; }; 014880E1005EAE4D11CD283A = { buildActionMask = 2147483647; files = ( 0148813B005EB04411CD283A, - 0148813C005EB04411CD283A, 0148813D005EB04411CD283A, 0148813E005EB04411CD283A, 0148813F005EB04411CD283A, @@ -566,7 +590,13 @@ 01488141005EB04411CD283A, 01488142005EB04411CD283A, 01488143005EB04411CD283A, - 01488144005EB04411CD283A, + 9D347A410380197600003D05, + 9D347A430380197600003D05, + 9D347A460380197600003D05, + 9D347A480380197600003D05, + 9D347A4A0380197600003D05, + 05F88FD1041003A500003D05, + 05F88FD3041003A500003D05, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -575,19 +605,24 @@ buildActionMask = 2147483647; files = ( 01488145005EB04411CD283A, - 01488146005EB04411CD283A, 01488147005EB04411CD283A, 01488148005EB04411CD283A, 01488149005EB04411CD283A, 0148814A005EB04411CD283A, - 0148814B005EB04411CD283A, 0148814C005EB04411CD283A, 0148814D005EB04411CD283A, 0148814E005EB04411CD283A, 0148814F005EB04411CD283A, 01488150005EB04411CD283A, - 01488151005EB04411CD283A, F540EDC3027A41BF01CA2E66, + 9D347A400380197600003D05, + 9D347A420380197600003D05, + 9D347A440380197600003D05, + 9D347A450380197600003D05, + 9D347A470380197600003D05, + 9D347A490380197600003D05, + 05F88FD0041003A500003D05, + 05F88FD2041003A500003D05, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -615,7 +650,8 @@ ); buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 54.1.9; + DYLIB_CURRENT_VERSION = 163; + FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\""; LIBRARY_STYLE = STATIC; OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; OTHER_CFLAGS = "-DVDADER_RULES"; @@ -635,7 +671,6 @@ productInstallPath = /usr/local/lib; productName = AppleX509TP; productReference = 014880CB005EAE4D11CD283A; - shouldUseHeadermap = 1; }; 014880E7005EAE4D11CD283A = { buildActionMask = 2147483647; @@ -648,6 +683,10 @@ 01488157005EB04411CD283A, 01488158005EB04411CD283A, 01488159005EB04411CD283A, + 9D347A54038019EF00003D05, + 9D347A56038019EF00003D05, + 9D347A58038019EF00003D05, + 9D347A5A038019EF00003D05, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -658,13 +697,16 @@ 0148815A005EB04411CD283A, 0148815B005EB04411CD283A, 0148815C005EB04411CD283A, - 0148815D005EB04411CD283A, 01488161005EB04411CD283A, 01488162005EB04411CD283A, 01488163005EB04411CD283A, 9D4B1BC80156C2E500A17CD1, 9D14AC53020093D100003D05, 9D9AEFBB02B6BC6C00003D05, + 9D347A53038019EF00003D05, + 9D347A55038019EF00003D05, + 9D347A57038019EF00003D05, + 9D347A59038019EF00003D05, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -749,12 +791,6 @@ settings = { }; }; - 014880F7005EB04411CD283A = { - fileRef = 07A0F603005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; 014880F8005EB04411CD283A = { fileRef = 07A0F60A005DAEE111CD283A; isa = PBXBuildFile; @@ -893,12 +929,6 @@ settings = { }; }; - 01488110005EB04411CD283A = { - fileRef = 07A0F602005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; 01488111005EB04411CD283A = { fileRef = 07A0F604005DAEE111CD283A; isa = PBXBuildFile; @@ -1145,12 +1175,6 @@ settings = { }; }; - 0148813C005EB04411CD283A = { - fileRef = 07A0F6B3005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; 0148813D005EB04411CD283A = { fileRef = 07A0F6B5005DAEE111CD283A; isa = PBXBuildFile; @@ -1193,24 +1217,12 @@ settings = { }; }; - 01488144005EB04411CD283A = { - fileRef = 07A0F6C8005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; 01488145005EB04411CD283A = { fileRef = 07A0F6AD005DAEE111CD283A; isa = PBXBuildFile; settings = { }; }; - 01488146005EB04411CD283A = { - fileRef = 07A0F6B2005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; 01488147005EB04411CD283A = { fileRef = 07A0F6B4005DAEE111CD283A; isa = PBXBuildFile; @@ -1235,12 +1247,6 @@ settings = { }; }; - 0148814B005EB04411CD283A = { - fileRef = 07A0F6BD005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; 0148814C005EB04411CD283A = { fileRef = 07A0F6BF005DAEE111CD283A; isa = PBXBuildFile; @@ -1271,12 +1277,6 @@ settings = { }; }; - 01488151005EB04411CD283A = { - fileRef = 07A0F6C7005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; 01488152005EB04411CD283A = { fileRef = 07A0F6CC005DAEE111CD283A; isa = PBXBuildFile; @@ -1343,12 +1343,6 @@ settings = { }; }; - 0148815D005EB04411CD283A = { - fileRef = 07A0F6D5005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; 01488161005EB04411CD283A = { fileRef = 07A0F6DB005DAEE111CD283A; isa = PBXBuildFile; @@ -1388,48 +1382,56 @@ target = 01CE6B1DFFF2B33A11CD283A; }; 0149035400A9DC487F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = DES.c; path = MiscCSPAlgs/DES.c; refType = 4; }; 0149035500A9DC487F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = DES.h; path = MiscCSPAlgs/DES.h; refType = 4; }; 0149035600A9DC487F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = MD5.c; path = MiscCSPAlgs/MD5.c; refType = 4; }; 0149035700A9DC487F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = MD5.h; path = MiscCSPAlgs/MD5.h; refType = 4; }; 0149035800A9DC487F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = SHA1_priv.c; path = MiscCSPAlgs/SHA1_priv.c; refType = 4; }; 0149035900A9DC487F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = SHA1_priv.h; path = MiscCSPAlgs/SHA1_priv.h; refType = 4; }; 0149035A00A9DC487F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = SHA1.c; path = MiscCSPAlgs/SHA1.c; refType = 4; }; 0149035B00A9DC487F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = SHA1.h; path = MiscCSPAlgs/SHA1.h; @@ -1484,6 +1486,7 @@ }; }; 0149036400A9DF347F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = platform.h; path = MiscCSPAlgs/platform.h; @@ -1543,6 +1546,10 @@ 01FA8226FFF2B54C11CD283A, 01FA8229FFF2B54C11CD283A, 01FA8228FFF2B54C11CD283A, + 563FC2AC03F8454B0DCA289E, + 563FC2AD03F8454B0DCA289E, + 563FC2AE03F8454B0DCA289E, + 563FC2AF03F8454B0DCA289E, ); isa = PBXGroup; name = "Client Library"; @@ -1570,156 +1577,169 @@ refType = 4; }; 0177F269FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = CCallbackMgr.cp; refType = 4; }; 0177F26AFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = CCallbackMgr.h; refType = 4; }; 0177F27EFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdatetime.cpp; refType = 4; }; 0177F27FFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdatetime.h; refType = 4; }; - 0177F286FFFAA2D311CD283A = { - isa = PBXFileReference; - path = DefaultKeychain.cpp; - refType = 4; - }; - 0177F287FFFAA2D311CD283A = { - isa = PBXFileReference; - path = DefaultKeychain.h; - refType = 4; - }; 0177F28AFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DLDBListCFPref.cpp; refType = 4; }; 0177F28BFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DLDBListCFPref.h; refType = 4; }; 0177F290FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Globals.cpp; refType = 4; }; 0177F291FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Globals.h; refType = 4; }; 0177F292FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Item.cpp; refType = 4; }; 0177F293FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Item.h; refType = 4; }; 0177F29CFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCCursor.cpp; refType = 4; }; 0177F29DFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCCursor.h; refType = 4; }; 0177F29EFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCEventNotifier.cpp; refType = 4; }; 0177F29FFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCEventNotifier.h; refType = 4; }; 0177F2A0FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCEventObserver.cpp; refType = 4; }; 0177F2A1FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCEventObserver.h; refType = 4; }; 0177F2A2FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCExceptions.h; refType = 4; }; 0177F2B7FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Keychains.cpp; refType = 4; }; 0177F2B8FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Keychains.h; refType = 4; }; 0177F2C6FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = PrimaryKey.cpp; refType = 4; }; 0177F2C7FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = PrimaryKey.h; refType = 4; }; - 0177F2C9FFFAA2D311CD283A = { - isa = PBXFileReference; - path = Refs.h; - refType = 4; - }; 0177F2CCFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Schema.cpp; refType = 4; }; 0177F2CDFFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Schema.h; refType = 4; }; 0177F2D1FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychainAPI.cpp; refType = 4; }; 0177F2D2FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychainAPI.h; refType = 4; }; 0177F2D3FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychainAPIPriv.h; refType = 4; }; 0177F2D6FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = StorageManager.cpp; refType = 4; }; 0177F2D7FFFAA2D311CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = StorageManager.h; refType = 4; @@ -1742,15 +1762,6 @@ ); }; }; - 0177F2EEFFFAA2D311CD283A = { - fileRef = 0177F287FFFAA2D311CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; - }; 0177F2F0FFFAA2D311CD283A = { fileRef = 0177F28BFFFAA2D311CD283A; isa = PBXBuildFile; @@ -1832,15 +1843,6 @@ ); }; }; - 0177F317FFFAA2D311CD283A = { - fileRef = 0177F2C9FFFAA2D311CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; - }; 0177F319FFFAA2D311CD283A = { fileRef = 0177F2CDFFFAA2D311CD283A; isa = PBXBuildFile; @@ -1893,14 +1895,6 @@ ); }; }; - 0177F330FFFAA2D311CD283A = { - fileRef = 0177F286FFFAA2D311CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; 0177F332FFFAA2D311CD283A = { fileRef = 0177F28AFFFAA2D311CD283A; isa = PBXBuildFile; @@ -1990,11 +1984,13 @@ }; }; 0177F352FFFAC61911CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCUtilities.cpp; refType = 4; }; 0177F353FFFAC61911CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KCUtilities.h; refType = 4; @@ -2017,21 +2013,25 @@ }; }; 017A54F20094AAE57F000001 = { + fileEncoding = 30; isa = PBXFileReference; path = "https-proxy-protocol.h"; refType = 4; }; 017A54F30094AAE57F000001 = { + fileEncoding = 30; isa = PBXFileReference; path = "https-proxy-protocol.cpp"; refType = 4; }; 017B6CA6009748107F000001 = { + fileEncoding = 30; isa = PBXFileReference; path = buffers.cpp; refType = 4; }; 017B6CA7009748107F000001 = { + fileEncoding = 30; isa = PBXFileReference; path = buffers.h; refType = 4; @@ -2052,11 +2052,13 @@ }; }; 01827D09008CB8707F000001 = { + fileEncoding = 30; isa = PBXFileReference; path = "ftp-proxy-protocol.h"; refType = 4; }; 01827D0A008CB8707F000001 = { + fileEncoding = 30; isa = PBXFileReference; path = "ftp-proxy-protocol.cpp"; refType = 4; @@ -2098,14 +2100,16 @@ 125E8604FFF3D96711CD283A, 01FA8902FFF2BCA811CD283A, 01FA8903FFF2BCA811CD283A, + C2907DD7042BA6E300CA2E77, 01FA88F8FFF2BBEB11CD283A, 9DC1DF0F0299BCB400003D05, + 9D347AA10380366700003D05, + C227CDCC03E7173300CA2E77, 3283A53602B96AED05CA2E77, ); isa = PBXAggregateTarget; name = world; productName = world; - shouldUseHeadermap = 0; }; 01CE6B1CFFF2B31311CD283A = { isa = PBXTargetDependency; @@ -2128,13 +2132,14 @@ ); isa = PBXLegacyTarget; name = generate; + passBuildSettingsInEnvironment = 0; productName = generate; settingsToExpand = 6; settingsToPassInEnvironment = 1; settingsToPassOnCommandLine = 280; - shouldUseHeadermap = 0; }; 01D5634800974F7C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; name = openssl_pkcs7.h; path = openssl/openssl_pkcs7.h; @@ -2195,131 +2200,157 @@ refType = 4; }; 01FA7FE8FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = certextensions.h; refType = 4; }; 01FA7FE9FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssm.h; refType = 4; }; 01FA7FEAFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmaci.h; refType = 4; }; 01FA7FEBFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmapi.h; refType = 4; }; 01FA7FECFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmapple.h; refType = 4; }; 01FA7FEDFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmcli.h; refType = 4; }; 01FA7FEEFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmconfig.h; refType = 4; }; 01FA7FEFFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmcspi.h; refType = 4; }; 01FA7FF0FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdli.h; refType = 4; }; 01FA7FF1FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmerr.h; refType = 4; }; 01FA7FF2FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmkrapi.h; refType = 4; }; 01FA7FF3FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmkrspi.h; refType = 4; }; 01FA7FF4FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmspi.h; refType = 4; }; 01FA7FF5FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmtpi.h; refType = 4; }; 01FA7FF6FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmtype.h; refType = 4; }; 01FA7FF7FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = eisl.h; refType = 4; }; 01FA7FF8FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = emmspi.h; refType = 4; }; 01FA7FF9FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = emmtype.h; refType = 4; }; 01FA7FFAFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = mds.h; refType = 4; }; 01FA7FFBFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = mds_schema.h; refType = 4; }; 01FA7FFCFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidsalg.h; refType = 4; }; 01FA7FFDFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidsattr.h; refType = 4; }; 01FA7FFEFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidsbase.h; refType = 4; }; 01FA7FFFFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidscert.h; refType = 4; }; 01FA8000FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidscrl.h; refType = 4; }; 01FA8001FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = x509defs.h; refType = 4; @@ -2328,8 +2359,6 @@ children = ( 32623CFC024BBA3B05CA2E77, 01FA8004FFF2B54C11CD283A, - 01FA8005FFF2B54C11CD283A, - 01FA8006FFF2B54C11CD283A, 32867BAB02316C3905CA2E77, 32867BAC02316C3905CA2E77, 01FA8008FFF2B54C11CD283A, @@ -2368,156 +2397,175 @@ refType = 4; }; 01FA8004FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = aclclient.h; refType = 4; }; - 01FA8005FFF2B54C11CD283A = { - isa = PBXFileReference; - path = aclsupport.cpp; - refType = 4; - }; - 01FA8006FFF2B54C11CD283A = { - isa = PBXFileReference; - path = aclsupport.h; - refType = 4; - }; 01FA8008FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cryptoclient.cpp; refType = 4; }; 01FA8009FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cryptoclient.h; refType = 4; }; 01FA800AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cspclient.cpp; refType = 4; }; 01FA800BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cspclient.h; refType = 4; }; 01FA800CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmclient.cpp; refType = 4; }; 01FA800DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmclient.h; refType = 4; }; 01FA800EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = dlclient.cpp; refType = 4; }; 01FA800FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = dlclient.h; refType = 4; }; 01FA8010FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DLDBList.cpp; refType = 4; }; 01FA8011FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DLDBList.h; refType = 4; }; 01FA8012FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = genkey.cpp; refType = 4; }; 01FA8013FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = genkey.h; refType = 4; }; 01FA8014FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = keychainacl.cpp; refType = 4; }; 01FA8015FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = keychainacl.h; refType = 4; }; 01FA8016FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = keyclient.cpp; refType = 4; }; 01FA8017FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = keyclient.h; refType = 4; }; 01FA8018FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = macclient.cpp; refType = 4; }; 01FA8019FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = macclient.h; refType = 4; }; 01FA801AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = multidldb.cpp; refType = 4; }; 01FA801BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = multidldb.h; refType = 4; }; 01FA801CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = osxsigner.cpp; refType = 4; }; 01FA801DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = osxsigner.h; refType = 4; }; 01FA801EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = securestorage.cpp; refType = 4; }; 01FA801FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = securestorage.h; refType = 4; }; 01FA8020FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = signclient.cpp; refType = 4; }; 01FA8021FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = signclient.h; refType = 4; }; 01FA8022FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = wrapkey.cpp; refType = 4; }; 01FA8023FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = wrapkey.h; refType = 4; @@ -2547,86 +2595,103 @@ refType = 4; }; 01FA8027FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ACsession.h; refType = 4; }; 01FA8028FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = "c++plugin.h"; refType = 4; }; 01FA8029FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = CLsession.h; refType = 4; }; 01FA802AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = CSPsession.cpp; refType = 4; }; 01FA802BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = CSPsession.h; refType = 4; }; 01FA802CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = csputilities.cpp; refType = 4; }; 01FA802DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmplugin.cpp; refType = 4; }; 01FA802EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmplugin.h; refType = 4; }; 01FA802FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DLsession.cpp; refType = 4; }; 01FA8030FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DLsession.h; refType = 4; }; 01FA8031FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.cfg; refType = 4; }; 01FA8032FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.mk; refType = 4; }; 01FA8033FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.pl; refType = 4; }; 01FA8034FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = pluginsession.cpp; refType = 4; }; 01FA8035FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = pluginsession.h; refType = 4; }; 01FA8036FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = pluginspi.h; refType = 4; }; 01FA8037FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = TPsession.h; refType = 4; @@ -2668,6 +2733,8 @@ 01FA807AFFF2B54C11CD283A, 01FA807BFFF2B54C11CD283A, 9D8B6A2A015A48F500A17CD1, + F581A93B0316D96A01D50C4C, + F52A2F160316DA1901D50C4C, 01FA807CFFF2B54C11CD283A, 01FA807DFFF2B54C11CD283A, 01FA807EFFF2B54C11CD283A, @@ -2675,8 +2742,10 @@ 01FA8080FFF2B54C11CD283A, 01FA8081FFF2B54C11CD283A, 01FA8082FFF2B54C11CD283A, + 4EE175A40459EC6F0036F88D, 01FA8083FFF2B54C11CD283A, 01FA8084FFF2B54C11CD283A, + C2952B0C044B55BB00CA2E77, 01FA808DFFF2B54C11CD283A, 01FA8096FFF2B54C11CD283A, 01FA8097FFF2B54C11CD283A, @@ -2705,501 +2774,601 @@ refType = 4; }; 01FA803BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_any.cpp; refType = 4; }; 01FA803CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_any.h; refType = 4; }; 01FA803DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_codesigning.cpp; refType = 4; }; 01FA803EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_codesigning.h; refType = 4; }; 01FA803FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_comment.cpp; refType = 4; }; 01FA8040FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_comment.h; refType = 4; }; 01FA8043FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_password.cpp; refType = 4; }; 01FA8044FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_password.h; refType = 4; }; 01FA8045FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_process.cpp; refType = 4; }; 01FA8046FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_process.h; refType = 4; }; 01FA8047FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_threshold.cpp; refType = 4; }; 01FA8048FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = acl_threshold.h; refType = 4; }; 01FA8049FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = AppleDatabase.cpp; refType = 4; }; 01FA804AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = AppleDatabase.h; refType = 4; }; 01FA804BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = AtomicFile.cpp; refType = 4; }; 01FA804CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = AtomicFile.h; refType = 4; }; 01FA804DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = callback.cpp; refType = 4; }; 01FA804EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = callback.h; refType = 4; }; 01FA804FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = codesigning.cpp; refType = 4; }; 01FA8050FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = codesigning.h; refType = 4; }; 01FA8051FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = context.cpp; refType = 4; }; 01FA8052FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = context.h; refType = 4; }; 01FA8055FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmacl.cpp; refType = 4; }; 01FA8056FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmacl.h; refType = 4; }; 01FA8057FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmaclpod.cpp; refType = 4; }; 01FA8058FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmaclpod.h; refType = 4; }; 01FA8059FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmalloc.cpp; refType = 4; }; 01FA805AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmalloc.h; refType = 4; }; 01FA805BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmcred.cpp; refType = 4; }; 01FA805CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmcred.h; refType = 4; }; 01FA805DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdata.cpp; refType = 4; }; 01FA805EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdata.h; refType = 4; }; 01FA805FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdates.cpp; refType = 4; }; 01FA8060FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdates.h; refType = 4; }; 01FA8061FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdb.cpp; refType = 4; }; 01FA8062FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmdb.h; refType = 4; }; 01FA8063FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmerrno.cpp; refType = 4; }; 01FA8064FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmerrno.h; refType = 4; }; 01FA8065FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmlist.cpp; refType = 4; }; 01FA8066FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmlist.h; refType = 4; }; 01FA8067FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmwalkers.cpp; refType = 4; }; 01FA8068FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmwalkers.h; refType = 4; }; 01FA8069FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = daemon.cpp; refType = 4; }; 01FA806AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = daemon.h; refType = 4; }; 01FA806BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Database.cpp; refType = 4; }; 01FA806CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Database.h; refType = 4; }; 01FA806DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DatabaseSession.cpp; refType = 4; }; 01FA806EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DatabaseSession.h; refType = 4; }; 01FA806FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbContext.cpp; refType = 4; }; 01FA8070FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbContext.h; refType = 4; }; 01FA8071FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbIndex.cpp; refType = 4; }; 01FA8072FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbIndex.h; refType = 4; }; 01FA8073FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbName.cpp; refType = 4; }; 01FA8074FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbName.h; refType = 4; }; 01FA8075FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbQuery.cpp; refType = 4; }; 01FA8076FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbQuery.h; refType = 4; }; 01FA8077FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbValue.cpp; refType = 4; }; 01FA8078FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = DbValue.h; refType = 4; }; 01FA8079FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = debugging.cpp; refType = 4; }; 01FA807AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = debugging.h; refType = 4; }; 01FA807BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = debugsupport.h; refType = 4; }; 01FA807CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.mk; refType = 4; }; 01FA807DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.pl; refType = 4; }; 01FA807EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = globalizer.cpp; refType = 4; }; 01FA807FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = globalizer.h; refType = 4; }; 01FA8080FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = guids.cpp; refType = 4; }; 01FA8081FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = handleobject.cpp; refType = 4; }; 01FA8082FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = handleobject.h; refType = 4; }; 01FA8083FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = logging.cpp; refType = 4; }; 01FA8084FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = logging.h; refType = 4; }; 01FA8085FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = "mach++.cpp"; refType = 4; }; 01FA8086FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = "mach++.h"; refType = 4; }; 01FA8087FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = mach_notify.c; refType = 4; }; 01FA8088FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = mach_notify.h; refType = 4; }; 01FA8089FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = machrunloopserver.cpp; refType = 4; }; 01FA808AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = machrunloopserver.h; refType = 4; }; 01FA808BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = machserver.cpp; refType = 4; }; 01FA808CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = machserver.h; refType = 4; }; 01FA808DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = memutils.h; refType = 4; }; 01FA808EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = MetaAttribute.cpp; refType = 4; }; 01FA808FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = MetaAttribute.h; refType = 4; }; 01FA8090FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = MetaRecord.cpp; refType = 4; }; 01FA8091FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = MetaRecord.h; refType = 4; }; 01FA8096FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = os9utils.cpp; refType = 4; }; 01FA8097FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = os9utils.h; refType = 4; }; 01FA8098FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = osxsigning.cpp; refType = 4; }; 01FA8099FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = osxsigning.h; refType = 4; }; 01FA809AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ReadWriteSection.h; refType = 4; }; 01FA809BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = refcount.h; refType = 4; }; 01FA809EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = SelectionPredicate.cpp; refType = 4; }; 01FA809FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = SelectionPredicate.h; refType = 4; }; 01FA80A0FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = threading.cpp; refType = 4; }; 01FA80A1FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = threading.h; refType = 4; }; 01FA80A2FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = tqueue.cpp; refType = 4; }; 01FA80A3FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = tqueue.h; refType = 4; }; 01FA80A4FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = utilities.cpp; refType = 4; }; 01FA80A5FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = utilities.h; refType = 4; }; 01FA80A6FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = utility_config.h; refType = 4; }; 01FA80A7FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = walkers.cpp; refType = 4; }; 01FA80A8FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = walkers.h; refType = 4; @@ -3239,333 +3408,411 @@ refType = 4; }; 01FA80ACFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = attachfactory.cpp; refType = 4; }; 01FA80ADFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = attachfactory.h; refType = 4; }; 01FA80AEFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = attachment.cpp; refType = 4; }; 01FA80AFFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = attachment.h; refType = 4; }; 01FA80B0FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cspattachment.cpp; refType = 4; }; 01FA80B1FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cspattachment.h; refType = 4; }; 01FA80B2FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssm.cpp; refType = 4; }; 01FA80B3FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmcontext.cpp; refType = 4; }; 01FA80B4FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmcontext.h; refType = 4; }; 01FA80B5FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmint.h; refType = 4; }; 01FA80B6FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmmds.cpp; refType = 4; }; 01FA80B7FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cssmmds.h; refType = 4; }; 01FA80B8FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.cfg; refType = 4; }; 01FA80B9FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.mk; refType = 4; }; 01FA80BAFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.pl; refType = 4; }; 01FA80BBFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = manager.cpp; refType = 4; }; 01FA80BCFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = manager.h; refType = 4; }; 01FA80BDFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = MDS; refType = 4; }; 01FA80BEFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = module.cpp; refType = 4; }; 01FA80BFFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = module.h; refType = 4; }; 01FA80C0FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidsalg.c; refType = 4; }; 01FA80C1FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidsattr.c; refType = 4; }; 01FA80C2FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidscert.cpp; refType = 4; }; 01FA80C3FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = oidscrl.cpp; refType = 4; }; 01FA80C4FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = transition.cpp; refType = 4; }; 01FA80C6FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = generator.mk; refType = 4; }; 01FA80D6FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = TODO; refType = 4; }; 01FA8126FFF2B54C11CD283A = { children = ( - 01FA8127FFF2B54C11CD283A, - 01FA8129FFF2B54C11CD283A, - 01FA812AFFF2B54C11CD283A, - 01FA812CFFF2B54C11CD283A, - 01FA812DFFF2B54C11CD283A, - 01FA812EFFF2B54C11CD283A, - 01FA812FFFF2B54C11CD283A, - 01FA8130FFF2B54C11CD283A, - 01FA8131FFF2B54C11CD283A, - 01FA8135FFF2B54C11CD283A, - 01FA8136FFF2B54C11CD283A, - 01FA8137FFF2B54C11CD283A, + 9D384F880301AFD800003D05, + 9D384F850301AF8C00003D05, 01FA8138FFF2B54C11CD283A, - 01FA8152FFF2B54C11CD283A, 01FA8153FFF2B54C11CD283A, - 01FA8156FFF2B54C11CD283A, - 01FA8158FFF2B54C11CD283A, - 01FA8159FFF2B54C11CD283A, - 01FA815AFFF2B54C11CD283A, - 01FA815BFFF2B54C11CD283A, - 01FA815CFFF2B54C11CD283A, - 01FA815DFFF2B54C11CD283A, - 01FA815EFFF2B54C11CD283A, - 01FA815FFFF2B54C11CD283A, - 01FA8161FFF2B54C11CD283A, - 01FA8162FFF2B54C11CD283A, - 01FA8163FFF2B54C11CD283A, - 01FA8164FFF2B54C11CD283A, - 01FA8165FFF2B54C11CD283A, - 01FA8166FFF2B54C11CD283A, - 01FA8167FFF2B54C11CD283A, - 9D78BC7401EBB71A00003D05, + 9D384F890301AFEC00003D05, + 9D384F8A0301B01900003D05, 33BD042000838F447F000001, - 9D78BC7801EBCA2300003D05, - 9D78BC7A01ECA79D00003D05, ); isa = PBXGroup; path = SecureTransport; refType = 4; }; 01FA8127FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = appleCdsa.cpp; refType = 4; }; 01FA8129FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = appleSession.cpp; refType = 4; }; 01FA812AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = cipherSpecs.cpp; + name = cipherSpecs.cpp; + path = SecureTransport/cipherSpecs.cpp; refType = 4; }; 01FA812CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sslDigests.cpp; + name = sslDigests.cpp; + path = SecureTransport/sslDigests.cpp; refType = 4; }; 01FA812DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslCert.cpp; refType = 4; }; 01FA812EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslChangeCipher.cpp; refType = 4; }; 01FA812FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslHandshakeFinish.cpp; refType = 4; }; 01FA8130FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslHandshakeHello.cpp; refType = 4; }; - 01FA8131FFF2B54C11CD283A = { + 01FA8132FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslKeyExchange.cpp; refType = 4; }; 01FA8135FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ModuleAttacher.cpp; refType = 4; }; 01FA8136FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = ModuleAttacher.h; - refType = 4; + name = ModuleAttacher.h; + path = SecureTransport/ModuleAttacher.h; + refType = 2; }; 01FA8137FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sslNullCipher.cpp; + name = sslNullCipher.cpp; + path = SecureTransport/sslNullCipher.cpp; refType = 4; }; 01FA8138FFF2B54C11CD283A = { children = ( + 01FA8136FFF2B54C11CD283A, 01FA8139FFF2B54C11CD283A, 01FA813BFFF2B54C11CD283A, 01FA813CFFF2B54C11CD283A, 01FA813DFFF2B54C11CD283A, + 01FA813EFFF2B54C11CD283A, 01FA8141FFF2B54C11CD283A, 01FA8142FFF2B54C11CD283A, + 01FA8143FFF2B54C11CD283A, + 01FA8144FFF2B54C11CD283A, 01FA8145FFF2B54C11CD283A, 01FA8146FFF2B54C11CD283A, + 01FA8147FFF2B54C11CD283A, 01FA8148FFF2B54C11CD283A, + 01FA814AFFF2B54C11CD283A, 01FA814BFFF2B54C11CD283A, 01FA814CFFF2B54C11CD283A, + 01FA814DFFF2B54C11CD283A, + 01FA814EFFF2B54C11CD283A, + 01FA8150FFF2B54C11CD283A, 01FA8151FFF2B54C11CD283A, 9D78BC7201EBB3F900003D05, 9D78BC7601EBBBED00003D05, - 9D98FF0C0371DDE400003D05, - 9D98FF0D0371DDE400003D05, - 9D98FF0E0371DDE400003D05, - 9D98FF0F0371DDE400003D05, - 9D98FF100371DDE400003D05, - 9D98FF110371DDE400003D05, - 9D98FF120371DDE400003D05, - 9D98FF130371DDE400003D05, - 9D98FF140371DDE400003D05, + 9DD4620003119BCE00003D05, ); isa = PBXGroup; + name = "Private Headers"; path = privateInc; refType = 4; }; 01FA8139FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = appleCdsa.h; refType = 4; }; 01FA813BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = appleSession.h; refType = 4; }; 01FA813CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cipherSpecs.h; refType = 4; }; 01FA813DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = cryptType.h; refType = 4; }; + 01FA813EFFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = sslDigests.h; + refType = 4; + }; 01FA8141FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ssl.h; refType = 4; }; 01FA8142FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2.h; refType = 4; }; + 01FA8143FFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = sslAlertMessage.h; + refType = 4; + }; + 01FA8144FFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = sslMemory.h; + refType = 4; + }; 01FA8145FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslBER.h; refType = 4; }; 01FA8146FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslBuildFlags.h; refType = 4; }; + 01FA8147FFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = sslContext.h; + refType = 4; + }; 01FA8148FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslDebug.h; refType = 4; }; + 01FA814AFFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = sslHandshake.h; + refType = 4; + }; 01FA814BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslKeychain.h; refType = 4; }; 01FA814CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslPriv.h; refType = 4; }; + 01FA814DFFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = sslRecord.h; + refType = 4; + }; + 01FA814EFFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = sslSession.h; + refType = 4; + }; + 01FA8150FFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = sslUtils.h; + refType = 4; + }; 01FA8151FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = symCipher.h; refType = 4; }; 01FA8152FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = README; refType = 4; @@ -3576,1355 +3823,1211 @@ 01FA8155FFF2B54C11CD283A, ); isa = PBXGroup; + name = "Public Headers"; path = SecureTransport; refType = 4; }; 01FA8154FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = CipherSuite.h; refType = 4; }; 01FA8155FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = SecureTransport.h; refType = 4; }; - 01FA8156FFF2B54C11CD283A = { - isa = PBXFileReference; - path = secureTransport.exp; - refType = 4; - }; 01FA8158FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2CipherMap.cpp; refType = 4; }; 01FA8159FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2Message.cpp; refType = 4; }; 01FA815AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2Protocol.cpp; refType = 4; }; 01FA815BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = ssl2Record.cpp; refType = 4; }; 01FA815CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslAlertMessage.cpp; refType = 4; }; 01FA815DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslMemory.cpp; refType = 4; }; 01FA815EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslBER.cpp; refType = 4; }; 01FA815FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslContext.cpp; refType = 4; }; 01FA8161FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslHandshake.cpp; refType = 4; }; 01FA8162FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslKeychain.cpp; refType = 4; }; 01FA8163FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslRecord.cpp; refType = 4; }; 01FA8164FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslSession.cpp; refType = 4; }; 01FA8165FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslTransport.cpp; refType = 4; }; 01FA8166FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = sslUtils.cpp; refType = 4; }; 01FA8167FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = symCipher.cpp; - refType = 4; - }; - 01FA8168FFF2B54C11CD283A = { - children = ( - 01FA8169FFF2B54C11CD283A, - 01FA817CFFF2B54C11CD283A, - 01FA818CFFF2B54C11CD283A, - 01FA819CFFF2B54C11CD283A, - ); - isa = PBXGroup; - path = SecurityASN1; + name = symCipher.cpp; + path = SecureTransport/symCipher.cpp; refType = 4; }; - 01FA8169FFF2B54C11CD283A = { + 01FA819DFFF2B54C11CD283A = { children = ( - 4EB202DD0058585F7F000001, - 01FA816AFFF2B54C11CD283A, - 01FA816BFFF2B54C11CD283A, - 01FA816CFFF2B54C11CD283A, - 01FA816DFFF2B54C11CD283A, - 01FA816EFFF2B54C11CD283A, - 01FA816FFFF2B54C11CD283A, - 01FA8170FFF2B54C11CD283A, - F540EDC4027A41E201CA2E66, - 01FA8171FFF2B54C11CD283A, - 01FA8172FFF2B54C11CD283A, - 01FA8173FFF2B54C11CD283A, - 01FA8174FFF2B54C11CD283A, - 01FA8175FFF2B54C11CD283A, - 01FA8176FFF2B54C11CD283A, - 01FA8177FFF2B54C11CD283A, - 01FA8178FFF2B54C11CD283A, - 01FA8179FFF2B54C11CD283A, - 01FA817AFFF2B54C11CD283A, - 01FA817BFFF2B54C11CD283A, + 01FA8214FFF2B54C11CD283A, + 01FA821EFFF2B54C11CD283A, + 01FA81B5FFF2B54C11CD283A, + 01FA81B4FFF2B54C11CD283A, + 01FA8219FFF2B54C11CD283A, + 01FA8218FFF2B54C11CD283A, + 01FA8223FFF2B54C11CD283A, + 01FA8222FFF2B54C11CD283A, + 125E85A9FFF3CDEF11CD283A, + 125E85A8FFF3CDEF11CD283A, + 01FA81A5FFF2B54C11CD283A, + 01FA81A4FFF2B54C11CD283A, + 01FA8221FFF2B54C11CD283A, + 01FA8220FFF2B54C11CD283A, + 01FA81BDFFF2B54C11CD283A, + 01FA81BCFFF2B54C11CD283A, + 01FA8225FFF2B54C11CD283A, + 01FA8224FFF2B54C11CD283A, + 01FA81A0FFF2B54C11CD283A, + 01FA81A1FFF2B54C11CD283A, + C2C11912047187E800CA2E77, + C2C11913047187E800CA2E77, + 01FA819EFFF2B54C11CD283A, + 01FA819FFFF2B54C11CD283A, + 01FA81A2FFF2B54C11CD283A, + 01FA81A3FFF2B54C11CD283A, + 01FA81B9FFF2B54C11CD283A, + 01FA81B8FFF2B54C11CD283A, + 3253C16401C7D8A005CA2E77, + 3253C16501C7D8A005CA2E77, + C2952B0E044B560900CA2E77, + C2952B0F044B560900CA2E77, + C2952B10044B560900CA2E77, + C2952B11044B560900CA2E77, + 01FA81B2FFF2B54C11CD283A, + 01FA81B3FFF2B54C11CD283A, + 32361EEC01EB8FCF05CA2E77, + 32361EED01EB8FCF05CA2E77, + 01FA823AFFF2B54C11CD283A, + 01379EAE001E00F311CD296C, + 0165238D000BEC3311CD296C, + 0165238E000BEC3311CD296C, + 0165238F000BEC3311CD296C, + 01FA81A6FFF2B54C11CD283A, + 01FA822AFFF2B54C11CD283A, ); isa = PBXGroup; - path = asn; + path = SecurityServer; refType = 4; }; - 01FA816AFFF2B54C11CD283A = { + 01FA819EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = "asn-useful.asn1"; + path = acl_keychain.cpp; refType = 4; }; - 01FA816BFFF2B54C11CD283A = { + 01FA819FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs1.asn1; + path = acl_keychain.h; refType = 4; }; - 01FA816CFFF2B54C11CD283A = { + 01FA81A0FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs1oids.asn; + path = acls.cpp; refType = 4; }; - 01FA816DFFF2B54C11CD283A = { + 01FA81A1FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs5.asn1; + path = acls.h; refType = 4; }; - 01FA816EFFF2B54C11CD283A = { + 01FA81A2FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs7.asn; + path = agentquery.cpp; refType = 4; }; - 01FA816FFFF2B54C11CD283A = { + 01FA81A3FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs8.asn; + path = agentquery.h; refType = 4; }; - 01FA8170FFF2B54C11CD283A = { + 01FA81A4FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs9oids.asn; + path = authority.cpp; refType = 4; }; - 01FA8171FFF2B54C11CD283A = { + 01FA81A5FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_cms.asn; + path = authority.h; refType = 4; }; - 01FA8172FFF2B54C11CD283A = { - isa = PBXFileReference; - path = sm_ess.asn; + 01FA81A6FFF2B54C11CD283A = { + children = ( + 01FA81A8FFF2B54C11CD283A, + 408F00D5045E0650009D840B, + C284B43E042F847900CA2E77, + F5A7F718023D96EA01CA2E64, + 3267644800EBF3A905CD296C, + 01FA81ABFFF2B54C11CD283A, + 01FA81ADFFF2B54C11CD283A, + 01FA81A7FFF2B54C11CD283A, + F5A7F716023D96EA01CA2E64, + F5A7F717023D96EA01CA2E64, + 40ACEF4E0462F6FF0035B857, + 40ACEF4F0462F6FF0035B857, + 01FA81A9FFF2B54C11CD283A, + 01FA81AAFFF2B54C11CD283A, + 40ACEF4A0462F6EC0035B857, + 40ACEF4B0462F6EC0035B857, + 01FA81ACFFF2B54C11CD283A, + 01FA81AEFFF2B54C11CD283A, + 01FA81AFFFF2B54C11CD283A, + C284B440042F856A00CA2E77, + C2907DD8042BA6F800CA2E77, + C2A6D4E0042FC54000CA2E77, + F5A7F715023D96EA01CA2E64, + ); + isa = PBXGroup; + path = Authorization; refType = 4; }; - 01FA8173FFF2B54C11CD283A = { + 01FA81A7FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_vdatypes.asn; + path = Authorization.cpp; refType = 4; }; - 01FA8174FFF2B54C11CD283A = { + 01FA81A8FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x411mtsas.asn; + path = Authorization.h; refType = 4; }; - 01FA8175FFF2B54C11CD283A = { + 01FA81A9FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x411ub.asn; + path = AuthorizationEngine.cpp; refType = 4; }; - 01FA8176FFF2B54C11CD283A = { + 01FA81AAFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x501if.asn; + path = AuthorizationEngine.h; refType = 4; }; - 01FA8177FFF2B54C11CD283A = { + 01FA81ABFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x501ud.asn; + path = AuthorizationTags.h; refType = 4; }; - 01FA8178FFF2B54C11CD283A = { + 01FA81ACFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509af.asn; + path = AuthorizationTrampoline.cpp; refType = 4; }; - 01FA8179FFF2B54C11CD283A = { + 01FA81ADFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509ce.asn; + path = AuthorizationWalkers.h; refType = 4; }; - 01FA817AFFF2B54C11CD283A = { + 01FA81AEFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509cmn.asn; + path = trampolineClient.cpp; refType = 4; }; - 01FA817BFFF2B54C11CD283A = { + 01FA81AFFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x520sa.asn; + path = trampolineServer.cpp; refType = 4; }; - 01FA817CFFF2B54C11CD283A = { - children = ( - 4EB202DE0058585F7F000001, - 01FA817DFFF2B54C11CD283A, - 01FA817EFFF2B54C11CD283A, - 01FA817FFFF2B54C11CD283A, - 01FA8180FFF2B54C11CD283A, - F540E6F9027A33DA01CA2E66, - 01FA8181FFF2B54C11CD283A, - 01FA8182FFF2B54C11CD283A, - 01FA8183FFF2B54C11CD283A, - 01FA8184FFF2B54C11CD283A, - 01FA8185FFF2B54C11CD283A, - 01FA8186FFF2B54C11CD283A, - 01FA8187FFF2B54C11CD283A, - 01FA8188FFF2B54C11CD283A, - 01FA8189FFF2B54C11CD283A, - 01FA818AFFF2B54C11CD283A, - 01FA818BFFF2B54C11CD283A, - ); - isa = PBXGroup; - path = "c++"; + 01FA81B1FFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = BLOBFORMAT; refType = 4; }; - 01FA817DFFF2B54C11CD283A = { + 01FA81B2FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs1oids.cpp; + path = cfnotifier.cpp; refType = 4; }; - 01FA817EFFF2B54C11CD283A = { + 01FA81B3FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs7.cpp; + path = cfnotifier.h; refType = 4; }; - 01FA817FFFF2B54C11CD283A = { + 01FA81B4FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs8.cpp; + path = connection.cpp; refType = 4; }; - 01FA8180FFF2B54C11CD283A = { + 01FA81B5FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs9oids.cpp; + path = connection.h; refType = 4; }; - 01FA8181FFF2B54C11CD283A = { + 01FA81B8FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_cms.cpp; + path = dbcrypto.cpp; refType = 4; }; - 01FA8182FFF2B54C11CD283A = { + 01FA81B9FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_ess.cpp; + path = dbcrypto.h; refType = 4; }; - 01FA8183FFF2B54C11CD283A = { - isa = PBXFileReference; - path = sm_vdatypes.cpp; - refType = 4; - }; - 01FA8184FFF2B54C11CD283A = { - isa = PBXFileReference; - path = sm_x411mtsas.cpp; - refType = 4; - }; - 01FA8185FFF2B54C11CD283A = { + 01FA81BCFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x411ub.cpp; + path = key.cpp; refType = 4; }; - 01FA8186FFF2B54C11CD283A = { + 01FA81BDFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x501if.cpp; + path = key.h; refType = 4; }; - 01FA8187FFF2B54C11CD283A = { + 01FA8214FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x501ud.cpp; + path = main.cpp; refType = 4; }; - 01FA8188FFF2B54C11CD283A = { + 01FA8215FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509af.cpp; + path = Makefile; refType = 4; }; - 01FA8189FFF2B54C11CD283A = { + 01FA8216FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509ce.cpp; - refType = 4; + name = Makefile.startup; + path = SecurityServer/Makefile.startup; + refType = 2; }; - 01FA818AFFF2B54C11CD283A = { + 01FA8218FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509cmn.cpp; + path = process.cpp; refType = 4; }; - 01FA818BFFF2B54C11CD283A = { + 01FA8219FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x520sa.cpp; - refType = 4; - }; - 01FA818CFFF2B54C11CD283A = { - children = ( - 4EB202E00058588E7F000001, - 01FA818DFFF2B54C11CD283A, - 01FA818EFFF2B54C11CD283A, - 01FA818FFFF2B54C11CD283A, - 01FA8190FFF2B54C11CD283A, - F540E6F7027A33A501CA2E66, - 01FA8191FFF2B54C11CD283A, - 01FA8192FFF2B54C11CD283A, - 01FA8193FFF2B54C11CD283A, - 01FA8194FFF2B54C11CD283A, - 01FA8195FFF2B54C11CD283A, - 01FA8196FFF2B54C11CD283A, - 01FA8197FFF2B54C11CD283A, - 01FA8198FFF2B54C11CD283A, - 01FA8199FFF2B54C11CD283A, - 01FA819AFFF2B54C11CD283A, - 01FA819BFFF2B54C11CD283A, - ); - isa = PBXGroup; - path = inc; + path = process.h; refType = 4; }; - 01FA818DFFF2B54C11CD283A = { + 01FA821AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs1oids.h; + path = secagent.defs; refType = 4; }; - 01FA818EFFF2B54C11CD283A = { + 01FA821BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs7.h; + path = secagent_types.h; refType = 4; }; - 01FA818FFFF2B54C11CD283A = { + 01FA821CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs8.h; + path = SecurityAgentClient.cpp; refType = 4; }; - 01FA8190FFF2B54C11CD283A = { + 01FA821DFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = pkcs9oids.h; + path = SecurityAgentClient.h; refType = 4; }; - 01FA8191FFF2B54C11CD283A = { + 01FA821EFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_cms.h; + path = securityserver.h; refType = 4; }; - 01FA8192FFF2B54C11CD283A = { + 01FA821FFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_ess.h; + path = SecurityServerClient.h; refType = 4; }; - 01FA8193FFF2B54C11CD283A = { + 01FA8220FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_vdatypes.h; + path = server.cpp; refType = 4; }; - 01FA8194FFF2B54C11CD283A = { + 01FA8221FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x411mtsas.h; + path = server.h; refType = 4; }; - 01FA8195FFF2B54C11CD283A = { + 01FA8222FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x411ub.h; + path = session.cpp; refType = 4; }; - 01FA8196FFF2B54C11CD283A = { + 01FA8223FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x501if.h; + path = session.h; refType = 4; }; - 01FA8197FFF2B54C11CD283A = { + 01FA8224FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x501ud.h; + path = ssblob.cpp; refType = 4; }; - 01FA8198FFF2B54C11CD283A = { + 01FA8225FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509af.h; + path = ssblob.h; refType = 4; }; - 01FA8199FFF2B54C11CD283A = { + 01FA8226FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509ce.h; + path = ssclient.cpp; refType = 4; }; - 01FA819AFFF2B54C11CD283A = { + 01FA8227FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x509cmn.h; + path = ssclient.h; refType = 4; }; - 01FA819BFFF2B54C11CD283A = { + 01FA8228FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = sm_x520sa.h; + path = sstransit.cpp; refType = 4; }; - 01FA819CFFF2B54C11CD283A = { + 01FA8229FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = Makefile; + path = sstransit.h; refType = 4; }; - 01FA819DFFF2B54C11CD283A = { + 01FA822AFFF2B54C11CD283A = { children = ( - 01FA8214FFF2B54C11CD283A, - 01FA821EFFF2B54C11CD283A, - 01FA81B5FFF2B54C11CD283A, - 01FA81B4FFF2B54C11CD283A, - 01FA8219FFF2B54C11CD283A, - 01FA8218FFF2B54C11CD283A, - 01FA8223FFF2B54C11CD283A, - 01FA8222FFF2B54C11CD283A, - 125E85A9FFF3CDEF11CD283A, - 125E85A8FFF3CDEF11CD283A, - 01FA81A5FFF2B54C11CD283A, - 01FA81A4FFF2B54C11CD283A, - 01FA8221FFF2B54C11CD283A, - 01FA8220FFF2B54C11CD283A, - 01FA81BDFFF2B54C11CD283A, - 01FA81BCFFF2B54C11CD283A, - 01FA8225FFF2B54C11CD283A, - 01FA8224FFF2B54C11CD283A, - 01FA81A0FFF2B54C11CD283A, - 01FA81A1FFF2B54C11CD283A, - 01FA819EFFF2B54C11CD283A, - 01FA819FFFF2B54C11CD283A, - 01FA81A2FFF2B54C11CD283A, - 01FA81A3FFF2B54C11CD283A, - 01FA81B9FFF2B54C11CD283A, - 01FA81B8FFF2B54C11CD283A, - 01FA81B2FFF2B54C11CD283A, - 01FA81B3FFF2B54C11CD283A, - 01FA823AFFF2B54C11CD283A, - 3253C16401C7D8A005CA2E77, - 3253C16501C7D8A005CA2E77, - 32361EEC01EB8FCF05CA2E77, - 32361EED01EB8FCF05CA2E77, - 01379EAE001E00F311CD296C, - 0165238D000BEC3311CD296C, - 0165238E000BEC3311CD296C, - 0165238F000BEC3311CD296C, - 01FA81A6FFF2B54C11CD283A, - 01FA822AFFF2B54C11CD283A, + 01FA8216FFF2B54C11CD283A, + 01FA822BFFF2B54C11CD283A, + 01FA822CFFF2B54C11CD283A, + 21306AAD0030B27011CD283A, ); isa = PBXGroup; - path = SecurityServer; - refType = 4; - }; - 01FA819EFFF2B54C11CD283A = { - isa = PBXFileReference; - path = acl_keychain.cpp; + path = StartupItems; refType = 4; }; - 01FA819FFFF2B54C11CD283A = { - isa = PBXFileReference; - path = acl_keychain.h; + 01FA822BFFF2B54C11CD283A = { + fileEncoding = 30; + isa = PBXExecutableFileReference; + path = SecurityServer; refType = 4; }; - 01FA81A0FFF2B54C11CD283A = { + 01FA822CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = acls.cpp; + path = StartupParameters.plist; refType = 4; }; - 01FA81A1FFF2B54C11CD283A = { + 01FA8239FFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = acls.h; + path = TODO; refType = 4; }; - 01FA81A2FFF2B54C11CD283A = { + 01FA823AFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = agentquery.cpp; + path = transition.cpp; refType = 4; }; - 01FA81A3FFF2B54C11CD283A = { + 01FA823BFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = agentquery.h; + path = ucsp.defs; refType = 4; }; - 01FA81A4FFF2B54C11CD283A = { + 01FA823CFFF2B54C11CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = authority.cpp; + path = ucsp_types.h; refType = 4; }; - 01FA81A5FFF2B54C11CD283A = { - isa = PBXFileReference; - path = authority.h; - refType = 4; + 01FA848EFFF2B54C11CD283A = { + fileRef = 01FA7FE8FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81A6FFF2B54C11CD283A = { - children = ( - 01FA81A8FFF2B54C11CD283A, - F5A7F718023D96EA01CA2E64, - 3267644800EBF3A905CD296C, - 01FA81A7FFF2B54C11CD283A, - F5A7F716023D96EA01CA2E64, - F5A7F717023D96EA01CA2E64, - 01FA81A9FFF2B54C11CD283A, - 01FA81AAFFF2B54C11CD283A, - 01FA81ABFFF2B54C11CD283A, - 01FA81ACFFF2B54C11CD283A, - 01FA81ADFFF2B54C11CD283A, - 01FA81AEFFF2B54C11CD283A, - 01FA81AFFFF2B54C11CD283A, - F5A7F715023D96EA01CA2E64, - ); - isa = PBXGroup; - path = Authorization; - refType = 4; + 01FA848FFFF2B54C11CD283A = { + fileRef = 01FA7FE9FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81A7FFF2B54C11CD283A = { - isa = PBXFileReference; - path = Authorization.cpp; - refType = 4; + 01FA8490FFF2B54C11CD283A = { + fileRef = 01FA7FEAFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81A8FFF2B54C11CD283A = { - isa = PBXFileReference; - path = Authorization.h; - refType = 4; + 01FA8491FFF2B54C11CD283A = { + fileRef = 01FA7FEBFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81A9FFF2B54C11CD283A = { - isa = PBXFileReference; - path = AuthorizationEngine.cpp; - refType = 4; + 01FA8492FFF2B54C11CD283A = { + fileRef = 01FA7FECFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81AAFFF2B54C11CD283A = { - isa = PBXFileReference; - path = AuthorizationEngine.h; - refType = 4; + 01FA8493FFF2B54C11CD283A = { + fileRef = 01FA7FEDFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81ABFFF2B54C11CD283A = { - isa = PBXFileReference; - path = AuthorizationTags.h; - refType = 4; + 01FA8494FFF2B54C11CD283A = { + fileRef = 01FA7FEEFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81ACFFF2B54C11CD283A = { - isa = PBXFileReference; - path = AuthorizationTrampoline.cpp; - refType = 4; + 01FA8495FFF2B54C11CD283A = { + fileRef = 01FA7FEFFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81ADFFF2B54C11CD283A = { - isa = PBXFileReference; - path = AuthorizationWalkers.h; - refType = 4; - }; - 01FA81AEFFF2B54C11CD283A = { - isa = PBXFileReference; - path = trampolineClient.cpp; - refType = 4; + 01FA8496FFF2B54C11CD283A = { + fileRef = 01FA7FF0FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81AFFFF2B54C11CD283A = { - isa = PBXFileReference; - path = trampolineServer.cpp; - refType = 4; + 01FA8497FFF2B54C11CD283A = { + fileRef = 01FA7FF1FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81B1FFF2B54C11CD283A = { - isa = PBXFileReference; - path = BLOBFORMAT; - refType = 4; + 01FA8498FFF2B54C11CD283A = { + fileRef = 01FA7FF2FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81B2FFF2B54C11CD283A = { - isa = PBXFileReference; - path = cfnotifier.cpp; - refType = 4; + 01FA8499FFF2B54C11CD283A = { + fileRef = 01FA7FF3FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81B3FFF2B54C11CD283A = { - isa = PBXFileReference; - path = cfnotifier.h; - refType = 4; + 01FA849AFFF2B54C11CD283A = { + fileRef = 01FA7FF4FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81B4FFF2B54C11CD283A = { - isa = PBXFileReference; - path = connection.cpp; - refType = 4; + 01FA849BFFF2B54C11CD283A = { + fileRef = 01FA7FF5FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81B5FFF2B54C11CD283A = { - isa = PBXFileReference; - path = connection.h; - refType = 4; + 01FA849CFFF2B54C11CD283A = { + fileRef = 01FA7FF6FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81B8FFF2B54C11CD283A = { - isa = PBXFileReference; - path = dbcrypto.cpp; - refType = 4; + 01FA849DFFF2B54C11CD283A = { + fileRef = 01FA7FF7FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81B9FFF2B54C11CD283A = { - isa = PBXFileReference; - path = dbcrypto.h; - refType = 4; + 01FA849EFFF2B54C11CD283A = { + fileRef = 01FA7FF8FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81BCFFF2B54C11CD283A = { - isa = PBXFileReference; - path = key.cpp; - refType = 4; + 01FA849FFFF2B54C11CD283A = { + fileRef = 01FA7FF9FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA81BDFFF2B54C11CD283A = { - isa = PBXFileReference; - path = key.h; - refType = 4; + 01FA84A0FFF2B54C11CD283A = { + fileRef = 01FA7FFAFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA8214FFF2B54C11CD283A = { - isa = PBXFileReference; - path = main.cpp; - refType = 4; + 01FA84A1FFF2B54C11CD283A = { + fileRef = 01FA7FFBFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA8215FFF2B54C11CD283A = { - isa = PBXFileReference; - path = Makefile; - refType = 4; + 01FA84A2FFF2B54C11CD283A = { + fileRef = 01FA7FFCFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA8216FFF2B54C11CD283A = { - isa = PBXFileReference; - name = Makefile.startup; - path = SecurityServer/Makefile.startup; - refType = 2; + 01FA84A3FFF2B54C11CD283A = { + fileRef = 01FA7FFDFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA8218FFF2B54C11CD283A = { - isa = PBXFileReference; - path = process.cpp; - refType = 4; + 01FA84A4FFF2B54C11CD283A = { + fileRef = 01FA7FFEFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA8219FFF2B54C11CD283A = { - isa = PBXFileReference; - path = process.h; - refType = 4; + 01FA84A5FFF2B54C11CD283A = { + fileRef = 01FA7FFFFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA821AFFF2B54C11CD283A = { - isa = PBXFileReference; - path = secagent.defs; - refType = 4; + 01FA84A6FFF2B54C11CD283A = { + fileRef = 01FA8000FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA821BFFF2B54C11CD283A = { - isa = PBXFileReference; - path = secagent_types.h; - refType = 4; + 01FA84A7FFF2B54C11CD283A = { + fileRef = 01FA8001FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 01FA821CFFF2B54C11CD283A = { - isa = PBXFileReference; - path = SecurityAgentClient.cpp; - refType = 4; + 01FA84A8FFF2B54C11CD283A = { + fileRef = 01FA8004FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA821DFFF2B54C11CD283A = { - isa = PBXFileReference; - path = SecurityAgentClient.h; - refType = 4; + 01FA84AAFFF2B54C11CD283A = { + fileRef = 01FA8009FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA821EFFF2B54C11CD283A = { - isa = PBXFileReference; - path = securityserver.h; - refType = 4; + 01FA84ABFFF2B54C11CD283A = { + fileRef = 01FA800BFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA821FFFF2B54C11CD283A = { - isa = PBXFileReference; - path = SecurityServerClient.h; - refType = 4; + 01FA84ACFFF2B54C11CD283A = { + fileRef = 01FA800DFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8220FFF2B54C11CD283A = { - isa = PBXFileReference; - path = server.cpp; - refType = 4; + 01FA84ADFFF2B54C11CD283A = { + fileRef = 01FA800FFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8221FFF2B54C11CD283A = { - isa = PBXFileReference; - path = server.h; - refType = 4; + 01FA84AEFFF2B54C11CD283A = { + fileRef = 01FA8011FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8222FFF2B54C11CD283A = { - isa = PBXFileReference; - path = session.cpp; - refType = 4; + 01FA84AFFFF2B54C11CD283A = { + fileRef = 01FA8013FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8223FFF2B54C11CD283A = { - isa = PBXFileReference; - path = session.h; - refType = 4; + 01FA84B0FFF2B54C11CD283A = { + fileRef = 01FA8015FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8224FFF2B54C11CD283A = { - isa = PBXFileReference; - path = ssblob.cpp; - refType = 4; + 01FA84B1FFF2B54C11CD283A = { + fileRef = 01FA8017FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8225FFF2B54C11CD283A = { - isa = PBXFileReference; - path = ssblob.h; - refType = 4; + 01FA84B2FFF2B54C11CD283A = { + fileRef = 01FA8019FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8226FFF2B54C11CD283A = { - isa = PBXFileReference; - path = ssclient.cpp; - refType = 4; + 01FA84B3FFF2B54C11CD283A = { + fileRef = 01FA801BFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8227FFF2B54C11CD283A = { - isa = PBXFileReference; - path = ssclient.h; - refType = 4; + 01FA84B4FFF2B54C11CD283A = { + fileRef = 01FA801DFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8228FFF2B54C11CD283A = { - isa = PBXFileReference; - path = sstransit.cpp; - refType = 4; + 01FA84B5FFF2B54C11CD283A = { + fileRef = 01FA801FFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8229FFF2B54C11CD283A = { - isa = PBXFileReference; - path = sstransit.h; - refType = 4; + 01FA84B6FFF2B54C11CD283A = { + fileRef = 01FA8021FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA822AFFF2B54C11CD283A = { - children = ( - 01FA8216FFF2B54C11CD283A, - 01FA822BFFF2B54C11CD283A, - 01FA822CFFF2B54C11CD283A, - 21306AAD0030B27011CD283A, - ); - isa = PBXGroup; - path = StartupItems; - refType = 4; + 01FA84B7FFF2B54C11CD283A = { + fileRef = 01FA8023FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA822BFFF2B54C11CD283A = { - isa = PBXExecutableFileReference; - path = SecurityServer; - refType = 4; + 01FA84B8FFF2B54C11CD283A = { + fileRef = 01FA8027FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA822CFFF2B54C11CD283A = { - isa = PBXFileReference; - path = StartupParameters.plist; - refType = 4; + 01FA84B9FFF2B54C11CD283A = { + fileRef = 01FA8028FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8239FFF2B54C11CD283A = { - isa = PBXFileReference; - path = TODO; - refType = 4; + 01FA84BAFFF2B54C11CD283A = { + fileRef = 01FA8029FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA823AFFF2B54C11CD283A = { - isa = PBXFileReference; - path = transition.cpp; - refType = 4; + 01FA84BBFFF2B54C11CD283A = { + fileRef = 01FA802BFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA823BFFF2B54C11CD283A = { - isa = PBXFileReference; - path = ucsp.defs; - refType = 4; + 01FA84BCFFF2B54C11CD283A = { + fileRef = 01FA802EFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA823CFFF2B54C11CD283A = { - isa = PBXFileReference; - path = ucsp_types.h; - refType = 4; + 01FA84BDFFF2B54C11CD283A = { + fileRef = 01FA8030FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA823FFFF2B54C11CD283A = { - children = ( - 01FA8241FFF2B54C11CD283A, - 01FA8263FFF2B54C11CD283A, - 01FA8467FFF2B54C11CD283A, - 01FA848CFFF2B54C11CD283A, - ); - isa = PBXGroup; - path = SecuritySNACCRuntime; - refType = 4; + 01FA84BEFFF2B54C11CD283A = { + fileRef = 01FA8035FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8241FFF2B54C11CD283A = { - isa = PBXFileReference; - path = Apple_README; - refType = 4; + 01FA84BFFFF2B54C11CD283A = { + fileRef = 01FA8036FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8263FFF2B54C11CD283A = { - children = ( - 01FA8264FFF2B54C11CD283A, - 01FA827AFFF2B54C11CD283A, - 01FA829BFFF2B54C11CD283A, - ); - isa = PBXGroup; - path = "c++-lib"; - refType = 4; + 01FA84C0FFF2B54C11CD283A = { + fileRef = 01FA8037FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 01FA8264FFF2B54C11CD283A = { - children = ( - 01FA8265FFF2B54C11CD283A, - 01FA8266FFF2B54C11CD283A, - 01FA8267FFF2B54C11CD283A, - 01FA8268FFF2B54C11CD283A, - 01FA8269FFF2B54C11CD283A, - 01FA826AFFF2B54C11CD283A, - 01FA826BFFF2B54C11CD283A, - 01FA826CFFF2B54C11CD283A, - 01FA826DFFF2B54C11CD283A, - 01FA826EFFF2B54C11CD283A, - 01FA826FFFF2B54C11CD283A, - 01FA8270FFF2B54C11CD283A, - 01FA8271FFF2B54C11CD283A, - 01FA8272FFF2B54C11CD283A, - 01FA8273FFF2B54C11CD283A, - 01FA8274FFF2B54C11CD283A, - 01FA8275FFF2B54C11CD283A, - 01FA8276FFF2B54C11CD283A, - ); - isa = PBXGroup; - path = "c++"; - refType = 4; - }; - 01FA8265FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-any.cpp"; - refType = 4; - }; - 01FA8266FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-bits.cpp"; - refType = 4; - }; - 01FA8267FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-bool.cpp"; - refType = 4; - }; - 01FA8268FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-enum.cpp"; - refType = 4; - }; - 01FA8269FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-int.cpp"; - refType = 4; - }; - 01FA826AFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-len.cpp"; - refType = 4; - }; - 01FA826BFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-list.cpp"; - refType = 4; - }; - 01FA826CFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-null.cpp"; - refType = 4; - }; - 01FA826DFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-octs.cpp"; - refType = 4; - }; - 01FA826EFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-oid.cpp"; - refType = 4; - }; - 01FA826FFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-real.cpp"; - refType = 4; - }; - 01FA8270FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-tag.cpp"; - refType = 4; - }; - 01FA8271FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-type.cpp"; - refType = 4; - }; - 01FA8272FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-useful.cpp"; - refType = 4; - }; - 01FA8273FFF2B54C11CD283A = { - isa = PBXFileReference; - path = hash.cpp; - refType = 4; - }; - 01FA8274FFF2B54C11CD283A = { - isa = PBXFileReference; - path = meta.cpp; - refType = 4; - }; - 01FA8275FFF2B54C11CD283A = { - isa = PBXFileReference; - path = print.cpp; - refType = 4; - }; - 01FA8276FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "str-stk.cpp"; - refType = 4; - }; - 01FA827AFFF2B54C11CD283A = { - children = ( - 01FA827BFFF2B54C11CD283A, - 01FA827CFFF2B54C11CD283A, - 01FA827DFFF2B54C11CD283A, - 01FA827EFFF2B54C11CD283A, - 01FA827FFFF2B54C11CD283A, - 01FA8280FFF2B54C11CD283A, - 01FA8281FFF2B54C11CD283A, - 01FA8282FFF2B54C11CD283A, - 01FA8283FFF2B54C11CD283A, - 01FA8284FFF2B54C11CD283A, - 01FA8285FFF2B54C11CD283A, - 01FA8286FFF2B54C11CD283A, - 01FA8287FFF2B54C11CD283A, - 01FA8288FFF2B54C11CD283A, - 01FA8289FFF2B54C11CD283A, - 01FA828AFFF2B54C11CD283A, - 01FA828BFFF2B54C11CD283A, - 01FA828CFFF2B54C11CD283A, - 01FA828DFFF2B54C11CD283A, - 01FA828EFFF2B54C11CD283A, - 01FA828FFFF2B54C11CD283A, - 01FA8290FFF2B54C11CD283A, - 01FA8291FFF2B54C11CD283A, - 01FA8292FFF2B54C11CD283A, - 01FA8293FFF2B54C11CD283A, - 01FA8295FFF2B54C11CD283A, - 01FA8296FFF2B54C11CD283A, - ); - isa = PBXGroup; - path = inc; - refType = 4; - }; - 01FA827BFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-any.h"; - refType = 4; - }; - 01FA827CFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-bits.h"; - refType = 4; - }; - 01FA827DFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-bool.h"; - refType = 4; - }; - 01FA827EFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-buf.h"; - refType = 4; - }; - 01FA827FFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-config.h"; - refType = 4; - }; - 01FA8280FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-enum.h"; - refType = 4; - }; - 01FA8281FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-incl.h"; - refType = 4; - }; - 01FA8282FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-int.h"; - refType = 4; - }; - 01FA8283FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-len.h"; - refType = 4; - }; - 01FA8284FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-list.h"; - refType = 4; - }; - 01FA8285FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-null.h"; - refType = 4; - }; - 01FA8286FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-octs.h"; - refType = 4; - }; - 01FA8287FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-oid.h"; - refType = 4; - }; - 01FA8288FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-real.h"; - refType = 4; - }; - 01FA8289FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-tag.h"; - refType = 4; - }; - 01FA828AFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-type.h"; - refType = 4; - }; - 01FA828BFFF2B54C11CD283A = { - isa = PBXFileReference; - path = "asn-useful.h"; - refType = 4; - }; - 01FA828CFFF2B54C11CD283A = { - isa = PBXFileReference; - path = cdsaUtils.h; - refType = 4; - }; - 01FA828DFFF2B54C11CD283A = { - isa = PBXFileReference; - path = config.h; - refType = 4; - }; - 01FA828EFFF2B54C11CD283A = { - isa = PBXFileReference; - path = hash.h; - refType = 4; - }; - 01FA828FFFF2B54C11CD283A = { - isa = PBXFileReference; - path = init.h; - refType = 4; - }; - 01FA8290FFF2B54C11CD283A = { - isa = PBXFileReference; - path = meta.h; - refType = 4; - }; - 01FA8291FFF2B54C11CD283A = { - isa = PBXFileReference; - path = policy.h; - refType = 4; - }; - 01FA8292FFF2B54C11CD283A = { - isa = PBXFileReference; - path = print.h; - refType = 4; - }; - 01FA8293FFF2B54C11CD283A = { - isa = PBXFileReference; - path = sm_vdasnacc.h; - refType = 4; - }; - 01FA8295FFF2B54C11CD283A = { - isa = PBXFileReference; - path = snacc.h; - refType = 4; - }; - 01FA8296FFF2B54C11CD283A = { - isa = PBXFileReference; - path = "str-stk.h"; - refType = 4; - }; - 01FA829BFFF2B54C11CD283A = { - children = ( - 01FA82B6FFF2B54C11CD283A, - 01FA82BDFFF2B54C11CD283A, - 01FA82BEFFF2B54C11CD283A, - ); - isa = PBXGroup; - path = src; - refType = 4; - }; - 01FA82B6FFF2B54C11CD283A = { - isa = PBXFileReference; - path = cdsaUtils.cpp; - refType = 4; - }; - 01FA82BDFFF2B54C11CD283A = { - isa = PBXFileReference; - path = sm_buffer.cpp; - refType = 4; - }; - 01FA82BEFFF2B54C11CD283A = { - isa = PBXFileReference; - path = sm_vdasnacc.cpp; - refType = 4; - }; - 01FA8467FFF2B54C11CD283A = { - isa = PBXFileReference; - path = README; - refType = 4; - }; - 01FA848CFFF2B54C11CD283A = { - isa = PBXFileReference; - path = VDADER_RULES.TXT; - refType = 4; - }; - 01FA848EFFF2B54C11CD283A = { - fileRef = 01FA7FE8FFF2B54C11CD283A; + 01FA84C1FFF2B54C11CD283A = { + fileRef = 01FA803CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA848FFFF2B54C11CD283A = { - fileRef = 01FA7FE9FFF2B54C11CD283A; + 01FA84C2FFF2B54C11CD283A = { + fileRef = 01FA803EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8490FFF2B54C11CD283A = { - fileRef = 01FA7FEAFFF2B54C11CD283A; + 01FA84C3FFF2B54C11CD283A = { + fileRef = 01FA8040FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8491FFF2B54C11CD283A = { - fileRef = 01FA7FEBFFF2B54C11CD283A; + 01FA84C5FFF2B54C11CD283A = { + fileRef = 01FA8044FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8492FFF2B54C11CD283A = { - fileRef = 01FA7FECFFF2B54C11CD283A; + 01FA84C6FFF2B54C11CD283A = { + fileRef = 01FA8046FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8493FFF2B54C11CD283A = { - fileRef = 01FA7FEDFFF2B54C11CD283A; + 01FA84C7FFF2B54C11CD283A = { + fileRef = 01FA8048FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8494FFF2B54C11CD283A = { - fileRef = 01FA7FEEFFF2B54C11CD283A; + 01FA84C8FFF2B54C11CD283A = { + fileRef = 01FA804AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8495FFF2B54C11CD283A = { - fileRef = 01FA7FEFFFF2B54C11CD283A; + 01FA84C9FFF2B54C11CD283A = { + fileRef = 01FA804CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8496FFF2B54C11CD283A = { - fileRef = 01FA7FF0FFF2B54C11CD283A; + 01FA84CAFFF2B54C11CD283A = { + fileRef = 01FA804EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8497FFF2B54C11CD283A = { - fileRef = 01FA7FF1FFF2B54C11CD283A; + 01FA84CBFFF2B54C11CD283A = { + fileRef = 01FA8050FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8498FFF2B54C11CD283A = { - fileRef = 01FA7FF2FFF2B54C11CD283A; + 01FA84CCFFF2B54C11CD283A = { + fileRef = 01FA8052FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA8499FFF2B54C11CD283A = { - fileRef = 01FA7FF3FFF2B54C11CD283A; + 01FA84CEFFF2B54C11CD283A = { + fileRef = 01FA8056FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA849AFFF2B54C11CD283A = { - fileRef = 01FA7FF4FFF2B54C11CD283A; + 01FA84CFFFF2B54C11CD283A = { + fileRef = 01FA8058FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA849BFFF2B54C11CD283A = { - fileRef = 01FA7FF5FFF2B54C11CD283A; + 01FA84D0FFF2B54C11CD283A = { + fileRef = 01FA805AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA849CFFF2B54C11CD283A = { - fileRef = 01FA7FF6FFF2B54C11CD283A; + 01FA84D1FFF2B54C11CD283A = { + fileRef = 01FA805CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA849DFFF2B54C11CD283A = { - fileRef = 01FA7FF7FFF2B54C11CD283A; + 01FA84D2FFF2B54C11CD283A = { + fileRef = 01FA805EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA849EFFF2B54C11CD283A = { - fileRef = 01FA7FF8FFF2B54C11CD283A; + 01FA84D3FFF2B54C11CD283A = { + fileRef = 01FA8060FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA849FFFF2B54C11CD283A = { - fileRef = 01FA7FF9FFF2B54C11CD283A; + 01FA84D4FFF2B54C11CD283A = { + fileRef = 01FA8062FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A0FFF2B54C11CD283A = { - fileRef = 01FA7FFAFFF2B54C11CD283A; + 01FA84D5FFF2B54C11CD283A = { + fileRef = 01FA8064FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A1FFF2B54C11CD283A = { - fileRef = 01FA7FFBFFF2B54C11CD283A; + 01FA84D6FFF2B54C11CD283A = { + fileRef = 01FA8066FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A2FFF2B54C11CD283A = { - fileRef = 01FA7FFCFFF2B54C11CD283A; + 01FA84D7FFF2B54C11CD283A = { + fileRef = 01FA8068FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A3FFF2B54C11CD283A = { - fileRef = 01FA7FFDFFF2B54C11CD283A; + 01FA84D8FFF2B54C11CD283A = { + fileRef = 01FA806AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A4FFF2B54C11CD283A = { - fileRef = 01FA7FFEFFF2B54C11CD283A; + 01FA84D9FFF2B54C11CD283A = { + fileRef = 01FA806CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A5FFF2B54C11CD283A = { - fileRef = 01FA7FFFFFF2B54C11CD283A; + 01FA84DAFFF2B54C11CD283A = { + fileRef = 01FA806EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A6FFF2B54C11CD283A = { - fileRef = 01FA8000FFF2B54C11CD283A; + 01FA84DBFFF2B54C11CD283A = { + fileRef = 01FA8070FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A7FFF2B54C11CD283A = { - fileRef = 01FA8001FFF2B54C11CD283A; + 01FA84DCFFF2B54C11CD283A = { + fileRef = 01FA8072FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, + Private, ); }; }; - 01FA84A8FFF2B54C11CD283A = { - fileRef = 01FA8004FFF2B54C11CD283A; + 01FA84DDFFF2B54C11CD283A = { + fileRef = 01FA8074FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -4932,8 +5035,8 @@ ); }; }; - 01FA84A9FFF2B54C11CD283A = { - fileRef = 01FA8006FFF2B54C11CD283A; + 01FA84DEFFF2B54C11CD283A = { + fileRef = 01FA8076FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -4941,8 +5044,8 @@ ); }; }; - 01FA84AAFFF2B54C11CD283A = { - fileRef = 01FA8009FFF2B54C11CD283A; + 01FA84DFFFF2B54C11CD283A = { + fileRef = 01FA8078FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -4950,8 +5053,8 @@ ); }; }; - 01FA84ABFFF2B54C11CD283A = { - fileRef = 01FA800BFFF2B54C11CD283A; + 01FA84E0FFF2B54C11CD283A = { + fileRef = 01FA807AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -4959,8 +5062,8 @@ ); }; }; - 01FA84ACFFF2B54C11CD283A = { - fileRef = 01FA800DFFF2B54C11CD283A; + 01FA84E1FFF2B54C11CD283A = { + fileRef = 01FA807BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -4968,8 +5071,8 @@ ); }; }; - 01FA84ADFFF2B54C11CD283A = { - fileRef = 01FA800FFFF2B54C11CD283A; + 01FA84E2FFF2B54C11CD283A = { + fileRef = 01FA807FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -4977,8 +5080,8 @@ ); }; }; - 01FA84AEFFF2B54C11CD283A = { - fileRef = 01FA8011FFF2B54C11CD283A; + 01FA84E3FFF2B54C11CD283A = { + fileRef = 01FA8082FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -4986,8 +5089,8 @@ ); }; }; - 01FA84AFFFF2B54C11CD283A = { - fileRef = 01FA8013FFF2B54C11CD283A; + 01FA84E4FFF2B54C11CD283A = { + fileRef = 01FA8084FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -4995,8 +5098,8 @@ ); }; }; - 01FA84B0FFF2B54C11CD283A = { - fileRef = 01FA8015FFF2B54C11CD283A; + 01FA84E5FFF2B54C11CD283A = { + fileRef = 01FA8086FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5004,8 +5107,8 @@ ); }; }; - 01FA84B1FFF2B54C11CD283A = { - fileRef = 01FA8017FFF2B54C11CD283A; + 01FA84E6FFF2B54C11CD283A = { + fileRef = 01FA8088FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5013,8 +5116,8 @@ ); }; }; - 01FA84B2FFF2B54C11CD283A = { - fileRef = 01FA8019FFF2B54C11CD283A; + 01FA84E7FFF2B54C11CD283A = { + fileRef = 01FA808AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5022,8 +5125,8 @@ ); }; }; - 01FA84B3FFF2B54C11CD283A = { - fileRef = 01FA801BFFF2B54C11CD283A; + 01FA84E8FFF2B54C11CD283A = { + fileRef = 01FA808CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5031,8 +5134,8 @@ ); }; }; - 01FA84B4FFF2B54C11CD283A = { - fileRef = 01FA801DFFF2B54C11CD283A; + 01FA84E9FFF2B54C11CD283A = { + fileRef = 01FA808DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5040,8 +5143,8 @@ ); }; }; - 01FA84B5FFF2B54C11CD283A = { - fileRef = 01FA801FFFF2B54C11CD283A; + 01FA84EAFFF2B54C11CD283A = { + fileRef = 01FA808FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5049,8 +5152,8 @@ ); }; }; - 01FA84B6FFF2B54C11CD283A = { - fileRef = 01FA8021FFF2B54C11CD283A; + 01FA84EBFFF2B54C11CD283A = { + fileRef = 01FA8091FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5058,8 +5161,8 @@ ); }; }; - 01FA84B7FFF2B54C11CD283A = { - fileRef = 01FA8023FFF2B54C11CD283A; + 01FA84EDFFF2B54C11CD283A = { + fileRef = 01FA8097FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5067,8 +5170,8 @@ ); }; }; - 01FA84B8FFF2B54C11CD283A = { - fileRef = 01FA8027FFF2B54C11CD283A; + 01FA84EEFFF2B54C11CD283A = { + fileRef = 01FA8099FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5076,8 +5179,8 @@ ); }; }; - 01FA84B9FFF2B54C11CD283A = { - fileRef = 01FA8028FFF2B54C11CD283A; + 01FA84EFFFF2B54C11CD283A = { + fileRef = 01FA809AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5085,8 +5188,8 @@ ); }; }; - 01FA84BAFFF2B54C11CD283A = { - fileRef = 01FA8029FFF2B54C11CD283A; + 01FA84F0FFF2B54C11CD283A = { + fileRef = 01FA809BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5094,8 +5197,8 @@ ); }; }; - 01FA84BBFFF2B54C11CD283A = { - fileRef = 01FA802BFFF2B54C11CD283A; + 01FA84F2FFF2B54C11CD283A = { + fileRef = 01FA809FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5103,8 +5206,8 @@ ); }; }; - 01FA84BCFFF2B54C11CD283A = { - fileRef = 01FA802EFFF2B54C11CD283A; + 01FA84F3FFF2B54C11CD283A = { + fileRef = 01FA80A1FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5112,8 +5215,8 @@ ); }; }; - 01FA84BDFFF2B54C11CD283A = { - fileRef = 01FA8030FFF2B54C11CD283A; + 01FA84F4FFF2B54C11CD283A = { + fileRef = 01FA80A3FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5121,8 +5224,8 @@ ); }; }; - 01FA84BEFFF2B54C11CD283A = { - fileRef = 01FA8035FFF2B54C11CD283A; + 01FA84F5FFF2B54C11CD283A = { + fileRef = 01FA80A5FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5130,8 +5233,8 @@ ); }; }; - 01FA84BFFFF2B54C11CD283A = { - fileRef = 01FA8036FFF2B54C11CD283A; + 01FA84F6FFF2B54C11CD283A = { + fileRef = 01FA80A6FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5139,8 +5242,8 @@ ); }; }; - 01FA84C0FFF2B54C11CD283A = { - fileRef = 01FA8037FFF2B54C11CD283A; + 01FA84F7FFF2B54C11CD283A = { + fileRef = 01FA80A8FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5148,8 +5251,8 @@ ); }; }; - 01FA84C1FFF2B54C11CD283A = { - fileRef = 01FA803CFFF2B54C11CD283A; + 01FA84F8FFF2B54C11CD283A = { + fileRef = 01FA80ADFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5157,8 +5260,8 @@ ); }; }; - 01FA84C2FFF2B54C11CD283A = { - fileRef = 01FA803EFFF2B54C11CD283A; + 01FA84F9FFF2B54C11CD283A = { + fileRef = 01FA80AFFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5166,8 +5269,8 @@ ); }; }; - 01FA84C3FFF2B54C11CD283A = { - fileRef = 01FA8040FFF2B54C11CD283A; + 01FA84FAFFF2B54C11CD283A = { + fileRef = 01FA80B1FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5175,8 +5278,8 @@ ); }; }; - 01FA84C5FFF2B54C11CD283A = { - fileRef = 01FA8044FFF2B54C11CD283A; + 01FA84FBFFF2B54C11CD283A = { + fileRef = 01FA80B4FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5184,8 +5287,8 @@ ); }; }; - 01FA84C6FFF2B54C11CD283A = { - fileRef = 01FA8046FFF2B54C11CD283A; + 01FA84FCFFF2B54C11CD283A = { + fileRef = 01FA80B5FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5193,8 +5296,8 @@ ); }; }; - 01FA84C7FFF2B54C11CD283A = { - fileRef = 01FA8048FFF2B54C11CD283A; + 01FA84FDFFF2B54C11CD283A = { + fileRef = 01FA80B7FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5202,8 +5305,8 @@ ); }; }; - 01FA84C8FFF2B54C11CD283A = { - fileRef = 01FA804AFFF2B54C11CD283A; + 01FA84FEFFF2B54C11CD283A = { + fileRef = 01FA80BCFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5211,8 +5314,8 @@ ); }; }; - 01FA84C9FFF2B54C11CD283A = { - fileRef = 01FA804CFFF2B54C11CD283A; + 01FA84FFFFF2B54C11CD283A = { + fileRef = 01FA80BFFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5220,233 +5323,170 @@ ); }; }; - 01FA84CAFFF2B54C11CD283A = { - fileRef = 01FA804EFFF2B54C11CD283A; + 01FA8517FFF2B54C11CD283A = { + fileRef = 01FA8136FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84CBFFF2B54C11CD283A = { - fileRef = 01FA8050FFF2B54C11CD283A; + 01FA8518FFF2B54C11CD283A = { + fileRef = 01FA8139FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84CCFFF2B54C11CD283A = { - fileRef = 01FA8052FFF2B54C11CD283A; + 01FA851AFFF2B54C11CD283A = { + fileRef = 01FA813BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84CEFFF2B54C11CD283A = { - fileRef = 01FA8056FFF2B54C11CD283A; + 01FA851BFFF2B54C11CD283A = { + fileRef = 01FA813CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84CFFFF2B54C11CD283A = { - fileRef = 01FA8058FFF2B54C11CD283A; + 01FA851CFFF2B54C11CD283A = { + fileRef = 01FA813DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D0FFF2B54C11CD283A = { - fileRef = 01FA805AFFF2B54C11CD283A; + 01FA851DFFF2B54C11CD283A = { + fileRef = 01FA813EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D1FFF2B54C11CD283A = { - fileRef = 01FA805CFFF2B54C11CD283A; + 01FA8520FFF2B54C11CD283A = { + fileRef = 01FA8141FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D2FFF2B54C11CD283A = { - fileRef = 01FA805EFFF2B54C11CD283A; + 01FA8521FFF2B54C11CD283A = { + fileRef = 01FA8142FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D3FFF2B54C11CD283A = { - fileRef = 01FA8060FFF2B54C11CD283A; + 01FA8522FFF2B54C11CD283A = { + fileRef = 01FA8143FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D4FFF2B54C11CD283A = { - fileRef = 01FA8062FFF2B54C11CD283A; + 01FA8523FFF2B54C11CD283A = { + fileRef = 01FA8144FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D5FFF2B54C11CD283A = { - fileRef = 01FA8064FFF2B54C11CD283A; + 01FA8524FFF2B54C11CD283A = { + fileRef = 01FA8145FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D6FFF2B54C11CD283A = { - fileRef = 01FA8066FFF2B54C11CD283A; + 01FA8525FFF2B54C11CD283A = { + fileRef = 01FA8146FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D7FFF2B54C11CD283A = { - fileRef = 01FA8068FFF2B54C11CD283A; + 01FA8526FFF2B54C11CD283A = { + fileRef = 01FA8147FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D8FFF2B54C11CD283A = { - fileRef = 01FA806AFFF2B54C11CD283A; + 01FA8527FFF2B54C11CD283A = { + fileRef = 01FA8148FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84D9FFF2B54C11CD283A = { - fileRef = 01FA806CFFF2B54C11CD283A; + 01FA8529FFF2B54C11CD283A = { + fileRef = 01FA814AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84DAFFF2B54C11CD283A = { - fileRef = 01FA806EFFF2B54C11CD283A; + 01FA852AFFF2B54C11CD283A = { + fileRef = 01FA814BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84DBFFF2B54C11CD283A = { - fileRef = 01FA8070FFF2B54C11CD283A; + 01FA852BFFF2B54C11CD283A = { + fileRef = 01FA814CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84DCFFF2B54C11CD283A = { - fileRef = 01FA8072FFF2B54C11CD283A; + 01FA852CFFF2B54C11CD283A = { + fileRef = 01FA814DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84DDFFF2B54C11CD283A = { - fileRef = 01FA8074FFF2B54C11CD283A; + 01FA852DFFF2B54C11CD283A = { + fileRef = 01FA814EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84DEFFF2B54C11CD283A = { - fileRef = 01FA8076FFF2B54C11CD283A; + 01FA852FFFF2B54C11CD283A = { + fileRef = 01FA8150FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84DFFFF2B54C11CD283A = { - fileRef = 01FA8078FFF2B54C11CD283A; + 01FA8530FFF2B54C11CD283A = { + fileRef = 01FA8151FFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84E0FFF2B54C11CD283A = { - fileRef = 01FA807AFFF2B54C11CD283A; + 01FA8531FFF2B54C11CD283A = { + fileRef = 01FA8154FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, + Public, ); }; }; - 01FA84E1FFF2B54C11CD283A = { - fileRef = 01FA807BFFF2B54C11CD283A; + 01FA8532FFF2B54C11CD283A = { + fileRef = 01FA8155FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, + Public, ); }; }; - 01FA84E2FFF2B54C11CD283A = { - fileRef = 01FA807FFFF2B54C11CD283A; + 01FA8546FFF2B54C11CD283A = { + fileRef = 01FA81A8FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, + Public, ); }; }; - 01FA84E3FFF2B54C11CD283A = { - fileRef = 01FA8082FFF2B54C11CD283A; + 01FA8548FFF2B54C11CD283A = { + fileRef = 01FA81ABFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, + Public, ); }; }; - 01FA84E4FFF2B54C11CD283A = { - fileRef = 01FA8084FFF2B54C11CD283A; + 01FA8549FFF2B54C11CD283A = { + fileRef = 01FA81ADFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -5454,6384 +5494,6767 @@ ); }; }; - 01FA84E5FFF2B54C11CD283A = { - fileRef = 01FA8086FFF2B54C11CD283A; + 01FA8609FFF2B54C11CD283A = { + fileRef = 01FA80BDFFF2B54C11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 01FA84E6FFF2B54C11CD283A = { - fileRef = 01FA8088FFF2B54C11CD283A; + 01FA86DAFFF2B54C11CD283A = { + fileRef = 01FA8008FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84E7FFF2B54C11CD283A = { - fileRef = 01FA808AFFF2B54C11CD283A; + 01FA86DBFFF2B54C11CD283A = { + fileRef = 01FA800AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84E8FFF2B54C11CD283A = { - fileRef = 01FA808CFFF2B54C11CD283A; + 01FA86DCFFF2B54C11CD283A = { + fileRef = 01FA800CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84E9FFF2B54C11CD283A = { - fileRef = 01FA808DFFF2B54C11CD283A; + 01FA86DDFFF2B54C11CD283A = { + fileRef = 01FA800EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84EAFFF2B54C11CD283A = { - fileRef = 01FA808FFFF2B54C11CD283A; + 01FA86DEFFF2B54C11CD283A = { + fileRef = 01FA8010FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84EBFFF2B54C11CD283A = { - fileRef = 01FA8091FFF2B54C11CD283A; + 01FA86DFFFF2B54C11CD283A = { + fileRef = 01FA8012FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84EDFFF2B54C11CD283A = { - fileRef = 01FA8097FFF2B54C11CD283A; + 01FA86E0FFF2B54C11CD283A = { + fileRef = 01FA8014FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84EEFFF2B54C11CD283A = { - fileRef = 01FA8099FFF2B54C11CD283A; + 01FA86E1FFF2B54C11CD283A = { + fileRef = 01FA8016FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84EFFFF2B54C11CD283A = { - fileRef = 01FA809AFFF2B54C11CD283A; + 01FA86E2FFF2B54C11CD283A = { + fileRef = 01FA8018FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F0FFF2B54C11CD283A = { - fileRef = 01FA809BFFF2B54C11CD283A; + 01FA86E3FFF2B54C11CD283A = { + fileRef = 01FA801AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F2FFF2B54C11CD283A = { - fileRef = 01FA809FFFF2B54C11CD283A; + 01FA86E4FFF2B54C11CD283A = { + fileRef = 01FA801CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F3FFF2B54C11CD283A = { - fileRef = 01FA80A1FFF2B54C11CD283A; + 01FA86E5FFF2B54C11CD283A = { + fileRef = 01FA801EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F4FFF2B54C11CD283A = { - fileRef = 01FA80A3FFF2B54C11CD283A; + 01FA86E6FFF2B54C11CD283A = { + fileRef = 01FA8020FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F5FFF2B54C11CD283A = { - fileRef = 01FA80A5FFF2B54C11CD283A; + 01FA86E7FFF2B54C11CD283A = { + fileRef = 01FA8022FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F6FFF2B54C11CD283A = { - fileRef = 01FA80A6FFF2B54C11CD283A; + 01FA86E9FFF2B54C11CD283A = { + fileRef = 01FA802AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F7FFF2B54C11CD283A = { - fileRef = 01FA80A8FFF2B54C11CD283A; + 01FA86EAFFF2B54C11CD283A = { + fileRef = 01FA802CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F8FFF2B54C11CD283A = { - fileRef = 01FA80ADFFF2B54C11CD283A; + 01FA86EBFFF2B54C11CD283A = { + fileRef = 01FA802DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84F9FFF2B54C11CD283A = { - fileRef = 01FA80AFFFF2B54C11CD283A; + 01FA86ECFFF2B54C11CD283A = { + fileRef = 01FA802FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84FAFFF2B54C11CD283A = { - fileRef = 01FA80B1FFF2B54C11CD283A; + 01FA86EDFFF2B54C11CD283A = { + fileRef = 01FA8034FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84FBFFF2B54C11CD283A = { - fileRef = 01FA80B4FFF2B54C11CD283A; + 01FA86EFFFF2B54C11CD283A = { + fileRef = 01FA803BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84FCFFF2B54C11CD283A = { - fileRef = 01FA80B5FFF2B54C11CD283A; + 01FA86F0FFF2B54C11CD283A = { + fileRef = 01FA803DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84FDFFF2B54C11CD283A = { - fileRef = 01FA80B7FFF2B54C11CD283A; + 01FA86F1FFF2B54C11CD283A = { + fileRef = 01FA803FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84FEFFF2B54C11CD283A = { - fileRef = 01FA80BCFFF2B54C11CD283A; + 01FA86F3FFF2B54C11CD283A = { + fileRef = 01FA8043FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA84FFFFF2B54C11CD283A = { - fileRef = 01FA80BFFFF2B54C11CD283A; + 01FA86F4FFF2B54C11CD283A = { + fileRef = 01FA8045FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8517FFF2B54C11CD283A = { - fileRef = 01FA8136FFF2B54C11CD283A; + 01FA86F5FFF2B54C11CD283A = { + fileRef = 01FA8047FFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA8518FFF2B54C11CD283A = { - fileRef = 01FA8139FFF2B54C11CD283A; + 01FA86F6FFF2B54C11CD283A = { + fileRef = 01FA8049FFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA851AFFF2B54C11CD283A = { - fileRef = 01FA813BFFF2B54C11CD283A; + 01FA86F7FFF2B54C11CD283A = { + fileRef = 01FA804BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA851BFFF2B54C11CD283A = { - fileRef = 01FA813CFFF2B54C11CD283A; + 01FA86F8FFF2B54C11CD283A = { + fileRef = 01FA804DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA851CFFF2B54C11CD283A = { - fileRef = 01FA813DFFF2B54C11CD283A; + 01FA86F9FFF2B54C11CD283A = { + fileRef = 01FA804FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA8520FFF2B54C11CD283A = { - fileRef = 01FA8141FFF2B54C11CD283A; + 01FA86FAFFF2B54C11CD283A = { + fileRef = 01FA8051FFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA8521FFF2B54C11CD283A = { - fileRef = 01FA8142FFF2B54C11CD283A; + 01FA86FCFFF2B54C11CD283A = { + fileRef = 01FA8055FFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA8524FFF2B54C11CD283A = { - fileRef = 01FA8145FFF2B54C11CD283A; + 01FA86FDFFF2B54C11CD283A = { + fileRef = 01FA8057FFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA8525FFF2B54C11CD283A = { - fileRef = 01FA8146FFF2B54C11CD283A; + 01FA86FEFFF2B54C11CD283A = { + fileRef = 01FA8059FFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA8527FFF2B54C11CD283A = { - fileRef = 01FA8148FFF2B54C11CD283A; + 01FA86FFFFF2B54C11CD283A = { + fileRef = 01FA805BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA852AFFF2B54C11CD283A = { - fileRef = 01FA814BFFF2B54C11CD283A; + 01FA8700FFF2B54C11CD283A = { + fileRef = 01FA805DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA852BFFF2B54C11CD283A = { - fileRef = 01FA814CFFF2B54C11CD283A; + 01FA8701FFF2B54C11CD283A = { + fileRef = 01FA805FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA8530FFF2B54C11CD283A = { - fileRef = 01FA8151FFF2B54C11CD283A; + 01FA8702FFF2B54C11CD283A = { + fileRef = 01FA8061FFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA8531FFF2B54C11CD283A = { - fileRef = 01FA8154FFF2B54C11CD283A; + 01FA8703FFF2B54C11CD283A = { + fileRef = 01FA8063FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, ); }; }; - 01FA8532FFF2B54C11CD283A = { - fileRef = 01FA8155FFF2B54C11CD283A; + 01FA8704FFF2B54C11CD283A = { + fileRef = 01FA8065FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, ); }; }; - 01FA8533FFF2B54C11CD283A = { - fileRef = 01FA818DFFF2B54C11CD283A; + 01FA8705FFF2B54C11CD283A = { + fileRef = 01FA8067FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8534FFF2B54C11CD283A = { - fileRef = 01FA818EFFF2B54C11CD283A; + 01FA8706FFF2B54C11CD283A = { + fileRef = 01FA8069FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8535FFF2B54C11CD283A = { - fileRef = 01FA818FFFF2B54C11CD283A; + 01FA8707FFF2B54C11CD283A = { + fileRef = 01FA806BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8536FFF2B54C11CD283A = { - fileRef = 01FA8190FFF2B54C11CD283A; + 01FA8708FFF2B54C11CD283A = { + fileRef = 01FA806DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8537FFF2B54C11CD283A = { - fileRef = 01FA8191FFF2B54C11CD283A; + 01FA8709FFF2B54C11CD283A = { + fileRef = 01FA806FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8538FFF2B54C11CD283A = { - fileRef = 01FA8192FFF2B54C11CD283A; + 01FA870AFFF2B54C11CD283A = { + fileRef = 01FA8071FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8539FFF2B54C11CD283A = { - fileRef = 01FA8193FFF2B54C11CD283A; + 01FA870BFFF2B54C11CD283A = { + fileRef = 01FA8073FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA853AFFF2B54C11CD283A = { - fileRef = 01FA8194FFF2B54C11CD283A; + 01FA870CFFF2B54C11CD283A = { + fileRef = 01FA8075FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA853BFFF2B54C11CD283A = { - fileRef = 01FA8195FFF2B54C11CD283A; + 01FA870DFFF2B54C11CD283A = { + fileRef = 01FA8077FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA853CFFF2B54C11CD283A = { - fileRef = 01FA8196FFF2B54C11CD283A; + 01FA870EFFF2B54C11CD283A = { + fileRef = 01FA8079FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA853DFFF2B54C11CD283A = { - fileRef = 01FA8197FFF2B54C11CD283A; + 01FA870FFFF2B54C11CD283A = { + fileRef = 01FA807EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA853EFFF2B54C11CD283A = { - fileRef = 01FA8198FFF2B54C11CD283A; + 01FA8710FFF2B54C11CD283A = { + fileRef = 01FA8080FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA853FFFF2B54C11CD283A = { - fileRef = 01FA8199FFF2B54C11CD283A; + 01FA8711FFF2B54C11CD283A = { + fileRef = 01FA8081FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8540FFF2B54C11CD283A = { - fileRef = 01FA819AFFF2B54C11CD283A; + 01FA8712FFF2B54C11CD283A = { + fileRef = 01FA8083FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8541FFF2B54C11CD283A = { - fileRef = 01FA819BFFF2B54C11CD283A; + 01FA8713FFF2B54C11CD283A = { + fileRef = 01FA8085FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8546FFF2B54C11CD283A = { - fileRef = 01FA81A8FFF2B54C11CD283A; + 01FA8714FFF2B54C11CD283A = { + fileRef = 01FA8087FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, ); }; }; - 01FA8548FFF2B54C11CD283A = { - fileRef = 01FA81ABFFF2B54C11CD283A; + 01FA8715FFF2B54C11CD283A = { + fileRef = 01FA8089FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Public, ); }; }; - 01FA8549FFF2B54C11CD283A = { - fileRef = 01FA81ADFFF2B54C11CD283A; + 01FA8716FFF2B54C11CD283A = { + fileRef = 01FA808BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8583FFF2B54C11CD283A = { - fileRef = 01FA827BFFF2B54C11CD283A; + 01FA8717FFF2B54C11CD283A = { + fileRef = 01FA808EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8584FFF2B54C11CD283A = { - fileRef = 01FA827CFFF2B54C11CD283A; + 01FA8718FFF2B54C11CD283A = { + fileRef = 01FA8090FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8585FFF2B54C11CD283A = { - fileRef = 01FA827DFFF2B54C11CD283A; + 01FA871BFFF2B54C11CD283A = { + fileRef = 01FA8096FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8586FFF2B54C11CD283A = { - fileRef = 01FA827EFFF2B54C11CD283A; + 01FA871CFFF2B54C11CD283A = { + fileRef = 01FA8098FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8587FFF2B54C11CD283A = { - fileRef = 01FA827FFFF2B54C11CD283A; + 01FA871EFFF2B54C11CD283A = { + fileRef = 01FA809EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8588FFF2B54C11CD283A = { - fileRef = 01FA8280FFF2B54C11CD283A; + 01FA871FFFF2B54C11CD283A = { + fileRef = 01FA80A0FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8589FFF2B54C11CD283A = { - fileRef = 01FA8281FFF2B54C11CD283A; + 01FA8720FFF2B54C11CD283A = { + fileRef = 01FA80A2FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA858AFFF2B54C11CD283A = { - fileRef = 01FA8282FFF2B54C11CD283A; + 01FA8721FFF2B54C11CD283A = { + fileRef = 01FA80A4FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA858BFFF2B54C11CD283A = { - fileRef = 01FA8283FFF2B54C11CD283A; + 01FA8722FFF2B54C11CD283A = { + fileRef = 01FA80A7FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA858CFFF2B54C11CD283A = { - fileRef = 01FA8284FFF2B54C11CD283A; + 01FA8724FFF2B54C11CD283A = { + fileRef = 01FA80ACFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA858DFFF2B54C11CD283A = { - fileRef = 01FA8285FFF2B54C11CD283A; + 01FA8725FFF2B54C11CD283A = { + fileRef = 01FA80AEFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA858EFFF2B54C11CD283A = { - fileRef = 01FA8286FFF2B54C11CD283A; + 01FA8726FFF2B54C11CD283A = { + fileRef = 01FA80B0FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA858FFFF2B54C11CD283A = { - fileRef = 01FA8287FFF2B54C11CD283A; + 01FA8727FFF2B54C11CD283A = { + fileRef = 01FA80B2FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8590FFF2B54C11CD283A = { - fileRef = 01FA8288FFF2B54C11CD283A; + 01FA8728FFF2B54C11CD283A = { + fileRef = 01FA80B3FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8591FFF2B54C11CD283A = { - fileRef = 01FA8289FFF2B54C11CD283A; + 01FA8729FFF2B54C11CD283A = { + fileRef = 01FA80B6FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8592FFF2B54C11CD283A = { - fileRef = 01FA828AFFF2B54C11CD283A; + 01FA872AFFF2B54C11CD283A = { + fileRef = 01FA80BBFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8593FFF2B54C11CD283A = { - fileRef = 01FA828BFFF2B54C11CD283A; + 01FA872BFFF2B54C11CD283A = { + fileRef = 01FA80BEFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8594FFF2B54C11CD283A = { - fileRef = 01FA828CFFF2B54C11CD283A; + 01FA872CFFF2B54C11CD283A = { + fileRef = 01FA80C0FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8595FFF2B54C11CD283A = { - fileRef = 01FA828DFFF2B54C11CD283A; + 01FA872DFFF2B54C11CD283A = { + fileRef = 01FA80C1FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8596FFF2B54C11CD283A = { - fileRef = 01FA828EFFF2B54C11CD283A; + 01FA872EFFF2B54C11CD283A = { + fileRef = 01FA80C2FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8597FFF2B54C11CD283A = { - fileRef = 01FA828FFFF2B54C11CD283A; + 01FA872FFFF2B54C11CD283A = { + fileRef = 01FA80C3FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8598FFF2B54C11CD283A = { - fileRef = 01FA8290FFF2B54C11CD283A; + 01FA8730FFF2B54C11CD283A = { + fileRef = 01FA80C4FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8599FFF2B54C11CD283A = { - fileRef = 01FA8291FFF2B54C11CD283A; + 01FA874FFFF2B54C11CD283A = { + fileRef = 01FA8127FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA859AFFF2B54C11CD283A = { - fileRef = 01FA8292FFF2B54C11CD283A; + 01FA8751FFF2B54C11CD283A = { + fileRef = 01FA8129FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA859BFFF2B54C11CD283A = { - fileRef = 01FA8293FFF2B54C11CD283A; + 01FA8752FFF2B54C11CD283A = { + fileRef = 01FA812AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA859DFFF2B54C11CD283A = { - fileRef = 01FA8295FFF2B54C11CD283A; + 01FA8754FFF2B54C11CD283A = { + fileRef = 01FA812CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA859EFFF2B54C11CD283A = { - fileRef = 01FA8296FFF2B54C11CD283A; + 01FA8755FFF2B54C11CD283A = { + fileRef = 01FA812DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( - Private, ); }; }; - 01FA8609FFF2B54C11CD283A = { - fileRef = 01FA80BDFFF2B54C11CD283A; + 01FA8756FFF2B54C11CD283A = { + fileRef = 01FA812EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 01FA86D9FFF2B54C11CD283A = { - fileRef = 01FA8005FFF2B54C11CD283A; + 01FA8757FFF2B54C11CD283A = { + fileRef = 01FA812FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86DAFFF2B54C11CD283A = { - fileRef = 01FA8008FFF2B54C11CD283A; + 01FA8758FFF2B54C11CD283A = { + fileRef = 01FA8130FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86DBFFF2B54C11CD283A = { - fileRef = 01FA800AFFF2B54C11CD283A; + 01FA875AFFF2B54C11CD283A = { + fileRef = 01FA8132FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86DCFFF2B54C11CD283A = { - fileRef = 01FA800CFFF2B54C11CD283A; + 01FA875CFFF2B54C11CD283A = { + fileRef = 01FA8135FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86DDFFF2B54C11CD283A = { - fileRef = 01FA800EFFF2B54C11CD283A; + 01FA875DFFF2B54C11CD283A = { + fileRef = 01FA8137FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86DEFFF2B54C11CD283A = { - fileRef = 01FA8010FFF2B54C11CD283A; + 01FA8760FFF2B54C11CD283A = { + fileRef = 01FA8158FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86DFFFF2B54C11CD283A = { - fileRef = 01FA8012FFF2B54C11CD283A; + 01FA8761FFF2B54C11CD283A = { + fileRef = 01FA8159FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E0FFF2B54C11CD283A = { - fileRef = 01FA8014FFF2B54C11CD283A; + 01FA8762FFF2B54C11CD283A = { + fileRef = 01FA815AFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E1FFF2B54C11CD283A = { - fileRef = 01FA8016FFF2B54C11CD283A; + 01FA8763FFF2B54C11CD283A = { + fileRef = 01FA815BFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E2FFF2B54C11CD283A = { - fileRef = 01FA8018FFF2B54C11CD283A; + 01FA8764FFF2B54C11CD283A = { + fileRef = 01FA815CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E3FFF2B54C11CD283A = { - fileRef = 01FA801AFFF2B54C11CD283A; + 01FA8765FFF2B54C11CD283A = { + fileRef = 01FA815DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E4FFF2B54C11CD283A = { - fileRef = 01FA801CFFF2B54C11CD283A; + 01FA8766FFF2B54C11CD283A = { + fileRef = 01FA815EFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E5FFF2B54C11CD283A = { - fileRef = 01FA801EFFF2B54C11CD283A; + 01FA8767FFF2B54C11CD283A = { + fileRef = 01FA815FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E6FFF2B54C11CD283A = { - fileRef = 01FA8020FFF2B54C11CD283A; + 01FA8769FFF2B54C11CD283A = { + fileRef = 01FA8161FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E7FFF2B54C11CD283A = { - fileRef = 01FA8022FFF2B54C11CD283A; + 01FA876AFFF2B54C11CD283A = { + fileRef = 01FA8162FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86E9FFF2B54C11CD283A = { - fileRef = 01FA802AFFF2B54C11CD283A; + 01FA876BFFF2B54C11CD283A = { + fileRef = 01FA8163FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86EAFFF2B54C11CD283A = { - fileRef = 01FA802CFFF2B54C11CD283A; + 01FA876CFFF2B54C11CD283A = { + fileRef = 01FA8164FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86EBFFF2B54C11CD283A = { - fileRef = 01FA802DFFF2B54C11CD283A; + 01FA876DFFF2B54C11CD283A = { + fileRef = 01FA8165FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86ECFFF2B54C11CD283A = { - fileRef = 01FA802FFFF2B54C11CD283A; + 01FA876EFFF2B54C11CD283A = { + fileRef = 01FA8166FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86EDFFF2B54C11CD283A = { - fileRef = 01FA8034FFF2B54C11CD283A; + 01FA876FFFF2B54C11CD283A = { + fileRef = 01FA8167FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86EFFFF2B54C11CD283A = { - fileRef = 01FA803BFFF2B54C11CD283A; + 01FA8783FFF2B54C11CD283A = { + fileRef = 01FA81A7FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86F0FFF2B54C11CD283A = { - fileRef = 01FA803DFFF2B54C11CD283A; + 01FA8786FFF2B54C11CD283A = { + fileRef = 01FA81AEFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86F1FFF2B54C11CD283A = { - fileRef = 01FA803FFFF2B54C11CD283A; + 01FA8787FFF2B54C11CD283A = { + fileRef = 01FA81AFFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA86F3FFF2B54C11CD283A = { - fileRef = 01FA8043FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); + 01FA88F0FFF2B96911CD283A = { + buildArgumentsString = "-f SecurityServer/Makefile $ACTION \"SRCROOT=$SRCROOT\" \"TARGET_BUILD_DIR=$TARGET_BUILD_DIR\" \"BUILT_PRODUCTS_DIR=$BUILT_PRODUCTS_DIR\""; + buildPhases = ( + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = "SecurityServer MIG RPC"; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; + buildToolPath = /usr/bin/gnumake; + dependencies = ( + ); + isa = PBXLegacyTarget; + name = "SecurityServer MIG RPC"; + passBuildSettingsInEnvironment = 0; + productName = "SecurityServer MIG RPC"; + settingsToExpand = 6; + settingsToPassInEnvironment = 1; + settingsToPassOnCommandLine = 280; }; - 01FA86F4FFF2B54C11CD283A = { - fileRef = 01FA8045FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 01FA88F8FFF2BBEB11CD283A = { + isa = PBXTargetDependency; + target = 01FA88F9FFF2BBEB11CD283A; }; - 01FA86F5FFF2B54C11CD283A = { - fileRef = 01FA8047FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); + 01FA88F9FFF2BBEB11CD283A = { + buildArgumentsString = "-f SecurityServer/Makefile.startup $ALL_SETTINGS $ACTION"; + buildPhases = ( + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = "Install Startup Arrangements"; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; + buildToolPath = /usr/bin/gnumake; + dependencies = ( + ); + isa = PBXLegacyTarget; + name = "Install Startup Arrangements"; + passBuildSettingsInEnvironment = 0; + productName = "Install Startup Arrangements"; + settingsToExpand = 6; + settingsToPassInEnvironment = 1; + settingsToPassOnCommandLine = 280; }; - 01FA86F6FFF2B54C11CD283A = { - fileRef = 01FA8049FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 01FA88FBFFF2BC5611CD283A = { + isa = PBXExecutableFileReference; + path = SecurityServer; + refType = 3; }; - 01FA86F7FFF2B54C11CD283A = { - fileRef = 01FA804BFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); + 01FA88FCFFF2BC5611CD283A = { + buildPhases = ( + C2952B0B044B553F00CA2E77, + 01FA88FDFFF2BC5611CD283A, + 01FA88FEFFF2BC5611CD283A, + 01FA88FFFFF2BC5611CD283A, + 01FA8900FFF2BC5611CD283A, + ); + buildSettings = { + CURRENT_PROJECT_VERSION = 163; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/derived_src\""; + INSTALL_PATH = "$(SYSTEM_CORE_SERVICES_DIR)"; + LIBRARY_SEARCH_PATHS = ""; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = "-DDatabase=XDatabase"; + OTHER_LDFLAGS = "-twolevel_namespace -lSecurityAgentClient"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = SecurityServer; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = "-sectorder __TEXT __text \"$(SRCROOT)/SecurityServer/SecurityServer.order\" -e start"; + VERSIONING_SYSTEM = "apple-generic"; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; + dependencies = ( + C25FA84C03CB687400CA2E77, + 1B40D2E3FFF9716411CD283A, + ); + isa = PBXToolTarget; + name = SecurityServer; + productInstallPath = "$(SYSTEM_CORE_SERVICES_DIR)"; + productName = SecurityServer; + productReference = 01FA88FBFFF2BC5611CD283A; }; - 01FA86F8FFF2B54C11CD283A = { - fileRef = 01FA804DFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 01FA88FDFFF2BC5611CD283A = { + buildActionMask = 2147483647; + files = ( + 125E85AFFFF3D51B11CD283A, + 125E85B0FFF3D51B11CD283A, + 125E85B1FFF3D51B11CD283A, + 125E85B2FFF3D51B11CD283A, + 125E85B3FFF3D51B11CD283A, + 125E85B9FFF3D54811CD283A, + 125E85BAFFF3D54811CD283A, + 125E85BBFFF3D54811CD283A, + 125E85BFFFF3D5ED11CD283A, + 125E85C0FFF3D5ED11CD283A, + 125E85C1FFF3D5ED11CD283A, + 125E85C2FFF3D5ED11CD283A, + 125E85C3FFF3D5ED11CD283A, + 125E85C4FFF3D5ED11CD283A, + 125E85C5FFF3D5ED11CD283A, + 125E85C6FFF3D5ED11CD283A, + 125E85C7FFF3D5ED11CD283A, + 3253C16601C7D8A105CA2E77, + 32361EEE01EB8FD005CA2E77, + 32361F0A01F4B39505CA2E77, + F5A7F720023D974F01CA2E64, + C2952B13044B560900CA2E77, + C2952B15044B560900CA2E77, + 40ACEF4D0462F6EC0035B857, + 40ACEF510462F6FF0035B857, + C2C11915047187E800CA2E77, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 01FA86F9FFF2B54C11CD283A = { - fileRef = 01FA804FFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 01FA88FEFFF2BC5611CD283A = { + buildActionMask = 2147483647; + files = ( + 125E85B4FFF3D51B11CD283A, + 125E85B5FFF3D51B11CD283A, + 125E85B6FFF3D51B11CD283A, + 125E85B7FFF3D51B11CD283A, + 125E85B8FFF3D51B11CD283A, + 125E85BCFFF3D54811CD283A, + 125E85BDFFF3D54811CD283A, + 125E85BEFFF3D54811CD283A, + 125E85C8FFF3D5ED11CD283A, + 125E85C9FFF3D5ED11CD283A, + 125E85CAFFF3D5ED11CD283A, + 125E85CCFFF3D5ED11CD283A, + 125E85CDFFF3D5ED11CD283A, + 125E85CEFFF3D5ED11CD283A, + 125E85CFFFF3D5ED11CD283A, + 125E85D0FFF3D5ED11CD283A, + 125E85D1FFF3D5ED11CD283A, + 3253C16701C7D8A105CA2E77, + 32361EEF01EB8FD005CA2E77, + 32554D7C01F4C97405CA2E77, + C2952B12044B560900CA2E77, + C2952B14044B560900CA2E77, + 40ACEF4C0462F6EC0035B857, + 40ACEF500462F6FF0035B857, + C2C11914047187E800CA2E77, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 01FA86FAFFF2B54C11CD283A = { - fileRef = 01FA8051FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 01FA88FFFFF2BC5611CD283A = { + buildActionMask = 2147483647; + files = ( + 1BA451B20097605B7F000001, + 3949557400CC6A4511CD283A, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 01FA86FCFFF2B54C11CD283A = { - fileRef = 01FA8055FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 01FA8900FFF2BC5611CD283A = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 01FA86FDFFF2B54C11CD283A = { - fileRef = 01FA8057FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 01FA8901FFF2BCA811CD283A = { + isa = PBXExecutableFileReference; + path = AuthorizationTrampoline; + refType = 3; }; - 01FA86FEFFF2B54C11CD283A = { - fileRef = 01FA8059FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 01FA8902FFF2BCA811CD283A = { + isa = PBXTargetDependency; + target = 01FA88FCFFF2BC5611CD283A; }; - 01FA86FFFFF2B54C11CD283A = { - fileRef = 01FA805BFFF2B54C11CD283A; + 01FA8903FFF2BCA811CD283A = { + isa = PBXTargetDependency; + target = 01FA8904FFF2BCA811CD283A; + }; + 01FA8904FFF2BCA811CD283A = { + buildPhases = ( + 01FA8905FFF2BCA811CD283A, + 01FA8906FFF2BCA811CD283A, + 01FA8908FFF2BCA811CD283A, + 01FA890AFFF2BCA811CD283A, + ); + buildSettings = { + CURRENT_PROJECT_VERSION = 163; + INSTALL_PATH = "$(SYSTEM_CORE_SERVICES_DIR)"; + LIBRARY_SEARCH_PATHS = ""; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_LDFLAGS = "-twolevel_namespace"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = AuthorizationTrampoline; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = ""; + VERSIONING_SYSTEM = "apple-generic"; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + ); + isa = PBXToolTarget; + name = AuthorizationTrampoline; + productInstallPath = "$(SYSTEM_CORE_SERVICES_DIR)"; + productName = AuthorizationTrampoline; + productReference = 01FA8901FFF2BCA811CD283A; + }; + 01FA8905FFF2BCA811CD283A = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 01FA8906FFF2BCA811CD283A = { + buildActionMask = 2147483647; + files = ( + 01FA8907FFF2BCA811CD283A, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 01FA8907FFF2BCA811CD283A = { + fileRef = 01FA81ACFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA8700FFF2B54C11CD283A = { - fileRef = 01FA805DFFF2B54C11CD283A; + 01FA8908FFF2BCA811CD283A = { + buildActionMask = 2147483647; + files = ( + 1BA451B30097605B7F000001, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 01FA890AFFF2BCA811CD283A = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 01FA890DFFF2BD9911CD283A = { + children = ( + 01FA890FFFF2BE3511CD283A, + 01FA8910FFF2BE3511CD283A, + 01FA8911FFF2BE3511CD283A, + 01FA8912FFF2BE3511CD283A, + 01FA8913FFF2BE3511CD283A, + 01FA8914FFF2BE3511CD283A, + 01FA8915FFF2BE3511CD283A, + 01FA8916FFF2BE3511CD283A, + 01FA8917FFF2BE3511CD283A, + 01FA8918FFF2BE3511CD283A, + 01FA8919FFF2BE3511CD283A, + 01FA891AFFF2BE3511CD283A, + 01FA891BFFF2BE3511CD283A, + 01FA891CFFF2BE3511CD283A, + 32554D7901F4C97305CA2E77, + 0177F2CCFFFAA2D311CD283A, + 07A0F690005DAEE111CD283A, + 52F5173004C4B29300D9D6E1, + ); + isa = PBXGroup; + path = derived_src; + refType = 3; + }; + 01FA890EFFF2BD9911CD283A = { + children = ( + 01FA891FFFF2BE3511CD283A, + 01FA8920FFF2BE3511CD283A, + 01FA8926FFF2BE3511CD283A, + 32554D7A01F4C97305CA2E77, + ); + isa = PBXGroup; + name = "derived headers"; + path = include; + refType = 3; + }; + 01FA890FFFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = ACabstractsession.cpp; + refType = 4; + }; + 01FA8910FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CLabstractsession.cpp; + refType = 4; + }; + 01FA8911FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CSPabstractsession.cpp; + refType = 4; + }; + 01FA8912FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = cssmexports.gen; + refType = 4; + }; + 01FA8913FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = DLabstractsession.cpp; + refType = 4; + }; + 01FA8914FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = errorcodes.gen; + refType = 4; + }; + 01FA8915FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = funcnames.gen; + refType = 4; + }; + 01FA8916FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = generator.rpt; + refType = 4; + }; + 01FA8917FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = secagentServer.cpp; + refType = 4; + }; + 01FA8918FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = secagentUser.cpp; + refType = 4; + }; + 01FA8919FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = TPabstractsession.cpp; + refType = 4; + }; + 01FA891AFFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = transition.gen; + refType = 4; + }; + 01FA891BFFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = ucspServer.cpp; + refType = 4; + }; + 01FA891CFFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = ucspUser.cpp; + refType = 4; + }; + 01FA891FFFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = secagent.h; + refType = 4; + }; + 01FA8920FFF2BE3511CD283A = { + children = ( + 01FA8921FFF2BE3511CD283A, + 01FA8922FFF2BE3511CD283A, + 01FA8923FFF2BE3511CD283A, + 01FA8924FFF2BE3511CD283A, + 01FA8925FFF2BE3511CD283A, + ); + isa = PBXGroup; + path = Security; + refType = 4; + }; + 01FA8921FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = ACabstractsession.h; + refType = 4; + }; + 01FA8922FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CLabstractsession.h; + refType = 4; + }; + 01FA8923FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CSPabstractsession.h; + refType = 4; + }; + 01FA8924FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = DLabstractsession.h; + refType = 4; + }; + 01FA8925FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = TPabstractsession.h; + refType = 4; + }; + 01FA8926FFF2BE3511CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = ucsp.h; + refType = 4; + }; + 01FA8929FFF2BE3511CD283A = { + fileRef = 01FA8921FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8701FFF2B54C11CD283A = { - fileRef = 01FA805FFFF2B54C11CD283A; + 01FA892AFFF2BE3511CD283A = { + fileRef = 01FA8922FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8702FFF2B54C11CD283A = { - fileRef = 01FA8061FFF2B54C11CD283A; + 01FA892BFFF2BE3511CD283A = { + fileRef = 01FA8923FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8703FFF2B54C11CD283A = { - fileRef = 01FA8063FFF2B54C11CD283A; + 01FA892CFFF2BE3511CD283A = { + fileRef = 01FA8924FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8704FFF2B54C11CD283A = { - fileRef = 01FA8065FFF2B54C11CD283A; + 01FA892DFFF2BE3511CD283A = { + fileRef = 01FA8925FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8705FFF2B54C11CD283A = { - fileRef = 01FA8067FFF2B54C11CD283A; + 01FA8930FFF2BE3511CD283A = { + fileRef = 01FA890FFFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA8706FFF2B54C11CD283A = { - fileRef = 01FA8069FFF2B54C11CD283A; + 01FA8931FFF2BE3511CD283A = { + fileRef = 01FA8910FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA8707FFF2B54C11CD283A = { - fileRef = 01FA806BFFF2B54C11CD283A; + 01FA8932FFF2BE3511CD283A = { + fileRef = 01FA8911FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA8708FFF2B54C11CD283A = { - fileRef = 01FA806DFFF2B54C11CD283A; + 01FA8933FFF2BE3511CD283A = { + fileRef = 01FA8913FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA8709FFF2B54C11CD283A = { - fileRef = 01FA806FFFF2B54C11CD283A; + 01FA8936FFF2BE3511CD283A = { + fileRef = 01FA8919FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA870AFFF2B54C11CD283A = { - fileRef = 01FA8071FFF2B54C11CD283A; +//010 +//011 +//012 +//013 +//014 +//020 +//021 +//022 +//023 +//024 + 025C84BB0027360A11CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = threading_internal.h; + refType = 4; + }; + 025C84BC0027360A11CD296C = { + fileRef = 025C84BB0027360A11CD296C; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA870BFFF2B54C11CD283A = { - fileRef = 01FA8073FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); +//020 +//021 +//022 +//023 +//024 +//030 +//031 +//032 +//033 +//034 + 030701E1FFF95F6F11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = Security.exp; + refType = 4; + }; + 030701E3FFF96F8511CD283A = { + isa = PBXLibraryReference; + path = libSecurityAgentClient.a; + refType = 3; + }; + 030701E4FFF96F8511CD283A = { + buildPhases = ( + 030701E5FFF96F8511CD283A, + 030701E6FFF96F8511CD283A, + 030701E7FFF96F8511CD283A, + 030701E8FFF96F8511CD283A, + ); + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 163; + INSTALL_PATH = /usr/local/lib; + LIBRARY_STYLE = STATIC; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = "-DNOSA -DAGENTPATH=\\\\\\\"$(SYSTEM_LIBRARY_DIR)/CoreServices/SecurityAgent.app\\\\\\\" -DAGENTNAME=\\\\\\\"SecurityAgent\\\\\\\""; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOL_FLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = libSecurityAgentClient.a; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; + dependencies = ( + 1B40D2E4FFF9716411CD283A, + ); + isa = PBXLibraryTarget; + name = "SecurityAgent Client"; + productInstallPath = /usr/local/lib; + productName = "SecurityAgent Client"; + productReference = 030701E3FFF96F8511CD283A; }; - 01FA870CFFF2B54C11CD283A = { - fileRef = 01FA8075FFF2B54C11CD283A; + 030701E5FFF96F8511CD283A = { + buildActionMask = 2147483647; + files = ( + 406934DF04EDBB8C00447C8E, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 030701E6FFF96F8511CD283A = { + buildActionMask = 2147483647; + files = ( + 030701E9FFF96F9911CD283A, + 030701EAFFF96F9911CD283A, + 406934DE04EDBB8A00447C8E, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 030701E7FFF96F8511CD283A = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 030701E8FFF96F8511CD283A = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 030701E9FFF96F9911CD283A = { + fileRef = 01FA821CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA870DFFF2B54C11CD283A = { - fileRef = 01FA8077FFF2B54C11CD283A; + 030701EAFFF96F9911CD283A = { + fileRef = 01FA8918FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA870EFFF2B54C11CD283A = { - fileRef = 01FA8079FFF2B54C11CD283A; + 034768DDFF38A45A11DB9C8B = { + children = ( + 1BA451B10097605B7F000001, + 01FA88FBFFF2BC5611CD283A, + 01FA8901FFF2BCA811CD283A, + 125E85D4FFF3D67D11CD283A, + 030701E3FFF96F8511CD283A, + 325EAA3100D6B2BE05CD296C, + 325EAA3200D6B2BE05CD296C, + F54323B4022DC91501CA2E64, + 9DC1DEF40299BBCD00003D05, + 9D347A6B0380312200003D05, + 9D347A8C0380359B00003D05, + C227CDCA03E7171400CA2E77, + C2907DD5042BA6B100CA2E77, + ); + isa = PBXGroup; + name = Products; + path = ""; + refType = 4; + }; + 039FF1DB00724BE07F000001 = { + children = ( + 057C0BBE0457129200BA3D3B, + 057C0BBF0457129200BA3D3B, + 057C0BDB0458299B00BA3D3B, + 057C0BDC0458299B00BA3D3B, + 039FF1DC00724C3A7F000001, + 039FF1E200724FFC7F000001, + 0149035400A9DC487F000001, + 0149035500A9DC487F000001, + 07A0F672005DAEE111CD283A, + 07A0F673005DAEE111CD283A, + 209FCB5000A739657F000001, + 209FCB4E00A738117F000001, + 59375E6B00A848827F000001, + 0149035600A9DC487F000001, + 0149035700A9DC487F000001, + 05553B6A042F88F800003D05, + 05553B6B042F88F800003D05, + 039FF1E000724E6E7F000001, + 039FF1DE00724E1A7F000001, + 0149036400A9DF347F000001, + 2C5247F0007A39B47F000001, + 2C5247F1007A39B47F000001, + 52BFC307007A6A1B7F000001, + 52BFC308007A6A1B7F000001, + 4A4C7674007A52DC7F000001, + 4A4C7675007A52DC7F000001, + 59375E7100A849BB7F000001, + 0149035800A9DC487F000001, + 0149035900A9DC487F000001, + 0149035A00A9DC487F000001, + 0149035B00A9DC487F000001, + 07A0F675005DAEE111CD283A, + 07A0F674005DAEE111CD283A, + 9D206AA601EB68F200003D05, + ); + isa = PBXGroup; + name = MiscCSPAlgs; + refType = 4; + }; + 039FF1DC00724C3A7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = desContext.cpp; + path = MiscCSPAlgs/desContext.cpp; + refType = 4; + }; + 039FF1DD00724C3A7F000001 = { + fileRef = 039FF1DC00724C3A7F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA870FFFF2B54C11CD283A = { - fileRef = 01FA807EFFF2B54C11CD283A; + 039FF1DE00724E1A7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = miscAlgFactory.h; + path = MiscCSPAlgs/miscAlgFactory.h; + refType = 4; + }; + 039FF1DF00724E1A7F000001 = { + fileRef = 039FF1DE00724E1A7F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8710FFF2B54C11CD283A = { - fileRef = 01FA8080FFF2B54C11CD283A; + 039FF1E000724E6E7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = miscAlgFactory.cpp; + path = MiscCSPAlgs/miscAlgFactory.cpp; + refType = 4; + }; + 039FF1E100724E6E7F000001 = { + fileRef = 039FF1E000724E6E7F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8711FFF2B54C11CD283A = { - fileRef = 01FA8081FFF2B54C11CD283A; + 039FF1E200724FFC7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = desContext.h; + path = AppleCSP/MiscCSPAlgs/desContext.h; + refType = 2; + }; + 039FF1E300724FFC7F000001 = { + fileRef = 039FF1E200724FFC7F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8712FFF2B54C11CD283A = { - fileRef = 01FA8083FFF2B54C11CD283A; + 03B76D49FFF2D31811CD283A = { + fileRef = 01FA823CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8713FFF2B54C11CD283A = { - fileRef = 01FA8085FFF2B54C11CD283A; + 03B76D4AFFF2D35D11CD283A = { + fileRef = 01FA8227FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8714FFF2B54C11CD283A = { - fileRef = 01FA8087FFF2B54C11CD283A; + 03B76D4BFFF2D35D11CD283A = { + fileRef = 01FA8229FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8715FFF2B54C11CD283A = { - fileRef = 01FA8089FFF2B54C11CD283A; + 03B76D4CFFF2D35D11CD283A = { + fileRef = 01FA821FFFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8716FFF2B54C11CD283A = { - fileRef = 01FA808BFFF2B54C11CD283A; + 03B76D4DFFF2D35D11CD283A = { + fileRef = 01FA8926FFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA8717FFF2B54C11CD283A = { - fileRef = 01FA808EFFF2B54C11CD283A; + 03B76D4EFFF2D35D11CD283A = { + fileRef = 01FA8226FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA8718FFF2B54C11CD283A = { - fileRef = 01FA8090FFF2B54C11CD283A; + 03B76D4FFFF2D35D11CD283A = { + fileRef = 01FA8228FFF2B54C11CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA871BFFF2B54C11CD283A = { - fileRef = 01FA8096FFF2B54C11CD283A; + 03B76D51FFF2D43011CD283A = { + fileRef = 01FA891CFFF2BE3511CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( ); }; }; - 01FA871CFFF2B54C11CD283A = { - fileRef = 01FA8098FFF2B54C11CD283A; +//030 +//031 +//032 +//033 +//034 +//050 +//051 +//052 +//053 +//054 + 05293B8A043916C100003D05 = { + fileRef = 05F88FC30410032C00003D05; isa = PBXBuildFile; settings = { ATTRIBUTES = ( + Private, ); }; }; - 01FA871EFFF2B54C11CD283A = { - fileRef = 01FA809EFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 05553B6A042F88F800003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = pkcs12Derive.cpp; + path = MiscCSPAlgs/pkcs12Derive.cpp; + refType = 4; }; - 01FA871FFFF2B54C11CD283A = { - fileRef = 01FA80A0FFF2B54C11CD283A; + 05553B6B042F88F800003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = pkcs12Derive.h; + path = MiscCSPAlgs/pkcs12Derive.h; + refType = 4; + }; + 05553B6C042F88F800003D05 = { + fileRef = 05553B6A042F88F800003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8720FFF2B54C11CD283A = { - fileRef = 01FA80A2FFF2B54C11CD283A; + 05553B6D042F88F800003D05 = { + fileRef = 05553B6B042F88F800003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8721FFF2B54C11CD283A = { - fileRef = 01FA80A4FFF2B54C11CD283A; + 05553B6E042F892F00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = pkcs8.cpp; + refType = 4; + }; + 05553B6F042F892F00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = pkcs8.h; + refType = 4; + }; + 05553B70042F892F00003D05 = { + fileRef = 05553B6E042F892F00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8722FFF2B54C11CD283A = { - fileRef = 01FA80A7FFF2B54C11CD283A; + 05553B71042F892F00003D05 = { + fileRef = 05553B6F042F892F00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8724FFF2B54C11CD283A = { - fileRef = 01FA80ACFFF2B54C11CD283A; + 05553B72042F90DD00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = pbkdDigest.cpp; + refType = 4; + }; + 05553B73042F90DD00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = pbkdDigest.h; + refType = 4; + }; + 05553B74042F90DD00003D05 = { + fileRef = 05553B72042F90DD00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8725FFF2B54C11CD283A = { - fileRef = 01FA80AEFFF2B54C11CD283A; + 05553B75042F90DD00003D05 = { + fileRef = 05553B73042F90DD00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8726FFF2B54C11CD283A = { - fileRef = 01FA80B0FFF2B54C11CD283A; + 056015700461B82B00D4A1BF = { + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1; + dstSubfolderSpec = 0; + files = ( + 056015720461B87200D4A1BF, + ); + isa = PBXCopyFilesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 056015710461B87200D4A1BF = { + fileEncoding = 30; + isa = PBXFileReference; + name = certtool.1; + path = CertTool/certtool.1; + refType = 4; + }; + 056015720461B87200D4A1BF = { + fileRef = 056015710461B87200D4A1BF; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8727FFF2B54C11CD283A = { - fileRef = 01FA80B2FFF2B54C11CD283A; + 057C0BB00456E14700BA3D3B = { + children = ( + 057C0BB10456E16900BA3D3B, + 057C0BB20456E16900BA3D3B, + 057C0BB30456E16900BA3D3B, + 057C0BB40456E16900BA3D3B, + 057C0BB50456E16900BA3D3B, + ); + isa = PBXGroup; + name = bf; + refType = 4; + }; + 057C0BB10456E16900BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = bf_ecb.c; + path = bf/bf_ecb.c; + refType = 4; + }; + 057C0BB20456E16900BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = bf_enc.c; + path = bf/bf_enc.c; + refType = 4; + }; + 057C0BB30456E16900BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = bf_locl.h; + path = bf/bf_locl.h; + refType = 4; + }; + 057C0BB40456E16900BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = bf_pi.h; + path = bf/bf_pi.h; + refType = 4; + }; + 057C0BB50456E16900BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = bf_skey.c; + path = bf/bf_skey.c; + refType = 4; + }; + 057C0BB60456E16900BA3D3B = { + fileRef = 057C0BB10456E16900BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8728FFF2B54C11CD283A = { - fileRef = 01FA80B3FFF2B54C11CD283A; + 057C0BB70456E16900BA3D3B = { + fileRef = 057C0BB20456E16900BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8729FFF2B54C11CD283A = { - fileRef = 01FA80B6FFF2B54C11CD283A; + 057C0BB80456E16900BA3D3B = { + fileRef = 057C0BB30456E16900BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA872AFFF2B54C11CD283A = { - fileRef = 01FA80BBFFF2B54C11CD283A; + 057C0BB90456E16900BA3D3B = { + fileRef = 057C0BB40456E16900BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA872BFFF2B54C11CD283A = { - fileRef = 01FA80BEFFF2B54C11CD283A; + 057C0BBA0456E16900BA3D3B = { + fileRef = 057C0BB50456E16900BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA872CFFF2B54C11CD283A = { - fileRef = 01FA80C0FFF2B54C11CD283A; + 057C0BBB0456E18300BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = blowfish.h; + path = openssl/blowfish.h; + refType = 4; + }; + 057C0BBC0456E18300BA3D3B = { + fileRef = 057C0BBB0456E18300BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA872DFFF2B54C11CD283A = { - fileRef = 01FA80C1FFF2B54C11CD283A; + 057C0BBE0457129200BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = bfContext.cpp; + path = MiscCSPAlgs/bfContext.cpp; + refType = 4; + }; + 057C0BBF0457129200BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = bfContext.h; + path = MiscCSPAlgs/bfContext.h; + refType = 4; + }; + 057C0BC00457129200BA3D3B = { + fileRef = 057C0BBE0457129200BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA872EFFF2B54C11CD283A = { - fileRef = 01FA80C2FFF2B54C11CD283A; + 057C0BC10457129200BA3D3B = { + fileRef = 057C0BBF0457129200BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA872FFFF2B54C11CD283A = { - fileRef = 01FA80C3FFF2B54C11CD283A; + 057C0BC404581E0000BA3D3B = { + children = ( + 057C0BC504581E3300BA3D3B, + 057C0BC604581E3300BA3D3B, + 057C0BC704581E3300BA3D3B, + 057C0BC804581E3300BA3D3B, + 057C0BC904581E3300BA3D3B, + ); + isa = PBXGroup; + name = cast; + refType = 4; + }; + 057C0BC504581E3300BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = c_ecb.c; + path = cast/c_ecb.c; + refType = 4; + }; + 057C0BC604581E3300BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = c_enc.c; + path = cast/c_enc.c; + refType = 4; + }; + 057C0BC704581E3300BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = c_skey.c; + path = cast/c_skey.c; + refType = 4; + }; + 057C0BC804581E3300BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = cast_lcl.h; + path = cast/cast_lcl.h; + refType = 4; + }; + 057C0BC904581E3300BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = cast_s.h; + path = cast/cast_s.h; + refType = 4; + }; + 057C0BCA04581E3300BA3D3B = { + fileRef = 057C0BC504581E3300BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8730FFF2B54C11CD283A = { - fileRef = 01FA80C4FFF2B54C11CD283A; + 057C0BCB04581E3300BA3D3B = { + fileRef = 057C0BC604581E3300BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA874FFFF2B54C11CD283A = { - fileRef = 01FA8127FFF2B54C11CD283A; + 057C0BCC04581E3300BA3D3B = { + fileRef = 057C0BC704581E3300BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8751FFF2B54C11CD283A = { - fileRef = 01FA8129FFF2B54C11CD283A; + 057C0BCD04581E3300BA3D3B = { + fileRef = 057C0BC804581E3300BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8752FFF2B54C11CD283A = { - fileRef = 01FA812AFFF2B54C11CD283A; + 057C0BCE04581E3300BA3D3B = { + fileRef = 057C0BC904581E3300BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8754FFF2B54C11CD283A = { - fileRef = 01FA812CFFF2B54C11CD283A; + 057C0BD704581E6800BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = cast.h; + path = openssl/cast.h; + refType = 4; + }; + 057C0BD804581E6800BA3D3B = { + fileRef = 057C0BD704581E6800BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8755FFF2B54C11CD283A = { - fileRef = 01FA812DFFF2B54C11CD283A; + 057C0BDB0458299B00BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = castContext.cpp; + path = MiscCSPAlgs/castContext.cpp; + refType = 4; + }; + 057C0BDC0458299B00BA3D3B = { + fileEncoding = 30; + isa = PBXFileReference; + name = castContext.h; + path = MiscCSPAlgs/castContext.h; + refType = 4; + }; + 057C0BDF0458299B00BA3D3B = { + fileRef = 057C0BDB0458299B00BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8756FFF2B54C11CD283A = { - fileRef = 01FA812EFFF2B54C11CD283A; + 057C0BE00458299B00BA3D3B = { + fileRef = 057C0BDC0458299B00BA3D3B; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8757FFF2B54C11CD283A = { - fileRef = 01FA812FFFF2B54C11CD283A; + 05855484FFF2DA1E11CD283A = { + isa = PBXTargetDependency; + target = 01FA88F0FFF2B96911CD283A; + }; + 05D098CE043C6DD200003D05 = { + fileEncoding = 4; + isa = PBXFileReference; + path = AppleCSPKeys.h; + refType = 4; + }; + 05D098CF043C6DD200003D05 = { + fileRef = 05D098CE043C6DD200003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8758FFF2B54C11CD283A = { - fileRef = 01FA8130FFF2B54C11CD283A; + 05D098D0043C6DE300003D05 = { + fileEncoding = 4; + isa = PBXFileReference; + path = AppleCSPKeys.cpp; + refType = 4; + }; + 05D098D1043C6DE300003D05 = { + fileRef = 05D098D0043C6DE300003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8759FFF2B54C11CD283A = { - fileRef = 01FA8131FFF2B54C11CD283A; + 05F88FC00410032C00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = opensslAsn1.cpp; + path = opensslUtils/opensslAsn1.cpp; + refType = 4; + }; + 05F88FC10410032C00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = opensslAsn1.h; + path = opensslUtils/opensslAsn1.h; + refType = 4; + }; + 05F88FC20410032C00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = osKeyTemplates.cpp; + path = opensslUtils/osKeyTemplates.cpp; + refType = 4; + }; + 05F88FC30410032C00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = osKeyTemplates.h; + path = opensslUtils/osKeyTemplates.h; + refType = 4; + }; + 05F88FC40410032C00003D05 = { + fileRef = 05F88FC00410032C00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA875CFFF2B54C11CD283A = { - fileRef = 01FA8135FFF2B54C11CD283A; + 05F88FC50410032C00003D05 = { + fileRef = 05F88FC10410032C00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA875DFFF2B54C11CD283A = { - fileRef = 01FA8137FFF2B54C11CD283A; + 05F88FC60410032C00003D05 = { + fileRef = 05F88FC20410032C00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8760FFF2B54C11CD283A = { - fileRef = 01FA8158FFF2B54C11CD283A; + 05F88FC70410032C00003D05 = { + fileRef = 05F88FC30410032C00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8761FFF2B54C11CD283A = { - fileRef = 01FA8159FFF2B54C11CD283A; + 05F88FC80410035B00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = CryptKitAsn1.cpp; + refType = 4; + }; + 05F88FC90410035B00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = CryptKitAsn1.h; + refType = 4; + }; + 05F88FCA0410035B00003D05 = { + fileRef = 05F88FC80410035B00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8762FFF2B54C11CD283A = { - fileRef = 01FA815AFFF2B54C11CD283A; + 05F88FCB0410035B00003D05 = { + fileRef = 05F88FC90410035B00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA8763FFF2B54C11CD283A = { - fileRef = 01FA815BFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 01FA8764FFF2B54C11CD283A = { - fileRef = 01FA815CFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 05F88FCC041003A500003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = clNameUtils.cpp; + refType = 4; }; - 01FA8765FFF2B54C11CD283A = { - fileRef = 01FA815DFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 05F88FCD041003A500003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = clNameUtils.h; + refType = 4; }; - 01FA8766FFF2B54C11CD283A = { - fileRef = 01FA815EFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 05F88FCE041003A500003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = clNssUtils.cpp; + refType = 4; }; - 01FA8767FFF2B54C11CD283A = { - fileRef = 01FA815FFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 05F88FCF041003A500003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = clNssUtils.h; + refType = 4; }; - 01FA8769FFF2B54C11CD283A = { - fileRef = 01FA8161FFF2B54C11CD283A; + 05F88FD0041003A500003D05 = { + fileRef = 05F88FCC041003A500003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA876AFFF2B54C11CD283A = { - fileRef = 01FA8162FFF2B54C11CD283A; + 05F88FD1041003A500003D05 = { + fileRef = 05F88FCD041003A500003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA876BFFF2B54C11CD283A = { - fileRef = 01FA8163FFF2B54C11CD283A; + 05F88FD2041003A500003D05 = { + fileRef = 05F88FCE041003A500003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA876CFFF2B54C11CD283A = { - fileRef = 01FA8164FFF2B54C11CD283A; + 05F88FD3041003A500003D05 = { + fileRef = 05F88FCF041003A500003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 01FA876DFFF2B54C11CD283A = { - fileRef = 01FA8165FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; +//050 +//051 +//052 +//053 +//054 +//070 +//071 +//072 +//073 +//074 + 07A0F5EA005DAEE111CD283A = { + children = ( + 256C38AB0094AE067F000001, + 57FCEE8D007B8B3D7F000001, + 2C5247EA007A39B47F000001, + 039FF1DB00724BE07F000001, + 07A0F5EB005DAEE111CD283A, + 07A0F5F4005DAEE111CD283A, + 07A0F606005DAEE111CD283A, + 07A0F66E005DAEE111CD283A, + 07A0F680005DAEE111CD283A, + 9D291881026B56B800003D05, + 07A0F685005DAEE111CD283A, + 325EAA3700D6B47405CD296C, + 9D64BAF1019B176100003D05, + 9D64BAF2019B176100003D05, + 9D64BAF3019B176100003D05, + 9DA13D0401B4638200003D05, + ); + isa = PBXGroup; + path = AppleCSP; + refType = 4; }; - 01FA876EFFF2B54C11CD283A = { - fileRef = 01FA8166FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5EB005DAEE111CD283A = { + children = ( + 07A0F5EC005DAEE111CD283A, + 07A0F5EE005DAEE111CD283A, + 4AC94A7E0084C0977F000001, + 07A0F5EF005DAEE111CD283A, + 07A0F5F0005DAEE111CD283A, + 07A0F5F1005DAEE111CD283A, + 07A0F5F2005DAEE111CD283A, + 07A0F5F3005DAEE111CD283A, + 4AC94A7C0084BE397F000001, + 9D8F0D1D01C80C0C00003D05, + 9D2C3D0001C826C800003D05, + 9D8F0D1E01C80C0C00003D05, + 9D8F0D1F01C80C0C00003D05, + 9D2C3D0201C82F6000003D05, + ); + isa = PBXGroup; + path = AES; + refType = 4; }; - 01FA876FFFF2B54C11CD283A = { - fileRef = 01FA8167FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5EC005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = aescsp.cpp; + refType = 4; }; - 01FA8770FFF2B54C11CD283A = { - fileRef = 01FA817DFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5EE005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = aescspi.h; + refType = 4; }; - 01FA8771FFF2B54C11CD283A = { - fileRef = 01FA817EFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5EF005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = "boxes-ref.h"; + refType = 4; }; - 01FA8772FFF2B54C11CD283A = { - fileRef = 01FA817FFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F0005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = "rijndael-alg-ref.c"; + refType = 4; }; - 01FA8773FFF2B54C11CD283A = { - fileRef = 01FA8180FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F1005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = "rijndael-alg-ref.h"; + refType = 4; }; - 01FA8774FFF2B54C11CD283A = { - fileRef = 01FA8181FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F2005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = rijndaelApi.c; + refType = 4; }; - 01FA8775FFF2B54C11CD283A = { - fileRef = 01FA8182FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F3005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = rijndaelApi.h; + refType = 4; }; - 01FA8776FFF2B54C11CD283A = { - fileRef = 01FA8183FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F4005DAEE111CD283A = { + children = ( + 07A0F5F5005DAEE111CD283A, + 07A0F5F6005DAEE111CD283A, + 07A0F5F7005DAEE111CD283A, + 07A0F5F8005DAEE111CD283A, + 05D098D0043C6DE300003D05, + 05D098CE043C6DD200003D05, + 07A0F5F9005DAEE111CD283A, + 07A0F5FA005DAEE111CD283A, + 07A0F5FB005DAEE111CD283A, + 07A0F5FC005DAEE111CD283A, + 07A0F5FD005DAEE111CD283A, + 07A0F5FE005DAEE111CD283A, + 07A0F5FF005DAEE111CD283A, + 07A0F600005DAEE111CD283A, + 07A0F601005DAEE111CD283A, + 05553B6E042F892F00003D05, + 05553B6F042F892F00003D05, + 1691956B009480BC7F000001, + 07A0F604005DAEE111CD283A, + 07A0F605005DAEE111CD283A, + 1691956D009485A47F000001, + 1691956F009486767F000001, + 48855E830095DC957F000001, + 48855E850095DD697F000001, + ); + isa = PBXGroup; + path = AppleCSP; + refType = 4; }; - 01FA8777FFF2B54C11CD283A = { - fileRef = 01FA8184FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F5005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleCSP.cpp; + refType = 4; }; - 01FA8778FFF2B54C11CD283A = { - fileRef = 01FA8185FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F6005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleCSP.h; + refType = 4; }; - 01FA8779FFF2B54C11CD283A = { - fileRef = 01FA8186FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F7005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleCSPContext.cpp; + refType = 4; }; - 01FA877AFFF2B54C11CD283A = { - fileRef = 01FA8187FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F8005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleCSPContext.h; + refType = 4; }; - 01FA877BFFF2B54C11CD283A = { - fileRef = 01FA8188FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 01FA877CFFF2B54C11CD283A = { - fileRef = 01FA8189FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 01FA877DFFF2B54C11CD283A = { - fileRef = 01FA818AFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 01FA877EFFF2B54C11CD283A = { - fileRef = 01FA818BFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5F9005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleCSPSession.h; + refType = 4; }; - 01FA8783FFF2B54C11CD283A = { - fileRef = 01FA81A7FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5FA005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleCSPUtils.cpp; + refType = 4; }; - 01FA8786FFF2B54C11CD283A = { - fileRef = 01FA81AEFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5FB005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleCSPUtils.h; + refType = 4; }; - 01FA8787FFF2B54C11CD283A = { - fileRef = 01FA81AFFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5FC005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = BinaryKey.h; + refType = 4; }; - 01FA87C9FFF2B54C11CD283A = { - fileRef = 01FA8265FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5FD005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = BlockCryptor.cpp; + refType = 4; }; - 01FA87CAFFF2B54C11CD283A = { - fileRef = 01FA8266FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5FE005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = BlockCryptor.h; + refType = 4; }; - 01FA87CBFFF2B54C11CD283A = { - fileRef = 01FA8267FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F5FF005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = cspdebugging.c; + refType = 4; }; - 01FA87CCFFF2B54C11CD283A = { - fileRef = 01FA8268FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F600005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = cspdebugging.h; + refType = 4; }; - 01FA87CDFFF2B54C11CD283A = { - fileRef = 01FA8269FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F601005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = deriveKey.cpp; + refType = 4; }; - 01FA87CEFFF2B54C11CD283A = { - fileRef = 01FA826AFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F604005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = wrapKey.cpp; + refType = 4; }; - 01FA87CFFFF2B54C11CD283A = { - fileRef = 01FA826BFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F605005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = wrapKeyCms.cpp; + refType = 4; }; - 01FA87D0FFF2B54C11CD283A = { - fileRef = 01FA826CFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F606005DAEE111CD283A = { + children = ( + 07A0F607005DAEE111CD283A, + 07A0F608005DAEE111CD283A, + 07A0F609005DAEE111CD283A, + 07A0F60A005DAEE111CD283A, + 07A0F60B005DAEE111CD283A, + 07A0F60C005DAEE111CD283A, + 07A0F60D005DAEE111CD283A, + 07A0F60E005DAEE111CD283A, + 07A0F60F005DAEE111CD283A, + 07A0F610005DAEE111CD283A, + 07A0F611005DAEE111CD283A, + 07A0F612005DAEE111CD283A, + ); + isa = PBXGroup; + path = BSafeCSP; + refType = 4; }; - 01FA87D1FFF2B54C11CD283A = { - fileRef = 01FA826DFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F607005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = algmaker.cpp; + refType = 4; }; - 01FA87D2FFF2B54C11CD283A = { - fileRef = 01FA826EFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F608005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsafeAsymmetric.cpp; + refType = 4; }; - 01FA87D3FFF2B54C11CD283A = { - fileRef = 01FA826FFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F609005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsafeContext.cpp; + refType = 4; }; - 01FA87D4FFF2B54C11CD283A = { - fileRef = 01FA8270FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F60A005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsafecsp.h; + refType = 4; }; - 01FA87D5FFF2B54C11CD283A = { - fileRef = 01FA8271FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F60B005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsafecspi.h; + refType = 4; }; - 01FA87D6FFF2B54C11CD283A = { - fileRef = 01FA8272FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F60C005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsafeKeyGen.cpp; + refType = 4; }; - 01FA87D7FFF2B54C11CD283A = { - fileRef = 01FA8273FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F60D005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsafePKCS1.cpp; + refType = 4; }; - 01FA87D8FFF2B54C11CD283A = { - fileRef = 01FA8274FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F60E005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsafePKCS1.h; + refType = 4; }; - 01FA87D9FFF2B54C11CD283A = { - fileRef = 01FA8275FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F60F005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsafeSymmetric.cpp; + refType = 4; }; - 01FA87DAFFF2B54C11CD283A = { - fileRef = 01FA8276FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F610005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = bsobjects.h; + refType = 4; }; - 01FA87F7FFF2B54C11CD283A = { - fileRef = 01FA82B6FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F611005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = memory.cpp; + refType = 4; }; - 01FA87FEFFF2B54C11CD283A = { - fileRef = 01FA82BDFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F612005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = miscalgorithms.cpp; + refType = 4; }; - 01FA87FFFFF2B54C11CD283A = { - fileRef = 01FA82BEFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 01FA88F0FFF2B96911CD283A = { - buildArgumentsString = "-f SecurityServer/Makefile $ACTION \"SRCROOT=$SRCROOT\" \"TARGET_BUILD_DIR=$TARGET_BUILD_DIR\" \"BUILT_PRODUCTS_DIR=$BUILT_PRODUCTS_DIR\""; - buildPhases = ( - ); - buildSettings = { - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = "SecurityServer MIG RPC"; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - buildToolPath = /usr/bin/gnumake; - dependencies = ( + 07A0F66E005DAEE111CD283A = { + children = ( + 07A0F66F005DAEE111CD283A, + 07A0F670005DAEE111CD283A, + 07A0F671005DAEE111CD283A, + 07A0F676005DAEE111CD283A, + 07A0F677005DAEE111CD283A, + 07A0F678005DAEE111CD283A, + 07A0F679005DAEE111CD283A, + 07A0F67A005DAEE111CD283A, + 07A0F67B005DAEE111CD283A, + 07A0F67E005DAEE111CD283A, + 07A0F67F005DAEE111CD283A, + 63B97E6600603F0A7F000001, + 05F88FC80410035B00003D05, + 05F88FC90410035B00003D05, ); - isa = PBXLegacyTarget; - name = "SecurityServer MIG RPC"; - productName = "SecurityServer MIG RPC"; - settingsToExpand = 6; - settingsToPassInEnvironment = 1; - settingsToPassOnCommandLine = 280; - shouldUseHeadermap = 0; + isa = PBXGroup; + path = CryptKitCSP; + refType = 4; }; - 01FA88F8FFF2BBEB11CD283A = { - isa = PBXTargetDependency; - target = 01FA88F9FFF2BBEB11CD283A; + 07A0F66F005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = cryptkitcsp.cpp; + refType = 4; }; - 01FA88F9FFF2BBEB11CD283A = { - buildArgumentsString = "-f SecurityServer/Makefile.startup $ALL_SETTINGS $ACTION"; - buildPhases = ( - ); - buildSettings = { - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = "Install Startup Arrangements"; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - buildToolPath = /usr/bin/gnumake; - dependencies = ( - ); - isa = PBXLegacyTarget; - name = "Install Startup Arrangements"; - productName = "Install Startup Arrangements"; - settingsToExpand = 6; - settingsToPassInEnvironment = 1; - settingsToPassOnCommandLine = 280; - shouldUseHeadermap = 0; + 07A0F670005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = cryptkitcsp.h; + refType = 4; }; - 01FA88FBFFF2BC5611CD283A = { - isa = PBXExecutableFileReference; - path = SecurityServer; - refType = 3; + 07A0F671005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CryptKitSpace.h; + refType = 4; }; - 01FA88FCFFF2BC5611CD283A = { - buildPhases = ( - 01FA88FDFFF2BC5611CD283A, - 01FA88FEFFF2BC5611CD283A, - 01FA88FFFFF2BC5611CD283A, - 01FA8900FFF2BC5611CD283A, - ); - buildSettings = { - CURRENT_PROJECT_VERSION = 54.1.9; - INSTALL_PATH = "$(SYSTEM_CORE_SERVICES_DIR)"; - LIBRARY_SEARCH_PATHS = ""; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_CFLAGS = "-DDatabase=XDatabase"; - OTHER_LDFLAGS = "-twolevel_namespace -lSecurityAgentClient"; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = SecurityServer; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = "-sectorder __TEXT __text \"$(SRCROOT)/SecurityServer/SecurityServer.order\" -e start"; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - dependencies = ( - 1B40D2E3FFF9716411CD283A, - ); - isa = PBXToolTarget; - name = SecurityServer; - productInstallPath = "$(SYSTEM_CORE_SERVICES_DIR)"; - productName = SecurityServer; - productReference = 01FA88FBFFF2BC5611CD283A; - shouldUseHeadermap = 1; + 07A0F672005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + name = DigestContext.cpp; + path = AppleCSP/MiscCSPAlgs/DigestContext.cpp; + refType = 2; }; - 01FA88FDFFF2BC5611CD283A = { - buildActionMask = 2147483647; - files = ( - 125E85AFFFF3D51B11CD283A, - 125E85B0FFF3D51B11CD283A, - 125E85B1FFF3D51B11CD283A, - 125E85B2FFF3D51B11CD283A, - 125E85B3FFF3D51B11CD283A, - 125E85B9FFF3D54811CD283A, - 125E85BAFFF3D54811CD283A, - 125E85BBFFF3D54811CD283A, - 125E85BFFFF3D5ED11CD283A, - 125E85C0FFF3D5ED11CD283A, - 125E85C1FFF3D5ED11CD283A, - 125E85C2FFF3D5ED11CD283A, - 125E85C3FFF3D5ED11CD283A, - 125E85C4FFF3D5ED11CD283A, - 125E85C5FFF3D5ED11CD283A, - 125E85C6FFF3D5ED11CD283A, - 125E85C7FFF3D5ED11CD283A, - 4EB202E10058588E7F000001, - 3253C16601C7D8A105CA2E77, - 32361EEE01EB8FD005CA2E77, - 32361F0A01F4B39505CA2E77, - F5A7F720023D974F01CA2E64, - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F673005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + name = DigestContext.h; + path = AppleCSP/MiscCSPAlgs/DigestContext.h; + refType = 2; }; - 01FA88FEFFF2BC5611CD283A = { - buildActionMask = 2147483647; - files = ( - 125E85B4FFF3D51B11CD283A, - 125E85B5FFF3D51B11CD283A, - 125E85B6FFF3D51B11CD283A, - 125E85B7FFF3D51B11CD283A, - 125E85B8FFF3D51B11CD283A, - 125E85BCFFF3D54811CD283A, - 125E85BDFFF3D54811CD283A, - 125E85BEFFF3D54811CD283A, - 125E85C8FFF3D5ED11CD283A, - 125E85C9FFF3D5ED11CD283A, - 125E85CAFFF3D5ED11CD283A, - 125E85CCFFF3D5ED11CD283A, - 125E85CDFFF3D5ED11CD283A, - 125E85CEFFF3D5ED11CD283A, - 125E85CFFFF3D5ED11CD283A, - 125E85D0FFF3D5ED11CD283A, - 125E85D1FFF3D5ED11CD283A, - 3253C16701C7D8A105CA2E77, - 32361EEF01EB8FD005CA2E77, - 32554D7C01F4C97405CA2E77, - F5A7F71F023D974E01CA2E64, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F674005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + name = SHA1_MD5_Object.cpp; + path = MiscCSPAlgs/SHA1_MD5_Object.cpp; + refType = 4; }; - 01FA88FFFFF2BC5611CD283A = { - buildActionMask = 2147483647; - files = ( - 1BA451B20097605B7F000001, - 3949557400CC6A4511CD283A, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F675005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + name = SHA1_MD5_Object.h; + path = MiscCSPAlgs/SHA1_MD5_Object.h; + refType = 4; }; - 01FA8900FFF2BC5611CD283A = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F676005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FEEAsymmetricContext.cpp; + refType = 4; }; - 01FA8901FFF2BCA811CD283A = { - isa = PBXExecutableFileReference; - path = AuthorizationTrampoline; - refType = 3; + 07A0F677005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FEEAsymmetricContext.h; + refType = 4; }; - 01FA8902FFF2BCA811CD283A = { - isa = PBXTargetDependency; - target = 01FA88FCFFF2BC5611CD283A; + 07A0F678005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FEECSPUtils.cpp; + refType = 4; }; - 01FA8903FFF2BCA811CD283A = { - isa = PBXTargetDependency; - target = 01FA8904FFF2BCA811CD283A; + 07A0F679005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FEECSPUtils.h; + refType = 4; }; - 01FA8904FFF2BCA811CD283A = { - buildPhases = ( - 01FA8905FFF2BCA811CD283A, - 01FA8906FFF2BCA811CD283A, - 01FA8908FFF2BCA811CD283A, - 01FA890AFFF2BCA811CD283A, - ); - buildSettings = { - CURRENT_PROJECT_VERSION = 54.1.9; - INSTALL_PATH = "$(SYSTEM_CORE_SERVICES_DIR)"; - LIBRARY_SEARCH_PATHS = ""; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_LDFLAGS = "-twolevel_namespace"; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = AuthorizationTrampoline; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - dependencies = ( - ); - isa = PBXToolTarget; - name = AuthorizationTrampoline; - productInstallPath = "$(SYSTEM_CORE_SERVICES_DIR)"; - productName = AuthorizationTrampoline; - productReference = 01FA8901FFF2BCA811CD283A; - shouldUseHeadermap = 1; + 07A0F67A005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FEEKeys.cpp; + refType = 4; }; - 01FA8905FFF2BCA811CD283A = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 01FA8906FFF2BCA811CD283A = { - buildActionMask = 2147483647; - files = ( - 01FA8907FFF2BCA811CD283A, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 01FA8907FFF2BCA811CD283A = { - fileRef = 01FA81ACFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F67B005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FEEKeys.h; + refType = 4; }; - 01FA8908FFF2BCA811CD283A = { - buildActionMask = 2147483647; - files = ( - 1BA451B30097605B7F000001, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F67E005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FEESignatureObject.cpp; + refType = 4; }; - 01FA890AFFF2BCA811CD283A = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F67F005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FEESignatureObject.h; + refType = 4; }; - 01FA890DFFF2BD9911CD283A = { + 07A0F680005DAEE111CD283A = { children = ( - 01FA890FFFF2BE3511CD283A, - 01FA8910FFF2BE3511CD283A, - 01FA8911FFF2BE3511CD283A, - 01FA8912FFF2BE3511CD283A, - 01FA8913FFF2BE3511CD283A, - 01FA8914FFF2BE3511CD283A, - 01FA8915FFF2BE3511CD283A, - 01FA8916FFF2BE3511CD283A, - 01FA8917FFF2BE3511CD283A, - 01FA8918FFF2BE3511CD283A, - 01FA8919FFF2BE3511CD283A, - 01FA891AFFF2BE3511CD283A, - 01FA891BFFF2BE3511CD283A, - 01FA891CFFF2BE3511CD283A, - 32554D7901F4C97305CA2E77, - 0177F2CCFFFAA2D311CD283A, - 07A0F690005DAEE111CD283A, + 07A0F681005DAEE111CD283A, + 07A0F682005DAEE111CD283A, + 07A0F683005DAEE111CD283A, + 07A0F684005DAEE111CD283A, + 05553B72042F90DD00003D05, + 05553B73042F90DD00003D05, ); isa = PBXGroup; - path = derived_src; - refType = 3; + path = PBKDF2; + refType = 4; }; - 01FA890EFFF2BD9911CD283A = { + 07A0F681005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = HMACSHA1.c; + refType = 4; + }; + 07A0F682005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = HMACSHA1.h; + refType = 4; + }; + 07A0F683005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = pbkdf2.c; + refType = 4; + }; + 07A0F684005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = pbkdf2.h; + refType = 4; + }; + 07A0F685005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = TODO; + refType = 4; + }; + 07A0F686005DAEE111CD283A = { children = ( - 01FA891FFFF2BE3511CD283A, - 01FA8920FFF2BE3511CD283A, - 01FA8926FFF2BE3511CD283A, - 32554D7A01F4C97305CA2E77, + 07A0F68A005DAEE111CD283A, + 07A0F68B005DAEE111CD283A, + 07A0F68C005DAEE111CD283A, + 07A0F68D005DAEE111CD283A, + F5E32A1500EAB9A301CD283A, + 07A0F691005DAEE111CD283A, + 07A0F692005DAEE111CD283A, + 07A0F693005DAEE111CD283A, + 07A0F694005DAEE111CD283A, + 07A0F695005DAEE111CD283A, + 07A0F696005DAEE111CD283A, + 07A0F697005DAEE111CD283A, + 07A0F698005DAEE111CD283A, + 07A0F699005DAEE111CD283A, + 07A0F69A005DAEE111CD283A, + 07A0F69B005DAEE111CD283A, + 07A0F69C005DAEE111CD283A, + 07A0F69D005DAEE111CD283A, + 07A0F69E005DAEE111CD283A, + 07A0F69F005DAEE111CD283A, + 327DDDE700D6FC1A05CD296C, + 9DAE2E3201A43D6B00003D05, + 9DAE2E3301A43D6B00003D05, + 9DAE2E3401A43D6B00003D05, + 9DAE2E3501A43D6B00003D05, ); isa = PBXGroup; - name = "derived headers"; - path = include; - refType = 3; + path = AppleCSPDL; + refType = 4; }; - 01FA890FFFF2BE3511CD283A = { + 07A0F68A005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = ACabstractsession.cpp; + path = CSPDLDatabase.cpp; refType = 4; }; - 01FA8910FFF2BE3511CD283A = { + 07A0F68B005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = CLabstractsession.cpp; + path = CSPDLDatabase.h; refType = 4; }; - 01FA8911FFF2BE3511CD283A = { + 07A0F68C005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = CSPabstractsession.cpp; + path = CSPDLPlugin.cpp; refType = 4; }; - 01FA8912FFF2BE3511CD283A = { + 07A0F68D005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = cssmexports.gen; + path = CSPDLPlugin.h; refType = 4; }; - 01FA8913FFF2BE3511CD283A = { + 07A0F690005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = DLabstractsession.cpp; + path = KeySchema.cpp; refType = 4; }; - 01FA8914FFF2BE3511CD283A = { + 07A0F691005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = errorcodes.gen; + path = KeySchema.h; refType = 4; }; - 01FA8915FFF2BE3511CD283A = { + 07A0F692005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = funcnames.gen; + path = SSContext.cpp; refType = 4; }; - 01FA8916FFF2BE3511CD283A = { + 07A0F693005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = generator.rpt; + path = SSContext.h; refType = 4; }; - 01FA8917FFF2BE3511CD283A = { + 07A0F694005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = secagentServer.cpp; + path = SSCSPDLSession.cpp; refType = 4; }; - 01FA8918FFF2BE3511CD283A = { + 07A0F695005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = secagentUser.cpp; + path = SSCSPDLSession.h; refType = 4; }; - 01FA8919FFF2BE3511CD283A = { + 07A0F696005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = TPabstractsession.cpp; + path = SSCSPSession.cpp; refType = 4; }; - 01FA891AFFF2BE3511CD283A = { + 07A0F697005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = transition.gen; + path = SSCSPSession.h; refType = 4; }; - 01FA891BFFF2BE3511CD283A = { + 07A0F698005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = ucspServer.cpp; + path = SSDatabase.cpp; refType = 4; }; - 01FA891CFFF2BE3511CD283A = { + 07A0F699005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = ucspUser.cpp; + path = SSDatabase.h; refType = 4; }; - 01FA891FFFF2BE3511CD283A = { + 07A0F69A005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = secagent.h; + path = SSDLSession.cpp; refType = 4; }; - 01FA8920FFF2BE3511CD283A = { - children = ( - 01FA8921FFF2BE3511CD283A, - 01FA8922FFF2BE3511CD283A, - 01FA8923FFF2BE3511CD283A, - 01FA8924FFF2BE3511CD283A, - 01FA8925FFF2BE3511CD283A, - ); - isa = PBXGroup; - path = Security; + 07A0F69B005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = SSDLSession.h; refType = 4; }; - 01FA8921FFF2BE3511CD283A = { + 07A0F69C005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = ACabstractsession.h; + path = SSFactory.cpp; refType = 4; }; - 01FA8922FFF2BE3511CD283A = { + 07A0F69D005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = CLabstractsession.h; + path = SSFactory.h; refType = 4; }; - 01FA8923FFF2BE3511CD283A = { + 07A0F69E005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = CSPabstractsession.h; + path = SSKey.cpp; refType = 4; }; - 01FA8924FFF2BE3511CD283A = { + 07A0F69F005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = DLabstractsession.h; + path = SSKey.h; refType = 4; }; - 01FA8925FFF2BE3511CD283A = { + 07A0F6A0005DAEE111CD283A = { + children = ( + 07A0F6A4005DAEE111CD283A, + 07A0F6A5005DAEE111CD283A, + 07A0F6A8005DAEE111CD283A, + 07A0F6A9005DAEE111CD283A, + 07A0F6AA005DAEE111CD283A, + 3290383500D6BB3705CD296C, + 9DAE2E2D01A3378900003D05, + 9DAE2E2E01A3378900003D05, + ); + isa = PBXGroup; + path = AppleDL; + refType = 4; + }; + 07A0F6A4005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = TPabstractsession.h; + path = AppleFileDL.cpp; refType = 4; }; - 01FA8926FFF2BE3511CD283A = { + 07A0F6A5005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = ucsp.h; + path = AppleFileDL.h; refType = 4; }; - 01FA8929FFF2BE3511CD283A = { - fileRef = 01FA8921FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 07A0F6A8005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = FORMAT; + refType = 4; }; - 01FA892AFFF2BE3511CD283A = { - fileRef = 01FA8922FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; - }; - 01FA892BFFF2BE3511CD283A = { - fileRef = 01FA8923FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 07A0F6A9005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = ISSUES; + refType = 4; }; - 01FA892CFFF2BE3511CD283A = { - fileRef = 01FA8924FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 07A0F6AA005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = TODO; + refType = 4; }; - 01FA892DFFF2BE3511CD283A = { - fileRef = 01FA8925FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 07A0F6AB005DAEE111CD283A = { + children = ( + 07A0F6AD005DAEE111CD283A, + 07A0F6AE005DAEE111CD283A, + 07A0F6B4005DAEE111CD283A, + 07A0F6B5005DAEE111CD283A, + 9D347A350380197600003D05, + 9D347A360380197600003D05, + 07A0F6B6005DAEE111CD283A, + 07A0F6B7005DAEE111CD283A, + 9D347A370380197600003D05, + 07A0F6B8005DAEE111CD283A, + 9D347A380380197600003D05, + 9D347A390380197600003D05, + 07A0F6B9005DAEE111CD283A, + 07A0F6BA005DAEE111CD283A, + 07A0F6BE005DAEE111CD283A, + 07A0F6BF005DAEE111CD283A, + 07A0F6C0005DAEE111CD283A, + 9D347A3A0380197600003D05, + 9D347A3B0380197600003D05, + 9D347A3C0380197600003D05, + 9D347A3D0380197600003D05, + 9D347A3E0380197600003D05, + 9D347A3F0380197600003D05, + 07A0F6C1005DAEE111CD283A, + 07A0F6C2005DAEE111CD283A, + 07A0F6C3005DAEE111CD283A, + 07A0F6C4005DAEE111CD283A, + 07A0F6C5005DAEE111CD283A, + 07A0F6C6005DAEE111CD283A, + F540EDC2027A41BF01CA2E66, + 05F88FCC041003A500003D05, + 05F88FCD041003A500003D05, + 05F88FCE041003A500003D05, + 05F88FCF041003A500003D05, + 07A0F6C9005DAEE111CD283A, + 3290383600D6BB3705CD296C, + 9DAE2E2501A2E63700003D05, + 9DAE2E2601A2E63700003D05, + ); + isa = PBXGroup; + path = AppleX509CL; + refType = 4; }; - 01FA8930FFF2BE3511CD283A = { - fileRef = 01FA890FFFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F6AD005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleX509CL.cpp; + refType = 4; }; - 01FA8931FFF2BE3511CD283A = { - fileRef = 01FA8910FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F6AE005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleX509CL.h; + refType = 4; }; - 01FA8932FFF2BE3511CD283A = { - fileRef = 01FA8911FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F6B4005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CLCertExtensions.cpp; + refType = 4; }; - 01FA8933FFF2BE3511CD283A = { - fileRef = 01FA8913FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F6B5005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CLCertExtensions.h; + refType = 4; }; - 01FA8936FFF2BE3511CD283A = { - fileRef = 01FA8919FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F6B6005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CertFields.cpp; + refType = 4; }; -//010 -//011 -//012 -//013 -//014 -//020 -//021 -//022 -//023 -//024 - 025C84BB0027360A11CD296C = { + 07A0F6B7005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = threading_internal.h; + path = CLCachedEntry.cpp; refType = 4; }; - 025C84BC0027360A11CD296C = { - fileRef = 025C84BB0027360A11CD296C; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 07A0F6B8005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CLCachedEntry.h; + refType = 4; }; -//020 -//021 -//022 -//023 -//024 -//030 -//031 -//032 -//033 -//034 - 030701E1FFF95F6F11CD283A = { + 07A0F6B9005DAEE111CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = Security.exp; + path = CSPAttacher.cpp; refType = 4; }; - 030701E3FFF96F8511CD283A = { - isa = PBXLibraryReference; - path = libSecurityAgentClient.a; - refType = 3; + 07A0F6BA005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = CSPAttacher.h; + refType = 4; }; - 030701E4FFF96F8511CD283A = { - buildPhases = ( - 030701E5FFF96F8511CD283A, - 030701E6FFF96F8511CD283A, - 030701E7FFF96F8511CD283A, - 030701E8FFF96F8511CD283A, - ); - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 54.1.9; - INSTALL_PATH = /usr/local/lib; - LIBRARY_STYLE = STATIC; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_CFLAGS = "-DNOSA -DAGENTPATH=\\\\\\\"$(SYSTEM_LIBRARY_DIR)/CoreServices/SecurityAgent.app\\\\\\\" -DAGENTNAME=\\\\\\\"SecurityAgent\\\\\\\""; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOL_FLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = libSecurityAgentClient.a; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - dependencies = ( - 1B40D2E4FFF9716411CD283A, - ); - isa = PBXLibraryTarget; - name = "SecurityAgent Client"; - productInstallPath = /usr/local/lib; - productName = "SecurityAgent Client"; - productReference = 030701E3FFF96F8511CD283A; - shouldUseHeadermap = 1; + 07A0F6BE005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = cldebugging.h; + refType = 4; }; - 030701E5FFF96F8511CD283A = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F6BF005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = DecodedCert.cpp; + refType = 4; }; - 030701E6FFF96F8511CD283A = { - buildActionMask = 2147483647; - files = ( - 030701E9FFF96F9911CD283A, - 030701EAFFF96F9911CD283A, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F6C0005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = DecodedCert.h; + refType = 4; }; - 030701E7FFF96F8511CD283A = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F6C1005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = LockedMap.h; + refType = 4; }; - 030701E8FFF96F8511CD283A = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 07A0F6C2005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleX509CLSession.cpp; + refType = 4; }; - 030701E9FFF96F9911CD283A = { - fileRef = 01FA821CFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F6C3005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleX509CLSession.h; + refType = 4; }; - 030701EAFFF96F9911CD283A = { - fileRef = 01FA8918FFF2BE3511CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 07A0F6C4005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = Session_Cert.cpp; + refType = 4; }; - 034768DDFF38A45A11DB9C8B = { + 07A0F6C5005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = Session_CRL.cpp; + refType = 4; + }; + 07A0F6C6005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = Session_Crypto.cpp; + refType = 4; + }; + 07A0F6C9005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = TODO; + refType = 4; + }; + 07A0F6CA005DAEE111CD283A = { children = ( - 1BA451B10097605B7F000001, - 01FA88FBFFF2BC5611CD283A, - 01FA8901FFF2BCA811CD283A, - 125E85D4FFF3D67D11CD283A, - 030701E3FFF96F8511CD283A, - 325EAA3100D6B2BE05CD296C, - 325EAA3200D6B2BE05CD296C, - F54323B4022DC91501CA2E64, - 9DC1DEF40299BBCD00003D05, + 07A0F6CB005DAEE111CD283A, + 07A0F6CC005DAEE111CD283A, + 07A0F6CF005DAEE111CD283A, + 07A0F6D0005DAEE111CD283A, + 07A0F6D1005DAEE111CD283A, + 07A0F6D2005DAEE111CD283A, + 07A0F6D6005DAEE111CD283A, + 07A0F6D8005DAEE111CD283A, + 07A0F6DB005DAEE111CD283A, + 07A0F6DC005DAEE111CD283A, + 9D4B1BC70156C2E500A17CD1, + 9D347A4B038019EF00003D05, + 9D347A4C038019EF00003D05, + 9D347A4D038019EF00003D05, + 9D347A4E038019EF00003D05, + 9D347A4F038019EF00003D05, + 9D347A50038019EF00003D05, + 9D347A51038019EF00003D05, + 9D347A52038019EF00003D05, + 07A0F6DD005DAEE111CD283A, + 07A0F6DE005DAEE111CD283A, + 07A0F6DF005DAEE111CD283A, + 07A0F6E0005DAEE111CD283A, + 3290383700D6BB3705CD296C, + 9DAE2E2901A2F93200003D05, + 9DAE2E2A01A2F93200003D05, + 9D09B90701B4314500003D05, + 9D14AC52020093D100003D05, + 9D9AEFBA02B6BC6C00003D05, ); isa = PBXGroup; - name = Products; - path = ""; + path = AppleX509TP; refType = 4; }; - 039FF1DB00724BE07F000001 = { + 07A0F6CB005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleTP.cpp; + refType = 4; + }; + 07A0F6CC005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleTP.h; + refType = 4; + }; + 07A0F6CF005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleTPSession.cpp; + refType = 4; + }; + 07A0F6D0005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleTPSession.h; + refType = 4; + }; + 07A0F6D1005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = certGroupUtils.cpp; + refType = 4; + }; + 07A0F6D2005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = certGroupUtils.h; + refType = 4; + }; + 07A0F6D6005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = tpdebugging.h; + refType = 4; + }; + 07A0F6D8005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootCerts.h; + refType = 4; + }; + 07A0F6DB005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = TPCertInfo.cpp; + refType = 4; + }; + 07A0F6DC005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = TPCertInfo.h; + refType = 4; + }; + 07A0F6DD005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = tpPolicies.cpp; + refType = 4; + }; + 07A0F6DE005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = tpPolicies.h; + refType = 4; + }; + 07A0F6DF005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = tpTime.c; + refType = 4; + }; + 07A0F6E0005DAEE111CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = tpTime.h; + refType = 4; + }; + 07E4D6D300A0CA617F000001 = { children = ( - 039FF1DC00724C3A7F000001, - 039FF1E200724FFC7F000001, - 0149035400A9DC487F000001, - 0149035500A9DC487F000001, - 07A0F672005DAEE111CD283A, - 07A0F673005DAEE111CD283A, - 209FCB5000A739657F000001, - 209FCB4E00A738117F000001, - 59375E6B00A848827F000001, - 0149035600A9DC487F000001, - 0149035700A9DC487F000001, - 039FF1E000724E6E7F000001, - 039FF1DE00724E1A7F000001, - 0149036400A9DF347F000001, - 2C5247F0007A39B47F000001, - 2C5247F1007A39B47F000001, - 52BFC307007A6A1B7F000001, - 52BFC308007A6A1B7F000001, - 4A4C7674007A52DC7F000001, - 4A4C7675007A52DC7F000001, - 59375E7100A849BB7F000001, - 0149035800A9DC487F000001, - 0149035900A9DC487F000001, - 0149035A00A9DC487F000001, - 0149035B00A9DC487F000001, - 07A0F675005DAEE111CD283A, - 07A0F674005DAEE111CD283A, - 9D206AA601EB68F200003D05, + 07E4D6D400A0CA617F000001, + 07E4D6D500A0CA617F000001, + 07E4D6D600A0CA617F000001, + 07E4D6D700A0CA617F000001, + 07E4D6D800A0CA617F000001, + 07E4D6D900A0CA617F000001, + 07E4D6DA00A0CA617F000001, + 07E4D6DB00A0CA617F000001, ); isa = PBXGroup; - name = MiscCSPAlgs; + name = dsa; refType = 4; }; - 039FF1DC00724C3A7F000001 = { + 07E4D6D400A0CA617F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = desContext.cpp; - path = MiscCSPAlgs/desContext.cpp; + name = dsa_asn1.c; + path = dsa/dsa_asn1.c; refType = 4; }; - 039FF1DD00724C3A7F000001 = { - fileRef = 039FF1DC00724C3A7F000001; - isa = PBXBuildFile; - settings = { - }; + 07E4D6D500A0CA617F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dsa_err.c; + path = dsa/dsa_err.c; + refType = 4; }; - 039FF1DE00724E1A7F000001 = { + 07E4D6D600A0CA617F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = miscAlgFactory.h; - path = MiscCSPAlgs/miscAlgFactory.h; + name = dsa_gen.c; + path = dsa/dsa_gen.c; refType = 4; }; - 039FF1DF00724E1A7F000001 = { - fileRef = 039FF1DE00724E1A7F000001; - isa = PBXBuildFile; - settings = { - }; + 07E4D6D700A0CA617F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dsa_key.c; + path = dsa/dsa_key.c; + refType = 4; }; - 039FF1E000724E6E7F000001 = { + 07E4D6D800A0CA617F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = miscAlgFactory.cpp; - path = MiscCSPAlgs/miscAlgFactory.cpp; + name = dsa_lib.c; + path = dsa/dsa_lib.c; refType = 4; }; - 039FF1E100724E6E7F000001 = { - fileRef = 039FF1E000724E6E7F000001; - isa = PBXBuildFile; - settings = { - }; + 07E4D6D900A0CA617F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dsa_ossl.c; + path = dsa/dsa_ossl.c; + refType = 4; }; - 039FF1E200724FFC7F000001 = { + 07E4D6DA00A0CA617F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = desContext.h; - path = AppleCSP/MiscCSPAlgs/desContext.h; - refType = 2; + name = dsa_sign.c; + path = dsa/dsa_sign.c; + refType = 4; }; - 039FF1E300724FFC7F000001 = { - fileRef = 039FF1E200724FFC7F000001; + 07E4D6DB00A0CA617F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dsa_vrf.c; + path = dsa/dsa_vrf.c; + refType = 4; + }; + 07E4D6DC00A0CA617F000001 = { + fileRef = 07E4D6D400A0CA617F000001; isa = PBXBuildFile; settings = { }; }; - 03B76D49FFF2D31811CD283A = { - fileRef = 01FA823CFFF2B54C11CD283A; + 07E4D6DD00A0CA617F000001 = { + fileRef = 07E4D6D500A0CA617F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 03B76D4AFFF2D35D11CD283A = { - fileRef = 01FA8227FFF2B54C11CD283A; + 07E4D6DE00A0CA617F000001 = { + fileRef = 07E4D6D600A0CA617F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 03B76D4BFFF2D35D11CD283A = { - fileRef = 01FA8229FFF2B54C11CD283A; + 07E4D6DF00A0CA617F000001 = { + fileRef = 07E4D6D700A0CA617F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 03B76D4CFFF2D35D11CD283A = { - fileRef = 01FA821FFFF2B54C11CD283A; + 07E4D6E000A0CA617F000001 = { + fileRef = 07E4D6D800A0CA617F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 03B76D4DFFF2D35D11CD283A = { - fileRef = 01FA8926FFF2BE3511CD283A; + 07E4D6E100A0CA617F000001 = { + fileRef = 07E4D6D900A0CA617F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 03B76D4EFFF2D35D11CD283A = { - fileRef = 01FA8226FFF2B54C11CD283A; + 07E4D6E200A0CA617F000001 = { + fileRef = 07E4D6DA00A0CA617F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 03B76D4FFFF2D35D11CD283A = { - fileRef = 01FA8228FFF2B54C11CD283A; + 07E4D6E300A0CA617F000001 = { + fileRef = 07E4D6DB00A0CA617F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 03B76D51FFF2D43011CD283A = { - fileRef = 01FA891CFFF2BE3511CD283A; + 07E4D6E400A0CD8D7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = sha.h; + path = openssl/sha.h; + refType = 4; + }; + 07E4D6E500A0CD8D7F000001 = { + fileRef = 07E4D6E400A0CD8D7F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; -//030 -//031 -//032 -//033 -//034 -//050 -//051 -//052 -//053 -//054 - 05855484FFF2DA1E11CD283A = { - isa = PBXTargetDependency; - target = 01FA88F0FFF2B96911CD283A; - }; -//050 -//051 -//052 -//053 -//054 //070 //071 //072 //073 //074 - 07A0F5EA005DAEE111CD283A = { - children = ( - 256C38AB0094AE067F000001, - 57FCEE8D007B8B3D7F000001, - 2C5247EA007A39B47F000001, - 039FF1DB00724BE07F000001, - 07A0F5EB005DAEE111CD283A, - 07A0F5F4005DAEE111CD283A, - 07A0F606005DAEE111CD283A, - 07A0F66E005DAEE111CD283A, - 07A0F680005DAEE111CD283A, - 9D291881026B56B800003D05, - 07A0F685005DAEE111CD283A, - 325EAA3700D6B47405CD296C, - 9D64BAF1019B176100003D05, - 9D64BAF2019B176100003D05, - 9D64BAF3019B176100003D05, - 9DA13D0401B4638200003D05, +//080 +//081 +//082 +//083 +//084 + 0867D690FE84028FC02AAC07 = { + buildStyles = ( + 01CE6B1AFFF2B1BA11CD283A, + 01CE6B19FFF2B1BA11CD283A, + C2F346A204D5C05D0039D9E5, + 320C8FE900EA6AD705CD296C, + F58998F803809BCA01CA2A98, + ); + hasScannedForEncodings = 1; + isa = PBXProject; + mainGroup = 0867D691FE84028FC02AAC07; + productRefGroup = 034768DDFF38A45A11DB9C8B; + projectDirPath = ""; + targets = ( + 01CE6B1BFFF2B31311CD283A, + 01CE6B1DFFF2B33A11CD283A, + 01FA88F0FFF2B96911CD283A, + 0867D69CFE84028FC02AAC07, + 030701E4FFF96F8511CD283A, + 125E85D5FFF3D67D11CD283A, + 01FA88FCFFF2BC5611CD283A, + 01FA8904FFF2BCA811CD283A, + C2907DD4042BA6B100CA2E77, + 01FA88F9FFF2BBEB11CD283A, + 3290385000D6BB7805CD296C, + 014880CD005EAE4D11CD283A, + 014880D4005EAE4D11CD283A, + 014880DA005EAE4D11CD283A, + 014880E0005EAE4D11CD283A, + 014880E6005EAE4D11CD283A, + 3290383800D6BB3705CD296C, + 325EAA2200D6B08805CD296C, + 3290382200D6BA5905CD296C, + 3290381900D6BA5905CD296C, + 3290382800D6BA5905CD296C, + 3290382E00D6BA5905CD296C, + 9D347A6A0380312200003D05, + 9DC1DEF30299BBCD00003D05, + 9D347A8B0380359B00003D05, + C227CDC903E7171400CA2E77, + 322C5F3B02B9641F05CA2E77, ); - isa = PBXGroup; - path = AppleCSP; - refType = 4; }; - 07A0F5EB005DAEE111CD283A = { + 0867D691FE84028FC02AAC07 = { children = ( - 07A0F5EC005DAEE111CD283A, - 07A0F5EE005DAEE111CD283A, - 4AC94A7E0084C0977F000001, - 07A0F5EF005DAEE111CD283A, - 07A0F5F0005DAEE111CD283A, - 07A0F5F1005DAEE111CD283A, - 07A0F5F2005DAEE111CD283A, - 07A0F5F3005DAEE111CD283A, - 4AC94A7C0084BE397F000001, - 9D8F0D1D01C80C0C00003D05, - 9D2C3D0001C826C800003D05, - 9D8F0D1E01C80C0C00003D05, - 9D8F0D1F01C80C0C00003D05, - 9D2C3D0201C82F6000003D05, + 01FA7FE6FFF2B54C11CD283A, + 0177F263FFFAA2D311CD283A, + 0F404EB6008616EE7F000001, + 01FA819DFFF2B54C11CD283A, + 01FA8126FFF2B54C11CD283A, + 07A0F5EA005DAEE111CD283A, + 07A0F686005DAEE111CD283A, + 07A0F6A0005DAEE111CD283A, + 07A0F6AB005DAEE111CD283A, + 07A0F6CA005DAEE111CD283A, + F5A5E50E00FB884E01CD29D4, + 9DC1DEEE0299BBA900003D05, + 9DC1DEEC0299BB8F00003D05, + 9D347A950380362500003D05, + C227CDC203E716B100CA2E77, + 3283A53702B96AF805CA2E77, + 01FA890DFFF2BD9911CD283A, + 01FA890EFFF2BD9911CD283A, + 030701E1FFF95F6F11CD283A, + 0867D69AFE84028FC02AAC07, + 034768DDFF38A45A11DB9C8B, ); isa = PBXGroup; - path = AES; - refType = 4; - }; - 07A0F5EC005DAEE111CD283A = { - isa = PBXFileReference; - path = aescsp.cpp; - refType = 4; - }; - 07A0F5EE005DAEE111CD283A = { - isa = PBXFileReference; - path = aescspi.h; - refType = 4; - }; - 07A0F5EF005DAEE111CD283A = { - isa = PBXFileReference; - path = "boxes-ref.h"; - refType = 4; - }; - 07A0F5F0005DAEE111CD283A = { - isa = PBXFileReference; - path = "rijndael-alg-ref.c"; - refType = 4; - }; - 07A0F5F1005DAEE111CD283A = { - isa = PBXFileReference; - path = "rijndael-alg-ref.h"; - refType = 4; - }; - 07A0F5F2005DAEE111CD283A = { - isa = PBXFileReference; - path = rijndaelApi.c; - refType = 4; - }; - 07A0F5F3005DAEE111CD283A = { - isa = PBXFileReference; - path = rijndaelApi.h; + name = Security; refType = 4; }; - 07A0F5F4005DAEE111CD283A = { + 0867D69AFE84028FC02AAC07 = { children = ( - 07A0F5F5005DAEE111CD283A, - 07A0F5F6005DAEE111CD283A, - 07A0F5F7005DAEE111CD283A, - 07A0F5F8005DAEE111CD283A, - 07A0F5F9005DAEE111CD283A, - 07A0F5FA005DAEE111CD283A, - 07A0F5FB005DAEE111CD283A, - 07A0F5FC005DAEE111CD283A, - 07A0F5FD005DAEE111CD283A, - 07A0F5FE005DAEE111CD283A, - 07A0F5FF005DAEE111CD283A, - 07A0F600005DAEE111CD283A, - 07A0F601005DAEE111CD283A, - 07A0F602005DAEE111CD283A, - 07A0F603005DAEE111CD283A, - 1691956B009480BC7F000001, - 07A0F604005DAEE111CD283A, - 07A0F605005DAEE111CD283A, - 1691956D009485A47F000001, - 1691956F009486767F000001, - 48855E830095DC957F000001, - 48855E850095DD697F000001, + 325EAA2900D6B23F05CD296C, + 125E85ADFFF3D44A11CD283A, + 327DDDFA00D7E81F05CD296C, + 9D347A5F0380300100003D05, ); isa = PBXGroup; - path = AppleCSP; - refType = 4; - }; - 07A0F5F5005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleCSP.cpp; - refType = 4; - }; - 07A0F5F6005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleCSP.h; - refType = 4; - }; - 07A0F5F7005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleCSPContext.cpp; - refType = 4; - }; - 07A0F5F8005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleCSPContext.h; - refType = 4; - }; - 07A0F5F9005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleCSPSession.h; - refType = 4; - }; - 07A0F5FA005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleCSPUtils.cpp; - refType = 4; - }; - 07A0F5FB005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleCSPUtils.h; + name = "External Frameworks and Libraries"; refType = 4; }; - 07A0F5FC005DAEE111CD283A = { - isa = PBXFileReference; - path = BinaryKey.h; - refType = 4; - }; - 07A0F5FD005DAEE111CD283A = { - isa = PBXFileReference; - path = BlockCryptor.cpp; - refType = 4; - }; - 07A0F5FE005DAEE111CD283A = { - isa = PBXFileReference; - path = BlockCryptor.h; - refType = 4; - }; - 07A0F5FF005DAEE111CD283A = { - isa = PBXFileReference; - path = cspdebugging.c; - refType = 4; - }; - 07A0F600005DAEE111CD283A = { - isa = PBXFileReference; - path = cspdebugging.h; - refType = 4; - }; - 07A0F601005DAEE111CD283A = { - isa = PBXFileReference; - path = deriveKey.cpp; - refType = 4; - }; - 07A0F602005DAEE111CD283A = { - isa = PBXFileReference; - path = pkcs_7_8.cpp; - refType = 4; - }; - 07A0F603005DAEE111CD283A = { - isa = PBXFileReference; - path = pkcs_7_8.h; - refType = 4; - }; - 07A0F604005DAEE111CD283A = { - isa = PBXFileReference; - path = wrapKey.cpp; - refType = 4; - }; - 07A0F605005DAEE111CD283A = { - isa = PBXFileReference; - path = wrapKeyCms.cpp; - refType = 4; - }; - 07A0F606005DAEE111CD283A = { - children = ( - 07A0F607005DAEE111CD283A, - 07A0F608005DAEE111CD283A, - 07A0F609005DAEE111CD283A, - 07A0F60A005DAEE111CD283A, - 07A0F60B005DAEE111CD283A, - 07A0F60C005DAEE111CD283A, - 07A0F60D005DAEE111CD283A, - 07A0F60E005DAEE111CD283A, - 07A0F60F005DAEE111CD283A, - 07A0F610005DAEE111CD283A, - 07A0F611005DAEE111CD283A, - 07A0F612005DAEE111CD283A, + 0867D69CFE84028FC02AAC07 = { + buildPhases = ( + 0867D69DFE84028FC02AAC07, + 0867D69EFE84028FC02AAC07, + 0867D69FFE84028FC02AAC07, + 0867D6A0FE84028FC02AAC07, + 0867D6A2FE84028FC02AAC07, + F5DDE3AE00B3358F01CD283A, ); - isa = PBXGroup; - path = BSafeCSP; - refType = 4; - }; - 07A0F607005DAEE111CD283A = { - isa = PBXFileReference; - path = algmaker.cpp; - refType = 4; - }; - 07A0F608005DAEE111CD283A = { - isa = PBXFileReference; - path = bsafeAsymmetric.cpp; - refType = 4; - }; - 07A0F609005DAEE111CD283A = { - isa = PBXFileReference; - path = bsafeContext.cpp; - refType = 4; - }; - 07A0F60A005DAEE111CD283A = { - isa = PBXFileReference; - path = bsafecsp.h; - refType = 4; - }; - 07A0F60B005DAEE111CD283A = { - isa = PBXFileReference; - path = bsafecspi.h; - refType = 4; - }; - 07A0F60C005DAEE111CD283A = { - isa = PBXFileReference; - path = bsafeKeyGen.cpp; - refType = 4; - }; - 07A0F60D005DAEE111CD283A = { - isa = PBXFileReference; - path = bsafePKCS1.cpp; - refType = 4; - }; - 07A0F60E005DAEE111CD283A = { - isa = PBXFileReference; - path = bsafePKCS1.h; - refType = 4; - }; - 07A0F60F005DAEE111CD283A = { - isa = PBXFileReference; - path = bsafeSymmetric.cpp; - refType = 4; - }; - 07A0F610005DAEE111CD283A = { - isa = PBXFileReference; - path = bsobjects.h; - refType = 4; - }; - 07A0F611005DAEE111CD283A = { - isa = PBXFileReference; - path = memory.cpp; - refType = 4; - }; - 07A0F612005DAEE111CD283A = { - isa = PBXFileReference; - path = miscalgorithms.cpp; - refType = 4; - }; - 07A0F66E005DAEE111CD283A = { - children = ( - 07A0F66F005DAEE111CD283A, - 07A0F670005DAEE111CD283A, - 07A0F671005DAEE111CD283A, - 07A0F676005DAEE111CD283A, - 07A0F677005DAEE111CD283A, - 07A0F678005DAEE111CD283A, - 07A0F679005DAEE111CD283A, - 07A0F67A005DAEE111CD283A, - 07A0F67B005DAEE111CD283A, - 07A0F67E005DAEE111CD283A, - 07A0F67F005DAEE111CD283A, - 63B97E6600603F0A7F000001, + buildSettings = { + CURRENT_PROJECT_VERSION = 163; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 163; + FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\""; + FRAMEWORK_VERSION = A; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)\" \"$(BUILT_PRODUCTS_DIR)/derived_src\""; + INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + LIBRARY_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)\""; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = "-DLIMITED_SIGNING -DBUILTIN_PLUGINS -DVDADER_RULES -DCRYPTKIT_CSP_ENABLE -DASC_CSP_ENABLE"; + OTHER_LDFLAGS = "-lComCryption -lCryptKit -twolevel_namespace -lnssasn1"; + PREBINDING = YES; + PRODUCT_NAME = Security; + SECTORDER_FLAGS = "-sectorder __TEXT __text \"$(SRCROOT)/Security.order\" -seg_addr_table \"$(APPLE_INTERNAL_DEVELOPER_DIR)/seg_addr_table\""; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = Sec; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = framework; + }; + dependencies = ( + C25FA84D03CB689300CA2E77, + 3290384F00D6BB7805CD296C, + 05855484FFF2DA1E11CD283A, ); - isa = PBXGroup; - path = CryptKitCSP; - refType = 4; - }; - 07A0F66F005DAEE111CD283A = { - isa = PBXFileReference; - path = cryptkitcsp.cpp; - refType = 4; - }; - 07A0F670005DAEE111CD283A = { - isa = PBXFileReference; - path = cryptkitcsp.h; - refType = 4; - }; - 07A0F671005DAEE111CD283A = { - isa = PBXFileReference; - path = CryptKitSpace.h; - refType = 4; - }; - 07A0F672005DAEE111CD283A = { - isa = PBXFileReference; - name = DigestContext.cpp; - path = AppleCSP/MiscCSPAlgs/DigestContext.cpp; - refType = 2; - }; - 07A0F673005DAEE111CD283A = { - isa = PBXFileReference; - name = DigestContext.h; - path = AppleCSP/MiscCSPAlgs/DigestContext.h; - refType = 2; - }; - 07A0F674005DAEE111CD283A = { - isa = PBXFileReference; - name = SHA1_MD5_Object.cpp; - path = MiscCSPAlgs/SHA1_MD5_Object.cpp; - refType = 4; - }; - 07A0F675005DAEE111CD283A = { - isa = PBXFileReference; - name = SHA1_MD5_Object.h; - path = MiscCSPAlgs/SHA1_MD5_Object.h; - refType = 4; - }; - 07A0F676005DAEE111CD283A = { - isa = PBXFileReference; - path = FEEAsymmetricContext.cpp; - refType = 4; - }; - 07A0F677005DAEE111CD283A = { - isa = PBXFileReference; - path = FEEAsymmetricContext.h; - refType = 4; - }; - 07A0F678005DAEE111CD283A = { - isa = PBXFileReference; - path = FEECSPUtils.cpp; - refType = 4; - }; - 07A0F679005DAEE111CD283A = { - isa = PBXFileReference; - path = FEECSPUtils.h; - refType = 4; + isa = PBXFrameworkTarget; + name = Security; + productInstallPath = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + productName = Security; + productReference = F54323B4022DC91501CA2E64; + productSettingsXML = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + Security + CFBundleGetInfoString + Security.framework 2.0, Copyright © 2000-2002 Apple Computer Inc. + CFBundleIconFile + + CFBundleIdentifier + com.apple.security + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Security + CFBundlePackageType + FMWK + CFBundleShortVersionString + 2.0 + CFBundleSignature + ???? + CFBundleVersion + 163 + + +"; }; - 07A0F67A005DAEE111CD283A = { - isa = PBXFileReference; - path = FEEKeys.cpp; - refType = 4; - }; - 07A0F67B005DAEE111CD283A = { - isa = PBXFileReference; - path = FEEKeys.h; - refType = 4; - }; - 07A0F67E005DAEE111CD283A = { - isa = PBXFileReference; - path = FEESignatureObject.cpp; - refType = 4; - }; - 07A0F67F005DAEE111CD283A = { - isa = PBXFileReference; - path = FEESignatureObject.h; - refType = 4; - }; - 07A0F680005DAEE111CD283A = { - children = ( - 07A0F681005DAEE111CD283A, - 07A0F682005DAEE111CD283A, - 07A0F683005DAEE111CD283A, - 07A0F684005DAEE111CD283A, - ); - isa = PBXGroup; - path = PBKDF2; - refType = 4; - }; - 07A0F681005DAEE111CD283A = { - isa = PBXFileReference; - path = HMACSHA1.c; - refType = 4; - }; - 07A0F682005DAEE111CD283A = { - isa = PBXFileReference; - path = HMACSHA1.h; - refType = 4; - }; - 07A0F683005DAEE111CD283A = { - isa = PBXFileReference; - path = pbkdf2.c; - refType = 4; - }; - 07A0F684005DAEE111CD283A = { - isa = PBXFileReference; - path = pbkdf2.h; - refType = 4; - }; - 07A0F685005DAEE111CD283A = { - isa = PBXFileReference; - path = TODO; - refType = 4; - }; - 07A0F686005DAEE111CD283A = { - children = ( - 07A0F68A005DAEE111CD283A, - 07A0F68B005DAEE111CD283A, - 07A0F68C005DAEE111CD283A, - 07A0F68D005DAEE111CD283A, - F5E32A1500EAB9A301CD283A, - 07A0F691005DAEE111CD283A, - 07A0F692005DAEE111CD283A, - 07A0F693005DAEE111CD283A, - 07A0F694005DAEE111CD283A, - 07A0F695005DAEE111CD283A, - 07A0F696005DAEE111CD283A, - 07A0F697005DAEE111CD283A, - 07A0F698005DAEE111CD283A, - 07A0F699005DAEE111CD283A, - 07A0F69A005DAEE111CD283A, - 07A0F69B005DAEE111CD283A, - 07A0F69C005DAEE111CD283A, - 07A0F69D005DAEE111CD283A, - 07A0F69E005DAEE111CD283A, - 07A0F69F005DAEE111CD283A, - 327DDDE700D6FC1A05CD296C, - 9DAE2E3201A43D6B00003D05, - 9DAE2E3301A43D6B00003D05, - 9DAE2E3401A43D6B00003D05, - 9DAE2E3501A43D6B00003D05, - ); - isa = PBXGroup; - path = AppleCSPDL; - refType = 4; - }; - 07A0F68A005DAEE111CD283A = { - isa = PBXFileReference; - path = CSPDLDatabase.cpp; - refType = 4; - }; - 07A0F68B005DAEE111CD283A = { - isa = PBXFileReference; - path = CSPDLDatabase.h; - refType = 4; - }; - 07A0F68C005DAEE111CD283A = { - isa = PBXFileReference; - path = CSPDLPlugin.cpp; - refType = 4; - }; - 07A0F68D005DAEE111CD283A = { - isa = PBXFileReference; - path = CSPDLPlugin.h; - refType = 4; - }; - 07A0F690005DAEE111CD283A = { - isa = PBXFileReference; - path = KeySchema.cpp; - refType = 4; - }; - 07A0F691005DAEE111CD283A = { - isa = PBXFileReference; - path = KeySchema.h; - refType = 4; - }; - 07A0F692005DAEE111CD283A = { - isa = PBXFileReference; - path = SSContext.cpp; - refType = 4; - }; - 07A0F693005DAEE111CD283A = { - isa = PBXFileReference; - path = SSContext.h; - refType = 4; - }; - 07A0F694005DAEE111CD283A = { - isa = PBXFileReference; - path = SSCSPDLSession.cpp; - refType = 4; - }; - 07A0F695005DAEE111CD283A = { - isa = PBXFileReference; - path = SSCSPDLSession.h; - refType = 4; - }; - 07A0F696005DAEE111CD283A = { - isa = PBXFileReference; - path = SSCSPSession.cpp; - refType = 4; - }; - 07A0F697005DAEE111CD283A = { - isa = PBXFileReference; - path = SSCSPSession.h; - refType = 4; - }; - 07A0F698005DAEE111CD283A = { - isa = PBXFileReference; - path = SSDatabase.cpp; - refType = 4; - }; - 07A0F699005DAEE111CD283A = { - isa = PBXFileReference; - path = SSDatabase.h; - refType = 4; - }; - 07A0F69A005DAEE111CD283A = { - isa = PBXFileReference; - path = SSDLSession.cpp; - refType = 4; - }; - 07A0F69B005DAEE111CD283A = { - isa = PBXFileReference; - path = SSDLSession.h; - refType = 4; - }; - 07A0F69C005DAEE111CD283A = { - isa = PBXFileReference; - path = SSFactory.cpp; - refType = 4; - }; - 07A0F69D005DAEE111CD283A = { - isa = PBXFileReference; - path = SSFactory.h; - refType = 4; - }; - 07A0F69E005DAEE111CD283A = { - isa = PBXFileReference; - path = SSKey.cpp; - refType = 4; - }; - 07A0F69F005DAEE111CD283A = { - isa = PBXFileReference; - path = SSKey.h; - refType = 4; - }; - 07A0F6A0005DAEE111CD283A = { - children = ( - 07A0F6A4005DAEE111CD283A, - 07A0F6A5005DAEE111CD283A, - 07A0F6A8005DAEE111CD283A, - 07A0F6A9005DAEE111CD283A, - 07A0F6AA005DAEE111CD283A, - 3290383500D6BB3705CD296C, - 9DAE2E2D01A3378900003D05, - 9DAE2E2E01A3378900003D05, - ); - isa = PBXGroup; - path = AppleDL; - refType = 4; - }; - 07A0F6A4005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleFileDL.cpp; - refType = 4; - }; - 07A0F6A5005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleFileDL.h; - refType = 4; - }; - 07A0F6A8005DAEE111CD283A = { - isa = PBXFileReference; - path = FORMAT; - refType = 4; - }; - 07A0F6A9005DAEE111CD283A = { - isa = PBXFileReference; - path = ISSUES; - refType = 4; - }; - 07A0F6AA005DAEE111CD283A = { - isa = PBXFileReference; - path = TODO; - refType = 4; - }; - 07A0F6AB005DAEE111CD283A = { - children = ( - 07A0F6AD005DAEE111CD283A, - 07A0F6AE005DAEE111CD283A, - 07A0F6B2005DAEE111CD283A, - 07A0F6B3005DAEE111CD283A, - 07A0F6B4005DAEE111CD283A, - 07A0F6B5005DAEE111CD283A, - 07A0F6B6005DAEE111CD283A, - 07A0F6B7005DAEE111CD283A, - 07A0F6B8005DAEE111CD283A, - 07A0F6B9005DAEE111CD283A, - 07A0F6BA005DAEE111CD283A, - 07A0F6BD005DAEE111CD283A, - 07A0F6BE005DAEE111CD283A, - 07A0F6BF005DAEE111CD283A, - 07A0F6C0005DAEE111CD283A, - 07A0F6C1005DAEE111CD283A, - 07A0F6C2005DAEE111CD283A, - 07A0F6C3005DAEE111CD283A, - 07A0F6C4005DAEE111CD283A, - 07A0F6C5005DAEE111CD283A, - 07A0F6C6005DAEE111CD283A, - F540EDC2027A41BF01CA2E66, - 07A0F6C7005DAEE111CD283A, - 07A0F6C8005DAEE111CD283A, - 07A0F6C9005DAEE111CD283A, - 3290383600D6BB3705CD296C, - 9DAE2E2501A2E63700003D05, - 9DAE2E2601A2E63700003D05, - ); - isa = PBXGroup; - path = AppleX509CL; - refType = 4; - }; - 07A0F6AD005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleX509CL.cpp; - refType = 4; - }; - 07A0F6AE005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleX509CL.h; - refType = 4; - }; - 07A0F6B2005DAEE111CD283A = { - isa = PBXFileReference; - path = CertBuilder.cpp; - refType = 4; - }; - 07A0F6B3005DAEE111CD283A = { - isa = PBXFileReference; - path = CertBuilder.h; - refType = 4; - }; - 07A0F6B4005DAEE111CD283A = { - isa = PBXFileReference; - path = CLCertExtensions.cpp; - refType = 4; - }; - 07A0F6B5005DAEE111CD283A = { - isa = PBXFileReference; - path = CLCertExtensions.h; - refType = 4; - }; - 07A0F6B6005DAEE111CD283A = { - isa = PBXFileReference; - path = CertFields.cpp; - refType = 4; - }; - 07A0F6B7005DAEE111CD283A = { - isa = PBXFileReference; - path = CLCachedEntry.cpp; - refType = 4; - }; - 07A0F6B8005DAEE111CD283A = { - isa = PBXFileReference; - path = CLCachedEntry.h; - refType = 4; - }; - 07A0F6B9005DAEE111CD283A = { - isa = PBXFileReference; - path = CSPAttacher.cpp; - refType = 4; - }; - 07A0F6BA005DAEE111CD283A = { - isa = PBXFileReference; - path = CSPAttacher.h; - refType = 4; - }; - 07A0F6BD005DAEE111CD283A = { - isa = PBXFileReference; - path = cldebugging.c; - refType = 4; - }; - 07A0F6BE005DAEE111CD283A = { - isa = PBXFileReference; - path = cldebugging.h; - refType = 4; - }; - 07A0F6BF005DAEE111CD283A = { - isa = PBXFileReference; - path = DecodedCert.cpp; - refType = 4; - }; - 07A0F6C0005DAEE111CD283A = { - isa = PBXFileReference; - path = DecodedCert.h; - refType = 4; - }; - 07A0F6C1005DAEE111CD283A = { - isa = PBXFileReference; - path = LockedMap.h; - refType = 4; - }; - 07A0F6C2005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleX509CLSession.cpp; - refType = 4; - }; - 07A0F6C3005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleX509CLSession.h; - refType = 4; - }; - 07A0F6C4005DAEE111CD283A = { - isa = PBXFileReference; - path = Session_Cert.cpp; - refType = 4; + 0867D69DFE84028FC02AAC07 = { + buildActionMask = 2147483647; + files = ( + 01FA848EFFF2B54C11CD283A, + 01FA848FFFF2B54C11CD283A, + 01FA8490FFF2B54C11CD283A, + 01FA8491FFF2B54C11CD283A, + 01FA8492FFF2B54C11CD283A, + 01FA8493FFF2B54C11CD283A, + 01FA8494FFF2B54C11CD283A, + 01FA8495FFF2B54C11CD283A, + 01FA8496FFF2B54C11CD283A, + 01FA8497FFF2B54C11CD283A, + 01FA8498FFF2B54C11CD283A, + 01FA8499FFF2B54C11CD283A, + 01FA849AFFF2B54C11CD283A, + 01FA849BFFF2B54C11CD283A, + 01FA849CFFF2B54C11CD283A, + 01FA849DFFF2B54C11CD283A, + 01FA849EFFF2B54C11CD283A, + 01FA849FFFF2B54C11CD283A, + 01FA84A0FFF2B54C11CD283A, + 01FA84A1FFF2B54C11CD283A, + 01FA84A2FFF2B54C11CD283A, + 01FA84A3FFF2B54C11CD283A, + 01FA84A4FFF2B54C11CD283A, + 01FA84A5FFF2B54C11CD283A, + 01FA84A6FFF2B54C11CD283A, + 01FA84A7FFF2B54C11CD283A, + 01FA84A8FFF2B54C11CD283A, + 01FA84AAFFF2B54C11CD283A, + 01FA84ABFFF2B54C11CD283A, + 01FA84ACFFF2B54C11CD283A, + 01FA84ADFFF2B54C11CD283A, + 01FA84AEFFF2B54C11CD283A, + 01FA84AFFFF2B54C11CD283A, + 01FA84B0FFF2B54C11CD283A, + 01FA84B1FFF2B54C11CD283A, + 01FA84B2FFF2B54C11CD283A, + 01FA84B3FFF2B54C11CD283A, + 01FA84B4FFF2B54C11CD283A, + 01FA84B5FFF2B54C11CD283A, + 01FA84B6FFF2B54C11CD283A, + 01FA84B7FFF2B54C11CD283A, + 01FA84B8FFF2B54C11CD283A, + 01FA84B9FFF2B54C11CD283A, + 01FA84BAFFF2B54C11CD283A, + 01FA84BBFFF2B54C11CD283A, + 01FA84BCFFF2B54C11CD283A, + 01FA84BDFFF2B54C11CD283A, + 01FA84BEFFF2B54C11CD283A, + 01FA84BFFFF2B54C11CD283A, + 01FA84C0FFF2B54C11CD283A, + 01FA84C1FFF2B54C11CD283A, + 01FA84C2FFF2B54C11CD283A, + 01FA84C3FFF2B54C11CD283A, + 01FA84C5FFF2B54C11CD283A, + 01FA84C6FFF2B54C11CD283A, + 01FA84C7FFF2B54C11CD283A, + 01FA84C8FFF2B54C11CD283A, + 01FA84C9FFF2B54C11CD283A, + 01FA84CAFFF2B54C11CD283A, + 01FA84CBFFF2B54C11CD283A, + 01FA84CCFFF2B54C11CD283A, + 01FA84CEFFF2B54C11CD283A, + 01FA84CFFFF2B54C11CD283A, + 01FA84D0FFF2B54C11CD283A, + 01FA84D1FFF2B54C11CD283A, + 01FA84D2FFF2B54C11CD283A, + 01FA84D3FFF2B54C11CD283A, + 01FA84D4FFF2B54C11CD283A, + 01FA84D5FFF2B54C11CD283A, + 01FA84D6FFF2B54C11CD283A, + 01FA84D7FFF2B54C11CD283A, + 01FA84D8FFF2B54C11CD283A, + 01FA84D9FFF2B54C11CD283A, + 01FA84DAFFF2B54C11CD283A, + 01FA84DBFFF2B54C11CD283A, + 01FA84DCFFF2B54C11CD283A, + 01FA84DDFFF2B54C11CD283A, + 01FA84DEFFF2B54C11CD283A, + 01FA84DFFFF2B54C11CD283A, + 01FA84E0FFF2B54C11CD283A, + 01FA84E1FFF2B54C11CD283A, + 01FA84E2FFF2B54C11CD283A, + 01FA84E3FFF2B54C11CD283A, + 01FA84E4FFF2B54C11CD283A, + 01FA84E5FFF2B54C11CD283A, + 01FA84E6FFF2B54C11CD283A, + 01FA84E7FFF2B54C11CD283A, + 01FA84E8FFF2B54C11CD283A, + 01FA84E9FFF2B54C11CD283A, + 01FA84EAFFF2B54C11CD283A, + 01FA84EBFFF2B54C11CD283A, + 01FA84EDFFF2B54C11CD283A, + 01FA84EEFFF2B54C11CD283A, + 01FA84EFFFF2B54C11CD283A, + 01FA84F0FFF2B54C11CD283A, + 01FA84F2FFF2B54C11CD283A, + 01FA84F3FFF2B54C11CD283A, + 025C84BC0027360A11CD296C, + 01FA84F4FFF2B54C11CD283A, + 01FA84F5FFF2B54C11CD283A, + 01FA84F6FFF2B54C11CD283A, + 01FA84F7FFF2B54C11CD283A, + 01FA84F8FFF2B54C11CD283A, + 01FA84F9FFF2B54C11CD283A, + 01FA84FAFFF2B54C11CD283A, + 01FA84FBFFF2B54C11CD283A, + 01FA84FCFFF2B54C11CD283A, + 01FA84FDFFF2B54C11CD283A, + 01FA84FEFFF2B54C11CD283A, + 01FA84FFFFF2B54C11CD283A, + 01FA8517FFF2B54C11CD283A, + 01FA8518FFF2B54C11CD283A, + 01FA851AFFF2B54C11CD283A, + 01FA851BFFF2B54C11CD283A, + 01FA851CFFF2B54C11CD283A, + 01FA851DFFF2B54C11CD283A, + 01FA8520FFF2B54C11CD283A, + 01FA8521FFF2B54C11CD283A, + 01FA8522FFF2B54C11CD283A, + 01FA8523FFF2B54C11CD283A, + 01FA8524FFF2B54C11CD283A, + 01FA8525FFF2B54C11CD283A, + 01FA8526FFF2B54C11CD283A, + 01FA8527FFF2B54C11CD283A, + 01FA8529FFF2B54C11CD283A, + 01FA852AFFF2B54C11CD283A, + 01FA852BFFF2B54C11CD283A, + 01FA852CFFF2B54C11CD283A, + 01FA852DFFF2B54C11CD283A, + 01FA852FFFF2B54C11CD283A, + 01FA8530FFF2B54C11CD283A, + 01FA8531FFF2B54C11CD283A, + 01FA8532FFF2B54C11CD283A, + 01FA8546FFF2B54C11CD283A, + 01FA8548FFF2B54C11CD283A, + 01FA8549FFF2B54C11CD283A, + 01FA8929FFF2BE3511CD283A, + 01FA892AFFF2BE3511CD283A, + 01FA892BFFF2BE3511CD283A, + 01FA892CFFF2BE3511CD283A, + 01FA892DFFF2BE3511CD283A, + 03B76D49FFF2D31811CD283A, + 03B76D4AFFF2D35D11CD283A, + 56EB36FE03F83C7E0DCA289E, + 03B76D4BFFF2D35D11CD283A, + 03B76D4CFFF2D35D11CD283A, + 03B76D4DFFF2D35D11CD283A, + 2DFDC7A8FFF3E4ED11CD283A, + 31200C5CFFF3E57C11CD283A, + 338005E1FFF3E69711CD283A, + 0177F2DEFFFAA2D311CD283A, + 0177F2EAFFFAA2D311CD283A, + 0177F2F0FFFAA2D311CD283A, + 0177F2F4FFFAA2D311CD283A, + 0177F2F5FFFAA2D311CD283A, + 0177F2FAFFFAA2D311CD283A, + 0177F2FBFFFAA2D311CD283A, + 0177F2FCFFFAA2D311CD283A, + 0177F2FDFFFAA2D311CD283A, + 0177F354FFFAC61911CD283A, + 0177F30BFFFAA2D311CD283A, + 0177F315FFFAA2D311CD283A, + 0177F319FFFAA2D311CD283A, + 0177F31AFFFAA2D311CD283A, + 0177F31BFFFAA2D311CD283A, + 0177F31DFFFAA2D311CD283A, + 014989C0006AA1D111CD283A, + 014989C1006AA1D111CD283A, + 33BD042300838F447F000001, + 33BD042C00838FB17F000001, + 33BD042D00838FB17F000001, + 33BD042E00838FB17F000001, + 33BD0449008390257F000001, + 33BD044A008390257F000001, + 33BD044B008390257F000001, + 33BD044C008390257F000001, + 33BD044D008390257F000001, + 33BD044E008390257F000001, + 33BD044F008390257F000001, + 33BD0450008390257F000001, + 33BD0451008390257F000001, + 33BD0452008390257F000001, + 33BD0460008390B17F000001, + 33BD0464008391C07F000001, + F559B18D01D1510B01CA2E64, + 017B6CA8009748107F000001, + 2F4DD9A700A0A0767F000001, + 3290387000D6C5FE05CD296C, + 327DDDE300D6F8A605CD296C, + 327DDDE400D6F8A605CD296C, + 327DDDF800D7DB7505CD296C, + 32604C2800E3C14505CD296C, + 3272260B00E3C75605CD296C, + 3267644900EBF3AA05CD296C, + F58785CA00FB966001CD29D4, + 9D8B6A2B015A48F500A17CD1, + 9D51868D018F27B500003D05, + 9D51868E018F27B500003D05, + 9D51868F018F27B500003D05, + 9D1DEC1A0198777400003D05, + 9D69C0270198A8E100003D05, + 9D69C02B019AF15E00003D05, + 9D64BAEC019AFD7900003D05, + 326618CE01C6844D05CA2E77, + 9D8F0D2001C80C0C00003D05, + 32554D7B01F4C97305CA2E77, + 9D78BC7301EBB3F900003D05, + 9D78BC7701EBBBED00003D05, + F54323C7022DC98301CA2E64, + F5786217022F1DA301CA2E64, + F54323C9022DC98301CA2E64, + F57861CC022F0F3801CA2E64, + F5786172022EDDE501CA2E64, + F5786180022EDE6401CA2E64, + 8F7ACD2C02357F2503CA2E8C, + F578617A022EDE2B01CA2E64, + 9D2F711403156A7800003D05, + F57861F8022F12FC01CA2E64, + F57861C0022EEF1B01CA2E64, + F578617C022EDE3F01CA2E64, + 4C2ACAB8044267EE00CA2E66, + F57861C4022EEF3401CA2E64, + F57861CA022F0D0A01CA2E64, + BD6FEB7303A5642B03CA2E64, + F5786174022EDDFB01CA2E64, + F5786176022EDE0501CA2E64, + F5786178022EDE1701CA2E64, + F578617E022EDE5C01CA2E64, + F57861C2022EEF2601CA2E64, + F57861C8022EFAE501CA2E64, + F57861C6022EEF4701CA2E64, + 5BA4A43101F4E3F604CA2E82, + F5786226022F32E001CA2E64, + F578622E022F37EB01CA2E64, + F5786233022F39A101CA2E64, + F578623A022F48C601CA2E64, + F578623D023024CC01CA2E64, + F55B3B480230375401CA2E64, + F55B3B4C02303B2A01CA2E64, + F55B3B500230448601CA2E64, + F55B3B7B02304A6001CA2E64, + 32867BAA0231611A05CA2E77, + 32867BAE02316C3905CA2E77, + 32867BB502316E3305CA2E77, + 320F60A00234113505CA2E77, + 8F7ACD320235805903CA2E8C, + 3244148A0236DD1505CA2E77, + 3244148F023837A505CA2E77, + F5A7F71D023D972201CA2E64, + 563FC2B203F845EC0DCA289E, + 563FC2B303F845EC0DCA289E, + F5394A1C0279082901CA2E64, + 3206D1FE029996FC05CA2E77, + 9DD4620103119BCE00003D05, + 9D347A7F038031F000003D05, + 9D347A80038031F100003D05, + 9D347A81038031F200003D05, + 9D347A82038031F300003D05, + 9D347A83038031F400003D05, + 9D347A84038031F500003D05, + 9D347A85038031F600003D05, + 9D347A86038031F700003D05, + 05293B8A043916C100003D05, + C2908499042BC01100CA2E77, + C284B43F042F847900CA2E77, + C2A6D4E1042FC54000CA2E77, + C2B484990450D42900CA2E77, + C213880F0455C01F00CA2E77, + C2952B0D044B55BB00CA2E77, + C2227D96044F404900CA2E77, + 408F00D6045E0650009D840B, + 4EE175A50459EC6F0036F88D, + C2AE352C0469781800CA2E77, + C244C1360479624A00CA2E77, + 52807AD504A3D56C00F46CAB, + 4046155904EE76E70001454E, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 07A0F6C5005DAEE111CD283A = { - isa = PBXFileReference; - path = Session_CRL.cpp; - refType = 4; + 0867D69EFE84028FC02AAC07 = { + buildActionMask = 2147483647; + files = ( + 01FA8609FFF2B54C11CD283A, + 9D64BAF0019B173900003D05, + 9D64BAF4019B176200003D05, + 9D64BAF5019B176200003D05, + 9D64BAF6019B176200003D05, + 9DAE2E2701A2E63800003D05, + 9DAE2E2801A2E63800003D05, + 9DAE2E2B01A2F93200003D05, + 9DAE2E2C01A2F93200003D05, + 9D09B90801B4314500003D05, + 9DAE2E2F01A3378A00003D05, + 9DAE2E3001A3378A00003D05, + 9DAE2E3601A43D6B00003D05, + 9DAE2E3701A43D6B00003D05, + 9DAE2E3801A43D6B00003D05, + 9DAE2E3901A43D6B00003D05, + 9DA13D0501B4638200003D05, + 52807AD204A3D4B800F46CAB, + 5274775904CDF08D00F0AE7D, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 07A0F6C6005DAEE111CD283A = { - isa = PBXFileReference; - path = Session_Crypto.cpp; - refType = 4; + 0867D69FFE84028FC02AAC07 = { + buildActionMask = 2147483647; + files = ( + 01FA86DAFFF2B54C11CD283A, + 01FA86DBFFF2B54C11CD283A, + 01FA86DCFFF2B54C11CD283A, + 01FA86DDFFF2B54C11CD283A, + 01FA86DEFFF2B54C11CD283A, + 01FA86DFFFF2B54C11CD283A, + 01FA86E0FFF2B54C11CD283A, + 01FA86E1FFF2B54C11CD283A, + 01FA86E2FFF2B54C11CD283A, + 01FA86E3FFF2B54C11CD283A, + 01FA86E4FFF2B54C11CD283A, + 01FA86E5FFF2B54C11CD283A, + 01FA86E6FFF2B54C11CD283A, + 01FA86E7FFF2B54C11CD283A, + 01FA86E9FFF2B54C11CD283A, + 01FA86EAFFF2B54C11CD283A, + 01FA86EBFFF2B54C11CD283A, + 01FA86ECFFF2B54C11CD283A, + 01FA86EDFFF2B54C11CD283A, + 01FA86EFFFF2B54C11CD283A, + 01FA86F0FFF2B54C11CD283A, + 01FA86F1FFF2B54C11CD283A, + 01FA86F3FFF2B54C11CD283A, + 01FA86F4FFF2B54C11CD283A, + 01FA86F5FFF2B54C11CD283A, + 01FA86F6FFF2B54C11CD283A, + 01FA86F7FFF2B54C11CD283A, + 01FA86F8FFF2B54C11CD283A, + 01FA86F9FFF2B54C11CD283A, + 01FA86FAFFF2B54C11CD283A, + 01FA86FCFFF2B54C11CD283A, + 01FA86FDFFF2B54C11CD283A, + 01FA86FEFFF2B54C11CD283A, + 01FA86FFFFF2B54C11CD283A, + 01FA8700FFF2B54C11CD283A, + 01FA8701FFF2B54C11CD283A, + 01FA8702FFF2B54C11CD283A, + 01FA8703FFF2B54C11CD283A, + 01FA8704FFF2B54C11CD283A, + 01FA8705FFF2B54C11CD283A, + 01FA8706FFF2B54C11CD283A, + 01FA8707FFF2B54C11CD283A, + 01FA8708FFF2B54C11CD283A, + 01FA8709FFF2B54C11CD283A, + 01FA870AFFF2B54C11CD283A, + 01FA870BFFF2B54C11CD283A, + 01FA870CFFF2B54C11CD283A, + 01FA870DFFF2B54C11CD283A, + 01FA870EFFF2B54C11CD283A, + 01FA870FFFF2B54C11CD283A, + 01FA8710FFF2B54C11CD283A, + 01FA8711FFF2B54C11CD283A, + 01FA8712FFF2B54C11CD283A, + 01FA8713FFF2B54C11CD283A, + 01FA8714FFF2B54C11CD283A, + 01FA8715FFF2B54C11CD283A, + 01FA8716FFF2B54C11CD283A, + 01FA8717FFF2B54C11CD283A, + 01FA8718FFF2B54C11CD283A, + 01FA871BFFF2B54C11CD283A, + 01FA871CFFF2B54C11CD283A, + 01FA871EFFF2B54C11CD283A, + 01FA871FFFF2B54C11CD283A, + 01FA8720FFF2B54C11CD283A, + 01FA8721FFF2B54C11CD283A, + 01FA8722FFF2B54C11CD283A, + 01FA8724FFF2B54C11CD283A, + 01FA8725FFF2B54C11CD283A, + 01FA8726FFF2B54C11CD283A, + 01FA8727FFF2B54C11CD283A, + 01FA8728FFF2B54C11CD283A, + 01FA8729FFF2B54C11CD283A, + 01FA872AFFF2B54C11CD283A, + 01FA872BFFF2B54C11CD283A, + 01FA872CFFF2B54C11CD283A, + 01FA872DFFF2B54C11CD283A, + 01FA872EFFF2B54C11CD283A, + 01FA872FFFF2B54C11CD283A, + 01FA8730FFF2B54C11CD283A, + 01FA874FFFF2B54C11CD283A, + 01FA8751FFF2B54C11CD283A, + 01FA8752FFF2B54C11CD283A, + 01FA8754FFF2B54C11CD283A, + 01FA8755FFF2B54C11CD283A, + 01FA8756FFF2B54C11CD283A, + 01FA8757FFF2B54C11CD283A, + 01FA8758FFF2B54C11CD283A, + 01FA875AFFF2B54C11CD283A, + 01FA875CFFF2B54C11CD283A, + 01FA875DFFF2B54C11CD283A, + 01FA8760FFF2B54C11CD283A, + 01FA8761FFF2B54C11CD283A, + 01FA8762FFF2B54C11CD283A, + 01FA8763FFF2B54C11CD283A, + 01FA8764FFF2B54C11CD283A, + 01FA8765FFF2B54C11CD283A, + 01FA8766FFF2B54C11CD283A, + 01FA8767FFF2B54C11CD283A, + 01FA8769FFF2B54C11CD283A, + 01FA876AFFF2B54C11CD283A, + 01FA876BFFF2B54C11CD283A, + 01FA876CFFF2B54C11CD283A, + 01FA876DFFF2B54C11CD283A, + 01FA876EFFF2B54C11CD283A, + 01FA876FFFF2B54C11CD283A, + 01FA8783FFF2B54C11CD283A, + 01FA8786FFF2B54C11CD283A, + 01FA8787FFF2B54C11CD283A, + 01FA8930FFF2BE3511CD283A, + 01FA8931FFF2BE3511CD283A, + 01FA8932FFF2BE3511CD283A, + 01FA8933FFF2BE3511CD283A, + 01FA8936FFF2BE3511CD283A, + 03B76D4EFFF2D35D11CD283A, + 03B76D4FFFF2D35D11CD283A, + 563FC2B003F8456F0DCA289E, + 563FC2B103F8456F0DCA289E, + 03B76D51FFF2D43011CD283A, + 0177F323FFFAA2D311CD283A, + 0177F32CFFFAA2D311CD283A, + 0177F332FFFAA2D311CD283A, + 0177F334FFFAA2D311CD283A, + 0177F335FFFAA2D311CD283A, + 0177F33AFFFAA2D311CD283A, + 0177F33BFFFAA2D311CD283A, + 0177F33CFFFAA2D311CD283A, + 0177F355FFFAC61911CD283A, + 0177F344FFFAA2D311CD283A, + 0177F349FFFAA2D311CD283A, + 0177F34BFFFAA2D311CD283A, + 0177F34EFFFAA2D311CD283A, + 0177F350FFFAA2D311CD283A, + 33BD042400838F447F000001, + 33BD042F00838FB17F000001, + 33BD043000838FB17F000001, + 33BD043100838FB17F000001, + 33BD0454008390257F000001, + 33BD0455008390257F000001, + 33BD0456008390257F000001, + 33BD0457008390257F000001, + 33BD0458008390257F000001, + 33BD0459008390257F000001, + 33BD045A008390257F000001, + 33BD045B008390257F000001, + 33BD045C008390257F000001, + 33BD045D008390257F000001, + 33BD0461008390B17F000001, + 33BD0465008391C07F000001, + 017B6CA9009748107F000001, + 2F4DD9A800A0A0767F000001, + 3290387100D6C5FE05CD296C, + 327DDDE500D6F8A605CD296C, + 327DDDE600D6F8A605CD296C, + 327DDDF900D7DB7605CD296C, + 32604C2900E3C14505CD296C, + 3272260C00E3C75705CD296C, + F58785CB00FB966001CD29D4, + 9D518690018F27B500003D05, + 9D518692018F27B500003D05, + 9D518693018F27B500003D05, + 9D518694018F27B500003D05, + 9D1DEC1C0198796200003D05, + 9D69C0290198AB3700003D05, + 9D64BAEA019AF3B800003D05, + 9D64BAEE019AFE3700003D05, + 326618CF01C6844D05CA2E77, + 9D78BC7501EBB71A00003D05, + 9D78BC7901EBCA2400003D05, + 9D78BC7B01ECA79D00003D05, + 5BA4A43301F4E3F604CA2E82, + F54323C6022DC98301CA2E64, + F54323C8022DC98301CA2E64, + F57861FB022F1A9301CA2E64, + F57861FD022F1AA001CA2E64, + F57861FF022F1AAB01CA2E64, + F5786201022F1B4001CA2E64, + F5786203022F1B5001CA2E64, + F5786205022F1B5901CA2E64, + F5786207022F1B6501CA2E64, + F5786209022F1B6F01CA2E64, + F578620B022F1B7901CA2E64, + F578620D022F1B8701CA2E64, + F578620F022F1B9301CA2E64, + F5786211022F1B9C01CA2E64, + F5786213022F1BA801CA2E64, + F5786215022F1BB601CA2E64, + F5786227022F32E001CA2E64, + F578622F022F37EB01CA2E64, + F5786232022F39A101CA2E64, + F5786239022F48C601CA2E64, + F578623E023024CC01CA2E64, + F55B3B490230375401CA2E64, + F55B3B4D02303B2A01CA2E64, + F55B3B510230448601CA2E64, + F55B3B7C02304A6001CA2E64, + 32867BA90231611A05CA2E77, + 32867BAD02316C3905CA2E77, + 32867BB402316E3305CA2E77, + 320F609F0234113505CA2E77, + 8F7ACD2D02357F2503CA2E8C, + 8F7ACD330235805903CA2E8C, + 324414890236DD1505CA2E77, + 3244148E023837A505CA2E77, + 32623CFD024BBA3B05CA2E77, + 3206D1FD029996FC05CA2E77, + C2908498042BC01100CA2E77, + C284B441042F856A00CA2E77, + C2227D97044F404900CA2E77, + C2AE352B0469781800CA2E77, + 52807AD304A3D4B800F46CAB, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 07A0F6C7005DAEE111CD283A = { - isa = PBXFileReference; - path = SnaccUtils.cpp; - refType = 4; + 0867D6A0FE84028FC02AAC07 = { + buildActionMask = 2147483647; + files = ( + 125E85AEFFF3D44A11CD283A, + 325EAA2A00D6B24005CD296C, + 325EAA2B00D6B24005CD296C, + 325EAA2C00D6B24005CD296C, + 325EAA2D00D6B24005CD296C, + 325EAA2E00D6B24005CD296C, + 327DDDFB00D7E81F05CD296C, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 07A0F6C8005DAEE111CD283A = { - isa = PBXFileReference; - path = SnaccUtils.h; - refType = 4; + 0867D6A2FE84028FC02AAC07 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 07A0F6C9005DAEE111CD283A = { +//080 +//081 +//082 +//083 +//084 +//0A0 +//0A1 +//0A2 +//0A3 +//0A4 + 0AD5441E0003C2C511CD296C = { + fileEncoding = 30; isa = PBXFileReference; - path = TODO; + path = SecurityServer.order; refType = 4; }; - 07A0F6CA005DAEE111CD283A = { +//0A0 +//0A1 +//0A2 +//0A3 +//0A4 +//0F0 +//0F1 +//0F2 +//0F3 +//0F4 + 0F404EB6008616EE7F000001 = { children = ( - 07A0F6CB005DAEE111CD283A, - 07A0F6CC005DAEE111CD283A, - 07A0F6CF005DAEE111CD283A, - 07A0F6D0005DAEE111CD283A, - 07A0F6D1005DAEE111CD283A, - 07A0F6D2005DAEE111CD283A, - 07A0F6D5005DAEE111CD283A, - 07A0F6D6005DAEE111CD283A, - 07A0F6D8005DAEE111CD283A, - 07A0F6DB005DAEE111CD283A, - 07A0F6DC005DAEE111CD283A, - 9D4B1BC70156C2E500A17CD1, - 07A0F6DD005DAEE111CD283A, - 07A0F6DE005DAEE111CD283A, - 07A0F6DF005DAEE111CD283A, - 07A0F6E0005DAEE111CD283A, - 3290383700D6BB3705CD296C, - 9DAE2E2901A2F93200003D05, - 9DAE2E2A01A2F93200003D05, - 9D09B90701B4314500003D05, - 9D14AC52020093D100003D05, - 9D9AEFBA02B6BC6C00003D05, + 0F404EB9008618137F000001, + 0F404EBA008618137F000001, + 0F404EBB008618137F000001, + 0F404EBC008618137F000001, + 0F404EBF008618137F000001, + 0F404EC0008618137F000001, + 0F404EC1008618137F000001, + 0F404EC2008618137F000001, + 0F404EC3008618137F000001, + 0F404EC4008618137F000001, + 3264486400D54DD305CD296C, + 3264486500D54DD305CD296C, + 0F404EC5008618137F000001, + 0F404EC7008618137F000001, + 0F404ECA008618137F000001, + 0F404ECB008618137F000001, + 4D37AD3A00AA03857F000001, + 4D37AD3900AA03857F000001, + 4D37AD3C00AA03857F000001, + 4D37AD3B00AA03857F000001, + 4D37AD3E00AA03857F000001, + 4D37AD3D00AA03857F000001, + 4D37AD3F00AA03857F000001, + 4D37AD4100AA03857F000001, + 4D37AD4000AA03857F000001, + 0F404ECC008618137F000001, + 0F404ED5008618137F000001, ); isa = PBXGroup; - path = AppleX509TP; - refType = 4; - }; - 07A0F6CB005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleTP.cpp; - refType = 4; - }; - 07A0F6CC005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleTP.h; - refType = 4; - }; - 07A0F6CF005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleTPSession.cpp; - refType = 4; - }; - 07A0F6D0005DAEE111CD283A = { - isa = PBXFileReference; - path = AppleTPSession.h; - refType = 4; - }; - 07A0F6D1005DAEE111CD283A = { - isa = PBXFileReference; - path = certGroupUtils.cpp; - refType = 4; - }; - 07A0F6D2005DAEE111CD283A = { - isa = PBXFileReference; - path = certGroupUtils.h; - refType = 4; - }; - 07A0F6D5005DAEE111CD283A = { - isa = PBXFileReference; - path = tpdebugging.c; - refType = 4; - }; - 07A0F6D6005DAEE111CD283A = { - isa = PBXFileReference; - path = tpdebugging.h; - refType = 4; - }; - 07A0F6D8005DAEE111CD283A = { - isa = PBXFileReference; - path = rootCerts.h; + path = Network; refType = 4; }; - 07A0F6DB005DAEE111CD283A = { + 0F404EB9008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = TPCertInfo.cpp; + path = protocol.h; refType = 4; }; - 07A0F6DC005DAEE111CD283A = { + 0F404EBA008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = TPCertInfo.h; + path = protocol.cpp; refType = 4; }; - 07A0F6DD005DAEE111CD283A = { + 0F404EBB008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = tpPolicies.cpp; + path = transfer.h; refType = 4; }; - 07A0F6DE005DAEE111CD283A = { + 0F404EBC008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = tpPolicies.h; + path = transfer.cpp; refType = 4; }; - 07A0F6DF005DAEE111CD283A = { + 0F404EBF008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = tpTime.c; + path = connectionpool.h; refType = 4; }; - 07A0F6E0005DAEE111CD283A = { + 0F404EC0008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = tpTime.h; - refType = 4; - }; - 07E4D6D300A0CA617F000001 = { - children = ( - 07E4D6D400A0CA617F000001, - 07E4D6D500A0CA617F000001, - 07E4D6D600A0CA617F000001, - 07E4D6D700A0CA617F000001, - 07E4D6D800A0CA617F000001, - 07E4D6D900A0CA617F000001, - 07E4D6DA00A0CA617F000001, - 07E4D6DB00A0CA617F000001, - ); - isa = PBXGroup; - name = dsa; + path = connectionpool.cpp; refType = 4; }; - 07E4D6D400A0CA617F000001 = { + 0F404EC1008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa_asn1.c; - path = dsa/dsa_asn1.c; + path = target.h; refType = 4; }; - 07E4D6D500A0CA617F000001 = { + 0F404EC2008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa_err.c; - path = dsa/dsa_err.c; + path = target.cpp; refType = 4; }; - 07E4D6D600A0CA617F000001 = { + 0F404EC3008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa_gen.c; - path = dsa/dsa_gen.c; + path = observer.h; refType = 4; }; - 07E4D6D700A0CA617F000001 = { + 0F404EC4008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa_key.c; - path = dsa/dsa_key.c; + path = observer.cpp; refType = 4; }; - 07E4D6D800A0CA617F000001 = { + 0F404EC5008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa_lib.c; - path = dsa/dsa_lib.c; + path = parameters.h; refType = 4; }; - 07E4D6D900A0CA617F000001 = { + 0F404EC7008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa_ossl.c; - path = dsa/dsa_ossl.c; + path = parameters.cpp; refType = 4; }; - 07E4D6DA00A0CA617F000001 = { + 0F404ECA008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa_sign.c; - path = dsa/dsa_sign.c; + path = xfercore.h; refType = 4; }; - 07E4D6DB00A0CA617F000001 = { + 0F404ECB008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa_vrf.c; - path = dsa/dsa_vrf.c; + path = xfercore.cpp; refType = 4; }; - 07E4D6DC00A0CA617F000001 = { - fileRef = 07E4D6D400A0CA617F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 07E4D6DD00A0CA617F000001 = { - fileRef = 07E4D6D500A0CA617F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 07E4D6DE00A0CA617F000001 = { - fileRef = 07E4D6D600A0CA617F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 07E4D6DF00A0CA617F000001 = { - fileRef = 07E4D6D700A0CA617F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 07E4D6E000A0CA617F000001 = { - fileRef = 07E4D6D800A0CA617F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 07E4D6E100A0CA617F000001 = { - fileRef = 07E4D6D900A0CA617F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 07E4D6E200A0CA617F000001 = { - fileRef = 07E4D6DA00A0CA617F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 07E4D6E300A0CA617F000001 = { - fileRef = 07E4D6DB00A0CA617F000001; - isa = PBXBuildFile; - settings = { - }; + 0F404ECC008618137F000001 = { + children = ( + 0F404ECD008618137F000001, + 0F404ECE008618137F000001, + 0F404ECF008618137F000001, + 0F404ED0008618137F000001, + 0F404ED1008618137F000001, + 0F404ED2008618137F000001, + 0F404ED3008618137F000001, + 0F404ED4008618137F000001, + 21781539008B941B7F000001, + 2178153A008B941B7F000001, + 01827D09008CB8707F000001, + 01827D0A008CB8707F000001, + 017A54F20094AAE57F000001, + 017A54F30094AAE57F000001, + ); + isa = PBXGroup; + name = Protocols; + refType = 4; }; - 07E4D6E400A0CD8D7F000001 = { + 0F404ECD008618137F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = sha.h; - path = openssl/sha.h; + path = "file-protocol.h"; refType = 4; }; - 07E4D6E500A0CD8D7F000001 = { - fileRef = 07E4D6E400A0CD8D7F000001; - isa = PBXBuildFile; - settings = { - }; + 0F404ECE008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "file-protocol.cpp"; + refType = 4; }; -//070 -//071 -//072 -//073 -//074 -//080 -//081 -//082 -//083 -//084 - 0867D690FE84028FC02AAC07 = { - buildStyles = ( - 01CE6B1AFFF2B1BA11CD283A, - 01CE6B19FFF2B1BA11CD283A, - 320C8FE900EA6AD705CD296C, - ); - isa = PBXProject; - mainGroup = 0867D691FE84028FC02AAC07; - productRefGroup = 034768DDFF38A45A11DB9C8B; - projectDirPath = ""; - targets = ( - 01CE6B1BFFF2B31311CD283A, - 01CE6B1DFFF2B33A11CD283A, - 01FA88F0FFF2B96911CD283A, - 0867D69CFE84028FC02AAC07, - 030701E4FFF96F8511CD283A, - 125E85D5FFF3D67D11CD283A, - 01FA88FCFFF2BC5611CD283A, - 01FA8904FFF2BCA811CD283A, - 01FA88F9FFF2BBEB11CD283A, - 3290385000D6BB7805CD296C, - 014880CD005EAE4D11CD283A, - 014880D4005EAE4D11CD283A, - 014880DA005EAE4D11CD283A, - 014880E0005EAE4D11CD283A, - 014880E6005EAE4D11CD283A, - 3290383800D6BB3705CD296C, - 325EAA2200D6B08805CD296C, - 3290382200D6BA5905CD296C, - 3290381900D6BA5905CD296C, - 3290382800D6BA5905CD296C, - 3290382E00D6BA5905CD296C, - 9DC1DEF30299BBCD00003D05, - 322C5F3B02B9641F05CA2E77, - ); + 0F404ECF008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "ftp-protocol.h"; + refType = 4; }; - 0867D691FE84028FC02AAC07 = { - children = ( - 01FA7FE6FFF2B54C11CD283A, - 0177F263FFFAA2D311CD283A, - 0F404EB6008616EE7F000001, - 01FA819DFFF2B54C11CD283A, - 01FA8126FFF2B54C11CD283A, - 01FA8168FFF2B54C11CD283A, - 01FA823FFFF2B54C11CD283A, - 07A0F5EA005DAEE111CD283A, - 07A0F686005DAEE111CD283A, - 07A0F6A0005DAEE111CD283A, - 07A0F6AB005DAEE111CD283A, - 07A0F6CA005DAEE111CD283A, - F5A5E50E00FB884E01CD29D4, - 9DC1DEEC0299BB8F00003D05, - 3283A53702B96AF805CA2E77, - 01FA890DFFF2BD9911CD283A, - 01FA890EFFF2BD9911CD283A, - 030701E1FFF95F6F11CD283A, - 0867D69AFE84028FC02AAC07, - 034768DDFF38A45A11DB9C8B, - ); - isa = PBXGroup; - name = Security; + 0F404ED0008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "ftp-protocol.cpp"; refType = 4; }; - 0867D69AFE84028FC02AAC07 = { - children = ( - 325EAA2900D6B23F05CD296C, - 125E85ADFFF3D44A11CD283A, - 327DDDFA00D7E81F05CD296C, - ); - isa = PBXGroup; - name = "External Frameworks and Libraries"; + 0F404ED1008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "http-protocol.h"; refType = 4; }; - 0867D69CFE84028FC02AAC07 = { - buildPhases = ( - 0867D69DFE84028FC02AAC07, - 0867D69EFE84028FC02AAC07, - 0867D69FFE84028FC02AAC07, - 0867D6A0FE84028FC02AAC07, - 0867D6A2FE84028FC02AAC07, - F5DDE3AE00B3358F01CD283A, - ); - buildSettings = { - CURRENT_PROJECT_VERSION = 54.1.9; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 54.1.9; - FRAMEWORK_SEARCH_PATHS = ""; - FRAMEWORK_VERSION = A; - HEADER_SEARCH_PATHS = "\"$(SRCROOT)\" \"$(BUILT_PRODUCTS_DIR)/derived_src\""; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; - LIBRARY_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)\""; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_CFLAGS = "-DLIMITED_SIGNING -DBUILTIN_PLUGINS -DVDADER_RULES -DCRYPTKIT_CSP_ENABLE -DASC_CSP_ENABLE"; - OTHER_LDFLAGS = "-lComCryption -lCryptKit -twolevel_namespace"; - PREBINDING = YES; - PRODUCT_NAME = Security; - SECTORDER_FLAGS = "-sectorder __TEXT __text \"$(APPLE_INTERNAL_DIR)/OrderFiles/Security.order\" -seg_addr_table \"$(APPLE_INTERNAL_DEVELOPER_DIR)/seg_addr_table\""; - VERSION_INFO_PREFIX = Sec; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - WRAPPER_EXTENSION = framework; - }; - dependencies = ( - 3290384F00D6BB7805CD296C, - 05855484FFF2DA1E11CD283A, - ); - isa = PBXFrameworkTarget; - name = Security; - productInstallPath = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; - productName = Security; - productReference = F54323B4022DC91501CA2E64; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - Security - CFBundleGetInfoString - - CFBundleIconFile - - CFBundleIdentifier - com.apple.security - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Security - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.1.6 - CFBundleSignature - ???? - CFBundleVersion - 54.1.9 - - -"; - shouldUseHeadermap = 1; + 0F404ED2008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "http-protocol.cpp"; + refType = 4; }; - 0867D69DFE84028FC02AAC07 = { - buildActionMask = 2147483647; - files = ( - 01FA848EFFF2B54C11CD283A, - 01FA848FFFF2B54C11CD283A, - 01FA8490FFF2B54C11CD283A, - 01FA8491FFF2B54C11CD283A, - 01FA8492FFF2B54C11CD283A, - 01FA8493FFF2B54C11CD283A, - 01FA8494FFF2B54C11CD283A, - 01FA8495FFF2B54C11CD283A, - 01FA8496FFF2B54C11CD283A, - 01FA8497FFF2B54C11CD283A, - 01FA8498FFF2B54C11CD283A, - 01FA8499FFF2B54C11CD283A, - 01FA849AFFF2B54C11CD283A, - 01FA849BFFF2B54C11CD283A, - 01FA849CFFF2B54C11CD283A, - 01FA849DFFF2B54C11CD283A, - 01FA849EFFF2B54C11CD283A, - 01FA849FFFF2B54C11CD283A, - 01FA84A0FFF2B54C11CD283A, - 01FA84A1FFF2B54C11CD283A, - 01FA84A2FFF2B54C11CD283A, - 01FA84A3FFF2B54C11CD283A, - 01FA84A4FFF2B54C11CD283A, - 01FA84A5FFF2B54C11CD283A, - 01FA84A6FFF2B54C11CD283A, - 01FA84A7FFF2B54C11CD283A, - 01FA84A8FFF2B54C11CD283A, - 01FA84A9FFF2B54C11CD283A, - 01FA84AAFFF2B54C11CD283A, - 01FA84ABFFF2B54C11CD283A, - 01FA84ACFFF2B54C11CD283A, - 01FA84ADFFF2B54C11CD283A, - 01FA84AEFFF2B54C11CD283A, - 01FA84AFFFF2B54C11CD283A, - 01FA84B0FFF2B54C11CD283A, - 01FA84B1FFF2B54C11CD283A, - 01FA84B2FFF2B54C11CD283A, - 01FA84B3FFF2B54C11CD283A, - 01FA84B4FFF2B54C11CD283A, - 01FA84B5FFF2B54C11CD283A, - 01FA84B6FFF2B54C11CD283A, - 01FA84B7FFF2B54C11CD283A, - 01FA84B8FFF2B54C11CD283A, - 01FA84B9FFF2B54C11CD283A, - 01FA84BAFFF2B54C11CD283A, - 01FA84BBFFF2B54C11CD283A, - 01FA84BCFFF2B54C11CD283A, - 01FA84BDFFF2B54C11CD283A, - 01FA84BEFFF2B54C11CD283A, - 01FA84BFFFF2B54C11CD283A, - 01FA84C0FFF2B54C11CD283A, - 01FA84C1FFF2B54C11CD283A, - 01FA84C2FFF2B54C11CD283A, - 01FA84C3FFF2B54C11CD283A, - 01FA84C5FFF2B54C11CD283A, - 01FA84C6FFF2B54C11CD283A, - 01FA84C7FFF2B54C11CD283A, - 01FA84C8FFF2B54C11CD283A, - 01FA84C9FFF2B54C11CD283A, - 01FA84CAFFF2B54C11CD283A, - 01FA84CBFFF2B54C11CD283A, - 01FA84CCFFF2B54C11CD283A, - 01FA84CEFFF2B54C11CD283A, - 01FA84CFFFF2B54C11CD283A, - 01FA84D0FFF2B54C11CD283A, - 01FA84D1FFF2B54C11CD283A, - 01FA84D2FFF2B54C11CD283A, - 01FA84D3FFF2B54C11CD283A, - 01FA84D4FFF2B54C11CD283A, - 01FA84D5FFF2B54C11CD283A, - 01FA84D6FFF2B54C11CD283A, - 01FA84D7FFF2B54C11CD283A, - 01FA84D8FFF2B54C11CD283A, - 01FA84D9FFF2B54C11CD283A, - 01FA84DAFFF2B54C11CD283A, - 01FA84DBFFF2B54C11CD283A, - 01FA84DCFFF2B54C11CD283A, - 01FA84DDFFF2B54C11CD283A, - 01FA84DEFFF2B54C11CD283A, - 01FA84DFFFF2B54C11CD283A, - 01FA84E0FFF2B54C11CD283A, - 01FA84E1FFF2B54C11CD283A, - 01FA84E2FFF2B54C11CD283A, - 01FA84E3FFF2B54C11CD283A, - 01FA84E4FFF2B54C11CD283A, - 01FA84E5FFF2B54C11CD283A, - 01FA84E6FFF2B54C11CD283A, - 01FA84E7FFF2B54C11CD283A, - 01FA84E8FFF2B54C11CD283A, - 01FA84E9FFF2B54C11CD283A, - 01FA84EAFFF2B54C11CD283A, - 01FA84EBFFF2B54C11CD283A, - 01FA84EDFFF2B54C11CD283A, - 01FA84EEFFF2B54C11CD283A, - 01FA84EFFFF2B54C11CD283A, - 01FA84F0FFF2B54C11CD283A, - 01FA84F2FFF2B54C11CD283A, - 01FA84F3FFF2B54C11CD283A, - 025C84BC0027360A11CD296C, - 01FA84F4FFF2B54C11CD283A, - 01FA84F5FFF2B54C11CD283A, - 01FA84F6FFF2B54C11CD283A, - 01FA84F7FFF2B54C11CD283A, - 01FA84F8FFF2B54C11CD283A, - 01FA84F9FFF2B54C11CD283A, - 01FA84FAFFF2B54C11CD283A, - 01FA84FBFFF2B54C11CD283A, - 01FA84FCFFF2B54C11CD283A, - 01FA84FDFFF2B54C11CD283A, - 01FA84FEFFF2B54C11CD283A, - 01FA84FFFFF2B54C11CD283A, - 01FA8517FFF2B54C11CD283A, - 01FA8518FFF2B54C11CD283A, - 01FA851AFFF2B54C11CD283A, - 01FA851BFFF2B54C11CD283A, - 01FA851CFFF2B54C11CD283A, - 01FA8520FFF2B54C11CD283A, - 01FA8521FFF2B54C11CD283A, - 01FA8524FFF2B54C11CD283A, - 01FA8525FFF2B54C11CD283A, - 01FA8527FFF2B54C11CD283A, - 01FA852AFFF2B54C11CD283A, - 01FA852BFFF2B54C11CD283A, - 01FA8530FFF2B54C11CD283A, - 01FA8531FFF2B54C11CD283A, - 01FA8532FFF2B54C11CD283A, - 01FA8533FFF2B54C11CD283A, - 01FA8534FFF2B54C11CD283A, - 01FA8535FFF2B54C11CD283A, - 01FA8536FFF2B54C11CD283A, - 01FA8537FFF2B54C11CD283A, - 01FA8538FFF2B54C11CD283A, - 01FA8539FFF2B54C11CD283A, - 01FA853AFFF2B54C11CD283A, - 01FA853BFFF2B54C11CD283A, - 01FA853CFFF2B54C11CD283A, - 01FA853DFFF2B54C11CD283A, - 01FA853EFFF2B54C11CD283A, - 01FA853FFFF2B54C11CD283A, - 01FA8540FFF2B54C11CD283A, - 01FA8541FFF2B54C11CD283A, - 4EB202E2005859A47F000001, - 01FA8546FFF2B54C11CD283A, - 01FA8548FFF2B54C11CD283A, - 01FA8549FFF2B54C11CD283A, - 01FA8583FFF2B54C11CD283A, - 01FA8584FFF2B54C11CD283A, - 01FA8585FFF2B54C11CD283A, - 01FA8586FFF2B54C11CD283A, - 01FA8587FFF2B54C11CD283A, - 01FA8588FFF2B54C11CD283A, - 01FA8589FFF2B54C11CD283A, - 01FA858AFFF2B54C11CD283A, - 01FA858BFFF2B54C11CD283A, - 01FA858CFFF2B54C11CD283A, - 01FA858DFFF2B54C11CD283A, - 01FA858EFFF2B54C11CD283A, - 01FA858FFFF2B54C11CD283A, - 01FA8590FFF2B54C11CD283A, - 01FA8591FFF2B54C11CD283A, - 01FA8592FFF2B54C11CD283A, - 01FA8593FFF2B54C11CD283A, - 01FA8594FFF2B54C11CD283A, - 01FA8595FFF2B54C11CD283A, - 01FA8596FFF2B54C11CD283A, - 01FA8597FFF2B54C11CD283A, - 01FA8598FFF2B54C11CD283A, - 01FA8599FFF2B54C11CD283A, - 01FA859AFFF2B54C11CD283A, - 01FA859BFFF2B54C11CD283A, - 01FA859DFFF2B54C11CD283A, - 01FA859EFFF2B54C11CD283A, - 01FA8929FFF2BE3511CD283A, - 01FA892AFFF2BE3511CD283A, - 01FA892BFFF2BE3511CD283A, - 01FA892CFFF2BE3511CD283A, - 01FA892DFFF2BE3511CD283A, - 03B76D49FFF2D31811CD283A, - 03B76D4AFFF2D35D11CD283A, - 03B76D4BFFF2D35D11CD283A, - 03B76D4CFFF2D35D11CD283A, - 03B76D4DFFF2D35D11CD283A, - 2DFDC7A8FFF3E4ED11CD283A, - 31200C5CFFF3E57C11CD283A, - 338005E1FFF3E69711CD283A, - 0177F2DEFFFAA2D311CD283A, - 0177F2EAFFFAA2D311CD283A, - 0177F2EEFFFAA2D311CD283A, - 0177F2F0FFFAA2D311CD283A, - 0177F2F4FFFAA2D311CD283A, - 0177F2F5FFFAA2D311CD283A, - 0177F2FAFFFAA2D311CD283A, - 0177F2FBFFFAA2D311CD283A, - 0177F2FCFFFAA2D311CD283A, - 0177F2FDFFFAA2D311CD283A, - 0177F354FFFAC61911CD283A, - 0177F30BFFFAA2D311CD283A, - 0177F315FFFAA2D311CD283A, - 0177F317FFFAA2D311CD283A, - 0177F319FFFAA2D311CD283A, - 0177F31AFFFAA2D311CD283A, - 0177F31BFFFAA2D311CD283A, - 0177F31DFFFAA2D311CD283A, - 014989C0006AA1D111CD283A, - 014989C1006AA1D111CD283A, - 33BD042300838F447F000001, - 33BD042C00838FB17F000001, - 33BD042D00838FB17F000001, - 33BD042E00838FB17F000001, - 33BD0449008390257F000001, - 33BD044A008390257F000001, - 33BD044B008390257F000001, - 33BD044C008390257F000001, - 33BD044D008390257F000001, - 33BD044E008390257F000001, - 33BD044F008390257F000001, - 33BD0450008390257F000001, - 33BD0451008390257F000001, - 33BD0452008390257F000001, - 33BD0460008390B17F000001, - 33BD0464008391C07F000001, - F559B18D01D1510B01CA2E64, - 017B6CA8009748107F000001, - 2F4DD9A700A0A0767F000001, - 3290387000D6C5FE05CD296C, - 327DDDE300D6F8A605CD296C, - 327DDDE400D6F8A605CD296C, - 327DDDF800D7DB7505CD296C, - 32604C2800E3C14505CD296C, - 3272260B00E3C75605CD296C, - 3267644900EBF3AA05CD296C, - F58785CA00FB966001CD29D4, - 9D8B6A2B015A48F500A17CD1, - 9D51868D018F27B500003D05, - 9D51868E018F27B500003D05, - 9D51868F018F27B500003D05, - 9D1DEC1A0198777400003D05, - 9D69C0270198A8E100003D05, - 9D69C02B019AF15E00003D05, - 9D64BAEC019AFD7900003D05, - 326618CE01C6844D05CA2E77, - 9D8F0D2001C80C0C00003D05, - 32554D7B01F4C97305CA2E77, - 9D78BC7301EBB3F900003D05, - 9D78BC7701EBBBED00003D05, - F54323C7022DC98301CA2E64, - F5786217022F1DA301CA2E64, - F54323C9022DC98301CA2E64, - F57861CC022F0F3801CA2E64, - F5786172022EDDE501CA2E64, - F5786180022EDE6401CA2E64, - F578617A022EDE2B01CA2E64, - F57861F8022F12FC01CA2E64, - F57861C0022EEF1B01CA2E64, - F578617C022EDE3F01CA2E64, - F57861C4022EEF3401CA2E64, - F57861CA022F0D0A01CA2E64, - F5786174022EDDFB01CA2E64, - F5786176022EDE0501CA2E64, - F5786178022EDE1701CA2E64, - F578617E022EDE5C01CA2E64, - F57861C2022EEF2601CA2E64, - F57861C8022EFAE501CA2E64, - F57861C6022EEF4701CA2E64, - 5BA4A43101F4E3F604CA2E82, - F5786226022F32E001CA2E64, - F578622E022F37EB01CA2E64, - F5786233022F39A101CA2E64, - F578623A022F48C601CA2E64, - F578623D023024CC01CA2E64, - F55B3B480230375401CA2E64, - F55B3B4C02303B2A01CA2E64, - F55B3B500230448601CA2E64, - F55B3B7B02304A6001CA2E64, - 32867BAA0231611A05CA2E77, - 32867BAE02316C3905CA2E77, - 32867BB502316E3305CA2E77, - 320F60A00234113505CA2E77, - 8F7ACD2C02357F2503CA2E8C, - 8F7ACD320235805903CA2E8C, - 3244148A0236DD1505CA2E77, - 3244148F023837A505CA2E77, - F5A7F71D023D972201CA2E64, - F5394A1C0279082901CA2E64, - F540EDC8027A43A501CA2E66, - 3206D1FE029996FC05CA2E77, - 9D98FF150371DDE400003D05, - 9D98FF160371DDE400003D05, - 9D98FF170371DDE400003D05, - 9D98FF180371DDE400003D05, - 9D98FF190371DDE400003D05, - 9D98FF1A0371DDE400003D05, - 9D98FF1B0371DDE400003D05, - 9D98FF1C0371DDE400003D05, - 9D98FF1D0371DDE400003D05, - F500ED3C037CD0E101CA2E64, + 0F404ED3008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "https-protocol.h"; + refType = 4; + }; + 0F404ED4008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "https-protocol.cpp"; + refType = 4; + }; + 0F404ED5008618137F000001 = { + children = ( + 0F404ED6008618137F000001, + 0F404ED7008618137F000001, ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + isa = PBXGroup; + name = Managers; + refType = 4; + }; + 0F404ED6008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = simplemanager.h; + refType = 4; + }; + 0F404ED7008618137F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = simplemanager.cpp; + refType = 4; + }; +//0F0 +//0F1 +//0F2 +//0F3 +//0F4 +//120 +//121 +//122 +//123 +//124 + 125E85A8FFF3CDEF11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = xdatabase.cpp; + refType = 4; + }; + 125E85A9FFF3CDEF11CD283A = { + fileEncoding = 30; + isa = PBXFileReference; + path = xdatabase.h; + refType = 4; + }; + 125E85ADFFF3D44A11CD283A = { + isa = PBXFrameworkReference; + name = CoreFoundation.framework; + path = /System/Library/Frameworks/CoreFoundation.framework; + refType = 0; + }; + 125E85AEFFF3D44A11CD283A = { + fileRef = 125E85ADFFF3D44A11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85AFFFF3D51B11CD283A = { + fileRef = 01FA819FFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85B0FFF3D51B11CD283A = { + fileRef = 01FA81A1FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85B1FFF3D51B11CD283A = { + fileRef = 01FA81A3FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85B2FFF3D51B11CD283A = { + fileRef = 01FA81A5FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85B3FFF3D51B11CD283A = { + fileRef = 01FA81AAFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85B4FFF3D51B11CD283A = { + fileRef = 01FA819EFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85B5FFF3D51B11CD283A = { + fileRef = 01FA81A0FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85B6FFF3D51B11CD283A = { + fileRef = 01FA81A2FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85B7FFF3D51B11CD283A = { + fileRef = 01FA81A4FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85B8FFF3D51B11CD283A = { + fileRef = 01FA81A9FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85B9FFF3D54811CD283A = { + fileRef = 01FA81B3FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85BAFFF3D54811CD283A = { + fileRef = 01FA81B5FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85BBFFF3D54811CD283A = { + fileRef = 01FA81B9FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85BCFFF3D54811CD283A = { + fileRef = 01FA81B2FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85BDFFF3D54811CD283A = { + fileRef = 01FA81B4FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85BEFFF3D54811CD283A = { + fileRef = 01FA81B8FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + COMPILER_FLAGS = "-Wno-invalid-offsetof"; + }; + }; + 125E85BFFFF3D5ED11CD283A = { + fileRef = 01FA81BDFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C0FFF3D5ED11CD283A = { + fileRef = 01FA8219FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C1FFF3D5ED11CD283A = { + fileRef = 01FA821BFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C2FFF3D5ED11CD283A = { + fileRef = 01FA821DFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C3FFF3D5ED11CD283A = { + fileRef = 01FA821EFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C4FFF3D5ED11CD283A = { + fileRef = 01FA8221FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C5FFF3D5ED11CD283A = { + fileRef = 01FA8223FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C6FFF3D5ED11CD283A = { + fileRef = 01FA8225FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C7FFF3D5ED11CD283A = { + fileRef = 125E85A9FFF3CDEF11CD283A; + isa = PBXBuildFile; + settings = { + }; + }; + 125E85C8FFF3D5ED11CD283A = { + fileRef = 01FA81BCFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85C9FFF3D5ED11CD283A = { + fileRef = 01FA8214FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85CAFFF3D5ED11CD283A = { + fileRef = 01FA8218FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85CCFFF3D5ED11CD283A = { + fileRef = 01FA8220FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85CDFFF3D5ED11CD283A = { + fileRef = 01FA8222FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; }; - 0867D69EFE84028FC02AAC07 = { - buildActionMask = 2147483647; - files = ( - 01FA8609FFF2B54C11CD283A, - 9D64BAF0019B173900003D05, - 9D64BAF4019B176200003D05, - 9D64BAF5019B176200003D05, - 9D64BAF6019B176200003D05, - 9DAE2E2701A2E63800003D05, - 9DAE2E2801A2E63800003D05, - 9DAE2E2B01A2F93200003D05, - 9DAE2E2C01A2F93200003D05, - 9D09B90801B4314500003D05, - 9DAE2E2F01A3378A00003D05, - 9DAE2E3001A3378A00003D05, - 9DAE2E3601A43D6B00003D05, - 9DAE2E3701A43D6B00003D05, - 9DAE2E3801A43D6B00003D05, - 9DAE2E3901A43D6B00003D05, - 9DA13D0501B4638200003D05, - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 125E85CEFFF3D5ED11CD283A = { + fileRef = 01FA8224FFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; }; - 0867D69FFE84028FC02AAC07 = { - buildActionMask = 2147483647; - files = ( - 01FA86D9FFF2B54C11CD283A, - 01FA86DAFFF2B54C11CD283A, - 01FA86DBFFF2B54C11CD283A, - 01FA86DCFFF2B54C11CD283A, - 01FA86DDFFF2B54C11CD283A, - 01FA86DEFFF2B54C11CD283A, - 01FA86DFFFF2B54C11CD283A, - 01FA86E0FFF2B54C11CD283A, - 01FA86E1FFF2B54C11CD283A, - 01FA86E2FFF2B54C11CD283A, - 01FA86E3FFF2B54C11CD283A, - 01FA86E4FFF2B54C11CD283A, - 01FA86E5FFF2B54C11CD283A, - 01FA86E6FFF2B54C11CD283A, - 01FA86E7FFF2B54C11CD283A, - 01FA86E9FFF2B54C11CD283A, - 01FA86EAFFF2B54C11CD283A, - 01FA86EBFFF2B54C11CD283A, - 01FA86ECFFF2B54C11CD283A, - 01FA86EDFFF2B54C11CD283A, - 01FA86EFFFF2B54C11CD283A, - 01FA86F0FFF2B54C11CD283A, - 01FA86F1FFF2B54C11CD283A, - 01FA86F3FFF2B54C11CD283A, - 01FA86F4FFF2B54C11CD283A, - 01FA86F5FFF2B54C11CD283A, - 01FA86F6FFF2B54C11CD283A, - 01FA86F7FFF2B54C11CD283A, - 01FA86F8FFF2B54C11CD283A, - 01FA86F9FFF2B54C11CD283A, - 01FA86FAFFF2B54C11CD283A, - 01FA86FCFFF2B54C11CD283A, - 01FA86FDFFF2B54C11CD283A, - 01FA86FEFFF2B54C11CD283A, - 01FA86FFFFF2B54C11CD283A, - 01FA8700FFF2B54C11CD283A, - 01FA8701FFF2B54C11CD283A, - 01FA8702FFF2B54C11CD283A, - 01FA8703FFF2B54C11CD283A, - 01FA8704FFF2B54C11CD283A, - 01FA8705FFF2B54C11CD283A, - 01FA8706FFF2B54C11CD283A, - 01FA8707FFF2B54C11CD283A, - 01FA8708FFF2B54C11CD283A, - 01FA8709FFF2B54C11CD283A, - 01FA870AFFF2B54C11CD283A, - 01FA870BFFF2B54C11CD283A, - 01FA870CFFF2B54C11CD283A, - 01FA870DFFF2B54C11CD283A, - 01FA870EFFF2B54C11CD283A, - 01FA870FFFF2B54C11CD283A, - 01FA8710FFF2B54C11CD283A, - 01FA8711FFF2B54C11CD283A, - 01FA8712FFF2B54C11CD283A, - 01FA8713FFF2B54C11CD283A, - 01FA8714FFF2B54C11CD283A, - 01FA8715FFF2B54C11CD283A, - 01FA8716FFF2B54C11CD283A, - 01FA8717FFF2B54C11CD283A, - 01FA8718FFF2B54C11CD283A, - 01FA871BFFF2B54C11CD283A, - 01FA871CFFF2B54C11CD283A, - 01FA871EFFF2B54C11CD283A, - 01FA871FFFF2B54C11CD283A, - 01FA8720FFF2B54C11CD283A, - 01FA8721FFF2B54C11CD283A, - 01FA8722FFF2B54C11CD283A, - 01FA8724FFF2B54C11CD283A, - 01FA8725FFF2B54C11CD283A, - 01FA8726FFF2B54C11CD283A, - 01FA8727FFF2B54C11CD283A, - 01FA8728FFF2B54C11CD283A, - 01FA8729FFF2B54C11CD283A, - 01FA872AFFF2B54C11CD283A, - 01FA872BFFF2B54C11CD283A, - 01FA872CFFF2B54C11CD283A, - 01FA872DFFF2B54C11CD283A, - 01FA872EFFF2B54C11CD283A, - 01FA872FFFF2B54C11CD283A, - 01FA8730FFF2B54C11CD283A, - 01FA874FFFF2B54C11CD283A, - 01FA8751FFF2B54C11CD283A, - 01FA8752FFF2B54C11CD283A, - 01FA8754FFF2B54C11CD283A, - 01FA8755FFF2B54C11CD283A, - 01FA8756FFF2B54C11CD283A, - 01FA8757FFF2B54C11CD283A, - 01FA8758FFF2B54C11CD283A, - 01FA8759FFF2B54C11CD283A, - 01FA875CFFF2B54C11CD283A, - 01FA875DFFF2B54C11CD283A, - 01FA8760FFF2B54C11CD283A, - 01FA8761FFF2B54C11CD283A, - 01FA8762FFF2B54C11CD283A, - 01FA8763FFF2B54C11CD283A, - 01FA8764FFF2B54C11CD283A, - 01FA8765FFF2B54C11CD283A, - 01FA8766FFF2B54C11CD283A, - 01FA8767FFF2B54C11CD283A, - 01FA8769FFF2B54C11CD283A, - 01FA876AFFF2B54C11CD283A, - 01FA876BFFF2B54C11CD283A, - 01FA876CFFF2B54C11CD283A, - 01FA876DFFF2B54C11CD283A, - 01FA876EFFF2B54C11CD283A, - 01FA876FFFF2B54C11CD283A, - 01FA8770FFF2B54C11CD283A, - 01FA8771FFF2B54C11CD283A, - 01FA8772FFF2B54C11CD283A, - 01FA8773FFF2B54C11CD283A, - 01FA8774FFF2B54C11CD283A, - 01FA8775FFF2B54C11CD283A, - 01FA8776FFF2B54C11CD283A, - 01FA8777FFF2B54C11CD283A, - 01FA8778FFF2B54C11CD283A, - 01FA8779FFF2B54C11CD283A, - 01FA877AFFF2B54C11CD283A, - 01FA877BFFF2B54C11CD283A, - 01FA877CFFF2B54C11CD283A, - 01FA877DFFF2B54C11CD283A, - 01FA877EFFF2B54C11CD283A, - 4EB202E3005859A47F000001, - 01FA8783FFF2B54C11CD283A, - 01FA8786FFF2B54C11CD283A, - 01FA8787FFF2B54C11CD283A, - 01FA87C9FFF2B54C11CD283A, - 01FA87CAFFF2B54C11CD283A, - 01FA87CBFFF2B54C11CD283A, - 01FA87CCFFF2B54C11CD283A, - 01FA87CDFFF2B54C11CD283A, - 01FA87CEFFF2B54C11CD283A, - 01FA87CFFFF2B54C11CD283A, - 01FA87D0FFF2B54C11CD283A, - 01FA87D1FFF2B54C11CD283A, - 01FA87D2FFF2B54C11CD283A, - 01FA87D3FFF2B54C11CD283A, - 01FA87D4FFF2B54C11CD283A, - 01FA87D5FFF2B54C11CD283A, - 01FA87D6FFF2B54C11CD283A, - 01FA87D7FFF2B54C11CD283A, - 01FA87D8FFF2B54C11CD283A, - 01FA87D9FFF2B54C11CD283A, - 01FA87DAFFF2B54C11CD283A, - 01FA87F7FFF2B54C11CD283A, - 01FA87FEFFF2B54C11CD283A, - 01FA87FFFFF2B54C11CD283A, - 01FA8930FFF2BE3511CD283A, - 01FA8931FFF2BE3511CD283A, - 01FA8932FFF2BE3511CD283A, - 01FA8933FFF2BE3511CD283A, - 01FA8936FFF2BE3511CD283A, - 03B76D4EFFF2D35D11CD283A, - 03B76D4FFFF2D35D11CD283A, - 03B76D51FFF2D43011CD283A, - 0177F323FFFAA2D311CD283A, - 0177F32CFFFAA2D311CD283A, - 0177F330FFFAA2D311CD283A, - 0177F332FFFAA2D311CD283A, - 0177F334FFFAA2D311CD283A, - 0177F335FFFAA2D311CD283A, - 0177F33AFFFAA2D311CD283A, - 0177F33BFFFAA2D311CD283A, - 0177F33CFFFAA2D311CD283A, - 0177F355FFFAC61911CD283A, - 0177F344FFFAA2D311CD283A, - 0177F349FFFAA2D311CD283A, - 0177F34BFFFAA2D311CD283A, - 0177F34EFFFAA2D311CD283A, - 0177F350FFFAA2D311CD283A, - 33BD042400838F447F000001, - 33BD042F00838FB17F000001, - 33BD043000838FB17F000001, - 33BD043100838FB17F000001, - 33BD0454008390257F000001, - 33BD0455008390257F000001, - 33BD0456008390257F000001, - 33BD0457008390257F000001, - 33BD0458008390257F000001, - 33BD0459008390257F000001, - 33BD045A008390257F000001, - 33BD045B008390257F000001, - 33BD045C008390257F000001, - 33BD045D008390257F000001, - 33BD0461008390B17F000001, - 33BD0465008391C07F000001, - 017B6CA9009748107F000001, - 2F4DD9A800A0A0767F000001, - 3290387100D6C5FE05CD296C, - 327DDDE500D6F8A605CD296C, - 327DDDE600D6F8A605CD296C, - 327DDDF900D7DB7605CD296C, - 32604C2900E3C14505CD296C, - 3272260C00E3C75705CD296C, - F58785CB00FB966001CD29D4, - 9D518690018F27B500003D05, - 9D518692018F27B500003D05, - 9D518693018F27B500003D05, - 9D518694018F27B500003D05, - 9D1DEC1C0198796200003D05, - 9D69C0290198AB3700003D05, - 9D64BAEA019AF3B800003D05, - 9D64BAEE019AFE3700003D05, - 326618CF01C6844D05CA2E77, - 9D78BC7501EBB71A00003D05, - 9D78BC7901EBCA2400003D05, - 9D78BC7B01ECA79D00003D05, - 5BA4A43301F4E3F604CA2E82, - F54323C6022DC98301CA2E64, - F54323C8022DC98301CA2E64, - F57861FB022F1A9301CA2E64, - F57861FD022F1AA001CA2E64, - F57861FF022F1AAB01CA2E64, - F5786201022F1B4001CA2E64, - F5786203022F1B5001CA2E64, - F5786205022F1B5901CA2E64, - F5786207022F1B6501CA2E64, - F5786209022F1B6F01CA2E64, - F578620B022F1B7901CA2E64, - F578620D022F1B8701CA2E64, - F578620F022F1B9301CA2E64, - F5786211022F1B9C01CA2E64, - F5786213022F1BA801CA2E64, - F5786215022F1BB601CA2E64, - F5786227022F32E001CA2E64, - F578622F022F37EB01CA2E64, - F5786232022F39A101CA2E64, - F5786239022F48C601CA2E64, - F578623E023024CC01CA2E64, - F55B3B490230375401CA2E64, - F55B3B4D02303B2A01CA2E64, - F55B3B510230448601CA2E64, - F55B3B7C02304A6001CA2E64, - 32867BA90231611A05CA2E77, - 32867BAD02316C3905CA2E77, - 32867BB402316E3305CA2E77, - 320F609F0234113505CA2E77, - 8F7ACD2D02357F2503CA2E8C, - 8F7ACD330235805903CA2E8C, - 324414890236DD1505CA2E77, - 3244148E023837A505CA2E77, - 32623CFD024BBA3B05CA2E77, - F540E6FA027A33DA01CA2E66, - 3206D1FD029996FC05CA2E77, + 125E85CFFFF3D5ED11CD283A = { + fileRef = 01FA823AFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85D0FFF3D5ED11CD283A = { + fileRef = 125E85A8FFF3CDEF11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85D1FFF3D5ED11CD283A = { + fileRef = 01FA891BFFF2BE3511CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 125E85D4FFF3D67D11CD283A = { + isa = PBXLibraryReference; + path = libSecurityAgentServer.a; + refType = 3; + }; + 125E85D5FFF3D67D11CD283A = { + buildPhases = ( + 125E85D6FFF3D67D11CD283A, + 125E85D7FFF3D67D11CD283A, + 125E85D9FFF3D67D11CD283A, + 125E85DAFFF3D67D11CD283A, ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 163; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/include\""; + INSTALL_PATH = /usr/local/lib; + LIBRARY_STYLE = STATIC; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOL_FLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = libSecurityAgentServer.a; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + 125E85DCFFF3D76D11CD283A, + ); + isa = PBXLibraryTarget; + name = "SecurityAgent Server"; + productInstallPath = /usr/local/lib; + productName = "SecurityAgent Server"; + productReference = 125E85D4FFF3D67D11CD283A; }; - 0867D6A0FE84028FC02AAC07 = { + 125E85D6FFF3D67D11CD283A = { buildActionMask = 2147483647; files = ( - 125E85AEFFF3D44A11CD283A, - 325EAA2A00D6B24005CD296C, - 325EAA2B00D6B24005CD296C, - 325EAA2C00D6B24005CD296C, - 325EAA2D00D6B24005CD296C, - 325EAA2E00D6B24005CD296C, - 327DDDFB00D7E81F05CD296C, + 125E8606FFF3DB3E11CD283A, ); - isa = PBXFrameworksBuildPhase; + isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 0867D6A2FE84028FC02AAC07 = { + 125E85D7FFF3D67D11CD283A = { buildActionMask = 2147483647; files = ( + 125E85D8FFF3D67D11CD283A, ); - isa = PBXRezBuildPhase; + isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; -//080 -//081 -//082 -//083 -//084 -//0A0 -//0A1 -//0A2 -//0A3 -//0A4 - 0AD5441E0003C2C511CD296C = { - isa = PBXFileReference; - path = SecurityServer.order; - refType = 4; + 125E85D8FFF3D67D11CD283A = { + fileRef = 01FA8917FFF2BE3511CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; }; -//0A0 -//0A1 -//0A2 -//0A3 -//0A4 -//0F0 -//0F1 -//0F2 -//0F3 -//0F4 - 0F404EB6008616EE7F000001 = { - children = ( - 0F404EB9008618137F000001, - 0F404EBA008618137F000001, - 0F404EBB008618137F000001, - 0F404EBC008618137F000001, - 0F404EBF008618137F000001, - 0F404EC0008618137F000001, - 0F404EC1008618137F000001, - 0F404EC2008618137F000001, - 0F404EC3008618137F000001, - 0F404EC4008618137F000001, - 3264486400D54DD305CD296C, - 3264486500D54DD305CD296C, - 0F404EC5008618137F000001, - 0F404EC7008618137F000001, - 0F404ECA008618137F000001, - 0F404ECB008618137F000001, - 4D37AD3A00AA03857F000001, - 4D37AD3900AA03857F000001, - 4D37AD3C00AA03857F000001, - 4D37AD3B00AA03857F000001, - 4D37AD3E00AA03857F000001, - 4D37AD3D00AA03857F000001, - 4D37AD3F00AA03857F000001, - 4D37AD4100AA03857F000001, - 4D37AD4000AA03857F000001, - 0F404ECC008618137F000001, - 0F404ED5008618137F000001, + 125E85D9FFF3D67D11CD283A = { + buildActionMask = 2147483647; + files = ( ); - isa = PBXGroup; - path = Network; - refType = 4; - }; - 0F404EB9008618137F000001 = { - isa = PBXFileReference; - path = protocol.h; - refType = 4; - }; - 0F404EBA008618137F000001 = { - isa = PBXFileReference; - path = protocol.cpp; - refType = 4; - }; - 0F404EBB008618137F000001 = { - isa = PBXFileReference; - path = transfer.h; - refType = 4; - }; - 0F404EBC008618137F000001 = { - isa = PBXFileReference; - path = transfer.cpp; - refType = 4; - }; - 0F404EBF008618137F000001 = { - isa = PBXFileReference; - path = connectionpool.h; - refType = 4; - }; - 0F404EC0008618137F000001 = { - isa = PBXFileReference; - path = connectionpool.cpp; - refType = 4; - }; - 0F404EC1008618137F000001 = { - isa = PBXFileReference; - path = target.h; - refType = 4; - }; - 0F404EC2008618137F000001 = { - isa = PBXFileReference; - path = target.cpp; - refType = 4; - }; - 0F404EC3008618137F000001 = { - isa = PBXFileReference; - path = observer.h; - refType = 4; + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 0F404EC4008618137F000001 = { - isa = PBXFileReference; - path = observer.cpp; - refType = 4; + 125E85DAFFF3D67D11CD283A = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 0F404EC5008618137F000001 = { - isa = PBXFileReference; - path = parameters.h; - refType = 4; + 125E85DCFFF3D76D11CD283A = { + isa = PBXTargetDependency; + target = 01FA88F0FFF2B96911CD283A; }; - 0F404EC7008618137F000001 = { - isa = PBXFileReference; - path = parameters.cpp; - refType = 4; + 125E8604FFF3D96711CD283A = { + isa = PBXTargetDependency; + target = 125E85D5FFF3D67D11CD283A; }; - 0F404ECA008618137F000001 = { - isa = PBXFileReference; - path = xfercore.h; - refType = 4; + 125E8606FFF3DB3E11CD283A = { + fileRef = 01FA821BFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + }; }; - 0F404ECB008618137F000001 = { +//120 +//121 +//122 +//123 +//124 +//160 +//161 +//162 +//163 +//164 + 1691956B009480BC7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = xfercore.cpp; - refType = 4; + name = RawSigner.h; + path = AppleCSP/AppleCSP/RawSigner.h; + refType = 2; }; - 0F404ECC008618137F000001 = { - children = ( - 0F404ECD008618137F000001, - 0F404ECE008618137F000001, - 0F404ECF008618137F000001, - 0F404ED0008618137F000001, - 0F404ED1008618137F000001, - 0F404ED2008618137F000001, - 0F404ED3008618137F000001, - 0F404ED4008618137F000001, - 21781539008B941B7F000001, - 2178153A008B941B7F000001, - 01827D09008CB8707F000001, - 01827D0A008CB8707F000001, - 017A54F20094AAE57F000001, - 017A54F30094AAE57F000001, - ); - isa = PBXGroup; - name = Protocols; - refType = 4; + 1691956C009480BC7F000001 = { + fileRef = 1691956B009480BC7F000001; + isa = PBXBuildFile; + settings = { + }; }; - 0F404ECD008618137F000001 = { + 1691956D009485A47F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = "file-protocol.h"; + path = SignatureContext.h; refType = 4; }; - 0F404ECE008618137F000001 = { - isa = PBXFileReference; - path = "file-protocol.cpp"; - refType = 4; + 1691956E009485A47F000001 = { + fileRef = 1691956D009485A47F000001; + isa = PBXBuildFile; + settings = { + }; }; - 0F404ECF008618137F000001 = { + 1691956F009486767F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = "ftp-protocol.h"; + path = SignatureContext.cpp; refType = 4; }; - 0F404ED0008618137F000001 = { - isa = PBXFileReference; - path = "ftp-protocol.cpp"; - refType = 4; + 16919570009486767F000001 = { + fileRef = 1691956F009486767F000001; + isa = PBXBuildFile; + settings = { + }; }; - 0F404ED1008618137F000001 = { - isa = PBXFileReference; - path = "http-protocol.h"; + 169195710094A2ED7F000001 = { + children = ( + 59375E6D00A849237F000001, + 2C5247ED007A39B47F000001, + 2C5247EC007A39B47F000001, + 2C5247EE007A39B47F000001, + 57FCEE8B007A7B2F7F000001, + 52BFC306007A6A1B7F000001, + 4A4C766D007A4E317F000001, + 4A4C766C007A4E317F000001, + 4A4C7672007A4E657F000001, + ); + isa = PBXGroup; + name = misc; + path = ""; refType = 4; }; - 0F404ED2008618137F000001 = { - isa = PBXFileReference; - path = "http-protocol.cpp"; + 169195720094A2ED7F000001 = { + children = ( + 169195DF0094A8577F000001, + 169195E00094A8577F000001, + 169195E10094A8577F000001, + 169195E20094A8577F000001, + 169195E40094A8577F000001, + 169195E50094A8577F000001, + 169195E60094A8577F000001, + 169195E70094A8577F000001, + 169195E80094A8577F000001, + 169195E90094A8577F000001, + 169195EA0094A8577F000001, + 59375E6E00A849237F000001, + 169195EB0094A8577F000001, + 2C5247EB007A39B47F000001, + 169195EC0094A8577F000001, + 01D5634800974F7C7F000001, + 169195EE0094A8577F000001, + 2C5247EF007A39B47F000001, + 52BFC304007A6A1B7F000001, + 4A4C766E007A4E317F000001, + 169195EF0094A8577F000001, + 169195F00094A8577F000001, + 169195F10094A8577F000001, + 07E4D6E400A0CD8D7F000001, + 169195F30094A8577F000001, + 169195F20094A8577F000001, + 9D29187F026B504700003D05, + 057C0BBB0456E18300BA3D3B, + 057C0BD704581E6800BA3D3B, + ); + isa = PBXGroup; + name = openssl; refType = 4; }; - 0F404ED3008618137F000001 = { - isa = PBXFileReference; - path = "https-protocol.h"; + 169195730094A5A87F000001 = { + children = ( + 169195740094A5A87F000001, + ); + isa = PBXGroup; + name = stack; refType = 4; }; - 0F404ED4008618137F000001 = { + 169195740094A5A87F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = "https-protocol.cpp"; + name = stack.c; + path = stack/stack.c; refType = 4; }; - 0F404ED5008618137F000001 = { + 169195750094A5A87F000001 = { children = ( - 0F404ED6008618137F000001, - 0F404ED7008618137F000001, + 169195760094A5A87F000001, + 169195770094A5A87F000001, + 169195780094A5A87F000001, + 169195790094A5A87F000001, + 1691957A0094A5A87F000001, + 1691957B0094A5A87F000001, + 1691957C0094A5A87F000001, + 1691957E0094A5A87F000001, + 1691957F0094A5A87F000001, + 169195800094A5A87F000001, + 169195810094A5A87F000001, ); isa = PBXGroup; - name = Managers; + name = rsa; refType = 4; }; - 0F404ED6008618137F000001 = { + 169195760094A5A87F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = simplemanager.h; + name = rsa_chk.c; + path = rsa/rsa_chk.c; refType = 4; }; - 0F404ED7008618137F000001 = { + 169195770094A5A87F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = simplemanager.cpp; + name = rsa_eay.c; + path = rsa/rsa_eay.c; refType = 4; }; -//0F0 -//0F1 -//0F2 -//0F3 -//0F4 -//120 -//121 -//122 -//123 -//124 - 125E85A8FFF3CDEF11CD283A = { + 169195780094A5A87F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = xdatabase.cpp; + name = rsa_err.c; + path = rsa/rsa_err.c; refType = 4; }; - 125E85A9FFF3CDEF11CD283A = { + 169195790094A5A87F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = xdatabase.h; + name = rsa_gen.c; + path = rsa/rsa_gen.c; refType = 4; }; - 125E85ADFFF3D44A11CD283A = { - isa = PBXFrameworkReference; - name = CoreFoundation.framework; - path = /System/Library/Frameworks/CoreFoundation.framework; - refType = 0; - }; - 125E85AEFFF3D44A11CD283A = { - fileRef = 125E85ADFFF3D44A11CD283A; - isa = PBXBuildFile; - settings = { - }; - }; - 125E85AFFFF3D51B11CD283A = { - fileRef = 01FA819FFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; - }; - 125E85B0FFF3D51B11CD283A = { - fileRef = 01FA81A1FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; - }; - 125E85B1FFF3D51B11CD283A = { - fileRef = 01FA81A3FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; - }; - 125E85B2FFF3D51B11CD283A = { - fileRef = 01FA81A5FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; - }; - 125E85B3FFF3D51B11CD283A = { - fileRef = 01FA81AAFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; - }; - 125E85B4FFF3D51B11CD283A = { - fileRef = 01FA819EFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 125E85B5FFF3D51B11CD283A = { - fileRef = 01FA81A0FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 125E85B6FFF3D51B11CD283A = { - fileRef = 01FA81A2FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 125E85B7FFF3D51B11CD283A = { - fileRef = 01FA81A4FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 125E85B8FFF3D51B11CD283A = { - fileRef = 01FA81A9FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 125E85B9FFF3D54811CD283A = { - fileRef = 01FA81B3FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; - }; - 125E85BAFFF3D54811CD283A = { - fileRef = 01FA81B5FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 1691957A0094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rsa_lib.c; + path = rsa/rsa_lib.c; + refType = 4; }; - 125E85BBFFF3D54811CD283A = { - fileRef = 01FA81B9FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 1691957B0094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rsa_none.c; + path = rsa/rsa_none.c; + refType = 4; }; - 125E85BCFFF3D54811CD283A = { - fileRef = 01FA81B2FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 1691957C0094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rsa_null.c; + path = rsa/rsa_null.c; + refType = 4; }; - 125E85BDFFF3D54811CD283A = { - fileRef = 01FA81B4FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 1691957E0094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rsa_pk1.c; + path = rsa/rsa_pk1.c; + refType = 4; }; - 125E85BEFFF3D54811CD283A = { - fileRef = 01FA81B8FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; + 1691957F0094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rsa_saos.c; + path = rsa/rsa_saos.c; + refType = 4; }; - 125E85BFFFF3D5ED11CD283A = { - fileRef = 01FA81BDFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195800094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rsa_sign.c; + path = rsa/rsa_sign.c; + refType = 4; }; - 125E85C0FFF3D5ED11CD283A = { - fileRef = 01FA8219FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195810094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rsa_ssl.c; + path = rsa/rsa_ssl.c; + refType = 4; }; - 125E85C1FFF3D5ED11CD283A = { - fileRef = 01FA821BFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195820094A5A87F000001 = { + children = ( + 169195830094A5A87F000001, + ); + isa = PBXGroup; + name = lhash; + refType = 4; }; - 125E85C2FFF3D5ED11CD283A = { - fileRef = 01FA821DFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195830094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = lhash.c; + path = lhash/lhash.c; + refType = 4; }; - 125E85C3FFF3D5ED11CD283A = { - fileRef = 01FA821EFFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195840094A5A87F000001 = { + children = ( + 169195860094A5A87F000001, + 169195870094A5A87F000001, + ); + isa = PBXGroup; + name = err; + refType = 4; }; - 125E85C4FFF3D5ED11CD283A = { - fileRef = 01FA8221FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195860094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = err_prn.c; + path = err/err_prn.c; + refType = 4; }; - 125E85C5FFF3D5ED11CD283A = { - fileRef = 01FA8223FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195870094A5A87F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = err.c; + path = err/err.c; + refType = 4; }; - 125E85C6FFF3D5ED11CD283A = { - fileRef = 01FA8225FFF2B54C11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195880094A5A87F000001 = { + children = ( + 1691959C0094A63C7F000001, + 1691959D0094A63C7F000001, + 1691959E0094A63C7F000001, + 1691959F0094A63C7F000001, + 169195A00094A63C7F000001, + 169195A10094A63C7F000001, + 169195A20094A63C7F000001, + 169195A30094A63C7F000001, + 169195A40094A63C7F000001, + 169195A50094A63C7F000001, + 169195A60094A63C7F000001, + 169195A70094A63C7F000001, + 169195A80094A63C7F000001, + 169195A90094A63C7F000001, + 169195AA0094A63C7F000001, + 169195AB0094A63C7F000001, + 169195AC0094A63C7F000001, + 169195AD0094A63C7F000001, + 169195AE0094A63C7F000001, + 169195AF0094A63C7F000001, + 169195B00094A63C7F000001, + 169195B10094A63C7F000001, + ); + isa = PBXGroup; + name = bn; + refType = 4; }; - 125E85C7FFF3D5ED11CD283A = { - fileRef = 125E85A9FFF3CDEF11CD283A; - isa = PBXBuildFile; - settings = { - }; + 169195890094A5A87F000001 = { + children = ( + 169195B20094A63C7F000001, + 169195B30094A63C7F000001, + ); + isa = PBXGroup; + name = bio; + refType = 4; }; - 125E85C8FFF3D5ED11CD283A = { - fileRef = 01FA81BCFFF2B54C11CD283A; + 1691958A0094A5A87F000001 = { + children = ( + 169195B40094A63C7F000001, + 169195B50094A63C7F000001, + ); + isa = PBXGroup; + name = buffer; + path = ""; + refType = 4; + }; + 1691958B0094A5A87F000001 = { + fileRef = 169195740094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85C9FFF3D5ED11CD283A = { - fileRef = 01FA8214FFF2B54C11CD283A; + 1691958C0094A5A87F000001 = { + fileRef = 169195760094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85CAFFF3D5ED11CD283A = { - fileRef = 01FA8218FFF2B54C11CD283A; + 1691958D0094A5A87F000001 = { + fileRef = 169195770094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85CCFFF3D5ED11CD283A = { - fileRef = 01FA8220FFF2B54C11CD283A; + 1691958E0094A5A87F000001 = { + fileRef = 169195780094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85CDFFF3D5ED11CD283A = { - fileRef = 01FA8222FFF2B54C11CD283A; + 1691958F0094A5A87F000001 = { + fileRef = 169195790094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85CEFFF3D5ED11CD283A = { - fileRef = 01FA8224FFF2B54C11CD283A; + 169195900094A5A87F000001 = { + fileRef = 1691957A0094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85CFFFF3D5ED11CD283A = { - fileRef = 01FA823AFFF2B54C11CD283A; + 169195910094A5A87F000001 = { + fileRef = 1691957B0094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85D0FFF3D5ED11CD283A = { - fileRef = 125E85A8FFF3CDEF11CD283A; + 169195920094A5A87F000001 = { + fileRef = 1691957C0094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85D1FFF3D5ED11CD283A = { - fileRef = 01FA891BFFF2BE3511CD283A; + 169195940094A5A87F000001 = { + fileRef = 1691957E0094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); - }; - }; - 125E85D4FFF3D67D11CD283A = { - isa = PBXLibraryReference; - path = libSecurityAgentServer.a; - refType = 3; - }; - 125E85D5FFF3D67D11CD283A = { - buildPhases = ( - 125E85D6FFF3D67D11CD283A, - 125E85D7FFF3D67D11CD283A, - 125E85D9FFF3D67D11CD283A, - 125E85DAFFF3D67D11CD283A, - ); - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 54.1.9; - HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/include\""; - INSTALL_PATH = /usr/local/lib; - LIBRARY_STYLE = STATIC; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOL_FLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = libSecurityAgentServer.a; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; - dependencies = ( - 125E85DCFFF3D76D11CD283A, - ); - isa = PBXLibraryTarget; - name = "SecurityAgent Server"; - productInstallPath = /usr/local/lib; - productName = "SecurityAgent Server"; - productReference = 125E85D4FFF3D67D11CD283A; - shouldUseHeadermap = 1; - }; - 125E85D6FFF3D67D11CD283A = { - buildActionMask = 2147483647; - files = ( - 125E8606FFF3DB3E11CD283A, - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 125E85D7FFF3D67D11CD283A = { - buildActionMask = 2147483647; - files = ( - 125E85D8FFF3D67D11CD283A, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; }; - 125E85D8FFF3D67D11CD283A = { - fileRef = 01FA8917FFF2BE3511CD283A; + 169195950094A5A87F000001 = { + fileRef = 1691957F0094A5A87F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - ); }; }; - 125E85D9FFF3D67D11CD283A = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 125E85DAFFF3D67D11CD283A = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 125E85DCFFF3D76D11CD283A = { - isa = PBXTargetDependency; - target = 01FA88F0FFF2B96911CD283A; + 169195960094A5A87F000001 = { + fileRef = 169195800094A5A87F000001; + isa = PBXBuildFile; + settings = { + }; }; - 125E8604FFF3D96711CD283A = { - isa = PBXTargetDependency; - target = 125E85D5FFF3D67D11CD283A; + 169195970094A5A87F000001 = { + fileRef = 169195810094A5A87F000001; + isa = PBXBuildFile; + settings = { + }; }; - 125E8606FFF3DB3E11CD283A = { - fileRef = 01FA821BFFF2B54C11CD283A; + 169195980094A5A87F000001 = { + fileRef = 169195830094A5A87F000001; isa = PBXBuildFile; settings = { }; }; -//120 -//121 -//122 -//123 -//124 -//160 -//161 -//162 -//163 -//164 - 1691956B009480BC7F000001 = { - isa = PBXFileReference; - name = RawSigner.h; - path = AppleCSP/AppleCSP/RawSigner.h; - refType = 2; + 1691959A0094A5A87F000001 = { + fileRef = 169195860094A5A87F000001; + isa = PBXBuildFile; + settings = { + }; }; - 1691956C009480BC7F000001 = { - fileRef = 1691956B009480BC7F000001; + 1691959B0094A5A87F000001 = { + fileRef = 169195870094A5A87F000001; isa = PBXBuildFile; settings = { }; }; - 1691956D009485A47F000001 = { + 1691959C0094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = SignatureContext.h; + name = bn_add.c; + path = bn/bn_add.c; refType = 4; }; - 1691956E009485A47F000001 = { - fileRef = 1691956D009485A47F000001; - isa = PBXBuildFile; - settings = { - }; + 1691959D0094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = bn_asm.c; + path = bn/bn_asm.c; + refType = 4; }; - 1691956F009486767F000001 = { + 1691959E0094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = SignatureContext.cpp; + name = bn_blind.c; + path = bn/bn_blind.c; refType = 4; }; - 16919570009486767F000001 = { - fileRef = 1691956F009486767F000001; - isa = PBXBuildFile; - settings = { - }; + 1691959F0094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = bn_ctx.c; + path = bn/bn_ctx.c; + refType = 4; }; - 169195710094A2ED7F000001 = { - children = ( - 59375E6D00A849237F000001, - 2C5247ED007A39B47F000001, - 2C5247EC007A39B47F000001, - 2C5247EE007A39B47F000001, - 57FCEE8B007A7B2F7F000001, - 52BFC306007A6A1B7F000001, - 4A4C766D007A4E317F000001, - 4A4C766C007A4E317F000001, - 4A4C7672007A4E657F000001, - ); - isa = PBXGroup; - name = misc; - path = ""; + 169195A00094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = bn_div.c; + path = bn/bn_div.c; refType = 4; }; - 169195720094A2ED7F000001 = { - children = ( - 169195DF0094A8577F000001, - 169195E00094A8577F000001, - 169195E10094A8577F000001, - 169195E20094A8577F000001, - 169195E40094A8577F000001, - 169195E50094A8577F000001, - 169195E60094A8577F000001, - 169195E70094A8577F000001, - 169195E80094A8577F000001, - 169195E90094A8577F000001, - 169195EA0094A8577F000001, - 59375E6E00A849237F000001, - 169195EB0094A8577F000001, - 2C5247EB007A39B47F000001, - 169195EC0094A8577F000001, - 01D5634800974F7C7F000001, - 169195EE0094A8577F000001, - 2C5247EF007A39B47F000001, - 52BFC304007A6A1B7F000001, - 4A4C766E007A4E317F000001, - 169195EF0094A8577F000001, - 169195F00094A8577F000001, - 169195F10094A8577F000001, - 07E4D6E400A0CD8D7F000001, - 169195F30094A8577F000001, - 169195F20094A8577F000001, - 9D29187F026B504700003D05, - ); - isa = PBXGroup; - name = openssl; + 169195A10094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = bn_err.c; + path = bn/bn_err.c; refType = 4; }; - 169195730094A5A87F000001 = { - children = ( - 169195740094A5A87F000001, - ); - isa = PBXGroup; - name = stack; + 169195A20094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = bn_exp.c; + path = bn/bn_exp.c; refType = 4; }; - 169195740094A5A87F000001 = { + 169195A30094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = stack.c; - path = stack/stack.c; + name = bn_exp2.c; + path = bn/bn_exp2.c; refType = 4; }; - 169195750094A5A87F000001 = { - children = ( - 169195760094A5A87F000001, - 169195770094A5A87F000001, - 169195780094A5A87F000001, - 169195790094A5A87F000001, - 1691957A0094A5A87F000001, - 1691957B0094A5A87F000001, - 1691957C0094A5A87F000001, - 1691957E0094A5A87F000001, - 1691957F0094A5A87F000001, - 169195800094A5A87F000001, - 169195810094A5A87F000001, - ); - isa = PBXGroup; - name = rsa; + 169195A40094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = bn_gcd.c; + path = bn/bn_gcd.c; refType = 4; }; - 169195760094A5A87F000001 = { + 169195A50094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_chk.c; - path = rsa/rsa_chk.c; + name = bn_lcl.h; + path = bn/bn_lcl.h; refType = 4; }; - 169195770094A5A87F000001 = { + 169195A60094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_eay.c; - path = rsa/rsa_eay.c; + name = bn_lib.c; + path = bn/bn_lib.c; refType = 4; }; - 169195780094A5A87F000001 = { + 169195A70094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_err.c; - path = rsa/rsa_err.c; + name = bn_mont.c; + path = bn/bn_mont.c; refType = 4; }; - 169195790094A5A87F000001 = { + 169195A80094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_gen.c; - path = rsa/rsa_gen.c; + name = bn_mpi.c; + path = bn/bn_mpi.c; refType = 4; }; - 1691957A0094A5A87F000001 = { + 169195A90094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_lib.c; - path = rsa/rsa_lib.c; + name = bn_mul.c; + path = bn/bn_mul.c; refType = 4; }; - 1691957B0094A5A87F000001 = { + 169195AA0094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_none.c; - path = rsa/rsa_none.c; + name = bn_prime.c; + path = bn/bn_prime.c; refType = 4; }; - 1691957C0094A5A87F000001 = { + 169195AB0094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_null.c; - path = rsa/rsa_null.c; + name = bn_prime.h; + path = bn/bn_prime.h; refType = 4; }; - 1691957E0094A5A87F000001 = { + 169195AC0094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_pk1.c; - path = rsa/rsa_pk1.c; + name = bn_print.c; + path = bn/bn_print.c; refType = 4; }; - 1691957F0094A5A87F000001 = { + 169195AD0094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_saos.c; - path = rsa/rsa_saos.c; + name = bn_rand.c; + path = bn/bn_rand.c; refType = 4; }; - 169195800094A5A87F000001 = { + 169195AE0094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_sign.c; - path = rsa/rsa_sign.c; + name = bn_recp.c; + path = bn/bn_recp.c; refType = 4; }; - 169195810094A5A87F000001 = { + 169195AF0094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa_ssl.c; - path = rsa/rsa_ssl.c; + name = bn_shift.c; + path = bn/bn_shift.c; refType = 4; }; - 169195820094A5A87F000001 = { - children = ( - 169195830094A5A87F000001, - ); - isa = PBXGroup; - name = lhash; + 169195B00094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = bn_sqr.c; + path = bn/bn_sqr.c; refType = 4; }; - 169195830094A5A87F000001 = { + 169195B10094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = lhash.c; - path = lhash/lhash.c; + name = bn_word.c; + path = bn/bn_word.c; refType = 4; }; - 169195840094A5A87F000001 = { - children = ( - 169195860094A5A87F000001, - 169195870094A5A87F000001, - ); - isa = PBXGroup; - name = err; + 169195B20094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = bio_lib.c; + path = bio/bio_lib.c; refType = 4; }; - 169195860094A5A87F000001 = { + 169195B30094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = err_prn.c; - path = err/err_prn.c; + name = bss_file.c; + path = bio/bss_file.c; refType = 4; }; - 169195870094A5A87F000001 = { + 169195B40094A63C7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = err.c; - path = err/err.c; + name = buf_err.c; + path = buffer/buf_err.c; refType = 4; }; - 169195880094A5A87F000001 = { - children = ( - 1691959C0094A63C7F000001, - 1691959D0094A63C7F000001, - 1691959E0094A63C7F000001, - 1691959F0094A63C7F000001, - 169195A00094A63C7F000001, - 169195A10094A63C7F000001, - 169195A20094A63C7F000001, - 169195A30094A63C7F000001, - 169195A40094A63C7F000001, - 169195A50094A63C7F000001, - 169195A60094A63C7F000001, - 169195A70094A63C7F000001, - 169195A80094A63C7F000001, - 169195A90094A63C7F000001, - 169195AA0094A63C7F000001, - 169195AB0094A63C7F000001, - 169195AC0094A63C7F000001, - 169195AD0094A63C7F000001, - 169195AE0094A63C7F000001, - 169195AF0094A63C7F000001, - 169195B00094A63C7F000001, - 169195B10094A63C7F000001, - ); - isa = PBXGroup; - name = bn; + 169195B50094A63C7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = buffer.c; + path = buffer/buffer.c; refType = 4; }; - 169195890094A5A87F000001 = { - children = ( - 169195B20094A63C7F000001, - 169195B30094A63C7F000001, - ); - isa = PBXGroup; - name = bio; - refType = 4; + 169195B60094A63C7F000001 = { + fileRef = 169195A50094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; }; - 1691958A0094A5A87F000001 = { - children = ( - 169195B40094A63C7F000001, - 169195B50094A63C7F000001, - ); - isa = PBXGroup; - name = buffer; - path = ""; - refType = 4; + 169195B70094A63C7F000001 = { + fileRef = 169195AB0094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; }; - 1691958B0094A5A87F000001 = { - fileRef = 169195740094A5A87F000001; + 169195B80094A63C7F000001 = { + fileRef = 1691959C0094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 1691958C0094A5A87F000001 = { - fileRef = 169195760094A5A87F000001; + 169195B90094A63C7F000001 = { + fileRef = 1691959D0094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 1691958D0094A5A87F000001 = { - fileRef = 169195770094A5A87F000001; + 169195BA0094A63C7F000001 = { + fileRef = 1691959E0094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 1691958E0094A5A87F000001 = { - fileRef = 169195780094A5A87F000001; + 169195BB0094A63C7F000001 = { + fileRef = 1691959F0094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 1691958F0094A5A87F000001 = { - fileRef = 169195790094A5A87F000001; + 169195BC0094A63C7F000001 = { + fileRef = 169195A00094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 169195900094A5A87F000001 = { - fileRef = 1691957A0094A5A87F000001; + 169195BD0094A63C7F000001 = { + fileRef = 169195A10094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 169195910094A5A87F000001 = { - fileRef = 1691957B0094A5A87F000001; + 169195BE0094A63C7F000001 = { + fileRef = 169195A20094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 169195920094A5A87F000001 = { - fileRef = 1691957C0094A5A87F000001; + 169195BF0094A63C7F000001 = { + fileRef = 169195A30094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 169195940094A5A87F000001 = { - fileRef = 1691957E0094A5A87F000001; + 169195C00094A63C7F000001 = { + fileRef = 169195A40094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 169195950094A5A87F000001 = { - fileRef = 1691957F0094A5A87F000001; + 169195C10094A63C7F000001 = { + fileRef = 169195A60094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 169195960094A5A87F000001 = { - fileRef = 169195800094A5A87F000001; + 169195C20094A63C7F000001 = { + fileRef = 169195A70094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 169195970094A5A87F000001 = { - fileRef = 169195810094A5A87F000001; + 169195C30094A63C7F000001 = { + fileRef = 169195A80094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 169195980094A5A87F000001 = { - fileRef = 169195830094A5A87F000001; + 169195C40094A63C7F000001 = { + fileRef = 169195A90094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 1691959A0094A5A87F000001 = { - fileRef = 169195860094A5A87F000001; + 169195C50094A63C7F000001 = { + fileRef = 169195AA0094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 1691959B0094A5A87F000001 = { - fileRef = 169195870094A5A87F000001; + 169195C60094A63C7F000001 = { + fileRef = 169195AC0094A63C7F000001; isa = PBXBuildFile; settings = { }; }; - 1691959C0094A63C7F000001 = { - isa = PBXFileReference; - name = bn_add.c; - path = bn/bn_add.c; + 169195C70094A63C7F000001 = { + fileRef = 169195AD0094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195C80094A63C7F000001 = { + fileRef = 169195AE0094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195C90094A63C7F000001 = { + fileRef = 169195AF0094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195CA0094A63C7F000001 = { + fileRef = 169195B00094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195CB0094A63C7F000001 = { + fileRef = 169195B10094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195CC0094A63C7F000001 = { + fileRef = 169195B20094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195CD0094A63C7F000001 = { + fileRef = 169195B30094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195CE0094A63C7F000001 = { + fileRef = 169195B40094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195CF0094A63C7F000001 = { + fileRef = 169195B50094A63C7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195D00094A6FD7F000001 = { + children = ( + 169195D70094A7427F000001, + 169195D80094A7427F000001, + 05F88FC00410032C00003D05, + 05F88FC10410032C00003D05, + 05F88FC20410032C00003D05, + 05F88FC30410032C00003D05, + ); + isa = PBXGroup; + name = opensslUtils; refType = 4; }; - 1691959D0094A63C7F000001 = { + 169195D10094A6FD7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_asm.c; - path = bn/bn_asm.c; + path = cryptlib.c; refType = 4; }; - 1691959E0094A63C7F000001 = { + 169195D20094A6FD7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_blind.c; - path = bn/bn_blind.c; + path = ex_data.c; refType = 4; }; - 1691959F0094A63C7F000001 = { + 169195D30094A6FD7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_ctx.c; - path = bn/bn_ctx.c; + path = mem.c; refType = 4; }; - 169195A00094A63C7F000001 = { + 169195D40094A6FD7F000001 = { + fileRef = 169195D10094A6FD7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195D50094A6FD7F000001 = { + fileRef = 169195D20094A6FD7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195D60094A6FD7F000001 = { + fileRef = 169195D30094A6FD7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195D70094A7427F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_div.c; - path = bn/bn_div.c; + name = opensslUtils.cpp; + path = opensslUtils/opensslUtils.cpp; refType = 4; }; - 169195A10094A63C7F000001 = { + 169195D80094A7427F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_err.c; - path = bn/bn_err.c; + name = opensslUtils.h; + path = opensslUtils/opensslUtils.h; refType = 4; }; - 169195A20094A63C7F000001 = { + 169195DB0094A7427F000001 = { + fileRef = 169195D80094A7427F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195DD0094A7427F000001 = { + fileRef = 169195D70094A7427F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 169195DF0094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_exp.c; - path = bn/bn_exp.c; + name = asn1.h; + path = openssl/asn1.h; refType = 4; }; - 169195A30094A63C7F000001 = { + 169195E00094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_exp2.c; - path = bn/bn_exp2.c; + name = bio.h; + path = openssl/bio.h; refType = 4; }; - 169195A40094A63C7F000001 = { + 169195E10094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_gcd.c; - path = bn/bn_gcd.c; + name = bn.h; + path = openssl/bn.h; refType = 4; }; - 169195A50094A63C7F000001 = { + 169195E20094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_lcl.h; - path = bn/bn_lcl.h; + name = buffer.h; + path = openssl/buffer.h; refType = 4; }; - 169195A60094A63C7F000001 = { + 169195E30094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_lib.c; - path = bn/bn_lib.c; + path = cryptlib.h; refType = 4; }; - 169195A70094A63C7F000001 = { + 169195E40094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_mont.c; - path = bn/bn_mont.c; + name = crypto.h; + path = openssl/crypto.h; refType = 4; }; - 169195A80094A63C7F000001 = { + 169195E50094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_mpi.c; - path = bn/bn_mpi.c; + name = dsa.h; + path = openssl/dsa.h; refType = 4; }; - 169195A90094A63C7F000001 = { + 169195E60094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_mul.c; - path = bn/bn_mul.c; + name = e_os.h; + path = openssl/e_os.h; refType = 4; }; - 169195AA0094A63C7F000001 = { + 169195E70094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_prime.c; - path = bn/bn_prime.c; + name = e_os2.h; + path = openssl/e_os2.h; refType = 4; }; - 169195AB0094A63C7F000001 = { + 169195E80094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_prime.h; - path = bn/bn_prime.h; + name = err.h; + path = openssl/err.h; refType = 4; }; - 169195AC0094A63C7F000001 = { + 169195E90094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_print.c; - path = bn/bn_print.c; + name = evp.h; + path = openssl/evp.h; refType = 4; }; - 169195AD0094A63C7F000001 = { + 169195EA0094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_rand.c; - path = bn/bn_rand.c; + name = lhash.h; + path = openssl/lhash.h; refType = 4; }; - 169195AE0094A63C7F000001 = { + 169195EB0094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_recp.c; - path = bn/bn_recp.c; + name = objects.h; + path = openssl/objects.h; refType = 4; }; - 169195AF0094A63C7F000001 = { + 169195EC0094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_shift.c; - path = bn/bn_shift.c; + name = opensslv.h; + path = openssl/opensslv.h; refType = 4; }; - 169195B00094A63C7F000001 = { + 169195EE0094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_sqr.c; - path = bn/bn_sqr.c; + name = rand.h; + path = openssl/rand.h; refType = 4; }; - 169195B10094A63C7F000001 = { + 169195EF0094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn_word.c; - path = bn/bn_word.c; + name = rsa.h; + path = openssl/rsa.h; refType = 4; }; - 169195B20094A63C7F000001 = { + 169195F00094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bio_lib.c; - path = bio/bio_lib.c; + name = safestack.h; + path = openssl/safestack.h; refType = 4; }; - 169195B30094A63C7F000001 = { + 169195F10094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bss_file.c; - path = bio/bss_file.c; + name = stack.h; + path = openssl/stack.h; refType = 4; }; - 169195B40094A63C7F000001 = { + 169195F20094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = buf_err.c; - path = buffer/buf_err.c; + name = x509_vfy.h; + path = openssl/x509_vfy.h; refType = 4; }; - 169195B50094A63C7F000001 = { + 169195F30094A8577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = buffer.c; - path = buffer/buffer.c; + name = x509.h; + path = openssl/x509.h; refType = 4; }; - 169195B60094A63C7F000001 = { - fileRef = 169195A50094A63C7F000001; + 169195F40094A8577F000001 = { + fileRef = 169195DF0094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195B70094A63C7F000001 = { - fileRef = 169195AB0094A63C7F000001; + 169195F50094A8577F000001 = { + fileRef = 169195E00094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195B80094A63C7F000001 = { - fileRef = 1691959C0094A63C7F000001; + 169195F60094A8577F000001 = { + fileRef = 169195E10094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195B90094A63C7F000001 = { - fileRef = 1691959D0094A63C7F000001; + 169195F70094A8577F000001 = { + fileRef = 169195E20094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195BA0094A63C7F000001 = { - fileRef = 1691959E0094A63C7F000001; + 169195F80094A8577F000001 = { + fileRef = 169195E30094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195BB0094A63C7F000001 = { - fileRef = 1691959F0094A63C7F000001; + 169195F90094A8577F000001 = { + fileRef = 169195E40094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195BC0094A63C7F000001 = { - fileRef = 169195A00094A63C7F000001; + 169195FA0094A8577F000001 = { + fileRef = 169195E50094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195BD0094A63C7F000001 = { - fileRef = 169195A10094A63C7F000001; + 169195FB0094A8577F000001 = { + fileRef = 169195E60094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195BE0094A63C7F000001 = { - fileRef = 169195A20094A63C7F000001; + 169195FC0094A8577F000001 = { + fileRef = 169195E70094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195BF0094A63C7F000001 = { - fileRef = 169195A30094A63C7F000001; + 169195FD0094A8577F000001 = { + fileRef = 169195E80094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C00094A63C7F000001 = { - fileRef = 169195A40094A63C7F000001; + 169195FE0094A8577F000001 = { + fileRef = 169195E90094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C10094A63C7F000001 = { - fileRef = 169195A60094A63C7F000001; + 169195FF0094A8577F000001 = { + fileRef = 169195EA0094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C20094A63C7F000001 = { - fileRef = 169195A70094A63C7F000001; + 169196000094A8577F000001 = { + fileRef = 169195EB0094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C30094A63C7F000001 = { - fileRef = 169195A80094A63C7F000001; + 169196010094A8577F000001 = { + fileRef = 169195EC0094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C40094A63C7F000001 = { - fileRef = 169195A90094A63C7F000001; + 169196030094A8577F000001 = { + fileRef = 169195EE0094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C50094A63C7F000001 = { - fileRef = 169195AA0094A63C7F000001; + 169196040094A8577F000001 = { + fileRef = 169195EF0094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C60094A63C7F000001 = { - fileRef = 169195AC0094A63C7F000001; + 169196050094A8577F000001 = { + fileRef = 169195F00094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C70094A63C7F000001 = { - fileRef = 169195AD0094A63C7F000001; + 169196060094A8577F000001 = { + fileRef = 169195F10094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C80094A63C7F000001 = { - fileRef = 169195AE0094A63C7F000001; + 169196070094A8577F000001 = { + fileRef = 169195F20094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195C90094A63C7F000001 = { - fileRef = 169195AF0094A63C7F000001; + 169196080094A8577F000001 = { + fileRef = 169195F30094A8577F000001; isa = PBXBuildFile; settings = { }; }; - 169195CA0094A63C7F000001 = { - fileRef = 169195B00094A63C7F000001; - isa = PBXBuildFile; - settings = { - }; +//160 +//161 +//162 +//163 +//164 +//1B0 +//1B1 +//1B2 +//1B3 +//1B4 + 1B40D2E3FFF9716411CD283A = { + isa = PBXTargetDependency; + target = 030701E4FFF96F8511CD283A; }; - 169195CB0094A63C7F000001 = { - fileRef = 169195B10094A63C7F000001; + 1B40D2E4FFF9716411CD283A = { + isa = PBXTargetDependency; + target = 01FA88F0FFF2B96911CD283A; + }; + 1BA451B10097605B7F000001 = { + isa = PBXFrameworkReference; + path = Security.framework; + refType = 3; + }; + 1BA451B20097605B7F000001 = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 169195CC0094A63C7F000001 = { - fileRef = 169195B20094A63C7F000001; + 1BA451B30097605B7F000001 = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 169195CD0094A63C7F000001 = { - fileRef = 169195B30094A63C7F000001; +//1B0 +//1B1 +//1B2 +//1B3 +//1B4 +//200 +//201 +//202 +//203 +//204 + 209FCB4E00A738117F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MacContext.h; + path = MiscCSPAlgs/MacContext.h; + refType = 4; + }; + 209FCB4F00A738117F000001 = { + fileRef = 209FCB4E00A738117F000001; isa = PBXBuildFile; settings = { }; }; - 169195CE0094A63C7F000001 = { - fileRef = 169195B40094A63C7F000001; - isa = PBXBuildFile; - settings = { - }; + 209FCB5000A739657F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MacContext.cpp; + path = AppleCSP/MiscCSPAlgs/MacContext.cpp; + refType = 2; }; - 169195CF0094A63C7F000001 = { - fileRef = 169195B50094A63C7F000001; + 209FCB5100A739657F000001 = { + fileRef = 209FCB5000A739657F000001; isa = PBXBuildFile; settings = { }; }; - 169195D00094A6FD7F000001 = { - children = ( - 169195D70094A7427F000001, - 169195D80094A7427F000001, - 169195D90094A7427F000001, - 169195DA0094A7427F000001, - ); - isa = PBXGroup; - name = opensslUtils; - refType = 4; - }; - 169195D10094A6FD7F000001 = { +//200 +//201 +//202 +//203 +//204 +//210 +//211 +//212 +//213 +//214 + 21306AAD0030B27011CD283A = { + fileEncoding = 30; isa = PBXFileReference; - path = cryptlib.c; + path = Localizable.strings; refType = 4; }; - 169195D20094A6FD7F000001 = { + 21781539008B941B7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = ex_data.c; + path = "http-proxy-protocol.h"; refType = 4; }; - 169195D30094A6FD7F000001 = { + 2178153A008B941B7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = mem.c; + path = "http-proxy-protocol.cpp"; refType = 4; }; - 169195D40094A6FD7F000001 = { - fileRef = 169195D10094A6FD7F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 169195D50094A6FD7F000001 = { - fileRef = 169195D20094A6FD7F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 169195D60094A6FD7F000001 = { - fileRef = 169195D30094A6FD7F000001; - isa = PBXBuildFile; - settings = { - }; +//210 +//211 +//212 +//213 +//214 +//250 +//251 +//252 +//253 +//254 + 256C38AB0094AE067F000001 = { + children = ( + 256C38AC0094AE787F000001, + 256C38AD0094AE787F000001, + 256C38AE0094AE787F000001, + 256C38AF0094AE787F000001, + 28B044DF0094C5577F000001, + 28B044E10094C6C57F000001, + 256C38B60094B96F7F000001, + 256C38B40094B2537F000001, + 28B044E30094DC627F000001, + 28B044E40094DC627F000001, + ); + isa = PBXGroup; + name = RSA_DSA; + refType = 4; }; - 169195D70094A7427F000001 = { + 256C38AC0094AE787F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = opensslUtils.cpp; - path = opensslUtils/opensslUtils.cpp; + name = RSA_DSA_csp.h; + path = RSA_DSA/RSA_DSA_csp.h; refType = 4; }; - 169195D80094A7427F000001 = { + 256C38AD0094AE787F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = opensslUtils.h; - path = opensslUtils/opensslUtils.h; + name = RSA_DSA_csp.cpp; + path = RSA_DSA/RSA_DSA_csp.cpp; refType = 4; }; - 169195D90094A7427F000001 = { + 256C38AE0094AE787F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = openRsaSnacc.cpp; - path = opensslUtils/openRsaSnacc.cpp; + name = RSA_DSA_keys.cpp; + path = RSA_DSA/RSA_DSA_keys.cpp; refType = 4; }; - 169195DA0094A7427F000001 = { + 256C38AF0094AE787F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = openRsaSnacc.h; - path = opensslUtils/openRsaSnacc.h; + name = RSA_DSA_keys.h; + path = RSA_DSA/RSA_DSA_keys.h; refType = 4; }; - 169195DB0094A7427F000001 = { - fileRef = 169195D80094A7427F000001; + 256C38B00094AE787F000001 = { + fileRef = 256C38AC0094AE787F000001; isa = PBXBuildFile; settings = { }; }; - 169195DC0094A7427F000001 = { - fileRef = 169195DA0094A7427F000001; + 256C38B10094AE787F000001 = { + fileRef = 256C38AF0094AE787F000001; isa = PBXBuildFile; settings = { }; }; - 169195DD0094A7427F000001 = { - fileRef = 169195D70094A7427F000001; + 256C38B20094AE787F000001 = { + fileRef = 256C38AD0094AE787F000001; isa = PBXBuildFile; settings = { }; }; - 169195DE0094A7427F000001 = { - fileRef = 169195D90094A7427F000001; + 256C38B30094AE787F000001 = { + fileRef = 256C38AE0094AE787F000001; isa = PBXBuildFile; settings = { }; }; - 169195DF0094A8577F000001 = { + 256C38B40094B2537F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = asn1.h; - path = openssl/asn1.h; - refType = 4; + name = RSA_DSA_utils.h; + path = AppleCSP/RSA_DSA/RSA_DSA_utils.h; + refType = 2; }; - 169195E00094A8577F000001 = { - isa = PBXFileReference; - name = bio.h; - path = openssl/bio.h; - refType = 4; + 256C38B50094B2537F000001 = { + fileRef = 256C38B40094B2537F000001; + isa = PBXBuildFile; + settings = { + }; }; - 169195E10094A8577F000001 = { + 256C38B60094B96F7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = bn.h; - path = openssl/bn.h; - refType = 4; + name = RSA_DSA_utils.cpp; + path = AppleCSP/RSA_DSA/RSA_DSA_utils.cpp; + refType = 2; }; - 169195E20094A8577F000001 = { - isa = PBXFileReference; - name = buffer.h; - path = openssl/buffer.h; - refType = 4; + 256C38B70094B96F7F000001 = { + fileRef = 256C38B60094B96F7F000001; + isa = PBXBuildFile; + settings = { + }; }; - 169195E30094A8577F000001 = { +//250 +//251 +//252 +//253 +//254 +//280 +//281 +//282 +//283 +//284 + 28B044DF0094C5577F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = cryptlib.h; - refType = 4; + name = RSA_DSA_signature.h; + path = AppleCSP/RSA_DSA/RSA_DSA_signature.h; + refType = 2; }; - 169195E40094A8577F000001 = { - isa = PBXFileReference; - name = crypto.h; - path = openssl/crypto.h; - refType = 4; + 28B044E00094C5577F000001 = { + fileRef = 28B044DF0094C5577F000001; + isa = PBXBuildFile; + settings = { + }; }; - 169195E50094A8577F000001 = { + 28B044E10094C6C57F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = dsa.h; - path = openssl/dsa.h; - refType = 4; + name = RSA_DSA_signature.cpp; + path = AppleCSP/RSA_DSA/RSA_DSA_signature.cpp; + refType = 2; }; - 169195E60094A8577F000001 = { - isa = PBXFileReference; - name = e_os.h; - path = openssl/e_os.h; - refType = 4; + 28B044E20094C6C57F000001 = { + fileRef = 28B044E10094C6C57F000001; + isa = PBXBuildFile; + settings = { + }; }; - 169195E70094A8577F000001 = { + 28B044E30094DC627F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = e_os2.h; - path = openssl/e_os2.h; + name = RSA_asymmetric.cpp; + path = RSA_DSA/RSA_asymmetric.cpp; refType = 4; }; - 169195E80094A8577F000001 = { + 28B044E40094DC627F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = err.h; - path = openssl/err.h; + name = RSA_asymmetric.h; + path = RSA_DSA/RSA_asymmetric.h; refType = 4; }; - 169195E90094A8577F000001 = { - isa = PBXFileReference; - name = evp.h; - path = openssl/evp.h; - refType = 4; + 28B044E50094DC627F000001 = { + fileRef = 28B044E40094DC627F000001; + isa = PBXBuildFile; + settings = { + }; }; - 169195EA0094A8577F000001 = { - isa = PBXFileReference; - name = lhash.h; - path = openssl/lhash.h; - refType = 4; + 28B044E60094DC627F000001 = { + fileRef = 28B044E30094DC627F000001; + isa = PBXBuildFile; + settings = { + }; }; - 169195EB0094A8577F000001 = { - isa = PBXFileReference; - name = objects.h; - path = openssl/objects.h; +//280 +//281 +//282 +//283 +//284 +//2C0 +//2C1 +//2C2 +//2C3 +//2C4 + 2C5247EA007A39B47F000001 = { + children = ( + 057C0BB00456E14700BA3D3B, + 057C0BC404581E0000BA3D3B, + 9D291872026B4FF900003D05, + 07E4D6D300A0CA617F000001, + 169195D00094A6FD7F000001, + 169195890094A5A87F000001, + 169195880094A5A87F000001, + 1691958A0094A5A87F000001, + 169195840094A5A87F000001, + 169195820094A5A87F000001, + 169195710094A2ED7F000001, + 169195750094A5A87F000001, + 169195730094A5A87F000001, + 169195720094A2ED7F000001, + 169195D10094A6FD7F000001, + 169195E30094A8577F000001, + 169195D20094A6FD7F000001, + 169195D30094A6FD7F000001, + ); + isa = PBXGroup; + path = open_ssl; refType = 4; }; - 169195EC0094A8577F000001 = { + 2C5247EB007A39B47F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = opensslv.h; - path = openssl/opensslv.h; + name = opensslconf.h; + path = openssl/opensslconf.h; refType = 4; }; - 169195EE0094A8577F000001 = { + 2C5247EC007A39B47F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rand.h; - path = openssl/rand.h; + name = rc2_cbc.c; + path = misc/rc2_cbc.c; refType = 4; }; - 169195EF0094A8577F000001 = { + 2C5247ED007A39B47F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = rsa.h; - path = openssl/rsa.h; + name = rc2_locl.h; + path = misc/rc2_locl.h; refType = 4; }; - 169195F00094A8577F000001 = { + 2C5247EE007A39B47F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = safestack.h; - path = openssl/safestack.h; + name = rc2_skey.c; + path = misc/rc2_skey.c; refType = 4; }; - 169195F10094A8577F000001 = { + 2C5247EF007A39B47F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = stack.h; - path = openssl/stack.h; + name = rc2.h; + path = openssl/rc2.h; refType = 4; }; - 169195F20094A8577F000001 = { + 2C5247F0007A39B47F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = x509_vfy.h; - path = openssl/x509_vfy.h; + name = rc2Context.cpp; + path = MiscCSPAlgs/rc2Context.cpp; refType = 4; }; - 169195F30094A8577F000001 = { + 2C5247F1007A39B47F000001 = { + fileEncoding = 30; isa = PBXFileReference; - name = x509.h; - path = openssl/x509.h; + name = rc2Context.h; + path = MiscCSPAlgs/rc2Context.h; refType = 4; }; - 169195F40094A8577F000001 = { - fileRef = 169195DF0094A8577F000001; + 2C5247F2007A39B47F000001 = { + fileRef = 2C5247EB007A39B47F000001; isa = PBXBuildFile; settings = { }; }; - 169195F50094A8577F000001 = { - fileRef = 169195E00094A8577F000001; + 2C5247F3007A39B47F000001 = { + fileRef = 2C5247ED007A39B47F000001; isa = PBXBuildFile; settings = { }; }; - 169195F60094A8577F000001 = { - fileRef = 169195E10094A8577F000001; + 2C5247F4007A39B47F000001 = { + fileRef = 2C5247EF007A39B47F000001; isa = PBXBuildFile; settings = { }; }; - 169195F70094A8577F000001 = { - fileRef = 169195E20094A8577F000001; + 2C5247F5007A39B47F000001 = { + fileRef = 2C5247F1007A39B47F000001; isa = PBXBuildFile; settings = { }; }; - 169195F80094A8577F000001 = { - fileRef = 169195E30094A8577F000001; + 2C5247F6007A39B47F000001 = { + fileRef = 2C5247EC007A39B47F000001; isa = PBXBuildFile; settings = { }; }; - 169195F90094A8577F000001 = { - fileRef = 169195E40094A8577F000001; + 2C5247F7007A39B47F000001 = { + fileRef = 2C5247EE007A39B47F000001; isa = PBXBuildFile; settings = { }; }; - 169195FA0094A8577F000001 = { - fileRef = 169195E50094A8577F000001; + 2C5247F8007A39B47F000001 = { + fileRef = 2C5247F0007A39B47F000001; isa = PBXBuildFile; settings = { }; }; - 169195FB0094A8577F000001 = { - fileRef = 169195E60094A8577F000001; +//2C0 +//2C1 +//2C2 +//2C3 +//2C4 +//2D0 +//2D1 +//2D2 +//2D3 +//2D4 + 2DFDC7A8FFF3E4ED11CD283A = { + fileRef = 01FA821DFFF2B54C11CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 169195FC0094A8577F000001 = { - fileRef = 169195E70094A8577F000001; +//2D0 +//2D1 +//2D2 +//2D3 +//2D4 +//2F0 +//2F1 +//2F2 +//2F3 +//2F4 + 2F4DD9A500A0A0767F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = fdsel.h; + refType = 4; + }; + 2F4DD9A600A0A0767F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = fdsel.cpp; + refType = 4; + }; + 2F4DD9A700A0A0767F000001 = { + fileRef = 2F4DD9A500A0A0767F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 169195FD0094A8577F000001 = { - fileRef = 169195E80094A8577F000001; + 2F4DD9A800A0A0767F000001 = { + fileRef = 2F4DD9A600A0A0767F000001; isa = PBXBuildFile; settings = { }; }; - 169195FE0094A8577F000001 = { - fileRef = 169195E90094A8577F000001; +//2F0 +//2F1 +//2F2 +//2F3 +//2F4 +//310 +//311 +//312 +//313 +//314 + 31200C5CFFF3E57C11CD283A = { + fileRef = 01FA891FFFF2BE3511CD283A; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 169195FF0094A8577F000001 = { - fileRef = 169195EA0094A8577F000001; +//310 +//311 +//312 +//313 +//314 +//320 +//321 +//322 +//323 +//324 + 3206D1FB029996FC05CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = TrustItem.cpp; + refType = 4; + }; + 3206D1FC029996FC05CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = TrustItem.h; + refType = 4; + }; + 3206D1FD029996FC05CA2E77 = { + fileRef = 3206D1FB029996FC05CA2E77; isa = PBXBuildFile; settings = { }; }; - 169196000094A8577F000001 = { - fileRef = 169195EB0094A8577F000001; + 3206D1FE029996FC05CA2E77 = { + fileRef = 3206D1FC029996FC05CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 169196010094A8577F000001 = { - fileRef = 169195EC0094A8577F000001; + 320C8FE900EA6AD705CD296C = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = NO; + OTHER_CFLAGS = "\U0001-Wall -W -Winline -Wundef -Wno-unused -Wcast-qual -Wcast-align -Wmissing-noreturn"; + }; + isa = PBXBuildStyle; + name = "Lint Screen"; + }; + 320F609D0234113505CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cssmcert.cpp; + refType = 4; + }; + 320F609E0234113505CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cssmcert.h; + refType = 4; + }; + 320F609F0234113505CA2E77 = { + fileRef = 320F609D0234113505CA2E77; isa = PBXBuildFile; settings = { }; }; - 169196030094A8577F000001 = { - fileRef = 169195EE0094A8577F000001; + 320F60A00234113505CA2E77 = { + fileRef = 320F609E0234113505CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 169196040094A8577F000001 = { - fileRef = 169195EF0094A8577F000001; + 322C5F3B02B9641F05CA2E77 = { + buildArgumentsString = "-f $(SRCROOT)/keychains/Makefile $ACTION"; + buildPhases = ( + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = "System Keychains"; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + buildToolPath = /usr/bin/gnumake; + buildWorkingDirectory = ""; + dependencies = ( + ); + isa = PBXLegacyTarget; + name = "System Keychains"; + passBuildSettingsInEnvironment = 1; + productName = "System Keychains"; + settingsToExpand = 6; + settingsToPassInEnvironment = 287; + settingsToPassOnCommandLine = 280; + }; + 32361EEC01EB8FCF05CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = notifications.h; + refType = 4; + }; + 32361EED01EB8FCF05CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = notifications.cpp; + refType = 4; + }; + 32361EEE01EB8FD005CA2E77 = { + fileRef = 32361EEC01EB8FCF05CA2E77; isa = PBXBuildFile; settings = { }; }; - 169196050094A8577F000001 = { - fileRef = 169195F00094A8577F000001; + 32361EEF01EB8FD005CA2E77 = { + fileRef = 32361EED01EB8FCF05CA2E77; isa = PBXBuildFile; settings = { }; }; - 169196060094A8577F000001 = { - fileRef = 169195F10094A8577F000001; + 32361F0701F4B28E05CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = ucspNotify.defs; + refType = 4; + }; + 32361F0A01F4B39505CA2E77 = { + fileRef = 01FA823CFFF2B54C11CD283A; isa = PBXBuildFile; settings = { }; }; - 169196070094A8577F000001 = { - fileRef = 169195F20094A8577F000001; + 324414870236DD1505CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cfutilities.cpp; + refType = 4; + }; + 324414880236DD1505CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cfutilities.h; + refType = 4; + }; + 324414890236DD1505CA2E77 = { + fileRef = 324414870236DD1505CA2E77; isa = PBXBuildFile; settings = { }; }; - 169196080094A8577F000001 = { - fileRef = 169195F30094A8577F000001; + 3244148A0236DD1505CA2E77 = { + fileRef = 324414880236DD1505CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; -//160 -//161 -//162 -//163 -//164 -//1B0 -//1B1 -//1B2 -//1B3 -//1B4 - 1B40D2E3FFF9716411CD283A = { - isa = PBXTargetDependency; - target = 030701E4FFF96F8511CD283A; + 3244148B0236DD2705CA2E77 = { + children = ( + 324414880236DD1505CA2E77, + 324414870236DD1505CA2E77, + ); + isa = PBXGroup; + name = CF; + refType = 4; }; - 1B40D2E4FFF9716411CD283A = { - isa = PBXTargetDependency; - target = 01FA88F0FFF2B96911CD283A; + 3244148C023837A505CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = TrustStore.cpp; + refType = 4; }; - 1BA451B10097605B7F000001 = { - isa = PBXFrameworkReference; - path = Security.framework; - refType = 3; + 3244148D023837A505CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = TrustStore.h; + refType = 4; }; - 1BA451B20097605B7F000001 = { - fileRef = 1BA451B10097605B7F000001; + 3244148E023837A505CA2E77 = { + fileRef = 3244148C023837A505CA2E77; isa = PBXBuildFile; settings = { }; }; - 1BA451B30097605B7F000001 = { - fileRef = 1BA451B10097605B7F000001; + 3244148F023837A505CA2E77 = { + fileRef = 3244148D023837A505CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; -//1B0 -//1B1 -//1B2 -//1B3 -//1B4 -//200 -//201 -//202 -//203 -//204 - 209FCB4E00A738117F000001 = { + 3253C16401C7D8A005CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = MacContext.h; - path = MiscCSPAlgs/MacContext.h; + path = entropy.h; refType = 4; }; - 209FCB4F00A738117F000001 = { - fileRef = 209FCB4E00A738117F000001; + 3253C16501C7D8A005CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = entropy.cpp; + refType = 4; + }; + 3253C16601C7D8A105CA2E77 = { + fileRef = 3253C16401C7D8A005CA2E77; isa = PBXBuildFile; settings = { }; }; - 209FCB5000A739657F000001 = { - isa = PBXFileReference; - name = MacContext.cpp; - path = AppleCSP/MiscCSPAlgs/MacContext.cpp; - refType = 2; - }; - 209FCB5100A739657F000001 = { - fileRef = 209FCB5000A739657F000001; + 3253C16701C7D8A105CA2E77 = { + fileRef = 3253C16501C7D8A005CA2E77; isa = PBXBuildFile; settings = { }; }; -//200 -//201 -//202 -//203 -//204 -//210 -//211 -//212 -//213 -//214 - 21306AAD0030B27011CD283A = { + 32554D7901F4C97305CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = Localizable.strings; + path = ucspNotifySender.cpp; refType = 4; }; - 21781539008B941B7F000001 = { + 32554D7A01F4C97305CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = "http-proxy-protocol.h"; + path = ucspNotify.h; refType = 4; }; - 2178153A008B941B7F000001 = { - isa = PBXFileReference; - path = "http-proxy-protocol.cpp"; - refType = 4; + 32554D7B01F4C97305CA2E77 = { + fileRef = 32554D7A01F4C97305CA2E77; + isa = PBXBuildFile; + settings = { + }; }; -//210 -//211 -//212 -//213 -//214 -//250 -//251 -//252 -//253 -//254 - 256C38AB0094AE067F000001 = { + 32554D7C01F4C97405CA2E77 = { + fileRef = 32554D7901F4C97305CA2E77; + isa = PBXBuildFile; + settings = { + }; + }; + 325EAA2100D6B08805CD296C = { + isa = PBXBundleReference; + path = AppleCSP.bundle; + refType = 3; + }; + 325EAA2200D6B08805CD296C = { + buildPhases = ( + 325EAA2400D6B08805CD296C, + 325EAA2500D6B08805CD296C, + 325EAA2600D6B08805CD296C, + 325EAA2700D6B08805CD296C, + 325EAA2800D6B08805CD296C, + ); + buildSettings = { + CURRENT_PROJECT_VERSION = 163; + LIBRARY_SEARCH_PATHS = ""; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = "-bundle -undefined error"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = AppleCSP; + SECTORDER_FLAGS = ""; + VERSIONING_SYSTEM = "apple-generic"; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = bundle; + }; + dependencies = ( + 325EAA2300D6B08805CD296C, + ); + isa = PBXBundleTarget; + name = "AppleCSP Plugin"; + productName = "AppleCSP Plugin"; + productReference = 325EAA2100D6B08805CD296C; + productSettingsXML = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + AppleCSP + CFBundleGetInfoString + + CFBundleIconFile + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + + CFBundlePackageType + BNDL + CFBundleShortVersionString + 2.0 + CFBundleSignature + ???? + CFBundleVersion + 163 + + +"; + }; + 325EAA2300D6B08805CD296C = { + isa = PBXTargetDependency; + target = 014880CD005EAE4D11CD283A; + }; + 325EAA2400D6B08805CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 325EAA2500D6B08805CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 325EAA2600D6B08805CD296C = { + buildActionMask = 2147483647; + files = ( + 325EAA3800D6B47505CD296C, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 325EAA2700D6B08805CD296C = { + buildActionMask = 2147483647; + files = ( + 325EAA3300D6B2BF05CD296C, + 325EAA3400D6B2BF05CD296C, + 325EAA3500D6B2BF05CD296C, + 3290381400D6B78A05CD296C, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 325EAA2800D6B08805CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 325EAA2900D6B23F05CD296C = { children = ( - 256C38AC0094AE787F000001, - 256C38AD0094AE787F000001, - 256C38AE0094AE787F000001, - 256C38AF0094AE787F000001, - 28B044DF0094C5577F000001, - 28B044E10094C6C57F000001, - 256C38B60094B96F7F000001, - 256C38B40094B2537F000001, - 28B044E30094DC627F000001, - 28B044E40094DC627F000001, + 0149036600A9E34D7F000001, + 0149036700A9E34D7F000001, ); isa = PBXGroup; - name = RSA_DSA; + name = "From BSafe"; refType = 4; }; - 256C38AC0094AE787F000001 = { - isa = PBXFileReference; - name = RSA_DSA_csp.h; - path = RSA_DSA/RSA_DSA_csp.h; - refType = 4; + 325EAA2A00D6B24005CD296C = { + fileRef = 014880C7005EAE4D11CD283A; + isa = PBXBuildFile; + settings = { + }; }; - 256C38AD0094AE787F000001 = { - isa = PBXFileReference; - name = RSA_DSA_csp.cpp; - path = RSA_DSA/RSA_DSA_csp.cpp; - refType = 4; + 325EAA2B00D6B24005CD296C = { + fileRef = 014880C8005EAE4D11CD283A; + isa = PBXBuildFile; + settings = { + }; }; - 256C38AE0094AE787F000001 = { - isa = PBXFileReference; - name = RSA_DSA_keys.cpp; - path = RSA_DSA/RSA_DSA_keys.cpp; - refType = 4; + 325EAA2C00D6B24005CD296C = { + fileRef = 014880C9005EAE4D11CD283A; + isa = PBXBuildFile; + settings = { + }; }; - 256C38AF0094AE787F000001 = { - isa = PBXFileReference; - name = RSA_DSA_keys.h; - path = RSA_DSA/RSA_DSA_keys.h; - refType = 4; + 325EAA2D00D6B24005CD296C = { + fileRef = 014880CA005EAE4D11CD283A; + isa = PBXBuildFile; + settings = { + }; }; - 256C38B00094AE787F000001 = { - fileRef = 256C38AC0094AE787F000001; + 325EAA2E00D6B24005CD296C = { + fileRef = 014880CB005EAE4D11CD283A; isa = PBXBuildFile; settings = { }; }; - 256C38B10094AE787F000001 = { - fileRef = 256C38AF0094AE787F000001; + 325EAA3100D6B2BE05CD296C = { + children = ( + 014880C7005EAE4D11CD283A, + 014880C8005EAE4D11CD283A, + 014880C9005EAE4D11CD283A, + 014880CA005EAE4D11CD283A, + 014880CB005EAE4D11CD283A, + ); + isa = PBXGroup; + name = "Plugins as Libraries"; + path = ""; + refType = 4; + }; + 325EAA3200D6B2BE05CD296C = { + children = ( + 325EAA2100D6B08805CD296C, + 3290381500D6BA5905CD296C, + 3290381600D6BA5905CD296C, + 3290381700D6BA5905CD296C, + 3290381800D6BA5905CD296C, + ); + isa = PBXGroup; + name = "Plugins Proper"; + refType = 4; + }; + 325EAA3300D6B2BF05CD296C = { + fileRef = 014880C7005EAE4D11CD283A; isa = PBXBuildFile; settings = { }; }; - 256C38B20094AE787F000001 = { - fileRef = 256C38AD0094AE787F000001; + 325EAA3400D6B2BF05CD296C = { + fileRef = 0149036600A9E34D7F000001; isa = PBXBuildFile; settings = { }; }; - 256C38B30094AE787F000001 = { - fileRef = 256C38AE0094AE787F000001; + 325EAA3500D6B2BF05CD296C = { + fileRef = 0149036700A9E34D7F000001; isa = PBXBuildFile; settings = { }; }; - 256C38B40094B2537F000001 = { + 325EAA3700D6B47405CD296C = { + fileEncoding = 30; isa = PBXFileReference; - name = RSA_DSA_utils.h; - path = AppleCSP/RSA_DSA/RSA_DSA_utils.h; - refType = 2; + path = AppleCSPPlugin.cpp; + refType = 4; }; - 256C38B50094B2537F000001 = { - fileRef = 256C38B40094B2537F000001; + 325EAA3800D6B47505CD296C = { + fileRef = 325EAA3700D6B47405CD296C; isa = PBXBuildFile; settings = { }; }; - 256C38B60094B96F7F000001 = { + 32604C2600E3C14405CD296C = { + fileEncoding = 30; isa = PBXFileReference; - name = RSA_DSA_utils.cpp; - path = AppleCSP/RSA_DSA/RSA_DSA_utils.cpp; - refType = 2; + path = devrandom.cpp; + refType = 4; }; - 256C38B70094B96F7F000001 = { - fileRef = 256C38B60094B96F7F000001; + 32604C2700E3C14405CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = devrandom.h; + refType = 4; + }; + 32604C2800E3C14505CD296C = { + fileRef = 32604C2700E3C14405CD296C; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; -//250 -//251 -//252 -//253 -//254 -//280 -//281 -//282 -//283 -//284 - 28B044DF0094C5577F000001 = { - isa = PBXFileReference; - name = RSA_DSA_signature.h; - path = AppleCSP/RSA_DSA/RSA_DSA_signature.h; - refType = 2; - }; - 28B044E00094C5577F000001 = { - fileRef = 28B044DF0094C5577F000001; + 32604C2900E3C14505CD296C = { + fileRef = 32604C2600E3C14405CD296C; isa = PBXBuildFile; settings = { }; }; - 28B044E10094C6C57F000001 = { + 32623CFC024BBA3B05CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = RSA_DSA_signature.cpp; - path = AppleCSP/RSA_DSA/RSA_DSA_signature.cpp; + name = aclclient.cpp; + path = cdsa/cdsa_client/aclclient.cpp; refType = 2; }; - 28B044E20094C6C57F000001 = { - fileRef = 28B044E10094C6C57F000001; + 32623CFD024BBA3B05CA2E77 = { + fileRef = 32623CFC024BBA3B05CA2E77; isa = PBXBuildFile; settings = { }; }; - 28B044E30094DC627F000001 = { + 3264486400D54DD305CD296C = { + fileEncoding = 30; isa = PBXFileReference; - name = RSA_asymmetric.cpp; - path = RSA_DSA/RSA_asymmetric.cpp; + path = multiobserver.h; refType = 4; }; - 28B044E40094DC627F000001 = { + 3264486500D54DD305CD296C = { + fileEncoding = 30; isa = PBXFileReference; - name = RSA_asymmetric.h; - path = RSA_DSA/RSA_asymmetric.h; + path = multiobserver.cpp; refType = 4; }; - 28B044E50094DC627F000001 = { - fileRef = 28B044E40094DC627F000001; + 326618CC01C6844C05CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = acl_protectedpw.cpp; + refType = 4; + }; + 326618CD01C6844C05CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = acl_protectedpw.h; + refType = 4; + }; + 326618CE01C6844D05CA2E77 = { + fileRef = 326618CD01C6844C05CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 28B044E60094DC627F000001 = { - fileRef = 28B044E30094DC627F000001; + 326618CF01C6844D05CA2E77 = { + fileRef = 326618CC01C6844C05CA2E77; isa = PBXBuildFile; settings = { }; }; -//280 -//281 -//282 -//283 -//284 -//2C0 -//2C1 -//2C2 -//2C3 -//2C4 - 2C5247EA007A39B47F000001 = { - children = ( - 9D291872026B4FF900003D05, - 07E4D6D300A0CA617F000001, - 169195D00094A6FD7F000001, - 169195890094A5A87F000001, - 169195880094A5A87F000001, - 1691958A0094A5A87F000001, - 169195840094A5A87F000001, - 169195820094A5A87F000001, - 169195710094A2ED7F000001, - 169195750094A5A87F000001, - 169195730094A5A87F000001, - 169195720094A2ED7F000001, - 169195D10094A6FD7F000001, - 169195E30094A8577F000001, - 169195D20094A6FD7F000001, - 169195D30094A6FD7F000001, - ); - isa = PBXGroup; - path = open_ssl; + 3267644800EBF3A905CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = AuthSession.h; + refType = 4; + }; + 3267644900EBF3AA05CD296C = { + fileRef = 3267644800EBF3A905CD296C; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + 3272260900E3C75605CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = uniformrandom.cpp; + refType = 4; + }; + 3272260A00E3C75605CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = uniformrandom.h; refType = 4; }; - 2C5247EB007A39B47F000001 = { - isa = PBXFileReference; - name = opensslconf.h; - path = openssl/opensslconf.h; - refType = 4; + 3272260B00E3C75605CD296C = { + fileRef = 3272260A00E3C75605CD296C; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 3272260C00E3C75705CD296C = { + fileRef = 3272260900E3C75605CD296C; + isa = PBXBuildFile; + settings = { + }; }; - 2C5247EC007A39B47F000001 = { - isa = PBXFileReference; - name = rc2_cbc.c; - path = misc/rc2_cbc.c; + 3272260D00E3C7FB05CD296C = { + children = ( + 32604C2600E3C14405CD296C, + 32604C2700E3C14405CD296C, + 3272260900E3C75605CD296C, + 3272260A00E3C75605CD296C, + ); + isa = PBXGroup; + name = "Random Numbers"; + path = ""; refType = 4; }; - 2C5247ED007A39B47F000001 = { - isa = PBXFileReference; - name = rc2_locl.h; - path = misc/rc2_locl.h; + 327DDDBD00D6D8E605CD296C = { + children = ( + 3290386E00D6C5FD05CD296C, + 3290386F00D6C5FD05CD296C, + 327DDDDF00D6F8A505CD296C, + 327DDDE000D6F8A505CD296C, + 327DDDE100D6F8A505CD296C, + 327DDDE200D6F8A505CD296C, + ); + isa = PBXGroup; + name = "Module Loading"; refType = 4; }; - 2C5247EE007A39B47F000001 = { + 327DDDDF00D6F8A505CD296C = { + fileEncoding = 30; isa = PBXFileReference; - name = rc2_skey.c; - path = misc/rc2_skey.c; + path = modload_plugin.cpp; refType = 4; }; - 2C5247EF007A39B47F000001 = { + 327DDDE000D6F8A505CD296C = { + fileEncoding = 30; isa = PBXFileReference; - name = rc2.h; - path = openssl/rc2.h; + path = modload_plugin.h; refType = 4; }; - 2C5247F0007A39B47F000001 = { + 327DDDE100D6F8A505CD296C = { + fileEncoding = 30; isa = PBXFileReference; - name = rc2Context.cpp; - path = MiscCSPAlgs/rc2Context.cpp; + path = modload_static.cpp; refType = 4; }; - 2C5247F1007A39B47F000001 = { + 327DDDE200D6F8A505CD296C = { + fileEncoding = 30; isa = PBXFileReference; - name = rc2Context.h; - path = MiscCSPAlgs/rc2Context.h; + path = modload_static.h; refType = 4; }; - 2C5247F2007A39B47F000001 = { - fileRef = 2C5247EB007A39B47F000001; - isa = PBXBuildFile; - settings = { - }; - }; - 2C5247F3007A39B47F000001 = { - fileRef = 2C5247ED007A39B47F000001; + 327DDDE300D6F8A605CD296C = { + fileRef = 327DDDE000D6F8A505CD296C; isa = PBXBuildFile; settings = { }; }; - 2C5247F4007A39B47F000001 = { - fileRef = 2C5247EF007A39B47F000001; + 327DDDE400D6F8A605CD296C = { + fileRef = 327DDDE200D6F8A505CD296C; isa = PBXBuildFile; settings = { }; }; - 2C5247F5007A39B47F000001 = { - fileRef = 2C5247F1007A39B47F000001; + 327DDDE500D6F8A605CD296C = { + fileRef = 327DDDDF00D6F8A505CD296C; isa = PBXBuildFile; settings = { }; }; - 2C5247F6007A39B47F000001 = { - fileRef = 2C5247EC007A39B47F000001; + 327DDDE600D6F8A605CD296C = { + fileRef = 327DDDE100D6F8A505CD296C; isa = PBXBuildFile; settings = { }; }; - 2C5247F7007A39B47F000001 = { - fileRef = 2C5247EE007A39B47F000001; - isa = PBXBuildFile; - settings = { - }; + 327DDDE700D6FC1A05CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleCSPDLPlugin.cpp; + refType = 4; }; - 2C5247F8007A39B47F000001 = { - fileRef = 2C5247F0007A39B47F000001; + 327DDDE800D6FC1B05CD296C = { + fileRef = 327DDDE700D6FC1A05CD296C; isa = PBXBuildFile; settings = { }; }; -//2C0 -//2C1 -//2C2 -//2C3 -//2C4 -//2D0 -//2D1 -//2D2 -//2D3 -//2D4 - 2DFDC7A8FFF3E4ED11CD283A = { - fileRef = 01FA821DFFF2B54C11CD283A; + 327DDDF500D707D805CD296C = { + fileRef = 07A0F68C005DAEE111CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; -//2D0 -//2D1 -//2D2 -//2D3 -//2D4 -//2F0 -//2F1 -//2F2 -//2F3 -//2F4 - 2F4DD9A500A0A0767F000001 = { + 327DDDF600D7DB7505CD296C = { + fileEncoding = 30; isa = PBXFileReference; - path = fdsel.h; + path = powerwatch.cpp; refType = 4; }; - 2F4DD9A600A0A0767F000001 = { + 327DDDF700D7DB7505CD296C = { + fileEncoding = 30; isa = PBXFileReference; - path = fdsel.cpp; + path = powerwatch.h; refType = 4; }; - 2F4DD9A700A0A0767F000001 = { - fileRef = 2F4DD9A500A0A0767F000001; + 327DDDF800D7DB7505CD296C = { + fileRef = 327DDDF700D7DB7505CD296C; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -11839,176 +12262,122 @@ ); }; }; - 2F4DD9A800A0A0767F000001 = { - fileRef = 2F4DD9A600A0A0767F000001; - isa = PBXBuildFile; - settings = { - }; - }; -//2F0 -//2F1 -//2F2 -//2F3 -//2F4 -//310 -//311 -//312 -//313 -//314 - 31200C5CFFF3E57C11CD283A = { - fileRef = 01FA891FFFF2BE3511CD283A; + 327DDDF900D7DB7605CD296C = { + fileRef = 327DDDF600D7DB7505CD296C; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; -//310 -//311 -//312 -//313 -//314 -//320 -//321 -//322 -//323 -//324 - 3206D1FB029996FC05CA2E77 = { - isa = PBXFileReference; - path = TrustItem.cpp; - refType = 4; - }; - 3206D1FC029996FC05CA2E77 = { - isa = PBXFileReference; - path = TrustItem.h; - refType = 4; + 327DDDFA00D7E81F05CD296C = { + isa = PBXFrameworkReference; + name = IOKit.framework; + path = /System/Library/Frameworks/IOKit.framework; + refType = 0; }; - 3206D1FD029996FC05CA2E77 = { - fileRef = 3206D1FB029996FC05CA2E77; + 327DDDFB00D7E81F05CD296C = { + fileRef = 327DDDFA00D7E81F05CD296C; isa = PBXBuildFile; settings = { }; }; - 3206D1FE029996FC05CA2E77 = { - fileRef = 3206D1FC029996FC05CA2E77; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 3283A53602B96AED05CA2E77 = { + isa = PBXTargetDependency; + target = 322C5F3B02B9641F05CA2E77; }; - 320C8FE900EA6AD705CD296C = { - buildRules = ( + 3283A53702B96AF805CA2E77 = { + children = ( + 3283A53802B96B2A05CA2E77, + 3283A53902B96B2A05CA2E77, ); - buildSettings = { - COPY_PHASE_STRIP = NO; - OTHER_CFLAGS = "\U0001-Wall -W -Winline -Wundef -Wno-unused -Wcast-qual -Wcast-align -Wmissing-noreturn"; - }; - isa = PBXBuildStyle; - name = "Lint Screen"; - }; - 320F609D0234113505CA2E77 = { - isa = PBXFileReference; - path = cssmcert.cpp; + isa = PBXGroup; + path = keychains; refType = 4; }; - 320F609E0234113505CA2E77 = { + 3283A53802B96B2A05CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = cssmcert.h; - refType = 4; - }; - 320F609F0234113505CA2E77 = { - fileRef = 320F609D0234113505CA2E77; - isa = PBXBuildFile; - settings = { - }; - }; - 320F60A00234113505CA2E77 = { - fileRef = 320F609E0234113505CA2E77; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; - }; - 322C5F3B02B9641F05CA2E77 = { - buildArgumentsString = "-f $(SRCROOT)/keychains/Makefile $ACTION"; - buildPhases = ( - ); - buildSettings = { - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = "System Keychains"; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - buildToolPath = /usr/bin/gnumake; - buildWorkingDirectory = ""; - dependencies = ( - ); - isa = PBXLegacyTarget; - name = "System Keychains"; - productName = "System Keychains"; - settingsToExpand = 6; - settingsToPassInEnvironment = 287; - settingsToPassOnCommandLine = 280; - shouldUseHeadermap = 0; + path = Makefile; + refType = 4; }; - 32361EEC01EB8FCF05CA2E77 = { + 3283A53902B96B2A05CA2E77 = { isa = PBXFileReference; - path = notifications.h; + path = X509Anchors; refType = 4; }; - 32361EED01EB8FCF05CA2E77 = { + 32867BA70231611A05CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = notifications.cpp; + path = tpclient.cpp; refType = 4; }; - 32361EEE01EB8FD005CA2E77 = { - fileRef = 32361EEC01EB8FCF05CA2E77; + 32867BA80231611A05CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = tpclient.h; + refType = 4; + }; + 32867BA90231611A05CA2E77 = { + fileRef = 32867BA70231611A05CA2E77; isa = PBXBuildFile; settings = { }; }; - 32361EEF01EB8FD005CA2E77 = { - fileRef = 32361EED01EB8FCF05CA2E77; + 32867BAA0231611A05CA2E77 = { + fileRef = 32867BA80231611A05CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 32361F0701F4B28E05CA2E77 = { + 32867BAB02316C3905CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = ucspNotify.defs; + path = clclient.cpp; refType = 4; }; - 32361F0A01F4B39505CA2E77 = { - fileRef = 01FA823CFFF2B54C11CD283A; + 32867BAC02316C3905CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = clclient.h; + refType = 4; + }; + 32867BAD02316C3905CA2E77 = { + fileRef = 32867BAB02316C3905CA2E77; isa = PBXBuildFile; settings = { }; }; - 324414870236DD1505CA2E77 = { + 32867BAE02316C3905CA2E77 = { + fileRef = 32867BAC02316C3905CA2E77; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 32867BB202316E3305CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = cfutilities.cpp; + path = cssmtrust.cpp; refType = 4; }; - 324414880236DD1505CA2E77 = { + 32867BB302316E3305CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = cfutilities.h; + path = cssmtrust.h; refType = 4; }; - 324414890236DD1505CA2E77 = { - fileRef = 324414870236DD1505CA2E77; + 32867BB402316E3305CA2E77 = { + fileRef = 32867BB202316E3305CA2E77; isa = PBXBuildFile; settings = { }; }; - 3244148A0236DD1505CA2E77 = { - fileRef = 324414880236DD1505CA2E77; + 32867BB502316E3305CA2E77 = { + fileRef = 32867BB302316E3305CA2E77; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -12016,116 +12385,362 @@ ); }; }; - 3244148B0236DD2705CA2E77 = { - children = ( - 324414880236DD1505CA2E77, - 324414870236DD1505CA2E77, + 3290381400D6B78A05CD296C = { + fileRef = 1BA451B10097605B7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 3290381500D6BA5905CD296C = { + isa = PBXBundleReference; + path = AppleDL.bundle; + refType = 3; + }; + 3290381600D6BA5905CD296C = { + isa = PBXBundleReference; + path = AppleCSPDL.bundle; + refType = 3; + }; + 3290381700D6BA5905CD296C = { + isa = PBXBundleReference; + path = AppleX509CL.bundle; + refType = 3; + }; + 3290381800D6BA5905CD296C = { + isa = PBXBundleReference; + path = AppleX509TP.bundle; + refType = 3; + }; + 3290381900D6BA5905CD296C = { + buildPhases = ( + 3290381A00D6BA5905CD296C, + 3290381B00D6BA5905CD296C, + 3290381C00D6BA5905CD296C, + 3290381D00D6BA5905CD296C, + 3290382100D6BA5905CD296C, ); - isa = PBXGroup; - name = CF; - refType = 4; + buildSettings = { + CURRENT_PROJECT_VERSION = 163; + LIBRARY_SEARCH_PATHS = ""; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = "-bundle -undefined error"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = AppleDL; + SECTORDER_FLAGS = ""; + VERSIONING_SYSTEM = "apple-generic"; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = bundle; + }; + dependencies = ( + 3290383B00D6BB3705CD296C, + ); + isa = PBXBundleTarget; + name = "AppleDL Plugin"; + productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; + productName = "AppleDL Plugin"; + productReference = 3290381500D6BA5905CD296C; + productSettingsXML = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + AppleDL + CFBundleGetInfoString + + CFBundleIconFile + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + + CFBundlePackageType + BNDL + CFBundleShortVersionString + 2.0 + CFBundleSignature + ???? + CFBundleVersion + 163 + + +"; }; - 3244148C023837A505CA2E77 = { - isa = PBXFileReference; - path = TrustStore.cpp; - refType = 4; + 3290381A00D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 3244148D023837A505CA2E77 = { - isa = PBXFileReference; - path = TrustStore.h; - refType = 4; + 3290381B00D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 3244148E023837A505CA2E77 = { - fileRef = 3244148C023837A505CA2E77; + 3290381C00D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + 3290383C00D6BB3705CD296C, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 3290381D00D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + 3290381E00D6BA5905CD296C, + 3290382000D6BA5905CD296C, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 3290381E00D6BA5905CD296C = { + fileRef = 1BA451B10097605B7F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 3290382000D6BA5905CD296C = { + fileRef = 014880C8005EAE4D11CD283A; isa = PBXBuildFile; settings = { }; }; - 3244148F023837A505CA2E77 = { - fileRef = 3244148D023837A505CA2E77; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 3290382100D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 3290382200D6BA5905CD296C = { + buildPhases = ( + 3290382300D6BA5905CD296C, + 3290382400D6BA5905CD296C, + 3290382500D6BA5905CD296C, + 3290382600D6BA5905CD296C, + 3290382700D6BA5905CD296C, + ); + buildSettings = { + CURRENT_PROJECT_VERSION = 163; + LIBRARY_SEARCH_PATHS = ""; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = "-bundle -undefined error"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = AppleCSPDL; + SECTORDER_FLAGS = ""; + VERSIONING_SYSTEM = "apple-generic"; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = bundle; + }; + dependencies = ( + 3290383E00D6BB3705CD296C, + ); + isa = PBXBundleTarget; + name = "AppleCSPDL Plugin"; + productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; + productName = "AppleCSPDL Plugin"; + productReference = 3290381600D6BA5905CD296C; + productSettingsXML = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + AppleCSPDL + CFBundleGetInfoString + + CFBundleIconFile + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + + CFBundlePackageType + BNDL + CFBundleShortVersionString + 2.0 + CFBundleSignature + ???? + CFBundleVersion + 163 + + +"; + }; + 3290382300D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 3253C16401C7D8A005CA2E77 = { - isa = PBXFileReference; - path = entropy.h; - refType = 4; + 3290382400D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 3253C16501C7D8A005CA2E77 = { - isa = PBXFileReference; - path = entropy.cpp; - refType = 4; + 3290382500D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + 327DDDE800D6FC1B05CD296C, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 3253C16601C7D8A105CA2E77 = { - fileRef = 3253C16401C7D8A005CA2E77; - isa = PBXBuildFile; - settings = { - }; + 3290382600D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + 3290384000D6BB3705CD296C, + 3290384100D6BB3705CD296C, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 3253C16701C7D8A105CA2E77 = { - fileRef = 3253C16501C7D8A005CA2E77; - isa = PBXBuildFile; - settings = { + 3290382700D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 3290382800D6BA5905CD296C = { + buildPhases = ( + 3290382900D6BA5905CD296C, + 3290382A00D6BA5905CD296C, + 3290382B00D6BA5905CD296C, + 3290382C00D6BA5905CD296C, + 3290382D00D6BA5905CD296C, + ); + buildSettings = { + CURRENT_PROJECT_VERSION = 163; + LIBRARY_SEARCH_PATHS = ""; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = "-bundle -undefined error"; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = AppleX509CL; + SECTORDER_FLAGS = ""; + VERSIONING_SYSTEM = "apple-generic"; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = bundle; }; + dependencies = ( + 3290384400D6BB3705CD296C, + ); + isa = PBXBundleTarget; + name = "AppleX509CL Plugin"; + productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; + productName = "AppleX509CL Plugin"; + productReference = 3290381700D6BA5905CD296C; + productSettingsXML = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + AppleX509CL + CFBundleGetInfoString + + CFBundleIconFile + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + + CFBundlePackageType + BNDL + CFBundleShortVersionString + 2.0 + CFBundleSignature + ???? + CFBundleVersion + 163 + + +"; }; - 32554D7901F4C97305CA2E77 = { - isa = PBXFileReference; - path = ucspNotifySender.cpp; - refType = 4; + 3290382900D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 32554D7A01F4C97305CA2E77 = { - isa = PBXFileReference; - path = ucspNotify.h; - refType = 4; + 3290382A00D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 32554D7B01F4C97305CA2E77 = { - fileRef = 32554D7A01F4C97305CA2E77; - isa = PBXBuildFile; - settings = { - }; + 3290382B00D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + 3290384500D6BB3705CD296C, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 32554D7C01F4C97405CA2E77 = { - fileRef = 32554D7901F4C97305CA2E77; - isa = PBXBuildFile; - settings = { - }; + 3290382C00D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + 3290384600D6BB3705CD296C, + 3290384700D6BB3705CD296C, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 325EAA2100D6B08805CD296C = { - isa = PBXBundleReference; - path = AppleCSP.bundle; - refType = 3; + 3290382D00D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 325EAA2200D6B08805CD296C = { + 3290382E00D6BA5905CD296C = { buildPhases = ( - 325EAA2400D6B08805CD296C, - 325EAA2500D6B08805CD296C, - 325EAA2600D6B08805CD296C, - 325EAA2700D6B08805CD296C, - 325EAA2800D6B08805CD296C, + 3290382F00D6BA5905CD296C, + 3290383000D6BA5905CD296C, + 3290383100D6BA5905CD296C, + 3290383200D6BA5905CD296C, + 3290383300D6BA5905CD296C, ); buildSettings = { - CURRENT_PROJECT_VERSION = 54.1.9; + CURRENT_PROJECT_VERSION = 163; LIBRARY_SEARCH_PATHS = ""; OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_CFLAGS = ""; OTHER_LDFLAGS = "-bundle -undefined error"; OTHER_REZFLAGS = ""; - PRODUCT_NAME = AppleCSP; + PRODUCT_NAME = AppleX509TP; SECTORDER_FLAGS = ""; + VERSIONING_SYSTEM = "apple-generic"; WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; WRAPPER_EXTENSION = bundle; }; dependencies = ( - 325EAA2300D6B08805CD296C, + 3290384A00D6BB3705CD296C, ); isa = PBXBundleTarget; - name = "AppleCSP Plugin"; - productName = "AppleCSP Plugin"; - productReference = 325EAA2100D6B08805CD296C; + name = "AppleX509TP Plugin"; + productName = "AppleX509TP Plugin"; + productReference = 3290381800D6BA5905CD296C; productSettingsXML = " @@ -12133,7 +12748,7 @@ CFBundleDevelopmentRegion English CFBundleExecutable - AppleCSP + AppleX509TP CFBundleGetInfoString CFBundleIconFile @@ -12147,212 +12762,245 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.1.6 + 2.0 CFBundleSignature ???? CFBundleVersion - 54.1.9 + 163 "; - shouldUseHeadermap = 0; - }; - 325EAA2300D6B08805CD296C = { - isa = PBXTargetDependency; - target = 014880CD005EAE4D11CD283A; }; - 325EAA2400D6B08805CD296C = { + 3290382F00D6BA5905CD296C = { buildActionMask = 2147483647; files = ( ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 325EAA2500D6B08805CD296C = { + 3290383000D6BA5905CD296C = { buildActionMask = 2147483647; files = ( + 9D103F9F01AC72C200003D05, + 9D103FA001AC72C200003D05, ); isa = PBXResourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 325EAA2600D6B08805CD296C = { + 3290383100D6BA5905CD296C = { buildActionMask = 2147483647; files = ( - 325EAA3800D6B47505CD296C, + 3290384B00D6BB3705CD296C, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 325EAA2700D6B08805CD296C = { + 3290383200D6BA5905CD296C = { buildActionMask = 2147483647; files = ( - 325EAA3300D6B2BF05CD296C, - 325EAA3400D6B2BF05CD296C, - 325EAA3500D6B2BF05CD296C, - 3290381400D6B78A05CD296C, + 3290384C00D6BB3705CD296C, + 3290384D00D6BB3705CD296C, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 3290383300D6BA5905CD296C = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 3290383500D6BB3705CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleDLPlugin.cpp; + refType = 4; + }; + 3290383600D6BB3705CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleX509CLPlugin.cpp; + refType = 4; + }; + 3290383700D6BB3705CD296C = { + fileEncoding = 30; + isa = PBXFileReference; + path = AppleX509TPPlugin.cpp; + refType = 4; + }; + 3290383800D6BB3705CD296C = { + buildPhases = ( + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = "Plugin Bundles"; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + 3290383900D6BB3705CD296C, + 3290383A00D6BB3705CD296C, + 3290383D00D6BB3705CD296C, + 3290384300D6BB3705CD296C, + 3290384900D6BB3705CD296C, ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + isa = PBXAggregateTarget; + name = "Plugin Bundles"; + productName = "Plugin Bundles"; }; - 325EAA2800D6B08805CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 3290383900D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 325EAA2200D6B08805CD296C; }; - 325EAA2900D6B23F05CD296C = { - children = ( - 0149036600A9E34D7F000001, - 0149036700A9E34D7F000001, - ); - isa = PBXGroup; - name = "From BSafe"; - refType = 4; + 3290383A00D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 3290381900D6BA5905CD296C; }; - 325EAA2A00D6B24005CD296C = { - fileRef = 014880C7005EAE4D11CD283A; - isa = PBXBuildFile; - settings = { - }; + 3290383B00D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 014880DA005EAE4D11CD283A; }; - 325EAA2B00D6B24005CD296C = { - fileRef = 014880C8005EAE4D11CD283A; + 3290383C00D6BB3705CD296C = { + fileRef = 3290383500D6BB3705CD296C; isa = PBXBuildFile; settings = { }; }; - 325EAA2C00D6B24005CD296C = { - fileRef = 014880C9005EAE4D11CD283A; - isa = PBXBuildFile; - settings = { - }; + 3290383D00D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 3290382200D6BA5905CD296C; }; - 325EAA2D00D6B24005CD296C = { - fileRef = 014880CA005EAE4D11CD283A; + 3290383E00D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 014880D4005EAE4D11CD283A; + }; + 3290384000D6BB3705CD296C = { + fileRef = 014880C9005EAE4D11CD283A; isa = PBXBuildFile; settings = { }; }; - 325EAA2E00D6B24005CD296C = { - fileRef = 014880CB005EAE4D11CD283A; + 3290384100D6BB3705CD296C = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 325EAA3100D6B2BE05CD296C = { - children = ( - 014880C7005EAE4D11CD283A, - 014880C8005EAE4D11CD283A, - 014880C9005EAE4D11CD283A, - 014880CA005EAE4D11CD283A, - 014880CB005EAE4D11CD283A, - ); - isa = PBXGroup; - name = "Plugins as Libraries"; - path = ""; - refType = 4; + 3290384300D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 3290382800D6BA5905CD296C; }; - 325EAA3200D6B2BE05CD296C = { - children = ( - 325EAA2100D6B08805CD296C, - 3290381500D6BA5905CD296C, - 3290381600D6BA5905CD296C, - 3290381700D6BA5905CD296C, - 3290381800D6BA5905CD296C, - ); - isa = PBXGroup; - name = "Plugins Proper"; - refType = 4; + 3290384400D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 014880E0005EAE4D11CD283A; }; - 325EAA3300D6B2BF05CD296C = { - fileRef = 014880C7005EAE4D11CD283A; + 3290384500D6BB3705CD296C = { + fileRef = 3290383600D6BB3705CD296C; isa = PBXBuildFile; settings = { }; }; - 325EAA3400D6B2BF05CD296C = { - fileRef = 0149036600A9E34D7F000001; + 3290384600D6BB3705CD296C = { + fileRef = 014880CA005EAE4D11CD283A; isa = PBXBuildFile; settings = { }; }; - 325EAA3500D6B2BF05CD296C = { - fileRef = 0149036700A9E34D7F000001; + 3290384700D6BB3705CD296C = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 325EAA3700D6B47405CD296C = { - isa = PBXFileReference; - path = AppleCSPPlugin.cpp; - refType = 4; + 3290384900D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 3290382E00D6BA5905CD296C; }; - 325EAA3800D6B47505CD296C = { - fileRef = 325EAA3700D6B47405CD296C; + 3290384A00D6BB3705CD296C = { + isa = PBXTargetDependency; + target = 014880E6005EAE4D11CD283A; + }; + 3290384B00D6BB3705CD296C = { + fileRef = 3290383700D6BB3705CD296C; isa = PBXBuildFile; settings = { }; }; - 32604C2600E3C14405CD296C = { - isa = PBXFileReference; - path = devrandom.cpp; - refType = 4; - }; - 32604C2700E3C14405CD296C = { - isa = PBXFileReference; - path = devrandom.h; - refType = 4; - }; - 32604C2800E3C14505CD296C = { - fileRef = 32604C2700E3C14405CD296C; + 3290384C00D6BB3705CD296C = { + fileRef = 014880CB005EAE4D11CD283A; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 32604C2900E3C14505CD296C = { - fileRef = 32604C2600E3C14405CD296C; + 3290384D00D6BB3705CD296C = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 32623CFC024BBA3B05CA2E77 = { - isa = PBXFileReference; - name = aclclient.cpp; - path = cdsa/cdsa_client/aclclient.cpp; - refType = 2; + 3290384F00D6BB7805CD296C = { + isa = PBXTargetDependency; + target = 3290385000D6BB7805CD296C; }; - 32623CFD024BBA3B05CA2E77 = { - fileRef = 32623CFC024BBA3B05CA2E77; - isa = PBXBuildFile; - settings = { + 3290385000D6BB7805CD296C = { + buildPhases = ( + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = "Built-in Plugin Code"; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; + dependencies = ( + 3290385100D6BB7805CD296C, + 3290385200D6BB7805CD296C, + 3290385300D6BB7805CD296C, + 3290385400D6BB7805CD296C, + 3290385500D6BB7805CD296C, + ); + isa = PBXAggregateTarget; + name = "Built-in Plugin Code"; + productName = "Built-in Plugin Code"; }; - 3264486400D54DD305CD296C = { - isa = PBXFileReference; - path = multiobserver.h; - refType = 4; + 3290385100D6BB7805CD296C = { + isa = PBXTargetDependency; + target = 014880CD005EAE4D11CD283A; }; - 3264486500D54DD305CD296C = { - isa = PBXFileReference; - path = multiobserver.cpp; - refType = 4; + 3290385200D6BB7805CD296C = { + isa = PBXTargetDependency; + target = 014880D4005EAE4D11CD283A; }; - 326618CC01C6844C05CA2E77 = { + 3290385300D6BB7805CD296C = { + isa = PBXTargetDependency; + target = 014880DA005EAE4D11CD283A; + }; + 3290385400D6BB7805CD296C = { + isa = PBXTargetDependency; + target = 014880E0005EAE4D11CD283A; + }; + 3290385500D6BB7805CD296C = { + isa = PBXTargetDependency; + target = 014880E6005EAE4D11CD283A; + }; + 3290386E00D6C5FD05CD296C = { + fileEncoding = 30; isa = PBXFileReference; - path = acl_protectedpw.cpp; + path = modloader.cpp; refType = 4; }; - 326618CD01C6844C05CA2E77 = { + 3290386F00D6C5FD05CD296C = { + fileEncoding = 30; isa = PBXFileReference; - path = acl_protectedpw.h; + path = modloader.h; refType = 4; }; - 326618CE01C6844D05CA2E77 = { - fileRef = 326618CD01C6844C05CA2E77; + 3290387000D6C5FE05CD296C = { + fileRef = 3290386F00D6C5FD05CD296C; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -12360,38 +13008,94 @@ ); }; }; - 326618CF01C6844D05CA2E77 = { - fileRef = 326618CC01C6844C05CA2E77; + 3290387100D6C5FE05CD296C = { + fileRef = 3290386E00D6C5FD05CD296C; isa = PBXBuildFile; settings = { }; }; - 3267644800EBF3A905CD296C = { - isa = PBXFileReference; - path = AuthSession.h; +//320 +//321 +//322 +//323 +//324 +//330 +//331 +//332 +//333 +//334 + 338005E1FFF3E69711CD283A = { + fileRef = 01FA821BFFF2B54C11CD283A; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 33BD041F00838F447F000001 = { + children = ( + 017B6CA6009748107F000001, + 017B6CA7009748107F000001, + 33BD0434008390257F000001, + 33BD0435008390257F000001, + 33BD0436008390257F000001, + 33BD0437008390257F000001, + C2AE35290469781800CA2E77, + C2AE352A0469781800CA2E77, + 33BD0462008391C07F000001, + 33BD0463008391C07F000001, + 33BD045E008390B17F000001, + 33BD045F008390B17F000001, + 33BD0438008390257F000001, + 33BD0439008390257F000001, + 33BD043A008390257F000001, + 33BD043B008390257F000001, + 33BD043C008390257F000001, + 33BD043D008390257F000001, + 2F4DD9A600A0A0767F000001, + 2F4DD9A500A0A0767F000001, + 33BD043E008390257F000001, + 33BD043F008390257F000001, + 33BD0440008390257F000001, + 33BD0441008390257F000001, + 33BD0442008390257F000001, + 33BD0443008390257F000001, + 33BD0444008390257F000001, + 33BD0445008390257F000001, + 33BD0446008390257F000001, + 33BD0447008390257F000001, + C2908496042BC01100CA2E77, + C2908497042BC01100CA2E77, + 33BD042500838F5A7F000001, + ); + isa = PBXGroup; + name = UNIX; refType = 4; }; - 3267644900EBF3AA05CD296C = { - fileRef = 3267644800EBF3A905CD296C; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 33BD042000838F447F000001 = { + children = ( + 33BD042100838F447F000001, + 33BD042200838F447F000001, + ); + isa = PBXGroup; + name = "C++ Interface"; + refType = 4; }; - 3272260900E3C75605CD296C = { + 33BD042100838F447F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = uniformrandom.cpp; + path = "securetransport++.cpp"; refType = 4; }; - 3272260A00E3C75605CD296C = { + 33BD042200838F447F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = uniformrandom.h; + path = "securetransport++.h"; refType = 4; }; - 3272260B00E3C75605CD296C = { - fileRef = 3272260A00E3C75605CD296C; + 33BD042300838F447F000001 = { + fileRef = 33BD042200838F447F000001; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -12399,176 +13103,237 @@ ); }; }; - 3272260C00E3C75705CD296C = { - fileRef = 3272260900E3C75605CD296C; + 33BD042400838F447F000001 = { + fileRef = 33BD042100838F447F000001; isa = PBXBuildFile; settings = { }; }; - 3272260D00E3C7FB05CD296C = { + 33BD042500838F5A7F000001 = { children = ( - 32604C2600E3C14405CD296C, - 32604C2700E3C14405CD296C, - 3272260900E3C75605CD296C, - 3272260A00E3C75605CD296C, + 33BD042600838FB17F000001, + 33BD042700838FB17F000001, + 33BD042800838FB17F000001, + 33BD042900838FB17F000001, + 33BD042A00838FB17F000001, + 33BD042B00838FB17F000001, ); isa = PBXGroup; - name = "Random Numbers"; - path = ""; + name = Socks; refType = 4; }; - 327DDDBD00D6D8E605CD296C = { - children = ( - 3290386E00D6C5FD05CD296C, - 3290386F00D6C5FD05CD296C, - 327DDDDF00D6F8A505CD296C, - 327DDDE000D6F8A505CD296C, - 327DDDE100D6F8A505CD296C, - 327DDDE200D6F8A505CD296C, - ); - isa = PBXGroup; - name = "Module Loading"; + 33BD042600838FB17F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "socks++.cpp"; refType = 4; }; - 327DDDDF00D6F8A505CD296C = { + 33BD042700838FB17F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = modload_plugin.cpp; + path = "socks++.h"; refType = 4; }; - 327DDDE000D6F8A505CD296C = { + 33BD042800838FB17F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = modload_plugin.h; + path = "socks++4.cpp"; refType = 4; }; - 327DDDE100D6F8A505CD296C = { + 33BD042900838FB17F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = modload_static.cpp; + path = "socks++4.h"; refType = 4; }; - 327DDDE200D6F8A505CD296C = { + 33BD042A00838FB17F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = modload_static.h; + path = "socks++5.cpp"; refType = 4; }; - 327DDDE300D6F8A605CD296C = { - fileRef = 327DDDE000D6F8A505CD296C; + 33BD042B00838FB17F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "socks++5.h"; + refType = 4; + }; + 33BD042C00838FB17F000001 = { + fileRef = 33BD042700838FB17F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 327DDDE400D6F8A605CD296C = { - fileRef = 327DDDE200D6F8A505CD296C; + 33BD042D00838FB17F000001 = { + fileRef = 33BD042900838FB17F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 327DDDE500D6F8A605CD296C = { - fileRef = 327DDDDF00D6F8A505CD296C; + 33BD042E00838FB17F000001 = { + fileRef = 33BD042B00838FB17F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 327DDDE600D6F8A605CD296C = { - fileRef = 327DDDE100D6F8A505CD296C; + 33BD042F00838FB17F000001 = { + fileRef = 33BD042600838FB17F000001; isa = PBXBuildFile; settings = { }; }; - 327DDDE700D6FC1A05CD296C = { - isa = PBXFileReference; - path = AppleCSPDLPlugin.cpp; - refType = 4; - }; - 327DDDE800D6FC1B05CD296C = { - fileRef = 327DDDE700D6FC1A05CD296C; + 33BD043000838FB17F000001 = { + fileRef = 33BD042800838FB17F000001; isa = PBXBuildFile; settings = { }; }; - 327DDDF500D707D805CD296C = { - fileRef = 07A0F68C005DAEE111CD283A; + 33BD043100838FB17F000001 = { + fileRef = 33BD042A00838FB17F000001; isa = PBXBuildFile; settings = { }; }; - 327DDDF600D7DB7505CD296C = { + 33BD0434008390257F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = powerwatch.cpp; + path = bufferfifo.cpp; refType = 4; }; - 327DDDF700D7DB7505CD296C = { + 33BD0435008390257F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = powerwatch.h; + path = bufferfifo.h; refType = 4; }; - 327DDDF800D7DB7505CD296C = { - fileRef = 327DDDF700D7DB7505CD296C; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 33BD0436008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = constdata.cpp; + refType = 4; }; - 327DDDF900D7DB7605CD296C = { - fileRef = 327DDDF600D7DB7505CD296C; - isa = PBXBuildFile; - settings = { - }; + 33BD0437008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = constdata.h; + refType = 4; }; - 327DDDFA00D7E81F05CD296C = { - isa = PBXFrameworkReference; - name = IOKit.framework; - path = /System/Library/Frameworks/IOKit.framework; - refType = 0; + 33BD0438008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = inetreply.cpp; + refType = 4; }; - 327DDDFB00D7E81F05CD296C = { - fileRef = 327DDDFA00D7E81F05CD296C; - isa = PBXBuildFile; - settings = { - }; + 33BD0439008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = inetreply.h; + refType = 4; }; - 3283A53602B96AED05CA2E77 = { - isa = PBXTargetDependency; - target = 322C5F3B02B9641F05CA2E77; + 33BD043A008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "ip++.cpp"; + refType = 4; }; - 3283A53702B96AF805CA2E77 = { - children = ( - 3283A53802B96B2A05CA2E77, - 3283A53902B96B2A05CA2E77, - ); - isa = PBXGroup; - path = keychains; + 33BD043B008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "ip++.h"; refType = 4; }; - 3283A53802B96B2A05CA2E77 = { + 33BD043C008390257F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = Makefile; + path = selector.cpp; refType = 4; }; - 3283A53902B96B2A05CA2E77 = { + 33BD043D008390257F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = X509Anchors; + path = selector.h; refType = 4; }; - 32867BA70231611A05CA2E77 = { + 33BD043E008390257F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = tpclient.cpp; + path = streams.cpp; refType = 4; }; - 32867BA80231611A05CA2E77 = { + 33BD043F008390257F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = tpclient.h; + path = streams.h; refType = 4; }; - 32867BA90231611A05CA2E77 = { - fileRef = 32867BA70231611A05CA2E77; + 33BD0440008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = timeflow.cpp; + refType = 4; + }; + 33BD0441008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = timeflow.h; + refType = 4; + }; + 33BD0442008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = typedvalue.cpp; + refType = 4; + }; + 33BD0443008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = typedvalue.h; + refType = 4; + }; + 33BD0444008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "unix++.cpp"; + refType = 4; + }; + 33BD0445008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "unix++.h"; + refType = 4; + }; + 33BD0446008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = url.cpp; + refType = 4; + }; + 33BD0447008390257F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = url.h; + refType = 4; + }; + 33BD0449008390257F000001 = { + fileRef = 33BD0435008390257F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 32867BAA0231611A05CA2E77 = { - fileRef = 32867BA80231611A05CA2E77; + 33BD044A008390257F000001 = { + fileRef = 33BD0437008390257F000001; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -12576,24 +13341,17 @@ ); }; }; - 32867BAB02316C3905CA2E77 = { - isa = PBXFileReference; - path = clclient.cpp; - refType = 4; - }; - 32867BAC02316C3905CA2E77 = { - isa = PBXFileReference; - path = clclient.h; - refType = 4; - }; - 32867BAD02316C3905CA2E77 = { - fileRef = 32867BAB02316C3905CA2E77; + 33BD044B008390257F000001 = { + fileRef = 33BD0439008390257F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 32867BAE02316C3905CA2E77 = { - fileRef = 32867BAC02316C3905CA2E77; + 33BD044C008390257F000001 = { + fileRef = 33BD043B008390257F000001; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -12601,24 +13359,17 @@ ); }; }; - 32867BB202316E3305CA2E77 = { - isa = PBXFileReference; - path = cssmtrust.cpp; - refType = 4; - }; - 32867BB302316E3305CA2E77 = { - isa = PBXFileReference; - path = cssmtrust.h; - refType = 4; - }; - 32867BB402316E3305CA2E77 = { - fileRef = 32867BB202316E3305CA2E77; + 33BD044D008390257F000001 = { + fileRef = 33BD043D008390257F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 32867BB502316E3305CA2E77 = { - fileRef = 32867BB302316E3305CA2E77; + 33BD044E008390257F000001 = { + fileRef = 33BD043F008390257F000001; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -12626,619 +13377,522 @@ ); }; }; - 3290381400D6B78A05CD296C = { - fileRef = 1BA451B10097605B7F000001; + 33BD044F008390257F000001 = { + fileRef = 33BD0441008390257F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 3290381500D6BA5905CD296C = { - isa = PBXBundleReference; - path = AppleDL.bundle; - refType = 3; - }; - 3290381600D6BA5905CD296C = { - isa = PBXBundleReference; - path = AppleCSPDL.bundle; - refType = 3; - }; - 3290381700D6BA5905CD296C = { - isa = PBXBundleReference; - path = AppleX509CL.bundle; - refType = 3; - }; - 3290381800D6BA5905CD296C = { - isa = PBXBundleReference; - path = AppleX509TP.bundle; - refType = 3; - }; - 3290381900D6BA5905CD296C = { - buildPhases = ( - 3290381A00D6BA5905CD296C, - 3290381B00D6BA5905CD296C, - 3290381C00D6BA5905CD296C, - 3290381D00D6BA5905CD296C, - 3290382100D6BA5905CD296C, - ); - buildSettings = { - CURRENT_PROJECT_VERSION = 54.1.9; - LIBRARY_SEARCH_PATHS = ""; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = "-bundle -undefined error"; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = AppleDL; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - WRAPPER_EXTENSION = bundle; + 33BD0450008390257F000001 = { + fileRef = 33BD0443008390257F000001; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); }; - dependencies = ( - 3290383B00D6BB3705CD296C, - ); - isa = PBXBundleTarget; - name = "AppleDL Plugin"; - productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; - productName = "AppleDL Plugin"; - productReference = 3290381500D6BA5905CD296C; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - AppleDL - CFBundleGetInfoString - - CFBundleIconFile - - CFBundleIdentifier - - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.1.6 - CFBundleSignature - ???? - CFBundleVersion - 54.1.9 - - -"; - shouldUseHeadermap = 0; - }; - 3290381A00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 3290381B00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 3290381C00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 3290383C00D6BB3705CD296C, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; }; - 3290381D00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 3290381E00D6BA5905CD296C, - 3290382000D6BA5905CD296C, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD0451008390257F000001 = { + fileRef = 33BD0445008390257F000001; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 3290381E00D6BA5905CD296C = { - fileRef = 1BA451B10097605B7F000001; + 33BD0452008390257F000001 = { + fileRef = 33BD0447008390257F000001; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 3290382000D6BA5905CD296C = { - fileRef = 014880C8005EAE4D11CD283A; + 33BD0454008390257F000001 = { + fileRef = 33BD0434008390257F000001; isa = PBXBuildFile; settings = { }; }; - 3290382100D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD0455008390257F000001 = { + fileRef = 33BD0436008390257F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290382200D6BA5905CD296C = { - buildPhases = ( - 3290382300D6BA5905CD296C, - 3290382400D6BA5905CD296C, - 3290382500D6BA5905CD296C, - 3290382600D6BA5905CD296C, - 3290382700D6BA5905CD296C, - ); - buildSettings = { - CURRENT_PROJECT_VERSION = 54.1.9; - LIBRARY_SEARCH_PATHS = ""; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = "-bundle -undefined error"; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = AppleCSPDL; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - WRAPPER_EXTENSION = bundle; + 33BD0456008390257F000001 = { + fileRef = 33BD0438008390257F000001; + isa = PBXBuildFile; + settings = { + }; + }; + 33BD0457008390257F000001 = { + fileRef = 33BD043A008390257F000001; + isa = PBXBuildFile; + settings = { }; - dependencies = ( - 3290383E00D6BB3705CD296C, - ); - isa = PBXBundleTarget; - name = "AppleCSPDL Plugin"; - productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; - productName = "AppleCSPDL Plugin"; - productReference = 3290381600D6BA5905CD296C; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - AppleCSPDL - CFBundleGetInfoString - - CFBundleIconFile - - CFBundleIdentifier - - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.1.6 - CFBundleSignature - ???? - CFBundleVersion - 54.1.9 - - -"; - shouldUseHeadermap = 0; }; - 3290382300D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD0458008390257F000001 = { + fileRef = 33BD043C008390257F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290382400D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD0459008390257F000001 = { + fileRef = 33BD043E008390257F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290382500D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 327DDDE800D6FC1B05CD296C, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD045A008390257F000001 = { + fileRef = 33BD0440008390257F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290382600D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 3290384000D6BB3705CD296C, - 3290384100D6BB3705CD296C, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD045B008390257F000001 = { + fileRef = 33BD0442008390257F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290382700D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD045C008390257F000001 = { + fileRef = 33BD0444008390257F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290382800D6BA5905CD296C = { - buildPhases = ( - 3290382900D6BA5905CD296C, - 3290382A00D6BA5905CD296C, - 3290382B00D6BA5905CD296C, - 3290382C00D6BA5905CD296C, - 3290382D00D6BA5905CD296C, - ); - buildSettings = { - CURRENT_PROJECT_VERSION = 54.1.9; - LIBRARY_SEARCH_PATHS = ""; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = "-bundle -undefined error"; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = AppleX509CL; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - WRAPPER_EXTENSION = bundle; + 33BD045D008390257F000001 = { + fileRef = 33BD0446008390257F000001; + isa = PBXBuildFile; + settings = { }; - dependencies = ( - 3290384400D6BB3705CD296C, - ); - isa = PBXBundleTarget; - name = "AppleX509CL Plugin"; - productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; - productName = "AppleX509CL Plugin"; - productReference = 3290381700D6BA5905CD296C; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - AppleX509CL - CFBundleGetInfoString - - CFBundleIconFile - - CFBundleIdentifier - - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.1.6 - CFBundleSignature - ???? - CFBundleVersion - 54.1.9 - - -"; - shouldUseHeadermap = 0; }; - 3290382900D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD045E008390B17F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = hosts.cpp; + refType = 4; }; - 3290382A00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD045F008390B17F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = hosts.h; + refType = 4; }; - 3290382B00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 3290384500D6BB3705CD296C, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD0460008390B17F000001 = { + fileRef = 33BD045F008390B17F000001; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 3290382C00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 3290384600D6BB3705CD296C, - 3290384700D6BB3705CD296C, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD0461008390B17F000001 = { + fileRef = 33BD045E008390B17F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290382D00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 33BD0462008391C07F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = headermap.cpp; + refType = 4; }; - 3290382E00D6BA5905CD296C = { - buildPhases = ( - 3290382F00D6BA5905CD296C, - 3290383000D6BA5905CD296C, - 3290383100D6BA5905CD296C, - 3290383200D6BA5905CD296C, - 3290383300D6BA5905CD296C, - ); - buildSettings = { - CURRENT_PROJECT_VERSION = 54.1.9; - LIBRARY_SEARCH_PATHS = ""; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; - OTHER_LDFLAGS = "-bundle -undefined error"; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = AppleX509TP; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - WRAPPER_EXTENSION = bundle; + 33BD0463008391C07F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = headermap.h; + refType = 4; + }; + 33BD0464008391C07F000001 = { + fileRef = 33BD0463008391C07F000001; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 33BD0465008391C07F000001 = { + fileRef = 33BD0462008391C07F000001; + isa = PBXBuildFile; + settings = { + }; + }; +//330 +//331 +//332 +//333 +//334 +//390 +//391 +//392 +//393 +//394 + 3949557400CC6A4511CD283A = { + fileRef = 125E85ADFFF3D44A11CD283A; + isa = PBXBuildFile; + settings = { }; - dependencies = ( - 3290384A00D6BB3705CD296C, - ); - isa = PBXBundleTarget; - name = "AppleX509TP Plugin"; - productName = "AppleX509TP Plugin"; - productReference = 3290381800D6BA5905CD296C; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - AppleX509TP - CFBundleGetInfoString - - CFBundleIconFile - - CFBundleIdentifier - - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.1.6 - CFBundleSignature - ???? - CFBundleVersion - 54.1.9 - - -"; - shouldUseHeadermap = 0; }; - 3290382F00D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; +//390 +//391 +//392 +//393 +//394 +//400 +//401 +//402 +//403 +//404 + 4046155904EE76E70001454E = { + fileRef = F5A7F717023D96EA01CA2E64; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 3290383000D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 9D103F9F01AC72C200003D05, - 9D103FA001AC72C200003D05, - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 406934DE04EDBB8A00447C8E = { + fileRef = F5A7F716023D96EA01CA2E64; + isa = PBXBuildFile; + settings = { + }; }; - 3290383100D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 3290384B00D6BB3705CD296C, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 406934DF04EDBB8C00447C8E = { + fileRef = F5A7F717023D96EA01CA2E64; + isa = PBXBuildFile; + settings = { + }; }; - 3290383200D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - 3290384C00D6BB3705CD296C, - 3290384D00D6BB3705CD296C, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 408F00D5045E0650009D840B = { + fileEncoding = 30; + isa = PBXFileReference; + path = AuthorizationDB.h; + refType = 4; }; - 3290383300D6BA5905CD296C = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; + 408F00D6045E0650009D840B = { + fileRef = 408F00D5045E0650009D840B; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; }; - 3290383500D6BB3705CD296C = { + 40ACEF4A0462F6EC0035B857 = { + fileEncoding = 30; isa = PBXFileReference; - path = AppleDLPlugin.cpp; + path = AuthorizationDBPlist.cpp; refType = 4; }; - 3290383600D6BB3705CD296C = { + 40ACEF4B0462F6EC0035B857 = { + fileEncoding = 30; isa = PBXFileReference; - path = AppleX509CLPlugin.cpp; + path = AuthorizationDBPlist.h; refType = 4; }; - 3290383700D6BB3705CD296C = { + 40ACEF4C0462F6EC0035B857 = { + fileRef = 40ACEF4A0462F6EC0035B857; + isa = PBXBuildFile; + settings = { + }; + }; + 40ACEF4D0462F6EC0035B857 = { + fileRef = 40ACEF4B0462F6EC0035B857; + isa = PBXBuildFile; + settings = { + }; + }; + 40ACEF4E0462F6FF0035B857 = { + fileEncoding = 30; + indentWidth = 4; isa = PBXFileReference; - path = AppleX509TPPlugin.cpp; + path = AuthorizationRule.cpp; refType = 4; + tabWidth = 4; + usesTabs = 1; }; - 3290383800D6BB3705CD296C = { - buildPhases = ( - ); - buildSettings = { - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = "Plugin Bundles"; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + 40ACEF4F0462F6FF0035B857 = { + fileEncoding = 30; + isa = PBXFileReference; + path = AuthorizationRule.h; + refType = 4; + }; + 40ACEF500462F6FF0035B857 = { + fileRef = 40ACEF4E0462F6FF0035B857; + isa = PBXBuildFile; + settings = { }; - dependencies = ( - 3290383900D6BB3705CD296C, - 3290383A00D6BB3705CD296C, - 3290383D00D6BB3705CD296C, - 3290384300D6BB3705CD296C, - 3290384900D6BB3705CD296C, - ); - isa = PBXAggregateTarget; - name = "Plugin Bundles"; - productName = "Plugin Bundles"; - shouldUseHeadermap = 0; }; - 3290383900D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 325EAA2200D6B08805CD296C; + 40ACEF510462F6FF0035B857 = { + fileRef = 40ACEF4F0462F6FF0035B857; + isa = PBXBuildFile; + settings = { + }; }; - 3290383A00D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 3290381900D6BA5905CD296C; +//400 +//401 +//402 +//403 +//404 +//480 +//481 +//482 +//483 +//484 + 48855E830095DC957F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = YarrowConnection.h; + refType = 4; }; - 3290383B00D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 014880DA005EAE4D11CD283A; + 48855E840095DC957F000001 = { + fileRef = 48855E830095DC957F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290383C00D6BB3705CD296C = { - fileRef = 3290383500D6BB3705CD296C; + 48855E850095DD697F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = YarrowConnection.cpp; + refType = 4; + }; + 48855E860095DD697F000001 = { + fileRef = 48855E850095DD697F000001; isa = PBXBuildFile; settings = { }; }; - 3290383D00D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 3290382200D6BA5905CD296C; +//480 +//481 +//482 +//483 +//484 +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 + 4A4C766C007A4E317F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc5_enc.c; + path = misc/rc5_enc.c; + refType = 4; }; - 3290383E00D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 014880D4005EAE4D11CD283A; + 4A4C766D007A4E317F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc5_locl.h; + path = misc/rc5_locl.h; + refType = 4; }; - 3290384000D6BB3705CD296C = { - fileRef = 014880C9005EAE4D11CD283A; + 4A4C766E007A4E317F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc5.h; + path = openssl/rc5.h; + refType = 4; + }; + 4A4C766F007A4E317F000001 = { + fileRef = 4A4C766D007A4E317F000001; isa = PBXBuildFile; settings = { }; }; - 3290384100D6BB3705CD296C = { - fileRef = 1BA451B10097605B7F000001; + 4A4C7670007A4E317F000001 = { + fileRef = 4A4C766E007A4E317F000001; isa = PBXBuildFile; settings = { }; }; - 3290384300D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 3290382800D6BA5905CD296C; + 4A4C7671007A4E317F000001 = { + fileRef = 4A4C766C007A4E317F000001; + isa = PBXBuildFile; + settings = { + }; }; - 3290384400D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 014880E0005EAE4D11CD283A; + 4A4C7672007A4E657F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc5_skey.c; + path = misc/rc5_skey.c; + refType = 4; }; - 3290384500D6BB3705CD296C = { - fileRef = 3290383600D6BB3705CD296C; + 4A4C7673007A4E657F000001 = { + fileRef = 4A4C7672007A4E657F000001; isa = PBXBuildFile; settings = { }; }; - 3290384600D6BB3705CD296C = { - fileRef = 014880CA005EAE4D11CD283A; + 4A4C7674007A52DC7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc5Context.cpp; + path = MiscCSPAlgs/rc5Context.cpp; + refType = 4; + }; + 4A4C7675007A52DC7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc5Context.h; + path = MiscCSPAlgs/rc5Context.h; + refType = 4; + }; + 4A4C7676007A52DC7F000001 = { + fileRef = 4A4C7675007A52DC7F000001; isa = PBXBuildFile; settings = { }; }; - 3290384700D6BB3705CD296C = { - fileRef = 1BA451B10097605B7F000001; + 4A4C7677007A52DC7F000001 = { + fileRef = 4A4C7674007A52DC7F000001; isa = PBXBuildFile; settings = { }; }; - 3290384900D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 3290382E00D6BA5905CD296C; - }; - 3290384A00D6BB3705CD296C = { - isa = PBXTargetDependency; - target = 014880E6005EAE4D11CD283A; + 4AC94A7C0084BE397F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "vRijndael-alg-ref.c"; + refType = 4; }; - 3290384B00D6BB3705CD296C = { - fileRef = 3290383700D6BB3705CD296C; + 4AC94A7D0084BE397F000001 = { + fileRef = 4AC94A7C0084BE397F000001; isa = PBXBuildFile; settings = { }; }; - 3290384C00D6BB3705CD296C = { - fileRef = 014880CB005EAE4D11CD283A; + 4AC94A7E0084C0977F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "boxes-ref.c"; + refType = 4; + }; + 4AC94A7F0084C0977F000001 = { + fileRef = 4AC94A7E0084C0977F000001; isa = PBXBuildFile; settings = { }; }; - 3290384D00D6BB3705CD296C = { - fileRef = 1BA451B10097605B7F000001; +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 +//4C0 +//4C1 +//4C2 +//4C3 +//4C4 + 4C2ACAB7044267EE00CA2E66 = { + fileEncoding = 4; + isa = PBXFileReference; + path = SecIdentityPriv.h; + refType = 4; + }; + 4C2ACAB8044267EE00CA2E66 = { + fileRef = 4C2ACAB7044267EE00CA2E66; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 3290384F00D6BB7805CD296C = { - isa = PBXTargetDependency; - target = 3290385000D6BB7805CD296C; +//4C0 +//4C1 +//4C2 +//4C3 +//4C4 +//4D0 +//4D1 +//4D2 +//4D3 +//4D4 + 4D37AD3900AA03857F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = netconnection.cpp; + refType = 4; }; - 3290385000D6BB7805CD296C = { - buildPhases = ( - ); - buildSettings = { - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = "Built-in Plugin Code"; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - dependencies = ( - 3290385100D6BB7805CD296C, - 3290385200D6BB7805CD296C, - 3290385300D6BB7805CD296C, - 3290385400D6BB7805CD296C, - 3290385500D6BB7805CD296C, - ); - isa = PBXAggregateTarget; - name = "Built-in Plugin Code"; - productName = "Built-in Plugin Code"; - shouldUseHeadermap = 0; + 4D37AD3A00AA03857F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = netconnection.h; + refType = 4; }; - 3290385100D6BB7805CD296C = { - isa = PBXTargetDependency; - target = 014880CD005EAE4D11CD283A; + 4D37AD3B00AA03857F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = neterror.cpp; + refType = 4; }; - 3290385200D6BB7805CD296C = { - isa = PBXTargetDependency; - target = 014880D4005EAE4D11CD283A; + 4D37AD3C00AA03857F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = neterror.h; + refType = 4; }; - 3290385300D6BB7805CD296C = { - isa = PBXTargetDependency; - target = 014880DA005EAE4D11CD283A; + 4D37AD3D00AA03857F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = netmanager.cpp; + refType = 4; }; - 3290385400D6BB7805CD296C = { - isa = PBXTargetDependency; - target = 014880E0005EAE4D11CD283A; + 4D37AD3E00AA03857F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = netmanager.h; + refType = 4; }; - 3290385500D6BB7805CD296C = { - isa = PBXTargetDependency; - target = 014880E6005EAE4D11CD283A; + 4D37AD3F00AA03857F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + path = netparameters.h; + refType = 4; }; - 3290386E00D6C5FD05CD296C = { + 4D37AD4000AA03857F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = modloader.cpp; + path = networkchooser.cpp; refType = 4; }; - 3290386F00D6C5FD05CD296C = { + 4D37AD4100AA03857F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = modloader.h; + path = networkchooser.h; refType = 4; }; - 3290387000D6C5FE05CD296C = { - fileRef = 3290386F00D6C5FD05CD296C; +//4D0 +//4D1 +//4D2 +//4D3 +//4D4 +//4E0 +//4E1 +//4E2 +//4E3 +//4E4 + 4EE175A40459EC6F0036F88D = { + fileEncoding = 30; + isa = PBXFileReference; + path = ktracecodes.h; + refType = 4; + }; + 4EE175A50459EC6F0036F88D = { + fileRef = 4EE175A40459EC6F0036F88D; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -13246,24 +13900,54 @@ ); }; }; - 3290387100D6C5FE05CD296C = { - fileRef = 3290386E00D6C5FD05CD296C; +//4E0 +//4E1 +//4E2 +//4E3 +//4E4 +//520 +//521 +//522 +//523 +//524 + 5274775904CDF08D00F0AE7D = { + fileRef = 52F5173004C4B29300D9D6E1; isa = PBXBuildFile; settings = { }; }; -//320 -//321 -//322 -//323 -//324 -//330 -//331 -//332 -//333 -//334 - 338005E1FFF3E69711CD283A = { - fileRef = 01FA821BFFF2B54C11CD283A; + 52807AD004A3D4B800F46CAB = { + fileEncoding = 30; + isa = PBXFileReference; + path = iToolsTrustedApps.plist; + refType = 4; + }; + 52807AD104A3D4B800F46CAB = { + fileEncoding = 30; + isa = PBXFileReference; + path = SecKeychainAddIToolsPassword.c; + refType = 4; + }; + 52807AD204A3D4B800F46CAB = { + fileRef = 52807AD004A3D4B800F46CAB; + isa = PBXBuildFile; + settings = { + }; + }; + 52807AD304A3D4B800F46CAB = { + fileRef = 52807AD104A3D4B800F46CAB; + isa = PBXBuildFile; + settings = { + }; + }; + 52807AD404A3D56C00F46CAB = { + fileEncoding = 30; + isa = PBXFileReference; + path = SecAccessPriv.h; + refType = 4; + }; + 52807AD504A3D56C00F46CAB = { + fileRef = 52807AD404A3D56C00F46CAB; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -13271,130 +13955,121 @@ ); }; }; - 33BD041F00838F447F000001 = { - children = ( - 017B6CA6009748107F000001, - 017B6CA7009748107F000001, - 33BD0434008390257F000001, - 33BD0435008390257F000001, - 33BD0436008390257F000001, - 33BD0437008390257F000001, - 33BD0462008391C07F000001, - 33BD0463008391C07F000001, - 33BD045E008390B17F000001, - 33BD045F008390B17F000001, - 33BD0438008390257F000001, - 33BD0439008390257F000001, - 33BD043A008390257F000001, - 33BD043B008390257F000001, - 33BD043C008390257F000001, - 33BD043D008390257F000001, - 2F4DD9A600A0A0767F000001, - 2F4DD9A500A0A0767F000001, - 33BD043E008390257F000001, - 33BD043F008390257F000001, - 33BD0440008390257F000001, - 33BD0441008390257F000001, - 33BD0442008390257F000001, - 33BD0443008390257F000001, - 33BD0444008390257F000001, - 33BD0445008390257F000001, - 33BD0446008390257F000001, - 33BD0447008390257F000001, - 33BD042500838F5A7F000001, - ); - isa = PBXGroup; - name = UNIX; + 52BFC304007A6A1B7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc4.h; + path = openssl/rc4.h; refType = 4; }; - 33BD042000838F447F000001 = { - children = ( - 33BD042100838F447F000001, - 33BD042200838F447F000001, - ); - isa = PBXGroup; - name = "C++ Interface"; + 52BFC306007A6A1B7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc4_skey.c; + path = misc/rc4_skey.c; refType = 4; }; - 33BD042100838F447F000001 = { + 52BFC307007A6A1B7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = "securetransport++.cpp"; + name = rc4Context.cpp; + path = MiscCSPAlgs/rc4Context.cpp; refType = 4; }; - 33BD042200838F447F000001 = { + 52BFC308007A6A1B7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = "securetransport++.h"; + name = rc4Context.h; + path = MiscCSPAlgs/rc4Context.h; refType = 4; }; - 33BD042300838F447F000001 = { - fileRef = 33BD042200838F447F000001; + 52BFC30A007A6A1B7F000001 = { + fileRef = 52BFC308007A6A1B7F000001; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD042400838F447F000001 = { - fileRef = 33BD042100838F447F000001; + 52BFC30C007A6A1B7F000001 = { + fileRef = 52BFC306007A6A1B7F000001; isa = PBXBuildFile; settings = { }; }; - 33BD042500838F5A7F000001 = { - children = ( - 33BD042600838FB17F000001, - 33BD042700838FB17F000001, - 33BD042800838FB17F000001, - 33BD042900838FB17F000001, - 33BD042A00838FB17F000001, - 33BD042B00838FB17F000001, - ); - isa = PBXGroup; - name = Socks; - refType = 4; + 52BFC30D007A6A1B7F000001 = { + fileRef = 52BFC307007A6A1B7F000001; + isa = PBXBuildFile; + settings = { + }; }; - 33BD042600838FB17F000001 = { + 52D4AA9104B3AE3E00393476 = { + fileEncoding = 30; isa = PBXFileReference; - path = "socks++.cpp"; + path = generateErrStrings.pl; refType = 4; }; - 33BD042700838FB17F000001 = { + 52F5173004C4B29300D9D6E1 = { + fileEncoding = 30; isa = PBXFileReference; - path = "socks++.h"; + path = SecErrorMessages.strings; refType = 4; }; - 33BD042800838FB17F000001 = { +//520 +//521 +//522 +//523 +//524 +//560 +//561 +//562 +//563 +//564 + 563FC2AC03F8454B0DCA289E = { + fileEncoding = 30; isa = PBXFileReference; - path = "socks++4.cpp"; + path = dictionary.cpp; refType = 4; }; - 33BD042900838FB17F000001 = { + 563FC2AD03F8454B0DCA289E = { + fileEncoding = 30; isa = PBXFileReference; - path = "socks++4.h"; + path = dictionary.h; refType = 4; }; - 33BD042A00838FB17F000001 = { + 563FC2AE03F8454B0DCA289E = { + fileEncoding = 30; isa = PBXFileReference; - path = "socks++5.cpp"; + path = eventlistener.cpp; refType = 4; }; - 33BD042B00838FB17F000001 = { + 563FC2AF03F8454B0DCA289E = { + fileEncoding = 30; isa = PBXFileReference; - path = "socks++5.h"; + path = eventlistener.h; refType = 4; }; - 33BD042C00838FB17F000001 = { - fileRef = 33BD042700838FB17F000001; + 563FC2B003F8456F0DCA289E = { + fileRef = 563FC2AC03F8454B0DCA289E; + isa = PBXBuildFile; + settings = { + }; + }; + 563FC2B103F8456F0DCA289E = { + fileRef = 563FC2AE03F8454B0DCA289E; + isa = PBXBuildFile; + settings = { + }; + }; + 563FC2B203F845EC0DCA289E = { + fileRef = 563FC2AD03F8454B0DCA289E; isa = PBXBuildFile; settings = { ATTRIBUTES = ( Private, ); }; - }; - 33BD042D00838FB17F000001 = { - fileRef = 33BD042900838FB17F000001; + }; + 563FC2B303F845EC0DCA289E = { + fileRef = 563FC2AF03F8454B0DCA289E; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -13402,8 +14077,8 @@ ); }; }; - 33BD042E00838FB17F000001 = { - fileRef = 33BD042B00838FB17F000001; + 56EB36FE03F83C7E0DCA289E = { + fileRef = 32361EEC01EB8FCF05CA2E77; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -13411,126 +14086,250 @@ ); }; }; - 33BD042F00838FB17F000001 = { - fileRef = 33BD042600838FB17F000001; +//560 +//561 +//562 +//563 +//564 +//570 +//571 +//572 +//573 +//574 + 57FCEE8B007A7B2F7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = rc4_enc.c; + path = misc/rc4_enc.c; + refType = 4; + }; + 57FCEE8C007A7B2F7F000001 = { + fileRef = 57FCEE8B007A7B2F7F000001; isa = PBXBuildFile; settings = { }; }; - 33BD043000838FB17F000001 = { - fileRef = 33BD042800838FB17F000001; + 57FCEE8D007B8B3D7F000001 = { + children = ( + 57FCEE8E007B8B3D7F000001, + 57FCEE8F007B8B3D7F000001, + 57FCEE9C007B8D4F7F000001, + ); + isa = PBXGroup; + name = ComCryption; + refType = 4; + }; + 57FCEE8E007B8B3D7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = ascContext.cpp; + path = ComCryption/ascContext.cpp; + refType = 4; + }; + 57FCEE8F007B8B3D7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + name = ascContext.h; + path = ComCryption/ascContext.h; + refType = 4; + }; + 57FCEE95007B8B3D7F000001 = { + fileRef = 57FCEE8F007B8B3D7F000001; isa = PBXBuildFile; settings = { }; }; - 33BD043100838FB17F000001 = { - fileRef = 33BD042A00838FB17F000001; + 57FCEE99007B8B3D7F000001 = { + fileRef = 57FCEE8E007B8B3D7F000001; isa = PBXBuildFile; settings = { }; }; - 33BD0434008390257F000001 = { + 57FCEE9C007B8D4F7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = bufferfifo.cpp; + name = ascFactory.h; + path = ComCryption/ascFactory.h; refType = 4; }; - 33BD0435008390257F000001 = { - isa = PBXFileReference; - path = bufferfifo.h; - refType = 4; + 57FCEE9D007B8D4F7F000001 = { + fileRef = 57FCEE9C007B8D4F7F000001; + isa = PBXBuildFile; + settings = { + }; }; - 33BD0436008390257F000001 = { +//570 +//571 +//572 +//573 +//574 +//590 +//591 +//592 +//593 +//594 + 59375E6B00A848827F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = constdata.cpp; + name = MD2Object.h; + path = MiscCSPAlgs/MD2Object.h; refType = 4; }; - 33BD0437008390257F000001 = { - isa = PBXFileReference; - path = constdata.h; - refType = 4; + 59375E6C00A848827F000001 = { + fileRef = 59375E6B00A848827F000001; + isa = PBXBuildFile; + settings = { + }; }; - 33BD0438008390257F000001 = { + 59375E6D00A849237F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = inetreply.cpp; + name = md2_dgst.c; + path = misc/md2_dgst.c; refType = 4; }; - 33BD0439008390257F000001 = { + 59375E6E00A849237F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = inetreply.h; + name = md2.h; + path = openssl/md2.h; refType = 4; }; - 33BD043A008390257F000001 = { - isa = PBXFileReference; - path = "ip++.cpp"; - refType = 4; + 59375E6F00A849237F000001 = { + fileRef = 59375E6E00A849237F000001; + isa = PBXBuildFile; + settings = { + }; }; - 33BD043B008390257F000001 = { - isa = PBXFileReference; - path = "ip++.h"; - refType = 4; + 59375E7000A849237F000001 = { + fileRef = 59375E6D00A849237F000001; + isa = PBXBuildFile; + settings = { + }; }; - 33BD043C008390257F000001 = { + 59375E7100A849BB7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = selector.cpp; + name = MD2Object.cpp; + path = MiscCSPAlgs/MD2Object.cpp; refType = 4; }; - 33BD043D008390257F000001 = { - isa = PBXFileReference; - path = selector.h; - refType = 4; + 59375E7200A849BB7F000001 = { + fileRef = 59375E7100A849BB7F000001; + isa = PBXBuildFile; + settings = { + }; }; - 33BD043E008390257F000001 = { +//590 +//591 +//592 +//593 +//594 +//5B0 +//5B1 +//5B2 +//5B3 +//5B4 + 5BA4A42D01F4E3F504CA2E82 = { + fileEncoding = 30; isa = PBXFileReference; - path = streams.cpp; + path = Identity.cpp; refType = 4; }; - 33BD043F008390257F000001 = { + 5BA4A42E01F4E3F504CA2E82 = { + fileEncoding = 30; isa = PBXFileReference; - path = streams.h; + path = Identity.h; refType = 4; }; - 33BD0440008390257F000001 = { - isa = PBXFileReference; - path = timeflow.cpp; - refType = 4; + 5BA4A43101F4E3F604CA2E82 = { + fileRef = 5BA4A42E01F4E3F504CA2E82; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 33BD0441008390257F000001 = { - isa = PBXFileReference; - path = timeflow.h; - refType = 4; + 5BA4A43301F4E3F604CA2E82 = { + fileRef = 5BA4A42D01F4E3F504CA2E82; + isa = PBXBuildFile; + settings = { + }; }; - 33BD0442008390257F000001 = { +//5B0 +//5B1 +//5B2 +//5B3 +//5B4 +//630 +//631 +//632 +//633 +//634 + 63B97E6600603F0A7F000001 = { + fileEncoding = 30; isa = PBXFileReference; - path = typedvalue.cpp; + path = CryptKitDER.cpp; refType = 4; }; - 33BD0443008390257F000001 = { - isa = PBXFileReference; - path = typedvalue.h; - refType = 4; + 63B97E6700603F0B7F000001 = { + fileRef = 63B97E6600603F0A7F000001; + isa = PBXBuildFile; + settings = { + }; }; - 33BD0444008390257F000001 = { +//630 +//631 +//632 +//633 +//634 +//8F0 +//8F1 +//8F2 +//8F3 +//8F4 + 8F7ACD2A02357F2503CA2E8C = { + fileEncoding = 30; isa = PBXFileReference; - path = "unix++.cpp"; + path = SecACL.h; refType = 4; }; - 33BD0445008390257F000001 = { + 8F7ACD2B02357F2503CA2E8C = { + fileEncoding = 30; isa = PBXFileReference; - path = "unix++.h"; + path = SecACL.cpp; refType = 4; }; - 33BD0446008390257F000001 = { + 8F7ACD2C02357F2503CA2E8C = { + fileRef = 8F7ACD2A02357F2503CA2E8C; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + 8F7ACD2D02357F2503CA2E8C = { + fileRef = 8F7ACD2B02357F2503CA2E8C; + isa = PBXBuildFile; + settings = { + }; + }; + 8F7ACD300235805903CA2E8C = { + fileEncoding = 30; isa = PBXFileReference; - path = url.cpp; + path = ACL.h; refType = 4; }; - 33BD0447008390257F000001 = { + 8F7ACD310235805903CA2E8C = { + fileEncoding = 30; isa = PBXFileReference; - path = url.h; + path = ACL.cpp; refType = 4; }; - 33BD0449008390257F000001 = { - fileRef = 33BD0435008390257F000001; + 8F7ACD320235805903CA2E8C = { + fileRef = 8F7ACD300235805903CA2E8C; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -13538,44 +14337,67 @@ ); }; }; - 33BD044A008390257F000001 = { - fileRef = 33BD0437008390257F000001; + 8F7ACD330235805903CA2E8C = { + fileRef = 8F7ACD310235805903CA2E8C; + isa = PBXBuildFile; + settings = { + }; + }; +//8F0 +//8F1 +//8F2 +//8F3 +//8F4 +//9D0 +//9D1 +//9D2 +//9D3 +//9D4 + 9D09B90701B4314500003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = tp_policyOids.mdsinfo; + refType = 4; + }; + 9D09B90801B4314500003D05 = { + fileRef = 9D09B90701B4314500003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD044B008390257F000001 = { - fileRef = 33BD0439008390257F000001; + 9D103F9F01AC72C200003D05 = { + fileRef = 9DAE2E2A01A2F93200003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD044C008390257F000001 = { - fileRef = 33BD043B008390257F000001; + 9D103FA001AC72C200003D05 = { + fileRef = 9DAE2E2901A2F93200003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD044D008390257F000001 = { - fileRef = 33BD043D008390257F000001; + 9D14AC52020093D100003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = tpCredRequest.cpp; + refType = 4; + }; + 9D14AC53020093D100003D05 = { + fileRef = 9D14AC52020093D100003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD044E008390257F000001 = { - fileRef = 33BD043F008390257F000001; + 9D1DEC190198777400003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MDSAttrStrings.h; + path = cdsa/mds/MDSAttrStrings.h; + refType = 4; + }; + 9D1DEC1A0198777400003D05 = { + fileRef = 9D1DEC190198777400003D05; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -13583,139 +14405,274 @@ ); }; }; - 33BD044F008390257F000001 = { - fileRef = 33BD0441008390257F000001; + 9D1DEC1B0198796200003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MDSAttrStrings.cpp; + path = cdsa/mds/MDSAttrStrings.cpp; + refType = 2; + }; + 9D1DEC1C0198796200003D05 = { + fileRef = 9D1DEC1B0198796200003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD0450008390257F000001 = { - fileRef = 33BD0443008390257F000001; + 9D206AA601EB68F200003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = NullCryptor.h; + path = MiscCSPAlgs/NullCryptor.h; + refType = 4; + }; + 9D206AA701EB68F200003D05 = { + fileRef = 9D206AA601EB68F200003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD0451008390257F000001 = { - fileRef = 33BD0445008390257F000001; + 9D291872026B4FF900003D05 = { + children = ( + 9D291875026B502600003D05, + 9D291876026B502600003D05, + 9D291877026B502600003D05, + 9D291878026B502600003D05, + 9D291879026B502600003D05, + ); + isa = PBXGroup; + name = dh; + refType = 4; + }; + 9D291875026B502600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dh_check.c; + path = dh/dh_check.c; + refType = 4; + }; + 9D291876026B502600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dh_err.c; + path = dh/dh_err.c; + refType = 4; + }; + 9D291877026B502600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dh_gen.c; + path = dh/dh_gen.c; + refType = 4; + }; + 9D291878026B502600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dh_key.c; + path = dh/dh_key.c; + refType = 4; + }; + 9D291879026B502600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dh_lib.c; + path = dh/dh_lib.c; + refType = 4; + }; + 9D29187A026B502600003D05 = { + fileRef = 9D291875026B502600003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD0452008390257F000001 = { - fileRef = 33BD0447008390257F000001; + 9D29187B026B502600003D05 = { + fileRef = 9D291876026B502600003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD0454008390257F000001 = { - fileRef = 33BD0434008390257F000001; + 9D29187C026B502600003D05 = { + fileRef = 9D291877026B502600003D05; isa = PBXBuildFile; settings = { }; }; - 33BD0455008390257F000001 = { - fileRef = 33BD0436008390257F000001; + 9D29187D026B502600003D05 = { + fileRef = 9D291878026B502600003D05; isa = PBXBuildFile; settings = { }; }; - 33BD0456008390257F000001 = { - fileRef = 33BD0438008390257F000001; + 9D29187E026B502600003D05 = { + fileRef = 9D291879026B502600003D05; isa = PBXBuildFile; settings = { }; }; - 33BD0457008390257F000001 = { - fileRef = 33BD043A008390257F000001; + 9D29187F026B504700003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = dh.h; + path = openssl/dh.h; + refType = 4; + }; + 9D291880026B504700003D05 = { + fileRef = 9D29187F026B504700003D05; isa = PBXBuildFile; settings = { }; }; - 33BD0458008390257F000001 = { - fileRef = 33BD043C008390257F000001; + 9D291881026B56B800003D05 = { + children = ( + 9D291882026B56DA00003D05, + 9D291883026B56DA00003D05, + 9D291884026B56DA00003D05, + 9D291885026B56DA00003D05, + 9D291886026B56DA00003D05, + 9D291887026B56DA00003D05, + 9D29188E026B8BBD00003D05, + 9D29188F026B8BBD00003D05, + ); + isa = PBXGroup; + name = DiffieHellman; + path = AppleCSP; + refType = 2; + }; + 9D291882026B56DA00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = DH_csp.cpp; + path = DiffieHellman/DH_csp.cpp; + refType = 4; + }; + 9D291883026B56DA00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = DH_csp.h; + path = DiffieHellman/DH_csp.h; + refType = 4; + }; + 9D291884026B56DA00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = DH_exchange.cpp; + path = DiffieHellman/DH_exchange.cpp; + refType = 4; + }; + 9D291885026B56DA00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = DH_exchange.h; + path = DiffieHellman/DH_exchange.h; + refType = 4; + }; + 9D291886026B56DA00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = DH_keys.cpp; + path = DiffieHellman/DH_keys.cpp; + refType = 4; + }; + 9D291887026B56DA00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = DH_keys.h; + path = DiffieHellman/DH_keys.h; + refType = 4; + }; + 9D291888026B56DA00003D05 = { + fileRef = 9D291882026B56DA00003D05; isa = PBXBuildFile; settings = { }; }; - 33BD0459008390257F000001 = { - fileRef = 33BD043E008390257F000001; + 9D291889026B56DA00003D05 = { + fileRef = 9D291883026B56DA00003D05; isa = PBXBuildFile; settings = { }; }; - 33BD045A008390257F000001 = { - fileRef = 33BD0440008390257F000001; + 9D29188A026B56DA00003D05 = { + fileRef = 9D291884026B56DA00003D05; isa = PBXBuildFile; settings = { }; }; - 33BD045B008390257F000001 = { - fileRef = 33BD0442008390257F000001; + 9D29188B026B56DA00003D05 = { + fileRef = 9D291885026B56DA00003D05; isa = PBXBuildFile; settings = { }; }; - 33BD045C008390257F000001 = { - fileRef = 33BD0444008390257F000001; + 9D29188C026B56DA00003D05 = { + fileRef = 9D291886026B56DA00003D05; isa = PBXBuildFile; settings = { }; }; - 33BD045D008390257F000001 = { - fileRef = 33BD0446008390257F000001; + 9D29188D026B56DA00003D05 = { + fileRef = 9D291887026B56DA00003D05; isa = PBXBuildFile; settings = { }; }; - 33BD045E008390B17F000001 = { + 9D29188E026B8BBD00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = hosts.cpp; + name = DH_utils.cpp; + path = DiffieHellman/DH_utils.cpp; refType = 4; }; - 33BD045F008390B17F000001 = { + 9D29188F026B8BBD00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = hosts.h; + name = DH_utils.h; + path = DiffieHellman/DH_utils.h; refType = 4; }; - 33BD0460008390B17F000001 = { - fileRef = 33BD045F008390B17F000001; + 9D291890026B8BBD00003D05 = { + fileRef = 9D29188E026B8BBD00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 33BD0461008390B17F000001 = { - fileRef = 33BD045E008390B17F000001; + 9D291891026B8BBD00003D05 = { + fileRef = 9D29188F026B8BBD00003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D2C3D0001C826C800003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = gladmanContext.h; + refType = 4; + }; + 9D2C3D0101C826C800003D05 = { + fileRef = 9D2C3D0001C826C800003D05; isa = PBXBuildFile; settings = { }; }; - 33BD0462008391C07F000001 = { + 9D2C3D0201C82F6000003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = headermap.cpp; + path = aesCommon.h; refType = 4; }; - 33BD0463008391C07F000001 = { + 9D2C3D0301C82F6100003D05 = { + fileRef = 9D2C3D0201C82F6000003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D2F711303156A7800003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = headermap.h; + path = SecCertificatePriv.h; refType = 4; }; - 33BD0464008391C07F000001 = { - fileRef = 33BD0463008391C07F000001; + 9D2F711403156A7800003D05 = { + fileRef = 9D2F711303156A7800003D05; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -13723,546 +14680,428 @@ ); }; }; - 33BD0465008391C07F000001 = { - fileRef = 33BD0462008391C07F000001; - isa = PBXBuildFile; - settings = { - }; + 9D347A350380197600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = CLCrlExtensions.cpp; + refType = 4; }; -//330 -//331 -//332 -//333 -//334 -//390 -//391 -//392 -//393 -//394 - 3949557400CC6A4511CD283A = { - fileRef = 125E85ADFFF3D44A11CD283A; - isa = PBXBuildFile; - settings = { - }; + 9D347A360380197600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = CLCrlExtensions.h; + refType = 4; }; -//390 -//391 -//392 -//393 -//394 -//480 -//481 -//482 -//483 -//484 - 48855E830095DC957F000001 = { + 9D347A370380197600003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = YarrowConnection.h; + path = CLFieldsCommon.cpp; refType = 4; }; - 48855E840095DC957F000001 = { - fileRef = 48855E830095DC957F000001; - isa = PBXBuildFile; - settings = { - }; + 9D347A380380197600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = CLFieldsCommon.h; + refType = 4; }; - 48855E850095DD697F000001 = { + 9D347A390380197600003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = YarrowConnection.cpp; + path = CrlFields.cpp; refType = 4; }; - 48855E860095DD697F000001 = { - fileRef = 48855E850095DD697F000001; - isa = PBXBuildFile; - settings = { - }; + 9D347A3A0380197600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = DecodedCrl.cpp; + refType = 4; }; -//480 -//481 -//482 -//483 -//484 -//4A0 -//4A1 -//4A2 -//4A3 -//4A4 - 4A4C766C007A4E317F000001 = { + 9D347A3B0380197600003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = rc5_enc.c; - path = misc/rc5_enc.c; + path = DecodedCrl.h; refType = 4; }; - 4A4C766D007A4E317F000001 = { + 9D347A3C0380197600003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = rc5_locl.h; - path = misc/rc5_locl.h; + path = DecodedExtensions.cpp; refType = 4; }; - 4A4C766E007A4E317F000001 = { + 9D347A3D0380197600003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = rc5.h; - path = openssl/rc5.h; + path = DecodedExtensions.h; refType = 4; }; - 4A4C766F007A4E317F000001 = { - fileRef = 4A4C766D007A4E317F000001; + 9D347A3E0380197600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = DecodedItem.cpp; + refType = 4; + }; + 9D347A3F0380197600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = DecodedItem.h; + refType = 4; + }; + 9D347A400380197600003D05 = { + fileRef = 9D347A350380197600003D05; isa = PBXBuildFile; settings = { }; }; - 4A4C7670007A4E317F000001 = { - fileRef = 4A4C766E007A4E317F000001; + 9D347A410380197600003D05 = { + fileRef = 9D347A360380197600003D05; isa = PBXBuildFile; settings = { }; }; - 4A4C7671007A4E317F000001 = { - fileRef = 4A4C766C007A4E317F000001; + 9D347A420380197600003D05 = { + fileRef = 9D347A370380197600003D05; isa = PBXBuildFile; settings = { }; }; - 4A4C7672007A4E657F000001 = { - isa = PBXFileReference; - name = rc5_skey.c; - path = misc/rc5_skey.c; - refType = 4; - }; - 4A4C7673007A4E657F000001 = { - fileRef = 4A4C7672007A4E657F000001; + 9D347A430380197600003D05 = { + fileRef = 9D347A380380197600003D05; isa = PBXBuildFile; settings = { }; }; - 4A4C7674007A52DC7F000001 = { - isa = PBXFileReference; - name = rc5Context.cpp; - path = MiscCSPAlgs/rc5Context.cpp; - refType = 4; - }; - 4A4C7675007A52DC7F000001 = { - isa = PBXFileReference; - name = rc5Context.h; - path = MiscCSPAlgs/rc5Context.h; - refType = 4; + 9D347A440380197600003D05 = { + fileRef = 9D347A390380197600003D05; + isa = PBXBuildFile; + settings = { + }; }; - 4A4C7676007A52DC7F000001 = { - fileRef = 4A4C7675007A52DC7F000001; + 9D347A450380197600003D05 = { + fileRef = 9D347A3A0380197600003D05; isa = PBXBuildFile; settings = { }; }; - 4A4C7677007A52DC7F000001 = { - fileRef = 4A4C7674007A52DC7F000001; + 9D347A460380197600003D05 = { + fileRef = 9D347A3B0380197600003D05; isa = PBXBuildFile; settings = { }; }; - 4AC94A7C0084BE397F000001 = { - isa = PBXFileReference; - path = "vRijndael-alg-ref.c"; - refType = 4; + 9D347A470380197600003D05 = { + fileRef = 9D347A3C0380197600003D05; + isa = PBXBuildFile; + settings = { + }; }; - 4AC94A7D0084BE397F000001 = { - fileRef = 4AC94A7C0084BE397F000001; + 9D347A480380197600003D05 = { + fileRef = 9D347A3D0380197600003D05; isa = PBXBuildFile; settings = { }; }; - 4AC94A7E0084C0977F000001 = { - isa = PBXFileReference; - path = "boxes-ref.c"; - refType = 4; + 9D347A490380197600003D05 = { + fileRef = 9D347A3E0380197600003D05; + isa = PBXBuildFile; + settings = { + }; }; - 4AC94A7F0084C0977F000001 = { - fileRef = 4AC94A7E0084C0977F000001; + 9D347A4A0380197600003D05 = { + fileRef = 9D347A3F0380197600003D05; isa = PBXBuildFile; settings = { }; }; -//4A0 -//4A1 -//4A2 -//4A3 -//4A4 -//4D0 -//4D1 -//4D2 -//4D3 -//4D4 - 4D37AD3900AA03857F000001 = { + 9D347A4B038019EF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = netconnection.cpp; + path = TPCrlInfo.cpp; refType = 4; }; - 4D37AD3A00AA03857F000001 = { + 9D347A4C038019EF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = netconnection.h; + path = TPCrlInfo.h; refType = 4; }; - 4D37AD3B00AA03857F000001 = { + 9D347A4D038019EF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = neterror.cpp; + path = tpCrlVerify.cpp; refType = 4; }; - 4D37AD3C00AA03857F000001 = { + 9D347A4E038019EF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = neterror.h; + path = tpCrlVerify.h; refType = 4; }; - 4D37AD3D00AA03857F000001 = { + 9D347A4F038019EF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = netmanager.cpp; + path = TPDatabase.cpp; refType = 4; }; - 4D37AD3E00AA03857F000001 = { + 9D347A50038019EF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = netmanager.h; + path = TPDatabase.h; refType = 4; }; - 4D37AD3F00AA03857F000001 = { + 9D347A51038019EF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = netparameters.h; + path = TPNetwork.cpp; refType = 4; }; - 4D37AD4000AA03857F000001 = { + 9D347A52038019EF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = networkchooser.cpp; + path = TPNetwork.h; refType = 4; }; - 4D37AD4100AA03857F000001 = { - isa = PBXFileReference; - path = networkchooser.h; - refType = 4; + 9D347A53038019EF00003D05 = { + fileRef = 9D347A4B038019EF00003D05; + isa = PBXBuildFile; + settings = { + }; }; -//4D0 -//4D1 -//4D2 -//4D3 -//4D4 -//4E0 -//4E1 -//4E2 -//4E3 -//4E4 - 4EB202DD0058585F7F000001 = { - isa = PBXFileReference; - path = appleoids.asn; - refType = 4; + 9D347A54038019EF00003D05 = { + fileRef = 9D347A4C038019EF00003D05; + isa = PBXBuildFile; + settings = { + }; }; - 4EB202DE0058585F7F000001 = { - isa = PBXFileReference; - path = appleoids.cpp; - refType = 4; + 9D347A55038019EF00003D05 = { + fileRef = 9D347A4D038019EF00003D05; + isa = PBXBuildFile; + settings = { + }; }; - 4EB202E00058588E7F000001 = { - isa = PBXFileReference; - path = appleoids.h; - refType = 4; + 9D347A56038019EF00003D05 = { + fileRef = 9D347A4E038019EF00003D05; + isa = PBXBuildFile; + settings = { + }; }; - 4EB202E10058588E7F000001 = { - fileRef = 4EB202E00058588E7F000001; + 9D347A57038019EF00003D05 = { + fileRef = 9D347A4F038019EF00003D05; isa = PBXBuildFile; settings = { }; }; - 4EB202E2005859A47F000001 = { - fileRef = 4EB202E00058588E7F000001; + 9D347A58038019EF00003D05 = { + fileRef = 9D347A50038019EF00003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 4EB202E3005859A47F000001 = { - fileRef = 4EB202DE0058585F7F000001; + 9D347A59038019EF00003D05 = { + fileRef = 9D347A51038019EF00003D05; isa = PBXBuildFile; settings = { }; }; -//4E0 -//4E1 -//4E2 -//4E3 -//4E4 -//520 -//521 -//522 -//523 -//524 - 52BFC304007A6A1B7F000001 = { - isa = PBXFileReference; - name = rc4.h; - path = openssl/rc4.h; - refType = 4; + 9D347A5A038019EF00003D05 = { + fileRef = 9D347A52038019EF00003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D347A5F0380300100003D05 = { + isa = PBXFrameworkReference; + name = LDAP.framework; + path = /System/Library/Frameworks/LDAP.framework; + refType = 0; + }; + 9D347A660380312200003D05 = { + buildActionMask = 2147483647; + files = ( + 9D347A70038031AF00003D05, + 9D347A72038031B800003D05, + 9D347A74038031B900003D05, + 9D347A76038031BA00003D05, + 9D347A78038031BB00003D05, + 9D347A7A038031BC00003D05, + 9D347A7C038031BE00003D05, + 9D347A7E038031BE00003D05, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9D347A670380312200003D05 = { + buildActionMask = 2147483647; + files = ( + 9D347A6F038031AF00003D05, + 9D347A71038031B800003D05, + 9D347A73038031B900003D05, + 9D347A75038031BA00003D05, + 9D347A77038031BB00003D05, + 9D347A79038031BC00003D05, + 9D347A7B038031BD00003D05, + 9D347A7D038031BE00003D05, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9D347A680380312200003D05 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9D347A690380312200003D05 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9D347A6A0380312200003D05 = { + buildPhases = ( + 9D347A660380312200003D05, + 9D347A670380312200003D05, + 9D347A680380312200003D05, + 9D347A690380312200003D05, + ); + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 163; + INSTALL_PATH = /usr/local/lib; + LIBRARY_STYLE = STATIC; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOL_FLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = libCdsaUtils.a; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + ); + isa = PBXLibraryTarget; + name = libCdsaUtils; + productInstallPath = /usr/local/lib; + productName = libCdsaUtils; + productReference = 9D347A6B0380312200003D05; }; - 52BFC306007A6A1B7F000001 = { - isa = PBXFileReference; - name = rc4_skey.c; - path = misc/rc4_skey.c; - refType = 4; + 9D347A6B0380312200003D05 = { + isa = PBXLibraryReference; + path = libCdsaUtils.a; + refType = 3; }; - 52BFC307007A6A1B7F000001 = { + 9D347A6D038031AF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = rc4Context.cpp; - path = MiscCSPAlgs/rc4Context.cpp; + path = cuDbUtils.cpp; refType = 4; }; - 52BFC308007A6A1B7F000001 = { + 9D347A6E038031AF00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = rc4Context.h; - path = MiscCSPAlgs/rc4Context.h; + path = cuDbUtils.h; refType = 4; }; - 52BFC30A007A6A1B7F000001 = { - fileRef = 52BFC308007A6A1B7F000001; + 9D347A6F038031AF00003D05 = { + fileRef = 9D347A6D038031AF00003D05; isa = PBXBuildFile; settings = { }; }; - 52BFC30C007A6A1B7F000001 = { - fileRef = 52BFC306007A6A1B7F000001; + 9D347A70038031AF00003D05 = { + fileRef = 9D347A6E038031AF00003D05; isa = PBXBuildFile; settings = { }; }; - 52BFC30D007A6A1B7F000001 = { - fileRef = 52BFC307007A6A1B7F000001; + 9D347A71038031B800003D05 = { + fileRef = 9DC1DEFC0299BC7F00003D05; isa = PBXBuildFile; settings = { }; }; -//520 -//521 -//522 -//523 -//524 -//570 -//571 -//572 -//573 -//574 - 57FCEE8B007A7B2F7F000001 = { - isa = PBXFileReference; - name = rc4_enc.c; - path = misc/rc4_enc.c; - refType = 4; - }; - 57FCEE8C007A7B2F7F000001 = { - fileRef = 57FCEE8B007A7B2F7F000001; + 9D347A72038031B800003D05 = { + fileRef = 9DC1DEFD0299BC7F00003D05; isa = PBXBuildFile; settings = { }; }; - 57FCEE8D007B8B3D7F000001 = { - children = ( - 57FCEE8E007B8B3D7F000001, - 57FCEE8F007B8B3D7F000001, - 57FCEE9C007B8D4F7F000001, - ); - isa = PBXGroup; - name = ComCryption; - refType = 4; - }; - 57FCEE8E007B8B3D7F000001 = { - isa = PBXFileReference; - name = ascContext.cpp; - path = ComCryption/ascContext.cpp; - refType = 4; - }; - 57FCEE8F007B8B3D7F000001 = { - isa = PBXFileReference; - name = ascContext.h; - path = ComCryption/ascContext.h; - refType = 4; - }; - 57FCEE95007B8B3D7F000001 = { - fileRef = 57FCEE8F007B8B3D7F000001; + 9D347A73038031B900003D05 = { + fileRef = 9DC1DEFE0299BC7F00003D05; isa = PBXBuildFile; settings = { }; }; - 57FCEE99007B8B3D7F000001 = { - fileRef = 57FCEE8E007B8B3D7F000001; + 9D347A74038031B900003D05 = { + fileRef = 9DC1DEFF0299BC7F00003D05; isa = PBXBuildFile; settings = { }; }; - 57FCEE9C007B8D4F7F000001 = { - isa = PBXFileReference; - name = ascFactory.h; - path = ComCryption/ascFactory.h; - refType = 4; - }; - 57FCEE9D007B8D4F7F000001 = { - fileRef = 57FCEE9C007B8D4F7F000001; + 9D347A75038031BA00003D05 = { + fileRef = 9DC1DF050299BC9500003D05; isa = PBXBuildFile; settings = { }; }; -//570 -//571 -//572 -//573 -//574 -//590 -//591 -//592 -//593 -//594 - 59375E6B00A848827F000001 = { - isa = PBXFileReference; - name = MD2Object.h; - path = MiscCSPAlgs/MD2Object.h; - refType = 4; - }; - 59375E6C00A848827F000001 = { - fileRef = 59375E6B00A848827F000001; + 9D347A76038031BA00003D05 = { + fileRef = 9DC1DF060299BC9500003D05; isa = PBXBuildFile; settings = { }; }; - 59375E6D00A849237F000001 = { - isa = PBXFileReference; - name = md2_dgst.c; - path = misc/md2_dgst.c; - refType = 4; - }; - 59375E6E00A849237F000001 = { - isa = PBXFileReference; - name = md2.h; - path = openssl/md2.h; - refType = 4; - }; - 59375E6F00A849237F000001 = { - fileRef = 59375E6E00A849237F000001; + 9D347A77038031BB00003D05 = { + fileRef = 9DC1DF070299BC9500003D05; isa = PBXBuildFile; settings = { }; }; - 59375E7000A849237F000001 = { - fileRef = 59375E6D00A849237F000001; + 9D347A78038031BB00003D05 = { + fileRef = 9DC1DF080299BC9500003D05; isa = PBXBuildFile; settings = { }; }; - 59375E7100A849BB7F000001 = { - isa = PBXFileReference; - name = MD2Object.cpp; - path = MiscCSPAlgs/MD2Object.cpp; - refType = 4; - }; - 59375E7200A849BB7F000001 = { - fileRef = 59375E7100A849BB7F000001; + 9D347A79038031BC00003D05 = { + fileRef = 9DC1DF090299BC9500003D05; isa = PBXBuildFile; settings = { }; }; -//590 -//591 -//592 -//593 -//594 -//5B0 -//5B1 -//5B2 -//5B3 -//5B4 - 5BA4A42D01F4E3F504CA2E82 = { - isa = PBXFileReference; - path = Identity.cpp; - refType = 4; - }; - 5BA4A42E01F4E3F504CA2E82 = { - isa = PBXFileReference; - path = Identity.h; - refType = 4; - }; - 5BA4A43101F4E3F604CA2E82 = { - fileRef = 5BA4A42E01F4E3F504CA2E82; + 9D347A7A038031BC00003D05 = { + fileRef = 9DC1DF0A0299BC9500003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 5BA4A43301F4E3F604CA2E82 = { - fileRef = 5BA4A42D01F4E3F504CA2E82; + 9D347A7B038031BD00003D05 = { + fileRef = 9DC1DF0B0299BC9500003D05; isa = PBXBuildFile; settings = { }; }; -//5B0 -//5B1 -//5B2 -//5B3 -//5B4 -//630 -//631 -//632 -//633 -//634 - 63B97E6600603F0A7F000001 = { - isa = PBXFileReference; - path = CryptKitDER.cpp; - refType = 4; - }; - 63B97E6700603F0B7F000001 = { - fileRef = 63B97E6600603F0A7F000001; + 9D347A7C038031BE00003D05 = { + fileRef = 9DC1DF0C0299BC9500003D05; isa = PBXBuildFile; settings = { }; }; -//630 -//631 -//632 -//633 -//634 -//8F0 -//8F1 -//8F2 -//8F3 -//8F4 - 8F7ACD2A02357F2503CA2E8C = { - isa = PBXFileReference; - path = SecACL.h; - refType = 4; - }; - 8F7ACD2B02357F2503CA2E8C = { - isa = PBXFileReference; - path = SecACL.cpp; - refType = 4; - }; - 8F7ACD2C02357F2503CA2E8C = { - fileRef = 8F7ACD2A02357F2503CA2E8C; + 9D347A7D038031BE00003D05 = { + fileRef = 9DC1DF0D0299BC9500003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 8F7ACD2D02357F2503CA2E8C = { - fileRef = 8F7ACD2B02357F2503CA2E8C; + 9D347A7E038031BE00003D05 = { + fileRef = 9DC1DF0E0299BC9500003D05; isa = PBXBuildFile; settings = { }; }; - 8F7ACD300235805903CA2E8C = { - isa = PBXFileReference; - path = ACL.h; - refType = 4; - }; - 8F7ACD310235805903CA2E8C = { - isa = PBXFileReference; - path = ACL.cpp; - refType = 4; - }; - 8F7ACD320235805903CA2E8C = { - fileRef = 8F7ACD300235805903CA2E8C; + 9D347A7F038031F000003D05 = { + fileRef = 9DC1DEFD0299BC7F00003D05; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -14270,64 +15109,44 @@ ); }; }; - 8F7ACD330235805903CA2E8C = { - fileRef = 8F7ACD310235805903CA2E8C; - isa = PBXBuildFile; - settings = { - }; - }; -//8F0 -//8F1 -//8F2 -//8F3 -//8F4 -//9D0 -//9D1 -//9D2 -//9D3 -//9D4 - 9D09B90701B4314500003D05 = { - isa = PBXFileReference; - path = tp_policyOids.mdsinfo; - refType = 4; - }; - 9D09B90801B4314500003D05 = { - fileRef = 9D09B90701B4314500003D05; + 9D347A80038031F100003D05 = { + fileRef = 9D347A6E038031AF00003D05; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D103F9F01AC72C200003D05 = { - fileRef = 9DAE2E2A01A2F93200003D05; + 9D347A81038031F200003D05 = { + fileRef = 9DC1DEFF0299BC7F00003D05; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D103FA001AC72C200003D05 = { - fileRef = 9DAE2E2901A2F93200003D05; + 9D347A82038031F300003D05 = { + fileRef = 9DC1DF060299BC9500003D05; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D14AC52020093D100003D05 = { - isa = PBXFileReference; - path = tpCredRequest.cpp; - refType = 4; - }; - 9D14AC53020093D100003D05 = { - fileRef = 9D14AC52020093D100003D05; + 9D347A83038031F400003D05 = { + fileRef = 9DC1DF080299BC9500003D05; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D1DEC190198777400003D05 = { - isa = PBXFileReference; - name = MDSAttrStrings.h; - path = cdsa/mds/MDSAttrStrings.h; - refType = 4; - }; - 9D1DEC1A0198777400003D05 = { - fileRef = 9D1DEC190198777400003D05; + 9D347A84038031F500003D05 = { + fileRef = 9DC1DF0A0299BC9500003D05; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -14335,249 +15154,299 @@ ); }; }; - 9D1DEC1B0198796200003D05 = { - isa = PBXFileReference; - name = MDSAttrStrings.cpp; - path = cdsa/mds/MDSAttrStrings.cpp; - refType = 2; - }; - 9D1DEC1C0198796200003D05 = { - fileRef = 9D1DEC1B0198796200003D05; + 9D347A85038031F600003D05 = { + fileRef = 9DC1DF0C0299BC9500003D05; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D206AA601EB68F200003D05 = { - isa = PBXFileReference; - name = NullCryptor.h; - path = MiscCSPAlgs/NullCryptor.h; - refType = 4; - }; - 9D206AA701EB68F200003D05 = { - fileRef = 9D206AA601EB68F200003D05; + 9D347A86038031F700003D05 = { + fileRef = 9DC1DF0E0299BC9500003D05; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D291872026B4FF900003D05 = { - children = ( - 9D291875026B502600003D05, - 9D291876026B502600003D05, - 9D291877026B502600003D05, - 9D291878026B502600003D05, - 9D291879026B502600003D05, + 9D347A870380359B00003D05 = { + buildActionMask = 2147483647; + files = ( + 9D347A9B0380364500003D05, ); - isa = PBXGroup; - name = dh; - refType = 4; + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 9D291875026B502600003D05 = { - isa = PBXFileReference; - name = dh_check.c; - path = dh/dh_check.c; - refType = 4; + 9D347A880380359B00003D05 = { + buildActionMask = 2147483647; + files = ( + 9D347A990380364500003D05, + 9D347A9A0380364500003D05, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 9D291876026B502600003D05 = { - isa = PBXFileReference; - name = dh_err.c; - path = dh/dh_err.c; - refType = 4; + 9D347A890380359B00003D05 = { + buildActionMask = 2147483647; + files = ( + 9D347A9C0380364B00003D05, + 9D347A9D0380364D00003D05, + 9D347A9E0380364E00003D05, + 9D347AA2038036DC00003D05, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 9D291877026B502600003D05 = { + 9D347A8A0380359B00003D05 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9D347A8B0380359B00003D05 = { + buildPhases = ( + 9D347A870380359B00003D05, + 9D347A880380359B00003D05, + 9D347A890380359B00003D05, + 9D347A8A0380359B00003D05, + ); + buildSettings = { + HEADER_SEARCH_PATHS = "\"$(SRCROOT)\""; + INSTALL_PATH = /usr/bin; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = crlrefresh; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + 9D347AA00380365F00003D05, + ); + isa = PBXToolTarget; + name = CrlRefresh; + productInstallPath = /usr/bin; + productName = CrlRefresh; + productReference = 9D347A8C0380359B00003D05; + }; + 9D347A8C0380359B00003D05 = { + isa = PBXExecutableFileReference; + path = crlrefresh; + refType = 3; + }; + 9D347A8E0380360000003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = dh_gen.c; - path = dh/dh_gen.c; + name = CertTool.cpp; + path = CertTool/CertTool.cpp; refType = 4; }; - 9D291878026B502600003D05 = { + 9D347A8F0380360000003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = dh_key.c; - path = dh/dh_key.c; + name = CertUI.cpp; + path = CertTool/CertUI.cpp; refType = 4; }; - 9D291879026B502600003D05 = { + 9D347A900380360000003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = dh_lib.c; - path = dh/dh_lib.c; + name = CertUI.h; + path = CertTool/CertUI.h; refType = 4; }; - 9D29187A026B502600003D05 = { - fileRef = 9D291875026B502600003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9D29187B026B502600003D05 = { - fileRef = 9D291876026B502600003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9D29187C026B502600003D05 = { - fileRef = 9D291877026B502600003D05; + 9D347A910380360000003D05 = { + fileRef = 9D347A8E0380360000003D05; isa = PBXBuildFile; settings = { }; }; - 9D29187D026B502600003D05 = { - fileRef = 9D291878026B502600003D05; + 9D347A920380360000003D05 = { + fileRef = 9D347A8F0380360000003D05; isa = PBXBuildFile; settings = { }; }; - 9D29187E026B502600003D05 = { - fileRef = 9D291879026B502600003D05; + 9D347A930380360000003D05 = { + fileRef = 9D347A900380360000003D05; isa = PBXBuildFile; settings = { }; }; - 9D29187F026B504700003D05 = { - isa = PBXFileReference; - name = dh.h; - path = openssl/dh.h; - refType = 4; - }; - 9D291880026B504700003D05 = { - fileRef = 9D29187F026B504700003D05; + 9D347A940380361A00003D05 = { + fileRef = 9D347A6B0380312200003D05; isa = PBXBuildFile; settings = { }; }; - 9D291881026B56B800003D05 = { + 9D347A950380362500003D05 = { children = ( - 9D291882026B56DA00003D05, - 9D291883026B56DA00003D05, - 9D291884026B56DA00003D05, - 9D291885026B56DA00003D05, - 9D291886026B56DA00003D05, - 9D291887026B56DA00003D05, - 9D29188E026B8BBD00003D05, - 9D29188F026B8BBD00003D05, + 9D347A960380364500003D05, + 9D347A970380364500003D05, + 9D347A980380364500003D05, ); isa = PBXGroup; - name = DiffieHellman; - path = AppleCSP; - refType = 2; - }; - 9D291882026B56DA00003D05 = { - isa = PBXFileReference; - name = DH_csp.cpp; - path = DiffieHellman/DH_csp.cpp; - refType = 4; - }; - 9D291883026B56DA00003D05 = { - isa = PBXFileReference; - name = DH_csp.h; - path = DiffieHellman/DH_csp.h; - refType = 4; - }; - 9D291884026B56DA00003D05 = { - isa = PBXFileReference; - name = DH_exchange.cpp; - path = DiffieHellman/DH_exchange.cpp; + name = CrlRefresh; + path = ""; refType = 4; }; - 9D291885026B56DA00003D05 = { + 9D347A960380364500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = DH_exchange.h; - path = DiffieHellman/DH_exchange.h; + name = crlRefresh.cpp; + path = CrlRefresh/crlRefresh.cpp; refType = 4; }; - 9D291886026B56DA00003D05 = { + 9D347A970380364500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = DH_keys.cpp; - path = DiffieHellman/DH_keys.cpp; + name = ldapFetch.cpp; + path = CrlRefresh/ldapFetch.cpp; refType = 4; }; - 9D291887026B56DA00003D05 = { + 9D347A980380364500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = DH_keys.h; - path = DiffieHellman/DH_keys.h; + name = ldapFetch.h; + path = CrlRefresh/ldapFetch.h; refType = 4; }; - 9D291888026B56DA00003D05 = { - fileRef = 9D291882026B56DA00003D05; + 9D347A990380364500003D05 = { + fileRef = 9D347A960380364500003D05; isa = PBXBuildFile; settings = { }; }; - 9D291889026B56DA00003D05 = { - fileRef = 9D291883026B56DA00003D05; + 9D347A9A0380364500003D05 = { + fileRef = 9D347A970380364500003D05; isa = PBXBuildFile; settings = { }; }; - 9D29188A026B56DA00003D05 = { - fileRef = 9D291884026B56DA00003D05; + 9D347A9B0380364500003D05 = { + fileRef = 9D347A980380364500003D05; isa = PBXBuildFile; settings = { }; }; - 9D29188B026B56DA00003D05 = { - fileRef = 9D291885026B56DA00003D05; + 9D347A9C0380364B00003D05 = { + fileRef = 9D347A5F0380300100003D05; isa = PBXBuildFile; settings = { }; }; - 9D29188C026B56DA00003D05 = { - fileRef = 9D291886026B56DA00003D05; + 9D347A9D0380364D00003D05 = { + fileRef = 125E85ADFFF3D44A11CD283A; isa = PBXBuildFile; settings = { }; }; - 9D29188D026B56DA00003D05 = { - fileRef = 9D291887026B56DA00003D05; + 9D347A9E0380364E00003D05 = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 9D29188E026B8BBD00003D05 = { - isa = PBXFileReference; - name = DH_utils.cpp; - path = DiffieHellman/DH_utils.cpp; - refType = 4; + 9D347A9F0380365900003D05 = { + isa = PBXTargetDependency; + target = 9D347A6A0380312200003D05; }; - 9D29188F026B8BBD00003D05 = { - isa = PBXFileReference; - name = DH_utils.h; - path = DiffieHellman/DH_utils.h; - refType = 4; + 9D347AA00380365F00003D05 = { + isa = PBXTargetDependency; + target = 9D347A6A0380312200003D05; }; - 9D291890026B8BBD00003D05 = { - fileRef = 9D29188E026B8BBD00003D05; - isa = PBXBuildFile; - settings = { - }; + 9D347AA10380366700003D05 = { + isa = PBXTargetDependency; + target = 9D347A8B0380359B00003D05; }; - 9D291891026B8BBD00003D05 = { - fileRef = 9D29188F026B8BBD00003D05; + 9D347AA2038036DC00003D05 = { + fileRef = 9D347A6B0380312200003D05; isa = PBXBuildFile; settings = { }; }; - 9D2C3D0001C826C800003D05 = { - isa = PBXFileReference; - path = gladmanContext.h; + 9D384F850301AF8C00003D05 = { + children = ( + 9D384F870301AFC700003D05, + 9D384F860301AFBC00003D05, + 01FA812EFFF2B54C11CD283A, + 01FA815CFFF2B54C11CD283A, + 01FA815FFFF2B54C11CD283A, + 01FA8163FFF2B54C11CD283A, + 01FA8164FFF2B54C11CD283A, + 01FA8165FFF2B54C11CD283A, + 9D78BC7801EBCA2300003D05, + 9D78BC7A01ECA79D00003D05, + ); + isa = PBXGroup; + name = "SSL Core"; + refType = 4; + }; + 9D384F860301AFBC00003D05 = { + children = ( + 01FA815BFFF2B54C11CD283A, + 01FA8158FFF2B54C11CD283A, + 01FA8159FFF2B54C11CD283A, + 01FA815AFFF2B54C11CD283A, + ); + isa = PBXGroup; + name = SSL2; + refType = 4; + }; + 9D384F870301AFC700003D05 = { + children = ( + 01FA812FFFF2B54C11CD283A, + 01FA8130FFF2B54C11CD283A, + 01FA812DFFF2B54C11CD283A, + 01FA8132FFF2B54C11CD283A, + 01FA8161FFF2B54C11CD283A, + ); + isa = PBXGroup; + name = Handshake; + refType = 4; + }; + 9D384F880301AFD800003D05 = { + children = ( + 01FA8135FFF2B54C11CD283A, + 01FA8127FFF2B54C11CD283A, + 01FA8129FFF2B54C11CD283A, + 01FA8162FFF2B54C11CD283A, + ); + isa = PBXGroup; + name = "Apple Custom"; refType = 4; }; - 9D2C3D0101C826C800003D05 = { - fileRef = 9D2C3D0001C826C800003D05; - isa = PBXBuildFile; - settings = { - }; + 9D384F890301AFEC00003D05 = { + children = ( + 01FA8167FFF2B54C11CD283A, + 9D78BC7401EBB71A00003D05, + 01FA812CFFF2B54C11CD283A, + 01FA812AFFF2B54C11CD283A, + 01FA8137FFF2B54C11CD283A, + ); + isa = PBXGroup; + name = Crypto; + path = ""; + refType = 2; }; - 9D2C3D0201C82F6000003D05 = { - isa = PBXFileReference; - path = aesCommon.h; + 9D384F8A0301B01900003D05 = { + children = ( + 01FA8152FFF2B54C11CD283A, + 01FA8166FFF2B54C11CD283A, + 01FA815DFFF2B54C11CD283A, + 01FA815EFFF2B54C11CD283A, + ); + isa = PBXGroup; + name = Misc.; refType = 4; }; - 9D2C3D0301C82F6100003D05 = { - fileRef = 9D2C3D0201C82F6000003D05; - isa = PBXBuildFile; - settings = { - }; - }; 9D4B1BC70156C2E500A17CD1 = { + fileEncoding = 30; isa = PBXFileReference; path = tpCertGroup.cpp; refType = 4; @@ -14612,42 +15481,49 @@ refType = 2; }; 9D518683018F27B400003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = mdsapi.cpp; path = cdsa/mds/mdsapi.cpp; refType = 4; }; 9D518686018F27B400003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = MDSModule.cpp; path = cdsa/mds/MDSModule.cpp; refType = 4; }; 9D518687018F27B400003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = MDSModule.h; path = cdsa/mds/MDSModule.h; refType = 4; }; 9D518688018F27B400003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = MDSSchema.cpp; path = cdsa/mds/MDSSchema.cpp; refType = 4; }; 9D518689018F27B400003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = MDSSchema.h; path = cdsa/mds/MDSSchema.h; refType = 4; }; 9D51868A018F27B400003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = MDSSession.cpp; path = cdsa/mds/MDSSession.cpp; refType = 4; }; 9D51868B018F27B400003D05 = { + fileEncoding = 30; isa = PBXFileReference; name = MDSSession.h; path = cdsa/mds/MDSSession.h; @@ -14680,855 +15556,1182 @@ ); }; }; - 9D518690018F27B500003D05 = { - fileRef = 9D518683018F27B400003D05; + 9D518690018F27B500003D05 = { + fileRef = 9D518683018F27B400003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D518692018F27B500003D05 = { + fileRef = 9D518686018F27B400003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D518693018F27B500003D05 = { + fileRef = 9D518688018F27B400003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D518694018F27B500003D05 = { + fileRef = 9D51868A018F27B400003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D64BAE9019AF3B800003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MDSAttrUtils.cpp; + path = cdsa/mds/MDSAttrUtils.cpp; + refType = 4; + }; + 9D64BAEA019AF3B800003D05 = { + fileRef = 9D64BAE9019AF3B800003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D64BAEB019AFD7900003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MDSDictionary.h; + path = cdsa/mds/MDSDictionary.h; + refType = 4; + }; + 9D64BAEC019AFD7900003D05 = { + fileRef = 9D64BAEB019AFD7900003D05; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 9D64BAED019AFE3600003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MDSDictionary.cpp; + path = cdsa/mds/MDSDictionary.cpp; + refType = 4; + }; + 9D64BAEE019AFE3700003D05 = { + fileRef = 9D64BAED019AFE3600003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D64BAEF019B173900003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cssm.mdsinfo; + refType = 4; + }; + 9D64BAF0019B173900003D05 = { + fileRef = 9D64BAEF019B173900003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D64BAF1019B176100003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = csp_capabilities.mdsinfo; + refType = 4; + }; + 9D64BAF2019B176100003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = csp_common.mdsinfo; + refType = 4; + }; + 9D64BAF3019B176100003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = csp_primary.mdsinfo; + refType = 4; + }; + 9D64BAF4019B176200003D05 = { + fileRef = 9D64BAF1019B176100003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D64BAF5019B176200003D05 = { + fileRef = 9D64BAF2019B176100003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D64BAF6019B176200003D05 = { + fileRef = 9D64BAF3019B176100003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D69C0260198A8E000003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MDSAttrParser.h; + path = cdsa/mds/MDSAttrParser.h; + refType = 4; + }; + 9D69C0270198A8E100003D05 = { + fileRef = 9D69C0260198A8E000003D05; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 9D69C0280198AB3700003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MDSAttrParser.cpp; + path = cdsa/mds/MDSAttrParser.cpp; + refType = 4; + }; + 9D69C0290198AB3700003D05 = { + fileRef = 9D69C0280198AB3700003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D69C02A019AF15E00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = MDSAttrUtils.h; + path = cdsa/mds/MDSAttrUtils.h; + refType = 4; + }; + 9D69C02B019AF15E00003D05 = { + fileRef = 9D69C02A019AF15E00003D05; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 9D78BC7201EBB3F900003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = tls_hmac.h; + refType = 4; + }; + 9D78BC7301EBB3F900003D05 = { + fileRef = 9D78BC7201EBB3F900003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D78BC7401EBB71A00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + name = tls_hmac.cpp; + path = SecureTransport/tls_hmac.cpp; + refType = 4; + }; + 9D78BC7501EBB71A00003D05 = { + fileRef = 9D78BC7401EBB71A00003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D78BC7601EBBBED00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = tls_ssl.h; + refType = 4; + }; + 9D78BC7701EBBBED00003D05 = { + fileRef = 9D78BC7601EBBBED00003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D78BC7801EBCA2300003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = ssl3Callouts.cpp; + refType = 4; + }; + 9D78BC7901EBCA2400003D05 = { + fileRef = 9D78BC7801EBCA2300003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D78BC7A01ECA79D00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = tls1Callouts.cpp; + refType = 4; + }; + 9D78BC7B01ECA79D00003D05 = { + fileRef = 9D78BC7A01ECA79D00003D05; + isa = PBXBuildFile; + settings = { + }; + }; + 9D8B6A2A015A48F500A17CD1 = { + fileEncoding = 30; + isa = PBXFileReference; + path = digestobject.h; + refType = 4; + }; + 9D8B6A2B015A48F500A17CD1 = { + fileRef = 9D8B6A2A015A48F500A17CD1; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 9D8F0D1D01C80C0C00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = gladmanContext.cpp; + refType = 4; + }; + 9D8F0D1E01C80C0C00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rijndaelGladman.c; + refType = 4; + }; + 9D8F0D1F01C80C0C00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rijndaelGladman.h; + refType = 4; + }; + 9D8F0D2001C80C0C00003D05 = { + fileRef = 9D8F0D1F01C80C0C00003D05; isa = PBXBuildFile; settings = { }; }; - 9D518692018F27B500003D05 = { - fileRef = 9D518686018F27B400003D05; + 9D8F0D2901C815A600003D05 = { + fileRef = 9D8F0D1F01C80C0C00003D05; isa = PBXBuildFile; settings = { }; }; - 9D518693018F27B500003D05 = { - fileRef = 9D518688018F27B400003D05; + 9D8F0D2A01C815A600003D05 = { + fileRef = 9D8F0D1D01C80C0C00003D05; isa = PBXBuildFile; settings = { }; }; - 9D518694018F27B500003D05 = { - fileRef = 9D51868A018F27B400003D05; + 9D8F0D2B01C815A600003D05 = { + fileRef = 9D8F0D1E01C80C0C00003D05; isa = PBXBuildFile; settings = { }; }; - 9D64BAE9019AF3B800003D05 = { + 9D9AEFBA02B6BC6C00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = MDSAttrUtils.cpp; - path = cdsa/mds/MDSAttrUtils.cpp; + path = rootCerts.cpp; refType = 4; }; - 9D64BAEA019AF3B800003D05 = { - fileRef = 9D64BAE9019AF3B800003D05; + 9D9AEFBB02B6BC6C00003D05 = { + fileRef = 9D9AEFBA02B6BC6C00003D05; isa = PBXBuildFile; settings = { }; }; - 9D64BAEB019AFD7900003D05 = { + 9DA13D0401B4638200003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = MDSDictionary.h; - path = cdsa/mds/MDSDictionary.h; + path = csp_capabilities_common.mds; refType = 4; }; - 9D64BAEC019AFD7900003D05 = { - fileRef = 9D64BAEB019AFD7900003D05; + 9DA13D0501B4638200003D05 = { + fileRef = 9DA13D0401B4638200003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 9D64BAED019AFE3600003D05 = { + 9DAE2E2501A2E63700003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = MDSDictionary.cpp; - path = cdsa/mds/MDSDictionary.cpp; + path = cl_primary.mdsinfo; refType = 4; }; - 9D64BAEE019AFE3700003D05 = { - fileRef = 9D64BAED019AFE3600003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9D64BAEF019B173900003D05 = { + 9DAE2E2601A2E63700003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = cssm.mdsinfo; + path = cl_common.mdsinfo; refType = 4; }; - 9D64BAF0019B173900003D05 = { - fileRef = 9D64BAEF019B173900003D05; + 9DAE2E2701A2E63800003D05 = { + fileRef = 9DAE2E2601A2E63700003D05; isa = PBXBuildFile; settings = { }; }; - 9D64BAF1019B176100003D05 = { - isa = PBXFileReference; - path = csp_capabilities.mdsinfo; - refType = 4; + 9DAE2E2801A2E63800003D05 = { + fileRef = 9DAE2E2501A2E63700003D05; + isa = PBXBuildFile; + settings = { + }; }; - 9D64BAF2019B176100003D05 = { + 9DAE2E2901A2F93200003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = csp_common.mdsinfo; + path = tp_common.mdsinfo; refType = 4; }; - 9D64BAF3019B176100003D05 = { + 9DAE2E2A01A2F93200003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = csp_primary.mdsinfo; + path = tp_primary.mdsinfo; refType = 4; }; - 9D64BAF4019B176200003D05 = { - fileRef = 9D64BAF1019B176100003D05; + 9DAE2E2B01A2F93200003D05 = { + fileRef = 9DAE2E2901A2F93200003D05; isa = PBXBuildFile; settings = { }; }; - 9D64BAF5019B176200003D05 = { - fileRef = 9D64BAF2019B176100003D05; + 9DAE2E2C01A2F93200003D05 = { + fileRef = 9DAE2E2A01A2F93200003D05; isa = PBXBuildFile; settings = { }; }; - 9D64BAF6019B176200003D05 = { - fileRef = 9D64BAF3019B176100003D05; - isa = PBXBuildFile; - settings = { - }; + 9DAE2E2D01A3378900003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = dl_common.mdsinfo; + refType = 4; }; - 9D69C0260198A8E000003D05 = { + 9DAE2E2E01A3378900003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = MDSAttrParser.h; - path = cdsa/mds/MDSAttrParser.h; + path = dl_primary.mdsinfo; refType = 4; }; - 9D69C0270198A8E100003D05 = { - fileRef = 9D69C0260198A8E000003D05; + 9DAE2E2F01A3378A00003D05 = { + fileRef = 9DAE2E2D01A3378900003D05; isa = PBXBuildFile; settings = { - ATTRIBUTES = ( - Private, - ); }; }; - 9D69C0280198AB3700003D05 = { - isa = PBXFileReference; - name = MDSAttrParser.cpp; - path = cdsa/mds/MDSAttrParser.cpp; - refType = 4; - }; - 9D69C0290198AB3700003D05 = { - fileRef = 9D69C0280198AB3700003D05; + 9DAE2E3001A3378A00003D05 = { + fileRef = 9DAE2E2E01A3378900003D05; isa = PBXBuildFile; settings = { }; }; - 9D69C02A019AF15E00003D05 = { + 9DAE2E3201A43D6B00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - name = MDSAttrUtils.h; - path = cdsa/mds/MDSAttrUtils.h; + path = cspdl_common.mdsinfo; refType = 4; }; - 9D69C02B019AF15E00003D05 = { - fileRef = 9D69C02A019AF15E00003D05; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 9DAE2E3301A43D6B00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cspdl_csp_capabilities.mdsinfo; + refType = 4; }; - 9D78BC7201EBB3F900003D05 = { + 9DAE2E3401A43D6B00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = tls_hmac.h; + path = cspdl_csp_primary.mdsinfo; refType = 4; }; - 9D78BC7301EBB3F900003D05 = { - fileRef = 9D78BC7201EBB3F900003D05; + 9DAE2E3501A43D6B00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cspdl_dl_primary.mdsinfo; + refType = 4; + }; + 9DAE2E3601A43D6B00003D05 = { + fileRef = 9DAE2E3201A43D6B00003D05; isa = PBXBuildFile; settings = { }; }; - 9D78BC7401EBB71A00003D05 = { - isa = PBXFileReference; - path = tls_hmac.cpp; - refType = 4; - }; - 9D78BC7501EBB71A00003D05 = { - fileRef = 9D78BC7401EBB71A00003D05; + 9DAE2E3701A43D6B00003D05 = { + fileRef = 9DAE2E3301A43D6B00003D05; isa = PBXBuildFile; settings = { }; }; - 9D78BC7601EBBBED00003D05 = { - isa = PBXFileReference; - path = tls_ssl.h; - refType = 4; + 9DAE2E3801A43D6B00003D05 = { + fileRef = 9DAE2E3401A43D6B00003D05; + isa = PBXBuildFile; + settings = { + }; }; - 9D78BC7701EBBBED00003D05 = { - fileRef = 9D78BC7601EBBBED00003D05; + 9DAE2E3901A43D6B00003D05 = { + fileRef = 9DAE2E3501A43D6B00003D05; isa = PBXBuildFile; settings = { }; }; - 9D78BC7801EBCA2300003D05 = { - isa = PBXFileReference; - path = ssl3Callouts.cpp; + 9DC1DEEC0299BB8F00003D05 = { + children = ( + 9D347A8E0380360000003D05, + 9D347A8F0380360000003D05, + 9D347A900380360000003D05, + 056015710461B87200D4A1BF, + ); + isa = PBXGroup; + name = CertTool; refType = 4; }; - 9D78BC7901EBCA2400003D05 = { - fileRef = 9D78BC7801EBCA2300003D05; - isa = PBXBuildFile; - settings = { + 9DC1DEEE0299BBA900003D05 = { + children = ( + 9DC1DEFC0299BC7F00003D05, + 9DC1DEFD0299BC7F00003D05, + 9D347A6D038031AF00003D05, + 9D347A6E038031AF00003D05, + 9DC1DEFE0299BC7F00003D05, + 9DC1DEFF0299BC7F00003D05, + 9DC1DF050299BC9500003D05, + 9DC1DF060299BC9500003D05, + 9DC1DF070299BC9500003D05, + 9DC1DF080299BC9500003D05, + 9DC1DF090299BC9500003D05, + 9DC1DF0A0299BC9500003D05, + 9DC1DF0B0299BC9500003D05, + 9DC1DF0C0299BC9500003D05, + 9DC1DF0D0299BC9500003D05, + 9DC1DF0E0299BC9500003D05, + ); + isa = PBXGroup; + path = CdsaUtils; + refType = 4; + }; + 9DC1DEEF0299BBCD00003D05 = { + buildActionMask = 2147483647; + files = ( + 9D347A930380360000003D05, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9DC1DEF00299BBCD00003D05 = { + buildActionMask = 2147483647; + files = ( + 9D347A910380360000003D05, + 9D347A920380360000003D05, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9DC1DEF10299BBCD00003D05 = { + buildActionMask = 2147483647; + files = ( + 9DC1DF100299BD8500003D05, + 9DC1DF110299BD8C00003D05, + 9D347A940380361A00003D05, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9DC1DEF20299BBCD00003D05 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 9DC1DEF30299BBCD00003D05 = { + buildPhases = ( + 9DC1DEEF0299BBCD00003D05, + 9DC1DEF00299BBCD00003D05, + 9DC1DEF10299BBCD00003D05, + 9DC1DEF20299BBCD00003D05, + 056015700461B82B00D4A1BF, + ); + buildSettings = { + HEADER_SEARCH_PATHS = "\"$(SRCROOT)\" \"$(SRCROOT)/CertTool\""; + INSTALL_PATH = /usr/bin; + OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = certtool; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; + dependencies = ( + 9D347A9F0380365900003D05, + ); + isa = PBXToolTarget; + name = CertTool; + productInstallPath = ""; + productName = CertTool; + productReference = 9DC1DEF40299BBCD00003D05; }; - 9D78BC7A01ECA79D00003D05 = { + 9DC1DEF40299BBCD00003D05 = { + isa = PBXExecutableFileReference; + path = certtool; + refType = 3; + }; + 9DC1DEFC0299BC7F00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = tls1Callouts.cpp; + path = cuCdsaUtils.cpp; refType = 4; }; - 9D78BC7B01ECA79D00003D05 = { - fileRef = 9D78BC7A01ECA79D00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9D8B6A2A015A48F500A17CD1 = { + 9DC1DEFD0299BC7F00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = digestobject.h; + path = cuCdsaUtils.h; refType = 4; }; - 9D8B6A2B015A48F500A17CD1 = { - fileRef = 9D8B6A2A015A48F500A17CD1; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; - }; - 9D8F0D1D01C80C0C00003D05 = { + 9DC1DEFE0299BC7F00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = gladmanContext.cpp; + path = cuEnc64.c; refType = 4; }; - 9D8F0D1E01C80C0C00003D05 = { + 9DC1DEFF0299BC7F00003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = rijndaelGladman.c; + path = cuEnc64.h; refType = 4; }; - 9D8F0D1F01C80C0C00003D05 = { + 9DC1DF050299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = rijndaelGladman.h; + path = cuFileIo.c; refType = 4; }; - 9D8F0D2001C80C0C00003D05 = { - fileRef = 9D8F0D1F01C80C0C00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9D8F0D2901C815A600003D05 = { - fileRef = 9D8F0D1F01C80C0C00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9D8F0D2A01C815A600003D05 = { - fileRef = 9D8F0D1D01C80C0C00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9D8F0D2B01C815A600003D05 = { - fileRef = 9D8F0D1E01C80C0C00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9D98FF0C0371DDE400003D05 = { + 9DC1DF060299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = SecureTransportPriv.h; + path = cuFileIo.h; refType = 4; }; - 9D98FF0D0371DDE400003D05 = { + 9DC1DF070299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = sslAlertMessage.h; + path = cuOidParser.cpp; refType = 4; }; - 9D98FF0E0371DDE400003D05 = { + 9DC1DF080299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = sslContext.h; + path = cuOidParser.h; refType = 4; }; - 9D98FF0F0371DDE400003D05 = { + 9DC1DF090299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = sslDigests.h; + path = cuPem.cpp; refType = 4; }; - 9D98FF100371DDE400003D05 = { + 9DC1DF0A0299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = sslHandshake.h; + path = cuPem.h; refType = 4; }; - 9D98FF110371DDE400003D05 = { + 9DC1DF0B0299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = sslMemory.h; + path = cuPrintCert.cpp; refType = 4; }; - 9D98FF120371DDE400003D05 = { + 9DC1DF0C0299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = sslRecord.h; + path = cuPrintCert.h; refType = 4; }; - 9D98FF130371DDE400003D05 = { + 9DC1DF0D0299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = sslSession.h; + path = cuTimeStr.cpp; refType = 4; }; - 9D98FF140371DDE400003D05 = { + 9DC1DF0E0299BC9500003D05 = { + fileEncoding = 30; isa = PBXFileReference; - path = sslUtils.h; + path = cuTimeStr.h; refType = 4; }; - 9D98FF150371DDE400003D05 = { - fileRef = 9D98FF0C0371DDE400003D05; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; + 9DC1DF0F0299BCB400003D05 = { + isa = PBXTargetDependency; + target = 9DC1DEF30299BBCD00003D05; }; - 9D98FF160371DDE400003D05 = { - fileRef = 9D98FF0D0371DDE400003D05; + 9DC1DF100299BD8500003D05 = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 9D98FF170371DDE400003D05 = { - fileRef = 9D98FF0E0371DDE400003D05; + 9DC1DF110299BD8C00003D05 = { + fileRef = 125E85ADFFF3D44A11CD283A; isa = PBXBuildFile; settings = { }; }; - 9D98FF180371DDE400003D05 = { - fileRef = 9D98FF0F0371DDE400003D05; - isa = PBXBuildFile; - settings = { - }; + 9DD4620003119BCE00003D05 = { + fileEncoding = 30; + isa = PBXFileReference; + path = SecureTransportPriv.h; + refType = 4; }; - 9D98FF190371DDE400003D05 = { - fileRef = 9D98FF100371DDE400003D05; + 9DD4620103119BCE00003D05 = { + fileRef = 9DD4620003119BCE00003D05; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D98FF1A0371DDE400003D05 = { - fileRef = 9D98FF110371DDE400003D05; +//9D0 +//9D1 +//9D2 +//9D3 +//9D4 +//BD0 +//BD1 +//BD2 +//BD3 +//BD4 + BD6FEB7203A5642B03CA2E64 = { + fileEncoding = 30; + isa = PBXFileReference; + path = SecKeyPriv.h; + refType = 4; + }; + BD6FEB7303A5642B03CA2E64 = { + fileRef = BD6FEB7203A5642B03CA2E64; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D98FF1B0371DDE400003D05 = { - fileRef = 9D98FF120371DDE400003D05; +//BD0 +//BD1 +//BD2 +//BD3 +//BD4 +//C20 +//C21 +//C22 +//C23 +//C24 + C213880E0455C01F00CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = SecPolicyPriv.h; + refType = 4; + }; + C213880F0455C01F00CA2E77 = { + fileRef = C213880E0455C01F00CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D98FF1C0371DDE400003D05 = { - fileRef = 9D98FF130371DDE400003D05; + C2227D96044F404900CA2E77 = { + fileRef = F581A93B0316D96A01D50C4C; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9D98FF1D0371DDE400003D05 = { - fileRef = 9D98FF140371DDE400003D05; + C2227D97044F404900CA2E77 = { + fileRef = F52A2F160316DA1901D50C4C; isa = PBXBuildFile; settings = { }; }; - 9D9AEFBA02B6BC6C00003D05 = { - isa = PBXFileReference; - path = rootCerts.cpp; + C227CDC203E716B100CA2E77 = { + children = ( + C227CDC303E7170100CA2E77, + ); + isa = PBXGroup; + name = systemkeychain; + path = SecurityServer/StartupItems; refType = 4; }; - 9D9AEFBB02B6BC6C00003D05 = { - fileRef = 9D9AEFBA02B6BC6C00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9DA13D0401B4638200003D05 = { + C227CDC303E7170100CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = csp_capabilities_common.mds; - refType = 4; + name = systemkeychain.cpp; + path = SecurityServer/systemkeychain.cpp; + refType = 2; }; - 9DA13D0501B4638200003D05 = { - fileRef = 9DA13D0401B4638200003D05; - isa = PBXBuildFile; - settings = { - }; + C227CDC503E7171400CA2E77 = { + buildActionMask = 2147483647; + files = ( + C227CDD603E7424300CA2E77, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 9DAE2E2501A2E63700003D05 = { - isa = PBXFileReference; - path = cl_primary.mdsinfo; - refType = 4; + C227CDC603E7171400CA2E77 = { + buildActionMask = 2147483647; + files = ( + C227CDCD03E7175300CA2E77, + C227CDD503E7424200CA2E77, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 9DAE2E2601A2E63700003D05 = { - isa = PBXFileReference; - path = cl_common.mdsinfo; - refType = 4; + C227CDC703E7171400CA2E77 = { + buildActionMask = 2147483647; + files = ( + C227CDCE03E71AFB00CA2E77, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 9DAE2E2701A2E63800003D05 = { - fileRef = 9DAE2E2601A2E63700003D05; - isa = PBXBuildFile; - settings = { - }; + C227CDC803E7171400CA2E77 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; }; - 9DAE2E2801A2E63800003D05 = { - fileRef = 9DAE2E2501A2E63700003D05; - isa = PBXBuildFile; - settings = { + C227CDC903E7171400CA2E77 = { + buildPhases = ( + C227CDC503E7171400CA2E77, + C227CDC603E7171400CA2E77, + C227CDC703E7171400CA2E77, + C227CDC803E7171400CA2E77, + ); + buildSettings = { + INSTALL_PATH = /usr/sbin; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = systemkeychain; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; + dependencies = ( + ); + isa = PBXToolTarget; + name = systemkeychain; + productInstallPath = /usr/sbin; + productName = systemkeychain; + productReference = C227CDCA03E7171400CA2E77; }; - 9DAE2E2901A2F93200003D05 = { - isa = PBXFileReference; - path = tp_common.mdsinfo; - refType = 4; + C227CDCA03E7171400CA2E77 = { + isa = PBXExecutableFileReference; + path = systemkeychain; + refType = 3; }; - 9DAE2E2A01A2F93200003D05 = { - isa = PBXFileReference; - path = tp_primary.mdsinfo; - refType = 4; + C227CDCC03E7173300CA2E77 = { + isa = PBXTargetDependency; + target = C227CDC903E7171400CA2E77; }; - 9DAE2E2B01A2F93200003D05 = { - fileRef = 9DAE2E2901A2F93200003D05; + C227CDCD03E7175300CA2E77 = { + fileRef = C227CDC303E7170100CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DAE2E2C01A2F93200003D05 = { - fileRef = 9DAE2E2A01A2F93200003D05; + C227CDCE03E71AFB00CA2E77 = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 9DAE2E2D01A3378900003D05 = { - isa = PBXFileReference; - path = dl_common.mdsinfo; - refType = 4; - }; - 9DAE2E2E01A3378900003D05 = { - isa = PBXFileReference; - path = dl_primary.mdsinfo; - refType = 4; - }; - 9DAE2E2F01A3378A00003D05 = { - fileRef = 9DAE2E2D01A3378900003D05; + C227CDD503E7424200CA2E77 = { + fileRef = 01FA8224FFF2B54C11CD283A; isa = PBXBuildFile; settings = { }; }; - 9DAE2E3001A3378A00003D05 = { - fileRef = 9DAE2E2E01A3378900003D05; + C227CDD603E7424300CA2E77 = { + fileRef = 01FA8225FFF2B54C11CD283A; isa = PBXBuildFile; settings = { }; }; - 9DAE2E3201A43D6B00003D05 = { - isa = PBXFileReference; - path = cspdl_common.mdsinfo; - refType = 4; - }; - 9DAE2E3301A43D6B00003D05 = { - isa = PBXFileReference; - path = cspdl_csp_capabilities.mdsinfo; - refType = 4; - }; - 9DAE2E3401A43D6B00003D05 = { - isa = PBXFileReference; - path = cspdl_csp_primary.mdsinfo; - refType = 4; - }; - 9DAE2E3501A43D6B00003D05 = { + C244C1350479624A00CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - path = cspdl_dl_primary.mdsinfo; + path = SecTrustedApplicationPriv.h; refType = 4; }; - 9DAE2E3601A43D6B00003D05 = { - fileRef = 9DAE2E3201A43D6B00003D05; + C244C1360479624A00CA2E77 = { + fileRef = C244C1350479624A00CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9DAE2E3701A43D6B00003D05 = { - fileRef = 9DAE2E3301A43D6B00003D05; - isa = PBXBuildFile; - settings = { - }; + C25FA84C03CB687400CA2E77 = { + isa = PBXTargetDependency; + target = 0867D69CFE84028FC02AAC07; + }; + C25FA84D03CB689300CA2E77 = { + isa = PBXTargetDependency; + target = 01CE6B1DFFF2B33A11CD283A; + }; + C284B43E042F847900CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = AuthorizationPriv.h; + refType = 4; }; - 9DAE2E3801A43D6B00003D05 = { - fileRef = 9DAE2E3401A43D6B00003D05; + C284B43F042F847900CA2E77 = { + fileRef = C284B43E042F847900CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9DAE2E3901A43D6B00003D05 = { - fileRef = 9DAE2E3501A43D6B00003D05; + C284B440042F856A00CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = privPortClient.cpp; + refType = 4; + }; + C284B441042F856A00CA2E77 = { + fileRef = C284B440042F856A00CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DEEC0299BB8F00003D05 = { - children = ( - 9DC1DEED0299BB9E00003D05, - 9DC1DEEE0299BBA900003D05, - ); - isa = PBXGroup; - name = CertTool; - refType = 4; - }; - 9DC1DEED0299BB9E00003D05 = { - children = ( - 9DC1DEF60299BC6C00003D05, - 9DC1DEF70299BC6C00003D05, - 9DC1DEF80299BC6C00003D05, - ); - isa = PBXGroup; - name = CertTool; - refType = 4; - }; - 9DC1DEEE0299BBA900003D05 = { - children = ( - 9DC1DEFC0299BC7F00003D05, - 9DC1DEFD0299BC7F00003D05, - 9DC1DEFE0299BC7F00003D05, - 9DC1DEFF0299BC7F00003D05, - 9DC1DF050299BC9500003D05, - 9DC1DF060299BC9500003D05, - 9DC1DF070299BC9500003D05, - 9DC1DF080299BC9500003D05, - 9DC1DF090299BC9500003D05, - 9DC1DF0A0299BC9500003D05, - 9DC1DF0B0299BC9500003D05, - 9DC1DF0C0299BC9500003D05, - 9DC1DF0D0299BC9500003D05, - 9DC1DF0E0299BC9500003D05, - ); - isa = PBXGroup; - name = cdsaUtils; - path = ""; - refType = 4; - }; - 9DC1DEEF0299BBCD00003D05 = { + C2907DD0042BA6B100CA2E77 = { buildActionMask = 2147483647; files = ( - 9DC1DEFB0299BC6C00003D05, - 9DC1DF010299BC7F00003D05, - 9DC1DF030299BC7F00003D05, - 9DC1DF130299BDE300003D05, - 9DC1DF150299BDE400003D05, - 9DC1DF170299BDE600003D05, - 9DC1DF190299BDEA00003D05, - 9DC1DF1B0299BDEB00003D05, + C2A6D4E2042FC54000CA2E77, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 9DC1DEF00299BBCD00003D05 = { + C2907DD1042BA6B100CA2E77 = { buildActionMask = 2147483647; files = ( - 9DC1DEF90299BC6C00003D05, - 9DC1DEFA0299BC6C00003D05, - 9DC1DF000299BC7F00003D05, - 9DC1DF020299BC7F00003D05, - 9DC1DF120299BDE200003D05, - 9DC1DF140299BDE300003D05, - 9DC1DF160299BDE500003D05, - 9DC1DF180299BDE600003D05, - 9DC1DF1A0299BDEA00003D05, + C2907DD9042BA6F800CA2E77, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 9DC1DEF10299BBCD00003D05 = { + C2907DD2042BA6B100CA2E77 = { buildActionMask = 2147483647; files = ( - 9DC1DF100299BD8500003D05, - 9DC1DF110299BD8C00003D05, + C2907DDA042BA71700CA2E77, ); isa = PBXFrameworksBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 9DC1DEF20299BBCD00003D05 = { + C2907DD3042BA6B100CA2E77 = { buildActionMask = 2147483647; files = ( ); isa = PBXRezBuildPhase; runOnlyForDeploymentPostprocessing = 0; }; - 9DC1DEF30299BBCD00003D05 = { + C2907DD4042BA6B100CA2E77 = { buildPhases = ( - 9DC1DEEF0299BBCD00003D05, - 9DC1DEF00299BBCD00003D05, - 9DC1DEF10299BBCD00003D05, - 9DC1DEF20299BBCD00003D05, + C2907DD0042BA6B100CA2E77, + C2907DD1042BA6B100CA2E77, + C2907DD2042BA6B100CA2E77, + C2907DD3042BA6B100CA2E77, ); buildSettings = { - HEADER_SEARCH_PATHS = "$(SRCROOT)/CertTool"; - INSTALL_PATH = /usr/bin; - OPTIMIZATION_CFLAGS = "-Os -DNDEBUG"; + INSTALL_PATH = "$(SYSTEM_CORE_SERVICES_DIR)"; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; OTHER_REZFLAGS = ""; - PRODUCT_NAME = certtool; + PRODUCT_NAME = privportserver; REZ_EXECUTABLE = YES; SECTORDER_FLAGS = ""; WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; }; dependencies = ( + C290849A042BC9AF00CA2E77, ); isa = PBXToolTarget; - name = CertTool; - productInstallPath = ""; - productName = CertTool; - productReference = 9DC1DEF40299BBCD00003D05; - shouldUseHeadermap = 0; + name = PrivPortServer; + productInstallPath = "$(SYSTEM_CORE_SERVICES_DIR)"; + productName = PrivPortServer; + productReference = C2907DD5042BA6B100CA2E77; }; - 9DC1DEF40299BBCD00003D05 = { + C2907DD5042BA6B100CA2E77 = { isa = PBXExecutableFileReference; - path = certtool; + path = privportserver; refType = 3; }; - 9DC1DEF60299BC6C00003D05 = { - isa = PBXFileReference; - name = CertTool.cpp; - path = CertTool/CertTool/CertTool.cpp; - refType = 4; - }; - 9DC1DEF70299BC6C00003D05 = { - isa = PBXFileReference; - name = CertUI.cpp; - path = CertTool/CertTool/CertUI.cpp; - refType = 4; + C2907DD7042BA6E300CA2E77 = { + isa = PBXTargetDependency; + target = C2907DD4042BA6B100CA2E77; }; - 9DC1DEF80299BC6C00003D05 = { + C2907DD8042BA6F800CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = CertUI.h; - path = CertTool/CertTool/CertUI.h; + path = privPortServer.cpp; refType = 4; }; - 9DC1DEF90299BC6C00003D05 = { - fileRef = 9DC1DEF60299BC6C00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9DC1DEFA0299BC6C00003D05 = { - fileRef = 9DC1DEF70299BC6C00003D05; + C2907DD9042BA6F800CA2E77 = { + fileRef = C2907DD8042BA6F800CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DEFB0299BC6C00003D05 = { - fileRef = 9DC1DEF80299BC6C00003D05; + C2907DDA042BA71700CA2E77 = { + fileRef = 1BA451B10097605B7F000001; isa = PBXBuildFile; settings = { }; }; - 9DC1DEFC0299BC7F00003D05 = { - isa = PBXFileReference; - name = cdsaUtils.c; - path = CertTool/cdsaUtils/cdsaUtils.c; - refType = 4; - }; - 9DC1DEFD0299BC7F00003D05 = { - isa = PBXFileReference; - name = cdsaUtils.h; - path = CertTool/cdsaUtils/cdsaUtils.h; - refType = 4; - }; - 9DC1DEFE0299BC7F00003D05 = { + C2908496042BC01100CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = cuEnc64.c; - path = CertTool/cdsaUtils/cuEnc64.c; + path = fdmover.cpp; refType = 4; }; - 9DC1DEFF0299BC7F00003D05 = { + C2908497042BC01100CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = cuEnc64.h; - path = CertTool/cdsaUtils/cuEnc64.h; + path = fdmover.h; refType = 4; }; - 9DC1DF000299BC7F00003D05 = { - fileRef = 9DC1DEFC0299BC7F00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9DC1DF010299BC7F00003D05 = { - fileRef = 9DC1DEFD0299BC7F00003D05; - isa = PBXBuildFile; - settings = { - }; - }; - 9DC1DF020299BC7F00003D05 = { - fileRef = 9DC1DEFE0299BC7F00003D05; + C2908498042BC01100CA2E77 = { + fileRef = C2908496042BC01100CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF030299BC7F00003D05 = { - fileRef = 9DC1DEFF0299BC7F00003D05; + C2908499042BC01100CA2E77 = { + fileRef = C2908497042BC01100CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9DC1DF050299BC9500003D05 = { - isa = PBXFileReference; - name = fileIo.c; - path = CertTool/cdsaUtils/fileIo.c; - refType = 4; - }; - 9DC1DF060299BC9500003D05 = { - isa = PBXFileReference; - name = fileIo.h; - path = CertTool/cdsaUtils/fileIo.h; - refType = 4; - }; - 9DC1DF070299BC9500003D05 = { - isa = PBXFileReference; - name = oidParser.cpp; - path = CertTool/cdsaUtils/oidParser.cpp; - refType = 4; + C290849A042BC9AF00CA2E77 = { + isa = PBXTargetDependency; + target = 0867D69CFE84028FC02AAC07; }; - 9DC1DF080299BC9500003D05 = { - isa = PBXFileReference; - name = oidParser.h; - path = CertTool/cdsaUtils/oidParser.h; - refType = 4; + C2952B0B044B553F00CA2E77 = { + buildActionMask = 2147483647; + files = ( + ); + generatedFileNames = ( + ); + isa = PBXShellScriptBuildPhase; + neededFileNames = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "${SRCROOT}/SecurityServer/generate.pl ${SRCROOT}/SecurityServer/generate.cf ${BUILT_PRODUCTS_DIR}/include/flip_gen.h ${BUILT_PRODUCTS_DIR}/derived_src/flip_gen.cpp ${SRCROOT}/cdsa/cdsa/cssmtype.h"; }; - 9DC1DF090299BC9500003D05 = { + C2952B0C044B55BB00CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = pem.cpp; - path = CertTool/cdsaUtils/pem.cpp; + path = memstreams.h; refType = 4; }; - 9DC1DF0A0299BC9500003D05 = { - isa = PBXFileReference; - name = pem.h; - path = CertTool/cdsaUtils/pem.h; - refType = 4; + C2952B0D044B55BB00CA2E77 = { + fileRef = C2952B0C044B55BB00CA2E77; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; }; - 9DC1DF0B0299BC9500003D05 = { + C2952B0E044B560900CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = printCert.cpp; - path = CertTool/cdsaUtils/printCert.cpp; + path = flippers.cpp; refType = 4; }; - 9DC1DF0C0299BC9500003D05 = { + C2952B0F044B560900CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = printCert.h; - path = CertTool/cdsaUtils/printCert.h; + path = flippers.h; refType = 4; }; - 9DC1DF0D0299BC9500003D05 = { + C2952B10044B560900CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = timeStr.cpp; - path = CertTool/cdsaUtils/timeStr.cpp; + path = transwalkers.cpp; refType = 4; }; - 9DC1DF0E0299BC9500003D05 = { + C2952B11044B560900CA2E77 = { + fileEncoding = 30; isa = PBXFileReference; - name = timeStr.h; - path = CertTool/cdsaUtils/timeStr.h; + path = transwalkers.h; refType = 4; }; - 9DC1DF0F0299BCB400003D05 = { - isa = PBXTargetDependency; - target = 9DC1DEF30299BBCD00003D05; - }; - 9DC1DF100299BD8500003D05 = { - fileRef = 1BA451B10097605B7F000001; + C2952B12044B560900CA2E77 = { + fileRef = C2952B0E044B560900CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF110299BD8C00003D05 = { - fileRef = 125E85ADFFF3D44A11CD283A; + C2952B13044B560900CA2E77 = { + fileRef = C2952B0F044B560900CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF120299BDE200003D05 = { - fileRef = 9DC1DF050299BC9500003D05; + C2952B14044B560900CA2E77 = { + fileRef = C2952B10044B560900CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF130299BDE300003D05 = { - fileRef = 9DC1DF060299BC9500003D05; + C2952B15044B560900CA2E77 = { + fileRef = C2952B11044B560900CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF140299BDE300003D05 = { - fileRef = 9DC1DF070299BC9500003D05; + C2A6D4E0042FC54000CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = privPort.h; + refType = 4; + }; + C2A6D4E1042FC54000CA2E77 = { + fileRef = C2A6D4E0042FC54000CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + ); }; }; - 9DC1DF150299BDE400003D05 = { - fileRef = 9DC1DF080299BC9500003D05; + C2A6D4E2042FC54000CA2E77 = { + fileRef = C2A6D4E0042FC54000CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF160299BDE500003D05 = { - fileRef = 9DC1DF090299BC9500003D05; + C2AE35290469781800CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "db++.cpp"; + refType = 4; + }; + C2AE352A0469781800CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "db++.h"; + refType = 4; + }; + C2AE352B0469781800CA2E77 = { + fileRef = C2AE35290469781800CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF170299BDE600003D05 = { - fileRef = 9DC1DF0A0299BC9500003D05; + C2AE352C0469781800CA2E77 = { + fileRef = C2AE352A0469781800CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9DC1DF180299BDE600003D05 = { - fileRef = 9DC1DF0B0299BC9500003D05; + C2B484980450D42900CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = SecTrustPriv.h; + refType = 4; + }; + C2B484990450D42900CA2E77 = { + fileRef = C2B484980450D42900CA2E77; isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Private, + ); }; }; - 9DC1DF190299BDEA00003D05 = { - fileRef = 9DC1DF0C0299BC9500003D05; + C2C11912047187E800CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = codesigdb.cpp; + refType = 4; + }; + C2C11913047187E800CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = codesigdb.h; + refType = 4; + }; + C2C11914047187E800CA2E77 = { + fileRef = C2C11912047187E800CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF1A0299BDEA00003D05 = { - fileRef = 9DC1DF0D0299BC9500003D05; + C2C11915047187E800CA2E77 = { + fileRef = C2C11913047187E800CA2E77; isa = PBXBuildFile; settings = { }; }; - 9DC1DF1B0299BDEB00003D05 = { - fileRef = 9DC1DF0E0299BC9500003D05; - isa = PBXBuildFile; - settings = { + C2EE0104044B56E700CA2E77 = { + fileEncoding = 30; + isa = PBXFileReference; + path = generate.cf; + refType = 4; + }; + C2EE0105044B56E700CA2E77 = { + fileEncoding = 30; + isa = PBXExecutableFileReference; + path = generate.pl; + refType = 4; + }; + C2F346A204D5C05D0039D9E5 = { + buildRules = ( + ); + buildSettings = { + OTHER_CFLAGS = "\U0001-pg"; + OTHER_LDFLAGS = "\U0001-pg"; }; + isa = PBXBuildStyle; + name = "Deployment-gprof"; }; -//9D0 -//9D1 -//9D2 -//9D3 -//9D4 +//C20 +//C21 +//C22 +//C23 +//C24 //F50 //F51 //F52 //F53 //F54 - F500ED3B037CD0E101CA2E64 = { + F52A2F160316DA1901D50C4C = { + fileEncoding = 30; isa = PBXFileReference; - path = SecKeyPriv.h; + path = endian.cpp; refType = 4; }; - F500ED3C037CD0E101CA2E64 = { - fileRef = F500ED3B037CD0E101CA2E64; + F5394A1C0279082901CA2E64 = { + fileRef = 07A0F691005DAEE111CD283A; isa = PBXBuildFile; settings = { ATTRIBUTES = ( @@ -15536,29 +16739,8 @@ ); }; }; - F5394A1C0279082901CA2E64 = { - fileRef = 07A0F691005DAEE111CD283A; - isa = PBXBuildFile; - settings = { - }; - }; - F540E6F7027A33A501CA2E66 = { - isa = PBXFileReference; - path = pkcs10.h; - refType = 4; - }; - F540E6F9027A33DA01CA2E66 = { - isa = PBXFileReference; - path = pkcs10.cpp; - refType = 4; - }; - F540E6FA027A33DA01CA2E66 = { - fileRef = F540E6F9027A33DA01CA2E66; - isa = PBXBuildFile; - settings = { - }; - }; F540EDC2027A41BF01CA2E66 = { + fileEncoding = 30; isa = PBXFileReference; path = Session_CSR.cpp; refType = 4; @@ -15569,41 +16751,31 @@ settings = { }; }; - F540EDC4027A41E201CA2E66 = { - isa = PBXFileReference; - path = pkcs10.asn; - refType = 4; - }; - F540EDC8027A43A501CA2E66 = { - fileRef = F540E6F7027A33A501CA2E66; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Private, - ); - }; - }; F54323B4022DC91501CA2E64 = { isa = PBXFrameworkReference; path = Security.framework; refType = 3; }; F54323BD022DC98301CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecCFTypes.cpp; refType = 4; }; F54323BE022DC98301CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecCFTypes.h; refType = 4; }; F54323BF022DC98301CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecRuntime.cpp; refType = 4; }; F54323C0022DC98301CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecRuntime.h; refType = 4; @@ -15639,6 +16811,7 @@ }; }; F559B18C01D1510A01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = trackingallocator.h; refType = 4; @@ -15653,11 +16826,13 @@ }; }; F55B3B460230375401CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = CertificateRequest.h; refType = 4; }; F55B3B470230375401CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = CertificateRequest.cpp; refType = 4; @@ -15678,11 +16853,13 @@ }; }; F55B3B4A02303B2A01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = KeyItem.h; refType = 4; }; F55B3B4B02303B2A01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = KeyItem.cpp; refType = 4; @@ -15703,11 +16880,13 @@ }; }; F55B3B4E0230448601CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Trust.h; refType = 4; }; F55B3B4F0230448601CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Trust.cpp; refType = 4; @@ -15728,11 +16907,13 @@ }; }; F55B3B7902304A6001CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = TrustedApplication.h; refType = 4; }; F55B3B7A02304A6001CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = TrustedApplication.cpp; refType = 4; @@ -15753,6 +16934,7 @@ }; }; F5786171022EDDE501CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecBase.h; refType = 4; @@ -15767,6 +16949,7 @@ }; }; F5786173022EDDFB01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychain.h; refType = 4; @@ -15781,6 +16964,7 @@ }; }; F5786175022EDE0501CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychainItem.h; refType = 4; @@ -15795,6 +16979,7 @@ }; }; F5786177022EDE1701CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychainSearch.h; refType = 4; @@ -15809,6 +16994,7 @@ }; }; F5786179022EDE2B01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecCertificate.h; refType = 4; @@ -15823,6 +17009,7 @@ }; }; F578617B022EDE3F01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecIdentity.h; refType = 4; @@ -15837,6 +17024,7 @@ }; }; F578617D022EDE5C01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecPolicy.h; refType = 4; @@ -15851,6 +17039,7 @@ }; }; F578617F022EDE6401CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecAccess.h; refType = 4; @@ -15869,27 +17058,34 @@ F57861CB022F0F3801CA2E64, F5786171022EDDE501CA2E64, F578617F022EDE6401CA2E64, + 52807AD404A3D56C00F46CAB, 8F7ACD2A02357F2503CA2E8C, F5786179022EDE2B01CA2E64, + 9D2F711303156A7800003D05, F57861F7022F12FC01CA2E64, F57861BF022EEF1B01CA2E64, F578617B022EDE3F01CA2E64, + 4C2ACAB7044267EE00CA2E66, F57861C3022EEF3401CA2E64, F57861C9022F0D0A01CA2E64, - F500ED3B037CD0E101CA2E64, + BD6FEB7203A5642B03CA2E64, F5786173022EDDFB01CA2E64, F5786175022EDE0501CA2E64, F5786177022EDE1701CA2E64, F578617D022EDE5C01CA2E64, + C213880E0455C01F00CA2E77, F57861C1022EEF2601CA2E64, F57861C7022EFAE501CA2E64, + C2B484980450D42900CA2E77, F57861C5022EEF4701CA2E64, + C244C1350479624A00CA2E77, ); isa = PBXGroup; name = "Public API"; refType = 4; }; F57861BF022EEF1B01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecCertificateRequest.h; refType = 4; @@ -15904,6 +17100,7 @@ }; }; F57861C1022EEF2601CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecPolicySearch.h; refType = 4; @@ -15918,6 +17115,7 @@ }; }; F57861C3022EEF3401CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecIdentitySearch.h; refType = 4; @@ -15932,6 +17130,7 @@ }; }; F57861C5022EEF4701CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecTrustedApplication.h; refType = 4; @@ -15946,6 +17145,7 @@ }; }; F57861C7022EFAE501CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecTrust.h; refType = 4; @@ -15960,6 +17160,7 @@ }; }; F57861C9022F0D0A01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecKey.h; refType = 4; @@ -15974,6 +17175,7 @@ }; }; F57861CB022F0F3801CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Security.h; refType = 4; @@ -15988,6 +17190,7 @@ }; }; F57861F7022F12FC01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecCertificateBundle.h; refType = 4; @@ -16026,6 +17229,7 @@ refType = 4; }; F57861FA022F1A9301CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecAccess.cpp; refType = 4; @@ -16037,6 +17241,7 @@ }; }; F57861FC022F1AA001CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecCertificate.cpp; refType = 4; @@ -16048,6 +17253,7 @@ }; }; F57861FE022F1AAB01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecCertificateRequest.cpp; refType = 4; @@ -16059,6 +17265,7 @@ }; }; F5786200022F1B4001CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecCertificateBundle.cpp; refType = 4; @@ -16070,6 +17277,7 @@ }; }; F5786202022F1B5001CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecIdentity.cpp; refType = 4; @@ -16081,6 +17289,7 @@ }; }; F5786204022F1B5901CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecIdentitySearch.cpp; refType = 4; @@ -16092,6 +17301,7 @@ }; }; F5786206022F1B6501CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecKey.cpp; refType = 4; @@ -16103,6 +17313,7 @@ }; }; F5786208022F1B6F01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychain.cpp; refType = 4; @@ -16114,6 +17325,7 @@ }; }; F578620A022F1B7901CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychainItem.cpp; refType = 4; @@ -16125,6 +17337,7 @@ }; }; F578620C022F1B8701CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecKeychainSearch.cpp; refType = 4; @@ -16136,6 +17349,7 @@ }; }; F578620E022F1B9301CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecPolicy.cpp; refType = 4; @@ -16147,6 +17361,7 @@ }; }; F5786210022F1B9C01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecPolicySearch.cpp; refType = 4; @@ -16158,6 +17373,7 @@ }; }; F5786212022F1BA801CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecTrust.cpp; refType = 4; @@ -16169,6 +17385,7 @@ }; }; F5786214022F1BB601CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecTrustedApplication.cpp; refType = 4; @@ -16180,6 +17397,7 @@ }; }; F5786216022F1DA301CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = SecBridge.h; refType = 4; @@ -16223,8 +17441,6 @@ F5786238022F48C601CA2E64, F578622D022F37EB01CA2E64, F578622C022F37EB01CA2E64, - 0177F286FFFAA2D311CD283A, - 0177F287FFFAA2D311CD283A, 0177F290FFFAA2D311CD283A, 0177F291FFFAA2D311CD283A, 0177F2D6FFFAA2D311CD283A, @@ -16233,6 +17449,8 @@ F55B3B4E0230448601CA2E64, F55B3B7A02304A6001CA2E64, F55B3B7902304A6001CA2E64, + 52807AD004A3D4B800F46CAB, + 52807AD104A3D4B800F46CAB, ); isa = PBXGroup; name = "API Classes"; @@ -16241,8 +17459,8 @@ F5786223022F2DDB01CA2E64 = { children = ( 0177F269FFFAA2D311CD283A, - 0177F26AFFFAA2D311CD283A, 0177F27EFFFAA2D311CD283A, + 0177F26AFFFAA2D311CD283A, 0177F27FFFFAA2D311CD283A, 0177F28AFFFAA2D311CD283A, 0177F28BFFFAA2D311CD283A, @@ -16255,7 +17473,6 @@ 0177F353FFFAC61911CD283A, 0177F2C6FFFAA2D311CD283A, 0177F2C7FFFAA2D311CD283A, - 0177F2C9FFFAA2D311CD283A, F579CFD900E99FC401CD283A, 0177F2CDFFFAA2D311CD283A, 0177F2D2FFFAA2D311CD283A, @@ -16265,6 +17482,7 @@ 3244148D023837A505CA2E77, 3206D1FB029996FC05CA2E77, 3206D1FC029996FC05CA2E77, + 52D4AA9104B3AE3E00393476, ); isa = PBXGroup; name = Internal; @@ -16272,11 +17490,13 @@ refType = 4; }; F5786224022F32E001CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = IdentityCursor.h; refType = 4; }; F5786225022F32E001CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = IdentityCursor.cpp; refType = 4; @@ -16297,11 +17517,13 @@ }; }; F578622C022F37EB01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = PolicyCursor.h; refType = 4; }; F578622D022F37EB01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = PolicyCursor.cpp; refType = 4; @@ -16322,11 +17544,13 @@ }; }; F5786230022F39A101CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Certificate.cpp; refType = 4; }; F5786231022F39A101CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Certificate.h; refType = 4; @@ -16347,11 +17571,13 @@ }; }; F5786237022F48C601CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Policies.cpp; refType = 4; }; F5786238022F48C601CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Policies.h; refType = 4; @@ -16372,11 +17598,13 @@ }; }; F578623B023024CC01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Access.h; refType = 4; }; F578623C023024CC01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = Access.cpp; refType = 4; @@ -16397,17 +17625,26 @@ }; }; F579CFD900E99FC401CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = Schema.m4; refType = 4; }; + F581A93B0316D96A01D50C4C = { + fileEncoding = 30; + isa = PBXFileReference; + path = endian.h; + refType = 4; + }; F58785C800FB965F01CD29D4 = { + fileEncoding = 30; isa = PBXFileReference; name = checkpw.c; path = checkpw/checkpw.c; refType = 2; }; F58785C900FB965F01CD29D4 = { + fileEncoding = 30; isa = PBXFileReference; name = checkpw.h; path = checkpw/checkpw.h; @@ -16428,6 +17665,20 @@ settings = { }; }; + F58998F803809BCA01CA2A98 = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = NO; + OPTIMIZATION_CFLAGS = "-O0 -fno-inline"; + OTHER_CFLAGS = "\U0001 -DDEBUGDUMP -gfull"; + SECTORDER_FLAGS = ""; + i386 = YES; + ppc = YES; + }; + isa = PBXBuildStyle; + name = "Development-fat"; + }; F5A5E50E00FB884E01CD29D4 = { children = ( F58785C800FB965F01CD29D4, @@ -16438,21 +17689,25 @@ refType = 4; }; F5A7F715023D96EA01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = authorization.plist; refType = 4; }; F5A7F716023D96EA01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = AuthorizationData.cpp; refType = 4; }; F5A7F717023D96EA01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = AuthorizationData.h; refType = 4; }; F5A7F718023D96EA01CA2E64 = { + fileEncoding = 30; isa = PBXFileReference; path = AuthorizationPlugin.h; refType = 4; @@ -16466,12 +17721,6 @@ ); }; }; - F5A7F71F023D974E01CA2E64 = { - fileRef = F5A7F716023D96EA01CA2E64; - isa = PBXBuildFile; - settings = { - }; - }; F5A7F720023D974F01CA2E64 = { fileRef = F5A7F717023D96EA01CA2E64; isa = PBXBuildFile; @@ -16492,6 +17741,7 @@ shellScript = "${SRCROOT}/symbol_strip.sh ${SRCROOT}/Security.exp"; }; F5E32A1500EAB9A301CD283A = { + fileEncoding = 30; isa = PBXFileReference; path = KeySchema.m4; refType = 4; diff --git a/SecurityASN1/CVSVersionInfo.txt b/SecurityASN1/CVSVersionInfo.txt deleted file mode 100644 index 14abdcdf..00000000 --- a/SecurityASN1/CVSVersionInfo.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Created and modified by checkpoint; do not edit -# $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:59 mb Exp $ -# $Name: Security-54~1~9 $ -ProjectName: SecurityASN1 -ProjectVersion: 6 diff --git a/SecurityASN1/Makefile b/SecurityASN1/Makefile deleted file mode 100644 index 2113cd5c..00000000 --- a/SecurityASN1/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# -# Makefile to build snacc-generated code for pkcs* and cms -# -ASN1_SRC= sm_vdatypes.asn sm_x501ud.asn sm_x411ub.asn sm_x411mtsas.asn \ - sm_x501if.asn sm_x520sa.asn sm_x509cmn.asn sm_x509af.asn \ - sm_x509ce.asn pkcs1oids.asn pkcs9oids.asn sm_cms.asn sm_ess.asn \ - pkcs7.asn pkcs8.asn appleoids.asn pkcs10.asn - -SNACC_SRC= $(SRCROOT)/.. - -GEN_SRC= $(ASN1_SRC:%.asn=%.cpp) -GEN_HDR= $(ASN1_SRC:%.asn=%.h) - -PKCS_HOME=$(shell echo `pwd`) - -ASN_SRC_DIR= $(PKCS_HOME)/asn -GEN_SRC_DIR= $(PKCS_HOME)/c++ -GEN_HDR_DIR= $(PKCS_HOME)/inc - -VPATH= $(ASN_SRC_DIR) - -# -# get snacc headers from snacc project source, not from /usr/local/include -# -HDR_INCPATH= -I$(SNACC_SRC)/c++-lib/inc - -# -# standard useful ASN1 -# -ASN_USEFUL= asn-useful.asn1 - -# -# local build directory, -# -#LOCAL_BUILD= /Data_and_Apps/dmitchBuild -LOCAL_BUILD= $(BUILT_PRODUCTS_DIR) - -CFLAGS= -g $(HDR_INCPATH) -DVDADER_RULES -LDFLAGS= -lstdc++ -lsnacc++ -L$(LOCAL_BUILD) - -CC= /usr/bin/cc -SNACC= /usr/local/bin/snacc -SNACC_FLAGS= -C -D -u $(ASN_USEFUL) - -first: $(GEN_SRC) move_genfiles - -$(GEN_SRC): - (cd $(ASN_SRC_DIR); $(SNACC) $(SNACC_FLAGS) $(ASN1_SRC)) - -move_genfiles: clean_genfiles - (cd $(ASN_SRC_DIR); \ - mv *.cpp $(GEN_SRC_DIR); \ - mv *.h $(GEN_HDR_DIR)) - -clean_genfiles: - (cd $(GEN_SRC_DIR); rm -f *.cpp) - (cd $(GEN_HDR_DIR); rm -f *.h) - -clean: clean_genfiles - -install: - -# anything else? - - diff --git a/SecurityASN1/PkcsCms.pbproj/project.pbxproj b/SecurityASN1/PkcsCms.pbproj/project.pbxproj deleted file mode 100644 index 1fd0b62b..00000000 --- a/SecurityASN1/PkcsCms.pbproj/project.pbxproj +++ /dev/null @@ -1,797 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 36; - objects = { - 01C17CFFFF16DC3011CD283A = { - children = ( - 01C17D00FF16DC3011CD283A, - ); - isa = PBXGroup; - name = Frameworks; - refType = 4; - }; - 01C17D00FF16DC3011CD283A = { - isa = PBXFrameworkReference; - path = SecuritySNACCRuntime.framework; - refType = 3; - }; - 01C17D01FF16DC3011CD283A = { - fileRef = 01C17D00FF16DC3011CD283A; - isa = PBXBuildFile; - settings = { - }; - }; -//010 -//011 -//012 -//013 -//014 -//020 -//021 -//022 -//023 -//024 - 022D30ACFEF82B87D0A17CE7 = { - buildStyles = ( - 2B4BC6B0FFE026FE7F000001, - 2B4BC6B1FFE026FE7F000001, - ); - isa = PBXProject; - mainGroup = 022D30ADFEF82B87D0A17CE7; - productRefGroup = 022D30AFFEF8301ED0A17CE7; - projectDirPath = ""; - targets = ( - 022D30F5FEF83C56D0A17CE7, - 022D30B1FEF8301ED0A17CE7, - 022D30AEFEF82D08D0A17CE7, - ); - }; - 022D30ADFEF82B87D0A17CE7 = { - children = ( - 022D30B7FEF8308ED0A17CE7, - 022D30C7FEF8308ED0A17CE7, - 01C17CFFFF16DC3011CD283A, - 022D30AFFEF8301ED0A17CE7, - 9D8FD570024790F700003D05, - ); - isa = PBXGroup; - refType = 4; - }; - 022D30AEFEF82D08D0A17CE7 = { - buildArgumentsString = "-f $(SRCROOT)/Makefile $ACTION SRCROOT=$(SRCROOT) BUILT_PRODUCTS_DIR=$(BUILT_PRODUCTS_DIR)"; - buildPhases = ( - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ""; - HEADER_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Libraries/CIncludes\""; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = CompileAsn; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - buildToolPath = /usr/bin/gnumake; - dependencies = ( - ); - isa = PBXLegacyTarget; - name = CompileAsn; - productName = CompileAsn; - settingsToExpand = 6; - settingsToPassInEnvironment = 287; - settingsToPassOnCommandLine = 280; - shouldUseHeadermap = 0; - }; - 022D30AFFEF8301ED0A17CE7 = { - children = ( - 0509B1B7FF15465811CD283A, - ); - isa = PBXGroup; - name = Products; - refType = 4; - }; - 022D30B1FEF8301ED0A17CE7 = { - buildPhases = ( - 022D30B2FEF8301ED0A17CE7, - 022D30B3FEF8301ED0A17CE7, - 022D30B4FEF8301ED0A17CE7, - 022D30B5FEF8301ED0A17CE7, - 022D30B6FEF8301ED0A17CE7, - ); - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\""; - FRAMEWORK_VERSION = A; - HEADER_SEARCH_PATHS = "\"$(SRCROOT)/inc\" \"$(BUILT_PRODUCTS_DIR)/SecuritySNACCRuntime.framework/Headers\" \"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/SecuritySNACCRuntime.framework/Headers\""; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = "-DVDADER_RULES"; - OTHER_LDFLAGS = "\"-lstdc++\""; - OTHER_LIBTOOL_FLAGS = ""; - OTHER_REZFLAGS = ""; - PRINCIPAL_CLASS = ""; - PRODUCT_NAME = SecurityASN1; - SECTORDER_FLAGS = "-sectorder __TEXT __text \"$(APPLE_INTERNAL_DIR)/OrderFiles/SecurityASN1.order\""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - WRAPPER_EXTENSION = framework; - }; - dependencies = ( - ); - isa = PBXFrameworkTarget; - name = PkcsCms; - productInstallPath = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; - productName = SecurityASN1; - productReference = 0509B1B7FF15465811CD283A; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - SecurityASN1 - CFBundleGetInfoString - - CFBundleIconFile - - CFBundleIdentifier - - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - - CFBundlePackageType - FMWK - CFBundleShortVersionString - - CFBundleSignature - ???? - CFBundleVersion - 0.0.1d1 - - -"; - shouldUseHeadermap = 1; - }; - 022D30B2FEF8301ED0A17CE7 = { - buildActionMask = 2147483647; - files = ( - 022D30D7FEF8308ED0A17CE7, - 022D30D8FEF8308ED0A17CE7, - 022D30D9FEF8308ED0A17CE7, - 022D30DAFEF8308ED0A17CE7, - 022D30DBFEF8308ED0A17CE7, - 022D30DCFEF8308ED0A17CE7, - 022D30DDFEF8308ED0A17CE7, - 022D30DEFEF8308ED0A17CE7, - 022D30DFFEF8308ED0A17CE7, - 022D30E0FEF8308ED0A17CE7, - 022D30E1FEF8308ED0A17CE7, - 022D30E2FEF8308ED0A17CE7, - 022D30E3FEF8308ED0A17CE7, - 022D30E4FEF8308ED0A17CE7, - 022D30E5FEF8308ED0A17CE7, - ); - isa = PBXHeadersBuildPhase; - }; - 022D30B3FEF8301ED0A17CE7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXResourcesBuildPhase; - }; - 022D30B4FEF8301ED0A17CE7 = { - buildActionMask = 2147483647; - files = ( - 022D30E6FEF8308ED0A17CE7, - 022D30E7FEF8308ED0A17CE7, - 022D30E8FEF8308ED0A17CE7, - 022D30E9FEF8308ED0A17CE7, - 022D30EAFEF8308ED0A17CE7, - 022D30EBFEF8308ED0A17CE7, - 022D30ECFEF8308ED0A17CE7, - 022D30EDFEF8308ED0A17CE7, - 022D30EEFEF8308ED0A17CE7, - 022D30EFFEF8308ED0A17CE7, - 022D30F0FEF8308ED0A17CE7, - 022D30F1FEF8308ED0A17CE7, - 022D30F2FEF8308ED0A17CE7, - 022D30F3FEF8308ED0A17CE7, - 022D30F4FEF8308ED0A17CE7, - ); - isa = PBXSourcesBuildPhase; - }; - 022D30B5FEF8301ED0A17CE7 = { - buildActionMask = 2147483647; - files = ( - 01C17D01FF16DC3011CD283A, - 9D8FD66D024790F800003D05, - ); - isa = PBXFrameworksBuildPhase; - }; - 022D30B6FEF8301ED0A17CE7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - }; - 022D30B7FEF8308ED0A17CE7 = { - children = ( - 022D30B8FEF8308ED0A17CE7, - 022D30B9FEF8308ED0A17CE7, - 022D30BAFEF8308ED0A17CE7, - 022D30BBFEF8308ED0A17CE7, - 022D30BCFEF8308ED0A17CE7, - 022D30BDFEF8308ED0A17CE7, - 022D30BEFEF8308ED0A17CE7, - 022D30BFFEF8308ED0A17CE7, - 022D30C0FEF8308ED0A17CE7, - 022D30C1FEF8308ED0A17CE7, - 022D30C2FEF8308ED0A17CE7, - 022D30C3FEF8308ED0A17CE7, - 022D30C4FEF8308ED0A17CE7, - 022D30C5FEF8308ED0A17CE7, - 022D30C6FEF8308ED0A17CE7, - ); - isa = PBXGroup; - name = "gen src"; - refType = 4; - }; - 022D30B8FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = pkcs1oids.cpp; - path = "c++/pkcs1oids.cpp"; - refType = 4; - }; - 022D30B9FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = pkcs7.cpp; - path = "c++/pkcs7.cpp"; - refType = 4; - }; - 022D30BAFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = pkcs8.cpp; - path = "c++/pkcs8.cpp"; - refType = 4; - }; - 022D30BBFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = pkcs9oids.cpp; - path = "c++/pkcs9oids.cpp"; - refType = 4; - }; - 022D30BCFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_cms.cpp; - path = "c++/sm_cms.cpp"; - refType = 4; - }; - 022D30BDFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_ess.cpp; - path = "c++/sm_ess.cpp"; - refType = 4; - }; - 022D30BEFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_vdatypes.cpp; - path = "c++/sm_vdatypes.cpp"; - refType = 4; - }; - 022D30BFFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x411mtsas.cpp; - path = "c++/sm_x411mtsas.cpp"; - refType = 4; - }; - 022D30C0FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x411ub.cpp; - path = "c++/sm_x411ub.cpp"; - refType = 4; - }; - 022D30C1FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x501if.cpp; - path = "c++/sm_x501if.cpp"; - refType = 4; - }; - 022D30C2FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x501ud.cpp; - path = "c++/sm_x501ud.cpp"; - refType = 4; - }; - 022D30C3FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x509af.cpp; - path = "c++/sm_x509af.cpp"; - refType = 4; - }; - 022D30C4FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x509ce.cpp; - path = "c++/sm_x509ce.cpp"; - refType = 4; - }; - 022D30C5FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x509cmn.cpp; - path = "c++/sm_x509cmn.cpp"; - refType = 4; - }; - 022D30C6FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x520sa.cpp; - path = "c++/sm_x520sa.cpp"; - refType = 4; - }; - 022D30C7FEF8308ED0A17CE7 = { - children = ( - 022D30C8FEF8308ED0A17CE7, - 022D30C9FEF8308ED0A17CE7, - 022D30CAFEF8308ED0A17CE7, - 022D30CBFEF8308ED0A17CE7, - 022D30CCFEF8308ED0A17CE7, - 022D30CDFEF8308ED0A17CE7, - 022D30CEFEF8308ED0A17CE7, - 022D30CFFEF8308ED0A17CE7, - 022D30D0FEF8308ED0A17CE7, - 022D30D1FEF8308ED0A17CE7, - 022D30D2FEF8308ED0A17CE7, - 022D30D3FEF8308ED0A17CE7, - 022D30D4FEF8308ED0A17CE7, - 022D30D5FEF8308ED0A17CE7, - 022D30D6FEF8308ED0A17CE7, - ); - isa = PBXGroup; - name = "gen inc"; - path = ""; - refType = 4; - }; - 022D30C8FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = pkcs1oids.h; - path = inc/pkcs1oids.h; - refType = 4; - }; - 022D30C9FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = pkcs7.h; - path = inc/pkcs7.h; - refType = 4; - }; - 022D30CAFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = pkcs8.h; - path = inc/pkcs8.h; - refType = 4; - }; - 022D30CBFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = pkcs9oids.h; - path = inc/pkcs9oids.h; - refType = 4; - }; - 022D30CCFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_cms.h; - path = inc/sm_cms.h; - refType = 4; - }; - 022D30CDFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_ess.h; - path = inc/sm_ess.h; - refType = 4; - }; - 022D30CEFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_vdatypes.h; - path = inc/sm_vdatypes.h; - refType = 4; - }; - 022D30CFFEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x411mtsas.h; - path = inc/sm_x411mtsas.h; - refType = 4; - }; - 022D30D0FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x411ub.h; - path = inc/sm_x411ub.h; - refType = 4; - }; - 022D30D1FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x501if.h; - path = inc/sm_x501if.h; - refType = 4; - }; - 022D30D2FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x501ud.h; - path = inc/sm_x501ud.h; - refType = 4; - }; - 022D30D3FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x509af.h; - path = inc/sm_x509af.h; - refType = 4; - }; - 022D30D4FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x509ce.h; - path = inc/sm_x509ce.h; - refType = 4; - }; - 022D30D5FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x509cmn.h; - path = inc/sm_x509cmn.h; - refType = 4; - }; - 022D30D6FEF8308ED0A17CE7 = { - isa = PBXFileReference; - name = sm_x520sa.h; - path = inc/sm_x520sa.h; - refType = 4; - }; - 022D30D7FEF8308ED0A17CE7 = { - fileRef = 022D30C8FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30D8FEF8308ED0A17CE7 = { - fileRef = 022D30C9FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30D9FEF8308ED0A17CE7 = { - fileRef = 022D30CAFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30DAFEF8308ED0A17CE7 = { - fileRef = 022D30CBFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30DBFEF8308ED0A17CE7 = { - fileRef = 022D30CCFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30DCFEF8308ED0A17CE7 = { - fileRef = 022D30CDFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30DDFEF8308ED0A17CE7 = { - fileRef = 022D30CEFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30DEFEF8308ED0A17CE7 = { - fileRef = 022D30CFFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30DFFEF8308ED0A17CE7 = { - fileRef = 022D30D0FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30E0FEF8308ED0A17CE7 = { - fileRef = 022D30D1FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30E1FEF8308ED0A17CE7 = { - fileRef = 022D30D2FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30E2FEF8308ED0A17CE7 = { - fileRef = 022D30D3FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30E3FEF8308ED0A17CE7 = { - fileRef = 022D30D4FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30E4FEF8308ED0A17CE7 = { - fileRef = 022D30D5FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30E5FEF8308ED0A17CE7 = { - fileRef = 022D30D6FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 022D30E6FEF8308ED0A17CE7 = { - fileRef = 022D30B8FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30E7FEF8308ED0A17CE7 = { - fileRef = 022D30B9FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30E8FEF8308ED0A17CE7 = { - fileRef = 022D30BAFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30E9FEF8308ED0A17CE7 = { - fileRef = 022D30BBFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30EAFEF8308ED0A17CE7 = { - fileRef = 022D30BCFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30EBFEF8308ED0A17CE7 = { - fileRef = 022D30BDFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30ECFEF8308ED0A17CE7 = { - fileRef = 022D30BEFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30EDFEF8308ED0A17CE7 = { - fileRef = 022D30BFFEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30EEFEF8308ED0A17CE7 = { - fileRef = 022D30C0FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30EFFEF8308ED0A17CE7 = { - fileRef = 022D30C1FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30F0FEF8308ED0A17CE7 = { - fileRef = 022D30C2FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30F1FEF8308ED0A17CE7 = { - fileRef = 022D30C3FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30F2FEF8308ED0A17CE7 = { - fileRef = 022D30C4FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30F3FEF8308ED0A17CE7 = { - fileRef = 022D30C5FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30F4FEF8308ED0A17CE7 = { - fileRef = 022D30C6FEF8308ED0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 022D30F5FEF83C56D0A17CE7 = { - buildPhases = ( - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ""; - HEADER_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Libraries/CIncludes\""; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = World; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - dependencies = ( - 022D30F7FEF83C56D0A17CE7, - ); - isa = PBXAggregateTarget; - name = World; - productName = World; - shouldUseHeadermap = 0; - }; - 022D30F7FEF83C56D0A17CE7 = { - isa = PBXTargetDependency; - target = 022D30B1FEF8301ED0A17CE7; - }; -//020 -//021 -//022 -//023 -//024 -//050 -//051 -//052 -//053 -//054 - 0509B1B7FF15465811CD283A = { - isa = PBXFrameworkReference; - path = SecurityASN1.framework; - refType = 3; - }; -//050 -//051 -//052 -//053 -//054 -//2B0 -//2B1 -//2B2 -//2B3 -//2B4 - 2B4BC6B0FFE026FE7F000001 = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = NO; - OPTIMIZATION_CFLAGS = "-O0"; - }; - isa = PBXBuildStyle; - name = Development; - }; - 2B4BC6B1FFE026FE7F000001 = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = YES; - }; - isa = PBXBuildStyle; - name = Deployment; - }; -//2B0 -//2B1 -//2B2 -//2B3 -//2B4 -//9D0 -//9D1 -//9D2 -//9D3 -//9D4 - 9D8FD570024790F700003D05 = { - isa = PBXFrameworkReference; - name = Security.framework; - path = /System/Library/Frameworks/Security.framework; - refType = 0; - }; - 9D8FD66D024790F800003D05 = { - fileRef = 9D8FD570024790F700003D05; - isa = PBXBuildFile; - settings = { - }; - }; - }; - rootObject = 022D30ACFEF82B87D0A17CE7; -} diff --git a/SecurityASN1/asn/appleoids.asn b/SecurityASN1/asn/appleoids.asn deleted file mode 100644 index f21ccb43..00000000 --- a/SecurityASN1/asn/appleoids.asn +++ /dev/null @@ -1,195 +0,0 @@ -APPLE-OIDS -DEFINITIONS IMPLICIT TAGS ::= -BEGIN --- EXPORTS All -- - -IMPORTS - BigIntegerStr - FROM VdaEnhancedTypes - pkcs - FROM PKCS1-OIDS -; - --- base OIDs for Apple, Apple Data Security -appleBaseOid OBJECT IDENTIFIER ::= { 1 2 840 113635 } -appleDataSecurity OBJECT IDENTIFIER ::= { appleBaseOid 100 } - --- base OIDs for Apple Trust Policies and Algorithms -appleTrustPolicy OBJECT IDENTIFIER ::= { appleDataSecurity 1 } -appleSecurityAlgorithm OBJECT IDENTIFIER ::=Ê{ appleDataSecurity 2 } - --- Apple trust policy OIDs - -appleISignTP OBJECT IDENTIFIER ::= { appleTrustPolicy 1 } -appleX509Basic OBJECT IDENTIFIER ::= { appleTrustPolicy 2 } -appleSSLPolicy OBJECT IDENTIFIER ::= { appleTrustPolicy 3 } - --- Apple algorithms -appleFee OBJECT IDENTIFIER ::= { appleSecurityAlgorithm 1 } -appleAsc OBJECT IDENTIFIER ::= { appleSecurityAlgorithm 2 } -appleFeeMD5 OBJECT IDENTIFIER ::= { appleSecurityAlgorithm 3 } -appleFeeSHA1 OBJECT IDENTIFIER ::= { appleSecurityAlgorithm 4 } -appleFeed OBJECT IDENTIFIER ::= { appleSecurityAlgorithm 5 } -appleFeedExp OBJECT IDENTIFIER ::= { appleSecurityAlgorithm 6 } -appleECDSA OBJECT IDENTIFIER ::= { appleSecurityAlgorithm 7 } - --- PKCS3 OIDs -pkcs-3 OBJECT IDENTIFIER ::= { pkcs 3 } -dhKeyAgreement OBJECT IDENTIFIER ::= { pkcs-3 1 } - --- FEE ElGamal-style signature -FEEElGamalSignature ::= SEQUENCE { - u BigIntegerStr, - pmX BigIntegerStr -} - --- FEE ECDSA-style signature -FEEECDSASignature ::= SEQUENCE { - c BigIntegerStr, - d BigIntegerStr -} - --- FEE Curve parameters -FEEPrimeType ::= INTEGER { pt-mersenne(0), pt-fee(1), pt-general(2) } -FEECurveType ::= INTEGER { ct-montgomery(0), ct-weierstrass(1), ct-general(2) } - -FEECurveParameters ::= SEQUENCE -{ - primeType FEEPrimeType, - curveType FEECurveType, - q INTEGER, -- unsigned - k INTEGER, -- signed - m INTEGER, - a BigIntegerStr, - bb BigIntegerStr, -- can't use variable/field b - c BigIntegerStr, - x1Plus BigIntegerStr, - x1Minus BigIntegerStr, - cOrderPlus BigIntegerStr, - cOrderMinus BigIntegerStr, - x1OrderPlus BigIntegerStr, - x1OrderMinus BigIntegerStr, - basePrime BigIntegerStr OPTIONAL -- iff FEEPrimeType == pt-general -} - --- FEE keys - -FEEPublicKey ::= SEQUENCE -{ - version INTEGER, - curveParams FEECurveParameters, - plusX BigIntegerStr, - minusX BigIntegerStr, - plusY BigIntegerStr OPTIONAL -- iff FEECurveType == ct-weierstrass -} - -FEEPrivateKey ::= SEQUENCE -{ - version INTEGER, - curveParams FEECurveParameters, - privData BigIntegerStr -} - --- DSA keys --- --- DSA private keys are represented as a PrivateKeyInfo (pkcs8); DSA public keys --- are represented as SubjectPublicKeyInfo (sm_s509af). However, the public p, g, --- and q parameters are expressed in the AlgorithmIdentifier.parameters --- field which is an ANY type. To simplify encoding and decoding (AsnAny is a royal --- hassle to deal with), we define new structs for the entire keys here. --- NOTE: these definition are derived from reverse engineering the key blobs --- created by BSAFE 4.0 using info type KI_DSA{Public,Private}BER. The BSAFE --- documentation claims that this encoding is X9.20 compatible; however BSAFE --- adds a field to the dss-params (here called DSABSafeParams) struct which --- indicates the prime size in bits. The encoding and decoding implemented here --- is verified to be compatible with BSAFE 4.0 but no othyer implementations of --- DSA keys. --- -DSAPrivateKey ::= SEQUENCE -{ - version INTEGER, - dsaAlg DSAAlgorithmId, - privateKey OCTET STRING -} - --- --- The publicKey is actually the DER encoding of an ASN integer, wrapped in a --- BIT STRING. --- -DSAPublicKey ::= SEQUENCE -{ - dsaAlg DSAAlgorithmId, - publicKey BIT STRING -} - --- --- A convenient replacement for a DSA AlgorithmIdentifier --- -DSAAlgorithmId ::= SEQUENCE -{ - algorithm OBJECT IDENTIFIER, -- id_dsa from sm_cms - params DSABsafeParams -} - --- --- This is the "ANY" parameter from AlgorithmIdentifier. --- -DSABsafeParams ::= SEQUENCE -{ - keySizeInBits INTEGER, - p BigIntegerStr, - q BigIntegerStr, - g BigIntegerStr -} - --- --- DSAPrivateKey.privateKey is actually the DER encoding, as an AsnOcts, of this. --- -DSAPrivateKeyOcts ::= SEQUENCE -{ - privateKey BigIntegerStr -} - --- --- DSA signature --- -DSASignature ::= SEQUENCE -{ - r BigIntegerStr, - s BigIntegerStr -} - --- --- Encoding of the basic DSA parameters for use in a CDSA key generation context. --- -DSAAlgParams ::= SEQUENCE -{ - p BigIntegerStr, - q BigIntegerStr, - g BigIntegerStr -} - --- Diffie Hellman per PKCS3 - -DHPrivateKey ::= SEQUENCE -{ - dHOid OBJECT IDENTIFIER, -- dhKeyAgreement - params DHParameter, - secretPart BigIntegerStr -} - -DHParameterBlock ::= SEQUENCE -{ - oid OBJECT IDENTIFIER, -- pkcs-3 - params DHParameter -} - -DHParameter ::= SEQUENCE -{ - prime BigIntegerStr, -- p - base BigIntegerStr, -- g - privateValueLength BigIntegerStr OPTIONAL -} - -END -- APPLE-OIDS - diff --git a/SecurityASN1/asn/asn-useful.asn1 b/SecurityASN1/asn/asn-useful.asn1 deleted file mode 100644 index 57f29fbd..00000000 --- a/SecurityASN1/asn/asn-useful.asn1 +++ /dev/null @@ -1,105 +0,0 @@ -ASN-USEFUL DEFINITIONS ::= -BEGIN - --- file: .../asn1specs/asn-useful.asn1 --- --- NOTE: every one of these types is marked as a PDU so the compiler --- will produce the encode and decode routines that --- enc/dec the top tag/len pairs, not just the content decoders. --- (only nec for re-generating the library files "asn_useful.[ch]"). --- The isPdu field does not affect how this module is linked --- with other modules during compilation. --- --- (type DEF comment directives immediately follow the "::=") --- --- MS 92 --- --- $Header: /cvs/root/Security/SecurityASN1/asn/Attic/asn-useful.asn1,v 1.1.1.1 2001/05/18 23:13:59 mb Exp $ --- $Log: asn-useful.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:13:59 mb --- Move from private repository to open source repository --- --- Revision 1.1 2000/06/14 22:23:07 dmitch --- New PKCS/CMS snacc-generated framework. --- --- Revision 1.1.1.1 2000/03/09 00:59:54 rmurphy --- Base Fortissimo Tree --- --- Revision 1.2 1999/03/10 18:23:38 aram --- Corrected definition of UTF8String. --- --- Revision 1.1 1999/03/10 18:16:44 aram --- Added UTF8String definition. --- --- Revision 1.3 1995/07/24 15:12:35 rj --- useful.asn1 renamed to asn-useful.asn1 to accomodate to snacc's new file name generation scheme. --- --- Revision 1.2 1994/08/28 09:54:19 rj --- comment leader fixed. --- --- Revision 1.1 1994/08/28 09:51:15 rj --- first check-in. - - -ObjectDescriptor ::= -- isPdu:"TRUE" -- - [UNIVERSAL 7] IMPLICIT OCTET STRING - -UTF8String ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 12] IMPLICIT OCTET STRING - -NumericString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 18] IMPLICIT OCTET STRING - -PrintableString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 19] IMPLICIT OCTET STRING - -TeletexString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 20] IMPLICIT OCTET STRING - -T61String ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 20] IMPLICIT OCTET STRING - -VideotexString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 21] IMPLICIT OCTET STRING - -IA5String ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 22] IMPLICIT OCTET STRING - -GraphicString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 25] IMPLICIT OCTET STRING - -VisibleString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 26] IMPLICIT OCTET STRING - -ISO646String ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 26] IMPLICIT OCTET STRING - -GeneralString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 27] IMPLICIT OCTET STRING - -UTCTime ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 23] IMPLICIT OCTET STRING - -GeneralizedTime ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 24] IMPLICIT OCTET STRING - -UniversalString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 28] IMPLICIT OCTET STRING - -BMPString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 30] IMPLICIT OCTET STRING - -EXTERNAL ::= --snacc isPdu:"TRUE" -- [UNIVERSAL 8] IMPLICIT SEQUENCE -{ - direct-reference OBJECT IDENTIFIER OPTIONAL, - indirect-reference INTEGER OPTIONAL, - data-value-descriptor ObjectDescriptor OPTIONAL, - encoding CHOICE - { - single-ASN1-type [0] OCTET STRING, -- should be ANY - octet-aligned [1] IMPLICIT OCTET STRING, - arbitrary [2] IMPLICIT BIT STRING - } -} - -END -- of ASN-USEFUL type definitions diff --git a/SecurityASN1/asn/pkcs1.asn1 b/SecurityASN1/asn/pkcs1.asn1 deleted file mode 100644 index b89fa06c..00000000 --- a/SecurityASN1/asn/pkcs1.asn1 +++ /dev/null @@ -1,205 +0,0 @@ -PKCS-1 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) - modules(0) pkcs-1(1)} - --- $Revision: 1.1.1.1 $ - --- This module has been checked for conformance with the ASN.1 --- standard by the OSS ASN.1 Tools - -DEFINITIONS EXPLICIT TAGS ::= - -BEGIN - --- EXPORTS ALL -- --- All types and values defined in this module is exported for use in other --- ASN.1 modules. - --- IMPORTS None -- - --- Basic object identifiers - --- The DER for this in hexadecimal is: --- 06 08 --- 2A 86 48 86 F7 0D 01 01 --- -pkcs-1 OBJECT IDENTIFIER ::= { - iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } - --- --- When the following OIDs are used in an AlgorithmIdentifier --- the parameters MUST be present and MUST be NULL. --- -rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } -md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 } -md4WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 3 } -md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 } -sha1WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 5 } -rsaOAEPEncryptionSET OBJECT IDENTIFIER ::= { pkcs-1 6 } - --- --- When id-RSAES-OAEP is used in an AlgorithmIdentifier --- the parameters MUST be present and MUST be RSAES-OAEP-params. --- -id-RSAES-OAEP OBJECT IDENTIFIER ::= { pkcs-1 7 } - --- --- When id-mgf1 is used in an AlgorithmIdentifier --- the parameters MUST be present and MUST be --- a DigestAlgorithmIdentifier, specifically SHA1Identifier. --- -id-mgf1 OBJECT IDENTIFIER ::= { pkcs-1 8 } - --- --- When id-pSpecified is used in an AlgorithmIdentifier --- the parameters MUST be an OCTET STRING. --- -id-pSpecified OBJECT IDENTIFIER ::= { pkcs-1 9 } - --- --- This OID really belongs in a module with the secsig OIDs. --- -id-sha1 OBJECT IDENTIFIER ::= { - iso(1) identified-organization(3) oiw(14) secsig(3) - algorithms(2) 26 } - - --- Useful types - -ALGORITHM-IDENTIFIER ::= TYPE-IDENTIFIER - --- Note: the parameter InfoObjectSet in the following definitions --- allows a distinct information object set to be specified for --- sets of algorithms such as: --- DigestAlgorithms ALGORITHM-IDENTIFIER ::= { --- { NULL IDENTIFIED BY id-sha1 }, --- { NULL IDENTIFIED BY id-md5 }, --- { NULL IDENTIFIED BY id-md2 } --- } --- -AlgorithmIdentifier { ALGORITHM-IDENTIFIER:InfoObjectSet } ::= -SEQUENCE { - algorithm ALGORITHM-IDENTIFIER.&id({InfoObjectSet}), - parameters ALGORITHM-IDENTIFIER.&Type({InfoObjectSet} - {@algorithm}) OPTIONAL -} - --- Algorithms - --- --- Allowed OAEP digest algorithms. --- -OAEPDigestAlgorithms ALGORITHM-IDENTIFIER ::= { - { SHA1Parameters IDENTIFIED BY id-sha1 }, - ... --Allows for future expansion -} - -sha1Identifier AlgorithmIdentifier {{ OAEPDigestAlgorithms }} ::= - {algorithm id-sha1, parameters SHA1Parameters : NULL} - -SHA1Parameters ::= NULL - --- --- Allowed Mask Generation Function algorithms. --- If the identifier is id-mgf1, the parameters --- are a single digest algorithm identifier. --- -PKCS1MGFAlgorithms ALGORITHM-IDENTIFIER ::= { - { MGF1Parameters IDENTIFIED BY id-mgf1 }, - ...--Allows for future expansion -} - -MGF1Parameters ::= - AlgorithmIdentifier { {OAEPDigestAlgorithms} } - --- --- Allowed algorithms for pSourceFunc. --- -PKCS1PSourceAlgorithms ALGORITHM-IDENTIFIER ::= { - { PEmptyString IDENTIFIED BY id-pSpecified }, - ...--Allows for future expansion -} - -PEmptyString ::= OCTET STRING (SIZE(0)) - --- --- This identifier means that P is an empty string, so the digest --- of the empty string appears in the RSA block before masking. --- -pSpecifiedEmptyIdentifier AlgorithmIdentifier {{ PKCS1PSourceAlgorithms }} ::= - { algorithm id-pSpecified, parameters PEmptyString : ''H } - --- --- Default AlgorithmIdentifier for id-RSAES-OAEP.maskGenFunc. --- -mgf1SHA1Identifier AlgorithmIdentifier {{ PKCS1MGFAlgorithms }} ::= - { algorithm id-mgf1, - parameters AlgorithmIdentifier{{OAEPDigestAlgorithms}} : sha1Identifier} - --- --- Type identifier definitions for the PKCS #1 OIDs. --- -PKCS1Algorithms ALGORITHM-IDENTIFIER ::= { - { NULL IDENTIFIED BY rsaEncryption } | - { NULL IDENTIFIED BY md2WithRSAEncryption } | - { NULL IDENTIFIED BY md4WithRSAEncryption } | - { NULL IDENTIFIED BY md5WithRSAEncryption } | - { NULL IDENTIFIED BY sha1WithRSAEncryption } | - { NULL IDENTIFIED BY rsaOAEPEncryptionSET } | - { RSAES-OAEP-params IDENTIFIED BY id-RSAES-OAEP } | - PKCS1PSourceAlgorithms, - ... -- Allows for future expansion -} - --- Main structures - -RSAPublicKey ::= SEQUENCE { - modulus INTEGER, -- (Usually large) n = p*q - publicExponent INTEGER -- (Usually small) e -} - --- --- Representation of RSA private key with p and q --- information for the CRT algorithm. --- -RSAPrivateKey ::= SEQUENCE { - version INTEGER { rsaPrivateKeyVer0(0) }(rsaPrivateKeyVer0), - modulus INTEGER, -- (Usually large) n - publicExponent INTEGER, -- (Usually small) e - privateExponent INTEGER, -- (Usually large) d - prime1 INTEGER, -- (Usually large) p - prime2 INTEGER, -- (Usually large) q - exponent1 INTEGER, -- (Usually large) d mod (p-1) - exponent2 INTEGER, -- (Usually large) d mod (q-1) - coefficient INTEGER -- (Usually large) (inverse of q) mod p -} - --- --- AlgorithmIdentifier.parameters for id-RSAES-OAEP. --- Note that the tags in this Sequence are explicit. --- - -RSAES-OAEP-params ::= SEQUENCE { - hashFunc [0] AlgorithmIdentifier { {OAEPDigestAlgorithms} } - DEFAULT sha1Identifier, - maskGenFunc [1] AlgorithmIdentifier { {PKCS1MGFAlgorithms} } - DEFAULT mgf1SHA1Identifier, - pSourceFunc [2] AlgorithmIdentifier { {PKCS1PSourceAlgorithms} } - DEFAULT pSpecifiedEmptyIdentifier -} - --- --- Identifier for default RSAES-OAEP algorithm identifier --- The DER Encoding of this is in hexadecimal: --- 30 0D --- 06 09 --- 2A 86 48 86 F7 0D 01 01 07 --- 30 00 --- Notice that the DER encoding of default values is "empty". --- -rSAES-OAEP-Default-Identifier AlgorithmIdentifier{ {PKCS1Algorithms} } ::= - {algorithm id-RSAES-OAEP, - parameters RSAES-OAEP-params : {hashFunc sha1Identifier, - maskGenFunc mgf1SHA1Identifier, - pSourceFunc pSpecifiedEmptyIdentifier}} - -END -- PKCS1Definitions diff --git a/SecurityASN1/asn/pkcs10.asn b/SecurityASN1/asn/pkcs10.asn deleted file mode 100644 index 73fdb819..00000000 --- a/SecurityASN1/asn/pkcs10.asn +++ /dev/null @@ -1,53 +0,0 @@ --- PKCS10 ASN module - -PKCS5 -DEFINITIONS IMPLICIT TAGS ::= -BEGIN --- EXPORTS All -- - -IMPORTS - -- Directory Information Framework (X.501) - Name, Attribute, Attributes - FROM InformationFramework - - -- Directory Authentication Framework (X.509) - AlgorithmIdentifier, SubjectPublicKeyInfo - FROM AuthenticationFramework - - -- CryptographicMessageSyntax (draft-ietf-smime-cms-13) - Signature, SignatureAlgorithmIdentifier - FROM CryptographicMessageSyntax -; - -CertificationRequestInfo ::= SEQUENCE { - version VersionP10, - subject Name, - subjectPublicKeyInfo SubjectPublicKeyInfo, - attributes [0] IMPLICIT Attributes -} - -VersionP10 ::= INTEGER --- redefined, same as InformationFramework (sm_x501if.asn) --- Attributes ::= SET OF Attribute - --- Per PKCS10 spec -CertificationRequest ::= SEQUENCE { - certificationRequestInfo CertificationRequestInfo, - signatureAlgorithm SignatureAlgorithmIdentifier, - signature Signature -} - --- This is what we actually use to avoid unnecessary --- setup and teardown of CertificationRequestInfo when --- signing and verifying -CertificationRequestSigned ::= SEQUENCE { - certificationRequestInfo ANY, - signatureAlgorithm SignatureAlgorithmIdentifier, - signature Signature -} - --- duplicated from CryptographicMessageSyntax --- SignatureAlgorithmIdentifier ::= AlgorithmIdentifier --- Signature ::= BIT STRING - -END -- PKCS10 diff --git a/SecurityASN1/asn/pkcs1oids.asn b/SecurityASN1/asn/pkcs1oids.asn deleted file mode 100644 index bc1025df..00000000 --- a/SecurityASN1/asn/pkcs1oids.asn +++ /dev/null @@ -1,46 +0,0 @@ -PKCS1-OIDS -DEFINITIONS IMPLICIT TAGS ::= -BEGIN --- EXPORTS All -- - -IMPORTS - BigIntegerStr - FROM VdaEnhancedTypes -; - -rsadsi OBJECT IDENTIFIER ::= { 1 2 840 113549 } -pkcs OBJECT IDENTIFIER ::= { rsadsi 1 } - -pkcs-1 OBJECT IDENTIFIER ::= { pkcs 1 } -rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } -md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 } -md4WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 3 } -md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 } -sha1withRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 5 } -- dmitch - -rsaDigestAlgorithm OBJECT IDENTIFIER ::= { rsadsi 2 } -md2 OBJECT IDENTIFIER ::= { rsaDigestAlgorithm 2 } -md4 OBJECT IDENTIFIER ::= { rsaDigestAlgorithm 4 } -md5 OBJECT IDENTIFIER ::= { rsaDigestAlgorithm 5 } - -RSAPublicKey ::= SEQUENCE { - modulus BigIntegerStr, -- n - publicExponent BigIntegerStr -- e -} - -RSAPrivateKey ::= SEQUENCE { - version INTEGER, -- Version, - modulus BigIntegerStr, -- n - publicExponent BigIntegerStr, -- e - privateExponent BigIntegerStr, -- d - prime1 BigIntegerStr, -- p - prime2 BigIntegerStr, -- q - exponent1 BigIntegerStr, -- d mod (p-1) - exponent2 BigIntegerStr, -- d mod (q-1) - coefficient BigIntegerStr -- (inverse of q) mod p -} - --- Version ::= INTEGER - -END -- PKCS1-OIDS - diff --git a/SecurityASN1/asn/pkcs5.asn1 b/SecurityASN1/asn/pkcs5.asn1 deleted file mode 100644 index d090fbb7..00000000 --- a/SecurityASN1/asn/pkcs5.asn1 +++ /dev/null @@ -1,141 +0,0 @@ --- PKCS #5 v2.0 ASN.1 Module --- Revised March 25, 1999 - --- This module has been checked for conformance with the --- ASN.1 standard by the OSS ASN.1 Tools - -PKCS5v2-0 {iso(1) member-body(2) us(840) rsadsi(113549) - pkcs(1) pkcs-5(5) modules(16) pkcs5v2-0(1)} - -DEFINITIONS ::= BEGIN - --- Basic object identifiers - -rsadsi OBJECT IDENTIFIER ::= - {iso(1) member-body(2) us(840) 113549} -pkcs OBJECT IDENTIFIER ::= {rsadsi 1} -pkcs-5 OBJECT IDENTIFIER ::= {pkcs 5} - --- Basic types and classes - -AlgorithmIdentifier { ALGORITHM-IDENTIFIER:InfoObjectSet } ::= -SEQUENCE { - algorithm ALGORITHM-IDENTIFIER.&id({InfoObjectSet}), - parameters ALGORITHM-IDENTIFIER.&Type({InfoObjectSet} - {@algorithm}) OPTIONAL } - -ALGORITHM-IDENTIFIER ::= TYPE-IDENTIFIER - --- PBKDF2 - -PBKDF2Algorithms ALGORITHM-IDENTIFIER ::= - { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ...} - -id-PBKDF2 OBJECT IDENTIFIER ::= {pkcs-5 12} - -algid-hmacWithSHA1 AlgorithmIdentifier {{PBKDF2-PRFs}} ::= - {algorithm id-hmacWithSHA1, parameters NULL : NULL} - -PBKDF2-params ::= SEQUENCE { - salt CHOICE { - specified OCTET STRING, - otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}} - }, - iterationCount INTEGER (1..MAX), - keyLength INTEGER (1..MAX) OPTIONAL, - prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT - algid-hmacWithSHA1 } - -PBKDF2-SaltSources ALGORITHM-IDENTIFIER ::= { ... } - -PBKDF2-PRFs ALGORITHM-IDENTIFIER ::= - { {NULL IDENTIFIED BY id-hmacWithSHA1}, ... } - - -- PBES1 - -PBES1Algorithms ALGORITHM-IDENTIFIER ::= - { {PBEParameter IDENTIFIED BY pbeWithMD2AndDES-CBC} | - {PBEParameter IDENTIFIED BY pbeWithMD2AndRC2-CBC} | - {PBEParameter IDENTIFIED BY pbeWithMD5AndDES-CBC} | - {PBEParameter IDENTIFIED BY pbeWithMD5AndRC2-CBC} | - {PBEParameter IDENTIFIED BY pbeWithSHA1AndDES-CBC} | - {PBEParameter IDENTIFIED BY pbeWithSHA1AndRC2-CBC}, ...} - -pbeWithMD2AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 1} -pbeWithMD2AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 4} -pbeWithMD5AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 3} -pbeWithMD5AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 6} -pbeWithSHA1AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 10} -pbeWithSHA1AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 11} - -PBEParameter ::= SEQUENCE { - salt OCTET STRING (SIZE(8)), - iterationCount INTEGER } - --- PBES2 - -PBES2Algorithms ALGORITHM-IDENTIFIER ::= - { {PBES2-params IDENTIFIED BY id-PBES2}, ...} - -id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13} - -PBES2-params ::= SEQUENCE { - keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}}, - encryptionScheme AlgorithmIdentifier {{PBES2-Encs}} } - -PBES2-KDFs ALGORITHM-IDENTIFIER ::= - { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ... } - -PBES2-Encs ALGORITHM-IDENTIFIER ::= { ... } - --- PBMAC1 - -PBMAC1Algorithms ALGORITHM-IDENTIFIER ::= - { {PBMAC1-params IDENTIFIED BY id-PBMAC1}, ...} - -id-PBMAC1 OBJECT IDENTIFIER ::= {pkcs-5 14} - -PBMAC1-params ::= SEQUENCE { - keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}}, - messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} } - -PBMAC1-KDFs ALGORITHM-IDENTIFIER ::= - { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ... } - -PBMAC1-MACs ALGORITHM-IDENTIFIER ::= { ... } - --- Supporting techniques - -digestAlgorithm OBJECT IDENTIFIER ::= {rsadsi 2} -encryptionAlgorithm OBJECT IDENTIFIER ::= {rsadsi 3} - -SupportingAlgorithms ALGORITHM-IDENTIFIER ::= - { {NULL IDENTIFIED BY id-hmacWithSHA1} | - {OCTET STRING (SIZE(8)) IDENTIFIED BY desCBC} | - {OCTET STRING (SIZE(8)) IDENTIFIED BY des-EDE3-CBC} | - {RC2-CBC-Parameter IDENTIFIED BY rc2CBC} | - {RC5-CBC-Parameters IDENTIFIED BY rc5-CBC-PAD}, ... } - -id-hmacWithSHA1 OBJECT IDENTIFIER ::= {digestAlgorithm 7} - -desCBC OBJECT IDENTIFIER ::= - {iso(1) identified-organization(3) oiw(14) secsig(3) - algorithms(2) 7} -- from OIW - -des-EDE3-CBC OBJECT IDENTIFIER ::= {encryptionAlgorithm 7} - -rc2CBC OBJECT IDENTIFIER ::= {encryptionAlgorithm 2} - -RC2-CBC-Parameter ::= SEQUENCE { - rc2ParameterVersion INTEGER OPTIONAL, - iv OCTET STRING (SIZE(8)) } - -rc5-CBC-PAD OBJECT IDENTIFIER ::= {encryptionAlgorithm 9} - -RC5-CBC-Parameters ::= SEQUENCE { - version INTEGER {v1-0(16)} (v1-0), - rounds INTEGER (8..127), - blockSizeInBits INTEGER (64 | 128), - iv OCTET STRING OPTIONAL } - -END diff --git a/SecurityASN1/asn/pkcs7.asn b/SecurityASN1/asn/pkcs7.asn deleted file mode 100644 index 69b2d0b2..00000000 --- a/SecurityASN1/asn/pkcs7.asn +++ /dev/null @@ -1,63 +0,0 @@ -PKCS7 - --- ??? {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-7(7) --- modules(0) pkcs-7(1)} - -DEFINITIONS EXPLICIT TAGS ::= -BEGIN - --- --- 3. Definitions --- - --- EXPORTS All; - -IMPORTS - - informationFramework, authenticationFramework - FROM UsefulDefinitions { usefulDefinitions } - - AlgorithmIdentifier - FROM AuthenticationFramework { authenticationFramework } - -; - --- *** A large amount of stuff we don't need right now deleted *** - --- --- 13. Encrypted-data content type --- - -EncryptedData ::= SEQUENCE { - version INTEGER {edVer0(0)} (edVer0), - encryptedContentInfo EncryptedContentInfo -} - -EncryptedContentInfo ::= SEQUENCE { - contentType ContentType, - contentEncryptionAlgorithm - ContentEncryptionAlgorithmIdentifier, - encryptedContent - [0] IMPLICIT EncryptedContent OPTIONAL -} - -ContentType ::= OBJECT IDENTIFIER - -EncryptedContent ::= OCTET STRING - -ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier - --- --- 14. Object Identifiers --- - -pkcs-7 OBJECT IDENTIFIER ::= - { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 7 } -dataPkcs7 OBJECT IDENTIFIER ::= { pkcs-7 1 } -signedData OBJECT IDENTIFIER ::= { pkcs-7 2 } -envelopedData OBJECT IDENTIFIER ::= { pkcs-7 3 } -signedAndEnvelopedData OBJECT IDENTIFIER ::= { pkcs-7 4 } -digestedData OBJECT IDENTIFIER ::= { pkcs-7 5 } -encryptedData OBJECT IDENTIFIER ::= { pkcs-7 6 } - -END diff --git a/SecurityASN1/asn/pkcs8.asn b/SecurityASN1/asn/pkcs8.asn deleted file mode 100644 index 163db63d..00000000 --- a/SecurityASN1/asn/pkcs8.asn +++ /dev/null @@ -1,40 +0,0 @@ -PrivateKeyInformationSyntax --- PKCS#8 ASN.1 -DEFINITIONS IMPLICIT TAGS ::= -BEGIN --- EXPORTS All -- -IMPORTS - AlgorithmIdentifier - FROM AuthenticationFramework { authenticationFramework } - Attributes - FROM InformationFramework { informationFramework } - EncryptedKey - FROM CryptographicMessageSyntax -; - -PrivateKeyInfo ::= SEQUENCE { - version INTEGER, -- Version, - privateKeyAlgorithm AlgorithmIdentifier, - privateKey PrivateKey, - attributes [0] IMPLICIT Attributes OPTIONAL } - - --- Version ::= INTEGER - --- PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier - - -PrivateKey ::= OCTET STRING - - -EncryptedPrivateKeyInfo ::= SEQUENCE { - encryptionAlgorithm AlgorithmIdentifier, - encryptedKey EncryptedKey } - - --- EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier - --- EncryptedKey ::= OCTET STRING - -END -- PrivateKeyInformationSyntax - diff --git a/SecurityASN1/asn/pkcs9oids.asn b/SecurityASN1/asn/pkcs9oids.asn deleted file mode 100644 index c8113e39..00000000 --- a/SecurityASN1/asn/pkcs9oids.asn +++ /dev/null @@ -1,19 +0,0 @@ -PKCS9-OIDS -DEFINITIONS IMPLICIT TAGS ::= -BEGIN --- EXPORTS All -- - -pkcs-9 OBJECT IDENTIFIER ::= { 1 2 840 113549 1 9 } - -emailAddress OBJECT IDENTIFIER ::= { pkcs-9 1 } -unstructuredName OBJECT IDENTIFIER ::= { pkcs-9 2 } -contentTypePkcs9 OBJECT IDENTIFIER ::= { pkcs-9 3 } -messageDigest OBJECT IDENTIFIER ::= { pkcs-9 4 } -signingTime OBJECT IDENTIFIER ::= { pkcs-9 5 } -countersignature OBJECT IDENTIFIER ::= { pkcs-9 6 } -challengePassword OBJECT IDENTIFIER ::= { pkcs-9 7 } -unstructuredAddress OBJECT IDENTIFIER ::= { pkcs-9 8 } -extendedCertificateAttributes OBJECT IDENTIFIER ::= { pkcs-9 9 } - -END -- PKCS9-OIDS - diff --git a/SecurityASN1/asn/sm_cms.asn b/SecurityASN1/asn/sm_cms.asn deleted file mode 100644 index c861a477..00000000 --- a/SecurityASN1/asn/sm_cms.asn +++ /dev/null @@ -1,431 +0,0 @@ - --- @(#) sm_cms.asn 1.13 12/17/98 14:17:10 --- FROM cms.txt: - - CryptographicMessageSyntax - { 1 2 840 113549 1 9 16 0 1 } - --RWC;{ iso(1) member-body(2) us(840) rsadsi(113549) - --RWC; pkcs(1) pkcs-9(9) smime(16) modules(0) cms(1) } - - DEFINITIONS IMPLICIT TAGS ::= - BEGIN - - -- EXPORTS All - -- The types and values defined in this module are exported for use in - -- the other ASN.1 modules. Other applications may use them for their - -- own purposes. - - IMPORTS - - -- MB;KeyIdentifier (replaces SubjectKeyIdentifier) - KeyIdentifier - FROM CertificateExtensions - - -- MB;PKCS1-OIDS - rsadsi, pkcs --MB;rsaEncryption, md5 - FROM PKCS1-OIDS - - -- Useful Definitions from X.501 - informationFramework, authenticationFramework - FROM UsefulDefinitions { usefulDefinitions } - - -- Directory Information Framework (X.501) - Name, Attribute, Attributes, AttributeValue - FROM InformationFramework --RWC; { joint-iso-itu-t ds(5) rWCmodules(1) - --RWC; "modules(1)" re-defined from above "CrytpgraphicMessageSyntax". - --RWC; informationFramework(1) 3 } - - -- Directory Authentication Framework (X.509) - AlgorithmIdentifier, AttributeCertificate, Certificate, - CertificateList, CertificateSerialNumber, Time - FROM AuthenticationFramework; --RWC;{ joint-iso-itu-t rWCds(5) - --RWC; "ds(1)" re-defined. - --RWC;module(1) rWCauthenticationFramework(7) 3 } ; - - - - - - -- Cryptographic Message Syntax - - ContentInfo ::= SEQUENCE { - contentType ContentType, - content [0] EXPLICIT ANY } --RWC;DEFINED BY contentType } - - ContentType ::= OBJECT IDENTIFIER - - SignedData ::= SEQUENCE { - version CMSVersion, - digestAlgorithms DigestAlgorithmIdentifiers, - encapContentInfo EncapsulatedContentInfo, - certificates [0] IMPLICIT CertificateSet OPTIONAL, - crls [1] IMPLICIT CertificateRevocationLists OPTIONAL, - signerInfos SignerInfos } - - DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier - - SignerInfos ::= SET OF SignerInfo - - - - EncapsulatedContentInfo ::= SEQUENCE { - eContentType ContentType, - eContent [0] EXPLICIT OCTET STRING OPTIONAL } - - SignerInfo ::= SEQUENCE { - version CMSVersion, - sid SignerIdentifier, - digestAlgorithm DigestAlgorithmIdentifier, - signedAttrs [0] IMPLICIT Attributes OPTIONAL, --MB;SignedAttributes OPTIONAL, - signatureAlgorithm SignatureAlgorithmIdentifier, - signature SignatureValue, - unsignedAttrs [1] IMPLICIT Attributes OPTIONAL } --MB;UnsignedAttributes OPTIONAL } - - SignerIdentifier ::= CHOICE { - issuerAndSerialNumber IssuerAndSerialNumber, - subjectKeyIdentifier [0] KeyIdentifier } --MB;SubjectKeyIdentifier } - - --MB;SignedAttributes ::= SET SIZE (1..MAX) OF Attribute - - --MB;UnsignedAttributes ::= SET SIZE (1..MAX) OF Attribute - - --MB;Attribute ::= SEQUENCE { - --MB; attrType OBJECT IDENTIFIER, - --MB; attrValues SET OF AttributeValue } - - --MB;AttributeValue ::= ANY - - SignatureValue ::= OCTET STRING - - EnvelopedData ::= SEQUENCE { - version CMSVersion, - originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL, - recipientInfos RecipientInfos, - encryptedContentInfo EncryptedContentInfo, - unprotectedAttrs [1] IMPLICIT Attributes OPTIONAL } --MB;UnprotectedAttributes OPTIONAL } - - OriginatorInfo ::= SEQUENCE { - certs [0] IMPLICIT CertificateSet OPTIONAL, - crls [1] IMPLICIT CertificateRevocationLists OPTIONAL } - - RecipientInfos ::= SET OF RecipientInfo - - EncryptedContentInfo ::= SEQUENCE { - contentType ContentType, - contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier, - encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL } - - EncryptedContent ::= OCTET STRING - - - - --MB;UnprotectedAttributes ::= SET SIZE (1..MAX) OF Attribute - - RecipientInfo ::= CHOICE { - ktri KeyTransRecipientInfo, - kari [1] KeyAgreeRecipientInfo, - kekri [2] KEKRecipientInfo } - - EncryptedKey ::= OCTET STRING - - KeyTransRecipientInfo ::= SEQUENCE { - version CMSVersion, -- always set to 0 or 2 - rid RecipientIdentifier, - keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, - encryptedKey EncryptedKey } - - RecipientIdentifier ::= CHOICE { - issuerAndSerialNumber IssuerAndSerialNumber, - subjectKeyIdentifier [0] KeyIdentifier } --MB;SubjectKeyIdentifier } - - KeyAgreeRecipientInfo ::= SEQUENCE { - version CMSVersion, -- always set to 3 - originator [0] EXPLICIT OriginatorIdentifierOrKey, - ukm [1] EXPLICIT UserKeyingMaterial OPTIONAL, - keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, - recipientEncryptedKeys RecipientEncryptedKeys } - - OriginatorIdentifierOrKey ::= CHOICE { - issuerAndSerialNumber IssuerAndSerialNumber, - subjectKeyIdentifier [0] KeyIdentifier, --MB;SubjectKeyIdentifier, - originatorKey [1] OriginatorPublicKey } - - OriginatorPublicKey ::= SEQUENCE { - algorithm AlgorithmIdentifier, - publicKey BIT STRING } - - RecipientEncryptedKeys ::= SEQUENCE OF RecipientEncryptedKey - - RecipientEncryptedKey ::= SEQUENCE { - rid KeyAgreeRecipientIdentifier, - encryptedKey EncryptedKey } - - KeyAgreeRecipientIdentifier ::= CHOICE { - issuerAndSerialNumber IssuerAndSerialNumber, - rKeyId [0] IMPLICIT RecipientKeyIdentifier } - - - - - RecipientKeyIdentifier ::= SEQUENCE { - subjectKeyIdentifier KeyIdentifier, --MB;SubjectKeyIdentifier, - date GeneralizedTime OPTIONAL, - other OtherKeyAttribute OPTIONAL } - - --MB;SubjectKeyIdentifier ::= OCTET STRING - - KEKRecipientInfo ::= SEQUENCE { - version CMSVersion, -- always set to 4 - kekid KEKIdentifier, - keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, - encryptedKey EncryptedKey } - - KEKIdentifier ::= SEQUENCE { - keyIdentifier OCTET STRING, - date GeneralizedTime OPTIONAL, - other OtherKeyAttribute OPTIONAL } - - DigestedData ::= SEQUENCE { - version CMSVersion, - digestAlgorithm DigestAlgorithmIdentifier, - encapContentInfo EncapsulatedContentInfo, - digest Digest } - - Digest ::= OCTET STRING - - EncryptedData ::= SEQUENCE { - version CMSVersion, - encryptedContentInfo EncryptedContentInfo } - - AuthenticatedData ::= SEQUENCE { - version CMSVersion, - originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL, - recipientInfos RecipientInfos, - macAlgorithm MessageAuthenticationCodeAlgorithm, - digestAlgorithm [1] DigestAlgorithmIdentifier OPTIONAL, - encapContentInfo EncapsulatedContentInfo, - authenctiatedAttributes [2] IMPLICIT Attributes OPTIONAL, --MB;AuthAttributes OPTIONAL, - mac MessageAuthenticationCode, - unauthenticatedAttributes [3] IMPLICIT Attributes OPTIONAL } --MB;UnauthAttributes OPTIONAL } - - --MB;AuthAttributes ::= SET SIZE (1..MAX) OF Attribute - - --MB;UnauthAttributes ::= SET SIZE (1..MAX) OF Attribute - - MessageAuthenticationCode ::= OCTET STRING - - DigestAlgorithmIdentifier ::= AlgorithmIdentifier - - - - SignatureAlgorithmIdentifier ::= AlgorithmIdentifier - - KeyEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier - - ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier - - MessageAuthenticationCodeAlgorithm ::= AlgorithmIdentifier - - CertificateRevocationLists ::= SET OF CertificateList - - CertificateChoices ::= CHOICE { - certificate Certificate, -- See X.509 - extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete - attrCert [1] IMPLICIT AttributeCertificate } -- See X.509 & X9.57 - - CertificateSet ::= SET OF CertificateChoices - - IssuerAndSerialNumber ::= SEQUENCE { - issuer Name, - serialNumber CertificateSerialNumber } - - CMSVersion ::= INTEGER { v0(0), v1(1), v2(2), v3(3), v4(4) } - - UserKeyingMaterial ::= OCTET STRING - - UserKeyingMaterials ::= SET SIZE (1..MAX) OF UserKeyingMaterial - - OtherKeyAttribute ::= SEQUENCE { - keyAttrId OBJECT IDENTIFIER, - keyAttr ANY OPTIONAL } --RWC;DEFINED BY keyAttrId OPTIONAL } - - - -- CMS Attributes - - MessageDigest ::= OCTET STRING - - SigningTime ::= Time - - --MB;Time ::= CHOICE { - --MB; utcTime UTCTime, - --MB; generalTime GeneralizedTime } - - Countersignature ::= SignerInfo - - - - -- Algorithm Identifiers - - sha-1 OBJECT IDENTIFIER ::= { 1 3 14 3 2 26 } --MB;{ iso(1) identified-organization(3) - --MB;oiw(14) secsig(3) algorithm(2) 26 } - - --MB;md5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) - --MB; rsadsi(113549) digestAlgorithm(2) 5 } - - id-dsa-with-sha1 OBJECT IDENTIFIER ::= { 1 2 840 10040 4 3 } --MB;{ iso(1) member-body(2) - --MB;us(840) x9-57 (10040) x9cm(4) 3 } - - --MB;rsaEncryption OBJECT IDENTIFIER ::= { iso(1) member-body(2) - --MB; us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 1 } - - dh-public-number OBJECT IDENTIFIER ::= { 1 2 840 10046 2 1 } --MB;{ iso(1) member-body(2) - --MB;us(840) ansi-x942(10046) number-type(2) 1 } - - id-alg-ESDH OBJECT IDENTIFIER ::= { pkcs 9 16 3 5 } --MB;{ iso(1) member-body(2) us(840) - --MB;rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) alg(3) 5 } - - id-alg-CMS3DESwrap OBJECT IDENTIFIER ::= { pkcs 9 16 3 6 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) alg(3) 6 } - - id-alg-CMSRC2wrap OBJECT IDENTIFIER ::= { pkcs 9 16 3 7 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) alg(3) 7 } - - des-ede3-cbc OBJECT IDENTIFIER ::= { rsadsi 3 7 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) encryptionAlgorithm(3) 7 } - - rc2-cbc OBJECT IDENTIFIER ::= { rsadsi 3 2 } --MB;{ iso(1) member-body(2) us(840) - --MB;rsadsi(113549) encryptionAlgorithm(3) 2 } - - hMAC-SHA1 OBJECT IDENTIFIER ::= { 1 3 6 1 5 5 8 1 2 } --MB;{ iso(1) identified-organization(3) - --MB;dod(6) internet(1) security(5) mechanisms(5) 8 1 2 } - - -- some more algorithms added by dmitch - - rc2-ecb OBJECT IDENTIFIER ::= { rsadsi 3 3 } - - rc4 OBJECT IDENTIFIER ::= { rsadsi 3 4 } - - rc4WithMAC OBJECT IDENTIFIER ::= { rsadsi 3 5 } - - desx-CBC OBJECT IDENTIFIER ::= { rsadsi 3 6 } - - rc5CBC OBJECT IDENTIFIER ::= { rsadsi 3 8 } - - rc5-CBCPad OBJECT IDENTIFIER ::= { rsadsi 3 9 } - - desCDMF OBJECT IDENTIFIER ::= { rsadsi 3 10 } - - -- this is the OID used by BSAFE when generating DSA keys. It is not - -- the same as id_dsa from sm_x501ud... - - dsa-bsafe OBJECT IDENTIFIER ::= {1 3 14 3 2 12} - - -- end of dmitch addenda - - - -- Algorithm Parameters - - KeyWrapAlgorithm ::= AlgorithmIdentifier - - RC2wrapParameter ::= RC2ParameterVersion - - RC2ParameterVersion ::= INTEGER - - CBCParameter ::= IV - - IV ::= OCTET STRING -- exactly 8 octets - - RC2CBCParameter ::= SEQUENCE { - rc2ParameterVersion INTEGER, - iv OCTET STRING } -- exactly 8 octets - - - -- Content Type Object Identifiers - - id-data OBJECT IDENTIFIER ::= { pkcs 7 1 } --MB; { iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs7(7) 1 } - - id-signedData OBJECT IDENTIFIER ::= { pkcs 7 2 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs7(7) 2 } - - id-envelopedData OBJECT IDENTIFIER ::= { pkcs 7 3 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs7(7) 3 } - - id-digestedData OBJECT IDENTIFIER ::= { pkcs 7 5 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs7(7) 5 } - - id-encryptedData OBJECT IDENTIFIER ::= { pkcs 7 6 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs7(7) 6 } - - id-ct-authData OBJECT IDENTIFIER ::= { pkcs 9 16 1 2 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) - --MB;ct(1) 2 } - - - -- Attribute Object Identifiers - - id-contentType OBJECT IDENTIFIER ::= { pkcs 9 3 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs9(9) 3 } - - id-messageDigest OBJECT IDENTIFIER ::= { pkcs 9 4 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs9(9) 4 } - - id-signingTime OBJECT IDENTIFIER ::= { pkcs 9 5 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs9(9) 5 } - - id-countersignature OBJECT IDENTIFIER ::= { pkcs 9 6 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs9(9) 6 } - - - -- Obsolete Extended Certificate syntax from PKCS#6 - - ExtendedCertificateOrCertificate ::= CHOICE { - certificate Certificate, - extendedCertificate [0] IMPLICIT ExtendedCertificate } - - ExtendedCertificate ::= SEQUENCE { - extendedCertificateInfo ExtendedCertificateInfo, - signatureAlgorithm SignatureAlgorithmIdentifier, - signature Signature } - - ExtendedCertificateInfo ::= SEQUENCE { - version CMSVersion, - certificate Certificate, - attributes Attributes } --MB;UnauthAttributes } - - Signature ::= BIT STRING - - - - -- Everything below this line is not part of draft-ietf-smime-cms-13.txt - - - -- Attribute Object Identifiers - - id-macValue OBJECT IDENTIFIER ::= { pkcs 9 16 2 8 } --MB;{ iso(1) member-body(2) - --MB;us(840) rsadsi(113549) pkcs(1) pkcs9(9) smime(16) aa(2) 8 } - - - -- Algorithm Identifiers - - id-dsa OBJECT IDENTIFIER ::= { 1 2 840 10040 4 1 } --MB;{iso(1) member-body(2) - --MB;us(840) x9-57(10040) x9cm(4) 1 } - - - -- Content Encryption Algorithms - -- For the effective-key-bits (key size) greater than 32 and less - -- than 256, the RC2-CBC algorithm parameters are encoded as: - -- RC2-CBC parameter ::= SEQUENCE { - -- rc2ParameterVersion INTEGER, - -- iv OCTET STRING (8) } - -- For the effective-key-bits of 40, 64, and 128, the - -- rc2ParameterVersion values are 160, 120, 58 respectively. - - - -- Normally in PKCS#7 - DigestInfo ::= SEQUENCE { -- Defined in PKCS#7 but not IETF-CMS - digestAlgorithm DigestAlgorithmIdentifier, - digest Digest } - - - END -- of CryptographicMessageSyntax diff --git a/SecurityASN1/asn/sm_ess.asn b/SecurityASN1/asn/sm_ess.asn deleted file mode 100644 index f90e24e7..00000000 --- a/SecurityASN1/asn/sm_ess.asn +++ /dev/null @@ -1,238 +0,0 @@ --- @(#) sm_ess.asn 1.13 12/17/98 14:17:02 --- FROM ess.txt: draft-ietf-smime-ess-09.txt -ExtendedSecurityServices - { 1 2 840 113549 1 9 16 0 2 } --MB;{ iso(1) member-body(2) us(840) rsadsi(113549) - --MB; pkcs(1) pkcs-9(9) smime(16) modules(0) ess(2) } - -DEFINITIONS IMPLICIT TAGS ::= -BEGIN - -IMPORTS - - KeyIdentifier, PolicyQualifierInfo, PolicyInformation, CertPolicyId - FROM CertificateExtensions - - pkcs-9 - FROM PKCS9-OIDS - --- Cryptographic Message Syntax (CMS) - ContentType, IssuerAndSerialNumber, CMSVersion - FROM CryptographicMessageSyntax { 1 2 840 113549 1 9 16 0 1 } - --RWC;iso(1) member-body(2) us(840) - --RWC;rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) modules(0) cms(1)} - --- PKIX Certificate and CRL Profile, Sec A.2 Implicitly Tagged Module, --- 1988 Syntax - --RWC;PolicyInformation FROM PKIX1Implicit88 {iso(1) RWC; Added ")" - --RWC;identified-organization(3)dod(6) internet(1) security(5) - --RWC;mechanisms(5) pkix(7)id-mod(0) id-pkix1-implicit-88(2)} - --- X.509 - --RWC;GeneralNames, CertificateSerialNumber FROM CertificateExtensions RWC; Removed "," - --RWC;{joint-iso-ccitt ds(5) module(1) certificateExtensions(26) 0} - - ub-security-categories, ub-privacy-mark-length, ub-integer-options FROM UpperBounds - -- RWC; Added to avoid SNACC ASN.1 Compiler link errors. - - CertificateSerialNumber, IssuerSerial - FROM AuthenticationFramework --RWC; Added - - GeneralNames FROM CommonX509Definitions ; --RWC; Added - - --- Extended Security Services - --- The construct "SEQUENCE SIZE (1..MAX) OF" appears in several ASN.1 --- constructs in this module. A valid ASN.1 SEQUENCE can have zero or --- more entries. The SIZE (1..MAX) construct constrains the SEQUENCE to --- have at least one entry. MAX indicates the upper bound is unspecified. --- Implementations are free to choose an upper bound that suits their --- environment. - --- Section 2.7 - -ReceiptRequest ::= SEQUENCE { - signedContentIdentifier ContentIdentifier, - receiptsFrom ReceiptsFrom, - receiptsTo SEQUENCE SIZE (1..ub-receiptsTo) OF GeneralNames } - -ub-receiptsTo INTEGER ::= 16 - -smime OBJECT IDENTIFIER ::= { pkcs-9 smime(16) } - -id-aa OBJECT IDENTIFIER ::= { pkcs-9 smime(16) 2 } - -id-aa-receiptRequest OBJECT IDENTIFIER ::= { id-aa 1 } - -ContentIdentifier ::= OCTET STRING - -id-aa-contentIdentifier OBJECT IDENTIFIER ::= { id-aa 7 } - -ReceiptsFrom ::= CHOICE { - allOrFirstTier [0] AllOrFirstTier, - -- formerly "allOrNone [0]AllOrNone" - receiptList [1] SEQUENCE OF GeneralNames } - -AllOrFirstTier ::= INTEGER { -- Formerly AllOrNone - allReceipts (0), - firstTierRecipients (1) } - - --- Section 2.8 - -Receipt ::= SEQUENCE { - version CMSVersion, -- Version is imported from [CMS] - contentType ContentType, - signedContentIdentifier ContentIdentifier, - originatorSignatureValue OCTET STRING } - -id-ct-receipt OBJECT IDENTIFIER ::= { smime id-ct(1) 1 } - --- Section 2.9 - -ContentHints ::= SEQUENCE { - contentDescription UTF8String OPTIONAL, --RWC;SIZE (1..MAX) OPTIONAL, - contentType ContentType } - -id-aa-contentHint OBJECT IDENTIFIER ::= { id-aa 4 } - --- Section 2.10 - -MsgSigDigest ::= OCTET STRING - -id-aa-msgSigDigest OBJECT IDENTIFIER ::= { id-aa 5 } - --- Section 2.11 - -ContentReference ::= SEQUENCE { - contentType ContentType, - signedContentIdentifier ContentIdentifier, - originatorSignatureValue OCTET STRING } - -id-aa-contentReference OBJECT IDENTIFIER ::= { id-aa 10 } - - --- Section 3.2 - -ESSSecurityLabel ::= SET { - security-policy-identifier SecurityPolicyIdentifier, - security-classification SecurityClassification OPTIONAL, - privacy-mark ESSPrivacyMark OPTIONAL, - security-categories SecurityCategories OPTIONAL } - -id-aa-securityLabel OBJECT IDENTIFIER ::= { id-aa 2} - -SecurityPolicyIdentifier ::= OBJECT IDENTIFIER - -SecurityClassification ::= INTEGER { - unmarked (0), - unclassified (1), - restricted (2), - confidential (3), - secret (4), - top-secret (5) } (0..ub-integer-options) - ---RWC; IMPORTED;ub-integer-options INTEGER ::= 256 - -ESSPrivacyMark ::= CHOICE { - pStringááááá PrintableString, --RWC;SIZE (1..ub-privacy-mark-length), - utf8Stringáá UTF8String --RWC;SIZE (1..MAX) -} - ---RWC; IMPORTED;ub-privacy-mark-length INTEGER ::= 128 - -SecurityCategories ::= SET SIZE (1..ub-security-categories) OF - SecurityCategory - ---RWC; IMPORTED;ub-security-categories INTEGER ::= 64 - -SecurityCategory ::= SEQUENCE { - type [0] OBJECT IDENTIFIER, - value [1] ANY --RWC;DEFINED BY type -} - ---Note: The aforementioned SecurityCategory syntax produces identical ---hex encodings as the following SecurityCategory syntax that is ---documented in the X.411 specification: --- ---SecurityCategory ::= SEQUENCE { --- type [0] SECURITY-CATEGORY, --- value [1] ANY DEFINED BY type } --- ---SECURITY-CATEGORY MACRO ::= ---BEGIN ---TYPE NOTATION ::= type | empty ---VALUE NOTATION ::= value (VALUE OBJECT IDENTIFIER) ---END - --- Section 3.4 - -EquivalentLabels ::= SEQUENCE OF ESSSecurityLabel - -id-aa-equivalentLabels OBJECT IDENTIFIER ::= { id-aa 9} - - --- Section 4.4 - -MLExpansionHistory ::= SEQUENCE - SIZE (1..ub-ml-expansion-history) OF MLData - -id-aa-mlExpandHistory OBJECT IDENTIFIER ::= { id-aa 3} - -ub-ml-expansion-history INTEGER ::= 64 - -MLData ::= SEQUENCE { - mailListIdentifier EntityIdentifier, - -- EntityIdentifier is imported from [CMS] - expansionTime GeneralizedTime, - mlReceiptPolicy MLReceiptPolicy OPTIONAL } - -EntityIdentifier ::= CHOICE { - issuerAndSerialNumber IssuerAndSerialNumber, - subjectKeyIdentifier KeyIdentifier } - -MLReceiptPolicy ::= CHOICE { - none [0] NULL, - insteadOf [1] SEQUENCE SIZE (1..MAX) OF GeneralNames, - inAdditionTo [2] SEQUENCE SIZE (1..MAX) OF GeneralNames } - - --- Section 5.4 - -SigningCertificate ::= SEQUENCE { - certs SEQUENCE OF ESSCertID, - policies SEQUENCE OF PolicyInformation OPTIONAL -} - -id-aa-signingCertificate OBJECT IDENTIFIER ::= { id-aa 4444 } --RWC;Removed } - -ESSCertID ::= SEQUENCE { - certHash CertHash, - issuerSerial IssuerSerial OPTIONAL -} - -CertHash ::= OCTET STRING -- SHA1 hash of entire certificate ---RWC; Modified "Hash" to "CertHash" to avoid crypto++ library contention. - ---RWC; ---RWC; Added for completeness ---RWC; - - - -- policyQualifierIds for Internet policy qualifiers - - id-pkix OBJECT IDENTIFIER ::= - { iso(1) identified-organization(3) dod(6) internet(1) - security(5) mechanisms(5) pkix(7) } - - id-qt OBJECT IDENTIFIER ::= { id-pkix 2 } - id-qt-cps OBJECT IDENTIFIER ::= { id-qt 1 } - id-qt-unotice OBJECT IDENTIFIER ::= { id-qt 2 } - - PolicyQualifierId ::= - OBJECT IDENTIFIER ( id-qt-cps | id-qt-unotice ) - - - - -END diff --git a/SecurityASN1/asn/sm_vdatypes.asn b/SecurityASN1/asn/sm_vdatypes.asn deleted file mode 100644 index 3fb591dc..00000000 --- a/SecurityASN1/asn/sm_vdatypes.asn +++ /dev/null @@ -1,13 +0,0 @@ --- @(#) sm_vdatypes.asn 1.4 4/27/98 14:51:24 -VdaEnhancedTypes DEFINITIONS ::= -BEGIN - --- NOTE: --- This module contains the ASN.1 defintions for types that are not --- supported by Snacc 1.3b1 (i.e. UniversalString) and some echanced --- types for handling large integers. --- - -BigIntegerStr ::= [UNIVERSAL 2] IMPLICIT OCTET STRING - -END diff --git a/SecurityASN1/asn/sm_x411mtsas.asn b/SecurityASN1/asn/sm_x411mtsas.asn deleted file mode 100644 index 8e819a0f..00000000 --- a/SecurityASN1/asn/sm_x411mtsas.asn +++ /dev/null @@ -1,158 +0,0 @@ --- @(#) sm_x411mtsas.asn 1.3 2/25/98 16:39:35 -MTSAbstractService --- { joint-iso-ccitt mhs-motis(6) mts(3) modules(0) --- mts-abstract-service(1) } - -DEFINITIONS IMPLICIT TAGS ::= - -BEGIN - --- Prologue - --- Exports everything - --- Import UpperBounds Information - -IMPORTS - ub-bit-options, ub-built-in-content-type, - ub-built-in-encoded-information-types, ub-common-name-length, - ub-content-id-length, ub-content-length, ub-content-types, - ub-country-name-alpha-length, ub-country-name-numeric-length, - ub-dl-expansions, ub-domain-defined-attribute-value-length, - ub-domain-defined-attributes, ub-domain-defined-attribute-type-length, - ub-domain-name-length, - ub-encoded-information-types, ub-extension-attributes, ub-extension-types, - ub-generation-qualifier-length, ub-given-name-length, ub-initials-length, - ub-integer-options, ub-labels-and-redirections, ub-local-id-length, - ub-mta-name-length, ub-mts-user-types, ub-numeric-user-id-length, - ub-organization-name-length, ub-organizational-unit-name-length, - ub-organizational-units, ub-password-length, ub-pds-name-length, - ub-pds-parameter-length, - ub-postal-code-length, ub-privacy-mark-length, ub-queue-size, - ub-reason-codes, ub-recipients, ub-recipient-number-for-advice-length, - ub-redirections, ub-security-categories, ub-security-labels, - ub-security-problems, ub-supplementary-info-length, ub-surname-length, - ub-terminal-id-length, ub-tsap-id-length, - ub-x121-address-length - FROM UpperBounds { upperBounds } ; - --- O/R names - --- not used --- --- ORName ::= [APPLICATION 0] SEQUENCE { --- address COMPONENTS OF ORAddress, --- directory-name [0] Name OPTIONAL } - -ORAddress ::= SEQUENCE { - standard-attributes StandardAttributes, - domain-defined-attributes DomainDefinedAttributes OPTIONAL, - - -- also see teletex-domain-defined-attributes - - extension-attributes ExtensionAttributes OPTIONAL } - --- Note - The OR-address is semantically absent from the OR-name --- if the standard-attribute sequence is empty and the --- domain-defined-attributes and extension-attributes are both omitted. - --- Standard attributes - -StandardAttributes ::= SEQUENCE { - country-name CountryName OPTIONAL, - administration-domain-name AdministrationDomainName OPTIONAL, - -- also see extended-network-address - network-address [0] NetworkAddress OPTIONAL, - terminal-identifier [1] TerminalIdentifier OPTIONAL, - private-domain-name [2] PrivateDomainName OPTIONAL, - --also see teletex-organization-name - organization-name [3] OrganizationName OPTIONAL, - numeric-user-identifier [4] NumericUserIdentifier OPTIONAL, - --also see teletex-personal-name - personal-name [5] PersonalName OPTIONAL, - --also see teletex-organizational-unit-names - organizational-unit-names [6] OrganizationUnitNames OPTIONAL } - - -CountryName ::= [APPLICATION 1] CHOICE { - x121-dcc-code NumericString (SIZE (ub-country-name-numeric-length)), - - iso-3166-alpha2-code PrintableString (SIZE (ub-country-name-alpha-length)) } - -AdministrationDomainName ::= [APPLICATION 2] CHOICE { - numeric NumericString (SIZE (0..ub-domain-name-length)), - printable PrintableString (SIZE (0..ub-domain-name-length)) } - -NetworkAddress ::= X121Address - -X121Address ::= NumericString (SIZE (1..ub-x121-address-length)) - -TerminalIdentifier ::= PrintableString (SIZE (1..ub-terminal-id-length)) - -PrivateDomainName ::= CHOICE { - numeric NumericString (SIZE (1. .ub-domain-name-length)), - printable PrintableString (SIZE (1..ub-domain-name-length)) } - -OrganizationName ::= PrintableString (SIZE (1..ub-organization-name-length)) - -NumericUserIdentifier ::= NumericString (SIZE (1..ub-numeric-user-id-length)) - -PersonalName ::= SET { - surname [0] PrintableString (SIZE (1..ub-surname-length)), - given-name [1] PrintableString (SIZE (1..ub-given-name-length)) OPTIONAL, - initials [2] PrintableString (SIZE (1..ub-initials-length)) OPTIONAL, - generation-qualifier [3] PrintableString - (SIZE (1..ub-generation-qualifier-length)) OPTIONAL } - -OrganizationUnitNames ::= SEQUENCE SIZE (1..ub-organizational-units) OF - OrganizationUnitName - -OrganizationUnitName ::= PrintableString - (SIZE (1..ub-organizational-unit-name-length)) - --- Domain-defined attributes - -DomainDefinedAttributes ::= SEQUENCE SIZE (1..ub-domain-defined-attributes) - OF DomainDefinedAttribute - -DomainDefinedAttribute ::= SEQUENCE { - type PrintableString (SIZE (1..ub-domain-defined-attribute-type-length)), - value PrintableString (SIZE (1..ub-domain-defined-attribute-value-length)) } - --- Extension attributes - -ExtensionAttributes ::= SET SIZE (1. .ub-extension-attributes) OF - ExtensionAttribute - -ExtensionAttribute ::= SEQUENCE { - extension-attribute-type [0] INTEGER, - extension-attribute-value [1] ANY } - -CommonName ::= PrintableString (SIZE (1..ub-common-name-length)) - -TeletexCommonName ::= TeletexString (SIZE (1..ub-common-name-length)) - -TeletexOrganizationalName ::= TeletexString - (SIZE (1..ub-organization-name-length)) - -TeletexPersonalName ::= SET { - surname [0] TeletexString (SIZE (1..ub-surname-length)), - given-name [1] TeletexString (SIZE (1..ub-given-name-length)) OPTIONAL, - initials [2] TeletexString (SIZE (1..ub-initials-length)) OPTIONAL, - generation-qualifier [3] TeletexString - (SIZE (1..ub-generation-qualifier-length)) OPTIONAL } - -TeletexOrganizationUnitNames ::= SEQUENCE SIZE (1..ub-organizational-units) OF - TeletexOrganizationalUnitName - -TeletexOrganizationalUnitName ::= TeletexString - (SIZE (1..ub-organizational-unit-name-length)) - -TeletexDomainDefinedAttributes ::= SEQUENCE - SIZE (1..ub-domain-defined-attributes) OF TeletexDomainDefinedAttribute - -TeletexDomainDefinedAttribute ::= SEQUENCE { - type TeletexString (SIZE (1..ub-domain-defined-attribute-type-length)), - value TeletexString (SIZE (1..ub-domain-defined-attribute-value-length)) } - -END diff --git a/SecurityASN1/asn/sm_x411ub.asn b/SecurityASN1/asn/sm_x411ub.asn deleted file mode 100644 index 2a9ed239..00000000 --- a/SecurityASN1/asn/sm_x411ub.asn +++ /dev/null @@ -1,131 +0,0 @@ --- @(#) sm_x411ub.asn 1.3 3/4/98 15:25:57 -UpperBounds --- { joint-iso-ccitt mhs-motis(6) mts(3) modules(0) upper-bounds(3) } - -DEFINITIONS IMPLICIT TAGS ::= - -BEGIN - --- Prologue - --- Exports everything - --- IMPORTS nothing - --- Upper bounds - -ub-integer-options INTEGER ::= 256 - -ub-queue-size INTEGER ::= 2147483647 -- the largest integer in 32 bits - -ub-content-length INTEGER ::= 2147483647 -- the largest integer in 32 bits - -ub-password-length INTEGER ::= 62 - -ub-bit-options INTEGER ::= 16 - -ub-content-types INTEGER ::= 1024 - -ub-tsap-id-length INTEGER ::= 16 - -ub-recipients INTEGER ::= 32767 - -ub-content-id-length INTEGER ::= 16 - -ub-x121-address-length INTEGER ::= 15 - -ub-mts-user-types INTEGER ::= 256 - -ub-reason-codes INTEGER ::= 32767 - -ub-diagnostic-codes INTEGER ::= 32767 - -ub-supplementary-info-length INTEGER ::= 256 - -ub-extension-types INTEGER ::= 256 - -ub-recipient-number-for-advice-length INTEGER ::= 32 - -ub-content-correlator-length INTEGER ::= 512 - -ub-redirections INTEGER ::= 512 - -ub-dl-expansions INTEGER ::= 512 - -ub-built-in-content-type INTEGER ::= 32767 - -ub-local-id-length INTEGER ::= 32 - -ub-mta-name-length INTEGER ::= 32 - -ub-country-name-numeric-length INTEGER ::= 3 - -ub-country-name-alpha-length INTEGER ::= 2 - -ub-domain-name-length INTEGER ::= 16 - -ub-terminal-id-length INTEGER ::= 24 - -ub-organization-name-length INTEGER ::= 64 - -ub-numeric-user-id-length INTEGER ::= 32 - -ub-surname-length INTEGER ::= 40 - -ub-given-name-length INTEGER ::= 16 - -ub-initials-length INTEGER ::= 5 - -ub-generation-qualifier-length INTEGER ::= 3 - -ub-organizational-units INTEGER ::= 4 - -ub-organizational-unit-name-length INTEGER ::= 32 - -ub-domain-defined-attributes INTEGER ::= 4 - -ub-domain-defined-attribute-type-length INTEGER ::= 8 - -ub-domain-defined-attribute-value-length INTEGER ::= 128 - -ub-extension-attributes INTEGER ::= 256 - -ub-common-name-length INTEGER ::= 64 - -ub-pds-name-length INTEGER ::= 16 - -ub-postal-code-length INTEGER ::= 16 - -ub-pds-parameter-length INTEGER ::= 30 - -ub-physical-address-lines INTEGER ::= 6 - -ub-unformatted-address-length INTEGER ::= 180 - -ub-e163-4-number-length INTEGER ::= 15 - -ub-e163-4-sub-address-length INTEGER ::= 40 - -ub-built-in-encoded-information-types INTEGER ::= 32 - -ub-teletex-private-use-length INTEGER ::= 128 - -ub-encoded-information-types INTEGER ::= 1024 - -ub-security-labels INTEGER ::= 256 - -ub-labels-and-redirections INTEGER ::= 256 - -ub-security-problems INTEGER ::= 256 - -ub-privacy-mark-length INTEGER ::= 128 - -ub-security-categories INTEGER ::= 64 - -ub-transfers INTEGER ::= 512 - -ub-bilateral-info INTEGER ::= 1024 - -ub-additional-info INTEGER ::= 1024 - -END -- of UpperBounds diff --git a/SecurityASN1/asn/sm_x501if.asn b/SecurityASN1/asn/sm_x501if.asn deleted file mode 100644 index 2673eea4..00000000 --- a/SecurityASN1/asn/sm_x501if.asn +++ /dev/null @@ -1,48 +0,0 @@ --- @(#) sm_x501if.asn 1.2 2/24/98 13:39:21 -InformationFramework --- --- oid defined in sm_x501ud.asn --- --- { joint-iso-itu-t(1) ds(5) modules(1) informationFramework(1) 3 } -DEFINITIONS EXPLICIT TAGS ::= -BEGIN - - --- Added this because the CMS module needs it and thinks it comes from --- this module. --- --- Pierce 2/23/98 - -Attributes ::= SET OF Attribute - -AttributeType ::= OBJECT IDENTIFIER - -AttributeValue ::= ANY - -Attribute ::= SEQUENCE { - type AttributeType, - values SET OF AttributeValue -} - -Name ::= CHOICE { - rDNSequence RDNSequence -} - -DistinguishedName ::= RDNSequence - -RDNSequence ::= SEQUENCE OF RelativeDistinguishedName - -RelativeDistinguishedName ::= SET SIZE (1..MAX) OF - AttributeTypeAndDistinguishedValue - - -AttributeTypeAndDistinguishedValue ::= SEQUENCE { - type OBJECT IDENTIFIER, - value ANY, - primaryDistinguished BOOLEAN DEFAULT TRUE, - valuesWithContext SET SIZE (1 .. MAX) OF SEQUENCE { - distingAttrValue OBJECT IDENTIFIER OPTIONAL, - contextList SET SIZE (1 .. MAX) OF ANY } OPTIONAL -} - -END diff --git a/SecurityASN1/asn/sm_x501ud.asn b/SecurityASN1/asn/sm_x501ud.asn deleted file mode 100644 index b5313955..00000000 --- a/SecurityASN1/asn/sm_x501ud.asn +++ /dev/null @@ -1,136 +0,0 @@ --- @(#) sm_x501ud.asn 1.3 3/2/98 12:55:28 -UsefulDefinitions --- { joint-iso-ccitt ds(5) module(1) usefulDefinitions(0) 2 } -DEFINITIONS ::= - -BEGIN - --- EXPORTS All -- - --- The types and values defined in this module are exported for use in the --- other ASN.1 modules contained within the Directory Specifications, and --- for the use of other applications which will use them to access --- Directory services. Other applications may use them for their own purposes, --- but this will not constrain extensions and modifications needed to maintain --- or improve the Directory service. - -ds OBJECT IDENTIFIER ::= { joint-iso-ccitt ds(5) } - --- categories of information object - -module OBJECT IDENTIFIER ::= {ds 1} - -serviceElement OBJECT IDENTIFIER ::= {ds 2} -applicationContext OBJECT IDENTIFIER ::= {ds 3} -attributeType OBJECT IDENTIFIER ::= {ds 4} -attributeSyntax OBJECT IDENTIFIER ::= {ds 5} -objectClass OBJECT IDENTIFIER ::= {ds 6} --- attributeSet OBJECT IDENTIFIER ::= {ds 7} -dsAlgorithm OBJECT IDENTIFIER ::= {ds 8} -abstractSyntax OBJECT IDENTIFIER ::= {ds 9} --- object OBJECT IDENTIFIER ::= {ds 10} --- port OBJECT IDENTIFIER ::= {ds 11} -dsaOperationalAttribute OBJECT IDENTIFIER ::= {ds 12} -matchingRule OBJECT IDENTIFIER ::= {ds 13} -knowledgeMatchingRule OBJECT IDENTIFIER ::= {ds 14} -nameForm OBJECT IDENTIFIER ::= {ds 15} -group OBJECT IDENTIFIER ::= {ds 16} -subentry OBJECT IDENTIFIER ::= {ds 17} -operationalAttributeType OBJECT IDENTIFIER ::= {ds 18} -operationalBinding OBJECT IDENTIFIER ::= {ds 19} -schemaObjectClass OBJECT IDENTIFIER ::= {ds 20} -schemaOperationalAttribute OBJECT IDENTIFIER ::= {ds 21} -administrativeRoles OBJECT IDENTIFIER ::= {ds 23} -accessControlAttribute OBJECT IDENTIFIER ::= {ds 24} -rosObject OBJECT IDENTIFIER ::= {ds 25} -contract OBJECT IDENTIFIER ::= {ds 26} -package OBJECT IDENTIFIER ::= {ds 27} -accessControlSchemes OBJECT IDENTIFIER ::= {ds 28} -certificateExtension OBJECT IDENTIFIER ::= {ds 29} -managementObject OBJECT IDENTIFIER ::= {ds 30} --- modules -- - --- already defined --- --- usefulDefinitions OBJECT IDENTIFIER ::= {module usefulDefinitions(0) 3} -informationFramework OBJECT IDENTIFIER ::= {module informationFramework(1) 3} -directoryAbstractService OBJECT IDENTIFIER ::= {module directoryAbstractService(2) 3} -distributedOperations OBJECT IDENTIFIER ::= {module distributedOperations(3) 3} -protocolObjectIdentifiers OBJECT IDENTIFIER ::= {module protocolObjectIdentifiers (4) 3} -selectedAttributeTypes OBJECT IDENTIFIER ::= {module selectedAttributeTypes(5) 3} -selectedObjectClasses OBJECT IDENTIFIER ::= {module selectedObjectClasses(6) 3} -authenticationFramework OBJECT IDENTIFIER ::= {module authenticationFramework(7) 3} -algorithmObjectIdentifiers OBJECT IDENTIFIER ::= {module algorithmObjectIdentifiers(8) 3} -directoryObjectIdentifiers OBJECT IDENTIFIER ::= {module directoryObjectIdentifiers(9) 3} -upperBounds OBJECT IDENTIFIER ::= {module upperBounds(10) 3} -dap OBJECT IDENTIFIER ::= {module dap(11) 3} - -dsp OBJECT IDENTIFIER ::= {module dsp(12) 3} -distributedDirectoryOIDs OBJECT IDENTIFIER ::= {module distributedDirectoryOIDs(13) 3} -directoryShadowOIDs OBJECT IDENTIFIER ::= {module directoryShadowOIDs(14) 3} -directoryShadowAbstractService OBJECT IDENTIFIER ::= {module directoryShadowAbstractService(15) 3} -disp OBJECT IDENTIFIER ::= {module disp(16) 3} -dop OBJECT IDENTIFIER ::= {module dop(17) 3} -opBindingManagement OBJECT IDENTIFIER ::= {module opBindingManagement(18) 3} -opBindingOIDs OBJECT IDENTIFIER ::= {module opBindingOIDs(19) 3} -hierarchicalOperationalBindings OBJECT IDENTIFIER ::= {module hierarchicalOperationalBindings(20) 3} -dsaOperationalAttributeTypes OBJECT IDENTIFIER ::= {module dsaOperationalAttributeTypes(22) 3} -schemaAdministration OBJECT IDENTIFIER ::= {module schemaAdministration(23) 3} -basicAccessControl OBJECT IDENTIFIER ::= {module basicAccessControl(24) 3} -directoryOperationalBindingTypes OBJECT IDENTIFIER ::= {module directoryOperationalBindingTypes(25) 3} -certificateExtensions OBJECT IDENTIFIER ::= {module certificateExtensions (26) 0} -directoryManagement OBJECT IDENTIFIER ::= {module directoryManagement (27) 1} -enhancedSecurity OBJECT IDENTIFIER ::= {module enhancedSecurity (28) } - - --- synonyms -- -id-oc OBJECT IDENTIFIER ::= objectClass -id-at OBJECT IDENTIFIER ::= attributeType -id-as OBJECT IDENTIFIER ::= abstractSyntax -id-mr OBJECT IDENTIFIER ::= matchingRule -id-nf OBJECT IDENTIFIER ::= nameForm -id-sc OBJECT IDENTIFIER ::= subentry -id-oa OBJECT IDENTIFIER ::= operationalAttributeType -id-ob OBJECT IDENTIFIER ::= operationalBinding -id-doa OBJECT IDENTIFIER ::= dsaOperationalAttribute -id-kmr OBJECT IDENTIFIER ::= knowledgeMatchingRule -id-soc OBJECT IDENTIFIER ::= schemaObjectClass -id-soa OBJECT IDENTIFIER ::= schemaOperationalAttribute -id-ar OBJECT IDENTIFIER ::= administrativeRoles -id-aca OBJECT IDENTIFIER ::= accessControlAttribute -id-ac OBJECT IDENTIFIER ::= applicationContext -id-rosObject OBJECT IDENTIFIER ::= rosObject -id-contract OBJECT IDENTIFIER ::= contract -id-package OBJECT IDENTIFIER ::= package -id-acScheme OBJECT IDENTIFIER ::= accessControlSchemes -id-ce OBJECT IDENTIFIER ::= certificateExtension -id-mgt OBJECT IDENTIFIER ::= managementObject --- obsolete module identifiers -- --- usefulDefinitions OBJECT IDENTIFIER ::= {module 0} --- informationFramework OBJECT IDENTIFIER ::= {module 1} --- directoryAbstractService OBJECT IDENTIFIER ::= {module 2} --- distributedOperations OBJECT IDENTIFIER ::= {module 3} --- protocolObjectIdentifiers OBJECT IDENTIFIER ::= {module 4} --- selectedAttributeTypes OBJECT IDENTIFIER ::= {module 5} --- selectedObjectClasses OBJECT IDENTIFIER ::= {module 6} --- authenticationFramework OBJECT IDENTIFIER ::= {module 7} --- algorithmObjectIdentifiers OBJECT IDENTIFIER ::= {module 8} --- directoryObjectIdentifiers OBJECT IDENTIFIER ::= {module 9} --- upperBounds OBJECT IDENTIFIER ::= {module 10} --- dap OBJECT IDENTIFIER ::= {module 11} --- dsp OBJECT IDENTIFIER ::= {module 12} --- distributedDirectoryObjectIdentifiers --- OBJECT IDENTIFIER ::= {module 13} --- unused module identifiers -- --- directoryShadowOIDs OBJECT IDENTIFIER ::= {module 14} --- directoryShadowAbstractService OBJECT IDENTIFIER ::= {module 15} --- disp OBJECT IDENTIFIER ::= {module 16} --- dop OBJECT IDENTIFIER ::= {module 17} --- opBindingManagement OBJECT IDENTIFIER ::= {module 18} --- opBindingOIDs OBJECT IDENTIFIER ::= {module 19} --- hierarchicalOperationalBindings OBJECT IDENTIFIER ::= {module 20} --- dsaOperationalAttributeTypes OBJECT IDENTIFIER ::= {module 22} --- schemaAdministration OBJECT IDENTIFIER ::= {module 23} --- basicAccessControl OBJECT IDENTIFIER ::= {module 24} --- operationalBindingOIDs OBJECT IDENTIFIER ::= {module 25} -END diff --git a/SecurityASN1/asn/sm_x509af.asn b/SecurityASN1/asn/sm_x509af.asn deleted file mode 100644 index 8fd9ef6e..00000000 --- a/SecurityASN1/asn/sm_x509af.asn +++ /dev/null @@ -1,215 +0,0 @@ --- @(#) sm_x509af.asn 1.2 2/24/98 13:40:34 -AuthenticationFramework --- --- oid defined in sm_x501ud.asn --- --- {joint-iso-ccitt ds(5) module(1) authenticationFramework(7) 3} - -DEFINITIONS ::= - -BEGIN - --- EXPORTS All -- --- The types and values defined in this module are exported for use in the --- other ASN.1 modules contained --- within the Directory Specifications, and for the use of other applications --- which will use them to access Directory services. Other applications may --- use them for their own purposes, but this will not constrain --- extensions and modifications needed to maintain or improve the Directory --- service. - -IMPORTS - - BigIntegerStr - FROM VdaEnhancedTypes - - id-at, informationFramework, upperBounds, selectedAttributeTypes, - basicAccessControl, certificateExtensions - FROM UsefulDefinitions { usefulDefinitions } - - Name, Attribute, AttributeType - FROM InformationFramework { informationFramework } - - ub-password-length - FROM UpperBounds { upperBounds } - --- not used --- AuthenticationLevel --- FROM BasicAccessControl { basicAccessControl } - --- GeneralNames --- FROM CertificateExtensions { certificateExtensions } - - GeneralNames - FROM CommonX509Definitions - - UniqueIdentifier - FROM SelectedAttributeTypes { selectedAttributeTypes } ; - --- basic certificate definition - -Certificate ::= SEQUENCE { - certificateToSign CertificateToSign, - algorithmIdentifier AlgorithmIdentifier, - signatureValue BIT STRING } - -CertificateToSign ::= SEQUENCE { - version [0] Version DEFAULT v1, - serialNumber CertificateSerialNumber, - signature AlgorithmIdentifier, - issuer Name, - validity Validity, - subject Name, - subjectPublicKeyInfo SubjectPublicKeyInfo, - -- if present, version must be v2 or v3 - issuerUniqueIdentifier [1] IMPLICIT UniqueIdentifier OPTIONAL, - -- if present, version must be v2 or v3 - subjectUniqueIdentifier [2] IMPLICIT UniqueIdentifier OPTIONAL, - -- If present, version must be v3 - extensions [3] Extensions OPTIONAL } - -Version ::= INTEGER { v1(0), v2(1), v3(2) } - --- CertificateSerialNumber ::= INTEGER - -CertificateSerialNumber ::= BigIntegerStr - - -AlgorithmIdentifier ::= SEQUENCE { - algorithm OBJECT IDENTIFIER, - parameters ANY OPTIONAL } - -Validity ::= SEQUENCE { - notBefore Time, - notAfter Time } - -SubjectPublicKeyInfo ::= SEQUENCE { - algorithm AlgorithmIdentifier, - subjectPublicKey BIT STRING } - -Time ::= CHOICE { - utcTime UTCTime, - generalizedTime GeneralizedTime } - -Extensions ::= SEQUENCE OF Extension - --- For those extensions where ordering of individual extensions within the --- SEQUENCE is significant, the specification of those individual extensions --- shall include the rules for the significance of the order therein - -Extension ::= SEQUENCE { - extnId OBJECT IDENTIFIER, - critical BOOLEAN DEFAULT FALSE, - -- extnValue contains a DER encoding - extnValue OCTET STRING } - --- other certifiate constructs - -Certificates ::= SEQUENCE { - userCertificate Certificate, - certificationPath ForwardCertificationPath OPTIONAL } - -ForwardCertificationPath ::= SEQUENCE OF CrossCertificates - -CrossCertificates ::= SET OF Certificate - -CertificationPath ::= SEQUENCE { - userCertificate Certificate, - theCACertificates SEQUENCE OF CertificatePair OPTIONAL } - -CertificatePair ::= SEQUENCE { - -- at least one of the pair shall be present - forward [0] Certificate OPTIONAL, - reverse [1] Certificate OPTIONAL } - --- certificate revocation list (CRL) - -CertificateList ::= SEQUENCE { - crlToSign CRLToSign, - algorithmIdentifier AlgorithmIdentifier, - signatureValue BIT STRING } - -CRLToSign ::= SEQUENCE { - version Version OPTIONAL, -- if present, version must be v2 - signature AlgorithmIdentifier, - issuer Name, - thisUpdate Time, - nextUpdate Time OPTIONAL, - revokedCertificates SEQUENCE OF SEQUENCE { - userCertificate CertificateSerialNumber, - revocationDate Time, - crlEntryExtensions Extensions OPTIONAL } OPTIONAL, - crlExtensions [0] Extensions OPTIONAL } - --- attribute certificate -AttributeCertificationPath ::= SEQUENCE { - attributeCertificate AttributeCertificate, - acPath SEQUENCE OF ACPathData OPTIONAL } - -ACPathData ::= SEQUENCE { - certificate [0] Certificate OPTIONAL, - attributeCertificate [1] AttributeCertificate OPTIONAL } - -AttributeCertificate ::= SEQUENCE { - attributeCertificateInfo AttributeCertificateInfo, - algorithmIdentifier AlgorithmIdentifier, - signatureValue BIT STRING } - -AttributeCertificateInfo ::= SEQUENCE { - version Version DEFAULT v1, - subject CHOICE { - baseCertificateID [0] IssuerSerial, -- associated with a Public Key - -- Certificate - subjectName [1] GeneralNames }, -- associated with a name - issuer GeneralNames, -- CA issuing the attribute certificate - signature AlgorithmIdentifier, - serialNumber CertificateSerialNumber, - attCertValidityPeriod AttCertValidityPeriod, - attributes SEQUENCE OF Attribute, - issuerUniqueID UniqueIdentifier OPTIONAL, - extensions Extensions OPTIONAL } - -IssuerSerial ::= SEQUENCE { - issuer GeneralNames, - serial CertificateSerialNumber, - issuerUID UniqueIdentifier OPTIONAL} - -AttCertValidityPeriod ::= SEQUENCE { - notBeforeTime GeneralizedTime, - notAfterTime GeneralizedTime } - -AttributeCertificateAssertion ::= SEQUENCE { - -- At least one component of the sequence must be present - subject [0] CHOICE { - baseCertificateID [0] IssuerSerial, - subjectName [1] Name } OPTIONAL, - issuer [1] Name OPTIONAL, - attCertValidity [2] GeneralizedTime OPTIONAL, - attType [3] SET OF AttributeType OPTIONAL } - --- attribute types -- - -UserPassword ::= OCTET STRING (SIZE (0..ub-password-length)) - -UserCertificate ::= Certificate - -CACertificate ::= Certificate - -CrossCertificatePair ::= CertificatePair - -AuthorityRevocationList ::= CertificateList - -CertificateRevocationList ::= CertificateList - -AttributeCertificateRevocationList ::= CertificateList - --- object identifier assignments -- -id-at-userPassword OBJECT IDENTIFIER ::= {id-at 35} -id-at-userCertificate OBJECT IDENTIFIER ::= {id-at 36} -id-at-cAcertificate OBJECT IDENTIFIER ::= {id-at 37} -id-at-authorityRevocationList OBJECT IDENTIFIER ::= {id-at 38} -id-at-certificateRevocationList OBJECT IDENTIFIER ::= {id-at 39} -id-at-crossCertificatePair OBJECT IDENTIFIER ::= {id-at 40} -id-at-attributeCertificate OBJECT IDENTIFIER ::= {id-at 58} - -END diff --git a/SecurityASN1/asn/sm_x509ce.asn b/SecurityASN1/asn/sm_x509ce.asn deleted file mode 100644 index b096a241..00000000 --- a/SecurityASN1/asn/sm_x509ce.asn +++ /dev/null @@ -1,265 +0,0 @@ --- @(#) sm_x509ce.asn 1.3 3/4/98 15:25:14 -CertificateExtensions --- --- oid defined sm_x501ud.asn --- {joint-iso-ccitt ds(5) module(1) certificateExtensions(26) 0} - -DEFINITIONS IMPLICIT TAGS ::= - -BEGIN - --- EXPORTS ALL - -IMPORTS - id-at, id-ce, id-mr, informationFramework, authenticationFramework, - selectedAttributeTypes, upperBounds - FROM UsefulDefinitions { usefulDefinitions } - - Name, RelativeDistinguishedName, Attribute - FROM InformationFramework { informationFramework } - - GeneralNames, GeneralName - FROM CommonX509Definitions - - CertificateSerialNumber, CertificateList, AlgorithmIdentifier - FROM AuthenticationFramework { authenticationFramework } - - DirectoryString - FROM SelectedAttributeTypes { selectedAttributeTypes } - - ORAddress - FROM MTSAbstractService { mTSAbstractService } - - id-pkix - FROM ExtendedSecurityServices { extendedSecurityServices }; - --- Unless explicitly noted otherwise, there is no significance to the ordering --- of components of a SEQUENCE OF construct in this specification. - --- Key and policy information extensions -- - -AuthorityKeyIdentifier ::= SEQUENCE { - keyIdentifier [0] KeyIdentifier OPTIONAL, - authorityCertIssuer [1] GeneralNames OPTIONAL, - authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL } - -KeyIdentifier ::= OCTET STRING - -SubjectKeyIdentifier ::= KeyIdentifier - -KeyUsage ::= BIT STRING { - digitalSignature (0), - nonRepudiation (1), - keyEncipherment (2), - dataEncipherment (3), - keyAgreement (4), - keyCertSign (5), - cRLSign (6), - encipherOnly (7), - decipherOnly (8) } - -KeyPurposeId ::= OBJECT IDENTIFIER - --- Added 9/14/00 by dmitch -ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId - -PrivateKeyUsagePeriod ::= SEQUENCE { - notBefore [0] GeneralizedTime OPTIONAL, - notAfter [1] GeneralizedTime OPTIONAL } - ( WITH COMPONENTS {..., notBefore PRESENT} | - WITH COMPONENTS {..., notAfter PRESENT} ) - - -CertificatePoliciesSyntax ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation - -PolicyInformation ::= SEQUENCE { - policyIdentifier CertPolicyId, - policyQualifiers SEQUENCE SIZE (1..MAX) OF PolicyQualifierInfo OPTIONAL } - -CertPolicyId ::= OBJECT IDENTIFIER - -PolicyQualifierInfo ::= SEQUENCE { - policyQualifierId OBJECT IDENTIFIER, - qualifier ANY OPTIONAL } - -PolicyMappingsSyntax ::= SEQUENCE SIZE (1..MAX) OF SEQUENCE { - issuerDomainPolicy CertPolicyId, - subjectDomainPolicy CertPolicyId } - -SupportedAlgorithm ::= SEQUENCE { - algorithmIdentifier AlgorithmIdentifier, - intendedUsage [0] KeyUsage OPTIONAL, - intendedCertificatePolicies [1] CertificatePoliciesSyntax OPTIONAL } - --- Certificate subject and certificate issuer attributes extensions -- - -SubjectName ::= GeneralNames - --- moved to sm_x509cmn.asn since both sm_x509af.asn and sm_x509ce.asn need --- it --- --- GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName - --- GeneralName ::= CHOICE { --- otherName [0] OTHER-NAME, - -- rfc822Name [1] IA5String, - -- dNSName [2] IA5String, - -- x400Address [3] ORAddress, - -- directoryName [4] Name, - -- ediPartyName [5] EDIPartyName, - -- uniformResourceIdentifier [6] IA5String, - -- iPAddress [7] OCTET STRING, - -- registeredID [8] OBJECT IDENTIFIER } --- --- OTHER-NAME ::= OBJECT IDENTIFIER - --- EDIPartyName ::= SEQUENCE { - -- nameAssigner [0] DirectoryString OPTIONAL, - -- partyName [1] DirectoryString } --- - -IssuerAltName ::= GeneralNames - -SubjectDirectoryAttributes ::= AttributesSyntax - -AttributesSyntax ::= SEQUENCE SIZE (1..MAX) OF Attribute - - --- Certification path constraints extensions -- - -BasicConstraintsSyntax ::= SEQUENCE { - cA BOOLEAN DEFAULT FALSE, - pathLenConstraint INTEGER (0..MAX) OPTIONAL } - -NameConstraintsSyntax ::= SEQUENCE { - permittedSubtrees [0] GeneralSubtrees OPTIONAL, - excludedSubtrees [1] GeneralSubtrees OPTIONAL } - -GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree - -GeneralSubtree ::= SEQUENCE { - base GeneralName, - minimum [0] BaseDistance DEFAULT 0, - maximum [1] BaseDistance OPTIONAL } - -BaseDistance ::= INTEGER (0..MAX) - -PolicyConstraintsSyntax ::= SEQUENCE { - requireExplicitPolicy [0] SkipCerts OPTIONAL, - inhibitPolicyMapping [1] SkipCerts OPTIONAL } - -SkipCerts ::= INTEGER (0..MAX) - -CertPolicySet ::= SEQUENCE OF CertPolicyId - --- Basic CRL extensions -- - -CRLNumber ::= INTEGER (0..MAX) - -CRLReason ::= ENUMERATED { - unspecified (0), - keyCompromise (1), - cACompromise (2), - affiliationChanged (3), - superseded (4), - cessationOfOperation (5), - certificateHold (6), -- note 7 is not used by this spec. - removeFromCRL (8) } - -HoldInstruction ::= OBJECT IDENTIFIER - - -InvalidityDate ::= GeneralizedTime - --- CRL distribution points and delta-CRL extensions -- - -CRLDistPointsSyntax ::= SEQUENCE SIZE (1..MAX) OF DistributionPoint - -DistributionPoint ::= SEQUENCE { - distributionPoint [0] DistributionPointName OPTIONAL, - reasons [1] ReasonFlags OPTIONAL, - cRLIssuer [2] GeneralNames OPTIONAL } - -DistributionPointName ::= CHOICE { - fullName [0] GeneralNames, - nameRelativeToCRLIssuer [1] RelativeDistinguishedName } - -ReasonFlags ::= BIT STRING { - unused (0), - keyCompromise (1), - caCompromise (2), - affiliationChanged (3), - superseded (4), - cessationOfOperation (5), - certificateHold (6) } - -IssuingDistPointSyntax ::= SEQUENCE { - distributionPoint [0] DistributionPointName OPTIONAL, - onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE, - onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE, - onlySomeReasons [3] ReasonFlags OPTIONAL, - indirectCRL [4] BOOLEAN DEFAULT FALSE } - -CertificateIssuer ::= GeneralNames - -BaseCRLNumber ::= CRLNumber - -DeltaRevocationList ::= CertificateList - --- Matching rules - --- removed. Our ASN.1 compiler does not support matching ruling. We will --- do this manually -Pierce --- - --- end of Matching rules - --- Object identifier assignments -- - -id-at-supportedAlgorithms OBJECT IDENTIFIER ::= {id-at 52} -id-at-deltaRevocationList OBJECT IDENTIFIER ::= {id-at 53} -id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= {id-ce 9} -id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= {id-ce 14} -id-ce-keyUsage OBJECT IDENTIFIER ::= {id-ce 15} -id-ce-privateKeyUsagePeriod OBJECT IDENTIFIER ::= {id-ce 16} -id-ce-subjectAltName OBJECT IDENTIFIER ::= {id-ce 17} -id-ce-issuerAltName OBJECT IDENTIFIER ::= {id-ce 18} -id-ce-basicConstraints OBJECT IDENTIFIER ::= {id-ce 19} -id-ce-cRLNumber OBJECT IDENTIFIER ::= {id-ce 20} -id-ce-reasonCode OBJECT IDENTIFIER ::= {id-ce 21} -id-ce-instructionCode OBJECT IDENTIFIER ::= {id-ce 23} -id-ce-invalidityDate OBJECT IDENTIFIER ::= {id-ce 24} -id-ce-deltaCRLIndicator OBJECT IDENTIFIER ::= {id-ce 27} -id-ce-issuingDistributionPoint OBJECT IDENTIFIER ::= {id-ce 28} -id-ce-certificateIssuer OBJECT IDENTIFIER ::= {id-ce 29} -id-ce-nameConstraints OBJECT IDENTIFIER ::= {id-ce 30} -id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= {id-ce 31} -id-ce-certificatePolicies OBJECT IDENTIFIER ::= {id-ce 32} -id-ce-policyMappings OBJECT IDENTIFIER ::= {id-ce 33} --- deprecated OBJECT IDENTIFIER ::= {id-ce 34} -id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= {id-ce 35} -id-ce-policyConstraints OBJECT IDENTIFIER ::= {id-ce 36} -id-ce-extKeyUsage OBJECT IDENTIFIER ::= {id-ce 37} -id-mr-certificateExactMatch OBJECT IDENTIFIER ::= {id-mr 34} -id-mr-certificateMatch OBJECT IDENTIFIER ::= {id-mr 35} -id-mr-certificatePairExactMatch OBJECT IDENTIFIER ::= {id-mr 36} -id-mr-certificatePairMatch OBJECT IDENTIFIER ::= {id-mr 37} -id-mr-certificateListExactMatch OBJECT IDENTIFIER ::= {id-mr 38} -id-mr-certificateListMatch OBJECT IDENTIFIER ::= {id-mr 39} -id-mr-algorithmIdentifierMatch OBJECT IDENTIFIER ::= {id-mr 40} - -id-kp OBJECT IDENTIFIER ::= {id-pkix 3} -id-kp-serverAuth OBJECT IDENTIFIER ::= {id-kp 1} -id-kp-clientAuth OBJECT IDENTIFIER ::= {id-kp 2} -id-kp-codeSigning OBJECT IDENTIFIER ::= {id-kp 3} -id-kp-emailProtection OBJECT IDENTIFIER ::= {id-kp 4} -id-kp-timeStamping OBJECT IDENTIFIER ::= {id-kp 8} - -id-netscape-cert-type OBJECT IDENTIFIER ::= {2 16 840 1 113730 1 1} - --- The following OBJECT IDENTIFIERS are not used by this specification: --- {id-ce 2}, {id-ce 3}, {id-ce 4}, {id-ce 5}, {id-ce 6}, {id-ce 7}, --- {id-ce 8}, {id-ce 10}, {id-ce 11}, {id-ce 12}, {id-ce 13}, --- {id-ce 22}, {id-ce 25}, {id-ce 26} - -END diff --git a/SecurityASN1/asn/sm_x509cmn.asn b/SecurityASN1/asn/sm_x509cmn.asn deleted file mode 100644 index 94f6e86b..00000000 --- a/SecurityASN1/asn/sm_x509cmn.asn +++ /dev/null @@ -1,41 +0,0 @@ --- @(#) sm_x509cmn.asn 1.3 3/2/98 12:56:14 -CommonX509Definitions -DEFINITIONS IMPLICIT TAGS ::= - -BEGIN - --- EXPORTS ALL - -IMPORTS - informationFramework, selectedAttributeTypes - FROM UsefulDefinitions { usefulDefinitions } - - Name - FROM InformationFramework { informationFramework } - - DirectoryString - FROM SelectedAttributeTypes { selectedAttributeTypes } - - ORAddress - FROM MTSAbstractService { mTSAbstractService } ; - -GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName - -GeneralName ::= CHOICE { - otherName [0] OTHER-NAME, - rfc822Name [1] IA5String, - dNSName [2] IA5String, - x400Address [3] ORAddress, - directoryName [4] Name, - ediPartyName [5] EDIPartyName, - uniformResourceIdentifier [6] IA5String, - iPAddress [7] OCTET STRING, - registeredID [8] OBJECT IDENTIFIER } - -OTHER-NAME ::= OBJECT IDENTIFIER - -EDIPartyName ::= SEQUENCE { - nameAssigner [0] DirectoryString OPTIONAL, - partyName [1] DirectoryString } - -END diff --git a/SecurityASN1/asn/sm_x520sa.asn b/SecurityASN1/asn/sm_x520sa.asn deleted file mode 100644 index 6483a153..00000000 --- a/SecurityASN1/asn/sm_x520sa.asn +++ /dev/null @@ -1,196 +0,0 @@ --- @(#) sm_x520sa.asn 1.3 4/27/98 14:42:39 -SelectedAttributeTypes --- --- oid defined in sm_x501ud.asn --- --- {joint-iso-ccitt ds(5) module(1) selectedAttributeTypes(5) 2} -DEFINITIONS ::= - -BEGIN - --- EXPORTS All -- - --- The types and values defined in this module are exported for use in the --- other ASN.1 modules contained --- within the Directory Specifications, and for the use of other applications --- which will use them to access --- Directory services. Other applications may use them for their own purposes, --- but this will not constrain --- extensions and modifications needed to maintain or improve the Directory --- service. -IMPORTS - - informationFramework, upperBounds, id-at, id-mr - FROM UsefulDefinitions { usefulDefinitions } - - AttributeType, DistinguishedName - FROM InformationFramework { informationFramework } ; - --- Directory string type -- - -UniqueIdentifier ::= BIT STRING - -DirectoryString ::= CHOICE { - teletexString TeletexString (SIZE (1..MAX)), - printableString PrintableString (SIZE (1..MAX)), - universalString UniversalString (SIZE (1..MAX)), - bmpString BMPString (SIZE (1..MAX)), - utf8String UTF8String (SIZE (1..MAX)) } - - --- Object identifier assignments --- object identifiers assigned in other modules are shown in comments --- Attributes --- id-at-objectClass OBJECT IDENTIFIER ::= {id-at 0} --- id-at-aliasedEntryName OBJECT IDENTIFIER ::= {id-at 1} -id-at-encryptedAliasedEntryName OBJECT IDENTIFIER ::= {id-at 1 2} -id-at-knowledgeInformation OBJECT IDENTIFIER ::= {id-at 2} -id-at-commonName OBJECT IDENTIFIER ::= {id-at 3} -id-at-encryptedCommonName OBJECT IDENTIFIER ::= {id-at 3 2} -id-at-surname OBJECT IDENTIFIER ::= {id-at 4} -id-at-encryptedSurname OBJECT IDENTIFIER ::= {id-at 4 2} -id-at-serialNumber OBJECT IDENTIFIER ::= {id-at 5} -id-at-encryptedSerialNumber OBJECT IDENTIFIER ::= {id-at 5 2} -id-at-countryName OBJECT IDENTIFIER ::= {id-at 6} -id-at-encryptedCountryName OBJECT IDENTIFIER ::= {id-at 6 2} -id-at-localityName OBJECT IDENTIFIER ::= {id-at 7} -id-at-encryptedLocalityName OBJECT IDENTIFIER ::= {id-at 7 2} -id-at-collectiveLocalityName OBJECT IDENTIFIER ::= {id-at 7 1} -id-at-encryptedCollectiveLocalityName OBJECT IDENTIFIER ::= {id-at 7 1 2} -id-at-stateOrProvinceName OBJECT IDENTIFIER ::= {id-at 8} -id-at-encryptedStateOrProvinceName OBJECT IDENTIFIER ::= {id-at 8 2} -id-at-collectiveStateOrProvinceName OBJECT IDENTIFIER ::= {id-at 8 1} -id-at-encryptedCollectiveStateOrProvinceName OBJECT IDENTIFIER ::= {id-at 8 1 2} -id-at-streetAddress OBJECT IDENTIFIER ::= {id-at 9} -id-at-encryptedStreetAddress OBJECT IDENTIFIER ::= {id-at 9 2} -id-at-collectiveStreetAddress OBJECT IDENTIFIER ::= {id-at 9 1} -id-at-encryptedCollectiveStreetAddress OBJECT IDENTIFIER ::= {id-at 9 1 2} -id-at-organizationName OBJECT IDENTIFIER ::= {id-at 10} -id-at-encryptedOrganizationName OBJECT IDENTIFIER ::= {id-at 10 2} -id-at-collectiveOrganizationName OBJECT IDENTIFIER ::= {id-at 10 1} -id-at-encryptedCollectiveOrganizationName OBJECT IDENTIFIER ::= {id-at 10 1 2} -id-at-organizationalUnitName OBJECT IDENTIFIER ::= {id-at 11} -id-at-encryptedOrganizationalUnitName OBJECT IDENTIFIER ::= {id-at 11 2} -id-at-collectiveOrganizationalUnitName OBJECT IDENTIFIER ::= {id-at 11 1} -id-at-encryptedCollectiveOrganizationalUnitName OBJECT IDENTIFIER ::= {id-at 11 1 2} -id-at-title OBJECT IDENTIFIER ::= {id-at 12} -id-at-encryptedTitle OBJECT IDENTIFIER ::= {id-at 12 2} -id-at-description OBJECT IDENTIFIER ::= {id-at 13} -id-at-encryptedDescription OBJECT IDENTIFIER ::= {id-at 13 2} -id-at-searchGuide OBJECT IDENTIFIER ::= {id-at 14} -id-at-encryptedSearchGuide OBJECT IDENTIFIER ::= {id-at 14 2} -id-at-businessCategory OBJECT IDENTIFIER ::= {id-at 15} -id-at-encryptedBusinessCategory OBJECT IDENTIFIER ::= {id-at 15 2} -id-at-postalAddress OBJECT IDENTIFIER ::= {id-at 16} -id-at-encryptedPostalAddress OBJECT IDENTIFIER ::= {id-at 16 2} -id-at-collectivePostalAddress OBJECT IDENTIFIER ::= {id-at 16 1} -id-at-encryptedCollectivePostalAddress OBJECT IDENTIFIER ::= {id-at 16 1 2} -id-at-postalCode OBJECT IDENTIFIER ::= {id-at 17} -id-at-encryptedPostalCode OBJECT IDENTIFIER ::= {id-at 17 2} -id-at-collectivePostalCode OBJECT IDENTIFIER ::= {id-at 17 1} -id-at-encryptedCollectivePostalCode OBJECT IDENTIFIER ::= {id-at 17 1 2} -id-at-postOfficeBox OBJECT IDENTIFIER ::= {id-at 18} -id-at-encryptedPostOfficeBox OBJECT IDENTIFIER ::= {id-at 18 2} -id-at-collectivePostOfficeBox OBJECT IDENTIFIER ::= {id-at 18 1} -id-at-encryptedCollectivePostOfficeBox OBJECT IDENTIFIER ::= {id-at 18 1 2} -id-at-physicalDeliveryOfficeName OBJECT IDENTIFIER ::= {id-at 19} -id-at-encryptedPhysicalDeliveryOfficeName OBJECT IDENTIFIER ::= {id-at 19 2} -id-at-collectivePhysicalDeliveryOfficeName OBJECT IDENTIFIER ::= {id-at 19 1} -id-at-encryptedCollectivePhysicalDeliveryOfficeName OBJECT IDENTIFIER ::= {id-at 19 1 2} -id-at-telephoneNumber OBJECT IDENTIFIER ::= {id-at 20} -id-at-encryptedTelephoneNumber OBJECT IDENTIFIER ::= {id-at 20 2} -id-at-collectiveTelephoneNumber OBJECT IDENTIFIER ::= {id-at 20 1} -id-at-encryptedCollectiveTelephoneNumber OBJECT IDENTIFIER ::= {id-at 20 1 2} -id-at-telexNumber OBJECT IDENTIFIER ::= {id-at 21} -id-at-encryptedTelexNumber OBJECT IDENTIFIER ::= {id-at 21 2} -id-at-collectiveTelexNumber OBJECT IDENTIFIER ::= {id-at 21 1} -id-at-encryptedCollectiveTelexNumber OBJECT IDENTIFIER ::= {id-at 21 1 2} -id-at-teletexTerminalIdentifier OBJECT IDENTIFIER ::= {id-at 22} -id-at-encryptedTeletexTerminalIdentifier OBJECT IDENTIFIER ::= {id-at 22 2} -id-at-collectiveTeletexTerminalIdentifier OBJECT IDENTIFIER ::= {id-at 22 1} -id-at-encryptedCollectiveTeletexTerminalIdentifier OBJECT IDENTIFIER ::= {id-at 22 1 2} -id-at-facsimileTelephoneNumber OBJECT IDENTIFIER ::= {id-at 23} -id-at-encryptedFacsimileTelephoneNumber OBJECT IDENTIFIER ::= {id-at 23 2} -id-at-collectiveFacsimileTelephoneNumber OBJECT IDENTIFIER ::= {id-at 23 1} -id-at-encryptedCollectiveFacsimileTelephoneNumber OBJECT IDENTIFIER ::= {id-at 23 1 2} -id-at-x121Address OBJECT IDENTIFIER ::= {id-at 24} -id-at-encryptedX121Address OBJECT IDENTIFIER ::= {id-at 24 2} -id-at-internationalISDNNumber OBJECT IDENTIFIER ::= {id-at 25} -id-at-encryptedInternationalISDNNumber OBJECT IDENTIFIER ::= {id-at 25 2} -id-at-collectiveInternationalISDNNumber OBJECT IDENTIFIER ::= {id-at 25 1} -id-at-encryptedCollectiveInternationalISDNNumber OBJECT IDENTIFIER ::= {id-at 25 1 2} -id-at-registeredAddress OBJECT IDENTIFIER ::= {id-at 26} -id-at-encryptedRegisteredAddress OBJECT IDENTIFIER ::= {id-at 26 2} -id-at-destinationIndicator OBJECT IDENTIFIER ::= {id-at 27} -id-at-encryptedDestinationIndicator OBJECT IDENTIFIER ::= {id-at 27 2} -id-at-preferredDeliveryMethod OBJECT IDENTIFIER ::= {id-at 28} -id-at-encryptedPreferredDeliveryMethod OBJECT IDENTIFIER ::= {id-at 28 2} -id-at-presentationAddress OBJECT IDENTIFIER ::= {id-at 29} -id-at-encryptedPresentationAddress OBJECT IDENTIFIER ::= {id-at 29 2} -id-at-supportedApplicationContext OBJECT IDENTIFIER ::= {id-at 30} -id-at-encryptedSupportedApplicationContext OBJECT IDENTIFIER ::= {id-at 30 2} -id-at-member OBJECT IDENTIFIER ::= {id-at 31} -id-at-encryptedMember OBJECT IDENTIFIER ::= {id-at 31 2} -id-at-owner OBJECT IDENTIFIER ::= {id-at 32} -id-at-encryptedOwner OBJECT IDENTIFIER ::= {id-at 32 2} -id-at-roleOccupant OBJECT IDENTIFIER ::= {id-at 33} -id-at-encryptedRoleOccupant OBJECT IDENTIFIER ::= {id-at 33 2} -id-at-seeAlso OBJECT IDENTIFIER ::= {id-at 34} -id-at-encryptedSeeAlso OBJECT IDENTIFIER ::= {id-at 34 2} --- id-at-userPassword OBJECT IDENTIFIER ::= {id-at 35} -id-at-encryptedUserPassword OBJECT IDENTIFIER ::= {id-at 35 2} --- id-at-userCertificate OBJECT IDENTIFIER ::= {id-at 36} -id-at-encryptedUserCertificate OBJECT IDENTIFIER ::= {id-at 36 2} --- id-at-cACertificate OBJECT IDENTIFIER ::= {id-at 37} -id-at-encryptedCACertificate OBJECT IDENTIFIER ::= {id-at 37 2} --- id-at-authorityRevocationList OBJECT IDENTIFIER ::= {id-at 38} -id-at-encryptedAuthorityRevocationList - OBJECT IDENTIFIER ::= {id-at 38 2} --- id-at-certificateRevocationList OBJECT IDENTIFIER ::= {id-at 39} -id-at-encryptedCertificateRevocationList - OBJECT IDENTIFIER ::= {id-at 39 2} --- id-at-crossCertificatePair OBJECT IDENTIFIER ::= {id-at 40} -id-at-encryptedCrossCertificatePair OBJECT IDENTIFIER ::= {id-at 40 2} -id-at-name OBJECT IDENTIFIER ::= {id-at 41} -id-at-givenName OBJECT IDENTIFIER ::= {id-at 42} -id-at-encryptedGivenName OBJECT IDENTIFIER ::= {id-at 42 2} -id-at-initials OBJECT IDENTIFIER ::= {id-at 43} -id-at-encryptedInitials OBJECT IDENTIFIER ::= {id-at 43 2} -id-at-generationQualifier OBJECT IDENTIFIER ::= {id-at 44} -id-at-encryptedGenerationQualifier OBJECT IDENTIFIER ::= {id-at 44 2} -id-at-uniqueIdentifier OBJECT IDENTIFIER ::= {id-at 45} -id-at-encryptedUniqueIdentifier OBJECT IDENTIFIER ::= {id-at 45 2} -id-at-dnQualifier OBJECT IDENTIFIER ::= {id-at 46} -id-at-encryptedDnQualifier OBJECT IDENTIFIER ::= {id-at 46 2} -id-at-enhancedSearchGuide OBJECT IDENTIFIER ::= {id-at 47} -id-at-encryptedEnhancedSearchGuide - OBJECT IDENTIFIER ::= {id-at 47 2} -id-at-protocolInformation OBJECT IDENTIFIER ::= {id-at 48} -id-at-encryptedProtocolInformation - OBJECT IDENTIFIER ::= {id-at 48 2} -id-at-distinguishedName OBJECT IDENTIFIER ::= {id-at 49} -id-at-encryptedDistinguishedName OBJECT IDENTIFIER ::= {id-at 49 2} -id-at-uniqueMember OBJECT IDENTIFIER ::= {id-at 50} -id-at-encryptedUniqueMember OBJECT IDENTIFIER ::= {id-at 50 2} -id-at-houseIdentifier OBJECT IDENTIFIER ::= {id-at 51} -id-at-encryptedHouseIdentifier OBJECT IDENTIFIER ::= {id-at 51 2} ---id-at-supportedAlgorithms OBJECT IDENTIFIER ::= {id-at 52} -id-at-encryptedSupportedAlgorithms OBJECT IDENTIFIER ::= {id-at 52 2} ---id-at-deltaRevocationList OBJECT IDENTIFIER ::= {id-at 53} -id-at-encryptedDeltaRevocationList OBJECT IDENTIFIER ::= {id-at 53 2} -id-at-dmdName OBJECT IDENTIFIER ::= {id-at 54} -id-at-encryptedDmdName OBJECT IDENTIFIER ::= {id-at 54 2} --- id-at-clearance OBJECT IDENTIFIER ::= {id-at 55} -id-at-encryptedClearance OBJECT IDENTIFIER ::= {id-at 55 2} --- id-at-defaultDirQop OBJECT IDENTIFIER ::= {id-at 56} -id-at-encryptedDefaultDirQop OBJECT IDENTIFIER ::= {id-at 56 2} --- id-at-attributeIntegrityInfo OBJECT IDENTIFIER ::= {id-at 57} -id-at-encryptedAttributeIntegrityInfo OBJECT IDENTIFIER ::= {id-at 57 2} ---id-at-attributeCertificate OBJECT IDENTIFIER ::= {id-at 58} -id-at-encryptedAttributeCertificate OBJECT IDENTIFIER ::= {id-at 58 2} --- id-at-attributeCertificateRevocationList OBJECT IDENTIFIER ::= {id-at 59} -id-at-encryptedAttributeCertificateRevocationList OBJECT IDENTIFIER ::= {id-at 59 2} --- id-at-confKeyInfo OBJECT IDENTIFIER ::= {id-at 60} -id-at-encryptedConfKeyInfo OBJECT IDENTIFIER ::= {id-at 60 2} - -END diff --git a/SecurityASN1/c++/.cvsignore b/SecurityASN1/c++/.cvsignore deleted file mode 100644 index 8b137891..00000000 --- a/SecurityASN1/c++/.cvsignore +++ /dev/null @@ -1 +0,0 @@ - diff --git a/SecurityASN1/c++/appleoids.cpp b/SecurityASN1/c++/appleoids.cpp deleted file mode 100644 index 3fe998bb..00000000 --- a/SecurityASN1/c++/appleoids.cpp +++ /dev/null @@ -1,3361 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// appleoids.cpp - class member functions for ASN.1 module APPLE-OIDS -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -DSABsafeParams::DSABsafeParams() -{ -} - -DSABsafeParams::DSABsafeParams (const DSABsafeParams &) -{ - Asn1Error << "use of incompletely defined DSABsafeParams::DSABsafeParams (const DSABsafeParams &)" << endl; - abort(); -} - -DSABsafeParams::~DSABsafeParams() -{ -} - -AsnType *DSABsafeParams::Clone() const -{ - return new DSABsafeParams; -} - -AsnType *DSABsafeParams::Copy() const -{ - return new DSABsafeParams (*this); -} - -#if SNACC_DEEP_COPY -DSABsafeParams &DSABsafeParams::operator = (const DSABsafeParams &that) -#else // SNACC_DEEP_COPY -DSABsafeParams &DSABsafeParams::operator = (const DSABsafeParams &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - keySizeInBits = that.keySizeInBits; - p = that.p; - q = that.q; - g = that.g; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DSABsafeParams &DSABsafeParams::operator = (const DSABsafeParams &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DSABsafeParams::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = g.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = q.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = p.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = keySizeInBits.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // DSABsafeParams::BEncContent - - -void DSABsafeParams::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - keySizeInBits.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-100); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - p.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-101); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - q.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-102); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - g.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-103); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-104); - } - else - return; -} // DSABsafeParams::BDecContent - -AsnLen DSABsafeParams::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DSABsafeParams::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DSABsafeParams::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-105); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DSABsafeParams::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "keySizeInBits "; - os << keySizeInBits; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "p "; - os << p; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "q "; - os << q; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "g "; - os << g; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DSABsafeParams::Print - - -DHParameter::DHParameter() -{ - privateValueLength = NULL; -} - -DHParameter::DHParameter (const DHParameter &) -{ - Asn1Error << "use of incompletely defined DHParameter::DHParameter (const DHParameter &)" << endl; - abort(); -} - -DHParameter::~DHParameter() -{ - delete privateValueLength; -} - -AsnType *DHParameter::Clone() const -{ - return new DHParameter; -} - -AsnType *DHParameter::Copy() const -{ - return new DHParameter (*this); -} - -#if SNACC_DEEP_COPY -DHParameter &DHParameter::operator = (const DHParameter &that) -#else // SNACC_DEEP_COPY -DHParameter &DHParameter::operator = (const DHParameter &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - prime = that.prime; - base = that.base; - if (that.privateValueLength) - { - if (!privateValueLength) - privateValueLength = new BigIntegerStr; - *privateValueLength = *that.privateValueLength; - } - else - { - delete privateValueLength; - privateValueLength = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DHParameter &DHParameter::operator = (const DHParameter &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DHParameter::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (privateValueLength)) - { - l = privateValueLength->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - } - - l = base.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = prime.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // DHParameter::BEncContent - - -void DHParameter::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - prime.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-106); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - base.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-107); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - privateValueLength = new BigIntegerStr; - privateValueLength->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-108); - } - else - return; -} // DHParameter::BDecContent - -AsnLen DHParameter::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DHParameter::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DHParameter::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-109); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DHParameter::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "prime "; - os << prime; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "base "; - os << base; - os << "," << endl; - } - - if (NOT_NULL (privateValueLength)) - { - os << ","<< endl; - Indent (os, indentG); - os << "privateValueLength "; - os << *privateValueLength; - } - else - { - Indent (os, indentG); - os << "privateValueLength "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DHParameter::Print - - -FEECurveParameters::FEECurveParameters() -{ - basePrime = NULL; -} - -FEECurveParameters::FEECurveParameters (const FEECurveParameters &) -{ - Asn1Error << "use of incompletely defined FEECurveParameters::FEECurveParameters (const FEECurveParameters &)" << endl; - abort(); -} - -FEECurveParameters::~FEECurveParameters() -{ - delete basePrime; -} - -AsnType *FEECurveParameters::Clone() const -{ - return new FEECurveParameters; -} - -AsnType *FEECurveParameters::Copy() const -{ - return new FEECurveParameters (*this); -} - -#if SNACC_DEEP_COPY -FEECurveParameters &FEECurveParameters::operator = (const FEECurveParameters &that) -#else // SNACC_DEEP_COPY -FEECurveParameters &FEECurveParameters::operator = (const FEECurveParameters &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - primeType = that.primeType; - curveType = that.curveType; - q = that.q; - k = that.k; - m = that.m; - a = that.a; - bb = that.bb; - c = that.c; - x1Plus = that.x1Plus; - x1Minus = that.x1Minus; - cOrderPlus = that.cOrderPlus; - cOrderMinus = that.cOrderMinus; - x1OrderPlus = that.x1OrderPlus; - x1OrderMinus = that.x1OrderMinus; - if (that.basePrime) - { - if (!basePrime) - basePrime = new BigIntegerStr; - *basePrime = *that.basePrime; - } - else - { - delete basePrime; - basePrime = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined FEECurveParameters &FEECurveParameters::operator = (const FEECurveParameters &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -FEECurveParameters::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (basePrime)) - { - l = basePrime->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - } - - l = x1OrderMinus.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = x1OrderPlus.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = cOrderMinus.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = cOrderPlus.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = x1Minus.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = x1Plus.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = c.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = bb.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = a.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = m.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = k.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = q.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = curveType.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = primeType.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // FEECurveParameters::BEncContent - - -void FEECurveParameters::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - primeType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-110); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - curveType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-111); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - q.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-112); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - k.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-113); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - m.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-114); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - a.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-115); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - bb.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-116); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - c.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-117); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - x1Plus.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-118); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - x1Minus.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-119); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - cOrderPlus.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-120); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - cOrderMinus.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-121); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - x1OrderPlus.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-122); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - x1OrderMinus.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-123); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - basePrime = new BigIntegerStr; - basePrime->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-124); - } - else - return; -} // FEECurveParameters::BDecContent - -AsnLen FEECurveParameters::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void FEECurveParameters::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "FEECurveParameters::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-125); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void FEECurveParameters::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "primeType "; - os << primeType; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "curveType "; - os << curveType; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "q "; - os << q; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "k "; - os << k; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "m "; - os << m; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "a "; - os << a; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "bb "; - os << bb; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "c "; - os << c; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "x1Plus "; - os << x1Plus; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "x1Minus "; - os << x1Minus; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "cOrderPlus "; - os << cOrderPlus; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "cOrderMinus "; - os << cOrderMinus; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "x1OrderPlus "; - os << x1OrderPlus; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "x1OrderMinus "; - os << x1OrderMinus; - os << "," << endl; - } - - if (NOT_NULL (basePrime)) - { - os << ","<< endl; - Indent (os, indentG); - os << "basePrime "; - os << *basePrime; - } - else - { - Indent (os, indentG); - os << "basePrime "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // FEECurveParameters::Print - - -DSAAlgorithmId::DSAAlgorithmId() -{ -#if TCL - params = new DSABsafeParams; -#else - params = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DSAAlgorithmId::DSAAlgorithmId (const DSAAlgorithmId &) -{ - Asn1Error << "use of incompletely defined DSAAlgorithmId::DSAAlgorithmId (const DSAAlgorithmId &)" << endl; - abort(); -} - -DSAAlgorithmId::~DSAAlgorithmId() -{ - delete params; -} - -AsnType *DSAAlgorithmId::Clone() const -{ - return new DSAAlgorithmId; -} - -AsnType *DSAAlgorithmId::Copy() const -{ - return new DSAAlgorithmId (*this); -} - -#if SNACC_DEEP_COPY -DSAAlgorithmId &DSAAlgorithmId::operator = (const DSAAlgorithmId &that) -#else // SNACC_DEEP_COPY -DSAAlgorithmId &DSAAlgorithmId::operator = (const DSAAlgorithmId &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - algorithm = that.algorithm; - if (that.params) - { - if (!params) - params = new DSABsafeParams; - *params = *that.params; - } - else - { - delete params; - params = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DSAAlgorithmId &DSAAlgorithmId::operator = (const DSAAlgorithmId &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DSAAlgorithmId::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = params->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = algorithm.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // DSAAlgorithmId::BEncContent - - -void DSAAlgorithmId::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - algorithm.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-126); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - params = new DSABsafeParams; - params->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-127); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-128); - } - else - return; -} // DSAAlgorithmId::BDecContent - -AsnLen DSAAlgorithmId::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DSAAlgorithmId::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DSAAlgorithmId::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-129); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DSAAlgorithmId::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "algorithm "; - os << algorithm; - os << "," << endl; - } - - if (NOT_NULL (params)) - { - Indent (os, indentG); - os << "params "; - os << *params; - } - else - { - Indent (os, indentG); - os << "params "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DSAAlgorithmId::Print - - -FEEElGamalSignature::FEEElGamalSignature() -{ -} - -FEEElGamalSignature::FEEElGamalSignature (const FEEElGamalSignature &) -{ - Asn1Error << "use of incompletely defined FEEElGamalSignature::FEEElGamalSignature (const FEEElGamalSignature &)" << endl; - abort(); -} - -FEEElGamalSignature::~FEEElGamalSignature() -{ -} - -AsnType *FEEElGamalSignature::Clone() const -{ - return new FEEElGamalSignature; -} - -AsnType *FEEElGamalSignature::Copy() const -{ - return new FEEElGamalSignature (*this); -} - -#if SNACC_DEEP_COPY -FEEElGamalSignature &FEEElGamalSignature::operator = (const FEEElGamalSignature &that) -#else // SNACC_DEEP_COPY -FEEElGamalSignature &FEEElGamalSignature::operator = (const FEEElGamalSignature &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - u = that.u; - pmX = that.pmX; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined FEEElGamalSignature &FEEElGamalSignature::operator = (const FEEElGamalSignature &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -FEEElGamalSignature::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = pmX.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = u.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // FEEElGamalSignature::BEncContent - - -void FEEElGamalSignature::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - u.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-130); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - pmX.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-131); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-132); - } - else - return; -} // FEEElGamalSignature::BDecContent - -AsnLen FEEElGamalSignature::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void FEEElGamalSignature::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "FEEElGamalSignature::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-133); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void FEEElGamalSignature::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "u "; - os << u; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "pmX "; - os << pmX; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // FEEElGamalSignature::Print - - -FEEECDSASignature::FEEECDSASignature() -{ -} - -FEEECDSASignature::FEEECDSASignature (const FEEECDSASignature &) -{ - Asn1Error << "use of incompletely defined FEEECDSASignature::FEEECDSASignature (const FEEECDSASignature &)" << endl; - abort(); -} - -FEEECDSASignature::~FEEECDSASignature() -{ -} - -AsnType *FEEECDSASignature::Clone() const -{ - return new FEEECDSASignature; -} - -AsnType *FEEECDSASignature::Copy() const -{ - return new FEEECDSASignature (*this); -} - -#if SNACC_DEEP_COPY -FEEECDSASignature &FEEECDSASignature::operator = (const FEEECDSASignature &that) -#else // SNACC_DEEP_COPY -FEEECDSASignature &FEEECDSASignature::operator = (const FEEECDSASignature &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - c = that.c; - d = that.d; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined FEEECDSASignature &FEEECDSASignature::operator = (const FEEECDSASignature &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -FEEECDSASignature::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = d.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = c.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // FEEECDSASignature::BEncContent - - -void FEEECDSASignature::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - c.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-134); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - d.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-135); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-136); - } - else - return; -} // FEEECDSASignature::BDecContent - -AsnLen FEEECDSASignature::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void FEEECDSASignature::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "FEEECDSASignature::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-137); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void FEEECDSASignature::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "c "; - os << c; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "d "; - os << d; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // FEEECDSASignature::Print - - -FEEPublicKey::FEEPublicKey() -{ -#if TCL - curveParams = new FEECurveParameters; -#else - curveParams = NULL; // incomplete initialization of mandatory element! -#endif // TCL - plusY = NULL; -} - -FEEPublicKey::FEEPublicKey (const FEEPublicKey &) -{ - Asn1Error << "use of incompletely defined FEEPublicKey::FEEPublicKey (const FEEPublicKey &)" << endl; - abort(); -} - -FEEPublicKey::~FEEPublicKey() -{ - delete curveParams; - delete plusY; -} - -AsnType *FEEPublicKey::Clone() const -{ - return new FEEPublicKey; -} - -AsnType *FEEPublicKey::Copy() const -{ - return new FEEPublicKey (*this); -} - -#if SNACC_DEEP_COPY -FEEPublicKey &FEEPublicKey::operator = (const FEEPublicKey &that) -#else // SNACC_DEEP_COPY -FEEPublicKey &FEEPublicKey::operator = (const FEEPublicKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.curveParams) - { - if (!curveParams) - curveParams = new FEECurveParameters; - *curveParams = *that.curveParams; - } - else - { - delete curveParams; - curveParams = NULL; - } - plusX = that.plusX; - minusX = that.minusX; - if (that.plusY) - { - if (!plusY) - plusY = new BigIntegerStr; - *plusY = *that.plusY; - } - else - { - delete plusY; - plusY = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined FEEPublicKey &FEEPublicKey::operator = (const FEEPublicKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -FEEPublicKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (plusY)) - { - l = plusY->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - } - - l = minusX.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = plusX.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = curveParams->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // FEEPublicKey::BEncContent - - -void FEEPublicKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-138); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - curveParams = new FEECurveParameters; - curveParams->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-139); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - plusX.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-140); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - minusX.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-141); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - plusY = new BigIntegerStr; - plusY->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-142); - } - else - return; -} // FEEPublicKey::BDecContent - -AsnLen FEEPublicKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void FEEPublicKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "FEEPublicKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-143); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void FEEPublicKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (curveParams)) - { - Indent (os, indentG); - os << "curveParams "; - os << *curveParams; - } - else - { - Indent (os, indentG); - os << "curveParams "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "plusX "; - os << plusX; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "minusX "; - os << minusX; - os << "," << endl; - } - - if (NOT_NULL (plusY)) - { - os << ","<< endl; - Indent (os, indentG); - os << "plusY "; - os << *plusY; - } - else - { - Indent (os, indentG); - os << "plusY "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // FEEPublicKey::Print - - -FEEPrivateKey::FEEPrivateKey() -{ -#if TCL - curveParams = new FEECurveParameters; -#else - curveParams = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -FEEPrivateKey::FEEPrivateKey (const FEEPrivateKey &) -{ - Asn1Error << "use of incompletely defined FEEPrivateKey::FEEPrivateKey (const FEEPrivateKey &)" << endl; - abort(); -} - -FEEPrivateKey::~FEEPrivateKey() -{ - delete curveParams; -} - -AsnType *FEEPrivateKey::Clone() const -{ - return new FEEPrivateKey; -} - -AsnType *FEEPrivateKey::Copy() const -{ - return new FEEPrivateKey (*this); -} - -#if SNACC_DEEP_COPY -FEEPrivateKey &FEEPrivateKey::operator = (const FEEPrivateKey &that) -#else // SNACC_DEEP_COPY -FEEPrivateKey &FEEPrivateKey::operator = (const FEEPrivateKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.curveParams) - { - if (!curveParams) - curveParams = new FEECurveParameters; - *curveParams = *that.curveParams; - } - else - { - delete curveParams; - curveParams = NULL; - } - privData = that.privData; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined FEEPrivateKey &FEEPrivateKey::operator = (const FEEPrivateKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -FEEPrivateKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = privData.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = curveParams->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // FEEPrivateKey::BEncContent - - -void FEEPrivateKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-144); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - curveParams = new FEECurveParameters; - curveParams->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-145); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - privData.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-146); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-147); - } - else - return; -} // FEEPrivateKey::BDecContent - -AsnLen FEEPrivateKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void FEEPrivateKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "FEEPrivateKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-148); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void FEEPrivateKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (curveParams)) - { - Indent (os, indentG); - os << "curveParams "; - os << *curveParams; - } - else - { - Indent (os, indentG); - os << "curveParams "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "privData "; - os << privData; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // FEEPrivateKey::Print - - -DSAPrivateKey::DSAPrivateKey() -{ -#if TCL - dsaAlg = new DSAAlgorithmId; -#else - dsaAlg = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DSAPrivateKey::DSAPrivateKey (const DSAPrivateKey &) -{ - Asn1Error << "use of incompletely defined DSAPrivateKey::DSAPrivateKey (const DSAPrivateKey &)" << endl; - abort(); -} - -DSAPrivateKey::~DSAPrivateKey() -{ - delete dsaAlg; -} - -AsnType *DSAPrivateKey::Clone() const -{ - return new DSAPrivateKey; -} - -AsnType *DSAPrivateKey::Copy() const -{ - return new DSAPrivateKey (*this); -} - -#if SNACC_DEEP_COPY -DSAPrivateKey &DSAPrivateKey::operator = (const DSAPrivateKey &that) -#else // SNACC_DEEP_COPY -DSAPrivateKey &DSAPrivateKey::operator = (const DSAPrivateKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.dsaAlg) - { - if (!dsaAlg) - dsaAlg = new DSAAlgorithmId; - *dsaAlg = *that.dsaAlg; - } - else - { - delete dsaAlg; - dsaAlg = NULL; - } - privateKey = that.privateKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DSAPrivateKey &DSAPrivateKey::operator = (const DSAPrivateKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DSAPrivateKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = privateKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = dsaAlg->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // DSAPrivateKey::BEncContent - - -void DSAPrivateKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-149); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - dsaAlg = new DSAAlgorithmId; - dsaAlg->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-150); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - privateKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-151); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-152); - } - else - return; -} // DSAPrivateKey::BDecContent - -AsnLen DSAPrivateKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DSAPrivateKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DSAPrivateKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-153); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DSAPrivateKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (dsaAlg)) - { - Indent (os, indentG); - os << "dsaAlg "; - os << *dsaAlg; - } - else - { - Indent (os, indentG); - os << "dsaAlg "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "privateKey "; - os << privateKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DSAPrivateKey::Print - - -DSAPublicKey::DSAPublicKey() -{ -#if TCL - dsaAlg = new DSAAlgorithmId; -#else - dsaAlg = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DSAPublicKey::DSAPublicKey (const DSAPublicKey &) -{ - Asn1Error << "use of incompletely defined DSAPublicKey::DSAPublicKey (const DSAPublicKey &)" << endl; - abort(); -} - -DSAPublicKey::~DSAPublicKey() -{ - delete dsaAlg; -} - -AsnType *DSAPublicKey::Clone() const -{ - return new DSAPublicKey; -} - -AsnType *DSAPublicKey::Copy() const -{ - return new DSAPublicKey (*this); -} - -#if SNACC_DEEP_COPY -DSAPublicKey &DSAPublicKey::operator = (const DSAPublicKey &that) -#else // SNACC_DEEP_COPY -DSAPublicKey &DSAPublicKey::operator = (const DSAPublicKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.dsaAlg) - { - if (!dsaAlg) - dsaAlg = new DSAAlgorithmId; - *dsaAlg = *that.dsaAlg; - } - else - { - delete dsaAlg; - dsaAlg = NULL; - } - publicKey = that.publicKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DSAPublicKey &DSAPublicKey::operator = (const DSAPublicKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DSAPublicKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = publicKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = dsaAlg->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // DSAPublicKey::BEncContent - - -void DSAPublicKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - dsaAlg = new DSAAlgorithmId; - dsaAlg->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-154); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - publicKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-155); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-156); - } - else - return; -} // DSAPublicKey::BDecContent - -AsnLen DSAPublicKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DSAPublicKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DSAPublicKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-157); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DSAPublicKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (dsaAlg)) - { - Indent (os, indentG); - os << "dsaAlg "; - os << *dsaAlg; - } - else - { - Indent (os, indentG); - os << "dsaAlg "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "publicKey "; - os << publicKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DSAPublicKey::Print - - -DSAPrivateKeyOcts::DSAPrivateKeyOcts() -{ -} - -DSAPrivateKeyOcts::DSAPrivateKeyOcts (const DSAPrivateKeyOcts &) -{ - Asn1Error << "use of incompletely defined DSAPrivateKeyOcts::DSAPrivateKeyOcts (const DSAPrivateKeyOcts &)" << endl; - abort(); -} - -DSAPrivateKeyOcts::~DSAPrivateKeyOcts() -{ -} - -AsnType *DSAPrivateKeyOcts::Clone() const -{ - return new DSAPrivateKeyOcts; -} - -AsnType *DSAPrivateKeyOcts::Copy() const -{ - return new DSAPrivateKeyOcts (*this); -} - -#if SNACC_DEEP_COPY -DSAPrivateKeyOcts &DSAPrivateKeyOcts::operator = (const DSAPrivateKeyOcts &that) -#else // SNACC_DEEP_COPY -DSAPrivateKeyOcts &DSAPrivateKeyOcts::operator = (const DSAPrivateKeyOcts &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - privateKey = that.privateKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DSAPrivateKeyOcts &DSAPrivateKeyOcts::operator = (const DSAPrivateKeyOcts &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DSAPrivateKeyOcts::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = privateKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // DSAPrivateKeyOcts::BEncContent - - -void DSAPrivateKeyOcts::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - privateKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-158); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-159); - } - else - return; -} // DSAPrivateKeyOcts::BDecContent - -AsnLen DSAPrivateKeyOcts::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DSAPrivateKeyOcts::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DSAPrivateKeyOcts::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-160); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DSAPrivateKeyOcts::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "privateKey "; - os << privateKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DSAPrivateKeyOcts::Print - - -DSASignature::DSASignature() -{ -} - -DSASignature::DSASignature (const DSASignature &) -{ - Asn1Error << "use of incompletely defined DSASignature::DSASignature (const DSASignature &)" << endl; - abort(); -} - -DSASignature::~DSASignature() -{ -} - -AsnType *DSASignature::Clone() const -{ - return new DSASignature; -} - -AsnType *DSASignature::Copy() const -{ - return new DSASignature (*this); -} - -#if SNACC_DEEP_COPY -DSASignature &DSASignature::operator = (const DSASignature &that) -#else // SNACC_DEEP_COPY -DSASignature &DSASignature::operator = (const DSASignature &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - r = that.r; - s = that.s; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DSASignature &DSASignature::operator = (const DSASignature &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DSASignature::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = s.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = r.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // DSASignature::BEncContent - - -void DSASignature::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - r.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-161); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - s.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-162); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-163); - } - else - return; -} // DSASignature::BDecContent - -AsnLen DSASignature::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DSASignature::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DSASignature::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-164); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DSASignature::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "r "; - os << r; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "s "; - os << s; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DSASignature::Print - - -DSAAlgParams::DSAAlgParams() -{ -} - -DSAAlgParams::DSAAlgParams (const DSAAlgParams &) -{ - Asn1Error << "use of incompletely defined DSAAlgParams::DSAAlgParams (const DSAAlgParams &)" << endl; - abort(); -} - -DSAAlgParams::~DSAAlgParams() -{ -} - -AsnType *DSAAlgParams::Clone() const -{ - return new DSAAlgParams; -} - -AsnType *DSAAlgParams::Copy() const -{ - return new DSAAlgParams (*this); -} - -#if SNACC_DEEP_COPY -DSAAlgParams &DSAAlgParams::operator = (const DSAAlgParams &that) -#else // SNACC_DEEP_COPY -DSAAlgParams &DSAAlgParams::operator = (const DSAAlgParams &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - p = that.p; - q = that.q; - g = that.g; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DSAAlgParams &DSAAlgParams::operator = (const DSAAlgParams &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DSAAlgParams::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = g.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = q.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = p.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // DSAAlgParams::BEncContent - - -void DSAAlgParams::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - p.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-165); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - q.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-166); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - g.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-167); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-168); - } - else - return; -} // DSAAlgParams::BDecContent - -AsnLen DSAAlgParams::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DSAAlgParams::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DSAAlgParams::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-169); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DSAAlgParams::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "p "; - os << p; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "q "; - os << q; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "g "; - os << g; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DSAAlgParams::Print - - -DHPrivateKey::DHPrivateKey() -{ -#if TCL - params = new DHParameter; -#else - params = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DHPrivateKey::DHPrivateKey (const DHPrivateKey &) -{ - Asn1Error << "use of incompletely defined DHPrivateKey::DHPrivateKey (const DHPrivateKey &)" << endl; - abort(); -} - -DHPrivateKey::~DHPrivateKey() -{ - delete params; -} - -AsnType *DHPrivateKey::Clone() const -{ - return new DHPrivateKey; -} - -AsnType *DHPrivateKey::Copy() const -{ - return new DHPrivateKey (*this); -} - -#if SNACC_DEEP_COPY -DHPrivateKey &DHPrivateKey::operator = (const DHPrivateKey &that) -#else // SNACC_DEEP_COPY -DHPrivateKey &DHPrivateKey::operator = (const DHPrivateKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - dHOid = that.dHOid; - if (that.params) - { - if (!params) - params = new DHParameter; - *params = *that.params; - } - else - { - delete params; - params = NULL; - } - secretPart = that.secretPart; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DHPrivateKey &DHPrivateKey::operator = (const DHPrivateKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DHPrivateKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = secretPart.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = params->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = dHOid.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // DHPrivateKey::BEncContent - - -void DHPrivateKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - dHOid.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-170); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - params = new DHParameter; - params->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-171); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - secretPart.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-172); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-173); - } - else - return; -} // DHPrivateKey::BDecContent - -AsnLen DHPrivateKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DHPrivateKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DHPrivateKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-174); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DHPrivateKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "dHOid "; - os << dHOid; - os << "," << endl; - } - - if (NOT_NULL (params)) - { - Indent (os, indentG); - os << "params "; - os << *params; - } - else - { - Indent (os, indentG); - os << "params "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "secretPart "; - os << secretPart; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DHPrivateKey::Print - - -DHParameterBlock::DHParameterBlock() -{ -#if TCL - params = new DHParameter; -#else - params = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DHParameterBlock::DHParameterBlock (const DHParameterBlock &) -{ - Asn1Error << "use of incompletely defined DHParameterBlock::DHParameterBlock (const DHParameterBlock &)" << endl; - abort(); -} - -DHParameterBlock::~DHParameterBlock() -{ - delete params; -} - -AsnType *DHParameterBlock::Clone() const -{ - return new DHParameterBlock; -} - -AsnType *DHParameterBlock::Copy() const -{ - return new DHParameterBlock (*this); -} - -#if SNACC_DEEP_COPY -DHParameterBlock &DHParameterBlock::operator = (const DHParameterBlock &that) -#else // SNACC_DEEP_COPY -DHParameterBlock &DHParameterBlock::operator = (const DHParameterBlock &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - oid = that.oid; - if (that.params) - { - if (!params) - params = new DHParameter; - *params = *that.params; - } - else - { - delete params; - params = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DHParameterBlock &DHParameterBlock::operator = (const DHParameterBlock &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DHParameterBlock::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = params->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = oid.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // DHParameterBlock::BEncContent - - -void DHParameterBlock::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - oid.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-175); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - params = new DHParameter; - params->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-176); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-177); - } - else - return; -} // DHParameterBlock::BDecContent - -AsnLen DHParameterBlock::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DHParameterBlock::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DHParameterBlock::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-178); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DHParameterBlock::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "oid "; - os << oid; - os << "," << endl; - } - - if (NOT_NULL (params)) - { - Indent (os, indentG); - os << "params "; - os << *params; - } - else - { - Indent (os, indentG); - os << "params "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DHParameterBlock::Print - - diff --git a/SecurityASN1/c++/pkcs10.cpp b/SecurityASN1/c++/pkcs10.cpp deleted file mode 100644 index dbc3a9b5..00000000 --- a/SecurityASN1/c++/pkcs10.cpp +++ /dev/null @@ -1,738 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs10.cpp - class member functions for ASN.1 module PKCS5 -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -CertificationRequestInfo::CertificationRequestInfo() -{ -#if TCL - subject = new Name; -#else - subject = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - subjectPublicKeyInfo = new SubjectPublicKeyInfo; -#else - subjectPublicKeyInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -CertificationRequestInfo::CertificationRequestInfo (const CertificationRequestInfo &) -{ - Asn1Error << "use of incompletely defined CertificationRequestInfo::CertificationRequestInfo (const CertificationRequestInfo &)" << endl; - abort(); -} - -CertificationRequestInfo::~CertificationRequestInfo() -{ - delete subject; - delete subjectPublicKeyInfo; -} - -AsnType *CertificationRequestInfo::Clone() const -{ - return new CertificationRequestInfo; -} - -AsnType *CertificationRequestInfo::Copy() const -{ - return new CertificationRequestInfo (*this); -} - -#if SNACC_DEEP_COPY -CertificationRequestInfo &CertificationRequestInfo::operator = (const CertificationRequestInfo &that) -#else // SNACC_DEEP_COPY -CertificationRequestInfo &CertificationRequestInfo::operator = (const CertificationRequestInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.subject) - { - if (!subject) - subject = new Name; - *subject = *that.subject; - } - else - { - delete subject; - subject = NULL; - } - if (that.subjectPublicKeyInfo) - { - if (!subjectPublicKeyInfo) - subjectPublicKeyInfo = new SubjectPublicKeyInfo; - *subjectPublicKeyInfo = *that.subjectPublicKeyInfo; - } - else - { - delete subjectPublicKeyInfo; - subjectPublicKeyInfo = NULL; - } - attributes = that.attributes; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificationRequestInfo &CertificationRequestInfo::operator = (const CertificationRequestInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CertificationRequestInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = attributes.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - - BEncEocIfNec (b); - l = subjectPublicKeyInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = subject->BEncContent (b); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // CertificationRequestInfo::BEncContent - - -void CertificationRequestInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-100); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subject = new Name; - subject->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-101); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subjectPublicKeyInfo = new SubjectPublicKeyInfo; - subjectPublicKeyInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-102); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - attributes.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-103); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-104); - } - else - return; -} // CertificationRequestInfo::BDecContent - -AsnLen CertificationRequestInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificationRequestInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificationRequestInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-105); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CertificationRequestInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (subject)) - { - Indent (os, indentG); - os << "subject "; - os << *subject; - } - else - { - Indent (os, indentG); - os << "subject "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (subjectPublicKeyInfo)) - { - Indent (os, indentG); - os << "subjectPublicKeyInfo "; - os << *subjectPublicKeyInfo; - } - else - { - Indent (os, indentG); - os << "subjectPublicKeyInfo "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "attributes "; - os << attributes; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CertificationRequestInfo::Print - - -CertificationRequest::CertificationRequest() -{ -#if TCL - certificationRequestInfo = new CertificationRequestInfo; -#else - certificationRequestInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - signatureAlgorithm = new SignatureAlgorithmIdentifier; -#else - signatureAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -CertificationRequest::CertificationRequest (const CertificationRequest &) -{ - Asn1Error << "use of incompletely defined CertificationRequest::CertificationRequest (const CertificationRequest &)" << endl; - abort(); -} - -CertificationRequest::~CertificationRequest() -{ - delete certificationRequestInfo; - delete signatureAlgorithm; -} - -AsnType *CertificationRequest::Clone() const -{ - return new CertificationRequest; -} - -AsnType *CertificationRequest::Copy() const -{ - return new CertificationRequest (*this); -} - -#if SNACC_DEEP_COPY -CertificationRequest &CertificationRequest::operator = (const CertificationRequest &that) -#else // SNACC_DEEP_COPY -CertificationRequest &CertificationRequest::operator = (const CertificationRequest &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.certificationRequestInfo) - { - if (!certificationRequestInfo) - certificationRequestInfo = new CertificationRequestInfo; - *certificationRequestInfo = *that.certificationRequestInfo; - } - else - { - delete certificationRequestInfo; - certificationRequestInfo = NULL; - } - if (that.signatureAlgorithm) - { - if (!signatureAlgorithm) - signatureAlgorithm = new SignatureAlgorithmIdentifier; - *signatureAlgorithm = *that.signatureAlgorithm; - } - else - { - delete signatureAlgorithm; - signatureAlgorithm = NULL; - } - signature = that.signature; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificationRequest &CertificationRequest::operator = (const CertificationRequest &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CertificationRequest::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = signature.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = signatureAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = certificationRequestInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // CertificationRequest::BEncContent - - -void CertificationRequest::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - certificationRequestInfo = new CertificationRequestInfo; - certificationRequestInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-106); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signatureAlgorithm = new SignatureAlgorithmIdentifier; - signatureAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-107); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signature.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-108); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-109); - } - else - return; -} // CertificationRequest::BDecContent - -AsnLen CertificationRequest::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificationRequest::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificationRequest::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-110); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CertificationRequest::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (certificationRequestInfo)) - { - Indent (os, indentG); - os << "certificationRequestInfo "; - os << *certificationRequestInfo; - } - else - { - Indent (os, indentG); - os << "certificationRequestInfo "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (signatureAlgorithm)) - { - Indent (os, indentG); - os << "signatureAlgorithm "; - os << *signatureAlgorithm; - } - else - { - Indent (os, indentG); - os << "signatureAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signature "; - os << signature; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CertificationRequest::Print - - -CertificationRequestSigned::CertificationRequestSigned() -{ -#if TCL - signatureAlgorithm = new SignatureAlgorithmIdentifier; -#else - signatureAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -CertificationRequestSigned::CertificationRequestSigned (const CertificationRequestSigned &) -{ - Asn1Error << "use of incompletely defined CertificationRequestSigned::CertificationRequestSigned (const CertificationRequestSigned &)" << endl; - abort(); -} - -CertificationRequestSigned::~CertificationRequestSigned() -{ - delete signatureAlgorithm; -} - -AsnType *CertificationRequestSigned::Clone() const -{ - return new CertificationRequestSigned; -} - -AsnType *CertificationRequestSigned::Copy() const -{ - return new CertificationRequestSigned (*this); -} - -#if SNACC_DEEP_COPY -CertificationRequestSigned &CertificationRequestSigned::operator = (const CertificationRequestSigned &that) -#else // SNACC_DEEP_COPY -CertificationRequestSigned &CertificationRequestSigned::operator = (const CertificationRequestSigned &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - certificationRequestInfo = that.certificationRequestInfo; - if (that.signatureAlgorithm) - { - if (!signatureAlgorithm) - signatureAlgorithm = new SignatureAlgorithmIdentifier; - *signatureAlgorithm = *that.signatureAlgorithm; - } - else - { - delete signatureAlgorithm; - signatureAlgorithm = NULL; - } - signature = that.signature; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificationRequestSigned &CertificationRequestSigned::operator = (const CertificationRequestSigned &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CertificationRequestSigned::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = signature.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = signatureAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - ENC_LOAD_ANYBUF(&certificationRequestInfo, b, l); - totalLen += l; - - return totalLen; -} // CertificationRequestSigned::BEncContent - - -void CertificationRequestSigned::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - // ANY type - DEC_LOAD_ANYBUF(&certificationRequestInfo, b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signatureAlgorithm = new SignatureAlgorithmIdentifier; - signatureAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-111); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signature.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-112); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-113); - } - else - return; -} // CertificationRequestSigned::BDecContent - -AsnLen CertificationRequestSigned::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificationRequestSigned::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificationRequestSigned::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-114); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CertificationRequestSigned::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "certificationRequestInfo "; - os << certificationRequestInfo; - os << "," << endl; - } - - if (NOT_NULL (signatureAlgorithm)) - { - Indent (os, indentG); - os << "signatureAlgorithm "; - os << *signatureAlgorithm; - } - else - { - Indent (os, indentG); - os << "signatureAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signature "; - os << signature; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CertificationRequestSigned::Print - - diff --git a/SecurityASN1/c++/pkcs1oids.cpp b/SecurityASN1/c++/pkcs1oids.cpp deleted file mode 100644 index 23d1ba68..00000000 --- a/SecurityASN1/c++/pkcs1oids.cpp +++ /dev/null @@ -1,552 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs1oids.cpp - class member functions for ASN.1 module PKCS1-OIDS -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -RSAPublicKey::RSAPublicKey() -{ -} - -RSAPublicKey::RSAPublicKey (const RSAPublicKey &) -{ - Asn1Error << "use of incompletely defined RSAPublicKey::RSAPublicKey (const RSAPublicKey &)" << endl; - abort(); -} - -RSAPublicKey::~RSAPublicKey() -{ -} - -AsnType *RSAPublicKey::Clone() const -{ - return new RSAPublicKey; -} - -AsnType *RSAPublicKey::Copy() const -{ - return new RSAPublicKey (*this); -} - -#if SNACC_DEEP_COPY -RSAPublicKey &RSAPublicKey::operator = (const RSAPublicKey &that) -#else // SNACC_DEEP_COPY -RSAPublicKey &RSAPublicKey::operator = (const RSAPublicKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - modulus = that.modulus; - publicExponent = that.publicExponent; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RSAPublicKey &RSAPublicKey::operator = (const RSAPublicKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -RSAPublicKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = publicExponent.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = modulus.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // RSAPublicKey::BEncContent - - -void RSAPublicKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - modulus.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-100); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - publicExponent.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-101); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-102); - } - else - return; -} // RSAPublicKey::BDecContent - -AsnLen RSAPublicKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void RSAPublicKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "RSAPublicKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-103); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void RSAPublicKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "modulus "; - os << modulus; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "publicExponent "; - os << publicExponent; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // RSAPublicKey::Print - - -RSAPrivateKey::RSAPrivateKey() -{ -} - -RSAPrivateKey::RSAPrivateKey (const RSAPrivateKey &) -{ - Asn1Error << "use of incompletely defined RSAPrivateKey::RSAPrivateKey (const RSAPrivateKey &)" << endl; - abort(); -} - -RSAPrivateKey::~RSAPrivateKey() -{ -} - -AsnType *RSAPrivateKey::Clone() const -{ - return new RSAPrivateKey; -} - -AsnType *RSAPrivateKey::Copy() const -{ - return new RSAPrivateKey (*this); -} - -#if SNACC_DEEP_COPY -RSAPrivateKey &RSAPrivateKey::operator = (const RSAPrivateKey &that) -#else // SNACC_DEEP_COPY -RSAPrivateKey &RSAPrivateKey::operator = (const RSAPrivateKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - modulus = that.modulus; - publicExponent = that.publicExponent; - privateExponent = that.privateExponent; - prime1 = that.prime1; - prime2 = that.prime2; - exponent1 = that.exponent1; - exponent2 = that.exponent2; - coefficient = that.coefficient; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RSAPrivateKey &RSAPrivateKey::operator = (const RSAPrivateKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -RSAPrivateKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = coefficient.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = exponent2.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = exponent1.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = prime2.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = prime1.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = privateExponent.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = publicExponent.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = modulus.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // RSAPrivateKey::BEncContent - - -void RSAPrivateKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-104); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - modulus.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-105); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - publicExponent.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-106); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - privateExponent.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-107); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - prime1.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-108); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - prime2.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-109); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - exponent1.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-110); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - exponent2.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-111); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - coefficient.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-112); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-113); - } - else - return; -} // RSAPrivateKey::BDecContent - -AsnLen RSAPrivateKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void RSAPrivateKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "RSAPrivateKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-114); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void RSAPrivateKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "modulus "; - os << modulus; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "publicExponent "; - os << publicExponent; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "privateExponent "; - os << privateExponent; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "prime1 "; - os << prime1; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "prime2 "; - os << prime2; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "exponent1 "; - os << exponent1; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "exponent2 "; - os << exponent2; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "coefficient "; - os << coefficient; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // RSAPrivateKey::Print - - diff --git a/SecurityASN1/c++/pkcs7.cpp b/SecurityASN1/c++/pkcs7.cpp deleted file mode 100644 index 925396fc..00000000 --- a/SecurityASN1/c++/pkcs7.cpp +++ /dev/null @@ -1,473 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs7.cpp - class member functions for ASN.1 module PKCS7 -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -EncryptedContentInfo1::EncryptedContentInfo1() -{ -#if TCL - contentEncryptionAlgorithm = new ContentEncryptionAlgorithmIdentifier1; -#else - contentEncryptionAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL - encryptedContent = NULL; -} - -EncryptedContentInfo1::EncryptedContentInfo1 (const EncryptedContentInfo1 &) -{ - Asn1Error << "use of incompletely defined EncryptedContentInfo1::EncryptedContentInfo1 (const EncryptedContentInfo1 &)" << endl; - abort(); -} - -EncryptedContentInfo1::~EncryptedContentInfo1() -{ - delete contentEncryptionAlgorithm; - delete encryptedContent; -} - -AsnType *EncryptedContentInfo1::Clone() const -{ - return new EncryptedContentInfo1; -} - -AsnType *EncryptedContentInfo1::Copy() const -{ - return new EncryptedContentInfo1 (*this); -} - -#if SNACC_DEEP_COPY -EncryptedContentInfo1 &EncryptedContentInfo1::operator = (const EncryptedContentInfo1 &that) -#else // SNACC_DEEP_COPY -EncryptedContentInfo1 &EncryptedContentInfo1::operator = (const EncryptedContentInfo1 &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - contentType = that.contentType; - if (that.contentEncryptionAlgorithm) - { - if (!contentEncryptionAlgorithm) - contentEncryptionAlgorithm = new ContentEncryptionAlgorithmIdentifier1; - *contentEncryptionAlgorithm = *that.contentEncryptionAlgorithm; - } - else - { - delete contentEncryptionAlgorithm; - contentEncryptionAlgorithm = NULL; - } - if (that.encryptedContent) - { - if (!encryptedContent) - encryptedContent = new EncryptedContent1; - *encryptedContent = *that.encryptedContent; - } - else - { - delete encryptedContent; - encryptedContent = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EncryptedContentInfo1 &EncryptedContentInfo1::operator = (const EncryptedContentInfo1 &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EncryptedContentInfo1::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (encryptedContent)) - { - l = encryptedContent->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - } - - BEncEocIfNec (b); - l = contentEncryptionAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = contentType.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // EncryptedContentInfo1::BEncContent - - -void EncryptedContentInfo1::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-100); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentEncryptionAlgorithm = new ContentEncryptionAlgorithmIdentifier1; - contentEncryptionAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-101); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedContent = new EncryptedContent1; - encryptedContent->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-102); - } - else - return; -} // EncryptedContentInfo1::BDecContent - -AsnLen EncryptedContentInfo1::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EncryptedContentInfo1::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EncryptedContentInfo1::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-103); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EncryptedContentInfo1::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "contentType "; - os << contentType; - os << "," << endl; - } - - if (NOT_NULL (contentEncryptionAlgorithm)) - { - Indent (os, indentG); - os << "contentEncryptionAlgorithm "; - os << *contentEncryptionAlgorithm; - } - else - { - Indent (os, indentG); - os << "contentEncryptionAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (encryptedContent)) - { - os << ","<< endl; - Indent (os, indentG); - os << "encryptedContent "; - os << *encryptedContent; - } - else - { - Indent (os, indentG); - os << "encryptedContent "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EncryptedContentInfo1::Print - - -EncryptedData1::EncryptedData1() -{ -#if TCL - encryptedContentInfo = new EncryptedContentInfo1; -#else - encryptedContentInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EncryptedData1::EncryptedData1 (const EncryptedData1 &) -{ - Asn1Error << "use of incompletely defined EncryptedData1::EncryptedData1 (const EncryptedData1 &)" << endl; - abort(); -} - -EncryptedData1::~EncryptedData1() -{ - delete encryptedContentInfo; -} - -AsnType *EncryptedData1::Clone() const -{ - return new EncryptedData1; -} - -AsnType *EncryptedData1::Copy() const -{ - return new EncryptedData1 (*this); -} - -#if SNACC_DEEP_COPY -EncryptedData1 &EncryptedData1::operator = (const EncryptedData1 &that) -#else // SNACC_DEEP_COPY -EncryptedData1 &EncryptedData1::operator = (const EncryptedData1 &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.encryptedContentInfo) - { - if (!encryptedContentInfo) - encryptedContentInfo = new EncryptedContentInfo1; - *encryptedContentInfo = *that.encryptedContentInfo; - } - else - { - delete encryptedContentInfo; - encryptedContentInfo = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EncryptedData1 &EncryptedData1::operator = (const EncryptedData1 &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EncryptedData1::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = encryptedContentInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // EncryptedData1::BEncContent - - -void EncryptedData1::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-104); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedContentInfo = new EncryptedContentInfo1; - encryptedContentInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-105); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-106); - } - else - return; -} // EncryptedData1::BDecContent - -AsnLen EncryptedData1::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EncryptedData1::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EncryptedData1::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-107); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EncryptedData1::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (encryptedContentInfo)) - { - Indent (os, indentG); - os << "encryptedContentInfo "; - os << *encryptedContentInfo; - } - else - { - Indent (os, indentG); - os << "encryptedContentInfo "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EncryptedData1::Print - - diff --git a/SecurityASN1/c++/pkcs8.cpp b/SecurityASN1/c++/pkcs8.cpp deleted file mode 100644 index fb974516..00000000 --- a/SecurityASN1/c++/pkcs8.cpp +++ /dev/null @@ -1,500 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs8.cpp - class member functions for ASN.1 module PrivateKeyInformationSyntax -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -PrivateKeyInfo::PrivateKeyInfo() -{ -#if TCL - privateKeyAlgorithm = new AlgorithmIdentifier; -#else - privateKeyAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL - attributes = NULL; -} - -PrivateKeyInfo::PrivateKeyInfo (const PrivateKeyInfo &) -{ - Asn1Error << "use of incompletely defined PrivateKeyInfo::PrivateKeyInfo (const PrivateKeyInfo &)" << endl; - abort(); -} - -PrivateKeyInfo::~PrivateKeyInfo() -{ - delete privateKeyAlgorithm; - delete attributes; -} - -AsnType *PrivateKeyInfo::Clone() const -{ - return new PrivateKeyInfo; -} - -AsnType *PrivateKeyInfo::Copy() const -{ - return new PrivateKeyInfo (*this); -} - -#if SNACC_DEEP_COPY -PrivateKeyInfo &PrivateKeyInfo::operator = (const PrivateKeyInfo &that) -#else // SNACC_DEEP_COPY -PrivateKeyInfo &PrivateKeyInfo::operator = (const PrivateKeyInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.privateKeyAlgorithm) - { - if (!privateKeyAlgorithm) - privateKeyAlgorithm = new AlgorithmIdentifier; - *privateKeyAlgorithm = *that.privateKeyAlgorithm; - } - else - { - delete privateKeyAlgorithm; - privateKeyAlgorithm = NULL; - } - privateKey = that.privateKey; - if (that.attributes) - { - if (!attributes) - attributes = new Attributes; - *attributes = *that.attributes; - } - else - { - delete attributes; - attributes = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PrivateKeyInfo &PrivateKeyInfo::operator = (const PrivateKeyInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -PrivateKeyInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (attributes)) - { - BEncEocIfNec (b); - l = attributes->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - l = privateKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = privateKeyAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // PrivateKeyInfo::BEncContent - - -void PrivateKeyInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-100); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - privateKeyAlgorithm = new AlgorithmIdentifier; - privateKeyAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-101); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - privateKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-102); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - attributes = new Attributes; - attributes->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-103); - } - else - return; -} // PrivateKeyInfo::BDecContent - -AsnLen PrivateKeyInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void PrivateKeyInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "PrivateKeyInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-104); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void PrivateKeyInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (privateKeyAlgorithm)) - { - Indent (os, indentG); - os << "privateKeyAlgorithm "; - os << *privateKeyAlgorithm; - } - else - { - Indent (os, indentG); - os << "privateKeyAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "privateKey "; - os << privateKey; - os << "," << endl; - } - - if (NOT_NULL (attributes)) - { - os << ","<< endl; - Indent (os, indentG); - os << "attributes "; - os << *attributes; - } - else - { - Indent (os, indentG); - os << "attributes "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // PrivateKeyInfo::Print - - -EncryptedPrivateKeyInfo::EncryptedPrivateKeyInfo() -{ -#if TCL - encryptionAlgorithm = new AlgorithmIdentifier; -#else - encryptionAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EncryptedPrivateKeyInfo::EncryptedPrivateKeyInfo (const EncryptedPrivateKeyInfo &) -{ - Asn1Error << "use of incompletely defined EncryptedPrivateKeyInfo::EncryptedPrivateKeyInfo (const EncryptedPrivateKeyInfo &)" << endl; - abort(); -} - -EncryptedPrivateKeyInfo::~EncryptedPrivateKeyInfo() -{ - delete encryptionAlgorithm; -} - -AsnType *EncryptedPrivateKeyInfo::Clone() const -{ - return new EncryptedPrivateKeyInfo; -} - -AsnType *EncryptedPrivateKeyInfo::Copy() const -{ - return new EncryptedPrivateKeyInfo (*this); -} - -#if SNACC_DEEP_COPY -EncryptedPrivateKeyInfo &EncryptedPrivateKeyInfo::operator = (const EncryptedPrivateKeyInfo &that) -#else // SNACC_DEEP_COPY -EncryptedPrivateKeyInfo &EncryptedPrivateKeyInfo::operator = (const EncryptedPrivateKeyInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.encryptionAlgorithm) - { - if (!encryptionAlgorithm) - encryptionAlgorithm = new AlgorithmIdentifier; - *encryptionAlgorithm = *that.encryptionAlgorithm; - } - else - { - delete encryptionAlgorithm; - encryptionAlgorithm = NULL; - } - encryptedKey = that.encryptedKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EncryptedPrivateKeyInfo &EncryptedPrivateKeyInfo::operator = (const EncryptedPrivateKeyInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EncryptedPrivateKeyInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = encryptedKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = encryptionAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // EncryptedPrivateKeyInfo::BEncContent - - -void EncryptedPrivateKeyInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptionAlgorithm = new AlgorithmIdentifier; - encryptionAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-105); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-106); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-107); - } - else - return; -} // EncryptedPrivateKeyInfo::BDecContent - -AsnLen EncryptedPrivateKeyInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EncryptedPrivateKeyInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EncryptedPrivateKeyInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-108); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EncryptedPrivateKeyInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (encryptionAlgorithm)) - { - Indent (os, indentG); - os << "encryptionAlgorithm "; - os << *encryptionAlgorithm; - } - else - { - Indent (os, indentG); - os << "encryptionAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "encryptedKey "; - os << encryptedKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EncryptedPrivateKeyInfo::Print - - diff --git a/SecurityASN1/c++/pkcs9oids.cpp b/SecurityASN1/c++/pkcs9oids.cpp deleted file mode 100644 index 193ba016..00000000 --- a/SecurityASN1/c++/pkcs9oids.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs9oids.cpp - class member functions for ASN.1 module PKCS9-OIDS -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - diff --git a/SecurityASN1/c++/sm_cms.cpp b/SecurityASN1/c++/sm_cms.cpp deleted file mode 100644 index e8b1a95e..00000000 --- a/SecurityASN1/c++/sm_cms.cpp +++ /dev/null @@ -1,10334 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_cms.cpp - class member functions for ASN.1 module CryptographicMessageSyntax -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -OriginatorPublicKey::OriginatorPublicKey() -{ -#if TCL - algorithm = new AlgorithmIdentifier; -#else - algorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -OriginatorPublicKey::OriginatorPublicKey (const OriginatorPublicKey &) -{ - Asn1Error << "use of incompletely defined OriginatorPublicKey::OriginatorPublicKey (const OriginatorPublicKey &)" << endl; - abort(); -} - -OriginatorPublicKey::~OriginatorPublicKey() -{ - delete algorithm; -} - -AsnType *OriginatorPublicKey::Clone() const -{ - return new OriginatorPublicKey; -} - -AsnType *OriginatorPublicKey::Copy() const -{ - return new OriginatorPublicKey (*this); -} - -#if SNACC_DEEP_COPY -OriginatorPublicKey &OriginatorPublicKey::operator = (const OriginatorPublicKey &that) -#else // SNACC_DEEP_COPY -OriginatorPublicKey &OriginatorPublicKey::operator = (const OriginatorPublicKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.algorithm) - { - if (!algorithm) - algorithm = new AlgorithmIdentifier; - *algorithm = *that.algorithm; - } - else - { - delete algorithm; - algorithm = NULL; - } - publicKey = that.publicKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined OriginatorPublicKey &OriginatorPublicKey::operator = (const OriginatorPublicKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -OriginatorPublicKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = publicKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = algorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // OriginatorPublicKey::BEncContent - - -void OriginatorPublicKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - algorithm = new AlgorithmIdentifier; - algorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-100); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - publicKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-101); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-102); - } - else - return; -} // OriginatorPublicKey::BDecContent - -AsnLen OriginatorPublicKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void OriginatorPublicKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "OriginatorPublicKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-103); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void OriginatorPublicKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (algorithm)) - { - Indent (os, indentG); - os << "algorithm "; - os << *algorithm; - } - else - { - Indent (os, indentG); - os << "algorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "publicKey "; - os << publicKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // OriginatorPublicKey::Print - - -AsnType *CertificateRevocationLists::Clone() const -{ - return new CertificateRevocationLists; -} - -AsnType *CertificateRevocationLists::Copy() const -{ - return new CertificateRevocationLists (*this); -} - -AsnLen CertificateRevocationLists::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void CertificateRevocationLists::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "CertificateRevocationLists::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-104); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -CertificateRevocationLists::CertificateRevocationLists (const CertificateRevocationLists &) -{ - Asn1Error << "use of incompletely defined CertificateRevocationLists::CertificateRevocationLists (const CertificateRevocationLists &)" << endl; - abort(); -} - -CertificateRevocationLists::~CertificateRevocationLists() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -CertificateRevocationLists &CertificateRevocationLists::operator = (const CertificateRevocationLists &that) -#else // SNACC_DEEP_COPY -CertificateRevocationLists &CertificateRevocationLists::operator = (const CertificateRevocationLists &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificateRevocationLists &CertificateRevocationLists::operator = (const CertificateRevocationLists &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void CertificateRevocationLists::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void CertificateRevocationLists::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // CertificateRevocationLists::SetCurrElmt - - -unsigned long int CertificateRevocationLists::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // CertificateRevocationLists::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -CertificateList *CertificateRevocationLists::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateList; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificateRevocationLists::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -CertificateList *CertificateRevocationLists::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateList; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificateRevocationLists::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -CertificateList *CertificateRevocationLists::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateList; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificateRevocationLists::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertificateList *CertificateRevocationLists::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateList; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificateRevocationLists::InsertAfter - - -CertificateRevocationLists &CertificateRevocationLists::AppendCopy (CertificateList &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateList; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -CertificateRevocationLists &CertificateRevocationLists::PrependCopy (CertificateList &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateList; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // CertificateRevocationLists::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -CertificateRevocationLists &CertificateRevocationLists::InsertBeforeAndCopy (CertificateList &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateList; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // CertificateRevocationLists::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertificateRevocationLists &CertificateRevocationLists::InsertAfterAndCopy (CertificateList &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateList; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // CertificateRevocationLists::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void CertificateRevocationLists::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen CertificateRevocationLists::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // CertificateRevocationLists::BEncContent - - -void CertificateRevocationLists::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - CertificateList *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-105); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // CertificateRevocationLists::BDecContent - - -IssuerAndSerialNumber::IssuerAndSerialNumber() -{ -#if TCL - issuer = new Name; -#else - issuer = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -IssuerAndSerialNumber::IssuerAndSerialNumber (const IssuerAndSerialNumber &) -{ - Asn1Error << "use of incompletely defined IssuerAndSerialNumber::IssuerAndSerialNumber (const IssuerAndSerialNumber &)" << endl; - abort(); -} - -IssuerAndSerialNumber::~IssuerAndSerialNumber() -{ - delete issuer; -} - -AsnType *IssuerAndSerialNumber::Clone() const -{ - return new IssuerAndSerialNumber; -} - -AsnType *IssuerAndSerialNumber::Copy() const -{ - return new IssuerAndSerialNumber (*this); -} - -#if SNACC_DEEP_COPY -IssuerAndSerialNumber &IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber &that) -#else // SNACC_DEEP_COPY -IssuerAndSerialNumber &IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.issuer) - { - if (!issuer) - issuer = new Name; - *issuer = *that.issuer; - } - else - { - delete issuer; - issuer = NULL; - } - serialNumber = that.serialNumber; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined IssuerAndSerialNumber &IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -IssuerAndSerialNumber::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = serialNumber.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - l = issuer->BEncContent (b); - totalLen += l; - - return totalLen; -} // IssuerAndSerialNumber::BEncContent - - -void IssuerAndSerialNumber::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuer = new Name; - issuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-106); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - serialNumber.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-107); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-108); - } - else - return; -} // IssuerAndSerialNumber::BDecContent - -AsnLen IssuerAndSerialNumber::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void IssuerAndSerialNumber::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "IssuerAndSerialNumber::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-109); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void IssuerAndSerialNumber::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (issuer)) - { - Indent (os, indentG); - os << "issuer "; - os << *issuer; - } - else - { - Indent (os, indentG); - os << "issuer "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "serialNumber "; - os << serialNumber; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // IssuerAndSerialNumber::Print - - -OtherKeyAttribute::OtherKeyAttribute() -{ - keyAttr = NULL; -} - -OtherKeyAttribute::OtherKeyAttribute (const OtherKeyAttribute &) -{ - Asn1Error << "use of incompletely defined OtherKeyAttribute::OtherKeyAttribute (const OtherKeyAttribute &)" << endl; - abort(); -} - -OtherKeyAttribute::~OtherKeyAttribute() -{ - delete keyAttr; -} - -AsnType *OtherKeyAttribute::Clone() const -{ - return new OtherKeyAttribute; -} - -AsnType *OtherKeyAttribute::Copy() const -{ - return new OtherKeyAttribute (*this); -} - -#if SNACC_DEEP_COPY -OtherKeyAttribute &OtherKeyAttribute::operator = (const OtherKeyAttribute &that) -#else // SNACC_DEEP_COPY -OtherKeyAttribute &OtherKeyAttribute::operator = (const OtherKeyAttribute &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - keyAttrId = that.keyAttrId; - if (that.keyAttr) - { - if (!keyAttr) - keyAttr = new AsnAny; - *keyAttr = *that.keyAttr; - } - else - { - delete keyAttr; - keyAttr = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined OtherKeyAttribute &OtherKeyAttribute::operator = (const OtherKeyAttribute &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -OtherKeyAttribute::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (keyAttr)) - { - ENC_LOAD_ANYBUF(keyAttr, b, l); - totalLen += l; - } - - l = keyAttrId.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // OtherKeyAttribute::BEncContent - - -void OtherKeyAttribute::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - keyAttrId.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = b.PeekByte(); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDecEoc (b, seqBytesDecoded, env); - - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-110); - } - - // ANY type - keyAttr = new AsnAny; - DEC_LOAD_ANYBUF(keyAttr, b, seqBytesDecoded, env); - - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-111); - } - else - return; -} // OtherKeyAttribute::BDecContent - -AsnLen OtherKeyAttribute::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void OtherKeyAttribute::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "OtherKeyAttribute::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-112); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void OtherKeyAttribute::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "keyAttrId "; - os << keyAttrId; - os << "," << endl; - } - - if (NOT_NULL (keyAttr)) - { - os << ","<< endl; - Indent (os, indentG); - os << "keyAttr "; - os << *keyAttr; - } - else - { - Indent (os, indentG); - os << "keyAttr "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // OtherKeyAttribute::Print - - -AsnType *DigestAlgorithmIdentifiers::Clone() const -{ - return new DigestAlgorithmIdentifiers; -} - -AsnType *DigestAlgorithmIdentifiers::Copy() const -{ - return new DigestAlgorithmIdentifiers (*this); -} - -AsnLen DigestAlgorithmIdentifiers::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void DigestAlgorithmIdentifiers::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "DigestAlgorithmIdentifiers::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-113); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -DigestAlgorithmIdentifiers::DigestAlgorithmIdentifiers (const DigestAlgorithmIdentifiers &) -{ - Asn1Error << "use of incompletely defined DigestAlgorithmIdentifiers::DigestAlgorithmIdentifiers (const DigestAlgorithmIdentifiers &)" << endl; - abort(); -} - -DigestAlgorithmIdentifiers::~DigestAlgorithmIdentifiers() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers &that) -#else // SNACC_DEEP_COPY -DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void DigestAlgorithmIdentifiers::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void DigestAlgorithmIdentifiers::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // DigestAlgorithmIdentifiers::SetCurrElmt - - -unsigned long int DigestAlgorithmIdentifiers::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // DigestAlgorithmIdentifiers::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -DigestAlgorithmIdentifier *DigestAlgorithmIdentifiers::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DigestAlgorithmIdentifier; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // DigestAlgorithmIdentifiers::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -DigestAlgorithmIdentifier *DigestAlgorithmIdentifiers::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DigestAlgorithmIdentifier; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // DigestAlgorithmIdentifiers::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -DigestAlgorithmIdentifier *DigestAlgorithmIdentifiers::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DigestAlgorithmIdentifier; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // DigestAlgorithmIdentifiers::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -DigestAlgorithmIdentifier *DigestAlgorithmIdentifiers::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DigestAlgorithmIdentifier; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // DigestAlgorithmIdentifiers::InsertAfter - - -DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::AppendCopy (DigestAlgorithmIdentifier &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DigestAlgorithmIdentifier; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::PrependCopy (DigestAlgorithmIdentifier &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DigestAlgorithmIdentifier; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // DigestAlgorithmIdentifiers::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::InsertBeforeAndCopy (DigestAlgorithmIdentifier &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new DigestAlgorithmIdentifier; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // DigestAlgorithmIdentifiers::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::InsertAfterAndCopy (DigestAlgorithmIdentifier &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new DigestAlgorithmIdentifier; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // DigestAlgorithmIdentifiers::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void DigestAlgorithmIdentifiers::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen DigestAlgorithmIdentifiers::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // DigestAlgorithmIdentifiers::BEncContent - - -void DigestAlgorithmIdentifiers::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - DigestAlgorithmIdentifier *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-114); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // DigestAlgorithmIdentifiers::BDecContent - - -EncapsulatedContentInfo::EncapsulatedContentInfo() -{ - eContent = NULL; -} - -EncapsulatedContentInfo::EncapsulatedContentInfo (const EncapsulatedContentInfo &) -{ - Asn1Error << "use of incompletely defined EncapsulatedContentInfo::EncapsulatedContentInfo (const EncapsulatedContentInfo &)" << endl; - abort(); -} - -EncapsulatedContentInfo::~EncapsulatedContentInfo() -{ - delete eContent; -} - -AsnType *EncapsulatedContentInfo::Clone() const -{ - return new EncapsulatedContentInfo; -} - -AsnType *EncapsulatedContentInfo::Copy() const -{ - return new EncapsulatedContentInfo (*this); -} - -#if SNACC_DEEP_COPY -EncapsulatedContentInfo &EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo &that) -#else // SNACC_DEEP_COPY -EncapsulatedContentInfo &EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - eContentType = that.eContentType; - if (that.eContent) - { - if (!eContent) - eContent = new AsnOcts; - *eContent = *that.eContent; - } - else - { - delete eContent; - eContent = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EncapsulatedContentInfo &EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EncapsulatedContentInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (eContent)) - { - BEncEocIfNec (b); - l = eContent->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - l = eContentType.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // EncapsulatedContentInfo::BEncContent - - -void EncapsulatedContentInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - eContentType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-115); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - && (tag1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-116); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - eContent = new AsnOcts; - eContent->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-117); - } - else - return; -} // EncapsulatedContentInfo::BDecContent - -AsnLen EncapsulatedContentInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EncapsulatedContentInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EncapsulatedContentInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-118); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EncapsulatedContentInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "eContentType "; - os << eContentType; - os << "," << endl; - } - - if (NOT_NULL (eContent)) - { - os << ","<< endl; - Indent (os, indentG); - os << "eContent "; - os << *eContent; - } - else - { - Indent (os, indentG); - os << "eContent "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EncapsulatedContentInfo::Print - - -SignerIdentifier::SignerIdentifier() -{ - choiceId = issuerAndSerialNumberCid; -#if TCL - issuerAndSerialNumber = new IssuerAndSerialNumber; -#else - issuerAndSerialNumber = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -SignerIdentifier::SignerIdentifier (const SignerIdentifier &) -{ - Asn1Error << "use of incompletely defined SignerIdentifier::SignerIdentifier (const SignerIdentifier &)" << endl; - abort(); -} - -SignerIdentifier::~SignerIdentifier() -{ - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - delete subjectKeyIdentifier; - break; - } // end of switch -} // end of destructor - -AsnType *SignerIdentifier::Clone() const -{ - return new SignerIdentifier; -} - -AsnType *SignerIdentifier::Copy() const -{ - return new SignerIdentifier (*this); -} - -#if SNACC_DEEP_COPY -SignerIdentifier &SignerIdentifier::operator = (const SignerIdentifier &that) -#else // SNACC_DEEP_COPY -SignerIdentifier &SignerIdentifier::operator = (const SignerIdentifier &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - delete subjectKeyIdentifier; - break; - } - switch (choiceId = that.choiceId) - { - case issuerAndSerialNumberCid: - issuerAndSerialNumber = new IssuerAndSerialNumber; - *issuerAndSerialNumber = *that.issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - subjectKeyIdentifier = new KeyIdentifier; - *subjectKeyIdentifier = *that.subjectKeyIdentifier; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SignerIdentifier &SignerIdentifier::operator = (const SignerIdentifier &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -SignerIdentifier::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case issuerAndSerialNumberCid: - BEncEocIfNec (b); - l = issuerAndSerialNumber->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - case subjectKeyIdentifierCid: - l = subjectKeyIdentifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - break; - - } // end switch - return l; -} // SignerIdentifier::BEncContent - - -void SignerIdentifier::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = issuerAndSerialNumberCid; - issuerAndSerialNumber = new IssuerAndSerialNumber; - issuerAndSerialNumber->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 0): - case MAKE_TAG_ID (CNTX, CONS, 0): - choiceId = subjectKeyIdentifierCid; - subjectKeyIdentifier = new KeyIdentifier; - subjectKeyIdentifier->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-119); - break; - } // end switch -} // SignerIdentifier::BDecContent - - -AsnLen SignerIdentifier::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void SignerIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void SignerIdentifier::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case issuerAndSerialNumberCid: - os << "issuerAndSerialNumber "; - if (issuerAndSerialNumber) - os << *issuerAndSerialNumber; - else - os << "-- void3 --\n"; - break; - - case subjectKeyIdentifierCid: - os << "subjectKeyIdentifier "; - if (subjectKeyIdentifier) - os << *subjectKeyIdentifier; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // SignerIdentifier::Print - -EncryptedContentInfo::EncryptedContentInfo() -{ -#if TCL - contentEncryptionAlgorithm = new ContentEncryptionAlgorithmIdentifier; -#else - contentEncryptionAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL - encryptedContent = NULL; -} - -EncryptedContentInfo::EncryptedContentInfo (const EncryptedContentInfo &) -{ - Asn1Error << "use of incompletely defined EncryptedContentInfo::EncryptedContentInfo (const EncryptedContentInfo &)" << endl; - abort(); -} - -EncryptedContentInfo::~EncryptedContentInfo() -{ - delete contentEncryptionAlgorithm; - delete encryptedContent; -} - -AsnType *EncryptedContentInfo::Clone() const -{ - return new EncryptedContentInfo; -} - -AsnType *EncryptedContentInfo::Copy() const -{ - return new EncryptedContentInfo (*this); -} - -#if SNACC_DEEP_COPY -EncryptedContentInfo &EncryptedContentInfo::operator = (const EncryptedContentInfo &that) -#else // SNACC_DEEP_COPY -EncryptedContentInfo &EncryptedContentInfo::operator = (const EncryptedContentInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - contentType = that.contentType; - if (that.contentEncryptionAlgorithm) - { - if (!contentEncryptionAlgorithm) - contentEncryptionAlgorithm = new ContentEncryptionAlgorithmIdentifier; - *contentEncryptionAlgorithm = *that.contentEncryptionAlgorithm; - } - else - { - delete contentEncryptionAlgorithm; - contentEncryptionAlgorithm = NULL; - } - if (that.encryptedContent) - { - if (!encryptedContent) - encryptedContent = new EncryptedContent; - *encryptedContent = *that.encryptedContent; - } - else - { - delete encryptedContent; - encryptedContent = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EncryptedContentInfo &EncryptedContentInfo::operator = (const EncryptedContentInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EncryptedContentInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (encryptedContent)) - { - l = encryptedContent->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - } - - BEncEocIfNec (b); - l = contentEncryptionAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = contentType.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // EncryptedContentInfo::BEncContent - - -void EncryptedContentInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-120); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentEncryptionAlgorithm = new ContentEncryptionAlgorithmIdentifier; - contentEncryptionAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-121); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedContent = new EncryptedContent; - encryptedContent->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-122); - } - else - return; -} // EncryptedContentInfo::BDecContent - -AsnLen EncryptedContentInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EncryptedContentInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EncryptedContentInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-123); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EncryptedContentInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "contentType "; - os << contentType; - os << "," << endl; - } - - if (NOT_NULL (contentEncryptionAlgorithm)) - { - Indent (os, indentG); - os << "contentEncryptionAlgorithm "; - os << *contentEncryptionAlgorithm; - } - else - { - Indent (os, indentG); - os << "contentEncryptionAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (encryptedContent)) - { - os << ","<< endl; - Indent (os, indentG); - os << "encryptedContent "; - os << *encryptedContent; - } - else - { - Indent (os, indentG); - os << "encryptedContent "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EncryptedContentInfo::Print - - -RecipientIdentifier::RecipientIdentifier() -{ - choiceId = issuerAndSerialNumberCid; -#if TCL - issuerAndSerialNumber = new IssuerAndSerialNumber; -#else - issuerAndSerialNumber = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -RecipientIdentifier::RecipientIdentifier (const RecipientIdentifier &) -{ - Asn1Error << "use of incompletely defined RecipientIdentifier::RecipientIdentifier (const RecipientIdentifier &)" << endl; - abort(); -} - -RecipientIdentifier::~RecipientIdentifier() -{ - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - delete subjectKeyIdentifier; - break; - } // end of switch -} // end of destructor - -AsnType *RecipientIdentifier::Clone() const -{ - return new RecipientIdentifier; -} - -AsnType *RecipientIdentifier::Copy() const -{ - return new RecipientIdentifier (*this); -} - -#if SNACC_DEEP_COPY -RecipientIdentifier &RecipientIdentifier::operator = (const RecipientIdentifier &that) -#else // SNACC_DEEP_COPY -RecipientIdentifier &RecipientIdentifier::operator = (const RecipientIdentifier &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - delete subjectKeyIdentifier; - break; - } - switch (choiceId = that.choiceId) - { - case issuerAndSerialNumberCid: - issuerAndSerialNumber = new IssuerAndSerialNumber; - *issuerAndSerialNumber = *that.issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - subjectKeyIdentifier = new KeyIdentifier; - *subjectKeyIdentifier = *that.subjectKeyIdentifier; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RecipientIdentifier &RecipientIdentifier::operator = (const RecipientIdentifier &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -RecipientIdentifier::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case issuerAndSerialNumberCid: - BEncEocIfNec (b); - l = issuerAndSerialNumber->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - case subjectKeyIdentifierCid: - l = subjectKeyIdentifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - break; - - } // end switch - return l; -} // RecipientIdentifier::BEncContent - - -void RecipientIdentifier::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = issuerAndSerialNumberCid; - issuerAndSerialNumber = new IssuerAndSerialNumber; - issuerAndSerialNumber->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 0): - case MAKE_TAG_ID (CNTX, CONS, 0): - choiceId = subjectKeyIdentifierCid; - subjectKeyIdentifier = new KeyIdentifier; - subjectKeyIdentifier->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-124); - break; - } // end switch -} // RecipientIdentifier::BDecContent - - -AsnLen RecipientIdentifier::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void RecipientIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void RecipientIdentifier::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case issuerAndSerialNumberCid: - os << "issuerAndSerialNumber "; - if (issuerAndSerialNumber) - os << *issuerAndSerialNumber; - else - os << "-- void3 --\n"; - break; - - case subjectKeyIdentifierCid: - os << "subjectKeyIdentifier "; - if (subjectKeyIdentifier) - os << *subjectKeyIdentifier; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // RecipientIdentifier::Print - -OriginatorIdentifierOrKey::OriginatorIdentifierOrKey() -{ - choiceId = issuerAndSerialNumberCid; -#if TCL - issuerAndSerialNumber = new IssuerAndSerialNumber; -#else - issuerAndSerialNumber = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -OriginatorIdentifierOrKey::OriginatorIdentifierOrKey (const OriginatorIdentifierOrKey &) -{ - Asn1Error << "use of incompletely defined OriginatorIdentifierOrKey::OriginatorIdentifierOrKey (const OriginatorIdentifierOrKey &)" << endl; - abort(); -} - -OriginatorIdentifierOrKey::~OriginatorIdentifierOrKey() -{ - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - delete subjectKeyIdentifier; - break; - case originatorKeyCid: - delete originatorKey; - break; - } // end of switch -} // end of destructor - -AsnType *OriginatorIdentifierOrKey::Clone() const -{ - return new OriginatorIdentifierOrKey; -} - -AsnType *OriginatorIdentifierOrKey::Copy() const -{ - return new OriginatorIdentifierOrKey (*this); -} - -#if SNACC_DEEP_COPY -OriginatorIdentifierOrKey &OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey &that) -#else // SNACC_DEEP_COPY -OriginatorIdentifierOrKey &OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - delete subjectKeyIdentifier; - break; - case originatorKeyCid: - delete originatorKey; - break; - } - switch (choiceId = that.choiceId) - { - case issuerAndSerialNumberCid: - issuerAndSerialNumber = new IssuerAndSerialNumber; - *issuerAndSerialNumber = *that.issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - subjectKeyIdentifier = new KeyIdentifier; - *subjectKeyIdentifier = *that.subjectKeyIdentifier; - break; - case originatorKeyCid: - originatorKey = new OriginatorPublicKey; - *originatorKey = *that.originatorKey; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined OriginatorIdentifierOrKey &OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -OriginatorIdentifierOrKey::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case issuerAndSerialNumberCid: - BEncEocIfNec (b); - l = issuerAndSerialNumber->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - case subjectKeyIdentifierCid: - l = subjectKeyIdentifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - break; - - case originatorKeyCid: - BEncEocIfNec (b); - l = originatorKey->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - break; - - } // end switch - return l; -} // OriginatorIdentifierOrKey::BEncContent - - -void OriginatorIdentifierOrKey::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = issuerAndSerialNumberCid; - issuerAndSerialNumber = new IssuerAndSerialNumber; - issuerAndSerialNumber->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 0): - case MAKE_TAG_ID (CNTX, CONS, 0): - choiceId = subjectKeyIdentifierCid; - subjectKeyIdentifier = new KeyIdentifier; - subjectKeyIdentifier->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = originatorKeyCid; - originatorKey = new OriginatorPublicKey; - originatorKey->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-125); - break; - } // end switch -} // OriginatorIdentifierOrKey::BDecContent - - -AsnLen OriginatorIdentifierOrKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void OriginatorIdentifierOrKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void OriginatorIdentifierOrKey::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case issuerAndSerialNumberCid: - os << "issuerAndSerialNumber "; - if (issuerAndSerialNumber) - os << *issuerAndSerialNumber; - else - os << "-- void3 --\n"; - break; - - case subjectKeyIdentifierCid: - os << "subjectKeyIdentifier "; - if (subjectKeyIdentifier) - os << *subjectKeyIdentifier; - else - os << "-- void3 --\n"; - break; - - case originatorKeyCid: - os << "originatorKey "; - if (originatorKey) - os << *originatorKey; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // OriginatorIdentifierOrKey::Print - -RecipientKeyIdentifier::RecipientKeyIdentifier() -{ - date = NULL; - other = NULL; -} - -RecipientKeyIdentifier::RecipientKeyIdentifier (const RecipientKeyIdentifier &) -{ - Asn1Error << "use of incompletely defined RecipientKeyIdentifier::RecipientKeyIdentifier (const RecipientKeyIdentifier &)" << endl; - abort(); -} - -RecipientKeyIdentifier::~RecipientKeyIdentifier() -{ - delete date; - delete other; -} - -AsnType *RecipientKeyIdentifier::Clone() const -{ - return new RecipientKeyIdentifier; -} - -AsnType *RecipientKeyIdentifier::Copy() const -{ - return new RecipientKeyIdentifier (*this); -} - -#if SNACC_DEEP_COPY -RecipientKeyIdentifier &RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier &that) -#else // SNACC_DEEP_COPY -RecipientKeyIdentifier &RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - subjectKeyIdentifier = that.subjectKeyIdentifier; - if (that.date) - { - if (!date) - date = new GeneralizedTime; - *date = *that.date; - } - else - { - delete date; - date = NULL; - } - if (that.other) - { - if (!other) - other = new OtherKeyAttribute; - *other = *that.other; - } - else - { - delete other; - other = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RecipientKeyIdentifier &RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -RecipientKeyIdentifier::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (other)) - { - BEncEocIfNec (b); - l = other->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (date)) - { - l = date->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - totalLen += l; - } - - l = subjectKeyIdentifier.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - return totalLen; -} // RecipientKeyIdentifier::BEncContent - - -void RecipientKeyIdentifier::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subjectKeyIdentifier.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-126); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - date = new GeneralizedTime; - date->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - other = new OtherKeyAttribute; - other->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-127); - } - else - return; -} // RecipientKeyIdentifier::BDecContent - -AsnLen RecipientKeyIdentifier::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void RecipientKeyIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "RecipientKeyIdentifier::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-128); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void RecipientKeyIdentifier::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "subjectKeyIdentifier "; - os << subjectKeyIdentifier; - os << "," << endl; - } - - if (NOT_NULL (date)) - { - os << ","<< endl; - Indent (os, indentG); - os << "date "; - os << *date; - } - else - { - Indent (os, indentG); - os << "date "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (other)) - { - os << ","<< endl; - Indent (os, indentG); - os << "other "; - os << *other; - } - else - { - Indent (os, indentG); - os << "other "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // RecipientKeyIdentifier::Print - - -KEKIdentifier::KEKIdentifier() -{ - date = NULL; - other = NULL; -} - -KEKIdentifier::KEKIdentifier (const KEKIdentifier &) -{ - Asn1Error << "use of incompletely defined KEKIdentifier::KEKIdentifier (const KEKIdentifier &)" << endl; - abort(); -} - -KEKIdentifier::~KEKIdentifier() -{ - delete date; - delete other; -} - -AsnType *KEKIdentifier::Clone() const -{ - return new KEKIdentifier; -} - -AsnType *KEKIdentifier::Copy() const -{ - return new KEKIdentifier (*this); -} - -#if SNACC_DEEP_COPY -KEKIdentifier &KEKIdentifier::operator = (const KEKIdentifier &that) -#else // SNACC_DEEP_COPY -KEKIdentifier &KEKIdentifier::operator = (const KEKIdentifier &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - keyIdentifier = that.keyIdentifier; - if (that.date) - { - if (!date) - date = new GeneralizedTime; - *date = *that.date; - } - else - { - delete date; - date = NULL; - } - if (that.other) - { - if (!other) - other = new OtherKeyAttribute; - *other = *that.other; - } - else - { - delete other; - other = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined KEKIdentifier &KEKIdentifier::operator = (const KEKIdentifier &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -KEKIdentifier::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (other)) - { - BEncEocIfNec (b); - l = other->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (date)) - { - l = date->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - totalLen += l; - } - - l = keyIdentifier.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - return totalLen; -} // KEKIdentifier::BEncContent - - -void KEKIdentifier::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - keyIdentifier.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-129); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - date = new GeneralizedTime; - date->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - other = new OtherKeyAttribute; - other->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-130); - } - else - return; -} // KEKIdentifier::BDecContent - -AsnLen KEKIdentifier::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void KEKIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "KEKIdentifier::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-131); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void KEKIdentifier::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "keyIdentifier "; - os << keyIdentifier; - os << "," << endl; - } - - if (NOT_NULL (date)) - { - os << ","<< endl; - Indent (os, indentG); - os << "date "; - os << *date; - } - else - { - Indent (os, indentG); - os << "date "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (other)) - { - os << ","<< endl; - Indent (os, indentG); - os << "other "; - os << *other; - } - else - { - Indent (os, indentG); - os << "other "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // KEKIdentifier::Print - - -ExtendedCertificateInfo::ExtendedCertificateInfo() -{ -#if TCL - certificate = new Certificate; -#else - certificate = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -ExtendedCertificateInfo::ExtendedCertificateInfo (const ExtendedCertificateInfo &) -{ - Asn1Error << "use of incompletely defined ExtendedCertificateInfo::ExtendedCertificateInfo (const ExtendedCertificateInfo &)" << endl; - abort(); -} - -ExtendedCertificateInfo::~ExtendedCertificateInfo() -{ - delete certificate; -} - -AsnType *ExtendedCertificateInfo::Clone() const -{ - return new ExtendedCertificateInfo; -} - -AsnType *ExtendedCertificateInfo::Copy() const -{ - return new ExtendedCertificateInfo (*this); -} - -#if SNACC_DEEP_COPY -ExtendedCertificateInfo &ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo &that) -#else // SNACC_DEEP_COPY -ExtendedCertificateInfo &ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.certificate) - { - if (!certificate) - certificate = new Certificate; - *certificate = *that.certificate; - } - else - { - delete certificate; - certificate = NULL; - } - attributes = that.attributes; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ExtendedCertificateInfo &ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ExtendedCertificateInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = attributes.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = certificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // ExtendedCertificateInfo::BEncContent - - -void ExtendedCertificateInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-132); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - certificate = new Certificate; - certificate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-133); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - attributes.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-134); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-135); - } - else - return; -} // ExtendedCertificateInfo::BDecContent - -AsnLen ExtendedCertificateInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ExtendedCertificateInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ExtendedCertificateInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-136); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ExtendedCertificateInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (certificate)) - { - Indent (os, indentG); - os << "certificate "; - os << *certificate; - } - else - { - Indent (os, indentG); - os << "certificate "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "attributes "; - os << attributes; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ExtendedCertificateInfo::Print - - -SignerInfo::SignerInfo() -{ -#if TCL - sid = new SignerIdentifier; -#else - sid = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - digestAlgorithm = new DigestAlgorithmIdentifier; -#else - digestAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL - signedAttrs = NULL; -#if TCL - signatureAlgorithm = new SignatureAlgorithmIdentifier; -#else - signatureAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL - unsignedAttrs = NULL; -} - -SignerInfo::SignerInfo (const SignerInfo &) -{ - Asn1Error << "use of incompletely defined SignerInfo::SignerInfo (const SignerInfo &)" << endl; - abort(); -} - -SignerInfo::~SignerInfo() -{ - delete sid; - delete digestAlgorithm; - delete signedAttrs; - delete signatureAlgorithm; - delete unsignedAttrs; -} - -AsnType *SignerInfo::Clone() const -{ - return new SignerInfo; -} - -AsnType *SignerInfo::Copy() const -{ - return new SignerInfo (*this); -} - -#if SNACC_DEEP_COPY -SignerInfo &SignerInfo::operator = (const SignerInfo &that) -#else // SNACC_DEEP_COPY -SignerInfo &SignerInfo::operator = (const SignerInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.sid) - { - if (!sid) - sid = new SignerIdentifier; - *sid = *that.sid; - } - else - { - delete sid; - sid = NULL; - } - if (that.digestAlgorithm) - { - if (!digestAlgorithm) - digestAlgorithm = new DigestAlgorithmIdentifier; - *digestAlgorithm = *that.digestAlgorithm; - } - else - { - delete digestAlgorithm; - digestAlgorithm = NULL; - } - if (that.signedAttrs) - { - if (!signedAttrs) - signedAttrs = new Attributes; - *signedAttrs = *that.signedAttrs; - } - else - { - delete signedAttrs; - signedAttrs = NULL; - } - if (that.signatureAlgorithm) - { - if (!signatureAlgorithm) - signatureAlgorithm = new SignatureAlgorithmIdentifier; - *signatureAlgorithm = *that.signatureAlgorithm; - } - else - { - delete signatureAlgorithm; - signatureAlgorithm = NULL; - } - signature = that.signature; - if (that.unsignedAttrs) - { - if (!unsignedAttrs) - unsignedAttrs = new Attributes; - *unsignedAttrs = *that.unsignedAttrs; - } - else - { - delete unsignedAttrs; - unsignedAttrs = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SignerInfo &SignerInfo::operator = (const SignerInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -SignerInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (unsignedAttrs)) - { - BEncEocIfNec (b); - l = unsignedAttrs->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - l = signature.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = signatureAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - if (NOT_NULL (signedAttrs)) - { - BEncEocIfNec (b); - l = signedAttrs->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - BEncEocIfNec (b); - l = digestAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = sid->BEncContent (b); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // SignerInfo::BEncContent - - -void SignerInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-137); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - sid = new SignerIdentifier; - sid->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-138); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - digestAlgorithm = new DigestAlgorithmIdentifier; - digestAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-139); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signedAttrs = new Attributes; - signedAttrs->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signatureAlgorithm = new SignatureAlgorithmIdentifier; - signatureAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-140); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signature.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-141); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - unsignedAttrs = new Attributes; - unsignedAttrs->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-142); - } - else - return; -} // SignerInfo::BDecContent - -AsnLen SignerInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void SignerInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "SignerInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-143); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void SignerInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (sid)) - { - Indent (os, indentG); - os << "sid "; - os << *sid; - } - else - { - Indent (os, indentG); - os << "sid "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (digestAlgorithm)) - { - Indent (os, indentG); - os << "digestAlgorithm "; - os << *digestAlgorithm; - } - else - { - Indent (os, indentG); - os << "digestAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (signedAttrs)) - { - Indent (os, indentG); - os << "signedAttrs "; - os << *signedAttrs; - } - else - { - Indent (os, indentG); - os << "signedAttrs "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (signatureAlgorithm)) - { - Indent (os, indentG); - os << "signatureAlgorithm "; - os << *signatureAlgorithm; - } - else - { - Indent (os, indentG); - os << "signatureAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signature "; - os << signature; - os << "," << endl; - } - - if (NOT_NULL (unsignedAttrs)) - { - os << ","<< endl; - Indent (os, indentG); - os << "unsignedAttrs "; - os << *unsignedAttrs; - } - else - { - Indent (os, indentG); - os << "unsignedAttrs "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // SignerInfo::Print - - -KeyTransRecipientInfo::KeyTransRecipientInfo() -{ -#if TCL - rid = new RecipientIdentifier; -#else - rid = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; -#else - keyEncryptionAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -KeyTransRecipientInfo::KeyTransRecipientInfo (const KeyTransRecipientInfo &) -{ - Asn1Error << "use of incompletely defined KeyTransRecipientInfo::KeyTransRecipientInfo (const KeyTransRecipientInfo &)" << endl; - abort(); -} - -KeyTransRecipientInfo::~KeyTransRecipientInfo() -{ - delete rid; - delete keyEncryptionAlgorithm; -} - -AsnType *KeyTransRecipientInfo::Clone() const -{ - return new KeyTransRecipientInfo; -} - -AsnType *KeyTransRecipientInfo::Copy() const -{ - return new KeyTransRecipientInfo (*this); -} - -#if SNACC_DEEP_COPY -KeyTransRecipientInfo &KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo &that) -#else // SNACC_DEEP_COPY -KeyTransRecipientInfo &KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.rid) - { - if (!rid) - rid = new RecipientIdentifier; - *rid = *that.rid; - } - else - { - delete rid; - rid = NULL; - } - if (that.keyEncryptionAlgorithm) - { - if (!keyEncryptionAlgorithm) - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; - *keyEncryptionAlgorithm = *that.keyEncryptionAlgorithm; - } - else - { - delete keyEncryptionAlgorithm; - keyEncryptionAlgorithm = NULL; - } - encryptedKey = that.encryptedKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined KeyTransRecipientInfo &KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -KeyTransRecipientInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = encryptedKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = keyEncryptionAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = rid->BEncContent (b); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // KeyTransRecipientInfo::BEncContent - - -void KeyTransRecipientInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-144); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - rid = new RecipientIdentifier; - rid->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-145); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; - keyEncryptionAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-146); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-147); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-148); - } - else - return; -} // KeyTransRecipientInfo::BDecContent - -AsnLen KeyTransRecipientInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void KeyTransRecipientInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "KeyTransRecipientInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-149); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void KeyTransRecipientInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (rid)) - { - Indent (os, indentG); - os << "rid "; - os << *rid; - } - else - { - Indent (os, indentG); - os << "rid "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (keyEncryptionAlgorithm)) - { - Indent (os, indentG); - os << "keyEncryptionAlgorithm "; - os << *keyEncryptionAlgorithm; - } - else - { - Indent (os, indentG); - os << "keyEncryptionAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "encryptedKey "; - os << encryptedKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // KeyTransRecipientInfo::Print - - -KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier() -{ - choiceId = issuerAndSerialNumberCid; -#if TCL - issuerAndSerialNumber = new IssuerAndSerialNumber; -#else - issuerAndSerialNumber = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier (const KeyAgreeRecipientIdentifier &) -{ - Asn1Error << "use of incompletely defined KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier (const KeyAgreeRecipientIdentifier &)" << endl; - abort(); -} - -KeyAgreeRecipientIdentifier::~KeyAgreeRecipientIdentifier() -{ - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case rKeyIdCid: - delete rKeyId; - break; - } // end of switch -} // end of destructor - -AsnType *KeyAgreeRecipientIdentifier::Clone() const -{ - return new KeyAgreeRecipientIdentifier; -} - -AsnType *KeyAgreeRecipientIdentifier::Copy() const -{ - return new KeyAgreeRecipientIdentifier (*this); -} - -#if SNACC_DEEP_COPY -KeyAgreeRecipientIdentifier &KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier &that) -#else // SNACC_DEEP_COPY -KeyAgreeRecipientIdentifier &KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case rKeyIdCid: - delete rKeyId; - break; - } - switch (choiceId = that.choiceId) - { - case issuerAndSerialNumberCid: - issuerAndSerialNumber = new IssuerAndSerialNumber; - *issuerAndSerialNumber = *that.issuerAndSerialNumber; - break; - case rKeyIdCid: - rKeyId = new RecipientKeyIdentifier; - *rKeyId = *that.rKeyId; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined KeyAgreeRecipientIdentifier &KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -KeyAgreeRecipientIdentifier::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case issuerAndSerialNumberCid: - BEncEocIfNec (b); - l = issuerAndSerialNumber->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - case rKeyIdCid: - BEncEocIfNec (b); - l = rKeyId->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - break; - - } // end switch - return l; -} // KeyAgreeRecipientIdentifier::BEncContent - - -void KeyAgreeRecipientIdentifier::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = issuerAndSerialNumberCid; - issuerAndSerialNumber = new IssuerAndSerialNumber; - issuerAndSerialNumber->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 0): - choiceId = rKeyIdCid; - rKeyId = new RecipientKeyIdentifier; - rKeyId->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-150); - break; - } // end switch -} // KeyAgreeRecipientIdentifier::BDecContent - - -AsnLen KeyAgreeRecipientIdentifier::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void KeyAgreeRecipientIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void KeyAgreeRecipientIdentifier::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case issuerAndSerialNumberCid: - os << "issuerAndSerialNumber "; - if (issuerAndSerialNumber) - os << *issuerAndSerialNumber; - else - os << "-- void3 --\n"; - break; - - case rKeyIdCid: - os << "rKeyId "; - if (rKeyId) - os << *rKeyId; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // KeyAgreeRecipientIdentifier::Print - -KEKRecipientInfo::KEKRecipientInfo() -{ -#if TCL - kekid = new KEKIdentifier; -#else - kekid = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; -#else - keyEncryptionAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -KEKRecipientInfo::KEKRecipientInfo (const KEKRecipientInfo &) -{ - Asn1Error << "use of incompletely defined KEKRecipientInfo::KEKRecipientInfo (const KEKRecipientInfo &)" << endl; - abort(); -} - -KEKRecipientInfo::~KEKRecipientInfo() -{ - delete kekid; - delete keyEncryptionAlgorithm; -} - -AsnType *KEKRecipientInfo::Clone() const -{ - return new KEKRecipientInfo; -} - -AsnType *KEKRecipientInfo::Copy() const -{ - return new KEKRecipientInfo (*this); -} - -#if SNACC_DEEP_COPY -KEKRecipientInfo &KEKRecipientInfo::operator = (const KEKRecipientInfo &that) -#else // SNACC_DEEP_COPY -KEKRecipientInfo &KEKRecipientInfo::operator = (const KEKRecipientInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.kekid) - { - if (!kekid) - kekid = new KEKIdentifier; - *kekid = *that.kekid; - } - else - { - delete kekid; - kekid = NULL; - } - if (that.keyEncryptionAlgorithm) - { - if (!keyEncryptionAlgorithm) - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; - *keyEncryptionAlgorithm = *that.keyEncryptionAlgorithm; - } - else - { - delete keyEncryptionAlgorithm; - keyEncryptionAlgorithm = NULL; - } - encryptedKey = that.encryptedKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined KEKRecipientInfo &KEKRecipientInfo::operator = (const KEKRecipientInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -KEKRecipientInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = encryptedKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = keyEncryptionAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = kekid->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // KEKRecipientInfo::BEncContent - - -void KEKRecipientInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-151); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - kekid = new KEKIdentifier; - kekid->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-152); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; - keyEncryptionAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-153); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-154); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-155); - } - else - return; -} // KEKRecipientInfo::BDecContent - -AsnLen KEKRecipientInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void KEKRecipientInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "KEKRecipientInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-156); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void KEKRecipientInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (kekid)) - { - Indent (os, indentG); - os << "kekid "; - os << *kekid; - } - else - { - Indent (os, indentG); - os << "kekid "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (keyEncryptionAlgorithm)) - { - Indent (os, indentG); - os << "keyEncryptionAlgorithm "; - os << *keyEncryptionAlgorithm; - } - else - { - Indent (os, indentG); - os << "keyEncryptionAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "encryptedKey "; - os << encryptedKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // KEKRecipientInfo::Print - - -ExtendedCertificate::ExtendedCertificate() -{ -#if TCL - extendedCertificateInfo = new ExtendedCertificateInfo; -#else - extendedCertificateInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - signatureAlgorithm = new SignatureAlgorithmIdentifier; -#else - signatureAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -ExtendedCertificate::ExtendedCertificate (const ExtendedCertificate &) -{ - Asn1Error << "use of incompletely defined ExtendedCertificate::ExtendedCertificate (const ExtendedCertificate &)" << endl; - abort(); -} - -ExtendedCertificate::~ExtendedCertificate() -{ - delete extendedCertificateInfo; - delete signatureAlgorithm; -} - -AsnType *ExtendedCertificate::Clone() const -{ - return new ExtendedCertificate; -} - -AsnType *ExtendedCertificate::Copy() const -{ - return new ExtendedCertificate (*this); -} - -#if SNACC_DEEP_COPY -ExtendedCertificate &ExtendedCertificate::operator = (const ExtendedCertificate &that) -#else // SNACC_DEEP_COPY -ExtendedCertificate &ExtendedCertificate::operator = (const ExtendedCertificate &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.extendedCertificateInfo) - { - if (!extendedCertificateInfo) - extendedCertificateInfo = new ExtendedCertificateInfo; - *extendedCertificateInfo = *that.extendedCertificateInfo; - } - else - { - delete extendedCertificateInfo; - extendedCertificateInfo = NULL; - } - if (that.signatureAlgorithm) - { - if (!signatureAlgorithm) - signatureAlgorithm = new SignatureAlgorithmIdentifier; - *signatureAlgorithm = *that.signatureAlgorithm; - } - else - { - delete signatureAlgorithm; - signatureAlgorithm = NULL; - } - signature = that.signature; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ExtendedCertificate &ExtendedCertificate::operator = (const ExtendedCertificate &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ExtendedCertificate::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = signature.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = signatureAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = extendedCertificateInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // ExtendedCertificate::BEncContent - - -void ExtendedCertificate::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - extendedCertificateInfo = new ExtendedCertificateInfo; - extendedCertificateInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-157); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signatureAlgorithm = new SignatureAlgorithmIdentifier; - signatureAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-158); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signature.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-159); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-160); - } - else - return; -} // ExtendedCertificate::BDecContent - -AsnLen ExtendedCertificate::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ExtendedCertificate::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ExtendedCertificate::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-161); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ExtendedCertificate::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (extendedCertificateInfo)) - { - Indent (os, indentG); - os << "extendedCertificateInfo "; - os << *extendedCertificateInfo; - } - else - { - Indent (os, indentG); - os << "extendedCertificateInfo "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (signatureAlgorithm)) - { - Indent (os, indentG); - os << "signatureAlgorithm "; - os << *signatureAlgorithm; - } - else - { - Indent (os, indentG); - os << "signatureAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signature "; - os << signature; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ExtendedCertificate::Print - - -AsnType *SignerInfos::Clone() const -{ - return new SignerInfos; -} - -AsnType *SignerInfos::Copy() const -{ - return new SignerInfos (*this); -} - -AsnLen SignerInfos::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void SignerInfos::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "SignerInfos::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-162); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -SignerInfos::SignerInfos (const SignerInfos &) -{ - Asn1Error << "use of incompletely defined SignerInfos::SignerInfos (const SignerInfos &)" << endl; - abort(); -} - -SignerInfos::~SignerInfos() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -SignerInfos &SignerInfos::operator = (const SignerInfos &that) -#else // SNACC_DEEP_COPY -SignerInfos &SignerInfos::operator = (const SignerInfos &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SignerInfos &SignerInfos::operator = (const SignerInfos &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void SignerInfos::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void SignerInfos::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // SignerInfos::SetCurrElmt - - -unsigned long int SignerInfos::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // SignerInfos::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -SignerInfo *SignerInfos::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SignerInfo; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SignerInfos::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -SignerInfo *SignerInfos::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SignerInfo; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SignerInfos::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -SignerInfo *SignerInfos::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SignerInfo; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SignerInfos::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -SignerInfo *SignerInfos::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SignerInfo; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SignerInfos::InsertAfter - - -SignerInfos &SignerInfos::AppendCopy (SignerInfo &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SignerInfo; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -SignerInfos &SignerInfos::PrependCopy (SignerInfo &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SignerInfo; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // SignerInfos::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -SignerInfos &SignerInfos::InsertBeforeAndCopy (SignerInfo &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new SignerInfo; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // SignerInfos::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -SignerInfos &SignerInfos::InsertAfterAndCopy (SignerInfo &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new SignerInfo; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // SignerInfos::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void SignerInfos::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen SignerInfos::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // SignerInfos::BEncContent - - -void SignerInfos::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - SignerInfo *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-163); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // SignerInfos::BDecContent - - -RecipientEncryptedKey::RecipientEncryptedKey() -{ -#if TCL - rid = new KeyAgreeRecipientIdentifier; -#else - rid = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -RecipientEncryptedKey::RecipientEncryptedKey (const RecipientEncryptedKey &) -{ - Asn1Error << "use of incompletely defined RecipientEncryptedKey::RecipientEncryptedKey (const RecipientEncryptedKey &)" << endl; - abort(); -} - -RecipientEncryptedKey::~RecipientEncryptedKey() -{ - delete rid; -} - -AsnType *RecipientEncryptedKey::Clone() const -{ - return new RecipientEncryptedKey; -} - -AsnType *RecipientEncryptedKey::Copy() const -{ - return new RecipientEncryptedKey (*this); -} - -#if SNACC_DEEP_COPY -RecipientEncryptedKey &RecipientEncryptedKey::operator = (const RecipientEncryptedKey &that) -#else // SNACC_DEEP_COPY -RecipientEncryptedKey &RecipientEncryptedKey::operator = (const RecipientEncryptedKey &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.rid) - { - if (!rid) - rid = new KeyAgreeRecipientIdentifier; - *rid = *that.rid; - } - else - { - delete rid; - rid = NULL; - } - encryptedKey = that.encryptedKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RecipientEncryptedKey &RecipientEncryptedKey::operator = (const RecipientEncryptedKey &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -RecipientEncryptedKey::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = encryptedKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - l = rid->BEncContent (b); - totalLen += l; - - return totalLen; -} // RecipientEncryptedKey::BEncContent - - -void RecipientEncryptedKey::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - rid = new KeyAgreeRecipientIdentifier; - rid->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-164); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-165); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-166); - } - else - return; -} // RecipientEncryptedKey::BDecContent - -AsnLen RecipientEncryptedKey::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void RecipientEncryptedKey::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "RecipientEncryptedKey::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-167); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void RecipientEncryptedKey::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (rid)) - { - Indent (os, indentG); - os << "rid "; - os << *rid; - } - else - { - Indent (os, indentG); - os << "rid "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "encryptedKey "; - os << encryptedKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // RecipientEncryptedKey::Print - - -CertificateChoices::CertificateChoices() -{ - choiceId = certificateCid; -#if TCL - certificate = new Certificate; -#else - certificate = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -CertificateChoices::CertificateChoices (const CertificateChoices &) -{ - Asn1Error << "use of incompletely defined CertificateChoices::CertificateChoices (const CertificateChoices &)" << endl; - abort(); -} - -CertificateChoices::~CertificateChoices() -{ - switch (choiceId) - { - case certificateCid: - delete certificate; - break; - case extendedCertificateCid: - delete extendedCertificate; - break; - case attrCertCid: - delete attrCert; - break; - } // end of switch -} // end of destructor - -AsnType *CertificateChoices::Clone() const -{ - return new CertificateChoices; -} - -AsnType *CertificateChoices::Copy() const -{ - return new CertificateChoices (*this); -} - -#if SNACC_DEEP_COPY -CertificateChoices &CertificateChoices::operator = (const CertificateChoices &that) -#else // SNACC_DEEP_COPY -CertificateChoices &CertificateChoices::operator = (const CertificateChoices &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case certificateCid: - delete certificate; - break; - case extendedCertificateCid: - delete extendedCertificate; - break; - case attrCertCid: - delete attrCert; - break; - } - switch (choiceId = that.choiceId) - { - case certificateCid: - certificate = new Certificate; - *certificate = *that.certificate; - break; - case extendedCertificateCid: - extendedCertificate = new ExtendedCertificate; - *extendedCertificate = *that.extendedCertificate; - break; - case attrCertCid: - attrCert = new AttributeCertificate; - *attrCert = *that.attrCert; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificateChoices &CertificateChoices::operator = (const CertificateChoices &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CertificateChoices::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case certificateCid: - BEncEocIfNec (b); - l = certificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - case extendedCertificateCid: - BEncEocIfNec (b); - l = extendedCertificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - break; - - case attrCertCid: - BEncEocIfNec (b); - l = attrCert->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - break; - - } // end switch - return l; -} // CertificateChoices::BEncContent - - -void CertificateChoices::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = certificateCid; - certificate = new Certificate; - certificate->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 0): - choiceId = extendedCertificateCid; - extendedCertificate = new ExtendedCertificate; - extendedCertificate->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = attrCertCid; - attrCert = new AttributeCertificate; - attrCert->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-168); - break; - } // end switch -} // CertificateChoices::BDecContent - - -AsnLen CertificateChoices::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void CertificateChoices::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void CertificateChoices::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case certificateCid: - os << "certificate "; - if (certificate) - os << *certificate; - else - os << "-- void3 --\n"; - break; - - case extendedCertificateCid: - os << "extendedCertificate "; - if (extendedCertificate) - os << *extendedCertificate; - else - os << "-- void3 --\n"; - break; - - case attrCertCid: - os << "attrCert "; - if (attrCert) - os << *attrCert; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // CertificateChoices::Print - -AsnType *CertificateSet::Clone() const -{ - return new CertificateSet; -} - -AsnType *CertificateSet::Copy() const -{ - return new CertificateSet (*this); -} - -AsnLen CertificateSet::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void CertificateSet::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "CertificateSet::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-169); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -CertificateSet::CertificateSet (const CertificateSet &) -{ - Asn1Error << "use of incompletely defined CertificateSet::CertificateSet (const CertificateSet &)" << endl; - abort(); -} - -CertificateSet::~CertificateSet() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -CertificateSet &CertificateSet::operator = (const CertificateSet &that) -#else // SNACC_DEEP_COPY -CertificateSet &CertificateSet::operator = (const CertificateSet &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificateSet &CertificateSet::operator = (const CertificateSet &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void CertificateSet::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void CertificateSet::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // CertificateSet::SetCurrElmt - - -unsigned long int CertificateSet::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // CertificateSet::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -CertificateChoices *CertificateSet::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateChoices; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificateSet::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -CertificateChoices *CertificateSet::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateChoices; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificateSet::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -CertificateChoices *CertificateSet::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateChoices; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificateSet::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertificateChoices *CertificateSet::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateChoices; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificateSet::InsertAfter - - -CertificateSet &CertificateSet::AppendCopy (CertificateChoices &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateChoices; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -CertificateSet &CertificateSet::PrependCopy (CertificateChoices &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateChoices; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // CertificateSet::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -CertificateSet &CertificateSet::InsertBeforeAndCopy (CertificateChoices &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateChoices; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // CertificateSet::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertificateSet &CertificateSet::InsertAfterAndCopy (CertificateChoices &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CertificateChoices; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // CertificateSet::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void CertificateSet::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen CertificateSet::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // CertificateSet::BEncContent - - -void CertificateSet::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - CertificateChoices *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if (!((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-170); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // CertificateSet::BDecContent - - -OriginatorInfo::OriginatorInfo() -{ - certs = NULL; - crls = NULL; -} - -OriginatorInfo::OriginatorInfo (const OriginatorInfo &) -{ - Asn1Error << "use of incompletely defined OriginatorInfo::OriginatorInfo (const OriginatorInfo &)" << endl; - abort(); -} - -OriginatorInfo::~OriginatorInfo() -{ - delete certs; - delete crls; -} - -AsnType *OriginatorInfo::Clone() const -{ - return new OriginatorInfo; -} - -AsnType *OriginatorInfo::Copy() const -{ - return new OriginatorInfo (*this); -} - -#if SNACC_DEEP_COPY -OriginatorInfo &OriginatorInfo::operator = (const OriginatorInfo &that) -#else // SNACC_DEEP_COPY -OriginatorInfo &OriginatorInfo::operator = (const OriginatorInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.certs) - { - if (!certs) - certs = new CertificateSet; - *certs = *that.certs; - } - else - { - delete certs; - certs = NULL; - } - if (that.crls) - { - if (!crls) - crls = new CertificateRevocationLists; - *crls = *that.crls; - } - else - { - delete crls; - crls = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined OriginatorInfo &OriginatorInfo::operator = (const OriginatorInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -OriginatorInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (crls)) - { - BEncEocIfNec (b); - l = crls->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - if (NOT_NULL (certs)) - { - BEncEocIfNec (b); - l = certs->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // OriginatorInfo::BEncContent - - -void OriginatorInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - certs = new CertificateSet; - certs->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - crls = new CertificateRevocationLists; - crls->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-171); - } - else - return; -} // OriginatorInfo::BDecContent - -AsnLen OriginatorInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void OriginatorInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "OriginatorInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-172); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void OriginatorInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (certs)) - { - nonePrinted = false; - Indent (os, indentG); - os << "certs "; - os << *certs; - } - else - { - Indent (os, indentG); - os << "certs "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (crls)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "crls "; - os << *crls; - } - else - { - Indent (os, indentG); - os << "crls "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // OriginatorInfo::Print - - -AsnType *RecipientEncryptedKeys::Clone() const -{ - return new RecipientEncryptedKeys; -} - -AsnType *RecipientEncryptedKeys::Copy() const -{ - return new RecipientEncryptedKeys (*this); -} - -AsnLen RecipientEncryptedKeys::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void RecipientEncryptedKeys::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "RecipientEncryptedKeys::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-173); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -RecipientEncryptedKeys::RecipientEncryptedKeys (const RecipientEncryptedKeys &) -{ - Asn1Error << "use of incompletely defined RecipientEncryptedKeys::RecipientEncryptedKeys (const RecipientEncryptedKeys &)" << endl; - abort(); -} - -RecipientEncryptedKeys::~RecipientEncryptedKeys() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -RecipientEncryptedKeys &RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys &that) -#else // SNACC_DEEP_COPY -RecipientEncryptedKeys &RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RecipientEncryptedKeys &RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void RecipientEncryptedKeys::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void RecipientEncryptedKeys::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // RecipientEncryptedKeys::SetCurrElmt - - -unsigned long int RecipientEncryptedKeys::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // RecipientEncryptedKeys::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -RecipientEncryptedKey *RecipientEncryptedKeys::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientEncryptedKey; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RecipientEncryptedKeys::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -RecipientEncryptedKey *RecipientEncryptedKeys::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientEncryptedKey; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RecipientEncryptedKeys::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -RecipientEncryptedKey *RecipientEncryptedKeys::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientEncryptedKey; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RecipientEncryptedKeys::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -RecipientEncryptedKey *RecipientEncryptedKeys::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientEncryptedKey; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RecipientEncryptedKeys::InsertAfter - - -RecipientEncryptedKeys &RecipientEncryptedKeys::AppendCopy (RecipientEncryptedKey &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientEncryptedKey; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -RecipientEncryptedKeys &RecipientEncryptedKeys::PrependCopy (RecipientEncryptedKey &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientEncryptedKey; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // RecipientEncryptedKeys::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -RecipientEncryptedKeys &RecipientEncryptedKeys::InsertBeforeAndCopy (RecipientEncryptedKey &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientEncryptedKey; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // RecipientEncryptedKeys::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -RecipientEncryptedKeys &RecipientEncryptedKeys::InsertAfterAndCopy (RecipientEncryptedKey &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientEncryptedKey; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // RecipientEncryptedKeys::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void RecipientEncryptedKeys::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen RecipientEncryptedKeys::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // RecipientEncryptedKeys::BEncContent - - -void RecipientEncryptedKeys::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - RecipientEncryptedKey *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-174); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // RecipientEncryptedKeys::BDecContent - - -KeyAgreeRecipientInfo::KeyAgreeRecipientInfo() -{ -#if TCL - originator = new OriginatorIdentifierOrKey; -#else - originator = NULL; // incomplete initialization of mandatory element! -#endif // TCL - ukm = NULL; -#if TCL - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; -#else - keyEncryptionAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -KeyAgreeRecipientInfo::KeyAgreeRecipientInfo (const KeyAgreeRecipientInfo &) -{ - Asn1Error << "use of incompletely defined KeyAgreeRecipientInfo::KeyAgreeRecipientInfo (const KeyAgreeRecipientInfo &)" << endl; - abort(); -} - -KeyAgreeRecipientInfo::~KeyAgreeRecipientInfo() -{ - delete originator; - delete ukm; - delete keyEncryptionAlgorithm; -} - -AsnType *KeyAgreeRecipientInfo::Clone() const -{ - return new KeyAgreeRecipientInfo; -} - -AsnType *KeyAgreeRecipientInfo::Copy() const -{ - return new KeyAgreeRecipientInfo (*this); -} - -#if SNACC_DEEP_COPY -KeyAgreeRecipientInfo &KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo &that) -#else // SNACC_DEEP_COPY -KeyAgreeRecipientInfo &KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.originator) - { - if (!originator) - originator = new OriginatorIdentifierOrKey; - *originator = *that.originator; - } - else - { - delete originator; - originator = NULL; - } - if (that.ukm) - { - if (!ukm) - ukm = new UserKeyingMaterial; - *ukm = *that.ukm; - } - else - { - delete ukm; - ukm = NULL; - } - if (that.keyEncryptionAlgorithm) - { - if (!keyEncryptionAlgorithm) - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; - *keyEncryptionAlgorithm = *that.keyEncryptionAlgorithm; - } - else - { - delete keyEncryptionAlgorithm; - keyEncryptionAlgorithm = NULL; - } - recipientEncryptedKeys = that.recipientEncryptedKeys; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined KeyAgreeRecipientInfo &KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -KeyAgreeRecipientInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = recipientEncryptedKeys.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = keyEncryptionAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - if (NOT_NULL (ukm)) - { - BEncEocIfNec (b); - l = ukm->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - BEncEocIfNec (b); - l = originator->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // KeyAgreeRecipientInfo::BEncContent - - -void KeyAgreeRecipientInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-175); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - originator = new OriginatorIdentifierOrKey; - originator->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-176); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - && (tag1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-177); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - ukm = new UserKeyingMaterial; - ukm->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier; - keyEncryptionAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-178); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - recipientEncryptedKeys.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-179); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-180); - } - else - return; -} // KeyAgreeRecipientInfo::BDecContent - -AsnLen KeyAgreeRecipientInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void KeyAgreeRecipientInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "KeyAgreeRecipientInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-181); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void KeyAgreeRecipientInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (originator)) - { - Indent (os, indentG); - os << "originator "; - os << *originator; - } - else - { - Indent (os, indentG); - os << "originator "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (ukm)) - { - Indent (os, indentG); - os << "ukm "; - os << *ukm; - } - else - { - Indent (os, indentG); - os << "ukm "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (keyEncryptionAlgorithm)) - { - Indent (os, indentG); - os << "keyEncryptionAlgorithm "; - os << *keyEncryptionAlgorithm; - } - else - { - Indent (os, indentG); - os << "keyEncryptionAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "recipientEncryptedKeys "; - os << recipientEncryptedKeys; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // KeyAgreeRecipientInfo::Print - - -RecipientInfo::RecipientInfo() -{ - choiceId = ktriCid; -#if TCL - ktri = new KeyTransRecipientInfo; -#else - ktri = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -RecipientInfo::RecipientInfo (const RecipientInfo &) -{ - Asn1Error << "use of incompletely defined RecipientInfo::RecipientInfo (const RecipientInfo &)" << endl; - abort(); -} - -RecipientInfo::~RecipientInfo() -{ - switch (choiceId) - { - case ktriCid: - delete ktri; - break; - case kariCid: - delete kari; - break; - case kekriCid: - delete kekri; - break; - } // end of switch -} // end of destructor - -AsnType *RecipientInfo::Clone() const -{ - return new RecipientInfo; -} - -AsnType *RecipientInfo::Copy() const -{ - return new RecipientInfo (*this); -} - -#if SNACC_DEEP_COPY -RecipientInfo &RecipientInfo::operator = (const RecipientInfo &that) -#else // SNACC_DEEP_COPY -RecipientInfo &RecipientInfo::operator = (const RecipientInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case ktriCid: - delete ktri; - break; - case kariCid: - delete kari; - break; - case kekriCid: - delete kekri; - break; - } - switch (choiceId = that.choiceId) - { - case ktriCid: - ktri = new KeyTransRecipientInfo; - *ktri = *that.ktri; - break; - case kariCid: - kari = new KeyAgreeRecipientInfo; - *kari = *that.kari; - break; - case kekriCid: - kekri = new KEKRecipientInfo; - *kekri = *that.kekri; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RecipientInfo &RecipientInfo::operator = (const RecipientInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -RecipientInfo::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case ktriCid: - BEncEocIfNec (b); - l = ktri->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - case kariCid: - BEncEocIfNec (b); - l = kari->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - break; - - case kekriCid: - BEncEocIfNec (b); - l = kekri->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 2); - break; - - } // end switch - return l; -} // RecipientInfo::BEncContent - - -void RecipientInfo::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = ktriCid; - ktri = new KeyTransRecipientInfo; - ktri->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = kariCid; - kari = new KeyAgreeRecipientInfo; - kari->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 2): - choiceId = kekriCid; - kekri = new KEKRecipientInfo; - kekri->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-182); - break; - } // end switch -} // RecipientInfo::BDecContent - - -AsnLen RecipientInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void RecipientInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void RecipientInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case ktriCid: - os << "ktri "; - if (ktri) - os << *ktri; - else - os << "-- void3 --\n"; - break; - - case kariCid: - os << "kari "; - if (kari) - os << *kari; - else - os << "-- void3 --\n"; - break; - - case kekriCid: - os << "kekri "; - if (kekri) - os << *kekri; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // RecipientInfo::Print - -AsnType *RecipientInfos::Clone() const -{ - return new RecipientInfos; -} - -AsnType *RecipientInfos::Copy() const -{ - return new RecipientInfos (*this); -} - -AsnLen RecipientInfos::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void RecipientInfos::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "RecipientInfos::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-183); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -RecipientInfos::RecipientInfos (const RecipientInfos &) -{ - Asn1Error << "use of incompletely defined RecipientInfos::RecipientInfos (const RecipientInfos &)" << endl; - abort(); -} - -RecipientInfos::~RecipientInfos() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -RecipientInfos &RecipientInfos::operator = (const RecipientInfos &that) -#else // SNACC_DEEP_COPY -RecipientInfos &RecipientInfos::operator = (const RecipientInfos &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RecipientInfos &RecipientInfos::operator = (const RecipientInfos &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void RecipientInfos::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void RecipientInfos::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // RecipientInfos::SetCurrElmt - - -unsigned long int RecipientInfos::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // RecipientInfos::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -RecipientInfo *RecipientInfos::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientInfo; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RecipientInfos::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -RecipientInfo *RecipientInfos::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientInfo; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RecipientInfos::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -RecipientInfo *RecipientInfos::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientInfo; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RecipientInfos::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -RecipientInfo *RecipientInfos::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientInfo; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RecipientInfos::InsertAfter - - -RecipientInfos &RecipientInfos::AppendCopy (RecipientInfo &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientInfo; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -RecipientInfos &RecipientInfos::PrependCopy (RecipientInfo &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientInfo; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // RecipientInfos::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -RecipientInfos &RecipientInfos::InsertBeforeAndCopy (RecipientInfo &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientInfo; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // RecipientInfos::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -RecipientInfos &RecipientInfos::InsertAfterAndCopy (RecipientInfo &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new RecipientInfo; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // RecipientInfos::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void RecipientInfos::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen RecipientInfos::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // RecipientInfos::BEncContent - - -void RecipientInfos::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - RecipientInfo *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if (!((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2)))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-184); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // RecipientInfos::BDecContent - - -ContentInfo::ContentInfo() -{ -} - -ContentInfo::ContentInfo (const ContentInfo &) -{ - Asn1Error << "use of incompletely defined ContentInfo::ContentInfo (const ContentInfo &)" << endl; - abort(); -} - -ContentInfo::~ContentInfo() -{ -} - -AsnType *ContentInfo::Clone() const -{ - return new ContentInfo; -} - -AsnType *ContentInfo::Copy() const -{ - return new ContentInfo (*this); -} - -#if SNACC_DEEP_COPY -ContentInfo &ContentInfo::operator = (const ContentInfo &that) -#else // SNACC_DEEP_COPY -ContentInfo &ContentInfo::operator = (const ContentInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - contentType = that.contentType; - content = that.content; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ContentInfo &ContentInfo::operator = (const ContentInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ContentInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - ENC_LOAD_ANYBUF(&content, b, l); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - - l = contentType.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // ContentInfo::BEncContent - - -void ContentInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-185); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - DEC_LOAD_ANYBUF(&content, b, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-186); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-187); - } - else - return; -} // ContentInfo::BDecContent - -AsnLen ContentInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ContentInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ContentInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-188); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ContentInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "contentType "; - os << contentType; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "content "; - os << content; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ContentInfo::Print - - -SignedData::SignedData() -{ -#if TCL - encapContentInfo = new EncapsulatedContentInfo; -#else - encapContentInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL - certificates = NULL; - crls = NULL; -} - -SignedData::SignedData (const SignedData &) -{ - Asn1Error << "use of incompletely defined SignedData::SignedData (const SignedData &)" << endl; - abort(); -} - -SignedData::~SignedData() -{ - delete encapContentInfo; - delete certificates; - delete crls; -} - -AsnType *SignedData::Clone() const -{ - return new SignedData; -} - -AsnType *SignedData::Copy() const -{ - return new SignedData (*this); -} - -#if SNACC_DEEP_COPY -SignedData &SignedData::operator = (const SignedData &that) -#else // SNACC_DEEP_COPY -SignedData &SignedData::operator = (const SignedData &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - digestAlgorithms = that.digestAlgorithms; - if (that.encapContentInfo) - { - if (!encapContentInfo) - encapContentInfo = new EncapsulatedContentInfo; - *encapContentInfo = *that.encapContentInfo; - } - else - { - delete encapContentInfo; - encapContentInfo = NULL; - } - if (that.certificates) - { - if (!certificates) - certificates = new CertificateSet; - *certificates = *that.certificates; - } - else - { - delete certificates; - certificates = NULL; - } - if (that.crls) - { - if (!crls) - crls = new CertificateRevocationLists; - *crls = *that.crls; - } - else - { - delete crls; - crls = NULL; - } - signerInfos = that.signerInfos; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SignedData &SignedData::operator = (const SignedData &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -SignedData::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = signerInfos.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - - if (NOT_NULL (crls)) - { - BEncEocIfNec (b); - l = crls->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - if (NOT_NULL (certificates)) - { - BEncEocIfNec (b); - l = certificates->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - BEncEocIfNec (b); - l = encapContentInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = digestAlgorithms.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // SignedData::BEncContent - - -void SignedData::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-189); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - digestAlgorithms.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-190); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encapContentInfo = new EncapsulatedContentInfo; - encapContentInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-191); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - certificates = new CertificateSet; - certificates->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - crls = new CertificateRevocationLists; - crls->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signerInfos.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-192); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-193); - } - else - return; -} // SignedData::BDecContent - -AsnLen SignedData::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void SignedData::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "SignedData::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-194); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void SignedData::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "digestAlgorithms "; - os << digestAlgorithms; - os << "," << endl; - } - - if (NOT_NULL (encapContentInfo)) - { - Indent (os, indentG); - os << "encapContentInfo "; - os << *encapContentInfo; - } - else - { - Indent (os, indentG); - os << "encapContentInfo "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (certificates)) - { - Indent (os, indentG); - os << "certificates "; - os << *certificates; - } - else - { - Indent (os, indentG); - os << "certificates "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (crls)) - { - Indent (os, indentG); - os << "crls "; - os << *crls; - } - else - { - Indent (os, indentG); - os << "crls "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signerInfos "; - os << signerInfos; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // SignedData::Print - - -EnvelopedData::EnvelopedData() -{ - originatorInfo = NULL; -#if TCL - encryptedContentInfo = new EncryptedContentInfo; -#else - encryptedContentInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL - unprotectedAttrs = NULL; -} - -EnvelopedData::EnvelopedData (const EnvelopedData &) -{ - Asn1Error << "use of incompletely defined EnvelopedData::EnvelopedData (const EnvelopedData &)" << endl; - abort(); -} - -EnvelopedData::~EnvelopedData() -{ - delete originatorInfo; - delete encryptedContentInfo; - delete unprotectedAttrs; -} - -AsnType *EnvelopedData::Clone() const -{ - return new EnvelopedData; -} - -AsnType *EnvelopedData::Copy() const -{ - return new EnvelopedData (*this); -} - -#if SNACC_DEEP_COPY -EnvelopedData &EnvelopedData::operator = (const EnvelopedData &that) -#else // SNACC_DEEP_COPY -EnvelopedData &EnvelopedData::operator = (const EnvelopedData &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.originatorInfo) - { - if (!originatorInfo) - originatorInfo = new OriginatorInfo; - *originatorInfo = *that.originatorInfo; - } - else - { - delete originatorInfo; - originatorInfo = NULL; - } - recipientInfos = that.recipientInfos; - if (that.encryptedContentInfo) - { - if (!encryptedContentInfo) - encryptedContentInfo = new EncryptedContentInfo; - *encryptedContentInfo = *that.encryptedContentInfo; - } - else - { - delete encryptedContentInfo; - encryptedContentInfo = NULL; - } - if (that.unprotectedAttrs) - { - if (!unprotectedAttrs) - unprotectedAttrs = new Attributes; - *unprotectedAttrs = *that.unprotectedAttrs; - } - else - { - delete unprotectedAttrs; - unprotectedAttrs = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EnvelopedData &EnvelopedData::operator = (const EnvelopedData &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EnvelopedData::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (unprotectedAttrs)) - { - BEncEocIfNec (b); - l = unprotectedAttrs->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - BEncEocIfNec (b); - l = encryptedContentInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = recipientInfos.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - - if (NOT_NULL (originatorInfo)) - { - BEncEocIfNec (b); - l = originatorInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // EnvelopedData::BEncContent - - -void EnvelopedData::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-195); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - originatorInfo = new OriginatorInfo; - originatorInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - recipientInfos.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-196); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedContentInfo = new EncryptedContentInfo; - encryptedContentInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-197); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - unprotectedAttrs = new Attributes; - unprotectedAttrs->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-198); - } - else - return; -} // EnvelopedData::BDecContent - -AsnLen EnvelopedData::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EnvelopedData::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EnvelopedData::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-199); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EnvelopedData::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (originatorInfo)) - { - Indent (os, indentG); - os << "originatorInfo "; - os << *originatorInfo; - } - else - { - Indent (os, indentG); - os << "originatorInfo "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "recipientInfos "; - os << recipientInfos; - os << "," << endl; - } - - if (NOT_NULL (encryptedContentInfo)) - { - Indent (os, indentG); - os << "encryptedContentInfo "; - os << *encryptedContentInfo; - } - else - { - Indent (os, indentG); - os << "encryptedContentInfo "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (unprotectedAttrs)) - { - os << ","<< endl; - Indent (os, indentG); - os << "unprotectedAttrs "; - os << *unprotectedAttrs; - } - else - { - Indent (os, indentG); - os << "unprotectedAttrs "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EnvelopedData::Print - - -DigestedData::DigestedData() -{ -#if TCL - digestAlgorithm = new DigestAlgorithmIdentifier; -#else - digestAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - encapContentInfo = new EncapsulatedContentInfo; -#else - encapContentInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DigestedData::DigestedData (const DigestedData &) -{ - Asn1Error << "use of incompletely defined DigestedData::DigestedData (const DigestedData &)" << endl; - abort(); -} - -DigestedData::~DigestedData() -{ - delete digestAlgorithm; - delete encapContentInfo; -} - -AsnType *DigestedData::Clone() const -{ - return new DigestedData; -} - -AsnType *DigestedData::Copy() const -{ - return new DigestedData (*this); -} - -#if SNACC_DEEP_COPY -DigestedData &DigestedData::operator = (const DigestedData &that) -#else // SNACC_DEEP_COPY -DigestedData &DigestedData::operator = (const DigestedData &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.digestAlgorithm) - { - if (!digestAlgorithm) - digestAlgorithm = new DigestAlgorithmIdentifier; - *digestAlgorithm = *that.digestAlgorithm; - } - else - { - delete digestAlgorithm; - digestAlgorithm = NULL; - } - if (that.encapContentInfo) - { - if (!encapContentInfo) - encapContentInfo = new EncapsulatedContentInfo; - *encapContentInfo = *that.encapContentInfo; - } - else - { - delete encapContentInfo; - encapContentInfo = NULL; - } - digest = that.digest; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DigestedData &DigestedData::operator = (const DigestedData &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DigestedData::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = digest.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = encapContentInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = digestAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // DigestedData::BEncContent - - -void DigestedData::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-200); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - digestAlgorithm = new DigestAlgorithmIdentifier; - digestAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-201); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encapContentInfo = new EncapsulatedContentInfo; - encapContentInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-202); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - digest.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-203); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-204); - } - else - return; -} // DigestedData::BDecContent - -AsnLen DigestedData::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DigestedData::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DigestedData::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-205); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DigestedData::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (digestAlgorithm)) - { - Indent (os, indentG); - os << "digestAlgorithm "; - os << *digestAlgorithm; - } - else - { - Indent (os, indentG); - os << "digestAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (encapContentInfo)) - { - Indent (os, indentG); - os << "encapContentInfo "; - os << *encapContentInfo; - } - else - { - Indent (os, indentG); - os << "encapContentInfo "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "digest "; - os << digest; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DigestedData::Print - - -EncryptedData::EncryptedData() -{ -#if TCL - encryptedContentInfo = new EncryptedContentInfo; -#else - encryptedContentInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EncryptedData::EncryptedData (const EncryptedData &) -{ - Asn1Error << "use of incompletely defined EncryptedData::EncryptedData (const EncryptedData &)" << endl; - abort(); -} - -EncryptedData::~EncryptedData() -{ - delete encryptedContentInfo; -} - -AsnType *EncryptedData::Clone() const -{ - return new EncryptedData; -} - -AsnType *EncryptedData::Copy() const -{ - return new EncryptedData (*this); -} - -#if SNACC_DEEP_COPY -EncryptedData &EncryptedData::operator = (const EncryptedData &that) -#else // SNACC_DEEP_COPY -EncryptedData &EncryptedData::operator = (const EncryptedData &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.encryptedContentInfo) - { - if (!encryptedContentInfo) - encryptedContentInfo = new EncryptedContentInfo; - *encryptedContentInfo = *that.encryptedContentInfo; - } - else - { - delete encryptedContentInfo; - encryptedContentInfo = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EncryptedData &EncryptedData::operator = (const EncryptedData &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EncryptedData::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = encryptedContentInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // EncryptedData::BEncContent - - -void EncryptedData::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-206); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encryptedContentInfo = new EncryptedContentInfo; - encryptedContentInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-207); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-208); - } - else - return; -} // EncryptedData::BDecContent - -AsnLen EncryptedData::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EncryptedData::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EncryptedData::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-209); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EncryptedData::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (encryptedContentInfo)) - { - Indent (os, indentG); - os << "encryptedContentInfo "; - os << *encryptedContentInfo; - } - else - { - Indent (os, indentG); - os << "encryptedContentInfo "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EncryptedData::Print - - -AuthenticatedData::AuthenticatedData() -{ - originatorInfo = NULL; -#if TCL - macAlgorithm = new MessageAuthenticationCodeAlgorithm; -#else - macAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL - digestAlgorithm = NULL; -#if TCL - encapContentInfo = new EncapsulatedContentInfo; -#else - encapContentInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL - authenctiatedAttributes = NULL; - unauthenticatedAttributes = NULL; -} - -AuthenticatedData::AuthenticatedData (const AuthenticatedData &) -{ - Asn1Error << "use of incompletely defined AuthenticatedData::AuthenticatedData (const AuthenticatedData &)" << endl; - abort(); -} - -AuthenticatedData::~AuthenticatedData() -{ - delete originatorInfo; - delete macAlgorithm; - delete digestAlgorithm; - delete encapContentInfo; - delete authenctiatedAttributes; - delete unauthenticatedAttributes; -} - -AsnType *AuthenticatedData::Clone() const -{ - return new AuthenticatedData; -} - -AsnType *AuthenticatedData::Copy() const -{ - return new AuthenticatedData (*this); -} - -#if SNACC_DEEP_COPY -AuthenticatedData &AuthenticatedData::operator = (const AuthenticatedData &that) -#else // SNACC_DEEP_COPY -AuthenticatedData &AuthenticatedData::operator = (const AuthenticatedData &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - if (that.originatorInfo) - { - if (!originatorInfo) - originatorInfo = new OriginatorInfo; - *originatorInfo = *that.originatorInfo; - } - else - { - delete originatorInfo; - originatorInfo = NULL; - } - recipientInfos = that.recipientInfos; - if (that.macAlgorithm) - { - if (!macAlgorithm) - macAlgorithm = new MessageAuthenticationCodeAlgorithm; - *macAlgorithm = *that.macAlgorithm; - } - else - { - delete macAlgorithm; - macAlgorithm = NULL; - } - if (that.digestAlgorithm) - { - if (!digestAlgorithm) - digestAlgorithm = new DigestAlgorithmIdentifier; - *digestAlgorithm = *that.digestAlgorithm; - } - else - { - delete digestAlgorithm; - digestAlgorithm = NULL; - } - if (that.encapContentInfo) - { - if (!encapContentInfo) - encapContentInfo = new EncapsulatedContentInfo; - *encapContentInfo = *that.encapContentInfo; - } - else - { - delete encapContentInfo; - encapContentInfo = NULL; - } - if (that.authenctiatedAttributes) - { - if (!authenctiatedAttributes) - authenctiatedAttributes = new Attributes; - *authenctiatedAttributes = *that.authenctiatedAttributes; - } - else - { - delete authenctiatedAttributes; - authenctiatedAttributes = NULL; - } - mac = that.mac; - if (that.unauthenticatedAttributes) - { - if (!unauthenticatedAttributes) - unauthenticatedAttributes = new Attributes; - *unauthenticatedAttributes = *that.unauthenticatedAttributes; - } - else - { - delete unauthenticatedAttributes; - unauthenticatedAttributes = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AuthenticatedData &AuthenticatedData::operator = (const AuthenticatedData &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AuthenticatedData::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (unauthenticatedAttributes)) - { - BEncEocIfNec (b); - l = unauthenticatedAttributes->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 3); - totalLen += l; - } - - l = mac.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - if (NOT_NULL (authenctiatedAttributes)) - { - BEncEocIfNec (b); - l = authenctiatedAttributes->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 2); - totalLen += l; - } - - BEncEocIfNec (b); - l = encapContentInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - if (NOT_NULL (digestAlgorithm)) - { - BEncEocIfNec (b); - l = digestAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - BEncEocIfNec (b); - l = macAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = recipientInfos.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - - if (NOT_NULL (originatorInfo)) - { - BEncEocIfNec (b); - l = originatorInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // AuthenticatedData::BEncContent - - -void AuthenticatedData::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-210); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - originatorInfo = new OriginatorInfo; - originatorInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - recipientInfos.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-211); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - macAlgorithm = new MessageAuthenticationCodeAlgorithm; - macAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-212); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - digestAlgorithm = new DigestAlgorithmIdentifier; - digestAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encapContentInfo = new EncapsulatedContentInfo; - encapContentInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-213); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - authenctiatedAttributes = new Attributes; - authenctiatedAttributes->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - mac.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-214); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 3))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - unauthenticatedAttributes = new Attributes; - unauthenticatedAttributes->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-215); - } - else - return; -} // AuthenticatedData::BDecContent - -AsnLen AuthenticatedData::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AuthenticatedData::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AuthenticatedData::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-216); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AuthenticatedData::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - if (NOT_NULL (originatorInfo)) - { - Indent (os, indentG); - os << "originatorInfo "; - os << *originatorInfo; - } - else - { - Indent (os, indentG); - os << "originatorInfo "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "recipientInfos "; - os << recipientInfos; - os << "," << endl; - } - - if (NOT_NULL (macAlgorithm)) - { - Indent (os, indentG); - os << "macAlgorithm "; - os << *macAlgorithm; - } - else - { - Indent (os, indentG); - os << "macAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (digestAlgorithm)) - { - Indent (os, indentG); - os << "digestAlgorithm "; - os << *digestAlgorithm; - } - else - { - Indent (os, indentG); - os << "digestAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (encapContentInfo)) - { - Indent (os, indentG); - os << "encapContentInfo "; - os << *encapContentInfo; - } - else - { - Indent (os, indentG); - os << "encapContentInfo "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (authenctiatedAttributes)) - { - Indent (os, indentG); - os << "authenctiatedAttributes "; - os << *authenctiatedAttributes; - } - else - { - Indent (os, indentG); - os << "authenctiatedAttributes "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "mac "; - os << mac; - os << "," << endl; - } - - if (NOT_NULL (unauthenticatedAttributes)) - { - os << ","<< endl; - Indent (os, indentG); - os << "unauthenticatedAttributes "; - os << *unauthenticatedAttributes; - } - else - { - Indent (os, indentG); - os << "unauthenticatedAttributes "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AuthenticatedData::Print - - -AsnType *UserKeyingMaterials::Clone() const -{ - return new UserKeyingMaterials; -} - -AsnType *UserKeyingMaterials::Copy() const -{ - return new UserKeyingMaterials (*this); -} - -AsnLen UserKeyingMaterials::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void UserKeyingMaterials::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "UserKeyingMaterials::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-217); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -UserKeyingMaterials::UserKeyingMaterials (const UserKeyingMaterials &) -{ - Asn1Error << "use of incompletely defined UserKeyingMaterials::UserKeyingMaterials (const UserKeyingMaterials &)" << endl; - abort(); -} - -UserKeyingMaterials::~UserKeyingMaterials() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -UserKeyingMaterials &UserKeyingMaterials::operator = (const UserKeyingMaterials &that) -#else // SNACC_DEEP_COPY -UserKeyingMaterials &UserKeyingMaterials::operator = (const UserKeyingMaterials &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined UserKeyingMaterials &UserKeyingMaterials::operator = (const UserKeyingMaterials &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void UserKeyingMaterials::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void UserKeyingMaterials::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // UserKeyingMaterials::SetCurrElmt - - -unsigned long int UserKeyingMaterials::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // UserKeyingMaterials::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -UserKeyingMaterial *UserKeyingMaterials::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new UserKeyingMaterial; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // UserKeyingMaterials::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -UserKeyingMaterial *UserKeyingMaterials::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new UserKeyingMaterial; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // UserKeyingMaterials::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -UserKeyingMaterial *UserKeyingMaterials::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new UserKeyingMaterial; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // UserKeyingMaterials::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -UserKeyingMaterial *UserKeyingMaterials::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new UserKeyingMaterial; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // UserKeyingMaterials::InsertAfter - - -UserKeyingMaterials &UserKeyingMaterials::AppendCopy (UserKeyingMaterial &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new UserKeyingMaterial; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -UserKeyingMaterials &UserKeyingMaterials::PrependCopy (UserKeyingMaterial &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new UserKeyingMaterial; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // UserKeyingMaterials::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -UserKeyingMaterials &UserKeyingMaterials::InsertBeforeAndCopy (UserKeyingMaterial &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new UserKeyingMaterial; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // UserKeyingMaterials::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -UserKeyingMaterials &UserKeyingMaterials::InsertAfterAndCopy (UserKeyingMaterial &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new UserKeyingMaterial; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // UserKeyingMaterials::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void UserKeyingMaterials::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen UserKeyingMaterials::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncDefLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, PRIM, OCTETSTRING_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // UserKeyingMaterials::BEncContent - - -void UserKeyingMaterials::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - UserKeyingMaterial *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - && (tag1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-218); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // UserKeyingMaterials::BDecContent - - -RC2CBCParameter::RC2CBCParameter() -{ -} - -RC2CBCParameter::RC2CBCParameter (const RC2CBCParameter &) -{ - Asn1Error << "use of incompletely defined RC2CBCParameter::RC2CBCParameter (const RC2CBCParameter &)" << endl; - abort(); -} - -RC2CBCParameter::~RC2CBCParameter() -{ -} - -AsnType *RC2CBCParameter::Clone() const -{ - return new RC2CBCParameter; -} - -AsnType *RC2CBCParameter::Copy() const -{ - return new RC2CBCParameter (*this); -} - -#if SNACC_DEEP_COPY -RC2CBCParameter &RC2CBCParameter::operator = (const RC2CBCParameter &that) -#else // SNACC_DEEP_COPY -RC2CBCParameter &RC2CBCParameter::operator = (const RC2CBCParameter &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - rc2ParameterVersion = that.rc2ParameterVersion; - iv = that.iv; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RC2CBCParameter &RC2CBCParameter::operator = (const RC2CBCParameter &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -RC2CBCParameter::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = iv.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - l = rc2ParameterVersion.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // RC2CBCParameter::BEncContent - - -void RC2CBCParameter::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - rc2ParameterVersion.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-219); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - iv.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-220); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-221); - } - else - return; -} // RC2CBCParameter::BDecContent - -AsnLen RC2CBCParameter::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void RC2CBCParameter::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "RC2CBCParameter::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-222); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void RC2CBCParameter::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "rc2ParameterVersion "; - os << rc2ParameterVersion; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "iv "; - os << iv; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // RC2CBCParameter::Print - - -ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate() -{ - choiceId = certificateCid; -#if TCL - certificate = new Certificate; -#else - certificate = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate (const ExtendedCertificateOrCertificate &) -{ - Asn1Error << "use of incompletely defined ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate (const ExtendedCertificateOrCertificate &)" << endl; - abort(); -} - -ExtendedCertificateOrCertificate::~ExtendedCertificateOrCertificate() -{ - switch (choiceId) - { - case certificateCid: - delete certificate; - break; - case extendedCertificateCid: - delete extendedCertificate; - break; - } // end of switch -} // end of destructor - -AsnType *ExtendedCertificateOrCertificate::Clone() const -{ - return new ExtendedCertificateOrCertificate; -} - -AsnType *ExtendedCertificateOrCertificate::Copy() const -{ - return new ExtendedCertificateOrCertificate (*this); -} - -#if SNACC_DEEP_COPY -ExtendedCertificateOrCertificate &ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate &that) -#else // SNACC_DEEP_COPY -ExtendedCertificateOrCertificate &ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case certificateCid: - delete certificate; - break; - case extendedCertificateCid: - delete extendedCertificate; - break; - } - switch (choiceId = that.choiceId) - { - case certificateCid: - certificate = new Certificate; - *certificate = *that.certificate; - break; - case extendedCertificateCid: - extendedCertificate = new ExtendedCertificate; - *extendedCertificate = *that.extendedCertificate; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ExtendedCertificateOrCertificate &ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ExtendedCertificateOrCertificate::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case certificateCid: - BEncEocIfNec (b); - l = certificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - case extendedCertificateCid: - BEncEocIfNec (b); - l = extendedCertificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - break; - - } // end switch - return l; -} // ExtendedCertificateOrCertificate::BEncContent - - -void ExtendedCertificateOrCertificate::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = certificateCid; - certificate = new Certificate; - certificate->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 0): - choiceId = extendedCertificateCid; - extendedCertificate = new ExtendedCertificate; - extendedCertificate->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-223); - break; - } // end switch -} // ExtendedCertificateOrCertificate::BDecContent - - -AsnLen ExtendedCertificateOrCertificate::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void ExtendedCertificateOrCertificate::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void ExtendedCertificateOrCertificate::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case certificateCid: - os << "certificate "; - if (certificate) - os << *certificate; - else - os << "-- void3 --\n"; - break; - - case extendedCertificateCid: - os << "extendedCertificate "; - if (extendedCertificate) - os << *extendedCertificate; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // ExtendedCertificateOrCertificate::Print - -DigestInfo::DigestInfo() -{ -#if TCL - digestAlgorithm = new DigestAlgorithmIdentifier; -#else - digestAlgorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DigestInfo::DigestInfo (const DigestInfo &) -{ - Asn1Error << "use of incompletely defined DigestInfo::DigestInfo (const DigestInfo &)" << endl; - abort(); -} - -DigestInfo::~DigestInfo() -{ - delete digestAlgorithm; -} - -AsnType *DigestInfo::Clone() const -{ - return new DigestInfo; -} - -AsnType *DigestInfo::Copy() const -{ - return new DigestInfo (*this); -} - -#if SNACC_DEEP_COPY -DigestInfo &DigestInfo::operator = (const DigestInfo &that) -#else // SNACC_DEEP_COPY -DigestInfo &DigestInfo::operator = (const DigestInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.digestAlgorithm) - { - if (!digestAlgorithm) - digestAlgorithm = new DigestAlgorithmIdentifier; - *digestAlgorithm = *that.digestAlgorithm; - } - else - { - delete digestAlgorithm; - digestAlgorithm = NULL; - } - digest = that.digest; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DigestInfo &DigestInfo::operator = (const DigestInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DigestInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = digest.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = digestAlgorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // DigestInfo::BEncContent - - -void DigestInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - digestAlgorithm = new DigestAlgorithmIdentifier; - digestAlgorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-224); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - digest.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-225); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-226); - } - else - return; -} // DigestInfo::BDecContent - -AsnLen DigestInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DigestInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DigestInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-227); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DigestInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (digestAlgorithm)) - { - Indent (os, indentG); - os << "digestAlgorithm "; - os << *digestAlgorithm; - } - else - { - Indent (os, indentG); - os << "digestAlgorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "digest "; - os << digest; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DigestInfo::Print - - diff --git a/SecurityASN1/c++/sm_ess.cpp b/SecurityASN1/c++/sm_ess.cpp deleted file mode 100644 index f6a22666..00000000 --- a/SecurityASN1/c++/sm_ess.cpp +++ /dev/null @@ -1,6649 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_ess.cpp - class member functions for ASN.1 module ExtendedSecurityServices -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -AsnType *SigningCertificateSeqOf1::Clone() const -{ - return new SigningCertificateSeqOf1; -} - -AsnType *SigningCertificateSeqOf1::Copy() const -{ - return new SigningCertificateSeqOf1 (*this); -} - -AsnLen SigningCertificateSeqOf1::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void SigningCertificateSeqOf1::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "SigningCertificateSeqOf1::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-100); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -SigningCertificateSeqOf1::SigningCertificateSeqOf1 (const SigningCertificateSeqOf1 &) -{ - Asn1Error << "use of incompletely defined SigningCertificateSeqOf1::SigningCertificateSeqOf1 (const SigningCertificateSeqOf1 &)" << endl; - abort(); -} - -SigningCertificateSeqOf1::~SigningCertificateSeqOf1() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -SigningCertificateSeqOf1 &SigningCertificateSeqOf1::operator = (const SigningCertificateSeqOf1 &that) -#else // SNACC_DEEP_COPY -SigningCertificateSeqOf1 &SigningCertificateSeqOf1::operator = (const SigningCertificateSeqOf1 &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SigningCertificateSeqOf1 &SigningCertificateSeqOf1::operator = (const SigningCertificateSeqOf1 &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void SigningCertificateSeqOf1::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void SigningCertificateSeqOf1::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // SigningCertificateSeqOf1::SetCurrElmt - - -unsigned long int SigningCertificateSeqOf1::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // SigningCertificateSeqOf1::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -PolicyInformation *SigningCertificateSeqOf1::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SigningCertificateSeqOf1::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -PolicyInformation *SigningCertificateSeqOf1::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SigningCertificateSeqOf1::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -PolicyInformation *SigningCertificateSeqOf1::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SigningCertificateSeqOf1::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -PolicyInformation *SigningCertificateSeqOf1::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SigningCertificateSeqOf1::InsertAfter - - -SigningCertificateSeqOf1 &SigningCertificateSeqOf1::AppendCopy (PolicyInformation &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -SigningCertificateSeqOf1 &SigningCertificateSeqOf1::PrependCopy (PolicyInformation &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // SigningCertificateSeqOf1::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -SigningCertificateSeqOf1 &SigningCertificateSeqOf1::InsertBeforeAndCopy (PolicyInformation &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // SigningCertificateSeqOf1::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -SigningCertificateSeqOf1 &SigningCertificateSeqOf1::InsertAfterAndCopy (PolicyInformation &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // SigningCertificateSeqOf1::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void SigningCertificateSeqOf1::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen SigningCertificateSeqOf1::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // SigningCertificateSeqOf1::BEncContent - - -void SigningCertificateSeqOf1::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - PolicyInformation *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-101); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // SigningCertificateSeqOf1::BDecContent - - -AsnType *MLReceiptPolicySeqOf1::Clone() const -{ - return new MLReceiptPolicySeqOf1; -} - -AsnType *MLReceiptPolicySeqOf1::Copy() const -{ - return new MLReceiptPolicySeqOf1 (*this); -} - -AsnLen MLReceiptPolicySeqOf1::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void MLReceiptPolicySeqOf1::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "MLReceiptPolicySeqOf1::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-102); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -MLReceiptPolicySeqOf1::MLReceiptPolicySeqOf1 (const MLReceiptPolicySeqOf1 &) -{ - Asn1Error << "use of incompletely defined MLReceiptPolicySeqOf1::MLReceiptPolicySeqOf1 (const MLReceiptPolicySeqOf1 &)" << endl; - abort(); -} - -MLReceiptPolicySeqOf1::~MLReceiptPolicySeqOf1() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -MLReceiptPolicySeqOf1 &MLReceiptPolicySeqOf1::operator = (const MLReceiptPolicySeqOf1 &that) -#else // SNACC_DEEP_COPY -MLReceiptPolicySeqOf1 &MLReceiptPolicySeqOf1::operator = (const MLReceiptPolicySeqOf1 &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined MLReceiptPolicySeqOf1 &MLReceiptPolicySeqOf1::operator = (const MLReceiptPolicySeqOf1 &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void MLReceiptPolicySeqOf1::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void MLReceiptPolicySeqOf1::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // MLReceiptPolicySeqOf1::SetCurrElmt - - -unsigned long int MLReceiptPolicySeqOf1::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // MLReceiptPolicySeqOf1::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -GeneralNames *MLReceiptPolicySeqOf1::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLReceiptPolicySeqOf1::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -GeneralNames *MLReceiptPolicySeqOf1::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLReceiptPolicySeqOf1::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -GeneralNames *MLReceiptPolicySeqOf1::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLReceiptPolicySeqOf1::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -GeneralNames *MLReceiptPolicySeqOf1::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLReceiptPolicySeqOf1::InsertAfter - - -MLReceiptPolicySeqOf1 &MLReceiptPolicySeqOf1::AppendCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -MLReceiptPolicySeqOf1 &MLReceiptPolicySeqOf1::PrependCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // MLReceiptPolicySeqOf1::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -MLReceiptPolicySeqOf1 &MLReceiptPolicySeqOf1::InsertBeforeAndCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // MLReceiptPolicySeqOf1::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -MLReceiptPolicySeqOf1 &MLReceiptPolicySeqOf1::InsertAfterAndCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // MLReceiptPolicySeqOf1::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void MLReceiptPolicySeqOf1::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen MLReceiptPolicySeqOf1::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // MLReceiptPolicySeqOf1::BEncContent - - -void MLReceiptPolicySeqOf1::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - GeneralNames *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-103); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // MLReceiptPolicySeqOf1::BDecContent - - -AsnType *MLReceiptPolicySeqOf::Clone() const -{ - return new MLReceiptPolicySeqOf; -} - -AsnType *MLReceiptPolicySeqOf::Copy() const -{ - return new MLReceiptPolicySeqOf (*this); -} - -AsnLen MLReceiptPolicySeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void MLReceiptPolicySeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "MLReceiptPolicySeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-104); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -MLReceiptPolicySeqOf::MLReceiptPolicySeqOf (const MLReceiptPolicySeqOf &) -{ - Asn1Error << "use of incompletely defined MLReceiptPolicySeqOf::MLReceiptPolicySeqOf (const MLReceiptPolicySeqOf &)" << endl; - abort(); -} - -MLReceiptPolicySeqOf::~MLReceiptPolicySeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -MLReceiptPolicySeqOf &MLReceiptPolicySeqOf::operator = (const MLReceiptPolicySeqOf &that) -#else // SNACC_DEEP_COPY -MLReceiptPolicySeqOf &MLReceiptPolicySeqOf::operator = (const MLReceiptPolicySeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined MLReceiptPolicySeqOf &MLReceiptPolicySeqOf::operator = (const MLReceiptPolicySeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void MLReceiptPolicySeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void MLReceiptPolicySeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // MLReceiptPolicySeqOf::SetCurrElmt - - -unsigned long int MLReceiptPolicySeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // MLReceiptPolicySeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -GeneralNames *MLReceiptPolicySeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLReceiptPolicySeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -GeneralNames *MLReceiptPolicySeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLReceiptPolicySeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -GeneralNames *MLReceiptPolicySeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLReceiptPolicySeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -GeneralNames *MLReceiptPolicySeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLReceiptPolicySeqOf::InsertAfter - - -MLReceiptPolicySeqOf &MLReceiptPolicySeqOf::AppendCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -MLReceiptPolicySeqOf &MLReceiptPolicySeqOf::PrependCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // MLReceiptPolicySeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -MLReceiptPolicySeqOf &MLReceiptPolicySeqOf::InsertBeforeAndCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // MLReceiptPolicySeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -MLReceiptPolicySeqOf &MLReceiptPolicySeqOf::InsertAfterAndCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // MLReceiptPolicySeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void MLReceiptPolicySeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen MLReceiptPolicySeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // MLReceiptPolicySeqOf::BEncContent - - -void MLReceiptPolicySeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - GeneralNames *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-105); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // MLReceiptPolicySeqOf::BDecContent - - -AsnType *ReceiptsFromSeqOf::Clone() const -{ - return new ReceiptsFromSeqOf; -} - -AsnType *ReceiptsFromSeqOf::Copy() const -{ - return new ReceiptsFromSeqOf (*this); -} - -AsnLen ReceiptsFromSeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ReceiptsFromSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ReceiptsFromSeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-106); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -ReceiptsFromSeqOf::ReceiptsFromSeqOf (const ReceiptsFromSeqOf &) -{ - Asn1Error << "use of incompletely defined ReceiptsFromSeqOf::ReceiptsFromSeqOf (const ReceiptsFromSeqOf &)" << endl; - abort(); -} - -ReceiptsFromSeqOf::~ReceiptsFromSeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -ReceiptsFromSeqOf &ReceiptsFromSeqOf::operator = (const ReceiptsFromSeqOf &that) -#else // SNACC_DEEP_COPY -ReceiptsFromSeqOf &ReceiptsFromSeqOf::operator = (const ReceiptsFromSeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ReceiptsFromSeqOf &ReceiptsFromSeqOf::operator = (const ReceiptsFromSeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void ReceiptsFromSeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void ReceiptsFromSeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // ReceiptsFromSeqOf::SetCurrElmt - - -unsigned long int ReceiptsFromSeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // ReceiptsFromSeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -GeneralNames *ReceiptsFromSeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ReceiptsFromSeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -GeneralNames *ReceiptsFromSeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ReceiptsFromSeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -GeneralNames *ReceiptsFromSeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ReceiptsFromSeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -GeneralNames *ReceiptsFromSeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ReceiptsFromSeqOf::InsertAfter - - -ReceiptsFromSeqOf &ReceiptsFromSeqOf::AppendCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -ReceiptsFromSeqOf &ReceiptsFromSeqOf::PrependCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // ReceiptsFromSeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -ReceiptsFromSeqOf &ReceiptsFromSeqOf::InsertBeforeAndCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // ReceiptsFromSeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ReceiptsFromSeqOf &ReceiptsFromSeqOf::InsertAfterAndCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // ReceiptsFromSeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void ReceiptsFromSeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen ReceiptsFromSeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // ReceiptsFromSeqOf::BEncContent - - -void ReceiptsFromSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - GeneralNames *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-107); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // ReceiptsFromSeqOf::BDecContent - - -AsnType *ReceiptRequestSeqOf::Clone() const -{ - return new ReceiptRequestSeqOf; -} - -AsnType *ReceiptRequestSeqOf::Copy() const -{ - return new ReceiptRequestSeqOf (*this); -} - -AsnLen ReceiptRequestSeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ReceiptRequestSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ReceiptRequestSeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-108); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -ReceiptRequestSeqOf::ReceiptRequestSeqOf (const ReceiptRequestSeqOf &) -{ - Asn1Error << "use of incompletely defined ReceiptRequestSeqOf::ReceiptRequestSeqOf (const ReceiptRequestSeqOf &)" << endl; - abort(); -} - -ReceiptRequestSeqOf::~ReceiptRequestSeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -ReceiptRequestSeqOf &ReceiptRequestSeqOf::operator = (const ReceiptRequestSeqOf &that) -#else // SNACC_DEEP_COPY -ReceiptRequestSeqOf &ReceiptRequestSeqOf::operator = (const ReceiptRequestSeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ReceiptRequestSeqOf &ReceiptRequestSeqOf::operator = (const ReceiptRequestSeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void ReceiptRequestSeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void ReceiptRequestSeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // ReceiptRequestSeqOf::SetCurrElmt - - -unsigned long int ReceiptRequestSeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // ReceiptRequestSeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -GeneralNames *ReceiptRequestSeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ReceiptRequestSeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -GeneralNames *ReceiptRequestSeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ReceiptRequestSeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -GeneralNames *ReceiptRequestSeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ReceiptRequestSeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -GeneralNames *ReceiptRequestSeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ReceiptRequestSeqOf::InsertAfter - - -ReceiptRequestSeqOf &ReceiptRequestSeqOf::AppendCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -ReceiptRequestSeqOf &ReceiptRequestSeqOf::PrependCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // ReceiptRequestSeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -ReceiptRequestSeqOf &ReceiptRequestSeqOf::InsertBeforeAndCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // ReceiptRequestSeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ReceiptRequestSeqOf &ReceiptRequestSeqOf::InsertAfterAndCopy (GeneralNames &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralNames; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // ReceiptRequestSeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void ReceiptRequestSeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen ReceiptRequestSeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // ReceiptRequestSeqOf::BEncContent - - -void ReceiptRequestSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - GeneralNames *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-109); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // ReceiptRequestSeqOf::BDecContent - - -ESSPrivacyMark::ESSPrivacyMark() -{ - choiceId = pStringCid; -#if TCL - pString = new PrintableString; -#else - pString = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -ESSPrivacyMark::ESSPrivacyMark (const ESSPrivacyMark &) -{ - Asn1Error << "use of incompletely defined ESSPrivacyMark::ESSPrivacyMark (const ESSPrivacyMark &)" << endl; - abort(); -} - -ESSPrivacyMark::~ESSPrivacyMark() -{ - switch (choiceId) - { - case pStringCid: - delete pString; - break; - case utf8StringCid: - delete utf8String; - break; - } // end of switch -} // end of destructor - -AsnType *ESSPrivacyMark::Clone() const -{ - return new ESSPrivacyMark; -} - -AsnType *ESSPrivacyMark::Copy() const -{ - return new ESSPrivacyMark (*this); -} - -#if SNACC_DEEP_COPY -ESSPrivacyMark &ESSPrivacyMark::operator = (const ESSPrivacyMark &that) -#else // SNACC_DEEP_COPY -ESSPrivacyMark &ESSPrivacyMark::operator = (const ESSPrivacyMark &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case pStringCid: - delete pString; - break; - case utf8StringCid: - delete utf8String; - break; - } - switch (choiceId = that.choiceId) - { - case pStringCid: - pString = new PrintableString; - *pString = *that.pString; - break; - case utf8StringCid: - utf8String = new UTF8String; - *utf8String = *that.utf8String; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ESSPrivacyMark &ESSPrivacyMark::operator = (const ESSPrivacyMark &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ESSPrivacyMark::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case pStringCid: - l = pString->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - break; - - case utf8StringCid: - l = utf8String->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, 12); - break; - - } // end switch - return l; -} // ESSPrivacyMark::BEncContent - - -void ESSPrivacyMark::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE): - choiceId = pStringCid; - pString = new PrintableString; - pString->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, 12): - case MAKE_TAG_ID (UNIV, CONS, 12): - choiceId = utf8StringCid; - utf8String = new UTF8String; - utf8String->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-110); - break; - } // end switch -} // ESSPrivacyMark::BDecContent - - -AsnLen ESSPrivacyMark::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void ESSPrivacyMark::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void ESSPrivacyMark::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case pStringCid: - os << "pString "; - if (pString) - os << *pString; - else - os << "-- void3 --\n"; - break; - - case utf8StringCid: - os << "utf8String "; - if (utf8String) - os << *utf8String; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // ESSPrivacyMark::Print - -SecurityCategory::SecurityCategory() -{ -} - -SecurityCategory::SecurityCategory (const SecurityCategory &) -{ - Asn1Error << "use of incompletely defined SecurityCategory::SecurityCategory (const SecurityCategory &)" << endl; - abort(); -} - -SecurityCategory::~SecurityCategory() -{ -} - -AsnType *SecurityCategory::Clone() const -{ - return new SecurityCategory; -} - -AsnType *SecurityCategory::Copy() const -{ - return new SecurityCategory (*this); -} - -#if SNACC_DEEP_COPY -SecurityCategory &SecurityCategory::operator = (const SecurityCategory &that) -#else // SNACC_DEEP_COPY -SecurityCategory &SecurityCategory::operator = (const SecurityCategory &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - type = that.type; - value = that.value; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SecurityCategory &SecurityCategory::operator = (const SecurityCategory &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -SecurityCategory::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - ENC_LOAD_ANYBUF(&value, b, l); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - - l = type.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - - return totalLen; -} // SecurityCategory::BEncContent - - -void SecurityCategory::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - type.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-111); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - DEC_LOAD_ANYBUF(&value, b, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-112); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-113); - } - else - return; -} // SecurityCategory::BDecContent - -AsnLen SecurityCategory::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void SecurityCategory::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "SecurityCategory::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-114); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void SecurityCategory::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "type "; - os << type; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "value "; - os << value; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // SecurityCategory::Print - - -EntityIdentifier::EntityIdentifier() -{ - choiceId = issuerAndSerialNumberCid; -#if TCL - issuerAndSerialNumber = new IssuerAndSerialNumber; -#else - issuerAndSerialNumber = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EntityIdentifier::EntityIdentifier (const EntityIdentifier &) -{ - Asn1Error << "use of incompletely defined EntityIdentifier::EntityIdentifier (const EntityIdentifier &)" << endl; - abort(); -} - -EntityIdentifier::~EntityIdentifier() -{ - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - delete subjectKeyIdentifier; - break; - } // end of switch -} // end of destructor - -AsnType *EntityIdentifier::Clone() const -{ - return new EntityIdentifier; -} - -AsnType *EntityIdentifier::Copy() const -{ - return new EntityIdentifier (*this); -} - -#if SNACC_DEEP_COPY -EntityIdentifier &EntityIdentifier::operator = (const EntityIdentifier &that) -#else // SNACC_DEEP_COPY -EntityIdentifier &EntityIdentifier::operator = (const EntityIdentifier &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case issuerAndSerialNumberCid: - delete issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - delete subjectKeyIdentifier; - break; - } - switch (choiceId = that.choiceId) - { - case issuerAndSerialNumberCid: - issuerAndSerialNumber = new IssuerAndSerialNumber; - *issuerAndSerialNumber = *that.issuerAndSerialNumber; - break; - case subjectKeyIdentifierCid: - subjectKeyIdentifier = new KeyIdentifier; - *subjectKeyIdentifier = *that.subjectKeyIdentifier; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EntityIdentifier &EntityIdentifier::operator = (const EntityIdentifier &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EntityIdentifier::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case issuerAndSerialNumberCid: - BEncEocIfNec (b); - l = issuerAndSerialNumber->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - case subjectKeyIdentifierCid: - l = subjectKeyIdentifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - break; - - } // end switch - return l; -} // EntityIdentifier::BEncContent - - -void EntityIdentifier::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = issuerAndSerialNumberCid; - issuerAndSerialNumber = new IssuerAndSerialNumber; - issuerAndSerialNumber->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE): - choiceId = subjectKeyIdentifierCid; - subjectKeyIdentifier = new KeyIdentifier; - subjectKeyIdentifier->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-115); - break; - } // end switch -} // EntityIdentifier::BDecContent - - -AsnLen EntityIdentifier::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void EntityIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void EntityIdentifier::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case issuerAndSerialNumberCid: - os << "issuerAndSerialNumber "; - if (issuerAndSerialNumber) - os << *issuerAndSerialNumber; - else - os << "-- void3 --\n"; - break; - - case subjectKeyIdentifierCid: - os << "subjectKeyIdentifier "; - if (subjectKeyIdentifier) - os << *subjectKeyIdentifier; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // EntityIdentifier::Print - -ReceiptsFrom::ReceiptsFrom() -{ - choiceId = allOrFirstTierCid; -#if TCL - allOrFirstTier = new AllOrFirstTier; -#else - allOrFirstTier = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -ReceiptsFrom::ReceiptsFrom (const ReceiptsFrom &) -{ - Asn1Error << "use of incompletely defined ReceiptsFrom::ReceiptsFrom (const ReceiptsFrom &)" << endl; - abort(); -} - -ReceiptsFrom::~ReceiptsFrom() -{ - switch (choiceId) - { - case allOrFirstTierCid: - delete allOrFirstTier; - break; - case receiptListCid: - delete receiptList; - break; - } // end of switch -} // end of destructor - -AsnType *ReceiptsFrom::Clone() const -{ - return new ReceiptsFrom; -} - -AsnType *ReceiptsFrom::Copy() const -{ - return new ReceiptsFrom (*this); -} - -#if SNACC_DEEP_COPY -ReceiptsFrom &ReceiptsFrom::operator = (const ReceiptsFrom &that) -#else // SNACC_DEEP_COPY -ReceiptsFrom &ReceiptsFrom::operator = (const ReceiptsFrom &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case allOrFirstTierCid: - delete allOrFirstTier; - break; - case receiptListCid: - delete receiptList; - break; - } - switch (choiceId = that.choiceId) - { - case allOrFirstTierCid: - allOrFirstTier = new AllOrFirstTier; - *allOrFirstTier = *that.allOrFirstTier; - break; - case receiptListCid: - receiptList = new ReceiptsFromSeqOf; - *receiptList = *that.receiptList; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ReceiptsFrom &ReceiptsFrom::operator = (const ReceiptsFrom &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ReceiptsFrom::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case allOrFirstTierCid: - l = allOrFirstTier->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 0); - break; - - case receiptListCid: - BEncEocIfNec (b); - l = receiptList->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - break; - - } // end switch - return l; -} // ReceiptsFrom::BEncContent - - -void ReceiptsFrom::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (CNTX, PRIM, 0): - choiceId = allOrFirstTierCid; - allOrFirstTier = new AllOrFirstTier; - allOrFirstTier->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = receiptListCid; - receiptList = new ReceiptsFromSeqOf; - receiptList->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-116); - break; - } // end switch -} // ReceiptsFrom::BDecContent - - -AsnLen ReceiptsFrom::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void ReceiptsFrom::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void ReceiptsFrom::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case allOrFirstTierCid: - os << "allOrFirstTier "; - if (allOrFirstTier) - os << *allOrFirstTier; - else - os << "-- void3 --\n"; - break; - - case receiptListCid: - os << "receiptList "; - if (receiptList) - os << *receiptList; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // ReceiptsFrom::Print - -AsnType *SecurityCategories::Clone() const -{ - return new SecurityCategories; -} - -AsnType *SecurityCategories::Copy() const -{ - return new SecurityCategories (*this); -} - -AsnLen SecurityCategories::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void SecurityCategories::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "SecurityCategories::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-117); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -SecurityCategories::SecurityCategories (const SecurityCategories &) -{ - Asn1Error << "use of incompletely defined SecurityCategories::SecurityCategories (const SecurityCategories &)" << endl; - abort(); -} - -SecurityCategories::~SecurityCategories() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -SecurityCategories &SecurityCategories::operator = (const SecurityCategories &that) -#else // SNACC_DEEP_COPY -SecurityCategories &SecurityCategories::operator = (const SecurityCategories &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SecurityCategories &SecurityCategories::operator = (const SecurityCategories &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void SecurityCategories::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void SecurityCategories::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // SecurityCategories::SetCurrElmt - - -unsigned long int SecurityCategories::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // SecurityCategories::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -SecurityCategory *SecurityCategories::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SecurityCategory; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SecurityCategories::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -SecurityCategory *SecurityCategories::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SecurityCategory; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SecurityCategories::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -SecurityCategory *SecurityCategories::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SecurityCategory; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SecurityCategories::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -SecurityCategory *SecurityCategories::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SecurityCategory; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SecurityCategories::InsertAfter - - -SecurityCategories &SecurityCategories::AppendCopy (SecurityCategory &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SecurityCategory; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -SecurityCategories &SecurityCategories::PrependCopy (SecurityCategory &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new SecurityCategory; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // SecurityCategories::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -SecurityCategories &SecurityCategories::InsertBeforeAndCopy (SecurityCategory &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new SecurityCategory; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // SecurityCategories::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -SecurityCategories &SecurityCategories::InsertAfterAndCopy (SecurityCategory &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new SecurityCategory; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // SecurityCategories::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void SecurityCategories::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen SecurityCategories::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // SecurityCategories::BEncContent - - -void SecurityCategories::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - SecurityCategory *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-118); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // SecurityCategories::BDecContent - - -MLReceiptPolicy::MLReceiptPolicy() -{ - choiceId = noneCid; -#if TCL - none = new AsnNull; -#else - none = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -MLReceiptPolicy::MLReceiptPolicy (const MLReceiptPolicy &) -{ - Asn1Error << "use of incompletely defined MLReceiptPolicy::MLReceiptPolicy (const MLReceiptPolicy &)" << endl; - abort(); -} - -MLReceiptPolicy::~MLReceiptPolicy() -{ - switch (choiceId) - { - case noneCid: - delete none; - break; - case insteadOfCid: - delete insteadOf; - break; - case inAdditionToCid: - delete inAdditionTo; - break; - } // end of switch -} // end of destructor - -AsnType *MLReceiptPolicy::Clone() const -{ - return new MLReceiptPolicy; -} - -AsnType *MLReceiptPolicy::Copy() const -{ - return new MLReceiptPolicy (*this); -} - -#if SNACC_DEEP_COPY -MLReceiptPolicy &MLReceiptPolicy::operator = (const MLReceiptPolicy &that) -#else // SNACC_DEEP_COPY -MLReceiptPolicy &MLReceiptPolicy::operator = (const MLReceiptPolicy &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case noneCid: - delete none; - break; - case insteadOfCid: - delete insteadOf; - break; - case inAdditionToCid: - delete inAdditionTo; - break; - } - switch (choiceId = that.choiceId) - { - case noneCid: - none = new AsnNull; - *none = *that.none; - break; - case insteadOfCid: - insteadOf = new MLReceiptPolicySeqOf; - *insteadOf = *that.insteadOf; - break; - case inAdditionToCid: - inAdditionTo = new MLReceiptPolicySeqOf1; - *inAdditionTo = *that.inAdditionTo; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined MLReceiptPolicy &MLReceiptPolicy::operator = (const MLReceiptPolicy &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -MLReceiptPolicy::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case noneCid: - l = none->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 0); - break; - - case insteadOfCid: - BEncEocIfNec (b); - l = insteadOf->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - break; - - case inAdditionToCid: - BEncEocIfNec (b); - l = inAdditionTo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 2); - break; - - } // end switch - return l; -} // MLReceiptPolicy::BEncContent - - -void MLReceiptPolicy::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (CNTX, PRIM, 0): - choiceId = noneCid; - none = new AsnNull; - none->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = insteadOfCid; - insteadOf = new MLReceiptPolicySeqOf; - insteadOf->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 2): - choiceId = inAdditionToCid; - inAdditionTo = new MLReceiptPolicySeqOf1; - inAdditionTo->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-119); - break; - } // end switch -} // MLReceiptPolicy::BDecContent - - -AsnLen MLReceiptPolicy::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void MLReceiptPolicy::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void MLReceiptPolicy::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case noneCid: - os << "none "; - if (none) - os << *none; - else - os << "-- void3 --\n"; - break; - - case insteadOfCid: - os << "insteadOf "; - if (insteadOf) - os << *insteadOf; - else - os << "-- void3 --\n"; - break; - - case inAdditionToCid: - os << "inAdditionTo "; - if (inAdditionTo) - os << *inAdditionTo; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // MLReceiptPolicy::Print - -ESSCertID::ESSCertID() -{ - issuerSerial = NULL; -} - -ESSCertID::ESSCertID (const ESSCertID &) -{ - Asn1Error << "use of incompletely defined ESSCertID::ESSCertID (const ESSCertID &)" << endl; - abort(); -} - -ESSCertID::~ESSCertID() -{ - delete issuerSerial; -} - -AsnType *ESSCertID::Clone() const -{ - return new ESSCertID; -} - -AsnType *ESSCertID::Copy() const -{ - return new ESSCertID (*this); -} - -#if SNACC_DEEP_COPY -ESSCertID &ESSCertID::operator = (const ESSCertID &that) -#else // SNACC_DEEP_COPY -ESSCertID &ESSCertID::operator = (const ESSCertID &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - certHash = that.certHash; - if (that.issuerSerial) - { - if (!issuerSerial) - issuerSerial = new IssuerSerial; - *issuerSerial = *that.issuerSerial; - } - else - { - delete issuerSerial; - issuerSerial = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ESSCertID &ESSCertID::operator = (const ESSCertID &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ESSCertID::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (issuerSerial)) - { - BEncEocIfNec (b); - l = issuerSerial->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - l = certHash.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - return totalLen; -} // ESSCertID::BEncContent - - -void ESSCertID::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - certHash.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-120); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuerSerial = new IssuerSerial; - issuerSerial->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-121); - } - else - return; -} // ESSCertID::BDecContent - -AsnLen ESSCertID::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ESSCertID::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ESSCertID::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-122); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ESSCertID::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "certHash "; - os << certHash; - os << "," << endl; - } - - if (NOT_NULL (issuerSerial)) - { - os << ","<< endl; - Indent (os, indentG); - os << "issuerSerial "; - os << *issuerSerial; - } - else - { - Indent (os, indentG); - os << "issuerSerial "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ESSCertID::Print - - -AsnType *SigningCertificateSeqOf::Clone() const -{ - return new SigningCertificateSeqOf; -} - -AsnType *SigningCertificateSeqOf::Copy() const -{ - return new SigningCertificateSeqOf (*this); -} - -AsnLen SigningCertificateSeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void SigningCertificateSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "SigningCertificateSeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-123); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -SigningCertificateSeqOf::SigningCertificateSeqOf (const SigningCertificateSeqOf &) -{ - Asn1Error << "use of incompletely defined SigningCertificateSeqOf::SigningCertificateSeqOf (const SigningCertificateSeqOf &)" << endl; - abort(); -} - -SigningCertificateSeqOf::~SigningCertificateSeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -SigningCertificateSeqOf &SigningCertificateSeqOf::operator = (const SigningCertificateSeqOf &that) -#else // SNACC_DEEP_COPY -SigningCertificateSeqOf &SigningCertificateSeqOf::operator = (const SigningCertificateSeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SigningCertificateSeqOf &SigningCertificateSeqOf::operator = (const SigningCertificateSeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void SigningCertificateSeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void SigningCertificateSeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // SigningCertificateSeqOf::SetCurrElmt - - -unsigned long int SigningCertificateSeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // SigningCertificateSeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -ESSCertID *SigningCertificateSeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSCertID; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SigningCertificateSeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -ESSCertID *SigningCertificateSeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSCertID; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SigningCertificateSeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -ESSCertID *SigningCertificateSeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSCertID; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SigningCertificateSeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ESSCertID *SigningCertificateSeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSCertID; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // SigningCertificateSeqOf::InsertAfter - - -SigningCertificateSeqOf &SigningCertificateSeqOf::AppendCopy (ESSCertID &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSCertID; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -SigningCertificateSeqOf &SigningCertificateSeqOf::PrependCopy (ESSCertID &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSCertID; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // SigningCertificateSeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -SigningCertificateSeqOf &SigningCertificateSeqOf::InsertBeforeAndCopy (ESSCertID &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new ESSCertID; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // SigningCertificateSeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -SigningCertificateSeqOf &SigningCertificateSeqOf::InsertAfterAndCopy (ESSCertID &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new ESSCertID; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // SigningCertificateSeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void SigningCertificateSeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen SigningCertificateSeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // SigningCertificateSeqOf::BEncContent - - -void SigningCertificateSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - ESSCertID *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-124); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // SigningCertificateSeqOf::BDecContent - - -ESSSecurityLabel::ESSSecurityLabel() -{ - security_classification = NULL; - privacy_mark = NULL; - security_categories = NULL; -} - -ESSSecurityLabel::ESSSecurityLabel (const ESSSecurityLabel &) -{ - Asn1Error << "use of incompletely defined ESSSecurityLabel::ESSSecurityLabel (const ESSSecurityLabel &)" << endl; - abort(); -} - -ESSSecurityLabel::~ESSSecurityLabel() -{ - delete security_classification; - delete privacy_mark; - delete security_categories; -} - -AsnType *ESSSecurityLabel::Clone() const -{ - return new ESSSecurityLabel; -} - -AsnType *ESSSecurityLabel::Copy() const -{ - return new ESSSecurityLabel (*this); -} - -#if SNACC_DEEP_COPY -ESSSecurityLabel &ESSSecurityLabel::operator = (const ESSSecurityLabel &that) -#else // SNACC_DEEP_COPY -ESSSecurityLabel &ESSSecurityLabel::operator = (const ESSSecurityLabel &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - security_policy_identifier = that.security_policy_identifier; - if (that.security_classification) - { - if (!security_classification) - security_classification = new SecurityClassification; - *security_classification = *that.security_classification; - } - else - { - delete security_classification; - security_classification = NULL; - } - if (that.privacy_mark) - { - if (!privacy_mark) - privacy_mark = new ESSPrivacyMark; - *privacy_mark = *that.privacy_mark; - } - else - { - delete privacy_mark; - privacy_mark = NULL; - } - if (that.security_categories) - { - if (!security_categories) - security_categories = new SecurityCategories; - *security_categories = *that.security_categories; - } - else - { - delete security_categories; - security_categories = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ESSSecurityLabel &ESSSecurityLabel::operator = (const ESSSecurityLabel &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen ESSSecurityLabel::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - AsnBuf outputBuf; - int iii=0, tmpCount=0; - char *lpszBuf = (char *)calloc(1, 1024); - outputBuf.Init(lpszBuf, 1024); - outputBuf.ResetInWriteRvsMode(); - CSM_Buffer *tmpEnc[4]; - if (NOT_NULL (security_categories)) - { - BEncEocIfNec (b); - l = security_categories->BEncContent (outputBuf); - l += BEncConsLen (outputBuf, l); - - l += BEncTag1 (outputBuf, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - if (NOT_NULL (privacy_mark)) - { - l = privacy_mark->BEncContent (outputBuf); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - if (NOT_NULL (security_classification)) - { - l = security_classification->BEncContent (outputBuf); - BEncDefLenTo127 (outputBuf, l); - l++; - - l += BEncTag1 (outputBuf, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - l = security_policy_identifier.BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - - vdasnacc_sortSet(tmpEnc, iii); - tmpCount = iii; /** REMEMBER how many we have**/ - for (iii=0; iii < tmpCount; iii++) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < tmpCount; iii++) delete tmpEnc[iii]; - free(lpszBuf); - return totalLen; -} // ESSSecurityLabel::BEncContent - - -void ESSSecurityLabel::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen setBytesDecoded = 0; - unsigned int mandatoryElmtsDecoded = 0; - AsnLen elmtLen1; - - for (; (setBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN); ) - { - tag1 = BDecTag (b, setBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, setBytesDecoded, env) - break; /* exit for loop */ - } - elmtLen1 = BDecLen (b, setBytesDecoded, env); - switch (tag1) - { - case MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE): - security_policy_identifier.BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - mandatoryElmtsDecoded++; - break; - - case MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE): - security_classification = new SecurityClassification; - security_classification->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, PRIM, 12): - case MAKE_TAG_ID (UNIV, CONS, 12): - privacy_mark = new ESSPrivacyMark; - privacy_mark->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE): - security_categories = new SecurityCategories; - security_categories->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - default: - Asn1Error << "Unexpected Tag on SET elmt." << endl; - SnaccExcep::throwMe(-125); - } // end switch - } // end for loop - bytesDecoded += setBytesDecoded; - if (mandatoryElmtsDecoded != 1) - { - Asn1Error << "ERROR - non-optional SET element missing." << endl; - SnaccExcep::throwMe(-126); - } -} // ESSSecurityLabel::BDecContent - -AsnLen -ESSSecurityLabel::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void ESSSecurityLabel::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "ESSSecurityLabel::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-127); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ESSSecurityLabel::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SET --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "security-policy-identifier "; - os << security_policy_identifier; - } - - if (NOT_NULL (security_classification)) - { - os << ","<< endl; - Indent (os, indentG); - os << "security-classification "; - os << *security_classification; - } - else - os << "-- void2 --\n"; - - if (NOT_NULL (privacy_mark)) - { - os << ","<< endl; - Indent (os, indentG); - os << "privacy-mark "; - os << *privacy_mark; - } - else - os << "-- void2 --\n"; - - if (NOT_NULL (security_categories)) - { - os << ","<< endl; - Indent (os, indentG); - os << "security-categories "; - os << *security_categories; - } - else - os << "-- void2 --\n"; - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ESSSecurityLabel - operator << - - -MLData::MLData() -{ -#if TCL - mailListIdentifier = new EntityIdentifier; -#else - mailListIdentifier = NULL; // incomplete initialization of mandatory element! -#endif // TCL - mlReceiptPolicy = NULL; -} - -MLData::MLData (const MLData &) -{ - Asn1Error << "use of incompletely defined MLData::MLData (const MLData &)" << endl; - abort(); -} - -MLData::~MLData() -{ - delete mailListIdentifier; - delete mlReceiptPolicy; -} - -AsnType *MLData::Clone() const -{ - return new MLData; -} - -AsnType *MLData::Copy() const -{ - return new MLData (*this); -} - -#if SNACC_DEEP_COPY -MLData &MLData::operator = (const MLData &that) -#else // SNACC_DEEP_COPY -MLData &MLData::operator = (const MLData &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.mailListIdentifier) - { - if (!mailListIdentifier) - mailListIdentifier = new EntityIdentifier; - *mailListIdentifier = *that.mailListIdentifier; - } - else - { - delete mailListIdentifier; - mailListIdentifier = NULL; - } - expansionTime = that.expansionTime; - if (that.mlReceiptPolicy) - { - if (!mlReceiptPolicy) - mlReceiptPolicy = new MLReceiptPolicy; - *mlReceiptPolicy = *that.mlReceiptPolicy; - } - else - { - delete mlReceiptPolicy; - mlReceiptPolicy = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined MLData &MLData::operator = (const MLData &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -MLData::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (mlReceiptPolicy)) - { - l = mlReceiptPolicy->BEncContent (b); - totalLen += l; - } - - l = expansionTime.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - totalLen += l; - - l = mailListIdentifier->BEncContent (b); - totalLen += l; - - return totalLen; -} // MLData::BEncContent - - -void MLData::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - mailListIdentifier = new EntityIdentifier; - mailListIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-128); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - expansionTime.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-129); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - mlReceiptPolicy = new MLReceiptPolicy; - mlReceiptPolicy->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-130); - } - else - return; -} // MLData::BDecContent - -AsnLen MLData::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void MLData::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "MLData::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-131); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void MLData::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (mailListIdentifier)) - { - Indent (os, indentG); - os << "mailListIdentifier "; - os << *mailListIdentifier; - } - else - { - Indent (os, indentG); - os << "mailListIdentifier "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "expansionTime "; - os << expansionTime; - os << "," << endl; - } - - if (NOT_NULL (mlReceiptPolicy)) - { - os << ","<< endl; - Indent (os, indentG); - os << "mlReceiptPolicy "; - os << *mlReceiptPolicy; - } - else - { - Indent (os, indentG); - os << "mlReceiptPolicy "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // MLData::Print - - -ReceiptRequest::ReceiptRequest() -{ -#if TCL - receiptsFrom = new ReceiptsFrom; -#else - receiptsFrom = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -ReceiptRequest::ReceiptRequest (const ReceiptRequest &) -{ - Asn1Error << "use of incompletely defined ReceiptRequest::ReceiptRequest (const ReceiptRequest &)" << endl; - abort(); -} - -ReceiptRequest::~ReceiptRequest() -{ - delete receiptsFrom; -} - -AsnType *ReceiptRequest::Clone() const -{ - return new ReceiptRequest; -} - -AsnType *ReceiptRequest::Copy() const -{ - return new ReceiptRequest (*this); -} - -#if SNACC_DEEP_COPY -ReceiptRequest &ReceiptRequest::operator = (const ReceiptRequest &that) -#else // SNACC_DEEP_COPY -ReceiptRequest &ReceiptRequest::operator = (const ReceiptRequest &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - signedContentIdentifier = that.signedContentIdentifier; - if (that.receiptsFrom) - { - if (!receiptsFrom) - receiptsFrom = new ReceiptsFrom; - *receiptsFrom = *that.receiptsFrom; - } - else - { - delete receiptsFrom; - receiptsFrom = NULL; - } - receiptsTo = that.receiptsTo; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ReceiptRequest &ReceiptRequest::operator = (const ReceiptRequest &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ReceiptRequest::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = receiptsTo.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = receiptsFrom->BEncContent (b); - totalLen += l; - - l = signedContentIdentifier.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - return totalLen; -} // ReceiptRequest::BEncContent - - -void ReceiptRequest::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signedContentIdentifier.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-132); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - receiptsFrom = new ReceiptsFrom; - receiptsFrom->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-133); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - receiptsTo.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-134); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-135); - } - else - return; -} // ReceiptRequest::BDecContent - -AsnLen ReceiptRequest::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ReceiptRequest::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ReceiptRequest::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-136); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ReceiptRequest::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "signedContentIdentifier "; - os << signedContentIdentifier; - os << "," << endl; - } - - if (NOT_NULL (receiptsFrom)) - { - Indent (os, indentG); - os << "receiptsFrom "; - os << *receiptsFrom; - } - else - { - Indent (os, indentG); - os << "receiptsFrom "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "receiptsTo "; - os << receiptsTo; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ReceiptRequest::Print - - -Receipt::Receipt() -{ -} - -Receipt::Receipt (const Receipt &) -{ - Asn1Error << "use of incompletely defined Receipt::Receipt (const Receipt &)" << endl; - abort(); -} - -Receipt::~Receipt() -{ -} - -AsnType *Receipt::Clone() const -{ - return new Receipt; -} - -AsnType *Receipt::Copy() const -{ - return new Receipt (*this); -} - -#if SNACC_DEEP_COPY -Receipt &Receipt::operator = (const Receipt &that) -#else // SNACC_DEEP_COPY -Receipt &Receipt::operator = (const Receipt &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - version = that.version; - contentType = that.contentType; - signedContentIdentifier = that.signedContentIdentifier; - originatorSignatureValue = that.originatorSignatureValue; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Receipt &Receipt::operator = (const Receipt &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -Receipt::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = originatorSignatureValue.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - l = signedContentIdentifier.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - l = contentType.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - l = version.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // Receipt::BEncContent - - -void Receipt::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-137); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-138); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signedContentIdentifier.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-139); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - originatorSignatureValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-140); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-141); - } - else - return; -} // Receipt::BDecContent - -AsnLen Receipt::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void Receipt::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Receipt::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-142); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void Receipt::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "version "; - os << version; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "contentType "; - os << contentType; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signedContentIdentifier "; - os << signedContentIdentifier; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "originatorSignatureValue "; - os << originatorSignatureValue; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // Receipt::Print - - -ContentHints::ContentHints() -{ - contentDescription = NULL; -} - -ContentHints::ContentHints (const ContentHints &) -{ - Asn1Error << "use of incompletely defined ContentHints::ContentHints (const ContentHints &)" << endl; - abort(); -} - -ContentHints::~ContentHints() -{ - delete contentDescription; -} - -AsnType *ContentHints::Clone() const -{ - return new ContentHints; -} - -AsnType *ContentHints::Copy() const -{ - return new ContentHints (*this); -} - -#if SNACC_DEEP_COPY -ContentHints &ContentHints::operator = (const ContentHints &that) -#else // SNACC_DEEP_COPY -ContentHints &ContentHints::operator = (const ContentHints &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.contentDescription) - { - if (!contentDescription) - contentDescription = new UTF8String; - *contentDescription = *that.contentDescription; - } - else - { - delete contentDescription; - contentDescription = NULL; - } - contentType = that.contentType; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ContentHints &ContentHints::operator = (const ContentHints &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ContentHints::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = contentType.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - if (NOT_NULL (contentDescription)) - { - l = contentDescription->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, 12); - totalLen += l; - } - - return totalLen; -} // ContentHints::BEncContent - - -void ContentHints::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, 12)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, 12))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentDescription = new UTF8String; - contentDescription->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-143); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-144); - } - else - return; -} // ContentHints::BDecContent - -AsnLen ContentHints::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ContentHints::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ContentHints::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-145); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ContentHints::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (contentDescription)) - { - Indent (os, indentG); - os << "contentDescription "; - os << *contentDescription; - } - else - { - Indent (os, indentG); - os << "contentDescription "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "contentType "; - os << contentType; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ContentHints::Print - - -ContentReference::ContentReference() -{ -} - -ContentReference::ContentReference (const ContentReference &) -{ - Asn1Error << "use of incompletely defined ContentReference::ContentReference (const ContentReference &)" << endl; - abort(); -} - -ContentReference::~ContentReference() -{ -} - -AsnType *ContentReference::Clone() const -{ - return new ContentReference; -} - -AsnType *ContentReference::Copy() const -{ - return new ContentReference (*this); -} - -#if SNACC_DEEP_COPY -ContentReference &ContentReference::operator = (const ContentReference &that) -#else // SNACC_DEEP_COPY -ContentReference &ContentReference::operator = (const ContentReference &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - contentType = that.contentType; - signedContentIdentifier = that.signedContentIdentifier; - originatorSignatureValue = that.originatorSignatureValue; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ContentReference &ContentReference::operator = (const ContentReference &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ContentReference::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = originatorSignatureValue.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - l = signedContentIdentifier.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - l = contentType.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // ContentReference::BEncContent - - -void ContentReference::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contentType.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-146); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signedContentIdentifier.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-147); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - originatorSignatureValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-148); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-149); - } - else - return; -} // ContentReference::BDecContent - -AsnLen ContentReference::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ContentReference::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ContentReference::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-150); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ContentReference::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "contentType "; - os << contentType; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signedContentIdentifier "; - os << signedContentIdentifier; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "originatorSignatureValue "; - os << originatorSignatureValue; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ContentReference::Print - - -AsnType *EquivalentLabels::Clone() const -{ - return new EquivalentLabels; -} - -AsnType *EquivalentLabels::Copy() const -{ - return new EquivalentLabels (*this); -} - -AsnLen EquivalentLabels::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EquivalentLabels::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EquivalentLabels::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-151); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -EquivalentLabels::EquivalentLabels (const EquivalentLabels &) -{ - Asn1Error << "use of incompletely defined EquivalentLabels::EquivalentLabels (const EquivalentLabels &)" << endl; - abort(); -} - -EquivalentLabels::~EquivalentLabels() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -EquivalentLabels &EquivalentLabels::operator = (const EquivalentLabels &that) -#else // SNACC_DEEP_COPY -EquivalentLabels &EquivalentLabels::operator = (const EquivalentLabels &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EquivalentLabels &EquivalentLabels::operator = (const EquivalentLabels &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void EquivalentLabels::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void EquivalentLabels::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // EquivalentLabels::SetCurrElmt - - -unsigned long int EquivalentLabels::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // EquivalentLabels::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -ESSSecurityLabel *EquivalentLabels::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSSecurityLabel; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // EquivalentLabels::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -ESSSecurityLabel *EquivalentLabels::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSSecurityLabel; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // EquivalentLabels::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -ESSSecurityLabel *EquivalentLabels::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSSecurityLabel; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // EquivalentLabels::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ESSSecurityLabel *EquivalentLabels::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSSecurityLabel; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // EquivalentLabels::InsertAfter - - -EquivalentLabels &EquivalentLabels::AppendCopy (ESSSecurityLabel &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSSecurityLabel; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -EquivalentLabels &EquivalentLabels::PrependCopy (ESSSecurityLabel &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ESSSecurityLabel; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // EquivalentLabels::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -EquivalentLabels &EquivalentLabels::InsertBeforeAndCopy (ESSSecurityLabel &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new ESSSecurityLabel; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // EquivalentLabels::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -EquivalentLabels &EquivalentLabels::InsertAfterAndCopy (ESSSecurityLabel &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new ESSSecurityLabel; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // EquivalentLabels::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void EquivalentLabels::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen EquivalentLabels::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // EquivalentLabels::BEncContent - - -void EquivalentLabels::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - ESSSecurityLabel *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-152); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // EquivalentLabels::BDecContent - - -AsnType *MLExpansionHistory::Clone() const -{ - return new MLExpansionHistory; -} - -AsnType *MLExpansionHistory::Copy() const -{ - return new MLExpansionHistory (*this); -} - -AsnLen MLExpansionHistory::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void MLExpansionHistory::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "MLExpansionHistory::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-153); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -MLExpansionHistory::MLExpansionHistory (const MLExpansionHistory &) -{ - Asn1Error << "use of incompletely defined MLExpansionHistory::MLExpansionHistory (const MLExpansionHistory &)" << endl; - abort(); -} - -MLExpansionHistory::~MLExpansionHistory() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -MLExpansionHistory &MLExpansionHistory::operator = (const MLExpansionHistory &that) -#else // SNACC_DEEP_COPY -MLExpansionHistory &MLExpansionHistory::operator = (const MLExpansionHistory &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined MLExpansionHistory &MLExpansionHistory::operator = (const MLExpansionHistory &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void MLExpansionHistory::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void MLExpansionHistory::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // MLExpansionHistory::SetCurrElmt - - -unsigned long int MLExpansionHistory::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // MLExpansionHistory::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -MLData *MLExpansionHistory::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new MLData; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLExpansionHistory::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -MLData *MLExpansionHistory::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new MLData; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLExpansionHistory::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -MLData *MLExpansionHistory::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new MLData; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLExpansionHistory::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -MLData *MLExpansionHistory::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new MLData; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // MLExpansionHistory::InsertAfter - - -MLExpansionHistory &MLExpansionHistory::AppendCopy (MLData &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new MLData; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -MLExpansionHistory &MLExpansionHistory::PrependCopy (MLData &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new MLData; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // MLExpansionHistory::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -MLExpansionHistory &MLExpansionHistory::InsertBeforeAndCopy (MLData &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new MLData; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // MLExpansionHistory::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -MLExpansionHistory &MLExpansionHistory::InsertAfterAndCopy (MLData &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new MLData; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // MLExpansionHistory::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void MLExpansionHistory::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen MLExpansionHistory::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // MLExpansionHistory::BEncContent - - -void MLExpansionHistory::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - MLData *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-154); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // MLExpansionHistory::BDecContent - - -SigningCertificate::SigningCertificate() -{ - policies = NULL; -} - -SigningCertificate::SigningCertificate (const SigningCertificate &) -{ - Asn1Error << "use of incompletely defined SigningCertificate::SigningCertificate (const SigningCertificate &)" << endl; - abort(); -} - -SigningCertificate::~SigningCertificate() -{ - delete policies; -} - -AsnType *SigningCertificate::Clone() const -{ - return new SigningCertificate; -} - -AsnType *SigningCertificate::Copy() const -{ - return new SigningCertificate (*this); -} - -#if SNACC_DEEP_COPY -SigningCertificate &SigningCertificate::operator = (const SigningCertificate &that) -#else // SNACC_DEEP_COPY -SigningCertificate &SigningCertificate::operator = (const SigningCertificate &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - certs = that.certs; - if (that.policies) - { - if (!policies) - policies = new SigningCertificateSeqOf1; - *policies = *that.policies; - } - else - { - delete policies; - policies = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SigningCertificate &SigningCertificate::operator = (const SigningCertificate &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -SigningCertificate::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (policies)) - { - BEncEocIfNec (b); - l = policies->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - BEncEocIfNec (b); - l = certs.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // SigningCertificate::BEncContent - - -void SigningCertificate::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - certs.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-155); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - policies = new SigningCertificateSeqOf1; - policies->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-156); - } - else - return; -} // SigningCertificate::BDecContent - -AsnLen SigningCertificate::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void SigningCertificate::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "SigningCertificate::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-157); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void SigningCertificate::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "certs "; - os << certs; - os << "," << endl; - } - - if (NOT_NULL (policies)) - { - os << ","<< endl; - Indent (os, indentG); - os << "policies "; - os << *policies; - } - else - { - Indent (os, indentG); - os << "policies "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // SigningCertificate::Print - - diff --git a/SecurityASN1/c++/sm_vdatypes.cpp b/SecurityASN1/c++/sm_vdatypes.cpp deleted file mode 100644 index cd1aa974..00000000 --- a/SecurityASN1/c++/sm_vdatypes.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_vdatypes.cpp - class member functions for ASN.1 module VdaEnhancedTypes -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -AsnType *BigIntegerStr::Clone() const -{ - return new BigIntegerStr; -} - -AsnType *BigIntegerStr::Copy() const -{ - return new BigIntegerStr (*this); -} - -AsnLen BigIntegerStr::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - return l; -} - -void BigIntegerStr::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - Asn1Error << "BigIntegerStr::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-100); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - diff --git a/SecurityASN1/c++/sm_x411mtsas.cpp b/SecurityASN1/c++/sm_x411mtsas.cpp deleted file mode 100644 index f73d660b..00000000 --- a/SecurityASN1/c++/sm_x411mtsas.cpp +++ /dev/null @@ -1,4836 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x411mtsas.cpp - class member functions for ASN.1 module MTSAbstractService -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -CountryName::CountryName() -{ - choiceId = x121_dcc_codeCid; -#if TCL - x121_dcc_code = new NumericString; -#else - x121_dcc_code = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -CountryName::CountryName (const CountryName &) -{ - Asn1Error << "use of incompletely defined CountryName::CountryName (const CountryName &)" << endl; - abort(); -} - -CountryName::~CountryName() -{ - switch (choiceId) - { - case x121_dcc_codeCid: - delete x121_dcc_code; - break; - case iso_3166_alpha2_codeCid: - delete iso_3166_alpha2_code; - break; - } // end of switch -} // end of destructor - -AsnType *CountryName::Clone() const -{ - return new CountryName; -} - -AsnType *CountryName::Copy() const -{ - return new CountryName (*this); -} - -#if SNACC_DEEP_COPY -CountryName &CountryName::operator = (const CountryName &that) -#else // SNACC_DEEP_COPY -CountryName &CountryName::operator = (const CountryName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case x121_dcc_codeCid: - delete x121_dcc_code; - break; - case iso_3166_alpha2_codeCid: - delete iso_3166_alpha2_code; - break; - } - switch (choiceId = that.choiceId) - { - case x121_dcc_codeCid: - x121_dcc_code = new NumericString; - *x121_dcc_code = *that.x121_dcc_code; - break; - case iso_3166_alpha2_codeCid: - iso_3166_alpha2_code = new PrintableString; - *iso_3166_alpha2_code = *that.iso_3166_alpha2_code; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CountryName &CountryName::operator = (const CountryName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CountryName::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case x121_dcc_codeCid: - l = x121_dcc_code->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); - break; - - case iso_3166_alpha2_codeCid: - l = iso_3166_alpha2_code->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - break; - - } // end switch - return l; -} // CountryName::BEncContent - - -void CountryName::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE): - choiceId = x121_dcc_codeCid; - x121_dcc_code = new NumericString; - x121_dcc_code->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE): - choiceId = iso_3166_alpha2_codeCid; - iso_3166_alpha2_code = new PrintableString; - iso_3166_alpha2_code->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-100); - break; - } // end switch -} // CountryName::BDecContent - - -AsnLen CountryName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, APPL, CONS, 1); - return l; -} - -void CountryName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - AsnLen extraLen1; - - if (BDecTag (b, bytesDecoded, env) != MAKE_TAG_ID (APPL, CONS, 1)) { - Asn1Error << "CountryName::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-101); - } - extraLen1 = BDecLen (b, bytesDecoded, env); - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); - if (extraLen1 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); -} - -void CountryName::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case x121_dcc_codeCid: - os << "x121-dcc-code "; - if (x121_dcc_code) - os << *x121_dcc_code; - else - os << "-- void3 --\n"; - break; - - case iso_3166_alpha2_codeCid: - os << "iso-3166-alpha2-code "; - if (iso_3166_alpha2_code) - os << *iso_3166_alpha2_code; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // CountryName::Print - -AdministrationDomainName::AdministrationDomainName() -{ - choiceId = numericCid; -#if TCL - numeric = new NumericString; -#else - numeric = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -AdministrationDomainName::AdministrationDomainName (const AdministrationDomainName &) -{ - Asn1Error << "use of incompletely defined AdministrationDomainName::AdministrationDomainName (const AdministrationDomainName &)" << endl; - abort(); -} - -AdministrationDomainName::~AdministrationDomainName() -{ - switch (choiceId) - { - case numericCid: - delete numeric; - break; - case printableCid: - delete printable; - break; - } // end of switch -} // end of destructor - -AsnType *AdministrationDomainName::Clone() const -{ - return new AdministrationDomainName; -} - -AsnType *AdministrationDomainName::Copy() const -{ - return new AdministrationDomainName (*this); -} - -#if SNACC_DEEP_COPY -AdministrationDomainName &AdministrationDomainName::operator = (const AdministrationDomainName &that) -#else // SNACC_DEEP_COPY -AdministrationDomainName &AdministrationDomainName::operator = (const AdministrationDomainName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case numericCid: - delete numeric; - break; - case printableCid: - delete printable; - break; - } - switch (choiceId = that.choiceId) - { - case numericCid: - numeric = new NumericString; - *numeric = *that.numeric; - break; - case printableCid: - printable = new PrintableString; - *printable = *that.printable; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AdministrationDomainName &AdministrationDomainName::operator = (const AdministrationDomainName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AdministrationDomainName::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case numericCid: - l = numeric->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); - break; - - case printableCid: - l = printable->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - break; - - } // end switch - return l; -} // AdministrationDomainName::BEncContent - - -void AdministrationDomainName::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE): - choiceId = numericCid; - numeric = new NumericString; - numeric->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE): - choiceId = printableCid; - printable = new PrintableString; - printable->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-102); - break; - } // end switch -} // AdministrationDomainName::BDecContent - - -AsnLen AdministrationDomainName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, APPL, CONS, 2); - return l; -} - -void AdministrationDomainName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - AsnLen extraLen1; - - if (BDecTag (b, bytesDecoded, env) != MAKE_TAG_ID (APPL, CONS, 2)) { - Asn1Error << "AdministrationDomainName::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-103); - } - extraLen1 = BDecLen (b, bytesDecoded, env); - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); - if (extraLen1 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); -} - -void AdministrationDomainName::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case numericCid: - os << "numeric "; - if (numeric) - os << *numeric; - else - os << "-- void3 --\n"; - break; - - case printableCid: - os << "printable "; - if (printable) - os << *printable; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // AdministrationDomainName::Print - -PrivateDomainName::PrivateDomainName() -{ - choiceId = numericCid; -#if TCL - numeric = new NumericString; -#else - numeric = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -PrivateDomainName::PrivateDomainName (const PrivateDomainName &) -{ - Asn1Error << "use of incompletely defined PrivateDomainName::PrivateDomainName (const PrivateDomainName &)" << endl; - abort(); -} - -PrivateDomainName::~PrivateDomainName() -{ - switch (choiceId) - { - case numericCid: - delete numeric; - break; - case printableCid: - delete printable; - break; - } // end of switch -} // end of destructor - -AsnType *PrivateDomainName::Clone() const -{ - return new PrivateDomainName; -} - -AsnType *PrivateDomainName::Copy() const -{ - return new PrivateDomainName (*this); -} - -#if SNACC_DEEP_COPY -PrivateDomainName &PrivateDomainName::operator = (const PrivateDomainName &that) -#else // SNACC_DEEP_COPY -PrivateDomainName &PrivateDomainName::operator = (const PrivateDomainName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case numericCid: - delete numeric; - break; - case printableCid: - delete printable; - break; - } - switch (choiceId = that.choiceId) - { - case numericCid: - numeric = new NumericString; - *numeric = *that.numeric; - break; - case printableCid: - printable = new PrintableString; - *printable = *that.printable; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PrivateDomainName &PrivateDomainName::operator = (const PrivateDomainName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -PrivateDomainName::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case numericCid: - l = numeric->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); - break; - - case printableCid: - l = printable->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - break; - - } // end switch - return l; -} // PrivateDomainName::BEncContent - - -void PrivateDomainName::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE): - choiceId = numericCid; - numeric = new NumericString; - numeric->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE): - choiceId = printableCid; - printable = new PrintableString; - printable->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-104); - break; - } // end switch -} // PrivateDomainName::BDecContent - - -AsnLen PrivateDomainName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void PrivateDomainName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void PrivateDomainName::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case numericCid: - os << "numeric "; - if (numeric) - os << *numeric; - else - os << "-- void3 --\n"; - break; - - case printableCid: - os << "printable "; - if (printable) - os << *printable; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // PrivateDomainName::Print - -PersonalName::PersonalName() -{ - given_name = NULL; - initials = NULL; - generation_qualifier = NULL; -} - -PersonalName::PersonalName (const PersonalName &) -{ - Asn1Error << "use of incompletely defined PersonalName::PersonalName (const PersonalName &)" << endl; - abort(); -} - -PersonalName::~PersonalName() -{ - delete given_name; - delete initials; - delete generation_qualifier; -} - -AsnType *PersonalName::Clone() const -{ - return new PersonalName; -} - -AsnType *PersonalName::Copy() const -{ - return new PersonalName (*this); -} - -#if SNACC_DEEP_COPY -PersonalName &PersonalName::operator = (const PersonalName &that) -#else // SNACC_DEEP_COPY -PersonalName &PersonalName::operator = (const PersonalName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - surname = that.surname; - if (that.given_name) - { - if (!given_name) - given_name = new PrintableString; - *given_name = *that.given_name; - } - else - { - delete given_name; - given_name = NULL; - } - if (that.initials) - { - if (!initials) - initials = new PrintableString; - *initials = *that.initials; - } - else - { - delete initials; - initials = NULL; - } - if (that.generation_qualifier) - { - if (!generation_qualifier) - generation_qualifier = new PrintableString; - *generation_qualifier = *that.generation_qualifier; - } - else - { - delete generation_qualifier; - generation_qualifier = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PersonalName &PersonalName::operator = (const PersonalName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen PersonalName::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - AsnBuf outputBuf; - int iii=0, tmpCount=0; - char *lpszBuf = (char *)calloc(1, 1024); - outputBuf.Init(lpszBuf, 1024); - outputBuf.ResetInWriteRvsMode(); - CSM_Buffer *tmpEnc[4]; - if (NOT_NULL (generation_qualifier)) - { - l = generation_qualifier->BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, CNTX, PRIM, 3); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - if (NOT_NULL (initials)) - { - l = initials->BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, CNTX, PRIM, 2); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - if (NOT_NULL (given_name)) - { - l = given_name->BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, CNTX, PRIM, 1); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - l = surname.BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, CNTX, PRIM, 0); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - - vdasnacc_sortSet(tmpEnc, iii); - tmpCount = iii; /** REMEMBER how many we have**/ - for (iii=0; iii < tmpCount; iii++) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < tmpCount; iii++) delete tmpEnc[iii]; - free(lpszBuf); - return totalLen; -} // PersonalName::BEncContent - - -void PersonalName::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen setBytesDecoded = 0; - unsigned int mandatoryElmtsDecoded = 0; - AsnLen elmtLen1; - - for (; (setBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN); ) - { - tag1 = BDecTag (b, setBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, setBytesDecoded, env) - break; /* exit for loop */ - } - elmtLen1 = BDecLen (b, setBytesDecoded, env); - switch (tag1) - { - case MAKE_TAG_ID (CNTX, PRIM, 0): - case MAKE_TAG_ID (CNTX, CONS, 0): - surname.BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - mandatoryElmtsDecoded++; - break; - - case MAKE_TAG_ID (CNTX, PRIM, 1): - case MAKE_TAG_ID (CNTX, CONS, 1): - given_name = new PrintableString; - given_name->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 2): - case MAKE_TAG_ID (CNTX, CONS, 2): - initials = new PrintableString; - initials->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 3): - case MAKE_TAG_ID (CNTX, CONS, 3): - generation_qualifier = new PrintableString; - generation_qualifier->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - default: - Asn1Error << "Unexpected Tag on SET elmt." << endl; - SnaccExcep::throwMe(-105); - } // end switch - } // end for loop - bytesDecoded += setBytesDecoded; - if (mandatoryElmtsDecoded != 1) - { - Asn1Error << "ERROR - non-optional SET element missing." << endl; - SnaccExcep::throwMe(-106); - } -} // PersonalName::BDecContent - -AsnLen -PersonalName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void PersonalName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "PersonalName::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-107); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void PersonalName::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SET --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "surname "; - os << surname; - } - - if (NOT_NULL (given_name)) - { - os << ","<< endl; - Indent (os, indentG); - os << "given-name "; - os << *given_name; - } - else - os << "-- void2 --\n"; - - if (NOT_NULL (initials)) - { - os << ","<< endl; - Indent (os, indentG); - os << "initials "; - os << *initials; - } - else - os << "-- void2 --\n"; - - if (NOT_NULL (generation_qualifier)) - { - os << ","<< endl; - Indent (os, indentG); - os << "generation-qualifier "; - os << *generation_qualifier; - } - else - os << "-- void2 --\n"; - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // PersonalName - operator << - - -DomainDefinedAttribute::DomainDefinedAttribute() -{ -} - -DomainDefinedAttribute::DomainDefinedAttribute (const DomainDefinedAttribute &) -{ - Asn1Error << "use of incompletely defined DomainDefinedAttribute::DomainDefinedAttribute (const DomainDefinedAttribute &)" << endl; - abort(); -} - -DomainDefinedAttribute::~DomainDefinedAttribute() -{ -} - -AsnType *DomainDefinedAttribute::Clone() const -{ - return new DomainDefinedAttribute; -} - -AsnType *DomainDefinedAttribute::Copy() const -{ - return new DomainDefinedAttribute (*this); -} - -#if SNACC_DEEP_COPY -DomainDefinedAttribute &DomainDefinedAttribute::operator = (const DomainDefinedAttribute &that) -#else // SNACC_DEEP_COPY -DomainDefinedAttribute &DomainDefinedAttribute::operator = (const DomainDefinedAttribute &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - type = that.type; - value = that.value; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DomainDefinedAttribute &DomainDefinedAttribute::operator = (const DomainDefinedAttribute &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DomainDefinedAttribute::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = value.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - totalLen += l; - - l = type.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - totalLen += l; - - return totalLen; -} // DomainDefinedAttribute::BEncContent - - -void DomainDefinedAttribute::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - type.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-108); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - value.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-109); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-110); - } - else - return; -} // DomainDefinedAttribute::BDecContent - -AsnLen DomainDefinedAttribute::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DomainDefinedAttribute::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DomainDefinedAttribute::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-111); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DomainDefinedAttribute::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "type "; - os << type; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "value "; - os << value; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DomainDefinedAttribute::Print - - -ExtensionAttribute::ExtensionAttribute() -{ -} - -ExtensionAttribute::ExtensionAttribute (const ExtensionAttribute &) -{ - Asn1Error << "use of incompletely defined ExtensionAttribute::ExtensionAttribute (const ExtensionAttribute &)" << endl; - abort(); -} - -ExtensionAttribute::~ExtensionAttribute() -{ -} - -AsnType *ExtensionAttribute::Clone() const -{ - return new ExtensionAttribute; -} - -AsnType *ExtensionAttribute::Copy() const -{ - return new ExtensionAttribute (*this); -} - -#if SNACC_DEEP_COPY -ExtensionAttribute &ExtensionAttribute::operator = (const ExtensionAttribute &that) -#else // SNACC_DEEP_COPY -ExtensionAttribute &ExtensionAttribute::operator = (const ExtensionAttribute &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - extension_attribute_type = that.extension_attribute_type; - extension_attribute_value = that.extension_attribute_value; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ExtensionAttribute &ExtensionAttribute::operator = (const ExtensionAttribute &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ExtensionAttribute::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - ENC_LOAD_ANYBUF(&extension_attribute_value, b, l); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - - l = extension_attribute_type.BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - - return totalLen; -} // ExtensionAttribute::BEncContent - - -void ExtensionAttribute::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - extension_attribute_type.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-112); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - DEC_LOAD_ANYBUF(&extension_attribute_value, b, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-113); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-114); - } - else - return; -} // ExtensionAttribute::BDecContent - -AsnLen ExtensionAttribute::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ExtensionAttribute::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ExtensionAttribute::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-115); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ExtensionAttribute::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "extension-attribute-type "; - os << extension_attribute_type; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "extension-attribute-value "; - os << extension_attribute_value; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ExtensionAttribute::Print - - -TeletexDomainDefinedAttribute::TeletexDomainDefinedAttribute() -{ -} - -TeletexDomainDefinedAttribute::TeletexDomainDefinedAttribute (const TeletexDomainDefinedAttribute &) -{ - Asn1Error << "use of incompletely defined TeletexDomainDefinedAttribute::TeletexDomainDefinedAttribute (const TeletexDomainDefinedAttribute &)" << endl; - abort(); -} - -TeletexDomainDefinedAttribute::~TeletexDomainDefinedAttribute() -{ -} - -AsnType *TeletexDomainDefinedAttribute::Clone() const -{ - return new TeletexDomainDefinedAttribute; -} - -AsnType *TeletexDomainDefinedAttribute::Copy() const -{ - return new TeletexDomainDefinedAttribute (*this); -} - -#if SNACC_DEEP_COPY -TeletexDomainDefinedAttribute &TeletexDomainDefinedAttribute::operator = (const TeletexDomainDefinedAttribute &that) -#else // SNACC_DEEP_COPY -TeletexDomainDefinedAttribute &TeletexDomainDefinedAttribute::operator = (const TeletexDomainDefinedAttribute &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - type = that.type; - value = that.value; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined TeletexDomainDefinedAttribute &TeletexDomainDefinedAttribute::operator = (const TeletexDomainDefinedAttribute &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -TeletexDomainDefinedAttribute::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = value.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - totalLen += l; - - l = type.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - totalLen += l; - - return totalLen; -} // TeletexDomainDefinedAttribute::BEncContent - - -void TeletexDomainDefinedAttribute::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - type.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-116); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - value.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-117); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-118); - } - else - return; -} // TeletexDomainDefinedAttribute::BDecContent - -AsnLen TeletexDomainDefinedAttribute::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void TeletexDomainDefinedAttribute::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "TeletexDomainDefinedAttribute::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-119); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void TeletexDomainDefinedAttribute::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "type "; - os << type; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "value "; - os << value; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // TeletexDomainDefinedAttribute::Print - - -AsnType *OrganizationUnitNames::Clone() const -{ - return new OrganizationUnitNames; -} - -AsnType *OrganizationUnitNames::Copy() const -{ - return new OrganizationUnitNames (*this); -} - -AsnLen OrganizationUnitNames::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void OrganizationUnitNames::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "OrganizationUnitNames::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-120); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -OrganizationUnitNames::OrganizationUnitNames (const OrganizationUnitNames &) -{ - Asn1Error << "use of incompletely defined OrganizationUnitNames::OrganizationUnitNames (const OrganizationUnitNames &)" << endl; - abort(); -} - -OrganizationUnitNames::~OrganizationUnitNames() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -OrganizationUnitNames &OrganizationUnitNames::operator = (const OrganizationUnitNames &that) -#else // SNACC_DEEP_COPY -OrganizationUnitNames &OrganizationUnitNames::operator = (const OrganizationUnitNames &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined OrganizationUnitNames &OrganizationUnitNames::operator = (const OrganizationUnitNames &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void OrganizationUnitNames::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void OrganizationUnitNames::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // OrganizationUnitNames::SetCurrElmt - - -unsigned long int OrganizationUnitNames::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // OrganizationUnitNames::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -OrganizationUnitName *OrganizationUnitNames::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new OrganizationUnitName; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // OrganizationUnitNames::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -OrganizationUnitName *OrganizationUnitNames::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new OrganizationUnitName; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // OrganizationUnitNames::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -OrganizationUnitName *OrganizationUnitNames::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new OrganizationUnitName; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // OrganizationUnitNames::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -OrganizationUnitName *OrganizationUnitNames::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new OrganizationUnitName; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // OrganizationUnitNames::InsertAfter - - -OrganizationUnitNames &OrganizationUnitNames::AppendCopy (OrganizationUnitName &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new OrganizationUnitName; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -OrganizationUnitNames &OrganizationUnitNames::PrependCopy (OrganizationUnitName &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new OrganizationUnitName; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // OrganizationUnitNames::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -OrganizationUnitNames &OrganizationUnitNames::InsertBeforeAndCopy (OrganizationUnitName &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new OrganizationUnitName; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // OrganizationUnitNames::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -OrganizationUnitNames &OrganizationUnitNames::InsertAfterAndCopy (OrganizationUnitName &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new OrganizationUnitName; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // OrganizationUnitNames::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void OrganizationUnitNames::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen OrganizationUnitNames::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncDefLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // OrganizationUnitNames::BEncContent - - -void OrganizationUnitNames::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - OrganizationUnitName *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) - && (tag1 != MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-121); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // OrganizationUnitNames::BDecContent - - -AsnType *DomainDefinedAttributes::Clone() const -{ - return new DomainDefinedAttributes; -} - -AsnType *DomainDefinedAttributes::Copy() const -{ - return new DomainDefinedAttributes (*this); -} - -AsnLen DomainDefinedAttributes::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DomainDefinedAttributes::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DomainDefinedAttributes::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-122); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -DomainDefinedAttributes::DomainDefinedAttributes (const DomainDefinedAttributes &) -{ - Asn1Error << "use of incompletely defined DomainDefinedAttributes::DomainDefinedAttributes (const DomainDefinedAttributes &)" << endl; - abort(); -} - -DomainDefinedAttributes::~DomainDefinedAttributes() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -DomainDefinedAttributes &DomainDefinedAttributes::operator = (const DomainDefinedAttributes &that) -#else // SNACC_DEEP_COPY -DomainDefinedAttributes &DomainDefinedAttributes::operator = (const DomainDefinedAttributes &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DomainDefinedAttributes &DomainDefinedAttributes::operator = (const DomainDefinedAttributes &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void DomainDefinedAttributes::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void DomainDefinedAttributes::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // DomainDefinedAttributes::SetCurrElmt - - -unsigned long int DomainDefinedAttributes::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // DomainDefinedAttributes::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -DomainDefinedAttribute *DomainDefinedAttributes::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DomainDefinedAttribute; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // DomainDefinedAttributes::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -DomainDefinedAttribute *DomainDefinedAttributes::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DomainDefinedAttribute; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // DomainDefinedAttributes::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -DomainDefinedAttribute *DomainDefinedAttributes::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DomainDefinedAttribute; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // DomainDefinedAttributes::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -DomainDefinedAttribute *DomainDefinedAttributes::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DomainDefinedAttribute; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // DomainDefinedAttributes::InsertAfter - - -DomainDefinedAttributes &DomainDefinedAttributes::AppendCopy (DomainDefinedAttribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DomainDefinedAttribute; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -DomainDefinedAttributes &DomainDefinedAttributes::PrependCopy (DomainDefinedAttribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DomainDefinedAttribute; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // DomainDefinedAttributes::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -DomainDefinedAttributes &DomainDefinedAttributes::InsertBeforeAndCopy (DomainDefinedAttribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new DomainDefinedAttribute; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // DomainDefinedAttributes::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -DomainDefinedAttributes &DomainDefinedAttributes::InsertAfterAndCopy (DomainDefinedAttribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new DomainDefinedAttribute; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // DomainDefinedAttributes::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void DomainDefinedAttributes::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen DomainDefinedAttributes::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // DomainDefinedAttributes::BEncContent - - -void DomainDefinedAttributes::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - DomainDefinedAttribute *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-123); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // DomainDefinedAttributes::BDecContent - - -AsnType *ExtensionAttributes::Clone() const -{ - return new ExtensionAttributes; -} - -AsnType *ExtensionAttributes::Copy() const -{ - return new ExtensionAttributes (*this); -} - -AsnLen ExtensionAttributes::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void ExtensionAttributes::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "ExtensionAttributes::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-124); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -ExtensionAttributes::ExtensionAttributes (const ExtensionAttributes &) -{ - Asn1Error << "use of incompletely defined ExtensionAttributes::ExtensionAttributes (const ExtensionAttributes &)" << endl; - abort(); -} - -ExtensionAttributes::~ExtensionAttributes() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -ExtensionAttributes &ExtensionAttributes::operator = (const ExtensionAttributes &that) -#else // SNACC_DEEP_COPY -ExtensionAttributes &ExtensionAttributes::operator = (const ExtensionAttributes &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ExtensionAttributes &ExtensionAttributes::operator = (const ExtensionAttributes &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void ExtensionAttributes::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void ExtensionAttributes::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // ExtensionAttributes::SetCurrElmt - - -unsigned long int ExtensionAttributes::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // ExtensionAttributes::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -ExtensionAttribute *ExtensionAttributes::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ExtensionAttribute; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ExtensionAttributes::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -ExtensionAttribute *ExtensionAttributes::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ExtensionAttribute; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ExtensionAttributes::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -ExtensionAttribute *ExtensionAttributes::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ExtensionAttribute; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ExtensionAttributes::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ExtensionAttribute *ExtensionAttributes::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ExtensionAttribute; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ExtensionAttributes::InsertAfter - - -ExtensionAttributes &ExtensionAttributes::AppendCopy (ExtensionAttribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ExtensionAttribute; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -ExtensionAttributes &ExtensionAttributes::PrependCopy (ExtensionAttribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ExtensionAttribute; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // ExtensionAttributes::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -ExtensionAttributes &ExtensionAttributes::InsertBeforeAndCopy (ExtensionAttribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new ExtensionAttribute; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // ExtensionAttributes::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ExtensionAttributes &ExtensionAttributes::InsertAfterAndCopy (ExtensionAttribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new ExtensionAttribute; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // ExtensionAttributes::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void ExtensionAttributes::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen ExtensionAttributes::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // ExtensionAttributes::BEncContent - - -void ExtensionAttributes::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - ExtensionAttribute *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-125); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // ExtensionAttributes::BDecContent - - -StandardAttributes::StandardAttributes() -{ - country_name = NULL; - administration_domain_name = NULL; - network_address = NULL; - terminal_identifier = NULL; - private_domain_name = NULL; - organization_name = NULL; - numeric_user_identifier = NULL; - personal_name = NULL; - organizational_unit_names = NULL; -} - -StandardAttributes::StandardAttributes (const StandardAttributes &) -{ - Asn1Error << "use of incompletely defined StandardAttributes::StandardAttributes (const StandardAttributes &)" << endl; - abort(); -} - -StandardAttributes::~StandardAttributes() -{ - delete country_name; - delete administration_domain_name; - delete network_address; - delete terminal_identifier; - delete private_domain_name; - delete organization_name; - delete numeric_user_identifier; - delete personal_name; - delete organizational_unit_names; -} - -AsnType *StandardAttributes::Clone() const -{ - return new StandardAttributes; -} - -AsnType *StandardAttributes::Copy() const -{ - return new StandardAttributes (*this); -} - -#if SNACC_DEEP_COPY -StandardAttributes &StandardAttributes::operator = (const StandardAttributes &that) -#else // SNACC_DEEP_COPY -StandardAttributes &StandardAttributes::operator = (const StandardAttributes &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.country_name) - { - if (!country_name) - country_name = new CountryName; - *country_name = *that.country_name; - } - else - { - delete country_name; - country_name = NULL; - } - if (that.administration_domain_name) - { - if (!administration_domain_name) - administration_domain_name = new AdministrationDomainName; - *administration_domain_name = *that.administration_domain_name; - } - else - { - delete administration_domain_name; - administration_domain_name = NULL; - } - if (that.network_address) - { - if (!network_address) - network_address = new NetworkAddress; - *network_address = *that.network_address; - } - else - { - delete network_address; - network_address = NULL; - } - if (that.terminal_identifier) - { - if (!terminal_identifier) - terminal_identifier = new TerminalIdentifier; - *terminal_identifier = *that.terminal_identifier; - } - else - { - delete terminal_identifier; - terminal_identifier = NULL; - } - if (that.private_domain_name) - { - if (!private_domain_name) - private_domain_name = new PrivateDomainName; - *private_domain_name = *that.private_domain_name; - } - else - { - delete private_domain_name; - private_domain_name = NULL; - } - if (that.organization_name) - { - if (!organization_name) - organization_name = new OrganizationName; - *organization_name = *that.organization_name; - } - else - { - delete organization_name; - organization_name = NULL; - } - if (that.numeric_user_identifier) - { - if (!numeric_user_identifier) - numeric_user_identifier = new NumericUserIdentifier; - *numeric_user_identifier = *that.numeric_user_identifier; - } - else - { - delete numeric_user_identifier; - numeric_user_identifier = NULL; - } - if (that.personal_name) - { - if (!personal_name) - personal_name = new PersonalName; - *personal_name = *that.personal_name; - } - else - { - delete personal_name; - personal_name = NULL; - } - if (that.organizational_unit_names) - { - if (!organizational_unit_names) - organizational_unit_names = new OrganizationUnitNames; - *organizational_unit_names = *that.organizational_unit_names; - } - else - { - delete organizational_unit_names; - organizational_unit_names = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined StandardAttributes &StandardAttributes::operator = (const StandardAttributes &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -StandardAttributes::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (organizational_unit_names)) - { - BEncEocIfNec (b); - l = organizational_unit_names->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 6); - totalLen += l; - } - - if (NOT_NULL (personal_name)) - { - BEncEocIfNec (b); - l = personal_name->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 5); - totalLen += l; - } - - if (NOT_NULL (numeric_user_identifier)) - { - l = numeric_user_identifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 4); - totalLen += l; - } - - if (NOT_NULL (organization_name)) - { - l = organization_name->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 3); - totalLen += l; - } - - if (NOT_NULL (private_domain_name)) - { - BEncEocIfNec (b); - l = private_domain_name->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 2); - totalLen += l; - } - - if (NOT_NULL (terminal_identifier)) - { - l = terminal_identifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 1); - totalLen += l; - } - - if (NOT_NULL (network_address)) - { - l = network_address->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - } - - if (NOT_NULL (administration_domain_name)) - { - BEncEocIfNec (b); - l = administration_domain_name->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, APPL, CONS, 2); - totalLen += l; - } - - if (NOT_NULL (country_name)) - { - BEncEocIfNec (b); - l = country_name->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, APPL, CONS, 1); - totalLen += l; - } - - return totalLen; -} // StandardAttributes::BEncContent - - -void StandardAttributes::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (APPL, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - country_name = new CountryName; - country_name->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (APPL, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - administration_domain_name = new AdministrationDomainName; - administration_domain_name->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - network_address = new NetworkAddress; - network_address->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - terminal_identifier = new TerminalIdentifier; - terminal_identifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - private_domain_name = new PrivateDomainName; - private_domain_name->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 3)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 3))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - organization_name = new OrganizationName; - organization_name->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 4)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 4))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - numeric_user_identifier = new NumericUserIdentifier; - numeric_user_identifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 5))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - personal_name = new PersonalName; - personal_name->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 6))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - organizational_unit_names = new OrganizationUnitNames; - organizational_unit_names->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-126); - } - else - return; -} // StandardAttributes::BDecContent - -AsnLen StandardAttributes::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void StandardAttributes::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "StandardAttributes::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-127); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void StandardAttributes::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (country_name)) - { - nonePrinted = false; - Indent (os, indentG); - os << "country-name "; - os << *country_name; - } - else - { - Indent (os, indentG); - os << "country-name "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (administration_domain_name)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "administration-domain-name "; - os << *administration_domain_name; - } - else - { - Indent (os, indentG); - os << "administration-domain-name "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (network_address)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "network-address "; - os << *network_address; - } - else - { - Indent (os, indentG); - os << "network-address "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (terminal_identifier)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "terminal-identifier "; - os << *terminal_identifier; - } - else - { - Indent (os, indentG); - os << "terminal-identifier "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (private_domain_name)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "private-domain-name "; - os << *private_domain_name; - } - else - { - Indent (os, indentG); - os << "private-domain-name "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (organization_name)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "organization-name "; - os << *organization_name; - } - else - { - Indent (os, indentG); - os << "organization-name "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (numeric_user_identifier)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "numeric-user-identifier "; - os << *numeric_user_identifier; - } - else - { - Indent (os, indentG); - os << "numeric-user-identifier "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (personal_name)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "personal-name "; - os << *personal_name; - } - else - { - Indent (os, indentG); - os << "personal-name "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (organizational_unit_names)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "organizational-unit-names "; - os << *organizational_unit_names; - } - else - { - Indent (os, indentG); - os << "organizational-unit-names "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // StandardAttributes::Print - - -ORAddress::ORAddress() -{ -#if TCL - standard_attributes = new StandardAttributes; -#else - standard_attributes = NULL; // incomplete initialization of mandatory element! -#endif // TCL - domain_defined_attributes = NULL; - extension_attributes = NULL; -} - -ORAddress::ORAddress (const ORAddress &) -{ - Asn1Error << "use of incompletely defined ORAddress::ORAddress (const ORAddress &)" << endl; - abort(); -} - -ORAddress::~ORAddress() -{ - delete standard_attributes; - delete domain_defined_attributes; - delete extension_attributes; -} - -AsnType *ORAddress::Clone() const -{ - return new ORAddress; -} - -AsnType *ORAddress::Copy() const -{ - return new ORAddress (*this); -} - -#if SNACC_DEEP_COPY -ORAddress &ORAddress::operator = (const ORAddress &that) -#else // SNACC_DEEP_COPY -ORAddress &ORAddress::operator = (const ORAddress &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.standard_attributes) - { - if (!standard_attributes) - standard_attributes = new StandardAttributes; - *standard_attributes = *that.standard_attributes; - } - else - { - delete standard_attributes; - standard_attributes = NULL; - } - if (that.domain_defined_attributes) - { - if (!domain_defined_attributes) - domain_defined_attributes = new DomainDefinedAttributes; - *domain_defined_attributes = *that.domain_defined_attributes; - } - else - { - delete domain_defined_attributes; - domain_defined_attributes = NULL; - } - if (that.extension_attributes) - { - if (!extension_attributes) - extension_attributes = new ExtensionAttributes; - *extension_attributes = *that.extension_attributes; - } - else - { - delete extension_attributes; - extension_attributes = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ORAddress &ORAddress::operator = (const ORAddress &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ORAddress::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (extension_attributes)) - { - BEncEocIfNec (b); - l = extension_attributes->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (domain_defined_attributes)) - { - BEncEocIfNec (b); - l = domain_defined_attributes->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - BEncEocIfNec (b); - l = standard_attributes->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // ORAddress::BEncContent - - -void ORAddress::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - standard_attributes = new StandardAttributes; - standard_attributes->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-128); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - domain_defined_attributes = new DomainDefinedAttributes; - domain_defined_attributes->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - extension_attributes = new ExtensionAttributes; - extension_attributes->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-129); - } - else - return; -} // ORAddress::BDecContent - -AsnLen ORAddress::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ORAddress::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ORAddress::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-130); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ORAddress::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (standard_attributes)) - { - Indent (os, indentG); - os << "standard-attributes "; - os << *standard_attributes; - } - else - { - Indent (os, indentG); - os << "standard-attributes "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (domain_defined_attributes)) - { - os << ","<< endl; - Indent (os, indentG); - os << "domain-defined-attributes "; - os << *domain_defined_attributes; - } - else - { - Indent (os, indentG); - os << "domain-defined-attributes "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (extension_attributes)) - { - os << ","<< endl; - Indent (os, indentG); - os << "extension-attributes "; - os << *extension_attributes; - } - else - { - Indent (os, indentG); - os << "extension-attributes "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ORAddress::Print - - -TeletexPersonalName::TeletexPersonalName() -{ - given_name = NULL; - initials = NULL; - generation_qualifier = NULL; -} - -TeletexPersonalName::TeletexPersonalName (const TeletexPersonalName &) -{ - Asn1Error << "use of incompletely defined TeletexPersonalName::TeletexPersonalName (const TeletexPersonalName &)" << endl; - abort(); -} - -TeletexPersonalName::~TeletexPersonalName() -{ - delete given_name; - delete initials; - delete generation_qualifier; -} - -AsnType *TeletexPersonalName::Clone() const -{ - return new TeletexPersonalName; -} - -AsnType *TeletexPersonalName::Copy() const -{ - return new TeletexPersonalName (*this); -} - -#if SNACC_DEEP_COPY -TeletexPersonalName &TeletexPersonalName::operator = (const TeletexPersonalName &that) -#else // SNACC_DEEP_COPY -TeletexPersonalName &TeletexPersonalName::operator = (const TeletexPersonalName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - surname = that.surname; - if (that.given_name) - { - if (!given_name) - given_name = new TeletexString; - *given_name = *that.given_name; - } - else - { - delete given_name; - given_name = NULL; - } - if (that.initials) - { - if (!initials) - initials = new TeletexString; - *initials = *that.initials; - } - else - { - delete initials; - initials = NULL; - } - if (that.generation_qualifier) - { - if (!generation_qualifier) - generation_qualifier = new TeletexString; - *generation_qualifier = *that.generation_qualifier; - } - else - { - delete generation_qualifier; - generation_qualifier = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined TeletexPersonalName &TeletexPersonalName::operator = (const TeletexPersonalName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen TeletexPersonalName::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - AsnBuf outputBuf; - int iii=0, tmpCount=0; - char *lpszBuf = (char *)calloc(1, 1024); - outputBuf.Init(lpszBuf, 1024); - outputBuf.ResetInWriteRvsMode(); - CSM_Buffer *tmpEnc[4]; - if (NOT_NULL (generation_qualifier)) - { - l = generation_qualifier->BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, CNTX, PRIM, 3); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - if (NOT_NULL (initials)) - { - l = initials->BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, CNTX, PRIM, 2); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - if (NOT_NULL (given_name)) - { - l = given_name->BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, CNTX, PRIM, 1); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - } - - l = surname.BEncContent (outputBuf); - l += BEncDefLen (outputBuf, l); - - l += BEncTag1 (outputBuf, CNTX, PRIM, 0); - totalLen += l; - SNACC_BUFRESET_READ(&outputBuf); - SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL); - SNACC_BUFRESET_WRITE(&outputBuf); - iii++; - - vdasnacc_sortSet(tmpEnc, iii); - tmpCount = iii; /** REMEMBER how many we have**/ - for (iii=0; iii < tmpCount; iii++) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < tmpCount; iii++) delete tmpEnc[iii]; - free(lpszBuf); - return totalLen; -} // TeletexPersonalName::BEncContent - - -void TeletexPersonalName::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen setBytesDecoded = 0; - unsigned int mandatoryElmtsDecoded = 0; - AsnLen elmtLen1; - - for (; (setBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN); ) - { - tag1 = BDecTag (b, setBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, setBytesDecoded, env) - break; /* exit for loop */ - } - elmtLen1 = BDecLen (b, setBytesDecoded, env); - switch (tag1) - { - case MAKE_TAG_ID (CNTX, PRIM, 0): - case MAKE_TAG_ID (CNTX, CONS, 0): - surname.BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - mandatoryElmtsDecoded++; - break; - - case MAKE_TAG_ID (CNTX, PRIM, 1): - case MAKE_TAG_ID (CNTX, CONS, 1): - given_name = new TeletexString; - given_name->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 2): - case MAKE_TAG_ID (CNTX, CONS, 2): - initials = new TeletexString; - initials->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 3): - case MAKE_TAG_ID (CNTX, CONS, 3): - generation_qualifier = new TeletexString; - generation_qualifier->BDecContent (b, tag1, elmtLen1, setBytesDecoded, env); - break; - - default: - Asn1Error << "Unexpected Tag on SET elmt." << endl; - SnaccExcep::throwMe(-131); - } // end switch - } // end for loop - bytesDecoded += setBytesDecoded; - if (mandatoryElmtsDecoded != 1) - { - Asn1Error << "ERROR - non-optional SET element missing." << endl; - SnaccExcep::throwMe(-132); - } -} // TeletexPersonalName::BDecContent - -AsnLen -TeletexPersonalName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void TeletexPersonalName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "TeletexPersonalName::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-133); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void TeletexPersonalName::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SET --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "surname "; - os << surname; - } - - if (NOT_NULL (given_name)) - { - os << ","<< endl; - Indent (os, indentG); - os << "given-name "; - os << *given_name; - } - else - os << "-- void2 --\n"; - - if (NOT_NULL (initials)) - { - os << ","<< endl; - Indent (os, indentG); - os << "initials "; - os << *initials; - } - else - os << "-- void2 --\n"; - - if (NOT_NULL (generation_qualifier)) - { - os << ","<< endl; - Indent (os, indentG); - os << "generation-qualifier "; - os << *generation_qualifier; - } - else - os << "-- void2 --\n"; - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // TeletexPersonalName - operator << - - -AsnType *TeletexOrganizationUnitNames::Clone() const -{ - return new TeletexOrganizationUnitNames; -} - -AsnType *TeletexOrganizationUnitNames::Copy() const -{ - return new TeletexOrganizationUnitNames (*this); -} - -AsnLen TeletexOrganizationUnitNames::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void TeletexOrganizationUnitNames::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "TeletexOrganizationUnitNames::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-134); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -TeletexOrganizationUnitNames::TeletexOrganizationUnitNames (const TeletexOrganizationUnitNames &) -{ - Asn1Error << "use of incompletely defined TeletexOrganizationUnitNames::TeletexOrganizationUnitNames (const TeletexOrganizationUnitNames &)" << endl; - abort(); -} - -TeletexOrganizationUnitNames::~TeletexOrganizationUnitNames() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -TeletexOrganizationUnitNames &TeletexOrganizationUnitNames::operator = (const TeletexOrganizationUnitNames &that) -#else // SNACC_DEEP_COPY -TeletexOrganizationUnitNames &TeletexOrganizationUnitNames::operator = (const TeletexOrganizationUnitNames &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined TeletexOrganizationUnitNames &TeletexOrganizationUnitNames::operator = (const TeletexOrganizationUnitNames &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void TeletexOrganizationUnitNames::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void TeletexOrganizationUnitNames::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // TeletexOrganizationUnitNames::SetCurrElmt - - -unsigned long int TeletexOrganizationUnitNames::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // TeletexOrganizationUnitNames::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -TeletexOrganizationalUnitName *TeletexOrganizationUnitNames::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexOrganizationalUnitName; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // TeletexOrganizationUnitNames::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -TeletexOrganizationalUnitName *TeletexOrganizationUnitNames::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexOrganizationalUnitName; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // TeletexOrganizationUnitNames::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -TeletexOrganizationalUnitName *TeletexOrganizationUnitNames::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexOrganizationalUnitName; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // TeletexOrganizationUnitNames::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -TeletexOrganizationalUnitName *TeletexOrganizationUnitNames::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexOrganizationalUnitName; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // TeletexOrganizationUnitNames::InsertAfter - - -TeletexOrganizationUnitNames &TeletexOrganizationUnitNames::AppendCopy (TeletexOrganizationalUnitName &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexOrganizationalUnitName; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -TeletexOrganizationUnitNames &TeletexOrganizationUnitNames::PrependCopy (TeletexOrganizationalUnitName &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexOrganizationalUnitName; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // TeletexOrganizationUnitNames::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -TeletexOrganizationUnitNames &TeletexOrganizationUnitNames::InsertBeforeAndCopy (TeletexOrganizationalUnitName &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexOrganizationalUnitName; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // TeletexOrganizationUnitNames::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -TeletexOrganizationUnitNames &TeletexOrganizationUnitNames::InsertAfterAndCopy (TeletexOrganizationalUnitName &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexOrganizationalUnitName; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // TeletexOrganizationUnitNames::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void TeletexOrganizationUnitNames::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen TeletexOrganizationUnitNames::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncDefLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // TeletexOrganizationUnitNames::BEncContent - - -void TeletexOrganizationUnitNames::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - TeletexOrganizationalUnitName *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) - && (tag1 != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-135); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // TeletexOrganizationUnitNames::BDecContent - - -AsnType *TeletexDomainDefinedAttributes::Clone() const -{ - return new TeletexDomainDefinedAttributes; -} - -AsnType *TeletexDomainDefinedAttributes::Copy() const -{ - return new TeletexDomainDefinedAttributes (*this); -} - -AsnLen TeletexDomainDefinedAttributes::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void TeletexDomainDefinedAttributes::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "TeletexDomainDefinedAttributes::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-136); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -TeletexDomainDefinedAttributes::TeletexDomainDefinedAttributes (const TeletexDomainDefinedAttributes &) -{ - Asn1Error << "use of incompletely defined TeletexDomainDefinedAttributes::TeletexDomainDefinedAttributes (const TeletexDomainDefinedAttributes &)" << endl; - abort(); -} - -TeletexDomainDefinedAttributes::~TeletexDomainDefinedAttributes() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -TeletexDomainDefinedAttributes &TeletexDomainDefinedAttributes::operator = (const TeletexDomainDefinedAttributes &that) -#else // SNACC_DEEP_COPY -TeletexDomainDefinedAttributes &TeletexDomainDefinedAttributes::operator = (const TeletexDomainDefinedAttributes &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined TeletexDomainDefinedAttributes &TeletexDomainDefinedAttributes::operator = (const TeletexDomainDefinedAttributes &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void TeletexDomainDefinedAttributes::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void TeletexDomainDefinedAttributes::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // TeletexDomainDefinedAttributes::SetCurrElmt - - -unsigned long int TeletexDomainDefinedAttributes::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // TeletexDomainDefinedAttributes::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -TeletexDomainDefinedAttribute *TeletexDomainDefinedAttributes::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexDomainDefinedAttribute; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // TeletexDomainDefinedAttributes::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -TeletexDomainDefinedAttribute *TeletexDomainDefinedAttributes::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexDomainDefinedAttribute; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // TeletexDomainDefinedAttributes::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -TeletexDomainDefinedAttribute *TeletexDomainDefinedAttributes::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexDomainDefinedAttribute; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // TeletexDomainDefinedAttributes::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -TeletexDomainDefinedAttribute *TeletexDomainDefinedAttributes::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexDomainDefinedAttribute; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // TeletexDomainDefinedAttributes::InsertAfter - - -TeletexDomainDefinedAttributes &TeletexDomainDefinedAttributes::AppendCopy (TeletexDomainDefinedAttribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexDomainDefinedAttribute; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -TeletexDomainDefinedAttributes &TeletexDomainDefinedAttributes::PrependCopy (TeletexDomainDefinedAttribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexDomainDefinedAttribute; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // TeletexDomainDefinedAttributes::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -TeletexDomainDefinedAttributes &TeletexDomainDefinedAttributes::InsertBeforeAndCopy (TeletexDomainDefinedAttribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexDomainDefinedAttribute; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // TeletexDomainDefinedAttributes::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -TeletexDomainDefinedAttributes &TeletexDomainDefinedAttributes::InsertAfterAndCopy (TeletexDomainDefinedAttribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new TeletexDomainDefinedAttribute; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // TeletexDomainDefinedAttributes::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void TeletexDomainDefinedAttributes::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen TeletexDomainDefinedAttributes::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // TeletexDomainDefinedAttributes::BEncContent - - -void TeletexDomainDefinedAttributes::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - TeletexDomainDefinedAttribute *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-137); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // TeletexDomainDefinedAttributes::BDecContent - - diff --git a/SecurityASN1/c++/sm_x411ub.cpp b/SecurityASN1/c++/sm_x411ub.cpp deleted file mode 100644 index c9fe085e..00000000 --- a/SecurityASN1/c++/sm_x411ub.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x411ub.cpp - class member functions for ASN.1 module UpperBounds -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - diff --git a/SecurityASN1/c++/sm_x501if.cpp b/SecurityASN1/c++/sm_x501if.cpp deleted file mode 100644 index f02e84e1..00000000 --- a/SecurityASN1/c++/sm_x501if.cpp +++ /dev/null @@ -1,3470 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x501if.cpp - class member functions for ASN.1 module InformationFramework -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -AsnType *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Clone() const -{ - return new AttributeTypeAndDistinguishedValueSetOfSeqSetOf; -} - -AsnType *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Copy() const -{ - return new AttributeTypeAndDistinguishedValueSetOfSeqSetOf (*this); -} - -AsnLen AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-100); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AttributeTypeAndDistinguishedValueSetOfSeqSetOf (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &) -{ - Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AttributeTypeAndDistinguishedValueSetOfSeqSetOf (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &)" << endl; - abort(); -} - -AttributeTypeAndDistinguishedValueSetOfSeqSetOf::~AttributeTypeAndDistinguishedValueSetOfSeqSetOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &that) -#else // SNACC_DEEP_COPY -AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::SetCurrElmt - - -unsigned long int AttributeTypeAndDistinguishedValueSetOfSeqSetOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -AsnAny *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AsnAny; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -AsnAny *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AsnAny; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -AsnAny *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AsnAny; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AsnAny *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AsnAny; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfter - - -AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AppendCopy (AsnAny &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AsnAny; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::PrependCopy (AsnAny &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AsnAny; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBeforeAndCopy (AsnAny &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AsnAny; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfterAndCopy (AsnAny &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AsnAny; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - tmpEnc[iii] = (CSM_Buffer *)currElmt->elmt->value; - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEncContent - - -void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnAny *listElmt; - AsnLen listBytesDecoded = 0; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - listElmt = Append(); - DEC_LOAD_ANYBUF(listElmt, b, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDecContent - - -AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq() -{ - distingAttrValue = NULL; -} - -AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq (const AttributeTypeAndDistinguishedValueSetOfSeq &) -{ - Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq (const AttributeTypeAndDistinguishedValueSetOfSeq &)" << endl; - abort(); -} - -AttributeTypeAndDistinguishedValueSetOfSeq::~AttributeTypeAndDistinguishedValueSetOfSeq() -{ - delete distingAttrValue; -} - -AsnType *AttributeTypeAndDistinguishedValueSetOfSeq::Clone() const -{ - return new AttributeTypeAndDistinguishedValueSetOfSeq; -} - -AsnType *AttributeTypeAndDistinguishedValueSetOfSeq::Copy() const -{ - return new AttributeTypeAndDistinguishedValueSetOfSeq (*this); -} - -#if SNACC_DEEP_COPY -AttributeTypeAndDistinguishedValueSetOfSeq &AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq &that) -#else // SNACC_DEEP_COPY -AttributeTypeAndDistinguishedValueSetOfSeq &AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.distingAttrValue) - { - if (!distingAttrValue) - distingAttrValue = new AsnOid; - *distingAttrValue = *that.distingAttrValue; - } - else - { - delete distingAttrValue; - distingAttrValue = NULL; - } - contextList = that.contextList; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeq &AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttributeTypeAndDistinguishedValueSetOfSeq::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = contextList.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - - if (NOT_NULL (distingAttrValue)) - { - l = distingAttrValue->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - } - - return totalLen; -} // AttributeTypeAndDistinguishedValueSetOfSeq::BEncContent - - -void AttributeTypeAndDistinguishedValueSetOfSeq::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - distingAttrValue = new AsnOid; - distingAttrValue->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - contextList.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-101); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-102); - } - else - return; -} // AttributeTypeAndDistinguishedValueSetOfSeq::BDecContent - -AsnLen AttributeTypeAndDistinguishedValueSetOfSeq::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributeTypeAndDistinguishedValueSetOfSeq::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributeTypeAndDistinguishedValueSetOfSeq::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-103); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AttributeTypeAndDistinguishedValueSetOfSeq::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (distingAttrValue)) - { - Indent (os, indentG); - os << "distingAttrValue "; - os << *distingAttrValue; - } - else - { - Indent (os, indentG); - os << "distingAttrValue "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "contextList "; - os << contextList; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AttributeTypeAndDistinguishedValueSetOfSeq::Print - - -AsnType *AttributeTypeAndDistinguishedValueSetOf::Clone() const -{ - return new AttributeTypeAndDistinguishedValueSetOf; -} - -AsnType *AttributeTypeAndDistinguishedValueSetOf::Copy() const -{ - return new AttributeTypeAndDistinguishedValueSetOf (*this); -} - -AsnLen AttributeTypeAndDistinguishedValueSetOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void AttributeTypeAndDistinguishedValueSetOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "AttributeTypeAndDistinguishedValueSetOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-104); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AttributeTypeAndDistinguishedValueSetOf::AttributeTypeAndDistinguishedValueSetOf (const AttributeTypeAndDistinguishedValueSetOf &) -{ - Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOf::AttributeTypeAndDistinguishedValueSetOf (const AttributeTypeAndDistinguishedValueSetOf &)" << endl; - abort(); -} - -AttributeTypeAndDistinguishedValueSetOf::~AttributeTypeAndDistinguishedValueSetOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf &that) -#else // SNACC_DEEP_COPY -AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void AttributeTypeAndDistinguishedValueSetOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void AttributeTypeAndDistinguishedValueSetOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // AttributeTypeAndDistinguishedValueSetOf::SetCurrElmt - - -unsigned long int AttributeTypeAndDistinguishedValueSetOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // AttributeTypeAndDistinguishedValueSetOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -AttributeTypeAndDistinguishedValueSetOfSeq *AttributeTypeAndDistinguishedValueSetOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeTypeAndDistinguishedValueSetOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -AttributeTypeAndDistinguishedValueSetOfSeq *AttributeTypeAndDistinguishedValueSetOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeTypeAndDistinguishedValueSetOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeTypeAndDistinguishedValueSetOfSeq *AttributeTypeAndDistinguishedValueSetOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeTypeAndDistinguishedValueSetOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeTypeAndDistinguishedValueSetOfSeq *AttributeTypeAndDistinguishedValueSetOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeTypeAndDistinguishedValueSetOf::InsertAfter - - -AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::AppendCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::PrependCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // AttributeTypeAndDistinguishedValueSetOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::InsertBeforeAndCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // AttributeTypeAndDistinguishedValueSetOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::InsertAfterAndCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // AttributeTypeAndDistinguishedValueSetOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void AttributeTypeAndDistinguishedValueSetOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen AttributeTypeAndDistinguishedValueSetOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // AttributeTypeAndDistinguishedValueSetOf::BEncContent - - -void AttributeTypeAndDistinguishedValueSetOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - AttributeTypeAndDistinguishedValueSetOfSeq *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-105); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // AttributeTypeAndDistinguishedValueSetOf::BDecContent - - -AsnType *AttributeSetOf::Clone() const -{ - return new AttributeSetOf; -} - -AsnType *AttributeSetOf::Copy() const -{ - return new AttributeSetOf (*this); -} - -AsnLen AttributeSetOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void AttributeSetOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "AttributeSetOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-106); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AttributeSetOf::AttributeSetOf (const AttributeSetOf &) -{ - Asn1Error << "use of incompletely defined AttributeSetOf::AttributeSetOf (const AttributeSetOf &)" << endl; - abort(); -} - -AttributeSetOf::~AttributeSetOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -AttributeSetOf &AttributeSetOf::operator = (const AttributeSetOf &that) -#else // SNACC_DEEP_COPY -AttributeSetOf &AttributeSetOf::operator = (const AttributeSetOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeSetOf &AttributeSetOf::operator = (const AttributeSetOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void AttributeSetOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void AttributeSetOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // AttributeSetOf::SetCurrElmt - - -unsigned long int AttributeSetOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // AttributeSetOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -AttributeValue *AttributeSetOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeValue; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeSetOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -AttributeValue *AttributeSetOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeValue; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeSetOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeValue *AttributeSetOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeValue; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeSetOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeValue *AttributeSetOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeValue; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeSetOf::InsertAfter - - -AttributeSetOf &AttributeSetOf::AppendCopy (AttributeValue &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeValue; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -AttributeSetOf &AttributeSetOf::PrependCopy (AttributeValue &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeValue; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // AttributeSetOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeSetOf &AttributeSetOf::InsertBeforeAndCopy (AttributeValue &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeValue; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // AttributeSetOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeSetOf &AttributeSetOf::InsertAfterAndCopy (AttributeValue &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeValue; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // AttributeSetOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void AttributeSetOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen AttributeSetOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - tmpEnc[iii] = (CSM_Buffer *)currElmt->elmt->value; - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // AttributeSetOf::BEncContent - - -void AttributeSetOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - AttributeValue *listElmt; - AsnLen listBytesDecoded = 0; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - listElmt = Append(); - DEC_LOAD_ANYBUF(listElmt, b, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // AttributeSetOf::BDecContent - - -Attribute::Attribute() -{ -} - -Attribute::Attribute (const Attribute &) -{ - Asn1Error << "use of incompletely defined Attribute::Attribute (const Attribute &)" << endl; - abort(); -} - -Attribute::~Attribute() -{ -} - -AsnType *Attribute::Clone() const -{ - return new Attribute; -} - -AsnType *Attribute::Copy() const -{ - return new Attribute (*this); -} - -#if SNACC_DEEP_COPY -Attribute &Attribute::operator = (const Attribute &that) -#else // SNACC_DEEP_COPY -Attribute &Attribute::operator = (const Attribute &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - type = that.type; - values = that.values; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Attribute &Attribute::operator = (const Attribute &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -Attribute::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = values.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - - l = type.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // Attribute::BEncContent - - -void Attribute::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - type.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-107); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - values.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-108); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-109); - } - else - return; -} // Attribute::BDecContent - -AsnLen Attribute::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void Attribute::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Attribute::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-110); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void Attribute::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "type "; - os << type; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "values "; - os << values; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // Attribute::Print - - -AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue() -{ - primaryDistinguished = NULL; - valuesWithContext = NULL; -} - -AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue (const AttributeTypeAndDistinguishedValue &) -{ - Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue (const AttributeTypeAndDistinguishedValue &)" << endl; - abort(); -} - -AttributeTypeAndDistinguishedValue::~AttributeTypeAndDistinguishedValue() -{ - delete primaryDistinguished; - delete valuesWithContext; -} - -AsnType *AttributeTypeAndDistinguishedValue::Clone() const -{ - return new AttributeTypeAndDistinguishedValue; -} - -AsnType *AttributeTypeAndDistinguishedValue::Copy() const -{ - return new AttributeTypeAndDistinguishedValue (*this); -} - -#if SNACC_DEEP_COPY -AttributeTypeAndDistinguishedValue &AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue &that) -#else // SNACC_DEEP_COPY -AttributeTypeAndDistinguishedValue &AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - type = that.type; - value = that.value; - if (that.primaryDistinguished) - { - if (!primaryDistinguished) - primaryDistinguished = new AsnBool; - *primaryDistinguished = *that.primaryDistinguished; - } - else - { - delete primaryDistinguished; - primaryDistinguished = NULL; - } - if (that.valuesWithContext) - { - if (!valuesWithContext) - valuesWithContext = new AttributeTypeAndDistinguishedValueSetOf; - *valuesWithContext = *that.valuesWithContext; - } - else - { - delete valuesWithContext; - valuesWithContext = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValue &AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttributeTypeAndDistinguishedValue::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (valuesWithContext)) - { - BEncEocIfNec (b); - l = valuesWithContext->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (primaryDistinguished)) - { - l = primaryDistinguished->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, BOOLEAN_TAG_CODE); - totalLen += l; - } - - ENC_LOAD_ANYBUF(&value, b, l); - totalLen += l; - - l = type.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // AttributeTypeAndDistinguishedValue::BEncContent - - -void AttributeTypeAndDistinguishedValue::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - type.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-111); - } - - // ANY type - DEC_LOAD_ANYBUF(&value, b, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - primaryDistinguished = new AsnBool; - primaryDistinguished->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - valuesWithContext = new AttributeTypeAndDistinguishedValueSetOf; - valuesWithContext->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-112); - } - else - return; -} // AttributeTypeAndDistinguishedValue::BDecContent - -AsnLen AttributeTypeAndDistinguishedValue::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributeTypeAndDistinguishedValue::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributeTypeAndDistinguishedValue::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-113); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AttributeTypeAndDistinguishedValue::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "type "; - os << type; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "value "; - os << value; - os << "," << endl; - } - - if (NOT_NULL (primaryDistinguished)) - { - os << ","<< endl; - Indent (os, indentG); - os << "primaryDistinguished "; - os << *primaryDistinguished; - } - else - { - Indent (os, indentG); - os << "primaryDistinguished "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (valuesWithContext)) - { - os << ","<< endl; - Indent (os, indentG); - os << "valuesWithContext "; - os << *valuesWithContext; - } - else - { - Indent (os, indentG); - os << "valuesWithContext "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AttributeTypeAndDistinguishedValue::Print - - -AsnType *RelativeDistinguishedName::Clone() const -{ - return new RelativeDistinguishedName; -} - -AsnType *RelativeDistinguishedName::Copy() const -{ - return new RelativeDistinguishedName (*this); -} - -AsnLen RelativeDistinguishedName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void RelativeDistinguishedName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "RelativeDistinguishedName::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-114); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -RelativeDistinguishedName::RelativeDistinguishedName (const RelativeDistinguishedName &) -{ - Asn1Error << "use of incompletely defined RelativeDistinguishedName::RelativeDistinguishedName (const RelativeDistinguishedName &)" << endl; - abort(); -} - -RelativeDistinguishedName::~RelativeDistinguishedName() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -RelativeDistinguishedName &RelativeDistinguishedName::operator = (const RelativeDistinguishedName &that) -#else // SNACC_DEEP_COPY -RelativeDistinguishedName &RelativeDistinguishedName::operator = (const RelativeDistinguishedName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RelativeDistinguishedName &RelativeDistinguishedName::operator = (const RelativeDistinguishedName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void RelativeDistinguishedName::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void RelativeDistinguishedName::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // RelativeDistinguishedName::SetCurrElmt - - -unsigned long int RelativeDistinguishedName::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // RelativeDistinguishedName::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -AttributeTypeAndDistinguishedValue *RelativeDistinguishedName::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValue; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RelativeDistinguishedName::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -AttributeTypeAndDistinguishedValue *RelativeDistinguishedName::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValue; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RelativeDistinguishedName::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeTypeAndDistinguishedValue *RelativeDistinguishedName::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValue; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RelativeDistinguishedName::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeTypeAndDistinguishedValue *RelativeDistinguishedName::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValue; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RelativeDistinguishedName::InsertAfter - - -RelativeDistinguishedName &RelativeDistinguishedName::AppendCopy (AttributeTypeAndDistinguishedValue &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValue; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -RelativeDistinguishedName &RelativeDistinguishedName::PrependCopy (AttributeTypeAndDistinguishedValue &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValue; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // RelativeDistinguishedName::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -RelativeDistinguishedName &RelativeDistinguishedName::InsertBeforeAndCopy (AttributeTypeAndDistinguishedValue &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValue; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // RelativeDistinguishedName::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -RelativeDistinguishedName &RelativeDistinguishedName::InsertAfterAndCopy (AttributeTypeAndDistinguishedValue &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeTypeAndDistinguishedValue; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // RelativeDistinguishedName::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void RelativeDistinguishedName::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen RelativeDistinguishedName::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // RelativeDistinguishedName::BEncContent - - -void RelativeDistinguishedName::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - AttributeTypeAndDistinguishedValue *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-115); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // RelativeDistinguishedName::BDecContent - - -AsnType *RDNSequence::Clone() const -{ - return new RDNSequence; -} - -AsnType *RDNSequence::Copy() const -{ - return new RDNSequence (*this); -} - -AsnLen RDNSequence::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void RDNSequence::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "RDNSequence::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-116); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -RDNSequence::RDNSequence (const RDNSequence &) -{ - Asn1Error << "use of incompletely defined RDNSequence::RDNSequence (const RDNSequence &)" << endl; - abort(); -} - -RDNSequence::~RDNSequence() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -RDNSequence &RDNSequence::operator = (const RDNSequence &that) -#else // SNACC_DEEP_COPY -RDNSequence &RDNSequence::operator = (const RDNSequence &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined RDNSequence &RDNSequence::operator = (const RDNSequence &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void RDNSequence::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void RDNSequence::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // RDNSequence::SetCurrElmt - - -unsigned long int RDNSequence::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // RDNSequence::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -RelativeDistinguishedName *RDNSequence::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RelativeDistinguishedName; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RDNSequence::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -RelativeDistinguishedName *RDNSequence::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RelativeDistinguishedName; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RDNSequence::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -RelativeDistinguishedName *RDNSequence::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RelativeDistinguishedName; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RDNSequence::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -RelativeDistinguishedName *RDNSequence::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RelativeDistinguishedName; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // RDNSequence::InsertAfter - - -RDNSequence &RDNSequence::AppendCopy (RelativeDistinguishedName &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RelativeDistinguishedName; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -RDNSequence &RDNSequence::PrependCopy (RelativeDistinguishedName &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new RelativeDistinguishedName; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // RDNSequence::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -RDNSequence &RDNSequence::InsertBeforeAndCopy (RelativeDistinguishedName &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new RelativeDistinguishedName; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // RDNSequence::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -RDNSequence &RDNSequence::InsertAfterAndCopy (RelativeDistinguishedName &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new RelativeDistinguishedName; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // RDNSequence::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void RDNSequence::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen RDNSequence::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // RDNSequence::BEncContent - - -void RDNSequence::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - RelativeDistinguishedName *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-117); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // RDNSequence::BDecContent - - -AsnType *Attributes::Clone() const -{ - return new Attributes; -} - -AsnType *Attributes::Copy() const -{ - return new Attributes (*this); -} - -AsnLen Attributes::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void Attributes::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "Attributes::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-118); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -Attributes::Attributes (const Attributes &) -{ - Asn1Error << "use of incompletely defined Attributes::Attributes (const Attributes &)" << endl; - abort(); -} - -Attributes::~Attributes() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -Attributes &Attributes::operator = (const Attributes &that) -#else // SNACC_DEEP_COPY -Attributes &Attributes::operator = (const Attributes &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Attributes &Attributes::operator = (const Attributes &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void Attributes::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void Attributes::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // Attributes::SetCurrElmt - - -unsigned long int Attributes::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // Attributes::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -Attribute *Attributes::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // Attributes::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -Attribute *Attributes::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // Attributes::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -Attribute *Attributes::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // Attributes::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -Attribute *Attributes::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // Attributes::InsertAfter - - -Attributes &Attributes::AppendCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -Attributes &Attributes::PrependCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // Attributes::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -Attributes &Attributes::InsertBeforeAndCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // Attributes::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -Attributes &Attributes::InsertAfterAndCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // Attributes::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void Attributes::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen Attributes::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // Attributes::BEncContent - - -void Attributes::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - Attribute *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-119); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // Attributes::BDecContent - - -Name::Name() -{ - choiceId = rDNSequenceCid; -#if TCL - rDNSequence = new RDNSequence; -#else - rDNSequence = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -Name::Name (const Name &) -{ - Asn1Error << "use of incompletely defined Name::Name (const Name &)" << endl; - abort(); -} - -Name::~Name() -{ - switch (choiceId) - { - case rDNSequenceCid: - delete rDNSequence; - break; - } // end of switch -} // end of destructor - -AsnType *Name::Clone() const -{ - return new Name; -} - -AsnType *Name::Copy() const -{ - return new Name (*this); -} - -#if SNACC_DEEP_COPY -Name &Name::operator = (const Name &that) -#else // SNACC_DEEP_COPY -Name &Name::operator = (const Name &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case rDNSequenceCid: - delete rDNSequence; - break; - } - switch (choiceId = that.choiceId) - { - case rDNSequenceCid: - rDNSequence = new RDNSequence; - *rDNSequence = *that.rDNSequence; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Name &Name::operator = (const Name &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -Name::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case rDNSequenceCid: - BEncEocIfNec (b); - l = rDNSequence->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - break; - - } // end switch - return l; -} // Name::BEncContent - - -void Name::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE): - choiceId = rDNSequenceCid; - rDNSequence = new RDNSequence; - rDNSequence->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-120); - break; - } // end switch -} // Name::BDecContent - - -AsnLen Name::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void Name::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void Name::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case rDNSequenceCid: - os << "rDNSequence "; - if (rDNSequence) - os << *rDNSequence; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // Name::Print - diff --git a/SecurityASN1/c++/sm_x501ud.cpp b/SecurityASN1/c++/sm_x501ud.cpp deleted file mode 100644 index 2191447f..00000000 --- a/SecurityASN1/c++/sm_x501ud.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x501ud.cpp - class member functions for ASN.1 module UsefulDefinitions -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - diff --git a/SecurityASN1/c++/sm_x509af.cpp b/SecurityASN1/c++/sm_x509af.cpp deleted file mode 100644 index 0b7bc800..00000000 --- a/SecurityASN1/c++/sm_x509af.cpp +++ /dev/null @@ -1,9586 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x509af.cpp - class member functions for ASN.1 module AuthenticationFramework -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -AsnType *AttributeCertificateAssertionSetOf::Clone() const -{ - return new AttributeCertificateAssertionSetOf; -} - -AsnType *AttributeCertificateAssertionSetOf::Copy() const -{ - return new AttributeCertificateAssertionSetOf (*this); -} - -AsnLen AttributeCertificateAssertionSetOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void AttributeCertificateAssertionSetOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "AttributeCertificateAssertionSetOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-100); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AttributeCertificateAssertionSetOf::AttributeCertificateAssertionSetOf (const AttributeCertificateAssertionSetOf &) -{ - Asn1Error << "use of incompletely defined AttributeCertificateAssertionSetOf::AttributeCertificateAssertionSetOf (const AttributeCertificateAssertionSetOf &)" << endl; - abort(); -} - -AttributeCertificateAssertionSetOf::~AttributeCertificateAssertionSetOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::operator = (const AttributeCertificateAssertionSetOf &that) -#else // SNACC_DEEP_COPY -AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::operator = (const AttributeCertificateAssertionSetOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::operator = (const AttributeCertificateAssertionSetOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void AttributeCertificateAssertionSetOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void AttributeCertificateAssertionSetOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // AttributeCertificateAssertionSetOf::SetCurrElmt - - -unsigned long int AttributeCertificateAssertionSetOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // AttributeCertificateAssertionSetOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -AttributeType *AttributeCertificateAssertionSetOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeType; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificateAssertionSetOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -AttributeType *AttributeCertificateAssertionSetOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeType; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificateAssertionSetOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeType *AttributeCertificateAssertionSetOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeType; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificateAssertionSetOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeType *AttributeCertificateAssertionSetOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeType; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificateAssertionSetOf::InsertAfter - - -AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::AppendCopy (AttributeType &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeType; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::PrependCopy (AttributeType &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeType; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // AttributeCertificateAssertionSetOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::InsertBeforeAndCopy (AttributeType &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeType; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // AttributeCertificateAssertionSetOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::InsertAfterAndCopy (AttributeType &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new AttributeType; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // AttributeCertificateAssertionSetOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void AttributeCertificateAssertionSetOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen AttributeCertificateAssertionSetOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncDefLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, PRIM, OID_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // AttributeCertificateAssertionSetOf::BEncContent - - -void AttributeCertificateAssertionSetOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - AttributeType *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-101); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // AttributeCertificateAssertionSetOf::BDecContent - - -AsnType *AttributeCertificateInfoSeqOf::Clone() const -{ - return new AttributeCertificateInfoSeqOf; -} - -AsnType *AttributeCertificateInfoSeqOf::Copy() const -{ - return new AttributeCertificateInfoSeqOf (*this); -} - -AsnLen AttributeCertificateInfoSeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributeCertificateInfoSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributeCertificateInfoSeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-102); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AttributeCertificateInfoSeqOf::AttributeCertificateInfoSeqOf (const AttributeCertificateInfoSeqOf &) -{ - Asn1Error << "use of incompletely defined AttributeCertificateInfoSeqOf::AttributeCertificateInfoSeqOf (const AttributeCertificateInfoSeqOf &)" << endl; - abort(); -} - -AttributeCertificateInfoSeqOf::~AttributeCertificateInfoSeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::operator = (const AttributeCertificateInfoSeqOf &that) -#else // SNACC_DEEP_COPY -AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::operator = (const AttributeCertificateInfoSeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::operator = (const AttributeCertificateInfoSeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void AttributeCertificateInfoSeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void AttributeCertificateInfoSeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // AttributeCertificateInfoSeqOf::SetCurrElmt - - -unsigned long int AttributeCertificateInfoSeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // AttributeCertificateInfoSeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -Attribute *AttributeCertificateInfoSeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificateInfoSeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -Attribute *AttributeCertificateInfoSeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificateInfoSeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -Attribute *AttributeCertificateInfoSeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificateInfoSeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -Attribute *AttributeCertificateInfoSeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificateInfoSeqOf::InsertAfter - - -AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::AppendCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::PrependCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // AttributeCertificateInfoSeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::InsertBeforeAndCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // AttributeCertificateInfoSeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::InsertAfterAndCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // AttributeCertificateInfoSeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void AttributeCertificateInfoSeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen AttributeCertificateInfoSeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // AttributeCertificateInfoSeqOf::BEncContent - - -void AttributeCertificateInfoSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - Attribute *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-103); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // AttributeCertificateInfoSeqOf::BDecContent - - -AlgorithmIdentifier::AlgorithmIdentifier() -{ - parameters = NULL; -} - -AlgorithmIdentifier::AlgorithmIdentifier (const AlgorithmIdentifier &) -{ - Asn1Error << "use of incompletely defined AlgorithmIdentifier::AlgorithmIdentifier (const AlgorithmIdentifier &)" << endl; - abort(); -} - -AlgorithmIdentifier::~AlgorithmIdentifier() -{ - delete parameters; -} - -AsnType *AlgorithmIdentifier::Clone() const -{ - return new AlgorithmIdentifier; -} - -AsnType *AlgorithmIdentifier::Copy() const -{ - return new AlgorithmIdentifier (*this); -} - -#if SNACC_DEEP_COPY -AlgorithmIdentifier &AlgorithmIdentifier::operator = (const AlgorithmIdentifier &that) -#else // SNACC_DEEP_COPY -AlgorithmIdentifier &AlgorithmIdentifier::operator = (const AlgorithmIdentifier &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - algorithm = that.algorithm; - if (that.parameters) - { - if (!parameters) - parameters = new AsnAny; - *parameters = *that.parameters; - } - else - { - delete parameters; - parameters = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AlgorithmIdentifier &AlgorithmIdentifier::operator = (const AlgorithmIdentifier &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AlgorithmIdentifier::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (parameters)) - { - ENC_LOAD_ANYBUF(parameters, b, l); - totalLen += l; - } - - l = algorithm.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // AlgorithmIdentifier::BEncContent - - -void AlgorithmIdentifier::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - algorithm.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = b.PeekByte(); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDecEoc (b, seqBytesDecoded, env); - - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-104); - } - - // ANY type - parameters = new AsnAny; - DEC_LOAD_ANYBUF(parameters, b, seqBytesDecoded, env); - - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-105); - } - else - return; -} // AlgorithmIdentifier::BDecContent - -AsnLen AlgorithmIdentifier::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AlgorithmIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AlgorithmIdentifier::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-106); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AlgorithmIdentifier::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "algorithm "; - os << algorithm; - os << "," << endl; - } - - if (NOT_NULL (parameters)) - { - os << ","<< endl; - Indent (os, indentG); - os << "parameters "; - os << *parameters; - } - else - { - Indent (os, indentG); - os << "parameters "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AlgorithmIdentifier::Print - - -Time::Time() -{ - choiceId = utcTimeCid; -#if TCL - utcTime = new UTCTime; -#else - utcTime = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -Time::Time (const Time &) -{ - Asn1Error << "use of incompletely defined Time::Time (const Time &)" << endl; - abort(); -} - -Time::~Time() -{ - switch (choiceId) - { - case utcTimeCid: - delete utcTime; - break; - case generalizedTimeCid: - delete generalizedTime; - break; - } // end of switch -} // end of destructor - -AsnType *Time::Clone() const -{ - return new Time; -} - -AsnType *Time::Copy() const -{ - return new Time (*this); -} - -#if SNACC_DEEP_COPY -Time &Time::operator = (const Time &that) -#else // SNACC_DEEP_COPY -Time &Time::operator = (const Time &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case utcTimeCid: - delete utcTime; - break; - case generalizedTimeCid: - delete generalizedTime; - break; - } - switch (choiceId = that.choiceId) - { - case utcTimeCid: - utcTime = new UTCTime; - *utcTime = *that.utcTime; - break; - case generalizedTimeCid: - generalizedTime = new GeneralizedTime; - *generalizedTime = *that.generalizedTime; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Time &Time::operator = (const Time &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -Time::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case utcTimeCid: - l = utcTime->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE); - break; - - case generalizedTimeCid: - l = generalizedTime->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - break; - - } // end switch - return l; -} // Time::BEncContent - - -void Time::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE): - choiceId = utcTimeCid; - utcTime = new UTCTime; - utcTime->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE): - choiceId = generalizedTimeCid; - generalizedTime = new GeneralizedTime; - generalizedTime->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-107); - break; - } // end switch -} // Time::BDecContent - - -AsnLen Time::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void Time::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void Time::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case utcTimeCid: - os << "utcTime "; - if (utcTime) - os << *utcTime; - else - os << "-- void3 --\n"; - break; - - case generalizedTimeCid: - os << "generalizedTime "; - if (generalizedTime) - os << *generalizedTime; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // Time::Print - -Extension::Extension() -{ - critical = NULL; -} - -Extension::Extension (const Extension &) -{ - Asn1Error << "use of incompletely defined Extension::Extension (const Extension &)" << endl; - abort(); -} - -Extension::~Extension() -{ - delete critical; -} - -AsnType *Extension::Clone() const -{ - return new Extension; -} - -AsnType *Extension::Copy() const -{ - return new Extension (*this); -} - -#if SNACC_DEEP_COPY -Extension &Extension::operator = (const Extension &that) -#else // SNACC_DEEP_COPY -Extension &Extension::operator = (const Extension &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - extnId = that.extnId; - if (that.critical) - { - if (!critical) - critical = new AsnBool; - *critical = *that.critical; - } - else - { - delete critical; - critical = NULL; - } - extnValue = that.extnValue; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Extension &Extension::operator = (const Extension &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -Extension::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = extnValue.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - totalLen += l; - - if (NOT_NULL (critical)) - { - l = critical->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, BOOLEAN_TAG_CODE); - totalLen += l; - } - - l = extnId.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // Extension::BEncContent - - -void Extension::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - extnId.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-108); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - critical = new AsnBool; - critical->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - extnValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-109); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-110); - } - else - return; -} // Extension::BDecContent - -AsnLen Extension::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void Extension::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Extension::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-111); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void Extension::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "extnId "; - os << extnId; - os << "," << endl; - } - - if (NOT_NULL (critical)) - { - Indent (os, indentG); - os << "critical "; - os << *critical; - } - else - { - Indent (os, indentG); - os << "critical "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "extnValue "; - os << extnValue; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // Extension::Print - - -AttCertValidityPeriod::AttCertValidityPeriod() -{ -} - -AttCertValidityPeriod::AttCertValidityPeriod (const AttCertValidityPeriod &) -{ - Asn1Error << "use of incompletely defined AttCertValidityPeriod::AttCertValidityPeriod (const AttCertValidityPeriod &)" << endl; - abort(); -} - -AttCertValidityPeriod::~AttCertValidityPeriod() -{ -} - -AsnType *AttCertValidityPeriod::Clone() const -{ - return new AttCertValidityPeriod; -} - -AsnType *AttCertValidityPeriod::Copy() const -{ - return new AttCertValidityPeriod (*this); -} - -#if SNACC_DEEP_COPY -AttCertValidityPeriod &AttCertValidityPeriod::operator = (const AttCertValidityPeriod &that) -#else // SNACC_DEEP_COPY -AttCertValidityPeriod &AttCertValidityPeriod::operator = (const AttCertValidityPeriod &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - notBeforeTime = that.notBeforeTime; - notAfterTime = that.notAfterTime; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttCertValidityPeriod &AttCertValidityPeriod::operator = (const AttCertValidityPeriod &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttCertValidityPeriod::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = notAfterTime.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - totalLen += l; - - l = notBeforeTime.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - totalLen += l; - - return totalLen; -} // AttCertValidityPeriod::BEncContent - - -void AttCertValidityPeriod::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - notBeforeTime.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-112); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - notAfterTime.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-113); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-114); - } - else - return; -} // AttCertValidityPeriod::BDecContent - -AsnLen AttCertValidityPeriod::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttCertValidityPeriod::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttCertValidityPeriod::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-115); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AttCertValidityPeriod::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "notBeforeTime "; - os << notBeforeTime; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "notAfterTime "; - os << notAfterTime; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AttCertValidityPeriod::Print - - -Validity::Validity() -{ -#if TCL - notBefore = new Time; -#else - notBefore = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - notAfter = new Time; -#else - notAfter = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -Validity::Validity (const Validity &) -{ - Asn1Error << "use of incompletely defined Validity::Validity (const Validity &)" << endl; - abort(); -} - -Validity::~Validity() -{ - delete notBefore; - delete notAfter; -} - -AsnType *Validity::Clone() const -{ - return new Validity; -} - -AsnType *Validity::Copy() const -{ - return new Validity (*this); -} - -#if SNACC_DEEP_COPY -Validity &Validity::operator = (const Validity &that) -#else // SNACC_DEEP_COPY -Validity &Validity::operator = (const Validity &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.notBefore) - { - if (!notBefore) - notBefore = new Time; - *notBefore = *that.notBefore; - } - else - { - delete notBefore; - notBefore = NULL; - } - if (that.notAfter) - { - if (!notAfter) - notAfter = new Time; - *notAfter = *that.notAfter; - } - else - { - delete notAfter; - notAfter = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Validity &Validity::operator = (const Validity &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -Validity::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = notAfter->BEncContent (b); - totalLen += l; - - l = notBefore->BEncContent (b); - totalLen += l; - - return totalLen; -} // Validity::BEncContent - - -void Validity::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - notBefore = new Time; - notBefore->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-116); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - notAfter = new Time; - notAfter->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-117); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-118); - } - else - return; -} // Validity::BDecContent - -AsnLen Validity::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void Validity::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Validity::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-119); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void Validity::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (notBefore)) - { - Indent (os, indentG); - os << "notBefore "; - os << *notBefore; - } - else - { - Indent (os, indentG); - os << "notBefore "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (notAfter)) - { - Indent (os, indentG); - os << "notAfter "; - os << *notAfter; - } - else - { - Indent (os, indentG); - os << "notAfter "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // Validity::Print - - -SubjectPublicKeyInfo::SubjectPublicKeyInfo() -{ -#if TCL - algorithm = new AlgorithmIdentifier; -#else - algorithm = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -SubjectPublicKeyInfo::SubjectPublicKeyInfo (const SubjectPublicKeyInfo &) -{ - Asn1Error << "use of incompletely defined SubjectPublicKeyInfo::SubjectPublicKeyInfo (const SubjectPublicKeyInfo &)" << endl; - abort(); -} - -SubjectPublicKeyInfo::~SubjectPublicKeyInfo() -{ - delete algorithm; -} - -AsnType *SubjectPublicKeyInfo::Clone() const -{ - return new SubjectPublicKeyInfo; -} - -AsnType *SubjectPublicKeyInfo::Copy() const -{ - return new SubjectPublicKeyInfo (*this); -} - -#if SNACC_DEEP_COPY -SubjectPublicKeyInfo &SubjectPublicKeyInfo::operator = (const SubjectPublicKeyInfo &that) -#else // SNACC_DEEP_COPY -SubjectPublicKeyInfo &SubjectPublicKeyInfo::operator = (const SubjectPublicKeyInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.algorithm) - { - if (!algorithm) - algorithm = new AlgorithmIdentifier; - *algorithm = *that.algorithm; - } - else - { - delete algorithm; - algorithm = NULL; - } - subjectPublicKey = that.subjectPublicKey; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SubjectPublicKeyInfo &SubjectPublicKeyInfo::operator = (const SubjectPublicKeyInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -SubjectPublicKeyInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = subjectPublicKey.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = algorithm->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // SubjectPublicKeyInfo::BEncContent - - -void SubjectPublicKeyInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - algorithm = new AlgorithmIdentifier; - algorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-120); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subjectPublicKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-121); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-122); - } - else - return; -} // SubjectPublicKeyInfo::BDecContent - -AsnLen SubjectPublicKeyInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void SubjectPublicKeyInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "SubjectPublicKeyInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-123); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void SubjectPublicKeyInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (algorithm)) - { - Indent (os, indentG); - os << "algorithm "; - os << *algorithm; - } - else - { - Indent (os, indentG); - os << "algorithm "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "subjectPublicKey "; - os << subjectPublicKey; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // SubjectPublicKeyInfo::Print - - -AsnType *Extensions::Clone() const -{ - return new Extensions; -} - -AsnType *Extensions::Copy() const -{ - return new Extensions (*this); -} - -AsnLen Extensions::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void Extensions::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Extensions::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-124); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -Extensions::Extensions (const Extensions &) -{ - Asn1Error << "use of incompletely defined Extensions::Extensions (const Extensions &)" << endl; - abort(); -} - -Extensions::~Extensions() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -Extensions &Extensions::operator = (const Extensions &that) -#else // SNACC_DEEP_COPY -Extensions &Extensions::operator = (const Extensions &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Extensions &Extensions::operator = (const Extensions &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void Extensions::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void Extensions::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // Extensions::SetCurrElmt - - -unsigned long int Extensions::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // Extensions::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -Extension *Extensions::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Extension; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // Extensions::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -Extension *Extensions::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Extension; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // Extensions::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -Extension *Extensions::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Extension; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // Extensions::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -Extension *Extensions::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Extension; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // Extensions::InsertAfter - - -Extensions &Extensions::AppendCopy (Extension &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Extension; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -Extensions &Extensions::PrependCopy (Extension &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Extension; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // Extensions::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -Extensions &Extensions::InsertBeforeAndCopy (Extension &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Extension; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // Extensions::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -Extensions &Extensions::InsertAfterAndCopy (Extension &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Extension; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // Extensions::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void Extensions::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen Extensions::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // Extensions::BEncContent - - -void Extensions::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - Extension *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-125); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // Extensions::BDecContent - - -IssuerSerial::IssuerSerial() -{ - issuerUID = NULL; -} - -IssuerSerial::IssuerSerial (const IssuerSerial &) -{ - Asn1Error << "use of incompletely defined IssuerSerial::IssuerSerial (const IssuerSerial &)" << endl; - abort(); -} - -IssuerSerial::~IssuerSerial() -{ - delete issuerUID; -} - -AsnType *IssuerSerial::Clone() const -{ - return new IssuerSerial; -} - -AsnType *IssuerSerial::Copy() const -{ - return new IssuerSerial (*this); -} - -#if SNACC_DEEP_COPY -IssuerSerial &IssuerSerial::operator = (const IssuerSerial &that) -#else // SNACC_DEEP_COPY -IssuerSerial &IssuerSerial::operator = (const IssuerSerial &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - issuer = that.issuer; - serial = that.serial; - if (that.issuerUID) - { - if (!issuerUID) - issuerUID = new UniqueIdentifier; - *issuerUID = *that.issuerUID; - } - else - { - delete issuerUID; - issuerUID = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined IssuerSerial &IssuerSerial::operator = (const IssuerSerial &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -IssuerSerial::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (issuerUID)) - { - l = issuerUID->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - } - - l = serial.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = issuer.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // IssuerSerial::BEncContent - - -void IssuerSerial::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuer.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-126); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - serial.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-127); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuerUID = new UniqueIdentifier; - issuerUID->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-128); - } - else - return; -} // IssuerSerial::BDecContent - -AsnLen IssuerSerial::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void IssuerSerial::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "IssuerSerial::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-129); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void IssuerSerial::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "issuer "; - os << issuer; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "serial "; - os << serial; - os << "," << endl; - } - - if (NOT_NULL (issuerUID)) - { - os << ","<< endl; - Indent (os, indentG); - os << "issuerUID "; - os << *issuerUID; - } - else - { - Indent (os, indentG); - os << "issuerUID "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // IssuerSerial::Print - - -AttributeCertificateAssertionChoice::AttributeCertificateAssertionChoice() -{ - choiceId = baseCertificateIDCid; -#if TCL - baseCertificateID = new IssuerSerial; -#else - baseCertificateID = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -AttributeCertificateAssertionChoice::AttributeCertificateAssertionChoice (const AttributeCertificateAssertionChoice &) -{ - Asn1Error << "use of incompletely defined AttributeCertificateAssertionChoice::AttributeCertificateAssertionChoice (const AttributeCertificateAssertionChoice &)" << endl; - abort(); -} - -AttributeCertificateAssertionChoice::~AttributeCertificateAssertionChoice() -{ - switch (choiceId) - { - case baseCertificateIDCid: - delete baseCertificateID; - break; - case subjectNameCid: - delete subjectName; - break; - } // end of switch -} // end of destructor - -AsnType *AttributeCertificateAssertionChoice::Clone() const -{ - return new AttributeCertificateAssertionChoice; -} - -AsnType *AttributeCertificateAssertionChoice::Copy() const -{ - return new AttributeCertificateAssertionChoice (*this); -} - -#if SNACC_DEEP_COPY -AttributeCertificateAssertionChoice &AttributeCertificateAssertionChoice::operator = (const AttributeCertificateAssertionChoice &that) -#else // SNACC_DEEP_COPY -AttributeCertificateAssertionChoice &AttributeCertificateAssertionChoice::operator = (const AttributeCertificateAssertionChoice &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case baseCertificateIDCid: - delete baseCertificateID; - break; - case subjectNameCid: - delete subjectName; - break; - } - switch (choiceId = that.choiceId) - { - case baseCertificateIDCid: - baseCertificateID = new IssuerSerial; - *baseCertificateID = *that.baseCertificateID; - break; - case subjectNameCid: - subjectName = new Name; - *subjectName = *that.subjectName; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificateAssertionChoice &AttributeCertificateAssertionChoice::operator = (const AttributeCertificateAssertionChoice &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttributeCertificateAssertionChoice::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case baseCertificateIDCid: - BEncEocIfNec (b); - BEncEocIfNec (b); - l = baseCertificateID->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - break; - - case subjectNameCid: - BEncEocIfNec (b); - l = subjectName->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - break; - - } // end switch - return l; -} // AttributeCertificateAssertionChoice::BEncContent - - -void AttributeCertificateAssertionChoice::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen1; - switch (tag) - { - case MAKE_TAG_ID (CNTX, CONS, 0): - tag = BDecTag (b, bytesDecoded, env); - if (tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-130); - } - - elmtLen1 = BDecLen (b, bytesDecoded, env); - choiceId = baseCertificateIDCid; - baseCertificateID = new IssuerSerial; - baseCertificateID->BDecContent (b, tag, elmtLen1, bytesDecoded, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - tag = BDecTag (b, bytesDecoded, env); - elmtLen1 = BDecLen (b, bytesDecoded, env); - choiceId = subjectNameCid; - subjectName = new Name; - subjectName->BDecContent (b, tag, elmtLen1, bytesDecoded, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-131); - break; - } // end switch -} // AttributeCertificateAssertionChoice::BDecContent - - -AsnLen AttributeCertificateAssertionChoice::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void AttributeCertificateAssertionChoice::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void AttributeCertificateAssertionChoice::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case baseCertificateIDCid: - os << "baseCertificateID "; - if (baseCertificateID) - os << *baseCertificateID; - else - os << "-- void3 --\n"; - break; - - case subjectNameCid: - os << "subjectName "; - if (subjectName) - os << *subjectName; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // AttributeCertificateAssertionChoice::Print - -AttributeCertificateInfoChoice::AttributeCertificateInfoChoice() -{ - choiceId = baseCertificateIDCid; -#if TCL - baseCertificateID = new IssuerSerial; -#else - baseCertificateID = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -AttributeCertificateInfoChoice::AttributeCertificateInfoChoice (const AttributeCertificateInfoChoice &) -{ - Asn1Error << "use of incompletely defined AttributeCertificateInfoChoice::AttributeCertificateInfoChoice (const AttributeCertificateInfoChoice &)" << endl; - abort(); -} - -AttributeCertificateInfoChoice::~AttributeCertificateInfoChoice() -{ - switch (choiceId) - { - case baseCertificateIDCid: - delete baseCertificateID; - break; - case subjectNameCid: - delete subjectName; - break; - } // end of switch -} // end of destructor - -AsnType *AttributeCertificateInfoChoice::Clone() const -{ - return new AttributeCertificateInfoChoice; -} - -AsnType *AttributeCertificateInfoChoice::Copy() const -{ - return new AttributeCertificateInfoChoice (*this); -} - -#if SNACC_DEEP_COPY -AttributeCertificateInfoChoice &AttributeCertificateInfoChoice::operator = (const AttributeCertificateInfoChoice &that) -#else // SNACC_DEEP_COPY -AttributeCertificateInfoChoice &AttributeCertificateInfoChoice::operator = (const AttributeCertificateInfoChoice &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case baseCertificateIDCid: - delete baseCertificateID; - break; - case subjectNameCid: - delete subjectName; - break; - } - switch (choiceId = that.choiceId) - { - case baseCertificateIDCid: - baseCertificateID = new IssuerSerial; - *baseCertificateID = *that.baseCertificateID; - break; - case subjectNameCid: - subjectName = new GeneralNames; - *subjectName = *that.subjectName; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificateInfoChoice &AttributeCertificateInfoChoice::operator = (const AttributeCertificateInfoChoice &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttributeCertificateInfoChoice::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case baseCertificateIDCid: - BEncEocIfNec (b); - BEncEocIfNec (b); - l = baseCertificateID->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - break; - - case subjectNameCid: - BEncEocIfNec (b); - BEncEocIfNec (b); - l = subjectName->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - break; - - } // end switch - return l; -} // AttributeCertificateInfoChoice::BEncContent - - -void AttributeCertificateInfoChoice::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen1; - switch (tag) - { - case MAKE_TAG_ID (CNTX, CONS, 0): - tag = BDecTag (b, bytesDecoded, env); - if (tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-132); - } - - elmtLen1 = BDecLen (b, bytesDecoded, env); - choiceId = baseCertificateIDCid; - baseCertificateID = new IssuerSerial; - baseCertificateID->BDecContent (b, tag, elmtLen1, bytesDecoded, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - tag = BDecTag (b, bytesDecoded, env); - if (tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-133); - } - - elmtLen1 = BDecLen (b, bytesDecoded, env); - choiceId = subjectNameCid; - subjectName = new GeneralNames; - subjectName->BDecContent (b, tag, elmtLen1, bytesDecoded, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-134); - break; - } // end switch -} // AttributeCertificateInfoChoice::BDecContent - - -AsnLen AttributeCertificateInfoChoice::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void AttributeCertificateInfoChoice::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void AttributeCertificateInfoChoice::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case baseCertificateIDCid: - os << "baseCertificateID "; - if (baseCertificateID) - os << *baseCertificateID; - else - os << "-- void3 --\n"; - break; - - case subjectNameCid: - os << "subjectName "; - if (subjectName) - os << *subjectName; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // AttributeCertificateInfoChoice::Print - -CRLToSignSeqOfSeq::CRLToSignSeqOfSeq() -{ -#if TCL - revocationDate = new Time; -#else - revocationDate = NULL; // incomplete initialization of mandatory element! -#endif // TCL - crlEntryExtensions = NULL; -} - -CRLToSignSeqOfSeq::CRLToSignSeqOfSeq (const CRLToSignSeqOfSeq &) -{ - Asn1Error << "use of incompletely defined CRLToSignSeqOfSeq::CRLToSignSeqOfSeq (const CRLToSignSeqOfSeq &)" << endl; - abort(); -} - -CRLToSignSeqOfSeq::~CRLToSignSeqOfSeq() -{ - delete revocationDate; - delete crlEntryExtensions; -} - -AsnType *CRLToSignSeqOfSeq::Clone() const -{ - return new CRLToSignSeqOfSeq; -} - -AsnType *CRLToSignSeqOfSeq::Copy() const -{ - return new CRLToSignSeqOfSeq (*this); -} - -#if SNACC_DEEP_COPY -CRLToSignSeqOfSeq &CRLToSignSeqOfSeq::operator = (const CRLToSignSeqOfSeq &that) -#else // SNACC_DEEP_COPY -CRLToSignSeqOfSeq &CRLToSignSeqOfSeq::operator = (const CRLToSignSeqOfSeq &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - userCertificate = that.userCertificate; - if (that.revocationDate) - { - if (!revocationDate) - revocationDate = new Time; - *revocationDate = *that.revocationDate; - } - else - { - delete revocationDate; - revocationDate = NULL; - } - if (that.crlEntryExtensions) - { - if (!crlEntryExtensions) - crlEntryExtensions = new Extensions; - *crlEntryExtensions = *that.crlEntryExtensions; - } - else - { - delete crlEntryExtensions; - crlEntryExtensions = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CRLToSignSeqOfSeq &CRLToSignSeqOfSeq::operator = (const CRLToSignSeqOfSeq &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CRLToSignSeqOfSeq::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (crlEntryExtensions)) - { - BEncEocIfNec (b); - l = crlEntryExtensions->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - l = revocationDate->BEncContent (b); - totalLen += l; - - l = userCertificate.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - return totalLen; -} // CRLToSignSeqOfSeq::BEncContent - - -void CRLToSignSeqOfSeq::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - userCertificate.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-135); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - revocationDate = new Time; - revocationDate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-136); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - crlEntryExtensions = new Extensions; - crlEntryExtensions->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-137); - } - else - return; -} // CRLToSignSeqOfSeq::BDecContent - -AsnLen CRLToSignSeqOfSeq::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CRLToSignSeqOfSeq::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CRLToSignSeqOfSeq::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-138); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CRLToSignSeqOfSeq::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "userCertificate "; - os << userCertificate; - os << "," << endl; - } - - if (NOT_NULL (revocationDate)) - { - Indent (os, indentG); - os << "revocationDate "; - os << *revocationDate; - } - else - { - Indent (os, indentG); - os << "revocationDate "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (crlEntryExtensions)) - { - os << ","<< endl; - Indent (os, indentG); - os << "crlEntryExtensions "; - os << *crlEntryExtensions; - } - else - { - Indent (os, indentG); - os << "crlEntryExtensions "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CRLToSignSeqOfSeq::Print - - -AsnType *CRLToSignSeqOf::Clone() const -{ - return new CRLToSignSeqOf; -} - -AsnType *CRLToSignSeqOf::Copy() const -{ - return new CRLToSignSeqOf (*this); -} - -AsnLen CRLToSignSeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CRLToSignSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CRLToSignSeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-139); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -CRLToSignSeqOf::CRLToSignSeqOf (const CRLToSignSeqOf &) -{ - Asn1Error << "use of incompletely defined CRLToSignSeqOf::CRLToSignSeqOf (const CRLToSignSeqOf &)" << endl; - abort(); -} - -CRLToSignSeqOf::~CRLToSignSeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -CRLToSignSeqOf &CRLToSignSeqOf::operator = (const CRLToSignSeqOf &that) -#else // SNACC_DEEP_COPY -CRLToSignSeqOf &CRLToSignSeqOf::operator = (const CRLToSignSeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CRLToSignSeqOf &CRLToSignSeqOf::operator = (const CRLToSignSeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void CRLToSignSeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void CRLToSignSeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // CRLToSignSeqOf::SetCurrElmt - - -unsigned long int CRLToSignSeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // CRLToSignSeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -CRLToSignSeqOfSeq *CRLToSignSeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CRLToSignSeqOfSeq; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CRLToSignSeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -CRLToSignSeqOfSeq *CRLToSignSeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CRLToSignSeqOfSeq; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CRLToSignSeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -CRLToSignSeqOfSeq *CRLToSignSeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CRLToSignSeqOfSeq; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CRLToSignSeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CRLToSignSeqOfSeq *CRLToSignSeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CRLToSignSeqOfSeq; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CRLToSignSeqOf::InsertAfter - - -CRLToSignSeqOf &CRLToSignSeqOf::AppendCopy (CRLToSignSeqOfSeq &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CRLToSignSeqOfSeq; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -CRLToSignSeqOf &CRLToSignSeqOf::PrependCopy (CRLToSignSeqOfSeq &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CRLToSignSeqOfSeq; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // CRLToSignSeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -CRLToSignSeqOf &CRLToSignSeqOf::InsertBeforeAndCopy (CRLToSignSeqOfSeq &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CRLToSignSeqOfSeq; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // CRLToSignSeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CRLToSignSeqOf &CRLToSignSeqOf::InsertAfterAndCopy (CRLToSignSeqOfSeq &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CRLToSignSeqOfSeq; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // CRLToSignSeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void CRLToSignSeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen CRLToSignSeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // CRLToSignSeqOf::BEncContent - - -void CRLToSignSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - CRLToSignSeqOfSeq *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-140); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // CRLToSignSeqOf::BDecContent - - -CertificateToSign::CertificateToSign() -{ - version = NULL; -#if TCL - signature = new AlgorithmIdentifier; -#else - signature = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - issuer = new Name; -#else - issuer = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - validity = new Validity; -#else - validity = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - subject = new Name; -#else - subject = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - subjectPublicKeyInfo = new SubjectPublicKeyInfo; -#else - subjectPublicKeyInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL - issuerUniqueIdentifier = NULL; - subjectUniqueIdentifier = NULL; - extensions = NULL; -} - -CertificateToSign::CertificateToSign (const CertificateToSign &) -{ - Asn1Error << "use of incompletely defined CertificateToSign::CertificateToSign (const CertificateToSign &)" << endl; - abort(); -} - -CertificateToSign::~CertificateToSign() -{ - delete version; - delete signature; - delete issuer; - delete validity; - delete subject; - delete subjectPublicKeyInfo; - delete issuerUniqueIdentifier; - delete subjectUniqueIdentifier; - delete extensions; -} - -AsnType *CertificateToSign::Clone() const -{ - return new CertificateToSign; -} - -AsnType *CertificateToSign::Copy() const -{ - return new CertificateToSign (*this); -} - -#if SNACC_DEEP_COPY -CertificateToSign &CertificateToSign::operator = (const CertificateToSign &that) -#else // SNACC_DEEP_COPY -CertificateToSign &CertificateToSign::operator = (const CertificateToSign &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.version) - { - if (!version) - version = new Version; - *version = *that.version; - } - else - { - delete version; - version = NULL; - } - serialNumber = that.serialNumber; - if (that.signature) - { - if (!signature) - signature = new AlgorithmIdentifier; - *signature = *that.signature; - } - else - { - delete signature; - signature = NULL; - } - if (that.issuer) - { - if (!issuer) - issuer = new Name; - *issuer = *that.issuer; - } - else - { - delete issuer; - issuer = NULL; - } - if (that.validity) - { - if (!validity) - validity = new Validity; - *validity = *that.validity; - } - else - { - delete validity; - validity = NULL; - } - if (that.subject) - { - if (!subject) - subject = new Name; - *subject = *that.subject; - } - else - { - delete subject; - subject = NULL; - } - if (that.subjectPublicKeyInfo) - { - if (!subjectPublicKeyInfo) - subjectPublicKeyInfo = new SubjectPublicKeyInfo; - *subjectPublicKeyInfo = *that.subjectPublicKeyInfo; - } - else - { - delete subjectPublicKeyInfo; - subjectPublicKeyInfo = NULL; - } - if (that.issuerUniqueIdentifier) - { - if (!issuerUniqueIdentifier) - issuerUniqueIdentifier = new UniqueIdentifier; - *issuerUniqueIdentifier = *that.issuerUniqueIdentifier; - } - else - { - delete issuerUniqueIdentifier; - issuerUniqueIdentifier = NULL; - } - if (that.subjectUniqueIdentifier) - { - if (!subjectUniqueIdentifier) - subjectUniqueIdentifier = new UniqueIdentifier; - *subjectUniqueIdentifier = *that.subjectUniqueIdentifier; - } - else - { - delete subjectUniqueIdentifier; - subjectUniqueIdentifier = NULL; - } - if (that.extensions) - { - if (!extensions) - extensions = new Extensions; - *extensions = *that.extensions; - } - else - { - delete extensions; - extensions = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificateToSign &CertificateToSign::operator = (const CertificateToSign &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CertificateToSign::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (extensions)) - { - BEncEocIfNec (b); - BEncEocIfNec (b); - l = extensions->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 3); - totalLen += l; - } - - if (NOT_NULL (subjectUniqueIdentifier)) - { - l = subjectUniqueIdentifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 2); - totalLen += l; - } - - if (NOT_NULL (issuerUniqueIdentifier)) - { - l = issuerUniqueIdentifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 1); - totalLen += l; - } - - BEncEocIfNec (b); - l = subjectPublicKeyInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = subject->BEncContent (b); - totalLen += l; - - BEncEocIfNec (b); - l = validity->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = issuer->BEncContent (b); - totalLen += l; - - BEncEocIfNec (b); - l = signature->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = serialNumber.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - if (NOT_NULL (version)) - { - BEncEocIfNec (b); - l = version->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // CertificateToSign::BEncContent - - -void CertificateToSign::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if (tag1 != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-141); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - version = new Version; - version->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - serialNumber.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-142); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signature = new AlgorithmIdentifier; - signature->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-143); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuer = new Name; - issuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-144); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - validity = new Validity; - validity->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-145); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subject = new Name; - subject->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-146); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subjectPublicKeyInfo = new SubjectPublicKeyInfo; - subjectPublicKeyInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-147); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuerUniqueIdentifier = new UniqueIdentifier; - issuerUniqueIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 2)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subjectUniqueIdentifier = new UniqueIdentifier; - subjectUniqueIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 3))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-148); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - extensions = new Extensions; - extensions->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-149); - } - else - return; -} // CertificateToSign::BDecContent - -AsnLen CertificateToSign::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificateToSign::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificateToSign::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-150); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CertificateToSign::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (version)) - { - Indent (os, indentG); - os << "version "; - os << *version; - } - else - { - Indent (os, indentG); - os << "version "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "serialNumber "; - os << serialNumber; - os << "," << endl; - } - - if (NOT_NULL (signature)) - { - Indent (os, indentG); - os << "signature "; - os << *signature; - } - else - { - Indent (os, indentG); - os << "signature "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (issuer)) - { - Indent (os, indentG); - os << "issuer "; - os << *issuer; - } - else - { - Indent (os, indentG); - os << "issuer "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (validity)) - { - Indent (os, indentG); - os << "validity "; - os << *validity; - } - else - { - Indent (os, indentG); - os << "validity "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (subject)) - { - Indent (os, indentG); - os << "subject "; - os << *subject; - } - else - { - Indent (os, indentG); - os << "subject "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (subjectPublicKeyInfo)) - { - Indent (os, indentG); - os << "subjectPublicKeyInfo "; - os << *subjectPublicKeyInfo; - } - else - { - Indent (os, indentG); - os << "subjectPublicKeyInfo "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (issuerUniqueIdentifier)) - { - os << ","<< endl; - Indent (os, indentG); - os << "issuerUniqueIdentifier "; - os << *issuerUniqueIdentifier; - } - else - { - Indent (os, indentG); - os << "issuerUniqueIdentifier "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (subjectUniqueIdentifier)) - { - os << ","<< endl; - Indent (os, indentG); - os << "subjectUniqueIdentifier "; - os << *subjectUniqueIdentifier; - } - else - { - Indent (os, indentG); - os << "subjectUniqueIdentifier "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (extensions)) - { - os << ","<< endl; - Indent (os, indentG); - os << "extensions "; - os << *extensions; - } - else - { - Indent (os, indentG); - os << "extensions "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CertificateToSign::Print - - -CRLToSign::CRLToSign() -{ - version = NULL; -#if TCL - signature = new AlgorithmIdentifier; -#else - signature = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - issuer = new Name; -#else - issuer = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - thisUpdate = new Time; -#else - thisUpdate = NULL; // incomplete initialization of mandatory element! -#endif // TCL - nextUpdate = NULL; - revokedCertificates = NULL; - crlExtensions = NULL; -} - -CRLToSign::CRLToSign (const CRLToSign &) -{ - Asn1Error << "use of incompletely defined CRLToSign::CRLToSign (const CRLToSign &)" << endl; - abort(); -} - -CRLToSign::~CRLToSign() -{ - delete version; - delete signature; - delete issuer; - delete thisUpdate; - delete nextUpdate; - delete revokedCertificates; - delete crlExtensions; -} - -AsnType *CRLToSign::Clone() const -{ - return new CRLToSign; -} - -AsnType *CRLToSign::Copy() const -{ - return new CRLToSign (*this); -} - -#if SNACC_DEEP_COPY -CRLToSign &CRLToSign::operator = (const CRLToSign &that) -#else // SNACC_DEEP_COPY -CRLToSign &CRLToSign::operator = (const CRLToSign &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.version) - { - if (!version) - version = new Version; - *version = *that.version; - } - else - { - delete version; - version = NULL; - } - if (that.signature) - { - if (!signature) - signature = new AlgorithmIdentifier; - *signature = *that.signature; - } - else - { - delete signature; - signature = NULL; - } - if (that.issuer) - { - if (!issuer) - issuer = new Name; - *issuer = *that.issuer; - } - else - { - delete issuer; - issuer = NULL; - } - if (that.thisUpdate) - { - if (!thisUpdate) - thisUpdate = new Time; - *thisUpdate = *that.thisUpdate; - } - else - { - delete thisUpdate; - thisUpdate = NULL; - } - if (that.nextUpdate) - { - if (!nextUpdate) - nextUpdate = new Time; - *nextUpdate = *that.nextUpdate; - } - else - { - delete nextUpdate; - nextUpdate = NULL; - } - if (that.revokedCertificates) - { - if (!revokedCertificates) - revokedCertificates = new CRLToSignSeqOf; - *revokedCertificates = *that.revokedCertificates; - } - else - { - delete revokedCertificates; - revokedCertificates = NULL; - } - if (that.crlExtensions) - { - if (!crlExtensions) - crlExtensions = new Extensions; - *crlExtensions = *that.crlExtensions; - } - else - { - delete crlExtensions; - crlExtensions = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CRLToSign &CRLToSign::operator = (const CRLToSign &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CRLToSign::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (crlExtensions)) - { - BEncEocIfNec (b); - BEncEocIfNec (b); - l = crlExtensions->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - if (NOT_NULL (revokedCertificates)) - { - BEncEocIfNec (b); - l = revokedCertificates->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (nextUpdate)) - { - l = nextUpdate->BEncContent (b); - totalLen += l; - } - - l = thisUpdate->BEncContent (b); - totalLen += l; - - l = issuer->BEncContent (b); - totalLen += l; - - BEncEocIfNec (b); - l = signature->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - if (NOT_NULL (version)) - { - l = version->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - } - - return totalLen; -} // CRLToSign::BEncContent - - -void CRLToSign::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version = new Version; - version->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signature = new AlgorithmIdentifier; - signature->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-151); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuer = new Name; - issuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-152); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - thisUpdate = new Time; - thisUpdate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-153); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - nextUpdate = new Time; - nextUpdate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - revokedCertificates = new CRLToSignSeqOf; - revokedCertificates->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-154); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - crlExtensions = new Extensions; - crlExtensions->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-155); - } - else - return; -} // CRLToSign::BDecContent - -AsnLen CRLToSign::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CRLToSign::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CRLToSign::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-156); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CRLToSign::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (version)) - { - Indent (os, indentG); - os << "version "; - os << *version; - } - else - { - Indent (os, indentG); - os << "version "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (signature)) - { - Indent (os, indentG); - os << "signature "; - os << *signature; - } - else - { - Indent (os, indentG); - os << "signature "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (issuer)) - { - Indent (os, indentG); - os << "issuer "; - os << *issuer; - } - else - { - Indent (os, indentG); - os << "issuer "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (thisUpdate)) - { - Indent (os, indentG); - os << "thisUpdate "; - os << *thisUpdate; - } - else - { - Indent (os, indentG); - os << "thisUpdate "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (nextUpdate)) - { - os << ","<< endl; - Indent (os, indentG); - os << "nextUpdate "; - os << *nextUpdate; - } - else - { - Indent (os, indentG); - os << "nextUpdate "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (revokedCertificates)) - { - os << ","<< endl; - Indent (os, indentG); - os << "revokedCertificates "; - os << *revokedCertificates; - } - else - { - Indent (os, indentG); - os << "revokedCertificates "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (crlExtensions)) - { - os << ","<< endl; - Indent (os, indentG); - os << "crlExtensions "; - os << *crlExtensions; - } - else - { - Indent (os, indentG); - os << "crlExtensions "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CRLToSign::Print - - -AttributeCertificateInfo::AttributeCertificateInfo() -{ - version = NULL; -#if TCL - subject = new AttributeCertificateInfoChoice; -#else - subject = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - signature = new AlgorithmIdentifier; -#else - signature = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - attCertValidityPeriod = new AttCertValidityPeriod; -#else - attCertValidityPeriod = NULL; // incomplete initialization of mandatory element! -#endif // TCL - issuerUniqueID = NULL; - extensions = NULL; -} - -AttributeCertificateInfo::AttributeCertificateInfo (const AttributeCertificateInfo &) -{ - Asn1Error << "use of incompletely defined AttributeCertificateInfo::AttributeCertificateInfo (const AttributeCertificateInfo &)" << endl; - abort(); -} - -AttributeCertificateInfo::~AttributeCertificateInfo() -{ - delete version; - delete subject; - delete signature; - delete attCertValidityPeriod; - delete issuerUniqueID; - delete extensions; -} - -AsnType *AttributeCertificateInfo::Clone() const -{ - return new AttributeCertificateInfo; -} - -AsnType *AttributeCertificateInfo::Copy() const -{ - return new AttributeCertificateInfo (*this); -} - -#if SNACC_DEEP_COPY -AttributeCertificateInfo &AttributeCertificateInfo::operator = (const AttributeCertificateInfo &that) -#else // SNACC_DEEP_COPY -AttributeCertificateInfo &AttributeCertificateInfo::operator = (const AttributeCertificateInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.version) - { - if (!version) - version = new Version; - *version = *that.version; - } - else - { - delete version; - version = NULL; - } - if (that.subject) - { - if (!subject) - subject = new AttributeCertificateInfoChoice; - *subject = *that.subject; - } - else - { - delete subject; - subject = NULL; - } - issuer = that.issuer; - if (that.signature) - { - if (!signature) - signature = new AlgorithmIdentifier; - *signature = *that.signature; - } - else - { - delete signature; - signature = NULL; - } - serialNumber = that.serialNumber; - if (that.attCertValidityPeriod) - { - if (!attCertValidityPeriod) - attCertValidityPeriod = new AttCertValidityPeriod; - *attCertValidityPeriod = *that.attCertValidityPeriod; - } - else - { - delete attCertValidityPeriod; - attCertValidityPeriod = NULL; - } - attributes = that.attributes; - if (that.issuerUniqueID) - { - if (!issuerUniqueID) - issuerUniqueID = new UniqueIdentifier; - *issuerUniqueID = *that.issuerUniqueID; - } - else - { - delete issuerUniqueID; - issuerUniqueID = NULL; - } - if (that.extensions) - { - if (!extensions) - extensions = new Extensions; - *extensions = *that.extensions; - } - else - { - delete extensions; - extensions = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificateInfo &AttributeCertificateInfo::operator = (const AttributeCertificateInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttributeCertificateInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (extensions)) - { - BEncEocIfNec (b); - l = extensions->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (issuerUniqueID)) - { - l = issuerUniqueID->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - } - - BEncEocIfNec (b); - l = attributes.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = attCertValidityPeriod->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = serialNumber.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = signature->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = issuer.BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - l = subject->BEncContent (b); - totalLen += l; - - if (NOT_NULL (version)) - { - l = version->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - } - - return totalLen; -} // AttributeCertificateInfo::BEncContent - - -void AttributeCertificateInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - version = new Version; - version->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subject = new AttributeCertificateInfoChoice; - subject->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-157); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuer.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-158); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signature = new AlgorithmIdentifier; - signature->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-159); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - serialNumber.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-160); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - attCertValidityPeriod = new AttCertValidityPeriod; - attCertValidityPeriod->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-161); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - attributes.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-162); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuerUniqueID = new UniqueIdentifier; - issuerUniqueID->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - extensions = new Extensions; - extensions->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-163); - } - else - return; -} // AttributeCertificateInfo::BDecContent - -AsnLen AttributeCertificateInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributeCertificateInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributeCertificateInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-164); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AttributeCertificateInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (version)) - { - Indent (os, indentG); - os << "version "; - os << *version; - } - else - { - Indent (os, indentG); - os << "version "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (subject)) - { - Indent (os, indentG); - os << "subject "; - os << *subject; - } - else - { - Indent (os, indentG); - os << "subject "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "issuer "; - os << issuer; - os << "," << endl; - } - - if (NOT_NULL (signature)) - { - Indent (os, indentG); - os << "signature "; - os << *signature; - } - else - { - Indent (os, indentG); - os << "signature "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "serialNumber "; - os << serialNumber; - os << "," << endl; - } - - if (NOT_NULL (attCertValidityPeriod)) - { - Indent (os, indentG); - os << "attCertValidityPeriod "; - os << *attCertValidityPeriod; - } - else - { - Indent (os, indentG); - os << "attCertValidityPeriod "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "attributes "; - os << attributes; - os << "," << endl; - } - - if (NOT_NULL (issuerUniqueID)) - { - os << ","<< endl; - Indent (os, indentG); - os << "issuerUniqueID "; - os << *issuerUniqueID; - } - else - { - Indent (os, indentG); - os << "issuerUniqueID "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (extensions)) - { - os << ","<< endl; - Indent (os, indentG); - os << "extensions "; - os << *extensions; - } - else - { - Indent (os, indentG); - os << "extensions "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AttributeCertificateInfo::Print - - -Certificate::Certificate() -{ -#if TCL - certificateToSign = new CertificateToSign; -#else - certificateToSign = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - algorithmIdentifier = new AlgorithmIdentifier; -#else - algorithmIdentifier = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -Certificate::Certificate (const Certificate &) -{ - Asn1Error << "use of incompletely defined Certificate::Certificate (const Certificate &)" << endl; - abort(); -} - -Certificate::~Certificate() -{ - delete certificateToSign; - delete algorithmIdentifier; -} - -AsnType *Certificate::Clone() const -{ - return new Certificate; -} - -AsnType *Certificate::Copy() const -{ - return new Certificate (*this); -} - -#if SNACC_DEEP_COPY -Certificate &Certificate::operator = (const Certificate &that) -#else // SNACC_DEEP_COPY -Certificate &Certificate::operator = (const Certificate &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.certificateToSign) - { - if (!certificateToSign) - certificateToSign = new CertificateToSign; - *certificateToSign = *that.certificateToSign; - } - else - { - delete certificateToSign; - certificateToSign = NULL; - } - if (that.algorithmIdentifier) - { - if (!algorithmIdentifier) - algorithmIdentifier = new AlgorithmIdentifier; - *algorithmIdentifier = *that.algorithmIdentifier; - } - else - { - delete algorithmIdentifier; - algorithmIdentifier = NULL; - } - signatureValue = that.signatureValue; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Certificate &Certificate::operator = (const Certificate &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -Certificate::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = signatureValue.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = algorithmIdentifier->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = certificateToSign->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // Certificate::BEncContent - - -void Certificate::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - certificateToSign = new CertificateToSign; - certificateToSign->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-165); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - algorithmIdentifier = new AlgorithmIdentifier; - algorithmIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-166); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signatureValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-167); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-168); - } - else - return; -} // Certificate::BDecContent - -AsnLen Certificate::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void Certificate::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Certificate::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-169); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void Certificate::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (certificateToSign)) - { - Indent (os, indentG); - os << "certificateToSign "; - os << *certificateToSign; - } - else - { - Indent (os, indentG); - os << "certificateToSign "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (algorithmIdentifier)) - { - Indent (os, indentG); - os << "algorithmIdentifier "; - os << *algorithmIdentifier; - } - else - { - Indent (os, indentG); - os << "algorithmIdentifier "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signatureValue "; - os << signatureValue; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // Certificate::Print - - -AsnType *CrossCertificates::Clone() const -{ - return new CrossCertificates; -} - -AsnType *CrossCertificates::Copy() const -{ - return new CrossCertificates (*this); -} - -AsnLen CrossCertificates::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - return l; -} - -void CrossCertificates::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "CrossCertificates::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-170); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -CrossCertificates::CrossCertificates (const CrossCertificates &) -{ - Asn1Error << "use of incompletely defined CrossCertificates::CrossCertificates (const CrossCertificates &)" << endl; - abort(); -} - -CrossCertificates::~CrossCertificates() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -CrossCertificates &CrossCertificates::operator = (const CrossCertificates &that) -#else // SNACC_DEEP_COPY -CrossCertificates &CrossCertificates::operator = (const CrossCertificates &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CrossCertificates &CrossCertificates::operator = (const CrossCertificates &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void CrossCertificates::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void CrossCertificates::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // CrossCertificates::SetCurrElmt - - -unsigned long int CrossCertificates::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // CrossCertificates::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -Certificate *CrossCertificates::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Certificate; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CrossCertificates::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -Certificate *CrossCertificates::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Certificate; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CrossCertificates::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -Certificate *CrossCertificates::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Certificate; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CrossCertificates::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -Certificate *CrossCertificates::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Certificate; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CrossCertificates::InsertAfter - - -CrossCertificates &CrossCertificates::AppendCopy (Certificate &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Certificate; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -CrossCertificates &CrossCertificates::PrependCopy (Certificate &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Certificate; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // CrossCertificates::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -CrossCertificates &CrossCertificates::InsertBeforeAndCopy (Certificate &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Certificate; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // CrossCertificates::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CrossCertificates &CrossCertificates::InsertAfterAndCopy (Certificate &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Certificate; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // CrossCertificates::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void CrossCertificates::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen CrossCertificates::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - { - int iii,icount; - CSM_Buffer **tmpEnc=NULL; - for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++); - tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount); - for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0) - { - BEncEocIfNec (b); - ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen); - elmtLen += BEncConsLen (outputBuf, elmtLen); - - elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE); - ENCODE_BUF2(tmpEnc[iii]); - } - vdasnacc_sortSetOf(tmpEnc, icount); - for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length()) - SM_WriteToAsnBuf(tmpEnc[iii], b); - for (iii=0; iii < icount; iii++) delete tmpEnc[iii]; - free(tmpEnc); - } - totalLen += elmtLen; - return totalLen; -} // CrossCertificates::BEncContent - - -void CrossCertificates::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - Certificate *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-171); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // CrossCertificates::BDecContent - - -CertificatePair::CertificatePair() -{ - forward = NULL; - reverse = NULL; -} - -CertificatePair::CertificatePair (const CertificatePair &) -{ - Asn1Error << "use of incompletely defined CertificatePair::CertificatePair (const CertificatePair &)" << endl; - abort(); -} - -CertificatePair::~CertificatePair() -{ - delete forward; - delete reverse; -} - -AsnType *CertificatePair::Clone() const -{ - return new CertificatePair; -} - -AsnType *CertificatePair::Copy() const -{ - return new CertificatePair (*this); -} - -#if SNACC_DEEP_COPY -CertificatePair &CertificatePair::operator = (const CertificatePair &that) -#else // SNACC_DEEP_COPY -CertificatePair &CertificatePair::operator = (const CertificatePair &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.forward) - { - if (!forward) - forward = new Certificate; - *forward = *that.forward; - } - else - { - delete forward; - forward = NULL; - } - if (that.reverse) - { - if (!reverse) - reverse = new Certificate; - *reverse = *that.reverse; - } - else - { - delete reverse; - reverse = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificatePair &CertificatePair::operator = (const CertificatePair &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CertificatePair::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (reverse)) - { - BEncEocIfNec (b); - BEncEocIfNec (b); - l = reverse->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - if (NOT_NULL (forward)) - { - BEncEocIfNec (b); - BEncEocIfNec (b); - l = forward->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // CertificatePair::BEncContent - - -void CertificatePair::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-172); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - forward = new Certificate; - forward->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-173); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - reverse = new Certificate; - reverse->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-174); - } - else - return; -} // CertificatePair::BDecContent - -AsnLen CertificatePair::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificatePair::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificatePair::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-175); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CertificatePair::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (forward)) - { - nonePrinted = false; - Indent (os, indentG); - os << "forward "; - os << *forward; - } - else - { - Indent (os, indentG); - os << "forward "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (reverse)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "reverse "; - os << *reverse; - } - else - { - Indent (os, indentG); - os << "reverse "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CertificatePair::Print - - -CertificateList::CertificateList() -{ -#if TCL - crlToSign = new CRLToSign; -#else - crlToSign = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - algorithmIdentifier = new AlgorithmIdentifier; -#else - algorithmIdentifier = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -CertificateList::CertificateList (const CertificateList &) -{ - Asn1Error << "use of incompletely defined CertificateList::CertificateList (const CertificateList &)" << endl; - abort(); -} - -CertificateList::~CertificateList() -{ - delete crlToSign; - delete algorithmIdentifier; -} - -AsnType *CertificateList::Clone() const -{ - return new CertificateList; -} - -AsnType *CertificateList::Copy() const -{ - return new CertificateList (*this); -} - -#if SNACC_DEEP_COPY -CertificateList &CertificateList::operator = (const CertificateList &that) -#else // SNACC_DEEP_COPY -CertificateList &CertificateList::operator = (const CertificateList &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.crlToSign) - { - if (!crlToSign) - crlToSign = new CRLToSign; - *crlToSign = *that.crlToSign; - } - else - { - delete crlToSign; - crlToSign = NULL; - } - if (that.algorithmIdentifier) - { - if (!algorithmIdentifier) - algorithmIdentifier = new AlgorithmIdentifier; - *algorithmIdentifier = *that.algorithmIdentifier; - } - else - { - delete algorithmIdentifier; - algorithmIdentifier = NULL; - } - signatureValue = that.signatureValue; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificateList &CertificateList::operator = (const CertificateList &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CertificateList::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = signatureValue.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = algorithmIdentifier->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = crlToSign->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // CertificateList::BEncContent - - -void CertificateList::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - crlToSign = new CRLToSign; - crlToSign->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-176); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - algorithmIdentifier = new AlgorithmIdentifier; - algorithmIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-177); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signatureValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-178); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-179); - } - else - return; -} // CertificateList::BDecContent - -AsnLen CertificateList::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificateList::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificateList::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-180); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CertificateList::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (crlToSign)) - { - Indent (os, indentG); - os << "crlToSign "; - os << *crlToSign; - } - else - { - Indent (os, indentG); - os << "crlToSign "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (algorithmIdentifier)) - { - Indent (os, indentG); - os << "algorithmIdentifier "; - os << *algorithmIdentifier; - } - else - { - Indent (os, indentG); - os << "algorithmIdentifier "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signatureValue "; - os << signatureValue; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CertificateList::Print - - -AttributeCertificate::AttributeCertificate() -{ -#if TCL - attributeCertificateInfo = new AttributeCertificateInfo; -#else - attributeCertificateInfo = NULL; // incomplete initialization of mandatory element! -#endif // TCL -#if TCL - algorithmIdentifier = new AlgorithmIdentifier; -#else - algorithmIdentifier = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -AttributeCertificate::AttributeCertificate (const AttributeCertificate &) -{ - Asn1Error << "use of incompletely defined AttributeCertificate::AttributeCertificate (const AttributeCertificate &)" << endl; - abort(); -} - -AttributeCertificate::~AttributeCertificate() -{ - delete attributeCertificateInfo; - delete algorithmIdentifier; -} - -AsnType *AttributeCertificate::Clone() const -{ - return new AttributeCertificate; -} - -AsnType *AttributeCertificate::Copy() const -{ - return new AttributeCertificate (*this); -} - -#if SNACC_DEEP_COPY -AttributeCertificate &AttributeCertificate::operator = (const AttributeCertificate &that) -#else // SNACC_DEEP_COPY -AttributeCertificate &AttributeCertificate::operator = (const AttributeCertificate &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.attributeCertificateInfo) - { - if (!attributeCertificateInfo) - attributeCertificateInfo = new AttributeCertificateInfo; - *attributeCertificateInfo = *that.attributeCertificateInfo; - } - else - { - delete attributeCertificateInfo; - attributeCertificateInfo = NULL; - } - if (that.algorithmIdentifier) - { - if (!algorithmIdentifier) - algorithmIdentifier = new AlgorithmIdentifier; - *algorithmIdentifier = *that.algorithmIdentifier; - } - else - { - delete algorithmIdentifier; - algorithmIdentifier = NULL; - } - signatureValue = that.signatureValue; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificate &AttributeCertificate::operator = (const AttributeCertificate &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttributeCertificate::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = signatureValue.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = algorithmIdentifier->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - BEncEocIfNec (b); - l = attributeCertificateInfo->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // AttributeCertificate::BEncContent - - -void AttributeCertificate::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - attributeCertificateInfo = new AttributeCertificateInfo; - attributeCertificateInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-181); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - algorithmIdentifier = new AlgorithmIdentifier; - algorithmIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-182); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - signatureValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-183); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-184); - } - else - return; -} // AttributeCertificate::BDecContent - -AsnLen AttributeCertificate::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributeCertificate::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributeCertificate::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-185); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AttributeCertificate::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (attributeCertificateInfo)) - { - Indent (os, indentG); - os << "attributeCertificateInfo "; - os << *attributeCertificateInfo; - } - else - { - Indent (os, indentG); - os << "attributeCertificateInfo "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (algorithmIdentifier)) - { - Indent (os, indentG); - os << "algorithmIdentifier "; - os << *algorithmIdentifier; - } - else - { - Indent (os, indentG); - os << "algorithmIdentifier "; - os << "-- void --"; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "signatureValue "; - os << signatureValue; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AttributeCertificate::Print - - -AsnType *CertificationPathSeqOf::Clone() const -{ - return new CertificationPathSeqOf; -} - -AsnType *CertificationPathSeqOf::Copy() const -{ - return new CertificationPathSeqOf (*this); -} - -AsnLen CertificationPathSeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificationPathSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificationPathSeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-186); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -CertificationPathSeqOf::CertificationPathSeqOf (const CertificationPathSeqOf &) -{ - Asn1Error << "use of incompletely defined CertificationPathSeqOf::CertificationPathSeqOf (const CertificationPathSeqOf &)" << endl; - abort(); -} - -CertificationPathSeqOf::~CertificationPathSeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -CertificationPathSeqOf &CertificationPathSeqOf::operator = (const CertificationPathSeqOf &that) -#else // SNACC_DEEP_COPY -CertificationPathSeqOf &CertificationPathSeqOf::operator = (const CertificationPathSeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificationPathSeqOf &CertificationPathSeqOf::operator = (const CertificationPathSeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void CertificationPathSeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void CertificationPathSeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // CertificationPathSeqOf::SetCurrElmt - - -unsigned long int CertificationPathSeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // CertificationPathSeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -CertificatePair *CertificationPathSeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificatePair; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificationPathSeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -CertificatePair *CertificationPathSeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificatePair; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificationPathSeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -CertificatePair *CertificationPathSeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificatePair; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificationPathSeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertificatePair *CertificationPathSeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificatePair; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificationPathSeqOf::InsertAfter - - -CertificationPathSeqOf &CertificationPathSeqOf::AppendCopy (CertificatePair &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificatePair; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -CertificationPathSeqOf &CertificationPathSeqOf::PrependCopy (CertificatePair &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertificatePair; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // CertificationPathSeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -CertificationPathSeqOf &CertificationPathSeqOf::InsertBeforeAndCopy (CertificatePair &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CertificatePair; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // CertificationPathSeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertificationPathSeqOf &CertificationPathSeqOf::InsertAfterAndCopy (CertificatePair &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CertificatePair; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // CertificationPathSeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void CertificationPathSeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen CertificationPathSeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // CertificationPathSeqOf::BEncContent - - -void CertificationPathSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - CertificatePair *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-187); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // CertificationPathSeqOf::BDecContent - - -AsnType *ForwardCertificationPath::Clone() const -{ - return new ForwardCertificationPath; -} - -AsnType *ForwardCertificationPath::Copy() const -{ - return new ForwardCertificationPath (*this); -} - -AsnLen ForwardCertificationPath::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ForwardCertificationPath::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ForwardCertificationPath::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-188); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -ForwardCertificationPath::ForwardCertificationPath (const ForwardCertificationPath &) -{ - Asn1Error << "use of incompletely defined ForwardCertificationPath::ForwardCertificationPath (const ForwardCertificationPath &)" << endl; - abort(); -} - -ForwardCertificationPath::~ForwardCertificationPath() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -ForwardCertificationPath &ForwardCertificationPath::operator = (const ForwardCertificationPath &that) -#else // SNACC_DEEP_COPY -ForwardCertificationPath &ForwardCertificationPath::operator = (const ForwardCertificationPath &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ForwardCertificationPath &ForwardCertificationPath::operator = (const ForwardCertificationPath &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void ForwardCertificationPath::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void ForwardCertificationPath::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // ForwardCertificationPath::SetCurrElmt - - -unsigned long int ForwardCertificationPath::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // ForwardCertificationPath::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -CrossCertificates *ForwardCertificationPath::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CrossCertificates; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ForwardCertificationPath::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -CrossCertificates *ForwardCertificationPath::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CrossCertificates; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ForwardCertificationPath::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -CrossCertificates *ForwardCertificationPath::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CrossCertificates; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ForwardCertificationPath::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CrossCertificates *ForwardCertificationPath::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CrossCertificates; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ForwardCertificationPath::InsertAfter - - -ForwardCertificationPath &ForwardCertificationPath::AppendCopy (CrossCertificates &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CrossCertificates; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -ForwardCertificationPath &ForwardCertificationPath::PrependCopy (CrossCertificates &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CrossCertificates; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // ForwardCertificationPath::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -ForwardCertificationPath &ForwardCertificationPath::InsertBeforeAndCopy (CrossCertificates &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CrossCertificates; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // ForwardCertificationPath::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ForwardCertificationPath &ForwardCertificationPath::InsertAfterAndCopy (CrossCertificates &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CrossCertificates; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // ForwardCertificationPath::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void ForwardCertificationPath::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen ForwardCertificationPath::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // ForwardCertificationPath::BEncContent - - -void ForwardCertificationPath::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - CrossCertificates *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-189); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // ForwardCertificationPath::BDecContent - - -ACPathData::ACPathData() -{ - certificate = NULL; - attributeCertificate = NULL; -} - -ACPathData::ACPathData (const ACPathData &) -{ - Asn1Error << "use of incompletely defined ACPathData::ACPathData (const ACPathData &)" << endl; - abort(); -} - -ACPathData::~ACPathData() -{ - delete certificate; - delete attributeCertificate; -} - -AsnType *ACPathData::Clone() const -{ - return new ACPathData; -} - -AsnType *ACPathData::Copy() const -{ - return new ACPathData (*this); -} - -#if SNACC_DEEP_COPY -ACPathData &ACPathData::operator = (const ACPathData &that) -#else // SNACC_DEEP_COPY -ACPathData &ACPathData::operator = (const ACPathData &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.certificate) - { - if (!certificate) - certificate = new Certificate; - *certificate = *that.certificate; - } - else - { - delete certificate; - certificate = NULL; - } - if (that.attributeCertificate) - { - if (!attributeCertificate) - attributeCertificate = new AttributeCertificate; - *attributeCertificate = *that.attributeCertificate; - } - else - { - delete attributeCertificate; - attributeCertificate = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ACPathData &ACPathData::operator = (const ACPathData &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -ACPathData::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (attributeCertificate)) - { - BEncEocIfNec (b); - BEncEocIfNec (b); - l = attributeCertificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - if (NOT_NULL (certificate)) - { - BEncEocIfNec (b); - BEncEocIfNec (b); - l = certificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // ACPathData::BEncContent - - -void ACPathData::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-190); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - certificate = new Certificate; - certificate->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-191); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - attributeCertificate = new AttributeCertificate; - attributeCertificate->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-192); - } - else - return; -} // ACPathData::BDecContent - -AsnLen ACPathData::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ACPathData::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ACPathData::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-193); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void ACPathData::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (certificate)) - { - nonePrinted = false; - Indent (os, indentG); - os << "certificate "; - os << *certificate; - } - else - { - Indent (os, indentG); - os << "certificate "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (attributeCertificate)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "attributeCertificate "; - os << *attributeCertificate; - } - else - { - Indent (os, indentG); - os << "attributeCertificate "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // ACPathData::Print - - -AsnType *AttributeCertificationPathSeqOf::Clone() const -{ - return new AttributeCertificationPathSeqOf; -} - -AsnType *AttributeCertificationPathSeqOf::Copy() const -{ - return new AttributeCertificationPathSeqOf (*this); -} - -AsnLen AttributeCertificationPathSeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributeCertificationPathSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributeCertificationPathSeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-194); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AttributeCertificationPathSeqOf::AttributeCertificationPathSeqOf (const AttributeCertificationPathSeqOf &) -{ - Asn1Error << "use of incompletely defined AttributeCertificationPathSeqOf::AttributeCertificationPathSeqOf (const AttributeCertificationPathSeqOf &)" << endl; - abort(); -} - -AttributeCertificationPathSeqOf::~AttributeCertificationPathSeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::operator = (const AttributeCertificationPathSeqOf &that) -#else // SNACC_DEEP_COPY -AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::operator = (const AttributeCertificationPathSeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::operator = (const AttributeCertificationPathSeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void AttributeCertificationPathSeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void AttributeCertificationPathSeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // AttributeCertificationPathSeqOf::SetCurrElmt - - -unsigned long int AttributeCertificationPathSeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // AttributeCertificationPathSeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -ACPathData *AttributeCertificationPathSeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ACPathData; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificationPathSeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -ACPathData *AttributeCertificationPathSeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ACPathData; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificationPathSeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -ACPathData *AttributeCertificationPathSeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ACPathData; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificationPathSeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ACPathData *AttributeCertificationPathSeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ACPathData; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributeCertificationPathSeqOf::InsertAfter - - -AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::AppendCopy (ACPathData &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ACPathData; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::PrependCopy (ACPathData &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new ACPathData; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // AttributeCertificationPathSeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::InsertBeforeAndCopy (ACPathData &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new ACPathData; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // AttributeCertificationPathSeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::InsertAfterAndCopy (ACPathData &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new ACPathData; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // AttributeCertificationPathSeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void AttributeCertificationPathSeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen AttributeCertificationPathSeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // AttributeCertificationPathSeqOf::BEncContent - - -void AttributeCertificationPathSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - ACPathData *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-195); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // AttributeCertificationPathSeqOf::BDecContent - - -Certificates::Certificates() -{ -#if TCL - userCertificate = new Certificate; -#else - userCertificate = NULL; // incomplete initialization of mandatory element! -#endif // TCL - certificationPath = NULL; -} - -Certificates::Certificates (const Certificates &) -{ - Asn1Error << "use of incompletely defined Certificates::Certificates (const Certificates &)" << endl; - abort(); -} - -Certificates::~Certificates() -{ - delete userCertificate; - delete certificationPath; -} - -AsnType *Certificates::Clone() const -{ - return new Certificates; -} - -AsnType *Certificates::Copy() const -{ - return new Certificates (*this); -} - -#if SNACC_DEEP_COPY -Certificates &Certificates::operator = (const Certificates &that) -#else // SNACC_DEEP_COPY -Certificates &Certificates::operator = (const Certificates &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.userCertificate) - { - if (!userCertificate) - userCertificate = new Certificate; - *userCertificate = *that.userCertificate; - } - else - { - delete userCertificate; - userCertificate = NULL; - } - if (that.certificationPath) - { - if (!certificationPath) - certificationPath = new ForwardCertificationPath; - *certificationPath = *that.certificationPath; - } - else - { - delete certificationPath; - certificationPath = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined Certificates &Certificates::operator = (const Certificates &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -Certificates::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (certificationPath)) - { - BEncEocIfNec (b); - l = certificationPath->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - BEncEocIfNec (b); - l = userCertificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // Certificates::BEncContent - - -void Certificates::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - userCertificate = new Certificate; - userCertificate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-196); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - certificationPath = new ForwardCertificationPath; - certificationPath->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-197); - } - else - return; -} // Certificates::BDecContent - -AsnLen Certificates::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void Certificates::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "Certificates::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-198); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void Certificates::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (userCertificate)) - { - Indent (os, indentG); - os << "userCertificate "; - os << *userCertificate; - } - else - { - Indent (os, indentG); - os << "userCertificate "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (certificationPath)) - { - os << ","<< endl; - Indent (os, indentG); - os << "certificationPath "; - os << *certificationPath; - } - else - { - Indent (os, indentG); - os << "certificationPath "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // Certificates::Print - - -CertificationPath::CertificationPath() -{ -#if TCL - userCertificate = new Certificate; -#else - userCertificate = NULL; // incomplete initialization of mandatory element! -#endif // TCL - theCACertificates = NULL; -} - -CertificationPath::CertificationPath (const CertificationPath &) -{ - Asn1Error << "use of incompletely defined CertificationPath::CertificationPath (const CertificationPath &)" << endl; - abort(); -} - -CertificationPath::~CertificationPath() -{ - delete userCertificate; - delete theCACertificates; -} - -AsnType *CertificationPath::Clone() const -{ - return new CertificationPath; -} - -AsnType *CertificationPath::Copy() const -{ - return new CertificationPath (*this); -} - -#if SNACC_DEEP_COPY -CertificationPath &CertificationPath::operator = (const CertificationPath &that) -#else // SNACC_DEEP_COPY -CertificationPath &CertificationPath::operator = (const CertificationPath &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.userCertificate) - { - if (!userCertificate) - userCertificate = new Certificate; - *userCertificate = *that.userCertificate; - } - else - { - delete userCertificate; - userCertificate = NULL; - } - if (that.theCACertificates) - { - if (!theCACertificates) - theCACertificates = new CertificationPathSeqOf; - *theCACertificates = *that.theCACertificates; - } - else - { - delete theCACertificates; - theCACertificates = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificationPath &CertificationPath::operator = (const CertificationPath &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -CertificationPath::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (theCACertificates)) - { - BEncEocIfNec (b); - l = theCACertificates->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - BEncEocIfNec (b); - l = userCertificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // CertificationPath::BEncContent - - -void CertificationPath::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - userCertificate = new Certificate; - userCertificate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-199); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - theCACertificates = new CertificationPathSeqOf; - theCACertificates->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-200); - } - else - return; -} // CertificationPath::BDecContent - -AsnLen CertificationPath::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificationPath::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificationPath::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-201); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void CertificationPath::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (userCertificate)) - { - Indent (os, indentG); - os << "userCertificate "; - os << *userCertificate; - } - else - { - Indent (os, indentG); - os << "userCertificate "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (theCACertificates)) - { - os << ","<< endl; - Indent (os, indentG); - os << "theCACertificates "; - os << *theCACertificates; - } - else - { - Indent (os, indentG); - os << "theCACertificates "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // CertificationPath::Print - - -AttributeCertificationPath::AttributeCertificationPath() -{ -#if TCL - attributeCertificate = new AttributeCertificate; -#else - attributeCertificate = NULL; // incomplete initialization of mandatory element! -#endif // TCL - acPath = NULL; -} - -AttributeCertificationPath::AttributeCertificationPath (const AttributeCertificationPath &) -{ - Asn1Error << "use of incompletely defined AttributeCertificationPath::AttributeCertificationPath (const AttributeCertificationPath &)" << endl; - abort(); -} - -AttributeCertificationPath::~AttributeCertificationPath() -{ - delete attributeCertificate; - delete acPath; -} - -AsnType *AttributeCertificationPath::Clone() const -{ - return new AttributeCertificationPath; -} - -AsnType *AttributeCertificationPath::Copy() const -{ - return new AttributeCertificationPath (*this); -} - -#if SNACC_DEEP_COPY -AttributeCertificationPath &AttributeCertificationPath::operator = (const AttributeCertificationPath &that) -#else // SNACC_DEEP_COPY -AttributeCertificationPath &AttributeCertificationPath::operator = (const AttributeCertificationPath &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.attributeCertificate) - { - if (!attributeCertificate) - attributeCertificate = new AttributeCertificate; - *attributeCertificate = *that.attributeCertificate; - } - else - { - delete attributeCertificate; - attributeCertificate = NULL; - } - if (that.acPath) - { - if (!acPath) - acPath = new AttributeCertificationPathSeqOf; - *acPath = *that.acPath; - } - else - { - delete acPath; - acPath = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificationPath &AttributeCertificationPath::operator = (const AttributeCertificationPath &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttributeCertificationPath::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (acPath)) - { - BEncEocIfNec (b); - l = acPath->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - BEncEocIfNec (b); - l = attributeCertificate->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // AttributeCertificationPath::BEncContent - - -void AttributeCertificationPath::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - attributeCertificate = new AttributeCertificate; - attributeCertificate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-202); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - acPath = new AttributeCertificationPathSeqOf; - acPath->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-203); - } - else - return; -} // AttributeCertificationPath::BDecContent - -AsnLen AttributeCertificationPath::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributeCertificationPath::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributeCertificationPath::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-204); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AttributeCertificationPath::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (attributeCertificate)) - { - Indent (os, indentG); - os << "attributeCertificate "; - os << *attributeCertificate; - } - else - { - Indent (os, indentG); - os << "attributeCertificate "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (acPath)) - { - os << ","<< endl; - Indent (os, indentG); - os << "acPath "; - os << *acPath; - } - else - { - Indent (os, indentG); - os << "acPath "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AttributeCertificationPath::Print - - -AttributeCertificateAssertion::AttributeCertificateAssertion() -{ - subject = NULL; - issuer = NULL; - attCertValidity = NULL; - attType = NULL; -} - -AttributeCertificateAssertion::AttributeCertificateAssertion (const AttributeCertificateAssertion &) -{ - Asn1Error << "use of incompletely defined AttributeCertificateAssertion::AttributeCertificateAssertion (const AttributeCertificateAssertion &)" << endl; - abort(); -} - -AttributeCertificateAssertion::~AttributeCertificateAssertion() -{ - delete subject; - delete issuer; - delete attCertValidity; - delete attType; -} - -AsnType *AttributeCertificateAssertion::Clone() const -{ - return new AttributeCertificateAssertion; -} - -AsnType *AttributeCertificateAssertion::Copy() const -{ - return new AttributeCertificateAssertion (*this); -} - -#if SNACC_DEEP_COPY -AttributeCertificateAssertion &AttributeCertificateAssertion::operator = (const AttributeCertificateAssertion &that) -#else // SNACC_DEEP_COPY -AttributeCertificateAssertion &AttributeCertificateAssertion::operator = (const AttributeCertificateAssertion &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.subject) - { - if (!subject) - subject = new AttributeCertificateAssertionChoice; - *subject = *that.subject; - } - else - { - delete subject; - subject = NULL; - } - if (that.issuer) - { - if (!issuer) - issuer = new Name; - *issuer = *that.issuer; - } - else - { - delete issuer; - issuer = NULL; - } - if (that.attCertValidity) - { - if (!attCertValidity) - attCertValidity = new GeneralizedTime; - *attCertValidity = *that.attCertValidity; - } - else - { - delete attCertValidity; - attCertValidity = NULL; - } - if (that.attType) - { - if (!attType) - attType = new AttributeCertificateAssertionSetOf; - *attType = *that.attType; - } - else - { - delete attType; - attType = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributeCertificateAssertion &AttributeCertificateAssertion::operator = (const AttributeCertificateAssertion &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AttributeCertificateAssertion::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (attType)) - { - BEncEocIfNec (b); - BEncEocIfNec (b); - l = attType->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 3); - totalLen += l; - } - - if (NOT_NULL (attCertValidity)) - { - BEncEocIfNec (b); - l = attCertValidity->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 2); - totalLen += l; - } - - if (NOT_NULL (issuer)) - { - BEncEocIfNec (b); - l = issuer->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - if (NOT_NULL (subject)) - { - BEncEocIfNec (b); - l = subject->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // AttributeCertificateAssertion::BEncContent - - -void AttributeCertificateAssertion::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - subject = new AttributeCertificateAssertionChoice; - subject->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - issuer = new Name; - issuer->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - && (tag1 != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-205); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - attCertValidity = new GeneralizedTime; - attCertValidity->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 3))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - - if (tag1 != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-206); - } - - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - attType = new AttributeCertificateAssertionSetOf; - attType->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-207); - } - else - return; -} // AttributeCertificateAssertion::BDecContent - -AsnLen AttributeCertificateAssertion::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributeCertificateAssertion::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributeCertificateAssertion::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-208); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AttributeCertificateAssertion::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (subject)) - { - nonePrinted = false; - Indent (os, indentG); - os << "subject "; - os << *subject; - } - else - { - Indent (os, indentG); - os << "subject "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (issuer)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "issuer "; - os << *issuer; - } - else - { - Indent (os, indentG); - os << "issuer "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (attCertValidity)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "attCertValidity "; - os << *attCertValidity; - } - else - { - Indent (os, indentG); - os << "attCertValidity "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (attType)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "attType "; - os << *attType; - } - else - { - Indent (os, indentG); - os << "attType "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AttributeCertificateAssertion::Print - - diff --git a/SecurityASN1/c++/sm_x509ce.cpp b/SecurityASN1/c++/sm_x509ce.cpp deleted file mode 100644 index 576033a4..00000000 --- a/SecurityASN1/c++/sm_x509ce.cpp +++ /dev/null @@ -1,6837 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x509ce.cpp - class member functions for ASN.1 module CertificateExtensions -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -PolicyQualifierInfo::PolicyQualifierInfo() -{ - qualifier = NULL; -} - -PolicyQualifierInfo::PolicyQualifierInfo (const PolicyQualifierInfo &) -{ - Asn1Error << "use of incompletely defined PolicyQualifierInfo::PolicyQualifierInfo (const PolicyQualifierInfo &)" << endl; - abort(); -} - -PolicyQualifierInfo::~PolicyQualifierInfo() -{ - delete qualifier; -} - -AsnType *PolicyQualifierInfo::Clone() const -{ - return new PolicyQualifierInfo; -} - -AsnType *PolicyQualifierInfo::Copy() const -{ - return new PolicyQualifierInfo (*this); -} - -#if SNACC_DEEP_COPY -PolicyQualifierInfo &PolicyQualifierInfo::operator = (const PolicyQualifierInfo &that) -#else // SNACC_DEEP_COPY -PolicyQualifierInfo &PolicyQualifierInfo::operator = (const PolicyQualifierInfo &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - policyQualifierId = that.policyQualifierId; - if (that.qualifier) - { - if (!qualifier) - qualifier = new AsnAny; - *qualifier = *that.qualifier; - } - else - { - delete qualifier; - qualifier = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PolicyQualifierInfo &PolicyQualifierInfo::operator = (const PolicyQualifierInfo &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -PolicyQualifierInfo::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (qualifier)) - { - ENC_LOAD_ANYBUF(qualifier, b, l); - totalLen += l; - } - - l = policyQualifierId.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // PolicyQualifierInfo::BEncContent - - -void PolicyQualifierInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - policyQualifierId.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = b.PeekByte(); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDecEoc (b, seqBytesDecoded, env); - - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-100); - } - - // ANY type - qualifier = new AsnAny; - DEC_LOAD_ANYBUF(qualifier, b, seqBytesDecoded, env); - - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-101); - } - else - return; -} // PolicyQualifierInfo::BDecContent - -AsnLen PolicyQualifierInfo::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void PolicyQualifierInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "PolicyQualifierInfo::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-102); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void PolicyQualifierInfo::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "policyQualifierId "; - os << policyQualifierId; - os << "," << endl; - } - - if (NOT_NULL (qualifier)) - { - os << ","<< endl; - Indent (os, indentG); - os << "qualifier "; - os << *qualifier; - } - else - { - Indent (os, indentG); - os << "qualifier "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // PolicyQualifierInfo::Print - - -AsnType *AttributesSyntax::Clone() const -{ - return new AttributesSyntax; -} - -AsnType *AttributesSyntax::Copy() const -{ - return new AttributesSyntax (*this); -} - -AsnLen AttributesSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AttributesSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AttributesSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-103); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AttributesSyntax::AttributesSyntax (const AttributesSyntax &) -{ - Asn1Error << "use of incompletely defined AttributesSyntax::AttributesSyntax (const AttributesSyntax &)" << endl; - abort(); -} - -AttributesSyntax::~AttributesSyntax() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -AttributesSyntax &AttributesSyntax::operator = (const AttributesSyntax &that) -#else // SNACC_DEEP_COPY -AttributesSyntax &AttributesSyntax::operator = (const AttributesSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AttributesSyntax &AttributesSyntax::operator = (const AttributesSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void AttributesSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void AttributesSyntax::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // AttributesSyntax::SetCurrElmt - - -unsigned long int AttributesSyntax::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // AttributesSyntax::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -Attribute *AttributesSyntax::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributesSyntax::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -Attribute *AttributesSyntax::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributesSyntax::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -Attribute *AttributesSyntax::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributesSyntax::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -Attribute *AttributesSyntax::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // AttributesSyntax::InsertAfter - - -AttributesSyntax &AttributesSyntax::AppendCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -AttributesSyntax &AttributesSyntax::PrependCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // AttributesSyntax::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -AttributesSyntax &AttributesSyntax::InsertBeforeAndCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // AttributesSyntax::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -AttributesSyntax &AttributesSyntax::InsertAfterAndCopy (Attribute &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new Attribute; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // AttributesSyntax::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void AttributesSyntax::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen AttributesSyntax::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // AttributesSyntax::BEncContent - - -void AttributesSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - Attribute *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-104); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // AttributesSyntax::BDecContent - - -DistributionPointName::DistributionPointName() -{ - choiceId = fullNameCid; -#if TCL - fullName = new GeneralNames; -#else - fullName = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DistributionPointName::DistributionPointName (const DistributionPointName &) -{ - Asn1Error << "use of incompletely defined DistributionPointName::DistributionPointName (const DistributionPointName &)" << endl; - abort(); -} - -DistributionPointName::~DistributionPointName() -{ - switch (choiceId) - { - case fullNameCid: - delete fullName; - break; - case nameRelativeToCRLIssuerCid: - delete nameRelativeToCRLIssuer; - break; - } // end of switch -} // end of destructor - -AsnType *DistributionPointName::Clone() const -{ - return new DistributionPointName; -} - -AsnType *DistributionPointName::Copy() const -{ - return new DistributionPointName (*this); -} - -#if SNACC_DEEP_COPY -DistributionPointName &DistributionPointName::operator = (const DistributionPointName &that) -#else // SNACC_DEEP_COPY -DistributionPointName &DistributionPointName::operator = (const DistributionPointName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case fullNameCid: - delete fullName; - break; - case nameRelativeToCRLIssuerCid: - delete nameRelativeToCRLIssuer; - break; - } - switch (choiceId = that.choiceId) - { - case fullNameCid: - fullName = new GeneralNames; - *fullName = *that.fullName; - break; - case nameRelativeToCRLIssuerCid: - nameRelativeToCRLIssuer = new RelativeDistinguishedName; - *nameRelativeToCRLIssuer = *that.nameRelativeToCRLIssuer; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DistributionPointName &DistributionPointName::operator = (const DistributionPointName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DistributionPointName::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case fullNameCid: - BEncEocIfNec (b); - l = fullName->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - break; - - case nameRelativeToCRLIssuerCid: - BEncEocIfNec (b); - l = nameRelativeToCRLIssuer->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - break; - - } // end switch - return l; -} // DistributionPointName::BEncContent - - -void DistributionPointName::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (CNTX, CONS, 0): - choiceId = fullNameCid; - fullName = new GeneralNames; - fullName->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = nameRelativeToCRLIssuerCid; - nameRelativeToCRLIssuer = new RelativeDistinguishedName; - nameRelativeToCRLIssuer->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-105); - break; - } // end switch -} // DistributionPointName::BDecContent - - -AsnLen DistributionPointName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void DistributionPointName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void DistributionPointName::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case fullNameCid: - os << "fullName "; - if (fullName) - os << *fullName; - else - os << "-- void3 --\n"; - break; - - case nameRelativeToCRLIssuerCid: - os << "nameRelativeToCRLIssuer "; - if (nameRelativeToCRLIssuer) - os << *nameRelativeToCRLIssuer; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // DistributionPointName::Print - -PolicyMappingsSyntaxSeq::PolicyMappingsSyntaxSeq() -{ -} - -PolicyMappingsSyntaxSeq::PolicyMappingsSyntaxSeq (const PolicyMappingsSyntaxSeq &) -{ - Asn1Error << "use of incompletely defined PolicyMappingsSyntaxSeq::PolicyMappingsSyntaxSeq (const PolicyMappingsSyntaxSeq &)" << endl; - abort(); -} - -PolicyMappingsSyntaxSeq::~PolicyMappingsSyntaxSeq() -{ -} - -AsnType *PolicyMappingsSyntaxSeq::Clone() const -{ - return new PolicyMappingsSyntaxSeq; -} - -AsnType *PolicyMappingsSyntaxSeq::Copy() const -{ - return new PolicyMappingsSyntaxSeq (*this); -} - -#if SNACC_DEEP_COPY -PolicyMappingsSyntaxSeq &PolicyMappingsSyntaxSeq::operator = (const PolicyMappingsSyntaxSeq &that) -#else // SNACC_DEEP_COPY -PolicyMappingsSyntaxSeq &PolicyMappingsSyntaxSeq::operator = (const PolicyMappingsSyntaxSeq &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - issuerDomainPolicy = that.issuerDomainPolicy; - subjectDomainPolicy = that.subjectDomainPolicy; - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PolicyMappingsSyntaxSeq &PolicyMappingsSyntaxSeq::operator = (const PolicyMappingsSyntaxSeq &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -PolicyMappingsSyntaxSeq::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = subjectDomainPolicy.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - l = issuerDomainPolicy.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // PolicyMappingsSyntaxSeq::BEncContent - - -void PolicyMappingsSyntaxSeq::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - issuerDomainPolicy.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-106); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - subjectDomainPolicy.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-107); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-108); - } - else - return; -} // PolicyMappingsSyntaxSeq::BDecContent - -AsnLen PolicyMappingsSyntaxSeq::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void PolicyMappingsSyntaxSeq::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "PolicyMappingsSyntaxSeq::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-109); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void PolicyMappingsSyntaxSeq::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "issuerDomainPolicy "; - os << issuerDomainPolicy; - os << "," << endl; - } - - { - Indent (os, indentG); - os << "subjectDomainPolicy "; - os << subjectDomainPolicy; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // PolicyMappingsSyntaxSeq::Print - - -AsnType *PolicyInformationSeqOf::Clone() const -{ - return new PolicyInformationSeqOf; -} - -AsnType *PolicyInformationSeqOf::Copy() const -{ - return new PolicyInformationSeqOf (*this); -} - -AsnLen PolicyInformationSeqOf::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void PolicyInformationSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "PolicyInformationSeqOf::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-110); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -PolicyInformationSeqOf::PolicyInformationSeqOf (const PolicyInformationSeqOf &) -{ - Asn1Error << "use of incompletely defined PolicyInformationSeqOf::PolicyInformationSeqOf (const PolicyInformationSeqOf &)" << endl; - abort(); -} - -PolicyInformationSeqOf::~PolicyInformationSeqOf() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -PolicyInformationSeqOf &PolicyInformationSeqOf::operator = (const PolicyInformationSeqOf &that) -#else // SNACC_DEEP_COPY -PolicyInformationSeqOf &PolicyInformationSeqOf::operator = (const PolicyInformationSeqOf &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PolicyInformationSeqOf &PolicyInformationSeqOf::operator = (const PolicyInformationSeqOf &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void PolicyInformationSeqOf::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void PolicyInformationSeqOf::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // PolicyInformationSeqOf::SetCurrElmt - - -unsigned long int PolicyInformationSeqOf::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // PolicyInformationSeqOf::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -PolicyQualifierInfo *PolicyInformationSeqOf::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyQualifierInfo; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // PolicyInformationSeqOf::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -PolicyQualifierInfo *PolicyInformationSeqOf::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyQualifierInfo; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // PolicyInformationSeqOf::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -PolicyQualifierInfo *PolicyInformationSeqOf::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyQualifierInfo; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // PolicyInformationSeqOf::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -PolicyQualifierInfo *PolicyInformationSeqOf::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyQualifierInfo; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // PolicyInformationSeqOf::InsertAfter - - -PolicyInformationSeqOf &PolicyInformationSeqOf::AppendCopy (PolicyQualifierInfo &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyQualifierInfo; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -PolicyInformationSeqOf &PolicyInformationSeqOf::PrependCopy (PolicyQualifierInfo &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyQualifierInfo; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // PolicyInformationSeqOf::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -PolicyInformationSeqOf &PolicyInformationSeqOf::InsertBeforeAndCopy (PolicyQualifierInfo &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyQualifierInfo; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // PolicyInformationSeqOf::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -PolicyInformationSeqOf &PolicyInformationSeqOf::InsertAfterAndCopy (PolicyQualifierInfo &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyQualifierInfo; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // PolicyInformationSeqOf::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void PolicyInformationSeqOf::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen PolicyInformationSeqOf::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // PolicyInformationSeqOf::BEncContent - - -void PolicyInformationSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - PolicyQualifierInfo *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-111); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // PolicyInformationSeqOf::BDecContent - - -PolicyInformation::PolicyInformation() -{ - policyQualifiers = NULL; -} - -PolicyInformation::PolicyInformation (const PolicyInformation &) -{ - Asn1Error << "use of incompletely defined PolicyInformation::PolicyInformation (const PolicyInformation &)" << endl; - abort(); -} - -PolicyInformation::~PolicyInformation() -{ - delete policyQualifiers; -} - -AsnType *PolicyInformation::Clone() const -{ - return new PolicyInformation; -} - -AsnType *PolicyInformation::Copy() const -{ - return new PolicyInformation (*this); -} - -#if SNACC_DEEP_COPY -PolicyInformation &PolicyInformation::operator = (const PolicyInformation &that) -#else // SNACC_DEEP_COPY -PolicyInformation &PolicyInformation::operator = (const PolicyInformation &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - policyIdentifier = that.policyIdentifier; - if (that.policyQualifiers) - { - if (!policyQualifiers) - policyQualifiers = new PolicyInformationSeqOf; - *policyQualifiers = *that.policyQualifiers; - } - else - { - delete policyQualifiers; - policyQualifiers = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PolicyInformation &PolicyInformation::operator = (const PolicyInformation &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -PolicyInformation::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (policyQualifiers)) - { - BEncEocIfNec (b); - l = policyQualifiers->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - } - - l = policyIdentifier.BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - - return totalLen; -} // PolicyInformation::BEncContent - - -void PolicyInformation::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - policyIdentifier.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-112); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - policyQualifiers = new PolicyInformationSeqOf; - policyQualifiers->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-113); - } - else - return; -} // PolicyInformation::BDecContent - -AsnLen PolicyInformation::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void PolicyInformation::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "PolicyInformation::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-114); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void PolicyInformation::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - { - Indent (os, indentG); - os << "policyIdentifier "; - os << policyIdentifier; - os << "," << endl; - } - - if (NOT_NULL (policyQualifiers)) - { - os << ","<< endl; - Indent (os, indentG); - os << "policyQualifiers "; - os << *policyQualifiers; - } - else - { - Indent (os, indentG); - os << "policyQualifiers "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // PolicyInformation::Print - - -GeneralSubtree::GeneralSubtree() -{ -#if TCL - base = new GeneralName; -#else - base = NULL; // incomplete initialization of mandatory element! -#endif // TCL - minimum = NULL; - maximum = NULL; -} - -GeneralSubtree::GeneralSubtree (const GeneralSubtree &) -{ - Asn1Error << "use of incompletely defined GeneralSubtree::GeneralSubtree (const GeneralSubtree &)" << endl; - abort(); -} - -GeneralSubtree::~GeneralSubtree() -{ - delete base; - delete minimum; - delete maximum; -} - -AsnType *GeneralSubtree::Clone() const -{ - return new GeneralSubtree; -} - -AsnType *GeneralSubtree::Copy() const -{ - return new GeneralSubtree (*this); -} - -#if SNACC_DEEP_COPY -GeneralSubtree &GeneralSubtree::operator = (const GeneralSubtree &that) -#else // SNACC_DEEP_COPY -GeneralSubtree &GeneralSubtree::operator = (const GeneralSubtree &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.base) - { - if (!base) - base = new GeneralName; - *base = *that.base; - } - else - { - delete base; - base = NULL; - } - if (that.minimum) - { - if (!minimum) - minimum = new BaseDistance; - *minimum = *that.minimum; - } - else - { - delete minimum; - minimum = NULL; - } - if (that.maximum) - { - if (!maximum) - maximum = new BaseDistance; - *maximum = *that.maximum; - } - else - { - delete maximum; - maximum = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined GeneralSubtree &GeneralSubtree::operator = (const GeneralSubtree &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -GeneralSubtree::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (maximum)) - { - l = maximum->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 1); - totalLen += l; - } - - if (NOT_NULL (minimum)) - { - l = minimum->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - } - - l = base->BEncContent (b); - totalLen += l; - - return totalLen; -} // GeneralSubtree::BEncContent - - -void GeneralSubtree::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 2)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 3)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 4)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 5)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 6)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 6)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 7)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 7)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 8))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - base = new GeneralName; - base->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-115); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - minimum = new BaseDistance; - minimum->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - maximum = new BaseDistance; - maximum->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-116); - } - else - return; -} // GeneralSubtree::BDecContent - -AsnLen GeneralSubtree::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void GeneralSubtree::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "GeneralSubtree::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-117); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void GeneralSubtree::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (base)) - { - Indent (os, indentG); - os << "base "; - os << *base; - } - else - { - Indent (os, indentG); - os << "base "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (minimum)) - { - os << ","<< endl; - Indent (os, indentG); - os << "minimum "; - os << *minimum; - } - else - { - Indent (os, indentG); - os << "minimum "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (maximum)) - { - os << ","<< endl; - Indent (os, indentG); - os << "maximum "; - os << *maximum; - } - else - { - Indent (os, indentG); - os << "maximum "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // GeneralSubtree::Print - - -DistributionPoint::DistributionPoint() -{ - distributionPoint = NULL; - reasons = NULL; - cRLIssuer = NULL; -} - -DistributionPoint::DistributionPoint (const DistributionPoint &) -{ - Asn1Error << "use of incompletely defined DistributionPoint::DistributionPoint (const DistributionPoint &)" << endl; - abort(); -} - -DistributionPoint::~DistributionPoint() -{ - delete distributionPoint; - delete reasons; - delete cRLIssuer; -} - -AsnType *DistributionPoint::Clone() const -{ - return new DistributionPoint; -} - -AsnType *DistributionPoint::Copy() const -{ - return new DistributionPoint (*this); -} - -#if SNACC_DEEP_COPY -DistributionPoint &DistributionPoint::operator = (const DistributionPoint &that) -#else // SNACC_DEEP_COPY -DistributionPoint &DistributionPoint::operator = (const DistributionPoint &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.distributionPoint) - { - if (!distributionPoint) - distributionPoint = new DistributionPointName; - *distributionPoint = *that.distributionPoint; - } - else - { - delete distributionPoint; - distributionPoint = NULL; - } - if (that.reasons) - { - if (!reasons) - reasons = new ReasonFlags; - *reasons = *that.reasons; - } - else - { - delete reasons; - reasons = NULL; - } - if (that.cRLIssuer) - { - if (!cRLIssuer) - cRLIssuer = new GeneralNames; - *cRLIssuer = *that.cRLIssuer; - } - else - { - delete cRLIssuer; - cRLIssuer = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DistributionPoint &DistributionPoint::operator = (const DistributionPoint &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DistributionPoint::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (cRLIssuer)) - { - BEncEocIfNec (b); - l = cRLIssuer->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 2); - totalLen += l; - } - - if (NOT_NULL (reasons)) - { - l = reasons->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 1); - totalLen += l; - } - - if (NOT_NULL (distributionPoint)) - { - BEncEocIfNec (b); - l = distributionPoint->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // DistributionPoint::BEncContent - - -void DistributionPoint::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - distributionPoint = new DistributionPointName; - distributionPoint->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - reasons = new ReasonFlags; - reasons->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - cRLIssuer = new GeneralNames; - cRLIssuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-118); - } - else - return; -} // DistributionPoint::BDecContent - -AsnLen DistributionPoint::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void DistributionPoint::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "DistributionPoint::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-119); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void DistributionPoint::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (distributionPoint)) - { - nonePrinted = false; - Indent (os, indentG); - os << "distributionPoint "; - os << *distributionPoint; - } - else - { - Indent (os, indentG); - os << "distributionPoint "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (reasons)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "reasons "; - os << *reasons; - } - else - { - Indent (os, indentG); - os << "reasons "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (cRLIssuer)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "cRLIssuer "; - os << *cRLIssuer; - } - else - { - Indent (os, indentG); - os << "cRLIssuer "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // DistributionPoint::Print - - -AsnType *CertificatePoliciesSyntax::Clone() const -{ - return new CertificatePoliciesSyntax; -} - -AsnType *CertificatePoliciesSyntax::Copy() const -{ - return new CertificatePoliciesSyntax (*this); -} - -AsnLen CertificatePoliciesSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertificatePoliciesSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertificatePoliciesSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-120); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -CertificatePoliciesSyntax::CertificatePoliciesSyntax (const CertificatePoliciesSyntax &) -{ - Asn1Error << "use of incompletely defined CertificatePoliciesSyntax::CertificatePoliciesSyntax (const CertificatePoliciesSyntax &)" << endl; - abort(); -} - -CertificatePoliciesSyntax::~CertificatePoliciesSyntax() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -CertificatePoliciesSyntax &CertificatePoliciesSyntax::operator = (const CertificatePoliciesSyntax &that) -#else // SNACC_DEEP_COPY -CertificatePoliciesSyntax &CertificatePoliciesSyntax::operator = (const CertificatePoliciesSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertificatePoliciesSyntax &CertificatePoliciesSyntax::operator = (const CertificatePoliciesSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void CertificatePoliciesSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void CertificatePoliciesSyntax::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // CertificatePoliciesSyntax::SetCurrElmt - - -unsigned long int CertificatePoliciesSyntax::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // CertificatePoliciesSyntax::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -PolicyInformation *CertificatePoliciesSyntax::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificatePoliciesSyntax::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -PolicyInformation *CertificatePoliciesSyntax::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificatePoliciesSyntax::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -PolicyInformation *CertificatePoliciesSyntax::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificatePoliciesSyntax::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -PolicyInformation *CertificatePoliciesSyntax::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertificatePoliciesSyntax::InsertAfter - - -CertificatePoliciesSyntax &CertificatePoliciesSyntax::AppendCopy (PolicyInformation &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -CertificatePoliciesSyntax &CertificatePoliciesSyntax::PrependCopy (PolicyInformation &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // CertificatePoliciesSyntax::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -CertificatePoliciesSyntax &CertificatePoliciesSyntax::InsertBeforeAndCopy (PolicyInformation &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // CertificatePoliciesSyntax::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertificatePoliciesSyntax &CertificatePoliciesSyntax::InsertAfterAndCopy (PolicyInformation &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyInformation; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // CertificatePoliciesSyntax::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void CertificatePoliciesSyntax::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen CertificatePoliciesSyntax::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // CertificatePoliciesSyntax::BEncContent - - -void CertificatePoliciesSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - PolicyInformation *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-121); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // CertificatePoliciesSyntax::BDecContent - - -AsnType *GeneralSubtrees::Clone() const -{ - return new GeneralSubtrees; -} - -AsnType *GeneralSubtrees::Copy() const -{ - return new GeneralSubtrees (*this); -} - -AsnLen GeneralSubtrees::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void GeneralSubtrees::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "GeneralSubtrees::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-122); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -GeneralSubtrees::GeneralSubtrees (const GeneralSubtrees &) -{ - Asn1Error << "use of incompletely defined GeneralSubtrees::GeneralSubtrees (const GeneralSubtrees &)" << endl; - abort(); -} - -GeneralSubtrees::~GeneralSubtrees() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -GeneralSubtrees &GeneralSubtrees::operator = (const GeneralSubtrees &that) -#else // SNACC_DEEP_COPY -GeneralSubtrees &GeneralSubtrees::operator = (const GeneralSubtrees &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined GeneralSubtrees &GeneralSubtrees::operator = (const GeneralSubtrees &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void GeneralSubtrees::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void GeneralSubtrees::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // GeneralSubtrees::SetCurrElmt - - -unsigned long int GeneralSubtrees::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // GeneralSubtrees::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -GeneralSubtree *GeneralSubtrees::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralSubtree; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // GeneralSubtrees::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -GeneralSubtree *GeneralSubtrees::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralSubtree; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // GeneralSubtrees::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -GeneralSubtree *GeneralSubtrees::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralSubtree; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // GeneralSubtrees::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -GeneralSubtree *GeneralSubtrees::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralSubtree; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // GeneralSubtrees::InsertAfter - - -GeneralSubtrees &GeneralSubtrees::AppendCopy (GeneralSubtree &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralSubtree; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -GeneralSubtrees &GeneralSubtrees::PrependCopy (GeneralSubtree &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralSubtree; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // GeneralSubtrees::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -GeneralSubtrees &GeneralSubtrees::InsertBeforeAndCopy (GeneralSubtree &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralSubtree; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // GeneralSubtrees::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -GeneralSubtrees &GeneralSubtrees::InsertAfterAndCopy (GeneralSubtree &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralSubtree; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // GeneralSubtrees::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void GeneralSubtrees::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen GeneralSubtrees::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // GeneralSubtrees::BEncContent - - -void GeneralSubtrees::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - GeneralSubtree *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-123); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // GeneralSubtrees::BDecContent - - -AuthorityKeyIdentifier::AuthorityKeyIdentifier() -{ - keyIdentifier = NULL; - authorityCertIssuer = NULL; - authorityCertSerialNumber = NULL; -} - -AuthorityKeyIdentifier::AuthorityKeyIdentifier (const AuthorityKeyIdentifier &) -{ - Asn1Error << "use of incompletely defined AuthorityKeyIdentifier::AuthorityKeyIdentifier (const AuthorityKeyIdentifier &)" << endl; - abort(); -} - -AuthorityKeyIdentifier::~AuthorityKeyIdentifier() -{ - delete keyIdentifier; - delete authorityCertIssuer; - delete authorityCertSerialNumber; -} - -AsnType *AuthorityKeyIdentifier::Clone() const -{ - return new AuthorityKeyIdentifier; -} - -AsnType *AuthorityKeyIdentifier::Copy() const -{ - return new AuthorityKeyIdentifier (*this); -} - -#if SNACC_DEEP_COPY -AuthorityKeyIdentifier &AuthorityKeyIdentifier::operator = (const AuthorityKeyIdentifier &that) -#else // SNACC_DEEP_COPY -AuthorityKeyIdentifier &AuthorityKeyIdentifier::operator = (const AuthorityKeyIdentifier &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.keyIdentifier) - { - if (!keyIdentifier) - keyIdentifier = new KeyIdentifier; - *keyIdentifier = *that.keyIdentifier; - } - else - { - delete keyIdentifier; - keyIdentifier = NULL; - } - if (that.authorityCertIssuer) - { - if (!authorityCertIssuer) - authorityCertIssuer = new GeneralNames; - *authorityCertIssuer = *that.authorityCertIssuer; - } - else - { - delete authorityCertIssuer; - authorityCertIssuer = NULL; - } - if (that.authorityCertSerialNumber) - { - if (!authorityCertSerialNumber) - authorityCertSerialNumber = new CertificateSerialNumber; - *authorityCertSerialNumber = *that.authorityCertSerialNumber; - } - else - { - delete authorityCertSerialNumber; - authorityCertSerialNumber = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined AuthorityKeyIdentifier &AuthorityKeyIdentifier::operator = (const AuthorityKeyIdentifier &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -AuthorityKeyIdentifier::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (authorityCertSerialNumber)) - { - l = authorityCertSerialNumber->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 2); - totalLen += l; - } - - if (NOT_NULL (authorityCertIssuer)) - { - BEncEocIfNec (b); - l = authorityCertIssuer->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - if (NOT_NULL (keyIdentifier)) - { - l = keyIdentifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - } - - return totalLen; -} // AuthorityKeyIdentifier::BEncContent - - -void AuthorityKeyIdentifier::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - keyIdentifier = new KeyIdentifier; - keyIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - authorityCertIssuer = new GeneralNames; - authorityCertIssuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 2)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - authorityCertSerialNumber = new CertificateSerialNumber; - authorityCertSerialNumber->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-124); - } - else - return; -} // AuthorityKeyIdentifier::BDecContent - -AsnLen AuthorityKeyIdentifier::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void AuthorityKeyIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AuthorityKeyIdentifier::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-125); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void AuthorityKeyIdentifier::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (keyIdentifier)) - { - nonePrinted = false; - Indent (os, indentG); - os << "keyIdentifier "; - os << *keyIdentifier; - } - else - { - Indent (os, indentG); - os << "keyIdentifier "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (authorityCertIssuer)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "authorityCertIssuer "; - os << *authorityCertIssuer; - } - else - { - Indent (os, indentG); - os << "authorityCertIssuer "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (authorityCertSerialNumber)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "authorityCertSerialNumber "; - os << *authorityCertSerialNumber; - } - else - { - Indent (os, indentG); - os << "authorityCertSerialNumber "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // AuthorityKeyIdentifier::Print - - -AsnType *ExtKeyUsageSyntax::Clone() const -{ - return new ExtKeyUsageSyntax; -} - -AsnType *ExtKeyUsageSyntax::Copy() const -{ - return new ExtKeyUsageSyntax (*this); -} - -AsnLen ExtKeyUsageSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void ExtKeyUsageSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "ExtKeyUsageSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-126); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -ExtKeyUsageSyntax::ExtKeyUsageSyntax (const ExtKeyUsageSyntax &) -{ - Asn1Error << "use of incompletely defined ExtKeyUsageSyntax::ExtKeyUsageSyntax (const ExtKeyUsageSyntax &)" << endl; - abort(); -} - -ExtKeyUsageSyntax::~ExtKeyUsageSyntax() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -ExtKeyUsageSyntax &ExtKeyUsageSyntax::operator = (const ExtKeyUsageSyntax &that) -#else // SNACC_DEEP_COPY -ExtKeyUsageSyntax &ExtKeyUsageSyntax::operator = (const ExtKeyUsageSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined ExtKeyUsageSyntax &ExtKeyUsageSyntax::operator = (const ExtKeyUsageSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void ExtKeyUsageSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void ExtKeyUsageSyntax::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // ExtKeyUsageSyntax::SetCurrElmt - - -unsigned long int ExtKeyUsageSyntax::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // ExtKeyUsageSyntax::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -KeyPurposeId *ExtKeyUsageSyntax::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new KeyPurposeId; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ExtKeyUsageSyntax::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -KeyPurposeId *ExtKeyUsageSyntax::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new KeyPurposeId; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ExtKeyUsageSyntax::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -KeyPurposeId *ExtKeyUsageSyntax::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new KeyPurposeId; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ExtKeyUsageSyntax::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -KeyPurposeId *ExtKeyUsageSyntax::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new KeyPurposeId; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // ExtKeyUsageSyntax::InsertAfter - - -ExtKeyUsageSyntax &ExtKeyUsageSyntax::AppendCopy (KeyPurposeId &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new KeyPurposeId; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -ExtKeyUsageSyntax &ExtKeyUsageSyntax::PrependCopy (KeyPurposeId &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new KeyPurposeId; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // ExtKeyUsageSyntax::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -ExtKeyUsageSyntax &ExtKeyUsageSyntax::InsertBeforeAndCopy (KeyPurposeId &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new KeyPurposeId; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // ExtKeyUsageSyntax::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -ExtKeyUsageSyntax &ExtKeyUsageSyntax::InsertAfterAndCopy (KeyPurposeId &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new KeyPurposeId; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // ExtKeyUsageSyntax::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void ExtKeyUsageSyntax::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen ExtKeyUsageSyntax::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncDefLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // ExtKeyUsageSyntax::BEncContent - - -void ExtKeyUsageSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - KeyPurposeId *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-127); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // ExtKeyUsageSyntax::BDecContent - - -PrivateKeyUsagePeriod::PrivateKeyUsagePeriod() -{ - notBefore = NULL; - notAfter = NULL; -} - -PrivateKeyUsagePeriod::PrivateKeyUsagePeriod (const PrivateKeyUsagePeriod &) -{ - Asn1Error << "use of incompletely defined PrivateKeyUsagePeriod::PrivateKeyUsagePeriod (const PrivateKeyUsagePeriod &)" << endl; - abort(); -} - -PrivateKeyUsagePeriod::~PrivateKeyUsagePeriod() -{ - delete notBefore; - delete notAfter; -} - -AsnType *PrivateKeyUsagePeriod::Clone() const -{ - return new PrivateKeyUsagePeriod; -} - -AsnType *PrivateKeyUsagePeriod::Copy() const -{ - return new PrivateKeyUsagePeriod (*this); -} - -#if SNACC_DEEP_COPY -PrivateKeyUsagePeriod &PrivateKeyUsagePeriod::operator = (const PrivateKeyUsagePeriod &that) -#else // SNACC_DEEP_COPY -PrivateKeyUsagePeriod &PrivateKeyUsagePeriod::operator = (const PrivateKeyUsagePeriod &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.notBefore) - { - if (!notBefore) - notBefore = new GeneralizedTime; - *notBefore = *that.notBefore; - } - else - { - delete notBefore; - notBefore = NULL; - } - if (that.notAfter) - { - if (!notAfter) - notAfter = new GeneralizedTime; - *notAfter = *that.notAfter; - } - else - { - delete notAfter; - notAfter = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PrivateKeyUsagePeriod &PrivateKeyUsagePeriod::operator = (const PrivateKeyUsagePeriod &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -PrivateKeyUsagePeriod::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (notAfter)) - { - l = notAfter->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 1); - totalLen += l; - } - - if (NOT_NULL (notBefore)) - { - l = notBefore->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - } - - return totalLen; -} // PrivateKeyUsagePeriod::BEncContent - - -void PrivateKeyUsagePeriod::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - notBefore = new GeneralizedTime; - notBefore->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - notAfter = new GeneralizedTime; - notAfter->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-128); - } - else - return; -} // PrivateKeyUsagePeriod::BDecContent - -AsnLen PrivateKeyUsagePeriod::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void PrivateKeyUsagePeriod::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "PrivateKeyUsagePeriod::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-129); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void PrivateKeyUsagePeriod::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (notBefore)) - { - nonePrinted = false; - Indent (os, indentG); - os << "notBefore "; - os << *notBefore; - } - else - { - Indent (os, indentG); - os << "notBefore "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (notAfter)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "notAfter "; - os << *notAfter; - } - else - { - Indent (os, indentG); - os << "notAfter "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // PrivateKeyUsagePeriod::Print - - -AsnType *PolicyMappingsSyntax::Clone() const -{ - return new PolicyMappingsSyntax; -} - -AsnType *PolicyMappingsSyntax::Copy() const -{ - return new PolicyMappingsSyntax (*this); -} - -AsnLen PolicyMappingsSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void PolicyMappingsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "PolicyMappingsSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-130); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -PolicyMappingsSyntax::PolicyMappingsSyntax (const PolicyMappingsSyntax &) -{ - Asn1Error << "use of incompletely defined PolicyMappingsSyntax::PolicyMappingsSyntax (const PolicyMappingsSyntax &)" << endl; - abort(); -} - -PolicyMappingsSyntax::~PolicyMappingsSyntax() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -PolicyMappingsSyntax &PolicyMappingsSyntax::operator = (const PolicyMappingsSyntax &that) -#else // SNACC_DEEP_COPY -PolicyMappingsSyntax &PolicyMappingsSyntax::operator = (const PolicyMappingsSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PolicyMappingsSyntax &PolicyMappingsSyntax::operator = (const PolicyMappingsSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void PolicyMappingsSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void PolicyMappingsSyntax::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // PolicyMappingsSyntax::SetCurrElmt - - -unsigned long int PolicyMappingsSyntax::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // PolicyMappingsSyntax::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -PolicyMappingsSyntaxSeq *PolicyMappingsSyntax::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyMappingsSyntaxSeq; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // PolicyMappingsSyntax::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -PolicyMappingsSyntaxSeq *PolicyMappingsSyntax::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyMappingsSyntaxSeq; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // PolicyMappingsSyntax::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -PolicyMappingsSyntaxSeq *PolicyMappingsSyntax::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyMappingsSyntaxSeq; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // PolicyMappingsSyntax::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -PolicyMappingsSyntaxSeq *PolicyMappingsSyntax::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyMappingsSyntaxSeq; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // PolicyMappingsSyntax::InsertAfter - - -PolicyMappingsSyntax &PolicyMappingsSyntax::AppendCopy (PolicyMappingsSyntaxSeq &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyMappingsSyntaxSeq; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -PolicyMappingsSyntax &PolicyMappingsSyntax::PrependCopy (PolicyMappingsSyntaxSeq &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyMappingsSyntaxSeq; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // PolicyMappingsSyntax::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -PolicyMappingsSyntax &PolicyMappingsSyntax::InsertBeforeAndCopy (PolicyMappingsSyntaxSeq &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyMappingsSyntaxSeq; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // PolicyMappingsSyntax::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -PolicyMappingsSyntax &PolicyMappingsSyntax::InsertAfterAndCopy (PolicyMappingsSyntaxSeq &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new PolicyMappingsSyntaxSeq; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // PolicyMappingsSyntax::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void PolicyMappingsSyntax::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen PolicyMappingsSyntax::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // PolicyMappingsSyntax::BEncContent - - -void PolicyMappingsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - PolicyMappingsSyntaxSeq *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-131); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // PolicyMappingsSyntax::BDecContent - - -SupportedAlgorithm::SupportedAlgorithm() -{ -#if TCL - algorithmIdentifier = new AlgorithmIdentifier; -#else - algorithmIdentifier = NULL; // incomplete initialization of mandatory element! -#endif // TCL - intendedUsage = NULL; - intendedCertificatePolicies = NULL; -} - -SupportedAlgorithm::SupportedAlgorithm (const SupportedAlgorithm &) -{ - Asn1Error << "use of incompletely defined SupportedAlgorithm::SupportedAlgorithm (const SupportedAlgorithm &)" << endl; - abort(); -} - -SupportedAlgorithm::~SupportedAlgorithm() -{ - delete algorithmIdentifier; - delete intendedUsage; - delete intendedCertificatePolicies; -} - -AsnType *SupportedAlgorithm::Clone() const -{ - return new SupportedAlgorithm; -} - -AsnType *SupportedAlgorithm::Copy() const -{ - return new SupportedAlgorithm (*this); -} - -#if SNACC_DEEP_COPY -SupportedAlgorithm &SupportedAlgorithm::operator = (const SupportedAlgorithm &that) -#else // SNACC_DEEP_COPY -SupportedAlgorithm &SupportedAlgorithm::operator = (const SupportedAlgorithm &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.algorithmIdentifier) - { - if (!algorithmIdentifier) - algorithmIdentifier = new AlgorithmIdentifier; - *algorithmIdentifier = *that.algorithmIdentifier; - } - else - { - delete algorithmIdentifier; - algorithmIdentifier = NULL; - } - if (that.intendedUsage) - { - if (!intendedUsage) - intendedUsage = new KeyUsage; - *intendedUsage = *that.intendedUsage; - } - else - { - delete intendedUsage; - intendedUsage = NULL; - } - if (that.intendedCertificatePolicies) - { - if (!intendedCertificatePolicies) - intendedCertificatePolicies = new CertificatePoliciesSyntax; - *intendedCertificatePolicies = *that.intendedCertificatePolicies; - } - else - { - delete intendedCertificatePolicies; - intendedCertificatePolicies = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined SupportedAlgorithm &SupportedAlgorithm::operator = (const SupportedAlgorithm &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -SupportedAlgorithm::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (intendedCertificatePolicies)) - { - BEncEocIfNec (b); - l = intendedCertificatePolicies->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - if (NOT_NULL (intendedUsage)) - { - l = intendedUsage->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - } - - BEncEocIfNec (b); - l = algorithmIdentifier->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += l; - - return totalLen; -} // SupportedAlgorithm::BEncContent - - -void SupportedAlgorithm::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - algorithmIdentifier = new AlgorithmIdentifier; - algorithmIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-132); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - intendedUsage = new KeyUsage; - intendedUsage->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - intendedCertificatePolicies = new CertificatePoliciesSyntax; - intendedCertificatePolicies->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-133); - } - else - return; -} // SupportedAlgorithm::BDecContent - -AsnLen SupportedAlgorithm::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void SupportedAlgorithm::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "SupportedAlgorithm::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-134); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void SupportedAlgorithm::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (algorithmIdentifier)) - { - Indent (os, indentG); - os << "algorithmIdentifier "; - os << *algorithmIdentifier; - } - else - { - Indent (os, indentG); - os << "algorithmIdentifier "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (intendedUsage)) - { - os << ","<< endl; - Indent (os, indentG); - os << "intendedUsage "; - os << *intendedUsage; - } - else - { - Indent (os, indentG); - os << "intendedUsage "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (intendedCertificatePolicies)) - { - os << ","<< endl; - Indent (os, indentG); - os << "intendedCertificatePolicies "; - os << *intendedCertificatePolicies; - } - else - { - Indent (os, indentG); - os << "intendedCertificatePolicies "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // SupportedAlgorithm::Print - - -BasicConstraintsSyntax::BasicConstraintsSyntax() -{ - cA = NULL; - pathLenConstraint = NULL; -} - -BasicConstraintsSyntax::BasicConstraintsSyntax (const BasicConstraintsSyntax &) -{ - Asn1Error << "use of incompletely defined BasicConstraintsSyntax::BasicConstraintsSyntax (const BasicConstraintsSyntax &)" << endl; - abort(); -} - -BasicConstraintsSyntax::~BasicConstraintsSyntax() -{ - delete cA; - delete pathLenConstraint; -} - -AsnType *BasicConstraintsSyntax::Clone() const -{ - return new BasicConstraintsSyntax; -} - -AsnType *BasicConstraintsSyntax::Copy() const -{ - return new BasicConstraintsSyntax (*this); -} - -#if SNACC_DEEP_COPY -BasicConstraintsSyntax &BasicConstraintsSyntax::operator = (const BasicConstraintsSyntax &that) -#else // SNACC_DEEP_COPY -BasicConstraintsSyntax &BasicConstraintsSyntax::operator = (const BasicConstraintsSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.cA) - { - if (!cA) - cA = new AsnBool; - *cA = *that.cA; - } - else - { - delete cA; - cA = NULL; - } - if (that.pathLenConstraint) - { - if (!pathLenConstraint) - pathLenConstraint = new AsnInt; - *pathLenConstraint = *that.pathLenConstraint; - } - else - { - delete pathLenConstraint; - pathLenConstraint = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined BasicConstraintsSyntax &BasicConstraintsSyntax::operator = (const BasicConstraintsSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -BasicConstraintsSyntax::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (pathLenConstraint)) - { - l = pathLenConstraint->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (cA)) - { - l = cA->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, BOOLEAN_TAG_CODE); - totalLen += l; - } - - return totalLen; -} // BasicConstraintsSyntax::BEncContent - - -void BasicConstraintsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - cA = new AsnBool; - cA->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - pathLenConstraint = new AsnInt; - pathLenConstraint->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-135); - } - else - return; -} // BasicConstraintsSyntax::BDecContent - -AsnLen BasicConstraintsSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void BasicConstraintsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "BasicConstraintsSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-136); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void BasicConstraintsSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (cA)) - { - nonePrinted = false; - Indent (os, indentG); - os << "cA "; - os << *cA; - } - else - { - Indent (os, indentG); - os << "cA "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (pathLenConstraint)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "pathLenConstraint "; - os << *pathLenConstraint; - } - else - { - Indent (os, indentG); - os << "pathLenConstraint "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // BasicConstraintsSyntax::Print - - -NameConstraintsSyntax::NameConstraintsSyntax() -{ - permittedSubtrees = NULL; - excludedSubtrees = NULL; -} - -NameConstraintsSyntax::NameConstraintsSyntax (const NameConstraintsSyntax &) -{ - Asn1Error << "use of incompletely defined NameConstraintsSyntax::NameConstraintsSyntax (const NameConstraintsSyntax &)" << endl; - abort(); -} - -NameConstraintsSyntax::~NameConstraintsSyntax() -{ - delete permittedSubtrees; - delete excludedSubtrees; -} - -AsnType *NameConstraintsSyntax::Clone() const -{ - return new NameConstraintsSyntax; -} - -AsnType *NameConstraintsSyntax::Copy() const -{ - return new NameConstraintsSyntax (*this); -} - -#if SNACC_DEEP_COPY -NameConstraintsSyntax &NameConstraintsSyntax::operator = (const NameConstraintsSyntax &that) -#else // SNACC_DEEP_COPY -NameConstraintsSyntax &NameConstraintsSyntax::operator = (const NameConstraintsSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.permittedSubtrees) - { - if (!permittedSubtrees) - permittedSubtrees = new GeneralSubtrees; - *permittedSubtrees = *that.permittedSubtrees; - } - else - { - delete permittedSubtrees; - permittedSubtrees = NULL; - } - if (that.excludedSubtrees) - { - if (!excludedSubtrees) - excludedSubtrees = new GeneralSubtrees; - *excludedSubtrees = *that.excludedSubtrees; - } - else - { - delete excludedSubtrees; - excludedSubtrees = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined NameConstraintsSyntax &NameConstraintsSyntax::operator = (const NameConstraintsSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -NameConstraintsSyntax::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (excludedSubtrees)) - { - BEncEocIfNec (b); - l = excludedSubtrees->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - } - - if (NOT_NULL (permittedSubtrees)) - { - BEncEocIfNec (b); - l = permittedSubtrees->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // NameConstraintsSyntax::BEncContent - - -void NameConstraintsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - permittedSubtrees = new GeneralSubtrees; - permittedSubtrees->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - excludedSubtrees = new GeneralSubtrees; - excludedSubtrees->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-137); - } - else - return; -} // NameConstraintsSyntax::BDecContent - -AsnLen NameConstraintsSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void NameConstraintsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "NameConstraintsSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-138); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void NameConstraintsSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (permittedSubtrees)) - { - nonePrinted = false; - Indent (os, indentG); - os << "permittedSubtrees "; - os << *permittedSubtrees; - } - else - { - Indent (os, indentG); - os << "permittedSubtrees "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (excludedSubtrees)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "excludedSubtrees "; - os << *excludedSubtrees; - } - else - { - Indent (os, indentG); - os << "excludedSubtrees "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // NameConstraintsSyntax::Print - - -PolicyConstraintsSyntax::PolicyConstraintsSyntax() -{ - requireExplicitPolicy = NULL; - inhibitPolicyMapping = NULL; -} - -PolicyConstraintsSyntax::PolicyConstraintsSyntax (const PolicyConstraintsSyntax &) -{ - Asn1Error << "use of incompletely defined PolicyConstraintsSyntax::PolicyConstraintsSyntax (const PolicyConstraintsSyntax &)" << endl; - abort(); -} - -PolicyConstraintsSyntax::~PolicyConstraintsSyntax() -{ - delete requireExplicitPolicy; - delete inhibitPolicyMapping; -} - -AsnType *PolicyConstraintsSyntax::Clone() const -{ - return new PolicyConstraintsSyntax; -} - -AsnType *PolicyConstraintsSyntax::Copy() const -{ - return new PolicyConstraintsSyntax (*this); -} - -#if SNACC_DEEP_COPY -PolicyConstraintsSyntax &PolicyConstraintsSyntax::operator = (const PolicyConstraintsSyntax &that) -#else // SNACC_DEEP_COPY -PolicyConstraintsSyntax &PolicyConstraintsSyntax::operator = (const PolicyConstraintsSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.requireExplicitPolicy) - { - if (!requireExplicitPolicy) - requireExplicitPolicy = new SkipCerts; - *requireExplicitPolicy = *that.requireExplicitPolicy; - } - else - { - delete requireExplicitPolicy; - requireExplicitPolicy = NULL; - } - if (that.inhibitPolicyMapping) - { - if (!inhibitPolicyMapping) - inhibitPolicyMapping = new SkipCerts; - *inhibitPolicyMapping = *that.inhibitPolicyMapping; - } - else - { - delete inhibitPolicyMapping; - inhibitPolicyMapping = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined PolicyConstraintsSyntax &PolicyConstraintsSyntax::operator = (const PolicyConstraintsSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -PolicyConstraintsSyntax::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (inhibitPolicyMapping)) - { - l = inhibitPolicyMapping->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 1); - totalLen += l; - } - - if (NOT_NULL (requireExplicitPolicy)) - { - l = requireExplicitPolicy->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 0); - totalLen += l; - } - - return totalLen; -} // PolicyConstraintsSyntax::BEncContent - - -void PolicyConstraintsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - requireExplicitPolicy = new SkipCerts; - requireExplicitPolicy->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - inhibitPolicyMapping = new SkipCerts; - inhibitPolicyMapping->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-139); - } - else - return; -} // PolicyConstraintsSyntax::BDecContent - -AsnLen PolicyConstraintsSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void PolicyConstraintsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "PolicyConstraintsSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-140); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void PolicyConstraintsSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (requireExplicitPolicy)) - { - nonePrinted = false; - Indent (os, indentG); - os << "requireExplicitPolicy "; - os << *requireExplicitPolicy; - } - else - { - Indent (os, indentG); - os << "requireExplicitPolicy "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (inhibitPolicyMapping)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "inhibitPolicyMapping "; - os << *inhibitPolicyMapping; - } - else - { - Indent (os, indentG); - os << "inhibitPolicyMapping "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // PolicyConstraintsSyntax::Print - - -AsnType *CertPolicySet::Clone() const -{ - return new CertPolicySet; -} - -AsnType *CertPolicySet::Copy() const -{ - return new CertPolicySet (*this); -} - -AsnLen CertPolicySet::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CertPolicySet::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CertPolicySet::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-141); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -CertPolicySet::CertPolicySet (const CertPolicySet &) -{ - Asn1Error << "use of incompletely defined CertPolicySet::CertPolicySet (const CertPolicySet &)" << endl; - abort(); -} - -CertPolicySet::~CertPolicySet() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -CertPolicySet &CertPolicySet::operator = (const CertPolicySet &that) -#else // SNACC_DEEP_COPY -CertPolicySet &CertPolicySet::operator = (const CertPolicySet &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CertPolicySet &CertPolicySet::operator = (const CertPolicySet &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void CertPolicySet::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void CertPolicySet::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // CertPolicySet::SetCurrElmt - - -unsigned long int CertPolicySet::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // CertPolicySet::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -CertPolicyId *CertPolicySet::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertPolicyId; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertPolicySet::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -CertPolicyId *CertPolicySet::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertPolicyId; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertPolicySet::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -CertPolicyId *CertPolicySet::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertPolicyId; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertPolicySet::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertPolicyId *CertPolicySet::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertPolicyId; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CertPolicySet::InsertAfter - - -CertPolicySet &CertPolicySet::AppendCopy (CertPolicyId &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertPolicyId; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -CertPolicySet &CertPolicySet::PrependCopy (CertPolicyId &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new CertPolicyId; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // CertPolicySet::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -CertPolicySet &CertPolicySet::InsertBeforeAndCopy (CertPolicyId &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CertPolicyId; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // CertPolicySet::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CertPolicySet &CertPolicySet::InsertAfterAndCopy (CertPolicyId &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new CertPolicyId; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // CertPolicySet::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void CertPolicySet::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen CertPolicySet::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncDefLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // CertPolicySet::BEncContent - - -void CertPolicySet::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - CertPolicyId *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-142); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // CertPolicySet::BDecContent - - -AsnType *CRLDistPointsSyntax::Clone() const -{ - return new CRLDistPointsSyntax; -} - -AsnType *CRLDistPointsSyntax::Copy() const -{ - return new CRLDistPointsSyntax (*this); -} - -AsnLen CRLDistPointsSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void CRLDistPointsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "CRLDistPointsSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-143); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -CRLDistPointsSyntax::CRLDistPointsSyntax (const CRLDistPointsSyntax &) -{ - Asn1Error << "use of incompletely defined CRLDistPointsSyntax::CRLDistPointsSyntax (const CRLDistPointsSyntax &)" << endl; - abort(); -} - -CRLDistPointsSyntax::~CRLDistPointsSyntax() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -CRLDistPointsSyntax &CRLDistPointsSyntax::operator = (const CRLDistPointsSyntax &that) -#else // SNACC_DEEP_COPY -CRLDistPointsSyntax &CRLDistPointsSyntax::operator = (const CRLDistPointsSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined CRLDistPointsSyntax &CRLDistPointsSyntax::operator = (const CRLDistPointsSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void CRLDistPointsSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void CRLDistPointsSyntax::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // CRLDistPointsSyntax::SetCurrElmt - - -unsigned long int CRLDistPointsSyntax::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // CRLDistPointsSyntax::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -DistributionPoint *CRLDistPointsSyntax::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DistributionPoint; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CRLDistPointsSyntax::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -DistributionPoint *CRLDistPointsSyntax::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DistributionPoint; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CRLDistPointsSyntax::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -DistributionPoint *CRLDistPointsSyntax::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DistributionPoint; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CRLDistPointsSyntax::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -DistributionPoint *CRLDistPointsSyntax::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DistributionPoint; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // CRLDistPointsSyntax::InsertAfter - - -CRLDistPointsSyntax &CRLDistPointsSyntax::AppendCopy (DistributionPoint &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DistributionPoint; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -CRLDistPointsSyntax &CRLDistPointsSyntax::PrependCopy (DistributionPoint &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new DistributionPoint; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // CRLDistPointsSyntax::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -CRLDistPointsSyntax &CRLDistPointsSyntax::InsertBeforeAndCopy (DistributionPoint &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new DistributionPoint; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // CRLDistPointsSyntax::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -CRLDistPointsSyntax &CRLDistPointsSyntax::InsertAfterAndCopy (DistributionPoint &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new DistributionPoint; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // CRLDistPointsSyntax::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void CRLDistPointsSyntax::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen CRLDistPointsSyntax::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - BEncEocIfNec (b); - elmtLen = currElmt->elmt->BEncContent (b); - elmtLen += BEncConsLen (b, elmtLen); - - elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - totalLen += elmtLen; - } - return totalLen; -} // CRLDistPointsSyntax::BEncContent - - -void CRLDistPointsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - DistributionPoint *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-144); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // CRLDistPointsSyntax::BDecContent - - -IssuingDistPointSyntax::IssuingDistPointSyntax() -{ - distributionPoint = NULL; - onlyContainsUserCerts = NULL; - onlyContainsCACerts = NULL; - onlySomeReasons = NULL; - indirectCRL = NULL; -} - -IssuingDistPointSyntax::IssuingDistPointSyntax (const IssuingDistPointSyntax &) -{ - Asn1Error << "use of incompletely defined IssuingDistPointSyntax::IssuingDistPointSyntax (const IssuingDistPointSyntax &)" << endl; - abort(); -} - -IssuingDistPointSyntax::~IssuingDistPointSyntax() -{ - delete distributionPoint; - delete onlyContainsUserCerts; - delete onlyContainsCACerts; - delete onlySomeReasons; - delete indirectCRL; -} - -AsnType *IssuingDistPointSyntax::Clone() const -{ - return new IssuingDistPointSyntax; -} - -AsnType *IssuingDistPointSyntax::Copy() const -{ - return new IssuingDistPointSyntax (*this); -} - -#if SNACC_DEEP_COPY -IssuingDistPointSyntax &IssuingDistPointSyntax::operator = (const IssuingDistPointSyntax &that) -#else // SNACC_DEEP_COPY -IssuingDistPointSyntax &IssuingDistPointSyntax::operator = (const IssuingDistPointSyntax &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.distributionPoint) - { - if (!distributionPoint) - distributionPoint = new DistributionPointName; - *distributionPoint = *that.distributionPoint; - } - else - { - delete distributionPoint; - distributionPoint = NULL; - } - if (that.onlyContainsUserCerts) - { - if (!onlyContainsUserCerts) - onlyContainsUserCerts = new AsnBool; - *onlyContainsUserCerts = *that.onlyContainsUserCerts; - } - else - { - delete onlyContainsUserCerts; - onlyContainsUserCerts = NULL; - } - if (that.onlyContainsCACerts) - { - if (!onlyContainsCACerts) - onlyContainsCACerts = new AsnBool; - *onlyContainsCACerts = *that.onlyContainsCACerts; - } - else - { - delete onlyContainsCACerts; - onlyContainsCACerts = NULL; - } - if (that.onlySomeReasons) - { - if (!onlySomeReasons) - onlySomeReasons = new ReasonFlags; - *onlySomeReasons = *that.onlySomeReasons; - } - else - { - delete onlySomeReasons; - onlySomeReasons = NULL; - } - if (that.indirectCRL) - { - if (!indirectCRL) - indirectCRL = new AsnBool; - *indirectCRL = *that.indirectCRL; - } - else - { - delete indirectCRL; - indirectCRL = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined IssuingDistPointSyntax &IssuingDistPointSyntax::operator = (const IssuingDistPointSyntax &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -IssuingDistPointSyntax::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - if (NOT_NULL (indirectCRL)) - { - l = indirectCRL->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 4); - totalLen += l; - } - - if (NOT_NULL (onlySomeReasons)) - { - l = onlySomeReasons->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 3); - totalLen += l; - } - - if (NOT_NULL (onlyContainsCACerts)) - { - l = onlyContainsCACerts->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 2); - totalLen += l; - } - - if (NOT_NULL (onlyContainsUserCerts)) - { - l = onlyContainsUserCerts->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, CNTX, PRIM, 1); - totalLen += l; - } - - if (NOT_NULL (distributionPoint)) - { - BEncEocIfNec (b); - l = distributionPoint->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // IssuingDistPointSyntax::BEncContent - - -void IssuingDistPointSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - if (elmtLen0 == 0) - return; - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - distributionPoint = new DistributionPointName; - distributionPoint->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - onlyContainsUserCerts = new AsnBool; - onlyContainsUserCerts->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - onlyContainsCACerts = new AsnBool; - onlyContainsCACerts->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 3)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 3))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - onlySomeReasons = new ReasonFlags; - onlySomeReasons->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - if (seqBytesDecoded == elmtLen0) - { - bytesDecoded += seqBytesDecoded; - return; - } - else - { - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env) - bytesDecoded += seqBytesDecoded; - return; - } - } - } - - if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 4))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - indirectCRL = new AsnBool; - indirectCRL->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-145); - } - else - return; -} // IssuingDistPointSyntax::BDecContent - -AsnLen IssuingDistPointSyntax::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void IssuingDistPointSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "IssuingDistPointSyntax::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-146); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void IssuingDistPointSyntax::Print (ostream &os) const -{ -#ifndef NDEBUG - int nonePrinted = true; - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (distributionPoint)) - { - nonePrinted = false; - Indent (os, indentG); - os << "distributionPoint "; - os << *distributionPoint; - } - else - { - Indent (os, indentG); - os << "distributionPoint "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (onlyContainsUserCerts)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "onlyContainsUserCerts "; - os << *onlyContainsUserCerts; - } - else - { - Indent (os, indentG); - os << "onlyContainsUserCerts "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (onlyContainsCACerts)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "onlyContainsCACerts "; - os << *onlyContainsCACerts; - } - else - { - Indent (os, indentG); - os << "onlyContainsCACerts "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (onlySomeReasons)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "onlySomeReasons "; - os << *onlySomeReasons; - } - else - { - Indent (os, indentG); - os << "onlySomeReasons "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (indirectCRL)) - { - if (!nonePrinted) - os << "," << endl; - nonePrinted = false; - Indent (os, indentG); - os << "indirectCRL "; - os << *indirectCRL; - } - else - { - Indent (os, indentG); - os << "indirectCRL "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // IssuingDistPointSyntax::Print - - diff --git a/SecurityASN1/c++/sm_x509cmn.cpp b/SecurityASN1/c++/sm_x509cmn.cpp deleted file mode 100644 index dca97bd7..00000000 --- a/SecurityASN1/c++/sm_x509cmn.cpp +++ /dev/null @@ -1,1108 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x509cmn.cpp - class member functions for ASN.1 module CommonX509Definitions -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -EDIPartyName::EDIPartyName() -{ - nameAssigner = NULL; -#if TCL - partyName = new DirectoryString; -#else - partyName = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EDIPartyName::EDIPartyName (const EDIPartyName &) -{ - Asn1Error << "use of incompletely defined EDIPartyName::EDIPartyName (const EDIPartyName &)" << endl; - abort(); -} - -EDIPartyName::~EDIPartyName() -{ - delete nameAssigner; - delete partyName; -} - -AsnType *EDIPartyName::Clone() const -{ - return new EDIPartyName; -} - -AsnType *EDIPartyName::Copy() const -{ - return new EDIPartyName (*this); -} - -#if SNACC_DEEP_COPY -EDIPartyName &EDIPartyName::operator = (const EDIPartyName &that) -#else // SNACC_DEEP_COPY -EDIPartyName &EDIPartyName::operator = (const EDIPartyName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.nameAssigner) - { - if (!nameAssigner) - nameAssigner = new DirectoryString; - *nameAssigner = *that.nameAssigner; - } - else - { - delete nameAssigner; - nameAssigner = NULL; - } - if (that.partyName) - { - if (!partyName) - partyName = new DirectoryString; - *partyName = *that.partyName; - } - else - { - delete partyName; - partyName = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EDIPartyName &EDIPartyName::operator = (const EDIPartyName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EDIPartyName::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - BEncEocIfNec (b); - l = partyName->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 1); - totalLen += l; - - if (NOT_NULL (nameAssigner)) - { - BEncEocIfNec (b); - l = nameAssigner->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - totalLen += l; - } - - return totalLen; -} // EDIPartyName::BEncContent - - -void EDIPartyName::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - AsnLen elmtLen2; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - nameAssigner = new DirectoryString; - nameAssigner->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - elmtLen2 = BDecLen (b, seqBytesDecoded, env); - partyName = new DirectoryString; - partyName->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, seqBytesDecoded, env); - - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(-100); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(-101); - } - else - return; -} // EDIPartyName::BDecContent - -AsnLen EDIPartyName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void EDIPartyName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "EDIPartyName::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-102); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EDIPartyName::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (nameAssigner)) - { - Indent (os, indentG); - os << "nameAssigner "; - os << *nameAssigner; - } - else - { - Indent (os, indentG); - os << "nameAssigner "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (partyName)) - { - Indent (os, indentG); - os << "partyName "; - os << *partyName; - } - else - { - Indent (os, indentG); - os << "partyName "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EDIPartyName::Print - - -GeneralName::GeneralName() -{ - choiceId = otherNameCid; -#if TCL - otherName = new OTHER_NAME; -#else - otherName = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -GeneralName::GeneralName (const GeneralName &) -{ - Asn1Error << "use of incompletely defined GeneralName::GeneralName (const GeneralName &)" << endl; - abort(); -} - -GeneralName::~GeneralName() -{ - switch (choiceId) - { - case otherNameCid: - delete otherName; - break; - case rfc822NameCid: - delete rfc822Name; - break; - case dNSNameCid: - delete dNSName; - break; - case x400AddressCid: - delete x400Address; - break; - case directoryNameCid: - delete directoryName; - break; - case ediPartyNameCid: - delete ediPartyName; - break; - case uniformResourceIdentifierCid: - delete uniformResourceIdentifier; - break; - case iPAddressCid: - delete iPAddress; - break; - case registeredIDCid: - delete registeredID; - break; - } // end of switch -} // end of destructor - -AsnType *GeneralName::Clone() const -{ - return new GeneralName; -} - -AsnType *GeneralName::Copy() const -{ - return new GeneralName (*this); -} - -#if SNACC_DEEP_COPY -GeneralName &GeneralName::operator = (const GeneralName &that) -#else // SNACC_DEEP_COPY -GeneralName &GeneralName::operator = (const GeneralName &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case otherNameCid: - delete otherName; - break; - case rfc822NameCid: - delete rfc822Name; - break; - case dNSNameCid: - delete dNSName; - break; - case x400AddressCid: - delete x400Address; - break; - case directoryNameCid: - delete directoryName; - break; - case ediPartyNameCid: - delete ediPartyName; - break; - case uniformResourceIdentifierCid: - delete uniformResourceIdentifier; - break; - case iPAddressCid: - delete iPAddress; - break; - case registeredIDCid: - delete registeredID; - break; - } - switch (choiceId = that.choiceId) - { - case otherNameCid: - otherName = new OTHER_NAME; - *otherName = *that.otherName; - break; - case rfc822NameCid: - rfc822Name = new IA5String; - *rfc822Name = *that.rfc822Name; - break; - case dNSNameCid: - dNSName = new IA5String; - *dNSName = *that.dNSName; - break; - case x400AddressCid: - x400Address = new ORAddress; - *x400Address = *that.x400Address; - break; - case directoryNameCid: - directoryName = new Name; - *directoryName = *that.directoryName; - break; - case ediPartyNameCid: - ediPartyName = new EDIPartyName; - *ediPartyName = *that.ediPartyName; - break; - case uniformResourceIdentifierCid: - uniformResourceIdentifier = new IA5String; - *uniformResourceIdentifier = *that.uniformResourceIdentifier; - break; - case iPAddressCid: - iPAddress = new AsnOcts; - *iPAddress = *that.iPAddress; - break; - case registeredIDCid: - registeredID = new AsnOid; - *registeredID = *that.registeredID; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined GeneralName &GeneralName::operator = (const GeneralName &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -GeneralName::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case otherNameCid: - l = otherName->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 0); - break; - - case rfc822NameCid: - l = rfc822Name->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 1); - break; - - case dNSNameCid: - l = dNSName->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 2); - break; - - case x400AddressCid: - BEncEocIfNec (b); - l = x400Address->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 3); - break; - - case directoryNameCid: - BEncEocIfNec (b); - l = directoryName->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 4); - break; - - case ediPartyNameCid: - BEncEocIfNec (b); - l = ediPartyName->BEncContent (b); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 5); - break; - - case uniformResourceIdentifierCid: - l = uniformResourceIdentifier->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 6); - break; - - case iPAddressCid: - l = iPAddress->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 7); - break; - - case registeredIDCid: - l = registeredID->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 8); - break; - - } // end switch - return l; -} // GeneralName::BEncContent - - -void GeneralName::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen1; - switch (tag) - { - case MAKE_TAG_ID (CNTX, PRIM, 0): - choiceId = otherNameCid; - otherName = new OTHER_NAME; - otherName->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 1): - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = rfc822NameCid; - rfc822Name = new IA5String; - rfc822Name->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 2): - case MAKE_TAG_ID (CNTX, CONS, 2): - choiceId = dNSNameCid; - dNSName = new IA5String; - dNSName->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 3): - choiceId = x400AddressCid; - x400Address = new ORAddress; - x400Address->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 4): - tag = BDecTag (b, bytesDecoded, env); - elmtLen1 = BDecLen (b, bytesDecoded, env); - choiceId = directoryNameCid; - directoryName = new Name; - directoryName->BDecContent (b, tag, elmtLen1, bytesDecoded, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 5): - choiceId = ediPartyNameCid; - ediPartyName = new EDIPartyName; - ediPartyName->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 6): - case MAKE_TAG_ID (CNTX, CONS, 6): - choiceId = uniformResourceIdentifierCid; - uniformResourceIdentifier = new IA5String; - uniformResourceIdentifier->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 7): - case MAKE_TAG_ID (CNTX, CONS, 7): - choiceId = iPAddressCid; - iPAddress = new AsnOcts; - iPAddress->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 8): - choiceId = registeredIDCid; - registeredID = new AsnOid; - registeredID->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-103); - break; - } // end switch -} // GeneralName::BDecContent - - -AsnLen GeneralName::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void GeneralName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void GeneralName::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case otherNameCid: - os << "otherName "; - if (otherName) - os << *otherName; - else - os << "-- void3 --\n"; - break; - - case rfc822NameCid: - os << "rfc822Name "; - if (rfc822Name) - os << *rfc822Name; - else - os << "-- void3 --\n"; - break; - - case dNSNameCid: - os << "dNSName "; - if (dNSName) - os << *dNSName; - else - os << "-- void3 --\n"; - break; - - case x400AddressCid: - os << "x400Address "; - if (x400Address) - os << *x400Address; - else - os << "-- void3 --\n"; - break; - - case directoryNameCid: - os << "directoryName "; - if (directoryName) - os << *directoryName; - else - os << "-- void3 --\n"; - break; - - case ediPartyNameCid: - os << "ediPartyName "; - if (ediPartyName) - os << *ediPartyName; - else - os << "-- void3 --\n"; - break; - - case uniformResourceIdentifierCid: - os << "uniformResourceIdentifier "; - if (uniformResourceIdentifier) - os << *uniformResourceIdentifier; - else - os << "-- void3 --\n"; - break; - - case iPAddressCid: - os << "iPAddress "; - if (iPAddress) - os << *iPAddress; - else - os << "-- void3 --\n"; - break; - - case registeredIDCid: - os << "registeredID "; - if (registeredID) - os << *registeredID; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // GeneralName::Print - -AsnType *GeneralNames::Clone() const -{ - return new GeneralNames; -} - -AsnType *GeneralNames::Copy() const -{ - return new GeneralNames (*this); -} - -AsnLen GeneralNames::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -void GeneralNames::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "GeneralNames::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(-104); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -GeneralNames::GeneralNames (const GeneralNames &) -{ - Asn1Error << "use of incompletely defined GeneralNames::GeneralNames (const GeneralNames &)" << endl; - abort(); -} - -GeneralNames::~GeneralNames() -{ - SetCurrToFirst(); - for (; Curr() != NULL; RemoveCurrFromList()) - ; -} // end of destructor - -#if SNACC_DEEP_COPY -GeneralNames &GeneralNames::operator = (const GeneralNames &that) -#else // SNACC_DEEP_COPY -GeneralNames &GeneralNames::operator = (const GeneralNames &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - SetCurrToFirst(); - for (; Curr(); RemoveCurrFromList()) - ; - - //that.SetCurrToFirst(); - //for (; that.Curr(); that.GoNext()) - // AppendCopy (*that.Curr()); - for (const AsnListElmt *run=that.first; run; run=run->next) - AppendCopy (*run->elmt); - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined GeneralNames &GeneralNames::operator = (const GeneralNames &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -void GeneralNames::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE/SET OF -- " << endl; - indentG += stdIndentG; - //SetCurrToFirst(); - //for (; Curr() != NULL; GoNext()) - for (const AsnListElmt *run=first; run; run=run->next) - { - Indent (os, indentG); - //os << *Curr(); - os << *run->elmt; - //if (Curr() != Last()) - if (run != last) - os << ","; - os << endl; - } - indentG -= stdIndentG; - Indent (os, indentG); - os << "}\n"; -#endif /* NDEBUG */ - - -} // Print - - -void GeneralNames::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - if (count) - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} // GeneralNames::SetCurrElmt - - -unsigned long int GeneralNames::GetCurrElmtIndex() -{ - unsigned long int i; - AsnListElmt *tmp; - if (curr != NULL) - { - for (i = 0, tmp = first; tmp != NULL; i++) - { - if (tmp == curr) - return i; - else - tmp = tmp->next; - } - } - return count; -} // GeneralNames::GetCurrElmtIndex - - -// alloc new list elmt, put at end of list -// and return the component type -GeneralName *GeneralNames::Append() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralName; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // GeneralNames::Append - - -// alloc new list elmt, put at begining of list -// and return the component type -GeneralName *GeneralNames::Prepend() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralName; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // GeneralNames::Prepend - - -// alloc new list elmt, insert it before the -// current element and return the component type -// if the current element is null, the new element -// is placed at the beginning of the list. -GeneralName *GeneralNames::InsertBefore() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralName; - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // GeneralNames::InsertBefore - - -// alloc new list elmt, insert it after the -// current element and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -GeneralName *GeneralNames::InsertAfter() -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralName; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return (curr = newElmt)->elmt; -} // GeneralNames::InsertAfter - - -GeneralNames &GeneralNames::AppendCopy (GeneralName &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralName; - *newElmt->elmt = elmt; - newElmt->next = NULL; - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - count++; - return *this; -} // AppendCopy - - -GeneralNames &GeneralNames::PrependCopy (GeneralName &elmt) -{ - AsnListElmt *newElmt; - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralName; - *newElmt->elmt = elmt; - newElmt->prev = NULL; - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - count++; - return *this; -} // GeneralNames::PrependCopy - - -// alloc new list elmt, insert it before the -// current element, copy the given elmt into the new elmt -// and return the component type. -// if the current element is null, the new element -// is placed at the beginning of the list. -GeneralNames &GeneralNames::InsertBeforeAndCopy (GeneralName &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralName; - *newElmt->elmt = elmt; - - if (curr == NULL) - { - newElmt->next = first; - newElmt->prev = NULL; - first = newElmt; - if (last == NULL) - last = newElmt; - } - else - { - newElmt->next = curr; - newElmt->prev = curr->prev; - curr->prev = newElmt; - if (curr == first) - first = newElmt; - else - newElmt->prev->next = newElmt; - } - count++; - return *this; -} // GeneralNames::InsertBeforeAndCopy - - -// alloc new list elmt, insert it after the -// current element, copy given elmt in to new elmt -// and return the component type -// if the current element is null, the new element -// is placed at the end of the list. -GeneralNames &GeneralNames::InsertAfterAndCopy (GeneralName &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - newElmt->elmt = new GeneralName; - *newElmt->elmt = elmt; - if (curr == NULL) - { - newElmt->prev = last; - newElmt->next = NULL; - last = newElmt; - if (first == NULL) - first = newElmt; - } - else - { - newElmt->prev = curr; - newElmt->next = curr->next; - curr->next = newElmt; - if (curr == last) - last = newElmt; - else - newElmt->next->prev = newElmt; - } - count++; - return *this; -} // GeneralNames::InsertAfterAndCopy - - -// remove current element from list if current element is not NULL -// The new current element will be the next element. -// If the current element is the last element in the list -// the second but last element will become the new current element. -void GeneralNames::RemoveCurrFromList() -{ - AsnListElmt *del_elmt; - - if (curr != NULL) - { - del_elmt = curr; - count--; - - if (count == 0) - first = last = curr = NULL; - else if (curr == first) - { - curr = first= first->next; - first->prev = NULL; - } - else if (curr == last) - { - curr = last = last->prev; - last->next = NULL; - } - else - { - curr->prev->next = curr->next; - curr->next->prev = curr->prev; - } - - delete del_elmt->elmt; - delete del_elmt; - } -} - - -AsnLen GeneralNames::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen elmtLen; - AsnLen totalLen = 0; - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - { - elmtLen = currElmt->elmt->BEncContent (b); - totalLen += elmtLen; - } - return totalLen; -} // GeneralNames::BEncContent - - -void GeneralNames::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -{ - GeneralName *listElmt; - AsnTag tag1; - AsnLen listBytesDecoded = 0; - AsnLen elmtLen1; - - while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN)) - { - tag1 = BDecTag (b, listBytesDecoded, env); - if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env); - break; - } - if (!((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)) - - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 2)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2)) - - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 3)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 4)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 5)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 6)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 6)) - - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 7)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 7)) - - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 8)))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(-105); - } - - elmtLen1 = BDecLen (b, listBytesDecoded, env); - listElmt = Append(); - listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env); - } - - bytesDecoded += listBytesDecoded; -} // GeneralNames::BDecContent - - diff --git a/SecurityASN1/c++/sm_x520sa.cpp b/SecurityASN1/c++/sm_x520sa.cpp deleted file mode 100644 index 2a1c1a78..00000000 --- a/SecurityASN1/c++/sm_x520sa.cpp +++ /dev/null @@ -1,304 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x520sa.cpp - class member functions for ASN.1 module SelectedAttributeTypes -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "sm_vdatypes.h" -#include "sm_x501ud.h" -#include "sm_x411ub.h" -#include "sm_x411mtsas.h" -#include "sm_x501if.h" -#include "sm_x520sa.h" -#include "sm_x509cmn.h" -#include "sm_x509af.h" -#include "sm_x509ce.h" -#include "pkcs1oids.h" -#include "pkcs9oids.h" -#include "sm_cms.h" -#include "sm_ess.h" -#include "pkcs7.h" -#include "pkcs8.h" -#include "appleoids.h" -#include "pkcs10.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -DirectoryString::DirectoryString() -{ - choiceId = teletexStringCid; -#if TCL - teletexString = new TeletexString; -#else - teletexString = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -DirectoryString::DirectoryString (const DirectoryString &) -{ - Asn1Error << "use of incompletely defined DirectoryString::DirectoryString (const DirectoryString &)" << endl; - abort(); -} - -DirectoryString::~DirectoryString() -{ - switch (choiceId) - { - case teletexStringCid: - delete teletexString; - break; - case printableStringCid: - delete printableString; - break; - case universalStringCid: - delete universalString; - break; - case bmpStringCid: - delete bmpString; - break; - case utf8StringCid: - delete utf8String; - break; - } // end of switch -} // end of destructor - -AsnType *DirectoryString::Clone() const -{ - return new DirectoryString; -} - -AsnType *DirectoryString::Copy() const -{ - return new DirectoryString (*this); -} - -#if SNACC_DEEP_COPY -DirectoryString &DirectoryString::operator = (const DirectoryString &that) -#else // SNACC_DEEP_COPY -DirectoryString &DirectoryString::operator = (const DirectoryString &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case teletexStringCid: - delete teletexString; - break; - case printableStringCid: - delete printableString; - break; - case universalStringCid: - delete universalString; - break; - case bmpStringCid: - delete bmpString; - break; - case utf8StringCid: - delete utf8String; - break; - } - switch (choiceId = that.choiceId) - { - case teletexStringCid: - teletexString = new TeletexString; - *teletexString = *that.teletexString; - break; - case printableStringCid: - printableString = new PrintableString; - *printableString = *that.printableString; - break; - case universalStringCid: - universalString = new UniversalString; - *universalString = *that.universalString; - break; - case bmpStringCid: - bmpString = new BMPString; - *bmpString = *that.bmpString; - break; - case utf8StringCid: - utf8String = new UTF8String; - *utf8String = *that.utf8String; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined DirectoryString &DirectoryString::operator = (const DirectoryString &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -DirectoryString::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case teletexStringCid: - l = teletexString->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - break; - - case printableStringCid: - l = printableString->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - break; - - case universalStringCid: - l = universalString->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, UNIVERSALSTRING_TAG_CODE); - break; - - case bmpStringCid: - l = bmpString->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BMPSTRING_TAG_CODE); - break; - - case utf8StringCid: - l = utf8String->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, 12); - break; - - } // end switch - return l; -} // DirectoryString::BEncContent - - -void DirectoryString::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - switch (tag) - { - case MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE): - choiceId = teletexStringCid; - teletexString = new TeletexString; - teletexString->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE): - choiceId = printableStringCid; - printableString = new PrintableString; - printableString->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE): - choiceId = universalStringCid; - universalString = new UniversalString; - universalString->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE): - case MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE): - choiceId = bmpStringCid; - bmpString = new BMPString; - bmpString->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (UNIV, PRIM, 12): - case MAKE_TAG_ID (UNIV, CONS, 12): - choiceId = utf8StringCid; - utf8String = new UTF8String; - utf8String->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(-100); - break; - } // end switch -} // DirectoryString::BDecContent - - -AsnLen DirectoryString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void DirectoryString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void DirectoryString::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case teletexStringCid: - os << "teletexString "; - if (teletexString) - os << *teletexString; - else - os << "-- void3 --\n"; - break; - - case printableStringCid: - os << "printableString "; - if (printableString) - os << *printableString; - else - os << "-- void3 --\n"; - break; - - case universalStringCid: - os << "universalString "; - if (universalString) - os << *universalString; - else - os << "-- void3 --\n"; - break; - - case bmpStringCid: - os << "bmpString "; - if (bmpString) - os << *bmpString; - else - os << "-- void3 --\n"; - break; - - case utf8StringCid: - os << "utf8String "; - if (utf8String) - os << *utf8String; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // DirectoryString::Print - diff --git a/SecurityASN1/inc/.cvsignore b/SecurityASN1/inc/.cvsignore deleted file mode 100644 index e69de29b..00000000 diff --git a/SecurityASN1/inc/appleoids.h b/SecurityASN1/inc/appleoids.h deleted file mode 100644 index 9f96e215..00000000 --- a/SecurityASN1/inc/appleoids.h +++ /dev/null @@ -1,471 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// appleoids.h - class definitions for ASN.1 module APPLE-OIDS -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _appleoids_h_ -#define _appleoids_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class FEEPrimeType; -class FEECurveType; -class DSABsafeParams; -class DHParameter; -class FEECurveParameters; -class DSAAlgorithmId; -class FEEElGamalSignature; -class FEEECDSASignature; -class FEEPublicKey; -class FEEPrivateKey; -class DSAPrivateKey; -class DSAPublicKey; -class DSAPrivateKeyOcts; -class DSASignature; -class DSAAlgParams; -class DHPrivateKey; -class DHParameterBlock; - -//------------------------------------------------------------------------------ -// class definitions: - -/* INTEGER { pt_mersenne (0), pt_fee (1), pt_general (2) } */ -class FEEPrimeType: public AsnInt -{ -public: - FEEPrimeType(): AsnInt() {} - FEEPrimeType (int i): AsnInt (i) {} - enum - { - pt_mersenne = 0, - pt_fee = 1, - pt_general = 2 - }; -}; - - -/* INTEGER { ct_montgomery (0), ct_weierstrass (1), ct_general (2) } */ -class FEECurveType: public AsnInt -{ -public: - FEECurveType(): AsnInt() {} - FEECurveType (int i): AsnInt (i) {} - enum - { - ct_montgomery = 0, - ct_weierstrass = 1, - ct_general = 2 - }; -}; - - -class DSABsafeParams: public AsnType -{ -public: - AsnInt keySizeInBits; - BigIntegerStr p; - BigIntegerStr q; - BigIntegerStr g; - - DSABsafeParams(); - DSABsafeParams (const DSABsafeParams &); - virtual ~DSABsafeParams(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DSABsafeParams &operator = (const DSABsafeParams &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DHParameter: public AsnType -{ -public: - BigIntegerStr prime; - BigIntegerStr base; - BigIntegerStr *privateValueLength; - - DHParameter(); - DHParameter (const DHParameter &); - virtual ~DHParameter(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DHParameter &operator = (const DHParameter &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class FEECurveParameters: public AsnType -{ -public: - FEEPrimeType primeType; - FEECurveType curveType; - AsnInt q; - AsnInt k; - AsnInt m; - BigIntegerStr a; - BigIntegerStr bb; - BigIntegerStr c; - BigIntegerStr x1Plus; - BigIntegerStr x1Minus; - BigIntegerStr cOrderPlus; - BigIntegerStr cOrderMinus; - BigIntegerStr x1OrderPlus; - BigIntegerStr x1OrderMinus; - BigIntegerStr *basePrime; - - FEECurveParameters(); - FEECurveParameters (const FEECurveParameters &); - virtual ~FEECurveParameters(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - FEECurveParameters &operator = (const FEECurveParameters &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DSAAlgorithmId: public AsnType -{ -public: - AsnOid algorithm; - DSABsafeParams *params; - - DSAAlgorithmId(); - DSAAlgorithmId (const DSAAlgorithmId &); - virtual ~DSAAlgorithmId(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DSAAlgorithmId &operator = (const DSAAlgorithmId &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class FEEElGamalSignature: public AsnType -{ -public: - BigIntegerStr u; - BigIntegerStr pmX; - - FEEElGamalSignature(); - FEEElGamalSignature (const FEEElGamalSignature &); - virtual ~FEEElGamalSignature(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - FEEElGamalSignature &operator = (const FEEElGamalSignature &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class FEEECDSASignature: public AsnType -{ -public: - BigIntegerStr c; - BigIntegerStr d; - - FEEECDSASignature(); - FEEECDSASignature (const FEEECDSASignature &); - virtual ~FEEECDSASignature(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - FEEECDSASignature &operator = (const FEEECDSASignature &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class FEEPublicKey: public AsnType -{ -public: - AsnInt version; - FEECurveParameters *curveParams; - BigIntegerStr plusX; - BigIntegerStr minusX; - BigIntegerStr *plusY; - - FEEPublicKey(); - FEEPublicKey (const FEEPublicKey &); - virtual ~FEEPublicKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - FEEPublicKey &operator = (const FEEPublicKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class FEEPrivateKey: public AsnType -{ -public: - AsnInt version; - FEECurveParameters *curveParams; - BigIntegerStr privData; - - FEEPrivateKey(); - FEEPrivateKey (const FEEPrivateKey &); - virtual ~FEEPrivateKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - FEEPrivateKey &operator = (const FEEPrivateKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DSAPrivateKey: public AsnType -{ -public: - AsnInt version; - DSAAlgorithmId *dsaAlg; - AsnOcts privateKey; - - DSAPrivateKey(); - DSAPrivateKey (const DSAPrivateKey &); - virtual ~DSAPrivateKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DSAPrivateKey &operator = (const DSAPrivateKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DSAPublicKey: public AsnType -{ -public: - DSAAlgorithmId *dsaAlg; - AsnBits publicKey; - - DSAPublicKey(); - DSAPublicKey (const DSAPublicKey &); - virtual ~DSAPublicKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DSAPublicKey &operator = (const DSAPublicKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DSAPrivateKeyOcts: public AsnType -{ -public: - BigIntegerStr privateKey; - - DSAPrivateKeyOcts(); - DSAPrivateKeyOcts (const DSAPrivateKeyOcts &); - virtual ~DSAPrivateKeyOcts(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DSAPrivateKeyOcts &operator = (const DSAPrivateKeyOcts &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DSASignature: public AsnType -{ -public: - BigIntegerStr r; - BigIntegerStr s; - - DSASignature(); - DSASignature (const DSASignature &); - virtual ~DSASignature(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DSASignature &operator = (const DSASignature &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DSAAlgParams: public AsnType -{ -public: - BigIntegerStr p; - BigIntegerStr q; - BigIntegerStr g; - - DSAAlgParams(); - DSAAlgParams (const DSAAlgParams &); - virtual ~DSAAlgParams(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DSAAlgParams &operator = (const DSAAlgParams &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DHPrivateKey: public AsnType -{ -public: - AsnOid dHOid; - DHParameter *params; - BigIntegerStr secretPart; - - DHPrivateKey(); - DHPrivateKey (const DHPrivateKey &); - virtual ~DHPrivateKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DHPrivateKey &operator = (const DHPrivateKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DHParameterBlock: public AsnType -{ -public: - AsnOid oid; - DHParameter *params; - - DHParameterBlock(); - DHParameterBlock (const DHParameterBlock &); - virtual ~DHParameterBlock(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DHParameterBlock &operator = (const DHParameterBlock &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -#define appleBaseOid_arc 1, 2, 840, 113635 -#define appleBaseOid AsnOid(appleBaseOid_arc) -#define appleDataSecurity_arc 1, 2, 840, 113635, 100 -#define appleDataSecurity AsnOid(appleDataSecurity_arc) -#define appleTrustPolicy_arc 1, 2, 840, 113635, 100, 1 -#define appleTrustPolicy AsnOid(appleTrustPolicy_arc) -#define appleSecurityAlgorithm_arc 1, 2, 840, 113635, 100, 2 -#define appleSecurityAlgorithm AsnOid(appleSecurityAlgorithm_arc) -#define appleISignTP_arc 1, 2, 840, 113635, 100, 1, 1 -#define appleISignTP AsnOid(appleISignTP_arc) -#define appleX509Basic_arc 1, 2, 840, 113635, 100, 1, 2 -#define appleX509Basic AsnOid(appleX509Basic_arc) -#define appleSSLPolicy_arc 1, 2, 840, 113635, 100, 1, 3 -#define appleSSLPolicy AsnOid(appleSSLPolicy_arc) -#define appleFee_arc 1, 2, 840, 113635, 100, 2, 1 -#define appleFee AsnOid(appleFee_arc) -#define appleAsc_arc 1, 2, 840, 113635, 100, 2, 2 -#define appleAsc AsnOid(appleAsc_arc) -#define appleFeeMD5_arc 1, 2, 840, 113635, 100, 2, 3 -#define appleFeeMD5 AsnOid(appleFeeMD5_arc) -#define appleFeeSHA1_arc 1, 2, 840, 113635, 100, 2, 4 -#define appleFeeSHA1 AsnOid(appleFeeSHA1_arc) -#define appleFeed_arc 1, 2, 840, 113635, 100, 2, 5 -#define appleFeed AsnOid(appleFeed_arc) -#define appleFeedExp_arc 1, 2, 840, 113635, 100, 2, 6 -#define appleFeedExp AsnOid(appleFeedExp_arc) -#define appleECDSA_arc 1, 2, 840, 113635, 100, 2, 7 -#define appleECDSA AsnOid(appleECDSA_arc) -#define pkcs_3_arc 1, 2, 840, 113549, 1, 3 -#define pkcs_3 AsnOid(pkcs_3_arc) -#define dhKeyAgreement_arc 1, 2, 840, 113549, 1, 3, 1 -#define dhKeyAgreement AsnOid(dhKeyAgreement_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of appleoids.h */ diff --git a/SecurityASN1/inc/pkcs10.h b/SecurityASN1/inc/pkcs10.h deleted file mode 100644 index 01093ca3..00000000 --- a/SecurityASN1/inc/pkcs10.h +++ /dev/null @@ -1,110 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs10.h - class definitions for ASN.1 module PKCS5 -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _pkcs10_h_ -#define _pkcs10_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class CertificationRequestInfo; -class CertificationRequest; -class CertificationRequestSigned; - -//------------------------------------------------------------------------------ -// class definitions: - -typedef enum PKCS5AnyId -{ - -} PKCS5AnyId; - - -/* INTEGER */ -typedef AsnInt VersionP10; - -class CertificationRequestInfo: public AsnType -{ -public: - VersionP10 version; - Name *subject; - SubjectPublicKeyInfo *subjectPublicKeyInfo; - Attributes attributes; - - CertificationRequestInfo(); - CertificationRequestInfo (const CertificationRequestInfo &); - virtual ~CertificationRequestInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificationRequestInfo &operator = (const CertificationRequestInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertificationRequest: public AsnType -{ -public: - CertificationRequestInfo *certificationRequestInfo; - SignatureAlgorithmIdentifier *signatureAlgorithm; - Signature signature; - - CertificationRequest(); - CertificationRequest (const CertificationRequest &); - virtual ~CertificationRequest(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificationRequest &operator = (const CertificationRequest &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertificationRequestSigned: public AsnType -{ -public: - AsnAny certificationRequestInfo; - SignatureAlgorithmIdentifier *signatureAlgorithm; - Signature signature; - - CertificationRequestSigned(); - CertificationRequestSigned (const CertificationRequestSigned &); - virtual ~CertificationRequestSigned(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificationRequestSigned &operator = (const CertificationRequestSigned &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -//------------------------------------------------------------------------------ - -#endif /* conditional include of pkcs10.h */ diff --git a/SecurityASN1/inc/pkcs1oids.h b/SecurityASN1/inc/pkcs1oids.h deleted file mode 100644 index 7c56584a..00000000 --- a/SecurityASN1/inc/pkcs1oids.h +++ /dev/null @@ -1,104 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs1oids.h - class definitions for ASN.1 module PKCS1-OIDS -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _pkcs1oids_h_ -#define _pkcs1oids_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class RSAPublicKey; -class RSAPrivateKey; - -//------------------------------------------------------------------------------ -// class definitions: - -class RSAPublicKey: public AsnType -{ -public: - BigIntegerStr modulus; - BigIntegerStr publicExponent; - - RSAPublicKey(); - RSAPublicKey (const RSAPublicKey &); - virtual ~RSAPublicKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RSAPublicKey &operator = (const RSAPublicKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class RSAPrivateKey: public AsnType -{ -public: - AsnInt version; - BigIntegerStr modulus; - BigIntegerStr publicExponent; - BigIntegerStr privateExponent; - BigIntegerStr prime1; - BigIntegerStr prime2; - BigIntegerStr exponent1; - BigIntegerStr exponent2; - BigIntegerStr coefficient; - - RSAPrivateKey(); - RSAPrivateKey (const RSAPrivateKey &); - virtual ~RSAPrivateKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RSAPrivateKey &operator = (const RSAPrivateKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -#define rsadsi_arc 1, 2, 840, 113549 -#define rsadsi AsnOid(rsadsi_arc) -#define pkcs_arc 1, 2, 840, 113549, 1 -#define pkcs AsnOid(pkcs_arc) -#define pkcs_1_arc 1, 2, 840, 113549, 1, 1 -#define pkcs_1 AsnOid(pkcs_1_arc) -#define rsaEncryption_arc 1, 2, 840, 113549, 1, 1, 1 -#define rsaEncryption AsnOid(rsaEncryption_arc) -#define md2WithRSAEncryption_arc 1, 2, 840, 113549, 1, 1, 2 -#define md2WithRSAEncryption AsnOid(md2WithRSAEncryption_arc) -#define md4WithRSAEncryption_arc 1, 2, 840, 113549, 1, 1, 3 -#define md4WithRSAEncryption AsnOid(md4WithRSAEncryption_arc) -#define md5WithRSAEncryption_arc 1, 2, 840, 113549, 1, 1, 4 -#define md5WithRSAEncryption AsnOid(md5WithRSAEncryption_arc) -#define sha1withRSAEncryption_arc 1, 2, 840, 113549, 1, 1, 5 -#define sha1withRSAEncryption AsnOid(sha1withRSAEncryption_arc) -#define rsaDigestAlgorithm_arc 1, 2, 840, 113549, 2 -#define rsaDigestAlgorithm AsnOid(rsaDigestAlgorithm_arc) -#define md2_arc 1, 2, 840, 113549, 2, 2 -#define md2 AsnOid(md2_arc) -#define md4_arc 1, 2, 840, 113549, 2, 4 -#define md4 AsnOid(md4_arc) -#define md5_arc 1, 2, 840, 113549, 2, 5 -#define md5 AsnOid(md5_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of pkcs1oids.h */ diff --git a/SecurityASN1/inc/pkcs7.h b/SecurityASN1/inc/pkcs7.h deleted file mode 100644 index 3aedd6c6..00000000 --- a/SecurityASN1/inc/pkcs7.h +++ /dev/null @@ -1,111 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs7.h - class definitions for ASN.1 module PKCS7 -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _pkcs7_h_ -#define _pkcs7_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class EncryptedDataInt; -class EncryptedContentInfo1; -class EncryptedData1; - -//------------------------------------------------------------------------------ -// class definitions: - -/* INTEGER { edVer0 (0) } */ -class EncryptedDataInt: public AsnInt -{ -public: - EncryptedDataInt(): AsnInt() {} - EncryptedDataInt (int i): AsnInt (i) {} - enum - { - edVer0 = 0 - }; -}; - - -/* OBJECT IDENTIFIER */ -typedef AsnOid ContentType1; - -/* OCTET STRING */ -typedef AsnOcts EncryptedContent1; - -/* AlgorithmIdentifier */ -typedef AlgorithmIdentifier ContentEncryptionAlgorithmIdentifier1; - -class EncryptedContentInfo1: public AsnType -{ -public: - ContentType1 contentType; - ContentEncryptionAlgorithmIdentifier1 *contentEncryptionAlgorithm; - EncryptedContent1 *encryptedContent; - - EncryptedContentInfo1(); - EncryptedContentInfo1 (const EncryptedContentInfo1 &); - virtual ~EncryptedContentInfo1(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EncryptedContentInfo1 &operator = (const EncryptedContentInfo1 &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class EncryptedData1: public AsnType -{ -public: - EncryptedDataInt version; - EncryptedContentInfo1 *encryptedContentInfo; - - EncryptedData1(); - EncryptedData1 (const EncryptedData1 &); - virtual ~EncryptedData1(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EncryptedData1 &operator = (const EncryptedData1 &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -#define pkcs_7_arc 1, 2, 840, 113549, 1, 7 -#define pkcs_7 AsnOid(pkcs_7_arc) -#define dataPkcs7_arc 1, 2, 840, 113549, 1, 7, 1 -#define dataPkcs7 AsnOid(dataPkcs7_arc) -#define signedData_arc 1, 2, 840, 113549, 1, 7, 2 -#define signedData AsnOid(signedData_arc) -#define envelopedData_arc 1, 2, 840, 113549, 1, 7, 3 -#define envelopedData AsnOid(envelopedData_arc) -#define signedAndEnvelopedData_arc 1, 2, 840, 113549, 1, 7, 4 -#define signedAndEnvelopedData AsnOid(signedAndEnvelopedData_arc) -#define digestedData_arc 1, 2, 840, 113549, 1, 7, 5 -#define digestedData AsnOid(digestedData_arc) -#define encryptedData_arc 1, 2, 840, 113549, 1, 7, 6 -#define encryptedData AsnOid(encryptedData_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of pkcs7.h */ diff --git a/SecurityASN1/inc/pkcs8.h b/SecurityASN1/inc/pkcs8.h deleted file mode 100644 index dd9bd68e..00000000 --- a/SecurityASN1/inc/pkcs8.h +++ /dev/null @@ -1,78 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs8.h - class definitions for ASN.1 module PrivateKeyInformationSyntax -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _pkcs8_h_ -#define _pkcs8_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class PrivateKeyInfo; -class EncryptedPrivateKeyInfo; - -//------------------------------------------------------------------------------ -// class definitions: - -/* OCTET STRING */ -typedef AsnOcts PrivateKey; - -class PrivateKeyInfo: public AsnType -{ -public: - AsnInt version; - AlgorithmIdentifier *privateKeyAlgorithm; - PrivateKey privateKey; - Attributes *attributes; - - PrivateKeyInfo(); - PrivateKeyInfo (const PrivateKeyInfo &); - virtual ~PrivateKeyInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PrivateKeyInfo &operator = (const PrivateKeyInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class EncryptedPrivateKeyInfo: public AsnType -{ -public: - AlgorithmIdentifier *encryptionAlgorithm; - EncryptedKey encryptedKey; - - EncryptedPrivateKeyInfo(); - EncryptedPrivateKeyInfo (const EncryptedPrivateKeyInfo &); - virtual ~EncryptedPrivateKeyInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EncryptedPrivateKeyInfo &operator = (const EncryptedPrivateKeyInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -//------------------------------------------------------------------------------ - -#endif /* conditional include of pkcs8.h */ diff --git a/SecurityASN1/inc/pkcs9oids.h b/SecurityASN1/inc/pkcs9oids.h deleted file mode 100644 index c3f72cf8..00000000 --- a/SecurityASN1/inc/pkcs9oids.h +++ /dev/null @@ -1,45 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// pkcs9oids.h - class definitions for ASN.1 module PKCS9-OIDS -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _pkcs9oids_h_ -#define _pkcs9oids_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - - -//------------------------------------------------------------------------------ -// class definitions: - -//------------------------------------------------------------------------------ -// externs for value defs - -#define pkcs_9_arc 1, 2, 840, 113549, 1, 9 -#define pkcs_9 AsnOid(pkcs_9_arc) -#define emailAddress_arc 1, 2, 840, 113549, 1, 9, 1 -#define emailAddress AsnOid(emailAddress_arc) -#define unstructuredName_arc 1, 2, 840, 113549, 1, 9, 2 -#define unstructuredName AsnOid(unstructuredName_arc) -#define contentTypePkcs9_arc 1, 2, 840, 113549, 1, 9, 3 -#define contentTypePkcs9 AsnOid(contentTypePkcs9_arc) -#define messageDigest_arc 1, 2, 840, 113549, 1, 9, 4 -#define messageDigest AsnOid(messageDigest_arc) -#define signingTime_arc 1, 2, 840, 113549, 1, 9, 5 -#define signingTime AsnOid(signingTime_arc) -#define countersignature_arc 1, 2, 840, 113549, 1, 9, 6 -#define countersignature AsnOid(countersignature_arc) -#define challengePassword_arc 1, 2, 840, 113549, 1, 9, 7 -#define challengePassword AsnOid(challengePassword_arc) -#define unstructuredAddress_arc 1, 2, 840, 113549, 1, 9, 8 -#define unstructuredAddress AsnOid(unstructuredAddress_arc) -#define extendedCertificateAttributes_arc 1, 2, 840, 113549, 1, 9, 9 -#define extendedCertificateAttributes AsnOid(extendedCertificateAttributes_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of pkcs9oids.h */ diff --git a/SecurityASN1/inc/sm_cms.h b/SecurityASN1/inc/sm_cms.h deleted file mode 100644 index dbc362f1..00000000 --- a/SecurityASN1/inc/sm_cms.h +++ /dev/null @@ -1,1454 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_cms.h - class definitions for ASN.1 module CryptographicMessageSyntax -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_cms_h_ -#define _sm_cms_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class CMSVersion; -class OriginatorPublicKey; -class CertificateRevocationLists; -class IssuerAndSerialNumber; -class OtherKeyAttribute; -class DigestAlgorithmIdentifiers; -class EncapsulatedContentInfo; -class SignerIdentifier; -class EncryptedContentInfo; -class RecipientIdentifier; -class OriginatorIdentifierOrKey; -class RecipientKeyIdentifier; -class KEKIdentifier; -class ExtendedCertificateInfo; -class SignerInfo; -class KeyTransRecipientInfo; -class KeyAgreeRecipientIdentifier; -class KEKRecipientInfo; -class ExtendedCertificate; -class SignerInfos; -class RecipientEncryptedKey; -class CertificateChoices; -class CertificateSet; -class OriginatorInfo; -class RecipientEncryptedKeys; -class KeyAgreeRecipientInfo; -class RecipientInfo; -class RecipientInfos; -class ContentInfo; -class SignedData; -class EnvelopedData; -class DigestedData; -class EncryptedData; -class AuthenticatedData; -class UserKeyingMaterials; -class RC2CBCParameter; -class ExtendedCertificateOrCertificate; -class DigestInfo; - -//------------------------------------------------------------------------------ -// class definitions: - -typedef enum CryptographicMessageSyntaxAnyId -{ - -} CryptographicMessageSyntaxAnyId; - - -/* OBJECT IDENTIFIER */ -typedef AsnOid ContentType; - -/* OCTET STRING */ -typedef AsnOcts SignatureValue; - -/* OCTET STRING */ -typedef AsnOcts EncryptedContent; - -/* OCTET STRING */ -typedef AsnOcts EncryptedKey; - -/* OCTET STRING */ -typedef AsnOcts Digest; - -/* OCTET STRING */ -typedef AsnOcts MessageAuthenticationCode; - -/* INTEGER { v0 (0), v1 (1), v2 (2), v3 (3), v4 (4) } */ -class CMSVersion: public AsnInt -{ -public: - CMSVersion(): AsnInt() {} - CMSVersion (int i): AsnInt (i) {} - enum - { - v0 = 0, - v1 = 1, - v2 = 2, - v3 = 3, - v4 = 4 - }; -}; - - -/* OCTET STRING */ -typedef AsnOcts UserKeyingMaterial; - -/* OCTET STRING */ -typedef AsnOcts MessageDigest; - -/* INTEGER */ -typedef AsnInt RC2ParameterVersion; - -/* OCTET STRING */ -typedef AsnOcts IV; - -/* BIT STRING */ -typedef AsnBits Signature; - -class OriginatorPublicKey: public AsnType -{ -public: - AlgorithmIdentifier *algorithm; - AsnBits publicKey; - - OriginatorPublicKey(); - OriginatorPublicKey (const OriginatorPublicKey &); - virtual ~OriginatorPublicKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - OriginatorPublicKey &operator = (const OriginatorPublicKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* AlgorithmIdentifier */ -typedef AlgorithmIdentifier DigestAlgorithmIdentifier; - -/* AlgorithmIdentifier */ -typedef AlgorithmIdentifier SignatureAlgorithmIdentifier; - -/* AlgorithmIdentifier */ -typedef AlgorithmIdentifier KeyEncryptionAlgorithmIdentifier; - -/* AlgorithmIdentifier */ -typedef AlgorithmIdentifier ContentEncryptionAlgorithmIdentifier; - -/* AlgorithmIdentifier */ -typedef AlgorithmIdentifier MessageAuthenticationCodeAlgorithm; - -class CertificateRevocationLists: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - CertificateList *elmt; - } *first, *curr, *last; - -public: - CertificateRevocationLists() { count = 0; first = curr = last = NULL; } - CertificateRevocationLists (const CertificateRevocationLists &); - virtual ~CertificateRevocationLists(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificateRevocationLists &operator = (const CertificateRevocationLists &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - CertificateList *First() const { return count > 0 ? first->elmt : NULL; } - CertificateList *Last() const { return count > 0 ? last->elmt : NULL; } - CertificateList *Curr() const { return curr ? curr->elmt : NULL; } - CertificateList *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - CertificateList *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - CertificateList *GoNext() { if (curr) curr = curr->next; return Curr(); } - CertificateList *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - CertificateList *Append(); // add elmt to end of list - CertificateList *Prepend(); // add elmt to beginning of list - CertificateList *InsertBefore(); //insert elmt before current elmt - CertificateList *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - CertificateRevocationLists &AppendCopy (CertificateList &elmt); // add elmt to end of list - CertificateRevocationLists &PrependCopy (CertificateList &elmt); // add elmt to beginning of list - CertificateRevocationLists &InsertBeforeAndCopy (CertificateList &elmt); //insert elmt before current elmt - CertificateRevocationLists &InsertAfterAndCopy (CertificateList &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class IssuerAndSerialNumber: public AsnType -{ -public: - Name *issuer; - CertificateSerialNumber serialNumber; - - IssuerAndSerialNumber(); - IssuerAndSerialNumber (const IssuerAndSerialNumber &); - virtual ~IssuerAndSerialNumber(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - IssuerAndSerialNumber &operator = (const IssuerAndSerialNumber &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class OtherKeyAttribute: public AsnType -{ -public: - AsnOid keyAttrId; - AsnAny *keyAttr; - - OtherKeyAttribute(); - OtherKeyAttribute (const OtherKeyAttribute &); - virtual ~OtherKeyAttribute(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - OtherKeyAttribute &operator = (const OtherKeyAttribute &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DigestAlgorithmIdentifiers: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - DigestAlgorithmIdentifier *elmt; - } *first, *curr, *last; - -public: - DigestAlgorithmIdentifiers() { count = 0; first = curr = last = NULL; } - DigestAlgorithmIdentifiers (const DigestAlgorithmIdentifiers &); - virtual ~DigestAlgorithmIdentifiers(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DigestAlgorithmIdentifiers &operator = (const DigestAlgorithmIdentifiers &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - DigestAlgorithmIdentifier *First() const { return count > 0 ? first->elmt : NULL; } - DigestAlgorithmIdentifier *Last() const { return count > 0 ? last->elmt : NULL; } - DigestAlgorithmIdentifier *Curr() const { return curr ? curr->elmt : NULL; } - DigestAlgorithmIdentifier *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - DigestAlgorithmIdentifier *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - DigestAlgorithmIdentifier *GoNext() { if (curr) curr = curr->next; return Curr(); } - DigestAlgorithmIdentifier *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - DigestAlgorithmIdentifier *Append(); // add elmt to end of list - DigestAlgorithmIdentifier *Prepend(); // add elmt to beginning of list - DigestAlgorithmIdentifier *InsertBefore(); //insert elmt before current elmt - DigestAlgorithmIdentifier *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - DigestAlgorithmIdentifiers &AppendCopy (DigestAlgorithmIdentifier &elmt); // add elmt to end of list - DigestAlgorithmIdentifiers &PrependCopy (DigestAlgorithmIdentifier &elmt); // add elmt to beginning of list - DigestAlgorithmIdentifiers &InsertBeforeAndCopy (DigestAlgorithmIdentifier &elmt); //insert elmt before current elmt - DigestAlgorithmIdentifiers &InsertAfterAndCopy (DigestAlgorithmIdentifier &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class EncapsulatedContentInfo: public AsnType -{ -public: - ContentType eContentType; - AsnOcts *eContent; - - EncapsulatedContentInfo(); - EncapsulatedContentInfo (const EncapsulatedContentInfo &); - virtual ~EncapsulatedContentInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EncapsulatedContentInfo &operator = (const EncapsulatedContentInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class SignerIdentifier: public AsnType -{ -public: - enum ChoiceIdEnum - { - issuerAndSerialNumberCid = 0, - subjectKeyIdentifierCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - IssuerAndSerialNumber *issuerAndSerialNumber; - KeyIdentifier *subjectKeyIdentifier; - }; - - - SignerIdentifier(); - SignerIdentifier (const SignerIdentifier &); - virtual ~SignerIdentifier(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SignerIdentifier &operator = (const SignerIdentifier &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class EncryptedContentInfo: public AsnType -{ -public: - ContentType contentType; - ContentEncryptionAlgorithmIdentifier *contentEncryptionAlgorithm; - EncryptedContent *encryptedContent; - - EncryptedContentInfo(); - EncryptedContentInfo (const EncryptedContentInfo &); - virtual ~EncryptedContentInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EncryptedContentInfo &operator = (const EncryptedContentInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class RecipientIdentifier: public AsnType -{ -public: - enum ChoiceIdEnum - { - issuerAndSerialNumberCid = 0, - subjectKeyIdentifierCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - IssuerAndSerialNumber *issuerAndSerialNumber; - KeyIdentifier *subjectKeyIdentifier; - }; - - - RecipientIdentifier(); - RecipientIdentifier (const RecipientIdentifier &); - virtual ~RecipientIdentifier(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RecipientIdentifier &operator = (const RecipientIdentifier &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class OriginatorIdentifierOrKey: public AsnType -{ -public: - enum ChoiceIdEnum - { - issuerAndSerialNumberCid = 0, - subjectKeyIdentifierCid = 1, - originatorKeyCid = 2 - }; - - enum ChoiceIdEnum choiceId; - union - { - IssuerAndSerialNumber *issuerAndSerialNumber; - KeyIdentifier *subjectKeyIdentifier; - OriginatorPublicKey *originatorKey; - }; - - - OriginatorIdentifierOrKey(); - OriginatorIdentifierOrKey (const OriginatorIdentifierOrKey &); - virtual ~OriginatorIdentifierOrKey(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - OriginatorIdentifierOrKey &operator = (const OriginatorIdentifierOrKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class RecipientKeyIdentifier: public AsnType -{ -public: - KeyIdentifier subjectKeyIdentifier; - GeneralizedTime *date; - OtherKeyAttribute *other; - - RecipientKeyIdentifier(); - RecipientKeyIdentifier (const RecipientKeyIdentifier &); - virtual ~RecipientKeyIdentifier(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RecipientKeyIdentifier &operator = (const RecipientKeyIdentifier &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class KEKIdentifier: public AsnType -{ -public: - AsnOcts keyIdentifier; - GeneralizedTime *date; - OtherKeyAttribute *other; - - KEKIdentifier(); - KEKIdentifier (const KEKIdentifier &); - virtual ~KEKIdentifier(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - KEKIdentifier &operator = (const KEKIdentifier &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ExtendedCertificateInfo: public AsnType -{ -public: - CMSVersion version; - Certificate *certificate; - Attributes attributes; - - ExtendedCertificateInfo(); - ExtendedCertificateInfo (const ExtendedCertificateInfo &); - virtual ~ExtendedCertificateInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ExtendedCertificateInfo &operator = (const ExtendedCertificateInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class SignerInfo: public AsnType -{ -public: - CMSVersion version; - SignerIdentifier *sid; - DigestAlgorithmIdentifier *digestAlgorithm; - Attributes *signedAttrs; - SignatureAlgorithmIdentifier *signatureAlgorithm; - SignatureValue signature; - Attributes *unsignedAttrs; - - SignerInfo(); - SignerInfo (const SignerInfo &); - virtual ~SignerInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SignerInfo &operator = (const SignerInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class KeyTransRecipientInfo: public AsnType -{ -public: - CMSVersion version; - RecipientIdentifier *rid; - KeyEncryptionAlgorithmIdentifier *keyEncryptionAlgorithm; - EncryptedKey encryptedKey; - - KeyTransRecipientInfo(); - KeyTransRecipientInfo (const KeyTransRecipientInfo &); - virtual ~KeyTransRecipientInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - KeyTransRecipientInfo &operator = (const KeyTransRecipientInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class KeyAgreeRecipientIdentifier: public AsnType -{ -public: - enum ChoiceIdEnum - { - issuerAndSerialNumberCid = 0, - rKeyIdCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - IssuerAndSerialNumber *issuerAndSerialNumber; - RecipientKeyIdentifier *rKeyId; - }; - - - KeyAgreeRecipientIdentifier(); - KeyAgreeRecipientIdentifier (const KeyAgreeRecipientIdentifier &); - virtual ~KeyAgreeRecipientIdentifier(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - KeyAgreeRecipientIdentifier &operator = (const KeyAgreeRecipientIdentifier &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class KEKRecipientInfo: public AsnType -{ -public: - CMSVersion version; - KEKIdentifier *kekid; - KeyEncryptionAlgorithmIdentifier *keyEncryptionAlgorithm; - EncryptedKey encryptedKey; - - KEKRecipientInfo(); - KEKRecipientInfo (const KEKRecipientInfo &); - virtual ~KEKRecipientInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - KEKRecipientInfo &operator = (const KEKRecipientInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ExtendedCertificate: public AsnType -{ -public: - ExtendedCertificateInfo *extendedCertificateInfo; - SignatureAlgorithmIdentifier *signatureAlgorithm; - Signature signature; - - ExtendedCertificate(); - ExtendedCertificate (const ExtendedCertificate &); - virtual ~ExtendedCertificate(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ExtendedCertificate &operator = (const ExtendedCertificate &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class SignerInfos: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - SignerInfo *elmt; - } *first, *curr, *last; - -public: - SignerInfos() { count = 0; first = curr = last = NULL; } - SignerInfos (const SignerInfos &); - virtual ~SignerInfos(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SignerInfos &operator = (const SignerInfos &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - SignerInfo *First() const { return count > 0 ? first->elmt : NULL; } - SignerInfo *Last() const { return count > 0 ? last->elmt : NULL; } - SignerInfo *Curr() const { return curr ? curr->elmt : NULL; } - SignerInfo *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - SignerInfo *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - SignerInfo *GoNext() { if (curr) curr = curr->next; return Curr(); } - SignerInfo *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - SignerInfo *Append(); // add elmt to end of list - SignerInfo *Prepend(); // add elmt to beginning of list - SignerInfo *InsertBefore(); //insert elmt before current elmt - SignerInfo *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - SignerInfos &AppendCopy (SignerInfo &elmt); // add elmt to end of list - SignerInfos &PrependCopy (SignerInfo &elmt); // add elmt to beginning of list - SignerInfos &InsertBeforeAndCopy (SignerInfo &elmt); //insert elmt before current elmt - SignerInfos &InsertAfterAndCopy (SignerInfo &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class RecipientEncryptedKey: public AsnType -{ -public: - KeyAgreeRecipientIdentifier *rid; - EncryptedKey encryptedKey; - - RecipientEncryptedKey(); - RecipientEncryptedKey (const RecipientEncryptedKey &); - virtual ~RecipientEncryptedKey(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RecipientEncryptedKey &operator = (const RecipientEncryptedKey &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertificateChoices: public AsnType -{ -public: - enum ChoiceIdEnum - { - certificateCid = 0, - extendedCertificateCid = 1, - attrCertCid = 2 - }; - - enum ChoiceIdEnum choiceId; - union - { - Certificate *certificate; - ExtendedCertificate *extendedCertificate; - AttributeCertificate *attrCert; - }; - - - CertificateChoices(); - CertificateChoices (const CertificateChoices &); - virtual ~CertificateChoices(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificateChoices &operator = (const CertificateChoices &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertificateSet: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - CertificateChoices *elmt; - } *first, *curr, *last; - -public: - CertificateSet() { count = 0; first = curr = last = NULL; } - CertificateSet (const CertificateSet &); - virtual ~CertificateSet(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificateSet &operator = (const CertificateSet &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - CertificateChoices *First() const { return count > 0 ? first->elmt : NULL; } - CertificateChoices *Last() const { return count > 0 ? last->elmt : NULL; } - CertificateChoices *Curr() const { return curr ? curr->elmt : NULL; } - CertificateChoices *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - CertificateChoices *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - CertificateChoices *GoNext() { if (curr) curr = curr->next; return Curr(); } - CertificateChoices *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - CertificateChoices *Append(); // add elmt to end of list - CertificateChoices *Prepend(); // add elmt to beginning of list - CertificateChoices *InsertBefore(); //insert elmt before current elmt - CertificateChoices *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - CertificateSet &AppendCopy (CertificateChoices &elmt); // add elmt to end of list - CertificateSet &PrependCopy (CertificateChoices &elmt); // add elmt to beginning of list - CertificateSet &InsertBeforeAndCopy (CertificateChoices &elmt); //insert elmt before current elmt - CertificateSet &InsertAfterAndCopy (CertificateChoices &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class OriginatorInfo: public AsnType -{ -public: - CertificateSet *certs; - CertificateRevocationLists *crls; - - OriginatorInfo(); - OriginatorInfo (const OriginatorInfo &); - virtual ~OriginatorInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - OriginatorInfo &operator = (const OriginatorInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class RecipientEncryptedKeys: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - RecipientEncryptedKey *elmt; - } *first, *curr, *last; - -public: - RecipientEncryptedKeys() { count = 0; first = curr = last = NULL; } - RecipientEncryptedKeys (const RecipientEncryptedKeys &); - virtual ~RecipientEncryptedKeys(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RecipientEncryptedKeys &operator = (const RecipientEncryptedKeys &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - RecipientEncryptedKey *First() const { return count > 0 ? first->elmt : NULL; } - RecipientEncryptedKey *Last() const { return count > 0 ? last->elmt : NULL; } - RecipientEncryptedKey *Curr() const { return curr ? curr->elmt : NULL; } - RecipientEncryptedKey *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - RecipientEncryptedKey *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - RecipientEncryptedKey *GoNext() { if (curr) curr = curr->next; return Curr(); } - RecipientEncryptedKey *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - RecipientEncryptedKey *Append(); // add elmt to end of list - RecipientEncryptedKey *Prepend(); // add elmt to beginning of list - RecipientEncryptedKey *InsertBefore(); //insert elmt before current elmt - RecipientEncryptedKey *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - RecipientEncryptedKeys &AppendCopy (RecipientEncryptedKey &elmt); // add elmt to end of list - RecipientEncryptedKeys &PrependCopy (RecipientEncryptedKey &elmt); // add elmt to beginning of list - RecipientEncryptedKeys &InsertBeforeAndCopy (RecipientEncryptedKey &elmt); //insert elmt before current elmt - RecipientEncryptedKeys &InsertAfterAndCopy (RecipientEncryptedKey &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class KeyAgreeRecipientInfo: public AsnType -{ -public: - CMSVersion version; - OriginatorIdentifierOrKey *originator; - UserKeyingMaterial *ukm; - KeyEncryptionAlgorithmIdentifier *keyEncryptionAlgorithm; - RecipientEncryptedKeys recipientEncryptedKeys; - - KeyAgreeRecipientInfo(); - KeyAgreeRecipientInfo (const KeyAgreeRecipientInfo &); - virtual ~KeyAgreeRecipientInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - KeyAgreeRecipientInfo &operator = (const KeyAgreeRecipientInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class RecipientInfo: public AsnType -{ -public: - enum ChoiceIdEnum - { - ktriCid = 0, - kariCid = 1, - kekriCid = 2 - }; - - enum ChoiceIdEnum choiceId; - union - { - KeyTransRecipientInfo *ktri; - KeyAgreeRecipientInfo *kari; - KEKRecipientInfo *kekri; - }; - - - RecipientInfo(); - RecipientInfo (const RecipientInfo &); - virtual ~RecipientInfo(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RecipientInfo &operator = (const RecipientInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class RecipientInfos: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - RecipientInfo *elmt; - } *first, *curr, *last; - -public: - RecipientInfos() { count = 0; first = curr = last = NULL; } - RecipientInfos (const RecipientInfos &); - virtual ~RecipientInfos(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RecipientInfos &operator = (const RecipientInfos &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - RecipientInfo *First() const { return count > 0 ? first->elmt : NULL; } - RecipientInfo *Last() const { return count > 0 ? last->elmt : NULL; } - RecipientInfo *Curr() const { return curr ? curr->elmt : NULL; } - RecipientInfo *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - RecipientInfo *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - RecipientInfo *GoNext() { if (curr) curr = curr->next; return Curr(); } - RecipientInfo *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - RecipientInfo *Append(); // add elmt to end of list - RecipientInfo *Prepend(); // add elmt to beginning of list - RecipientInfo *InsertBefore(); //insert elmt before current elmt - RecipientInfo *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - RecipientInfos &AppendCopy (RecipientInfo &elmt); // add elmt to end of list - RecipientInfos &PrependCopy (RecipientInfo &elmt); // add elmt to beginning of list - RecipientInfos &InsertBeforeAndCopy (RecipientInfo &elmt); //insert elmt before current elmt - RecipientInfos &InsertAfterAndCopy (RecipientInfo &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class ContentInfo: public AsnType -{ -public: - ContentType contentType; - AsnAny content; - - ContentInfo(); - ContentInfo (const ContentInfo &); - virtual ~ContentInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ContentInfo &operator = (const ContentInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class SignedData: public AsnType -{ -public: - CMSVersion version; - DigestAlgorithmIdentifiers digestAlgorithms; - EncapsulatedContentInfo *encapContentInfo; - CertificateSet *certificates; - CertificateRevocationLists *crls; - SignerInfos signerInfos; - - SignedData(); - SignedData (const SignedData &); - virtual ~SignedData(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SignedData &operator = (const SignedData &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class EnvelopedData: public AsnType -{ -public: - CMSVersion version; - OriginatorInfo *originatorInfo; - RecipientInfos recipientInfos; - EncryptedContentInfo *encryptedContentInfo; - Attributes *unprotectedAttrs; - - EnvelopedData(); - EnvelopedData (const EnvelopedData &); - virtual ~EnvelopedData(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EnvelopedData &operator = (const EnvelopedData &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DigestedData: public AsnType -{ -public: - CMSVersion version; - DigestAlgorithmIdentifier *digestAlgorithm; - EncapsulatedContentInfo *encapContentInfo; - Digest digest; - - DigestedData(); - DigestedData (const DigestedData &); - virtual ~DigestedData(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DigestedData &operator = (const DigestedData &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class EncryptedData: public AsnType -{ -public: - CMSVersion version; - EncryptedContentInfo *encryptedContentInfo; - - EncryptedData(); - EncryptedData (const EncryptedData &); - virtual ~EncryptedData(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EncryptedData &operator = (const EncryptedData &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AuthenticatedData: public AsnType -{ -public: - CMSVersion version; - OriginatorInfo *originatorInfo; - RecipientInfos recipientInfos; - MessageAuthenticationCodeAlgorithm *macAlgorithm; - DigestAlgorithmIdentifier *digestAlgorithm; - EncapsulatedContentInfo *encapContentInfo; - Attributes *authenctiatedAttributes; - MessageAuthenticationCode mac; - Attributes *unauthenticatedAttributes; - - AuthenticatedData(); - AuthenticatedData (const AuthenticatedData &); - virtual ~AuthenticatedData(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AuthenticatedData &operator = (const AuthenticatedData &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class UserKeyingMaterials: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - UserKeyingMaterial *elmt; - } *first, *curr, *last; - -public: - UserKeyingMaterials() { count = 0; first = curr = last = NULL; } - UserKeyingMaterials (const UserKeyingMaterials &); - virtual ~UserKeyingMaterials(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - UserKeyingMaterials &operator = (const UserKeyingMaterials &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - UserKeyingMaterial *First() const { return count > 0 ? first->elmt : NULL; } - UserKeyingMaterial *Last() const { return count > 0 ? last->elmt : NULL; } - UserKeyingMaterial *Curr() const { return curr ? curr->elmt : NULL; } - UserKeyingMaterial *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - UserKeyingMaterial *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - UserKeyingMaterial *GoNext() { if (curr) curr = curr->next; return Curr(); } - UserKeyingMaterial *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - UserKeyingMaterial *Append(); // add elmt to end of list - UserKeyingMaterial *Prepend(); // add elmt to beginning of list - UserKeyingMaterial *InsertBefore(); //insert elmt before current elmt - UserKeyingMaterial *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - UserKeyingMaterials &AppendCopy (UserKeyingMaterial &elmt); // add elmt to end of list - UserKeyingMaterials &PrependCopy (UserKeyingMaterial &elmt); // add elmt to beginning of list - UserKeyingMaterials &InsertBeforeAndCopy (UserKeyingMaterial &elmt); //insert elmt before current elmt - UserKeyingMaterials &InsertAfterAndCopy (UserKeyingMaterial &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -/* Time */ -typedef Time SigningTime; - -/* SignerInfo */ -typedef SignerInfo Countersignature; - -/* AlgorithmIdentifier */ -typedef AlgorithmIdentifier KeyWrapAlgorithm; - -/* RC2ParameterVersion */ -typedef RC2ParameterVersion RC2wrapParameter; - -/* IV */ -typedef IV CBCParameter; - -class RC2CBCParameter: public AsnType -{ -public: - AsnInt rc2ParameterVersion; - AsnOcts iv; - - RC2CBCParameter(); - RC2CBCParameter (const RC2CBCParameter &); - virtual ~RC2CBCParameter(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RC2CBCParameter &operator = (const RC2CBCParameter &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ExtendedCertificateOrCertificate: public AsnType -{ -public: - enum ChoiceIdEnum - { - certificateCid = 0, - extendedCertificateCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - Certificate *certificate; - ExtendedCertificate *extendedCertificate; - }; - - - ExtendedCertificateOrCertificate(); - ExtendedCertificateOrCertificate (const ExtendedCertificateOrCertificate &); - virtual ~ExtendedCertificateOrCertificate(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ExtendedCertificateOrCertificate &operator = (const ExtendedCertificateOrCertificate &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DigestInfo: public AsnType -{ -public: - DigestAlgorithmIdentifier *digestAlgorithm; - Digest digest; - - DigestInfo(); - DigestInfo (const DigestInfo &); - virtual ~DigestInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DigestInfo &operator = (const DigestInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -#define sha_1_arc 1, 3, 14, 3, 2, 26 -#define sha_1 AsnOid(sha_1_arc) -#define id_dsa_with_sha1_arc 1, 2, 840, 10040, 4, 3 -#define id_dsa_with_sha1 AsnOid(id_dsa_with_sha1_arc) -#define dh_public_number_arc 1, 2, 840, 10046, 2, 1 -#define dh_public_number AsnOid(dh_public_number_arc) -#define id_alg_ESDH_arc 1, 2, 840, 113549, 1, 9, 16, 3, 5 -#define id_alg_ESDH AsnOid(id_alg_ESDH_arc) -#define id_alg_CMS3DESwrap_arc 1, 2, 840, 113549, 1, 9, 16, 3, 6 -#define id_alg_CMS3DESwrap AsnOid(id_alg_CMS3DESwrap_arc) -#define id_alg_CMSRC2wrap_arc 1, 2, 840, 113549, 1, 9, 16, 3, 7 -#define id_alg_CMSRC2wrap AsnOid(id_alg_CMSRC2wrap_arc) -#define des_ede3_cbc_arc 1, 2, 840, 113549, 3, 7 -#define des_ede3_cbc AsnOid(des_ede3_cbc_arc) -#define rc2_cbc_arc 1, 2, 840, 113549, 3, 2 -#define rc2_cbc AsnOid(rc2_cbc_arc) -#define hMAC_SHA1_arc 1, 3, 6, 1, 5, 5, 8, 1, 2 -#define hMAC_SHA1 AsnOid(hMAC_SHA1_arc) -#define rc2_ecb_arc 1, 2, 840, 113549, 3, 3 -#define rc2_ecb AsnOid(rc2_ecb_arc) -#define rc4_arc 1, 2, 840, 113549, 3, 4 -#define rc4 AsnOid(rc4_arc) -#define rc4WithMAC_arc 1, 2, 840, 113549, 3, 5 -#define rc4WithMAC AsnOid(rc4WithMAC_arc) -#define desx_CBC_arc 1, 2, 840, 113549, 3, 6 -#define desx_CBC AsnOid(desx_CBC_arc) -#define rc5CBC_arc 1, 2, 840, 113549, 3, 8 -#define rc5CBC AsnOid(rc5CBC_arc) -#define rc5_CBCPad_arc 1, 2, 840, 113549, 3, 9 -#define rc5_CBCPad AsnOid(rc5_CBCPad_arc) -#define desCDMF_arc 1, 2, 840, 113549, 3, 10 -#define desCDMF AsnOid(desCDMF_arc) -#define dsa_bsafe_arc 1, 3, 14, 3, 2, 12 -#define dsa_bsafe AsnOid(dsa_bsafe_arc) -#define id_data_arc 1, 2, 840, 113549, 1, 7, 1 -#define id_data AsnOid(id_data_arc) -#define id_signedData_arc 1, 2, 840, 113549, 1, 7, 2 -#define id_signedData AsnOid(id_signedData_arc) -#define id_envelopedData_arc 1, 2, 840, 113549, 1, 7, 3 -#define id_envelopedData AsnOid(id_envelopedData_arc) -#define id_digestedData_arc 1, 2, 840, 113549, 1, 7, 5 -#define id_digestedData AsnOid(id_digestedData_arc) -#define id_encryptedData_arc 1, 2, 840, 113549, 1, 7, 6 -#define id_encryptedData AsnOid(id_encryptedData_arc) -#define id_ct_authData_arc 1, 2, 840, 113549, 1, 9, 16, 1, 2 -#define id_ct_authData AsnOid(id_ct_authData_arc) -#define id_contentType_arc 1, 2, 840, 113549, 1, 9, 3 -#define id_contentType AsnOid(id_contentType_arc) -#define id_messageDigest_arc 1, 2, 840, 113549, 1, 9, 4 -#define id_messageDigest AsnOid(id_messageDigest_arc) -#define id_signingTime_arc 1, 2, 840, 113549, 1, 9, 5 -#define id_signingTime AsnOid(id_signingTime_arc) -#define id_countersignature_arc 1, 2, 840, 113549, 1, 9, 6 -#define id_countersignature AsnOid(id_countersignature_arc) -#define id_macValue_arc 1, 2, 840, 113549, 1, 9, 16, 2, 8 -#define id_macValue AsnOid(id_macValue_arc) -#define id_dsa_arc 1, 2, 840, 10040, 4, 1 -#define id_dsa AsnOid(id_dsa_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_cms.h */ diff --git a/SecurityASN1/inc/sm_ess.h b/SecurityASN1/inc/sm_ess.h deleted file mode 100644 index 6c17a968..00000000 --- a/SecurityASN1/inc/sm_ess.h +++ /dev/null @@ -1,1057 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_ess.h - class definitions for ASN.1 module ExtendedSecurityServices -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_ess_h_ -#define _sm_ess_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class AllOrFirstTier; -class SecurityClassification; -class SigningCertificateSeqOf1; -class MLReceiptPolicySeqOf1; -class MLReceiptPolicySeqOf; -class ReceiptsFromSeqOf; -class ReceiptRequestSeqOf; -class ESSPrivacyMark; -class SecurityCategory; -class EntityIdentifier; -class ReceiptsFrom; -class SecurityCategories; -class MLReceiptPolicy; -class ESSCertID; -class SigningCertificateSeqOf; -class ESSSecurityLabel; -class MLData; -class ReceiptRequest; -class Receipt; -class ContentHints; -class ContentReference; -class EquivalentLabels; -class MLExpansionHistory; -class SigningCertificate; - -//------------------------------------------------------------------------------ -// class definitions: - -typedef enum ExtendedSecurityServicesAnyId -{ - -} ExtendedSecurityServicesAnyId; - - -/* OCTET STRING */ -typedef AsnOcts ContentIdentifier; - -/* INTEGER { allReceipts (0), firstTierRecipients (1) } */ -class AllOrFirstTier: public AsnInt -{ -public: - AllOrFirstTier(): AsnInt() {} - AllOrFirstTier (int i): AsnInt (i) {} - enum - { - allReceipts = 0, - firstTierRecipients = 1 - }; -}; - - -/* OCTET STRING */ -typedef AsnOcts MsgSigDigest; - -/* OBJECT IDENTIFIER */ -typedef AsnOid SecurityPolicyIdentifier; - -/* INTEGER { unmarked (0), unclassified (1), restricted (2), confidential (3), secret (4), top_secret (5) } (0..ub-integer-options) */ -class SecurityClassification: public AsnInt -{ -public: - SecurityClassification(): AsnInt() {} - SecurityClassification (int i): AsnInt (i) {} - enum - { - unmarked = 0, - unclassified = 1, - restricted = 2, - confidential = 3, - secret = 4, - top_secret = 5 - }; -}; - - -/* OCTET STRING */ -typedef AsnOcts CertHash; - -/* OBJECT IDENTIFIER (id-qt-cps) | (id-qt-unotice) */ -typedef AsnOid PolicyQualifierId; - -class SigningCertificateSeqOf1: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - PolicyInformation *elmt; - } *first, *curr, *last; - -public: - SigningCertificateSeqOf1() { count = 0; first = curr = last = NULL; } - SigningCertificateSeqOf1 (const SigningCertificateSeqOf1 &); - virtual ~SigningCertificateSeqOf1(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SigningCertificateSeqOf1 &operator = (const SigningCertificateSeqOf1 &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - PolicyInformation *First() const { return count > 0 ? first->elmt : NULL; } - PolicyInformation *Last() const { return count > 0 ? last->elmt : NULL; } - PolicyInformation *Curr() const { return curr ? curr->elmt : NULL; } - PolicyInformation *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - PolicyInformation *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - PolicyInformation *GoNext() { if (curr) curr = curr->next; return Curr(); } - PolicyInformation *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - PolicyInformation *Append(); // add elmt to end of list - PolicyInformation *Prepend(); // add elmt to beginning of list - PolicyInformation *InsertBefore(); //insert elmt before current elmt - PolicyInformation *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - SigningCertificateSeqOf1 &AppendCopy (PolicyInformation &elmt); // add elmt to end of list - SigningCertificateSeqOf1 &PrependCopy (PolicyInformation &elmt); // add elmt to beginning of list - SigningCertificateSeqOf1 &InsertBeforeAndCopy (PolicyInformation &elmt); //insert elmt before current elmt - SigningCertificateSeqOf1 &InsertAfterAndCopy (PolicyInformation &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class MLReceiptPolicySeqOf1: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - GeneralNames *elmt; - } *first, *curr, *last; - -public: - MLReceiptPolicySeqOf1() { count = 0; first = curr = last = NULL; } - MLReceiptPolicySeqOf1 (const MLReceiptPolicySeqOf1 &); - virtual ~MLReceiptPolicySeqOf1(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - MLReceiptPolicySeqOf1 &operator = (const MLReceiptPolicySeqOf1 &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - GeneralNames *First() const { return count > 0 ? first->elmt : NULL; } - GeneralNames *Last() const { return count > 0 ? last->elmt : NULL; } - GeneralNames *Curr() const { return curr ? curr->elmt : NULL; } - GeneralNames *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - GeneralNames *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - GeneralNames *GoNext() { if (curr) curr = curr->next; return Curr(); } - GeneralNames *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - GeneralNames *Append(); // add elmt to end of list - GeneralNames *Prepend(); // add elmt to beginning of list - GeneralNames *InsertBefore(); //insert elmt before current elmt - GeneralNames *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - MLReceiptPolicySeqOf1 &AppendCopy (GeneralNames &elmt); // add elmt to end of list - MLReceiptPolicySeqOf1 &PrependCopy (GeneralNames &elmt); // add elmt to beginning of list - MLReceiptPolicySeqOf1 &InsertBeforeAndCopy (GeneralNames &elmt); //insert elmt before current elmt - MLReceiptPolicySeqOf1 &InsertAfterAndCopy (GeneralNames &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class MLReceiptPolicySeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - GeneralNames *elmt; - } *first, *curr, *last; - -public: - MLReceiptPolicySeqOf() { count = 0; first = curr = last = NULL; } - MLReceiptPolicySeqOf (const MLReceiptPolicySeqOf &); - virtual ~MLReceiptPolicySeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - MLReceiptPolicySeqOf &operator = (const MLReceiptPolicySeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - GeneralNames *First() const { return count > 0 ? first->elmt : NULL; } - GeneralNames *Last() const { return count > 0 ? last->elmt : NULL; } - GeneralNames *Curr() const { return curr ? curr->elmt : NULL; } - GeneralNames *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - GeneralNames *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - GeneralNames *GoNext() { if (curr) curr = curr->next; return Curr(); } - GeneralNames *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - GeneralNames *Append(); // add elmt to end of list - GeneralNames *Prepend(); // add elmt to beginning of list - GeneralNames *InsertBefore(); //insert elmt before current elmt - GeneralNames *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - MLReceiptPolicySeqOf &AppendCopy (GeneralNames &elmt); // add elmt to end of list - MLReceiptPolicySeqOf &PrependCopy (GeneralNames &elmt); // add elmt to beginning of list - MLReceiptPolicySeqOf &InsertBeforeAndCopy (GeneralNames &elmt); //insert elmt before current elmt - MLReceiptPolicySeqOf &InsertAfterAndCopy (GeneralNames &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class ReceiptsFromSeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - GeneralNames *elmt; - } *first, *curr, *last; - -public: - ReceiptsFromSeqOf() { count = 0; first = curr = last = NULL; } - ReceiptsFromSeqOf (const ReceiptsFromSeqOf &); - virtual ~ReceiptsFromSeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ReceiptsFromSeqOf &operator = (const ReceiptsFromSeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - GeneralNames *First() const { return count > 0 ? first->elmt : NULL; } - GeneralNames *Last() const { return count > 0 ? last->elmt : NULL; } - GeneralNames *Curr() const { return curr ? curr->elmt : NULL; } - GeneralNames *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - GeneralNames *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - GeneralNames *GoNext() { if (curr) curr = curr->next; return Curr(); } - GeneralNames *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - GeneralNames *Append(); // add elmt to end of list - GeneralNames *Prepend(); // add elmt to beginning of list - GeneralNames *InsertBefore(); //insert elmt before current elmt - GeneralNames *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - ReceiptsFromSeqOf &AppendCopy (GeneralNames &elmt); // add elmt to end of list - ReceiptsFromSeqOf &PrependCopy (GeneralNames &elmt); // add elmt to beginning of list - ReceiptsFromSeqOf &InsertBeforeAndCopy (GeneralNames &elmt); //insert elmt before current elmt - ReceiptsFromSeqOf &InsertAfterAndCopy (GeneralNames &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class ReceiptRequestSeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - GeneralNames *elmt; - } *first, *curr, *last; - -public: - ReceiptRequestSeqOf() { count = 0; first = curr = last = NULL; } - ReceiptRequestSeqOf (const ReceiptRequestSeqOf &); - virtual ~ReceiptRequestSeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ReceiptRequestSeqOf &operator = (const ReceiptRequestSeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - GeneralNames *First() const { return count > 0 ? first->elmt : NULL; } - GeneralNames *Last() const { return count > 0 ? last->elmt : NULL; } - GeneralNames *Curr() const { return curr ? curr->elmt : NULL; } - GeneralNames *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - GeneralNames *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - GeneralNames *GoNext() { if (curr) curr = curr->next; return Curr(); } - GeneralNames *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - GeneralNames *Append(); // add elmt to end of list - GeneralNames *Prepend(); // add elmt to beginning of list - GeneralNames *InsertBefore(); //insert elmt before current elmt - GeneralNames *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - ReceiptRequestSeqOf &AppendCopy (GeneralNames &elmt); // add elmt to end of list - ReceiptRequestSeqOf &PrependCopy (GeneralNames &elmt); // add elmt to beginning of list - ReceiptRequestSeqOf &InsertBeforeAndCopy (GeneralNames &elmt); //insert elmt before current elmt - ReceiptRequestSeqOf &InsertAfterAndCopy (GeneralNames &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class ESSPrivacyMark: public AsnType -{ -public: - enum ChoiceIdEnum - { - pStringCid = 0, - utf8StringCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - PrintableString *pString; - UTF8String *utf8String; - }; - - - ESSPrivacyMark(); - ESSPrivacyMark (const ESSPrivacyMark &); - virtual ~ESSPrivacyMark(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ESSPrivacyMark &operator = (const ESSPrivacyMark &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class SecurityCategory: public AsnType -{ -public: - AsnOid type; - AsnAny value; - - SecurityCategory(); - SecurityCategory (const SecurityCategory &); - virtual ~SecurityCategory(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SecurityCategory &operator = (const SecurityCategory &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class EntityIdentifier: public AsnType -{ -public: - enum ChoiceIdEnum - { - issuerAndSerialNumberCid = 0, - subjectKeyIdentifierCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - IssuerAndSerialNumber *issuerAndSerialNumber; - KeyIdentifier *subjectKeyIdentifier; - }; - - - EntityIdentifier(); - EntityIdentifier (const EntityIdentifier &); - virtual ~EntityIdentifier(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EntityIdentifier &operator = (const EntityIdentifier &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ReceiptsFrom: public AsnType -{ -public: - enum ChoiceIdEnum - { - allOrFirstTierCid = 0, - receiptListCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - AllOrFirstTier *allOrFirstTier; - ReceiptsFromSeqOf *receiptList; - }; - - - ReceiptsFrom(); - ReceiptsFrom (const ReceiptsFrom &); - virtual ~ReceiptsFrom(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ReceiptsFrom &operator = (const ReceiptsFrom &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class SecurityCategories: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - SecurityCategory *elmt; - } *first, *curr, *last; - -public: - SecurityCategories() { count = 0; first = curr = last = NULL; } - SecurityCategories (const SecurityCategories &); - virtual ~SecurityCategories(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SecurityCategories &operator = (const SecurityCategories &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - SecurityCategory *First() const { return count > 0 ? first->elmt : NULL; } - SecurityCategory *Last() const { return count > 0 ? last->elmt : NULL; } - SecurityCategory *Curr() const { return curr ? curr->elmt : NULL; } - SecurityCategory *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - SecurityCategory *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - SecurityCategory *GoNext() { if (curr) curr = curr->next; return Curr(); } - SecurityCategory *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - SecurityCategory *Append(); // add elmt to end of list - SecurityCategory *Prepend(); // add elmt to beginning of list - SecurityCategory *InsertBefore(); //insert elmt before current elmt - SecurityCategory *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - SecurityCategories &AppendCopy (SecurityCategory &elmt); // add elmt to end of list - SecurityCategories &PrependCopy (SecurityCategory &elmt); // add elmt to beginning of list - SecurityCategories &InsertBeforeAndCopy (SecurityCategory &elmt); //insert elmt before current elmt - SecurityCategories &InsertAfterAndCopy (SecurityCategory &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class MLReceiptPolicy: public AsnType -{ -public: - enum ChoiceIdEnum - { - noneCid = 0, - insteadOfCid = 1, - inAdditionToCid = 2 - }; - - enum ChoiceIdEnum choiceId; - union - { - AsnNull *none; - MLReceiptPolicySeqOf *insteadOf; - MLReceiptPolicySeqOf1 *inAdditionTo; - }; - - - MLReceiptPolicy(); - MLReceiptPolicy (const MLReceiptPolicy &); - virtual ~MLReceiptPolicy(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - MLReceiptPolicy &operator = (const MLReceiptPolicy &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ESSCertID: public AsnType -{ -public: - CertHash certHash; - IssuerSerial *issuerSerial; - - ESSCertID(); - ESSCertID (const ESSCertID &); - virtual ~ESSCertID(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ESSCertID &operator = (const ESSCertID &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class SigningCertificateSeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - ESSCertID *elmt; - } *first, *curr, *last; - -public: - SigningCertificateSeqOf() { count = 0; first = curr = last = NULL; } - SigningCertificateSeqOf (const SigningCertificateSeqOf &); - virtual ~SigningCertificateSeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SigningCertificateSeqOf &operator = (const SigningCertificateSeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - ESSCertID *First() const { return count > 0 ? first->elmt : NULL; } - ESSCertID *Last() const { return count > 0 ? last->elmt : NULL; } - ESSCertID *Curr() const { return curr ? curr->elmt : NULL; } - ESSCertID *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - ESSCertID *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - ESSCertID *GoNext() { if (curr) curr = curr->next; return Curr(); } - ESSCertID *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - ESSCertID *Append(); // add elmt to end of list - ESSCertID *Prepend(); // add elmt to beginning of list - ESSCertID *InsertBefore(); //insert elmt before current elmt - ESSCertID *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - SigningCertificateSeqOf &AppendCopy (ESSCertID &elmt); // add elmt to end of list - SigningCertificateSeqOf &PrependCopy (ESSCertID &elmt); // add elmt to beginning of list - SigningCertificateSeqOf &InsertBeforeAndCopy (ESSCertID &elmt); //insert elmt before current elmt - SigningCertificateSeqOf &InsertAfterAndCopy (ESSCertID &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class ESSSecurityLabel: public AsnType -{ -public: - SecurityPolicyIdentifier security_policy_identifier; - SecurityClassification *security_classification; - ESSPrivacyMark *privacy_mark; - SecurityCategories *security_categories; - - ESSSecurityLabel(); - ESSSecurityLabel (const ESSSecurityLabel &); - virtual ~ESSSecurityLabel(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ESSSecurityLabel &operator = (const ESSSecurityLabel &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class MLData: public AsnType -{ -public: - EntityIdentifier *mailListIdentifier; - GeneralizedTime expansionTime; - MLReceiptPolicy *mlReceiptPolicy; - - MLData(); - MLData (const MLData &); - virtual ~MLData(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - MLData &operator = (const MLData &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ReceiptRequest: public AsnType -{ -public: - ContentIdentifier signedContentIdentifier; - ReceiptsFrom *receiptsFrom; - ReceiptRequestSeqOf receiptsTo; - - ReceiptRequest(); - ReceiptRequest (const ReceiptRequest &); - virtual ~ReceiptRequest(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ReceiptRequest &operator = (const ReceiptRequest &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class Receipt: public AsnType -{ -public: - CMSVersion version; - ContentType contentType; - ContentIdentifier signedContentIdentifier; - AsnOcts originatorSignatureValue; - - Receipt(); - Receipt (const Receipt &); - virtual ~Receipt(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Receipt &operator = (const Receipt &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ContentHints: public AsnType -{ -public: - UTF8String *contentDescription; - ContentType contentType; - - ContentHints(); - ContentHints (const ContentHints &); - virtual ~ContentHints(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ContentHints &operator = (const ContentHints &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ContentReference: public AsnType -{ -public: - ContentType contentType; - ContentIdentifier signedContentIdentifier; - AsnOcts originatorSignatureValue; - - ContentReference(); - ContentReference (const ContentReference &); - virtual ~ContentReference(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ContentReference &operator = (const ContentReference &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class EquivalentLabels: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - ESSSecurityLabel *elmt; - } *first, *curr, *last; - -public: - EquivalentLabels() { count = 0; first = curr = last = NULL; } - EquivalentLabels (const EquivalentLabels &); - virtual ~EquivalentLabels(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EquivalentLabels &operator = (const EquivalentLabels &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - ESSSecurityLabel *First() const { return count > 0 ? first->elmt : NULL; } - ESSSecurityLabel *Last() const { return count > 0 ? last->elmt : NULL; } - ESSSecurityLabel *Curr() const { return curr ? curr->elmt : NULL; } - ESSSecurityLabel *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - ESSSecurityLabel *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - ESSSecurityLabel *GoNext() { if (curr) curr = curr->next; return Curr(); } - ESSSecurityLabel *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - ESSSecurityLabel *Append(); // add elmt to end of list - ESSSecurityLabel *Prepend(); // add elmt to beginning of list - ESSSecurityLabel *InsertBefore(); //insert elmt before current elmt - ESSSecurityLabel *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - EquivalentLabels &AppendCopy (ESSSecurityLabel &elmt); // add elmt to end of list - EquivalentLabels &PrependCopy (ESSSecurityLabel &elmt); // add elmt to beginning of list - EquivalentLabels &InsertBeforeAndCopy (ESSSecurityLabel &elmt); //insert elmt before current elmt - EquivalentLabels &InsertAfterAndCopy (ESSSecurityLabel &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class MLExpansionHistory: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - MLData *elmt; - } *first, *curr, *last; - -public: - MLExpansionHistory() { count = 0; first = curr = last = NULL; } - MLExpansionHistory (const MLExpansionHistory &); - virtual ~MLExpansionHistory(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - MLExpansionHistory &operator = (const MLExpansionHistory &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - MLData *First() const { return count > 0 ? first->elmt : NULL; } - MLData *Last() const { return count > 0 ? last->elmt : NULL; } - MLData *Curr() const { return curr ? curr->elmt : NULL; } - MLData *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - MLData *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - MLData *GoNext() { if (curr) curr = curr->next; return Curr(); } - MLData *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - MLData *Append(); // add elmt to end of list - MLData *Prepend(); // add elmt to beginning of list - MLData *InsertBefore(); //insert elmt before current elmt - MLData *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - MLExpansionHistory &AppendCopy (MLData &elmt); // add elmt to end of list - MLExpansionHistory &PrependCopy (MLData &elmt); // add elmt to beginning of list - MLExpansionHistory &InsertBeforeAndCopy (MLData &elmt); //insert elmt before current elmt - MLExpansionHistory &InsertAfterAndCopy (MLData &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class SigningCertificate: public AsnType -{ -public: - SigningCertificateSeqOf certs; - SigningCertificateSeqOf1 *policies; - - SigningCertificate(); - SigningCertificate (const SigningCertificate &); - virtual ~SigningCertificate(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SigningCertificate &operator = (const SigningCertificate &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -#define ub_receiptsTo_val 16 -#define ub_receiptsTo AsnInt(ub_receiptsTo_val) -#define smime_arc 1, 2, 840, 113549, 1, 9, 16 -#define smime AsnOid(smime_arc) -#define id_aa_arc 1, 2, 840, 113549, 1, 9, 16, 2 -#define id_aa AsnOid(id_aa_arc) -#define id_aa_receiptRequest_arc 1, 2, 840, 113549, 1, 9, 16, 2, 1 -#define id_aa_receiptRequest AsnOid(id_aa_receiptRequest_arc) -#define id_aa_contentIdentifier_arc 1, 2, 840, 113549, 1, 9, 16, 2, 7 -#define id_aa_contentIdentifier AsnOid(id_aa_contentIdentifier_arc) -#define id_ct_receipt_arc 1, 2, 840, 113549, 1, 9, 16, 1, 1 -#define id_ct_receipt AsnOid(id_ct_receipt_arc) -#define id_aa_contentHint_arc 1, 2, 840, 113549, 1, 9, 16, 2, 4 -#define id_aa_contentHint AsnOid(id_aa_contentHint_arc) -#define id_aa_msgSigDigest_arc 1, 2, 840, 113549, 1, 9, 16, 2, 5 -#define id_aa_msgSigDigest AsnOid(id_aa_msgSigDigest_arc) -#define id_aa_contentReference_arc 1, 2, 840, 113549, 1, 9, 16, 2, 10 -#define id_aa_contentReference AsnOid(id_aa_contentReference_arc) -#define id_aa_securityLabel_arc 1, 2, 840, 113549, 1, 9, 16, 2, 2 -#define id_aa_securityLabel AsnOid(id_aa_securityLabel_arc) -#define id_aa_equivalentLabels_arc 1, 2, 840, 113549, 1, 9, 16, 2, 9 -#define id_aa_equivalentLabels AsnOid(id_aa_equivalentLabels_arc) -#define id_aa_mlExpandHistory_arc 1, 2, 840, 113549, 1, 9, 16, 2, 3 -#define id_aa_mlExpandHistory AsnOid(id_aa_mlExpandHistory_arc) -#define ub_ml_expansion_history_val 64 -#define ub_ml_expansion_history AsnInt(ub_ml_expansion_history_val) -#define id_aa_signingCertificate_arc 1, 2, 840, 113549, 1, 9, 16, 2, 4444 -#define id_aa_signingCertificate AsnOid(id_aa_signingCertificate_arc) -#define id_pkix_arc 1, 3, 6, 1, 5, 5, 7 -#define id_pkix AsnOid(id_pkix_arc) -#define id_qt_arc 1, 3, 6, 1, 5, 5, 7, 2 -#define id_qt AsnOid(id_qt_arc) -#define id_qt_cps_arc 1, 3, 6, 1, 5, 5, 7, 2, 1 -#define id_qt_cps AsnOid(id_qt_cps_arc) -#define id_qt_unotice_arc 1, 3, 6, 1, 5, 5, 7, 2, 2 -#define id_qt_unotice AsnOid(id_qt_unotice_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_ess.h */ diff --git a/SecurityASN1/inc/sm_vdatypes.h b/SecurityASN1/inc/sm_vdatypes.h deleted file mode 100644 index 5f2a1e0c..00000000 --- a/SecurityASN1/inc/sm_vdatypes.h +++ /dev/null @@ -1,45 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_vdatypes.h - class definitions for ASN.1 module VdaEnhancedTypes -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_vdatypes_h_ -#define _sm_vdatypes_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class BigIntegerStr; - -//------------------------------------------------------------------------------ -// class definitions: - -/* [UNIVERSAL 2] IMPLICIT OCTET STRING */ -class BigIntegerStr: public AsnOcts -{ -public: - BigIntegerStr(): AsnOcts() {} - BigIntegerStr (const char *str): AsnOcts (str) {} - BigIntegerStr (const char *str, const size_t len): AsnOcts (str, len) {} - BigIntegerStr (const AsnOcts &o): AsnOcts (o) {} - BigIntegerStr &operator = (const BigIntegerStr &o) { ReSet (o); return *this; } - BigIntegerStr &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_vdatypes.h */ diff --git a/SecurityASN1/inc/sm_x411mtsas.h b/SecurityASN1/inc/sm_x411mtsas.h deleted file mode 100644 index abc40e4c..00000000 --- a/SecurityASN1/inc/sm_x411mtsas.h +++ /dev/null @@ -1,666 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x411mtsas.h - class definitions for ASN.1 module MTSAbstractService -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_x411mtsas_h_ -#define _sm_x411mtsas_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class CountryName; -class AdministrationDomainName; -class PrivateDomainName; -class PersonalName; -class DomainDefinedAttribute; -class ExtensionAttribute; -class TeletexDomainDefinedAttribute; -class OrganizationUnitNames; -class DomainDefinedAttributes; -class ExtensionAttributes; -class StandardAttributes; -class ORAddress; -class TeletexPersonalName; -class TeletexOrganizationUnitNames; -class TeletexDomainDefinedAttributes; - -//------------------------------------------------------------------------------ -// class definitions: - -typedef enum MTSAbstractServiceAnyId -{ - -} MTSAbstractServiceAnyId; - - -class CountryName: public AsnType -{ -public: - enum ChoiceIdEnum - { - x121_dcc_codeCid = 0, - iso_3166_alpha2_codeCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - NumericString *x121_dcc_code; - PrintableString *iso_3166_alpha2_code; - }; - - - CountryName(); - CountryName (const CountryName &); - virtual ~CountryName(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CountryName &operator = (const CountryName &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AdministrationDomainName: public AsnType -{ -public: - enum ChoiceIdEnum - { - numericCid = 0, - printableCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - NumericString *numeric; - PrintableString *printable; - }; - - - AdministrationDomainName(); - AdministrationDomainName (const AdministrationDomainName &); - virtual ~AdministrationDomainName(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AdministrationDomainName &operator = (const AdministrationDomainName &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* NumericString (SIZE (1..ub-x121-address-length)) */ -typedef NumericString X121Address; - -/* PrintableString (SIZE (1..ub-terminal-id-length)) */ -typedef PrintableString TerminalIdentifier; - -class PrivateDomainName: public AsnType -{ -public: - enum ChoiceIdEnum - { - numericCid = 0, - printableCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - NumericString *numeric; - PrintableString *printable; - }; - - - PrivateDomainName(); - PrivateDomainName (const PrivateDomainName &); - virtual ~PrivateDomainName(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PrivateDomainName &operator = (const PrivateDomainName &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* PrintableString (SIZE (1..ub-organization-name-length)) */ -typedef PrintableString OrganizationName; - -/* NumericString (SIZE (1..ub-numeric-user-id-length)) */ -typedef NumericString NumericUserIdentifier; - -class PersonalName: public AsnType -{ -public: - PrintableString surname; - PrintableString *given_name; - PrintableString *initials; - PrintableString *generation_qualifier; - - PersonalName(); - PersonalName (const PersonalName &); - virtual ~PersonalName(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PersonalName &operator = (const PersonalName &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* PrintableString (SIZE (1..ub-organizational-unit-name-length)) */ -typedef PrintableString OrganizationUnitName; - -class DomainDefinedAttribute: public AsnType -{ -public: - PrintableString type; - PrintableString value; - - DomainDefinedAttribute(); - DomainDefinedAttribute (const DomainDefinedAttribute &); - virtual ~DomainDefinedAttribute(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DomainDefinedAttribute &operator = (const DomainDefinedAttribute &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ExtensionAttribute: public AsnType -{ -public: - AsnInt extension_attribute_type; - AsnAny extension_attribute_value; - - ExtensionAttribute(); - ExtensionAttribute (const ExtensionAttribute &); - virtual ~ExtensionAttribute(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ExtensionAttribute &operator = (const ExtensionAttribute &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* TeletexString (SIZE (1..ub-organizational-unit-name-length)) */ -typedef TeletexString TeletexOrganizationalUnitName; - -class TeletexDomainDefinedAttribute: public AsnType -{ -public: - TeletexString type; - TeletexString value; - - TeletexDomainDefinedAttribute(); - TeletexDomainDefinedAttribute (const TeletexDomainDefinedAttribute &); - virtual ~TeletexDomainDefinedAttribute(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - TeletexDomainDefinedAttribute &operator = (const TeletexDomainDefinedAttribute &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* X121Address */ -typedef X121Address NetworkAddress; - -class OrganizationUnitNames: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - OrganizationUnitName *elmt; - } *first, *curr, *last; - -public: - OrganizationUnitNames() { count = 0; first = curr = last = NULL; } - OrganizationUnitNames (const OrganizationUnitNames &); - virtual ~OrganizationUnitNames(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - OrganizationUnitNames &operator = (const OrganizationUnitNames &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - OrganizationUnitName *First() const { return count > 0 ? first->elmt : NULL; } - OrganizationUnitName *Last() const { return count > 0 ? last->elmt : NULL; } - OrganizationUnitName *Curr() const { return curr ? curr->elmt : NULL; } - OrganizationUnitName *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - OrganizationUnitName *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - OrganizationUnitName *GoNext() { if (curr) curr = curr->next; return Curr(); } - OrganizationUnitName *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - OrganizationUnitName *Append(); // add elmt to end of list - OrganizationUnitName *Prepend(); // add elmt to beginning of list - OrganizationUnitName *InsertBefore(); //insert elmt before current elmt - OrganizationUnitName *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - OrganizationUnitNames &AppendCopy (OrganizationUnitName &elmt); // add elmt to end of list - OrganizationUnitNames &PrependCopy (OrganizationUnitName &elmt); // add elmt to beginning of list - OrganizationUnitNames &InsertBeforeAndCopy (OrganizationUnitName &elmt); //insert elmt before current elmt - OrganizationUnitNames &InsertAfterAndCopy (OrganizationUnitName &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class DomainDefinedAttributes: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - DomainDefinedAttribute *elmt; - } *first, *curr, *last; - -public: - DomainDefinedAttributes() { count = 0; first = curr = last = NULL; } - DomainDefinedAttributes (const DomainDefinedAttributes &); - virtual ~DomainDefinedAttributes(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DomainDefinedAttributes &operator = (const DomainDefinedAttributes &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - DomainDefinedAttribute *First() const { return count > 0 ? first->elmt : NULL; } - DomainDefinedAttribute *Last() const { return count > 0 ? last->elmt : NULL; } - DomainDefinedAttribute *Curr() const { return curr ? curr->elmt : NULL; } - DomainDefinedAttribute *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - DomainDefinedAttribute *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - DomainDefinedAttribute *GoNext() { if (curr) curr = curr->next; return Curr(); } - DomainDefinedAttribute *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - DomainDefinedAttribute *Append(); // add elmt to end of list - DomainDefinedAttribute *Prepend(); // add elmt to beginning of list - DomainDefinedAttribute *InsertBefore(); //insert elmt before current elmt - DomainDefinedAttribute *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - DomainDefinedAttributes &AppendCopy (DomainDefinedAttribute &elmt); // add elmt to end of list - DomainDefinedAttributes &PrependCopy (DomainDefinedAttribute &elmt); // add elmt to beginning of list - DomainDefinedAttributes &InsertBeforeAndCopy (DomainDefinedAttribute &elmt); //insert elmt before current elmt - DomainDefinedAttributes &InsertAfterAndCopy (DomainDefinedAttribute &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class ExtensionAttributes: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - ExtensionAttribute *elmt; - } *first, *curr, *last; - -public: - ExtensionAttributes() { count = 0; first = curr = last = NULL; } - ExtensionAttributes (const ExtensionAttributes &); - virtual ~ExtensionAttributes(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ExtensionAttributes &operator = (const ExtensionAttributes &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - ExtensionAttribute *First() const { return count > 0 ? first->elmt : NULL; } - ExtensionAttribute *Last() const { return count > 0 ? last->elmt : NULL; } - ExtensionAttribute *Curr() const { return curr ? curr->elmt : NULL; } - ExtensionAttribute *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - ExtensionAttribute *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - ExtensionAttribute *GoNext() { if (curr) curr = curr->next; return Curr(); } - ExtensionAttribute *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - ExtensionAttribute *Append(); // add elmt to end of list - ExtensionAttribute *Prepend(); // add elmt to beginning of list - ExtensionAttribute *InsertBefore(); //insert elmt before current elmt - ExtensionAttribute *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - ExtensionAttributes &AppendCopy (ExtensionAttribute &elmt); // add elmt to end of list - ExtensionAttributes &PrependCopy (ExtensionAttribute &elmt); // add elmt to beginning of list - ExtensionAttributes &InsertBeforeAndCopy (ExtensionAttribute &elmt); //insert elmt before current elmt - ExtensionAttributes &InsertAfterAndCopy (ExtensionAttribute &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class StandardAttributes: public AsnType -{ -public: - CountryName *country_name; - AdministrationDomainName *administration_domain_name; - NetworkAddress *network_address; - TerminalIdentifier *terminal_identifier; - PrivateDomainName *private_domain_name; - OrganizationName *organization_name; - NumericUserIdentifier *numeric_user_identifier; - PersonalName *personal_name; - OrganizationUnitNames *organizational_unit_names; - - StandardAttributes(); - StandardAttributes (const StandardAttributes &); - virtual ~StandardAttributes(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - StandardAttributes &operator = (const StandardAttributes &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class ORAddress: public AsnType -{ -public: - StandardAttributes *standard_attributes; - DomainDefinedAttributes *domain_defined_attributes; - ExtensionAttributes *extension_attributes; - - ORAddress(); - ORAddress (const ORAddress &); - virtual ~ORAddress(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ORAddress &operator = (const ORAddress &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* PrintableString (SIZE (1..ub-common-name-length)) */ -typedef PrintableString CommonName; - -/* TeletexString (SIZE (1..ub-common-name-length)) */ -typedef TeletexString TeletexCommonName; - -/* TeletexString (SIZE (1..ub-organization-name-length)) */ -typedef TeletexString TeletexOrganizationalName; - -class TeletexPersonalName: public AsnType -{ -public: - TeletexString surname; - TeletexString *given_name; - TeletexString *initials; - TeletexString *generation_qualifier; - - TeletexPersonalName(); - TeletexPersonalName (const TeletexPersonalName &); - virtual ~TeletexPersonalName(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - TeletexPersonalName &operator = (const TeletexPersonalName &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class TeletexOrganizationUnitNames: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - TeletexOrganizationalUnitName *elmt; - } *first, *curr, *last; - -public: - TeletexOrganizationUnitNames() { count = 0; first = curr = last = NULL; } - TeletexOrganizationUnitNames (const TeletexOrganizationUnitNames &); - virtual ~TeletexOrganizationUnitNames(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - TeletexOrganizationUnitNames &operator = (const TeletexOrganizationUnitNames &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - TeletexOrganizationalUnitName *First() const { return count > 0 ? first->elmt : NULL; } - TeletexOrganizationalUnitName *Last() const { return count > 0 ? last->elmt : NULL; } - TeletexOrganizationalUnitName *Curr() const { return curr ? curr->elmt : NULL; } - TeletexOrganizationalUnitName *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - TeletexOrganizationalUnitName *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - TeletexOrganizationalUnitName *GoNext() { if (curr) curr = curr->next; return Curr(); } - TeletexOrganizationalUnitName *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - TeletexOrganizationalUnitName *Append(); // add elmt to end of list - TeletexOrganizationalUnitName *Prepend(); // add elmt to beginning of list - TeletexOrganizationalUnitName *InsertBefore(); //insert elmt before current elmt - TeletexOrganizationalUnitName *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - TeletexOrganizationUnitNames &AppendCopy (TeletexOrganizationalUnitName &elmt); // add elmt to end of list - TeletexOrganizationUnitNames &PrependCopy (TeletexOrganizationalUnitName &elmt); // add elmt to beginning of list - TeletexOrganizationUnitNames &InsertBeforeAndCopy (TeletexOrganizationalUnitName &elmt); //insert elmt before current elmt - TeletexOrganizationUnitNames &InsertAfterAndCopy (TeletexOrganizationalUnitName &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class TeletexDomainDefinedAttributes: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - TeletexDomainDefinedAttribute *elmt; - } *first, *curr, *last; - -public: - TeletexDomainDefinedAttributes() { count = 0; first = curr = last = NULL; } - TeletexDomainDefinedAttributes (const TeletexDomainDefinedAttributes &); - virtual ~TeletexDomainDefinedAttributes(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - TeletexDomainDefinedAttributes &operator = (const TeletexDomainDefinedAttributes &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - TeletexDomainDefinedAttribute *First() const { return count > 0 ? first->elmt : NULL; } - TeletexDomainDefinedAttribute *Last() const { return count > 0 ? last->elmt : NULL; } - TeletexDomainDefinedAttribute *Curr() const { return curr ? curr->elmt : NULL; } - TeletexDomainDefinedAttribute *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - TeletexDomainDefinedAttribute *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - TeletexDomainDefinedAttribute *GoNext() { if (curr) curr = curr->next; return Curr(); } - TeletexDomainDefinedAttribute *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - TeletexDomainDefinedAttribute *Append(); // add elmt to end of list - TeletexDomainDefinedAttribute *Prepend(); // add elmt to beginning of list - TeletexDomainDefinedAttribute *InsertBefore(); //insert elmt before current elmt - TeletexDomainDefinedAttribute *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - TeletexDomainDefinedAttributes &AppendCopy (TeletexDomainDefinedAttribute &elmt); // add elmt to end of list - TeletexDomainDefinedAttributes &PrependCopy (TeletexDomainDefinedAttribute &elmt); // add elmt to beginning of list - TeletexDomainDefinedAttributes &InsertBeforeAndCopy (TeletexDomainDefinedAttribute &elmt); //insert elmt before current elmt - TeletexDomainDefinedAttributes &InsertAfterAndCopy (TeletexDomainDefinedAttribute &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_x411mtsas.h */ diff --git a/SecurityASN1/inc/sm_x411ub.h b/SecurityASN1/inc/sm_x411ub.h deleted file mode 100644 index 56cebf81..00000000 --- a/SecurityASN1/inc/sm_x411ub.h +++ /dev/null @@ -1,139 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x411ub.h - class definitions for ASN.1 module UpperBounds -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_x411ub_h_ -#define _sm_x411ub_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - - -//------------------------------------------------------------------------------ -// class definitions: - -//------------------------------------------------------------------------------ -// externs for value defs - -#define ub_integer_options_val 256 -#define ub_integer_options AsnInt(ub_integer_options_val) -#define ub_queue_size_val 2147483647 -#define ub_queue_size AsnInt(ub_queue_size_val) -#define ub_content_length_val 2147483647 -#define ub_content_length AsnInt(ub_content_length_val) -#define ub_password_length_val 62 -#define ub_password_length AsnInt(ub_password_length_val) -#define ub_bit_options_val 16 -#define ub_bit_options AsnInt(ub_bit_options_val) -#define ub_content_types_val 1024 -#define ub_content_types AsnInt(ub_content_types_val) -#define ub_tsap_id_length_val 16 -#define ub_tsap_id_length AsnInt(ub_tsap_id_length_val) -#define ub_recipients_val 32767 -#define ub_recipients AsnInt(ub_recipients_val) -#define ub_content_id_length_val 16 -#define ub_content_id_length AsnInt(ub_content_id_length_val) -#define ub_x121_address_length_val 15 -#define ub_x121_address_length AsnInt(ub_x121_address_length_val) -#define ub_mts_user_types_val 256 -#define ub_mts_user_types AsnInt(ub_mts_user_types_val) -#define ub_reason_codes_val 32767 -#define ub_reason_codes AsnInt(ub_reason_codes_val) -#define ub_diagnostic_codes_val 32767 -#define ub_diagnostic_codes AsnInt(ub_diagnostic_codes_val) -#define ub_supplementary_info_length_val 256 -#define ub_supplementary_info_length AsnInt(ub_supplementary_info_length_val) -#define ub_extension_types_val 256 -#define ub_extension_types AsnInt(ub_extension_types_val) -#define ub_recipient_number_for_advice_length_val 32 -#define ub_recipient_number_for_advice_length AsnInt(ub_recipient_number_for_advice_length_val) -#define ub_content_correlator_length_val 512 -#define ub_content_correlator_length AsnInt(ub_content_correlator_length_val) -#define ub_redirections_val 512 -#define ub_redirections AsnInt(ub_redirections_val) -#define ub_dl_expansions_val 512 -#define ub_dl_expansions AsnInt(ub_dl_expansions_val) -#define ub_built_in_content_type_val 32767 -#define ub_built_in_content_type AsnInt(ub_built_in_content_type_val) -#define ub_local_id_length_val 32 -#define ub_local_id_length AsnInt(ub_local_id_length_val) -#define ub_mta_name_length_val 32 -#define ub_mta_name_length AsnInt(ub_mta_name_length_val) -#define ub_country_name_numeric_length_val 3 -#define ub_country_name_numeric_length AsnInt(ub_country_name_numeric_length_val) -#define ub_country_name_alpha_length_val 2 -#define ub_country_name_alpha_length AsnInt(ub_country_name_alpha_length_val) -#define ub_domain_name_length_val 16 -#define ub_domain_name_length AsnInt(ub_domain_name_length_val) -#define ub_terminal_id_length_val 24 -#define ub_terminal_id_length AsnInt(ub_terminal_id_length_val) -#define ub_organization_name_length_val 64 -#define ub_organization_name_length AsnInt(ub_organization_name_length_val) -#define ub_numeric_user_id_length_val 32 -#define ub_numeric_user_id_length AsnInt(ub_numeric_user_id_length_val) -#define ub_surname_length_val 40 -#define ub_surname_length AsnInt(ub_surname_length_val) -#define ub_given_name_length_val 16 -#define ub_given_name_length AsnInt(ub_given_name_length_val) -#define ub_initials_length_val 5 -#define ub_initials_length AsnInt(ub_initials_length_val) -#define ub_generation_qualifier_length_val 3 -#define ub_generation_qualifier_length AsnInt(ub_generation_qualifier_length_val) -#define ub_organizational_units_val 4 -#define ub_organizational_units AsnInt(ub_organizational_units_val) -#define ub_organizational_unit_name_length_val 32 -#define ub_organizational_unit_name_length AsnInt(ub_organizational_unit_name_length_val) -#define ub_domain_defined_attributes_val 4 -#define ub_domain_defined_attributes AsnInt(ub_domain_defined_attributes_val) -#define ub_domain_defined_attribute_type_length_val 8 -#define ub_domain_defined_attribute_type_length AsnInt(ub_domain_defined_attribute_type_length_val) -#define ub_domain_defined_attribute_value_length_val 128 -#define ub_domain_defined_attribute_value_length AsnInt(ub_domain_defined_attribute_value_length_val) -#define ub_extension_attributes_val 256 -#define ub_extension_attributes AsnInt(ub_extension_attributes_val) -#define ub_common_name_length_val 64 -#define ub_common_name_length AsnInt(ub_common_name_length_val) -#define ub_pds_name_length_val 16 -#define ub_pds_name_length AsnInt(ub_pds_name_length_val) -#define ub_postal_code_length_val 16 -#define ub_postal_code_length AsnInt(ub_postal_code_length_val) -#define ub_pds_parameter_length_val 30 -#define ub_pds_parameter_length AsnInt(ub_pds_parameter_length_val) -#define ub_physical_address_lines_val 6 -#define ub_physical_address_lines AsnInt(ub_physical_address_lines_val) -#define ub_unformatted_address_length_val 180 -#define ub_unformatted_address_length AsnInt(ub_unformatted_address_length_val) -#define ub_e163_4_number_length_val 15 -#define ub_e163_4_number_length AsnInt(ub_e163_4_number_length_val) -#define ub_e163_4_sub_address_length_val 40 -#define ub_e163_4_sub_address_length AsnInt(ub_e163_4_sub_address_length_val) -#define ub_built_in_encoded_information_types_val 32 -#define ub_built_in_encoded_information_types AsnInt(ub_built_in_encoded_information_types_val) -#define ub_teletex_private_use_length_val 128 -#define ub_teletex_private_use_length AsnInt(ub_teletex_private_use_length_val) -#define ub_encoded_information_types_val 1024 -#define ub_encoded_information_types AsnInt(ub_encoded_information_types_val) -#define ub_security_labels_val 256 -#define ub_security_labels AsnInt(ub_security_labels_val) -#define ub_labels_and_redirections_val 256 -#define ub_labels_and_redirections AsnInt(ub_labels_and_redirections_val) -#define ub_security_problems_val 256 -#define ub_security_problems AsnInt(ub_security_problems_val) -#define ub_privacy_mark_length_val 128 -#define ub_privacy_mark_length AsnInt(ub_privacy_mark_length_val) -#define ub_security_categories_val 64 -#define ub_security_categories AsnInt(ub_security_categories_val) -#define ub_transfers_val 512 -#define ub_transfers AsnInt(ub_transfers_val) -#define ub_bilateral_info_val 1024 -#define ub_bilateral_info AsnInt(ub_bilateral_info_val) -#define ub_additional_info_val 1024 -#define ub_additional_info AsnInt(ub_additional_info_val) -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_x411ub.h */ diff --git a/SecurityASN1/inc/sm_x501if.h b/SecurityASN1/inc/sm_x501if.h deleted file mode 100644 index 32f3cce3..00000000 --- a/SecurityASN1/inc/sm_x501if.h +++ /dev/null @@ -1,531 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x501if.h - class definitions for ASN.1 module InformationFramework -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_x501if_h_ -#define _sm_x501if_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class AttributeTypeAndDistinguishedValueSetOfSeqSetOf; -class AttributeTypeAndDistinguishedValueSetOfSeq; -class AttributeTypeAndDistinguishedValueSetOf; -class AttributeSetOf; -class Attribute; -class AttributeTypeAndDistinguishedValue; -class RelativeDistinguishedName; -class RDNSequence; -class Attributes; -class Name; - -//------------------------------------------------------------------------------ -// class definitions: - -typedef enum InformationFrameworkAnyId -{ - -} InformationFrameworkAnyId; - - -/* OBJECT IDENTIFIER */ -typedef AsnOid AttributeType; - -/* ANY */ -typedef AsnAny AttributeValue; - -class AttributeTypeAndDistinguishedValueSetOfSeqSetOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - AsnAny *elmt; - } *first, *curr, *last; - -public: - AttributeTypeAndDistinguishedValueSetOfSeqSetOf() { count = 0; first = curr = last = NULL; } - AttributeTypeAndDistinguishedValueSetOfSeqSetOf (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &); - virtual ~AttributeTypeAndDistinguishedValueSetOfSeqSetOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeTypeAndDistinguishedValueSetOfSeqSetOf &operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - AsnAny *First() const { return count > 0 ? first->elmt : NULL; } - AsnAny *Last() const { return count > 0 ? last->elmt : NULL; } - AsnAny *Curr() const { return curr ? curr->elmt : NULL; } - AsnAny *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - AsnAny *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - AsnAny *GoNext() { if (curr) curr = curr->next; return Curr(); } - AsnAny *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - AsnAny *Append(); // add elmt to end of list - AsnAny *Prepend(); // add elmt to beginning of list - AsnAny *InsertBefore(); //insert elmt before current elmt - AsnAny *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AppendCopy (AsnAny &elmt); // add elmt to end of list - AttributeTypeAndDistinguishedValueSetOfSeqSetOf &PrependCopy (AsnAny &elmt); // add elmt to beginning of list - AttributeTypeAndDistinguishedValueSetOfSeqSetOf &InsertBeforeAndCopy (AsnAny &elmt); //insert elmt before current elmt - AttributeTypeAndDistinguishedValueSetOfSeqSetOf &InsertAfterAndCopy (AsnAny &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class AttributeTypeAndDistinguishedValueSetOfSeq: public AsnType -{ -public: - AsnOid *distingAttrValue; - AttributeTypeAndDistinguishedValueSetOfSeqSetOf contextList; - - AttributeTypeAndDistinguishedValueSetOfSeq(); - AttributeTypeAndDistinguishedValueSetOfSeq (const AttributeTypeAndDistinguishedValueSetOfSeq &); - virtual ~AttributeTypeAndDistinguishedValueSetOfSeq(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeTypeAndDistinguishedValueSetOfSeq &operator = (const AttributeTypeAndDistinguishedValueSetOfSeq &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeTypeAndDistinguishedValueSetOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - AttributeTypeAndDistinguishedValueSetOfSeq *elmt; - } *first, *curr, *last; - -public: - AttributeTypeAndDistinguishedValueSetOf() { count = 0; first = curr = last = NULL; } - AttributeTypeAndDistinguishedValueSetOf (const AttributeTypeAndDistinguishedValueSetOf &); - virtual ~AttributeTypeAndDistinguishedValueSetOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeTypeAndDistinguishedValueSetOf &operator = (const AttributeTypeAndDistinguishedValueSetOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - AttributeTypeAndDistinguishedValueSetOfSeq *First() const { return count > 0 ? first->elmt : NULL; } - AttributeTypeAndDistinguishedValueSetOfSeq *Last() const { return count > 0 ? last->elmt : NULL; } - AttributeTypeAndDistinguishedValueSetOfSeq *Curr() const { return curr ? curr->elmt : NULL; } - AttributeTypeAndDistinguishedValueSetOfSeq *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - AttributeTypeAndDistinguishedValueSetOfSeq *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - AttributeTypeAndDistinguishedValueSetOfSeq *GoNext() { if (curr) curr = curr->next; return Curr(); } - AttributeTypeAndDistinguishedValueSetOfSeq *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - AttributeTypeAndDistinguishedValueSetOfSeq *Append(); // add elmt to end of list - AttributeTypeAndDistinguishedValueSetOfSeq *Prepend(); // add elmt to beginning of list - AttributeTypeAndDistinguishedValueSetOfSeq *InsertBefore(); //insert elmt before current elmt - AttributeTypeAndDistinguishedValueSetOfSeq *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - AttributeTypeAndDistinguishedValueSetOf &AppendCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt); // add elmt to end of list - AttributeTypeAndDistinguishedValueSetOf &PrependCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt); // add elmt to beginning of list - AttributeTypeAndDistinguishedValueSetOf &InsertBeforeAndCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt); //insert elmt before current elmt - AttributeTypeAndDistinguishedValueSetOf &InsertAfterAndCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class AttributeSetOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - AttributeValue *elmt; - } *first, *curr, *last; - -public: - AttributeSetOf() { count = 0; first = curr = last = NULL; } - AttributeSetOf (const AttributeSetOf &); - virtual ~AttributeSetOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeSetOf &operator = (const AttributeSetOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - AttributeValue *First() const { return count > 0 ? first->elmt : NULL; } - AttributeValue *Last() const { return count > 0 ? last->elmt : NULL; } - AttributeValue *Curr() const { return curr ? curr->elmt : NULL; } - AttributeValue *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - AttributeValue *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - AttributeValue *GoNext() { if (curr) curr = curr->next; return Curr(); } - AttributeValue *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - AttributeValue *Append(); // add elmt to end of list - AttributeValue *Prepend(); // add elmt to beginning of list - AttributeValue *InsertBefore(); //insert elmt before current elmt - AttributeValue *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - AttributeSetOf &AppendCopy (AttributeValue &elmt); // add elmt to end of list - AttributeSetOf &PrependCopy (AttributeValue &elmt); // add elmt to beginning of list - AttributeSetOf &InsertBeforeAndCopy (AttributeValue &elmt); //insert elmt before current elmt - AttributeSetOf &InsertAfterAndCopy (AttributeValue &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class Attribute: public AsnType -{ -public: - AttributeType type; - AttributeSetOf values; - - Attribute(); - Attribute (const Attribute &); - virtual ~Attribute(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Attribute &operator = (const Attribute &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeTypeAndDistinguishedValue: public AsnType -{ -public: - AsnOid type; - AsnAny value; - AsnBool *primaryDistinguished; - AttributeTypeAndDistinguishedValueSetOf *valuesWithContext; - - AttributeTypeAndDistinguishedValue(); - AttributeTypeAndDistinguishedValue (const AttributeTypeAndDistinguishedValue &); - virtual ~AttributeTypeAndDistinguishedValue(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeTypeAndDistinguishedValue &operator = (const AttributeTypeAndDistinguishedValue &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class RelativeDistinguishedName: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - AttributeTypeAndDistinguishedValue *elmt; - } *first, *curr, *last; - -public: - RelativeDistinguishedName() { count = 0; first = curr = last = NULL; } - RelativeDistinguishedName (const RelativeDistinguishedName &); - virtual ~RelativeDistinguishedName(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RelativeDistinguishedName &operator = (const RelativeDistinguishedName &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - AttributeTypeAndDistinguishedValue *First() const { return count > 0 ? first->elmt : NULL; } - AttributeTypeAndDistinguishedValue *Last() const { return count > 0 ? last->elmt : NULL; } - AttributeTypeAndDistinguishedValue *Curr() const { return curr ? curr->elmt : NULL; } - AttributeTypeAndDistinguishedValue *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - AttributeTypeAndDistinguishedValue *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - AttributeTypeAndDistinguishedValue *GoNext() { if (curr) curr = curr->next; return Curr(); } - AttributeTypeAndDistinguishedValue *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - AttributeTypeAndDistinguishedValue *Append(); // add elmt to end of list - AttributeTypeAndDistinguishedValue *Prepend(); // add elmt to beginning of list - AttributeTypeAndDistinguishedValue *InsertBefore(); //insert elmt before current elmt - AttributeTypeAndDistinguishedValue *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - RelativeDistinguishedName &AppendCopy (AttributeTypeAndDistinguishedValue &elmt); // add elmt to end of list - RelativeDistinguishedName &PrependCopy (AttributeTypeAndDistinguishedValue &elmt); // add elmt to beginning of list - RelativeDistinguishedName &InsertBeforeAndCopy (AttributeTypeAndDistinguishedValue &elmt); //insert elmt before current elmt - RelativeDistinguishedName &InsertAfterAndCopy (AttributeTypeAndDistinguishedValue &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class RDNSequence: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - RelativeDistinguishedName *elmt; - } *first, *curr, *last; - -public: - RDNSequence() { count = 0; first = curr = last = NULL; } - RDNSequence (const RDNSequence &); - virtual ~RDNSequence(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - RDNSequence &operator = (const RDNSequence &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - RelativeDistinguishedName *First() const { return count > 0 ? first->elmt : NULL; } - RelativeDistinguishedName *Last() const { return count > 0 ? last->elmt : NULL; } - RelativeDistinguishedName *Curr() const { return curr ? curr->elmt : NULL; } - RelativeDistinguishedName *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - RelativeDistinguishedName *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - RelativeDistinguishedName *GoNext() { if (curr) curr = curr->next; return Curr(); } - RelativeDistinguishedName *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - RelativeDistinguishedName *Append(); // add elmt to end of list - RelativeDistinguishedName *Prepend(); // add elmt to beginning of list - RelativeDistinguishedName *InsertBefore(); //insert elmt before current elmt - RelativeDistinguishedName *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - RDNSequence &AppendCopy (RelativeDistinguishedName &elmt); // add elmt to end of list - RDNSequence &PrependCopy (RelativeDistinguishedName &elmt); // add elmt to beginning of list - RDNSequence &InsertBeforeAndCopy (RelativeDistinguishedName &elmt); //insert elmt before current elmt - RDNSequence &InsertAfterAndCopy (RelativeDistinguishedName &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class Attributes: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - Attribute *elmt; - } *first, *curr, *last; - -public: - Attributes() { count = 0; first = curr = last = NULL; } - Attributes (const Attributes &); - virtual ~Attributes(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Attributes &operator = (const Attributes &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - Attribute *First() const { return count > 0 ? first->elmt : NULL; } - Attribute *Last() const { return count > 0 ? last->elmt : NULL; } - Attribute *Curr() const { return curr ? curr->elmt : NULL; } - Attribute *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - Attribute *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - Attribute *GoNext() { if (curr) curr = curr->next; return Curr(); } - Attribute *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - Attribute *Append(); // add elmt to end of list - Attribute *Prepend(); // add elmt to beginning of list - Attribute *InsertBefore(); //insert elmt before current elmt - Attribute *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - Attributes &AppendCopy (Attribute &elmt); // add elmt to end of list - Attributes &PrependCopy (Attribute &elmt); // add elmt to beginning of list - Attributes &InsertBeforeAndCopy (Attribute &elmt); //insert elmt before current elmt - Attributes &InsertAfterAndCopy (Attribute &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class Name: public AsnType -{ -public: - enum ChoiceIdEnum - { - rDNSequenceCid = 0 - }; - - enum ChoiceIdEnum choiceId; - union - { - RDNSequence *rDNSequence; - }; - - - Name(); - Name (const Name &); - virtual ~Name(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Name &operator = (const Name &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* RDNSequence */ -typedef RDNSequence DistinguishedName; - -//------------------------------------------------------------------------------ -// externs for value defs - -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_x501if.h */ diff --git a/SecurityASN1/inc/sm_x501ud.h b/SecurityASN1/inc/sm_x501ud.h deleted file mode 100644 index 3e035db3..00000000 --- a/SecurityASN1/inc/sm_x501ud.h +++ /dev/null @@ -1,133 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x501ud.h - class definitions for ASN.1 module UsefulDefinitions -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_x501ud_h_ -#define _sm_x501ud_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - - -//------------------------------------------------------------------------------ -// class definitions: - -//------------------------------------------------------------------------------ -// externs for value defs - -#define ds_arc 2, 5 -#define ds AsnOid(ds_arc) -#define module_arc 2, 5, 1 -#define module AsnOid(module_arc) -#define serviceElement_arc 2, 5, 2 -#define serviceElement AsnOid(serviceElement_arc) -#define applicationContext_arc 2, 5, 3 -#define applicationContext AsnOid(applicationContext_arc) -#define attributeType_arc 2, 5, 4 -#define attributeType AsnOid(attributeType_arc) -#define attributeSyntax_arc 2, 5, 5 -#define attributeSyntax AsnOid(attributeSyntax_arc) -#define objectClass_arc 2, 5, 6 -#define objectClass AsnOid(objectClass_arc) -#define dsAlgorithm_arc 2, 5, 8 -#define dsAlgorithm AsnOid(dsAlgorithm_arc) -#define abstractSyntax_arc 2, 5, 9 -#define abstractSyntax AsnOid(abstractSyntax_arc) -#define dsaOperationalAttribute_arc 2, 5, 12 -#define dsaOperationalAttribute AsnOid(dsaOperationalAttribute_arc) -#define matchingRule_arc 2, 5, 13 -#define matchingRule AsnOid(matchingRule_arc) -#define knowledgeMatchingRule_arc 2, 5, 14 -#define knowledgeMatchingRule AsnOid(knowledgeMatchingRule_arc) -#define nameForm_arc 2, 5, 15 -#define nameForm AsnOid(nameForm_arc) -#define group_arc 2, 5, 16 -#define group AsnOid(group_arc) -#define subentry_arc 2, 5, 17 -#define subentry AsnOid(subentry_arc) -#define operationalAttributeType_arc 2, 5, 18 -#define operationalAttributeType AsnOid(operationalAttributeType_arc) -#define operationalBinding_arc 2, 5, 19 -#define operationalBinding AsnOid(operationalBinding_arc) -#define schemaObjectClass_arc 2, 5, 20 -#define schemaObjectClass AsnOid(schemaObjectClass_arc) -#define schemaOperationalAttribute_arc 2, 5, 21 -#define schemaOperationalAttribute AsnOid(schemaOperationalAttribute_arc) -#define administrativeRoles_arc 2, 5, 23 -#define administrativeRoles AsnOid(administrativeRoles_arc) -#define accessControlAttribute_arc 2, 5, 24 -#define accessControlAttribute AsnOid(accessControlAttribute_arc) -#define rosObject_arc 2, 5, 25 -#define rosObject AsnOid(rosObject_arc) -#define contract_arc 2, 5, 26 -#define contract AsnOid(contract_arc) -#define package_arc 2, 5, 27 -#define package AsnOid(package_arc) -#define accessControlSchemes_arc 2, 5, 28 -#define accessControlSchemes AsnOid(accessControlSchemes_arc) -#define certificateExtension_arc 2, 5, 29 -#define certificateExtension AsnOid(certificateExtension_arc) -#define managementObject_arc 2, 5, 30 -#define managementObject AsnOid(managementObject_arc) -#define informationFramework_arc 2, 5, 1, 1, 3 -#define informationFramework AsnOid(informationFramework_arc) -#define directoryAbstractService_arc 2, 5, 1, 2, 3 -#define directoryAbstractService AsnOid(directoryAbstractService_arc) -#define distributedOperations_arc 2, 5, 1, 3, 3 -#define distributedOperations AsnOid(distributedOperations_arc) -#define protocolObjectIdentifiers_arc 2, 5, 1, 4, 3 -#define protocolObjectIdentifiers AsnOid(protocolObjectIdentifiers_arc) -#define selectedAttributeTypes_arc 2, 5, 1, 5, 3 -#define selectedAttributeTypes AsnOid(selectedAttributeTypes_arc) -#define selectedObjectClasses_arc 2, 5, 1, 6, 3 -#define selectedObjectClasses AsnOid(selectedObjectClasses_arc) -#define authenticationFramework_arc 2, 5, 1, 7, 3 -#define authenticationFramework AsnOid(authenticationFramework_arc) -#define algorithmObjectIdentifiers_arc 2, 5, 1, 8, 3 -#define algorithmObjectIdentifiers AsnOid(algorithmObjectIdentifiers_arc) -#define directoryObjectIdentifiers_arc 2, 5, 1, 9, 3 -#define directoryObjectIdentifiers AsnOid(directoryObjectIdentifiers_arc) -#define upperBounds_arc 2, 5, 1, 10, 3 -#define upperBounds AsnOid(upperBounds_arc) -#define dap_arc 2, 5, 1, 11, 3 -#define dap AsnOid(dap_arc) -#define dsp_arc 2, 5, 1, 12, 3 -#define dsp AsnOid(dsp_arc) -#define distributedDirectoryOIDs_arc 2, 5, 1, 13, 3 -#define distributedDirectoryOIDs AsnOid(distributedDirectoryOIDs_arc) -#define directoryShadowOIDs_arc 2, 5, 1, 14, 3 -#define directoryShadowOIDs AsnOid(directoryShadowOIDs_arc) -#define directoryShadowAbstractService_arc 2, 5, 1, 15, 3 -#define directoryShadowAbstractService AsnOid(directoryShadowAbstractService_arc) -#define disp_arc 2, 5, 1, 16, 3 -#define disp AsnOid(disp_arc) -#define dop_arc 2, 5, 1, 17, 3 -#define dop AsnOid(dop_arc) -#define opBindingManagement_arc 2, 5, 1, 18, 3 -#define opBindingManagement AsnOid(opBindingManagement_arc) -#define opBindingOIDs_arc 2, 5, 1, 19, 3 -#define opBindingOIDs AsnOid(opBindingOIDs_arc) -#define hierarchicalOperationalBindings_arc 2, 5, 1, 20, 3 -#define hierarchicalOperationalBindings AsnOid(hierarchicalOperationalBindings_arc) -#define dsaOperationalAttributeTypes_arc 2, 5, 1, 22, 3 -#define dsaOperationalAttributeTypes AsnOid(dsaOperationalAttributeTypes_arc) -#define schemaAdministration_arc 2, 5, 1, 23, 3 -#define schemaAdministration AsnOid(schemaAdministration_arc) -#define basicAccessControl_arc 2, 5, 1, 24, 3 -#define basicAccessControl AsnOid(basicAccessControl_arc) -#define directoryOperationalBindingTypes_arc 2, 5, 1, 25, 3 -#define directoryOperationalBindingTypes AsnOid(directoryOperationalBindingTypes_arc) -#define certificateExtensions_arc 2, 5, 1, 26, 0 -#define certificateExtensions AsnOid(certificateExtensions_arc) -#define directoryManagement_arc 2, 5, 1, 27, 1 -#define directoryManagement AsnOid(directoryManagement_arc) -#define enhancedSecurity_arc 2, 5, 1, 28 -#define enhancedSecurity AsnOid(enhancedSecurity_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_x501ud.h */ diff --git a/SecurityASN1/inc/sm_x509af.h b/SecurityASN1/inc/sm_x509af.h deleted file mode 100644 index 586583ad..00000000 --- a/SecurityASN1/inc/sm_x509af.h +++ /dev/null @@ -1,1186 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x509af.h - class definitions for ASN.1 module AuthenticationFramework -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_x509af_h_ -#define _sm_x509af_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class Version; -class AttributeCertificateAssertionSetOf; -class AttributeCertificateInfoSeqOf; -class AlgorithmIdentifier; -class Time; -class Extension; -class AttCertValidityPeriod; -class Validity; -class SubjectPublicKeyInfo; -class Extensions; -class IssuerSerial; -class AttributeCertificateAssertionChoice; -class AttributeCertificateInfoChoice; -class CRLToSignSeqOfSeq; -class CRLToSignSeqOf; -class CertificateToSign; -class CRLToSign; -class AttributeCertificateInfo; -class Certificate; -class CrossCertificates; -class CertificatePair; -class CertificateList; -class AttributeCertificate; -class CertificationPathSeqOf; -class ForwardCertificationPath; -class ACPathData; -class AttributeCertificationPathSeqOf; -class Certificates; -class CertificationPath; -class AttributeCertificationPath; -class AttributeCertificateAssertion; - -//------------------------------------------------------------------------------ -// class definitions: - -typedef enum AuthenticationFrameworkAnyId -{ - -} AuthenticationFrameworkAnyId; - - -/* INTEGER { v1 (0), v2 (1), v3 (2) } */ -class Version: public AsnInt -{ -public: - Version(): AsnInt() {} - Version (int i): AsnInt (i) {} - enum - { - v1 = 0, - v2 = 1, - v3 = 2 - }; -}; - - -/* OCTET STRING (SIZE (0..ub-password-length)) */ -typedef AsnOcts UserPassword; - -class AttributeCertificateAssertionSetOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - AttributeType *elmt; - } *first, *curr, *last; - -public: - AttributeCertificateAssertionSetOf() { count = 0; first = curr = last = NULL; } - AttributeCertificateAssertionSetOf (const AttributeCertificateAssertionSetOf &); - virtual ~AttributeCertificateAssertionSetOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificateAssertionSetOf &operator = (const AttributeCertificateAssertionSetOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - AttributeType *First() const { return count > 0 ? first->elmt : NULL; } - AttributeType *Last() const { return count > 0 ? last->elmt : NULL; } - AttributeType *Curr() const { return curr ? curr->elmt : NULL; } - AttributeType *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - AttributeType *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - AttributeType *GoNext() { if (curr) curr = curr->next; return Curr(); } - AttributeType *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - AttributeType *Append(); // add elmt to end of list - AttributeType *Prepend(); // add elmt to beginning of list - AttributeType *InsertBefore(); //insert elmt before current elmt - AttributeType *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - AttributeCertificateAssertionSetOf &AppendCopy (AttributeType &elmt); // add elmt to end of list - AttributeCertificateAssertionSetOf &PrependCopy (AttributeType &elmt); // add elmt to beginning of list - AttributeCertificateAssertionSetOf &InsertBeforeAndCopy (AttributeType &elmt); //insert elmt before current elmt - AttributeCertificateAssertionSetOf &InsertAfterAndCopy (AttributeType &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class AttributeCertificateInfoSeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - Attribute *elmt; - } *first, *curr, *last; - -public: - AttributeCertificateInfoSeqOf() { count = 0; first = curr = last = NULL; } - AttributeCertificateInfoSeqOf (const AttributeCertificateInfoSeqOf &); - virtual ~AttributeCertificateInfoSeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificateInfoSeqOf &operator = (const AttributeCertificateInfoSeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - Attribute *First() const { return count > 0 ? first->elmt : NULL; } - Attribute *Last() const { return count > 0 ? last->elmt : NULL; } - Attribute *Curr() const { return curr ? curr->elmt : NULL; } - Attribute *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - Attribute *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - Attribute *GoNext() { if (curr) curr = curr->next; return Curr(); } - Attribute *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - Attribute *Append(); // add elmt to end of list - Attribute *Prepend(); // add elmt to beginning of list - Attribute *InsertBefore(); //insert elmt before current elmt - Attribute *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - AttributeCertificateInfoSeqOf &AppendCopy (Attribute &elmt); // add elmt to end of list - AttributeCertificateInfoSeqOf &PrependCopy (Attribute &elmt); // add elmt to beginning of list - AttributeCertificateInfoSeqOf &InsertBeforeAndCopy (Attribute &elmt); //insert elmt before current elmt - AttributeCertificateInfoSeqOf &InsertAfterAndCopy (Attribute &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -/* BigIntegerStr */ -typedef BigIntegerStr CertificateSerialNumber; - -class AlgorithmIdentifier: public AsnType -{ -public: - AsnOid algorithm; - AsnAny *parameters; - - AlgorithmIdentifier(); - AlgorithmIdentifier (const AlgorithmIdentifier &); - virtual ~AlgorithmIdentifier(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AlgorithmIdentifier &operator = (const AlgorithmIdentifier &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class Time: public AsnType -{ -public: - enum ChoiceIdEnum - { - utcTimeCid = 0, - generalizedTimeCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - UTCTime *utcTime; - GeneralizedTime *generalizedTime; - }; - - - Time(); - Time (const Time &); - virtual ~Time(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Time &operator = (const Time &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class Extension: public AsnType -{ -public: - AsnOid extnId; - AsnBool *critical; - AsnOcts extnValue; - - Extension(); - Extension (const Extension &); - virtual ~Extension(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Extension &operator = (const Extension &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttCertValidityPeriod: public AsnType -{ -public: - GeneralizedTime notBeforeTime; - GeneralizedTime notAfterTime; - - AttCertValidityPeriod(); - AttCertValidityPeriod (const AttCertValidityPeriod &); - virtual ~AttCertValidityPeriod(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttCertValidityPeriod &operator = (const AttCertValidityPeriod &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class Validity: public AsnType -{ -public: - Time *notBefore; - Time *notAfter; - - Validity(); - Validity (const Validity &); - virtual ~Validity(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Validity &operator = (const Validity &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class SubjectPublicKeyInfo: public AsnType -{ -public: - AlgorithmIdentifier *algorithm; - AsnBits subjectPublicKey; - - SubjectPublicKeyInfo(); - SubjectPublicKeyInfo (const SubjectPublicKeyInfo &); - virtual ~SubjectPublicKeyInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SubjectPublicKeyInfo &operator = (const SubjectPublicKeyInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class Extensions: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - Extension *elmt; - } *first, *curr, *last; - -public: - Extensions() { count = 0; first = curr = last = NULL; } - Extensions (const Extensions &); - virtual ~Extensions(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Extensions &operator = (const Extensions &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - Extension *First() const { return count > 0 ? first->elmt : NULL; } - Extension *Last() const { return count > 0 ? last->elmt : NULL; } - Extension *Curr() const { return curr ? curr->elmt : NULL; } - Extension *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - Extension *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - Extension *GoNext() { if (curr) curr = curr->next; return Curr(); } - Extension *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - Extension *Append(); // add elmt to end of list - Extension *Prepend(); // add elmt to beginning of list - Extension *InsertBefore(); //insert elmt before current elmt - Extension *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - Extensions &AppendCopy (Extension &elmt); // add elmt to end of list - Extensions &PrependCopy (Extension &elmt); // add elmt to beginning of list - Extensions &InsertBeforeAndCopy (Extension &elmt); //insert elmt before current elmt - Extensions &InsertAfterAndCopy (Extension &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class IssuerSerial: public AsnType -{ -public: - GeneralNames issuer; - CertificateSerialNumber serial; - UniqueIdentifier *issuerUID; - - IssuerSerial(); - IssuerSerial (const IssuerSerial &); - virtual ~IssuerSerial(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - IssuerSerial &operator = (const IssuerSerial &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeCertificateAssertionChoice: public AsnType -{ -public: - enum ChoiceIdEnum - { - baseCertificateIDCid = 0, - subjectNameCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - IssuerSerial *baseCertificateID; - Name *subjectName; - }; - - - AttributeCertificateAssertionChoice(); - AttributeCertificateAssertionChoice (const AttributeCertificateAssertionChoice &); - virtual ~AttributeCertificateAssertionChoice(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificateAssertionChoice &operator = (const AttributeCertificateAssertionChoice &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeCertificateInfoChoice: public AsnType -{ -public: - enum ChoiceIdEnum - { - baseCertificateIDCid = 0, - subjectNameCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - IssuerSerial *baseCertificateID; - GeneralNames *subjectName; - }; - - - AttributeCertificateInfoChoice(); - AttributeCertificateInfoChoice (const AttributeCertificateInfoChoice &); - virtual ~AttributeCertificateInfoChoice(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificateInfoChoice &operator = (const AttributeCertificateInfoChoice &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CRLToSignSeqOfSeq: public AsnType -{ -public: - CertificateSerialNumber userCertificate; - Time *revocationDate; - Extensions *crlEntryExtensions; - - CRLToSignSeqOfSeq(); - CRLToSignSeqOfSeq (const CRLToSignSeqOfSeq &); - virtual ~CRLToSignSeqOfSeq(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CRLToSignSeqOfSeq &operator = (const CRLToSignSeqOfSeq &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CRLToSignSeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - CRLToSignSeqOfSeq *elmt; - } *first, *curr, *last; - -public: - CRLToSignSeqOf() { count = 0; first = curr = last = NULL; } - CRLToSignSeqOf (const CRLToSignSeqOf &); - virtual ~CRLToSignSeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CRLToSignSeqOf &operator = (const CRLToSignSeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - CRLToSignSeqOfSeq *First() const { return count > 0 ? first->elmt : NULL; } - CRLToSignSeqOfSeq *Last() const { return count > 0 ? last->elmt : NULL; } - CRLToSignSeqOfSeq *Curr() const { return curr ? curr->elmt : NULL; } - CRLToSignSeqOfSeq *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - CRLToSignSeqOfSeq *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - CRLToSignSeqOfSeq *GoNext() { if (curr) curr = curr->next; return Curr(); } - CRLToSignSeqOfSeq *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - CRLToSignSeqOfSeq *Append(); // add elmt to end of list - CRLToSignSeqOfSeq *Prepend(); // add elmt to beginning of list - CRLToSignSeqOfSeq *InsertBefore(); //insert elmt before current elmt - CRLToSignSeqOfSeq *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - CRLToSignSeqOf &AppendCopy (CRLToSignSeqOfSeq &elmt); // add elmt to end of list - CRLToSignSeqOf &PrependCopy (CRLToSignSeqOfSeq &elmt); // add elmt to beginning of list - CRLToSignSeqOf &InsertBeforeAndCopy (CRLToSignSeqOfSeq &elmt); //insert elmt before current elmt - CRLToSignSeqOf &InsertAfterAndCopy (CRLToSignSeqOfSeq &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class CertificateToSign: public AsnType -{ -public: - Version *version; - CertificateSerialNumber serialNumber; - AlgorithmIdentifier *signature; - Name *issuer; - Validity *validity; - Name *subject; - SubjectPublicKeyInfo *subjectPublicKeyInfo; - UniqueIdentifier *issuerUniqueIdentifier; - UniqueIdentifier *subjectUniqueIdentifier; - Extensions *extensions; - - CertificateToSign(); - CertificateToSign (const CertificateToSign &); - virtual ~CertificateToSign(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificateToSign &operator = (const CertificateToSign &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CRLToSign: public AsnType -{ -public: - Version *version; - AlgorithmIdentifier *signature; - Name *issuer; - Time *thisUpdate; - Time *nextUpdate; - CRLToSignSeqOf *revokedCertificates; - Extensions *crlExtensions; - - CRLToSign(); - CRLToSign (const CRLToSign &); - virtual ~CRLToSign(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CRLToSign &operator = (const CRLToSign &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeCertificateInfo: public AsnType -{ -public: - Version *version; - AttributeCertificateInfoChoice *subject; - GeneralNames issuer; - AlgorithmIdentifier *signature; - CertificateSerialNumber serialNumber; - AttCertValidityPeriod *attCertValidityPeriod; - AttributeCertificateInfoSeqOf attributes; - UniqueIdentifier *issuerUniqueID; - Extensions *extensions; - - AttributeCertificateInfo(); - AttributeCertificateInfo (const AttributeCertificateInfo &); - virtual ~AttributeCertificateInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificateInfo &operator = (const AttributeCertificateInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class Certificate: public AsnType -{ -public: - CertificateToSign *certificateToSign; - AlgorithmIdentifier *algorithmIdentifier; - AsnBits signatureValue; - - Certificate(); - Certificate (const Certificate &); - virtual ~Certificate(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Certificate &operator = (const Certificate &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CrossCertificates: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - Certificate *elmt; - } *first, *curr, *last; - -public: - CrossCertificates() { count = 0; first = curr = last = NULL; } - CrossCertificates (const CrossCertificates &); - virtual ~CrossCertificates(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CrossCertificates &operator = (const CrossCertificates &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - Certificate *First() const { return count > 0 ? first->elmt : NULL; } - Certificate *Last() const { return count > 0 ? last->elmt : NULL; } - Certificate *Curr() const { return curr ? curr->elmt : NULL; } - Certificate *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - Certificate *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - Certificate *GoNext() { if (curr) curr = curr->next; return Curr(); } - Certificate *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - Certificate *Append(); // add elmt to end of list - Certificate *Prepend(); // add elmt to beginning of list - Certificate *InsertBefore(); //insert elmt before current elmt - Certificate *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - CrossCertificates &AppendCopy (Certificate &elmt); // add elmt to end of list - CrossCertificates &PrependCopy (Certificate &elmt); // add elmt to beginning of list - CrossCertificates &InsertBeforeAndCopy (Certificate &elmt); //insert elmt before current elmt - CrossCertificates &InsertAfterAndCopy (Certificate &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class CertificatePair: public AsnType -{ -public: - Certificate *forward; - Certificate *reverse; - - CertificatePair(); - CertificatePair (const CertificatePair &); - virtual ~CertificatePair(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificatePair &operator = (const CertificatePair &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertificateList: public AsnType -{ -public: - CRLToSign *crlToSign; - AlgorithmIdentifier *algorithmIdentifier; - AsnBits signatureValue; - - CertificateList(); - CertificateList (const CertificateList &); - virtual ~CertificateList(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificateList &operator = (const CertificateList &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeCertificate: public AsnType -{ -public: - AttributeCertificateInfo *attributeCertificateInfo; - AlgorithmIdentifier *algorithmIdentifier; - AsnBits signatureValue; - - AttributeCertificate(); - AttributeCertificate (const AttributeCertificate &); - virtual ~AttributeCertificate(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificate &operator = (const AttributeCertificate &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertificationPathSeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - CertificatePair *elmt; - } *first, *curr, *last; - -public: - CertificationPathSeqOf() { count = 0; first = curr = last = NULL; } - CertificationPathSeqOf (const CertificationPathSeqOf &); - virtual ~CertificationPathSeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificationPathSeqOf &operator = (const CertificationPathSeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - CertificatePair *First() const { return count > 0 ? first->elmt : NULL; } - CertificatePair *Last() const { return count > 0 ? last->elmt : NULL; } - CertificatePair *Curr() const { return curr ? curr->elmt : NULL; } - CertificatePair *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - CertificatePair *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - CertificatePair *GoNext() { if (curr) curr = curr->next; return Curr(); } - CertificatePair *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - CertificatePair *Append(); // add elmt to end of list - CertificatePair *Prepend(); // add elmt to beginning of list - CertificatePair *InsertBefore(); //insert elmt before current elmt - CertificatePair *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - CertificationPathSeqOf &AppendCopy (CertificatePair &elmt); // add elmt to end of list - CertificationPathSeqOf &PrependCopy (CertificatePair &elmt); // add elmt to beginning of list - CertificationPathSeqOf &InsertBeforeAndCopy (CertificatePair &elmt); //insert elmt before current elmt - CertificationPathSeqOf &InsertAfterAndCopy (CertificatePair &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class ForwardCertificationPath: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - CrossCertificates *elmt; - } *first, *curr, *last; - -public: - ForwardCertificationPath() { count = 0; first = curr = last = NULL; } - ForwardCertificationPath (const ForwardCertificationPath &); - virtual ~ForwardCertificationPath(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ForwardCertificationPath &operator = (const ForwardCertificationPath &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - CrossCertificates *First() const { return count > 0 ? first->elmt : NULL; } - CrossCertificates *Last() const { return count > 0 ? last->elmt : NULL; } - CrossCertificates *Curr() const { return curr ? curr->elmt : NULL; } - CrossCertificates *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - CrossCertificates *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - CrossCertificates *GoNext() { if (curr) curr = curr->next; return Curr(); } - CrossCertificates *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - CrossCertificates *Append(); // add elmt to end of list - CrossCertificates *Prepend(); // add elmt to beginning of list - CrossCertificates *InsertBefore(); //insert elmt before current elmt - CrossCertificates *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - ForwardCertificationPath &AppendCopy (CrossCertificates &elmt); // add elmt to end of list - ForwardCertificationPath &PrependCopy (CrossCertificates &elmt); // add elmt to beginning of list - ForwardCertificationPath &InsertBeforeAndCopy (CrossCertificates &elmt); //insert elmt before current elmt - ForwardCertificationPath &InsertAfterAndCopy (CrossCertificates &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class ACPathData: public AsnType -{ -public: - Certificate *certificate; - AttributeCertificate *attributeCertificate; - - ACPathData(); - ACPathData (const ACPathData &); - virtual ~ACPathData(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ACPathData &operator = (const ACPathData &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeCertificationPathSeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - ACPathData *elmt; - } *first, *curr, *last; - -public: - AttributeCertificationPathSeqOf() { count = 0; first = curr = last = NULL; } - AttributeCertificationPathSeqOf (const AttributeCertificationPathSeqOf &); - virtual ~AttributeCertificationPathSeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificationPathSeqOf &operator = (const AttributeCertificationPathSeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - ACPathData *First() const { return count > 0 ? first->elmt : NULL; } - ACPathData *Last() const { return count > 0 ? last->elmt : NULL; } - ACPathData *Curr() const { return curr ? curr->elmt : NULL; } - ACPathData *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - ACPathData *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - ACPathData *GoNext() { if (curr) curr = curr->next; return Curr(); } - ACPathData *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - ACPathData *Append(); // add elmt to end of list - ACPathData *Prepend(); // add elmt to beginning of list - ACPathData *InsertBefore(); //insert elmt before current elmt - ACPathData *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - AttributeCertificationPathSeqOf &AppendCopy (ACPathData &elmt); // add elmt to end of list - AttributeCertificationPathSeqOf &PrependCopy (ACPathData &elmt); // add elmt to beginning of list - AttributeCertificationPathSeqOf &InsertBeforeAndCopy (ACPathData &elmt); //insert elmt before current elmt - AttributeCertificationPathSeqOf &InsertAfterAndCopy (ACPathData &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class Certificates: public AsnType -{ -public: - Certificate *userCertificate; - ForwardCertificationPath *certificationPath; - - Certificates(); - Certificates (const Certificates &); - virtual ~Certificates(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - Certificates &operator = (const Certificates &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertificationPath: public AsnType -{ -public: - Certificate *userCertificate; - CertificationPathSeqOf *theCACertificates; - - CertificationPath(); - CertificationPath (const CertificationPath &); - virtual ~CertificationPath(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificationPath &operator = (const CertificationPath &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeCertificationPath: public AsnType -{ -public: - AttributeCertificate *attributeCertificate; - AttributeCertificationPathSeqOf *acPath; - - AttributeCertificationPath(); - AttributeCertificationPath (const AttributeCertificationPath &); - virtual ~AttributeCertificationPath(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificationPath &operator = (const AttributeCertificationPath &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributeCertificateAssertion: public AsnType -{ -public: - AttributeCertificateAssertionChoice *subject; - Name *issuer; - GeneralizedTime *attCertValidity; - AttributeCertificateAssertionSetOf *attType; - - AttributeCertificateAssertion(); - AttributeCertificateAssertion (const AttributeCertificateAssertion &); - virtual ~AttributeCertificateAssertion(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributeCertificateAssertion &operator = (const AttributeCertificateAssertion &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* Certificate */ -typedef Certificate UserCertificate; - -/* Certificate */ -typedef Certificate CACertificate; - -/* CertificatePair */ -typedef CertificatePair CrossCertificatePair; - -/* CertificateList */ -typedef CertificateList AuthorityRevocationList; - -/* CertificateList */ -typedef CertificateList CertificateRevocationList; - -/* CertificateList */ -typedef CertificateList AttributeCertificateRevocationList; - -//------------------------------------------------------------------------------ -// externs for value defs - -#define id_at_userPassword_arc 2, 5, 4, 35 -#define id_at_userPassword AsnOid(id_at_userPassword_arc) -#define id_at_userCertificate_arc 2, 5, 4, 36 -#define id_at_userCertificate AsnOid(id_at_userCertificate_arc) -#define id_at_cAcertificate_arc 2, 5, 4, 37 -#define id_at_cAcertificate AsnOid(id_at_cAcertificate_arc) -#define id_at_authorityRevocationList_arc 2, 5, 4, 38 -#define id_at_authorityRevocationList AsnOid(id_at_authorityRevocationList_arc) -#define id_at_certificateRevocationList_arc 2, 5, 4, 39 -#define id_at_certificateRevocationList AsnOid(id_at_certificateRevocationList_arc) -#define id_at_crossCertificatePair_arc 2, 5, 4, 40 -#define id_at_crossCertificatePair AsnOid(id_at_crossCertificatePair_arc) -#define id_at_attributeCertificate_arc 2, 5, 4, 58 -#define id_at_attributeCertificate AsnOid(id_at_attributeCertificate_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_x509af.h */ diff --git a/SecurityASN1/inc/sm_x509ce.h b/SecurityASN1/inc/sm_x509ce.h deleted file mode 100644 index 918ed70a..00000000 --- a/SecurityASN1/inc/sm_x509ce.h +++ /dev/null @@ -1,1059 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x509ce.h - class definitions for ASN.1 module CertificateExtensions -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_x509ce_h_ -#define _sm_x509ce_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class KeyUsage; -class CRLReason; -class ReasonFlags; -class PolicyQualifierInfo; -class AttributesSyntax; -class DistributionPointName; -class PolicyMappingsSyntaxSeq; -class PolicyInformationSeqOf; -class PolicyInformation; -class GeneralSubtree; -class DistributionPoint; -class CertificatePoliciesSyntax; -class GeneralSubtrees; -class AuthorityKeyIdentifier; -class ExtKeyUsageSyntax; -class PrivateKeyUsagePeriod; -class PolicyMappingsSyntax; -class SupportedAlgorithm; -class BasicConstraintsSyntax; -class NameConstraintsSyntax; -class PolicyConstraintsSyntax; -class CertPolicySet; -class CRLDistPointsSyntax; -class IssuingDistPointSyntax; - -//------------------------------------------------------------------------------ -// class definitions: - -typedef enum CertificateExtensionsAnyId -{ - -} CertificateExtensionsAnyId; - - -/* OCTET STRING */ -typedef AsnOcts KeyIdentifier; - -/* BIT STRING { digitalSignature (0), nonRepudiation (1), keyEncipherment (2), dataEncipherment (3), keyAgreement (4), keyCertSign (5), cRLSign (6), encipherOnly (7), decipherOnly (8) } */ -class KeyUsage: public AsnBits -{ -public: - KeyUsage(): AsnBits() {} - KeyUsage (const size_t bits): AsnBits (bits) {} - KeyUsage (const char *str, const size_t bitLen): AsnBits (str, bitLen) {} - KeyUsage (const AsnBits &b): AsnBits (b) {} - enum - { - digitalSignature = 0, - nonRepudiation = 1, - keyEncipherment = 2, - dataEncipherment = 3, - keyAgreement = 4, - keyCertSign = 5, - cRLSign = 6, - encipherOnly = 7, - decipherOnly = 8 - }; -}; - - -/* OBJECT IDENTIFIER */ -typedef AsnOid KeyPurposeId; - -/* OBJECT IDENTIFIER */ -typedef AsnOid CertPolicyId; - -/* INTEGER (0..MAX) */ -typedef AsnInt BaseDistance; - -/* INTEGER (0..MAX) */ -typedef AsnInt SkipCerts; - -/* INTEGER (0..MAX) */ -typedef AsnInt CRLNumber; - -/* ENUMERATED { unspecified (0), keyCompromise (1), cACompromise (2), affiliationChanged (3), superseded (4), cessationOfOperation (5), certificateHold (6), removeFromCRL (8) } */ -class CRLReason: public AsnEnum -{ -public: - CRLReason(): AsnEnum() {} - CRLReason (int i): AsnEnum (i) {} - enum - { - unspecified = 0, - keyCompromise = 1, - cACompromise = 2, - affiliationChanged = 3, - superseded = 4, - cessationOfOperation = 5, - certificateHold = 6, - removeFromCRL = 8 - }; -}; - - -/* OBJECT IDENTIFIER */ -typedef AsnOid HoldInstruction; - -/* BIT STRING { unused (0), keyCompromise (1), caCompromise (2), affiliationChanged (3), superseded (4), cessationOfOperation (5), certificateHold (6) } */ -class ReasonFlags: public AsnBits -{ -public: - ReasonFlags(): AsnBits() {} - ReasonFlags (const size_t bits): AsnBits (bits) {} - ReasonFlags (const char *str, const size_t bitLen): AsnBits (str, bitLen) {} - ReasonFlags (const AsnBits &b): AsnBits (b) {} - enum - { - unused = 0, - keyCompromise = 1, - caCompromise = 2, - affiliationChanged = 3, - superseded = 4, - cessationOfOperation = 5, - certificateHold = 6 - }; -}; - - -class PolicyQualifierInfo: public AsnType -{ -public: - AsnOid policyQualifierId; - AsnAny *qualifier; - - PolicyQualifierInfo(); - PolicyQualifierInfo (const PolicyQualifierInfo &); - virtual ~PolicyQualifierInfo(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PolicyQualifierInfo &operator = (const PolicyQualifierInfo &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class AttributesSyntax: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - Attribute *elmt; - } *first, *curr, *last; - -public: - AttributesSyntax() { count = 0; first = curr = last = NULL; } - AttributesSyntax (const AttributesSyntax &); - virtual ~AttributesSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AttributesSyntax &operator = (const AttributesSyntax &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - Attribute *First() const { return count > 0 ? first->elmt : NULL; } - Attribute *Last() const { return count > 0 ? last->elmt : NULL; } - Attribute *Curr() const { return curr ? curr->elmt : NULL; } - Attribute *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - Attribute *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - Attribute *GoNext() { if (curr) curr = curr->next; return Curr(); } - Attribute *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - Attribute *Append(); // add elmt to end of list - Attribute *Prepend(); // add elmt to beginning of list - Attribute *InsertBefore(); //insert elmt before current elmt - Attribute *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - AttributesSyntax &AppendCopy (Attribute &elmt); // add elmt to end of list - AttributesSyntax &PrependCopy (Attribute &elmt); // add elmt to beginning of list - AttributesSyntax &InsertBeforeAndCopy (Attribute &elmt); //insert elmt before current elmt - AttributesSyntax &InsertAfterAndCopy (Attribute &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class DistributionPointName: public AsnType -{ -public: - enum ChoiceIdEnum - { - fullNameCid = 0, - nameRelativeToCRLIssuerCid = 1 - }; - - enum ChoiceIdEnum choiceId; - union - { - GeneralNames *fullName; - RelativeDistinguishedName *nameRelativeToCRLIssuer; - }; - - - DistributionPointName(); - DistributionPointName (const DistributionPointName &); - virtual ~DistributionPointName(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DistributionPointName &operator = (const DistributionPointName &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class PolicyMappingsSyntaxSeq: public AsnType -{ -public: - CertPolicyId issuerDomainPolicy; - CertPolicyId subjectDomainPolicy; - - PolicyMappingsSyntaxSeq(); - PolicyMappingsSyntaxSeq (const PolicyMappingsSyntaxSeq &); - virtual ~PolicyMappingsSyntaxSeq(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PolicyMappingsSyntaxSeq &operator = (const PolicyMappingsSyntaxSeq &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class PolicyInformationSeqOf: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - PolicyQualifierInfo *elmt; - } *first, *curr, *last; - -public: - PolicyInformationSeqOf() { count = 0; first = curr = last = NULL; } - PolicyInformationSeqOf (const PolicyInformationSeqOf &); - virtual ~PolicyInformationSeqOf(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PolicyInformationSeqOf &operator = (const PolicyInformationSeqOf &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - PolicyQualifierInfo *First() const { return count > 0 ? first->elmt : NULL; } - PolicyQualifierInfo *Last() const { return count > 0 ? last->elmt : NULL; } - PolicyQualifierInfo *Curr() const { return curr ? curr->elmt : NULL; } - PolicyQualifierInfo *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - PolicyQualifierInfo *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - PolicyQualifierInfo *GoNext() { if (curr) curr = curr->next; return Curr(); } - PolicyQualifierInfo *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - PolicyQualifierInfo *Append(); // add elmt to end of list - PolicyQualifierInfo *Prepend(); // add elmt to beginning of list - PolicyQualifierInfo *InsertBefore(); //insert elmt before current elmt - PolicyQualifierInfo *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - PolicyInformationSeqOf &AppendCopy (PolicyQualifierInfo &elmt); // add elmt to end of list - PolicyInformationSeqOf &PrependCopy (PolicyQualifierInfo &elmt); // add elmt to beginning of list - PolicyInformationSeqOf &InsertBeforeAndCopy (PolicyQualifierInfo &elmt); //insert elmt before current elmt - PolicyInformationSeqOf &InsertAfterAndCopy (PolicyQualifierInfo &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class PolicyInformation: public AsnType -{ -public: - CertPolicyId policyIdentifier; - PolicyInformationSeqOf *policyQualifiers; - - PolicyInformation(); - PolicyInformation (const PolicyInformation &); - virtual ~PolicyInformation(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PolicyInformation &operator = (const PolicyInformation &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class GeneralSubtree: public AsnType -{ -public: - GeneralName *base; - BaseDistance *minimum; - BaseDistance *maximum; - - GeneralSubtree(); - GeneralSubtree (const GeneralSubtree &); - virtual ~GeneralSubtree(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - GeneralSubtree &operator = (const GeneralSubtree &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class DistributionPoint: public AsnType -{ -public: - DistributionPointName *distributionPoint; - ReasonFlags *reasons; - GeneralNames *cRLIssuer; - - DistributionPoint(); - DistributionPoint (const DistributionPoint &); - virtual ~DistributionPoint(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DistributionPoint &operator = (const DistributionPoint &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertificatePoliciesSyntax: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - PolicyInformation *elmt; - } *first, *curr, *last; - -public: - CertificatePoliciesSyntax() { count = 0; first = curr = last = NULL; } - CertificatePoliciesSyntax (const CertificatePoliciesSyntax &); - virtual ~CertificatePoliciesSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertificatePoliciesSyntax &operator = (const CertificatePoliciesSyntax &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - PolicyInformation *First() const { return count > 0 ? first->elmt : NULL; } - PolicyInformation *Last() const { return count > 0 ? last->elmt : NULL; } - PolicyInformation *Curr() const { return curr ? curr->elmt : NULL; } - PolicyInformation *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - PolicyInformation *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - PolicyInformation *GoNext() { if (curr) curr = curr->next; return Curr(); } - PolicyInformation *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - PolicyInformation *Append(); // add elmt to end of list - PolicyInformation *Prepend(); // add elmt to beginning of list - PolicyInformation *InsertBefore(); //insert elmt before current elmt - PolicyInformation *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - CertificatePoliciesSyntax &AppendCopy (PolicyInformation &elmt); // add elmt to end of list - CertificatePoliciesSyntax &PrependCopy (PolicyInformation &elmt); // add elmt to beginning of list - CertificatePoliciesSyntax &InsertBeforeAndCopy (PolicyInformation &elmt); //insert elmt before current elmt - CertificatePoliciesSyntax &InsertAfterAndCopy (PolicyInformation &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class GeneralSubtrees: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - GeneralSubtree *elmt; - } *first, *curr, *last; - -public: - GeneralSubtrees() { count = 0; first = curr = last = NULL; } - GeneralSubtrees (const GeneralSubtrees &); - virtual ~GeneralSubtrees(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - GeneralSubtrees &operator = (const GeneralSubtrees &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - GeneralSubtree *First() const { return count > 0 ? first->elmt : NULL; } - GeneralSubtree *Last() const { return count > 0 ? last->elmt : NULL; } - GeneralSubtree *Curr() const { return curr ? curr->elmt : NULL; } - GeneralSubtree *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - GeneralSubtree *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - GeneralSubtree *GoNext() { if (curr) curr = curr->next; return Curr(); } - GeneralSubtree *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - GeneralSubtree *Append(); // add elmt to end of list - GeneralSubtree *Prepend(); // add elmt to beginning of list - GeneralSubtree *InsertBefore(); //insert elmt before current elmt - GeneralSubtree *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - GeneralSubtrees &AppendCopy (GeneralSubtree &elmt); // add elmt to end of list - GeneralSubtrees &PrependCopy (GeneralSubtree &elmt); // add elmt to beginning of list - GeneralSubtrees &InsertBeforeAndCopy (GeneralSubtree &elmt); //insert elmt before current elmt - GeneralSubtrees &InsertAfterAndCopy (GeneralSubtree &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class AuthorityKeyIdentifier: public AsnType -{ -public: - KeyIdentifier *keyIdentifier; - GeneralNames *authorityCertIssuer; - CertificateSerialNumber *authorityCertSerialNumber; - - AuthorityKeyIdentifier(); - AuthorityKeyIdentifier (const AuthorityKeyIdentifier &); - virtual ~AuthorityKeyIdentifier(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AuthorityKeyIdentifier &operator = (const AuthorityKeyIdentifier &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* KeyIdentifier */ -typedef KeyIdentifier SubjectKeyIdentifier; - -class ExtKeyUsageSyntax: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - KeyPurposeId *elmt; - } *first, *curr, *last; - -public: - ExtKeyUsageSyntax() { count = 0; first = curr = last = NULL; } - ExtKeyUsageSyntax (const ExtKeyUsageSyntax &); - virtual ~ExtKeyUsageSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - ExtKeyUsageSyntax &operator = (const ExtKeyUsageSyntax &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - KeyPurposeId *First() const { return count > 0 ? first->elmt : NULL; } - KeyPurposeId *Last() const { return count > 0 ? last->elmt : NULL; } - KeyPurposeId *Curr() const { return curr ? curr->elmt : NULL; } - KeyPurposeId *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - KeyPurposeId *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - KeyPurposeId *GoNext() { if (curr) curr = curr->next; return Curr(); } - KeyPurposeId *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - KeyPurposeId *Append(); // add elmt to end of list - KeyPurposeId *Prepend(); // add elmt to beginning of list - KeyPurposeId *InsertBefore(); //insert elmt before current elmt - KeyPurposeId *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - ExtKeyUsageSyntax &AppendCopy (KeyPurposeId &elmt); // add elmt to end of list - ExtKeyUsageSyntax &PrependCopy (KeyPurposeId &elmt); // add elmt to beginning of list - ExtKeyUsageSyntax &InsertBeforeAndCopy (KeyPurposeId &elmt); //insert elmt before current elmt - ExtKeyUsageSyntax &InsertAfterAndCopy (KeyPurposeId &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class PrivateKeyUsagePeriod: public AsnType -{ -public: - GeneralizedTime *notBefore; - GeneralizedTime *notAfter; - - PrivateKeyUsagePeriod(); - PrivateKeyUsagePeriod (const PrivateKeyUsagePeriod &); - virtual ~PrivateKeyUsagePeriod(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PrivateKeyUsagePeriod &operator = (const PrivateKeyUsagePeriod &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class PolicyMappingsSyntax: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - PolicyMappingsSyntaxSeq *elmt; - } *first, *curr, *last; - -public: - PolicyMappingsSyntax() { count = 0; first = curr = last = NULL; } - PolicyMappingsSyntax (const PolicyMappingsSyntax &); - virtual ~PolicyMappingsSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PolicyMappingsSyntax &operator = (const PolicyMappingsSyntax &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - PolicyMappingsSyntaxSeq *First() const { return count > 0 ? first->elmt : NULL; } - PolicyMappingsSyntaxSeq *Last() const { return count > 0 ? last->elmt : NULL; } - PolicyMappingsSyntaxSeq *Curr() const { return curr ? curr->elmt : NULL; } - PolicyMappingsSyntaxSeq *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - PolicyMappingsSyntaxSeq *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - PolicyMappingsSyntaxSeq *GoNext() { if (curr) curr = curr->next; return Curr(); } - PolicyMappingsSyntaxSeq *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - PolicyMappingsSyntaxSeq *Append(); // add elmt to end of list - PolicyMappingsSyntaxSeq *Prepend(); // add elmt to beginning of list - PolicyMappingsSyntaxSeq *InsertBefore(); //insert elmt before current elmt - PolicyMappingsSyntaxSeq *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - PolicyMappingsSyntax &AppendCopy (PolicyMappingsSyntaxSeq &elmt); // add elmt to end of list - PolicyMappingsSyntax &PrependCopy (PolicyMappingsSyntaxSeq &elmt); // add elmt to beginning of list - PolicyMappingsSyntax &InsertBeforeAndCopy (PolicyMappingsSyntaxSeq &elmt); //insert elmt before current elmt - PolicyMappingsSyntax &InsertAfterAndCopy (PolicyMappingsSyntaxSeq &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class SupportedAlgorithm: public AsnType -{ -public: - AlgorithmIdentifier *algorithmIdentifier; - KeyUsage *intendedUsage; - CertificatePoliciesSyntax *intendedCertificatePolicies; - - SupportedAlgorithm(); - SupportedAlgorithm (const SupportedAlgorithm &); - virtual ~SupportedAlgorithm(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - SupportedAlgorithm &operator = (const SupportedAlgorithm &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* GeneralNames */ -typedef GeneralNames SubjectName; - -/* GeneralNames */ -typedef GeneralNames IssuerAltName; - -/* AttributesSyntax */ -typedef AttributesSyntax SubjectDirectoryAttributes; - -class BasicConstraintsSyntax: public AsnType -{ -public: - AsnBool *cA; - AsnInt *pathLenConstraint; - - BasicConstraintsSyntax(); - BasicConstraintsSyntax (const BasicConstraintsSyntax &); - virtual ~BasicConstraintsSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - BasicConstraintsSyntax &operator = (const BasicConstraintsSyntax &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class NameConstraintsSyntax: public AsnType -{ -public: - GeneralSubtrees *permittedSubtrees; - GeneralSubtrees *excludedSubtrees; - - NameConstraintsSyntax(); - NameConstraintsSyntax (const NameConstraintsSyntax &); - virtual ~NameConstraintsSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - NameConstraintsSyntax &operator = (const NameConstraintsSyntax &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class PolicyConstraintsSyntax: public AsnType -{ -public: - SkipCerts *requireExplicitPolicy; - SkipCerts *inhibitPolicyMapping; - - PolicyConstraintsSyntax(); - PolicyConstraintsSyntax (const PolicyConstraintsSyntax &); - virtual ~PolicyConstraintsSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - PolicyConstraintsSyntax &operator = (const PolicyConstraintsSyntax &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class CertPolicySet: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - CertPolicyId *elmt; - } *first, *curr, *last; - -public: - CertPolicySet() { count = 0; first = curr = last = NULL; } - CertPolicySet (const CertPolicySet &); - virtual ~CertPolicySet(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CertPolicySet &operator = (const CertPolicySet &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - CertPolicyId *First() const { return count > 0 ? first->elmt : NULL; } - CertPolicyId *Last() const { return count > 0 ? last->elmt : NULL; } - CertPolicyId *Curr() const { return curr ? curr->elmt : NULL; } - CertPolicyId *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - CertPolicyId *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - CertPolicyId *GoNext() { if (curr) curr = curr->next; return Curr(); } - CertPolicyId *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - CertPolicyId *Append(); // add elmt to end of list - CertPolicyId *Prepend(); // add elmt to beginning of list - CertPolicyId *InsertBefore(); //insert elmt before current elmt - CertPolicyId *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - CertPolicySet &AppendCopy (CertPolicyId &elmt); // add elmt to end of list - CertPolicySet &PrependCopy (CertPolicyId &elmt); // add elmt to beginning of list - CertPolicySet &InsertBeforeAndCopy (CertPolicyId &elmt); //insert elmt before current elmt - CertPolicySet &InsertAfterAndCopy (CertPolicyId &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -/* GeneralizedTime */ -typedef GeneralizedTime InvalidityDate; - -class CRLDistPointsSyntax: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - DistributionPoint *elmt; - } *first, *curr, *last; - -public: - CRLDistPointsSyntax() { count = 0; first = curr = last = NULL; } - CRLDistPointsSyntax (const CRLDistPointsSyntax &); - virtual ~CRLDistPointsSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - CRLDistPointsSyntax &operator = (const CRLDistPointsSyntax &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - DistributionPoint *First() const { return count > 0 ? first->elmt : NULL; } - DistributionPoint *Last() const { return count > 0 ? last->elmt : NULL; } - DistributionPoint *Curr() const { return curr ? curr->elmt : NULL; } - DistributionPoint *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - DistributionPoint *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - DistributionPoint *GoNext() { if (curr) curr = curr->next; return Curr(); } - DistributionPoint *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - DistributionPoint *Append(); // add elmt to end of list - DistributionPoint *Prepend(); // add elmt to beginning of list - DistributionPoint *InsertBefore(); //insert elmt before current elmt - DistributionPoint *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - CRLDistPointsSyntax &AppendCopy (DistributionPoint &elmt); // add elmt to end of list - CRLDistPointsSyntax &PrependCopy (DistributionPoint &elmt); // add elmt to beginning of list - CRLDistPointsSyntax &InsertBeforeAndCopy (DistributionPoint &elmt); //insert elmt before current elmt - CRLDistPointsSyntax &InsertAfterAndCopy (DistributionPoint &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -class IssuingDistPointSyntax: public AsnType -{ -public: - DistributionPointName *distributionPoint; - AsnBool *onlyContainsUserCerts; - AsnBool *onlyContainsCACerts; - ReasonFlags *onlySomeReasons; - AsnBool *indirectCRL; - - IssuingDistPointSyntax(); - IssuingDistPointSyntax (const IssuingDistPointSyntax &); - virtual ~IssuingDistPointSyntax(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - IssuingDistPointSyntax &operator = (const IssuingDistPointSyntax &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -/* GeneralNames */ -typedef GeneralNames CertificateIssuer; - -/* CRLNumber */ -typedef CRLNumber BaseCRLNumber; - -/* CertificateList */ -typedef CertificateList DeltaRevocationList; - -//------------------------------------------------------------------------------ -// externs for value defs - -#define id_at_supportedAlgorithms_arc 2, 5, 4, 52 -#define id_at_supportedAlgorithms AsnOid(id_at_supportedAlgorithms_arc) -#define id_at_deltaRevocationList_arc 2, 5, 4, 53 -#define id_at_deltaRevocationList AsnOid(id_at_deltaRevocationList_arc) -#define id_ce_subjectDirectoryAttributes_arc 2, 5, 29, 9 -#define id_ce_subjectDirectoryAttributes AsnOid(id_ce_subjectDirectoryAttributes_arc) -#define id_ce_subjectKeyIdentifier_arc 2, 5, 29, 14 -#define id_ce_subjectKeyIdentifier AsnOid(id_ce_subjectKeyIdentifier_arc) -#define id_ce_keyUsage_arc 2, 5, 29, 15 -#define id_ce_keyUsage AsnOid(id_ce_keyUsage_arc) -#define id_ce_privateKeyUsagePeriod_arc 2, 5, 29, 16 -#define id_ce_privateKeyUsagePeriod AsnOid(id_ce_privateKeyUsagePeriod_arc) -#define id_ce_subjectAltName_arc 2, 5, 29, 17 -#define id_ce_subjectAltName AsnOid(id_ce_subjectAltName_arc) -#define id_ce_issuerAltName_arc 2, 5, 29, 18 -#define id_ce_issuerAltName AsnOid(id_ce_issuerAltName_arc) -#define id_ce_basicConstraints_arc 2, 5, 29, 19 -#define id_ce_basicConstraints AsnOid(id_ce_basicConstraints_arc) -#define id_ce_cRLNumber_arc 2, 5, 29, 20 -#define id_ce_cRLNumber AsnOid(id_ce_cRLNumber_arc) -#define id_ce_reasonCode_arc 2, 5, 29, 21 -#define id_ce_reasonCode AsnOid(id_ce_reasonCode_arc) -#define id_ce_instructionCode_arc 2, 5, 29, 23 -#define id_ce_instructionCode AsnOid(id_ce_instructionCode_arc) -#define id_ce_invalidityDate_arc 2, 5, 29, 24 -#define id_ce_invalidityDate AsnOid(id_ce_invalidityDate_arc) -#define id_ce_deltaCRLIndicator_arc 2, 5, 29, 27 -#define id_ce_deltaCRLIndicator AsnOid(id_ce_deltaCRLIndicator_arc) -#define id_ce_issuingDistributionPoint_arc 2, 5, 29, 28 -#define id_ce_issuingDistributionPoint AsnOid(id_ce_issuingDistributionPoint_arc) -#define id_ce_certificateIssuer_arc 2, 5, 29, 29 -#define id_ce_certificateIssuer AsnOid(id_ce_certificateIssuer_arc) -#define id_ce_nameConstraints_arc 2, 5, 29, 30 -#define id_ce_nameConstraints AsnOid(id_ce_nameConstraints_arc) -#define id_ce_cRLDistributionPoints_arc 2, 5, 29, 31 -#define id_ce_cRLDistributionPoints AsnOid(id_ce_cRLDistributionPoints_arc) -#define id_ce_certificatePolicies_arc 2, 5, 29, 32 -#define id_ce_certificatePolicies AsnOid(id_ce_certificatePolicies_arc) -#define id_ce_policyMappings_arc 2, 5, 29, 33 -#define id_ce_policyMappings AsnOid(id_ce_policyMappings_arc) -#define id_ce_authorityKeyIdentifier_arc 2, 5, 29, 35 -#define id_ce_authorityKeyIdentifier AsnOid(id_ce_authorityKeyIdentifier_arc) -#define id_ce_policyConstraints_arc 2, 5, 29, 36 -#define id_ce_policyConstraints AsnOid(id_ce_policyConstraints_arc) -#define id_ce_extKeyUsage_arc 2, 5, 29, 37 -#define id_ce_extKeyUsage AsnOid(id_ce_extKeyUsage_arc) -#define id_mr_certificateExactMatch_arc 2, 5, 13, 34 -#define id_mr_certificateExactMatch AsnOid(id_mr_certificateExactMatch_arc) -#define id_mr_certificateMatch_arc 2, 5, 13, 35 -#define id_mr_certificateMatch AsnOid(id_mr_certificateMatch_arc) -#define id_mr_certificatePairExactMatch_arc 2, 5, 13, 36 -#define id_mr_certificatePairExactMatch AsnOid(id_mr_certificatePairExactMatch_arc) -#define id_mr_certificatePairMatch_arc 2, 5, 13, 37 -#define id_mr_certificatePairMatch AsnOid(id_mr_certificatePairMatch_arc) -#define id_mr_certificateListExactMatch_arc 2, 5, 13, 38 -#define id_mr_certificateListExactMatch AsnOid(id_mr_certificateListExactMatch_arc) -#define id_mr_certificateListMatch_arc 2, 5, 13, 39 -#define id_mr_certificateListMatch AsnOid(id_mr_certificateListMatch_arc) -#define id_mr_algorithmIdentifierMatch_arc 2, 5, 13, 40 -#define id_mr_algorithmIdentifierMatch AsnOid(id_mr_algorithmIdentifierMatch_arc) -#define id_kp_arc 1, 3, 6, 1, 5, 5, 7, 3 -#define id_kp AsnOid(id_kp_arc) -#define id_kp_serverAuth_arc 1, 3, 6, 1, 5, 5, 7, 3, 1 -#define id_kp_serverAuth AsnOid(id_kp_serverAuth_arc) -#define id_kp_clientAuth_arc 1, 3, 6, 1, 5, 5, 7, 3, 2 -#define id_kp_clientAuth AsnOid(id_kp_clientAuth_arc) -#define id_kp_codeSigning_arc 1, 3, 6, 1, 5, 5, 7, 3, 3 -#define id_kp_codeSigning AsnOid(id_kp_codeSigning_arc) -#define id_kp_emailProtection_arc 1, 3, 6, 1, 5, 5, 7, 3, 4 -#define id_kp_emailProtection AsnOid(id_kp_emailProtection_arc) -#define id_kp_timeStamping_arc 1, 3, 6, 1, 5, 5, 7, 3, 8 -#define id_kp_timeStamping AsnOid(id_kp_timeStamping_arc) -#define id_netscape_cert_type_arc 2, 16, 840, 1, 113730, 1, 1 -#define id_netscape_cert_type AsnOid(id_netscape_cert_type_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_x509ce.h */ diff --git a/SecurityASN1/inc/sm_x509cmn.h b/SecurityASN1/inc/sm_x509cmn.h deleted file mode 100644 index 123a2007..00000000 --- a/SecurityASN1/inc/sm_x509cmn.h +++ /dev/null @@ -1,165 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x509cmn.h - class definitions for ASN.1 module CommonX509Definitions -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_x509cmn_h_ -#define _sm_x509cmn_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class EDIPartyName; -class GeneralName; -class GeneralNames; - -//------------------------------------------------------------------------------ -// class definitions: - -/* OBJECT IDENTIFIER */ -typedef AsnOid OTHER_NAME; - -class EDIPartyName: public AsnType -{ -public: - DirectoryString *nameAssigner; - DirectoryString *partyName; - - EDIPartyName(); - EDIPartyName (const EDIPartyName &); - virtual ~EDIPartyName(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EDIPartyName &operator = (const EDIPartyName &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class GeneralName: public AsnType -{ -public: - enum ChoiceIdEnum - { - otherNameCid = 0, - rfc822NameCid = 1, - dNSNameCid = 2, - x400AddressCid = 3, - directoryNameCid = 4, - ediPartyNameCid = 5, - uniformResourceIdentifierCid = 6, - iPAddressCid = 7, - registeredIDCid = 8 - }; - - enum ChoiceIdEnum choiceId; - union - { - OTHER_NAME *otherName; - IA5String *rfc822Name; - IA5String *dNSName; - ORAddress *x400Address; - Name *directoryName; - EDIPartyName *ediPartyName; - IA5String *uniformResourceIdentifier; - AsnOcts *iPAddress; - AsnOid *registeredID; - }; - - - GeneralName(); - GeneralName (const GeneralName &); - virtual ~GeneralName(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - GeneralName &operator = (const GeneralName &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class GeneralNames: public AsnType -{ -protected: - unsigned long int count; - struct AsnListElmt - { - AsnListElmt *next; - AsnListElmt *prev; - GeneralName *elmt; - } *first, *curr, *last; - -public: - GeneralNames() { count = 0; first = curr = last = NULL; } - GeneralNames (const GeneralNames &); - virtual ~GeneralNames(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - GeneralNames &operator = (const GeneralNames &); - void SetCurrElmt (unsigned long int index); - unsigned long int GetCurrElmtIndex(); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - // reading member fcns - int Count() const { return count; } - // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!) - GeneralName *First() const { return count > 0 ? first->elmt : NULL; } - GeneralName *Last() const { return count > 0 ? last->elmt : NULL; } - GeneralName *Curr() const { return curr ? curr->elmt : NULL; } - GeneralName *Next() const { return curr && curr->next ? curr->next->elmt : NULL; } - GeneralName *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; } - - // routines that move the curr elmt - GeneralName *GoNext() { if (curr) curr = curr->next; return Curr(); } - GeneralName *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - GeneralName *Append(); // add elmt to end of list - GeneralName *Prepend(); // add elmt to beginning of list - GeneralName *InsertBefore(); //insert elmt before current elmt - GeneralName *InsertAfter(); //insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - GeneralNames &AppendCopy (GeneralName &elmt); // add elmt to end of list - GeneralNames &PrependCopy (GeneralName &elmt); // add elmt to beginning of list - GeneralNames &InsertBeforeAndCopy (GeneralName &elmt); //insert elmt before current elmt - GeneralNames &InsertAfterAndCopy (GeneralName &elmt); //insert elmt after current elmt - - // removing the current elmt from the list - void RemoveCurrFromList(); - - // encode and decode routines - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_x509cmn.h */ diff --git a/SecurityASN1/inc/sm_x520sa.h b/SecurityASN1/inc/sm_x520sa.h deleted file mode 100644 index f915e222..00000000 --- a/SecurityASN1/inc/sm_x520sa.h +++ /dev/null @@ -1,331 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// sm_x520sa.h - class definitions for ASN.1 module SelectedAttributeTypes -// -// This file was generated by snacc on Mon Apr 22 22:34:19 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_x520sa_h_ -#define _sm_x520sa_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class DirectoryString; - -//------------------------------------------------------------------------------ -// class definitions: - -/* BIT STRING */ -typedef AsnBits UniqueIdentifier; - -class DirectoryString: public AsnType -{ -public: - enum ChoiceIdEnum - { - teletexStringCid = 0, - printableStringCid = 1, - universalStringCid = 2, - bmpStringCid = 3, - utf8StringCid = 4 - }; - - enum ChoiceIdEnum choiceId; - union - { - TeletexString *teletexString; - PrintableString *printableString; - UniversalString *universalString; - BMPString *bmpString; - UTF8String *utf8String; - }; - - - DirectoryString(); - DirectoryString (const DirectoryString &); - virtual ~DirectoryString(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - DirectoryString &operator = (const DirectoryString &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -#define id_at_encryptedAliasedEntryName_arc 2, 5, 4, 1, 2 -#define id_at_encryptedAliasedEntryName AsnOid(id_at_encryptedAliasedEntryName_arc) -#define id_at_knowledgeInformation_arc 2, 5, 4, 2 -#define id_at_knowledgeInformation AsnOid(id_at_knowledgeInformation_arc) -#define id_at_commonName_arc 2, 5, 4, 3 -#define id_at_commonName AsnOid(id_at_commonName_arc) -#define id_at_encryptedCommonName_arc 2, 5, 4, 3, 2 -#define id_at_encryptedCommonName AsnOid(id_at_encryptedCommonName_arc) -#define id_at_surname_arc 2, 5, 4, 4 -#define id_at_surname AsnOid(id_at_surname_arc) -#define id_at_encryptedSurname_arc 2, 5, 4, 4, 2 -#define id_at_encryptedSurname AsnOid(id_at_encryptedSurname_arc) -#define id_at_serialNumber_arc 2, 5, 4, 5 -#define id_at_serialNumber AsnOid(id_at_serialNumber_arc) -#define id_at_encryptedSerialNumber_arc 2, 5, 4, 5, 2 -#define id_at_encryptedSerialNumber AsnOid(id_at_encryptedSerialNumber_arc) -#define id_at_countryName_arc 2, 5, 4, 6 -#define id_at_countryName AsnOid(id_at_countryName_arc) -#define id_at_encryptedCountryName_arc 2, 5, 4, 6, 2 -#define id_at_encryptedCountryName AsnOid(id_at_encryptedCountryName_arc) -#define id_at_localityName_arc 2, 5, 4, 7 -#define id_at_localityName AsnOid(id_at_localityName_arc) -#define id_at_encryptedLocalityName_arc 2, 5, 4, 7, 2 -#define id_at_encryptedLocalityName AsnOid(id_at_encryptedLocalityName_arc) -#define id_at_collectiveLocalityName_arc 2, 5, 4, 7, 1 -#define id_at_collectiveLocalityName AsnOid(id_at_collectiveLocalityName_arc) -#define id_at_encryptedCollectiveLocalityName_arc 2, 5, 4, 7, 1, 2 -#define id_at_encryptedCollectiveLocalityName AsnOid(id_at_encryptedCollectiveLocalityName_arc) -#define id_at_stateOrProvinceName_arc 2, 5, 4, 8 -#define id_at_stateOrProvinceName AsnOid(id_at_stateOrProvinceName_arc) -#define id_at_encryptedStateOrProvinceName_arc 2, 5, 4, 8, 2 -#define id_at_encryptedStateOrProvinceName AsnOid(id_at_encryptedStateOrProvinceName_arc) -#define id_at_collectiveStateOrProvinceName_arc 2, 5, 4, 8, 1 -#define id_at_collectiveStateOrProvinceName AsnOid(id_at_collectiveStateOrProvinceName_arc) -#define id_at_encryptedCollectiveStateOrProvinceName_arc 2, 5, 4, 8, 1, 2 -#define id_at_encryptedCollectiveStateOrProvinceName AsnOid(id_at_encryptedCollectiveStateOrProvinceName_arc) -#define id_at_streetAddress_arc 2, 5, 4, 9 -#define id_at_streetAddress AsnOid(id_at_streetAddress_arc) -#define id_at_encryptedStreetAddress_arc 2, 5, 4, 9, 2 -#define id_at_encryptedStreetAddress AsnOid(id_at_encryptedStreetAddress_arc) -#define id_at_collectiveStreetAddress_arc 2, 5, 4, 9, 1 -#define id_at_collectiveStreetAddress AsnOid(id_at_collectiveStreetAddress_arc) -#define id_at_encryptedCollectiveStreetAddress_arc 2, 5, 4, 9, 1, 2 -#define id_at_encryptedCollectiveStreetAddress AsnOid(id_at_encryptedCollectiveStreetAddress_arc) -#define id_at_organizationName_arc 2, 5, 4, 10 -#define id_at_organizationName AsnOid(id_at_organizationName_arc) -#define id_at_encryptedOrganizationName_arc 2, 5, 4, 10, 2 -#define id_at_encryptedOrganizationName AsnOid(id_at_encryptedOrganizationName_arc) -#define id_at_collectiveOrganizationName_arc 2, 5, 4, 10, 1 -#define id_at_collectiveOrganizationName AsnOid(id_at_collectiveOrganizationName_arc) -#define id_at_encryptedCollectiveOrganizationName_arc 2, 5, 4, 10, 1, 2 -#define id_at_encryptedCollectiveOrganizationName AsnOid(id_at_encryptedCollectiveOrganizationName_arc) -#define id_at_organizationalUnitName_arc 2, 5, 4, 11 -#define id_at_organizationalUnitName AsnOid(id_at_organizationalUnitName_arc) -#define id_at_encryptedOrganizationalUnitName_arc 2, 5, 4, 11, 2 -#define id_at_encryptedOrganizationalUnitName AsnOid(id_at_encryptedOrganizationalUnitName_arc) -#define id_at_collectiveOrganizationalUnitName_arc 2, 5, 4, 11, 1 -#define id_at_collectiveOrganizationalUnitName AsnOid(id_at_collectiveOrganizationalUnitName_arc) -#define id_at_encryptedCollectiveOrganizationalUnitName_arc 2, 5, 4, 11, 1, 2 -#define id_at_encryptedCollectiveOrganizationalUnitName AsnOid(id_at_encryptedCollectiveOrganizationalUnitName_arc) -#define id_at_title_arc 2, 5, 4, 12 -#define id_at_title AsnOid(id_at_title_arc) -#define id_at_encryptedTitle_arc 2, 5, 4, 12, 2 -#define id_at_encryptedTitle AsnOid(id_at_encryptedTitle_arc) -#define id_at_description_arc 2, 5, 4, 13 -#define id_at_description AsnOid(id_at_description_arc) -#define id_at_encryptedDescription_arc 2, 5, 4, 13, 2 -#define id_at_encryptedDescription AsnOid(id_at_encryptedDescription_arc) -#define id_at_searchGuide_arc 2, 5, 4, 14 -#define id_at_searchGuide AsnOid(id_at_searchGuide_arc) -#define id_at_encryptedSearchGuide_arc 2, 5, 4, 14, 2 -#define id_at_encryptedSearchGuide AsnOid(id_at_encryptedSearchGuide_arc) -#define id_at_businessCategory_arc 2, 5, 4, 15 -#define id_at_businessCategory AsnOid(id_at_businessCategory_arc) -#define id_at_encryptedBusinessCategory_arc 2, 5, 4, 15, 2 -#define id_at_encryptedBusinessCategory AsnOid(id_at_encryptedBusinessCategory_arc) -#define id_at_postalAddress_arc 2, 5, 4, 16 -#define id_at_postalAddress AsnOid(id_at_postalAddress_arc) -#define id_at_encryptedPostalAddress_arc 2, 5, 4, 16, 2 -#define id_at_encryptedPostalAddress AsnOid(id_at_encryptedPostalAddress_arc) -#define id_at_collectivePostalAddress_arc 2, 5, 4, 16, 1 -#define id_at_collectivePostalAddress AsnOid(id_at_collectivePostalAddress_arc) -#define id_at_encryptedCollectivePostalAddress_arc 2, 5, 4, 16, 1, 2 -#define id_at_encryptedCollectivePostalAddress AsnOid(id_at_encryptedCollectivePostalAddress_arc) -#define id_at_postalCode_arc 2, 5, 4, 17 -#define id_at_postalCode AsnOid(id_at_postalCode_arc) -#define id_at_encryptedPostalCode_arc 2, 5, 4, 17, 2 -#define id_at_encryptedPostalCode AsnOid(id_at_encryptedPostalCode_arc) -#define id_at_collectivePostalCode_arc 2, 5, 4, 17, 1 -#define id_at_collectivePostalCode AsnOid(id_at_collectivePostalCode_arc) -#define id_at_encryptedCollectivePostalCode_arc 2, 5, 4, 17, 1, 2 -#define id_at_encryptedCollectivePostalCode AsnOid(id_at_encryptedCollectivePostalCode_arc) -#define id_at_postOfficeBox_arc 2, 5, 4, 18 -#define id_at_postOfficeBox AsnOid(id_at_postOfficeBox_arc) -#define id_at_encryptedPostOfficeBox_arc 2, 5, 4, 18, 2 -#define id_at_encryptedPostOfficeBox AsnOid(id_at_encryptedPostOfficeBox_arc) -#define id_at_collectivePostOfficeBox_arc 2, 5, 4, 18, 1 -#define id_at_collectivePostOfficeBox AsnOid(id_at_collectivePostOfficeBox_arc) -#define id_at_encryptedCollectivePostOfficeBox_arc 2, 5, 4, 18, 1, 2 -#define id_at_encryptedCollectivePostOfficeBox AsnOid(id_at_encryptedCollectivePostOfficeBox_arc) -#define id_at_physicalDeliveryOfficeName_arc 2, 5, 4, 19 -#define id_at_physicalDeliveryOfficeName AsnOid(id_at_physicalDeliveryOfficeName_arc) -#define id_at_encryptedPhysicalDeliveryOfficeName_arc 2, 5, 4, 19, 2 -#define id_at_encryptedPhysicalDeliveryOfficeName AsnOid(id_at_encryptedPhysicalDeliveryOfficeName_arc) -#define id_at_collectivePhysicalDeliveryOfficeName_arc 2, 5, 4, 19, 1 -#define id_at_collectivePhysicalDeliveryOfficeName AsnOid(id_at_collectivePhysicalDeliveryOfficeName_arc) -#define id_at_encryptedCollectivePhysicalDeliveryOfficeName_arc 2, 5, 4, 19, 1, 2 -#define id_at_encryptedCollectivePhysicalDeliveryOfficeName AsnOid(id_at_encryptedCollectivePhysicalDeliveryOfficeName_arc) -#define id_at_telephoneNumber_arc 2, 5, 4, 20 -#define id_at_telephoneNumber AsnOid(id_at_telephoneNumber_arc) -#define id_at_encryptedTelephoneNumber_arc 2, 5, 4, 20, 2 -#define id_at_encryptedTelephoneNumber AsnOid(id_at_encryptedTelephoneNumber_arc) -#define id_at_collectiveTelephoneNumber_arc 2, 5, 4, 20, 1 -#define id_at_collectiveTelephoneNumber AsnOid(id_at_collectiveTelephoneNumber_arc) -#define id_at_encryptedCollectiveTelephoneNumber_arc 2, 5, 4, 20, 1, 2 -#define id_at_encryptedCollectiveTelephoneNumber AsnOid(id_at_encryptedCollectiveTelephoneNumber_arc) -#define id_at_telexNumber_arc 2, 5, 4, 21 -#define id_at_telexNumber AsnOid(id_at_telexNumber_arc) -#define id_at_encryptedTelexNumber_arc 2, 5, 4, 21, 2 -#define id_at_encryptedTelexNumber AsnOid(id_at_encryptedTelexNumber_arc) -#define id_at_collectiveTelexNumber_arc 2, 5, 4, 21, 1 -#define id_at_collectiveTelexNumber AsnOid(id_at_collectiveTelexNumber_arc) -#define id_at_encryptedCollectiveTelexNumber_arc 2, 5, 4, 21, 1, 2 -#define id_at_encryptedCollectiveTelexNumber AsnOid(id_at_encryptedCollectiveTelexNumber_arc) -#define id_at_teletexTerminalIdentifier_arc 2, 5, 4, 22 -#define id_at_teletexTerminalIdentifier AsnOid(id_at_teletexTerminalIdentifier_arc) -#define id_at_encryptedTeletexTerminalIdentifier_arc 2, 5, 4, 22, 2 -#define id_at_encryptedTeletexTerminalIdentifier AsnOid(id_at_encryptedTeletexTerminalIdentifier_arc) -#define id_at_collectiveTeletexTerminalIdentifier_arc 2, 5, 4, 22, 1 -#define id_at_collectiveTeletexTerminalIdentifier AsnOid(id_at_collectiveTeletexTerminalIdentifier_arc) -#define id_at_encryptedCollectiveTeletexTerminalIdentifier_arc 2, 5, 4, 22, 1, 2 -#define id_at_encryptedCollectiveTeletexTerminalIdentifier AsnOid(id_at_encryptedCollectiveTeletexTerminalIdentifier_arc) -#define id_at_facsimileTelephoneNumber_arc 2, 5, 4, 23 -#define id_at_facsimileTelephoneNumber AsnOid(id_at_facsimileTelephoneNumber_arc) -#define id_at_encryptedFacsimileTelephoneNumber_arc 2, 5, 4, 23, 2 -#define id_at_encryptedFacsimileTelephoneNumber AsnOid(id_at_encryptedFacsimileTelephoneNumber_arc) -#define id_at_collectiveFacsimileTelephoneNumber_arc 2, 5, 4, 23, 1 -#define id_at_collectiveFacsimileTelephoneNumber AsnOid(id_at_collectiveFacsimileTelephoneNumber_arc) -#define id_at_encryptedCollectiveFacsimileTelephoneNumber_arc 2, 5, 4, 23, 1, 2 -#define id_at_encryptedCollectiveFacsimileTelephoneNumber AsnOid(id_at_encryptedCollectiveFacsimileTelephoneNumber_arc) -#define id_at_x121Address_arc 2, 5, 4, 24 -#define id_at_x121Address AsnOid(id_at_x121Address_arc) -#define id_at_encryptedX121Address_arc 2, 5, 4, 24, 2 -#define id_at_encryptedX121Address AsnOid(id_at_encryptedX121Address_arc) -#define id_at_internationalISDNNumber_arc 2, 5, 4, 25 -#define id_at_internationalISDNNumber AsnOid(id_at_internationalISDNNumber_arc) -#define id_at_encryptedInternationalISDNNumber_arc 2, 5, 4, 25, 2 -#define id_at_encryptedInternationalISDNNumber AsnOid(id_at_encryptedInternationalISDNNumber_arc) -#define id_at_collectiveInternationalISDNNumber_arc 2, 5, 4, 25, 1 -#define id_at_collectiveInternationalISDNNumber AsnOid(id_at_collectiveInternationalISDNNumber_arc) -#define id_at_encryptedCollectiveInternationalISDNNumber_arc 2, 5, 4, 25, 1, 2 -#define id_at_encryptedCollectiveInternationalISDNNumber AsnOid(id_at_encryptedCollectiveInternationalISDNNumber_arc) -#define id_at_registeredAddress_arc 2, 5, 4, 26 -#define id_at_registeredAddress AsnOid(id_at_registeredAddress_arc) -#define id_at_encryptedRegisteredAddress_arc 2, 5, 4, 26, 2 -#define id_at_encryptedRegisteredAddress AsnOid(id_at_encryptedRegisteredAddress_arc) -#define id_at_destinationIndicator_arc 2, 5, 4, 27 -#define id_at_destinationIndicator AsnOid(id_at_destinationIndicator_arc) -#define id_at_encryptedDestinationIndicator_arc 2, 5, 4, 27, 2 -#define id_at_encryptedDestinationIndicator AsnOid(id_at_encryptedDestinationIndicator_arc) -#define id_at_preferredDeliveryMethod_arc 2, 5, 4, 28 -#define id_at_preferredDeliveryMethod AsnOid(id_at_preferredDeliveryMethod_arc) -#define id_at_encryptedPreferredDeliveryMethod_arc 2, 5, 4, 28, 2 -#define id_at_encryptedPreferredDeliveryMethod AsnOid(id_at_encryptedPreferredDeliveryMethod_arc) -#define id_at_presentationAddress_arc 2, 5, 4, 29 -#define id_at_presentationAddress AsnOid(id_at_presentationAddress_arc) -#define id_at_encryptedPresentationAddress_arc 2, 5, 4, 29, 2 -#define id_at_encryptedPresentationAddress AsnOid(id_at_encryptedPresentationAddress_arc) -#define id_at_supportedApplicationContext_arc 2, 5, 4, 30 -#define id_at_supportedApplicationContext AsnOid(id_at_supportedApplicationContext_arc) -#define id_at_encryptedSupportedApplicationContext_arc 2, 5, 4, 30, 2 -#define id_at_encryptedSupportedApplicationContext AsnOid(id_at_encryptedSupportedApplicationContext_arc) -#define id_at_member_arc 2, 5, 4, 31 -#define id_at_member AsnOid(id_at_member_arc) -#define id_at_encryptedMember_arc 2, 5, 4, 31, 2 -#define id_at_encryptedMember AsnOid(id_at_encryptedMember_arc) -#define id_at_owner_arc 2, 5, 4, 32 -#define id_at_owner AsnOid(id_at_owner_arc) -#define id_at_encryptedOwner_arc 2, 5, 4, 32, 2 -#define id_at_encryptedOwner AsnOid(id_at_encryptedOwner_arc) -#define id_at_roleOccupant_arc 2, 5, 4, 33 -#define id_at_roleOccupant AsnOid(id_at_roleOccupant_arc) -#define id_at_encryptedRoleOccupant_arc 2, 5, 4, 33, 2 -#define id_at_encryptedRoleOccupant AsnOid(id_at_encryptedRoleOccupant_arc) -#define id_at_seeAlso_arc 2, 5, 4, 34 -#define id_at_seeAlso AsnOid(id_at_seeAlso_arc) -#define id_at_encryptedSeeAlso_arc 2, 5, 4, 34, 2 -#define id_at_encryptedSeeAlso AsnOid(id_at_encryptedSeeAlso_arc) -#define id_at_encryptedUserPassword_arc 2, 5, 4, 35, 2 -#define id_at_encryptedUserPassword AsnOid(id_at_encryptedUserPassword_arc) -#define id_at_encryptedUserCertificate_arc 2, 5, 4, 36, 2 -#define id_at_encryptedUserCertificate AsnOid(id_at_encryptedUserCertificate_arc) -#define id_at_encryptedCACertificate_arc 2, 5, 4, 37, 2 -#define id_at_encryptedCACertificate AsnOid(id_at_encryptedCACertificate_arc) -#define id_at_encryptedAuthorityRevocationList_arc 2, 5, 4, 38, 2 -#define id_at_encryptedAuthorityRevocationList AsnOid(id_at_encryptedAuthorityRevocationList_arc) -#define id_at_encryptedCertificateRevocationList_arc 2, 5, 4, 39, 2 -#define id_at_encryptedCertificateRevocationList AsnOid(id_at_encryptedCertificateRevocationList_arc) -#define id_at_encryptedCrossCertificatePair_arc 2, 5, 4, 40, 2 -#define id_at_encryptedCrossCertificatePair AsnOid(id_at_encryptedCrossCertificatePair_arc) -#define id_at_name_arc 2, 5, 4, 41 -#define id_at_name AsnOid(id_at_name_arc) -#define id_at_givenName_arc 2, 5, 4, 42 -#define id_at_givenName AsnOid(id_at_givenName_arc) -#define id_at_encryptedGivenName_arc 2, 5, 4, 42, 2 -#define id_at_encryptedGivenName AsnOid(id_at_encryptedGivenName_arc) -#define id_at_initials_arc 2, 5, 4, 43 -#define id_at_initials AsnOid(id_at_initials_arc) -#define id_at_encryptedInitials_arc 2, 5, 4, 43, 2 -#define id_at_encryptedInitials AsnOid(id_at_encryptedInitials_arc) -#define id_at_generationQualifier_arc 2, 5, 4, 44 -#define id_at_generationQualifier AsnOid(id_at_generationQualifier_arc) -#define id_at_encryptedGenerationQualifier_arc 2, 5, 4, 44, 2 -#define id_at_encryptedGenerationQualifier AsnOid(id_at_encryptedGenerationQualifier_arc) -#define id_at_uniqueIdentifier_arc 2, 5, 4, 45 -#define id_at_uniqueIdentifier AsnOid(id_at_uniqueIdentifier_arc) -#define id_at_encryptedUniqueIdentifier_arc 2, 5, 4, 45, 2 -#define id_at_encryptedUniqueIdentifier AsnOid(id_at_encryptedUniqueIdentifier_arc) -#define id_at_dnQualifier_arc 2, 5, 4, 46 -#define id_at_dnQualifier AsnOid(id_at_dnQualifier_arc) -#define id_at_encryptedDnQualifier_arc 2, 5, 4, 46, 2 -#define id_at_encryptedDnQualifier AsnOid(id_at_encryptedDnQualifier_arc) -#define id_at_enhancedSearchGuide_arc 2, 5, 4, 47 -#define id_at_enhancedSearchGuide AsnOid(id_at_enhancedSearchGuide_arc) -#define id_at_encryptedEnhancedSearchGuide_arc 2, 5, 4, 47, 2 -#define id_at_encryptedEnhancedSearchGuide AsnOid(id_at_encryptedEnhancedSearchGuide_arc) -#define id_at_protocolInformation_arc 2, 5, 4, 48 -#define id_at_protocolInformation AsnOid(id_at_protocolInformation_arc) -#define id_at_encryptedProtocolInformation_arc 2, 5, 4, 48, 2 -#define id_at_encryptedProtocolInformation AsnOid(id_at_encryptedProtocolInformation_arc) -#define id_at_distinguishedName_arc 2, 5, 4, 49 -#define id_at_distinguishedName AsnOid(id_at_distinguishedName_arc) -#define id_at_encryptedDistinguishedName_arc 2, 5, 4, 49, 2 -#define id_at_encryptedDistinguishedName AsnOid(id_at_encryptedDistinguishedName_arc) -#define id_at_uniqueMember_arc 2, 5, 4, 50 -#define id_at_uniqueMember AsnOid(id_at_uniqueMember_arc) -#define id_at_encryptedUniqueMember_arc 2, 5, 4, 50, 2 -#define id_at_encryptedUniqueMember AsnOid(id_at_encryptedUniqueMember_arc) -#define id_at_houseIdentifier_arc 2, 5, 4, 51 -#define id_at_houseIdentifier AsnOid(id_at_houseIdentifier_arc) -#define id_at_encryptedHouseIdentifier_arc 2, 5, 4, 51, 2 -#define id_at_encryptedHouseIdentifier AsnOid(id_at_encryptedHouseIdentifier_arc) -#define id_at_encryptedSupportedAlgorithms_arc 2, 5, 4, 52, 2 -#define id_at_encryptedSupportedAlgorithms AsnOid(id_at_encryptedSupportedAlgorithms_arc) -#define id_at_encryptedDeltaRevocationList_arc 2, 5, 4, 53, 2 -#define id_at_encryptedDeltaRevocationList AsnOid(id_at_encryptedDeltaRevocationList_arc) -#define id_at_dmdName_arc 2, 5, 4, 54 -#define id_at_dmdName AsnOid(id_at_dmdName_arc) -#define id_at_encryptedDmdName_arc 2, 5, 4, 54, 2 -#define id_at_encryptedDmdName AsnOid(id_at_encryptedDmdName_arc) -#define id_at_encryptedClearance_arc 2, 5, 4, 55, 2 -#define id_at_encryptedClearance AsnOid(id_at_encryptedClearance_arc) -#define id_at_encryptedDefaultDirQop_arc 2, 5, 4, 56, 2 -#define id_at_encryptedDefaultDirQop AsnOid(id_at_encryptedDefaultDirQop_arc) -#define id_at_encryptedAttributeIntegrityInfo_arc 2, 5, 4, 57, 2 -#define id_at_encryptedAttributeIntegrityInfo AsnOid(id_at_encryptedAttributeIntegrityInfo_arc) -#define id_at_encryptedAttributeCertificate_arc 2, 5, 4, 58, 2 -#define id_at_encryptedAttributeCertificate AsnOid(id_at_encryptedAttributeCertificate_arc) -#define id_at_encryptedAttributeCertificateRevocationList_arc 2, 5, 4, 59, 2 -#define id_at_encryptedAttributeCertificateRevocationList AsnOid(id_at_encryptedAttributeCertificateRevocationList_arc) -#define id_at_encryptedConfKeyInfo_arc 2, 5, 4, 60, 2 -#define id_at_encryptedConfKeyInfo AsnOid(id_at_encryptedConfKeyInfo_arc) -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_x520sa.h */ diff --git a/SecuritySNACCRuntime/.cvsignore b/SecuritySNACCRuntime/.cvsignore deleted file mode 100644 index b083d03e..00000000 --- a/SecuritySNACCRuntime/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -tcl-p diff --git a/SecuritySNACCRuntime/Apple_README b/SecuritySNACCRuntime/Apple_README deleted file mode 100644 index 4339d806..00000000 --- a/SecuritySNACCRuntime/Apple_README +++ /dev/null @@ -1,53 +0,0 @@ - MacOS X Porting notes - 20 March 2002 dmitch - --- snacc.pbproj contains the following targets: - - world: aggregate target, builds UnixBuild and snaccRuntime - - UnixBuild: Legacy target, invokes MacOSX-Install, a custom - script to config and build the snacc compiler. This does - not install the snacc binary; maybe it should. - - snaccRuntime: builds the runtime support library as an OSX - framework using the same source as c++-lib. Currently - obsolete; this is now part of Security.framework. - - asn-useful - recompiles the sole ASN1 source in this modules - asn-usefule.asn1. Do this after building and installing - a new compiler. - --- There are a few header files which have duplicate copies - in the snacc-1.3vda root directory and in c++-lib/inc. They're - needed in the root by the compiler build and various configure - operations, and neneded in c++lib for the framework built - there (snaccRuntime.framework). The headers are needed by - other headers installed in that framework. A non-trivial - amount of Makefile and configure.in hacking could eliminate - the need for maintaining duplicate copies of these files. - Be my guest. One header, config.h, is generated at configure - time and is subsequently copied into the c++-lib/inc directory - by the MacOSX-Install script. The other headers are policy.h - and snacc.h, which change rarely. - --- The following examples are skipped during the build all. - - c++-examples.simple - runtime failure - c-examples/snmp - runtime failure - tbl-example - runtime failure - tcl-example - build failure - --- When running the snacc compiler to generate C++ source, you - must specify the (undocumented) -D argument to enable VDADER_RULES. - When compiling that source, you must do a -DVDADER_RULES. - --- As of 20 March 2002, the BDec routines now throw SnaccExcep exceptions; - there are no more setjmp/longjmp catchers. This is controlled by the - SNACC_EXCEPTION_ENABLE flag found in both asn-config.h files. - --- As of 20 March 2002, there are no more BEncPdu or BDecPdu functions - anywhere. These were convenience routines and added about 47 KBytes - to Security.framework. This is controlled by the SNACC_ENABLE_PDU - flag found in both asn-config.h files. - - \ No newline at end of file diff --git a/SecuritySNACCRuntime/COPYING b/SecuritySNACCRuntime/COPYING deleted file mode 100644 index a43ea212..00000000 --- a/SecuritySNACCRuntime/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/SecuritySNACCRuntime/CVSVersionInfo.txt b/SecuritySNACCRuntime/CVSVersionInfo.txt deleted file mode 100644 index 7f234b9b..00000000 --- a/SecuritySNACCRuntime/CVSVersionInfo.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Created and modified by checkpoint; do not edit -# $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ -# $Name: Security-54~1~9 $ -ProjectName: SecuritySNACCRuntime -ProjectVersion: 6.1 diff --git a/SecuritySNACCRuntime/ChangeLog b/SecuritySNACCRuntime/ChangeLog deleted file mode 100644 index 39db4b7a..00000000 --- a/SecuritySNACCRuntime/ChangeLog +++ /dev/null @@ -1,761 +0,0 @@ -Fri Oct 10 13:43:18 1997 Sebastian Wangnick - - * tcl-asn/makefile, tcl-asn/asnwish.c, tcl-asn/beredit, compiler/core/val-parser.c, tcl-asn/README, c-lib/src/tbl-gen.c, compiler/core/define.c, c++-examples/simple/good-pr.ber, c-examples/simple/good-pr.ber, version.h, README: - Corrected bug in generic table decoder wrt. indefinite length elements - Corrected compiler access to freed memory (bug reported by Markku Savela) - Broke asnwish.c into two pieces so that one can build ones on wish - Added beredit tool (based on asnwish, allowes to edit BER messages) - -Tue Sep 16 15:05:10 1997 Sebastian Wangnick - - * tbl-tools/berdecode/berdecode.c: Changed default value of strip to 0. - - * entry.html: Documented current situation - -Tue Sep 16 14:57:59 1997 Sebastian Wangnick - - * README: Proper description of last-minute changes - - * asn1specs/p-rec.asn1, tbl-example/p-rec.ber: - Added test for "tag dividable by 128" case. - - * c-lib/src/tbl-enc.c, c-lib/src/tbl-gen.c: - Fixed "tag dividable by 128" case. - Fixed problem of peeking beyond tag size. - -Fri Sep 5 07:15:06 1997 Sebastian Wangnick - - * tcl-asn/asnwish.c: Picky compiler mods - -Thu Sep 4 13:54:10 1997 Sebastian Wangnick - - * tbl-tools/berdecode/berdecode.c, c++-lib/src/asn-list.C, configure.in: - A little more portability - -Wed Sep 3 12:50:33 1997 Sebastian Wangnick - - * compiler/makefile: Shifted parse and lex - - * tcl-asn/makefile, tcl-asn/asnwish.c: - Reworked asnwish to neither strip nor encapsulate; instead, - buffer reads during decoding incrementally Tcl_Read the channel. - - * c-lib/src/tbl-enc.c, c-lib/src/asn-tag.c: - Patch to tag decoding for tags > 2^14 (thanks to Enrico Badella) - Patch to TblEncTag to emit final 0x00 if previous octet signals continuation - - * c++-lib/src/asn-tag.C: - Patch to tag decoding for tags > 2^14 (thanks to Enrico Badella) - -Mon Sep 1 14:21:03 1997 Sebastian Wangnick - - * compiler/core/err-chk.c: Improved error output in certain cases. - -Thu Aug 28 09:48:08 1997 Sebastian Wangnick - - * README, entry.html, ChangeLog: Added description of changes - - * compiler/core/lex-asn1.l, compiler/core/parse-asn1.y: - Reworked number range checking, only gives warning now. - -Wed Aug 27 15:56:09 1997 Sebastian Wangnick - - * tcl-asn/README, tcl-asn/asnwish.c, tcl-asn/makefile, tbl-tools/berdecode/berdecode.c, tbl-tools/berdecode/makefile, tbl-tools/berdecode/README, tbl-tools/makefile, c-lib/src/tbl-dbg.c, c-lib/src/tbl-gen.c, c-lib/inc/tbl-dbg.h, c-lib/inc/tbl-gen.h, c-lib/makefile: - Added generic table decoding, debug routines, berdecode, and asnwish. - - * c++-lib/src/asn-bits.C: - GetBit now returns 0 or 1, not 0 or <#bit>, even if bool type is emulated. - - * version.h, makefile: - Added generic table decoding, debug routines, berdecode, and asnwish. - -Thu Jun 19 09:32:22 1997 Sebastian Wangnick - - * README: Added 1.3b3 change description - - * doc/makefile: Disabled making new doc due to new version string. - - * compiler/boot/tbl.h, compiler/boot/tbl.c, c-lib/boot/tbl.h, c-lib/boot/tbl.c: - Remade by make tar - - * version.h: Fixed release date. - - * tbl-tools/ptbl/pasn1.c, compiler/core/lex-asn1.l, compiler/core/parse-asn1.y, compiler/boot/tbl.c, compiler/boot/tbl.h, compiler/core/gen-tbls.c, c-lib/boot/tbl.h, c-lib/src/tbl-util.c, c-lib/boot/tbl.c, asn1specs/tbl.asn1, version.h: - Added isPdu flag to tables. Added value range checks during parsing. - -Wed May 7 15:20:57 1997 Sebastian Wangnick - - * README, tbl-tools/ptbl/pasn1.c, compiler/core/gen-tbls.h, compiler/core/snacc.c, c-lib/inc/tbl-incl.h, compiler/core/gen-tbls.c, asn1specs/tbl.asn1, version.h: - Added (limited) size constraints, bitstring and enumeration names to tables - - * compiler/back-ends/c-gen/gen-vals.c: - Fixed bug in C value string generation. - -Mon Apr 7 13:14:16 1997 Sebastian Wangnick - - * README: Final README for 1.3b1 - - * snacc.h: Made more C++ readable (credits to Steve Walker) - -Thu Mar 20 15:50:25 1997 Sebastian Wangnick - - * version.h, README: Push to 1.3b1. - -Thu Mar 13 14:48:28 1997 Sebastian Wangnick - - * compiler/core/parse-asn1.y: - Parsed SEQUENCE SIZE(..) OF as SET, corrected. - - * compiler/boot/tbl.h, compiler/boot/tbl.c, compiler/back-ends/idl-gen/gen-code.c, c-lib/src/print.c, c-lib/src/asn-tag.c, c-lib/inc/asn-config.h, c-lib/boot/tbl.h, c-lib/boot/tbl.c, c-lib/boot/asn-useful.h, c-lib/boot/asn-useful.c, c-lib/makefile, c++-lib/makefile, version.h: - Improved dependency generation for stupid makedepends. - Corrected PeekTag to peek into buffer only as far as necessary. - Added installable error handler. - Fixed small glitch in idl-code generator (Markku Savela ). - -Mon Mar 3 11:58:34 1997 Sebastian Wangnick - - * compiler/core/parse-asn1.y, compiler/boot/tbl.c, compiler/boot/tbl.h, compiler/makefile, c-lib/boot/tbl.c, c-lib/boot/tbl.h, c-lib/boot/asn-useful.c, c-lib/boot/asn-useful.h, c++-examples/test-lib/makefile, acconfig.h, makefile, ChangeLog: - Final pre-delivery stuff (I hope). - -Fri Feb 28 13:43:53 1997 Sebastian Wangnick - - * version.h: New version #. - - * .cvsignore: Added config.cache - - * tcl-lib/snacced.tcl, tcl-example/edex1.asn1, tcl-lib/selbox.tcl, compiler/core/parse-asn1.y, compiler/core/print.c, compiler/back-ends/c-gen/gen-dec.c, compiler/back-ends/c++-gen/gen-code.c, c-lib/src/tbl-util.c, compiler/makefile, c-lib/src/hash.c, c-lib/src/nibble-alloc.c, c-lib/src/tbl-free.c, c-lib/src/asn-real.c, c-lib/src/asn-tag.c, c-lib/inc/asn-any.h, c-lib/inc/hash.h, c-lib/src/asn-any.c, c++-lib/src/tkAppInit.c, c-lib/tbl.h.patch, c++-lib/src/meta.C, c++-lib/src/tcl-if.C, c++-lib/src/asn-oid.C, c++-lib/src/asn-real.C, c++-lib/src/hash.C, c++-lib/src/asn-int.C, c++-lib/src/asn-octs.C, c++-lib/src/asn-bits.C, c++-lib/src/asn-bool.C, c++-lib/src/asn-enum.C, c++-lib/inc/meta.h, c++-lib/src/asn-any.C, c++-examples/test-lib/test-lib.C, c++-lib/inc/hash.h, c++-examples/test-lib/makefile, configure.in, snacc.h, acconfig.h: - Modifications collected for new version 1.3: Bug fixes, tk4.2. - -Sun Feb 16 22:26:40 1997 rj - - * README: url corrected - - * c-examples/test-lib/README, c-examples/any/example.c, c-examples/any/README, c++-lib/src/str-stk.C, c++-lib/src/print.C, c++-lib/src/hash.C, c++-lib/src/asn-tag.C, c++-lib/src/asn-len.C, c++-lib/src/asn-bool.C, c++-lib/src/asn-any.C, c++-lib/inc/str-stk.h, c++-lib/inc/print.h, c++-lib/inc/hash.h, c++-lib/inc/asn-type.h, c++-lib/inc/asn-tag.h, c++-lib/inc/asn-real.h, c++-lib/inc/asn-octs.h, c++-lib/inc/asn-list.h, c++-lib/inc/asn-incl.h, c++-lib/inc/asn-buf.h, c++-lib/inc/asn-bits.h, c++-examples/test-lib/README, c++-examples/any/README, asn1specs/ex1.asn1, asn1specs/any.asn1: - check-in of a few cosmetic changes - - * README, ChangeLog, version.h: final release of snacc 1.2rj - - * makefile: remove tcl-p when making clobber - - * INITIAL: first check-in - - * tcl-example/.cvsignore: ignore yet two more generated files - - * doc/makefile: typo fixed - - * c++-examples/any/.cvsignore, c-examples/any/.cvsignore: - ignore more generated files and directories - - * c++-examples/simple/.cvsignore, c-examples/simple/.cvsignore: - ignore generated directories - - * c-examples/test-lib/.cvsignore: ignore yet another generated file - - * tbl-example/.cvsignore: ignore two more generated files - - * tbl-tools/pval/.cvsignore, tbl-tools/ptbl/.cvsignore, tbl-tools/mkchdr/.cvsignore: - ignore yet another generated file - - * makefile: correct path to configure script - - * compiler/makefile: snacc is needed to generate the distfiles - - * tcl-example/.cvsignore: ignore more generated files - - * tbl-tools/mkchdr/.cvsignore: ignore yet another generated file - - * tbl-example/.cvsignore, doc/.cvsignore: - ignore yet two more generated files - - * doc/.cvsignore: ignore yet another generated file - - * tcl-example/.cvsignore, tbl-tools/pval/.cvsignore, tbl-tools/ptbl/.cvsignore, tbl-tools/mkchdr/.cvsignore, tbl-example/.cvsignore, c-examples/test-lib/.cvsignore: - ignore the dependencies file - - * c-examples/snmp/.cvsignore, c-examples/simple/.cvsignore, c-examples/any/.cvsignore, c++-examples/test-lib/.cvsignore, c++-examples/snmp/.cvsignore, c++-examples/simple/.cvsignore, c++-examples/any/.cvsignore: - ignore yet another file - - * c++-lib/.cvsignore: ignore generated directories - - * c++-lib/.cvsignore, compiler/.cvsignore: - ignore yet another generated file - - * c-lib/.cvsignore: ignore more generated files and directories - - * doc/thisnextafter.tex, doc/misc-defs.tex, doc/list-popup.eps, doc/str-popup.eps, doc/struct.eps, doc/simple.eps, doc/selbox.eps, doc/recur.eps, doc/example.eps, c-lib/tbl.h.patch: - first check-in - - * makefile: generate tcl-p before it is needed... - - * configure.in, doc/intro-1.2.tex, c++-lib/makefile, c++-examples/snmp/makefile, c++-examples/simple/makefile, c++-examples/any/makefile: - made return *this after calling abort()'' a compile time option. - - * maketail: rule to generate $(TCL-P) added - - * makehead.in, doc/snacc.1, compiler/back-ends/c++-gen/gen-code.h, compiler/back-ends/c++-gen/gen-code.c: - made return *this after calling abort()'' a compile time option. - - * compiler/core/snacc.c: - made ``return *this after calling abort()'' a compile time option. - - * c++-lib/inc/asn-oid.h: construct in the order the members are defined - - * tcl-example/makefile: remove more generated files - - * compiler/back-ends/c++-gen/gen-code.c: - use the TIME_WITH_SYS_TIME flag (checked and generated by configure). - return *this after calling abort() for compilers that don't know about this volatile function. - comment out unused parameters, the compiler otherwise may complain. - - * compiler/makefile: - let make clobber remove the link to install-sh that make made - let make clean remove more created files - - * c-lib/makefile: - let make clobber remove the link to install-sh that make made - - * c++-lib/src/asn-oid.C: name lookup of \for' scoping - - * c++-lib/inc/asn-null.h: comment out an unused argument - - * c++-lib/inc/asn-len.h: make the unsigned value unsigned :-) - -Sun Feb 16 05:22:42 1997 Robert Joop - - * ***** this is the end, my last words on my final snacc release, 1.2rj.10. ***** - - * lots of files and directories added to the various .cvsignore files. - - * added a file INITIAL to explain the first steps necessary after - an initial cvs checkout. - - * made ``return *this after calling abort()'' a compile time - option. - - * compiler/back-ends/c++-gen/gen-code.c: comment out unused - parameters, the compiler otherwise may complain. - - * compiler/back-ends/c++-gen/gen-code.c: return *this after - calling abort() for compilers that don't know about this volatile - function. - - * compiler/back-ends/c++-gen/gen-code.c: use the - TIME_WITH_SYS_TIME flag (checked and generated by configure) - - * changes for new ANSI `for' scoping - -Sat Feb 15 19:09:43 1997 Robert Joop - - * configure.in and acconfig.h: check whether the compiler supports - volatile functions (and whether abort() is volatile). In member - functions, return *this after calling abort() for those stupid - compilers (they would otherwise abort with an error). - - * tbl-tools/ and tbl-example/ directoies added. - - * compiler/core/snacc.c: do not silently ignore the -tcl option if - not compiled for tcl code generation - - * compiler/core/snacc.c: use the TIME_WITH_SYS_TIME flag (checked - and generated by configure) - - * c++-lib/src/asn-list.C: names of Tcl*-functions fixed (obviously - they weren't needed :-) - - * c++-lib/inc/tcl-if.h, c++-lib/src/tcl-if.C: `typename' appears - to be a reserved word in gcc 2.7, so prefix it with `_' - - * c++-lib/src/asn-bits.C: dereferencing pointer to member function - is neither necessary nor allowed - - * c++-lib/src/asn-type.C: "virtual" removed from functions. (fix - due to changed C++ language.) - -Thu Sep 7 20:21:39 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * deep copying code added to C++ backend generated assignment - operators. - - * c-lib/makefile and c++-lib/makefile: asn-useful.asn1 is compiled - with the -l 50 option, as recommended by MS in the documentation. - - * compiler/back-ends/c++-gen/kwd.c: bool, true and false are - reserved words in new C++ (supported by gcc since version 2.6). - - * new options -mA and -mC for snacc(1) that switch the names used - between those defined in the ASN.1 files and those used in the - generated C++ code. enum type MetaNameStyle introduced. - - * c++-lib/src/tcl-if.C: duplicate code merged into a new function - SnaccTcl::gettypedesc(). - - * c++-lib/*: long int replaced by AsnIntType at a lot of - places. It shall provide a 32 bit integer type on all platforms. - new type introduced: AsnUIntType (32 bit unsigned integer type). - -Thu Aug 17 17:01:59 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * c++-lib/*/asn-real.[hC]: recognize and return "±inf" for - PLUS-INFINITY/MINUS-INFINITY - - * c++-lib/*/asn-enum.[hC]: AsnEnumTypeDesc gets its own TclGetVal - and TclSetVal functions. - - * c++-lib/*/meta.[hC]: introduce an AsnEnumTypeDesc class with its - own TclGetDesc2 function that returns the value names but omits - the numeric values. - - * c++-lib/src/tcl-if.C &al.: set Tcl's errorCode variable - - * c++-lib/{inc,src}: snacced.[hC] renamed to tcl-if.[hC]. class - SnaccEd renamed to SnaccTcl. - - * the PDU flag belongs to the metacode, not only to the tcl - interface. (type and variable named adjusted) - -Thu Jul 27 10:27:07 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * cpp macro TBL changed to TTBL since some type table code uses - TBL as a type name. - - * c++-lib/makefile: make $(TCL-P) if necessary. - - * c++-lib/makefile: actions for stamp-useful rule: call diff only - if both input files exist. - - * rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 - renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to - accomodate to snacc's new file name generation scheme. - -Tue Jul 25 13:35:58 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * policy.h: added switch for (en|dis)abling the compilation of the - idl code generator. - - * compiler: PrintConditionalIncludeOpen() and - PrintConditionalIncludeClose() moved from - back-ends/c-gen/gen-code.[ch] to back-ends/cond.[ch]. - - * .../compiler/back-ends/c++-gen/gen-vals.c: use true/false - instead of AsnBool::true/false. - - * the compiler is compiled from two files, tbl.h and tbl.c, it - generates itself. for bootstrapping purposes, initial versions are - supplied with the distribution. - -Mon Jul 24 14:26:16 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * .../c++-lib: code extracted from AsnOcts::TclGetVal and - AsnOcts::TclSetVal (src/asn-octs.C) into ::debinify and ::binify - (src/meta.C). - - * Clone() added to AsnEnum. - - * various C++ files: ``#error "..."'' instead of ``#error ...'' - - * c++-lib/*/asn-list.?: operator == and != return bool instead of int. - - * .../maketail: the .C.o default rule now uses CXXFLAGS instead of - CFLAGS for compilation. - - * .../c-lib and c++-lib call make recursively to generate the - different depencies for all the different makefiles. - - * .../configure looks for tclsh(1)---the tcl-lib uses it to - construct the tclIndex file. .../configure doesn't look for Tcl/Tk - if the tclsh is absent. - - * .../configure looks for patch(1)---the c-lib uses it to patch - tbl.h. - - * .../configure searches for tree-3.6's libtktree.a and sets - TREELIBS in .../makehead accordingly. - - * type table tools and the example merged into the distribution: - .../tbl-tools/ and .../tbl-example. - - * dummy action added to config.h.in and config.h rules to trick - many makes' overoptimization. - - * snacc -h now prints the usage to stdout. - - * bug report address changed to protect an innocent's mailbox :-) - - * .../version.h contains the snacc version---it is included in the - compiler source and is used by the .../makefile upon tar-file - generation. - - * configure checks for memset(3), memcpy(3) and memcmp(3) and - .../snac.h defines replacements using bzero(3), bcopy(3) and - bcmp(3) if necessary. - - * .../compiler/core/mem.c: Realloc() now checks realloc(3)'s - return value. - - * changed `_' to `-' in file names. - - * file names in .../compiler/back-ends/ have been shortened for - redundant parts (e.g. c_gen/gen_c_code -> c_gen/gen_code or - c++_gen/c++_kwd -> c++_gen/kwd). - -Sun Jul 23 12:51:24 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * an additional type description, AsnAliasTypeDesc, for type - definitions of the form ``TypeB ::= TypeA''. see the documentation - for further details. - - * allow for more than one PDU per .asn1 file set: - - each type description gets a bool flag, pdu. - - each type description gets accompanied with a create function - that returns a newly allocated object of its mirror type. the type - description contains a pointer to this function. the getTclPDU() - function is deleted. - - compiler/core/meta.h: struct TclPDU becomes a linked list. it - gets a flag `used' to detect invalid command line arguments. - - * additional function TclUnsetVal() to delete OPTIONAL members and - SEQUENCE OF and SET OF list elements. - - *_getref() gets an additional optional argument, bool - create=false, to faciliate the different member access semantics - of TclGetVal() and TclSetVal(). - - * to accomodate to snacc's new file name generation scheme: - - useful.asn1 renamed to asn-useful.asn1 - - any-test.[hC] renamed to any.[hC] - - * by default, snacc now derives output file names from the .asn1 - input file name instead of the module name. a global variable, - `keepbaseG', is used to toggle between old and new behaviour. - -Sat Jul 22 22:49:25 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * use install-sh instead of install.sh, to prevent `make' implicit - rules from creating a file called install from it when there is no - makefile. - -Mon Feb 20 12:38:00 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * c{,++}_lib/makefile: remove stamp-useful before removing - asn_useful.[hcC]. - -Sun Feb 19 19:13:50 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * some c{,++}_examples/*/makefile: some make(1)s leave a trailing - `/' on $(@D). since some mkdir(1)s deny their cooperation with - such arguments, this slash has got to be stripped. - -Sat Feb 18 14:12:23 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * in a lot of makefiles: dirname(1) and basename(1) do not exist - on every system. so we're using $(@D) and $(@F) instead. - - * the code partially relied on big endianess. autoconf is used to - (un)define WORDS_BIGENDIAN accordingly and the byte order - dependent code parts have been fixed. - - * instead of relying on (sizeof (int) == 4), autoconf now checks - some integer sizes and cpp is used to select appropiatly sized - integer types. - - * c++_lib/{inc/asn_list.h,src/asn_list.C}: #pragma - interface/implementation are GNU specific and need to be wrapped - (by #ifdef __GNUG__). - - * configure.in, acconfig.h, misc .C files: added #define - HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS (we need to check for this - since not every C++ compiler provides them.) - - * snacc.h: added #defines GLASS and KHO for wrapping and enabling - of project and user specific code, resp. - -Fri Feb 17 15:27:31 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * c_examples/simple/README: reflect the test script's integration - into the makefile. - - * makehead.in, maketail: added a small hack to find gcc's hidden - include directory to pass it to makedepend. this shall enable - X11's makedepend to find .h files a little more the way gcc does. - - * configure.in, changes for autoconf 2.x - -Mon Feb 13 15:43:10 1995 Robert Joop (rj@rainbow.in-berlin.de) - - * miscelleanous makefiles: make depend builds snacc if and where - necessary. - - * makefiles changed to augment CPPFLAGS instead of overriding - them. - - * CFLAGS, CXXFLAGS and LDFLAGS moved from the various makefiles to - makehead(.in). - - * settings for IEEE_REAL_FMT/IEEE_REAL_LIB moved from - {c_lib,c++_lib}/inc/asn_config.h to acconfig.h. - -Mon Oct 10 01:59:50 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * compiler/back_ends/c++_gen/gen_c++_code.c: the list functions - Append(), Prepend(), InsertBefore() and InsertAfter() now set the - current element to the element just inserted. - -Sat Oct 8 02:20:20 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * since autoconf substitutes in config.h.bot as well, we can't use - it. therefore it has been renamed to snacc.h and it includes the - config.h (generated by autoconf/configure) and policy.h (edited by - the person who wishes to compile/install/use snacc). - - * the compiler is generated with a file it generates itself. for - bootstraping purposes, an initial version is supplied in the - distribution (c_lib/boot/asn_useful.[hc]). - - * to complement the destructors, T::T (const T&) and - T &T::operator = (const T &) have been added to override the - defaults supplied by the compiler. reason: simple pointer - duplication may lead to unreferenced objects and to objects - referenced more than once (on which the destructors delete may - choke). - - * three bugs in compiler/back_ends/c++_gen/gen_c++_code.c's list - functions fixed (IBM ENC detected and fixed it at only place only). - - * at the same places as the below two points: code for a Tcl - interface added. - - * c++_lib/*: meta code for the basic types added. (and a little - glue code in compiler/core/snacc.c) - - * compiler/back_ends/c++_gen/gen_c++_code.c: code added that (on - request) added meta information to the C++ classes generated. - - * compiler/back_ends/c++_gen/gen_c++_code.c: turned character - pointers into constant character arrays. - - * several `unsigned long int' turned into `size_t' (C++ code - only). - -Thu Oct 6 19:25:31 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * c++_lib/*: virtual inline functions (the destructor and the - Clone() function) moved from inc/*.h to src/*.C because g++ turns - every one of them into a static non-inline function in every file - where the .h file gets included. - -Wed Sep 28 12:17:50 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * c++_lib/inc/asn_buf.h: fixed both Copy()'s name and - implementation to CopyOut() that always returns the number of - bytes copied out instead of 0 in case less than the requested - amount is available. - -Sat Sep 17 20:07:29 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * compiler/back_ends/c++_gen/gen_c++_code.c: reordered the - functions to get rid of their annoying declarations. - -Wed Sep 14 00:59:36 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * the constructors should initialize all pointers or else the - destructor may delete bogus pointers. - - * c_lib/inc/asn_list.h: is unwise to #define unbalanced if()s! - - * since i was still irritated by cpp standing for c++ and not the - C preprocessor, i renamed them to cxx (which is one known suffix - for C++ source files). since the standard #define is __cplusplus, - cplusplus would have been the more obvious choice, but it is a - little too long. - - * made Print() const (and some other, mainly comparison functions). - -Thu Sep 1 01:11:17 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * compiler/core/snacc_config.h dissolved into mem.h and - snacc_util.h. - - * the empty statement in a - for (...; ...; ...); - has often been overseen; the equivalent - for (...; ...; ...) - ; - has proven to be less error prone. - - * off-topic: cvs and rcs fixed to recognize .C and .asn1 as - suffices for C++ and ASN.1 code, respectively. - -Wed Aug 31 00:03:22 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * it is a good idea to have every .c file include its - corresponding .h file were its functions are declared, because - it's a very effictive way to let an ANSI compiler assert that - every function is defined with the same number and types of - arguments as it is declared with. proof: ParseValues() was - declared different than defined (different return type and - arguments reversed). - - * for reasons unknown, the compiler files included two of the - various almost identical config.h files. - - * compiler/back_ends/c++_gen/gen_c++_code.c: turned the huge - inline funtions into normal functions. (the change was actually - made by IBM ENC, but wasn't properly marked.) due to their size, - these inlines wouldn't get inlined anyway. due to their size they - wouldn't offer any speed advantage (the function call overhead - diminishes). instead, the compiler generated static functions in - every .C file were the .h file is included! this inflates the .o - files and executables real quick (i'm speaking of MBytes per - executable). - - * integrating c{,++}_examples: - .../simple: test csh-script integrated into makefile. - -Mon Aug 29 11:18:11 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * the dependencies have been moved into a separate file that is - not under cvs control. otherwise, the makefiles would inflate the - repository unnecessarily. - -Sun Aug 28 11:18:23 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * config.h defines TRUE/FALSE for C only. for C++, the built-in - bool type accompanied by true/false is used. for C++ compilers - that don't have bool built-in, an equivalent enum is defined. - - * merged .../tbl_{lib,include}/ with .../c_lib/. changes detected - were: - - asn_any.h present in c_lib only. - - asn_bits.c ... - - tbl_*/asn_len.[ch] has an additional function PeekEoc(). - - tbl_include/asn_list.h has an additonal macro - FOR_REST_LIST_ELMT_RVS() and three additional functions, - GetAsnListElmtIndex(), AsnListFree() and GetAsnListElmt(). - tbl_lib/asn_list.c defines only one additional function, - GetAsnListElmt(). - - asn_oid.h has the same extension as the compiler version. - - asn_real.c: the tbl version at two places has - exponent >>= 8; - where the c_lib has - exponent >> 8; - since the latter is a statement without any effect, that's - probably the buggy version... - - tbl_*/asn_tag.[hc]: two additional macros, CONSIFY() and - DECONSIFY(), and an additional function, PeekTag(). - - asn_useful.c: the c_lib version contains two dozen used - variables, so why not use the tbl version? - - exp_buf.h ... - - files only found in tbl_include: gen_buf.h, - tbl{,_dec,_enc,_free,_gen_c_hdr,_incl,_print,_util}.h. - - files only found in tbl_lib: gen_buf.c, - tbl{,_dec,_enc,_free,_print,_util}.c. - - sbuf.[hc]: tbl uses functions, c_lib defines cpp macros. - - * modified the makefiles to include depend, install, clean and - clobber phony targets following the usual conventions. - - * INSTALL, mkinstalldirs and install.sh copied from autoconf-1.11. - - * 1.0-to-1.1-changes renamed to NEWS. README.changes that starts - with a line reading ``Changes between 1.0 and 1.1'' merged into NEWS. - - * collected common code from compiler/core/snacc_config.h, - c_lib/inc/asn_config.h and c++_lib/inc/asn_config.h into config.h.bot. - - * adding support for configuration via GNU autoconf: - - writing a configure.in, acconfig.h, makehead.in. - - replace a lot of macros in the makefiles with an inclusion of a - makehead file generated by configure. since file inclusion has - been a feature supported since UNIX System III, i consider it - pretty portable. - - * first cvs import. - - * inserting RCS keywords as a preparation for cvs import. - -Sat Aug 27 11:59:08 1994 Robert Joop (rj@rainbow.in-berlin.de) - - * fixed the developer's nightmare that for every tiny change, - virtually everything was remade. - - * -DFLEX ain't necessary since flex defines FLEX_SCANNER already. - - * renamed asn1.lex to lex-asn1.l and asn1.yacc to parse-asn1.y to - take advantage of make's default rules. - - * collision of #define Free() in the compiler's mem.h and a member - called Free in c_lib's struct AnyInfo in asn_any.h resolved. - - * changed the directory structure. the content of .../c_lib/ + - .../c_include/ was almost identical to that of .../src/c_lib/, so - i merged them. .../src/ isn't the only directory containing - source, so i renamed it to compiler. to sum it up: - - old: new: - .../src/back_ends .../compiler/back_ends - .../src .../compiler/core - .../src/c_lib -> merged with .../c_{lib,include} - .../c_lib .../c_lib/src - .../c_include .../c_lib/inc - .../c++_lib .../c++_lib/src - .../c++_include .../c++_lib/inc - - the differences found between .../src/c_lib/ and - .../c_{lib,include}/: - - Malloc()/Free() vs. NibbleAlloc() - - snacc_config.h partially copied to asn_config.h - - for the compiler, struct OID in asn_oid.h contains an additional - member. - - the functions AsnListConcat(), AsnListFree() and - GetAsnListElmtIndex() existed in the compiler version only. - the mixture of Asn1Alloc() in combination with Free() and free() - has been unified to using Asn1Free(). - - yet another almost identical copy of c_lib/ can be found in - .../tbl_{lib,include}/. - - * since the code was quite inconsistent in respect of where lines - were broken (many short lines that unbroken are shorter than 72 - columns were broken, and many long lines were broken into pieces - that were much longer than 80 columns), i took the liberty to - unify the layout. - - * some international rules of typography: - - put a space before an opening parenthesis, and one after a - closing one. - - no space after an opening parenthesis, or before a closing one. - - no space before punctuation. - - one space after punctuation (in some countries two after a full - stop). - - * a space somewhere between function name and first argument helps - to see that there are actually two words, not just one. for me, - AlongFunctionName(andanArgument, ...) - looks too much like - AlongFunctionNameCandanArgument, ...) - and thus i prefer - AlongFunctionName (andanArgument, ...) - - * moved `*' and `&' from the type to the value. that's where C and - C++ bind them to! people are often mislead by this and generate - bugs like - char* p1, p2; - instead of - char *p1, *p2; - which they really meant. blame K&R, not me :-) - - * removed trailing blank lines. they simply produce blank pages - when the file is printed out. some files had got a dozen of them! - - * trailing white space removed. noted here because it might cause - problems when someone wants to integrate patches; but vi users - hate empty lines that aren't empty because of white space, since - it keeps some movement commands from working. - - * one of IBM ENC's changes is the addition of C++ destructors. - this change was clearly marked and therefore i removed the - #defines. - - * i took the official snacc-1.1 distribution and made a diff(1) to - another version modified by IBM ENC. this diff has been merged - with the official version using `patch -D _IBM_ENC_`. diff --git a/SecuritySNACCRuntime/INSTALL b/SecuritySNACCRuntime/INSTALL deleted file mode 100644 index 8a7d026f..00000000 --- a/SecuritySNACCRuntime/INSTALL +++ /dev/null @@ -1,146 +0,0 @@ - This is a generic INSTALL file for utilities distributions. -If this package does not come with, e.g., installable documentation or -data files, please ignore the references to them below. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation, and -creates the Makefile(s) (one in each subdirectory of the source -directory). In some packages it creates a C header file containing -system-dependent definitions. It also creates a file `config.status' -that you can run in the future to recreate the current configuration. - -To compile this package: - -1. Configure the package for your system. - - Normally, you just `cd' to the directory containing the package's -source code and type `./configure'. If you're using `csh' on an old -version of System V, you might need to type `sh configure' instead to -prevent `csh' from trying to execute `configure' itself. - - Running `configure' takes awhile. While it is running, it -prints some messages that tell what it is doing. If you don't want to -see any messages, run `configure' with its standard output redirected -to `/dev/null'; for example, `./configure >/dev/null'. - - To compile the package in a different directory from the one -containing the source code, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. If -for some reason `configure' is not in the source code directory that -you are configuring, then it will report that it can't find the source -code. In that case, run `configure' with the option `--srcdir=DIR', -where DIR is the directory that contains the source code. - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. Alternately, you can do so by consistently -giving a value for the `prefix' variable when you run `make', e.g., - make prefix=/usr/gnu - make prefix=/usr/gnu install - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH' or set the `make' -variable `exec_prefix' to PATH, the package will use PATH as the prefix -for installing programs and libraries. Data files and documentation -will still use the regular prefix. Normally, all files are installed -using the same prefix. - - Some packages pay attention to `--with-PACKAGE' options to -`configure', where PACKAGE is something like `gnu-as' or `x' (for the -X Window System). They may also pay attention to `--enable-FEATURE' -options, where FEATURE indicates an optional part of the package. The -README should mention any `--with-' and `--enable-' options that the -package recognizes. - - `configure' also recognizes the following options: - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' - Do not print messages saying which checks are being made. - -`--verbose' - Print the results of the checks. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--x-includes=DIR' - X include files are in DIR. - -`--x-libraries=DIR' - X library files are in DIR. - - `configure' also accepts and ignores some other options. - - On systems that require unusual options for compilation or linking -that the package's `configure' script does not know about, you can give -`configure' initial values for variables by setting them in the -environment. In Bourne-compatible shells, you can do that on the -command line like this: - - CC='gcc -traditional' LIBS=-lposix ./configure - -On systems that have the `env' program, you can do it like this: - - env CC='gcc -traditional' LIBS=-lposix ./configure - - Here are the `make' variables that you might want to override with -environment variables when running `configure'. - - For these variables, any value given in the environment overrides the -value that `configure' would choose: - - - Variable: CC - C compiler program. The default is `cc'. - - - Variable: INSTALL - Program to use to install files. The default is `install' if you - have it, `cp' otherwise. - - For these variables, any value given in the environment is added to -the value that `configure' chooses: - - - Variable: DEFS - Configuration options, in the form `-Dfoo -Dbar...'. Do not use - this variable in packages that create a configuration header file. - - - Variable: LIBS - Libraries to link with, in the form `-lfoo -lbar...'. - - If you need to do unusual things to compile the package, we encourage -you to figure out how `configure' could check whether to do them, and -mail diffs or instructions to the address given in the README so we -can include them in the next release. - -2. Type `make' to compile the package. If you want, you can override -the `make' variables CFLAGS and LDFLAGS like this: - - make CFLAGS=-O2 LDFLAGS=-s - -3. If the package comes with self-tests and you want to run them, -type `make check'. If you're not sure whether there are any, try it; -if `make' responds with something like - make: *** No way to make target `check'. Stop. -then the package does not come with self-tests. - -4. Type `make install' to install programs, data files, and -documentation. - -5. You can remove the program binaries and object files from the -source directory by typing `make clean'. To also remove the -Makefile(s), the header file containing system-dependent definitions -(if the package uses one), and `config.status' (all the files that -`configure' created), type `make distclean'. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need it if you want to regenerate -`configure' using a newer version of `autoconf'. diff --git a/SecuritySNACCRuntime/MacOSX-Install b/SecuritySNACCRuntime/MacOSX-Install deleted file mode 100755 index 84f54770..00000000 --- a/SecuritySNACCRuntime/MacOSX-Install +++ /dev/null @@ -1,14 +0,0 @@ -: -export LEXLIB="-ll" -export CFLAGS="-DMACOS -DYYTEXT_POINTER" -export srcdir=`pwd` -echo === running configure.... -chmod a+x configure -./configure -rm -f c++-lib/inc/config.h -cp -p config.h c++-lib/inc -echo === running make depend for $srcdir.... -make depend srcdir=$srcdir -echo === running make compiler.... -#make all srcdir=$srcdir -make compiler srcdir=$srcdir diff --git a/SecuritySNACCRuntime/MacOSX-configure b/SecuritySNACCRuntime/MacOSX-configure deleted file mode 100644 index 3fea3a51..00000000 --- a/SecuritySNACCRuntime/MacOSX-configure +++ /dev/null @@ -1,6 +0,0 @@ -: -export LEXLIB="-ll" -export CFLAGS="-DMACOS -DYYTEXT_POINTER" -./configure -rm -f c++-lib/inc/config.h -cp config.h c++-lib/inc diff --git a/SecuritySNACCRuntime/MacOSX-make b/SecuritySNACCRuntime/MacOSX-make deleted file mode 100644 index 396f6d30..00000000 --- a/SecuritySNACCRuntime/MacOSX-make +++ /dev/null @@ -1,21 +0,0 @@ -# -# dummy make file to launch MacOSX-Install -# - -first all: - $(SRCROOT)/MacOSX-Install - -clean: - echo === Cleaning snacc source via Makefile === - (cd $(SRCROOT); make clean srcdir=$(SRCROOT)) - -# -# used very infrequently to recompile asn-useful.asn -# -asn-useful: - (cd c++-lib; \ - rm -f inc/asn-useful src/asn-useful.cpp c++/asn-useful.cpp stamp-useful; \ - make stamp-useful; \ - cp src/asn-useful.cpp c++) - -# FIXME - install? diff --git a/SecuritySNACCRuntime/NEWS b/SecuritySNACCRuntime/NEWS deleted file mode 100644 index ec1c5e27..00000000 --- a/SecuritySNACCRuntime/NEWS +++ /dev/null @@ -1,160 +0,0 @@ -======================================================================= - -main changes between versions 1.1 and 1.2: - -* ports to linux and alpha, which should make snacc both endianess and - 64 bit clean. -* to complement the destructors, T::T (const T&) and - T &T::operator = (const T &) have been added to override the defaults - supplied by the compiler. reason: simple pointer duplication may lead - to unreferenced objects and to objects referenced more than once (on - which the destructors delete may choke). -* the files asn_useful.[hcC] and tbl.[ch] get regenerated automagically. - since the compiler itself is compiled with it, a bootstapping version - is included in the distribution. -* the choice selector and all pointer members get initialized to get - predictable behaviour from the destructors (C++ code only, the C code - may still be broken!). -* turned C++ inline functions into normal functions. this can reduce - the size of .o files and executables dramatically! (the change was - partially made by IBM ENC.) -* the c++ lib compiles under gcc 2.6 (which has the bool type built-in). -* GNU autoconf support added. -* makefiles rewritten to provide the usual phony targets. -* code duplication (4 config files, 3 c_libs) reduced. -* C++ destructors added (partially contributed by IBM ENC). - -======================================================================= - - Snacc Changes from version 1.0 to 1.1 - -Thanks to many bug reports from users of snacc 1.0, snacc 1.1 is more -reliable. Most of the changes between 1.0 and 1.1 are listed in the -"1.0-to-1.1-changes" file. - -Type tables are the biggest addition. The rest were mostly bug fixes. -If you reported a bug and you don't see the fix, I either didn't have -time or simply forgot. Sorry. - -See README.future for the status of snacc now that I have graduated. - -The remainder of this file contains descriptions of many of the fixes -between version 1.0 and 1.1. I am sure there are fixes that are not -documented here. - -======================================================================= - -The GNU Library Public License (LGPL) has been punted. - -======================================================================= -Added table generation the compiler - -files: src/{ tbl.c tbl.h gen_tbls.c } -======================================================================= - -Added table libraries and tools - -files: tbl_include/* tbl_lib/* tbl_tools/* tbl_example/* -======================================================================= - -Re-aligned data structure for parse tree with code generated by -newer version of snacc (yes, the parse tree was originally defined -in ASN.1 - see asn1specs/asn1module.asn1) - -======================================================================= -defined T61String and ISO646String Tag codes. - -files: snacc/c_inlcude/asn_tag.h and snacc/c++_inlcude/asn_tag.h - -#define TT61STRING_TAG_CODE TELETEXSTRING_TAG_CODE -#define ISO646STRING_TAG_CODE VISIBLESTRING_TAG_CODE - -======================================================================= - -Named arcs in OBJECT IDENTIFER values no longer generate ASN.1 integers. -e.g. test OBJECT IDENTIFIER ::={2 3 4 ds(5) 1} - -used to be equivalent to: - ds INTEGER ::= 5 - test OBJECT IDENTIFER ::= {2 3 4 ds 1} - -Snacc now ignores the name (ds in this case). Ideally the arc could -be entered into an object identifier tree maintained by snacc. - -files: snacc/src/val_parser.c - -======================================================================= - -Fixed bug in macro definition parsing that threw off the line -number global. - -file: asn1.lex - -======================================================================= - -Added file and line number information to import errors. - -A lineNo field was added to the ImportElmt and ImportModule data -structures. The yacc code for the import elements & modules sets the -lineNo values correctly. The error reporting code in line_types.c and -line_values.c now prints the line number info. - -files: link_types.c link_values.c asn1module.h asn1.yacc - - -======================================================================= - -Added some line number info to multiply defined symbol error reports - -file: err_chk.c - uses importElmt line number info - -======================================================================= - -Added line number info to export errors. - -======================================================================= - -Added file and line number info to typing errors for OBJECT -IDENTIFIER values. Also stopped errors that cascade from other -OID values referencing a malformed oid value. - -file: normalize.c - - -======================================================================= - -Error messages will be printed for recursively defined OBJECT -IDENTIIFER values. - -file: link_values.c - -======================================================================= - -Fixed bug #20. ie Not grabbing EOC on tagged (by def or in parent) - CHOICEs embedded in other SET, SEQ, CHOICE, SET OF or SEQ OF types. - -file: gen_c_dec.c - -======================================================================= - -Fixed bug #21. ie Value linking problem when assigning a value -to a choice with a named number from one of the choice's elmts. - -file: link_values.c, snacc_util.c (added routine "GetAllNamedElmts") - -======================================================================= - - -Fixed bug #22 - potentially not allocating enough space for - a C++ field name conflict - -file: snacc/src/back_ends/c++_gen/cpp_types.c - -======================================================================= - -Fixed nibble alloc bug. curr pointer could be incremened past - end ptr which then caused problems with new allocs. - -file: c_lib/nibble_alloc.c tbl_lib/nibble_alloc.c - -======================================================================= diff --git a/SecuritySNACCRuntime/README b/SecuritySNACCRuntime/README deleted file mode 100644 index 69e5c003..00000000 --- a/SecuritySNACCRuntime/README +++ /dev/null @@ -1,230 +0,0 @@ -This new release, 1.3, consists of some improvements and bug fixes: - -New in 1.3: - * Corrected bug in generic table decoder wrt. indefinite length elements - * Corrected compiler access to freed memory (bug reported by Markku Savela) - * Broke asnwish.c into two pieces so that one can build ones own wish - * Added "beredit" tool (based on asnwish, allowes to edit BER messages) - -New in 1.3b4: - * Generic table decoding routines with callback mechanism in tbl library - * New tool "berdecode", decoding any BER data, can also use table file - * New Tcl/Tk tool "asnwish", reads table files, access to grammar, en-/decoding - * Fix for tag values > 2^14 (credits to Enrico Badella) - * Fix for table-encoding tag values dividable by 128 - * Small fix in AsnBits::GetBit to return TRUE (i.e., 1) instead of #bit in byte - -New in 1.3b3: - * Added isPdu flag to tables - * Added number range checks during parsing - -New in 1.3b2: - * Small fix of C value string generation w char >127 (credits to Marc LeFur) - * Added (limited) size constraints, bitstring and enumeration names to tables - -New in 1.3b1: - * Made snacc.h more C++-readable (credits to Steve Walker). - * Improved dependency generation for stupid makedepends. - * Corrected PeekTag to peek into buffer only as far as necessary. - * Added installable error handler. - * Fixed small glitch in idl-code generator (credits to Markku Savela). - * Finally fixed cut-and-paste error in SEQUENCE OF parsing. - -New in 1.3a: - * Continued porting C, C++, tbl to 64 bit, any endianness: Hash typedef, - PeekTag algorithm used by tables. - * Fixed cut-and-paste error in SEQUENCE OF parsing. - * Added missing initialisation of exponent in asn-real.[Cc]. - * Fixed tbl-free.c and some other table-related bugs. - * Added casts and stuff for picky C++ compilers. - * Incorporated all valid bug fixes from snacc-bugs. - * Initial move of tcl stuff to tcl7.6/tk4.2/tree4.1. - - -WARNING: the rest of this README is out of date! - - -For the newer releases, please look at - - http://www.fokus.gmd.de/ovma/freeware/snacc/entry.html - -Please send comments and bug reports to the new maintainer you will find -in the above web page. - -Newer Snacc versions will continue to be made available at: - - ftp://ftp.fokus.gmd.de/pub/freeware/snacc/ - -Robert Joop, 1997-02-16 - - - -For more up-to-date information, please refer to doc/snacc.ps. - -The bug-report address given below was for Snacc 1.1. - - - - -snacc ASN.1 Compiler Release 1.1 - (updated Jul 93) ------------------------------------------------------ - -This package provides the C/yacc/lex source code for snacc, an ASN.1 -to C or C++ compiler. Snacc is short for "Sample Neufeld Asn.1 to C -Compiler" and ASN.1 stands for Abstract Syntax Notation One (CCITT -X.208/ ISO 8824). See the COPYRIGHT file for copyright information. - - -What It Does ------------- - -Given an ASN.1 source file(s) snacc can produce: - - 1. C routines for BER encoding, decoding, printing and freeing. - 2. C++ routines for BER encoding, decoding, and printing. - 3. A type table that can be used with C driver routines - for BER encoding, decoding, printing and freeing. - 4. if you are really lucky, a core dump! :) - -Snacc produces reasonably efficient C or C++ routines and data -structures to support BER encoding and decoding values of the given -ASN.1 data structures. Printing routines for the decoded values are -also generated. For C only, hierarchical freeing routines are -generated (but are not recommended for efficiency reasons). - -When using the C or C++ (not table) options, snacc creates the -following C files for each ASN.1 source file (module): - - 1. .h file for the C/C++ translation of the ASN.1 data - structure and prototypes for the generated routines. - - 2. .c/.C file for the C/C++ encode, decode, print and free - routines. - -When using the table option, snacc produces a type table file -(a BER encoding) that can later be loaded at runtime by the -table driven encoding and decoding routines. - -See the latex or PostScript version of the documentation in the -snacc/doc directory for indepth information on this tool. For a quick -introduction, look at the examples in snacc/c_examples, -snacc/c++_examples and snacc/tbl_example. - - -Features of ASN.1 Supported ---------------------------- - - - parses ASN.1 '90 (subtype notation etc.) - - macro definitions do not generate syntax errors but are - are not processed. (retained as string) - - value notation is parsed and for OBJECT IDENTIFIERs, INTEGERs - and BOOLEANS (any other value in { }'s is currently kept as a string) - - handles multiple ASN.1 module compiling/linking (IMPORTS/EXPORTS) - - some X.400 and SNMP macros are parsed - - supports ";" separted type or value definitions in the ASN.1 source. - This is useful when dealing with some macros that introduce parsing - problems. Does not require the ";"'s though. - - ANY DEFINED BY types are handled using the SNMP OBJECT-TYPE - macro to define the identifier to type mapping. - - -Bugs are still quite likely even though this is the second release of -snacc. if you find any or have other comments please email: - snacc-bugs@cs.ubc.ca - - -To Install It -------------- - -By default, the snacc makefile uses GNU bison and GNU flex (instead of -yacc and lex). If you do not have these installed, see the -snacc/src/README and snacc/src/makefile. Otherwise, type "make" in -this directory. Hopefully this will put the snacc binary in the -snacc/bin directory and build the C runtime library, the table library -and the table tools. Alternatively, type "make all" to install these -and the C++ library. - -Compiling problems may occurr on different flavours of UNIX but they -should not be too difficult fix. Likely sources of problems include -non-standard include files and lex, yacc and cc idiosyncrasies. -If your yacc croaks with a message about too many productions use -bison. Same thing with lex -> use flex. Bison and flex are both -freely available from numerous ftp sites. (even cs.ubc.ca in /mirror2/gnu) - -The makefiles take advantage of the file inclusion feature. Since this -has already been supported by UNIX System III make (somewhen around -1980), I consider it to be pretty portable. If your make is crippled, -either use a newer one (e.g. GNU make), or as a last resort, remove the -include statements and call make with `-f makehead makefile maketail'. - The dependencies have been moved into a separate file that is not -under cvs control. Otherwise, the makefiles would inflate the -repository unnecessarily. GNU make automatically makes the dependencies -if the file does not exist, but other makes simply give up. In that -case, an initial (empty) file has to be generated. The top level -makefile does this for you. - The behaviour of makedepend has been changed between X11R5 and R6. -The new version keeps the source files' dirname and replaces the suffix -only, the old version removed the dirname. The makefiles expect the -new behaviour. If you've still got the R5 makedepend, the compiler's -dependencies will be useless. (If you only install the code and don't -make any changes, this won't hurt you.) - -The snacc compiler and the generated code will compile under ANSI and -non-ANSI C compilers. See the README and the makefile in the -snacc/src directory for more compiling information. Snacc has been -successfully installed on Sun SPARCs, HP700s, IBM RS 6000s, MIPS, -i486/Linux, Alpha OSF/1 and many other machines. - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/README,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:04 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:50 aram -# Originals from SMIME Free Library. -# -# Revision 1.14 1997/10/10 13:42:31 wan -# Corrected bug in generic table decoder wrt. indefinite length elements -# Corrected compiler access to freed memory (bug reported by Markku Savela) -# Broke asnwish.c into two pieces so that one can build ones on wish -# Added beredit tool (based on asnwish, allowes to edit BER messages) -# -# Revision 1.13 1997/09/16 14:57:59 wan -# Proper description of last-minute changes -# -# Revision 1.12 1997/09/05 07:51:04 wan -# Updated -# -# Revision 1.11 1997/08/28 09:48:08 wan -# Added description of changes -# -# Revision 1.10 1997/06/19 09:32:22 wan -# Added 1.3b3 change description -# -# Revision 1.9 1997/05/07 15:20:57 wan -# Added (limited) size constraints, bitstring and enumeration names to tables -# -# Revision 1.8 1997/04/07 13:14:16 wan -# Final README for 1.3b1 -# -# Revision 1.7 1997/03/20 15:50:24 wan -# Push to 1.3b1. -# -# Revision 1.6 1997/02/16 22:26:40 rj -# url corrected -# -# Revision 1.5 1997/02/16 20:23:14 rj -# final release of snacc 1.2rj -# -# Revision 1.4 1995/09/07 20:54:03 rj -# check-in for release 1.2rj.8 -# -# Revision 1.3 1995/02/22 09:54:05 rj -# added Alpha OSF/1 to the list of supported platforms. -# -# Revision 1.2 1994/09/01 01:40:54 rj -# some word about makefile inclusion and dependencies added. -# -# Revision 1.1 1994/08/28 11:02:04 rj -# first check-in diff --git a/SecuritySNACCRuntime/VDADER_RULES.TXT b/SecuritySNACCRuntime/VDADER_RULES.TXT deleted file mode 100644 index 05779798..00000000 --- a/SecuritySNACCRuntime/VDADER_RULES.TXT +++ /dev/null @@ -1,24 +0,0 @@ - -This is an interim release of the VDA Enchanced version of the SNACC 1.3. To -enable the use of DER encoding you need to use the "-D" command line option. -The DER rules enchancements have been made to the C++ side only so don't -forget the "-C" (C++) option. - -At this time this modified version is closely tied to the VDA developed SFL -library. If you use the "-D" it's assumed that you are also using the SFL -in which case there is no problem. However, if you want to use this version -of SNACC standalone you will need to acquire the sm_vdasnacc.h and -sm_vdasnacc.cpp files from the SFL distribution. This situation is temporary. -As we fix/add features into SNACC we will most likely move those files into -our enchanced SNACC distribution. - -Also.. The file comments have not been updated yet. However, I did include -the SCCS (SunOS 4.1.3 SCCS) files so that the changes we made can be reviewed -by those wishing to do so. We will merge the comments from the SCCS history -into each modified file when modifications are complete. - -For more information on the SFL try http://www.jgvandyke.com - -Pierce Leonberger -Systems Engineer -J.G. Van Dyke & Associates (VDA) diff --git a/SecuritySNACCRuntime/acconfig.h b/SecuritySNACCRuntime/acconfig.h deleted file mode 100644 index 32786e33..00000000 --- a/SecuritySNACCRuntime/acconfig.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * file: acconfig.h - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/acconfig.h,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ - * $Log: acconfig.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:04 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:16 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:05:47 aram - * Originals from SMIME Free Library. - * - * Revision 1.7 1997/03/03 11:58:26 wan - * Final pre-delivery stuff (I hope). - * - * Revision 1.6 1997/02/28 13:39:34 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.5 1997/02/15 20:01:37 rj - * check whether the compiler supports volatile functions (and whether abort() is volatile). - * - * Revision 1.4 1995/02/20 11:16:57 rj - * cpp switch HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS added. - * - * Revision 1.3 1995/02/13 14:46:49 rj - * settings for IEEE_REAL_FMT/IEEE_REAL_LIB moved from {c_lib,c++_lib}/inc/asn_config.h to acconfig.h. - * - * Revision 1.2 1994/10/08 04:38:56 rj - * slot for autoconf Tcl detection added. - * - * Revision 1.1 1994/09/01 00:51:19 rj - * first check-in (new file). - * - */ - -/* - * define IEEE_REAL_FMT if your system/compiler uses the native ieee double - * this should improve the performance of encoding reals. - * If your system has the IEEE library routines (iszero, isinf etc) - * then define IEEE_REAL_LIB. If neither are defined then - * frexp is used. Performance is probaby best for IEEE_REAL_FMT. - * - * #define IEEE_REAL_FMT - * #define IEEE_REAL_LIB - */ -/* use ANSI or K&R style C? */ -#undef __USE_ANSI_C__ - -/* does the C++ compiler have the bool type built-in? */ -#undef BOOL_BUILTIN - -/* does the C++ compiler allow variable sized automatic arryas? */ -#undef HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS - -/* do we have all the libs we need for the Tcl interface? */ -#undef HAVE_TCL - -/* does the compiler support volatile functions (and is abort() volatile?) */ -#undef COMPILER_WITHOUT_VOLATILE_FUNCTIONS diff --git a/SecuritySNACCRuntime/asn1specs/any.asn1 b/SecuritySNACCRuntime/asn1specs/any.asn1 deleted file mode 100644 index dbf5ac0a..00000000 --- a/SecuritySNACCRuntime/asn1specs/any.asn1 +++ /dev/null @@ -1,116 +0,0 @@ --- file: asn1specs/any.asn1 --- --- this file is used in ../c{,++}-examples/any/ --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/any.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: any.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:55 aram --- Originals from SMIME Free Library. --- --- Revision 1.2 1997/02/16 20:25:20 rj --- check-in of a few cosmetic changes --- --- Revision 1.1 1994/08/31 22:44:44 rj --- first check-in. - -ANY-TEST DEFINITIONS ::= BEGIN - --- --- use the SNMP OBJECT type to define the correlation between --- the identifying INTEGER/OBJECT IDENTIFIER --- and the ANY DEFINED BY type --- - -intId OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - ::= 1 - -boolId OBJECT-TYPE - SYNTAX BOOLEAN - ACCESS read-write - STATUS mandatory - ::= 2 - -octsId OBJECT-TYPE - SYNTAX [PRIVATE 2] IMPLICIT OCTET STRING - ACCESS read-write - STATUS mandatory - ::= 3 - -bitsId OBJECT-TYPE - SYNTAX [PRIVATE 1] BIT STRING - ACCESS read-write - STATUS mandatory - ::= 4 - -realId OBJECT-TYPE - SYNTAX REAL - ACCESS read-write - STATUS mandatory - ::= 5 - --- --- note that the following OBJECT-TYPE OBJECT IDENTIFIER values --- reference the previous OBJECT-TYPE INTEGER values - -intOid OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - ::= { 0 1 2 3 4 intId} - -boolOid OBJECT-TYPE - SYNTAX BOOLEAN - ACCESS read-write - STATUS mandatory - ::= { 0 1 2 3 4 boolId} - -octsOid OBJECT-TYPE - SYNTAX OCTET STRING - ACCESS read-write - STATUS mandatory - ::= { 0 1 2 3 4 octsId} - -bitsOid OBJECT-TYPE - SYNTAX BIT STRING - ACCESS read-write - STATUS mandatory - ::= { 0 1 2 3 4 bitsId} - -realOid OBJECT-TYPE - SYNTAX REAL - ACCESS read-write - STATUS mandatory - ::= { 0 1 2 3 4 realId} - - --- this type tests both the INTEGER and OBJECT IDENTIFIER mapping -AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE -{ - intMap TSeq1, - oidMap TSeq2 -} - -TSeq1 ::= SEQUENCE OF AttrValue1 - - -AttrValue1 ::= SEQUENCE -{ - id INTEGER, - ANY DEFINED BY id -} - -TSeq2 ::= SEQUENCE OF AttrValue2 - -AttrValue2 ::= SEQUENCE -{ - id OBJECT IDENTIFIER, - ANY DEFINED BY id -} - -END diff --git a/SecuritySNACCRuntime/asn1specs/asn-useful.asn1 b/SecuritySNACCRuntime/asn1specs/asn-useful.asn1 deleted file mode 100644 index 72f7b626..00000000 --- a/SecuritySNACCRuntime/asn1specs/asn-useful.asn1 +++ /dev/null @@ -1,99 +0,0 @@ -ASN-USEFUL DEFINITIONS ::= -BEGIN - --- file: .../asn1specs/asn-useful.asn1 --- --- NOTE: every one of these types is marked as a PDU so the compiler --- will produce the encode and decode routines that --- enc/dec the top tag/len pairs, not just the content decoders. --- (only nec for re-generating the library files "asn_useful.[ch]"). --- The isPdu field does not affect how this module is linked --- with other modules during compilation. --- --- (type DEF comment directives immediately follow the "::=") --- --- MS 92 --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/asn-useful.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: asn-useful.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.2 2000/06/08 19:58:05 dmitch --- Added UTF8String. --- --- Revision 1.1.1.1 1999/03/16 18:05:55 aram --- Originals from SMIME Free Library. --- --- Revision 1.3 1995/07/24 15:12:35 rj --- useful.asn1 renamed to asn-useful.asn1 to accomodate to snacc's new file name generation scheme. --- --- Revision 1.2 1994/08/28 09:54:19 rj --- comment leader fixed. --- --- Revision 1.1 1994/08/28 09:51:15 rj --- first check-in. - - -ObjectDescriptor ::= -- isPdu:"TRUE" -- - [UNIVERSAL 7] IMPLICIT OCTET STRING - -UTF8String ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 12] IMPLICIT OCTET STRING - -NumericString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 18] IMPLICIT OCTET STRING - -PrintableString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 19] IMPLICIT OCTET STRING - -TeletexString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 20] IMPLICIT OCTET STRING - -T61String ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 20] IMPLICIT OCTET STRING - -VideotexString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 21] IMPLICIT OCTET STRING - -IA5String ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 22] IMPLICIT OCTET STRING - -GraphicString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 25] IMPLICIT OCTET STRING - -VisibleString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 26] IMPLICIT OCTET STRING - -ISO646String ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 26] IMPLICIT OCTET STRING - -GeneralString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 27] IMPLICIT OCTET STRING - -UTCTime ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 23] IMPLICIT OCTET STRING - -GeneralizedTime ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 24] IMPLICIT OCTET STRING - -UniversalString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 28] IMPLICIT OCTET STRING - -BMPString ::= --snacc isPdu:"TRUE" -- - [UNIVERSAL 30] IMPLICIT OCTET STRING - -EXTERNAL ::= --snacc isPdu:"TRUE" -- [UNIVERSAL 8] IMPLICIT SEQUENCE -{ - direct-reference OBJECT IDENTIFIER OPTIONAL, - indirect-reference INTEGER OPTIONAL, - data-value-descriptor ObjectDescriptor OPTIONAL, - encoding CHOICE - { - single-ASN1-type [0] OCTET STRING, -- should be ANY - octet-aligned [1] IMPLICIT OCTET STRING, - arbitrary [2] IMPLICIT BIT STRING - } -} - -END -- of ASN-USEFUL type definitions diff --git a/SecuritySNACCRuntime/asn1specs/asn1module.asn1 b/SecuritySNACCRuntime/asn1specs/asn1module.asn1 deleted file mode 100644 index 66014144..00000000 --- a/SecuritySNACCRuntime/asn1specs/asn1module.asn1 +++ /dev/null @@ -1,673 +0,0 @@ --- file: .../asn1specs/asn1module.asn1 --- --- This module describes the data structure used to reprsent the --- compiled ASN.1. --- Using ASN.1 for the internal data structure allows writing --- (encoding) to disk for storage (not done yet due to recursive --- refs back to the module) --- --- Mike Sample 91/08/29 --- Modifed 92/05 MS --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/asn1module.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: asn1module.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:55 aram --- Originals from SMIME Free Library. --- --- Revision 1.3 1995/07/25 20:04:04 rj --- data structures added for idl backend. --- --- Revision 1.2 1994/08/28 09:54:16 rj --- comment leader fixed. --- --- Revision 1.1 1994/08/28 09:51:11 rj --- first check-in. - -Asn1Module DEFINITIONS IMPLICIT TAGS ::= -BEGIN - - --- exports everything --- imports nothing - - -Modules ::= [APPLICATION 0] IMPLICIT SEQUENCE -{ - creationTime INTEGER, - modules ModuleList -} - -ModuleList ::= SEQUENCE OF Module - - -Module ::= SEQUENCE -{ - status ENUMERATED { mod-ok(0), mod-not-linked(1), mod-error(2) }, - modId ModuleId, - tagDefault ENUMERATED { explicit-tags(0), implicit-tags(1) }, - exportStatus ENUMERATED { exports-all(0), exports-nothing(1), - exports-some(2) }, - imports ImportModuleList, - typeDefs TypeDefList, - valueDefs ValueDefList, - hasAnys BOOLEAN, - - asn1SrcFileName MyString, - cHdrFileName MyString, - cSrcFileName MyString, - cxxHdrFileName MyString, - cxxSrcFileName MyString, - - dbHdrFileName MyString, -- IBM-ENC - dbSrcFileName MyString, -- IBM-ENC - - cxxname MyString, -- META - - idlFileName MyString, -- IDL - idlname MyString -- IDL -} - - -ModuleId ::= SEQUENCE -{ - name MyString, - oid OBJECT IDENTIFIER OPTIONAL --snacc cTypeName:"OID" isPtr:"TRUE" -} - - -ImportModuleList ::= SEQUENCE OF ImportModule - - -ImportModule ::= SEQUENCE -{ - modId ModuleId, - importElmts ImportElmtList, - moduleRef Module, --snacc isEncDec:"FALSE" - lineNo INTEGER -} - - -ImportElmtList ::= SEQUENCE OF ImportElmt - - -ImportElmt ::= SEQUENCE -{ - resolvedRef CHOICE - { - type [0] TypeDef, -- not encoded - value [1] ValueDef -- not encoded - } OPTIONAL, - name MyString, - privateScope BOOLEAN, -- true if from MODNAME.TYPE ref - lineNo INTEGER -} - -TypeDefList ::= SEQUENCE OF TypeDef - -OidOrInt ::= CHOICE -{ - oid OBJECT IDENTIFIER, - intId INTEGER -} - -AnyRef ::= SEQUENCE -{ - anyIdName MyString, - id OidOrInt -} - -AnyRefList ::= SEQUENCE OF AnyRef - -TypeDef ::= SEQUENCE -{ - exported BOOLEAN, - recursive BOOLEAN, - isPdu BOOLEAN, - localRefCount INTEGER, - importRefCount INTEGER, - tmpRefCount INTEGER, - visited BOOLEAN, - definedName MyString, - type Type, - cTypeDefInfo CTDI, - cxxTypeDefInfo CxxTDI, - attrList AttributeList, - refList TypeDefList, - anyRefs AnyRefList -} - - -Tag ::= SEQUENCE -{ - tclass INTEGER, -- swap this for the BER_CLASS enum from basetypes.h - form INTEGER, -- swap this for the BER_FORM enum - code INTEGER, - explicit BOOLEAN, - valueRef Value -} - -Type ::= SEQUENCE -{ - optional BOOLEAN, - implicit BOOLEAN, - tags TagList, - defaultVal [0] IMPLICIT NamedValue OPTIONAL, - subtypes [1] Subtype OPTIONAL, - basicType [2] BasicType, - lineNo INTEGER, - cTypeRefInfo CTRI, - cxxTypeRefInfo CxxTRI, - attrList AttributeList -} - -TagList ::= SEQUENCE OF Tag - -AttributeList ::= SEQUENCE OF MyString - -NamedNumberList ::= ValueDefList - - --- BasicTypes with NULL need no more info that which type it is --- (this is known from the choice id) - -BasicType ::= CHOICE -{ - unknown [0] IMPLICIT NULL, - boolean [1] IMPLICIT NULL, - integer [2] IMPLICIT NamedNumberList, - bitString [3] IMPLICIT NamedNumberList, - octetString [4] IMPLICIT NULL, - null [5] IMPLICIT NULL, - oid [6] IMPLICIT NULL, - real [7] IMPLICIT NULL, - enumerated [8] IMPLICIT NamedNumberList, - sequence [9] IMPLICIT NamedTypeList, - sequenceOf [10] IMPLICIT Type, - set [11] IMPLICIT NamedTypeList, - setOf [12] IMPLICIT Type, - choice [13] IMPLICIT NamedTypeList, - selection [14] IMPLICIT SelectionType, - componentsOf [15] IMPLICIT Type, -- [Resolved](local/import) type ref - any [16] IMPLICIT NULL, - anyDefinedBy [17] IMPLICIT AnyDefinedByType, - localTypeRef [19] IMPLICIT TypeRef, - importTypeRef [20] IMPLICIT TypeRef, - macroType [21] MacroType, - macroDef [22] IMPLICIT MacroDef --snacc isPtr:"FALSE" -} - -MacroDef ::= MyString -- just keep the text for now - -MacroType ::= CHOICE -{ - rosOperation [0] IMPLICIT RosOperationMacroType, - rosError [1] IMPLICIT RosErrorMacroType, - rosBind [2] IMPLICIT RosBindMacroType, - rosUnbind [3] IMPLICIT RosBindMacroType, - rosAse [4] IMPLICIT RosAseMacroType, - rosAc [5] IMPLICIT RosAcMacroType, - mtsasExtension [6] IMPLICIT MtsasExtensionMacroType, - mtsasExtensions [7] IMPLICIT MtsasExtensionsMacroType, - mtsasExtensionAttribute [8] IMPLICIT MtsasExtensionAttributeMacroType, - mtsasToken [9] IMPLICIT MtsasTokenMacroType, - mtsasTokenData [10] IMPLICIT MtsasTokenDataMacroType, - mtsasSecurityCategory [11] IMPLICIT MtsasSecurityCategoryMacroType, - asnObject [12] IMPLICIT AsnObjectMacroType, - asnPort [13] IMPLICIT AsnPortMacroType, - asnRefine [14] IMPLICIT AsnRefineMacroType, - asnAbstractBind [15] IMPLICIT AsnAbstractBindMacroType, - asnAbstractUnbind [16] IMPLICIT AsnAbstractBindMacroType, - asnAbstractOperation [17] IMPLICIT RosOperationMacroType, - asnAbstractError [18] IMPLICIT RosErrorMacroType, - afAlgorithm [19] IMPLICIT Type, - afEncrypted [20] IMPLICIT Type, - afProtected [21] IMPLICIT Type, - afSignature [22] IMPLICIT Type, - afSigned [23] IMPLICIT Type, - snmpObjectType [24] IMPLICIT SnmpObjectTypeMacroType -} - - -AnyDefinedByType ::= SEQUENCE -{ - fieldName MyString, -- name of field that its defined by - link NamedType OPTIONAL -- REFERENCE not encoded -} - - -SelectionType ::= SEQUENCE -{ - fieldName MyString, -- name of field in choice - typeRef Type, -- [Resolved](local/import) type ref - link NamedType OPTIONAL -- REFERENCE not encoded -} - -NamedTypeList ::= SEQUENCE OF NamedType - -NamedType ::= SEQUENCE -{ - fieldName MyString, -- may be empty or NULL str - type Type -} - - -TypeRef ::= SEQUENCE -{ - typeName MyString, - moduleName MyString, -- used for "modname.type" refs(may be null) - module Module, --snacc isEncDec:"FALSE" - link TypeDef --snacc isEncDec:"FALSE" -} - - - -RosOperationMacroType ::= SEQUENCE -{ - arguments NamedType, - result NamedType, - errors [0] IMPLICIT TypeOrValueList OPTIONAL, - linkedOps [1] IMPLICIT TypeOrValueList OPTIONAL -} - -ValueList ::= SEQUENCE OF Value - -TypeOrValueList ::= SEQUENCE OF TypeOrValue - -TypeOrValue ::= CHOICE -{ - type [0] IMPLICIT Type, - value [1] IMPLICIT Value -} - -OidList ::= SEQUENCE OF OBJECT IDENTIFIER - - -RosErrorMacroType ::= SEQUENCE -{ - parameter NamedType -} - -RosBindMacroType ::= SEQUENCE -{ - argument NamedType, - result NamedType, - error NamedType -} - - -RosAseMacroType ::= SEQUENCE -{ - operations ValueList, - consumerInvokes ValueList, - supplierInvokes ValueList -} - -RosAcMacroType ::= SEQUENCE -{ - nonRoElements ValueList, - bindMacroType Type, - unbindMacroType Type, - remoteOperations Value, - operationsOf ValueList, - initiatorConsumerOf ValueList, - responderConsumerOf ValueList, - abstractSyntaxes OidList -} - - -MtsasExtensionMacroType ::= SEQUENCE -{ - elmtType [0] IMPLICIT NamedType OPTIONAL, - defaultValue [1] IMPLICIT Value OPTIONAL, - criticalForSubmission [2] IMPLICIT BOOLEAN OPTIONAL, - criticalForTransfer [3] IMPLICIT BOOLEAN OPTIONAL, - criticalForDelivery [4] IMPLICIT BOOLEAN OPTIONAL -} - - -MtsasExtensionsMacroType ::= SEQUENCE -{ - extensions ValueList -} - -MtsasExtensionAttributeMacroType ::= SEQUENCE -{ - type Type OPTIONAL -} - -MtsasTokenMacroType ::= SEQUENCE -{ - type Type OPTIONAL -} - -MtsasTokenDataMacroType ::= SEQUENCE -{ - type Type OPTIONAL -} - -MtsasSecurityCategoryMacroType ::= SEQUENCE -{ - type Type OPTIONAL -} - -AsnObjectMacroType ::= SEQUENCE -{ - ports AsnPortList OPTIONAL -} - -AsnPortList ::= SEQUENCE OF AsnPort - -AsnPort ::= SEQUENCE -{ - portValue Value, - portType ENUMERATED - { - consumer-port(0), - supplier-port(1), - symmetric-port(2) - } -} - - -AsnPortMacroType ::= SEQUENCE -{ - abstractOps [0] IMPLICIT TypeOrValueList OPTIONAL, - consumerInvokes [1] IMPLICIT TypeOrValueList OPTIONAL, - supplierInvokes [2] IMPLICIT TypeOrValueList OPTIONAL -} - - -AsnRefineMacroType ::= INTEGER - -AsnAbstractBindMacroType ::= SEQUENCE -{ - ports [0] IMPLICIT AsnPortList OPTIONAL, - type [1] IMPLICIT Type OPTIONAL -} - - -SnmpObjectTypeMacroType ::= SEQUENCE -{ - syntax Type, - access ENUMERATED - { snmp-read-only(0), snmp-read-write(1), - snmp-write-only(2), snmp-not-accessible(3)}, - status ENUMERATED - { snmp-mandatory(0), snmp-optional(1), - snmp-obsolete(2), snmp-deprecated(3)}, - description [0] IMPLICIT Value OPTIONAL, - reference [1] IMPLICIT Value OPTIONAL, - index [2] IMPLICIT TypeOrValueList OPTIONAL, - defVal [3] IMPLICIT Value OPTIONAL -} - - -Subtype ::= CHOICE -{ - single [0] SubtypeValue, - and [1] IMPLICIT SubtypeList, - or [2] IMPLICIT SubtypeList, - not [3] Subtype -} - -SubtypeList ::= SEQUENCE OF Subtype - -SubtypeValue ::= CHOICE -{ - singleValue [0] IMPLICIT Value, - contained [1] IMPLICIT Type, - valueRange [2] IMPLICIT ValueRangeSubtype, - permittedAlphabet [3] Subtype, -- only valuerange or singleval - sizeConstraint [4] Subtype, -- only single value ints or val range - innerSubtype [5] IMPLICIT InnerSubtype -} - - -ValueRangeSubtype ::= SEQUENCE -{ - lowerEndInclusive BOOLEAN, - upperEndInclusive BOOLEAN, - lowerEndValue Value, - upperEndValue Value -} - - -InnerSubtype ::= SEQUENCE -{ - constraintType ENUMERATED { full-ct(0), partial-ct(1), single-ct(2) }, - constraints ConstraintList -} - -ConstraintList ::= SEQUENCE OF Constraint - -Constraint ::= SEQUENCE -{ - fieldRef MyString, -- not used if in single-ct, may be null - presenceConstraint ENUMERATED - { - present-ct(0), - absent-ct(1), - empty-ct(2), - optional-ct(3) - }, - valueConstraints Subtype -} - - -ValueDefList ::= SEQUENCE OF ValueDef - - -ValueDef ::= SEQUENCE -{ - exported BOOLEAN, - definedName MyString, - value Value -} - -Value ::= SEQUENCE -{ - type Type OPTIONAL, - valueType INTEGER, -- holds one of choiceId's def'd for BasicType - basicValue BasicValue, - lineNo INTEGER -} - -BasicValue ::= CHOICE -{ - unknown [0] IMPLICIT NULL, - empty [1] IMPLICIT NULL, - integer [2] IMPLICIT INTEGER, - specialInteger [3] IMPLICIT SpecialIntegerValue, - longInteger [4] IMPLICIT INTEGER, -- put LONG before INTGEGER - boolean [5] IMPLICIT BOOLEAN, - real [6] IMPLICIT REAL, - specialReal [7] IMPLICIT SpecialRealValue, - asciiText [8] IMPLICIT OCTET STRING, - asciiHex [9] IMPLICIT OCTET STRING, - asciiBitString [10] IMPLICIT OCTET STRING, - oid [11] IMPLICIT OBJECT IDENTIFIER, - linkedOid [12] IMPLICIT OBJECT IDENTIFIER, --snacc cTypeName:"OID" - berValue [13] IMPLICIT OCTET STRING, - perValue [14] IMPLICIT OCTET STRING, - namedValue [15] IMPLICIT NamedValue, - null [16] IMPLICIT NULL, - localValueRef [17] IMPLICIT ValueRef, - importValueRef [18] IMPLICIT ValueRef, - valueNotation [19] IMPLICIT OCTET STRING -} - - - -SpecialIntegerValue ::= ENUMERATED { min-int(0), max-int(1) } -SpecialRealValue ::= ENUMERATED { minus-infinity-real(0), plus-infinity-real(1) } - - -ValueRef ::= SEQUENCE -{ - valueName MyString, - moduleName MyString, -- used for "modname.value" refs (may be null) - link ValueDef, --snacc isEncDec:"FALSE" - module Module --snacc isEncDec:"FALSE" -} - -NamedValue ::= SEQUENCE -{ - fieldName MyString, -- may be null - value Value -} - -NamedValueList ::= SEQUENCE OF NamedValue - -CTypeId ::= ENUMERATED { c-choice(0), c-list(1), c-any(2), c-anydefinedby(3), - c-lib(4), c-struct(5), c-typeref(6), c-no-type(7), - c-typedef(8) } - --- C Type Def Info - info used for routine naming --- and referencing from other types -CTDI ::= SEQUENCE -{ - asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId" - cTypeId CTypeId, - cTypeName MyString, - isPdu BOOLEAN, - isEncDec BOOLEAN, -- if false, no routines are gen - -- and not included in encodings - isPtrForTypeDef BOOLEAN, - isPtrForTypeRef BOOLEAN, - isPtrInChoice BOOLEAN, - isPtrForOpt BOOLEAN, - - -- defines these names, used by references - optTestRoutineName MyString, -- routine/macro to check whether - -- opt type is present - defaultFieldName MyString, -- base for generating field names - - printRoutineName MyString, - encodeRoutineName MyString, - decodeRoutineName MyString, - freeRoutineName MyString, - - genPrintRoutine BOOLEAN, - genEncodeRoutine BOOLEAN, - genDecodeRoutine BOOLEAN, - genFreeRoutine BOOLEAN, - genTypeDef BOOLEAN -} - - --- --- CTRI (C Type Ref Info) is used for generating C typedefinitions --- from the ASN.1 types info -CTRI ::= SEQUENCE -{ - cTypeId CTypeId, - cFieldName MyString, - cTypeName MyString, - isPtr BOOLEAN, --- isEndCType BOOLEAN, false for struct/union def -- - cNamedElmts CNamedElmts OPTIONAL, -- for C_LIB bits/int/enums - choiceIdValue INTEGER, -- enum value of this c field - choiceIdSymbol MyString, -- this fields sym in choiceId enum - choiceIdEnumName MyString, - choiceIdEnumFieldName MyString, - optTestRoutineName MyString, -- these names are gained from refd type def - printRoutineName MyString, -- or are over-ridden snacc attribute comment - encodeRoutineName MyString, - decodeRoutineName MyString, - freeRoutineName MyString, - isEncDec BOOLEAN -- whether part of enc value -} - -CNamedElmts ::= SEQUENCE OF CNamedElmt - -CNamedElmt ::= SEQUENCE -{ - name MyString, - value INTEGER -} - - -CxxTDI ::= SEQUENCE -{ - asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId" - className MyString, - isPdu BOOLEAN, - isEnc BOOLEAN, - isPtrForTypeDef BOOLEAN, - isPtrForOpt BOOLEAN, - isPtrInChoice BOOLEAN, - isPtrInSetAndSeq BOOLEAN, - isPtrInList BOOLEAN, - optTestRoutineName MyString, - defaultFieldName MyString -- base for generating field names -} - - - -CxxTRI ::= SEQUENCE -{ - isEnc BOOLEAN, - className MyString, - fieldName MyString, - isPtr BOOLEAN, - namedElmts CNamedElmts, - choiceIdSymbol MyString, - choiceIdValue INTEGER, - optTestRoutineName MyString -} - -IDLTDI ::= SEQUENCE -{ - asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId" - typeName MyString, - isPdu BOOLEAN, - isEnc BOOLEAN, - isPtrForTypeDef BOOLEAN, - isPtrForOpt BOOLEAN, - isPtrInChoice BOOLEAN, - isPtrInSetAndSeq BOOLEAN, - isPtrInList BOOLEAN, - optTestRoutineName MyString, - defaultFieldName MyString -- base for generating field names -} - -IDLTRI ::= SEQUENCE -{ - isEnc BOOLEAN, - typeName MyString, - fieldName MyString, - isPtr BOOLEAN, - namedElmts CNamedElmts, - choiceIdSymbol MyString, - choiceIdValue INTEGER, - optTestRoutineName MyString -} - --- use snacc compiler directives to overide the builtin types. --- --- All strings used in module data struct are null terminated so --- can just use a char* --- Note the snacc comments before the PrintableString --- bind with the MyString TypeDef and the ones after PrintableString --- bind with the PrintableString Type ref. - - -MyString ::= --snacc isPtrForTypeDef:"FALSE" - --snacc isPtrForTypeRef:"FALSE" - --snacc isPtrInChoice:"FALSE" - --snacc isPtrForOpt:"FALSE" - --snacc optTestRoutineName:"MYSTRING_NON_NULL" - --snacc genPrintRoutine:"FALSE" - --snacc genEncodeRoutine:"FALSE" - --snacc genDecodeRoutine:"FALSE" - --snacc genFreeRoutine:"FALSE" - --snacc printRoutineName:"printMyString" - --snacc encodeRoutineName:"EncMyString" - --snacc decodeRoutineName:"DecMyString" - --snacc freeRoutineName:"FreeMyString" - PrintableString --snacc cTypeName:"char*" - -END diff --git a/SecuritySNACCRuntime/asn1specs/err-test.asn1 b/SecuritySNACCRuntime/asn1specs/err-test.asn1 deleted file mode 100644 index c91abd43..00000000 --- a/SecuritySNACCRuntime/asn1specs/err-test.asn1 +++ /dev/null @@ -1,237 +0,0 @@ --- .../asn1specs/err_test.asn1 --- --- This module exercises snacc's semantic error checking of ASN.1 types. --- Every line that has the "error" comment should cause snacc to produce --- at least one error message --- --- Mike Sample 92/07 --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/err-test.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: err-test.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:55 aram --- Originals from SMIME Free Library. --- --- Revision 1.3 1995/07/25 19:53:16 rj --- changed `_' to `-' in file names. --- --- Revision 1.2 1994/08/28 09:54:17 rj --- comment leader fixed. --- --- Revision 1.1 1994/08/28 09:51:13 rj --- first check-in. - -ERROR-TEST DEFINITIONS ::= -BEGIN - - --- first check that CHOICEs and SETs without distinct tags --- cause error msgs - -AChoice ::= CHOICE -- error -{ - f1 [0] INTEGER, -- these two have the same - f2 [0] INTEGER, -- tags - f3 INTEGER, -- the tag of f3 - f4 AChoice3 -- conflicts with one of AChoice3's elmt tags -} - -ASet ::= SET -- error -{ - f1 [0] INTEGER, -- same [0] tags - f2 [0] INTEGER -} - - -T1 ::= INTEGER -T2 ::= BOOLEAN - -AChoice2 ::= CHOICE -- error -{ - T1, - INTEGER -} - -ASet2 ::= SET -- error -{ - T2, - BOOLEAN -} - -AChoice3 ::= CHOICE -{ - T1, - T2 -} - - --- --- now check that Sequence have distinct tags --- on one or consective optional elmts and following (if any) --- non-optional elmt --- - -ASequence ::= SEQUENCE -- no errors -{ - f1 [0] INTEGER, - f2 [0] BOOLEAN -} - -ASequence1 ::= SEQUENCE -{ - INTEGER OPTIONAL, - INTEGER OPTIONAL, -- error, ambiguous values possible - INTEGER, -- error - INTEGER -} - -ASequence3 ::= SEQUENCE -{ - f1 [0] OBJECT IDENTIFIER OPTIONAL, - f2 [1] INTEGER OPTIONAL, - f3 [0] BOOLEAN, -- error - f4 [2] OCTET STRING OPTIONAL, - f5 [2] BIT STRING OPTIONAL, -- error - f6 [3] ASequence OPTIONAL, - f7 [3] INTEGER, -- error - f8 [4] BOOLEAN OPTIONAL, - f9 [4] INTEGER OPTIONAL -- error -} - - - --- --- now check that duplicate APPLICATION tag errors are reported --- -Foo1 ::= [APPLICATION 0] INTEGER -Foo2 ::= [APPLICATION 1] INTEGER - -Bar1 ::= [APPLICATION 0] IMPLICIT INTEGER -- error -Bar2 ::= [APPLICATION 1] IMPLICIT INTEGER -- error - --- --- check that field name errors are reported --- - -AChoice4 ::= CHOICE -{ - f1 INTEGER, - f2 BOOLEAN, - [0] AChoice4 -} - -ASet3 ::= SET -{ - f1 [0] INTEGER, - f2 [1] INTEGER, - f3 [2] BOOLEAN, - f3 [3] BOOLEAN, -- error, field name conflict - [4] AChoice4 -- error, field name conflict too -} - - --- --- now check some recursive type related errors --- - -A2 ::= A2 -- error - -A1 ::= B1 -- error -B1 ::= A1 -- error - -C1 ::= D1 -- error -D1 ::= E1 -- error -E1 ::= F1 -- error -F1 ::= C1 -- error - -RecSeq ::= SEQUENCE -{ - INTEGER, - BOOLEAN, - RecSeq, -- warning, infinitely large values? - RecSeq OPTIONAL -- this should be ok 'cause it's optional -} - - --- --- now check some named bit and named number related errors --- -aVal INTEGER ::= -4 - -Enum1 ::= ENUMERATED { zero(0), one(1), two(2), one(0) } -- 2 errors - -Int1 ::= INTEGER { zero(0), one(1), two(2), yoyo(2), one(7), foo(aVal) } -- 2 errors - -Bits1 ::= BIT STRING { zero(0), one(1), two(2), one(4), foo(-2), pogo(0), - gogo(aVal) } -- 4 errors - - - --- --- now check that implicitly tagged CHOICE, ANY and ANY DEFINED BY --- cause error msgs --- -BChoice1 ::= [APPLICATION 5] IMPLICIT CHOICE -- error -{ - INTEGER, - BOOLEAN -} - -BChoice2 ::= CHOICE -- no error -{ - INTEGER, - BOOLEAN -} - -BChoice3 ::= [APPLICATION 6] CHOICE -- no error -{ - INTEGER, - BOOLEAN -} - -BSeq ::= SEQUENCE -{ - INTEGER, - BOOLEAN, - [0] IMPLICIT BChoice2, -- error - [1] IMPLICIT BChoice3, -- no error - [2] IMPLICIT CHOICE {INTEGER, BOOLEAN} -- error -} - - --- --- now test that errors are reported for multiply defined --- types and valus --- - -TypeCopy1 ::= INTEGER -TypeCopy1 ::= BOOLEAN -TypeCopy1 ::= INTEGER - -valCopy1 INTEGER ::= 1 -valCopy1 BOOLEAN ::= TRUE -valCopy1 INTEGER ::= 1 - - --- --- test some OBJECT IDENTIFER value errors --- - -oid1 OBJECT IDENTIFIER ::= { oid1 ms(1) 1 } -- error: recursive value -oid2 OBJECT IDENTIFIER ::= { oid1 ms(1) 2 } - - -- error: can only ref other oid values from first arc -oid3 OBJECT IDENTIFIER ::= { ms(1) oid2 2 } - -boolVal BOOLEAN ::= TRUE -intVal1 INTEGER ::= 1 -intVal2 INTEGER ::= -1 -oid4 OBJECT IDENTIFIER ::= { oid2 intVal1 intVal2 boolVal 1} - -oid5 OBJECT IDENTIFIER ::= { 1 2 -4} - -oid6 OBJECT IDENTIFIER ::= { oid7 1} -oid7 OBJECT IDENTIFIER ::= { oid6 1 } -END diff --git a/SecuritySNACCRuntime/asn1specs/ex1.asn1 b/SecuritySNACCRuntime/asn1specs/ex1.asn1 deleted file mode 100644 index 3a020188..00000000 --- a/SecuritySNACCRuntime/asn1specs/ex1.asn1 +++ /dev/null @@ -1,40 +0,0 @@ --- file: .../asn1specs/ex1.asn1 --- --- This is an example ASN.1 module used in the documentation --- --- MS 92 --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/ex1.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: ex1.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:55 aram --- Originals from SMIME Free Library. --- --- Revision 1.2 1997/02/16 20:25:22 rj --- check-in of a few cosmetic changes --- --- Revision 1.1 1994/10/08 05:41:32 rj --- initial check-in. --- - -EX1 DEFINITIONS ::= -BEGIN - -anOidVal OBJECT IDENTIFIER ::= { joint-iso-ccitt 40 foobar(29) } -theSameOidVal OBJECT IDENTIFIER ::= { 2 40 29 } -anIntVal INTEGER ::= 1 -aBoolVal BOOLEAN ::= TRUE - -T1 ::= SEQUENCE -{ - INTEGER OPTIONAL, - OCTET STRING OPTIONAL, - ENUMERATED { a(0), b(1), c(2) }, - SEQUENCE OF INTEGER, - SEQUENCE { id OBJECT IDENTIFIER, value OCTET STRING }, - CHOICE { INTEGER, OBJECT IDENTIFIER } -} - -END diff --git a/SecuritySNACCRuntime/asn1specs/install-sh b/SecuritySNACCRuntime/asn1specs/install-sh deleted file mode 100644 index ab74c882..00000000 --- a/SecuritySNACCRuntime/asn1specs/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -tranformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/SecuritySNACCRuntime/asn1specs/makefile b/SecuritySNACCRuntime/asn1specs/makefile deleted file mode 100644 index 3e8b37ac..00000000 --- a/SecuritySNACCRuntime/asn1specs/makefile +++ /dev/null @@ -1,47 +0,0 @@ -# .../asn1specs/makefile - -include ../makehead - -TOP = .. - -ASN1FILES = \ - rfc1155-smi.asn1 \ - rfc1157-snmp.asn1 \ - rfc1213-mib2.asn1 \ - any.asn1 \ - asn1module.asn1 \ - err-test.asn1 \ - ex1.asn1 \ - p-rec.asn1 \ - tbl.asn1 \ - asn-useful.asn1 - -DISTFILES = \ - makefile \ - $(ASN1FILES) - -#------------------------------------------------------------------------------- - -.PHONY: depend install distfiles clean clobber - -install-sh: - ln $(TOP)/install-sh $@ - -$(incdir)/snacc/asn1: - $(TOP)/mkinstalldirs $@ - -install:: $(ASN1FILES) install-sh $(incdir)/snacc/asn1 - -install:: - for a in $(ASN1FILES); do $(INSTALL_DATA) $$a $(incdir)/snacc/asn1/; done - -gen-distfiles:: $(DISTFILES) - -distfiles:: - @echo $(DISTFILES) - -# dummies: -depend clean:: - -clobber:: - $(RM) install-sh diff --git a/SecuritySNACCRuntime/asn1specs/p-rec.asn1 b/SecuritySNACCRuntime/asn1specs/p-rec.asn1 deleted file mode 100644 index 28448f96..00000000 --- a/SecuritySNACCRuntime/asn1specs/p-rec.asn1 +++ /dev/null @@ -1,56 +0,0 @@ --- file: .../asn1specs/p_rec.asn1 --- --- this file is used in ../c{,++}-examples/simple/ --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/p-rec.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: p-rec.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:56 aram --- Originals from SMIME Free Library. --- --- Revision 1.3 1997/09/16 14:55:30 wan --- Added test for "tag dividable by 128" case. --- --- Revision 1.2 1995/07/25 19:53:17 rj --- changed `_' to `-' in file names. --- --- Revision 1.1 1994/08/31 23:05:47 rj --- first check-in. --- - -P-REC DEFINITIONS ::= -BEGIN - - -PersonnelRecord ::= --snacc isPdu:"TRUE" -- [APPLICATION 0] IMPLICIT SET -{ - Name, - title [0] IA5String, - EmployeeNumber, - dateOfHire [1] Date, - nameOfSpouse [2] Name, - children [3] IMPLICIT SEQUENCE OF ChildInformation DEFAULT {} -} - -ChildInformation ::= SET -{ - Name, - dateOfBirth [0] Date -} - -Name ::= [APPLICATION 1] IMPLICIT SEQUENCE -{ - givenName IA5String, - initial IA5String, - familyName IA5String -} - -EmployeeNumber ::= [APPLICATION 128] IMPLICIT INTEGER - -Date ::= [APPLICATION 3] IMPLICIT IA5String -- YYYYMMDD - - - -END diff --git a/SecuritySNACCRuntime/asn1specs/rfc1155-smi.asn1 b/SecuritySNACCRuntime/asn1specs/rfc1155-smi.asn1 deleted file mode 100644 index b6be0406..00000000 --- a/SecuritySNACCRuntime/asn1specs/rfc1155-smi.asn1 +++ /dev/null @@ -1,155 +0,0 @@ --- file: asn1specs/1155_smi.asn1 --- --- this file is used in ../c{,++}-examples/snmp/ --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/rfc1155-smi.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: rfc1155-smi.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:56 aram --- Originals from SMIME Free Library. --- --- Revision 1.3 1995/07/27 08:29:16 rj --- rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to accomodate to snacc's new file name generation scheme. --- --- Revision 1.2 1995/07/25 19:53:12 rj --- changed `_' to `-' in file names. --- --- Revision 1.1 1994/08/31 23:08:26 rj --- first check-in. --- - -RFC1155-SMI DEFINITIONS ::= BEGIN - - EXPORTS -- EVERYTHING - internet, directory, mgmt, - experimental, private, enterprises, - OBJECT-TYPE, ObjectName, ObjectSyntax, SimpleSyntax, - ApplicationSyntax, NetworkAddress, IpAddress, - Counter, Gauge, TimeTicks, Opaque; - - -- the path to the root - - internet OBJECT IDENTIFIER ::= { iso org(3) dod(6) 1 } - - directory OBJECT IDENTIFIER ::= { internet 1 } - - mgmt OBJECT IDENTIFIER ::= { internet 2 } - - experimental OBJECT IDENTIFIER ::= { internet 3 } - - private OBJECT IDENTIFIER ::= { internet 4 } - enterprises OBJECT IDENTIFIER ::= { private 1 } - - - -- definition of object types - - OBJECT-TYPE MACRO ::= - BEGIN - TYPE NOTATION ::= "SYNTAX" type (TYPE ObjectSyntax) - "ACCESS" Access - "STATUS" Status - VALUE NOTATION ::= value (VALUE ObjectName) - - Access ::= "read-only" - | "read-write" - | "write-only" - | "not-accessible" - Status ::= "mandatory" - | "optional" - | "obsolete" - END - - -- names of objects in the MIB - - ObjectName ::= - OBJECT IDENTIFIER - - - - - - -- syntax of objects in the MIB - - ObjectSyntax ::= - CHOICE { - simple - SimpleSyntax, - - -- note that simple SEQUENCEs are not directly - -- mentioned here to keep things simple (i.e., - -- prevent mis-use). However, application-wide - -- types which are IMPLICITly encoded simple - -- SEQUENCEs may appear in the following CHOICE - - application-wide - ApplicationSyntax - } - - SimpleSyntax ::= - CHOICE { - number - INTEGER, - - string - OCTET STRING, - - object - OBJECT IDENTIFIER, - - empty - NULL - } - - ApplicationSyntax ::= - CHOICE { - address - NetworkAddress, - - counter - Counter, - - gauge - Gauge, - - ticks - TimeTicks, - - arbitrary - Opaque - - -- other application-wide types, as they are - -- defined, will be added here - } - - - -- application-wide types - - NetworkAddress ::= - CHOICE { - internet - IpAddress - } - - IpAddress ::= - [APPLICATION 0] -- in network-byte order - IMPLICIT OCTET STRING (SIZE (4)) - - Counter ::= - [APPLICATION 1] - IMPLICIT INTEGER (0..4294967295) - - Gauge ::= - [APPLICATION 2] - IMPLICIT INTEGER (0..4294967295) - - TimeTicks ::= - [APPLICATION 3] - IMPLICIT INTEGER (0..4294967295) - - Opaque ::= - [APPLICATION 4] -- arbitrary ASN.1 value, - IMPLICIT OCTET STRING -- "double-wrapped" - - END diff --git a/SecuritySNACCRuntime/asn1specs/rfc1157-snmp.asn1 b/SecuritySNACCRuntime/asn1specs/rfc1157-snmp.asn1 deleted file mode 100644 index eeab22df..00000000 --- a/SecuritySNACCRuntime/asn1specs/rfc1157-snmp.asn1 +++ /dev/null @@ -1,166 +0,0 @@ --- file: asn1specs/1157_snmp.asn1 --- --- this file is used in ../c{,++}-examples/snmp/ --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/rfc1157-snmp.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: rfc1157-snmp.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:56 aram --- Originals from SMIME Free Library. --- --- Revision 1.3 1995/07/27 08:29:17 rj --- rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to accomodate to snacc's new file name generation scheme. --- --- Revision 1.2 1995/07/25 19:53:13 rj --- changed `_' to `-' in file names. --- --- Revision 1.1 1994/08/31 23:08:27 rj --- first check-in. --- - -RFC1157-SNMP DEFINITIONS ::= BEGIN - - IMPORTS - ObjectName, ObjectSyntax, NetworkAddress, IpAddress, TimeTicks - FROM RFC1155-SMI; - - - -- top-level message - - Message ::= - SEQUENCE { - version -- version-1 for this RFC - INTEGER { - version-1(0) - }, - - community -- community name - OCTET STRING, - - data -- e.g., PDUs if trivial - PDUs -- authentication is being used - } - - - -- protocol data units - - PDUs ::= - CHOICE { - get-request - GetRequest-PDU, - - get-next-request - GetNextRequest-PDU, - - get-response - GetResponse-PDU, - - set-request - SetRequest-PDU, - - trap - Trap-PDU - } - - - - - - -- PDUs - - GetRequest-PDU ::= - [0] - IMPLICIT PDU - - GetNextRequest-PDU ::= - [1] - IMPLICIT PDU - - GetResponse-PDU ::= - [2] - IMPLICIT PDU - - SetRequest-PDU ::= - [3] - IMPLICIT PDU - - PDU ::= - SEQUENCE { - request-id - INTEGER, - - error-status -- sometimes ignored - INTEGER { - noError(0), - tooBig(1), - noSuchName(2), - badValue(3), - readOnly(4), - genErr(5) - }, - - error-index -- sometimes ignored - INTEGER, - - variable-bindings -- values are sometimes ignored - VarBindList - } - - Trap-PDU ::= - [4] - IMPLICIT SEQUENCE { - enterprise -- type of object generating - -- trap, see sysObjectID in [5] - - - OBJECT IDENTIFIER, - - - - agent-addr -- address of object generating - NetworkAddress, -- trap - - generic-trap -- generic trap type - INTEGER { - coldStart(0), - warmStart(1), - linkDown(2), - linkUp(3), - authenticationFailure(4), - egpNeighborLoss(5), - enterpriseSpecific(6) - }, - - specific-trap -- specific code, present even - INTEGER, -- if generic-trap is not - -- enterpriseSpecific - - time-stamp -- time elapsed between the last - TimeTicks, -- (re)initialization of the - -- network - -- entity and the generation of the - -- trap - - variable-bindings -- "interesting" information - VarBindList - } - - - -- variable bindings - - VarBind ::= - SEQUENCE { - name - ObjectName, - - value - ObjectSyntax - } - - VarBindList ::= - SEQUENCE OF - VarBind - -END diff --git a/SecuritySNACCRuntime/asn1specs/rfc1213-mib2.asn1 b/SecuritySNACCRuntime/asn1specs/rfc1213-mib2.asn1 deleted file mode 100644 index 33133544..00000000 --- a/SecuritySNACCRuntime/asn1specs/rfc1213-mib2.asn1 +++ /dev/null @@ -1,2663 +0,0 @@ --- file: asn1specs/1213_mib2.asn1 --- --- this file is used in ../c{,++}-examples/snmp/ --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/rfc1213-mib2.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: rfc1213-mib2.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:56 aram --- Originals from SMIME Free Library. --- --- Revision 1.3 1995/07/27 08:29:19 rj --- rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to accomodate to snacc's new file name generation scheme. --- --- Revision 1.2 1995/07/25 19:53:14 rj --- changed `_' to `-' in file names. --- --- Revision 1.1 1994/08/31 23:08:28 rj --- first check-in. --- - -RFC1213-MIB DEFINITIONS ::= BEGIN - - IMPORTS - mgmt, NetworkAddress, IpAddress, Counter, Gauge, - TimeTicks - FROM RFC1155-SMI - --- OBJECT-TYPE --- FROM RFC-1212 - - ; - - -- This MIB module uses the extended OBJECT-TYPE macro as - -- defined in [14]; - - - -- MIB-II (same prefix as MIB-I) - - mib-2 OBJECT IDENTIFIER ::= { mgmt 1 } - - -- textual conventions - - DisplayString ::= - OCTET STRING - -- This data type is used to model textual information taken - -- from the NVT ASCII character set. By convention, objects - -- with this syntax are declared as having - -- SIZE (0..255) - - PhysAddress ::= - OCTET STRING - -- This data type is used to model media addresses. For many - -- types of media, this will be in a binary representation. - -- For example, an ethernet address would be represented as - -- a string of 6 octets. - - - -- groups in MIB-II - - system OBJECT IDENTIFIER ::= { mib-2 1 } - - interfaces OBJECT IDENTIFIER ::= { mib-2 2 } - - at OBJECT IDENTIFIER ::= { mib-2 3 } - - ip OBJECT IDENTIFIER ::= { mib-2 4 } - - icmp OBJECT IDENTIFIER ::= { mib-2 5 } - - tcp OBJECT IDENTIFIER ::= { mib-2 6 } - - udp OBJECT IDENTIFIER ::= { mib-2 7 } - - egp OBJECT IDENTIFIER ::= { mib-2 8 } - - -- historical (some say hysterical) - -- cmot OBJECT IDENTIFIER ::= { mib-2 9 } - - transmission OBJECT IDENTIFIER ::= { mib-2 10 } - - snmp OBJECT IDENTIFIER ::= { mib-2 11 } - - - -- the System group - - -- Implementation of the System group is mandatory for all - -- systems. If an agent is not configured to have a value - -- for any of these variables, a string of length 0 is - -- returned. - - sysDescr OBJECT-TYPE - SYNTAX DisplayString (SIZE (0..255)) - ACCESS read-only - STATUS mandatory - DESCRIPTION - "A textual description of the entity. This value - should include the full name and version - identification of the system's hardware type, - software operating-system, and networking - software. It is mandatory that this only contain - printable ASCII characters." - ::= { system 1 } - - sysObjectID OBJECT-TYPE - SYNTAX OBJECT IDENTIFIER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The vendor's authoritative identification of the - network management subsystem contained in the - entity. This value is allocated within the SMI - enterprises subtree (1.3.6.1.4.1) and provides an - easy and unambiguous means for determining `what - kind of box' is being managed. For example, if - vendor `Flintstones, Inc.' was assigned the - subtree 1.3.6.1.4.1.4242, it could assign the - identifier 1.3.6.1.4.1.4242.1.1 to its `Fred - Router'." - ::= { system 2 } - - sysUpTime OBJECT-TYPE - SYNTAX TimeTicks - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The time (in hundredths of a second) since the - network management portion of the system was last - re-initialized." - ::= { system 3 } - - sysContact OBJECT-TYPE - SYNTAX DisplayString (SIZE (0..255)) - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The textual identification of the contact person - for this managed node, together with information - on how to contact this person." - ::= { system 4 } - - sysName OBJECT-TYPE - SYNTAX DisplayString (SIZE (0..255)) - ACCESS read-write - STATUS mandatory - DESCRIPTION - "An administratively-assigned name for this - managed node. By convention, this is the node's - fully-qualified domain name." - ::= { system 5 } - - sysLocation OBJECT-TYPE - SYNTAX DisplayString (SIZE (0..255)) - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The physical location of this node (e.g., - `telephone closet, 3rd floor')." - ::= { system 6 } - - sysServices OBJECT-TYPE - SYNTAX INTEGER (0..127) - ACCESS read-only - STATUS mandatory - DESCRIPTION - "A value which indicates the set of services that - this entity primarily offers. - - The value is a sum. This sum initially takes the - value zero, Then, for each layer, L, in the range - 1 through 7, that this node performs transactions - for, 2 raised to (L - 1) is added to the sum. For - example, a node which performs primarily routing - functions would have a value of 4 (2^(3-1)). In - contrast, a node which is a host offering - application services would have a value of 72 - (2^(4-1) + 2^(7-1)). Note that in the context of - the Internet suite of protocols, values should be - calculated accordingly: - - layer functionality - 1 physical (e.g., repeaters) - 2 datalink/subnetwork (e.g., bridges) - 3 internet (e.g., IP gateways) - 4 end-to-end (e.g., IP hosts) - 7 applications (e.g., mail relays) - - For systems including OSI protocols, layers 5 and - 6 may also be counted." - ::= { system 7 } - - - - -- the Interfaces group - - -- Implementation of the Interfaces group is mandatory for - -- all systems. - - ifNumber OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of network interfaces (regardless of - their current state) present on this system." - ::= { interfaces 1 } - - - -- the Interfaces table - - -- The Interfaces table contains information on the entity's - -- interfaces. Each interface is thought of as being - -- attached to a `subnetwork'. Note that this term should - -- not be confused with `subnet' which refers to an - -- addressing partitioning scheme used in the Internet suite - -- of protocols. - - ifTable OBJECT-TYPE - SYNTAX SEQUENCE OF IfEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "A list of interface entries. The number of - entries is given by the value of ifNumber." - ::= { interfaces 2 } - - ifEntry OBJECT-TYPE - SYNTAX IfEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "An interface entry containing objects at the - subnetwork layer and below for a particular - interface." - INDEX { ifIndex } - ::= { ifTable 1 } - - IfEntry ::= - SEQUENCE { - ifIndex - INTEGER, - ifDescr - DisplayString, - ifType - INTEGER, - ifMtu - INTEGER, - ifSpeed - Gauge, - ifPhysAddress - PhysAddress, - ifAdminStatus - INTEGER, - ifOperStatus - INTEGER, - ifLastChange - TimeTicks, - ifInOctets - Counter, - ifInUcastPkts - Counter, - ifInNUcastPkts - Counter, - ifInDiscards - Counter, - ifInErrors - Counter, - ifInUnknownProtos - Counter, - ifOutOctets - Counter, - ifOutUcastPkts - Counter, - ifOutNUcastPkts - Counter, - ifOutDiscards - Counter, - ifOutErrors - Counter, - ifOutQLen - Gauge, - ifSpecific - OBJECT IDENTIFIER - } - - ifIndex OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "A unique value for each interface. Its value - ranges between 1 and the value of ifNumber. The - value for each interface must remain constant at - least from one re-initialization of the entity's - network management system to the next re- - initialization." - ::= { ifEntry 1 } - - ifDescr OBJECT-TYPE - SYNTAX DisplayString (SIZE (0..255)) - ACCESS read-only - STATUS mandatory - DESCRIPTION - "A textual string containing information about the - interface. This string should include the name of - the manufacturer, the product name and the version - of the hardware interface." - ::= { ifEntry 2 } - - ifType OBJECT-TYPE - SYNTAX INTEGER { - other(1), -- none of the following - regular1822(2), - hdh1822(3), - ddn-x25(4), - rfc877-x25(5), - ethernet-csmacd(6), - iso88023-csmacd(7), - iso88024-tokenBus(8), - iso88025-tokenRing(9), - iso88026-man(10), - starLan(11), - proteon-10Mbit(12), - proteon-80Mbit(13), - hyperchannel(14), - fddi(15), - lapb(16), - sdlc(17), - ds1(18), -- T-1 - e1(19), -- european equiv. of T-1 - basicISDN(20), - primaryISDN(21), -- proprietary serial - propPointToPointSerial(22), - ppp(23), - softwareLoopback(24), - eon(25), -- CLNP over IP [11] - ethernet-3Mbit(26), - nsip(27), -- XNS over IP - slip(28), -- generic SLIP - ultra(29), -- ULTRA technologies - ds3(30), -- T-3 - sip(31), -- SMDS - frame-relay(32) - } - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The type of interface, distinguished according to - the physical/link protocol(s) immediately `below' - the network layer in the protocol stack." - ::= { ifEntry 3 } - - ifMtu OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The size of the largest datagram which can be - sent/received on the interface, specified in - octets. For interfaces that are used for - transmitting network datagrams, this is the size - of the largest network datagram that can be sent - on the interface." - ::= { ifEntry 4 } - - ifSpeed OBJECT-TYPE - SYNTAX Gauge - ACCESS read-only - STATUS mandatory - DESCRIPTION - "An estimate of the interface's current bandwidth - in bits per second. For interfaces which do not - vary in bandwidth or for those where no accurate - estimation can be made, this object should contain - the nominal bandwidth." - ::= { ifEntry 5 } - - ifPhysAddress OBJECT-TYPE - SYNTAX PhysAddress - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The interface's address at the protocol layer - immediately `below' the network layer in the - protocol stack. For interfaces which do not have - such an address (e.g., a serial line), this object - should contain an octet string of zero length." - ::= { ifEntry 6 } - - ifAdminStatus OBJECT-TYPE - SYNTAX INTEGER { - up(1), -- ready to pass packets - down(2), - testing(3) -- in some test mode - } - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The desired state of the interface. The - testing(3) state indicates that no operational - packets can be passed." - ::= { ifEntry 7 } - - ifOperStatus OBJECT-TYPE - SYNTAX INTEGER { - up(1), -- ready to pass packets - down(2), - testing(3) -- in some test mode - } - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The current operational state of the interface. - The testing(3) state indicates that no operational - packets can be passed." - ::= { ifEntry 8 } - - ifLastChange OBJECT-TYPE - SYNTAX TimeTicks - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The value of sysUpTime at the time the interface - entered its current operational state. If the - current state was entered prior to the last re- - initialization of the local network management - subsystem, then this object contains a zero - value." - ::= { ifEntry 9 } - - ifInOctets OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of octets received on the - interface, including framing characters." - ::= { ifEntry 10 } - - ifInUcastPkts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of subnetwork-unicast packets - delivered to a higher-layer protocol." - ::= { ifEntry 11 } - - ifInNUcastPkts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of non-unicast (i.e., subnetwork- - broadcast or subnetwork-multicast) packets - delivered to a higher-layer protocol." - ::= { ifEntry 12 } - - ifInDiscards OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of inbound packets which were chosen - to be discarded even though no errors had been - detected to prevent their being deliverable to a - higher-layer protocol. One possible reason for - discarding such a packet could be to free up - buffer space." - ::= { ifEntry 13 } - - ifInErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of inbound packets that contained - errors preventing them from being deliverable to a - higher-layer protocol." - ::= { ifEntry 14 } - - - ifInUnknownProtos OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of packets received via the interface - which were discarded because of an unknown or - unsupported protocol." - ::= { ifEntry 15 } - - ifOutOctets OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of octets transmitted out of the - interface, including framing characters." - ::= { ifEntry 16 } - - ifOutUcastPkts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of packets that higher-level - protocols requested be transmitted to a - subnetwork-unicast address, including those that - were discarded or not sent." - ::= { ifEntry 17 } - - ifOutNUcastPkts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of packets that higher-level - protocols requested be transmitted to a non- - unicast (i.e., a subnetwork-broadcast or - subnetwork-multicast) address, including those - that were discarded or not sent." - ::= { ifEntry 18 } - - ifOutDiscards OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of outbound packets which were chosen - to be discarded even though no errors had been - detected to prevent their being transmitted. One - possible reason for discarding such a packet could - be to free up buffer space." - ::= { ifEntry 19 } - - ifOutErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of outbound packets that could not be - transmitted because of errors." - ::= { ifEntry 20 } - - ifOutQLen OBJECT-TYPE - SYNTAX Gauge - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The length of the output packet queue (in - packets)." - ::= { ifEntry 21 } - - ifSpecific OBJECT-TYPE - SYNTAX OBJECT IDENTIFIER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "A reference to MIB definitions specific to the - particular media being used to realize the - interface. For example, if the interface is - realized by an ethernet, then the value of this - object refers to a document defining objects - specific to ethernet. If this information is not - present, its value should be set to the OBJECT - IDENTIFIER { 0 0 }, which is a syntatically valid - object identifier, and any conformant - implementation of ASN.1 and BER must be able to - generate and recognize this value." - ::= { ifEntry 22 } - - - -- the Address Translation group - - -- Implementation of the Address Translation group is - -- mandatory for all systems. Note however that this group - -- is deprecated by MIB-II. That is, it is being included - -- solely for compatibility with MIB-I nodes, and will most - -- likely be excluded from MIB-III nodes. From MIB-II and - -- onwards, each network protocol group contains its own - -- address translation tables. - - -- The Address Translation group contains one table which is - -- the union across all interfaces of the translation tables - -- for converting a NetworkAddress (e.g., an IP address) into - -- a subnetwork-specific address. For lack of a better term, - -- this document refers to such a subnetwork-specific address - -- as a `physical' address. - - -- Examples of such translation tables are: for broadcast - -- media where ARP is in use, the translation table is - -- equivalent to the ARP cache; or, on an X.25 network where - -- non-algorithmic translation to X.121 addresses is - -- required, the translation table contains the - -- NetworkAddress to X.121 address equivalences. - - atTable OBJECT-TYPE - SYNTAX SEQUENCE OF AtEntry - ACCESS not-accessible - STATUS deprecated - DESCRIPTION - "The Address Translation tables contain the - NetworkAddress to `physical' address equivalences. - Some interfaces do not use translation tables for - determining address equivalences (e.g., DDN-X.25 - has an algorithmic method); if all interfaces are - of this type, then the Address Translation table - is empty, i.e., has zero entries." - ::= { at 1 } - - atEntry OBJECT-TYPE - SYNTAX AtEntry - ACCESS not-accessible - STATUS deprecated - DESCRIPTION - "Each entry contains one NetworkAddress to - `physical' address equivalence." - INDEX { atIfIndex, - atNetAddress } - ::= { atTable 1 } - - AtEntry ::= - SEQUENCE { - atIfIndex - INTEGER, - atPhysAddress - PhysAddress, - atNetAddress - NetworkAddress - } - - atIfIndex OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS deprecated - DESCRIPTION - "The interface on which this entry's equivalence - is effective. The interface identified by a - particular value of this index is the same - interface as identified by the same value of - ifIndex." - ::= { atEntry 1 } - - atPhysAddress OBJECT-TYPE - SYNTAX PhysAddress - ACCESS read-write - STATUS deprecated - DESCRIPTION - "The media-dependent `physical' address. - - Setting this object to a null string (one of zero - length) has the effect of invaliding the - corresponding entry in the atTable object. That - is, it effectively dissasociates the interface - identified with said entry from the mapping - identified with said entry. It is an - implementation-specific matter as to whether the - agent removes an invalidated entry from the table. - Accordingly, management stations must be prepared - to receive tabular information from agents that - corresponds to entries not currently in use. - Proper interpretation of such entries requires - examination of the relevant atPhysAddress object." - ::= { atEntry 2 } - - atNetAddress OBJECT-TYPE - SYNTAX NetworkAddress - ACCESS read-write - STATUS deprecated - DESCRIPTION - "The NetworkAddress (e.g., the IP address) - corresponding to the media-dependent `physical' - address." - ::= { atEntry 3 } - - - -- the IP group - - -- Implementation of the IP group is mandatory for all - -- systems. - - ipForwarding OBJECT-TYPE - SYNTAX INTEGER { - forwarding(1), -- acting as a gateway - not-forwarding(2) -- NOT acting as a gateway - } - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The indication of whether this entity is acting - as an IP gateway in respect to the forwarding of - datagrams received by, but not addressed to, this - entity. IP gateways forward datagrams. IP hosts - do not (except those source-routed via the host). - - Note that for some managed nodes, this object may - take on only a subset of the values possible. - Accordingly, it is appropriate for an agent to - return a `badValue' response if a management - station attempts to change this object to an - inappropriate value." - ::= { ip 1 } - - ipDefaultTTL OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The default value inserted into the Time-To-Live - field of the IP header of datagrams originated at - this entity, whenever a TTL value is not supplied - by the transport layer protocol." - ::= { ip 2 } - - ipInReceives OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of input datagrams received from - interfaces, including those received in error." - ::= { ip 3 } - - ipInHdrErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of input datagrams discarded due to - errors in their IP headers, including bad - checksums, version number mismatch, other format - errors, time-to-live exceeded, errors discovered - in processing their IP options, etc." - ::= { ip 4 } - - ipInAddrErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of input datagrams discarded because - the IP address in their IP header's destination - field was not a valid address to be received at - this entity. This count includes invalid - addresses (e.g., 0.0.0.0) and addresses of - unsupported Classes (e.g., Class E). For entities - which are not IP Gateways and therefore do not - forward datagrams, this counter includes datagrams - discarded because the destination address was not - a local address." - ::= { ip 5 } - - ipForwDatagrams OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of input datagrams for which this - entity was not their final IP destination, as a - result of which an attempt was made to find a - route to forward them to that final destination. - In entities which do not act as IP Gateways, this - counter will include only those packets which were - Source-Routed via this entity, and the Source- - Route option processing was successful." - ::= { ip 6 } - - ipInUnknownProtos OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of locally-addressed datagrams - received successfully but discarded because of an - unknown or unsupported protocol." - ::= { ip 7 } - - ipInDiscards OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of input IP datagrams for which no - problems were encountered to prevent their - continued processing, but which were discarded - (e.g., for lack of buffer space). Note that this - counter does not include any datagrams discarded - while awaiting re-assembly." - ::= { ip 8 } - - ipInDelivers OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of input datagrams successfully - delivered to IP user-protocols (including ICMP)." - ::= { ip 9 } - - ipOutRequests OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of IP datagrams which local IP - user-protocols (including ICMP) supplied to IP in - requests for transmission. Note that this counter - does not include any datagrams counted in - ipForwDatagrams." - ::= { ip 10 } - - ipOutDiscards OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of output IP datagrams for which no - problem was encountered to prevent their - transmission to their destination, but which were - discarded (e.g., for lack of buffer space). Note - that this counter would include datagrams counted - in ipForwDatagrams if any such packets met this - (discretionary) discard criterion." - ::= { ip 11 } - - ipOutNoRoutes OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of IP datagrams discarded because no - route could be found to transmit them to their - destination. Note that this counter includes any - packets counted in ipForwDatagrams which meet this - `no-route' criterion. Note that this includes any - datagarms which a host cannot route because all of - its default gateways are down." - ::= { ip 12 } - - ipReasmTimeout OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The maximum number of seconds which received - fragments are held while they are awaiting - reassembly at this entity." - ::= { ip 13 } - - ipReasmReqds OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of IP fragments received which needed - to be reassembled at this entity." - ::= { ip 14 } - - ipReasmOKs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of IP datagrams successfully re- - assembled." - ::= { ip 15 } - - ipReasmFails OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of failures detected by the IP re- - assembly algorithm (for whatever reason: timed - out, errors, etc). Note that this is not - necessarily a count of discarded IP fragments - since some algorithms (notably the algorithm in - RFC 815) can lose track of the number of fragments - by combining them as they are received." - ::= { ip 16 } - - ipFragOKs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of IP datagrams that have been - successfully fragmented at this entity." - ::= { ip 17 } - - ipFragFails OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of IP datagrams that have been - discarded because they needed to be fragmented at - this entity but could not be, e.g., because their - Don't Fragment flag was set." - ::= { ip 18 } - - ipFragCreates OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of IP datagram fragments that have - been generated as a result of fragmentation at - this entity." - ::= { ip 19 } - - - - -- the IP address table - - -- The IP address table contains this entity's IP addressing - -- information. - - ipAddrTable OBJECT-TYPE - SYNTAX SEQUENCE OF IpAddrEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "The table of addressing information relevant to - this entity's IP addresses." - ::= { ip 20 } - - ipAddrEntry OBJECT-TYPE - SYNTAX IpAddrEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "The addressing information for one of this - entity's IP addresses." - INDEX { ipAdEntAddr } - ::= { ipAddrTable 1 } - - IpAddrEntry ::= - SEQUENCE { - ipAdEntAddr - IpAddress, - ipAdEntIfIndex - INTEGER, - ipAdEntNetMask - IpAddress, - ipAdEntBcastAddr - INTEGER, - ipAdEntReasmMaxSize - INTEGER (0..65535) - } - - ipAdEntAddr OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The IP address to which this entry's addressing - information pertains." - ::= { ipAddrEntry 1 } - - - ipAdEntIfIndex OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The index value which uniquely identifies the - interface to which this entry is applicable. The - interface identified by a particular value of this - index is the same interface as identified by the - same value of ifIndex." - ::= { ipAddrEntry 2 } - - ipAdEntNetMask OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The subnet mask associated with the IP address of - this entry. The value of the mask is an IP - address with all the network bits set to 1 and all - the hosts bits set to 0." - ::= { ipAddrEntry 3 } - - ipAdEntBcastAddr OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The value of the least-significant bit in the IP - broadcast address used for sending datagrams on - the (logical) interface associated with the IP - address of this entry. For example, when the - Internet standard all-ones broadcast address is - used, the value will be 1. This value applies to - both the subnet and network broadcasts addresses - used by the entity on this (logical) interface." - ::= { ipAddrEntry 4 } - - ipAdEntReasmMaxSize OBJECT-TYPE - SYNTAX INTEGER (0..65535) - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The size of the largest IP datagram which this - entity can re-assemble from incoming IP fragmented - datagrams received on this interface." - ::= { ipAddrEntry 5 } - - - - -- the IP routing table - - -- The IP routing table contains an entry for each route - -- presently known to this entity. - - ipRouteTable OBJECT-TYPE - SYNTAX SEQUENCE OF IpRouteEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "This entity's IP Routing table." - ::= { ip 21 } - - ipRouteEntry OBJECT-TYPE - SYNTAX IpRouteEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "A route to a particular destination." - INDEX { ipRouteDest } - ::= { ipRouteTable 1 } - - IpRouteEntry ::= - SEQUENCE { - ipRouteDest - IpAddress, - ipRouteIfIndex - INTEGER, - ipRouteMetric1 - INTEGER, - ipRouteMetric2 - INTEGER, - ipRouteMetric3 - INTEGER, - ipRouteMetric4 - INTEGER, - ipRouteNextHop - IpAddress, - ipRouteType - INTEGER, - ipRouteProto - INTEGER, - ipRouteAge - INTEGER, - ipRouteMask - IpAddress, - ipRouteMetric5 - INTEGER, - ipRouteInfo - OBJECT IDENTIFIER - } - - ipRouteDest OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The destination IP address of this route. An - entry with a value of 0.0.0.0 is considered a - default route. Multiple routes to a single - destination can appear in the table, but access to - such multiple entries is dependent on the table- - access mechanisms defined by the network - management protocol in use." - ::= { ipRouteEntry 1 } - - ipRouteIfIndex OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The index value which uniquely identifies the - local interface through which the next hop of this - route should be reached. The interface identified - by a particular value of this index is the same - interface as identified by the same value of - ifIndex." - ::= { ipRouteEntry 2 } - - ipRouteMetric1 OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The primary routing metric for this route. The - semantics of this metric are determined by the - routing-protocol specified in the route's - ipRouteProto value. If this metric is not used, - its value should be set to -1." - ::= { ipRouteEntry 3 } - - ipRouteMetric2 OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "An alternate routing metric for this route. The - semantics of this metric are determined by the - routing-protocol specified in the route's - ipRouteProto value. If this metric is not used, - its value should be set to -1." - ::= { ipRouteEntry 4 } - - ipRouteMetric3 OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "An alternate routing metric for this route. The - semantics of this metric are determined by the - routing-protocol specified in the route's - ipRouteProto value. If this metric is not used, - its value should be set to -1." - ::= { ipRouteEntry 5 } - - ipRouteMetric4 OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "An alternate routing metric for this route. The - semantics of this metric are determined by the - routing-protocol specified in the route's - ipRouteProto value. If this metric is not used, - its value should be set to -1." - ::= { ipRouteEntry 6 } - - ipRouteNextHop OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The IP address of the next hop of this route. - (In the case of a route bound to an interface - which is realized via a broadcast media, the value - of this field is the agent's IP address on that - interface.)" - ::= { ipRouteEntry 7 } - - ipRouteType OBJECT-TYPE - SYNTAX INTEGER { - other(1), -- none of the following - - invalid(2), -- an invalidated route - -- route to directly - direct(3), -- connected (sub-)network - - -- route to a non-local - indirect(4) -- host/network/sub-network - } - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The type of route. Note that the values - direct(3) and indirect(4) refer to the notion of - direct and indirect routing in the IP - architecture. - - Setting this object to the value invalid(2) has - the effect of invalidating the corresponding entry - in the ipRouteTable object. That is, it - effectively dissasociates the destination - identified with said entry from the route - identified with said entry. It is an - implementation-specific matter as to whether the - agent removes an invalidated entry from the table. - Accordingly, management stations must be prepared - to receive tabular information from agents that - corresponds to entries not currently in use. - Proper interpretation of such entries requires - examination of the relevant ipRouteType object." - ::= { ipRouteEntry 8 } - - ipRouteProto OBJECT-TYPE - SYNTAX INTEGER { - other(1), -- none of the following - - -- non-protocol information, - -- e.g., manually configured - local(2), -- entries - - -- set via a network - netmgmt(3), -- management protocol - - -- obtained via ICMP, - icmp(4), -- e.g., Redirect - - -- the remaining values are - -- all gateway routing - -- protocols - egp(5), - ggp(6), - hello(7), - rip(8), - is-is(9), - es-is(10), - ciscoIgrp(11), - bbnSpfIgp(12), - ospf(13), - bgp(14) - } - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The routing mechanism via which this route was - learned. Inclusion of values for gateway routing - protocols is not intended to imply that hosts - should support those protocols." - ::= { ipRouteEntry 9 } - - ipRouteAge OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The number of seconds since this route was last - updated or otherwise determined to be correct. - Note that no semantics of `too old' can be implied - except through knowledge of the routing protocol - by which the route was learned." - ::= { ipRouteEntry 10 } - - ipRouteMask OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-write - STATUS mandatory - DESCRIPTION - "Indicate the mask to be logical-ANDed with the - destination address before being compared to the - value in the ipRouteDest field. For those systems - that do not support arbitrary subnet masks, an - agent constructs the value of the ipRouteMask by - determining whether the value of the correspondent - ipRouteDest field belong to a class-A, B, or C - network, and then using one of: - - mask network - 255.0.0.0 class-A - 255.255.0.0 class-B - 255.255.255.0 class-C - - If the value of the ipRouteDest is 0.0.0.0 (a - default route), then the mask value is also - 0.0.0.0. It should be noted that all IP routing - subsystems implicitly use this mechanism." - ::= { ipRouteEntry 11 } - - ipRouteMetric5 OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "An alternate routing metric for this route. The - semantics of this metric are determined by the - routing-protocol specified in the route's - ipRouteProto value. If this metric is not used, - its value should be set to -1." - ::= { ipRouteEntry 12 } - - ipRouteInfo OBJECT-TYPE - SYNTAX OBJECT IDENTIFIER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "A reference to MIB definitions specific to the - particular routing protocol which is responsible - for this route, as determined by the value - specified in the route's ipRouteProto value. If - this information is not present, its value should - be set to the OBJECT IDENTIFIER { 0 0 }, which is - a syntatically valid object identifier, and any - conformant implementation of ASN.1 and BER must be - able to generate and recognize this value." - ::= { ipRouteEntry 13 } - - - -- the IP Address Translation table - - -- The IP address translation table contain the IpAddress to - -- `physical' address equivalences. Some interfaces do not - -- use translation tables for determining address - -- equivalences (e.g., DDN-X.25 has an algorithmic method); - -- if all interfaces are of this type, then the Address - -- Translation table is empty, i.e., has zero entries. - - ipNetToMediaTable OBJECT-TYPE - SYNTAX SEQUENCE OF IpNetToMediaEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "The IP Address Translation table used for mapping - from IP addresses to physical addresses." - ::= { ip 22 } - - ipNetToMediaEntry OBJECT-TYPE - SYNTAX IpNetToMediaEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "Each entry contains one IpAddress to `physical' - address equivalence." - INDEX { ipNetToMediaIfIndex, - ipNetToMediaNetAddress } - ::= { ipNetToMediaTable 1 } - - IpNetToMediaEntry ::= - SEQUENCE { - ipNetToMediaIfIndex - INTEGER, - ipNetToMediaPhysAddress - PhysAddress, - ipNetToMediaNetAddress - IpAddress, - ipNetToMediaType - INTEGER - } - - ipNetToMediaIfIndex OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The interface on which this entry's equivalence - is effective. The interface identified by a - particular value of this index is the same - interface as identified by the same value of - ifIndex." - ::= { ipNetToMediaEntry 1 } - - ipNetToMediaPhysAddress OBJECT-TYPE - SYNTAX PhysAddress - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The media-dependent `physical' address." - ::= { ipNetToMediaEntry 2 } - - - - ipNetToMediaNetAddress OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The IpAddress corresponding to the media- - dependent `physical' address." - ::= { ipNetToMediaEntry 3 } - - ipNetToMediaType OBJECT-TYPE - SYNTAX INTEGER { - other(1), -- none of the following - invalid(2), -- an invalidated mapping - dynamic(3), - static(4) - } - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The type of mapping. - - Setting this object to the value invalid(2) has - the effect of invalidating the corresponding entry - in the ipNetToMediaTable. That is, it effectively - dissasociates the interface identified with said - entry from the mapping identified with said entry. - It is an implementation-specific matter as to - whether the agent removes an invalidated entry - from the table. Accordingly, management stations - must be prepared to receive tabular information - from agents that corresponds to entries not - currently in use. Proper interpretation of such - entries requires examination of the relevant - ipNetToMediaType object." - ::= { ipNetToMediaEntry 4 } - - - -- additional IP objects - - ipRoutingDiscards OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of routing entries which were chosen - to be discarded even though they are valid. One - possible reason for discarding such an entry could - be to free-up buffer space for other routing - entries." - ::= { ip 23 } - - - -- the ICMP group - - -- Implementation of the ICMP group is mandatory for all - -- systems. - - icmpInMsgs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of ICMP messages which the - entity received. Note that this counter includes - all those counted by icmpInErrors." - ::= { icmp 1 } - - icmpInErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP messages which the entity - received but determined as having ICMP-specific - errors (bad ICMP checksums, bad length, etc.)." - ::= { icmp 2 } - - icmpInDestUnreachs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Destination Unreachable - messages received." - ::= { icmp 3 } - - icmpInTimeExcds OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Time Exceeded messages - received." - ::= { icmp 4 } - - - icmpInParmProbs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Parameter Problem messages - received." - ::= { icmp 5 } - - icmpInSrcQuenchs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Source Quench messages - received." - ::= { icmp 6 } - - icmpInRedirects OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Redirect messages received." - ::= { icmp 7 } - - icmpInEchos OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Echo (request) messages - received." - ::= { icmp 8 } - - icmpInEchoReps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Echo Reply messages received." - ::= { icmp 9 } - - icmpInTimestamps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Timestamp (request) messages - received." - ::= { icmp 10 } - - icmpInTimestampReps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Timestamp Reply messages - received." - ::= { icmp 11 } - - icmpInAddrMasks OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Address Mask Request messages - received." - ::= { icmp 12 } - - icmpInAddrMaskReps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Address Mask Reply messages - received." - ::= { icmp 13 } - - icmpOutMsgs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of ICMP messages which this - entity attempted to send. Note that this counter - includes all those counted by icmpOutErrors." - ::= { icmp 14 } - - icmpOutErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP messages which this entity did - not send due to problems discovered within ICMP - such as a lack of buffers. This value should not - include errors discovered outside the ICMP layer - such as the inability of IP to route the resultant - datagram. In some implementations there may be no - types of error which contribute to this counter's - value." - ::= { icmp 15 } - - icmpOutDestUnreachs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Destination Unreachable - messages sent." - ::= { icmp 16 } - - icmpOutTimeExcds OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Time Exceeded messages sent." - ::= { icmp 17 } - - icmpOutParmProbs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Parameter Problem messages - sent." - ::= { icmp 18 } - - icmpOutSrcQuenchs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Source Quench messages sent." - ::= { icmp 19 } - - icmpOutRedirects OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Redirect messages sent. For a - host, this object will always be zero, since hosts - do not send redirects." - ::= { icmp 20 } - - icmpOutEchos OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Echo (request) messages sent." - ::= { icmp 21 } - - icmpOutEchoReps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Echo Reply messages sent." - ::= { icmp 22 } - - icmpOutTimestamps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Timestamp (request) messages - sent." - ::= { icmp 23 } - - icmpOutTimestampReps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Timestamp Reply messages - sent." - ::= { icmp 24 } - - icmpOutAddrMasks OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Address Mask Request messages - sent." - ::= { icmp 25 } - - - icmpOutAddrMaskReps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of ICMP Address Mask Reply messages - sent." - ::= { icmp 26 } - - - -- the TCP group - - -- Implementation of the TCP group is mandatory for all - -- systems that implement the TCP. - - -- Note that instances of object types that represent - -- information about a particular TCP connection are - -- transient; they persist only as long as the connection - -- in question. - - tcpRtoAlgorithm OBJECT-TYPE - SYNTAX INTEGER { - other(1), -- none of the following - - constant(2), -- a constant rto - rsre(3), -- MIL-STD-1778, Appendix B - vanj(4) -- Van Jacobson's algorithm [10] - } - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The algorithm used to determine the timeout value - used for retransmitting unacknowledged octets." - ::= { tcp 1 } - - tcpRtoMin OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The minimum value permitted by a TCP - implementation for the retransmission timeout, - measured in milliseconds. More refined semantics - for objects of this type depend upon the algorithm - used to determine the retransmission timeout. In - particular, when the timeout algorithm is rsre(3), - an object of this type has the semantics of the - LBOUND quantity described in RFC 793." - ::= { tcp 2 } - - - tcpRtoMax OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The maximum value permitted by a TCP - implementation for the retransmission timeout, - measured in milliseconds. More refined semantics - for objects of this type depend upon the algorithm - used to determine the retransmission timeout. In - particular, when the timeout algorithm is rsre(3), - an object of this type has the semantics of the - UBOUND quantity described in RFC 793." - ::= { tcp 3 } - - tcpMaxConn OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The limit on the total number of TCP connections - the entity can support. In entities where the - maximum number of connections is dynamic, this - object should contain the value -1." - ::= { tcp 4 } - - tcpActiveOpens OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of times TCP connections have made a - direct transition to the SYN-SENT state from the - CLOSED state." - ::= { tcp 5 } - - tcpPassiveOpens OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of times TCP connections have made a - direct transition to the SYN-RCVD state from the - LISTEN state." - ::= { tcp 6 } - - - - tcpAttemptFails OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of times TCP connections have made a - direct transition to the CLOSED state from either - the SYN-SENT state or the SYN-RCVD state, plus the - number of times TCP connections have made a direct - transition to the LISTEN state from the SYN-RCVD - state." - ::= { tcp 7 } - - tcpEstabResets OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of times TCP connections have made a - direct transition to the CLOSED state from either - the ESTABLISHED state or the CLOSE-WAIT state." - ::= { tcp 8 } - - tcpCurrEstab OBJECT-TYPE - SYNTAX Gauge - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of TCP connections for which the - current state is either ESTABLISHED or CLOSE- - WAIT." - ::= { tcp 9 } - - tcpInSegs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of segments received, including - those received in error. This count includes - segments received on currently established - connections." - ::= { tcp 10 } - - tcpOutSegs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of segments sent, including - those on current connections but excluding those - containing only retransmitted octets." - ::= { tcp 11 } - - tcpRetransSegs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of segments retransmitted - that - is, the number of TCP segments transmitted - containing one or more previously transmitted - octets." - ::= { tcp 12 } - - - -- the TCP Connection table - - -- The TCP connection table contains information about this - -- entity's existing TCP connections. - - tcpConnTable OBJECT-TYPE - SYNTAX SEQUENCE OF TcpConnEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "A table containing TCP connection-specific - information." - ::= { tcp 13 } - - tcpConnEntry OBJECT-TYPE - SYNTAX TcpConnEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "Information about a particular current TCP - connection. An object of this type is transient, - in that it ceases to exist when (or soon after) - the connection makes the transition to the CLOSED - state." - INDEX { tcpConnLocalAddress, - tcpConnLocalPort, - tcpConnRemAddress, - tcpConnRemPort } - ::= { tcpConnTable 1 } - - - TcpConnEntry ::= - SEQUENCE { - tcpConnState - INTEGER, - tcpConnLocalAddress - IpAddress, - tcpConnLocalPort - INTEGER (0..65535), - tcpConnRemAddress - IpAddress, - tcpConnRemPort - INTEGER (0..65535) - } - - tcpConnState OBJECT-TYPE - SYNTAX INTEGER { - closed(1), - listen(2), - synSent(3), - synReceived(4), - established(5), - finWait1(6), - finWait2(7), - closeWait(8), - lastAck(9), - closing(10), - timeWait(11), - deleteTCB(12) - } - ACCESS read-write - STATUS mandatory - DESCRIPTION - "The state of this TCP connection. - - The only value which may be set by a management - station is deleteTCB(12). Accordingly, it is - appropriate for an agent to return a `badValue' - response if a management station attempts to set - this object to any other value. - - If a management station sets this object to the - value deleteTCB(12), then this has the effect of - deleting the TCB (as defined in RFC 793) of the - corresponding connection on the managed node, - resulting in immediate termination of the - connection. - - As an implementation-specific option, a RST - segment may be sent from the managed node to the - other TCP endpoint (note however that RST segments - are not sent reliably)." - ::= { tcpConnEntry 1 } - - tcpConnLocalAddress OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The local IP address for this TCP connection. In - the case of a connection in the listen state which - is willing to accept connections for any IP - interface associated with the node, the value - 0.0.0.0 is used." - ::= { tcpConnEntry 2 } - - tcpConnLocalPort OBJECT-TYPE - SYNTAX INTEGER (0..65535) - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The local port number for this TCP connection." - ::= { tcpConnEntry 3 } - - tcpConnRemAddress OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The remote IP address for this TCP connection." - ::= { tcpConnEntry 4 } - - tcpConnRemPort OBJECT-TYPE - SYNTAX INTEGER (0..65535) - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The remote port number for this TCP connection." - ::= { tcpConnEntry 5 } - - - -- additional TCP objects - - tcpInErrs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of segments received in error - (e.g., bad TCP checksums)." - ::= { tcp 14 } - - tcpOutRsts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of TCP segments sent containing the - RST flag." - ::= { tcp 15 } - - - -- the UDP group - - -- Implementation of the UDP group is mandatory for all - -- systems which implement the UDP. - - udpInDatagrams OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of UDP datagrams delivered to - UDP users." - ::= { udp 1 } - - udpNoPorts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of received UDP datagrams for - which there was no application at the destination - port." - ::= { udp 2 } - - udpInErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of received UDP datagrams that could - not be delivered for reasons other than the lack - of an application at the destination port." - ::= { udp 3 } - - - udpOutDatagrams OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of UDP datagrams sent from this - entity." - ::= { udp 4 } - - - -- the UDP Listener table - - -- The UDP listener table contains information about this - -- entity's UDP end-points on which a local application is - -- currently accepting datagrams. - - udpTable OBJECT-TYPE - SYNTAX SEQUENCE OF UdpEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "A table containing UDP listener information." - ::= { udp 5 } - - udpEntry OBJECT-TYPE - SYNTAX UdpEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "Information about a particular current UDP - listener." - INDEX { udpLocalAddress, udpLocalPort } - ::= { udpTable 1 } - - UdpEntry ::= - SEQUENCE { - udpLocalAddress - IpAddress, - udpLocalPort - INTEGER (0..65535) - } - - udpLocalAddress OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The local IP address for this UDP listener. In - the case of a UDP listener which is willing to - accept datagrams for any IP interface associated - with the node, the value 0.0.0.0 is used." - ::= { udpEntry 1 } - - udpLocalPort OBJECT-TYPE - SYNTAX INTEGER (0..65535) - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The local port number for this UDP listener." - ::= { udpEntry 2 } - - - -- the EGP group - - -- Implementation of the EGP group is mandatory for all - -- systems which implement the EGP. - - egpInMsgs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of EGP messages received without - error." - ::= { egp 1 } - - egpInErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of EGP messages received that proved - to be in error." - ::= { egp 2 } - - egpOutMsgs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of locally generated EGP - messages." - ::= { egp 3 } - - egpOutErrors OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of locally generated EGP messages not - sent due to resource limitations within an EGP - entity." - ::= { egp 4 } - - - -- the EGP Neighbor table - - -- The EGP neighbor table contains information about this - -- entity's EGP neighbors. - - egpNeighTable OBJECT-TYPE - SYNTAX SEQUENCE OF EgpNeighEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "The EGP neighbor table." - ::= { egp 5 } - - egpNeighEntry OBJECT-TYPE - SYNTAX EgpNeighEntry - ACCESS not-accessible - STATUS mandatory - DESCRIPTION - "Information about this entity's relationship with - a particular EGP neighbor." - INDEX { egpNeighAddr } - ::= { egpNeighTable 1 } - - EgpNeighEntry ::= - SEQUENCE { - egpNeighState - INTEGER, - egpNeighAddr - IpAddress, - egpNeighAs - INTEGER, - egpNeighInMsgs - Counter, - egpNeighInErrs - Counter, - egpNeighOutMsgs - Counter, - egpNeighOutErrs - Counter, - egpNeighInErrMsgs - Counter, - egpNeighOutErrMsgs - Counter, - egpNeighStateUps - Counter, - egpNeighStateDowns - Counter, - egpNeighIntervalHello - INTEGER, - egpNeighIntervalPoll - INTEGER, - egpNeighMode - INTEGER, - egpNeighEventTrigger - INTEGER - } - - egpNeighState OBJECT-TYPE - SYNTAX INTEGER { - idle(1), - acquisition(2), - down(3), - up(4), - cease(5) - } - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The EGP state of the local system with respect to - this entry's EGP neighbor. Each EGP state is - represented by a value that is one greater than - the numerical value associated with said state in - RFC 904." - ::= { egpNeighEntry 1 } - - egpNeighAddr OBJECT-TYPE - SYNTAX IpAddress - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The IP address of this entry's EGP neighbor." - ::= { egpNeighEntry 2 } - - egpNeighAs OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The autonomous system of this EGP peer. Zero - should be specified if the autonomous system - number of the neighbor is not yet known." - ::= { egpNeighEntry 3 } - - egpNeighInMsgs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of EGP messages received without error - from this EGP peer." - ::= { egpNeighEntry 4 } - - egpNeighInErrs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of EGP messages received from this EGP - peer that proved to be in error (e.g., bad EGP - checksum)." - ::= { egpNeighEntry 5 } - - egpNeighOutMsgs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of locally generated EGP messages to - this EGP peer." - ::= { egpNeighEntry 6 } - - egpNeighOutErrs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of locally generated EGP messages not - sent to this EGP peer due to resource limitations - within an EGP entity." - ::= { egpNeighEntry 7 } - - egpNeighInErrMsgs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of EGP-defined error messages received - from this EGP peer." - ::= { egpNeighEntry 8 } - - egpNeighOutErrMsgs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of EGP-defined error messages sent to - this EGP peer." - ::= { egpNeighEntry 9 } - - egpNeighStateUps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of EGP state transitions to the UP - state with this EGP peer." - ::= { egpNeighEntry 10 } - - egpNeighStateDowns OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The number of EGP state transitions from the UP - state to any other state with this EGP peer." - ::= { egpNeighEntry 11 } - - egpNeighIntervalHello OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The interval between EGP Hello command - retransmissions (in hundredths of a second). This - represents the t1 timer as defined in RFC 904." - ::= { egpNeighEntry 12 } - - egpNeighIntervalPoll OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The interval between EGP poll command - retransmissions (in hundredths of a second). This - represents the t3 timer as defined in RFC 904." - ::= { egpNeighEntry 13 } - - egpNeighMode OBJECT-TYPE - SYNTAX INTEGER { active(1), passive(2) } - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The polling mode of this EGP entity, either - passive or active." - ::= { egpNeighEntry 14 } - - egpNeighEventTrigger OBJECT-TYPE - SYNTAX INTEGER { start(1), stop(2) } - ACCESS read-write - STATUS mandatory - DESCRIPTION - "A control variable used to trigger operator- - initiated Start and Stop events. When read, this - variable always returns the most recent value that - egpNeighEventTrigger was set to. If it has not - been set since the last initialization of the - network management subsystem on the node, it - returns a value of `stop'. - - When set, this variable causes a Start or Stop - event on the specified neighbor, as specified on - pages 8-10 of RFC 904. Briefly, a Start event - causes an Idle peer to begin neighbor acquisition - and a non-Idle peer to reinitiate neighbor - acquisition. A stop event causes a non-Idle peer - to return to the Idle state until a Start event - occurs, either via egpNeighEventTrigger or - otherwise." - ::= { egpNeighEntry 15 } - - - -- additional EGP objects - - egpAs OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The autonomous system number of this EGP entity." - ::= { egp 6 } - - - - -- the Transmission group - - -- Based on the transmission media underlying each interface - -- on a system, the corresponding portion of the Transmission - -- group is mandatory for that system. - - -- When Internet-standard definitions for managing - -- transmission media are defined, the transmission group is - -- used to provide a prefix for the names of those objects. - - -- Typically, such definitions reside in the experimental - -- portion of the MIB until they are "proven", then as a - -- part of the Internet standardization process, the - -- definitions are accordingly elevated and a new object - -- identifier, under the transmission group is defined. By - -- convention, the name assigned is: - -- - -- type OBJECT IDENTIFIER ::= { transmission number } - -- - -- where "type" is the symbolic value used for the media in - -- the ifType column of the ifTable object, and "number" is - -- the actual integer value corresponding to the symbol. - - - -- the SNMP group - - -- Implementation of the SNMP group is mandatory for all - -- systems which support an SNMP protocol entity. Some of - -- the objects defined below will be zero-valued in those - -- SNMP implementations that are optimized to support only - -- those functions specific to either a management agent or - -- a management station. In particular, it should be - -- observed that the objects below refer to an SNMP entity, - -- and there may be several SNMP entities residing on a - -- managed node (e.g., if the node is hosting acting as - -- a management station). - - snmpInPkts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of Messages delivered to the - SNMP entity from the transport service." - ::= { snmp 1 } - - snmpOutPkts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Messages which were - passed from the SNMP protocol entity to the - transport service." - ::= { snmp 2 } - - snmpInBadVersions OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Messages which were - delivered to the SNMP protocol entity and were for - an unsupported SNMP version." - ::= { snmp 3 } - - snmpInBadCommunityNames OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Messages delivered to - the SNMP protocol entity which used a SNMP - community name not known to said entity." - ::= { snmp 4 } - - snmpInBadCommunityUses OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Messages delivered to - the SNMP protocol entity which represented an SNMP - operation which was not allowed by the SNMP - community named in the Message." - ::= { snmp 5 } - - snmpInASNParseErrs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of ASN.1 or BER errors - encountered by the SNMP protocol entity when - decoding received SNMP Messages." - ::= { snmp 6 } - - - -- { snmp 7 } is not used - - snmpInTooBigs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP PDUs which were - delivered to the SNMP protocol entity and for - which the value of the error-status field is - `tooBig'." - ::= { snmp 8 } - - snmpInNoSuchNames OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP PDUs which were - delivered to the SNMP protocol entity and for - which the value of the error-status field is - `noSuchName'." - ::= { snmp 9 } - - snmpInBadValues OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP PDUs which were - delivered to the SNMP protocol entity and for - which the value of the error-status field is - `badValue'." - ::= { snmp 10 } - - snmpInReadOnlys OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number valid SNMP PDUs which were - delivered to the SNMP protocol entity and for - which the value of the error-status field is - `readOnly'. It should be noted that it is a - protocol error to generate an SNMP PDU which - contains the value `readOnly' in the error-status - field, as such this object is provided as a means - of detecting incorrect implementations of the - SNMP." - ::= { snmp 11 } - - snmpInGenErrs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP PDUs which were - delivered to the SNMP protocol entity and for - which the value of the error-status field is - `genErr'." - ::= { snmp 12 } - - snmpInTotalReqVars OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of MIB objects which have been - retrieved successfully by the SNMP protocol entity - as the result of receiving valid SNMP Get-Request - and Get-Next PDUs." - ::= { snmp 13 } - - snmpInTotalSetVars OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of MIB objects which have been - altered successfully by the SNMP protocol entity - as the result of receiving valid SNMP Set-Request - PDUs." - ::= { snmp 14 } - - snmpInGetRequests OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Get-Request PDUs which - have been accepted and processed by the SNMP - protocol entity." - ::= { snmp 15 } - - snmpInGetNexts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Get-Next PDUs which have - been accepted and processed by the SNMP protocol - entity." - ::= { snmp 16 } - - snmpInSetRequests OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Set-Request PDUs which - have been accepted and processed by the SNMP - protocol entity." - ::= { snmp 17 } - - snmpInGetResponses OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Get-Response PDUs which - have been accepted and processed by the SNMP - protocol entity." - ::= { snmp 18 } - - snmpInTraps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Trap PDUs which have - been accepted and processed by the SNMP protocol - entity." - ::= { snmp 19 } - - snmpOutTooBigs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP PDUs which were - generated by the SNMP protocol entity and for - which the value of the error-status field is - `tooBig.'" - ::= { snmp 20 } - - - snmpOutNoSuchNames OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP PDUs which were - generated by the SNMP protocol entity and for - which the value of the error-status is - `noSuchName'." - ::= { snmp 21 } - - snmpOutBadValues OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP PDUs which were - generated by the SNMP protocol entity and for - which the value of the error-status field is - `badValue'." - ::= { snmp 22 } - - -- { snmp 23 } is not used - - snmpOutGenErrs OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP PDUs which were - generated by the SNMP protocol entity and for - which the value of the error-status field is - `genErr'." - ::= { snmp 24 } - - snmpOutGetRequests OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Get-Request PDUs which - have been generated by the SNMP protocol entity." - ::= { snmp 25 } - - snmpOutGetNexts OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Get-Next PDUs which have - been generated by the SNMP protocol entity." - ::= { snmp 26 } - - snmpOutSetRequests OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Set-Request PDUs which - have been generated by the SNMP protocol entity." - ::= { snmp 27 } - - snmpOutGetResponses OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Get-Response PDUs which - have been generated by the SNMP protocol entity." - ::= { snmp 28 } - - snmpOutTraps OBJECT-TYPE - SYNTAX Counter - ACCESS read-only - STATUS mandatory - DESCRIPTION - "The total number of SNMP Trap PDUs which have - been generated by the SNMP protocol entity." - ::= { snmp 29 } - - snmpEnableAuthenTraps OBJECT-TYPE - SYNTAX INTEGER { enabled(1), disabled(2) } - ACCESS read-write - STATUS mandatory - DESCRIPTION - "Indicates whether the SNMP agent process is - permitted to generate authentication-failure - traps. The value of this object overrides any - configuration information; as such, it provides a - means whereby all authentication-failure traps may - be disabled. - - Note that it is strongly recommended that this - object be stored in non-volatile memory so that it - remains constant between re-initializations of the - network management system." - ::= { snmp 30 } - -END diff --git a/SecuritySNACCRuntime/asn1specs/tbl.asn1 b/SecuritySNACCRuntime/asn1specs/tbl.asn1 deleted file mode 100644 index 7433cd19..00000000 --- a/SecuritySNACCRuntime/asn1specs/tbl.asn1 +++ /dev/null @@ -1,171 +0,0 @@ --- .../asn1specs/tbl.asn1 --- --- TBL types describe ASN.1 data structures. --- These can be used in generic, interpretive encoders/decoders. --- Interpretive decoders are typically slower, but don't eat memory --- with type-specific encoding and decoding code. --- The tbl types can also be sent over the network --- and allow dynamic re-configuration of encoders/decoders. --- --- To understand how this type table structure is used --- look in: --- 1. .../compiler/core/gen-tbls.c --- this will show you how various things are generated --- from the big parse tree (asn1module.asn1). --- Pay particular attention to the typeDefId use --- --- 2. look in .../c-lib/makefile for an example of how you can --- modify the tbl.h file generated from this module to suit --- your own needs. --- --- 3. look in .../tbl-tools/ptbl/pasn1.c to see how the --- TBL data struct relates to the original ASN.1 --- --- --- --- Mike Sample, April 11, 1992 --- Mods MS Feb 7/93 --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/tbl.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ --- $Log: tbl.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:05 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:05:56 aram --- Originals from SMIME Free Library. --- --- Revision 1.5 1997/06/19 09:17:13 wan --- Added isPdu flag to tables. Added value range checks during parsing. --- --- Revision 1.4 1997/05/07 15:18:33 wan --- Added (limited) size constraints, bitstring and enumeration names to tables --- --- Revision 1.3 1995/07/25 19:56:00 rj --- introductory comments adjusted to match changed file names. --- --- changed `_' to `-' in file names. --- --- Revision 1.2 1994/08/28 09:54:18 rj --- comment leader fixed. --- --- Revision 1.1 1994/08/28 09:51:14 rj --- first check-in. - -TBL DEFINITIONS ::= -BEGIN - - --- imports nothing --- exports nothing - -TBL ::= --snacc isPdu:"TRUE" -- SEQUENCE -{ - totalNumModules INTEGER, -- these totals can help allocation - totalNumTypeDefs INTEGER, -- when decoding (ie use arrays) - totalNumTypes INTEGER, - totalNumTags INTEGER, - totalNumStrings INTEGER, - totalLenStrings INTEGER, - modules SEQUENCE OF TBLModule -} - -TBLModule ::= SEQUENCE -{ - name [0] IMPLICIT PrintableString, - id [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL, - isUseful [2] IMPLICIT BOOLEAN, -- true if useful types module - typeDefs [3] IMPLICIT SEQUENCE OF TBLTypeDef -} - --- --- The typedefId is just an integer that uniquely identifies --- each TBLTypeDef (type references use these as "pointers"). --- The typeDefId's in each module will have consecutive type ids. --- The first typedef in a module will have the lowest Id and the --- last typedef will have the highest. Thus if the first typedef --- in a module has the id of 12 and the last typedef in that module --- has the id of 27, the module contains the typdefs in the range --- 12..27 (inclusive). This can be used to re-compute the --- IMPORT information for modules in a type table. --- --- (The LoadTBL routine hides this integer/ptr crap from the user --- by adding real pointers to the tbl.h data structures where useful. --- When loading, the typeDefIds are converted into these real ptrs) --- -TBLTypeDef ::= SEQUENCE -{ - typeDefId TBLTypeDefId, - typeName PrintableString, -- OPTIONAL, I have forgotten why this is opt! - -- I can see no good reason for it - type TBLType, - isPdu NULL OPTIONAL -} - -TBLType ::= SEQUENCE -{ - typeId [0] IMPLICIT TBLTypeId, - optional [1] IMPLICIT BOOLEAN, - tagList [2] IMPLICIT SEQUENCE OF TBLTag OPTIONAL, - content [3] TBLTypeContent, - fieldName [4] IMPLICIT PrintableString OPTIONAL, - constraint[5] IMPLICIT TBLRange OPTIONAL, - values [6] IMPLICIT TBLNamedNumberList OPTIONAL -} - -TBLRange ::= SEQUENCE -{ - from [0] IMPLICIT INTEGER, - to [1] IMPLICIT INTEGER -} - -TBLNamedNumberList ::= SEQUENCE OF TBLNamedNumber - -TBLNamedNumber ::= SEQUENCE -{ - name [0] IMPLICIT PrintableString, - value [1] IMPLICIT INTEGER -} - -TBLTypeContent ::= CHOICE -{ - primType [0] IMPLICIT NULL, - elmts [1] IMPLICIT SEQUENCE OF TBLType, - typeRef [2] IMPLICIT TBLTypeRef -} - -TBLTypeRef ::= SEQUENCE -{ - typeDef TBLTypeDefId, - implicit BOOLEAN -} - -TBLTypeId ::= ENUMERATED -{ - tbl-boolean (0), - tbl-integer (1), - tbl-bitstring (2), - tbl-octetstring (3), - tbl-null (4), - tbl-oid (5), - tbl-real (6), - tbl-enumerated (7), - tbl-sequence (8), - tbl-set (9), - tbl-sequenceof (10), - tbl-setof (11), - tbl-choice (12), - tbl-typeref (13) -} - -TBLTypeDefId ::= INTEGER - -TBLTag ::= SEQUENCE -{ - tclass TBLTagClass, - code INTEGER (0..MAX) -} - -TBLTagClass ::= ENUMERATED { universal (0), application (1), - context (2), private (3) } - -END diff --git a/SecuritySNACCRuntime/c++-examples/any/README b/SecuritySNACCRuntime/c++-examples/any/README deleted file mode 100644 index d65005fb..00000000 --- a/SecuritySNACCRuntime/c++-examples/any/README +++ /dev/null @@ -1,96 +0,0 @@ -(RCS control information is at the end of this file.) - - -C++ ANY example README ---------------------- - -This example shows how the snacc compiler handles the ANY DEFINED BY -type in C++. ANY types (not ANY DEFINED BY) require modifications -to the generated code. Type "make" to build this example. - -This directory should have the following 4 files in it: - - README - example.C - genber.C - makefile - -There are 3 programs generated by the makefile: - - genber - builds a BER value of the AnyTestType and writes it - to a file called "att.ber" - - def - takes file name of an AnyTestType BER value. Decodes the - file and re-encodes it to stdout. Uses definite - lengths for constructed values. - - indef - takes file name of an AnyTestType BER value. Decodes the - file and re-encodes it to stdout. Uses indefinite - lengths for constructed values. - - -These files use the code generated by snacc from the -snacc/asn1specs/any.asn1 file. (see the makefile) - -Look at genber.C to see how values can be built and printed. - -Look at the generated code in any_test.C and any_test.h to see how the -any hash table is built. - - -try the following commands in your c-shell: - -%1 genber # generate the att.ber file -%2 indef att.ber > tmp.ber # decode att.ber an re-encode into tmp.ber -%3 def tmp.ber > tmp2.ber # decode tmp.ber an re-encode into tmp2.ber -%4 diff att.ber tmp2.ber # compare .ber files (should be the same) - -When you are finished with the example type "make clean" to remove -the binaries and generated code. - - - -Things To Note --------------- - -Snacc ASN.1 comment commands - -In the snacc/asn1specs/any.asn1 file, the AnyTestType has a special -"--snacc" ASN.1 comment after ::= to give snacc some extra information -about the AnyTestType. - -AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE { ... etc. ... } - -The "isPdu" flag only affects the generated C code, not C++. Each -C++ type gets PDU methods by default. - - -SNMP OBJECT-TYPE Macro - -The SNMP OBJECT-TYPE macro is used to define the id value to type -mapping for ANY DEFINED BY types. The macro has been modified to -accept both INTEGERs and OBJECT IDENTIFIERs as id values (see -snacc/asn1specs/any.asn1). This macro can be used with other -protocols to define the id to type mapping. - -Two hash tables are used to hold the id to type mappings. One for -INTEGER to type mappings and the other for OBJECT IDENTIFIER to type -mappings. The hash tables are automatically initialized in each -module that has OBJECT-TYPE macros. In C the hash table must be -explicitly initialized. - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/any/Attic/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:57 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1997/02/16 20:25:26 rj -# check-in of a few cosmetic changes -# -# Revision 1.1 1994/08/31 08:47:59 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# diff --git a/SecuritySNACCRuntime/c++-examples/any/example.C b/SecuritySNACCRuntime/c++-examples/any/example.C deleted file mode 100644 index eb0a504a..00000000 --- a/SecuritySNACCRuntime/c++-examples/any/example.C +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// c++_examples/any/example.C - an example of how to use C++ ASN.1-BER -// for ANY Types -// -// AUTHOR: Mike Sample -// DATE: 92 -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/any/Attic/example.C,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -// $Log: example.C,v $ -// Revision 1.1.1.1 2001/05/18 23:14:05 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1.1.1 1999/03/16 18:05:57 aram -// Originals from SMIME Free Library. -// -// Revision 1.5 1995/07/24 15:33:33 rj -// changed `_' to `-' in file names. -// -// any-test.[hC] becomes any.[hC] due to to snacc's new file name generation scheme. -// -// check return value of new. -// -// Revision 1.4 1995/02/18 13:53:07 rj -// added #define HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS since not every C++ compiler provides them. -// -// Revision 1.3 1994/10/08 01:26:21 rj -// several \size_t' -// -// Revision 1.2 1994/08/31 08:56:29 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -// - -#include -#include -#include -#include - -#include "asn-incl.h" -#include "any.h" - -main (int argc, char *argv[]) -{ - if (argc != 2) - { - cerr << "Usage: " << argv[0] << " " << endl; - cerr << " Decodes the given AnyTestType BER data file" << endl; - cerr << " and re-encodes it to stdout" << endl; - exit (1); - } - - ifstream dataFile; - // open the data file - dataFile.open (argv[1]); - - if (!dataFile) - { - perror ("ifstream::open"); - exit (1); - } - - // get size of the data file file - dataFile.seekg (0, ios::end); - int dataSize = dataFile.tellg(); - dataFile.seekg (0); - - // read data from file into contiguous block for a buffer -#if HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS - char data[dataSize]; -#else - char *data = new char[dataSize]; - if (!data) - return 1; -#endif /* HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS */ - dataFile.read (data, dataSize); - dataFile.close(); - - // - // put the BER data read from the file - // into buffer format, ready for reading from the - // beginning - // - AsnBuf inputBuf; - inputBuf.InstallData ((char*)data, dataSize); - - size_t decodedLen; - AnyTestType att; - - if (!att.BDecPdu (inputBuf, decodedLen)) - { - cerr << "ERROR - Decode routines failed, exiting..." << endl; - exit (1); - } - - cerr << "decodedValue AnyTestType ::= " << att << endl << endl; - - // - // allocate a new buffer and set up for writing to - // - AsnBuf outputBuf; -#if HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS - char outputData[dataSize + 512]; -#else - char *outputData = new char[dataSize + 512]; - if (!outputData) - return 1; -#endif /* HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS */ - outputBuf.Init (outputData, dataSize+512); - outputBuf.ResetInWriteRvsMode(); - - size_t encodedLen; - if (!att.BEncPdu (outputBuf, encodedLen)) - { - cerr << "ERROR - Encode routines failed" << endl; - } - - // write the BER value to cout - outputBuf.ResetInReadMode(); - for ( ; encodedLen > 0; encodedLen--) - cout.put (outputBuf.GetByte()); - - return 0; -} diff --git a/SecuritySNACCRuntime/c++-examples/any/genber.C b/SecuritySNACCRuntime/c++-examples/any/genber.C deleted file mode 100644 index 38c02353..00000000 --- a/SecuritySNACCRuntime/c++-examples/any/genber.C +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// c++_examples/any/genber.C - builds an AnyTestType value and writes BER form -// of the value to a file called "att.ber" -// -// Shows how to build internal rep of lists and ANY values. -// -// MS 92 -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/any/Attic/genber.C,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -// $Log: genber.C,v $ -// Revision 1.1.1.1 2001/05/18 23:14:05 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/08 19:58:44 dmitch -// Mods for X port. -// -// Revision 1.1.1.1 1999/03/16 18:05:57 aram -// Originals from SMIME Free Library. -// -// Revision 1.5 1995/07/24 15:33:34 rj -// changed `_' to `-' in file names. -// -// any-test.[hC] becomes any.[hC] due to to snacc's new file name generation scheme. -// -// check return value of new. -// -// Revision 1.4 1995/02/18 13:54:03 rj -// added #define HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS since not every C++ compiler provides them. -// -// Revision 1.3 1994/10/08 01:26:22 rj -// several \size_t' -// -// Revision 1.2 1994/08/31 08:56:30 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -// - - -#include -#include -#include -#include - -#include "asn-incl.h" -#include "any.h" - -#define APPLE_ANY_HACK 1 - -main (int argc, char *argv[]) -{ - ofstream outputFile; - AsnBuf outputBuf; - size_t encodedLen; - size_t dataSize = 1024; -#if HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS - char data[dataSize]; -#else - char *data = new char[dataSize]; - if (!data) - return 1; -#endif /* HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS */ - AnyTestType att; - TSeq1 ts1; - TSeq2 ts2; - AttrValue1 *atv1ptr; - AttrValue2 *atv2ptr; - AsnInt intVal; - AsnBool boolVal; - AsnOcts octsVal ("Hi Mom"); - OctsId octsIdVal = octsVal; - AsnBits bitsVal; - BitsId bitsIdVal (9); - AsnReal realVal; - - // READ THIS!!! - // you must be really careful when setting the - // "value" field and "id" fields in an - // ANY/ANY DEFINED BY type because "value" is a - // "AsnType*" and will accept any - // pointer value. It will even encode - // the wrong value without complaining if you - // set "value" to the wrong object. - - atv1ptr = att.intMap.Append(); - atv1ptr->id = intId; - intVal = -99; - #if APPLE_ANY_HACK - atv1ptr->anyDefBy.value = reinterpret_cast(&intVal); - #else - atv1ptr->anyDefBy.value = &intVal; - #endif - atv1ptr = att.intMap.Append(); - atv1ptr->id = boolId; - boolVal = true; - #if APPLE_ANY_HACK - atv1ptr->anyDefBy.value = reinterpret_cast(&boolVal); - #else - atv1ptr->anyDefBy.value = &boolVal; - #endif - - atv1ptr = att.intMap.Append(); - atv1ptr->id = octsId; - #if APPLE_ANY_HACK - atv1ptr->anyDefBy.value = reinterpret_cast(&octsIdVal); - #else - atv1ptr->anyDefBy.value = &octsIdVal; - #endif - - atv1ptr = att.intMap.Append(); - atv1ptr->id = bitsId; - bitsIdVal.SetBit (0); - bitsIdVal.ClrBit (1); - bitsIdVal.SetBit (2); - bitsIdVal.ClrBit (3); - bitsIdVal.SetBit (4); - bitsIdVal.ClrBit (5); - bitsIdVal.SetBit (6); - bitsIdVal.ClrBit (7); - bitsIdVal.SetBit (8); - bitsIdVal.ClrBit (9); - #if APPLE_ANY_HACK - atv1ptr->anyDefBy.value = reinterpret_cast(&bitsIdVal); - #else - atv1ptr->anyDefBy.value = &bitsIdVal; - #endif - - atv1ptr = att.intMap.Append(); - atv1ptr->id = realId; - realVal = 108.3838; - #if APPLE_ANY_HACK - atv1ptr->anyDefBy.value = reinterpret_cast(&realVal); - #else - atv1ptr->anyDefBy.value = &realVal; - #endif - - // now do TSeq2 with same vals but use OID as identifier - atv2ptr = att.oidMap.Append(); - atv2ptr->id = intOid; - #if APPLE_ANY_HACK - atv2ptr->anyDefBy.value = reinterpret_cast(&intVal); - #else - atv2ptr->anyDefBy.value = &intVal; - #endif - - atv2ptr = att.oidMap.Append(); - atv2ptr->id = boolOid; - #if APPLE_ANY_HACK - atv2ptr->anyDefBy.value = reinterpret_cast(&boolVal); - #else - atv2ptr->anyDefBy.value = &boolVal; - #endif - - atv2ptr = att.oidMap.Append(); - atv2ptr->id = octsOid; - #if APPLE_ANY_HACK - atv2ptr->anyDefBy.value = reinterpret_cast(&octsVal); - #else - atv2ptr->anyDefBy.value = &octsVal; - #endif - - atv2ptr = att.oidMap.Append(); - atv2ptr->id = bitsOid; - bitsVal = bitsIdVal; // copy bits - #if APPLE_ANY_HACK - atv2ptr->anyDefBy.value = reinterpret_cast(&bitsVal); - #else - atv2ptr->anyDefBy.value = &bitsVal; - #endif - - atv2ptr = att.oidMap.Append(); - atv2ptr->id = realOid; - #if APPLE_ANY_HACK - atv2ptr->anyDefBy.value = reinterpret_cast(&bitsVal); - #else - atv2ptr->anyDefBy.value = &bitsVal; - #endif - - outputBuf.Init (data, dataSize); - outputBuf.ResetInWriteRvsMode(); - - if (!att.BEncPdu (outputBuf, encodedLen)) - cout << "failed encoding AnyTestType value" << endl; - - outputFile.open ("att.ber"); - if (!outputFile) - { - perror ("ofstream::open"); - exit (1); - } - - outputBuf.ResetInReadMode(); - for ( ; encodedLen > 0; encodedLen--) - outputFile.put (outputBuf.GetByte()); - - - cout << "Wrote the following BER AnyTestType value to att.ber." << endl; - cout << "Test it with \"def\" and \"indef\"" << endl; - //cout << att << endl; - - return 0; -} diff --git a/SecuritySNACCRuntime/c++-examples/any/makefile b/SecuritySNACCRuntime/c++-examples/any/makefile deleted file mode 100644 index aa03d9b5..00000000 --- a/SecuritySNACCRuntime/c++-examples/any/makefile +++ /dev/null @@ -1,169 +0,0 @@ -# c++-examples/any/makefile -# -# WARNING: this makefile isn't safe for parallel making! -# -# builds the C++ ANY example -# -# MS 92 -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/any/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.3 2000/12/22 00:03:01 dmitch -# Misc. updates for clean build on Cheetah 1D7. -# -# Revision 1.2 2000/06/08 19:58:44 dmitch -# Mods for X port. -# -# Revision 1.1.1.1 1999/03/16 18:05:57 aram -# Originals from SMIME Free Library. -# -# Revision 1.9 1997/02/16 16:47:46 rj -# made return *this after calling abort()'' a compile time option. -# -# Revision 1.8 1995/07/24 15:29:07 rj -# useful.asn1 renamed to asn-useful.asn1 to accomodate to snacc's new file name generation scheme. -# any-test.[hC] becomes any.[hC] due to to snacc's new file name generation scheme. -# -# `cd && make' instead of `cd; make'. -# -# changed `_' to `-' in file names. -# -# Revision 1.7 1995/02/20 11:46:19 rj -# build snacc if it doesn't exist. -# some makes leave a trailing slash on $(@D), others don't. this causes some mkdir(1)s to deny their cooperation. therefore, the slash has got to be stripped. -# -# Revision 1.6 1995/02/13 14:58:12 rj -# augment CPPFLAGS, not overwrite -# -# Revision 1.5 1994/10/08 04:35:42 rj -# enhance portability by using standard make capabilities instead of utilies (basename, dirname) not found on every platform. -# -# for the dependencies, generate the snacc compiler if it doesn't exist. -# -# Revision 1.4 1994/09/01 02:26:53 rj -# use CXX instead of CC to get another default linkage -# -# Revision 1.3 1994/08/31 21:38:34 rj -# rebuild the executables when the c++-lib is newer. -# -# Revision 1.2 1994/08/31 10:31:47 rj -# since .o files get moved, a few more dependencies are needed. -# -# Revision 1.1 1994/08/31 08:48:03 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../../makehead - -TOP = ../.. - -ASN1_SRC_DIR = $(TOP)/asn1specs - -ASN1_C++_LIB_DIR = $(TOP)/c++-lib -BUILD_DIR = /Data_and_Apps/dmitchBuild -ASN1_C++_INC_DIR = $(ASN1_C++_LIB_DIR)/inc -ASN1_C++_LIB = $(ASN1_C++_LIB_DIR)/libasn1c++.a -framework cdsa_utilities -F/System/Library/PrivateFrameworks -#ASN1_C++_LIB = $(BUILD_DIR)/libsnacc++.a -#ASN1_C++_LIB = -framework snaccRuntime -F/Data_and_Apps/dmitchBuild -lstdc++ - -COMPILERDIR = $(TOP)/compiler -SNACC = $(COMPILERDIR)/snacc -USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 -SNACCFLAGS = -C $(SNACC_NOVOLAT) -u $(USEFUL_TYPES) - -CC = $(CXX) -CPPFLAGS += -I$(TOP) -I$(ASN1_C++_INC_DIR) $(LENFLAG) -DVDADER_RULES -F/System/Library/PrivateFrameworks - -ASN1FILES = $(ASN1_SRC_DIR)/any.asn1 - -# generated by snacc from any.asn1: -ASN1HFILES = any.h -ASN1CFILES = any.cpp - -CFILES = \ - genber.C \ - example.C - -DISTFILES = \ - README \ - makefile \ - $(CFILES) - -#------------------------------------------------------------------------------- - -all:: genber def indef - -$(ASN1HFILES) \ -$(ASN1CFILES): $(SNACC) $(ASN1FILES) - $(REASON) - $(SNACC) $(SNACCFLAGS) $(ASN1FILES) - -$(SNACC): - cd $(@D) && $(MAKE) $(@F) - -def-obj \ -indef-obj: - mkdir $@ - -def-obj/any.o \ -def-obj/example.o: - $(REASON) - $(MAKE) LENFLAG= `echo $(@D) | sed -e 's:/$$::'` $(@F) - mv $(@F) $@ - -indef-obj/any.o \ -indef-obj/example.o: - $(REASON) - $(MAKE) LENFLAG=-DUSE_INDEF_LEN `echo $(@D) | sed -e 's:/$$::'` $(@F) - mv $(@F) $@ - -genber: def-obj/any.o genber.o - $(REASON) - $(CC) $(LDFLAGS) -o $@ def-obj/any.o genber.o $(ASN1_C++_LIB) $(LIBS) -lstdc++ - -def: def-obj/any.o def-obj/example.o - $(REASON) - $(CC) $(LDFLAGS) -o $@ def-obj/any.o def-obj/example.o $(ASN1_C++_LIB) $(LIBS) -lstdc++ - -indef: indef-obj/any.o indef-obj/example.o - $(REASON) - $(CC) $(LDFLAGS) -o $@ indef-obj/any.o indef-obj/example.o $(ASN1_C++_LIB) $(LIBS) -lstdc++ - -genber \ -def \ -indef: - -.PHONY: check - -check:: genber def indef - $(RM) foo.ber bar.ber - ./genber - ./indef att.ber > foo.ber - ./def foo.ber > bar.ber - @echo '' - @if cmp -s bar.ber att.ber; then\ - echo "+++ Passed simple encode/decode tests using any.asn1.";\ - else\ - echo "--- Failed simple encode/decode tests using any.asn1.";\ - fi - @echo '' - $(RM) foo.ber bar.ber - -clean:: - $(RM) *.o *~ .emacs* core def indef genber att.ber $(ASN1HFILES) $(ASN1CFILES) - $(RM) -r def-obj indef-obj - $(RM) foo.ber bar.ber - -depend:: $(SNACC) - -include ../../maketail - -depend:: - cp dependencies deps - for dir in def-obj indef-obj; do\ - < dependencies sed -e 's:^\(.*\.o\):'"$$dir"'/\1:' >> deps;\ - done - mv deps dependencies diff --git a/SecuritySNACCRuntime/c++-examples/makefile b/SecuritySNACCRuntime/c++-examples/makefile deleted file mode 100644 index 0b16647a..00000000 --- a/SecuritySNACCRuntime/c++-examples/makefile +++ /dev/null @@ -1,36 +0,0 @@ -# file: .../c++-examples/makefile - -# Apple change: simple doesn't run (yet). -#SUBDIRS = test-lib simple any snmp -SUBDIRS = test-lib any snmp - -#------------------------------------------------------------------------------- - -.PHONY: implicit_default -implicit_default:: - $(MAKE) subdirs - -subdirs:: $(SUBDIRS) -$(SUBDIRS):: - cd $@ && $(MAKE) $(subtarget) - -# the following hack is needed for older make versions (gmake doesn't need it): -init-depend:: - @for dir in $(SUBDIRS); do\ - test -f $$dir/dependencies || touch $$dir/dependencies;\ - done - -.DEFAULT:: - $(MAKE) subdirs subtarget=$@ - -distfiles:: - echo makefile - for dir in $(SUBDIRS); do\ - subfiles=`cd $$dir && $(MAKE) -s $@`;\ - for file in $$subfiles; do\ - echo "$$dir/$$file";\ - done;\ - done - -# dummy: -install:: diff --git a/SecuritySNACCRuntime/c++-examples/simple/README b/SecuritySNACCRuntime/c++-examples/simple/README deleted file mode 100644 index d87e6dde..00000000 --- a/SecuritySNACCRuntime/c++-examples/simple/README +++ /dev/null @@ -1,111 +0,0 @@ -(RCS control information is at the end of this file.) - - -C++ Simple Example README -------------------------- - -This directory should have 6 files in it: - - README - this file - - genber.C - C++ source code for a program that creates and encodes - a PersonnelRecord value to a file. - - example.C - C++ source code for a program that decodes a given - PersonnelRecord value and re-encodes it to stdout. - - makefile - compiles the example programs - - good_pr.ber - BER encoding of a Personnel Record (all definite lengths) - - - -Type "make" to generate the 3 example programs: - genber - def - indef - - - -snacc is called from the makefile on .../asn1specs/p_rec.asn1 to -generate the following files: - -p_rec.h - C++ classes for PersonnelRecord types. - -p_rec.C - C++ source code for the PersonnelRecord encode, decode, - print, and free methods. - -These source files are then compiled with example.C to make the -programs def and indef. Each program takes 1 argument, the name of a -file containing an BER encoded PersonnelRecord value. - - -Try the following: - -%1 genber # create a file called pr.ber -%2 indef good_pr.ber > indef_pr.ber -%3 def indef_pr.ber > def_pr.ber -%4 diff good_pr.ber def_pr.ber # should be no differences - -(commands 2-4 can be made via the `check' phony target.) - -The above commands decode the BER value in "good_pr.ber" and -indef_pr.ber respectively and then re-encode them to stdout. -Both programs will decode any valid BER representation of a -PersonnelRecord value but, the def program will re-encode the -given data using only the definite length BER format and the -indef program will re-encode the given data using only the -indefinite length BER format. - -Compare the lengths of the def_pr.ber and indef_pr.ber files, -indefinite length encodings are usually larger. - - - -Things to Note --------------- - -Look at genber.C to see how to build a C++ value and then encode it. -look at the example.C file to see buffer usage. Look at -.../c++_lib/inc/asn_config.h and .../c++_lib/inc/asn_buf.h if you -want to change the buffer managment. - - -Snacc ASN.1 comment commands - -Notice the special "--snacc" ASN.1 comment in .../asn1specs/p_rec.asn1. - -PersonnelRecord ::= --snacc isPdu:"TRUE" -- [APPLICATION 0] IMPLICIT SET - { ... etc. ... } - -The "isPdu" flag tells snacc that the PersonnelRecord is a PDU type. -This flag has no effect on the generated C++ code, since each type gets -PDU members automatically for C++. - - - -Length formats - -Both the def and indef programs were generated from the same source -file, example.c. Indefinite length encoders can be created by giving -the -DUSE_INDEF_LEN flag to the C++ compiler when compiling. Currently -the indefinite/definite length encoder choice is made a compile time. -To change this to a run-time decision, a simple solution would be to -modify BerEncodeConsLen and BerEncodeEocIfNec macros in -.../c++_lib/inc/asn_len.h to check a global flag. - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/simple/Attic/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:57 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1994/10/08 04:43:46 rj -# the test csh skript has been integrated into the makefile -# -# Revision 1.1 1994/08/31 08:48:05 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# diff --git a/SecuritySNACCRuntime/c++-examples/simple/example.C b/SecuritySNACCRuntime/c++-examples/simple/example.C deleted file mode 100644 index 0ff86db4..00000000 --- a/SecuritySNACCRuntime/c++-examples/simple/example.C +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// c++_examples/simple/example.C - an example of how to use C++ ASN.1-BER -// encoders and decoders generated by snacc -// -// AUTHOR: Mike Sample -// DATE: Aug 92 -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/simple/Attic/example.C,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -// $Log: example.C,v $ -// Revision 1.1.1.1 2001/05/18 23:14:05 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1.1.1 1999/03/16 18:05:57 aram -// Originals from SMIME Free Library. -// -// Revision 1.5 1995/07/24 15:36:03 rj -// check return value of new. -// -// changed `_' to `-' in file names. -// -// Revision 1.4 1995/02/18 13:54:18 rj -// added #define HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS since not every C++ compiler provides them. -// -// Revision 1.3 1994/10/08 01:27:02 rj -// several \size_t' -// -// Revision 1.2 1994/08/31 08:56:32 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -// - -#include -#include -#include -#include -#include "asn-incl.h" -#include "p-rec.h" - - -main (int argc, char *argv[]) -{ - AsnBuf inputBuf; - AsnBuf outputBuf; - size_t encodedLen; - size_t decodedLen; - size_t dataSize; - ifstream dataFile; - PersonnelRecord pr; - - if (argc != 2) - { - cerr << "Usage: " << argv[0] << " " << endl; - cerr << " Decodes the given PersonnelRecord BER data file" << endl; - cerr << " and re-encodes it to stdout" << endl; - exit (1); - } - - - // open the data file - dataFile.open (argv[1]); - - if (!dataFile) - { - perror ("ifstream::open"); - exit (1); - } - - // get size of the data file file - dataFile.seekg (0, ios::end); - dataSize = dataFile.tellg(); - dataFile.seekg (0); - - // read data from file into contiguous block for a buffer -#if HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS - char data[dataSize]; -#else - char *data = new char[dataSize]; - if (!data) - return 1; -#endif /* HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS */ - dataFile.read (data, dataSize); - dataFile.close(); - - // - // put the BER data read from the file - // into buffer format, ready for reading from the - // beginning - // - inputBuf.InstallData (data, dataSize); - - if (!pr.BDecPdu (inputBuf, decodedLen)) - { - cerr << "--- ERROR - Decode routines failed, exiting..." << endl; - exit (1); - } - - cerr << "decodedValue PersonnelRecord ::= " << pr << endl << endl; - - // - // allocate a new buffer set up for writing to - // -#if HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS - char outputData[dataSize + 512]; -#else - char *outputData = new char[dataSize + 512]; - if (!outputData) - return 1; -#endif /* HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS */ - outputBuf.Init (outputData, dataSize+512); - outputBuf.ResetInWriteRvsMode(); - - if (!pr.BEncPdu (outputBuf, encodedLen)) - { - cerr << "--- ERROR - Encode routines failed" << endl; - } - - // write the BER value to cout - outputBuf.ResetInReadMode(); - for (; encodedLen > 0; encodedLen--) - cout.put (outputBuf.GetByte()); - - return 0; -} diff --git a/SecuritySNACCRuntime/c++-examples/simple/genber.C b/SecuritySNACCRuntime/c++-examples/simple/genber.C deleted file mode 100644 index 7ecb7569..00000000 --- a/SecuritySNACCRuntime/c++-examples/simple/genber.C +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++examples/simple/genber.C---builds an PersonnelRecord value and writes BER form of the value to a file called "pr.ber" -// -// MS 92 -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/simple/Attic/genber.C,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -// $Log: genber.C,v $ -// Revision 1.1.1.1 2001/05/18 23:14:05 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1.1.1 1999/03/16 18:05:57 aram -// Originals from SMIME Free Library. -// -// Revision 1.5 1995/07/24 15:40:32 rj -// changed `_' to `-' in file names. -// -// Revision 1.4 1994/12/11 15:36:14 rj -// const for a constant value [DEC] -// -// Revision 1.3 1994/10/08 01:27:03 rj -// several \size_t' -// -// Revision 1.2 1994/08/31 08:56:33 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -// - - -#include -#include -#include -#include - -#include "asn-incl.h" -#include "p-rec.h" - - -main (int argc, char *argv[]) -{ - ofstream outputFile; - AsnBuf outputBuf; - size_t encodedLen; - const size_t dataSize = 1024; - char data[dataSize]; - ChildInformation *ciPtr; - PersonnelRecord pr; - - // build internal value of a PersonnelRecord - pr.name = new Name; - pr.name->givenName = "John"; // this calls pr.name->givenName.Set ("John"); - pr.name->initial = "E"; - pr.name->familyName = "Smith"; - - pr.title.Set ("The Big Cheese"); - pr.employeeNumber = 99999; - pr.dateOfHire.Set ("19820104"); - - pr.nameOfSpouse = new Name; - pr.nameOfSpouse->givenName.Set ("Mary"); - pr.nameOfSpouse->initial.Set ("L"); - pr.nameOfSpouse->familyName.Set ("Smith"); - - pr.children = new PersonnelRecordSeqOf; - - ciPtr = pr.children->Append(); - ciPtr->name = new Name; - ciPtr->name->givenName.Set ("James"); - ciPtr->name->initial.Set ("R"); - ciPtr->name->familyName.Set ("Smith"); - ciPtr->dateOfBirth.Set ("19570310"); - - ciPtr = pr.children->Append(); - ciPtr->name = new Name; - ciPtr->name->givenName.Set ("Lisa"); - ciPtr->name->initial.Set ("M"); - ciPtr->name->familyName.Set ("Smith"); - ciPtr->dateOfBirth.Set ("19610621"); - - - // set up buffer for writing to - outputBuf.Init (data, dataSize); - outputBuf.ResetInWriteRvsMode(); - - // encode the internal value we just build into the buffer - if (!pr.BEncPdu (outputBuf, encodedLen)) - cout << "failed encoding AnyTestType value" << endl; - - // open file to hold the BER value - outputFile.open ("pr.ber"); - if (!outputFile) - { - perror ("ofstream::open"); - exit (1); - } - - // copy the BER value from the buffer to the file - outputBuf.ResetInReadMode(); - for (; encodedLen > 0; encodedLen--) - outputFile.put (outputBuf.GetByte()); - - - cout << "Wrote the following BER PersonnelRecord value to pr.ber." << endl; - cout << "Test it with \"def\" and \"indef\"." << endl; - cout << pr << endl; - - return 0; -} diff --git a/SecuritySNACCRuntime/c++-examples/simple/good-pr.ber b/SecuritySNACCRuntime/c++-examples/simple/good-pr.ber deleted file mode 100644 index f8cc9410ed7be7741ca4c0e0805cce1fbee7df6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmYdj>`N37WAVz*$P;696=My~%`C}SARxvUl98(5l$oyJoROMZoEqQAz|7b-e<7DM zhoPl~k%6Is$s!?;M&HDuN-;(ssK&*PhVqGmVys??xv9lsj6pE-z}igB4U7#94CO%D Td@_p@#Tb22 foo.ber - ./def foo.ber > bar.ber - @if cmp -s bar.ber good-pr.ber; then\ - echo "+++ Passed simple encode/decode tests using p-rec.asn1.";\ - else\ - echo "--- Failed simple encode/decode tests using p-rec.asn1.";\ - fi - $(RM) foo.ber bar.ber - -clean:: - $(RM) *.o *~ .emacs* core def indef genber pr.ber $(ASN1HFILES) $(ASN1CFILES) - $(RM) -r def-obj indef-obj - $(RM) foo.ber bar.ber - -depend:: $(SNACC) - -include ../../maketail - -depend:: - cp dependencies deps - for dir in def-obj indef-obj; do\ - < dependencies sed -e 's:^\(.*\.o\):'"$$dir"'/\1:' >> deps;\ - done - mv deps dependencies diff --git a/SecuritySNACCRuntime/c++-examples/snmp/README b/SecuritySNACCRuntime/c++-examples/snmp/README deleted file mode 100644 index ba339191..00000000 --- a/SecuritySNACCRuntime/c++-examples/snmp/README +++ /dev/null @@ -1,132 +0,0 @@ -(RCS control information is at the end of this file.) - - -C++ SNMP Example - Mike Sample Mar 92 ---------------------------------- - -This example illustrates a few more features of the compiler than the -simple example. It also shows some deficiencies. No executable -programs are generated by the makefile, it only generates the snmp -code and compiles it without linking. - -This directory contains 2 files: - README - makefile - -Snacc generates source from the following ASN.1 files: - .../asn1specs/rfc1155-smi.asn1 - .../asn1specs/rfc1157-snmp.asn1 - .../asn1specs/rfc1213-mib2.asn1 - -multi-module compilation - The IMPORT/EXPORT mechanisms of ASN.1 '88 are supported so you don't - have to dump all of the ASN.1 definitions into a single file - The order of the ASN.1 file arguments is the order that they - are included in the generated source files. For example: - - %1 snacc rfc1155-smi.asn1 rfc1157-snmp.asn1 rfc1213-mib2.asn1 - - causes the order in which hdr files are included in rfc1213-mib2.C - to be: - - #include "asn-incl.h" - #include "rfc1155-smi.h" - #include "rfc1157-snmp.h" - #include "rfc1213-mib2.h" - - - Currently, snacc assumes that each ASN.1 file given on the command - line depends on all of the others on the command line. There is - no attempt to compute the dependencies via the import lists alone. - -SNMP OBJECT-TYPE macro parsing / ANY type hash table - The SNMP OBJECT-TYPE macro is parsed. This results in the - type in the "SYNTAX" part of the macro is put into - the ANY type hash table using the OBJECT-TYPE macro's value as the - hash key. Also if the type in the SYNTAX field is not defined - outsided of the macro (could be different tagging etc), a proper - type definition is generated for it. If you want to change the way - the macro is handled, modify the corresponding routine in "do_macros.c". - -value definitions - The OBJECT IDENTIFIER values are turned into statically initialized - C++ values and included in the generated source and include file. This - is also done for INTEGER and BOOLEAN values. More complex values - are ignored by the compiler at the moment. (modify parse_vals.c if - you want to improve this) - - --P option of snacc is demonstrated - The ASN.1 for the parsed modules is generated from the internal data - structure. This can be useful for making sure the compiler is - handling your ASN.1 files correctly. It is also useful to see how - the types are modified and sorted to simplify code generation. - (see the file snacc.output after typeing "make") - -Deficiencies - A deficiency in parsing large integers is shown when parsing the - following rfc 1155 types: - - Counter ::= - [APPLICATION 1] - IMPLICIT INTEGER (0..4294967295) - - Gauge ::= - [APPLICATION 2] - IMPLICIT INTEGER (0..4294967295) - - TimeTicks ::= - [APPLICATION 3] - IMPLICIT INTEGER (0..4294967295) - -Due the size of a C long int the above ASN.1 is represented internally as: - -Counter ::= [APPLICATION 1] IMPLICIT INTEGER (0..-1) - -Gauge ::= [APPLICATION 2] IMPLICIT INTEGER (0..-1) - -TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..-1) - -The ASN.1 library contains routines for encoding/decoding unsigned -long integers but you must hand code the cases where it is used - the -compiler never generates code that calls them. - -Note also that the produced code for the SNMP ASN.1 must be modified -to correclty handle the "Opaque" data type. SNMP does not use the ANY -DEFINED BY type in an effort to simplify things. Instead an OCTET -STRING is used to hold and encoded value whose type is defined by an -OBJECT IDENTIFIER. With some simple modifications you can use the -snacc AsnAnyDefinedBy type instead of the OCTET STRING to achieve -the desired results. - -This should underline the danger of blindly trusting the compiler to -do the right thing for protocols such as SNMP or X.500 where the type -of an encoded value depends on a mechanism outside of ASN.1 or the ANY -type (ANY DEFINED BY types should work automatically). - -There is a problem when generating C++ code with the SNMP ASN.1 files. -Several of the ASN.1 value names conflict with C++ keywords. The -generated code will not compile properly as a result. The best way to -fix these is to modify the ASN.1 files directly. The compiler will -munge field or type names to avoid conflicts with the target language -but currently does not check value names. The SNMP ASN.1 module shows -this problem the with value "private" in rfc1155-smi.asn1. - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/snmp/Attic/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:58 aram -# Originals from SMIME Free Library. -# -# Revision 1.3 1995/07/27 11:36:13 rj -# rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to accomodate to snacc's new file name generation scheme. -# -# Revision 1.2 1995/07/24 15:41:22 rj -# changed `_' to `-' in file names. -# -# Revision 1.1 1994/08/31 08:48:13 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# diff --git a/SecuritySNACCRuntime/c++-examples/snmp/makefile b/SecuritySNACCRuntime/c++-examples/snmp/makefile deleted file mode 100644 index 285a70ba..00000000 --- a/SecuritySNACCRuntime/c++-examples/snmp/makefile +++ /dev/null @@ -1,115 +0,0 @@ -# c++-examples/snmp/makefile -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/snmp/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.3 2000/12/22 00:03:17 dmitch -# Misc. updates for clean build on Cheetah 1D7. -# -# Revision 1.2 2000/06/08 19:59:20 dmitch -# Mods for X port. -# -# Revision 1.1.1.1 1999/03/16 18:05:58 aram -# Originals from SMIME Free Library. -# -# Revision 1.10 1997/02/16 16:48:08 rj -# made return *this after calling abort()'' a compile time option. -# -# Revision 1.9 1995/07/27 11:59:01 rj -# rfc1213-mib -> rfc1213-mib2 -# -# Revision 1.8 1995/07/27 08:29:58 rj -# rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to accomodate to snacc's new file name generation scheme. -# -# Revision 1.7 1995/07/24 15:30:11 rj -# `cd && make' instead of `cd; make'. -# -# changed `_' to `-' in file names. -# -# Revision 1.6 1995/02/20 11:48:41 rj -# build snacc if it doesn't exist. -# -# Revision 1.5 1995/02/13 14:58:15 rj -# augment CPPFLAGS, not overwrite -# -# Revision 1.4 1994/10/08 04:36:28 rj -# for the dependencies, generate the snacc compiler if it doesn't exist. -# -# Revision 1.3 1994/09/01 02:26:56 rj -# use CXX instead of CC to get another default linkage -# -# Revision 1.2 1994/08/31 23:25:41 rj -# print a less irritating usage. -# -# Revision 1.1 1994/08/31 08:48:14 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../../makehead - -TOP = ../.. - -ASN1_SPEC_DIR = $(TOP)/asn1specs - -ASN1_C++_LIB_DIR = $(TOP)/c++-lib -ASN1_C++_INC_DIR = $(ASN1_C++_LIB_DIR)/inc -ASN1_C++_LIB = $(ASN1_C++_LIB_DIR)/libasn1c++.a - -COMPILERDIR = $(TOP)/compiler -SNACC = $(COMPILERDIR)/snacc - -CC = $(CXX) -CPPFLAGS += -I$(TOP) -I$(ASN1_C++_INC_DIR) -F/System/Library/PrivateFrameworks - -ASN1FILES = \ - $(ASN1_SPEC_DIR)/rfc1155-smi.asn1 \ - $(ASN1_SPEC_DIR)/rfc1157-snmp.asn1 \ - $(ASN1_SPEC_DIR)/rfc1213-mib2.asn1 - -ASN1HFILES = \ - rfc1155-smi.h \ - rfc1213-mib2.h \ - rfc1157-snmp.h - -ASN1CFILES = \ - rfc1155-smi.cpp \ - rfc1213-mib2.cpp \ - rfc1157-snmp.cpp - -DISTFILES = \ - README \ - makefile \ - -#------------------------------------------------------------------------------- - -default:: warning - -warning:: - @echo '' - @echo 'read the README and enter `$(MAKE) fail` to test for yourself' - @echo '' - -fail:: $(ASN1HFILES) $(ASN1CFILES) - $(CXX) $(CPPFLAGS) $(CFLAGS) -c $(ASN1CFILES) - -$(ASN1HFILES) \ -$(ASN1CFILES): $(SNACC) $(ASN1FILES) - $(REASON) - $(SNACC) -P -C $(SNACC_NOVOLAT) $(ASN1FILES) > snacc.output~ - mv snacc.output~ snacc.output - -$(SNACC): - cd $(@D) && $(MAKE) $(@F) - -check:: - @echo "the purpose of this directories' contents is to show deficiencies." - @echo "if you want to exercise 'em, make the phony target "'`'"fail'" - -clean:: - $(RM) *.o *~ .emacs* core $(ASN1HFILES) $(ASN1CFILES) snacc.output - -depend:: $(SNACC) - -include ../../maketail diff --git a/SecuritySNACCRuntime/c++-examples/test-lib/README b/SecuritySNACCRuntime/c++-examples/test-lib/README deleted file mode 100644 index 8fe272fa..00000000 --- a/SecuritySNACCRuntime/c++-examples/test-lib/README +++ /dev/null @@ -1,43 +0,0 @@ -(RCS control information is at the end of this file.) - - -C++ test_lib README -------------------- - -This directory should have 3 files: - README - this file - makefile - test_lib.C - -Type "make" to compile test_lib. - -test_lib tests each encode and decode routine in the C++ ASN.1 -runtime library. Errors will be reported. - -test_lib should be run for each machine architecture you install snacc on. -If you modify the library routines you should run test_lib again. - -The general testing methodology is: - 1. test the buffer routines - 2. test tags - 3. test lengths - 4. test each libarary type. - -For each type, a range of values is encoded and then decoded -and and compared with the original value. - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/test-lib/Attic/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:58 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1997/02/16 20:25:29 rj -# check-in of a few cosmetic changes -# -# Revision 1.1 1994/08/31 08:48:16 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# diff --git a/SecuritySNACCRuntime/c++-examples/test-lib/makefile b/SecuritySNACCRuntime/c++-examples/test-lib/makefile deleted file mode 100644 index 13e2d05b..00000000 --- a/SecuritySNACCRuntime/c++-examples/test-lib/makefile +++ /dev/null @@ -1,68 +0,0 @@ -# c++-examples/test-lib/makefile -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/test-lib/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.2 2000/12/22 00:03:29 dmitch -# Misc. updates for clean build on Cheetah 1D7. -# -# Revision 1.1.1.1 1999/03/16 18:05:58 aram -# Originals from SMIME Free Library. -# -# Revision 1.7 1997/03/03 11:58:30 wan -# Final pre-delivery stuff (I hope). -# -# Revision 1.6 1997/02/28 13:39:41 wan -# Modifications collected for new version 1.3: Bug fixes, tk4.2. -# -# Revision 1.5 1995/07/24 15:31:14 rj -# changed `_' to `-' in file names. -# -# Revision 1.4 1995/02/13 14:58:17 rj -# augment CPPFLAGS, not overwrite -# -# Revision 1.3 1994/09/01 02:26:58 rj -# use CXX instead of CC to get another default linkage -# -# Revision 1.2 1994/08/31 21:44:25 rj -# rebuild the executables when the c++-lib is newer. -# -# Revision 1.1 1994/08/31 08:48:17 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../../makehead - -TOP = ../.. - -ASN1_C++_LIB_DIR = $(TOP)/c++-lib -ASN1_C++_INC_DIR = $(ASN1_C++_LIB_DIR)/inc -ASN1_C++_LIB = $(ASN1_C++_LIB_DIR)/libasn1c++.a - -CC = $(CXX) -CPPFLAGS += -I$(TOP) -I$(ASN1_C++_INC_DIR) -F/System/Library/PrivateFrameworks - -CFILES = \ - test-lib.C - -DISTFILES = \ - README \ - makefile \ - $(CFILES) - -#------------------------------------------------------------------------------- - -default:: check - -check:: test-lib - ./test-lib - -test-lib: $(ASN1_C++_LIB) test-lib.o - $(CXX) $(LDFLAGS) -o $@ test-lib.o $(ASN1_C++_LIB) $(LIBS) -lstdc++ - -clean:: - $(RM) *.o *~ .emacs* test-lib core - -include ../../maketail diff --git a/SecuritySNACCRuntime/c++-examples/test-lib/test-lib.C b/SecuritySNACCRuntime/c++-examples/test-lib/test-lib.C deleted file mode 100644 index 801a2166..00000000 --- a/SecuritySNACCRuntime/c++-examples/test-lib/test-lib.C +++ /dev/null @@ -1,815 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// c++_examples/test_lib/test_lib.C -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-examples/test-lib/Attic/test-lib.C,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -// $Log: test-lib.C,v $ -// Revision 1.1.1.1 2001/05/18 23:14:05 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/08 19:59:34 dmitch -// Mods for X port. -// -// Revision 1.1.1.1 1999/03/16 18:05:58 aram -// Originals from SMIME Free Library. -// -// Revision 1.5 1997/02/28 13:39:42 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.4 1995/07/24 15:44:10 rj -// #error "..." instead of #error ... -// -// changed `_' to `-' in file names. -// -// function and file names adjusted. -// -// Revision 1.3 1995/02/18 16:40:08 rj -// utilize either isinf(3) or finite(3), whatever happens to be present. -// -// Revision 1.2 1994/08/31 08:56:35 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -// - -#include -#include -#include "asn-incl.h" - - -int TestAsnBuffers(); -int TestAsnTag(); -int TestAsnLen(); -int TestAsnBool(); -int TestAsnInt(); -int TestAsnReal(); -int TestAsnOcts(); -int TestAsnBits(); -int TestAsnOid(); -int TestAsnList(); - -const int bufSize = 256; - -int main() -{ - int isErr = false; - - if (!TestAsnBuffers()) - { - cout << "Failed buffer tests, no point in proceeding ... bye!" << endl; - return 1; - } - - if (!TestAsnTag()) - { - cout << "Failed Tag test." << endl; - isErr = true; - } - - if (!TestAsnLen()) - { - cout << "Failed Length test." << endl; - isErr = true; - } - - if (!TestAsnBool()) - { - cout << "Failed BOOLEAN test." << endl; - isErr = true; - } - - - if (!TestAsnInt()) - { - cout << "Failed INTEGER test." << endl; - isErr = true; - } - - if (!TestAsnOcts()) - { - cout << "Failed OCTET STRING test." << endl; - isErr = true; - } - - - if (!TestAsnBits()) - { - cout << "Failed BIT STRING test." << endl; - isErr = true; - } - - - if (!TestAsnOid()) - { - cout << "Failed OBJECT IDENTIFIER test." << endl; - isErr = true; - } - - - if (!TestAsnReal()) - { - cout << "Failed REAL test." << endl; - isErr = true; - } - - - - if (isErr) - { - cout << "There are errors in the primitive type encoding/decoding" << endl; - cout << "library for this architecture. Time for gdb..." << endl; - } - else - { - cout << "The primitive type encoding/decoding library passed simple tests." << endl; - cout << "It should be safe to use..." << endl; - } - return isErr; -} - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnBuffers() -{ - AsnBuf b; - char bufData[256]; - int i,j; - int noErr = true; - - // initialize buffer - b.Init (bufData, 256); - b.ResetInWriteRvsMode(); - - // write whole range of byte (0..255) - // remember, write works in reverse - for (i = 0; i < 256; i++) - b.PutByteRvs (i); - - if (b.WriteError()) - { - cout << "Error writing to buffer." << endl; - noErr = false; - } - - // read in values & verify - b.ResetInReadMode(); - for (i = 255; i >= 0; i--) - if (b.GetByte() != i) - { - cout << "Error verifying data written to buffer." << endl; - noErr = false; - } - - if (b.ReadError()) - { - cout << "Error reading from buffer." << endl; - noErr = false; - } - - - /* now make sure errors are detected */ - b.ResetInWriteRvsMode(); - - for (i = 0; i < 257; i++) // write past end of buffer - b.PutByteRvs (0); - - if (!b.WriteError()) - { - cout << "Buffers failed to report buffer write overflow." << endl; - noErr = false; - } - - - b.ResetInReadMode(); - for (i = 256; i >= 0; i--) // read past end of buffer - b.GetByte(); - - if (!b.ReadError()) - { - cout << "Buffers failed to report buffer read overflow." << endl; - noErr = false; - } - - return noErr; -} /* TestAsnBuffers */ - - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnTag() -{ - AsnTag aTag1; - AsnTag aTag2; - int i, j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = true; - ENV_TYPE env; - AsnBuf b; - char bufData[256]; - long int val; - BER_CLASS tagClass; - BER_FORM form; - BER_UNIV_CODE code; - - - /* initialize buffer */ - b.Init (bufData, 256); - - /* encode a TRUE value and verify */ - tagClass = UNIV; - form = PRIM; - code = INTEGER_TAG_CODE; - aTag1 = MAKE_TAG_ID (tagClass, form, code); - - for (i = 0; i < 2; i++) - { - b.ResetInWriteRvsMode(); - len1 = BEncTag1 (b, tagClass, form, code); - - if (b.WriteError()) - { - noErr = false; - cout << "Error encoding a Tag." << endl; - } - - b.ResetInReadMode(); - - aTag2 = 0; - - /* make sure no decode errors and that it decodes to same tag */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - aTag2 = BDecTag (b, len2, env); - } - else - { - noErr = false; - cout << "Error decoding a Tag - error number " << val << endl; - } - if (noErr && ((aTag2 != aTag1) || (len1 != len2))) - { - noErr = false; - cout << "Error decoded Tag does not match encoded Tag." << endl; - } - /* set a new test tag value */ - tagClass = CNTX; - form = CONS; - code = (BER_UNIV_CODE) 29; - aTag1 = MAKE_TAG_ID (tagClass, form, code); - } - return noErr; -} /* TestAsnTag */ - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnLen() -{ - AsnLen aLen1; - AsnLen aLen2; - int i,j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = true; - ENV_TYPE env; - AsnBuf b; - char bufData[256]; - long int val; - - /* initialize buffer */ - b.Init (bufData, 256); - - - /* encode a TRUE value and verify */ - aLen1 = 99999; - for (i = 0; i < 2; i++) - { - b.ResetInWriteRvsMode(); - len1 = BEncDefLen (b, aLen1); - - if (b.WriteError()) - { - noErr = false; - cout << "Error encoding Length." << endl; - } - - b.ResetInReadMode(); - - aLen2 = 0; - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - aLen2 = BDecLen (b, len2, env); - } - else - { - noErr = false; - cout << "Error decoding Length - error number " << val << endl; - } - - - if (noErr && ((aLen2 != aLen1) || (len1 != len2))) - { - noErr = false; - cout << "Error - decoded length does not match encoded length" << endl; - } - aLen1 = 2; - } - - - /* test indef len */ - b.ResetInWriteRvsMode(); - len1 = BEncIndefLen (b); - - if (b.WriteError()) - { - noErr = false; - cout << "Error encoding indefinite Length." << endl; - } - - b.ResetInReadMode(); - - aLen2 = 0; - - /* make sure no decode errors */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - aLen2 = BDecLen (b, len2, env); - } - else - { - noErr = false; - cout << "Error decoding Length - error number " << val << endl; - } - - - if (noErr && ((aLen2 != INDEFINITE_LEN) || (len1 != len2))) - { - noErr = false; - cout << "Error - decoded length does not match encoded length" << endl; - } - - /* test EOC */ - b.ResetInWriteRvsMode(); - len1 = BEncEoc (b); - - if (b.WriteError()) - { - noErr = false; - cout << "Error encoding indefinite Length." << endl; - } - - b.ResetInReadMode(); - - aLen2 = 0; - - /* make sure no decode errors */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecEoc (b, len2, env); - } - else - { - noErr = false; - cout << "Error decoding Length - error number " << val << endl; - } - - - if (noErr && (len1 != len2)) - { - noErr = false; - cout << "Error - decoded EOC length error" << endl; - } - - return noErr; -} /* TestAsnLen */ - - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnBool() -{ - AsnBuf b; - char bufData[bufSize]; - AsnBool aBool1; - AsnBool aBool2; - int j; - AsnLen len1; - AsnLen len2; - int noErr = true; - - // initialize a small buffer - b.Init (bufData, bufSize); - b.ResetInWriteRvsMode(); - - // encode a true value and verify - aBool1 = true; - - if (!aBool1.BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding TRUE BOOLEAN value." << endl; - } - - b.ResetInReadMode(); - - aBool2 = false; // set to opposite of expected value - - // make sure no decode errors and that it decodes to true - if (!aBool2.BDecPdu (b, len2) || !aBool2 || (len1 != len2)) - { - noErr = false; - cout << "Error decoding TRUE BOOLEAN value." << endl; - } - - // now encode a false value and verify - b.ResetInWriteRvsMode(); - aBool1 = false; - - if (!aBool1.BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding FALSE BOOLEAN value." << endl; - } - - b.ResetInReadMode(); - - aBool2 = true; // set to opposite of expected value - - // make sure no decode errors and that it decodes to false - if (!aBool2.BDecPdu (b, len2) || aBool2 || (len1 != len2)) - { - noErr = false; - cout << "Error decoding FALSE BOOLEAN value." << endl; - } - - return noErr; -} /* TestAsnBool */ - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnInt() -{ - AsnBuf b; - char bufData[bufSize]; - AsnInt a1; - AsnInt a2; - int i,j, sign; - AsnLen len1; - AsnLen len2; - int noErr = true; - - // initialize a small buffer - b.Init (bufData, bufSize); - - // - // Encode a range of integers: negative & positive in - // the 1 to sizeof (long int) range - // - - sign = 1; - for (j = 0; j < 2; j++) - { - for (i = 0; i < sizeof (long int); i++) - { - b.ResetInWriteRvsMode(); - - a1 = sign * (17 << (i * 8)); // 17 is a random choice - if (!a1.BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding INTEGER value " << a1 << "." << endl; - } - - b.ResetInReadMode(); - a2 = 0; - - // make sure no decode errors and that it decodes to the correc val - if (!a2.BDecPdu (b, len2) || (a2 != a1) || (len1 != len2)) - { - noErr = false; - cout << "Error decoding INTEGER value " << a1 << "." << endl; - } - } - sign = -1; - } - - return noErr; - -} /* TestAsnInt */ - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnOcts() -{ - AsnBuf b; - char bufData[bufSize]; - AsnOcts a1; - AsnOcts a2; - int i,j; - AsnLen len1; - AsnLen len2; - int noErr = true; - - // initialize a small buffer - b.Init (bufData, bufSize); - - a1 = "Hello Gumby?"; - for (j = 0; j < 2; j++) - { - b.ResetInWriteRvsMode(); - - if (!a1.BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding OCTET STRING value " << a1 << "." << endl; - } - - b.ResetInReadMode(); - - // make sure no decode errors and that it decodes to the correc val - if (!a2.BDecPdu (b, len2) || (a2 != a1) || (len1 != len2)) - { - noErr = false; - cout << "Error decoding OCTET STRING value " << a1 << "." << endl; - } - a1 = ""; // try an empty string - } - - return noErr; - -} /* TestAsnOcts */ - - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnBits() -{ - AsnBuf b; - char bufData[bufSize]; - AsnBits a1 (32); - AsnBits a2 (32); - short bitsToSet[32] = { 0, 1, 0, 0, 1, 1, 0, 1, - 0, 1, 0, 0, 1, 1, 0, 1, - 0, 1, 0, 0, 1, 1, 0, 1, - 0, 1, 0, 0, 1, 1, 0, 1 }; - int i,j; - AsnLen len1; - AsnLen len2; - int noErr = true; - - // initialize a small buffer - b.Init (bufData, bufSize); - - - // set some bits - for (i = 0; i < 32; i++) - { - if (bitsToSet[i]) - a1.SetBit (i); - else - a1.ClrBit (i); - - } - - b.ResetInWriteRvsMode(); - if (!a1.BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding BIT STRING value " << a1 << "." << endl; - } - - b.ResetInReadMode(); - - // make sure no decode errors and that it decodes to the correc val - if (!a2.BDecPdu (b, len2) || (a2 != a1) || (len1 != len2)) - { - noErr = false; - cout << "Error decoding BIT STRING value " << a1 << "." << endl; - } - - - return noErr; - -} /* TestAsnBits */ - - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnOid() -{ - AsnBuf b; - char bufData[bufSize]; - AsnOid a1 (0,1,2,3,4,5,6); - AsnOid a2; - AsnOid a3 (2,38,29,40,200,10,4000); - int i,j; - AsnLen len1; - AsnLen len2; - int noErr = true; - - // initialize a small buffer - b.Init (bufData, bufSize); - - for (i = 0; i < 2; i++) - { - b.ResetInWriteRvsMode(); - - if (!a1.BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding OBJECT IDENTIFIER value " << a1 << "." << endl; - } - - b.ResetInReadMode(); - - // make sure no decode errors and that it decodes to the correc val - if (!a2.BDecPdu (b, len2) || (a2 != a1) || (len1 != len2)) - { - noErr = false; - cout << "Error decoding OBJECT IDENTIFIER value " << a1 << "." << endl; - } - - a1 = a3; - } - return noErr; - -} /* TestAsnOid */ - -/* - * returns true if passes encode/decode tests - * - * NOT USED - nuked template design. - */ -/* -int -TestAsnList() -{ - AsnBuf b; - char bufData[bufSize]; - AsnList intList1; - AsnList intList2; - AsnList boolList1; - AsnList boolList2; - int i,j; - AsnLen len1; - AsnLen len2; - int noErr = true; - - b.Init (bufData, bufSize); - - b.ResetInWriteRvsMode(); - - if (!intList1.BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding SEQUENCE OF value " << intList1 << "." << endl; - } - - b.ResetInReadMode(); - - if (!intList2.BDecPdu (b, len2) || (len1 != len2)) - { - noErr = false; - cout << "Error decoding SEQUENCE OF value " << intList1 << "." << endl; - } - cout << "intlist 1 = " << intList1 << endl; - cout << "intlist 2 = " << intList1 << endl; - - - if (!boolList1.BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding SEQUENCE OF value " << boolList1 << "." << endl; - } - - b.ResetInReadMode(); - - if (!boolList2.BDecPdu (b, len2) || (len1 != len2)) - { - noErr = false; - cout << "Error decoding SEQUENCE OF value " << boolList1 << "." << endl; - } - cout << "boolList 1 = " << boolList1 << endl; - cout << "boolList 2 = " << boolList1 << endl; - - return noErr; - -} TestAsnList */ - - - -/* - * returns true if passes encode/decode tests - */ -int -TestAsnReal() -{ -#ifdef __APPLE__ - /* we don't seem to have any of this stuff */ - return true; -#else - AsnBuf b; - char bufData[bufSize]; - AsnReal a2; - AsnReal a[] = { 0.0, 0.8, -22.484848, PLUS_INFINITY, MINUS_INFINITY}; - int i,j; - AsnLen len1; - AsnLen len2; - int noErr = true; - - - /* - * if you do not have the ieee_functions in your math lib, - * this will not link. Comment it out and cross you fingers. - * (or check/set the +/-infinity values for you architecture) - */ -#if HAVE_ISINF - if (!isinf ((double)PLUS_INFINITY)) || !isinf ((double)MINUS_INFINITY)) -#else -#if HAVE_FINITE - if (finite ((double)PLUS_INFINITY) || finite ((double)MINUS_INFINITY)) -#else - #error "oops: you've got neither isinf(3) nor finite(3)?!" -#endif -#endif - { - cout << "WARNING: PLUS_INFINITY and MINUS_INFINITY in .../c++-lib/src/asn-real.C are" << endl; - cout << "not correct for this architecture. Modify the AsnPlusInfinity() routine." << endl; - } - - - // initialize a small buffer - b.Init (bufData, bufSize); - - for (i = 0; i < 5; i++) - { - b.ResetInWriteRvsMode(); - - if (!a[i].BEncPdu (b, len1)) - { - noErr = false; - cout << "Error encoding REAL value " << a[i] << "." << endl; - } - - b.ResetInReadMode(); - - // make sure no decode errors and that it decodes to the correc val - if (!a2.BDecPdu (b, len2) || (a2 != a[i]) || (len1 != len2)) - { - noErr = false; - cout << "Error decoding REAL value " << a[i] << "." << endl; - } - } - - return noErr; -#endif -} /* TestAsnReal */ diff --git a/SecuritySNACCRuntime/c++-lib/README b/SecuritySNACCRuntime/c++-lib/README deleted file mode 100644 index 5cb78e8a..00000000 --- a/SecuritySNACCRuntime/c++-lib/README +++ /dev/null @@ -1,34 +0,0 @@ -(RCS control information is at the end of this file.) - - -C++ ASN.1 library README ------------------------- - -This directory contains the class definitions and the encode, decode, -free and print methods for all of the built-in ASN.1 types. It also -contains buffer routines. - -The makefile will produce one or two libraries, libasn1c++.a and -libasn1tcl.a. -Whether the tcl library is to be generated or not is determined at -configuration time. - -In addition to the normal C++ libraries contents, the Tcl library -contains the meta code and the Tcl interface described in the -documentation. - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/Attic/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:59 aram -# Originals from SMIME Free Library. -# -# Revision 1.3 1995/07/24 15:45:53 rj -# mention meta code and tcl interface and their additional libary. -# -# Revision 1.2 1994/09/01 00:55:55 rj -# textual change to adapt to change of directory tree. -# diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-any.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-any.cpp deleted file mode 100644 index c629bd5e..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-any.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-any.C -// -// MS 92 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// -// ------------------------------------------------------------------------ -// - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 - -// ------------------------------------------------------------------------ -// -// All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's -// SCCS. The revision #'s start at 1.1, which is the original version from -// SNACC 1.3. -// -// -// ../SCCS/s.asn-any.C: -// -// D 1.2 98/05/01 13:47:09 pleonber 2 1 00046/00007/00164 -// added destructor and copy for CSM_Buffer handling. -// -// D 1.1 98/05/01 13:19:19 pleonber 1 0 00171/00000/00000 -// date and time created 98/05/01 13:19:19 by pleonber -// -// ----------------------- End of VDA Modifications --------------------------- -// -// -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-any.cpp,v 1.4 2002/03/21 05:38:44 dmitch Exp $ -// $Log: asn-any.cpp,v $ -// Revision 1.4 2002/03/21 05:38:44 dmitch -// Radar 2868524: no more setjmp/longjmp in SNACC-generated code. -// -// Revision 1.3.44.1 2002/03/20 00:36:48 dmitch -// Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. -// -// Revision 1.3 2001/06/27 23:09:14 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.2 2001/06/25 22:44:17 dmitch -// Globalize hashTblLock with a ModuleNexus. Partial fix for Radar 2664258. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.6 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.5 2000/12/20 00:51:37 dmitch -// Cosmetic changwe to resync with ../c++/asn-any.cpp. -// -// Revision 1.4 2000/12/20 00:43:14 dmitch -// Acquire and release hashTblLock via an StLock. -// -// Revision 1.3 2000/12/07 22:32:03 dmitch -// Thread-safe mods: see comments for same file in ../c++/. -// -// Revision 1.2 2000/12/07 22:13:45 dmitch -// Thread-safe mods: added hashTblLock. -// -// Revision 1.1 2000/06/15 18:44:59 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:37 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.5 1999/03/21 02:07:35 mb -// Added Copy to every AsnType. -// -// Revision 1.4 1999/03/19 23:59:21 mb -// Invoke Print on our value since CSM_Buffer::Print now implements print too. -// -// Revision 1.3 1999/03/19 00:55:01 mb -// Made CSM_Buffer a subclass of AsnType. -// -// Revision 1.2 1999/03/18 22:35:28 mb -// Made all destructors virtual. -// -// Revision 1.1 1999/02/25 05:21:49 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/28 13:39:43 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.5 1997/02/16 20:26:01 rj -// check-in of a few cosmetic changes -// -// Revision 1.4 1995/07/24 20:12:48 rj -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:20 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:10 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:55 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-incl.h" -#include "sm_vdasnacc.h" - -//#include "asn-config.h" -//#include "asn-len.h" -//#include "asn-tag.h" -//#include "asn-type.h" -//#include "asn-oid.h" -//#include "asn-int.h" -//#include "asn-any.h" - - -#ifdef __APPLE__ -#include -#include -Table *AsnAny::oidHashTbl = NULL; -Table *AsnAny::intHashTbl = NULL; -ModuleNexus hashTblLock; -#endif - -// Define this ANY value's type to the one that the given id hashes -// to in the ANY table. -void -AsnAny::SetTypeByInt (AsnInt id) -{ - Hash hash; - void *anyInfo; - - /* use int as hash string */ - AsnIntType idval = (AsnIntType) id; - hash = MakeHash ((char*)&idval, sizeof (idval)); - #ifdef __APPLE__ - StLock _(hashTblLock()); - #endif - if (CheckForAndReturnValue (intHashTbl, hash, &anyInfo)) - ai = (AnyInfo*) anyInfo; - else - ai = NULL; /* indicates failure */ - -} /* SetAnyTypeByInt */ - -// Define this ANY value's type to the one that the given id hashes -// to in the ANY table. -void AsnAny::SetTypeByOid (AsnOid &id) -{ - Hash hash; - void *anyInfo; - - /* use encoded oid as hash string */ - hash = MakeHash (id.Str(), id.Len()); - - #ifdef __APPLE__ - StLock _(hashTblLock()); - #endif - - if (CheckForAndReturnValue (oidHashTbl, hash, &anyInfo)) - ai = (AnyInfo*) anyInfo; - else - ai = NULL; /* indicates failure */ - -} /* SetAnyTypeByOid */ - - - -// Given an integer, intId, to hash on, the type and it's anyId -// are installed in the integer id hash tbl -void -AsnAny::InstallAnyByInt (AsnInt intId, int anyId, AsnType *type) -{ - AnyInfo *a; - Hash h; - - a = new AnyInfo; - // Oid will be NULL and 0 len by default constructor - a->anyId = anyId; - a->intId = intId; - a->typeToClone = type; - - #ifdef __APPLE__ - StLock _(hashTblLock()); - #endif - if (AsnAny::intHashTbl == NULL) - AsnAny::intHashTbl = InitHash(); - - AsnIntType idval = (AsnIntType) intId; - h = MakeHash ((char*)&idval, sizeof (idval)); - Insert (AsnAny::intHashTbl, a, h); - -} /* InstallAnyByInt */ - - -// given an OBJECT IDENTIFIER, oid, to hash on, the type and it's anyId -// are installed in the OBJECT IDENTIFIER id hash tbl -void -AsnAny::InstallAnyByOid (AsnOid &oid, int anyId, AsnType *type) -{ - AnyInfo *a; - Hash h; - - a = new AnyInfo; - a->anyId = anyId; - a->oid = oid; // copy given oid - a->typeToClone = type; - - h = MakeHash (oid.Str(), oid.Len()); - - #ifdef __APPLE__ - StLock _(hashTblLock()); - #endif - if (AsnAny::oidHashTbl == NULL) - AsnAny::oidHashTbl = InitHash(); - - Insert (AsnAny::oidHashTbl, a, h); -} /* InstallAnyByOid */ - - -AsnType *AsnAny::Clone() const -{ - return new AsnAny; -} - -AsnType *AsnAny::Copy() const -{ - return new AsnAny (*this); -} - - -// -// if you haven't set up the value properly -// this will croak (since it's a programming error -// - ie, you didn't initialize the data structure properly -// -AsnLen -AsnAny::BEnc (BUF_TYPE b) -{ - return value->BEnc (b); -} - - - -void -AsnAny::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - if (ai == NULL) - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-81); - #else - longjmp (env, -81); - #endif - - // XXX This is wrong. - value = static_cast(ai->typeToClone->Clone()); - - if (value == NULL) - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-82); - #else - longjmp (env, -82); - #endif - else - value->BDec (b, bytesDecoded, env); -} - - -void AsnAny::Print (ostream &os) const -{ -#ifndef NDEBUG - value->Print(os); -#endif -} - -#ifdef VDADER_RULES - -AsnAny::~AsnAny() -{ - delete this->value; -} - -AsnAny &AsnAny::operator = (const AsnAny &o) -{ - if (this->ai) // take care of most copies. - delete this->ai; - this->ai = NULL; - if (o.ai) - { - this->ai = new AnyInfo; - *this->ai = *o.ai; - } - /* __APPLE__ - I don't think this needs a lock since it's - * not modifying the hash tables */ - if (o.intHashTbl) - { - this->intHashTbl = o.intHashTbl; // same pointer. - } - if (o.oidHashTbl) - { - this->oidHashTbl = o.oidHashTbl; - } - - if (o.value) - this->value = static_cast(o.value->Copy()); - - return *this; -} - -#endif - diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-bits.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-bits.cpp deleted file mode 100644 index 7e4b0a44..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-bits.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-bits.C - AsnBits (ASN.1 BIT STRING) Type -// -// Mike Sample -// 92/07/02 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-bits.cpp,v 1.4 2002/03/21 05:38:44 dmitch Exp $ -// $Log: asn-bits.cpp,v $ -// Revision 1.4 2002/03/21 05:38:44 dmitch -// Radar 2868524: no more setjmp/longjmp in SNACC-generated code. -// -// Revision 1.3.44.1 2002/03/20 00:36:48 dmitch -// Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. -// -// Revision 1.3 2001/06/28 23:36:11 dmitch -// Removed SccsId statics. numToHexCharTblG table now const. Radar 2705410. -// -// Revision 1.2 2001/06/27 23:09:14 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.1.1.1 2001/05/18 23:14:05 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/12/07 22:15:49 dmitch -// Thread-safe mods: added a local StrStk strStkG to the routines which need it. -// -// Revision 1.1 2000/06/15 18:44:57 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:34 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.3 1999/03/21 02:07:35 mb -// Added Copy to every AsnType. -// -// Revision 1.2 1999/02/26 00:23:39 mb -// Fixed for Mac OS 8 -// -// Revision 1.1 1999/02/25 05:21:50 mb -// Added snacc c++ library -// -// Revision 1.9 1997/08/27 15:55:15 wan -// GetBit now returns 0 or 1, not 0 or <#bit>, even if bool type is emulated. -// -// Revision 1.8 1997/02/28 13:39:44 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.7 1997/01/01 20:19:01 rj -// dereferencing pointer to member function is neither necessary nor allowed -// -// Revision 1.6 1995/08/17 15:37:49 rj -// set Tcl's errorCode variable -// -// Revision 1.5 1995/07/24 20:09:07 rj -// use memzero that is defined in .../snacc.h to use either memset or bzero. -// use memcmpeq that is defined in .../snacc.h to use either memcmp or bcmp. -// -// call constructor with additional pdu and create arguments. -// -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// Revision 1.4 1994/10/08 04:18:21 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.3 1994/08/31 23:37:57 rj -// TRUE turned into true -// -// Revision 1.2 1994/08/28 10:01:11 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:57 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-type.h" -#include "asn-bits.h" -#include "str-stk.h" - -#ifndef __APPLE__ - -/* OS X - thread safe - the only routine which uses this allocates - * it on the stack */ -extern StrStk strStkG; -unsigned short int strStkUnusedBitsG; -#endif /* __APPLE__ */ - -const -char numToHexCharTblG[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - -AsnBits::~AsnBits() -{ - delete bits; -} - -AsnType *AsnBits::Clone() const -{ - return new AsnBits; -} - -AsnType *AsnBits::Copy() const -{ - return new AsnBits (*this); -} - -// Initializes the bits string with a bit string numBits in length. -// All bits are zeroed. -void AsnBits::Set (size_t numBits) -{ - bitLen = numBits; - size_t octetLen = (bitLen+7)/8; - -#ifndef _IBM_ENC_ - bits = Asn1Alloc (octetLen); -#else - bits = (char *) mem_mgr_ptr->Get (octetLen); // Guido Grassel, 11.8.93 -#endif /* _IBM_ENC_ */ - memzero (bits, octetLen); // init to zeros -} - -// initializes a BIT STRING with the given string and bit length -// Copies the bits from bitsOcts. -void AsnBits::Set (const char *bitOcts, size_t numBits) -{ - if (bitOcts != bits) - { - bitLen = numBits; - size_t octetLen = (bitLen+7)/8; -#ifndef _IBM_ENC_ - bits = new char[octetLen]; -#else - bits = (char *) mem_mgr_ptr->Get (octetLen); // Guido Grassel, 11.8.93 -#endif /* _IBM_ENC_ */ - memcpy (bits, bitOcts, octetLen); - } -} - -// initializes a BIT STRING by copying another BIT STRING's bits -void AsnBits::Set (const AsnBits &b) -{ - if (&b != this) - { - bitLen = b.bitLen; - size_t octetLen = (bitLen+7)/8; -#ifndef _IBM_ENC_ - bits = new char[octetLen]; -#else - bits = (char *) mem_mgr_ptr->Get (octetLen); // Guido Grassel, 11.8.93 -#endif /* _IBM_ENC_ */ - memcpy (bits, b.bits, octetLen); - } -} - -// Initializes the bits string with a bit string numBits in length. -// All bits are zeroed. -void AsnBits::ReSet (size_t numBits) -{ -#ifndef _IBM_ENC_ - delete bits; - Set (numBits); -#else - mem_mgr_ptr->Put ((void *) bits); // Guido Grassel, 11.8.93 - Set (numBits); -#endif /* _IBM_ENC_ */ -} - -// frees old bits value and then re-initializes the -// BIT STRING with the given string and bit length -// Copies the bitOcts into bits. -void AsnBits::ReSet (const char *bitOcts, size_t numBits) -{ - if (bitOcts != bits) - { -#ifndef _IBM_ENC_ - delete bits; - Set (bitOcts, numBits); -#else - mem_mgr_ptr->Put ((void *) bits); // Guido Grassel, 11.8.93 - Set (bitOcts, numBits); -#endif /* _IBM_ENC_ */ - } -} - -// frees old bits value and then re-initializes the -// BIT STRING by copying another BIT STRING's bits -void AsnBits::ReSet (const AsnBits &b) -{ - if (&b != this) // avoid b = b; probs - { -#ifndef _IBM_ENC_ - delete bits; - Set (b); -#else - mem_mgr_ptr->Put ((void *) bits); // Guido Grassel, 11.8.93 - Set (b); -#endif /* _IBM_ENC_ */ - } -} - - -// Returns true if the given BIT STRING is the same as this one -bool AsnBits::BitsEquiv (const AsnBits &ab) const -{ - size_t octetsLessOne = (bitLen-1)/8; - size_t octetBits = 7 - (bitLen % 8); - - if (!bitLen && !ab.bitLen) - return true; - - // trailing bits may not be significant - return bitLen == ab.bitLen - && !memcmpeq (bits, ab.bits, octetsLessOne) - && (bits[octetsLessOne] & (0xFF << octetBits)) == (ab.bits[octetsLessOne] & (0xFF << octetBits)); -} /* AsnBits::BitsEquiv */ - - -// set given bit to 1. Most signif. bit is bit 0, least signif bit is bitLen-1 -void AsnBits::SetBit (size_t bit) -{ - if (bit < bitLen) - { - size_t octet = bit/8; - size_t octetsBit = 7 - (bit % 8); // bit zero is first/most sig bit in octet - bits[octet] |= 1 << octetsBit; - } -#ifdef DEBUG - else - Asn1Errror << "AsnBits::SetBit: ERROR - bit larger than bit string" << endl; -#endif -} /* AsnBits::SetBit */ - -// Clr bit. Most signif. bit is bit 0, least signif bit is bitLen-1 -void AsnBits::ClrBit (size_t bit) -{ - if (bit < bitLen) - { - size_t octet = bit/8; - size_t octetsBit = 7 - (bit % 8); // bit zero is first/most sig bit in octet - bits[octet] &= ~(1 << octetsBit); - } -#ifdef DEBUG - else - Asn1Errror << "AsnBits::ClrBit: ERROR - bit larger than bit string" << endl; -#endif -} /* AsnBits::ClrBit */ - -// returns given bit. Most signif. bit is bit 0, least signif bit is bitLen-1. -// Returns false if the givnen bit index is out of range. -bool AsnBits::GetBit (size_t bit) const -{ - if (bit < bitLen) - { - size_t octet = bit/8; - size_t octetsBit = 7 - (bit % 8); // bit zero is first/most sig bit in octet - return !!(bits[octet] & (1 << octetsBit)); - } -#ifdef DEBUG - else - Asn1Errror << "AsnBits::GetBit: ERROR - bit larger than bit string" << endl; -#endif - - return false; -} /* AsnBits::GetBit */ - - -// Encoded the content (included unused bits octet) of the BIT STRING -// to the given buffer. -AsnLen AsnBits::BEncContent (BUF_TYPE b) -{ - size_t byteLen = (bitLen+7)/8; - b.PutSegRvs (bits, byteLen); - - size_t unusedBits = (bitLen % 8); - if (unusedBits != 0) - unusedBits = 8 - unusedBits; - b.PutByteRvs (unusedBits); - - return byteLen + 1; - -} /* AsnBits::BEncContent */ - - -// Decodes a BER BIT STRING from the given buffer and stores -// the value in this object. -void AsnBits::BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env) -{ -// char *tmp; - - /* - * tagId is encoded tag shifted into long int. - * if CONS bit is set then constructed bit string - */ - if (tagId & 0x20000000) - BDecConsBits (b, elmtLen, bytesDecoded, env); - - else /* primitive octet string */ - { - bytesDecoded += elmtLen; - elmtLen--; - bitLen = (elmtLen * 8) - (unsigned int)b.GetByte(); -#ifndef _IBM_ENC_ - bits = Asn1Alloc (elmtLen); -#else - bits = (char *) mem_mgr_ptr->Get (elmtLen); // Guido Grassel, 11.8.93 -#endif /* _IBM_ENC_ */ - b.CopyOut (bits, elmtLen); - if (b.ReadError()) - { - Asn1Error << "BDecBitString: ERROR - decoded past end of data" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-1); - #else - longjmp (env, -1); - #endif - } - } - -} /* AsnBits::BDecContent */ - -AsnLen AsnBits::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - return l; -} - -void AsnBits::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - tag = BDecTag (b, bytesDecoded, env); - if ((tag != MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - Asn1Error << "AsnBits::BDec: ERROR tag on BIT STRING is wrong." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-50); - #else - longjmp (env,-50); - #endif - } - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -/* - * Used to concatentate constructed bit strings when decoding. - * - * fills string stack with references to the pieces of a - * construced bit string. sets strStkUnusedBitsG appropriately. - * and strStkTotalByteLenG to bytelen needed to hold the bitstring - */ -#ifdef __APPLE__ -void AsnBits::FillBitStringStk (BUF_TYPE b, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env, - StrStk &strStkG, - unsigned short int &strStkUnusedBitsG) -#else -void AsnBits::FillBitStringStk (BUF_TYPE b, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env) -#endif -{ - size_t refdLen; - size_t totalRefdLen; - char *strPtr; - AsnLen totalElmtsLen1 = 0; - unsigned long int tagId1; - AsnLen elmtLen1; - size_t lenToRef; -// size_t unusedBits; - - for (; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN); ) - { - tagId1 = BDecTag (b, totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, totalElmtsLen1, env); - break; - } - - elmtLen1 = BDecLen (b, totalElmtsLen1, env); - if (tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - { - /* - * primitive part of string, put references to piece (s) in - * str stack - */ - - /* - * get unused bits octet - */ - if (strStkUnusedBitsG != 0) - { - /* - * whoa - only allowed non-octed aligned bits on - * on last piece of bits string - */ - Asn1Error << "BDecConsBitString: ERROR - a component of a constructed BIT STRING that is not the last has non-zero unused bits" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-2); - #else - longjmp (env, -2); - #endif - } - - if (elmtLen1 != 0) - strStkUnusedBitsG = b.GetByte(); - - totalRefdLen = 0; - lenToRef =elmtLen1-1; /* remove one octet for the unused bits oct*/ - refdLen = lenToRef; - while (1) - { - strPtr = b.GetSeg (&refdLen); - - strStkG.Push (strPtr, refdLen); - totalRefdLen += refdLen; - if (totalRefdLen == lenToRef) - break; /* exit this while loop */ - - if (refdLen == 0) /* end of data */ - { - Asn1Error << "BDecConsOctetString: ERROR - expecting more data" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-3); - #else - longjmp (env, -3); - #endif - } - refdLen = lenToRef - totalRefdLen; - } - totalElmtsLen1 += elmtLen1; - } - - - else if (tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)) - { - /* - * constructed octets string embedding in this constructed - * octet string. decode it. - */ - FillBitStringStk (b, elmtLen1, totalElmtsLen1, env - #ifdef __APPLE__ - , strStkG, strStkUnusedBitsG - #endif - ); - } - else /* wrong tag */ - { - Asn1Error << "BDecConsBitString: ERROR - decoded non-BIT STRING tag inside a constructed BIT STRING" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-4); - #else - longjmp (env, -4); - #endif - } - } /* end of for */ - - bytesDecoded += totalElmtsLen1; -} /* FillBitStringStk */ - - -/* - * decodes a seq of universally tagged bits until either EOC is - * encountered or the given len decoded. Return them in a - * single concatenated bit string - */ -void AsnBits::BDecConsBits (BUF_TYPE b, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env) -{ - #ifdef __APPLE__ - StrStk strStkG(128, 64); - unsigned short int strStkUnusedBitsG; - #endif - strStkG.Reset(); - strStkUnusedBitsG = 0; - - /* - * decode each piece of the octet string, puting - * an entry in the octet/bit string stack for each - */ - FillBitStringStk (b, elmtLen, bytesDecoded, env, strStkG, - strStkUnusedBitsG); - - /* alloc single str long enough for combined bitstring */ - bitLen = strStkG.totalByteLen*8 - strStkUnusedBitsG; - -#ifndef _IBM_ENC_ - bits = Asn1Alloc (strStkG.totalByteLen); -#else - bits = (char *) mem_mgr_ptr->Get (strStkG.totalByteLen); // Guido Grassel, 11.8.93 -#endif /* _IBM_ENC_ */ - - strStkG.CopyOut (bits); - -} /* BDecConsBits */ - -// prints the BIT STRING to the given ostream. -void AsnBits::Print (ostream &os) const -{ -#ifndef NDEBUG - size_t octetLen = (bitLen+7)/8; - - os << "'"; - for (unsigned i = 0; i < octetLen; i++) - os << TO_HEX (bits[i] >> 4) << (TO_HEX (bits[i])); - os << "'H -- BIT STRING bitlen = " << bitLen << " --"; -#endif /* NDEBUG */ -} - -#if META - -const AsnBitsTypeDesc AsnBits::_desc (NULL, NULL, false, AsnTypeDesc::BIT_STRING, NULL, NULL); - -const AsnTypeDesc *AsnBits::_getdesc() const -{ - return &_desc; -} - -#if TCL - -int AsnBits::TclGetVal (Tcl_Interp *interp) const -{ - Tcl_ResetResult(interp); - for (int i=0; igetmodule()->name, ".", _getdesc()->getname(), NULL); - Tcl_SetErrorCode (interp, "SNACC", "ILLBIT", NULL); - return TCL_ERROR; - } - - ReSet (i); - - for (i=0, p=valstr; igetnames(); - if (n) - { - for (; n->name; n++) - if (n->value == value) - { - Tcl_SetResult (interp, (char*)n->name, TCL_STATIC); - return TCL_OK; - } - } - char valstr[80]; - sprintf (valstr, "%d", value); - Tcl_AppendResult (interp, "illegal numeric enumeration value ", valstr, " for type ", _getdesc()->getmodule()->name, ".", _getdesc()->getname(), NULL); - Tcl_SetErrorCode (interp, "SNACC", "ILLENUM", NULL); - return TCL_ERROR; -} - -int AsnEnum::TclSetVal (Tcl_Interp *interp, const char *valstr) -{ - const AsnNameDesc *n = _getdesc()->getnames(); - if (n) - { - for (; n->name; n++) - if (!strcmp (n->name, valstr)) - { - value = n->value; - return TCL_OK; - } - } - Tcl_SetErrorCode (interp, "SNACC", "ILLENUM", NULL); - Tcl_AppendResult (interp, "illegal symbolic enumeration value \"", valstr, "\" for type ", _getdesc()->getmodule()->name, ".", _getdesc()->getname(), NULL); - return TCL_ERROR; -} - -#endif /* TCL */ -#endif /* META */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-int.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-int.cpp deleted file mode 100644 index 23748cd5..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-int.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-int.C - methods for AsnInt (ASN.1 INTEGER) class -// -// MS 92/06/16 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-int.cpp,v 1.3 2002/03/21 05:38:44 dmitch Exp $ -// $Log: asn-int.cpp,v $ -// Revision 1.3 2002/03/21 05:38:44 dmitch -// Radar 2868524: no more setjmp/longjmp in SNACC-generated code. -// -// Revision 1.2.44.1 2002/03/20 00:36:49 dmitch -// Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. -// -// Revision 1.2 2001/06/27 23:09:14 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.1.1.1 2001/05/18 23:14:05 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1 2000/06/15 18:44:57 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:35 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:36 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:51 mb -// Added snacc c++ library -// -// Revision 1.7 1997/02/28 13:39:45 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.6 1995/09/07 18:55:50 rj -// (unsigned) long int replaced by newly introduced Asn(U)IntType at a lot of places. -// they shall provide 32 bit integer types on all platforms. -// -// Revision 1.5 1995/07/24 20:17:32 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// call constructor with additional pdu and create arguments. -// -// changed `_' to `-' in file names. -// -// Revision 1.4 1995/02/18 16:48:05 rj -// denote a long if we want a long -// -// Revision 1.3 1994/10/08 04:18:23 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:12 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:59 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-type.h" -#include "asn-int.h" - -AsnType *AsnInt::Clone() const -{ - return new AsnInt; -} - -AsnType *AsnInt::Copy() const -{ - return new AsnInt (*this); -} - -// Encodes BER content of this AsnInt to the given buffer. -// Returns the number of octets written to the buffer. -AsnLen AsnInt::BEncContent (BUF_TYPE b) -{ - AsnLen len; - unsigned i; - AsnUIntType mask; - AsnUIntType dataCpy; - -#define MASK (0x7f80L << ((sizeof (AsnIntType) - 2) * 8)) - - dataCpy = value; - - /* - * calculate encoded length of the integer (content) - */ - mask = MASK; - if ((AsnIntType)dataCpy < 0) - for (len = sizeof (AsnIntType); len > 1; --len) - { - if ((dataCpy & mask) == mask) - mask >>= 8; - else - break; - } - else - for (len = sizeof (AsnIntType); len > 1; --len) - { - if ((dataCpy & mask) == 0) - mask >>= 8; - else - break; - } - - /* - * write the BER integer - */ - for (i = 0; i < len; i++) - { - b.PutByteRvs (dataCpy); - dataCpy >>= 8; - } - - return len; -} - -// Decodes the content of a BER INTEGER from the given buffer. -// The value is placed in this object. tagId is ignored. -// bytesDecoded is incremented by the number of bytes read for this -// integer value. -void AsnInt::BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env) -{ - unsigned i; - AsnUIntType byte; - - if (elmtLen > sizeof (AsnIntType)) - { - Asn1Error << "AsnInt::BDecContent: ERROR - integer is too big to decode." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-7); - #else - longjmp (env, -7); - #endif - } - - /* - * look at integer value - */ - byte = (AsnUIntType) b.GetByte(); - - if (byte & 0x80) /* top bit of first byte is sign bit */ - value = (-1 << 8) | byte; - else - value = byte; - - /* - * write from buffer into AsnIntType - */ - for (i = 1; i < elmtLen; i++) - value = (value << 8) | (AsnUIntType)(b.GetByte()); - - bytesDecoded += elmtLen; - - if (b.ReadError()) - { - Asn1Error << "AsnInt::BDecContent: ERROR - decoded past end of data." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-8); - #else - longjmp (env, -8); - #endif - } - - -} /* AsnInt::BDecContent */ - -AsnLen AsnInt::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - return l; -} - -void AsnInt::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - if (BDecTag (b, bytesDecoded, env) != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - { - Asn1Error << "AsnInt::BDec: ERROR tag on INTEGER is wrong." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-53); - #else - longjmp (env,-53); - #endif - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE), elmtLen, bytesDecoded, env); -} - -void AsnInt::Print (ostream &os) const -{ -#ifndef NDEBUG - os << value; -#endif -} - -#if META - -const AsnIntTypeDesc AsnInt::_desc (NULL, NULL, false, AsnTypeDesc::INTEGER, NULL, NULL); - -const AsnTypeDesc *AsnInt::_getdesc() const -{ - return &_desc; -} - -#if TCL - -#define RETURN_NAME_INSTEAD_OF_VALUE 0 - -int AsnInt::TclGetVal (Tcl_Interp *interp) const -{ -#if RETURN_NAME_INSTEAD_OF_VALUE - const AsnNameDesc *n = _getdesc()->getnames(); - if (n) - for (; n->name; n++) - if (n->value == value) - { - Tcl_SetResult (interp, n->name, TCL_STATIC); - return TCL_OK; - } -#endif - - char buf[32]; - sprintf (buf, "%d", value); - Tcl_SetResult (interp, buf, TCL_VOLATILE); - return TCL_OK; -} - -int AsnInt::TclSetVal (Tcl_Interp *interp, const char *valstr) -{ - const AsnNameDesc *n = _getdesc()->getnames(); - if (n) - for (; n->name; n++) - if (!strcmp (n->name, valstr)) - { - value = n->value; - return TCL_OK; - } - - int valval; - if (Tcl_GetInt (interp, (char*)valstr, &valval) != TCL_OK) - return TCL_ERROR; - value = valval; - return TCL_OK; -} - -#endif /* TCL */ -#endif /* META */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-len.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-len.cpp deleted file mode 100644 index cc8b4013..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-len.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-len.C - ASN.1 Length manipluation routines -// -// MS 92/06/18 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// - -#include "asn-config.h" -#include "asn-len.h" - - -/* - * Encodes the given length to the given buffer. - * returns the number of octets written to the buffer. - */ -AsnLen -BEncDefLen (BUF_TYPE b, AsnLen len) -{ - /* - * unrolled for efficiency - * (check each possibitlity of the 4 byte integer) - */ - if (len < 128) - { - b.PutByteRvs (len); - return 1; - } - else if (len < 256) - { - b.PutByteRvs (len); - b.PutByteRvs (0x81); - return 2; - } - else if (len < 65536) - { - b.PutByteRvs (len); - b.PutByteRvs (len >> 8); - b.PutByteRvs (0x82); - return 3; - } - else if (len < 16777126) - { - b.PutByteRvs (len); - b.PutByteRvs (len >> 8); - b.PutByteRvs (len >> 16); - b.PutByteRvs (0x83); - return 4; - } - else - { - b.PutByteRvs (len); - b.PutByteRvs (len >> 8); - b.PutByteRvs (len >> 16); - b.PutByteRvs (len >> 24); - b.PutByteRvs (0x84); - return 5; - } -} /* EncodeDefLen */ - -/* - * Decode a BER length from the given buffer. Increments bytesDecoded - * by the number of octets of the encoded length. Flags an - * error if the length is too large or a read error occurs - */ -AsnLen -BDecLen (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen len; - unsigned char byte; - unsigned lenBytes; - - byte = b.GetByte(); - - if (b.ReadError()) - { - Asn1Error << "BDecLen: decoded past end of data" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-9); - #else - longjmp (env, -9); - #endif - } - - bytesDecoded++; - if (byte < 128) /* short length */ - return byte; - - else if (byte == (unsigned char) 0x080) /* indef len indicator */ - return INDEFINITE_LEN; - - else /* long len form */ - { - /* - * strip high bit to get # bytes left in len - */ - lenBytes = byte & (unsigned char) 0x7f; - - if (lenBytes > sizeof (long int)) - { - Asn1Error << "BDecLen: ERROR - length overflow" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-10); - #else - longjmp (env, -10); - #endif - } - - bytesDecoded += lenBytes; - - for (len = 0; lenBytes > 0; lenBytes--) - len = (len << 8) | (unsigned long int) b.GetByte(); - - - if (b.ReadError()) - { - Asn1Error << "BDecLen: decoded past end of data" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-11); - #else - longjmp (env, -11); - #endif - } - - return len; - } - /* not reached */ -} - - -/* - * Encodes an End of Contents (EOC) to the given buffer. - * Returns the encoded length. - */ -AsnLen -BEncEoc (BUF_TYPE b) -{ - - b.PutByteRvs (0); - b.PutByteRvs (0); - return 2; -} /* BEncEoc */ - -/* - * Decodes an EOC from the given buffer. flags an error if the - * octets are non-zero or if read error occured. - */ -void -BDecEoc (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - - if ((b.GetByte() != 0) || (b.GetByte() != 0) || b.ReadError()) - { - Asn1Error << "BDecEoc: ERROR - non zero byte in EOC or end of data reached" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-12); - #else - longjmp (env, -12); - #endif - } - bytesDecoded += 2; -} /* BDecEoc */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-list.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-list.cpp deleted file mode 100644 index 997237d7..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-list.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-list.C -// -// Mike Sample -// 92/07/02 -// -// *** NOTE - this is not tested and not used **** -// snacc generates a new class for each list type, -// methods and all. -// (gcc choked on templates) -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-list.cpp,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-list.cpp,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1 2000/06/15 18:44:57 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:35 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.3 1999/07/14 23:53:56 aram -// Made const correct so things build with CW 5.0 -// -// Revision 1.2 1999/03/21 02:07:36 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:52 mb -// Added snacc c++ library -// -// Revision 1.8 1997/09/04 13:54:09 wan -// A little more portability -// -// Revision 1.7 1997/01/02 08:42:39 rj -// names of Tcl*-functions fixed (obviously they weren't needed :-) -// -// Revision 1.6 1995/07/24 20:18:15 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// call constructor with additional pdu and create arguments. -// -// changed `_' to `-' in file names. -// -// Revision 1.5 1995/02/18 14:06:02 rj -// #pragma interface/implementation are GNU specific and need to be wrapped. -// -// Revision 1.4 1994/10/08 04:18:25 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.3 1994/08/31 23:38:24 rj -// FALSE/TRUE turned into false/true -// -// Revision 1.2 1994/08/28 10:01:14 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:21:02 rj -// first check-in. for a list of changes to 1.1 please refer to the ChangeLog. - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-type.h" - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "asn-list.h" - -template -void AsnList::SetCurrElmt (unsigned long int index) -{ - unsigned long int i; - curr = first; - for (i = 0; (i < (count-1)) && (i < index); i++) - curr = curr->next; -} - - -// print routine for lists -template -ostream &operator << (ostream &os, AsnList &l) -{ - os << "SEQUENCE OF { "; - - l.SetCurrToFirst(); - for (; l.Curr() != NULL; l.GoNext()) - { - os << *l.Curr(); - if (l.Curr() != l.Last()) - os << ", "; - } - - os << " }"; - return os; -} - - - -// alloc new list elmt, put at end of list -// and return the component type -template -T &AsnList::Append() -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - - newElmt->next = NULL; - - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - - count++; - - return newElmt->elmt; - -} /* AsnList::Append */ - - -// alloc new list elmt, put at beggining of list -// and return the component type -template -T &AsnList::Prepend() -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - - newElmt->prev = NULL; - - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - - count++; - - return newElmt->elmt; - -} /* AsnList::Prepend */ - -template -AsnList& AsnList::AppendAndCopy (T &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - - newElmt->elmt = elmt; - - newElmt->next = NULL; - - if (last == NULL) - { - newElmt->prev = NULL; - first = last = newElmt; - } - else - { - newElmt->prev = last; - last->next = newElmt; - last = newElmt; - } - - count++; - - return this; - -} /* AppendAndCopy */ - -template -AsnList& AsnList::PrependAndCopy (T &elmt) -{ - AsnListElmt *newElmt; - - newElmt = new AsnListElmt; - - newElmt->elmt = elmt; - - newElmt->prev = NULL; - - if (first == NULL) - { - newElmt->next = NULL; - first = last = newElmt; - } - else - { - newElmt->next = first; - first->prev = newElmt; - first = newElmt; - } - - count++; - - return this; - -} /* PrependAndCopy */ - -template -AsnType *AsnList::Clone() const -{ - return new T; -} - -template -AsnType *AsnList::Copy() const -{ - return new T (*this); -} - -template -AsnLen AsnList::BEncContent (BUF_TYPE b) -{ - AsnListElmt *currElmt; - AsnLen sum = 0; - - for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev) - sum += currElmt->elmt.BEnc (b); - - return sum; -} - -template -void AsnList::BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env) -{ - T listElmt; - AsnTag listElmtTagId; - AsnLen localBytesDecoded = 0; - AsnLen listElmtLen = 0; - - - while ((localBytesDecoded < elmtLen) || (elmtLen == INDEFINITE_LEN)) - { - listElmtTagId = BDecTag (b, bytesDecoded, env); - - if ((listElmtTagId == EOC) && (elmtLen == INDEFINITE_LEN)) - break; - - - listElmt = Append(); - listElmtLen = BDecLen (b, bytesDecoded, env); - listElmt.BDecContent (b, listElmtTagId, listElmtLen, localBytesDecoded, env); - } - bytesDecoded += localBytesDecoded; - -} /* AsnList::BDecContent */ - -template -AsnLen AsnList::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} - -template -void AsnList::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - if (BDecTag (b, bytesDecoded, env) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) - { - Asn1Error << "AsnList::BDec: ERROR tag on SEQUENCE OF is wrong." << endl; - longjmp (env,-54); - } - elmtLen = BDecLen (b, bytesDecoded, env); - - BDecContent (b, MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE), elmtLen, bytesDecoded, env); -} - -template -int ListsEquiv (AsnList& l1, AsnList& l2) -{ - if (l1.Count() != l2.Count()) - return false; - - l1.SetCurrToFirst(); - l2.SetCurrToFirst(); - - for (; l1.Curr() != NULL; l1.GoNext(), l2.GoNext()) - { - if (*l1.Curr() != *l2.Curr()) - { - return false; - } - } - return true; -} - -#if 0 -#if META - -const AsnTypeDesc AsnList::_desc (NULL, NULL, false, AsnTypeDesc::SET_or_SEQUENCE_OF, NULL); - -const AsnTypeDesc *AsnList::_getdesc() const -{ - return &_desc; -} - -#if TCL - -int AsnList::TclGetVal (Tcl_Interp *interp) const -{ - return TCL_ERROR; -} - -int AsnList::TclSetVal (Tcl_Interp *interp, const char *valstr) -{ - return TCL_ERROR; -} - -#endif /* TCL */ -#endif /* META */ -#endif /* 0 */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-null.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-null.cpp deleted file mode 100644 index 7fe44749..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-null.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-null.C -// -// MS 92 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-null.cpp,v 1.3 2002/03/21 05:38:44 dmitch Exp $ -// $Log: asn-null.cpp,v $ -// Revision 1.3 2002/03/21 05:38:44 dmitch -// Radar 2868524: no more setjmp/longjmp in SNACC-generated code. -// -// Revision 1.2.44.1 2002/03/20 00:36:49 dmitch -// Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. -// -// Revision 1.2 2001/06/27 23:09:14 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1 2000/06/15 18:44:57 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:35 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:36 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:52 mb -// Added snacc c++ library -// -// Revision 1.5 1995/08/17 15:38:19 rj -// set Tcl's errorCode variable -// -// Revision 1.4 1995/07/24 20:18:27 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// call constructor with additional pdu and create arguments. -// -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:26 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:15 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:21:04 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-type.h" -#include "asn-null.h" - -AsnType *AsnNull::Clone() const -{ - return new AsnNull; -} - -AsnType *AsnNull::Copy() const -{ - return new AsnNull (*this); -} - -void AsnNull::BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env) -{ - if (elmtLen != 0) - { - Asn1Error << "AsnNull::BDecContent: ERROR - NULL values len is non-zero" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-13); - #else - longjmp (env, -13); - #endif - } -} /* AsnNull::BDecContent */ - -AsnLen AsnNull::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - l += BEncTag1 (b, UNIV, PRIM, NULLTYPE_TAG_CODE); - return l; -} - -void AsnNull::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - if (BDecTag (b, bytesDecoded, env) != MAKE_TAG_ID (UNIV, PRIM, NULLTYPE_TAG_CODE)) - { - Asn1Error << "AsnNull::BDec: ERROR tag on NULL is wrong." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-55); - #else - longjmp (env, -55); - #endif - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, MAKE_TAG_ID (UNIV, PRIM, NULLTYPE_TAG_CODE), elmtLen, bytesDecoded, env); -} - -void AsnNull::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "NULL"; -#endif -} - -#if META - -const AsnNullTypeDesc AsnNull::_desc (NULL, NULL, false, AsnTypeDesc::NUL_, NULL); - -const AsnTypeDesc *AsnNull::_getdesc() const -{ - return &_desc; -} - -#if TCL - -int AsnNull::TclGetVal (Tcl_Interp *interp) const -{ - return TCL_OK; -} - -int AsnNull::TclSetVal (Tcl_Interp *interp, const char *valstr) -{ - if (*valstr) - { - Tcl_AppendResult (interp, "illegal non-null value `", valstr, "' for type ", _getdesc()->getmodule()->name, ".", _getdesc()->getname(), NULL); - Tcl_SetErrorCode (interp, "SNACC", "ILLNULL", NULL); - return TCL_ERROR; - } - - return TCL_OK; -} - -#endif /* TCL */ -#endif /* META */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-octs.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-octs.cpp deleted file mode 100644 index 0dc53519..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-octs.cpp +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-octs.C - ASN.1 OCTET STRING methods for AsnOcts Class -// -// Mike Sample -// 92/07/02 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-octs.cpp,v 1.3 2002/03/21 05:38:44 dmitch Exp $ -// $Log: asn-octs.cpp,v $ -// Revision 1.3 2002/03/21 05:38:44 dmitch -// Radar 2868524: no more setjmp/longjmp in SNACC-generated code. -// -// Revision 1.2.44.1 2002/03/20 00:36:49 dmitch -// Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. -// -// Revision 1.2 2001/06/27 23:09:15 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/12/07 22:16:14 dmitch -// Thread-safe mods: added a local StrStk strStkG to the routines which need it. -// -// Revision 1.1 2000/06/15 18:44:57 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:35 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.4 1999/04/08 21:21:25 aram -// Fixed AsnOcts destructor. -// -// Revision 1.3 1999/03/21 02:07:36 mb -// Added Copy to every AsnType. -// -// Revision 1.2 1999/02/26 00:23:40 mb -// Fixed for Mac OS 8 -// -// Revision 1.1 1999/02/25 05:21:53 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/28 13:39:45 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.5 1995/08/17 15:33:33 rj -// augment binify()'s error message -// -// Revision 1.4 1995/07/24 20:23:32 rj -// use memcmpeq that is defined in .../snacc.h to use either memcmp or bcmp. -// -// code extracted from AsnOcts::TclGetVal and AsnOcts::TclSetVal into ::debinify and ::binify in meta.C -// -// #if TCL ... #endif wrapped into #if META ... #endif -// -// call constructor with additional pdu and create arguments. -// -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:27 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:16 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:21:05 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-type.h" -#include "asn-bits.h" /* for TO_HEX */ -#include "asn-octs.h" -#include "str-stk.h" - -#ifndef __APPLE__ -extern StrStk strStkG; -#endif - -AsnOcts::~AsnOcts() -{ - Asn1Free( octs ); -} - -AsnType *AsnOcts::Clone() const -{ - return new AsnOcts; -} - -AsnType *AsnOcts::Copy() const -{ - return new AsnOcts (*this); -} - -// Initialize the AsnOcts with a char * and length. -// copies the string str. -void AsnOcts::Set (const char *str, size_t len) -{ - octetLen = len; -#ifndef _IBM_ENC_ - octs = new char[octetLen]; -#else - octs = (char *) mem_mgr_ptr->Get (octetLen+1); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - memcpy (octs, str, octetLen); -} - -// Initialize the AsnOcts from another AsnOcts -// copies the string from o. -void AsnOcts::Set (const AsnOcts &o) -{ - if (&o != this) // avoid o = o; - { - octetLen = o.octetLen; -#ifndef _IBM_ENC_ - octs = new char[octetLen]; -#else - octs = (char *) mem_mgr_ptr->Get (octetLen+1); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - memcpy (octs, o.octs, octetLen); - } -} - -// Initialize the AsnOcts from a Null terminated string. -// copies the string str. -void AsnOcts::Set (const char *str) -{ - octetLen = strlen (str); -#ifndef _IBM_ENC_ - octs = new char[octetLen]; -#else - octs = (char *) mem_mgr_ptr->Get (octetLen+1); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - memcpy (octs, str, octetLen); -} - - -// free old octs value and tehn set the new -// octs and octetLen values with the given char *and length. -// copies the string str. -void AsnOcts::ReSet (const char *str, size_t len) -{ - if (str != octs) - { -#ifndef _IBM_ENC_ - delete octs; - Set (str, len); -#else - mem_mgr_ptr->Put ((void *)octs); /* Guido Grassel, 11.8.93 */ - Set (str, len); -#endif /* _IBM_ENC_ */ - } -} - -// Free old octs value and then set the new -// octs and octetLen from the given AsnOcts -// copies the string in o. -void AsnOcts::ReSet (const AsnOcts &o) -{ - if (&o != this) // avoid s = s; - { -#ifndef _IBM_ENC_ - delete octs; - Set (o); -#else - mem_mgr_ptr->Put ((void *)octs); /* Guido Grassel, 11.8.93 */ - Set (o); -#endif /* _IBM_ENC_ */ - } -} - -// Free old octs value and then set the new -// octs and octetLen values from a null terminated string. -// copies the string str. -void AsnOcts::ReSet (const char *str) -{ - if (str != octs) - { -#ifndef _IBM_ENC_ - delete octs; - Set (str); -#else - mem_mgr_ptr->Put ((void *)octs); /* Guido Grassel, 11.8.93 */ - Set (str); -#endif /* _IBM_ENC_ */ - } -} - - -// Prints the AsnOcts to the given ostream in Value Notation. -void AsnOcts::Print (ostream &os) const -{ -#ifndef NDEBUG - unsigned i; - os << "'"; - for (i = 0; i < octetLen; i++) - os << TO_HEX (octs[i] >> 4) << (TO_HEX (octs[i])); - - os << "'H -- \""; - - /* put printable parts in ASN.1 comment */ - for (i = 0; i < octetLen; i++) - { - if (isspace (octs[i])) - os << " "; /* newlines->space (so don't screw up ASN.1 comment) */ - else if (isprint (octs[i])) - os <Get (elmtLen+1); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - b.CopyOut (octs, elmtLen); - - if (b.ReadError()) - { - Asn1Error << "BDecOctetString: ERROR - decoded past end of data" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-14); - #else - longjmp (env, -14); - #endif - } - - /* add null terminator - this is not included in the str's len */ - octs[elmtLen] = '\0'; - bytesDecoded += elmtLen; - } - -} /* AsnOcts::BDecContent */ - -AsnLen AsnOcts::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - return l; -} - -void AsnOcts::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - tag = BDecTag (b, bytesDecoded, env); - if ((tag != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) && - (tag != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error << "AsnOcts::BDec: ERROR tag on OCTET STRING is wrong." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-56); - #else - longjmp (env,-56); - #endif - } - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - - - -/* - * Used for concatenating constructed OCTET STRING values when decoding - * - * fills string stack with references to the pieces of a - * construced octet string - */ -#ifdef __APPLE__ -static void -FillOctetStringStk (BUF_TYPE b, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env, StrStk &strStkG) -#else -static void -FillOctetStringStk (BUF_TYPE b, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -#endif -{ - size_t refdLen; - size_t totalRefdLen; - char *strPtr; - AsnLen totalElmtsLen1 = 0; - unsigned long int tagId1; - AsnLen elmtLen1; - - for (; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - tagId1 = BDecTag (b, totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, totalElmtsLen1, env); - break; - } - - elmtLen1 = BDecLen (b, totalElmtsLen1, env); - if (tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - { - /* - * primitive part of string, put references to piece (s) in - * str stack - */ - totalRefdLen = 0; - refdLen = elmtLen1; - while (1) - { - strPtr = b.GetSeg (&refdLen); - - strStkG.Push (strPtr, refdLen); - totalRefdLen += refdLen; - if (totalRefdLen == elmtLen1) - break; /* exit this while loop */ - - if (refdLen == 0) /* end of data */ - { - Asn1Error << "BDecConsOctetString: ERROR - attempt to decode past end of data" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-15); - #else - longjmp (env, -15); - #endif - } - refdLen = elmtLen1 - totalRefdLen; - } - totalElmtsLen1 += elmtLen1; - } - - - else if (tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE)) - { - /* - * constructed octets string embedding in this constructed - * octet string. decode it. - */ - #ifdef __APPLE__ - FillOctetStringStk (b, elmtLen1, totalElmtsLen1, env, - strStkG); - #else - FillOctetStringStk (b, elmtLen1, totalElmtsLen1, env); - #endif - } - else /* wrong tag */ - { - Asn1Error << "BDecConsOctetString: ERROR - decoded non-OCTET STRING tag inside a constructed OCTET STRING" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-16); - #else - longjmp (env, -16); - #endif - } - } /* end of for */ - - bytesDecoded += totalElmtsLen1; - -} /* AsnOcts::FillOctetStringStk */ - - - -/* - * decodes a seq of universally tagged octets until either EOC is - * encountered or the given len decoded. Return them in a - * single concatenated octet string - */ -void AsnOcts::BDecConsOcts (BUF_TYPE b, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env) -{ - #ifdef __APPLE__ - StrStk strStkG(128, 64); - #endif - strStkG.Reset(); - - /* - * decode each piece of the octet string, puting - * an entry in the octet/bit string stack for each - */ - #ifdef __APPLE__ - FillOctetStringStk (b, elmtLen, bytesDecoded, env, strStkG); - #else - FillOctetStringStk (b, elmtLen, bytesDecoded, env); - #endif - - /* alloc single str long enough for combined octetstring */ - octetLen = strStkG.totalByteLen; - -#ifndef _IBM_ENC_ - octs = Asn1Alloc (octetLen); -#else - octs = (char *) mem_mgr_ptr->Get (octetLen); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - - strStkG.CopyOut (octs); - -} /* BDecConsOcts */ - -int AsnOcts::OctsEquiv (const AsnOcts &o) const -{ - return o.octetLen == octetLen && !memcmpeq (o.octs, octs, octetLen); -} - -#if META - -const AsnOctsTypeDesc AsnOcts::_desc (NULL, NULL, false, AsnTypeDesc::OCTET_STRING, NULL); - -const AsnTypeDesc *AsnOcts::_getdesc() const -{ - return &_desc; -} - -#if TCL - -int AsnOcts::TclGetVal (Tcl_Interp *interp) const -{ - return debinify (interp, octs, octetLen); -} - -int AsnOcts::TclSetVal (Tcl_Interp *interp, const char *valstr) -{ - char* buf; - size_t len; - int result = TCL_OK; - -#ifndef _IBM_ENC_ - buf = new char[strlen (valstr)]; -#else - buf = (char *) mem_mgr_ptr->Get (strlen (valstr)+1); -#endif /* _IBM_ENC_ */ - - if (!buf) - { - Tcl_AppendResult (interp, "Malloc failed for type ", _getdesc()->getmodule()->name, ".", _getdesc()->getname(), NULL); - return TCL_ERROR; - } - if (binify (interp, valstr, buf, &len) != TCL_OK) - { - Tcl_AppendResult (interp, " for type ", _getdesc()->getmodule()->name, ".", _getdesc()->getname(), NULL); - result = TCL_ERROR; - } - else - ReSet (buf, len); - -#ifndef _IBM_ENC_ - delete buf; -#else - mem_mgr_ptr->Put ((void*) buf); -#endif /* _IBM_ENC_ */ - - return result; -} - -#endif /* TCL */ -#endif /* META */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-oid.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-oid.cpp deleted file mode 100644 index c845ffe8..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-oid.cpp +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-oid.C - OBJECT IDENTIFIER -// -// Mike Sample -// 92/07/02 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-oid.cpp,v 1.4 2002/03/21 05:38:45 dmitch Exp $ -// $Log: asn-oid.cpp,v $ -// Revision 1.4 2002/03/21 05:38:45 dmitch -// Radar 2868524: no more setjmp/longjmp in SNACC-generated code. -// -// Revision 1.3.44.1 2002/03/20 00:36:50 dmitch -// Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. -// -// Revision 1.3 2001/06/27 23:09:15 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.2 2001/06/21 19:51:43 dmitch -// Made AsnOid::Set(unsigned long...) thread-safe by making static arc arrays local. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.4 2001/05/05 00:59:19 rmurphy -// Adding darwin license headers -// -// Revision 1.3 2000/06/08 20:05:35 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.3 1999/03/21 02:07:37 mb -// Added Copy to every AsnType. -// -// Revision 1.2 1999/02/26 00:23:40 mb -// Fixed for Mac OS 8 -// -// Revision 1.1 1999/02/25 05:21:53 mb -// Added snacc c++ library -// -// Revision 1.7 1997/02/28 13:39:46 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.6 1997/02/16 12:32:49 rj -// name lookup of \for' scoping -// -// Revision 1.5 1995/08/17 15:31:14 rj -// set Tcl's errorCode variable -// -// Revision 1.4 1995/07/24 20:25:38 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// call constructor with additional pdu and create arguments. -// -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:28 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:17 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:21:06 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-config.h" -#if TCL -#include -#endif -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-type.h" -#include "asn-oid.h" -#include "print.h" - -AsnOid::~AsnOid() -{ - delete oid; -} - -AsnType *AsnOid::Clone() const -{ - return new AsnOid; -} - -AsnType *AsnOid::Copy() const -{ - return new AsnOid (*this); -} - -// Initializes an AsnOid with a string and it's length. -// The string should hold the encoded OID. -// The string is copied -#ifndef _IBM_ENC_ -void AsnOid::Set (const char *encOid, size_t len) -#else -void AsnOid::Set (const char *encOid, const size_t len) -#endif /* _IBM_ENC_ */ -{ - if (encOid != oid) - { - octetLen = len; -#ifndef _IBM_ENC_ - oid = new char[octetLen]; -#else - oid = (char *) mem_mgr_ptr->Get (octetLen); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - memcpy (oid, encOid, octetLen); - } -} - -// Inits an AsnOid from another OID. -// The oid string is copied. -void AsnOid::Set (const AsnOid &o) -{ - if (&o != this) - { - octetLen = o.octetLen; -#ifndef _IBM_ENC_ - oid = new char[octetLen]; -#else - oid = (char *) mem_mgr_ptr->Get (octetLen); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - memcpy (oid, o.oid, octetLen); - } -} - - -// Given some arc numbers, an AsnOid is built. -// Set (1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1) results in -// oid { 1 2 3 4 5 }. The first negative arc number represnts -// the end of the arc numbers - at least 2 are required. -// The prototype in the AsnOid class provides default -1 parameters -// so you only need to provide the number of arc number in the oid -// as params. (eg Set (1,2,3,4,5)) -void AsnOid::Set (unsigned long int a1, unsigned long int a2, long int a3, long int a4, long int a5, long int a6, long int a7, long int a8, long int a9, long int a10, long int a11) -{ - long int arcNumArr[11]; - char buf[11*5]; /* make big enough for max oid with 11 arcs*/ - char *tmpBuf; - size_t totalLen; - size_t elmtLen; - long int tmpArcNum; - long int headArcNum; - - tmpBuf = buf; - - arcNumArr[0] = a1; - arcNumArr[1] = a2; - arcNumArr[2] = a3; - arcNumArr[3] = a4; - arcNumArr[4] = a5; - arcNumArr[5] = a6; - arcNumArr[6] = a7; - arcNumArr[7] = a8; - arcNumArr[8] = a9; - arcNumArr[9] = a10; - arcNumArr[10] = a11; - - // munge together first oid arc numbers - headArcNum = tmpArcNum = (arcNumArr[0] * 40) + arcNumArr[1]; - - // figure encoded length for this arc number - for (elmtLen = 1; (tmpArcNum >>= 7) != 0; elmtLen++) - ; - - // write bytes except the last/least significant of the head arc number - // more bit is on - totalLen = elmtLen; - unsigned i; - for (i = 1; i < elmtLen; i++) - { - *(tmpBuf++) = 0x80 | (headArcNum >> ((elmtLen-i)*7)); - } - - // write least significant (more bit is off) - *(tmpBuf++) = 0x7f & headArcNum; - - // repeat for the rest of the arc numbers - for (i = 2; (i < 11) && (arcNumArr[i] > 0); i++) - { - tmpArcNum = arcNumArr[i]; - for (elmtLen = 1; (tmpArcNum >>= 7) != 0; elmtLen++) - ; - totalLen += elmtLen; - tmpArcNum = arcNumArr[i]; - for (unsigned j = 1; j < elmtLen; j++) - { - *(tmpBuf++) = 0x80 | (tmpArcNum >> ((elmtLen-j)*7)); - } - *(tmpBuf++) = 0x7f & tmpArcNum; - } - -#ifndef _IBM_ENC_ - oid = Asn1Alloc (totalLen); -#else - oid = (char *) mem_mgr_ptr->Get (totalLen); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - memcpy (oid, buf, totalLen); - octetLen = totalLen; - -} /* AsnOid::Set */ - - - -// Like Set except frees old oid value first -#ifndef _IBM_ENC_ -void AsnOid::ReSet (const char *encOid, size_t len) -#else -void AsnOid::ReSet (const char *encOid, const size_t len) -#endif /* _IBM_ENC_ */ -{ - if (encOid != oid) - { -#ifndef _IBM_ENC_ - delete oid; -#else - mem_mgr_ptr->Put ((void *) oid); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - Set (encOid, len); - } -} - -// Like Set except frees old oid value first -void AsnOid::ReSet (const AsnOid &o) -{ - if (&o != this) - { -#ifndef _IBM_ENC_ - delete oid; -#else - mem_mgr_ptr->Put ((void *) oid); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - Set (o); - } -} - -void AsnOid::ReSet (unsigned long int a1, unsigned long int a2, long int a3, long int a4, long int a5, long int a6, long int a7, long int a8, long int a9, long int a10, long int a11) -{ -#ifndef _IBM_ENC_ - delete oid; -#else - mem_mgr_ptr->Put ((void *) oid); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - Set (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); -} - - -// returns the number of arc numbers in the OID value -unsigned long int AsnOid::NumArcs() const -{ - unsigned i; - int numArcs; - - for (numArcs=0, i=0; i < octetLen; ) - { - // skip octets in this arc num with the 'more' bit set - for (; (i < octetLen) && (oid[i] & 0x80); i++) - ; - - // skip last octet in this arc num (no more bit) - i++; - - numArcs++; - } - - // add one to return value because the first two arcs are - // crunched together into a single one. - return numArcs +1; - -} /* AsnOid::NumArcs */ - -int AsnOid::OidEquiv (const AsnOid &o) const -{ - return o.octetLen == octetLen && !strncmp (o.oid, oid, octetLen); -} - - - -// Decodes the content of a BER OBJECT IDENTIFIER value and puts -// the results in this AsnOid object. -void AsnOid::BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env) -{ - /* treat like primitive octet string */ - octetLen = elmtLen; -#ifndef _IBM_ENC_ - oid = Asn1Alloc (elmtLen); -#else - oid = (char *) mem_mgr_ptr->Get (elmtLen); /* Guido Grassel, 11.8.93 */ -#endif /* _IBM_ENC_ */ - b.CopyOut (oid, elmtLen); - - if (b.ReadError()) - { - Asn1Error << "BDecOctetString: ERROR - decoded past end of data" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-17); - #else - longjmp (env, -17); - #endif - } - bytesDecoded += elmtLen; -} /* AsnOid::BDecContent */ - -AsnLen AsnOid::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - return l; -} - -void AsnOid::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - if (BDecTag (b, bytesDecoded, env) != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)) - { - Asn1Error << "AsnOid::BDec: ERROR tag on OBJECT IDENTIFIER is wrong." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-57); - #else - longjmp (env,-57); - #endif - } - elmtLen = BDecLen (b, bytesDecoded, env); - - BDecContent (b, MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE), elmtLen, bytesDecoded, env); -} - -AsnLen AsnOid::BEncContent (BUF_TYPE b) -{ - b.PutSegRvs (oid, octetLen); - return octetLen; -} - -// Prints an AsnOid in ASN.1 Value Notation. -// Decodes the oid to get the individual arc numbers -void AsnOid::Print (ostream &os) const -{ -#ifndef NDEBUG - unsigned short int firstArcNum; - unsigned long int arcNum; - unsigned i; - - // print oid in - os << "{"; - - if (oid) - { - // un-munge first two arc numbers - for (arcNum = 0, i=0; (i < octetLen) && (oid[i] & 0x80); i++) - arcNum = (arcNum << 7) + (oid[i] & 0x7f); - - arcNum = (arcNum << 7) + (oid[i] & 0x7f); - i++; - firstArcNum = arcNum/40; - if (firstArcNum > 2) - firstArcNum = 2; - - os << firstArcNum << " " << arcNum - (firstArcNum * 40); - - for (; i < octetLen; ) - { - for (arcNum = 0; (i < octetLen) && (oid[i] & 0x80); i++) - arcNum = (arcNum << 7) + (oid[i] & 0x7f); - - arcNum = (arcNum << 7) + (oid[i] & 0x7f); - i++; - os << " " << arcNum; - } - } - else - os << "-- void --"; - - os << "}"; -#endif /* NDEBUG */ -} // AsnOid::Print - -#if META - -const AsnOidTypeDesc AsnOid::_desc (NULL, NULL, false, AsnTypeDesc::OBJECT_IDENTIFIER, NULL); - -const AsnTypeDesc *AsnOid::_getdesc() const -{ - return &_desc; -} - -#if TCL - -int AsnOid::TclGetVal (Tcl_Interp *interp) const -{ - if (oid) - { - strstream buf; - buf << *this; - buf.str()[strlen(buf.str())-1] = '\0'; // chop the trailing '}' - Tcl_SetResult (interp, buf.str()+1, TCL_VOLATILE); // copy without leading '{' - } - return TCL_OK; -} - -int AsnOid::TclSetVal (Tcl_Interp *interp, const char *valstr) -{ - if (!*valstr) - { - delete oid; - oid = NULL; - octetLen = 0; - return TCL_OK; - } - - Args arc; - if (Tcl_SplitList (interp, (char*)valstr, &arc.c, &arc.v) != TCL_OK) - return TCL_ERROR; - if (arc.c < 2) - { - Tcl_AppendResult (interp, "oid arc must contain at least two numbers", NULL); - Tcl_SetErrorCode (interp, "SNACC", "ILLARC", "<2", NULL); - return TCL_ERROR; - } - if (arc.c > 11) - { - Tcl_AppendResult (interp, "snacc limits oid arcs to no more than 11 numbers", NULL); - Tcl_SetErrorCode (interp, "SNACC", "ILLARC", ">11", NULL); - return TCL_ERROR; - } - - int na[11], i; - for (i=0; i 1) && ((val & mask) == 0)) - { - mask >>= 8; - retVal--; - } - - return retVal; - -} /* SignedIntOctetLen */ - - - -#ifdef IEEE_REAL_FMT - -// Returns the PLUS INFINITY in double format -// This assumes that a C++ double is an IEEE double. -// The bits for IEEE double PLUS INFINITY are -// 0x7ff0000000000000 -double AsnPlusInfinity() -{ -#ifndef _IBM_ENC_ - double d; - unsigned char *c = (unsigned char *)&d; - -#if WORDS_BIGENDIAN - c[0] = 0x7f; - c[1] = 0xf0; - c[2] = 0x0; - c[3] = 0x0; - c[4] = 0x0; - c[5] = 0x0; - c[6] = 0x0; - c[7] = 0x0; -#else - c[7] = 0x7f; - c[6] = 0xf0; - c[5] = 0x0; - c[4] = 0x0; - c[3] = 0x0; - c[2] = 0x0; - c[1] = 0x0; - c[0] = 0x0; -#endif - - return d; -#else - return 1.7976931348623158e+308; -#endif /* _IBM_ENC_ */ -} /* AsnPlusInfinity */ - -double AsnMinusInfinity() -{ - return -AsnPlusInfinity(); -} - -#if SIZEOF_DOUBLE != 8 - #error oops: doubles are expected to be 8 bytes in size! -#endif - -/* - * Use this routine if you system/compiler represents doubles in the IEEE format. - */ -AsnLen AsnReal::BEncContent (BUF_TYPE b) -{ - int exponent; - int isNeg; -#if SIZEOF_LONG == 8 - unsigned long mantissa, val, *p; - int i; -#elif SIZEOF_LONG == 4 - unsigned char *dbl; - unsigned long int *first4; - unsigned long int *second4; -#else - #error long neither 8 nor 4 bytes in size? -#endif - - /* no contents for 0.0 reals */ - if (value == 0.0) /* all bits zero, disregarding top/sign bit */ - return 0; - -#if SIZEOF_LONG == 8 - /* - * this part assumes that sizeof (long) == sizeof (double) == 8 - * It shouldn't be endian-dependent but I haven't verified that - */ - - p = (unsigned long*) &value; - val = *p; - - isNeg = (val >> 63) & 1; - /* special real values for +/- oo */ - if (!finite (value)) - { - if (isNeg) - b.PutByteRvs(ENC_MINUS_INFINITY); - else - b.PutByteRvs(ENC_PLUS_INFINITY); - return 1; - } - else /* encode a binary real value */ - { - exponent = (val >> 52) & 0x7ff; - mantissa = (val & 0xfffffffffffffL) | 0x10000000000000L; - - for (i = 0; i < 7; i++) - { - b.PutByteRvs(mantissa & 0xff); - mantissa >>= 8; - } - exponent -= (1023 + 52); - -#elif SIZEOF_LONG == 4 - /* - * this part assumes that sizeof (long) == 4 and - * that sizeof (double) == 8 - * - * sign exponent - * b 2-12 incl - * Sv-----------v----- rest is mantissa - * ------------------------------------------- - * | | - * ------------------------------------------- - * 123456878 1234 - * - * sign bit is 1 if real is < 0 - * exponent is an 11 bit unsigned value (subtract 1023 to get correct exp value) - * decimal pt implied before mantissa (ie mantissa is all fractional) - * and implicit 1 bit to left of decimal - * - * when given NaN (not a number - ie oo/oo) it encodes the wrong value - * instead of checking for the error. If you want to check for it, - * a NaN is any sign bit with a max exponent (all bits a 1) followed - * by any non-zero mantissa. (a zero mantissa is used for infinity) - * - */ - - first4 = (unsigned long int*) (dbl = (unsigned char*) &value); - second4 = (unsigned long int *) (dbl + sizeof (long int)); - - /* no contents for 0.0 reals */ - if (value == 0.0) /* all bits zero, disregarding top/sign bit */ - return 0; - - isNeg = dbl[0] & 0x80; - - /* special real values for +/- oo */ - if (((*first4 & 0x7fffffff) == 0x7ff00000) && (*second4 == 0)) - { - if (isNeg) - b.PutByteRvs (ENC_MINUS_INFINITY); - else - b.PutByteRvs (ENC_PLUS_INFINITY); - - return 1; - } - else /* encode a binary real value */ - { - exponent = (((*first4) >> 20) & 0x07ff); - - /* write the mantissa (N value) */ - b.PutSegRvs ((char*)(dbl+2), sizeof (double)-2); - - /* - * The rightmost 4 bits of a double 2nd octet are the - * most sig bits of the mantissa. - * write the most signficant byte of the asn1 real manitssa, - * adding implicit bit to 'left of decimal' if not de-normalized - * (de normalized if exponent == 0) - * - * if the double is not in de-normalized form subtract 1023 - * from the exponent to get proper signed exponent. - * - * for both the normalized and de-norm forms - * correct the exponent by subtracting 52 since: - * 1. mantissa is 52 bits in the double (56 in ASN.1 REAL form) - * 2. implicit decimal at the beginning of double's mantissa - * 3. ASN.1 REAL's implicit decimal is after its mantissa - * so converting the double mantissa to the ASN.1 form has the - * effect of multiplying it by 2^52. Subtracting 52 from the - * exponent corrects this. - */ - if (exponent == 0) /* de-normalized - no implicit 1 to left of dec.*/ - { - b.PutByteRvs (dbl[1] & 0x0f); - exponent -= 52; - } - else - { - b.PutByteRvs ((dbl[1] & 0x0f) | 0x10); /* 0x10 adds implicit bit */ - exponent -= (1023 + 52); - } - -#else - #error long neither 8 nor 4 bytes in size? -#endif - - /* write the exponent */ - b.PutByteRvs (exponent & 0xff); - b.PutByteRvs (exponent >> 8); - - /* write format octet */ - /* bb is 00 since base is 2 so do nothing */ - /* ff is 00 since no other shifting is nec */ - if (isNeg) - b.PutByteRvs (REAL_BINARY | REAL_EXPLEN_2 | REAL_SIGN); - else - b.PutByteRvs (REAL_BINARY | REAL_EXPLEN_2); - - return sizeof (double) + 2; - } - - /* not reached */ - -} /* AsnReal::BEncContent */ - -#else /* IEEE_REAL_FMT not def */ - -#ifdef IEEE_REAL_LIB - -// Returns the PLUS INFINITY in double format -// this assumes you have the IEEE functions in -// the math lib -double AsnPlusInfinity() -{ - return infinity(); -} /* AsnPlusInfinity */ - -double AsnMinusInfinity() -{ - return -AsnPlusInfinity(); -} - -// This routine uses the ieee library routines to encode -// this AsnReal's double value -AsnLen AsnReal::BEncContent (BUF_TYPE b) -{ - AsnLen encLen; - double mantissa; - double tmpMantissa; - unsigned int truncatedMantissa; - int exponent; - unsigned int expLen; - int sign; - unsigned char buf[sizeof (double)]; - int i, mantissaLen; - unsigned char firstOctet; - - /* no contents for 0.0 reals */ - if (iszero (value)) - return 0; - - /* special real values for +/- oo */ - if (isinf (value)) - { - if (signbit (value)) /* neg */ - b.PutByteRvs (ENC_MINUS_INFINITY); - else - b.PutByteRvs (ENC_PLUS_INFINITY); - - encLen = 1; - } - else /* encode a binary real value */ - { - if (signbit (value)) - sign = -1; - else - sign = 1; - - exponent = ilogb (value); - - /* get the absolute value of the mantissa (subtract 1 to make < 1) */ - mantissa = scalbn (fabs (value), -exponent-1); - - - tmpMantissa = mantissa; - - /* convert mantissa into an unsigned integer */ - for (i = 0; i < sizeof (double); i++) - { - /* normalizied so shift 8 bits worth to the left of the decimal */ - tmpMantissa *= (1<<8); - - /* grab only (octet sized) the integer part */ - truncatedMantissa = (unsigned int) tmpMantissa; - - /* remove part to left of decimal now for next iteration */ - tmpMantissa -= truncatedMantissa; - - /* write into tmp buffer */ - buf[i] = truncatedMantissa; - - /* keep track of last non zero octet so can zap trailing zeros */ - if (truncatedMantissa) - mantissaLen = i+1; - } - - /* - * write format octet (first octet of content) - * field 1 S bb ff ee - * bit# 8 7 65 43 21 - * - * 1 in bit#1 means binary rep - * 1 in bit#2 means the mantissa is neg, 0 pos - * bb is the base: 65 base - * 00 2 - * 01 8 - * 10 16 - * 11 future ext. - * - * ff is the Value of F where Mantissa = sign x N x 2^F - * FF can be one of 0 to 3 inclusive. (used to save re-alignment) - * - * ee is the length of the exponent: 21 length - * 00 1 - * 01 2 - * 10 3 - * 11 long form - * - * - * encoded binary real value looks like - * - * fmt oct - * -------------------------------------------------------- - * |1Sbbffee| exponent (2's comp) | N (unsigned int) | - * -------------------------------------------------------- - * 87654321 - */ - firstOctet = REAL_BINARY; - if (signbit (value)) - firstOctet |= REAL_SIGN; - - /* bb is 00 since base is 2 so do nothing */ - /* ff is 00 since no other shifting is nec */ - - /* - * get exponent calculate its encoded length - * Note that the process of converting the mantissa - * double to an int shifted the decimal mantissaLen * 8 - * to the right - so correct that here - */ - exponent++; /* compensate for trick to put mantissa < 1 */ - exponent -= (mantissaLen * 8); - expLen = SignedIntOctetLen (exponent); - - switch (expLen) - { - case 1: - firstOctet |= REAL_EXPLEN_1; - break; - case 2: - firstOctet |= REAL_EXPLEN_2; - break; - case 3: - firstOctet |= REAL_EXPLEN_3; - break; - default: - firstOctet |= REAL_EXPLEN_LONG; - break; - } - - encLen = mantissaLen + expLen + 1; - - /* write the mantissa (N value) */ - b.PutSegRvs ((char*)buf, mantissaLen); - - /* write the exponent */ - for (i = expLen; i > 0; i--) - { - b.PutByteRvs (exponent); - exponent >> 8; - } - - /* write the exponents length if nec */ - if (expLen > 3) - { - encLen++; - b.PutByteRvs (expLen); - } - - /* write the format octet */ - b.PutByteRvs (firstOctet); - - } - return encLen; - -} /* AsnReal::BEncContent */ - -#else /* neither IEEE_REAL_FMT or IEEE_REAL_LIB are def */ - - -// Returns the PLUS INFINITY in double format -// This assumes that a C++ double is an IEEE double. -// The bits for IEEE double PLUS INFINITY are -// 0x7ff0000000000000 -// NOTE: this is a guess - you should set this up for -// your architecture -double AsnPlusInfinity() -{ - double d; - unsigned char *c; - unsigned i; - - c = (unsigned char*)&d; - c[0] = 0x7f; - c[1] = 0xf0; - for (i = 2; i < sizeof (double); i++) - c[i] = 0; - return d; -} /* AsnPlusInfinity */ - -double AsnMinusInfinity() -{ - return -AsnPlusInfinity(); -} - -/* - * Encodes the content of an ASN.1 REAL value to the given buffer. - * This version of the routine does not assume an IEEE double rep. - * or the existence of the IEEE library routines. Uses old style - * UNIX frexp etc. - */ -AsnLen AsnReal::BEncContent (BUF_TYPE b) -{ - unsigned long int encLen; - double mantissa; - double tmpMantissa; - unsigned int truncatedMantissa; - int exponent; - unsigned int expLen; - int sign; - unsigned char buf[sizeof (double)]; - unsigned i, mantissaLen; - unsigned char firstOctet; - - /* no contents for 0.0 reals */ - if (value == 0.0) - return 0; - - /* special real values for +/- oo */ - if (value == MINUS_INFINITY) - { - b.PutByteRvs (ENC_MINUS_INFINITY); - encLen = 1; - } - else if (value == PLUS_INFINITY) - { - b.PutByteRvs (ENC_PLUS_INFINITY); - encLen = 1; - } - else /* encode a binary real value */ - { - /* - * this is what frexp gets from value - * value == mantissa * 2^exponent - * where 0.5 <= |manitissa| < 1.0 - */ - mantissa = frexp (value, &exponent); - - /* set sign and make mantissa = | mantissa | */ - if (mantissa < 0.0) - { - sign = -1; - mantissa *= -1; - } - else - sign = 1; - - - tmpMantissa = mantissa; - - /* convert mantissa into an unsigned integer */ - for (i = 0; i < sizeof (double); i++) - { - /* normalizied so shift 8 bits worth to the left of the decimal */ - tmpMantissa *= (1<<8); - - /* grab only (octet sized) the integer part */ - truncatedMantissa = (unsigned int) tmpMantissa; - - /* remove part to left of decimal now for next iteration */ - tmpMantissa -= truncatedMantissa; - - /* write into tmp buffer */ - buf[i] = truncatedMantissa; - - /* keep track of last non zero octet so can zap trailing zeros */ - if (truncatedMantissa) - mantissaLen = i+1; - } - - /* - * write format octet (first octet of content) - * field 1 S bb ff ee - * bit# 8 7 65 43 21 - * - * 1 in bit#1 means binary rep - * 1 in bit#2 means the mantissa is neg, 0 pos - * bb is the base: 65 base - * 00 2 - * 01 8 - * 10 16 - * 11 future ext. - * - * ff is the Value of F where Mantissa = sign x N x 2^F - * FF can be one of 0 to 3 inclusive. (used to save re-alignment) - * - * ee is the length of the exponent: 21 length - * 00 1 - * 01 2 - * 10 3 - * 11 long form - * - * - * encoded binary real value looks like - * - * fmt oct - * -------------------------------------------------------- - * |1Sbbffee| exponent (2's comp) | N (unsigned int) | - * -------------------------------------------------------- - * 87654321 - */ - firstOctet = REAL_BINARY; - if (sign == -1) - firstOctet |= REAL_SIGN; - - /* bb is 00 since base is 2 so do nothing */ - /* ff is 00 since no other shifting is nec */ - - /* - * get exponent calculate its encoded length - * Note that the process of converting the mantissa - * double to an int shifted the decimal mantissaLen * 8 - * to the right - so correct that here - */ - exponent -= (mantissaLen * 8); - expLen = SignedIntOctetLen (exponent); - - switch (expLen) - { - case 1: - firstOctet |= REAL_EXPLEN_1; - break; - case 2: - firstOctet |= REAL_EXPLEN_2; - break; - case 3: - firstOctet |= REAL_EXPLEN_3; - break; - default: - firstOctet |= REAL_EXPLEN_LONG; - break; - } - - encLen = mantissaLen + expLen + 1; - - /* write the mantissa (N value) */ - b.PutSegRvs ((char*)buf, mantissaLen); - - /* write the exponent */ - for (i = expLen; i > 0; i--) - { - b.PutByteRvs (exponent); - exponent >>= 8; - } - - /* write the exponents length if nec */ - if (expLen > 3) - { - encLen++; - b.PutByteRvs (expLen); - } - - /* write the format octet */ - b.PutByteRvs (firstOctet); - - } - return encLen; - -} /* AsnReal:BEncContent */ - - - -#endif -#endif - - -// Decode a REAL value's content from the given buffer. -// places the result in this object. -void AsnReal::BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env) -{ - unsigned char firstOctet; - unsigned char firstExpOctet; - unsigned i; - unsigned int expLen; - double mantissa; - unsigned short base; - long int exponent = 0; - double tmpBase; - double tmpExp; - - - if (elmtLen == 0) - { - value = 0.0; - return; - } - - firstOctet = b.GetByte(); - if (elmtLen == 1) - { - bytesDecoded += 1; - if (firstOctet == ENC_PLUS_INFINITY) - value = PLUS_INFINITY; - else if (firstOctet == ENC_MINUS_INFINITY) - value = MINUS_INFINITY; - else - { - Asn1Error << "AsnReal::BDecContent: ERROR - unrecognized 1 octet length real number" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-18); - #else - longjmp (env, -18); - #endif - } - } - else - { - if (firstOctet & REAL_BINARY) - { - firstExpOctet = b.GetByte(); - if (firstExpOctet & 0x80) - exponent = -1; - switch (firstOctet & REAL_EXPLEN_MASK) - { - case REAL_EXPLEN_1: - expLen = 1; - exponent = (exponent << 8) | firstExpOctet; - break; - - case REAL_EXPLEN_2: - expLen = 2; - exponent = (exponent << 16) | (((unsigned long int) firstExpOctet) << 8) | b.GetByte(); - break; - - case REAL_EXPLEN_3: - expLen = 3; - exponent = (exponent << 16) | (((unsigned long int) firstExpOctet) << 8) | b.GetByte(); - exponent = (exponent << 8) | b.GetByte(); - break; - - default: /* long form */ - expLen = firstExpOctet +1; - i = firstExpOctet-1; - firstExpOctet = b.GetByte(); - if (firstExpOctet & 0x80) - exponent = (-1 <<8) | firstExpOctet; - else - exponent = firstExpOctet; - for (;i > 0; firstExpOctet--) - exponent = (exponent << 8) | b.GetByte(); - break; - } - - mantissa = 0.0; - for (i = 1 + expLen; i < elmtLen; i++) - { - mantissa *= (1<<8); - mantissa += b.GetByte(); - } - - /* adjust N by scaling factor */ - mantissa *= (1<<((firstOctet & REAL_FACTOR_MASK) >> 2)); - - switch (firstOctet & REAL_BASE_MASK) - { - case REAL_BASE_2: - base = 2; - break; - - case REAL_BASE_8: - base = 8; - break; - - case REAL_BASE_16: - base = 16; - break; - - default: - Asn1Error << "AsnReal::BDecContent: ERROR - unsupported base for a binary real number." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-19); - #else - longjmp (env, -19); - #endif - break; - - } - - tmpBase = base; - tmpExp = exponent; - - value = mantissa * pow ((double)base, (double)exponent); - - if (firstOctet & REAL_SIGN) - value = -value; - - bytesDecoded += elmtLen; - } - else /* decimal version */ - { - Asn1Error << "AsnReal::BDecContent: ERROR - decimal REAL form is not currently supported" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-20); - #else - longjmp (env, -20); - #endif - } - } - -} /* AsnInt::BDecContent */ - -AsnLen AsnReal::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, REAL_TAG_CODE); - return l; -} - -void AsnReal::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - if (BDecTag (b, bytesDecoded, env) != MAKE_TAG_ID (UNIV, PRIM, REAL_TAG_CODE)) - { - Asn1Error << "AsnReal::BDec: ERROR tag on REAL is wrong." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-58); - #else - longjmp (env,-58); - #endif - } - elmtLen = BDecLen (b, bytesDecoded, env); - - BDecContent (b, MAKE_TAG_ID (UNIV, PRIM, REAL_TAG_CODE), elmtLen, bytesDecoded, env); -} - -void AsnReal::Print (ostream &os) const -{ -#ifndef NDEBUG - os << value; -#endif -} - -#if META - -const AsnRealTypeDesc AsnReal::_desc (NULL, NULL, false, AsnTypeDesc::REAL, NULL); - -const AsnTypeDesc *AsnReal::_getdesc() const -{ - return &_desc; -} - -#if TCL - -int AsnReal::TclGetVal (Tcl_Interp *interp) const -{ - if (value == PLUS_INFINITY) - strcpy (interp->result, "+inf"); - else if (value == MINUS_INFINITY) - strcpy (interp->result, "-inf"); - else - sprintf (interp->result, "%g", value); - return TCL_OK; -} - -int AsnReal::TclSetVal (Tcl_Interp *interp, const char *valstr) -{ - double valval; - - if (!strcmp (valstr, "+inf")) - valval = PLUS_INFINITY; - else if (!strcmp (valstr, "-inf")) - valval = MINUS_INFINITY; - else if (Tcl_GetDouble (interp, (char*)valstr, &valval) != TCL_OK) - return TCL_ERROR; - - value = valval; - - return TCL_OK; -} - -#endif /* TCL */ -#endif /* META */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-tag.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-tag.cpp deleted file mode 100644 index 05fd6382..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-tag.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-tag.C - ASN.1 tag manipulation routines -// -// MS 92/06/18 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" - -/* - * Decode a BER Tag from the given buffer. Error is - * flagged if the tag is too long or if a read error occurs. - */ -AsnTag -BDecTag (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tagId; - AsnTag tmpTagId; - unsigned i; - - tagId = ((AsnTag) b.GetByte()) << ((sizeof (AsnTag)-1) *8); - bytesDecoded++; - - /* check if long tag format (ie code > 31) */ - if ((tagId & (((AsnTag) 0x1f) << ((sizeof (AsnTag)-1)*8))) == (((AsnTag)0x1f) << ((sizeof (AsnTag)-1)*8))) - { - i = 2; - do - { - tmpTagId = (AsnTag) b.GetByte(); - tagId |= (tmpTagId << ((sizeof (AsnTag)-i)*8)); - bytesDecoded++; - i++; - } - while ((tmpTagId & (AsnTag)0x80) && (i <= sizeof (AsnTag))); - - /* - * check for too long a tag - */ - if (i > (sizeof (AsnTag)+1)) - { - Asn1Error << "BDecTag: ERROR - tag value overflow" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-21); - #else - longjmp (env, -21); - #endif - } - } - - if (b.ReadError()) - { - Asn1Error << "BDecTag: ERROR - decoded past the end of data" << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-22); - #else - longjmp (env, -22); - #endif - } - - return tagId; - -} /* BDecTag */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-type.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-type.cpp deleted file mode 100644 index 91c65e83..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-type.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/asn-type.C - Abstract class that all ASN.1 types are derived from -// Design motivated by ANY type. -// -// Runtime cost in speed and space for virtual fcns will -// hopefully not be too bad -// -// If your ASN.1 code does not use ANY or ANY DEFIND BY -// types then you could make the BEnc, BDec and Clone -// non-virtual in the AsnType to improve performance. -// (undef SUPPORT_ANY_TYPE) -// -// NOTE: The virtual encode/decode/print etc fcns -// could be purely virtual (= 0) creating an abstract class -// but the ANY handling code needs to instantiate the AsnType -// base class (via Cloning). Also it allows for default -// error reporting for ANY types that have not been -// instantiated properly. -// -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// MS 92 -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-type.cpp,v 1.3 2002/03/21 05:38:45 dmitch Exp $ -// $Log: asn-type.cpp,v $ -// Revision 1.3 2002/03/21 05:38:45 dmitch -// Radar 2868524: no more setjmp/longjmp in SNACC-generated code. -// -// Revision 1.2.44.1 2002/03/20 00:36:50 dmitch -// Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. -// -// Revision 1.2 2001/06/27 23:09:15 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1 2000/06/15 18:44:58 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:36 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:38 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:55 mb -// Added snacc c++ library -// -// Revision 1.4 1997/01/01 20:13:55 rj -// "virtual" removed from functions. (fix due to changed C++ language.) -// -// Revision 1.3 1995/07/24 20:35:21 rj -// _getref() gets an additional optional argument to faciliate the different member access semantics of TclGetVal() and TclSetVal(). -// -// additional function TclUnsetVal() to delete OPTIONAL members and SEQUENCE OF and SET OF list elements. -// returns an error for all other types. -// -// #if TCL ... #endif wrapped into #if META ... #endif -// -// call constructor with additional pdu and create arguments. -// -// changed `_' to `-' in file names. -// -// Revision 1.2 1994/10/08 04:18:31 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.1 1994/09/13 14:18:45 rj -// inline functions moved from asn_type.h to asn_type.C. -// functions that are called upon error only don't need to be that fast. -// -// Revision 1.2 1994/08/28 10:00:57 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:44 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-type.h" - -AsnType::~AsnType() -{ -} - -#ifdef SUPPORT_ANY_TYPE - -AsnType *AsnType::Clone() const -{ - return NULL; -} - -AsnType *AsnType::Copy() const -{ - return NULL; -} - -void AsnType::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - Asn1Error << "ERROR - Attempt to decode an improperly formed ANY type (programming error)." << endl; - #if SNACC_EXCEPTION_ENABLE - SnaccExcep::throwMe(-80); - #else - longjmp (env, -80); - #endif -} - -AsnLen AsnType::BEnc (BUF_TYPE b) -{ - Asn1Error << "ERROR - Attempt to encode an improperly formed ANY type (programming error)." << endl; - return 0; -} - -#endif - -void AsnType::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "ERROR - Attempt to print an improperly formed ANY type (programming error)." << endl; -#endif /* NDEBUG */ -} - -#if META - -const AsnTypeDesc AsnType::_desc (NULL, NULL, false, AsnTypeDesc::VOID, NULL); - -const AsnTypeDesc *AsnType::_getdesc() const -{ - return &_desc; -} - -AsnType *AsnType::_getref (const char *membername, bool create) -{ - return NULL; -} - -const char *AsnType::_typename() const -{ - return _desc.typenames[_getdesc()->type]; -} - -#if TCL - -int AsnType::TclGetDesc (Tcl_DString *valstr) const -{ - return TCL_OK; -} - -int AsnType::TclGetVal (Tcl_Interp *interp) const -{ - Tcl_AppendResult (interp, "can't get value from ", _typename(), NULL); - return TCL_ERROR; -} - -int AsnType::TclSetVal (Tcl_Interp *interp, const char *) -{ - Tcl_AppendResult (interp, "can't set value in ", _typename(), NULL); - return TCL_ERROR; -} - -int AsnType::TclUnsetVal (Tcl_Interp *interp, const char *) -{ - Tcl_AppendResult (interp, "can't unset member(s) in ", _typename(), NULL); - return TCL_ERROR; -} - -#endif /* TCL */ -#endif /* META */ diff --git a/SecuritySNACCRuntime/c++-lib/c++/asn-useful.cpp b/SecuritySNACCRuntime/c++-lib/c++/asn-useful.cpp deleted file mode 100644 index 3e53655b..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/asn-useful.cpp +++ /dev/null @@ -1,1095 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// asn-useful.cpp - class member functions for ASN.1 module ASN-USEFUL -// -// This file was generated by snacc on Wed Mar 20 11:39:57 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "asn-useful.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -AsnType *ObjectDescriptor::Clone() const -{ - return new ObjectDescriptor; -} - -AsnType *ObjectDescriptor::Copy() const -{ - return new ObjectDescriptor (*this); -} - -AsnLen ObjectDescriptor::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OD_TAG_CODE); - return l; -} - -void ObjectDescriptor::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE))) - { - Asn1Error << "ObjectDescriptor::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(50); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *UTF8String::Clone() const -{ - return new UTF8String; -} - -AsnType *UTF8String::Copy() const -{ - return new UTF8String (*this); -} - -AsnLen UTF8String::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, 12); - return l; -} - -void UTF8String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, 12)) - && (tag != MAKE_TAG_ID (UNIV, CONS, 12))) - { - Asn1Error << "UTF8String::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(49); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *NumericString::Clone() const -{ - return new NumericString; -} - -AsnType *NumericString::Copy() const -{ - return new NumericString (*this); -} - -AsnLen NumericString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); - return l; -} - -void NumericString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE))) - { - Asn1Error << "NumericString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(48); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *PrintableString::Clone() const -{ - return new PrintableString; -} - -AsnType *PrintableString::Copy() const -{ - return new PrintableString (*this); -} - -AsnLen PrintableString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - return l; -} - -void PrintableString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) - { - Asn1Error << "PrintableString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(47); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *TeletexString::Clone() const -{ - return new TeletexString; -} - -AsnType *TeletexString::Copy() const -{ - return new TeletexString (*this); -} - -AsnLen TeletexString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} - -void TeletexString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error << "TeletexString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(46); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *T61String::Clone() const -{ - return new T61String; -} - -AsnType *T61String::Copy() const -{ - return new T61String (*this); -} - -AsnLen T61String::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} - -void T61String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error << "T61String::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(45); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *VideotexString::Clone() const -{ - return new VideotexString; -} - -AsnType *VideotexString::Copy() const -{ - return new VideotexString (*this); -} - -AsnLen VideotexString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE); - return l; -} - -void VideotexString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, VIDEOTEXSTRING_TAG_CODE))) - { - Asn1Error << "VideotexString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(44); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *IA5String::Clone() const -{ - return new IA5String; -} - -AsnType *IA5String::Copy() const -{ - return new IA5String (*this); -} - -AsnLen IA5String::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, IA5STRING_TAG_CODE); - return l; -} - -void IA5String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) - { - Asn1Error << "IA5String::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(43); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *GraphicString::Clone() const -{ - return new GraphicString; -} - -AsnType *GraphicString::Copy() const -{ - return new GraphicString (*this); -} - -AsnLen GraphicString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GRAPHICSTRING_TAG_CODE); - return l; -} - -void GraphicString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GRAPHICSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, GRAPHICSTRING_TAG_CODE))) - { - Asn1Error << "GraphicString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(42); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *VisibleString::Clone() const -{ - return new VisibleString; -} - -AsnType *VisibleString::Copy() const -{ - return new VisibleString (*this); -} - -AsnLen VisibleString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} - -void VisibleString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error << "VisibleString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(41); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *ISO646String::Clone() const -{ - return new ISO646String; -} - -AsnType *ISO646String::Copy() const -{ - return new ISO646String (*this); -} - -AsnLen ISO646String::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} - -void ISO646String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error << "ISO646String::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(40); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *GeneralString::Clone() const -{ - return new GeneralString; -} - -AsnType *GeneralString::Copy() const -{ - return new GeneralString (*this); -} - -AsnLen GeneralString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALSTRING_TAG_CODE); - return l; -} - -void GeneralString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GENERALSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, GENERALSTRING_TAG_CODE))) - { - Asn1Error << "GeneralString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(39); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *UTCTime::Clone() const -{ - return new UTCTime; -} - -AsnType *UTCTime::Copy() const -{ - return new UTCTime (*this); -} - -AsnLen UTCTime::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE); - return l; -} - -void UTCTime::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))) - { - Asn1Error << "UTCTime::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(38); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *GeneralizedTime::Clone() const -{ - return new GeneralizedTime; -} - -AsnType *GeneralizedTime::Copy() const -{ - return new GeneralizedTime (*this); -} - -AsnLen GeneralizedTime::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - return l; -} - -void GeneralizedTime::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - Asn1Error << "GeneralizedTime::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(37); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *UniversalString::Clone() const -{ - return new UniversalString; -} - -AsnType *UniversalString::Copy() const -{ - return new UniversalString (*this); -} - -AsnLen UniversalString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, UNIVERSALSTRING_TAG_CODE); - return l; -} - -void UniversalString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE))) - { - Asn1Error << "UniversalString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(36); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *BMPString::Clone() const -{ - return new BMPString; -} - -AsnType *BMPString::Copy() const -{ - return new BMPString (*this); -} - -AsnLen BMPString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BMPSTRING_TAG_CODE); - return l; -} - -void BMPString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE))) - { - Asn1Error << "BMPString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(35); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -EXTERNALChoice::EXTERNALChoice() -{ - choiceId = single_ASN1_typeCid; -#if TCL - single_ASN1_type = new AsnOcts; -#else - single_ASN1_type = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice &) -{ - Asn1Error << "use of incompletely defined EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice &)" << endl; - abort(); -} - -EXTERNALChoice::~EXTERNALChoice() -{ - switch (choiceId) - { - case single_ASN1_typeCid: - delete single_ASN1_type; - break; - case octet_alignedCid: - delete octet_aligned; - break; - case arbitraryCid: - delete arbitrary; - break; - } // end of switch -} // end of destructor - -AsnType *EXTERNALChoice::Clone() const -{ - return new EXTERNALChoice; -} - -AsnType *EXTERNALChoice::Copy() const -{ - return new EXTERNALChoice (*this); -} - -#if SNACC_DEEP_COPY -EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &that) -#else // SNACC_DEEP_COPY -EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case single_ASN1_typeCid: - delete single_ASN1_type; - break; - case octet_alignedCid: - delete octet_aligned; - break; - case arbitraryCid: - delete arbitrary; - break; - } - switch (choiceId = that.choiceId) - { - case single_ASN1_typeCid: - single_ASN1_type = new AsnOcts; - *single_ASN1_type = *that.single_ASN1_type; - break; - case octet_alignedCid: - octet_aligned = new AsnOcts; - *octet_aligned = *that.octet_aligned; - break; - case arbitraryCid: - arbitrary = new AsnBits; - *arbitrary = *that.arbitrary; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EXTERNALChoice::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case single_ASN1_typeCid: - BEncEocIfNec (b); - l = single_ASN1_type->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - break; - - case octet_alignedCid: - l = octet_aligned->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 1); - break; - - case arbitraryCid: - l = arbitrary->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 2); - break; - - } // end switch - return l; -} // EXTERNALChoice::BEncContent - - -void EXTERNALChoice::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen1; - switch (tag) - { - case MAKE_TAG_ID (CNTX, CONS, 0): - tag = BDecTag (b, bytesDecoded, env); - if ((tag != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(34); - } - - elmtLen1 = BDecLen (b, bytesDecoded, env); - choiceId = single_ASN1_typeCid; - single_ASN1_type = new AsnOcts; - single_ASN1_type->BDecContent (b, tag, elmtLen1, bytesDecoded, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 1): - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = octet_alignedCid; - octet_aligned = new AsnOcts; - octet_aligned->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 2): - case MAKE_TAG_ID (CNTX, CONS, 2): - choiceId = arbitraryCid; - arbitrary = new AsnBits; - arbitrary->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(33); - break; - } // end switch -} // EXTERNALChoice::BDecContent - - -AsnLen EXTERNALChoice::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void EXTERNALChoice::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void EXTERNALChoice::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case single_ASN1_typeCid: - os << "single-ASN1-type "; - if (single_ASN1_type) - os << *single_ASN1_type; - else - os << "-- void3 --\n"; - break; - - case octet_alignedCid: - os << "octet-aligned "; - if (octet_aligned) - os << *octet_aligned; - else - os << "-- void3 --\n"; - break; - - case arbitraryCid: - os << "arbitrary "; - if (arbitrary) - os << *arbitrary; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // EXTERNALChoice::Print - -EXTERNAL::EXTERNAL() -{ - direct_reference = NULL; - indirect_reference = NULL; - data_value_descriptor = NULL; -#if TCL - encoding = new EXTERNALChoice; -#else - encoding = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EXTERNAL::EXTERNAL (const EXTERNAL &) -{ - Asn1Error << "use of incompletely defined EXTERNAL::EXTERNAL (const EXTERNAL &)" << endl; - abort(); -} - -EXTERNAL::~EXTERNAL() -{ - delete direct_reference; - delete indirect_reference; - delete data_value_descriptor; - delete encoding; -} - -AsnType *EXTERNAL::Clone() const -{ - return new EXTERNAL; -} - -AsnType *EXTERNAL::Copy() const -{ - return new EXTERNAL (*this); -} - -#if SNACC_DEEP_COPY -EXTERNAL &EXTERNAL::operator = (const EXTERNAL &that) -#else // SNACC_DEEP_COPY -EXTERNAL &EXTERNAL::operator = (const EXTERNAL &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.direct_reference) - { - if (!direct_reference) - direct_reference = new AsnOid; - *direct_reference = *that.direct_reference; - } - else - { - delete direct_reference; - direct_reference = NULL; - } - if (that.indirect_reference) - { - if (!indirect_reference) - indirect_reference = new AsnInt; - *indirect_reference = *that.indirect_reference; - } - else - { - delete indirect_reference; - indirect_reference = NULL; - } - if (that.data_value_descriptor) - { - if (!data_value_descriptor) - data_value_descriptor = new ObjectDescriptor; - *data_value_descriptor = *that.data_value_descriptor; - } - else - { - delete data_value_descriptor; - data_value_descriptor = NULL; - } - if (that.encoding) - { - if (!encoding) - encoding = new EXTERNALChoice; - *encoding = *that.encoding; - } - else - { - delete encoding; - encoding = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EXTERNAL &EXTERNAL::operator = (const EXTERNAL &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EXTERNAL::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = encoding->BEncContent (b); - totalLen += l; - - if (NOT_NULL (data_value_descriptor)) - { - l = data_value_descriptor->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OD_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (indirect_reference)) - { - l = indirect_reference->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (direct_reference)) - { - l = direct_reference->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - } - - return totalLen; -} // EXTERNAL::BEncContent - - -void EXTERNAL::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - direct_reference = new AsnOid; - direct_reference->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - indirect_reference = new AsnInt; - indirect_reference->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - data_value_descriptor = new ObjectDescriptor; - data_value_descriptor->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 2)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encoding = new EXTERNALChoice; - encoding->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(32); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(31); - } - else - return; -} // EXTERNAL::BDecContent - -AsnLen EXTERNAL::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, EXTERNAL_TAG_CODE); - return l; -} - -void EXTERNAL::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, EXTERNAL_TAG_CODE)) - { - Asn1Error << "EXTERNAL::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(30); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EXTERNAL::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (direct_reference)) - { - Indent (os, indentG); - os << "direct-reference "; - os << *direct_reference; - } - else - { - Indent (os, indentG); - os << "direct-reference "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (indirect_reference)) - { - Indent (os, indentG); - os << "indirect-reference "; - os << *indirect_reference; - } - else - { - Indent (os, indentG); - os << "indirect-reference "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (data_value_descriptor)) - { - Indent (os, indentG); - os << "data-value-descriptor "; - os << *data_value_descriptor; - } - else - { - Indent (os, indentG); - os << "data-value-descriptor "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (encoding)) - { - Indent (os, indentG); - os << "encoding "; - os << *encoding; - } - else - { - Indent (os, indentG); - os << "encoding "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EXTERNAL::Print - - diff --git a/SecuritySNACCRuntime/c++-lib/c++/hash.cpp b/SecuritySNACCRuntime/c++-lib/c++/hash.cpp deleted file mode 100644 index 85e186a1..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/hash.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/hash.C -// -// This was borrowed from Don Acton and Terry Coatta's Raven Code. -// It has been modified somewhat. -// - Mike Sample 92 -// -// This is a set or routines that implements an extensible hashing -// algorithm. At the moment it assumes that all the hash codes are unique -// (ie. there are no collisions). For the way hash codes are currently being -// supplied this is not a bad assumption. -// The extensible hashing routine used is based on a multiway tree with -// each node in the tree being a fixed array of (2^n) size. At a given -// level, i, in the tree with the first level being level 0, bits -// i*n through i*n through (i+1)*n-1 are used as the index into the table. -// Each entry in the table is either NULL (unused) or a pointer to an -// object of type entry. The entry contains all the information about a -// hash entry. The entry also contains a field indicating whether or not this -// is a leaf node. If an entry isn't a leaf node then it references a table at -// at the next level and not a value. With the current implementation -// a 32 hash value is used and table sizes are 256. The algorithm used -// here is the same as the one used in the Set class of the Raven -// class system. -// -// Copyright (C) 1992 the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/hash.cpp,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: hash.cpp,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1 2000/06/15 18:44:58 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:36 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:56 mb -// Added snacc c++ library -// -// Revision 1.7 1997/02/28 13:39:46 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.6 1997/02/16 20:26:08 rj -// check-in of a few cosmetic changes -// -// Revision 1.5 1995/07/24 20:34:07 rj -// use memzero that is defined in .../snacc.h to use either memset or bzero. -// -// changed `_' to `-' in file names. -// -// Revision 1.4 1994/10/08 04:18:32 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.3 1994/08/31 23:43:05 rj -// FALSE/TRUE turned into false/true -// -// Revision 1.2 1994/08/28 10:01:21 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:21:11 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-config.h" -#include "hash.h" - - -/* - * - * From sdbm, an ndbm work-alike hashed database library - * Author: oz@nexus.yorku.ca - * Status: public domain. - * - * polynomial conversion ignoring overflows - * [this seems to work remarkably well, in fact better - * then the ndbm hash function. Replace at your own risk] - * use: 65599 nice. - * 65587 even better. - * - * [In one experiment, this function hashed 84165 symbols (English words - * plus symbol table values) with no collisions. -bjb] - * - */ - -Hash -MakeHash (const char *str, size_t len) -{ - register Hash n = 0; - -#define HASHC n = *str++ + 65587 * n - - if (len > 0) - { - int loop; - loop = (len + 8 - 1) >> 3; - switch (len & (8 - 1)) - { - case 0: /* very strange! - switch labels in do loop */ - do - { - HASHC; - case 7: HASHC; - case 6: HASHC; - case 5: HASHC; - case 4: HASHC; - case 3: HASHC; - case 2: HASHC; - case 1: HASHC; - } while (--loop); - } - } - return n; -} - - -/* Creates and clears a new hash slot */ -static HashSlot * -NewHashSlot() -{ - HashSlot *foo; - - foo = new HashSlot; - if (foo == NULL) - return NULL; - memzero (foo, sizeof (HashSlot)); - return foo; -} - -/* Create a new cleared hash table */ -static Table * -NewTable() -{ - Table *new_table; - -// new_table = new Table; -// whose bug is it that gcc won't compile the above line? - new_table = (Table *) new Table; - if (new_table == NULL) - return NULL; - memzero (new_table, sizeof (Table)); - return new_table; -} - -/* This routine is used to initialize the hash tables. When it is called - * it returns a value which is used to identify which hash table - * a particular request is to operate on. - */ -Table * -InitHash() -{ - Table *table; - table = NewTable(); - if (table == NULL) - return 0; - else - return table; -} - -/* When a hash collision occurs at a leaf slot this routine is called to - * split the entry and add a new level to the tree at this point. - */ -static int -SplitAndInsert (HashSlot *entry, void *element, Hash hash_value) -{ - - if (((entry->table = NewTable()) == NULL) || - !Insert (entry->table, entry->value, entry->hash >> INDEXSHIFT) || - !Insert (entry->table, element, hash_value >> INDEXSHIFT)) - return false; - - entry->leaf = false; - return true; -} - -/* This routine takes a hash table identifier, an element (value) and the - * coresponding hash value for that element and enters it into the table - * assuming it isn't already there. - */ -int -Insert (Table *table, void *element, Hash hash_value) -{ - HashSlot *entry; - - entry = (HashSlot *) (*table)[hash_value & INDEXMASK]; - - if (entry == NULL) { - /* Need to add this element here */ - entry = NewHashSlot(); - if (entry == NULL) - return false; - entry->leaf = true; - entry->value = element; - entry->hash = hash_value; - (*table)[hash_value & INDEXMASK] = entry; - return true; - } - - if (hash_value == entry->hash) - return true; - - if (entry->leaf) - return SplitAndInsert (entry, element, hash_value); - - return Insert (entry->table, element, hash_value >> INDEXSHIFT); -} - - -/* This routine looks to see if a particular hash value is already stored in - * the table. It returns true if it is and false otherwise. - */ -int -CheckFor (Table *table, Hash hash) -{ - HashSlot *entry; - - entry = (HashSlot *) table[hash & INDEXMASK]; - - if (entry == NULL) - return false; - if (entry->leaf) - return entry->hash == hash; - return CheckFor (entry->table, hash >> INDEXSHIFT); -} - -/* In addition to checking for a hash value in the tree this function also - * returns the coresponding element value into the space pointed to by - * the value parameter. If the hash value isn't found false is returned - * the the space pointed to by value is not changed. - */ -int -CheckForAndReturnValue (Table *table, Hash hash, void **value) -{ - HashSlot *entry; - entry = (HashSlot *) (*table)[hash & INDEXMASK]; - - if (entry == NULL) - return false; - - if (entry->leaf) - { - if (entry->hash == hash) - { - *value = entry->value; - return true; - } - else - return false; - } - return CheckForAndReturnValue (entry->table, hash >> INDEXSHIFT, value); -} diff --git a/SecuritySNACCRuntime/c++-lib/c++/meta.cpp b/SecuritySNACCRuntime/c++-lib/c++/meta.cpp deleted file mode 100644 index dc8f1184..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/meta.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/meta.C -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/meta.cpp,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: meta.cpp,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1 2000/06/15 18:44:58 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:36 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:56 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/28 13:39:47 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.4 1995/08/17 15:23:51 rj -// introducing an AsnEnumTypeDesc class with its own TclGetDesc2 function that returns the value names but omits the numeric values. -// utility function AsnSe_TypeDesc::mandatmemberr added. -// -// Revision 1.3 1995/07/26 19:39:35 rj -// comment leader fixed -// -// Revision 1.2 1995/07/25 22:11:31 rj -// lots of new data types, and new data and function members in old ones. -// -// use memcmpeq that is defined in .../snacc.h to use either memcmp or bcmp. -// -// code extracted from AsnOcts::TclGetVal and AsnOcts::TclSetVal in asn-octs.C into ::debinify and ::binify. -// -// #if TCL ... #endif wrapped into #if META ... #endif -// -// call constructor with additional pdu and create arguments. -// -// changed `_' to `-' in file names. - -#include "asn-incl.h" - -#if META - -AsnMemberDesc::AsnMemberDesc (const char *_name, const AsnTypeDesc *_desc): - name (_name), - desc (_desc) -{ -} - -AsnMemberDesc::AsnMemberDesc(): - name (NULL), desc(NULL) -{ -} - -int AsnMemberDesc::TclGetDesc (Tcl_DString *desc) const -{ - if (name) - { - Tcl_DStringStartSublist (desc); - Tcl_DStringAppendElement (desc, (char*)name); - this->desc->AsnTypeDesc::TclGetDesc (desc); - TclGetDesc2 (desc); - Tcl_DStringEndSublist (desc); - return TCL_OK; - } - else - return TCL_BREAK; -} - -int AsnMemberDesc::TclGetDesc2 (Tcl_DString *desc) const -{ - return TCL_OK; -} - -AsnSe_MemberDesc::AsnSe_MemberDesc (const char *name, const AsnTypeDesc *desc, bool _optional): - AsnMemberDesc (name, desc), - optional (_optional) -{ -} - -AsnSe_MemberDesc::AsnSe_MemberDesc(): - AsnMemberDesc() -{ -} - -int AsnSe_MemberDesc::TclGetDesc2 (Tcl_DString *desc) const -{ - Tcl_DStringAppendElement (desc, optional ? "optional" : "mandatory"); - return TCL_OK; -} - -const char *const AsnTypeDesc::typenames[] = // NOTE: keep this array in sync with the enum Type -{ - "(void)", - "(alias)", - - "INTEGER", - "REAL", - "NULL", - "BOOLEAN", - "ENUMERATED", - "BIT STRING", - "OCTET STRING", - "OBJECT IDENTIFIER", - - "SET", - "SEQUENCE", - "SET OF", - "SEQUENCE OF", - "CHOICE", - "ANY", -}; - -AsnTypeDesc::AsnTypeDesc (const AsnModuleDesc *_module, const char *_name, bool ispdu, Type _type, AsnType *(*_create)()): - module (_module), - name (_name), - pdu (ispdu), - type (_type), - create (_create) -{ -} - -const AsnModuleDesc *AsnTypeDesc::getmodule() const -{ - return module; -} - -const char *AsnTypeDesc::getname() const -{ - return name; -} - -bool AsnTypeDesc::ispdu() const -{ - return pdu; -} - -AsnTypeDesc::Type AsnTypeDesc::gettype() const -{ - return type; -} - -const AsnNameDesc *AsnTypeDesc::getnames() const -{ - Asn1Error << typenames[type] << "::getnames() called" << endl; - abort(); - return NULL; -} - -//const AsnMemberDesc *AsnTypeDesc::getmembers() const -//{ - //Asn1Error << typenames[type] << "::getmembers() called" << endl; - //abort(); -//} - -//\[banner "names types (int, enum)"]----------------------------------------------------------------------------------------------- -AsnNamesTypeDesc::AsnNamesTypeDesc (const AsnModuleDesc *module, const char *name, bool ispdu, Type type, AsnType *(*create)(), const AsnNameDesc *_names): - AsnTypeDesc (module, name, ispdu, type, create), - names (_names) -{ -} - -const AsnNameDesc *AsnNamesTypeDesc::getnames() const -{ - return names; -} - -//\[banner "enum type"]------------------------------------------------------------------------------------------------------------- -AsnEnumTypeDesc::AsnEnumTypeDesc (const AsnModuleDesc *module, const char *name, bool ispdu, Type type, AsnType *(*create)(), const AsnNameDesc *names): - AsnNamesTypeDesc (module, name, ispdu, type, create, names) -{ -} - -//\[banner "members types (choice, set, sequence)"]--------------------------------------------------------------------------------- -AsnMembersTypeDesc::AsnMembersTypeDesc (const AsnModuleDesc *module, const char *name, bool ispdu, Type type, AsnType *(*create)()): - AsnTypeDesc (module, name, ispdu, type, create) -{ -} - -//\[banner "choice type"]----------------------------------------------------------------------------------------------------------- -AsnChoiceTypeDesc::AsnChoiceTypeDesc (const AsnModuleDesc *module, const char *name, bool ispdu, Type type, AsnType *(*create)(), const AsnChoiceMemberDesc *_members): - AsnMembersTypeDesc (module, name, ispdu, type, create), - members (_members) -{ -} - -int AsnChoiceTypeDesc::choicebyname (const char *name) const -{ - for (int m=0; members[m].name; m++) - if (!strcmp (members[m].name, name)) - return m; - - return -1; -} - -const char *AsnChoiceTypeDesc::choicebyvalue (int value) const -{ - return members[value].name; -} - -//\[banner "set/sequence type"]----------------------------------------------------------------------------------------------------- -AsnSe_TypeDesc::AsnSe_TypeDesc (const AsnModuleDesc *module, const char *name, bool ispdu, Type type, AsnType *(*create)(), const AsnSe_MemberDesc *_members): - AsnMembersTypeDesc (module, name, ispdu, type, create), - members (_members) -{ -} - -//\[banner "list type"]------------------------------------------------------------------------------------------------------------- -AsnListTypeDesc::AsnListTypeDesc (const AsnModuleDesc *module, const char *name, bool ispdu, Type type, AsnType *(*create)(), const AsnTypeDesc *_base): - AsnTypeDesc (module, name, ispdu, type, create), - base (_base) -{ -} - -//\[banner "alias type"]------------------------------------------------------------------------------------------------------------ -AsnAliasTypeDesc::AsnAliasTypeDesc (const AsnModuleDesc *module, const char *name, bool ispdu, Type type, AsnType *(*create)(), const AsnTypeDesc *_alias): - AsnTypeDesc (module, name, ispdu, type, create), - alias (_alias) -{ -} - -const AsnModuleDesc *AsnAliasTypeDesc::getmodule() const -{ - return module; -} - -const char *AsnAliasTypeDesc::getname() const -{ - return name; -} - -bool AsnAliasTypeDesc::ispdu() const -{ - return pdu; -} - -AsnTypeDesc::Type AsnAliasTypeDesc::gettype() const -{ - return alias->gettype(); -} - -const AsnNameDesc *AsnAliasTypeDesc::getnames() const -{ - return alias->getnames(); -} - -//const AsnMemberDesc *AsnAliasTypeDesc::getmembers() const -//{ - //return alias->getmembers(); -//} - -//\[banner "Tcl routines"]---------------------------------------------------------------------------------------------------------- -#if TCL - -int AsnTypeDesc::TclGetDesc (Tcl_DString *desc) const -{ - Tcl_DStringStartSublist (desc); - Tcl_DStringAppendElement (desc, getmodule() ? (char*) getmodule()->name : ""); - Tcl_DStringAppendElement (desc, getname() ? (char*) getname() : ""); - Tcl_DStringEndSublist (desc); - Tcl_DStringAppendElement (desc, ispdu() ? "pdu" : "sub"); - Tcl_DStringAppendElement (desc, (char*) typenames[gettype()]); - - return TCL_OK; -} - -int AsnTypeDesc::TclGetDesc2 (Tcl_DString *desc) const -{ - return TCL_OK; -} - -int AsnNamesTypeDesc::TclGetDesc (Tcl_DString *desc) const -{ - AsnTypeDesc::TclGetDesc (desc); - return TclGetDesc2 (desc); -} - -// for BIT STRING and INTEGER: -int AsnNamesTypeDesc::TclGetDesc2 (Tcl_DString *desc) const -{ - Tcl_DStringStartSublist (desc); - const AsnNameDesc *n; - if (n = names) - for (; n->name; n++) - { - Tcl_DStringStartSublist (desc); - Tcl_DStringAppendElement (desc, (char*) n->name); - char buf[32]; - sprintf (buf, "%d", n->value); - Tcl_DStringAppendElement (desc, buf); - Tcl_DStringEndSublist (desc); - } - Tcl_DStringEndSublist (desc); - - return TCL_OK; -} - -int AsnEnumTypeDesc::TclGetDesc2 (Tcl_DString *desc) const -{ - Tcl_DStringStartSublist (desc); - const AsnNameDesc *n; - if (n = names) - for (; n->name; n++) - Tcl_DStringAppendElement (desc, (char*) n->name); - Tcl_DStringEndSublist (desc); - - return TCL_OK; -} - -int AsnMembersTypeDesc::TclGetDesc (Tcl_DString *desc) const -{ - AsnTypeDesc::TclGetDesc (desc); - return TclGetDesc2 (desc); -} - -int AsnChoiceTypeDesc::TclGetDesc2 (Tcl_DString *desc) const -{ - Tcl_DStringStartSublist (desc); - const AsnChoiceMemberDesc *m; - if (m = members) - for (; m->TclGetDesc (desc) == TCL_OK; m++) - ; - Tcl_DStringEndSublist (desc); - - return TCL_OK; -} - -int AsnSe_TypeDesc::mandatmemberr (Tcl_Interp *interp, const char *membername) const -{ - sprintf (interp->result, "(in type %s.%s:) member %s is mandatory and can't be deleted", getmodule()->name, getname(), membername); - Tcl_SetErrorCode (interp, "SNACC", "MANDMEMB", NULL); - return TCL_ERROR; -} - -int AsnSe_TypeDesc::TclGetDesc2 (Tcl_DString *desc) const -{ - Tcl_DStringStartSublist (desc); - const AsnSe_MemberDesc *m; - if (m = members) - for (; m->TclGetDesc (desc) == TCL_OK; m++) - ; - Tcl_DStringEndSublist (desc); - - return TCL_OK; -} - -int AsnListTypeDesc::TclGetDesc (Tcl_DString *desc) const -{ - AsnTypeDesc::TclGetDesc (desc); - return base->AsnTypeDesc::TclGetDesc (desc); -} - -int AsnAliasTypeDesc::TclGetDesc (Tcl_DString *desc) const -{ - AsnTypeDesc::TclGetDesc (desc); - return alias->TclGetDesc2 (desc); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -// designed to be used with Tcl_SplitList(): argument list that automagically frees itself when it goes out of scope: -Args::Args() -{ - v = NULL; -} - -Args::~Args() -{ - if (v) - free (v); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -// since Tcl cannot handle binary strings, the following hack is needed: - -int debinify (Tcl_Interp *interp, const char *bin, size_t len) -{ - char* str; - int i, o; - -#ifndef _IBM_ENC_ - str = new char[2*len+1]; -#else - str = (char *) mem_mgr_ptr->Get (2*len+2); -#endif /* _IBM_ENC_ */ - - - for (o=i=0; iPut ((void*) str); -#endif /* _IBM_ENC_ */ - - return TCL_OK; -} - -int binify (Tcl_Interp *interp, const char *str, char *buf, size_t *len) -{ - for (*len=0; *str; ) - if (*str == '\\') - switch (*++str) - { - case '0': - buf[(*len)++] = '\0'; - str++; - break; - case '\\': - buf[(*len)++] = *str++; - break; - default: - Tcl_AppendResult (interp, "illegal use of '\\' in string value", NULL); - Tcl_SetErrorCode (interp, "SNACC", "ILLESC", NULL); - return TCL_ERROR; - } - else - buf[(*len)++] = *str++; - - return TCL_OK; -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -#endif // TCL - -#endif // META diff --git a/SecuritySNACCRuntime/c++-lib/c++/print.cpp b/SecuritySNACCRuntime/c++-lib/c++/print.cpp deleted file mode 100644 index 910d49ca..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/print.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/print.C -// -// MS 92 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/print.cpp,v 1.4 2001/06/28 22:49:58 mb Exp $ -// $Log: print.cpp,v $ -// Revision 1.4 2001/06/28 22:49:58 mb -// Saved 4 bytes of data when compiling with -DNDEBUG -// -// Revision 1.3 2001/06/27 23:57:50 dmitch -// Reimplement partial fix for Radar 2664258: Print() routines are now empty stubs in NDEBUG config. -// -// Revision 1.2 2001/06/27 23:09:15 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1 2000/06/15 18:44:58 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:36 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:56 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/16 20:26:09 rj -// check-in of a few cosmetic changes -// -// Revision 1.4 1995/07/24 20:34:55 rj -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:33 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:22 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:21:12 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-incl.h" - -#ifndef NDEBUG -// the generated operator << routines for aggregate types use these globals -unsigned short int indentG = 0; -unsigned short int stdIndentG = 4; -#endif - -void -Indent (ostream &os, unsigned short int i) -{ -#ifndef NDEBUG - while (i-->0) - os << ' '; -#endif -} - -ostream &operator << (ostream &os, const AsnType &v) -{ -#ifndef NDEBUG - v.Print (os); -#endif - return os; -} diff --git a/SecuritySNACCRuntime/c++-lib/c++/str-stk.cpp b/SecuritySNACCRuntime/c++-lib/c++/str-stk.cpp deleted file mode 100644 index 8c57566c..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/str-stk.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/str-stk.C -// -// MS 92/07/06 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/str-stk.cpp,v 1.2 2002/02/07 04:30:04 mb Exp $ -// $Log: str-stk.cpp,v $ -// Revision 1.2 2002/02/07 04:30:04 mb -// Fixes required to build with gcc3. -// Merged from branch PR-2848996 -// Bug #: 2848996 -// Submitted by: -// Reviewed by: Turly O'Connor -// -// Revision 1.1.1.1.12.1 2002/02/06 23:45:03 mb -// Changes to allow building with gcc3 -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/12/07 22:16:57 dmitch -// Thread-safe mods: removed global StrStk strStkG. -// -// -// 2000/12/7 dmitch -// #ifdef'd out strStkG for thread safety -// -// Revision 1.1 2000/06/15 18:44:58 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:37 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/06/04 21:43:21 mb -// Fixed several memory leaks. -// -// Revision 1.1 1999/02/25 05:21:57 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/16 20:26:11 rj -// check-in of a few cosmetic changes -// -// Revision 1.4 1995/07/24 20:34:57 rj -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:15:22 rj -// fixed both Copy()'s name and implementation to CopyOut() that always returns the number of bytes copied out instead of 0 in case less than the requested amount is available. -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:24 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:21:13 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#include "asn-config.h" -#include "str-stk.h" - -#ifndef __APPLE__ -/* clients each have their own for OS X */ -// global for use by AsnBits and AsnOcts - -StrStk strStkG (128, 64); -#endif /* 0 */ - -StrStk::StrStk (int stkSize, int growIncrement) -{ - stk = new struct Elmt[stkSize]; - size = stkSize; - growSize = growIncrement; -} - -StrStk::~StrStk () -{ - delete stk; -} - -void StrStk::Reset() -{ - nextFreeElmt = 0; - totalByteLen = 0; -} - -void StrStk::Push (char *str, size_t strLen) -{ - if (nextFreeElmt >= size) - { - struct Elmt *tmpStk; - // alloc bigger stack and copy old elmts to it - tmpStk = new struct Elmt[size + growSize]; - for (size_t i = 0; i < size; i++) - tmpStk[i] = stk[i]; - delete stk; - stk = tmpStk; - size += growSize; - } - totalByteLen += strLen; - stk[nextFreeElmt].str = str; - stk[nextFreeElmt++].len = strLen; -} - -/* - * copy string pieces (buffer refs) into single block. - * assumes that the buf is at least totalByteLen byte long. - */ -void StrStk::CopyOut (char *buf) -{ - unsigned long int curr; - char *bufCurr; - - bufCurr = buf; - for (curr = 0; curr < nextFreeElmt; curr++) - { - memcpy (bufCurr, stk[curr].str, stk[curr].len); - bufCurr += stk[curr].len; - } -} diff --git a/SecuritySNACCRuntime/c++-lib/c++/tcl-if.cpp b/SecuritySNACCRuntime/c++-lib/c++/tcl-if.cpp deleted file mode 100644 index 7547c3c3..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/tcl-if.cpp +++ /dev/null @@ -1,1103 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/src/tcl-if.C -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/tcl-if.cpp,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: tcl-if.cpp,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.2 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.1 2000/06/15 18:44:58 dmitch -// These snacc-generated source files are now checked in to allow cross-platform build. -// -// Revision 1.2 2000/06/08 20:05:37 dmitch -// Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... -// -// Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/02/26 00:23:41 mb -// Fixed for Mac OS 8 -// -// Revision 1.1 1999/02/25 05:21:57 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/28 13:39:47 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.5 1997/01/01 23:24:35 rj -// `typename' appears to be a reserved word in gcc 2.7, so prefix it with `_' -// -// Revision 1.4 1995/09/07 18:57:13 rj -// duplicate code merged into a new function SnaccTcl::gettypedesc(). -// -// Revision 1.3 1995/08/17 15:09:09 rj -// snacced.[hC] renamed to tcl-if.[hC]. -// class SnaccEd renamed to SnaccTcl. -// set Tcl's errorCode variable. -// -// Revision 1.2 1995/07/27 09:53:38 rj -// comment leader fixed -// -// Revision 1.1 1995/07/27 09:52:22 rj -// new file: tcl interface used by snacced. - -#if !defined(macintosh) && !defined(__APPLE__) -#include -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include "asn-incl.h" - -#if TCL - -#ifdef _AIX32 -extern "C" int strncasecmp (const char* s1, const char* s2, size_t number); -extern "C" int strcasecmp (const char* s1, const char* s2); -#endif - -#include "tcl-if.h" -#include "init.h" - -//\[banner "utility functions"]----------------------------------------------------------------------------------------------------- -static bool strniabbr (const char *pattern, const char *test, size_t min) -{ - register len; - - if (strlen (pattern)create(); - fn = NULL; - fd = -1; - filesize = 0; -} - -ASN1File::ASN1File (const AsnTypeDesc *typedesc, const char *_fn, int _fd) -{ - type = typedesc; - pdu = type->create(); - - int fnlen = strlen (_fn) + 1; - fn = new char [fnlen]; - memcpy (fn, _fn, fnlen); - - fd = _fd; -} - -ASN1File::~ASN1File() -{ - delete pdu; - delete fn; - if (fd >= 0) - close (fd); -} - -bool ASN1File::bad() -{ - return fd < 0; -} - -int ASN1File::finfo (Tcl_Interp *interp) -{ - Tcl_AppendElement (interp, fn ? fn : ""); - char *acc = "bad"; - if (!bad()) - { - int flags; - if ((flags = fcntl (fd, F_GETFL)) != -1) - switch (flags & O_ACCMODE) - { - case O_RDONLY: - acc = "ro"; - break; - case O_WRONLY: - acc = "wo"; - break; - case O_RDWR: - acc = "rw"; - break; - } - } - Tcl_AppendElement (interp, acc); - - return TCL_OK; -} - -int ASN1File::read (Tcl_Interp *interp, const char *rfn) -{ - int rfd; - TmpFD tmpfd; - - delete pdu; - pdu = type->create(); - - if (rfn) - { - if ((rfd = open (rfn, O_RDONLY)) < 0) - { - Tcl_AppendResult (interp, "can't open \"", rfn, "\": ", Tcl_PosixError (interp), NULL); - return TCL_ERROR; - } - tmpfd = rfd; - } - else if (fd < 0) - { - Tcl_AppendResult (interp, "can't read, file is not open", NULL); - Tcl_SetErrorCode (interp, "SNACC", "MUSTOPEN", NULL); - return TCL_ERROR; - } - else - { - rfn = fn; - lseek (rfd = fd, 0l, SEEK_SET); - } - - struct stat statbuf; - if (fstat (rfd, &statbuf)) - { - Tcl_AppendResult (interp, "can't fstat \"", rfn, "\": ", Tcl_PosixError (interp), NULL); - return TCL_ERROR; - } - - filesize = statbuf.st_size; - - char* buf = new char[filesize]; - if (::read (rfd, buf, filesize) != filesize) - { - Tcl_AppendResult (interp, "can't read \"", rfn, "\": ", Tcl_PosixError (interp), NULL); - delete buf; - return TCL_ERROR; - } - - AsnBuf inputBuf; - inputBuf.InstallData (buf, filesize); - - size_t decodedLen = 0; - jmp_buf env; - int eval; - if (eval = setjmp (env)) - { - char eno[80]; - sprintf (eno, "%d", eval); - Tcl_AppendResult (interp, "can't decode (error ", eno, ")", NULL); - Tcl_SetErrorCode (interp, "SNACC", "DECODE", eno, NULL); - delete buf; - return TCL_ERROR; - } - pdu->BDec (inputBuf, decodedLen, env); - if (inputBuf.ReadError()) - { - Tcl_AppendResult (interp, "can't decode, out of data", NULL); - Tcl_SetErrorCode (interp, "SNACC", "DECODE", "EOBUF", NULL); - delete buf; - return TCL_ERROR; - } - -#if DEBUG -cout << "DECODED:" << endl << *pdu << endl; -#endif - - if (decodedLen != filesize) - sprintf (interp->result, "decoded %d of %d bytes", decodedLen, filesize); - - delete buf; - return TCL_OK; -} - -int ASN1File::write (Tcl_Interp *interp, const char *wfn) -{ - int wfd; - TmpFD tmpfd; - - if (wfn) - { - if ((wfd = open (wfn, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0) - { - Tcl_AppendResult (interp, "can't open \"", wfn, "\": ", Tcl_PosixError (interp), NULL); - return TCL_ERROR; - } - tmpfd = wfd; - } - else if (fd < 0) - { - Tcl_AppendResult (interp, "can't write, file is not open", NULL); - Tcl_SetErrorCode (interp, "SNACC", "MUSTOPEN", NULL); - return TCL_ERROR; - } - else - { - wfn = fn; - int flags; - if ((flags = fcntl (fd, F_GETFL)) == -1) - { - Tcl_AppendResult (interp, "can't fcntl \"", wfn, "\": ", Tcl_PosixError (interp), NULL); - return TCL_ERROR; - } - else - { - if ((flags & O_ACCMODE) == O_RDONLY) - { - Tcl_AppendResult (interp, "can't write, file is read only", NULL); - Tcl_SetErrorCode (interp, "SNACC", "WRITE", "RDONLY", NULL); - return TCL_ERROR; - } - } - lseek (wfd = fd, 0l, SEEK_SET); - } - - size_t size = filesize ? filesize : 10240; - char *buf; - AsnBuf outputBuf; - size_t encodedLen; - for (;;) - { - size <<= 1; - buf = new char[size]; - outputBuf.Init (buf, size); - outputBuf.ResetInWriteRvsMode(); - encodedLen = pdu->BEnc (outputBuf); - if (!outputBuf.WriteError()) - break; - delete buf; - } - - outputBuf.ResetInReadMode(); - size_t hunklen = 8192; - char* hunk = new char[hunklen]; - for (size_t written=0; writtenresult, "wrong # args: should be \"snacc import filename\""); - return TCL_ERROR; - } - - const char *fn = argv[1]; - int fd; - if ((fd = open (fn, O_RDONLY)) < 0) - { - Tcl_AppendResult (interp, "can't open \"", fn, "\": ", Tcl_PosixError (interp), NULL); - return TCL_ERROR; - } - TmpFD tmpfd (fd); - - struct stat statbuf; - if (fstat (fd, &statbuf)) - { - Tcl_AppendResult (interp, "can't fstat \"", fn, "\"'s fd: ", Tcl_PosixError (interp), NULL); - return TCL_ERROR; - } - - off_t filesize = statbuf.st_size; - - char* ibuf = new char[filesize]; - if (::read (fd, ibuf, filesize) != filesize) - { - Tcl_AppendResult (interp, "read error on \"", fn, "\": ", Tcl_PosixError (interp), NULL); - delete ibuf; - return TCL_ERROR; - } - - int result = debinify (interp, ibuf, filesize); - delete ibuf; - return result; -} - -int export (Tcl_Interp *interp, int argc, char **argv) -{ - if (argc != 3) - { - strcpy (interp->result, "wrong # args: should be \"snacc export str filename\""); - return TCL_ERROR; - } - - const char *str = argv[1], *fn = argv[2]; - char* obuf = new char[strlen (str)]; // the binary buffer is as most as long as the escaped Tcl string. - size_t olen; - if (binify (interp, str, obuf, &olen) != TCL_OK) - { - delete obuf; - return TCL_ERROR; - } - - int fd; - if ((fd = open (fn, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0) - { - Tcl_AppendResult (interp, "can't open \"", fn, "\": ", Tcl_PosixError (interp), NULL); - delete obuf; - return TCL_ERROR; - } - TmpFD tmpfd (fd); - - if (::write (fd, obuf, olen) != olen) - { - Tcl_AppendResult (interp, "write error on \"", fn, "\": ", Tcl_PosixError (interp), NULL); - delete obuf; - return TCL_ERROR; - } - - delete obuf; - return TCL_OK; -} - -//\[banner "ctor & dtor"]----------------------------------------------------------------------------------------------------------- -SnaccTcl::SnaccTcl (Tcl_Interp *i) -{ - interp = i; - - Tcl_InitHashTable (&modules, TCL_STRING_KEYS); - Tcl_InitHashTable (&types, TCL_STRING_KEYS); - - const AsnModuleDesc **moddesc; - for (moddesc=asnModuleDescs; *moddesc; moddesc++) - { - int created; - Tcl_HashEntry *entry = Tcl_CreateHashEntry (&modules, (char*)(*moddesc)->name, &created); - assert (created); - Tcl_SetHashValue (entry, *moddesc); - - const AsnTypeDesc **typedesc; - for (typedesc=(*moddesc)->types; *typedesc; typedesc++) - { - char buf[1024]; - sprintf (buf, "%s %s", (*moddesc)->name, (*typedesc)->name); - char *_typename = strdup (buf); - int created; - Tcl_HashEntry *entry = Tcl_CreateHashEntry (&types, _typename, &created); - if (!created) - { - cerr << "fatal error: duplicate type " << _typename << endl; - exit (1); - } - Tcl_SetHashValue (entry, *typedesc); - } - } - - Tcl_InitHashTable (&files, TCL_STRING_KEYS); -} - -SnaccTcl::~SnaccTcl() -{ - Tcl_DeleteHashTable (&files); -} - -//\[banner "utility functions"]----------------------------------------------------------------------------------------------------- -const AsnTypeDesc *SnaccTcl::gettypedesc (const char *cmdname, const char *_typename) -{ - Tcl_HashEntry *typedescentry; - if (typedescentry = Tcl_FindHashEntry (&types, (char*)_typename)) - return (const AsnTypeDesc *)Tcl_GetHashValue (typedescentry); - else - { - Tcl_SetErrorCode (interp, "SNACC", "ILLTYPE", NULL); - Tcl_AppendResult (interp, "snacc ", cmdname, ": no type \"", _typename, "\"", NULL); - return NULL; - } -} - -//\[banner "data manipulation functions"]------------------------------------------------------------------------------------------- -Tcl_HashEntry *SnaccTcl::create() -{ - static unsigned int id; - int created; - Tcl_HashEntry *entry; - do - { - sprintf (interp->result, "file%u", id++); - entry = Tcl_CreateHashEntry (&files, interp->result, &created); - } - while (!created); - return entry; -} - -int SnaccTcl::create (int argc, char **argv) -{ - if (argc != 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc create {module type}\""); - return TCL_ERROR; - } - - const char *_typename = argv[1]; - const AsnTypeDesc *typedesc; - if (!(typedesc = gettypedesc ("type", _typename))) - return TCL_ERROR; - - Tcl_HashEntry *entry = create(); - ASN1File *file = new ASN1File (typedesc); - Tcl_SetHashValue (entry, file); - - return TCL_OK; -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -// snacc open {module type} filename ?flags? ?permissions? - -int SnaccTcl::openfile (int argc, char **argv) -{ - if (argc < 3 || argc > 5) - { - strcpy (interp->result, "wrong # args: should be \"snacc open {module type} filename ?flags? ?permissions?\""); - return TCL_ERROR; - } - - const char *_typename = argv[1]; - const char *filename = argv[2]; - bool rw_spec = false; - int oflags = 0, omode = 0666, fd = -1; - - switch (argc) - { - case 5: - if (Tcl_GetInt (interp, argv[4], &omode)) - return TCL_ERROR; - // \(da fall thru - case 4: - { - Args flags; - if (Tcl_SplitList (interp, argv[3], &flags.c, &flags.v) != TCL_OK) - return TCL_ERROR; - - for (int i=0; ibad()) - { - delete file; - Tcl_AppendResult (interp, "internal error on \"", filename, "\": bad status", NULL); - Tcl_SetErrorCode (interp, "SNACC", "OPEN", "BAD", NULL); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = create(); - Tcl_SetHashValue (entry, file); - - return file->read (interp); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::finfo (int argc, char **argv) -{ - if (argc != 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc finfo file\""); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, argv[1]); - if (!entry) - { - Tcl_AppendResult (interp, "no file named \"", argv[1], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - - return file->finfo (interp); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -// snacc read file ?{module type} filename? - -int SnaccTcl::read (int argc, char **argv) -{ - const char *_typename, *filename; - - switch (argc) - { - case 2: // reread from old fd - _typename = filename = NULL; - break; - case 4: - _typename = argv[2]; - filename = argv[3]; - break; - default: - strcpy (interp->result, "wrong # args: should be \"snacc read file ?{module type} filename?\""); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, argv[1]); - if (!entry) - { - Tcl_AppendResult (interp, "no file named \"", argv[1], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - - if (_typename) - { - const AsnTypeDesc *typedesc; - if (!(typedesc = gettypedesc ("read", _typename))) - return TCL_ERROR; - - delete file; - file = new ASN1File (typedesc); - Tcl_SetHashValue (entry, file); - } - - return file->read (interp, filename); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::write (int argc, char **argv) -{ - if (argc < 2 || argc > 3) - { - strcpy (interp->result, "wrong # args: should be \"snacc write file ?filename?\""); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, argv[1]); - if (!entry) - { - Tcl_AppendResult (interp, "no file named \"", argv[1], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - - return file->write (interp, argv[2]); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::closefile (int argc, char **argv) -{ - if (argc != 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc close file\""); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, argv[1]); - if (!entry) - { - Tcl_AppendResult (interp, "no file named \"", argv[1], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - delete file; - - Tcl_DeleteHashEntry (entry); - - return TCL_OK; -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::modulesinfo (int argc, char **argv) -{ - if (argc != 1) - { - strcpy (interp->result, "wrong # args: should be \"snacc modules\""); - return TCL_ERROR; - } - - Tcl_HashEntry *moduleentry; - Tcl_HashSearch hi; - for (moduleentry=Tcl_FirstHashEntry (&modules, &hi); moduleentry; moduleentry=Tcl_NextHashEntry (&hi)) - Tcl_AppendElement (interp, Tcl_GetHashKey (&modules, moduleentry)); - - return TCL_OK; -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::typesinfo (int argc, char **argv) -{ - switch (argc) - { - case 1: - Tcl_HashEntry *typeentry; - Tcl_HashSearch hi; - for (typeentry=Tcl_FirstHashEntry (&types, &hi); typeentry; typeentry=Tcl_NextHashEntry (&hi)) - Tcl_AppendElement (interp, Tcl_GetHashKey (&types, typeentry)); - return TCL_OK; - case 2: - Tcl_HashEntry *moduleentry; - if (moduleentry = Tcl_FindHashEntry (&modules, argv[1])) - { - const AsnModuleDesc *moddesc = (const AsnModuleDesc *)Tcl_GetHashValue (moduleentry); - const AsnTypeDesc **typedesc; - for (typedesc=moddesc->types; *typedesc; typedesc++) - Tcl_AppendElement (interp, (char*)(*typedesc)->name); - return TCL_OK; - } - else - { - Tcl_AppendResult (interp, "snacc types: no module \"", argv[1], "\"", NULL); - return TCL_ERROR; - } - default: - strcpy (interp->result, "wrong # args: should be \"snacc types ?module?\""); - return TCL_ERROR; - } -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::typeinfo (int argc, char **argv) -{ - if (argc != 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc type {module type}\""); - return TCL_ERROR; - } - - const char *_typename = argv[1]; - const AsnTypeDesc *typedesc; - if (!(typedesc = gettypedesc ("type", _typename))) - return TCL_ERROR; - - Tcl_DString desc; - Tcl_DStringInit (&desc); - int rc = typedesc->TclGetDesc (&desc); - Tcl_DStringResult (interp, &desc); - return rc; -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::info (int argc, char **argv) -{ - if (argc != 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc info path\""); - return TCL_ERROR; - } - - Args path; - if (Tcl_SplitList (interp, argv[1], &path.c, &path.v) != TCL_OK) - return TCL_ERROR; - - if (path.c < 1) - { - strcpy (interp->result, "snacc info: wrong # args in path"); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, path.v[0]); - if (!entry) - { - Tcl_AppendResult (interp, "snacc info: no file named \"", path.v[0], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - - AsnType *var = (AsnType *)*file; - for (int i=1; i_getref (path.v[i]))) - { - Tcl_AppendResult (interp, "snacc info: illegal component \"", path.v[i], "\" in path", NULL); - return TCL_ERROR; - } - - Tcl_DString desc; - Tcl_DStringInit (&desc); - int rc; - if ((rc = var->_getdesc()->AsnTypeDesc::TclGetDesc (&desc)) == TCL_OK) - rc = var->TclGetDesc (&desc); - Tcl_DStringResult (interp, &desc); - return rc; -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::getval (int argc, char **argv) -{ - if (argc != 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc get path\""); - return TCL_ERROR; - } - - Args path; - if (Tcl_SplitList (interp, argv[1], &path.c, &path.v) != TCL_OK) - return TCL_ERROR; - - if (path.c < 1) - { - strcpy (interp->result, "snacc get: wrong # args in path"); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, path.v[0]); - if (!entry) - { - Tcl_AppendResult (interp, "snacc get: no file named \"", path.v[0], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - - AsnType *var = (AsnType *)*file; - for (int i=1; i_getref (path.v[i]))) - { - Tcl_AppendResult (interp, "snacc get: illegal component \"", path.v[i], "\" in path", NULL); - return TCL_ERROR; - } - - return var->TclGetVal (interp); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::test (int argc, char **argv) -{ - if (argc != 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc get path\""); - return TCL_ERROR; - } - - Args path; - if (Tcl_SplitList (interp, argv[1], &path.c, &path.v) != TCL_OK) - return TCL_ERROR; - - if (path.c < 1) - { - strcpy (interp->result, "snacc get: wrong # args in path"); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, path.v[0]); - if (!entry) - { - Tcl_AppendResult (interp, "snacc get: no file named \"", path.v[0], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - - AsnType *var = (AsnType *)*file; - for (int i=1; i_getref (path.v[i]))) - { - Tcl_AppendResult (interp, "snacc test: illegal component \"", path.v[i], "\" in path", NULL); - return TCL_ERROR; - } - -cout << *var; - strstream s; - s << *var; - s.put ('\0'); - cout << strlen(s.str()) << endl; - cout << s.str() << endl; - - return TCL_OK; -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::setval (int argc, char **argv) -{ - if (argc != 3) - { - strcpy (interp->result, "wrong # args: should be \"snacc set path value\""); - return TCL_ERROR; - } - - Args path; - if (Tcl_SplitList (interp, argv[1], &path.c, &path.v) != TCL_OK) - return TCL_ERROR; - - if (path.c < 1) - { - strcpy (interp->result, "snacc set: wrong # args in path"); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, path.v[0]); - if (!entry) - { - Tcl_AppendResult (interp, "snacc set: no file named \"", path.v[0], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - - AsnType *var = (AsnType *)*file; - for (int i=1; i_getref (path.v[i], true))) - { - Tcl_AppendResult (interp, "snacc set: illegal component \"", path.v[i], "\" in path", NULL); - return TCL_ERROR; - } - - return var->TclSetVal (interp, argv[2]); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int SnaccTcl::unsetval (int argc, char **argv) -{ - if (argc != 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc unset path\""); - return TCL_ERROR; - } - - Args path; - if (Tcl_SplitList (interp, argv[1], &path.c, &path.v) != TCL_OK) - return TCL_ERROR; - - if (path.c == 1) - { - strcpy (interp->result, "snacc unset: sorry, but you are not allowed to unset the file itself"); - return TCL_ERROR; - } - else if (path.c < 1) - { - strcpy (interp->result, "snacc unset: wrong # args in path"); - return TCL_ERROR; - } - - Tcl_HashEntry *entry = Tcl_FindHashEntry (&files, path.v[0]); - if (!entry) - { - Tcl_AppendResult (interp, "snacc unset: no file named \"", path.v[0], "\"", NULL); - return TCL_ERROR; - } - - ASN1File *file = (ASN1File *)Tcl_GetHashValue (entry); - - AsnType *var = (AsnType *)*file; - for (int i=1; i_getref (path.v[i]))) - { - Tcl_AppendResult (interp, "snacc unset: illegal component \"", path.v[i], "\" in path", NULL); - return TCL_ERROR; - } - } - - return var->TclUnsetVal (interp, path.v[path.c-1]); -} - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -int Snacc_Cmd (ClientData cd, Tcl_Interp *interp, int argc, char **argv) -{ - SnaccTcl *ed = (SnaccTcl *)cd; - -#ifdef DEBUG - ed->ckip (interp); -#endif - - if (argc < 2) - { - strcpy (interp->result, "wrong # args: should be \"snacc option arg ?arg ...?\""); - return TCL_ERROR; - } - --argc; - argv++; - - switch (**argv) - { - case 'c': - if (!strcmp (*argv, "close")) - return ed->closefile (argc, argv); - else if (!strcmp (*argv, "create")) - return ed->create (argc, argv); - break; - case 'e': - if (!strcmp (*argv, "export")) - return export (interp, argc, argv); - break; - case 'f': - if (!strcmp (*argv, "finfo")) - return ed->finfo (argc, argv); - break; - case 'g': - if (!strcmp (*argv, "get")) - return ed->getval (argc, argv); - break; - case 'i': - if (!strcmp (*argv, "import")) - return import (interp, argc, argv); - else if (!strcmp (*argv, "info")) - return ed->info (argc, argv); - break; - case 'm': - if (!strcmp (*argv, "modules")) - return ed->modulesinfo (argc, argv); - break; - case 'o': - if (!strcmp (*argv, "open")) - return ed->openfile (argc, argv); - break; - case 'r': - if (!strcmp (*argv, "read")) - return ed->read (argc, argv); - break; - case 's': - if (!strcmp (*argv, "set")) - return ed->setval (argc, argv); - break; - case 't': - if (!strcmp (*argv, "test")) - return ed->test (argc, argv); - else if (!strcmp (*argv, "type")) - return ed->typeinfo (argc, argv); - else if (!strcmp (*argv, "types")) - return ed->typesinfo (argc, argv); - break; - case 'u': - if (!strcmp (*argv, "unset")) - return ed->unsetval (argc, argv); - break; - case 'w': - if (!strcmp (*argv, "write")) - return ed->write (argc, argv); - break; - } - sprintf (interp->result, "bad command option %s: should be close, create, export, finfo, get, import, info, modules, open, read, set, type, types, unset or write", *argv); - - return TCL_ERROR; -} - -//\[banner "check for proper initialization & finalization"]------------------------------------------------------------------------ - -struct check -{ - int i, j; - - check (int); - - bool bad(); -}; - -static int cki; - -check::check (int v) -{ - i = v; - j = ~i; -} - -#define CK 42 - -bool check::bad() -{ - return i != CK || j != ~CK; -} - -check check (CK); - -//\[banner "initialization & finalization"]----------------------------------------------------------------------------------------- -void Snacc_Exit (ClientData data) -{ - delete (SnaccTcl *)data; -} - -// prohibit function name mangling to enable tkAppInit.c:Tcl_AppInit() to call this function: -extern "C" int Snacc_Init (Tcl_Interp *interp) -{ - if (check.bad()) - { - static const char emsg[] = "linkage error, constructors of static variables didn't get called!\n"; - write (2, emsg, sizeof emsg); - exit (1); - } - - SnaccTcl *data = new SnaccTcl (interp); - Tcl_CreateCommand (interp, "snacc", Snacc_Cmd, (ClientData)data, Snacc_Exit); - return TCL_OK; -} - -#endif // TCL diff --git a/SecuritySNACCRuntime/c++-lib/c++/tkAppInit.c b/SecuritySNACCRuntime/c++-lib/c++/tkAppInit.c deleted file mode 100644 index 60dec14e..00000000 --- a/SecuritySNACCRuntime/c++-lib/c++/tkAppInit.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * snacced - Snacc_Init added to the default tkXAppInit. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/tkAppInit.c,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ - * $Log: tkAppInit.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:06 mb - * Move from private repository to open source repository - * - * Revision 1.3 2001/05/05 00:59:17 rmurphy - * Adding darwin license headers - * - * Revision 1.2 2000/06/15 18:44:59 dmitch - * These snacc-generated source files are now checked in to allow cross-platform build. - * - * Revision 1.2 2000/06/08 20:05:37 dmitch - * Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... - * - * Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy - * Base Fortissimo Tree - * - * Revision 1.1 1999/02/25 05:21:58 mb - * Added snacc c++ library - * - * Revision 1.2 1997/02/28 13:39:48 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.1 1997/01/02 09:07:59 rj - * first check-in - * - */ - -#ifndef __APPLE__ -/* I don't know why this gets configd to build but we don't have tk.h */ - -#include "snacc.h" - -#if TCL - -/* - * tkXAppInit.c -- - * - * Provides a default version of the TclX_AppInit procedure for use with - * applications built with Extended Tcl and Tk. This is based on the - * the UCB Tk file tkAppInit.c - * - *----------------------------------------------------------------------------- - * Copyright 1991-1993 Karl Lehenbauer and Mark Diekhans. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies. Karl Lehenbauer and - * Mark Diekhans make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - *----------------------------------------------------------------------------- - * $Id: tkAppInit.c,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ - *----------------------------------------------------------------------------- - * Copyright (c) 1993 The Regents of the University of California. - * All rights reserved. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF - * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - */ - -#ifndef lint -static char rcsid[] = "$Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/tkAppInit.c,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ SPRITE (Berkeley)"; -#endif /* not lint */ - -#include - -#include "init.h" - -int -main(argc, argv) - int argc; /* Number of command-line arguments. */ - char **argv; /* Values of command-line arguments. */ -{ - Tk_Main(argc, argv, Tcl_AppInit); - return 0; /* Needed only to prevent compiler warning. */ -} - -int -Tcl_AppInit (interp) - Tcl_Interp *interp; /* Interpreter for application. */ -{ - if (Tcl_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - if (Tk_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL); - - if (Snacc_Init (interp) == TCL_ERROR) - return TCL_ERROR; - - if (Tree_Init (interp) == TCL_ERROR) - return TCL_ERROR; - - Tcl_SetVar (interp, "tcl_rcFileName", "~/.snaccedrc", TCL_GLOBAL_ONLY); - - return TCL_OK; -} - -#endif - -#endif // Apple diff --git a/SecuritySNACCRuntime/c++-lib/dependencies b/SecuritySNACCRuntime/c++-lib/dependencies deleted file mode 100644 index e69de29b..00000000 diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-any.h b/SecuritySNACCRuntime/c++-lib/inc/asn-any.h deleted file mode 100644 index 1d55e40a..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-any.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-any.h - C++ class for any type -// -// MS 92 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// -// ------------------------------------------------------------------------ -// - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 - -// ------------------------------------------------------------------------ -// -// All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's -// SCCS. The revision #'s start at 1.1, which is the original version from -// SNACC 1.3. -// -// -// ../SCCS/s.asn-any.h: -// -// D 1.2 98/05/01 13:46:36 pleonber 2 1 00008/00000/00099 -// added destructor and copy for CSM_Buffer handling (cleans up memory). -// -// D 1.1 98/05/01 13:16:05 pleonber 1 0 00099/00000/00000 -// date and time created 98/05/01 13:16:05 by pleonber -// -// ----------------------- End of VDA Modifications --------------------------- -// -// -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-any.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-any.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.5 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.4 2000/12/22 20:33:26 mb -// New Security framework fase 1 complete. -// -// Revision 1.3 2000/12/07 22:14:38 dmitch -// Thread-safe mods: made oidHashTbl and intHashTbl private. -// -// Revision 1.2 2000/06/15 18:48:25 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.4 1999/03/21 02:07:31 mb -// Added Copy to every AsnType. -// -// Revision 1.3 1999/03/18 22:35:26 mb -// Made all destructors virtual. -// -// Revision 1.2 1999/02/26 00:32:55 mb -// Fix bug when not building with VDADER_RULES defined. -// -// Revision 1.1 1999/02/25 05:21:40 mb -// Added snacc c++ library -// -// Revision 1.4 1997/01/02 08:39:42 rj -// missing prototype added -// -// Revision 1.3 1994/10/08 04:17:56 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:43 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:24 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_any_h_ -#define _asn_any_h_ - -#ifdef _IBM_ENC_ -#include "shmmgr.h" // Guido Grassel 4.8.93 -#endif /* _IBM_ENC_ */ - -#include "hash.h" - -#ifdef __APPLE__ -#include /* for Mutex */ -#endif - -/* this is put into the hash table with the int or oid as the key */ -#ifndef _IBM_ENC_ -class AnyInfo -#else -class AnyInfo: public MemMgr // Guido Grassel 4.8.93 -#endif /* _IBM_ENC_ */ -{ -public: - int anyId; // will be a value from the AnyId enum - AsnOid oid; // will be zero len/null if intId is valid - AsnInt intId; - AsnType *typeToClone; -}; - -#if defined(macintosh) || defined(__APPLE__) -class CSM_Buffer; -#endif - -class AsnAny: public AsnType -{ -#ifdef __APPLE__ -/* need a lock to protect these, declared as a static in the .cpp file. - *...plus, I have no idea why these - * were declared public. They are not used anywhere else. - */ -private: - static Table *oidHashTbl; // all AsnAny class instances - static Table *intHashTbl; // share these tables -public: -#else -public: - static Table *oidHashTbl; // all AsnAny class instances - static Table *intHashTbl; // share these tables -#endif - AnyInfo *ai; // points to entry in hash tbl for this type -#if defined(macintosh) || defined(__APPLE__) -// FIXME - needs work - CSM_Buffer *value; -#else - AsnType *value; -#endif - AsnAny() { ai = NULL; value = NULL; } - - // class level methods - static void InstallAnyByInt (AsnInt intId, int anyId, AsnType *type); - static void InstallAnyByOid (AsnOid &oid, int anyId, AsnType *type); - - int GetId() const { return ai ? ai->anyId : -1; } - void SetTypeByInt (AsnInt id); - void SetTypeByOid (AsnOid &id); - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - - void Print (ostream &) const; - -#if 0 -#if TCL - int TclGetDesc (Tcl_DString *) const; - int TclGetVal (Tcl_DString *) const; - int TclSetVal (Tcl_Interp *, const char *val); - int TclUnSetVal (Tcl_Interp *, const char *member); -#endif /* TCL */ -#endif - -#ifdef VDADER_RULES - virtual ~AsnAny(); - AsnAny &operator = (const AsnAny &o); -}; - -// AnyDefinedBy is currently the same as AsnAny: -typedef AsnAny AsnAnyDefinedBy; - -#else -}; -#endif /* _conditional_include_ */ - -#endif /* _asn_any_h_ */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-bits.h b/SecuritySNACCRuntime/c++-lib/inc/asn-bits.h deleted file mode 100644 index e99d74f0..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-bits.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-bits.h - ASN.1 BIT STRING type -// -// Mike Sample -// 92/07/02 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-bits.h,v 1.2 2001/06/28 23:36:11 dmitch Exp $ -// $Log: asn-bits.h,v $ -// Revision 1.2 2001/06/28 23:36:11 dmitch -// Removed SccsId statics. numToHexCharTblG table now const. Radar 2705410. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.5 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.4 2000/12/07 22:29:50 dmitch -// Thread-safe mods: added strStkG, strStkUnusedBitsG arguments to FillBitStringStk . -// -// Revision 1.3 2000/08/24 20:00:25 dmitch -// Added BitOcts() accessor. -// -// Revision 1.2 2000/06/15 18:48:22 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// 2000/8/24 dmitch at Apple -// Added BitOcts() accessor. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.3 1999/03/21 02:07:31 mb -// Added Copy to every AsnType. -// -// Revision 1.2 1999/03/18 22:35:27 mb -// Made all destructors virtual. -// -// Revision 1.1 1999/02/25 05:21:40 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/16 20:25:33 rj -// check-in of a few cosmetic changes -// -// Revision 1.5 1995/07/24 17:53:51 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// Revision 1.4 1995/02/18 19:26:18 rj -// remove const from arguments that are passed by value. -// -// Revision 1.3 1994/10/08 04:17:57 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:44 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:25 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_bits_h_ -#define _asn_bits_h_ - -#ifdef __APPLE__ -#include "str-stk.h" -#endif - -extern const char numToHexCharTblG[]; - -#define TO_HEX( fourBits) (numToHexCharTblG[(fourBits) & 0x0F]) - -class AsnBits: public AsnType -{ -private: - bool BitsEquiv (const AsnBits &ab) const; - void BDecConsBits (BUF_TYPE b, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - #ifdef __APPLE__ - void FillBitStringStk (BUF_TYPE b, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env, - StrStk &strStkG, unsigned short int &strStkUnusedBitsG); - #else - void FillBitStringStk (BUF_TYPE b, AsnLen elmtLen0, - AsnLen &bytesDecoded, ENV_TYPE env); - #endif - -protected: - size_t bitLen; - char *bits; - -public: - - AsnBits() { bits = NULL; bitLen = 0; } - AsnBits (size_t numBits) { Set (numBits); } - AsnBits (const char *bitOcts, size_t numBits) - { Set (bitOcts, numBits); } - AsnBits (const AsnBits &b) { Set (b); } -#ifndef _IBM_ENC_ - virtual ~AsnBits(); -#else - virtual ~AsnBits() { mem_mgr_ptr->Put ((void *) bits); } // Guido Grassel, 11.8.93 -#endif /* _IBM_ENC_ */ - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - AsnBits &operator = (const AsnBits &b) { ReSet (b); return *this; } - - // overwrite existing bits and bitLen values - void Set (size_t numBits); - void Set (const char *bitOcts, size_t numBits); - void Set (const AsnBits &b); - - // free old bits value, the reset bits and bitLen values - void ReSet (size_t numBits); - void ReSet (const char *bitOcts, size_t numBits); - void ReSet (const AsnBits &b); - - bool operator == (const AsnBits &ab) const { return BitsEquiv (ab); } - bool operator != (const AsnBits &ab) const { return !BitsEquiv (ab); } - - void SetBit (size_t); - void ClrBit (size_t); - bool GetBit (size_t) const; - - // Apple addenda: this is just too useful to exclude. - const char *BitOcts() const { return bits; } - - size_t BitLen() const { return bitLen; } - - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - - void Print (ostream &) const; - -#if META - static const AsnBitsTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif /* TCL */ -#endif /* META */ -}; - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-bool.h b/SecuritySNACCRuntime/c++-lib/inc/asn-bool.h deleted file mode 100644 index 2a8b333f..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-bool.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-bool.h - c++ version of ASN.1 integer -// -// MS 92/06/15 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// -// ------------------------------------------------------------------------ -// - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 - -// ------------------------------------------------------------------------ -// -// All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's -// SCCS. The revision #'s start at 1.1, which is the original version from -// SNACC 1.3. -// -// -// ../SCCS/s.asn-bool.h: -// -// D 1.2 98/04/24 22:40:40 pleonber 2 1 00002/00000/00118 -// added INSERT_VDA_COMMENTS for script that adds SCCS history -// -// D 1.1 97/11/11 15:48:58 cmmaster 1 0 00118/00000/00000 -// date and time created 97/11/11 15:48:58 by cmmaster -// -// ----------------------- End of VDA Modifications --------------------------- -// -// -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-bool.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-bool.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:23 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:32 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:41 mb -// Added snacc c++ library -// -// Revision 1.8 1995/09/07 18:45:13 rj -// use AsnBoolTypeDesc instead of AsnTypeDesc (no real difference, it is the same type). -// -// Revision 1.7 1995/07/24 17:53:54 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// Revision 1.6 1995/02/18 19:17:19 rj -// add TRUE/FALSE for backwards compatibility. -// -// Revision 1.5 1995/02/18 12:41:31 rj -// a few more lines for the sake of backwards compatibility. -// -// Revision 1.4 1994/10/08 04:17:58 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.3 1994/08/31 23:32:13 rj -// use the bool built-in where applicable, and a replacement type otherwise. -// -// Revision 1.2 1994/08/28 10:00:45 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:27 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_bool_h_ -#define _asn_bool_h_ - -#if GLASS -// for backwards compatibility: -#ifndef FALSE -enum { FALSE = false, TRUE = true }; -#endif -#endif // GLASS - -class AsnBool: public AsnType -{ -protected: - -// for backwards compatibility: -#if GLASS -#if BOOL_BUILTIN - typedef bool _bool; -#else - enum - { - false = ::false, - true = ::true - }; -#endif -#endif - - bool value; - -public: - AsnBool (const bool val): -#if BOOL_BUILTIN - value (val) -#else - value (!!val) -#endif - {} - AsnBool() {} - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - operator bool() const { return value; } - AsnBool &operator = (bool newvalue) { value = newvalue; return *this; } - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - - void Print (ostream &) const; - -#if META - static const AsnBoolTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif // TCL -#endif // META -}; - -#endif // conditional include diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-buf.h b/SecuritySNACCRuntime/c++-lib/inc/asn-buf.h deleted file mode 100644 index a14afd46..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-buf.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-buf.h - buffer class -// -// MS 92 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-buf.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-buf.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:17 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:23 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.4 1999/08/06 16:13:18 mb -// Set readError when doing a GetSeg past the end of the buffer. This fixes many potential bugs and hangs when doing streaming decodes with embedded data. -// -// Revision 1.3 1999/07/14 23:53:55 aram -// Made const correct so things build with CW 5.0 -// -// Revision 1.2 1999/03/04 00:43:20 mb -// Made buffer full check work for NULL buffer in an unsigned int context -// -// Revision 1.1 1999/02/25 05:21:41 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/16 20:25:35 rj -// check-in of a few cosmetic changes -// -// Revision 1.4 1995/07/25 20:18:58 rj -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:15:38 rj -// fixed both Copy()'s name and implementation to CopyOut() that always returns the number of bytes copied out instead of 0 in case less than the requested amount is available. -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:46 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:28 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_buf_h_ -#define _asn_buf_h_ - -class AsnBuf -{ -protected: - char *dataStart; - char *dataEnd; - char *blkStart; - char *blkEnd; - char *readLoc; - bool writeError; - bool readError; - -public: - // install data for reading or blank blk for writing in buffer - // must be followed by 'mode' setting method call - void Init (char *data, size_t dataLen) - { - readError = writeError = 1; - blkStart = data; - blkEnd = data + dataLen; - dataStart = dataEnd = readLoc = blkEnd; - } - - void ResetInReadMode() - { - readLoc = dataStart; - readError = false; - writeError = true; - } - - void ResetInWriteRvsMode() - { - dataStart = dataEnd = blkEnd; - writeError = false; - readError = true; - } - - void InstallData (const char *data, size_t dataLen) - { - Init (const_cast(data), dataLen); - dataStart = blkStart; - ResetInReadMode(); - } - - size_t DataLen() { return dataEnd - dataStart; } - char *DataPtr() { return dataStart; } - size_t BlkLen() { return blkEnd - blkStart; } - char *BlkPtr() { return blkStart; } - bool Eod() { return readLoc >= dataEnd; } - bool ReadError() { return readError; } - bool WriteError() { return writeError; } - - void Skip (size_t skipLen) - { - if ((readLoc + skipLen) > dataEnd) - { - readLoc = dataEnd; - readError = true; - } - else - readLoc += skipLen; - } - - size_t CopyOut (char *dst, size_t copyLen) - { - if (readLoc + copyLen > dataEnd) - { - copyLen = dataEnd - readLoc; - readError = true; - } - memcpy (dst, readLoc, copyLen); - readLoc += copyLen; - return copyLen; - } - - unsigned char PeekByte() - { - if (Eod()) - { - readError = true; - return 0; - } - else - return *readLoc; - } - - char *GetSeg (size_t *lenPtr) - { - char *retVal = readLoc; - if ((readLoc + *lenPtr) > dataEnd) - { - *lenPtr = dataEnd - readLoc; - readLoc = dataEnd; - - /* Attempting to read more bytes than left in the buffer is a read error --Michael. */ - readError = true; - - return retVal; - } - else - { - readLoc += *lenPtr; - return retVal; - } - } - - void PutSegRvs (char *seg, size_t segLen) - { - if (dataStart < (blkStart + segLen)) - writeError = true; - else - { - dataStart -= segLen; - memcpy (dataStart, seg, segLen); - } - } - - unsigned char GetByte() - { - if (Eod()) - { - readError = true; - return 0; - } - else - return *(readLoc++); - } - - void PutByteRvs (unsigned char byte) - { - if (dataStart <= blkStart) - writeError = true; - else - *(--dataStart) = byte; - } -}; - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-config.h b/SecuritySNACCRuntime/c++-lib/inc/asn-config.h deleted file mode 100644 index d7cecf89..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-config.h +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-config.h - decoder alloc routines and buffer routines and other configuration stuff. -// -// MS 92/06/18 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-config.h,v 1.7 2002/06/12 18:36:31 dmitch Exp $ -// $Log: asn-config.h,v $ -// Revision 1.7 2002/06/12 18:36:31 dmitch -// Radar 2951933: Avoid including iostream in asn-config.h for NDEBUG builds. -// -// Revision 1.6.94.4 2002/06/11 22:59:03 dmitch -// Radar 2951933. -// -// Revision 1.6.94.3 2002/06/11 22:34:50 dmitch -// More endl cleanup. -// -// Revision 1.6.94.2 2002/06/11 22:27:28 dmitch -// Clean up endl declaration for NDEBUG case. -// -// Revision 1.6.94.1 2002/06/10 23:19:08 dmitch -// Radar 2934358 - avoid #include \ in asn-config.h -// -// Revision 1.6 2002/04/18 18:58:08 dmitch -// Radar 2904404 - avoid deprecated iostream.h -// -// Revision 1.5.24.1 2002/04/17 00:48:53 dmitch -// Radar 2904404 - avoid deprecated iostream.h. -// -// Revision 1.5 2002/03/21 05:38:47 dmitch -// Radar 2868524: no more setjmp/longjmp in SNACC-generated code. -// -// Revision 1.4.32.4 2002/03/20 20:56:37 dmitch -// Further refinements for Radar 2868524: no more BDecPdu or BEncPdu. -// -// Revision 1.4.32.3 2002/03/20 02:54:08 dmitch -// Avoid the unused and uninitialized ENV_TYPE var in BDecPdu. -// -// Revision 1.4.32.2 2002/03/20 01:28:02 dmitch -// Added throw() to SnaccExcep destructor. -// -// Revision 1.4.32.1 2002/03/20 00:36:52 dmitch -// Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. -// -// Revision 1.4 2002/02/07 04:30:04 mb -// Fixes required to build with gcc3. -// Merged from branch PR-2848996 -// Bug #: 2848996 -// Submitted by: -// Reviewed by: Turly O'Connor -// -// Revision 1.3.10.1 2002/02/06 23:45:04 mb -// Changes to allow building with gcc3 -// -// Revision 1.3 2001/06/27 23:09:16 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.2 2001/06/26 23:47:26 dmitch -// Implemented AsnNullError as replacement for cerr in NDEBUG configuration. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:23 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.3 1999/04/08 21:20:18 aram -// Fixed Asn1Free macro. -// -// Revision 1.2 1999/03/16 03:04:30 mb -// Added common base class SecObject and implemented signing of the digest in SecSigner. -// -// Revision 1.1 1999/02/25 05:21:41 mb -// Added snacc c++ library -// -// Revision 1.7 1995/09/07 18:48:36 rj -// AsnIntType and AsnUIntType introduced to replace (unsigned) long int at a lot of places. -// they shall provide 32 bit integer types on all platforms. -// -// Revision 1.6 1995/07/25 20:19:00 rj -// changed `_' to `-' in file names. -// -// Revision 1.5 1995/02/13 14:47:46 rj -// settings for IEEE_REAL_FMT/IEEE_REAL_LIB moved from {c_lib,c++_lib}/inc/asn_config.h to acconfig.h. -// -// Revision 1.4 1994/10/08 04:17:59 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.3 1994/09/01 00:58:47 rj -// redundant code moved into ../../config.h.bot; semicolon removed from end of macro texts. -// -// Revision 1.2 1994/08/28 10:00:47 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:29 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_config_h_ -#define _asn_config_h_ - -#include /* for isprint() in < -namespace std { - extern ostream& endl(ostream& outs); -} -#else -#include -#endif -/* assume these... */ -using std::iostream; -using std::ostream; -using std::istream; -using std::endl; - -#include -#include -#include -#include /* to get ieee conversion functions & pow */ - -#include "snacc.h" - -using std::streamsize; - -// used not only by AsnInt (asn-int.h), but by AsnNameDesc (meta.h) as well: -#if SIZEOF_INT == 4 -# define I int -#else -# if SIZEOF_LONG == 4 -# define I long -# else -# if SIZEOF_SHORT == 4 -# define I short -# endif -# endif -#endif -#ifdef I - typedef I AsnIntType; - typedef unsigned I AsnUIntType; -# undef I -#else -# error "can't find integer type which is 4 bytes in size" -#endif - -/* used to test if optionals are present */ -#define NOT_NULL( ptr) ((ptr) != NULL) - - -/* - * Asn1Error (char *str) - * - configure error handler - */ -#ifndef NDEBUG -#define Asn1Error std::cerr -#else - -/* silent ostream */ -class Asn1ErrorClass; -class Asn1ErrorClass /* public ostream */ -{ -public: - Asn1ErrorClass& put (char c) { return *this; }; - Asn1ErrorClass& write (const char * s, streamsize n) { return *this; }; - Asn1ErrorClass& flush () { return *this; }; - template - Asn1ErrorClass &operator << (const T &) { return *this; } -}; - - -#ifdef __APPLE__ - -/* Avoid the static load-time init of AsnErrorClass */ -#include -extern ModuleNexus AsnNullError; - -/* Avoid instantiating cerr and endl */ -#define Asn1Error AsnNullError() -#define endl AsnNullError() - -#else /* NDEBUG, !__APPLE__ */ - -/* This does not currently have an instantiation */ -extern Asn1ErrorClass Asn1Error; - -#endif /* __APPLE__ */ -#endif /* NDEBUG */ - -/* - * Asn1Warning (char *str) - configure warning mechanism - * (currently not called) - */ -#define Asn1Warning Asn1Error - - -/* - * configure memory scheme used by decoder to allocate memory - * for the decoded value. The include file name cannot be - * be null. - */ -#define Asn1New( class) new class -#define Asn1Delete( ptr) delete ptr -#define Asn1Alloc( size) new char[size] -#define Asn1Free( ptr) delete[] ptr - -#include "asn-buf.h" -#define BUF_TYPE AsnBuf & - -/* - * Enables throw/catch as replacement for setjmp/longjmp in C++ lib. - * BDecPdu still returns int (1 = OK, 0 = fail) in either config. - * The compiler gets this symbol from c-lib/inc/asn-config.h; runtime - * support gets this symbol from this file. There is currently no - * straightforward way to have one symbol used in both environments. - */ -#define SNACC_EXCEPTION_ENABLE 1 - -/* - * With the SNACC_EXCEPTION_ENABLE mods, ENV_TYPE is not used, though - * it still appears in the BDec*() function. - */ -#if SNACC_EXCEPTION_ENABLE -#define ENV_TYPE int -#else -#define ENV_TYPE jmp_buf -#endif /* SNACC_EXCEPTION_ENABLE */ - -/* - * Enable BEncPdu, BDecPdu. Same remarks apply as above w.r.t the - * c++ config file. - */ -#define SNACC_ENABLE_PDU 0 -#if SNACC_ENABLE_PDU - -#if SNACC_EXCEPTION_ENABLE -/* return true if succeeded, false otherwise */ -#define PDU_MEMBER_MACROS\ - int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)\ - {\ - bytesEncoded = BEnc (b);\ - return !b.WriteError();\ - }\ -\ - int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)\ - {\ -\ - bytesDecoded = 0;\ - try\ - {\ - BDec (b, bytesDecoded, 0);\ - return !b.ReadError();\ - }\ - catch(...) {\ - return false;\ - }\ - } -#else /* SNACC_EXCEPTION_ENABLE */ -#define PDU_MEMBER_MACROS\ - int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)\ - {\ - bytesEncoded = BEnc (b);\ - return !b.WriteError();\ - }\ -\ - int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)\ - {\ - ENV_TYPE env;\ - int val;\ -\ - bytesDecoded = 0;\ - if ((val = setjmp (env)) == 0)\ - {\ - BDec (b, bytesDecoded, env);\ - return !b.ReadError();\ - }\ - else\ - return false;\ - } -#endif /* SNACC_EXCEPTION_ENABLE */ -#else /* !SNACC_ENABLE_PDU */ -/* empty */ -#define PDU_MEMBER_MACROS -#endif - -/* - * SNACC exception class - */ -#if SNACC_EXCEPTION_ENABLE - -#include - -class SnaccExcep : public std::exception { -protected: - SnaccExcep(int err) : mErrNum(err) { } -public: - virtual ~SnaccExcep() throw() {}; - virtual int errNum() { return mErrNum; } - static void throwMe(int err); // implemented in cdsaUtils.cpp -protected: - int mErrNum; -}; -#endif /* SNACC_EXCEPTION_ENABLE */ - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-enum.h b/SecuritySNACCRuntime/c++-lib/inc/asn-enum.h deleted file mode 100644 index e37d8e29..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-enum.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-enum.h - c++ version of ASN.1 ENUMERATED -// -// inherits from AsnInt but changes universal tag stuff -// MS 92/06/15 -// -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-enum.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-enum.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:23 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:32 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:42 mb -// Added snacc c++ library -// -// Revision 1.5 1995/08/17 15:17:07 rj -// AsnEnumTypeDesc gets its own TclGetVal and TclSetVal functions. -// -// Revision 1.4 1995/07/24 17:52:00 rj -// Clone() added, or else the _desc would be wrong (and the wrong BEnc etc... would get called for Clone-d objects). -// -// _desc changed from AsnIntTypeDesc to AsnEnumTypeDesc. -// -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:17:59 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:48 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:31 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_enum_h_ -#define _asn_enum_h_ - -class AsnEnum: public AsnInt -{ -public: -#if !TCL - AsnEnum(): - AsnInt() - {} -#endif - AsnEnum (int i): - AsnInt (i) - {} - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - -#if META - static const AsnEnumTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif /* TCL */ -#endif /* META */ -}; - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-incl.h b/SecuritySNACCRuntime/c++-lib/inc/asn-incl.h deleted file mode 100644 index 967a8236..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-incl.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-incl.h - includes all of the asn1 library files -// -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// -// ------------------------------------------------------------------------ -// - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 - -// ------------------------------------------------------------------------ -// -// All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's -// SCCS. The revision #'s start at 1.1, which is the original version from -// SNACC 1.3. -// -// -// ../SCCS/s.asn-incl.h: -// -// D 1.2 98/05/01 13:14:40 pleonber 2 1 00006/00000/00059 -// added #include for sm_vdasnacc.h -// -// D 1.1 98/05/01 13:13:30 pleonber 1 0 00059/00000/00000 -// date and time created 98/05/01 13:13:30 by pleonber -// -// ----------------------- End of VDA Modifications --------------------------- -// -// -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-incl.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-incl.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.4 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.3 2001/01/10 01:12:03 dmitch -// Rearranged #includes so sm_vdasnacc.h always sees asn-buf.h. -// -// Revision 1.2 2000/06/15 18:48:23 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:42 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/16 20:25:37 rj -// check-in of a few cosmetic changes -// -// Revision 1.4 1995/07/24 17:52:33 rj -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:01 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:49 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:33 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifdef _IBM_ENC_ -#define ChoiceUnion -#endif /* _IBM_ENC_ */ - - -#include "asn-config.h" -#include "asn-buf.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-type.h" -#include "asn-int.h" -#include "asn-bool.h" -#include "asn-real.h" -#include "asn-oid.h" -#include "asn-octs.h" -#include "asn-bits.h" -#include "asn-enum.h" -#include "asn-null.h" -#ifdef VDADER_RULES -#include "sm_vdasnacc.h" -#endif -#include "asn-any.h" -#include "asn-useful.h" -#include "print.h" diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-int.h b/SecuritySNACCRuntime/c++-lib/inc/asn-int.h deleted file mode 100644 index 4781d81e..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-int.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-int.h - c++ version of ASN.1 integer -// -// MS 92/06/15 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-int.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-int.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:23 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:32 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:42 mb -// Added snacc c++ library -// -// Revision 1.5 1995/09/07 18:49:19 rj -// long int replaced by newly introduced AsnIntType at a lot of places. -// it shall provide a 32 bit integer type on all platforms. -// -// Revision 1.4 1995/07/24 17:53:56 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:02 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:49 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:35 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_int_h_ -#define _asn_int_h_ - -class AsnInt: public AsnType -{ -protected: - AsnIntType value; - -public: - AsnInt() {} - AsnInt (AsnIntType val): - value (val) - {} - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - operator AsnIntType() const { return value; } - AsnInt &operator = (AsnIntType newvalue) { value = newvalue; return *this; } - - void Set (AsnIntType i) { value = i; } - void ReSet (AsnIntType i) { value = i; } - - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - - void Print (ostream &os) const; - -#if META - static const AsnIntTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif /* TCL */ -#endif /* META */ -}; - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-len.h b/SecuritySNACCRuntime/c++-lib/inc/asn-len.h deleted file mode 100644 index bfc82759..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-len.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-len.h - handle ASN.1 length encoding/decoding etc. -// -// MS 92/06/18 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-len.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-len.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:23 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:43 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/16 10:07:43 rj -// make the unsigned value unsigned :-) -// -// Revision 1.5 1995/07/25 20:19:01 rj -// changed `_' to `-' in file names. -// -// Revision 1.4 1994/10/08 04:18:04 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.3 1994/08/31 23:35:00 rj -// semicolon removed from end of macro text -// -// Revision 1.2 1994/08/28 10:00:50 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:36 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_len_h_ -#define _asn_len_h_ - -typedef size_t AsnLen; - -#define INDEFINITE_LEN ~0UL // max unsigned value used for indef rep - -#ifdef USE_INDEF_LEN - -#define BEncEocIfNec(b)\ - BEncEoc (b) - -#define BEncConsLen(b, len)\ - 2 + BEncIndefLen (b) /* include len for EOC */ - -#else // default -- use definite length -- usually faster (for snacc encoders) and smaller encodings - -#define BEncEocIfNec(b) /* do nothing */ - -#define BEncConsLen(b, len)\ - BEncDefLen (b, len) - -#endif - -#define BEncIndefLen( b)\ - 1;\ - b.PutByteRvs (0x80) - -/* - * use if you know the encoded length will be 0 >= len <= 127 - * Eg for booleans, nulls, any resonable integers and reals - * - * NOTE: this particular Encode Routine does NOT return the length - * encoded (1). The length counter must be explicity incremented - */ -#define BEncDefLenTo127( b, len)\ - b.PutByteRvs ((unsigned char) len) - -#define BDEC_2ND_EOC_OCTET( b, bytesDecoded, env)\ -{\ - if ((b.GetByte() != 0) || b.ReadError())\ - Asn1Warning << "Warning - second octet of EOC not zero" << endl;\ - (bytesDecoded)++;\ -} - -AsnLen BDecLen (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - -AsnLen BEncDefLen ( BUF_TYPE b, AsnLen len); - -AsnLen BEncEoc (BUF_TYPE b); - -void BDecEoc (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-list.h b/SecuritySNACCRuntime/c++-lib/inc/asn-list.h deleted file mode 100644 index 0080ee3e..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-list.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-list.h -// -// **** NOTE - this is not used or tested due to problems with gcc **** -// -// Mike Sample -// 92/07/02 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-list.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-list.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:24 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:32 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:43 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/16 20:25:38 rj -// check-in of a few cosmetic changes -// -// Revision 1.5 1995/07/24 17:46:54 rj -// operator == and != return bool instead of int. -// -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// Revision 1.4 1995/02/18 14:06:09 rj -// #pragma interface/implementation are GNU specific and need to be wrapped. -// -// Revision 1.3 1994/10/08 04:18:05 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:51 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:37 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_list_h_ -#define _asn_list_h_ - -#ifdef __GNUG__ -#pragma interface -#endif - -#ifdef _IBM_ENC_ -#include "shmmgr.h" // Guido Grassel 5.8.93 -#endif /* _IBM_ENC_ */ - -template -#ifndef _IBM_ENC_ -class AsnList -#else -class AsnList: public MemMgr // Guido Grassel 12.8.93 -#endif /* _IBM_ENC_ */ -{ -protected: - unsigned long int count; - struct AsnListElmt - { - T elmt; - AsnListElmt *next, *prev; - } *first, *curr, *last; - -#ifdef _IBM_ENC_ - AsnListElmt *first, *curr, *last; -#endif /* _IBM_ENC_ */ - -public: - AsnList(): - count (0), - first (NULL), - curr (NULL), - last (NULL) - {} - - friend ostream &operator << (ostream &os, AsnList &l); - - void SetCurrElmt (unsigned long int index); - void SetCurrToFirst() { curr = first; } - void SetCurrToLast() { curr = last; } - - // reading member fcns - int Count() { return count; } - T *First() { return count > 0 ? &first->elmt : NULL; } - T *Last() { return count > 0 ? &last->elmt : NULL; } - T *Curr() { return curr ? &curr->elmt : NULL; } - T *Next() { return curr && curr->next ? &curr->next->elmt : NULL; } - T *Prev() { return curr && curr->prev ? &curr->prev->elmt : NULL; } - - // routines that move the curr elmt - T *GoNext() { if (curr) curr = curr->next; return Curr(); } - T *GoPrev() { if (curr) curr = curr->prev; return Curr(); } - - // write & alloc fcns - returns new elmt - T &Append(); // add elmt to end of list - T &Prepend(); // add elmt to begginning of list -// T &InsertBefore(); insert elmt before current elmt -// T &InsertAfter(); insert elmt after current elmt - - // write & alloc & copy - returns list after copying elmt - AsnList &AppendAndCopy (T &elmt); // add elmt to end of list - AsnList &PrependAndCopy (T &elmt); // add elmt to begginning of list -// AsnList &InsertBeforeAndCopy (T &elmt); insert elmt before current elmt -// AsnList &InsertAfterAndCopy (T &elmt); insert elmt after current elmt - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - // encode and decode routines - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - -#if META - static const AsnTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif /* TCL */ -#endif /* META */ -}; - -// This causes gcc2 on C++ to choke - -#if 0 -template -int ListsEquiv (AsnList &l1, AsnList &l2); - -template -inline bool operator == (AsnList &l1, AsnList &l2) -{ - return ListsEquiv (l1, l2); -} - -template -inline bool operator != (AsnList &l1, AsnList &l2) -{ - return !ListsEquiv (l1,l2); -} -#endif - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-null.h b/SecuritySNACCRuntime/c++-lib/inc/asn-null.h deleted file mode 100644 index 3d217752..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-null.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-null.h - C++ version of ASN.1 NULL -// -// MS 92/06/15 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-null.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-null.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:24 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:33 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:44 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/16 10:08:29 rj -// comment out an unused argument -// -// Revision 1.4 1995/07/24 17:53:57 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:06 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:52 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:38 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_null_h_ -#define _asn_null_h_ - -class AsnNull: public AsnType -{ -public: - AsnNull() {} - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - AsnLen BEncContent (BUF_TYPE /*b*/) { return 0; } - void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - - void Print (ostream &os) const; - -#if META - static const AsnNullTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif /* TCL */ -#endif /* META */ -}; - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-octs.h b/SecuritySNACCRuntime/c++-lib/inc/asn-octs.h deleted file mode 100644 index 2d881bbc..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-octs.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-octs.h - ASN.1 OCTET STRING type -// -// Mike Sample -// 92/07/02 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// -// ------------------------------------------------------------------------ -// - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 - -// ------------------------------------------------------------------------ -// -// All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's -// SCCS. The revision #'s start at 1.1, which is the original version from -// SNACC 1.3. -// -// -// ../SCCS/s.asn-octs.h: -// -// D 1.3 98/04/24 22:46:51 pleonber 3 2 00002/00000/00129 -// added INSERT_VDA_COMMENTS for script that adds SCCS history to file -// -// D 1.2 97/11/11 15:53:59 dharris 2 1 00004/00000/00125 -// changed == operator overide to remove warning -// -// D 1.1 97/11/11 15:50:52 cmmaster 1 0 00125/00000/00000 -// date and time created 97/11/11 15:50:52 by cmmaster -// -// ----------------------- End of VDA Modifications --------------------------- -// -// -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-octs.h,v 1.2 2002/04/18 18:58:08 dmitch Exp $ -// $Log: asn-octs.h,v $ -// Revision 1.2 2002/04/18 18:58:08 dmitch -// Radar 2904404 - avoid deprecated iostream.h -// -// Revision 1.1.1.1.70.1 2002/04/17 00:48:53 dmitch -// Radar 2904404 - avoid deprecated iostream.h. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:24 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.3 1999/03/21 02:07:33 mb -// Added Copy to every AsnType. -// -// Revision 1.2 1999/03/18 22:35:27 mb -// Made all destructors virtual. -// -// Revision 1.1 1999/02/25 05:21:44 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/16 20:25:40 rj -// check-in of a few cosmetic changes -// -// Revision 1.4 1995/07/24 17:46:52 rj -// operator == and != return bool instead of int. -// -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:07 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:53 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:39 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_octs_h_ -#define _asn_octs_h_ - -#include - -class AsnOcts: public AsnType -{ -private: - int OctsEquiv (const AsnOcts &o) const; - - void FillBitStringStk (BUF_TYPE b, AsnLen elmtLen0, AsnLen& bytesDecoded, ENV_TYPE env); - - void BDecConsOcts (BUF_TYPE b, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - -protected: - size_t octetLen; - char *octs; - -public: - - // constructor and Set alway copy strings so destructor can always delete - AsnOcts(): - octetLen (0), - octs (NULL) - {} - AsnOcts (const char *str) { Set (str); } - AsnOcts (const char *str, const size_t len) - { Set (str, len); } - AsnOcts (const AsnOcts &o) { Set (o); } -#ifndef _IBM_ENC_ - virtual ~AsnOcts(); -#else - virtual ~AsnOcts() { mem_mgr_ptr->Put ((void *)octs); } // Guido Grassel, 11.8.93 -#endif /* _IBM_ENC_ */ - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - AsnOcts &operator = (const AsnOcts &o) { ReSet (o); return *this; } - AsnOcts &operator = (const char *str) { ReSet (str); return *this; } - - // these set the octs and octetLen values - void Set (const char *str, size_t len); - void Set (const AsnOcts &o); - void Set (const char *str); - - // these free the old octs value and - // then reset the octs and octetLen values - void ReSet (const char *str, size_t len); - void ReSet (const AsnOcts &o); - void ReSet (const char *str); - - size_t Len() const { return octetLen; } - operator const char* () const { return octs; } - operator char* () { return octs; } - - const char * Octs() const { return octs; } - -#ifdef VDADER_RULES - bool operator == (const AsnOcts &o) const { if (OctsEquiv(o)) return true; else return false; } -#else - bool operator == (const AsnOcts &o) const { return OctsEquiv (o); } -#endif - bool operator != (const AsnOcts &o) const { return !OctsEquiv (o); } - - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - - void Print (ostream &os) const; - -#if META - static const AsnOctsTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif /* TCL */ -#endif /* META */ -}; - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-oid.h b/SecuritySNACCRuntime/c++-lib/inc/asn-oid.h deleted file mode 100644 index f9375f60..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-oid.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-oid.h - ASN.1 OBJECT IDENTIFIER type -// -// Mike Sample -// 92/07/02 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// -// ------------------------------------------------------------------------ -// - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 - -// ------------------------------------------------------------------------ -// -// All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's -// SCCS. The revision #'s start at 1.1, which is the original version from -// SNACC 1.3. -// -// -// ../SCCS/s.asn-oid.h: -// -// D 1.3 98/04/24 22:41:22 pleonber 3 2 00002/00000/00129 -// added INSERT_VDA_COMMENTS for script that adds SCCS history -// -// D 1.2 97/11/11 15:55:44 dharris 2 1 00004/00000/00125 -// changed == operator to remove warnings -// -// D 1.1 97/11/11 15:50:57 cmmaster 1 0 00125/00000/00000 -// date and time created 97/11/11 15:50:57 by cmmaster -// -// ----------------------- End of VDA Modifications --------------------------- -// -// -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-oid.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-oid.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:24 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.3 1999/03/21 02:07:33 mb -// Added Copy to every AsnType. -// -// Revision 1.2 1999/03/18 22:35:27 mb -// Made all destructors virtual. -// -// Revision 1.1 1999/02/25 05:21:44 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/16 12:56:15 rj -// construct in the order the members are defined -// -// Revision 1.5 1995/07/24 18:37:59 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// _desc type corrected from AsnOctsTypeDesc to AsnOidTypeDesc. -// -// Revision 1.4 1995/02/18 19:25:16 rj -// remove const from arguments that are passed by value. -// -// Revision 1.3 1994/10/08 04:18:08 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:54 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:40 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_oid_h_ -#define _asn_oid_h_ - -class AsnOid: public AsnType -{ -private: - int OidEquiv (const AsnOid &o) const; - -protected: - size_t octetLen; - char *oid; - -public: - AsnOid(): - octetLen (0), - oid (NULL) - {} - - AsnOid (const char *encOid, size_t len) { Set (encOid, len); } - AsnOid (const AsnOid &o) { Set (o); } - AsnOid (unsigned long int a1, unsigned long int a2, long int a3 = -1, long int a4 = -1, long int a5 = -1, long int a6 = -1, long int a7 = -1, long int a8 = -1, long int a9 = -1, long int a10 = -1, long int a11 = -1) - { Set (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); } -#ifndef _IBM_ENC_ - virtual ~AsnOid(); -#else - virtual ~AsnOid() { mem_mgr_ptr->Put ((void*) oid); } // Guido Grassel, 11.8.93 -#endif /* _IBM_ENC_ */ - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - AsnOid &operator = (const AsnOid &o) { ReSet (o); return *this; } - - size_t Len() const { return octetLen; } - const char *Str() const { return oid; } - operator char * () { return oid; } - operator const char * () const { return oid; } - unsigned long int NumArcs() const; - -#ifdef VDADER_RULES - bool operator == (const AsnOid &o) const { if (OidEquiv(o)) return true; else return false; } -#else - bool operator == (const AsnOid &o) const { return OidEquiv (o); } -#endif - bool operator != (const AsnOid &o) const { return !OidEquiv (o); } - - // Set methods overwrite oid and octetLen values - void Set (const char *encOid, size_t len); - void Set (const AsnOid &o); - - // first two arc numbers are mandatory. rest are optional since negative arc nums are not allowed in the - // encodings, use them to indicate the 'end of arc numbers' in the optional parameters - void Set (unsigned long int a1, unsigned long int a2, long int a3 = -1, long int a4 = -1, long int a5 = -1, long int a6 = -1, long int a7 = -1, long int a8 = -1, long int a9 = -1, long int a10 = -1, long int a11 = -1); - - - // ReSet routines are like Set except the old oid value is freed - void ReSet (const char *encOid, size_t len); - void ReSet (const AsnOid &o); - void ReSet (unsigned long int a1, unsigned long int a2, long int a3 = -1, long int a4 = -1, long int a5 = -1, long int a6 = -1, long int a7 = -1, long int a8 = -1, long int a9 = -1, long int a10 = -1, long int a11 = -1); - - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - PDU_MEMBER_MACROS - - void Print (ostream &os) const; - -#if META - static const AsnOidTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif /* TCL */ -#endif /* META */ -}; - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-real.h b/SecuritySNACCRuntime/c++-lib/inc/asn-real.h deleted file mode 100644 index b19cf28e..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-real.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-real.h - ASN.1 REAL type -// -// Mike Sample -// 92/07/02 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-real.h,v 1.2 2001/06/21 21:57:00 dmitch Exp $ -// $Log: asn-real.h,v $ -// Revision 1.2 2001/06/21 21:57:00 dmitch -// Avoid global const PLUS_INFINITY, MINUS_INFINITY -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:24 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:33 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:45 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/16 20:25:42 rj -// check-in of a few cosmetic changes -// -// Revision 1.4 1995/07/24 17:53:59 rj -// #if TCL ... #endif wrapped into #if META ... #endif -// -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:18:09 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:55 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:41 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_real_h_ -#define _asn_real_h_ - -class AsnReal: public AsnType -{ -protected: - double value; - -public: - AsnReal(): - value (0.0) - {} - AsnReal (double val): - value (val) - {} - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - operator double() const { return value; } - AsnReal &operator = (double newvalue) { value = newvalue; return *this; } - - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - - void Print (ostream &os) const; - - PDU_MEMBER_MACROS - -#if META - static const AsnRealTypeDesc _desc; - - const AsnTypeDesc *_getdesc() const; - -#if TCL - int TclGetVal (Tcl_Interp *) const; - int TclSetVal (Tcl_Interp *, const char *val); -#endif /* TCL */ -#endif /* META */ -}; - -extern double AsnPlusInfinity(); -extern double AsnMinusInfinity(); - -#define PLUS_INFINITY AsnReal(AsnPlusInfinity()) -#define MINUS_INFINITY AsnReal(AsnMinusInfinity()) - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-tag.h b/SecuritySNACCRuntime/c++-lib/inc/asn-tag.h deleted file mode 100644 index 3fd3fd37..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-tag.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-tag.h - stuff for dealing with tags -// -// MS 92 -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// -// ------------------------------------------------------------------------ -// - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 - -// ------------------------------------------------------------------------ -// -// All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's -// SCCS. The revision #'s start at 1.1, which is the original version from -// SNACC 1.3. -// -// -// ../SCCS/s.asn-tag.h: -// -// D 1.2 98/04/24 22:39:52 pleonber 2 1 00012/00000/00204 -// added INSERT_VDA_COMMENT for script that adds SCCS history -// -// D 1.1 98/04/17 10:30:00 pleonber 1 0 00204/00000/00000 -// date and time created 98/04/17 10:30:00 by pleonber -// -// ----------------------- End of VDA Modifications --------------------------- -// -// -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-tag.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-tag.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.4 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.3 2000/12/22 00:20:55 dmitch -// Added UTF8STRING_TAG_CODE. -// -// Revision 1.2 2000/06/15 18:48:24 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:45 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/16 20:25:45 rj -// check-in of a few cosmetic changes -// -// Revision 1.5 1995/07/24 17:35:52 rj -// ``#error "..."'' instead of ``#error ...''. -// -// changed `_' to `-' in file names. -// -// Revision 1.4 1995/02/18 16:45:53 rj -// let cpp choose a 32 bit integer type. -// -// Revision 1.3 1994/10/08 04:18:09 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:56 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:43 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_tag_h_ -#define _asn_tag_h_ - -#if SIZEOF_INT == 4 - #define UL unsigned int -#elif SIZEOF_LONG == 4 - #define UL unsigned long -#elif SIZEOF_SHORT == 4 - #define UL unsigned short -#else - #error "can't find integer type which is 4 bytes in size" -#endif -typedef UL AsnTag; - -// Tag Id's byte len -#define TB sizeof (AsnTag) - -// The MAKE_TAG_ID macro generates the TAG_ID rep for the -// the given class/form/code (rep'd in long integer form) -// if the class/form/code are constants the compiler (should) -// calculate the tag completely --> zero runtime overhead. -// This is good for efficiently comparing tags in switch statements -// (decoding) etc. because run-time bit fiddling (eliminated) minimized -#ifndef _IBM_ENC_ -#define MAKE_TAG_ID( cl, fm, cd)\ - ((((UL)(cl)) << ((TB -1) * 8)) | (((UL)(fm)) << ((TB -1) * 8)) | (MAKE_TAG_ID_CODE (((UL)(cd))))) -#else -#define MAKE_TAG_ID( cl, fm, cd)\ - ((MAKE_TAG_ID_CODE (cd)) | (cl << ((TB -1) * 8)) | (fm << ((TB -1) * 8))) -#endif /* _IBM_ENC_ */ - -#define MAKE_TAG_ID_CODE( cd)\ -( (cd < 31) ? (MAKE_TAG_ID_CODE1 (cd)):\ - ((cd < 128)? (MAKE_TAG_ID_CODE2 (cd)):\ - ((cd < 16384)? (MAKE_TAG_ID_CODE3 (cd)):\ - (MAKE_TAG_ID_CODE4 (cd))))) - -#define MAKE_TAG_ID_CODE1( cd) ((long int)cd << ((TB -1) * 8)) -#define MAKE_TAG_ID_CODE2( cd) ((31l << ((TB -1) * 8)) | (cd << ((TB-2) * 8))) -#define MAKE_TAG_ID_CODE3( cd) ((31l << ((TB -1) * 8))\ - | ((cd & 0x3f80) << 9)\ - | ( 0x0080 << ((TB-2) * 8))\ - | ((cd & 0x007F) << ((TB-3)* 8))) - -#define MAKE_TAG_ID_CODE4( cd) ((31l << ((TB -1) * 8))\ - | ((cd & 0x1fc000) << 2)\ - | ( 0x0080 << ((TB-2) * 8))\ - | ((cd & 0x3f80) << 1)\ - | ( 0x0080 << ((TB-3) * 8))\ - | ((cd & 0x007F) << ((TB-4)*8))) - - -typedef enum BER_CLASS -{ - ANY_CLASS = -2, - NULL_CLASS = -1, - UNIV = 0, - APPL = (1 << 6), - CNTX = (2 << 6), - PRIV = (3 << 6) -} BER_CLASS; - -typedef enum BER_FORM -{ - ANY_FORM = -2, - NULL_FORM = -1, - PRIM = 0, - CONS = (1 << 5) -} BER_FORM; - - -typedef enum BER_UNIV_CODE -{ - NO_TAG_CODE = 0, - BOOLEAN_TAG_CODE = 1, - INTEGER_TAG_CODE, - BITSTRING_TAG_CODE, - OCTETSTRING_TAG_CODE, - NULLTYPE_TAG_CODE, - OID_TAG_CODE, - OD_TAG_CODE, - EXTERNAL_TAG_CODE, - REAL_TAG_CODE, - ENUM_TAG_CODE, - UTF8STRING_TAG_CODE = 12, - SEQ_TAG_CODE = 16, - SET_TAG_CODE, - NUMERICSTRING_TAG_CODE, - PRINTABLESTRING_TAG_CODE, - TELETEXSTRING_TAG_CODE, - VIDEOTEXSTRING_TAG_CODE, - IA5STRING_TAG_CODE, - UTCTIME_TAG_CODE, - GENERALIZEDTIME_TAG_CODE, - GRAPHICSTRING_TAG_CODE, - VISIBLESTRING_TAG_CODE, - -#ifndef VDADER_RULES - - GENERALSTRING_TAG_CODE - -#else - GENERALSTRING_TAG_CODE, - UNIVERSALSTRING_TAG_CODE = 28, - BMPSTRING_TAG_CODE = 30 -#endif - -} BER_UNIV_CODE; - -#define TT61STRING_TAG_CODE TELETEXSTRING_TAG_CODE -#define ISO646STRING_TAG_CODE VISIBLESTRING_TAG_CODE - -/* - * the TAG_ID_[CLASS/FORM/CODE] macros are not - * super fast - try not to use during encoding/decoding - */ -#define TAG_ID_CLASS( tid) ( (tid & (0xC0 << ((TB-1) *8))) >> ((TB -1) * 8)) -#define TAG_ID_FORM( tid) ( (tid & (0x20 << ((TB-1) *8))) >> ((TB -1) * 8)) - -/* - * TAG_IS_CONS evaluates to true if the given AsnTag type - * tag has the constructed bit set. - */ -#define TAG_IS_CONS(tag) ((tag) & (CONS << ((TB-1) *8))) - - -#define EOC_TAG_ID 0 - - - -/* - * tag encoders. given constant exprs for class form & code in the - * source, these can be optimized by the compiler (eg - * do the shifts and bitwise ors etc) - */ - -#define BEncTag1( b, class, form, code)\ - 1;\ - b.PutByteRvs ((class) | (form) | (code)) - -#define BEncTag2( b, class, form, code)\ - 2;\ - b.PutByteRvs (code);\ - b.PutByteRvs ((class) | (form) | 31) - -#define BEncTag3( b, class, form, code)\ - 3;\ - b.PutByteRvs ((code) & 0x7F);\ - b.PutByteRvs (0x80 | ((code) >> 7));\ - b.PutByteRvs ((class) | (form) | 31) - -#define BEncTag4( b, class, form, code)\ - 4;\ - b.PutByteRvs ((code) & 0x7F);\ - b.PutByteRvs (0x80 | ((code) >> 7));\ - b.PutByteRvs (0x80 | ((code) >> 14));\ - b.PutByteRvs ((class) | (form) | 31) - -#define BEncTag5( b, class, form, code)\ - 5;\ - b.PutByteRvs ((code) & 0x7F);\ - b.PutByteRvs (0x80 | ((code) >> 7));\ - b.PutByteRvs (0x80 | ((code) >> 14));\ - b.PutByteRvs (0x80 | ((code) >> 21));\ - b.PutByteRvs ((class) | (form) | 31) - - -AsnTag BDecTag (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-type.h b/SecuritySNACCRuntime/c++-lib/inc/asn-type.h deleted file mode 100644 index c096cf64..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-type.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/asn-type.h - Abstract class that all ASN.1 types are derived from -// Design motivated by ANY type. -// -// Runtime cost in speed and space for virtual fcns will -// hopefully not be too bad -// -// If your ASN.1 code does not use ANY or ANY DEFIND BY -// types then you could make the BEnc, BDec and Clone -// non-virtual in the AsnType to improve performance. -// (undef SUPPORT_ANY_TYPE) -// -// NOTE: The virtual encode/decode/print etc fcns -// could be purely virtual (= 0) creating an abstract class -// but the ANY handling code needs to instantiate the AsnType -// base class (via Cloning). Also it allows for default -// error reporting for ANY types that have not been -// instantiated properly. -// -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// MS 92 -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-type.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: asn-type.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:24 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/03/21 02:07:33 mb -// Added Copy to every AsnType. -// -// Revision 1.1 1999/02/25 05:21:46 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/16 20:25:48 rj -// check-in of a few cosmetic changes -// -// Revision 1.5 1995/07/24 17:39:00 rj -// _getref() gets an additional optional argument to faciliate the different member access semantics of TclGetVal() and TclSetVal(). -// -// _typename() made private, no need to be public. -// -// additional function TclUnsetVal() to delete OPTIONAL members and SEQUENCE OF and SET OF list elements. -// -// #if TCL ... #endif wrapped into #if META ... #endif -// -// getTclPDU() deleted. -// -// changed `_' to `-' in file names. -// -// Revision 1.4 1994/10/08 04:18:10 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.3 1994/09/13 14:18:52 rj -// inline functions moved from asn_type.h to asn_type.C. -// functions that are called upon error only don't need to be that fast. -// -// Revision 1.2 1994/08/28 10:00:57 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:44 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_type_h_ -#define _asn_type_h_ - -#ifdef _IBM_ENC_ -#include "shmmgr.h" // Guido Grassel 4.8.93 -#endif /* _IBM_ENC_ */ - -#define SUPPORT_ANY_TYPE - -#if TCL -#include -#undef VOID -#endif - -#if META -#include "meta.h" -#endif - -#ifndef __IBM_ENC_ -class AsnType -#else -class AsnType: public MemMgr // Guido Grassel, 12.8.93 -#endif /* __IBM_ENC_ */ -{ -public: - virtual ~AsnType(); - -#ifdef SUPPORT_ANY_TYPE - - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - virtual void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - virtual AsnLen BEnc (BUF_TYPE b); - -#else - - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) - {} - AsnLen BEnc (BUF_TYPE b) { return 0; } - -#endif - - virtual void Print (ostream &) const; - -#if META - static const AsnTypeDesc _desc; - - virtual const AsnTypeDesc *_getdesc() const; - virtual AsnType *_getref (const char *membername, bool create=false); - -private: - const char *_typename() const; - -#if TCL -public: - virtual int TclGetDesc (Tcl_DString *) const; - virtual int TclGetVal (Tcl_Interp *) const; - virtual int TclSetVal (Tcl_Interp *, const char *val); - virtual int TclUnsetVal (Tcl_Interp *, const char *membernames); -#endif // TCL -#endif // META -}; - -#endif // conditional include diff --git a/SecuritySNACCRuntime/c++-lib/inc/asn-useful.h b/SecuritySNACCRuntime/c++-lib/inc/asn-useful.h deleted file mode 100644 index daadb7b5..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/asn-useful.h +++ /dev/null @@ -1,408 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// asn-useful.h - class definitions for ASN.1 module ASN-USEFUL -// -// This file was generated by snacc on Wed Mar 20 10:07:04 2002 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _asn_useful_h_ -#define _asn_useful_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class ObjectDescriptor; -class UTF8String; -class NumericString; -class PrintableString; -class TeletexString; -class T61String; -class VideotexString; -class IA5String; -class GraphicString; -class VisibleString; -class ISO646String; -class GeneralString; -class UTCTime; -class GeneralizedTime; -class UniversalString; -class BMPString; -class EXTERNALChoice; -class EXTERNAL; - -//------------------------------------------------------------------------------ -// class definitions: - -/* [UNIVERSAL 7] IMPLICIT OCTET STRING */ -class ObjectDescriptor: public AsnOcts -{ -public: - ObjectDescriptor(): AsnOcts() {} - ObjectDescriptor (const char *str): AsnOcts (str) {} - ObjectDescriptor (const char *str, const size_t len): AsnOcts (str, len) {} - ObjectDescriptor (const AsnOcts &o): AsnOcts (o) {} - ObjectDescriptor &operator = (const ObjectDescriptor &o) { ReSet (o); return *this; } - ObjectDescriptor &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 12] IMPLICIT OCTET STRING */ -class UTF8String: public AsnOcts -{ -public: - UTF8String(): AsnOcts() {} - UTF8String (const char *str): AsnOcts (str) {} - UTF8String (const char *str, const size_t len): AsnOcts (str, len) {} - UTF8String (const AsnOcts &o): AsnOcts (o) {} - UTF8String &operator = (const UTF8String &o) { ReSet (o); return *this; } - UTF8String &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 18] IMPLICIT OCTET STRING */ -class NumericString: public AsnOcts -{ -public: - NumericString(): AsnOcts() {} - NumericString (const char *str): AsnOcts (str) {} - NumericString (const char *str, const size_t len): AsnOcts (str, len) {} - NumericString (const AsnOcts &o): AsnOcts (o) {} - NumericString &operator = (const NumericString &o) { ReSet (o); return *this; } - NumericString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 19] IMPLICIT OCTET STRING */ -class PrintableString: public AsnOcts -{ -public: - PrintableString(): AsnOcts() {} - PrintableString (const char *str): AsnOcts (str) {} - PrintableString (const char *str, const size_t len): AsnOcts (str, len) {} - PrintableString (const AsnOcts &o): AsnOcts (o) {} - PrintableString &operator = (const PrintableString &o) { ReSet (o); return *this; } - PrintableString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 20] IMPLICIT OCTET STRING */ -class TeletexString: public AsnOcts -{ -public: - TeletexString(): AsnOcts() {} - TeletexString (const char *str): AsnOcts (str) {} - TeletexString (const char *str, const size_t len): AsnOcts (str, len) {} - TeletexString (const AsnOcts &o): AsnOcts (o) {} - TeletexString &operator = (const TeletexString &o) { ReSet (o); return *this; } - TeletexString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 20] IMPLICIT OCTET STRING */ -class T61String: public AsnOcts -{ -public: - T61String(): AsnOcts() {} - T61String (const char *str): AsnOcts (str) {} - T61String (const char *str, const size_t len): AsnOcts (str, len) {} - T61String (const AsnOcts &o): AsnOcts (o) {} - T61String &operator = (const T61String &o) { ReSet (o); return *this; } - T61String &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 21] IMPLICIT OCTET STRING */ -class VideotexString: public AsnOcts -{ -public: - VideotexString(): AsnOcts() {} - VideotexString (const char *str): AsnOcts (str) {} - VideotexString (const char *str, const size_t len): AsnOcts (str, len) {} - VideotexString (const AsnOcts &o): AsnOcts (o) {} - VideotexString &operator = (const VideotexString &o) { ReSet (o); return *this; } - VideotexString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 22] IMPLICIT OCTET STRING */ -class IA5String: public AsnOcts -{ -public: - IA5String(): AsnOcts() {} - IA5String (const char *str): AsnOcts (str) {} - IA5String (const char *str, const size_t len): AsnOcts (str, len) {} - IA5String (const AsnOcts &o): AsnOcts (o) {} - IA5String &operator = (const IA5String &o) { ReSet (o); return *this; } - IA5String &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 25] IMPLICIT OCTET STRING */ -class GraphicString: public AsnOcts -{ -public: - GraphicString(): AsnOcts() {} - GraphicString (const char *str): AsnOcts (str) {} - GraphicString (const char *str, const size_t len): AsnOcts (str, len) {} - GraphicString (const AsnOcts &o): AsnOcts (o) {} - GraphicString &operator = (const GraphicString &o) { ReSet (o); return *this; } - GraphicString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 26] IMPLICIT OCTET STRING */ -class VisibleString: public AsnOcts -{ -public: - VisibleString(): AsnOcts() {} - VisibleString (const char *str): AsnOcts (str) {} - VisibleString (const char *str, const size_t len): AsnOcts (str, len) {} - VisibleString (const AsnOcts &o): AsnOcts (o) {} - VisibleString &operator = (const VisibleString &o) { ReSet (o); return *this; } - VisibleString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 26] IMPLICIT OCTET STRING */ -class ISO646String: public AsnOcts -{ -public: - ISO646String(): AsnOcts() {} - ISO646String (const char *str): AsnOcts (str) {} - ISO646String (const char *str, const size_t len): AsnOcts (str, len) {} - ISO646String (const AsnOcts &o): AsnOcts (o) {} - ISO646String &operator = (const ISO646String &o) { ReSet (o); return *this; } - ISO646String &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 27] IMPLICIT OCTET STRING */ -class GeneralString: public AsnOcts -{ -public: - GeneralString(): AsnOcts() {} - GeneralString (const char *str): AsnOcts (str) {} - GeneralString (const char *str, const size_t len): AsnOcts (str, len) {} - GeneralString (const AsnOcts &o): AsnOcts (o) {} - GeneralString &operator = (const GeneralString &o) { ReSet (o); return *this; } - GeneralString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 23] IMPLICIT OCTET STRING */ -class UTCTime: public AsnOcts -{ -public: - UTCTime(): AsnOcts() {} - UTCTime (const char *str): AsnOcts (str) {} - UTCTime (const char *str, const size_t len): AsnOcts (str, len) {} - UTCTime (const AsnOcts &o): AsnOcts (o) {} - UTCTime &operator = (const UTCTime &o) { ReSet (o); return *this; } - UTCTime &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 24] IMPLICIT OCTET STRING */ -class GeneralizedTime: public AsnOcts -{ -public: - GeneralizedTime(): AsnOcts() {} - GeneralizedTime (const char *str): AsnOcts (str) {} - GeneralizedTime (const char *str, const size_t len): AsnOcts (str, len) {} - GeneralizedTime (const AsnOcts &o): AsnOcts (o) {} - GeneralizedTime &operator = (const GeneralizedTime &o) { ReSet (o); return *this; } - GeneralizedTime &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 28] IMPLICIT OCTET STRING */ -class UniversalString: public AsnOcts -{ -public: - UniversalString(): AsnOcts() {} - UniversalString (const char *str): AsnOcts (str) {} - UniversalString (const char *str, const size_t len): AsnOcts (str, len) {} - UniversalString (const AsnOcts &o): AsnOcts (o) {} - UniversalString &operator = (const UniversalString &o) { ReSet (o); return *this; } - UniversalString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -/* [UNIVERSAL 30] IMPLICIT OCTET STRING */ -class BMPString: public AsnOcts -{ -public: - BMPString(): AsnOcts() {} - BMPString (const char *str): AsnOcts (str) {} - BMPString (const char *str, const size_t len): AsnOcts (str, len) {} - BMPString (const AsnOcts &o): AsnOcts (o) {} - BMPString &operator = (const BMPString &o) { ReSet (o); return *this; } - BMPString &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); -}; - - -class EXTERNALChoice: public AsnType -{ -public: - enum ChoiceIdEnum - { - single_ASN1_typeCid = 0, - octet_alignedCid = 1, - arbitraryCid = 2 - }; - - enum ChoiceIdEnum choiceId; - union - { - AsnOcts *single_ASN1_type; - AsnOcts *octet_aligned; - AsnBits *arbitrary; - }; - - - EXTERNALChoice(); - EXTERNALChoice (const EXTERNALChoice &); - virtual ~EXTERNALChoice(); - - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EXTERNALChoice &operator = (const EXTERNALChoice &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -class EXTERNAL: public AsnType -{ -public: - AsnOid *direct_reference; - AsnInt *indirect_reference; - ObjectDescriptor *data_value_descriptor; - EXTERNALChoice *encoding; - - EXTERNAL(); - EXTERNAL (const EXTERNAL &); - virtual ~EXTERNAL(); - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - EXTERNAL &operator = (const EXTERNAL &); - AsnLen BEncContent (BUF_TYPE b); - void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - void Print (ostream &os) const; -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -//------------------------------------------------------------------------------ - -#endif /* conditional include of asn-useful.h */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/cdsaUtils.h b/SecuritySNACCRuntime/c++-lib/inc/cdsaUtils.h deleted file mode 100644 index f85019b1..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/cdsaUtils.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * cdsaUtils.h - utility functions for CDSA-related code - */ - -#ifndef _SNACC_CDSA_UTILS_H_ -#define _SNACC_CDSA_UTILS_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* all decoding errors throw CSSMERR_CL_UNKNOWN_FORMAT */ - -/* malloc/copy AsnBits.bits -->CssmOwnedData */ -void SC_asnBitsToCssmData( - const AsnBits &bits, - CssmOwnedData &oData); - -/* given DER-encoded bit string, decoded it and malloc/copy results - * back to a CssmOwnedData */ -void SC_decodeAsnBitsToCssmData( - const CssmData encodedBits, - CssmOwnedData &oData); - -/* DER-decode any AsnType object */ -void SC_decodeAsnObj( - const CssmData &derEncoded, - AsnType &asnObj); - -/* DER-encode any AsnType object. */ -void SC_encodeAsnObj( - AsnType &asnObj, - CssmOwnedData &derEncoded, - size_t maxEncodedSize); - -/* - * Given a contentLength, obtain the length of the DER length encoding. - */ -size_t SC_lengthOfLength( - size_t contentLen); - -/* - * Encode a DER length field. Pass in the lengthOfLength if you've obtained - * it in a previous call to CL_lengthOfLength. - */ -void SC_encodeLength( - size_t contentLen, - void *cp, - size_t lengthOfLength = 0); - -#ifdef __cplusplus -} -#endif - -#endif /* _SNACC_CDSA_UTILS_H_ */ \ No newline at end of file diff --git a/SecuritySNACCRuntime/c++-lib/inc/config.h b/SecuritySNACCRuntime/c++-lib/inc/config.h deleted file mode 100644 index 531ed594..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/config.h +++ /dev/null @@ -1,128 +0,0 @@ -/* config.h. Generated automatically by configure. */ -/* config.h.in. Generated automatically from configure.in by autoheader. */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define if you don't have vprintf but do have _doprnt. */ -/* #undef HAVE_DOPRNT */ - -/* Define if you have the vprintf function. */ -#define HAVE_VPRINTF 1 - -/* Define if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define if your processor stores words with the most significant - byte first (like Motorola and SPARC, unlike Intel and VAX). */ -#define WORDS_BIGENDIAN 1 - -/* Define if the X Window System is missing or not being used. */ -#define X_DISPLAY_MISSING 1 - -/* Define if lex declares yytext as a char * by default, not a char[]. */ -/* #undef YYTEXT_POINTER */ - -/* - * file: acconfig.h - */ - -/* - * define IEEE_REAL_FMT if your system/compiler uses the native ieee double - * this should improve the performance of encoding reals. - * If your system has the IEEE library routines (iszero, isinf etc) - * then define IEEE_REAL_LIB. If neither are defined then - * frexp is used. Performance is probaby best for IEEE_REAL_FMT. - * - * #define IEEE_REAL_FMT - * #define IEEE_REAL_LIB - */ -/* use ANSI or K&R style C? */ -#define __USE_ANSI_C__ 1 - -/* does the C++ compiler have the bool type built-in? */ -#define BOOL_BUILTIN 1 - -/* does the C++ compiler allow variable sized automatic arryas? */ -#define HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS 1 - -/* do we have all the libs we need for the Tcl interface? */ -/* #undef HAVE_TCL */ - -/* does the compiler support volatile functions (and is abort() volatile?) */ -/* #undef COMPILER_WITHOUT_VOLATILE_FUNCTIONS */ - -/* The number of bytes in a double. */ -#define SIZEOF_DOUBLE 8 - -/* The number of bytes in a int. */ -#define SIZEOF_INT 4 - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/* The number of bytes in a short. */ -#define SIZEOF_SHORT 2 - -/* Define if you have the finite function. */ -#define HAVE_FINITE 1 - -/* Define if you have the isinf function. */ -#define HAVE_ISINF 1 - -/* Define if you have the memcmp function. */ -#define HAVE_MEMCMP 1 - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY 1 - -/* Define if you have the memset function. */ -#define HAVE_MEMSET 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the m library (-lm). */ -/* #undef HAVE_LIBM */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/hash.h b/SecuritySNACCRuntime/c++-lib/inc/hash.h deleted file mode 100644 index 1f070c56..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/hash.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/hash.h - C++ hash tbl routines -// -// Based on hashing stuff from UBC Raven Code (Terry Coatta & Don Acton) -// -// MS 92 -// Copyright (C) 1992 the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/hash.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: hash.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:25 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:46 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/28 13:39:42 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.4 1997/02/16 20:25:51 rj -// check-in of a few cosmetic changes -// -// Revision 1.3 1994/10/08 04:18:12 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:00:59 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:46 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _asn_hash_h_ -#define _asn_hash_h_ - -#define TABLESIZE 256 -#define INDEXMASK 0xFF -#define INDEXSHIFT 8 - -typedef void *Table[TABLESIZE]; - -typedef unsigned int Hash; - -typedef struct HashSlot -{ - int leaf; - Hash hash; - void *value; - Table *table; -} HashSlot; - -Hash MakeHash (const char *str, size_t len); - -Table *InitHash(); - -int Insert (Table *table, void *element, Hash hash); - -int CheckFor (Table *table, Hash hash); - -int CheckForAndReturnValue (Table *table, Hash hash, void **value); - - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/init.h b/SecuritySNACCRuntime/c++-lib/inc/init.h deleted file mode 100644 index 99389308..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/init.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * file: .../c++-lib/inc/init.h - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/init.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ - * $Log: init.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:06 mb - * Move from private repository to open source repository - * - * Revision 1.3 2001/05/05 00:59:18 rmurphy - * Adding darwin license headers - * - * Revision 1.2 2000/06/15 18:48:25 dmitch - * Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. - * - * Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy - * Base Fortissimo Tree - * - * Revision 1.1 1999/02/25 05:21:47 mb - * Added snacc c++ library - * - * Revision 1.1 1995/07/27 09:22:35 rj - * new file: .h file containing a declaration for a function defined in a C++ file, but with C linkage. - * - */ - -extern -#ifdef __cplusplus - "C" -#endif - int Snacc_Init (Tcl_Interp *interp); diff --git a/SecuritySNACCRuntime/c++-lib/inc/meta.h b/SecuritySNACCRuntime/c++-lib/inc/meta.h deleted file mode 100644 index ce1ef325..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/meta.h +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/meta.h -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/meta.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: meta.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:25 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:47 mb -// Added snacc c++ library -// -// Revision 1.6 1997/02/28 13:39:43 wan -// Modifications collected for new version 1.3: Bug fixes, tk4.2. -// -// Revision 1.5 1995/09/07 18:50:04 rj -// long int replaced by newly introduced AsnIntType. -// it shall provide a 32 bit integer type on all platforms. -// -// Revision 1.4 1995/08/17 15:23:47 rj -// introducing an AsnEnumTypeDesc class with its own TclGetDesc2 function that returns the value names but omits the numeric values. -// utility function AsnSe_TypeDesc::mandatmemberr added. -// - -#include -#include - -struct AsnNameDesc -{ - const char *const name; - const AsnIntType value; -}; - -struct AsnTypeDesc; - -struct AsnMemberDesc // description of CHOICE member; base class for AsnSe_MemberDesc -{ - const char *const name; - const AsnTypeDesc *const desc; - - AsnMemberDesc (const char *, const AsnTypeDesc *); - AsnMemberDesc(); - -#if TCL - virtual int TclGetDesc (Tcl_DString *) const; - virtual int TclGetDesc2 (Tcl_DString *) const; -#endif -}; - -struct AsnSe_MemberDesc: AsnMemberDesc // _ == t/quence; description of SET or SEQUENCE member -{ - bool optional; - - AsnSe_MemberDesc (const char *, const AsnTypeDesc *, bool); - AsnSe_MemberDesc(); - -#if TCL - int TclGetDesc2 (Tcl_DString *) const; -#endif -}; - -typedef AsnMemberDesc AsnChoiceMemberDesc; -typedef AsnSe_MemberDesc AsnSetMemberDesc; -typedef AsnSe_MemberDesc AsnSequenceMemberDesc; - -struct AsnModuleDesc; - -class AsnType; - -struct AsnTypeDesc -{ - const AsnModuleDesc *module; - const char *const name; // NULL for basic types - const bool pdu; - const enum Type // NOTE: keep this enum in sync with the typenames[] - { - VOID, - ALIAS, - - INTEGER, - REAL, - NUL_, // sic! (can't fight the ubiquitous NULL #define) - BOOLEAN, - ENUMERATED, - BIT_STRING, - OCTET_STRING, - OBJECT_IDENTIFIER, - - SET, - SEQUENCE, - SET_OF, - SEQUENCE_OF, - CHOICE, - ANY - } type; - - AsnType *(*create)(); - - static const char *const typenames[]; - - AsnTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)()); - - virtual const AsnModuleDesc *getmodule() const; - virtual const char *getname() const; - virtual bool ispdu() const; - virtual Type gettype() const; - virtual const AsnNameDesc *getnames() const; - //virtual const AsnMemberDesc *getmembers() const; - -#if TCL - virtual int TclGetDesc (Tcl_DString *) const; - virtual int TclGetDesc2 (Tcl_DString *) const; -#endif -}; - -struct AsnNamesTypeDesc: AsnTypeDesc -{ - const AsnNameDesc *const names; - - AsnNamesTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnNameDesc *); - - const AsnNameDesc *getnames() const; - -#if TCL - int TclGetDesc (Tcl_DString *) const; - // for BIT STRING and INTEGER, ENUMERATED has its own: - int TclGetDesc2 (Tcl_DString *) const; -#endif -}; - -struct AsnEnumTypeDesc: AsnNamesTypeDesc -{ - AsnEnumTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnNameDesc *); - -#if TCL - int TclGetDesc2 (Tcl_DString *) const; -#endif -}; - -struct AsnMembersTypeDesc: AsnTypeDesc -{ - AsnMembersTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)()); - -#if TCL - int TclGetDesc (Tcl_DString *) const; -#endif -}; - -struct AsnChoiceTypeDesc: AsnMembersTypeDesc -{ - const AsnChoiceMemberDesc *const members; - - AsnChoiceTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnChoiceMemberDesc *); - - int choicebyname (const char *name) const; - const char *choicebyvalue (int value) const; - -#if TCL - int TclGetDesc2 (Tcl_DString *) const; -#endif -}; - -struct AsnSe_TypeDesc: AsnMembersTypeDesc -{ - const AsnSe_MemberDesc *const members; - - AsnSe_TypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnSe_MemberDesc *); - -#if TCL - int mandatmemberr (Tcl_Interp *interp, const char *membername) const; - int TclGetDesc2 (Tcl_DString *) const; -#endif -}; - -struct AsnListTypeDesc: AsnTypeDesc -{ - const AsnTypeDesc *const base; - - AsnListTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnTypeDesc *); - -#if TCL - int TclGetDesc (Tcl_DString *) const; -#endif -}; - -struct AsnAliasTypeDesc: AsnTypeDesc -{ - const AsnTypeDesc *const alias; - - AsnAliasTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnTypeDesc *); - - const AsnModuleDesc *getmodule() const; - const char *getname() const; - bool ispdu() const; - Type gettype() const; - - const AsnNameDesc *getnames() const; - //const AsnMemberDesc *getmembers() const; - -#if TCL - int TclGetDesc (Tcl_DString *) const; -#endif -}; - -typedef AsnTypeDesc AsnRealTypeDesc; -typedef AsnTypeDesc AsnNullTypeDesc; -typedef AsnTypeDesc AsnBoolTypeDesc; -typedef AsnNamesTypeDesc AsnIntTypeDesc; -typedef AsnNamesTypeDesc AsnBitsTypeDesc; -typedef AsnTypeDesc AsnOctsTypeDesc; -typedef AsnTypeDesc AsnOidTypeDesc; -typedef AsnSe_TypeDesc AsnSetTypeDesc; -typedef AsnSe_TypeDesc AsnSequenceTypeDesc; - -struct AsnModuleDesc -{ - const char *const name; - const AsnTypeDesc **const types; -}; - -extern const AsnModuleDesc *asnModuleDescs[]; - -#if TCL - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -// designed to be used with Tcl_SplitList(): argument list that automagically frees itself when it goes out of scope: - -struct Args -{ - int c; - char **v; - - Args(); - virtual ~Args(); -}; - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -// file that automagically closes itself when it goes out of scope: - -struct TmpFD -{ - int fd; - - TmpFD() { fd = -1; } - TmpFD (int _fd) { fd = _fd; } - ~TmpFD() { if (fd > 0) ::close (fd); } - - int operator = (int _fd){ return fd = _fd; } -// operator int() { return fd; } -}; - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -// hack to cope with Tcl's inability to handle binary strings: - -extern int debinify (Tcl_Interp *interp, const char *in, size_t len); -extern int binify (Tcl_Interp *interp, const char *str, char *buf, size_t *len); - -//\[sep]---------------------------------------------------------------------------------------------------------------------------- -#endif /* TCL */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/print.h b/SecuritySNACCRuntime/c++-lib/inc/print.h deleted file mode 100644 index d5d326b9..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/print.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/print.h -// -// MS 92 -// -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/print.h,v 1.3 2001/06/27 23:57:51 dmitch Exp $ -// $Log: print.h,v $ -// Revision 1.3 2001/06/27 23:57:51 dmitch -// Reimplement partial fix for Radar 2664258: Print() routines are now empty stubs in NDEBUG config. -// -// Revision 1.2 2001/06/27 23:09:16 dmitch -// Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration. -// -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:25 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:47 mb -// Added snacc c++ library -// -// Revision 1.4 1997/02/16 20:25:54 rj -// check-in of a few cosmetic changes -// -// Revision 1.3 1994/10/08 04:18:13 rj -// code for meta structures added (provides information about the generated code itself). -// -// code for Tcl interface added (makes use of the above mentioned meta code). -// -// virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. -// -// made Print() const (and some other, mainly comparison functions). -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:00 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:47 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _snacccpp_print_h_ -#define _snacccpp_print_h_ - -extern unsigned short int indentG; -extern unsigned short int stdIndentG; - -void Indent (ostream &os, unsigned short int i); - -ostream &operator << (ostream &os, const AsnType &a); - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/sm_vdasnacc.h b/SecuritySNACCRuntime/c++-lib/inc/sm_vdasnacc.h deleted file mode 100644 index 69620140..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/sm_vdasnacc.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* @(#) sm_vdasnacc.h 1.21 5/1/98 09:59:08 */ -// vdasnacc.h -// -#ifndef _SM_VDASNACC_H_ -#define _SM_VDASNACC_H_ - -#include "asn-incl.h" - -#include -#ifndef SM_SIZE_T -#define SM_SIZE_T size_t -#endif - -#ifdef WIN32 -#include -#define SM_FOPEN_WRITE "wb" -#define SM_FOPEN_READ "rb" -#define SM_FOPEN_APPEND "ab" -#else -#define SM_FOPEN_WRITE "w" -#define SM_FOPEN_READ "r" -#define SM_FOPEN_APPEND "a" -#endif - - -////////////////////////////////////////////////////////////////////////// -// CSM_Buffer is the general purpose buffer used throughout the SFL -class CSM_Buffer: public AsnType -{ -private: - SM_SIZE_T m_lSize; - char *m_pMemory; -#if !defined(macintosh) && !defined(__APPLE__) - char *m_pszFN; - FILE *m_pFP; -#endif - char *m_pMemFP; - char *m_pCache; - SM_SIZE_T m_lCacheSize; - -#if !defined(macintosh) && !defined(__APPLE__) - // returns bool value indicating if the buffer is in a file - bool InFile() { if (m_pszFN == NULL) return false; else return true; } -#endif - - // AllocMoreMem allocates specified more bytes for mem buffer - void AllocMoreMem(SM_SIZE_T lSize); - -public: - // CONSTRUCTORS - // use this constructor to create a complete empty buffer - CSM_Buffer(); - // use this constructor to create a memory buffer of size lSize - CSM_Buffer(size_t lSize); - // use this constructor to create a buffer in file pszFileName - //CSM_Buffer(char *pszFileName); - // use this constructor to init the memory buffer with a ptr and size - CSM_Buffer(const char *pBuf, SM_SIZE_T lSize); - // use this constructor to make a copy of the provided buffer - // and put it into this buffer - CSM_Buffer(const CSM_Buffer &b); - - virtual ~CSM_Buffer(); // DESTRUCTOR - - // Inheirited from AsnType. - virtual AsnType *Clone() const; - virtual AsnType *Copy() const; - - virtual AsnLen BEnc (BUF_TYPE b); - void Print (ostream &os) const; - - // CONTENT MODIFYING MEMBERS - void Clear(); - - // ATTRIBUTE MEMBERS - // return size of the buffer - SM_SIZE_T Length() const; - // copy the provided null terminated memory in memory buffer - void Set(const char *psz); - // copy the provided memory of size lSize in memory buffer - void Set(const char *p, SM_SIZE_T lSize); - // set the length of the buffer - void SetLength(SM_SIZE_T lSize) { m_lSize = lSize; } -#if !defined(macintosh) && !defined(__APPLE__) - // copy the provided file name into m_pszFN - void SetFileName(char *pszFN) - { -#ifdef HAVE_STRDUP - strdup(pszFN); -#else - m_pszFN = (char *)malloc (strlen (pszFN) + 1); - strcpy (m_pszFN, pszFN); -#endif - } -#endif - // allocate memory in the buffer and return ptr to it - char* Alloc(SM_SIZE_T lSize); - // compare this with b, return 0 if match - long Compare(const CSM_Buffer &b); - // ReSet copies b into this - long ReSet(const CSM_Buffer &b); - - // BUFFER DATA ACCESS MEMBERS - // return a pointer to the actual data, if in file, call CopyAll - const char* Access() const; - // return a copy of the actual data and return the size - char* Get(SM_SIZE_T &l) const; - // return a copy of the actual data - char* Get() const { SM_SIZE_T l; return Get(l); } - - // COMPARISON OPERATORS - bool operator == (/*const*/ CSM_Buffer &b) { - if (Compare(b) == 0) return true; else return false; } - bool operator != (/*const*/ CSM_Buffer &b) { - if (Compare(b) == 0) return false; else return true; } - - // ASSIGNMENT OPERATOR - CSM_Buffer &operator = (/*const*/ CSM_Buffer &b) { - ReSet(b); return *this; } - -#if !defined(macintosh) && !defined(__APPLE__) - // BUFFER CONVERSION MEMBERS - long ConvertFileToMemory(); - long ConvertMemoryToFile(char *pszFN); -#endif - - // STREAMING MEMBERS - long Open(char *pszMode); - long Seek(SM_SIZE_T lOffset, SM_SIZE_T lOrigin); - void Close(); - - // STREAMING MEMBERS - long cRead(char *pBuffer, SM_SIZE_T lSize); - long Write(const char *pBuffer, SM_SIZE_T lSize); - char* nRead(SM_SIZE_T lSize, SM_SIZE_T &lBytesRead); - void Flush(); -}; - -long vdasnacc_sortSet(CSM_Buffer *pEncBuf[], int icount); -long vdasnacc_sortSetOf(CSM_Buffer **&pEncBuf, int icount); -long SM_WriteToAsnBuf(CSM_Buffer *&pCBuf, AsnBuf &SNACCinputBuf); -long SM_WriteToAsnBuf(CSM_Buffer &CBuf, AsnBuf &SNACCoutputBuf); -long SM_ReadFromAsnBuf(CSM_Buffer *&pCBuf, // OUT,copied data. - AsnBuf &SNACCinputBuf, // IN, input SNACC buffer - long length, // IN, length of data to read. - CSM_Buffer *preLoad); // IN, optional data to be pre-loaded; - // (for SNACC support) -// no alloc version of SM_ReadFromAsnBuf -long SM_ReadFromAsnBuf( - AsnBuf &SNACCinputBuf, // IN, input SNACC buffer - CSM_Buffer *pCBuf, // OUT,copied data. - long length, // IN, length of data to read. - CSM_Buffer *preLoad); // IN, optional data to be pre-loaded; - // (for SNACC support) -// function to convert an AsnBits to a CSM_Buffer -long SM_AsnBits2Buffer(AsnBits *pBits, CSM_Buffer *pBuffer); -long SM_Buffer2AsnBits(CSM_Buffer *pBuffer, AsnBits *pBits, size_t lBits); -long SM_BufferReverseBits(CSM_Buffer *pBuffer); - -class BigIntegerStr; -#define SM_BUF_2_BIG_INT_STR 0 -#if SM_BUF_2_BIG_INT_STR -// FIXME - why doesn't this link properly? -// prototypes for converting to and from BigIntegerStr and CSM_Buffer. -long SM_Buffer2BigIntegerStr( CSM_Buffer *asn1Data, - BigIntegerStr &pSnaccBigIntStr, - bool unsignedFlag); - -long SM_Buffer2BigIntegerStr( CSM_Buffer *asn1Data, - BigIntegerStr *&pSnaccBigIntStr, - bool unsignedFlag); -#endif /* SM_BUF_2_BIG_INT_STR */ - -// VDASNACC_ENCDEC_BUFSIZE is the number of bytes in the global -// buffer used for encoding and decoding -#define VDASNACC_ENCDEC_BUFSIZE 100000 - -//typedef struct -//{ -// long lgth; /* Number of characters in string */ -// unsigned char *str; /* Pointer to character string */ -//} Str_struct; - -#define NULL_STR (Str_struct *) NULL - -//extern "C" { -//#include /**** Standard I/O includes ****/ -//long vdasnacc_sortSetOf(Str_struct **strEnc, int icount); -//long vdasnacc_sortSet(Str_struct **strEnc, int icount); -//void free_Str(Str_struct *str); -//void free_Str_content(Str_struct *str); -//} - -#if SNACC_ENABLE_PDU -/* Note no equivalent if !SNACC_ENABLE_PDU */ -#define ENCODE_ANY(encodedData,asnAny)\ - {\ - CSM_Buffer *blob=new CSM_Buffer;\ -\ - if ((encodedData) && (asnAny))\ - {\ - ENCODE_BUF((encodedData), blob)\ - (asnAny)->value = (AsnType *)blob;\ - }\ - } - -#define DECODE_ANY(decodeData,asnAny)\ - {\ - CSM_Buffer *blob;\ - if ((asnAny))\ - blob=(CSM_Buffer *)(asnAny)->value;\ -\ - if (blob)\ - DECODE_BUF((decodeData), blob)\ - } - -#define ENCODE_BUF_NO_ALLOC(encodeData, blob)\ - {\ - char *pchBuffer = (char *)calloc(1, \ - VDASNACC_ENCDEC_BUFSIZE);\ - size_t encodedLen;\ - AsnBuf outputBuf;\ - int status=0;\ - \ - outputBuf.Init(pchBuffer, VDASNACC_ENCDEC_BUFSIZE);\ - outputBuf.ResetInWriteRvsMode();\ - status = (encodeData)->BEncPdu (outputBuf, encodedLen);\ - outputBuf.ResetInReadMode();\ - SM_ReadFromAsnBuf(outputBuf, (blob), outputBuf.DataLen(),NULL);\ - free(pchBuffer);\ - } - -#define ENCODE_BUF(encodeData, blob)\ - {\ - char *pchBuffer = (char *)calloc(1, \ - VDASNACC_ENCDEC_BUFSIZE);\ - size_t encodedLen;\ - AsnBuf outputBuf;\ - int status=0;\ - \ - outputBuf.Init(pchBuffer, VDASNACC_ENCDEC_BUFSIZE);\ - outputBuf.ResetInWriteRvsMode();\ - if((status = (encodeData)->BEncPdu (outputBuf, encodedLen))==false)\ - SME_THROW(33, "BAD SNACC Encode", NULL);\ - outputBuf.ResetInReadMode();\ - SM_ReadFromAsnBuf((blob), outputBuf, outputBuf.DataLen(),NULL);\ - free(pchBuffer);\ - } - -#define DECODE_BUF(decodeData, blob)\ - {\ - char *pchBuffer = (char *)calloc(1, \ - VDASNACC_ENCDEC_BUFSIZE);\ - size_t encodedLen;\ - AsnBuf outputBuf;\ - int nDecStatus = 0;\ - \ - outputBuf.Init(pchBuffer, VDASNACC_ENCDEC_BUFSIZE);\ - outputBuf.ResetInWriteRvsMode();\ - SM_WriteToAsnBuf((blob), outputBuf);\ - outputBuf.ResetInReadMode();\ - if ((nDecStatus = (decodeData)->BDecPdu(outputBuf, encodedLen)) == false)\ - SME_THROW(34, "BAD SNACC Decode", NULL);\ - free(pchBuffer);\ - } - -#endif /* SNACC_ENABLE_PDU */ - -// This macro is usually only necessary if a SNACC AsnBuf is used -// immediately after being loaded by an application (e.g. consecutive -// encode decode operations). -#define SNACC_BUFRESET_READ(pSnaccBuf) (pSnaccBuf)->ResetInReadMode(); -#define SNACC_BUFRESET_WRITE(pSnaccBuf) (pSnaccBuf)->ResetInWriteRvsMode(); - -#define SM_ASSIGN_ANYBUF(lpBuf, asnAny)\ - {\ - (asnAny)->value = (AsnType *)new CSM_Buffer(*(lpBuf));\ - } - -/* don't know if this actually works... dave */ -#define SM_EXTRACT_ANYBUF(pSS, asnAny)\ - {\ - (pSS) = new CSM_Buffer(*(CSM_Buffer *)(asnAny)->value);\ - } - -#define ENCODE_BUF1(encodeContent, encodeLen)\ - {\ - AsnBuf outputBuf;\ - char *lpszBuf;\ -\ - lpszBuf = (char *)calloc(1, VDASNACC_ENCDEC_BUFSIZE/2);\ - outputBuf.Init(lpszBuf, VDASNACC_ENCDEC_BUFSIZE/2);\ - outputBuf.ResetInWriteRvsMode();\ - (encodeLen) = encodeContent(outputBuf); - -#define ENCODE_BUF2(blob)\ - outputBuf.ResetInReadMode();\ - SM_ReadFromAsnBuf((blob), outputBuf, outputBuf.DataLen(),NULL);\ - free(lpszBuf);\ - } - - // RWC; The following macro defines the ASN ANY load for "BEnc...()" - // RWC; operations into the final output buffers. NO ERROR checking - // RWC; is performed to be sure the buffer is ASN decodable. - // RWC; this convention for loading ANY results is only valid for - // RWC; the SMIME/MSP library loads, where previous logic has - // RWC; loaded the "AsnType *value" element with a "CSM_Buffer *" - // RWC; containing the encoded ANY result. - // RWC; The "Str_struct *" needs to be freed when class destroyed. - // RWC; Place encoded ASN directly into buffer. -#if defined(macintosh) || defined(__APPLE__) -#define ENC_LOAD_ANYBUF(asnType, Bbuf, l) \ - if ((asnType)->value != NULL)\ - {\ - l = (asnType)->value->BEnc(Bbuf);\ - } -#else -#define ENC_LOAD_ANYBUF(asnType, Bbuf, l) \ - if ((CSM_Buffer *)(asnType)->value != NULL)\ - {\ - SM_WriteToAsnBuf(((CSM_Buffer *&)(asnType)->value), Bbuf);\ - l = ((CSM_Buffer *)(asnType)->value)->Length();\ - } -#endif - -// RWC; The following macro decodes the ANY buffer tag and length to -// RWC; allocate a "CSM_Buffer", then copies the unencoded results. -// RWC; The assumption is that the "readloc" buffer will still be intact -// RWC; even after the decode of the tag and length. (HOPEFULLY!) -// RWC; Once the data for this ANY is copied, unencoded into the CSM_Buffer -// RWC; then we set the buffer "readloc" pointer to after this element. -// RWC; "bBuf.GetSeg(elmtLen)" -#define DEC_LOAD_ANYBUF(asnType, Bbuf, l, env) \ - {\ - size_t len = (size_t) 0; \ - AsnLen bytesDecoded = 0L; \ - size_t elmtLen = (size_t) 0; \ - int tag = 0 ; \ - char *readloc = NULL; \ - CSM_Buffer *blob; \ - CSM_Buffer *preLoad;\ -\ - readloc = Bbuf.GetSeg (&len);\ - tag = BDecTag (Bbuf, bytesDecoded, env);\ - elmtLen = BDecLen (Bbuf, bytesDecoded, env);\ - len = bytesDecoded;\ - preLoad = new CSM_Buffer(readloc, len);\ - SM_ReadFromAsnBuf(blob, (Bbuf), elmtLen,preLoad);\ - (asnType)->value = blob;\ - delete preLoad;\ - l += len + elmtLen;\ - } - - -// RWC; Correctly process our OID values, the "char *" "asnOid->Set()" function -// directly loads the "->oid" private variable, no processing!!! -//int SM_STR_TO_OID(char *lpStrOid, AsnOid *asnOid); -//int SM_OID_TO_STR(char *lpStrOid, AsnOid *asnOid); - -#ifdef BOB -#define SNACC_OID_FIX(asnOid, long_arr4) \ - {\ - unsigned long int a[11];\ - int i;\ - for (i=0; i < (long_arr4)->lgth; i++) a[i] = (long_arr4)->int_arr[i];\ - for (i=(long_arr4)->lgth; i < 11; i++) a[i] = -1;\ - (asnOid)->Set(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],\ - a[10]);\ - } -#endif - -#endif // _SM_VDASNACC_H_ - -// EOF vdasnacc.h diff --git a/SecuritySNACCRuntime/c++-lib/inc/sm_vdatypes.h b/SecuritySNACCRuntime/c++-lib/inc/sm_vdatypes.h deleted file mode 100644 index 5f631a51..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/sm_vdatypes.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// NOTE: this is a machine generated file--editing not recommended -// -// sm_vdatypes.h - class definitions for ASN.1 module VdaEnhancedTypes -// -// This file was generated by snacc on Mon Mar 22 21:49:57 1999 -// UBC snacc by Mike Sample -// A couple of enhancements made by IBM European Networking Center - -#ifndef _sm_vdatypes_h_ -#define _sm_vdatypes_h_ - - -//------------------------------------------------------------------------------ -// class declarations: - -class BigIntegerStr; - -//------------------------------------------------------------------------------ -// class definitions: - -/* [UNIVERSAL 2] IMPLICIT OCTET STRING */ -class BigIntegerStr: public AsnOcts -{ -public: - BigIntegerStr(): AsnOcts() {} - BigIntegerStr (const char *str): AsnOcts (str) {} - BigIntegerStr (const char *str, const size_t len): AsnOcts (str, len) {} - BigIntegerStr (const AsnOcts &o): AsnOcts (o) {} - BigIntegerStr &operator = (const BigIntegerStr &o) { ReSet (o); return *this; } - BigIntegerStr &operator = (const char *str) { ReSet (str); return *this; } - virtual AsnType *Clone() const; - - virtual AsnType *Copy() const; - - AsnLen BEnc (BUF_TYPE b); - void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); - int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded); - int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded); - -}; - - -//------------------------------------------------------------------------------ -// externs for value defs - -//------------------------------------------------------------------------------ - -#endif /* conditional include of sm_vdatypes.h */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/snacc.h b/SecuritySNACCRuntime/c++-lib/inc/snacc.h deleted file mode 100644 index ee407878..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/snacc.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * file: snacc.h - * - * - * ------------------------------------------------------------------------ - * - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 - - * ------------------------------------------------------------------------ - * - * All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's - * SCCS. The revision #'s start at 1.1, which is the original version from - * SNACC 1.3. - * - * - * ../SCCS/s.snacc.h: - * - * D 1.3 98/04/24 22:30:19 pleonber 3 2 00002/00000/00157 - * added INSERT_VDA_COMMENTS comment for script that adds SCCS history. - * - * D 1.2 97/11/07 08:01:08 pleonber 2 1 00004/00000/00153 - * added #ifndef _gVDADER_RULES extern int gVDADER_RULES #endif - * - * D 1.1 97/10/30 13:09:44 cmmaster 1 0 00153/00000/00000 - * date and time created 97/10/30 13:09:44 by cmmaster - * - * ----------------------- End of VDA Modifications --------------------------- - * - * - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/snacc.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ - * $Log: snacc.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:06 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:18 rmurphy - * Adding darwin license headers - * - * Revision 1.1 2000/06/15 18:47:21 dmitch - * Files duplicated or copied from elsewhere. See Apple_README for gory details. - * - * Revision 1.1.1.1 2000/03/09 01:00:04 rmurphy - * Base Fortissimo Tree - * - * Revision 1.1 1999/02/25 05:32:31 mb - * Added public headers. - * - * Revision 1.7 1997/04/07 13:13:18 wan - * Made more C++ readable (credits to Steve Walker) - * - * Revision 1.6 1997/02/28 13:39:35 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.5 1997/02/15 20:38:48 rj - * In member functions, return *this after calling abort() for stupid compilers that don't seem to know about volatile abort() (they would otherwise abort with an error). - * - * Revision 1.4 1995/07/24 15:06:52 rj - * configure checks for mem* functions. define replacements using b* functions, if necessary. - * - */ - -#ifndef _SNACC_H_ -#define _SNACC_H_ - -#define GLASS 1 -#define KHO 1 - -#include "config.h" - -#if STDC_HEADERS -#include -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#if HAVE_MEMCMP /* memcmp(3) returns <0, 0 and 0, bcmp(3) returns only 0 and !0 */ -#define memcmpeq( a, b, len) memcmp (a, b, len) -#else -#define memcmpeq( a, b, len) bcmp (a, b, len) -#endif -#if HAVE_MEMSET -#define memzero( p, len) memset (p, 0, len) -#else -#define memzero( p, len) bzero (p, len) -#endif -#if !HAVE_MEMCPY -#define memcpy( dst, src, len) bcopy (src, dst, len) -#endif - -#ifdef __cplusplus - -#ifdef VOLATILE_RETRUN -# define RETURN_THIS_FOR_COMPILERS_WITHOUT_VOLATILE_FUNCTIONS return *this; -#else -# define RETURN_THIS_FOR_COMPILERS_WITHOUT_VOLATILE_FUNCTIONS -#endif - -#if !BOOL_BUILTIN -#ifndef true -// enum bool { false, true }; -// the above looks elegant, but leads to anachronisms (<, ==, !=, ... return value of type int, not enum bool), therefore: -typedef int bool; -enum { false, true }; -#endif -#endif - -#else /* !__cplusplus */ - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - -#endif /* __cplusplus */ - -/* - * Inspired by gdb 4.0, for better or worse... - * (grabbed from Barry Brachman - MS) - * - * These macros munge C routine declarations such - * that they work for ANSI or non-ANSI C compilers - */ -#ifdef __USE_ANSI_C__ - -#define PROTO( X) X -#define PARAMS( arglist, args) (args) -#define NOPARAMS() (void) -#define _AND_ , -#define DOTS , ... - -#else /* !__USE_ANSI_C__ */ - -#define PROTO( X) () -#define PARAMS( arglist, args) arglist args; -#define NOPARAMS() () -#define _AND_ ; -#define DOTS -#define void char - -#endif /* __USE_ANSI_C__ */ - -#include "policy.h" - -#if COMPILER -#define TCL (HAVE_TCL && !NO_TCL) -#define META (TCL && !NO_META) -#endif - -#if MAKEDEPEND -#if !NO_META -#ifdef META -#undef META -#endif -#define META 1 -#endif -#if !NO_TCL -#ifdef TCL -#undef TCL -#endif -#define TCL 1 -#endif -#endif - -#if TCL -#ifdef META -#undef META -#endif -#define META 1 -#endif - -#define COMMA , - -#ifdef _IBM_ENC_ -#define if_IBM_ENC( code) code -#else -#define if_IBM_ENC( code) -#endif - -#if META -#define if_META( code) code -#else -#define if_META( code) -#endif - -#if TCL && META -#define if_TCL( code) code -#else -#define if_TCL( code) -#endif - -#ifndef _gVDADER_RULES -extern int gVDADER_RULES; -#endif - -#endif /* _SNACC_H_ */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/str-stk.h b/SecuritySNACCRuntime/c++-lib/inc/str-stk.h deleted file mode 100644 index 89605489..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/str-stk.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/str-stk.h - maintains a stack of the components of a bit string or octet string so they can be copied into a single chunk -// -// MS 92/07/06 -// -// Copyright (C) 1992 Michael Sample and the University of British Columbia -// -// This library is free software; you can redistribute it and/or -// modify it provided that this copyright/license information is retained -// in original form. -// -// If you modify this file, you must clearly indicate your changes. -// -// This source code 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. -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/str-stk.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: str-stk.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:25 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.2 1999/06/04 21:43:20 mb -// Fixed several memory leaks. -// -// Revision 1.1 1999/02/25 05:21:48 mb -// Added snacc c++ library -// -// Revision 1.5 1997/02/16 20:25:56 rj -// check-in of a few cosmetic changes -// -// Revision 1.4 1995/07/25 21:09:14 rj -// changed `_' to `-' in file names. -// -// Revision 1.3 1994/10/08 04:15:30 rj -// fixed both Copy()'s name and implementation to CopyOut() that always returns the number of bytes copied out instead of 0 in case less than the requested amount is available. -// -// several `unsigned long int' turned into `size_t'. -// -// Revision 1.2 1994/08/28 10:01:01 rj -// comment leader fixed. -// -// Revision 1.1 1994/08/28 09:20:49 rj -// first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - -#ifndef _str_stk_h_ -#define _str_stk_h_ - -#ifndef _IBM_ENC_ -class StrStk -#else -#include "shmmgr.h" // Guido Grassel 4.8.93 - -class StrStk: public MemMgr // Guido Grassel 12.8.93 -#endif /* _IBM_ENC_ */ -{ -public: - struct Elmt - { - char *str; - size_t len; - } *stk; - size_t size; - size_t growSize; - size_t nextFreeElmt; - size_t totalByteLen; - - StrStk (int stkSize, int growIncrement); - ~StrStk (); - - void Reset(); - - void Push (char *str, size_t strLen); - - // copy string pieces (buffer refs) into single block. - // assumes that the buf is at least totalByteLen byte long. - void CopyOut (char *buf); - -}; - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c++-lib/inc/tcl-if.h b/SecuritySNACCRuntime/c++-lib/inc/tcl-if.h deleted file mode 100644 index 8c9718a9..00000000 --- a/SecuritySNACCRuntime/c++-lib/inc/tcl-if.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// file: .../c++-lib/inc/tcl-if.h -// -// $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/tcl-if.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $ -// $Log: tcl-if.h,v $ -// Revision 1.1.1.1 2001/05/18 23:14:06 mb -// Move from private repository to open source repository -// -// Revision 1.3 2001/05/05 00:59:18 rmurphy -// Adding darwin license headers -// -// Revision 1.2 2000/06/15 18:48:25 dmitch -// Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime. -// -// Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy -// Base Fortissimo Tree -// -// Revision 1.1 1999/02/25 05:21:48 mb -// Added snacc c++ library -// -// Revision 1.5 1997/01/01 23:27:22 rj -// `typename' appears to be a reserved word in gcc 2.7, so prefix it with `_' -// -// Revision 1.4 1995/09/07 18:50:34 rj -// duplicate code merged into a new function SnaccTcl::gettypedesc(). -// -// Revision 1.3 1995/08/17 15:06:43 rj -// snacced.[hC] renamed to tcl-if.[hC]. -// class SnaccEd renamed to SnaccTcl. -// -// Revision 1.2 1995/07/27 09:53:25 rj -// comment leader fixed -// -// Revision 1.1 1995/07/27 09:52:12 rj -// new file: tcl interface used by snacced. - -#ifdef DEBUG -#include -#endif - -class SnaccTcl -{ - Tcl_Interp *interp; - Tcl_HashTable modules, - types, - files; - - Tcl_HashEntry *create(); - const AsnTypeDesc *gettypedesc (const char *cmdname, const char *type_name); - -public: - SnaccTcl (Tcl_Interp *); - ~SnaccTcl(); - - int create (int argc, char **argv); - int openfile (int argc, char **argv); - int finfo (int argc, char **argv); - int read (int argc, char **argv); - int write (int argc, char **argv); - int closefile (int argc, char **argv); - - int modulesinfo (int argc, char **argv); - int typesinfo (int argc, char **argv); - int typeinfo (int argc, char **argv); - int info (int argc, char **argv); - - int getval (int argc, char **argv); - int setval (int argc, char **argv); - int unsetval (int argc, char **argv); - - int test (int argc, char **argv); - -#ifdef DEBUG - void ckip (Tcl_Interp *i) { assert (i == interp); } -#endif -}; - -class ASN1File -{ - const AsnTypeDesc *type; - AsnType *pdu; - - char *fn; - int fd; - off_t filesize; - -public: - ASN1File (const AsnTypeDesc *); - ASN1File (const AsnTypeDesc *, const char *fn, int fd); - virtual ~ASN1File(); - - bool bad(); - - operator AsnType * () { return pdu; } - - int finfo (Tcl_Interp *); - - int read (Tcl_Interp *, const char *fn=NULL); - int write (Tcl_Interp *, const char *fn=NULL); -}; diff --git a/SecuritySNACCRuntime/c++-lib/install-sh b/SecuritySNACCRuntime/c++-lib/install-sh deleted file mode 100644 index ab74c882..00000000 --- a/SecuritySNACCRuntime/c++-lib/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -tranformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/SecuritySNACCRuntime/c++-lib/makefile b/SecuritySNACCRuntime/c++-lib/makefile deleted file mode 100644 index 38708d32..00000000 --- a/SecuritySNACCRuntime/c++-lib/makefile +++ /dev/null @@ -1,326 +0,0 @@ -# c++-lib/makefile -# -# makes C++ ASN.1 runtime library -# -# MS 92 -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:05 mb -# Move from private repository to open source repository -# -# Revision 1.3 2000/12/22 00:04:15 dmitch -# Misc. updates for clean build on Cheetah 1D7. -# -# Revision 1.2 2000/05/10 23:38:06 rmurphy -# Updating makefile and install related files -# -# Revision 1.1.1.1 1999/03/16 18:05:58 aram -# Originals from SMIME Free Library. -# -# Revision 1.12 1997/03/13 09:15:05 wan -# Improved dependency generation for stupid makedepends. -# Corrected PeekTag to peek into buffer only as far as necessary. -# Added installable error handler. -# Fixed small glitch in idl-code generator (Markku Savela ). -# -# Revision 1.11 1997/02/16 16:48:25 rj -# made return *this after calling abort()'' a compile time option. -# -# Revision 1.10 1997/02/15 20:40:26 rj -# clean/clobber simplified, no recursive call -# -# Revision 1.9 1995/09/07 18:44:09 rj -# snacced.[hC] renamed into tcl-if.[hC], -# tkXAppInit.c lost its X. -# -# asn-useful.asn1 is compiled with the -l 50 option, as recommended by MS in the documentation. -# -# Revision 1.8 1995/07/27 08:33:31 rj -# make $(TCL-P) if necessary. -# -# actions for stamp-useful rule: call diff only if both input files exist. -# -# Revision 1.7 1995/07/24 15:52:59 rj -# changed `_' to `-' in file names. -# -# useful.asn1 renamed to asn-useful.asn1 to accomodate to snacc's new file name generation scheme. -# -# make tcl interface as determined thru the $(TCL-P) utility prog. -# -# `cd && make' instead of `cd; make'. -# -# create installation directories only if they do not exist already. -# -# call make recursively to generate the libraries different dependencies and concatenate them. -# -# Revision 1.6 1995/02/20 11:40:24 rj -# remove stamp-useful before removing asn-useful.[hC]. -# distribute install-sh. -# use $(INSTALL*) in a for-loop as some install programs (namely the distributed install-sh) only process their first argument! -# -# Revision 1.5 1995/02/09 14:03:22 rj -# enforce generation of inc/asn-useful.h and src/asn-useful.cpp when making dependencies -# -# Revision 1.4 1994/10/08 05:27:31 rj -# don't distribute the non-bootstrapping version of asn-useful.[hc] -# -# Revision 1.3 1994/10/08 04:03:19 rj -# a new asn-useful.[Ch] get generated every time the compiler or asn-useful.asn1 changes. -# -# the Tcl interface needs a separate library because conditional compilation and virtual tables don't match otherwise. -# -# Revision 1.2 1994/08/31 23:28:41 rj -# DISTFILES and install phony target added. -# -# Revision 1.1 1994/08/28 09:20:22 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../makehead -include ../makehead.static - -DEPENDENCIES = - -TOP = .. - -ASN1_SRC_DIR = $(TOP)/asn1specs - -COMPILERDIR = $(TOP)/compiler -SNACC = $(COMPILERDIR)/snacc -USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 - -CPPFLAGS += -Iinc -I$(TOP) $(tcl_def) -F/System/Library/PrivateFrameworks - -# -# hack around broken autoconf and missing makehead -# -RANLIB= /usr/bin/ranlib -TCL-P = $(TOP)/tcl-p - -#- #ifdef _IBM_ENC_ -#- # Base directory of snacc11 -#- UserDir=/net/saturn/usr4/GLASS/tools -#- Snacc11Dir=$(UserDir)/snacc -#- # -#- # where ShmMgr is located -#- ShmMgrDir=/net/saturn/usr4/GLASS/tools/shmmgr -#- # -#- # Directories of the HeiTS -#- # needed to include *.h files and Libs. -#- HeiTSDir = /u/HeiTS -#- OSSDir = $(HeiTSDir)/oss -#- BMSDir = $(HeiTSDir)/bms -#- MEMDir = $(HeiTSDir)/memmgr -#- # -#- # my own .h files for OSS are located at -#- OwnOSSDir = $(UserDir)/include/HeiTS3.2.6/oss_aix -#- OwnMemMgrDir = $(UserDir)/include/HeiTS3.2.6/memmgr -#- # -#- # OSS include and define for compiling -#- # HeiTS 3.2.6 -#- HeiTSIncDirs = -I$(OwnOSSDir) -I$(OwnMemMgrDir) -D__AIX_32__ -D__AIX__ -#- # HeiTS 3.2.7 -#- #HeiTSIncDirs = -I$(OwnOSSDir) -I$(OwnMemMgrDir) -D__ALL_SOURCE -D__AIX_32__ -DMMSERV -DDEBUG -DMAP_MANAGEMENT -DMHEG -#- # -#- LIB_HDR_DIR = $(Snacc11Dir)/cpp_incl -#- -#- CC = xlC -#- CFLAGS = -c -g -qchars=signed -+ -DIEEE_REAL_FMT -I$(LIB_HDR_DIR) -I$(ShmMgrDir) $(HeiTSIncDirs) -#- #endif /* _IBM_ENC_ */ - -HFILES.d = \ - inc/asn-any.h \ - inc/asn-bits.h \ - inc/asn-bool.h \ - inc/asn-buf.h \ - inc/asn-config.h \ - inc/asn-enum.h \ - inc/asn-incl.h \ - inc/asn-int.h \ - inc/asn-len.h \ - inc/asn-list.h \ - inc/asn-null.h \ - inc/asn-octs.h \ - inc/asn-oid.h \ - inc/asn-real.h \ - inc/asn-tag.h \ - inc/asn-type.h \ - inc/hash.h \ - inc/init.h \ - inc/meta.h \ - inc/print.h \ - inc/tcl-if.h \ - inc/str-stk.h - -HFILES = \ - $(HFILES.d) \ - inc/asn-useful.h - -HFILES.shared = \ - $(TOP)/snacc.h \ - $(TOP)/config.h \ - $(TOP)/policy.h - -CFILES.d = \ - src/asn-any.cpp \ - src/asn-bits.cpp \ - src/asn-bool.cpp \ - src/asn-enum.cpp \ - src/asn-int.cpp \ - src/asn-len.cpp \ - src/asn-list.cpp \ - src/asn-null.cpp \ - src/asn-octs.cpp \ - src/asn-oid.cpp \ - src/asn-real.cpp \ - src/asn-tag.cpp \ - src/asn-type.cpp \ - src/hash.cpp \ - src/meta.cpp \ - src/print.cpp \ - src/tcl-if.cpp \ - src/str-stk.cpp \ - src/tkAppInit.c - -CFILES = \ - $(CFILES.d) \ - src/asn-useful.cpp - -d = src - -OFILES = \ - $d/asn-any.o \ - $d/asn-bits.o \ - $d/asn-bool.o \ - $d/asn-enum.o \ - $d/asn-int.o \ - $d/asn-len.o \ - $d/asn-list.o \ - $d/asn-null.o \ - $d/asn-octs.o \ - $d/asn-oid.o \ - $d/asn-real.o \ - $d/asn-tag.o \ - $d/asn-type.o \ - $d/asn-useful.o \ - $d/hash.o \ - $d/meta.o \ - $d/print.o \ - $d/tcl-if.o \ - $d/str-stk.o \ - $d/tkAppInit.o - -DISTFILES = \ - README \ - makefile \ - $(HFILES.d) \ - $(CFILES.d) - -LIB = libasn1c++.a - -#------------------------------------------------------------------------------- - -default:: c++-lib tcl-lib - -d = dummy - -$d:: $(CFILES) - -$d:: - test -d $@ || mkdir $@ - $(RM) $@/*.[Cc] $@/*.cpp - ln $(CFILES) $@ - -.PHONY: ofiles lib -.PHONY: c++-lib tcl-lib - -ofiles: $(OFILES) - -lib: libasn1$d.a - -c++-lib: - $(MAKE) d=c++ c++ ofiles lib tcl_def=-DMETA=0 - -tcl-lib:: $(TCL-P) - -tcl-lib:: - if $(TCL-P); then $(MAKE) d=tcl tcl ofiles lib tcl_def=-DTCL; fi - -libasn1c++.a \ -libasn1tcl.a: $(OFILES) - $(AR) rv $@ $? - $(RANLIB) $@ - -#$(LIB):: $(CFILES) - -inc/asn-useful.h \ -src/asn-useful.cpp: stamp-useful - -stamp-useful: $(SNACC) $(USEFUL_TYPES) $(TCL-P) - if $(TCL-P); then\ - $(SNACC) -C $(SNACC_NOVOLAT) -l 50 -tcl "" $(USEFUL_TYPES);\ - $(RM) modules.cpp;\ - else\ - $(SNACC) -C $(SNACC_NOVOLAT) -l 50 $(USEFUL_TYPES);\ - fi -# the dates in the two files will differ, so the files really differ if diff prints more than 4 lines of output: - @if [ ! -f inc/asn-useful.h ] || [ `diff asn-useful.h inc/asn-useful.h | wc -l` -gt 4 ]; then\ - mv asn-useful.h inc/asn-useful.h;\ - else\ - echo "asn-useful.h hasn't changed";\ - $(RM) asn-useful.h;\ - fi - @if [ ! -f src/asn-useful.cpp ] || [ `diff asn-useful.cpp src/asn-useful.cpp | wc -l` -gt 4 ]; then\ - mv asn-useful.cpp src/asn-useful.cpp;\ - else\ - echo "asn-useful.cpp hasn't changed";\ - $(RM) asn-useful.cpp;\ - fi - date > $@ - -$(SNACC): - cd $(@D) && $(MAKE) $(@F) - -install-sh: - ln $(TOP)/install-sh $@ - -$(incdir)/snacc/c++ $(libexecdir): - $(TOP)/mkinstalldirs $@ - -install:: $(HFILES) c++-lib tcl-lib install-sh $(incdir)/snacc/c++ $(libexecdir) - -install:: - for h in $(HFILES) $(HFILES.shared); do $(INSTALL_DATA) $$h $(incdir)/snacc/c++/; done - for l in $(LIB); do $(INSTALL_DATA) $$l $(libexecdir)/; $(RANLIB) -t $(libexecdir)/$$l; done - if [ $d != tcl ]; then $(MAKE) LIB=libasn1tcl.a d=tcl $@; fi - -clean:: - $(RM) stamp-useful - $(RM) asn-useful.h inc/asn-useful.h - $(RM) asn-useful.cpp src/asn-useful.cpp - $(RM) $(OFILES) - $(RM) -r c++ tcl - $(RM) *.o *~ .emacs* core - -clobber:: - $(RM) libasn1c++.a - $(RM) libasn1tcl.a - $(RM) install-sh - -depend:: inc/asn-useful.h src/asn-useful.cpp - -depend:: - if [ x"$(DEPENDENCIES)" = x ]; then\ - $(MAKE) d=c++ c++ DEPENDENCIES=deps.c++ depend;\ - if $(TCL-P); then\ - $(MAKE) d=tcl tcl tcl_def=-DTCL DEPENDENCIES=deps.tcl depend;\ - fi;\ - cp /dev/null dependencies;\ - for dir in c++ tcl; do\ - < deps.$$dir sed -e "s/^src/$$dir/;s/^[a-z-]*\.o:/$$dir\/&/" >> dependencies;\ - $(RM) deps.$$dir;\ - done;\ - fi - -include ../maketail diff --git a/SecuritySNACCRuntime/c++-lib/src/asn-useful.cpp b/SecuritySNACCRuntime/c++-lib/src/asn-useful.cpp deleted file mode 100644 index 3e53655b..00000000 --- a/SecuritySNACCRuntime/c++-lib/src/asn-useful.cpp +++ /dev/null @@ -1,1095 +0,0 @@ -// NOTE: this is a machine generated file--editing not recommended -// -// asn-useful.cpp - class member functions for ASN.1 module ASN-USEFUL -// -// This file was generated by snacc on Wed Mar 20 11:39:57 2002 -// UBC snacc written by Mike Sample -// A couple of enhancements made by IBM European Networking Center - - -#include "asn-incl.h" -#include "asn-useful.h" - -//------------------------------------------------------------------------------ -// value defs - - -//------------------------------------------------------------------------------ -// class member definitions: - -AsnType *ObjectDescriptor::Clone() const -{ - return new ObjectDescriptor; -} - -AsnType *ObjectDescriptor::Copy() const -{ - return new ObjectDescriptor (*this); -} - -AsnLen ObjectDescriptor::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OD_TAG_CODE); - return l; -} - -void ObjectDescriptor::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE))) - { - Asn1Error << "ObjectDescriptor::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(50); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *UTF8String::Clone() const -{ - return new UTF8String; -} - -AsnType *UTF8String::Copy() const -{ - return new UTF8String (*this); -} - -AsnLen UTF8String::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, 12); - return l; -} - -void UTF8String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, 12)) - && (tag != MAKE_TAG_ID (UNIV, CONS, 12))) - { - Asn1Error << "UTF8String::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(49); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *NumericString::Clone() const -{ - return new NumericString; -} - -AsnType *NumericString::Copy() const -{ - return new NumericString (*this); -} - -AsnLen NumericString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); - return l; -} - -void NumericString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE))) - { - Asn1Error << "NumericString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(48); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *PrintableString::Clone() const -{ - return new PrintableString; -} - -AsnType *PrintableString::Copy() const -{ - return new PrintableString (*this); -} - -AsnLen PrintableString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - return l; -} - -void PrintableString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) - { - Asn1Error << "PrintableString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(47); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *TeletexString::Clone() const -{ - return new TeletexString; -} - -AsnType *TeletexString::Copy() const -{ - return new TeletexString (*this); -} - -AsnLen TeletexString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} - -void TeletexString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error << "TeletexString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(46); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *T61String::Clone() const -{ - return new T61String; -} - -AsnType *T61String::Copy() const -{ - return new T61String (*this); -} - -AsnLen T61String::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} - -void T61String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error << "T61String::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(45); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *VideotexString::Clone() const -{ - return new VideotexString; -} - -AsnType *VideotexString::Copy() const -{ - return new VideotexString (*this); -} - -AsnLen VideotexString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE); - return l; -} - -void VideotexString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, VIDEOTEXSTRING_TAG_CODE))) - { - Asn1Error << "VideotexString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(44); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *IA5String::Clone() const -{ - return new IA5String; -} - -AsnType *IA5String::Copy() const -{ - return new IA5String (*this); -} - -AsnLen IA5String::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, IA5STRING_TAG_CODE); - return l; -} - -void IA5String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) - { - Asn1Error << "IA5String::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(43); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *GraphicString::Clone() const -{ - return new GraphicString; -} - -AsnType *GraphicString::Copy() const -{ - return new GraphicString (*this); -} - -AsnLen GraphicString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GRAPHICSTRING_TAG_CODE); - return l; -} - -void GraphicString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GRAPHICSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, GRAPHICSTRING_TAG_CODE))) - { - Asn1Error << "GraphicString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(42); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *VisibleString::Clone() const -{ - return new VisibleString; -} - -AsnType *VisibleString::Copy() const -{ - return new VisibleString (*this); -} - -AsnLen VisibleString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} - -void VisibleString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error << "VisibleString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(41); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *ISO646String::Clone() const -{ - return new ISO646String; -} - -AsnType *ISO646String::Copy() const -{ - return new ISO646String (*this); -} - -AsnLen ISO646String::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} - -void ISO646String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error << "ISO646String::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(40); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *GeneralString::Clone() const -{ - return new GeneralString; -} - -AsnType *GeneralString::Copy() const -{ - return new GeneralString (*this); -} - -AsnLen GeneralString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALSTRING_TAG_CODE); - return l; -} - -void GeneralString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GENERALSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, GENERALSTRING_TAG_CODE))) - { - Asn1Error << "GeneralString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(39); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *UTCTime::Clone() const -{ - return new UTCTime; -} - -AsnType *UTCTime::Copy() const -{ - return new UTCTime (*this); -} - -AsnLen UTCTime::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE); - return l; -} - -void UTCTime::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))) - { - Asn1Error << "UTCTime::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(38); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *GeneralizedTime::Clone() const -{ - return new GeneralizedTime; -} - -AsnType *GeneralizedTime::Copy() const -{ - return new GeneralizedTime (*this); -} - -AsnLen GeneralizedTime::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - return l; -} - -void GeneralizedTime::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - Asn1Error << "GeneralizedTime::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(37); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *UniversalString::Clone() const -{ - return new UniversalString; -} - -AsnType *UniversalString::Copy() const -{ - return new UniversalString (*this); -} - -AsnLen UniversalString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, UNIVERSALSTRING_TAG_CODE); - return l; -} - -void UniversalString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE))) - { - Asn1Error << "UniversalString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(36); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -AsnType *BMPString::Clone() const -{ - return new BMPString; -} - -AsnType *BMPString::Copy() const -{ - return new BMPString (*this); -} - -AsnLen BMPString::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, BMPSTRING_TAG_CODE); - return l; -} - -void BMPString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE))) - { - Asn1Error << "BMPString::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(35); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -EXTERNALChoice::EXTERNALChoice() -{ - choiceId = single_ASN1_typeCid; -#if TCL - single_ASN1_type = new AsnOcts; -#else - single_ASN1_type = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice &) -{ - Asn1Error << "use of incompletely defined EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice &)" << endl; - abort(); -} - -EXTERNALChoice::~EXTERNALChoice() -{ - switch (choiceId) - { - case single_ASN1_typeCid: - delete single_ASN1_type; - break; - case octet_alignedCid: - delete octet_aligned; - break; - case arbitraryCid: - delete arbitrary; - break; - } // end of switch -} // end of destructor - -AsnType *EXTERNALChoice::Clone() const -{ - return new EXTERNALChoice; -} - -AsnType *EXTERNALChoice::Copy() const -{ - return new EXTERNALChoice (*this); -} - -#if SNACC_DEEP_COPY -EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &that) -#else // SNACC_DEEP_COPY -EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - switch (choiceId) - { - case single_ASN1_typeCid: - delete single_ASN1_type; - break; - case octet_alignedCid: - delete octet_aligned; - break; - case arbitraryCid: - delete arbitrary; - break; - } - switch (choiceId = that.choiceId) - { - case single_ASN1_typeCid: - single_ASN1_type = new AsnOcts; - *single_ASN1_type = *that.single_ASN1_type; - break; - case octet_alignedCid: - octet_aligned = new AsnOcts; - *octet_aligned = *that.octet_aligned; - break; - case arbitraryCid: - arbitrary = new AsnBits; - *arbitrary = *that.arbitrary; - break; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EXTERNALChoice::BEncContent (BUF_TYPE b) -{ - AsnLen l; - switch (choiceId) - { - case single_ASN1_typeCid: - BEncEocIfNec (b); - l = single_ASN1_type->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - l += BEncConsLen (b, l); - - l += BEncTag1 (b, CNTX, CONS, 0); - break; - - case octet_alignedCid: - l = octet_aligned->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 1); - break; - - case arbitraryCid: - l = arbitrary->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, CNTX, PRIM, 2); - break; - - } // end switch - return l; -} // EXTERNALChoice::BEncContent - - -void EXTERNALChoice::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen1; - switch (tag) - { - case MAKE_TAG_ID (CNTX, CONS, 0): - tag = BDecTag (b, bytesDecoded, env); - if ((tag != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - && (tag != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error << "Unexpected Tag" << endl; - SnaccExcep::throwMe(34); - } - - elmtLen1 = BDecLen (b, bytesDecoded, env); - choiceId = single_ASN1_typeCid; - single_ASN1_type = new AsnOcts; - single_ASN1_type->BDecContent (b, tag, elmtLen1, bytesDecoded, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 1): - case MAKE_TAG_ID (CNTX, CONS, 1): - choiceId = octet_alignedCid; - octet_aligned = new AsnOcts; - octet_aligned->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 2): - case MAKE_TAG_ID (CNTX, CONS, 2): - choiceId = arbitraryCid; - arbitrary = new AsnBits; - arbitrary->BDecContent (b, tag, elmtLen0, bytesDecoded, env); - break; - - default: - Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; - SnaccExcep::throwMe(33); - break; - } // end switch -} // EXTERNALChoice::BDecContent - - -AsnLen EXTERNALChoice::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - return l; -} - -void EXTERNALChoice::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnLen elmtLen; - AsnTag tag; - - /* CHOICEs are a special case - grab identifying tag */ - /* this allows easier handling of nested CHOICEs */ - tag = BDecTag (b, bytesDecoded, env); - elmtLen = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen, bytesDecoded, env); -} - -void EXTERNALChoice::Print (ostream &os) const -{ -#ifndef NDEBUG - switch (choiceId) - { - case single_ASN1_typeCid: - os << "single-ASN1-type "; - if (single_ASN1_type) - os << *single_ASN1_type; - else - os << "-- void3 --\n"; - break; - - case octet_alignedCid: - os << "octet-aligned "; - if (octet_aligned) - os << *octet_aligned; - else - os << "-- void3 --\n"; - break; - - case arbitraryCid: - os << "arbitrary "; - if (arbitrary) - os << *arbitrary; - else - os << "-- void3 --\n"; - break; - - } // end of switch -#endif /* NDEBUG */ -} // EXTERNALChoice::Print - -EXTERNAL::EXTERNAL() -{ - direct_reference = NULL; - indirect_reference = NULL; - data_value_descriptor = NULL; -#if TCL - encoding = new EXTERNALChoice; -#else - encoding = NULL; // incomplete initialization of mandatory element! -#endif // TCL -} - -EXTERNAL::EXTERNAL (const EXTERNAL &) -{ - Asn1Error << "use of incompletely defined EXTERNAL::EXTERNAL (const EXTERNAL &)" << endl; - abort(); -} - -EXTERNAL::~EXTERNAL() -{ - delete direct_reference; - delete indirect_reference; - delete data_value_descriptor; - delete encoding; -} - -AsnType *EXTERNAL::Clone() const -{ - return new EXTERNAL; -} - -AsnType *EXTERNAL::Copy() const -{ - return new EXTERNAL (*this); -} - -#if SNACC_DEEP_COPY -EXTERNAL &EXTERNAL::operator = (const EXTERNAL &that) -#else // SNACC_DEEP_COPY -EXTERNAL &EXTERNAL::operator = (const EXTERNAL &) -#endif // SNACC_DEEP_COPY -{ -#if SNACC_DEEP_COPY - if (this != &that) - { - if (that.direct_reference) - { - if (!direct_reference) - direct_reference = new AsnOid; - *direct_reference = *that.direct_reference; - } - else - { - delete direct_reference; - direct_reference = NULL; - } - if (that.indirect_reference) - { - if (!indirect_reference) - indirect_reference = new AsnInt; - *indirect_reference = *that.indirect_reference; - } - else - { - delete indirect_reference; - indirect_reference = NULL; - } - if (that.data_value_descriptor) - { - if (!data_value_descriptor) - data_value_descriptor = new ObjectDescriptor; - *data_value_descriptor = *that.data_value_descriptor; - } - else - { - delete data_value_descriptor; - data_value_descriptor = NULL; - } - if (that.encoding) - { - if (!encoding) - encoding = new EXTERNALChoice; - *encoding = *that.encoding; - } - else - { - delete encoding; - encoding = NULL; - } - } - - return *this; -#else // SNACC_DEEP_COPY - Asn1Error << "use of incompletely defined EXTERNAL &EXTERNAL::operator = (const EXTERNAL &)" << endl; - abort(); - // if your compiler complains here, check the -novolat option -#endif // SNACC_DEEP_COPY -} - -AsnLen -EXTERNAL::BEncContent (BUF_TYPE b) -{ - AsnLen totalLen = 0; - AsnLen l; - - l = encoding->BEncContent (b); - totalLen += l; - - if (NOT_NULL (data_value_descriptor)) - { - l = data_value_descriptor->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OD_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (indirect_reference)) - { - l = indirect_reference->BEncContent (b); - BEncDefLenTo127 (b, l); - l++; - - l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - totalLen += l; - } - - if (NOT_NULL (direct_reference)) - { - l = direct_reference->BEncContent (b); - l += BEncDefLen (b, l); - - l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - totalLen += l; - } - - return totalLen; -} // EXTERNAL::BEncContent - - -void EXTERNAL::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag1; - AsnLen seqBytesDecoded = 0; - AsnLen elmtLen1; - tag1 = BDecTag (b, seqBytesDecoded, env); - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - direct_reference = new AsnOid; - direct_reference->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - indirect_reference = new AsnInt; - indirect_reference->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) - || (tag1 == MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - data_value_descriptor = new ObjectDescriptor; - data_value_descriptor->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - tag1 = BDecTag (b, seqBytesDecoded, env); - } - - if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)) - || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 2)) - || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) - { - elmtLen1 = BDecLen (b, seqBytesDecoded, env); - encoding = new EXTERNALChoice; - encoding->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); - } - else - { - Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; - SnaccExcep::throwMe(32); - } - - bytesDecoded += seqBytesDecoded; - if (elmtLen0 == INDEFINITE_LEN) - { - BDecEoc (b, bytesDecoded, env); - return; - } - else if (seqBytesDecoded != elmtLen0) - { - Asn1Error << "ERROR - Length discrepancy on sequence." << endl; - SnaccExcep::throwMe(31); - } - else - return; -} // EXTERNAL::BDecContent - -AsnLen EXTERNAL::BEnc (BUF_TYPE b) -{ - AsnLen l; - l = BEncContent (b); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, EXTERNAL_TAG_CODE); - return l; -} - -void EXTERNAL::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, EXTERNAL_TAG_CODE)) - { - Asn1Error << "EXTERNAL::BDec: ERROR - wrong tag" << endl; - SnaccExcep::throwMe(30); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecContent (b, tag, elmtLen1, bytesDecoded, env); -} - -void EXTERNAL::Print (ostream &os) const -{ -#ifndef NDEBUG - os << "{ -- SEQUENCE --" << endl; - indentG += stdIndentG; - - if (NOT_NULL (direct_reference)) - { - Indent (os, indentG); - os << "direct-reference "; - os << *direct_reference; - } - else - { - Indent (os, indentG); - os << "direct-reference "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (indirect_reference)) - { - Indent (os, indentG); - os << "indirect-reference "; - os << *indirect_reference; - } - else - { - Indent (os, indentG); - os << "indirect-reference "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (data_value_descriptor)) - { - Indent (os, indentG); - os << "data-value-descriptor "; - os << *data_value_descriptor; - } - else - { - Indent (os, indentG); - os << "data-value-descriptor "; - os << "-- void --"; - os << "," << endl; - } - - if (NOT_NULL (encoding)) - { - Indent (os, indentG); - os << "encoding "; - os << *encoding; - } - else - { - Indent (os, indentG); - os << "encoding "; - os << "-- void --"; - os << endl; - } - - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif /* NDEBUG */ -} // EXTERNAL::Print - - diff --git a/SecuritySNACCRuntime/c++-lib/src/cdsaUtils.cpp b/SecuritySNACCRuntime/c++-lib/src/cdsaUtils.cpp deleted file mode 100644 index 55583c13..00000000 --- a/SecuritySNACCRuntime/c++-lib/src/cdsaUtils.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * cdsaUtils.cpp - utility functions for CDSA-related code - */ - -#include "cdsaUtils.h" -#include - -#ifdef NDEBUG - -#include - -/* silent cerr substitute */ -ModuleNexus AsnNullError; -#endif /* NDEBUG */ - -/* malloc/copy AsnBits.bits -->CssmOwnedData */ -void SC_asnBitsToCssmData( - const AsnBits &bits, - CssmOwnedData &oData) -{ - size_t len = (bits.BitLen() + 7) / 8; - oData.copy(reinterpret_cast(bits.BitOcts()), len); -} - -/* given DER-encoded bit string, decoded it and malloc/copy results - * back to a CssmOwnedData */ -void SC_decodeAsnBitsToCssmData( - const CssmData encodedBits, - CssmOwnedData &oData) -{ - AsnBits decodedBits; - SC_decodeAsnObj(encodedBits, decodedBits); - size_t len = (decodedBits.BitLen() + 7) / 8; - oData.copy(reinterpret_cast(decodedBits.BitOcts()), len); -} - -/* - * Universal BDecPdu/BEncPdu replacements, used below in SC_decodeAsnObj and - * SC_encodeAsnObj. - * - * All AsnType subclasses implement this either via PDU_MEMBER_MACROS - * for SecuritySNACCRuntime built-in types, or explicitly for all - * other classes using asn-useful.h. To faciliate a global "one - * routine for encode/decode" which operates on AsnType &'s, we have - * to explicitly provide this here. Why this is not in AsnType, I don't - * know. - */ -static int SC_BDecPDU( - AsnType &asnObj, - BUF_TYPE b, - AsnLen &bytesDecoded) -{ - ENV_TYPE env; - - bytesDecoded = 0; - try { - asnObj.BDec(b, bytesDecoded, env); - return !b.ReadError(); - } - catch(...) { - return false; - } -} - -static int SC_BEncPdu( - AsnType &asnObj, - BUF_TYPE b, - AsnLen &bytesEncoded) -{ - bytesEncoded = asnObj.BEnc(b); - return !b.WriteError(); -} - -/* DER-decode any AsnType object */ -void SC_decodeAsnObj( - const CssmData &derEncoded, - AsnType &asnObj) -{ - AsnBuf buf; - size_t len = (size_t)derEncoded.length(); - - buf.InstallData(reinterpret_cast(derEncoded.data()), len); - if(!SC_BDecPDU(asnObj, buf, len)) { - CssmError::throwMe(CSSMERR_CL_UNKNOWN_FORMAT); - } -} - -/* - * DER-encode any AsnType object. - * Unfortunately the call has to give an estimate of the max encoded size of - * the result. There is no way (that I know of) to figure this out at encode - * time. If this turns out to be a problem we might have to do a retry, - * doubling the size of the encoded buffer. Be liberal; the maxEncodedSize - * buffer is only temporary - due to snacc encoding style, a copy out is - * necessary in any case, so the mallocd size of encodedBuf is exactly the - * right size. - */ -void SC_encodeAsnObj( - AsnType &asnObj, - CssmOwnedData &derEncoded, - size_t maxEncodedSize) -{ - CssmAutoData aData(derEncoded.allocator); // temp encode target - aData.malloc(maxEncodedSize); - memset(aData.data(), 0, maxEncodedSize); - AsnBuf encBuf; - encBuf.Init(static_cast(aData.data()), maxEncodedSize); - encBuf.ResetInWriteRvsMode(); - AsnLen encoded; - int rtn = SC_BEncPdu(asnObj, encBuf, encoded); - if(encoded > maxEncodedSize) { - CssmError::throwMe(CSSMERR_CSSM_BUFFER_TOO_SMALL); - } - if(!rtn) { - /* not sure how this can happen... */ - CssmError::throwMe(CSSMERR_CSSM_BUFFER_TOO_SMALL); - } - /* success; copy out to caller */ - derEncoded.get().clear(); - derEncoded.copy(encBuf.DataPtr(), encBuf.DataLen()); -} - -/* - * Given a contentLength, obtain the length of the DER length encoding. - */ -size_t SC_lengthOfLength( - size_t contentLen) -{ - if(contentLen < 128) { - return 1; - } - else if(contentLen < 256) { - return 2; - } - else if(contentLen < 65536) { - return 3; - } - else if(contentLen < 16777126) { - return 4; - } - else { - return 5; - } -} - -/* - * Encode a DER length field. Pass in the lengthOfLength if you've obtained - * it in a previous call to SC_lengthOfLength. - */ -void SC_encodeLength( - size_t contentLen, - void *cp, - size_t lengthOfLength) -{ - if(lengthOfLength == 0) { - lengthOfLength = SC_lengthOfLength(contentLen); - } - unsigned char *ucp = reinterpret_cast(cp); - if(lengthOfLength == 1) { - /* easy case */ - *ucp = contentLen; - return; - } - lengthOfLength--; - *ucp = (0x80 + lengthOfLength); - ucp += lengthOfLength; - for(size_t i=0; i>= 8; - } -} - -/* - * Explicitly non-inlined SnaccError throw - */ -void SnaccExcep::throwMe(int err) -{ - throw SnaccExcep(err); -} diff --git a/SecuritySNACCRuntime/c++-lib/src/sm_buffer.cpp b/SecuritySNACCRuntime/c++-lib/src/sm_buffer.cpp deleted file mode 100644 index b0d87e9d..00000000 --- a/SecuritySNACCRuntime/c++-lib/src/sm_buffer.cpp +++ /dev/null @@ -1,898 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - -#ifndef __APPLE__ -#ifndef NO_SCCS_ID -static char SccsId[ ] = "@(#) sm_buffer.cpp 1.17 5/7/98 16:36:20"; -#endif -#endif - -////////////////////////////////////////////////////////////////////////// -// sm_buffer.cpp -// This source file implements various members of the CSM_Buffer class. -// Be careful when you modify these -// members because code is being written based on the characteristics -// of these members... -////////////////////////////////////////////////////////////////////////// - -#include -#if !defined(macintosh) && !defined(__APPLE__) -#include -#include -#endif -#include - -#ifdef SUNOS -#include // for SEEK_CUR and SEEK_END -#endif - -#include "sm_vdasnacc.h" -#ifndef NDEBUG -#include -#endif - -#if defined(macintosh) || defined(__APPLE__) - -#include - -#define SME_SETUP(A) try { -#define SME_THROW(A, B, C) throw(static_cast(A)) -#define SME_FINISH } -#define SME_CATCH_SETUP catch(SM_RET_VAL) { -#define SME_CATCH_FINISH } -#define SM_RET_VAL long -#define SM_NO_ERROR 0 -#define SME_FINISH_CATCH } catch(SM_RET_VAL) {} -#define SME(S) S - -#define SM_MEMORY_ERROR memFullErr -#define SM_MISSING_PARAM paramErr -#define SM_FILEIO_ERROR ioErr - -#else - -#define SME_SETUP(A) do {} while (0) -#define SME_THROW(A, B, C) do {} while (0) -#define SME_FINISH -#define SME_CATCH_SETUP -#define SME_CATCH_FINISH -#define SM_RET_VAL long -#define SM_NO_ERROR 0 -#define SME_FINISH_CATCH -#define SME(S) S - -#endif - -////////////////////////////////////////////////////////////////////////// -void CSM_Buffer::Clear() -{ - m_lSize = 0; - m_pMemory = NULL; -#if !defined(macintosh) && !defined(__APPLE__) - m_pszFN = NULL; - m_pFP = NULL; -#endif - m_pMemFP = NULL; - m_pCache = NULL; - m_lCacheSize = 0; -} - -////////////////////////////////////////////////////////////////////////// -CSM_Buffer::CSM_Buffer() -{ - SME_SETUP("CSM_Buffer::CSM_Buffer(size_t)"); - - Clear(); - - if ((m_pMemory = (char *)calloc(1, 1)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - SME(SetLength(0)); - - SME_FINISH_CATCH -} - -////////////////////////////////////////////////////////////////////////// -CSM_Buffer::CSM_Buffer(size_t lSize) -{ - SME_SETUP("CSM_Buffer::CSM_Buffer(size_t)"); - - Clear(); - - if ((m_pMemory = (char *)calloc(1, lSize + 1)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - SME(SetLength(lSize)); - - SME_FINISH_CATCH -} - -////////////////////////////////////////////////////////////////////////// -#if !defined(macintosh) && !defined(__APPLE__) -CSM_Buffer::CSM_Buffer(char *pszFileName) -{ - SME_SETUP("CSM_Buffer::CSM_Buffer(char*)"); - - Clear(); - - if (pszFileName == NULL) - SME_THROW(SM_MISSING_PARAM, NULL, NULL); - - if ((m_pszFN = strdup(pszFileName)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - - SME_FINISH_CATCH -} -#endif - -////////////////////////////////////////////////////////////////////////// -CSM_Buffer::CSM_Buffer(const char *pBuf, SM_SIZE_T lSize) -{ - SME_SETUP("CSM_Buffer::CSM_Buffer(char *, size_t)"); - - Clear(); - - if (pBuf == NULL) - SME_THROW(SM_MISSING_PARAM, NULL, NULL); - - SME(Set(pBuf, lSize)); - - SME_FINISH_CATCH -} - -////////////////////////////////////////////////////////////////////////// -CSM_Buffer::CSM_Buffer(const CSM_Buffer &b) -{ - SME_SETUP("CSM_Buffer::CSM_Buffer(CSM_Buffer&)"); - - Clear(); - - SME(ReSet(b)); - - SME_FINISH_CATCH -} - -////////////////////////////////////////////////////////////////////////// -CSM_Buffer::~CSM_Buffer() -{ - if (m_pMemory) - free (m_pMemory); -#if !defined(macintosh) && !defined(__APPLE__) - if (m_pszFN) - free (m_pszFN); - if (m_pFP) - fclose(m_pFP); -#endif - if (m_pCache) - free (m_pCache); -} - -////////////////////////////////////////////////////////////////////////// -SM_SIZE_T CSM_Buffer::Length() const -{ - SM_SIZE_T lRet = 0; - - SME_SETUP("CSM_Buffer::Length"); - -#if !defined(macintosh) && !defined(__APPLE__) - if (InFile()) - { - // file version - struct stat statBuf; - // how big is data in file - if (stat(m_pszFN, &statBuf) == -1) - { - char szMsg[512]; - sprintf(szMsg, "Couldn't stat file %s", m_pszFN); - SME_THROW(SM_FILEIO_ERROR, szMsg, NULL); - } - lRet = statBuf.st_size; - } - else -#endif - { - // memory version - lRet = m_lSize; - } - - SME_FINISH_CATCH - - return lRet; -} - -////////////////////////////////////////////////////////////////////////// -void CSM_Buffer::Set(const char *psz) -{ - SME_SETUP("CSM_Buffer::Set(char *)"); - if (psz == NULL) - SME_THROW(SM_MISSING_PARAM, NULL, NULL); - if (m_pMemory) - free(m_pMemory); -#if !defined(macintosh) && !defined(__APPLE__) - int len = strlen(psz); - m_pMemory = (char*)malloc(len + 1); - if (m_pMemory == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - strcpy(m_pMemory, psz); - SME(SetLength(len)); -#else - if ((m_pMemory = strdup(psz)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - SME(SetLength(strlen(psz))); -#endif - SME_FINISH_CATCH -} - -////////////////////////////////////////////////////////////////////////// -void CSM_Buffer::Set(const char *p, SM_SIZE_T lSize) -{ - SME_SETUP("CSM_Buffer::Set(char *, size_t)"); - if (m_pMemory) - free(m_pMemory); - - if (p == NULL) - { - m_pMemory = NULL; - SME(SetLength(0)); - } - else - { - m_pMemory = (char *)calloc(1, lSize + 1); - if (m_pMemory == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - memcpy(m_pMemory, p, lSize); - SME(SetLength(lSize)); - } - SME_FINISH_CATCH -} - -////////////////////////////////////////////////////////////////////////// -// allocate memory in the cache -char* CSM_Buffer::Alloc(SM_SIZE_T lSize) -{ - SME_SETUP("CSM_Buffer::Alloc"); - - if (m_pCache) - free(m_pCache); - if ((m_pCache = (char *)calloc(1, lSize)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - m_lCacheSize = lSize; - - SME_FINISH_CATCH - - return m_pCache; -} - -////////////////////////////////////////////////////////////////////////// -void CSM_Buffer::AllocMoreMem(SM_SIZE_T lSize) -{ - char *pNew; - SM_SIZE_T lLength = Length(); - - SME_SETUP("CSM_Buffer::AllocMoreMem"); - - if ((pNew = (char *)calloc(1, lLength + lSize)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - memcpy(pNew, m_pMemory, lLength); - SetLength(lLength + lSize); - m_pMemFP = pNew + (m_pMemFP - m_pMemory); - free(m_pMemory); - m_pMemory = pNew; - - SME_FINISH_CATCH -} - -////////////////////////////////////////////////////////////////////////// -const char* CSM_Buffer::Access() const -{ - SME_SETUP("CSM_Buffer::Access"); -#if !defined(macintosh) && !defined(__APPLE__) - if (InFile()) - { - // if the data is in a file AND - // if there's already memory in m_pMemory then free it - if (m_pMemory != NULL) - free (m_pMemory); - SME(m_pMemory = Get()); - } -#endif - SME_FINISH_CATCH - return m_pMemory; -} - -////////////////////////////////////////////////////////////////////////// -// return a copy of the actual data and return the size -char* CSM_Buffer::Get(SM_SIZE_T &l) const -{ - char *pRet = NULL; - SME_SETUP("CSM_Buffer::Get"); - - SM_SIZE_T lSize = Length(); - -#if !defined(macintosh) && !defined(__APPLE__) - if (InFile()) // data in file - { - // allocate memory - if ((pRet = (char *)calloc(1, lSize + 1)) == NULL) - SME_THROW(SM_MEMORY_ERROR, "calloc failure", NULL); - // close file if present - if (m_pFP != NULL) - fclose(m_pFP); - // open the file - if ((m_pFP = fopen(m_pszFN, SM_FOPEN_READ)) == NULL) - { - char szMsg[512]; - sprintf(szMsg, "Couldn't open file %s", m_pszFN); - SME_THROW(SM_FILEIO_ERROR, szMsg, NULL); - } - // read the data - long lRead = fread(pRet, 1, lSize, m_pFP); - if (ferror(m_pFP) != 0) - { - char szMsg[512]; - sprintf(szMsg, "Couldn't read file %s", m_pszFN); - SME_THROW(SM_FILEIO_ERROR, szMsg, NULL); - } - // close and clear FP - fclose(m_pFP); - m_pFP = NULL; - l = lRead; // store the size that will be returned - } - else -#endif - { - // if there is data, duplicate it - if (m_pMemory) - { - pRet = (char *)calloc(1, lSize); - memcpy(pRet, m_pMemory, lSize); - l = lSize; // store the size that will be returned - } - } - - SME_FINISH - SME_CATCH_SETUP - if (pRet != NULL) - { - free(pRet); - pRet = NULL; - } -#if !defined(macintosh) && !defined(__APPLE__) - if (m_pFP != NULL) - { - fclose(m_pFP); - m_pFP = NULL; - } -#endif - SME_CATCH_FINISH - return pRet; -} - -////////////////////////////////////////////////////////////////////////// -// compare buffers regardless of memory/file status -long CSM_Buffer::Compare(const CSM_Buffer &b) -{ - const char *p1 = NULL; - const char *p2 = NULL; - long lRet = -2; - - SME_SETUP("CSM_Buffer::Compare"); - // use AccessAll on both buffers for comparison. If buffer is in - // file, then this results in a CopyAll which isn't as efficient, - // but this can be fixed later... - if ((p1 = Access()) != NULL) - { - if ((p2 = b.Access()) != NULL) - { - if (Length() == b.Length()) - lRet = (long)memcmp(p1, p2, Length()); - // p1 and p2 are the same as the memory pointers in - // the buffers so they do not need to be freed, they - // will be freed by the buffer's destructor - } -#if !defined(macintosh) && !defined(__APPLE__) - else - if (InFile()) - free (p1); -#endif - } - SME_FINISH_CATCH - return lRet; -} - -////////////////////////////////////////////////////////////////////////// -// copy b into this -SM_RET_VAL CSM_Buffer::ReSet(const CSM_Buffer &b) -{ - char *p; - SM_SIZE_T l; - SME_SETUP("CSM_Buffer::ReSet"); - -#if !defined(macintosh) && !defined(__APPLE__) - m_pszFNP = NULL; - m_pFP = NULL; -#endif - if (m_pMemory) - free(m_pMemory); - - m_pMemory = m_pMemFP = NULL; - SME(SetLength(0)); - m_pCache = NULL; - m_lCacheSize = 0; - - SME(p = b.Get(l)); - - SME(Set(p, l)); - - free(p); - - SME_FINISH_CATCH - - return SM_NO_ERROR; -} - -#if !defined(macintosh) && !defined(__APPLE__) -////////////////////////////////////////////////////////////////////////// -// ConvertFileToMemory makes a CSM_Buffer storing its contents in -// file into a CSM_Buffer storing its contents in memory -SM_RET_VAL CSM_Buffer::ConvertFileToMemory() -{ - SM_SIZE_T l; - - SME_SETUP("CSM_Buffer::ConvertFileToMemory"); - - if (m_pszFN == NULL) - // we're already in memory - return SM_NO_ERROR; - - // read everything into memory - SME(m_pMemory = Get(l)); - - // free the file name - free(m_pszFN); - m_pszFN = NULL; - - // store the new size - SME(SetLength(l)); - - SME_FINISH_CATCH - - return SM_NO_ERROR; -} - -////////////////////////////////////////////////////////////////////////// -// ConvertMemoryToFile makes a CSM_Buffer storing its contents in -// buffer into a CSM_Buffer storing its contents in file -SM_RET_VAL CSM_Buffer::ConvertMemoryToFile(char *pszFN) -{ - SM_SIZE_T lRet = 0; - - SME_SETUP("CSM_Buffer::ConvertMemoryToFile"); - - if (pszFN == NULL) - SME_THROW(SM_NO_FILENAME, NULL, NULL); - - if (InFile()) - { - if (strcmp(m_pszFN, pszFN) == 0) // we're already in file - return SM_NO_ERROR; - else - { - SM_SIZE_T lBytesRead; - SM_SIZE_T lSize=4096; - char *ptr; - FILE *fp=fopen(pszFN, "w"); - this->Open(SM_FOPEN_READ); - while ((ptr=this->nRead(lSize, lBytesRead)) != NULL && lBytesRead > 0) - { - fwrite(ptr, 1, lBytesRead, fp); - } - this->Close(); - fclose(fp); - return(SM_NO_ERROR); - } - } - - // open the new file - if ((m_pFP = fopen(pszFN, SM_FOPEN_WRITE)) == NULL) - { - char szMsg[512]; - sprintf(szMsg, "Couldn't stat file %s", pszFN); - SME_THROW(SM_FILEIO_ERROR, szMsg, NULL); - } - - // write the data - SM_SIZE_T lLength = Length(); - // store the file name - if ((m_pszFN = strdup(pszFN)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - - if ((lRet = fwrite(m_pMemory, 1, lLength, m_pFP)) != lLength) - { - char szMsg[512]; - sprintf(szMsg, "Couldn't write file %s", m_pszFN); - SME_THROW(SM_FILEIO_ERROR, szMsg, NULL); - } - - fclose(m_pFP); - m_pFP = NULL; - - SME_FINISH - SME_CATCH_SETUP - // cleanup/catch code - if ((m_pszFN != NULL) && (pszFN != NULL)) - { - free(m_pszFN); - m_pszFN = NULL; - } - SME_CATCH_FINISH - - return SM_NO_ERROR; -} -#endif - -////////////////////////////////////////////////////////////////////////// -SM_RET_VAL CSM_Buffer::Open(char *pszMode) -{ - SME_SETUP("CSM_Buffer::Open"); - - if (pszMode == NULL) - SME_THROW(SM_MISSING_PARAM, NULL, NULL); - -#if !defined(macintosh) && !defined(__APPLE__) - if (!InFile()) -#endif - // memory version - m_pMemFP = m_pMemory; // set current pointer to start -#if !defined(macintosh) && !defined(__APPLE__) - else - // file version - if ((m_pFP = fopen(m_pszFN, pszMode)) == NULL) - { - char szMsg[512]; - sprintf(szMsg, "Couldn't open file %s", m_pszFN); - SME_THROW(SM_FILEIO_ERROR, szMsg, NULL); - } -#endif - - SME_FINISH_CATCH - return SM_NO_ERROR; -} - -////////////////////////////////////////////////////////////////////////// -SM_RET_VAL CSM_Buffer::Seek(SM_SIZE_T lOffset, SM_SIZE_T lOrigin) -{ - SM_RET_VAL lRet = SM_NO_ERROR; - - SME_SETUP("CSM_Buffer::Seek"); - -#if !defined(macintosh) && !defined(__APPLE__) - if (!InFile()) -#endif - { - // memory version - char *pSave = m_pMemFP; - - if (m_pMemFP == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - - SM_SIZE_T lLength = Length(); - - switch (lOrigin) - { - case SEEK_CUR: - m_pMemFP += lOffset; - break; - case SEEK_END: - m_pMemFP = (m_pMemory + lLength - 1) + lOffset; - break; - default: // SEEK_SET - m_pMemFP = m_pMemory + lOffset; - break; - } - if ((m_pMemFP > (m_pMemory + lLength - 1)) || - (m_pMemFP < m_pMemory)) - { - m_pMemFP = pSave; - lRet = -1; - } - } -#if !defined(macintosh) && !defined(__APPLE__) - else - { - // file version - if (m_pFP == NULL) - SME_THROW(SM_FILEIO_ERROR, "FP is NULL", NULL); - - lRet = fseek(m_pFP, lOffset, lOrigin); - } -#endif - - SME_FINISH_CATCH - - return lRet; -} - -////////////////////////////////////////////////////////////////////////// -void CSM_Buffer::Close() -{ -#if !defined(macintosh) && !defined(__APPLE__) - if (m_pFP != NULL) - { - fclose(m_pFP); - m_pFP = NULL; - if (m_pMemory) - { - free(m_pMemory); - m_pMemory = NULL; - } - } - else -#endif - m_pMemFP = NULL; -} - -////////////////////////////////////////////////////////////////////////// -AsnType *CSM_Buffer::Clone() const -{ - return new CSM_Buffer; -} - -////////////////////////////////////////////////////////////////////////// -AsnType *CSM_Buffer::Copy() const -{ - return new CSM_Buffer (*this); -} - -////////////////////////////////////////////////////////////////////////// -AsnLen CSM_Buffer::BEnc(BUF_TYPE BBuf) -{ - char *ptr; - unsigned int jj=0; - SM_SIZE_T lRead=1; - SM_SIZE_T lOffset; - - this->Open(SM_FOPEN_READ); - for (jj = 0; jj < this->Length() && lRead > 0; jj += lRead) - { - if (jj == 0) // first time, only get last X bytes within 4096 block. - { - lOffset = this->Length() - (this->Length() % 4096); - } - else - lOffset -= 4096; - this->Seek(lOffset, 0); - ptr = this->nRead(4096, lRead); - BBuf.PutSegRvs(ptr, lRead); - } - this->Close(); - - return this->Length(); -} - -////////////////////////////////////////////////////////////////////////// -void CSM_Buffer::Print (ostream &os) const -{ -#ifndef NDEBUG - int len = Length(); - int i; - - os << "{ -- ANY --" << endl; - indentG += stdIndentG; - Indent (os, indentG); - - long oFlags = os.flags(); - os << hex; - for (i = 0; i < len; i++) - { - os << setw(2) << setfill('0') - << static_cast(static_cast(m_pMemory[i])) << " "; - - if (i == len - 1 || i % 16 == 15) - { - int j; - os << " "; - for (j = i > 15 ? i - 15 : 0; j <= i; j++) - { - if (m_pMemory[j] >= 0x20 && m_pMemory[j] < 0x80) - os << m_pMemory[j]; - else - os << '.'; - } - os << endl; - } - } - - os.flags(oFlags); - os << endl; - indentG -= stdIndentG; - Indent (os, indentG); - os << "}"; -#endif NDEBUG -} - -////////////////////////////////////////////////////////////////////////// -SM_RET_VAL CSM_Buffer::cRead(char *pBuffer, SM_SIZE_T lSize) -{ - SM_RET_VAL lRet = 0; - - SME_SETUP("CSM_Buffer::cRead"); - - if ((pBuffer == NULL) || (lSize <= 0)) - SME_THROW(SM_MISSING_PARAM, NULL, NULL); - -#if !defined(macintosh) && !defined(__APPLE__) - if (!InFile()) -#endif - { - // memory version - if (m_pMemFP == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - - SM_SIZE_T lReadSize = lSize; - SM_SIZE_T lLength = Length(); - // adjust the read size to what's possible - if ((m_pMemFP + lReadSize) > (m_pMemory + lLength)) - lReadSize = (m_pMemory + lLength) - m_pMemFP; - memcpy(pBuffer, m_pMemFP, lReadSize); - // adjust the current pointer - if (lReadSize > 0) - { - m_pMemFP += lReadSize; - lRet = lReadSize; - } - else - lRet = 0; - } -#if !defined(macintosh) && !defined(__APPLE__) - else - { - // file version - if (m_pFP == NULL) - SME_THROW(SM_FILEIO_ERROR, "FP is NULL", NULL); - - lRet = fread(pBuffer, 1, lSize, m_pFP); - } -#endif - - SME_FINISH_CATCH - - return lRet; -} - -////////////////////////////////////////////////////////////////////////// -SM_RET_VAL CSM_Buffer::Write(const char *pBuffer, SM_SIZE_T lSize) -{ - SM_RET_VAL lRet = 0; - - SME_SETUP("CSM_Buffer::Write"); - - if ((pBuffer == NULL) || (lSize <= 0)) - SME_THROW(SM_MISSING_PARAM, NULL, NULL); - -#if !defined(macintosh) && !defined(__APPLE__) - if (!InFile()) -#endif - { - // memory version - if (m_pMemFP == NULL) - { - if (m_pMemory == NULL) - { - // if we get here, we assume that the memory - // hasn't been allocated yet, allocate it... - if ((m_pMemFP = m_pMemory = (char *)calloc(1, lSize)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - SetLength(lSize); - } - else - m_pMemFP = m_pMemory; - } - - // do we have enough space to write to this buffer? - if ((SM_SIZE_T)(((m_pMemory + Length()) - m_pMemFP)) < lSize) - // nope, get lSize more bytes - AllocMoreMem(lSize); - memcpy(m_pMemFP, pBuffer, lSize); - m_pMemFP += lSize; - lRet = lSize; - } -#if !defined(macintosh) && !defined(__APPLE__) - else - { - // file version - if (m_pFP == NULL) - SME_THROW(SM_FILEIO_ERROR, "FP is NULL", NULL); - - if ((lRet = fwrite(pBuffer, 1, lSize, m_pFP)) > 0) - SetLength(m_lSize + lRet); - } -#endif - - SME_FINISH_CATCH - - return lRet; -} - -////////////////////////////////////////////////////////////////////////// -char* CSM_Buffer::nRead(SM_SIZE_T lSize, SM_SIZE_T &lBytesRead) -{ - char *pRet = NULL; - - SME_SETUP("CSM_Buffer::nRead"); - - if (lSize <= 0) - SME_THROW(SM_MISSING_PARAM, NULL, NULL); - -#if !defined(macintosh) && !defined(__APPLE__) - if (!InFile()) -#endif - { - // memory version - if (m_pMemFP == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - - SM_SIZE_T lReadSize = lSize; - SM_SIZE_T lLength = Length(); - // adjust the read size to what's possible - if ((m_pMemFP + lReadSize) > (m_pMemory + lLength)) - lReadSize = (m_pMemory + lLength) - m_pMemFP; - pRet = m_pMemFP; - // adjust the current pointer - if (lReadSize > 0) - { - m_pMemFP += lReadSize; - lBytesRead = lReadSize; - } - else - lBytesRead = 0; - } -#if !defined(macintosh) && !defined(__APPLE__) - else - { - // file version - if (m_pFP == NULL) - SME_THROW(SM_FILEIO_ERROR, "FP is NULL", NULL); - // if there's something already in the memory, free it - if (m_pMemory != NULL) - free (m_pMemory); - // allocate memory to receive the read data - if ((m_pMemory = (char *)calloc(1, lSize + 1)) == NULL) - SME_THROW(SM_MEMORY_ERROR, NULL, NULL); - // now, read into the memory cache - lBytesRead = fread(m_pMemory, 1, lSize, m_pFP); - // now set what we'll return - pRet = m_pMemory; - } -#endif - - SME_FINISH_CATCH - - return pRet; -} - -////////////////////////////////////////////////////////////////////////// -void CSM_Buffer::Flush() -{ - if (m_pCache != NULL) - { - Write(m_pCache, m_lCacheSize); - free(m_pCache); - m_pCache = NULL; - m_lCacheSize = 0; - } -} - -// EOF sm_buffer.cpp diff --git a/SecuritySNACCRuntime/c++-lib/src/sm_vdasnacc.cpp b/SecuritySNACCRuntime/c++-lib/src/sm_vdasnacc.cpp deleted file mode 100644 index b7461f37..00000000 --- a/SecuritySNACCRuntime/c++-lib/src/sm_vdasnacc.cpp +++ /dev/null @@ -1,560 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - -#ifndef __APPLE__ -#ifndef NO_SCCS_ID -static char SccsId[ ] = "@(#) sm_vdasnacc.cpp 1.18 6/1/98 11:07:01"; -#endif -#endif - -/** - vdasnacc.CPP - This file handles any additional miscellaneous routines to support - the integration of the MSP into SNACC environment. - ***/ - -//#include "sm_api.h" -#include "sm_vdasnacc.h" -#include "sm_vdatypes.h" - -long vdasnacc_sortSetTag( - CSM_Buffer *pEncBuf[], // IN/OUT, buffer to sort - int start_index, // IN, start index for sort. - int icount, // IN, size of array. - int tag); // IN, tag to place. -long SM_DetermineLengthBuf(AsnBuf &SNACCinputBuf); - - -/** This function sorts the specified "Str_struct" array in reverse order. - This is done for the "Set Of" ASN.1 ordering. The ASN.1 components will - be loaded in ascending order; they will be loaded in the reverse order - of this array (hence, we load them in descending order). -***/ -long vdasnacc_sortSetOf(CSM_Buffer **&pEncBuf, int icount) -{ - long status=0; - int lessCount; - int i,j; - int l1,l2; - const char *ptr1,*ptr2; - CSM_Buffer *tmpEnc; - - for (i=0; i < icount; i++) - { - for (j=i+1; j < icount; j++) /** always start with present "i". **/ - { - ptr1 = pEncBuf[i]->Access(); - ptr2 = pEncBuf[j]->Access(); - l1 = pEncBuf[i]->Length(); - l2 = pEncBuf[j]->Length(); - if (l1 < l2) - lessCount = l1; - else - lessCount = l2; - if (memcmp(ptr1, ptr2, lessCount) < 0 || - (memcmp(ptr1, ptr2, lessCount) == 0 && - l1 < l2)) /** check if = with more */ - { /** SWITCH buffers so that greater is first. **/ - tmpEnc = pEncBuf[i]; - pEncBuf[i] = pEncBuf[j]; - pEncBuf[j] = tmpEnc; - } - } - - } - - - return(status); -} - - -/** This function sorts the specified "Str_struct" array in reverse order. - This is done for the "Set" ASN.1 ordering. The ASN.1 components will - be loaded in ascending order; they will be loaded in the reverse order - of this array (hence, we load them in descending order). The SET ordering - is based on the lower 5 bits of the tag item (guaranteed to be unique - based on the ASN.1 definition of a SET). This is based on the ISO rules. -***/ -#define ASN_UNIVERSAL 0x00 -#define ASN_APPLICATION 0x40 -#define ASN_CONTEXT 0x80 -#define ASN_PRIVATE 0xC0 -long vdasnacc_sortSet(CSM_Buffer *pEncBuf[], int icount) -{ - long status=0; - int tag_count=0; - int tag_index=0; - - // This algorithm for Set ordering requires Universal tags first - // followed by Application, then Context specific tags. - // Each entry in this category is then sorted by the lower 5 bits. - // (They are loaded in reverse order for SNACC buffer loads.) - tag_count = vdasnacc_sortSetTag(pEncBuf, tag_index, icount, - ASN_PRIVATE); - tag_index += tag_count; // skip this set of tags, onto the next. - tag_count = vdasnacc_sortSetTag(pEncBuf, tag_index, icount, - ASN_CONTEXT); - tag_index += tag_count; // skip this set of tags, onto the next. - tag_count = vdasnacc_sortSetTag(pEncBuf, tag_index, icount, - ASN_APPLICATION); - tag_index += tag_count; - tag_count = vdasnacc_sortSetTag(pEncBuf, tag_index, icount, - ASN_UNIVERSAL); - - return(status); -} - - -// vdasnacc_sortSetTag -// This routine sorts the specified buffer from the start index to the end -// for the specified tag. This entails switching all entries until the -// tagged entries are consecutive, then sorting according the lower 5 bits -// of the tags within that tag. The number of entries of that tag type -// are returned. -long vdasnacc_sortSetTag( - CSM_Buffer *pEncBuf[], // IN/OUT, buffer to sort - int start_index, // IN, start index for sort. - int icount, // IN, size of array. - int tag) // IN, tag to place. -{ - int i,j; - int tag_count=0; - CSM_Buffer *tmpEnc; - const char *ptri,*ptrj; - int mask = 0x1f; /** for SET, not SET OF logic, only sort based on - first 5 bits of tag. **/ - int mask_TAG = 0xc0; /** mask for upper tag bits indicating UNIVERSAL, - APPLICATION or CONTEXT ASN.1 Class. **/ - - for (i=start_index; i < icount; i++) - { - ptri = pEncBuf[i]->Access(); - if (((ptri[0]&mask_TAG)^tag) != 0) - { - for (j=i+1; (j < icount) && (((ptri[0]&mask_TAG)^tag) != 0); j++) - /** always start with present "i". **/ - { - ptrj = pEncBuf[j]->Access(); - if (((ptri[0]&mask_TAG)^tag) != 0 && - ((ptrj[0]&mask_TAG)^tag) == 0) - { /** SWITCH buffers so that greater is first. **/ - tmpEnc = pEncBuf[i]; - pEncBuf[i] = pEncBuf[j]; - pEncBuf[j] = tmpEnc; - ptri = pEncBuf[i]->Access(); - ptrj = pEncBuf[j]->Access(); - } - } - } - if (((ptri[0]&mask_TAG)^tag) == 0) - tag_count++; // COUNT each of this tag type. - } - - for (i=start_index; i < tag_count; i++) - { - for (j=i+1; j < tag_count; j++) /** always start with present "i". **/ - { - ptri = pEncBuf[i]->Access(); - ptrj = pEncBuf[j]->Access(); - if ((ptri[0]&mask) < (ptrj[0]&mask)) - { /** SWITCH buffers so that greater is first. **/ - tmpEnc = pEncBuf[i]; - pEncBuf[i] = pEncBuf[j]; - pEncBuf[j] = tmpEnc; - } - } - } - return(tag_count); -} - - -// -// SM_WriteToAsnBuf -long SM_WriteToAsnBuf( - CSM_Buffer &CBuf, // IN,class must be pre-allocated - AsnBuf &SNACCoutputBuf) -{ - long status=0; - CSM_Buffer *pCBuf=&CBuf; - - status = SM_WriteToAsnBuf(pCBuf, SNACCoutputBuf); - return(status); -} -long SM_WriteToAsnBuf( - CSM_Buffer *&pCBuf, // IN,class must be pre-allocated - AsnBuf &SNACCoutputBuf) -{ - long status=0; - char *ptr; - unsigned int jj=0; - SM_SIZE_T lRead=1; - SM_SIZE_T lOffset; - - pCBuf->Open(SM_FOPEN_READ); - for (jj = 0; jj < pCBuf->Length() && lRead > 0; jj += lRead) - { - if (jj == 0) // first time, only get last X bytes within 4096 block. - { - lOffset = pCBuf->Length() - (pCBuf->Length() % 4096); - } - else - lOffset -= 4096; - pCBuf->Seek(lOffset, 0); - ptr = pCBuf->nRead(4096, lRead); - SNACCoutputBuf.PutSegRvs(ptr, lRead); - } - pCBuf->Close(); - //SNACCoutputBuf.ResetInReadMode(); - if (lRead != jj) - status = 1; // error. - return(status); -} - -// SM_ReadFromAsnBuf (pre-alloced version) -// This function does the same thing as SM_ReadFromAsnBuf but does not -// allocate the incoming CSM_Buffer... -long SM_ReadFromAsnBuf( - AsnBuf &SNACCinputBuf, // IN, input SNACC buffer - CSM_Buffer *pCBuf, // OUT, copied data - long length, // IN, length of data to read. - CSM_Buffer *preLoad) // IN, optional data to be pre-loaded; - // (for SNACC support) -{ - char tmpBuf[4096]; - unsigned int jj, lWritten, lToRead; - int tmpLength; - - if (length == INDEFINITE_LEN) - { - // RWC; Call custom routine to trace the actual unknown ASN data in the - // RWC; buffer and determine the actual length of the buffer (this may - // RWC; be a recursive call). - AsnBuf SNACCinputBuf2 = SNACCinputBuf; // Create new, working copy for - // ASN ANY length determination. - length = SM_DetermineLengthBuf(SNACCinputBuf2); - } - - tmpLength = length; - if (preLoad) - tmpLength += preLoad->Length(); - // pCBuf should already be allocated and ready for use... - if (pCBuf == NULL) - return -1; - pCBuf->Open(SM_FOPEN_WRITE); - if (preLoad) // load requested data in front of SNACC buf. - pCBuf->Write(preLoad->Access(), preLoad->Length()); - for (jj=0, lWritten=1; - jj < (unsigned int)length && lWritten > 0; jj += lWritten) - { - if (length - jj < 4096) lToRead = length - jj; - else lToRead = 4096; - lWritten = SNACCinputBuf.CopyOut(&tmpBuf[0], lToRead); - if (lWritten) - pCBuf->Write(&tmpBuf[0], lWritten); - } - pCBuf->Close(); - - return (length); -} - -// SM_ReadFromAsnBuf (allocating version) -// NOTE::: IMPORTANT NOT TO RESET CSM_Buffer Write BUFFER. -// ALSO, DO NOT RESET THE AsnBuf from SNACC; this function is used -// to read data from ANY components in the incomming SNACC message. -long SM_ReadFromAsnBuf(CSM_Buffer *&pCBuf, // OUT,copied data. - AsnBuf &SNACCinputBuf, // IN, input SNACC buffer - long length, // IN, length of data to read. - CSM_Buffer *preLoad) // IN, optional data to be pre-loaded; - // (for SNACC support) -{ - int tmpLength; - - tmpLength = length; - if (preLoad) - tmpLength += preLoad->Length(); -#if defined(macintosh) || defined(__APPLE__) - pCBuf = new CSM_Buffer(length == INDEFINITE_LEN ? 0 : preLoad ? tmpLength : length); -#else - if (SNACCinputBuf.DataLen() > 16384) // RWC; MUST BE FIXED!!!! - pCBuf = new CSM_Buffer(tmpnam(NULL), 0); - else - pCBuf = new CSM_Buffer(0); -#endif - return (SM_ReadFromAsnBuf(SNACCinputBuf, pCBuf, length, preLoad)); -} - -////////////////////////////////////////////////////////////////////////// -// SM_AsnBits2Buffer gets the bits out of the snacc AsnBits class and -// stores them in a buffer LSB style. -long SM_AsnBits2Buffer(AsnBits *pBits, CSM_Buffer *pBuffer) -{ - size_t lBits; - size_t lNumBytes; - size_t i, j; - char *pch; - long lRetVal = -1; - - while (true) - { - if ((pBits == NULL) || (pBuffer == NULL)) - break; - - lBits = pBits->BitLen(); - // calculate the number of bytes being put into the buffer - lNumBytes = lBits / 8; - if (lBits % 8 > 0) - lNumBytes++; - - if ((pch = pBuffer->Alloc(lNumBytes)) == NULL) - break; - - for (i = 0; i < lNumBytes; i++) - { - for (j = 0; j < 8 && ((i*8)+j) < lBits; j++) - { - pch[i] += (pBits->GetBit((i*8)+j) << j); - } - } - - pBuffer->Open(SM_FOPEN_WRITE); - pBuffer->Flush(); - pBuffer->Close(); - - lRetVal = 0; - break; - } - return lRetVal; -} - -////////////////////////////////////////////////////////////////////////// -// SM_Buffer2AsnBits gets the bits out of the snacc AsnBits class and -// stores them in a buffer LSB style. -long SM_Buffer2AsnBits(CSM_Buffer *pBuffer, AsnBits *pBits, size_t lBits) -{ - size_t lNumBytes; - size_t i, j; - const char *pch; - long lRetVal = -1; - - if ((pBits != NULL) && (pBuffer != NULL)) - { - - pBits->ReSet(lBits); - // calculate the number of bytes being put into the buffer - lNumBytes = lBits / 8; - if (lBits % 8 > 0) - lNumBytes++; - pch = pBuffer->Access(); - - for (i = 0; i < lNumBytes; i++) - { - for (j = 0; j < 8 && ((i*8)+j) < lBits; j++) - { - if ((pch[i] >> j) & 0x01) - pBits->SetBit((i*8)+j); - } - } - lRetVal = 0; - } - - return lRetVal; -} - -long SM_BufferReverseBits(CSM_Buffer *pBuffer) -{ - long status=0; - size_t i; - unsigned char *ptr; - #ifdef __APPLE__ - static const short bbb[256]= - #else - static short bbb[256]= - #endif - { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff - }; - - if (pBuffer) - { - ptr = (unsigned char *)pBuffer->Access(); - for (i=0; i < pBuffer->Length(); i++) - { - ptr[i] = (char)bbb[ptr[i]]; - } - } - - return(status); -} - -#if SM_BUF_2_BIG_INT_STR - -long SM_Buffer2BigIntegerStr( CSM_Buffer *asn1Data, - BigIntegerStr &pSnaccBigIntStr, - bool unsignedFlag) -{ - BigIntegerStr *p = &pSnaccBigIntStr; - - return(SM_Buffer2BigIntegerStr(asn1Data, p, unsignedFlag)); -} - -// FUNCTION: SM_Buffer2BigIntegerStr() -// -// PURPOSE: Encforce ASN.1 encoding rules on the asn1Data. Make sure it's -// unsigned if the unsignedFlag is set to true. -// -long SM_Buffer2BigIntegerStr( CSM_Buffer *asn1Data, - BigIntegerStr *&ppSnaccBigIntStr, - bool unsignedFlag ) -{ - char *pDataCopy = const_cast(asn1Data->Access()); - SM_SIZE_T dataLen = asn1Data->Length(); - - // UPDATE comment - - /* IF the Fortezza Card generates an r,s,p,q,g or y value in which the - * first 9 bits are all set to 0, then the encoding software deletes the - * first octet from the octets to be encoded. This rule is applied - * repeatedly to the remaining octets until the first 9 bits are not all - * set to 0. - */ - if (unsignedFlag == 1) - { - while ( !( (pDataCopy[0] & 0xFF) || (pDataCopy[1] & 0x80)) ) - { - memcpy( &pDataCopy[0], &pDataCopy[1], (dataLen - 1)); - dataLen --; - pDataCopy[dataLen] = 0; - } - - /* If the Fortezza Card generates a r,s,p,q,g, or y value in which the - * MSB is set to 1, THEN the software prepends a single octet in which - * all bits are set to 0. - */ - if (pDataCopy[0] & 0x80) - { - char *tmp = NULL; - - tmp = (char *) calloc(1, dataLen + 1); - - tmp[0] = 0; - memcpy(&tmp[1], pDataCopy, dataLen); - free(pDataCopy); - pDataCopy = &tmp[0]; - dataLen ++; - - } - } - /* - * ASN.1 rules state that the first 9 bits of an integer encoding can - * not be all ones or all zeros. - */ - else - { - /* check for first first 9 bits all ones - */ - while ( (pDataCopy[0] & 0xFF) && (pDataCopy[1] & 0x80) ) - { - memcpy( &pDataCopy[0], &pDataCopy[1], dataLen - 1); - dataLen --; - pDataCopy[dataLen] = 0; - } - - /* check for first 9 bits all zeros - */ - while (pDataCopy[0] == 0 && (pDataCopy[1] >> 7) == 0) - { - memcpy( &pDataCopy[0], &pDataCopy[1], (dataLen - 1)); - dataLen --; - pDataCopy[dataLen] = 0; - } - } - - if (ppSnaccBigIntStr == NULL) - ppSnaccBigIntStr = new BigIntegerStr( pDataCopy, dataLen); - else - ppSnaccBigIntStr->ReSet( pDataCopy, dataLen ); - - return (0); -} - -#endif /* SM_BUF_2_BIG_INT_STR */ - -// -// -// RULES for recursive operation, determining the length of the specified -// buffer: -// - Always assume only the data from a valid ANY was passed in, missing tag -// and length. -// - Parse data from the 1st byte; if ASN data sets do not match the specified -// length or EOC designator, then we assume it is part of sequence and -// continue parsing. -// -long SM_DetermineLengthBuf(AsnBuf &SNACCinputBuf) -{ - AsnLen length = 0; - unsigned long int tagId1; - AsnLen elmtLen1; - AsnLen elmtLen0=INDEFINITE_LEN; - ENV_TYPE env; - - while (elmtLen0 == INDEFINITE_LEN) - { - tagId1 = BDecTag (SNACCinputBuf, length, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (SNACCinputBuf, length, env); - break; - } - elmtLen1 = BDecLen (SNACCinputBuf, length, env); - if (elmtLen1 == INDEFINITE_LEN) - { - elmtLen1 = SM_DetermineLengthBuf(SNACCinputBuf); - length += elmtLen1; - } - else if (!SNACCinputBuf.ReadError()) - { - SNACCinputBuf.Skip(elmtLen1); // SKIP this ASN.1 component. - length += elmtLen1; - } - else - { - length = 0; - break; - } - } - - return((long)length); - -} - - -/*** EOF smimesnacc.CPP ***/ diff --git a/SecuritySNACCRuntime/c++-lib/src/tkAppInit.c b/SecuritySNACCRuntime/c++-lib/src/tkAppInit.c deleted file mode 100644 index 4de6a67f..00000000 --- a/SecuritySNACCRuntime/c++-lib/src/tkAppInit.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * snacced - Snacc_Init added to the default tkXAppInit. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/src/Attic/tkAppInit.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - * $Log: tkAppInit.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:07 mb - * Move from private repository to open source repository - * - * Revision 1.3 2001/05/05 00:59:19 rmurphy - * Adding darwin license headers - * - * Revision 1.2 2000/06/08 20:05:37 dmitch - * Mods for X port. These files are actually machine generated and probably don't need to be in CVS.... - * - * Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy - * Base Fortissimo Tree - * - * Revision 1.1 1999/02/25 05:21:58 mb - * Added snacc c++ library - * - * Revision 1.2 1997/02/28 13:39:48 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.1 1997/01/02 09:07:59 rj - * first check-in - * - */ - -#ifndef __APPLE__ -/* I don't know why this gets configd to build but we don't have tk.h */ - -#include "snacc.h" - -#if TCL - -/* - * tkXAppInit.c -- - * - * Provides a default version of the TclX_AppInit procedure for use with - * applications built with Extended Tcl and Tk. This is based on the - * the UCB Tk file tkAppInit.c - * - *----------------------------------------------------------------------------- - * Copyright 1991-1993 Karl Lehenbauer and Mark Diekhans. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies. Karl Lehenbauer and - * Mark Diekhans make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - *----------------------------------------------------------------------------- - * $Id: tkAppInit.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - *----------------------------------------------------------------------------- - * Copyright (c) 1993 The Regents of the University of California. - * All rights reserved. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF - * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - */ - -#ifndef lint -static char rcsid[] = "$Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/src/Attic/tkAppInit.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ SPRITE (Berkeley)"; -#endif /* not lint */ - -#include - -#include "init.h" - -int -main(argc, argv) - int argc; /* Number of command-line arguments. */ - char **argv; /* Values of command-line arguments. */ -{ - Tk_Main(argc, argv, Tcl_AppInit); - return 0; /* Needed only to prevent compiler warning. */ -} - -int -Tcl_AppInit (interp) - Tcl_Interp *interp; /* Interpreter for application. */ -{ - if (Tcl_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - if (Tk_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL); - - if (Snacc_Init (interp) == TCL_ERROR) - return TCL_ERROR; - - if (Tree_Init (interp) == TCL_ERROR) - return TCL_ERROR; - - Tcl_SetVar (interp, "tcl_rcFileName", "~/.snaccedrc", TCL_GLOBAL_ONLY); - - return TCL_OK; -} - -#endif - -#endif // Apple diff --git a/SecuritySNACCRuntime/c++-lib/stamp-useful b/SecuritySNACCRuntime/c++-lib/stamp-useful deleted file mode 100644 index d20c726e..00000000 --- a/SecuritySNACCRuntime/c++-lib/stamp-useful +++ /dev/null @@ -1 +0,0 @@ -Wed Mar 20 11:39:57 PST 2002 diff --git a/SecuritySNACCRuntime/c-examples/any/README b/SecuritySNACCRuntime/c-examples/any/README deleted file mode 100644 index b62deb58..00000000 --- a/SecuritySNACCRuntime/c-examples/any/README +++ /dev/null @@ -1,113 +0,0 @@ -(RCS control information is at the end of this file.) - - -C ANY example README ------------------- - -This example shows how the snacc compiler handles the ANY DEFINED BY -type in C. ANY types (not ANY DEFINED BY) require the modifications -to the generated code. Type "make" to build this example. - -This directory should have the following files in it: - - README - genber.c - example.c - makefile - -There are 3 programs generated by the makefile: - - genber - builds a BER value of the AnyTestType and writes it - to a file called "att.ber" - - def - takes file name of an AnyTestType value. Decodes the - file and re-encodes it to stdout. Uses definite - lengths for constructed values. - - indef - takes file name of an AnyTestType value. Decodes the - file and re-encodes it to stdout. Uses indefinite - lengths for constructed values. - - -These files use the code generated by snacc from the -snacc/asn1specs/any.asn1 file. (see the makefile) - -Look at genber.c to see how values can be built and printed. - -Look at the generated code in any_test.c and any_test.h to see how the -any hash table is built. - - -try the following commands in your c-shell: - -%1 genber # generate the att.ber file -%2 indef att.ber > tmp.ber # decode att.ber an re-encode into tmp.ber -%3 def tmp.ber > tmp2.ber # decode tmp.ber an re-encode into tmp2.ber -%4 diff att.ber tmp2.ber # compare .ber files (should be the same) - -When you are finished with the example type "make clean" to remove -the binaries and generated code. - - - -Things To Note --------------- - -Snacc ASN.1 comment commands - -In the snacc/asn1specs/any.asn1 file, the AnyTestType has a special -"--snacc" ASN.1 comment after ::= to give snacc some extra information -about the AnyTestType. - -AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE { ... etc. ... } - -The "isPdu" flag tells snacc that the AnyTestType is a PDU type that -you will be calling the encoding and decoding routines directly -from your code. This causes snacc to generate the "BEncAnyTestType" -and "BDecAnyTestType" routines in addition to the standard -"BEncAnyTestTypeContent" and "BDecAnyTestTypeContent". - -The Content encoding and decoding routines only deal with the content -of the type, ignoring all of the tag and length pairs on the given -type (in this case the UNIVERSAL (CONSTRUCTED) 16 tag and the length -for the SEQUENCE). The "BEncAnyTestType" and "BDecAnyTestType" -routines do encode the SEQUENCE tag and its length. This design is -motivated by IMPLICIT tagging. - -The compiler generated routines generally only call the content -oriented routines except in the case of ANY and ANY DEFINED BY types. -For ANY and ANY DEFINED BY types the PDU form of the rouine is called -since the tags are not known by the containing type. - - -SNMP OBJECT-TYPE Macro - -The SNMP OBJECT-TYPE macro is used to define the id to type mapping -for ANY DEFINED BY types. The macro has been modified to accept both -INTEGERs and OBJECT IDENTIFIERs as values (see -snacc/asn1specs/any.asn1). This macro can be used with other -protocols to define the id to type mapping. - -Two hash tables are used to hold the id to type mappings. One for -INTEGER to type mappings and the other for OBJECT IDENTIFIER to type -mappings. You must explicitly initialize the hash tables by calling -generated init routines once at the beginning of your program. Each -module that has OBJECT-TYPE macros in it will generate an -"InitAny" routine. You must call every init routine to -add all the mappings to the hash table(s). - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/any/Attic/README,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:08 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1997/02/16 20:26:14 rj -# check-in of a few cosmetic changes -# -# Revision 1.1 1994/08/31 08:46:17 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# diff --git a/SecuritySNACCRuntime/c-examples/any/example.c b/SecuritySNACCRuntime/c-examples/any/example.c deleted file mode 100644 index 769e0cf5..00000000 --- a/SecuritySNACCRuntime/c-examples/any/example.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * c-examples/any/example.c - an example of how to call C ASN.1-BER - * encoders and decoders generated by snacc - * - * AUTHOR: Mike Sample - * DATE: Mar 92 - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/any/Attic/example.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - * $Log: example.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:07 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:19 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:08 aram - * Originals from SMIME Free Library. - * - * Revision 1.6 1997/02/16 20:26:15 rj - * check-in of a few cosmetic changes - * - * Revision 1.5 1995/07/24 20:40:19 rj - * any-test.[hc] becomes any.[hc] due to to snacc's new file name generation scheme. - * - * changed `_' to `-' in file names. - * - * Revision 1.4 1995/02/18 15:17:35 rj - * cosmetic changes - * - * Revision 1.3 1994/08/31 23:45:45 rj - * more portable .h file inclusion. - * - * Revision 1.2 1994/08/31 08:59:31 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" - -#include -#include -#if HAVE_FCNTL_H -#include -#endif -#include - -#include "any.h" - - - -main PARAMS ((argc, argv), - int argc _AND_ - char *argv[]) -{ - int fd; - SBuf buf; - SBuf encBuf; - char *encData; - AsnLen encodedLen; - AsnLen decodedLen; - int val; - AnyTestType att; - int size; - char *origData; - struct stat sbuf; - jmp_buf env; - - if (argc != 2) - { - fprintf (stderr, "Usage: %s \n", argv[0]); - fprintf (stderr, " Decodes the given PersonnelRecord BER data file\n"); - fprintf (stderr, " and re-encodes it to stdout\n"); - exit (1); - } - - fd = open (argv[1], O_RDONLY, 0); - if (fd < 0) - { - perror ("main: fopen"); - exit (1); - } - - if (fstat (fd, &sbuf) < 0) - { - perror ("main: fstat"); - exit (1); - } - - size = sbuf.st_size; - origData = (char*)malloc (size); - if (read (fd, origData, size) != size) - { - perror ("main: read"); - exit (1); - } - - close (fd); - - /* - * puts the given data 'origData' of 'size' bytes - * into an SBuf and sets the SBuf up for reading - * origData from the beginning - */ - SBufInstallData (&buf, origData, size); - - /* - * the first argument (512) is the number of bytes to - * initially allocate for the decoder to allocate from. - * The second argument (512) is the size in bytes to - * enlarge the nibble memory by when it fills up - */ - InitNibbleMem (512, 512); - - - /* - * initialize the hash table for the - * the ANY type mappings. - * This only needs to be done once per execution - * (before any encoding or decoding is done) - */ - InitAnyANY_TEST(); - - decodedLen = 0; - if ((val = setjmp (env)) == 0) - { - BDecAnyTestType (&buf, &att, &decodedLen, env); - } - else - { - fprintf (stderr, "ERROR - Decode routines returned %d\n",val); - exit (1); - } - - fprintf (stderr, "decodedValue AnyTestType ::= "); - PrintAnyTestType (stderr, &att, 0); - fprintf (stderr, "\n\n"); - - /* - * setup a new buffer set up for writing. - * make sure size is big enough to hold the encoded - * value (may be larger than decoded value if encoding - * with indef lengths - so add 512 slush bytes) - */ - encData = (char*) malloc (size + 512); - SBufInit (&encBuf, encData, size + 512); - SBufResetInWriteRvsMode (&encBuf); - - encodedLen = BEncAnyTestType (&encBuf, &att); - if ((encodedLen <= 0) || SBufWriteError (&encBuf)) - { - fprintf (stderr, "ERROR - buffer to hold the encoded value was too small\n"); - exit (1); - } - - /* - * free all of the decoded value since - * it has been encoded into the buffer. - * This is much more efficient than freeing - * each compontent of the value individually - */ - ResetNibbleMem(); - - /* - * write encoded value from encBuf - * to stdout - */ - fwrite (SBufDataPtr (&encBuf), SBufDataLen (&encBuf), 1, stdout); - - return 0; -} diff --git a/SecuritySNACCRuntime/c-examples/any/genber.c b/SecuritySNACCRuntime/c-examples/any/genber.c deleted file mode 100644 index 7ab8fc90..00000000 --- a/SecuritySNACCRuntime/c-examples/any/genber.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * c-examples/any/genber.c - builds an AnyTestType value and writes BER form - * of the value to a file called "att.ber" - * - * Shows how to build internal rep of lists and ANY values. - * - * MS 92 - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/any/Attic/genber.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - * $Log: genber.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:07 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:19 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:08 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1995/07/24 20:40:50 rj - * any-test.[hc] becomes any.[hc] due to to snacc's new file name generation scheme. - * - * changed `_' to `-' in file names. - * - * Revision 1.4 1995/02/18 15:17:36 rj - * cosmetic changes - * - * Revision 1.3 1994/08/31 23:48:06 rj - * more portable .h file inclusion. - * - * Revision 1.2 1994/08/31 08:59:32 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include /* this must be before stddef for gcc-2.3.1 */ -#include -#include -#include -#include -#include -#include - -#include "asn-incl.h" -#include "any.h" - - -main (int argc, char *argv[]) -{ - FILE *outputFile; - SBuf outputBuf; - unsigned long int encodedLen; - int dataSize = 1024; - int i; - char data[1024]; - AnyTestType att; - TSeq1 ts1; - TSeq2 ts2; - AttrValue1 **atv1Hndl; - AttrValue2 **atv2Hndl; - AsnInt intVal; - AsnBool boolVal; - AsnOcts octsVal; - AsnBits bitsVal; - AsnReal realVal; - - /* used to alloc part of value (Asn1Alloc & AsnListAppend) */ - InitNibbleMem (512,512); - - /* init id to type ANY hash table */ - InitAnyANY_TEST(); - - att.intMap = AsnListNew (sizeof (void*)); - atv1Hndl = (AttrValue1**)AsnListAppend (att.intMap); - *atv1Hndl = (AttrValue1*) Asn1Alloc (sizeof (AttrValue1)); - (*atv1Hndl)->id = intId; /* the id's are defined in the generated code */ - intVal = -99; - (*atv1Hndl)->anyDefBy.value = (void*) &intVal; - - atv1Hndl = (AttrValue1**)AsnListAppend (att.intMap); - *atv1Hndl = (AttrValue1*) Asn1Alloc (sizeof (AttrValue1)); - (*atv1Hndl)->id = boolId; - boolVal = TRUE; - (*atv1Hndl)->anyDefBy.value = (void*)&boolVal; - - atv1Hndl = (AttrValue1**)AsnListAppend (att.intMap); - *atv1Hndl = (AttrValue1*) Asn1Alloc (sizeof (AttrValue1)); - (*atv1Hndl)->id = octsId; - octsVal.octs = "Hi Mom"; - octsVal.octetLen = strlen (octsVal.octs); - (*atv1Hndl)->anyDefBy.value = (void*)&octsVal; - - atv1Hndl = (AttrValue1**)AsnListAppend (att.intMap); - *atv1Hndl = (AttrValue1*) Asn1Alloc (sizeof (AttrValue1)); - (*atv1Hndl)->id = bitsId; - bitsVal.bitLen = 10; - bitsVal.bits = (char*)&i; - SetAsnBit (&bitsVal, 0); - ClrAsnBit (&bitsVal, 1); - SetAsnBit (&bitsVal, 2); - ClrAsnBit (&bitsVal, 3); - SetAsnBit (&bitsVal, 4); - ClrAsnBit (&bitsVal, 5); - SetAsnBit (&bitsVal, 6); - ClrAsnBit (&bitsVal, 7); - SetAsnBit (&bitsVal, 8); - ClrAsnBit (&bitsVal, 9); - (*atv1Hndl)->anyDefBy.value = (void*)&bitsVal; - - atv1Hndl = (AttrValue1**)AsnListAppend (att.intMap); - *atv1Hndl = (AttrValue1*) Asn1Alloc (sizeof (AttrValue1)); - (*atv1Hndl)->id = realId; - realVal = 108.3838; - (*atv1Hndl)->anyDefBy.value = (void*)&realVal; - - /* now do TSeq2 with same vals but use OID as identifier */ - att.oidMap = AsnListNew (sizeof (void*)); - - atv2Hndl = (AttrValue2**)AsnListAppend (att.oidMap); - *atv2Hndl = (AttrValue2*) Asn1Alloc (sizeof (AttrValue2)); - (*atv2Hndl)->id = intOid; - (*atv2Hndl)->anyDefBy.value = (void*)&intVal; - - atv2Hndl = (AttrValue2**)AsnListAppend (att.oidMap); - *atv2Hndl = (AttrValue2*) Asn1Alloc (sizeof (AttrValue2)); - (*atv2Hndl)->id = boolOid; - (*atv2Hndl)->anyDefBy.value = (void*)&boolVal; - - atv2Hndl = (AttrValue2**)AsnListAppend (att.oidMap); - *atv2Hndl = (AttrValue2*) Asn1Alloc (sizeof (AttrValue2)); - (*atv2Hndl)->id = octsOid; - (*atv2Hndl)->anyDefBy.value = (void*)&octsVal; - - atv2Hndl = (AttrValue2**)AsnListAppend (att.oidMap); - *atv2Hndl = (AttrValue2*) Asn1Alloc (sizeof (AttrValue2)); - (*atv2Hndl)->id = bitsOid; - (*atv2Hndl)->anyDefBy.value = (void*)&bitsVal; - - atv2Hndl = (AttrValue2**)AsnListAppend (att.oidMap); - *atv2Hndl = (AttrValue2*) Asn1Alloc (sizeof (AttrValue2)); - (*atv2Hndl)->id = realOid; - (*atv2Hndl)->anyDefBy.value = (void*)&realVal; - - SBufInit (&outputBuf,data, dataSize); - SBufResetInWriteRvsMode (&outputBuf); - - encodedLen = BEncAnyTestType (&outputBuf, &att); - if ((encodedLen <= 0) || (SBufWriteError (&outputBuf))) - { - fprintf (stderr, "failed encoding AnyTestType value\n"); - exit (1); - } - - outputFile = fopen ("att.ber", "w"); - if (!outputFile) - { - perror ("fopen:"); - exit (1); - } - - SBufResetInReadMode (&outputBuf); - for ( ; encodedLen > 0; encodedLen--) - fputc (SBufGetByte (&outputBuf), outputFile); - - - printf ("Wrote the following BER AnyTestType value to att.ber.\n"); - printf ("Test it with \"def\" and \"indef\"\n"); - - PrintAnyTestType (stdout, &att, 0); - printf ("\n"); - - return 0; -} diff --git a/SecuritySNACCRuntime/c-examples/any/makefile b/SecuritySNACCRuntime/c-examples/any/makefile deleted file mode 100644 index 46f77767..00000000 --- a/SecuritySNACCRuntime/c-examples/any/makefile +++ /dev/null @@ -1,150 +0,0 @@ -# c-examples/any/makefile -# -# WARNING: this makefile isn't safe for parallel making! -# -# compile the any example -# -# MS 92 -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/any/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:08 aram -# Originals from SMIME Free Library. -# -# Revision 1.6 1995/07/24 20:42:31 rj -# useful.asn1 renamed to asn-useful.asn1 to accomodate to snacc's new file name generation scheme. -# any-test.[hc] becomes any.[hc] due to to snacc's new file name generation scheme. -# -# `cd && make' instead of `cd; make'. -# -# changed `_' to `-' in file names. -# -# Revision 1.5 1995/02/20 11:51:39 rj -# build snacc if it doesn't exist. -# some makes leave a trailing slash on $(@D), others don't. this causes some mkdir(1)s to deny their cooperation. therefore, the slash has got to be stripped. -# -# Revision 1.4 1995/02/13 15:05:05 rj -# augment CPPFLAGS, not overwrite. -# use $(@D) and $(@F) instead of `dirname $@` and `basename $@` (not every system's got the commands). -# we need the compiler for the dependencies, so make it if it doesn't yet exist. -# -# Revision 1.3 1994/08/31 21:41:37 rj -# rebuild the executables when the c-lib is newer. -# -# Revision 1.2 1994/08/31 10:31:49 rj -# since .o files get moved, a few more dependencies are needed. -# -# Revision 1.1 1994/08/31 08:46:20 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../../makehead - -TOP = ../.. - -ASN1_SRC_DIR = $(TOP)/asn1specs - -ASN1_C_LIB_DIR = $(TOP)/c-lib -ASN1_C_INC_DIR = $(ASN1_C_LIB_DIR)/inc -ASN1_C_LIB = $(ASN1_C_LIB_DIR)/libasn1csbuf.a - -COMPILERDIR = $(TOP)/compiler -SNACC = $(COMPILERDIR)/snacc -USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 -SNACCFLAGS = -u $(USEFUL_TYPES) - -CPPFLAGS += -I$(TOP) -I$(ASN1_C_INC_DIR) -DUSE_SBUF $(LENFLAG) - -ASN1FILES = $(ASN1_SRC_DIR)/any.asn1 - -# generated by snacc from any.asn1: -ASN1HFILES = any.h -ASN1CFILES = any.c - -CFILES = \ - genber.c \ - example.c - -DISTFILES = \ - README \ - makefile \ - $(CFILES) - -#------------------------------------------------------------------------------- - -all:: genber def indef - -$(ASN1HFILES) \ -$(ASN1CFILES): $(SNACC) $(ASN1FILES) - $(REASON) - $(SNACC) $(SNACCFLAGS) $(ASN1FILES) - -$(SNACC): - cd $(@D) && $(MAKE) $(@F) - -def-obj \ -indef-obj: - mkdir $@ - -def-obj/any.o \ -def-obj/example.o: - $(REASON) - $(MAKE) LENFLAG= `echo $(@D) | sed -e 's:/$$::'` $(@F) - mv $(@F) $@ - -indef-obj/any.o \ -indef-obj/example.o: - $(REASON) - $(MAKE) LENFLAG=-DUSE_INDEF_LEN `echo $(@D) | sed -e 's:/$$::'` $(@F) - mv $(@F) $@ - -genber: def-obj/any.o genber.o - $(REASON) - $(CC) $(LDFLAGS) -o $@ def-obj/any.o genber.o $(ASN1_C_LIB) $(LIBS) - -def: def-obj/any.o def-obj/example.o - $(REASON) - $(CC) $(LDFLAGS) -o $@ def-obj/any.o def-obj/example.o $(ASN1_C_LIB) $(LIBS) - -indef: indef-obj/any.o indef-obj/example.o - $(REASON) - $(CC) $(LDFLAGS) -o $@ indef-obj/any.o indef-obj/example.o $(ASN1_C_LIB) $(LIBS) - -genber \ -def \ -indef: $(ASN1_C_LIB) - -.PHONY: check - -check:: genber def indef - $(RM) foo.ber bar.ber - ./genber - ./indef att.ber > foo.ber - ./def foo.ber > bar.ber - @echo '' - @if cmp -s bar.ber att.ber; then\ - echo "+++ Passed simple encode/decode tests using any.asn1.";\ - else\ - echo "--- Failed simple encode/decode tests using any.asn1.";\ - fi - @echo '' - $(RM) foo.ber bar.ber - -clean:: - $(RM) *.o *~ .emacs* core def indef genber att.ber $(ASN1HFILES) $(ASN1CFILES) - $(RM) -r def-obj indef-obj - $(RM) foo.ber bar.ber - -depend:: $(SNACC) - -include ../../maketail - -depend:: - cp dependencies deps - for dir in def-obj indef-obj; do\ - < dependencies sed -e 's:^\(.*\.o\):'"$$dir"'/\1:' >> deps;\ - done - mv deps dependencies diff --git a/SecuritySNACCRuntime/c-examples/makefile b/SecuritySNACCRuntime/c-examples/makefile deleted file mode 100644 index 43819d96..00000000 --- a/SecuritySNACCRuntime/c-examples/makefile +++ /dev/null @@ -1,53 +0,0 @@ -# c-examples/makefile -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.2 2000/06/08 20:06:37 dmitch -# Mods for X port. -# -# Revision 1.1.1.1 1999/03/16 18:06:08 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1995/07/24 20:38:56 rj -# `cd && make' instead of `cd; make'. -# -# changed `_' to `-' in file names. -# - -# Appple change: snmp test does not work. -#SUBDIRS = test-lib simple any snmp -SUBDIRS = test-lib simple any - -#------------------------------------------------------------------------------- - -.PHONY: implicit_default -implicit_default:: - $(MAKE) subdirs - -subdirs:: $(SUBDIRS) -$(SUBDIRS):: - cd $@ && $(MAKE) $(subtarget) - -# the following hack is needed for older make versions (gmake doesn't need it): -init-depend:: - @for dir in $(SUBDIRS); do\ - test -f $$dir/dependencies || touch $$dir/dependencies;\ - done - -.DEFAULT:: - $(MAKE) subdirs subtarget=$@ - -distfiles:: - echo makefile - for dir in $(SUBDIRS); do\ - subfiles=`cd $$dir && $(MAKE) -s $@`;\ - for file in $$subfiles; do\ - echo "$$dir/$$file";\ - done;\ - done - -# dummy: -install:: diff --git a/SecuritySNACCRuntime/c-examples/simple/README b/SecuritySNACCRuntime/c-examples/simple/README deleted file mode 100644 index 89b096af..00000000 --- a/SecuritySNACCRuntime/c-examples/simple/README +++ /dev/null @@ -1,134 +0,0 @@ -(RCS control information is at the end of this file.) - - -C Simple Example README ------------------------ - -This directory should have 8 files in it: - -README - this file -genber.c - C source code for a program that creates and encodes - a PersonnelRecord value to a file. -expbuf_ex.c - C source code for a program that calls the generated - PersonnelRecord encoder and decoder routines - using the ExpBuf buffer type -minbuf_ex.c - C source code for program that calls the generated - PersonnelRecord encoder and decoder routines - using the MinBuf buffer type -sbuf_ex.c - C source code for a program that calls the generated - PersonnelRecord encoder and decoder routines - using the MinBuf buffer type -makefile - compiles the example programs -good_pr.ber - BER encoding of a Personnel Record (all definite lengths) - - - -Type "make" to generate the 7 example programs: - genber - expbuf_def - expbuf_indef - minbuf_def - minbuf_indef - sbuf_def - sbuf_indef - - -snacc is called from the makefile on snacc/asn1specs/p_rec.asn1 to -generate the following files: - -p_rec.h - C data structs for PersonnelRecord and prototypes for - the generated encode, decode, print and free routines. -p_rec.c - C source code for the PersonnelRecord encode, decode, - print, and free routines. - -These source files are then compiled with *_ex.c and genber.c files to -make 7 programs. Each program takes 1 argument (except genber), the -name of a file containing an BER encoded PersonnelRecord value. - - -Try the following: (or use the makefile's `check' phony target) - -eg% ./genber # create a file called pr.ber -eg% ./sbuf_indef good_pr.ber > indef_pr.ber -eg% ./sbuf_def indef_pr.ber > def_pr.ber -eg% diff good_pr.ber def_pr.ber # should be no differences - - -The above commands decode the BER value in "good_pr.ber" and -indef_pr.ber respectively and then re-encode then to stdout. -Both programs will decode any valid BER representation of a -PersonnelRecord value but, the sbuf_def program will re-encode the -given data using only the definite length BER format and the -sbuf_indef program will re-encode the given data using only the -indefinite length BER format. - -Compare the lengths of the def_pr.ber and indef_pr.ber files, -indefinite length encodings are usually larger. - - - -Things to Note --------------- - - -Look at genber.c to see how to build a C value and then encode it. -look at the *_ex.c files to see the different types of buffer -manipulation. Read the comments in the code. - -It should be relatively simple to change the memory and buffer -management to fit your target environment. -(see snacc/c_include/asn_config.h.) - - -Snacc ASN.1 comment commands - -Notice the special "--snacc" ASN.1 comment in snacc/asn1specs/p_rec.asn1. - -PersonnelRecord ::= --snacc isPdu:"TRUE" -- [APPLICATION 0] IMPLICIT SET - { ... etc. ... } - -The "isPdu" flag tells snacc that the PersonnelRecord is a PDU type -that you will be calling the encoding and decoding routines directly -from your code. This causes snacc to generate the -"BEncPersonnelRecord" and "BDecPersonnelRecord" routines in addition -to the standard "BEncPersonnelRecordContent" and -"BDecPersonnelRecordContent". - -The Content encoding and decoding routines only deal with the content -of the type, ignoring all of the tag and length pairs on the given -type (in this case the APPLICATION (CONSTRUCTED) 0 tag and the length -for the SET). The "BEncPersonnelRecord" and "BDecPersonnelRecord" -routines do encode the APPLICATION tag and the SET's length. This -design is motivated by IMPLICIT tagging. - -The compiler generated routines generally only call the content -oriented routines except in the case of ANY and ANY DEFINED BY types. -For ANY and ANY DEFINED BY types the PDU form of the rouine is called -since the tags are not known by the containing type. - - -Length formats - -Each pair of *_def and *_indef programs were generated from the same -source file, *_ex.c. Indefinite length encoders can be created by -giving the -DUSE_INDEF_LEN flag to the C compiler when compiling. -Currently the indefinite/definite length encoder choice is made a -compile time. To change this to a run-time decision, a simple -solution would be to modify BerEncodeConsLen and BerEncodeEocIfNec -macros in snacc/c_lib/asn_len.h to check a global flag. - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/simple/Attic/README,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:09 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1995/02/17 16:17:24 rj -# reflect the test script's integration into the makefile. -# -# Revision 1.1 1994/08/31 08:46:22 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# diff --git a/SecuritySNACCRuntime/c-examples/simple/expbuf-ex.c b/SecuritySNACCRuntime/c-examples/simple/expbuf-ex.c deleted file mode 100644 index 445ed81e..00000000 --- a/SecuritySNACCRuntime/c-examples/simple/expbuf-ex.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * c_examples/simple/expbuf_ex.c - an example of how to call C ASN.1-BER - * encoders and decoders generated by snacc - * with the ExpBuf buffer. - * - * AUTHOR: Mike Sample - * DATE: Mar 92 - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/simple/Attic/expbuf-ex.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - * $Log: expbuf-ex.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:07 mb - * Move from private repository to open source repository - * - * Revision 1.3 2001/05/05 00:59:20 rmurphy - * Adding darwin license headers - * - * Revision 1.2 2000/06/08 20:06:59 dmitch - * Mods for X port. - * - * Revision 1.1.1.1 1999/03/16 18:06:08 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1995/07/24 20:44:58 rj - * changed `_' to `-' in file names. - * - * Revision 1.4 1995/02/18 15:12:53 rj - * cosmetic changes - * - * Revision 1.3 1994/08/31 23:48:29 rj - * more portable .h file inclusion. - * - * Revision 1.2 1994/08/31 08:59:34 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" - -#include -#include -#if HAVE_FCNTL_H -#include -#endif -#include - -#include "p-rec.h" -#include "exp-buf.h" - -main PARAMS ((argc, argv), - int argc _AND_ - char *argv[]) -{ - int fd; - ExpBuf *buf; - ExpBuf b; - ExpBuf *tmpBuf; - AsnLen encodedLen; - AsnLen decodedLen; - int val; - PersonnelRecord pr; - int size; - char *origData; - struct stat sbuf; - jmp_buf env; - int decodeErr; - AsnTag tag; - - - if (argc != 2) - { - fprintf (stderr, "Usage: %s \n", argv[0]); - fprintf (stderr, " Decodes the given PersonnelRecord BER data file\n"); - fprintf (stderr, " and re-encodes it to stdout\n"); - exit (1); - } - - fd = open (argv[1], O_RDONLY, 0); - if (fd < 0) - { - perror ("main: fopen"); - exit (1); - } - - if (fstat (fd, &sbuf) < 0) - { - perror ("main: fstat"); - exit (1); - } - - size = sbuf.st_size; - origData = (char*)malloc (size); - if (read (fd, origData, size) != size) - { - perror ("main: read"); - exit (1); - } - - close (fd); - - /* - * the "1024" is the size in bytes of the data - * blk to allocate when writing to a buffer that - * fills up. - */ - ExpBufInit (1024); - - /* - * the first argument (512) is the number of bytes to - * initially allocate for the decoder to allocate from. - * The second argument (512) is the size in bytes to - * enlarge the nibble memory by when it fills up - */ - InitNibbleMem (512, 512); - - /* - * put the BER data read from the file - * into buffer format, ready for reading from the - * beginning - */ - buf = &b; - ExpBufInstallDataInBuf (buf, origData, size); - - decodedLen = 0; - decodeErr = FALSE; - if ((val = setjmp (env)) == 0) - { - BDecPersonnelRecord (&buf, &pr, &decodedLen, env); - } - else - { - decodeErr = TRUE; - fprintf (stderr, "ERROR - Decode routines returned %d\n",val); - } - - if (decodeErr) - exit (1); - - fprintf (stderr, "decodedValue PersonnelRecord ::= "); - PrintPersonnelRecord (stderr, &pr, 0); - fprintf (stderr, "\n\n"); - - /* - * allocate a new buffer set up for writing to - */ - buf = ExpBufAllocBufAndData(); - - encodedLen = BEncPersonnelRecord (&buf, &pr); - - /* - * Alway check for a buffer write error after encoding - */ - if (ExpBufWriteError (&buf)) - { - fprintf (stderr, "ERROR - buffer write error during encoding\n"); - exit (1); - } - - - /* - * free all of the decoded value since - * it has been encoded into the buffer. - * This is much more efficient than freeing - * each compontent of the value individually - */ - ResetNibbleMem(); - - /* - * go through buffer (s) and write encoded value - * to stdout - */ - buf->curr = buf->dataStart; - for ( tmpBuf = buf; tmpBuf != NULL; tmpBuf = tmpBuf->next) - { - fwrite (tmpBuf->dataStart, tmpBuf->dataEnd - tmpBuf->dataStart, 1, stdout); - } - - return 0; -} diff --git a/SecuritySNACCRuntime/c-examples/simple/genber.c b/SecuritySNACCRuntime/c-examples/simple/genber.c deleted file mode 100644 index c22e2b62..00000000 --- a/SecuritySNACCRuntime/c-examples/simple/genber.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * c_examples/simple/genber.c - builds a PersonnelRecord value and writes BER form - * of the value to a file called "pr.ber" - * - * - * MS 92 - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/simple/Attic/genber.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - * $Log: genber.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:07 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:20 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:08 aram - * Originals from SMIME Free Library. - * - * Revision 1.6 1995/07/24 20:45:00 rj - * changed `_' to `-' in file names. - * - * Revision 1.5 1995/02/18 15:12:54 rj - * cosmetic changes - * - * Revision 1.4 1995/02/17 16:21:03 rj - * unnecessary inclusion of removed. - * - * Revision 1.3 1994/09/01 01:02:37 rj - * more portable .h file inclusion. - * - * Revision 1.2 1994/08/31 08:59:35 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" - -#include -#include - -#include -#if STDC_HEADERS -#include -#endif -#include -#include - -#include "p-rec.h" - - -main (int argc, char *argv[]) -{ - FILE *outputFile; - SBuf outputBuf; - unsigned long int encodedLen; - int dataSize = 1024; - int i; - char data[1024]; - PersonnelRecord pr; - ChildInformation **childHndl; - - /* used to alloc part of value (Asn1Alloc & AsnListAppend) */ - InitNibbleMem (512,512); - - pr.name = Asn1Alloc (sizeof (Name)); - pr.name->givenName.octs = "John"; - pr.name->givenName.octetLen = strlen (pr.name->givenName.octs); - pr.name->initial.octs = "E"; - pr.name->initial.octetLen = strlen (pr.name->initial.octs); - pr.name->familyName.octs = "Smith"; - pr.name->familyName.octetLen = strlen (pr.name->familyName.octs); - - pr.title.octs = "The Big Cheese"; - pr.title.octetLen = strlen (pr.title.octs); - - pr.employeeNumber = 99999; - - pr.dateOfHire.octs = "19820104"; - pr.dateOfHire.octetLen = strlen (pr.dateOfHire.octs); - - pr.nameOfSpouse = (Name*) Asn1Alloc (sizeof (Name)); - pr.nameOfSpouse->givenName.octs = "Mary"; - pr.nameOfSpouse->givenName.octetLen = - strlen (pr.nameOfSpouse->givenName.octs); - pr.nameOfSpouse->initial.octs = "L"; - pr.nameOfSpouse->initial.octetLen = strlen (pr.nameOfSpouse->initial.octs); - pr.nameOfSpouse->familyName.octs = "Smith"; - pr.nameOfSpouse->familyName.octetLen = - strlen (pr.nameOfSpouse->familyName.octs); - - pr.children = AsnListNew (sizeof (void*)); - - childHndl = AsnListAppend (pr.children); - *childHndl = Asn1Alloc (sizeof (ChildInformation)); - - (*childHndl)->dateOfBirth.octs = "19570310"; - (*childHndl)->dateOfBirth.octetLen = strlen ((*childHndl)->dateOfBirth.octs); - (*childHndl)->name = (Name*) Asn1Alloc (sizeof (Name)); - - (*childHndl)->name->givenName.octs = "James"; - (*childHndl)->name->givenName.octetLen = - strlen ((*childHndl)->name->givenName.octs); - (*childHndl)->name->initial.octs = "R"; - (*childHndl)->name->initial.octetLen = - strlen ((*childHndl)->name->initial.octs); - (*childHndl)->name->familyName.octs = "Smith"; - (*childHndl)->name->familyName.octetLen = - strlen ((*childHndl)->name->familyName.octs); - - childHndl = AsnListAppend (pr.children); - *childHndl = Asn1Alloc (sizeof (ChildInformation)); - - (*childHndl)->dateOfBirth.octs = "19610621"; - (*childHndl)->dateOfBirth.octetLen = strlen ((*childHndl)->dateOfBirth.octs); - - (*childHndl)->name = (Name*) Asn1Alloc (sizeof (Name)); - - (*childHndl)->name->givenName.octs = "Lisa"; - (*childHndl)->name->givenName.octetLen = - strlen ((*childHndl)->name->givenName.octs); - (*childHndl)->name->initial.octs = "M"; - (*childHndl)->name->initial.octetLen = - strlen ((*childHndl)->name->initial.octs); - (*childHndl)->name->familyName.octs = "Smith"; - (*childHndl)->name->familyName.octetLen = - strlen ((*childHndl)->name->familyName.octs); - - SBufInit (&outputBuf,data, dataSize); - SBufResetInWriteRvsMode (&outputBuf); - - encodedLen = BEncPersonnelRecord (&outputBuf, &pr); - - /* - * after encoding a value ALWAYS check for write error - * in the buffer. The encode routine do not use longjmp - * when they enter an error state - */ - if ((encodedLen <= 0) || (SBufWriteError (&outputBuf))) - { - fprintf (stderr, "failed encoding PersonnelRecord value\n"); - exit (1); - } - - outputFile = fopen ("pr.ber", "w"); - if (!outputFile) - { - perror ("fopen:"); - exit (1); - } - - SBufResetInReadMode (&outputBuf); - for ( ; encodedLen > 0; encodedLen--) - fputc (SBufGetByte (&outputBuf), outputFile); - - - printf ("Wrote the following BER PersonnelRecord value to pr.ber.\n"); - printf ("Test it with \"def\" and \"indef\"\n"); - - PrintPersonnelRecord (stdout, &pr, 0); - printf ("\n"); - - return 0; -} diff --git a/SecuritySNACCRuntime/c-examples/simple/good-pr.ber b/SecuritySNACCRuntime/c-examples/simple/good-pr.ber deleted file mode 100644 index f8cc9410ed7be7741ca4c0e0805cce1fbee7df6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmYdj>`N37WAVz*$P;696=My~%`C}SARxvUl98(5l$oyJoROMZoEqQAz|7b-e<7DM zhoPl~k%6Is$s!?;M&HDuN-;(ssK&*PhVqGmVys??xv9lsj6pE-z}igB4U7#94CO%D Td@_p@#Tb22 $$bt-foo.ber;\ - ./$${bt}buf-def $$bt-foo.ber > $$bt-bar.ber;\ - done - @for bt in min exp s; do\ - if cmp -s $$bt-bar.ber good-pr.ber; then\ - echo "+++ Passed simple encode/decode tests using p-rec.asn1 with $${bt}bufs.";\ - else\ - echo "--- Failed simple encode/decode tests using p-rec.asn1 with $${bt}bufs.";\ - fi;\ - $(RM) $$bt-foo.ber $$bt-bar.ber;\ - done - -clean:: - $(RM) *.o *~ core .emacs* - $(RM) expbuf-def expbuf-indef sbuf-indef sbuf-def minbuf-def minbuf-indef genber pr.ber $(ASN1HFILES) $(ASN1CFILES) - $(RM) -r *-def-obj *-indef-obj - $(RM) *-foo.ber *-bar.ber - -depend:: $(SNACC) - -include ../../maketail - -depend:: - cp dependencies deps - for dir in min-def-obj min-indef-obj exp-def-obj exp-indef-obj s-def-obj s-indef-obj; do\ - < dependencies sed -e 's:^\(.*\.o\):'"$$dir"'/\1:' >> deps;\ - done - mv deps dependencies diff --git a/SecuritySNACCRuntime/c-examples/simple/minbuf-ex.c b/SecuritySNACCRuntime/c-examples/simple/minbuf-ex.c deleted file mode 100644 index ff5f7baa..00000000 --- a/SecuritySNACCRuntime/c-examples/simple/minbuf-ex.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * c_examples/simple/minbuf_ex.c - an example of how to call C ASN.1-BER - * encoders and decoders generated by snacc - * using the MinBuf buffer. - * - * AUTHOR: Mike Sample - * DATE: Mar 92 - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/simple/Attic/minbuf-ex.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - * $Log: minbuf-ex.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:07 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:20 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:09 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1995/07/24 20:46:59 rj - * changed `_' to `-' in file names. - * - * Revision 1.4 1995/02/18 15:12:55 rj - * cosmetic changes - * - * Revision 1.3 1994/09/01 01:02:38 rj - * more portable .h file inclusion. - * - * Revision 1.2 1994/08/31 08:59:36 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" - -#include -#include -#if HAVE_FCNTL_H -#include -#endif -#include - -#include "p-rec.h" - - -main PARAMS ((argc, argv), - int argc _AND_ - char *argv[]) -{ - int fd; - char *buf; - char *encBuf; - char *encData; - int encBufSize; - AsnLen encodedLen; - AsnLen decodedLen; - int val; - PersonnelRecord pr; - int size; - char *origData; - struct stat sbuf; - jmp_buf env; - int decodeErr; - AsnTag tag; - - - if (argc != 2) - { - fprintf (stderr, "Usage: %s \n", argv[0]); - fprintf (stderr, " Decodes the given PersonnelRecord BER data file\n"); - fprintf (stderr, " and re-encodes it to stdout\n"); - exit (1); - } - - fd = open (argv[1], O_RDONLY, 0); - if (fd < 0) - { - perror ("main: fopen"); - exit (1); - } - - if (fstat (fd, &sbuf) < 0) - { - perror ("main: fstat"); - exit (1); - } - - size = sbuf.st_size; - origData = (char*)malloc (size); - if (read (fd, origData, size) != size) - { - perror ("main: read"); - exit (1); - } - - close (fd); - - /* set up min buf */ - buf = origData; - - /* - * the first argument (512) is the number of bytes to - * initially allocate for the decoder to allocate from. - * The second argument (512) is the size in bytes to - * enlarge the nibble memory by when it fills up - */ - InitNibbleMem (512, 512); - - - decodedLen = 0; - decodeErr = FALSE; - if ((val = setjmp (env)) == 0) - { - BDecPersonnelRecord (&buf, &pr, &decodedLen, env); - } - else - { - decodeErr = TRUE; - fprintf (stderr, "ERROR - Decode routines returned %d\n",val); - } - - if (decodeErr) - exit (1); - - fprintf (stderr, "decodedValue PersonnelRecord ::= "); - PrintPersonnelRecord (stderr, &pr, 0); - fprintf (stderr, "\n\n"); - - /* - * setup a new buffer set up for writing. - * make sure size is big enough to hold the encoded - * value (may be larger than decoded value if encoding - * with indef lengths - so add 512 slush bytes) - */ - encBufSize = size + 512; - encData = (char*) malloc (encBufSize); - - /* - * set 'buffer' up for writing by setting ptr - * byte after last byte of the block - */ - encBuf = encData + encBufSize; - encodedLen = BEncPersonnelRecord (&encBuf, &pr); - - /* - * this will never report a write error - * since no error checking done by MinBuf code - * and alawys return false for when read or write errors. - */ - if (MinBufWriteError (&encBuf)) - { - fprintf (stderr, "ERROR - buffer to hold the encoded value was too small\n"); - exit (1); - } - - /* - * free all of the decoded value since - * it has been encoded into the buffer. - * This is much more efficient than freeing - * each compontent of the value individually - */ - ResetNibbleMem(); - - /* - * write encoded value from encBuf - * to stdout - */ - fwrite (encBuf, encData + encBufSize - encBuf, 1, stdout); - - return 0; -} diff --git a/SecuritySNACCRuntime/c-examples/simple/sbuf-ex.c b/SecuritySNACCRuntime/c-examples/simple/sbuf-ex.c deleted file mode 100644 index 9a6ecbc5..00000000 --- a/SecuritySNACCRuntime/c-examples/simple/sbuf-ex.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * c_examples/simple/sbuf_ex.c - an example of how to call C ASN.1-BER - * encoders and decoders generated by snacc - * using the SBuf buffer. - * - * AUTHOR: Mike Sample - * DATE: Mar 92 - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/simple/Attic/sbuf-ex.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - * $Log: sbuf-ex.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:07 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:20 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:09 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1995/07/24 20:47:00 rj - * changed `_' to `-' in file names. - * - * Revision 1.4 1995/02/18 15:12:56 rj - * cosmetic changes - * - * Revision 1.3 1994/09/01 01:02:39 rj - * more portable .h file inclusion. - * - * Revision 1.2 1994/08/31 08:59:37 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" - -#include -#include -#if HAVE_FCNTL_H -#include -#endif -#include - -#include "p-rec.h" - -main PARAMS ((argc, argv), - int argc _AND_ - char *argv[]) -{ - int fd; - SBuf buf; - SBuf encBuf; - char *encData; - AsnLen encodedLen; - AsnLen decodedLen; - int val; - PersonnelRecord pr; - int size; - char *origData; - struct stat sbuf; - jmp_buf env; - int decodeErr; - AsnTag tag; - - if (argc != 2) - { - fprintf (stderr, "Usage: %s \n", argv[0]); - fprintf (stderr, " Decodes the given PersonnelRecord BER data file\n"); - fprintf (stderr, " and re-encodes it to stdout\n"); - exit (1); - } - - fd = open (argv[1], O_RDONLY, 0); - if (fd < 0) - { - perror ("main: fopen"); - exit (1); - } - - if (fstat (fd, &sbuf) < 0) - { - perror ("main: fstat"); - exit (1); - } - - size = sbuf.st_size; - origData = (char*)malloc (size); - if (read (fd, origData, size) != size) - { - perror ("main: read"); - exit (1); - } - - close (fd); - - /* - * puts the given data 'origData' of 'size' bytes - * into an SBuf and sets the SBuf up for reading - * origData from the beginning - */ - SBufInstallData (&buf, origData, size); - - /* - * the first argument (512) is the number of bytes to - * initially allocate for the decoder to allocate from. - * The second argument (512) is the size in bytes to - * enlarge the nibble memory by when it fills up - */ - InitNibbleMem (512, 512); - - - decodedLen = 0; - decodeErr = FALSE; - if ((val = setjmp (env)) == 0) - { - BDecPersonnelRecord (&buf, &pr, &decodedLen, env); - } - else - { - decodeErr = TRUE; - fprintf (stderr, "ERROR - Decode routines returned %d\n",val); - } - - if (decodeErr) - exit (1); - - fprintf (stderr, "decodedValue PersonnelRecord ::= "); - PrintPersonnelRecord (stderr, &pr, 0); - fprintf (stderr, "\n\n"); - - /* - * setup a new buffer set up for writing. - * make sure size is big enough to hold the encoded - * value (may be larger than decoded value if encoding - * with indef lengths - so add 512 slush bytes) - */ - encData = (char*) malloc (size + 512); - SBufInit (&encBuf, encData, size + 512); - SBufResetInWriteRvsMode (&encBuf); - - encodedLen = BEncPersonnelRecord (&encBuf, &pr); - - if (SBufWriteError (&encBuf)) - { - fprintf (stderr, "ERROR - buffer to hold the encoded value was too small\n"); - exit (1); - } - - /* - * free all of the decoded value since - * it has been encoded into the buffer. - * This is much more efficient than freeing - * each compontent of the value individually - */ - ResetNibbleMem(); - - /* - * write encoded value from encBuf - * to stdout - */ - fwrite (SBufDataPtr (&encBuf), SBufDataLen (&encBuf), 1, stdout); - - return 0; -} diff --git a/SecuritySNACCRuntime/c-examples/snmp/README b/SecuritySNACCRuntime/c-examples/snmp/README deleted file mode 100644 index 305f7019..00000000 --- a/SecuritySNACCRuntime/c-examples/snmp/README +++ /dev/null @@ -1,124 +0,0 @@ -(RCS control information is at the end of this file.) - - -C SNMP Example - Mike Sample Mar 92 ------------------------------------ - -This example illustrates a few more features of the compiler than the -simple example. It also shows some deficiencies. No executable -programs are generated by the makefile, it only generates the snmp -code and compiles it without linking. - -This directory contains 2 files: - README - makefile - -Snacc generates source from the following ASN.1 files: - snacc/asn1specs/rfc1155_smi.asn1 - snacc/asn1specs/rfc1157_snmp.asn1 - snacc/asn1specs/rfc1213_mib2.asn1 - -multi-module compilation - The IMPORT/EXPORT mechanisms of ASN.1 '88 are supported so you don't - have to dump all of the ASN.1 definitions into a single file - The order of the ASN.1 file arguments is the order that they - are included in the generated source files. For example: - - %1 snacc rfc1155-smi.asn1 rfc1157-snmp.asn1 rfc1213-mib2.asn1 - - causes the order in which hdr files are included in rfc1213-mib.c - to be: - - #include "asn-incl.h" - #include "rfc1155-smi.h" - #include "rfc1157-snmp.h" - #include "rfc1213-mib2.h" - - - Currently, snacc assumes that each ASN.1 file given on the command - line depends on all of the others on the command line. There is - no attempt to compute the dependencies via the import lists alone. - -SNMP OBJECT-TYPE macro parsing / ANY type hash table - The SNMP OBJECT-TYPE macro is parsed. This results in the - type in the "SYNTAX" part of the macro is put into - the ANY type hash table using the OBJECT-TYPE macro's value as the - hash key. Also if the type in the SYNTAX field is not defined - outsided of the macro (could be different tagging etc), a proper - type definition is generated for it. If you want to change the way - the macro is handled, modify the corresponding routine in "do_macros.c". - -value definitions - The OBJECT IDENTIFIER values are turned into statically initialized - C values and included in the generated source and include file. This - is also done for INTEGER and BOOLEAN values. More complex values - are ignored by the compiler at the moment. (modify parse_vals.c if - you want to improve this) - - --P option of snacc is demonstrated - The ASN.1 for the parsed modules is generated from the internal data - structure. This can be useful for making sure the compiler is - handling your ASN.1 files correctly. It is also useful to see how - the types are modified and sorted to simplify code generation. - (see the snacc.output file after typeing "make") - -Deficiencies - A deficiency in parsing large integers is shown when parsing the - following rfc 1155 types: - - Counter ::= - [APPLICATION 1] - IMPLICIT INTEGER (0..4294967295) - - Gauge ::= - [APPLICATION 2] - IMPLICIT INTEGER (0..4294967295) - - TimeTicks ::= - [APPLICATION 3] - IMPLICIT INTEGER (0..4294967295) - -Due the size of a C long int the above ASN.1 is represented internally as: - -Counter ::= [APPLICATION 1] IMPLICIT INTEGER (0..-1) - -Gauge ::= [APPLICATION 2] IMPLICIT INTEGER (0..-1) - -TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..-1) - -The ASN.1 library contains routines for encoding/decoding unsigned -long integers but you must hand code the cases where it is used - the -compiler never generates code that calls them. - -Note also that the produced code for the SNMP ASN.1 must be modified -to correclty handle the "Opaque" data type. SNMP does not use the ANY -DEFINED BY type in an effort to simplify things. Instead an OCTET -STRING is used to hold and encoded value whose type is defined by an -OBJECT IDENTIFIER. With some simple modifications you can use the -snacc AsnAnyDefinedBy type instead of the OCTET STRING to achieve -the desired results. - -This should underline the danger of blindly trusting the compiler to -do the right thing for protocols such as SNMP or X.500 where the type -of an encoded value depends on a mechanism outside of ASN.1 or the ANY -type (ANY DEFINED BY types should work automatically). - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/snmp/Attic/README,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:09 aram -# Originals from SMIME Free Library. -# -# Revision 1.3 1995/07/27 09:58:31 rj -# rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to accomodate to snacc's new file name generation scheme. -# -# Revision 1.2 1995/07/24 20:47:39 rj -# changed `_' to `-' in file names. -# -# Revision 1.1 1994/08/31 08:46:33 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# diff --git a/SecuritySNACCRuntime/c-examples/snmp/makefile b/SecuritySNACCRuntime/c-examples/snmp/makefile deleted file mode 100644 index 3dd9a23d..00000000 --- a/SecuritySNACCRuntime/c-examples/snmp/makefile +++ /dev/null @@ -1,97 +0,0 @@ -# c-examples/snmp/makefile -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/snmp/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:09 aram -# Originals from SMIME Free Library. -# -# Revision 1.6 1995/07/27 09:57:38 rj -# rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to accomodate to snacc's new file name generation scheme. -# -# Revision 1.5 1995/07/24 20:48:27 rj -# `cd && make' instead of `cd; make'. -# -# changed `_' to `-' in file names. -# -# Revision 1.4 1995/02/20 11:52:11 rj -# build snacc if it doesn't exist. -# -# Revision 1.3 1995/02/13 15:05:48 rj -# augment CPPFLAGS, not overwrite. -# we need the compiler for the dependencies, so make it if it doesn't yet exist. -# -# Revision 1.2 1994/08/31 23:25:46 rj -# print a less irritating usage. -# -# Revision 1.1 1994/08/31 08:46:34 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../../makehead - -TOP = ../.. - -ASN1_SPEC_DIR = $(TOP)/asn1specs - -ASN1_C_LIB_DIR = $(TOP)/c-lib -ASN1_C_INC_DIR = $(ASN1_C_LIB_DIR)/inc -ASN1_C_LIB = $(ASN1_C_LIB_DIR)/libasn1csbuf.a - -COMPILERDIR = $(TOP)/compiler -SNACC = $(COMPILERDIR)/snacc - -CPPFLAGS += -I$(TOP) -I$(ASN1_C_INC_DIR) -DUSE_SBUF - -ASN1FILES = \ - $(ASN1_SPEC_DIR)/rfc1155-smi.asn1 \ - $(ASN1_SPEC_DIR)/rfc1157-snmp.asn1 \ - $(ASN1_SPEC_DIR)/rfc1213-mib2.asn1 - -ASN1HFILES = \ - rfc1155-smi.h \ - rfc1213-mib2.h \ - rfc1157-snmp.h - -ASN1CFILES = \ - rfc1155-smi.c \ - rfc1213-mib2.c \ - rfc1157-snmp.c - -DISTFILES = \ - README \ - makefile \ - -#------------------------------------------------------------------------------- - -default:: warning - -warning:: - @echo '' - @echo 'read the README and enter `$(MAKE) fail` to test for yourself' - @echo '' - -fail:: $(ASN1HFILES) $(ASN1CFILES) - $(CC) $(CPPFLAGS) $(CFLAGS) -c $(ASN1CFILES) - -$(ASN1HFILES) \ -$(ASN1CFILES): $(SNACC) $(ASN1FILES) - $(REASON) - $(SNACC) -P $(ASN1FILES) > snacc.output~ - mv snacc.output~ snacc.output - -$(SNACC): - cd $(@D) && $(MAKE) $(@F) - -check:: - @echo "the purpose of this directories' contents is to show deficiencies." - @echo "if you want to exercise 'em, make the phony target "'`'"fail'" - -clean:: - $(RM) *.o *~ .emacs* core $(ASN1HFILES) $(ASN1CFILES) snacc.output - -depend:: $(SNACC) - -include ../../maketail diff --git a/SecuritySNACCRuntime/c-examples/test-lib/README b/SecuritySNACCRuntime/c-examples/test-lib/README deleted file mode 100644 index d2f6738a..00000000 --- a/SecuritySNACCRuntime/c-examples/test-lib/README +++ /dev/null @@ -1,43 +0,0 @@ -(RCS control information is at the end of this file.) - - -C test_lib README ------------------ - -This directory should have 3 files: - README - this file - makefile - test_lib.c - -Type "make" to compile test_lib. - -test_lib tests each encode and decode routine in the C ASN.1 -runtime library. Errors will be reported. - -test_lib should be run for each machine architecture you install snacc on. -If you modify the library routines you should run test_lib again. - -The general testing methodology is: - 1. test the buffer routines - 2. test tags - 3. test lengths - 4. test each libarary type. - -For each type, a range of values is encoded and then decoded -and and compared with the original value. - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/test-lib/Attic/README,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:09 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1997/02/16 20:26:19 rj -# check-in of a few cosmetic changes -# -# Revision 1.1 1994/08/31 08:46:36 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# diff --git a/SecuritySNACCRuntime/c-examples/test-lib/makefile b/SecuritySNACCRuntime/c-examples/test-lib/makefile deleted file mode 100644 index c995281e..00000000 --- a/SecuritySNACCRuntime/c-examples/test-lib/makefile +++ /dev/null @@ -1,56 +0,0 @@ -# c-examples/test-lib/makefile -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/test-lib/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:09 aram -# Originals from SMIME Free Library. -# -# Revision 1.4 1995/07/24 20:50:11 rj -# changed `_' to `-' in file names. -# -# Revision 1.3 1995/02/13 15:05:59 rj -# augment CPPFLAGS, not overwrite. -# -# Revision 1.2 1994/08/31 21:43:20 rj -# rebuild the executables when the c-lib is newer. -# -# Revision 1.1 1994/08/31 08:46:37 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../../makehead - -TOP = ../.. - -ASN1_C_LIB_DIR = $(TOP)/c-lib -ASN1_C_INC_DIR = $(ASN1_C_LIB_DIR)/inc -ASN1_C_LIB = $(ASN1_C_LIB_DIR)/libasn1csbuf.a - -CPPFLAGS += -I$(TOP) -I$(ASN1_C_INC_DIR) -DUSE_SBUF - -LDLIBS = $(ASN1_C_LIB) $(LIBS) - -CFILES = \ - test-lib.c - -DISTFILES = \ - README \ - makefile \ - $(CFILES) - -#------------------------------------------------------------------------------- - -default:: check - -check:: test-lib - ./test-lib - -test-lib: $(ASN1_C_LIB) - -clean:: - $(RM) *.o *~ .emacs* test-lib core - -include ../../maketail diff --git a/SecuritySNACCRuntime/c-examples/test-lib/test-lib.c b/SecuritySNACCRuntime/c-examples/test-lib/test-lib.c deleted file mode 100644 index e334ffd7..00000000 --- a/SecuritySNACCRuntime/c-examples/test-lib/test-lib.c +++ /dev/null @@ -1,962 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * c_examples/test_lib/test_lib.c - * - * uses SBufs for buffers - * - * MS 92 - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-examples/test-lib/Attic/test-lib.c,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ - * $Log: test-lib.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:07 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:20 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:09 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1995/07/24 20:50:34 rj - * ``#error "..."'' instead of ``#error ...''. - * - * changed `_' to `-' in file names. - * - * Revision 1.4 1995/02/18 16:17:44 rj - * utilize either isinf(3) or finite(3), whatever happens to be present. - * - * Revision 1.3 1994/08/31 23:48:45 rj - * more portable .h file inclusion. - * - * Revision 1.2 1994/08/31 08:59:39 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" - -int TestAsnBuffers(); -int TestAsnTag(); -int TestAsnLen(); -int TestAsnBool(); -int TestAsnInt(); -int TestAsnReal(); -int TestAsnOcts(); -int TestAsnBits(); -int TestAsnOid(); -int TestAsnList(); - -int bufSize = 256; - -int -main() -{ - int isErr = FALSE; - - /* set up the PLUS and MINUS INFINITY globals */ - InitAsnInfinity(); - - /* needed for OCTET STRING, BIT STRING and OBJECT IDENTIFIER decoding */ - InitNibbleMem (256, 256); - - if (!TestAsnBuffers()) - { - fprintf (stdout, "Failed buffer tests, no point in proceeding ... bye!\n"); - return 1; - } - - - if (!TestAsnTag()) - { - fprintf (stdout, "Failed Tag test.\n" ); - isErr = TRUE; - } - - if (!TestAsnLen()) - { - fprintf (stdout, "Failed Length test.\n" ); - isErr = TRUE; - } - - if (!TestAsnBool()) - { - fprintf (stdout, "Failed BOOLEAN test.\n" ); - isErr = TRUE; - } - - - if (!TestAsnInt()) - { - fprintf (stdout, "Failed INTEGER test.\n" ); - isErr = TRUE; - } - - if (!TestAsnOcts()) - { - fprintf (stdout, "Failed OCTET STRING test.\n" ); - isErr = TRUE; - } - - - if (!TestAsnBits()) - { - fprintf (stdout, "Failed BIT STRING test.\n" ); - isErr = TRUE; - } - - - if (!TestAsnOid()) - { - fprintf (stdout, "Failed OBJECT IDENTIFIER test.\n" ); - isErr = TRUE; - } - - - if (!TestAsnReal()) - { - fprintf (stdout, "Failed REAL test.\n" ); - isErr = TRUE; - } - - - - if (isErr) - { - fprintf (stdout, "There are errors in the primitive type encoding/decoding\n" ); - fprintf (stdout, "library for this architecture. Time for gdb...\n" ); - } - else - { - fprintf (stdout, "The primitive type encoding/decoding library passed simple tests.\n"); - fprintf (stdout, "It should be safe to use...\n" ); - } - - return isErr; -} - - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnBuffers() -{ - int i,j; - int noErr = TRUE; - SBuf b; - char bufData[256]; - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - SBufResetInWriteRvsMode (&b); - - /* - * write whole range of byte (0..255) - * remember, write works in reverse - */ - for (i = 0; i < 256; i++) - BufPutByteRvs (&b,i); - - if (BufWriteError (&b)) - { - fprintf (stdout, "Error writing to buffer.\n" ); - noErr = FALSE; - } - - /* read in values & verify */ - SBufResetInReadMode (&b); - for (i = 255; i >= 0; i--) - if (BufGetByte (&b) != i) - { - fprintf (stdout, "Error verifying data written to buffer.\n" ); - noErr = FALSE; - } - - if (BufReadError (&b)) - { - fprintf (stdout, "Error reading from buffer.\n" ); - noErr = FALSE; - } - - - /* now make sure errors are detected */ - SBufResetInWriteRvsMode (&b); - - for (i = 0; i < 257; i++) /* write past end of buffer */ - BufPutByteRvs (&b,0); - - if (!BufWriteError (&b)) - { - fprintf (stdout, "Buffers failed to report buffer write overflow.\n" ); - noErr = FALSE; - } - - - SBufResetInReadMode (&b); - for (i = 256; i >= 0; i--) /* read past end of buffer */ - BufGetByte (&b); - - if (!BufReadError (&b)) - { - fprintf (stdout, "Buffers failed to report buffer read overflow.\n" ); - noErr = FALSE; - } - - return noErr; -} /* TestAsnBuffers */ - - - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnTag() -{ - AsnTag aTag1; - AsnTag aTag2; - int i, j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = TRUE; - ENV_TYPE env; - SBuf b; - char bufData[256]; - long int val; - BER_CLASS class; - BER_FORM form; - BER_UNIV_CODE code; - - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - - - /* encode a true value and verify */ - class = UNIV; - form = PRIM; - code = INTEGER_TAG_CODE; - aTag1 = MAKE_TAG_ID (class, form, code); - - for (i = 0; i < 2; i++) - { - SBufResetInWriteRvsMode (&b); - len1 = BEncTag1 (&b, class, form, code); - - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding a Tag.\n" ); - } - - SBufResetInReadMode (&b); - - aTag2 = 0; - - /* make sure no decode errors and that it decodes to same tag */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - aTag2 = BDecTag (&b, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding a Tag - error number %d\n", val); - } - if (noErr && ((aTag2 != aTag1) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error decoded Tag does not match encoded Tag.\n" ); - } - /* set a new test tag value */ - class = CNTX; - form = CONS; - code = 29; - aTag1 = MAKE_TAG_ID (class, form, code); - } - return noErr; -} /* TestAsnTag */ - - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnLen() -{ - AsnLen aLen1; - AsnLen aLen2; - int i,j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = TRUE; - ENV_TYPE env; - SBuf b; - char bufData[256]; - long int val; - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - - - /* encode a true value and verify */ - aLen1 = 99999; - for (i = 0; i < 2; i++) - { - SBufResetInWriteRvsMode (&b); - len1 = BEncDefLen (&b, aLen1); - - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding Length.\n" ); - } - - SBufResetInReadMode (&b); - - aLen2 = 0; - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - aLen2 = BDecLen (&b, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding Length - error number %d\n", val); - } - - - if (noErr && ((aLen2 != aLen1) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error - decoded lenght does not match encoded length\n"); - } - aLen1 = 2; - } - - - /* test indef len */ - SBufResetInWriteRvsMode (&b); - len1 = BEncIndefLen (&b); - - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding indefinite Length.\n" ); - } - - SBufResetInReadMode (&b); - - aLen2 = 0; - - /* make sure no decode errors */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - aLen2 = BDecLen (&b, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding Length - error number %d\n", val); - } - - - if (noErr && ((aLen2 != INDEFINITE_LEN) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error - decoded length does not match encoded length\n"); - } - - /* test EOC */ - SBufResetInWriteRvsMode (&b); - len1 = BEncEoc (&b); - - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding indefinite Length.\n" ); - } - - SBufResetInReadMode (&b); - - aLen2 = 0; - - /* make sure no decode errors */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecEoc (&b, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding Length - error number %d\n", val); - } - - - if (noErr && (len1 != len2)) - { - noErr = FALSE; - fprintf (stdout, "Error - decoded EOC length error.\n"); - } - - return noErr; -} /* TestAsnLen */ - - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnBool() -{ - AsnBool aBool1; - AsnBool aBool2; - int j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = TRUE; - ENV_TYPE env; - SBuf b; - char bufData[256]; - long int val; - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - SBufResetInWriteRvsMode (&b); - - /* encode a true value and verify */ - aBool1 = TRUE; - len1 = BEncAsnBoolContent (&b, &aBool1); - - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding TRUE BOOLEAN value.\n" ); - } - - SBufResetInReadMode (&b); - - aBool2 = FALSE; /* set to opposite of expected value */ - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecAsnBoolContent (&b, tag, len1, &aBool2, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding a BOOLEAN - error number %d\n", val); - } - - - if (noErr && ((aBool2 != aBool1) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error decoding TRUE BOOLEAN value.\n" ); - } - - /* now encode a false value and verify */ - SBufResetInWriteRvsMode (&b); - aBool1 = FALSE; - - len1 = BEncAsnBoolContent (&b, &aBool1); - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding FALSE BOOLEAN value.\n" ); - } - - SBufResetInReadMode (&b); - - aBool2 = TRUE; /* set to opposite of expected value */ - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecAsnBoolContent (&b, tag, len1, &aBool2, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding a BOOLEAN - error number %d\n", val); - } - - - if (noErr && ((aBool2 != aBool1) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error decoding TRUE BOOLEAN value.\n" ); - } - - /* make sure no decode errors and that it decodes to false */ - - return noErr; -} /* TestAsnBool */ - - - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnInt() -{ - AsnInt a1; - AsnInt a2; - int i,j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = TRUE; - ENV_TYPE env; - SBuf b; - char bufData[256]; - long int val; - int sign; - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - - /* - * Encode a range of integers: negative & positive in - * the 1 to sizeof (AsnInt) range - */ - sign = 1; - for (j = 0; j < 2; j++) - { - for (i = 0; i < sizeof (AsnInt); i++) - { - SBufResetInWriteRvsMode (&b); - - a1 = sign * (17 << (i * 8)); /* 17 is a random choice :) */ - len1 = BEncAsnIntContent (&b, &a1); - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding INTEGER value %d.\n", a1 ); - } - - SBufResetInReadMode (&b); - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecAsnIntContent (&b, tag, len1, &a2, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding a INTEGER - error number %d\n", val); - } - - if (noErr && ((a2 != a1) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error decoding INTEGER value %d.\n", a1 ); - } - } - sign = -1; - } - - return noErr; - -} /* TestAsnInt */ - - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnOcts() -{ - AsnOcts a1; - AsnOcts a2; - int i,j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = TRUE; - ENV_TYPE env; - SBuf b; - char bufData[256]; - long int val; - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - - a1.octs = "Hello Gumby"; - a1.octetLen = strlen (a1.octs); - - /* - * octet string decoder needs to know tag form - * (snacc always encodes octet strings as primitives) - */ - tag = MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE); - - for (j = 0; j < 2; j++) - { - SBufResetInWriteRvsMode (&b); - - len1 = BEncAsnOctsContent (&b, &a1); - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding OCTET STRING value \"%s\".\n", a1.octs ); - } - SBufResetInReadMode (&b); - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecAsnOctsContent (&b, tag, len1, &a2, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding an OCTET STRING - error number %d\n", val); - } - - if (noErr && (!AsnOctsEquiv (&a2,&a1) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error decoding OCTET STRING value %s.\n", a1.octs ); - } - a1.octs = ""; /* test empty string */ - a1.octetLen = strlen (a1.octs); - } - - ResetNibbleMem(); - return noErr; - -} /* TestAsnOcts */ - - - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnBits() -{ - AsnBits a1; - AsnBits a2; - int i,j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = TRUE; - ENV_TYPE env; - SBuf b; - char bufData[256]; - long int val; - short bitsToSet[35]; - - /* - * init bitsToSet - old compilers don't support automatic init - * of aggregate types. - */ - bitsToSet[0] = 0; - bitsToSet[1] = 1; - bitsToSet[2] = 0; - bitsToSet[3] = 0; - bitsToSet[4] = 1; - bitsToSet[5] = 1; - bitsToSet[6] = 0; - bitsToSet[7] = 1; - bitsToSet[8] = 0; - bitsToSet[9] = 1; - bitsToSet[10] = 0; - bitsToSet[11] = 0; - bitsToSet[12] = 1; - bitsToSet[13] = 1; - bitsToSet[14] = 0; - bitsToSet[15] = 1; - bitsToSet[16] = 0; - bitsToSet[17] = 1; - bitsToSet[18] = 0; - bitsToSet[19] = 0; - bitsToSet[20] = 1; - bitsToSet[21] = 1; - bitsToSet[22] = 0; - bitsToSet[23] = 1; - bitsToSet[24] = 0; - bitsToSet[25] = 1; - bitsToSet[26] = 0; - bitsToSet[27] = 1; - bitsToSet[28] = 1; - bitsToSet[29] = 0; - bitsToSet[30] = 1; - bitsToSet[31] = 1; - bitsToSet[32] = 0; - bitsToSet[33] = 1; - bitsToSet[34] = 0; - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - - /* initialize bit string */ - a1.bits = Asn1Alloc (5); - a1.bitLen = 35; - for (i = 0; i < 35; i++) - { - if (bitsToSet[i]) - SetAsnBit (&a1, i); - else - ClrAsnBit (&a1, i); - } - - /* - * bit string decoder needs to know tag form - * (snacc always encodes bit strings as primitives) - */ - tag = MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE); - - SBufResetInWriteRvsMode (&b); - - len1 = BEncAsnBitsContent (&b, &a1); - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding BIT STRING value "); - PrintAsnBits (stdout, &a1, 0); - fprintf (stdout, "\n"); - } - SBufResetInReadMode (&b); - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecAsnBitsContent (&b, tag, len1, &a2, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding an BIT STRING - error number %d\n", val); - } - - if (noErr && (!AsnBitsEquiv (&a2,&a1) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error decoding BIT STRING value "); - PrintAsnBits (stdout, &a1, 0); - fprintf (stdout, "\n"); - } - ResetNibbleMem(); - return noErr; - -} /* TestAsnBits */ - - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnOid() -{ - AsnOid a1; - AsnOid a2; - int i,j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = TRUE; - ENV_TYPE env; - SBuf b; - char bufData[256]; - long int val; - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - - /* mib-2 oid { iso 3 6 1 2 1 }*/ - a1.octetLen = 5; - a1.octs = "\53\6\1\2\1"; - - - for (j = 0; j < 2; j++) - { - SBufResetInWriteRvsMode (&b); - - len1 = BEncAsnOidContent (&b, &a1); - if (BufWriteError (&b)) - { - noErr = FALSE; - fprintf (stdout, "Error encoding OCTET STRING value \"%s\".\n", a1.octs ); - } - SBufResetInReadMode (&b); - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecAsnOidContent (&b, tag, len1, &a2, &len2, env); - } - else - { - noErr = FALSE; - fprintf (stdout, "Error decoding an OCTET STRING - error number %d\n", val); - } - - if (noErr && (!AsnOidsEquiv (&a2,&a1) || (len1 != len2))) - { - noErr = FALSE; - fprintf (stdout, "Error decoding OCTET STRING value %s.\n", a1.octs ); - } - /* system { mib-2 1 }*/ - a1.octs = "\53\6\1\2\1\1"; - a1.octetLen = 6; - } - ResetNibbleMem(); - return noErr; - -} /* TestAsnOid */ - -/* - * returns TRUE if passes encode/decode tests - */ -int -TestAsnReal() -{ - AsnReal a1[5]; - AsnReal a2; - int i,j; - AsnLen len1; - AsnLen len2; - AsnTag tag; - int noErr = TRUE; - int elmtErr = FALSE; - ENV_TYPE env; - SBuf b; - char bufData[256]; - long int val; - int sign; - AsnReal inf; - unsigned char *c; - - - /* - * if you do not have the ieee_functions in your math lib, - * this will not link. Comment it out and cross you fingers. - * (or check/set the +/-infinity values for you architecture) - */ -#if HAVE_ISINF - if (!isinf (PLUS_INFINITY) || !isinf (MINUS_INFINITY)) -#else -#if HAVE_FINITE - if (finite (PLUS_INFINITY) || finite (MINUS_INFINITY)) -#else - #error "oops: you've got neither isinf(3) nor finite(3)?!" -#endif -#endif - { - fprintf (stdout, "WARNING: PLUS_INFINITY and MINUS_INFINITY in asn_real.c are not\n"); - fprintf (stdout, "correct for this architecture. Modify the InitAsnInfinity() Routine.\n"); - } - - /* - * init test value array. - * some old compilers don't support automatic init of aggregate types - * like: - * AsnReal a1[] = { 0.0, 0.8, -22.484848, PLUS_INFINITY, MINUS_INFINITY}; - */ - a1[0] = 0.0; - a1[1] = 0.8; - a1[2] = -22.484848; - a1[3] = PLUS_INFINITY; - a1[4] = MINUS_INFINITY; - - /* initialize buffer */ - SBufInit (&b, bufData, 256); - - /* - * Encode a range of integers: negative & positive in - * the 1 to sizeof (AsnInt) range - */ - for (i = 0; i < 5; i++) - { - elmtErr = FALSE; - SBufResetInWriteRvsMode (&b); - - len1 = BEncAsnRealContent (&b, &a1[i]); - if (BufWriteError (&b)) - { - elmtErr = TRUE; - fprintf (stdout, "Error encoding REAL value "); - PrintAsnReal (stdout,&a1[i],0); - fprintf (stdout, ".\n"); - } - - SBufResetInReadMode (&b); - - /* make sure no decode errors and that it decodes to true */ - len2 = 0; - if ((val = setjmp (env)) == 0) - { - BDecAsnRealContent (&b, tag, len1, &a2, &len2, env); - } - else - { - elmtErr = TRUE; - fprintf (stdout, "Error decoding a REAL - error number %d\n", val); - } - - /* testing reals for equality is sketchy */ - if (!elmtErr && ((a2 != a1[i]) || (len1 != len2))) - { - - elmtErr = TRUE; - fprintf (stdout, "Error decoding REAL value "); - PrintAsnReal (stdout, &a1[i], 0); - fprintf (stdout, ".\n"); - - if (len1 == len2) /* therefore a2 != a1[i] */ - { - fprintf (stdout, "The value decoded was "); - PrintAsnReal (stdout, &a2, 0); - fprintf (stdout, ".\n"); - } - else - fprintf (stdout, "The encoded and decoded length disagree.\n"); - } - if (elmtErr) - noErr = FALSE; - } - - - return noErr; - -} /* TestAsnReal */ diff --git a/SecuritySNACCRuntime/c-lib/.cvsignore b/SecuritySNACCRuntime/c-lib/.cvsignore deleted file mode 100644 index 1a2b4fa3..00000000 --- a/SecuritySNACCRuntime/c-lib/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -Cebuf -ebuf -mbuf -sbuf -tbl diff --git a/SecuritySNACCRuntime/c-lib/README b/SecuritySNACCRuntime/c-lib/README deleted file mode 100644 index 17c2e234..00000000 --- a/SecuritySNACCRuntime/c-lib/README +++ /dev/null @@ -1,36 +0,0 @@ -(RCS control information is at the end of this file.) - - -C ASN.1 library README ----------------------- - -This directory contains the type definitions and the encode, decode, -free and print routines for all of the built-in ASN.1 types. It also -contains the code for three different buffer types. - -The makefile will produce 3 different libraries, one for each buffer -type. Each buffer types requires a different library because many of -the buffer routine calls made from the encode and decode library -routines are macros (for performance reasons). - -The 3 libararies are: - libasn1cebuf.a - uses the ExpBufs - libasn1cmbuf.a - uses the MinBufs - libasn1csbuf.a - uses the SBufs - -See the documentation for a full descriptions of the buffer types. -You must link your code with proper library (i.e. if you use SBufs, -link with libasn1csbuf.a). - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/Attic/README,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:10 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1994/08/31 23:50:07 rj -# textual change to adapt to change of directory tree. -# diff --git a/SecuritySNACCRuntime/c-lib/asn-useful.c b/SecuritySNACCRuntime/c-lib/asn-useful.c deleted file mode 100644 index 2ce63e57..00000000 --- a/SecuritySNACCRuntime/c-lib/asn-useful.c +++ /dev/null @@ -1,874 +0,0 @@ -/* - * asn-useful.c - * - * "ASN-USEFUL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Tue Mar 19 07:24:46 2002 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "asn-useful.h" - - -AsnLen BEncUTF8String PARAMS ((b, v), -BUF_TYPE b _AND_ -UTF8String *v) -{ - AsnLen l; - l = BEncUTF8StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, 12); - return l; -} /* BEncUTF8String */ - -void BDecUTF8String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -UTF8String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, 12))&& - (tag != MAKE_TAG_ID (UNIV, CONS, 12))) - { - Asn1Error ("BDecUTF8String: ERROR - wrong tag\n"); - longjmp (env, 50); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecUTF8StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecUTF8String */ - -AsnLen BEncNumericString PARAMS ((b, v), -BUF_TYPE b _AND_ -NumericString *v) -{ - AsnLen l; - l = BEncNumericStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); - return l; -} /* BEncNumericString */ - -void BDecNumericString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -NumericString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE))) - { - Asn1Error ("BDecNumericString: ERROR - wrong tag\n"); - longjmp (env, 49); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecNumericStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecNumericString */ - -AsnLen BEncPrintableString PARAMS ((b, v), -BUF_TYPE b _AND_ -PrintableString *v) -{ - AsnLen l; - l = BEncPrintableStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - return l; -} /* BEncPrintableString */ - -void BDecPrintableString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -PrintableString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) - { - Asn1Error ("BDecPrintableString: ERROR - wrong tag\n"); - longjmp (env, 48); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecPrintableStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecPrintableString */ - -AsnLen BEncTeletexString PARAMS ((b, v), -BUF_TYPE b _AND_ -TeletexString *v) -{ - AsnLen l; - l = BEncTeletexStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} /* BEncTeletexString */ - -void BDecTeletexString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -TeletexString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecTeletexString: ERROR - wrong tag\n"); - longjmp (env, 47); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecTeletexStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecTeletexString */ - -AsnLen BEncT61String PARAMS ((b, v), -BUF_TYPE b _AND_ -T61String *v) -{ - AsnLen l; - l = BEncT61StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} /* BEncT61String */ - -void BDecT61String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -T61String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecT61String: ERROR - wrong tag\n"); - longjmp (env, 46); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecT61StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecT61String */ - -AsnLen BEncVideotexString PARAMS ((b, v), -BUF_TYPE b _AND_ -VideotexString *v) -{ - AsnLen l; - l = BEncVideotexStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE); - return l; -} /* BEncVideotexString */ - -void BDecVideotexString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -VideotexString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VIDEOTEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecVideotexString: ERROR - wrong tag\n"); - longjmp (env, 45); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecVideotexStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecVideotexString */ - -AsnLen BEncIA5String PARAMS ((b, v), -BUF_TYPE b _AND_ -IA5String *v) -{ - AsnLen l; - l = BEncIA5StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, IA5STRING_TAG_CODE); - return l; -} /* BEncIA5String */ - -void BDecIA5String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -IA5String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) - { - Asn1Error ("BDecIA5String: ERROR - wrong tag\n"); - longjmp (env, 44); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecIA5StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecIA5String */ - -AsnLen BEncGraphicString PARAMS ((b, v), -BUF_TYPE b _AND_ -GraphicString *v) -{ - AsnLen l; - l = BEncGraphicStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GRAPHICSTRING_TAG_CODE); - return l; -} /* BEncGraphicString */ - -void BDecGraphicString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GraphicString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GRAPHICSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GRAPHICSTRING_TAG_CODE))) - { - Asn1Error ("BDecGraphicString: ERROR - wrong tag\n"); - longjmp (env, 43); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGraphicStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGraphicString */ - -AsnLen BEncVisibleString PARAMS ((b, v), -BUF_TYPE b _AND_ -VisibleString *v) -{ - AsnLen l; - l = BEncVisibleStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} /* BEncVisibleString */ - -void BDecVisibleString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -VisibleString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error ("BDecVisibleString: ERROR - wrong tag\n"); - longjmp (env, 42); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecVisibleStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecVisibleString */ - -AsnLen BEncISO646String PARAMS ((b, v), -BUF_TYPE b _AND_ -ISO646String *v) -{ - AsnLen l; - l = BEncISO646StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} /* BEncISO646String */ - -void BDecISO646String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -ISO646String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error ("BDecISO646String: ERROR - wrong tag\n"); - longjmp (env, 41); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecISO646StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecISO646String */ - -AsnLen BEncGeneralString PARAMS ((b, v), -BUF_TYPE b _AND_ -GeneralString *v) -{ - AsnLen l; - l = BEncGeneralStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GENERALSTRING_TAG_CODE); - return l; -} /* BEncGeneralString */ - -void BDecGeneralString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GeneralString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GENERALSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GENERALSTRING_TAG_CODE))) - { - Asn1Error ("BDecGeneralString: ERROR - wrong tag\n"); - longjmp (env, 40); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGeneralStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGeneralString */ - -AsnLen BEncUTCTime PARAMS ((b, v), -BUF_TYPE b _AND_ -UTCTime *v) -{ - AsnLen l; - l = BEncUTCTimeContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE); - return l; -} /* BEncUTCTime */ - -void BDecUTCTime PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -UTCTime *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))) - { - Asn1Error ("BDecUTCTime: ERROR - wrong tag\n"); - longjmp (env, 39); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecUTCTimeContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecUTCTime */ - -AsnLen BEncGeneralizedTime PARAMS ((b, v), -BUF_TYPE b _AND_ -GeneralizedTime *v) -{ - AsnLen l; - l = BEncGeneralizedTimeContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - return l; -} /* BEncGeneralizedTime */ - -void BDecGeneralizedTime PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GeneralizedTime *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - Asn1Error ("BDecGeneralizedTime: ERROR - wrong tag\n"); - longjmp (env, 38); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGeneralizedTimeContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGeneralizedTime */ - -AsnLen BEncUniversalString PARAMS ((b, v), -BUF_TYPE b _AND_ -UniversalString *v) -{ - AsnLen l; - l = BEncUniversalStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, UNIVERSALSTRING_TAG_CODE); - return l; -} /* BEncUniversalString */ - -void BDecUniversalString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -UniversalString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE))) - { - Asn1Error ("BDecUniversalString: ERROR - wrong tag\n"); - longjmp (env, 37); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecUniversalStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecUniversalString */ - -AsnLen BEncBMPString PARAMS ((b, v), -BUF_TYPE b _AND_ -BMPString *v) -{ - AsnLen l; - l = BEncBMPStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, BMPSTRING_TAG_CODE); - return l; -} /* BEncBMPString */ - -void BDecBMPString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -BMPString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE))) - { - Asn1Error ("BDecBMPString: ERROR - wrong tag\n"); - longjmp (env, 36); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecBMPStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecBMPString */ - -AsnLen -BEncEXTERNALChoiceContent PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNALChoice *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - BEncEocIfNec (b); - itemLen = BEncAsnOctsContent (b, (v->a.single_ASN1_type)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 4); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 0); - - totalLen += itemLen; - - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - itemLen = BEncAsnOctsContent (b, (v->a.octet_aligned)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - break; - - case EXTERNALCHOICE_ARBITRARY: - itemLen = BEncAsnBitsContent (b, (v->a.arbitrary)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncEXTERNALChoiceContent */ - -void -BDecEXTERNALChoiceContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -EXTERNALChoice *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - - - switch (tagId0) - { - case MAKE_TAG_ID (CNTX, CONS, 0): - tagId1 = BDecTag (b, &totalElmtsLen1, env); -if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) && - (tagId1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, 35); - } - - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->choiceId) = EXTERNALCHOICE_SINGLE_ASN1_TYPE; - (v->a.single_ASN1_type) = (AsnOcts*) Asn1Alloc (sizeof (AsnOcts)); - CheckAsn1Alloc ((v->a.single_ASN1_type), env); - BDecAsnOctsContent (b, tagId1, elmtLen1, (v->a.single_ASN1_type), &totalElmtsLen1, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 1): - case MAKE_TAG_ID (CNTX, CONS, 1): - (v->choiceId) = EXTERNALCHOICE_OCTET_ALIGNED; - (v->a.octet_aligned) = (AsnOcts*) Asn1Alloc (sizeof (AsnOcts)); - CheckAsn1Alloc ((v->a.octet_aligned), env); - BDecAsnOctsContent (b, tagId0, elmtLen0, (v->a.octet_aligned), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 2): - case MAKE_TAG_ID (CNTX, CONS, 2): - (v->choiceId) = EXTERNALCHOICE_ARBITRARY; - (v->a.arbitrary) = (AsnBits*) Asn1Alloc (sizeof (AsnBits)); - CheckAsn1Alloc ((v->a.arbitrary), env); - BDecAsnBitsContent (b, tagId0, elmtLen0, (v->a.arbitrary), &totalElmtsLen1, env); - break; - - default: - Asn1Error ("ERROR - unexpected tag in CHOICE\n"); - longjmp (env, 34); - break; - } /* end switch */ - (*bytesDecoded) += totalElmtsLen1; -} /* BDecEXTERNALChoiceContent */ - -void -PrintEXTERNALChoice PARAMS ((f, v, indent), -FILE* f _AND_ -EXTERNALChoice *v _AND_ -unsigned short int indent) -{ - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - fprintf (f,"single-ASN1-type "); - PrintAsnOcts (f, (v->a.single_ASN1_type), indent + stdIndentG); - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - fprintf (f,"octet-aligned "); - PrintAsnOcts (f, (v->a.octet_aligned), indent + stdIndentG); - break; - - case EXTERNALCHOICE_ARBITRARY: - fprintf (f,"arbitrary "); - PrintAsnBits (f, (v->a.arbitrary), indent + stdIndentG); - break; - - } -} /* PrintEXTERNALChoice */ - -void -FreeEXTERNALChoice PARAMS ((v), -EXTERNALChoice *v) -{ - - if (v == NULL) - return; - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - FreeAsnOcts ((v->a.single_ASN1_type)); - Asn1Free ((v->a.single_ASN1_type)); - - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - FreeAsnOcts ((v->a.octet_aligned)); - Asn1Free ((v->a.octet_aligned)); - - break; - - case EXTERNALCHOICE_ARBITRARY: - FreeAsnBits ((v->a.arbitrary)); - Asn1Free ((v->a.arbitrary)); - - break; - - } -} /* FreeEXTERNALChoice */ - - - - -AsnLen BEncEXTERNAL PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNAL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncEXTERNALContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, EXTERNAL_TAG_CODE); - return l; -} /* BEncEXTERNAL */ - -void BDecEXTERNAL PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -EXTERNAL *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, CONS, EXTERNAL_TAG_CODE))) - { - Asn1Error ("BDecEXTERNAL: ERROR - wrong tag\n"); - longjmp (env, 33); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecEXTERNALContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecEXTERNAL */ - -AsnLen -BEncEXTERNALContent PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNAL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncEXTERNALChoiceContent (b, (v->encoding)); - - totalLen += itemLen; - - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - itemLen = BEncObjectDescriptorContent (b, (&v->data_value_descriptor)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 7); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->indirect_reference))) - { - itemLen = BEncAsnIntContent (b, (v->indirect_reference)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - } - - if (ASNOID_PRESENT ((&v->direct_reference))) - { - itemLen = BEncAsnOidContent (b, (&v->direct_reference)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 6); - - totalLen += itemLen; - } - - return totalLen; - -} /* BEncEXTERNALContent */ - -void -BDecEXTERNALContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -EXTERNAL *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnOidContent (b, tagId1, elmtLen1, (&v->direct_reference), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->indirect_reference) = (AsnInt*) Asn1Alloc (sizeof (AsnInt)); - CheckAsn1Alloc ((v->indirect_reference), env); - BDecAsnIntContent (b, tagId1, elmtLen1, (v->indirect_reference), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) || -(tagId1 == MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecObjectDescriptorContent (b, tagId1, elmtLen1, (&v->data_value_descriptor), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)) || - (tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1))|| - (tagId1 == MAKE_TAG_ID (CNTX, CONS, 1)) || - (tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2))|| - (tagId1 == MAKE_TAG_ID (CNTX, CONS, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->encoding) = (EXTERNALChoice*) Asn1Alloc (sizeof (EXTERNALChoice)); - CheckAsn1Alloc ((v->encoding), env); - BDecEXTERNALChoiceContent (b, tagId1, elmtLen1, (v->encoding), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, 32); - } - else - longjmp (env, 31); - - - if (!seqDone) - longjmp (env, 30); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecEXTERNALContent */ - -void -PrintEXTERNAL PARAMS ((f, v, indent), -FILE* f _AND_ -EXTERNAL *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - if (ASNOID_PRESENT ((&v->direct_reference))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"direct-reference "); - PrintAsnOid (f, (&v->direct_reference), indent + stdIndentG); - fprintf (f, ",\n"); - } - if (NOT_NULL ((v->indirect_reference))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"indirect-reference "); - PrintAsnInt (f, (v->indirect_reference), indent + stdIndentG); - fprintf (f, ",\n"); - } - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"data-value-descriptor "); - PrintObjectDescriptor (f, (&v->data_value_descriptor), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"encoding "); - PrintEXTERNALChoice (f, (v->encoding), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintEXTERNAL */ - -void -FreeEXTERNAL PARAMS ((v), -EXTERNAL *v) -{ - - if (v == NULL) - return; - if (ASNOID_PRESENT ((&v->direct_reference))) - { - FreeAsnOid ((&v->direct_reference)); - } - - if (NOT_NULL ((v->indirect_reference))) - { - FreeAsnInt ((v->indirect_reference)); - Asn1Free ((v->indirect_reference)); - } - - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - FreeObjectDescriptor ((&v->data_value_descriptor)); - } - - FreeEXTERNALChoice ((v->encoding)); - Asn1Free ((v->encoding)); - -} /* FreeEXTERNAL */ - - - - diff --git a/SecuritySNACCRuntime/c-lib/asn-useful.h b/SecuritySNACCRuntime/c-lib/asn-useful.h deleted file mode 100644 index d11f83b0..00000000 --- a/SecuritySNACCRuntime/c-lib/asn-useful.h +++ /dev/null @@ -1,325 +0,0 @@ -/* - * asn-useful.h - * - * "ASN-USEFUL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Tue Mar 19 07:24:46 2002 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _asn_useful_h_ -#define _asn_useful_h_ - - - - -typedef AsnOcts ObjectDescriptor; /* [UNIVERSAL 7] IMPLICIT OCTET STRING */ - -#define BEncObjectDescriptorContent BEncAsnOctsContent - -#define BDecObjectDescriptorContent BDecAsnOctsContent - -#define PrintObjectDescriptor PrintAsnOcts - -#define FreeObjectDescriptor FreeAsnOcts - - - - -typedef AsnOcts UTF8String; /* [UNIVERSAL 12] IMPLICIT OCTET STRING */ - -AsnLen BEncUTF8String PROTO ((BUF_TYPE b, UTF8String *v)); - -void BDecUTF8String PROTO ((BUF_TYPE b, UTF8String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncUTF8StringContent BEncAsnOctsContent - -#define BDecUTF8StringContent BDecAsnOctsContent - -#define PrintUTF8String PrintAsnOcts - -#define FreeUTF8String FreeAsnOcts - - - - -typedef AsnOcts NumericString; /* [UNIVERSAL 18] IMPLICIT OCTET STRING */ - -AsnLen BEncNumericString PROTO ((BUF_TYPE b, NumericString *v)); - -void BDecNumericString PROTO ((BUF_TYPE b, NumericString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncNumericStringContent BEncAsnOctsContent - -#define BDecNumericStringContent BDecAsnOctsContent - -#define PrintNumericString PrintAsnOcts - -#define FreeNumericString FreeAsnOcts - - - - -typedef AsnOcts PrintableString; /* [UNIVERSAL 19] IMPLICIT OCTET STRING */ - -AsnLen BEncPrintableString PROTO ((BUF_TYPE b, PrintableString *v)); - -void BDecPrintableString PROTO ((BUF_TYPE b, PrintableString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncPrintableStringContent BEncAsnOctsContent - -#define BDecPrintableStringContent BDecAsnOctsContent - -#define PrintPrintableString PrintAsnOcts - -#define FreePrintableString FreeAsnOcts - - - - -typedef AsnOcts TeletexString; /* [UNIVERSAL 20] IMPLICIT OCTET STRING */ - -AsnLen BEncTeletexString PROTO ((BUF_TYPE b, TeletexString *v)); - -void BDecTeletexString PROTO ((BUF_TYPE b, TeletexString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncTeletexStringContent BEncAsnOctsContent - -#define BDecTeletexStringContent BDecAsnOctsContent - -#define PrintTeletexString PrintAsnOcts - -#define FreeTeletexString FreeAsnOcts - - - - -typedef AsnOcts T61String; /* [UNIVERSAL 20] IMPLICIT OCTET STRING */ - -AsnLen BEncT61String PROTO ((BUF_TYPE b, T61String *v)); - -void BDecT61String PROTO ((BUF_TYPE b, T61String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncT61StringContent BEncAsnOctsContent - -#define BDecT61StringContent BDecAsnOctsContent - -#define PrintT61String PrintAsnOcts - -#define FreeT61String FreeAsnOcts - - - - -typedef AsnOcts VideotexString; /* [UNIVERSAL 21] IMPLICIT OCTET STRING */ - -AsnLen BEncVideotexString PROTO ((BUF_TYPE b, VideotexString *v)); - -void BDecVideotexString PROTO ((BUF_TYPE b, VideotexString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncVideotexStringContent BEncAsnOctsContent - -#define BDecVideotexStringContent BDecAsnOctsContent - -#define PrintVideotexString PrintAsnOcts - -#define FreeVideotexString FreeAsnOcts - - - - -typedef AsnOcts IA5String; /* [UNIVERSAL 22] IMPLICIT OCTET STRING */ - -AsnLen BEncIA5String PROTO ((BUF_TYPE b, IA5String *v)); - -void BDecIA5String PROTO ((BUF_TYPE b, IA5String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncIA5StringContent BEncAsnOctsContent - -#define BDecIA5StringContent BDecAsnOctsContent - -#define PrintIA5String PrintAsnOcts - -#define FreeIA5String FreeAsnOcts - - - - -typedef AsnOcts GraphicString; /* [UNIVERSAL 25] IMPLICIT OCTET STRING */ - -AsnLen BEncGraphicString PROTO ((BUF_TYPE b, GraphicString *v)); - -void BDecGraphicString PROTO ((BUF_TYPE b, GraphicString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGraphicStringContent BEncAsnOctsContent - -#define BDecGraphicStringContent BDecAsnOctsContent - -#define PrintGraphicString PrintAsnOcts - -#define FreeGraphicString FreeAsnOcts - - - - -typedef AsnOcts VisibleString; /* [UNIVERSAL 26] IMPLICIT OCTET STRING */ - -AsnLen BEncVisibleString PROTO ((BUF_TYPE b, VisibleString *v)); - -void BDecVisibleString PROTO ((BUF_TYPE b, VisibleString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncVisibleStringContent BEncAsnOctsContent - -#define BDecVisibleStringContent BDecAsnOctsContent - -#define PrintVisibleString PrintAsnOcts - -#define FreeVisibleString FreeAsnOcts - - - - -typedef AsnOcts ISO646String; /* [UNIVERSAL 26] IMPLICIT OCTET STRING */ - -AsnLen BEncISO646String PROTO ((BUF_TYPE b, ISO646String *v)); - -void BDecISO646String PROTO ((BUF_TYPE b, ISO646String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncISO646StringContent BEncAsnOctsContent - -#define BDecISO646StringContent BDecAsnOctsContent - -#define PrintISO646String PrintAsnOcts - -#define FreeISO646String FreeAsnOcts - - - - -typedef AsnOcts GeneralString; /* [UNIVERSAL 27] IMPLICIT OCTET STRING */ - -AsnLen BEncGeneralString PROTO ((BUF_TYPE b, GeneralString *v)); - -void BDecGeneralString PROTO ((BUF_TYPE b, GeneralString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGeneralStringContent BEncAsnOctsContent - -#define BDecGeneralStringContent BDecAsnOctsContent - -#define PrintGeneralString PrintAsnOcts - -#define FreeGeneralString FreeAsnOcts - - - - -typedef AsnOcts UTCTime; /* [UNIVERSAL 23] IMPLICIT OCTET STRING */ - -AsnLen BEncUTCTime PROTO ((BUF_TYPE b, UTCTime *v)); - -void BDecUTCTime PROTO ((BUF_TYPE b, UTCTime *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncUTCTimeContent BEncAsnOctsContent - -#define BDecUTCTimeContent BDecAsnOctsContent - -#define PrintUTCTime PrintAsnOcts - -#define FreeUTCTime FreeAsnOcts - - - - -typedef AsnOcts GeneralizedTime; /* [UNIVERSAL 24] IMPLICIT OCTET STRING */ - -AsnLen BEncGeneralizedTime PROTO ((BUF_TYPE b, GeneralizedTime *v)); - -void BDecGeneralizedTime PROTO ((BUF_TYPE b, GeneralizedTime *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGeneralizedTimeContent BEncAsnOctsContent - -#define BDecGeneralizedTimeContent BDecAsnOctsContent - -#define PrintGeneralizedTime PrintAsnOcts - -#define FreeGeneralizedTime FreeAsnOcts - - - - -typedef AsnOcts UniversalString; /* [UNIVERSAL 28] IMPLICIT OCTET STRING */ - -AsnLen BEncUniversalString PROTO ((BUF_TYPE b, UniversalString *v)); - -void BDecUniversalString PROTO ((BUF_TYPE b, UniversalString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncUniversalStringContent BEncAsnOctsContent - -#define BDecUniversalStringContent BDecAsnOctsContent - -#define PrintUniversalString PrintAsnOcts - -#define FreeUniversalString FreeAsnOcts - - - - -typedef AsnOcts BMPString; /* [UNIVERSAL 30] IMPLICIT OCTET STRING */ - -AsnLen BEncBMPString PROTO ((BUF_TYPE b, BMPString *v)); - -void BDecBMPString PROTO ((BUF_TYPE b, BMPString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncBMPStringContent BEncAsnOctsContent - -#define BDecBMPStringContent BDecAsnOctsContent - -#define PrintBMPString PrintAsnOcts - -#define FreeBMPString FreeAsnOcts - - - - -typedef struct EXTERNALChoice /* CHOICE */ -{ - enum EXTERNALChoiceChoiceId - { - EXTERNALCHOICE_SINGLE_ASN1_TYPE, - EXTERNALCHOICE_OCTET_ALIGNED, - EXTERNALCHOICE_ARBITRARY - } choiceId; - union EXTERNALChoiceChoiceUnion - { - AsnOcts* single_ASN1_type; /* [0] OCTET STRING */ - AsnOcts* octet_aligned; /* [1] IMPLICIT OCTET STRING */ - AsnBits* arbitrary; /* [2] IMPLICIT BIT STRING */ - } a; -} EXTERNALChoice; - -AsnLen BEncEXTERNALChoiceContent PROTO ((BUF_TYPE b, EXTERNALChoice *v)); - -void BDecEXTERNALChoiceContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, EXTERNALChoice *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintEXTERNALChoice PROTO ((FILE* f, EXTERNALChoice *v, unsigned short int indent)); -void FreeEXTERNALChoice PROTO ((EXTERNALChoice *v)); - - - - - -typedef struct EXTERNAL /* [UNIVERSAL 8] IMPLICIT SEQUENCE */ -{ - AsnOid direct_reference; /* OBJECT IDENTIFIER OPTIONAL */ - AsnInt* indirect_reference; /* INTEGER OPTIONAL */ - ObjectDescriptor data_value_descriptor; /* ObjectDescriptor OPTIONAL */ - struct EXTERNALChoice* encoding; /* EXTERNALChoice */ -} EXTERNAL; - -AsnLen BEncEXTERNAL PROTO ((BUF_TYPE b, EXTERNAL *v)); - -void BDecEXTERNAL PROTO ((BUF_TYPE b, EXTERNAL *result, AsnLen *bytesDecoded, ENV_TYPE env)); -AsnLen BEncEXTERNALContent PROTO ((BUF_TYPE b, EXTERNAL *v)); - -void BDecEXTERNALContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, EXTERNAL *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintEXTERNAL PROTO ((FILE* f, EXTERNAL *v, unsigned short int indent)); -void FreeEXTERNAL PROTO ((EXTERNAL *v)); - - - - - - -#endif /* conditional include of asn-useful.h */ diff --git a/SecuritySNACCRuntime/c-lib/boot/asn-useful.c b/SecuritySNACCRuntime/c-lib/boot/asn-useful.c deleted file mode 100644 index 415b7009..00000000 --- a/SecuritySNACCRuntime/c-lib/boot/asn-useful.c +++ /dev/null @@ -1,799 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn-useful.c - * - * "ASN-USEFUL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Mon Mar 3 11:08:41 1997 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "asn-useful.h" - - -AsnLen BEncNumericString PARAMS ((b, v), -BUF_TYPE b _AND_ -NumericString *v) -{ - AsnLen l; - l = BEncNumericStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); - return l; -} /* BEncNumericString */ - -void BDecNumericString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -NumericString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE))) - { - Asn1Error ("BDecNumericString: ERROR - wrong tag\n"); - longjmp (env, 50); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecNumericStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecNumericString */ - -AsnLen BEncPrintableString PARAMS ((b, v), -BUF_TYPE b _AND_ -PrintableString *v) -{ - AsnLen l; - l = BEncPrintableStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - return l; -} /* BEncPrintableString */ - -void BDecPrintableString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -PrintableString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) - { - Asn1Error ("BDecPrintableString: ERROR - wrong tag\n"); - longjmp (env, 49); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecPrintableStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecPrintableString */ - -AsnLen BEncTeletexString PARAMS ((b, v), -BUF_TYPE b _AND_ -TeletexString *v) -{ - AsnLen l; - l = BEncTeletexStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} /* BEncTeletexString */ - -void BDecTeletexString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -TeletexString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecTeletexString: ERROR - wrong tag\n"); - longjmp (env, 48); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecTeletexStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecTeletexString */ - -AsnLen BEncT61String PARAMS ((b, v), -BUF_TYPE b _AND_ -T61String *v) -{ - AsnLen l; - l = BEncT61StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} /* BEncT61String */ - -void BDecT61String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -T61String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecT61String: ERROR - wrong tag\n"); - longjmp (env, 47); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecT61StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecT61String */ - -AsnLen BEncVideotexString PARAMS ((b, v), -BUF_TYPE b _AND_ -VideotexString *v) -{ - AsnLen l; - l = BEncVideotexStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE); - return l; -} /* BEncVideotexString */ - -void BDecVideotexString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -VideotexString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VIDEOTEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecVideotexString: ERROR - wrong tag\n"); - longjmp (env, 46); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecVideotexStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecVideotexString */ - -AsnLen BEncIA5String PARAMS ((b, v), -BUF_TYPE b _AND_ -IA5String *v) -{ - AsnLen l; - l = BEncIA5StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, IA5STRING_TAG_CODE); - return l; -} /* BEncIA5String */ - -void BDecIA5String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -IA5String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) - { - Asn1Error ("BDecIA5String: ERROR - wrong tag\n"); - longjmp (env, 45); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecIA5StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecIA5String */ - -AsnLen BEncGraphicString PARAMS ((b, v), -BUF_TYPE b _AND_ -GraphicString *v) -{ - AsnLen l; - l = BEncGraphicStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GRAPHICSTRING_TAG_CODE); - return l; -} /* BEncGraphicString */ - -void BDecGraphicString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GraphicString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GRAPHICSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GRAPHICSTRING_TAG_CODE))) - { - Asn1Error ("BDecGraphicString: ERROR - wrong tag\n"); - longjmp (env, 44); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGraphicStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGraphicString */ - -AsnLen BEncVisibleString PARAMS ((b, v), -BUF_TYPE b _AND_ -VisibleString *v) -{ - AsnLen l; - l = BEncVisibleStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} /* BEncVisibleString */ - -void BDecVisibleString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -VisibleString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error ("BDecVisibleString: ERROR - wrong tag\n"); - longjmp (env, 43); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecVisibleStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecVisibleString */ - -AsnLen BEncISO646String PARAMS ((b, v), -BUF_TYPE b _AND_ -ISO646String *v) -{ - AsnLen l; - l = BEncISO646StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} /* BEncISO646String */ - -void BDecISO646String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -ISO646String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error ("BDecISO646String: ERROR - wrong tag\n"); - longjmp (env, 42); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecISO646StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecISO646String */ - -AsnLen BEncGeneralString PARAMS ((b, v), -BUF_TYPE b _AND_ -GeneralString *v) -{ - AsnLen l; - l = BEncGeneralStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GENERALSTRING_TAG_CODE); - return l; -} /* BEncGeneralString */ - -void BDecGeneralString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GeneralString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GENERALSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GENERALSTRING_TAG_CODE))) - { - Asn1Error ("BDecGeneralString: ERROR - wrong tag\n"); - longjmp (env, 41); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGeneralStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGeneralString */ - -AsnLen BEncUTCTime PARAMS ((b, v), -BUF_TYPE b _AND_ -UTCTime *v) -{ - AsnLen l; - l = BEncUTCTimeContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE); - return l; -} /* BEncUTCTime */ - -void BDecUTCTime PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -UTCTime *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))) - { - Asn1Error ("BDecUTCTime: ERROR - wrong tag\n"); - longjmp (env, 40); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecUTCTimeContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecUTCTime */ - -AsnLen BEncGeneralizedTime PARAMS ((b, v), -BUF_TYPE b _AND_ -GeneralizedTime *v) -{ - AsnLen l; - l = BEncGeneralizedTimeContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - return l; -} /* BEncGeneralizedTime */ - -void BDecGeneralizedTime PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GeneralizedTime *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - Asn1Error ("BDecGeneralizedTime: ERROR - wrong tag\n"); - longjmp (env, 39); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGeneralizedTimeContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGeneralizedTime */ - -AsnLen -BEncEXTERNALChoiceContent PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNALChoice *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - BEncEocIfNec (b); - itemLen = BEncAsnOctsContent (b, (v->a.single_ASN1_type)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 4); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 0); - - totalLen += itemLen; - - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - itemLen = BEncAsnOctsContent (b, (v->a.octet_aligned)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - break; - - case EXTERNALCHOICE_ARBITRARY: - itemLen = BEncAsnBitsContent (b, (v->a.arbitrary)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncEXTERNALChoiceContent */ - -void -BDecEXTERNALChoiceContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -EXTERNALChoice *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - - - switch (tagId0) - { - case MAKE_TAG_ID (CNTX, CONS, 0): - tagId1 = BDecTag (b, &totalElmtsLen1, env); -if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) && - (tagId1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, 38); - } - - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->choiceId) = EXTERNALCHOICE_SINGLE_ASN1_TYPE; - (v->a.single_ASN1_type) = (AsnOcts*) Asn1Alloc (sizeof (AsnOcts)); - CheckAsn1Alloc ((v->a.single_ASN1_type), env); - BDecAsnOctsContent (b, tagId1, elmtLen1, (v->a.single_ASN1_type), &totalElmtsLen1, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 1): - case MAKE_TAG_ID (CNTX, CONS, 1): - (v->choiceId) = EXTERNALCHOICE_OCTET_ALIGNED; - (v->a.octet_aligned) = (AsnOcts*) Asn1Alloc (sizeof (AsnOcts)); - CheckAsn1Alloc ((v->a.octet_aligned), env); - BDecAsnOctsContent (b, tagId0, elmtLen0, (v->a.octet_aligned), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 2): - case MAKE_TAG_ID (CNTX, CONS, 2): - (v->choiceId) = EXTERNALCHOICE_ARBITRARY; - (v->a.arbitrary) = (AsnBits*) Asn1Alloc (sizeof (AsnBits)); - CheckAsn1Alloc ((v->a.arbitrary), env); - BDecAsnBitsContent (b, tagId0, elmtLen0, (v->a.arbitrary), &totalElmtsLen1, env); - break; - - default: - Asn1Error ("ERROR - unexpected tag in CHOICE\n"); - longjmp (env, 37); - break; - } /* end switch */ - (*bytesDecoded) += totalElmtsLen1; -} /* BDecEXTERNALChoiceContent */ - -void -PrintEXTERNALChoice PARAMS ((f, v, indent), -FILE* f _AND_ -EXTERNALChoice *v _AND_ -unsigned short int indent) -{ - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - fprintf (f,"single-ASN1-type "); - PrintAsnOcts (f, (v->a.single_ASN1_type), indent + stdIndentG); - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - fprintf (f,"octet-aligned "); - PrintAsnOcts (f, (v->a.octet_aligned), indent + stdIndentG); - break; - - case EXTERNALCHOICE_ARBITRARY: - fprintf (f,"arbitrary "); - PrintAsnBits (f, (v->a.arbitrary), indent + stdIndentG); - break; - - } -} /* PrintEXTERNALChoice */ - -void -FreeEXTERNALChoice PARAMS ((v), -EXTERNALChoice *v) -{ - - if (v == NULL) - return; - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - FreeAsnOcts ((v->a.single_ASN1_type)); - Asn1Free ((v->a.single_ASN1_type)); - - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - FreeAsnOcts ((v->a.octet_aligned)); - Asn1Free ((v->a.octet_aligned)); - - break; - - case EXTERNALCHOICE_ARBITRARY: - FreeAsnBits ((v->a.arbitrary)); - Asn1Free ((v->a.arbitrary)); - - break; - - } -} /* FreeEXTERNALChoice */ - - - - -AsnLen BEncEXTERNAL PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNAL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncEXTERNALContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, EXTERNAL_TAG_CODE); - return l; -} /* BEncEXTERNAL */ - -void BDecEXTERNAL PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -EXTERNAL *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, CONS, EXTERNAL_TAG_CODE))) - { - Asn1Error ("BDecEXTERNAL: ERROR - wrong tag\n"); - longjmp (env, 36); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecEXTERNALContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecEXTERNAL */ - -AsnLen -BEncEXTERNALContent PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNAL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncEXTERNALChoiceContent (b, (v->encoding)); - - totalLen += itemLen; - - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - itemLen = BEncObjectDescriptorContent (b, (&v->data_value_descriptor)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 7); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->indirect_reference))) - { - itemLen = BEncAsnIntContent (b, (v->indirect_reference)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - } - - if (ASNOID_PRESENT ((&v->direct_reference))) - { - itemLen = BEncAsnOidContent (b, (&v->direct_reference)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 6); - - totalLen += itemLen; - } - - return totalLen; - -} /* BEncEXTERNALContent */ - -void -BDecEXTERNALContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -EXTERNAL *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnOidContent (b, tagId1, elmtLen1, (&v->direct_reference), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->indirect_reference) = (AsnInt*) Asn1Alloc (sizeof (AsnInt)); - CheckAsn1Alloc ((v->indirect_reference), env); - BDecAsnIntContent (b, tagId1, elmtLen1, (v->indirect_reference), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) || -(tagId1 == MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecObjectDescriptorContent (b, tagId1, elmtLen1, (&v->data_value_descriptor), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)) || - (tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1))|| - (tagId1 == MAKE_TAG_ID (CNTX, CONS, 1)) || - (tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2))|| - (tagId1 == MAKE_TAG_ID (CNTX, CONS, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->encoding) = (EXTERNALChoice*) Asn1Alloc (sizeof (EXTERNALChoice)); - CheckAsn1Alloc ((v->encoding), env); - BDecEXTERNALChoiceContent (b, tagId1, elmtLen1, (v->encoding), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, 35); - } - else - longjmp (env, 34); - - - if (!seqDone) - longjmp (env, 33); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecEXTERNALContent */ - -void -PrintEXTERNAL PARAMS ((f, v, indent), -FILE* f _AND_ -EXTERNAL *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - if (ASNOID_PRESENT ((&v->direct_reference))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"direct-reference "); - PrintAsnOid (f, (&v->direct_reference), indent + stdIndentG); - fprintf (f, ",\n"); - } - if (NOT_NULL ((v->indirect_reference))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"indirect-reference "); - PrintAsnInt (f, (v->indirect_reference), indent + stdIndentG); - fprintf (f, ",\n"); - } - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"data-value-descriptor "); - PrintObjectDescriptor (f, (&v->data_value_descriptor), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"encoding "); - PrintEXTERNALChoice (f, (v->encoding), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintEXTERNAL */ - -void -FreeEXTERNAL PARAMS ((v), -EXTERNAL *v) -{ - - if (v == NULL) - return; - if (ASNOID_PRESENT ((&v->direct_reference))) - { - FreeAsnOid ((&v->direct_reference)); - } - - if (NOT_NULL ((v->indirect_reference))) - { - FreeAsnInt ((v->indirect_reference)); - Asn1Free ((v->indirect_reference)); - } - - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - FreeObjectDescriptor ((&v->data_value_descriptor)); - } - - FreeEXTERNALChoice ((v->encoding)); - Asn1Free ((v->encoding)); - -} /* FreeEXTERNAL */ - - - - diff --git a/SecuritySNACCRuntime/c-lib/boot/asn-useful.h b/SecuritySNACCRuntime/c-lib/boot/asn-useful.h deleted file mode 100644 index bc7502ac..00000000 --- a/SecuritySNACCRuntime/c-lib/boot/asn-useful.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn-useful.h - * - * "ASN-USEFUL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Mon Mar 3 11:08:41 1997 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _asn_useful_h_ -#define _asn_useful_h_ - - - - -typedef AsnOcts ObjectDescriptor; /* [UNIVERSAL 7] IMPLICIT OCTET STRING */ - -#define BEncObjectDescriptorContent BEncAsnOctsContent - -#define BDecObjectDescriptorContent BDecAsnOctsContent - -#define PrintObjectDescriptor PrintAsnOcts - -#define FreeObjectDescriptor FreeAsnOcts - - - - -typedef AsnOcts NumericString; /* [UNIVERSAL 18] IMPLICIT OCTET STRING */ - -AsnLen BEncNumericString PROTO ((BUF_TYPE b, NumericString *v)); - -void BDecNumericString PROTO ((BUF_TYPE b, NumericString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncNumericStringContent BEncAsnOctsContent - -#define BDecNumericStringContent BDecAsnOctsContent - -#define PrintNumericString PrintAsnOcts - -#define FreeNumericString FreeAsnOcts - - - - -typedef AsnOcts PrintableString; /* [UNIVERSAL 19] IMPLICIT OCTET STRING */ - -AsnLen BEncPrintableString PROTO ((BUF_TYPE b, PrintableString *v)); - -void BDecPrintableString PROTO ((BUF_TYPE b, PrintableString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncPrintableStringContent BEncAsnOctsContent - -#define BDecPrintableStringContent BDecAsnOctsContent - -#define PrintPrintableString PrintAsnOcts - -#define FreePrintableString FreeAsnOcts - - - - -typedef AsnOcts TeletexString; /* [UNIVERSAL 20] IMPLICIT OCTET STRING */ - -AsnLen BEncTeletexString PROTO ((BUF_TYPE b, TeletexString *v)); - -void BDecTeletexString PROTO ((BUF_TYPE b, TeletexString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncTeletexStringContent BEncAsnOctsContent - -#define BDecTeletexStringContent BDecAsnOctsContent - -#define PrintTeletexString PrintAsnOcts - -#define FreeTeletexString FreeAsnOcts - - - - -typedef AsnOcts T61String; /* [UNIVERSAL 20] IMPLICIT OCTET STRING */ - -AsnLen BEncT61String PROTO ((BUF_TYPE b, T61String *v)); - -void BDecT61String PROTO ((BUF_TYPE b, T61String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncT61StringContent BEncAsnOctsContent - -#define BDecT61StringContent BDecAsnOctsContent - -#define PrintT61String PrintAsnOcts - -#define FreeT61String FreeAsnOcts - - - - -typedef AsnOcts VideotexString; /* [UNIVERSAL 21] IMPLICIT OCTET STRING */ - -AsnLen BEncVideotexString PROTO ((BUF_TYPE b, VideotexString *v)); - -void BDecVideotexString PROTO ((BUF_TYPE b, VideotexString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncVideotexStringContent BEncAsnOctsContent - -#define BDecVideotexStringContent BDecAsnOctsContent - -#define PrintVideotexString PrintAsnOcts - -#define FreeVideotexString FreeAsnOcts - - - - -typedef AsnOcts IA5String; /* [UNIVERSAL 22] IMPLICIT OCTET STRING */ - -AsnLen BEncIA5String PROTO ((BUF_TYPE b, IA5String *v)); - -void BDecIA5String PROTO ((BUF_TYPE b, IA5String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncIA5StringContent BEncAsnOctsContent - -#define BDecIA5StringContent BDecAsnOctsContent - -#define PrintIA5String PrintAsnOcts - -#define FreeIA5String FreeAsnOcts - - - - -typedef AsnOcts GraphicString; /* [UNIVERSAL 25] IMPLICIT OCTET STRING */ - -AsnLen BEncGraphicString PROTO ((BUF_TYPE b, GraphicString *v)); - -void BDecGraphicString PROTO ((BUF_TYPE b, GraphicString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGraphicStringContent BEncAsnOctsContent - -#define BDecGraphicStringContent BDecAsnOctsContent - -#define PrintGraphicString PrintAsnOcts - -#define FreeGraphicString FreeAsnOcts - - - - -typedef AsnOcts VisibleString; /* [UNIVERSAL 26] IMPLICIT OCTET STRING */ - -AsnLen BEncVisibleString PROTO ((BUF_TYPE b, VisibleString *v)); - -void BDecVisibleString PROTO ((BUF_TYPE b, VisibleString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncVisibleStringContent BEncAsnOctsContent - -#define BDecVisibleStringContent BDecAsnOctsContent - -#define PrintVisibleString PrintAsnOcts - -#define FreeVisibleString FreeAsnOcts - - - - -typedef AsnOcts ISO646String; /* [UNIVERSAL 26] IMPLICIT OCTET STRING */ - -AsnLen BEncISO646String PROTO ((BUF_TYPE b, ISO646String *v)); - -void BDecISO646String PROTO ((BUF_TYPE b, ISO646String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncISO646StringContent BEncAsnOctsContent - -#define BDecISO646StringContent BDecAsnOctsContent - -#define PrintISO646String PrintAsnOcts - -#define FreeISO646String FreeAsnOcts - - - - -typedef AsnOcts GeneralString; /* [UNIVERSAL 27] IMPLICIT OCTET STRING */ - -AsnLen BEncGeneralString PROTO ((BUF_TYPE b, GeneralString *v)); - -void BDecGeneralString PROTO ((BUF_TYPE b, GeneralString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGeneralStringContent BEncAsnOctsContent - -#define BDecGeneralStringContent BDecAsnOctsContent - -#define PrintGeneralString PrintAsnOcts - -#define FreeGeneralString FreeAsnOcts - - - - -typedef AsnOcts UTCTime; /* [UNIVERSAL 23] IMPLICIT OCTET STRING */ - -AsnLen BEncUTCTime PROTO ((BUF_TYPE b, UTCTime *v)); - -void BDecUTCTime PROTO ((BUF_TYPE b, UTCTime *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncUTCTimeContent BEncAsnOctsContent - -#define BDecUTCTimeContent BDecAsnOctsContent - -#define PrintUTCTime PrintAsnOcts - -#define FreeUTCTime FreeAsnOcts - - - - -typedef AsnOcts GeneralizedTime; /* [UNIVERSAL 24] IMPLICIT OCTET STRING */ - -AsnLen BEncGeneralizedTime PROTO ((BUF_TYPE b, GeneralizedTime *v)); - -void BDecGeneralizedTime PROTO ((BUF_TYPE b, GeneralizedTime *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGeneralizedTimeContent BEncAsnOctsContent - -#define BDecGeneralizedTimeContent BDecAsnOctsContent - -#define PrintGeneralizedTime PrintAsnOcts - -#define FreeGeneralizedTime FreeAsnOcts - - - - -typedef struct EXTERNALChoice /* CHOICE */ -{ - enum EXTERNALChoiceChoiceId - { - EXTERNALCHOICE_SINGLE_ASN1_TYPE, - EXTERNALCHOICE_OCTET_ALIGNED, - EXTERNALCHOICE_ARBITRARY - } choiceId; - union EXTERNALChoiceChoiceUnion - { - AsnOcts* single_ASN1_type; /* [0] OCTET STRING */ - AsnOcts* octet_aligned; /* [1] IMPLICIT OCTET STRING */ - AsnBits* arbitrary; /* [2] IMPLICIT BIT STRING */ - } a; -} EXTERNALChoice; - -AsnLen BEncEXTERNALChoiceContent PROTO ((BUF_TYPE b, EXTERNALChoice *v)); - -void BDecEXTERNALChoiceContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, EXTERNALChoice *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintEXTERNALChoice PROTO ((FILE* f, EXTERNALChoice *v, unsigned short int indent)); -void FreeEXTERNALChoice PROTO ((EXTERNALChoice *v)); - - - - - -typedef struct EXTERNAL /* [UNIVERSAL 8] IMPLICIT SEQUENCE */ -{ - AsnOid direct_reference; /* OBJECT IDENTIFIER OPTIONAL */ - AsnInt* indirect_reference; /* INTEGER OPTIONAL */ - ObjectDescriptor data_value_descriptor; /* ObjectDescriptor OPTIONAL */ - struct EXTERNALChoice* encoding; /* EXTERNALChoice */ -} EXTERNAL; - -AsnLen BEncEXTERNAL PROTO ((BUF_TYPE b, EXTERNAL *v)); - -void BDecEXTERNAL PROTO ((BUF_TYPE b, EXTERNAL *result, AsnLen *bytesDecoded, ENV_TYPE env)); -AsnLen BEncEXTERNALContent PROTO ((BUF_TYPE b, EXTERNAL *v)); - -void BDecEXTERNALContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, EXTERNAL *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintEXTERNAL PROTO ((FILE* f, EXTERNAL *v, unsigned short int indent)); -void FreeEXTERNAL PROTO ((EXTERNAL *v)); - - - - - - -#endif /* conditional include of asn-useful.h */ diff --git a/SecuritySNACCRuntime/c-lib/boot/tbl.c b/SecuritySNACCRuntime/c-lib/boot/tbl.c deleted file mode 100644 index f37ac7d0..00000000 --- a/SecuritySNACCRuntime/c-lib/boot/tbl.c +++ /dev/null @@ -1,2137 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#if TTBL -/* - * tbl.c - * - * "TBL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Mon Jun 2 11:23:56 1997 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "tbl.h" - - -AsnLen -BEncTBLRangeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLRange *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->to)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->from)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLRangeContent */ - -void -BDecTBLRangeContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLRange *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->from), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -100); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->to), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -101); - } - else - longjmp (env, -102); - - - if (!seqDone) - longjmp (env, -103); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLRangeContent */ - -void -PrintTBLRange PARAMS ((f, v, indent), -FILE* f _AND_ -TBLRange *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"from "); - PrintAsnInt (f, (&v->from), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"to "); - PrintAsnInt (f, (&v->to), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLRange */ - -void -FreeTBLRange PARAMS ((v), -TBLRange *v) -{ - - if (v == NULL) - return; - FreeAsnInt ((&v->from)); - - FreeAsnInt ((&v->to)); - -} /* FreeTBLRange */ - - - - -AsnLen -BEncTBLNamedNumberContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumber *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->value)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLNamedNumberContent */ - -void -BDecTBLNamedNumberContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLNamedNumber *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->name), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -104); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->value), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -105); - } - else - longjmp (env, -106); - - - if (!seqDone) - longjmp (env, -107); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLNamedNumberContent */ - -void -PrintTBLNamedNumber PARAMS ((f, v, indent), -FILE* f _AND_ -TBLNamedNumber *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"name "); - PrintPrintableString (f, (&v->name), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"value "); - PrintAsnInt (f, (&v->value), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLNamedNumber */ - -void -FreeTBLNamedNumber PARAMS ((v), -TBLNamedNumber *v) -{ - - if (v == NULL) - return; - FreePrintableString ((&v->name)); - - FreeAsnInt ((&v->value)); - -} /* FreeTBLNamedNumber */ - - - - -AsnLen -BEncTBLNamedNumberListContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumberList *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLNamedNumberListContent */ - -void -BDecTBLNamedNumberListContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLNamedNumberList *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLNamedNumber **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLNamedNumber**) AsnListAppend (v); - (*tmpVar) = (TBLNamedNumber*) Asn1Alloc (sizeof (TBLNamedNumber)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLNamedNumberContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -108); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLNamedNumberListContent */ - -void -PrintTBLNamedNumberList PARAMS ((f, v, indent), -FILE* f _AND_ -TBLNamedNumberList *v _AND_ -unsigned short int indent) -{ - TBLNamedNumber *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLNamedNumber (f, tmp, indent + stdIndentG); - if (tmp != (TBLNamedNumber*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLNamedNumberList */ - -void -FreeTBLNamedNumberList PARAMS ((v), -TBLNamedNumberList *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLNamedNumber ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLNamedNumberList */ - - - - -AsnLen -BEncTBLTypeRefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeRef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnBoolContent (b, (&v->implicit)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDef)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeRefContent */ - -void -BDecTBLTypeRefContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeRef *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeDefIdContent (b, tagId1, elmtLen1, (&v->typeDef), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -109); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->implicit), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -110); - } - else - longjmp (env, -111); - - - if (!seqDone) - longjmp (env, -112); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeRefContent */ - -void -PrintTBLTypeRef PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeRef *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeDef "); - PrintTBLTypeDefId (f, (&v->typeDef), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"implicit "); - PrintAsnBool (f, (&v->implicit), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeRef */ - -void -FreeTBLTypeRef PARAMS ((v), -TBLTypeRef *v) -{ - - if (v == NULL) - return; - FreeTBLTypeDefId ((&v->typeDef)); - - FreeAsnBool ((&v->implicit)); - -} /* FreeTBLTypeRef */ - - - - -AsnLen -BEncTBLTagContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTag *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->code)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncTBLTagClassContent (b, (&v->tclass)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 10); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTagContent */ - -void -BDecTBLTagContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTag *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, ENUM_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTagClassContent (b, tagId1, elmtLen1, (&v->tclass), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -113); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->code), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -114); - } - else - longjmp (env, -115); - - - if (!seqDone) - longjmp (env, -116); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTagContent */ - -void -PrintTBLTag PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTag *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"tclass "); - PrintTBLTagClass (f, (&v->tclass), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"code "); - PrintAsnInt (f, (&v->code), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTag */ - -void -FreeTBLTag PARAMS ((v), -TBLTag *v) -{ - - if (v == NULL) - return; - FreeTBLTagClass ((&v->tclass)); - - FreeAsnInt ((&v->code)); - -} /* FreeTBLTag */ - - - - -AsnLen -BEncTBLTypeSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTagContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeSeqOfContent */ - -void -BDecTBLTypeSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLTag **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLTag**) AsnListAppend (v); - (*tmpVar) = (TBLTag*) Asn1Alloc (sizeof (TBLTag)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTagContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -117); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeSeqOfContent */ - -void -PrintTBLTypeSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeSeqOf *v _AND_ -unsigned short int indent) -{ - TBLTag *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLTag (f, tmp, indent + stdIndentG); - if (tmp != (TBLTag*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeSeqOf */ - -void -FreeTBLTypeSeqOf PARAMS ((v), -TBLTypeSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLTag ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLTypeSeqOf */ - - - - -AsnLen -BEncTBLTypeContentSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContentSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeContentSeqOfContent */ - -void -BDecTBLTypeContentSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeContentSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLType **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLType**) AsnListAppend (v); - (*tmpVar) = (TBLType*) Asn1Alloc (sizeof (TBLType)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTypeContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -118); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContentSeqOfContent */ - -void -PrintTBLTypeContentSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeContentSeqOf *v _AND_ -unsigned short int indent) -{ - TBLType *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLType (f, tmp, indent + stdIndentG); - if (tmp != (TBLType*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeContentSeqOf */ - -void -FreeTBLTypeContentSeqOf PARAMS ((v), -TBLTypeContentSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLType ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLTypeContentSeqOf */ - - - - -AsnLen -BEncTBLTypeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLType *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->values))) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberListContent (b, (v->values)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 6); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->constraint))) - { - BEncEocIfNec (b); - itemLen = BEncTBLRangeContent (b, (v->constraint)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 5); - - totalLen += itemLen; - } - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - itemLen = BEncPrintableStringContent (b, (&v->fieldName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 4); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentContent (b, (v->content)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - if (NOT_NULL ((v->tagList))) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeSeqOfContent (b, (v->tagList)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - } - - itemLen = BEncAsnBoolContent (b, (&v->optional)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeIdContent (b, (&v->typeId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeContent */ - -void -BDecTBLTypeContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLType *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - AsnLen totalElmtsLen3 = 0; - AsnLen elmtLen3; - AsnTag tagId3; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeIdContent (b, tagId1, elmtLen1, (&v->typeId), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -119); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->optional), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -120); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->tagList) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->tagList), env); - BDecTBLTypeSeqOfContent (b, tagId1, elmtLen1, (v->tagList), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->content) = (TBLTypeContent*) Asn1Alloc (sizeof (TBLTypeContent)); - CheckAsn1Alloc ((v->content), env); - tagId2 = BDecTag (b, &totalElmtsLen1, env); - elmtLen2 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeContentContent (b, tagId2, elmtLen2, (v->content), &totalElmtsLen1, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc(b, &totalElmtsLen1, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - else - longjmp (env, -121); - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 4)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 4)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->fieldName), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 5)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->constraint) = (TBLRange*) Asn1Alloc (sizeof (TBLRange)); - CheckAsn1Alloc ((v->constraint), env); - BDecTBLRangeContent (b, tagId1, elmtLen1, (v->constraint), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 6)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->values) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->values), env); - BDecTBLNamedNumberListContent (b, tagId1, elmtLen1, (v->values), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -122); - } - - - if (!seqDone) - longjmp (env, -123); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContent */ - -void -PrintTBLType PARAMS ((f, v, indent), -FILE* f _AND_ -TBLType *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeId "); - PrintTBLTypeId (f, (&v->typeId), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"optional "); - PrintAsnBool (f, (&v->optional), indent + stdIndentG); - fprintf (f, ",\n"); - if (NOT_NULL ((v->tagList))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"tagList "); - PrintTBLTypeSeqOf (f, (v->tagList), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"content "); - PrintTBLTypeContent (f, (v->content), indent + stdIndentG); - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"fieldName "); - PrintPrintableString (f, (&v->fieldName), indent + stdIndentG); - } - if (NOT_NULL ((v->constraint))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"constraint "); - PrintTBLRange (f, (v->constraint), indent + stdIndentG); - } - if (NOT_NULL ((v->values))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"values "); - PrintTBLNamedNumberList (f, (v->values), indent + stdIndentG); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLType */ - -void -FreeTBLType PARAMS ((v), -TBLType *v) -{ - - if (v == NULL) - return; - FreeTBLTypeId ((&v->typeId)); - - FreeAsnBool ((&v->optional)); - - if (NOT_NULL ((v->tagList))) - { - FreeTBLTypeSeqOf ((v->tagList)); - Asn1Free ((v->tagList)); - } - - FreeTBLTypeContent ((v->content)); - Asn1Free ((v->content)); - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - FreePrintableString ((&v->fieldName)); - } - - if (NOT_NULL ((v->constraint))) - { - FreeTBLRange ((v->constraint)); - Asn1Free ((v->constraint)); - } - - if (NOT_NULL ((v->values))) - { - FreeTBLNamedNumberList ((v->values)); - Asn1Free ((v->values)); - } - -} /* FreeTBLType */ - - - - -AsnLen -BEncTBLTypeContentContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContent *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - itemLen = BEncAsnNullContent (b, (&v->a.primType)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_ELMTS: - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentSeqOfContent (b, (v->a.elmts)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 1); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_TYPEREF: - BEncEocIfNec (b); - itemLen = BEncTBLTypeRefContent (b, (v->a.typeRef)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncTBLTypeContentContent */ - -void -BDecTBLTypeContentContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeContent *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - switch (tagId0) - { - case MAKE_TAG_ID (CNTX, PRIM, 0): - (v->choiceId) = TBLTYPECONTENT_PRIMTYPE; - BDecAsnNullContent (b, tagId0, elmtLen0, (&v->a.primType), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - (v->choiceId) = TBLTYPECONTENT_ELMTS; - (v->a.elmts) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->a.elmts), env); - BDecTBLTypeContentSeqOfContent (b, tagId0, elmtLen0, (v->a.elmts), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 2): - (v->choiceId) = TBLTYPECONTENT_TYPEREF; - (v->a.typeRef) = (TBLTypeRef*) Asn1Alloc (sizeof (TBLTypeRef)); - CheckAsn1Alloc ((v->a.typeRef), env); - BDecTBLTypeRefContent (b, tagId0, elmtLen0, (v->a.typeRef), &totalElmtsLen1, env); - break; - - default: - Asn1Error ("ERROR - unexpected tag in CHOICE\n"); - longjmp (env, -124); - break; - } /* end switch */ - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContentContent */ - -void -PrintTBLTypeContent PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeContent *v _AND_ -unsigned short int indent) -{ - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - fprintf (f,"primType "); - PrintAsnNull (f, (&v->a.primType), indent + stdIndentG); - break; - - case TBLTYPECONTENT_ELMTS: - fprintf (f,"elmts "); - PrintTBLTypeContentSeqOf (f, (v->a.elmts), indent + stdIndentG); - break; - - case TBLTYPECONTENT_TYPEREF: - fprintf (f,"typeRef "); - PrintTBLTypeRef (f, (v->a.typeRef), indent + stdIndentG); - break; - - } -} /* PrintTBLTypeContent */ - -void -FreeTBLTypeContent PARAMS ((v), -TBLTypeContent *v) -{ - - if (v == NULL) - return; - switch (v->choiceId) - { - case TBLTYPECONTENT_ELMTS: - FreeTBLTypeContentSeqOf ((v->a.elmts)); - Asn1Free ((v->a.elmts)); - - break; - - case TBLTYPECONTENT_TYPEREF: - FreeTBLTypeRef ((v->a.typeRef)); - Asn1Free ((v->a.typeRef)); - - break; - - } -} /* FreeTBLTypeContent */ - - - - -AsnLen -BEncTBLTypeDefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeDef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->isPdu))) - { - itemLen = BEncAsnNullContent (b, (v->isPdu)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 5); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, (v->type)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->typeName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 19); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDefId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeDefContent */ - -void -BDecTBLTypeDefContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeDef *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeDefIdContent (b, tagId1, elmtLen1, (&v->typeDefId), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -125); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) || -(tagId1 == MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->typeName), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -126); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->type) = (TBLType*) Asn1Alloc (sizeof (TBLType)); - CheckAsn1Alloc ((v->type), env); - BDecTBLTypeContent (b, tagId1, elmtLen1, (v->type), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - else - longjmp (env, -127); - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (UNIV, PRIM, NULLTYPE_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->isPdu) = (AsnNull*) Asn1Alloc (sizeof (AsnNull)); - CheckAsn1Alloc ((v->isPdu), env); - BDecAsnNullContent (b, tagId1, elmtLen1, (v->isPdu), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -128); - } - - - if (!seqDone) - longjmp (env, -129); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeDefContent */ - -void -PrintTBLTypeDef PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeDef *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeDefId "); - PrintTBLTypeDefId (f, (&v->typeDefId), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"typeName "); - PrintPrintableString (f, (&v->typeName), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"type "); - PrintTBLType (f, (v->type), indent + stdIndentG); - if (NOT_NULL ((v->isPdu))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"isPdu "); - PrintAsnNull (f, (v->isPdu), indent + stdIndentG); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeDef */ - -void -FreeTBLTypeDef PARAMS ((v), -TBLTypeDef *v) -{ - - if (v == NULL) - return; - FreeTBLTypeDefId ((&v->typeDefId)); - - FreePrintableString ((&v->typeName)); - - FreeTBLType ((v->type)); - Asn1Free ((v->type)); - - if (NOT_NULL ((v->isPdu))) - { - FreeAsnNull ((v->isPdu)); - Asn1Free ((v->isPdu)); - } - -} /* FreeTBLTypeDef */ - - - - -AsnLen -BEncTBLModuleSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModuleSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeDefContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLModuleSeqOfContent */ - -void -BDecTBLModuleSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLModuleSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLTypeDef **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLTypeDef**) AsnListAppend (v); - (*tmpVar) = (TBLTypeDef*) Asn1Alloc (sizeof (TBLTypeDef)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTypeDefContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -130); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLModuleSeqOfContent */ - -void -PrintTBLModuleSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLModuleSeqOf *v _AND_ -unsigned short int indent) -{ - TBLTypeDef *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLTypeDef (f, tmp, indent + stdIndentG); - if (tmp != (TBLTypeDef*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLModuleSeqOf */ - -void -FreeTBLModuleSeqOf PARAMS ((v), -TBLModuleSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLTypeDef ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLModuleSeqOf */ - - - - -AsnLen -BEncTBLModuleContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModule *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLModuleSeqOfContent (b, (v->typeDefs)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - itemLen = BEncAsnBoolContent (b, (&v->isUseful)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - if (ASNOID_PRESENT ((&v->id))) - { - itemLen = BEncAsnOidContent (b, (&v->id)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - } - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLModuleContent */ - -void -BDecTBLModuleContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLModule *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->name), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -131); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnOidContent (b, tagId1, elmtLen1, (&v->id), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->isUseful), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -132); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->typeDefs) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->typeDefs), env); - BDecTBLModuleSeqOfContent (b, tagId1, elmtLen1, (v->typeDefs), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -133); - } - else - longjmp (env, -134); - - - if (!seqDone) - longjmp (env, -135); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLModuleContent */ - -void -PrintTBLModule PARAMS ((f, v, indent), -FILE* f _AND_ -TBLModule *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"name "); - PrintPrintableString (f, (&v->name), indent + stdIndentG); - fprintf (f, ",\n"); - if (ASNOID_PRESENT ((&v->id))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"id "); - PrintAsnOid (f, (&v->id), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"isUseful "); - PrintAsnBool (f, (&v->isUseful), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"typeDefs "); - PrintTBLModuleSeqOf (f, (v->typeDefs), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLModule */ - -void -FreeTBLModule PARAMS ((v), -TBLModule *v) -{ - - if (v == NULL) - return; - FreePrintableString ((&v->name)); - - if (ASNOID_PRESENT ((&v->id))) - { - FreeAsnOid ((&v->id)); - } - - FreeAsnBool ((&v->isUseful)); - - FreeTBLModuleSeqOf ((v->typeDefs)); - Asn1Free ((v->typeDefs)); - -} /* FreeTBLModule */ - - - - -AsnLen -BEncTBLSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLModuleContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLSeqOfContent */ - -void -BDecTBLSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLModule **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLModule**) AsnListAppend (v); - (*tmpVar) = (TBLModule*) Asn1Alloc (sizeof (TBLModule)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLModuleContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -136); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLSeqOfContent */ - -void -PrintTBLSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLSeqOf *v _AND_ -unsigned short int indent) -{ - TBLModule *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLModule (f, tmp, indent + stdIndentG); - if (tmp != (TBLModule*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLSeqOf */ - -void -FreeTBLSeqOf PARAMS ((v), -TBLSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLModule ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLSeqOf */ - - - - -AsnLen BEncTBL PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncTBLContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} /* BEncTBL */ - -void BDecTBL PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -TBL *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error ("BDecTBL: ERROR - wrong tag\n"); - longjmp (env, -137); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecTBLContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecTBL */ - -AsnLen -BEncTBLContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLSeqOfContent (b, (v->modules)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalLenStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTags)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypes)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypeDefs)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumModules)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLContent */ - -void -BDecTBLContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBL *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumModules), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -138); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTypeDefs), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -139); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTypes), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -140); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTags), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -141); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumStrings), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -142); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalLenStrings), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -143); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->modules) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->modules), env); - BDecTBLSeqOfContent (b, tagId1, elmtLen1, (v->modules), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -144); - } - else - longjmp (env, -145); - - - if (!seqDone) - longjmp (env, -146); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLContent */ - -void -PrintTBL PARAMS ((f, v, indent), -FILE* f _AND_ -TBL *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumModules "); - PrintAsnInt (f, (&v->totalNumModules), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTypeDefs "); - PrintAsnInt (f, (&v->totalNumTypeDefs), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTypes "); - PrintAsnInt (f, (&v->totalNumTypes), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTags "); - PrintAsnInt (f, (&v->totalNumTags), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumStrings "); - PrintAsnInt (f, (&v->totalNumStrings), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalLenStrings "); - PrintAsnInt (f, (&v->totalLenStrings), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"modules "); - PrintTBLSeqOf (f, (v->modules), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBL */ - -void -FreeTBL PARAMS ((v), -TBL *v) -{ - - if (v == NULL) - return; - FreeAsnInt ((&v->totalNumModules)); - - FreeAsnInt ((&v->totalNumTypeDefs)); - - FreeAsnInt ((&v->totalNumTypes)); - - FreeAsnInt ((&v->totalNumTags)); - - FreeAsnInt ((&v->totalNumStrings)); - - FreeAsnInt ((&v->totalLenStrings)); - - FreeTBLSeqOf ((v->modules)); - Asn1Free ((v->modules)); - -} /* FreeTBL */ - - - - -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/boot/tbl.h b/SecuritySNACCRuntime/c-lib/boot/tbl.h deleted file mode 100644 index 57842c63..00000000 --- a/SecuritySNACCRuntime/c-lib/boot/tbl.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl.h - * - * "TBL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Mon Jun 2 11:23:56 1997 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _tbl_h_ -#define _tbl_h_ - - - - -typedef enum - { - TBL_BOOLEAN = 0, - TBL_INTEGER = 1, - TBL_BITSTRING = 2, - TBL_OCTETSTRING = 3, - TBL_NULL = 4, - TBL_OID = 5, - TBL_REAL = 6, - TBL_ENUMERATED = 7, - TBL_SEQUENCE = 8, - TBL_SET = 9, - TBL_SEQUENCEOF = 10, - TBL_SETOF = 11, - TBL_CHOICE = 12, - TBL_TYPEREF = 13 - } TBLTypeId; /* ENUMERATED { TBL_BOOLEAN (0), TBL_INTEGER (1), TBL_BITSTRING (2), TBL_OCTETSTRING (3), TBL_NULL (4), TBL_OID (5), TBL_REAL (6), TBL_ENUMERATED (7), TBL_SEQUENCE (8), TBL_SET (9), TBL_SEQUENCEOF (10), TBL_SETOF (11), TBL_CHOICE (12), TBL_TYPEREF (13) } */ - -#define BEncTBLTypeIdContent BEncAsnEnumContent - -#define BDecTBLTypeIdContent BDecAsnEnumContent - -#define PrintTBLTypeId PrintAsnEnum - -#define FreeTBLTypeId FreeAsnEnum - - - - -typedef AsnInt TBLTypeDefId; /* INTEGER */ - -#define BEncTBLTypeDefIdContent BEncAsnIntContent - -#define BDecTBLTypeDefIdContent BDecAsnIntContent - -#define PrintTBLTypeDefId PrintAsnInt - -#define FreeTBLTypeDefId FreeAsnInt - - - - -typedef enum - { - UNIVERSAL = 0, - APPLICATION = 1, - CONTEXT = 2, - PRIVATE = 3 - } TBLTagClass; /* ENUMERATED { UNIVERSAL (0), APPLICATION (1), CONTEXT (2), PRIVATE (3) } */ - -#define BEncTBLTagClassContent BEncAsnEnumContent - -#define BDecTBLTagClassContent BDecAsnEnumContent - -#define PrintTBLTagClass PrintAsnEnum - -#define FreeTBLTagClass FreeAsnEnum - - - - -typedef struct TBLRange /* SEQUENCE */ -{ - AsnInt from; /* [0] IMPLICIT INTEGER */ - AsnInt to; /* [1] IMPLICIT INTEGER */ -} TBLRange; - -AsnLen BEncTBLRangeContent PROTO ((BUF_TYPE b, TBLRange *v)); - -void BDecTBLRangeContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLRange *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLRange PROTO ((FILE* f, TBLRange *v, unsigned short int indent)); -void FreeTBLRange PROTO ((TBLRange *v)); - - - - - -typedef struct TBLNamedNumber /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnInt value; /* [1] IMPLICIT INTEGER */ -} TBLNamedNumber; - -AsnLen BEncTBLNamedNumberContent PROTO ((BUF_TYPE b, TBLNamedNumber *v)); - -void BDecTBLNamedNumberContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLNamedNumber *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLNamedNumber PROTO ((FILE* f, TBLNamedNumber *v, unsigned short int indent)); -void FreeTBLNamedNumber PROTO ((TBLNamedNumber *v)); - - - - - -typedef AsnList TBLNamedNumberList; /* SEQUENCE OF TBLNamedNumber */ - -AsnLen BEncTBLNamedNumberListContent PROTO ((BUF_TYPE b, TBLNamedNumberList *v)); - -void BDecTBLNamedNumberListContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLNamedNumberList *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLNamedNumberList PROTO ((FILE* f, TBLNamedNumberList *v, unsigned short int indent)); -void FreeTBLNamedNumberList PROTO ((TBLNamedNumberList *v)); - - - - - -typedef struct TBLTypeRef /* SEQUENCE */ -{ - TBLTypeDefId typeDef; /* TBLTypeDefId */ - AsnBool implicit; /* BOOLEAN */ - struct TBLTypeDef *typeDefPtr; /* Added by MS to hold resolved index */ -} TBLTypeRef; - -AsnLen BEncTBLTypeRefContent PROTO ((BUF_TYPE b, TBLTypeRef *v)); - -void BDecTBLTypeRefContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeRef *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeRef PROTO ((FILE* f, TBLTypeRef *v, unsigned short int indent)); -void FreeTBLTypeRef PROTO ((TBLTypeRef *v)); - - - - - -typedef struct TBLTag /* SEQUENCE */ -{ - TBLTagClass tclass; /* TBLTagClass */ - AsnInt code; /* INTEGER (0..MAX) */ - BER_FORM form; /* added by MS to simplify enc/dec */ - AsnTag encTag; /* added by MS to simplify enc/dec */ -} TBLTag; - -AsnLen BEncTBLTagContent PROTO ((BUF_TYPE b, TBLTag *v)); - -void BDecTBLTagContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTag *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTag PROTO ((FILE* f, TBLTag *v, unsigned short int indent)); -void FreeTBLTag PROTO ((TBLTag *v)); - - - - - -typedef AsnList TBLTypeSeqOf; /* SEQUENCE OF TBLTag */ - -AsnLen BEncTBLTypeSeqOfContent PROTO ((BUF_TYPE b, TBLTypeSeqOf *v)); - -void BDecTBLTypeSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeSeqOf PROTO ((FILE* f, TBLTypeSeqOf *v, unsigned short int indent)); -void FreeTBLTypeSeqOf PROTO ((TBLTypeSeqOf *v)); - - - - - -typedef AsnList TBLTypeContentSeqOf; /* SEQUENCE OF TBLType */ - -AsnLen BEncTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, TBLTypeContentSeqOf *v)); - -void BDecTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeContentSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeContentSeqOf PROTO ((FILE* f, TBLTypeContentSeqOf *v, unsigned short int indent)); -void FreeTBLTypeContentSeqOf PROTO ((TBLTypeContentSeqOf *v)); - - - - - -typedef struct TBLType /* SEQUENCE */ -{ - TBLTypeId typeId; /* [0] IMPLICIT TBLTypeId */ - AsnBool optional; /* [1] IMPLICIT BOOLEAN */ - TBLTypeSeqOf* tagList; /* [2] IMPLICIT TBLTypeSeqOf OPTIONAL */ - struct TBLTypeContent* content; /* [3] TBLTypeContent */ - PrintableString fieldName; /* [4] IMPLICIT PrintableString OPTIONAL */ - struct TBLRange* constraint; /* [5] IMPLICIT TBLRange OPTIONAL */ - TBLNamedNumberList* values; /* [6] IMPLICIT TBLNamedNumberList OPTIONAL */ -} TBLType; - -AsnLen BEncTBLTypeContent PROTO ((BUF_TYPE b, TBLType *v)); - -void BDecTBLTypeContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLType *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLType PROTO ((FILE* f, TBLType *v, unsigned short int indent)); -void FreeTBLType PROTO ((TBLType *v)); - - - - - -typedef struct TBLTypeContent /* CHOICE */ -{ - enum TBLTypeContentChoiceId - { - TBLTYPECONTENT_PRIMTYPE, - TBLTYPECONTENT_ELMTS, - TBLTYPECONTENT_TYPEREF - } choiceId; - union TBLTypeContentChoiceUnion - { - AsnNull primType; /* [0] IMPLICIT NULL */ - TBLTypeContentSeqOf* elmts; /* [1] IMPLICIT TBLTypeContentSeqOf */ - struct TBLTypeRef* typeRef; /* [2] IMPLICIT TBLTypeRef */ - } a; -} TBLTypeContent; - -AsnLen BEncTBLTypeContentContent PROTO ((BUF_TYPE b, TBLTypeContent *v)); - -void BDecTBLTypeContentContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeContent *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeContent PROTO ((FILE* f, TBLTypeContent *v, unsigned short int indent)); -void FreeTBLTypeContent PROTO ((TBLTypeContent *v)); - - - - - -typedef struct TBLTypeDef /* SEQUENCE */ -{ - TBLTypeDefId typeDefId; /* TBLTypeDefId */ - PrintableString typeName; /* PrintableString */ - struct TBLType* type; /* TBLType */ - AsnNull* isPdu; /* NULL OPTIONAL */ -} TBLTypeDef; - -AsnLen BEncTBLTypeDefContent PROTO ((BUF_TYPE b, TBLTypeDef *v)); - -void BDecTBLTypeDefContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeDef *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeDef PROTO ((FILE* f, TBLTypeDef *v, unsigned short int indent)); -void FreeTBLTypeDef PROTO ((TBLTypeDef *v)); - - - - - -typedef AsnList TBLModuleSeqOf; /* SEQUENCE OF TBLTypeDef */ - -AsnLen BEncTBLModuleSeqOfContent PROTO ((BUF_TYPE b, TBLModuleSeqOf *v)); - -void BDecTBLModuleSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLModuleSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLModuleSeqOf PROTO ((FILE* f, TBLModuleSeqOf *v, unsigned short int indent)); -void FreeTBLModuleSeqOf PROTO ((TBLModuleSeqOf *v)); - - - - - -typedef struct TBLModule /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnOid id; /* [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL */ - AsnBool isUseful; /* [2] IMPLICIT BOOLEAN */ - TBLModuleSeqOf* typeDefs; /* [3] IMPLICIT TBLModuleSeqOf */ -} TBLModule; - -AsnLen BEncTBLModuleContent PROTO ((BUF_TYPE b, TBLModule *v)); - -void BDecTBLModuleContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLModule *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLModule PROTO ((FILE* f, TBLModule *v, unsigned short int indent)); -void FreeTBLModule PROTO ((TBLModule *v)); - - - - - -typedef AsnList TBLSeqOf; /* SEQUENCE OF TBLModule */ - -AsnLen BEncTBLSeqOfContent PROTO ((BUF_TYPE b, TBLSeqOf *v)); - -void BDecTBLSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLSeqOf PROTO ((FILE* f, TBLSeqOf *v, unsigned short int indent)); -void FreeTBLSeqOf PROTO ((TBLSeqOf *v)); - - - - - -typedef struct TBL /* SEQUENCE */ -{ - AsnInt totalNumModules; /* INTEGER */ - AsnInt totalNumTypeDefs; /* INTEGER */ - AsnInt totalNumTypes; /* INTEGER */ - AsnInt totalNumTags; /* INTEGER */ - AsnInt totalNumStrings; /* INTEGER */ - AsnInt totalLenStrings; /* INTEGER */ - TBLSeqOf* modules; /* TBLSeqOf */ -} TBL; - -AsnLen BEncTBL PROTO ((BUF_TYPE b, TBL *v)); - -void BDecTBL PROTO ((BUF_TYPE b, TBL *result, AsnLen *bytesDecoded, ENV_TYPE env)); -AsnLen BEncTBLContent PROTO ((BUF_TYPE b, TBL *v)); - -void BDecTBLContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBL *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBL PROTO ((FILE* f, TBL *v, unsigned short int indent)); -void FreeTBL PROTO ((TBL *v)); - - - - - - -#endif /* conditional include of tbl.h */ diff --git a/SecuritySNACCRuntime/c-lib/dependencies b/SecuritySNACCRuntime/c-lib/dependencies deleted file mode 100644 index 3dfeeee2..00000000 --- a/SecuritySNACCRuntime/c-lib/dependencies +++ /dev/null @@ -1,1040 +0,0 @@ -asn-len.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h -asn-tag.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h -asn-int.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h -asn-bool.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-bool.h -asn-bits.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h \ - /usr/include/string.h inc/asn-len.h inc/asn-tag.h inc/str-stk.h \ - inc/asn-bits.h -asn-octs.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/str-stk.h inc/asn-bits.h inc/asn-octs.h -asn-oid.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-octs.h inc/asn-oid.h -asn-real.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-real.h -asn-null.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-null.h -asn-list.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-list.h -asn-enum.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h inc/asn-enum.h -str-stk.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/str-stk.h -nibble-alloc.o : inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/exp-buf.h \ - inc/print.h /usr/include/string.h -print.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h -asn-any.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-oid.h inc/asn-octs.h inc/asn-int.h inc/asn-any.h \ - inc/hash.h -hash.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/hash.h -exp-buf.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/gen-buf.h -sbuf.o : -tbl-dec.o : -tbl-enc.o : -tbl-free.o : -tbl-gen.o : -tbl-dbg.o : -tbl-print.o : -tbl-util.o : -asn-useful.o : inc/asn-incl.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/exp-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h -tbl.o : -asn-len.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h -asn-tag.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h -asn-int.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h -asn-bool.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-bool.h -asn-bits.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h \ - /usr/include/string.h inc/asn-len.h inc/asn-tag.h inc/str-stk.h \ - inc/asn-bits.h -asn-octs.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/str-stk.h inc/asn-bits.h inc/asn-octs.h -asn-oid.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-octs.h inc/asn-oid.h -asn-real.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-real.h -asn-null.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-null.h -asn-list.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-list.h -asn-enum.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h inc/asn-enum.h -str-stk.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/str-stk.h -nibble-alloc.o : inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/exp-buf.h \ - inc/print.h /usr/include/string.h -print.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h -asn-any.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-oid.h inc/asn-octs.h inc/asn-int.h inc/asn-any.h \ - inc/hash.h -hash.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/hash.h -exp-buf.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/exp-buf.h inc/print.h inc/gen-buf.h -sbuf.o : -tbl-dec.o : -tbl-enc.o : -tbl-free.o : -tbl-gen.o : -tbl-dbg.o : -tbl-print.o : -tbl-util.o : -asn-useful.o : inc/asn-incl.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/exp-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h -tbl.o : -asn-len.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h -asn-tag.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h -asn-int.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h -asn-bool.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-bool.h -asn-bits.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h \ - /usr/include/string.h inc/asn-len.h inc/asn-tag.h inc/str-stk.h \ - inc/asn-bits.h -asn-octs.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/str-stk.h inc/asn-bits.h inc/asn-octs.h -asn-oid.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-octs.h inc/asn-oid.h -asn-real.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-real.h -asn-null.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-null.h -asn-list.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-list.h -asn-enum.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h inc/asn-enum.h -str-stk.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/str-stk.h -nibble-alloc.o : inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/min-buf.h \ - inc/print.h /usr/include/string.h -print.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h -asn-any.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-oid.h inc/asn-octs.h inc/asn-int.h inc/asn-any.h \ - inc/hash.h -hash.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/min-buf.h inc/print.h inc/hash.h -exp-buf.o : -sbuf.o : -tbl-dec.o : -tbl-enc.o : -tbl-free.o : -tbl-gen.o : -tbl-dbg.o : -tbl-print.o : -tbl-util.o : -asn-useful.o : inc/asn-incl.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/min-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h -tbl.o : -asn-len.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h -asn-tag.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h -asn-int.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h -asn-bool.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-bool.h -asn-bits.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h \ - /usr/include/string.h inc/asn-len.h inc/asn-tag.h inc/str-stk.h \ - inc/asn-bits.h -asn-octs.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/str-stk.h inc/asn-bits.h inc/asn-octs.h -asn-oid.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-octs.h inc/asn-oid.h -asn-real.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-real.h -asn-null.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-null.h -asn-list.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-list.h -asn-enum.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h inc/asn-enum.h -str-stk.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/str-stk.h -nibble-alloc.o : inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/sbuf.h \ - inc/print.h /usr/include/string.h -print.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h -asn-any.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-oid.h inc/asn-octs.h inc/asn-int.h inc/asn-any.h \ - inc/hash.h -hash.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/sbuf.h inc/print.h inc/hash.h -exp-buf.o : -sbuf.o : -tbl-dec.o : -tbl-enc.o : -tbl-free.o : -tbl-gen.o : -tbl-dbg.o : -tbl-print.o : -tbl-util.o : -asn-useful.o : inc/asn-incl.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/sbuf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h -tbl.o : -asn-len.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h -asn-tag.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h -asn-int.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h -asn-bool.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-bool.h -asn-bits.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h \ - /usr/include/string.h inc/asn-len.h inc/asn-tag.h inc/str-stk.h \ - inc/asn-bits.h -asn-octs.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/str-stk.h inc/asn-bits.h inc/asn-octs.h -asn-oid.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-octs.h inc/asn-oid.h -asn-real.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-real.h -asn-null.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-null.h -asn-list.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-list.h -asn-enum.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-int.h inc/asn-enum.h -str-stk.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/str-stk.h -nibble-alloc.o : inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h /usr/include/string.h -print.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h -asn-any.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-oid.h inc/asn-octs.h inc/asn-int.h inc/asn-any.h \ - inc/hash.h -hash.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/hash.h -exp-buf.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/exp-buf.h -sbuf.o : inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/sbuf.h -tbl-dec.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h inc/tbl-incl.h inc/asn-incl.h inc/asn-config.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h inc/tbl.h inc/tbl-util.h inc/tbl-enc.h inc/tbl-dec.h \ - inc/tbl-print.h inc/tbl-free.h -tbl-enc.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h inc/tbl-incl.h inc/asn-incl.h inc/asn-config.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h inc/tbl.h inc/tbl-util.h inc/tbl-enc.h inc/tbl-dec.h \ - inc/tbl-print.h inc/tbl-free.h -tbl-free.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h inc/tbl-incl.h inc/asn-incl.h inc/asn-config.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h inc/tbl.h inc/tbl-util.h inc/tbl-enc.h inc/tbl-dec.h \ - inc/tbl-print.h inc/tbl-free.h -tbl-gen.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h inc/tbl-gen.h inc/tbl-incl.h inc/asn-incl.h \ - inc/asn-config.h /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h inc/tbl.h inc/tbl-util.h inc/tbl-enc.h inc/tbl-dec.h \ - inc/tbl-print.h inc/tbl-free.h -tbl-dbg.o : inc/tbl-dbg.h inc/tbl-gen.h inc/tbl-incl.h inc/asn-incl.h \ - inc/asn-config.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h inc/nibble-alloc.h inc/gen-buf.h inc/print.h inc/asn-len.h \ - inc/asn-tag.h inc/asn-bool.h inc/asn-int.h inc/asn-enum.h inc/asn-real.h \ - inc/asn-octs.h inc/asn-bits.h inc/asn-oid.h inc/asn-null.h inc/asn-any.h \ - inc/hash.h inc/asn-list.h inc/asn-useful.h inc/tbl.h inc/tbl-util.h \ - inc/tbl-enc.h inc/tbl-dec.h inc/tbl-print.h inc/tbl-free.h -tbl-print.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h inc/tbl-incl.h inc/asn-incl.h inc/asn-config.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h inc/tbl.h inc/tbl-util.h inc/tbl-enc.h inc/tbl-dec.h \ - inc/tbl-print.h inc/tbl-free.h -tbl-util.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h inc/tbl-incl.h inc/asn-incl.h inc/asn-config.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h inc/tbl.h inc/tbl-util.h inc/tbl-enc.h inc/tbl-dec.h \ - inc/tbl-print.h inc/tbl-free.h inc/sbuf.h -asn-useful.o : inc/asn-incl.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h -tbl.o : inc/asn-incl.h inc/asn-config.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h inc/nibble-alloc.h inc/gen-buf.h \ - inc/print.h inc/asn-len.h inc/asn-tag.h inc/asn-bool.h inc/asn-int.h \ - inc/asn-enum.h inc/asn-real.h inc/asn-octs.h inc/asn-bits.h \ - inc/asn-oid.h inc/asn-null.h inc/asn-any.h inc/hash.h inc/asn-list.h \ - inc/asn-useful.h inc/tbl.h diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-any.h b/SecuritySNACCRuntime/c-lib/inc/asn-any.h deleted file mode 100644 index f367f405..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-any.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_any.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-any.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-any.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:22 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:19 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1997/02/28 13:39:49 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.2 1995/07/24 21:01:07 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:22 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_any_h_ -#define _asn_any_h_ - -#include "hash.h" - -/* - * 1 hash table for integer keys - * 1 hash table for oid keys - */ -extern Table *anyOidHashTblG; -extern Table *anyIntHashTblG; - -typedef AsnLen (*EncodeFcn) PROTO ((BUF_TYPE b, void *value)); -typedef void (*DecodeFcn) PROTO ((BUF_TYPE b, void *value, AsnLen *bytesDecoded, ENV_TYPE env)); -typedef void (*FreeFcn) PROTO ((void *v)); -typedef void (*PrintFcn) PROTO ((FILE *f, void *v)); - -/* - * this is put into the hash table with the - * int or oid as the key - */ -typedef struct AnyInfo -{ - int anyId; /* will be a value from the AnyId enum */ - AsnOid oid; /* will be zero len/null if intId is valid */ - AsnInt intId; - unsigned int size; /* size of the C data type (ie as ret'd by sizeof) */ - EncodeFcn Encode; - DecodeFcn Decode; - FreeFcn Free; - PrintFcn Print; -} AnyInfo; - - -typedef struct AsnAny -{ - AnyInfo *ai; /* point to entry in hash tbl that has routine ptrs */ - void *value; /* points to the value */ -} AsnAny; - -/* - * Returns anyId value for the given ANY type. - * Use this to determine to the type of an ANY after decoding - * it. Returns -1 if the ANY info is not available - */ -#define GetAsnAnyId( a) (((a)->ai)? (a)->ai->anyId: -1) - -/* - * used before encoding or decoding a type so the proper - * encode or decode routine is used. - */ -void SetAnyTypeByInt PROTO ((AsnAny *v, AsnInt id)); -void SetAnyTypeByOid PROTO ((AsnAny *v, AsnOid *id)); - - -/* - * used to initialize the hash table (s) - */ -void InstallAnyByInt PROTO ((int anyId, AsnInt intId, unsigned int size, EncodeFcn encode, DecodeFcn decode, FreeFcn free, PrintFcn print)); - -void InstallAnyByOid PROTO ((int anyId, AsnOid *oid, unsigned int size, EncodeFcn encode, DecodeFcn decode, FreeFcn free, PrintFcn print)); - - -/* - * Standard enc, dec, free, & print routines - * for the AsnAny type. - * These call the routines referenced from the - * given value's hash table entry. - */ -void FreeAsnAny PROTO ((AsnAny *v)); - -AsnLen BEncAsnAny PROTO ((BUF_TYPE b, AsnAny *v)); - -void BDecAsnAny PROTO ((BUF_TYPE b, AsnAny *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -void PrintAsnAny PROTO ((FILE *f, AsnAny *v, unsigned short indent)); - - - -/* AnyDefinedBy is currently the same as AsnAny */ - -typedef AsnAny AsnAnyDefinedBy; - -#define FreeAsnAnyDefinedBy FreeAsnAny - -#define BEncAsnAnyDefinedBy BEncAsnAny - -#define BDecAsnAnyDefinedBy BDecAsnAny - -#define PrintAsnAnyDefinedBy PrintAsnAny - - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-bits.h b/SecuritySNACCRuntime/c-lib/inc/asn-bits.h deleted file mode 100644 index 453ff8ab..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-bits.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_bits.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-bits.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-bits.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:22 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:19 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 21:01:09 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/12/11 21:48:28 rj - * argument order of BDecAsnBitsContent() fixed. - * - * Revision 1.1 1994/08/28 09:21:23 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -#ifndef _asn_bits_h_ -#define _asn_bits_h_ - - -typedef struct AsnBits -{ - int bitLen; - char *bits; -} AsnBits; - -extern char numToHexCharTblG[]; - -#define TO_HEX( fourBits) (numToHexCharTblG[(fourBits) & 0x0f]) - - -#define ASNBITS_PRESENT( abits) ((abits)->bits != NULL) - - -AsnLen BEncAsnBits PROTO ((BUF_TYPE b, AsnBits *data)); - -void BDecAsnBits PROTO ((BUF_TYPE b, AsnBits *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -AsnLen BEncAsnBitsContent PROTO ((BUF_TYPE b, AsnBits *bits)); - -void BDecAsnBitsContent PROTO ((BUF_TYPE b, AsnTag tagId, AsnLen len, AsnBits *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -void FreeAsnBits PROTO ((AsnBits *v)); - -void PrintAsnBits PROTO ((FILE *f, AsnBits *b, unsigned short int indent)); - -int AsnBitsEquiv PROTO ((AsnBits *b1, AsnBits *b2)); - -void SetAsnBit PROTO ((AsnBits *b1, unsigned long int bit)); - -void ClrAsnBit PROTO ((AsnBits *b1, unsigned long int bit)); - -int GetAsnBit PROTO ((AsnBits *b1, unsigned long int bit)); - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-bool.h b/SecuritySNACCRuntime/c-lib/inc/asn-bool.h deleted file mode 100644 index 04ba8667..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-bool.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_bool.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-bool.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-bool.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:22 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:10 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:24 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_bool_h_ -#define _asn_bool_h_ - -typedef unsigned char AsnBool; - - -AsnLen BEncAsnBool PROTO ((BUF_TYPE b, AsnBool *data)); - -void BDecAsnBool PROTO ((BUF_TYPE b, AsnBool *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -AsnLen BEncAsnBoolContent PROTO ((BUF_TYPE b, AsnBool *data)); - -void BDecAsnBoolContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen len, AsnBool *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -/* do nothing */ -#define FreeAsnBool( v) - -void PrintAsnBool PROTO ((FILE *f, AsnBool *b, unsigned short int indent)); - -#endif diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-config.h b/SecuritySNACCRuntime/c-lib/inc/asn-config.h deleted file mode 100644 index ed0ee03e..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-config.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_config.h - configures the ANSI/non ansi, defines - * decoder alloc routines and buffer routines - * - * MS 91 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - */ - -#ifndef _asn_config_h_ -#define _asn_config_h_ - -#include -#include /* for jmp_buf type, setjmp and longjmp */ - -/* for pow() used in asn_real.c - must include to avoid casting err on pow */ -#include - -#include "snacc.h" - - -/* used to test if optionals are present */ -#define NOT_NULL( ptr) ((ptr) != NULL) - - -/* - * Asn1Error (char *str) - configure error handler - */ -void Asn1Error PROTO ((char* str)); - - -/* - * Asn1Warning (char *str) - configure warning mechanism - * (currently never called) - */ -void Asn1Warning PROTO ((char* str)); - -/* - * Asn1ErrorHandler - procedure to call upon Asn1Warning (severity 0) - * and Asn1Error (severity 1). - */ -typedef void (*Asn1ErrorHandler) PROTO ((char* str, int severity)); - -/* - * Asn1InstallErrorHandler - installs new error handler, returns former one - */ -Asn1ErrorHandler Asn1InstallErrorHandler PROTO ((Asn1ErrorHandler handler)); - -/* - * configure memory scheme used by decoder to allocate memory - * for the decoded value. - * The Asn1Free will be called in the optionally generated - * hierachical free routines. - * - * nibble_alloc allocs from a single buffer and EVERYTHING - * is freed by a single fcn call. Individual elmts cannot be freed - */ - -#ifndef USE_NIBBLE_MEMORY -#define USE_NIBBLE_MEMORY 1 -#endif - -#if USE_NIBBLE_MEMORY - -#include "nibble-alloc.h" - -#define Asn1Alloc( size) NibbleAlloc (size) -#define Asn1Free( ptr) /* empty */ -#define CheckAsn1Alloc( ptr, env) \ - if ((ptr) == NULL)\ - longjmp (env, -27) - -#else /* !USE_NIBBLE_MEMORY */ - -#include "mem.h" - -#define Asn1Alloc( size) Malloc (size) -#define Asn1Free( ptr) Free (ptr) -#define CheckAsn1Alloc( ptr, env) \ - if ((ptr) == NULL)\ - longjmp (env, -27) - -#endif /* USE_NIBBLE_MEMORY */ - -#define ENV_TYPE jmp_buf - -/* - * configure buffer routines that the encoders (write) - * and decoders (read) use. This config technique kind - * of bites but is allows efficient macro calls. The - * Generated code & lib routines call/use the "Buf????" - * version of the macro - you define their meaning here. - */ -#ifdef USE_EXP_BUF - -#include "exp-buf.h" - -#define BUF_TYPE ExpBuf ** -#define BufGetByte( b) ExpBufGetByte (b) -#define BufGetSeg( b, lenPtr) ExpBufGetSeg (b, lenPtr) -#define BufCopy( dst, b, len) ExpBufCopy (dst, b, len) -#define BufSkip( b, len) ExpBufSkip (b, len) -#define BufPeekByte( b) ExpBufPeekByte (b) -#define BufPutByteRvs( b, byte) ExpBufPutByteRvs (b, byte) -#define BufPutSegRvs( b, data, len) ExpBufPutSegRvs (b, data, len) -#define BufReadError( b) ExpBufReadError (b) -#define BufWriteError( b) ExpBufWriteError (b) - -#else /* !USE_EXP_BUF */ - -#ifdef USE_MIN_BUF - -#include "min-buf.h" - -#define BUF_TYPE char ** -#define BufGetByte( b) MinBufGetByte (b) -#define BufGetSeg( b, lenPtr) MinBufGetSeg (b, lenPtr) -#define BufCopy( dst, b, len) MinBufCopy (dst, b, len) -#define BufSkip( b, len) MinBufSkip (b, len) -#define BufPeekByte( b) MinBufPeekByte (b) -#define BufPutByteRvs( b, byte) MinBufPutByteRvs (b, byte) -#define BufPutSegRvs( b, data, len) MinBufPutSegRvs (b, data, len) -#define BufReadError( b) MinBufReadError (b) -#define BufWriteError( b) MinBufWriteError (b) - -#else /* !USE_EXP_BUF && !USE_MIN_BUF */ - -#ifdef USE_SBUF - -#include "sbuf.h" - -#define BUF_TYPE SBuf * -#define BufGetByte( b) SBufGetByte (b) -#define BufGetSeg( b, lenPtr) SBufGetSeg (b, lenPtr) -#define BufCopy( dst, b, len) SBufCopy (dst, b, len) -#define BufSkip( b, len) SBufSkip (b, len) -#define BufPeekByte( b) SBufPeekByte (b) -#define BufPutByteRvs( b, byte) SBufPutByteRvs (b, byte) -#define BufPutSegRvs( b, data, len) SBufPutSegRvs (b, data, len) -#define BufReadError( b) SBufReadError (b) -#define BufWriteError( b) SBufWriteError (b) - -#else /* !USE_EXP_BUF && !USE_MIN_BUF && !USE_SBUF*/ - -#ifdef USE_GEN_BUF - -/* - * NOTE: for use with tables, I defined the (slower) - * GenBuf type that is more flexible (à la ISODE and XDR). - * This allows the encode/decode libs to support other - * buffer types dynamically instead of having different - * libs for each buffer type. - * The GenBufs are not provided for the compiled code - * (ie the c_lib directory) but could easily be added - * (I don't have time, tho). Tables tools are - * around 4x slower than the compiled version so a - * the GenBufs aren't such a big performance hit for table stuff. - * - */ -#include "gen-buf.h" - -#define BUF_TYPE GenBuf * -#define BufGetByte( b) GenBufGetByte (b) -#define BufGetSeg( b, lenPtr) GenBufGetSeg (b, lenPtr) -#define BufCopy( dst, b, len) GenBufCopy (dst, b, len) -#define BufSkip( b, len) GenBufSkip (b, len) -#define BufPeekByte( b) GenBufPeekByte (b) -#define BufPeekSeg( b, lenPtr) GenBufPeekSeg (b, lenPtr) -#define BufPeekCopy( dst, b, len) GenBufPeekCopy (dst, b, len) -#define BufPutByteRvs( b, byte) GenBufPutByteRvs (b, byte) -#define BufPutSegRvs( b, data, len) GenBufPutSegRvs (b, data, len) -#define BufReadError( b) GenBufReadError (b) -#define BufWriteError( b) GenBufWriteError (b) - -#else /* none?! */ - -#ifndef MAKEDEPEND - #error "don't know what buffer type to use!" -#endif - -#endif /* USE_GEN_BUF */ -#endif /* USE_SBUF */ -#endif /* USE_MIN_BUF */ -#endif /* USE_EXP_BUF */ - -#include "print.h" /* for printing set up */ - -/* - * Enables throw/catch as replacement for setjmp/longjmp in C++ lib. - * BDecPdu still returns int (1 = OK, 0 = fail) in either config. - * The compiler gets this symbol from this file; runtime support uses - * the same symbol in c++_lib/inc/asn-config.h There is currently no - * straightforward way to have one symbol used in both environments. - */ -#define SNACC_EXCEPTION_ENABLE 1 - -/* - * Enable BEncPdu, BDecPdu. Same remarks apply as above w.r.t the - * c++ config file. - */ -#define SNACC_ENABLE_PDU 0 - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-enum.h b/SecuritySNACCRuntime/c-lib/inc/asn-enum.h deleted file mode 100644 index 6e9d9b8b..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-enum.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_enum.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-enum.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-enum.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:22 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:12 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:26 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_enum_h_ -#define _asn_enum_h_ - -typedef AsnInt AsnEnum; - -/* - * ENUMERATED have a UNIVERSAL tag that is diff from INTEGERS - * so need diff encoding routine tho content stuff is the same - */ -AsnLen BEncAsnEnum PROTO ((BUF_TYPE b, AsnEnum *data)); - -void BDecAsnEnum PROTO ((BUF_TYPE b, AsnEnum *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -#define BEncAsnEnumContent BEncAsnIntContent - -#define BDecAsnEnumContent BDecAsnIntContent - -#define FreeAsnEnum FreeAsnInt - -#define PrintAsnEnum PrintAsnInt - - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-incl.h b/SecuritySNACCRuntime/c-lib/inc/asn-incl.h deleted file mode 100644 index d7abf22e..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-incl.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_incl.h - * includes hdr files nec for a user prg that calls the generated - * encoding/decoding routines. - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-incl.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-incl.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:22 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:13 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:27 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-bool.h" -#include "asn-int.h" -#include "asn-enum.h" -#include "asn-real.h" -#include "asn-octs.h" -#include "asn-bits.h" -#include "asn-oid.h" -#include "asn-null.h" -#include "asn-any.h" -#include "asn-list.h" -#include "asn-useful.h" diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-int.h b/SecuritySNACCRuntime/c-lib/inc/asn-int.h deleted file mode 100644 index 4223f69a..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-int.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_int.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-int.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-int.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:22 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/27 08:38:58 rj - * ``#error "..."'' instead of ``#error ...''. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1995/02/18 16:19:42 rj - * let cpp choose a 32 bit integer type. - * - * Revision 1.1 1994/08/28 09:21:28 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_int_h_ -#define _asn_int_h_ - -#if SIZEOF_INT == 4 -# define I int -#else -# if SIZEOF_LONG == 4 -# define I long -# else -# if SIZEOF_SHORT == 4 -# define I short -# endif -# endif -#endif -#ifdef I - typedef I AsnInt; - typedef unsigned I UAsnInt; -#else - #error "can't find integer type which is 4 bytes in size" -#endif -#undef I - -AsnLen BEncAsnInt PROTO ((BUF_TYPE b, AsnInt *data)); - -void BDecAsnInt PROTO ((BUF_TYPE b, AsnInt *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -AsnLen BEncAsnIntContent PROTO ((BUF_TYPE b, AsnInt *data)); - -void BDecAsnIntContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnInt *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -/* do nothing */ -#define FreeAsnInt( v) - -void PrintAsnInt PROTO ((FILE *f, AsnInt *v, unsigned short int indent)); - - - - -AsnLen BEncUAsnInt PROTO ((BUF_TYPE b, UAsnInt *data)); - -void BDecUAsnInt PROTO ((BUF_TYPE b, UAsnInt *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -AsnLen BEncUAsnIntContent PROTO ((BUF_TYPE b, UAsnInt *data)); - -void BDecUAsnIntContent PROTO ((BUF_TYPE b, AsnTag tagId, AsnLen len, UAsnInt *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -/* do nothing */ -#define FreeUAsnInt( v) - -void PrintUAsnInt PROTO ((FILE *f, UAsnInt *v, unsigned short int indent)); - - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-len.h b/SecuritySNACCRuntime/c-lib/inc/asn-len.h deleted file mode 100644 index d171ebd2..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-len.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_len.h - * - * Warning: many of these routines are MACROs for performance reasons - * - be carful where you use them. Don't use more than one per - * assignment statement - - * (eg itemLen += BEncEoc (b) + BEncFoo (b) ..; this - * will break the code) - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-len.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-len.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:22 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/27 08:42:40 rj - * cpp macro TBL changed to TTBL since some type table code uses TBL as a type name. - * - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:29 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_len_h_ -#define _asn_len_h_ - -typedef unsigned long int AsnLen; - -/* max unsigned value - used for internal rep of indef len */ -#define INDEFINITE_LEN ~0L - - -#ifdef USE_INDEF_LEN - -#define BEncEocIfNec( b) BEncEoc (b) - -/* - * include len for EOC (2 must be first due to BEncIndefLen - * - ack! ugly macros!) - */ -#define BEncConsLen( b, len) 2 + BEncIndefLen(b) - - -#else /* use definite length - faster?/smaller encodings */ - - -/* do nothing since only using definite lens */ -#define BEncEocIfNec( b) - -#define BEncConsLen( b, len) BEncDefLen(b, len) - - -#endif - - - -/* - * writes indefinite length byte to buffer. 'returns' encoded len (1) - */ -#define BEncIndefLen( b)\ - 1;\ - BufPutByteRvs (b, 0x80); - - -#define BEncEoc( b)\ - 2;\ - BufPutByteRvs (b, 0);\ - BufPutByteRvs (b, 0); - - -/* - * use if you know the encoded length will be 0 >= len <= 127 - * Eg for booleans, nulls, any resonable integers and reals - * - * NOTE: this particular Encode Routine does NOT return the length - * encoded (1). - */ -#define BEncDefLenTo127( b, len)\ - BufPutByteRvs (b, (unsigned char) len) - -#define BDEC_2ND_EOC_OCTET( b, bytesDecoded, env)\ -{\ - if ((BufGetByte (b) != 0) || BufReadError (b)) {\ - Asn1Error ("ERROR - second octet of EOC not zero\n");\ - longjmp (env, -28);}\ - (*bytesDecoded)++;\ -} - - -AsnLen BEncDefLen PROTO ((BUF_TYPE b, AsnLen len)); - -AsnLen BDecLen PROTO ((BUF_TYPE b, AsnLen *bytesDecoded, ENV_TYPE env)); - -/* -AsnLen BEncEoc PROTO ((BUF_TYPE b)); -*/ -void BDecEoc PROTO ((BUF_TYPE b, AsnLen *bytesDecoded, ENV_TYPE env)); - -#if TTBL -int PeekEoc PROTO ((BUF_TYPE b)); -#endif - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-list.h b/SecuritySNACCRuntime/c-lib/inc/asn-list.h deleted file mode 100644 index e97db18b..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-list.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_list.h - * - * --------- - * | AsnList | - * | last |-------------------------------------------| - * | curr |--------------------------| | - * | first|--------| | | - * --------- | | | - * V V V - * --------- --------- --------- - * |AsnListNode |AsnListNode |AsnListNode - * | next |---...->| next |--...-->| next |-----|i. - * .i|----| prev |<--...--| prev |<--...--| prev | - * | data | | data | | data | - * --------- --------- --------- - * - * Originally by Murray Goldberg - * Modified for ASN.1 use. - * MS 92 - * Copyright (C) 1992 the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-list.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-list.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:22 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 21:01:14 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 01:40:22 rj - * it is unwise to #define unbalanced if()s! (fixed.) - * three declarations added. - * - * Revision 1.1 1994/08/28 09:21:30 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_list_h_ -#define _asn_list_h_ - -typedef struct AsnListNode -{ - struct AsnListNode *prev; - struct AsnListNode *next; - void *data; /* this must be the last field of this structure */ -} AsnListNode; - -typedef struct AsnList -{ - AsnListNode *first; - AsnListNode *last; - AsnListNode *curr; - int count; /* number of elements in list */ - int dataSize; /* space required in each node for the data */ -} AsnList; - -#define FOR_EACH_LIST_ELMT( elmt, al)\ - if (!(al))\ - ;\ - else\ - for ((al)->curr = (al)->first; (al)->curr && ((elmt) = (void *)(al)->curr->data); (al)->curr = (al)->curr->next) - -#define FOR_EACH_LIST_ELMT_RVS( elmt, al)\ - if (!(al))\ - ;\ - else\ - for ((al)->curr = (al)->last; (al)->curr && ((elmt) = (void *)(al)->curr->data); (al)->curr = (al)->curr->prev) - - -#define FOR_REST_LIST_ELMT( elmt, al)\ - if (!(al))\ - ;\ - else\ - for (; (al)->curr && ((elmt) = (void *)(al)->curr->data); (al)->curr = (al)->curr->next) - -#define FOR_REST_LIST_ELMT_RVS( elmt, al)\ - if (!(al))\ - ;\ - else\ - for (; ((al)->curr && ((elmt) = (void *)(al)->curr->data); (al)->curr = (al)->curr->prev) - -/* - * The following macros return the pointer stored in the - * data part of the listNode. The do not change the current - * list pointer. - */ -#define CURR_LIST_ELMT( al) ((al)->curr->data) -#define NEXT_LIST_ELMT( al) ((al)->curr->next->data) -#define PREV_LIST_ELMT( al) ((al)->curr->prev->data) -#define LAST_LIST_ELMT( al) ((al)->last->data) -#define FIRST_LIST_ELMT( al) ((al)->first->data) -#define LIST_EMPTY( al) ((al)->count == 0) -#define LIST_COUNT( al) ((al)->count) - -/* - * list nodes are the parts of the list that contain ptrs/data - * to/of the list elmts. - */ -#define CURR_LIST_NODE( al) ((al)->curr) -#define FIRST_LIST_NODE( al) ((al)->first) -#define LAST_LIST_NODE( al) ((al)->last) -#define PREV_LIST_NODE( al) ((al)->curr->prev) -#define NEXT_LIST_NODE( al) ((al)->curr->next) -#define SET_CURR_LIST_NODE( al, listNode) ((al)->curr = (listNode)) - -void AsnListRemove PROTO ((AsnList *)); -void *AsnListAdd PROTO ((AsnList *)); -void *AsnListInsert PROTO ((AsnList *)); -void AsnListInit PROTO ((AsnList *list, int dataSize)); -AsnList *AsnListNew PROTO ((int)); -void *AsnListPrev PROTO ((AsnList *)); -void *AsnListNext PROTO ((AsnList *)); -void *AsnListLast PROTO ((AsnList *)); -void *AsnListFirst PROTO ((AsnList *)); -void *AsnListPrepend PROTO ((AsnList *)); -void *AsnListAppend PROTO ((AsnList *)); -void *AsnListCurr PROTO ((AsnList *)); -int AsnListCount PROTO ((AsnList *)); -AsnList *AsnListConcat PROTO ((AsnList *, AsnList *)); -long int GetAsnListElmtIndex PROTO ((void *elmt,AsnList *list)); -void AsnListFree PROTO (( AsnList *)); -void *GetAsnListElmt PROTO ((AsnList *list, unsigned int index)); - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-null.h b/SecuritySNACCRuntime/c-lib/inc/asn-null.h deleted file mode 100644 index fef03531..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-null.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_null.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-null.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-null.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:16 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:31 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_null_h_ -#define _asn_null_h_ - -typedef char AsnNull; - - -AsnLen BEncAsnNull PROTO ((BUF_TYPE b, AsnNull *data)); - -void BDecAsnNull PROTO ((BUF_TYPE b, AsnNull *result, AsnLen *bytesDecoded, ENV_TYPE env)); - - -/* 'return' length of encoded NULL value, 0 */ -#define BEncAsnNullContent(b, data) 0 - -void BDecAsnNullContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen len, AsnNull *result, AsnLen *bytesDecoded, ENV_TYPE env)); - - /* do nothing */ -#define FreeAsnNull( v) - -void PrintAsnNull PROTO ((FILE *f, AsnNull * b, unsigned short int indent)); - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-octs.h b/SecuritySNACCRuntime/c-lib/inc/asn-octs.h deleted file mode 100644 index 7e49aa3d..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-octs.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_octs.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-octs.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-octs.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 21:01:17 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/12/11 21:49:38 rj - * argument order of BDecAsnOctsContent() fixed. - * - * Revision 1.1 1994/08/28 09:21:32 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -#ifndef _asn_octs_h_ -#define _asn_octs_h_ - -typedef struct AsnOcts -{ - unsigned long int octetLen; - char *octs; -} AsnOcts; - -#define ASNOCTS_PRESENT( aocts) ((aocts)->octs != NULL) - - - -AsnLen BEncAsnOcts PROTO ((BUF_TYPE b, AsnOcts *data)); - -void BDecAsnOcts PROTO ((BUF_TYPE b, AsnOcts *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -AsnLen BEncAsnOctsContent PROTO ((BUF_TYPE b, AsnOcts *octs)); - -void BDecAsnOctsContent PROTO ((BUF_TYPE b, AsnTag tagId, AsnLen len, AsnOcts *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -void FreeAsnOcts PROTO ((AsnOcts *o)); - -void PrintAsnOcts PROTO ((FILE *f, AsnOcts *o, unsigned short int indent)); - -int AsnOctsEquiv PROTO ((AsnOcts *o1, AsnOcts *o2)); - - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-oid.h b/SecuritySNACCRuntime/c-lib/inc/asn-oid.h deleted file mode 100644 index 62bddd94..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-oid.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_oid.h - * - * this file depends on asn_octs.h - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-oid.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-oid.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/27 10:24:00 rj - * minor change to merge with type table code. - * - * Revision 1.1 1994/08/28 09:21:34 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -#ifndef _asn_oid_h_ -#define _asn_oid_h_ - -#include "asn-octs.h" - -typedef AsnOcts AsnOid; /* standard oid type */ - - -#define ASNOID_PRESENT( aoid) ASNOCTS_PRESENT (aoid) - -AsnLen BEncAsnOid PROTO ((BUF_TYPE b, AsnOid *data)); - -void BDecAsnOid PROTO ((BUF_TYPE b, AsnOid *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -#define BEncAsnOidContent( b, oid) BEncAsnOctsContent (b, oid) - - -void BDecAsnOidContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen len, AsnOid *result, AsnLen *bytesDecoded, ENV_TYPE env)); - - -#define FreeAsnOid FreeAsnOcts - -void PrintAsnOid PROTO ((FILE *f, AsnOid *b, unsigned short int indent)); - -#define AsnOidsEquiv( o1, o2) AsnOctsEquiv (o1, o2) - -/* linked oid type that may be easier to use in some circumstances */ -#define NULL_OID_ARCNUM -1 -typedef struct OID -{ - struct OID *next; - long int arcNum; -#if COMPILER || TTBL - struct Value *valueRef; -#endif -} OID; - -AsnLen EncodedOidLen PROTO ((OID *oid)); - -void BuildEncodedOid PROTO ((OID *oid, AsnOid *result)); - -void UnbuildEncodedOid PROTO ((AsnOid *eoid, OID **result)); - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-real.h b/SecuritySNACCRuntime/c-lib/inc/asn-real.h deleted file mode 100644 index 95e0bc06..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-real.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_real.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-real.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-real.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:20 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:18 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:35 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -#ifndef _asn_real_h_ -#define _asn_real_h_ - -typedef double AsnReal; - -extern AsnReal PLUS_INFINITY; -extern AsnReal MINUS_INFINITY; - - -void InitAsnInfinity(); - -AsnLen BEncAsnReal PROTO ((BUF_TYPE b, AsnReal *data)); - -void BDecAsnReal PROTO ((BUF_TYPE b, AsnReal *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -AsnLen BEncAsnRealContent PROTO ((BUF_TYPE b, AsnReal *data)); - -void BDecAsnRealContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen len, AsnReal *result, AsnLen *bytesDecoded, ENV_TYPE env)); - -/* do nothing */ -#define FreeAsnReal( v) - -void PrintAsnReal PROTO ((FILE *f, AsnReal *b, unsigned short int indent)); - -#endif diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-tag.h b/SecuritySNACCRuntime/c-lib/inc/asn-tag.h deleted file mode 100644 index 292480c4..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-tag.h +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_tag.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * INSERT_VDA_COMMENTS - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/asn-tag.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-tag.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:21 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/27 08:44:15 rj - * cpp macro TBL changed to TTBL since some type table code uses TBL as a type name. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1995/02/18 16:22:23 rj - * let cpp choose a 32 bit integer type. - * - * Revision 1.1 1994/08/28 09:21:37 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_tag_h_ -#define _asn_tag_h_ - -#if SIZEOF_INT == 4 -# define UL unsigned int -#else -# if SIZEOF_LONG == 4 -# define UL unsigned long -# else -# if SIZEOF_SHORT == 4 -# define UL unsigned short -# endif -# endif -#endif -#ifndef UL - #error "can't find integer type which is 4 bytes in size" -#endif -typedef UL AsnTag; - -/* Tag Id's byte length */ -#define TB sizeof (AsnTag) - -/* - * The MAKE_TAG_ID macro generates the TAG_ID rep for the - * the given class/form/code (rep'd in long integer form) - * if the class/form/code are constants the compiler (should) - * calculate the tag completely --> zero runtime overhead. - * This is good for efficiently comparing tags in switch statements - * (decoding) etc. because run-time bit fiddling (eliminated) minimized - */ -#ifndef _IBM_ENC_ -#define MAKE_TAG_ID( cl, fm, cd)\ - ((((UL)(cl)) << ((TB -1) * 8)) | (((UL)(fm)) << ((TB -1) * 8)) | (MAKE_TAG_ID_CODE (((UL)(cd))))) -#else -#define MAKE_TAG_ID( cl, fm, cd)\ - ((MAKE_TAG_ID_CODE (cd)) | (cl << ((TB -1) * 8)) | (fm << ((TB -1) * 8))) -#endif /* _IBM_ENC_ */ - -#define MAKE_TAG_ID_CODE(cd)\ -( (cd < 31) ? (MAKE_TAG_ID_CODE1 (cd)):\ - ((cd < 128)? (MAKE_TAG_ID_CODE2 (cd)):\ - ((cd < 16384)? (MAKE_TAG_ID_CODE3 (cd)):\ - (MAKE_TAG_ID_CODE4 (cd))))) - -#define MAKE_TAG_ID_CODE1(cd) (cd << ((TB -1) * 8)) -#define MAKE_TAG_ID_CODE2(cd) ((31 << ((TB -1) * 8)) | (cd << ((TB-2) * 8))) -#define MAKE_TAG_ID_CODE3(cd) ((31 << ((TB -1) * 8))\ - | ((cd & 0x3f80) << 9)\ - | ( 0x0080 << ((TB-2) * 8))\ - | ((cd & 0x007F) << ((TB-3)* 8))) - -#define MAKE_TAG_ID_CODE4(cd) ((31 << ((TB -1) * 8))\ - | ((cd & 0x1fc000) << 2)\ - | ( 0x0080 << ((TB-2) * 8))\ - | ((cd & 0x3f80) << 1)\ - | ( 0x0080 << ((TB-3) * 8))\ - | ((cd & 0x007F) << ((TB-4)*8))) - - - -typedef enum -{ - ANY_CLASS = -2, - NULL_CLASS = -1, - UNIV = 0, - APPL = (1 << 6), - CNTX = (2 << 6), - PRIV = (3 << 6) -} BER_CLASS; - -typedef enum -{ - ANY_FORM = -2, - NULL_FORM = -1, - PRIM = 0, - CONS = (1 << 5) -} BER_FORM; - - -typedef enum -{ - NO_TAG_CODE = 0, - BOOLEAN_TAG_CODE = 1, - INTEGER_TAG_CODE, - BITSTRING_TAG_CODE, - OCTETSTRING_TAG_CODE, - NULLTYPE_TAG_CODE, - OID_TAG_CODE, - OD_TAG_CODE, - EXTERNAL_TAG_CODE, - REAL_TAG_CODE, - ENUM_TAG_CODE, - SEQ_TAG_CODE = 16, - SET_TAG_CODE, - NUMERICSTRING_TAG_CODE, - PRINTABLESTRING_TAG_CODE, - TELETEXSTRING_TAG_CODE, - VIDEOTEXSTRING_TAG_CODE, - IA5STRING_TAG_CODE, - UTCTIME_TAG_CODE, - GENERALIZEDTIME_TAG_CODE, - GRAPHICSTRING_TAG_CODE, - VISIBLESTRING_TAG_CODE, - -#ifndef VDADER_RULES - - GENERALSTRING_TAG_CODE - -#else - GENERALSTRING_TAG_CODE, - UNIVERSALSTRING_TAG_CODE = 28, - BMPSTRING_TAG_CODE = 30 -#endif - -} BER_UNIV_CODE; - -#define TT61STRING_TAG_CODE TELETEXSTRING_TAG_CODE -#define ISO646STRING_TAG_CODE VISIBLESTRING_TAG_CODE - - -/* - * the TAG_ID_[CLASS/FORM/CODE] macros are not - * super fast - try not to use during encoding/decoding - */ -#define TAG_ID_CLASS( tid) ((tid & (0xC0 << ((TB-1) *8))) >> ((TB -1) * 8)) -#define TAG_ID_FORM( tid) ((tid & (0x20 << ((TB-1) *8))) >> ((TB -1) * 8)) - -/* - * TAG_IS_CONS evaluates to true if the given AsnTag type - * tag has the constructed bit set. - */ -#define TAG_IS_CONS( tag) ((tag) & (CONS << ((TB-1) *8))) -#define CONSIFY( tag) (tag | (CONS << ((TB-1) *8))) -#define DECONSIFY( tag) (tag & ~(CONS << ((TB-1) *8))) - - -/* not a valid tag - usually the first EOC octet */ -#define EOC_TAG_ID 0 - - - -/* - * tag encoders. given constant values for class form & - * code in the source, these can be optimized by the compiler - * (e.g. do the shifts and bitwise ands & ors etc) - * - * This is the prototype that the following BEncTag routines - * would use if they were routines. They return the number of - * octets written to the buffer. - * - * - *AsnLen BEncTag PROTO ((BUF_TYPE b, BER_CLASS class, BER_FORM form, int code)); - * - * WARNING: these are FRAGILE macros (What people will do for performance!) - * Be careful of situations like: - * if (foo) - * encLen += BEncTag1 (...); - * Use {}'s to enclose any ASN.1 related routine that you are - * treating as a single statement in your code. - */ -#define BEncTag1( b, class, form, code)\ - 1;\ - BufPutByteRvs (b, (class) | (form) | (code)); - -#define BEncTag2( b, class, form, code)\ - 2;\ - BufPutByteRvs (b, code);\ - BufPutByteRvs (b, (class) | (form) | 31); - -#define BEncTag3( b, class, form, code)\ - 3;\ - BufPutByteRvs (b, (code) & 0x7F);\ - BufPutByteRvs (b, 0x80 | ((code) >> 7));\ - BufPutByteRvs (b, (class) | (form) | 31); - -#define BEncTag4( b, class, form, code)\ - 4;\ - BufPutByteRvs (b, (code) & 0x7F);\ - BufPutByteRvs (b, 0x80 | ((code) >> 7));\ - BufPutByteRvs (b, 0x80 | ((code) >> 14));\ - BufPutByteRvs (b, (class) | (form) | 31); - -#define BEncTag5( b, class, form, code)\ - 5;\ - BufPutByteRvs (b, (code) & 0x7F);\ - BufPutByteRvs (b, 0x80 | ((code) >> 7));\ - BufPutByteRvs (b, 0x80 | ((code) >> 14));\ - BufPutByteRvs (b, 0x80 | ((code) >> 21));\ - BufPutByteRvs (b, (class) | (form) | 31); - - -/* the following are protos for routines ins asn_tag.c */ - - -AsnTag BDecTag PROTO ((BUF_TYPE b, AsnLen *bytesDecoded, ENV_TYPE env)); -#if TTBL -AsnTag PeekTag PROTO ((BUF_TYPE b, ENV_TYPE env)); -#endif - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/asn-useful.h b/SecuritySNACCRuntime/c-lib/inc/asn-useful.h deleted file mode 100644 index d11f83b0..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/asn-useful.h +++ /dev/null @@ -1,325 +0,0 @@ -/* - * asn-useful.h - * - * "ASN-USEFUL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Tue Mar 19 07:24:46 2002 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _asn_useful_h_ -#define _asn_useful_h_ - - - - -typedef AsnOcts ObjectDescriptor; /* [UNIVERSAL 7] IMPLICIT OCTET STRING */ - -#define BEncObjectDescriptorContent BEncAsnOctsContent - -#define BDecObjectDescriptorContent BDecAsnOctsContent - -#define PrintObjectDescriptor PrintAsnOcts - -#define FreeObjectDescriptor FreeAsnOcts - - - - -typedef AsnOcts UTF8String; /* [UNIVERSAL 12] IMPLICIT OCTET STRING */ - -AsnLen BEncUTF8String PROTO ((BUF_TYPE b, UTF8String *v)); - -void BDecUTF8String PROTO ((BUF_TYPE b, UTF8String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncUTF8StringContent BEncAsnOctsContent - -#define BDecUTF8StringContent BDecAsnOctsContent - -#define PrintUTF8String PrintAsnOcts - -#define FreeUTF8String FreeAsnOcts - - - - -typedef AsnOcts NumericString; /* [UNIVERSAL 18] IMPLICIT OCTET STRING */ - -AsnLen BEncNumericString PROTO ((BUF_TYPE b, NumericString *v)); - -void BDecNumericString PROTO ((BUF_TYPE b, NumericString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncNumericStringContent BEncAsnOctsContent - -#define BDecNumericStringContent BDecAsnOctsContent - -#define PrintNumericString PrintAsnOcts - -#define FreeNumericString FreeAsnOcts - - - - -typedef AsnOcts PrintableString; /* [UNIVERSAL 19] IMPLICIT OCTET STRING */ - -AsnLen BEncPrintableString PROTO ((BUF_TYPE b, PrintableString *v)); - -void BDecPrintableString PROTO ((BUF_TYPE b, PrintableString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncPrintableStringContent BEncAsnOctsContent - -#define BDecPrintableStringContent BDecAsnOctsContent - -#define PrintPrintableString PrintAsnOcts - -#define FreePrintableString FreeAsnOcts - - - - -typedef AsnOcts TeletexString; /* [UNIVERSAL 20] IMPLICIT OCTET STRING */ - -AsnLen BEncTeletexString PROTO ((BUF_TYPE b, TeletexString *v)); - -void BDecTeletexString PROTO ((BUF_TYPE b, TeletexString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncTeletexStringContent BEncAsnOctsContent - -#define BDecTeletexStringContent BDecAsnOctsContent - -#define PrintTeletexString PrintAsnOcts - -#define FreeTeletexString FreeAsnOcts - - - - -typedef AsnOcts T61String; /* [UNIVERSAL 20] IMPLICIT OCTET STRING */ - -AsnLen BEncT61String PROTO ((BUF_TYPE b, T61String *v)); - -void BDecT61String PROTO ((BUF_TYPE b, T61String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncT61StringContent BEncAsnOctsContent - -#define BDecT61StringContent BDecAsnOctsContent - -#define PrintT61String PrintAsnOcts - -#define FreeT61String FreeAsnOcts - - - - -typedef AsnOcts VideotexString; /* [UNIVERSAL 21] IMPLICIT OCTET STRING */ - -AsnLen BEncVideotexString PROTO ((BUF_TYPE b, VideotexString *v)); - -void BDecVideotexString PROTO ((BUF_TYPE b, VideotexString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncVideotexStringContent BEncAsnOctsContent - -#define BDecVideotexStringContent BDecAsnOctsContent - -#define PrintVideotexString PrintAsnOcts - -#define FreeVideotexString FreeAsnOcts - - - - -typedef AsnOcts IA5String; /* [UNIVERSAL 22] IMPLICIT OCTET STRING */ - -AsnLen BEncIA5String PROTO ((BUF_TYPE b, IA5String *v)); - -void BDecIA5String PROTO ((BUF_TYPE b, IA5String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncIA5StringContent BEncAsnOctsContent - -#define BDecIA5StringContent BDecAsnOctsContent - -#define PrintIA5String PrintAsnOcts - -#define FreeIA5String FreeAsnOcts - - - - -typedef AsnOcts GraphicString; /* [UNIVERSAL 25] IMPLICIT OCTET STRING */ - -AsnLen BEncGraphicString PROTO ((BUF_TYPE b, GraphicString *v)); - -void BDecGraphicString PROTO ((BUF_TYPE b, GraphicString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGraphicStringContent BEncAsnOctsContent - -#define BDecGraphicStringContent BDecAsnOctsContent - -#define PrintGraphicString PrintAsnOcts - -#define FreeGraphicString FreeAsnOcts - - - - -typedef AsnOcts VisibleString; /* [UNIVERSAL 26] IMPLICIT OCTET STRING */ - -AsnLen BEncVisibleString PROTO ((BUF_TYPE b, VisibleString *v)); - -void BDecVisibleString PROTO ((BUF_TYPE b, VisibleString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncVisibleStringContent BEncAsnOctsContent - -#define BDecVisibleStringContent BDecAsnOctsContent - -#define PrintVisibleString PrintAsnOcts - -#define FreeVisibleString FreeAsnOcts - - - - -typedef AsnOcts ISO646String; /* [UNIVERSAL 26] IMPLICIT OCTET STRING */ - -AsnLen BEncISO646String PROTO ((BUF_TYPE b, ISO646String *v)); - -void BDecISO646String PROTO ((BUF_TYPE b, ISO646String *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncISO646StringContent BEncAsnOctsContent - -#define BDecISO646StringContent BDecAsnOctsContent - -#define PrintISO646String PrintAsnOcts - -#define FreeISO646String FreeAsnOcts - - - - -typedef AsnOcts GeneralString; /* [UNIVERSAL 27] IMPLICIT OCTET STRING */ - -AsnLen BEncGeneralString PROTO ((BUF_TYPE b, GeneralString *v)); - -void BDecGeneralString PROTO ((BUF_TYPE b, GeneralString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGeneralStringContent BEncAsnOctsContent - -#define BDecGeneralStringContent BDecAsnOctsContent - -#define PrintGeneralString PrintAsnOcts - -#define FreeGeneralString FreeAsnOcts - - - - -typedef AsnOcts UTCTime; /* [UNIVERSAL 23] IMPLICIT OCTET STRING */ - -AsnLen BEncUTCTime PROTO ((BUF_TYPE b, UTCTime *v)); - -void BDecUTCTime PROTO ((BUF_TYPE b, UTCTime *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncUTCTimeContent BEncAsnOctsContent - -#define BDecUTCTimeContent BDecAsnOctsContent - -#define PrintUTCTime PrintAsnOcts - -#define FreeUTCTime FreeAsnOcts - - - - -typedef AsnOcts GeneralizedTime; /* [UNIVERSAL 24] IMPLICIT OCTET STRING */ - -AsnLen BEncGeneralizedTime PROTO ((BUF_TYPE b, GeneralizedTime *v)); - -void BDecGeneralizedTime PROTO ((BUF_TYPE b, GeneralizedTime *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncGeneralizedTimeContent BEncAsnOctsContent - -#define BDecGeneralizedTimeContent BDecAsnOctsContent - -#define PrintGeneralizedTime PrintAsnOcts - -#define FreeGeneralizedTime FreeAsnOcts - - - - -typedef AsnOcts UniversalString; /* [UNIVERSAL 28] IMPLICIT OCTET STRING */ - -AsnLen BEncUniversalString PROTO ((BUF_TYPE b, UniversalString *v)); - -void BDecUniversalString PROTO ((BUF_TYPE b, UniversalString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncUniversalStringContent BEncAsnOctsContent - -#define BDecUniversalStringContent BDecAsnOctsContent - -#define PrintUniversalString PrintAsnOcts - -#define FreeUniversalString FreeAsnOcts - - - - -typedef AsnOcts BMPString; /* [UNIVERSAL 30] IMPLICIT OCTET STRING */ - -AsnLen BEncBMPString PROTO ((BUF_TYPE b, BMPString *v)); - -void BDecBMPString PROTO ((BUF_TYPE b, BMPString *result, AsnLen *bytesDecoded, ENV_TYPE env)); -#define BEncBMPStringContent BEncAsnOctsContent - -#define BDecBMPStringContent BDecAsnOctsContent - -#define PrintBMPString PrintAsnOcts - -#define FreeBMPString FreeAsnOcts - - - - -typedef struct EXTERNALChoice /* CHOICE */ -{ - enum EXTERNALChoiceChoiceId - { - EXTERNALCHOICE_SINGLE_ASN1_TYPE, - EXTERNALCHOICE_OCTET_ALIGNED, - EXTERNALCHOICE_ARBITRARY - } choiceId; - union EXTERNALChoiceChoiceUnion - { - AsnOcts* single_ASN1_type; /* [0] OCTET STRING */ - AsnOcts* octet_aligned; /* [1] IMPLICIT OCTET STRING */ - AsnBits* arbitrary; /* [2] IMPLICIT BIT STRING */ - } a; -} EXTERNALChoice; - -AsnLen BEncEXTERNALChoiceContent PROTO ((BUF_TYPE b, EXTERNALChoice *v)); - -void BDecEXTERNALChoiceContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, EXTERNALChoice *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintEXTERNALChoice PROTO ((FILE* f, EXTERNALChoice *v, unsigned short int indent)); -void FreeEXTERNALChoice PROTO ((EXTERNALChoice *v)); - - - - - -typedef struct EXTERNAL /* [UNIVERSAL 8] IMPLICIT SEQUENCE */ -{ - AsnOid direct_reference; /* OBJECT IDENTIFIER OPTIONAL */ - AsnInt* indirect_reference; /* INTEGER OPTIONAL */ - ObjectDescriptor data_value_descriptor; /* ObjectDescriptor OPTIONAL */ - struct EXTERNALChoice* encoding; /* EXTERNALChoice */ -} EXTERNAL; - -AsnLen BEncEXTERNAL PROTO ((BUF_TYPE b, EXTERNAL *v)); - -void BDecEXTERNAL PROTO ((BUF_TYPE b, EXTERNAL *result, AsnLen *bytesDecoded, ENV_TYPE env)); -AsnLen BEncEXTERNALContent PROTO ((BUF_TYPE b, EXTERNAL *v)); - -void BDecEXTERNALContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, EXTERNAL *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintEXTERNAL PROTO ((FILE* f, EXTERNAL *v, unsigned short int indent)); -void FreeEXTERNAL PROTO ((EXTERNAL *v)); - - - - - - -#endif /* conditional include of asn-useful.h */ diff --git a/SecuritySNACCRuntime/c-lib/inc/exp-buf.h b/SecuritySNACCRuntime/c-lib/inc/exp-buf.h deleted file mode 100644 index fa6579f4..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/exp-buf.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * exp_buf.h - read/write/alloc/free routines for a simple buffer structure - * - * MACROS are gross but execution speed is important - * - * NOTE: replacing the malloc and free with a allocs/frees - * from/to buffer pools or similar tuned/fixed size - * mem mgmt will improve performance. - * - * You should tune the buffer management to your environment - * for best results - * - * MS 91 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/exp-buf.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: exp-buf.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:21 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/27 08:54:45 rj - * functions used by gen-bufs or type tables merged. - * - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:40 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _exp_buf_h_ -#define _exp_buf_h_ - -typedef struct ExpBuf -{ - char *dataStart; /* points to first valid data byte */ - /* when empty, 1 byte past blk end (rvs write)*/ - char *dataEnd; /* pts to first byte AFTER last valid data byte*/ - char *curr; /* current location to read form */ - /* points to next byte to read */ - struct ExpBuf *next; /* next buf (NULL if no next buffer)*/ - struct ExpBuf *prev; /* prev buf (NULL if no prev buffer)*/ - char *blkStart; /* points to first byte of the blk */ - char *blkEnd; /* points the first byte AFTER blks last byte */ - int readError; /* non-zero is attempt to read past end of data*/ - int writeError;/* non-zero is attempt write fails (no mor bufs)*/ -} ExpBuf; - - - -/* init, alloc and free routines */ -#if defined (DEBUG) /* use fcns when debugging/macros later */ || defined (USE_GEN_BUF) - -#ifdef USE_GEN_BUF -void PutExpBufInGenBuf PROTO ((ExpBuf *eb,GenBuf *gb)); -#endif - -void ExpBufInit PROTO ((unsigned long dataBlkSize)); -ExpBuf *ExpBufAllocBuf(); -void ExpBufFreeBuf PROTO ((ExpBuf *ptr)); -char *ExpBufAllocData(); -void ExpBufFreeData PROTO ((char *ptr)); -void ExpBufFreeBufAndData PROTO (( ExpBuf *b)); - -ExpBuf *ExpBufNext PROTO ((ExpBuf *b)); -ExpBuf *ExpBufPrev PROTO ((ExpBuf *b)); -void ExpBufResetInReadMode PROTO ((ExpBuf *b)); -void ExpBufResetInWriteRvsMode PROTO ((ExpBuf *b)); - -int ExpBufAtEod PROTO ((ExpBuf *b)); -int ExpBufFull PROTO ((ExpBuf *b)); -int ExpBufHasNoData PROTO ((ExpBuf *b)); -unsigned long ExpBufDataSize PROTO ((ExpBuf *b)); -unsigned long ExpBufDataBlkSize PROTO ((ExpBuf *b)); -char *ExpBufDataPtr PROTO ((ExpBuf *b)); - -#else - -extern unsigned long expBufDataBlkSizeG; - -#define ExpBufInit( size) expBufDataBlkSizeG = size; -#define ExpBufAllocBuf() ((ExpBuf *)malloc (sizeof (ExpBuf))) -#define ExpBufFreeBuf( ptr) free (ptr) -#define ExpBufAllocData() ((void *)malloc (expBufDataBlkSizeG)) -#define ExpBufFreeData( ptr) free (ptr) -#define ExpBufFreeBufAndData( b) { ExpBufFreeData ((b)->blkStart); ExpBufFreeBuf (b); } -#define ExpBufNext( b) ((b)->next) -#define ExpBufPrev( b) ((b)->prev) -#define ExpBufResetInReadMode( b) { (b)->curr = (b)->dataStart; (b)->readError = 0; (b)->writeError = 1; } -#define ExpBufResetInWriteRvsMode( b) { (b)->dataStart = (b)->dataEnd = (b)->blkEnd; (b)->writeError = 0; (b)->readError = 1; } - -/* ExpBufAtEod only valid during reads (fwd) */ -#define ExpBufAtEod( b) ((b)->curr == (b)->dataEnd) - -/* ExpBufFull only valid during write (reverse) */ -#define ExpBufFull( b) ((b)->dataStart == (b)->blkStart) -#define ExpBufHasNoData( b) ((b)->dataStart == (b)->dataEnd) -#define ExpBufDataSize( b) ((b)->dataEnd - (b)->dataStart) -#define ExpBufDataBlkSize( b) ((b)->blkEnd - (b)->blkStart) -#define ExpBufDataPtr( b) (ExpBufHasNoData (b)? NULL: (b)->dataStart) - -#endif /* DEBUG || USE_GEN_BUF */ - -#ifdef USE_GEN_BUF -int ExpBufReadError PROTO ((ExpBuf **b)); -int ExpBufWriteError PROTO ((ExpBuf **b)); -#else -#define ExpBufReadError( b) ((*b)->readError) -#define ExpBufWriteError( b) ((*b)->writeError) -#endif - -ExpBuf *ExpBufAllocBufAndData(); -void ExpBufInstallDataInBuf PROTO ((ExpBuf *b, char *data, unsigned long int len)); -void ExpBufFreeBufAndDataList PROTO (( ExpBuf *b)); -ExpBuf *ExpBufListLastBuf PROTO ((ExpBuf *b)); -ExpBuf *ExpBufListFirstBuf PROTO ((ExpBuf *b)); - -void ExpBufCopyToFile PROTO ((ExpBuf *b, FILE *f)); - -/* reading and writing routines */ - -void ExpBufSkip PROTO (( ExpBuf**, unsigned long len)); -int ExpBufCopy PROTO (( char *dst, ExpBuf **b, unsigned long len)); -unsigned char ExpBufPeekByte PROTO (( ExpBuf **b)); -#if TTBL -int ExpBufPeekCopy PROTO ((char *dst, ExpBuf **b, unsigned long len)); -char *ExpBufPeekSeg PROTO ((ExpBuf **b, unsigned long *len)); -#endif -char *ExpBufGetSeg PROTO ((ExpBuf **b, unsigned long *len)); -void ExpBufPutSegRvs PROTO ((ExpBuf **b, char *data, unsigned long len)); -unsigned char ExpBufGetByte PROTO ((ExpBuf **b)); -void ExpBufPutByteRvs PROTO ((ExpBuf **b, unsigned char byte)); - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/gen-buf.h b/SecuritySNACCRuntime/c-lib/inc/gen-buf.h deleted file mode 100644 index cf5633e0..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/gen-buf.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * gen_buf.h - flexible (runtime configurable) buffer mgmt stuff. - * - * These are somewhat slower than the direct approach used in - * the compiled stuff. Since tables are around 4x slower, - * the flexibility of the GenBufs can be justified. This - * also allows one enc/dec library to support all buffer types. - * - * MS 93 - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - */ - -#if USE_GEN_BUF - -#ifndef _gen_buf_h_ -#define _gen_buf_h_ - -/* - * These are the standard buffer routines that the lib - * routines need. Note that the Peek routines have be - * added to the standard list - they are necessary - * to nicely support the table oriented decoder. - * The "void *b" param's real type will be the buffer - * type that is used inside the GenBuf - * (ie SBuf * or ExpBuf ** have been defined). - * - * Note that macros can not be used for these standard functions - * because the GenBuf keeps a pointer to these routines. - * Thus the exp_buf.[ch] and sbuf.[ch] files are somewhat - * differnt than those in snacc/c_lib and snacc/c_include - * - */ - -typedef unsigned char (*BufGetByteFcn) PROTO ((void *b)); -typedef unsigned char *(*BufGetSegFcn) PROTO ((void *b, unsigned long int *lenPtr)); -typedef long int (*BufCopyFcn) PROTO ((char *dst, void *b, unsigned long int len)); -typedef void (*BufSkipFcn) PROTO ((void *b, unsigned long int len)); -typedef unsigned char (*BufPeekByteFcn) PROTO ((void *b)); -typedef unsigned char *(*BufPeekSegFcn) PROTO ((void *b, unsigned long int lenPtr)); -typedef long int (*BufPeekCopyFcn) PROTO ((char *dst, void *b, unsigned long int len)); -typedef void (*BufPutByteRvsFcn) PROTO ((void *b, unsigned char byte)); -typedef void (*BufPutSegRvsFcn) PROTO ((void *b, char *data, unsigned long int len)); -typedef int (*BufReadErrorFcn) PROTO ((void *b)); -typedef int (*BufWriteErrorFcn) PROTO ((void *b)); - - -typedef struct GenBuf -{ - BufGetByteFcn getByte; - BufGetSegFcn getSeg; - BufCopyFcn copy; - BufSkipFcn skip; - BufPeekByteFcn peekByte; - BufPeekSegFcn peekSeg; - BufPeekCopyFcn peekCopy; - BufPutByteRvsFcn putByteRvs; - BufPutSegRvsFcn putSegRvs; - BufReadErrorFcn readError; - BufWriteErrorFcn writeError; - void *bufInfo; - void *spare; /* hack to save space for ExpBuf ** type */ -} GenBuf; - - -#define GenBufGetByte( b) ((b)->getByte (b->bufInfo)) -#define GenBufGetSeg( b, lenPtr) ((b)->getSeg (b->bufInfo, lenPtr)) -#define GenBufCopy( dst, b, len) ((b)->copy (dst, b->bufInfo, len)) -#define GenBufSkip( b, len) ((b)->skip (b->bufInfo,len)) -#define GenBufPeekByte( b) ((b)->peekByte (b->bufInfo)) -#define GenBufPeekSeg( b, lenPtr) ((b)->peekSeg (b->bufInfo, lenPtr)) -#define GenBufPeekCopy( dst, b, len) ((b)->peekCopy (dst, b->bufInfo, len)) -#define GenBufPutByteRvs( b, byte) ((b)->putByteRvs (b->bufInfo, byte)) -#define GenBufPutSegRvs( b, data, len) ((b)->putSegRvs (b->bufInfo, data, len)) -#define GenBufReadError( b) ((b)->readError (b->bufInfo)) -#define GenBufWriteError( b) ((b)->writeError (b->bufInfo)) - - -#endif /* _gen_buf_h_ conditional include */ - -#endif /* USE_GEN_BUF */ diff --git a/SecuritySNACCRuntime/c-lib/inc/hash.h b/SecuritySNACCRuntime/c-lib/inc/hash.h deleted file mode 100644 index 1dc64c1f..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/hash.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * hash.h - * - * Based on hashing stuff from UBC Raven Code (Terry Coatta & Don Acton) - * - * MS 92 - * Copyright (C) 1992 the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/hash.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: hash.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:21 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1997/02/28 13:39:49 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.2 1995/07/24 21:01:19 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:41 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_hash_h_ -#define _asn_hash_h_ - -#define TABLESIZE 256 -#define INDEXMASK 0xFF -#define INDEXSHIFT 8 - -typedef void *Table[TABLESIZE]; - -typedef unsigned int Hash; - -typedef struct HashSlot -{ - int leaf; - Hash hash; - void *value; - Table *table; -} HashSlot; - -Hash MakeHash PROTO ((char *str, unsigned long int len)); - -Table *InitHash(); - -int Insert PROTO ((Table *table, void *element, Hash hash)); - -int CheckFor PROTO ((Table *table, Hash hash)); - -int CheckForAndReturnValue PROTO ((Table *table, Hash hash, void **value)); - - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/mem.h b/SecuritySNACCRuntime/c-lib/inc/mem.h deleted file mode 100644 index 982e25b5..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/mem.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/core/mem.h - * - * MS 91/08/03 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/mem.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: mem.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:21 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1994/09/01 00:40:32 rj - * snacc_config.h's last macro, MT ( ) got here. - * - * Revision 1.1 1994/08/28 09:49:22 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _snacc_mem_h_ -#define _snacc_mem_h_ - -void *Malloc PROTO ((int size)); -void *Realloc PROTO ((void *ptr, int newsize)); -void Free PROTO ((void *ptr)); - -/* malloc type */ -#define MT( type) (type *)Malloc (sizeof (type)) - -#endif diff --git a/SecuritySNACCRuntime/c-lib/inc/min-buf.h b/SecuritySNACCRuntime/c-lib/inc/min-buf.h deleted file mode 100644 index d72a2df7..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/min-buf.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * .../c-lib/inc/min-buf.h - trivial buffer routines. - * only use these for - * encoding - if you know you 'buffer' is big enough - * to hold the encoded value - * - * decoding - if you know that the encoding is error - * free. - * - * - * The minimal buffer is simply a block of mem referenced - * by a char **(ie BUF_TYPE char**). These are very efficient - * but should only be used when it is safe (see above) or you're - * willing to risk reading past the end of the buffer or writing - * 'past' the beginning (segmentation faults/bus errors etc). - * - * No checks for reading or writing past the buffer are done. - * every operation is assumed to succeed. - * MS 92 - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/min-buf.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: min-buf.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:21 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:21 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:42 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _min_buf_h_ -#define _min_buf_h_ - -#define MinBufGetByte(b)\ - (unsigned char)(*((*(b))++)) - -#define MinBufGetSeg( b, lenPtr)\ - *(b);\ - (*b) += *lenPtr; - -#define MinBufCopy( dst, b, len)\ - memcpy ((dst), *(b), (len));\ - (*(b)) += (len); - -#define MinBufSkip( b, len) ((*(b)) += len) - -#define MinBufPeekByte( b) (**(b)) - - -#define MinBufPutByteRvs( b, byte)\ - (*(--(*(b))) = (byte)) - -#define MinBufPutSegRvs( b, data, len)\ - ((*(b)) = (*(b)) - (len));\ - memcpy (*(b), (data), (len)); - - -#define MinBufReadError( b) 0 /* always false */ -#define MinBufWriteError( b) 0 /* always false */ - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/nibble-alloc.h b/SecuritySNACCRuntime/c-lib/inc/nibble-alloc.h deleted file mode 100644 index 5a9937f1..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/nibble-alloc.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * nibble_alloc.h - handles buffer allocation - * MS 91 - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/nibble-alloc.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: nibble-alloc.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:21 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:22 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:21:43 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _nibble_alloc_h_ -#define _nibble_alloc_h_ - -typedef struct NibbleBuf -{ - char *start; - char *end; - char *curr; - struct NibbleBuf *next; -} NibbleBuf; - - -typedef struct NibbleMem -{ - NibbleBuf *firstNibbleBuf; - NibbleBuf *currNibbleBuf; - unsigned long int incrementSize; -} NibbleMem; - - - -void InitNibbleMem PROTO ((unsigned long int initialSize, unsigned long int incrementSize)); - -void ShutdownNibbleMem(); - -void ServiceNibbleFault PROTO ((unsigned long int size)); - -void *NibbleAlloc PROTO ((unsigned long int size)); - -void ResetNibbleMem(); - - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/print.h b/SecuritySNACCRuntime/c-lib/inc/print.h deleted file mode 100644 index e109c073..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/print.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * print.h - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/print.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: print.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:21 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:23 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:45:38 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _snaccc_print_h_ -#define _snaccc_print_h_ - -extern unsigned short int stdIndentG; - -void Indent PROTO ((FILE *f, unsigned short int i)); - - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/sbuf.h b/SecuritySNACCRuntime/c-lib/inc/sbuf.h deleted file mode 100644 index 608b163c..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/sbuf.h +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * sbuf.h - a buffer consisting of one contiguous block - * that checks for read and write range errors. - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/sbuf.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: sbuf.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:21 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/27 08:54:46 rj - * functions used by gen-bufs or type tables merged. - * - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:45:39 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifndef _asn_buf_h_ -#define _asn_buf_h_ - -typedef struct SBuf -{ - char *dataStart; /* byte last written (or end) */ - char *dataEnd; /* ptr to first byte after last valid data byte */ - char *blkStart; /* ptr to first byte of the buffer */ - char *blkEnd; /* ptr to first byte past end of the buffer */ - char *readLoc; /* next byte to read (or end) */ - int writeError; /* whether write error occurred */ - int readError; /* whether read error occurred */ -} SBuf; - -#ifdef USE_GEN_BUF - -/* use functions (-> src/sbuf.c) instead of cpp macros */ - -void PutSBufInGenBuf PROTO ((SBuf *sb, GenBuf *gb)); -void SBufInit PROTO ((SBuf *b, char *data, long int dataLen)); -void SBufResetInReadMode PROTO ((SBuf *b)); -void SBufResetInWriteRvsMode PROTO ((SBuf *b)); -void SBufInstallData PROTO ((SBuf *b, char *data, long int dataLen)); -long int SBufDataLen PROTO ((SBuf *b)); -char *SBufDataPtr PROTO ((SBuf *b)); -long int SBufBlkLen PROTO ((SBuf *b)); -char *SBufBlkPtr PROTO ((SBuf *b)); -int SBufEod PROTO ((SBuf *b)); -int SBufReadError PROTO ((SBuf *b)); -int SBufWriteError PROTO ((SBuf *b)); -void SBufSkip PROTO ((SBuf *b, long int skipLen)); -void SBufCopy PROTO ((char *dst, SBuf *b, long int copyLen)); -unsigned char SBufPeekByte PROTO ((SBuf *b)); -#if TTBL -char *SBufPeekSeg PROTO ((SBuf *b, long int *lenPtr)); -void SBufPeekCopy PROTO ((char *dst, SBuf *b, long int copyLen)); -#endif -char *SBufGetSeg PROTO ((SBuf *b,long int *lenPtr)); -void SBufPutSegRvs PROTO ((SBuf *b, char *seg, long int segLen)); -unsigned char SBufGetByte PROTO ((SBuf *b)); -void SBufPutByteRvs PROTO ((SBuf *b, unsigned char byte)); - -#else - -/* initializes a buffer into an 'empty' state */ -#define SBufInit(b, data, dataLen)\ -{ (b)->readError = (b)->writeError = 1;\ - (b)->blkStart = data;\ - (b)->blkEnd = data + dataLen;\ - (b)->dataStart = (b)->dataEnd = (b)->readLoc = (b)->blkEnd;\ -} - -#define SBufResetInReadMode(b)\ -{ (b)->readLoc = (b)->dataStart;\ - (b)->readError = 0;\ - (b)->writeError = 1;\ -} - -#define SBufResetInWriteRvsMode(b)\ -{ (b)->dataStart = (b)->dataEnd = (b)->blkEnd;\ - (b)->writeError = 0;\ - (b)->readError = 1;\ -} - -/* installs given block of data into a buffer and sets it up for reading */ -#define SBufInstallData(b, data, dataLen)\ - SBufInit (b, data, dataLen);\ - (b)->dataStart = (b)->blkStart;\ - SBufResetInReadMode (b); - -/* returns the number of bytes in the data portion */ -#define SBufDataLen(b)\ - ((b)->dataEnd - (b)->dataStart) - -/* returns the pointer to the first data byte */ -#define SBufDataPtr(b)\ - ((b)->dataStart) - -/* returns the size of block, the maximum size for data */ -#define SBufBlkLen(b)\ - ((b)->blkEnd - (b)->blkStart) - -/* returns a pointer to the first byte of the block */ -#define SBufBlkPtr(b)\ - ((b)->blkStart) - -/* returns true if there is no more data to be read in the SBuf */ -#define SBufEod(b)\ - ((b)->readLoc >= (b)->dataEnd) - -/* returns true if you attempted to read past the end of data */ -#define SBufReadError(b)\ - ((b)->readError) - -/* - * returns true if you attempted to write past the end of the block - * (remember SBufs do not expand like ExpBufs) - */ -#define SBufWriteError(b)\ - ((b)->writeError) - -/* Skips the next skipLen bytes for reading */ -#define SBufSkip(b, skipLen)\ -{ if ( ((b)->readLoc + skipLen) > (b)->dataEnd)\ - {\ - (b)->readLoc = (b)->dataEnd;\ - (b)->readError = 1;\ - }\ - else\ - (b)->readLoc += skipLen;\ -} - - -/* - * copies copyLen bytes from buffer b into char *dst. - * assumes dst is pre-allocated and is large enough. - * Will set the read error flag is you attempt to copy - * more than the number of unread bytes available. - */ -#define SBufCopy(dst, b, copyLen)\ -{ if (((b)->readLoc + copyLen) > (b)->dataEnd)\ - {\ - memcpy (dst, (b)->readLoc, (b)->dataEnd - (b)->readLoc);\ - (b)->readLoc = (b)->dataEnd;\ - (b)->readError = 1;\ - }\ - else\ - {\ - memcpy (dst, (b)->readLoc, copyLen);\ - (b)->readLoc += copyLen;\ - }\ -} - -/* - * returns the next byte from the buffer without advancing the - * current read location. - */ -#define SBufPeekByte(b)\ - ((SBufEod (b))? ((b)->readError = 1):(unsigned char) *((b)->readLoc)) - -/* - * WARNING: this is a fragile macro. be careful where you use it. - * return a pointer into the buffer for the next bytes to be read - * if *lenPtr uread bytes are not available, *lenPtr will be set - * to the number of byte that are available. The current read location - * is advance by the number of bytes returned in *lenPtr. The read error - * flag will NOT set, ever, by this routine. - */ -#define SBufGetSeg( b, lenPtr)\ - ((b)->readLoc);\ - if (((b)->readLoc + *lenPtr) > (b)->dataEnd)\ - {\ - *lenPtr = (b)->dataEnd - (b)->readLoc;\ - (b)->readLoc = (b)->dataEnd;\ - }\ - else\ - (b)->readLoc += *lenPtr; - -/* - * Write in reverse the char *seg of segLen bytes to the buffer b. - * A reverse write of segement really just prepends the given seg - * (in original order) to the buffers existing data - */ -#define SBufPutSegRvs(b, seg, segLen)\ -{ if (((b)->dataStart - segLen) < (b)->blkStart)\ - (b)->writeError = 1;\ - else\ - {\ - (b)->dataStart -= segLen;\ - memcpy ((b)->dataStart, seg, segLen);\ - }\ -} - -/* - * returns the next byte from buffer b's data and advances the - * current read location by one byte. This will set the read error - * flag if you attempt to read past the end of the SBuf - */ -#define SBufGetByte(b)\ - (unsigned char)((SBufEod (b))? ((b)->readError = 1):*((b)->readLoc++)) - -/* - * writes (prepends) the given byte to buffer b's data - */ -#define SBufPutByteRvs(b, byte)\ -{ if ((b)->dataStart <= (b)->blkStart)\ - (b)->writeError = 1;\ - else\ - *(--(b)->dataStart) = byte;\ -} - -#endif /* USE_GEN_BUF */ - -#endif /* conditional include */ diff --git a/SecuritySNACCRuntime/c-lib/inc/str-stk.h b/SecuritySNACCRuntime/c-lib/inc/str-stk.h deleted file mode 100644 index 06f2716b..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/str-stk.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * str_stk.h - maintains a stack of the components of a bit string - * or octet string so they can be copied into a single chunk - * - * - * CONSTRUCTED BIT AND OCTET STRINGS SUCK. They should be - * specified in the application's ASN.1 spec as SEQUENCE OF OCTET STRING - * - * this stack stuff is for decoding constructed bit/octet strings - * so the user gets a single contiguous bit/octet str instead of - * irritating little pieces. This does not cost a lot more than - * a linked octet/bit string type since we're copying from the - * buffer anyway, not referencing it directly (even in simple case). - * It will cost more if the string stk overflows and - * needs to be enlarged via realloc - set the values of - * initialStkSizeG, and stkGrowSize carefully for your application. - * Once the StkSize grows, it doesn't shrink back ever. - * - * Only three routine use/deal with this stack garbage - * BDecConsAsnOcts - * BDecConsAsnBits - * SetupConsBitsOctsStringStk - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/str-stk.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: str-stk.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:22 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:01:24 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:45:41 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -typedef struct StrStkElmt -{ - char *str; - unsigned long int len; -} StrStkElmt; - -typedef struct StrStk -{ - StrStkElmt *stk; /* ptr to array of SSElmts with 'size' elmts */ - unsigned long int initialNumElmts; - unsigned long int numElmts; /* total # of elements in str stk */ - unsigned long int growElmts; /* # elmts to increase size by when nec */ - unsigned long int nextFreeElmt; /* index of next free element */ - unsigned long int totalByteLen; /* octet len of string stored in stk */ -} StrStk; - - -extern StrStk strStkG; - -/* - * initializes stk (Allocates if nec.) - * once stk is enlarged, it doesn't shrink - */ -#define RESET_STR_STK()\ -{\ - strStkG.nextFreeElmt = 0;\ - strStkG.totalByteLen = 0;\ - if (strStkG.stk == NULL){\ - strStkG.stk = (StrStkElmt*) malloc ((strStkG.initialNumElmts) *sizeof (StrStkElmt));\ - strStkG.numElmts = strStkG.initialNumElmts;}\ -} - - -/* - * add a char*,len pair to top of stack. - * grows stack if necessary using realloc (!) - */ -#define PUSH_STR(strPtr, strsLen, env)\ -{\ - if (strStkG.nextFreeElmt >= strStkG.numElmts)\ - {\ - strStkG.stk = (StrStkElmt*) realloc (strStkG.stk, (strStkG.numElmts + strStkG.growElmts) *sizeof (StrStkElmt));\ - strStkG.numElmts += strStkG.growElmts;\ - }\ - strStkG.totalByteLen += strsLen;\ - strStkG.stk[strStkG.nextFreeElmt].str = strPtr;\ - strStkG.stk[strStkG.nextFreeElmt].len = strsLen;\ - strStkG.nextFreeElmt++;\ -} - - -/* - * Set up size values for the stack that is used for merging constructed - * octet or bit string into single strings. - * **** Call this before decoding anything. ***** - * Note: you don't have to call this if the default values - * for initialStkSizeG and stkGrowSizeG are acceptable - */ -#define SetupConsBitsOctsStringStk (initialNumberOfElmts, numberOfElmtsToGrowBy)\ -{\ - strStkG.initialNumElmts = initialNumberOfElmts; \ - strStkG.growElmts = numberOfElmtsToGrowBy;\ -} diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-dec.h b/SecuritySNACCRuntime/c-lib/inc/tbl-dec.h deleted file mode 100644 index 88984451..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-dec.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl-util.h - type table utilities. - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/tbl-dec.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: tbl-dec.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:22 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/27 08:55:52 rj - * first check-in after being merged into .../c-lib/. - * - */ - - -AVal *TblDecode PROTO ((TBL *tbl, char *modName, char *typeName, BUF_TYPE b, unsigned long int *bytesDecoded)); - -AVal *TblDecodeType PROTO ((TBLType *tblT, BUF_TYPE b, int implicit, unsigned long int *bytesDecoded, ENV_TYPE env)); diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-enc.h b/SecuritySNACCRuntime/c-lib/inc/tbl-enc.h deleted file mode 100644 index b7e79c49..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-enc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl-enc.h - type table encoder - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/tbl-enc.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: tbl-enc.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:22 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/27 08:55:54 rj - * first check-in after being merged into .../c-lib/. - * - */ - - -int TblEncode PROTO ((TBL *tbl, char *modName, char *typeName, BUF_TYPE b, AVal *v, unsigned long int *bytesEncoded)); - -int TblEncodeType PROTO ((TBLType *tblT, BUF_TYPE b, AVal *v, int implicit, unsigned long int *bytesEncoded)); diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-free.h b/SecuritySNACCRuntime/c-lib/inc/tbl-free.h deleted file mode 100644 index 7ae47d71..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-free.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl-free.h - frees data structs returned by type table driven decoder. - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/tbl-free.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: tbl-free.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:22 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/27 08:55:55 rj - * first check-in after being merged into .../c-lib/. - * - */ - - -void TblFree PROTO ((TBL *tbl, char *modName, char *typeName, AVal *v)); - -void TblFreeType PROTO ((TBLType *tblT, AVal *v)); diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-gen-c-hdr.h b/SecuritySNACCRuntime/c-lib/inc/tbl-gen-c-hdr.h deleted file mode 100644 index b4ae1c39..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-gen-c-hdr.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl-gen-c-hdr.h - prints C type defs for vals - * tbl decoder will return for the given type table. - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/tbl-gen-c-hdr.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: tbl-gen-c-hdr.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:22 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/27 08:55:56 rj - * first check-in after being merged into .../c-lib/. - * - */ - -void TblPrintCHdr PROTO ((TBL *tbl, FILE *f)); diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-gen.h b/SecuritySNACCRuntime/c-lib/inc/tbl-gen.h deleted file mode 100644 index 03bbea75..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-gen.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#ifndef TBL_GEN_H -#define TBL_GEN_H - -#define USE_GEN_BUF 1 -#include "tbl-incl.h" - -typedef enum {TDEINFO, TDEEOC=TDEINFO, TDEPEEKTAG, TDEPUSHTAG, - TDEWARNING, TDEUNEXPECTED=TDEWARNING, TDENONOPTIONAL, TDEMANDATORY, - TDECONSTRAINT, TDENOMATCH, - TDEERROR} TdeExceptionCode; - -typedef int (*TdeTypeProc) PROTO ((TBLType* type, AVal* val, int begin)); -typedef int (*TdeSimpleProc) PROTO ((AsnTag tag, AsnOcts* val, int begin)); -typedef int (*TdeExcProc) PROTO ((TdeExceptionCode code, void* p1, void* p2, void* p3)); - -int -TdeDecode PROTO ((TBL* tbl, BUF_TYPE b, unsigned long int* bytesDecoded, - TdeTypeProc typeproc, TdeSimpleProc simpleproc, TdeExcProc excproc)); - -int -TdeDecodeSpecific PROTO ((TBL* tbl, BUF_TYPE b, TBLType* type, - unsigned long int* bytesDecoded, - TdeTypeProc typeproc, TdeSimpleProc simpleproc, TdeExcProc excproc)); -#endif diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-incl.h b/SecuritySNACCRuntime/c-lib/inc/tbl-incl.h deleted file mode 100644 index 765cf2bd..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-incl.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl-incl.h - wraps all nec tbl stuff in one file - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/tbl-incl.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: tbl-incl.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:22 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1997/05/07 15:18:34 wan - * Added (limited) size constraints, bitstring and enumeration names to tables - * - * Revision 1.1 1995/07/27 08:55:57 rj - * first check-in after being merged into .../c-lib/. - * - */ - -#define TTBL 3 - -#include "asn-incl.h" -#include "tbl.h" - -typedef void AVal; - -typedef AVal *AStructVal; /* an array of AVal ptrs */ - -typedef struct AChoiceVal -{ - enum { achoiceval_notused } choiceId; - AVal *val; -} AChoiceVal; - - -#include "tbl-util.h" -#include "tbl-enc.h" -#include "tbl-dec.h" -#include "tbl-print.h" -#include "tbl-free.h" - -/* - * TblError (char *str) - configure error handler - */ -#define TblError( str) fprintf (stderr, "%s", str) diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-print.h b/SecuritySNACCRuntime/c-lib/inc/tbl-print.h deleted file mode 100644 index 19af555d..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-print.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl-print.h - type table value printer - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/tbl-print.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: tbl-print.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:22 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/27 08:55:58 rj - * first check-in after being merged into .../c-lib/. - * - */ - - -void TblPrintValue PROTO ((TBL *tbl, char *modName, char *typeName, FILE *f, AVal *v)); - -void TblPrintTypeValue PROTO ((TBLType *tblT, FILE *f, AVal *v, unsigned short int indent)); diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-util.h b/SecuritySNACCRuntime/c-lib/inc/tbl-util.h deleted file mode 100644 index 261c6aff..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-util.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl-util.h - type table utilities. - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/inc/Attic/tbl-util.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: tbl-util.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:23 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:23 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/27 08:55:59 rj - * first check-in after being merged into .../c-lib/. - * - */ - -/* - * these rely on the TBLTagClass enum starting at zero - * and being in the order: UNIVERSAL, APPLICATION, CONTEXT, PRIVATE - */ -#define TblTagClassToBer(tblClass) (tblClass << 6) -#define BerTagClassToTbl(berClass) (berClass >> 6) -#define TagsEquiv(asnTag, tblTag) (((tblTag)->encTag == (asnTag)) ||\ - (((tblTag)->form == ANY_FORM) &&\ - ((tblTag)->encTag == DECONSIFY (asnTag)))) - - -char *LoadFile PROTO ((char *tblFileName, unsigned long int *size)); - -TBL *LoadTblFile PROTO ((char *tblFileName)); - -TBLTypeDef *TblFindTypeDef PROTO ((TBL *tbl, char *moduleName, char *typeName, TBLModule **tblModHndl)); - -TBLTypeDef *TblFindTypeDefInMod PROTO ((TBLModule *tbl, char *typeName)); - -TBLTypeDef *TblFindTypeDefByIndex PROTO ((TBL *tbl,TBLTypeDefId id)); - -TBLModule *TblFindModule PROTO ((TBL *tbl, char *modName)); diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl.h b/SecuritySNACCRuntime/c-lib/inc/tbl.h deleted file mode 100644 index b69de422..00000000 --- a/SecuritySNACCRuntime/c-lib/inc/tbl.h +++ /dev/null @@ -1,344 +0,0 @@ -/* - * tbl.h - * - * "TBL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Tue Mar 19 07:24:47 2002 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _tbl_h_ -#define _tbl_h_ - - - - -typedef enum - { - TBL_BOOLEAN = 0, - TBL_INTEGER = 1, - TBL_BITSTRING = 2, - TBL_OCTETSTRING = 3, - TBL_NULL = 4, - TBL_OID = 5, - TBL_REAL = 6, - TBL_ENUMERATED = 7, - TBL_SEQUENCE = 8, - TBL_SET = 9, - TBL_SEQUENCEOF = 10, - TBL_SETOF = 11, - TBL_CHOICE = 12, - TBL_TYPEREF = 13 - } TBLTypeId; /* ENUMERATED { TBL_BOOLEAN (0), TBL_INTEGER (1), TBL_BITSTRING (2), TBL_OCTETSTRING (3), TBL_NULL (4), TBL_OID (5), TBL_REAL (6), TBL_ENUMERATED (7), TBL_SEQUENCE (8), TBL_SET (9), TBL_SEQUENCEOF (10), TBL_SETOF (11), TBL_CHOICE (12), TBL_TYPEREF (13) } */ - -#define BEncTBLTypeIdContent BEncAsnEnumContent - -#define BDecTBLTypeIdContent BDecAsnEnumContent - -#define PrintTBLTypeId PrintAsnEnum - -#define FreeTBLTypeId FreeAsnEnum - - - - -typedef AsnInt TBLTypeDefId; /* INTEGER */ - -#define BEncTBLTypeDefIdContent BEncAsnIntContent - -#define BDecTBLTypeDefIdContent BDecAsnIntContent - -#define PrintTBLTypeDefId PrintAsnInt - -#define FreeTBLTypeDefId FreeAsnInt - - - - -typedef enum - { - UNIVERSAL = 0, - APPLICATION = 1, - CONTEXT = 2, - PRIVATE = 3 - } TBLTagClass; /* ENUMERATED { UNIVERSAL (0), APPLICATION (1), CONTEXT (2), PRIVATE (3) } */ - -#define BEncTBLTagClassContent BEncAsnEnumContent - -#define BDecTBLTagClassContent BDecAsnEnumContent - -#define PrintTBLTagClass PrintAsnEnum - -#define FreeTBLTagClass FreeAsnEnum - - - - -typedef struct TBLRange /* SEQUENCE */ -{ - AsnInt from; /* [0] IMPLICIT INTEGER */ - AsnInt to; /* [1] IMPLICIT INTEGER */ -} TBLRange; - -AsnLen BEncTBLRangeContent PROTO ((BUF_TYPE b, TBLRange *v)); - -void BDecTBLRangeContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLRange *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLRange PROTO ((FILE* f, TBLRange *v, unsigned short int indent)); -void FreeTBLRange PROTO ((TBLRange *v)); - - - - - -typedef struct TBLNamedNumber /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnInt value; /* [1] IMPLICIT INTEGER */ -} TBLNamedNumber; - -AsnLen BEncTBLNamedNumberContent PROTO ((BUF_TYPE b, TBLNamedNumber *v)); - -void BDecTBLNamedNumberContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLNamedNumber *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLNamedNumber PROTO ((FILE* f, TBLNamedNumber *v, unsigned short int indent)); -void FreeTBLNamedNumber PROTO ((TBLNamedNumber *v)); - - - - - -typedef AsnList TBLNamedNumberList; /* SEQUENCE OF TBLNamedNumber */ - -AsnLen BEncTBLNamedNumberListContent PROTO ((BUF_TYPE b, TBLNamedNumberList *v)); - -void BDecTBLNamedNumberListContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLNamedNumberList *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLNamedNumberList PROTO ((FILE* f, TBLNamedNumberList *v, unsigned short int indent)); -void FreeTBLNamedNumberList PROTO ((TBLNamedNumberList *v)); - - - - - -typedef struct TBLTypeRef /* SEQUENCE */ -{ - TBLTypeDefId typeDef; /* TBLTypeDefId */ - AsnBool implicit; /* BOOLEAN */ - struct TBLTypeDef *typeDefPtr; /* Added by MS to hold resolved index */ -} TBLTypeRef; - -AsnLen BEncTBLTypeRefContent PROTO ((BUF_TYPE b, TBLTypeRef *v)); - -void BDecTBLTypeRefContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeRef *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeRef PROTO ((FILE* f, TBLTypeRef *v, unsigned short int indent)); -void FreeTBLTypeRef PROTO ((TBLTypeRef *v)); - - - - - -typedef struct TBLTag /* SEQUENCE */ -{ - TBLTagClass tclass; /* TBLTagClass */ - AsnInt code; /* INTEGER (0..MAX) */ - BER_FORM form; /* added by MS to simplify enc/dec */ - AsnTag encTag; /* added by MS to simplify enc/dec */ -} TBLTag; - -AsnLen BEncTBLTagContent PROTO ((BUF_TYPE b, TBLTag *v)); - -void BDecTBLTagContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTag *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTag PROTO ((FILE* f, TBLTag *v, unsigned short int indent)); -void FreeTBLTag PROTO ((TBLTag *v)); - - - - - -typedef AsnList TBLTypeSeqOf; /* SEQUENCE OF TBLTag */ - -AsnLen BEncTBLTypeSeqOfContent PROTO ((BUF_TYPE b, TBLTypeSeqOf *v)); - -void BDecTBLTypeSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeSeqOf PROTO ((FILE* f, TBLTypeSeqOf *v, unsigned short int indent)); -void FreeTBLTypeSeqOf PROTO ((TBLTypeSeqOf *v)); - - - - - -typedef AsnList TBLTypeContentSeqOf; /* SEQUENCE OF TBLType */ - -AsnLen BEncTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, TBLTypeContentSeqOf *v)); - -void BDecTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeContentSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeContentSeqOf PROTO ((FILE* f, TBLTypeContentSeqOf *v, unsigned short int indent)); -void FreeTBLTypeContentSeqOf PROTO ((TBLTypeContentSeqOf *v)); - - - - - -typedef struct TBLType /* SEQUENCE */ -{ - TBLTypeId typeId; /* [0] IMPLICIT TBLTypeId */ - AsnBool optional; /* [1] IMPLICIT BOOLEAN */ - TBLTypeSeqOf* tagList; /* [2] IMPLICIT TBLTypeSeqOf OPTIONAL */ - struct TBLTypeContent* content; /* [3] TBLTypeContent */ - PrintableString fieldName; /* [4] IMPLICIT PrintableString OPTIONAL */ - struct TBLRange* constraint; /* [5] IMPLICIT TBLRange OPTIONAL */ - TBLNamedNumberList* values; /* [6] IMPLICIT TBLNamedNumberList OPTIONAL */ -} TBLType; - -AsnLen BEncTBLTypeContent PROTO ((BUF_TYPE b, TBLType *v)); - -void BDecTBLTypeContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLType *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLType PROTO ((FILE* f, TBLType *v, unsigned short int indent)); -void FreeTBLType PROTO ((TBLType *v)); - - - - - -typedef struct TBLTypeContent /* CHOICE */ -{ - enum TBLTypeContentChoiceId - { - TBLTYPECONTENT_PRIMTYPE, - TBLTYPECONTENT_ELMTS, - TBLTYPECONTENT_TYPEREF - } choiceId; - union TBLTypeContentChoiceUnion - { - AsnNull primType; /* [0] IMPLICIT NULL */ - TBLTypeContentSeqOf* elmts; /* [1] IMPLICIT TBLTypeContentSeqOf */ - struct TBLTypeRef* typeRef; /* [2] IMPLICIT TBLTypeRef */ - } a; -} TBLTypeContent; - -AsnLen BEncTBLTypeContentContent PROTO ((BUF_TYPE b, TBLTypeContent *v)); - -void BDecTBLTypeContentContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeContent *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeContent PROTO ((FILE* f, TBLTypeContent *v, unsigned short int indent)); -void FreeTBLTypeContent PROTO ((TBLTypeContent *v)); - - - - - -typedef struct TBLTypeDef /* SEQUENCE */ -{ - TBLTypeDefId typeDefId; /* TBLTypeDefId */ - PrintableString typeName; /* PrintableString */ - struct TBLType* type; /* TBLType */ - AsnNull* isPdu; /* NULL OPTIONAL */ -} TBLTypeDef; - -AsnLen BEncTBLTypeDefContent PROTO ((BUF_TYPE b, TBLTypeDef *v)); - -void BDecTBLTypeDefContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeDef *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeDef PROTO ((FILE* f, TBLTypeDef *v, unsigned short int indent)); -void FreeTBLTypeDef PROTO ((TBLTypeDef *v)); - - - - - -typedef AsnList TBLModuleSeqOf; /* SEQUENCE OF TBLTypeDef */ - -AsnLen BEncTBLModuleSeqOfContent PROTO ((BUF_TYPE b, TBLModuleSeqOf *v)); - -void BDecTBLModuleSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLModuleSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLModuleSeqOf PROTO ((FILE* f, TBLModuleSeqOf *v, unsigned short int indent)); -void FreeTBLModuleSeqOf PROTO ((TBLModuleSeqOf *v)); - - - - - -typedef struct TBLModule /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnOid id; /* [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL */ - AsnBool isUseful; /* [2] IMPLICIT BOOLEAN */ - TBLModuleSeqOf* typeDefs; /* [3] IMPLICIT TBLModuleSeqOf */ -} TBLModule; - -AsnLen BEncTBLModuleContent PROTO ((BUF_TYPE b, TBLModule *v)); - -void BDecTBLModuleContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLModule *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLModule PROTO ((FILE* f, TBLModule *v, unsigned short int indent)); -void FreeTBLModule PROTO ((TBLModule *v)); - - - - - -typedef AsnList TBLSeqOf; /* SEQUENCE OF TBLModule */ - -AsnLen BEncTBLSeqOfContent PROTO ((BUF_TYPE b, TBLSeqOf *v)); - -void BDecTBLSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLSeqOf PROTO ((FILE* f, TBLSeqOf *v, unsigned short int indent)); -void FreeTBLSeqOf PROTO ((TBLSeqOf *v)); - - - - - -typedef struct TBL /* SEQUENCE */ -{ - AsnInt totalNumModules; /* INTEGER */ - AsnInt totalNumTypeDefs; /* INTEGER */ - AsnInt totalNumTypes; /* INTEGER */ - AsnInt totalNumTags; /* INTEGER */ - AsnInt totalNumStrings; /* INTEGER */ - AsnInt totalLenStrings; /* INTEGER */ - TBLSeqOf* modules; /* TBLSeqOf */ -} TBL; - -AsnLen BEncTBL PROTO ((BUF_TYPE b, TBL *v)); - -void BDecTBL PROTO ((BUF_TYPE b, TBL *result, AsnLen *bytesDecoded, ENV_TYPE env)); -AsnLen BEncTBLContent PROTO ((BUF_TYPE b, TBL *v)); - -void BDecTBLContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBL *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBL PROTO ((FILE* f, TBL *v, unsigned short int indent)); -void FreeTBL PROTO ((TBL *v)); - - - - - - -#endif /* conditional include of tbl.h */ diff --git a/SecuritySNACCRuntime/c-lib/install-sh b/SecuritySNACCRuntime/c-lib/install-sh deleted file mode 100644 index ab74c882..00000000 --- a/SecuritySNACCRuntime/c-lib/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -tranformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/SecuritySNACCRuntime/c-lib/makefile b/SecuritySNACCRuntime/c-lib/makefile deleted file mode 100644 index 1bee46f6..00000000 --- a/SecuritySNACCRuntime/c-lib/makefile +++ /dev/null @@ -1,401 +0,0 @@ -# c-lib/makefile -# -# makes C ASN.1 runtime libraries (one for each flavour of buffer) -# -# MS 92 -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:07 mb -# Move from private repository to open source repository -# -# Revision 1.3 2000/12/22 01:22:41 dmitch -# Misc. mods for clean build on Cheetah 1D7. -# -# Revision 1.2 2000/06/08 20:07:49 dmitch -# Mods for X port. -# -# Revision 1.1.1.1 1999/03/16 18:06:10 aram -# Originals from SMIME Free Library. -# -# Revision 1.12 1997/08/27 15:55:30 wan -# Added generic table decoding, debug routines, berdecode, and asnwish. -# -# Revision 1.11 1997/03/13 09:15:08 wan -# Improved dependency generation for stupid makedepends. -# Corrected PeekTag to peek into buffer only as far as necessary. -# Added installable error handler. -# Fixed small glitch in idl-code generator (Markku Savela ). -# -# Revision 1.10 1997/02/16 12:34:03 rj -# let make clobber remove the link to install-sh that make made -# -# Revision 1.9 1995/09/07 18:58:15 rj -# asn-useful.asn1 is compiled with the -l 50 option, as recommended by MS in the documentation -# -# Revision 1.8 1995/07/24 20:56:31 rj -# useful.asn1 renamed to asn-useful.asn1 to accomodate to snacc's new file name generation scheme. -# -# generate tbl.[hc] from .../asn1specs/tbl.asn1 -# patch tbl.h to add some data members. -# distribute boot versions of tbl.[ch] and tbl.h.path. -# -# generate type table library. -# -# create installation directories only if they do not exist already. -# -# ranlib the copied libraries. -# -# call make recursively to generate the libraries different dependencies and concatenate them. -# -# changed `_' to `-' in file names. -# -# Revision 1.7 1995/02/20 11:42:04 rj -# remove stamp-useful before removing asn-useful.[hc]. -# distribute install-sh. -# use $(INSTALL*) in a for-loop as some install programs (namely the distributed install-sh) only process their first argument! -# -# Revision 1.6 1995/02/09 14:02:47 rj -# enforce generation of inc/asn-useful.h and src/asn-useful.c when making dependencies -# -# Revision 1.5 1994/10/08 05:27:56 rj -# typo fixed. -# -# Revision 1.4 1994/10/08 05:20:07 rj -# don't distribute the non-bootstrapping version of asn-useful.[hc] -# -# Revision 1.3 1994/10/08 04:47:42 rj -# the files asn-useful.[hc] get regenerated automagically. since the compiler itself is compiled with it, a bootstapping version is included in the distribution. -# -# Revision 1.2 1994/08/31 23:51:42 rj -# DISTFILES and install phony target added. -# -# Revision 1.1 1994/08/28 09:21:20 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../makehead -include ../makehead.static - -DEPENDENCIES = - -TOP = .. - -ASN1_SRC_DIR = $(TOP)/asn1specs - -COMPILERDIR = $(TOP)/compiler -SNACC = $(COMPILERDIR)/snacc -USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 - -CPPFLAGS += -I$(TOP) -Iinc $(bufFLAGS) $(compilerFLAGS) - -RANLIB= /usr/bin/ranlib - -HFILES.d = \ - inc/asn-any.h \ - inc/asn-bits.h \ - inc/asn-bool.h \ - inc/asn-config.h \ - inc/asn-enum.h \ - inc/asn-incl.h \ - inc/asn-int.h \ - inc/asn-len.h \ - inc/asn-list.h \ - inc/asn-null.h \ - inc/asn-octs.h \ - inc/asn-oid.h \ - inc/asn-real.h \ - inc/asn-tag.h \ - inc/exp-buf.h \ - inc/gen-buf.h \ - inc/hash.h \ - inc/min-buf.h \ - inc/nibble-alloc.h \ - inc/print.h \ - inc/sbuf.h \ - inc/str-stk.h \ - \ - inc/tbl-dec.h \ - inc/tbl-enc.h \ - inc/tbl-free.h \ - inc/tbl-gen.h \ - inc/tbl-dbg.h \ - inc/tbl-gen-c-hdr.h \ - inc/tbl-incl.h \ - inc/tbl-print.h \ - inc/tbl-util.h - -HFILES = \ - $(HFILES.d) \ - inc/asn-useful.h \ - inc/tbl.h - -HFILES.shared = \ - $(TOP)/snacc.h \ - $(TOP)/config.h \ - $(TOP)/policy.h - -CFILES.d = \ - src/asn-len.c \ - src/asn-tag.c \ - src/asn-int.c \ - src/asn-bool.c \ - src/asn-bits.c \ - src/asn-octs.c \ - src/asn-oid.c \ - src/asn-real.c \ - src/asn-null.c \ - src/asn-list.c \ - src/asn-enum.c \ - src/str-stk.c \ - src/nibble-alloc.c \ - src/print.c \ - src/asn-any.c \ - src/hash.c \ - src/exp-buf.c \ - src/sbuf.c \ - \ - src/tbl-dec.c \ - src/tbl-enc.c \ - src/tbl-free.c \ - src/tbl-gen.c \ - src/tbl-dbg.c \ - src/tbl-print.c \ - src/tbl-util.c - -CFILES = \ - $(CFILES.d) \ - src/asn-useful.c \ - src/tbl.c - -OFILES = \ - $b/asn-len.o \ - $b/asn-tag.o \ - $b/asn-int.o \ - $b/asn-bool.o \ - $b/asn-bits.o \ - $b/asn-octs.o \ - $b/asn-oid.o \ - $b/asn-real.o \ - $b/asn-null.o \ - $b/asn-list.o \ - $b/asn-useful.o \ - $b/asn-enum.o \ - $b/str-stk.o \ - $b/nibble-alloc.o \ - $b/print.o \ - $b/asn-any.o \ - $b/hash.o \ - $b/exp-buf.o \ - $b/sbuf.o \ - \ - $b/tbl.o \ - $b/tbl-dec.o \ - $b/tbl-enc.o \ - $b/tbl-free.o \ - $b/tbl-gen.o \ - $b/tbl-dbg.o \ - $b/tbl-print.o \ - $b/tbl-util.o - -DISTFILES = \ - README \ - makefile \ - $(HFILES.d) \ - $(CFILES.d) \ - boot/asn-useful.h \ - boot/asn-useful.c \ - tbl.h.patch \ - boot/tbl.h \ - boot/tbl.c - -EXPORTLIBS = libasn1cebuf.a libasn1cmbuf.a libasn1csbuf.a libasn1ctbl.a -compilerLIB = libasn1cCebuf.a - -LIBS = \ - $(EXPORTLIBS) \ - $(compilerLIB) - -MAKEFLAGS.ebuf = bufFLAGS=-DUSE_EXP_BUF b=ebuf ebuf -MAKEFLAGS.Cebuf = bufFLAGS=-DUSE_EXP_BUF b=Cebuf Cebuf -MAKEFLAGS.mbuf = bufFLAGS=-DUSE_MIN_BUF b=mbuf mbuf -MAKEFLAGS.sbuf = bufFLAGS=-DUSE_SBUF b=sbuf sbuf -MAKEFLAGS.tbl = bufFLAGS="-DUSE_GEN_BUF -DTTBL" b=tbl tbl - -#------------------------------------------------------------------------------- - -.PHONY: ebuf Cebuf mbuf sbuf tbl - -default:: ebuf-lib mbuf-lib sbuf-lib tbl-lib - @echo "C ASN.1 libraries made" - -all:: default Cebuf-lib - -b = dummy - -$b:: $(CFILES) - -$b:: - test -d $@ || mkdir $@ - $(RM) $@/*.c - -ln $(CFILES) $@ - -.PHONY: ofiles lib -.PHONY: ebuf-lib Cebuf-lib mbuf-lib sbuf-lib tbl-lib - -ofiles: $(OFILES) - -lib: libasn1c$b.a - -ebuf-lib: - $(MAKE) $(MAKEFLAGS.ebuf) ofiles lib - -Cebuf-lib: - $(MAKE) $(MAKEFLAGS.Cebuf) ofiles lib - -mbuf-lib: - $(MAKE) $(MAKEFLAGS.mbuf) ofiles lib - -sbuf-lib: - $(MAKE) $(MAKEFLAGS.sbuf) ofiles lib - -tbl-lib: - $(MAKE) $(MAKEFLAGS.tbl) ofiles lib - -libasn1cebuf.a \ -libasn1cCebuf.a \ -libasn1cmbuf.a \ -libasn1csbuf.a \ -libasn1ctbl.a: $(OFILES) - $(AR) rv $@ $? - $(RANLIB) $@ - -inc/asn-useful.h \ -src/asn-useful.c:: - $(RM) inc/asn-useful.h src/asn-useful.c - if [ -f $(SNACC) ]; then\ - $(MAKE) stamp-useful;\ - else\ - $(RM) asn-useful.h asn-useful.c;\ - ln boot/asn-useful.h boot/asn-useful.c .;\ - fi - ln asn-useful.h inc - ln asn-useful.c src - -stamp-useful: $(SNACC) $(USEFUL_TYPES) makefile - -mv asn-useful.h asn-useful.h.prev - -mv asn-useful.c asn-useful.c.prev - $(SNACC) -c -l 50 $(USEFUL_TYPES) -# the dates in the two files will differ, so the files really differ if diff prints more than 4 lines of output: - @if [ -f asn-useful.h.prev ]; then\ - if [ `diff asn-useful.h.prev asn-useful.h | wc -l` -gt 4 ]; then\ - $(RM) asn-useful.h.prev;\ - else\ - echo "asn-useful.h hasn't changed";\ - mv asn-useful.h.prev asn-useful.h;\ - fi;\ - fi - @if [ -f asn-useful.c.prev ]; then\ - if [ `diff asn-useful.c.prev asn-useful.c | wc -l` -gt 4 ]; then\ - $(RM) asn-useful.c.prev;\ - else\ - echo "asn-useful.c hasn't changed";\ - mv asn-useful.c.prev asn-useful.c;\ - fi;\ - fi - date > $@ - -boot/asn-useful.h \ -boot/asn-useful.c: stamp-useful - $(RM) boot/asn-useful.h boot/asn-useful.c - cp -p asn-useful.h asn-useful.c boot - -inc/tbl.h \ -src/tbl.c:: - $(RM) inc/tbl.h src/tbl.c - if [ -f $(SNACC) ]; then\ - $(MAKE) stamp-tbl;\ - else\ - $(RM) tbl.h tbl.c;\ - ln boot/tbl.h boot/tbl.c .;\ - fi - ln tbl.h inc - ln tbl.c src - -stamp-tbl: $(SNACC) $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 makefile - -mv tbl.h tbl.h.prev - -mv tbl.c tbl.c.prev - $(SNACC) -u $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 - $(PATCH) < tbl.h.patch - echo '#if TTBL' > tbl.c.tmp - cat tbl.c >> tbl.c.tmp - echo '#endif /* TTBL */' >> tbl.c.tmp - mv tbl.c.tmp tbl.c -# the dates in the two files will differ, so the files really differ if diff prints more than 4 lines of output: - @if [ -f tbl.h.prev ]; then\ - if [ `diff tbl.h.prev tbl.h | wc -l` -gt 4 ]; then\ - $(RM) tbl.h.prev;\ - else\ - echo "tbl.h hasn't changed";\ - mv tbl.h.prev tbl.h;\ - fi;\ - fi - @if [ -f tbl.c.prev ]; then\ - if [ `diff tbl.c.prev tbl.c | wc -l` -gt 4 ]; then\ - $(RM) tbl.c.prev;\ - else\ - echo "tbl.c hasn't changed";\ - mv tbl.c.prev tbl.c;\ - fi;\ - fi - date > $@ - -boot/tbl.h \ -boot/tbl.c: stamp-tbl - $(RM) boot/tbl.h boot/tbl.c - cp -p tbl.h tbl.c boot - -install-sh: - ln $(TOP)/install-sh $@ - -$(incdir)/snacc/c $(libdir): - $(TOP)/mkinstalldirs $@ - -install:: $(HFILES) ebuf-lib mbuf-lib sbuf-lib tbl-lib install-sh $(incdir)/snacc/c $(libdir) - -install:: - for h in $(HFILES) $(HFILES.shared); do $(INSTALL_DATA) $$h $(incdir)/snacc/c/; done - for l in $(EXPORTLIBS); do $(INSTALL_DATA) $$l $(libexecdir)/; $(RANLIB) -t $(libexecdir)/$$l; done - -clean:: - $(RM) *.o *~ *.prev .emacs* core - $(RM) stamp-useful stamp-tbl - $(RM) asn-useful.h inc/asn-useful.h - $(RM) asn-useful.c src/asn-useful.c - $(RM) tbl.h inc/tbl.h - $(RM) tbl.c src/tbl.c - $(RM) -r ebuf Cebuf mbuf sbuf tbl - $(RM) $(compilerLIB) - -clobber:: - $(RM) $(LIBS) - $(RM) install-sh - -depend:: inc/asn-useful.h src/asn-useful.c -depend:: inc/tbl.h src/tbl.c - -depend:: - if [ x"$(DEPENDENCIES)" = x ]; then\ - $(MAKE) $(MAKEFLAGS.ebuf) DEPENDENCIES=deps.ebuf depend;\ - $(MAKE) $(MAKEFLAGS.Cebuf) DEPENDENCIES=deps.Cebuf depend;\ - $(MAKE) $(MAKEFLAGS.mbuf) DEPENDENCIES=deps.mbuf depend;\ - $(MAKE) $(MAKEFLAGS.sbuf) DEPENDENCIES=deps.sbuf depend;\ - $(MAKE) $(MAKEFLAGS.tbl) DEPENDENCIES=deps.tbl depend;\ - cp /dev/null dependencies;\ - for dir in ebuf Cebuf mbuf sbuf tbl; do\ - < deps.$$dir sed -e "s/^src/$$dir/;s/^[a-z-]*\.o:/$$dir\/&/" >> dependencies;\ - $(RM) deps.$$dir;\ - done;\ - fi - -include ../maketail diff --git a/SecuritySNACCRuntime/c-lib/src/asn-any.c b/SecuritySNACCRuntime/c-lib/src/asn-any.c deleted file mode 100644 index 15e34409..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-any.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_any.c - BER encode, decode, print, free, type set up and installation - * routines for the ASN.1 ANY and ANY DEFINED BY types. - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-any.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-any.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:30 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1997/02/28 13:39:49 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.2 1995/07/24 21:04:48 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:45:49 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-oid.h" -#include "asn-int.h" -#include "asn-any.h" - -/* - * 2 hash tables. 1 for INTEGER to type mappings the other - * for OBJECT IDENTIFER to type mappings. - */ -Table *anyOidHashTblG = NULL; -Table *anyIntHashTblG = NULL; - -/* - * given an ANY type value and a integer hash key, this defines - * this any values type (gets ptr to hash tbl entry from int key). - * The hash table entry contains ptrs to the encode/decode etc. routines. - */ -void -SetAnyTypeByInt PARAMS ((v, id), - AsnAny *v _AND_ - AsnInt id) -{ - Hash hash; - void *anyInfo; - - /* use int as hash string */ - hash = MakeHash ((char*)&id, sizeof (id)); - if (CheckForAndReturnValue (anyIntHashTblG, hash, &anyInfo)) - v->ai = (AnyInfo*) anyInfo; - else - v->ai = NULL; /* indicates failure */ - -} /* SetAnyTypeByInt */ - - -/* - * Same as SetAnyTypeByInt except that the hash key is an OBJECT IDENTIFER. - */ -void SetAnyTypeByOid PARAMS ((v, id), - AsnAny *v _AND_ - AsnOid *id) -{ - Hash hash; - void *anyInfo; - - /* use encoded oid as hash string */ - hash = MakeHash (id->octs, id->octetLen); - if (CheckForAndReturnValue (anyOidHashTblG, hash, &anyInfo)) - v->ai = (AnyInfo*) anyInfo; - else - v->ai = NULL; /* indicates failure */ - -} /* SetAnyTypeByOid */ - - -/* - * Creates an entry in the hash table that contains the - * type's size, encode, decode, free, and print routines and anyId. - * The given intId is used as the hash key so future calls to - * SetAnyTypeByInt with that intId as the id will reference this entry. - * The anyId is stored in the hash tbl entry as well so the user can - * figure out the type with a simple integer comparison. - * - * This routine is usually called from the AnyInit routine that - * the compiler generates from MACRO info. Call this routine - * once for each possible ANY type to set up the hash table. - * Future calls to SetAnyTypeByInt/Oid will reference this table. - */ -void -InstallAnyByInt PARAMS ((anyId, intId, size, Encode, Decode, Free, Print), - int anyId _AND_ - AsnInt intId _AND_ - unsigned int size _AND_ - EncodeFcn Encode _AND_ - DecodeFcn Decode _AND_ - FreeFcn Free _AND_ - PrintFcn Print) -{ - AnyInfo *a; - Hash h; - - a = (AnyInfo*) malloc (sizeof (AnyInfo)); - a->anyId = anyId; - a->oid.octs = NULL; - a->oid.octetLen = 0; - a->intId = intId; - a->size = size; - a->Encode = Encode; - a->Decode = Decode; - a->Free = Free; - a->Print = Print; - - if (anyIntHashTblG == NULL) - anyIntHashTblG = InitHash(); - - h = MakeHash ((char*)&intId, sizeof (intId)); - Insert (anyIntHashTblG, a, h); - -} /* InstallAnyByOid */ - - -/* - * Same as InstallAnyByInt except the oid is used as the hash key - */ -void -InstallAnyByOid PARAMS ((anyId, oid, size, Encode, Decode, Free, Print), - int anyId _AND_ - AsnOid *oid _AND_ - unsigned int size _AND_ - EncodeFcn Encode _AND_ - DecodeFcn Decode _AND_ - FreeFcn Free _AND_ - PrintFcn Print) -{ - AnyInfo *a; - Hash h; - - a = (AnyInfo*) malloc (sizeof (AnyInfo)); - a->anyId = anyId; - a->oid.octs = oid->octs; - a->oid.octetLen = oid->octetLen; - a->size = size; - a->Encode = Encode; - a->Decode = Decode; - a->Free = Free; - a->Print = Print; - - h = MakeHash (oid->octs, oid->octetLen); - - if (anyOidHashTblG == NULL) - anyOidHashTblG = InitHash(); - - Insert (anyOidHashTblG, a, h); - -} /* InstallAnyByOid */ - - -/* - * Calls the free routine in this type's any info. - * If the routine ptr is NULL, nothing is done - * (This is the case for INTEGERs, BOOLEANs and other simple - * values) - */ -void -FreeAsnAny PARAMS ((v), - AsnAny *v) -{ - if ((v->ai != NULL) && (v->ai->Free != NULL)) - v->ai->Free (v->value); -} /* FreeAsnAny */ - - -/* - * Calls the Encode routine pointed to in the given type's - * Any Info. If the routine ptr is NULL nothing is encoded - * (This should set some type of error). - * Note: this calls the BEncFoo not BEncFooContent routine form - * since the tags are needed too. - */ -AsnLen -BEncAsnAny PARAMS ((b, v), - BUF_TYPE b _AND_ - AsnAny *v) -{ - if ((v->ai != NULL) && (v->ai->Encode != NULL)) - return v->ai->Encode (b, v->value); - else - return 0; -} /* BEncAsnAny */ - - -/* - * Calls the Decode routine pointed to in the given type's - * Any Info. If the routine ptr is NULL any error is flagged. - * Note: this calls the BDecFoo not BDecFooContent routine form - * since the tags are needed too. - */ -void BDecAsnAny PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnAny *result _AND_ - AsnLen *bytesDecoded _AND_ - ENV_TYPE env) -{ - if ((result->ai != NULL) && (result->ai->Decode != NULL)) - { - result->value = (void*) Asn1Alloc (result->ai->size); - result->ai->Decode (b, result->value, bytesDecoded, env); - } - else - { - Asn1Error ("ERROR - ANY Decode routine is NULL\n"); - longjmp (env, -44); - } -} - -/* - * Calls the print routine pointed to from the given type's - * Any Info. Prints an error if the type does not have - * any 'AnyInfo' or if the AnyInfo has a NULL Print routine ptr. - */ -void PrintAsnAny PARAMS ((f, v, indent), - FILE *f _AND_ - AsnAny *v _AND_ - unsigned short indent) -{ - if ((v->ai != NULL) && (v->ai->Print != NULL)) - v->ai->Print (f, v->value); - else - fprintf (f," -- ERROR: malformed ANY value --"); -} diff --git a/SecuritySNACCRuntime/c-lib/src/asn-bits.c b/SecuritySNACCRuntime/c-lib/src/asn-bits.c deleted file mode 100644 index ea907acc..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-bits.c +++ /dev/null @@ -1,450 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * .../c-lib/src/asn-bits.c - BER encode, decode, print and free routines for ASN.1 BIT STRING type - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-bits.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-bits.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:30 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/27 08:57:33 rj - * use memcmpeq that is defined in .../snacc.h to use either memcmp or bcmp. - * - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/12/11 21:51:31 rj - * #include - * - * Revision 1.2 1994/08/31 23:56:27 rj - * two unused variables removed. - * - * Revision 1.1 1994/08/28 09:45:50 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif - -#include "asn-len.h" -#include "asn-tag.h" -#include "str-stk.h" -#include "asn-bits.h" - -static unsigned short int unusedBitsG; - -char numToHexCharTblG[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - - - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 BIT STRING - */ -AsnLen -BEncAsnBits PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnBits *data) -{ - AsnLen len; - - len = BEncAsnBitsContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE); - return len; -} /* BEncAsnInt */ - - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 BIT STRING - */ -void -BDecAsnBits PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnBits *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if (((tag =BDecTag (b, bytesDecoded, env)) != - MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) && - (tag != MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))) - { - Asn1Error ("BDecAsnBits: ERROR - wrong tag on BIT STRING.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecAsnBitsContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecAsnBits */ - - - -/* - * Encodes the BIT STRING value (including the unused bits - * byte) to the given buffer. - */ -AsnLen -BEncAsnBitsContent PARAMS ((b, bits), - BUF_TYPE b _AND_ - AsnBits *bits) -{ - unsigned long int unusedBits; - unsigned long int byteLen; - - if (bits->bitLen == 0) - byteLen = 0; - else - byteLen = ((bits->bitLen-1) / 8) + 1; - - BufPutSegRvs (b, bits->bits, byteLen); - unusedBits = (bits->bitLen % 8); - if (unusedBits != 0) - unusedBits = 8 - unusedBits; - BufPutByteRvs (b, unusedBits); - return byteLen + 1; - -} /* BEncAsnBitsContent */ - - -/* - * Used when decoding to combine constructed pieces into one - * contiguous block. - * Fills string stack with references to the pieces of a - * construced bit string. sets unusedBitsG appropriately. - * and strStkG.totalByteLenG to bytelen needed to hold the bitstring - */ -static void -FillBitStringStk PARAMS ((b, elmtLen0, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnLen elmtLen0 _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - unsigned long int refdLen; - unsigned long int totalRefdLen; - char *strPtr; - unsigned long int totalElmtsLen1 = 0; - unsigned long int tagId1; - unsigned long int elmtLen1; - unsigned long int lenToRef; - - for (; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN); ) - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env); - break; - } - - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - if (tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) - { - /* - * primitive part of string, put references to piece (s) in - * str stack - */ - - /* - * get unused bits octet - */ - if (unusedBitsG != 0) - { - /* - * whoa - only allowed non-octet aligned bits on - * on last piece of bits string - */ - Asn1Error ("FillBitStringStk: ERROR - a component of a constructed BIT STRING that is not the last has non-zero unused bits\n"); - longjmp (env, -1); - } - - if (elmtLen1 != 0) - unusedBitsG = BufGetByte (b); - - totalRefdLen = 0; - lenToRef =elmtLen1-1; /* remove one octet for the unused bits oct*/ - refdLen = lenToRef; - while (1) - { - strPtr = BufGetSeg (b, &refdLen); - - PUSH_STR (strPtr, refdLen, env); - totalRefdLen += refdLen; - if (totalRefdLen == lenToRef) - break; /* exit this while loop */ - - if (refdLen == 0) /* end of data */ - { - Asn1Error ("FillBitStringStk: ERROR - expecting more data\n"); - longjmp (env, -2); - } - refdLen = lenToRef - totalRefdLen; - } - totalElmtsLen1 += elmtLen1; - } - - - else if (tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)) - { - /* - * constructed octets string embedding in this constructed - * octet string. decode it. - */ - FillBitStringStk (b, elmtLen1, &totalElmtsLen1, env); - } - else /* wrong tag */ - { - Asn1Error ("FillBitStringStk: ERROR - decoded non-BIT STRING tag inside a constructed BIT STRING\n"); - longjmp (env, -3); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; - -} /* FillBitStringStk */ - - -/* - * Decodes a seq of universally tagged bits until either EOC is - * encountered or the given len decoded. Returns them in a - * single concatenated bit string - */ -static void -BDecConsAsnBits PARAMS ((b, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnLen len _AND_ - AsnBits *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - char *bufCurr; - unsigned long int curr; - - RESET_STR_STK(); - - /* - * decode each piece of the octet string, puting - * an entry in the octet/bit string stack for each - */ - FillBitStringStk (b, len, bytesDecoded, env); - - /* alloc single str long enough for combined bitstring */ - result->bitLen = strStkG.totalByteLen*8 - unusedBitsG; - - bufCurr = result->bits = Asn1Alloc (strStkG.totalByteLen); - - /* copy bit string pieces (buffer refs) into single block */ - for (curr = 0; curr < strStkG.nextFreeElmt; curr++) - { - memcpy (bufCurr, strStkG.stk[curr].str, strStkG.stk[curr].len); - bufCurr += strStkG.stk[curr].len; - } - -} /* BDecConsAsnBits */ - -/* - * Decodes the content of a BIT STRING (including the unused bits octet) - * Always returns a single contiguous bit string - */ -void -BDecAsnBitsContent PARAMS ((b, tagId, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnTag tagId _AND_ - AsnLen len _AND_ - AsnBits *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - /* - * tagId is encoded tag shifted into long int. - * if CONS bit is set then constructed bit string - */ - if (TAG_IS_CONS (tagId)) - BDecConsAsnBits (b, len, result, bytesDecoded, env); - else /* primitive octet string */ - { - (*bytesDecoded) += len; - len--; - result->bitLen = (len * 8) - (unsigned int)BufGetByte (b); - result->bits = Asn1Alloc (len); - BufCopy (result->bits, b, len); - if (BufReadError (b)) - { - Asn1Error ("BDecAsnBitsContent: ERROR - decoded past end of data\n"); - longjmp (env, -4); - } - } -} /* BDecAsnBitsContent */ - - - -/* - * Frees the string part of a BIT STRING - */ -void -FreeAsnBits PARAMS ((v), - AsnBits *v) -{ - Asn1Free (v->bits); -} /* FreeAsnBits */ - - -/* - * Prints the contents of the given BIT STRING to the - * given file. indent is ignored. Always uses ASN.1 Value Notaion - * Hex format. (Should be binary versions in some cases) - */ -void -PrintAsnBits PARAMS ((f,v, indent), - FILE *f _AND_ - AsnBits *v _AND_ - unsigned short indent) -{ - int i; - unsigned long int octetLen; - - if (v->bitLen == 0) - octetLen = 0; - else - octetLen = (v->bitLen-1)/8 +1; - - fprintf (f,"'"); - for (i = 0; i < octetLen; i++) - fprintf (f,"%c%c", TO_HEX (v->bits[i] >> 4), TO_HEX (v->bits[i])); - fprintf (f,"'H"); - -} /* PrintAsnBits */ - -/* - * Returns TRUE if the given BIT STRINGs are identical. - * Otherwise returns FALSE. - */ -int -AsnBitsEquiv PARAMS ((b1, b2), - AsnBits *b1 _AND_ - AsnBits *b2) -{ - int octetsLessOne; - int octetBits; - - if ((b1->bitLen == 0) && (b2->bitLen == 0)) - return TRUE; - - octetsLessOne = (b1->bitLen-1)/8; - octetBits = 7 - (b1->bitLen % 8); - - /* trailing bits may not be significant */ - return b1->bitLen == b2->bitLen && !memcmpeq (b1->bits, b2->bits, octetsLessOne) && ((b1->bits[octetsLessOne] & (0xFF << octetBits)) == (b1->bits[octetsLessOne] & (0xFF << octetBits))); - -} /* AsnBitsEquiv */ - - -/* - * Set given bit to 1. Most significant bit is bit 0, least significant - * is bit (v1->bitLen -1) - */ -void -SetAsnBit PARAMS ((b1, bit), - AsnBits *b1 _AND_ - unsigned long int bit) -{ - unsigned long int octet; - unsigned long int octetsBit; - - if (bit < b1->bitLen) - { - octet = bit/8; - octetsBit = 7 - (bit % 8);/* bit zero is first/most sig bit in octet */ - b1->bits[octet] |= 1 << octetsBit; - } -} /* SetAsnBit */ - - -/* - * Set given bit to 0. Most significant bit is bit 0, least significant - * is bit (v1->bitLen -1) - */ -void -ClrAsnBit PARAMS ((b1, bit), - AsnBits *b1 _AND_ - unsigned long int bit) -{ - unsigned long int octet; - unsigned long int octetsBit; - - if (bit < b1->bitLen) - { - octet = bit/8; - octetsBit = 7 - (bit % 8);/* bit zero is first/most sig bit in octet */ - b1->bits[octet] &= ~(1 << octetsBit); - } - -} /* ClrAsnBit */ - - -/* - * Get given bit. Most significant bit is bit 0, least significant - * is bit (v1->bitLen -1). Returns TRUE if the bit is 1. Returns FALSE - * if the bit is 0. if the bit is out of range then returns 0. - */ -int -GetAsnBit PARAMS ((b1, bit), - AsnBits *b1 _AND_ - unsigned long int bit) -{ - unsigned long int octet; - unsigned long int octetsBit; - - if (bit < b1->bitLen) - { - octet = bit/8; - octetsBit = 7 - (bit % 8); /* bit zero is first/most sig bit in octet*/ - return b1->bits[octet] & (1 << octetsBit); - } - return 0; -} /* AsnBits::GetBit */ diff --git a/SecuritySNACCRuntime/c-lib/src/asn-bool.c b/SecuritySNACCRuntime/c-lib/src/asn-bool.c deleted file mode 100644 index 44fe2d70..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-bool.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_bool.c - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-bool.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-bool.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:30 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 21:04:49 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:05:57 rj - * reduce the risk of unwanted surprises with macro expansion by properly separating the C tokens. - * - * Revision 1.1 1994/08/28 09:45:51 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-bool.h" - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 BOOLEAN - */ -AsnLen -BEncAsnBool PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnBool *data) -{ - AsnLen len; - - len = BEncAsnBoolContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, BOOLEAN_TAG_CODE); - return len; -} /* BEncAsnBool */ - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 BOOLEAN - */ -void -BDecAsnBool PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnBool *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE)) - { - Asn1Error ("BDecAsnBool: ERROR - wrong tag on BOOLEAN.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecAsnBoolContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecAsnBool */ - -/* - * Encodes just the content of the given BOOLEAN value to the given buffer. - */ -AsnLen -BEncAsnBoolContent PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnBool *data) -{ - BufPutByteRvs (b, *data ? 0xFF : 0); - return 1; -} /* BEncAsnBoolContent */ - -/* - * Decodes just the content of an ASN.1 BOOLEAN from the given buffer. - * longjmps if there is a buffer reading problem - */ -void -BDecAsnBoolContent PARAMS ((b, tagId, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnTag tagId _AND_ - AsnLen len _AND_ - AsnBool *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - if (len != 1) - { - Asn1Error ("BDecAsnBoolContent: ERROR - BOOLEAN length must be 1\n"); - longjmp (env,-5); - } - - (*bytesDecoded)++; - *result = (BufGetByte (b) != 0); - - if (BufReadError (b)) - { - Asn1Error ("BDecAsnBoolContent: ERROR - decoded past end of data\n"); - longjmp (env, -6); - } -} /* BDecAsnBoolContent */ - -/* - * Prints the given BOOLEAN to the given FILE * in ASN.1 Value notation. - * Does not use the indent. - */ -void -PrintAsnBool PARAMS ((f, v, indent), - FILE *f _AND_ - AsnBool *v _AND_ - unsigned short int indent) -{ - if (*v) - fprintf (f, "TRUE"); - else - fprintf (f, "FALSE"); -} diff --git a/SecuritySNACCRuntime/c-lib/src/asn-enum.c b/SecuritySNACCRuntime/c-lib/src/asn-enum.c deleted file mode 100644 index e3e78dd7..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-enum.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_enum.c - routines for the ASN.1 ENUMERATED type - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-enum.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-enum.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:30 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 21:04:50 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 01:04:38 rj - * reduce the risk of unwanted surprises with macro expansion by properly separating the C tokens. - * - * Revision 1.1 1994/08/28 09:45:52 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-int.h" -#include "asn-enum.h" - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 ENUMERATED - */ -AsnLen -BEncAsnEnum PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnEnum *data) -{ - AsnLen len; - - len = BEncAsnEnumContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, ENUM_TAG_CODE); - return len; -} /* BEncAsnEnum */ - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 ENUMERATED - */ -void -BDecAsnEnum PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnEnum *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, ENUM_TAG_CODE)) - { - Asn1Error ("BDecAsnInt: ERROR wrong tag on ENUMERATED.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecAsnEnumContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecAsnEnum */ diff --git a/SecuritySNACCRuntime/c-lib/src/asn-int.c b/SecuritySNACCRuntime/c-lib/src/asn-int.c deleted file mode 100644 index 01eff1d5..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-int.c +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_int.c - BER encode, decode, print and free routines for the - * ASN.1 INTEGER type - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-int.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-int.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:30 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 21:04:51 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:05:05 rj - * reduce the risk of unwanted surprises with macro expansion by properly separating the C tokens. - * - * Revision 1.1 1994/08/28 09:45:53 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-int.h" - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 INTEGER - */ -AsnLen -BEncAsnInt PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnInt *data) -{ - AsnLen len; - - len = BEncAsnIntContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - return len; -} /* BEncAsnInt */ - - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 INTEGER - */ -void -BDecAsnInt PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnInt *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - { - Asn1Error ("BDecAsnInt: ERROR wrong tag on INTEGER.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecAsnIntContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecAsnInt */ - - -/* - * encodes signed long integer's contents - */ -AsnLen -BEncAsnIntContent PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnInt *data) -{ - int len; - int i; - unsigned long int mask; - unsigned long int dataCpy; - -#define INT_MASK (0x7f80 << ((sizeof(AsnInt) - 2) * 8)) - - dataCpy = *data; - - /* - * calculate encoded length of the integer (content) - */ - mask = INT_MASK; - if ((long int)dataCpy < 0) - for (len = sizeof (AsnInt); len > 1; --len) - { - if ((dataCpy & mask) == mask) - mask >>= 8; - else - break; - } - else - for (len = sizeof (AsnInt); len > 1; --len) - { - if ((dataCpy & mask) == 0) - mask >>= 8; - else - break; - } - - /* - * write the BER integer - */ - for (i = 0; i < len; i++) - { - BufPutByteRvs (b, dataCpy); - dataCpy >>= 8; - } - - return len; - -} /* BEncAsnIntContent */ - - -/* - * Decodes content of BER a INTEGER value. The given tag is ignored. - */ -void -BDecAsnIntContent PARAMS ((b, tagId, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnTag tagId _AND_ - AsnLen len _AND_ - AsnInt *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - int i; - long int retVal; - unsigned long int byte; - - - if (len > sizeof (AsnInt)) - { - Asn1Error ("BDecAsnIntContent: ERROR - integer to big to decode.\n"); - longjmp (env, -7); - } - - /* - * look at integer value - */ - byte = (unsigned long int) BufGetByte (b); - - if (byte & 0x80) /* top bit of first byte is sign bit */ - retVal = (-1 << 8) | byte; - else - retVal = byte; - - /* - * write from buffer into long int - */ - for (i = 1; i < len; i++) - retVal = (retVal << 8) | (unsigned long int)(BufGetByte (b)); - - if (BufReadError (b)) - { - Asn1Error ("BDecAsnIntContent: ERROR - decoded past end of data \n"); - longjmp (env, -8); - } - (*bytesDecoded) += len; - - *result = retVal; - -} /* BDecAsnIntContent */ - - -/* - * Prints the given integer to the given FILE * in Value Notation. - * indent is ignored. - */ -void -PrintAsnInt PARAMS ((f, v, indent), - FILE *f _AND_ - AsnInt *v _AND_ - unsigned short int indent) -{ - fprintf (f,"%d", *v); -} - - -/* - * The following deal with UNSIGNED long ints. - * They do the same as the above routines for unsigned values. - * - * The compiler generated code does not call them. (It should - * based on subtype info but it does not). - */ - - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 INTEGER - */ -AsnLen -BEncUAsnInt PARAMS ((b, data), - BUF_TYPE b _AND_ - UAsnInt *data) -{ - AsnLen len; - - len = BEncUAsnIntContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); - return len; -} /* BEncUAsnInt */ - - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 INTEGER - */ -void -BDecUAsnInt PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - UAsnInt *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - { - Asn1Error ("BDecAsnInt: ERROR wrong tag on INTGER.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecUAsnIntContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecUAsnInt */ - - -/* - * encodes unsigned long integer. This allows you to correctly - * handle unsiged values that used the most significant (sign) bit. - */ -AsnLen -BEncUAsnIntContent PARAMS ((b, data), - BUF_TYPE b _AND_ - UAsnInt *data) -{ - int len; - int i; - unsigned long int mask; - unsigned long int dataCpy; - - dataCpy = *data; - - /* - * calculate encoded length of the integer (content) - */ - mask = INT_MASK; - if ((long int)dataCpy < 0) - { - /*write integer as normal (remember writing in reverse) */ - for (i = 0; i < sizeof (UAsnInt); i++) - { - BufPutByteRvs (b, dataCpy); - dataCpy >>= 8; - } - /* - * write zero byte at beginning of int, since high bit - * is set and need to differentiate between sign - * bit and high bit in unsigned case. - * (this code follows the prev for loop since writing - * in reverse) - */ - BufPutByteRvs (b, 0); - - return sizeof (UAsnInt)+1; - } - else - { - for (len = sizeof (UAsnInt); len > 1; --len) - { - if ((dataCpy & mask) == 0) - mask >>= 8; - else - break; - } - - /* write the BER integer */ - for (i = 0; i < len; i++) - { - BufPutByteRvs (b, dataCpy); - dataCpy >>= 8; - } - return len; - } - -} /* BEncUAsnIntContent */ - - -/* - * decode integer portion - no tag or length expected or decoded - * assumes unsigned integer - This routine is useful for - * integer subtyped to > 0 eg Guage ::= INTEGER (0..4294967295) - */ -void -BDecUAsnIntContent PARAMS ((b, tag, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnTag tag _AND_ - AsnLen len _AND_ - UAsnInt *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - int i; - unsigned long int retVal; - - retVal = (unsigned long int) BufGetByte (b); - - if (len > (sizeof (UAsnInt)+1)) - { - Asn1Error ("BDecUAsnIntContent: ERROR - integer to big to decode.\n"); - longjmp (env, -9); - } - else if (retVal & 0x80) /* top bit of first byte is sign bit */ - { - Asn1Error ("BDecUAsnIntContent: ERROR - integer is negative.\n"); - longjmp (env, -10); - } - else if ((len == (sizeof (UAsnInt)+1)) && (retVal != 0)) - { - /* - * first octet must be zero 5 octets long - extra 0 octet - * at beginning is only used for value > 0 that need the - * high bit - */ - Asn1Error ("BDecUAsnIntContent: ERROR - integer is negative.\n"); - longjmp (env, -11); - } - - /* - * write from buffer into long int - */ - for (i = 1; i < len; i++) - retVal = (retVal << 8) | (unsigned long int)(BufGetByte (b)); - - if (BufReadError (b)) - { - Asn1Error ("BDecUIntegerContent: ERROR - decoded past end of data\n"); - longjmp (env, -12); - } - (*bytesDecoded) += len; - - *result = retVal; - -} /* BDecUAsnIntContent */ - - -void -PrintUAsnInt PARAMS ((f, v, indent), - FILE *f _AND_ - UAsnInt *v _AND_ - unsigned short int indent) -{ - fprintf (f, "%u", *v); -} diff --git a/SecuritySNACCRuntime/c-lib/src/asn-len.c b/SecuritySNACCRuntime/c-lib/src/asn-len.c deleted file mode 100644 index 12e0f51f..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-len.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_len.c - BER encode, decode and utilities for ASN.1 lengths. - * - * indefinite lens are representd by the highest AsnLen - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-len.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-len.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:30 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/27 08:58:36 rj - * merged PeekEoc(), a function used only by the type table code. - * - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:45:54 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" - - -AsnLen -BEncDefLen PARAMS ((b, len), - BUF_TYPE b _AND_ - AsnLen len) -{ - /* - * unrolled for efficiency - * check each possibitlity of the 4 byte integer - */ - if (len < 128) - { - BufPutByteRvs (b, len); - return 1; - } - else if (len < 256) - { - BufPutByteRvs (b, len); - BufPutByteRvs (b, 0x81); - return 2; - } - else if (len < 65536) - { - BufPutByteRvs (b, len); - BufPutByteRvs (b, len >> 8); - BufPutByteRvs (b, 0x82); - return 3; - } - else if (len < 16777126) - { - BufPutByteRvs (b, len); - BufPutByteRvs (b, len >> 8); - BufPutByteRvs (b, len >> 16); - BufPutByteRvs (b, 0x83); - return 4; - } - else - { - BufPutByteRvs (b, len); - BufPutByteRvs (b, len >> 8); - BufPutByteRvs (b, len >> 16); - BufPutByteRvs (b, len >> 24); - BufPutByteRvs (b, 0x84); - return 5; - } -} /* BEncDefLen */ - - -/* - * non unrolled version - */ -AsnLen -BEncDefLen2 PARAMS ((b, len), - BUF_TYPE b _AND_ - long int len) -{ - int i; - unsigned long int j; - - if (len < 128) - { - BufPutByteRvs (b, len); - return 1; - } - else - { - for (i = 0, j = len; j > 0; j >>= 8, i++) - BufPutByteRvs (b, j); - - BufPutByteRvs (b, 0x80 | i); - return i + 1; - } - -} /* BEncDefLen2 */ - - -/* - * decodes and returns an ASN.1 length - */ -AsnLen -BDecLen PARAMS ((b, bytesDecoded, env), - BUF_TYPE b _AND_ - unsigned long int *bytesDecoded _AND_ - jmp_buf env) -{ - AsnLen len; - AsnLen byte; - int lenBytes; - - byte = (unsigned long int) BufGetByte (b); - - if (BufReadError (b)) - { - Asn1Error ("BDecLen: ERROR - decoded past end of data\n"); - longjmp (env, -13); - } - - (*bytesDecoded)++; - if (byte < 128) /* short length */ - return byte; - - else if (byte == (AsnLen) 0x080) /* indef len indicator */ - return INDEFINITE_LEN; - - else /* long len form */ - { - /* - * strip high bit to get # bytes left in len - */ - lenBytes = byte & (AsnLen) 0x7f; - - if (lenBytes > sizeof (AsnLen)) - { - Asn1Error ("BDecLen: ERROR - length overflow\n"); - longjmp (env, -14); - } - - (*bytesDecoded) += lenBytes; - - for (len = 0; lenBytes > 0; lenBytes--) - len = (len << 8) | (AsnLen) BufGetByte (b); - - - if (BufReadError (b)) - { - Asn1Error ("BDecLen: ERROR - decoded past end of data\n"); - longjmp (env, -15); - } - - return len; - } - /* not reached */ -} /* BDecLen */ - - -/* MACRO -AsnLen -BEncEoc PARAMS ((b), - BUF_TYPE b) -{ - BufPutByteRvs (b, 0); - BufPutByteRvs (b, 0); - return 2; -} BEncEoc */ - -/* - * Decodes an End of Contents (EOC) marker from the given buffer. - * Flags and error if the octets are non-zero or if a read error - * occurs. Increments bytesDecoded by the length of the EOC marker. - */ -void -BDecEoc PARAMS ((b, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - if ((BufGetByte (b) != 0) || (BufGetByte (b) != 0) || BufReadError (b)) - { - Asn1Error ("BDecEoc: ERROR - non zero byte in EOC or end of data reached\n"); - longjmp (env, -16); - } - (*bytesDecoded) += 2; - -} /* BDecEoc */ - -#if TTBL -/* returns true if the next tag is actually and EOC */ -int PeekEoc PARAMS ((b), - BUF_TYPE b) -{ - return BufPeekByte (b) == 0; -} /* PeekEoc */ -#endif diff --git a/SecuritySNACCRuntime/c-lib/src/asn-list.c b/SecuritySNACCRuntime/c-lib/src/asn-list.c deleted file mode 100644 index d9b220aa..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-list.c +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_list.c - borrowed from Murray Goldberg - * - * the following routines implement the list data structure - * - * Copyright (C) 1992 the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-list.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-list.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:30 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/27 08:59:36 rj - * merged GetAsnListElmt(), a function used only by the type table code. - * - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:45:55 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-list.h" - -/* remove the entire list and all its nodes (not the actual list data elmts) */ -/* this is set up for the snace compiler */ -void -AsnListFree PARAMS ((list), - AsnList *list) -{ - AsnListNode *node, *next; - - node = list->first; - while (node) - { - next = node->next; - Asn1Free (node); - node = next; - } - - Asn1Free (list); -} /* AsnListFree */ - - -/* - * this routine removes the current node from the list. After removal the - * current pointer will point to the next node in line, or NULL if the - * removed item was at the tail of the list. - */ -void -AsnListRemove PARAMS ((list), - AsnList *list) -{ - AsnListNode *node; - - if (list->curr) - { - if (list->curr->next) - list->curr->next->prev = list->curr->prev; - else - list->last = list->curr->prev; - - if (list->curr->prev) - list->curr->prev->next = list->curr->next; - else - list->first = list->curr->next; - - node = list->curr; - - list->curr = list->curr->next; - list->count--; - - Asn1Free (node); - } -} - -/* - * this creates a new node after the current node and returns the - * address of the memory allocated for data. The current pointer is changed - * to point to the newly added node in the list. If the current pointer is - * initially off the list then this operation fails. - */ -void* -AsnListAdd PARAMS ((list), - AsnList *list) -{ - AsnListNode *newNode; - void *dataAddr; - - if (list->curr) - { - newNode = (AsnListNode *) Asn1Alloc (sizeof (AsnListNode) + list->dataSize); - dataAddr = (void *) &(newNode->data); - - newNode->next = list->curr->next; - newNode->prev = list->curr; - if (list->curr->next) - list->curr->next->prev = newNode; - else - list->last = newNode; - list->curr->next = newNode; - - list->curr = newNode; - list->count++; - } - - else - dataAddr = NULL; - - return dataAddr; -} - -/* - * this creates a new node before the current node and returns the - * address of the memory allocated for data. The current pointer is changed - * to point to the newly added node in the list. If the current pointer is - * initially off the list then this operation fails. - */ -void* -AsnListInsert PARAMS ((list), - AsnList *list) -{ - AsnListNode *newNode; - void *dataAddr; - - if (list->curr) - { - newNode = (AsnListNode *) Asn1Alloc (sizeof (AsnListNode) + list->dataSize); - dataAddr = (void *) &(newNode->data); - - newNode->next = list->curr; - newNode->prev = list->curr->prev; - if (list->curr->prev) - list->curr->prev->next = newNode; - else - list->first = newNode; - list->curr->prev = newNode; - - list->curr = newNode; - list->count++; - } - - else - dataAddr = NULL; - - return dataAddr; -} - - -void -AsnListInit PARAMS ((list, dataSize), - AsnList *list _AND_ - int dataSize) -{ - list->first = list->last = list->curr = NULL; - list->count = 0; - list->dataSize = dataSize; - -} /* AsnListInit */ - - -AsnList* -AsnListNew PARAMS ((dataSize), - int dataSize) -{ - AsnList *list; - - list = (AsnList *) Asn1Alloc (sizeof (AsnList)); - list->first = list->last = list->curr = NULL; - list->count = 0; - list->dataSize = dataSize; - - return list; -} - -/* - * backs up the current pointer by one and returns the data address of the new - * current node. If the current pointer is off the list, the new current node - * will be the last node of the list (unless the list is empty). - */ -void* -AsnListPrev PARAMS ((list), - AsnList *list) -{ - void *retVal; - - if (list->curr == NULL) - list->curr = list->last; - else - list->curr = list->curr->prev; - - if (list->curr == NULL) - retVal = NULL; - else - retVal = (void *) &(list->curr->data); - - return retVal; -} - -/* - * advances the current pointer by one and returns the data address of the new - * current node. If the current pointer is off the list, the new current node - * will be the first node of the list (unless the list is empty). - */ -void* -AsnListNext PARAMS ((list), - AsnList *list) -{ - void *retVal; - - if (list->curr == NULL) - list->curr = list->first; - else - list->curr = list->curr->next; - - if (list->curr == NULL) - retVal = NULL; - else - retVal = (void *) &(list->curr->data); - - return retVal; -} - -/* - * returns the data address of the last node (if there is one) and sets the - * current pointer to this node. - */ -void* -AsnListLast PARAMS ((list), - AsnList *list) -{ - void *retVal; - - list->curr = list->last; - - if (list->curr == NULL) - retVal = NULL; - else - retVal = (void *) &(list->curr->data); - - return retVal; -} - -/* - * returns the data address of the first node (if there is one) and sets the - * current pointer to this node. - */ -void* -AsnListFirst PARAMS ((list), - AsnList *list) -{ - void *retVal; - - list->curr = list->first; - - if (list->curr == NULL) - retVal = NULL; - else - retVal = (void *) &(list->curr->data); - - return retVal; -} - -/* - * this creates a new node at the beginning of the list and returns the - * address of the memory allocated for data. The current pointer is changed - * to point to the newly added node in the list. - */ -void* -AsnListPrepend PARAMS ((list), - AsnList *list) -{ - AsnListNode *newNode; - void *dataAddr; - - newNode = (AsnListNode *) Asn1Alloc (sizeof (AsnListNode) + list->dataSize); - dataAddr = (void *) &(newNode->data); - - newNode->prev = NULL; - - if (list->first == NULL) - { - newNode->next = NULL; - list->first = list->last = newNode; - } - else - { - newNode->next = list->first; - list->first->prev = newNode; - list->first = newNode; - } - - list->curr = newNode; - list->count++; - - return dataAddr; -} - -/* - * this creates a new node at the end of the list and returns the - * address of the memory allocated for data. The current pointer is changed - * to point to the newly added node in the list. - */ -void* -AsnListAppend PARAMS ((list), - AsnList *list) -{ - AsnListNode *newNode; - void *dataAddr; - - newNode = (AsnListNode *) Asn1Alloc (sizeof (AsnListNode) + list->dataSize); - dataAddr = (void *) &(newNode->data); - - newNode->next = NULL; - - if (list->last == NULL) - { - newNode->prev = NULL; - list->first = list->last = newNode; - } - else - { - newNode->prev = list->last; - list->last->next = newNode; - list->last = newNode; - } - - list->curr = newNode; - list->count++; - - return dataAddr; -} - -void* -AsnListCurr PARAMS ((list), - AsnList *list) -{ - void *retVal; - - if (list->curr) - retVal = (void *) &(list->curr->data); - else - retVal = NULL; - - return retVal; -} - -int -AsnListCount PARAMS ((list), - AsnList *list) -{ - return list->count; -} - - -AsnList* -AsnListConcat PARAMS ((l1,l2), - AsnList *l1 _AND_ - AsnList *l2) -{ - if (l2->count == 0) - return l1; - - if (l1->count == 0) - { - l1->count = l2->count; - l1->last = l2->last; - l1->first = l2->first; - l1->curr = l1->first; - } - else - { - l1->count += l2->count; - l1->last->next = l2->first; - l2->first->prev = l1->last; - l1->last = l2->last; - } - - return l1; -} - - -/* - * Returns the index (starting a 0 for the first elmt) - * of the given elmt in the given list - * returns -1 if the elmt is not in the list - * Assumes that the list node contains a single pointer - */ -long int -GetAsnListElmtIndex PARAMS ((elmt, list), - void *elmt _AND_ - AsnList *list) -{ - void *tmp; - void *tmpElmt; - long int index; - - index = 0; - tmp = (void*) CURR_LIST_NODE (list); - FOR_EACH_LIST_ELMT (tmpElmt, list) - { - if (tmpElmt == elmt) - { - SET_CURR_LIST_NODE (list, tmp); - return index; - } - else - index++; - } - - SET_CURR_LIST_NODE (list, tmp); - return -1; - -} /* GetAsnListElmtIndex */ - - -#if TTBL -/* - * Returns the element with the given index. - * indexes start a 0 for the first elmt. - * returns NULL if the index is too large. - * Assumes that the list node contains a single pointer. - */ -void* -GetAsnListElmt PARAMS ((list, index), - AsnList *list _AND_ - unsigned int index) -{ - void *tmp; - void *tmpElmt; - long int currIndex; - - if (index > LIST_COUNT (list)) - return NULL; - - currIndex = 0; - tmp = (void*) CURR_LIST_NODE (list); - FOR_EACH_LIST_ELMT (tmpElmt, list) - { - if (currIndex == index) - { - SET_CURR_LIST_NODE (list, tmp); - return tmpElmt; - } - currIndex++; - } - SET_CURR_LIST_NODE (list, tmp); - return NULL; - -} /* GetAsnListElmt */ -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/src/asn-null.c b/SecuritySNACCRuntime/c-lib/src/asn-null.c deleted file mode 100644 index 18ca2caf..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-null.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_null.c - BER encode, decode, print and free routines for the - * ASN.1 NULL type. - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-null.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-null.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:31 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 21:04:52 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:06:08 rj - * reduce the risk of unwanted surprises with macro expansion by properly separating the C tokens. - * - * Revision 1.1 1994/08/28 09:45:57 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-null.h" - - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 NULL - */ -AsnLen -BEncAsnNull PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnNull *data) -{ - AsnLen len; - - len = BEncAsnNullContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, NULLTYPE_TAG_CODE); - return len; -} /* BEncAsnNull */ - - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 NULL - */ -void -BDecAsnNull PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnNull *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, NULLTYPE_TAG_CODE)) - { - Asn1Error ("BDecAsnNull: ERROR wrong tag on NULL.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecAsnNullContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecAsnNull */ - - -void -BDecAsnNullContent PARAMS ((b, tagId, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnTag tagId _AND_ - AsnLen len _AND_ - AsnNull *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - if (len != 0) - { - Asn1Error ("BDecAsnNullContent: ERROR - NULL type's len must be 0\n"); - longjmp (env, -17); - } -} /* BDecAsnNullContent */ - -/* - * Prints the NULL value to the given FILE * in Value Notation. - * ignores the indent. - */ -void -PrintAsnNull PARAMS ((f,v, indent), - FILE *f _AND_ - AsnNull *v _AND_ - unsigned short int indent) -{ - fprintf (f, "NULL"); -} diff --git a/SecuritySNACCRuntime/c-lib/src/asn-octs.c b/SecuritySNACCRuntime/c-lib/src/asn-octs.c deleted file mode 100644 index 24100162..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-octs.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * .../c-lib/src/asn-octs.c - BER encode, decode, print and free routines for the ASN.1 OCTET STRING type. - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-octs.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-octs.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:31 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/27 09:00:32 rj - * use memcmpeq that is defined in .../snacc.h to use either memcmp or bcmp. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:06:15 rj - * reduce the risk of unwanted surprises with macro expansion by properly separating the C tokens. - * - * Revision 1.1 1994/08/28 09:45:58 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "str-stk.h" -#include "asn-bits.h" /* for TO_HEX macro */ -#include "asn-octs.h" - - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 OCTET STRING - */ -AsnLen -BEncAsnOcts PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnOcts *data) -{ - AsnLen len; - - len = BEncAsnOctsContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); - return len; -} /* BEncAsnOcts */ - - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 OCTET STRING - */ -void -BDecAsnOcts PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnOcts *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) && (tag != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error ("BDecAsnOcts: ERROR - wrong tag on OCTET STRING.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecAsnOctsContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecAsnOcts */ - -/* - * BER encodes just the content of an OCTET STRING. - */ -AsnLen -BEncAsnOctsContent PARAMS ((b, o), - BUF_TYPE b _AND_ - AsnOcts *o) -{ - BufPutSegRvs (b, o->octs, o->octetLen); - return o->octetLen; -} /* BEncAsnOctsContent */ - - - -/* - * Used for decoding constructed OCTET STRING values into - * a contiguous local rep. - * fills string stack with references to the pieces of a - * construced octet string - */ -static void -FillOctetStringStk PARAMS ((b, elmtLen0, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnLen elmtLen0 _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - unsigned long int refdLen; - unsigned long int totalRefdLen; - char *strPtr; - unsigned long int totalElmtsLen1 = 0; - unsigned long int tagId1; - unsigned long int elmtLen1; - - for (; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN); ) - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env); - break; - } - - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - if (tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) - { - /* - * primitive part of string, put references to piece (s) in - * str stack - */ - totalRefdLen = 0; - refdLen = elmtLen1; - while (1) - { - strPtr = BufGetSeg (b, &refdLen); - - PUSH_STR (strPtr, refdLen, env); - totalRefdLen += refdLen; - if (totalRefdLen == elmtLen1) - break; /* exit this while loop */ - - if (refdLen == 0) /* end of data */ - { - Asn1Error ("BDecConsOctetString: ERROR - attempt to decode past end of data\n"); - longjmp (env, -18); - } - refdLen = elmtLen1 - totalRefdLen; - } - totalElmtsLen1 += elmtLen1; - } - - - else if (tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE)) - { - /* - * constructed octets string embedding in this constructed - * octet string. decode it. - */ - FillOctetStringStk (b, elmtLen1, &totalElmtsLen1, env); - } - else /* wrong tag */ - { - Asn1Error ("BDecConsOctetString: ERROR - decoded non-OCTET STRING tag inside a constructed OCTET STRING\n"); - longjmp (env, -19); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; - -} /* FillOctetStringStk */ - - -/* - * Decodes a seq of universally tagged octets strings until either EOC is - * encountered or the given len is decoded. Merges them into a single - * string. puts a NULL terminator on the string but does not include - * this in the length. - */ -static void -BDecConsAsnOcts PARAMS ((b, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnLen len _AND_ - AsnOcts *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - char *bufCurr; - unsigned long int curr; - - RESET_STR_STK(); - - /* - * decode each piece of the octet string, puting - * an entry in the octet string stack for each - */ - FillOctetStringStk (b, len, bytesDecoded, env); - - result->octetLen = strStkG.totalByteLen; - - /* alloc str for all octs pieces with extra byte for null terminator */ - bufCurr = result->octs = Asn1Alloc (strStkG.totalByteLen +1); - - /* copy octet str pieces into single blk */ - for (curr = 0; curr < strStkG.nextFreeElmt; curr++) - { - memcpy (bufCurr, strStkG.stk[curr].str, strStkG.stk[curr].len); - bufCurr += strStkG.stk[curr].len; - } - - /* add null terminator - this is not included in the str's len */ - *bufCurr = '\0'; - -} /* BDecConsAsnOcts */ - -/* - * Decodes the content of a BER OCTET STRING value - */ -void -BDecAsnOctsContent PARAMS ((b, tagId, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnTag tagId _AND_ - AsnLen len _AND_ - AsnOcts *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - /* - * tagId is encoded tag shifted into long int. - * if CONS bit is set then constructed octet string - */ - if (TAG_IS_CONS (tagId)) - BDecConsAsnOcts (b, len, result, bytesDecoded, env); - - else /* primitive octet string */ - { - result->octetLen = len; - result->octs = Asn1Alloc (len+1); - BufCopy (result->octs, b, len); - - if (BufReadError (b)) - { - Asn1Error ("BDecOctetString: ERROR - decoded past end of data\n"); - longjmp (env, -20); - } - - /* add null terminator - this is not included in the str's len */ - result->octs[len] = '\0'; - (*bytesDecoded) += len; - } -} /* BDecAsnOctsContent */ - - -/* - * Frees the string part of the given OCTET STRING - */ -void -FreeAsnOcts PARAMS ((v), - AsnOcts *v) -{ - Asn1Free (v->octs); -} /* FreeAsnOcts */ - -/* - * Prints the given OCTET STRING value to the given FILE * in ASN.1 - * Value Notation. Since the value notation uses the hard to read - * hex format, the ASCII version is included in an ASN.1 comment. - */ -void -PrintAsnOcts PARAMS ((f,v, indent), - FILE *f _AND_ - AsnOcts *v _AND_ - unsigned short indent) -{ - int i; - - /* print hstring value */ - fprintf (f,"'"); - - for (i = 0; i < v->octetLen; i++) - fprintf (f,"%c%c", TO_HEX (v->octs[i] >> 4), TO_HEX (v->octs[i])); - - fprintf (f,"'H"); - - /* show printable chars in comment */ - fprintf (f," -- \""); - - for (i = 0; i < v->octetLen; i++) - { - if (isprint (v->octs[i])) - fprintf (f,"%c", v->octs[i]); - else - fprintf (f,"."); - } - fprintf (f,"\" --"); -} - - -/* - * Returns TRUE if the given OCTET STRING values are identical. - * Returns FALSE otherwise. - */ -int -AsnOctsEquiv PARAMS ((o1, o2), - AsnOcts *o1 _AND_ - AsnOcts *o2) -{ - return o1->octetLen == o2->octetLen && !memcmpeq (o1->octs, o2->octs, o1->octetLen); -} /* AsnOctsEquiv */ diff --git a/SecuritySNACCRuntime/c-lib/src/asn-oid.c b/SecuritySNACCRuntime/c-lib/src/asn-oid.c deleted file mode 100644 index 97ec881a..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-oid.c +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_oid.c - BER encode, decode, print and free routines for the - * ASN.1 OBJECT IDENTIFIER type. - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-oid.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-oid.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:31 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 21:04:53 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:06:21 rj - * reduce the risk of unwanted surprises with macro expansion by properly separating the C tokens. - * - * Revision 1.1 1994/08/28 09:45:59 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-octs.h" -#include "asn-oid.h" - - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 OBJECT ID - */ -AsnLen -BEncAsnOid PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnOid *data) -{ - AsnLen len; - - len = BEncAsnOidContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); - return len; -} /* BEncAsnOid */ - - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 OBJECT ID - */ -void -BDecAsnOid PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnOid *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)) - { - Asn1Error ("BDecAsnOid: ERROR - wrong tag on OBJECT IDENTIFIER.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecAsnOidContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecAsnOid */ - - - -/* - * Decodes just the content of the OID. - * AsnOid is handled the same as a primtive octet string - */ -void -BDecAsnOidContent PARAMS ((b, tagId, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnTag tagId _AND_ - AsnLen len _AND_ - AsnOid *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - result->octetLen = len; - result->octs = Asn1Alloc (len); - BufCopy (result->octs, b, len); - if (BufReadError (b)) - { - Asn1Error ("BDecAsnOidContent: ERROR - decoded past end of data\n"); - longjmp (env, -21); - } - (*bytesDecoded) += len; -} /* BDecAsnOidContent */ - - - -/* - * Prints the given OID to the given FILE * in ASN.1 Value Notation. - * Since the internal rep of an OID is 'encoded', this routine - * decodes each individual arc number to print it. - */ -void -PrintAsnOid PARAMS ((f,v, indent), - FILE *f _AND_ - AsnOid *v _AND_ - unsigned short int indent) -{ - unsigned short int firstArcNum; - unsigned long int arcNum; - int i; - - fprintf (f,"{"); - - /* un-munge first two arc numbers */ - for (arcNum = 0, i=0; (i < v->octetLen) && (v->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - i++; - firstArcNum = arcNum/40; - if (firstArcNum > 2) - firstArcNum = 2; - - fprintf (f,"%u %u", firstArcNum, arcNum - (firstArcNum * 40)); - - for (; i < v->octetLen; ) - { - for (arcNum = 0; (i < v->octetLen) && (v->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - i++; - fprintf (f," %u", arcNum); - } - fprintf (f,"}"); - -} /* PrintAsnOid */ - - - -/* - * given an OID, figures out the length for the encoded version - */ -AsnLen -EncodedOidLen PARAMS ((oid), - OID *oid) -{ - AsnLen totalLen; - unsigned long headArcNum; - unsigned long tmpArcNum; - OID *tmpOid; - - /* - * oid must have at least 2 elmts - */ - if (oid->next == NULL) - return 0; - - headArcNum = (oid->arcNum * 40) + oid->next->arcNum; - - /* - * figure out total encoded length of oid - */ - tmpArcNum = headArcNum; - for (totalLen = 1; (tmpArcNum >>= 7) != 0; totalLen++) - ; - for (tmpOid = oid->next->next; tmpOid != NULL; tmpOid = tmpOid->next) - { - totalLen++; - tmpArcNum = tmpOid->arcNum; - for (; (tmpArcNum >>= 7) != 0; totalLen++) - ; - } - - return totalLen; - -} /* EncodedOidLen */ - - -/* - * given an oid list and a pre-allocated ENC_OID - * (use EncodedOidLen to figure out byte length needed) - * fills the ENC_OID with a BER encoded version - * of the oid. - */ -void -BuildEncodedOid PARAMS ((oid, result), - OID *oid _AND_ - AsnOid *result) -{ - unsigned long len; - unsigned long headArcNum; - unsigned long tmpArcNum; - char *buf; - int i; - OID *tmpOid; - - buf = result->octs; - - /* - * oid must have at least 2 elmts - */ - if (oid->next == NULL) - return; - /* - * munge together first two arcNum - * note first arcnum must be <= 2 - * and second must be < 39 if first = 0 or 1 - * see (X.209) for ref to this stupidity - */ - headArcNum = (oid->arcNum * 40) + oid->next->arcNum; - - tmpArcNum = headArcNum; - - /* - * calc # bytes needed for head arc num - */ - for (len = 0; (tmpArcNum >>= 7) != 0; len++) - ; - - /* - * write more signifcant bytes (if any) of head arc num - * with 'more' bit set - */ - for (i=0; i < len; i++) - *(buf++) = 0x80 | (headArcNum >> ((len-i)*7)); - - /* - * write least significant byte of head arc num - */ - *(buf++) = 0x7f & headArcNum; - - - /* - * write following arc nums, if any - */ - for (tmpOid = oid->next->next; tmpOid != NULL; tmpOid = tmpOid->next) - { - /* - * figure out encoded length -1 of this arcNum - */ - tmpArcNum = tmpOid->arcNum; - for (len = 0; (tmpArcNum >>= 7) != 0; len++) - ; - - - /* - * write more signifcant bytes (if any) - * with 'more' bit set - */ - for (i=0; i < len; i++) - *(buf++) = 0x80 | (tmpOid->arcNum >> ((len-i)*7)); - - /* - * write least significant byte - */ - *(buf++) = 0x7f & tmpOid->arcNum; - } - -} /* BuildEncodedOid */ - - -/* - * convert an AsnOid into an OID (linked list) - * NOT RECOMMENDED for use in protocol implementations - */ -void -UnbuildEncodedOid PARAMS ((eoid, result), - AsnOid *eoid _AND_ - OID **result) -{ - OID **nextOid; - OID *headOid; - int arcNum; - int i; - int firstArcNum; - int secondArcNum; - - for (arcNum = 0, i=0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - i++; - - firstArcNum = arcNum / 40; - if (firstArcNum > 2) - firstArcNum = 2; - - secondArcNum = arcNum - (firstArcNum * 40); - - headOid = (OID*)malloc (sizeof (OID)); - headOid->arcNum = firstArcNum; - headOid->next = (OID*)malloc (sizeof (OID)); - headOid->next->arcNum = secondArcNum; - nextOid = &headOid->next->next; - - for (; i < eoid->octetLen; ) - { - for (arcNum = 0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80); i++) - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - i++; - *nextOid = (OID*)malloc (sizeof (OID)); - (*nextOid)->arcNum = arcNum; - nextOid = &(*nextOid)->next; - } - - *result = headOid; - -} /* UnbuildEncodedOid */ diff --git a/SecuritySNACCRuntime/c-lib/src/asn-real.c b/SecuritySNACCRuntime/c-lib/src/asn-real.c deleted file mode 100644 index 8e6e6cdc..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-real.c +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_real.c - BER encode, decode, print and free routines for ASN.1 REAL type. - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-real.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-real.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:31 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1997/02/28 13:39:50 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.4 1995/07/24 21:04:54 rj - * changed `_' to `-' in file names. - * - * Revision 1.3 1995/02/18 16:25:13 rj - * added support for CPU/compiler combination presenting 64 bit little endian long integers - * (in addition to the aforesupported 32 bit big endian long ints). - * - * Revision 1.2 1994/09/01 00:06:28 rj - * reduce the risk of unwanted surprises with macro expansion by properly separating the C tokens. - * - * Revision 1.1 1994/08/28 09:46:00 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" -#include "asn-real.h" - -double pow PROTO ((double base, double exp)); - -#ifdef IEEE_REAL_LIB -/* ieee functions (in case not in math.h)*/ -extern int iszero (double); -extern int isinf (double); -extern int signbit (double); -extern int ilogb (double); -extern double scalbn (double, int); -#endif - - -/* - * You must call InitAsnInfinity() to initailize these values - * (necessary if you deal with REAL values.) - */ -AsnReal PLUS_INFINITY; -AsnReal MINUS_INFINITY; - - -#define ENC_PLUS_INFINITY 0x40 -#define ENC_MINUS_INFINITY 0x41 - -#define REAL_BINARY 0x80 -#define REAL_SIGN 0x40 -#define REAL_EXPLEN_MASK 0x03 -#define REAL_EXPLEN_1 0x00 -#define REAL_EXPLEN_2 0x01 -#define REAL_EXPLEN_3 0x02 -#define REAL_EXPLEN_LONG 0x03 -#define REAL_FACTOR_MASK 0x0c -#define REAL_BASE_MASK 0x30 -#define REAL_BASE_2 0x00 -#define REAL_BASE_8 0x10 -#define REAL_BASE_16 0x20 - - -/* - * Returns the smallest octet length needed to - * hold the given long int value - */ -unsigned int -SignedIntOctetLen PARAMS ((val), - long int val) -{ - unsigned long int mask = (0x7f80L << ((sizeof (long int) - 2) * 8)); - unsigned int retVal = sizeof (long int); - - if (val < 0) - val = val ^ (~0L); /* XOR val with all 1's */ - - while ((retVal > 1) && ((val & mask) == 0)) - { - mask >>= 8; - retVal--; - } - - return retVal; - -} /* SignedIntOctetLen */ - - -/* - * encodes universal TAG LENGTH and Contents of and ASN.1 REAL - */ -AsnLen -BEncAsnReal PARAMS ((b, data), - BUF_TYPE b _AND_ - AsnReal *data) -{ - AsnLen len; - - len = BEncAsnRealContent (b, data); - len += BEncDefLen (b, len); - len += BEncTag1 (b, UNIV, PRIM, REAL_TAG_CODE); - return len; -} /* BEncAsnReal */ - - -/* - * decodes universal TAG LENGTH and Contents of and ASN.1 REAL - */ -void -BDecAsnReal PARAMS ((b, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnReal *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tag; - AsnLen elmtLen; - - if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, REAL_TAG_CODE)) - { - Asn1Error ("BDecAsnReal: ERROR wrong tag on REAL.\n"); - longjmp (env, -40); - } - - elmtLen = BDecLen (b, bytesDecoded, env); - BDecAsnRealContent (b, tag, elmtLen, result, bytesDecoded, env); - -} /* BDecAsnReal */ - - - -#ifdef IEEE_REAL_FMT - -/* - * Inits the PLUS_INFINITY and MINUS_INFINITY globals assuming - * that the double is an IEEE DOUBLE - * The bits for MINUS_INFINITY are 0xfff0000000000000 - * The bits for PLUS_INFINITY are 0x7ff0000000000000 - */ -void -InitAsnInfinity() -{ - unsigned char *c = (unsigned char *)&PLUS_INFINITY; - int i; - - if (sizeof (double) != 8) - Asn1Error ("InitAsnInfinity: ERROR expected sizeof (AsnReal) to be 8"); - -#if WORDS_BIGENDIAN /* Big endian */ - c[0] = 0x7f; - c[1] = 0xf0; - for (i = 2; i < sizeof (double); i++) - c[i] = 0; -#else /* Little endian */ - c[7] = 0x7f; - c[6] = 0xf0; - for (i = 0; i < 6; i++) - c[i] = 0; -#endif - - MINUS_INFINITY = -PLUS_INFINITY; -} /* InitAsnInfinity */ - -/* - * Encodes the content of an ASN.1 REAL value to the given buffer. - * This version of the routine ASSUMES that the C rep. of a double - * is the same as the IEEE std. - */ -AsnLen -BEncAsnRealContent PARAMS ((b, value), - BUF_TYPE b _AND_ - AsnReal *value) -{ - int exponent; - int isNeg; -#if SIZEOF_LONG == 4 - unsigned char *dbl; - unsigned long int *first4; - unsigned long int *second4; -#else -#if SIZEOF_LONG == 8 - unsigned long mantissa, val, *p; - int i; -#endif -#endif - - /* no contents for 0.0 reals */ - if (*value == 0.0) /* all bits zero, disregarding top/sign bit */ - return 0; - -#if SIZEOF_LONG == 4 -#if !WORDS_BIGENDIAN - #error sorry! this 32 bit code requires big endianess. -#endif - - /* this code is designed to work were longs are 32 bit wide and big endian */ - - dbl = (unsigned char *) value; - - first4 = (unsigned long int *) dbl; - second4 = (unsigned long int *) (dbl + sizeof (long int)); - - isNeg = dbl[0] & 0x80; - - /* special real values for +/- oo */ - if (((*first4 & 0x7fffffff) == 0x7ff00000) && (*second4 == 0)) - { - if (isNeg) - { - BufPutByteRvs (b, ENC_MINUS_INFINITY); - } - else - { - BufPutByteRvs (b, ENC_PLUS_INFINITY); - } - return 1; - } - else /* encode a binary real value */ - { - exponent = (((*first4) >> 20) & 0x07ff); - - /* write the mantissa (N value) */ - BufPutSegRvs (b, (char *)(dbl+2), sizeof (double)-2); - - /* - * The rightmost 4 bits of a double 2nd octet are the - * most sig bits of the mantissa. - * write the most signficant byte of the asn1 real mantissa, - * adding implicit bit to 'left of decimal' if not de-normalized - * (de normalized if exponent == 0) - * - * if the double is not in de-normalized form subtract 1023 - * from the exponent to get proper signed exponent. - * - * for both the normalized and de-norm forms - * correct the exponent by subtracting 52 since: - * 1. mantissa is 52 bits in the double (56 in ASN.1 REAL form) - * 2. implicit decimal at the beginning of double's mantissa - * 3. ASN.1 REAL's implicit decimal is after its mantissa - * so converting the double mantissa to the ASN.1 form has the - * effect of multiplying it by 2^52. Subtracting 52 from the - * exponent corrects this. - */ - if (exponent == 0) /* de-normalized - no implicit 1 to left of dec.*/ - { - BufPutByteRvs (b, dbl[1] & 0x0f); - exponent -= 52; - } - else - { - BufPutByteRvs (b, (dbl[1] & 0x0f) | 0x10); /* 0x10 adds implicit bit */ - exponent -= (1023 + 52); - } - -#else -#if SIZEOF_LONG == 8 -#if WORDS_BIGENDIAN - #error sorry! this 64 bit code requires little endianess. -#endif - - /* this code is designed to work on Alpha under OSF/1 (64 bit longs, little endian) */ - - p = (unsigned long *) value; - val = *p; - - isNeg = (val >> 63) & 1; - /* special real values for +/- oo */ - if (!finite (*value)) - { - if (isNeg) - { - BufPutByteRvs (b, ENC_MINUS_INFINITY); - } - else - { - BufPutByteRvs (b, ENC_PLUS_INFINITY); - } - return 1; - } - else /* encode a binary real value */ - { - exponent = (val >> 52) & 0x7ff; - mantissa = (val & 0xfffffffffffffL) | 0x10000000000000L; - - for (i = 0; i < 7; i++) - { - BufPutByteRvs (b, mantissa & 0xff); - mantissa >>= 8; - } - exponent -= (1023 + 52); - -#else - #error long neither 8 nor 4 bytes in size? -#endif -#endif - - /* write the exponent */ - BufPutByteRvs (b, exponent & 0xff); - BufPutByteRvs (b, exponent >> 8); - - /* write format octet */ - /* bb is 00 since base is 2 so do nothing */ - /* ff is 00 since no other shifting is nec */ - if (isNeg) - { - BufPutByteRvs (b, REAL_BINARY | REAL_EXPLEN_2 | REAL_SIGN); - } - else - { - BufPutByteRvs (b, REAL_BINARY | REAL_EXPLEN_2); - } - - return sizeof (double) + 2; - } - - /* not reached */ - -} /* BEncAsnRealContent */ - -#else /* IEEE_REAL_FMT not def */ - -#ifdef IEEE_REAL_LIB - - -/* - * Inits the PLUS_INFINITY and MINUS_INFINITY globals assuming - * that the ieee_values library is present - */ -void -InitAsnInfinity() -{ - PLUS_INFINITY = infinity(); - MINUS_INFINITY = -PLUS_INFINITY; -} /* InitAsnInfinity */ - -/* - * Encodes the content of an ASN.1 REAL value to the given buffer. - * This version of the routine does not assume an IEEE double rep. - * ieee library conversion routine are used instead. - */ -AsnLen -BEncAsnRealContent PARAMS ((b, value), - BUF_TYPE b _AND_ - AsnReal *value) -{ - unsigned long int encLen; - double mantissa; - double tmpMantissa; - unsigned int truncatedMantissa; - int exponent; - unsigned int expLen; - int sign; - unsigned char buf[sizeof (double)]; - int i, mantissaLen; - unsigned char firstOctet; - - /* no contents for 0.0 reals */ - if (iszero (*value)) - return 0; - - /* special real values for +/- oo */ - if (isinf (*value)) - { - if (signbit (*value)) /* neg */ - BufPutByteRvs (b, ENC_MINUS_INFINITY); - else - BufPutByteRvs (b, ENC_PLUS_INFINITY); - encLen = 1; - } - else /* encode a binary real value */ - { - if (signbit (*value)) - sign = -1; - else - sign = 1; - - exponent = ilogb (*value); - - /* get the absolute value of the mantissa (subtract 1 to make < 1) */ - mantissa = scalbn (fabs (*value), -exponent-1); - - - tmpMantissa = mantissa; - - /* convert mantissa into an unsigned integer */ - for (i = 0; i < sizeof (double); i++) - { - /* normalizied so shift 8 bits worth to the left of the decimal */ - tmpMantissa *= (1<<8); - - /* grab only (octet sized) the integer part */ - truncatedMantissa = (unsigned int) tmpMantissa; - - /* remove part to left of decimal now for next iteration */ - tmpMantissa -= truncatedMantissa; - - /* write into tmp buffer */ - buf[i] = truncatedMantissa; - - /* keep track of last non zero octet so can zap trailing zeros */ - if (truncatedMantissa) - mantissaLen = i+1; - } - - /* - * write format octet (first octet of content) - * field 1 S bb ff ee - * bit# 8 7 65 43 21 - * - * 1 in bit#1 means binary rep - * 1 in bit#2 means the mantissa is neg, 0 pos - * bb is the base: 65 base - * 00 2 - * 01 8 - * 10 16 - * 11 future ext. - * - * ff is the Value of F where Mantissa = sign x N x 2^F - * FF can be one of 0 to 3 inclusive. (used to save re-alignment) - * - * ee is the length of the exponent: 21 length - * 00 1 - * 01 2 - * 10 3 - * 11 long form - * - * - * encoded binary real value looks like - * - * fmt oct - * -------------------------------------------------------- - * |1Sbbffee| exponent (2's comp) | N (unsigned int) | - * -------------------------------------------------------- - * 87654321 - */ - firstOctet = REAL_BINARY; - if (signbit (*value)) - firstOctet |= REAL_SIGN; - - /* bb is 00 since base is 2 so do nothing */ - /* ff is 00 since no other shifting is nec */ - - /* - * get exponent calculate its encoded length - * Note that the process of converting the mantissa - * double to an int shifted the decimal mantissaLen * 8 - * to the right - so correct that here - */ - exponent++; /* compensate for trick to put mantissa < 1 */ - exponent -= (mantissaLen * 8); - expLen = SignedIntOctetLen (exponent); - - switch (expLen) - { - case 1: - firstOctet |= REAL_EXPLEN_1; - break; - case 2: - firstOctet |= REAL_EXPLEN_2; - break; - case 3: - firstOctet |= REAL_EXPLEN_3; - break; - default: - firstOctet |= REAL_EXPLEN_LONG; - break; - } - - encLen = mantissaLen + expLen + 1; - - /* write the mantissa (N value) */ - BufPutSegRvs (b, (char*)buf, mantissaLen); - - /* write the exponent */ - for (i = expLen; i > 0; i--) - { - BufPutByteRvs (b, exponent); - exponent >>= 8; - } - - /* write the exponents length if nec */ - if (expLen > 3) - { - encLen++; - BufPutByteRvs (b, expLen); - } - - /* write the format octet */ - BufPutByteRvs (b, firstOctet); - - } - return encLen; - -} /* BEncAsnRealContent */ - -#else /* neither IEEE_REAL_FMT or IEEE_REAL_LIB are def */ - -/* - * Inits the PLUS_INFINITY and MINUS_INFINITY globals assuming - * that the double is an IEEE DOUBLE. This should be changed - * for the target architecture (if it is not IEEE) - */ -void -InitAsnInfinity() -{ - unsigned char *c; - int i; - - if (sizeof (double) != 8) - Asn1Error ("InitAsnInfinity: ERROR expected sizeof (AsnReal) to be 8"); - - c = (unsigned char*)&PLUS_INFINITY; - c[0] = 0x7f; - c[1] = 0xf0; - for (i = 2; i < sizeof (double); i++) - c[i] = 0; - - MINUS_INFINITY = -PLUS_INFINITY; -} /* InitAsnInfinity */ - -/* - * Encodes the content of an ASN.1 REAL value to the given buffer. - * This version of the routine does not assume an IEEE double rep. - * or the existence of the IEEE library routines. Uses old style - * UNIX frexp etc. - */ -AsnLen -BEncAsnRealContent PARAMS ((b, value), - BUF_TYPE b _AND_ - AsnReal *value) -{ - unsigned long int encLen; - double mantissa; - double tmpMantissa; - unsigned int truncatedMantissa; - int exponent; - unsigned int expLen; - int sign; - unsigned char buf[sizeof (double)]; - int i, mantissaLen; - unsigned char firstOctet; - - /* no contents for 0.0 reals */ - if (*value == 0.0) - return 0; - - /* special real values for +/- oo */ - if (*value == MINUS_INFINITY) - { - BufPutByteRvs (b, ENC_MINUS_INFINITY); - encLen = 1; - } - else if (*value == PLUS_INFINITY) - { - BufPutByteRvs (b, ENC_PLUS_INFINITY); - encLen = 1; - } - else /* encode a binary real value */ - { - /* - * this is what frexp gets from *value - * *value == mantissa * 2^exponent - * where 0.5 <= |manitissa| < 1.0 - */ - mantissa = frexp (*value, &exponent); - - /* set sign and make mantissa = | mantissa | */ - if (mantissa < 0.0) - { - sign = -1; - mantissa *= -1; - } - else - sign = 1; - - - tmpMantissa = mantissa; - - /* convert mantissa into an unsigned integer */ - for (i = 0; i < sizeof (double); i++) - { - /* normalizied so shift 8 bits worth to the left of the decimal */ - tmpMantissa *= (1<<8); - - /* grab only (octet sized) the integer part */ - truncatedMantissa = (unsigned int) tmpMantissa; - - /* remove part to left of decimal now for next iteration */ - tmpMantissa -= truncatedMantissa; - - /* write into tmp buffer */ - buf[i] = truncatedMantissa; - - /* keep track of last non zero octet so can zap trailing zeros */ - if (truncatedMantissa) - mantissaLen = i+1; - } - - /* - * write format octet (first octet of content) - * field 1 S bb ff ee - * bit# 8 7 65 43 21 - * - * 1 in bit#1 means binary rep - * 1 in bit#2 means the mantissa is neg, 0 pos - * bb is the base: 65 base - * 00 2 - * 01 8 - * 10 16 - * 11 future ext. - * - * ff is the Value of F where Mantissa = sign x N x 2^F - * FF can be one of 0 to 3 inclusive. (used to save re-alignment) - * - * ee is the length of the exponent: 21 length - * 00 1 - * 01 2 - * 10 3 - * 11 long form - * - * - * encoded binary real value looks like - * - * fmt oct - * -------------------------------------------------------- - * |1Sbbffee| exponent (2's comp) | N (unsigned int) | - * -------------------------------------------------------- - * 87654321 - */ - firstOctet = REAL_BINARY; - if (sign == -1) - firstOctet |= REAL_SIGN; - - /* bb is 00 since base is 2 so do nothing */ - /* ff is 00 since no other shifting is nec */ - - /* - * get exponent calculate its encoded length - * Note that the process of converting the mantissa - * double to an int shifted the decimal mantissaLen * 8 - * to the right - so correct that here - */ - exponent -= (mantissaLen * 8); - expLen = SignedIntOctetLen (exponent); - - switch (expLen) - { - case 1: - firstOctet |= REAL_EXPLEN_1; - break; - case 2: - firstOctet |= REAL_EXPLEN_2; - break; - case 3: - firstOctet |= REAL_EXPLEN_3; - break; - default: - firstOctet |= REAL_EXPLEN_LONG; - break; - } - - encLen = mantissaLen + expLen + 1; - - /* write the mantissa (N value) */ - BufPutSegRvs (b, (char*)buf, mantissaLen); - - /* write the exponent */ - for (i = expLen; i > 0; i--) - { - BufPutByteRvs (b, exponent); - exponent >>= 8; - } - - /* write the exponents length if nec */ - if (expLen > 3) - { - encLen++; - BufPutByteRvs (b, expLen); - } - - /* write the format octet */ - BufPutByteRvs (b, firstOctet); - - } - return encLen; - -} /* BEncAsnRealContent */ - -#endif /* IEEE_REAL_LIB */ -#endif /* IEEE_REAL_FMT */ - - - -/* - * Decodes the content of a BER REAL value. - * This only supports the binary REAL encoding. The decimal encoding - * is left as an exercise to the reader. - */ -void -BDecAsnRealContent PARAMS ((b, tagId, len, result, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnTag tagId _AND_ - AsnLen len _AND_ - AsnReal *result _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - unsigned char firstOctet; - unsigned char firstExpOctet; - int i; - unsigned int expLen; - double mantissa; - unsigned short base; - long int exponent = 0; - double tmpBase; - double tmpExp; - - if (len == 0) - { - *result = 0.0; - return; - } - - firstOctet = BufGetByte (b); - if (len == 1) - { - (*bytesDecoded) += 1; - if (firstOctet == ENC_PLUS_INFINITY) - *result = PLUS_INFINITY; - else if (firstOctet == ENC_MINUS_INFINITY) - *result = MINUS_INFINITY; - else - { - Asn1Error ("BDecAsnRealContent: ERROR - unrecognized real number of length 1 octet.\n"); - longjmp (env, -22); - } - } - else - { - if (firstOctet & REAL_BINARY) - { - firstExpOctet = BufGetByte (b); - if (firstExpOctet & 0x80) - exponent = -1; - switch (firstOctet & REAL_EXPLEN_MASK) - { - case REAL_EXPLEN_1: - expLen = 1; - exponent = (exponent << 8)| firstExpOctet; - break; - - case REAL_EXPLEN_2: - expLen = 2; - exponent = (exponent << 16) | - (((unsigned long int) firstExpOctet) << 8) | - BufGetByte (b); - break; - - case REAL_EXPLEN_3: - expLen = 3; - exponent = (exponent << 16) | - (((unsigned long int) firstExpOctet) << 8) | - BufGetByte (b); - exponent = (exponent << 8) | BufGetByte (b); - break; - - default: /* long form */ - expLen = firstExpOctet +1; - i = firstExpOctet-1; - firstExpOctet = BufGetByte (b); - if (firstExpOctet & 0x80) - exponent = (-1 <<8) | firstExpOctet; - else - exponent = firstExpOctet; - for (;i > 0; firstExpOctet--) - exponent = (exponent << 8) | BufGetByte (b); - break; - } - - mantissa = 0.0; - for (i = 1 + expLen; i < len; i++) - { - mantissa *= (1<<8); - mantissa += BufGetByte (b); - } - - /* adjust N by scaling factor */ - mantissa *= (1<<((firstOctet & REAL_FACTOR_MASK) >> 2)); - - switch (firstOctet & REAL_BASE_MASK) - { - case REAL_BASE_2: - base = 2; - break; - - case REAL_BASE_8: - base = 8; - break; - - case REAL_BASE_16: - base = 16; - break; - - default: - Asn1Error ("BDecAsnRealContent: ERROR - unsupported base for a binary real number.\n"); - longjmp (env, -23); - break; - - } - - tmpBase = base; - tmpExp = exponent; - - *result = mantissa * pow ((double)base, (double)exponent); - - if (firstOctet & REAL_SIGN) - *result = -*result; - - (*bytesDecoded) += len; - } - else /* decimal version */ - { - Asn1Error ("BDecAsnRealContent: ERROR - decimal REAL form is not currently supported\n"); - longjmp (env, -24); - } - } - -} /* BDecAsnRealContent */ - - -/* - * Prints given REAL value to the given FILE * in ASN.1 Value Notation. - * indent is ignored. - */ -void -PrintAsnReal PARAMS ((f, v, indent), - FILE *f _AND_ - AsnReal *v _AND_ - unsigned short int indent) -{ - fprintf (f, "%.17E", *v); -} diff --git a/SecuritySNACCRuntime/c-lib/src/asn-tag.c b/SecuritySNACCRuntime/c-lib/src/asn-tag.c deleted file mode 100644 index a86793fa..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-tag.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * asn_tag.c - BER encode, decode and untility routines for ASN.1 Tags. - * - * MS 92 - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/asn-tag.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: asn-tag.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:32 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1997/09/03 12:11:41 wan - * Patch to tag decoding for tags > 2^14 (thanks to Enrico Badella) - * Patch to TblEncTag to emit final 0x00 if previous octet signals continuation - * - * Revision 1.4 1997/03/13 09:15:18 wan - * Improved dependency generation for stupid makedepends. - * Corrected PeekTag to peek into buffer only as far as necessary. - * Added installable error handler. - * Fixed small glitch in idl-code generator (Markku Savela ). - * - * Revision 1.3 1997/02/28 13:39:50 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.2 1995/07/27 09:01:25 rj - * merged PeekTag(), a function used only by the type table code. - * - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:46:01 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "asn-len.h" -#include "asn-tag.h" - - -/* - * Returns an AsnTag. An AsnTag is simply an encoded tag - * shifted to fill up an unsigned long int (first tag byte - * in most sig byte of long int) - * This rep permits easy case stmt comparison of tags. - * NOTE: The unsigned long rep for tag BREAKS if the - * the tag's code is over 2^21 (very unlikely) - * - * RETURNS 0 if decoded a 0 byte (ie first byte of an EOC) - */ -AsnTag -BDecTag PARAMS ((b, bytesDecoded, env), - BUF_TYPE b _AND_ - AsnLen *bytesDecoded _AND_ - jmp_buf env) -{ - AsnTag tagId; - AsnTag tmpTagId; - int i; - - tagId = ((AsnTag)BufGetByte (b)) << ((sizeof (AsnTag)-1)*8); - (*bytesDecoded)++; - - /* check if long tag format (ie code > 31) */ - if ((tagId & (((AsnTag) 0x1f) << ((sizeof (AsnTag)-1)*8))) == (((AsnTag)0x1f) << ((sizeof (AsnTag)-1)*8))) - { - i = 2; - do - { - tmpTagId = (AsnTag) BufGetByte (b); - tagId |= (tmpTagId << ((sizeof (AsnTag)-i)*8)); - (*bytesDecoded)++; - i++; - } - while ((tmpTagId & (AsnTag)0x80) && (i <= sizeof (AsnTag))); - - /* - * check for tag that is too long - */ - if (i > (sizeof (AsnTag)+1)) - { - Asn1Error ("BDecTag: ERROR - tag value overflow\n"); - longjmp (env, -25); - } - } - - if (BufReadError (b)) - { - Asn1Error ("BDecTag: ERROR - decoded past the end of data\n"); - longjmp (env, -26); - } - - return tagId; - -} /* BDecTag */ - - -#if TTBL -AsnTag PeekTag PARAMS ((b, env), - BUF_TYPE b _AND_ - ENV_TYPE env) -{ - AsnTag tagId, tmpTagId; - int i; - unsigned char buf[sizeof(AsnTag)]; - unsigned char* p = buf; - - /* - * peek/copy the next (max size of tag) bytes - * to get the tag info. The Peek buffer routines - * were added to the standard set for this function. - */ - - BufPeekCopy ((char*)buf, b, 1); - tagId = ((AsnTag)*p++) << ((sizeof (AsnTag)-1)*8); - - /* check if long tag format (ie code > 31) */ - if ((tagId & (((AsnTag) 0x1f) << ((sizeof (AsnTag)-1)*8))) == (((AsnTag)0x1f) << ((sizeof (AsnTag)-1)*8))) - { - i = 2; - do - { - BufPeekCopy ((char*)buf, b, i); - tmpTagId = (AsnTag) *p++; - tagId |= (tmpTagId << ((sizeof (AsnTag)-i)*8)); - i++; - } - while ((tmpTagId & (AsnTag)0x80) && (i <= sizeof (AsnTag))); - - /* - * check for tag that is too long - */ - if (i > (sizeof (AsnTag)+1)) - { - Asn1Error ("BDecTag: ERROR - tag value overflow\n"); - longjmp (env, -1004); - } - } - - return tagId; - -} /* PeekTag */ -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/src/asn-useful.c b/SecuritySNACCRuntime/c-lib/src/asn-useful.c deleted file mode 100644 index 2ce63e57..00000000 --- a/SecuritySNACCRuntime/c-lib/src/asn-useful.c +++ /dev/null @@ -1,874 +0,0 @@ -/* - * asn-useful.c - * - * "ASN-USEFUL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Tue Mar 19 07:24:46 2002 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "asn-useful.h" - - -AsnLen BEncUTF8String PARAMS ((b, v), -BUF_TYPE b _AND_ -UTF8String *v) -{ - AsnLen l; - l = BEncUTF8StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, 12); - return l; -} /* BEncUTF8String */ - -void BDecUTF8String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -UTF8String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, 12))&& - (tag != MAKE_TAG_ID (UNIV, CONS, 12))) - { - Asn1Error ("BDecUTF8String: ERROR - wrong tag\n"); - longjmp (env, 50); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecUTF8StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecUTF8String */ - -AsnLen BEncNumericString PARAMS ((b, v), -BUF_TYPE b _AND_ -NumericString *v) -{ - AsnLen l; - l = BEncNumericStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); - return l; -} /* BEncNumericString */ - -void BDecNumericString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -NumericString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE))) - { - Asn1Error ("BDecNumericString: ERROR - wrong tag\n"); - longjmp (env, 49); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecNumericStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecNumericString */ - -AsnLen BEncPrintableString PARAMS ((b, v), -BUF_TYPE b _AND_ -PrintableString *v) -{ - AsnLen l; - l = BEncPrintableStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); - return l; -} /* BEncPrintableString */ - -void BDecPrintableString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -PrintableString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) - { - Asn1Error ("BDecPrintableString: ERROR - wrong tag\n"); - longjmp (env, 48); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecPrintableStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecPrintableString */ - -AsnLen BEncTeletexString PARAMS ((b, v), -BUF_TYPE b _AND_ -TeletexString *v) -{ - AsnLen l; - l = BEncTeletexStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} /* BEncTeletexString */ - -void BDecTeletexString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -TeletexString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecTeletexString: ERROR - wrong tag\n"); - longjmp (env, 47); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecTeletexStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecTeletexString */ - -AsnLen BEncT61String PARAMS ((b, v), -BUF_TYPE b _AND_ -T61String *v) -{ - AsnLen l; - l = BEncT61StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); - return l; -} /* BEncT61String */ - -void BDecT61String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -T61String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecT61String: ERROR - wrong tag\n"); - longjmp (env, 46); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecT61StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecT61String */ - -AsnLen BEncVideotexString PARAMS ((b, v), -BUF_TYPE b _AND_ -VideotexString *v) -{ - AsnLen l; - l = BEncVideotexStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE); - return l; -} /* BEncVideotexString */ - -void BDecVideotexString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -VideotexString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VIDEOTEXSTRING_TAG_CODE))) - { - Asn1Error ("BDecVideotexString: ERROR - wrong tag\n"); - longjmp (env, 45); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecVideotexStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecVideotexString */ - -AsnLen BEncIA5String PARAMS ((b, v), -BUF_TYPE b _AND_ -IA5String *v) -{ - AsnLen l; - l = BEncIA5StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, IA5STRING_TAG_CODE); - return l; -} /* BEncIA5String */ - -void BDecIA5String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -IA5String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) - { - Asn1Error ("BDecIA5String: ERROR - wrong tag\n"); - longjmp (env, 44); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecIA5StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecIA5String */ - -AsnLen BEncGraphicString PARAMS ((b, v), -BUF_TYPE b _AND_ -GraphicString *v) -{ - AsnLen l; - l = BEncGraphicStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GRAPHICSTRING_TAG_CODE); - return l; -} /* BEncGraphicString */ - -void BDecGraphicString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GraphicString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GRAPHICSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GRAPHICSTRING_TAG_CODE))) - { - Asn1Error ("BDecGraphicString: ERROR - wrong tag\n"); - longjmp (env, 43); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGraphicStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGraphicString */ - -AsnLen BEncVisibleString PARAMS ((b, v), -BUF_TYPE b _AND_ -VisibleString *v) -{ - AsnLen l; - l = BEncVisibleStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} /* BEncVisibleString */ - -void BDecVisibleString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -VisibleString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error ("BDecVisibleString: ERROR - wrong tag\n"); - longjmp (env, 42); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecVisibleStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecVisibleString */ - -AsnLen BEncISO646String PARAMS ((b, v), -BUF_TYPE b _AND_ -ISO646String *v) -{ - AsnLen l; - l = BEncISO646StringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); - return l; -} /* BEncISO646String */ - -void BDecISO646String PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -ISO646String *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) - { - Asn1Error ("BDecISO646String: ERROR - wrong tag\n"); - longjmp (env, 41); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecISO646StringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecISO646String */ - -AsnLen BEncGeneralString PARAMS ((b, v), -BUF_TYPE b _AND_ -GeneralString *v) -{ - AsnLen l; - l = BEncGeneralStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GENERALSTRING_TAG_CODE); - return l; -} /* BEncGeneralString */ - -void BDecGeneralString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GeneralString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GENERALSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GENERALSTRING_TAG_CODE))) - { - Asn1Error ("BDecGeneralString: ERROR - wrong tag\n"); - longjmp (env, 40); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGeneralStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGeneralString */ - -AsnLen BEncUTCTime PARAMS ((b, v), -BUF_TYPE b _AND_ -UTCTime *v) -{ - AsnLen l; - l = BEncUTCTimeContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE); - return l; -} /* BEncUTCTime */ - -void BDecUTCTime PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -UTCTime *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))) - { - Asn1Error ("BDecUTCTime: ERROR - wrong tag\n"); - longjmp (env, 39); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecUTCTimeContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecUTCTime */ - -AsnLen BEncGeneralizedTime PARAMS ((b, v), -BUF_TYPE b _AND_ -GeneralizedTime *v) -{ - AsnLen l; - l = BEncGeneralizedTimeContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); - return l; -} /* BEncGeneralizedTime */ - -void BDecGeneralizedTime PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -GeneralizedTime *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) - { - Asn1Error ("BDecGeneralizedTime: ERROR - wrong tag\n"); - longjmp (env, 38); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecGeneralizedTimeContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecGeneralizedTime */ - -AsnLen BEncUniversalString PARAMS ((b, v), -BUF_TYPE b _AND_ -UniversalString *v) -{ - AsnLen l; - l = BEncUniversalStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, UNIVERSALSTRING_TAG_CODE); - return l; -} /* BEncUniversalString */ - -void BDecUniversalString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -UniversalString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE))) - { - Asn1Error ("BDecUniversalString: ERROR - wrong tag\n"); - longjmp (env, 37); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecUniversalStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecUniversalString */ - -AsnLen BEncBMPString PARAMS ((b, v), -BUF_TYPE b _AND_ -BMPString *v) -{ - AsnLen l; - l = BEncBMPStringContent (b, v); - l += BEncDefLen (b, l); - l += BEncTag1 (b, UNIV, PRIM, BMPSTRING_TAG_CODE); - return l; -} /* BEncBMPString */ - -void BDecBMPString PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -BMPString *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE))&& - (tag != MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE))) - { - Asn1Error ("BDecBMPString: ERROR - wrong tag\n"); - longjmp (env, 36); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecBMPStringContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecBMPString */ - -AsnLen -BEncEXTERNALChoiceContent PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNALChoice *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - BEncEocIfNec (b); - itemLen = BEncAsnOctsContent (b, (v->a.single_ASN1_type)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 4); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 0); - - totalLen += itemLen; - - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - itemLen = BEncAsnOctsContent (b, (v->a.octet_aligned)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - break; - - case EXTERNALCHOICE_ARBITRARY: - itemLen = BEncAsnBitsContent (b, (v->a.arbitrary)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncEXTERNALChoiceContent */ - -void -BDecEXTERNALChoiceContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -EXTERNALChoice *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - - - switch (tagId0) - { - case MAKE_TAG_ID (CNTX, CONS, 0): - tagId1 = BDecTag (b, &totalElmtsLen1, env); -if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) && - (tagId1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, 35); - } - - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->choiceId) = EXTERNALCHOICE_SINGLE_ASN1_TYPE; - (v->a.single_ASN1_type) = (AsnOcts*) Asn1Alloc (sizeof (AsnOcts)); - CheckAsn1Alloc ((v->a.single_ASN1_type), env); - BDecAsnOctsContent (b, tagId1, elmtLen1, (v->a.single_ASN1_type), &totalElmtsLen1, env); - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 1): - case MAKE_TAG_ID (CNTX, CONS, 1): - (v->choiceId) = EXTERNALCHOICE_OCTET_ALIGNED; - (v->a.octet_aligned) = (AsnOcts*) Asn1Alloc (sizeof (AsnOcts)); - CheckAsn1Alloc ((v->a.octet_aligned), env); - BDecAsnOctsContent (b, tagId0, elmtLen0, (v->a.octet_aligned), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, PRIM, 2): - case MAKE_TAG_ID (CNTX, CONS, 2): - (v->choiceId) = EXTERNALCHOICE_ARBITRARY; - (v->a.arbitrary) = (AsnBits*) Asn1Alloc (sizeof (AsnBits)); - CheckAsn1Alloc ((v->a.arbitrary), env); - BDecAsnBitsContent (b, tagId0, elmtLen0, (v->a.arbitrary), &totalElmtsLen1, env); - break; - - default: - Asn1Error ("ERROR - unexpected tag in CHOICE\n"); - longjmp (env, 34); - break; - } /* end switch */ - (*bytesDecoded) += totalElmtsLen1; -} /* BDecEXTERNALChoiceContent */ - -void -PrintEXTERNALChoice PARAMS ((f, v, indent), -FILE* f _AND_ -EXTERNALChoice *v _AND_ -unsigned short int indent) -{ - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - fprintf (f,"single-ASN1-type "); - PrintAsnOcts (f, (v->a.single_ASN1_type), indent + stdIndentG); - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - fprintf (f,"octet-aligned "); - PrintAsnOcts (f, (v->a.octet_aligned), indent + stdIndentG); - break; - - case EXTERNALCHOICE_ARBITRARY: - fprintf (f,"arbitrary "); - PrintAsnBits (f, (v->a.arbitrary), indent + stdIndentG); - break; - - } -} /* PrintEXTERNALChoice */ - -void -FreeEXTERNALChoice PARAMS ((v), -EXTERNALChoice *v) -{ - - if (v == NULL) - return; - switch (v->choiceId) - { - case EXTERNALCHOICE_SINGLE_ASN1_TYPE: - FreeAsnOcts ((v->a.single_ASN1_type)); - Asn1Free ((v->a.single_ASN1_type)); - - break; - - case EXTERNALCHOICE_OCTET_ALIGNED: - FreeAsnOcts ((v->a.octet_aligned)); - Asn1Free ((v->a.octet_aligned)); - - break; - - case EXTERNALCHOICE_ARBITRARY: - FreeAsnBits ((v->a.arbitrary)); - Asn1Free ((v->a.arbitrary)); - - break; - - } -} /* FreeEXTERNALChoice */ - - - - -AsnLen BEncEXTERNAL PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNAL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncEXTERNALContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, EXTERNAL_TAG_CODE); - return l; -} /* BEncEXTERNAL */ - -void BDecEXTERNAL PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -EXTERNAL *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, CONS, EXTERNAL_TAG_CODE))) - { - Asn1Error ("BDecEXTERNAL: ERROR - wrong tag\n"); - longjmp (env, 33); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecEXTERNALContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecEXTERNAL */ - -AsnLen -BEncEXTERNALContent PARAMS ((b, v), -BUF_TYPE b _AND_ -EXTERNAL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncEXTERNALChoiceContent (b, (v->encoding)); - - totalLen += itemLen; - - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - itemLen = BEncObjectDescriptorContent (b, (&v->data_value_descriptor)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 7); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->indirect_reference))) - { - itemLen = BEncAsnIntContent (b, (v->indirect_reference)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - } - - if (ASNOID_PRESENT ((&v->direct_reference))) - { - itemLen = BEncAsnOidContent (b, (&v->direct_reference)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 6); - - totalLen += itemLen; - } - - return totalLen; - -} /* BEncEXTERNALContent */ - -void -BDecEXTERNALContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -EXTERNAL *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnOidContent (b, tagId1, elmtLen1, (&v->direct_reference), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->indirect_reference) = (AsnInt*) Asn1Alloc (sizeof (AsnInt)); - CheckAsn1Alloc ((v->indirect_reference), env); - BDecAsnIntContent (b, tagId1, elmtLen1, (v->indirect_reference), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) || -(tagId1 == MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecObjectDescriptorContent (b, tagId1, elmtLen1, (&v->data_value_descriptor), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)) || - (tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1))|| - (tagId1 == MAKE_TAG_ID (CNTX, CONS, 1)) || - (tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2))|| - (tagId1 == MAKE_TAG_ID (CNTX, CONS, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->encoding) = (EXTERNALChoice*) Asn1Alloc (sizeof (EXTERNALChoice)); - CheckAsn1Alloc ((v->encoding), env); - BDecEXTERNALChoiceContent (b, tagId1, elmtLen1, (v->encoding), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, 32); - } - else - longjmp (env, 31); - - - if (!seqDone) - longjmp (env, 30); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecEXTERNALContent */ - -void -PrintEXTERNAL PARAMS ((f, v, indent), -FILE* f _AND_ -EXTERNAL *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - if (ASNOID_PRESENT ((&v->direct_reference))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"direct-reference "); - PrintAsnOid (f, (&v->direct_reference), indent + stdIndentG); - fprintf (f, ",\n"); - } - if (NOT_NULL ((v->indirect_reference))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"indirect-reference "); - PrintAsnInt (f, (v->indirect_reference), indent + stdIndentG); - fprintf (f, ",\n"); - } - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"data-value-descriptor "); - PrintObjectDescriptor (f, (&v->data_value_descriptor), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"encoding "); - PrintEXTERNALChoice (f, (v->encoding), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintEXTERNAL */ - -void -FreeEXTERNAL PARAMS ((v), -EXTERNAL *v) -{ - - if (v == NULL) - return; - if (ASNOID_PRESENT ((&v->direct_reference))) - { - FreeAsnOid ((&v->direct_reference)); - } - - if (NOT_NULL ((v->indirect_reference))) - { - FreeAsnInt ((v->indirect_reference)); - Asn1Free ((v->indirect_reference)); - } - - if (ASNOCTS_PRESENT ((&v->data_value_descriptor))) - { - FreeObjectDescriptor ((&v->data_value_descriptor)); - } - - FreeEXTERNALChoice ((v->encoding)); - Asn1Free ((v->encoding)); - -} /* FreeEXTERNAL */ - - - - diff --git a/SecuritySNACCRuntime/c-lib/src/exp-buf.c b/SecuritySNACCRuntime/c-lib/src/exp-buf.c deleted file mode 100644 index 46bf08e5..00000000 --- a/SecuritySNACCRuntime/c-lib/src/exp-buf.c +++ /dev/null @@ -1,896 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#if defined (USE_EXP_BUF) || defined (USE_GEN_BUF) -/* - * .../c-lib/src/exp-buf.c - buffer routines for the buffer structure - * - * - * --------- ---------- - * | ExpBuf |<------>| ExpBuf |<------> ...ExpBufs - * | |--- | |--- - * ---------- | ---------- | - * V V - * -------- -------- - * | DATA | | DATA | - * | BLK | | BLK | - * -------- -------- - * - * - * ExpBuf - * -------------- - * | readError | - * | writeError | - * | dataStart |----------- - * | dataEnd |-------- | - * | curr |------ | | - * | next | | | | - * | prev | | | | data - * | blkStart |=====|=|==|==>-------------------------- - * | blkEnd |--- | | | | | (each line - * -------------- | | | | | | reps a byte - * | | | |-->| - - - - - - - - - - - -| diff in addr) - * | | | | valid | - * | |-|----->| | - * | | | data | - * | | | | - * | | | - - - - - - - - - - - -| - * | |----->|(one byte after last valid data byte) - * | | | - * | -------------------------- - * |-----------> (one byte after last byte in data blk) - * - * - * readError - set to non-zero to indicate attempt to read past end of - * of data - * writeError- set to non-zero to indicate write error. - * Set if Alloc of new buf fails - * dataStart - pts to first VALID data byte ie *dataStart is first byte - * dataEnd - pts to byte AFTER last VALID byte *dataEnd is not in the data - * but *(dataEnd -1) is in the data - * curr - used for current read ptr - points to next byte to be read - * so *curr is the next byte to be read. - * next - pts to next BUF in list, NULL for last BUF in list - * prev - pts to prev BUF in list, NULL for first BUF in list - * blkStart - pts to start of the data blk. *blkStart is first byte - * in the buffer's data blk. - * blkEnd - pts to byte AFTER last writable byte of the dataBlk. - * *(blkEnd-1) is the last byte in the buffer's data blk. - * - * NOTES: - * - dataEnd is currently always the same as blkEnd - * - at End Of Data (EOD) (no more data to be read) - * if (curr == dataEnd) - * - buffer has no valid data if (dataStart == dataEnd) - * - number of valid data bytes = (dataEnd - dataStart) - * - size of the data block = (blkEnd - blkStart) - * - * - the write reverse routines modify dataStart - * - the read routines modify the curr ptr. - * - there are no 'forward' write routines at the moment - * (if there were they would adjust dataEnd) - * - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/exp-buf.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: exp-buf.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:32 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/27 09:05:29 rj - * merged type table routines and code used by its gen-bufs. - * - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:46:05 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "gen-buf.h" -#include "exp-buf.h" - - -/* default buffer data block size (used when allocating) */ -unsigned long expBufDataBlkSizeG = 1024; - - -#if defined (DEBUG) || defined (USE_GEN_BUF) /* otherwise macros */ - -#ifdef USE_GEN_BUF - -/* - * casts are used to overcome void * - ExpBuf * conflict - * be careful if you modify param lists etc. - */ -static struct GenBuf expBufOpsG = -{ - (BufGetByteFcn) ExpBufGetByte, - (BufGetSegFcn) ExpBufGetSeg, - (BufCopyFcn) ExpBufCopy, - (BufSkipFcn) ExpBufSkip, - (BufPeekByteFcn) ExpBufPeekByte, - (BufPeekSegFcn) ExpBufPeekSeg, - (BufPeekCopyFcn) ExpBufPeekCopy, - (BufPutByteRvsFcn) ExpBufPutByteRvs, - (BufPutSegRvsFcn) ExpBufPutSegRvs, - (BufReadErrorFcn) ExpBufReadError, - (BufWriteErrorFcn) ExpBufWriteError, - NULL, - NULL -}; - -#endif - -/* - * remember: ExpBufs are used via a handle (double ptr) - * in the standardized buffer routines. This allows - * the 'current' expbuf in the list of expbuf to be the arg. - * The list is doubly linked so you can always find - * the head or tail given any expbuf in the list - */ -void -PutExpBufInGenBuf PARAMS ((eb, gb), - ExpBuf *eb _AND_ - GenBuf *gb) -{ - *gb = expBufOpsG; /* structure assignemnt */ - gb->bufInfo = &gb->spare; /* handle to expbuf */ - gb->spare = eb; -} /* PutExpBufInGenBuf */ - -/* - * sets the size of the data block to attach to - * an ExpBuf when allocating a new one - */ -void -ExpBufInit PARAMS ((dataBlkSize), - unsigned long dataBlkSize) -{ - expBufDataBlkSizeG = dataBlkSize; -} /* InitBuffers */ - -/* - * Allocates and returns an uninitialized ExpBuf with - * no a data attached. - */ -ExpBuf* -ExpBufAllocBuf() -{ - return (ExpBuf*)malloc (sizeof (ExpBuf)); -} - -void -ExpBufFreeBuf PARAMS ((ptr), - ExpBuf *ptr) -{ - free (ptr); -} - -char* -ExpBufAllocData() -{ - return (char*)malloc (expBufDataBlkSizeG); -} - -void -ExpBufFreeData PARAMS ((ptr), - char *ptr) -{ - free (ptr); -} - -void -ExpBufFreeBufAndData PARAMS ((b), - ExpBuf *b) -{ - ExpBufFreeData ((b)->blkStart); - ExpBufFreeBuf (b); -} /* ExpBufFreeBufAndData */ - -ExpBuf* -ExpBufNext PARAMS ((b), - ExpBuf *b) -{ - return b->next; -} - -ExpBuf* -ExpBufPrev PARAMS ((b), - ExpBuf *b) -{ - return b->prev; -} - -int -ExpBufReadError PARAMS ((b), - ExpBuf **b) -{ - return (*b)->readError; -} /* ExpBufReadError */ - -int -ExpBufWriteError PARAMS ((b), - ExpBuf **b) -{ - return (*b)->writeError; -} /* ExpBufWriteError */ - -/* - * set curr ptr used in reads to the first byte - * to be read - */ -void -ExpBufResetInReadMode PARAMS ((b), - ExpBuf *b) -{ - b->curr = b->dataStart; - b->readError = 0; - b->writeError = 1; /* catch wrong mode errors */ -} - -/* - * sets dataStart to end of buffer - * so following writes (backward) - * over-write any existing data associated with - * the buffer - */ -void -ExpBufResetInWriteRvsMode PARAMS ((b), - ExpBuf *b) -{ - b->dataEnd = b->dataStart = b->blkEnd; - b->writeError = 0; - b->readError = 1; /* catch wrong mode errors */ -} - - -/* - * returns true if no more data can be read from - * the given buffer. only valid when buffer in read (fwd) - * mode. - */ -int -ExpBufAtEod PARAMS ((b), - ExpBuf *b) -{ - return b->curr == b->dataEnd; -} - - -/* - * returns true if no more reverse writes can be done - * to the buffer. Only valid when buffers in reverse - * write mode - */ -int -ExpBufFull PARAMS ((b), - ExpBuf *b) -{ - return (b)->dataStart == (b)->blkStart; -} - - -/* - * returns true if the given buffer has no - * valid data in it's data block - */ -int -ExpBufHasNoData PARAMS ((b), - ExpBuf *b) -{ - return b->dataStart == b->dataEnd; -} - - -/* - * returns the number of valid data bytes in the - * given buffer's data block - */ -unsigned long -ExpBufDataSize PARAMS ((b), - ExpBuf *b) -{ - return b->dataEnd - b->dataStart; -} - -/* - * returns size of data block that is attached to - * the given buffer. - */ -unsigned long -ExpBufDataBlkSize PARAMS ((b), - ExpBuf *b) -{ - return b->blkEnd - b->blkStart; -} - -/* - * returns a ptr the beginning of the valid data of - * the given buffer. - * returns NULL is there is no valid data. - */ -char* -ExpBufDataPtr PARAMS ((b), - ExpBuf *b) -{ - if (ExpBufHasNoData (b)) - return NULL; - else - return b->dataStart; -} - -#endif /* DEBUG || USE_EXP_BUF */ - - -/* - * returns last ExpBuf in a list of bufs. - * The given buf can be any buf in the list. - */ -ExpBuf* -ExpBufListLastBuf PARAMS ((b), - ExpBuf *b) -{ - for (; b->next != NULL; b = b->next) - ; - return b; -} - -/* - * returns first buf in a list of bufs . - * The given buf can be any buf in the list - */ -ExpBuf* -ExpBufListFirstBuf PARAMS ((b), - ExpBuf *b) -{ - for (; b->prev != NULL; b = b->prev) - ; - return b; -} - -/* - * Allocates a Buf and allocates an attaches a - * data block of expBufDataBlkSizeG to that buffer. - * sets up the blk for writing in that the data start - * and data end point to the byte after the data blk. - */ -ExpBuf* -ExpBufAllocBufAndData() -{ - ExpBuf *retVal; - - retVal = ExpBufAllocBuf(); - - if (retVal == NULL) - return NULL; - - retVal->readError = 0; - retVal->writeError = 0; - retVal->blkStart = ExpBufAllocData(); - - if (retVal->blkStart == NULL) - { - ExpBufFreeBuf (retVal); - return NULL; - } - - retVal->next = NULL; - retVal->prev = NULL; - retVal->curr = retVal->blkEnd = retVal->dataStart = retVal->dataEnd = - retVal->blkStart + expBufDataBlkSizeG; - - return retVal; -} /* ExpBufAllocBufAndData */ - - -/* - * Frees ExpBuf's and associated data blocks after - * after (next ptr) and including the given buffer, b. - */ -void -ExpBufFreeBufAndDataList PARAMS ((b), - ExpBuf *b) -{ - ExpBuf *tmp; - - for (; b != NULL;) - { - tmp = b->next; - ExpBufFreeBufAndData (b); - b = tmp; - } -} /* ExpBufFreeBufAndDataList */ - - -/* - * puts the given data in a buffer and sets it up for reading - * the data. This results in a "full" buffer with a data - * blk size of given data's len - */ -void -ExpBufInstallDataInBuf PARAMS ((buf, data, len), - ExpBuf *buf _AND_ - char *data _AND_ - unsigned long int len) -{ - buf->readError = 0; - buf->writeError = 0; - buf->blkStart = buf->dataStart = buf->curr = data; - buf->next = NULL; - buf->prev = NULL; - buf->blkEnd = buf->dataEnd = data + len; -} /* ExpBufInstallDataInBuf */ - - - -/* Buf reading and writing routines follow */ - -/* READ - * returns the next byte to be read without - * advancing the pointer. No check for end of - * data - this is lame - */ -unsigned char -ExpBufPeekByte PARAMS ((b), - ExpBuf **b) -{ - if ((*b)->curr == (*b)->dataEnd) - (*b)->readError = 1; - return *(*b)->curr; -} /* ExpBufPeek */ - -#if TTBL - -/* READ - * returns a ptr to the next "len" bytes (contiguous). - * if "len" is greater than the available contiguous bytes - * len is set the the number of contig. bytes the returned - * ptr references. The next call to ExpBufGetSeg or other ExpBufGet - * routines will return a ptrsto the SAME bytes (ie curr is NOT advanced). - * - * Does not change the buffer - * - * if the value returned in the len param is zero or the - * returned char * is NULL then at end of data. - * - */ -char* -ExpBufPeekSeg PARAMS ((b, len), - ExpBuf **b _AND_ - unsigned long int *len) -{ - int bytesLeft; - - if (ExpBufAtEod (*b)) - { - *len = 0; - return NULL; - } - - /* check for "buffer fault" and adjust "peeked" len */ - if (((*b)->dataEnd - (*b)->curr) <= *len) - *len = bytesLeft; - - return (*b)->curr; - -} /* ExpBufPeekSeg */ - - -/* READ - * copy the next len chars in the buffer to the given - * dst char string. The curr ptr in the buffer is - * NOT advanced so the next read will get the same bytes. - */ -int -ExpBufPeekCopy PARAMS ((dst, b, len), - char *dst _AND_ - ExpBuf **b _AND_ - unsigned long int len) -{ - unsigned long int gotLen; - int totalGotLen = 0; - char *srcPtr; - ExpBuf *origBuf; - - origBuf = *b; - - gotLen = len; - while (1) /* optimize std path - eg only one ExpBufGetPeekSeg needed */ - { - srcPtr = ExpBufPeekSeg (b, &gotLen); - memcpy (dst + totalGotLen, srcPtr, gotLen); - - totalGotLen += gotLen; - - if ((totalGotLen >= len) || ((*b)->next == NULL)) - { - *b = origBuf; - return totalGotLen; - } - - if (gotLen == 0) /* eod */ - { - (*b)->readError = 1; - *b = origBuf; - return totalGotLen; - } - - *b = (*b)->next; - /* get next buffer with valid data */ - while (((*b)->next != NULL) && ExpBufHasNoData (*b)) - *b = (*b)->next; - - /* reset current pointer to beggining of data if nec */ - (*b)->curr = (*b)->dataStart; - - gotLen = len - totalGotLen; - } - - /* not reached */ - -} /* ExpBufPeekCopy */ - -#endif /* TTBL */ - -/* READ - * copy the next len chars in the buffer to the given - * dst char string. The curr ptr in the buffer is advanced - * appropriately - */ -int -ExpBufCopy PARAMS ((dst, b, len), - char *dst _AND_ - ExpBuf **b _AND_ - unsigned long int len) -{ - unsigned long int gotLen; - int totalGotLen = 0; - char *srcPtr; - - gotLen = len; - while (1) /* optimize std path - eg only one ExpBufGetSeg needed */ - { - srcPtr = ExpBufGetSeg (b, &gotLen); - memcpy (dst + totalGotLen, srcPtr, gotLen); - - totalGotLen += gotLen; - - if (totalGotLen >= len) - return totalGotLen; - - if (gotLen == 0) /* eod */ - { - (*b)->readError = 1; - return totalGotLen; - } - - gotLen = len - totalGotLen; - } - - /* not reached */ - -} /* ExpBufCopy */ - - -/* - * advance the curr ptr in the given buffer over the next - * len bytes - */ -void -ExpBufSkip PARAMS ((b, len), - ExpBuf **b _AND_ - unsigned long int len) -{ - unsigned long int lenRemaining; - - lenRemaining = len; - while ((len > 0) && ExpBufGetSeg (b, &lenRemaining)) - { - len -= lenRemaining; - - if (lenRemaining == 0) - { - (*b)->readError = 1; - return; - } - - lenRemaining = len; - } -} /* ExpBufSkip */ - - -/* READ - * returns a ptr to the next "len" bytes (contiguous). - * if "len" is greater than the available contiguous bytes - * len is set the the number of contig. bytes the returned - * ptr references. Subsequent call to ExpBufGetSeg or other ExpBufGet - * routines will return ptrs to the following bytes (ie curr is advanced). - * Changes *b to pt to the next buffer and sets curr for the - * that buffer to dataStart if the current one has been totally read. - * - * if the value returned in the len param is zero or the - * returned char * is NULL then at end of data (eod) - * - */ - -char* -ExpBufGetSeg PARAMS ((b, len), - ExpBuf **b _AND_ - unsigned long int *len) -{ - int bytesLeft; - char *retVal; - - if (ExpBufAtEod (*b)) - { - *len = 0; - return NULL; - } - - bytesLeft = (*b)->dataEnd - (*b)->curr; - retVal = (*b)->curr; - - /* check for "buffer fault" */ - if (bytesLeft <= *len) - { - *len = bytesLeft; - - if ((*b)->next != NULL) - { - *b = (*b)->next; - - /* get next buffer with valid data */ - while (((*b)->next != NULL) && ExpBufHasNoData (*b)) - *b = (*b)->next; - - /* reset current pointer to beggining of data if nec */ - (*b)->curr = (*b)->dataStart; - } - else - (*b)->curr += *len; - } - else - (*b)->curr += *len; - - return retVal; - -} /* ExpBufGetSeg */ - - - -/* - * WRITE - * Copies len bytes from the data pointer into the given buffer - * - * FILLS EXP_BUFFERS BACKWARDS! from the end of the data to the beginning - * LINKS BUFFERS BACKWARDS! if a buf is full it allocs another an - * puts it at the HEAD of the buffer list - * - * changes *b to pt to the new "prev" buffer if the current one - * has been totally filled - * Rvs is for REVERSE! - * - * modifies the dataStart pointer to reflect the new data - */ - -void -ExpBufPutSegRvs PARAMS ((b, data, len), - ExpBuf **b _AND_ - char *data _AND_ - unsigned long int len) -{ - int bytesLeft; - ExpBuf *buf; - char *dataPtr; - - buf = *b; - - if (buf->writeError) - return; - - bytesLeft = buf->dataStart - buf->blkStart; - dataPtr = data + len; /* pts to end of data to be written */ - - /* optimize fast path */ - - do - { - if (bytesLeft > len) /* enough room in this buffer for write */ - { - buf->dataStart -= len; - memcpy (buf->dataStart, data, len); - break; /* this is the normal exit from this loop */ - } - else - { - /* - * going to fill this buffer completely, - * so alloc other one (only if one is not - * already linked in) - */ - dataPtr = dataPtr - bytesLeft; - buf->dataStart = buf->blkStart; - memcpy (buf->dataStart, dataPtr, bytesLeft); - - len -= bytesLeft; - - if (buf->prev == NULL) - { - /* alloc & insert new buf at head of buffer list */ - buf = ExpBufAllocBufAndData(); - - if (buf == NULL) - { - (*b)->writeError = 1; - return; - } - - buf->next = *b; - (*b)->prev = buf; - } - else - buf = buf->prev; - - *b = buf; /* update head of list */ - - bytesLeft = buf->dataStart - buf->blkStart; - } - } - while (1); - - /* not reached */ - -} /* ExpBufPutSegRvs */ - - - -/* - * returns the next byte and advances the curr ptr by one. - * sets the readError flag if there is no byte to read - * (ie at end of data) - */ -unsigned char -ExpBufGetByte PARAMS ((b), - ExpBuf **b) -{ - unsigned char retVal; - - - if (ExpBufAtEod (*b)) - { - (*b)->readError = 1; - return (unsigned char)0; - } - - retVal = *(*b)->curr++; - - /* "buffer fault" - if end of this buf, go on to next, if any */ - if (ExpBufAtEod (*b) && ((*b)->next != NULL)) - { - *b = (*b)->next; - - /* get next buffer with valid data */ - while (((*b)->next != NULL) && ExpBufHasNoData (*b)) - *b = (*b)->next; - - /* reset current pointer to beggining of data if nec */ - (*b)->curr = (*b)->dataStart; - } - - return retVal; - -} /* ExpBufGetByte */ - - -/* WRITE - * Puts a single octet into the buffer - * writes in reverse. - * allocates new buffers as nec - may change - * (*b) to new buffer since writing backwards - */ -void -ExpBufPutByteRvs PARAMS ((b, byte), - ExpBuf **b _AND_ - unsigned char byte) -{ - ExpBuf *new; - - if ((*b)->writeError) - return; - - *(--(*b)->dataStart) = byte; - - /* - * check if buffer is full and alloc new one if nec - * and insert it before this one since writing backwards - */ - if (ExpBufFull (*b)) - { - if ((*b)->prev == NULL) - { - /* - * no prev buf so alloc & insert - * new buf as head of buffer list - */ - new = ExpBufAllocBufAndData(); - if (new == NULL) - { - (*b)->writeError = 1; - return; - } - - new->next = *b; - (*b)->prev = new; - *b = new; - } - else - { - (*b) = (*b)->prev; - ExpBufResetInWriteRvsMode (*b); - } - - } -} /* ExpBufPutByteRvs */ - - -void -ExpBufCopyToFile PARAMS ((b, f), - ExpBuf *b _AND_ - FILE *f) -{ - long int writeLen; - - b = ExpBufListFirstBuf (b); - - for ( ; b != NULL; b = ExpBufNext (b)) - { - writeLen = fwrite (ExpBufDataPtr (b), sizeof (char), ExpBufDataSize (b), f); - - if (writeLen != ExpBufDataSize (b)) - fprintf (stderr, "ExpBufCopyToFile: error during writing\n"); - } -} - -#else /* !USE_EXP_BUF */ - -#ifdef __alpha -static void dummy() -{ -} -#endif - -#endif /* USE_EXP_BUF */ diff --git a/SecuritySNACCRuntime/c-lib/src/hash.c b/SecuritySNACCRuntime/c-lib/src/hash.c deleted file mode 100644 index 06eee750..00000000 --- a/SecuritySNACCRuntime/c-lib/src/hash.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * This was borrowed from Don Acton and Terry Coatta's Raven Code. - * It has been modified somewhat. - * - Mike Sample 92 - * - * This is a set or routines that implements an extensible hashing - * algorithm. At the moment it assumes that all the hash codes are unique - * (ie. there are no collisions). For the way hash codes are currently being - * supplied this is not a bad assumption. - * The extensible hashing routine used is based on a multiway tree with - * each node in the tree being a fixed array of (2^n) size. At a given - * level, i, in the tree with the first level being level 0, bits - * i*n through i*n through (i+1)*n-1 are used as the index into the table. - * Each entry in the table is either NULL (unused) or a pointer to an - * object of type entry. The entry contains all the information about a - * hash entry. The entry also contains a field indicating whether or not this - * is a leaf node. If an entry isn't a leaf node then it references a table at - * at the next level and not a value. With the current implementation - * a 32 hash value is used and table sizes are 256. The algorithm used - * here is the same as the one used in the Set class of the Raven - * class system. - * - * Copyright (C) 1992 University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/hash.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: hash.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:32 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1997/02/28 13:39:51 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.2 1995/07/27 09:05:54 rj - * use memzero that is defined in .../snacc.h to use either memset or bzero. - * - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:46:06 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "hash.h" - - -/* - * - * From sdbm, an ndbm work-alike hashed database library - * Author: oz@nexus.yorku.ca - * Status: public domain. - * - * polynomial conversion ignoring overflows - * [this seems to work remarkably well, in fact better - * then the ndbm hash function. Replace at your own risk] - * use: 65599 nice. - * 65587 even better. - * - * [In one experiment, this function hashed 84165 symbols (English words - * plus symbol table values) with no collisions. -bjb] - * - */ - -Hash -MakeHash PARAMS ((str, len), - char *str _AND_ - unsigned long int len) -{ - register Hash n; - n = 0; - -#define HASHC n = *str++ + 65587 * n - - if (len > 0) - { - int loop; - loop = (len + 8 - 1) >> 3; - switch (len & (8 - 1)) - { - case 0: - do - { - HASHC; - case 7: HASHC; - case 6: HASHC; - case 5: HASHC; - case 4: HASHC; - case 3: HASHC; - case 2: HASHC; - case 1: HASHC; - } while (--loop); - } - } - return n; -} - -/* Creates and clears a new hash slot */ -static HashSlot* -NewHashSlot() -{ - HashSlot *foo; - - foo = (HashSlot *) malloc (sizeof (HashSlot)); - if (foo == NULL) - return NULL; - memzero (foo, sizeof (HashSlot)); - return foo; -} - -/* Create a new cleared hash table */ -static Table* -NewTable() -{ - Table *new_table; - - new_table = (Table *) malloc (sizeof (Table)); - if (new_table == NULL) - return NULL; - memzero (new_table, sizeof (Table)); - return new_table; -} - -/* This routine is used to initialize the hash tables. When it is called - * it returns a value which is used to identify which hash table - * a particular request is to operate on. - */ -Table* -InitHash() -{ - Table *table; - table = NewTable(); - if (table == NULL) - return 0; - else - return table; -} - -/* When a hash collision occurs at a leaf slot this routine is called to - * split the entry and add a new level to the tree at this point. - */ -static int -SplitAndInsert PARAMS ((entry, element, hash_value), - HashSlot *entry _AND_ - void *element _AND_ - Hash hash_value) -{ - - if (((entry->table = NewTable()) == NULL) || - !Insert (entry->table, entry->value, entry->hash >> INDEXSHIFT) || - !Insert (entry->table, element, hash_value >> INDEXSHIFT)) - return FALSE; - - entry->leaf = FALSE; - return TRUE; -} - -/* This routine takes a hash table identifier, an element (value) and the - * coresponding hash value for that element and enters it into the table - * assuming it isn't already there. - */ -int -Insert PARAMS ((table, element, hash_value), - Table *table _AND_ - void *element _AND_ - Hash hash_value) -{ - HashSlot *entry; - - entry = (HashSlot *) (*table)[hash_value & INDEXMASK]; - - if (entry == NULL) { - /* Need to add this element here */ - entry = NewHashSlot(); - if (entry == NULL) - return FALSE; - entry->leaf = TRUE; - entry->value = element; - entry->hash = hash_value; - (*table)[hash_value & INDEXMASK] = (void*)entry; - return TRUE; - } - - if (hash_value == entry->hash) - return TRUE; - - if (entry->leaf) - return SplitAndInsert (entry, element, hash_value); - - return Insert (entry->table, element, hash_value >> INDEXSHIFT); -} - - -/* This routine looks to see if a particular hash value is already stored in - * the table. It returns true if it is and false otherwise. - */ -int -CheckFor PARAMS ((table, hash), - Table *table _AND_ - Hash hash) -{ - HashSlot *entry; - - entry = (HashSlot *) table[hash & INDEXMASK]; - - if (entry == NULL) - return FALSE; - if (entry->leaf) - return entry->hash == hash; - return CheckFor (entry->table, hash >> INDEXSHIFT); -} - -/* In addition to checking for a hash value in the tree this function also - * returns the coresponding element value into the space pointed to by - * the value parameter. If the hash value isn't found FALSE is returned - * the the space pointed to by value is not changed. - */ -int -CheckForAndReturnValue PARAMS ((table, hash, value), - Table *table _AND_ - Hash hash _AND_ - void **value) -{ - HashSlot *entry; - entry = (HashSlot *) (*table)[hash & INDEXMASK]; - - if (entry == NULL) - return FALSE; - - if (entry->leaf) - { - if (entry->hash == hash) - { - *value = entry->value; - return TRUE; - } - else - return FALSE; - } - return CheckForAndReturnValue (entry->table, hash >> INDEXSHIFT, value); -} diff --git a/SecuritySNACCRuntime/c-lib/src/nibble-alloc.c b/SecuritySNACCRuntime/c-lib/src/nibble-alloc.c deleted file mode 100644 index abb51504..00000000 --- a/SecuritySNACCRuntime/c-lib/src/nibble-alloc.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * .../c-lib/src/nibble-alloc.c - fast mem allocation for decoded values - * - * MS Dec 31/91 - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/nibble-alloc.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: nibble-alloc.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:32 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1997/02/28 13:39:51 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.3 1995/07/27 09:06:37 rj - * use memzero that is defined in .../snacc.h to use either memset or bzero. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:07:16 rj - * more portable .h file inclusion. - * - * Revision 1.1 1994/08/28 09:46:07 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" - -#if STDC_HEADERS || HAVE_STRING_H -#include -/* An ANSI string.h and pre-ANSI memory.h might conflict. */ -#if !STDC_HEADERS && HAVE_MEMORY_H -#include -#endif /* not STDC_HEADERS and HAVE_MEMORY_H */ -#endif /* not STDC_HEADERS and not HAVE_STRING_H */ - -#include "nibble-alloc.h" - - -NibbleMem *nmG = NULL; - -void -InitNibbleMem PARAMS ((initialSize, incrementSize), - unsigned long int initialSize _AND_ - unsigned long int incrementSize) -{ - NibbleMem *nm; - - nm = (NibbleMem*) malloc (sizeof (NibbleMem)); - nm->incrementSize = incrementSize; - - nm->currNibbleBuf = nm->firstNibbleBuf = (NibbleBuf*)malloc (sizeof (NibbleBuf)); - nm->firstNibbleBuf->curr = nm->firstNibbleBuf->start = (char*) malloc (initialSize); - nm->firstNibbleBuf->end = nm->firstNibbleBuf->start + initialSize; - nm->firstNibbleBuf->next = NULL; - memzero (nm->currNibbleBuf->start, initialSize); - - nmG = nm;/* set global */ - -} /* InitNibbleAlloc */ - - -/* - * alloc new nibble buf, link in, reset to curr nibble buf - */ -void -ServiceNibbleFault PARAMS ((size), - unsigned long size) -{ - NibbleMem *nm; - unsigned long newBufSize; - - nm = nmG; - - if (size > nm->incrementSize) - newBufSize = size; - else - newBufSize = nm->incrementSize; - - nm->currNibbleBuf->next = (NibbleBuf*) malloc (sizeof (NibbleBuf)); - nm->currNibbleBuf = nm->currNibbleBuf->next; - nm->currNibbleBuf->curr = nm->currNibbleBuf->start = (char*) malloc (newBufSize); - nm->currNibbleBuf->end = nm->currNibbleBuf->start + newBufSize; - nm->currNibbleBuf->next = NULL; - memzero (nm->currNibbleBuf->start, newBufSize); -} /* serviceNibbleFault */ - - - -/* - * returns requested space filled with zeros - */ -void* -NibbleAlloc PARAMS ((size), - unsigned long size) -{ - NibbleMem *nm; - char *retVal; - unsigned long ndiff; - - nm = nmG; - - if ((nm->currNibbleBuf->end - nm->currNibbleBuf->curr) < size) - ServiceNibbleFault (size); - - retVal = nm->currNibbleBuf->curr; - - /* - * maintain word alignment - */ - ndiff = size % sizeof (long); - if (ndiff != 0) - { - nm->currNibbleBuf->curr += size + sizeof (long) - ndiff; - - /* - * this is a fix from Terry Sullivan - * - * makes sure curr does not go past the end ptr - */ - if (nm->currNibbleBuf->curr > nm->currNibbleBuf->end) - nm->currNibbleBuf->curr = nm->currNibbleBuf->end; - } - else - nm->currNibbleBuf->curr += size; - - return retVal; -} /* NibbleAlloc */ - - - -/* - * frees all nibble buffers except the first, - * resets the first to empty and zero's it - */ -void -ResetNibbleMem() -{ - NibbleMem *nm; - NibbleBuf *tmp; - NibbleBuf *nextTmp; - - nm = nmG; - - /* - * reset first nibble buf - */ - memzero (nm->firstNibbleBuf->start, nm->firstNibbleBuf->curr - nm->firstNibbleBuf->start); - - nm->firstNibbleBuf->curr = nm->firstNibbleBuf->start; - - /* - * free incrementally added nibble bufs - */ - for (tmp = nm->firstNibbleBuf->next; tmp != NULL; ) - { - free (tmp->start); - nextTmp = tmp->next; - free (tmp); - tmp = nextTmp; - } - - /* From ftp://ftp.cs.ubc.ca/pub/local/src/snacc/bugs-in-1.1 */ - nm->firstNibbleBuf->next = NULL; - nm->currNibbleBuf = nm->firstNibbleBuf; - -} /* ResetNibbleMem */ - - -/* - * frees all nibble buffers, closing this - * NibbleMem completely - */ -void -ShutdownNibbleMem() -{ - NibbleMem *nm; - NibbleBuf *tmp; - NibbleBuf *nextTmp; - - nm = nmG; - nmG = NULL; - /* - * free nibble bufs - */ - for (tmp = nm->firstNibbleBuf; tmp != NULL; ) - { - free (tmp->start); - nextTmp = tmp->next; - free (tmp); - tmp = nextTmp; - } - - free (nm); -} /* ShutdownNibbleMem */ diff --git a/SecuritySNACCRuntime/c-lib/src/print.c b/SecuritySNACCRuntime/c-lib/src/print.c deleted file mode 100644 index 3bbbca44..00000000 --- a/SecuritySNACCRuntime/c-lib/src/print.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * print.c - library routines for printing ASN.1 values. - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/print.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: print.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:25 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:32 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1997/03/13 09:15:19 wan - * Improved dependency generation for stupid makedepends. - * Corrected PeekTag to peek into buffer only as far as necessary. - * Added installable error handler. - * Fixed small glitch in idl-code generator (Markku Savela ). - * - * Revision 1.2 1995/07/24 21:04:55 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:46:08 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "print.h" - -unsigned short int stdIndentG = 4; - - -void -Indent PARAMS ((f, i), - FILE *f _AND_ - unsigned short int i) -{ - for (; i > 0; i--) - fputc (' ', f); /* this may be slow */ -} - -void Asn1DefaultErrorHandler PARAMS ((str, severity), - char* str _AND_ - int severity) -{ - fprintf(stderr,"%s",str); -} - -static Asn1ErrorHandler asn1CurrentErrorHandler = Asn1DefaultErrorHandler; - -void -Asn1Error PARAMS ((str), - char* str) -{ - (*asn1CurrentErrorHandler)(str,1); -} - -void -Asn1Warning PARAMS ((str), - char* str) -{ - (*asn1CurrentErrorHandler)(str,0); -} - -Asn1ErrorHandler -Asn1InstallErrorHandler PARAMS ((handler), - Asn1ErrorHandler handler) -{ - Asn1ErrorHandler former = asn1CurrentErrorHandler; - asn1CurrentErrorHandler = handler; - return former; -} - diff --git a/SecuritySNACCRuntime/c-lib/src/sbuf.c b/SecuritySNACCRuntime/c-lib/src/sbuf.c deleted file mode 100644 index 7bf05c63..00000000 --- a/SecuritySNACCRuntime/c-lib/src/sbuf.c +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * .../c-lib/src/sbuf.c - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * MS - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - */ - -#ifdef USE_GEN_BUF - -#include "asn-config.h" -#include "gen-buf.h" -#include "sbuf.h" - -/* - * casts are used to overcome void * - SBuf * conflict - * be careful if you modify param lists etc. - */ -static struct GenBuf sBufOpsG = -{ - (BufGetByteFcn) SBufGetByte, - (BufGetSegFcn) SBufGetSeg, - (BufCopyFcn) SBufCopy, - (BufSkipFcn) SBufSkip, - (BufPeekByteFcn) SBufPeekByte, - (BufPeekSegFcn) SBufPeekSeg, - (BufPeekCopyFcn) SBufPeekCopy, - (BufPutByteRvsFcn) SBufPutByteRvs, - (BufPutSegRvsFcn) SBufPutSegRvs, - (BufReadErrorFcn) SBufReadError, - (BufWriteErrorFcn) SBufWriteError, - NULL, - NULL -}; - -void -PutSBufInGenBuf PARAMS ((sb, gb), - SBuf *sb _AND_ - GenBuf *gb) -{ - *gb = sBufOpsG; /* structure assignemnt */ - gb->bufInfo = sb; -} - -/* - * given an SBuf,b, and a block of data - * and its length this initializes a the SBuf - * to point to the data block. The data - * block is assumed to contain no valid data- - * ie it is empty and ready for writing - */ -void -SBufInit PARAMS ((b, data, dataLen), - SBuf *b _AND_ - char *data _AND_ - long int dataLen) -{ - b->readError = b->writeError = 1; - b->blkStart = data; - b->blkEnd = data + dataLen; - b->dataStart = b->dataEnd = b->readLoc = b->blkEnd; -} /* SBufInit */ - - -/* - * puts the given buffer in read mode and sets - * the current read location to the beginning of - * the buffer's data. - * The read error flag is cleared. - * The writeError flag is set so that attempted writes - * will be fail and be detectable via a call to - * SBufWriteError(). - */ -void -SBufResetInReadMode PARAMS ((b), - SBuf *b) -{ - b->readLoc = b->dataStart; - b->readError = 0; - b->writeError = 1; -} /* SBufResetInnReadMode */ - - -/* - * puts the given buffer in reverse writing mode and sets - * the current write location to the end of the - * buffer's data block. - * The data start and end pointers are set to point to - * the end of the block - ie no data. - * The write error flag is cleared. - * The readError flag is set so that attempted reads - * will be fail and be detectable via a call to - * SBufReadError(). - */ -void -SBufResetInWriteRvsMode PARAMS ((b), - SBuf *b) -{ - b->dataStart = b->dataEnd = b->blkEnd; - b->writeError = 0; - b->readError = 1; -} /* SBufResetInWriteRvsMode */ - -/* - * installs given block of data into a buffer - * and sets it up for reading - */ -void -SBufInstallData PARAMS ((b, data, dataLen), - SBuf *b _AND_ - char *data _AND_ - long int dataLen) -{ - SBufInit (b, data, dataLen); - b->dataStart = b->blkStart; - SBufResetInReadMode (b); -} /* SBufInstallData */ - -/* - * returns the number of bytes in the data portion - */ -long int -SBufDataLen PARAMS ((b), - SBuf *b) -{ - return b->dataEnd - b->dataStart; -} /* SBufDataLen */ - -/* - * returns the pointer to the first data byte - */ -char* -SBufDataPtr PARAMS ((b), - SBuf *b) -{ - b->dataStart; -} /* SBufDataPtr */ - -/* - * returns the size of block, the maximum size for data - * (does not look at how much data is present, just the - * max size if the block were empty) - */ -long int -SBufBlkLen PARAMS ((b), - SBuf *b) -{ - return b->blkEnd - b->blkStart; -} /* SBufBlkLen */ - -/* - * returns a pointer to the first byte of the block - */ -char* -SBufBlkPtr PARAMS ((b), - SBuf *b) -{ - return b->blkStart; -} /* SBufBlkPtr */ - -/* - * returns true if there is no more data - * to be read in the SBuf - */ -int -SBufEod PARAMS ((b), - SBuf *b) -{ - return b->readLoc >= b->dataEnd; -} /* SBufEod */ - - -/* returns true if you attempted to read past the end of data */ -int -SBufReadError PARAMS ((b), - SBuf *b) -{ - return b->readError; -} /* SBufReadError */ - -/* - * returns true if you attempted to write past the end of the block - * (remember SBufs do not expand like ExpBufs) - */ -int -SBufWriteError PARAMS ((b), - SBuf *b) -{ - return b->writeError; -} /* SBufWriteError */ - -/* - * Skips the next skipLen bytes for reading - */ -void -SBufSkip PARAMS ((b, skipLen), - SBuf *b _AND_ - long int skipLen) -{ - if (b->readLoc + skipLen > b->dataEnd) - { - b->readLoc = b->dataEnd; - b->readError = 1; - } - else - b->readLoc += skipLen; -} /* SBufSkip */ - - -/* - * copies copyLen bytes from buffer b into char *dst. - * Advances the curr read loc by copyLen - * Assumes dst is pre-allocated and is large enough. - * Will set the read error flag is you attempt to copy - * more than the number of unread bytes available. - */ -void -SBufCopy PARAMS ((dst, b, copyLen), - char *dst _AND_ - SBuf *b _AND_ - long int copyLen) -{ - if (b->readLoc + copyLen > b->dataEnd) - { - memcpy (dst, b->readLoc, b->dataEnd - b->readLoc); - b->readLoc = b->dataEnd; - b->readError = 1; - } - else - { - memcpy (dst, b->readLoc, copyLen); - b->readLoc += copyLen; - } -} /* SBufCopy */ - - -/* - * returns the next byte from the buffer without advancing the - * current read location. - */ -unsigned char -SBufPeekByte PARAMS ((b), - SBuf *b) -{ - if (SBufEod (b)) - { - b->readError = 1; - return (unsigned char)0; - } - else - return (unsigned char) *b->readLoc; -} /* SBufPeekByte */ - -#if TTBL - -/* - * returns a pointer into the buffer to the next bytes to be read. - * If *lenPtr unread bytes are not available, *lenPtr will be set - * to the number of bytes that are available. The current read location - * is *NOT* advanced at all. The read error flag will NOT be set - * by this routine. - */ -char* -SBufPeekSeg PARAMS ((b, lenPtr), - SBuf *b _AND_ - long int *lenPtr) -{ - if (b->readLoc + *lenPtr > b->dataEnd) - *lenPtr = b->dataEnd - b->readLoc; - - return b->readLoc; -} /* SBufPeekSeg */ - - - -/* - * copies copyLen bytes from buffer b into char *dst. - * Does NOT advance the curr read location. - * assumes dst is pre-allocated and is large enough. - * Will set the read error flag is you attempt to copy - * more than the number of unread bytes available. - */ -void -SBufPeekCopy PARAMS ((dst, b, copyLen), - char *dst _AND_ - SBuf *b _AND_ - long int copyLen) -{ - if (b->readLoc + copyLen > b->dataEnd) - { - memcpy (dst, b->readLoc, b->dataEnd - b->readLoc); - b->readError = 1; - } - else - memcpy (dst, b->readLoc, copyLen); - -} /* SBufCopy */ - -#endif /* TTBL */ - -/* - * returns a pointer into the buffer to the next bytes to be read. - * If *lenPtr unread bytes are not available, *lenPtr will be set - * to the number of bytes that are available. The current read location - * is advance by the number of bytes returned in *lenPtr. The read error - * flag will NOT be set, ever, by this routine. - */ -char* -SBufGetSeg PARAMS ((b, lenPtr), - SBuf *b _AND_ - long int *lenPtr) -{ - char *retVal; - retVal = b->readLoc; - - if (b->readLoc + *lenPtr > b->dataEnd) - { - *lenPtr = b->dataEnd - b->readLoc; - b->readLoc = b->dataEnd; - } - else - b->readLoc += *lenPtr; - - return retVal; -} /* SBufGetSeg */ - -/* - * Write in reverse the char *seg of segLen bytes to the buffer b. - * A reverse write of segement really just prepends the given seg - * (in original order) to the buffers existing data. - * If the SBuf does not have enough room for the segment, - * the writeError flag is set and *NO* copying is done at all. - */ -void -SBufPutSegRvs PARAMS ((b, seg, segLen), - SBuf *b _AND_ - char *seg _AND_ - long int segLen) -{ - if (b->dataStart - segLen < b->blkStart) - b->writeError = 1; - else - { - b->dataStart -= segLen; - memcpy (b->dataStart, seg, segLen); - } -} /* SBufPutSegRvs */ - -/* - * returns the next byte from buffer b's data and advances the - * current read location by one byte. This will set the read error - * flag if you attempt to read past the end of the SBuf - */ -unsigned char -SBufGetByte PARAMS ((b), - SBuf *b) -{ - if (SBufEod (b)) - b->readError = 1; - else - return (unsigned char)(*(b->readLoc++)); -} /* SBufGetByte */ - - -/* - * writes (prepends) the given byte to buffer b's data - */ -void -SBufPutByteRvs PARAMS ((b, byte), - SBuf *b _AND_ - unsigned char byte) -{ - if (b->dataStart <= b->blkStart) - b->writeError = 1; - else - *--b->dataStart = byte; -} /* SBufPutByteRvs */ - -#endif /* USE_GEN_BUF */ diff --git a/SecuritySNACCRuntime/c-lib/src/str-stk.c b/SecuritySNACCRuntime/c-lib/src/str-stk.c deleted file mode 100644 index b679c93c..00000000 --- a/SecuritySNACCRuntime/c-lib/src/str-stk.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * str_stk.c - maintains a stack of the components of a bit string - * or octet string so they can be copied into a single chunk - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/c-lib/src/Attic/str-stk.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: str-stk.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:26 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:32 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/07/24 21:04:57 rj - * changed `_' to `-' in file names. - * - * Revision 1.1 1994/08/28 09:46:09 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-config.h" -#include "str-stk.h" - -/* global for use by AsnBits and AsnOcts */ - -StrStk strStkG = { NULL, 128, 0, 64, 0, 0 }; diff --git a/SecuritySNACCRuntime/c-lib/src/tbl-dbg.c b/SecuritySNACCRuntime/c-lib/src/tbl-dbg.c deleted file mode 100644 index 4f50c0e9..00000000 --- a/SecuritySNACCRuntime/c-lib/src/tbl-dbg.c +++ /dev/null @@ -1,466 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#ifdef TTBL -#include "tbl-dbg.h" - -TdeExceptionCode DBGMinCode = TDEINFO; - -void DBGOcts PARAMS ((v), - AsnOcts* v) -{ - int i; - for (i = 0; i < v->octetLen; i++) - fprintf (stdout, "%c", isprint(v->octs[i])?v->octs[i]:'.'); -} - -char* -Class2ClassStr PARAMS ((class), - int class) -{ - switch (class) - { - case UNIV: - return "UNIV"; - break; - - case APPL: - return "APPL"; - break; - - case CNTX: - return "CNTX"; - break; - - case PRIV: - return "PRIV"; - break; - - default: - return "UNKNOWN"; - break; - } -} - -char* -Form2FormStr PARAMS ((form), - BER_FORM form) -{ - switch (form) - { - case PRIM: - return "PRIM"; - break; - - case CONS: - return "CONS"; - break; - - default: - return "UNKNOWN"; - break; - } -} - -char* -Code2UnivCodeStr PARAMS ((code), - BER_UNIV_CODE code) -{ - switch (code) - { - case BOOLEAN_TAG_CODE: - return "BOOLEAN"; - break; - - case INTEGER_TAG_CODE: - return "INTEGER"; - break; - - case BITSTRING_TAG_CODE: - return "BIT STRING"; - break; - - case OCTETSTRING_TAG_CODE: - return "OCTET STRING"; - break; - - case NULLTYPE_TAG_CODE: - return "NULL"; - break; - - case OID_TAG_CODE: - return "OBJECT IDENTIFIER"; - break; - - case OD_TAG_CODE: - return "OD"; - break; - - case EXTERNAL_TAG_CODE: - return "EXTERNAL"; - break; - - case REAL_TAG_CODE: - return "REAL"; - break; - - case ENUM_TAG_CODE: - return "ENUM"; - break; - - case SEQ_TAG_CODE: - return "SEQUENCE"; - break; - - case SET_TAG_CODE: - return "SET"; - break; - - case NUMERICSTRING_TAG_CODE: - return "NUMERICSTRING"; - break; - - case PRINTABLESTRING_TAG_CODE: - return "PRINTABLESTRING"; - break; - - case TELETEXSTRING_TAG_CODE: - return "TELETEXSTRING"; - break; - - case VIDEOTEXSTRING_TAG_CODE: - return "VIDEOTEXSTRING"; - break; - - case IA5STRING_TAG_CODE: - return "IA5STRING"; - break; - - case UTCTIME_TAG_CODE: - return "UTCTIME"; - break; - - case GENERALIZEDTIME_TAG_CODE: - return "GENERALIZEDTIME"; - break; - - case GRAPHICSTRING_TAG_CODE: - return "GRAPHICSTRING"; - break; - - case VISIBLESTRING_TAG_CODE: - return "VISIBLESTRING"; - break; - - case GENERALSTRING_TAG_CODE: - return "GENERALSTRING"; - break; - - default: - return "UNKNOWN"; - - } -} /* Form2FormStr */ - -#define SOT 0 -#define EOL 1 -#define EOLINC 2 -#define DECSOTEOL 3 -#define SOTSPC 4 -#define EOLIF 5 - -void DBGIndent PARAMS ((mode), - int mode) -{ - static int indent = 0; - static int withinline = 0; - int i; - - /*DEC*/ - if (mode==DECSOTEOL) - indent--; - - /*SPC*/ - if (mode==SOTSPC && withinline) - fprintf(stdout," "); - - /*SOT*/ - if ((mode==SOT || mode==DECSOTEOL || mode==SOTSPC) && !withinline) - { - for (i=0; i>24; - codename = Code2UnivCodeStr(bcode); - } - else - { - bcode = OCTETSTRING_TAG_CODE; - codename = "NOT_UNIV"; - } - if (begin) - { - DBGIndent(SOTSPC); - fprintf (stdout, "%s", codename); - if (TAG_IS_CONS(tag)) - { - if (tclass==UNIV) - { - fprintf(stdout, " {\n"); - DBGIndent(EOLINC); - } - } - else - { - fprintf(stdout,": "); - PrintAsnOcts(stdout,v,0); - fprintf(stdout,"\n"); - DBGIndent(EOL); - } - } - else - { - if (TAG_IS_CONS(tag) && tclass==UNIV) - { - DBGIndent(DECSOTEOL); - fprintf(stdout, "}\n"); - } - } - return 0; -} - -void DBGNamedValue PARAMS ((tnnl, val, mode), - TBLNamedNumberList* tnnl _AND_ - AsnInt val _AND_ - int mode) -{ - /* mode 0: Don't print if no named value. postfix print with -- */ - /* mode 0|1: prefix with -- */ - /* mode >1: prefix with , */ - TBLNamedNumber* tnn; - char* name = NULL; - FOR_EACH_LIST_ELMT (tnn, tnnl) - if (tnn->value == val) - { - name = tnn->name.octs; - break; - } - if (!mode && !name) - return; - if (mode<=1) - fprintf(stdout," -- "); - else - fprintf(stdout,", "); - if (name) - fprintf(stdout,"%s",name); - fprintf(stdout,"(%d)",val); - if (!mode) - fprintf(stdout," --"); -} - -void -DBGPrintType PARAMS ((type), - TBLType* type) -{ - static char* TIN [] = { "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", - "NULL", "OBJECT IDENTIFIER", "REAL", "ENUMERATED", "SEQUENCE", "SET", - "SEQUENCE OF", "SET OF", "CHOICE", NULL }; - - if (type->typeId == TBL_TYPEREF) - DBGOcts(&type->content->a.typeRef->typeDefPtr->typeName); - else - fprintf(stdout,TIN[type->typeId]); - if (type->fieldName.octetLen) - { - fprintf(stdout," "); - DBGOcts(&type->fieldName); - } -} - -typedef int (*Proc) PROTO (()); - -int -DBGType PARAMS ((type, val, begin), - TBLType* type _AND_ - AVal* val _AND_ - int begin) -{ - static Proc printproc [] = {PrintAsnBool, PrintAsnInt, PrintAsnBits, - PrintAsnOcts, - PrintAsnNull, PrintAsnOid, PrintAsnReal, PrintAsnInt, NULL, NULL, - NULL, NULL, NULL, - NULL}; - - if (begin) - { - DBGIndent(SOTSPC); - DBGPrintType(type); - if (type->typeId >= TBL_SEQUENCE && type->typeId <= TBL_CHOICE) - { - fprintf(stdout," {\n"); - DBGIndent(EOLINC); - } - } - else - { - if (printproc[type->typeId]) - { - DBGIndent(SOT); - fprintf(stdout,": "); - (*printproc[type->typeId])(stdout,val,0); - switch (type->typeId) - { - case TBL_BITSTRING: - { - AsnInt i; - AsnBits* b = (AsnBits*)val; - int mode = 1; - for (i=0; ibitLen;i++) - if (GetAsnBit(b,i)) - DBGNamedValue(type->values,i,mode++); - if (mode>1) - fprintf(stdout," --"); - } - break; - case TBL_ENUMERATED: - DBGNamedValue(type->values,*(AsnInt*)val,0); - break; - default: - break; - } - fprintf(stdout,"\n"); - DBGIndent(EOL); - } - if (type->typeId >= TBL_SEQUENCE && type->typeId <= TBL_CHOICE) - { - DBGIndent(DECSOTEOL); - fprintf(stdout,"}\n"); - } - } - return 0; -} - -int DBGExc PARAMS ((code, p1, p2, p3), - TdeExceptionCode code _AND_ - void* p1 _AND_ - void* p2 _AND_ - void* p3) -{ - if (codefrom,((TBLRange*)p2)->to); - DBGPrintType((TBLType*)p1); - fprintf(stdout,".\n"); - DBGIndent(EOL); - break; - case TDENOMATCH: - DBGIndent(EOLIF); - DBGIndent(SOT); - fprintf(stdout,"WARNING: Tag [%08X] does not match tag [%08X] of type ", - *(AsnTag*)p3,*(AsnTag*)p2); - DBGPrintType((TBLType*)p1); - fprintf(stdout,".\n"); - DBGIndent(EOL); - break; - case TDEERROR: - DBGIndent(EOLIF); - DBGIndent(SOT); - fprintf(stdout,"ERROR: %s.\n",(char*)p1); - DBGIndent(EOL); - break; - } - return 0; -} -#endif diff --git a/SecuritySNACCRuntime/c-lib/src/tbl-dec.c b/SecuritySNACCRuntime/c-lib/src/tbl-dec.c deleted file mode 100644 index 4a4317f4..00000000 --- a/SecuritySNACCRuntime/c-lib/src/tbl-dec.c +++ /dev/null @@ -1,456 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#ifdef TTBL - -/* - * tbl_dec.c - type table decoder. - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - */ - - -#include -#include "tbl-incl.h" - -int TagsMatch PROTO ((TBLType *tblT, AsnTag asnTag)); -void TblPopTagsAndLens PROTO ((TBLType *tblT, BUF_TYPE b, int implicit, unsigned long int *bytesDecoded, ENV_TYPE env)); - -void TblDecodeTagsAndLens PROTO ((TBLType *tblT, BUF_TYPE b, int implicit, ENV_TYPE env)); - -int CountMandatoryElmts PROTO ((TBLType *tblT)); - - -typedef struct TagNLen -{ - AsnTag tag; - AsnLen len; - unsigned int size; /* encoded len for this tag len pair */ -} TagNLen; - -#define TL_STK_SIZE 128 -static TagNLen tlStkG[TL_STK_SIZE]; -static int nextFreeTLG = 0; - -#define PUSH_TL(t,l,sz, env)\ - { if (nextFreeTLG >= TL_STK_SIZE)\ - longjmp (env, -1000);\ - tlStkG[nextFreeTLG].tag = t;\ - tlStkG[nextFreeTLG].len = l;\ - tlStkG[nextFreeTLG++].size = sz; } - -#define POP_TL(env)\ - { nextFreeTLG--;\ - if (nextFreeTLG < 0)\ - longjmp (env, -1001);} - -#define LAST_TAG() (tlStkG[nextFreeTLG-1].tag) -#define LAST_LEN() (tlStkG[nextFreeTLG-1].len) -#define LAST_SIZE() (tlStkG[nextFreeTLG-1].size) - - - -AVal* -TblDecode PARAMS ((tbl, modName, typeName, b, bytesDecoded), - TBL *tbl _AND_ - char *modName _AND_ - char *typeName _AND_ - BUF_TYPE b _AND_ - unsigned long int *bytesDecoded) -{ - TBLModule *tblMod; - TBLTypeDef *tblTd; - ENV_TYPE env; - AVal *retVal; - int val; - - tblTd = TblFindTypeDef (tbl, modName, typeName, &tblMod); - if (tblTd == NULL) - { - TblError ("TblDecode: Could not find a type definition with the given module and name"); - return NULL; - } - *bytesDecoded = 0; - - if ((val = setjmp (env)) == 0) - { - retVal = TblDecodeType (tblTd->type, b, FALSE, bytesDecoded, env); - } - else - retVal = NULL; - - if (val != 0) - fprintf (stderr,"ack! longjmp error number: %d\n", val); - - return retVal; -} /* TblDecode p*/ - - -AVal* -TblDecodeType PARAMS ((tblT, b, implicit, bytesDecoded, env), - TBLType *tblT _AND_ - BUF_TYPE b _AND_ - int implicit _AND_ - unsigned long int *bytesDecoded _AND_ - ENV_TYPE env) -{ - AVal *elmtVPtr; - unsigned long int tmpBytesDecoded = 0; - unsigned int currElmt; - TBLType *listElmtType; - TBLType *structElmtType; - TBLType *choiceElmtType; - AChoiceVal *cVal; - AStructVal *sVal; - AVal *retVal; - AVal **tmpHndl; - AsnTag asnTag; - int i, mandatoryCount, mandatoryElmts; - int implicitRef; - void *tmp; - - - TblDecodeTagsAndLens (tblT, b, implicit, env); - - switch (tblT->typeId) - { - case TBL_TYPEREF: - /* - * carry over implicit ref if goes - * through typeref with no tags - */ - implicitRef = tblT->content->a.typeRef->implicit || - (implicit && - ((tblT->tagList == NULL) || LIST_EMPTY (tblT->tagList))); - - retVal = TblDecodeType (tblT->content->a.typeRef->typeDefPtr->type, b, implicitRef, &tmpBytesDecoded, env); - break; - - case TBL_SEQUENCE: - /* go fwd though elmt type list */ - currElmt = 0; - sVal = (AStructVal*) Asn1Alloc (sizeof (AVal*)* - LIST_COUNT (tblT->content->a.elmts)); - tmp = CURR_LIST_NODE (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT (structElmtType, tblT->content->a.elmts) - { - if (TagsMatch (structElmtType, PeekTag (b,env))) - { - sVal[currElmt] = TblDecodeType (structElmtType, b, FALSE, &tmpBytesDecoded, env); - } - else if (!structElmtType->optional) - longjmp (env,-1008); - - currElmt++; - } - SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); - retVal = (AVal*) sVal; - break; - - case TBL_SET: - sVal = (AStructVal*) Asn1Alloc (sizeof (AVal*)* - LIST_COUNT (tblT->content->a.elmts)); - mandatoryCount = 0; - mandatoryElmts = CountMandatoryElmts (tblT); - if (LAST_LEN() == INDEFINITE_LEN) - while (!PeekEoc (b)) - { - asnTag = PeekTag (b,env); - currElmt = 0; - /* find elmt that matches the peeked tag */ - FOR_EACH_LIST_ELMT (structElmtType, tblT->content->a.elmts) - { - if (TagsMatch (structElmtType, asnTag)) - break; - currElmt++; - } - - /* didn't find a match */ - if (currElmt >= LIST_COUNT (tblT->content->a.elmts)) - longjmp (env,-1009); - - if (!structElmtType->optional) - mandatoryCount++; - - sVal[currElmt] = TblDecodeType (structElmtType, b, FALSE, &tmpBytesDecoded, env); - } - else - while (tmpBytesDecoded < LAST_LEN()) - { - asnTag = PeekTag (b,env); - currElmt = 0; - /* find elmt that matches the peeked tag */ - FOR_EACH_LIST_ELMT (structElmtType, tblT->content->a.elmts) - { - if (TagsMatch (structElmtType, asnTag)) - break; - currElmt++; - } - - if (currElmt >= LIST_COUNT (tblT->content->a.elmts)) - longjmp (env, -1007); - - if (!structElmtType->optional) - mandatoryCount++; - - sVal[currElmt] = TblDecodeType (structElmtType, b, FALSE, &tmpBytesDecoded, env); - } - if (mandatoryCount != mandatoryElmts) - longjmp (env,-1006); - else - retVal = sVal; - - break; - - - case TBL_SEQUENCEOF: - case TBL_SETOF: - retVal = (AsnList*)Asn1Alloc (sizeof (AsnList)); - listElmtType = FIRST_LIST_ELMT (tblT->content->a.elmts); - - if (LAST_LEN() == INDEFINITE_LEN) - while (!PeekEoc (b)) - { - elmtVPtr = TblDecodeType (listElmtType, b, FALSE, &tmpBytesDecoded, env); - tmpHndl = AsnListAppend ((AsnList*)retVal); - *tmpHndl = elmtVPtr; - } - else - while (tmpBytesDecoded < LAST_LEN()) - { - elmtVPtr = TblDecodeType (listElmtType, b, FALSE, &tmpBytesDecoded, env); - tmpHndl = AsnListAppend ((AsnList*)retVal); - *tmpHndl = elmtVPtr; - } - - break; - - case TBL_CHOICE: - retVal = cVal = (AChoiceVal*) Asn1Alloc (sizeof (AChoiceVal)); - asnTag = PeekTag (b,env); - i = 0; - /* find elmt that matches the peeked tag */ - tmp = CURR_LIST_NODE (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT (choiceElmtType, tblT->content->a.elmts) - { - if (TagsMatch (choiceElmtType, asnTag)) - { - cVal->choiceId = i; - break; - } - i++; - } - SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); - cVal->val = TblDecodeType (choiceElmtType, b, FALSE, &tmpBytesDecoded, env); - break; - - case TBL_BOOLEAN: - retVal = Asn1Alloc (sizeof (AsnBool)); - BDecAsnBoolContent (b, LAST_TAG(), LAST_LEN(), (AsnBool*) retVal, &tmpBytesDecoded, env); - break; - - case TBL_INTEGER: - case TBL_ENUMERATED: - retVal = Asn1Alloc (sizeof (AsnInt)); - BDecAsnIntContent (b, LAST_TAG(), LAST_LEN(), (AsnInt*) retVal, &tmpBytesDecoded, env); - break; - - case TBL_BITSTRING: - retVal = Asn1Alloc (sizeof (AsnBits)); - BDecAsnBitsContent (b, LAST_TAG(), LAST_LEN(), (AsnBits*) retVal, &tmpBytesDecoded, env); - break; - - case TBL_OCTETSTRING: - retVal = Asn1Alloc (sizeof (AsnOcts)); - BDecAsnOctsContent (b, LAST_TAG(), LAST_LEN(), (AsnOcts*) retVal, &tmpBytesDecoded, env); - break; - - case TBL_NULL: - retVal = Asn1Alloc (sizeof (AsnNull)); - BDecAsnNullContent (b, LAST_TAG(), LAST_LEN(), (AsnNull*) retVal, &tmpBytesDecoded, env); - break; - - case TBL_OID: - retVal = Asn1Alloc (sizeof (AsnOid)); - BDecAsnOidContent (b, LAST_TAG(), LAST_LEN(), (AsnOid*) retVal, &tmpBytesDecoded, env); - break; - - case TBL_REAL: - retVal = Asn1Alloc (sizeof (AsnReal)); - BDecAsnRealContent (b, LAST_TAG(), LAST_LEN(), (AsnReal*) retVal, &tmpBytesDecoded, env); - break; - - default: - retVal = NULL; - break; - } - - TblPopTagsAndLens (tblT, b, implicit, &tmpBytesDecoded, env); - - (*bytesDecoded) += tmpBytesDecoded; - - return retVal; - -} /* TblDecodeType */ - - -void -TblDecodeTagsAndLens PARAMS ((tblT, b, implicit, env), - TBLType *tblT _AND_ - BUF_TYPE b _AND_ - int implicit _AND_ - ENV_TYPE env) -{ - AsnTag tag; - AsnLen len; - AsnLen encSize; - TBLTag *tblTag; - - if ((tblT->tagList == NULL) || (LIST_EMPTY (tblT->tagList))) - return; - - SET_CURR_LIST_NODE (tblT->tagList, FIRST_LIST_NODE (tblT->tagList)); - if (implicit) - { - SET_CURR_LIST_NODE (tblT->tagList, NEXT_LIST_NODE (tblT->tagList)); - } - - - FOR_REST_LIST_ELMT (tblTag, tblT->tagList) - { - encSize = 0; - tag = BDecTag (b, &encSize, env); - len = BDecLen (b, &encSize, env); - - if (!TagsEquiv (tag, tblTag)) - longjmp (env, -1002); - - PUSH_TL (tag, len, encSize, env); - } -} /* TblDecodeTagsAndLens */ - -/* - * bytesDecoded should hold the length of the content that - * was just decoded. This verifies the lengths as it pops - * them off the stack. Also decodes EOCs. - */ -void -TblPopTagsAndLens PARAMS ((tblT, b, implicit, bytesDecoded, env), - TBLType *tblT _AND_ - BUF_TYPE b _AND_ - int implicit _AND_ - unsigned long int *bytesDecoded _AND_ - ENV_TYPE env) -{ - TBLTag *tblTag; - - FOR_EACH_LIST_ELMT_RVS (tblTag, tblT->tagList) - { - if (implicit && (tblTag == FIRST_LIST_ELMT (tblT->tagList))) - break; - - if (LAST_LEN() == INDEFINITE_LEN) - BDecEoc (b, bytesDecoded, env); - else if (*bytesDecoded != LAST_LEN()) - longjmp (env, -1003); - - (*bytesDecoded) += LAST_SIZE(); - POP_TL (env); - } -} /* TblPopTagsAndLens */ - - -int TagsMatch PARAMS ((tblT, asnTag), - TBLType *tblT _AND_ - AsnTag asnTag) -{ - TBLType *tmpTblT; - TBLType *elmtTblT; - TBLTag *tblTag; - void *tmp; - - /* - * skip through type refs until encounter first tag or - * untagged CHOICE (only TYPEREFs and CHOICEs can - * have empty tag lists). - */ - for (tmpTblT = tblT; ((tmpTblT->typeId == TBL_TYPEREF) && - ((tmpTblT->tagList == NULL) || LIST_EMPTY (tmpTblT->tagList))); - tmpTblT = tmpTblT->content->a.typeRef->typeDefPtr->type); - - - /* - * if untagged CHOICE must check for a match with the first tag - * of each component of the CHOICE - */ - if ((tmpTblT->typeId == TBL_CHOICE) && - ((tmpTblT->tagList == NULL) || LIST_EMPTY (tmpTblT->tagList))) - { - tmp = CURR_LIST_NODE (tmpTblT->content->a.elmts); - FOR_EACH_LIST_ELMT (elmtTblT, tmpTblT->content->a.elmts) - { - /* - * remember the elmt type can be an untagged choice too - * so call TagsMatch again. - */ - if (TagsMatch (elmtTblT, asnTag)) - { - SET_CURR_LIST_NODE (tmpTblT->content->a.elmts, tmp); - return TRUE; /* match in choice */ - } - } - SET_CURR_LIST_NODE (tmpTblT->content->a.elmts, tmp); - return FALSE; /* no match in choice */ - } - else /* is type other than untagged choice or type ref */ - { - tblTag = FIRST_LIST_ELMT (tmpTblT->tagList); - return TagsEquiv (asnTag, tblTag); - } -} /* TagsMatch */ - - -int -CountMandatoryElmts PARAMS ((tblT), - TBLType *tblT) -{ - TBLType *tblElmtT; - int count = 0; - FOR_EACH_LIST_ELMT (tblElmtT, tblT->content->a.elmts) - { - if (!tblElmtT->optional) - count++; - } - return count; -} /* CountMandatoryElmts */ - -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/src/tbl-enc.c b/SecuritySNACCRuntime/c-lib/src/tbl-enc.c deleted file mode 100644 index 9f9370f6..00000000 --- a/SecuritySNACCRuntime/c-lib/src/tbl-enc.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#ifdef TTBL - -/* - * tbl_enc.c - type table encoder - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - */ - - -#include -#include "tbl-incl.h" - -/* protos for non exported routines */ - -/* -int TblEncodePrimTagsAndLens PROTO ((TBLType *tblT, BUF_TYPE b, int implicit, unsigned long int *bytesEncoded)); - -int TblEncodeConsTagsAndLens PROTO ((TBLType *tblT, BUF_TYPE b, int implicit, unsigned long int *bytesEncoded)); -*/ - -int TblEncodeTagsAndLens PROTO ((TBLType *tblT, BUF_TYPE b, int implicit, unsigned long int *bytesEncoded)); - -AsnLen TblEncTag PROTO ((BUF_TYPE b, TBLTag *tag)); - - - - -/* - * Encode value v as though it is of type modName.typeName. - * bytesEncoded is set the actual number of bytes in the - * encode value. - * returns less than zero if an error occurs otherwise - * returns 0 for success. - */ -int -TblEncode PARAMS ((tbl, modName, typeName, b, v, bytesEncoded), - TBL *tbl _AND_ - char *modName _AND_ - char *typeName _AND_ - BUF_TYPE b _AND_ - AVal *v _AND_ - unsigned long int *bytesEncoded) -{ - TBLModule *tblMod; - TBLTypeDef *tblTd; - int retVal; - - tblTd = TblFindTypeDef (tbl, modName, typeName, &tblMod); - if (tblTd == NULL) - { - TblError ("TblEncode: Could not find a type definition with the given module and name"); - return -1; - } - *bytesEncoded = 0; - retVal = TblEncodeType (tblTd->type, b, v, FALSE, bytesEncoded); - - if (BufWriteError (b)) - retVal = -1; - - return retVal; -} /* TblEncode */ - - -/* - * returns less than zero if an error occurs - */ -int -TblEncodeType PARAMS ((tblT, b, v, implicit, bytesEncoded), - TBLType *tblT _AND_ - BUF_TYPE b _AND_ - AVal *v _AND_ - int implicit _AND_ - unsigned long int *bytesEncoded) -{ - AVal *elmtV; - AsnList *lVal; - int retVal = 0; - unsigned long int tmpBytesEncoded = 0; - unsigned int currElmt; - TBLType *listElmtType; - TBLType *structElmtType; - TBLType *choiceElmtType; - AChoiceVal *cVal; - AStructVal *sVal; - int implicitRef; - void *tmp; - - switch (tblT->typeId) - { - case TBL_TYPEREF: - - /* - * carry over implicit ref if goes - * through typeref with no tags - */ - implicitRef = tblT->content->a.typeRef->implicit || - (implicit && - ((tblT->tagList == NULL) || LIST_EMPTY (tblT->tagList))); - - retVal = TblEncodeType (tblT->content->a.typeRef->typeDefPtr->type, b, v, implicitRef, &tmpBytesEncoded); - break; - - case TBL_SEQUENCE: - case TBL_SET: - /* rvs though list value and list type def */ - currElmt = LIST_COUNT (tblT->content->a.elmts)-1; - sVal = (AStructVal*)v; - tmp = CURR_LIST_NODE (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT_RVS (structElmtType, tblT->content->a.elmts) - { - elmtV = sVal[currElmt--]; - if (!(structElmtType->optional && (elmtV == NULL))) - { - retVal = TblEncodeType (structElmtType, b, elmtV, FALSE, &tmpBytesEncoded); - if (retVal < 0) - break; /* exit for loop */ - } - } - /* restore list curr in case recursive type */ - SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); - break; - - case TBL_SEQUENCEOF: - case TBL_SETOF: - lVal = (AsnList*)v; - listElmtType = FIRST_LIST_ELMT (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT_RVS (elmtV, lVal) - { - retVal = TblEncodeType (listElmtType, b, elmtV, FALSE, &tmpBytesEncoded); - if (retVal < 0) - break; /* exit for loop */ - } - break; - - case TBL_CHOICE: - cVal = (AChoiceVal*) v; - choiceElmtType = (TBLType*)GetAsnListElmt (tblT->content->a.elmts, cVal->choiceId); - retVal = TblEncodeType (choiceElmtType, b, cVal->val, FALSE, &tmpBytesEncoded); - break; - - case TBL_BOOLEAN: - tmpBytesEncoded += BEncAsnBoolContent (b, (AsnBool*)v); - break; - - case TBL_INTEGER: - case TBL_ENUMERATED: - tmpBytesEncoded += BEncAsnIntContent (b, (AsnInt*)v); - break; - - case TBL_BITSTRING: - tmpBytesEncoded += BEncAsnBitsContent (b, (AsnBits*)v); - break; - - case TBL_OCTETSTRING: - tmpBytesEncoded += BEncAsnOctsContent (b, (AsnOcts*)v); - break; - - case TBL_NULL: - tmpBytesEncoded += BEncAsnNullContent (b, (AsnNull*)v); - break; - - case TBL_OID: - tmpBytesEncoded += BEncAsnOidContent (b, (AsnOid*)v); - break; - - case TBL_REAL: - tmpBytesEncoded += BEncAsnRealContent (b, (AsnReal*)v); - break; - - default: - retVal = -1; - } - - if (retVal >= 0) - retVal = TblEncodeTagsAndLens (tblT, b, implicit, &tmpBytesEncoded); - - (*bytesEncoded) += tmpBytesEncoded; - - return retVal; - -} /* TblEncodeTd */ - - -int -TblEncodeTagsAndLens PARAMS ((tblT, b, implicit, bytesEncoded), - TBLType *tblT _AND_ - BUF_TYPE b _AND_ - int implicit _AND_ - unsigned long int *bytesEncoded) -{ - TBLTag *tag; - - FOR_EACH_LIST_ELMT_RVS (tag, tblT->tagList) - { - if (!(implicit && (tag == FIRST_LIST_ELMT (tblT->tagList)))) - { - if (tag->form == CONS) - (*bytesEncoded) += BEncConsLen (b, *bytesEncoded); - else /* ANY_FORM or PRIM */ - (*bytesEncoded) += BEncDefLen (b, *bytesEncoded); - - (*bytesEncoded) += TblEncTag (b, tag); - } - } - return 0; /* no errors */ -} /* TblEncodeTagsAndLens */ - -/* -int -TblEncodePrimTagsAndLens PARAMS ((tblT, b, implicit, bytesEncoded), - TBLType *tblT _AND_ - BUF_TYPE b _AND_ - int implicit _AND_ - unsigned long int *bytesEncoded) -{ - TBLTag *tag; - int tagsEncoded; - int numTags; - - if ((tblT->tagList == NULL) ||(LIST_EMPTY (tblT->tagList))) - untaggedPrimG = TRUE; - else - { - numTags = LIST_COUNT (tblT->tagList); - if ((numTags != 1) || !implicit) - { - untaggedPrimG = FALSE; - tag = FIRST_LIST_ELMT (tblT->tagList); - (*bytesEncoded) += BEncDefLen (b, *bytesEncoded); - (*bytesEncoded) += TblEncTag (b, tag->tclass, PRIM, tag->code); - tagsEncoded = 1; - SET_CURR_LIST_NODE (tblT->tagList, LAST_LIST_NODE (tblT->tagList)->prev); - FOR_REST_LIST_ELMT_RVS (tag, tblT->tagList) - { - if (implicit && (tagsEncoded == (numTags -1))) - break; - (*bytesEncoded) += BEncConsLen (b, *bytesEncoded); - (*bytesEncoded) += TblEncTag (b, tag->tclass, CONS, tag->code); - tagsEncoded++; - } - } - else - untaggedPrimG = TRUE; - } - return 0; -} TblEncodeTagsAndLens */ - - -/* - * write encoded version of tag stored in the tag to - * the bufer - */ -AsnLen TblEncTag PARAMS ((b, tag), - BUF_TYPE b _AND_ - TBLTag *tag) -{ - AsnTag shifted; - unsigned char octet; - AsnLen encLen = 0; - int i; - - for (i = 0; i < sizeof (AsnTag); i++) - { - shifted = (tag->encTag >> (i * 8)); - octet = shifted & 0xff; - if (octet || i -#include "tbl-incl.h" - - -void -TblFree PARAMS ((tbl, modName, typeName, v), - TBL *tbl _AND_ - char *modName _AND_ - char *typeName _AND_ - AVal *v) -{ - TBLModule *tblMod; - TBLTypeDef *tblTd; - - tblTd = TblFindTypeDef (tbl, modName, typeName, &tblMod); - if (tblTd == NULL) - { - TblError ("TblFree: Could not find a type definition with the given module and name"); - } - - TblFreeType (tblTd->type, v); -} /* TblDecode p*/ - - -void -TblFreeType PARAMS ((tblT, v), - TBLType *tblT _AND_ - AVal *v) -{ - AVal *elmtVPtr; - unsigned int currElmt; - TBLType *listElmtType; - TBLType *structElmtType; - TBLType *choiceElmtType; - AChoiceVal *cVal; - AStructVal *sVal; - AsnList *lVal; - void *tmp; - - - switch (tblT->typeId) - { - case TBL_TYPEREF: - TblFreeType (tblT->content->a.typeRef->typeDefPtr->type, v); - break; - - case TBL_SEQUENCE: - case TBL_SET: - sVal = (AStructVal*)v; - currElmt = 0; - tmp = CURR_LIST_NODE (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT (structElmtType, tblT->content->a.elmts) - { - if (!((structElmtType->optional) && (sVal[currElmt] == NULL))) - TblFreeType (structElmtType, sVal[currElmt]); - currElmt++; - } - SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); - Asn1Free (v); - break; - - - case TBL_SEQUENCEOF: - case TBL_SETOF: - listElmtType = FIRST_LIST_ELMT (tblT->content->a.elmts); - lVal = (AsnList*)v; - FOR_EACH_LIST_ELMT (elmtVPtr, lVal) - { - TblFreeType (listElmtType, elmtVPtr); - } - AsnListFree (lVal); - break; - - case TBL_CHOICE: - cVal = (AChoiceVal*)v; - choiceElmtType = (TBLType*)GetAsnListElmt (tblT->content->a.elmts, cVal->choiceId); - TblFreeType (choiceElmtType, cVal->val); - Asn1Free (cVal); - break; - - case TBL_BOOLEAN: - FreeAsnBool ((AsnBool*)v); - Asn1Free (v); - break; - - case TBL_INTEGER: - case TBL_ENUMERATED: - FreeAsnInt ((AsnInt*)v); - Asn1Free (v); - break; - - case TBL_BITSTRING: - FreeAsnBits ((AsnBits*)v); - Asn1Free (v); - break; - - case TBL_OCTETSTRING: - FreeAsnOcts ((AsnOcts*)v); - Asn1Free (v); - break; - - case TBL_NULL: - FreeAsnNull ((AsnNull*)v); - Asn1Free (v); - break; - - case TBL_OID: - FreeAsnOid ((AsnOid*)v); - Asn1Free (v); - break; - - case TBL_REAL: - FreeAsnReal ((AsnReal*)v); - Asn1Free (v); - break; - - default: - break; - } - -} /* TblFreeType */ - -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/src/tbl-gen.c b/SecuritySNACCRuntime/c-lib/src/tbl-gen.c deleted file mode 100644 index ded07407..00000000 --- a/SecuritySNACCRuntime/c-lib/src/tbl-gen.c +++ /dev/null @@ -1,669 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#ifdef TTBL -#include -#include "tbl-gen.h" - -typedef struct TagNLen -{ - AsnTag tag; - AsnLen len; - unsigned int size; /* encoded len for this tag len pair */ -} TagNLen; - -#define TL_STK_SIZE 128 - -typedef struct STDEDecoder -{ - TBL* tbl; - BUF_TYPE b; - ENV_TYPE env; - TagNLen tlStk[TL_STK_SIZE]; - int nTlStk; - int rewindsize; - TdeTypeProc typeproc; - TdeSimpleProc simpleproc; - TdeExcProc excproc; -} * TDEDecoder; - - -#define TDEEXCEPTION(dec,code,p1,p2,p3) if ((dec)->excproc) if ((*(dec)->excproc)(code,p1,p2,p3)) longjmp((dec)->env,-236) - -#define TDEERRORMSG(dec,msg) TDEEXCEPTION(dec,TDEERROR,msg,NULL,NULL) - -#define TDEWARNUNEXPECTED(dec,type,elmtType) TDEEXCEPTION(dec,TDEUNEXPECTED,type,elmtType,NULL) -#define TDEWARNNONOPTIONAL(dec,type,elmtType) TDEEXCEPTION(dec,TDENONOPTIONAL,type,elmtType,NULL) -#define TDEWARNMANDATORY(dec,type) TDEEXCEPTION(dec,TDEMANDATORY,type,NULL,NULL) -#define TDEWARNCONSTRAINT(dec,type,cons,val) TDEEXCEPTION(dec,TDECONSTRAINT,type,cons,&val) -#define TDEWARNNOMATCH(dec,type,typetag,tag) TDEEXCEPTION(dec,TDENOMATCH,type,&typetag,&tag) - -#define TDEINFOEOC(dec) TDEEXCEPTION(dec,TDEEOC,NULL,NULL,NULL) -#define TDEINFOPEEKTAG(dec,tag) TDEEXCEPTION(dec,TDEPEEKTAG,&tag,NULL,NULL) -#define TDEINFOPUSHTAG(dec,tag,len,size) TDEEXCEPTION(dec,TDEPUSHTAG,&tag,&len,&size) - -#define TDETYPE(dec,type,val,begin) if (dec->typeproc) if ((*dec->typeproc)(type,val,begin)) longjmp(dec->env,-234) -#define TDESIMPLE(dec,tag,octs,begin) if (dec->simpleproc) if ((*dec->simpleproc)(tag,octs,begin)) longjmp(dec->env,-235) - -#define LAST_TAG() (dec->tlStk[dec->nTlStk-1-dec->rewindsize].tag) -#define LAST_LEN() (dec->tlStk[dec->nTlStk-1-dec->rewindsize].len) -#define LAST_SIZE() (dec->tlStk[dec->nTlStk-1-dec->rewindsize].size) - -AsnTag -TDEPeekTag PARAMS ((dec), - TDEDecoder dec) -{ - AsnTag tag; - if (dec->rewindsize) - tag = dec->tlStk[dec->nTlStk-dec->rewindsize].tag; - else - tag = PeekTag(dec->b,dec->env); - TDEINFOPEEKTAG(dec,tag); - return tag; -} - -AsnTag -TDEPushTag PARAMS ((dec), - TDEDecoder dec) -{ - if (dec->rewindsize) - dec->rewindsize--; - else - { - unsigned long encSize = 0; - if (dec->nTlStk >= TL_STK_SIZE) - longjmp (dec->env, -1000); - dec->tlStk[dec->nTlStk].tag = BDecTag (dec->b, &encSize, dec->env); - dec->tlStk[dec->nTlStk].len = BDecLen (dec->b, &encSize, dec->env); - dec->tlStk[dec->nTlStk++].size = encSize; - TDEINFOPUSHTAG(dec,LAST_TAG(),LAST_LEN(),LAST_SIZE()); - } - return LAST_TAG(); -} - -void -TDEDoPop PARAMS ((dec), - TDEDecoder dec) -{ - dec->nTlStk--; - if (dec->nTlStk < 0) - longjmp (dec->env, -1001); -} - -void -TDEPopTag PARAMS ((dec, bytesDecoded), - TDEDecoder dec _AND_ - unsigned long int *bytesDecoded) -{ - if (LAST_LEN()==INDEFINITE_LEN) - { - BDecEoc (dec->b, bytesDecoded, dec->env); - TDEINFOEOC(dec); - } - else if (*bytesDecoded != LAST_LEN()) - { - TDEERRORMSG(dec,"Lost BER synchronisation"); - longjmp (dec->env, -1003); - } - (*bytesDecoded) += LAST_SIZE(); - TDEDoPop(dec); -} - -void -TDECheckConstraint PARAMS ((dec, type, constraint, value), - TDEDecoder dec _AND_ - TBLType* type _AND_ - TBLRange* constraint _AND_ - AsnInt value) -{ - if (constraint && (valuefrom || value>constraint->to)) - TDEWARNCONSTRAINT(dec,type,constraint,value); -} - -int -TDEInTag PARAMS ((dec, bytesDecodedInTag), - TDEDecoder dec _AND_ - unsigned long int bytesDecodedInTag) -{ - return LAST_LEN()==INDEFINITE_LEN? !PeekEoc(dec->b): (bytesDecodedInTagcontent->a.elmts) - { - if (!elmtType->optional) - count++; - } - return count; -} - -void -TDESimpleDecode PARAMS ((dec, bytesDecoded), - TDEDecoder dec _AND_ - unsigned long int *bytesDecoded) -{ - AsnTag tag = TDEPushTag(dec); - unsigned long int bytesDecodedInTag = 0; - - BER_CLASS tclass = TAG_ID_CLASS(tag); - BER_FORM form = TAG_ID_FORM(tag); - unsigned long int code = tag & 0x1FFFFFFF; - BER_UNIV_CODE bcode; - if (tclass==UNIV) - bcode = code>>24; - else - bcode = OCTETSTRING_TAG_CODE; - - if (TAG_IS_CONS(tag)) - { - TDESIMPLE(dec,tag,NULL,1); - while (TDEInTag(dec,bytesDecodedInTag)) - { - TDESimpleDecode (dec, &bytesDecodedInTag); - } - TDESIMPLE(dec,tag,NULL,0); - } - else - { - PrintableString v; - switch (bcode) - { - case INTEGER_TAG_CODE: - case OCTETSTRING_TAG_CODE: - default: - v.octetLen = LAST_LEN(); - v.octs = Asn1Alloc(v.octetLen); - BufCopy(v.octs,dec->b,v.octetLen); - TDESIMPLE(dec,tag,&v,1); - Asn1Free(v.octs); - break; - } - bytesDecodedInTag += LAST_LEN(); - } - TDEPopTag(dec,&bytesDecodedInTag); - *bytesDecoded += bytesDecodedInTag; -} - -int -TDEPushTagsAndLens PARAMS ((dec, type, implicit), - TDEDecoder dec _AND_ - TBLType *type _AND_ - int implicit) -{ - AsnTag tag; - AsnLen len; - AsnLen encSize; - TBLTag *tblTag; - int fullMatch = TRUE; - int origTLG = dec->nTlStk; - int origRewindsize = dec->rewindsize; - - if ((type->tagList == NULL) || (LIST_EMPTY (type->tagList))) - return TRUE; - - SET_CURR_LIST_NODE (type->tagList, FIRST_LIST_NODE (type->tagList)); - if (implicit) - { - SET_CURR_LIST_NODE (type->tagList, NEXT_LIST_NODE (type->tagList)); - } - - FOR_REST_LIST_ELMT (tblTag, type->tagList) - { - tag = TDEPushTag(dec); - if (!TagsEquiv (tag, tblTag)) - { - /* - * Whoops! The expected tags do not completely fit! So what to do? - * - * This is a complicated situation since might have already read some - * tags from the buffer (and pushed), but now we should return failure - * AND REWIND TO THE STATE WE WERE IN WHEN CALLED, - * so that future PeekTag and then TblDecodeTagsAndLens calls start - * off there again! - * - * The idea is to modify PeekTag and this routine to first check - * whether there is information pending that was read already. - * - * Luckily, this can not happen recursively, only in sequence: - * ... -> ... - * ... -> Tags fit -> Tags fit -> ... - * ... -> Tags fit -> Tags fit -> ... - * Tags fit -> ... - * Tags don't fit -< - * Tags don't fit -< - * Complete subtype decoding remaining tags in simple manner - * <- - * Tags don't fit -< - * Tags fit -> ... - * Complete subtype decoding remaining tags in simple manner - * <- - * ... - */ - fullMatch = FALSE; - dec->rewindsize = origRewindsize + dec->nTlStk - origTLG; - TDEWARNNOMATCH(dec,type,tblTag->encTag,tag); - break; - } - } - if (fullMatch) - dec->rewindsize = 0; - return fullMatch; -} - -void -TDEPopTagsAndLens PARAMS ((dec, bytesDecoded, type, implicit), - TDEDecoder dec _AND_ - unsigned long int *bytesDecoded _AND_ - TBLType *type _AND_ - int implicit) -{ - TBLTag *tblTag; - if (dec->rewindsize) - TDEERRORMSG(dec,"Still rewinding at end of tag"); - FOR_EACH_LIST_ELMT_RVS (tblTag, type->tagList) - { - if (implicit && (tblTag == FIRST_LIST_ELMT (type->tagList))) - break; - TDEPopTag(dec,bytesDecoded); - } -} - -int -TDETagsMatch PARAMS ((type, asnTag), - TBLType *type _AND_ - AsnTag asnTag) -{ - TBLType *tmpTblT; - TBLType *elmtTblT; - TBLTag *tblTag; - void *tmp; - - /* - * skip through type refs until encounter first tag or - * untagged CHOICE (only TYPEREFs and CHOICEs can - * have empty tag lists). - */ - for (tmpTblT = type; ((tmpTblT->typeId == TBL_TYPEREF) && - ((tmpTblT->tagList == NULL) || LIST_EMPTY (tmpTblT->tagList))); - ) - tmpTblT = tmpTblT->content->a.typeRef->typeDefPtr->type; - - /* - * if untagged CHOICE must check for a match with the first tag - * of each component of the CHOICE - */ - if ((tmpTblT->typeId == TBL_CHOICE) && - ((tmpTblT->tagList == NULL) || LIST_EMPTY (tmpTblT->tagList))) - { - tmp = CURR_LIST_NODE (tmpTblT->content->a.elmts); - FOR_EACH_LIST_ELMT (elmtTblT, tmpTblT->content->a.elmts) - { - /* - * remember the elmt type can be an untagged choice too - * so call TagsMatch again. - */ - if (TagsMatch (elmtTblT, asnTag)) - { - SET_CURR_LIST_NODE (tmpTblT->content->a.elmts, tmp); - return TRUE; /* match in choice */ - } - } - SET_CURR_LIST_NODE (tmpTblT->content->a.elmts, tmp); - return FALSE; /* no match in choice */ - } - else /* is type other than untagged choice or type ref */ - { - int result; - tblTag = FIRST_LIST_ELMT (tmpTblT->tagList); - result = TagsEquiv (asnTag, tblTag); - return result; - } -} - -int -TDEDecodeType PARAMS ((dec, bytesDecoded, type, implicit, constraint), - TDEDecoder dec _AND_ - unsigned long int *bytesDecoded _AND_ - TBLType *type _AND_ - int implicit _AND_ - TBLRange* constraint) -{ - AVal *elmtVPtr; - unsigned long int tmpBytesDecoded = 0; - unsigned int currElmt; - TBLType *elmtType; - AVal *retVal = NULL; - AVal *eleVal; - AVal **tmpHndl; - AsnTag asnTag; - int i, mandatoryCount, mandatoryElmts; - int implicitRef; - void *tmp; - AsnInt value; - char* constraintmsg = NULL; - int elmtfound; - int indefinite; - - if (!TDEPushTagsAndLens (dec, type, implicit)) - return FALSE; - -#if TTBL>1 - if (!constraint) - constraint = type->constraint; -#endif - - TDETYPE(dec,type,NULL,1); - - switch (type->typeId) - { - case TBL_TYPEREF: - /* - * carry over implicit ref if goes - * through typeref with no tags - */ - implicitRef = type->content->a.typeRef->implicit || - (implicit && - ((type->tagList == NULL) || LIST_EMPTY (type->tagList))); - - if (!TDEDecodeType (dec, &tmpBytesDecoded, - type->content->a.typeRef->typeDefPtr->type, - implicitRef, constraint)) - { - TDEWARNUNEXPECTED(dec,type,type->content->a.typeRef->typeDefPtr->type); - TDESimpleDecode(dec, &tmpBytesDecoded); - } - break; - - case TBL_SEQUENCE: - /* go fwd though elmt type list */ - tmp = CURR_LIST_NODE (type->content->a.elmts); - FOR_EACH_LIST_ELMT (elmtType, type->content->a.elmts) - { - elmtfound = FALSE; - while (!elmtfound - && TDEInTag(dec,tmpBytesDecoded) - && TDETagsMatch (elmtType, TDEPeekTag (dec))) - elmtfound = TDEDecodeType (dec,&tmpBytesDecoded, - elmtType, FALSE, NULL); - if (!elmtfound && !elmtType->optional) - TDEWARNNONOPTIONAL(dec,type,elmtType); - } - SET_CURR_LIST_NODE (type->content->a.elmts, tmp); - - /* process remaining stuff in sequence */ - while (TDEInTag(dec,tmpBytesDecoded)) - { - TDEWARNUNEXPECTED(dec,type,NULL); - TDESimpleDecode(dec, &tmpBytesDecoded); - } - break; - - case TBL_SET: - mandatoryCount = 0; - mandatoryElmts = TDECountMandatoryElmts (type); - while (TDEInTag(dec,tmpBytesDecoded)) - { - asnTag = TDEPeekTag (dec); - elmtfound = FALSE; - /* find elmt that matches the peeked tag */ - tmp = CURR_LIST_NODE (type->content->a.elmts); - FOR_EACH_LIST_ELMT (elmtType, - type->content->a.elmts) - { - if (TDETagsMatch (elmtType, asnTag)) - { - elmtfound = TRUE; - break; - } - } - SET_CURR_LIST_NODE (type->content->a.elmts, tmp); - - /* didn't find a match */ - if (!elmtfound || !TDEDecodeType (dec, &tmpBytesDecoded, - elmtType, FALSE, NULL)) - { - TDEWARNUNEXPECTED(dec,type,elmtfound?elmtType:NULL); - TDESimpleDecode(dec, &tmpBytesDecoded); - } - else - { - if (!elmtType->optional) - mandatoryCount++; - } - - } - if (mandatoryCount != mandatoryElmts) - TDEWARNMANDATORY(dec,type); - break; - - - case TBL_SEQUENCEOF: - case TBL_SETOF: - elmtType = FIRST_LIST_ELMT (type->content->a.elmts); - constraintmsg = "Size of SEQUENCE/SET OF"; - value = 0; - - while (TDEInTag(dec,tmpBytesDecoded)) - { - if (!TDEDecodeType (dec, &tmpBytesDecoded, elmtType, - FALSE,NULL)) - { - TDEWARNUNEXPECTED(dec,type,elmtType); - TDESimpleDecode(dec, &tmpBytesDecoded); - } - else - value++; - } - break; - - case TBL_CHOICE: - elmtfound = FALSE; - if (TDEInTag(dec,tmpBytesDecoded)) - { - asnTag = TDEPeekTag (dec); - /* find elmt that matches the peeked tag */ - tmp = CURR_LIST_NODE (type->content->a.elmts); - FOR_EACH_LIST_ELMT (elmtType, type->content->a.elmts) - { - if (TDETagsMatch (elmtType, asnTag)) - { - elmtfound = TRUE; - break; - } - } - } - SET_CURR_LIST_NODE (type->content->a.elmts, tmp); - if (!elmtfound || !TDEDecodeType (dec, &tmpBytesDecoded, - elmtType, FALSE, NULL)) - { - TDEWARNUNEXPECTED(dec,type,elmtfound?elmtType:NULL); - TDESimpleDecode(dec, &tmpBytesDecoded); - } - break; - - case TBL_BOOLEAN: - retVal = Asn1Alloc (sizeof (AsnBool)); - BDecAsnBoolContent (dec->b, LAST_TAG(), LAST_LEN(), - (AsnBool*) retVal, &tmpBytesDecoded, dec->env); - break; - - case TBL_INTEGER: - case TBL_ENUMERATED: - retVal = Asn1Alloc (sizeof (AsnInt)); - BDecAsnIntContent (dec->b, LAST_TAG(), LAST_LEN(), - (AsnInt*) retVal, &tmpBytesDecoded, dec->env); - constraintmsg = "INTEGER/ENUMERATED"; - value = *(AsnInt*)retVal; - break; - - case TBL_BITSTRING: - retVal = Asn1Alloc (sizeof (AsnBits)); - BDecAsnBitsContent (dec->b, LAST_TAG(), LAST_LEN(), - (AsnBits*) retVal, &tmpBytesDecoded, dec->env); - break; - - case TBL_OCTETSTRING: - retVal = Asn1Alloc (sizeof (AsnOcts)); - BDecAsnOctsContent (dec->b, LAST_TAG(), LAST_LEN(), - (AsnOcts*) retVal, &tmpBytesDecoded, dec->env); - constraintmsg = "Length of OCTET STRING"; - value = ((AsnOcts*)retVal)->octetLen; - break; - - case TBL_NULL: - retVal = Asn1Alloc (sizeof (AsnNull)); - BDecAsnNullContent (dec->b, LAST_TAG(), LAST_LEN(), - (AsnNull*) retVal, &tmpBytesDecoded, dec->env); - break; - - case TBL_OID: - retVal = Asn1Alloc (sizeof (AsnOid)); - BDecAsnOidContent (dec->b, LAST_TAG(), LAST_LEN(), - (AsnOid*) retVal, &tmpBytesDecoded, dec->env); - break; - - case TBL_REAL: - retVal = Asn1Alloc (sizeof (AsnReal)); - BDecAsnRealContent (dec->b, LAST_TAG(), LAST_LEN(), - (AsnReal*) retVal, &tmpBytesDecoded, dec->env); - break; - - default: - retVal = NULL; - break; - } - - TDETYPE(dec,type,retVal,0); - if (retVal) - Asn1Free(retVal); - - if (constraintmsg) - TDECheckConstraint(dec,type,constraint,value); - - TDEPopTagsAndLens (dec, &tmpBytesDecoded, type, implicit); - (*bytesDecoded) += tmpBytesDecoded; - return TRUE; -} - -int -TDEDecodeSpecific PARAMS ((dec, bytesDecoded, type), - TDEDecoder dec _AND_ - unsigned long int *bytesDecoded _AND_ - TBLType* type) -{ - int val; - - *bytesDecoded = 0; - dec->rewindsize = 0; - dec->nTlStk = 0; - - if ((val = setjmp (dec->env)) == 0) - { - TDEDecodeType (dec, bytesDecoded, type, FALSE, NULL); - return TRUE; - } - return FALSE; -} - -int -TDEDecodeUnknown PARAMS ((dec, bytesDecoded), - TDEDecoder dec _AND_ - unsigned long int *bytesDecoded) -{ - TBLModule *tblMod = NULL; - TBLTypeDef *tblTd = NULL; - - *bytesDecoded = 0; - - FOR_EACH_LIST_ELMT (tblMod, dec->tbl->modules) - break; - if (!tblMod) - { - TDEERRORMSG (dec,"No module in grammar"); - return FALSE; - } - - FOR_EACH_LIST_ELMT_RVS (tblTd, tblMod->typeDefs) - break; - if (!tblTd) - { - TDEERRORMSG (dec,"No type in first module of grammar"); - return FALSE; - } - - return TDEDecodeSpecific (dec, bytesDecoded, tblTd->type); -} - -struct STDEDecoder sdec; - -void -TDEErrorHandler PARAMS ((str, severity), - char* str _AND_ - int severity) -{ - TDEERRORMSG(&sdec,str); -} - -int -TdeDecodeSpecific PARAMS ((tbl, b, type, bytesDecoded, typeproc, simpleproc, excproc), - TBL *tbl _AND_ - BUF_TYPE b _AND_ - TBLType* type _AND_ - unsigned long int *bytesDecoded _AND_ - TdeTypeProc typeproc _AND_ - TdeSimpleProc simpleproc _AND_ - TdeExcProc excproc) -{ - int result; - Asn1ErrorHandler former = Asn1InstallErrorHandler(TDEErrorHandler); - sdec.tbl = tbl; - sdec.b = b; - sdec.typeproc = typeproc; - sdec.simpleproc = simpleproc; - sdec.excproc = excproc; - result = TDEDecodeSpecific(&sdec,bytesDecoded,type); - Asn1InstallErrorHandler(former); - return result; -} - -int -TdeDecode PARAMS ((tbl, b, bytesDecoded, typeproc, simpleproc, excproc), - TBL *tbl _AND_ - BUF_TYPE b _AND_ - unsigned long int *bytesDecoded _AND_ - TdeTypeProc typeproc _AND_ - TdeSimpleProc simpleproc _AND_ - TdeExcProc excproc) -{ - int result; - Asn1ErrorHandler former = Asn1InstallErrorHandler(TDEErrorHandler); - sdec.tbl = tbl; - sdec.b = b; - sdec.typeproc = typeproc; - sdec.simpleproc = simpleproc; - sdec.excproc = excproc; - result = TDEDecodeUnknown(&sdec,bytesDecoded); - Asn1InstallErrorHandler(former); - return result; -} -#endif diff --git a/SecuritySNACCRuntime/c-lib/src/tbl-print.c b/SecuritySNACCRuntime/c-lib/src/tbl-print.c deleted file mode 100644 index 128f3d29..00000000 --- a/SecuritySNACCRuntime/c-lib/src/tbl-print.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#ifdef TTBL - -/* - * tbl_print.c - type table value printer - * - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - */ - - -#include -#include "tbl-incl.h" - -static int indentIncrG = 2; - -/* - * Print value v to file f as though it is of type modName.typeName in - * table tbl. - */ -void -TblPrintValue PARAMS ((tbl, modName, typeName, f, v), - TBL *tbl _AND_ - char *modName _AND_ - char *typeName _AND_ - FILE *f _AND_ - AVal *v) -{ - TBLTypeDef *tblTd; - TBLModule *tblMod; - - tblTd = TblFindTypeDef (tbl, modName, typeName, &tblMod); - - if (tblTd == NULL) - { - TblError ("TblEncode: Could not find a type definition with the given module and name"); - } - else - { - fprintf (f, "value %s.%s ::= \n", tblMod->name.octs, typeName); - TblPrintTypeValue (tblTd->type, f, v, 0); - } - -} /* TblPrint */ - -/* - * starts using indent after first newline printed by this routine - */ -void -TblPrintTypeValue PARAMS ((tblT, f, v, indent), - TBLType *tblT _AND_ - FILE *f _AND_ - AVal *v _AND_ - unsigned short int indent) -{ - AVal *elmtV; - AsnList *lVal; - unsigned int currElmt; - TBLType *listElmtType; - TBLType *structElmtType; - TBLType *choiceElmtType; - AChoiceVal *cVal; - AStructVal *sVal; - void *tmp; - - switch (tblT->typeId) - { - case TBL_TYPEREF: - TblPrintTypeValue (tblT->content->a.typeRef->typeDefPtr->type, f, v, indent); - break; - - case TBL_SEQUENCE: - case TBL_SET: - fprintf (f,"{\n"); - currElmt = 0; - sVal = (AStructVal*)v; - tmp = CURR_LIST_NODE (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT (structElmtType, tblT->content->a.elmts) - { - Indent (f, indent+indentIncrG); - elmtV = sVal[currElmt++]; - if (!(structElmtType->optional && (elmtV == NULL))) - { - if (structElmtType->fieldName.octs != NULL) - fprintf (f,"%s ", structElmtType->fieldName.octs); - - TblPrintTypeValue (structElmtType, f, elmtV, indent+indentIncrG); - - if (structElmtType != LAST_LIST_ELMT (tblT->content->a.elmts)) - fprintf (f,",\n"); - else - fprintf (f,"\n"); - } - } - /* restore list curr in case recursive type */ - SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); - Indent (f,indent); - fprintf (f,"}"); - break; - - case TBL_SEQUENCEOF: - case TBL_SETOF: - fprintf (f,"{\n"); - lVal = (AsnList*)v; - listElmtType = FIRST_LIST_ELMT (tblT->content->a.elmts); - tmp = CURR_LIST_NODE (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT (elmtV, lVal) - { - Indent (f, indent+indentIncrG); - TblPrintTypeValue (listElmtType, f, elmtV, indent+indentIncrG); - if (elmtV != LAST_LIST_ELMT (lVal)) - fprintf (f,",\n"); - else - fprintf (f,"\n"); - } - /* restore old list curr ptr */ - SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); - Indent (f,indent); - fprintf (f,"}"); - break; - - case TBL_CHOICE: - cVal = (AChoiceVal*) v; - choiceElmtType = (TBLType*)GetAsnListElmt (tblT->content->a.elmts, cVal->choiceId); - if (choiceElmtType->fieldName.octs != NULL) - fprintf (f,"%s ", choiceElmtType->fieldName.octs); - TblPrintTypeValue (choiceElmtType, f, cVal->val, indent+indentIncrG); - break; - - case TBL_BOOLEAN: - PrintAsnBool (f, (AsnBool*)v,indent); - break; - - case TBL_INTEGER: - case TBL_ENUMERATED: - PrintAsnInt (f, (AsnInt*)v, indent); - break; - - case TBL_BITSTRING: - PrintAsnBits (f, (AsnBits*)v, indent); - break; - - case TBL_OCTETSTRING: - PrintAsnOcts (f, (AsnOcts*)v, indent); - break; - - case TBL_NULL: - PrintAsnNull (f, (AsnNull*)v, indent); - break; - - case TBL_OID: - PrintAsnOid (f, (AsnOid*)v, indent); - break; - - case TBL_REAL: - PrintAsnReal (f, (AsnReal*)v, indent); - break; - - default: - fprintf (f, ""); - } - -} /* TblPrintTypeValue */ - -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/src/tbl-util.c b/SecuritySNACCRuntime/c-lib/src/tbl-util.c deleted file mode 100644 index 512ff5ca..00000000 --- a/SecuritySNACCRuntime/c-lib/src/tbl-util.c +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#ifdef TTBL - -/* - * tbl_util.c - type table utilities. - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * This library is free software; you can redistribute it and/or - * modify it provided that this copyright/license information is retained - * in original form. - * - * If you modify this file, you must clearly indicate your changes. - * - * This source code 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. - */ - - -#include -#include "tbl-incl.h" -#include "sbuf.h" - -/* non -exported routine protos */ -void TblLinkIndexes PROTO ((TBL *tbl)); -void TblLinkTypeRefs PROTO ((TBL *tbl, TBLType *tblT)); - -void TblFixTags PROTO ((TBL *tbl)); -void TblFixTypeTags PROTO ((TBLType *tblT)); -void TblSetTagForms PROTO ((TBLType *t)); - - -/* - * opens given filename, determines its size, allocs a block - * of that size and reads the file into it. returns a pointer - * to this block. Prints an err msgs is something screwed up - * and returns NULL. Sets the size param to the size of the file. - */ -char* -LoadFile PARAMS ((fileName, size), - char *fileName _AND_ - unsigned long int *size) -{ - FILE *f; - unsigned long int fsize; - char *fileData; - - f = fopen (fileName, "r"); - - if (f == NULL) - { - Asn1Error("Could not open file for reading.\n"); - return NULL; - } - - fseek (f, 0, 2); /* seek to end */ - fsize = ftell (f); /* get size of file */ - fseek (f, 0, 0); /* seek to beginning */ - - *size = fsize; - fileData = (char *) malloc (fsize); - - if (fileData == NULL) - { - Asn1Error("Not enough memory to read in file.\n"); - return NULL; - } - - if (fread (fileData, sizeof (char), fsize, f) != fsize) - { - free (fileData); - fileData = NULL; - Asn1Error("Trouble reading file.\n"); - } - - fclose (f); - return fileData; -} /* LoadFile */ - - -TBL* -LoadTblFile PARAMS ((tblFileName), - char *tblFileName) -{ - SBuf sb; - SBuf *sbPtr; - GenBuf gb; - TBL *tbl; - unsigned long int fsize; - char *fileData; - AsnLen decodedLen; - ENV_TYPE env; - int val; - - - fileData = LoadFile (tblFileName, &fsize); - if (fileData == NULL) - return NULL; - - SBufInstallData (&sb, fileData, fsize); - SBufResetInReadMode (&sb); - PutSBufInGenBuf (&sb, &gb); - - decodedLen = 0; - - tbl = (TBL*)Asn1Alloc (sizeof (TBL)); - - if ((val = setjmp (env)) == 0) - BDecTBL (&gb, tbl, &decodedLen, env); - else - return NULL; - - /* convert the typeDefIndexes into real pointers */ - TblLinkIndexes (tbl); - - TblFixTags (tbl); - - free (fileData); /* malloc'd in LoadFile */ - - return tbl; -} - - -/* - * just use slow individual lookup instead of creating a table - * (a conversion tbl could be built during decoding) - */ -void -TblLinkIndexes PARAMS ((tbl), - TBL *tbl) -{ - TBLModule *tblMod; - TBLTypeDef *tblTd; - - FOR_EACH_LIST_ELMT (tblMod, tbl->modules) - { - FOR_EACH_LIST_ELMT (tblTd, tblMod->typeDefs) - { - /* go through the types looking for TBLTypeRefs */ - TblLinkTypeRefs (tbl, tblTd->type); - } - } -} /* TBLLinkIndexes */ - - -/* - * set tags forms and include encoded version to improve - * decoding and encoding performance. - */ -void -TblFixTags PARAMS ((tbl), - TBL *tbl) -{ - TBLModule *tblMod; - TBLTypeDef *tblTd; - - FOR_EACH_LIST_ELMT (tblMod, tbl->modules) - { - FOR_EACH_LIST_ELMT (tblTd, tblMod->typeDefs) - { - TblFixTypeTags (tblTd->type); - } - } -} /* TBLFixTags */ - - - -/* - * recursively descends type looking for typeDefIds in type refs - * to convert to the type defs actual ptr - * - * Also sets the form field for each tag. (this speeds up enc/dec). - * Note that the form bit is not in the encoded version of a TBLTag. - */ -void -TblLinkTypeRefs PARAMS ((tbl, tblT), - TBL *tbl _AND_ - TBLType *tblT) -{ - TBLType *tblElmtT; - void *tmp; - - switch (tblT->typeId) - { - case TBL_BOOLEAN: - case TBL_INTEGER: - case TBL_BITSTRING: - case TBL_OCTETSTRING: - case TBL_NULL: - case TBL_OID: - case TBL_REAL: - case TBL_ENUMERATED: - /* not contained type refs so return */ - break; - - case TBL_SEQUENCE: - case TBL_SET: - case TBL_SEQUENCEOF: - case TBL_SETOF: - case TBL_CHOICE: - /* look for contained type refs */ - tmp = CURR_LIST_NODE (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT (tblElmtT, tblT->content->a.elmts) - { - TblLinkTypeRefs (tbl, tblElmtT); - } - SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); - break; - - case TBL_TYPEREF: - /* convert type def index into a pointer to the type def */ - tblT->content->a.typeRef->typeDefPtr = - TblFindTypeDefByIndex (tbl, tblT->content->a.typeRef->typeDef); - break; - } -} /* TblLinkTypeRefs */ -void -TblFixTypeTags PARAMS ((tblT), - TBLType *tblT) -{ - void *tmp; - TBLType *tblElmtT; - - TblSetTagForms (tblT); - switch (tblT->typeId) - { - case TBL_SEQUENCE: - case TBL_SET: - case TBL_SEQUENCEOF: - case TBL_SETOF: - case TBL_CHOICE: - /* fix tags in elmt types */ - tmp = CURR_LIST_NODE (tblT->content->a.elmts); - FOR_EACH_LIST_ELMT (tblElmtT, tblT->content->a.elmts) - { - TblFixTypeTags (tblElmtT); - } - SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); - break; - - default: - break; - } -} - -void -TblSetTagForms PARAMS ((tblT), - TBLType *tblT) -{ - TBLTag *tblTag; - TBLType *tmpTblT; - int numTags; - TBLTypeId tid; - BER_FORM form; - - if (tblT->tagList == NULL) - return; - - numTags = LIST_COUNT (tblT->tagList); - - /* - * get real type id (skip through type refs) - * count total number of tags too. - */ - for (tmpTblT = tblT; tmpTblT->typeId == TBL_TYPEREF; tmpTblT = tmpTblT->content->a.typeRef->typeDefPtr->type) - { - if (tmpTblT->tagList) - numTags += LIST_COUNT (tmpTblT->tagList); - if (tmpTblT->content->a.typeRef->implicit) - numTags--; - } - tid = tmpTblT->typeId; - - /* only traverse this types tags */ - FOR_EACH_LIST_ELMT (tblTag, tblT->tagList) - { - if (numTags > 1) - form = tblTag->form = CONS; - else - switch (tid) - { - case TBL_SEQUENCE: - case TBL_SET: - case TBL_SEQUENCEOF: - case TBL_SETOF: - case TBL_CHOICE: - form = tblTag->form = CONS; - break; - - case TBL_OCTETSTRING: - case TBL_BITSTRING: - tblTag->form = ANY_FORM; - form = PRIM; /* store as prim (for encoder - always prim) */ - break; - - default: - form = tblTag->form = PRIM; - break; - } - - tblTag->encTag = MAKE_TAG_ID (TblTagClassToBer (tblTag->tclass), form, tblTag->code); - numTags--; - } -} /* TblSetTagForms */ - - - -TBLTypeDef* -TblFindTypeDef PARAMS ((tbl, modName, typeName, tblModHndl), - TBL *tbl _AND_ - char *modName _AND_ - char *typeName _AND_ - TBLModule **tblModHndl) -{ - TBLModule *tblMod; - TBLTypeDef *tblTd; - void *tmp; - - /* look in named module only if given */ - if (modName != NULL) - { - tblMod = TblFindModule (tbl, modName); - *tblModHndl = tblMod; - if (tblMod == NULL) - return NULL; - - return TblFindTypeDefInMod (tblMod, typeName); - } - else /* look in all modules and return first instance */ - { - tmp = CURR_LIST_NODE (tbl->modules); - FOR_EACH_LIST_ELMT (tblMod, tbl->modules) - { - tblTd = TblFindTypeDefInMod (tblMod, typeName); - if (tblTd != NULL) - { - *tblModHndl = tblMod; - SET_CURR_LIST_NODE (tbl->modules, tmp); - return tblTd; - } - } - SET_CURR_LIST_NODE (tbl->modules, tmp); - } - return NULL; /* not found */ -} /* TblFindTypeDef */ - - -TBLTypeDef* -TblFindTypeDefInMod PARAMS ((tblMod, typeName), - TBLModule *tblMod _AND_ - char *typeName) -{ - TBLTypeDef *tblTd; - void *tmp; - - tmp = CURR_LIST_NODE (tblMod->typeDefs); - FOR_EACH_LIST_ELMT (tblTd, tblMod->typeDefs) - { - if (strcmp (tblTd->typeName.octs, typeName) == 0) - { - SET_CURR_LIST_NODE (tblMod->typeDefs, tmp); - return tblTd; - } - } - SET_CURR_LIST_NODE (tblMod->typeDefs, tmp); - return NULL; -} /* TblFindTypeDefInMod */ - - -TBLTypeDef* -TblFindTypeDefByIndex PARAMS ((tbl, id), - TBL *tbl _AND_ - TBLTypeDefId id) -{ - TBLModule *tblMod; - TBLTypeDef *tblTd; - void *tmp1; - void *tmp2; - - /* look in all modules and return typedef with given id */ - tmp1 = CURR_LIST_NODE (tbl->modules); - FOR_EACH_LIST_ELMT (tblMod, tbl->modules) - { - tmp2 = CURR_LIST_NODE (tblMod->typeDefs); - FOR_EACH_LIST_ELMT (tblTd, tblMod->typeDefs) - { - if (tblTd->typeDefId == id) - { - SET_CURR_LIST_NODE (tblMod->typeDefs, tmp2); - SET_CURR_LIST_NODE (tbl->modules, tmp1); - return tblTd; - } - } - SET_CURR_LIST_NODE (tblMod->typeDefs, tmp2); - } - SET_CURR_LIST_NODE (tbl->modules, tmp1); - - return NULL; -} /* TblFindTypeDefByIndex */ - - -TBLModule* -TblFindModule PARAMS ((tbl, modName), - TBL *tbl _AND_ - char *modName) -{ - TBLModule *tblMod; - void *tmp; - - tmp = CURR_LIST_NODE (tbl->modules); - FOR_EACH_LIST_ELMT (tblMod, tbl->modules) - { - if (strcmp (tblMod->name.octs, modName) == 0) - { - SET_CURR_LIST_NODE (tbl->modules, tmp); - return tblMod; - } - } - SET_CURR_LIST_NODE (tbl->modules, tmp); - return NULL; - -} /* TblFindModule */ - -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/src/tbl.c b/SecuritySNACCRuntime/c-lib/src/tbl.c deleted file mode 100644 index 957e98bb..00000000 --- a/SecuritySNACCRuntime/c-lib/src/tbl.c +++ /dev/null @@ -1,2119 +0,0 @@ -#if TTBL -/* - * tbl.c - * - * "TBL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Tue Mar 19 07:24:47 2002 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "tbl.h" - - -AsnLen -BEncTBLRangeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLRange *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->to)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->from)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLRangeContent */ - -void -BDecTBLRangeContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLRange *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->from), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -100); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->to), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -101); - } - else - longjmp (env, -102); - - - if (!seqDone) - longjmp (env, -103); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLRangeContent */ - -void -PrintTBLRange PARAMS ((f, v, indent), -FILE* f _AND_ -TBLRange *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"from "); - PrintAsnInt (f, (&v->from), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"to "); - PrintAsnInt (f, (&v->to), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLRange */ - -void -FreeTBLRange PARAMS ((v), -TBLRange *v) -{ - - if (v == NULL) - return; - FreeAsnInt ((&v->from)); - - FreeAsnInt ((&v->to)); - -} /* FreeTBLRange */ - - - - -AsnLen -BEncTBLNamedNumberContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumber *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->value)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLNamedNumberContent */ - -void -BDecTBLNamedNumberContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLNamedNumber *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->name), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -104); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->value), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -105); - } - else - longjmp (env, -106); - - - if (!seqDone) - longjmp (env, -107); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLNamedNumberContent */ - -void -PrintTBLNamedNumber PARAMS ((f, v, indent), -FILE* f _AND_ -TBLNamedNumber *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"name "); - PrintPrintableString (f, (&v->name), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"value "); - PrintAsnInt (f, (&v->value), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLNamedNumber */ - -void -FreeTBLNamedNumber PARAMS ((v), -TBLNamedNumber *v) -{ - - if (v == NULL) - return; - FreePrintableString ((&v->name)); - - FreeAsnInt ((&v->value)); - -} /* FreeTBLNamedNumber */ - - - - -AsnLen -BEncTBLNamedNumberListContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumberList *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLNamedNumberListContent */ - -void -BDecTBLNamedNumberListContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLNamedNumberList *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLNamedNumber **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLNamedNumber**) AsnListAppend (v); - (*tmpVar) = (TBLNamedNumber*) Asn1Alloc (sizeof (TBLNamedNumber)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLNamedNumberContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -108); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLNamedNumberListContent */ - -void -PrintTBLNamedNumberList PARAMS ((f, v, indent), -FILE* f _AND_ -TBLNamedNumberList *v _AND_ -unsigned short int indent) -{ - TBLNamedNumber *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLNamedNumber (f, tmp, indent + stdIndentG); - if (tmp != (TBLNamedNumber*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLNamedNumberList */ - -void -FreeTBLNamedNumberList PARAMS ((v), -TBLNamedNumberList *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLNamedNumber ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLNamedNumberList */ - - - - -AsnLen -BEncTBLTypeRefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeRef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnBoolContent (b, (&v->implicit)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDef)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeRefContent */ - -void -BDecTBLTypeRefContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeRef *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeDefIdContent (b, tagId1, elmtLen1, (&v->typeDef), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -109); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->implicit), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -110); - } - else - longjmp (env, -111); - - - if (!seqDone) - longjmp (env, -112); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeRefContent */ - -void -PrintTBLTypeRef PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeRef *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeDef "); - PrintTBLTypeDefId (f, (&v->typeDef), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"implicit "); - PrintAsnBool (f, (&v->implicit), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeRef */ - -void -FreeTBLTypeRef PARAMS ((v), -TBLTypeRef *v) -{ - - if (v == NULL) - return; - FreeTBLTypeDefId ((&v->typeDef)); - - FreeAsnBool ((&v->implicit)); - -} /* FreeTBLTypeRef */ - - - - -AsnLen -BEncTBLTagContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTag *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->code)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncTBLTagClassContent (b, (&v->tclass)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 10); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTagContent */ - -void -BDecTBLTagContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTag *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, ENUM_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTagClassContent (b, tagId1, elmtLen1, (&v->tclass), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -113); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->code), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -114); - } - else - longjmp (env, -115); - - - if (!seqDone) - longjmp (env, -116); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTagContent */ - -void -PrintTBLTag PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTag *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"tclass "); - PrintTBLTagClass (f, (&v->tclass), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"code "); - PrintAsnInt (f, (&v->code), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTag */ - -void -FreeTBLTag PARAMS ((v), -TBLTag *v) -{ - - if (v == NULL) - return; - FreeTBLTagClass ((&v->tclass)); - - FreeAsnInt ((&v->code)); - -} /* FreeTBLTag */ - - - - -AsnLen -BEncTBLTypeSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTagContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeSeqOfContent */ - -void -BDecTBLTypeSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLTag **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLTag**) AsnListAppend (v); - (*tmpVar) = (TBLTag*) Asn1Alloc (sizeof (TBLTag)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTagContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -117); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeSeqOfContent */ - -void -PrintTBLTypeSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeSeqOf *v _AND_ -unsigned short int indent) -{ - TBLTag *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLTag (f, tmp, indent + stdIndentG); - if (tmp != (TBLTag*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeSeqOf */ - -void -FreeTBLTypeSeqOf PARAMS ((v), -TBLTypeSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLTag ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLTypeSeqOf */ - - - - -AsnLen -BEncTBLTypeContentSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContentSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeContentSeqOfContent */ - -void -BDecTBLTypeContentSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeContentSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLType **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLType**) AsnListAppend (v); - (*tmpVar) = (TBLType*) Asn1Alloc (sizeof (TBLType)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTypeContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -118); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContentSeqOfContent */ - -void -PrintTBLTypeContentSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeContentSeqOf *v _AND_ -unsigned short int indent) -{ - TBLType *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLType (f, tmp, indent + stdIndentG); - if (tmp != (TBLType*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeContentSeqOf */ - -void -FreeTBLTypeContentSeqOf PARAMS ((v), -TBLTypeContentSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLType ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLTypeContentSeqOf */ - - - - -AsnLen -BEncTBLTypeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLType *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->values))) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberListContent (b, (v->values)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 6); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->constraint))) - { - BEncEocIfNec (b); - itemLen = BEncTBLRangeContent (b, (v->constraint)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 5); - - totalLen += itemLen; - } - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - itemLen = BEncPrintableStringContent (b, (&v->fieldName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 4); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentContent (b, (v->content)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - if (NOT_NULL ((v->tagList))) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeSeqOfContent (b, (v->tagList)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - } - - itemLen = BEncAsnBoolContent (b, (&v->optional)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeIdContent (b, (&v->typeId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeContent */ - -void -BDecTBLTypeContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLType *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - AsnLen totalElmtsLen3 = 0; - AsnLen elmtLen3; - AsnTag tagId3; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeIdContent (b, tagId1, elmtLen1, (&v->typeId), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -119); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->optional), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -120); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->tagList) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->tagList), env); - BDecTBLTypeSeqOfContent (b, tagId1, elmtLen1, (v->tagList), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->content) = (TBLTypeContent*) Asn1Alloc (sizeof (TBLTypeContent)); - CheckAsn1Alloc ((v->content), env); - tagId2 = BDecTag (b, &totalElmtsLen1, env); - elmtLen2 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeContentContent (b, tagId2, elmtLen2, (v->content), &totalElmtsLen1, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc(b, &totalElmtsLen1, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - else - longjmp (env, -121); - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 4)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 4)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->fieldName), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 5)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->constraint) = (TBLRange*) Asn1Alloc (sizeof (TBLRange)); - CheckAsn1Alloc ((v->constraint), env); - BDecTBLRangeContent (b, tagId1, elmtLen1, (v->constraint), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 6)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->values) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->values), env); - BDecTBLNamedNumberListContent (b, tagId1, elmtLen1, (v->values), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -122); - } - - - if (!seqDone) - longjmp (env, -123); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContent */ - -void -PrintTBLType PARAMS ((f, v, indent), -FILE* f _AND_ -TBLType *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeId "); - PrintTBLTypeId (f, (&v->typeId), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"optional "); - PrintAsnBool (f, (&v->optional), indent + stdIndentG); - fprintf (f, ",\n"); - if (NOT_NULL ((v->tagList))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"tagList "); - PrintTBLTypeSeqOf (f, (v->tagList), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"content "); - PrintTBLTypeContent (f, (v->content), indent + stdIndentG); - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"fieldName "); - PrintPrintableString (f, (&v->fieldName), indent + stdIndentG); - } - if (NOT_NULL ((v->constraint))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"constraint "); - PrintTBLRange (f, (v->constraint), indent + stdIndentG); - } - if (NOT_NULL ((v->values))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"values "); - PrintTBLNamedNumberList (f, (v->values), indent + stdIndentG); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLType */ - -void -FreeTBLType PARAMS ((v), -TBLType *v) -{ - - if (v == NULL) - return; - FreeTBLTypeId ((&v->typeId)); - - FreeAsnBool ((&v->optional)); - - if (NOT_NULL ((v->tagList))) - { - FreeTBLTypeSeqOf ((v->tagList)); - Asn1Free ((v->tagList)); - } - - FreeTBLTypeContent ((v->content)); - Asn1Free ((v->content)); - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - FreePrintableString ((&v->fieldName)); - } - - if (NOT_NULL ((v->constraint))) - { - FreeTBLRange ((v->constraint)); - Asn1Free ((v->constraint)); - } - - if (NOT_NULL ((v->values))) - { - FreeTBLNamedNumberList ((v->values)); - Asn1Free ((v->values)); - } - -} /* FreeTBLType */ - - - - -AsnLen -BEncTBLTypeContentContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContent *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - itemLen = BEncAsnNullContent (b, (&v->a.primType)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_ELMTS: - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentSeqOfContent (b, (v->a.elmts)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 1); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_TYPEREF: - BEncEocIfNec (b); - itemLen = BEncTBLTypeRefContent (b, (v->a.typeRef)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncTBLTypeContentContent */ - -void -BDecTBLTypeContentContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeContent *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - switch (tagId0) - { - case MAKE_TAG_ID (CNTX, PRIM, 0): - (v->choiceId) = TBLTYPECONTENT_PRIMTYPE; - BDecAsnNullContent (b, tagId0, elmtLen0, (&v->a.primType), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - (v->choiceId) = TBLTYPECONTENT_ELMTS; - (v->a.elmts) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->a.elmts), env); - BDecTBLTypeContentSeqOfContent (b, tagId0, elmtLen0, (v->a.elmts), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 2): - (v->choiceId) = TBLTYPECONTENT_TYPEREF; - (v->a.typeRef) = (TBLTypeRef*) Asn1Alloc (sizeof (TBLTypeRef)); - CheckAsn1Alloc ((v->a.typeRef), env); - BDecTBLTypeRefContent (b, tagId0, elmtLen0, (v->a.typeRef), &totalElmtsLen1, env); - break; - - default: - Asn1Error ("ERROR - unexpected tag in CHOICE\n"); - longjmp (env, -124); - break; - } /* end switch */ - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContentContent */ - -void -PrintTBLTypeContent PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeContent *v _AND_ -unsigned short int indent) -{ - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - fprintf (f,"primType "); - PrintAsnNull (f, (&v->a.primType), indent + stdIndentG); - break; - - case TBLTYPECONTENT_ELMTS: - fprintf (f,"elmts "); - PrintTBLTypeContentSeqOf (f, (v->a.elmts), indent + stdIndentG); - break; - - case TBLTYPECONTENT_TYPEREF: - fprintf (f,"typeRef "); - PrintTBLTypeRef (f, (v->a.typeRef), indent + stdIndentG); - break; - - } -} /* PrintTBLTypeContent */ - -void -FreeTBLTypeContent PARAMS ((v), -TBLTypeContent *v) -{ - - if (v == NULL) - return; - switch (v->choiceId) - { - case TBLTYPECONTENT_ELMTS: - FreeTBLTypeContentSeqOf ((v->a.elmts)); - Asn1Free ((v->a.elmts)); - - break; - - case TBLTYPECONTENT_TYPEREF: - FreeTBLTypeRef ((v->a.typeRef)); - Asn1Free ((v->a.typeRef)); - - break; - - } -} /* FreeTBLTypeContent */ - - - - -AsnLen -BEncTBLTypeDefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeDef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->isPdu))) - { - itemLen = BEncAsnNullContent (b, (v->isPdu)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 5); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, (v->type)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->typeName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 19); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDefId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeDefContent */ - -void -BDecTBLTypeDefContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeDef *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeDefIdContent (b, tagId1, elmtLen1, (&v->typeDefId), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -125); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) || -(tagId1 == MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->typeName), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -126); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->type) = (TBLType*) Asn1Alloc (sizeof (TBLType)); - CheckAsn1Alloc ((v->type), env); - BDecTBLTypeContent (b, tagId1, elmtLen1, (v->type), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - else - longjmp (env, -127); - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (UNIV, PRIM, NULLTYPE_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->isPdu) = (AsnNull*) Asn1Alloc (sizeof (AsnNull)); - CheckAsn1Alloc ((v->isPdu), env); - BDecAsnNullContent (b, tagId1, elmtLen1, (v->isPdu), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -128); - } - - - if (!seqDone) - longjmp (env, -129); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeDefContent */ - -void -PrintTBLTypeDef PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeDef *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeDefId "); - PrintTBLTypeDefId (f, (&v->typeDefId), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"typeName "); - PrintPrintableString (f, (&v->typeName), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"type "); - PrintTBLType (f, (v->type), indent + stdIndentG); - if (NOT_NULL ((v->isPdu))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"isPdu "); - PrintAsnNull (f, (v->isPdu), indent + stdIndentG); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeDef */ - -void -FreeTBLTypeDef PARAMS ((v), -TBLTypeDef *v) -{ - - if (v == NULL) - return; - FreeTBLTypeDefId ((&v->typeDefId)); - - FreePrintableString ((&v->typeName)); - - FreeTBLType ((v->type)); - Asn1Free ((v->type)); - - if (NOT_NULL ((v->isPdu))) - { - FreeAsnNull ((v->isPdu)); - Asn1Free ((v->isPdu)); - } - -} /* FreeTBLTypeDef */ - - - - -AsnLen -BEncTBLModuleSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModuleSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeDefContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLModuleSeqOfContent */ - -void -BDecTBLModuleSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLModuleSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLTypeDef **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLTypeDef**) AsnListAppend (v); - (*tmpVar) = (TBLTypeDef*) Asn1Alloc (sizeof (TBLTypeDef)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTypeDefContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -130); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLModuleSeqOfContent */ - -void -PrintTBLModuleSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLModuleSeqOf *v _AND_ -unsigned short int indent) -{ - TBLTypeDef *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLTypeDef (f, tmp, indent + stdIndentG); - if (tmp != (TBLTypeDef*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLModuleSeqOf */ - -void -FreeTBLModuleSeqOf PARAMS ((v), -TBLModuleSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLTypeDef ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLModuleSeqOf */ - - - - -AsnLen -BEncTBLModuleContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModule *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLModuleSeqOfContent (b, (v->typeDefs)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - itemLen = BEncAsnBoolContent (b, (&v->isUseful)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - if (ASNOID_PRESENT ((&v->id))) - { - itemLen = BEncAsnOidContent (b, (&v->id)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - } - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLModuleContent */ - -void -BDecTBLModuleContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLModule *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->name), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -131); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnOidContent (b, tagId1, elmtLen1, (&v->id), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->isUseful), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -132); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->typeDefs) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->typeDefs), env); - BDecTBLModuleSeqOfContent (b, tagId1, elmtLen1, (v->typeDefs), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -133); - } - else - longjmp (env, -134); - - - if (!seqDone) - longjmp (env, -135); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLModuleContent */ - -void -PrintTBLModule PARAMS ((f, v, indent), -FILE* f _AND_ -TBLModule *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"name "); - PrintPrintableString (f, (&v->name), indent + stdIndentG); - fprintf (f, ",\n"); - if (ASNOID_PRESENT ((&v->id))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"id "); - PrintAsnOid (f, (&v->id), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"isUseful "); - PrintAsnBool (f, (&v->isUseful), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"typeDefs "); - PrintTBLModuleSeqOf (f, (v->typeDefs), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLModule */ - -void -FreeTBLModule PARAMS ((v), -TBLModule *v) -{ - - if (v == NULL) - return; - FreePrintableString ((&v->name)); - - if (ASNOID_PRESENT ((&v->id))) - { - FreeAsnOid ((&v->id)); - } - - FreeAsnBool ((&v->isUseful)); - - FreeTBLModuleSeqOf ((v->typeDefs)); - Asn1Free ((v->typeDefs)); - -} /* FreeTBLModule */ - - - - -AsnLen -BEncTBLSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLModuleContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLSeqOfContent */ - -void -BDecTBLSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLModule **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLModule**) AsnListAppend (v); - (*tmpVar) = (TBLModule*) Asn1Alloc (sizeof (TBLModule)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLModuleContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -136); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLSeqOfContent */ - -void -PrintTBLSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLSeqOf *v _AND_ -unsigned short int indent) -{ - TBLModule *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLModule (f, tmp, indent + stdIndentG); - if (tmp != (TBLModule*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLSeqOf */ - -void -FreeTBLSeqOf PARAMS ((v), -TBLSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLModule ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLSeqOf */ - - - - -AsnLen BEncTBL PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncTBLContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} /* BEncTBL */ - -void BDecTBL PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -TBL *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error ("BDecTBL: ERROR - wrong tag\n"); - longjmp (env, -137); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecTBLContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecTBL */ - -AsnLen -BEncTBLContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLSeqOfContent (b, (v->modules)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalLenStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTags)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypes)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypeDefs)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumModules)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLContent */ - -void -BDecTBLContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBL *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumModules), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -138); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTypeDefs), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -139); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTypes), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -140); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTags), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -141); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumStrings), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -142); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalLenStrings), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -143); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->modules) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->modules), env); - BDecTBLSeqOfContent (b, tagId1, elmtLen1, (v->modules), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -144); - } - else - longjmp (env, -145); - - - if (!seqDone) - longjmp (env, -146); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLContent */ - -void -PrintTBL PARAMS ((f, v, indent), -FILE* f _AND_ -TBL *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumModules "); - PrintAsnInt (f, (&v->totalNumModules), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTypeDefs "); - PrintAsnInt (f, (&v->totalNumTypeDefs), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTypes "); - PrintAsnInt (f, (&v->totalNumTypes), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTags "); - PrintAsnInt (f, (&v->totalNumTags), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumStrings "); - PrintAsnInt (f, (&v->totalNumStrings), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalLenStrings "); - PrintAsnInt (f, (&v->totalLenStrings), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"modules "); - PrintTBLSeqOf (f, (v->modules), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBL */ - -void -FreeTBL PARAMS ((v), -TBL *v) -{ - - if (v == NULL) - return; - FreeAsnInt ((&v->totalNumModules)); - - FreeAsnInt ((&v->totalNumTypeDefs)); - - FreeAsnInt ((&v->totalNumTypes)); - - FreeAsnInt ((&v->totalNumTags)); - - FreeAsnInt ((&v->totalNumStrings)); - - FreeAsnInt ((&v->totalLenStrings)); - - FreeTBLSeqOf ((v->modules)); - Asn1Free ((v->modules)); - -} /* FreeTBL */ - - - - -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/stamp-tbl b/SecuritySNACCRuntime/c-lib/stamp-tbl deleted file mode 100644 index 1924b425..00000000 --- a/SecuritySNACCRuntime/c-lib/stamp-tbl +++ /dev/null @@ -1 +0,0 @@ -Wed Mar 20 11:39:20 PST 2002 diff --git a/SecuritySNACCRuntime/c-lib/stamp-useful b/SecuritySNACCRuntime/c-lib/stamp-useful deleted file mode 100644 index 1924b425..00000000 --- a/SecuritySNACCRuntime/c-lib/stamp-useful +++ /dev/null @@ -1 +0,0 @@ -Wed Mar 20 11:39:20 PST 2002 diff --git a/SecuritySNACCRuntime/c-lib/tbl.c b/SecuritySNACCRuntime/c-lib/tbl.c deleted file mode 100644 index 957e98bb..00000000 --- a/SecuritySNACCRuntime/c-lib/tbl.c +++ /dev/null @@ -1,2119 +0,0 @@ -#if TTBL -/* - * tbl.c - * - * "TBL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Tue Mar 19 07:24:47 2002 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "tbl.h" - - -AsnLen -BEncTBLRangeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLRange *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->to)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->from)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLRangeContent */ - -void -BDecTBLRangeContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLRange *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->from), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -100); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->to), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -101); - } - else - longjmp (env, -102); - - - if (!seqDone) - longjmp (env, -103); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLRangeContent */ - -void -PrintTBLRange PARAMS ((f, v, indent), -FILE* f _AND_ -TBLRange *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"from "); - PrintAsnInt (f, (&v->from), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"to "); - PrintAsnInt (f, (&v->to), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLRange */ - -void -FreeTBLRange PARAMS ((v), -TBLRange *v) -{ - - if (v == NULL) - return; - FreeAsnInt ((&v->from)); - - FreeAsnInt ((&v->to)); - -} /* FreeTBLRange */ - - - - -AsnLen -BEncTBLNamedNumberContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumber *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->value)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLNamedNumberContent */ - -void -BDecTBLNamedNumberContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLNamedNumber *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->name), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -104); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->value), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -105); - } - else - longjmp (env, -106); - - - if (!seqDone) - longjmp (env, -107); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLNamedNumberContent */ - -void -PrintTBLNamedNumber PARAMS ((f, v, indent), -FILE* f _AND_ -TBLNamedNumber *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"name "); - PrintPrintableString (f, (&v->name), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"value "); - PrintAsnInt (f, (&v->value), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLNamedNumber */ - -void -FreeTBLNamedNumber PARAMS ((v), -TBLNamedNumber *v) -{ - - if (v == NULL) - return; - FreePrintableString ((&v->name)); - - FreeAsnInt ((&v->value)); - -} /* FreeTBLNamedNumber */ - - - - -AsnLen -BEncTBLNamedNumberListContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumberList *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLNamedNumberListContent */ - -void -BDecTBLNamedNumberListContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLNamedNumberList *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLNamedNumber **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLNamedNumber**) AsnListAppend (v); - (*tmpVar) = (TBLNamedNumber*) Asn1Alloc (sizeof (TBLNamedNumber)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLNamedNumberContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -108); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLNamedNumberListContent */ - -void -PrintTBLNamedNumberList PARAMS ((f, v, indent), -FILE* f _AND_ -TBLNamedNumberList *v _AND_ -unsigned short int indent) -{ - TBLNamedNumber *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLNamedNumber (f, tmp, indent + stdIndentG); - if (tmp != (TBLNamedNumber*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLNamedNumberList */ - -void -FreeTBLNamedNumberList PARAMS ((v), -TBLNamedNumberList *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLNamedNumber ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLNamedNumberList */ - - - - -AsnLen -BEncTBLTypeRefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeRef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnBoolContent (b, (&v->implicit)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDef)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeRefContent */ - -void -BDecTBLTypeRefContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeRef *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeDefIdContent (b, tagId1, elmtLen1, (&v->typeDef), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -109); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->implicit), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -110); - } - else - longjmp (env, -111); - - - if (!seqDone) - longjmp (env, -112); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeRefContent */ - -void -PrintTBLTypeRef PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeRef *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeDef "); - PrintTBLTypeDefId (f, (&v->typeDef), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"implicit "); - PrintAsnBool (f, (&v->implicit), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeRef */ - -void -FreeTBLTypeRef PARAMS ((v), -TBLTypeRef *v) -{ - - if (v == NULL) - return; - FreeTBLTypeDefId ((&v->typeDef)); - - FreeAsnBool ((&v->implicit)); - -} /* FreeTBLTypeRef */ - - - - -AsnLen -BEncTBLTagContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTag *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->code)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncTBLTagClassContent (b, (&v->tclass)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 10); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTagContent */ - -void -BDecTBLTagContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTag *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, ENUM_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTagClassContent (b, tagId1, elmtLen1, (&v->tclass), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -113); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->code), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -114); - } - else - longjmp (env, -115); - - - if (!seqDone) - longjmp (env, -116); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTagContent */ - -void -PrintTBLTag PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTag *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"tclass "); - PrintTBLTagClass (f, (&v->tclass), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"code "); - PrintAsnInt (f, (&v->code), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTag */ - -void -FreeTBLTag PARAMS ((v), -TBLTag *v) -{ - - if (v == NULL) - return; - FreeTBLTagClass ((&v->tclass)); - - FreeAsnInt ((&v->code)); - -} /* FreeTBLTag */ - - - - -AsnLen -BEncTBLTypeSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTagContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeSeqOfContent */ - -void -BDecTBLTypeSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLTag **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLTag**) AsnListAppend (v); - (*tmpVar) = (TBLTag*) Asn1Alloc (sizeof (TBLTag)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTagContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -117); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeSeqOfContent */ - -void -PrintTBLTypeSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeSeqOf *v _AND_ -unsigned short int indent) -{ - TBLTag *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLTag (f, tmp, indent + stdIndentG); - if (tmp != (TBLTag*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeSeqOf */ - -void -FreeTBLTypeSeqOf PARAMS ((v), -TBLTypeSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLTag ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLTypeSeqOf */ - - - - -AsnLen -BEncTBLTypeContentSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContentSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeContentSeqOfContent */ - -void -BDecTBLTypeContentSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeContentSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLType **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLType**) AsnListAppend (v); - (*tmpVar) = (TBLType*) Asn1Alloc (sizeof (TBLType)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTypeContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -118); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContentSeqOfContent */ - -void -PrintTBLTypeContentSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeContentSeqOf *v _AND_ -unsigned short int indent) -{ - TBLType *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLType (f, tmp, indent + stdIndentG); - if (tmp != (TBLType*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeContentSeqOf */ - -void -FreeTBLTypeContentSeqOf PARAMS ((v), -TBLTypeContentSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLType ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLTypeContentSeqOf */ - - - - -AsnLen -BEncTBLTypeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLType *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->values))) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberListContent (b, (v->values)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 6); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->constraint))) - { - BEncEocIfNec (b); - itemLen = BEncTBLRangeContent (b, (v->constraint)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 5); - - totalLen += itemLen; - } - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - itemLen = BEncPrintableStringContent (b, (&v->fieldName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 4); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentContent (b, (v->content)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - if (NOT_NULL ((v->tagList))) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeSeqOfContent (b, (v->tagList)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - } - - itemLen = BEncAsnBoolContent (b, (&v->optional)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeIdContent (b, (&v->typeId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeContent */ - -void -BDecTBLTypeContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLType *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - AsnLen totalElmtsLen2 = 0; - AsnLen elmtLen2; - AsnTag tagId2; - AsnLen totalElmtsLen3 = 0; - AsnLen elmtLen3; - AsnTag tagId3; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeIdContent (b, tagId1, elmtLen1, (&v->typeId), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -119); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->optional), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -120); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->tagList) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->tagList), env); - BDecTBLTypeSeqOfContent (b, tagId1, elmtLen1, (v->tagList), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->content) = (TBLTypeContent*) Asn1Alloc (sizeof (TBLTypeContent)); - CheckAsn1Alloc ((v->content), env); - tagId2 = BDecTag (b, &totalElmtsLen1, env); - elmtLen2 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeContentContent (b, tagId2, elmtLen2, (v->content), &totalElmtsLen1, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc(b, &totalElmtsLen1, env); - if (elmtLen1 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - else - longjmp (env, -121); - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 4)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 4)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->fieldName), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 5)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->constraint) = (TBLRange*) Asn1Alloc (sizeof (TBLRange)); - CheckAsn1Alloc ((v->constraint), env); - BDecTBLRangeContent (b, tagId1, elmtLen1, (v->constraint), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 6)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->values) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->values), env); - BDecTBLNamedNumberListContent (b, tagId1, elmtLen1, (v->values), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -122); - } - - - if (!seqDone) - longjmp (env, -123); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContent */ - -void -PrintTBLType PARAMS ((f, v, indent), -FILE* f _AND_ -TBLType *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeId "); - PrintTBLTypeId (f, (&v->typeId), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"optional "); - PrintAsnBool (f, (&v->optional), indent + stdIndentG); - fprintf (f, ",\n"); - if (NOT_NULL ((v->tagList))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"tagList "); - PrintTBLTypeSeqOf (f, (v->tagList), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"content "); - PrintTBLTypeContent (f, (v->content), indent + stdIndentG); - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"fieldName "); - PrintPrintableString (f, (&v->fieldName), indent + stdIndentG); - } - if (NOT_NULL ((v->constraint))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"constraint "); - PrintTBLRange (f, (v->constraint), indent + stdIndentG); - } - if (NOT_NULL ((v->values))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"values "); - PrintTBLNamedNumberList (f, (v->values), indent + stdIndentG); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLType */ - -void -FreeTBLType PARAMS ((v), -TBLType *v) -{ - - if (v == NULL) - return; - FreeTBLTypeId ((&v->typeId)); - - FreeAsnBool ((&v->optional)); - - if (NOT_NULL ((v->tagList))) - { - FreeTBLTypeSeqOf ((v->tagList)); - Asn1Free ((v->tagList)); - } - - FreeTBLTypeContent ((v->content)); - Asn1Free ((v->content)); - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - FreePrintableString ((&v->fieldName)); - } - - if (NOT_NULL ((v->constraint))) - { - FreeTBLRange ((v->constraint)); - Asn1Free ((v->constraint)); - } - - if (NOT_NULL ((v->values))) - { - FreeTBLNamedNumberList ((v->values)); - Asn1Free ((v->values)); - } - -} /* FreeTBLType */ - - - - -AsnLen -BEncTBLTypeContentContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContent *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - itemLen = BEncAsnNullContent (b, (&v->a.primType)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_ELMTS: - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentSeqOfContent (b, (v->a.elmts)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 1); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_TYPEREF: - BEncEocIfNec (b); - itemLen = BEncTBLTypeRefContent (b, (v->a.typeRef)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncTBLTypeContentContent */ - -void -BDecTBLTypeContentContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeContent *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - switch (tagId0) - { - case MAKE_TAG_ID (CNTX, PRIM, 0): - (v->choiceId) = TBLTYPECONTENT_PRIMTYPE; - BDecAsnNullContent (b, tagId0, elmtLen0, (&v->a.primType), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 1): - (v->choiceId) = TBLTYPECONTENT_ELMTS; - (v->a.elmts) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->a.elmts), env); - BDecTBLTypeContentSeqOfContent (b, tagId0, elmtLen0, (v->a.elmts), &totalElmtsLen1, env); - break; - - case MAKE_TAG_ID (CNTX, CONS, 2): - (v->choiceId) = TBLTYPECONTENT_TYPEREF; - (v->a.typeRef) = (TBLTypeRef*) Asn1Alloc (sizeof (TBLTypeRef)); - CheckAsn1Alloc ((v->a.typeRef), env); - BDecTBLTypeRefContent (b, tagId0, elmtLen0, (v->a.typeRef), &totalElmtsLen1, env); - break; - - default: - Asn1Error ("ERROR - unexpected tag in CHOICE\n"); - longjmp (env, -124); - break; - } /* end switch */ - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeContentContent */ - -void -PrintTBLTypeContent PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeContent *v _AND_ -unsigned short int indent) -{ - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - fprintf (f,"primType "); - PrintAsnNull (f, (&v->a.primType), indent + stdIndentG); - break; - - case TBLTYPECONTENT_ELMTS: - fprintf (f,"elmts "); - PrintTBLTypeContentSeqOf (f, (v->a.elmts), indent + stdIndentG); - break; - - case TBLTYPECONTENT_TYPEREF: - fprintf (f,"typeRef "); - PrintTBLTypeRef (f, (v->a.typeRef), indent + stdIndentG); - break; - - } -} /* PrintTBLTypeContent */ - -void -FreeTBLTypeContent PARAMS ((v), -TBLTypeContent *v) -{ - - if (v == NULL) - return; - switch (v->choiceId) - { - case TBLTYPECONTENT_ELMTS: - FreeTBLTypeContentSeqOf ((v->a.elmts)); - Asn1Free ((v->a.elmts)); - - break; - - case TBLTYPECONTENT_TYPEREF: - FreeTBLTypeRef ((v->a.typeRef)); - Asn1Free ((v->a.typeRef)); - - break; - - } -} /* FreeTBLTypeContent */ - - - - -AsnLen -BEncTBLTypeDefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeDef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->isPdu))) - { - itemLen = BEncAsnNullContent (b, (v->isPdu)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 5); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, (v->type)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->typeName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 19); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDefId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeDefContent */ - -void -BDecTBLTypeDefContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLTypeDef *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecTBLTypeDefIdContent (b, tagId1, elmtLen1, (&v->typeDefId), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -125); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) || -(tagId1 == MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->typeName), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -126); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->type) = (TBLType*) Asn1Alloc (sizeof (TBLType)); - CheckAsn1Alloc ((v->type), env); - BDecTBLTypeContent (b, tagId1, elmtLen1, (v->type), &totalElmtsLen1, env); - if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) - seqDone = TRUE; - else - { - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - seqDone = TRUE; - } - } - } - else - longjmp (env, -127); - - - if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (UNIV, PRIM, NULLTYPE_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->isPdu) = (AsnNull*) Asn1Alloc (sizeof (AsnNull)); - CheckAsn1Alloc ((v->isPdu), env); - BDecAsnNullContent (b, tagId1, elmtLen1, (v->isPdu), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -128); - } - - - if (!seqDone) - longjmp (env, -129); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLTypeDefContent */ - -void -PrintTBLTypeDef PARAMS ((f, v, indent), -FILE* f _AND_ -TBLTypeDef *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"typeDefId "); - PrintTBLTypeDefId (f, (&v->typeDefId), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"typeName "); - PrintPrintableString (f, (&v->typeName), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"type "); - PrintTBLType (f, (v->type), indent + stdIndentG); - if (NOT_NULL ((v->isPdu))) - { - fprintf (f,",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"isPdu "); - PrintAsnNull (f, (v->isPdu), indent + stdIndentG); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLTypeDef */ - -void -FreeTBLTypeDef PARAMS ((v), -TBLTypeDef *v) -{ - - if (v == NULL) - return; - FreeTBLTypeDefId ((&v->typeDefId)); - - FreePrintableString ((&v->typeName)); - - FreeTBLType ((v->type)); - Asn1Free ((v->type)); - - if (NOT_NULL ((v->isPdu))) - { - FreeAsnNull ((v->isPdu)); - Asn1Free ((v->isPdu)); - } - -} /* FreeTBLTypeDef */ - - - - -AsnLen -BEncTBLModuleSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModuleSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeDefContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLModuleSeqOfContent */ - -void -BDecTBLModuleSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLModuleSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLTypeDef **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLTypeDef**) AsnListAppend (v); - (*tmpVar) = (TBLTypeDef*) Asn1Alloc (sizeof (TBLTypeDef)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLTypeDefContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -130); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLModuleSeqOfContent */ - -void -PrintTBLModuleSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLModuleSeqOf *v _AND_ -unsigned short int indent) -{ - TBLTypeDef *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLTypeDef (f, tmp, indent + stdIndentG); - if (tmp != (TBLTypeDef*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLModuleSeqOf */ - -void -FreeTBLModuleSeqOf PARAMS ((v), -TBLModuleSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLTypeDef ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLModuleSeqOf */ - - - - -AsnLen -BEncTBLModuleContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModule *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLModuleSeqOfContent (b, (v->typeDefs)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - itemLen = BEncAsnBoolContent (b, (&v->isUseful)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - if (ASNOID_PRESENT ((&v->id))) - { - itemLen = BEncAsnOidContent (b, (&v->id)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - } - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLModuleContent */ - -void -BDecTBLModuleContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLModule *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)) || -(tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecPrintableStringContent (b, tagId1, elmtLen1, (&v->name), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -131); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnOidContent (b, tagId1, elmtLen1, (&v->id), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - - - if (((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnBoolContent (b, tagId1, elmtLen1, (&v->isUseful), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -132); - - - if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->typeDefs) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->typeDefs), env); - BDecTBLModuleSeqOfContent (b, tagId1, elmtLen1, (v->typeDefs), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -133); - } - else - longjmp (env, -134); - - - if (!seqDone) - longjmp (env, -135); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLModuleContent */ - -void -PrintTBLModule PARAMS ((f, v, indent), -FILE* f _AND_ -TBLModule *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"name "); - PrintPrintableString (f, (&v->name), indent + stdIndentG); - fprintf (f, ",\n"); - if (ASNOID_PRESENT ((&v->id))) - { - Indent (f, indent + stdIndentG); - fprintf (f,"id "); - PrintAsnOid (f, (&v->id), indent + stdIndentG); - fprintf (f, ",\n"); - } - Indent (f, indent + stdIndentG); - fprintf (f,"isUseful "); - PrintAsnBool (f, (&v->isUseful), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"typeDefs "); - PrintTBLModuleSeqOf (f, (v->typeDefs), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLModule */ - -void -FreeTBLModule PARAMS ((v), -TBLModule *v) -{ - - if (v == NULL) - return; - FreePrintableString ((&v->name)); - - if (ASNOID_PRESENT ((&v->id))) - { - FreeAsnOid ((&v->id)); - } - - FreeAsnBool ((&v->isUseful)); - - FreeTBLModuleSeqOf ((v->typeDefs)); - Asn1Free ((v->typeDefs)); - -} /* FreeTBLModule */ - - - - -AsnLen -BEncTBLSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLModuleContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLSeqOfContent */ - -void -BDecTBLSeqOfContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBLSeqOf *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) - { - TBLModule **tmpVar; - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) - { - BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1, env) - break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ - } - if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - tmpVar = (TBLModule**) AsnListAppend (v); - (*tmpVar) = (TBLModule*) Asn1Alloc (sizeof (TBLModule)); - CheckAsn1Alloc ((*tmpVar), env); - BDecTBLModuleContent (b, tagId1, elmtLen1, (*tmpVar), &totalElmtsLen1, env); - } /* end of tag check if */ - else /* wrong tag */ - { - Asn1Error ("Unexpected Tag\n"); - longjmp (env, -136); - } - } /* end of for */ - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLSeqOfContent */ - -void -PrintTBLSeqOf PARAMS ((f, v, indent), -FILE* f _AND_ -TBLSeqOf *v _AND_ -unsigned short int indent) -{ - TBLModule *tmp; - if (v == NULL) - return; - fprintf (f,"{ -- SEQUENCE OF -- \n"); - FOR_EACH_LIST_ELMT (tmp, v) - { - Indent (f, indent+ stdIndentG); - PrintTBLModule (f, tmp, indent + stdIndentG); - if (tmp != (TBLModule*)LAST_LIST_ELMT (v)) - fprintf (f,",\n"); - } - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBLSeqOf */ - -void -FreeTBLSeqOf PARAMS ((v), -TBLSeqOf *v) -{ - - AsnListNode *l; - AsnListNode *tmp; - if (v == NULL) - return; - for (l = FIRST_LIST_NODE (v); l != NULL; ) - { - FreeTBLModule ((l->data)); - tmp = l->next; - Asn1Free (l->data); - Asn1Free (l); - l = tmp; - } -} /* FreeTBLSeqOf */ - - - - -AsnLen BEncTBL PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncTBLContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} /* BEncTBL */ - -void BDecTBL PARAMS ((b, result, bytesDecoded, env), -BUF_TYPE b _AND_ -TBL *result _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - AsnTag tag; - AsnLen elmtLen1; - - if (((tag = BDecTag (b, bytesDecoded, env)) != -MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))) - { - Asn1Error ("BDecTBL: ERROR - wrong tag\n"); - longjmp (env, -137); - } - elmtLen1 = BDecLen (b, bytesDecoded, env); - BDecTBLContent (b, tag, elmtLen1, result, bytesDecoded, env); -} /* BDecTBL */ - -AsnLen -BEncTBLContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLSeqOfContent (b, (v->modules)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalLenStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTags)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypes)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypeDefs)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumModules)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLContent */ - -void -BDecTBLContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), -BUF_TYPE b _AND_ -AsnTag tagId0 _AND_ -AsnLen elmtLen0 _AND_ -TBL *v _AND_ -AsnLen *bytesDecoded _AND_ -ENV_TYPE env) -{ - int seqDone = FALSE; - AsnLen totalElmtsLen1 = 0; - AsnLen elmtLen1; - AsnTag tagId1; - int mandatoryElmtCount1 = 0; - - - tagId1 = BDecTag (b, &totalElmtsLen1, env); - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumModules), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -138); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTypeDefs), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -139); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTypes), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -140); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumTags), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -141); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalNumStrings), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -142); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - BDecAsnIntContent (b, tagId1, elmtLen1, (&v->totalLenStrings), &totalElmtsLen1, env); - tagId1 = BDecTag (b, &totalElmtsLen1, env); - } - else - longjmp (env, -143); - - - if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))) - { - elmtLen1 = BDecLen (b, &totalElmtsLen1, env); - (v->modules) = AsnListNew (sizeof (char*)); - CheckAsn1Alloc ((v->modules), env); - BDecTBLSeqOfContent (b, tagId1, elmtLen1, (v->modules), &totalElmtsLen1, env); - seqDone = TRUE; - if (elmtLen0 == INDEFINITE_LEN) - BDecEoc (b, &totalElmtsLen1, env); - else if (totalElmtsLen1 != elmtLen0) - longjmp (env, -144); - } - else - longjmp (env, -145); - - - if (!seqDone) - longjmp (env, -146); - - (*bytesDecoded) += totalElmtsLen1; -} /* BDecTBLContent */ - -void -PrintTBL PARAMS ((f, v, indent), -FILE* f _AND_ -TBL *v _AND_ -unsigned short int indent) -{ - if (v == NULL) - return; - - fprintf (f,"{ -- SEQUENCE --\n"); - - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumModules "); - PrintAsnInt (f, (&v->totalNumModules), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTypeDefs "); - PrintAsnInt (f, (&v->totalNumTypeDefs), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTypes "); - PrintAsnInt (f, (&v->totalNumTypes), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumTags "); - PrintAsnInt (f, (&v->totalNumTags), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalNumStrings "); - PrintAsnInt (f, (&v->totalNumStrings), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"totalLenStrings "); - PrintAsnInt (f, (&v->totalLenStrings), indent + stdIndentG); - fprintf (f, ",\n"); - Indent (f, indent + stdIndentG); - fprintf (f,"modules "); - PrintTBLSeqOf (f, (v->modules), indent + stdIndentG); - fprintf (f,"\n"); - Indent (f, indent); - fprintf (f,"}"); -} /* PrintTBL */ - -void -FreeTBL PARAMS ((v), -TBL *v) -{ - - if (v == NULL) - return; - FreeAsnInt ((&v->totalNumModules)); - - FreeAsnInt ((&v->totalNumTypeDefs)); - - FreeAsnInt ((&v->totalNumTypes)); - - FreeAsnInt ((&v->totalNumTags)); - - FreeAsnInt ((&v->totalNumStrings)); - - FreeAsnInt ((&v->totalLenStrings)); - - FreeTBLSeqOf ((v->modules)); - Asn1Free ((v->modules)); - -} /* FreeTBL */ - - - - -#endif /* TTBL */ diff --git a/SecuritySNACCRuntime/c-lib/tbl.h b/SecuritySNACCRuntime/c-lib/tbl.h deleted file mode 100644 index b69de422..00000000 --- a/SecuritySNACCRuntime/c-lib/tbl.h +++ /dev/null @@ -1,344 +0,0 @@ -/* - * tbl.h - * - * "TBL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Tue Mar 19 07:24:47 2002 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _tbl_h_ -#define _tbl_h_ - - - - -typedef enum - { - TBL_BOOLEAN = 0, - TBL_INTEGER = 1, - TBL_BITSTRING = 2, - TBL_OCTETSTRING = 3, - TBL_NULL = 4, - TBL_OID = 5, - TBL_REAL = 6, - TBL_ENUMERATED = 7, - TBL_SEQUENCE = 8, - TBL_SET = 9, - TBL_SEQUENCEOF = 10, - TBL_SETOF = 11, - TBL_CHOICE = 12, - TBL_TYPEREF = 13 - } TBLTypeId; /* ENUMERATED { TBL_BOOLEAN (0), TBL_INTEGER (1), TBL_BITSTRING (2), TBL_OCTETSTRING (3), TBL_NULL (4), TBL_OID (5), TBL_REAL (6), TBL_ENUMERATED (7), TBL_SEQUENCE (8), TBL_SET (9), TBL_SEQUENCEOF (10), TBL_SETOF (11), TBL_CHOICE (12), TBL_TYPEREF (13) } */ - -#define BEncTBLTypeIdContent BEncAsnEnumContent - -#define BDecTBLTypeIdContent BDecAsnEnumContent - -#define PrintTBLTypeId PrintAsnEnum - -#define FreeTBLTypeId FreeAsnEnum - - - - -typedef AsnInt TBLTypeDefId; /* INTEGER */ - -#define BEncTBLTypeDefIdContent BEncAsnIntContent - -#define BDecTBLTypeDefIdContent BDecAsnIntContent - -#define PrintTBLTypeDefId PrintAsnInt - -#define FreeTBLTypeDefId FreeAsnInt - - - - -typedef enum - { - UNIVERSAL = 0, - APPLICATION = 1, - CONTEXT = 2, - PRIVATE = 3 - } TBLTagClass; /* ENUMERATED { UNIVERSAL (0), APPLICATION (1), CONTEXT (2), PRIVATE (3) } */ - -#define BEncTBLTagClassContent BEncAsnEnumContent - -#define BDecTBLTagClassContent BDecAsnEnumContent - -#define PrintTBLTagClass PrintAsnEnum - -#define FreeTBLTagClass FreeAsnEnum - - - - -typedef struct TBLRange /* SEQUENCE */ -{ - AsnInt from; /* [0] IMPLICIT INTEGER */ - AsnInt to; /* [1] IMPLICIT INTEGER */ -} TBLRange; - -AsnLen BEncTBLRangeContent PROTO ((BUF_TYPE b, TBLRange *v)); - -void BDecTBLRangeContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLRange *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLRange PROTO ((FILE* f, TBLRange *v, unsigned short int indent)); -void FreeTBLRange PROTO ((TBLRange *v)); - - - - - -typedef struct TBLNamedNumber /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnInt value; /* [1] IMPLICIT INTEGER */ -} TBLNamedNumber; - -AsnLen BEncTBLNamedNumberContent PROTO ((BUF_TYPE b, TBLNamedNumber *v)); - -void BDecTBLNamedNumberContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLNamedNumber *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLNamedNumber PROTO ((FILE* f, TBLNamedNumber *v, unsigned short int indent)); -void FreeTBLNamedNumber PROTO ((TBLNamedNumber *v)); - - - - - -typedef AsnList TBLNamedNumberList; /* SEQUENCE OF TBLNamedNumber */ - -AsnLen BEncTBLNamedNumberListContent PROTO ((BUF_TYPE b, TBLNamedNumberList *v)); - -void BDecTBLNamedNumberListContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLNamedNumberList *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLNamedNumberList PROTO ((FILE* f, TBLNamedNumberList *v, unsigned short int indent)); -void FreeTBLNamedNumberList PROTO ((TBLNamedNumberList *v)); - - - - - -typedef struct TBLTypeRef /* SEQUENCE */ -{ - TBLTypeDefId typeDef; /* TBLTypeDefId */ - AsnBool implicit; /* BOOLEAN */ - struct TBLTypeDef *typeDefPtr; /* Added by MS to hold resolved index */ -} TBLTypeRef; - -AsnLen BEncTBLTypeRefContent PROTO ((BUF_TYPE b, TBLTypeRef *v)); - -void BDecTBLTypeRefContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeRef *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeRef PROTO ((FILE* f, TBLTypeRef *v, unsigned short int indent)); -void FreeTBLTypeRef PROTO ((TBLTypeRef *v)); - - - - - -typedef struct TBLTag /* SEQUENCE */ -{ - TBLTagClass tclass; /* TBLTagClass */ - AsnInt code; /* INTEGER (0..MAX) */ - BER_FORM form; /* added by MS to simplify enc/dec */ - AsnTag encTag; /* added by MS to simplify enc/dec */ -} TBLTag; - -AsnLen BEncTBLTagContent PROTO ((BUF_TYPE b, TBLTag *v)); - -void BDecTBLTagContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTag *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTag PROTO ((FILE* f, TBLTag *v, unsigned short int indent)); -void FreeTBLTag PROTO ((TBLTag *v)); - - - - - -typedef AsnList TBLTypeSeqOf; /* SEQUENCE OF TBLTag */ - -AsnLen BEncTBLTypeSeqOfContent PROTO ((BUF_TYPE b, TBLTypeSeqOf *v)); - -void BDecTBLTypeSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeSeqOf PROTO ((FILE* f, TBLTypeSeqOf *v, unsigned short int indent)); -void FreeTBLTypeSeqOf PROTO ((TBLTypeSeqOf *v)); - - - - - -typedef AsnList TBLTypeContentSeqOf; /* SEQUENCE OF TBLType */ - -AsnLen BEncTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, TBLTypeContentSeqOf *v)); - -void BDecTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeContentSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeContentSeqOf PROTO ((FILE* f, TBLTypeContentSeqOf *v, unsigned short int indent)); -void FreeTBLTypeContentSeqOf PROTO ((TBLTypeContentSeqOf *v)); - - - - - -typedef struct TBLType /* SEQUENCE */ -{ - TBLTypeId typeId; /* [0] IMPLICIT TBLTypeId */ - AsnBool optional; /* [1] IMPLICIT BOOLEAN */ - TBLTypeSeqOf* tagList; /* [2] IMPLICIT TBLTypeSeqOf OPTIONAL */ - struct TBLTypeContent* content; /* [3] TBLTypeContent */ - PrintableString fieldName; /* [4] IMPLICIT PrintableString OPTIONAL */ - struct TBLRange* constraint; /* [5] IMPLICIT TBLRange OPTIONAL */ - TBLNamedNumberList* values; /* [6] IMPLICIT TBLNamedNumberList OPTIONAL */ -} TBLType; - -AsnLen BEncTBLTypeContent PROTO ((BUF_TYPE b, TBLType *v)); - -void BDecTBLTypeContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLType *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLType PROTO ((FILE* f, TBLType *v, unsigned short int indent)); -void FreeTBLType PROTO ((TBLType *v)); - - - - - -typedef struct TBLTypeContent /* CHOICE */ -{ - enum TBLTypeContentChoiceId - { - TBLTYPECONTENT_PRIMTYPE, - TBLTYPECONTENT_ELMTS, - TBLTYPECONTENT_TYPEREF - } choiceId; - union TBLTypeContentChoiceUnion - { - AsnNull primType; /* [0] IMPLICIT NULL */ - TBLTypeContentSeqOf* elmts; /* [1] IMPLICIT TBLTypeContentSeqOf */ - struct TBLTypeRef* typeRef; /* [2] IMPLICIT TBLTypeRef */ - } a; -} TBLTypeContent; - -AsnLen BEncTBLTypeContentContent PROTO ((BUF_TYPE b, TBLTypeContent *v)); - -void BDecTBLTypeContentContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeContent *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeContent PROTO ((FILE* f, TBLTypeContent *v, unsigned short int indent)); -void FreeTBLTypeContent PROTO ((TBLTypeContent *v)); - - - - - -typedef struct TBLTypeDef /* SEQUENCE */ -{ - TBLTypeDefId typeDefId; /* TBLTypeDefId */ - PrintableString typeName; /* PrintableString */ - struct TBLType* type; /* TBLType */ - AsnNull* isPdu; /* NULL OPTIONAL */ -} TBLTypeDef; - -AsnLen BEncTBLTypeDefContent PROTO ((BUF_TYPE b, TBLTypeDef *v)); - -void BDecTBLTypeDefContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLTypeDef *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLTypeDef PROTO ((FILE* f, TBLTypeDef *v, unsigned short int indent)); -void FreeTBLTypeDef PROTO ((TBLTypeDef *v)); - - - - - -typedef AsnList TBLModuleSeqOf; /* SEQUENCE OF TBLTypeDef */ - -AsnLen BEncTBLModuleSeqOfContent PROTO ((BUF_TYPE b, TBLModuleSeqOf *v)); - -void BDecTBLModuleSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLModuleSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLModuleSeqOf PROTO ((FILE* f, TBLModuleSeqOf *v, unsigned short int indent)); -void FreeTBLModuleSeqOf PROTO ((TBLModuleSeqOf *v)); - - - - - -typedef struct TBLModule /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnOid id; /* [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL */ - AsnBool isUseful; /* [2] IMPLICIT BOOLEAN */ - TBLModuleSeqOf* typeDefs; /* [3] IMPLICIT TBLModuleSeqOf */ -} TBLModule; - -AsnLen BEncTBLModuleContent PROTO ((BUF_TYPE b, TBLModule *v)); - -void BDecTBLModuleContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLModule *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLModule PROTO ((FILE* f, TBLModule *v, unsigned short int indent)); -void FreeTBLModule PROTO ((TBLModule *v)); - - - - - -typedef AsnList TBLSeqOf; /* SEQUENCE OF TBLModule */ - -AsnLen BEncTBLSeqOfContent PROTO ((BUF_TYPE b, TBLSeqOf *v)); - -void BDecTBLSeqOfContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBLSeqOf *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBLSeqOf PROTO ((FILE* f, TBLSeqOf *v, unsigned short int indent)); -void FreeTBLSeqOf PROTO ((TBLSeqOf *v)); - - - - - -typedef struct TBL /* SEQUENCE */ -{ - AsnInt totalNumModules; /* INTEGER */ - AsnInt totalNumTypeDefs; /* INTEGER */ - AsnInt totalNumTypes; /* INTEGER */ - AsnInt totalNumTags; /* INTEGER */ - AsnInt totalNumStrings; /* INTEGER */ - AsnInt totalLenStrings; /* INTEGER */ - TBLSeqOf* modules; /* TBLSeqOf */ -} TBL; - -AsnLen BEncTBL PROTO ((BUF_TYPE b, TBL *v)); - -void BDecTBL PROTO ((BUF_TYPE b, TBL *result, AsnLen *bytesDecoded, ENV_TYPE env)); -AsnLen BEncTBLContent PROTO ((BUF_TYPE b, TBL *v)); - -void BDecTBLContent PROTO ((BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, TBL *v, AsnLen *bytesDecoded, ENV_TYPE env)); - - -void PrintTBL PROTO ((FILE* f, TBL *v, unsigned short int indent)); -void FreeTBL PROTO ((TBL *v)); - - - - - - -#endif /* conditional include of tbl.h */ diff --git a/SecuritySNACCRuntime/c-lib/tbl.h.patch b/SecuritySNACCRuntime/c-lib/tbl.h.patch deleted file mode 100644 index 6e74ce2d..00000000 --- a/SecuritySNACCRuntime/c-lib/tbl.h.patch +++ /dev/null @@ -1,23 +0,0 @@ -*** tbl.h Wed Feb 5 17:37:16 1997 ---- boot/tbl.h Wed Jul 19 16:58:58 1995 -*************** -*** 82,87 **** ---- 82,88 ---- - { - TBLTypeDefId typeDef; /* TBLTypeDefId */ - AsnBool implicit; /* BOOLEAN */ -+ struct TBLTypeDef *typeDefPtr; /* Added by MS to hold resolved index */ - } TBLTypeRef; - - AsnLen BEncTBLTypeRefContent PROTO ((BUF_TYPE b, TBLTypeRef *v)); -*************** -*** 100,105 **** ---- 101,108 ---- - { - TBLTagClass tclass; /* TBLTagClass */ - AsnInt code; /* INTEGER (0..MAX) */ -+ BER_FORM form; /* added by MS to simplify enc/dec */ -+ AsnTag encTag; /* added by MS to simplify enc/dec */ - } TBLTag; - - AsnLen BEncTBLTagContent PROTO ((BUF_TYPE b, TBLTag *v)); diff --git a/SecuritySNACCRuntime/compiler/README b/SecuritySNACCRuntime/compiler/README deleted file mode 100644 index 9627ac8f..00000000 --- a/SecuritySNACCRuntime/compiler/README +++ /dev/null @@ -1,111 +0,0 @@ -(RCS control information is at the end of this file.) - - -README: snacc compiler source code - Mike Sample 92 ----------------------------------------------------- - - -Compiling the snacc compiler ----------------------------- - -The snacc source code can be compiled with ANSI and non-ANSI C -compilers. The configure script automatically determines the type of -your C compiler and defines __USE_ANSI_C__ accordingly. - -If you use lex, you should change the YYLMAX value in the lex -generated lex-asn1.c file from its measly default value (200 or so) to -something like 2048. YYLMAX is the longest token that the lexical -analyzer can match. I found this problem when snacc choked on the -DESCRIPTION field of an OBJECT-TYPE macro that was longer than 200 -characters. GNU flex does not have this problem (and seems to produce -smaller code than the old lex). - -Compiling parse-asn1.y with bison or yacc will produce 61 shift/reduce -errors and 2 reduce/reduce errors. These are mostly due to the macros -that are parsed. The reduce/reduce errors result from type or value -lists in some macros - the a "NULL" value and "NULL" type are both -represented by "NULL" - don't worry about this ambiguity. Bizzare -syntax errors that arise from these shift-reduce errors can be -handled by separating types/values with semi-colons. - -The length of generated files' names will be truncated to match your -system has the posix "pathconf" routine. If it does not the maximum -file length will be set at 14 chars. If you want to change this, -modify the "MakeBaseFileName" routine in back_ends/c_gen/str_util.c or -use the -mf cmd line option. - -snacc has been successfully installed on SPARCs, HP700s, RS 6000s, and -MIPS machines. You may have to fiddle with system include files. - -Outline of what snacc does --------------------------- - -The snacc compiler uses yacc and lex (or bison/flex) parser to produce -an attributed parse tree for an ASN.1 source file. The main steps of -the snacc are (see main() in core/snacc.c): - - - 1. parse USEFUL types module (if given on command line with -u option) - related src: core/snacc.c core/lex-asn1.l core/parse-asn1.y - core/asn1module.h - - 2. parse the ASN.1 source file(s) - related src: core/snacc.c core/lex-asn1.l core/parse-asn1.y - core/asn1module.h - - 3. link import and local type references to the type proper - definitions in the parsed modules (including useful types module). - related src: core/link_types.c - - 4. do parsing for OBJECT IDENTIFIER values. Simple recursive descent - parser. Could be expanded to handle more complex values. - related src: core/val_parser.c - -5. link any value references (some may be internal to OBJECT IDENTIFIERs) - related src: core/link_values.c - - 6. process macros - change type definitions in the macros to separate - type definitions and do systemd dependent processing. - related src: core/do_macros.c - - 7. normalize types and values - eg swap COMPONENTS OF and SELECTION types - for actual types/field. (and more) - related src: core/normalize.c - - 8. mark recursive type and report any recursion related errors. - (e.g. empty recursive types A ::= B B ::= A) - related src: core/recursive.c - - 9. check for sematic errors in each ASN.1 module. - related src: core/err_chk.c - -10. fill in the C or C++ type and routine naming information. - (done before dependency sorting so the sorter can make - decisions on the basis of whether a type is ref'd by pointer - (last resort)) - related src: back_ends/c++_gen/c++_types.c - back_ends/c++_gen/c++_rules.c - back_ends/c_gen/types_info.c - back_ends/c_gen/rules.c - -11. do type dependency sorting. Ordered from least dependent - to most dependent. Saves some irritations in the C/C++ code. - related src: core/dependency.c - -12. Generate C/C++ .h and .c/.C files - related src: core/snacc.c back_ends/* - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/Attic/README,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:08 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:38 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1994/09/01 01:37:51 rj -# document the changes: -# - autoconf stuff -# - filename changes. -# diff --git a/SecuritySNACCRuntime/compiler/back-ends/.cvsignore b/SecuritySNACCRuntime/compiler/back-ends/.cvsignore deleted file mode 100644 index 5761abcf..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.o diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-any.c b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-any.c deleted file mode 100644 index d14c83b5..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-any.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/gen_any.c - * - * prints Routine to initialize the ANY Hash table. The - * ANY Hash table maps the OBJECT IDENTIFIERS or INTEGERS - * to the correct decoding routines. - * - * Also prints an enum to identify each ANY mapping. - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * INSERT_VDA_COMMENTS - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/gen-any.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-any.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:39 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:19:11 rj - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:47:53 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 01:06:31 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:47:58 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "define.h" -#include "str-util.h" -#include "rules.h" -#include "gen-vals.h" -#include "lib-types.h" -#include "gen-any.h" - -static int anyEnumValG = 0; - - -void PrintCxxAnyEnum PROTO ((FILE *hdr, Module *m, CxxRules *r)); - -void PrintCxxAnyHashInitRoutine PROTO ((FILE *src, FILE *hdr, ModuleList *mods, Module *m, CxxRules *r)); - - -void -PrintCxxAnyCode PARAMS ((src, hdr, r, mods, m), - FILE *src _AND_ - FILE *hdr _AND_ - CxxRules *r _AND_ - ModuleList *mods _AND_ - Module *m) -{ - - if (!m->hasAnys) - return; - - PrintCxxAnyEnum (hdr, m, r); - PrintCxxAnyHashInitRoutine (src, hdr, mods, m, r); - -} /* PrintAnyCode */ - - - -void -PrintCxxAnyEnum PARAMS ((hdr, m, r), - FILE *hdr _AND_ - Module *m _AND_ - CxxRules *r) -{ - TypeDef *td; - AnyRef *ar; - AnyRefList *arl; - int firstPrinted = TRUE; - int i; - char *modName; - - modName = Asn1TypeName2CTypeName (m->modId->name); - - fprintf (hdr,"typedef enum %sAnyId\n", modName); - fprintf (hdr,"{\n"); - - /* do any lib types */ - for (i = BASICTYPE_BOOLEAN; i < BASICTYPE_MACRODEF; i++) - { - arl = LIBTYPE_GET_ANY_REFS (i); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - if (!firstPrinted) - fprintf (hdr,",\n"); - fprintf (hdr," %s = %d", ar->anyIdName, anyEnumValG++); - firstPrinted = FALSE; - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - if (!firstPrinted) - fprintf (hdr,",\n"); - fprintf (hdr," %s = %d", ar->anyIdName, anyEnumValG++); - firstPrinted = FALSE; - } - } - } - -#ifndef VDADER_RULES - if (firstPrinted) /* none have been printed */ - fprintf (hdr,"/* NO INTEGER or OBJECT IDENTIFIER to ANY type relationships were defined (via MACROs or other mechanism) */\n ??? \n"); -#endif - - fprintf (hdr,"\n} %sAnyId;\n\n\n", modName); - Free (modName); - -} /* PrintAnyEnum */ - - -void -PrintCxxAnyHashInitRoutine PARAMS ((src, hdr, mods, m, r), - FILE *src _AND_ - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r) -{ - TypeDef *td; - AnyRefList *arl; - AnyRef *ar; - CxxTDI *cxxtdi; - int i; - int j; - enum BasicTypeChoiceId typeId; - int installedSomeHashes = FALSE; - - -#ifndef VDADER_RULES - /* print InitAny class src file */ - fprintf (src,"// this class will automatically intialize the any hash tbl\n"); - fprintf (src,"class InitAny\n"); - fprintf (src,"{\n"); - fprintf (src," public:\n"); - fprintf (src," InitAny();\n"); - fprintf (src,"};\n\n"); - - fprintf (src,"static InitAny anyInitalizer;\n"); - - /* print constructor method that build hash tbl to src file*/ - fprintf (src,"InitAny::InitAny()\n"); - fprintf (src,"{\n"); - - /* first print value for OID's */ - - /* do any lib types first */ - i = 0; - for (j = BASICTYPE_BOOLEAN; j < BASICTYPE_MACRODEF; j++) - { - arl = LIBTYPE_GET_ANY_REFS (j); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - installedSomeHashes = TRUE; - if (ar->id->choiceId == OIDORINT_OID) - { - fprintf (src," %s oid%d", r->typeConvTbl[BASICTYPE_OID].className, i++); - PrintCxxOidValue (src, r, ar->id->a.oid); - fprintf (src,";\n"); - } - else if (ar->id->choiceId == OIDORINT_INTID) - { - fprintf (src," %s int%d", r->typeConvTbl[BASICTYPE_INTEGER].className, i++); - PrintCxxIntValue (src, r, ar->id->a.intId); - fprintf (src,";\n"); - } - } - } - } - - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - cxxtdi = td->cxxTypeDefInfo; - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - installedSomeHashes = TRUE; - if (ar->id->choiceId == OIDORINT_OID) - { - fprintf (src," %s oid%d", r->typeConvTbl[BASICTYPE_OID].className, i++); - PrintCxxOidValue (src, r, ar->id->a.oid); - fprintf (src,";\n"); - } - else if (ar->id->choiceId == OIDORINT_INTID) - { - fprintf (src," %s int%d", r->typeConvTbl[BASICTYPE_INTEGER].className, i++); - PrintCxxIntValue (src, r, ar->id->a.intId); - fprintf (src,";\n"); - } - } - } - } - - - /* now print hash init calls */ - i = 0; - for (j = BASICTYPE_BOOLEAN; j < BASICTYPE_MACRODEF; j++) - { - arl = LIBTYPE_GET_ANY_REFS (j); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - if (ar->id->choiceId == OIDORINT_OID) - fprintf (src," AsnAny::InstallAnyByOid (oid%d, %s, new %s);\n", i++, ar->anyIdName, r->typeConvTbl[j].className); - - else - fprintf (src," AsnAny::InstallAnyByInt (int%d, %s, new %s);\n", i++, ar->anyIdName, r->typeConvTbl[j].className); - - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - cxxtdi = td->cxxTypeDefInfo; - - if (ar->id->choiceId == OIDORINT_OID) - fprintf (src," AsnAny::InstallAnyByOid (oid%d, %s, new %s);\n", i++, ar->anyIdName, cxxtdi->className); - - else - fprintf (src," AsnAny::InstallAnyByInt (int%d, %s, new %s);\n", i++, ar->anyIdName, cxxtdi->className); - - } - } - } - - if (!installedSomeHashes) - { - fprintf (src," /* Since no INTEGER/OID to ANY type relations were defined\n"); - fprintf (src," * (usually done via MACROs) you must manually do the code\n"); - fprintf (src," * to fill the hash tbl.\n"); - fprintf (src," * if the ids are INTEGER use the following:\n"); - fprintf (src," * AsnAny::InstallAnyByInt (3, ??_ANY_ID, new );\n"); - fprintf (src," * if the ids are OBJECT IDENTIFIERs use the following:\n"); - fprintf (src," * AsnAny::InstallAnyByOid (OidValue, ??_ANY_ID, new );\n"); - fprintf (src," * put the ??_ANY_IDs in the AnyId enum.\n\n"); - fprintf (src," * For example if you have some thing like\n"); - fprintf (src," * T1 ::= SEQUENCE { id INTEGER, ANY DEFINED BY id }\n"); - fprintf (src," * and the id 1 maps to the type BOOLEAN use the following:\n"); - fprintf (src," * AsnAny::InstallAnyByInt (1, SOMEBOOL_ANY_ID, new AsnBool);\n"); - fprintf (src," */\n ???????\n"); /* generate compile error */ - fprintf (src," /* VDADER_RULES is selected UPDATE THIS COMMENT\n"); - fprintf (src," */\n"); - } - - - fprintf (src,"} /* InitAny::InitAny */\n\n\n"); -#endif - -} /* PrintAnyHashInitRoutine */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-any.h b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-any.h deleted file mode 100644 index 16273c14..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-any.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/gen_any.h - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/gen-any.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-any.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:39 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:19:12 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:47:54 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:47:59 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -void PrintCxxAnyCode PROTO ((FILE *src, FILE *hdr, CxxRules *r, ModuleList *mods, Module *m)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-code.c b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-code.c deleted file mode 100644 index 971014cc..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-code.c +++ /dev/null @@ -1,5650 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - - -/* - * compiler/back_ends/c++_gen/gen_code.c - routines for printing C++ code from type trees - * - * assumes that the type tree has already been run through the - * c++ type generator (c++_gen/types.c). - * - * This was hastily written - it has some huge routines in it. - * Needs a lot of cleaning up and modularization... - * - * Mike Sample - * 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * INSERT_VDA_COMMENTS - * - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/gen-code.c,v 1.4 2002/03/21 05:38:53 dmitch Exp $ - * $Log: gen-code.c,v $ - * Revision 1.4 2002/03/21 05:38:53 dmitch - * Radar 2868524: no more setjmp/longjmp in SNACC-generated code. - * - * Revision 1.3.44.3 2002/03/20 20:56:39 dmitch - * Further refinements for Radar 2868524: no more BDecPdu or BEncPdu. - * - * Revision 1.3.44.2 2002/03/20 02:53:09 dmitch - * Avoid the unused and uninitialized jmp_buf var in BDecPdu. - * - * Revision 1.3.44.1 2002/03/20 00:36:59 dmitch - * Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp. - * - * Revision 1.3 2001/06/27 23:51:42 dmitch - * Reimplement partial fix for Radar 2664258: Print() routines are now empty stubs in NDEBUG config. - * - * Revision 1.2 2001/06/27 23:07:00 dmitch - * Pusuant to Radar 2664258, Print() member functions are now conditional on #ifndef NDEBUG. - * - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.4 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.3 1999/03/20 03:13:48 mb - * Generate Copy member functions. - * - * Revision 1.2 1999/03/17 01:54:54 aram - * Changed compiler so that the destructors and Clone methods are virtual. - * - * Revision 1.1.1.1 1999/03/16 18:06:39 aram - * Originals from SMIME Free Library. - * - * Revision 1.12 1997/02/28 13:39:53 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.11 1997/02/16 15:14:06 rj - * made return *this after calling abort()'' a compile time option. - * - * Revision 1.10 1997/02/16 12:46:31 rj - * use the TIME_WITH_SYS_TIME flag (checked and generated by configure). - * return *this after calling abort() for compilers that don't know about this volatile function. - * comment out unused parameters, the compiler otherwise may complain. - * - * Revision 1.9 1995/09/07 20:47:32 rj - * deep copying assingment operators added. - * - * Revision 1.8 1995/09/07 19:25:27 rj - * PrintCxxCode(): boolean genMeta changed to enum type MetaNameStyle. used globally in printMetaG. - * - * set Tcl's errorCode variable. - * - * Revision 1.7 1995/08/17 15:00:06 rj - * the PDU flag belongs to the metacode, not only to the tcl interface. (type and variable named adjusted) - * - * Revision 1.6 1995/07/27 10:52:28 rj - * include config.h before using its #define's :-) - * - * file name has been shortened for redundant part: c++-gen/gen-c++-code -> c++-gen/gen-code. - * - * functions used only locally made static. - * - * #if TCL ... #endif wrapped into #if META ... #endif, both here and in generated files. - * - * code changes to allow for more than one PDU (meta code), e.g. generate -create() functions. - * - * generate additional TclUnsetVal() function to delete OPTIONAL members and SEQUENCE OF and SET OF list elements. - * - * _getref() gets an additional optional argument to faciliate the different member access semantics of TclGetVal() and TclSetVal(). - * - * the list functions Append(), Prepend(), InsertBefore() and InsertAfter() now set the current element to the element just inserted. - * - * changed `_' to `-' in file names. - * - * Revision 1.5 1995/02/18 14:45:16 rj - * tried to make the print function's output a little more readable. [kho] - * - * Revision 1.4 1994/10/08 03:19:24 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * turned the functions order upside down to get rid of those annoying declarations. - * - * turned character pointers into constant character arrays. - * - * code for meta structures added (provides information about the generated code itself). - * - * code for Tcl interface added (makes use of the above mentioned meta code). - * - * instead of being a no-op, the no-arg-constructors (that get used by Clone()) do something useful now, namely: - * - initialize the pointer in a choice union. (the destruktor may try to free the bogus pointer). - * - for the same reason: initialize pointers in sequences and sets. - * - * to complement the destructors, T::T (const T&) and T &T::operator = (const T &) have been added to override the defaults supplied by the compiler. - * reason: simple pointer duplication may lead to unreferenced objects and to objects referenced more than once (on which the destructors delete may choke). - * - * virtual inline functions (the destructor and the Clone() function) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. - * - * made Print() const (and some other, mainly comparison functions). - * - * Revision 1.3 1994/09/01 00:16:29 rj - * change of IBM ENC integrated: large inlines turned into normal functions. - * more portable .h file inclusion. - * - * Revision 1.2 1994/08/31 09:49:05 rj - * for the C++ code generated: turned TRUE/FALSE into true/false; - * the keyword `struct' had to be removed before AsnListElmt, or gcc 2.6 wouldn't compile the generated code. - * - * Revision 1.1 1994/08/28 09:48:01 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "snacc.h" - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "define.h" -#include "mem.h" -#include "lib-types.h" -#include "rules.h" -#include "types.h" -#include "cond.h" -#include "str-util.h" -#include "snacc-util.h" -#include "print.h" -#include "tag-util.h" /* get GetTags/FreeTags/CountTags/TagByteLen */ -#if META -#include "meta.h" -#endif -#include "gen-vals.h" -#include "gen-any.h" -#include "gen-code.h" - -#ifdef VDADER_RULES -long VDA_ProcessSetOf(FILE *src,TypeDef *td,Type *lst,CxxRules *r); -#endif - - -static const char bufTypeNameG[] = "BUF_TYPE"; -static const char lenTypeNameG[] = "AsnLen"; -static const char tagTypeNameG[] = "AsnTag"; -static const char envTypeNameG[] = "ENV_TYPE"; -static long int longJmpValG = -100; -static const char baseClassesG[] = ": public AsnType"; - -static int printTypesG; -static int printEncodersG; -static int printDecodersG; -static int printPrintersG; -static int printFreeG; -#if META -static MetaNameStyle printMetaG; -static MetaPDU *meta_pdus_G; -#if TCL -static int printTclG; -#endif -#endif /* META */ - - -static void -PrintHdrComment PARAMS ((hdr, m), - FILE *hdr _AND_ - Module *m) -{ - time_t now = time (NULL); - - fprintf (hdr, "// NOTE: this is a machine generated file--editing not recommended\n"); - fprintf (hdr, "//\n"); - fprintf (hdr, "// %s - class definitions for ASN.1 module %s\n", m->cxxHdrFileName, m->modId->name); - fprintf (hdr, "//\n"); - fprintf (hdr, "// This file was generated by snacc on %s", ctime (&now)); - fprintf (hdr, "// UBC snacc by Mike Sample\n"); - fprintf (hdr, "// A couple of enhancements made by IBM European Networking Center\n"); /* 20.8.93 Thomas Meyer */ - fprintf (hdr, "\n"); - -} /* PrintHdrComment */ - -static void -PrintSrcComment PARAMS ((src, m), - FILE *src _AND_ - Module *m) -{ - time_t now = time (NULL); - - fprintf (src, "// NOTE: this is a machine generated file--editing not recommended\n"); - fprintf (src, "//\n"); - fprintf (src, "// %s - class member functions for ASN.1 module %s\n", m->cxxSrcFileName, m->modId->name); - fprintf (src, "//\n"); - fprintf (src, "// This file was generated by snacc on %s", ctime (&now)); - fprintf (src, "// UBC snacc written by Mike Sample\n"); - fprintf (src, "// A couple of enhancements made by IBM European Networking Center\n"); /* 20.8.93 Thomas Meyer */ - fprintf (src, "\n"); - -} /* PrintSrcComment */ - - -static void -PrintSrcIncludes PARAMS ((src, if_IBM_ENC (srcdb COMMA) mods, m), - FILE *src _AND_ - if_IBM_ENC (FILE *srcdb _AND_) - ModuleList *mods _AND_ - Module *m) -{ - void *tmp; - Module *currMod; -#ifdef _IBM_ENC_ - size_t length; - char *inclstring; -#endif /* _IBM_ENC_ */ - - fprintf (src, "#include \"asn-incl.h\"\n"); - - tmp = (void *)CURR_LIST_NODE (mods); /* remember curr loc */ - FOR_EACH_LIST_ELMT (currMod, mods) - fprintf (src, "#include \"%s\"\n", currMod->cxxHdrFileName); - SET_CURR_LIST_NODE (mods, tmp); - -#ifdef _IBM_ENC_ -#include "./ibm_editor/print_src_includes.h" -#endif /* _IBM_ENC_ */ -} /* PrintSrcIncludes */ - - -static void -PrintTypeDecl PARAMS ((f, td), - FILE *f _AND_ - TypeDef *td) -{ - switch (td->type->basicType->choiceId) - { - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_SELECTION: - case BASICTYPE_UNKNOWN: - case BASICTYPE_MACRODEF: - case BASICTYPE_MACROTYPE: - return; /* do nothing */ - - default: - if (IsNewType (td->type)) - fprintf (f, "class %s;\n", td->cxxTypeDefInfo->className); - } - -} /* PrintTypeDecl */ - - -static void -PrintCxxType PARAMS ((hdr, mods, m, r, td, parent, t), - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - fprintf (hdr, "%s ", t->cxxTypeRefInfo->className); - - if (t->cxxTypeRefInfo->isPtr) - fprintf (hdr, "*"); - -} /* PrintCxxType */ - - -#ifdef _IBM_ENC_ -static void -PrintCxxTypedb PARAMS ((srcdb, mods, m, r, td, parent, t), - FILE *srcdb _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ -#include "./ibm_editor/print_cxx_type_db.h" -} /* PrintCxxTypedb */ -#endif - - -/* - * Uses the Constructor that takes no args. - * Assumes file f is positioned inside a class definition. - * All Classes get this to support the ANY type. - */ -static void -PrintCloneMethod PARAMS ((hdr, src, td), - FILE *hdr _AND_ - FILE *src _AND_ - TypeDef *td) -{ - fprintf (hdr, " virtual AsnType *Clone() const;\n\n", td->cxxTypeDefInfo->className); - - fprintf (src, "AsnType *%s::Clone() const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return new %s;\n", td->cxxTypeDefInfo->className); - fprintf (src, "}\n\n"); - - /* Print the Copy method as well. Use the copy constuctor. */ - fprintf (hdr, " virtual AsnType *Copy() const;\n\n", td->cxxTypeDefInfo->className); - - fprintf (src, "AsnType *%s::Copy() const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return new %s (*this);\n", td->cxxTypeDefInfo->className); - fprintf (src, "}\n\n"); -} /* PrintCloneMethod */ - - -/* - * prints inline definition of constructors if this class is - * derived from a library class. - * assumes FILE *f is positioned in the derived class definition (.h) - * - * 12/92 MS - added overloaded "=" ops for string types. - */ -static void -PrintDerivedConstructors PARAMS ((f, r, td), - FILE *f _AND_ - CxxRules *r _AND_ - TypeDef *td) -{ - enum BasicTypeChoiceId typeId; - char *derivedClassName; - char *baseClassName; - - typeId = GetBuiltinType (td->type); - derivedClassName = td->cxxTypeDefInfo->className; - baseClassName = td->type->cxxTypeRefInfo->className; - - /* every class gets the no-arg constructor */ -#if TCL - if (printTclG && typeId == BASICTYPE_ENUMERATED) - { - fprintf (f, "#if TCL\n"); - fprintf (f, " %s(): %s (_nmdescs[0].value) {}\n", derivedClassName, baseClassName); - fprintf (f, "#else\n"); - } -#endif /* TCL */ - fprintf (f, " %s(): %s() {}\n", derivedClassName, baseClassName); -#if TCL - if (printTclG && typeId == BASICTYPE_ENUMERATED) - fprintf (f, "#endif\n"); -#endif /* TCL */ - - switch (typeId) - { - case BASICTYPE_BOOLEAN: - fprintf (f, " %s (bool b): %s (b) {}\n", derivedClassName, baseClassName); - break; - - case BASICTYPE_ENUMERATED: - case BASICTYPE_INTEGER: - fprintf (f, " %s (int i): %s (i) {}\n", derivedClassName, baseClassName); - break; - - case BASICTYPE_REAL: - fprintf (f, " %s (double d): %s (d) {}\n", derivedClassName, baseClassName); - break; - - case BASICTYPE_OCTETSTRING: - fprintf (f, " %s (const char *str): %s (str) {}\n", derivedClassName, baseClassName); - - fprintf (f, " %s (const char *str, const size_t len): %s (str, len) {}\n", derivedClassName, baseClassName); - - fprintf (f, " %s (const %s &o): %s (o) {}\n", derivedClassName, baseClassName, baseClassName); - - /* include overloading of = op. MS 12/92 */ - fprintf (f, " %s &operator = (const %s &o) { ReSet (o); return *this; }\n", derivedClassName, derivedClassName); - fprintf (f, " %s &operator = (const char *str) { ReSet (str); return *this; }\n", derivedClassName); - break; - - case BASICTYPE_BITSTRING: - fprintf (f, " %s (const size_t bits): %s (bits) {}\n", derivedClassName, baseClassName); - - fprintf (f, " %s (const char *str, const size_t bitLen): %s (str, bitLen) {}\n", derivedClassName, baseClassName); - - fprintf (f, " %s (const %s &b): %s (b) {}\n", derivedClassName, baseClassName, baseClassName); - break; - - /* include overloading of = op. MS 12/92 */ - fprintf (f, " %s &operator = (const %s &b) { ReSet (b); return *this; }\n", derivedClassName, derivedClassName); - - case BASICTYPE_OID: - fprintf (f, " %s (const char *encOid, size_t len): %s (encOid, len) {}\n", derivedClassName, baseClassName); - - fprintf (f, " %s (const %s &o): %s (o) {}\n", derivedClassName, baseClassName, baseClassName); - - fprintf (f, " %s (unsigned long int a1, unsigned long int a2, long int a3=-1, long int a4=-1, long int a5=-1, long int a6=-1, long int a7=-1, long int a8=-1, long int a9=-1, long int a10=-1, long int a11=-1): %s (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) {}\n", baseClassName, derivedClassName, baseClassName); - - /* include overloading of = op. MS 12/92 */ - fprintf (f, " %s &operator = (const %s &o) { ReSet (o); return *this; }\n", derivedClassName, derivedClassName); - - break; - - - default: - /* do nothing */ - break; - } - -} /* PrintDerivedConstructors */ - - -static void -PrintMakeTag PARAMS ((f, tag), - FILE *f _AND_ - Tag *tag) -{ - char *classStr; - char *formStr; - - classStr = Class2ClassStr (tag->tclass); - - if (tag->form == ANY_FORM) /* default to PRIM for dual form tags */ - formStr = Form2FormStr (PRIM); - else - formStr = Form2FormStr (tag->form); - - fprintf (f, "MAKE_TAG_ID (%s, %s, ", classStr, formStr); - if (tag->tclass == UNIV) - fprintf (f, "%s)", Code2UnivCodeStr (tag->code)); - else - fprintf (f, "%d)", tag->code); - -} /* PrintMakeTag */ - -static void -PrintPduMemberFcns PARAMS ((src, hdr, r, cln), - FILE *src _AND_ - FILE *hdr _AND_ - CxxRules *r _AND_ - char *cln) -{ -#if SNACC_ENABLE_PDU - if (printEncodersG) - { - fprintf (hdr, " int B%s (%s b, %s &bytesEncoded);\n", r->encodePduBaseName, bufTypeNameG, lenTypeNameG); - - fprintf (src, "int %s::B%s (%s b, %s &bytesEncoded)\n", cln, r->encodePduBaseName, bufTypeNameG, lenTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " bytesEncoded = B%s (b);\n", r->encodeBaseName); - fprintf (src, " return !b.WriteError();\n"); - fprintf (src, "}\n\n"); - } - - if (printDecodersG) - { - fprintf (hdr, " int B%s (%s b, %s &bytesDecoded);\n", r->decodePduBaseName, bufTypeNameG, lenTypeNameG); - - fprintf (src, "int %s::B%s (%s b, %s &bytesDecoded)\n", cln, r->decodePduBaseName, bufTypeNameG, lenTypeNameG); - fprintf (src, "{\n"); - #if !SNACC_EXCEPTION_ENABLE - fprintf (src, " %s env;\n", envTypeNameG); - fprintf (src, " int val;\n\n"); - #endif - fprintf (src, " bytesDecoded = 0;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " try\n"); - fprintf (src, " {\n"); - fprintf (src, " BDec (b, bytesDecoded, 0);\n"); - fprintf (src, " return !b.ReadError();\n"); - fprintf (src, " }\n"); - fprintf (src, " catch(...)\n"); - fprintf (src, " {\n"); - fprintf (src, " return false;\n"); - fprintf (src, " }\n"); - #else /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " if ((val = setjmp (env)) == 0)\n"); - fprintf (src, " {\n"); - fprintf (src, " BDec (b, bytesDecoded, env);\n"); - fprintf (src, " return !b.ReadError();\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " return false;\n"); -/* - fprintf (src, " { cerr << \"longjmp return value is \" << val << endl;\n"); - fprintf (src, " return false; }\n"); -*/ - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, "}\n\n"); - } - - fprintf (hdr, "\n"); -#endif /* SNACC_ENABLE_PDU */ -} /* PrintPduMemberFcns */ - - -static void -PrintCxxEocEncoders PARAMS ((src, td, t, bufVarName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t _AND_ - char *bufVarName) -{ - TagList *tl; - Tag *tag; - int stoleChoiceTags; - - /* - * get all the tags on this type - */ - tl = (TagList*) GetTags (t, &stoleChoiceTags); - - /* - * leave choice elmt tag enc to encoding routine - */ - if (!stoleChoiceTags) - { - FOR_EACH_LIST_ELMT (tag, tl) - if (tag->form == CONS) - fprintf (src, " BEncEocIfNec (b);\n"); - } - - FreeTags (tl); - -} /* PrintCxxEocEncoders */ - - -static int -HasShortLen PARAMS ((t), - Type *t) -{ - enum BasicTypeChoiceId typesType; - /* - * efficiency hack - use simple length (1 byte) - * encoded for type (almost) guaranteed to have - * encoded lengths of 0 <= len <= 127 - */ - typesType = GetBuiltinType (t); - return typesType == BASICTYPE_BOOLEAN || typesType == BASICTYPE_INTEGER || typesType == BASICTYPE_NULL || typesType == BASICTYPE_REAL || typesType == BASICTYPE_ENUMERATED; -} /* HasShortLen */ - - -/* - * prints length encoding code. Primitives always use - * definite length and constructors get "ConsLen" - * which can be configured at compile to to be indefinite - * or definite. Primitives can also be "short" (isShort is true) - * in which case a fast macro is used to write the length. - * Types for which isShort apply are: boolean, null and - * (almost always) integer and reals - */ -static void -PrintCxxLenEncodingCode PARAMS ((f, isCons, isShort, lenVarName, bufVarName), - FILE *f _AND_ - int isCons _AND_ - int isShort _AND_ - char *lenVarName _AND_ - char *bufVarName) -{ - if (isCons) - fprintf (f, " %s += BEncConsLen (%s, %s);\n", lenVarName, bufVarName, lenVarName); - else - { - if (isShort) - { - fprintf (f, " BEncDefLenTo127 (%s, %s);\n", bufVarName, lenVarName); - fprintf (f, " %s++;\n", lenVarName); - } - else - fprintf (f, " %s += BEncDefLen (%s, %s);\n", lenVarName, bufVarName, lenVarName); - } -} /* PrintCxxLenEncodingCode */ - - -/* - * prints last tag's encoding code first - */ -static void -PrintCxxTagAndLenList PARAMS ((src, t, tagList, lenVarName, bufVarName), - FILE *src _AND_ - Type *t _AND_ - TagList *tagList _AND_ - char *lenVarName _AND_ - char *bufVarName) -{ - char *classStr; - char *formStr; - char *codeStr; - Tag *tg; - Tag *last; - int tagLen; - enum BasicTypeChoiceId typesType; - int isShort; - - if ((tagList == NULL) || LIST_EMPTY (tagList)) - return; - - /* - * efficiency hack - use simple length (1 byte) - * encoded for type (almost) guaranteed to have - * encoded lengths of 0 <= len <= 127 - */ - isShort = HasShortLen (t); - - /* - * since encoding backward encode tags backwards - */ - last = (Tag*)LAST_LIST_ELMT (tagList); - FOR_EACH_LIST_ELMT_RVS (tg, tagList) - { - classStr = Class2ClassStr (tg->tclass); - - if (tg->form == CONS) - { - formStr = Form2FormStr (CONS); - PrintCxxLenEncodingCode (src, TRUE, isShort, lenVarName, bufVarName); - } - else /* PRIM or ANY_FORM */ - { - formStr = Form2FormStr (PRIM); - PrintCxxLenEncodingCode (src, FALSE, isShort, lenVarName, bufVarName); - } - -/* GetTags sets the form properly now - if (IsPrimitiveByDefOrRef (t) && (tg == last)) - { - formStr = Form2FormStr (PRIM); - PrintCxxLenEncodingCode (src, FALSE, isShort, lenVarName, bufVarName); - } - else - { - formStr = Form2FormStr (CONS); - PrintCxxLenEncodingCode (src, TRUE, isShort, lenVarName, bufVarName); - } -*/ - - fprintf (src, "\n"); - - tagLen = TagByteLen (tg->code); - - if (tg->tclass == UNIV) - fprintf (src, " %s += BEncTag%d (%s, %s, %s, %s);\n", lenVarName, tagLen, bufVarName, classStr, formStr, Code2UnivCodeStr (tg->code)); - else - fprintf (src, " %s += BEncTag%d (%s, %s, %s, %d);\n", lenVarName, tagLen, bufVarName, classStr, formStr, tg->code); - } - -} /* PrintCxxTagAndLenList */ - - -/* - * Recursively walks through tags, printing lower lvl tags - * first (since encoding is done backwards). - * - */ -static void -PrintCxxTagAndLenEncodingCode PARAMS ((src, td, t, lenVarName, bufVarName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t _AND_ - char *lenVarName _AND_ - char *bufVarName) -{ - TagList *tl; - int stoleChoiceTags; - - /* - * get all the tags on this type - */ - tl = (TagList*) GetTags (t, &stoleChoiceTags); - - /* - * leave choice elmt tag enc to encoding routine - */ - if (!stoleChoiceTags) - PrintCxxTagAndLenList (src, t, tl, lenVarName, bufVarName); - - FreeTags (tl); - -} /* PrintCxxTagAndLenEncodingCode */ - - -/* - * used to figure out local variables to declare - * for decoding tags/len pairs on type t - */ -static int -CxxCountVariableLevels PARAMS ((t), - Type *t) -{ - if (GetBuiltinType (t) == BASICTYPE_CHOICE) - return CountTags (t) +1; /* since must decode 1 internal tag type */ - else - return CountTags (t); -} /* CxxCountVariableLevels */ - - -/* - * returns true if elmts curr following - * onward are all optional ow. false - */ -static int -RestAreTailOptional PARAMS ((e), - NamedTypeList *e) -{ - NamedType *elmt; - void *tmp; - int retVal; - - if (e == NULL) - return TRUE; - - tmp = (void*)CURR_LIST_NODE (e); - retVal = TRUE; - AsnListNext (e); - FOR_REST_LIST_ELMT (elmt, e) - { - if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL)) - { - retVal = FALSE; - break; - } - } - SET_CURR_LIST_NODE (e, tmp); /* reset list to orig loc */ - return retVal; -} - - -/* - * prints typedef or new class given an ASN.1 type def of a primitive type - * or typeref. Uses inheritance to cover re-tagging and named elmts. - */ -static void -PrintCxxSimpleDef PARAMS ((hdr, src, if_IBM_ENC (hdrdb COMMA srcdb COMMA) if_META (m COMMA) r, td), - FILE *hdr _AND_ - FILE *src _AND_ - if_IBM_ENC (FILE *hdrdb _AND_) - if_IBM_ENC (FILE *srcdb _AND_) - if_META (Module *m _AND_) - CxxRules *r _AND_ - TypeDef *td) -{ - Tag *tag; - TagList *tags; - char *formStr; - char *classStr; - int tagLen; - int i; - CNamedElmt *n; - int stoleChoiceTags; - int elmtLevel; - enum BasicTypeChoiceId typeId; - - fprintf (hdr, "/* "); - SpecialPrintType (hdr, td, td->type); - fprintf (hdr, " */\n"); - - /* check if has been re-tagged - * eg Foo ::= [APPLICATION 2] IMPLICIT REAL - * or if it has named elmts in which case a new class must - * be defined - * eg Foo ::= INTEGER { one (1), two (2), three (3) } - */ - - if (IsNewType (td->type)) - { - int hasNamedElmts; - -#ifdef _IBM_ENC_ -#include "./ibm_editor/print_cxx_simple_def.h" -#endif /* _IBM_ENC_ */ - - fprintf (hdr, "class %s: public %s\n", td->cxxTypeDefInfo->className, td->type->cxxTypeRefInfo->className); - fprintf (hdr, "{\n"); - fprintf (hdr, "public:\n"); - - /* - * must explicitly call constructors for base class - */ - PrintDerivedConstructors (hdr, r, td); - - /* do named elmts enum if any */ - /* for types with named elements, inherit from the base - * class and define and enum eg: - * Foo ::= INTEGER { one (1), two (2), five (5) } - * -> - * class Foo: public AsnInt - * { - * public: - * Foo(): AsnInt() {} - * Foo (int val): AsnInt (int val) {} - * enum { one = 1, two = 2, five = 5 }; - * }; - * or - * Foo2 ::= [APPLICATION 2] INTEGER - * --> - * class Foo: public AsnInt - * { - * public: - * Foo(): AsnInt() {} - * Foo (int val): AsnInt (int val) {} - * AsnLen BEnc { ....... } <-- holds new tag enc/dec - * void BDec { ....... } <--/ - * int BEncPdu { ....... } - * int BDecPdu { ....... } - * }; - * (must 'inherit' constructors explicitly) - */ - - if (hasNamedElmts = HasNamedElmts (td->type)) - { - fprintf (hdr, " enum\n"); - fprintf (hdr, " {\n"); - FOR_EACH_LIST_ELMT (n, td->type->cxxTypeRefInfo->namedElmts) - { - fprintf (hdr, " %s = %d", n->name, n->value); - if (n != (CNamedElmt *)LAST_LIST_ELMT (td->type->cxxTypeRefInfo->namedElmts)) - fprintf (hdr, ",\n"); - else - fprintf (hdr, "\n"); - } - fprintf (hdr, " };\n"); - } -#if META - if (printMetaG) - { - const char *T, *t; - int a3; - - fprintf (hdr, "\n"); - fprintf (hdr, "#if META\n"); - fprintf (src, "#if META\n\n"); - - fprintf (src, "static AsnType *create%s()\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return new %s;\n", td->cxxTypeDefInfo->className); - fprintf (src, "}\n\n"); - - if (hasNamedElmts = HasNamedElmts (td->type)) - { - fprintf (hdr, " static const AsnNameDesc _nmdescs[];\n"); - - fprintf (src, "const AsnNameDesc %s::_nmdescs[] =\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (n, td->type->cxxTypeRefInfo->namedElmts) -#if 0 /* (no asn1 names available!) */ - if (printMetaG == META_backend_names) - else /* META_asn1_names */ -#endif - fprintf (src, " \"%s\", %s, // %d\n", n->name, n->name, n->value); - fprintf (src, " NULL, -1\n"); - fprintf (src, "};\n\n"); - } - - switch (GetBuiltinType (td->type)) - { - case BASICTYPE_BOOLEAN: - T = "BOOLEAN"; - t = "Bool"; - a3 = FALSE; - break; - case BASICTYPE_ENUMERATED: - T = "ENUMERATED"; - t = "Enum"; - a3 = TRUE; - break; - case BASICTYPE_INTEGER: - T = "INTEGER"; - t = "Int"; - a3 = TRUE; - break; - case BASICTYPE_REAL: - T = "REAL"; - t = "Real"; - a3 = FALSE; - break; - case BASICTYPE_OCTETSTRING: - T = "OCTET_STRING"; - t = "Octs"; - a3 = FALSE; - break; - case BASICTYPE_BITSTRING: - T = "BIT_STRING"; - t = "Bits"; - a3 = TRUE; - break; - case BASICTYPE_OID: - T = "OID"; - t = "Oid"; - a3 = FALSE; - default: - T = - t = "?"; - a3 = FALSE; - } - - fprintf (hdr, " static const Asn%sTypeDesc _desc;\n", t); - fprintf (hdr, " const AsnTypeDesc *_getdesc() const;\n"); - - fprintf (src, "const Asn%sTypeDesc %s::_desc\n", t, td->cxxTypeDefInfo->className); - fprintf (src, "(\n"); - fprintf (src, " &%sModuleDesc,\n", m->cxxname); - if (printMetaG == META_backend_names) - fprintf (src, " \"%s\", // `%s'\n", td->cxxTypeDefInfo->className, td->definedName); - else /* META_asn1_names */ - fprintf (src, " \"%s\", // `%s'\n", td->definedName, td->cxxTypeDefInfo->className); - fprintf (src, " %s,\n", isMetaPDU (m->modId->name, td->definedName, meta_pdus_G) ? "true" : "false"); - fprintf (src, " AsnTypeDesc::%s,\n", T); - fprintf (src, " create%s", td->cxxTypeDefInfo->className); - if (a3) - fprintf (src, ",\n %s", hasNamedElmts ? "_nmdescs" : "NULL"); - fprintf (src, "\n);\n\n"); - - fprintf (src, "const AsnTypeDesc *%s::_getdesc() const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return &_desc;\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, "#endif // META\n"); - fprintf (src, "#endif // META\n\n"); - -#if TCL -#endif - } -#endif /* META */ - - /* - * Re-do BerEncode, BerDeocode, BerDecodePdu and BerDecodePdu - * if this type has been re-tagged - */ - if ((IsDefinedByLibraryType (td->type) && !HasDefaultTag (td->type)) - || (IsTypeRef (td->type) && ((td->type->tags != NULL) && !LIST_EMPTY (td->type->tags)))) - { - /* only BerEn/Decode BerEn/DecodePdu need to be re-done if tags are different */ - - /* print clone routine for ANY mgmt */ - PrintCloneMethod (hdr, src, td); - - tags = GetTags (td->type, &stoleChoiceTags); - typeId = GetBuiltinType (td->type); - - /* do BerEncode function */ - if (printEncodersG) - { - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeBaseName, bufTypeNameG); - fprintf (src, "%s %s::B%s (%s b)\n", lenTypeNameG, td->cxxTypeDefInfo->className, r->encodeBaseName, bufTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s l;\n", lenTypeNameG); - - PrintCxxEocEncoders (src, td, td->type, "b"); - - fprintf (src, " l = BEncContent (b);\n"); - - /* encode each tag/len pair if any */ - if (!stoleChoiceTags) - { - FOR_EACH_LIST_ELMT_RVS (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - - if (tag->form == ANY_FORM) - { - formStr = Form2FormStr (PRIM); - PrintCxxLenEncodingCode (src, FALSE, HasShortLen (td->type), "l", "b"); - } - else - { - formStr = Form2FormStr (tag->form); - PrintCxxLenEncodingCode (src, TRUE, HasShortLen (td->type), "l", "b"); - } - - fprintf (src, "\n"); - tagLen = TagByteLen (tag->code); - - if (tag->tclass == UNIV) - fprintf (src, " l += BEncTag%d (b, %s, %s, %s);\n", tagLen, classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, " l += BEncTag%d (b, %s, %s, %d);\n", tagLen, classStr, formStr, tag->code); - } - } - fprintf (src, " return l;\n"); - fprintf (src, "}\n\n"); - } - /* end of BEnc function */ - - /* Do BDec function */ - if (printDecodersG) - { - fprintf (hdr, " void B%s (%s b, %s &bytesDecoded, %s env);\n", r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - fprintf (src, "void %s::B%s (%s b, %s &bytesDecoded, %s env)\n", td->cxxTypeDefInfo->className, r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s tag;\n", tagTypeNameG); - - /* print extra locals for redundant lengths */ - for (i = 1; (tags != NULL) && (i <= LIST_COUNT (tags)); i++) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i); - if (typeId == BASICTYPE_CHOICE) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i++); - fprintf (src, "\n"); - - /* decode tag/length pair (s) */ - elmtLevel = 0; - if (!stoleChoiceTags) - { - FOR_EACH_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - - if (tag->form == ANY_FORM) - formStr = Form2FormStr (PRIM); - else - formStr = Form2FormStr (tag->form); - - fprintf (src, " if (((tag = BDecTag (b, bytesDecoded, env)) != "); - - if (tag->tclass == UNIV) - { - fprintf (src, "MAKE_TAG_ID (%s, %s, %s))", classStr, formStr, Code2UnivCodeStr (tag->code)); - if (tag->form == ANY_FORM) - fprintf (src, "\n && (tag != MAKE_TAG_ID (%s, %s, %s)))\n", classStr, Form2FormStr (CONS), Code2UnivCodeStr (tag->code)); - else - fprintf (src, ")\n"); - } - else - { - fprintf (src, "MAKE_TAG_ID (%s, %s, %d))", classStr, formStr, tag->code); - if (tag->form == ANY_FORM) - fprintf (src, "\n && (tag != MAKE_TAG_ID (%s, %s, %d)))\n", classStr, Form2FormStr (CONS), tag->code); - else - fprintf (src, ")\n"); - } - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"%s::B%s: ERROR - wrong tag\" << endl;\n", td->cxxTypeDefInfo->className, r->decodeBaseName); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - - fprintf (src, " elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - } - - /* decode first tag from CHOICE's content */ - if (typeId == BASICTYPE_CHOICE) - { - fprintf (src, " tag = BDecTag (b, bytesDecoded, env);\n"); - fprintf (src, " elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - - fprintf (src, " B%s (b, tag, elmtLen%d, bytesDecoded, env);\n", r->decodeContentBaseName, i-1); - - /* grab any EOCs that match redundant, indef lengths */ - for (i = elmtLevel-1; i > 0; i--) - { - fprintf (src, " if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - } - - fprintf (src, "}\n\n"); - } - /* end of BDec function */ - - PrintPduMemberFcns (src, hdr, r, td->cxxTypeDefInfo->className); - - FreeTags (tags); - } - /* close class def */ - fprintf (hdr, "};\n\n\n"); - - } - else /* isomorphic with referenced type, so just to a typedef */ - { -#ifdef _IBM_ENC_ -#include "./ibm_editor/print_cxx_simple_def1.h" -#endif /* _IBM_ENC_ */ - -#if META - if (printMetaG) - { - fprintf (hdr, "#if META\n"); - fprintf (src, "#if META\n\n"); - - fprintf (src, "static AsnType *create%s()\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return new %s;\n", td->cxxTypeDefInfo->className); - fprintf (src, "}\n\n"); - - fprintf (hdr, "struct %s: public %s\n", td->cxxTypeDefInfo->className, td->type->cxxTypeRefInfo->className); - fprintf (hdr, "{\n"); - - PrintDerivedConstructors (hdr, r, td); - - PrintCloneMethod (hdr, src, td); - - fprintf (hdr, " static const AsnAliasTypeDesc _desc;\n"); - fprintf (hdr, " const AsnTypeDesc *_getdesc() const;\n"); - - fprintf (src, "const AsnAliasTypeDesc %s::_desc\n", td->cxxTypeDefInfo->className); - fprintf (src, "(\n"); - fprintf (src, " &%sModuleDesc,\n", m->cxxname); - if (printMetaG == META_backend_names) - fprintf (src, " \"%s\", // `%s'\n", td->cxxTypeDefInfo->className, td->definedName); - else /* META_asn1_names */ - fprintf (src, " \"%s\", // `%s'\n", td->definedName, td->cxxTypeDefInfo->className); - fprintf (src, " %s,\n", isMetaPDU (m->modId->name, td->definedName, meta_pdus_G) ? "true" : "false"); - fprintf (src, " AsnTypeDesc::ALIAS,\n"); - fprintf (src, " create%s,\n", td->cxxTypeDefInfo->className); - fprintf (src, " &%s::_desc\n);\n\n", td->type->cxxTypeRefInfo->className); - - fprintf (src, "const AsnTypeDesc *%s::_getdesc() const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return &_desc;\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, "};\n\n"); - - fprintf (hdr, "#else // META\n\n"); - fprintf (src, "#endif // META\n\n"); - } -#endif /* META */ - - fprintf (hdr, "typedef %s %s;\n\n", td->type->cxxTypeRefInfo->className, td->cxxTypeDefInfo->className); - -#if META - if (printMetaG) - fprintf (hdr, "#endif // META\n\n"); -#endif /* META */ - } -} /* PrintCxxSimpleDef */ - -static void -PrintCxxChoiceDefCode PARAMS ((src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, parent, choice, novolatilefuncs), - FILE *src _AND_ - FILE *hdr _AND_ - if_IBM_ENC (FILE *srcdb _AND_) - if_IBM_ENC (FILE *hdrdb _AND_) - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *choice _AND_ - int novolatilefuncs) -{ - NamedType *e; - char *classStr; - char *formStr; - char *codeStr; - int tagLen, i; - Tag *tag; - TagList *tags; - char *varName; - CxxTRI *cxxtri; - int elmtLevel; - int varCount, tmpVarCount; - int stoleChoiceTags; - enum BasicTypeChoiceId tmpTypeId; - NamedType *defByNamedType; - -#ifdef _IBM_ENC_ -#include "./ibm_editor/print_cxx_choice_def_code.h" -#endif /* _IBM_ENC_ */ - - /* put class spec in hdr file */ - - fprintf (hdr, "class %s%s\n", td->cxxTypeDefInfo->className, baseClassesG); - fprintf (hdr, "{\n"); - fprintf (hdr, "public:\n"); - - /* write out choiceId enum type */ - - fprintf (hdr, " enum %s\n", r->choiceIdEnumName); - fprintf (hdr, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (hdr, " %s = %d", e->type->cxxTypeRefInfo->choiceIdSymbol, e->type->cxxTypeRefInfo->choiceIdValue); - if (e != (NamedType*)LAST_LIST_ELMT (choice->basicType->a.choice)) - fprintf (hdr, ",\n"); - else - fprintf (hdr, "\n"); - } - fprintf (hdr, " };\n\n"); - - /* write out the choice Id field */ - /* fprintf (hdr, "protected:\n"); */ - fprintf (hdr, " enum %s %s;\n", r->choiceIdEnumName, r->choiceIdFieldName); - - /* write out the choice element anonymous union */ - fprintf (hdr, " union\n"); - fprintf (hdr, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (hdr, " "); - PrintCxxType (hdr, mods, m, r, td, choice, e->type); - fprintf (hdr, "%s;\n", e->type->cxxTypeRefInfo->fieldName); - } - fprintf (hdr, " };\n\n"); - -#if META - if (printMetaG) - { - fprintf (hdr, "#if META\n"); - fprintf (src, "#if META\n\n"); - - fprintf (hdr, " static const AsnChoiceTypeDesc _desc;\n"); - fprintf (hdr, " static const AsnChoiceMemberDesc _mdescs[];\n\n"); - fprintf (hdr, " const AsnTypeDesc *_getdesc() const;\n"); - fprintf (hdr, " AsnType *_getref (const char *membername, bool create = false);\n\n"); - - fprintf (src, "static AsnType *create%s()\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return new %s;\n", td->cxxTypeDefInfo->className); - fprintf (src, "}\n\n"); - - fprintf (src, "const AsnChoiceMemberDesc %s::_mdescs[] =\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - if (printMetaG == META_backend_names) - fprintf (src, " AsnChoiceMemberDesc (\"%s\", &%s::_desc), // `%s'\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className, e->fieldName ? e->fieldName : ""); - else /* META_asn1_names */ - fprintf (src, " AsnChoiceMemberDesc (\"%s\", &%s::_desc), // `%s'\n", e->fieldName ? e->fieldName : e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className, e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " AsnChoiceMemberDesc()\n"); - fprintf (src, "};\n\n"); - - fprintf (src, "const AsnChoiceTypeDesc %s::_desc\n", td->cxxTypeDefInfo->className); - fprintf (src, "(\n"); - fprintf (src, " &%sModuleDesc,\n", m->cxxname); - if (printMetaG == META_backend_names) - fprintf (src, " \"%s\", // `%s'\n", td->cxxTypeDefInfo->className, td->definedName); - else /* META_asn1_names */ - fprintf (src, " \"%s\", // `%s'\n", td->definedName, td->cxxTypeDefInfo->className); - fprintf (src, " %s,\n", isMetaPDU (m->modId->name, td->definedName, meta_pdus_G) ? "true" : "false"); - fprintf (src, " AsnTypeDesc::CHOICE,\n"); - fprintf (src, " create%s,\n", td->cxxTypeDefInfo->className); - fprintf (src, " _mdescs\n"); - fprintf (src, ");\n\n"); - - fprintf (src, "const AsnTypeDesc *%s::_getdesc() const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return &_desc;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "AsnType *%s::_getref (const char *membername, bool create)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " ChoiceIdEnum newCid = (ChoiceIdEnum)_desc.choicebyname (membername);\n"); - fprintf (src, " if (newCid == -1)\n"); - fprintf (src, " return NULL;\n"); - fprintf (src, " if (newCid == choiceId)\n"); - fprintf (src, " {\n"); - fprintf (src, " switch (choiceId)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (src, " case %sCid:\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " return %s;\n", e->type->cxxTypeRefInfo->fieldName); - } - fprintf (src, " default:\n"); - fprintf (src, " return NULL;\n"); - fprintf (src, " }\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " if (create)\n"); - fprintf (src, " {\n"); - fprintf (src, "// switch (choiceId)\n"); - fprintf (src, "// {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (src, "// case %sCid:\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "// delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "// %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "// break;\n"); - } - fprintf (src, "// default:\n"); - fprintf (src, "// return NULL;\n"); - fprintf (src, "// }\n"); - e = FIRST_LIST_ELMT (choice->basicType->a.choice); - fprintf (src, " // simply delete any member, the virtual function table takes care of the rest:\n"); - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " switch (choiceId = newCid)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (src, " case %sCid:\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " return %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - } - fprintf (src, " default: // internal error!\n"); - fprintf (src, " return NULL;\n"); - fprintf (src, " }\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " return NULL;\n"); - fprintf (src, " }\n"); - fprintf (src, "}\n\n"); - -#if TCL - if (printTclG) - { - fprintf (hdr, "#if TCL\n"); - fprintf (src, "#if TCL\n\n"); - - fprintf (hdr, " int TclGetDesc (Tcl_DString *) const;\n"); - fprintf (hdr, " int TclGetVal (Tcl_Interp *) const;\n"); - fprintf (hdr, " int TclSetVal (Tcl_Interp *, const char *valstr);\n\n"); - - fprintf (src, "int %s::TclGetDesc (Tcl_DString *valstr) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Tcl_DStringAppendElement (valstr, (char*)_desc.choicebyvalue (choiceId));\n"); - fprintf (src, " // hack: since all members are pointers, we don't have to check for its type via choiceId, because all we want to know is whether it's NULL or not:\n"); - e = FIRST_LIST_ELMT (choice->basicType->a.choice); - fprintf (src, " Tcl_DStringAppendElement (valstr, %s ? \"valid\" : \"void\");\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclGetVal (Tcl_Interp *interp) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " switch (choiceId)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (src, " case %sCid:\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " if (%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " if (%s->TclGetVal (interp) != TCL_OK)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " break;\n"); - } - fprintf (src, " default:\n"); - fprintf (src, " Tcl_SetResult (interp, \"illegal choiceId in %s\", TCL_STATIC);\n", td->cxxTypeDefInfo->className); - fprintf (src, " Tcl_SetErrorCode (interp, \"SNACC\", \"ILLCHOICE\", NULL);\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " Tcl_DString valstr;\n"); - fprintf (src, " Tcl_DStringInit (&valstr);\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, (char*)_desc.choicebyvalue (choiceId));\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, interp->result);\n"); - fprintf (src, " Tcl_ResetResult (interp);\n"); - fprintf (src, " Tcl_DStringResult (interp, &valstr);\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclSetVal (Tcl_Interp *interp, const char *valstr)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Args elem;\n"); - fprintf (src, " if (Tcl_SplitList (interp, (char*)valstr, &elem.c, &elem.v) != TCL_OK)\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " if (elem.c != 2)\n"); - fprintf (src, " {\n"); - fprintf (src, " sprintf (interp->result, \"syntax error: expected a pair, but it's got %%d element(s)\", elem.c);\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " AsnType *member = _getref (elem.v[0], true);\n"); - fprintf (src, " if (!member)\n"); - fprintf (src, " {\n"); - fprintf (src, " Tcl_AppendResult (interp, \"illegal choice \", elem.v[0], \" for %s\", NULL);\n", td->cxxTypeDefInfo->className); - fprintf (src, " Tcl_SetErrorCode (interp, \"SNACC\", \"ILLCHOICE\", NULL);\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " return member->TclSetVal (interp, elem.v[1]);\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, "#endif // TCL\n"); - fprintf (src, "#endif // TCL\n\n"); - } -#endif /* TCL */ - - fprintf (hdr, "#endif // META\n"); - fprintf (src, "#endif // META\n\n"); - } -#endif /* META */ - - fprintf (hdr, "\n"); - - /* constructors and destructor */ - - fprintf (hdr, " %s();\n", td->cxxTypeDefInfo->className); - - fprintf (src, "%s::%s()\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - e = FIRST_LIST_ELMT (choice->basicType->a.choice); - fprintf (src, " choiceId = %sCid;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "#if TCL\n"); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, "#else\n"); - fprintf (src, " %s = NULL; // incomplete initialization of mandatory element!\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "#endif // TCL\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, " %s (const %s &);\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - - fprintf (src, "%s::%s (const %s &)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Asn1Error << \"use of incompletely defined %s::%s (const %s &)\" << endl;\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, " abort();\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, " virtual ~%s();\n\n", td->cxxTypeDefInfo->className); - - fprintf (src, "%s::~%s()\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " switch (choiceId)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (src, " case %s:\n", e->type->cxxTypeRefInfo->choiceIdSymbol); - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " break;\n"); - } - fprintf (src, " } // end of switch\n"); - fprintf (src, "} // end of destructor\n"); - fprintf (src, "\n"); - - /* print clone routine for ANY mgmt */ - PrintCloneMethod (hdr, src, td); - - fprintf (hdr, " %s &operator = (const %s &);\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - - fprintf (src, "#if SNACC_DEEP_COPY\n"); - fprintf (src, "%s &%s::operator = (const %s &that)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "#else // SNACC_DEEP_COPY\n"); - fprintf (src, "%s &%s::operator = (const %s &)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "#endif // SNACC_DEEP_COPY\n"); - fprintf (src, "{\n"); - fprintf (src, "#if SNACC_DEEP_COPY\n"); - fprintf (src, " if (this != &that)\n"); - fprintf (src, " {\n"); - fprintf (src, " switch (choiceId)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " case %s:\n", e->type->cxxTypeRefInfo->choiceIdSymbol); - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " break;\n"); - } - } - fprintf (src, " }\n"); - fprintf (src, " switch (choiceId = that.choiceId)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (src, " case %s:\n", e->type->cxxTypeRefInfo->choiceIdSymbol); - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, " *%s = *that.%s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->fieldName); - } - else - fprintf (src, " %s = that.%s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " break;\n"); - } - fprintf (src, " }\n"); - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " return *this;\n"); - fprintf (src, "#else // SNACC_DEEP_COPY\n"); - fprintf (src, " Asn1Error << \"use of incompletely defined %s &%s::operator = (const %s &)\" << endl;\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, " abort();\n"); - fprintf (src, " // if your compiler complains here, check the -novolat option\n"); - if (novolatilefuncs) - { - fprintf (src, " return *this;\n"); - } - fprintf (src, "#endif // SNACC_DEEP_COPY\n"); - fprintf (src, "}\n\n"); - - /* BerEncodeContent */ - if (printEncodersG) - { - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeContentBaseName, bufTypeNameG); - - fprintf (src, "%s\n", lenTypeNameG); - fprintf (src, "%s::B%s (%s b)\n", td->cxxTypeDefInfo->className, r->encodeContentBaseName, bufTypeNameG); - fprintf (src, "{\n"); - - /* print local vars */ - fprintf (src, " %s l;\n", lenTypeNameG); - - fprintf (src, " switch (%s)\n", r->choiceIdFieldName); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - cxxtri = e->type->cxxTypeRefInfo; - fprintf (src, " case %s:\n", cxxtri->choiceIdSymbol); - - varName = cxxtri->fieldName; - - /* encode Eoc (s) if nec */ - PrintCxxEocEncoders (src, td, e->type, "b"); - - /* encode content */ - tmpTypeId = GetBuiltinType (e->type); - if (tmpTypeId == BASICTYPE_ANYDEFINEDBY) - { - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - defByNamedType = e->type->basicType->a.anyDefinedBy->link; - if (GetBuiltinType (defByNamedType->type) == BASICTYPE_OID) - { - fprintf (src, "SetTypeByOid ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - else - { - fprintf (src, "SetTypeByInt ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b);\n", r->encodeBaseName); - } - else if (tmpTypeId == BASICTYPE_ANY) - { -#ifdef VDADER_RULES -if (! gVDADER_RULES) -{ -#endif - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "SetTypeBy???(???);\n"); - - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b);\n", r->encodeBaseName); - -#ifdef VDADER_RULES -} -else -{ - fprintf (src, " ENC_LOAD_ANYBUF("); - if (!cxxtri->isPtr) - fprintf (src, "&"); - fprintf (src, "%s, b, l);\n", varName); -} -#endif - } - else - { - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - fprintf (src, "B%s (b);\n", r->encodeContentBaseName); - } - - - /* encode tag (s) & len (s) */ - PrintCxxTagAndLenEncodingCode (src, td, e->type, "l", "b"); - - - fprintf (src, " break;\n\n"); - } - fprintf (src, " } // end switch\n"); - - fprintf (src, " return l;\n"); - fprintf (src, "} // %s::B%s\n\n\n", td->cxxTypeDefInfo->className, r->encodeContentBaseName); - } - /* end of BerEncodeContent method */ - - /* BerDecodeContent */ - if (printDecodersG) - { - fprintf (hdr, " void B%s (%s b, %s tag, %s elmtLen, %s &bytesDecoded, %s env);\n", r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "void %s::B%s (%s b, %s tag, %s elmtLen0, %s &bytesDecoded, %s env)\n", td->cxxTypeDefInfo->className, r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "{\n"); - - /* print local vars */ - /* count max number of extra length var nec - * by counting tag/len pairs on components of the CHOICE - */ - varCount = 0; - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - tmpVarCount = CxxCountVariableLevels (e->type); - if (tmpVarCount > varCount) - varCount = tmpVarCount; - } - /* write extra length vars - remeber choice content - * decoders are passed the 'key' tag so need one less - * than max var count. - */ - for (i = 1; i < varCount; i++) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i); - - /* switch on given tag - choices always have the key tag decoded */ - fprintf (src, " switch (tag)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - cxxtri = e->type->cxxTypeRefInfo; - - tags = GetTags (e->type, &stoleChoiceTags); - - if (LIST_EMPTY (tags)) - { - fprintf (src, " // ANY Type?\n"); - fprintf (src, " case MAKE_TAG_ID (?, ?, ?):\n"); - } - else - { - tag = (Tag*)FIRST_LIST_ELMT (tags); - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, formStr, tag->code); - } - - /* now decode extra tags/length pairs */ - AsnListFirst (tags); - AsnListNext (tags); - elmtLevel = 0; - if (stoleChoiceTags) - { - FOR_REST_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, formStr, tag->code); - } - } - } - else /* didn't steal nested choice's tags */ - { - FOR_REST_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - fprintf (src, " tag = BDecTag (b, bytesDecoded, env);\n"); - if (tag->form == ANY_FORM) - { - if (tag->tclass == UNIV) - { - fprintf (src, " if ((tag != MAKE_TAG_ID (%s, %s, %s))\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " && (tag != MAKE_TAG_ID (%s, %s, %s)))\n", classStr, Form2FormStr (CONS), codeStr); - } - else - { - fprintf (src, " if ((tag != MAKE_TAG_ID (%s, %s, %d))\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " && (tag != MAKE_TAG_ID (%s, %s, %d)))\n", classStr, Form2FormStr (CONS), tag->code); - } - - } - else - { - if (tag->tclass == UNIV) - fprintf (src, " if (tag != MAKE_TAG_ID (%s, %s, %s))\n", classStr, formStr, codeStr); - else - fprintf (src, " if (tag != MAKE_TAG_ID (%s, %s, %d))\n", classStr, formStr, tag->code); - } - - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"Unexpected Tag\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n\n"); - - fprintf (src, " elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - } - } - /* - * if the choices element is another choice && - * we didn't steal its tags then we must grab - * the key tag out of the contained CHOICE - */ - if (!stoleChoiceTags && (GetBuiltinType (e->type) == BASICTYPE_CHOICE)) - { - fprintf (src, " tag = BDecTag (b, bytesDecoded, env);\n"); - fprintf (src, " elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - - varName = cxxtri->fieldName; - - /* set choice id for to this elment */ - fprintf (src, " %s = %s;\n", r->choiceIdFieldName, cxxtri->choiceIdSymbol); - - /* alloc elmt if nec */ - if (cxxtri->isPtr) - fprintf (src, " %s = new %s;\n", varName, cxxtri->className); - - /* decode content */ - tmpTypeId = GetBuiltinType (e->type); - if (tmpTypeId == BASICTYPE_ANYDEFINEDBY) - { - /* - * must check for another EOC for ANYs - * since the any decode routines decode - * their own first tag/len pair - */ - elmtLevel++; - - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - defByNamedType = e->type->basicType->a.anyDefinedBy->link; - if (GetBuiltinType (defByNamedType->type) == BASICTYPE_OID) - { - fprintf (src, "SetTypeByOid ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - else - { - fprintf (src, "SetTypeByInt ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b, bytesDecoded, env);\n", r->decodeBaseName); - } - else if (tmpTypeId == BASICTYPE_ANY) - { - /* - * must check for another EOC for ANYs - * since the any decode routines decode - * their own first tag/len pair - */ - elmtLevel++; - -#ifdef VDADER_RULES -if (! gVDADER_RULES ) -{ -#endif - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "SetTypeBy???(???);\n"); - - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b, bytesDecoded, env);\n", r->decodeBaseName); - -#ifdef VDADER_RULES -} -else - { - fprintf (src, " DEC_LOAD_ANYBUF("); - if (!cxxtri->isPtr) - fprintf (src, "&"); - fprintf (src, "%s, b, bytesDecoded, env);\n", varName); - } -#endif - } - else - { - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - fprintf (src, "B%s (b, tag, elmtLen%d, bytesDecoded, env);\n", r->decodeContentBaseName, elmtLevel); - } - - /* decode Eoc (s) */ - for (i = elmtLevel-1; i >= 0; i--) - { - fprintf (src, " if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - } - - fprintf (src, " break;\n\n"); - FreeTags (tags); - } - - fprintf (src, " default:\n"); - fprintf (src, " Asn1Error << \"ERROR - unexpected tag in CHOICE\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " break;\n"); - - fprintf (src, " } // end switch\n"); - fprintf (src, "} // %s::B%s\n\n\n", td->cxxTypeDefInfo->className, r->decodeContentBaseName); - } - /* end of code for printing BDecodeContent method */ - - /* do BEnc function */ - if (printEncodersG) - { - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeBaseName, bufTypeNameG); - fprintf (src, "%s %s::B%s (%s b)\n", lenTypeNameG, td->cxxTypeDefInfo->className, r->encodeBaseName, bufTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s l;\n", lenTypeNameG); - fprintf (src, " l = B%s (b);\n", r->encodeContentBaseName); - - /* encode each tag/len pair if any */ - FOR_EACH_LIST_ELMT_RVS (tag, choice->tags) - { - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (CONS); /* choices are constructed */ - tagLen = TagByteLen (tag->code); - - fprintf (src, " l += BEncConsLen (b, l);\n"); - - if (tag->tclass == UNIV) - fprintf (src, " l += BEncTag%d (b, %s, %s, %s);\n", tagLen, classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, " l += BEncTag%d (b, %s, %s, %d);\n", tagLen, classStr, formStr, tag->code); - } - fprintf (src, " return l;\n"); - fprintf (src, "}\n\n"); - } - /* end of BEnc function */ - - /* Do BDec function */ - if (printDecodersG) - { - fprintf (hdr, " void B%s (%s b, %s &bytesDecoded, %s env);\n", r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "void %s::B%s (%s b, %s &bytesDecoded, %s env)\n", td->cxxTypeDefInfo->className, r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s elmtLen;\n", lenTypeNameG); - fprintf (src, " %s tag;\n", tagTypeNameG); - - /* print extra locals for redundant lengths */ - for (i = 1; (choice->tags != NULL) && (i <= LIST_COUNT (choice->tags)); i++) - { - fprintf (src, " %s extraLen%d;\n", lenTypeNameG, i); - } - fprintf (src, "\n"); - - /* decode tag/length pair (s) */ - elmtLevel = 0; - FOR_EACH_LIST_ELMT (tag, choice->tags) - { - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (CONS); /* choices are constructed */ - - fprintf (src, " if (BDecTag (b, bytesDecoded, env) != "); - if (tag->tclass == UNIV) - fprintf (src, "MAKE_TAG_ID (%s, %s, %s))", classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, "MAKE_TAG_ID (%s, %s, %d))", classStr, formStr, tag->code); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"%s::B%s: ERROR - wrong tag\" << endl;\n", td->cxxTypeDefInfo->className, r->decodeBaseName); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - fprintf (src, " extraLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - - /* decode identifying tag from choice body */ - fprintf (src, " /* CHOICEs are a special case - grab identifying tag */\n"); - fprintf (src, " /* this allows easier handling of nested CHOICEs */\n"); - fprintf (src, " tag = BDecTag (b, bytesDecoded, env);\n"); - fprintf (src, " elmtLen = BDecLen (b, bytesDecoded, env);\n"); - fprintf (src, " B%s (b, tag, elmtLen, bytesDecoded, env);\n", r->decodeContentBaseName); - - /* grab any EOCs that match redundant, indef lengths */ - for (i = elmtLevel; i > 0; i--) - { - fprintf (src, " if (extraLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - } - - fprintf (src, "}\n\n"); - } - /* end of BDec function */ - - PrintPduMemberFcns (src, hdr, r, td->cxxTypeDefInfo->className); - - /* ostream printing routine */ - if (printPrintersG) - { - fprintf (hdr, " void Print (ostream &os) const;\n", td->cxxTypeDefInfo->className); - - fprintf (src, "void %s::Print (ostream &os) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - #ifdef __APPLE__ - fprintf (src, "#ifndef NDEBUG\n"); - #endif - /* fprintf (src, " os << \"{\" << endl;\n") */ - fprintf (src, " switch (choiceId)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (src, " case %s:\n", e->type->cxxTypeRefInfo->choiceIdSymbol); - - /* value notation so print the choice elmts field name */ - if (e->fieldName != NULL) - fprintf (src, " os << \"%s \";\n", e->fieldName); - - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " if (%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " os << *%s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " else\n"); -#ifdef KHO - fprintf (src, " os << \"-- void3 --\\n\";\n", e->type->cxxTypeRefInfo->fieldName); -#else - fprintf (src, " os << \"-- void --\";\n", e->type->cxxTypeRefInfo->fieldName); -#endif - } - else - fprintf (src, " os << %s;\n", e->type->cxxTypeRefInfo->fieldName); - - fprintf (src, " break;\n\n"); - } - fprintf (src, " } // end of switch\n"); - - #ifdef __APPLE__ - fprintf (src, "#endif /* NDEBUG */\n"); - #endif - /* fprintf (src, " os << \"}\" << endl;\n") */ - fprintf (src, "} // %s::Print\n\n", td->cxxTypeDefInfo->className); - } - /* end of Print Method code */ - - /* close class definition */ - fprintf (hdr, "};\n\n\n"); - -} /* PrintCxxChoiceDefCode */ - - - -static void -PrintCxxSeqDefCode PARAMS ((src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, parent, seq, novolatilefuncs), - FILE *src _AND_ - FILE *hdr _AND_ - if_IBM_ENC (FILE *srcdb _AND_) - if_IBM_ENC (FILE *hdrdb _AND_) - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *seq _AND_ - int novolatilefuncs) -{ - NamedType *e; - char *classStr; - char *formStr; - char *codeStr; - int tagLen, i; - Tag *tag; - TagList *tags; - char *varName; - CxxTRI *cxxtri; - int elmtLevel; - int varCount, tmpVarCount; - int stoleChoiceTags; - int inTailOptElmts; - enum BasicTypeChoiceId tmpTypeId; - NamedType *defByNamedType; - NamedType *tmpElmt; - int allOpt; - -#ifdef _IBM_ENC_ -#include "./ibm_editor/print_cxx_seq_def_code.h" -#endif /* _IBM_ENC_ */ - - /* put class spec in hdr file */ - - fprintf (hdr, "class %s%s\n", td->cxxTypeDefInfo->className, baseClassesG); - fprintf (hdr, "{\n"); - fprintf (hdr, "public:\n"); - - /* write out the sequence elmts */ - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - fprintf (hdr, " "); - PrintCxxType (hdr, mods, m, r, td, seq, e->type); - fprintf (hdr, "%s;\n", e->type->cxxTypeRefInfo->fieldName); - } - - fprintf (hdr, "\n"); - -#if META - if (printMetaG) - { - fprintf (hdr, "#if META\n"); - fprintf (src, "#if META\n\n"); - - fprintf (hdr, " static const AsnSequenceTypeDesc _desc;\n"); - fprintf (hdr, " static const AsnSequenceMemberDesc _mdescs[];\n"); - fprintf (hdr, " const AsnTypeDesc *_getdesc() const;\n"); - fprintf (hdr, " AsnType *_getref (const char *membername, bool create = false);\n\n"); - - fprintf (src, "static AsnType *create%s()\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return new %s;\n", td->cxxTypeDefInfo->className); - fprintf (src, "}\n\n"); - - fprintf (src, "const AsnSequenceMemberDesc %s::_mdescs[] =\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - if (printMetaG == META_backend_names) - fprintf (src, " AsnSequenceMemberDesc (\"%s\", &%s::_desc, %s), // `%s'\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className, e->type->optional || e->type->defaultVal ? "true" : "false", e->fieldName ? e->fieldName : ""); - else /* META_asn1_names */ - fprintf (src, " AsnSequenceMemberDesc (\"%s\", &%s::_desc, %s), // `%s'\n", e->fieldName ? e->fieldName : e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className, e->type->optional || e->type->defaultVal ? "true" : "false", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " AsnSequenceMemberDesc()\n"); - fprintf (src, "};\n\n"); - - fprintf (src, "const AsnSequenceTypeDesc %s::_desc\n", td->cxxTypeDefInfo->className); - fprintf (src, "(\n"); - fprintf (src, " &%sModuleDesc,\n", m->cxxname); - if (printMetaG == META_backend_names) - fprintf (src, " \"%s\", // `%s'\n", td->cxxTypeDefInfo->className, td->definedName); - else /* META_asn1_names */ - fprintf (src, " \"%s\", // `%s'\n", td->definedName, td->cxxTypeDefInfo->className); - fprintf (src, " %s,\n", isMetaPDU (m->modId->name, td->definedName, meta_pdus_G) ? "true" : "false"); - fprintf (src, " AsnTypeDesc::SEQUENCE,\n"); - fprintf (src, " create%s,\n", td->cxxTypeDefInfo->className); - fprintf (src, " _mdescs\n"); - fprintf (src, ");\n\n"); - - fprintf (src, "const AsnTypeDesc *%s::_getdesc() const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return &_desc;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "AsnType *%s::_getref (const char *membername, bool create)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - fprintf (src, " if (!strcmp (membername, \"%s\"))\n", e->type->cxxTypeRefInfo->fieldName); - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " {\n"); - fprintf (src, " if (!%s && create)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, " return %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " }\n"); - } - else - fprintf (src, " return &%s;\n", e->type->cxxTypeRefInfo->fieldName); - } - fprintf (src, " return NULL;\n"); - fprintf (src, "}\n\n"); - -#if TCL - if (printTclG) - { - fprintf (hdr, "#if TCL\n"); - fprintf (src, "#if TCL\n\n"); - - fprintf (hdr, " int TclGetDesc (Tcl_DString *) const;\n"); - fprintf (hdr, " int TclGetVal (Tcl_Interp *) const;\n"); - fprintf (hdr, " int TclSetVal (Tcl_Interp *, const char *valstr);\n"); - fprintf (hdr, " int TclUnsetVal (Tcl_Interp *, const char *membname);\n\n"); - - fprintf (src, "int %s::TclGetDesc (Tcl_DString *valstr) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Tcl_DStringStartSublist (valstr);\n\n"); - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - fprintf (src, " Tcl_DStringStartSublist (valstr);\n"); - fprintf (src, " Tcl_DStringAppendElement (valstr, \"%s\");\n", e->type->cxxTypeRefInfo->fieldName); - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " Tcl_DStringAppendElement (valstr, %s ? \"valid\" : \"void\");\n", e->type->cxxTypeRefInfo->fieldName); - else - fprintf (src, " Tcl_DStringAppendElement (valstr, \"valid\");\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " Tcl_DStringEndSublist (valstr);\n\n"); - } - fprintf (src, " Tcl_DStringEndSublist (valstr);\n\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclGetVal (Tcl_Interp *interp) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Tcl_DString valstr;\n\n"); - fprintf (src, " Tcl_DStringInit (&valstr);\n\n"); - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " if (%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - fprintf (src, " Tcl_DStringStartSublist (&valstr);\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, \"%s\");\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " if (%s->TclGetVal (interp) != TCL_OK)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " goto Error;\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, interp->result);\n"); - fprintf (src, " Tcl_ResetResult (interp);\n"); - fprintf (src, " Tcl_DStringEndSublist (&valstr);\n"); - fprintf (src, " }\n\n"); - } - else - { - fprintf (src, " Tcl_DStringStartSublist (&valstr);\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, \"%s\");\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " if (%s.TclGetVal (interp) != TCL_OK)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " goto Error;\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, interp->result);\n"); - fprintf (src, " Tcl_ResetResult (interp);\n"); - fprintf (src, " Tcl_DStringEndSublist (&valstr);\n\n"); - } - } - fprintf (src, " Tcl_DStringResult (interp, &valstr);\n"); - fprintf (src, " return TCL_OK;\n\n"); - fprintf (src, "Error:\n"); - fprintf (src, " Tcl_DStringFree (&valstr);\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclSetVal (Tcl_Interp *interp, const char *valstr)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " int i;\n"); - fprintf (src, " Args elems;\n"); - fprintf (src, " if (Tcl_SplitList (interp, (char*)valstr, &elems.c, &elems.v) != TCL_OK)\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " Args* elempairs = new Args[elems.c];\n"); - fprintf (src, " for (i=0; iresult, \"syntax error in element #%%d: expected a pair, but it's got %%d element(s)\", i, elempairs[i].c);\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " for (const AsnSequenceMemberDesc *m=_mdescs; m->name; m++)\n"); - fprintf (src, " {\n"); - fprintf (src, " int count = 0;\n"); - fprintf (src, " for (i=0; iname))\n"); - fprintf (src, " count++;\n"); - fprintf (src, " if (count > 1)\n"); - fprintf (src, " {\n"); - fprintf (src, " sprintf (interp->result, \"duplicate value for member \\\"%%s\\\" in list\", m->name);\n"); - fprintf (src, " Tcl_SetErrorCode (interp, \"SNACC\", \"DUPMEMB\", NULL);\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " if (!m->optional && count < 1)\n"); - fprintf (src, " {\n"); - fprintf (src, " sprintf (interp->result, \"mandatory member \\\"%%s\\\" is missing in list\", m->name);\n"); - fprintf (src, " Tcl_SetErrorCode (interp, \"SNACC\", \"MISSMAND\", NULL);\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " \n"); - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " for (i=0; ibasicType->a.sequence) - { - fprintf (src, " if (!strcmp (elempairs[i].v[0], \"%s\"))\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " if (!%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, " if (%s->TclSetVal (interp, elempairs[i].v[1]))\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - } - else - { - fprintf (src, " if (%s.TclSetVal (interp, elempairs[i].v[1]))\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - } - fprintf (src, " }\n"); - } - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " // look for unmentioned optional members and delete them:\n"); - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - if (e->type->optional || e->type->defaultVal) - { - fprintf (src, " {\n"); - fprintf (src, " bool present = false;\n"); - fprintf (src, " for (i=0; itype->cxxTypeRefInfo->fieldName); - fprintf (src, " present = true;\n"); - fprintf (src, " if (!present)\n"); - fprintf (src, " {\n"); - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " }\n"); - fprintf (src, " }\n"); - } - } - fprintf (src, "\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclUnsetVal (Tcl_Interp *interp, const char *membernames)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Args elems;\n"); - fprintf (src, " if (Tcl_SplitList (interp, (char*)membernames, &elems.c, &elems.v) != TCL_OK)\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, "\n"); - fprintf (src, " for (int i=0; ibasicType->a.sequence) - { - fprintf (src, " if (!strcmp (elems.v[i], \"%s\"))\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - if (e->type->optional || e->type->defaultVal) - { - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - } - else - { - fprintf (src, " return _desc.mandatmemberr (interp, elems.v[i]);\n"); - } - fprintf (src, " }\n"); - } - fprintf (src, " }\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, "#endif // TCL\n"); - fprintf (src, "#endif // TCL\n\n"); - } -#endif /* TCL */ - - fprintf (hdr, "#endif // META\n\n"); - fprintf (src, "#endif // META\n\n"); - } -#endif /* META */ - - /* constructors and destructor: */ - - fprintf (hdr, " %s();\n", td->cxxTypeDefInfo->className); - - fprintf (src, "%s::%s()\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - if (e->type->cxxTypeRefInfo->isPtr) - if (e->type->optional || e->type->defaultVal) - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - else - { - fprintf (src, "#if TCL\n"); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, "#else\n"); - fprintf (src, " %s = NULL; // incomplete initialization of mandatory element!\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "#endif // TCL\n"); - } - } - fprintf (src, "}\n\n"); - - fprintf (hdr, " %s (const %s &);\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - - fprintf (src, "%s::%s (const %s &)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Asn1Error << \"use of incompletely defined %s::%s (const %s &)\" << endl;\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, " abort();\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, " virtual ~%s();\n", td->cxxTypeDefInfo->className); - - fprintf (src, "%s::~%s()\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "}\n\n"); - - /* print clone routine for ANY mgmt */ - PrintCloneMethod (hdr, src, td); - - fprintf (hdr, " %s &operator = (const %s &);\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - - fprintf (src, "#if SNACC_DEEP_COPY\n"); - fprintf (src, "%s &%s::operator = (const %s &that)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "#else // SNACC_DEEP_COPY\n"); - fprintf (src, "%s &%s::operator = (const %s &)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "#endif // SNACC_DEEP_COPY\n"); - fprintf (src, "{\n"); - fprintf (src, "#if SNACC_DEEP_COPY\n"); - fprintf (src, " if (this != &that)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " if (that.%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - fprintf (src, " if (!%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, " *%s = *that.%s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " }\n"); - } - else - fprintf (src, " %s = that.%s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->fieldName); - } - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " return *this;\n"); - fprintf (src, "#else // SNACC_DEEP_COPY\n"); - fprintf (src, " Asn1Error << \"use of incompletely defined %s &%s::operator = (const %s &)\" << endl;\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, " abort();\n"); - fprintf (src, " // if your compiler complains here, check the -novolat option\n"); - if (novolatilefuncs) - { - fprintf (src, " return *this;\n"); - } - fprintf (src, "#endif // SNACC_DEEP_COPY\n"); - fprintf (src, "}\n\n"); - - /* BerEncodeContent method */ - if (printEncodersG) - { - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeContentBaseName, bufTypeNameG); - - fprintf (src, "%s\n", lenTypeNameG); - fprintf (src, "%s::B%s (%s b)\n", td->cxxTypeDefInfo->className, r->encodeContentBaseName, bufTypeNameG); - - fprintf (src, "{\n"); - - /* print local vars */ - fprintf (src, " %s totalLen = 0;\n", lenTypeNameG); - fprintf (src, " %s l;\n\n", lenTypeNameG); - - FOR_EACH_LIST_ELMT_RVS (e, seq->basicType->a.sequence) - { - cxxtri = e->type->cxxTypeRefInfo; - - varName = cxxtri->fieldName; - - /* print optional test if nec */ - if (e->type->optional || (e->type->defaultVal != NULL)) - { - fprintf (src, " if (%s (%s))\n", cxxtri->optTestRoutineName, varName); - fprintf (src, " {\n"); - } - - /* encode Eoc (s) if nec */ - PrintCxxEocEncoders (src, td, e->type, "b"); - - /* encode content */ - tmpTypeId = GetBuiltinType (e->type); - if (tmpTypeId == BASICTYPE_ANYDEFINEDBY) - { - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - defByNamedType = e->type->basicType->a.anyDefinedBy->link; - if (GetBuiltinType (defByNamedType->type) == BASICTYPE_OID) - { - fprintf (src, "SetTypeByOid ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - else - { - fprintf (src, "SetTypeByInt ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b);\n", r->encodeBaseName); - } - else if (tmpTypeId == BASICTYPE_ANY) - { -#ifdef VDADER_RULES -if (! gVDADER_RULES) -{ -#endif - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "SetTypeBy???(???);\n"); - - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b);\n", r->encodeBaseName); - -#ifdef VDADER_RULES -} -else - { - fprintf (src, " ENC_LOAD_ANYBUF("); - if (!cxxtri->isPtr) - fprintf (src, "&"); - fprintf (src, "%s, b, l);\n", varName); - } -#endif - } - else - { - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - fprintf (src, "B%s (b);\n", r->encodeContentBaseName); - } - - - /* encode tag (s) & len (s) */ - PrintCxxTagAndLenEncodingCode (src, td, e->type, "l", "b"); - - - fprintf (src, " totalLen += l;\n"); - - /* close optional test if nec */ - if (e->type->optional || (e->type->defaultVal != NULL)) - fprintf (src, " }\n\n"); - else - fprintf (src, "\n"); - } - fprintf (src, " return totalLen;\n"); - fprintf (src, "} // %s::B%s\n\n\n", td->cxxTypeDefInfo->className, r->encodeContentBaseName); - } - /* end of BerEncodeContent method printing code */ - - /* write BerDecodeContent to src */ - if (printDecodersG) - { - fprintf (hdr, " void B%s (%s b, %s tag, %s elmtLen, %s &bytesDecoded, %s env);\n\n", r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "void %s::B%s (%s b, %s /*tag0*/, %s elmtLen0, %s &bytesDecoded, %s env)\n", td->cxxTypeDefInfo->className, r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "{\n"); - - /* print local vars */ - fprintf (src, " %s tag1;\n", tagTypeNameG); - fprintf (src, " %s seqBytesDecoded = 0;\n", lenTypeNameG); - /* count max number of extra length var nec */ - varCount = 0; - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - tmpVarCount = CxxCountVariableLevels (e->type); - - if (tmpVarCount > varCount) - varCount = tmpVarCount; - } - /* write extra length vars */ - for (i = 1; i <= varCount; i++) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i); - - /* handle empty seq */ - if ((seq->basicType->a.sequence == NULL) || LIST_EMPTY (seq->basicType->a.sequence)) - { - fprintf (src, " if (elmtLen0 == INDEFINITE_LEN)\n"); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - fprintf (src, " else if (elmtLen0 != 0)\n"); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"Expected an empty sequence\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - -/* - forget about posssible extensions to the type - fprintf (src, " {\n"); - fprintf (src, " tag1 = BDecTag (b, bytesDecoded, env);\n\n"); - fprintf (src, " if (tag1 == EOC_TAG_ID)\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, bytesDecoded, env)\n"); - fprintf (src, " else\n"); - - fprintf (src, " BerDiscardElmt (b, bytesDecoded, env);\n\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " BufSkip (b, elmtLen0);\n"); - fprintf (src, " bytesDecoded%d += elmtLen0;\n"); - fprintf (src, " }\n"); -*/ - } - else - { - /* check if all elmts are optional */ - AsnListFirst (seq->basicType->a.sequence); - inTailOptElmts = IsTailOptional (seq->basicType->a.sequence); - e = (NamedType*)FIRST_LIST_ELMT (seq->basicType->a.sequence); - - tmpTypeId = GetBuiltinType (e->type); - - if (!inTailOptElmts) - { - if (((tmpTypeId == BASICTYPE_ANY) || (tmpTypeId == BASICTYPE_ANYDEFINEDBY)) && (CountTags (e->type) == 0)) - { - if ((e->type->optional) && (e != (NamedType*)LAST_LIST_ELMT (seq->basicType->a.sequence))) - fprintf (src, "\n"); - } - else - fprintf (src, " tag1 = BDecTag (b, seqBytesDecoded, env);\n\n"); - } - else - { - fprintf (src, " if (elmtLen0 == 0)\n"); - fprintf (src, " return;\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - if (((tmpTypeId == BASICTYPE_ANY) || (tmpTypeId == BASICTYPE_ANYDEFINEDBY)) && (CountTags (e->type) == 0)) - { - if ((e->type->optional) && (e != (NamedType*)LAST_LIST_ELMT (seq->basicType->a.sequence))) - fprintf (src, "\n"); - } - else - fprintf (src, " tag1 = BDecTag (b, seqBytesDecoded, env);\n\n"); - fprintf (src, " if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))\n"); - fprintf (src, " {\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)\n"); - fprintf (src, " bytesDecoded += seqBytesDecoded;\n"); - fprintf (src, " return;\n"); - fprintf (src, " }\n"); - fprintf (src, " }\n\n"); - } - - - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - cxxtri = e->type->cxxTypeRefInfo; - elmtLevel = 0; - - tags = GetTags (e->type, &stoleChoiceTags); - - /* if (inTailOptElmts) - fprintf (src, " (!seqDone) && "); - */ - if (LIST_EMPTY (tags)) - fprintf (src, " // ANY type\n"); - else - { - tag = (Tag*)FIRST_LIST_ELMT (tags); - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - fprintf (src, " if ("); - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src, "(tag1 == MAKE_TAG_ID (%s, %s, %s))\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " || (tag1 == MAKE_TAG_ID (%s, %s, %s))", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src, "(tag1 == MAKE_TAG_ID (%s, %s, %s))", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src, "(tag1 == MAKE_TAG_ID (%s, %s, %d))\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " || (tag1 == MAKE_TAG_ID (%s, %s, %d))", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src, "(tag1 == MAKE_TAG_ID (%s, %s, %d))", classStr, formStr, tag->code); - } - - - /* now decode extra tags/length pairs */ - AsnListFirst (tags); - AsnListNext (tags); - if (stoleChoiceTags) - { - FOR_REST_LIST_ELMT (tag, tags) - { - fprintf (src, "\n || "); - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src, "(tag1 == MAKE_TAG_ID (%s, %s, %s))\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " || (tag1 == MAKE_TAG_ID (%s, %s, %s))", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src, "(tag1 == MAKE_TAG_ID (%s, %s, %s))", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src, "(tag1 == MAKE_TAG_ID (%s, %s, %d))\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " || (tag1 == MAKE_TAG_ID (%s, %s, %d))", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src, "(tag1 == MAKE_TAG_ID (%s, %s, %d))", classStr, formStr, tag->code); - } - } - fprintf (src, ")\n"); - fprintf (src, " {\n"); - fprintf (src, " elmtLen%d = BDecLen (b, seqBytesDecoded, env);\n", ++elmtLevel); - } - - else /* didn't steal nested choice's tags */ - { - fprintf (src, ")\n"); - fprintf (src, " {\n"); - fprintf (src, " elmtLen%d = BDecLen (b, seqBytesDecoded, env);\n", ++elmtLevel); - - FOR_REST_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - fprintf (src, " tag1 = BDecTag (b, seqBytesDecoded, env);\n\n"); - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src, " if ((tag1 != MAKE_TAG_ID (%s, %s, %s))\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " && (tag1 != MAKE_TAG_ID (%s, %s, %s)))\n", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src, " if (tag1 != MAKE_TAG_ID (%s, %s, %s))\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src, " if ((tag1 != MAKE_TAG_ID (%s, %s, %d))\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " && (tag1 != MAKE_TAG_ID (%s, %s, %d)))\n", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src, " if (tag1 != MAKE_TAG_ID (%s, %s, %d))\n", classStr, formStr, tag->code); - } - - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"Unexpected Tag\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n\n"); - fprintf (src, " elmtLen%d = BDecLen (b, seqBytesDecoded, env);\n", ++elmtLevel); - } - } - } - /* - * if this seq element is CHOICE && - * we didn't steal its tags then we must grab - * the key tag out of the contained CHOICE - */ - if (!stoleChoiceTags && (GetBuiltinType (e->type) == BASICTYPE_CHOICE)) - { - fprintf (src, " tag1 = BDecTag (b, seqBytesDecoded, env);\n"); - fprintf (src, " elmtLen%d = BDecLen (b, seqBytesDecoded, env);\n", ++elmtLevel); - } - - - - varName = cxxtri->fieldName; - - /* decode content */ - if (cxxtri->isPtr) - fprintf (src, " %s = new %s;\n", varName, cxxtri->className); - - - /* decode content */ - tmpTypeId = GetBuiltinType (e->type); - if (tmpTypeId == BASICTYPE_ANYDEFINEDBY) - { - /* - * must check for another EOC for ANYs - * since the any decode routines decode - * their own first tag/len pair - */ - elmtLevel++; - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - defByNamedType = e->type->basicType->a.anyDefinedBy->link; - if (GetBuiltinType (defByNamedType->type) == BASICTYPE_OID) - { - fprintf (src, "SetTypeByOid ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - else - { - fprintf (src, "SetTypeByInt ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b, seqBytesDecoded, env);\n", r->decodeBaseName); - } - else if (tmpTypeId == BASICTYPE_ANY) - { - /* - * must check for another EOC for ANYs - * since the any decode routines decode - * their own first tag/len pair - */ - elmtLevel++; - -#ifdef VDADER_RULES -if (! gVDADER_RULES) -{ -#endif - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "SetTypeBy???(???);\n"); - - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b, seqBytesDecoded, env);\n", r->decodeBaseName); - -#ifdef VDADER_RULES -} -else - { - fprintf (src, " DEC_LOAD_ANYBUF("); - if (!cxxtri->isPtr) - fprintf (src, "&"); - fprintf (src, "%s, b, seqBytesDecoded, env);\n", varName); - } -#endif - } - else - { - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - fprintf (src, "B%s (b, tag1, elmtLen%d, seqBytesDecoded, env);\n", r->decodeContentBaseName, elmtLevel); - } - - /* decode Eoc (s) */ - for (i = elmtLevel-1; i > 0; i--) - { - fprintf (src, " if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, seqBytesDecoded, env);\n\n"); - } - - /* - * print code for getting the next tag - */ - inTailOptElmts = RestAreTailOptional (seq->basicType->a.sequence); - if (e != (NamedType*)LAST_LIST_ELMT (seq->basicType->a.sequence)) - { - tmpElmt = (NamedType*)NEXT_LIST_ELMT (seq->basicType->a.sequence); - tmpTypeId = GetBuiltinType (tmpElmt->type); - if (!inTailOptElmts) - { - if ((tmpTypeId == BASICTYPE_ANY || tmpTypeId == BASICTYPE_ANYDEFINEDBY) && CountTags (tmpElmt->type) == 0) - { - /* don't get a tag since ANY's decode their own */ - if (e->type->optional || (tmpElmt->type->optional && tmpElmt != (NamedType*)LAST_LIST_ELMT (seq->basicType->a.sequence))) - /* let this cause a compile error in the generated code */ - fprintf (src, " \n"); - } - else - fprintf (src, " tag1 = BDecTag (b, seqBytesDecoded, env);\n"); - } - else - { - fprintf (src, " if (seqBytesDecoded == elmtLen0)\n"); - fprintf (src, " {\n"); - fprintf (src, " bytesDecoded += seqBytesDecoded;\n"); - fprintf (src, " return;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - - if ((tmpTypeId == BASICTYPE_ANY || tmpTypeId == BASICTYPE_ANYDEFINEDBY) && !CountTags (tmpElmt->type)) - { - /* don't get a tag since ANY's decode their own */ - if (e->type->optional || (tmpElmt->type->optional && tmpElmt != (NamedType *)LAST_LIST_ELMT (seq->basicType->a.sequence))) - { - /* - * let this cause a compile error in the generated code - */ - fprintf (src, " \n"); - } - fprintf (src, " tag1 = b.PeekByte();\n\n"); - fprintf (src, " if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))\n"); - fprintf (src, " {\n"); - fprintf (src, " BDecEoc (b, seqBytesDecoded, env);\n\n"); - fprintf (src, " bytesDecoded += seqBytesDecoded;\n"); - fprintf (src, " return;\n"); - fprintf (src, " }\n"); - - } - else - { - fprintf (src, " tag1 = BDecTag (b, seqBytesDecoded, env);\n\n"); - fprintf (src, " if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))\n"); - fprintf (src, " {\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)\n"); - fprintf (src, " bytesDecoded += seqBytesDecoded;\n"); - fprintf (src, " return;\n"); - fprintf (src, " }\n"); - } - fprintf (src, " }\n"); - - } - } - - - /* - * close tag check if (if there is one) and - * print else clause to handle missing non-optional elmt - * errors - */ - tmpTypeId = GetBuiltinType (e->type); - if ((tmpTypeId == BASICTYPE_ANYDEFINEDBY || tmpTypeId == BASICTYPE_ANY) && !CountTags (e->type)) - { - /* do nothing - no tag check if stmt to close */ - fprintf (src, "\n\n"); - } - else if (!e->type->optional && !e->type->defaultVal) - { - fprintf (src, " }\n"); /* end of tag check if */ - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"ERROR - SEQUENCE is missing non-optional elmt.\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n\n"); - } - else - fprintf (src, " }\n\n"); /* end of tag check if */ - - FreeTags (tags); - } - - /* for last elmt only */ - fprintf (src, " bytesDecoded += seqBytesDecoded;\n"); - fprintf (src, " if (elmtLen0 == INDEFINITE_LEN)\n"); - fprintf (src, " {\n"); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - fprintf (src, " return;\n"); - fprintf (src, " }\n"); - fprintf (src, " else if (seqBytesDecoded != elmtLen0)\n"); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"ERROR - Length discrepancy on sequence.\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " return;\n"); - - } /* end of non-empty set else clause */ - - fprintf (src, "} // %s::B%s\n\n", td->cxxTypeDefInfo->className, r->decodeContentBaseName); - } - /* end of code for printing ber decode content method */ - - /* do BEnc function */ - if (printEncodersG) - { - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeBaseName, bufTypeNameG); - - fprintf (src, "%s %s::B%s (%s b)\n", lenTypeNameG, td->cxxTypeDefInfo->className, r->encodeBaseName, bufTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s l;\n", lenTypeNameG); - fprintf (src, " l = B%s (b);\n", r->encodeContentBaseName); - - /* encode each tag/len pair if any */ - FOR_EACH_LIST_ELMT_RVS (tag, seq->tags) - { - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (CONS); /* seq's are constructed */ - tagLen = TagByteLen (tag->code); - - fprintf (src, " l += BEncConsLen (b, l);\n"); - - if (tag->tclass == UNIV) - fprintf (src, " l += BEncTag%d (b, %s, %s, %s);\n", tagLen, classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, " l += BEncTag%d (b, %s, %s, %d);\n", tagLen, classStr, formStr, tag->code); - } - fprintf (src, " return l;\n"); - fprintf (src, "}\n\n"); - } - /* end of BEnc function */ - - /* Do BDec function */ - if (printDecodersG) - { - fprintf (hdr, " void B%s (%s b, %s &bytesDecoded, %s env);\n", r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "void %s::B%s (%s b, %s &bytesDecoded, %s env)\n", td->cxxTypeDefInfo->className, r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s tag;\n", tagTypeNameG); - - /* print extra locals for redundant lengths */ - for (i = 1; (seq->tags != NULL) && (i <= LIST_COUNT (seq->tags)); i++) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i); - fprintf (src, "\n"); - - /* decode tag/length pair (s) */ - elmtLevel = 0; - FOR_EACH_LIST_ELMT (tag, seq->tags) - { - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (CONS); /* seqs are constructed */ - - fprintf (src, " if ((tag = BDecTag (b, bytesDecoded, env)) != "); - - if (tag->tclass == UNIV) - fprintf (src, "MAKE_TAG_ID (%s, %s, %s))\n", classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, "MAKE_TAG_ID (%s, %s, %d))\n", classStr, formStr, tag->code); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"%s::B%s: ERROR - wrong tag\" << endl;\n", td->cxxTypeDefInfo->className, r->decodeBaseName); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - - fprintf (src, " elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - - fprintf (src, " B%s (b, tag, elmtLen%d, bytesDecoded, env);\n", r->decodeContentBaseName, elmtLevel); - - /* grab any EOCs that match redundant, indef lengths */ - for (i = elmtLevel-1; i > 0; i--) - { - fprintf (src, " if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - } - - fprintf (src, "}\n\n"); - } - /* end of BDec function */ - - PrintPduMemberFcns (src, hdr, r, td->cxxTypeDefInfo->className); - - /* write code for printing */ - if (printPrintersG) - { - fprintf (hdr, " void Print (ostream &os) const;\n"); - - fprintf (src, "void %s::Print (ostream &os) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - #ifdef __APPLE__ - fprintf (src, "#ifndef NDEBUG\n"); - #endif - allOpt = AllElmtsOptional (seq->basicType->a.sequence); - if (allOpt) - fprintf (src, " int nonePrinted = true;\n"); - fprintf (src, " os << \"{ -- SEQUENCE --\" << endl;\n"); - fprintf (src, " indentG += stdIndentG;\n\n"); - - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - inTailOptElmts = IsTailOptional (seq->basicType->a.sequence); - - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " if (%s (%s))\n", cxxtri->optTestRoutineName, e->type->cxxTypeRefInfo->fieldName); - - fprintf (src, " {\n"); - - if (allOpt) - { - if (e != FIRST_LIST_ELMT (seq->basicType->a.sequence)) - { - fprintf (src, " if (!nonePrinted)\n"); - fprintf (src, " os << \",\" << endl;\n"); - } - fprintf (src, " nonePrinted = false;\n", i); - } - else if (inTailOptElmts) /* cannot be first elmt ow allOpt is true */ - fprintf (src, " os << \",\"<< endl;\n"); - - fprintf (src, " Indent (os, indentG);\n"); - - if (e->fieldName != NULL) - fprintf (src, " os << \"%s \";\n", e->fieldName); - - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " os << *%s;\n", e->type->cxxTypeRefInfo->fieldName); - else - fprintf (src, " os << %s;\n", e->type->cxxTypeRefInfo->fieldName); - -#ifdef KHO - if (e != LAST_LIST_ELMT (seq->basicType->a.sequence)&&(!e->type->cxxTypeRefInfo->isPtr) ) - fprintf (src, " os << \",\" << endl;\n"); -#else - if (e != LAST_LIST_ELMT (seq->basicType->a.sequence) && !inTailOptElmts && !NextIsTailOptional (seq->basicType->a.sequence)) - fprintf (src, " os << \",\" << endl;\n"); -#endif - - fprintf (src, " }\n"); - - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " else\n"); -#ifdef KHO - fprintf (src, " {\n"); - fprintf (src, " Indent (os, indentG);\n"); - if (e->fieldName != NULL) - fprintf (src, " os << \"%s \";\n", e->fieldName); - fprintf (src, " os << \"-- void --\";\n"); - if (e != LAST_LIST_ELMT (seq->basicType->a.sequence)) - fprintf (src, " os << \",\" << endl;\n"); - else - fprintf (src, " os << endl;\n"); - fprintf (src, " }\n"); -#else - fprintf (src, " os << \"-- void --\";\n"); -#endif - } - - fprintf (src, "\n"); - - if (e == LAST_LIST_ELMT (seq->basicType->a.sequence)) - fprintf (src, " os << endl;\n"); - } - - fprintf (src, " indentG -= stdIndentG;\n"); - fprintf (src, " Indent (os, indentG);\n"); - fprintf (src, " os << \"}\";\n"); - #ifdef __APPLE__ - fprintf (src, "#endif /* NDEBUG */\n"); - #endif - fprintf (src, "} // %s::Print\n\n\n", td->cxxTypeDefInfo->className); - } - /* end of print method code printer */ - - /* close class definition */ - fprintf (hdr, "};\n\n\n"); - -} /* PrintCxxSeqDefCode */ - - -static void -PrintCxxSetDefCode PARAMS ((src, hdr, mods, m, r, td, parent, set, novolatilefuncs), - FILE *src _AND_ - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *set _AND_ - int novolatilefuncs) -{ - NamedType *e; - char *classStr; - char *formStr; - char *codeStr; - int tagLen, i; - Tag *tag; - TagList *tags; - char *varName; - CxxTRI *cxxtri; - int elmtLevel; - int varCount, tmpVarCount; - int stoleChoiceTags; - int inTailOptElmts; - int mandatoryElmtCount; - enum BasicTypeChoiceId tmpTypeId; - NamedType *defByNamedType; - int allOpt; - - /* put class spec in hdr file */ - - fprintf (hdr, "class %s%s\n", td->cxxTypeDefInfo->className, baseClassesG); - fprintf (hdr, "{\n"); - fprintf (hdr, "public:\n"); - - /* write out the set elmts */ - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - fprintf (hdr, " "); - PrintCxxType (hdr, mods, m, r, td, set, e->type); - fprintf (hdr, "%s;\n", e->type->cxxTypeRefInfo->fieldName); - } - - fprintf (hdr, "\n"); - -#if META - if (printMetaG) - { - fprintf (hdr, "#if META\n"); - fprintf (src, "#if META\n\n"); - - fprintf (hdr, " static const AsnSetTypeDesc _desc;\n"); - fprintf (hdr, " static const AsnSetMemberDesc _mdescs[];\n"); - fprintf (hdr, " const AsnTypeDesc *_getdesc() const;\n"); - fprintf (hdr, " AsnType *_getref (const char *membername, bool create = false);\n\n"); - - fprintf (src, "static AsnType *create%s()\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return new %s;\n", td->cxxTypeDefInfo->className); - fprintf (src, "}\n\n"); - - fprintf (src, "const AsnSetMemberDesc %s::_mdescs[] =\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - if (printMetaG == META_backend_names) - fprintf (src, " AsnSetMemberDesc (\"%s\", &%s::_desc, %s), // `%s'\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className, e->type->optional || e->type->defaultVal ? "true" : "false", e->fieldName ? e->fieldName : ""); - else /* META_asn1_names */ - fprintf (src, " AsnSetMemberDesc (\"%s\", &%s::_desc, %s), // `%s'\n", e->fieldName ? e->fieldName : e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className, e->type->optional || e->type->defaultVal ? "true" : "false", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " AsnSetMemberDesc()\n"); - fprintf (src, "};\n\n"); - - fprintf (src, "const AsnSetTypeDesc %s::_desc\n", td->cxxTypeDefInfo->className); - fprintf (src, "(\n"); - fprintf (src, " &%sModuleDesc,\n", m->cxxname); - if (printMetaG == META_backend_names) - fprintf (src, " \"%s\", // `%s'\n", td->cxxTypeDefInfo->className, td->definedName); - else /* META_asn1_names */ - fprintf (src, " \"%s\", // `%s'\n", td->definedName, td->cxxTypeDefInfo->className); - fprintf (src, " %s,\n", isMetaPDU (m->modId->name, td->definedName, meta_pdus_G) ? "true" : "false"); - fprintf (src, " AsnTypeDesc::SET,\n"); - fprintf (src, " create%s,\n", td->cxxTypeDefInfo->className); - fprintf (src, " _mdescs\n"); - fprintf (src, ");\n\n"); - - fprintf (src, "const AsnTypeDesc *%s::_getdesc() const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return &_desc;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "AsnType *%s::_getref (const char *membername, bool create)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - fprintf (src, " if (!strcmp (membername, \"%s\"))\n", e->type->cxxTypeRefInfo->fieldName); - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " {\n"); - fprintf (src, " if (!%s && create)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, " return %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " }\n"); - } - else - fprintf (src, " return &%s;\n", e->type->cxxTypeRefInfo->fieldName); - } - fprintf (src, " return NULL;\n"); - fprintf (src, "}\n\n"); - -#if TCL - if (printTclG) - { - fprintf (hdr, "#if TCL\n"); - fprintf (src, "#if TCL\n\n"); - - fprintf (hdr, " int TclGetDesc (Tcl_DString *) const;\n"); - fprintf (hdr, " int TclGetVal (Tcl_Interp *) const;\n"); - fprintf (hdr, " int TclSetVal (Tcl_Interp *, const char *valstr);\n"); - fprintf (hdr, " int TclUnsetVal (Tcl_Interp *, const char *membernames);\n\n"); - - fprintf (src, "int %s::TclGetDesc (Tcl_DString *valstr) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Tcl_DStringStartSublist (valstr);\n\n"); - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - fprintf (src, " Tcl_DStringStartSublist (valstr);\n"); - fprintf (src, " Tcl_DStringAppendElement (valstr, \"%s\");\n", e->type->cxxTypeRefInfo->fieldName); - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " Tcl_DStringAppendElement (valstr, %s ? \"valid\" : \"void\");\n", e->type->cxxTypeRefInfo->fieldName); - else - fprintf (src, " Tcl_DStringAppendElement (valstr, \"valid\");\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " Tcl_DStringEndSublist (valstr);\n\n"); - } - fprintf (src, " Tcl_DStringEndSublist (valstr);\n\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclGetVal (Tcl_Interp *interp) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Tcl_DString valstr;\n\n"); - fprintf (src, " Tcl_DStringInit (&valstr);\n\n"); - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " if (%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - fprintf (src, " Tcl_DStringStartSublist (&valstr);\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, \"%s\");\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " if (%s->TclGetVal (interp) != TCL_OK)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " goto Error;\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, interp->result);\n"); - fprintf (src, " Tcl_ResetResult (interp);\n"); - fprintf (src, " Tcl_DStringEndSublist (&valstr);\n"); - fprintf (src, " }\n\n"); - } - else - { - fprintf (src, " Tcl_DStringStartSublist (&valstr);\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, \"%s\");\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " if (%s.TclGetVal (interp) != TCL_OK)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " goto Error;\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, interp->result);\n"); - fprintf (src, " Tcl_ResetResult (interp);\n"); - fprintf (src, " Tcl_DStringEndSublist (&valstr);\n\n"); - } - } - fprintf (src, " Tcl_DStringResult (interp, &valstr);\n"); - fprintf (src, " return TCL_OK;\n\n"); - fprintf (src, "Error:\n"); - fprintf (src, " Tcl_DStringFree (&valstr);\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclSetVal (Tcl_Interp *interp, const char *valstr)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " int i;\n"); - fprintf (src, " Args elems;\n"); - fprintf (src, " if (Tcl_SplitList (interp, (char*)valstr, &elems.c, &elems.v) != TCL_OK)\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " Args* elempairs = new Args[elems.c];\n"); - fprintf (src, " for (i=0; iresult, \"syntax error in element #%%d: expected a pair, but it's got %%d element(s)\", i, elempairs[i].c);\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " for (const AsnSetMemberDesc *m=_mdescs; m->name; m++)\n"); - fprintf (src, " {\n"); - fprintf (src, " int count = 0;\n"); - fprintf (src, " for (i=0; iname))\n"); - fprintf (src, " count++;\n"); - fprintf (src, " if (count > 1)\n"); - fprintf (src, " {\n"); - fprintf (src, " sprintf (interp->result, \"duplicate value for member \\\"%%s\\\" in list\", m->name);\n"); - fprintf (src, " Tcl_SetErrorCode (interp, \"SNACC\", \"DUPMEMB\", NULL);\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " if (!m->optional && count < 1)\n"); - fprintf (src, " {\n"); - fprintf (src, " sprintf (interp->result, \"mandatory member \\\"%%s\\\" is missing in list\", m->name);\n"); - fprintf (src, " Tcl_SetErrorCode (interp, \"SNACC\", \"MISSMAND\", NULL);\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " \n"); - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " for (i=0; ibasicType->a.set) - { - fprintf (src, " if (!strcmp (elempairs[i].v[0], \"%s\"))\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " if (!%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, " if (%s->TclSetVal (interp, elempairs[i].v[1]))\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - } - else - { - fprintf (src, " if (%s.TclSetVal (interp, elempairs[i].v[1]))\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " }\n"); - } - fprintf (src, " }\n"); - } - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " // look for unmentioned optional members and delete them:\n"); - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - if (e->type->optional || e->type->defaultVal) - { - fprintf (src, " {\n"); - fprintf (src, " bool present = false;\n"); - fprintf (src, " for (i=0; itype->cxxTypeRefInfo->fieldName); - fprintf (src, " present = true;\n"); - fprintf (src, " if (!present)\n"); - fprintf (src, " {\n"); - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " }\n"); - fprintf (src, " }\n"); - } - } - fprintf (src, "\n"); - fprintf (src, " delete elempairs;\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclUnsetVal (Tcl_Interp *interp, const char *membernames)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Args elems;\n"); - fprintf (src, " if (Tcl_SplitList (interp, (char*)membernames, &elems.c, &elems.v) != TCL_OK)\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, "\n"); - fprintf (src, " for (int i=0; ibasicType->a.set) - { - fprintf (src, " if (!strcmp (elems.v[i], \"%s\"))\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - if (e->type->optional || e->type->defaultVal) - { - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - } - else - { - fprintf (src, " return _desc.mandatmemberr (interp, elems.v[i]);\n"); - } - fprintf (src, " }\n"); - } - fprintf (src, " }\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, "#endif // TCL\n"); - fprintf (src, "#endif // TCL\n\n"); - } -#endif /* TCL */ - - fprintf (hdr, "#endif // META\n\n"); - fprintf (src, "#endif // META\n\n"); - } -#endif /* META */ - - /* constructors and destructor: */ - - fprintf (hdr, " %s();\n", td->cxxTypeDefInfo->className); - - fprintf (src, "%s::%s()\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - if (e->type->cxxTypeRefInfo->isPtr) - if (e->type->optional || e->type->defaultVal) - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - else - { - fprintf (src, "#if TCL\n"); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, "#else\n"); - fprintf (src, " %s = NULL; // incomplete initialization of mandatory element!\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "#endif // TCL\n"); - } - } - fprintf (src, "}\n\n"); - - fprintf (hdr, " %s (const %s &);\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - - fprintf (src, "%s::%s (const %s &)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Asn1Error << \"use of incompletely defined %s::%s (const %s &)\" << endl;\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, " abort();\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, " virtual ~%s();\n", td->cxxTypeDefInfo->className); - - fprintf (src, "%s::~%s()\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, "}\n\n"); - - /* print clone routine for ANY mgmt */ - PrintCloneMethod (hdr, src, td); - - fprintf (hdr, " %s &operator = (const %s &);\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - - fprintf (src, "#if SNACC_DEEP_COPY\n"); - fprintf (src, "%s &%s::operator = (const %s &that)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "#else // SNACC_DEEP_COPY\n"); - fprintf (src, "%s &%s::operator = (const %s &)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "#endif // SNACC_DEEP_COPY\n"); - fprintf (src, "{\n"); - fprintf (src, "#if SNACC_DEEP_COPY\n"); - fprintf (src, " if (this != &that)\n"); - fprintf (src, " {\n"); - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " if (that.%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " {\n"); - fprintf (src, " if (!%s)\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = new %s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->className); - fprintf (src, " *%s = *that.%s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " delete %s;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " %s = NULL;\n", e->type->cxxTypeRefInfo->fieldName); - fprintf (src, " }\n"); - } - else - fprintf (src, " %s = that.%s;\n", e->type->cxxTypeRefInfo->fieldName, e->type->cxxTypeRefInfo->fieldName); - } - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " return *this;\n"); - fprintf (src, "#else // SNACC_DEEP_COPY\n"); - fprintf (src, " Asn1Error << \"use of incompletely defined %s &%s::operator = (const %s &)\" << endl;\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, " abort();\n"); - fprintf (src, " // if your compiler complains here, check the -novolat option\n"); - if (novolatilefuncs) - { - fprintf (src, " return *this;\n"); - } - fprintf (src, "#endif // SNACC_DEEP_COPY\n"); - fprintf (src, "}\n\n"); - - /* BerEncode */ - if (printEncodersG) - { - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeContentBaseName, bufTypeNameG); - - fprintf (src, "%s %s::B%s (%s b)\n", lenTypeNameG, td->cxxTypeDefInfo->className, r->encodeContentBaseName, bufTypeNameG); - fprintf (src, "{\n"); - - /* print local vars */ - fprintf (src, " %s totalLen = 0;\n", lenTypeNameG); - fprintf (src, " %s l;\n\n", lenTypeNameG); - -#ifdef VDADER_RULES - { - if (gVDADER_RULES) - { int tmpCount=0; - FOR_EACH_LIST_ELMT_RVS (e, set->basicType->a.set) - tmpCount++; - fprintf (src, " AsnBuf outputBuf;\n int iii=0, tmpCount=0;\n"); - fprintf (src, " char *lpszBuf = (char *)calloc(1, 1024);\n"); - fprintf (src, " outputBuf.Init(lpszBuf, 1024);\n"); - fprintf (src, " outputBuf.ResetInWriteRvsMode();\n"); - - fprintf (src, " CSM_Buffer *tmpEnc[%d];\n", tmpCount); - /** allocate enough tmp CSM_Buffer(s) to sort SET. - NOT ALL MAY BE filled, there may be OPTIONAL SET - elements!! */ - } -#endif - - FOR_EACH_LIST_ELMT_RVS (e, set->basicType->a.set) - { - cxxtri = e->type->cxxTypeRefInfo; - - varName = cxxtri->fieldName; - - /* print optional test if nec*/ - if (e->type->optional || (e->type->defaultVal != NULL)) - { - fprintf (src, " if (%s (%s))\n", cxxtri->optTestRoutineName, varName); - fprintf (src, " {\n"); - } - - /* encode Eoc (s) if nec */ -#ifdef VDADER_RULES - if (gVDADER_RULES) - PrintCxxEocEncoders (src, td, e->type, "outputBuf"); - else -#endif - PrintCxxEocEncoders (src, td, e->type, "b"); - - /* encode content */ - tmpTypeId = GetBuiltinType (e->type); - if (tmpTypeId == BASICTYPE_ANYDEFINEDBY) - { - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - defByNamedType = e->type->basicType->a.anyDefinedBy->link; - if (GetBuiltinType (defByNamedType->type) == BASICTYPE_OID) - { - fprintf (src, "SetTypeByOid ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - else - { - fprintf (src, "SetTypeByInt ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); -#ifdef VDADER_RULES - if (gVDADER_RULES) - fprintf (src, "B%s (outputBuf);\n", r->encodeBaseName); - else -#endif - fprintf (src, "B%s (b);\n", r->encodeBaseName); - } - else if (tmpTypeId == BASICTYPE_ANY) - { - -#ifdef VDADER_RULES -if (! gVDADER_RULES) -{ -#endif - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "SetTypeBy???(???);\n"); - - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b);\n", r->encodeBaseName); - -#ifdef VDADER_RULES -} -else - { - fprintf (src, " ENC_LOAD_ANYBUF("); - if (!cxxtri->isPtr) - fprintf (src, "&"); - fprintf (src, "%s, outputBuf, l);\n", varName); - } -#endif - } - else - { - fprintf (src, " l = %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - -#ifdef VDADER_RULES - if (gVDADER_RULES) - fprintf (src, "B%s (outputBuf);\n", r->encodeContentBaseName); - else -#endif - fprintf (src, "B%s (b);\n", r->encodeContentBaseName); - } - - /* encode tag (s) & len (s) */ - -#ifdef VDADER_RULES - if (gVDADER_RULES) - PrintCxxTagAndLenEncodingCode (src, td, e->type, "l", "outputBuf"); - else -#endif - PrintCxxTagAndLenEncodingCode (src, td, e->type, "l", "b"); - - fprintf (src, " totalLen += l;\n"); - -#ifdef VDADER_RULES - if (gVDADER_RULES) /** NOW, encode for SET DER rule ordering.*/ - { /** RWC; Buffers handle files or memory. **/ - fprintf (src, " SNACC_BUFRESET_READ(&outputBuf);\n"); - fprintf (src, " SM_ReadFromAsnBuf(tmpEnc[iii], outputBuf,outputBuf.DataLen(),NULL);\n"); - fprintf (src, " SNACC_BUFRESET_WRITE(&outputBuf);\n"); - fprintf (src, " iii++;\n"); - } -#endif - - /* close optional test if nec */ - if (e->type->optional || (e->type->defaultVal != NULL)) - fprintf (src, " }\n\n"); - else - fprintf (src, "\n"); - } -#ifdef VDADER_RULES - if (gVDADER_RULES) /** LAST, Order for SET DER rule ordering.*/ - { /** re-order all elements, add to "b".*/ - fprintf (src, " vdasnacc_sortSet(tmpEnc, iii);\n"); - /** These "SET" components are now ordered in ascending order, - ** ready to be loaded into the output buffer. (RWC; TBD; make output - ** buffers accept these allocated buffers directly, no copy). - **/ - fprintf (src, " tmpCount = iii; /** REMEMBER how many we have**/\n"); - fprintf (src, " for (iii=0; iii < tmpCount; iii++)\n"); - fprintf (src, " SM_WriteToAsnBuf(tmpEnc[iii], b);\n"); - - fprintf (src, " for (iii=0; iii < tmpCount; iii++) delete tmpEnc[iii];\n"); - fprintf (src, " free(lpszBuf);\n"); - - } - } /** internal definition bracket for "tmpCount".**/ -#endif - fprintf (src, " return totalLen;\n"); - fprintf (src, "} // %s::B%s\n\n\n", td->cxxTypeDefInfo->className, r->encodeContentBaseName); - } - /* end of BerEncodeContent */ - - /* write BerDecodeContent */ - if (printDecodersG) - { - fprintf (hdr, " void B%s (%s b, %s tag, %s elmtLen, %s &bytesDecoded, %s env);\n\n", r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "void %s::B%s (%s b, %s /*tag0*/, %s elmtLen0, %s &bytesDecoded, %s env)\n", td->cxxTypeDefInfo->className, r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG, lenTypeNameG, envTypeNameG); - fprintf (src, "{\n"); - - /* print local vars */ - fprintf (src, " %s tag1;\n", tagTypeNameG); - fprintf (src, " %s setBytesDecoded = 0;\n", lenTypeNameG); - fprintf (src, " unsigned int mandatoryElmtsDecoded = 0;\n"); - /* count max number of extra length var nec */ - varCount = 0; - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - tmpVarCount = CxxCountVariableLevels (e->type); - if (tmpVarCount > varCount) - varCount = tmpVarCount; - } - /* write extra length vars */ - for (i = 1; i <= varCount; i++) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i); - fprintf (src, "\n"); - - /* handle empty set */ - if ((set->basicType->a.set == NULL) || LIST_EMPTY (set->basicType->a.set)) - { - fprintf (src, " if (elmtLen0 == INDEFINITE_LEN)\n"); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - fprintf (src, " else if (elmtLen0 != 0)\n"); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"Expected an empty sequence\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - -/* forget about potential extension types for now - fprintf (src, " if (elmtLen0 == INDEFINITE_LEN)\n"); - fprintf (src, " {\n"); - fprintf (src, " tag1 = BDecTag (b, bytesDecoded, env);\n\n"); - fprintf (src, " if (tag1 == EOC_TAG_ID)\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, bytesDecoded, env)\n"); - fprintf (src, " else\n"); - fprintf (src, " BerDiscardElmt (b, bytesDecoded, env);\n\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " BufSkip (b, elmtLen0);\n"); - fprintf (src, " bytesDecoded += elmtLen0;\n"); - fprintf (src, " }\n"); -*/ - } - else - { - fprintf (src, " for (; (setBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN); )\n"); - fprintf (src, " {\n"); - fprintf (src, " tag1 = BDecTag (b, setBytesDecoded, env);\n\n"); - fprintf (src, " if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))\n"); - fprintf (src, " {\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, setBytesDecoded, env)\n"); - fprintf (src, " break; /* exit for loop */\n"); - fprintf (src, " }\n"); - - fprintf (src, " elmtLen1 = BDecLen (b, setBytesDecoded, env);\n"); - fprintf (src, " switch (tag1)\n"); - fprintf (src, " {\n"); - mandatoryElmtCount = 0; - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - cxxtri = e->type->cxxTypeRefInfo; - - tags = GetTags (e->type, &stoleChoiceTags); - - if (LIST_EMPTY (tags)) - { - fprintf (src, " // ANY Type ?\n"); - fprintf (src, " case MAKE_TAG_ID (?, ?, ?):\n"); - } - else - { - tag = (Tag*)FIRST_LIST_ELMT (tags); - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, formStr, tag->code); - } - - /* now decode extra tags/length pairs */ - AsnListFirst (tags); - AsnListNext (tags); - elmtLevel = 1; - if (stoleChoiceTags) - { - FOR_REST_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src, " case MAKE_TAG_ID (%s, %s, %s):\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src, " case MAKE_TAG_ID (%s, %s, %d):\n", classStr, formStr, tag->code); - } - } - } - else /* didn't steal nested choice's tags */ - { - FOR_REST_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - fprintf (src, " tag1 = BDecTag (b, setBytesDecoded, env);\n"); - if (tag->form == ANY_FORM) - { - if (tag->tclass == UNIV) - { - fprintf (src, " if ((tag1 != MAKE_TAG_ID (%s, %s, %s))\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src, " && (tag1 != MAKE_TAG_ID (%s, %s, %s)))\n", classStr, Form2FormStr (CONS), codeStr); - } - else - { - fprintf (src, " if ((tag1 != MAKE_TAG_ID (%s, %s, %d))\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src, " && (tag1 != MAKE_TAG_ID (%s, %s, %d)))\n", classStr, Form2FormStr (CONS), tag->code); - } - - } - else - { - if (tag->tclass == UNIV) - fprintf (src, " if (tag1 != MAKE_TAG_ID (%s, %s, %s))\n", classStr, formStr, codeStr); - else - fprintf (src, " if (tag1 != MAKE_TAG_ID (%s, %s, %d))\n", classStr, formStr, tag->code); - } - - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"Unexpected Tag\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n\n"); - - fprintf (src, " elmtLen%d = BDecLen (b, setBytesDecoded, env);\n", ++elmtLevel); - } - } - } - /* - * if the choices element is another choice && - * we didn't steal its tags then we must grab - * the key tag out of the contained CHOICE - */ - if (!stoleChoiceTags && (GetBuiltinType (e->type) == BASICTYPE_CHOICE)) - { - fprintf (src, " tag1 = BDecTag (b, setBytesDecoded, env);\n"); - fprintf (src, " elmtLen%d = BDecLen (b, setBytesDecoded, env);\n", ++elmtLevel); - } - - varName = cxxtri->fieldName; - - /* decode content */ - if (cxxtri->isPtr) - fprintf (src, " %s = new %s;\n", varName, cxxtri->className); - - /* decode content */ - tmpTypeId = GetBuiltinType (e->type); - if (tmpTypeId == BASICTYPE_ANYDEFINEDBY) - { - /* - * must check for another EOC for ANYs - * since the any decode routines decode - * their own first tag/len pair - */ - elmtLevel++; - - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - defByNamedType = e->type->basicType->a.anyDefinedBy->link; - if (GetBuiltinType (defByNamedType->type) == BASICTYPE_OID) - { - fprintf (src, "SetTypeByOid ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - else - { - fprintf (src, "SetTypeByInt ("); - if (defByNamedType->type->cxxTypeRefInfo->isPtr) - fprintf (src, " *"); - fprintf (src, "%s);\n", defByNamedType->type->cxxTypeRefInfo->fieldName); - } - - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b, setBytesDecoded, env);\n", r->decodeBaseName); - } - else if (tmpTypeId == BASICTYPE_ANY) - { - /* - * must check for another EOC for ANYs - * since the any decode routines decode - * their own first tag/len pair - */ - elmtLevel++; - -#ifdef VDADER_RULES -if (!gVDADER_RULES) -{ -#endif - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "SetTypeBy???(???);\n"); - - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - fprintf (src, "B%s (b, setBytesDecoded, env);\n", r->decodeBaseName); - -#ifdef VDADER_RULES -} -else - { - fprintf (src, " DEC_LOAD_ANYBUF("); - if (!cxxtri->isPtr) - fprintf (src, "&"); - fprintf (src, "%s, b, setBytesDecoded, env);\n", varName); - } -#endif - } - else - { - fprintf (src, " %s", varName); - if (cxxtri->isPtr) - fprintf (src, "->"); - else - fprintf (src, "."); - - fprintf (src, "B%s (b, tag1, elmtLen%d, setBytesDecoded, env);\n", r->decodeContentBaseName, elmtLevel); - } - - /* decode Eoc (s) */ - for (i = elmtLevel-1; i >= 1; i--) - { - fprintf (src, " if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, setBytesDecoded, env);\n\n"); - } - - /* keep track of decoded non-optional elmts */ - if (!e->type->optional && (e->type->defaultVal == NULL)) - { - mandatoryElmtCount++; - fprintf (src, " mandatoryElmtsDecoded++;\n"); - } - fprintf (src, " break;\n\n"); - - FreeTags (tags); - } /* for each elmt */ - fprintf (src, " default:\n"); - fprintf (src, " Asn1Error << \"Unexpected Tag on SET elmt.\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " } // end switch\n"); - fprintf (src, " } // end for loop\n"); - fprintf (src, " bytesDecoded += setBytesDecoded;\n"); - fprintf (src, " if (mandatoryElmtsDecoded != %d)\n", mandatoryElmtCount); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"ERROR - non-optional SET element missing.\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - - } /* if not empty set clause */ - - fprintf (src, "} // %s::B%s\n\n", td->cxxTypeDefInfo->className, r->decodeContentBaseName); - } - /* end of decode content method code */ - - /* BerEncode */ - if (printEncodersG) - { - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeBaseName, bufTypeNameG); - - fprintf (src, "%s\n", lenTypeNameG); - fprintf (src, "%s::B%s (%s b)\n", td->cxxTypeDefInfo->className, r->encodeBaseName, bufTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s l;\n", lenTypeNameG); - fprintf (src, " l = B%s (b);\n", r->encodeContentBaseName); - - /* encode each tag/len pair if any */ - FOR_EACH_LIST_ELMT_RVS (tag, set->tags) - { - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (CONS); /* set's are constructed */ - tagLen = TagByteLen (tag->code); - - fprintf (src, " l += BEncConsLen (b, l);\n"); - - if (tag->tclass == UNIV) - fprintf (src, " l += BEncTag%d (b, %s, %s, %s);\n", tagLen, classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, " l += BEncTag%d (b, %s, %s, %d);\n", tagLen, classStr, formStr, tag->code); - } - fprintf (src, " return l;\n"); - fprintf (src, "}\n\n"); - } - /* end of BerEncode */ - - /* BerDecode */ - if (printDecodersG) - { - fprintf (hdr, " void B%s (%s b, %s &bytesDecoded, %s env);\n", r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "void %s::B%s (%s b, %s &bytesDecoded, %s env)\n", td->cxxTypeDefInfo->className, r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s tag;\n", tagTypeNameG); - - /* print extra locals for redundant lengths */ - for (i = 1; (set->tags != NULL) && (i <= LIST_COUNT (set->tags)); i++) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i); - fprintf (src, "\n"); - - /* decode tag/length pair (s) */ - elmtLevel = 0; - FOR_EACH_LIST_ELMT (tag, set->tags) - { - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (CONS); /* sets are constructed */ - - fprintf (src, " if ((tag = BDecTag (b, bytesDecoded, env)) != "); - - if (tag->tclass == UNIV) - fprintf (src, "MAKE_TAG_ID (%s, %s, %s))\n", classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, "MAKE_TAG_ID (%s, %s, %d))\n", classStr, formStr, tag->code); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"%s::B%s: ERROR - wrong tag\" << endl;\n", td->cxxTypeDefInfo->className, r->decodeBaseName); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - - fprintf (src, " elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - - fprintf (src, " B%s (b, tag, elmtLen%d, bytesDecoded, env);\n", r->decodeContentBaseName, i-1); - - /* grab any EOCs that match redundant, indef lengths */ - for (i = elmtLevel-1; i > 0; i--) - { - fprintf (src, " if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - } - - fprintf (src, "}\n\n"); - } - /* end of BerDecode */ - - PrintPduMemberFcns (src, hdr, r, td->cxxTypeDefInfo->className); - - /* write code for printing */ - if (printPrintersG) - { - fprintf (hdr, " void Print (ostream &os) const;\n"); - - fprintf (src, "void %s::Print (ostream &os) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - #ifdef __APPLE__ - fprintf (src, "#ifndef NDEBUG\n"); - #endif - allOpt = AllElmtsOptional (set->basicType->a.set); - if (allOpt) - fprintf (src, " int nonePrinted = true;\n"); - - fprintf (src, " os << \"{ -- SET --\" << endl;\n"); - fprintf (src, " indentG += stdIndentG;\n\n"); - - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - inTailOptElmts = IsTailOptional (set->basicType->a.set); - - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " if (%s (%s))\n", cxxtri->optTestRoutineName, e->type->cxxTypeRefInfo->fieldName); - - fprintf (src, " {\n"); - - if (allOpt) - { - if (e != FIRST_LIST_ELMT (set->basicType->a.set)) - { - fprintf (src, " if (!nonePrinted)\n"); - fprintf (src, " os << \",\" << endl;\n"); - } - fprintf (src, " nonePrinted = false;\n", i); - } - else if (inTailOptElmts) /* cannot be first elmt ow allOpt is true */ - fprintf (src, " os << \",\"<< endl;\n"); - - fprintf (src, " Indent (os, indentG);\n"); - - if (e->fieldName != NULL) - fprintf (src, " os << \"%s \";\n", e->fieldName); - - if (e->type->cxxTypeRefInfo->isPtr) - fprintf (src, " os << *%s;\n", e->type->cxxTypeRefInfo->fieldName); - else - fprintf (src, " os << %s;\n", e->type->cxxTypeRefInfo->fieldName); - - if (e != LAST_LIST_ELMT (set->basicType->a.set) && !inTailOptElmts && !NextIsTailOptional (set->basicType->a.set)) - fprintf (src, " os << \",\" << endl;\n"); - - fprintf (src, " }\n"); - - if (e->type->cxxTypeRefInfo->isPtr) - { - fprintf (src, " else\n"); -#ifdef KHO - fprintf (src, " os << \"-- void2 --\\n\";\n"); -#else - fprintf (src, " os << \"-- void --\";\n"); -#endif - } - - fprintf (src, "\n"); - - if (e == LAST_LIST_ELMT (set->basicType->a.set)) - fprintf (src, " os << endl;\n"); - } - fprintf (src, " indentG -= stdIndentG;\n"); - fprintf (src, " Indent (os, indentG);\n"); - fprintf (src, " os << \"}\";\n"); - #ifdef __APPLE__ - fprintf (src, "#endif /* NDEBUG */\n"); - #endif __APPLE__ - fprintf (src, "} // %s - operator <<\n\n\n", td->cxxTypeDefInfo->className); - } - /* end of print method code */ - - /* close class definition */ - fprintf (hdr, "};\n\n\n"); - -} /* PrintCxxSetDefCode */ - - -/* - * This major Bogosity results from gcc2.2.2 inability to handle - * template properly - */ -static void -PrintCxxListClass PARAMS ((src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, parent, lst), - FILE *src _AND_ - FILE *hdr _AND_ - if_IBM_ENC (FILE *srcdb _AND_) - if_IBM_ENC (FILE *hdrdb _AND_) - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *lst) -{ - char *lcn; /* list class name */ - char *ecn; /* (list) elmt class name */ - char *classStr; - char *formStr; - int tagLen; - Tag *tag; - int i, elmtLevel; - - lcn = td->cxxTypeDefInfo->className; - ecn = lst->basicType->a.setOf->cxxTypeRefInfo->className; - -#ifdef _IBM_ENC_ -#include "./ibm_editor/print_cxx_list_class.h" -#endif /* _IBM_ENC_ */ - - fprintf (hdr, "class %s%s\n", lcn, baseClassesG); - fprintf (hdr, "{\n"); - fprintf (hdr, "protected:\n"); - - fprintf (hdr, " unsigned long int count;\n"); - fprintf (hdr, " struct AsnListElmt\n"); - fprintf (hdr, " {\n"); - fprintf (hdr, " AsnListElmt *next;\n"); - fprintf (hdr, " AsnListElmt *prev;\n"); -#ifdef _IBM_ENC_ - fprintf (hdr, " void *operator new (size_t t) { return mem_mgr_ptr->Get (t); } // Guido Grassel 12.8.93\n"); - fprintf (hdr, " void operator delete (void *p) { mem_mgr_ptr->Put (p); } // Guido Grassel 12.8.93\n"); -#endif /* _IBM_ENC_ */ - fprintf (hdr, " %s *elmt;\n", ecn); - fprintf (hdr, " } *first, *curr, *last;\n\n"); - - fprintf (hdr, "public:\n"); - -#if META - if (printMetaG) - { - const char *emtn = "?"; - switch (lst->basicType->choiceId) - { - case BASICTYPE_SEQUENCEOF: - emtn = "SEQUENCE_OF"; - break; - case BASICTYPE_SETOF: - emtn = "SET_OF"; - break; - } - - fprintf (hdr, "#if META\n"); - fprintf (src, "#if META\n\n"); - - fprintf (hdr, " static const AsnListTypeDesc _desc;\n"); - fprintf (hdr, " const AsnTypeDesc *_getdesc() const;\n"); - fprintf (hdr, " AsnType *_getref (const char *index, bool create = false);\n\n"); - - fprintf (src, "static AsnType *create%s()\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return new %s;\n", td->cxxTypeDefInfo->className); - fprintf (src, "}\n\n"); - - fprintf (src, "const AsnListTypeDesc %s::_desc\n", td->cxxTypeDefInfo->className); - fprintf (src, "(\n"); - fprintf (src, " &%sModuleDesc,\n", m->cxxname); - if (printMetaG == META_backend_names) - fprintf (src, " \"%s\", // `%s'\n", td->cxxTypeDefInfo->className, td->definedName); - else /* META_asn1_names */ - fprintf (src, " \"%s\", // `%s'\n", td->definedName, td->cxxTypeDefInfo->className); - fprintf (src, " %s,\n", isMetaPDU (m->modId->name, td->definedName, meta_pdus_G) ? "true" : "false"); - fprintf (src, " AsnTypeDesc::%s,\n", emtn); - fprintf (src, " create%s,\n", td->cxxTypeDefInfo->className); - fprintf (src, " &%s::_desc\n", ecn); - fprintf (src, ");\n\n"); - - fprintf (src, "const AsnTypeDesc *%s::_getdesc() const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " return &_desc;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "AsnType *%s::_getref (const char *strindex, bool create)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " bool insert;\n"); - fprintf (src, " unsigned long index;\n"); - fprintf (src, " char c;\n"); - fprintf (src, " if (sscanf (strindex, \"insert %%lu%%c\", &index, &c) == 1)\n"); - fprintf (src, " {\n"); - fprintf (src, " insert = true;\n"); - fprintf (src, " }\n"); - fprintf (src, " else if (sscanf (strindex, \"%%lu%%c\", &index, &c) == 1)\n"); - fprintf (src, " {\n"); - fprintf (src, " insert = false;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " return NULL;\n"); - fprintf (src, " if (insert && index == Count())\n"); - fprintf (src, " return Append();\n"); - fprintf (src, " if (index >= Count())\n"); - fprintf (src, " return NULL;\n"); - fprintf (src, " SetCurrElmt (index);\n"); - fprintf (src, " return insert ? InsertBefore() : Curr();\n"); - fprintf (src, "}\n\n"); - -#if TCL - if (printTclG) - { - fprintf (hdr, "#if TCL\n"); - fprintf (src, "#if TCL\n\n"); - - fprintf (hdr, " int TclGetDesc (Tcl_DString *) const;\n"); - fprintf (hdr, " int TclGetVal (Tcl_Interp *) const;\n"); - fprintf (hdr, " int TclSetVal (Tcl_Interp *, const char *valstr);\n"); - fprintf (hdr, " int TclUnsetVal (Tcl_Interp *, const char *indexstr);\n"); - - fprintf (src, "int %s::TclGetDesc (Tcl_DString *valstr) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " char countstr[80];\n"); - fprintf (src, " sprintf (countstr, \"%%lu\", count);\n"); - fprintf (src, " Tcl_DStringAppendElement (valstr, countstr);\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, " return _desc.base->AsnTypeDesc::TclGetDesc (valstr);\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclGetVal (Tcl_Interp *interp) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Tcl_DString valstr;\n"); - fprintf (src, " Tcl_DStringInit (&valstr);\n"); - fprintf (src, " //for (SetCurrToFirst(); Curr(); GoNext())\n"); - fprintf (src, " for (const AsnListElmt *run=first; run; run=run->next)\n"); - fprintf (src, " {\n"); - fprintf (src, " if (run->elmt->TclGetVal (interp) != TCL_OK)\n"); - fprintf (src, " {\n"); - fprintf (src, " Tcl_DStringFree (&valstr);\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " Tcl_DStringAppendElement (&valstr, interp->result);\n"); - fprintf (src, " }\n"); - fprintf (src, " Tcl_ResetResult (interp);\n"); - fprintf (src, " Tcl_DStringResult (interp, &valstr);\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclSetVal (Tcl_Interp *interp, const char *valstr)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Args elem;\n"); - fprintf (src, " if (Tcl_SplitList (interp, (char*)valstr, &elem.c, &elem.v) != TCL_OK)\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, "\n"); - fprintf (src, " while (First())\n"); - fprintf (src, " RemoveCurrFromList();\n"); - fprintf (src, "\n"); - fprintf (src, " for (int i=0; iTclSetVal (interp, elem.v[i]) != TCL_OK)\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " }\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "int %s::TclUnsetVal (Tcl_Interp *interp, const char *indexstr)\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " int index;\n"); - fprintf (src, " if (Tcl_GetInt (interp, (char*)indexstr, &index) != TCL_OK)\n"); - fprintf (src, " return TCL_ERROR;\n"); - fprintf (src, " if (index >= Count())\n"); - fprintf (src, " {\n"); - fprintf (src, " sprintf (interp->result, \"error: list: index %%d out of range (0-%%d)\", index, Count()-1);\n"); - fprintf (src, " return NULL;\n"); - fprintf (src, " }\n"); - fprintf (src, " SetCurrElmt (index);\n"); - fprintf (src, " RemoveCurrFromList();\n"); - fprintf (src, " return TCL_OK;\n"); - fprintf (src, "}\n\n"); - - fprintf (hdr, "#endif // TCL\n"); - fprintf (src, "#endif // TCL\n\n"); - } -#endif /* TCL */ - - fprintf (hdr, "#endif // META\n\n"); - fprintf (src, "#endif // META\n\n"); - } -#endif /* META */ - - - fprintf (hdr, " %s() { count = 0; first = curr = last = NULL; }\n", lcn); - - fprintf (hdr, " %s (const %s &);\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - - fprintf (hdr, " virtual ~%s();\n", td->cxxTypeDefInfo->className); - - /* print clone routine for ANY mgmt */ - PrintCloneMethod (hdr, src, td); - - fprintf (hdr, " %s &operator = (const %s &);\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - - fprintf (hdr, " void SetCurrElmt (unsigned long int index);\n"); - fprintf (hdr, " unsigned long int GetCurrElmtIndex();\n"); - fprintf (hdr, " void SetCurrToFirst() { curr = first; }\n"); - fprintf (hdr, " void SetCurrToLast() { curr = last; }\n"); - - fprintf (hdr, " // reading member fcns\n"); - fprintf (hdr, " int Count() const { return count; }\n"); - fprintf (hdr, " // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!)\n"); - fprintf (hdr, " %s *First() const { return count > 0 ? first->elmt : NULL; }\n", ecn); - fprintf (hdr, " %s *Last() const { return count > 0 ? last->elmt : NULL; }\n", ecn); - fprintf (hdr, " %s *Curr() const { return curr ? curr->elmt : NULL; }\n", ecn); - fprintf (hdr, " %s *Next() const { return curr && curr->next ? curr->next->elmt : NULL; }\n", ecn); - fprintf (hdr, " %s *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; }\n\n", ecn); - - fprintf (hdr, " // routines that move the curr elmt\n"); - fprintf (hdr, " %s *GoNext() { if (curr) curr = curr->next; return Curr(); }\n", ecn); - fprintf (hdr, " %s *GoPrev() { if (curr) curr = curr->prev; return Curr(); }\n\n", ecn); - - fprintf (hdr, " // write & alloc fcns - returns new elmt\n"); - fprintf (hdr, " %s *Append(); // add elmt to end of list\n", ecn); - fprintf (hdr, " %s *Prepend(); // add elmt to beginning of list\n", ecn); - fprintf (hdr, " %s *InsertBefore(); //insert elmt before current elmt\n", ecn); - fprintf (hdr, " %s *InsertAfter(); //insert elmt after current elmt\n\n", ecn); - - fprintf (hdr, " // write & alloc & copy - returns list after copying elmt\n"); - fprintf (hdr, " %s &AppendCopy (%s &elmt); // add elmt to end of list\n", lcn, ecn); - fprintf (hdr, " %s &PrependCopy (%s &elmt); // add elmt to beginning of list\n", lcn, ecn); - fprintf (hdr, " %s &InsertBeforeAndCopy (%s &elmt); //insert elmt before current elmt\n", lcn, ecn); - fprintf (hdr, " %s &InsertAfterAndCopy (%s &elmt); //insert elmt after current elmt\n\n", lcn, ecn); - - fprintf (hdr, " // removing the current elmt from the list\n"); - fprintf (hdr, " void RemoveCurrFromList();\n\n"); - - fprintf (hdr, " // encode and decode routines \n"); - - /* print PDU oriented encode routine */ - if (printEncodersG) - { - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeBaseName, bufTypeNameG); - - fprintf (src, "%s %s::B%s (%s b)\n", lenTypeNameG, td->cxxTypeDefInfo->className, r->encodeBaseName, bufTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s l;\n", lenTypeNameG); - - /* encode the list content */ - fprintf (src, " l = B%s (b);\n", r->encodeContentBaseName); - - /* encode each tag/len pair if any */ - FOR_EACH_LIST_ELMT_RVS (tag, lst->tags) - { - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (CONS); /* choices are constructed */ - tagLen = TagByteLen (tag->code); - - /* always constructed lengths for list */ - fprintf (src, " l += BEncConsLen (b, l);\n"); - - if (tag->tclass == UNIV) - fprintf (src, " l += BEncTag%d (b, %s, %s, %s);\n", tagLen, classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, " l += BEncTag%d (b, %s, %s, %d);\n", tagLen, classStr, formStr, tag->code); - } - fprintf (src, " return l;\n"); - fprintf (src, "}\n\n"); - } - /* end of ber encode function */ - - /* do BerDecode function */ - if (printDecodersG) - { - fprintf (hdr, " void B%s (%s b, %s &bytesDecoded, %s env);\n", r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (src, "void %s::B%s (%s b, %s &bytesDecoded, %s env)\n", td->cxxTypeDefInfo->className, r->decodeBaseName, bufTypeNameG, lenTypeNameG, envTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s tag;\n", tagTypeNameG); - - /* print extra locals for redundant lengths */ - for (i = 1; (lst->tags != NULL) && (i <= LIST_COUNT (lst->tags)); i++) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i); - fprintf (src, "\n"); - - /* decode tag/length pair (s) */ - elmtLevel = 0; - FOR_EACH_LIST_ELMT (tag, lst->tags) - { - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (CONS); /* lists are constructed */ - - fprintf (src, " if ((tag = BDecTag (b, bytesDecoded, env)) != "); - - if (tag->tclass == UNIV) - fprintf (src, "MAKE_TAG_ID (%s, %s, %s))\n", classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src, "MAKE_TAG_ID (%s, %s, %d))\n", classStr, formStr, tag->code); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"%s::B%s: ERROR - wrong tag\" << endl;\n", td->cxxTypeDefInfo->className, r->decodeBaseName); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n"); - - fprintf (src, " elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - - fprintf (src, " B%s (b, tag, elmtLen%d, bytesDecoded, env);\n", r->decodeContentBaseName, elmtLevel); - - /* grab any EOCs that match redundant, indef lengths */ - for (i = elmtLevel-1; i > 0; i--) - { - fprintf (src, " if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, bytesDecoded, env);\n"); - } - - fprintf (src, "}\n\n"); - } - /* end of BDec function */ - - - if (printEncodersG) - fprintf (hdr, " %s B%s (%s b);\n", lenTypeNameG, r->encodeContentBaseName, bufTypeNameG); - - if (printDecodersG) - fprintf (hdr, " void B%s (%s b, %s tag, %s elmtLen, %s &bytesDecoded, %s env);\n\n", r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG, lenTypeNameG, envTypeNameG); - - fprintf (hdr, " PDU_MEMBER_MACROS\n"); - - if (printPrintersG) { - fprintf (hdr, " void Print (ostream &os) const;\n"); - } - fprintf (hdr, "};\n\n\n"); - -} /* PrintCxxListClass */ - - -/* - * Prints code to decode and check tags and lengths for a - * SEQ OF/SET OF element. - * - * as usual, assumes: - * b for buf var name - * elmtLen for elmts len var name - * env for environment var name - * listBytesDecoded for the runing total bytes decoded - * tag1 for tag - * - * Assumes first tag has been decoded and is in 'tag1' var - */ -static void -PrintCxxListTagAndLenDecCode PARAMS ((src, td, t), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t) -{ - TagList *tags; - Tag *tag; - int elmtLevel; - int stoleChoiceTags; - - elmtLevel = 0; - - tags = GetTags (t, &stoleChoiceTags); - if (stoleChoiceTags) - { - fprintf (src, " if (!("); - FOR_EACH_LIST_ELMT (tag, tags) - { - fprintf (src, "(tag1 == "); - PrintMakeTag (src, tag); - if (tag->form == ANY_FORM) - { - fprintf (src, ")\n || (tag1 == "); - tag->form = CONS; - PrintMakeTag (src, tag); - fprintf (src, ")\n"); - } - else - fprintf (src, ")"); - - if (tag != (Tag *)LAST_LIST_ELMT (tags)) - fprintf (src, "\n || "); - } - fprintf (src, "))\n"); - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"Unexpected Tag\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n\n"); - fprintf (src, " elmtLen%d = BDecLen (b, listBytesDecoded, env);\n", ++elmtLevel); - } - - else /* didn't steal nested choice's tags */ - { - AsnListFirst (tags); - - FOR_EACH_LIST_ELMT (tag, tags) - { - - fprintf (src, " if ((tag1 != "); - PrintMakeTag (src, tag); - if (tag->form == ANY_FORM) - { - fprintf (src, ")\n && (tag1 != "); - tag->form = CONS; - PrintMakeTag (src, tag); - fprintf (src, "))\n"); - } - else - fprintf (src, "))\n"); - - fprintf (src, " {\n"); - fprintf (src, " Asn1Error << \"Unexpected Tag\" << endl;\n"); - #if SNACC_EXCEPTION_ENABLE - fprintf (src, " SnaccExcep::throwMe(%d);\n", longJmpValG--); - #else - fprintf (src, " longjmp (env, %d);\n", longJmpValG--); - #endif /* SNACC_EXCEPTION_ENABLE */ - fprintf (src, " }\n\n"); - fprintf (src, " elmtLen%d = BDecLen (b, listBytesDecoded, env);\n", ++elmtLevel); - - if (tag != (Tag*)LAST_LIST_ELMT (tags)) - fprintf (src, " tag1 = BDecTag (b, listBytesDecoded, env);\n\n"); - - } - - /* - * if this seq element is CHOICE && - * we didn't steal its tags then we must grab - * the key tag out of the contained CHOICE - */ - if (GetBuiltinType (t) == BASICTYPE_CHOICE) - { - fprintf (src, " tag1 = BDecTag (b, listBytesDecoded, env);\n"); - fprintf (src, " elmtLen%d = BDecLen (b, listBytesDecoded, env);\n", ++elmtLevel); - } - } - FreeTags (tags); -} /* PrintCxxListTagAndLenDecCode */ - -/* - * This major Bogosity results from gcc2.2.2 inability to handle - * templates properly - */ -static void -PrintCxxListMethods PARAMS ((src, hdr, mods, m, r, td, parent, lst, novolatilefuncs), - FILE *src _AND_ - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *lst _AND_ - int novolatilefuncs) -{ - char *lcn; /* list class name */ - char *ecn; /* (list) elmt class name */ - int elmtLevel; - int i; - enum BasicTypeChoiceId tmpTypeId; - Tag *tag; - char *classStr; - char *formStr; - int tagLen; - - lcn = td->cxxTypeDefInfo->className; - ecn = lst->basicType->a.setOf->cxxTypeRefInfo->className; - - fprintf (src, "%s::%s (const %s &)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " Asn1Error << \"use of incompletely defined %s::%s (const %s &)\" << endl;\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, " abort();\n"); - fprintf (src, "}\n\n"); - - fprintf (src, "%s::~%s()\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - fprintf (src, " SetCurrToFirst();\n"); - fprintf (src, " for (; Curr() != NULL; RemoveCurrFromList())\n"); - fprintf (src, " ;\n"); - fprintf (src, "} // end of destructor\n\n"); - - fprintf (src, "#if SNACC_DEEP_COPY\n"); - fprintf (src, "%s &%s::operator = (const %s &that)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "#else // SNACC_DEEP_COPY\n"); - fprintf (src, "%s &%s::operator = (const %s &)\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, "#endif // SNACC_DEEP_COPY\n"); - fprintf (src, "{\n"); - fprintf (src, "#if SNACC_DEEP_COPY\n"); - fprintf (src, " if (this != &that)\n"); - fprintf (src, " {\n"); - fprintf (src, " SetCurrToFirst();\n"); - fprintf (src, " for (; Curr(); RemoveCurrFromList())\n"); - fprintf (src, " ;\n"); - fprintf (src, "\n"); - fprintf (src, " //that.SetCurrToFirst();\n"); - fprintf (src, " //for (; that.Curr(); that.GoNext())\n"); - fprintf (src, " // AppendCopy (*that.Curr());\n"); - fprintf (src, " for (const AsnListElmt *run=that.first; run; run=run->next)\n"); - fprintf (src, " AppendCopy (*run->elmt);\n"); - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " return *this;\n"); - fprintf (src, "#else // SNACC_DEEP_COPY\n"); - fprintf (src, " Asn1Error << \"use of incompletely defined %s &%s::operator = (const %s &)\" << endl;\n", td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className, td->cxxTypeDefInfo->className); - fprintf (src, " abort();\n"); - fprintf (src, " // if your compiler complains here, check the -novolat option\n"); - if (novolatilefuncs) - { - fprintf (src, " return *this;\n"); - } - fprintf (src, "#endif // SNACC_DEEP_COPY\n"); - fprintf (src, "}\n\n"); - - if (printPrintersG) - { - fprintf (src, "void %s::Print (ostream &os) const\n", td->cxxTypeDefInfo->className); - fprintf (src, "{\n"); - #ifdef __APPLE__ - fprintf (src, "#ifndef NDEBUG\n"); - #endif - fprintf (src, " os << \"{ -- SEQUENCE/SET OF -- \" << endl;\n"); - fprintf (src, " indentG += stdIndentG;\n"); - - fprintf (src, " //SetCurrToFirst();\n"); - fprintf (src, " //for (; Curr() != NULL; GoNext())\n"); - fprintf (src, " for (const AsnListElmt *run=first; run; run=run->next)\n"); - fprintf (src, " {\n"); - fprintf (src, " Indent (os, indentG);\n"); - fprintf (src, " //os << *Curr();\n"); - fprintf (src, " os << *run->elmt;\n"); - fprintf (src, " //if (Curr() != Last())\n"); - fprintf (src, " if (run != last)\n"); - fprintf (src, " os << \",\";\n"); - fprintf (src, " os << endl;\n"); - fprintf (src, " }\n"); - - fprintf (src, " indentG -= stdIndentG;\n"); - fprintf (src, " Indent (os, indentG);\n"); -#ifdef KHO - fprintf (src, " os << \"}\\n\";\n"); -#else - fprintf (src, " os << \"}\";\n"); -#endif - - #ifdef __APPLE__ - fprintf (src, "#endif /* NDEBUG */\n\n\n"); - #endif - fprintf (src, "} // Print\n\n\n"); - } - - fprintf (src, "void %s::SetCurrElmt (unsigned long int index)\n", lcn); - fprintf (src, "{\n"); - fprintf (src, " unsigned long int i;\n"); - fprintf (src, " curr = first;\n"); - fprintf (src, " if (count)\n"); - fprintf (src, " for (i = 0; (i < (count-1)) && (i < index); i++)\n"); - fprintf (src, " curr = curr->next;\n"); - fprintf (src, "} // %s::SetCurrElmt\n\n\n", lcn); - - - fprintf (src, "unsigned long int %s::GetCurrElmtIndex()\n", lcn); - fprintf (src, "{\n"); - fprintf (src, " unsigned long int i;\n"); - fprintf (src, " AsnListElmt *tmp;\n"); - fprintf (src, " if (curr != NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " for (i = 0, tmp = first; tmp != NULL; i++)\n"); - fprintf (src, " {\n"); - fprintf (src, " if (tmp == curr)\n"); - fprintf (src, " return i;\n"); - fprintf (src, " else\n"); - fprintf (src, " tmp = tmp->next;\n"); - fprintf (src, " }\n"); - fprintf (src, " }\n"); - fprintf (src, " return count;\n"); - fprintf (src, "} // %s::GetCurrElmtIndex\n\n\n", lcn); - - - fprintf (src, "// alloc new list elmt, put at end of list\n"); - fprintf (src, "// and return the component type\n"); - fprintf (src, "%s *%s::Append()\n", ecn, lcn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *newElmt;\n"); - fprintf (src, " newElmt = new AsnListElmt;\n"); - fprintf (src, " newElmt->elmt = new %s;\n", ecn); - fprintf (src, " newElmt->next = NULL;\n"); - fprintf (src, " if (last == NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->prev = NULL;\n"); - fprintf (src, " first = last = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->prev = last;\n"); - fprintf (src, " last->next = newElmt;\n"); - fprintf (src, " last = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " count++;\n"); - fprintf (src, " return (curr = newElmt)->elmt;\n"); - fprintf (src, "} // %s::Append\n\n\n", lcn); - - - fprintf (src, "// alloc new list elmt, put at begining of list\n"); - fprintf (src, "// and return the component type\n"); - fprintf (src, "%s *%s::Prepend()\n", ecn, lcn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *newElmt;\n"); - fprintf (src, " newElmt = new AsnListElmt;\n"); - fprintf (src, " newElmt->elmt = new %s;\n", ecn); - fprintf (src, " newElmt->prev = NULL;\n"); - fprintf (src, " if (first == NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->next = NULL;\n"); - fprintf (src, " first = last = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->next = first;\n"); - fprintf (src, " first->prev = newElmt;\n"); - fprintf (src, " first = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " count++;\n"); - fprintf (src, " return (curr = newElmt)->elmt;\n"); - fprintf (src, "} // %s::Prepend\n\n\n", lcn); - - - fprintf (src, "// alloc new list elmt, insert it before the\n"); - fprintf (src, "// current element and return the component type\n"); - fprintf (src, "// if the current element is null, the new element\n"); - fprintf (src, "// is placed at the beginning of the list.\n"); - fprintf (src, "%s *%s::InsertBefore()\n", ecn, lcn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *newElmt;\n"); - fprintf (src, " newElmt = new AsnListElmt;\n"); - fprintf (src, " newElmt->elmt = new %s;\n", ecn); - fprintf (src, " if (curr == NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->next = first;\n"); - fprintf (src, " newElmt->prev = NULL;\n"); - fprintf (src, " first = newElmt;\n"); - fprintf (src, " if (last == NULL)\n"); - fprintf (src, " last = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->next = curr;\n"); - fprintf (src, " newElmt->prev = curr->prev;\n"); - fprintf (src, " curr->prev = newElmt;\n"); - fprintf (src, " if (curr == first)\n"); - fprintf (src, " first = newElmt;\n"); - fprintf (src, " else\n"); - fprintf (src, " newElmt->prev->next = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " count++;\n"); - fprintf (src, " return (curr = newElmt)->elmt;\n"); - fprintf (src, "} // %s::InsertBefore\n\n\n", lcn); - - - fprintf (src, "// alloc new list elmt, insert it after the\n"); - fprintf (src, "// current element and return the component type\n"); - fprintf (src, "// if the current element is null, the new element\n"); - fprintf (src, "// is placed at the end of the list.\n"); - fprintf (src, "%s *%s::InsertAfter()\n", ecn, lcn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *newElmt;\n"); - fprintf (src, " newElmt = new AsnListElmt;\n"); - fprintf (src, " newElmt->elmt = new %s;\n", ecn); - fprintf (src, " if (curr == NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->prev = last;\n"); - fprintf (src, " newElmt->next = NULL;\n"); - fprintf (src, " last = newElmt;\n"); - fprintf (src, " if (first == NULL)\n"); - fprintf (src, " first = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->prev = curr;\n"); - fprintf (src, " newElmt->next = curr->next;\n"); - fprintf (src, " curr->next = newElmt;\n"); - fprintf (src, " if (curr == last)\n"); - fprintf (src, " last = newElmt;\n"); - fprintf (src, " else\n"); - fprintf (src, " newElmt->next->prev = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " count++;\n"); - fprintf (src, " return (curr = newElmt)->elmt;\n"); - fprintf (src, "} // %s::InsertAfter\n\n\n", lcn); - - - fprintf (src, "%s &%s::AppendCopy (%s &elmt)\n", lcn, lcn, ecn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *newElmt;\n"); - fprintf (src, " newElmt = new AsnListElmt;\n"); - fprintf (src, " newElmt->elmt = new %s;\n", ecn); - fprintf (src, " *newElmt->elmt = elmt;\n"); - fprintf (src, " newElmt->next = NULL;\n"); - fprintf (src, " if (last == NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->prev = NULL;\n"); - fprintf (src, " first = last = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->prev = last;\n"); - fprintf (src, " last->next = newElmt;\n"); - fprintf (src, " last = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " count++;\n"); - fprintf (src, " return *this;\n"); - fprintf (src, "} // AppendCopy\n\n\n"); - - - fprintf (src, "%s &%s::PrependCopy (%s &elmt)\n", lcn, lcn, ecn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *newElmt;\n"); - fprintf (src, " newElmt = new AsnListElmt;\n"); - fprintf (src, " newElmt->elmt = new %s;\n", ecn); - fprintf (src, " *newElmt->elmt = elmt;\n"); - fprintf (src, " newElmt->prev = NULL;\n"); - fprintf (src, " if (first == NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->next = NULL;\n"); - fprintf (src, " first = last = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->next = first;\n"); - fprintf (src, " first->prev = newElmt;\n"); - fprintf (src, " first = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " count++;\n"); - fprintf (src, " return *this;\n"); - fprintf (src, "} // %s::PrependCopy\n\n\n", lcn); - - - fprintf (src, "// alloc new list elmt, insert it before the\n"); - fprintf (src, "// current element, copy the given elmt into the new elmt\n"); - fprintf (src, "// and return the component type.\n"); - fprintf (src, "// if the current element is null, the new element\n"); - fprintf (src, "// is placed at the beginning of the list.\n"); - fprintf (src, "%s &%s::InsertBeforeAndCopy (%s &elmt)\n", lcn, lcn, ecn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *newElmt;\n"); - fprintf (src, "\n"); - fprintf (src, " newElmt = new AsnListElmt;\n"); - fprintf (src, " newElmt->elmt = new %s;\n", ecn); - fprintf (src, " *newElmt->elmt = elmt;\n"); - fprintf (src, "\n"); - fprintf (src, " if (curr == NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->next = first;\n"); - fprintf (src, " newElmt->prev = NULL;\n"); - fprintf (src, " first = newElmt;\n"); - fprintf (src, " if (last == NULL)\n"); - fprintf (src, " last = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->next = curr;\n"); - fprintf (src, " newElmt->prev = curr->prev;\n"); - fprintf (src, " curr->prev = newElmt;\n"); - fprintf (src, " if (curr == first)\n"); - fprintf (src, " first = newElmt;\n"); - fprintf (src, " else\n"); - fprintf (src, " newElmt->prev->next = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " count++;\n"); - fprintf (src, " return *this;\n"); - fprintf (src, "} // %s::InsertBeforeAndCopy\n\n\n", lcn); - - - fprintf (src, "// alloc new list elmt, insert it after the\n"); - fprintf (src, "// current element, copy given elmt in to new elmt\n"); - fprintf (src, "// and return the component type\n"); - fprintf (src, "// if the current element is null, the new element\n"); - fprintf (src, "// is placed at the end of the list.\n"); - fprintf (src, "%s &%s::InsertAfterAndCopy (%s &elmt)\n", lcn, lcn, ecn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *newElmt;\n"); - fprintf (src, "\n"); - fprintf (src, " newElmt = new AsnListElmt;\n"); - fprintf (src, " newElmt->elmt = new %s;\n", ecn); - fprintf (src, " *newElmt->elmt = elmt;\n"); - fprintf (src, " if (curr == NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->prev = last;\n"); - fprintf (src, " newElmt->next = NULL;\n"); - fprintf (src, " last = newElmt;\n"); - fprintf (src, " if (first == NULL)\n"); - fprintf (src, " first = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " newElmt->prev = curr;\n"); - fprintf (src, " newElmt->next = curr->next;\n"); - fprintf (src, " curr->next = newElmt;\n"); - fprintf (src, " if (curr == last)\n"); - fprintf (src, " last = newElmt;\n"); - fprintf (src, " else\n"); - fprintf (src, " newElmt->next->prev = newElmt;\n"); - fprintf (src, " }\n"); - fprintf (src, " count++;\n"); - fprintf (src, " return *this;\n"); - fprintf (src, "} // %s::InsertAfterAndCopy\n\n\n", lcn); - - - fprintf (src, "// remove current element from list if current element is not NULL \n"); - fprintf (src, "// The new current element will be the next element.\n"); - fprintf (src, "// If the current element is the last element in the list\n"); - fprintf (src, "// the second but last element will become the new current element.\n"); - fprintf (src, "void %s::RemoveCurrFromList()\n", lcn); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *del_elmt;\n"); - fprintf (src, "\n"); - fprintf (src, " if (curr != NULL)\n"); - fprintf (src, " {\n"); - fprintf (src, " del_elmt = curr;\n"); - fprintf (src, " count--;\n"); - fprintf (src, "\n"); - fprintf (src, " if (count == 0)\n"); - fprintf (src, " first = last = curr = NULL;\n"); - fprintf (src, " else if (curr == first)\n"); - fprintf (src, " {\n"); - fprintf (src, " curr = first= first->next;\n"); - fprintf (src, " first->prev = NULL;\n"); - fprintf (src, " }\n"); - fprintf (src, " else if (curr == last)\n"); - fprintf (src, " {\n"); - fprintf (src, " curr = last = last->prev;\n"); - fprintf (src, " last->next = NULL;\n"); - fprintf (src, " }\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - fprintf (src, " curr->prev->next = curr->next;\n"); - fprintf (src, " curr->next->prev = curr->prev;\n"); - fprintf (src, " }\n"); - fprintf (src, "\n"); - fprintf (src, " delete del_elmt->elmt;\n"); - fprintf (src, " delete del_elmt;\n"); - fprintf (src, " }\n"); - fprintf (src, "}\n\n\n"); - - if (printEncodersG) - { - fprintf (src, "%s %s::B%s (%s b)\n", lenTypeNameG, lcn, r->encodeContentBaseName, bufTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " AsnListElmt *currElmt;\n"); - fprintf (src, " %s elmtLen;\n", lenTypeNameG); - fprintf (src, " %s totalLen = 0;\n", lenTypeNameG); - -#ifdef VDADER_RULES - if (gVDADER_RULES && lst->basicType->choiceId != BASICTYPE_SETOF) - { -#endif - fprintf (src, " for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)\n"); - fprintf (src, " {\n"); - /* encode Eoc (s) if nec */ - PrintCxxEocEncoders (src, td, lst->basicType->a.setOf, "b"); - - tmpTypeId = GetBuiltinType (lst->basicType->a.setOf); - /* list element types cannot by ANY DEFINED BY */ - if (tmpTypeId == BASICTYPE_ANY) - { - fprintf (src, " currElmt->elmt->SetTypeBy???(???);\n"); - fprintf (src, " elmtLen = currElmt->elmt->B%s (b);\n", r->encodeBaseName); - } - else - { - fprintf (src, " elmtLen = currElmt->elmt->B%s (b);\n", r->encodeContentBaseName); - } - - /* encode list elmt tag/len pairs here */ - PrintCxxTagAndLenEncodingCode (src, td, lst->basicType->a.setOf, "elmtLen", "b"); - - fprintf (src, " totalLen += elmtLen;\n"); - fprintf (src, " }\n"); - -#ifdef VDADER_RULES - } - /** handling of SET OF encoding - **/ - else if (gVDADER_RULES && lst->basicType->choiceId == BASICTYPE_SETOF) - VDA_ProcessSetOf(src, td, lst, r); -#endif - - fprintf (src, " return totalLen;\n"); - fprintf (src, "} // %s::B%s\n\n\n", lcn, r->encodeContentBaseName); - } /** END IF for printDecodersG **/ - - if (printDecodersG) - { - fprintf (src, "void %s::B%s (%s b, %s /*tag0*/, %s elmtLen0,\n", lcn, r->decodeContentBaseName, bufTypeNameG, tagTypeNameG, lenTypeNameG); - fprintf (src, " %s &bytesDecoded, %s env)\n", lenTypeNameG, envTypeNameG); - fprintf (src, "{\n"); - fprintf (src, " %s *listElmt;\n", ecn); - -#ifdef VDADER_RULES - tmpTypeId = GetBuiltinType (lst->basicType->a.setOf); - - if ( tmpTypeId != BASICTYPE_ANY || ! gVDADER_RULES ) - fprintf (src, " %s tag1;\n", tagTypeNameG); -#endif - - fprintf (src, " %s listBytesDecoded = 0;\n", lenTypeNameG); - - /* print local vars elmtLen for decoding list component */ - elmtLevel = CxxCountVariableLevels (lst->basicType->a.setOf); - - for (i = 1; i <= elmtLevel; i++) - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i); - - fprintf (src, "\n"); - - - fprintf (src, " while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))\n"); - fprintf (src, " {\n"); - -#ifdef VDADER_RULES - /* decode content */ - /* note: cannot be ANY DEFINED BY as SET OF/SEQ OF ELMT */ - if ( tmpTypeId != BASICTYPE_ANY || ! gVDADER_RULES) /** RWC; 4/98 **/ - { -#endif - - - fprintf (src, " tag1 = BDecTag (b, listBytesDecoded, env);\n"); - - fprintf (src, " if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))\n"); - fprintf (src, " {\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);\n"); - fprintf (src, " break;\n"); - fprintf (src, " }\n"); - - PrintCxxListTagAndLenDecCode (src, td, lst->basicType->a.setOf); - - fprintf (src, " listElmt = Append();\n"); - -#ifdef VDADER_RULES - fprintf (src, " listElmt->B%s (b, tag1, elmtLen%d, listBytesDecoded, env);\n", r->decodeContentBaseName, elmtLevel); - - } - else - { - fprintf (src, " listElmt = Append();\n"); -#else - /* decode content */ - tmpTypeId = GetBuiltinType (lst->basicType->a.setOf); - /* note: cannot be ANY DEFINED BY as SET OF/SEQ OF ELMT */ - if (tmpTypeId == BASICTYPE_ANY) - { -#endif - -#ifdef VDADER_RULES -if (!gVDADER_RULES) -{ -#endif - fprintf (src, " listElmt->SetTypeBy???(???);\n"); - - fprintf (src, " listElmt->B%s (b, listBytesDecoded, env);\n", r->decodeBaseName, elmtLevel); - -#ifdef VDADER_RULES -} -else - { - fprintf (src, " DEC_LOAD_ANYBUF("); - fprintf (src, "listElmt, b, listBytesDecoded, env);\n"); - } - } /* end of else */ -#else - } /* end of if BASIC_ANY_TYPE */ - else - fprintf (src, " listElmt->B%s (b, tag1, elmtLen%d, listBytesDecoded, env);\n", r->decodeContentBaseName, elmtLevel); -#endif - /* grab any EOCs that match redundant, indef lengths */ - for (i = elmtLevel-1; i > 0; i--) - { - fprintf (src, " if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src, " BDecEoc (b, listBytesDecoded, env);\n"); - } - - - fprintf (src, " }\n\n"); /* end of while */ - - fprintf (src, " bytesDecoded += listBytesDecoded;\n"); - - fprintf (src, "} // %s::B%s\n\n\n", lcn, r->decodeContentBaseName); - } - -} /* PrintCxxListMethods */ - -static void -PrintCxxSetOfDefCode PARAMS ((src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, parent, setOf, novolatilefuncs), - FILE *src _AND_ - FILE *hdr _AND_ - if_IBM_ENC (FILE *srcdb _AND_) - if_IBM_ENC (FILE *hdrdb _AND_) - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *setOf _AND_ - int novolatilefuncs) -{ - /* do class */ - PrintCxxListClass (src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, parent, setOf); - - /* do methods */ - PrintCxxListMethods (src, hdr, mods, m, r, td, parent, setOf, novolatilefuncs); - -} /* PrintCxxSetOfDefCode */ - - -static void -PrintCxxAnyDefCode PARAMS ((src, hdr, mods, m, r, td, parent, any), - FILE *src _AND_ - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *any) -{ - fprintf (hdr, "/* "); - SpecialPrintType (hdr, td, td->type); - fprintf (hdr, " */\n"); - fprintf (hdr, "typedef %s %s;\n\n", td->type->cxxTypeRefInfo->className, td->cxxTypeDefInfo->className); -} /* PrintCxxAnyDefCode */ - - -static void -PrintCxxTypeDefCode PARAMS ((src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, novolatilefuncs), - FILE *src _AND_ - FILE *hdr _AND_ - if_IBM_ENC (FILE *srcdb _AND_) - if_IBM_ENC (FILE *hdrdb _AND_) - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - TypeDef *td _AND_ - int novolatilefuncs) -{ - CNamedElmt *n; - - switch (td->type->basicType->choiceId) - { - case BASICTYPE_BOOLEAN: /* library type */ - case BASICTYPE_REAL: /* library type */ - case BASICTYPE_OCTETSTRING: /* library type */ - case BASICTYPE_NULL: /* library type */ - case BASICTYPE_OID: /* library type */ - case BASICTYPE_INTEGER: /* library type */ - case BASICTYPE_BITSTRING: /* library type */ - case BASICTYPE_ENUMERATED: /* library type */ - PrintCxxSimpleDef (hdr, src, if_IBM_ENC (hdrdb COMMA srcdb COMMA) if_META (m COMMA) r, td); - break; - - case BASICTYPE_SEQUENCEOF: /* list types */ - case BASICTYPE_SETOF: - PrintCxxSetOfDefCode (src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, NULL, td->type, novolatilefuncs); - break; - - case BASICTYPE_IMPORTTYPEREF: /* type references */ - case BASICTYPE_LOCALTYPEREF: - /* - * if this type has been re-tagged then - * must create new class instead of using a typedef - */ - PrintCxxSimpleDef (hdr, src, if_IBM_ENC (hdrdb COMMA srcdb COMMA) if_META (m COMMA) r, td); - break; - - case BASICTYPE_ANYDEFINEDBY: /* ANY types */ - case BASICTYPE_ANY: -/* - fprintf (stderr, " ANY types require modification. "); - fprintf (stderr, " The source files will have a \" ANY - Fix Me! \" comment before related code.\n\n"); -*/ - PrintCxxAnyDefCode (src, hdr, mods, m, r, td, NULL, td->type); - break; - - case BASICTYPE_CHOICE: - PrintCxxChoiceDefCode (src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, NULL, td->type, novolatilefuncs); - break; - - case BASICTYPE_SET: - PrintCxxSetDefCode (src, hdr, mods, m, r, td, NULL, td->type, novolatilefuncs); - break; - - case BASICTYPE_SEQUENCE: - PrintCxxSeqDefCode (src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, NULL, td->type, novolatilefuncs); - break; - - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_SELECTION: - case BASICTYPE_UNKNOWN: - case BASICTYPE_MACRODEF: - case BASICTYPE_MACROTYPE: - /* do nothing */ - break; - } -} /* PrintCxxTypeDefCode */ - -void -PrintCxxCode PARAMS ((src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) if_META (printMeta COMMA meta COMMA meta_pdus COMMA) mods, m, r, longJmpVal, printTypes, printValues, printEncoders, printDecoders, printPrinters, printFree if_TCL (COMMA printTcl), novolatilefuncs), - FILE *src _AND_ - FILE *hdr _AND_ - if_IBM_ENC (FILE *srcdb _AND_) - if_IBM_ENC (FILE *hdrdb _AND_) - if_META (MetaNameStyle printMeta _AND_) - if_META (const Meta *meta _AND_) - if_META (MetaPDU *meta_pdus _AND_) - ModuleList *mods _AND_ - Module *m _AND_ - CxxRules *r _AND_ - long int longJmpVal _AND_ - int printTypes _AND_ - int printValues _AND_ - int printEncoders _AND_ - int printDecoders _AND_ - int printPrinters _AND_ - int printFree - if_TCL (_AND_ int printTcl) _AND_ - int novolatilefuncs) -{ - TypeDef *td; - ValueDef *vd; -#ifdef _IBM_ENC_ - char mm_name[40]; -#endif /* _IBM_ENC_ */ - - longJmpValG = longJmpVal; - printTypesG = printTypes; - printEncodersG = printEncoders; - printDecodersG = printDecoders; - printPrintersG = printPrinters; - printFreeG = printFree; -#if META - printMetaG = printMeta; - meta_pdus_G = meta_pdus; -#if TCL - printTclG = printTcl; -#endif /* TCL */ -#endif /* META */ - - PrintSrcComment (src, m); - PrintHdrComment (hdr, m); -#ifdef _IBM_ENC_ - PrintSrcComment (srcdb, m); /* 20.8.93 IBM-ENC */ - PrintHdrComment (hdrdb, m); /* 20.8.93 IBM-ENC */ - - strcpy (mm_name, m->cxxHdrFileName); -#endif /* _IBM_ENC_ */ - - PrintConditionalIncludeOpen (hdr, m->cxxHdrFileName); - -#ifdef _IBM_ENC_ - mm_name[strlen (mm_name)-2]='\0'; - fprintf (hdrdb, "#ifndef _%sdb_h_\n", mm_name); - fprintf(hdrdb, "#define _%sdb_h_\n", mm_name); -#endif /* _IBM_ENC_ */ - -#if META - if (printMetaG) - { - fprintf (src, "\n"); - fprintf (src, "#ifndef META\n"); - fprintf (src, "#define META 1\n"); - fprintf (src, "#endif\n"); -#if TCL - if (printTclG) - { - fprintf (src, "#ifndef TCL\n"); - fprintf (src, "#define TCL META\n"); - fprintf (src, "#endif\n"); - } -#endif /* TCL */ - } -#endif /* META */ - - fprintf (src, "\n"); - - PrintSrcIncludes (src, if_IBM_ENC (srcdb COMMA) mods, m); - - fprintf (src, "\n"); - - fprintf (hdr, "//------------------------------------------------------------------------------\n"); - fprintf (hdr, "// class declarations:\n\n"); - FOR_EACH_LIST_ELMT (td, m->typeDefs) - PrintTypeDecl (hdr, td); - fprintf (hdr, "\n"); - -#if META - if (printMeta) - { - fprintf (hdr, "#if META\n"); - fprintf (src, "#if META\n\n"); - - fprintf (hdr, "//------------------------------------------------------------------------------\n"); - fprintf (hdr, "extern const AsnModuleDesc %sModuleDesc;\n", m->cxxname); - - fprintf (src, "//------------------------------------------------------------------------------\n"); - fprintf (src, "static const AsnTypeDesc *%sModuleTypes[] =\n", m->cxxname); - fprintf (src, "{\n"); - FOR_EACH_LIST_ELMT (td, m->typeDefs) - fprintf (src, " &%s::_desc,\n", td->cxxTypeDefInfo->className); - fprintf (src, " NULL\n"); - fprintf (src, "};\n\n"); -#if 0 /* yet unused: */ - if (printMetaG == META_backend_names) - else /* META_asn1_names */ -#endif - fprintf (src, "const AsnModuleDesc %sModuleDesc = { \"%s\", %sModuleTypes };\n\n", m->cxxname, m->modId->name, m->cxxname); - - fprintf (hdr, "#endif // META\n\n"); - fprintf (src, "#endif // META\n\n"); - } -#endif /* META */ - - if (printValues) - { - fprintf (src, "//------------------------------------------------------------------------------\n"); - fprintf (src, "// value defs\n\n"); - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - PrintCxxValueDef (src, r, vd); - fprintf (src, "\n"); - } - - fprintf (hdr, "//------------------------------------------------------------------------------\n"); - fprintf (hdr, "// class definitions:\n\n"); - fprintf (src, "//------------------------------------------------------------------------------\n"); - fprintf (src, "// class member definitions:\n\n"); - - PrintCxxAnyCode (src, hdr, r, mods, m); - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - PrintCxxTypeDefCode (src, hdr, if_IBM_ENC (srcdb COMMA hdrdb COMMA) mods, m, r, td, novolatilefuncs); - - if (printValues) - { - fprintf (hdr, "//------------------------------------------------------------------------------\n"); - fprintf (hdr, "// externs for value defs\n\n"); - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - PrintCxxValueExtern (hdr, r, vd); - } - - fprintf (hdr, "//------------------------------------------------------------------------------\n"); - PrintConditionalIncludeClose (hdr, m->cxxHdrFileName); - -#ifdef _IBM_ENC_ - fprintf (hdrdb, "#endif\n"); -#endif /* _IBM_ENC_ */ -} /* PrintCxxCode */ - - -#ifdef VDADER_RULES - -/* this routine will generate code which will encode a SET OF in using DER - * rules. - */ -long VDA_ProcessSetOf(FILE *src, - TypeDef *td, - Type *lst, - CxxRules *r) -{ - enum BasicTypeChoiceId tmpTypeId; - - - fprintf (src, " {\n"); - fprintf (src, " int iii,icount;\n CSM_Buffer **tmpEnc=NULL;\n"); - fprintf (src, " for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++);\n"); - fprintf (src, " tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount);\n"); - fprintf (src, " for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0)\n"); - fprintf (src, " {\n"); - /* encode Eoc (s) if nec */ - PrintCxxEocEncoders (src, td, lst->basicType->a.setOf, "b"); - - tmpTypeId = GetBuiltinType (lst->basicType->a.setOf); - - /* list element types cannot by ANY DEFINED BY */ - if (tmpTypeId == BASICTYPE_ANY) - { - fprintf (src, " tmpEnc[iii] = (CSM_Buffer *)currElmt->elmt->value;\n"); - } - else - { /** SEE "smimesnacc.h" for a description of these ODD macros, to - ** save space. - **/ - fprintf (src, " ENCODE_BUF1(currElmt->elmt->B%s, elmtLen);\n", r->encodeContentBaseName); - - /** encode content only into buffer. - **/ - PrintCxxTagAndLenEncodingCode (src, td, lst->basicType->a.setOf, - "elmtLen", "outputBuf"); - - /** set tag and length in "outputBuf" buffer (DEFINED IN MACRO). - **/ - fprintf (src, " ENCODE_BUF2(tmpEnc[iii]);\n"); - - /** extract buffer to "Str_struct *". - **/ - } - fprintf (src, " }\n"); - - /* encode list elmt tag/len pairs here */ - - /** NOW, we have a list of icount "CSM_Buffer"s, which are the ASN.1 - ** encoded results of all of the specified "SET OF" components here. - ** THESE MUST be re-ordered in ascending order for proper DER - ** Encoding Rule encoding. - **/ - - fprintf (src, " vdasnacc_sortSetOf(tmpEnc, icount);\n"); - /** These "SET OF" components are now ordered in ascending order, - ** ready to be loaded into the output buffer. (RWC; TBD; make output - ** buffers accept these allocated buffers directly, no copy). - **/ - - fprintf (src, " for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length())\n"); - fprintf (src, " SM_WriteToAsnBuf(tmpEnc[iii], b);\n"); - /**fprintf (src, " b.PutSegRvs((char *)tmpEnc[iii]->str, tmpEnc[iii]->lgth);\n");**/ - if (tmpTypeId != BASICTYPE_ANY) /** FREE resources loaded here. **/ - fprintf (src, " for (iii=0; iii < icount; iii++) delete tmpEnc[iii];\n"); - fprintf (src, " free(tmpEnc);\n"); - fprintf (src, " }\n"); - fprintf (src, " totalLen += elmtLen;\n"); - - return(0); -} /** END else BASICTYPE_SETOF, RWC; only for VDADER_RULES define **/ - -#endif diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-code.h b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-code.h deleted file mode 100644 index 46308264..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-code.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/gen_code.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/gen-code.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-code.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:40 aram - * Originals from SMIME Free Library. - * - * Revision 1.6 1997/02/16 15:14:10 rj - * made return *this after calling abort()'' a compile time option. - * - * Revision 1.5 1995/09/07 19:18:25 rj - * boolean genMeta changed to enum type MetaNameStyle - * - * Revision 1.4 1995/08/17 15:00:08 rj - * the PDU flag belongs to the metacode, not only to the tcl interface. (type and variable named adjusted) - * - * Revision 1.3 1995/07/27 10:53:03 rj - * file name has been shortened for redundant part: c++-gen/gen-c++-code -> c++-gen/gen-code. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:47:55 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:04 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -void PrintCxxCode PROTO ((FILE *src, FILE *hdr, if_IBM_ENC (FILE *dbsrc COMMA FILE *dbhdr COMMA) if_META (MetaNameStyle genMeta COMMA const Meta *meta COMMA MetaPDU *metapdus COMMA) ModuleList *mods, Module *m, CxxRules *r, long int longJmpVal, int printTypes, int printValues, int printEncoders, int printDecoders, int printPrinters, int printFree, if_TCL (int printTcl COMMA) int novolatilefuncs)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-vals.c b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-vals.c deleted file mode 100644 index dc278e49..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-vals.c +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/gen_vals.c - prints ASN.1 values in c++ format - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/gen-vals.c,v 1.3 2001/06/25 21:51:10 dmitch Exp $ - * $Log: gen-vals.c,v $ - * Revision 1.3 2001/06/25 21:51:10 dmitch - * Avoid instantiating AsnInt constants; use #define instead. Partial fix for Radar 2664258. - * - * Revision 1.2 2001/06/20 21:30:32 dmitch - * Per SNACC_OIDS_AS_DEFINES #define, optionally define OIDs as #defines in the header rather than as statically initialized objects in the .cpp file. - * - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:40 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:20:05 rj - * use true/false instead of AsnBool::true/false. - * - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:47:57 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:17:22 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:05 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "oid.h" -#include "mem.h" -#include "define.h" -#include "lib-types.h" -#include "str-util.h" -#include "snacc-util.h" -#include "rules.h" -#include "gen-vals.h" - -/* non-exported routines' prototypes */ - -static void PrintCxxValueDefsName PROTO ((FILE *f, CxxRules *r, ValueDef *v)); - - - - -void -PrintCxxValueDef PARAMS ((src, r, v), - FILE *src _AND_ - CxxRules *r _AND_ - ValueDef *v) -{ - /* just do oid's, ints and bools for now */ - if ( - #if !SNACC_OIDS_AS_DEFINES - (v->value->basicValue->choiceId != BASICVALUE_OID) && - #endif /* SNACC_OIDS_AS_DEFINES */ - #if !SNACC_INTS_AS_DEFINES - (v->value->basicValue->choiceId != BASICVALUE_INTEGER) && - #endif /* !SNACC_INTS_AS_DEFINES */ - (v->value->basicValue->choiceId != BASICVALUE_BOOLEAN)) - return; - - /* - * put instantiation in src file - */ - fprintf (src, "const "); - PrintCxxValuesClass (src, r, v->value); - fprintf (src, " "); - PrintCxxValueDefsName (src, r, v); - fprintf (src, " "); - PrintCxxValueInstatiation (src, r, v->value); - fprintf (src, ";\n\n"); - - -} /* PrintCxxValueDef */ - -void -PrintCxxValueExtern PARAMS ((hdr, r, v), - FILE *hdr _AND_ - CxxRules *r _AND_ - ValueDef *v) -{ - /* just do oid's, ints and bools for now */ - if ((v->value->basicValue->choiceId != BASICVALUE_OID) && - (v->value->basicValue->choiceId != BASICVALUE_INTEGER) && - (v->value->basicValue->choiceId != BASICVALUE_BOOLEAN)) - return; - - #if SNACC_OIDS_AS_DEFINES - /* - * Special case for OIDs. The format is - * - * #define oidname_arc x,y,z,... - * #define oidname AsnOid(oidname_arc) - */ - if (v->value->basicValue->choiceId == BASICVALUE_OID) { - /* first just the arc */ - fprintf (hdr, "#define "); - PrintCxxValueDefsName (hdr, r, v); - fprintf (hdr, "_arc "); - PrintCxxValueInstatiation (hdr, r, v->value); - fprintf (hdr, "\n"); - - /* now the declaration using the arc */ - fprintf (hdr, "#define "); - PrintCxxValueDefsName (hdr, r, v); - fprintf (hdr, " "); - PrintCxxValuesClass (hdr, r, v->value); - fprintf (hdr, "("); - PrintCxxValueDefsName (hdr, r, v); - fprintf (hdr, "_arc)\n"); - - return; - } - #endif /* SNACC_OIDS_AS_DEFINES */ - - #if SNACC_INTS_AS_DEFINES - /* - * Special case for AsnInt. The format is - * - * #define oidname_val x - * #define oidname AsnInt(oidname_val) - */ - if (v->value->basicValue->choiceId == BASICVALUE_INTEGER) { - /* first just the integer value */ - fprintf (hdr, "#define "); - PrintCxxValueDefsName (hdr, r, v); - fprintf (hdr, "_val %d\n", v->value->basicValue->a.integer); - - /* now the declaration using the val */ - fprintf (hdr, "#define "); - PrintCxxValueDefsName (hdr, r, v); - fprintf (hdr, " "); - PrintCxxValuesClass (hdr, r, v->value); - fprintf (hdr, "("); - PrintCxxValueDefsName (hdr, r, v); - fprintf (hdr, "_val)\n"); - - return; - } - #endif /* SNACC_OIDS_AS_DEFINES */ - - /* - * put extern declaration in hdr file - */ - fprintf (hdr, "extern const "); - PrintCxxValuesClass (hdr, r, v->value); - fprintf (hdr, " "); - PrintCxxValueDefsName (hdr, r, v); - fprintf (hdr, ";\n"); - -} /* PrintCxxValueExtern */ - - -static void -PrintCxxValueDefsName PARAMS ((f, r, v), - FILE *f _AND_ - CxxRules *r _AND_ - ValueDef *v) -{ - char *cName; - cName = Asn1ValueName2CValueName (v->definedName); - fprintf (f, "%s", cName); - Free (cName); -} - -void -PrintCxxValuesClass PARAMS ((f, r, v), - FILE *f _AND_ - CxxRules *r _AND_ - Value *v) -{ - /* needs work - just do ints bools and oid's for now */ - switch (v->basicValue->choiceId) - { - case BASICVALUE_OID: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_OID].className); - break; - - case BASICVALUE_INTEGER: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_INTEGER].className); - break; - - case BASICVALUE_BOOLEAN: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_BOOLEAN].className); - break; - - default: - break; - } -} - - -void -PrintCxxValueInstatiation PARAMS ((f, r, v), - FILE *f _AND_ - CxxRules *r _AND_ - Value *v) -{ - /* needs work - just do oids, ints and bools for now */ - switch (v->basicValue->choiceId) - { - case BASICVALUE_OID: - PrintCxxOidValue (f, r, v->basicValue->a.oid); - break; - - case BASICVALUE_INTEGER: - PrintCxxIntValue (f, r, v->basicValue->a.integer); - break; - - case BASICVALUE_BOOLEAN: - fprintf (f, "(%s)", v->basicValue->a.boolean ? "true" : "false"); - break; - - default: - break; - } -} - - - -/* - * given an AOID, c++ AOID constructors params are produced. - * This is used for turning ASN.1 OBJECT ID values - * into usable c++ values. - * - * eg for the oid { 0 1 2 } (in AOID format) - * (0,1,2) - * is produced. - * - * The parentheses are omitted in the SNACC_OIDS_AS_DEFINES case; we're just printing - * the arc which can be used as an arg elsewhere. - - */ -void -PrintCxxOidValue PARAMS ((f, r, v), - FILE *f _AND_ - CxxRules *r _AND_ - AsnOid *v) -{ - unsigned short int firstArcNum; - unsigned long int arcNum; - int i; - - #if !SNACC_OIDS_AS_DEFINES - fprintf (f, "("); - #endif - - /* un-munge first two arc numbers */ - for (arcNum = 0, i=0; (i < v->octetLen) && (v->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - i++; - firstArcNum = arcNum/40; - if (firstArcNum > 2) - firstArcNum = 2; - - fprintf (f, "%u, %u", firstArcNum, arcNum - (firstArcNum * 40)); - - for (; i < v->octetLen; ) - { - for (arcNum = 0; (i < v->octetLen) && (v->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - i++; - - fprintf (f, ", %u", arcNum); - } - - #if !SNACC_OIDS_AS_DEFINES - fprintf (f, ")"); - #endif - -} /* PrintCxxOidValue */ - - - -void -PrintCxxIntValue PARAMS ((f, r, v), - FILE *f _AND_ - CxxRules *r _AND_ - AsnInt v) -{ - fprintf (f, "(%d)", v); -} /* PrintCxxIntValue */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-vals.h b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-vals.h deleted file mode 100644 index 8f9934c2..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/gen-vals.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/gen_vals.h - * - * MS 92 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/gen-vals.h,v 1.3 2001/06/25 21:51:10 dmitch Exp $ - * $Log: gen-vals.h,v $ - * Revision 1.3 2001/06/25 21:51:10 dmitch - * Avoid instantiating AsnInt constants; use #define instead. Partial fix for Radar 2664258. - * - * Revision 1.2 2001/06/20 21:30:32 dmitch - * Per SNACC_OIDS_AS_DEFINES #define, optionally define OIDs as #defines in the header rather than as statically initialized objects in the .cpp file. - * - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:40 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:23:19 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:47:58 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:06 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -/* - * When true, compile OIDs as #defines in the header, not as - * statically declared constants. - */ -#define SNACC_OIDS_AS_DEFINES 1 - -/* - * When true, compile AsnInts as #defines in the header, not as - * statically declared constants. - */ -#define SNACC_INTS_AS_DEFINES 1 - - -void PrintCxxValueDef PROTO ((FILE *src, CxxRules *r, ValueDef *v)); - -void PrintCxxValueExtern PROTO ((FILE *hdr, CxxRules *r, ValueDef *v)); - -void PrintCxxValuesClass PROTO ((FILE *f, CxxRules *r, Value *v)); - -void PrintCxxValueInstatiation PROTO ((FILE *f, CxxRules *r, Value *v)); - -void PrintCxxOidValue PROTO ((FILE *f, CxxRules *r, AsnOid *oid)); - -void PrintCxxIntValue PROTO ((FILE *f, CxxRules *r, AsnInt oid)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/kwd.c b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/kwd.c deleted file mode 100644 index a61e8f6a..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/kwd.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/kwd.c - routines for determining whether a given str is a C++ - * keyword - * - * NOTE: this was hacked up really quickly. It uses a slow linear - * search. A much better approach is to use a hash tbl. - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/kwd.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: kwd.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:40 aram - * Originals from SMIME Free Library. - * - * Revision 1.7 1995/09/07 19:05:01 rj - * where the C++ compiler has got the bool type built-in, let the C++ backend avoid conflicts with the new keywords. - * - * Revision 1.6 1995/08/17 14:56:12 rj - * bool added to the list of reserved words - * - * Revision 1.5 1995/07/25 18:22:40 rj - * file name has been shortened for redundant part: c++-gen/c++-kwd -> c++-gen/kwd. - * - * Revision 1.4 1995/02/17 20:10:40 rj - * inclusion order fixed. - * - * Revision 1.3 1994/10/08 03:48:04 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:19:44 rj - * snacc_config.h removed; more portable .h file inclusion. - * - * Revision 1.1 1994/08/28 09:48:11 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "snacc.h" - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif - -#include "kwd.h" - -/* - * last elmt will be NULL. - * key words grabbed from C++/Stroustrup 2.0 - */ -static char *cxxKWdG[] = -{ - "asm", "auto", "break", "case", "catch", "char", "class", "const", - "continue", "default", "delete", "do", "double", "else", "enum", - "extern", "float", "for", "friend", "goto", "if", "inline", "int", - "long", "new", "operator", "private", "protected", "public", - "register", "return", "short", "signed", "sizeof", "static", - "struct", "switch", "template", "this", "throw", "try", "typedef", - "union", "unsigned", "virtual", "void", "volatile", "while", -#if BOOL_BUILTIN - "bool", "true", "false", -#endif - NULL -}; - - -/* - * returns non-zero if the given str is a C++ key word - */ -int -IsCxxKeyWord PARAMS ((str), - char *str) -{ - int i; - - for (i=0; (cxxKWdG[i] != NULL) && (strcmp (cxxKWdG[i],str) != 0); i++) - ; - - return cxxKWdG[i] != NULL; -} diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/kwd.h b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/kwd.h deleted file mode 100644 index c3bb7975..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/kwd.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/kwd.h - routines for determining whether a given str is a C++ keyword - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/kwd.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: kwd.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:40 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:22:41 rj - * file name has been shortened for redundant part: c++-gen/c++-kwd -> c++-gen/kwd. - * - * Revision 1.2 1994/10/08 03:48:05 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:12 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -int IsCxxKeyWord PROTO ((char *str)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/rules.c b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/rules.c deleted file mode 100644 index ef165a8a..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/rules.c +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/rules.c - initialized c rule structure - * inits a table that contains info about - * converting each ASN.1 type to a C++ class - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/rules.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: rules.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:40 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:24:13 rj - * file name has been shortened for redundant part: c++-gen/c++-rules -> c++-gen/rules. - * - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:47:49 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 01:53:33 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:47:54 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" -#include "asn1module.h" -#include "rules.h" - - -CxxRules cxxRulesG = -{ - 4, - "choiceId", - "ChoiceIdEnum", - "a", - "ChoiceUnion", - FALSE, - "Enc", - "Dec", - "EncContent", - "DecContent", - "EncPdu", - "DecPdu", - { - { - BASICTYPE_UNKNOWN, - "???", - FALSE, - FALSE, - FALSE, - TRUE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "unknown" - }, - { - BASICTYPE_BOOLEAN, - "AsnBool", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "bool" - }, - { - BASICTYPE_INTEGER, - "AsnInt", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "integer" - }, - { - BASICTYPE_BITSTRING, - "AsnBits", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "bits" - }, - { - BASICTYPE_OCTETSTRING, - "AsnOcts", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "octs" - }, - { - BASICTYPE_NULL, - "AsnNull", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "null" - }, - { - BASICTYPE_OID, - "AsnOid", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "oid" - }, - { - BASICTYPE_REAL, - "AsnReal", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "real" - }, - { - BASICTYPE_ENUMERATED, - "AsnEnum", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "enumeration" - }, - { - BASICTYPE_SEQUENCE, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "seq" - }, - { - BASICTYPE_SEQUENCEOF, - "AsnList", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "seqOf" - }, - { - BASICTYPE_SET, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - FALSE, - "NOT_NULL", - "set" - }, - { - BASICTYPE_SETOF, - "AsnList", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "setOf" - }, - { - BASICTYPE_CHOICE, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - FALSE, - "NOT_NULL", - "choice" - }, - { - BASICTYPE_SELECTION, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "foo" - }, - { - BASICTYPE_COMPONENTSOF, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "bar" - }, - { - BASICTYPE_ANY, - "AsnAny", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "any" - }, - { - BASICTYPE_ANYDEFINEDBY, - "AsnAnyDefinedBy", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "anyDefBy" - }, - { - BASICTYPE_LOCALTYPEREF, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "foo" - }, - { - BASICTYPE_IMPORTTYPEREF, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "bar" - }, - { - BASICTYPE_MACROTYPE, - NULL, - FALSE, - FALSE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "foo" - }, - { - BASICTYPE_MACRODEF, - NULL, - FALSE, - FALSE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "foo" - } - } -}; diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/rules.h b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/rules.h deleted file mode 100644 index 19801f7a..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/rules.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/rules.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/rules.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: rules.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:40 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:24:21 rj - * file name has been shortened for redundant part: c++-gen/c++-rules -> c++-gen/rules. - * - * Revision 1.2 1994/10/08 03:47:50 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:47:55 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -/* see asn1module.h for CxxTDI (C++ type def info) */ - -typedef struct CxxRules -{ - int maxDigitsToAppend; - char *choiceIdFieldName; /* name of choiceId field */ - char *choiceIdEnumName; /* name (tag) for choiceId enum def name */ - char *choiceUnionFieldName; /* what the name of the choice's union is */ - char *choiceUnionName; /* name (tag) for choice union def name */ - int capitalizeNamedElmts; - char *encodeBaseName; - char *decodeBaseName; - char *encodeContentBaseName; - char *decodeContentBaseName; - char *encodePduBaseName; - char *decodePduBaseName; - CxxTDI typeConvTbl[BASICTYPE_MACRODEF + 1]; -} CxxRules; - -extern CxxRules cxxRulesG; diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/types.c b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/types.c deleted file mode 100644 index 596e6ead..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/types.c +++ /dev/null @@ -1,677 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c++-gen/types.c - fills in c++ type information - * - * MS 91/92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * INSERT_VDA_COMMENTS - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/types.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: types.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:40 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:25:11 rj - * file name has been shortened for redundant part: c++-gen/c++-types -> c++-gen/types. - * - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:47:51 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 01:06:02 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:47:56 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include -#include - -#include "asn-incl.h" -#include "define.h" -#include "asn1module.h" -#include "mem.h" -#include "snacc-util.h" -#include "str-util.h" -#include "rules.h" -#include "kwd.h" -#include "types.h" - -extern Module *usefulTypeModG; -static DefinedObj *definedNamesG; - -/* unexported prototypes */ - -void FillCxxTypeDefInfo PROTO ((CxxRules *r, Module *m, TypeDef *td)); - -static void FillCxxFieldNames PROTO ((CxxRules *r, NamedTypeList *firstSibling)); - -static void FillCxxTypeRefInfo PROTO ((CxxRules *r, Module *m, TypeDef *head, Type *parent, Type *t)); - -static void FillCxxStructElmts PROTO ((CxxRules *r, Module *m, TypeDef *head, Type *parent, NamedTypeList *t)); - -static void FillCxxChoiceElmts PROTO ((CxxRules *r, Module *m, TypeDef *head, Type *parent, NamedTypeList *first)); - -static int IsCxxPtr PROTO ((CxxRules *r, TypeDef *td, Type *parent, Type *t)); - -void FillCxxTDIDefaults PROTO ((CxxRules *r, CxxTDI *ctdi, TypeDef *td)); - - -/* - * allocates and fills all the cxxTypeInfos - * in the type trees for every module in the list - */ -void -FillCxxTypeInfo PARAMS ((r, modList), - CxxRules *r _AND_ - ModuleList *modList) -{ - TypeDef *td; - Module *m; - - /* - * go through each module's type defs and fill - * in the C type and enc/dec routines etc - */ - definedNamesG = NULL; - - /* do useful types first */ - if (usefulTypeModG != NULL) - { - FOR_EACH_LIST_ELMT (td, usefulTypeModG->typeDefs) - FillCxxTypeDefInfo (r, usefulTypeModG, td); - } - - FOR_EACH_LIST_ELMT (m, modList) - { - FOR_EACH_LIST_ELMT (td, m->typeDefs) - FillCxxTypeDefInfo (r, m, td); - } - - /* - * now that type def info is filled in - * set up set/seq/list/choice elements that ref - * those definitions - */ - - /* do useful types first */ - if (usefulTypeModG != NULL) - { - FOR_EACH_LIST_ELMT (td, usefulTypeModG->typeDefs) - FillCxxTypeRefInfo (r, usefulTypeModG, td, NULL, td->type); - } - - FOR_EACH_LIST_ELMT (m, modList) - { - FOR_EACH_LIST_ELMT (td, m->typeDefs) - FillCxxTypeRefInfo (r, m, td, NULL, td->type); - } - - /* - * modules compiled together (ie one call to snacc with - * multiple args) likely to be C compiled together so - * need a unique routines/types/defines/enum values - * since assuming they share same name space. - * All Typedefs, union, struct & enum Tags, and defined values - * (enum consts), #define names - * are assumed to share the same name space - */ - - /* done with checking for name conflicts */ - FreeDefinedObjs (&definedNamesG); - -} /* FillCxxTypeInfo */ - - -/* - * allocates and fills structure holding C type definition information - * fo the given ASN.1 type definition. Does not fill CTRI for contained - * types etc. - */ -void -FillCxxTypeDefInfo PARAMS ((r, m, td), - CxxRules *r _AND_ - Module *m _AND_ - TypeDef *td) -{ - int digit; - int len; - char *tmpName; - CxxTDI *cxxtdi; - - /* - * if CxxTDI is present this type def has already been 'filled' - */ - if (td->cxxTypeDefInfo != NULL) - return; - - - cxxtdi = MT (CxxTDI); - td->cxxTypeDefInfo = cxxtdi; - - /* get default type def attributes from table for type on rhs of ::= */ - - FillCxxTDIDefaults (r, cxxtdi, td); - - - /* - * if defined by a ref to another type definition fill in that type - * def's CxxTDI so can inherit (actully completly replace default - * attributes) from it - */ - if ((td->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (td->type->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - /* - * Fill in CxxTDI for defining type if nec. - * this works for importTypeRef as well since both a.localTypeRef - * and a.importTypeRef are of type TypeRef - */ - FillCxxTypeDefInfo (r, td->type->basicType->a.localTypeRef->module, td->type->basicType->a.localTypeRef->link); - - tmpName = cxxtdi->className; /* save className */ - /* copy all type def info and restore name related stuff - hack*/ - *cxxtdi = *td->type->basicType->a.localTypeRef->link->cxxTypeDefInfo; - cxxtdi->className = tmpName; /* restore className */ - } - - - /* - * check for any "--snacc" attributes that overide the current - * cxxtdi fields - * UNDEFINED FOR C++ - ParseTypeDefAttribs (cxxtdi, td->attrList); - */ - -} /* FillCxxTypeDefInfo */ - - -static void -FillCxxTypeRefInfo PARAMS ((r, m, head, parent, t), - CxxRules *r _AND_ - Module *m _AND_ - TypeDef *head _AND_ - Type *parent _AND_ - Type *t) -{ - CxxTRI *cxxtri; - CxxTDI *tmpCxxtdi; - ValueDef *namedElmt; - CNamedElmt *cne; - CNamedElmt **cneHndl; - char *elmtName; - char *listName; - char *choiceName; - char *unionName; - Type *tmpT; - int len, digit; - enum BasicTypeChoiceId basicTypeId; - - /* - * you must check for cycles yourself before calling this - */ - if (t->cxxTypeRefInfo == NULL) - { - cxxtri = MT (CxxTRI); - t->cxxTypeRefInfo = cxxtri; - } - else - cxxtri = t->cxxTypeRefInfo; - - basicTypeId = t->basicType->choiceId; - - tmpCxxtdi = &r->typeConvTbl[basicTypeId]; - - /* get base type def info from the conversion table in the rules */ - cxxtri->isEnc = tmpCxxtdi->isEnc; - cxxtri->className = tmpCxxtdi->className; - cxxtri->optTestRoutineName = tmpCxxtdi->optTestRoutineName; - - - /* - * convert named elmts to C++ names. - * check for name conflict with other defined Types/Names/Values - */ - if (((basicTypeId == BASICTYPE_INTEGER) || - (basicTypeId == BASICTYPE_ENUMERATED) || - (basicTypeId == BASICTYPE_BITSTRING)) && - !(LIST_EMPTY (t->basicType->a.integer))) - { - cxxtri->namedElmts = AsnListNew (sizeof (void*)); - FOR_EACH_LIST_ELMT (namedElmt, t->basicType->a.integer) - { - cneHndl = (CNamedElmt**)AsnListAppend (cxxtri->namedElmts); - cne = *cneHndl = MT (CNamedElmt); - elmtName = Asn1ValueName2CValueName (namedElmt->definedName); - len = strlen (elmtName); - cne->name = Malloc (len + 1 + r->maxDigitsToAppend); - strcpy (cne->name, elmtName); - Free (elmtName); /* not very efficient */ - - if (namedElmt->value->basicValue->choiceId == BASICVALUE_INTEGER) - cne->value = namedElmt->value->basicValue->a.integer; - else - { - fprintf (stderr,"Warning: unlinked defined value. Using -9999999\n"); - cne->value = -9999999; - } - - if (r->capitalizeNamedElmts) - Str2UCase (cne->name, len); - - /* - * append digits if enum value name is a keyword - */ - MakeCxxStrUnique (definedNamesG, cne->name, r->maxDigitsToAppend, 1); - /* not nec since each class hides the enum scope - DefineObj (&definedNamesG, cne->name); */ - } - } - - /* fill in rest of type info depending on the type */ - switch (basicTypeId) - { - case BASICTYPE_BOOLEAN: /* library types */ - case BASICTYPE_INTEGER: - case BASICTYPE_BITSTRING: - case BASICTYPE_OCTETSTRING: - case BASICTYPE_NULL: - case BASICTYPE_OID: - case BASICTYPE_REAL: - case BASICTYPE_ENUMERATED: - /* don't need to do anything else */ - break; - - - case BASICTYPE_SEQUENCEOF: /* list types */ - case BASICTYPE_SETOF: - /* fill in component type */ - FillCxxTypeRefInfo (r, m, head, t, t->basicType->a.setOf); - break; - - case BASICTYPE_IMPORTTYPEREF: /* type references */ - case BASICTYPE_LOCALTYPEREF: - /* - * grab class name from link (link is the def of the - * the ref'd type) - */ - if (t->basicType->a.localTypeRef->link != NULL) - { - /* inherit attributes from referenced type */ - tmpCxxtdi= t->basicType->a.localTypeRef->link->cxxTypeDefInfo; - cxxtri->className = tmpCxxtdi->className; - cxxtri->isEnc = tmpCxxtdi->isEnc; - cxxtri->optTestRoutineName = tmpCxxtdi->optTestRoutineName; - } - - break; - - case BASICTYPE_ANYDEFINEDBY: /* ANY types */ - break; /* these are handled now */ - - case BASICTYPE_ANY: - PrintErrLoc (m->asn1SrcFileName, t->lineNo); -#ifndef VDADER_RULES - fprintf (stderr,"Warning - generated code for the \"ANY\" type in type \"%s\" will need modification by YOU.", head->definedName); - fprintf (stderr," The source files will have a \"/* ANY - Fix Me! */\" comment before related code.\n\n"); -#else -if (gVDADER_RULES) -{ - fprintf (stderr,"Warning - VDA Enchanced ANY processing being used.\n"); -} -#endif - break; - - case BASICTYPE_CHOICE: - /* - * must fill field names BEFORE filling choice elmts - * (allows better naming for choice ids) - */ - FillCxxFieldNames (r, t->basicType->a.choice); - FillCxxChoiceElmts (r, m, head, t, t->basicType->a.choice); - break; - - case BASICTYPE_SET: - case BASICTYPE_SEQUENCE: - FillCxxStructElmts (r, m, head, t, t->basicType->a.set); - FillCxxFieldNames (r, t->basicType->a.set); - break; - - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_SELECTION: - fprintf (stderr,"Compiler error - COMPONENTS OF or SELECTION type slipped through normalizing phase.\n"); - break; - - case BASICTYPE_UNKNOWN: - case BASICTYPE_MACRODEF: - case BASICTYPE_MACROTYPE: - /* do nothing */ - break; - - } - - /* - * figure out whether this is a ptr based on the enclosing - * type (if any) and optionality/default - */ - cxxtri->isPtr = IsCxxPtr (r, head, parent, t); - - /* let user overide any defaults with the --snacc attributes */ - /* undefined for C++ ParseTypeRefAttribs (ctri, t->attrList); */ - - -} /* FillCxxTypeRefInfo */ - - - -static void -FillCxxStructElmts PARAMS ((r, m, head, parent, elmts), - CxxRules *r _AND_ - Module *m _AND_ - TypeDef *head _AND_ - Type *parent _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - - FOR_EACH_LIST_ELMT (et, elmts) - { - FillCxxTypeRefInfo (r, m, head, parent, et->type); - } - -} /* FillCxxStructElmts */ - - - -/* - * Figures out non-conflicting enum names for the - * choice id's - */ -static void -FillCxxChoiceElmts PARAMS ((r, m, head, parent, elmts), - CxxRules *r _AND_ - Module *m _AND_ - TypeDef *head _AND_ - Type *parent _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - int idCount = 0; - CxxTRI *cxxtri; - int len; - - /* - * fill in type info for elmt types first - */ - FOR_EACH_LIST_ELMT (et, elmts) - FillCxxTypeRefInfo (r, m, head, parent, et->type); - - /* - * set choiceId Symbol & value - * eg - * Car ::= CHOICE { class Car { - * chev ChevCar, -> enum ChoiceIdEnum { - * ford FordCar chevCid, - * toyota ToyotaCar fordCid, - * } toyotaCid } choiceId; - * union CarChoiceUnion { - * ChevCar *chev; - * FordCar *ford; - * ToyotaCar *toyota; }; - * ... - * } - * NOTE that the union is anonymous - */ - FOR_EACH_LIST_ELMT (et, elmts) - { - cxxtri = et->type->cxxTypeRefInfo; - - if (cxxtri == NULL) - continue; /* wierd type */ - - cxxtri->choiceIdValue = idCount++; - - len = strlen (cxxtri->fieldName); - cxxtri->choiceIdSymbol = Malloc (len + 4); - strcpy (cxxtri->choiceIdSymbol, cxxtri->fieldName); - strcat (cxxtri->choiceIdSymbol, "Cid"); - - if (r->capitalizeNamedElmts) - Str2UCase (cxxtri->choiceIdSymbol, len); - - } - -} /* FillCxxChoiceElmts */ - - -/* - * takes a list of "sibling" (eg same level in a structure) - * ElmtTypes and fills sets up the c field names in - * the CxxTRI struct - */ -static void -FillCxxFieldNames PARAMS ((r, elmts), - CxxRules *r _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - CxxTRI *cxxtri; - DefinedObj *fieldNames; - int len, num, digit, i, tmpLen; - char *tmpName; - char *asn1FieldName; - char *cFieldName; - - /* - * Initialize fieldname data - * allocate (if nec) and fill in CTRI fieldname if poss - * from asn1 field name. leave blank otherwise - */ - fieldNames = NewObjList(); - FOR_EACH_LIST_ELMT (et, elmts) - { - cxxtri = et->type->cxxTypeRefInfo; - if (cxxtri == NULL) - { - cxxtri = MT (CxxTRI); - et->type->cxxTypeRefInfo = cxxtri; - } - if (et->fieldName != NULL) - { - /* - * can assume that the field names are - * distinct because they have passed the - * error checking step. - * However, still call MakeCxxStrUnique - * to change any field names that - * conflict with C++ keywords - */ - asn1FieldName = et->fieldName; - tmpName = Asn1FieldName2CFieldName (asn1FieldName); - cxxtri->fieldName = Malloc (strlen (tmpName) + 1 + - r->maxDigitsToAppend); - strcpy (cxxtri->fieldName, tmpName); - Free (tmpName); - -/* old cxxtri->fieldName = Asn1FieldName2CFieldName (asn1FieldName); */ - - MakeCxxStrUnique (fieldNames, cxxtri->fieldName, r->maxDigitsToAppend, 1); - DefineObj (&fieldNames, cxxtri->fieldName); - } - } - - - FOR_EACH_LIST_ELMT (et, elmts) - { - cxxtri = et->type->cxxTypeRefInfo; - - /* - * generate field names for those without them - */ - if (cxxtri->fieldName == NULL) - { - if ((et->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (et->type->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - /* - * take ref'd type name as field name - * convert first let to lower case - */ - tmpName = et->type->basicType->a.localTypeRef->link->cxxTypeDefInfo->className; - tmpName = Asn1TypeName2CTypeName (tmpName); - cFieldName = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); - strcpy (cFieldName, tmpName); - Free (tmpName); - if (isupper (cFieldName[0])) - cFieldName[0] = tolower (cFieldName[0]); - } - else - { - /* - * get default field name for this type - */ - tmpName = r->typeConvTbl[et->type->basicType->choiceId].defaultFieldName; - cFieldName = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); - strcpy (cFieldName, tmpName); - - if (isupper (cFieldName[0])) - cFieldName[0] = tolower (cFieldName[0]); - } - - - len = strlen (cFieldName); - - /* - * try to use just the type name (with lower case first char). - * if that is already used in this type or a C++ keyword, - * append ascii digits to field name until unique - * in this type - */ - MakeCxxStrUnique (fieldNames, cFieldName, r->maxDigitsToAppend, 1); - DefineObj (&fieldNames, cFieldName); - cxxtri->fieldName = cFieldName; - } - } - FreeDefinedObjs (&fieldNames); -} /* FillCxxFieldNames */ - - - -/* - * returns true if this c type for this type should be - * be ref'd as a ptr - */ -static int -IsCxxPtr PARAMS ((r, td, parent, t), - CxxRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - CxxTDI *cxxtdi; - int retVal = FALSE; - - /* - * inherit ptr attriubutes from ref'd type if any - * otherwise grab lib c type def from the CxxRules - */ - if ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - cxxtdi = t->basicType->a.localTypeRef->link->cxxTypeDefInfo; - } - else - cxxtdi = &r->typeConvTbl[GetBuiltinType (t)]; - - /* no parent means t is the root of a typedef */ - if ((parent == NULL) && (cxxtdi->isPtrForTypeDef)) - retVal = TRUE; - - else if ((parent != NULL) && - ((parent->basicType->choiceId == BASICTYPE_SET) || - (parent->basicType->choiceId == BASICTYPE_SEQUENCE)) && - (cxxtdi->isPtrInSetAndSeq)) - retVal = TRUE; - - else if ((parent != NULL) && - ((parent->basicType->choiceId == BASICTYPE_SETOF) || - (parent->basicType->choiceId == BASICTYPE_SEQUENCEOF)) && - (cxxtdi->isPtrInList)) - retVal = TRUE; - - else if ((parent != NULL) && - (parent->basicType->choiceId == BASICTYPE_CHOICE) && - (cxxtdi->isPtrInChoice)) - retVal = TRUE; - - else if (((t->optional) || (t->defaultVal != NULL)) && (cxxtdi->isPtrForOpt)) - retVal = TRUE; - - return retVal; -} /* IsCxxPtr */ - - - -/* fill given cxxtdi with defaults from table for given typedef */ -void -FillCxxTDIDefaults PARAMS ((r, cxxtdi, td), - CxxRules *r _AND_ - CxxTDI *cxxtdi _AND_ - TypeDef *td) -{ - CxxTDI *tblCxxtdi; - int typeIndex; - char *tmpName; - - typeIndex = GetBuiltinType (td->type); - - if (typeIndex < 0) - return; - - tblCxxtdi = &r->typeConvTbl[typeIndex]; - - memcpy (cxxtdi, tblCxxtdi, sizeof (CxxTDI)); - - /* make sure class name is unique wrt to previously defined classes */ - tmpName = Asn1TypeName2CTypeName (td->definedName); - cxxtdi->className = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); - strcpy (cxxtdi->className, tmpName); - Free (tmpName); - - MakeCxxStrUnique (definedNamesG, cxxtdi->className, r->maxDigitsToAppend, 1); - DefineObj (&definedNamesG, cxxtdi->className); - -} /* FillCxxTDIDefaults */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/types.h b/SecuritySNACCRuntime/compiler/back-ends/c++-gen/types.h deleted file mode 100644 index d12d4a43..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c++-gen/types.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c++_gen/types.h - fills in c++ type information - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c++-gen/Attic/types.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: types.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:41 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:25:19 rj - * file name has been shortened for redundant part: c++-gen/c++-types -> c++-gen/types. - * - * Revision 1.2 1994/10/08 03:47:52 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:47:57 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -void FillCxxTypeInfo PROTO ((CxxRules *r, ModuleList *m)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any.c deleted file mode 100644 index aee7847b..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-any.c - * - * prints Routine to initialize the ANY Hash table. The - * ANY Hash table maps the OBJECT IDENTIFIERS or INTEGERS - * to the correct encoding/decoding etc routines. - * - * Also prints an enum to identify each ANY mapping. - * - * if the given module has no ANY or ANY DEFINED BY types - * nothing is printed. - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-any.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-any.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1 2000/05/10 21:35:01 rmurphy - * Adding back in base code files which had been moved to "2" versions. - * - * Revision 1.1.1.1 1999/03/16 18:06:41 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:33:43 rj - * file name has been shortened for redundant part: c-gen/gen-c-any -> c-gen/gen-any. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:21:15 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:15 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "rules.h" -#include "define.h" -#include "str-util.h" -#include "gen-vals.h" -#include "lib-types.h" -#include "gen-any.h" - -int anyEnumValG = 0; - - -void PrintCAnyEnum PROTO ((FILE *hdr, Module *m, CRules *r)); - -void PrintCAnyHashInitRoutine PROTO ((FILE *src, FILE *hdr, ModuleList *mods, Module *m, CRules *r)); - - - - -void -PrintCAnyCode PARAMS ((src, hdr, r, mods, m), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m) -{ - - if (!m->hasAnys) - return; - - PrintCAnyEnum (hdr, m, r); - PrintCAnyHashInitRoutine (src, hdr, mods, m, r); - -} /* PrintAnyCode */ - - - -void -PrintCAnyEnum PARAMS ((hdr, m, r), - FILE *hdr _AND_ - Module *m _AND_ - CRules *r) -{ - TypeDef *td; - AnyRef *ar; - AnyRefList *arl; - int i; - int firstPrinted = TRUE; - char *modName; - - modName = Asn1TypeName2CTypeName (m->modId->name); - - fprintf (hdr,"typedef enum %sAnyId\n", modName); - fprintf (hdr,"{\n"); - - /* do any lib types */ - for (i = BASICTYPE_BOOLEAN; i < BASICTYPE_MACRODEF; i++) - { - arl = LIBTYPE_GET_ANY_REFS (i); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - if (!firstPrinted) - fprintf (hdr,",\n"); - fprintf (hdr," %s = %d", ar->anyIdName, anyEnumValG++); - firstPrinted = FALSE; - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - if (!firstPrinted) - fprintf (hdr,",\n"); - fprintf (hdr," %s = %d", ar->anyIdName, anyEnumValG++); - firstPrinted = FALSE; - } - } - } - if (firstPrinted) /* none have been printed */ - fprintf (hdr,"/* NO INTEGER or OBJECT IDENTIFIER to ANY type relationships were defined (via MACROs or other mechanism) */\n???\n"); - - fprintf (hdr,"} %sAnyId;\n\n\n", modName); - Free (modName); - -} /* PrintAnyEnum */ - - -void -PrintCAnyHashInitRoutine PARAMS ((src, hdr, mods, m, r), - FILE *src _AND_ - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CRules *r) -{ - TypeDef *td; - AnyRef *ar; - AnyRefList *arl; - char *modName; - CTDI *ctdi; - int i,j; - enum BasicTypeChoiceId typeId; - char *encRoutineName; - char *decRoutineName; - char *freeRoutineName; - char *printRoutineName; - int installedSomeHashes = FALSE; - - /* print proto in hdr file */ - modName = Asn1TypeName2CTypeName (m->modId->name); - fprintf (hdr,"void InitAny%s();\n\n", modName); - - /* print routine to src file */ - fprintf (src,"void\nInitAny%s()\n", modName); - fprintf (src,"{\n"); - - /* first print value for OID's */ - /* do any lib types first */ - i = 0; - for (j = BASICTYPE_BOOLEAN; j < BASICTYPE_MACRODEF; j++) - { - arl = LIBTYPE_GET_ANY_REFS (j); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - installedSomeHashes = TRUE; - if (ar->id->choiceId == OIDORINT_OID) - { - fprintf (src," %s oid%d =", r->typeConvTbl[BASICTYPE_OID].cTypeName, i++); - PrintCOidValue (src, r, ar->id->a.oid); - fprintf (src,";\n"); - } - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - ctdi = td->cTypeDefInfo; - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - installedSomeHashes = TRUE; - if (ar->id->choiceId == OIDORINT_OID) - { - fprintf (src," %s oid%d =", r->typeConvTbl[BASICTYPE_OID].cTypeName, i++); - PrintCOidValue (src, r, ar->id->a.oid); - fprintf (src,";\n"); - } - } - } - } - - fprintf (src,"\n\n"); - - /* now print hash init calls */ - i = 0; - - /* do lib types first */ - for (j = BASICTYPE_BOOLEAN; j < BASICTYPE_MACRODEF; j++) - { - arl = LIBTYPE_GET_ANY_REFS (j); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - - encRoutineName = r->typeConvTbl[j].encodeRoutineName; - decRoutineName = r->typeConvTbl[j].decodeRoutineName; - printRoutineName = r->typeConvTbl[j].printRoutineName; - - /* - * use NULL free routine for types that - * have empyt macros for their free routines - * (since the any hash tbl needs the addr of the routine) - */ - switch (j) - { - case BASICTYPE_BOOLEAN: - case BASICTYPE_INTEGER: - case BASICTYPE_NULL: - case BASICTYPE_REAL: - case BASICTYPE_ENUMERATED: - freeRoutineName = "NULL"; - break; - default: - freeRoutineName = r->typeConvTbl[j].freeRoutineName; - } - - if (ar->id->choiceId == OIDORINT_OID) - fprintf (src," InstallAnyByOid (%s, &oid%d, sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n", ar->anyIdName, i++, r->typeConvTbl[j].cTypeName, encRoutineName, decRoutineName, freeRoutineName, printRoutineName); - else - fprintf (src," InstallAnyByInt (%s, %d, sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n", ar->anyIdName, ar->id->a.intId, r->typeConvTbl[j].cTypeName, encRoutineName, decRoutineName, freeRoutineName, printRoutineName); - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - ctdi = td->cTypeDefInfo; - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - typeId = GetBuiltinType (td->type); - - encRoutineName = ctdi->encodeRoutineName; - decRoutineName = ctdi->decodeRoutineName; - printRoutineName = ctdi->printRoutineName; - - /* - * use NULL free routine for types that - * have empyt macros for their free routines - * (since the any hash tbl needs the addr of the routine) - */ - switch (typeId) - { - case BASICTYPE_BOOLEAN: - case BASICTYPE_INTEGER: - case BASICTYPE_NULL: - case BASICTYPE_REAL: - case BASICTYPE_ENUMERATED: - freeRoutineName = "NULL"; - break; - default: - freeRoutineName = ctdi->freeRoutineName; - } - - if (ar->id->choiceId == OIDORINT_OID) - fprintf (src," InstallAnyByOid (%s, &oid%d, sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n", ar->anyIdName, i++, ctdi->cTypeName, encRoutineName, decRoutineName, freeRoutineName, printRoutineName); - else - fprintf (src," InstallAnyByInt (%s, %d, sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n", ar->anyIdName, ar->id->a.intId, ctdi->cTypeName, encRoutineName, decRoutineName, freeRoutineName, printRoutineName); - } - } - } - - - if (!installedSomeHashes) - { - fprintf (src," /* Since no INTEGER/OID to ANY type relations were defined\n"); - fprintf (src," * (usually done via MACROs) you must manually do the code\n"); - fprintf (src," * to fill the hash tbl.\n"); - fprintf (src," * if the ids are INTEGER use the following:\n"); - fprintf (src," * InstallAnyByInt (??_ANY_ID, intVal, sizeof (Foo), (EncodeFcn) BEncFoo, (DecodeFcn)BDecFoo, (FreeFcn)FreeFoo, (PrintFcn)PrintFoo);\n"); - fprintf (src," * if the ids are OBJECT IDENTIFIERs use the following:\n"); - fprintf (src," * InstallAnyByOid (??_ANY_ID, oidVal, sizeof (Foo), (EncodeFcn) BEncFoo, (DecodeFcn)BDecFoo, (FreeFcn)FreeFoo, (PrintFcn)PrintFoo);\n"); - fprintf (src," * put the ??_ANY_IDs in the AnyId enum.\n\n"); - fprintf (src," * For example if you have some thing like\n"); - fprintf (src," * T1 ::= SEQUENCE { id INTEGER, ANY DEFINED BY id }\n"); - fprintf (src," * and the id 1 maps to the type BOOLEAN use the following:\n"); - fprintf (src," * InstallAnyByInt (SOMEBOOL_ANY_ID, 1, sizeof (AsnBool), (EncodeFcn) BEncAsnBool, (DecodeFcn)BDecAsnBool, (FreeFcn)NULL, (PrintFcn)PrintAsnBool);;\n"); - fprintf (src," */\n ???????\n"); /* generate compile error */ - } - - - fprintf (src,"} /* InitAny%s */\n\n\n", modName); - - Free (modName); - -} /* PrintAnyHashInitRoutine */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any.h deleted file mode 100644 index de815711..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-any.h - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-any.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-any.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:41 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:33:59 rj - * file name has been shortened for redundant part: c-gen/gen-c-any -> c-gen/gen-any. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:08 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:16 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -extern int anyEnumValG; - - -void PrintCAnyCode PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any2.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any2.c deleted file mode 100644 index 5d060813..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-any2.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-any.c - * - * prints Routine to initialize the ANY Hash table. The - * ANY Hash table maps the OBJECT IDENTIFIERS or INTEGERS - * to the correct encoding/decoding etc routines. - * - * Also prints an enum to identify each ANY mapping. - * - * if the given module has no ANY or ANY DEFINED BY types - * nothing is printed. - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-any2.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-any2.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:41 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:33:43 rj - * file name has been shortened for redundant part: c-gen/gen-c-any -> c-gen/gen-any. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:21:15 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:15 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "rules.h" -#include "define.h" -#include "str-util.h" -#include "gen-vals.h" -#include "lib-types.h" -#include "gen-any.h" - -int anyEnumValG = 0; - - -void PrintCAnyEnum PROTO ((FILE *hdr, Module *m, CRules *r)); - -void PrintCAnyHashInitRoutine PROTO ((FILE *src, FILE *hdr, ModuleList *mods, Module *m, CRules *r)); - - - - -void -PrintCAnyCode PARAMS ((src, hdr, r, mods, m), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m) -{ - - if (!m->hasAnys) - return; - - PrintCAnyEnum (hdr, m, r); - PrintCAnyHashInitRoutine (src, hdr, mods, m, r); - -} /* PrintAnyCode */ - - - -void -PrintCAnyEnum PARAMS ((hdr, m, r), - FILE *hdr _AND_ - Module *m _AND_ - CRules *r) -{ - TypeDef *td; - AnyRef *ar; - AnyRefList *arl; - int i; - int firstPrinted = TRUE; - char *modName; - - modName = Asn1TypeName2CTypeName (m->modId->name); - - fprintf (hdr,"typedef enum %sAnyId\n", modName); - fprintf (hdr,"{\n"); - - /* do any lib types */ - for (i = BASICTYPE_BOOLEAN; i < BASICTYPE_MACRODEF; i++) - { - arl = LIBTYPE_GET_ANY_REFS (i); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - if (!firstPrinted) - fprintf (hdr,",\n"); - fprintf (hdr," %s = %d", ar->anyIdName, anyEnumValG++); - firstPrinted = FALSE; - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - if (!firstPrinted) - fprintf (hdr,",\n"); - fprintf (hdr," %s = %d", ar->anyIdName, anyEnumValG++); - firstPrinted = FALSE; - } - } - } - if (firstPrinted) /* none have been printed */ - fprintf (hdr,"/* NO INTEGER or OBJECT IDENTIFIER to ANY type relationships were defined (via MACROs or other mechanism) */\n???\n"); - - fprintf (hdr,"} %sAnyId;\n\n\n", modName); - Free (modName); - -} /* PrintAnyEnum */ - - -void -PrintCAnyHashInitRoutine PARAMS ((src, hdr, mods, m, r), - FILE *src _AND_ - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CRules *r) -{ - TypeDef *td; - AnyRef *ar; - AnyRefList *arl; - char *modName; - CTDI *ctdi; - int i,j; - enum BasicTypeChoiceId typeId; - char *encRoutineName; - char *decRoutineName; - char *freeRoutineName; - char *printRoutineName; - int installedSomeHashes = FALSE; - - /* print proto in hdr file */ - modName = Asn1TypeName2CTypeName (m->modId->name); - fprintf (hdr,"void InitAny%s();\n\n", modName); - - /* print routine to src file */ - fprintf (src,"void\nInitAny%s()\n", modName); - fprintf (src,"{\n"); - - /* first print value for OID's */ - /* do any lib types first */ - i = 0; - for (j = BASICTYPE_BOOLEAN; j < BASICTYPE_MACRODEF; j++) - { - arl = LIBTYPE_GET_ANY_REFS (j); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - installedSomeHashes = TRUE; - if (ar->id->choiceId == OIDORINT_OID) - { - fprintf (src," %s oid%d =", r->typeConvTbl[BASICTYPE_OID].cTypeName, i++); - PrintCOidValue (src, r, ar->id->a.oid); - fprintf (src,";\n"); - } - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - ctdi = td->cTypeDefInfo; - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - installedSomeHashes = TRUE; - if (ar->id->choiceId == OIDORINT_OID) - { - fprintf (src," %s oid%d =", r->typeConvTbl[BASICTYPE_OID].cTypeName, i++); - PrintCOidValue (src, r, ar->id->a.oid); - fprintf (src,";\n"); - } - } - } - } - - fprintf (src,"\n\n"); - - /* now print hash init calls */ - i = 0; - - /* do lib types first */ - for (j = BASICTYPE_BOOLEAN; j < BASICTYPE_MACRODEF; j++) - { - arl = LIBTYPE_GET_ANY_REFS (j); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - - encRoutineName = r->typeConvTbl[j].encodeRoutineName; - decRoutineName = r->typeConvTbl[j].decodeRoutineName; - printRoutineName = r->typeConvTbl[j].printRoutineName; - - /* - * use NULL free routine for types that - * have empyt macros for their free routines - * (since the any hash tbl needs the addr of the routine) - */ - switch (j) - { - case BASICTYPE_BOOLEAN: - case BASICTYPE_INTEGER: - case BASICTYPE_NULL: - case BASICTYPE_REAL: - case BASICTYPE_ENUMERATED: - freeRoutineName = "NULL"; - break; - default: - freeRoutineName = r->typeConvTbl[j].freeRoutineName; - } - - if (ar->id->choiceId == OIDORINT_OID) - fprintf (src," InstallAnyByOid (%s, &oid%d, sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n", ar->anyIdName, i++, r->typeConvTbl[j].cTypeName, encRoutineName, decRoutineName, freeRoutineName, printRoutineName); - else - fprintf (src," InstallAnyByInt (%s, %d, sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n", ar->anyIdName, ar->id->a.intId, r->typeConvTbl[j].cTypeName, encRoutineName, decRoutineName, freeRoutineName, printRoutineName); - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - ctdi = td->cTypeDefInfo; - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - typeId = GetBuiltinType (td->type); - - encRoutineName = ctdi->encodeRoutineName; - decRoutineName = ctdi->decodeRoutineName; - printRoutineName = ctdi->printRoutineName; - - /* - * use NULL free routine for types that - * have empyt macros for their free routines - * (since the any hash tbl needs the addr of the routine) - */ - switch (typeId) - { - case BASICTYPE_BOOLEAN: - case BASICTYPE_INTEGER: - case BASICTYPE_NULL: - case BASICTYPE_REAL: - case BASICTYPE_ENUMERATED: - freeRoutineName = "NULL"; - break; - default: - freeRoutineName = ctdi->freeRoutineName; - } - - if (ar->id->choiceId == OIDORINT_OID) - fprintf (src," InstallAnyByOid (%s, &oid%d, sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n", ar->anyIdName, i++, ctdi->cTypeName, encRoutineName, decRoutineName, freeRoutineName, printRoutineName); - else - fprintf (src," InstallAnyByInt (%s, %d, sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n", ar->anyIdName, ar->id->a.intId, ctdi->cTypeName, encRoutineName, decRoutineName, freeRoutineName, printRoutineName); - } - } - } - - - if (!installedSomeHashes) - { - fprintf (src," /* Since no INTEGER/OID to ANY type relations were defined\n"); - fprintf (src," * (usually done via MACROs) you must manually do the code\n"); - fprintf (src," * to fill the hash tbl.\n"); - fprintf (src," * if the ids are INTEGER use the following:\n"); - fprintf (src," * InstallAnyByInt (??_ANY_ID, intVal, sizeof (Foo), (EncodeFcn) BEncFoo, (DecodeFcn)BDecFoo, (FreeFcn)FreeFoo, (PrintFcn)PrintFoo);\n"); - fprintf (src," * if the ids are OBJECT IDENTIFIERs use the following:\n"); - fprintf (src," * InstallAnyByOid (??_ANY_ID, oidVal, sizeof (Foo), (EncodeFcn) BEncFoo, (DecodeFcn)BDecFoo, (FreeFcn)FreeFoo, (PrintFcn)PrintFoo);\n"); - fprintf (src," * put the ??_ANY_IDs in the AnyId enum.\n\n"); - fprintf (src," * For example if you have some thing like\n"); - fprintf (src," * T1 ::= SEQUENCE { id INTEGER, ANY DEFINED BY id }\n"); - fprintf (src," * and the id 1 maps to the type BOOLEAN use the following:\n"); - fprintf (src," * InstallAnyByInt (SOMEBOOL_ANY_ID, 1, sizeof (AsnBool), (EncodeFcn) BEncAsnBool, (DecodeFcn)BDecAsnBool, (FreeFcn)NULL, (PrintFcn)PrintAsnBool);;\n"); - fprintf (src," */\n ???????\n"); /* generate compile error */ - } - - - fprintf (src,"} /* InitAny%s */\n\n\n", modName); - - Free (modName); - -} /* PrintAnyHashInitRoutine */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code.c deleted file mode 100644 index e1978b35..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-code.c - generate C hdr and src files - * - * Assumes you have called FillCTypeInfo - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-code.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-code.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1 2000/05/10 21:35:01 rmurphy - * Adding back in base code files which had been moved to "2" versions. - * - * Revision 1.1.1.1 1999/03/16 18:06:41 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:39:46 rj - * file name has been shortened for redundant part: c-gen/gen-c-code -> c-gen/gen-code. - * - * PrintConditionalIncludeOpen() and PrintConditionalIncludeClose() moved to back-ends/cond.c - * - * changed `_' to `-' in file names. - * - * Revision 1.3 1995/02/18 12:50:53 rj - * typo fixed. - * - * Revision 1.2 1994/09/01 00:21:54 rj - * snacc_config.h and other superfluous .h files removed. - * - * Revision 1.1 1994/08/28 09:48:17 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "print.h" -#include "rules.h" -#include "type-info.h" -#include "util.h" -#include "cond.h" -#include "gen-type.h" -#include "gen-enc.h" -#include "gen-dec.h" -#include "gen-vals.h" -#include "gen-free.h" -#include "gen-print.h" -#include "gen-any.h" -#include "gen-code.h" - -/* unexported prototypes */ -static void PrintCSrcComment PROTO ((FILE *src, Module *m)); -static void PrintCSrcIncludes PROTO ((FILE *src, Module *m, ModuleList *mods)); -static void PrintCHdrComment PROTO ((FILE *hdr, Module *m)); - -/* - * Fills the hdr file with the C type and encode/decode prototypes - * Fills the src file with the encoded/decode routine definitions - */ -void -PrintCCode PARAMS ((src, hdr, mods, m, r, longJmpVal, printTypes, printValues, printEncoders, printDecoders, printPrinters, printFree), - FILE *src _AND_ - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CRules *r _AND_ - long int longJmpVal _AND_ - int printTypes _AND_ - int printValues _AND_ - int printEncoders _AND_ - int printDecoders _AND_ - int printPrinters _AND_ - int printFree) -{ - TypeDef *td; - ValueDef *vd; - - PrintCSrcComment (src, m); - PrintCSrcIncludes (src, m, mods); - - PrintCHdrComment (hdr, m); - PrintConditionalIncludeOpen (hdr, m->cHdrFileName); - - fprintf (hdr,"\n\n"); - fprintf (src,"\n\n"); - - - if (printValues) - { - /* put value defs at beginning of .c file */ - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - PrintCValueDef (src, r, vd); - } - } - - PrintCAnyCode (src, hdr, r, mods, m); - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (printTypes) - PrintCTypeDef (hdr, r, m, td); - - /* for PDU type or types ref'd with ANY/ANY DEF BY */ - if (printEncoders && - ((td->anyRefs != NULL) || td->cTypeDefInfo->isPdu)) - PrintCBerEncoder (src, hdr, r, m, td); - - /* for PDU type or types ref'd with ANY/ANY DEF BY */ - if (printDecoders && - ((td->anyRefs != NULL) || td->cTypeDefInfo->isPdu)) - PrintCBerDecoder (src, hdr, r, m, td, &longJmpVal); - - if (printEncoders) - PrintCBerContentEncoder (src, hdr, r, m, td); - - if (printDecoders) - PrintCBerContentDecoder (src, hdr, r, m, td, &longJmpVal); - - - if (printPrinters) - PrintCPrinter (src, hdr, r, mods, m, td); - - if (printFree) - PrintCFree (src, hdr, r, mods, m, td); - - /* only print new lines for normal types */ - switch (td->type->basicType->choiceId) - { - case BASICTYPE_SEQUENCEOF: /* list types */ - case BASICTYPE_SETOF: - case BASICTYPE_CHOICE: - case BASICTYPE_SET: - case BASICTYPE_SEQUENCE: - fprintf (src, "\n\n\n"); - /* fall through */ - - case BASICTYPE_IMPORTTYPEREF: /* type references */ - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_BOOLEAN: /* library type */ - case BASICTYPE_REAL: /* library type */ - case BASICTYPE_OCTETSTRING: /* library type */ - case BASICTYPE_NULL: /* library type */ - case BASICTYPE_OID: /* library type */ - case BASICTYPE_INTEGER: /* library type */ - case BASICTYPE_BITSTRING: /* library type */ - case BASICTYPE_ENUMERATED: /* library type */ - case BASICTYPE_ANYDEFINEDBY: /* ANY types */ - case BASICTYPE_ANY: - fprintf (hdr, "\n\n\n"); - break; - } - - } - - if (printValues) - { - /* put value externs at end of .h file */ - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - PrintCValueExtern (hdr, r, vd); - } - } - - PrintConditionalIncludeClose (hdr, m->cHdrFileName); - -} /* PrintCCode */ - - -static void -PrintCSrcComment PARAMS ((src, m), - FILE *src _AND_ - Module *m) -{ - long int t; - - t = time (0); - fprintf (src, "/*\n"); - fprintf (src, " * %s\n *\n", m->cSrcFileName); - fprintf (src, " * \"%s\" ASN.1 module encode/decode/print/free C src.\n *\n", m->modId->name); - fprintf (src, " * This file was generated by snacc on %s *\n", ctime (&t)); - fprintf (src, " * UBC snacc written by Mike Sample\n *\n"); - fprintf (src, " * NOTE: This is a machine generated file - editing not recommended\n"); - fprintf (src, " */\n\n\n"); - -} /* PrintSrcComment */ - - - -static void -PrintCSrcIncludes PARAMS ((src, m, mods), - FILE *src _AND_ - Module *m _AND_ - ModuleList *mods) -{ - void *tmp; - Module *impMod; - - /* - * include snacc runtime library related hdrs - */ - fprintf (src, "\n#include \"asn-incl.h\"\n"); - - /* - * print out include files in same order of the module - * list. every module in the list includes the others and it's - * own .h - */ - tmp = (void*)CURR_LIST_NODE (mods); - FOR_EACH_LIST_ELMT (impMod, mods) - { - fprintf (src, "#include \"%s\"\n", impMod->cHdrFileName); - } - SET_CURR_LIST_NODE (mods, tmp); - -} /* PrintCSrcIncludes */ - - -static void -PrintCHdrComment PARAMS ((f, m), - FILE *f _AND_ - Module *m) -{ - long int t; - - t = time (0); - fprintf (f, "/*\n"); - fprintf (f, " * %s\n *\n", m->cHdrFileName); - fprintf (f, " * \"%s\" ASN.1 module C type definitions and prototypes\n *\n", m->modId->name); - fprintf (f, " * This .h file was generated by snacc on %s *\n", ctime (&t)); - fprintf (f, " * UBC snacc written compiler by Mike Sample\n *\n"); - fprintf (f, " * NOTE: This is a machine generated file--editing not recommended\n"); - fprintf (f, " */\n\n\n"); -} /* PrintCHdrComment */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code.h deleted file mode 100644 index ed99d8fd..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-code.h - generates C hdr and source files - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-code.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-code.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:41 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:38:30 rj - * file name has been shortened for redundant part: c-gen/gen-c-code -> c-gen/gen-code. - * - * PrintConditionalIncludeOpen() and PrintConditionalIncludeClose() moved to back-ends/cond.h - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:09 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:19 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -void PrintCCode PROTO ((FILE *src, FILE *hdr, ModuleList *mods, Module *m, CRules *r, long int longJmpVal, int printTypes, int printValues, int printEncoders, int printDecoders, int printPrinters, int printFree)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code2.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code2.c deleted file mode 100644 index 9a7a9d9b..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-code2.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-code.c - generate C hdr and src files - * - * Assumes you have called FillCTypeInfo - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-code2.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-code2.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:41 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:39:46 rj - * file name has been shortened for redundant part: c-gen/gen-c-code -> c-gen/gen-code. - * - * PrintConditionalIncludeOpen() and PrintConditionalIncludeClose() moved to back-ends/cond.c - * - * changed `_' to `-' in file names. - * - * Revision 1.3 1995/02/18 12:50:53 rj - * typo fixed. - * - * Revision 1.2 1994/09/01 00:21:54 rj - * snacc_config.h and other superfluous .h files removed. - * - * Revision 1.1 1994/08/28 09:48:17 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "print.h" -#include "rules.h" -#include "type-info.h" -#include "util.h" -#include "cond.h" -#include "gen-type.h" -#include "gen-enc.h" -#include "gen-dec.h" -#include "gen-vals.h" -#include "gen-free.h" -#include "gen-print.h" -#include "gen-any.h" -#include "gen-code.h" - -/* unexported prototypes */ -static void PrintCSrcComment PROTO ((FILE *src, Module *m)); -static void PrintCSrcIncludes PROTO ((FILE *src, Module *m, ModuleList *mods)); -static void PrintCHdrComment PROTO ((FILE *hdr, Module *m)); - -/* - * Fills the hdr file with the C type and encode/decode prototypes - * Fills the src file with the encoded/decode routine definitions - */ -void -PrintCCode PARAMS ((src, hdr, mods, m, r, longJmpVal, printTypes, printValues, printEncoders, printDecoders, printPrinters, printFree), - FILE *src _AND_ - FILE *hdr _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - CRules *r _AND_ - long int longJmpVal _AND_ - int printTypes _AND_ - int printValues _AND_ - int printEncoders _AND_ - int printDecoders _AND_ - int printPrinters _AND_ - int printFree) -{ - TypeDef *td; - ValueDef *vd; - - PrintCSrcComment (src, m); - PrintCSrcIncludes (src, m, mods); - - PrintCHdrComment (hdr, m); - PrintConditionalIncludeOpen (hdr, m->cHdrFileName); - - fprintf (hdr,"\n\n"); - fprintf (src,"\n\n"); - - - if (printValues) - { - /* put value defs at beginning of .c file */ - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - PrintCValueDef (src, r, vd); - } - } - - PrintCAnyCode (src, hdr, r, mods, m); - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (printTypes) - PrintCTypeDef (hdr, r, m, td); - - /* for PDU type or types ref'd with ANY/ANY DEF BY */ - if (printEncoders && - ((td->anyRefs != NULL) || td->cTypeDefInfo->isPdu)) - PrintCBerEncoder (src, hdr, r, m, td); - - /* for PDU type or types ref'd with ANY/ANY DEF BY */ - if (printDecoders && - ((td->anyRefs != NULL) || td->cTypeDefInfo->isPdu)) - PrintCBerDecoder (src, hdr, r, m, td, &longJmpVal); - - if (printEncoders) - PrintCBerContentEncoder (src, hdr, r, m, td); - - if (printDecoders) - PrintCBerContentDecoder (src, hdr, r, m, td, &longJmpVal); - - - if (printPrinters) - PrintCPrinter (src, hdr, r, mods, m, td); - - if (printFree) - PrintCFree (src, hdr, r, mods, m, td); - - /* only print new lines for normal types */ - switch (td->type->basicType->choiceId) - { - case BASICTYPE_SEQUENCEOF: /* list types */ - case BASICTYPE_SETOF: - case BASICTYPE_CHOICE: - case BASICTYPE_SET: - case BASICTYPE_SEQUENCE: - fprintf (src, "\n\n\n"); - /* fall through */ - - case BASICTYPE_IMPORTTYPEREF: /* type references */ - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_BOOLEAN: /* library type */ - case BASICTYPE_REAL: /* library type */ - case BASICTYPE_OCTETSTRING: /* library type */ - case BASICTYPE_NULL: /* library type */ - case BASICTYPE_OID: /* library type */ - case BASICTYPE_INTEGER: /* library type */ - case BASICTYPE_BITSTRING: /* library type */ - case BASICTYPE_ENUMERATED: /* library type */ - case BASICTYPE_ANYDEFINEDBY: /* ANY types */ - case BASICTYPE_ANY: - fprintf (hdr, "\n\n\n"); - break; - } - - } - - if (printValues) - { - /* put value externs at end of .h file */ - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - PrintCValueExtern (hdr, r, vd); - } - } - - PrintConditionalIncludeClose (hdr, m->cHdrFileName); - -} /* PrintCCode */ - - -static void -PrintCSrcComment PARAMS ((src, m), - FILE *src _AND_ - Module *m) -{ - long int t; - - t = time (0); - fprintf (src, "/*\n"); - fprintf (src, " * %s\n *\n", m->cSrcFileName); - fprintf (src, " * \"%s\" ASN.1 module encode/decode/print/free C src.\n *\n", m->modId->name); - fprintf (src, " * This file was generated by snacc on %s *\n", ctime (&t)); - fprintf (src, " * UBC snacc written by Mike Sample\n *\n"); - fprintf (src, " * NOTE: This is a machine generated file - editing not recommended\n"); - fprintf (src, " */\n\n\n"); - -} /* PrintSrcComment */ - - - -static void -PrintCSrcIncludes PARAMS ((src, m, mods), - FILE *src _AND_ - Module *m _AND_ - ModuleList *mods) -{ - void *tmp; - Module *impMod; - - /* - * include snacc runtime library related hdrs - */ - fprintf (src, "\n#include \"asn-incl.h\"\n"); - - /* - * print out include files in same order of the module - * list. every module in the list includes the others and it's - * own .h - */ - tmp = (void*)CURR_LIST_NODE (mods); - FOR_EACH_LIST_ELMT (impMod, mods) - { - fprintf (src, "#include \"%s\"\n", impMod->cHdrFileName); - } - SET_CURR_LIST_NODE (mods, tmp); - -} /* PrintCSrcIncludes */ - - -static void -PrintCHdrComment PARAMS ((f, m), - FILE *f _AND_ - Module *m) -{ - long int t; - - t = time (0); - fprintf (f, "/*\n"); - fprintf (f, " * %s\n *\n", m->cHdrFileName); - fprintf (f, " * \"%s\" ASN.1 module C type definitions and prototypes\n *\n", m->modId->name); - fprintf (f, " * This .h file was generated by snacc on %s *\n", ctime (&t)); - fprintf (f, " * UBC snacc written compiler by Mike Sample\n *\n"); - fprintf (f, " * NOTE: This is a machine generated file--editing not recommended\n"); - fprintf (f, " */\n\n\n"); -} /* PrintCHdrComment */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-dec.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-dec.c deleted file mode 100644 index 0d062511..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-dec.c +++ /dev/null @@ -1,1912 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-dec.c - routines for printing C decoders from type trees - * - * The type tree has already been run through the c type generator - * (type-info.c). Types that the type generator didn't know how - * to handle (or didn't want/need to handle eg macros) get the - * C_NO_TYPE label and are ignored for code generation. - * - * NOTE: this is a real rats nest - it sort of evolved. It was - * written assuming SETs/SEQ/CHOICE etc could be nested - * hence all the crap about 'levels'. - * - * Mike Sample - * 91/10/23 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-dec.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-dec.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:41 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1997/02/28 13:39:54 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.3 1995/07/25 18:41:01 rj - * file name has been shortened for redundant part: c-gen/gen-c-dec -> c-gen/gen-dec. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:22:06 rj - * snacc_config.h and other superfluous .h files removed. - * - * Revision 1.1 1994/08/28 09:48:20 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "define.h" -#include "lib-types.h" -#include "rules.h" -#include "type-info.h" -#include "str-util.h" -#include "snacc-util.h" -#include "util.h" -#include "tag-util.h" -#include "gen-dec.h" - - -static CRules *genDecCRulesG; -char *valueArgNameG = "v"; -static long int *longJmpValG; -static char *decodedLenVarNameG = "totalElmtsLen"; -static char *itemLenVarNameG = "elmtLen"; -static char *mecVarNameG = "mandatoryElmtCount"; -static char *tagIdVarNameG = "tagId"; -char *bufTypeNameG = "BUF_TYPE"; -char *lenTypeNameG = "AsnLen"; -char *tagTypeNameG = "AsnTag"; -char *envTypeNameG = "ENV_TYPE"; - - - -/* non-exported prototypes */ - -static void PrintCBerDecoderPrototype PROTO ((FILE *hdr, TypeDef *td)); -static void PrintCBerDecoderDeclaration PROTO ((FILE *src, TypeDef *td)); -static void PrintCBerDecoderDefine PROTO ((FILE *src, TypeDef *td)); - -static int RecCountVariableLevels PROTO ((Type *t)); -static int CountVariableLevels PROTO ((Type *t)); -static void PrintCBerDecoderLocals PROTO ((FILE *src, TypeDef *td)); -static void PrintCBerListDecoderLocals PROTO ((FILE *src)); - -static void PrintCBerSetDecodeCode PROTO ((FILE *src, TypeDef *td, Type *parent, NamedTypeList *e, int elmtLevel, int totalLevel, int tagLevel, char *varName)); - -static void PrintCBerSeqDecodeCode PROTO ((FILE *src, TypeDef *td, Type *parent, NamedTypeList *e, int elmtLevel, int totalLevel, int tagLevel, char *varName)); - -static void PrintCBerListDecoderCode PROTO ((FILE *src, TypeDef *td, Type *t, int elmtLevel, int totalLevel, int tagLevel, char *varName)); - -static void PrintCBerChoiceDecodeCode PROTO ((FILE *src, TypeDef *td, Type *t, int elmtLevel, int totalLevel, int tagLevel, char *varName)); - -static void PrintCLenDecodingCode PROTO ((FILE *f)); - -static void PrintCBerDecoderIncludes PROTO ((FILE *src, Module *m, ModuleList *mods)); - -static void PrintCBerElmtDecodeCode PROTO ((FILE *src, TypeDef *td, Type *parent, Type *t, int elmtLevel, int totalLevel, int tagLevel, char *parnetVarName, char *elmtVarName, int stoleChoiceTags)); - - -void -PrintCBerDecoder PARAMS ((src, hdr, r, m, td, longJmpVal), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - long int *longJmpVal) -{ - int i; - enum BasicTypeChoiceId typeId; - int elmtLevel; - CTDI *ctdi; - Tag *tag; - char *classStr; - char *formStr; - int stoleChoiceTags; - TagList *tags; - - ctdi = td->cTypeDefInfo; - if (!ctdi->genDecodeRoutine) - return; - - /* - * if is type that refs another pdu type or lib type - * without generating a new type via tagging or named elmts - * print define to the hdr file - * (a type is a pdu by default if it is ref'd by an ANY) - */ - if (!IsNewType (td->type) && - (!IsTypeRef (td->type) || - (IsTypeRef (td->type) && - (td->type->basicType->a.localTypeRef->link->cTypeDefInfo->isPdu || - ((td->type->basicType->a.localTypeRef->link->anyRefs != NULL) && - !LIST_EMPTY (td->type->basicType->a.localTypeRef->link->anyRefs)))))) - { - fprintf(hdr,"#define B%s B%s\n", td->cTypeDefInfo->decodeRoutineName, td->type->cTypeRefInfo->decodeRoutineName); -/* - fprintf(hdr,"#define B%s(b, v, bytesDecoded, env) B%s(b, v, bytesDecoded, env)\n", td->cTypeDefInfo->decodeRoutineName, td->type->cTypeRefInfo->decodeRoutineName); -*/ - return; - } - - - - typeId = GetBuiltinType (td->type); - - /* print proto type to hdr file */ - fprintf (hdr, "void B%s PROTO ((%s b, %s *result, %s *bytesDecoded, %s env));\n", ctdi->decodeRoutineName, bufTypeNameG, ctdi->cTypeName, lenTypeNameG, envTypeNameG); - - /* print routine in src */ - fprintf (src,"void B%s PARAMS ((b, result, bytesDecoded, env),\n", ctdi->decodeRoutineName); - fprintf (src,"%s b _AND_\n", bufTypeNameG); - fprintf (src,"%s *result _AND_\n", ctdi->cTypeName); - fprintf (src,"%s *bytesDecoded _AND_\n", lenTypeNameG); - fprintf (src,"%s env)\n", envTypeNameG); - fprintf (src,"{\n"); - fprintf (src," %s tag;\n", tagTypeNameG); - - /* print extra locals for redundant lengths */ - tags = GetTags (td->type, &stoleChoiceTags); - for (i = 1; !stoleChoiceTags && (i <= LIST_COUNT (tags)); i++) - fprintf (src," %s elmtLen%d;\n", lenTypeNameG, i); - - /* add extra len for choice */ - if (typeId == BASICTYPE_CHOICE) - fprintf (src," %s elmtLen%d;\n", lenTypeNameG, i); - - fprintf (src,"\n"); - - /* decode tag/length pairs */ - elmtLevel = 0; - if (!stoleChoiceTags) - { - FOR_EACH_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - if (tag->form == ANY_FORM) - formStr = Form2FormStr (PRIM); - else - formStr = Form2FormStr (tag->form); - - fprintf (src," if (((tag = BDecTag (b, bytesDecoded, env)) != \n"); - - if (tag->tclass == UNIV) - { - fprintf (src,"MAKE_TAG_ID (%s, %s, %s))", classStr, formStr, Code2UnivCodeStr (tag->code)); - if (tag->form == ANY_FORM) - fprintf (src,"&&\n (tag != MAKE_TAG_ID (%s, %s, %s)))\n", classStr, Form2FormStr (CONS), Code2UnivCodeStr (tag->code)); - else - fprintf (src,")\n"); - } - else - { - fprintf (src,"MAKE_TAG_ID (%s, %s, %d))", classStr, formStr, tag->code); - if (tag->form == ANY_FORM) - fprintf (src,"&&\n (tag != MAKE_TAG_ID (%s, %s, %d)))\n", classStr, Form2FormStr (CONS), tag->code); - else - fprintf (src,")\n"); - - } - fprintf (src," {\n"); - fprintf (src," Asn1Error (\"B%s: ERROR - wrong tag\\n\");\n", ctdi->decodeRoutineName); - fprintf (src," longjmp (env, %d);\n", (*longJmpVal)--); - fprintf (src," }\n"); - - fprintf (src," elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - } - - /* for choices always decode first tag of the choice's content */ - if (typeId == BASICTYPE_CHOICE) - { - fprintf (src," tag = BDecTag (b, bytesDecoded, env);\n"); - fprintf (src," elmtLen%d = BDecLen (b, bytesDecoded, env);\n", ++elmtLevel); - } - - if ((typeId != BASICTYPE_ANY) && (typeId != BASICTYPE_ANYDEFINEDBY)) - fprintf (src," B%sContent (b, tag, elmtLen%d, result, bytesDecoded, env);\n", ctdi->decodeRoutineName, elmtLevel); - else - fprintf (src," B%s (b, result, bytesDecoded, env);\n", ctdi->decodeRoutineName, elmtLevel); - - - /* grab any EOCs that match redundant, indef lengths */ - for (i = elmtLevel-1; i > 0; i--) - { - fprintf (src," if (elmtLen%d == INDEFINITE_LEN)\n", i); - fprintf (src," BDecEoc (b, bytesDecoded, env);\n"); - } - - - fprintf (src,"} /* B%s */\n\n", ctdi->decodeRoutineName); - - FreeTags (tags); -} /* PrintCBerDecoder */ - - -void -PrintCBerContentDecoder PARAMS ((src, hdr, r, m, td, longJmpVal), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - long int *longJmpVal) -{ - NamedType *e; - CTDI *ctdi; - CTypeId rhsTypeId; /* cTypeId of the type that defined this typedef */ - Type *t; - BER_FORM form; - - longJmpValG = longJmpVal; - - genDecCRulesG = r; - - ctdi = td->cTypeDefInfo; - if ((ctdi == NULL) || (td->type->cTypeRefInfo == NULL)) - { - fprintf (stderr,"PrintCBerDecoder: ERROR - no type info\n"); - return; - } - - if (!ctdi->genDecodeRoutine) - return; - - rhsTypeId = td->type->cTypeRefInfo->cTypeId; - switch (rhsTypeId) - { - /* - * type refs or primitive types are - * defined as calls to the referenced type - */ - case C_ANY: - fprintf (hdr, "/* ANY - Fix Me! */\n"); - case C_ANYDEFINEDBY: - fprintf(hdr, "#define B%s B%s\n", td->cTypeDefInfo->decodeRoutineName, td->type->cTypeRefInfo->decodeRoutineName); - -/* - fprintf(hdr, "#define B%s( b, tagId, elmtLen, v, bytesDecoded, env) ", td->cTypeDefInfo->decodeRoutineName); - fprintf (hdr, "B%s (b, tagId, elmtLen, v, bytesDecoded, env)", td->type->cTypeRefInfo->decodeRoutineName); -*/ - fprintf (hdr,"\n\n"); - break; - - case C_LIB: - case C_TYPEREF: - PrintCBerDecoderDefine (hdr, td); - fprintf (hdr,"\n\n"); - break; - - - case C_CHOICE: - PrintCBerDecoderPrototype (hdr, td); - fprintf (hdr,"\n\n"); - PrintCBerDecoderDeclaration (src, td); - fprintf (src,"{\n"); - PrintCBerDecoderLocals (src, td); - fprintf (src,"\n\n"); - PrintCBerChoiceDecodeCode (src, td, td->type, FIRST_LEVEL-1, FIRST_LEVEL,FIRST_LEVEL-1, valueArgNameG); - - fprintf (src, " (*bytesDecoded) += totalElmtsLen1;\n"); - fprintf (src,"} /* B%sContent */",td->cTypeDefInfo->decodeRoutineName); - fprintf (src,"\n\n"); - break; - - case C_STRUCT: - PrintCBerDecoderPrototype (hdr, td); - fprintf (hdr,"\n\n"); - PrintCBerDecoderDeclaration (src, td); - fprintf (src,"{\n"); - PrintCBerDecoderLocals (src, td); - fprintf (src,"\n\n"); - if (td->type->basicType->choiceId == BASICTYPE_SET) - PrintCBerSetDecodeCode (src, td, td->type, td->type->basicType->a.set, FIRST_LEVEL-1, FIRST_LEVEL, FIRST_LEVEL-1, valueArgNameG); - else - PrintCBerSeqDecodeCode (src, td, td->type, td->type->basicType->a.sequence, FIRST_LEVEL-1, FIRST_LEVEL, FIRST_LEVEL-1, valueArgNameG); - - fprintf (src, " (*bytesDecoded) += totalElmtsLen1;\n"); - fprintf (src,"} /* B%sContent */",td->cTypeDefInfo->decodeRoutineName); - fprintf (src,"\n\n"); - break; - - - case C_LIST: - PrintCBerDecoderPrototype (hdr, td); - fprintf (hdr,"\n\n"); - - PrintCBerDecoderDeclaration (src, td); - fprintf (src,"{\n"); - PrintCBerDecoderLocals (src, td); - fprintf (src,"\n\n"); - PrintCBerListDecoderCode (src, td, td->type, FIRST_LEVEL-1, FIRST_LEVEL, FIRST_LEVEL-1, valueArgNameG); - - fprintf (src, " (*bytesDecoded) += totalElmtsLen1;\n"); - fprintf (src,"} /* B%sContent */",td->cTypeDefInfo->decodeRoutineName); - fprintf (src,"\n\n"); - break; - - case C_NO_TYPE: -/* fprintf (src,"< sorry, unsupported type >\n\n"); */ - return; /* dont' print newlines */ - break; - - default: - fprintf (stderr,"PrintCBerContentDecoder: ERROR - unknown c type id\n"); - return; - break; - } - -} /* PrintCBerContentDecoder */ - - - - -/* - * Prints prototype for decode routine in hdr file - */ - -static void -PrintCBerDecoderPrototype PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - CTDI *ctdi; - - ctdi = td->cTypeDefInfo; - fprintf (hdr,"void B%sContent PROTO ((%s b, %s tagId%d, %s elmtLen%d, %s *v, %s *bytesDecoded, %s env));\n", ctdi->decodeRoutineName, bufTypeNameG, tagTypeNameG, FIRST_LEVEL-1, lenTypeNameG, FIRST_LEVEL-1, ctdi->cTypeName,lenTypeNameG, envTypeNameG); - -} /* PrintCBerDecoderPrototype */ - - - -/* - * Prints declarations of decode routine for the given type def - */ -static void -PrintCBerDecoderDeclaration PARAMS ((src,td), - FILE *src _AND_ - TypeDef *td) -{ - CTDI *ctdi; - - ctdi = td->cTypeDefInfo; - fprintf (src,"void\n"); - fprintf (src,"B%sContent PARAMS ((b, tagId%d, elmtLen%d, v, bytesDecoded, env),\n", ctdi->decodeRoutineName, FIRST_LEVEL -1, FIRST_LEVEL -1); - fprintf (src,"%s b _AND_\n", bufTypeNameG); - fprintf (src,"%s tagId%d _AND_\n", tagTypeNameG, FIRST_LEVEL -1); - fprintf (src,"%s elmtLen%d _AND_\n", lenTypeNameG, FIRST_LEVEL -1); - fprintf (src,"%s *v _AND_\n", ctdi->cTypeName); - fprintf (src,"%s *bytesDecoded _AND_\n", lenTypeNameG); - fprintf (src,"%s env)\n", envTypeNameG); - -} /* PrintCBerDecoderDeclaration */ - - - -/* - * makes a define for type refs or primitive type renaming - * EG: - * TypeX ::= INTEGER --> #define BerDecodeTypeX(b,v) BerDecodeInteger(b,v) - * TypeX ::= TypeY --> #define BerDecodeTypeX(b,v) BerDecodeTypeY(b,v) - */ -static void -PrintCBerDecoderDefine PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - fprintf(hdr, "#define B%sContent B%sContent", td->cTypeDefInfo->decodeRoutineName, td->type->cTypeRefInfo->decodeRoutineName); - -/* - fprintf(hdr, "#define B%sContent( b, tagId, elmtLen, v, bytesDecoded, env) ", td->cTypeDefInfo->decodeRoutineName); - fprintf (hdr, "B%sContent (b, tagId, elmtLen, v, bytesDecoded, env)", td->type->cTypeRefInfo->decodeRoutineName); -*/ -} /* PrintCBerDecoderDefine */ - - - -/* - * used to figure out local variables to declare - */ -static int -RecCountVariableLevels PARAMS ((t), - Type *t) -{ - CTRI *ctri; - int maxLevels = 0; - NamedType *e; - TagList *tl; - int tagCount; - int typeCount; - void *tmp; - enum BasicTypeChoiceId typeId; - - ctri = t->cTypeRefInfo; - typeId = GetBuiltinType (t); - - /* embedded struct/choices aren't really an issue any more */ - if ((ctri->cTypeId == C_STRUCT) || - (ctri->cTypeId == C_CHOICE)) - { - maxLevels = 1; - - tagCount = CountTags (t); - - tmp = (void*)CURR_LIST_NODE (t->basicType->a.set); - FOR_EACH_LIST_ELMT (e, t->basicType->a.set) - { - if ((e->type == NULL) || (e->type->cTypeRefInfo == NULL)) - continue; - - typeCount = RecCountVariableLevels (e->type); - - if (typeCount > maxLevels) - maxLevels = typeCount; - } - SET_CURR_LIST_NODE (t->basicType->a.set, tmp); - return maxLevels + tagCount; - } - else if (ctri->cTypeId == C_LIST) - { - return CountTags (t) +RecCountVariableLevels (t->basicType->a.setOf); - } - else if (typeId == BASICTYPE_CHOICE) - return CountTags (t) +1; - else if ((typeId == BASICTYPE_ANY) || (typeId == BASICTYPE_ANYDEFINEDBY)) - return CountTags (t) +1; - else - return CountTags (t); - -} /* RecCountVariableLevels */ - - - -/* - * returns the number of variable contexts needed for - * decoding the contents of this type. Does not consider tags on this type. - */ -static int -CountVariableLevels PARAMS ((t), - Type *t) -{ - CTRI *ctri; - int maxLevels = 0; - NamedType *e; - TagList *tl; - int tagCount; - int typeCount; - void *tmp; - - ctri = t->cTypeRefInfo; - - if ((ctri->cTypeId == C_STRUCT) || - (ctri->cTypeId == C_CHOICE)) - { - maxLevels = 1; - tmp = (void*)CURR_LIST_NODE (t->basicType->a.set); - FOR_EACH_LIST_ELMT (e, t->basicType->a.set) - { - if ((e->type == NULL) || (e->type->cTypeRefInfo == NULL)) - continue; - - typeCount = RecCountVariableLevels (e->type); - - /* add extra level since must decode key tag in choice */ - if (GetBuiltinType (e->type) == BASICTYPE_CHOICE) - typeCount++; - - if (typeCount > maxLevels) - maxLevels = typeCount; - } - SET_CURR_LIST_NODE (t->basicType->a.set, tmp); - return maxLevels; - } - else if (ctri->cTypeId == C_LIST) - return RecCountVariableLevels (t->basicType->a.setOf); - else if ((ctri->cTypeId == C_ANY) || - (ctri->cTypeId == C_ANYDEFINEDBY)) - return 1; - else - return 0; -} /* CountVariableLevels */ - - - -/* - * prints local vars for constructed types (set/seq/choice) - */ -static void -PrintCBerDecoderLocals PARAMS ((src,td), - FILE *src _AND_ - TypeDef *td) -{ - int levels; - int i; - - levels = CountVariableLevels (td->type); - - fprintf (src, " int seqDone = FALSE;\n"); - - for (i = 0; i < levels; i++) - { - fprintf (src, " %s totalElmtsLen%d = 0;\n", lenTypeNameG, i + FIRST_LEVEL); - fprintf (src, " %s elmtLen%d;\n", lenTypeNameG, i + FIRST_LEVEL); - fprintf (src, " %s tagId%d;\n", tagTypeNameG, i + FIRST_LEVEL); - if (i == 0) - fprintf (src, " int mandatoryElmtCount%d = 0;\n", i + FIRST_LEVEL); - } - -} /* PrintCBerDecoderLocals */ - - -/* - * given the Type *(t) of an elmt in a set/seq/choice/list, - * prints decoding code. - * elmtVarName is string ptr ref to field being decoded - * eg "(&personnelRecord.name)" - * stoleChoiceTags is as returned by GetTags - * - * elmtLevel - last elmtLen# var that is valid/used (has a len) - * totalLevel - totalElmtsLen# to be used for running total of dec bytes - * tagIdLevel - last tagId# var that is valid/used (contains a tag) - */ -static void -PrintCBerElmtDecodeCode PARAMS ((src, td, parent, t, elmtLevel, totalLevel, tagLevel, parentVarName, elmtVarName, stoleChoiceTags), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t _AND_ - int elmtLevel _AND_ - int totalLevel _AND_ - int tagLevel _AND_ - char *parentVarName _AND_ - char *elmtVarName _AND_ - int stoleChoiceTags) -{ - CTRI *ctri; - Type *tmpType; - char idVarRef[MAX_VAR_REF]; - NamedType *idNamedType; - enum BasicTypeChoiceId tmpTypeId; - - ctri = t->cTypeRefInfo; - - /* check if meant to be encoded */ - if (!ctri->isEncDec) - return; - - tmpType = GetType (t); - - if (tmpType->basicType->choiceId == BASICTYPE_ANY) - { - fprintf (src,"/* ANY - Fix Me ! */\n"); - fprintf (src," SetAnyTypeBy???(%s, ???);\n", elmtVarName); - fprintf (src," B%s (b, %s, &%s%d, env);\n", ctri->decodeRoutineName, elmtVarName, decodedLenVarNameG, totalLevel); - } - else if (tmpType->basicType->choiceId == BASICTYPE_ANYDEFINEDBY) - { - /* get type of 'defining' field (int/enum/oid)*/ - idNamedType = t->basicType->a.anyDefinedBy->link; - tmpTypeId = GetBuiltinType (idNamedType->type); - - if (tmpTypeId == BASICTYPE_OID) - { - MakeVarPtrRef (genDecCRulesG, td, parent, idNamedType->type, parentVarName, idVarRef); - fprintf (src, " SetAnyTypeByOid (%s, %s);\n", elmtVarName, idVarRef); - } - else - { - /* want to ref int by value not ptr */ - MakeVarValueRef (genDecCRulesG, td, parent, idNamedType->type, parentVarName, idVarRef); - fprintf (src, " SetAnyTypeByInt (%s, %s);\n", elmtVarName, idVarRef); - } - fprintf (src," B%s (b, %s, &%s%d, env);\n", ctri->decodeRoutineName, elmtVarName, decodedLenVarNameG, totalLevel); - } - else switch (ctri->cTypeId) - { - case C_LIB: - case C_TYPEREF: - /* - * choices and octet/bit str types need tagId argument - */ - if ((tmpType->basicType->choiceId == BASICTYPE_CHOICE) && - !stoleChoiceTags) - { - /* - * strip off top tag of choice in not already done - * since choice decoders assume you are passing in - * their top tag - */ - fprintf (src, " %s%d = BDecTag (b, &%s%d, env);\n", tagIdVarNameG, ++tagLevel, decodedLenVarNameG, totalLevel); - fprintf (src, " %s%d = BDecLen (b, &%s%d, env);\n", itemLenVarNameG, ++elmtLevel, decodedLenVarNameG, totalLevel); - } - fprintf (src," B%sContent (b, %s%d, %s%d, %s, &%s%d, env);\n", ctri->decodeRoutineName, tagIdVarNameG, tagLevel, itemLenVarNameG, elmtLevel, elmtVarName, decodedLenVarNameG, totalLevel); - - /* From ftp://ftp.cs.ubc.ca/pub/local/src/snacc/bugs-in-1.1 */ - if ((tmpType->basicType->choiceId == BASICTYPE_CHOICE) - && !stoleChoiceTags) - { - fprintf(src," if (elmtLen%d == INDEFINITE_LEN)\n", elmtLevel-1); - fprintf(src," BDecEoc(b, &totalElmtsLen%d, env);\n", totalLevel); - } - - break; - - - /* - * NOTE: the CHOICE, STRUCT and LIST switch clauses won't - * fire due to the current 'normalization' - * (see normalize.c) - */ - - case C_CHOICE: - /* - * strip off top tag of choice in not already done - * since choice decoders assume you are passing in - * their top tag - */ - if (!stoleChoiceTags) - { - fprintf (src, " %s%d = BDecTag (b, &%s%d, env);\n\n", tagIdVarNameG, ++tagLevel, decodedLenVarNameG, totalLevel); - - fprintf (src, " %s%d = BDecLen (b, &%s%d, env);\n", itemLenVarNameG, ++elmtLevel, decodedLenVarNameG, totalLevel); - } - PrintCBerChoiceDecodeCode (src, td, t, elmtLevel, totalLevel+1, tagLevel, elmtVarName); - break; - - - case C_STRUCT: - if (t->basicType->choiceId == BASICTYPE_SET) - PrintCBerSetDecodeCode (src, td, t, t->basicType->a.set, elmtLevel, totalLevel+1, tagLevel, elmtVarName); - else - { - PrintCBerSeqDecodeCode (src, td, t, t->basicType->a.sequence, elmtLevel,totalLevel+1, tagLevel, elmtVarName); - fprintf (src," seqDone = FALSE;\n"); - } - fprintf (src," %s%d += %s%d;\n", decodedLenVarNameG, totalLevel, decodedLenVarNameG, totalLevel+1); - break; - - - case C_LIST: - PrintCBerListDecoderCode (src, td, t, elmtLevel, totalLevel+1, tagLevel, elmtVarName); - fprintf (src,"\n\n"); - fprintf (src," %s%d += %s%d;\n", decodedLenVarNameG, totalLevel, decodedLenVarNameG, totalLevel+1); - break; - - - case C_NO_TYPE: - break; - - default: - fprintf (stderr,"PrintCBerElmtDecodeCode: ERROR - unknown c type id\n"); - break; - } - -} /* PrintCBerElmtDecodeCode */ - - -/* - * Prints code for decoding the elmts of SET - */ -static void -PrintCBerSetDecodeCode PARAMS ((src, td, parent, elmts, elmtLevel, totalLevel, tagLevel, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts _AND_ - int elmtLevel _AND_ - int totalLevel _AND_ - int tagLevel _AND_ - char *varName) -{ - NamedType *e; - CTRI *ctri; - TagList *tags; - Tag *tag; - TagList *tl; - enum BasicTypeChoiceId builtinType; - char *classStr; - char *formStr; - char *codeStr; - int mandatoryCount = 0; - int i; - char tmpVarName[MAX_VAR_REF]; - int stoleChoiceTags; - char *routineName; - int initialTagLevel; - int initialElmtLevel; - - - initialTagLevel = tagLevel; - initialElmtLevel = elmtLevel; - - - routineName = td->cTypeDefInfo->decodeRoutineName; - - if ((elmts == NULL) || LIST_EMPTY (elmts)) /* empty set */ - { - fprintf (src," if (elmtLen%d == INDEFINITE_LEN)\n", elmtLevel); - fprintf (src," {\n"); - fprintf (src," BDecEoc (b, &totalElmtsLen%d, env);\n", totalLevel); - fprintf (src," }\n"); - fprintf (src," else if (elmtLen%d != 0)\n", elmtLevel); - fprintf (src," {\n"); - fprintf (src," Asn1Error (\"Expected an empty SET\\n\");\n"); - fprintf (src," longjmp (env, %d);\n",(*longJmpValG)--); - - fprintf (src," }\n"); - -/* forget about possible extension types for now - fprintf (src," if (elmtLen%d == INDEFINITE_LEN)\n", elmtLevel); - fprintf (src," {\n"); - fprintf (src," tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", ++tagLevel, totalLevel); - - fprintf (src," if (tagId%d == EOC_TAG_ID)\n", tagLevel); - fprintf (src," BDEC_2ND_EOC_OCTET (b, &totalElmtsLen%d, env)\n", totalLevel); - fprintf (src," else\n"); - fprintf (src," BerDiscardElmt (b, &totalElmtsLen%d, env);\n\n",totalLevel); - fprintf (src," }\n"); - fprintf (src," else\n"); - fprintf (src," {\n"); - fprintf (src," BufSkip (b, elmtLen%d);\n", elmtLevel); - fprintf (src," totalElmtsLen%d += elmtLen%d;\n", totalLevel, elmtLevel); - fprintf (src," }\n"); -*/ - return; - } - - - fprintf (src, "for ( ; (totalElmtsLen%d < elmtLen%d) || (elmtLen%d == INDEFINITE_LEN);)\n", totalLevel, elmtLevel, elmtLevel); - fprintf (src, "{\n"); - fprintf (src, " tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", ++tagLevel, totalLevel); - fprintf (src, " if ((tagId%d == EOC_TAG_ID) && (elmtLen%d == INDEFINITE_LEN))\n", tagLevel, elmtLevel); - fprintf (src, " {\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, &totalElmtsLen%d, env)\n", totalLevel); - fprintf (src, " break; /* got EOC so can exit this SET's for loop*/\n"); - fprintf (src, " }\n"); - - fprintf (src, " elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - - fprintf (src, " switch (tagId%d)\n", tagLevel); - fprintf (src, " {\n"); - - FOR_EACH_LIST_ELMT (e, elmts) - { - - elmtLevel = initialElmtLevel+1; - tagLevel = initialTagLevel+1; - if ((e->type == NULL) || (e->type->cTypeRefInfo == NULL)) - { - fprintf (src, "< ERROR - no c type information - prob unsuported type>\n"); - continue; - } - - ctri = e->type->cTypeRefInfo; - - /* check if meant to be encoded */ - if (!ctri->isEncDec) - continue; - - tags = GetTags (e->type, &stoleChoiceTags); - builtinType = GetBuiltinType (e->type); - - if ((tags == NULL) || LIST_EMPTY (tags)) - { - if ((builtinType != BASICTYPE_ANY) && - (builtinType != BASICTYPE_ANYDEFINEDBY)) - fprintf (src, "\n"); - else - { - fprintf (src," /* ANY - Fix Me ! */\n"); - fprintf (src," case MAKE_TAG_ID (?,?,?):\n"); - } - } - else - { - tag = (Tag*)FIRST_LIST_ELMT (tags); - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (CONS), codeStr); - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (PRIM), codeStr); - } - else - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - } - else - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, formStr, tag->code); - } - - AsnListFirst (tags); - AsnListNext (tags); /* set curr to 2nd tag */ - FOR_REST_LIST_ELMT (tag, tags) - { - - codeStr = Code2UnivCodeStr (tag->code); - classStr = Class2ClassStr (tag->tclass); - formStr = Form2FormStr (tag->form); - - if (stoleChoiceTags) - { - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - } - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - } - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, formStr, tag->code); - } - } - else - { - tagLevel = initialTagLevel+2; - if (tag->form == ANY_FORM) - { - fprintf (src," tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n", tagLevel, totalLevel); - if (tag->tclass == UNIV) - { - fprintf (src,"if ((tagId%d != MAKE_TAG_ID (%s, %s, %s)) &&\n", tagLevel, classStr, Form2FormStr (PRIM), codeStr); - fprintf (src," (tagId%d != MAKE_TAG_ID (%s, %s, %s)))\n", tagLevel, classStr, Form2FormStr (CONS), codeStr); - } - else - { - fprintf (src,"if ((tagId%d != MAKE_TAG_ID (%s, %s, %d)) &&\n", tagLevel, classStr, Form2FormStr (PRIM), tag->code); - fprintf (src," (tagId%d != MAKE_TAG_ID (%s, %s, %d)))\n", tagLevel, classStr, Form2FormStr (CONS), tag->code); - } - - } - else - { - if (tag->tclass == UNIV) - fprintf (src,"if (BDecTag (b, &totalElmtsLen%d, env) != MAKE_TAG_ID (%s, %s, %s))\n", totalLevel, classStr, formStr, codeStr); - else - fprintf (src,"if (BDecTag (b, &totalElmtsLen%d, env) != MAKE_TAG_ID (%s, %s, %d))\n", totalLevel, classStr, formStr, tag->code); - } - - fprintf (src," {\n"); - fprintf (src," Asn1Error (\"Unexpected Tag\\n\");\n"); - fprintf (src," longjmp (env, %d);\n", (*longJmpValG)--); - fprintf (src," }\n\n"); - fprintf (src,"elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - } - } - } - - MakeVarPtrRef (genDecCRulesG, td, parent, e->type, varName, tmpVarName); - - /* - * allocate mem for decoding result - */ - PrintElmtAllocCode (src, e->type, tmpVarName); - - PrintCBerElmtDecodeCode (src, td, parent, e->type, elmtLevel, totalLevel, tagLevel, varName, tmpVarName, stoleChoiceTags); - - /* - * must check for another EOC for ANYs - * Since the any decode routines - * decode their own first tag/len pair - */ - if ((builtinType == BASICTYPE_ANY) || - (builtinType == BASICTYPE_ANYDEFINEDBY)) - PrintEocDecoders (src, elmtLevel, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - /* - * must check for another EOC for tagged CHOICEs - * since the choice decoder routines do not check - * for an EOC on the choice's overall length - - * they are only passed the tag/len of the choice's - * component. - */ - else if ((builtinType == BASICTYPE_CHOICE) && !(stoleChoiceTags) && - ((tags != NULL) && !LIST_EMPTY (tags))) - PrintEocDecoders (src, elmtLevel, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - - else - PrintEocDecoders (src, elmtLevel-1, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - - if ((!e->type->optional) && (e->type->defaultVal == NULL)) - { - mandatoryCount++; - fprintf (src, " mandatoryElmtCount%d++;\n", totalLevel); - } - - FreeTags (tags); - - fprintf (src," break;\n\n"); - } /* end for */ - - fprintf (src, " default:\n"); - fprintf (src, " Asn1Error (\"B%sContent: ERROR - Unexpected tag in SET\\n\");\n", routineName); - fprintf (src, " longjmp (env, %d);\n",(*longJmpValG)--); - fprintf (src, " break;\n"); - -/* - fprintf (src, " Asn1Warning (\"B%sContent: Warning - unexpected tag in SET, discarding elmt\\n\");\n", routineName); - fprintf (src, " BerDiscardElmt (b, &totalElmtsLen%d, env);\n\n", totalLevel); -*/ - - fprintf (src, " } /* end switch */\n"); - fprintf (src, " } /* end for */\n"); - - fprintf (src, " if (mandatoryElmtCount%d != %d)\n", totalLevel, mandatoryCount); - - fprintf (src, " {\n"); - fprintf (src, " Asn1Error (\"B%sContent: ERROR - non-optional elmt missing from SET\\n\");\n", routineName); - fprintf (src, " longjmp (env, %d);\n",(*longJmpValG)--); - fprintf (src, " }\n"); - -} /* PrintCBerSetDecodeCode */ - - - - -/* - * Prints code for decoding the elmts of a SEQUENCE - */ -static void -PrintCBerSeqDecodeCode PARAMS ((src, td, parent, elmts, elmtLevel, totalLevel, tagLevel, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts _AND_ - int elmtLevel _AND_ - int totalLevel _AND_ - int tagLevel _AND_ - char *varName) -{ - CTRI *ctri; - CTDI *ctdi; - NamedType *e; - NamedType *tmpElmt; - NamedType *last; - TagList *tags; - Tag *tag; - Tag *lastTag; - enum BasicTypeChoiceId builtinType; - enum BasicTypeChoiceId tmpTypeId; - char *classStr; - BER_FORM form; - char *formStr; - char *codeStr; - int i; - char tmpVarName[MAX_VAR_REF]; - int stoleChoiceTags; - char *routineName; - int inTailOptElmts = FALSE; - int initialElmtLevel; - int initialTagLevel; - - - initialTagLevel = tagLevel; - initialElmtLevel = elmtLevel; - - - routineName = td->cTypeDefInfo->decodeRoutineName; - - if ((elmts == NULL) || LIST_EMPTY (elmts)) /* empty seq */ - { - fprintf (src," if (elmtLen%d == INDEFINITE_LEN)\n", elmtLevel); - fprintf (src," {\n"); - fprintf (src," BDecEoc (b, &totalElmtsLen%d, env);\n", totalLevel); - fprintf (src," }\n"); - fprintf (src," else if (elmtLen%d != 0)\n", elmtLevel); - fprintf (src," {\n"); - fprintf (src," Asn1Error (\"Expected an empty SEQUENCE\\n\");\n"); - fprintf (src," longjmp (env, %d);\n",(*longJmpValG)--); - - fprintf (src," }\n"); - -/* - forget about extended types for now - fprintf (src," tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", tagLevel+1, totalLevel); - fprintf (src," {\n"); - fprintf (src," if (tagId%d == EOC_TAG_ID)\n", tagLevel+1); - fprintf (src," BDEC_2ND_EOC_OCTET (b, &totalElmtsLen%d, env)\n", totalLevel); - fprintf (src," else\n"); - fprintf (src," BerDiscardElmt (b, &totalElmtsLen%d, env);\n\n",totalLevel); - fprintf (src," }\n"); - fprintf (src," else \n"); - fprintf (src," {\n"); - fprintf (src," BufSkip (b, elmtLen%d);\n", elmtLevel); - fprintf (src," totalElmtsLen%d += elmtLen%d\n", totalLevel, elmtLevel); - fprintf (src," }\n"); -*/ - return; - } - - /* - * must set list curr since IsTailOptional checks from curr pt - * onward - */ - AsnListFirst (elmts); - inTailOptElmts = IsTailOptional (elmts); - e = (NamedType*)FIRST_LIST_ELMT (elmts); - tmpTypeId = GetBuiltinType (e->type); - - /* - * print code to decode the first tag - */ - tagLevel++; - if (!inTailOptElmts) - { - if (((tmpTypeId == BASICTYPE_ANY) || - (tmpTypeId == BASICTYPE_ANYDEFINEDBY)) && - (CountTags (e->type) == 0)) - { - if ((e->type->optional) && (e != (NamedType*)LAST_LIST_ELMT (elmts))) - { - /* let this cause a compile error in the generated code */ - fprintf (src,"\n"); - } - } - else - fprintf (src, " tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", tagLevel, totalLevel); - } - else - { - fprintf (src, " if ((elmtLen%d != INDEFINITE_LEN) && (totalElmtsLen%d == elmtLen%d))\n", elmtLevel, totalLevel, elmtLevel); - fprintf (src, " seqDone = TRUE;\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - - if (((tmpTypeId == BASICTYPE_ANY) || - (tmpTypeId == BASICTYPE_ANYDEFINEDBY)) && - (CountTags (e->type) == 0)) - { - if ((e->type->optional) && (e != (NamedType*)LAST_LIST_ELMT (elmts))) - { - /* let this cause a compile error in the generated code */ - fprintf (src,"\n"); - } - } - else - fprintf (src, " tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", tagLevel, totalLevel); - fprintf (src," if ((elmtLen%d == INDEFINITE_LEN) && (tagId%d == EOC_TAG_ID))\n", elmtLevel, tagLevel); - fprintf (src, " {\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, &totalElmtsLen%d, env)\n", totalLevel); - fprintf (src, " seqDone = TRUE;\n"); - fprintf (src, " }\n"); - fprintf (src, " }\n\n"); - } - - last = (NamedType*)LAST_LIST_ELMT (elmts); - FOR_EACH_LIST_ELMT (e, elmts) - { - elmtLevel = initialElmtLevel; - tagLevel = initialTagLevel+1; - - if ((e->type == NULL) || (e->type->cTypeRefInfo == NULL)) - { - fprintf (src, "< ERROR - no c type information - prob unsuported type>\n"); - continue; - } - - ctri = e->type->cTypeRefInfo; - - /* check if meant to be encoded */ - if (!ctri->isEncDec) - continue; - - tags = GetTags (e->type, &stoleChoiceTags); - builtinType = GetBuiltinType (e->type); - - - if ((tags == NULL) || LIST_EMPTY (tags)) - { - if ((builtinType != BASICTYPE_ANY) && - (builtinType != BASICTYPE_ANYDEFINEDBY)) - fprintf (src, "\n"); - - if (inTailOptElmts) - { - fprintf (src," if (!seqDone)"); - } - /* always enclose elmt decoder in block */ - fprintf (src," {\n"); - -/* - else - { - fprintf (src," if (tagId%d == MAKE_TAG_ID (?, ?, ?))\n", tagLevel); - fprintf (src," {\n"); - } -*/ - } - else /* has tags */ - { - tag = (Tag*)FIRST_LIST_ELMT (tags); - - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - - - if (inTailOptElmts) - fprintf (src," if ((!seqDone) && ("); - else - fprintf (src," if (("); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src,"(tagId%d == MAKE_TAG_ID (%s, %s, %s)) ||\n", tagLevel, classStr, Form2FormStr (PRIM), codeStr); - fprintf (src,"(tagId%d == MAKE_TAG_ID (%s, %s, %s))", tagLevel, classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src,"(tagId%d == MAKE_TAG_ID (%s, %s, %s))", tagLevel, classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src,"(tagId%d == MAKE_TAG_ID (%s, %s, %d)) ||\n", tagLevel, classStr, Form2FormStr (PRIM), tag->code); - fprintf (src,"(tagId%d == MAKE_TAG_ID (%s, %s, %d))", tagLevel, classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src,"(tagId%d == MAKE_TAG_ID (%s, %s, %d))", tagLevel, classStr, formStr, tag->code); - } - - if (!stoleChoiceTags) - { - fprintf (src,"))\n"); - fprintf (src, " {\n"); - fprintf (src," elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - } - - AsnListFirst (tags); - AsnListNext (tags); - - FOR_REST_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - - if (stoleChoiceTags) - { - fprintf (src," ||\n"); - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src," (tagId%d ==MAKE_TAG_ID (%s, %s, %s))", tagLevel, classStr, Form2FormStr (PRIM), codeStr); - fprintf (src,"||\n (tagId%d == MAKE_TAG_ID (%s, %s, %s))", tagLevel, classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src," (tagId%d ==MAKE_TAG_ID (%s, %s, %s))", tagLevel, classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src," (tagId%d == MAKE_TAG_ID (%s, %s, %d))", tagLevel, classStr, Form2FormStr (PRIM), tag->code); - fprintf (src,"||\n (tagId%d == MAKE_TAG_ID (%s, %s, %d))", tagLevel, classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src," (tagId%d == MAKE_TAG_ID (%s, %s, %d))", tagLevel, classStr, formStr, tag->code); - } - } - else - { - - tagLevel = initialTagLevel + 2; - fprintf (src, " tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", tagLevel, totalLevel); - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src," if ((tagId%d != MAKE_TAG_ID (%s, %s, %s)) &&\n", tagLevel, classStr, Form2FormStr (PRIM), codeStr); - fprintf (src," (tagId%d != MAKE_TAG_ID (%s, %s, %s)))\n", tagLevel, classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src," if (tagId%d != MAKE_TAG_ID (%s, %s, %s))\n", tagLevel, classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src," if ((tagId%d != MAKE_TAG_ID (%s, %s, %d)) &&\n", tagLevel, classStr, Form2FormStr (PRIM), tag->code); - fprintf (src," (tagId%d != MAKE_TAG_ID (%s, %s, %d)))\n", tagLevel, classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src," if (tagId%d != MAKE_TAG_ID (%s, %s, %d))\n", tagLevel, classStr, formStr, tag->code); - } - - - fprintf (src," {\n"); - fprintf (src," Asn1Error (\"Unexpected Tag\\n\");\n"); - fprintf (src," longjmp (env, %d);\n",(*longJmpValG)--); - fprintf (src," }\n\n"); - fprintf (src," elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - } - } /* end tag list for */ - - if (stoleChoiceTags) - { - fprintf (src,"))\n"); - fprintf (src, " {\n"); - fprintf (src, " elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - } - } - - - MakeVarPtrRef (genDecCRulesG, td, parent, e->type, varName, tmpVarName); - - /* - * allocate mem for decoding result - */ - PrintElmtAllocCode (src, e->type, tmpVarName); - - PrintCBerElmtDecodeCode (src, td, parent, e->type, elmtLevel, totalLevel, tagLevel, varName, tmpVarName, stoleChoiceTags); - - /* - * must check for another EOC for ANYs - * Since the any decode routines - * decode their own first tag/len pair - */ - if ((builtinType == BASICTYPE_ANY) || - (builtinType == BASICTYPE_ANYDEFINEDBY)) - PrintEocDecoders (src, elmtLevel, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - /* - * must check for another EOC for tagged CHOICEs - * since the choice decoder routines do not check - * for an EOC on the choice's overall length - - * they are only passed the tag/len of the choice's - * component. - */ - else if ((builtinType == BASICTYPE_CHOICE) && (!stoleChoiceTags) && - ((tags != NULL) && !LIST_EMPTY (tags))) - PrintEocDecoders (src, elmtLevel, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - - else - PrintEocDecoders (src, elmtLevel-1, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - - - /* could check cons len vs decode len here */ - - if (!inTailOptElmts) - { - /* - * determine whether next elmt in Seq is start - * of tailing optionals - */ - AsnListNext (elmts); - inTailOptElmts = IsTailOptional (elmts); - AsnListPrev (elmts); - } - - /* - * print code for getting the next tag - */ - tmpTypeId = GetBuiltinType (e->type); - - if (e != last) - { - tmpElmt = (NamedType*)NEXT_LIST_ELMT (elmts); - tmpTypeId = GetBuiltinType (tmpElmt->type); - if (!inTailOptElmts) - { - if (((tmpTypeId == BASICTYPE_ANY) || - (tmpTypeId == BASICTYPE_ANYDEFINEDBY)) && - (CountTags (tmpElmt->type) == 0)) - { - if ((e->type->optional) || - ((tmpElmt->type->optional) && (tmpElmt != last))) - { - /* let this cause a compile error in the gen'd code */ - fprintf (src," \n"); - } - /* don't get a tag since ANY's decode their own */ - } - else - fprintf (src, " tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n", initialTagLevel+1, totalLevel); - } - else - { - fprintf (src, " if ((elmtLen%d != INDEFINITE_LEN) && (totalElmtsLen%d == elmtLen%d))\n", initialElmtLevel, totalLevel, initialElmtLevel); - fprintf (src, " seqDone = TRUE;\n"); - fprintf (src, " else\n"); - fprintf (src, " {\n"); - if (((tmpTypeId == BASICTYPE_ANY) || - (tmpTypeId == BASICTYPE_ANYDEFINEDBY)) && - (CountTags (tmpElmt->type) == 0)) - { - if ((e->type->optional) || - ((tmpElmt->type->optional) && (tmpElmt != last))) - { - /* let this cause a compile error in the gen'd code */ - fprintf (src," \n"); - - } - - /* peek ahead for first octet of eoc */ - fprintf (src," tagId%d = BufPeekByte (b);\n", initialTagLevel+1); - fprintf (src," if ((elmtLen%d == INDEFINITE_LEN) && (tagId%d == EOC_TAG_ID))\n", initialElmtLevel, initialTagLevel+1); - fprintf (src, " {\n"); - fprintf (src, " BDecEoc (b, &totalElmtsLen%d, env);\n", totalLevel); - fprintf (src, " seqDone = TRUE;\n"); - fprintf (src, " }\n"); - } - else - { - fprintf (src, " tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", initialTagLevel+1, totalLevel); - fprintf (src," if ((elmtLen%d == INDEFINITE_LEN) && (tagId%d == EOC_TAG_ID))\n", initialElmtLevel, initialTagLevel+1); - fprintf (src, " {\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, &totalElmtsLen%d, env)\n", totalLevel); - fprintf (src, " seqDone = TRUE;\n"); - fprintf (src, " }\n"); - } - fprintf (src, " }\n"); - } - } - else /* for last elmt only */ - { - fprintf (src," seqDone = TRUE;\n"); - fprintf (src," if (elmtLen%d == INDEFINITE_LEN)\n", initialElmtLevel); - fprintf (src," BDecEoc (b, &totalElmtsLen%d, env);\n", totalLevel); - fprintf (src," else if (totalElmtsLen%d != elmtLen%d)\n", totalLevel, initialElmtLevel); - fprintf (src," longjmp (env, %d);\n",(*longJmpValG)--); - } - - /* - * close (tag check/seqDone test) if block and - * print else clause to handle missing non-optional elmt - * errors - */ - tmpTypeId = GetBuiltinType (e->type); - if (((tmpTypeId == BASICTYPE_ANYDEFINEDBY) || - (tmpTypeId == BASICTYPE_ANY)) && - (CountTags (e->type) == 0)) - { - /* close if stmt block */ - fprintf (src," }\n"); - } - else if (!e->type->optional && (e->type->defaultVal == NULL)) - { - - fprintf (src, " }\n"); /* end of tag check if */ - fprintf (src, " else\n"); - fprintf (src, " longjmp (env, %d);\n", (*longJmpValG)--); - } - else - { - fprintf (src, " }\n"); /* end of tag check if */ - } - - fprintf (src,"\n\n"); - FreeTags (tags); - } - - - /* - * print code to make sure that truly finished with sequence - */ - - fprintf (src," if (!seqDone)\n"); - fprintf (src, " longjmp (env, %d);\n\n", (*longJmpValG)--); - -} /* PrintCBerSeqDecodeCode */ - - -/* - * Generates code for internally defined lists - * eg: - * TypeX = SET { foo INTEGER, bar SEQUENCE OF INTEGER } --> - * BerDecodeTypeX (b, len, v, bytesDecoded, env) - * { - * ... - * listLen1 = BerDecodeLen (b, &totalElmtsLen, env); - * retVal->bar = NewList(); - * for ( ; totalElmtsLen1 < listLen1 || listLen1== INDEFINITE_LEN;) - * { - * tagId1 = BerDecodeTag (b, &totalElmtsLen1, env); - * check for EOC - * elmtLen1 = BerDecodeLen (b, &totalElmtsLen1, env) - * tmpInt = Asn1Alloc (sizeof (int)); - * BerDecodeInteger (b, elmtLen1, tmpInt, &totalElmtsLen1, env); - * AppendList (retVal->bar, tmpInt); - * } - * totalElmtsLen += totalElmtsLen1; - * ... - * } - */ -static void -PrintCBerListDecoderCode PARAMS ((src, td, list, elmtLevel, totalLevel, tagLevel, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *list _AND_ - int elmtLevel _AND_ - int totalLevel _AND_ - int tagLevel _AND_ - char *varName) -{ - CTRI *ctri; - TagList *tags; - Tag *tag; - Tag *lastTag; - enum BasicTypeChoiceId builtinType; - char *classStr; - BER_FORM form; - char *formStr; - char *codeStr; - int mandatoryCount = 0; - int i; - char tmpVarName[MAX_VAR_REF]; - int stoleChoiceTags; - char *routineName; - int initialTagLevel; - int initialElmtLevel; - int taglessAny; - - initialTagLevel = tagLevel; - initialElmtLevel = elmtLevel; - - - routineName = td->cTypeDefInfo->decodeRoutineName; - ctri = list->basicType->a.setOf->cTypeRefInfo; - tags = GetTags (list->basicType->a.setOf, &stoleChoiceTags); - builtinType = GetBuiltinType (list->basicType->a.setOf); - - taglessAny = (((tags == NULL) || LIST_EMPTY (tags)) && - ((builtinType == BASICTYPE_ANY) || - (builtinType == BASICTYPE_ANYDEFINEDBY))); - - fprintf (src, " for (totalElmtsLen%d = 0; (totalElmtsLen%d < elmtLen%d) || (elmtLen%d == INDEFINITE_LEN);)\n", totalLevel, totalLevel, elmtLevel, elmtLevel); - fprintf (src, " {\n"); - fprintf (src," %s **tmpVar;\n", ctri->cTypeName); - - if (taglessAny) - { - fprintf (src, " tagId%d = BufPeekByte (b);\n\n", ++tagLevel); - fprintf (src, " if ((tagId%d == EOC_TAG_ID) && (elmtLen%d == INDEFINITE_LEN))\n", tagLevel, elmtLevel); - fprintf (src, " {\n"); - fprintf (src, " BDecEoc (b, &totalElmtsLen%d, env);\n", totalLevel); - fprintf (src, " break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/\n"); - fprintf (src, " }\n"); - } - else - { - fprintf (src, " tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", ++tagLevel, totalLevel); - fprintf (src, " if ((tagId%d == EOC_TAG_ID) && (elmtLen%d == INDEFINITE_LEN))\n", tagLevel, elmtLevel); - fprintf (src, " {\n"); - fprintf (src, " BDEC_2ND_EOC_OCTET (b, &totalElmtsLen%d, env)\n", totalLevel); - fprintf (src, " break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/\n"); - fprintf (src, " }\n"); - } - - - if ((tags == NULL) || LIST_EMPTY (tags)) - { - if (!taglessAny) - fprintf (src, "\n"); -/* - else - { - fprintf (src," if (tagId%d == MAKE_TAG_ID (?, ?, ?))",tagLevel); - fprintf (src," {\n"); - } -*/ - - } - else if (!stoleChoiceTags) /* choice decoder will check tag */ - { - tag = (Tag*)FIRST_LIST_ELMT (tags); - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src," if ((tagId%d == MAKE_TAG_ID (%s, %s, %s)) ||", tagLevel, classStr, Form2FormStr (PRIM), codeStr); - - fprintf (src," (tagId%d == MAKE_TAG_ID (%s, %s, %s))", tagLevel, classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src," if ((tagId%d == MAKE_TAG_ID (%s, %s, %s))", tagLevel, classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src," if ((tagId%d == MAKE_TAG_ID (%s, %s, %d)) ||\n", tagLevel, classStr, Form2FormStr (PRIM), tag->code); - fprintf (src," (tagId%d == MAKE_TAG_ID (%s, %s, %d))", tagLevel, classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src," if ((tagId%d == MAKE_TAG_ID (%s, %s, %d))", tagLevel, classStr, formStr, tag->code); - } - - fprintf (src,")\n"); - fprintf (src, " {\n"); - fprintf (src, " elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - - AsnListFirst (tags); - AsnListNext (tags); - FOR_REST_LIST_ELMT (tag, tags) - { - tagLevel = initialTagLevel+2; - fprintf (src, " tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n\n", tagLevel, totalLevel); - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src," if ((tagId%d != MAKE_TAG_ID (%s, %s, %s)) ||\n", tagLevel, classStr, Form2FormStr (PRIM), codeStr); - fprintf (src," (tagId%d != MAKE_TAG_ID (%s, %s, %s)))\n", tagLevel, classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src," if (tagId%d != MAKE_TAG_ID (%s, %s, %s))\n", tagLevel, classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src," if ((tagId%d != MAKE_TAG_ID (%s, %s, %d)) ||\n", tagLevel, classStr, Form2FormStr (PRIM), tag->code); - fprintf (src," (tagId%d != MAKE_TAG_ID (%s, %s, %d)))\n", tagLevel, classStr, Form2FormStr (CONS), tag->code); - - } - else - fprintf (src," if (tagId%d != MAKE_TAG_ID (%s, %s, %d))\n", tagLevel, classStr, formStr, tag->code); - } - - - fprintf (src," {\n"); - fprintf (src," Asn1Error (\"Unexpected Tag\\n\");\n"); - fprintf (src," longjmp (env, %d);\n", (*longJmpValG)--); - fprintf (src," }\n\n"); - fprintf (src," elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - } - } - if (stoleChoiceTags) - { - fprintf (src, " elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - } - - - - strcpy (tmpVarName, "(*tmpVar)"); - fprintf (src," tmpVar = (%s**) AsnListAppend (%s);\n", ctri->cTypeName, varName); - fprintf (src, " %s = (%s*) Asn1Alloc (sizeof (%s));\n", tmpVarName, ctri->cTypeName, ctri->cTypeName); - - fprintf (src," CheckAsn1Alloc (%s, env);\n", tmpVarName); - PrintCBerElmtDecodeCode (src, td, list, list->basicType->a.setOf, elmtLevel, totalLevel, tagLevel, varName, tmpVarName, stoleChoiceTags); - - /* - * must check for another EOC for ANYs - * Since the any decode routines - * decode their own first tag/len pair - */ - if ((builtinType == BASICTYPE_ANY) || - (builtinType == BASICTYPE_ANYDEFINEDBY)) - PrintEocDecoders (src, elmtLevel, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - /* - * must check for another EOC for tagged CHOICEs - * since the choice decoder routines do not check - * for an EOC on the choice's overall length - - * they are only passed the tag/len of the choice's - * component. - */ - else if ((builtinType == BASICTYPE_CHOICE) && (!stoleChoiceTags) && - ((tags != NULL) && !LIST_EMPTY (tags))) - PrintEocDecoders (src, elmtLevel, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - - else - PrintEocDecoders (src, elmtLevel-1, initialElmtLevel, itemLenVarNameG, totalLevel, decodedLenVarNameG); - - - if ((!stoleChoiceTags) && (!taglessAny)) - { - fprintf (src, " } /* end of tag check if */\n"); - fprintf (src, " else /* wrong tag */\n"); - fprintf (src," {\n"); - fprintf (src," Asn1Error (\"Unexpected Tag\\n\");\n"); - fprintf (src," longjmp (env, %d);\n", (*longJmpValG)--); - fprintf (src," }\n"); - } - fprintf (src, " } /* end of for */\n\n"); - - FreeTags (tags); - -} /* PrintCBerListDecodeCode */ - - - -/* - * t is the choice type pointer - */ -static void -PrintCBerChoiceDecodeCode PARAMS ((src, td, t, elmtLevel, totalLevel, tagLevel, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t _AND_ - int elmtLevel _AND_ - int totalLevel _AND_ - int tagLevel _AND_ - char *varName) -{ - NamedType *e; - CTRI *ctri; - TagList *tags; - Tag *tag; - Tag *lastTag; - enum BasicTypeChoiceId builtinType; - char *classStr; - BER_FORM form; - char *formStr; - char *codeStr; - int mandatoryCount = 0; - int i; - char tmpVarName[MAX_VAR_REF]; - char choiceIdVarName[MAX_VAR_REF]; - CTRI *parentCtri; - int stoleChoiceTags; - void *tmp; - int initialTagLevel; - int initialElmtLevel; - - initialTagLevel = tagLevel; - initialElmtLevel = elmtLevel; - - parentCtri = t->cTypeRefInfo; - - - fprintf (src, " switch (tagId%d)\n", tagLevel); - fprintf (src, " {\n"); - - - FOR_EACH_LIST_ELMT (e, t->basicType->a.choice) - { - /* hack ! remember curr loc cause called routine hacks it */ - tmp = (void*)CURR_LIST_NODE (t->basicType->a.choice); - - tagLevel = initialTagLevel; - elmtLevel = initialElmtLevel; - - if ((e->type == NULL) || (e->type->cTypeRefInfo == NULL)) - { - fprintf (src, "< ERROR - no c type information - prob unsuported type>\n"); - continue; - } - - ctri = e->type->cTypeRefInfo; - - tags = GetTags (e->type, &stoleChoiceTags); - builtinType = GetBuiltinType (e->type); - - if ((tags == NULL) || LIST_EMPTY (tags)) - { - if ((builtinType != BASICTYPE_ANY) && - (builtinType != BASICTYPE_ANYDEFINEDBY)) - fprintf (src, "\n"); - else - { - fprintf (src, " /* You must hand code ANY type refs */\n"); - fprintf (src," case MAKE_TAG_ID (?, ?, ?):\n"); - - } - - } - else - { - tag = (Tag*)FIRST_LIST_ELMT (tags); - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, formStr, tag->code); - } - - - AsnListFirst (tags); - AsnListNext (tags); /* set curr ptr to 2nd elmt */ - FOR_REST_LIST_ELMT (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - codeStr = Code2UnivCodeStr (tag->code); - formStr = Form2FormStr (tag->form); - - - if (stoleChoiceTags) - { - if (tag->tclass == UNIV) - { - if (tag->form == ANY_FORM) - { - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (PRIM), codeStr); - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, Form2FormStr (CONS), codeStr); - } - else - fprintf (src," case MAKE_TAG_ID (%s, %s, %s):\n", classStr, formStr, codeStr); - } - else - { - if (tag->form == ANY_FORM) - { - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (PRIM), tag->code); - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, Form2FormStr (CONS), tag->code); - } - else - fprintf (src," case MAKE_TAG_ID (%s, %s, %d):\n", classStr, formStr, tag->code); - } - } - else - { - tagLevel = initialTagLevel +1; - if (tag->form == ANY_FORM) - { - fprintf (src," tagId%d = BDecTag (b, &totalElmtsLen%d, env);\n", tagLevel, totalLevel); - if (tag->tclass == UNIV) - { - fprintf (src,"if ((tagId%d != MAKE_TAG_ID (%s, %s, %s)) &&\n", tagLevel, classStr, Form2FormStr (PRIM), codeStr); - fprintf (src," (tagId%d != MAKE_TAG_ID (%s, %s, %s)))\n", tagLevel, classStr, Form2FormStr (CONS), codeStr); - } - else - { - fprintf (src,"if ((tagId%d != MAKE_TAG_ID (%s, %s, %d)) &&\n", tagLevel, classStr, Form2FormStr (PRIM), tag->code); - fprintf (src," (tagId%d != MAKE_TAG_ID (%s, %s, %d)))\n", tagLevel, classStr, Form2FormStr (CONS), tag->code); - } - - } - else - { - if (tag->tclass == UNIV) - fprintf (src,"if (BDecTag (b, &totalElmtsLen%d, env) != MAKE_TAG_ID (%s, %s, %s))\n", totalLevel, classStr, formStr, codeStr); - else - fprintf (src,"if (BDecTag (b, &totalElmtsLen%d, env) != MAKE_TAG_ID (%s, %s, %d))\n", totalLevel, classStr, formStr, tag->code); - } - - fprintf (src," {\n"); - fprintf (src," Asn1Error (\"Unexpected Tag\\n\");\n"); - fprintf (src," longjmp (env, %d);\n", (*longJmpValG)--); - fprintf (src," }\n\n"); - fprintf (src," elmtLen%d = BDecLen (b, &totalElmtsLen%d, env);\n", ++elmtLevel, totalLevel); - } - } - } - - - MakeChoiceIdValueRef (genDecCRulesG, td, t, e->type, varName, choiceIdVarName); - fprintf (src, " %s = %s;\n", choiceIdVarName, ctri->choiceIdSymbol); - - MakeVarPtrRef (genDecCRulesG, td, t, e->type, varName, tmpVarName); - - PrintElmtAllocCode (src, e->type, tmpVarName); - - PrintCBerElmtDecodeCode (src, td, t, e->type, elmtLevel, totalLevel, tagLevel, varName, tmpVarName, stoleChoiceTags); - - /* - * this is slightly diff from set/seq since - * no loop checking for eoc (set) and no next elmt (seq) - * so should check elmtLen0 for EOC if nec - * (therefore (initialElmtLevel-1) instead of initialElmtLevel) - * - * must check for another EOC for ANYs - * Since the any decode routines - * decode their own first tag/len pair - */ - if ((builtinType == BASICTYPE_ANY) || - (builtinType == BASICTYPE_ANYDEFINEDBY)) - PrintEocDecoders (src, elmtLevel, initialElmtLevel-1, itemLenVarNameG, totalLevel, decodedLenVarNameG); - /* - * must check for another EOC for tagged CHOICEs - * since the choice decoder routines do not check - * for an EOC on the choice's overall length - - * they are only passed the tag/len of the choice's - * component. - */ - else if ((builtinType == BASICTYPE_CHOICE) && (!stoleChoiceTags) && - ((tags != NULL) && !LIST_EMPTY (tags))) - PrintEocDecoders (src, elmtLevel, initialElmtLevel-1, itemLenVarNameG, totalLevel, decodedLenVarNameG); - - else - PrintEocDecoders (src, elmtLevel-1, initialElmtLevel-1, itemLenVarNameG, totalLevel, decodedLenVarNameG); - - - FreeTags (tags); - - fprintf (src," break;\n\n"); - - /* reset curr list node to value remember at beg of loop */ - SET_CURR_LIST_NODE (t->basicType->a.choice, tmp); - } /* end for */ - - fprintf (src," default:\n"); - fprintf (src," Asn1Error (\"ERROR - unexpected tag in CHOICE\\n\");\n"); - fprintf (src," longjmp (env, %d);\n",(*longJmpValG)--); - fprintf (src," break;\n"); - - fprintf (src, " } /* end switch */\n"); - -} /* PrintCBerChoiceDecodeCode */ - - - -static void -PrintCLenDecodingCode PARAMS ((f), - FILE *f) -{ - fprintf (f, " itemLen += BDecDefLen (b, itemLen);"); -} /* PrintCLenDecodingCode */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-dec.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-dec.h deleted file mode 100644 index a1d0a780..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-dec.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-dec.h - routines for printing C decoders from type trees - * - * Mike Sample - * 91/09/26 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-dec.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-dec.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:42 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:41:03 rj - * file name has been shortened for redundant part: c-gen/gen-c-dec -> c-gen/gen-dec. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:10 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:22 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -void PrintCBerDecoder PROTO ((FILE *src, FILE *hdr, CRules *r, Module *m, TypeDef *td, long int *longJmpVal)); - - -void PrintCBerContentDecoder PROTO ((FILE *src, FILE *hdr, CRules *r, Module *m, TypeDef *td, long int *longJmpVal)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.c deleted file mode 100644 index d6e6dd23..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.c +++ /dev/null @@ -1,852 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-enc.c - routines for printing c encoders from type trees - * - * Mike Sample - * 91/09/26 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-enc.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-enc.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:42 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:42:24 rj - * file name has been shortened for redundant part: c-gen/gen-c-enc -> c-gen/gen-enc. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:23:10 rj - * snacc_config.h and other superfluous .h files removed. - * - * Revision 1.1 1994/08/28 09:48:24 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "define.h" -#include "rules.h" -#include "type-info.h" -#include "str-util.h" -#include "util.h" -#include "tag-util.h" -#include "snacc-util.h" -#include "gen-enc.h" - - - -static int moduleImplicitTagsG; -static CRules *genEncCRulesG; -extern char *valueArgNameG; - -char *encodedLenVarNameG = "totalLen"; -char *itemLenNameG = "itemLen"; -char *listComponentNameG = "component"; -char *listLenNameG = "listLen"; -char *returnTypeG = "AsnLen"; -extern char *bufTypeNameG; -extern char *lenTypeNameG; -extern char *tagTypeNameG; -extern char *envTypeNameG; - - -/* non-exported prototypes */ - -static void PrintCBerEncoderPrototype PROTO ((FILE *hdr, TypeDef *td)); -static void PrintCBerEncoderDeclaration PROTO ((FILE *src, TypeDef *td)); -static void PrintCBerEncoderDefine PROTO ((FILE *src, TypeDef *td)); - -static void PrintCBerEncoderLocals PROTO ((FILE *src, TypeDef *td)); - -static void PrintCBerElmtsEncodeCode PROTO ((FILE *src, TypeDef *td, Type *parent, NamedTypeList *e, int level, char *varName)); -static void PrintCBerElmtEncodeCode PROTO ((FILE *src, TypeDef *td, Type *parent, NamedType *e, int level, char *varName)); - -static void PrintCBerListEncoderCode PROTO ((FILE *src, TypeDef *td, Type *t, int level, char *varName)); -static void PrintCBerChoiceEncodeCode PROTO ((FILE *src, TypeDef *td, Type *t, int level, char *varName)); - -static void PrintCTagAndLenEncodingCode PROTO ((FILE *src, TypeDef *td, Type *t)); - -static void PrintEocEncoders PROTO ((FILE *src, TypeDef *td, Type *t)); - -static void PrintCLenEncodingCode PROTO ((FILE *f, int isCons, int isShort)); - -static void PrintCTagAndLenList PROTO ((FILE *src, Type *t,TagList *tg)); - - - - -void -PrintCBerEncoder PARAMS ((src, hdr, r, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td) -{ - enum BasicTypeChoiceId typeId; - int elmtLevel; - CTDI *ctdi; - TagList *tags; - Tag *tag; - char *formStr; - char *classStr; - int tagLen; - int stoleChoiceTags; - - - ctdi = td->cTypeDefInfo; - if (!ctdi->genEncodeRoutine) - return; - - /* - * if is type that refs another pdu type or lib type - * without generating a new type via tagging or named elmts - * print define to the hdr file - * (a type is a pdu by default if it is ref'd by an ANY) - */ - if (!IsNewType (td->type) && - (!IsTypeRef (td->type) || - (IsTypeRef (td->type) && - (td->type->basicType->a.localTypeRef->link->cTypeDefInfo->isPdu || - ((td->type->basicType->a.localTypeRef->link->anyRefs != NULL) && - !LIST_EMPTY (td->type->basicType->a.localTypeRef->link->anyRefs)))))) - { - fprintf(hdr,"#define B%s B%s\n", td->cTypeDefInfo->encodeRoutineName, td->type->cTypeRefInfo->encodeRoutineName); -/* - fprintf(hdr,"#define B%s(b, v, bytesDecoded, env) B%s(b, v, bytesDecoded, env)\n", td->cTypeDefInfo->encodeRoutineName, td->type->cTypeRefInfo->encodeRoutineName); - */ - return; - } - - typeId = GetBuiltinType (td->type); - - /* print proto to hdr file */ - fprintf (hdr,"%s B%s PROTO ((%s b, %s *v));\n\n", lenTypeNameG, ctdi->encodeRoutineName, bufTypeNameG, ctdi->cTypeName); - - /* print routine to src file */ - fprintf (src,"%s B%s PARAMS ((b, v),\n", lenTypeNameG, ctdi->encodeRoutineName); - fprintf (src,"%s b _AND_\n",bufTypeNameG); - fprintf (src,"%s *v)\n",ctdi->cTypeName); - fprintf (src,"{\n"); - fprintf (src," %s l;\n", lenTypeNameG); - - PrintEocEncoders (src, td, td->type); - - fprintf (src," l = B%sContent (b, v);\n", ctdi->encodeRoutineName); - - /* encode each tag/len pair if any */ - tags = GetTags (td->type, &stoleChoiceTags); - if (! stoleChoiceTags) - { - FOR_EACH_LIST_ELMT_RVS (tag, tags) - { - classStr = Class2ClassStr (tag->tclass); - - if (tag->form == ANY_FORM) - tag->form = PRIM; - formStr = Form2FormStr (tag->form); - tagLen = TagByteLen (tag->code); - - - if (tag->form == CONS) - fprintf (src," l += BEncConsLen (b, l);\n"); - else - fprintf (src," l += BEncDefLen (b, l);\n"); - - if (tag->tclass == UNIV) - fprintf (src," l += BEncTag%d (b, %s, %s, %s);\n", tagLen, classStr, formStr, Code2UnivCodeStr (tag->code)); - else - fprintf (src," l += BEncTag%d (b, %s, %s, %d);\n", tagLen, classStr, formStr, tag->code); - } - } - fprintf (src," return l;\n"); - fprintf (src,"} /* B%s */\n\n", ctdi->encodeRoutineName); - - FreeTags (tags); -} /* PrintCBerEncoder */ - -void -PrintCBerContentEncoder PARAMS ((src, hdr, r, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td) -{ - NamedType *e; - CTDI *ctdi; - CTypeId rhsTypeId; /* cTypeId of the type that defined this typedef */ - - genEncCRulesG = r; - - ctdi = td->cTypeDefInfo; - if (!ctdi->genEncodeRoutine) - return; - - rhsTypeId = td->type->cTypeRefInfo->cTypeId; - switch (rhsTypeId) - { - case C_ANY: - fprintf (hdr, "/* ANY - Fix Me! */\n"); - - /* - * Note - ANY's don't have the 'Content' suffix cause they - * encode their tags and lengths - */ - fprintf(hdr, "#define B%s B%s\n", td->cTypeDefInfo->encodeRoutineName, td->type->cTypeRefInfo->encodeRoutineName); - -/* - fprintf(hdr, "#define B%s( b, v) ",td->cTypeDefInfo->encodeRoutineName); - fprintf (hdr, "B%s (b, v)", td->type->cTypeRefInfo->encodeRoutineName); -*/ - - - break; - - case C_LIB: - case C_TYPEREF: - PrintCBerEncoderDefine (hdr, td); - fprintf (hdr,"\n\n"); - break; - - case C_CHOICE: - PrintCBerEncoderPrototype (hdr, td); - PrintCBerEncoderDeclaration (src, td); - fprintf (src,"{\n"); - PrintCBerEncoderLocals (src, td); - fprintf (src,"\n\n"); - PrintCBerChoiceEncodeCode (src, td, td->type, FIRST_LEVEL, valueArgNameG); - fprintf (src," return %s;\n\n", encodedLenVarNameG); - fprintf (src,"} /* B%sContent */",td->cTypeDefInfo->encodeRoutineName); - fprintf (hdr,"\n\n"); - fprintf (src,"\n\n"); - break; - - case C_STRUCT: - PrintCBerEncoderPrototype (hdr, td); - PrintCBerEncoderDeclaration (src, td); - fprintf (src,"{\n"); - PrintCBerEncoderLocals (src, td); - fprintf (src,"\n\n"); - PrintCBerElmtsEncodeCode (src, td, td->type, td->type->basicType->a.set, FIRST_LEVEL, valueArgNameG); - fprintf (src," return %s;\n\n", encodedLenVarNameG); - fprintf (src,"} /* B%sContent */",td->cTypeDefInfo->encodeRoutineName); - fprintf (hdr,"\n\n"); - fprintf (src,"\n\n"); - break; - - - case C_LIST: - PrintCBerEncoderPrototype (hdr, td); - fprintf (hdr,"\n\n"); - - PrintCBerEncoderDeclaration (src, td); - fprintf (src,"{\n"); - PrintCBerEncoderLocals (src, td); - fprintf (src,"\n\n"); - PrintCBerListEncoderCode (src, td, td->type, FIRST_LEVEL, valueArgNameG); - fprintf (src," return %s;\n\n", listLenNameG); - fprintf (src,"} /* B%sContent */", td->cTypeDefInfo->encodeRoutineName); - fprintf (src,"\n\n"); - break; - - case C_NO_TYPE: -/* fprintf (src," sorry, unsupported type \n\n"); */ - break; - - default: - fprintf (stderr,"PrintCBerEncoder: ERROR - unknown c type id\n"); - break; - } - -} /* PrintCBerContentEncoder */ - - - -/* - * Prints prototype for encode routine in hdr file - */ -static void -PrintCBerEncoderPrototype PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - CTDI *ctdi; - - ctdi = td->cTypeDefInfo; - fprintf (hdr,"%s B%sContent PROTO ((%s b, %s *v));", returnTypeG, ctdi->encodeRoutineName, bufTypeNameG, ctdi->cTypeName); - -} /* PrintCBerEncoderPrototype */ - - - -/* - * Prints declarations of encode routine for the given type def - */ -static void -PrintCBerEncoderDeclaration PARAMS ((src, td), - FILE *src _AND_ - TypeDef *td) -{ - CTDI *ctdi; - - ctdi = td->cTypeDefInfo; - fprintf (src,"%s\nB%sContent PARAMS ((b, v),\n%s b _AND_\n%s *v)\n", returnTypeG, ctdi->encodeRoutineName, bufTypeNameG, ctdi->cTypeName); - -} /* PrintCBerEncoderDeclaration */ - - - - -/* - * makes a define for type refs or primitive type renaming - * EG: - * TypeX ::= INTEGER --> #define BerEncodeTypeX(b,v) BerEncodeInteger(b,v) - * TypeX ::= TypeY --> #define BerEncodeTypeX(b,v) BerEncodeTypeY(b,v) - */ -static void -PrintCBerEncoderDefine PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - fprintf(hdr, "#define B%sContent B%sContent", td->cTypeDefInfo->encodeRoutineName, td->type->cTypeRefInfo->encodeRoutineName); - -/* - fprintf(hdr, "#define B%sContent( b, v) ",td->cTypeDefInfo->encodeRoutineName); - fprintf (hdr, "B%sContent (b, v)", td->type->cTypeRefInfo->encodeRoutineName); -*/ -} /* PrintCBerEncoderDefine */ - - - - -static void -PrintCBerEncoderLocals PARAMS ((src, td), - FILE *src _AND_ - TypeDef *td) -{ - fprintf (src, " AsnLen %s = 0;\n", encodedLenVarNameG); - fprintf (src, " AsnLen %s;\n", itemLenNameG); - fprintf (src, " AsnLen %s;\n", listLenNameG); - fprintf (src, " void *%s;", listComponentNameG); - -} /* PrintCBerEncoderLocals */ - - - -/* - * runs through elmts backwards and prints - * encoding code for each one - */ -static void -PrintCBerElmtsEncodeCode PARAMS ((src, td, parent, elmts, level, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts _AND_ - int level _AND_ - char *varName) -{ - NamedType *e; - - if (elmts == NULL) - { - fprintf (src,"/* ERROR? - expected elmts for this type*/\n"); - return; - } - - /* - * remember! encoding "backwards" so recursively traverse - * list backwards - */ - FOR_EACH_LIST_ELMT_RVS (e, elmts) - { - PrintCBerElmtEncodeCode (src, td, parent, e, level, varName); - } - -} /* PrintCBerElmtsEncodeCode */ - - - -/* - * Prints code for encoding the elmts of a SEQ or SET - */ -static void -PrintCBerElmtEncodeCode PARAMS ((src, td, parent, e, level, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedType *e _AND_ - int level _AND_ - char *varName) -{ - CTRI *ctri; - char elmtVarRef[MAX_VAR_REF]; - char idVarRef[MAX_VAR_REF]; - enum BasicTypeChoiceId tmpTypeId; - Type *tmpType; - NamedType *idNamedType; - - if ((e->type == NULL) || (e->type->cTypeRefInfo == NULL)) - return; - - ctri = e->type->cTypeRefInfo; - - /* check if meant to be encoded */ - if (!ctri->isEncDec) - return; - - - MakeVarPtrRef (genEncCRulesG, td, parent, e->type, varName, elmtVarRef); - - if (e->type->optional || (e->type->defaultVal != NULL)) - fprintf (src, " if (%s (%s))\n {\n", ctri->optTestRoutineName, elmtVarRef); - - PrintEocEncoders (src, td, e->type); - - switch (ctri->cTypeId) - { - case C_ANYDEFINEDBY: - - /* get type of 'defining' field (int/enum/oid)*/ - idNamedType = e->type->basicType->a.anyDefinedBy->link; - tmpTypeId = GetBuiltinType (idNamedType->type); - - if (tmpTypeId == BASICTYPE_OID) - { - MakeVarPtrRef (genEncCRulesG, td, parent, idNamedType->type, varName, idVarRef); - fprintf (src, " SetAnyTypeByOid (%s, %s);\n", elmtVarRef, idVarRef); - } - else - { - /* want to ref int by value not ptr */ - MakeVarValueRef (genEncCRulesG, td, parent, idNamedType->type, varName, idVarRef); - fprintf (src, " SetAnyTypeByInt (%s, %s);\n", elmtVarRef, idVarRef); - } - - /* ANY's enc's do tag and len so zap the Content suffix */ - fprintf (src, " %s = B%s (b, %s);\n", itemLenNameG, ctri->encodeRoutineName, elmtVarRef); - break; - - case C_TYPEREF: - tmpType = GetType (e->type); - - /* NOTE: ANY DEFINED BY must be directly in the parent (not ref)*/ - if (tmpType->cTypeRefInfo->cTypeId != C_ANY) - { - fprintf (src, " %s = B%sContent (b, %s);\n", itemLenNameG, ctri->encodeRoutineName, elmtVarRef); - break; - } - else /* fall through */ - - case C_ANY: - /* ANY's enc's do tag and len so zap the Content suffix */ - fprintf (src," /* ANY - Fix Me! */\n"); - fprintf (src, " SetAnyTypeBy???(%s, ???);\n", elmtVarRef); - fprintf (src, " %s = B%s (b, %s);\n", itemLenNameG, ctri->encodeRoutineName, elmtVarRef); - break; - - - case C_LIB: - fprintf (src, " %s = B%sContent (b, %s);\n", itemLenNameG, ctri->encodeRoutineName, elmtVarRef); - break; - - case C_CHOICE: - PrintCBerChoiceEncodeCode (src, td, e->type, level+1, elmtVarRef); - break; - - case C_STRUCT: - PrintCBerElmtsEncodeCode (src, td, e->type, e->type->basicType->a.set, level+1, elmtVarRef); - break; - - case C_LIST: - PrintCBerListEncoderCode (src, td, e->type, level+1, elmtVarRef); - fprintf (src, " %s = %s;\n", itemLenNameG, listLenNameG); - fprintf (src,"\n\n"); - break; - - case C_NO_TYPE: - break; - - default: - fprintf (stderr,"PrintCBerElmtEncodeCode: ERROR - unknown c type id\n"); - break; - } - - if (ctri->cTypeId != C_ANY) /* ANY's do their own tag/lens */ - { - PrintCTagAndLenEncodingCode (src, td, e->type); - fprintf (src,"\n %s += %s;\n", encodedLenVarNameG, itemLenNameG); - } - - if (e->type->optional || (e->type->defaultVal != NULL)) - fprintf (src, " }\n"); - - fprintf (src,"\n"); - -} /* PrintCBerElmtEncodeCode */ - - - - -/* - * Generates code for internally defined lists - * eg: - * TypeX = SET { foo INTEGER, bar SEQUENCE OF INTEGER } --> - * BerEncodeTypeX (b, v) - * { - * ... - * listLen = 0; - * FOR_EACH_LIST_ELMT (component, v->bar) - * { - * itemLen = BerEncodeInteger (b, (int*) component); - * itemLen+= EncodeLen (b, itemLen) - * itemLen += ENCODE_TAG (b, INTEGER_TAG); - * listLen += itemLen; - * } - * ... - * } - */ -static void -PrintCBerListEncoderCode PARAMS ((src, td, t, level, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t _AND_ - int level _AND_ - char *varName) -{ - CTRI *ctri; - char *elmtVarRef = "component"; - Type *tmpType; - enum BasicTypeChoiceId tmpTypeId; - TypeDef *idNamedType; - - - ctri = t->basicType->a.setOf->cTypeRefInfo; - - if (ctri == NULL) - return; - - fprintf (src, " listLen = 0;\n"); - fprintf (src, " FOR_EACH_LIST_ELMT_RVS (component, %s)\n", varName); - fprintf (src, " {\n"); - - PrintEocEncoders (src, td, t->basicType->a.setOf); - - /* - * need extra case here for SET OF typedef not just SET OF typeref - */ - switch (ctri->cTypeId) - { - - case C_TYPEREF: - tmpType = GetType (t->basicType->a.setOf); - - /* NOTE: ANY DEFINED BY must be directly in the parent (not ref)*/ - if (tmpType->cTypeRefInfo->cTypeId != C_ANY) - { - fprintf (src, " %s = B%sContent (b, %s);\n", itemLenNameG, ctri->encodeRoutineName, elmtVarRef); - break; - } - else /* fall through */ - - case C_ANY: - /* ANY's enc's do tag and len so zap the Content suffix */ - fprintf (src," /* ANY - Fix Me! */\n"); - fprintf (src, " SetAnyTypeBy???(%s, ???);\n", elmtVarRef); - fprintf (src, " %s = B%s (b, %s);\n", itemLenNameG, ctri->encodeRoutineName, elmtVarRef); - break; - - - - default: - fprintf (src, " %s = B%sContent (b, (%s*) %s);\n", itemLenNameG, ctri->encodeRoutineName, ctri->cTypeName, elmtVarRef); - break; - - } - - PrintCTagAndLenEncodingCode (src, td, t->basicType->a.setOf); - fprintf (src,"\n"); - fprintf (src, " %s += %s;\n", listLenNameG, itemLenNameG); - fprintf (src, " }\n"); - -} /* PrintCBerListEncoderCode */ - - - -static void -PrintCBerChoiceEncodeCode PARAMS ((src, td, t, level, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t _AND_ - int level _AND_ - char *varName) -{ - NamedType *e; - CTRI *ctri; - void *tmp; - - ctri = t->cTypeRefInfo; - - fprintf (src," switch (%s->%s)\n {\n", varName, ctri->choiceIdEnumFieldName); - - FOR_EACH_LIST_ELMT (e, t->basicType->a.choice) - { - tmp = (void*)CURR_LIST_NODE (t->basicType->a.choice); - - if (e->type == NULL) - continue; - - ctri = e->type->cTypeRefInfo; - - if (ctri != NULL) - fprintf (src, " case %s:\n", ctri->choiceIdSymbol); - else - fprintf (src, " case ????:\n"); - - - - PrintCBerElmtEncodeCode (src, td, t, e, level+1, varName); - fprintf (src," break;\n\n"); - - SET_CURR_LIST_NODE (t->basicType->a.choice, tmp); - } - - fprintf (src, " }\n"); -} /* PrintCBerChoiceEncodeCode */ - - - -/* - * prints DecodeBerEocIfNec (b) for each constructed len - * assoc with given type - */ -static void -PrintEocEncoders PARAMS ((src, td, t), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t) -{ - TagList *tl; - Tag *tag; - int consTagCount; - int stoleChoiceTags; - - /* - * get all the tags on this type - */ - tl = (TagList*) GetTags (t, &stoleChoiceTags); - - /* - * leave choice elmt tag enc to encoding routine - */ - - if (!stoleChoiceTags) - { - FOR_EACH_LIST_ELMT (tag, tl) - { - if (tag->form == CONS) - fprintf (src," BEncEocIfNec (b);\n"); - } - } -/* - consTagCount = 0; - if (!stoleChoiceTags) - { - FOR_EACH_LIST_ELMT (tag, tl) - consTagCount++; - } - - if (IsPrimitiveByDefOrRef (t)) - consTagCount--; - - for (; consTagCount > 0; consTagCount--) - fprintf (src," BEncEocIfNec (b);\n"); - -*/ - - FreeTags (tl); - -} /* PrintEocEncoders */ - - -/* - * Recursively walks throught type refs printing lower lvl tags - * first (since encoding is done backwards). - * - */ -static void -PrintCTagAndLenEncodingCode PARAMS ((src, td, t), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t) -{ - TagList *tl; - int stoleChoiceTags; - - /* - * get all the tags on this type - */ - tl = (TagList*) GetTags (t, &stoleChoiceTags); - - /* - * leave choice elmt tag enc to encoding routine - */ - if (!stoleChoiceTags) - PrintCTagAndLenList (src, t, tl); - - FreeTags (tl); - -} /* PrintCTagAndLenEncodingCode */ - - - -/* - * prints last tag's encoding code first - */ -static void -PrintCTagAndLenList PARAMS ((src, t, tagList), - FILE *src _AND_ - Type *t _AND_ - TagList *tagList) -{ - char *classStr; - char *formStr; - char *codeStr; - Tag *tg; - Tag *last; - int tagLen; - enum BasicTypeChoiceId typesType; - int isShort; - - if ((tagList == NULL) || LIST_EMPTY (tagList)) - return; - - /* - * efficiency hack - use simple length (1 byte) - * encoded for type (almost) guaranteed to have - * encoded lengths of 0 <= len <= 127 - */ - typesType = GetBuiltinType (t); - if ((typesType == BASICTYPE_BOOLEAN) || - (typesType == BASICTYPE_INTEGER) || - (typesType == BASICTYPE_NULL) || - (typesType == BASICTYPE_REAL) || - (typesType == BASICTYPE_ENUMERATED)) - isShort = 1; - else - isShort = 0; - - /* - * since encoding backward encode tags backwards - */ - last = (Tag*)LAST_LIST_ELMT (tagList); - FOR_EACH_LIST_ELMT_RVS (tg, tagList) - { - classStr = Class2ClassStr (tg->tclass); - - if (tg->form == CONS) - { - formStr = Form2FormStr (CONS); - PrintCLenEncodingCode (src, TRUE, isShort); - } - else /* PRIM or ANY_FORM */ - { - formStr = Form2FormStr (PRIM); - PrintCLenEncodingCode (src, FALSE, isShort); - } - -/* GetTags sets the form bit correctly now - if (IsPrimitiveByDefOrRef (t) && (tg == last)) - { - formStr = Form2FormStr (PRIM); - PrintCLenEncodingCode (src, FALSE, isShort); - } - else - { - formStr = Form2FormStr (CONS); - PrintCLenEncodingCode (src, TRUE, isShort); - } - */ - - fprintf (src,"\n"); - - if (tg->code < 31) - tagLen = 1; - else if (tg->code < 128) - tagLen = 2; - else if (tg->code < 16384) - tagLen = 3; - else if (tg->code < 2097152) - tagLen = 4; - else - tagLen = 5; - - fprintf (src," %s += BEncTag%d (b, %s, %s, %d);\n", itemLenNameG, tagLen, classStr, formStr, tg->code); - } - -} /* PrintCTagAndLenList */ - -/* - * prints length encoding code. Primitives always use - * definite length and constructors get "ConsLen" - * which can be configured at compile to to be indefinite - * or definite. Primitives can also be "short" (isShort is true) - * in which case a fast macro is used to write the length. - * Types for which isShort apply are: boolean, null and - * (almost always) integer and reals - */ -static void -PrintCLenEncodingCode PARAMS ((f, isCons, isShort), - FILE *f _AND_ - int isCons _AND_ - int isShort) -{ - /* fprintf (f, " BER_ENCODE_DEF_LEN (b, itemLen, itemLen);"); */ - if (isCons) - fprintf (f, " itemLen += BEncConsLen (b, itemLen);"); - else - { - if (isShort) - { - fprintf (f, " BEncDefLenTo127 (b, itemLen);\n"); - fprintf (f, " itemLen++;"); - } - else - fprintf (f, " itemLen += BEncDefLen (b, itemLen);"); - } -} /* PrintCLenEncodingCode */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.h deleted file mode 100644 index de684ac1..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-enc.h - routines for printing C encoders from type trees - * - * Mike Sample - * 91/09/26 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-enc.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-enc.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:42 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:42:25 rj - * file name has been shortened for redundant part: c-gen/gen-c-enc -> c-gen/gen-enc. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:11 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:25 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - - -void PrintCBerEncoder PROTO ((FILE *src, FILE *hdr, CRules *r, Module *m, TypeDef *td)); - -void PrintCBerContentEncoder PROTO ((FILE *src, FILE *hdr, CRules *r, Module *m, TypeDef *td)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-free.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-free.c deleted file mode 100644 index 33a36bb1..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-free.c +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-free.c - routines for printing C hierachical free routines - * - * Mike Sample - * 92/04 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-free.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-free.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:42 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:42:47 rj - * file name has been shortened for redundant part: c-gen/gen-c-free -> c-gen/gen-free. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:23:29 rj - * snacc_config.h and other superfluous .h files removed. - * - * Revision 1.1 1994/08/28 09:48:26 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "define.h" -#include "rules.h" -#include "type-info.h" -#include "str-util.h" -#include "util.h" -#include "gen-free.h" - -static char *returnTypeG = "void"; -static char *valueArgNameG = "v"; -static CRules *genFreeCRulesG; - -/* non-exported prototypes */ - -static void PrintCFreePrototype PROTO ((FILE *hdr, TypeDef *td)); -static void PrintCFreeDeclaration PROTO ((FILE *src, TypeDef *td)); -static void PrintCFreeDefine PROTO ((FILE *hdr, TypeDef *td)); -static void PrintCFreeLocals PROTO ((FILE *src,TypeDef *td)); -static void PrintCFreeElmts PROTO ((FILE *src, TypeDef *td, Type *parent, NamedTypeList *elmts, char *varName)); -static void PrintCElmtFree PROTO ((FILE *src, TypeDef *td, Type *parent, Type *e, char *varName)); -static void PrintCFreeListElmts PROTO ((FILE *src, TypeDef *td, Type *t, char *varName)); -static void PrintCFreeListRoutineBody PROTO ((FILE *src, TypeDef *td, Type *t,char *varName)); -static void PrintCFreeListDefine PROTO ((FILE *hdr,TypeDef *td)); -static void PrintCFreeChoiceElmts PROTO ((FILE *src, TypeDef *td, Type *t, char *varName)); - - - -void -PrintCFree PARAMS ((src, hdr, r, mods, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - TypeDef *td) -{ - NamedType *e; - CTDI *ctdi; - CTypeId rhsTypeId; /* cTypeId of the type that defined this typedef */ - - genFreeCRulesG = r; - - ctdi = td->cTypeDefInfo; - if ((ctdi == NULL) || (td->type->cTypeRefInfo == NULL)) - { - fprintf (stderr,"PrintCFree: ERROR - no type info\n"); - return; - } - - if (!ctdi->genFreeRoutine) - return; - - rhsTypeId = td->type->cTypeRefInfo->cTypeId; - switch (rhsTypeId) - { - case C_ANY: - case C_ANYDEFINEDBY: - case C_LIB: - case C_TYPEREF: - PrintCFreeDefine (hdr, td); - fprintf (hdr,"\n\n"); - break; - - case C_CHOICE: - PrintCFreePrototype (hdr, td); - PrintCFreeDeclaration (src, td); - fprintf (src,"{\n"); - PrintCFreeLocals (src, td); - fprintf (src," if (%s == NULL)\n", valueArgNameG); - fprintf (src," return;\n", valueArgNameG); - PrintCFreeChoiceElmts (src, td, td->type, valueArgNameG); - fprintf (src,"} /* %s */",td->cTypeDefInfo->freeRoutineName); - fprintf (hdr,"\n\n"); - fprintf (src,"\n\n"); - break; - - case C_STRUCT: - PrintCFreePrototype (hdr, td); - PrintCFreeDeclaration (src, td); - fprintf (src,"{\n"); - PrintCFreeLocals (src, td); - fprintf (src," if (%s == NULL)\n", valueArgNameG); - fprintf (src," return;\n", valueArgNameG); - PrintCFreeElmts (src, td, td->type, td->type->basicType->a.set, valueArgNameG); - fprintf (src,"} /* %s */", td->cTypeDefInfo->freeRoutineName); - fprintf (hdr,"\n\n"); - fprintf (src,"\n\n"); - break; - - - case C_LIST: - PrintCFreePrototype (hdr, td); - PrintCFreeDeclaration (src, td); - fprintf (src,"{\n"); - PrintCFreeLocals (src, td); - fprintf (src," if (%s == NULL)\n", valueArgNameG); - fprintf (src," return;\n", valueArgNameG); - PrintCFreeListRoutineBody (src, td, td->type, valueArgNameG); - fprintf (src,"} /* %s */", td->cTypeDefInfo->freeRoutineName); - fprintf (hdr,"\n\n"); - fprintf (src,"\n\n"); - break; - - - - case C_NO_TYPE: - break; - - default: - fprintf (stderr,"PrintCFree: ERROR - unknown c type id\n"); - break; - } - -} /* PrintCFree */ - - - -/* - * Prints prototype for encode routine in hdr file - */ -static void -PrintCFreePrototype PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - CTDI *ctdi; - - ctdi = td->cTypeDefInfo; - fprintf (hdr,"%s %s PROTO ((%s *v));\n", returnTypeG, ctdi->freeRoutineName, ctdi->cTypeName); - -} /* PrintCFreePrototype */ - - - -/* - * Prints declarations of encode routine for the given type def - */ -static void -PrintCFreeDeclaration PARAMS ((src, td), - FILE *src _AND_ - TypeDef *td) -{ - CTDI *ctdi; - - ctdi = td->cTypeDefInfo; - fprintf (src,"%s\n%s PARAMS ((v),\n%s *v)\n", returnTypeG, ctdi->freeRoutineName, ctdi->cTypeName); - -} /* PrintCFreeDeclaration */ - - - - -static void -PrintCFreeDefine PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - - fprintf(hdr, "#define %s %s ", td->cTypeDefInfo->freeRoutineName, td->type->cTypeRefInfo->freeRoutineName); - -/* - fprintf(hdr, "#define %s(v) ", td->cTypeDefInfo->freeRoutineName); - fprintf (hdr, "%s (v)", td->type->cTypeRefInfo->freeRoutineName); -*/ -} /* PrintCFreeDefine */ - - - - -static void -PrintCFreeLocals PARAMS ((src, td), - FILE *src _AND_ - TypeDef *td) -{ - fprintf (src, "\n"); - - if ((td->type->basicType->choiceId == BASICTYPE_SETOF) || - (td->type->basicType->choiceId == BASICTYPE_SEQUENCEOF)) - { - fprintf (src," AsnListNode *l;\n"); - fprintf (src," AsnListNode *tmp;\n"); - } - -} /* PrintCFreeLocals */ - - - -static void -PrintCFreeElmts PARAMS ((src, td, parent, elmts, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts _AND_ - char *varName) -{ - NamedType *e; - - if (elmts == NULL) - { - fprintf (src,"/* ERROR? - expected elmts for this type*/\n"); - return; - } - - FOR_EACH_LIST_ELMT (e, elmts) - PrintCElmtFree (src, td, parent, e->type, varName); - -} /* PrintCBerElmtsEncodeCode */ - - - -/* - * Prints code for encoding the elmts of a SEQ or SET - */ -static void -PrintCElmtFree PARAMS ((src, td, parent, e, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *e _AND_ - char *varName) -{ - CTRI *ctri; - char elmtVarRef[MAX_VAR_REF]; - Type *tmpType; - - if ((e == NULL) || (e->cTypeRefInfo == NULL)) - return; - - ctri = e->cTypeRefInfo; - - /* build ref to the elmt */ - MakeVarPtrRef (genFreeCRulesG, td, parent, e, varName, elmtVarRef); - - /* if optional then put in NULL check */ - if (e->optional || (e->defaultVal != NULL)) - fprintf (src, " if (%s (%s))\n {\n", ctri->optTestRoutineName, elmtVarRef); - - /* free contents of elmt first */ - switch (ctri->cTypeId) - { - case C_ANY: - case C_ANYDEFINEDBY: - case C_LIB: - case C_TYPEREF: - fprintf (src," %s (%s);\n", ctri->freeRoutineName, elmtVarRef); - break; - - case C_LIST: - PrintCFreeListElmts (src, td, e, elmtVarRef); - break; - - /* - * this follwing shouldn't happen since embedded - * choices/struct are moved to separate typedefs - * in normalize.c. - */ - case C_CHOICE: - PrintCFreeChoiceElmts (src, td, e, elmtVarRef); - break; - - case C_STRUCT: - PrintCFreeElmts (src, td, e, e->basicType->a.set, elmtVarRef); - break; - - - case C_NO_TYPE: - break; - - default: - fprintf (stderr,"PrintCElmtFree: ERROR - unknown c type id\n"); - break; - } - - /* free elmt itself if it is ref'd by ptr */ - if (ctri->isPtr) - fprintf (src," Asn1Free (%s);\n",elmtVarRef); - - /* write closing brkt for NULL check for optional elmts */ - if (e->optional || (e->defaultVal != NULL)) - fprintf (src, " }\n"); - - fprintf (src,"\n"); - -} /* PrintCElmtFree */ - - -static void -PrintCFreeListDefine PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - fprintf(hdr, "#define %s(v) ", td->cTypeDefInfo->freeRoutineName); - fprintf (hdr, "ASN1_FREE_LIST (v, %s)", td->type->cTypeRefInfo->freeRoutineName); -} - - -static void -PrintCFreeListRoutineBody PARAMS ((src, td, t, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t _AND_ - char *varName) -{ - Type *e; - CTRI *ctri; - char *elmtVarRef; - - fprintf (src," for (l = FIRST_LIST_NODE (%s); l != NULL; )\n", varName); - fprintf (src," {\n"); - - e = t->basicType->a.setOf; - ctri = e->cTypeRefInfo; - elmtVarRef = "(l->data)"; - switch (ctri->cTypeId) - { - case C_LIB: - case C_TYPEREF: - fprintf (src," %s (%s);\n", ctri->freeRoutineName, elmtVarRef); - break; - - case C_LIST: - PrintCFreeListElmts (src, td, e, elmtVarRef); - break; - - /* - * this follwing shouldn't happen since embedded - * choices/struct are moved to separate typedefs - * in normalize.c. - */ - case C_CHOICE: - PrintCFreeChoiceElmts (src, td, e, elmtVarRef); - break; - - case C_STRUCT: - PrintCFreeElmts (src, td, e, e->basicType->a.set, elmtVarRef); - break; - - - case C_NO_TYPE: - break; - - default: - fprintf (stderr,"PrintCElmtFree: ERROR - unknown c type id\n"); - break; - } - - fprintf (src," tmp = l->next;\n"); - fprintf (src," Asn1Free (l->data);\n"); - fprintf (src," Asn1Free (l);\n"); - fprintf (src," l = tmp;\n"); - fprintf (src," }\n"); -} - -static void -PrintCFreeListElmts PARAMS ((src, td, t, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t _AND_ - char *varName) -{ - Type *e; - CTRI *ctri; - char *elmtVarRef; - - fprintf (src," {\n"); - fprintf (src," AsnListNode *l;\n"); - fprintf (src," AsnListNode *tmp;\n"); - fprintf (src," for (l = FIRST_LIST_NODE (%s); l != NULL; )\n", varName); - fprintf (src," {\n"); - - - e = t->basicType->a.setOf; - ctri = e->cTypeRefInfo; - elmtVarRef = "(l->data)"; - switch (ctri->cTypeId) - { - case C_LIB: - case C_TYPEREF: - fprintf (src," %s (%s);\n", ctri->freeRoutineName, elmtVarRef); - break; - - case C_LIST: - PrintCFreeListElmts (src, td, e, elmtVarRef); - break; - - /* - * this follwing shouldn't happen since embedded - * choices/struct are moved to separate typedefs - * in normalize.c. - */ - case C_CHOICE: - PrintCFreeChoiceElmts (src, td, e, elmtVarRef); - break; - - case C_STRUCT: - PrintCFreeElmts (src, td, e, e->basicType->a.set, elmtVarRef); - break; - - - case C_NO_TYPE: - break; - - default: - fprintf (stderr,"PrintCElmtFree: ERROR - unknown c type id\n"); - break; - } - - fprintf (src," tmp = l->next;\n"); - fprintf (src," Asn1Free (l->data);\n"); - fprintf (src," Asn1Free (l);\n"); - fprintf (src," l = tmp;\n"); - fprintf (src," }\n"); - fprintf (src," }\n"); -} /* PrintCFreeListELmts */ - - - -static void -PrintCFreeChoiceElmts PARAMS ((src, td, t, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *t _AND_ - char *varName) -{ - NamedType *e; - CTRI *ctri; - void *tmp; - - ctri = t->cTypeRefInfo; - - fprintf (src," switch (%s->%s)\n {\n", varName, ctri->choiceIdEnumFieldName); - - FOR_EACH_LIST_ELMT (e, t->basicType->a.choice) - { - tmp = (void*)CURR_LIST_NODE (t->basicType->a.choice); - - if (e->type == NULL) - continue; - - ctri = e->type->cTypeRefInfo; - - if (e->type->cTypeRefInfo == NULL) - fprintf (src, " case ????:\n"); - else if (ctri->isPtr) - { - fprintf (src, " case %s:\n", ctri->choiceIdSymbol); - PrintCElmtFree (src, td, t, e->type, varName); - fprintf (src," break;\n\n"); - } - - SET_CURR_LIST_NODE (t->basicType->a.choice, tmp); - } - - fprintf (src, " }\n"); -} diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-free.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-free.h deleted file mode 100644 index df381750..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-free.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-free.h - * - * Mike Sample - * 92/04 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-free.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-free.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:42 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:42:48 rj - * file name has been shortened for redundant part: c-gen/gen-c-free -> c-gen/gen-free. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:12 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:27 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -void PrintCFree PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-print.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-print.c deleted file mode 100644 index 91d92ceb..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-print.c +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-print.c - routines for printing C hierachical print routines - * - * Mike Sample - * 92/04 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-print.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-print.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:42 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:43:18 rj - * file name has been shortened for redundant part: c-gen/gen-c-print -> c-gen/gen-print. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:23:43 rj - * snacc_config.h and other superfluous .h files removed. - * - * Revision 1.1 1994/08/28 09:48:28 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "define.h" -#include "rules.h" -#include "type-info.h" -#include "str-util.h" -#include "util.h" -#include "gen-print.h" - -static char *returnTypeG = "void"; -static char *valueArgNameG = "v"; -static char *fileTypeNameG = "FILE*"; -static char *indentTypeNameG = "unsigned short int"; -static CRules *genPrintCRulesG; -/* non-exported prototypes */ - -static void PrintCPrintPrototype PROTO ((FILE *hdr, TypeDef *td)); -static void PrintCPrintDeclaration PROTO ((FILE *src, TypeDef *td)); -static void PrintCPrintDefine PROTO ((FILE *hdr, TypeDef *td)); -static void PrintCPrintLocals PROTO ((FILE *src,TypeDef *td)); -/* -static void PrintCPrintElmts PROTO ((FILE *src, TypeDef *td, Type *parent, NamedTypeList *elmts, char *varName)); -*/ -static void PrintCChoiceElmtPrint PROTO ((FILE *src, TypeDef *td, Type *parent, NamedTypeList *elmts, NamedType *e, char *varName)); - - -static void PrintCElmtPrintWithIndent PROTO ((FILE *src, TypeDef *td, Type *parent, NamedTypeList *elmts, NamedType *e, char *varName, int allOpt)); - -static void PrintCChoicePrintRoutine PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); - -static void PrintCSetPrintRoutine PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); -static void PrintCSeqPrintRoutine PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); -static void PrintCSeqOfPrintRoutine PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); -static void PrintCSetOfPrintRoutine PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); - - - -void -PrintCPrinter PARAMS ((src, hdr, r, mods, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - TypeDef *td) -{ - if ((td->cTypeDefInfo == NULL) || !(td->cTypeDefInfo->genPrintRoutine)) - return; - - genPrintCRulesG = r; - switch (td->type->basicType->choiceId) - { - case BASICTYPE_IMPORTTYPEREF: /* type references */ - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_BOOLEAN: /* library type */ - case BASICTYPE_REAL: /* library type */ - case BASICTYPE_OCTETSTRING: /* library type */ - case BASICTYPE_NULL: /* library type */ - case BASICTYPE_OID: /* library type */ - case BASICTYPE_INTEGER: /* library type */ - case BASICTYPE_BITSTRING: /* library type */ - case BASICTYPE_ENUMERATED: /* library type */ - case BASICTYPE_ANYDEFINEDBY: /* ANY types */ - case BASICTYPE_ANY: - PrintCPrintDefine (hdr, td); - fprintf (hdr, "\n\n"); - break; - - case BASICTYPE_SETOF: - PrintCSetOfPrintRoutine (src, hdr, r, mods, m, td); - break; - - case BASICTYPE_SEQUENCEOF: - PrintCSeqOfPrintRoutine (src, hdr, r, mods, m, td); - break; - - case BASICTYPE_CHOICE: - PrintCChoicePrintRoutine (src, hdr, r, mods, m, td); - break; - - case BASICTYPE_SET: - PrintCSetPrintRoutine (src, hdr, r, mods, m, td); - break; - - - case BASICTYPE_SEQUENCE: - PrintCSeqPrintRoutine (src, hdr, r, mods, m, td); - break; - - default: - break; - } -} /* PrintCPrint */ - - -/* - * Prints prototype for encode routine in hdr file - */ -static void -PrintCPrintPrototype PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - CTDI *ctdi; - - ctdi = td->cTypeDefInfo; - fprintf (hdr,"%s %s PROTO ((%s f, %s *v, %s indent));\n", returnTypeG, ctdi->printRoutineName, fileTypeNameG, ctdi->cTypeName, indentTypeNameG); - -} /* PrintCPrintPrototype */ - - - -/* - * Prints declarations of encode routine for the given type def - */ -static void -PrintCPrintDeclaration PARAMS ((src, td), - FILE *src _AND_ - TypeDef *td) -{ - CTDI *ctdi; - - ctdi = td->cTypeDefInfo; - fprintf (src,"%s\n%s PARAMS ((f, v, indent),\n%s f _AND_\n%s *v _AND_\n%s indent)\n", returnTypeG, ctdi->printRoutineName, fileTypeNameG, ctdi->cTypeName, indentTypeNameG); - -} /* PrintCPrintDeclaration */ - - - - -static void -PrintCPrintDefine PARAMS ((hdr, td), - FILE *hdr _AND_ - TypeDef *td) -{ - fprintf(hdr, "#define %s %s", td->cTypeDefInfo->printRoutineName, td->type->cTypeRefInfo->printRoutineName); -/* - fprintf(hdr, "#define %s(f, v, indent) ", td->cTypeDefInfo->printRoutineName); - fprintf (hdr, "%s (f, v, indent)", td->type->cTypeRefInfo->printRoutineName); -*/ -} /* PrintCPrintDefine */ - - - - -static void -PrintCPrintLocals PARAMS ((src, td), - FILE *src _AND_ - TypeDef *td) -{ - /* none yet */ -} /* PrintCPrintLocals */ - - -/* -static void -PrintCPrintElmts PARAMS ((src, td, parent, elmts, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts _AND_ - char *varName) -{ - NamedType *e; - - - FOR_EACH_LIST_ELMT (e, elmts) - PrintCElmtPrint (src, td, parent, elmts, e, varName); -} PrintCBerElmtsEncodeCode */ - - - -/* - * Prints code for printing a CHOICE element - * - */ -static void -PrintCChoiceElmtPrint PARAMS ((src, td, parent, elmts, e, varName), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts _AND_ - NamedType *e _AND_ - char *varName) -{ - CTRI *ctri; - char elmtVarRef[MAX_VAR_REF]; - Type *tmpType; - int inTailOpts; - - ctri = e->type->cTypeRefInfo; - - - /* build ref to the elmt */ - MakeVarPtrRef (genPrintCRulesG, td, parent, e->type, varName, elmtVarRef); - - if (e->fieldName != NULL) - { - fprintf (src," fprintf (f,\"%s \");\n", e->fieldName); - fprintf (src," %s (f, %s, indent + stdIndentG);\n", e->type->cTypeRefInfo->printRoutineName, elmtVarRef); - } - else - { - fprintf (src," %s (f, %s, indent + stdIndentG);\n", e->type->cTypeRefInfo->printRoutineName, elmtVarRef); - } - -} /* PrintCChoiceElmtPrint */ - -/* - * Prints code for printing an elmt of a SEQ or SET - * - * Does funny things to print commas correctly - * eg for the following type - * Foo ::= SET - * { - * A, --> print A ",\n" - * B, B ",\n" - * C OPTIONAL, C ",\n" if C present - * D, D ",\n" - * E, E ",\n" - * F, F <- nothing after last non-opt - * before tail opts. - * G OPTIONAL, ",\n" G - * H OPTIONAL ",\n" H "\n" - * } - - */ -static void -PrintCElmtPrintWithIndent PARAMS ((src, td, parent, elmts, e, varName, allOpt), - FILE *src _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts _AND_ - NamedType *e _AND_ - char *varName _AND_ - int allOpt) -{ - CTRI *ctri; - char elmtVarRef[MAX_VAR_REF]; - Type *tmpType; - int inTailOpts; - - ctri = e->type->cTypeRefInfo; - - /* this assumes the elmts->curr == e */ - inTailOpts = IsTailOptional (elmts); - - /* build ref to the elmt */ - MakeVarPtrRef (genPrintCRulesG, td, parent, e->type, varName, elmtVarRef); - - /* if optional then put in NULL check */ - if (e->type->optional || (e->type->defaultVal != NULL)) - fprintf (src, " if (%s (%s))\n {\n", ctri->optTestRoutineName, elmtVarRef); - - if (allOpt) - { - if (e != FIRST_LIST_ELMT (elmts)) - { - fprintf (src, " if (!nonePrinted)\n"); - fprintf (src, " fprintf (f,\",\\n\");\n"); - } - fprintf (src, " nonePrinted = FALSE;\n"); - } - else if ((inTailOpts) && (e != FIRST_LIST_ELMT (elmts))) - fprintf (src, " fprintf (f,\",\\n\");\n"); - - fprintf (src," Indent (f, indent + stdIndentG);\n"); - - if (e->fieldName != NULL) - fprintf (src," fprintf (f,\"%s \");\n", e->fieldName); - - fprintf (src," %s (f, %s, indent + stdIndentG);\n", e->type->cTypeRefInfo->printRoutineName, elmtVarRef); - - if ((e != LAST_LIST_ELMT (elmts)) && - (!inTailOpts) && - (!NextIsTailOptional (elmts))) - fprintf (src," fprintf (f, \",\\n\");\n"); - - - /* write closing brkt for NULL check for optional elmts */ - if (e->type->optional || (e->type->defaultVal != NULL)) - fprintf (src, " }\n"); - - if (e == LAST_LIST_ELMT (elmts)) - fprintf (src," fprintf (f,\"\\n\");\n"); - -} /* PrintCElmtPrintWithIndent */ - - -static void -PrintCChoicePrintRoutine PARAMS ((src, hdr, r, mods, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - TypeDef *td) -{ - NamedType *e; - - PrintCPrintPrototype (hdr,td); - - PrintCPrintDeclaration (src, td); - fprintf (src,"{\n"); - PrintCPrintLocals (src,td); - fprintf (src," switch (%s->%s)\n", valueArgNameG, td->type->cTypeRefInfo->choiceIdEnumFieldName); - fprintf (src," {\n"); - - FOR_EACH_LIST_ELMT (e, td->type->basicType->a.choice) - { - fprintf (src," case %s:\n",e->type->cTypeRefInfo->choiceIdSymbol); - fprintf (src," "); - PrintCChoiceElmtPrint (src, td, td->type, td->type->basicType->a.choice, e, valueArgNameG); - fprintf (src," break;\n\n"); - } - fprintf (src," }\n"); -/* fprintf (src," fprintf (f,\"\\n\");\n"); */ - - fprintf (src,"} /* %s */\n\n", td->cTypeDefInfo->printRoutineName); - -} /* PrintCChoicePrintRoutine */ - - - -static void -PrintCSetPrintRoutine PARAMS ((src, hdr, r, mods, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - TypeDef *td) -{ - NamedType *e; - int allOpt; - - PrintCPrintPrototype (hdr,td); - - PrintCPrintDeclaration (src, td); - fprintf (src,"{\n"); - PrintCPrintLocals (src,td); - - allOpt = AllElmtsOptional (td->type->basicType->a.set); - /* - * print extra local variable so commas are handled correctly - * when all elements are optional - */ - if (allOpt) - fprintf (src," int nonePrinted = TRUE;\n\n"); - - fprintf (src," if (%s == NULL)\n", valueArgNameG); - fprintf (src," return;\n\n"); - - fprintf (src," fprintf (f,\"{ -- SET --\\n\");\n\n"); - - - FOR_EACH_LIST_ELMT (e, td->type->basicType->a.set) - { - PrintCElmtPrintWithIndent (src, td, td->type, td->type->basicType->a.set, e, valueArgNameG, allOpt); - } - fprintf (src," Indent (f, indent);\n"); - fprintf (src," fprintf (f,\"}\");\n"); - - fprintf (src,"} /* %s */\n\n", td->cTypeDefInfo->printRoutineName); - -} /* PrintCSetPrintRoutine */ - - - -static void -PrintCSeqPrintRoutine PARAMS ((src, hdr, r, mods, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - TypeDef *td) -{ - NamedType *e; - int allOpt; - - PrintCPrintPrototype (hdr,td); - - PrintCPrintDeclaration (src, td); - fprintf (src,"{\n"); - PrintCPrintLocals (src,td); - - allOpt = AllElmtsOptional (td->type->basicType->a.set); - /* - * print extra local variable so commas are handled correctly - * when all elements are optional - */ - if (allOpt) - fprintf (src," int nonePrinted = TRUE;\n\n"); - - fprintf (src," if (%s == NULL)\n", valueArgNameG); - fprintf (src," return;\n\n"); - - fprintf (src," fprintf (f,\"{ -- SEQUENCE --\\n\");\n\n"); - - FOR_EACH_LIST_ELMT (e, td->type->basicType->a.sequence) - { - PrintCElmtPrintWithIndent (src, td, td->type, td->type->basicType->a.sequence, e, valueArgNameG, allOpt); - } - fprintf (src," Indent (f, indent);\n"); - fprintf (src," fprintf (f,\"}\");\n"); - - fprintf (src,"} /* %s */\n\n", td->cTypeDefInfo->printRoutineName); -} /* PrintCSeqPrintRoutine */ - - - -static void -PrintCSetOfPrintRoutine PARAMS ((src, hdr, r, mods, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - TypeDef *td) -{ - NamedType *e; - - PrintCPrintPrototype (hdr,td); - - PrintCPrintDeclaration (src, td); - fprintf (src,"{\n"); - PrintCPrintLocals (src,td); - - fprintf (src," %s *tmp;\n", td->type->basicType->a.setOf->cTypeRefInfo->cTypeName); - - fprintf (src," if (%s == NULL)\n", valueArgNameG); - fprintf (src," return;\n"); - - fprintf (src," fprintf (f,\"{ -- SET OF -- \\n\");\n"); - - fprintf (src," FOR_EACH_LIST_ELMT (tmp, %s)\n", valueArgNameG); - fprintf (src," {\n"); - fprintf (src," Indent (f, indent+ stdIndentG);\n"); - fprintf (src," %s (f, tmp, indent + stdIndentG);\n", td->type->basicType->a.setOf->cTypeRefInfo->printRoutineName); - fprintf (src," if (tmp != (%s*)LAST_LIST_ELMT (%s))\n", td->type->basicType->a.setOf->cTypeRefInfo->cTypeName, valueArgNameG); - fprintf (src," fprintf (f,\",\\n\");\n"); - fprintf (src," }\n"); - fprintf (src," fprintf (f,\"\\n\");\n"); - fprintf (src," Indent (f, indent);\n"); - fprintf (src," fprintf (f,\"}\");\n"); - - fprintf (src,"} /* %s */\n\n", td->cTypeDefInfo->printRoutineName); - -} /* PrintCSetOfPrintRoutine */ - -static void -PrintCSeqOfPrintRoutine PARAMS ((src, hdr, r, mods, m, td), - FILE *src _AND_ - FILE *hdr _AND_ - CRules *r _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - TypeDef *td) -{ - NamedType *e; - - PrintCPrintPrototype (hdr,td); - - PrintCPrintDeclaration (src, td); - fprintf (src,"{\n"); - PrintCPrintLocals (src,td); - - fprintf (src," %s *tmp;\n", td->type->basicType->a.setOf->cTypeRefInfo->cTypeName); - - fprintf (src," if (%s == NULL)\n", valueArgNameG); - fprintf (src," return;\n"); - - fprintf (src," fprintf (f,\"{ -- SEQUENCE OF -- \\n\");\n"); - - fprintf (src," FOR_EACH_LIST_ELMT (tmp, %s)\n", valueArgNameG); - fprintf (src," {\n"); - fprintf (src," Indent (f, indent+ stdIndentG);\n"); - fprintf (src," %s (f, tmp, indent + stdIndentG);\n", td->type->basicType->a.setOf->cTypeRefInfo->printRoutineName); - fprintf (src," if (tmp != (%s*)LAST_LIST_ELMT (%s))\n", td->type->basicType->a.setOf->cTypeRefInfo->cTypeName, valueArgNameG); - fprintf (src," fprintf (f,\",\\n\");\n"); - fprintf (src," }\n"); - fprintf (src," fprintf (f,\"\\n\");\n"); - fprintf (src," Indent (f, indent);\n"); - fprintf (src," fprintf (f,\"}\");\n"); - - fprintf (src,"} /* %s */\n\n", td->cTypeDefInfo->printRoutineName); - -} /* PrintCSeqOfPrintRoutine */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-print.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-print.h deleted file mode 100644 index abd0143b..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-print.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-print.h - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-print.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-print.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:43:19 rj - * file name has been shortened for redundant part: c-gen/gen-c-print -> c-gen/gen-print. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:13 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:29 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -void PrintCPrinter PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-type.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-type.c deleted file mode 100644 index a74bd610..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-type.c +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-type.c - routines for printing c types from ASN.1 from type trees - * - * Mike Sample - * 91/09/26 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-type.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-type.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:43:44 rj - * file name has been shortened for redundant part: c-gen/gen-c-type -> c-gen/gen-type. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:23:58 rj - * snacc_config.h and other superfluous .h files removed. - * - * Revision 1.1 1994/08/28 09:48:31 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "print.h" -#include "rules.h" -#include "type-info.h" -#include "util.h" -#include "gen-type.h" - - -/* non-exported prototypes */ - -static void PrintCType PROTO ((FILE *f, CRules *r, Module *m, TypeDef *td, Type *parent, Type *t)); - -static void PrintCStructElmts PROTO ((FILE *f, CRules *r, Module *m, TypeDef *td, Type *parent, Type *t)); - - -static void PrintCChoiceIdEnum PROTO ((FILE *f, CRules *r, Module *m, TypeDef *td, Type *parent, Type *t)); - -static void PrintCChoiceUnion PROTO ((FILE *f, CRules *r, Module *m, TypeDef *td, Type *parent, Type *t)); - -static void PrintCChoiceTypeDef PROTO ((FILE *f, CRules *r, Module *m, TypeDef *td)); - -static void PrintTypeComment PROTO ((FILE *f, TypeDef *head, Type *t)); - - -static void PrintPreTypeDefStuff PROTO ((FILE *f, CRules *r, Module *m, TypeDef *td, Type *parent, Type *t)); - - - -void -PrintCTypeDef PARAMS ((f, r, m, td), - FILE *f _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td) -{ - CTRI *ctri; - CTDI *ctdi; - Type *t; - - ctdi = td->cTypeDefInfo; - if ((ctdi == NULL) || (!ctdi->genTypeDef)) - return; - - t = td->type; - ctri = t->cTypeRefInfo; - - PrintPreTypeDefStuff (f, r, m, td, NULL, t); - - switch (ctri->cTypeId) - { - case C_TYPEREF: - case C_LIB: - case C_ANY: - case C_ANYDEFINEDBY: - case C_LIST: - fprintf (f, "typedef "); - PrintCType (f, r, m, td, NULL, t); - fprintf (f, " %s;", ctdi->cTypeName); - PrintTypeComment (f, td, t); - fprintf (f, "\n\n"); - break; - - - case C_CHOICE: - PrintCChoiceTypeDef (f, r, m, td); - break; - - case C_STRUCT: - fprintf (f, "typedef "); - fprintf (f,"%s %s", "struct", t->cTypeRefInfo->cTypeName); - PrintTypeComment (f, td, t); - fprintf (f,"\n{\n"); - PrintCStructElmts (f, r, m, td, NULL, t); - fprintf (f, "} %s;", ctdi->cTypeName); - fprintf (f, "\n\n"); - break; - - default: - break; - /* else do nothing - some unprocessed or unknown type (macros etc) */ - } - -} /* PrintCTypeDef */ - - - -static void -PrintCType PARAMS ((f, r, m, td, parent, t), - FILE *f _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - CTRI *ctri; - CNamedElmt *n; - - ctri = t->cTypeRefInfo; - - if (ctri == NULL) - return; - - - switch (ctri->cTypeId) - { - case C_TYPEREF: - /* - * put struct in front of def if - * defined from a struct type (set/seq/choice) - * but only if not a ref of a ref - */ - if ((t->basicType->a.localTypeRef->link->type->cTypeRefInfo->cTypeId == C_STRUCT)|| - (t->basicType->a.localTypeRef->link->type->cTypeRefInfo->cTypeId == C_CHOICE)) - { - fprintf (f,"struct "); - } - - fprintf (f,"%s", ctri->cTypeName); - - if (ctri->isPtr) - fprintf (f,"*"); - break; - - case C_ANY: - fprintf (f,"/* ANY- Fix Me ! */\n"); - case C_ANYDEFINEDBY: - case C_LIST: - case C_LIB: - fprintf (f,"%s", ctri->cTypeName); - /* - * print enum constant defs - */ - if ((ctri->cNamedElmts != NULL) && - (t->basicType->choiceId == BASICTYPE_ENUMERATED)) - { - fprintf (f, "\n {\n"); - - FOR_EACH_LIST_ELMT (n, ctri->cNamedElmts) - { - fprintf (f," %s = %d", n->name, n->value); - if (n != (CNamedElmt*)LAST_LIST_ELMT (ctri->cNamedElmts)) - fprintf (f,","); - - fprintf (f,"\n"); - } - fprintf (f, " }"); - } - - if (ctri->isPtr) - fprintf (f,"*"); - break; - - default: - break; - /* nothing */ - } - -} /* PrintCType */ - - -static void -PrintCStructElmts PARAMS ((f, r, m, td, parent, t), - FILE *f _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - CTRI *ctri; - NamedType *et; - NamedTypeList *elmts; - - elmts = t->basicType->a.sequence; - - if ((elmts == NULL) || (LIST_EMPTY (elmts))) - { - fprintf (f, " char unused; /* empty ASN1 SET/SEQ - not used */\n"); - } - - FOR_EACH_LIST_ELMT (et, elmts) - { - - ctri = et->type->cTypeRefInfo; - fprintf (f," "); /* cheap, fixed indent */ - PrintCType (f, r, m, td, t, et->type); - fprintf (f, " %s;", ctri->cFieldName); - PrintTypeComment (f, td, et->type); - fprintf (f, "\n"); - } -} /* PrintCStructElmts */ - - - -static void -PrintCChoiceIdEnum PARAMS ((f, r, m, td, parent, t), - FILE *f _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - NamedType *et; - NamedType *last; - CTRI *ctri; - - ctri = t->cTypeRefInfo; - fprintf (f, " enum %s\n {\n", ctri->choiceIdEnumName); - - if ((t->basicType->a.choice != NULL) && - !(LIST_EMPTY (t->basicType->a.choice))) - last = (NamedType*)LAST_LIST_ELMT (t->basicType->a.choice); - - FOR_EACH_LIST_ELMT (et, t->basicType->a.choice) - { - ctri = et->type->cTypeRefInfo; - fprintf (f," %s", ctri->choiceIdSymbol); - if (et == last) - fprintf (f, "\n"); - else - fprintf (f, ",\n"); - } - - ctri = t->cTypeRefInfo; - fprintf (f, " } %s;", ctri->choiceIdEnumFieldName); - -} /* PrintCChoiceIdEnum */ - - -static void -PrintCChoiceUnion PARAMS ((f, r, m, td, parent, t), - FILE *f _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - CTRI *ctri; - ctri = t->cTypeRefInfo; - - fprintf (f," union %s\n {\n", ctri->cTypeName); - PrintCStructElmts (f, r, m, td, parent, t); - fprintf (f, " }"); -} /* PrintCChoiceUnion */ - - -static void -PrintCChoiceTypeDef PARAMS ((f, r, m, td), - FILE *f _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td) -{ - CTRI *ctri; - char *choiceName; - Type *t; - - t = td->type; - ctri = t->cTypeRefInfo; - choiceName = td->cTypeDefInfo->cTypeName; - - fprintf (f, "typedef "); - fprintf (f, "struct %s", choiceName); - PrintTypeComment (f, td, t); - fprintf (f,"\n{\n"); - PrintCChoiceIdEnum (f, r, m, td, NULL, t); - fprintf (f,"\n"); - PrintCChoiceUnion (f, r, m, td, NULL, t); - fprintf (f, " %s;", ctri->cFieldName); - fprintf (f,"\n} %s;\n\n", choiceName); -} /* PrintCChoiceDef */ - - - -/* - * used to print snippet of the defining ASN.1 after the - * C type. - */ -static void -PrintTypeComment PARAMS ((f, td, t), - FILE *f _AND_ - TypeDef *td _AND_ - Type *t) -{ - fprintf (f," /* "); - SpecialPrintType (f, td, t); - fprintf (f," */"); -} - - - -/* - * print any #defines for integers/bits with named elements - * (currenly only the first option will fire due to the - * steps taken in normalize.c) - */ -static void -PrintPreTypeDefStuff PARAMS ((f, r, m, td, parent, t), - FILE *f _AND_ - CRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - CTRI *ctri; - NamedType *et; - CNamedElmt *n; - - ctri = td->type->cTypeRefInfo; - - /* - * print defined stmts for non enumerated type with named elmts - */ - if ((ctri->cNamedElmts != NULL) && - (t->basicType->choiceId != BASICTYPE_ENUMERATED)) - { - FOR_EACH_LIST_ELMT (n, ctri->cNamedElmts) - { - fprintf(f, "\n#define %s %d", n->name, n->value); - } - fprintf (f, "\n\n"); - } - - else if ((t->basicType->choiceId == BASICTYPE_SET) || - (t->basicType->choiceId == BASICTYPE_SEQUENCE) || - (t->basicType->choiceId == BASICTYPE_CHOICE)) - { - - FOR_EACH_LIST_ELMT (et, t->basicType->a.set) - PrintPreTypeDefStuff (f, r, m, td, t, et->type); - } - - else if ((t->basicType->choiceId == BASICTYPE_SETOF) || - (t->basicType->choiceId == BASICTYPE_SEQUENCEOF)) - { - PrintPreTypeDefStuff (f, r, m, td, t, t->basicType->a.setOf); - } -} /* PrintPreTypeDefStuff */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-type.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-type.h deleted file mode 100644 index 800515cb..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-type.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-type.h - routines for printing c types ASN.1 from type trees - * - * Mike Sample - * 91/09/26 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-type.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-type.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:43:45 rj - * file name has been shortened for redundant part: c-gen/gen-c-type -> c-gen/gen-type. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:14 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:32 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -void PrintCTypeDef PROTO ((FILE *f, CRules *r, Module *m, TypeDef *td)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals.c deleted file mode 100644 index 16e8c3f1..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-vals.c - prints ASN.1 values in C format - * - * - * MS Feb 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-vals.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-vals.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1 2000/05/10 21:35:01 rmurphy - * Adding back in base code files which had been moved to "2" versions. - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1997/05/07 14:59:31 wan - * Fixed bug in C value string generation. - * - * Revision 1.3 1995/07/25 18:44:12 rj - * file name has been shortened for redundant part: c-gen/gen-c-vals -> c-gen/gen-vals. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:24:18 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:33 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "oid.h" -#include "asn1module.h" -#include "mem.h" -#include "define.h" -#include "lib-types.h" -#include "rules.h" -#include "type-info.h" -#include "str-util.h" -#include "snacc-util.h" -#include "util.h" -#include "kwd.h" -#include "gen-vals.h" - -/* non-exported routines' prototypes */ - -static void PrintValueDefsName PROTO ((FILE *f, CRules *r, ValueDef *v)); -static void PrintValueDefsType PROTO ((FILE *f, CRules *r, ValueDef *v)); -static void PrintValueInstatiation PROTO ((FILE *f, CRules *r, ValueDef *v)); - - - - -void -PrintCValueDef PARAMS ((src, r, v), - FILE *src _AND_ - CRules *r _AND_ - ValueDef *v) -{ - /* just do oid's, ints and bools for now */ - if ((v->value->basicValue->choiceId != BASICVALUE_OID) && - (v->value->basicValue->choiceId != BASICVALUE_INTEGER) && - (v->value->basicValue->choiceId != BASICVALUE_BOOLEAN)) - return; - - /* - * put instantiation in src file - */ - PrintValueDefsType (src, r, v); - fprintf (src," "); - PrintValueDefsName (src, r, v); - fprintf (src," = "); - PrintValueInstatiation (src, r, v); - fprintf (src,";\n\n"); - -} /* PrintCValueDef */ - -void -PrintCValueExtern PARAMS ((hdr, r, v), - FILE *hdr _AND_ - CRules *r _AND_ - ValueDef *v) -{ - /* just do oid's, ints and bools for now */ - if ((v->value->basicValue->choiceId != BASICVALUE_OID) && - (v->value->basicValue->choiceId != BASICVALUE_INTEGER) && - (v->value->basicValue->choiceId != BASICVALUE_BOOLEAN)) - return; - - /* - * put extern declaration in hdr file - */ - fprintf (hdr,"extern "); - PrintValueDefsType (hdr, r, v); - fprintf (hdr," "); - PrintValueDefsName (hdr, r, v); - fprintf (hdr,";\n"); - -} /* PrintCValueExtern */ - - -static void -PrintValueDefsName PARAMS ((f, r, v), - FILE *f _AND_ - CRules *r _AND_ - ValueDef *v) -{ - char *cName; - cName = Asn1ValueName2CValueName (v->definedName); - fprintf (f, "%s", cName); - Free (cName); -} - -static void -PrintValueDefsType PARAMS ((f, r, v), - FILE *f _AND_ - CRules *r _AND_ - ValueDef *v) -{ - /* needs work - just do ints bools and oid's for now */ - switch (v->value->basicValue->choiceId) - { - case BASICVALUE_OID: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_OID].cTypeName); - break; - - case BASICVALUE_INTEGER: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_INTEGER].cTypeName); - break; - - case BASICVALUE_BOOLEAN: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_BOOLEAN].cTypeName); - break; - - default: - break; - } -} - - -static void -PrintValueInstatiation PARAMS ((f, r, v), - FILE *f _AND_ - CRules *r _AND_ - ValueDef *v) -{ - /* needs work - just do ints, bools and oids for now */ - switch (v->value->basicValue->choiceId) - { - case BASICVALUE_OID: - PrintCOidValue (f, r, v->value->basicValue->a.oid); - break; - - case BASICVALUE_INTEGER: - fprintf (f, "%d", v->value->basicValue->a.integer); - break; - - case BASICVALUE_BOOLEAN: - if (v->value->basicValue->a.boolean) - fprintf (f, "TRUE"); - else - fprintf (f, "FALSE"); - break; - - default: - break; - } - - -} - - - -/* - * given an AOID, a c value is produced. - * This is used for turning ASN.1 OBJECT ID values - * into usable c values. - * - * eg for the oid { 0 1 2 } (in AOID format) - * - * { - * 2, - * "\1\2" - * } - * is produced. - */ -void -PrintCOidValue PARAMS ((f, r, oid), - FILE *f _AND_ - CRules *r _AND_ - AsnOid *oid) -{ - int i; - - fprintf (f, "{ "); - fprintf (f, "%d, ",oid->octetLen); - fprintf (f, "\""); - - /* print encoded oid string in C's 'octal' escape format */ - for (i = 0; i < oid->octetLen; i++) - fprintf (f, "\\%o", (unsigned char) oid->octs[i]); - fprintf (f, "\""); - fprintf (f, " }"); - -} /* PrintCOidValue */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals.h deleted file mode 100644 index 153a7784..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-vals.h - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-vals.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-vals.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:44:13 rj - * file name has been shortened for redundant part: c-gen/gen-c-vals -> c-gen/gen-vals. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:15 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:34 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -void PrintCValueDef PROTO ((FILE *src, CRules *r, ValueDef *v)); - -void PrintCValueExtern PROTO ((FILE *hdr, CRules *r, ValueDef *v)); - -void PrintCOidValue PROTO ((FILE *f, CRules *r, AsnOid *oid)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals2.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals2.c deleted file mode 100644 index bf54eb5a..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-vals2.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/gen-vals.c - prints ASN.1 values in C format - * - * - * MS Feb 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/gen-vals2.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-vals2.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1997/05/07 14:59:31 wan - * Fixed bug in C value string generation. - * - * Revision 1.3 1995/07/25 18:44:12 rj - * file name has been shortened for redundant part: c-gen/gen-c-vals -> c-gen/gen-vals. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:24:18 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:33 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "oid.h" -#include "asn1module.h" -#include "mem.h" -#include "define.h" -#include "lib-types.h" -#include "rules.h" -#include "type-info.h" -#include "str-util.h" -#include "snacc-util.h" -#include "util.h" -#include "kwd.h" -#include "gen-vals.h" - -/* non-exported routines' prototypes */ - -static void PrintValueDefsName PROTO ((FILE *f, CRules *r, ValueDef *v)); -static void PrintValueDefsType PROTO ((FILE *f, CRules *r, ValueDef *v)); -static void PrintValueInstatiation PROTO ((FILE *f, CRules *r, ValueDef *v)); - - - - -void -PrintCValueDef PARAMS ((src, r, v), - FILE *src _AND_ - CRules *r _AND_ - ValueDef *v) -{ - /* just do oid's, ints and bools for now */ - if ((v->value->basicValue->choiceId != BASICVALUE_OID) && - (v->value->basicValue->choiceId != BASICVALUE_INTEGER) && - (v->value->basicValue->choiceId != BASICVALUE_BOOLEAN)) - return; - - /* - * put instantiation in src file - */ - PrintValueDefsType (src, r, v); - fprintf (src," "); - PrintValueDefsName (src, r, v); - fprintf (src," = "); - PrintValueInstatiation (src, r, v); - fprintf (src,";\n\n"); - -} /* PrintCValueDef */ - -void -PrintCValueExtern PARAMS ((hdr, r, v), - FILE *hdr _AND_ - CRules *r _AND_ - ValueDef *v) -{ - /* just do oid's, ints and bools for now */ - if ((v->value->basicValue->choiceId != BASICVALUE_OID) && - (v->value->basicValue->choiceId != BASICVALUE_INTEGER) && - (v->value->basicValue->choiceId != BASICVALUE_BOOLEAN)) - return; - - /* - * put extern declaration in hdr file - */ - fprintf (hdr,"extern "); - PrintValueDefsType (hdr, r, v); - fprintf (hdr," "); - PrintValueDefsName (hdr, r, v); - fprintf (hdr,";\n"); - -} /* PrintCValueExtern */ - - -static void -PrintValueDefsName PARAMS ((f, r, v), - FILE *f _AND_ - CRules *r _AND_ - ValueDef *v) -{ - char *cName; - cName = Asn1ValueName2CValueName (v->definedName); - fprintf (f, "%s", cName); - Free (cName); -} - -static void -PrintValueDefsType PARAMS ((f, r, v), - FILE *f _AND_ - CRules *r _AND_ - ValueDef *v) -{ - /* needs work - just do ints bools and oid's for now */ - switch (v->value->basicValue->choiceId) - { - case BASICVALUE_OID: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_OID].cTypeName); - break; - - case BASICVALUE_INTEGER: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_INTEGER].cTypeName); - break; - - case BASICVALUE_BOOLEAN: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_BOOLEAN].cTypeName); - break; - - default: - break; - } -} - - -static void -PrintValueInstatiation PARAMS ((f, r, v), - FILE *f _AND_ - CRules *r _AND_ - ValueDef *v) -{ - /* needs work - just do ints, bools and oids for now */ - switch (v->value->basicValue->choiceId) - { - case BASICVALUE_OID: - PrintCOidValue (f, r, v->value->basicValue->a.oid); - break; - - case BASICVALUE_INTEGER: - fprintf (f, "%d", v->value->basicValue->a.integer); - break; - - case BASICVALUE_BOOLEAN: - if (v->value->basicValue->a.boolean) - fprintf (f, "TRUE"); - else - fprintf (f, "FALSE"); - break; - - default: - break; - } - - -} - - - -/* - * given an AOID, a c value is produced. - * This is used for turning ASN.1 OBJECT ID values - * into usable c values. - * - * eg for the oid { 0 1 2 } (in AOID format) - * - * { - * 2, - * "\1\2" - * } - * is produced. - */ -void -PrintCOidValue PARAMS ((f, r, oid), - FILE *f _AND_ - CRules *r _AND_ - AsnOid *oid) -{ - int i; - - fprintf (f, "{ "); - fprintf (f, "%d, ",oid->octetLen); - fprintf (f, "\""); - - /* print encoded oid string in C's 'octal' escape format */ - for (i = 0; i < oid->octetLen; i++) - fprintf (f, "\\%o", (unsigned char) oid->octs[i]); - fprintf (f, "\""); - fprintf (f, " }"); - -} /* PrintCOidValue */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.c deleted file mode 100644 index de430a18..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/kwd.c - routines for determining whether a given str is a C keyword - * - * NOTE: this was hacked up really quickly. It uses a slow linear - * search. A much better approach is to use a hash tbl. - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/kwd.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: kwd.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1 2000/05/10 21:35:02 rmurphy - * Adding back in base code files which had been moved to "2" versions. - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:45:38 rj - * file name has been shortened for redundant part: c-gen/c-kwd -> c-gen/kwd. - * - * Revision 1.3 1994/10/08 03:48:06 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:20:28 rj - * snacc_config.h removed; more portable .h file inclusion. - * - * Revision 1.1 1994/08/28 09:48:13 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "snacc.h" - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif - -#include "kwd.h" - -/* - * last elmt must be NULL. - * key words grabbed from K&R 2nd Ed - */ -static char *cKWdG[] = -{ - "auto", "break", "case", "char", "const", "continue", - "default", "do", "double", "else", "enum", "extern", - "float", "for", "goto", "if", "int", "long", "register", - "return", "short", "signed", "sizeof", "static", "struct", - "switch", "typedef", "union", "unsigned", "void", "volatile", - "while", NULL -}; - - -/* - * returns non-zero if the given str is a C key word - */ -int -IsCKeyWord PARAMS ((str), - char *str) -{ - int i; - - for (i=0; (cKWdG[i] != NULL) && (strcmp (cKWdG[i],str) != 0); i++) - ; - - return cKWdG[i] != NULL; -} diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.h deleted file mode 100644 index abac52ed..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/kwd.h - for determining whether a string is a C keyword - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/kwd.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: kwd.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:45:39 rj - * file name has been shortened for redundant part: c-gen/c-kwd -> c-gen/kwd. - * - * Revision 1.2 1994/10/08 03:48:07 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:14 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -int IsCKeyWord PROTO ((char *str)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd2.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd2.c deleted file mode 100644 index 7b26358b..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd2.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/kwd.c - routines for determining whether a given str is a C keyword - * - * NOTE: this was hacked up really quickly. It uses a slow linear - * search. A much better approach is to use a hash tbl. - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/kwd2.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: kwd2.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:45:38 rj - * file name has been shortened for redundant part: c-gen/c-kwd -> c-gen/kwd. - * - * Revision 1.3 1994/10/08 03:48:06 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:20:28 rj - * snacc_config.h removed; more portable .h file inclusion. - * - * Revision 1.1 1994/08/28 09:48:13 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "snacc.h" - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif - -#include "kwd.h" - -/* - * last elmt must be NULL. - * key words grabbed from K&R 2nd Ed - */ -static char *cKWdG[] = -{ - "auto", "break", "case", "char", "const", "continue", - "default", "do", "double", "else", "enum", "extern", - "float", "for", "goto", "if", "int", "long", "register", - "return", "short", "signed", "sizeof", "static", "struct", - "switch", "typedef", "union", "unsigned", "void", "volatile", - "while", NULL -}; - - -/* - * returns non-zero if the given str is a C key word - */ -int -IsCKeyWord PARAMS ((str), - char *str) -{ - int i; - - for (i=0; (cKWdG[i] != NULL) && (strcmp (cKWdG[i],str) != 0); i++) - ; - - return cKWdG[i] != NULL; -} diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules.c deleted file mode 100644 index e83cf358..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules.c +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/rules.c - initialized c rule structure - * inits a table that contains info about - * converting each ASN.1 type to C type - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/rules.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: rules.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1 2000/05/10 21:35:02 rmurphy - * Adding back in base code files which had been moved to "2" versions. - * - * Revision 1.1.1.1 1999/03/16 18:06:44 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:46:34 rj - * file name has been shortened for redundant part: c-gen/c-rules -> c-gen/rules. - * - * Revision 1.2 1994/09/01 00:24:35 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:35 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" -#include "asn1module.h" -#include "rules.h" - -/* - * (see rule.h and asn1module.h) -* -*/ - - -CRules cRulesG = -{ - 4, - "choiceId", - "ChoiceId", - "a", - "ChoiceUnion", - TRUE, - "Print", - "Enc", - "Dec", - "Free", - { - { - BASICTYPE_UNKNOWN, - C_NO_TYPE, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "unknown", - NULL, - NULL, - NULL, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE - }, - { - BASICTYPE_BOOLEAN, - C_LIB, - "AsnBool", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "bool", - "PrintAsnBool", - "EncAsnBool", - "DecAsnBool", - "FreeAsnBool", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_INTEGER, - C_LIB, - "AsnInt", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "int", - "PrintAsnInt", - "EncAsnInt", - "DecAsnInt", - "FreeAsnInt", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_BITSTRING, - C_LIB, - "AsnBits", - FALSE, - TRUE, - FALSE, - FALSE, - TRUE, - FALSE, - "ASNBITS_PRESENT", - "bits", - "PrintAsnBits", - "EncAsnBits", - "DecAsnBits", - "FreeAsnBits", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_OCTETSTRING, - C_LIB, - "AsnOcts", - FALSE, - TRUE, - FALSE, - FALSE, - TRUE, - FALSE, - "ASNOCTS_PRESENT", - "octs", - "PrintAsnOcts", - "EncAsnOcts", - "DecAsnOcts", - "FreeAsnOcts", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_NULL, - C_LIB, - "AsnNull", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "null", - "PrintAsnNull", - "EncAsnNull", - "DecAsnNull", - "FreeAsnNull", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_OID, - C_LIB, - "AsnOid", - FALSE, - TRUE, - FALSE, - FALSE, - TRUE, - FALSE, - "ASNOID_PRESENT", - "oid", - "PrintAsnOid", - "EncAsnOid", - "DecAsnOid", - "FreeAsnOid", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_REAL, - C_LIB, - "AsnReal", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "real", - "PrintAsnReal", - "EncAsnReal", - "DecAsnReal", - "FreeAsnReal", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_ENUMERATED, - C_LIB, - "enum", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "enum", - "PrintAsnEnum", - "EncAsnEnum", - "DecAsnEnum", - "FreeAsnEnum", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SEQUENCE, - C_STRUCT, - "struct", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "seq", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SEQUENCEOF, - C_LIST, - "AsnList", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "list", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SET, - C_STRUCT, - "struct", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "set", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SETOF, - C_LIST, - "AsnList", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "list", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_CHOICE, - C_CHOICE, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "choice", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SELECTION, - C_NO_TYPE, - NULL, - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "selection", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_COMPONENTSOF, - C_NO_TYPE, - NULL, - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "compsOf", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_ANY, - C_ANY, - "AsnAny", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "any", - "PrintAsnAny", - "EncAsnAny", - "DecAsnAny", - "FreeAsnAny", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_ANYDEFINEDBY, - C_ANYDEFINEDBY, - "AsnAnyDefinedBy", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "anyDefBy", - "PrintAsnAnyDefinedBy", - "EncAsnAnyDefinedBy", - "DecAsnAnyDefinedBy", - "FreeAsnAnyDefinedBy", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_LOCALTYPEREF, - C_TYPEREF, - NULL, - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "t", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_IMPORTTYPEREF, - C_TYPEREF, - NULL, - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "t", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_MACROTYPE, - C_NO_TYPE, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "macroType", - NULL, - NULL, - NULL, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE - }, - { - BASICTYPE_MACRODEF, - C_NO_TYPE, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "macroDef", - NULL, - NULL, - NULL, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE - } - } -}; diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules.h deleted file mode 100644 index a02c303c..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/rules.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/rules.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: rules.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:43 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:46:35 rj - * file name has been shortened for redundant part: c-gen/c-rules -> c-gen/rules. - * - * Revision 1.2 1994/10/08 03:48:16 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:36 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -/* see asn1module.h for CTDI (C type def info) */ - -typedef struct CRules -{ - int maxDigitsToAppend; - char *choiceIdFieldName; /* name of choiceId field */ - char *choiceIdEnumSuffix; /* suffix for choiceId enum def name */ - char *choiceUnionFieldName; /* what the name of the choice's union is */ - char *choiceUnionDefSuffix; /* suffix for choice union def name */ - int capitalizeNamedElmts; - char *printRoutineBaseName; /* eg if "Print" -> PrintFoo (..) */ - char *encodeRoutineBaseName; - char *decodeRoutineBaseName; - char *freeRoutineBaseName; - CTDI typeConvTbl[BASICTYPE_MACRODEF + 1]; -} CRules; - -extern CRules cRulesG; diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules2.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules2.c deleted file mode 100644 index c75660a0..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/rules2.c +++ /dev/null @@ -1,561 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/rules.c - initialized c rule structure - * inits a table that contains info about - * converting each ASN.1 type to C type - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/rules2.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: rules2.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:44 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:46:34 rj - * file name has been shortened for redundant part: c-gen/c-rules -> c-gen/rules. - * - * Revision 1.2 1994/09/01 00:24:35 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:35 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" -#include "asn1module.h" -#include "rules.h" - -/* - * (see rule.h and asn1module.h) -* -*/ - - -CRules cRulesG = -{ - 4, - "choiceId", - "ChoiceId", - "a", - "ChoiceUnion", - TRUE, - "Print", - "Enc", - "Dec", - "Free", - { - { - BASICTYPE_UNKNOWN, - C_NO_TYPE, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "unknown", - NULL, - NULL, - NULL, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE - }, - { - BASICTYPE_BOOLEAN, - C_LIB, - "AsnBool", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "bool", - "PrintAsnBool", - "EncAsnBool", - "DecAsnBool", - "FreeAsnBool", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_INTEGER, - C_LIB, - "AsnInt", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "int", - "PrintAsnInt", - "EncAsnInt", - "DecAsnInt", - "FreeAsnInt", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_BITSTRING, - C_LIB, - "AsnBits", - FALSE, - TRUE, - FALSE, - FALSE, - TRUE, - FALSE, - "ASNBITS_PRESENT", - "bits", - "PrintAsnBits", - "EncAsnBits", - "DecAsnBits", - "FreeAsnBits", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_OCTETSTRING, - C_LIB, - "AsnOcts", - FALSE, - TRUE, - FALSE, - FALSE, - TRUE, - FALSE, - "ASNOCTS_PRESENT", - "octs", - "PrintAsnOcts", - "EncAsnOcts", - "DecAsnOcts", - "FreeAsnOcts", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_NULL, - C_LIB, - "AsnNull", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "null", - "PrintAsnNull", - "EncAsnNull", - "DecAsnNull", - "FreeAsnNull", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_OID, - C_LIB, - "AsnOid", - FALSE, - TRUE, - FALSE, - FALSE, - TRUE, - FALSE, - "ASNOID_PRESENT", - "oid", - "PrintAsnOid", - "EncAsnOid", - "DecAsnOid", - "FreeAsnOid", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_REAL, - C_LIB, - "AsnReal", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "real", - "PrintAsnReal", - "EncAsnReal", - "DecAsnReal", - "FreeAsnReal", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_ENUMERATED, - C_LIB, - "enum", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - TRUE, - "NOT_NULL", - "enum", - "PrintAsnEnum", - "EncAsnEnum", - "DecAsnEnum", - "FreeAsnEnum", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SEQUENCE, - C_STRUCT, - "struct", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "seq", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SEQUENCEOF, - C_LIST, - "AsnList", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "list", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SET, - C_STRUCT, - "struct", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "set", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SETOF, - C_LIST, - "AsnList", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "list", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_CHOICE, - C_CHOICE, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "choice", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_SELECTION, - C_NO_TYPE, - NULL, - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "selection", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_COMPONENTSOF, - C_NO_TYPE, - NULL, - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "compsOf", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_ANY, - C_ANY, - "AsnAny", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "any", - "PrintAsnAny", - "EncAsnAny", - "DecAsnAny", - "FreeAsnAny", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_ANYDEFINEDBY, - C_ANYDEFINEDBY, - "AsnAnyDefinedBy", - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "anyDefBy", - "PrintAsnAnyDefinedBy", - "EncAsnAnyDefinedBy", - "DecAsnAnyDefinedBy", - "FreeAsnAnyDefinedBy", - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_LOCALTYPEREF, - C_TYPEREF, - NULL, - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "t", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_IMPORTTYPEREF, - C_TYPEREF, - NULL, - FALSE, - TRUE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "t", - NULL, - NULL, - NULL, - NULL, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE - }, - { - BASICTYPE_MACROTYPE, - C_NO_TYPE, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "macroType", - NULL, - NULL, - NULL, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE - }, - { - BASICTYPE_MACRODEF, - C_NO_TYPE, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - "NOT_NULL", - "macroDef", - NULL, - NULL, - NULL, - NULL, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE - } - } -}; diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/type-info.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/type-info.c deleted file mode 100644 index 791c82c1..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/type-info.c +++ /dev/null @@ -1,1315 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/type-info.c - fills in c type information - * - * MS 91/92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/type-info.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: type-info.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:44 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:47:45 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:26:44 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:42 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "snacc-util.h" -#include "define.h" -#include "str-util.h" -#include "rules.h" -#include "type-info.h" - - -extern Module *usefulTypeModG; -static DefinedObj *definedNamesG; -/* - * All Typedefs, union,struct & enum Tags, and definedvalues (enum consts) - * are assumed to share the same name space - this list is used to - * assure uniqueness. (actually 4 name spaces in C - see pg 227 KR 2nd Ed) - */ - - -/* unexported prototypes */ - -void FillCTypeDefInfo PROTO ((CRules *r, Module *m, TypeDef *td)); - -static void FillCFieldNames PROTO ((CRules *r, NamedTypeList *firstSibling)); - -static void FillCTypeRefInfo PROTO ((CRules *r, Module *m, TypeDef *head, Type *t, CTypeId parentTypeId)); - -static void FillCStructElmts PROTO ((CRules *r, Module *m, TypeDef *head, NamedTypeList *t)); - -static void FillCChoiceElmts PROTO ((CRules *r, Module *m, TypeDef *head, NamedTypeList *first)); - -static int IsCPtr PROTO ((CRules *r, TypeDef *td, Type *t, CTypeId parentTypeId)); - - -void ParseTypeDefAttribs PROTO ((CTDI *ctdi, AttributeList *attrList)); -void ParseTypeRefAttribs PROTO ((CTRI *ctri, AttributeList *attrList)); -void ParseAttr PROTO ((char *str, int *startLoc, char **attrName, char **attrValue)); - -int ParseBool PROTO ((char *str, int *result)); -int ParseInt PROTO ((char *str, int *result)); -int ParseCTypeId PROTO ((char *str, int *result)); - -void FillCTDIDefaults PROTO ((CRules *r, CTDI *ctdi, TypeDef *td)); - - -/* - * allocates and fills all the "cTypeDefInfo" for each type def - * and "cTypeRefInfo" for each type in the given modules. - * Also does the useful types module if it is not null. - */ -void -FillCTypeInfo PARAMS ((r, modList), - CRules *r _AND_ - ModuleList *modList) -{ - TypeDef *td; - Module *m; - - /* - * go through each module's type defs and fill - * in the C type and enc/dec routines etc - */ - definedNamesG = NewObjList(); - - /* do useful types first */ - if (usefulTypeModG != NULL) - { - FOR_EACH_LIST_ELMT (td, usefulTypeModG->typeDefs) - FillCTypeDefInfo (r, usefulTypeModG, td); - } - - FOR_EACH_LIST_ELMT (m, modList) - { - FOR_EACH_LIST_ELMT (td, m->typeDefs) - FillCTypeDefInfo (r, m, td); - } - - /* - * now that type def info is filled in - * set up set/seq/list/choice elements that ref - * those definitions - */ - - /* do useful types first */ - if (usefulTypeModG != NULL) - { - FOR_EACH_LIST_ELMT (td, usefulTypeModG->typeDefs) - FillCTypeRefInfo (r, usefulTypeModG, td, td->type, C_TYPEDEF); - } - - FOR_EACH_LIST_ELMT (m, modList) - { - FOR_EACH_LIST_ELMT (td, m->typeDefs) - FillCTypeRefInfo (r, m, td, td->type, C_TYPEDEF); - } - - /* - * modules compiled together (ie one call to snacc with - * multiple args) likely to be C compiled together so - * need a unique routines/types/defines/enum values - * since assuming they share same name space. - * All Typedefs, union, struct & enum Tags, and defined values - * (enum consts), #define names - * are assumed to share the same name space - */ - - FreeDefinedObjs (&definedNamesG); - -} /* FillCTypeInfo */ - - -/* - * allocates and fills structure holding C type definition information - * fo the given ASN.1 type definition. Does not fill CTRI for contained - * types etc. - */ -void -FillCTypeDefInfo PARAMS ((r, m, td), - CRules *r _AND_ - Module *m _AND_ - TypeDef *td) -{ - int digit; - int len; - char *tmpName; - CTDI *ctdi; - - /* - * if CTDI is present this type def has already been 'filled' - */ - if (td->cTypeDefInfo != NULL) - return; - - ctdi = td->cTypeDefInfo = MT (CTDI); - ctdi->cTypeId = C_TYPEDEF; - - /* get default type def attributes from table for type on rhs of ::= */ - - FillCTDIDefaults (r, ctdi, td); - - - /* - * if defined by a ref to another type definition fill in that type - * def's CTDI so can inherit (actully completly replace default - * attributes) from it - */ - if ((td->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (td->type->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - /* - * Fill in CTDI for defining type if nec. - * this works for importTypeRef as well since both a.localTypeRef - * and a.importTypeRef are of type TypeRef - */ - FillCTypeDefInfo (r, td->type->basicType->a.localTypeRef->module, td->type->basicType->a.localTypeRef->link); - - memcpy (ctdi, td->type->basicType->a.localTypeRef->link->cTypeDefInfo, sizeof (CTDI)); - } - - - /* - * Zap default names for routines/type with NULL so - * can determine if the --snacc attributes specified any - */ - ctdi->cTypeName = NULL; - ctdi->printRoutineName = NULL; - ctdi->encodeRoutineName = NULL; - ctdi->decodeRoutineName = NULL; - ctdi->freeRoutineName = NULL; - - - /* - * check for any "--snacc" attributes that overide the current - * ctdi fields - */ - ParseTypeDefAttribs (ctdi, td->attrList); - - - /* - * generate c typename for this type def if not given by - * --snacc attributes - */ - if (ctdi->cTypeName == NULL) - { - tmpName = Asn1TypeName2CTypeName (td->definedName); - len = strlen (tmpName); - ctdi->cTypeName = Malloc (len + r->maxDigitsToAppend + 1); - strcpy (ctdi->cTypeName, tmpName); - Free (tmpName); - - /* - * make sure c type def name is unique - * (no need to check if cTypeName was specified by --snacc attribs) - */ - MakeCStrUnique (definedNamesG, ctdi->cTypeName,r->maxDigitsToAppend, 1); - DefineObj (&definedNamesG, ctdi->cTypeName); - } - - - /* - * make names for encoder,decoder, print and free routines - * (if not already set by --snacc attributes - */ - if (ctdi->encodeRoutineName == NULL) - { - ctdi->encodeRoutineName = - Malloc (strlen (ctdi->cTypeName) + strlen (r->encodeRoutineBaseName) - + 1); - strcpy (ctdi->encodeRoutineName, r->encodeRoutineBaseName); - strcat (ctdi->encodeRoutineName, ctdi->cTypeName); - } - - if (ctdi->decodeRoutineName == NULL) - { - ctdi->decodeRoutineName = - Malloc (strlen (ctdi->cTypeName) + strlen (r->decodeRoutineBaseName) + 1); - strcpy (ctdi->decodeRoutineName, r->decodeRoutineBaseName); - strcat (ctdi->decodeRoutineName, ctdi->cTypeName); - } - - if (ctdi->printRoutineName == NULL) - { - ctdi->printRoutineName = - Malloc (strlen (ctdi->cTypeName) + strlen (r->printRoutineBaseName) + 1); - strcpy (ctdi->printRoutineName, r->printRoutineBaseName); - strcat (ctdi->printRoutineName, ctdi->cTypeName); - } - - if (ctdi->freeRoutineName == NULL) - { - ctdi->freeRoutineName = - Malloc (strlen (ctdi->cTypeName) + strlen (r->freeRoutineBaseName) + 1); - strcpy (ctdi->freeRoutineName, r->freeRoutineBaseName); - strcat (ctdi->freeRoutineName, ctdi->cTypeName); - } - -} /* FillCTypeDefInfo */ - - -static void -FillCTypeRefInfo PARAMS ((r, m, head, t, parentTypeId), - CRules *r _AND_ - Module *m _AND_ - TypeDef *head _AND_ - Type *t _AND_ - CTypeId parentTypeId) -{ - char *typeStr; - CTRI *ctri; - CTDI *tmpCtdi; - ValueDef *namedElmt; - CNamedElmt *cne; - CNamedElmt **cneHndl; - char *elmtName; - char *listName; - char *choiceName; - char *unionName; - Type *tmpT; - int len, digit; - enum BasicTypeChoiceId basicTypeId; - - /* - * you must check for cycles yourself before calling this - */ - if (t->cTypeRefInfo == NULL) - { - ctri = MT (CTRI); - t->cTypeRefInfo = ctri; - } - else - ctri = t->cTypeRefInfo; - - basicTypeId = t->basicType->choiceId; - - tmpCtdi = &r->typeConvTbl[basicTypeId]; - - /* get base type def info from the conversion table in the rules */ - /* if the cTypeId is C_LIB, nothing more needs to be done */ - ctri->cTypeId = tmpCtdi->cTypeId; - ctri->cTypeName = tmpCtdi->cTypeName; - ctri->optTestRoutineName = tmpCtdi->optTestRoutineName; - ctri->printRoutineName = tmpCtdi->printRoutineName; - ctri->encodeRoutineName = tmpCtdi->encodeRoutineName; - ctri->decodeRoutineName = tmpCtdi->decodeRoutineName; - ctri->freeRoutineName = tmpCtdi->freeRoutineName; - ctri->isEncDec = tmpCtdi->isEncDec; - - - if (ctri->cTypeId == C_ANY) - { - fprintf (stderr,"Warning - generated code for the \"ANY\" type in type \"%s\" will need modification by YOU.", head->definedName); - fprintf (stderr," The source files will have a \"/* ANY - Fix Me! */\" comment before related code.\n\n"); - } - - /* - * convert named elmts to C. - * check for name conflict with other defined Types/Names/Values - */ - if ((basicTypeId == BASICTYPE_INTEGER || basicTypeId == BASICTYPE_ENUMERATED || basicTypeId == BASICTYPE_BITSTRING) && !(LIST_EMPTY (t->basicType->a.integer))) - { - ctri->cNamedElmts = AsnListNew (sizeof (void *)); - FOR_EACH_LIST_ELMT (namedElmt, t->basicType->a.integer) - { - cneHndl = (CNamedElmt **)AsnListAppend (ctri->cNamedElmts); - cne = *cneHndl = MT (CNamedElmt); - elmtName = Asn1ValueName2CValueName (namedElmt->definedName); - len = strlen (elmtName); - cne->name = Malloc (len + 1 + r->maxDigitsToAppend); - strcpy (cne->name, elmtName); - Free (elmtName); /* not very efficient */ - - if (namedElmt->value->basicValue->choiceId == BASICVALUE_INTEGER) - cne->value = namedElmt->value->basicValue->a.integer; - else - { - fprintf (stderr,"Warning: unlinked defined value using -9999999\n"); - cne->value = -9999999; - } - - if (r->capitalizeNamedElmts) - Str2UCase (cne->name, len); - - /* - * append digits until there is not name conflict - * if nec - */ - MakeCStrUnique (definedNamesG, cne->name, r->maxDigitsToAppend, 1); - DefineObj (&definedNamesG, cne->name); - } - } - - /* - * Fill in c type name, routines, ptr attibutes etc - */ - if (r->typeConvTbl[basicTypeId].cTypeId == C_TYPEREF) - { - /* - * don't do this anymore - it cause problems since FillTypeDef - * changes name ie ORName -> ORName1 and other type use new name - * - * don't define type or print/enc/dec/free routines - * if typedef name is the same as the defining type ref name - * in P2: ORName ::= P1.ORName - if ((parentTypeId == C_TYPEDEF) && - (strcmp (head->definedName, t->basicType->a.localTypeRef->typeName) - == 0)) - { - tmpCtdi = head->cTypeDefInfo; - tmpCtdi->genPrintRoutine = FALSE; - tmpCtdi->genEncodeRoutine = FALSE; - tmpCtdi->genDecodeRoutine = FALSE; - tmpCtdi->genFreeRoutine = FALSE; - tmpCtdi->genTypeDef = FALSE; - } - */ - - /* - * grab type name from link (link is the def of the - * the ref'd type) - */ - if (t->basicType->a.localTypeRef->link != NULL) - { - /* inherit attributes from referenced type */ - tmpCtdi= t->basicType->a.localTypeRef->link->cTypeDefInfo; - ctri->cTypeName = tmpCtdi->cTypeName; - ctri->printRoutineName = tmpCtdi->printRoutineName; - ctri->encodeRoutineName = tmpCtdi->encodeRoutineName; - ctri->decodeRoutineName = tmpCtdi->decodeRoutineName; - ctri->freeRoutineName = tmpCtdi->freeRoutineName; - ctri->isEncDec = tmpCtdi->isEncDec; - ctri->optTestRoutineName = tmpCtdi->optTestRoutineName; - - } - else - { - /* - * guess type and routine names - */ - fprintf (stderr,"Assuming C Type and Routine names for unresolved type ref \"%s\"\n",t->basicType->a.localTypeRef->typeName); - - ctri->cTypeName = Asn1TypeName2CTypeName (t->basicType->a.localTypeRef->typeName); - - ctri->printRoutineName = Malloc (strlen (r->printRoutineBaseName) + strlen (ctri->cTypeName) + 1); - strcpy (ctri->printRoutineName, r->printRoutineBaseName); - strcat (ctri->printRoutineName, ctri->cTypeName); - - ctri->encodeRoutineName = Malloc (strlen (r->encodeRoutineBaseName)+ strlen (ctri->cTypeName) + 1); - strcpy (ctri->encodeRoutineName, r->encodeRoutineBaseName); - strcat (ctri->encodeRoutineName, ctri->cTypeName); - - ctri->decodeRoutineName = Malloc (strlen (r->decodeRoutineBaseName)+ strlen (ctri->cTypeName) + 1); - strcpy (ctri->decodeRoutineName, r->decodeRoutineBaseName); - strcat (ctri->decodeRoutineName, ctri->cTypeName); - - ctri->freeRoutineName = Malloc (strlen (ctri->cTypeName) + strlen (r->freeRoutineBaseName) + 1); - strcpy (ctri->freeRoutineName, r->freeRoutineBaseName); - strcat (ctri->freeRoutineName, ctri->cTypeName); - } - - } - - else if (r->typeConvTbl[basicTypeId].cTypeId == C_LIST) - { - /* - * List types (SET OF/ SEQ OF) - * fill in component type - */ - - FillCTypeRefInfo (r, m, head, t->basicType->a.setOf, C_LIST); - } - - else if (r->typeConvTbl[basicTypeId].cTypeId == C_CHOICE) - { - /* - * Choice - set up choice Id elmt names, choiceid enum name - * choiceid enum fieldName, choice union name. - * this will only be the first type in the typedef - * ie will not be embedded (those are turned into type - * refs in nomalize.c) - */ - - /* - * make union name (tag) from enclosing typedefs name plus "Choice" - * put in the cTypeName part. (the typeDef name is already unique - * but make sure union tag/name does not conflict with other types) - */ - len = strlen (head->cTypeDefInfo->cTypeName); - unionName = (char*) Malloc (len + strlen (r->choiceUnionDefSuffix) + r->maxDigitsToAppend + 1); - strcpy (unionName, head->cTypeDefInfo->cTypeName); - strcat (unionName, r->choiceUnionDefSuffix); - MakeCStrUnique (definedNamesG, unionName, r->maxDigitsToAppend, 1); - DefineObj (&definedNamesG, unionName); - ctri->cTypeName = unionName; - - ctri->choiceIdEnumName = Malloc (len + strlen (r->choiceIdEnumSuffix) + r->maxDigitsToAppend + 1); - strcpy (ctri->choiceIdEnumName, head->cTypeDefInfo->cTypeName); - strcat (ctri->choiceIdEnumName, r->choiceIdEnumSuffix); - MakeCStrUnique (definedNamesG, ctri->choiceIdEnumName, r->maxDigitsToAppend, 1); - DefineObj (&definedNamesG, ctri->choiceIdEnumName); - - ctri->choiceIdEnumFieldName = r->choiceIdFieldName; /* "choiceId" */ - ctri->cFieldName = r->choiceUnionFieldName; /* "a" */ - - /* - * must fill field names BEFORE filling choice elmts - * (allows better naming for choice ids - */ - FillCFieldNames (r, t->basicType->a.choice); - FillCChoiceElmts (r, m, head, t->basicType->a.choice); - - } - - else if (r->typeConvTbl[basicTypeId].cTypeId == C_STRUCT) - { - /* - * SETs and SEQUENCEs - */ - - /* - * make struct name (tag) (the typeDef name is already unique) - * the same as the enclosing typeDef - */ - unionName = Malloc (strlen (head->cTypeDefInfo->cTypeName) +1); - strcpy (unionName, head->cTypeDefInfo->cTypeName); - ctri->cTypeName = unionName; - - FillCStructElmts (r, m, head, t->basicType->a.set); - FillCFieldNames (r, t->basicType->a.set); - } - - /* - * figure out whether this is a ptr based on the enclosing - * type (if any) and optionality/default - */ - ctri->isPtr = IsCPtr (r, head, t, parentTypeId); - - /* let user overide any defaults with the --snacc attributes */ - ParseTypeRefAttribs (ctri, t->attrList); - - -} /* FillCTypeRefInfo */ - - - -static void -FillCStructElmts PARAMS ((r, m, head, elmts), - CRules *r _AND_ - Module *m _AND_ - TypeDef *head _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - - FOR_EACH_LIST_ELMT (et, elmts) - { - FillCTypeRefInfo (r, m, head, et->type, C_STRUCT); - } - -} /* FillCStructElmts */ - - - -/* - * Figures out non-conflicting enum names for the - * choice id's - */ -static void -FillCChoiceElmts PARAMS ((r, m, head, elmts), - CRules *r _AND_ - Module *m _AND_ - TypeDef *head _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - int idCount = 0; - CTRI *ctri; - char *firstName; - char *secondName; - int len; - - /* - * fill in type info for elmt types first - */ - FOR_EACH_LIST_ELMT (et, elmts) - FillCTypeRefInfo (r, m, head, et->type, C_CHOICE); - - /* - * set choiceId Symbol & value - * eg - * Car ::= CHOICE { typedef struct Car { - * chev ChevCar, -> enum CarChoiceId { - * ford FordCar CAR_CHEV, <- typename_fieldName - * toyota ToyotaCar CAR_FORD, - * } CAR_TOYOTA } choiceId; - * union CarChoiceUnion { - * ChevCar *chev; - * FordCar *ford; - * ToyotaCar *toyota; } a; - * } - */ - FOR_EACH_LIST_ELMT (et, elmts) - { - ctri = et->type->cTypeRefInfo; - - if (ctri == NULL) - continue; /* wierd type */ - - ctri->choiceIdValue = idCount++; - - firstName = Asn1TypeName2CTypeName (head->cTypeDefInfo->cTypeName); - secondName = ctri->cFieldName; - ctri->choiceIdSymbol = Malloc (strlen (firstName) + strlen (secondName) + 2 + r->maxDigitsToAppend); - strcpy (ctri->choiceIdSymbol, firstName); - strcat (ctri->choiceIdSymbol, "_"); - strcat (ctri->choiceIdSymbol, secondName); - Free (firstName); - len = strlen (ctri->choiceIdSymbol); - - if (r->capitalizeNamedElmts) - Str2UCase (ctri->choiceIdSymbol, len); - - MakeCStrUnique (definedNamesG, ctri->choiceIdSymbol, r->maxDigitsToAppend, 0); - DefineObj (&definedNamesG, ctri->choiceIdSymbol); - } - -} /* FillCChoiceElmts */ - - -/* - * takes a list of "sibling" (eg same level in a structure) - * ElmtTypes and fills sets up the c field names in - * the CTypeRefInfo struct - */ -static void -FillCFieldNames PARAMS ((r, elmts), - CRules *r _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - CTRI *ctri; - DefinedObj *fieldNames; - int len, num, digit, i, tmpLen; - char *tmpName; - char *asn1FieldName; - char *cFieldName; - - fieldNames = NewObjList(); - - /* - * Initialize fieldname data - * allocate (if nec) and fill in CTRI fieldname if poss - * from asn1 field name. leave blank otherwise - */ - FOR_EACH_LIST_ELMT (et, elmts) - { - ctri = et->type->cTypeRefInfo; - if (ctri == NULL) - { - ctri = MT (CTRI); - et->type->cTypeRefInfo = ctri; - } - if (et->fieldName != NULL) - { - asn1FieldName = et->fieldName; - ctri->cFieldName = Asn1FieldName2CFieldName (asn1FieldName); - DefineObj (&fieldNames, ctri->cFieldName); - } - } - - - FOR_EACH_LIST_ELMT (et, elmts) - { - ctri = et->type->cTypeRefInfo; - - /* - * generate field names for those without them - */ - if (ctri->cFieldName == NULL) - { - if ((et->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (et->type->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - /* - * take ref'd type name as field name - * convert first let to lower case - */ - tmpName = et->type->basicType->a.localTypeRef->link->cTypeDefInfo->cTypeName; - tmpName = Asn1TypeName2CTypeName (tmpName); - cFieldName = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); - strcpy (cFieldName, tmpName); - Free (tmpName); - if (isupper (cFieldName[0])) - cFieldName[0] = tolower (cFieldName[0]); - } - else - { - /* - * get default field name for this type - */ - tmpName = r->typeConvTbl[et->type->basicType->choiceId].defaultFieldName; - cFieldName = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); - strcpy (cFieldName, tmpName); - - if (isupper (cFieldName[0])) - cFieldName[0] = tolower (cFieldName[0]); - } - - - MakeCStrUnique (fieldNames, cFieldName, r->maxDigitsToAppend, 1); - - DefineObj (&fieldNames, cFieldName); - ctri->cFieldName = cFieldName; - } - } - FreeDefinedObjs (&fieldNames); -} /* FillCFieldNames */ - - - -/* - * returns true if this c type for this type should be - * be ref'd as a ptr - */ -static int -IsCPtr PARAMS ((r, td, t, parentCTypeId), - CRules *r _AND_ - TypeDef *td _AND_ - Type *t _AND_ - CTypeId parentCTypeId) -{ - CTDI *ctdi; - int retVal = FALSE; - - /* - * inherit ptr attriubutes from ref'd type if any - * otherwise grab lib c type def from the CRules - */ - if ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - ctdi = t->basicType->a.localTypeRef->link->cTypeDefInfo; - } - else - ctdi = &r->typeConvTbl[GetBuiltinType (t)]; - - if ((parentCTypeId == C_TYPEDEF) && (ctdi->isPtrForTypeDef)) - retVal = TRUE; - - else if ((parentCTypeId == C_STRUCT) && (ctdi->isPtrForTypeRef)) - retVal = TRUE; - - else if ((parentCTypeId == C_CHOICE) && (ctdi->isPtrInChoice)) - retVal = TRUE; - - else if (((t->optional) || (t->defaultVal != NULL)) && (ctdi->isPtrForOpt)) - retVal = TRUE; - - return retVal; -} /* IsCPtr */ - - - -#define BAD_VALUE(attrValue, attrType)\ - fprintf (stderr,"Warning: ignoring attribute with improper value (%s/%s)\n",attrType, attrValue) - -/* - * attrList is a list of strings that hold attribute value - * pairs. A list is used in case the attr/value pairs are - * given in multiple ASN.1 comments around the type. - */ -void ParseTypeDefAttribs PARAMS ((ctdi, attrList), - CTDI *ctdi _AND_ - AttributeList *attrList) -{ - char *attrName; - char *attrValue; - int loc; - MyString attr; - int result; - - if (attrList == NULL) - return; - - FOR_EACH_LIST_ELMT (attr, attrList) - { - loc = 0; /* loc is location to start/continue parse from */ - - while (1) - { - ParseAttr (attr, &loc, &attrName, &attrValue); - - if (attrName == NULL) - break; - - if (strcmp (attrName, "asn1TypeId") == 0) - { - if (ParseTypeId (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->asn1TypeId = result; - Free (attrValue); - } - else if (strcmp (attrName, "cTypeId") == 0) - { - if (ParseCTypeId (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->cTypeId = result; - Free (attrValue); - } - else if (strcmp (attrName, "cTypeName") == 0) - ctdi->cTypeName = attrValue; - - else if (strcmp (attrName, "isPdu") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->isPdu = result; - Free (attrValue); - } - else if (strcmp (attrName, "isPtrForTypeDef") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->isPtrForTypeDef = result; - Free (attrValue); - } - else if (strcmp (attrName, "isPtrForTypeRef") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->isPtrForTypeRef = result; - Free (attrValue); - } - else if (strcmp (attrName, "isPtrInChoice") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->isPtrInChoice = result; - Free (attrValue); - } - else if (strcmp (attrName, "isPtrForOpt") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->isPtrForOpt = result; - Free (attrValue); - } - else if (strcmp (attrName, "optTestRoutineName") == 0) - ctdi->optTestRoutineName = attrValue; - - else if (strcmp (attrName, "defaultFieldName") == 0) - ctdi->defaultFieldName = attrValue; - - else if (strcmp (attrName, "printRoutineName") == 0) - ctdi->printRoutineName = attrValue; - - else if (strcmp (attrName, "encodeRoutineName") == 0) - ctdi->encodeRoutineName = attrValue; - - else if (strcmp (attrName, "decodeRoutineName") == 0) - ctdi->decodeRoutineName = attrValue; - - else if (strcmp (attrName, "freeRoutineName") == 0) - ctdi->freeRoutineName = attrValue; - - else if (strcmp (attrName, "isEncDec") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - { - ctdi->isEncDec = result; - } - Free (attrValue); - } - else if (strcmp (attrName, "genTypeDef") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - { - ctdi->genTypeDef = result; - } - Free (attrValue); - } - else if (strcmp (attrName, "genPrintRoutine") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->genPrintRoutine = result; - Free (attrValue); - } - else if (strcmp (attrName, "genEncodeRoutine") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->genEncodeRoutine = result; - Free (attrValue); - } - else if (strcmp (attrName, "genDecodeRoutine") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->genDecodeRoutine = result; - Free (attrValue); - } - else if (strcmp (attrName, "genFreeRoutine") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctdi->genFreeRoutine = result; - Free (attrValue); - } - - else - fprintf (stderr,"Warning: ignoring unrecognized type def attribute value pair (%s/%s)\n", attrName, attrValue); - - } /* end while */ - } /* end for */ - -} /* ParseTypeDefAttribs */ - - -void ParseTypeRefAttribs PARAMS ((ctri, attrList), - CTRI *ctri _AND_ - AttributeList *attrList) -{ - char *attrName; - char *attrValue; - int loc; - int result; - MyString attr; - - if (attrList == NULL) - return; - - FOR_EACH_LIST_ELMT (attr, attrList) - { - loc = 0; /* loc is location to start/continue parse from */ - - while (1) - { - ParseAttr (attr, &loc, &attrName, &attrValue); - - if (attrName == NULL) - break; - - if (strcmp (attrName, "cTypeId") == 0) - { - if (ParseCTypeId (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctri->cTypeId = result; - Free (attrValue); - } - else if (strcmp (attrName, "cTypeName") == 0) - ctri->cTypeName = attrValue; - - else if (strcmp (attrName, "cFieldName") == 0) - ctri->cFieldName = attrValue; - - else if (strcmp (attrName, "isPtr") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctri->isPtr = result; - Free (attrValue); - } - else if (strcmp (attrName, "choiceIdValue") == 0) - { - if (ParseInt (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctri->choiceIdValue = result; - Free (attrValue); - } - else if (strcmp (attrName, "choiceIdSymbol") == 0) - ctri->choiceIdSymbol = attrValue; - - else if (strcmp (attrName, "choiceIdEnumName") == 0) - ctri->choiceIdEnumName = attrValue; - - else if (strcmp (attrName, "choiceIdEnumFieldName") == 0) - ctri->choiceIdEnumFieldName = attrValue; - - else if (strcmp (attrName, "optTestRoutineName") == 0) - ctri->optTestRoutineName = attrValue; - - else if (strcmp (attrName, "printRoutineName") == 0) - ctri->printRoutineName = attrValue; - - else if (strcmp (attrName, "encodeRoutineName") == 0) - ctri->encodeRoutineName = attrValue; - - else if (strcmp (attrName, "decodeRoutineName") == 0) - ctri->decodeRoutineName = attrValue; - - else if (strcmp (attrName, "isEncDec") == 0) - { - if (ParseBool (attrValue, &result) < 0) - BAD_VALUE (attrValue, attrName); - else - ctri->isEncDec = result; - Free (attrValue); - } - - else - fprintf (stderr,"Warning: ignoring unrecognized type ref attribute value pair (%s/%s)\n", attrName, attrValue); - - - } /* end while/ per comment */ - } /* end per att str */ -} /* ParseTypeRefAttribs */ - - -int -ParseBool PARAMS ((str, result), - char *str _AND_ - int *result) -{ - if (strcmp (str,"TRUE")==0) - { - *result = TRUE; - return 0; - } - - if (strcmp (str,"FALSE")==0) - { - *result = FALSE; - return 0; - } - return -1; -} - -int -ParseInt PARAMS ((str, result), - char *str _AND_ - int *result) -{ - *result = atoi (str); - return 0; -} - -int -ParseCTypeId PARAMS ((str, result), - char *str _AND_ - int *result) -{ - if (strcmp (str,"C_CHOICE")) - { - *result = C_CHOICE; - return 0; - } - if (strcmp (str,"C_LIST")) - { - *result = C_LIST; - return 0; - } - if (strcmp (str,"C_ANY")) - { - *result = C_ANY; - return 0; - } - if (strcmp (str,"C_ANYDEFINEDBY")) - { - *result = C_ANYDEFINEDBY; - return 0; - } - if (strcmp (str,"C_LIB")) - { - *result = C_LIB; - return 0; - } - if (strcmp (str,"C_STRUCT")) - { - *result = C_STRUCT; - return 0; - } - if (strcmp (str,"C_TYPEREF")) - { - *result = C_TYPEREF; - return 0; - } - if (strcmp (str,"C_TYPEDEF")) - { - *result = C_TYPEDEF; - return 0; - } - if (strcmp (str,"C_NO_TYPE")) - { - *result = C_NO_TYPE; - return 0; - } - return -1; -} - -int -ParseTypeId PARAMS ((str, result), - char *str _AND_ - int *result) -{ - if (strcmp (str,"UNKNOWN")) - { - *result = BASICTYPE_UNKNOWN; - return 0; - } - if (strcmp (str,"BOOLEAN")) - { - *result = BASICTYPE_BOOLEAN; - return 0; - } - if (strcmp (str,"INTEGER")) - { - *result = BASICTYPE_INTEGER; - return 0; - } - if (strcmp (str,"BITSTRING")) - { - *result = BASICTYPE_BITSTRING; - return 0; - } - if (strcmp (str,"OCTETSTRING")) - { - *result = BASICTYPE_OCTETSTRING; - return 0; - } - if (strcmp (str,"NULL")) - { - *result = BASICTYPE_NULL; - return 0; - } - if (strcmp (str,"OID")) - { - *result = BASICTYPE_OID; - return 0; - } - if (strcmp (str,"REAL")) - { - *result = BASICTYPE_REAL; - return 0; - } - if (strcmp (str,"ENUMERATED")) - { - *result = BASICTYPE_ENUMERATED; - return 0; - } - if (strcmp (str,"SEQUENCE")) - { - *result = BASICTYPE_SEQUENCE; - return 0; - } - if (strcmp (str,"SEQUENCEOF")) - { - *result = BASICTYPE_SEQUENCEOF; - return 0; - } - if (strcmp (str,"SET")) - { - *result = BASICTYPE_SET; - return 0; - } - if (strcmp (str,"SETOF")) - { - *result = BASICTYPE_SETOF; - return 0; - } - if (strcmp (str,"CHOICE")) - { - *result = BASICTYPE_CHOICE; - return 0; - } - if (strcmp (str,"ANY")) - { - *result = BASICTYPE_ANY; - return 0; - } - if (strcmp (str,"ANYDEFINEDBY")) - { - *result = BASICTYPE_ANYDEFINEDBY; - return 0; - } - if (strcmp (str,"LOCALTYPEREF")) - { - *result = BASICTYPE_LOCALTYPEREF; - return 0; - } - if (strcmp (str,"IMPORTYPEREF")) - { - *result = BASICTYPE_IMPORTTYPEREF; - return 0; - } - return -1; -} /* ParseTypeId */ - - -/* - * read attribute value pair from given str starting - * at str[loc]. Allocate and return attibute value - * in the attrValue parameter. The attribute name is - * returned in the attrName parameter - do not free this - * as it is statically defined and overwritten with - * each call to ParseAttr. - * str must be NULL terminated. - * - */ -void -ParseAttr PARAMS ((str, startLoc, attrName, attrValue), - char *str _AND_ - int *startLoc _AND_ - char **attrName _AND_ - char **attrValue) -{ - int len; - int loc; - int attrNameStart; - int attrNameEnd; - int attrValueStart; - int attrValueEnd; - static char retAttrName[200]; - char *retAttrValue; - - loc = *startLoc; - - len = strlen (str)-1; - - /* skip whitespc */ - for (; (loc <= len) && str[loc] == ' '; loc++) - ; - - if (loc >= len) - { - *attrName = NULL; - *attrValue = NULL; - return; - } - - attrNameStart = loc; - - for (; (loc <= len) && str[loc] != ':'; loc++) - ; - - if (loc > len) - { - *attrName = NULL; - *attrValue = NULL; - return; - } - - attrNameEnd = loc-1; - - loc++; /* skip: */ - - /* check for and skip " */ - if (str[loc++] != '"') - { - *attrName = NULL; - *attrValue = NULL; - fprintf (stderr,"ERROR in snacc comment attribute string \"%s\". Missing quote at beggining of field value\n",str); - return; - } - - attrValueStart = loc; - - for (; (loc <= len) && str[loc] != '"'; loc++) - ; - - attrValueEnd = loc-1; - - if ((loc > len) || (str[attrValueStart-1] != '"')) - { - *attrName = NULL; - *attrValue = NULL; - fprintf (stderr,"Parsing Error after position %d in snacc attribute string \"%s\".\n",*startLoc, str); - return; - } - - *startLoc = loc + 1; - retAttrValue = (char*) Malloc (attrValueEnd - attrValueStart + 2); - strncpy (retAttrName, &str[attrNameStart], attrNameEnd-attrNameStart+1); - strncpy (retAttrValue, &str[attrValueStart], attrValueEnd-attrValueStart+1); - retAttrValue[attrValueEnd-attrValueStart+1] = '\0'; - retAttrName[attrNameEnd-attrNameStart+1] = '\0'; - - *attrName = retAttrName; - *attrValue = retAttrValue; -} /* ParseAttr */ - - - -/* fill given ctdi with defaults from table for given typedef */ -void -FillCTDIDefaults PARAMS ((r, ctdi, td), - CRules *r _AND_ - CTDI *ctdi _AND_ - TypeDef *td) -{ - CTDI *tblCtdi; - int typeIndex; - - typeIndex = GetBuiltinType (td->type); - - if (typeIndex < 0) - return; - - tblCtdi = &r->typeConvTbl[typeIndex]; - - memcpy (ctdi, tblCtdi, sizeof (CTDI)); - -} diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/type-info.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/type-info.h deleted file mode 100644 index 7799a988..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/type-info.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/type-info.h - fills in c type information - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/type-info.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: type-info.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:44 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:47:46 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:20 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:43 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -/* -typedef struct CNamedElmt -{ - struct CNamedElmt *next; - int value; - char *name; -} CNamedElmt; - - - -typedef struct CTypeInfo -{ - CTypeId cTypeId; - char *cFieldName; - char *cTypeName; - int isPtr; - int isEndCType; - CNamedElmt *cNamedElmts; - int choiceIdValue; - char *choiceIdSymbol; - char *choiceIdEnumName; - char *choiceIdEnumFieldName; - char *printRoutineName; - char *encodeRoutineName; - char *decodeRoutineName; -} CTypeInfo; - - -*/ - -/* - * allows upto 9999 unamed fields of the same type in a single structure - * or 9999 values (diff asn1 scopes -> global c scope) with same name - */ - -/* -#define MAX_C_FIELD_NAME_DIGITS 4 -#define MAX_C_VALUE_NAME_DIGITS 4 -#define MAX_C_TYPE_NAME_DIGITS 4 -#define MAX_C_ROUTINE_NAME_DIGITS 4 - -*/ - -void PrintCTypeInfo PROTO ((FILE *f, Type *t)); - -void FillCTypeInfo PROTO ((CRules *r, ModuleList *m)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/util.c b/SecuritySNACCRuntime/compiler/back-ends/c-gen/util.c deleted file mode 100644 index 1ed36b72..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/util.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/util.c - utilities for generating C encoders and decoders - * - * MS 91/11/04 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/util.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: util.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:44 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:48:38 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:26:52 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:44 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "rules.h" -#include "snacc-util.h" -#include "util.h" - - -void -MakeVarPtrRef PARAMS ((r, td, parent, fieldType, parentVarName, newVarName), - CRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *fieldType _AND_ - char *parentVarName _AND_ - char *newVarName) -{ - CTRI *ctri; - - ctri = fieldType->cTypeRefInfo; - - /* always put in brackets to save future referencing hassles */ - strcpy (newVarName, "("); - - /* make ref'd field into a ptr by taking it's addr if nec */ - if (!ctri->isPtr) - strcat (newVarName, "&"); - - /* start with ref to parent */ - strcat (newVarName, parentVarName); - - /* ref this field */ - if ((td->type == parent) || (parent->cTypeRefInfo->isPtr)) - strcat (newVarName, "->"); - else - strcat (newVarName, "."); - - /* ref choice union field if nec */ - if (parent->basicType->choiceId == BASICTYPE_CHOICE) - { - strcat (newVarName, r->choiceUnionFieldName); - strcat (newVarName, "."); - } - - strcat (newVarName, ctri->cFieldName); - strcat (newVarName, ")"); - -} /* MakeVarPtrRef */ - - - - -void -MakeVarValueRef PARAMS ((r, td, parent, fieldType, parentVarName, newVarName), - CRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *fieldType _AND_ - char *parentVarName _AND_ - char *newVarName) -{ - CTRI *ctri; - - ctri = fieldType->cTypeRefInfo; - - /* always put in brackets to save future referencing hassles */ - strcpy (newVarName, "("); - - /* make ref'd field into a value by de-referencing if nec */ - if (ctri->isPtr) - strcat (newVarName, "*"); - - /* start with ref to parent */ - strcat (newVarName, parentVarName); - - /* ref this field */ - if ((td->type == parent) || (parent->cTypeRefInfo->isPtr)) - strcat (newVarName, "->"); - else - strcat (newVarName, "."); - - /* ref choice union field if nec */ - if (parent->basicType->choiceId == BASICTYPE_CHOICE) - { - strcat (newVarName, r->choiceUnionFieldName); - strcat (newVarName, "."); - } - - strcat (newVarName, ctri->cFieldName); - strcat (newVarName, ")"); - -} /* MakeVarValueRef */ - -void -MakeChoiceIdValueRef PARAMS ((r, td, parent, fieldType, parentVarName, newVarName), - CRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *fieldType _AND_ - char *parentVarName _AND_ - char *newVarName) -{ - CTRI *ctri; - - ctri = fieldType->cTypeRefInfo; - - /* always put in brackets to save future referencing hassles */ - strcpy (newVarName, "("); - - /* start with ref to parent */ - strcat (newVarName, parentVarName); - - /* ref this field */ - if ((td->type == parent) || (parent->cTypeRefInfo->isPtr)) - strcat (newVarName, "->"); - else - strcat (newVarName, "."); - - strcat (newVarName, parent->cTypeRefInfo->choiceIdEnumFieldName); - strcat (newVarName, ")"); - -} /* MakeChoiceIdValueRef */ - - -void -PrintElmtAllocCode PARAMS ((src, type, varRefPtrName), - FILE *src _AND_ - Type *type _AND_ - char *varRefPtrName) -{ - CTRI *ctri1; - CTRI *ctri2; - Type *t; - - t = GetType (type); - ctri1 = type->cTypeRefInfo; - ctri2 = t->cTypeRefInfo; - if (ctri1->isPtr) - { - if (ctri2->cTypeId == C_LIST) - fprintf (src, " %s = AsnListNew (sizeof (char*));\n", varRefPtrName); - else - fprintf (src, " %s = (%s*) Asn1Alloc (sizeof (%s));\n", varRefPtrName, ctri1->cTypeName, ctri1->cTypeName); - fprintf (src," CheckAsn1Alloc (%s, env);\n", varRefPtrName); - } - -} /* PrintElmtAllocCode */ - - -/* - * prints code to decode EOCs for the lengths that go with extra tagging - * maxLenLevel - the highest used length variable (ie 2 for elmtLen2) - * minLenLevel - the lowest valid length variable (ie 0 for elmtLen0) - * lenBaseVarName - len var name sans number (ie elmtLen for elmtLen2) - * totalLevel - current level for the running total - * totalBaseName - total var name sans number - * (ie totalElmtLen for totalElmtLen1) - */ -void -PrintEocDecoders PARAMS ((f, maxLenLevel, minLenLevel, lenBaseVarName, totalLevel, totalBaseVarName), - FILE *f _AND_ - int maxLenLevel _AND_ - int minLenLevel _AND_ - char *lenBaseVarName _AND_ - int totalLevel _AND_ - char *totalBaseVarName) -{ - int i; - for (i = maxLenLevel; i > minLenLevel; i--) - { - fprintf (f," if (%s%d == INDEFINITE_LEN)\n", lenBaseVarName, i); - fprintf (f," BDecEoc (b, &%s%d, env);\n", totalBaseVarName, totalLevel); - } -} /* PrintEocDeocoders */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/c-gen/util.h b/SecuritySNACCRuntime/compiler/back-ends/c-gen/util.h deleted file mode 100644 index ad895e44..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/c-gen/util.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back-ends/c-gen/util.c - C encoder/decode related utility routines - * - * MS 91/11/04 - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/Attic/util.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: util.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:44 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:48:39 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:21 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:45 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -#define FIRST_LEVEL 1 /* must be 1 or greater */ -#define MAX_VAR_REF 512 /* max chars for ref'ing a var eg v->foo->bar.x->v*/ - -void MakeVarPtrRef PROTO ((CRules *r, TypeDef *td, Type *parent, Type *fieldType, char *parentVarName, char *newVarName)); - -void MakeVarValueRef PROTO ((CRules *r, TypeDef *td, Type *parent, Type *fieldType, char *parentVarName, char *newVarName)); - -void MakeChoiceIdValueRef PROTO ((CRules *r, TypeDef *td, Type *parent, Type *fieldType, char *parentVarName, char *newVarName)); - -void PrintElmtAllocCode PROTO ((FILE *f, Type *type, char *varPtrRefName)); - -void PrintEocDecoders PROTO ((FILE *f, int maxLenLevel, int minLenLevel, char *lenBaseVarName, int totalLevel, char *totalBaseVarName)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/cond.c b/SecuritySNACCRuntime/compiler/back-ends/cond.c deleted file mode 100644 index 96358269..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/cond.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/cond.c - generate conditional include for C(++) hdr files - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/Attic/cond.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: cond.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:38 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/25 19:13:49 rj - * PrintConditionalIncludeOpen() and PrintConditionalIncludeClose() moved from back-ends/c-gen/gen-code.[ch]. - * - */ - -#include "asn-incl.h" -#include "cond.h" - - -void -PrintConditionalIncludeOpen PARAMS ((f, fileName), - FILE *f _AND_ - char *fileName) -{ - char hdrFileDefSym[256]; - int i; - - strcpy (hdrFileDefSym, fileName); - for (i = 0; i < strlen (hdrFileDefSym); i++) - if (hdrFileDefSym[i] == '-' || hdrFileDefSym[i] == '.') - hdrFileDefSym[i] = '_'; - - fprintf (f, "#ifndef _%s_\n", hdrFileDefSym); - fprintf(f, "#define _%s_\n\n\n", hdrFileDefSym); -} /* PrintConditionalIncludeOpen */ - - -void -PrintConditionalIncludeClose PARAMS ((f, fileName), - FILE *f _AND_ - char *fileName) -{ - fprintf (f, "\n#endif /* conditional include of %s */\n", fileName); - -} /* PrintConditionalIncludeClose */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/cond.h b/SecuritySNACCRuntime/compiler/back-ends/cond.h deleted file mode 100644 index aafe8a8c..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/cond.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/cond.h - generate conditional include for C(++) hdr files - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/Attic/cond.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: cond.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:38 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1995/07/25 19:13:50 rj - * PrintConditionalIncludeOpen() and PrintConditionalIncludeClose() moved from back-ends/c-gen/gen-code.[ch]. - * - * Revision 1.2 1994/10/08 03:48:09 rj - */ - - -void PrintConditionalIncludeOpen PROTO ((FILE *f, char *fileName)); -void PrintConditionalIncludeClose PROTO ((FILE *f, char *fileName)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-any.c b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-any.c deleted file mode 100644 index f360869e..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-any.c +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/gen_any.c - * - * prints Routine to initialize the ANY Hash table. The - * ANY Hash table maps the OBJECT IDENTIFIERS or INTEGERS - * to the correct decoding routines. - * - * Also prints an enum to identify each ANY mapping. - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/gen-any.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-any.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:32 rj - * first draft - * - */ - -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "define.h" -#include "str-util.h" -#include "rules.h" -#include "gen-vals.h" -#include "lib-types.h" -#include "gen-any.h" - -static int anyEnumValG = 0; - - -void PrintIDLAnyEnum PROTO ((FILE *idl, Module *m, IDLRules *r)); - -void PrintIDLAnyHashInitRoutine PROTO ((FILE *idl, ModuleList *mods, Module *m, IDLRules *r)); - - -void -PrintIDLAnyCode PARAMS ((idl, r, mods, m), - FILE *idl _AND_ - IDLRules *r _AND_ - ModuleList *mods _AND_ - Module *m) -{ - - if (!m->hasAnys) - return; - - PrintIDLAnyEnum (idl, m, r); -#if 0 - PrintIDLAnyHashInitRoutine (idl, mods, m, r); -#endif - -} /* PrintAnyCode */ - - - -void -PrintIDLAnyEnum PARAMS ((idl, m, r), - FILE *idl _AND_ - Module *m _AND_ - IDLRules *r) -{ - TypeDef *td; - AnyRef *ar; - AnyRefList *arl; - int firstPrinted = TRUE; - int i; - char *modName; - - modName = Asn1TypeName2CTypeName (m->modId->name); - - fprintf (idl,"typedef enum %sAnyId\n", modName); - fprintf (idl,"{\n"); - - /* do any lib types */ - for (i = BASICTYPE_BOOLEAN; i < BASICTYPE_MACRODEF; i++) - { - arl = LIBTYPE_GET_ANY_REFS (i); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - if (!firstPrinted) - fprintf (idl,",\n"); - fprintf (idl," %s = %d", ar->anyIdName, anyEnumValG++); - firstPrinted = FALSE; - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - if (!firstPrinted) - fprintf (idl,",\n"); - fprintf (idl," %s = %d", ar->anyIdName, anyEnumValG++); - firstPrinted = FALSE; - } - } - } - - if (firstPrinted) /* none have been printed */ - fprintf (idl,"/* NO INTEGER or OBJECT IDENTIFIER to ANY type relationships were defined (via MACROs or other mechanism) */\n ??? \n"); - - fprintf (idl,"\n} %sAnyId;\n\n\n", modName); - Free (modName); - -} /* PrintAnyEnum */ - - -#if 0 -void -PrintIDLAnyHashInitRoutine PARAMS ((idl, mods, m, r), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r) -{ - TypeDef *td; - AnyRefList *arl; - AnyRef *ar; - IDLTDI *idltdi; - int i; - int j; - enum BasicTypeChoiceId typeId; - int installedSomeHashes = FALSE; - - - /* print InitAny class src file */ - fprintf (src,"// this class will automatically intialize the any hash tbl\n"); - fprintf (src,"class InitAny\n"); - fprintf (src,"{\n"); - fprintf (src," public:\n"); - fprintf (src," InitAny();\n"); - fprintf (src,"};\n\n"); - - fprintf (src,"static InitAny anyInitalizer;\n"); - - /* print constructor method that build hash tbl to src file*/ - fprintf (src,"InitAny::InitAny()\n"); - fprintf (src,"{\n"); - - /* first print value for OID's */ - - /* do any lib types first */ - i = 0; - for (j = BASICTYPE_BOOLEAN; j < BASICTYPE_MACRODEF; j++) - { - arl = LIBTYPE_GET_ANY_REFS (j); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - installedSomeHashes = TRUE; - if (ar->id->choiceId == OIDORINT_OID) - { - fprintf (src," %s oid%d", r->typeConvTbl[BASICTYPE_OID].className, i++); - PrintIDLOidValue (src, r, ar->id->a.oid); - fprintf (src,";\n"); - } - else if (ar->id->choiceId == OIDORINT_INTID) - { - fprintf (src," %s int%d", r->typeConvTbl[BASICTYPE_INTEGER].className, i++); - PrintIDLIntValue (src, r, ar->id->a.intId); - fprintf (src,";\n"); - } - } - } - } - - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - idltdi = td->idlTypeDefInfo; - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - installedSomeHashes = TRUE; - if (ar->id->choiceId == OIDORINT_OID) - { - fprintf (src," %s oid%d", r->typeConvTbl[BASICTYPE_OID].className, i++); - PrintIDLOidValue (src, r, ar->id->a.oid); - fprintf (src,";\n"); - } - else if (ar->id->choiceId == OIDORINT_INTID) - { - fprintf (src," %s int%d", r->typeConvTbl[BASICTYPE_INTEGER].className, i++); - PrintIDLIntValue (src, r, ar->id->a.intId); - fprintf (src,";\n"); - } - } - } - } - - - /* now print hash init calls */ - i = 0; - for (j = BASICTYPE_BOOLEAN; j < BASICTYPE_MACRODEF; j++) - { - arl = LIBTYPE_GET_ANY_REFS (j); - if (arl != NULL) - { - FOR_EACH_LIST_ELMT (ar, arl) - { - if (ar->id->choiceId == OIDORINT_OID) - fprintf (src," AsnAny::InstallAnyByOid (oid%d, %s, new %s);\n", i++, ar->anyIdName, r->typeConvTbl[j].className); - - else - fprintf (src," AsnAny::InstallAnyByInt (int%d, %s, new %s);\n", i++, ar->anyIdName, r->typeConvTbl[j].className); - - } - } - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - if (td->anyRefs != NULL) - { - FOR_EACH_LIST_ELMT (ar, td->anyRefs) - { - idltdi = td->idlTypeDefInfo; - - if (ar->id->choiceId == OIDORINT_OID) - fprintf (src," AsnAny::InstallAnyByOid (oid%d, %s, new %s);\n", i++, ar->anyIdName, idltdi->className); - - else - fprintf (src," AsnAny::InstallAnyByInt (int%d, %s, new %s);\n", i++, ar->anyIdName, idltdi->className); - - } - } - } - - if (!installedSomeHashes) - { - fprintf (src," /* Since no INTEGER/OID to ANY type relations were defined\n"); - fprintf (src," * (usually done via MACROs) you must manually do the code\n"); - fprintf (src," * to fill the hash tbl.\n"); - fprintf (src," * if the ids are INTEGER use the following:\n"); - fprintf (src," * AsnAny::InstallAnyByInt (3, ??_ANY_ID, new );\n"); - fprintf (src," * if the ids are OBJECT IDENTIFIERs use the following:\n"); - fprintf (src," * AsnAny::InstallAnyByOid (OidValue, ??_ANY_ID, new );\n"); - fprintf (src," * put the ??_ANY_IDs in the AnyId enum.\n\n"); - fprintf (src," * For example if you have some thing like\n"); - fprintf (src," * T1 ::= SEQUENCE { id INTEGER, ANY DEFINED BY id }\n"); - fprintf (src," * and the id 1 maps to the type BOOLEAN use the following:\n"); - fprintf (src," * AsnAny::InstallAnyByInt (1, SOMEBOOL_ANY_ID, new AsnBool);\n"); - fprintf (src," */\n ???????\n"); /* generate compile error */ - } - - - fprintf (src,"} /* InitAny::InitAny */\n\n\n"); - -} /* PrintAnyHashInitRoutine */ -#endif diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-any.h b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-any.h deleted file mode 100644 index a0cc910c..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-any.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/gen_any.h - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/gen-any.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-any.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:33 rj - * first draft - * - */ - -void PrintIDLAnyCode PROTO ((FILE *src, IDLRules *r, ModuleList *mods, Module *m)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-code.c b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-code.c deleted file mode 100644 index aa825e2c..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-code.c +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/gen_idl_code.c - routines for printing CORBA IDL code from type trees - * - * assumes that the type tree has already been run through the - * IDL type generator (idl_gen/types.c). - * - * Mike Sample - * 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * Copyright © 1995 Robert Joop - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/gen-code.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-code.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:28 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1997/03/13 09:15:21 wan - * Improved dependency generation for stupid makedepends. - * Corrected PeekTag to peek into buffer only as far as necessary. - * Added installable error handler. - * Fixed small glitch in idl-code generator (Markku Savela ). - * - * Revision 1.1 1997/01/01 20:25:34 rj - * first draft - * - */ - -#include "snacc.h" - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "define.h" -#include "mem.h" -#include "lib-types.h" -#include "rules.h" -#include "types.h" -#include "cond.h" -#include "str-util.h" -#include "snacc-util.h" -#include "print.h" -#include "tag-util.h" /* get GetTags/FreeTags/CountTags/TagByteLen */ -#include "gen-vals.h" -#include "gen-any.h" -#include "gen-code.h" - - -static long int longJmpValG = -100; - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintComment PARAMS ((idl, m), - FILE *idl _AND_ - Module *m) -{ - long int t; - - t = time (0); - fprintf (idl, "// NOTE: this is a machine generated file -- editing not recommended\n"); - fprintf (idl, "//\n"); - fprintf (idl, "// %s -- IDL for ASN.1 module %s\n", m->idlFileName, m->modId->name); - fprintf (idl, "//\n"); - fprintf (idl, "// This file was generated by snacc on %s", ctime (&t)); - fprintf (idl, "// UBC snacc written by Mike Sample\n"); - fprintf (idl, "// IDL generator written by Robert Joop\n"); - fprintf (idl, "\n"); - -} /* PrintComment */ - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintIncludes PARAMS ((idl, mods, m), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m) -{ - void *tmp; - Module *currMod; - - fprintf (idl, "#include \"ASN1Types.idl\"\n"); - fprintf (idl, "#include \"BitString.idl\"\n"); - - tmp = (void *)CURR_LIST_NODE (mods); /* remember curr loc */ - FOR_EACH_LIST_ELMT (currMod, mods) - fprintf (idl, "#include \"%s\"\n", currMod->idlFileName); - SET_CURR_LIST_NODE (mods, tmp); - -} /* PrintIncludes */ - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintTypeDecl PARAMS ((f, td), - FILE *f _AND_ - TypeDef *td) -{ - switch (td->type->basicType->choiceId) - { - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_SELECTION: - case BASICTYPE_UNKNOWN: - case BASICTYPE_MACRODEF: - case BASICTYPE_MACROTYPE: - return; /* do nothing */ - - case BASICTYPE_ENUMERATED: - if (IsNewType (td->type)) - fprintf (f, " enum %s;\n", td->idlTypeDefInfo->typeName); - break; - - default: - if (IsNewType (td->type)) - fprintf (f, " struct %s;\n", td->idlTypeDefInfo->typeName); - } - -} /* PrintTypeDecl */ - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintIDLTypeAndName PARAMS ((idl, mods, m, r, td, parent, t), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - if (t->optional) - fprintf (idl, "union %sOptional switch (boolean) { case True: %s %s; };\n", t->idlTypeRefInfo->typeName, t->idlTypeRefInfo->typeName, t->idlTypeRefInfo->fieldName); - else - fprintf (idl, "%s %s;\n", t->idlTypeRefInfo->typeName, t->idlTypeRefInfo->fieldName); - -#if 0 - if (t->idlTypeRefInfo->isPtr) - fprintf (idl, "*"); -#endif - -} /* PrintIDLTypeAndName */ - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -/* - * prints typedef or new class given an ASN.1 type def of a primitive type - * or typeref. Uses inheritance to cover re-tagging and named elmts. - */ -static void -PrintIDLSimpleDef PARAMS ((idl, r, td), - FILE *idl _AND_ - IDLRules *r _AND_ - TypeDef *td) -{ - int hasNamedElmts; - CNamedElmt *n; - - fprintf (idl, " /* "); - SpecialPrintType (idl, td, td->type); - fprintf (idl, " */\n"); - - if (hasNamedElmts = HasNamedElmts (td->type)) - { - int tlen = strlen (td->idlTypeDefInfo->typeName) - strlen (r->typeSuffix); - switch (GetBuiltinType (td->type)) - { - case BASICTYPE_INTEGER: - fprintf (idl, " typedef %s %s;\n", td->type->idlTypeRefInfo->typeName, td->idlTypeDefInfo->typeName); - FOR_EACH_LIST_ELMT (n, td->type->idlTypeRefInfo->namedElmts) - fprintf (idl, " const %s %.*s_%s = %d;\n", td->idlTypeDefInfo->typeName, tlen, td->idlTypeDefInfo->typeName, n->name, n->value); - break; - case BASICTYPE_ENUMERATED: - fprintf (idl, " enum %s\n", td->idlTypeDefInfo->typeName); - fprintf (idl, " {\n"); - FOR_EACH_LIST_ELMT (n, td->type->idlTypeRefInfo->namedElmts) - { - char comma = (n != (CNamedElmt *)LAST_LIST_ELMT (td->type->idlTypeRefInfo->namedElmts)) ? ',' : ' '; - fprintf (idl, " %s%c // (original value = %d)\n", n->name, comma, n->value); - } - fprintf (idl, " };\n"); - break; - case BASICTYPE_BITSTRING: - fprintf (idl, " typedef %s %s;\n", td->type->idlTypeRefInfo->typeName, td->idlTypeDefInfo->typeName); - FOR_EACH_LIST_ELMT (n, td->type->idlTypeRefInfo->namedElmts) - fprintf (idl, " const unsigned long %.*s_%s = %d;\n", tlen, td->idlTypeDefInfo->typeName, n->name, n->value); - break; - default: - fprintf (idl, " ???!\n"); - } - } - else - fprintf (idl, " typedef %s %s;\n\n", td->type->idlTypeRefInfo->typeName, td->idlTypeDefInfo->typeName); - -} /* PrintIDLSimpleDef */ - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintIDLChoiceDefCode PARAMS ((idl, mods, m, r, td, parent, choice), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *choice) -{ - NamedType *e; - - /* put class spec in idl file */ - - /* write out choiceId enum type */ - - fprintf (idl, " enum %s%s\n", td->idlTypeDefInfo->typeName, r->choiceEnumSuffix); - fprintf (idl, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { - fprintf (idl, " %s", e->type->idlTypeRefInfo->choiceIdSymbol); - if (e != (NamedType *)LAST_LIST_ELMT (choice->basicType->a.choice)) - fprintf (idl, ",\n"); - else - fprintf (idl, "\n"); - } - fprintf (idl, " };\n\n"); - - /* write out the choice element anonymous union */ - fprintf (idl, " union %s switch (%s%s)\n", td->idlTypeDefInfo->typeName, td->idlTypeDefInfo->typeName, r->choiceEnumSuffix); - fprintf (idl, " {\n"); - FOR_EACH_LIST_ELMT (e, choice->basicType->a.choice) - { -#if 0 - fprintf (idl, " case %s: %s %s;\n", e->type->idlTypeRefInfo->choiceIdSymbol, e->type->idlTypeRefInfo->typeName, e->type->idlTypeRefInfo->fieldName); -#else - fprintf (idl, " case %s: ", e->type->idlTypeRefInfo->choiceIdSymbol); - PrintIDLTypeAndName (idl, mods, m, r, td, choice, e->type); -#endif - } - fprintf (idl, " };\n\n"); - -} /* PrintIDLChoiceDefCode */ - - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintIDLSeqDefCode PARAMS ((idl, mods, m, r, td, parent, seq), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *seq) -{ - NamedType *e; - - /* put class spec in idl file */ - - fprintf (idl, " struct %s\n", td->idlTypeDefInfo->typeName); - fprintf (idl, " {\n"); - - /* write out the sequence elmts */ - FOR_EACH_LIST_ELMT (e, seq->basicType->a.sequence) - { - fprintf (idl, " "); - PrintIDLTypeAndName (idl, mods, m, r, td, seq, e->type); - } - - /* close struct definition */ - fprintf (idl, " };\n\n\n"); - -} /* PrintIDLSeqDefCode */ - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintIDLSetDefCode PARAMS ((idl, mods, m, r, td, parent, set), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *set) -{ - NamedType *e; - - /* put class spec in idl file */ - - fprintf (idl, " struct %s\n", td->idlTypeDefInfo->typeName); - fprintf (idl, " {\n"); - - /* write out the set elmts */ - FOR_EACH_LIST_ELMT (e, set->basicType->a.set) - { - fprintf (idl, " "); - PrintIDLTypeAndName (idl, mods, m, r, td, set, e->type); - } - - fprintf (idl, " };\n\n"); - -} /* PrintIDLSetDefCode */ - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintCxxSetOfDefCode PARAMS ((idl, mods, m, r, td, parent, setOf), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *setOf) -{ - char *lcn; /* list class name */ - char *ecn; /* (list) elmt class name */ - - lcn = td->idlTypeDefInfo->typeName; - ecn = setOf->basicType->a.setOf->idlTypeRefInfo->typeName; - fprintf (idl, " typedef sequence<%s> %s;\n", ecn, lcn); - -} /* PrintCxxSetOfDefCode */ - - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintCxxAnyDefCode PARAMS ((idl, mods, m, r, td, parent, any), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *any) -{ - fprintf (idl, " /* "); - SpecialPrintType (idl, td, td->type); - fprintf (idl, " */\n"); - fprintf (idl, " typedef %s %s;\n\n", td->type->idlTypeRefInfo->typeName, td->idlTypeDefInfo->typeName); -} /* PrintCxxAnyDefCode */ - - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -static void -PrintIDLTypeDefCode PARAMS ((idl, mods, m, r, td), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r _AND_ - TypeDef *td) -{ - switch (td->type->basicType->choiceId) - { - case BASICTYPE_BOOLEAN: /* library type */ - case BASICTYPE_REAL: /* library type */ - case BASICTYPE_OCTETSTRING: /* library type */ - case BASICTYPE_NULL: /* library type */ - case BASICTYPE_OID: /* library type */ - case BASICTYPE_INTEGER: /* library type */ - case BASICTYPE_BITSTRING: /* library type */ - case BASICTYPE_ENUMERATED: /* library type */ - PrintIDLSimpleDef (idl, r, td); - break; - - case BASICTYPE_SEQUENCEOF: /* list types */ - case BASICTYPE_SETOF: - PrintCxxSetOfDefCode (idl, mods, m, r, td, NULL, td->type); - break; - - case BASICTYPE_IMPORTTYPEREF: /* type references */ - case BASICTYPE_LOCALTYPEREF: - /* - * if this type has been re-tagged then - * must create new class instead of using a typedef - */ - PrintIDLSimpleDef (idl, r, td); - break; - - case BASICTYPE_ANYDEFINEDBY: /* ANY types */ - case BASICTYPE_ANY: -/* - fprintf (stderr, " ANY types require modification. "); - fprintf (stderr, " The source files will have a \" ANY - Fix Me! \" comment before related code.\n\n"); -*/ - PrintCxxAnyDefCode (idl, mods, m, r, td, NULL, td->type); - break; - - case BASICTYPE_CHOICE: - PrintIDLChoiceDefCode (idl, mods, m, r, td, NULL, td->type); - break; - - case BASICTYPE_SET: - PrintIDLSetDefCode (idl, mods, m, r, td, NULL, td->type); - break; - - case BASICTYPE_SEQUENCE: - PrintIDLSeqDefCode (idl, mods, m, r, td, NULL, td->type); - break; - - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_SELECTION: - case BASICTYPE_UNKNOWN: - case BASICTYPE_MACRODEF: - case BASICTYPE_MACROTYPE: - /* do nothing */ - break; - } -} /* PrintIDLTypeDefCode */ - -/*\[sep]--------------------------------------------------------------------------------------------------------------------------*/ -void -PrintIDLCode PARAMS ((idl, mods, m, r, longJmpVal), - FILE *idl _AND_ - ModuleList *mods _AND_ - Module *m _AND_ - IDLRules *r _AND_ - long int longJmpVal _AND_ - int printValues) -{ - TypeDef *td; - ValueDef *vd; - - longJmpValG = longJmpVal; - - PrintComment (idl, m); - - PrintConditionalIncludeOpen (idl, m->idlFileName); - - PrintIncludes (idl, mods, m); - - fprintf (idl, "\n"); - fprintf (idl, "module %s\n{\n\n", m->idlname); - - fprintf (idl, " //----------------------------------------------------------------------------\n"); - fprintf (idl, " // type declarations:\n\n"); - FOR_EACH_LIST_ELMT (td, m->typeDefs) - PrintTypeDecl (idl, td); - fprintf (idl, "\n"); - - if (printValues) - { - fprintf (idl, " //----------------------------------------------------------------------------\n"); - fprintf (idl, " // value definitions:\n\n"); - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - PrintIDLValueDef (idl, r, vd); - fprintf (idl, "\n"); - } - - fprintf (idl, " //----------------------------------------------------------------------------\n"); - fprintf (idl, " // type definitions:\n\n"); - -#if 0 - PrintIDLAnyCode (idl, r, mods, m); -#endif - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - PrintIDLTypeDefCode (idl, mods, m, r, td); - fputc ('\n', idl); - } - - fprintf (idl, "}; // end of module %s\n", m->idlname); - - PrintConditionalIncludeClose (idl, m->idlFileName); - -} /* PrintIDLCode */ - -/*\[banner "EOF"]-----------------------------------------------------------------------------------------------------------------*/ diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-code.h b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-code.h deleted file mode 100644 index 6e494d6c..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-code.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/gen_code.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/gen-code.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-code.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:29 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:35 rj - * first draft - * - */ - -void PrintIDLCode PROTO ((FILE *idl, ModuleList *mods, Module *m, IDLRules *r, long int longJmpVal, int printValues)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-vals.c b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-vals.c deleted file mode 100644 index 35d1fd62..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-vals.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/gen_vals.c - prints ASN.1 values in IDL format - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/gen-vals.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-vals.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:29 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:36 rj - * first draft - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "oid.h" -#include "mem.h" -#include "define.h" -#include "lib-types.h" -#include "str-util.h" -#include "snacc-util.h" -#include "rules.h" -#include "gen-vals.h" - -/* non-exported routines' prototypes */ - -static void PrintIDLValueDefsName PROTO ((FILE *f, IDLRules *r, ValueDef *v)); - - - - -void -PrintIDLValueDef PARAMS ((idl, r, v), - FILE *idl _AND_ - IDLRules *r _AND_ - ValueDef *v) -{ - /* just do oid's, ints and bools for now */ - if ((v->value->basicValue->choiceId != BASICVALUE_OID) && - (v->value->basicValue->choiceId != BASICVALUE_INTEGER) && - (v->value->basicValue->choiceId != BASICVALUE_BOOLEAN)) - return; - - /* - * put instantiation in idl file - */ - fprintf (idl, " const "); - PrintIDLValuesClass (idl, r, v->value); - fprintf (idl, " "); - PrintIDLValueDefsName (idl, r, v); - fprintf (idl, " = "); - PrintIDLValueInstatiation (idl, r, v->value); - fprintf (idl, ";\n\n"); - -} /* PrintIDLValueDef */ - - -static void -PrintIDLValueDefsName PARAMS ((f, r, v), - FILE *f _AND_ - IDLRules *r _AND_ - ValueDef *v) -{ - char *cName; - cName = Asn1ValueName2CValueName (v->definedName); - fprintf (f, "%s", cName); - Free (cName); -} - -void -PrintIDLValuesClass PARAMS ((f, r, v), - FILE *f _AND_ - IDLRules *r _AND_ - Value *v) -{ - /* needs work - just do ints bools and oid's for now */ - switch (v->basicValue->choiceId) - { - case BASICVALUE_OID: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_OID].typeName); - break; - - case BASICVALUE_INTEGER: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_INTEGER].typeName); - break; - - case BASICVALUE_BOOLEAN: - fprintf (f, "%s", r->typeConvTbl[BASICTYPE_BOOLEAN].typeName); - break; - - default: - break; - } -} - - -void -PrintIDLValueInstatiation PARAMS ((f, r, v), - FILE *f _AND_ - IDLRules *r _AND_ - Value *v) -{ - /* needs work - just do oids, ints and bools for now */ - switch (v->basicValue->choiceId) - { - case BASICVALUE_OID: - PrintIDLOidValue (f, r, v->basicValue->a.oid); - break; - - case BASICVALUE_INTEGER: - PrintIDLIntValue (f, r, v->basicValue->a.integer); - break; - - case BASICVALUE_BOOLEAN: - fprintf (f, v->basicValue->a.boolean ? "TRUE" : "FALSE"); - break; - - default: - break; - } -} - - - -/* - * given an AOID, c++ AOID constructors params are produced. - * This is used for turning ASN.1 OBJECT ID values - * into usable c++ values. - * - * eg for the oid { 0 1 2 } (in AOID format) - * (0,1,2) - * is produced. - */ -void -PrintIDLOidValue PARAMS ((f, r, v), - FILE *f _AND_ - IDLRules *r _AND_ - AsnOid *v) -{ - unsigned short int firstArcNum; - unsigned long int arcNum; - int i; - - fprintf (f, "("); - - /* un-munge first two arc numbers */ - for (arcNum = 0, i=0; (i < v->octetLen) && (v->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - i++; - firstArcNum = arcNum/40; - if (firstArcNum > 2) - firstArcNum = 2; - - fprintf (f, "%u, %u", firstArcNum, arcNum - (firstArcNum * 40)); - - for (; i < v->octetLen; ) - { - for (arcNum = 0; (i < v->octetLen) && (v->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (v->octs[i] & 0x7f); - i++; - - fprintf (f, ", %u", arcNum); - } - fprintf (f, ")"); - -} /* PrintIDLOidValue */ - - - -void -PrintIDLIntValue PARAMS ((f, r, v), - FILE *f _AND_ - IDLRules *r _AND_ - AsnInt v) -{ - fprintf (f, "%d", v); - -} /* PrintIDLIntValue */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-vals.h b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-vals.h deleted file mode 100644 index fe091e79..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/gen-vals.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/gen_vals.h - * - * MS 92 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/gen-vals.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: gen-vals.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:29 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:37 rj - * first draft - * - */ - - -void PrintIDLValueDef PROTO ((FILE *src, IDLRules *r, ValueDef *v)); - -void PrintIDLValueExtern PROTO ((FILE *hdr, IDLRules *r, ValueDef *v)); - -void PrintIDLValuesClass PROTO ((FILE *f, IDLRules *r, Value *v)); - -void PrintIDLValueInstatiation PROTO ((FILE *f, IDLRules *r, Value *v)); - -void PrintIDLOidValue PROTO ((FILE *f, IDLRules *r, AsnOid *oid)); - -void PrintIDLIntValue PROTO ((FILE *f, IDLRules *r, AsnInt oid)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/rules.c b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/rules.c deleted file mode 100644 index e98a43fd..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/rules.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/rules.c - initialized c rule structure - * inits a table that contains info about - * converting each ASN.1 type to an IDL type - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/rules.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: rules.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:29 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:38 rj - * first draft - * - * Revision 1.3 1994/10/08 03:47:49 rj - */ - -#include "asn-incl.h" -#include "asn1module.h" -#include "rules.h" - - -IDLRules idlRulesG = -{ - 4, - - "", - "_T", - - "Choice", - "a", - "ChoiceUnion", - FALSE, - { - { - BASICTYPE_UNKNOWN, - "???", - FALSE, - FALSE, - FALSE, - TRUE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "unknown" - }, - { - BASICTYPE_BOOLEAN, - "BOOLEAN", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "bool" - }, - { - BASICTYPE_INTEGER, - "INTEGER", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "integer" - }, - { - BASICTYPE_BITSTRING, - "BitString", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "bits" - }, - { - BASICTYPE_OCTETSTRING, - "OctetString", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "octs" - }, - { - BASICTYPE_NULL, - "NULL", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "null" - }, - { - BASICTYPE_OID, - "ObjectIdentifier", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "oid" - }, - { - BASICTYPE_REAL, - "REAL", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "real" - }, - { - BASICTYPE_ENUMERATED, - "???", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "enumeration" - }, - { - BASICTYPE_SEQUENCE, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - TRUE, - "NOT_NULL", - "seq" - }, - { - BASICTYPE_SEQUENCEOF, - "AsnList", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "seqOf" - }, - { - BASICTYPE_SET, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - FALSE, - "NOT_NULL", - "set" - }, - { - BASICTYPE_SETOF, - "AsnList", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "setOf" - }, - { - BASICTYPE_CHOICE, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - TRUE, - FALSE, - "NOT_NULL", - "choice" - }, - { - BASICTYPE_SELECTION, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "foo" - }, - { - BASICTYPE_COMPONENTSOF, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "bar" - }, - { - BASICTYPE_ANY, - "any", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "any" - }, - { - BASICTYPE_ANYDEFINEDBY, - "any", - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "anyDefBy" - }, - { - BASICTYPE_LOCALTYPEREF, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "foo" - }, - { - BASICTYPE_IMPORTTYPEREF, - NULL, - FALSE, - TRUE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "bar" - }, - { - BASICTYPE_MACROTYPE, - NULL, - FALSE, - FALSE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "foo" - }, - { - BASICTYPE_MACRODEF, - NULL, - FALSE, - FALSE, - FALSE, - TRUE, - TRUE, - FALSE, - TRUE, - "NOT_NULL", - "foo" - } - } -}; diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/rules.h b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/rules.h deleted file mode 100644 index e4502071..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/rules.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/rules.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/rules.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: rules.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:29 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:39 rj - * first draft - * - * Revision 1.2 1994/10/08 03:47:50 rj - */ - -/* see ../../core/asn1module.h for IDLTDI (C++ type def info) */ - -typedef struct IDLRules -{ - int maxDigitsToAppend; - - char *typePrefix, - *typeSuffix; - - char *choiceEnumSuffix; - char *choiceUnionFieldName; /* what the name of the choice's union is */ - char *choiceUnionName; /* name (tag) for choice union def name */ - - int capitalizeNamedElmts; - - IDLTDI typeConvTbl[BASICTYPE_MACRODEF + 1]; -} IDLRules; - -extern IDLRules idlRulesG; diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/types.c b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/types.c deleted file mode 100644 index fffb4b47..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/types.c +++ /dev/null @@ -1,675 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/types.c - fills in IDL type information - * - * MS 91/92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/types.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: types.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:29 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:45 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:40 rj - * first draft - * - */ - -#include -#include - -#include "asn-incl.h" -#include "define.h" -#include "asn1module.h" -#include "mem.h" -#include "snacc-util.h" -#include "str-util.h" -#include "rules.h" -#include "c++-gen/kwd.h" -#include "types.h" - -extern Module *usefulTypeModG; - -static DefinedObj *definedNamesG; - -/* unexported prototypes */ - -void FillIDLTypeDefInfo PROTO ((IDLRules *r, Module *m, TypeDef *td)); - -static void FillIDLFieldNames PROTO ((IDLRules *r, NamedTypeList *firstSibling)); - -static void FillIDLTypeRefInfo PROTO ((IDLRules *r, Module *m, TypeDef *td, Type *parent, Type *t)); - -static void FillIDLStructElmts PROTO ((IDLRules *r, Module *m, TypeDef *td, Type *parent, NamedTypeList *t)); - -static void FillIDLChoiceElmts PROTO ((IDLRules *r, Module *m, TypeDef *td, Type *parent, NamedTypeList *first)); - -static int IsIDLPtr PROTO ((IDLRules *r, TypeDef *td, Type *parent, Type *t)); - -void FillIDLTDIDefaults PROTO ((IDLRules *r, IDLTDI *ctdi, TypeDef *td)); - - -/* - * allocates and fills all the idlTypeInfos - * in the type trees for every module in the list - */ -void -FillIDLTypeInfo PARAMS ((r, modList), - IDLRules *r _AND_ - ModuleList *modList) -{ - TypeDef *td; - Module *m; - - /* - * go through each module's type defs and fill - * in the C type and enc/dec routines etc - */ - definedNamesG = NULL; - - /* do useful types first */ - if (usefulTypeModG != NULL) - { - FOR_EACH_LIST_ELMT (td, usefulTypeModG->typeDefs) - FillIDLTypeDefInfo (r, usefulTypeModG, td); - } - - FOR_EACH_LIST_ELMT (m, modList) - { - FOR_EACH_LIST_ELMT (td, m->typeDefs) - FillIDLTypeDefInfo (r, m, td); - } - - /* - * now that type def info is filled in - * set up set/seq/list/choice elements that ref - * those definitions - */ - - /* do useful types first */ - if (usefulTypeModG != NULL) - { - FOR_EACH_LIST_ELMT (td, usefulTypeModG->typeDefs) - FillIDLTypeRefInfo (r, usefulTypeModG, td, NULL, td->type); - } - - FOR_EACH_LIST_ELMT (m, modList) - { - FOR_EACH_LIST_ELMT (td, m->typeDefs) - FillIDLTypeRefInfo (r, m, td, NULL, td->type); - } - - /* - * modules compiled together (ie one call to snacc with - * multiple args) likely to be C compiled together so - * need a unique routines/types/defines/enum values - * since assuming they share same name space. - * All Typedefs, union, struct & enum Tags, and defined values - * (enum consts), #define names - * are assumed to share the same name space - */ - - /* done with checking for name conflicts */ - FreeDefinedObjs (&definedNamesG); - -} /* FillIDLTypeInfo */ - - -/* - * allocates and fills structure holding C type definition information - * fo the given ASN.1 type definition. Does not fill CTRI for contained - * types etc. - */ -void -FillIDLTypeDefInfo PARAMS ((r, m, td), - IDLRules *r _AND_ - Module *m _AND_ - TypeDef *td) -{ - int digit; - int len; - char *tmpName; - IDLTDI *idltdi; - - /* - * if IDLTDI is present this type def has already been 'filled' - */ - if (td->idlTypeDefInfo != NULL) - return; - - - idltdi = MT (IDLTDI); - td->idlTypeDefInfo = idltdi; - - /* get default type def attributes from table for type on rhs of ::= */ - - FillIDLTDIDefaults (r, idltdi, td); - - - /* - * if defined by a ref to another type definition fill in that type - * def's IDLTDI so can inherit (actully completly replace default - * attributes) from it - */ - if ((td->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (td->type->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - /* - * Fill in IDLTDI for defining type if nec. - * this works for importTypeRef as well since both a.localTypeRef - * and a.importTypeRef are of type TypeRef - */ - FillIDLTypeDefInfo (r, td->type->basicType->a.localTypeRef->module, td->type->basicType->a.localTypeRef->link); - - tmpName = idltdi->typeName; /* save typeName */ - /* copy all type def info and restore name related stuff - hack*/ - *idltdi = *td->type->basicType->a.localTypeRef->link->idlTypeDefInfo; - idltdi->typeName = tmpName; /* restore typeName */ - } - - - /* - * check for any "--snacc" attributes that overide the current - * idltdi fields - * UNDEFINED FOR C++ - ParseTypeDefAttribs (idltdi, td->attrList); - */ - -} /* FillIDLTypeDefInfo */ - - -static void -FillIDLTypeRefInfo PARAMS ((r, m, td, parent, t), - IDLRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - IDLTRI *idltri; - IDLTDI *tmpidltdi; - ValueDef *namedElmt; - CNamedElmt *cne; - CNamedElmt **cneHndl; - char *elmtName; - char *listName; - char *choiceName; - char *unionName; - Type *tmpT; - int len, digit; - enum BasicTypeChoiceId - basicTypeId; - - /* - * you must check for cycles yourself before calling this - */ - if (t->idlTypeRefInfo == NULL) - { - idltri = MT (IDLTRI); - t->idlTypeRefInfo = idltri; - } - else - idltri = t->idlTypeRefInfo; - - basicTypeId = t->basicType->choiceId; - - tmpidltdi = &r->typeConvTbl[basicTypeId]; - - /* get base type def info from the conversion table in the rules */ - idltri->isEnc = tmpidltdi->isEnc; - idltri->typeName = tmpidltdi->typeName; - idltri->optTestRoutineName = tmpidltdi->optTestRoutineName; - - - /* - * convert named elmts to IDL names. - * check for name conflict with other defined Types/Names/Values - */ - if ((basicTypeId == BASICTYPE_INTEGER || basicTypeId == BASICTYPE_ENUMERATED || basicTypeId == BASICTYPE_BITSTRING) && !(LIST_EMPTY (t->basicType->a.integer))) - { - idltri->namedElmts = AsnListNew (sizeof (void *)); - FOR_EACH_LIST_ELMT (namedElmt, t->basicType->a.integer) - { - cneHndl = (CNamedElmt **)AsnListAppend (idltri->namedElmts); - cne = *cneHndl = MT (CNamedElmt); - elmtName = Asn1ValueName2CValueName (namedElmt->definedName); -#if 0 - if (basicTypeId == BASICTYPE_BITSTRING) -#endif - { - len = strlen (elmtName); - cne->name = Malloc (len + 1 + r->maxDigitsToAppend); - strcpy (cne->name, elmtName); - } -#if 0 - else - { - len = strlen (idltri->typeName) + 7 + strlen (elmtName); - cne->name = Malloc (len + 1 + r->maxDigitsToAppend); - strcpy (cne->name, idltri->typeName); - strcat (cne->name, "Choice_"); - strcat (cne->name, elmtName); - } -#endif - Free (elmtName); /* not very efficient */ - - if (namedElmt->value->basicValue->choiceId == BASICVALUE_INTEGER) - cne->value = namedElmt->value->basicValue->a.integer; - else - { - fprintf (stderr, "Warning: unlinked defined value. Using -9999999\n"); - cne->value = -9999999; - } - - if (r->capitalizeNamedElmts) - Str2UCase (cne->name, len); - - /* - * append digits if enum value name is a keyword - */ - MakeCxxStrUnique (definedNamesG, cne->name, r->maxDigitsToAppend, 1); - DefineObj (&definedNamesG, cne->name); - } - } - - /* fill in rest of type info depending on the type */ - switch (basicTypeId) - { - case BASICTYPE_BOOLEAN: /* library types */ - case BASICTYPE_INTEGER: - case BASICTYPE_BITSTRING: - case BASICTYPE_OCTETSTRING: - case BASICTYPE_NULL: - case BASICTYPE_OID: - case BASICTYPE_REAL: - case BASICTYPE_ENUMERATED: - /* don't need to do anything else */ - break; - - - case BASICTYPE_SEQUENCEOF: /* list types */ - case BASICTYPE_SETOF: - /* fill in component type */ - FillIDLTypeRefInfo (r, m, td, t, t->basicType->a.setOf); - break; - - case BASICTYPE_IMPORTTYPEREF: /* type references */ - case BASICTYPE_LOCALTYPEREF: - /* - * grab class name from link (link is the def of the - * the ref'd type) - */ - if (t->basicType->a.localTypeRef->link != NULL) - { - /* inherit attributes from referenced type */ - tmpidltdi= t->basicType->a.localTypeRef->link->idlTypeDefInfo; - idltri->typeName = tmpidltdi->typeName; - idltri->isEnc = tmpidltdi->isEnc; - idltri->optTestRoutineName = tmpidltdi->optTestRoutineName; - } - - break; - - case BASICTYPE_ANYDEFINEDBY: /* ANY types */ - break; /* these are handled now */ - - case BASICTYPE_ANY: -#if 0 - PrintErrLoc (m->asn1SrcFileName, t->lineNo); - fprintf (stderr, "Warning - generated code for the \"ANY\" type in type \"%s\" will need modification by YOU.", td->definedName); - fprintf (stderr, " The source files will have a \"/* ANY - Fix Me! */\" comment before related code.\n\n"); -#endif - - break; - - case BASICTYPE_CHOICE: - /* - * must fill field names BEFORE filling choice elmts - * (allows better naming for choice ids) - */ - FillIDLFieldNames (r, t->basicType->a.choice); - FillIDLChoiceElmts (r, m, td, t, t->basicType->a.choice); - break; - - case BASICTYPE_SET: - case BASICTYPE_SEQUENCE: - FillIDLStructElmts (r, m, td, t, t->basicType->a.set); - FillIDLFieldNames (r, t->basicType->a.set); - break; - - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_SELECTION: - fprintf (stderr, "Compiler error - COMPONENTS OF or SELECTION type slipped through normalizing phase.\n"); - break; - - case BASICTYPE_UNKNOWN: - case BASICTYPE_MACRODEF: - case BASICTYPE_MACROTYPE: - /* do nothing */ - break; - - } - - /* - * figure out whether this is a ptr based on the enclosing - * type (if any) and optionality/default - */ - idltri->isPtr = IsIDLPtr (r, td, parent, t); - - /* let user overide any defaults with the --snacc attributes */ - /* undefined for C++ ParseTypeRefAttribs (ctri, t->attrList); */ - - -} /* FillIDLTypeRefInfo */ - - - -static void -FillIDLStructElmts PARAMS ((r, m, td, parent, elmts), - IDLRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - - FOR_EACH_LIST_ELMT (et, elmts) - { - FillIDLTypeRefInfo (r, m, td, parent, et->type); - } - -} /* FillIDLStructElmts */ - - - -/* - * Figures out non-conflicting enum names for the - * choice id's - */ -static void -FillIDLChoiceElmts PARAMS ((r, m, td, parent, elmts), - IDLRules *r _AND_ - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - int idCount = 0; - IDLTRI *idltri; - int len; - - /* - * fill in type info for elmt types first - */ - FOR_EACH_LIST_ELMT (et, elmts) - FillIDLTypeRefInfo (r, m, td, parent, et->type); - - /* - * set choiceId Symbol & value - * eg - * Car ::= CHOICE { enum CarChoice { - * chev ChevCar, carChoice_chev, - * ford FordCar, carChoice_ford, - * toyota ToyotaCar carChoice_toyota - * } }; - * union Car switch (CarChoice) { - * ChevCar *chev; - * FordCar *ford; - * ToyotaCar *toyota; }; - * }; - * NOTE that the union is anonymous - */ - FOR_EACH_LIST_ELMT (et, elmts) - { - idltri = et->type->idlTypeRefInfo; - - if (idltri == NULL) - continue; /* wierd type */ - - idltri->choiceIdValue = idCount++; - - len = strlen (td->idlTypeDefInfo->typeName) + strlen (idltri->fieldName); - idltri->choiceIdSymbol = Malloc (len + 6 + 1); - strcpy (idltri->choiceIdSymbol, td->idlTypeDefInfo->typeName); - strcat (idltri->choiceIdSymbol, "Choice_"); - strcat (idltri->choiceIdSymbol, idltri->fieldName); - - if (r->capitalizeNamedElmts) - Str2UCase (idltri->choiceIdSymbol, len); - - Str2LCase (idltri->choiceIdSymbol, 1); - } - -} /* FillIDLChoiceElmts */ - - -/* - * takes a list of "sibling" (eg same level in a structure) - * ElmtTypes and fills sets up the c field names in - * the IDLTRI struct - */ -static void -FillIDLFieldNames PARAMS ((r, elmts), - IDLRules *r _AND_ - NamedTypeList *elmts) -{ - NamedType *et; - IDLTRI *idltri; - DefinedObj *fieldNames; - int len, num, digit, i, tmpLen; - char *tmpName; - char *asn1FieldName; - char *cFieldName; - - /* - * Initialize fieldname data - * allocate (if nec) and fill in CTRI fieldname if poss - * from asn1 field name. leave blank otherwise - */ - fieldNames = NewObjList(); - FOR_EACH_LIST_ELMT (et, elmts) - { - idltri = et->type->idlTypeRefInfo; - if (idltri == NULL) - { - idltri = MT (IDLTRI); - et->type->idlTypeRefInfo = idltri; - } - if (et->fieldName != NULL) - { - /* - * can assume that the field names are - * distinct because they have passed the - * error checking step. - * However, still call MakeCxxStrUnique - * to change any field names that - * conflict with C++ keywords - */ - asn1FieldName = et->fieldName; - tmpName = Asn1FieldName2CFieldName (asn1FieldName); - idltri->fieldName = Malloc (strlen (tmpName) + 1 + r->maxDigitsToAppend); - strcpy (idltri->fieldName, tmpName); - Free (tmpName); - -/* old idltri->fieldName = Asn1FieldName2CFieldName (asn1FieldName); */ - - MakeCxxStrUnique (fieldNames, idltri->fieldName, r->maxDigitsToAppend, 1); - DefineObj (&fieldNames, idltri->fieldName); - } - } - - - FOR_EACH_LIST_ELMT (et, elmts) - { - idltri = et->type->idlTypeRefInfo; - - /* - * generate field names for those without them - */ - if (idltri->fieldName == NULL) - { - if ((et->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (et->type->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - /* - * take ref'd type name as field name - * convert first let to lower case - */ - tmpName = et->type->basicType->a.localTypeRef->link->idlTypeDefInfo->typeName; - tmpName = Asn1TypeName2CTypeName (tmpName); - cFieldName = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); - strcpy (cFieldName, tmpName); - Free (tmpName); - if (isupper (cFieldName[0])) - cFieldName[0] = tolower (cFieldName[0]); - } - else - { - /* - * get default field name for this type - */ - tmpName = r->typeConvTbl[et->type->basicType->choiceId].defaultFieldName; - cFieldName = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); - strcpy (cFieldName, tmpName); - - if (isupper (cFieldName[0])) - cFieldName[0] = tolower (cFieldName[0]); - } - - - len = strlen (cFieldName); - - /* - * try to use just the type name (with lower case first char). - * if that is already used in this type or a C++ keyword, - * append ascii digits to field name until unique - * in this type - */ - MakeCxxStrUnique (fieldNames, cFieldName, r->maxDigitsToAppend, 1); - DefineObj (&fieldNames, cFieldName); - idltri->fieldName = cFieldName; - } - } - FreeDefinedObjs (&fieldNames); -} /* FillIDLFieldNames */ - - - -/* - * returns true if this c type for this type should be - * be ref'd as a ptr - */ -static int -IsIDLPtr PARAMS ((r, td, parent, t), - IDLRules *r _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - Type *t) -{ - IDLTDI *idltdi; - int retVal = FALSE; - - /* - * inherit ptr attriubutes from ref'd type if any - * otherwise grab lib c type def from the IDLRules - */ - if ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - idltdi = t->basicType->a.localTypeRef->link->idlTypeDefInfo; - } - else - idltdi = &r->typeConvTbl[GetBuiltinType (t)]; - - /* no parent means t is the root of a typedef */ - if ((parent == NULL) && (idltdi->isPtrForTypeDef)) - retVal = TRUE; - - else if ((parent != NULL) && - ((parent->basicType->choiceId == BASICTYPE_SET) || - (parent->basicType->choiceId == BASICTYPE_SEQUENCE)) && - (idltdi->isPtrInSetAndSeq)) - retVal = TRUE; - - else if ((parent != NULL) && - ((parent->basicType->choiceId == BASICTYPE_SETOF) || - (parent->basicType->choiceId == BASICTYPE_SEQUENCEOF)) && - (idltdi->isPtrInList)) - retVal = TRUE; - - else if ((parent != NULL) && - (parent->basicType->choiceId == BASICTYPE_CHOICE) && - (idltdi->isPtrInChoice)) - retVal = TRUE; - - else if (((t->optional) || (t->defaultVal != NULL)) && (idltdi->isPtrForOpt)) - retVal = TRUE; - - return retVal; -} /* IsIDLPtr */ - - - -/* fill given idltdi with defaults from table for given typedef */ -void -FillIDLTDIDefaults PARAMS ((r, idltdi, td), - IDLRules *r _AND_ - IDLTDI *idltdi _AND_ - TypeDef *td) -{ - IDLTDI *tblidltdi; - int typeIndex; - char *tmpName; - - typeIndex = GetBuiltinType (td->type); - - if (typeIndex < 0) - return; - - tblidltdi = &r->typeConvTbl[typeIndex]; - - memcpy (idltdi, tblidltdi, sizeof (IDLTDI)); - - /* make sure class name is unique wrt to previously defined classes */ - tmpName = Asn1TypeName2CTypeName (td->definedName); - idltdi->typeName = Malloc (strlen (tmpName) + 2 + r->maxDigitsToAppend +1); - strcpy (idltdi->typeName, tmpName); - if (tblidltdi->asn1TypeId != BASICTYPE_CHOICE) - strcat (idltdi->typeName, "_T"); - Free (tmpName); - - MakeCxxStrUnique (definedNamesG, idltdi->typeName, r->maxDigitsToAppend, 1); - DefineObj (&definedNamesG, idltdi->typeName); - -} /* FillIDLTDIDefaults */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/types.h b/SecuritySNACCRuntime/compiler/back-ends/idl-gen/types.h deleted file mode 100644 index 99b1e2eb..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/idl-gen/types.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/idl_gen/types.h - fills in c++ type information - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/idl-gen/Attic/types.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: types.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:29 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:46 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/01/01 20:25:42 rj - * first draft - * - */ - - -void FillIDLTypeInfo PROTO ((IDLRules *r, ModuleList *m)); diff --git a/SecuritySNACCRuntime/compiler/back-ends/str-util.c b/SecuritySNACCRuntime/compiler/back-ends/str-util.c deleted file mode 100644 index e20ccea8..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/str-util.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c_gen/str_util.c - bunch of ASN.1/C string utilities - * - * - * Mike Sample - * 91/08/12 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/Attic/str-util.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: str-util.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.3 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.2 2000/05/10 21:36:43 rmurphy - * changing the suffix for c++ output files to .cpp - requires -DMACOS on the compilation line - * - * Revision 1.1.1.1 1999/03/16 18:06:39 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 18:13:31 rj - * include string(s).h - * - * by default, snacc now derives output file names from the .asn1 input file name instead of the module name. - * the global keepbaseG variable switches between the two behaviours. - * - * additional filename generator for idl backend. - * - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:48:17 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:25:31 rj - * snacc_config.h removed; more portable .h file inclusion. - * - * Revision 1.1 1994/08/28 09:48:37 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" - -#include -#if HAVE_UNISTD_H -#include /* for pathconf (..) */ -#endif -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif -#include - -#include "asn1module.h" -#include "mem.h" -#include "define.h" -#include "c-gen/rules.h" -#include "c-gen/type-info.h" -#include "c-gen/kwd.h" -#include "c++-gen/kwd.h" -#include "str-util.h" - - -#define DIGIT_TO_ASCII( d) (((d) % 10) + '0') - -int keepbaseG = TRUE; - -/* - * allocates new and returns a copy of the given - * string with '-'s (dashes) replaced by '_'s (underscores) - */ -char * -Asn1TypeName2CTypeName PARAMS ((aName), - char *aName) -{ - char *retVal; - if (aName == NULL) - return NULL; - - retVal = Malloc (strlen (aName) + 1); - strcpy (retVal, aName); - Dash2Underscore (retVal, strlen (retVal)); - - return retVal; -} /* Asn1TypeName2CTypeName */ - - -/* - * allocates new str and returns a copy of the given - * string with '-'s (dashes) replaced by '_'s (underscores) - */ -char * -Asn1FieldName2CFieldName PARAMS ((aName), - char *aName) -{ - char *retVal; - if (aName == NULL) - return NULL; - - retVal = Malloc (strlen (aName) + 1); - strcpy (retVal, aName); - Dash2Underscore (retVal, strlen (retVal)); - - return retVal; -} /* Asn1FieldName2CFieldName */ - - -/* - * allocates new str and returns a copy of the given - * string with '-'s (dashes) replaced by '_'s (underscores) - */ -char * -Asn1ValueName2CValueName PARAMS ((aName), - char *aName) -{ - char *retVal; - if (aName == NULL) - return NULL; - - retVal = Malloc (strlen (aName) + 1); - strcpy (retVal, aName); - Dash2Underscore (retVal, strlen (retVal)); - - return retVal; -} /* Asn1FieldName2CFieldName */ - - -/* - * allocates and returns a string with all of - * the caps from the given string - */ -char * -GetCaps PARAMS ((str), - char *str) -{ - int i, j; - char *retVal; - - if (str == NULL) - return NULL; - - retVal = Malloc (strlen (str) + 1); - - for (j = 0, i = 0; i < strlen (str); i++) - { - if (isupper (str[i])) - retVal[j++] = str[i]; - } - - retVal[j] = '\0'; /* null terminate */ - - return retVal; - -} /* GetCaps */ - - -/* - * allocates and returns a string with all of - * the caps and digits from the given string - */ -char * -GetCapsAndDigits PARAMS ((str), - char *str) -{ - int i, j; - char *retVal; - - if (str == NULL) - return NULL; - - retVal = Malloc (strlen (str) + 1); - - for (j = 0, i = 0; i < strlen (str); i++) - { - if ((isupper (str[i])) || (isdigit (str[i]))) - retVal[j++] = str[i]; - } - - retVal[j] = '\0'; /* null terminate */ - - return retVal; - -} /* GetCapsAndDigits */ - - -/* - * replaces lowercase chars in given str - * with upper case version - * NOTE: modifies given str - */ -void -Str2UCase PARAMS ((str, len), - char *str _AND_ - int len) -{ - int i; - for (i=0; i < len; i++) - { - if (islower (str[i])) - str[i] = toupper (str[i]); - } -} /* Str2UCase */ - - -/* - * replaces uppercase chars in given str - * with lower case version - * NOTE: modifies given str - */ -void -Str2LCase PARAMS ((str, len), - char *str _AND_ - int len) -{ - int i; - for (i=0; i < len; i++) - { - if (isupper (str[i])) - str[i] = tolower (str[i]); - } -} /* Str2LCase */ - - -/* - * replace dash chars in given str - * with underscores - * NOTE: modifies given str - */ -void -Dash2Underscore PARAMS ((str, len), - char *str _AND_ - int len) -{ - int i; - for (i=0; i < len; i++) - { - if (str[i] == '-') - str[i] = '_'; - } -} /* Dash2Underscore */ - - -/* - * tacks on the ascii version of the given digit - * at the end of the given str. - * NOTE: make sure the str you give has enough space - * for the digits - */ -void -AppendDigit PARAMS ((str, digit), - char *str _AND_ - int digit) -{ - int high = 1000000000; - int currDigit; - int value; - char digitStr[20]; /* arbitrary length > max */ - - if (digit < 0) - digit *= -1; - - currDigit = 0; - while (high > 0) - { - value = digit / high; - if (value != 0) - digitStr[currDigit++]= DIGIT_TO_ASCII (value); - - digit = digit % high; - high = high/10; - } - - if (currDigit == 0) - strcat (str, "0"); - else - { - digitStr[currDigit] = '\0'; /* null terminate */ - strcat (str, digitStr); - } -} /* AppendDigit */ - - - - -/* - * given a defined object list containing null termintated strs, - * a str to be made unique wrt to the list by adding digits to the - * end, the max number of digits to add and the digit to start - * at, str is modified to be unique. It is not added to the - * defined object list. The given str must have enough spare, - * allocated chars after it's null terminator to hold maxDigits - * more characters. - * Only appends digits if the string is not unique or is a C keyword. - * - * Eg MakeCStrUnique ({ "Foo", "Bar" }, "Foo\0 ", 3, 1) - * modifies the the Str "Foo" to "Foo1" - */ -void -MakeCStrUnique PARAMS ((nameList, str, maxDigits, startingDigit), - DefinedObj *nameList _AND_ - char *str _AND_ - int maxDigits _AND_ - int startingDigit) -{ - int digit, len, maxDigitVal; - - if (ObjIsDefined (nameList, str, StrObjCmp) || IsCKeyWord (str)) - { - for (maxDigitVal = 1; maxDigits > 0; maxDigits--) - maxDigitVal *= 10; - - len = strlen (str); - digit = startingDigit; - do - { - str[len] = '\0'; - AppendDigit (str, digit++); - } while (ObjIsDefined (nameList, str, StrObjCmp) && (digit < maxDigitVal)); - } -} /* MakeCStrUnique */ - - -/* - * same as MakeCStrUnique except checks against C++ keywords - */ -void -MakeCxxStrUnique PARAMS ((nameList, str, maxDigits, startingDigit), - DefinedObj *nameList _AND_ - char *str _AND_ - int maxDigits _AND_ - int startingDigit) -{ - int digit, len, maxDigitVal; - - if (ObjIsDefined (nameList, str, StrObjCmp) || IsCxxKeyWord (str)) - { - for (maxDigitVal = 1; maxDigits > 0; maxDigits--) - maxDigitVal *= 10; - - len = strlen (str); - digit = startingDigit; - do - { - str[len] = '\0'; - AppendDigit (str, digit++); - } while (ObjIsDefined (nameList, str, StrObjCmp) && (digit < maxDigitVal)); - } -} /* MakeCxxStrUnique */ - - -/* - * if (keepbaseG) - * { - * strip leading path and trailing suffix - * } - * else - * { - * allocates and returns a base file name generated from - * the module's name. May shorten the name if the - * expected length exceed the systems max path component length - * (eg to support SYS V 14 char filename len limit) - * } - * Base file name is used as the base name for the generated C source files. - */ -char * -MakeBaseFileName PARAMS ((refName), - const char *refName) -{ - if (keepbaseG) - { - char *base, *dot; - int stublen; - char *stub; - - if (base = strrchr (refName, '/')) - base++; - else - base = refName; - - if (dot = strrchr (base, '.')) - stublen = dot - base; - else - stublen = strlen (base); - - stub = Malloc (stublen+1); - memcpy (stub, base, stublen); - stub[stublen] = '\0'; - - return stub; - } - else - { - int fNameLen; - int cpyLen; - char *retVal; - int maxPathComponentLen; - char pathName[1024]; -# define MAX_SUFFIX_LEN 2 /* .c, .h, .C */ - extern int maxFileNameLenG; /* declared in snacc.c */ - - /* - * if the user has not given the max file name len - * via the -mf option, - * find the max filename len (ala POSIX method) - * if possible. Otherwise hardwire it to 14 - * to support underpowered OSes - */ - if (maxFileNameLenG > 2) - maxPathComponentLen = maxFileNameLenG; - else -#ifdef _PC_NAME_MAX - maxPathComponentLen = pathconf (getcwd (pathName, 1024), _PC_NAME_MAX); -#else - maxPathComponentLen = 14; -#endif - - retVal = (char *)Malloc (strlen (refName) +1); - fNameLen = strlen (refName) + MAX_SUFFIX_LEN; - if ((fNameLen > maxPathComponentLen) && (maxPathComponentLen != -1)) - { - cpyLen = maxPathComponentLen - MAX_SUFFIX_LEN; - - /* don't allow trailing dash */ - if (refName[cpyLen-1] == '-') - cpyLen--; - - strncpy (retVal, refName, cpyLen); - retVal[cpyLen] = '\0'; - } - else - strcpy (retVal, refName); - - return retVal; - } -} /* MakeBaseFileName */ - - - - -/* - * given a module name and a suffix, the - * suffix is appended to the module name - * and the whole string is put into lower case - * and underscores are inserted in likely places - * (ie MTSAbstractSvc.h -> mts_abstract_svc.h) - */ -char * -MakeFileName PARAMS ((refName, suffix), - const char *refName _AND_ - const char *suffix) -{ - if (keepbaseG) - { - size_t baselen = strlen (refName), - sufflen = strlen (suffix); - char *filename = Malloc (baselen + sufflen + 1); - - memcpy (filename, refName, baselen); - memcpy (filename+baselen, suffix, sufflen); - filename[baselen+sufflen] = '\0'; - - return filename; - } - else - { - int i, cpyIndex, len; - char *hdrCpy; - int fNameLen; - char *fName; -#define MAX_UNDERSCORE 10 - - fName = Malloc (strlen (refName) + strlen (suffix) + 1); - strcpy (fName, refName); - strcat (fName, suffix); - - - fNameLen = strlen (fName); - - /* - * convert dashes to underscores, add spaces - */ - Dash2Underscore (fName, fNameLen); - - - /* - * remove the next two lines if you uncomment the - * following underscore inserter - */ - Str2LCase (fName, fNameLen - strlen (suffix)); - return fName; - - /* - * NO LONGER DONE - LET THE USER MODIFY THE ASN.1 IF DESIRED - * add underscore between Lcase/Ucase of UCase/UcaseLcasce - * eg MTSAbstractSvc -> MTS_Abstract_Svc - * (if enough space) - len = strlen (fName) + MAX_UNDERSCORE + 1; - hdrCpy = (char *) Malloc (len); - - hdrCpy[0] = fName[0]; - for (i = 1, cpyIndex = 1; (cpyIndex < len) && (i < fNameLen); i++) - { - if (((islower (fName[i-1])) && (isupper (fName[i]))) || - ((isupper (fName[i-1])) && (isupper (fName[i])) && - ((i < (fNameLen-1)) && (islower (fName[i+1]))))) - { - hdrCpy[cpyIndex++] = '_'; - hdrCpy[cpyIndex++] = fName[i]; - } - else - hdrCpy[cpyIndex++] = fName[i]; - } - hdrCpy[cpyIndex++] = '\0'; - - Str2LCase (hdrCpy, cpyIndex - strlen (suffix)); - - Free (fName); - return hdrCpy; - */ - } -} /* MakeFileName */ - - -char * -MakeCHdrFileName PARAMS ((refName), - const char *refName) -{ - return MakeFileName (refName, ".h"); -} - -char * -MakeCSrcFileName PARAMS ((refName), - const char *refName) -{ - return MakeFileName (refName, ".c"); -} - -char * -MakeCxxHdrFileName PARAMS ((refName), - const char *refName) -{ - return MakeFileName (refName, ".h"); -} - -char * -MakeCxxSrcFileName PARAMS ((refName), - const char *refName) -{ -#ifndef MACOS - return MakeFileName (refName, ".C"); -#else - return MakeFileName (refName, ".cpp"); /* ignore cpp rant */ -#endif -} - -#ifdef _IBM_ENC_ -char * /* 19.8.93 IBM-ENC */ -MakedbHdrFileName PARAMS ((refName), - const char *refName) -{ - return MakeFileName (refName, "db.h"); -} - -char * /* 19.8.93 IBM-ENC */ -MakedbSrcFileName PARAMS ((refName), - const char *refName) -{ - return MakeFileName (refName, "db.C"); -} -#endif /* _IBM_ENC_ */ - -#if IDL -char * -MakeIDLFileName PARAMS ((refName), - const char *refName) -{ - return MakeFileName (refName, ".idl"); -} -#endif diff --git a/SecuritySNACCRuntime/compiler/back-ends/str-util.h b/SecuritySNACCRuntime/compiler/back-ends/str-util.h deleted file mode 100644 index 9d6092a7..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/str-util.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c_gen/str_util.h - * - * Mike Sample - * 91/08/12 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/Attic/str-util.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: str-util.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:39 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:13:55 rj - * by default, snacc now derives output file names from the .asn1 input file name instead of the module name. - * the global keepbaseG variable switches between the two behaviours. - * - * additional filename generator for idl backend. - * - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:18 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:38 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -char *Asn1TypeName2CTypeName PROTO ((char *aName)); - -char *Asn1FieldName2CFieldName PROTO ((char *aName)); - -char *Asn1ValueName2CValueName PROTO ((char *aName)); - -char *GetCaps PROTO ((char *str)); - -char *GetCapsAndDigits PROTO ((char *str)); - -void Str2UCase PROTO ((char *str, int len)); - -void Str2LCase PROTO ((char *str, int len)); - -void Dash2Underscore PROTO ((char *str, int len)); - -void AppendDigit PROTO ((char *str, int digit)); - -void MakeCStrUnique PROTO ((DefinedObj *nameList, char *str, int maxDigits, int startingDigit)); - -void MakeCxxStrUnique PROTO ((DefinedObj *nameList, char *str, int maxDigits, int startingDigit)); - -extern int keepbaseG; - -char *MakeBaseFileName PROTO ((const char *moduleName)); -char *MakeFileName PROTO ((const char *moduleName, const char *suffix)); -char *MakeCHdrFileName PROTO ((const char *moduleName)); -char *MakeCSrcFileName PROTO ((const char *moduleName)); -char *MakeCxxHdrFileName PROTO ((const char *moduleName)); -char *MakeCxxSrcFileName PROTO ((const char *moduleName)); -#ifdef _IBM_ENC_ -char *MakedbHdrFileName PROTO ((const char *moduleName)); /* 19.8.93 IBM-ENC */ -char *MakedbSrcFileName PROTO ((const char *moduleName)); /* 19.8.93 IBM-ENC */ -#endif /* _IBM_ENC_ */ -#if IDL -char *MakeIDLFileName PROTO ((const char *moduleName)); -#endif diff --git a/SecuritySNACCRuntime/compiler/back-ends/tag-util.c b/SecuritySNACCRuntime/compiler/back-ends/tag-util.c deleted file mode 100644 index 4a2aece6..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/tag-util.c +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c_gen/tag_util.c - utilities for dealing with tags - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * INSERT_VDA_COMMENTS - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/Attic/tag-util.c,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ - * $Log: tag-util.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:08 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:39 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:15:28 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:26:07 rj - * snacc_config.h and other superfluous .h files removed. - * - * Revision 1.1 1994/08/28 09:48:39 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "define.h" -#include "lib-types.h" -#include "c-gen/rules.h" -#include "c-gen/type-info.h" -#include "str-util.h" -#include "snacc-util.h" -#include "c-gen/util.h" -#include "tag-util.h" - - - -/* - * returns the tags for the given type (stops at next type definition). - * if no tags have been grabbed yet and an untagged CHOICE is encountered, - * all of the CHOICE's top level tags are returned and the stoleChoiceTags - * flag is set. If the type has no tags an empty list is returned, not - * NULL. - * - * ASSUMES: tag list's and implicit flags have been adjusted according - * to module level IMPLICIT/EXPLICIT-TAGS and type level - * IMPLICIT/EXPLICIT tagging. - * - * EXAMPLE: - * - * typeX ::= SEQUENCE SomeChoice ::= CHOICE - * { { - * foo [0] INTEGER, [0] INTEGER, - * bar SomeChoice, [1] BOOLEAN, - * bell [1] IMPLICIT BOOLEAN, [2] IA5String - * gumby [2] SomeChoice, } - poki SomeOtherChoice - * } - * - * SomeOtherChoice ::= [APPLICATION 99] CHOICE { ....} - * - * GetTags (foo's type) --> CNTX 0, UNIV INTEGER_TAG_CODE stoleChoiceTags = FALSE - * GetTags (bar) --> CNTX 0, CNTX 1, CNTX 2 (SomeChoice Elmt's first Tags) - * stoleChoiceTags = TRUE - * GetTags (bell) --> CNTX 1 stoleChoiceTags = FALSE - * GetTags (gumby) --> CNTX 2 stoleChoiceTags = FALSE - * GetTags (poki) --> APPLICATION 99 stoleChoiceTags = FALSE - * - * MS 92/03/04 Added tag form information - */ -TagList* -GetTags PARAMS ((t, stoleChoiceTags), - Type *t _AND_ - int *stoleChoiceTags) -{ - Tag *tag; - TagList *tl; - TagList *retVal; - Tag *last; - Tag *tagCopy; - Tag **tagHndl; - int implicitRef; - int stoleChoicesAgain; - NamedType *e; - - tl = t->tags; - if (tl != NULL) - AsnListFirst (tl); - - retVal = (TagList*) AsnListNew (sizeof (void*)); - implicitRef = FALSE; - *stoleChoiceTags = FALSE; - - for (;;) - { - /* - * go through tag list local to this type if any - */ - - FOR_REST_LIST_ELMT (tag, tl) - { - tagCopy = (Tag*)Malloc (sizeof (Tag)); - memcpy (tagCopy, tag, sizeof (Tag)); - tagHndl = (Tag**)AsnListAppend (retVal); - *tagHndl = tagCopy; - - } - - /* - * follow tags of referenced types - */ - - if ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - if (!implicitRef) - implicitRef = t->implicit; - - - if (t->basicType->a.localTypeRef->link == NULL) - { - fprintf (stderr,"ERROR - unresolved type ref, cannot get tags for decoding>\n"); - break; - } - t = t->basicType->a.localTypeRef->link->type; - tl = t->tags; - - if (tl != NULL) - { - AsnListFirst (tl); /* set curr ptr to first node */ - if ((!LIST_EMPTY (tl)) && implicitRef) - { - AsnListNext (tl); - implicitRef = FALSE; - } - } - - } - - /* - * if untagged choice and no tags found yet - */ - else if ((t->basicType->choiceId == BASICTYPE_CHOICE) && (LIST_EMPTY (retVal))) - { - /* - * Return list of top level tags from this choice - * and set "stoleChoiceTags" bool param - */ - if (implicitRef) - fprintf (stderr,"ERROR - IMPLICITLY Tagged CHOICE\n"); - - *stoleChoiceTags = TRUE; - - FOR_EACH_LIST_ELMT (e, t->basicType->a.choice) - { - stoleChoicesAgain = FALSE; - tl = GetTags (e->type, &stoleChoicesAgain); - - if (tl == NULL) - break; - - AsnListFirst (tl); - if (stoleChoicesAgain) - { - FOR_EACH_LIST_ELMT (tag, tl) - { - tagCopy = (Tag*)Malloc (sizeof (Tag)); - memcpy (tagCopy, tag, sizeof (Tag)); - tagHndl = (Tag**)AsnListAppend (retVal); - *tagHndl = tagCopy; - - } - } - else - { - tag = (Tag*)FIRST_LIST_ELMT (tl); - tagCopy = (Tag*)Malloc (sizeof (Tag)); - memcpy (tagCopy, tag, sizeof (Tag)); - tagHndl = (Tag**)AsnListAppend (retVal); - *tagHndl = tagCopy; - } - FreeTags (tl); - } - - break; /* exit for loop */ - } - - else - break; /* exit for loop */ - } - - - if (!*stoleChoiceTags && (retVal != NULL) && !LIST_EMPTY (retVal)) - { - last = (Tag*)LAST_LIST_ELMT (retVal); - FOR_EACH_LIST_ELMT (tag, retVal) - { - tag->form = CONS; - } - last->form = LIBTYPE_GET_TAG_FORM (GetBuiltinType (t)); - } - - AsnListFirst (retVal); - return retVal; - -} /* GetTags */ - - -void -FreeTags PARAMS ((tl), - TagList *tl) -{ - Tag *tag; - AsnListNode *listNode; - AsnListNode *ln; - - /* free tags */ - FOR_EACH_LIST_ELMT (tag, tl) - { - Free (tag); - } - - /* free list nodes */ - for (ln = FIRST_LIST_NODE (tl); ln != NULL; ) - { - listNode = ln; - ln = ln->next; - Free (listNode); - } - - /* free list head */ - Free (tl); - -} /* FreeTags */ - -/* - * Returns the number of tags that GetTags would return for - * the same type. - */ -int -CountTags PARAMS ((t), - Type *t) -{ - int tagCount; - Tag *tag; - TagList *tl; - int implicitRef; - int stoleChoicesAgain; - NamedType *e; - - tl = t->tags; - if (tl != NULL) - AsnListFirst (tl); - - tagCount = 0; - implicitRef = FALSE; - - for (;;) - { - /* - * go through tag list local to this type if any - */ - - FOR_REST_LIST_ELMT (tag, tl) - { - tagCount++; - } - - /* - * follow tags of referenced types - */ - - if ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - if (!implicitRef) - implicitRef = t->implicit; - - - if (t->basicType->a.localTypeRef->link == NULL) - { - fprintf (stderr,"ERROR - unresolved type ref, cannot get tags for decoding>\n"); - break; - } - t = t->basicType->a.localTypeRef->link->type; - tl = t->tags; - - if (tl != NULL) - { - AsnListFirst (tl); /* set curr ptr to first node */ - if ((!LIST_EMPTY (tl)) && implicitRef) - { - AsnListNext (tl); - implicitRef = FALSE; - } - } - - } - else - break; - } - - return tagCount; - -} /* CountTags */ - - -unsigned long int -TagByteLen PARAMS ((tagCode), - unsigned long int tagCode) -{ - unsigned long int tagLen; - - if (tagCode < 31) - tagLen = 1; - else if (tagCode < 128) - tagLen = 2; - else if (tagCode < 16384) - tagLen = 3; - else if (tagCode < 2097152) - tagLen = 4; - else - tagLen = 5; - - return tagLen; -} /* TagByteLen */ - - - -char* -Class2ClassStr PARAMS ((class), - int class) -{ - switch (class) - { - case UNIV: - return "UNIV"; - break; - - case APPL: - return "APPL"; - break; - - case CNTX: - return "CNTX"; - break; - - case PRIV: - return "PRIV"; - break; - - default: - return "UNKNOWN"; - break; - } -} /* Class2ClassStr */ - - - -char* -Form2FormStr PARAMS ((form), - BER_FORM form) -{ - switch (form) - { - case PRIM: - return "PRIM"; - break; - - case CONS: - return "CONS"; - break; - - default: - return "UNKNOWN"; - break; - } -} /* Form2FormStr */ - - - -char* -Code2UnivCodeStr PARAMS ((code), - BER_UNIV_CODE code) -{ - switch (code) - { - case BOOLEAN_TAG_CODE: - return "BOOLEAN_TAG_CODE"; - break; - - case INTEGER_TAG_CODE: - return "INTEGER_TAG_CODE"; - break; - - case BITSTRING_TAG_CODE: - return "BITSTRING_TAG_CODE"; - break; - - case OCTETSTRING_TAG_CODE: - return "OCTETSTRING_TAG_CODE"; - break; - - case NULLTYPE_TAG_CODE: - return "NULLTYPE_TAG_CODE"; - break; - - case OID_TAG_CODE: - return "OID_TAG_CODE"; - break; - - case OD_TAG_CODE: - return "OD_TAG_CODE"; - break; - - case EXTERNAL_TAG_CODE: - return "EXTERNAL_TAG_CODE"; - break; - - case REAL_TAG_CODE: - return "REAL_TAG_CODE"; - break; - - case ENUM_TAG_CODE: - return "ENUM_TAG_CODE"; - break; - - case SEQ_TAG_CODE: - return "SEQ_TAG_CODE"; - break; - - case SET_TAG_CODE: - return "SET_TAG_CODE"; - break; - - case NUMERICSTRING_TAG_CODE: - return "NUMERICSTRING_TAG_CODE"; - break; - - case PRINTABLESTRING_TAG_CODE: - return "PRINTABLESTRING_TAG_CODE"; - break; - - case TELETEXSTRING_TAG_CODE: - return "TELETEXSTRING_TAG_CODE"; - break; - - case VIDEOTEXSTRING_TAG_CODE: - return "VIDEOTEXSTRING_TAG_CODE"; - break; - - case IA5STRING_TAG_CODE: - return "IA5STRING_TAG_CODE"; - break; - - case UTCTIME_TAG_CODE: - return "UTCTIME_TAG_CODE"; - break; - - case GENERALIZEDTIME_TAG_CODE: - return "GENERALIZEDTIME_TAG_CODE"; - break; - - case GRAPHICSTRING_TAG_CODE: - return "GRAPHICSTRING_TAG_CODE"; - break; - - case VISIBLESTRING_TAG_CODE: - return "VISIBLESTRING_TAG_CODE"; - break; - - case GENERALSTRING_TAG_CODE: - return "GENERALSTRING_TAG_CODE"; - break; - -#ifdef VDADER_RULES - - case UNIVERSALSTRING_TAG_CODE: - return "UNIVERSALSTRING_TAG_CODE"; - break; - - case BMPSTRING_TAG_CODE: - return "BMPSTRING_TAG_CODE"; - break; - - default: - { - /* if the universal type is not known then just return the - * unvisersal tag code. This is useful for defining new types - * in local modules w/o having to modify the compiler. - */ - static char retstring[3]; - sprintf(retstring, "%d", code); - return retstring; - } -#else - - default: - return "UNKNOWN"; -#endif - - } -} /* TagId2FormStr */ diff --git a/SecuritySNACCRuntime/compiler/back-ends/tag-util.h b/SecuritySNACCRuntime/compiler/back-ends/tag-util.h deleted file mode 100644 index fe844df0..00000000 --- a/SecuritySNACCRuntime/compiler/back-ends/tag-util.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * compiler/back_ends/c_gen/tag_util.h - utilities for dealing with tags - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/back-ends/Attic/tag-util.h,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $ - * $Log: tag-util.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:09 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:27 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:39 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 18:15:29 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:19 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:40 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -TagList *GetTags PROTO ((Type *t, int *stoleChoiceTags)); -void FreeTags PROTO ((TagList *tl)); -int CountTags PROTO ((Type *t)); -unsigned long int TagByteLen PROTO ((unsigned long int tagCode)); -char *Class2ClassStr PROTO ((int class)); /* class defined in asn1module.h */ -char *Form2FormStr PROTO ((BER_FORM form)); -char *Code2UnivCodeStr PROTO ((BER_UNIV_CODE code)); diff --git a/SecuritySNACCRuntime/compiler/boot/tbl.c b/SecuritySNACCRuntime/compiler/boot/tbl.c deleted file mode 100644 index e57bf15d..00000000 --- a/SecuritySNACCRuntime/compiler/boot/tbl.c +++ /dev/null @@ -1,592 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl.c - * - * "TBL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Mon Jun 2 11:23:51 1997 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "tbl.h" - - -AsnLen -BEncTBLRangeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLRange *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->to)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->from)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLRangeContent */ - - - - -AsnLen -BEncTBLNamedNumberContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumber *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->value)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLNamedNumberContent */ - - - - -AsnLen -BEncTBLNamedNumberListContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumberList *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLNamedNumberListContent */ - - - - -AsnLen -BEncTBLTypeRefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeRef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnBoolContent (b, (&v->implicit)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDef)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeRefContent */ - - - - -AsnLen -BEncTBLTagContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTag *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->code)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncTBLTagClassContent (b, (&v->tclass)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 10); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTagContent */ - - - - -AsnLen -BEncTBLTypeSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTagContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeSeqOfContent */ - - - - -AsnLen -BEncTBLTypeContentSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContentSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeContentSeqOfContent */ - - - - -AsnLen -BEncTBLTypeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLType *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->values))) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberListContent (b, (v->values)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 6); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->constraint))) - { - BEncEocIfNec (b); - itemLen = BEncTBLRangeContent (b, (v->constraint)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 5); - - totalLen += itemLen; - } - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - itemLen = BEncPrintableStringContent (b, (&v->fieldName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 4); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentContent (b, (v->content)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - if (NOT_NULL ((v->tagList))) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeSeqOfContent (b, (v->tagList)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - } - - itemLen = BEncAsnBoolContent (b, (&v->optional)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeIdContent (b, (&v->typeId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeContent */ - - - - -AsnLen -BEncTBLTypeContentContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContent *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - itemLen = BEncAsnNullContent (b, (&v->a.primType)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_ELMTS: - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentSeqOfContent (b, (v->a.elmts)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 1); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_TYPEREF: - BEncEocIfNec (b); - itemLen = BEncTBLTypeRefContent (b, (v->a.typeRef)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncTBLTypeContentContent */ - - - - -AsnLen -BEncTBLTypeDefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeDef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->isPdu))) - { - itemLen = BEncAsnNullContent (b, (v->isPdu)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 5); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, (v->type)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->typeName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 19); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDefId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeDefContent */ - - - - -AsnLen -BEncTBLModuleSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModuleSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeDefContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLModuleSeqOfContent */ - - - - -AsnLen -BEncTBLModuleContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModule *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLModuleSeqOfContent (b, (v->typeDefs)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - itemLen = BEncAsnBoolContent (b, (&v->isUseful)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - if (ASNOID_PRESENT ((&v->id))) - { - itemLen = BEncAsnOidContent (b, (&v->id)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - } - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLModuleContent */ - - - - -AsnLen -BEncTBLSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLModuleContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLSeqOfContent */ - - - - -AsnLen BEncTBL PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncTBLContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} /* BEncTBL */ - -AsnLen -BEncTBLContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLSeqOfContent (b, (v->modules)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalLenStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTags)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypes)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypeDefs)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumModules)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLContent */ - - - - diff --git a/SecuritySNACCRuntime/compiler/boot/tbl.h b/SecuritySNACCRuntime/compiler/boot/tbl.h deleted file mode 100644 index bc046218..00000000 --- a/SecuritySNACCRuntime/compiler/boot/tbl.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * tbl.h - * - * "TBL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Mon Jun 2 11:23:51 1997 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _tbl_h_ -#define _tbl_h_ - - - - -typedef enum - { - TBL_BOOLEAN = 0, - TBL_INTEGER = 1, - TBL_BITSTRING = 2, - TBL_OCTETSTRING = 3, - TBL_NULL = 4, - TBL_OID = 5, - TBL_REAL = 6, - TBL_ENUMERATED = 7, - TBL_SEQUENCE = 8, - TBL_SET = 9, - TBL_SEQUENCEOF = 10, - TBL_SETOF = 11, - TBL_CHOICE = 12, - TBL_TYPEREF = 13 - } TBLTypeId; /* ENUMERATED { TBL_BOOLEAN (0), TBL_INTEGER (1), TBL_BITSTRING (2), TBL_OCTETSTRING (3), TBL_NULL (4), TBL_OID (5), TBL_REAL (6), TBL_ENUMERATED (7), TBL_SEQUENCE (8), TBL_SET (9), TBL_SEQUENCEOF (10), TBL_SETOF (11), TBL_CHOICE (12), TBL_TYPEREF (13) } */ - -#define BEncTBLTypeIdContent BEncAsnEnumContent - - - - -typedef AsnInt TBLTypeDefId; /* INTEGER */ - -#define BEncTBLTypeDefIdContent BEncAsnIntContent - - - - -typedef enum - { - UNIVERSAL = 0, - APPLICATION = 1, - CONTEXT = 2, - PRIVATE = 3 - } TBLTagClass; /* ENUMERATED { UNIVERSAL (0), APPLICATION (1), CONTEXT (2), PRIVATE (3) } */ - -#define BEncTBLTagClassContent BEncAsnEnumContent - - - - -typedef struct TBLRange /* SEQUENCE */ -{ - AsnInt from; /* [0] IMPLICIT INTEGER */ - AsnInt to; /* [1] IMPLICIT INTEGER */ -} TBLRange; - -AsnLen BEncTBLRangeContent PROTO ((BUF_TYPE b, TBLRange *v)); - - - - -typedef struct TBLNamedNumber /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnInt value; /* [1] IMPLICIT INTEGER */ -} TBLNamedNumber; - -AsnLen BEncTBLNamedNumberContent PROTO ((BUF_TYPE b, TBLNamedNumber *v)); - - - - -typedef AsnList TBLNamedNumberList; /* SEQUENCE OF TBLNamedNumber */ - -AsnLen BEncTBLNamedNumberListContent PROTO ((BUF_TYPE b, TBLNamedNumberList *v)); - - - - -typedef struct TBLTypeRef /* SEQUENCE */ -{ - TBLTypeDefId typeDef; /* TBLTypeDefId */ - AsnBool implicit; /* BOOLEAN */ -} TBLTypeRef; - -AsnLen BEncTBLTypeRefContent PROTO ((BUF_TYPE b, TBLTypeRef *v)); - - - - -typedef struct TBLTag /* SEQUENCE */ -{ - TBLTagClass tclass; /* TBLTagClass */ - AsnInt code; /* INTEGER (0..MAX) */ -} TBLTag; - -AsnLen BEncTBLTagContent PROTO ((BUF_TYPE b, TBLTag *v)); - - - - -typedef AsnList TBLTypeSeqOf; /* SEQUENCE OF TBLTag */ - -AsnLen BEncTBLTypeSeqOfContent PROTO ((BUF_TYPE b, TBLTypeSeqOf *v)); - - - - -typedef AsnList TBLTypeContentSeqOf; /* SEQUENCE OF TBLType */ - -AsnLen BEncTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, TBLTypeContentSeqOf *v)); - - - - -typedef struct TBLType /* SEQUENCE */ -{ - TBLTypeId typeId; /* [0] IMPLICIT TBLTypeId */ - AsnBool optional; /* [1] IMPLICIT BOOLEAN */ - TBLTypeSeqOf* tagList; /* [2] IMPLICIT TBLTypeSeqOf OPTIONAL */ - struct TBLTypeContent* content; /* [3] TBLTypeContent */ - PrintableString fieldName; /* [4] IMPLICIT PrintableString OPTIONAL */ - struct TBLRange* constraint; /* [5] IMPLICIT TBLRange OPTIONAL */ - TBLNamedNumberList* values; /* [6] IMPLICIT TBLNamedNumberList OPTIONAL */ -} TBLType; - -AsnLen BEncTBLTypeContent PROTO ((BUF_TYPE b, TBLType *v)); - - - - -typedef struct TBLTypeContent /* CHOICE */ -{ - enum TBLTypeContentChoiceId - { - TBLTYPECONTENT_PRIMTYPE, - TBLTYPECONTENT_ELMTS, - TBLTYPECONTENT_TYPEREF - } choiceId; - union TBLTypeContentChoiceUnion - { - AsnNull primType; /* [0] IMPLICIT NULL */ - TBLTypeContentSeqOf* elmts; /* [1] IMPLICIT TBLTypeContentSeqOf */ - struct TBLTypeRef* typeRef; /* [2] IMPLICIT TBLTypeRef */ - } a; -} TBLTypeContent; - -AsnLen BEncTBLTypeContentContent PROTO ((BUF_TYPE b, TBLTypeContent *v)); - - - - -typedef struct TBLTypeDef /* SEQUENCE */ -{ - TBLTypeDefId typeDefId; /* TBLTypeDefId */ - PrintableString typeName; /* PrintableString */ - struct TBLType* type; /* TBLType */ - AsnNull* isPdu; /* NULL OPTIONAL */ -} TBLTypeDef; - -AsnLen BEncTBLTypeDefContent PROTO ((BUF_TYPE b, TBLTypeDef *v)); - - - - -typedef AsnList TBLModuleSeqOf; /* SEQUENCE OF TBLTypeDef */ - -AsnLen BEncTBLModuleSeqOfContent PROTO ((BUF_TYPE b, TBLModuleSeqOf *v)); - - - - -typedef struct TBLModule /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnOid id; /* [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL */ - AsnBool isUseful; /* [2] IMPLICIT BOOLEAN */ - TBLModuleSeqOf* typeDefs; /* [3] IMPLICIT TBLModuleSeqOf */ -} TBLModule; - -AsnLen BEncTBLModuleContent PROTO ((BUF_TYPE b, TBLModule *v)); - - - - -typedef AsnList TBLSeqOf; /* SEQUENCE OF TBLModule */ - -AsnLen BEncTBLSeqOfContent PROTO ((BUF_TYPE b, TBLSeqOf *v)); - - - - -typedef struct TBL /* SEQUENCE */ -{ - AsnInt totalNumModules; /* INTEGER */ - AsnInt totalNumTypeDefs; /* INTEGER */ - AsnInt totalNumTypes; /* INTEGER */ - AsnInt totalNumTags; /* INTEGER */ - AsnInt totalNumStrings; /* INTEGER */ - AsnInt totalLenStrings; /* INTEGER */ - TBLSeqOf* modules; /* TBLSeqOf */ -} TBL; - -AsnLen BEncTBL PROTO ((BUF_TYPE b, TBL *v)); - -AsnLen BEncTBLContent PROTO ((BUF_TYPE b, TBL *v)); - - - - - -#endif /* conditional include of tbl.h */ diff --git a/SecuritySNACCRuntime/compiler/core/.cvsignore b/SecuritySNACCRuntime/compiler/core/.cvsignore deleted file mode 100644 index 5761abcf..00000000 --- a/SecuritySNACCRuntime/compiler/core/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.o diff --git a/SecuritySNACCRuntime/compiler/core/asn1module.h b/SecuritySNACCRuntime/compiler/core/asn1module.h deleted file mode 100644 index af4026c2..00000000 --- a/SecuritySNACCRuntime/compiler/core/asn1module.h +++ /dev/null @@ -1,1028 +0,0 @@ -/* - * compiler/core/asn1module.h - * - * "Asn1Module" ASN.1 module C type definitions and prototypes - * - * This .h file was by snacc on Sun Feb 7 23:38:26 1993 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - -#ifndef _asn1module_h_ -#define _asn1module_h_ - - - - -typedef enum - { - PRESENT_CT = 0, - ABSENT_CT = 1, - EMPTY_CT = 2, - OPTIONAL_CT = 3 - } ConstraintEnum; /* ENUMERATED { PRESENT_CT (0), ABSENT_CT (1), EMPTY_CT (2), OPTIONAL_CT (3) } */ - - - - -typedef enum - { - FULL_CT = 0, - PARTIAL_CT = 1, - SINGLE_CT = 2 - } InnerSubtypeEnum; /* ENUMERATED { FULL_CT (0), PARTIAL_CT (1), SINGLE_CT (2) } */ - - - - -typedef enum - { - SNMP_MANDATORY = 0, - SNMP_OPTIONAL = 1, - SNMP_OBSOLETE = 2, - SNMP_DEPRECATED = 3 - } SnmpObjectTypeMacroTypeEnum1; /* ENUMERATED { SNMP_MANDATORY (0), SNMP_OPTIONAL (1), SNMP_OBSOLETE (2), SNMP_DEPRECATED (3) } */ - - - - -typedef enum - { - SNMP_READ_ONLY = 0, - SNMP_READ_WRITE = 1, - SNMP_WRITE_ONLY = 2, - SNMP_NOT_ACCESSIBLE = 3 - } SnmpObjectTypeMacroTypeEnum; /* ENUMERATED { SNMP_READ_ONLY (0), SNMP_READ_WRITE (1), SNMP_WRITE_ONLY (2), SNMP_NOT_ACCESSIBLE (3) } */ - - - - -typedef enum - { - CONSUMER_PORT = 0, - SUPPLIER_PORT = 1, - SYMMETRIC_PORT = 2 - } AsnPortEnum; /* ENUMERATED { CONSUMER_PORT (0), SUPPLIER_PORT (1), SYMMETRIC_PORT (2) } */ - - - - -typedef enum - { - EXPORTS_ALL = 0, - EXPORTS_NOTHING = 1, - EXPORTS_SOME = 2 - } ModuleEnum2; /* ENUMERATED { EXPORTS_ALL (0), EXPORTS_NOTHING (1), EXPORTS_SOME (2) } */ - - - - -typedef enum - { - EXPLICIT_TAGS = 0, - IMPLICIT_TAGS = 1 - } ModuleEnum1; /* ENUMERATED { EXPLICIT_TAGS (0), IMPLICIT_TAGS (1) } */ - - - - -typedef enum - { - MOD_OK = 0, - MOD_NOT_LINKED = 1, - MOD_ERROR = 2 - } ModuleEnum; /* ENUMERATED { MOD_OK (0), MOD_NOT_LINKED (1), MOD_ERROR (2) } */ - - - - -typedef AsnInt AsnRefineMacroType; /* INTEGER */ - - - - -typedef enum - { - MIN_INT = 0, - MAX_INT = 1 - } SpecialIntegerValue; /* ENUMERATED { MIN_INT (0), MAX_INT (1) } */ - - - - -typedef enum - { - MINUS_INFINITY_REAL = 0, - PLUS_INFINITY_REAL = 1 - } SpecialRealValue; /* ENUMERATED { MINUS_INFINITY_REAL (0), PLUS_INFINITY_REAL (1) } */ - - - - -typedef enum - { - C_CHOICE = 0, - C_LIST = 1, - C_ANY = 2, - C_ANYDEFINEDBY = 3, - C_LIB = 4, - C_STRUCT = 5, - C_TYPEREF = 6, - C_NO_TYPE = 7, - C_TYPEDEF = 8 - } CTypeId; /* ENUMERATED { C_CHOICE (0), C_LIST (1), C_ANY (2), C_ANYDEFINEDBY (3), C_LIB (4), C_STRUCT (5), C_TYPEREF (6), C_NO_TYPE (7), C_TYPEDEF (8) } */ - - - - -typedef struct OidOrInt /* CHOICE */ -{ - enum OidOrIntChoiceId - { - OIDORINT_OID, - OIDORINT_INTID - } choiceId; - union OidOrIntChoiceUnion - { - AsnOid *oid; /* OBJECT IDENTIFIER */ - AsnInt intId; /* INTEGER */ - } a; -} OidOrInt; - - - - -typedef AsnList OidList; /* SEQUENCE OF OBJECT IDENTIFIER */ - - - - -typedef char *MyString; /* PrintableString */ - - - - -typedef struct ModuleId /* SEQUENCE */ -{ - MyString name; /* MyString */ - OID *oid; /* OBJECT IDENTIFIER OPTIONAL */ -} ModuleId; - - - - -typedef struct AnyRef /* SEQUENCE */ -{ - MyString anyIdName; /* MyString */ - struct OidOrInt *id; /* OidOrInt */ -} AnyRef; - - - - -typedef AsnList AnyRefList; /* SEQUENCE OF AnyRef */ - - - - -typedef AsnList AttributeList; /* SEQUENCE OF MyString */ - - - - -typedef MyString MacroDef; /* MyString */ - - - - - - - - -typedef AsnList ImportModuleList; /* SEQUENCE OF ImportModule */ - - - - -typedef AsnList ImportElmtList; /* SEQUENCE OF ImportElmt */ - - - - -typedef AsnList TypeDefList; /* SEQUENCE OF TypeDef */ - - - - -typedef AsnList TagList; /* SEQUENCE OF Tag */ - - - - -typedef AsnList NamedTypeList; /* SEQUENCE OF NamedType */ - - - - -typedef AsnList ValueList; /* SEQUENCE OF Value */ - - - - -typedef AsnList TypeOrValueList; /* SEQUENCE OF TypeOrValue */ - - - - -typedef AsnList AsnPortList; /* SEQUENCE OF AsnPort */ - - - - -typedef AsnList SubtypeList; /* SEQUENCE OF Subtype */ - - - - -typedef AsnList ConstraintList; /* SEQUENCE OF Constraint */ - - - - -typedef AsnList ValueDefList; /* SEQUENCE OF ValueDef */ - - - - -typedef struct ImportElmtChoice /* CHOICE */ -{ - enum ImportElmtChoiceChoiceId - { - IMPORTELMTCHOICE_TYPE, - IMPORTELMTCHOICE_VALUE - } choiceId; - union ImportElmtChoiceChoiceUnion - { - struct TypeDef *type; /* [0] IMPLICIT TypeDef */ - struct ValueDef *value; /* [1] IMPLICIT ValueDef */ - } a; -} ImportElmtChoice; - - - - -typedef struct Module /* SEQUENCE */ -{ - ModuleEnum status; /* ModuleEnum */ - struct ModuleId *modId; /* ModuleId */ - ModuleEnum1 tagDefault; /* ModuleEnum1 */ - ModuleEnum2 exportStatus; /* ModuleEnum2 */ - ImportModuleList *imports; /* ImportModuleList */ - TypeDefList *typeDefs; /* TypeDefList */ - ValueDefList *valueDefs; /* ValueDefList */ - AsnBool hasAnys; /* BOOLEAN */ - MyString asn1SrcFileName; /* MyString */ - MyString cHdrFileName; /* MyString */ - MyString cSrcFileName; /* MyString */ - MyString cxxHdrFileName; /* MyString */ - MyString cxxSrcFileName; /* MyString */ -#ifdef _IBM_ENC_ - MyString dbHdrFileName; /* 19.8.93 IBM-ENC */ - MyString dbSrcFileName; /* 19.8.93 IBM-ENC */ -#endif /* _IBM_ENC_ */ -#if META - MyString cxxname; -#endif -#if IDL - MyString idlFileName; /* MyString */ - MyString idlname; -#endif -} Module; - - - - -typedef struct ImportModule /* SEQUENCE */ -{ - struct ModuleId *modId; /* ModuleId */ - ImportElmtList *importElmts; /* ImportElmtList */ - struct Module *moduleRef; /* Module */ - AsnInt lineNo; /* INTEGER */ -} ImportModule; - - - - -typedef struct ImportElmt /* SEQUENCE */ -{ - struct ImportElmtChoice *resolvedRef; /* ImportElmtChoice OPTIONAL */ - MyString name; /* MyString */ - AsnBool privateScope; /* BOOLEAN */ - AsnInt lineNo; /* INTEGER */ -} ImportElmt; - - - - -typedef struct TypeDef /* SEQUENCE */ -{ - AsnBool exported; /* BOOLEAN */ - AsnBool recursive; /* BOOLEAN */ - AsnBool isPdu; /* BOOLEAN */ - AsnInt localRefCount; /* INTEGER */ - AsnInt importRefCount; /* INTEGER */ - AsnInt tmpRefCount; /* INTEGER */ - AsnBool visited; /* BOOLEAN */ - MyString definedName; /* MyString */ - struct Type *type; /* Type */ - struct CTDI *cTypeDefInfo; /* CTDI */ - struct CxxTDI *cxxTypeDefInfo; /* CxxTDI */ - struct IDLTDI *idlTypeDefInfo; /* IDLTDI */ - AttributeList *attrList; /* AttributeList */ - TypeDefList *refList; /* TypeDefList */ - AnyRefList *anyRefs; /* AnyRefList */ -} TypeDef; - - - - -typedef struct Tag /* SEQUENCE */ -{ - AsnInt tclass; /* INTEGER */ - AsnInt form; /* INTEGER */ - AsnInt code; /* INTEGER */ - AsnBool explicit; /* BOOLEAN */ - struct Value *valueRef; /* Value */ -} Tag; - - - - -typedef struct Type /* SEQUENCE */ -{ - AsnBool optional; /* BOOLEAN */ - AsnBool implicit; /* BOOLEAN */ - TagList *tags; /* TagList */ - struct NamedValue *defaultVal; /* [0] IMPLICIT NamedValue OPTIONAL */ - struct Subtype *subtypes; /* [1] Subtype OPTIONAL */ - struct BasicType *basicType; /* [2] BasicType */ - AsnInt lineNo; /* INTEGER */ - struct CTRI *cTypeRefInfo; /* CTRI */ - struct CxxTRI *cxxTypeRefInfo; /* CxxTRI */ - struct IDLTRI *idlTypeRefInfo; /* IDLTRI */ - AttributeList *attrList; /* AttributeList */ -} Type; - - - - -typedef ValueDefList NamedNumberList; /* ValueDefList */ - - - - -typedef struct BasicType /* CHOICE */ -{ - enum BasicTypeChoiceId - { - BASICTYPE_UNKNOWN, - BASICTYPE_BOOLEAN, - BASICTYPE_INTEGER, - BASICTYPE_BITSTRING, - BASICTYPE_OCTETSTRING, - BASICTYPE_NULL, - BASICTYPE_OID, - BASICTYPE_REAL, - BASICTYPE_ENUMERATED, - BASICTYPE_SEQUENCE, - BASICTYPE_SEQUENCEOF, - BASICTYPE_SET, - BASICTYPE_SETOF, - BASICTYPE_CHOICE, - BASICTYPE_SELECTION, - BASICTYPE_COMPONENTSOF, - BASICTYPE_ANY, - BASICTYPE_ANYDEFINEDBY, - BASICTYPE_LOCALTYPEREF, - BASICTYPE_IMPORTTYPEREF, - BASICTYPE_MACROTYPE, - BASICTYPE_MACRODEF - } choiceId; - union BasicTypeChoiceUnion - { - AsnNull unknown; /* [0] IMPLICIT NULL */ - AsnNull boolean; /* [1] IMPLICIT NULL */ - NamedNumberList *integer; /* [2] IMPLICIT NamedNumberList */ - NamedNumberList *bitString; /* [3] IMPLICIT NamedNumberList */ - AsnNull octetString; /* [4] IMPLICIT NULL */ - AsnNull null; /* [5] IMPLICIT NULL */ - AsnNull oid; /* [6] IMPLICIT NULL */ - AsnNull real; /* [7] IMPLICIT NULL */ - NamedNumberList *enumerated; /* [8] IMPLICIT NamedNumberList */ - NamedTypeList *sequence; /* [9] IMPLICIT NamedTypeList */ - struct Type *sequenceOf; /* [10] IMPLICIT Type */ - NamedTypeList *set; /* [11] IMPLICIT NamedTypeList */ - struct Type *setOf; /* [12] IMPLICIT Type */ - NamedTypeList *choice; /* [13] IMPLICIT NamedTypeList */ - struct SelectionType *selection; /* [14] IMPLICIT SelectionType */ - struct Type *componentsOf; /* [15] IMPLICIT Type */ - AsnNull any; /* [16] IMPLICIT NULL */ - struct AnyDefinedByType *anyDefinedBy; /* [17] IMPLICIT AnyDefinedByType */ - struct TypeRef *localTypeRef; /* [19] IMPLICIT TypeRef */ - struct TypeRef *importTypeRef; /* [20] IMPLICIT TypeRef */ - struct MacroType *macroType; /* [21] MacroType */ - MacroDef macroDef; /* [22] IMPLICIT MacroDef */ - } a; -} BasicType; - - - - -typedef struct MacroType /* CHOICE */ -{ - enum MacroTypeChoiceId - { - MACROTYPE_ROSOPERATION, - MACROTYPE_ROSERROR, - MACROTYPE_ROSBIND, - MACROTYPE_ROSUNBIND, - MACROTYPE_ROSASE, - MACROTYPE_ROSAC, - MACROTYPE_MTSASEXTENSION, - MACROTYPE_MTSASEXTENSIONS, - MACROTYPE_MTSASEXTENSIONATTRIBUTE, - MACROTYPE_MTSASTOKEN, - MACROTYPE_MTSASTOKENDATA, - MACROTYPE_MTSASSECURITYCATEGORY, - MACROTYPE_ASNOBJECT, - MACROTYPE_ASNPORT, - MACROTYPE_ASNREFINE, - MACROTYPE_ASNABSTRACTBIND, - MACROTYPE_ASNABSTRACTUNBIND, - MACROTYPE_ASNABSTRACTOPERATION, - MACROTYPE_ASNABSTRACTERROR, - MACROTYPE_AFALGORITHM, - MACROTYPE_AFENCRYPTED, - MACROTYPE_AFPROTECTED, - MACROTYPE_AFSIGNATURE, - MACROTYPE_AFSIGNED, - MACROTYPE_SNMPOBJECTTYPE - } choiceId; - union MacroTypeChoiceUnion - { - struct RosOperationMacroType *rosOperation; /* [0] IMPLICIT RosOperationMacroType */ - struct RosErrorMacroType *rosError; /* [1] IMPLICIT RosErrorMacroType */ - struct RosBindMacroType *rosBind; /* [2] IMPLICIT RosBindMacroType */ - struct RosBindMacroType *rosUnbind; /* [3] IMPLICIT RosBindMacroType */ - struct RosAseMacroType *rosAse; /* [4] IMPLICIT RosAseMacroType */ - struct RosAcMacroType *rosAc; /* [5] IMPLICIT RosAcMacroType */ - struct MtsasExtensionMacroType *mtsasExtension; /* [6] IMPLICIT MtsasExtensionMacroType */ - struct MtsasExtensionsMacroType *mtsasExtensions; /* [7] IMPLICIT MtsasExtensionsMacroType */ - struct MtsasExtensionAttributeMacroType *mtsasExtensionAttribute; /* [8] IMPLICIT MtsasExtensionAttributeMacroType */ - struct MtsasTokenMacroType *mtsasToken; /* [9] IMPLICIT MtsasTokenMacroType */ - struct MtsasTokenDataMacroType *mtsasTokenData; /* [10] IMPLICIT MtsasTokenDataMacroType */ - struct MtsasSecurityCategoryMacroType *mtsasSecurityCategory; /* [11] IMPLICIT MtsasSecurityCategoryMacroType */ - struct AsnObjectMacroType *asnObject; /* [12] IMPLICIT AsnObjectMacroType */ - struct AsnPortMacroType *asnPort; /* [13] IMPLICIT AsnPortMacroType */ - AsnRefineMacroType asnRefine; /* [14] IMPLICIT AsnRefineMacroType */ - struct AsnAbstractBindMacroType *asnAbstractBind; /* [15] IMPLICIT AsnAbstractBindMacroType */ - struct AsnAbstractBindMacroType *asnAbstractUnbind; /* [16] IMPLICIT AsnAbstractBindMacroType */ - struct RosOperationMacroType *asnAbstractOperation; /* [17] IMPLICIT RosOperationMacroType */ - struct RosErrorMacroType *asnAbstractError; /* [18] IMPLICIT RosErrorMacroType */ - struct Type *afAlgorithm; /* [19] IMPLICIT Type */ - struct Type *afEncrypted; /* [20] IMPLICIT Type */ - struct Type *afProtected; /* [21] IMPLICIT Type */ - struct Type *afSignature; /* [22] IMPLICIT Type */ - struct Type *afSigned; /* [23] IMPLICIT Type */ - struct SnmpObjectTypeMacroType *snmpObjectType; /* [24] IMPLICIT SnmpObjectTypeMacroType */ - } a; -} MacroType; - - - - -typedef struct AnyDefinedByType /* SEQUENCE */ -{ - MyString fieldName; /* MyString */ - struct NamedType *link; /* NamedType OPTIONAL */ -} AnyDefinedByType; - - - - -typedef struct SelectionType /* SEQUENCE */ -{ - MyString fieldName; /* MyString */ - struct Type *typeRef; /* Type */ - struct NamedType *link; /* NamedType OPTIONAL */ -} SelectionType; - - - - -typedef struct NamedType /* SEQUENCE */ -{ - MyString fieldName; /* MyString */ - struct Type *type; /* Type */ -} NamedType; - - - - -typedef struct TypeRef /* SEQUENCE */ -{ - MyString typeName; /* MyString */ - MyString moduleName; /* MyString */ - struct Module *module; /* Module */ - struct TypeDef *link; /* TypeDef */ -} TypeRef; - - - - -typedef struct RosOperationMacroType /* SEQUENCE */ -{ - struct NamedType *arguments; /* NamedType */ - struct NamedType *result; /* NamedType */ - TypeOrValueList *errors; /* [0] IMPLICIT TypeOrValueList OPTIONAL */ - TypeOrValueList *linkedOps; /* [1] IMPLICIT TypeOrValueList OPTIONAL */ -} RosOperationMacroType; - - - - -typedef struct TypeOrValue /* CHOICE */ -{ - enum TypeOrValueChoiceId - { - TYPEORVALUE_TYPE, - TYPEORVALUE_VALUE - } choiceId; - union TypeOrValueChoiceUnion - { - struct Type *type; /* [0] IMPLICIT Type */ - struct Value *value; /* [1] IMPLICIT Value */ - } a; -} TypeOrValue; - - - - -typedef struct RosErrorMacroType /* SEQUENCE */ -{ - struct NamedType *parameter; /* NamedType */ -} RosErrorMacroType; - - - - -typedef struct RosBindMacroType /* SEQUENCE */ -{ - struct NamedType *argument; /* NamedType */ - struct NamedType *result; /* NamedType */ - struct NamedType *error; /* NamedType */ -} RosBindMacroType; - - - - -typedef struct RosAseMacroType /* SEQUENCE */ -{ - ValueList *operations; /* ValueList */ - ValueList *consumerInvokes; /* ValueList */ - ValueList *supplierInvokes; /* ValueList */ -} RosAseMacroType; - - - - -typedef struct RosAcMacroType /* SEQUENCE */ -{ - ValueList *nonRoElements; /* ValueList */ - struct Type *bindMacroType; /* Type */ - struct Type *unbindMacroType; /* Type */ - struct Value *remoteOperations; /* Value */ - ValueList *operationsOf; /* ValueList */ - ValueList *initiatorConsumerOf; /* ValueList */ - ValueList *responderConsumerOf; /* ValueList */ - OidList *abstractSyntaxes; /* OidList */ -} RosAcMacroType; - - - - -typedef struct MtsasExtensionMacroType /* SEQUENCE */ -{ - struct NamedType *elmtType; /* [0] IMPLICIT NamedType OPTIONAL */ - struct Value *defaultValue; /* [1] IMPLICIT Value OPTIONAL */ - AsnBool *criticalForSubmission; /* [2] IMPLICIT BOOLEAN OPTIONAL */ - AsnBool *criticalForTransfer; /* [3] IMPLICIT BOOLEAN OPTIONAL */ - AsnBool *criticalForDelivery; /* [4] IMPLICIT BOOLEAN OPTIONAL */ -} MtsasExtensionMacroType; - - - - -typedef struct MtsasExtensionsMacroType /* SEQUENCE */ -{ - ValueList *extensions; /* ValueList */ -} MtsasExtensionsMacroType; - - - - -typedef struct MtsasExtensionAttributeMacroType /* SEQUENCE */ -{ - struct Type *type; /* Type OPTIONAL */ -} MtsasExtensionAttributeMacroType; - - - - -typedef struct MtsasTokenMacroType /* SEQUENCE */ -{ - struct Type *type; /* Type OPTIONAL */ -} MtsasTokenMacroType; - - - - -typedef struct MtsasTokenDataMacroType /* SEQUENCE */ -{ - struct Type *type; /* Type OPTIONAL */ -} MtsasTokenDataMacroType; - - - - -typedef struct MtsasSecurityCategoryMacroType /* SEQUENCE */ -{ - struct Type *type; /* Type OPTIONAL */ -} MtsasSecurityCategoryMacroType; - - - - -typedef struct AsnObjectMacroType /* SEQUENCE */ -{ - AsnPortList *ports; /* AsnPortList OPTIONAL */ -} AsnObjectMacroType; - - - - -typedef struct AsnPort /* SEQUENCE */ -{ - struct Value *portValue; /* Value */ - AsnPortEnum portType; /* AsnPortEnum */ -} AsnPort; - - - - -typedef struct AsnPortMacroType /* SEQUENCE */ -{ - TypeOrValueList *abstractOps; /* [0] IMPLICIT TypeOrValueList OPTIONAL */ - TypeOrValueList *consumerInvokes; /* [1] IMPLICIT TypeOrValueList OPTIONAL */ - TypeOrValueList *supplierInvokes; /* [2] IMPLICIT TypeOrValueList OPTIONAL */ -} AsnPortMacroType; - - - - -typedef struct AsnAbstractBindMacroType /* SEQUENCE */ -{ - AsnPortList *ports; /* [0] IMPLICIT AsnPortList OPTIONAL */ - struct Type *type; /* [1] IMPLICIT Type OPTIONAL */ -} AsnAbstractBindMacroType; - - - - -typedef struct SnmpObjectTypeMacroType /* SEQUENCE */ -{ - struct Type *syntax; /* Type */ - SnmpObjectTypeMacroTypeEnum access; /* SnmpObjectTypeMacroTypeEnum */ - SnmpObjectTypeMacroTypeEnum1 status; /* SnmpObjectTypeMacroTypeEnum1 */ - struct Value *description; /* [0] IMPLICIT Value OPTIONAL */ - struct Value *reference; /* [1] IMPLICIT Value OPTIONAL */ - TypeOrValueList *index; /* [2] IMPLICIT TypeOrValueList OPTIONAL */ - struct Value *defVal; /* [3] IMPLICIT Value OPTIONAL */ -} SnmpObjectTypeMacroType; - - - - -typedef struct Subtype /* CHOICE */ -{ - enum SubtypeChoiceId - { - SUBTYPE_SINGLE, - SUBTYPE_AND, - SUBTYPE_OR, - SUBTYPE_NOT - } choiceId; - union SubtypeChoiceUnion - { - struct SubtypeValue *single; /* [0] SubtypeValue */ - SubtypeList *and; /* [1] IMPLICIT SubtypeList */ - SubtypeList *or; /* [2] IMPLICIT SubtypeList */ - struct Subtype *not; /* [3] Subtype */ - } a; -} Subtype; - - - - -typedef struct SubtypeValue /* CHOICE */ -{ - enum SubtypeValueChoiceId - { - SUBTYPEVALUE_SINGLEVALUE, - SUBTYPEVALUE_CONTAINED, - SUBTYPEVALUE_VALUERANGE, - SUBTYPEVALUE_PERMITTEDALPHABET, - SUBTYPEVALUE_SIZECONSTRAINT, - SUBTYPEVALUE_INNERSUBTYPE - } choiceId; - union SubtypeValueChoiceUnion - { - struct Value *singleValue; /* [0] IMPLICIT Value */ - struct Type *contained; /* [1] IMPLICIT Type */ - struct ValueRangeSubtype *valueRange; /* [2] IMPLICIT ValueRangeSubtype */ - struct Subtype *permittedAlphabet; /* [3] Subtype */ - struct Subtype *sizeConstraint; /* [4] Subtype */ - struct InnerSubtype *innerSubtype; /* [5] IMPLICIT InnerSubtype */ - } a; -} SubtypeValue; - - - - -typedef struct ValueRangeSubtype /* SEQUENCE */ -{ - AsnBool lowerEndInclusive; /* BOOLEAN */ - AsnBool upperEndInclusive; /* BOOLEAN */ - struct Value *lowerEndValue; /* Value */ - struct Value *upperEndValue; /* Value */ -} ValueRangeSubtype; - - - - -typedef struct InnerSubtype /* SEQUENCE */ -{ - InnerSubtypeEnum constraintType; /* InnerSubtypeEnum */ - ConstraintList *constraints; /* ConstraintList */ -} InnerSubtype; - - - - -typedef struct Constraint /* SEQUENCE */ -{ - MyString fieldRef; /* MyString */ - ConstraintEnum presenceConstraint; /* ConstraintEnum */ - struct Subtype *valueConstraints; /* Subtype */ -} Constraint; - - - - -typedef struct ValueDef /* SEQUENCE */ -{ - AsnBool exported; /* BOOLEAN */ - MyString definedName; /* MyString */ - struct Value *value; /* Value */ -} ValueDef; - - - - -typedef struct Value /* SEQUENCE */ -{ - struct Type *type; /* Type OPTIONAL */ - AsnInt valueType; /* INTEGER */ - struct BasicValue *basicValue; /* BasicValue */ - AsnInt lineNo; /* INTEGER */ -} Value; - - - - -typedef struct BasicValue /* CHOICE */ -{ - enum BasicValueChoiceId - { - BASICVALUE_UNKNOWN, - BASICVALUE_EMPTY, - BASICVALUE_INTEGER, - BASICVALUE_SPECIALINTEGER, - BASICVALUE_LONGINTEGER, - BASICVALUE_BOOLEAN, - BASICVALUE_REAL, - BASICVALUE_SPECIALREAL, - BASICVALUE_ASCIITEXT, - BASICVALUE_ASCIIHEX, - BASICVALUE_ASCIIBITSTRING, - BASICVALUE_OID, - BASICVALUE_LINKEDOID, - BASICVALUE_BERVALUE, - BASICVALUE_PERVALUE, - BASICVALUE_NAMEDVALUE, - BASICVALUE_NULL, - BASICVALUE_LOCALVALUEREF, - BASICVALUE_IMPORTVALUEREF, - BASICVALUE_VALUENOTATION - } choiceId; - union BasicValueChoiceUnion - { - AsnNull unknown; /* [0] IMPLICIT NULL */ - AsnNull empty; /* [1] IMPLICIT NULL */ - AsnInt integer; /* [2] IMPLICIT INTEGER */ - SpecialIntegerValue specialInteger; /* [3] IMPLICIT SpecialIntegerValue */ - AsnInt longInteger; /* [4] IMPLICIT INTEGER */ - AsnBool boolean; /* [5] IMPLICIT BOOLEAN */ - AsnReal real; /* [6] IMPLICIT REAL */ - SpecialRealValue specialReal; /* [7] IMPLICIT SpecialRealValue */ - AsnOcts *asciiText; /* [8] IMPLICIT OCTET STRING */ - AsnOcts *asciiHex; /* [9] IMPLICIT OCTET STRING */ - AsnOcts *asciiBitString; /* [10] IMPLICIT OCTET STRING */ - AsnOid *oid; /* [11] IMPLICIT OBJECT IDENTIFIER */ - OID *linkedOid; /* [12] IMPLICIT OBJECT IDENTIFIER */ - AsnOcts *berValue; /* [13] IMPLICIT OCTET STRING */ - AsnOcts *perValue; /* [14] IMPLICIT OCTET STRING */ - struct NamedValue *namedValue; /* [15] IMPLICIT NamedValue */ - AsnNull null; /* [16] IMPLICIT NULL */ - struct ValueRef *localValueRef; /* [17] IMPLICIT ValueRef */ - struct ValueRef *importValueRef; /* [18] IMPLICIT ValueRef */ - AsnOcts *valueNotation; /* [19] IMPLICIT OCTET STRING */ - } a; -} BasicValue; - - - - -typedef struct ValueRef /* SEQUENCE */ -{ - MyString valueName; /* MyString */ - MyString moduleName; /* MyString */ - struct ValueDef *link; /* ValueDef */ - struct Module *module; /* Module */ -} ValueRef; - - - - -typedef struct NamedValue /* SEQUENCE */ -{ - MyString fieldName; /* MyString */ - struct Value *value; /* Value */ -} NamedValue; - - - - -typedef AsnList ModuleList; /* SEQUENCE OF Module */ - - - - -typedef struct Modules /* [APPLICATION 0] IMPLICIT SEQUENCE */ -{ - AsnInt creationTime; /* INTEGER */ - ModuleList *modules; /* ModuleList */ -} Modules; - - - - -typedef AsnList NamedValueList; /* SEQUENCE OF NamedValue */ - - -typedef struct CTDI /* SEQUENCE */ -{ - enum BasicTypeChoiceId asn1TypeId; /* INTEGER */ - CTypeId cTypeId; /* CTypeId */ - MyString cTypeName; /* MyString */ - AsnBool isPdu; /* BOOLEAN */ - AsnBool isEncDec; /* BOOLEAN */ - AsnBool isPtrForTypeDef; /* BOOLEAN */ - AsnBool isPtrForTypeRef; /* BOOLEAN */ - AsnBool isPtrInChoice; /* BOOLEAN */ - AsnBool isPtrForOpt; /* BOOLEAN */ - MyString optTestRoutineName; /* MyString */ - MyString defaultFieldName; /* MyString */ - MyString printRoutineName; /* MyString */ - MyString encodeRoutineName; /* MyString */ - MyString decodeRoutineName; /* MyString */ - MyString freeRoutineName; /* MyString */ - AsnBool genPrintRoutine; /* BOOLEAN */ - AsnBool genEncodeRoutine; /* BOOLEAN */ - AsnBool genDecodeRoutine; /* BOOLEAN */ - AsnBool genFreeRoutine; /* BOOLEAN */ - AsnBool genTypeDef; /* BOOLEAN */ -} CTDI; - - - - -typedef struct CNamedElmt /* SEQUENCE */ -{ - MyString name; /* MyString */ - AsnInt value; /* INTEGER */ -} CNamedElmt; - - - - -typedef struct CxxTDI /* SEQUENCE */ -{ - enum BasicTypeChoiceId asn1TypeId; /* INTEGER */ - MyString className; /* MyString */ - AsnBool isPdu; /* BOOLEAN */ - AsnBool isEnc; /* BOOLEAN */ - AsnBool isPtrForTypeDef; /* BOOLEAN */ - AsnBool isPtrForOpt; /* BOOLEAN */ - AsnBool isPtrInChoice; /* BOOLEAN */ - AsnBool isPtrInSetAndSeq; /* BOOLEAN */ - AsnBool isPtrInList; /* BOOLEAN */ - MyString optTestRoutineName; /* MyString */ - MyString defaultFieldName; /* MyString */ -} CxxTDI; - -typedef struct IDLTDI /* SEQUENCE */ -{ - enum BasicTypeChoiceId asn1TypeId; /* INTEGER */ - MyString typeName; /* MyString */ - AsnBool isPdu; /* BOOLEAN */ - AsnBool isEnc; /* BOOLEAN */ - AsnBool isPtrForTypeDef; /* BOOLEAN */ - AsnBool isPtrForOpt; /* BOOLEAN */ - AsnBool isPtrInChoice; /* BOOLEAN */ - AsnBool isPtrInSetAndSeq; /* BOOLEAN */ - AsnBool isPtrInList; /* BOOLEAN */ - MyString optTestRoutineName; /* MyString */ - MyString defaultFieldName; /* MyString */ -} IDLTDI; - - - - -typedef AsnList CNamedElmts; /* SEQUENCE OF CNamedElmt */ - - - - -typedef struct CxxTRI /* SEQUENCE */ -{ - AsnBool isEnc; /* BOOLEAN */ - MyString className; /* MyString */ - MyString fieldName; /* MyString */ - AsnBool isPtr; /* BOOLEAN */ - CNamedElmts *namedElmts; /* CNamedElmts */ - MyString choiceIdSymbol; /* MyString */ - AsnInt choiceIdValue; /* INTEGER */ - MyString optTestRoutineName; /* MyString */ -} CxxTRI; - -typedef struct IDLTRI /* SEQUENCE */ -{ - AsnBool isEnc; /* BOOLEAN */ - MyString typeName; /* MyString */ - MyString fieldName; /* MyString */ - AsnBool isPtr; /* BOOLEAN */ - CNamedElmts *namedElmts; /* CNamedElmts */ - MyString choiceIdSymbol; /* MyString */ - AsnInt choiceIdValue; /* INTEGER */ - MyString optTestRoutineName; /* MyString */ -} IDLTRI; - - - - -typedef struct CTRI /* SEQUENCE */ -{ - CTypeId cTypeId; /* CTypeId */ - MyString cFieldName; /* MyString */ - MyString cTypeName; /* MyString */ - AsnBool isPtr; /* BOOLEAN */ - CNamedElmts *cNamedElmts; /* CNamedElmts OPTIONAL */ - AsnInt choiceIdValue; /* INTEGER */ - MyString choiceIdSymbol; /* MyString */ - MyString choiceIdEnumName; /* MyString */ - MyString choiceIdEnumFieldName; /* MyString */ - MyString optTestRoutineName; /* MyString */ - MyString printRoutineName; /* MyString */ - MyString encodeRoutineName; /* MyString */ - MyString decodeRoutineName; /* MyString */ - MyString freeRoutineName; /* MyString */ - AsnBool isEncDec; /* BOOLEAN */ -} CTRI; - - - -#endif /* conditional include of asn1module.h */ diff --git a/SecuritySNACCRuntime/compiler/core/define.c b/SecuritySNACCRuntime/compiler/core/define.c deleted file mode 100644 index 346bc5c0..00000000 --- a/SecuritySNACCRuntime/compiler/core/define.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * compiler/core/define.c - keeps a list of things that have been defined - * and provided means for checking if something has been - * defined - * - * MS 92 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/define.c,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: define.c,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:46 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1997/10/10 13:43:15 wan - * Corrected bug in generic table decoder wrt. indefinite length elements - * Corrected compiler access to freed memory (bug reported by Markku Savela) - * Broke asnwish.c into two pieces so that one can build ones on wish - * Added beredit tool (based on asnwish, allowes to edit BER messages) - * - * Revision 1.3 1995/07/25 19:41:21 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:27:38 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:48:58 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" -#include "mem.h" -#include "define.h" - -/* for CompareOids from snacc_util.c*/ -int CompareOids PROTO ((OID *oid1, OID *oid2)); - - -/* cmp routine for a null terminated string object type */ -int -StrObjCmp PARAMS ((s1, s2), - void *s1 _AND_ - void *s2) -{ - if (strcmp ((char*)s1, (char*) s2) == 0) - return TRUE; - else - return FALSE; -} - -/* cmp routine for a integer object type */ -int -IntObjCmp PARAMS ((s1, s2), - void *s1 _AND_ - void *s2) -{ - if (*((int*) s1) == *((int*) s2)) - return TRUE; - else - return FALSE; -} - - -/* cmp routine for a OID object type */ -int -OidObjCmp PARAMS ((o1, o2), - void *o1 _AND_ - void *o2) -{ - return CompareOids ((OID*)o1, (OID*)o2); -} - -/* special cmp routine - compares the pointers themselves */ -int -ObjPtrCmp PARAMS ((s1, s2), - void *s1 _AND_ - void *s2) -{ - if (s1 == s2) - return TRUE; - else - return FALSE; -} - - -DefinedObj* -NewObjList() -{ - return NULL; -} - -/* - * puts the given object into the give object list - * does not check for duplicates - you should do that - * before calling this - if you care. - */ -void -DefineObj PARAMS ((objListHndl, obj), - DefinedObj **objListHndl _AND_ - void *obj) -{ - DefinedObj *new; - - new = MT (DefinedObj); - new->obj = obj; - - /* insert new one at head */ - new->next = *objListHndl; - *objListHndl = new; - -} /* DefineObj */ - - -/* - * removes the first identical object from the list - * - if you are allowing duplicates use another routine. - * this only removes the first for efficiency reasons - all - * current usage of the DefineObj stuff does not allow duplicates. - */ -void -UndefineObj PARAMS ((objListHndl, obj, cmpRoutine), - DefinedObj **objListHndl _AND_ - void *obj _AND_ - CmpObjsRoutine cmpRoutine) -{ - DefinedObj *objListPtr; - DefinedObj **prevHndl; - - objListPtr = *objListHndl; - - prevHndl = objListHndl; - for ( ; objListPtr != NULL; objListPtr = *prevHndl) - { - if (cmpRoutine (objListPtr->obj, obj)) - { - /* found object, now remove it */ - *prevHndl = objListPtr->next; - Free (objListPtr); - } - else - prevHndl = &objListPtr->next; - } - -} /* UndefineObj */ - - -/* - * given an object list, an object and an object comparison routine, - * ObjIsDefined returns non-zero if the given object is already in - * the object list. The comparison routine should take two objects and - * return non-zero if the objects are equivalent - */ -int -ObjIsDefined PARAMS ((objListPtr, obj, cmpRoutine), - DefinedObj *objListPtr _AND_ - void *obj _AND_ - CmpObjsRoutine cmpRoutine) -{ - for ( ; objListPtr != NULL; objListPtr = objListPtr->next) - { - if (cmpRoutine (objListPtr->obj, obj)) - return TRUE; - } - return FALSE; - -} /* ObjIsDefined */ - -/* - * Frees the list holding the defined objects. - * Does not free the objects. - */ -void -FreeDefinedObjs PARAMS ((objListHndl), - DefinedObj **objListHndl) -{ - DefinedObj *dO; - DefinedObj *tmpDO; - - for (dO = *objListHndl; dO != NULL; ) - { - tmpDO = dO->next; - Free (dO); - dO = tmpDO; - } - *objListHndl = NULL; - -} /* FreeDefinedObjs */ - - - -/* - * Frees the list holding the defined objects. - * Does free the objects. - */ -void -FreeDefinedObjsAndContent PARAMS ((objListHndl), - DefinedObj **objListHndl) -{ - DefinedObj *dO; - DefinedObj *tmpDO; - - for (dO = *objListHndl; dO != NULL; ) - { - tmpDO = dO->next; - Free (dO->obj); - Free (dO); - dO = tmpDO; - } - *objListHndl = NULL; - -} /* FreeDefinedObjs */ diff --git a/SecuritySNACCRuntime/compiler/core/define.h b/SecuritySNACCRuntime/compiler/core/define.h deleted file mode 100644 index 4a2598b7..00000000 --- a/SecuritySNACCRuntime/compiler/core/define.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * compiler/core/define.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/define.h,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: define.h,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:46 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1994/10/08 03:48:35 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:48:59 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -typedef struct DefinedObj -{ - void *obj; - struct DefinedObj *next; -} DefinedObj; - - -typedef int (*CmpObjsRoutine) PROTO ((void *obj1, void *obj2)); -typedef int (*FreeObjRoutine) PROTO ((void *obj)); - -int StrObjCmp PROTO ((void *s1, void *s2)); - -int IntObjCmp PROTO ((void *s1, void *s2)); - -int OidObjCmp PROTO ((void *o1, void *o2)); - -int ObjPtrCmp PROTO ((void *s1, void *s2)); - -DefinedObj *NewObjList(); - -void DefineObj PROTO ((DefinedObj **l, void *obj)); - -void UndefineObj PROTO ((DefinedObj **l, void *obj, CmpObjsRoutine cmpRoutine)); - -int ObjIsDefined PROTO ((DefinedObj *l, void *obj, CmpObjsRoutine cmp)); - -void FreeDefinedObjs PROTO ((DefinedObj **l)); - -void FreeDefinedObjsAndContent PROTO ((DefinedObj **l)); diff --git a/SecuritySNACCRuntime/compiler/core/dependency.c b/SecuritySNACCRuntime/compiler/core/dependency.c deleted file mode 100644 index 1320a807..00000000 --- a/SecuritySNACCRuntime/compiler/core/dependency.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - * compiler/core/dependency.c - sorts types/values in order of dependency. - * typeDefs list is re-ordered - * going from independent->dependent types - * - * this is done after all import linking is done - * - * Mike Sample - * 91/08/12 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/dependency.c,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: dependency.c,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:46 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 19:41:22 rj - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:48:37 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:31:56 rj - * snacc_config.h removed; dependency.h includet. - * - * Revision 1.1 1994/08/28 09:49:00 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "snacc-util.h" -#include "dependency.h" - - -/* prototypes */ - -void SortTypeDependencies PROTO ((Module *m)); - -void SortInterModuleDependencies PROTO ((ModuleList *m)); - -TypeDefList *RemoveAndSortIndependents PROTO ((TypeDefList *tdl)); - -void SortTypeDefs PROTO ((TypeDefList *tdl)); - -void BuildLocalRefList PROTO ((Type *t, TypeDefList *refList)); - -void BuildWeightedLocalRefList PROTO ((Type *t, TypeDefList *refList)); - - -long int GetElmtIndex PROTO ((TypeDef *td, TypeDefList *tdl)); - -/* -void MoveAfter PROTO ((unsigned long int currIndex, unsigned long int afterIndex, AsnList *l)); -*/ - -/* - * Sorts type dependencies by reodering TypeDefs linear list - * with least dependent types followed by dependent types - */ -void -SortAllDependencies PARAMS ((modList), - ModuleList *modList) -{ - Module *m; - - FOR_EACH_LIST_ELMT (m, modList) - { - SortTypeDependencies (m); - } - -/* SortInterModuleDependencies (modList); */ - -} /* SortAllDependencies */ - - -/* - * This attempts to sort the types in order of dependency - * (least dependent --> dependent) - * - * This should only be called after the CTypeInfo or CxxTypeInfo - * has been added to the types. - * (the isPtr field is used to help determine ordering) - * - * Algorithm: (wierd!) - * - * First separte the ASN.1 type defs into 4 separate groups - * - * 1. Type defs that are defined directly from primitive/library types - * eg Foo ::= INTEGER {one (1), two (2) } - * - * 2. Type defs reference no local types in a way that needs a - * forward decl. of the ref'd type (ie ptr refs) - * - * 3. Type defs that reference local types in a way that needs - * a previous decl of the ref'd type (ie non ptr refs for SET/SEQ - * elmts) - * - * 4. Type defs that are not referenced by any local types - * (hence no local types depend on them so they can go last) - * - * - * The type defs in group 3 are further sorted by the SortTypeDefs routine - * - * Then all of the groups are merged in the order 1-2-3-4. - * - * Some wierd recursive types might cause problems... - * - * - * MS 92 - */ -void -SortTypeDependencies PARAMS ((m), - Module *m) -{ - TypeDef *curr; - TypeDefList *prims; - TypeDefList *noRefs; - TypeDefList *refs; - TypeDefList *notRefd; - TypeDef **newElmtHndl; - - prims = AsnListNew (sizeof (void*)); - noRefs = AsnListNew (sizeof (void*)); - refs = AsnListNew (sizeof (void*)); - notRefd = AsnListNew (sizeof (void*)); - - /* put each TypeDef in the appropriate list (1-4)*/ - FOR_EACH_LIST_ELMT (curr, m->typeDefs) - { - if (IsDefinedByLibraryType (curr->type)) - newElmtHndl = (TypeDef**) AsnListAppend (prims); - - else if (curr->localRefCount == 0) - newElmtHndl = (TypeDef**) AsnListAppend (notRefd); - - else - { - /* get list of local types that this type def refs */ - curr->refList = AsnListNew (sizeof (void*)); - BuildLocalRefList (curr->type, curr->refList); - - if (LIST_EMPTY (curr->refList)) - { - newElmtHndl = (TypeDef**) AsnListAppend (noRefs); - Free (curr->refList); - curr->refList = NULL; - } - else - newElmtHndl = (TypeDef**) AsnListAppend (refs); - } - - *newElmtHndl = curr; - } - - /* sort problem types */ - SortTypeDefs (refs); - - /* free refList space */ - FOR_EACH_LIST_ELMT (curr, refs) - { - if (curr->refList != NULL) - { - AsnListFree (curr->refList); - curr->refList = NULL; - } - } - - /* - * combine the typdef lists with the prims followed by the - * types that don't reference other types - * then prims, followed by composite types - */ - prims = AsnListConcat (prims, noRefs); - prims = AsnListConcat (prims, refs); - prims = AsnListConcat (prims, notRefd); - - AsnListFree (m->typeDefs); - Free (noRefs); - Free (refs); - Free (notRefd); - - m->typeDefs = prims; - -} /* SortTypeDependencies */ - - - - -/* - * Attempt to sort modules in order of "depends on none" to - * "depends on all" where a dependency is caused by importing - * from another module. - * cyclic dependencies are a pain - */ -/* - * Not implemented yet... perhaps best left in user's hands - * ie set it by the cmd line order - */ -/* -void -SortInterModuleDependencies PARAMS ((m), - ModuleList *m) -{ - -} SortInterModuleDependencies */ - - - -/* - * Given a non-empty TypeDef list, the refLists of TypeDefs - * are used to divide the list into two lists, one list - * that is sorted the order of dependency (independed-->dependent) - * and the other list contains types that are mutually dependent - * (recursive or depend on recursive types) - * The sorted list is returned and the passed in list has those - * TypeDefs that are now in the sorted list removed. - */ -TypeDefList* -RemoveAndSortIndependents PARAMS ((tdl), - TypeDefList *tdl) -{ - TypeDef *last; - TypeDef *currTd; - TypeDef **tdHndl; - TypeDef *tdRef; - AsnListNode *nextListNode; - long int tdIndex; - long int lastSLCount; - TypeDefList *subList; - int keep; - - /* - * iterate through the list making sub lists that don't depend - * on the others in the active list. Join sub lists in order - * and then deal with the active list if any - */ - lastSLCount = -1; /* just to start */ - subList = AsnListNew (sizeof (void*)); - - if (LIST_EMPTY (tdl)) - return subList; - - /* iterate through each type def in the tdl */ - while ((LIST_COUNT (subList) > lastSLCount) && !LIST_EMPTY (tdl)) - { - lastSLCount = LIST_COUNT (subList); - last = (TypeDef*)LAST_LIST_ELMT (tdl); - SET_CURR_LIST_NODE (tdl, FIRST_LIST_NODE (tdl)); - currTd = (TypeDef*)CURR_LIST_ELMT (tdl); - while (1) - { - nextListNode = NEXT_LIST_NODE (tdl); - keep = 0; - - /* - * iterate through this type def's local type refs. - * - * if any type def in the current type's local type ref list - * is in the tdl, then teh current type must remain in the tdl - * because it depends on that type. - */ - FOR_EACH_LIST_ELMT (tdRef, currTd->refList) - { - /* don't worry about recursive refs to self */ - if (tdRef != currTd) - { - /* - * if the tdRef is not in tdl - * GetElmtIndex will return < 0 - * if the tdRef is in the tdl, then the - * currTd must remain in the tdl. - */ - tdIndex = GetElmtIndex (tdRef, tdl); - if (tdIndex >= 0) - keep = 1; - } - } - if (!keep) - { - /* append to sublist and remove for tdl */ - tdHndl = (TypeDef**) AsnListAppend (subList); - *tdHndl = currTd; - AsnListRemove (tdl); - } - if (currTd == last) - break; /* exit while */ - - SET_CURR_LIST_NODE (tdl, nextListNode); - currTd = (TypeDef*)CURR_LIST_ELMT (tdl); - } - } - return subList; - -} /* RemoveAndSortIndependents */ - - -/* - * Given a list of types that depend on each other, this attempts - * to sort the list from independent--> most dependent. - * - * Kind of wierd algorithm - * 1. first separate and sort out linearly dependent types and place in - * a properly ordered list (RemoveAndSortIndependents) (call it "A") - * - * 2. if types with non-linear (recursive) dependencies remain, - * divide them into two groups, recursive (call it "B")(see recursive.c) - * and non-recursive (call it "C". The non-recursive ones will depend - * on the recursive ones (otherwise step 1 would have grabbed 'em). - * - * 3. Sort the types in list C as done in step one - there should be - * no problems (ie unsorted leftovers) since none of them are recursive. - * - * 4. For the recursive types in list B, re-do their refLists such that - * any types ref'd by a Ptr are not included in the refList - * (may have to update this wrt how the ref is used - - * eg in an inline of the ref'ing type). Then sort as in Step 1. - * Any types that could not be sorted have a definite problem and - * compiliation problems will occur. (.. And the code generation - * technique must be changed) - * (for C only the SET OF and SEQ OF Types are stripped from this - * since they are 'generic' - ie don't depend on the list elmt type) - * - * 5. re-combine all of the lists in order of dependency ie - * A-B-(B's leftovers)-C - * - * (the stripped C lists go after 'A') - */ -void -SortTypeDefs PARAMS ((tdl), - TypeDefList *tdl) -{ - TypeDef *last; - TypeDef *currTd; - TypeDef **tdHndl; - TypeDef *tmpTd; - TypeDef *tdRef; - AsnListNode *tdNodeToMove; - AsnListNode *nextListNode; - long int maxRefCount; - TypeDefList *subList; /* "A" */ - TypeDefList *nonRec; - TypeDefList *sortedRec; /* "B" */ - TypeDefList *sortedNonRec; /* "C" */ - TypeDefList *cLists; - - if ((tdl == NULL) || (LIST_EMPTY (tdl))) - return; - - subList = RemoveAndSortIndependents (tdl); - - /* return if simple sort worked (no recursive types) */ - if (LIST_EMPTY (tdl)) - { - *tdl = *subList; - Free (subList); - return; - } - - /* - * divide the remaining interdepedent types into - * two groups recursive and non-recursive. - * leave the recursive in the tdl and put the others in a new list. - * The non-recursive ones obviously depend on the recursive - * on since all of the simple type dependencies have been - * dealt with by RemoveAndSortIndependents - */ - last = (TypeDef*)LAST_LIST_ELMT (tdl); - SET_CURR_LIST_NODE (tdl, FIRST_LIST_NODE (tdl)); - currTd = (TypeDef*)CURR_LIST_ELMT (tdl); - nonRec = AsnListNew (sizeof (void*)); - - while (1) - { - nextListNode = NEXT_LIST_NODE (tdl); - - if (!currTd->recursive) - { - tdHndl = (TypeDef**)AsnListAppend (nonRec); - *tdHndl = currTd; - AsnListRemove (tdl); - } - - if (currTd == last) - break; /* exit while */ - - SET_CURR_LIST_NODE (tdl, nextListNode); - currTd = (TypeDef*)CURR_LIST_ELMT (tdl); - } - - /* sort the non-recusive types */ - sortedNonRec = RemoveAndSortIndependents (nonRec); - - if (!LIST_EMPTY (nonRec)) - { - fprintf (stderr,"SortTypeDefs: internal compiler error - non recursive type defs failed sort.\n"); - sortedNonRec = AsnListConcat (sortedNonRec, nonRec); - } - Free (nonRec); - - /* - * Remove list types from the list since they are generic. - * put them in "cLists". - * then re-do the dependency list for each type definition that - * remain in the recursive list with weighting - ie types - * that are ref'd as ptrs don't count. Then re-sort. - */ - last = (TypeDef*)LAST_LIST_ELMT (tdl); - SET_CURR_LIST_NODE (tdl, FIRST_LIST_NODE (tdl)); - currTd = (TypeDef*)CURR_LIST_ELMT (tdl); - - cLists = AsnListNew (sizeof (void*)); - while (1) - { - nextListNode = NEXT_LIST_NODE (tdl); - - /* nuke old ref list */ - AsnListFree (currTd->refList); - currTd->refList = NULL; - - /* for C only, remove lists since they are generic */ - if ((currTd->cTypeDefInfo != NULL) && - ((currTd->type->basicType->choiceId == BASICTYPE_SETOF) || - (currTd->type->basicType->choiceId == BASICTYPE_SEQUENCEOF))) - { - tdHndl = (TypeDef**)AsnListAppend (cLists); - *tdHndl = currTd; - AsnListRemove (tdl); - } - - if (currTd == last) - break; /* exit while */ - - SET_CURR_LIST_NODE (tdl, nextListNode); - currTd = (TypeDef*)CURR_LIST_ELMT (tdl); - } - - - - FOR_EACH_LIST_ELMT (currTd, tdl) - { - currTd->refList = AsnListNew (sizeof (void*)); - BuildWeightedLocalRefList (currTd->type, currTd->refList); - } - - sortedRec = RemoveAndSortIndependents (tdl); - - /* - * now merge subLists and put in tdl: - * tdl = cLists + sortedRec + impossible rec in tdl + sorted nonRec - */ - subList = AsnListConcat (subList, cLists); - subList = AsnListConcat (subList, sortedRec); - subList = AsnListConcat (subList, tdl); - subList = AsnListConcat (subList, sortedNonRec); - *tdl = *subList; - - Free (cLists); - Free (subList); - Free (sortedRec); - Free (sortedNonRec); - -} /* SortTypeDefs */ - - - - -/* - * Builds list of TypeDefs in this module that the given type refs. - * Does not follow type refs to include their type refs. - */ -void -BuildLocalRefList PARAMS ((t, refList), - Type *t _AND_ - TypeDefList *refList) -{ - NamedType *e; - TypeDef **tdHndl; - - switch (t->basicType->choiceId) - { - case BASICTYPE_CHOICE: - case BASICTYPE_SET: - case BASICTYPE_SEQUENCE: - FOR_EACH_LIST_ELMT (e, t->basicType->a.choice) - { - BuildLocalRefList (e->type, refList); - } - break; - - case BASICTYPE_SETOF: - case BASICTYPE_SEQUENCEOF: - BuildLocalRefList (t->basicType->a.setOf, refList); - break; - - case BASICTYPE_LOCALTYPEREF: - tdHndl = (TypeDef**)AsnListAppend (refList); - *tdHndl = t->basicType->a.localTypeRef->link; - break; - - /* - * default: other types are not aggregate and - * and can be ignored - */ - } -} /* BuildLocalRefList */ - - -/* - * Builds list of TypeDefs in this module that the given type references. - * Does not follow type refs to include their type refs. - * Does not include types that are ref'd as ptrs since - * If the target lang is C the type SET OF/SEQ OF types reference - * are not counted due to the current 'genericness' of the C list type - * (it doesn't need type info) - * they shouldn't affect type ordering. - */ -void -BuildWeightedLocalRefList PARAMS ((t, refList), - Type *t _AND_ - TypeDefList *refList) -{ - NamedType *e; - TypeDef **tdHndl; - - switch (t->basicType->choiceId) - { - case BASICTYPE_CHOICE: - case BASICTYPE_SET: - case BASICTYPE_SEQUENCE: - FOR_EACH_LIST_ELMT (e, t->basicType->a.choice) - { - BuildWeightedLocalRefList (e->type, refList); - } - break; - - - - case BASICTYPE_SETOF: - case BASICTYPE_SEQUENCEOF: - /* - * normalize makes embedded list defs into - * separate type defs now so this clause will - * not fire. (ie they will be a LOCAL_TYPEREF - * to the removed list type instead) - */ - - /* - * list types for C don't really depend on - * the component type (void*). So if the target lang - * is C then can achieve better ordering - * for ugly recursive defs by using this relaxation - * (ie not including the component type in the ref list) - */ - if (t->cTypeRefInfo == NULL) - BuildWeightedLocalRefList (t->basicType->a.setOf, refList); - - break; - - case BASICTYPE_LOCALTYPEREF: - - if (((t->cxxTypeRefInfo != NULL) && - !(t->cxxTypeRefInfo->isPtr)) || - ((t->cTypeRefInfo != NULL) && !(t->cTypeRefInfo->isPtr))) - { - tdHndl = (TypeDef**)AsnListAppend (refList); - *tdHndl = t->basicType->a.localTypeRef->link; - } - break; - - /* - * default: other types are not aggregate and - * and can be ignored - */ - } -} /* BuildWeightedLocalRefList */ - - - -/* - * Returns the index (starting a 0 for the first elmt) - * of the given td in the td list (tdl) - * returns -1 if td is not in the list - */ -long int -GetElmtIndex PARAMS ((td, tdl), - TypeDef *td _AND_ - TypeDefList *tdl) -{ - void *tmp; - TypeDef *tmpTd; - long int index; - - index = 0; - tmp = (void*) CURR_LIST_NODE (tdl); - FOR_EACH_LIST_ELMT (tmpTd, tdl) - { - if (tmpTd == td) - { - SET_CURR_LIST_NODE (tdl, tmp); - return index; - } - else - index++; - } - - SET_CURR_LIST_NODE (tdl, tmp); - return -1; - -} /* GetElmtIndex */ - - - - - -/* - * Attempts to order the types in tdl from independent-->most depenedent - * uses insertion after TypeDef that the given type def depends on. - * Hoky - doesn't work very well - differing results depending on - * initial order - NO LONGER USED -void -AttemptDependencySort PARAMS ((tdl), - TypeDefList *tdl) -{ - TypeDef *last; - TypeDef *currTd; - TypeDef **tdHndl; - TypeDef *tdRef; - AsnListNode *nextListNode; - long int tdIndex; - long int maxTdIndex; - long int currIndex; - - if (LIST_EMPTY (tdl)) - return; - - last = (TypeDef*)LAST_LIST_ELMT (tdl); - - FOR_EACH_LIST_ELMT (currTd, tdl) - { - currTd->visited = FALSE; - } - - SET_CURR_LIST_NODE (tdl, FIRST_LIST_NODE (tdl)); - currTd = (TypeDef*)CURR_LIST_ELMT (tdl); - - while (1) - { - nextListNode = NEXT_LIST_NODE (tdl); - - if (!currTd->visited) - { - currTd->visited = TRUE; - maxTdIndex = -1; - FOR_EACH_LIST_ELMT (tdRef, currTd->refList) - { - tdIndex = GetElmtIndex (tdRef, tdl); - if (tdIndex > maxTdIndex) - maxTdIndex = tdIndex; - } - } - - currIndex = GetElmtIndex (currTd, tdl); - - if ((maxTdIndex >= 0) && (currIndex < maxTdIndex)) - { - MoveAfter (currIndex, maxTdIndex, tdl); - } - - if (currTd == last) - break; - - SET_CURR_LIST_NODE (tdl, nextListNode); - currTd = (TypeDef*)CURR_LIST_ELMT (tdl); - } -} AttemptDependencySort */ - - - -/* - * Moves list node at currIndex to after Node at afterIndex - * in the given list l. Indexes start at 0 for the first elmt. - * May confuse the 'curr' pointer of the list - NO LONGER USED -void -MoveAfter PARAMS ((currIndex, afterIndex, l), - unsigned long int currIndex _AND_ - unsigned long int afterIndex _AND_ - AsnList *l) -{ - void *tmp; - AsnListNode *nodeToMove; - AsnListNode *afterNode; - int i; - - if ((l == NULL) || - (LIST_COUNT (l) <= currIndex) || - (LIST_COUNT (l) <= afterIndex)) - { - fprintf (stderr,"Internal compiler error - index confusion in MoveAfter\n"); - return; - } - - tmp = (void*) CURR_LIST_NODE (l); - - nodeToMove = l->first; - for (i = 0; i < currIndex; i++) - nodeToMove = nodeToMove->next; - - afterNode = l->first; - for (i = 0; i < afterIndex; i++) - afterNode = afterNode->next; - - pop out node to move - if (nodeToMove->next) - nodeToMove->next->prev = nodeToMove->prev; - else - l->last = nodeToMove->prev; - - if (nodeToMove->prev) - nodeToMove->prev->next = nodeToMove->next; - else - l->first = nodeToMove->next; - - insert node to move after selected node - nodeToMove->next = afterNode->next; - nodeToMove->prev = afterNode; - - if (afterNode->next) - afterNode->next->prev = nodeToMove; - else - l->last = nodeToMove; - - afterNode->next = nodeToMove; - -} MoveAfter */ diff --git a/SecuritySNACCRuntime/compiler/core/dependency.h b/SecuritySNACCRuntime/compiler/core/dependency.h deleted file mode 100644 index f3e0333d..00000000 --- a/SecuritySNACCRuntime/compiler/core/dependency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * compiler/core/depedency.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/dependency.h,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: dependency.h,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:47 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1994/10/08 03:48:38 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:01 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -void SortAllDependencies PROTO ((ModuleList *m)); diff --git a/SecuritySNACCRuntime/compiler/core/do-macros.c b/SecuritySNACCRuntime/compiler/core/do-macros.c deleted file mode 100644 index 9f96c0f8..00000000 --- a/SecuritySNACCRuntime/compiler/core/do-macros.c +++ /dev/null @@ -1,732 +0,0 @@ -/* - * compiler/core/do_macros.c - * - * Runs through type and value def lists and does any processing nec. - * for any macro encountered. - * - * Processing could consist of making stubs for OPERATION macro etc. - * What is done is very environment dependent. - * - * You should change this file to match your environment. - * - * Any Type Defs hidden in a MACRO Type are popped into the normal - * type def list and REFERENCED from the macro (instead of being - * defined there) - * - * SNMP Objectype macro fills the ANY Ref lists so the id to ANY - * type hash table is filled. - * - * Mike Sample - * 91/12/12 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/do-macros.c,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: do-macros.c,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:47 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:23 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:32:28 rj - * snacc_config.h removed; do_macros.h includet. - * - * Revision 1.1 1994/08/28 09:49:03 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include -#include /* for islower/toupper */ - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "define.h" -#include "str-util.h" -#include "normalize.h" -#include "snacc-util.h" -#include "do-macros.h" - -void AddAnyRefByOid PROTO ((AnyRefList **arl, char *enumIdName, AsnOid *oid)); - -void AddAnyRefByInt PROTO ((AnyRefList **arl, char *enumIdName, AsnInt intId)); - - -void ProcessMacrosInTypeDef PROTO ((Module *m, TypeDef *td)); - -void ProcessMacrosInValueDef PROTO ((Module *m, ValueDef *vd)); - -void ProcessMacrosInType PROTO ((Module *m, TypeDef *td, Type *t, ValueDef *v)); - -void ProcessMacrosInElmtTypes PROTO ((Module *m, TypeDef *td, NamedTypeList *e, ValueDef *v)); - -void ProcessMacrosInBasicType PROTO ((Module *m, TypeDef *td, Type *type, BasicType *bt, ValueDef *v)); - -void DefineType PROTO ((Module *m, TypeDef *td, Type *t, char *name)); - -void ProcessRosOperationMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, RosOperationMacroType *op, ValueDef *v)); - -void ProcessRosErrorMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, RosErrorMacroType *err, ValueDef *v)); - -void ProcessRosBindMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, RosBindMacroType *bind, ValueDef *v)); - -void ProcessRosAseMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, RosAseMacroType *ase, ValueDef *v)); - -void ProcessRosAcMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, RosAcMacroType *ac, ValueDef *v)); - -void ProcessMtsasExtensionsMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, MtsasExtensionsMacroType *exts, ValueDef *v)); - -void ProcessMtsasExtensionMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, MtsasExtensionMacroType *ext, ValueDef *v)); - -void ProcessMtsasExtensionAttributeMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, MtsasExtensionAttributeMacroType *ext, ValueDef *v)); - -void ProcessMtsasTokenMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, MtsasTokenMacroType *tok, ValueDef *v)); - -void ProcessMtsasTokenDataMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, MtsasTokenDataMacroType *tok, ValueDef *v)); - -void ProcessMtsasSecurityCategoryMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, MtsasSecurityCategoryMacroType *sec, ValueDef *v)); - -void ProcessAsnObjectMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, AsnObjectMacroType *obj, ValueDef *v)); - -void ProcessAsnPortMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, AsnPortMacroType *p, ValueDef *v)); - -void ProcessAsnAbstractBindMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, AsnAbstractBindMacroType *bind, ValueDef *v)); - -void ProcessSnmpObjectTypeMacroType PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, SnmpObjectTypeMacroType *bind, ValueDef *v)); - -/* -static TypeDef *snmpObjectSyntaxesG = NULL; -*/ - -/* - * Hunts for macros in TypeDefs or ValueDefs and - * might do something with them. - */ -void -ProcessMacros PARAMS ((m), - Module *m) -{ - TypeDef *td; - TypeDef **tmpTypeDefHndl; - ValueDef *vd; - - /* - * go through each type in typeList - */ - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - ProcessMacrosInTypeDef (m, td); - } - - /* - * go through each value in valueList and link - */ - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - ProcessMacrosInValueDef (m, vd); - } - - /* add snmp object syntaxes choice to typedef list */ -/* - tmpTypeDefHndl = (TypeDef**) AsnListAppend (m->typeDefs); - *tmpTypeDefHndl = snmpObjectSyntaxesG; - snmpObjectSyntaxesG = NULL; -*/ - - -} /* ProcessMacros */ - -/* - * Given an AnyRefList, char string for an enum Id, - * and an OBJECT IDENTIFIER, - * this routine puts the id and oid into the AnyRefList. - * When the code is generated, the AnyInit routine for - * the module to which the typeDef that owns the given AnyRefList - * belongs, calls a routine that will cause the given oid to - * hash to the TypeDef that owns the AnyRefList. - * The enumId value at runtime is used for simple determination of - * the ANY type by the user. - */ -void -AddAnyRefByOid PARAMS ((arl, enumId, oid), - AnyRefList **arl _AND_ - char *enumId _AND_ - AsnOid *oid) -{ - AnyRef **anyRefHndl; - - if (*arl == NULL) - *arl = AsnListNew (sizeof (void*)); - - anyRefHndl = (AnyRef**)AsnListAppend (*arl); - *anyRefHndl = MT (AnyRef); - - (*anyRefHndl)->anyIdName = Malloc (strlen (enumId)+1); - strcpy ((*anyRefHndl)->anyIdName, enumId); - - (*anyRefHndl)->id = MT (OidOrInt); - (*anyRefHndl)->id->choiceId = OIDORINT_OID; - (*anyRefHndl)->id->a.oid = MT (AsnOid); - (*anyRefHndl)->id->a.oid->octs = Malloc (oid->octetLen); - memcpy ((*anyRefHndl)->id->a.oid->octs, oid->octs, oid->octetLen); - (*anyRefHndl)->id->a.oid->octetLen = oid->octetLen; - -} /* AddAnyRefByOid */ - -/* - * Like AddAnyRefByOid except that an int maps to the type def - * instead of an OBJECT IDENTIFIER - */ -void -AddAnyRefByInt PARAMS ((arl, enumId, intId), - AnyRefList **arl _AND_ - char *enumId _AND_ - AsnInt intId) -{ - AnyRef **anyRefHndl; - - if (*arl == NULL) - *arl = AsnListNew (sizeof (void*)); - - anyRefHndl = (AnyRef**)AsnListAppend (*arl); - *anyRefHndl = MT (AnyRef); - - (*anyRefHndl)->anyIdName = Malloc (strlen (enumId)+1); - strcpy ((*anyRefHndl)->anyIdName, enumId); - (*anyRefHndl)->id = MT (OidOrInt); - (*anyRefHndl)->id->choiceId = OIDORINT_INTID; - (*anyRefHndl)->id->a.intId = intId; - -} /* AddAnyRefByInt */ - - -void -ProcessMacrosInValueDef PARAMS ((m, vd), - Module *m _AND_ - ValueDef *vd) -{ - if (vd == NULL) - return; - - /* turn linked oid's into encoded oids */ - if (vd->value->basicValue->choiceId == BASICVALUE_LINKEDOID) - NormalizeValue (m, vd, vd->value, FALSE); - - ProcessMacrosInType (m, NULL, vd->value->type, vd); - -} /* ProcessMacrosInValueDef */ - - - -void -ProcessMacrosInTypeDef PARAMS ((m,td), - Module *m _AND_ - TypeDef *td) -{ - if (td == NULL) - return; - - ProcessMacrosInType (m, td, td->type, NULL); - -} /* ProcessMacrosInTypeDef */ - - - -void -ProcessMacrosInType PARAMS ((m, td,t, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - ValueDef *v) -{ - if (t == NULL) - return; - - ProcessMacrosInBasicType (m, td, t, t->basicType, v); - -} /* ProcessMacrosInTypeDef */ - - - -void -ProcessMacrosInElmtTypes PARAMS ((m, td, e, v), - Module *m _AND_ - TypeDef *td _AND_ - NamedTypeList *e _AND_ - ValueDef *v) -{ - NamedType *nt; - FOR_EACH_LIST_ELMT (nt, e) - { - ProcessMacrosInType (m, td, nt->type, v); - } -} /* ProcessElmtTypes */ - - - -void -ProcessMacrosInBasicType PARAMS ((m,td,type,bt, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *type _AND_ - BasicType *bt _AND_ - ValueDef *v) -{ - - if (bt == NULL) - return; - - switch (bt->choiceId) - { - - case BASICTYPE_SEQUENCE: - case BASICTYPE_SET: - case BASICTYPE_CHOICE: - ProcessMacrosInElmtTypes (m, td, bt->a.set,v); - break; - - - - case BASICTYPE_SEQUENCEOF: - case BASICTYPE_SETOF: - ProcessMacrosInType (m, td, bt->a.setOf, v); - break; - - - - case BASICTYPE_MACROTYPE: - switch (bt->a.macroType->choiceId) - { - case MACROTYPE_ASNABSTRACTOPERATION: - case MACROTYPE_ROSOPERATION: - - ProcessRosOperationMacroType (m, td, type, bt, bt->a.macroType->a.rosOperation, v); - break; - - case MACROTYPE_ROSERROR: - case MACROTYPE_ASNABSTRACTERROR: - ProcessRosErrorMacroType (m, td, type, bt, bt->a.macroType->a.rosError, v); - break; - - case MACROTYPE_ROSBIND: - case MACROTYPE_ROSUNBIND: - ProcessRosBindMacroType (m, td, type, bt, bt->a.macroType->a.rosBind,v); - break; - - case MACROTYPE_ROSASE: - ProcessRosAseMacroType (m, td, type, bt, bt->a.macroType->a.rosAse,v); - break; - - case MACROTYPE_MTSASEXTENSIONS: - ProcessMtsasExtensionsMacroType (m, td, type, bt, bt->a.macroType->a.mtsasExtensions,v); - break; - - case MACROTYPE_MTSASEXTENSION: - ProcessMtsasExtensionMacroType (m, td, type, bt, bt->a.macroType->a.mtsasExtension,v); - break; - - case MACROTYPE_MTSASEXTENSIONATTRIBUTE: - ProcessMtsasExtensionAttributeMacroType (m, td, type, bt, bt->a.macroType->a.mtsasExtensionAttribute,v); - break; - - case MACROTYPE_MTSASTOKEN: - ProcessMtsasTokenMacroType (m, td, type, bt, bt->a.macroType->a.mtsasToken,v); - break; - - case MACROTYPE_MTSASTOKENDATA: - ProcessMtsasTokenDataMacroType (m, td, type, bt, bt->a.macroType->a.mtsasTokenData,v); - break; - - case MACROTYPE_MTSASSECURITYCATEGORY: - ProcessMtsasSecurityCategoryMacroType (m, td, type, bt, bt->a.macroType->a.mtsasSecurityCategory,v); - break; - - case MACROTYPE_ASNOBJECT: - ProcessAsnObjectMacroType (m, td, type, bt, bt->a.macroType->a.asnObject,v); - break; - - case MACROTYPE_ASNPORT: - ProcessAsnPortMacroType (m, td, type, bt, bt->a.macroType->a.asnPort,v); - break; - - case MACROTYPE_ASNABSTRACTBIND: - case MACROTYPE_ASNABSTRACTUNBIND: - ProcessAsnAbstractBindMacroType (m, td, type, bt, bt->a.macroType->a.asnAbstractBind,v); - break; - - case MACROTYPE_AFALGORITHM: - case MACROTYPE_AFENCRYPTED: - case MACROTYPE_AFPROTECTED: - case MACROTYPE_AFSIGNATURE: - case MACROTYPE_AFSIGNED: - break; - - case MACROTYPE_SNMPOBJECTTYPE: - ProcessSnmpObjectTypeMacroType (m, td, type, bt, bt->a.macroType->a.snmpObjectType,v); - break; - - default: - /* ignore any others */ - break; - } - - default: - /* the rest do not need processing */ - - break; - } -} /* ProcessMacrosInBasicType */ - - -/* - * Given a Type referenced in a macro, makes up a name and defines - * the type iff the type is not a simple type ref or library type. - * Returns the typedef of the type given type. (may be new may - * be from the typeref if t was a local or import type ref) - */ -void -DefineType PARAMS ((m, td, t, name), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - char *name) -{ - int digit; - TypeDef *newDef; - TypeDef **tmpTypeDefHndl; - Type *tmpType; - TypeDef *retVal; - - if (IsNewType (t)) - { - newDef = (TypeDef*)Malloc (sizeof (TypeDef)); - newDef->exported = FALSE; - newDef->type = (Type*)Malloc (sizeof (Type)); - memcpy (newDef->type, t, sizeof (Type)); - - - newDef->definedName = Malloc (strlen (name)+4); - strcpy (newDef->definedName, name); - - if (islower (newDef->definedName[0])) - newDef->definedName[0] = - toupper (newDef->definedName[0]); - - - /* set up unique type name for new type */ - for (digit = 0; - (LookupType (m->typeDefs, newDef->definedName) != NULL); - digit++) - AppendDigit (newDef->definedName, digit); - - /* - * now put new typedef at head of list - */ - tmpTypeDefHndl = (TypeDef**)AsnListPrepend (m->typeDefs); - *tmpTypeDefHndl = newDef; - - /* convert macro's type def into a ref */ - - SetupType (&tmpType, BASICTYPE_LOCALTYPEREF, 0); - memcpy (t, tmpType, sizeof (Type)); - Free (tmpType); - t->implicit = FALSE; - t->basicType->a.localTypeRef = (TypeRef*)Malloc (sizeof (TypeRef)); - t->basicType->a.localTypeRef->link = newDef; - t->basicType->a.localTypeRef->module = m; - t->basicType->a.localTypeRef->typeName = - newDef->definedName; - - } -} /* DefineType */ - - -void -ProcessRosOperationMacroType PARAMS ((m, td, t, bt, op, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosOperationMacroType *op _AND_ - ValueDef *v) -{ - - if (op->arguments != NULL) - DefineType (m, td, op->arguments->type, v->definedName); - - if (op->result != NULL) - DefineType (m, td, op->result->type, v->definedName); - -} /* ProcessRosOperationMacroType */ - - - -void -ProcessRosErrorMacroType PARAMS ((m, td, t, bt, err, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosErrorMacroType *err _AND_ - ValueDef *v) -{ - if ((err != NULL) && (err->parameter != NULL)) - DefineType (m, td, err->parameter->type, v->definedName); - -} /* ProcessRosErrorMacroType */ - - -void -ProcessRosBindMacroType PARAMS ((m, td, t, bt, bind, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosBindMacroType *bind _AND_ - ValueDef *v) -{ - if (bind != NULL) - { - DefineType (m, td, bind->argument->type, v->definedName); - DefineType (m, td, bind->result->type, v->definedName); - DefineType (m, td, bind->error->type, v->definedName); - } -} /* ProcessRosBindMacroType */ - - -void -ProcessRosAseMacroType PARAMS ((m, td, t, bt, ase, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAseMacroType *ase _AND_ - ValueDef *v) -{ - -} /* ProcessRosAseMacroType */ - - - -void -ProcessRosAcMacroType PARAMS ((m, td, t, bt, ac, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAcMacroType *ac _AND_ - ValueDef *v) -{ - -} /* ProcessRosAcMacroType */ - - - -void -ProcessMtsasExtensionsMacroType PARAMS ((m, td, t, bt, exts, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionsMacroType *exts _AND_ - ValueDef *v) -{ - -} /* ProcessMtsasExtensionsMacroType */ - - -void -ProcessMtsasExtensionMacroType PARAMS ((m, td, t, bt, ext, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionMacroType *ext _AND_ - ValueDef *v) -{ - -} /* ProcessMtsasExtensionMacroType */ - - -void -ProcessMtsasExtensionAttributeMacroType PARAMS ((m, td, t, bt, ext, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionAttributeMacroType *ext _AND_ - ValueDef *v) -{ - -} /* ProcessMtsasExtensionAttributeMacroType */ - - -void -ProcessMtsasTokenMacroType PARAMS ((m, td, t, bt, tok, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenMacroType *tok _AND_ - ValueDef *v) -{ - -} /* ProcessMtsasTokenMacroType */ - - -void -ProcessMtsasTokenDataMacroType PARAMS ((m, td, t, bt, tok, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenDataMacroType *tok _AND_ - ValueDef *v) -{ - - -} /* ProcessMtsasTokenDataMacroType */ - - -void -ProcessMtsasSecurityCategoryMacroType PARAMS ((m, td, t, bt, sec, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasSecurityCategoryMacroType *sec _AND_ - ValueDef *v) -{ - -} /* ProcessMtsasSecurityCategoryMacroType */ - - - -void -ProcessAsnObjectMacroType PARAMS ((m, td, t, bt, obj, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnObjectMacroType *obj _AND_ - ValueDef *v) -{ - -} /* ProcessAsnObjectMacroType */ - - -void -ProcessAsnPortMacroType PARAMS ((m, td, t, bt, p, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnPortMacroType *p _AND_ - ValueDef *v) -{ - -} /* ProcessAsnPortMacroType */ - - - -void -ProcessAsnAbstractBindMacroType PARAMS ((m, td, t, bt, bind, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnAbstractBindMacroType *bind _AND_ - ValueDef *v) -{ - -} /* ProcessAsnBindMacroType */ - - -void -ProcessSnmpObjectTypeMacroType PARAMS ((m, td, t, bt, ot, v), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - SnmpObjectTypeMacroType *ot _AND_ - ValueDef *v) -{ - NamedType *nt; - NamedType **tmpNtHndl; - char anyId[256]; - AnyRefList **arlHndl; - - if ((ot != NULL) && (ot->syntax != NULL)) - DefineType (m, td, ot->syntax, v->definedName); - - /* - * add ANY ref stuff to type ref'd by this macro so it is - * included in the ANY hash table. - */ - - /* - * do this since the SNMP spec doesn't have an ANY type - * but uses the mechanism. (SNMP uses an OCTET STRING - * where the 'ANY' value is - */ - m->hasAnys = TRUE; - - strcpy (anyId, v->definedName); -/* Str2UCase (anyId, strlen (anyId)); */ - strcat (anyId, "_ANY_ID"); - - arlHndl = GetAnyRefListHndl (ot->syntax); - - - if (v->value->basicValue->choiceId == BASICVALUE_OID) - AddAnyRefByOid (arlHndl, anyId, v->value->basicValue->a.oid); - - /* integer types are not allowed, but relax constraints anyway */ - else - AddAnyRefByInt (arlHndl, anyId, v->value->basicValue->a.integer); - - - - /* make a choice with all the object type elmts */ - /* USING THE ANY HASH TABLE NOW - if (snmpObjectSyntaxesG == NULL) - { - snmpObjectSyntaxesG = (TypeDef*) Malloc (sizeof (TypeDef)); - SetupType (&snmpObjectSyntaxesG->type, BASICTYPE_CHOICE, 0); - snmpObjectSyntaxesG->type->basicType->a.choice = - AsnListNew (sizeof (void*)); - snmpObjectSyntaxesG->definedName = "SnmpOpaqueTypes"; - - } - */ - - /* NOT DONE ANYMORE - * make each field in the choice the same as the object - * types SYNTAX field type (adjusted by Define type) - * make choice field name same as OBJ-TYPE value Defs name - * - * NOTE - using ptrs to type/fieldname, not duplicating them - * this may cause freeing probs - */ - /* - nt = MT (NamedType); - nt->fieldName = v->definedName; - nt->type = ot->syntax; - - tmpNtHndl = (NamedType**) - AsnListAppend (snmpObjectSyntaxesG->type->basicType->a.choice); - *tmpNtHndl = nt; - */ - -} /* ProcessSnmpObjectTypeMacro */ diff --git a/SecuritySNACCRuntime/compiler/core/do-macros.h b/SecuritySNACCRuntime/compiler/core/do-macros.h deleted file mode 100644 index 723cfa2a..00000000 --- a/SecuritySNACCRuntime/compiler/core/do-macros.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * compiler/core/do_macros.h - * - * MS 92 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/do-macros.h,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: do-macros.h,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:47 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:24 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:40 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:04 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -void ProcessMacros PROTO ((Module *m)); diff --git a/SecuritySNACCRuntime/compiler/core/err-chk.c b/SecuritySNACCRuntime/compiler/core/err-chk.c deleted file mode 100644 index e057a169..00000000 --- a/SecuritySNACCRuntime/compiler/core/err-chk.c +++ /dev/null @@ -1,996 +0,0 @@ -/* - * compiler/core/err_chk.c - Check for semantic errors an ASN.1 module - * - * The following are checked: - * - * - Components of CHOICE and SET types must have distinct tags. x - * - * - CHOICE, ANY, and ANY DEFINED BY types cannot be implicitly tagged. x - * - * - Type and value names within the same scope must be unique. x - * - * - Field names in a SET, SEQUENCE or CHOICE must be distinct. If - * a CHOICE with no field name is embedded in a SET, SEQUENCE or CHOICE, - * then the embedded CHOICE's field names must be distinct from its - * parents to avoid ambiguity in value notation. x - * - * - An APPLICATION tag can only be used once per module. x (done in asn1.yacc) - * - * - Each value in a named bit (BIT STRINGs) or named number x - * (INTEGERs and ENUMERATED) list must be different. - * - * - Each identifier in a named bit or named number list must be different. x - * - * - The tags on a series of one or more consecutive OPTIONAL or DEFAULT - * SEQUENCE elements and the following element must be distinct. x - * - * link_types.c does the following three checks - * A COMPONENTS OF type in a SET must reference a SET - * A COMPONENTS OF type in a SEQUENCE must reference a SEQUENCE - * SELECTION types must reference a field of a CHOICE type. - * - * - gives a warning if an ANY DEFINED BY type appears in a SET or - * if and ANY DEFINED BY appears in a SEQUENCE before its identifier. - * these cases make decoding difficult. - * - * ******* following are not done yet - need improved value proc. first***** - * - * - Each identifier in a BIT STRING value must from that BIT - * STRING's named bit list. - * - * - SET or SEQUENCE values can be empty {} only if the SET or - * SEQUENCE type was defined as empty or all of its elements are marked - * as OPTIONAL or DEFAULT. - * - * Mike Sample - * 92/07/13 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/err-chk.c,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: err-chk.c,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:47 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1997/09/01 14:19:43 wan - * Improved error output in certain cases. - * - * Revision 1.3 1995/07/25 19:41:25 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:33:02 rj - * snacc_config.h removed; err_chk.h includet. - * - * Revision 1.1 1994/08/28 09:49:05 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "snacc-util.h" -#include "tag-util.h" -#include "define.h" -#include "err-chk.h" - -typedef struct DefinedTag -{ - Tag *tag; - struct DefinedTag *next; -} DefinedTag; - - -typedef struct DefinedName -{ - char *name; - struct DefinedName *next; -} DefinedName; - - -static NamedType *badNamedType; -static DefinedName *fieldNames = NULL; - - -void ErrChkTypeDef PROTO ((Module *m, TypeDef *td)); - -void ErrChkType PROTO ((Module *m, TypeDef *td, Type *parent, NamedType *nt, Type *t)); - -void ErrChkElmtTypes PROTO ((Module *m, TypeDef *td, Type *parent, NamedTypeList *e)); - -void ErrChkBasicType PROTO ((Module *m, TypeDef *td, Type *parent, NamedType *nt, Type *type)); - -void ErrChkValueDef PROTO ((Module *m, ValueDef *vd)); - -void ErrChkValue PROTO ((Module *m, ValueDef *vd, Value *v)); - -int HasDistinctTags PROTO ((NamedTypeList *elmts)); - -int AddFirstTag PROTO ((DefinedObj **definedTags, Type *t)); - -void ChkFieldNames PROTO ((Module *m, TypeDef *td, Type *parent, NamedTypeList *elmts)); - -void ChkNamedNumbers PROTO ((Module *m, Type *t, NamedNumberList *n)); - -void ChkNamedBits PROTO ((Module *m, Type *t, NamedNumberList *n)); - -void ChkSeqTags PROTO ((Module *m, TypeDef *td, Type *t)); - - -/* return TRUE if the Tag *t1 and t2 are the same in class and code */ -int -TagObjCmp PARAMS ((t1, t2), - void *t1 _AND_ - void *t2) -{ - return (((Tag*) t1)->tclass == ((Tag*) t2)->tclass) && - (((Tag*) t1)->code == ((Tag*) t2)->code); -} - - -/* - * Checks for errors listed above. - * sets module status to MOD_ERROR if any errors occured - */ -void -ErrChkModule PARAMS ((m), - Module *m) -{ - TypeDef *td; - ValueDef *vd; - DefinedObj *typeNames; - DefinedObj *valueNames; - ImportModule *impList; - ImportElmt *impElmt; - - /* - * go through each type in typeList - */ - typeNames = NewObjList(); - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - /* first check for name conflicts */ - if (ObjIsDefined (typeNames, td->definedName, StrObjCmp)) - { - PrintErrLoc (m->asn1SrcFileName, td->type->lineNo); - fprintf (stderr,"ERROR - type \"%s\" is multiply defined.\n", td->definedName); - m->status = MOD_ERROR; - } - else - DefineObj (&typeNames, td->definedName); - - /* now check type def internals */ - ErrChkTypeDef (m, td); - } - - /* now check for name conflicts with imported types */ - FOR_EACH_LIST_ELMT (impList, m->imports) - { - FOR_EACH_LIST_ELMT (impElmt, impList->importElmts) - { - if ((!impElmt->privateScope) && (isupper (impElmt->name[0]))) - { - if (ObjIsDefined (typeNames, impElmt->name, StrObjCmp)) - { - PrintErrLoc (m->asn1SrcFileName, impElmt->lineNo); - fprintf (stderr,"ERROR - type \"%s\" is multiply defined.\n", impElmt->name); - m->status = MOD_ERROR; - } - else - DefineObj (&typeNames, impElmt->name); - } - } - } - FreeDefinedObjs (&typeNames); - - - /* - * go through each value for types - */ - valueNames = NewObjList(); - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - /* check for name conflict */ - if (ObjIsDefined (valueNames, vd->definedName, StrObjCmp)) - { - PrintErrLoc (m->asn1SrcFileName, vd->value->lineNo); - fprintf (stderr,"ERROR - value \"%s\" is multiply defined.\n", vd->definedName); - m->status = MOD_ERROR; - } - else - DefineObj (&valueNames, vd->definedName); - - /* check value internal info */ - ErrChkValueDef (m, vd); - } - /* now check for name conflicts with imported values */ - FOR_EACH_LIST_ELMT (impList, m->imports) - { - FOR_EACH_LIST_ELMT (impElmt, impList->importElmts) - { - if ((!impElmt->privateScope) && (islower (impElmt->name[0]))) - { - if (ObjIsDefined (valueNames, impElmt->name, StrObjCmp)) - { - PrintErrLoc (m->asn1SrcFileName, impElmt->lineNo); - fprintf (stderr,"ERROR - value \"%s\" is multiply defined.\n", vd->definedName); - m->status = MOD_ERROR; - } - else - DefineObj (&valueNames, impElmt->name); - } - } - } - - - FreeDefinedObjs (&valueNames); - -} /* ErrChkModule */ - - - -void -ErrChkTypeDef PARAMS ((m, td), - Module *m _AND_ - TypeDef *td) -{ - if (td == NULL) - return; - - ErrChkType (m, td, NULL, NULL, td->type); - -} /* ErrChkTypeDef */ - - - -void -ErrChkType PARAMS ((m, td, parent, nt, t), - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedType *nt _AND_ - Type *t) -{ - if (t == NULL) - return; - - ErrChkBasicType (m, td, parent, nt, t); - -} /* ErrChkType */ - - - -void -ErrChkElmtTypes PARAMS ((m, td, parent, e), - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *e) -{ - NamedType *nt; - - /* - * if starting new type aggregate type, - * check that the field names are distinct - * (goes 'through' un-named elements that are CHOICEs) - */ - if (td->type == parent) - { - ChkFieldNames (m, td, parent, e); - } - - - FOR_EACH_LIST_ELMT (nt, e) - { - ErrChkType (m, td, parent, nt, nt->type); - } -} /* ErrChkElmtTypes */ - - - -void -ErrChkBasicType PARAMS ((m, td, parent, tnt, type), - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedType *tnt _AND_ - Type *type) -{ - int i, numElmtsAdded; - NamedType *newElmt; - NamedType **newElmtHndl; - NamedType *nt; - NamedTypeList *elmts; - NamedType *origNext; - Type *refdType; - enum BasicTypeChoiceId refdTypeId; - TypeDef *newDef; - - if ((type == NULL) || (type->basicType == NULL)) - return; - - switch (type->basicType->choiceId) - { - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_IMPORTTYPEREF: - /* - * make sure that untagged CHOICE and ANY types - * are not implicitly tagged - */ - refdTypeId = ParanoidGetBuiltinType (type); - if ((type->implicit) && - ((refdTypeId == BASICTYPE_CHOICE) || - (refdTypeId == BASICTYPE_ANY) || - (refdTypeId == BASICTYPE_ANYDEFINEDBY)) && - (CountTags (type->basicType->a.localTypeRef->link->type) == 0)) - { - m->status = MOD_ERROR; - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - IMPLICITLY tagged CHOICE, ANY or ANY DEFINED BY type.\n"); - } - - if ((parent != NULL) && - ((refdTypeId == BASICTYPE_ANY) || - (refdTypeId == BASICTYPE_ANYDEFINEDBY))) - { - - /* - * give a warning. It is stupid to have an ANY DEFINED - * BY type in a SET since they are not ordered and hence - * the ANY DEFINED BY type may need to be decoded before - * its identifer which is very difficult - */ - if ((refdTypeId == BASICTYPE_ANYDEFINEDBY) && - (parent->basicType->choiceId == BASICTYPE_SET)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"WARNING - ANY DEFINED BY in a SET needs to be decoded before its identifier. This is not guaranteed since SETs are not ordered. Use a SEQUENCE instead, if possible.\n"); - } - - /* - * give a warning. It is stupid to have an ANY DEFINED - * BY type in a SEQUENCE before its identifier. - * The ANY DEFINED BY type will need to be decoded before - * its identifer which is very difficult. - * tnt is the NamedType holding "type" - */ - if ((refdTypeId == BASICTYPE_ANYDEFINEDBY) && (tnt != NULL) && - (parent->basicType->choiceId == BASICTYPE_SEQUENCE) && - (GetAsnListElmtIndex (tnt, parent->basicType->a.sequence) < - GetAsnListElmtIndex (type->basicType->a.anyDefinedBy->link, parent->basicType->a.sequence))) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"WARNING - ANY DEFINED BY in SEQUENCE should appear before its identifier since the identifier must be decoded before the ANY DEFINED BY type.\n"); - } - - - if (parent->basicType->choiceId == BASICTYPE_SEQUENCE) - nt = LAST_LIST_ELMT (parent->basicType->a.sequence); - - /* - * untagged, optional ANYs are strange and will cause faulty - * decoding code to be generated unless they are the last - * elmt in a SEQUENCE. - * (if they are the last elmt it is easy to check - * for the presence of the ANY if definite lengths are used) - * (must peek ahead for EOC otherwise) - */ - if (!((parent->basicType->choiceId == BASICTYPE_SEQUENCE) && - (type == nt->type)) && - (type->optional) && (CountTags (type) == 0)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"WARNING - untagged optional ANY encountered, the produced code will be wrong.\n"); - } - - /* - * if parent is SET or CHOICE then ANY or ANY DEFINED BY - * should be tagged to help determine its presence - * - * NOTE: there are also probs with untagged ANYs in SEQs - * where the ANY is preceeded by optional elmts - * (err msg written in produced code) - */ - if (((parent->basicType->choiceId == BASICTYPE_SET) || - (parent->basicType->choiceId == BASICTYPE_CHOICE)) && - (CountTags == 0)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"WARNING - untagged ANY in a SET or CHOICE, the produced code will be wrong.\n"); - } - } - - break; - - - case BASICTYPE_INTEGER: - case BASICTYPE_ENUMERATED: - ChkNamedNumbers (m, type, type->basicType->a.integer); - break; - - case BASICTYPE_BITSTRING: - ChkNamedBits (m, type, type->basicType->a.bitString); - break; - - - case BASICTYPE_SEQUENCEOF: - case BASICTYPE_SETOF: - ErrChkType (m, td, type, NULL, type->basicType->a.setOf); - break; - - case BASICTYPE_SEQUENCE: - ErrChkElmtTypes (m, td, type, type->basicType->a.sequence); - - /* - * check that tags on one or more consecutive optional elmts - * and following (if any) non-optional elmt are distinct - */ - ChkSeqTags (m, td, type); - break; - - - case BASICTYPE_CHOICE: - /* CHOICE elements must have distinct tags */ - if (!HasDistinctTags (type->basicType->a.choice)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - tag conflict among "); - PrintType (stderr, NULL, badNamedType->type); - fprintf (stderr," and the other CHOICE elements.\n"); - m->status = MOD_ERROR; - } - - /* - * untagged choices cannot be implicitily tagged - * (this would make it impossible/difficult to figure out which - * elmt of the choice was present when decoding) - */ - if (((type->tags == NULL) || LIST_EMPTY (type->tags)) && - (type->implicit)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - IMPLICITLy tagged CHOICE type.\n"); - m->status = MOD_ERROR; - } - - /* Check out each of the components */ - ErrChkElmtTypes (m, td, type, type->basicType->a.choice); - - - break; - - case BASICTYPE_ANYDEFINEDBY: - /* for ANY DEFINED BY make sure id field is int or oid */ - refdType = GetType (type->basicType->a.anyDefinedBy->link->type); - if ((refdType->basicType->choiceId != BASICTYPE_INTEGER) && - (refdType->basicType->choiceId != BASICTYPE_ENUMERATED) && - (refdType->basicType->choiceId != BASICTYPE_OID)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - Field referenced by ANY DEFINED BY type must be of INTEGER or OBJECT IDENTIFIER type.\n"); - m->status = MOD_ERROR; - } - - /* make sure id field is not optional */ - if (type->basicType->a.anyDefinedBy->link->type->optional) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - Field referenced by ANY DEFINED BY cannot be optional.\n"); - m->status = MOD_ERROR; - } - - /* - * give a warning. It is stupid to have an ANY DEFINED - * BY type in a SET since they are not ordered and hence - * the ANY DEFINED BY type may need to be decoded before - * its identifer which is very difficult - */ - if ((parent != NULL) && - (parent->basicType->choiceId == BASICTYPE_SET)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"WARNING - ANY DEFINED BY in a SET needs to be decoded before its identifier. This is not guaranteed since SETs are not ordered. Use a SEQUENCE instead, if possible.\n"); - } - - /* - * give a warning. It is stupid to have an ANY DEFINED - * BY type in a SEQUENCE before its identifier. - * The ANY DEFINED BY type will need to be decoded before - * its identifer which is very difficult. - * tnt is the NamedType holding "type" - */ - if ((parent != NULL) && (tnt != NULL) && - (parent->basicType->choiceId == BASICTYPE_SEQUENCE) && - (GetAsnListElmtIndex (tnt, parent->basicType->a.sequence) < - GetAsnListElmtIndex (type->basicType->a.anyDefinedBy->link, parent->basicType->a.sequence))) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"WARNING - ANY DEFINED BY in SEQUENCE should appear before its identifier since the identifier must be decoded before the ANY DEFINED BY type.\n"); - } - - - /* fall through - arrrrrg! */ - - - case BASICTYPE_ANY: - /* ANY cannot be implicitily tagged */ - if (((type->tags == NULL) || LIST_EMPTY (type->tags)) && - (type->implicit)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - IMPLICITLy tagged ANY type.\n"); - m->status = MOD_ERROR; - } - - - if (parent != NULL) - { - if (parent->basicType->choiceId == BASICTYPE_SEQUENCE) - nt = LAST_LIST_ELMT (parent->basicType->a.sequence); - - /* - * untagged, optional ANYs are strange and will cause faulty - * decoding code to be generated unless they are the last - * elmt in a SEQUENCE - */ - if (!((parent->basicType->choiceId == BASICTYPE_SEQUENCE) && - (type == nt->type)) && - (type->optional) && (CountTags (type) == 0)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"WARNING - untagged optional ANY encountered, the produced code will be wrong.\n"); - } - - /* - * if parent is SET or CHOICE then ANY or ANY DEFINED BY - * should be tagged to help determine its presence - * - * NOTE: there are also probs with untagged ANYs in SEQs - * where the ANY is preceeded by optional elmts - * (err msg written in produced code) - */ - if (((parent->basicType->choiceId == BASICTYPE_SET) || - (parent->basicType->choiceId == BASICTYPE_CHOICE)) && - (CountTags (type) == 0)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"WARNING - untagged ANY in a SET or CHOICE, the produced code will be wrong.\n"); - } - } - - - break; - - - - case BASICTYPE_SET: - /* SET elements must have distinct tags */ - if (!HasDistinctTags (type->basicType->a.set)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - tag conflict among "); - PrintType (stderr, NULL, badNamedType->type); - fprintf (stderr," and the other SET elements.\n"); - m->status = MOD_ERROR; - } - - /* Check out each of the components */ - ErrChkElmtTypes (m, td, type, type->basicType->a.set); - break; - - - default: - /* the rest do not need checking */ - break; - } -} /* ErrChkBasicType */ - - -void -ErrChkValueDef PARAMS ((m, vd), - Module *m _AND_ - ValueDef *vd) -{ - ErrChkValue (m, vd, vd->value); -} - -void -ErrChkValue PARAMS ((m, vd, v), - Module *m _AND_ - ValueDef *vd _AND_ - Value *v) -{ -} - - -/* - * returns non-zero if the first tags on the elements - * are all different. Otherwise 0 is returned - * - * algorithm: add each tag to a list, adding only if - * not already in list. if there, free list - * and return FALSE. if finished adding tags - * and no duplicates occurred then return TRUE; - */ -int -HasDistinctTags PARAMS ((elmts), - NamedTypeList *elmts) -{ - DefinedObj *tL; - NamedType *e; - - tL = NewObjList(); - FOR_EACH_LIST_ELMT (e, elmts) - { - if (!AddFirstTag (&tL, e->type)) - { - FreeDefinedObjs (&tL); - badNamedType = e; - return FALSE; - } - } - FreeDefinedObjs (&tL); - badNamedType = NULL; - return TRUE; -} /* HasDistinctTags */ - - -/* - * puts first tag of the given type into the defined tags list - * returns FALSE if the tag was already in the defined tags list. - * return TRUE otherwise - */ -int -AddFirstTag PARAMS ((definedTags, t), - DefinedObj **definedTags _AND_ - Type *t) -{ - Tag *tag; - TagList *tl; - Tag *last; - int implicitRef; - NamedType *e; - - tl = t->tags; - if (tl != NULL) - AsnListFirst (tl); - - implicitRef = FALSE; - - for (;;) - { - /* - * get first tag from tag list local to this type if any - */ - - if ((tl != NULL) && (CURR_LIST_NODE (tl) != NULL) && - (CURR_LIST_ELMT (tl) != NULL)) - { - tag = (Tag*) CURR_LIST_ELMT (tl); - - if (ObjIsDefined (*definedTags, tag, TagObjCmp)) - return FALSE; - else - { - DefineObj (definedTags, tag); - return TRUE; - } - } - - /* - * follow tags of referenced types if no tags on this type - */ - - if ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - { - if (!implicitRef) - implicitRef = t->implicit; - - - if (t->basicType->a.localTypeRef->link == NULL) - { - /* this should be found in the type link stage */ - fprintf (stderr,"ERROR - unresolved type ref, cannot get tags for decoding\n"); - break; - } - t = t->basicType->a.localTypeRef->link->type; - tl = t->tags; - - if (tl != NULL) - { - AsnListFirst (tl); /* set curr ptr to first node */ - if ((!LIST_EMPTY (tl)) && implicitRef) - { - AsnListNext (tl); - implicitRef = FALSE; - } - } - - } - - /* - * if untagged choice and no tags found yet - */ - else if ((t->basicType->choiceId == BASICTYPE_CHOICE)) - { - /* - * add top level tags from each choice elmt - */ - if (implicitRef) - { - fprintf (stderr,"ERROR - IMPLICITLY Tagged CHOICE\n"); - } - - - FOR_EACH_LIST_ELMT (e, t->basicType->a.choice) - { - if (!AddFirstTag (definedTags, e->type)) - return FALSE; - } - - return TRUE; - } - - else /* could be ANY type - assume correct tagging */ - return TRUE; - - } - -} /* AddFirstTag */ - - - - -/* - * Prints Errors if the field names of the elements are - * not distinct. - * currently an endless recursion problem here - * for recursive types involving CHOICEs - Fixed MS - */ -void -ChkFieldNamesRec PARAMS ((m, td, parent, elmts, fieldNames, followedTypeRefs), - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts _AND_ - DefinedObj **fieldNames _AND_ - DefinedObj **followedTypeRefs) -{ - NamedType *e; - Type *definingType; - - FOR_EACH_LIST_ELMT (e, elmts) - { - definingType = ParanoidGetType (e->type); - if (e->fieldName != NULL) - { - if (ObjIsDefined (*fieldNames, e->fieldName, StrObjCmp)) - { - if (parent->basicType->a.choice == elmts) - { - PrintErrLoc (m->asn1SrcFileName, e->type->lineNo); - fprintf (stderr,"WARNING - field name \"%s\" is used more than once in same value notation scope.\n", e->fieldName); - } - else - { - PrintErrLoc (m->asn1SrcFileName, parent->lineNo); - fprintf (stderr,"WARNING - field name \"%s\" in embedded CHOICE conflicts with field name in type \"%s\".", e->fieldName, td->definedName); - fprintf (stderr," This may lead to ambiguous value notation.\n"); - } - /* m->status = MOD_ERROR; */ - } - else - DefineObj (fieldNames, e->fieldName); - } - - /* - * must include embedded CHOICE's field names - * if it has no field name (this case is a reference to - * a CHOICE) (fieldName is NULL) - */ - else if (((e->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (e->type->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) && - (definingType->basicType->choiceId == BASICTYPE_CHOICE)) - { - /* stop if this is a recursive ref we have already checked */ - if (!ObjIsDefined (*followedTypeRefs, e->type->basicType->a.localTypeRef->typeName, StrObjCmp)) - { - /* push this type name so we don't go through it again */ - DefineObj (followedTypeRefs, e->type->basicType->a.localTypeRef->typeName); - /* pass in field type not defining type as parent for line no*/ - ChkFieldNamesRec (m, td, e->type, definingType->basicType->a.choice, fieldNames, followedTypeRefs); - - /* pop this type name since we're done checking it */ - UndefineObj (followedTypeRefs, e->type->basicType->a.localTypeRef->typeName, StrObjCmp); - } - } - - /* this is an embedded CHOICE definition (fieldName is NULL) */ - else if (e->type->basicType->choiceId == BASICTYPE_CHOICE) - { - ChkFieldNamesRec (m, td, e->type, /* pass in field type for line */ - definingType->basicType->a.choice, fieldNames, followedTypeRefs); - } - - } -} /* ChkFieldNamesRec */ - - - -/* - * wrapper for ChkFieldNamesRec - * Checks that the field names of an aggregate type (CHOICE/SET/SEQ) - * are distinct. Violations are printed to stderr. - */ -void -ChkFieldNames PARAMS ((m, td, parent, elmts), - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *elmts) -{ - DefinedObj *fieldNames; - DefinedObj *followedTypeRefs; - - fieldNames = NewObjList(); - followedTypeRefs = NewObjList(); - - /* - * first define the type itself as followed to prevent - * infinintely checking it - */ - DefineObj (&followedTypeRefs, td->definedName); - - ChkFieldNamesRec (m, td, parent, elmts, &fieldNames, &followedTypeRefs); - - FreeDefinedObjs (&fieldNames); - FreeDefinedObjs (&followedTypeRefs); - -} /* ChkFieldNames */ - - - -/* - * make sure that the identifiers of the named numbers are unique - * among themselves. - * - * also check that the values of the named numbers are unique - * among themselves. - */ -void -ChkNamedNumbers PARAMS ((m, t, n), - Module *m _AND_ - Type *t _AND_ - NamedNumberList *n) -{ - DefinedObj *ids; - DefinedObj *nums; - ValueDef *nn; - Value *baseVal; - - - if (n == NULL) - return; - - ids = NewObjList(); - nums = NewObjList(); - FOR_EACH_LIST_ELMT (nn, n) - { - if (ObjIsDefined (ids, nn->definedName, StrObjCmp)) - { - PrintErrLoc (m->asn1SrcFileName, t->lineNo); - fprintf (stderr,"ERROR - named numbers (%s) must have unique identifiers.\n", nn->definedName); - } - else - DefineObj (&ids, nn->definedName); - - baseVal = GetValue (nn->value); - if (baseVal->basicValue->choiceId != BASICVALUE_INTEGER) - { - PrintErrLoc (m->asn1SrcFileName, t->lineNo); - fprintf (stderr,"ERROR - value format problem (%s)- named numbers must be integers.\n", nn->definedName); - } - else if (ObjIsDefined (nums, &baseVal->basicValue->a.integer, IntObjCmp)) - { - PrintErrLoc (m->asn1SrcFileName, t->lineNo); - fprintf (stderr,"ERROR - named numbers (%s) must have unique values.\n", nn->definedName); - } - else - DefineObj (&nums, &baseVal->basicValue->a.integer); - - } - - FreeDefinedObjs (&ids); - FreeDefinedObjs (&nums); - -} /* ChkNamedNumbers */ - - - -/* - * The same as ChkNamedNumbers except that the elmt values must be - * > 0 (needed for BIT STRINGs) - */ -void -ChkNamedBits PARAMS ((m, t, n), - Module *m _AND_ - Type *t _AND_ - NamedNumberList *n) -{ - ValueDef *vd; - Value *baseVal; - - ChkNamedNumbers (m, t, n); - - FOR_EACH_LIST_ELMT (vd, n) - { - baseVal = GetValue (vd->value); - if ((baseVal->basicValue->choiceId == BASICVALUE_INTEGER) && - (baseVal->basicValue->a.integer < 0)) - { - PrintErrLoc (m->asn1SrcFileName, t->lineNo); - fprintf (stderr,"ERROR - named bits (%s) must have positive values.\n", vd->definedName); - } - } - -} /* ChkNamedBits */ - - - -/* - * check that tags on one or more consecutive optional elmts - * and following (if any) non-optional elmt are distinct - */ -void -ChkSeqTags PARAMS ((m, td, t), - Module *m _AND_ - TypeDef *td _AND_ - Type *t) -{ - DefinedObj *dO; - NamedType *e; - - if (t->basicType->choiceId != BASICTYPE_SEQUENCE) - return; - - dO = NewObjList(); - FOR_EACH_LIST_ELMT (e, t->basicType->a.sequence) - { - /* if optional add tag */ - if (e->type->optional || (e->type->defaultVal != NULL)) - { - if (!AddFirstTag (&dO, e->type)) - { - PrintErrLoc (m->asn1SrcFileName, e->type->lineNo); - fprintf (stderr,"ERROR - one or more consecutive optional SEQUENCE elmements and the the following non-optional elmt (if any) must have distinct tags.\n"); - m->status = MOD_ERROR; - } - } - else if (dO != NULL) /* first non-opt after opt elmts */ - { - if (!AddFirstTag (&dO, e->type)) - { - PrintErrLoc (m->asn1SrcFileName, e->type->lineNo); - fprintf (stderr,"ERROR - one or more consecutive optional SEQUENCE elmements and the the following non-optional elmt (if any) must have distinct tags.\n"); - m->status = MOD_ERROR; - } - FreeDefinedObjs (&dO); - dO = NewObjList(); - } - } - FreeDefinedObjs (&dO); - -} /* ChkSeqTags */ diff --git a/SecuritySNACCRuntime/compiler/core/err-chk.h b/SecuritySNACCRuntime/compiler/core/err-chk.h deleted file mode 100644 index 696d1954..00000000 --- a/SecuritySNACCRuntime/compiler/core/err-chk.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * compiler/core/err_chk.h - check parsed, linked & normalized module for semantic errors - * - * MS 92 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/err-chk.h,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: err-chk.h,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:47 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:26 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:42 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:07 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -void ErrChkModule PROTO ((Module *m)); diff --git a/SecuritySNACCRuntime/compiler/core/exports.c b/SecuritySNACCRuntime/compiler/core/exports.c deleted file mode 100644 index 036366ed..00000000 --- a/SecuritySNACCRuntime/compiler/core/exports.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * compiler/core/exports.c - * - * ExportElmt list set up during parse. - * (not kept in Module data struct) - * - * SetExports runs through type, value & macro defs and sets the - * exported flag accordingly. - * - * The exportsParsed boolean means whether the symbol "EXPORTS" - * was parsed - since if EXPORTS was parsed and the export list - * is empty, NOTHING is exported, otherwise if the "EXPORTS" - * symbol was not parsed (export list is empty) then EVERYTHING - * is exported. If "EXPORTS" was parsed and the list is not - * empty, then mark each item is the list as exported and the - * rest (that are not in the list) as not exported. - * - * Mike Sample - * 91/09/04 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/exports.c,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: exports.c,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:48 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:27 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:33:28 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:08 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "snacc-util.h" -#include "exports.h" - -/* - * called from main in snacc.c to set exported flags for - * typeDefs and valueDefs in the given module - */ -void -SetExports PARAMS ((m, e, exportsParsed), - Module *m _AND_ - ExportElmt *e _AND_ - int exportsParsed) -{ - TypeDef *td; - ValueDef *vd; - - if (!exportsParsed) /* export everything */ - { - /* - * set all typedefs', valuedefs' and macrodefs' exported flag - */ - m->exportStatus = EXPORTS_ALL; - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - td->exported = TRUE; - } - - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - vd->exported = TRUE; - } - } - else /* EXPORTS sym parsed */ - { - /* init every exports flag to false */ - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - td->exported = FALSE; - } - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - vd->exported = FALSE; - } - - if (e == NULL) /* export nothing */ - { - m->exportStatus = EXPORTS_NOTHING; - } - else /* just export types/values in export list */ - { - m->exportStatus = EXPORTS_SOME; - for (; e != NULL; e = e->next) - { - if ((td = LookupType (m->typeDefs, e->name)) != NULL) - td->exported = TRUE; - - else if ((vd = LookupValue (m->valueDefs, e->name)) != NULL) - vd->exported = TRUE; - else - { - PrintErrLoc (m->asn1SrcFileName, e->lineNo); - fprintf (stderr, "ERROR - exporting undefined type/value \"%s\"\n", e->name); - } - } - } - } -} /* SetExports */ diff --git a/SecuritySNACCRuntime/compiler/core/exports.h b/SecuritySNACCRuntime/compiler/core/exports.h deleted file mode 100644 index a016163a..00000000 --- a/SecuritySNACCRuntime/compiler/core/exports.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * compiler/core/exports.h - - * - * ExportElmt list set up during parse. - * (not kept in Module data struct) - * - * SetExports runs through type, value & macro defs and sets the - * exports flag accordingly. - * - * the exportsParsed boolean means whether the symbol "EXPORTS" - * was parsed - since if EXPORTS was parsed and the export list - * is empty, NOTHING is exported, otherwise if the "EXPORTS" - * symbol was not parsed (export list is empty) then EVERYTHING - * is exported - * - * Mike Sample - * 91/09/04 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/exports.h,v 1.1 2001/06/20 21:27:56 dmitch Exp $ - * $Log: exports.h,v $ - * Revision 1.1 2001/06/20 21:27:56 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:48 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1994/10/08 03:48:43 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:09 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -typedef struct ExportElmt -{ - char *name; - long int lineNo; - struct ExportElmt *next; -} ExportElmt; - - -void SetExports PROTO ((Module *m, ExportElmt *e, int exportsParsed)); diff --git a/SecuritySNACCRuntime/compiler/core/gen-tbls.c b/SecuritySNACCRuntime/compiler/core/gen-tbls.c deleted file mode 100644 index e0c8cc57..00000000 --- a/SecuritySNACCRuntime/compiler/core/gen-tbls.c +++ /dev/null @@ -1,741 +0,0 @@ -/* - * compiler/core/gen_tbls.c - * - * generates type tables and writes them to a file. - * - * MS - * 93/02/07 - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/gen-tbls.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: gen-tbls.c,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:48 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1997/06/19 09:17:16 wan - * Added isPdu flag to tables. Added value range checks during parsing. - * - * Revision 1.4 1997/05/07 15:18:34 wan - * Added (limited) size constraints, bitstring and enumeration names to tables - * - * Revision 1.3 1995/07/25 19:41:28 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:33:41 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:10 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "tbl.h" -#include "gen-tbls.h" - -extern Module *usefulTypeModG; - -/* non-exported routine protos */ -void GenTypeDefIds PROTO ((TBL *tbl, Module *m)); -int GenTblModule PROTO ((TBL *tbl, Module *m, TBLModule **newTbl)); -int GenTblTypeDefs PROTO ((TBL *tbl, Module *m, TBLModule *tblMod)); -int GenTblTypes PROTO ((TBL *tbl, Module *m, TBLModule *tblMod, TypeDef *td, TBLTypeDef *tblTd)); -TBLType *GenTblTypesRec PROTO ((TBL *tbl,Module *m, TBLModule *tblMod, TypeDef *td, TBLTypeDef *tblTd, Type *t)); - - -static int abortTblTypeDefG; -static int tblTypesTotalG; -static int tblTagsTotalG; -static int tblStringsTotalG; -static int tblStringLenTotalG; - -static int tableFileVersionG; - -void -GenTypeTbls PARAMS ((mods, fileName, tableFileVersion), - ModuleList *mods _AND_ - char *fileName _AND_ - int tableFileVersion) -{ - TBL tbl; - TBLModule *newTblMod; - FILE *tblFile; - ExpBuf *buf; - ExpBuf *tmpBuf; - Module *m; - - tableFileVersionG = tableFileVersion; - - tbl.modules = AsnListNew (sizeof (void*)); - tbl.totalNumModules = 0; - tbl.totalNumTypeDefs = 0; - tbl.totalNumTypes = 0; - tbl.totalNumTags = 0; - tbl.totalNumStrings = 0; - tbl.totalLenStrings = 0; - - /* - * Give each type def a unique id - * Id is stored in TypeDef's "tmpRefCount" since - * it was only used in the recursion pass. - * Also updates tbl.totalNumModules and - * tbl.totalNumTypeDefs appropriately - */ - FOR_EACH_LIST_ELMT (m, mods) - { - GenTypeDefIds (&tbl, m); - } - - /* number useful types if they are there any */ - if (usefulTypeModG != NULL) - GenTypeDefIds (&tbl, usefulTypeModG); - - /* convert each module from parse format to simpler table format */ - FOR_EACH_LIST_ELMT (m, mods) - { - if (!GenTblModule (&tbl, m, &newTblMod)) - { - fprintf (stderr,"ERROR: type table generator failed for module \"%s\", so file \"%s\" will not be written.\n", m->modId->name, fileName); - return; - } - } - - /* - * convert useful type mod from parse format to - * simpler table format, if one was given - */ - if (usefulTypeModG != NULL) - { - if (!GenTblModule (&tbl, usefulTypeModG, &newTblMod)) - { - fprintf (stderr,"ERROR: type table generator failed for useful types module, file \"%s\" will not be written.\n",fileName); - return; - } - /* mark the module as useful */ - newTblMod->isUseful = TRUE; - } - - /* encode the TBLModules */ - ExpBufInit (1024); - buf = ExpBufAllocBufAndData(); - - BEncTBL (&buf, &tbl); - - if (ExpBufWriteError (&buf)) - { - fprintf (stderr,"ERROR: buffer write error during encoding of type table.\n", fileName); - return; - } - - - /* open & truncate or create as file with given filename */ - tblFile = fopen (fileName,"w"); - - if (tblFile == NULL) - { - fprintf (stderr,"ERROR: Could not open file \"%s\" for the type table.\n", fileName); - return; - } - - - /* - * go through buffer (s) and write encoded value - * to stdout - */ - buf->curr = buf->dataStart; - for (tmpBuf = buf; tmpBuf != NULL; tmpBuf = tmpBuf->next) - { - fwrite (tmpBuf->dataStart, tmpBuf->dataEnd - tmpBuf->dataStart, 1, tblFile); - } - - fclose (tblFile); - -} /* GenTypeTbls */ - - -/* - * The typeDefIds start at zero. They are used as "portable" - * pointers. Each TBLTypeDef has a unique typeDefId. - * The typeDefIds in a given TBLModule will be consecutive - * and increasing from the first typedef to the last. - * - * This routine gives each type def in the given module a unique - * integer identifier. - * This id is temporarily stored in the tmpRefCount field of the TypeDef - * (in the big parse tree). The typeDefId is transfered - * to the TBL data structure after this. - * - * tbl.totalNumModules and tbl.totalNumTypeDefs are updated. - * - * ASSUMES: that tbl->totalNumModules is initialized to zero - * and that tbl->totalNumTypeDefs is initialized to zero - * on the first call to this routine. - * This allows subsequent calls to give out the proper ids - * to the types in the next module. - * - * (the type ids range from 0 to tbl->totalNumTypeDefs-1 (inclusive)) - */ -void -GenTypeDefIds PARAMS ((tbl,m), - TBL *tbl _AND_ - Module *m) -{ - TypeDef *td; - - tbl->totalNumModules++; - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - td->tmpRefCount = tbl->totalNumTypeDefs; - tbl->totalNumTypeDefs++; - } - -} /* GenTypeDefIds */ - - -/* - * builds a TBLModule from the given module and appends it to - * the given TBL's module list. Also updates the TBLs - * totals for modules, tags, typedefs and types. - * Returns TRUE is succeeded. FALSE is failed. - */ -int -GenTblModule PARAMS ((tbl, m, newTblMod), - TBL *tbl _AND_ - Module *m _AND_ - TBLModule **newTblMod) -{ - TBLModule **mHndl; - TBLModule *tblMod; - int eLen; - AsnOid *result; - - mHndl = AsnListAppend (tbl->modules); - - tblMod = MT (TBLModule); - *newTblMod = *mHndl = tblMod; - - /* copy the name */ - tblMod->name.octetLen = strlen (m->modId->name); - tblMod->name.octs = Malloc (tblMod->name.octetLen + 1); - strcpy (tblMod->name.octs, m->modId->name); - tbl->totalNumStrings++; - tbl->totalLenStrings += tblMod->name.octetLen; - - /* copy the OBJECT IDENTIFIER (if any) */ - if (m->modId->oid != NULL) - { - /* convert the (linked) OID into a (encoded) AsnOid */ - if (FlattenLinkedOid (m->modId->oid)) - { - eLen = EncodedOidLen (m->modId->oid); - tblMod->id.octetLen = eLen; - tblMod->id.octs = (char*)Malloc (eLen); - BuildEncodedOid (m->modId->oid, &tblMod->id); - tbl->totalNumStrings++; - tbl->totalLenStrings += eLen; - } - } - - /* - * useful defaults to false - * (ie assume the it is not the usefultypes modules) - */ - tblMod->isUseful = FALSE; - - /* now copy each of the type defs */ - return GenTblTypeDefs (tbl, m, tblMod); - -} /* GenTblModule */ - - -/* - * converts typeDefs in Module format to TBLModule format - * returns TRUE for success, FALSE for failure. - */ -int -GenTblTypeDefs PARAMS ((tbl, m, tblMod), - TBL *tbl _AND_ - Module *m _AND_ - TBLModule *tblMod) -{ - TypeDef *td; - TBLTypeDef **tblTdHndl; - TBLTypeDef *tblTd; - int isOk = TRUE; /* init to no errors */ - - tblMod->typeDefs = AsnListNew (sizeof (void*)); - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - - tblTd = MT (TBLTypeDef); - - /* set type def id */ - tblTd->typeDefId = td->tmpRefCount; - - /* copy type def name */ - tblTd->typeName.octetLen = strlen (td->definedName); - tblTd->typeName.octs = Malloc (tblTd->typeName.octetLen + 1); - strcpy (tblTd->typeName.octs, td->definedName); - tbl->totalNumStrings++; - tbl->totalLenStrings += tblTd->typeName.octetLen; - -/* - if (td->isPdu) - tblTd->isPdu = MT (AsnNull); -*/ - if (m!=usefulTypeModG) - { - MyString attr; - char* attrName; - char* attrValue; - int result = FALSE; - FOR_EACH_LIST_ELMT(attr,td->attrList) - { - int loc = 0; - while (TRUE) - { - ParseAttr(attr,&loc,&attrName,&attrValue); - if (!attrName) - break; - if (!strcmp(attrName,"isPdu")) - if (ParseBool(attrValue,&result)<0) - fprintf(stderr,"Warning: ignoring attribute with improper value (%s/%s)\n",attrName,attrValue); - Free(attrValue); - } - } - if (result) - tblTd->isPdu = MT (AsnNull); - } - - - /* fill in type portion */ - if (!GenTblTypes (tbl, m, tblMod, td, tblTd) && !abortTblTypeDefG) - isOk = FALSE; - - - /* - * add TBLtypeDef to TBLModule - * if no weird types were found - * (weird types are skipped) - */ - if (!abortTblTypeDefG) - { - tblTdHndl = AsnListAppend (tblMod->typeDefs); - *tblTdHndl = tblTd; - tbl->totalNumTypes += tblTypesTotalG; - tbl->totalNumTags += tblTagsTotalG; - tbl->totalNumStrings += tblStringsTotalG; - tbl->totalLenStrings += tblStringLenTotalG; - } - /* else could free it */ - - } - return isOk; -} /* GenTblTypeDefs */ - - -/* - * converts Module Type to a TBLModule Type. attaches converted - * type info to the given tblTd. - * Returns TRUE for success, FALSE for failure. - */ -int -GenTblTypes PARAMS ((tbl, m, tblMod, td, tblTd), - TBL *tbl _AND_ - Module *m _AND_ - TBLModule *tblMod _AND_ - TypeDef *td _AND_ - TBLTypeDef *tblTd) -{ - abortTblTypeDefG = FALSE; - tblTypesTotalG = 0; - tblTagsTotalG = 0; - tblStringsTotalG = 0; - tblStringLenTotalG = 0; - - tblTd->type = GenTblTypesRec (tbl, m, tblMod, td, tblTd, td->type); - - if (tblTd->type == NULL) - return FALSE; /* failed */ - else - return TRUE; - -} /* GenTblTypes */ - -BasicValue* -GetTblValue PARAMS ((v), - Value* v) -{ - switch (v->basicValue->choiceId) - { - case BASICVALUE_INTEGER: - return v->basicValue; - default: - return NULL; - } -} - -enum BasicTypeChoiceId -GetTblBasicType PARAMS ((bt), - BasicType* bt) -{ - switch (bt->choiceId) - { - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_IMPORTTYPEREF: - return GetTblBasicType (bt->a.localTypeRef->link->type->basicType); - default: - return bt->choiceId; - } -} - -TBLRange* -GenTblValueRange PARAMS ((tbl, m, tblMod, s, doSize), - TBL *tbl _AND_ - Module *m _AND_ - TBLModule *tblMod _AND_ - Subtype *s _AND_ - int doSize) -{ - TBLRange* range; - BasicValue* from; - BasicValue* to; - - if (tableFileVersionG<=1) - return NULL; - - switch (s->choiceId) - { - case SUBTYPE_SINGLE: - switch (s->a.single->choiceId) - { - case SUBTYPEVALUE_SINGLEVALUE: - if (doSize) - return NULL; - from = to = GetTblValue (s->a.single->a.singleValue); - break; - case SUBTYPEVALUE_VALUERANGE: - if (doSize) - return NULL; - from =GetTblValue(s->a.single->a.valueRange->lowerEndValue); - to = GetTblValue (s->a.single->a.valueRange->upperEndValue); - break; - case SUBTYPEVALUE_SIZECONSTRAINT: - if (!doSize) - return NULL; - return GenTblValueRange (tbl, m, tblMod, - s->a.single->a.sizeConstraint, 0); - break; - default: - return NULL; - } - break; - case SUBTYPE_AND: - if (s->a.and && LIST_COUNT(s->a.and)==1) - return GenTblValueRange (tbl, m, tblMod, - FIRST_LIST_ELMT(s->a.and), doSize); - return NULL; - case SUBTYPE_OR: - if (s->a.and && LIST_COUNT(s->a.or)==1) - return GenTblValueRange (tbl, m, tblMod, - FIRST_LIST_ELMT(s->a.or), doSize); - return NULL; - case SUBTYPE_NOT: - return NULL; - } - if (!from || !to) - return NULL; - range = MT (TBLRange); - range->from = from->a.integer; - range->to = to->a.integer; - return range; -} - -TBLNamedNumberList* -GenTblValues PARAMS ((tbl, m, tblMod, list), - TBL *tbl _AND_ - Module *m _AND_ - TBLModule *tblMod _AND_ - NamedNumberList* list) -{ - TBLNamedNumberList* tnnl = NULL; - - if (tableFileVersionG<=1) - return NULL; - - if (list && !LIST_EMPTY(list)) - { - ValueDef* vd; - tnnl = (TBLNamedNumberList*) AsnListNew(sizeof(void*)); - FOR_EACH_LIST_ELMT(vd,list) - { - BasicValue* bv = GetTblValue(vd->value); - if (bv) - { - TBLNamedNumber* tnn = MT(TBLNamedNumber); - *(TBLNamedNumber**)AsnListAppend(tnnl) = tnn; - tnn->value = bv->a.integer; - if (vd->definedName) - { - tnn->name.octetLen = strlen(vd->definedName); - tnn->name.octs = Malloc(tnn->name.octetLen+1); - strcpy(tnn->name.octs,vd->definedName); - tblStringsTotalG++; - tblStringLenTotalG += tnn->name.octetLen; - } - } - } - - } - return tnnl; -} - -TBLType* -GenTblTypesRec PARAMS ((tbl, m, tblMod, td, tblTd, t), - TBL *tbl _AND_ - Module *m _AND_ - TBLModule *tblMod _AND_ - TypeDef *td _AND_ - TBLTypeDef *tblTd _AND_ - Type *t) -{ - TBLType *tblT; - NamedType *e; - TBLType **tblTHndl; - Tag *tag; - TBLTag **tblTagHndl; - - tblTypesTotalG++; - tblT = MT (TBLType); - tblT->content = MT (TBLTypeContent); - switch (t->basicType->choiceId) - { - case BASICTYPE_BOOLEAN: - tblT->typeId = TBL_BOOLEAN; - tblT->content->choiceId = TBLTYPECONTENT_PRIMTYPE; - break; - - case BASICTYPE_INTEGER: - tblT->typeId = TBL_INTEGER; - tblT->content->choiceId = TBLTYPECONTENT_PRIMTYPE; - break; - - case BASICTYPE_BITSTRING: - tblT->typeId = TBL_BITSTRING; - tblT->content->choiceId = TBLTYPECONTENT_PRIMTYPE; - tblT->values = GenTblValues(tbl,m,tblMod,t->basicType->a.bitString); - break; - - case BASICTYPE_OCTETSTRING: - tblT->typeId = TBL_OCTETSTRING; - tblT->content->choiceId = TBLTYPECONTENT_PRIMTYPE; - if (t->subtypes) - tblT->constraint = GenTblValueRange(tbl, m, tblMod,t->subtypes,1); - break; - - case BASICTYPE_NULL: - tblT->typeId = TBL_NULL; - tblT->content->choiceId = TBLTYPECONTENT_PRIMTYPE; - break; - - case BASICTYPE_OID: - tblT->typeId = TBL_OID; - tblT->content->choiceId = TBLTYPECONTENT_PRIMTYPE; - break; - - case BASICTYPE_REAL: - tblT->typeId = TBL_REAL; - tblT->content->choiceId = TBLTYPECONTENT_PRIMTYPE; - break; - - case BASICTYPE_ENUMERATED: - tblT->typeId = TBL_ENUMERATED; - tblT->content->choiceId = TBLTYPECONTENT_PRIMTYPE; - tblT->values = GenTblValues(tbl,m,tblMod,t->basicType->a.enumerated); - break; - - case BASICTYPE_SEQUENCE: - tblT->typeId = TBL_SEQUENCE; - tblT->content->choiceId = TBLTYPECONTENT_ELMTS; - tblT->content->a.elmts = AsnListNew (sizeof (void*)); - FOR_EACH_LIST_ELMT (e, t->basicType->a.sequence) - { - tblTHndl = AsnListAppend (tblT->content->a.elmts); - *tblTHndl = GenTblTypesRec (tbl, m, tblMod, td, tblTd, e->type); - - if (*tblTHndl == NULL) - break; - - if (e->fieldName != NULL) - { - (**tblTHndl).fieldName.octetLen = strlen (e->fieldName); - (**tblTHndl).fieldName.octs = - Malloc ((**tblTHndl).fieldName.octetLen + 1); - strcpy ((**tblTHndl).fieldName.octs, e->fieldName); - tblStringsTotalG++; - tblStringLenTotalG += (**tblTHndl).fieldName.octetLen; - } - - (**tblTHndl).optional = - ((e->type->optional) || (e->type->defaultVal != NULL)); - } - - break; - - case BASICTYPE_SET: - tblT->typeId = TBL_SET; - tblT->content->choiceId = TBLTYPECONTENT_ELMTS; - tblT->content->a.elmts = AsnListNew (sizeof (void*)); - FOR_EACH_LIST_ELMT (e, t->basicType->a.set) - { - tblTHndl = AsnListAppend (tblT->content->a.elmts); - *tblTHndl = GenTblTypesRec (tbl, m, tblMod, td, tblTd, e->type); - - if (*tblTHndl == NULL) - break; - - if (e->fieldName != NULL) - { - (**tblTHndl).fieldName.octetLen = strlen (e->fieldName); - (**tblTHndl).fieldName.octs = - Malloc ((**tblTHndl).fieldName.octetLen + 1); - strcpy ((**tblTHndl).fieldName.octs, e->fieldName); - tblStringsTotalG++; - tblStringLenTotalG += (**tblTHndl).fieldName.octetLen; - } - - (**tblTHndl).optional = - ((e->type->optional) || (e->type->defaultVal != NULL)); - - } - break; - - case BASICTYPE_SEQUENCEOF: - tblT->typeId = TBL_SEQUENCEOF; - tblT->content->choiceId = TBLTYPECONTENT_ELMTS; - tblT->content->a.elmts = AsnListNew (sizeof (void*)); - tblTHndl = AsnListAppend (tblT->content->a.elmts); - *tblTHndl = GenTblTypesRec (tbl, m, tblMod, td, tblTd, t->basicType->a.sequenceOf); - if (t->subtypes) - tblT->constraint = GenTblValueRange(tbl, m, tblMod,t->subtypes,1); - break; - - case BASICTYPE_SETOF: - tblT->typeId = TBL_SETOF; - tblT->content->choiceId = TBLTYPECONTENT_ELMTS; - tblT->content->a.elmts = AsnListNew (sizeof (void*)); - tblTHndl = AsnListAppend (tblT->content->a.elmts); - *tblTHndl = GenTblTypesRec (tbl, m, tblMod, td, tblTd, t->basicType->a.setOf); - if (t->subtypes) - tblT->constraint = GenTblValueRange(tbl, m, tblMod,t->subtypes,1); - break; - - case BASICTYPE_CHOICE: - tblT->typeId = TBL_CHOICE; - tblT->content->choiceId = TBLTYPECONTENT_ELMTS; - tblT->content->a.elmts = AsnListNew (sizeof (void*)); - FOR_EACH_LIST_ELMT (e, t->basicType->a.set) - { - tblTHndl = AsnListAppend (tblT->content->a.elmts); - *tblTHndl = GenTblTypesRec (tbl, m, tblMod, td, tblTd, e->type); - - if (*tblTHndl == NULL) - break; - - if (e->fieldName != NULL) - { - (**tblTHndl).fieldName.octetLen = strlen (e->fieldName); - (**tblTHndl).fieldName.octs = - Malloc ((**tblTHndl).fieldName.octetLen + 1); - strcpy ((**tblTHndl).fieldName.octs, e->fieldName); - tblStringsTotalG++; - tblStringLenTotalG += (**tblTHndl).fieldName.octetLen; - } - - (**tblTHndl).optional = - ((e->type->optional) || (e->type->defaultVal != NULL)); - - } - break; - - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_IMPORTTYPEREF: - tblT->typeId = TBL_TYPEREF; - tblT->content->choiceId = TBLTYPECONTENT_TYPEREF; - tblT->content->a.typeRef = MT (TBLTypeRef); - tblT->content->a.typeRef->implicit = t->implicit; - tblT->content->a.typeRef->typeDef = - t->basicType->a.localTypeRef->link->tmpRefCount; - break; - - default: - if (!abortTblTypeDefG) /* only print first time */ - fprintf (stderr,"WARNING: Type definition \"%s\" will not be included in the type table because it contains a weird type.\n",td->definedName); - abortTblTypeDefG = TRUE; - Free (tblT->content); - Free (tblT); - tblT = NULL; - break; - } - - /* handle constraints */ - if (t->subtypes) - { - switch (GetTblBasicType(t->basicType)) - { - case BASICTYPE_INTEGER: - tblT->constraint = GenTblValueRange(tbl,m,tblMod,t->subtypes,0); - break; - case BASICTYPE_OCTETSTRING: - case BASICTYPE_SEQUENCEOF: - tblT->constraint = GenTblValueRange(tbl,m,tblMod,t->subtypes,1); - break; - default: - break; - } - } - - /* copy the tags */ - if ((tblT != NULL) && - ((t->tags != NULL) && (!LIST_EMPTY (t->tags)))) - { - tblT->tagList = AsnListNew (sizeof (void*)); - FOR_EACH_LIST_ELMT (tag, t->tags) - { - tblTagsTotalG++; - tblTagHndl = AsnListAppend (tblT->tagList); - *tblTagHndl = MT (TBLTag); - switch (tag->tclass) - { - case UNIV: - (**tblTagHndl).tclass = UNIVERSAL; - break; - case APPL: - (**tblTagHndl).tclass = APPLICATION; - break; - case CNTX: - (**tblTagHndl).tclass = CONTEXT; - break; - case PRIV: - (**tblTagHndl).tclass = PRIVATE; - break; - } - (**tblTagHndl).code = tag->code; - } - } - - return tblT; -} /* GenTblTypesRec */ diff --git a/SecuritySNACCRuntime/compiler/core/gen-tbls.h b/SecuritySNACCRuntime/compiler/core/gen-tbls.h deleted file mode 100644 index bee47563..00000000 --- a/SecuritySNACCRuntime/compiler/core/gen-tbls.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * compiler/core/gen_tbls.h - * - * generates type tables and writes them to a file. - * - * MS - * 93/02/07 - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/gen-tbls.h,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: gen-tbls.h,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:48 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1997/05/07 15:18:35 wan - * Added (limited) size constraints, bitstring and enumeration names to tables - * - * Revision 1.3 1995/07/25 19:41:29 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:44 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:11 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -void GenTypeTbls PROTO ((ModuleList *mods, char *fileName, int tableFileVersion)); diff --git a/SecuritySNACCRuntime/compiler/core/lex-asn1.c b/SecuritySNACCRuntime/compiler/core/lex-asn1.c deleted file mode 100644 index 28024dd9..00000000 --- a/SecuritySNACCRuntime/compiler/core/lex-asn1.c +++ /dev/null @@ -1,3496 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/lex-asn1.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include -#include - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include -#include -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 132 -#define YY_END_OF_BUFFER 133 -static yyconst short int yy_accept[698] = - { 0, - 0, 0, 0, 0, 0, 0, 133, 132, 3, 132, - 132, 8, 9, 5, 13, 4, 129, 128, 132, 16, - 12, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 10, 11, 127, 6, 15, 7, 60, 122, 3, 0, - 125, 0, 0, 0, 0, 128, 0, 0, 0, 126, - 126, 126, 126, 126, 126, 126, 126, 97, 126, 126, - 126, 126, 57, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 25, 126, 126, 126, 126, 126, 126, 126, 126, - - 126, 126, 126, 126, 102, 126, 126, 126, 126, 0, - 0, 0, 127, 123, 124, 0, 0, 131, 0, 0, - 14, 0, 126, 126, 126, 126, 29, 126, 126, 0, - 126, 126, 20, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 40, 126, 126, 126, 126, 126, 88, 126, - 126, 126, 126, 126, 126, 126, 49, 48, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 26, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 1, 2, 0, 0, 126, 126, 126, - - 126, 126, 126, 126, 126, 69, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 51, 126, 126, 126, 126, 126, - 126, 126, 126, 23, 126, 126, 126, 126, 126, 126, - 126, 94, 126, 126, 126, 46, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 50, 126, 126, 126, 126, - 126, 17, 126, 126, 37, 126, 126, 126, 52, 0, - 0, 126, 126, 126, 126, 126, 126, 126, 39, 0, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 67, 126, 126, 126, 38, 126, 126, - - 126, 120, 126, 126, 126, 126, 126, 22, 126, 126, - 126, 126, 0, 93, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 106, 126, 126, 126, 126, 0, 0, 55, - 126, 116, 126, 61, 126, 126, 126, 126, 28, 85, - 126, 126, 126, 126, 126, 126, 121, 126, 126, 126, - 126, 65, 126, 126, 126, 126, 126, 126, 126, 126, - 66, 0, 92, 126, 126, 100, 126, 126, 126, 126, - 126, 126, 126, 96, 75, 126, 64, 126, 126, 126, - 111, 117, 21, 126, 126, 115, 0, 126, 71, 126, - - 126, 0, 61, 126, 126, 126, 126, 126, 18, 126, - 126, 126, 32, 56, 126, 126, 126, 126, 126, 126, - 44, 126, 126, 45, 126, 126, 19, 126, 0, 0, - 126, 126, 126, 126, 126, 54, 36, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 0, 126, - 99, 0, 130, 0, 126, 126, 126, 63, 126, 126, - 126, 87, 126, 90, 126, 126, 126, 42, 126, 27, - 47, 126, 126, 0, 126, 126, 126, 31, 126, 126, - 126, 126, 126, 126, 126, 24, 126, 126, 126, 126, - 91, 126, 126, 0, 0, 126, 126, 109, 126, 126, - - 53, 0, 126, 126, 126, 110, 126, 86, 76, 126, - 0, 126, 126, 62, 68, 126, 113, 98, 119, 77, - 0, 112, 126, 0, 126, 126, 126, 34, 0, 0, - 126, 126, 126, 126, 126, 126, 126, 70, 33, 0, - 126, 126, 126, 43, 0, 84, 126, 0, 126, 126, - 80, 126, 126, 89, 0, 126, 107, 126, 0, 0, - 126, 126, 126, 126, 126, 126, 35, 0, 126, 41, - 118, 126, 126, 0, 114, 126, 126, 126, 0, 126, - 126, 0, 0, 126, 126, 126, 126, 126, 126, 0, - 0, 126, 126, 126, 0, 126, 126, 126, 0, 126, - - 72, 0, 0, 101, 126, 126, 126, 126, 126, 126, - 126, 0, 126, 126, 126, 0, 126, 58, 126, 0, - 126, 0, 0, 104, 126, 126, 126, 126, 126, 126, - 0, 126, 126, 59, 0, 126, 126, 0, 126, 0, - 0, 126, 103, 126, 126, 126, 126, 0, 81, 126, - 0, 126, 126, 0, 82, 0, 0, 126, 126, 78, - 126, 126, 81, 126, 0, 30, 126, 82, 0, 78, - 126, 126, 126, 126, 126, 30, 108, 0, 105, 95, - 126, 126, 126, 95, 73, 126, 83, 0, 126, 126, - 126, 126, 126, 126, 79, 74, 0 - - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 1, 1, 1, 1, 5, 6, - 7, 1, 1, 8, 9, 10, 1, 11, 12, 13, - 13, 13, 13, 13, 13, 13, 13, 14, 15, 16, - 17, 1, 1, 1, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 1, 45, 1, 1, 1, 46, 47, 48, 47, - - 47, 47, 49, 49, 49, 49, 49, 49, 49, 50, - 49, 49, 49, 49, 51, 49, 49, 49, 49, 49, - 49, 49, 52, 53, 54, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[55] = - { 0, - 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, - 4, 4, 4, 1, 1, 1, 1, 4, 4, 4, - 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 1, 1, 4, 4, 4, 3, 3, - 3, 1, 1, 1 - } ; - -static yyconst short int yy_base[706] = - { 0, - 0, 0, 0, 0, 0, 0, 508, 3540, 53, 499, - 52, 3540, 3540, 3540, 491, 3540, 3540, 47, 482, 3540, - 3540, 63, 96, 98, 113, 115, 126, 127, 140, 141, - 158, 153, 179, 188, 155, 187, 200, 205, 212, 217, - 41, 3540, 484, 3540, 3540, 3540, 3540, 3540, 65, 478, - 472, 54, 131, 466, 237, 58, 452, 162, 248, 226, - 239, 243, 263, 274, 247, 279, 281, 290, 456, 296, - 302, 302, 304, 305, 339, 323, 331, 338, 333, 354, - 359, 361, 363, 379, 387, 395, 402, 411, 417, 428, - 433, 439, 441, 397, 442, 453, 455, 471, 479, 486, - - 502, 495, 507, 522, 524, 530, 539, 541, 547, 415, - 412, 440, 436, 3540, 3540, 416, 151, 3540, 185, 282, - 3540, 420, 549, 547, 556, 573, 580, 582, 589, 407, - 588, 597, 599, 606, 611, 626, 631, 637, 640, 639, - 657, 664, 669, 666, 669, 678, 683, 686, 691, 727, - 705, 713, 718, 726, 727, 739, 740, 748, 762, 751, - 753, 770, 775, 784, 796, 789, 798, 801, 810, 819, - 828, 833, 836, 851, 861, 867, 869, 780, 878, 882, - 884, 891, 844, 899, 908, 915, 914, 921, 928, 933, - 935, 936, 947, 3540, 3540, 408, 384, 954, 962, 969, - - 977, 988, 976, 1004, 1013, 1022, 995, 1009, 1013, 1014, - 1025, 1027, 1028, 1042, 1053, 1050, 1055, 1072, 1081, 1074, - 1079, 1093, 1098, 1100, 1115, 1112, 1117, 1124, 1129, 1141, - 1150, 1143, 1155, 1158, 1175, 1182, 1191, 1181, 1190, 1218, - 1226, 1228, 1212, 1221, 1219, 1220, 1233, 1244, 1251, 1252, - 1259, 1266, 1274, 1281, 1292, 1289, 1300, 1313, 1311, 1325, - 1330, 1337, 1339, 1342, 1351, 1354, 1365, 1369, 1375, 483, - 366, 1380, 1386, 1391, 1390, 1399, 1410, 1416, 1413, 378, - 1444, 1418, 1435, 1437, 1462, 1453, 1461, 1456, 1467, 1465, - 1478, 1482, 1493, 1498, 1504, 1510, 1516, 1521, 1536, 1538, - - 1543, 1554, 1560, 1559, 1568, 1593, 1595, 1603, 1605, 1613, - 1615, 1608, 367, 1618, 1644, 1649, 1636, 1643, 1577, 1635, - 1638, 1659, 1661, 1662, 1674, 1685, 1687, 1688, 1699, 1706, - 1711, 1713, 1747, 1738, 1743, 1749, 1760, 508, 351, 1755, - 1767, 1772, 1778, 1783, 1789, 1794, 1800, 1809, 1811, 1818, - 1817, 1828, 1830, 1831, 1843, 1845, 1852, 1854, 1872, 1878, - 1884, 1889, 1884, 1892, 1897, 1899, 1910, 1911, 1918, 1932, - 1937, 349, 1959, 1944, 1955, 1956, 1958, 1970, 1977, 1984, - 1985, 1998, 2003, 2006, 2011, 2020, 2025, 2028, 1985, 2036, - 2052, 2057, 2059, 2064, 2067, 2069, 351, 2072, 2103, 2113, - - 2081, 308, 3540, 2095, 2103, 2104, 2116, 2125, 2130, 2133, - 2144, 2151, 2152, 2159, 2166, 2173, 2174, 2181, 2188, 2195, - 2196, 2207, 2209, 2218, 2221, 2226, 2233, 2240, 360, 306, - 2267, 2251, 2252, 2263, 2267, 2279, 2284, 2284, 2287, 2301, - 2301, 2306, 2309, 2314, 2328, 2331, 2343, 2336, 318, 2374, - 2377, 400, 3540, 424, 2379, 2387, 2371, 2376, 2384, 2397, - 2418, 2392, 2409, 2410, 2411, 2424, 2432, 2433, 2441, 2454, - 2455, 2456, 2405, 317, 2463, 2468, 2477, 2480, 2485, 2492, - 2504, 2507, 2506, 2515, 2542, 2550, 2532, 2534, 2559, 2568, - 2579, 2581, 2584, 2576, 844, 2577, 2593, 2600, 2595, 2598, - - 2612, 1669, 2619, 2621, 2633, 2634, 2636, 2668, 2670, 2659, - 296, 2663, 2674, 2683, 2689, 2694, 2701, 2709, 2716, 2718, - 288, 2741, 2743, 1945, 2745, 2754, 2756, 2758, 273, 261, - 2755, 2757, 2775, 2781, 2781, 2784, 2796, 2798, 2799, 264, - 2807, 2821, 2828, 2810, 266, 2842, 2853, 246, 2839, 2853, - 2854, 2856, 2871, 2878, 241, 2879, 2880, 2893, 245, 233, - 2901, 2902, 2904, 2854, 2919, 2928, 2947, 221, 2931, 2936, - 2938, 2949, 2950, 219, 2957, 2962, 2971, 2974, 216, 2983, - 2988, 218, 208, 2996, 3005, 3007, 3014, 3026, 3033, 42, - 209, 3032, 3061, 3064, 207, 3057, 3057, 3060, 196, 3078, - - 3071, 198, 197, 3083, 3086, 3101, 3100, 3108, 3115, 3122, - 3127, 180, 3129, 3140, 3141, 184, 3148, 3155, 3162, 176, - 3163, 166, 155, 3170, 3177, 3185, 3194, 3196, 3199, 3207, - 171, 3218, 3221, 3226, 163, 3229, 3240, 164, 3243, 152, - 152, 3248, 3251, 3262, 3265, 3273, 3270, 115, 3291, 3299, - 112, 3301, 3306, 90, 3323, 89, 83, 3305, 3318, 3326, - 3329, 3331, 3540, 3340, 82, 3343, 3348, 3540, 77, 3540, - 3355, 3357, 3362, 3372, 3387, 3540, 3389, 71, 3394, 3396, - 3411, 3410, 3411, 3540, 3413, 3438, 3447, 58, 3455, 3437, - 3458, 3444, 3449, 3461, 3468, 3470, 3540, 3512, 3516, 3520, - - 3523, 3525, 3529, 3531, 3535 - } ; - -static yyconst short int yy_def[706] = - { 0, - 697, 1, 698, 698, 699, 699, 697, 697, 697, 700, - 701, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 22, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 697, 697, 702, 697, 697, 697, 697, 697, 697, 700, - 697, 697, 701, 701, 703, 697, 697, 697, 23, 23, - 23, 33, 33, 33, 23, 33, 33, 33, 704, 33, - 33, 23, 23, 23, 59, 23, 33, 33, 33, 33, - 33, 33, 23, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 23, 23, 23, 23, 23, 33, 33, 33, - - 33, 33, 33, 33, 33, 33, 33, 33, 33, 697, - 697, 702, 702, 697, 697, 697, 703, 697, 703, 703, - 697, 697, 23, 23, 23, 33, 33, 33, 33, 704, - 23, 23, 23, 23, 23, 33, 33, 33, 23, 23, - 33, 33, 33, 59, 23, 23, 23, 23, 23, 59, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 33, 33, 33, 33, 33, 23, - 23, 23, 59, 33, 33, 33, 23, 23, 23, 23, - 23, 23, 23, 697, 697, 703, 697, 23, 23, 23, - - 23, 23, 23, 59, 59, 59, 23, 33, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 33, 33, 33, 23, 23, 59, - 59, 59, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 33, 33, 703, - 697, 33, 33, 33, 23, 23, 33, 23, 23, 59, - 59, 23, 23, 23, 59, 33, 33, 23, 23, 23, - 23, 33, 33, 33, 33, 33, 33, 33, 33, 33, - - 33, 33, 33, 23, 23, 59, 59, 59, 59, 59, - 59, 23, 59, 59, 59, 59, 33, 33, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 59, 33, 33, 33, 33, 703, 697, 33, - 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, - 23, 23, 23, 23, 23, 23, 23, 23, 33, 33, - 33, 33, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 59, 59, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 33, 33, - 33, 33, 33, 33, 23, 23, 59, 23, 59, 59, - - 23, 705, 697, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 697, 59, - 59, 23, 23, 23, 33, 33, 33, 23, 23, 33, - 23, 23, 23, 23, 23, 23, 23, 23, 59, 59, - 59, 705, 697, 705, 59, 59, 23, 23, 23, 23, - 59, 59, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 33, 697, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 59, 59, 23, 23, 59, 59, - 59, 59, 59, 697, 59, 33, 23, 23, 23, 23, - - 23, 697, 23, 23, 23, 23, 23, 59, 59, 23, - 697, 33, 33, 33, 33, 33, 33, 33, 33, 33, - 59, 59, 59, 697, 59, 59, 59, 59, 697, 697, - 23, 23, 33, 33, 23, 23, 23, 23, 23, 697, - 23, 23, 23, 23, 59, 59, 59, 697, 23, 23, - 23, 23, 23, 23, 697, 23, 23, 23, 697, 697, - 23, 23, 23, 33, 33, 33, 59, 697, 23, 23, - 23, 23, 23, 697, 23, 23, 23, 23, 697, 23, - 23, 697, 697, 23, 23, 23, 23, 23, 23, 59, - 697, 59, 59, 59, 697, 33, 23, 23, 697, 23, - - 23, 697, 697, 23, 23, 23, 23, 23, 23, 23, - 23, 697, 23, 23, 23, 697, 23, 23, 23, 697, - 23, 697, 697, 23, 23, 23, 23, 23, 23, 23, - 697, 23, 23, 23, 697, 23, 23, 697, 23, 697, - 697, 23, 23, 23, 23, 23, 23, 697, 23, 33, - 697, 33, 33, 697, 33, 697, 697, 23, 23, 23, - 23, 23, 697, 23, 697, 23, 23, 697, 697, 697, - 23, 23, 23, 33, 33, 697, 33, 697, 33, 33, - 33, 23, 23, 697, 23, 59, 59, 59, 59, 23, - 59, 23, 23, 23, 23, 23, 0, 697, 697, 697, - - 697, 697, 697, 697, 697 - } ; - -static yyconst short int yy_nxt[3595] = - { 0, - 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 18, 19, 20, 21, 8, 22, 23, 24, - 25, 26, 27, 28, 28, 29, 28, 28, 30, 31, - 32, 33, 34, 28, 35, 36, 37, 38, 39, 40, - 28, 28, 28, 41, 42, 43, 43, 43, 43, 43, - 43, 44, 45, 46, 49, 49, 52, 56, 56, 56, - 110, 610, 53, 53, 58, 58, 49, 49, 56, 56, - 56, 59, 114, 60, 60, 60, 111, 611, 115, 689, - 60, 61, 62, 60, 60, 60, 60, 60, 60, 60, - 60, 63, 64, 65, 60, 66, 60, 67, 68, 60, - - 60, 60, 60, 60, 60, 60, 684, 678, 69, 69, - 69, 69, 69, 69, 60, 60, 676, 70, 670, 60, - 669, 71, 74, 60, 60, 668, 60, 72, 60, 75, - 60, 60, 76, 665, 77, 52, 60, 73, 60, 60, - 60, 53, 53, 81, 60, 78, 60, 60, 60, 79, - 663, 60, 60, 118, 60, 80, 60, 82, 60, 119, - 83, 60, 60, 58, 58, 60, 86, 60, 60, 84, - 85, 60, 60, 657, 60, 87, 98, 656, 60, 60, - 60, 60, 60, 88, 60, 654, 60, 118, 651, 60, - 89, 122, 648, 118, 60, 641, 60, 90, 91, 60, - - 60, 92, 640, 638, 60, 94, 635, 631, 99, 60, - 60, 93, 100, 60, 623, 622, 95, 104, 60, 96, - 60, 60, 97, 101, 102, 60, 60, 620, 103, 60, - 60, 105, 616, 60, 106, 107, 60, 108, 60, 118, - 612, 60, 109, 60, 603, 119, 60, 60, 60, 697, - 697, 60, 602, 60, 599, 595, 697, 60, 60, 591, - 60, 60, 124, 583, 60, 60, 582, 60, 60, 60, - 60, 579, 60, 60, 123, 60, 574, 60, 60, 60, - 60, 60, 60, 572, 118, 60, 125, 120, 127, 60, - 119, 126, 60, 60, 568, 60, 60, 60, 60, 60, - - 60, 60, 560, 60, 129, 559, 60, 553, 60, 60, - 453, 128, 60, 60, 60, 60, 454, 548, 60, 131, - 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, - 60, 196, 132, 134, 60, 60, 135, 511, 133, 492, - 58, 58, 475, 60, 60, 60, 60, 59, 138, 60, - 60, 60, 60, 139, 60, 60, 60, 142, 143, 140, - 60, 429, 429, 60, 60, 60, 141, 145, 136, 137, - 60, 447, 60, 60, 428, 144, 60, 60, 60, 60, - 60, 60, 403, 60, 60, 474, 146, 148, 60, 122, - 147, 60, 378, 60, 150, 149, 126, 60, 60, 347, - - 339, 60, 453, 271, 60, 60, 152, 153, 454, 60, - 118, 151, 154, 60, 60, 697, 119, 60, 60, 60, - 60, 60, 164, 155, 60, 156, 118, 60, 60, 60, - 60, 165, 453, 60, 60, 60, 60, 197, 60, 60, - 115, 158, 157, 60, 112, 159, 60, 60, 697, 60, - 60, 60, 60, 270, 160, 60, 195, 60, 60, 194, - 60, 60, 162, 60, 130, 60, 60, 60, 121, 161, - 116, 60, 60, 60, 60, 50, 168, 163, 60, 166, - 169, 51, 60, 60, 60, 118, 170, 167, 171, 60, - 172, 119, 112, 173, 60, 57, 60, 60, 176, 55, - - 174, 60, 51, 60, 60, 60, 175, 697, 60, 179, - 118, 60, 177, 183, 60, 178, 119, 60, 60, 181, - 60, 60, 697, 697, 60, 60, 60, 184, 180, 60, - 338, 697, 697, 697, 60, 697, 182, 185, 697, 60, - 60, 60, 60, 60, 60, 186, 60, 188, 60, 60, - 697, 187, 60, 697, 60, 402, 60, 190, 60, 60, - 60, 60, 60, 60, 191, 60, 60, 189, 200, 60, - 198, 60, 60, 60, 60, 697, 192, 60, 60, 60, - 60, 60, 697, 193, 697, 199, 697, 201, 60, 697, - 60, 60, 202, 697, 697, 60, 697, 60, 60, 60, - - 60, 60, 60, 697, 60, 60, 697, 60, 60, 60, - 203, 60, 60, 205, 60, 697, 697, 206, 60, 60, - 60, 60, 60, 697, 60, 697, 204, 60, 60, 60, - 60, 60, 60, 697, 207, 697, 208, 60, 60, 697, - 60, 697, 60, 126, 60, 60, 209, 60, 60, 60, - 60, 697, 60, 60, 697, 60, 60, 213, 210, 60, - 60, 60, 697, 60, 216, 214, 211, 58, 58, 60, - 60, 60, 697, 212, 59, 60, 217, 697, 215, 60, - 60, 60, 60, 60, 697, 697, 60, 60, 60, 60, - 60, 60, 697, 697, 60, 219, 60, 697, 218, 60, - - 220, 60, 697, 60, 223, 697, 221, 60, 60, 222, - 60, 60, 60, 697, 60, 697, 60, 60, 697, 60, - 697, 224, 60, 697, 60, 697, 60, 60, 58, 58, - 60, 697, 60, 226, 60, 59, 227, 697, 60, 229, - 697, 228, 697, 60, 60, 697, 60, 60, 231, 60, - 697, 60, 60, 697, 60, 697, 225, 60, 60, 60, - 60, 60, 230, 697, 60, 60, 232, 60, 60, 60, - 60, 60, 235, 60, 236, 697, 60, 697, 60, 60, - 60, 60, 60, 60, 60, 233, 697, 60, 697, 60, - 234, 60, 60, 60, 60, 60, 60, 697, 60, 60, - - 238, 60, 60, 60, 237, 60, 60, 697, 697, 60, - 60, 60, 60, 240, 60, 60, 60, 60, 239, 60, - 60, 60, 60, 60, 241, 60, 60, 60, 697, 60, - 60, 60, 60, 697, 242, 60, 243, 60, 697, 60, - 60, 60, 60, 697, 60, 58, 58, 697, 244, 60, - 60, 60, 59, 60, 60, 245, 246, 248, 60, 60, - 60, 249, 531, 697, 60, 532, 697, 60, 126, 60, - 247, 697, 60, 259, 60, 533, 60, 60, 697, 60, - 60, 534, 250, 60, 697, 60, 60, 60, 60, 60, - 697, 60, 60, 251, 697, 697, 60, 60, 252, 60, - - 60, 60, 697, 256, 253, 60, 254, 60, 255, 60, - 60, 697, 60, 60, 697, 60, 258, 60, 60, 697, - 257, 60, 60, 60, 697, 60, 60, 60, 697, 697, - 60, 260, 60, 60, 60, 263, 697, 60, 697, 60, - 60, 697, 60, 697, 261, 60, 60, 60, 697, 265, - 262, 264, 60, 60, 60, 60, 60, 60, 266, 60, - 60, 268, 60, 697, 60, 697, 60, 60, 60, 60, - 697, 269, 60, 267, 60, 60, 60, 60, 60, 60, - 697, 697, 697, 60, 272, 60, 697, 60, 60, 697, - 60, 697, 697, 60, 60, 60, 273, 60, 60, 697, - - 60, 277, 60, 60, 274, 58, 58, 60, 60, 60, - 60, 275, 59, 60, 58, 58, 281, 60, 60, 60, - 60, 59, 276, 58, 58, 697, 60, 60, 282, 60, - 280, 60, 697, 278, 283, 60, 60, 697, 60, 60, - 697, 60, 64, 279, 60, 284, 60, 697, 60, 60, - 60, 64, 286, 60, 60, 60, 60, 697, 60, 60, - 697, 697, 285, 60, 697, 287, 60, 60, 60, 60, - 289, 60, 288, 60, 60, 60, 60, 697, 60, 697, - 60, 60, 697, 60, 60, 697, 60, 697, 290, 291, - 697, 60, 697, 60, 60, 60, 60, 60, 126, 60, - - 60, 697, 293, 60, 295, 60, 60, 697, 294, 697, - 60, 697, 60, 292, 60, 60, 697, 697, 60, 60, - 60, 298, 60, 60, 60, 60, 697, 296, 297, 60, - 697, 60, 126, 60, 60, 697, 60, 299, 60, 60, - 60, 60, 60, 60, 697, 60, 60, 697, 60, 60, - 60, 300, 697, 60, 60, 60, 60, 697, 60, 697, - 60, 301, 60, 697, 305, 60, 303, 697, 60, 302, - 60, 60, 60, 304, 60, 60, 60, 697, 697, 60, - 60, 60, 60, 60, 60, 697, 60, 697, 697, 60, - 306, 60, 697, 60, 307, 697, 60, 60, 697, 60, - - 60, 60, 60, 697, 60, 697, 60, 60, 309, 60, - 60, 311, 310, 60, 60, 60, 697, 697, 308, 58, - 58, 60, 60, 60, 697, 697, 59, 58, 58, 58, - 58, 60, 697, 315, 313, 697, 59, 60, 316, 697, - 317, 60, 60, 60, 60, 60, 60, 312, 697, 697, - 60, 60, 60, 60, 60, 64, 697, 64, 60, 697, - 60, 60, 60, 314, 60, 60, 697, 318, 697, 60, - 697, 697, 60, 60, 60, 60, 60, 60, 319, 697, - 60, 320, 60, 60, 60, 60, 697, 60, 321, 697, - 322, 60, 60, 60, 323, 60, 697, 60, 697, 60, - - 60, 697, 325, 697, 697, 60, 60, 60, 324, 326, - 60, 697, 60, 327, 60, 60, 697, 60, 697, 697, - 60, 60, 60, 60, 697, 60, 697, 697, 126, 697, - 60, 60, 60, 60, 60, 697, 330, 328, 60, 697, - 697, 60, 60, 329, 60, 697, 60, 332, 697, 697, - 60, 60, 60, 331, 60, 60, 60, 697, 60, 697, - 60, 60, 60, 60, 60, 697, 60, 60, 60, 333, - 60, 60, 60, 60, 697, 60, 60, 334, 60, 60, - 60, 697, 60, 60, 335, 60, 336, 337, 60, 697, - 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, - - 697, 60, 60, 341, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 697, 343, 340, 697, 60, 697, - 60, 60, 697, 60, 60, 697, 342, 697, 60, 345, - 344, 60, 60, 126, 60, 697, 697, 346, 60, 349, - 60, 60, 60, 60, 60, 58, 58, 60, 697, 60, - 697, 697, 59, 697, 60, 697, 60, 60, 60, 60, - 60, 348, 60, 58, 58, 350, 60, 351, 60, 697, - 59, 60, 353, 64, 697, 60, 60, 355, 60, 60, - 60, 356, 697, 60, 697, 60, 358, 60, 60, 354, - 60, 352, 60, 60, 697, 357, 60, 60, 60, 60, - - 60, 60, 697, 359, 60, 697, 60, 697, 60, 60, - 697, 60, 60, 697, 360, 60, 60, 60, 697, 60, - 60, 697, 60, 363, 697, 60, 60, 361, 60, 60, - 60, 697, 60, 362, 60, 60, 60, 697, 60, 60, - 60, 697, 60, 60, 697, 697, 364, 697, 60, 697, - 697, 365, 697, 60, 60, 366, 60, 60, 60, 697, - 60, 60, 60, 368, 697, 60, 697, 697, 60, 697, - 60, 697, 60, 60, 367, 60, 60, 369, 60, 60, - 370, 697, 60, 697, 60, 697, 60, 697, 371, 60, - 60, 697, 60, 60, 58, 58, 58, 58, 383, 60, - - 60, 372, 60, 59, 58, 58, 58, 58, 60, 60, - 697, 59, 697, 59, 58, 58, 58, 58, 60, 58, - 58, 59, 64, 59, 64, 126, 59, 697, 697, 377, - 697, 373, 64, 60, 64, 376, 697, 697, 697, 60, - 697, 374, 64, 375, 64, 58, 58, 64, 697, 60, - 58, 58, 59, 697, 60, 381, 384, 59, 60, 385, - 60, 60, 60, 60, 697, 60, 60, 697, 60, 60, - 502, 502, 697, 64, 379, 60, 60, 382, 64, 60, - 60, 697, 60, 60, 60, 380, 60, 388, 697, 386, - 60, 697, 60, 60, 540, 60, 697, 387, 122, 60, - - 60, 697, 60, 60, 389, 60, 60, 391, 60, 60, - 60, 697, 60, 60, 697, 60, 60, 697, 60, 60, - 60, 390, 393, 392, 60, 697, 60, 60, 60, 60, - 60, 60, 60, 697, 60, 697, 395, 60, 60, 697, - 60, 394, 60, 697, 60, 697, 697, 60, 58, 58, - 697, 697, 60, 396, 60, 397, 60, 60, 697, 697, - 398, 60, 60, 399, 697, 60, 697, 60, 60, 697, - 60, 60, 697, 60, 60, 60, 64, 60, 60, 60, - 697, 60, 60, 400, 697, 60, 404, 60, 401, 60, - 60, 60, 60, 697, 60, 697, 60, 60, 697, 60, - - 60, 60, 60, 697, 60, 60, 406, 60, 60, 697, - 60, 60, 60, 60, 405, 60, 60, 697, 60, 60, - 697, 60, 60, 697, 407, 697, 60, 60, 60, 60, - 60, 60, 60, 60, 408, 697, 60, 60, 410, 409, - 60, 60, 60, 60, 697, 126, 697, 412, 60, 411, - 60, 60, 60, 60, 697, 60, 60, 697, 60, 60, - 697, 60, 60, 414, 60, 697, 60, 413, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, 697, 60, - 697, 415, 697, 60, 60, 60, 60, 697, 416, 697, - 60, 60, 697, 60, 60, 60, 60, 60, 697, 697, - - 60, 419, 60, 60, 417, 60, 60, 60, 60, 420, - 60, 60, 697, 60, 418, 60, 60, 60, 60, 697, - 60, 60, 422, 60, 423, 60, 697, 421, 60, 697, - 60, 60, 425, 60, 697, 60, 60, 697, 60, 60, - 60, 60, 60, 60, 697, 424, 524, 524, 697, 60, - 697, 60, 60, 60, 426, 697, 697, 60, 60, 60, - 429, 429, 60, 60, 697, 60, 427, 430, 60, 432, - 555, 697, 433, 60, 122, 60, 60, 60, 60, 60, - 60, 60, 697, 60, 431, 60, 60, 60, 64, 60, - 697, 60, 697, 697, 434, 60, 60, 60, 60, 60, - - 435, 60, 60, 60, 443, 437, 60, 60, 60, 60, - 60, 60, 697, 436, 697, 60, 60, 60, 60, 60, - 697, 438, 697, 439, 60, 60, 60, 60, 60, 60, - 697, 60, 60, 440, 60, 697, 60, 60, 697, 60, - 441, 60, 60, 697, 60, 60, 60, 60, 697, 60, - 60, 60, 60, 60, 60, 60, 60, 697, 60, 60, - 697, 60, 697, 697, 442, 697, 60, 697, 60, 60, - 60, 60, 697, 444, 60, 60, 60, 60, 60, 60, - 697, 60, 60, 60, 60, 697, 60, 697, 446, 60, - 60, 60, 60, 448, 60, 697, 60, 60, 60, 445, - - 60, 697, 451, 60, 58, 58, 60, 697, 60, 697, - 60, 449, 60, 60, 58, 58, 60, 697, 697, 697, - 60, 59, 60, 697, 60, 60, 60, 456, 60, 60, - 697, 455, 64, 697, 60, 60, 60, 60, 697, 697, - 457, 60, 64, 697, 60, 60, 60, 60, 450, 697, - 60, 60, 458, 697, 60, 60, 60, 60, 60, 459, - 697, 60, 697, 460, 60, 60, 60, 697, 697, 60, - 697, 60, 60, 60, 60, 60, 60, 60, 461, 462, - 60, 697, 60, 60, 60, 60, 697, 60, 697, 697, - 60, 463, 60, 60, 60, 60, 697, 60, 60, 60, - - 60, 697, 466, 697, 60, 60, 60, 60, 697, 60, - 465, 697, 60, 60, 464, 60, 60, 60, 697, 60, - 60, 60, 60, 697, 467, 697, 60, 60, 60, 60, - 60, 468, 60, 697, 60, 697, 60, 60, 469, 60, - 60, 697, 60, 60, 697, 470, 60, 60, 60, 60, - 60, 60, 60, 697, 60, 697, 471, 472, 60, 60, - 697, 60, 60, 697, 60, 60, 697, 60, 58, 58, - 473, 60, 60, 60, 60, 59, 60, 60, 697, 697, - 478, 60, 477, 60, 479, 60, 60, 476, 60, 480, - 697, 697, 60, 60, 60, 697, 64, 60, 60, 60, - - 697, 60, 60, 60, 60, 481, 60, 697, 60, 60, - 697, 60, 60, 697, 697, 60, 60, 482, 60, 60, - 483, 697, 484, 60, 697, 60, 60, 60, 60, 697, - 486, 60, 60, 60, 60, 60, 697, 60, 697, 60, - 60, 697, 60, 697, 697, 60, 697, 485, 487, 60, - 60, 697, 60, 488, 697, 60, 60, 60, 697, 60, - 490, 60, 60, 697, 60, 489, 697, 60, 60, 60, - 491, 697, 60, 697, 60, 58, 58, 60, 58, 58, - 494, 494, 59, 697, 60, 59, 697, 495, 58, 58, - 697, 493, 60, 58, 58, 59, 499, 60, 697, 697, - - 59, 60, 60, 64, 697, 60, 64, 60, 64, 60, - 496, 697, 60, 697, 497, 500, 498, 60, 60, 502, - 502, 64, 60, 60, 60, 60, 59, 510, 60, 697, - 60, 60, 60, 501, 60, 60, 505, 60, 60, 697, - 504, 60, 60, 503, 506, 60, 697, 64, 697, 60, - 60, 60, 60, 507, 60, 60, 697, 60, 60, 697, - 697, 697, 60, 60, 60, 60, 60, 697, 697, 697, - 697, 508, 60, 60, 60, 60, 60, 60, 697, 60, - 60, 60, 60, 697, 60, 60, 60, 60, 60, 513, - 509, 697, 697, 60, 60, 60, 60, 60, 60, 60, - - 697, 60, 60, 697, 512, 60, 60, 514, 60, 60, - 60, 60, 697, 60, 697, 697, 60, 516, 60, 515, - 697, 60, 697, 60, 517, 60, 60, 519, 60, 60, - 518, 60, 60, 60, 697, 60, 60, 60, 60, 697, - 60, 697, 697, 58, 58, 60, 60, 60, 60, 520, - 521, 58, 58, 522, 697, 60, 60, 60, 59, 60, - 524, 524, 697, 60, 697, 523, 697, 59, 697, 58, - 58, 64, 697, 60, 697, 60, 59, 494, 494, 64, - 58, 58, 58, 58, 525, 58, 58, 59, 64, 59, - 697, 697, 59, 697, 697, 60, 60, 64, 697, 60, - - 697, 697, 697, 697, 526, 122, 697, 529, 64, 535, - 64, 530, 528, 64, 60, 527, 60, 126, 60, 60, - 60, 60, 697, 60, 60, 60, 537, 697, 697, 60, - 697, 60, 538, 60, 536, 697, 60, 60, 697, 60, - 60, 60, 60, 60, 60, 697, 60, 539, 697, 541, - 60, 542, 60, 60, 60, 60, 544, 60, 60, 60, - 60, 60, 60, 697, 543, 60, 697, 60, 697, 58, - 58, 58, 58, 697, 60, 60, 545, 60, 59, 697, - 60, 60, 60, 697, 547, 60, 697, 697, 697, 697, - 60, 697, 60, 60, 697, 549, 60, 64, 697, 64, - - 60, 60, 60, 546, 550, 60, 60, 60, 60, 697, - 697, 60, 60, 60, 697, 60, 60, 697, 551, 60, - 60, 60, 697, 60, 552, 697, 60, 60, 60, 697, - 697, 60, 697, 60, 60, 60, 60, 60, 60, 697, - 60, 60, 58, 58, 58, 58, 58, 58, 60, 59, - 60, 59, 697, 59, 697, 58, 58, 58, 58, 58, - 58, 697, 59, 697, 59, 697, 59, 697, 697, 697, - 64, 557, 64, 554, 64, 556, 60, 697, 60, 697, - 561, 697, 60, 64, 697, 64, 60, 64, 60, 697, - 558, 562, 697, 60, 60, 697, 60, 60, 60, 60, - - 60, 697, 565, 60, 697, 60, 60, 563, 697, 60, - 697, 564, 60, 60, 566, 60, 697, 60, 697, 60, - 60, 60, 60, 60, 60, 60, 567, 60, 60, 60, - 60, 60, 60, 697, 697, 60, 697, 60, 60, 60, - 60, 60, 60, 58, 58, 569, 60, 697, 60, 60, - 59, 60, 60, 60, 58, 58, 570, 697, 571, 60, - 575, 59, 60, 697, 60, 697, 697, 697, 697, 60, - 60, 64, 587, 60, 60, 60, 60, 60, 60, 60, - 60, 577, 64, 573, 60, 60, 60, 60, 578, 576, - 697, 697, 60, 697, 60, 60, 60, 60, 697, 60, - - 60, 60, 60, 60, 60, 60, 697, 697, 697, 60, - 60, 60, 60, 697, 60, 697, 697, 580, 60, 60, - 60, 60, 60, 60, 581, 586, 60, 60, 697, 60, - 697, 584, 60, 60, 60, 60, 585, 60, 60, 697, - 697, 60, 60, 60, 697, 60, 60, 60, 58, 58, - 60, 60, 60, 588, 697, 590, 60, 60, 697, 60, - 60, 60, 592, 60, 589, 697, 697, 60, 697, 60, - 60, 60, 60, 697, 60, 594, 64, 60, 60, 60, - 60, 60, 60, 60, 697, 593, 697, 596, 60, 697, - 60, 60, 60, 60, 697, 60, 60, 697, 60, 60, - - 697, 697, 60, 60, 60, 60, 697, 597, 60, 60, - 598, 697, 60, 60, 600, 60, 604, 60, 697, 60, - 697, 60, 601, 697, 60, 697, 60, 60, 60, 60, - 60, 697, 60, 58, 58, 60, 605, 60, 60, 607, - 59, 606, 697, 608, 697, 60, 60, 60, 60, 697, - 609, 60, 697, 697, 60, 60, 697, 60, 60, 613, - 697, 64, 58, 58, 60, 58, 58, 60, 697, 59, - 697, 697, 59, 697, 60, 60, 60, 697, 60, 617, - 697, 619, 60, 697, 697, 60, 697, 697, 60, 60, - 64, 60, 60, 64, 697, 697, 60, 614, 618, 60, - - 615, 60, 60, 60, 60, 621, 697, 60, 60, 60, - 697, 60, 60, 697, 60, 697, 697, 60, 625, 60, - 624, 60, 60, 697, 60, 60, 60, 60, 697, 60, - 626, 60, 60, 60, 697, 697, 60, 697, 697, 60, - 60, 60, 60, 60, 627, 697, 60, 60, 630, 60, - 632, 697, 60, 629, 60, 628, 60, 697, 60, 697, - 60, 60, 60, 60, 697, 60, 60, 697, 60, 60, - 60, 60, 60, 636, 633, 697, 60, 697, 697, 60, - 60, 60, 634, 60, 639, 637, 60, 60, 60, 60, - 697, 60, 697, 60, 60, 60, 60, 697, 60, 697, - - 697, 60, 60, 60, 60, 643, 60, 697, 60, 697, - 60, 60, 697, 642, 697, 60, 60, 645, 60, 644, - 60, 60, 697, 697, 60, 60, 60, 60, 60, 646, - 60, 697, 60, 697, 697, 60, 697, 60, 60, 60, - 60, 647, 60, 60, 697, 697, 650, 60, 60, 60, - 652, 60, 60, 649, 60, 697, 697, 60, 697, 60, - 60, 60, 60, 697, 60, 60, 697, 60, 60, 60, - 60, 653, 60, 658, 60, 697, 60, 697, 655, 60, - 697, 60, 60, 60, 60, 697, 60, 60, 697, 60, - 60, 60, 60, 659, 60, 60, 60, 697, 60, 697, - - 660, 60, 697, 60, 60, 697, 60, 697, 662, 661, - 697, 60, 60, 697, 60, 697, 60, 664, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 697, 60, 697, - 60, 60, 60, 60, 697, 666, 671, 697, 60, 60, - 667, 60, 60, 60, 697, 60, 60, 60, 672, 60, - 673, 60, 60, 697, 60, 60, 674, 60, 697, 60, - 60, 60, 60, 697, 60, 60, 697, 60, 60, 60, - 60, 60, 60, 60, 60, 697, 60, 675, 60, 60, - 60, 60, 60, 60, 60, 679, 60, 60, 60, 677, - 60, 682, 680, 60, 60, 697, 60, 697, 60, 697, - - 697, 697, 681, 60, 60, 60, 60, 60, 60, 60, - 697, 60, 60, 60, 60, 60, 60, 697, 60, 60, - 697, 60, 697, 683, 697, 697, 60, 697, 60, 60, - 60, 686, 687, 60, 60, 60, 60, 697, 60, 58, - 58, 60, 60, 60, 60, 697, 688, 685, 58, 58, - 697, 60, 60, 697, 60, 59, 58, 58, 691, 58, - 58, 126, 60, 59, 697, 693, 59, 64, 60, 60, - 60, 697, 697, 697, 60, 60, 64, 697, 60, 694, - 60, 697, 60, 690, 64, 60, 60, 692, 697, 60, - 60, 60, 60, 60, 697, 60, 697, 695, 697, 60, - - 697, 60, 60, 696, 697, 697, 697, 697, 697, 60, - 697, 60, 47, 47, 47, 47, 48, 48, 48, 48, - 50, 50, 50, 50, 54, 697, 54, 113, 113, 117, - 117, 117, 117, 69, 69, 452, 452, 452, 452, 7, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697 - - } ; - -static yyconst short int yy_chk[3595] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 9, 9, 11, 18, 18, 18, - 41, 590, 11, 11, 22, 22, 49, 49, 56, 56, - 56, 22, 52, 22, 22, 22, 41, 590, 52, 688, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - - 22, 22, 22, 22, 22, 22, 678, 669, 22, 22, - 22, 22, 22, 22, 23, 23, 665, 23, 657, 24, - 656, 23, 24, 24, 23, 654, 23, 23, 23, 24, - 23, 23, 24, 651, 25, 53, 26, 23, 25, 24, - 26, 53, 53, 27, 25, 26, 26, 27, 28, 26, - 648, 27, 28, 117, 25, 26, 26, 27, 28, 117, - 27, 29, 30, 58, 58, 29, 30, 27, 28, 29, - 29, 29, 30, 641, 32, 31, 35, 640, 32, 31, - 35, 29, 30, 31, 32, 638, 35, 119, 635, 31, - 32, 58, 631, 119, 32, 623, 35, 33, 33, 31, - - 33, 33, 622, 620, 33, 34, 616, 612, 36, 34, - 33, 33, 36, 34, 603, 602, 34, 37, 36, 34, - 33, 37, 34, 36, 36, 37, 38, 599, 36, 34, - 38, 37, 595, 39, 37, 38, 38, 39, 40, 55, - 591, 37, 40, 39, 583, 55, 38, 60, 40, 59, - 59, 60, 582, 39, 579, 574, 59, 60, 40, 568, - 61, 62, 62, 560, 61, 62, 559, 60, 65, 59, - 61, 555, 65, 59, 61, 62, 548, 59, 65, 59, - 61, 63, 63, 545, 120, 63, 63, 55, 65, 59, - 120, 64, 64, 64, 540, 63, 64, 66, 66, 67, - - 67, 66, 530, 67, 67, 529, 64, 521, 68, 68, - 402, 66, 68, 67, 70, 70, 402, 511, 70, 70, - 71, 71, 68, 72, 71, 73, 74, 72, 70, 73, - 74, 120, 71, 72, 71, 73, 74, 474, 71, 449, - 75, 75, 430, 72, 76, 73, 74, 75, 76, 77, - 77, 79, 79, 77, 76, 79, 78, 78, 78, 77, - 78, 429, 429, 77, 76, 79, 77, 79, 75, 75, - 78, 397, 80, 80, 372, 78, 80, 81, 81, 82, - 82, 81, 339, 82, 83, 429, 80, 81, 83, 429, - 80, 81, 313, 82, 83, 82, 84, 84, 84, 280, - - 271, 84, 452, 197, 83, 85, 85, 85, 452, 85, - 196, 84, 85, 86, 86, 130, 196, 86, 94, 85, - 87, 87, 94, 85, 87, 86, 454, 86, 94, 88, - 88, 94, 454, 88, 87, 89, 89, 122, 94, 89, - 116, 88, 87, 88, 113, 89, 90, 90, 112, 89, - 90, 91, 91, 196, 90, 91, 111, 92, 92, 110, - 90, 92, 93, 95, 69, 91, 93, 95, 57, 91, - 54, 92, 93, 95, 96, 51, 97, 93, 96, 95, - 97, 50, 93, 95, 96, 270, 97, 96, 98, 98, - 98, 270, 43, 98, 96, 19, 97, 99, 99, 15, - - 98, 99, 10, 98, 100, 100, 98, 7, 100, 100, - 338, 99, 99, 102, 102, 99, 338, 102, 100, 101, - 101, 101, 0, 0, 101, 103, 103, 102, 100, 103, - 270, 0, 0, 0, 101, 0, 101, 103, 0, 103, - 104, 104, 105, 105, 104, 104, 105, 106, 106, 106, - 0, 105, 106, 0, 104, 338, 105, 107, 107, 108, - 108, 107, 106, 108, 107, 109, 109, 106, 124, 109, - 123, 107, 124, 108, 123, 0, 108, 125, 124, 109, - 123, 125, 0, 109, 0, 123, 0, 125, 124, 0, - 123, 126, 126, 0, 0, 126, 0, 125, 127, 127, - - 128, 128, 127, 0, 128, 126, 0, 129, 129, 131, - 128, 129, 127, 131, 128, 0, 0, 132, 132, 131, - 133, 129, 132, 0, 133, 0, 129, 134, 132, 131, - 133, 134, 135, 0, 134, 0, 135, 134, 132, 0, - 133, 0, 135, 136, 136, 136, 135, 134, 136, 137, - 137, 0, 135, 137, 0, 138, 138, 139, 136, 138, - 140, 139, 0, 137, 140, 139, 137, 144, 144, 138, - 140, 139, 0, 138, 144, 141, 141, 0, 139, 141, - 140, 139, 142, 142, 0, 0, 142, 143, 143, 141, - 145, 143, 0, 0, 145, 144, 142, 0, 142, 146, - - 145, 143, 0, 146, 147, 0, 146, 148, 147, 146, - 145, 148, 149, 0, 147, 0, 149, 148, 0, 146, - 0, 148, 149, 0, 147, 0, 151, 148, 150, 150, - 151, 0, 149, 151, 152, 150, 151, 0, 152, 153, - 0, 152, 0, 153, 152, 0, 151, 154, 155, 153, - 0, 154, 155, 0, 152, 0, 150, 154, 155, 153, - 156, 157, 154, 0, 156, 157, 156, 154, 155, 158, - 156, 157, 160, 158, 161, 0, 160, 0, 161, 158, - 156, 157, 160, 159, 161, 158, 0, 159, 0, 158, - 159, 162, 160, 159, 161, 162, 163, 0, 178, 178, - - 163, 162, 178, 159, 162, 164, 163, 0, 0, 164, - 166, 162, 178, 165, 166, 164, 163, 165, 164, 167, - 166, 165, 168, 167, 166, 164, 168, 165, 0, 167, - 166, 169, 168, 0, 167, 169, 168, 165, 0, 167, - 170, 169, 168, 0, 170, 183, 183, 0, 169, 171, - 170, 169, 183, 171, 172, 170, 171, 173, 172, 171, - 170, 173, 495, 0, 172, 495, 0, 173, 174, 171, - 172, 0, 174, 183, 172, 495, 174, 173, 0, 175, - 175, 495, 174, 175, 0, 176, 176, 177, 177, 176, - 0, 177, 174, 175, 0, 0, 179, 179, 175, 176, - - 179, 177, 0, 180, 176, 181, 177, 180, 179, 181, - 179, 0, 182, 180, 0, 181, 182, 184, 184, 0, - 181, 184, 182, 180, 0, 181, 185, 185, 0, 0, - 185, 184, 182, 186, 186, 187, 0, 186, 0, 187, - 185, 0, 188, 0, 185, 187, 188, 186, 0, 189, - 186, 188, 188, 189, 190, 187, 191, 192, 190, 189, - 191, 192, 188, 0, 190, 0, 191, 192, 193, 189, - 0, 193, 193, 191, 190, 198, 191, 192, 193, 198, - 0, 0, 0, 199, 198, 198, 0, 199, 193, 0, - 200, 0, 0, 199, 200, 198, 199, 203, 201, 0, - - 200, 203, 201, 199, 200, 204, 204, 203, 201, 202, - 200, 201, 204, 202, 205, 205, 207, 203, 201, 202, - 207, 205, 202, 206, 206, 0, 207, 208, 208, 202, - 206, 208, 0, 204, 209, 210, 207, 0, 209, 210, - 0, 208, 205, 205, 209, 210, 211, 0, 212, 213, - 211, 206, 212, 213, 209, 210, 211, 0, 212, 213, - 0, 0, 211, 214, 0, 213, 211, 214, 212, 213, - 215, 216, 214, 214, 215, 216, 217, 0, 215, 0, - 217, 216, 0, 214, 215, 0, 217, 0, 216, 217, - 0, 216, 0, 218, 215, 220, 217, 218, 219, 220, - - 221, 0, 219, 218, 221, 220, 219, 0, 220, 0, - 221, 0, 219, 218, 222, 220, 0, 0, 222, 223, - 221, 224, 219, 223, 222, 224, 0, 222, 223, 223, - 0, 224, 225, 226, 222, 0, 225, 226, 227, 223, - 225, 224, 227, 226, 0, 228, 225, 0, 227, 228, - 229, 227, 0, 226, 229, 228, 225, 0, 227, 0, - 229, 228, 230, 0, 232, 228, 230, 0, 232, 229, - 229, 231, 230, 231, 232, 231, 233, 0, 0, 234, - 233, 231, 230, 234, 232, 0, 233, 0, 0, 234, - 233, 231, 0, 235, 235, 0, 233, 235, 0, 234, - - 236, 236, 238, 0, 236, 0, 238, 235, 237, 237, - 237, 239, 238, 237, 236, 239, 0, 0, 236, 240, - 240, 239, 238, 237, 0, 0, 240, 241, 241, 242, - 242, 239, 0, 243, 241, 0, 242, 243, 244, 0, - 245, 246, 244, 243, 245, 246, 244, 240, 0, 0, - 245, 246, 244, 243, 247, 241, 0, 242, 247, 0, - 245, 246, 244, 242, 247, 248, 0, 247, 0, 248, - 0, 0, 249, 250, 247, 248, 249, 250, 248, 0, - 251, 249, 249, 250, 251, 248, 0, 252, 250, 0, - 251, 252, 249, 250, 252, 253, 0, 252, 0, 253, - - 251, 0, 254, 0, 0, 253, 254, 252, 253, 255, - 256, 0, 254, 255, 256, 253, 0, 255, 0, 0, - 256, 257, 254, 255, 0, 257, 0, 0, 259, 0, - 256, 257, 259, 255, 258, 0, 259, 257, 258, 0, - 0, 257, 259, 258, 258, 0, 260, 261, 0, 0, - 260, 261, 259, 260, 258, 261, 260, 0, 262, 0, - 263, 261, 262, 264, 263, 0, 260, 264, 262, 263, - 263, 261, 265, 264, 0, 266, 265, 264, 262, 266, - 263, 0, 265, 264, 266, 266, 267, 268, 268, 0, - 267, 268, 265, 269, 269, 266, 267, 269, 272, 272, - - 0, 268, 272, 273, 273, 273, 267, 269, 273, 274, - 274, 275, 272, 274, 0, 275, 272, 0, 273, 0, - 276, 275, 0, 274, 276, 0, 274, 0, 277, 277, - 276, 275, 277, 278, 279, 0, 0, 278, 279, 282, - 276, 278, 277, 282, 279, 281, 281, 278, 0, 282, - 0, 0, 281, 0, 279, 0, 283, 278, 284, 282, - 283, 281, 284, 285, 285, 283, 283, 284, 284, 0, - 285, 286, 286, 281, 0, 286, 283, 288, 284, 287, - 287, 288, 0, 287, 0, 286, 290, 288, 289, 287, - 290, 285, 289, 287, 0, 289, 290, 288, 289, 291, - - 292, 292, 0, 291, 292, 0, 290, 0, 289, 291, - 0, 293, 293, 0, 292, 293, 294, 294, 0, 291, - 294, 0, 295, 295, 0, 293, 295, 293, 296, 296, - 294, 0, 296, 294, 297, 297, 295, 0, 297, 298, - 298, 0, 296, 298, 0, 0, 296, 0, 297, 0, - 0, 297, 0, 298, 299, 299, 300, 300, 299, 0, - 300, 301, 301, 301, 0, 301, 0, 0, 299, 0, - 300, 0, 302, 302, 300, 301, 302, 303, 303, 303, - 304, 0, 303, 0, 304, 0, 302, 0, 305, 305, - 304, 0, 303, 305, 306, 306, 307, 307, 319, 305, - - 304, 306, 319, 307, 308, 308, 309, 309, 319, 305, - 0, 308, 0, 309, 310, 310, 311, 311, 319, 314, - 314, 310, 306, 311, 307, 312, 314, 0, 0, 312, - 0, 307, 308, 312, 309, 311, 0, 0, 0, 312, - 0, 309, 310, 310, 311, 315, 315, 314, 0, 312, - 316, 316, 315, 0, 317, 317, 320, 316, 317, 321, - 320, 318, 318, 321, 0, 318, 320, 0, 317, 321, - 502, 502, 0, 315, 315, 318, 320, 318, 316, 321, - 322, 0, 323, 324, 322, 316, 323, 324, 0, 322, - 322, 0, 323, 324, 502, 325, 0, 323, 502, 325, - - 322, 0, 323, 324, 325, 325, 326, 327, 327, 328, - 326, 0, 327, 328, 0, 325, 326, 0, 327, 328, - 329, 326, 329, 328, 329, 0, 326, 330, 327, 328, - 329, 330, 331, 0, 332, 0, 331, 330, 332, 0, - 329, 330, 331, 0, 332, 0, 0, 330, 333, 333, - 0, 0, 331, 332, 332, 333, 334, 334, 0, 0, - 334, 335, 335, 335, 0, 335, 0, 336, 336, 0, - 334, 336, 0, 340, 340, 335, 333, 340, 337, 337, - 0, 336, 337, 336, 0, 341, 341, 340, 337, 341, - 342, 342, 337, 0, 342, 0, 343, 343, 0, 341, - - 343, 344, 344, 0, 342, 344, 345, 345, 345, 0, - 343, 345, 346, 346, 343, 344, 346, 0, 347, 347, - 0, 345, 347, 0, 346, 0, 346, 348, 348, 349, - 349, 348, 347, 349, 347, 0, 350, 350, 351, 348, - 350, 348, 351, 349, 0, 352, 0, 353, 351, 352, - 350, 353, 354, 352, 0, 353, 354, 0, 351, 352, - 0, 353, 354, 355, 355, 0, 356, 354, 355, 352, - 356, 353, 354, 357, 355, 358, 356, 357, 0, 358, - 0, 356, 0, 357, 355, 358, 356, 0, 358, 0, - 359, 359, 0, 357, 359, 358, 360, 360, 0, 0, - - 360, 361, 361, 361, 359, 363, 361, 362, 362, 363, - 360, 362, 0, 364, 360, 363, 361, 364, 365, 0, - 366, 362, 365, 364, 366, 363, 0, 364, 365, 0, - 366, 367, 368, 364, 0, 367, 368, 0, 365, 369, - 366, 367, 368, 369, 0, 367, 524, 524, 0, 369, - 0, 367, 368, 370, 369, 0, 0, 370, 371, 369, - 373, 373, 371, 370, 0, 374, 370, 373, 371, 374, - 524, 0, 375, 370, 524, 374, 375, 376, 371, 377, - 375, 376, 0, 377, 373, 374, 375, 376, 373, 377, - 0, 378, 0, 0, 377, 378, 375, 376, 379, 377, - - 378, 378, 379, 389, 389, 380, 381, 389, 379, 380, - 381, 378, 0, 379, 0, 380, 381, 389, 379, 382, - 0, 381, 0, 382, 383, 380, 381, 384, 383, 382, - 0, 384, 385, 383, 383, 0, 385, 384, 0, 382, - 386, 386, 385, 0, 383, 386, 387, 384, 0, 388, - 387, 386, 385, 388, 390, 390, 387, 0, 390, 388, - 0, 386, 0, 0, 388, 0, 387, 0, 390, 388, - 391, 391, 0, 390, 391, 392, 392, 393, 393, 392, - 0, 393, 394, 394, 391, 0, 394, 0, 395, 392, - 396, 393, 395, 398, 396, 0, 394, 398, 395, 394, - - 396, 0, 401, 398, 399, 399, 401, 0, 395, 0, - 396, 399, 401, 398, 400, 400, 404, 0, 0, 0, - 404, 400, 401, 0, 405, 406, 404, 405, 405, 406, - 0, 404, 399, 0, 405, 406, 404, 407, 0, 0, - 406, 407, 400, 0, 405, 406, 408, 407, 400, 0, - 408, 409, 407, 0, 410, 409, 408, 407, 410, 408, - 0, 409, 0, 410, 410, 411, 408, 0, 0, 411, - 0, 409, 412, 413, 410, 411, 412, 413, 411, 412, - 414, 0, 412, 413, 414, 411, 0, 415, 0, 0, - 414, 415, 412, 413, 416, 417, 0, 415, 416, 417, - - 414, 0, 418, 0, 416, 417, 418, 415, 0, 419, - 417, 0, 418, 419, 416, 417, 420, 421, 0, 419, - 420, 421, 418, 0, 419, 0, 420, 421, 422, 419, - 423, 420, 422, 0, 423, 0, 420, 421, 422, 424, - 423, 0, 425, 424, 0, 423, 425, 426, 422, 424, - 423, 426, 425, 0, 427, 0, 425, 426, 427, 424, - 0, 428, 425, 0, 427, 428, 0, 426, 431, 431, - 428, 428, 432, 433, 427, 431, 432, 433, 0, 0, - 433, 428, 432, 433, 434, 435, 435, 431, 434, 435, - 0, 0, 432, 433, 434, 0, 431, 436, 436, 435, - - 0, 436, 437, 437, 434, 438, 437, 0, 439, 438, - 0, 436, 439, 0, 0, 438, 437, 439, 439, 440, - 440, 0, 441, 440, 0, 438, 441, 442, 439, 0, - 443, 442, 441, 440, 443, 444, 0, 442, 0, 444, - 443, 0, 441, 0, 0, 444, 0, 442, 444, 445, - 443, 0, 446, 445, 0, 444, 446, 448, 0, 445, - 447, 448, 446, 0, 447, 446, 0, 448, 447, 445, - 448, 0, 446, 0, 447, 450, 450, 448, 451, 451, - 455, 455, 450, 0, 447, 451, 0, 455, 456, 456, - 0, 450, 457, 462, 462, 456, 457, 458, 0, 0, - - 462, 458, 457, 450, 0, 459, 451, 458, 455, 459, - 455, 0, 457, 0, 455, 459, 456, 458, 460, 461, - 461, 462, 460, 473, 473, 459, 461, 473, 460, 0, - 463, 464, 465, 460, 463, 464, 465, 473, 460, 0, - 463, 464, 465, 461, 466, 466, 0, 461, 0, 466, - 463, 464, 465, 467, 468, 466, 0, 467, 468, 0, - 0, 0, 469, 467, 468, 466, 469, 0, 0, 0, - 0, 469, 469, 467, 468, 470, 471, 472, 0, 470, - 471, 472, 469, 0, 475, 470, 471, 472, 475, 476, - 472, 0, 0, 476, 475, 470, 471, 472, 477, 476, - - 0, 478, 477, 0, 475, 478, 479, 477, 477, 476, - 479, 478, 0, 480, 0, 0, 479, 480, 477, 479, - 0, 478, 0, 480, 481, 481, 479, 483, 482, 481, - 482, 483, 482, 480, 0, 481, 484, 483, 482, 0, - 484, 0, 0, 485, 485, 481, 484, 483, 482, 484, - 485, 486, 486, 487, 0, 488, 484, 487, 486, 488, - 489, 489, 0, 487, 0, 488, 0, 489, 0, 490, - 490, 485, 0, 487, 0, 488, 490, 494, 494, 486, - 491, 491, 492, 492, 489, 493, 493, 491, 489, 492, - 0, 0, 493, 0, 0, 496, 496, 490, 0, 496, - - 0, 0, 0, 0, 490, 494, 0, 494, 491, 496, - 492, 494, 493, 493, 497, 492, 499, 498, 497, 500, - 499, 498, 0, 500, 497, 498, 499, 0, 0, 500, - 0, 498, 500, 501, 497, 0, 499, 501, 0, 500, - 503, 498, 504, 501, 503, 0, 504, 501, 0, 503, - 503, 504, 504, 501, 505, 506, 507, 507, 505, 506, - 503, 507, 504, 0, 505, 506, 0, 507, 0, 508, - 508, 509, 509, 0, 505, 506, 508, 507, 509, 0, - 510, 512, 512, 0, 510, 512, 0, 0, 0, 0, - 510, 0, 513, 513, 0, 512, 513, 508, 0, 509, - - 510, 514, 514, 508, 513, 514, 513, 515, 515, 0, - 0, 515, 516, 516, 0, 514, 516, 0, 514, 517, - 517, 515, 0, 517, 516, 0, 516, 518, 518, 0, - 0, 518, 0, 517, 519, 519, 520, 520, 519, 0, - 520, 518, 522, 522, 523, 523, 525, 525, 519, 522, - 520, 523, 0, 525, 0, 526, 526, 527, 527, 528, - 528, 0, 526, 0, 527, 0, 528, 0, 0, 0, - 522, 526, 523, 523, 525, 525, 531, 0, 532, 0, - 531, 0, 532, 526, 0, 527, 531, 528, 532, 0, - 527, 532, 0, 533, 533, 0, 531, 533, 532, 534, - - 534, 0, 535, 534, 0, 536, 535, 533, 0, 536, - 0, 534, 535, 534, 536, 536, 0, 537, 0, 538, - 539, 537, 535, 538, 539, 536, 537, 537, 541, 538, - 539, 544, 541, 0, 0, 544, 0, 537, 541, 538, - 539, 544, 542, 546, 546, 541, 542, 0, 541, 543, - 546, 544, 542, 543, 547, 547, 542, 0, 543, 543, - 549, 547, 542, 0, 549, 0, 0, 0, 0, 543, - 549, 546, 564, 564, 550, 551, 564, 552, 550, 551, - 549, 552, 547, 547, 550, 551, 564, 552, 553, 550, - 0, 0, 553, 0, 550, 551, 553, 552, 0, 554, - - 556, 557, 553, 554, 556, 557, 0, 0, 0, 554, - 556, 557, 553, 0, 558, 0, 0, 556, 558, 554, - 556, 557, 561, 562, 558, 563, 561, 562, 0, 563, - 0, 561, 561, 562, 558, 563, 562, 565, 565, 0, - 0, 565, 561, 562, 0, 563, 566, 566, 567, 567, - 566, 565, 569, 565, 0, 567, 569, 570, 0, 571, - 566, 570, 569, 571, 566, 0, 0, 570, 0, 571, - 572, 573, 569, 0, 572, 573, 567, 570, 575, 571, - 572, 573, 575, 576, 0, 572, 0, 576, 575, 0, - 572, 573, 577, 576, 0, 578, 577, 0, 575, 578, - - 0, 0, 577, 576, 580, 578, 0, 577, 580, 581, - 578, 0, 577, 581, 580, 578, 584, 584, 0, 581, - 0, 584, 581, 0, 580, 0, 585, 584, 586, 581, - 585, 0, 586, 592, 592, 587, 585, 584, 586, 587, - 592, 586, 0, 588, 0, 587, 585, 588, 586, 0, - 589, 588, 0, 0, 589, 587, 0, 588, 589, 592, - 0, 592, 593, 593, 589, 594, 594, 588, 0, 593, - 0, 0, 594, 0, 589, 596, 596, 0, 597, 596, - 0, 598, 597, 0, 0, 598, 0, 0, 597, 596, - 593, 598, 601, 594, 0, 0, 601, 593, 597, 600, - - 594, 598, 601, 600, 604, 600, 0, 605, 604, 600, - 0, 605, 601, 0, 604, 0, 0, 605, 606, 600, - 605, 607, 606, 0, 604, 607, 606, 605, 0, 608, - 607, 607, 606, 608, 0, 0, 609, 0, 0, 608, - 609, 607, 606, 610, 608, 0, 609, 610, 611, 608, - 613, 0, 611, 610, 613, 609, 609, 0, 611, 0, - 613, 614, 615, 610, 0, 614, 615, 0, 611, 617, - 613, 614, 615, 617, 614, 0, 618, 0, 0, 617, - 618, 614, 615, 619, 621, 619, 618, 619, 621, 617, - 0, 624, 0, 619, 621, 624, 618, 0, 625, 0, - - 0, 624, 625, 619, 621, 626, 626, 0, 625, 0, - 626, 624, 0, 625, 0, 627, 626, 628, 625, 627, - 629, 628, 0, 0, 629, 627, 626, 628, 630, 629, - 629, 0, 630, 0, 0, 627, 0, 628, 630, 632, - 629, 630, 633, 632, 0, 0, 633, 634, 630, 632, - 636, 634, 633, 632, 636, 0, 0, 634, 0, 632, - 636, 637, 633, 0, 639, 637, 0, 634, 639, 642, - 636, 637, 643, 642, 639, 0, 643, 0, 639, 642, - 0, 637, 643, 644, 639, 0, 645, 644, 0, 642, - 645, 647, 643, 644, 646, 647, 645, 0, 646, 0, - - 645, 647, 0, 644, 646, 0, 645, 0, 647, 646, - 0, 647, 649, 0, 646, 0, 649, 650, 650, 652, - 652, 650, 649, 652, 653, 653, 658, 0, 653, 0, - 658, 650, 649, 652, 0, 652, 658, 0, 653, 659, - 653, 655, 655, 659, 0, 655, 658, 660, 659, 659, - 661, 660, 662, 0, 661, 655, 662, 660, 0, 659, - 661, 664, 662, 0, 666, 664, 0, 660, 666, 667, - 661, 664, 662, 667, 666, 0, 671, 664, 672, 667, - 671, 664, 672, 673, 666, 671, 671, 673, 672, 667, - 674, 674, 672, 673, 674, 0, 671, 0, 672, 0, - - 0, 0, 673, 673, 674, 675, 675, 677, 677, 675, - 0, 677, 679, 679, 680, 680, 679, 0, 680, 675, - 0, 677, 0, 675, 0, 0, 679, 0, 680, 681, - 681, 682, 683, 681, 685, 682, 683, 0, 685, 686, - 686, 682, 683, 681, 685, 0, 686, 681, 687, 687, - 0, 682, 683, 0, 685, 687, 689, 689, 690, 691, - 691, 692, 690, 689, 0, 692, 691, 686, 690, 692, - 693, 0, 0, 0, 693, 692, 687, 0, 690, 693, - 693, 0, 694, 689, 689, 692, 694, 691, 0, 695, - 693, 696, 694, 695, 0, 696, 0, 694, 0, 695, - - 0, 696, 694, 695, 0, 0, 0, 0, 0, 695, - 0, 696, 698, 698, 698, 698, 699, 699, 699, 699, - 700, 700, 700, 700, 701, 0, 701, 702, 702, 703, - 703, 703, 703, 704, 704, 705, 705, 705, 705, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, - 697, 697, 697, 697 - - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "core/lex-asn1.l" -#define INITIAL 0 -#define MACRO_DEF 1 -#define BRACE_BAL 2 - -/* compiler/core/lex-asn1.l */ -/* AUTHOR: Mike Sample */ -/* DATE: 91/92 */ -/* Copyright (C) 1991, 1992 Michael Sample */ -/* and the University of British Columbia */ -/* 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. */ -/* these comments must only be a single line each - lex blows it otherwise */ -/* due to this claim, the rcs log is at the end of this file. */ -/* $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/lex-asn1.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $ */ -/* This lex spec should compile under either lex or flex. */ -/* There are three modes to the lexical analyzer, INITIAL, MACRO_DEF, */ -/* and BRACE_BAL. INITIAL is the normal mode. MACRO_DEF is used by */ -/* a lexical tie-in from the yacc code to eat a MACRO DEFINTION as a */ -/* single blk of text. BRACE_BAL is used to by a lexical tie-in for */ -/* eating values inside { }'s. */ -/* if your ASN.1 source file has control characters that cause */ -/* snacc to choke, use a program like 'tr' to condition them first. */ -#line 41 "core/lex-asn1.l" - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "exports.h" -#include "parse-asn1.h" /* defines the returned token values */ -#include "parser.h" -#include "lex-stuff.h" -#include "errno.h" - -unsigned long int myLineNoG = 0; - - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 55 "core/lex-asn1.l" - - - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 698 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 3540 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 57 "core/lex-asn1.l" -return BOXC_SYM; - YY_BREAK -case 2: -YY_RULE_SETUP -#line 58 "core/lex-asn1.l" -return BOXS_SYM; - YY_BREAK -case 3: -YY_RULE_SETUP -#line 60 "core/lex-asn1.l" -{ COUNT_NEWLINES (myLineNoG, yytext);} - YY_BREAK -case 4: -YY_RULE_SETUP -#line 61 "core/lex-asn1.l" -return DOT_SYM; - YY_BREAK -case 5: -YY_RULE_SETUP -#line 62 "core/lex-asn1.l" -return COMMA_SYM; - YY_BREAK -case 6: -YY_RULE_SETUP -#line 63 "core/lex-asn1.l" -return LEFTBRACE_SYM; - YY_BREAK -case 7: -YY_RULE_SETUP -#line 64 "core/lex-asn1.l" -return RIGHTBRACE_SYM; - YY_BREAK -case 8: -YY_RULE_SETUP -#line 65 "core/lex-asn1.l" -return LEFTPAREN_SYM; - YY_BREAK -case 9: -YY_RULE_SETUP -#line 66 "core/lex-asn1.l" -return RIGHTPAREN_SYM; - YY_BREAK -case 10: -YY_RULE_SETUP -#line 67 "core/lex-asn1.l" -return LEFTBRACKET_SYM; - YY_BREAK -case 11: -YY_RULE_SETUP -#line 68 "core/lex-asn1.l" -return RIGHTBRACKET_SYM; - YY_BREAK -case 12: -YY_RULE_SETUP -#line 69 "core/lex-asn1.l" -return LESSTHAN_SYM; - YY_BREAK -case 13: -YY_RULE_SETUP -#line 70 "core/lex-asn1.l" -return MINUS_SYM; - YY_BREAK -case 14: -YY_RULE_SETUP -#line 71 "core/lex-asn1.l" -return GETS_SYM; - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "core/lex-asn1.l" -return BAR_SYM; - YY_BREAK -case 16: -YY_RULE_SETUP -#line 73 "core/lex-asn1.l" -return SEMI_COLON_SYM; - YY_BREAK -case 17: -YY_RULE_SETUP -#line 74 "core/lex-asn1.l" -return TAGS_SYM; - YY_BREAK -case 18: -YY_RULE_SETUP -#line 75 "core/lex-asn1.l" -return BOOLEAN_SYM; - YY_BREAK -case 19: -YY_RULE_SETUP -#line 76 "core/lex-asn1.l" -return INTEGER_SYM; - YY_BREAK -case 20: -YY_RULE_SETUP -#line 77 "core/lex-asn1.l" -return BIT_SYM; - YY_BREAK -case 21: -YY_RULE_SETUP -#line 78 "core/lex-asn1.l" -return STRING_SYM; - YY_BREAK -case 22: -YY_RULE_SETUP -#line 79 "core/lex-asn1.l" -return OCTET_SYM; - YY_BREAK -case 23: -YY_RULE_SETUP -#line 80 "core/lex-asn1.l" -return NULL_SYM; - YY_BREAK -case 24: -YY_RULE_SETUP -#line 81 "core/lex-asn1.l" -return SEQUENCE_SYM; - YY_BREAK -case 25: -YY_RULE_SETUP -#line 82 "core/lex-asn1.l" -return OF_SYM; - YY_BREAK -case 26: -YY_RULE_SETUP -#line 83 "core/lex-asn1.l" -return SET_SYM; - YY_BREAK -case 27: -YY_RULE_SETUP -#line 84 "core/lex-asn1.l" -return IMPLICIT_SYM; - YY_BREAK -case 28: -YY_RULE_SETUP -#line 85 "core/lex-asn1.l" -return CHOICE_SYM; - YY_BREAK -case 29: -YY_RULE_SETUP -#line 86 "core/lex-asn1.l" -return ANY_SYM; - YY_BREAK -case 30: -YY_RULE_SETUP -#line 87 "core/lex-asn1.l" -{ - COUNT_NEWLINES (myLineNoG, yytext); - return OBJECT_IDENTIFIER_SYM;} - YY_BREAK -case 31: -YY_RULE_SETUP -#line 90 "core/lex-asn1.l" -return OPTIONAL_SYM; - YY_BREAK -case 32: -YY_RULE_SETUP -#line 91 "core/lex-asn1.l" -return DEFAULT_SYM; - YY_BREAK -case 33: -YY_RULE_SETUP -#line 92 "core/lex-asn1.l" -return COMPONENTS_SYM; - YY_BREAK -case 34: -YY_RULE_SETUP -#line 93 "core/lex-asn1.l" -return UNIVERSAL_SYM; - YY_BREAK -case 35: -YY_RULE_SETUP -#line 94 "core/lex-asn1.l" -return APPLICATION_SYM; - YY_BREAK -case 36: -YY_RULE_SETUP -#line 95 "core/lex-asn1.l" -return PRIVATE_SYM; - YY_BREAK -case 37: -YY_RULE_SETUP -#line 96 "core/lex-asn1.l" -return TRUE_SYM; - YY_BREAK -case 38: -YY_RULE_SETUP -#line 97 "core/lex-asn1.l" -return FALSE_SYM; - YY_BREAK -case 39: -YY_RULE_SETUP -#line 98 "core/lex-asn1.l" -return BEGIN_SYM; - YY_BREAK -case 40: -YY_RULE_SETUP -#line 99 "core/lex-asn1.l" -return END_SYM; - YY_BREAK -case 41: -YY_RULE_SETUP -#line 100 "core/lex-asn1.l" -return DEFINITIONS_SYM; - YY_BREAK -case 42: -YY_RULE_SETUP -#line 101 "core/lex-asn1.l" -return EXPLICIT_SYM; - YY_BREAK -case 43: -YY_RULE_SETUP -#line 102 "core/lex-asn1.l" -return ENUMERATED_SYM; - YY_BREAK -case 44: -YY_RULE_SETUP -#line 103 "core/lex-asn1.l" -return EXPORTS_SYM; - YY_BREAK -case 45: -YY_RULE_SETUP -#line 104 "core/lex-asn1.l" -return IMPORTS_SYM; - YY_BREAK -case 46: -YY_RULE_SETUP -#line 105 "core/lex-asn1.l" -return REAL_SYM; - YY_BREAK -case 47: -YY_RULE_SETUP -#line 106 "core/lex-asn1.l" -return INCLUDES_SYM; - YY_BREAK -case 48: -YY_RULE_SETUP -#line 107 "core/lex-asn1.l" -return MIN_SYM; - YY_BREAK -case 49: -YY_RULE_SETUP -#line 108 "core/lex-asn1.l" -return MAX_SYM; - YY_BREAK -case 50: -YY_RULE_SETUP -#line 109 "core/lex-asn1.l" -return SIZE_SYM; - YY_BREAK -case 51: -YY_RULE_SETUP -#line 110 "core/lex-asn1.l" -return FROM_SYM; - YY_BREAK -case 52: -YY_RULE_SETUP -#line 111 "core/lex-asn1.l" -return WITH_SYM; - YY_BREAK -case 53: -YY_RULE_SETUP -#line 112 "core/lex-asn1.l" -return COMPONENT_SYM; - YY_BREAK -case 54: -YY_RULE_SETUP -#line 113 "core/lex-asn1.l" -return PRESENT_SYM; - YY_BREAK -case 55: -YY_RULE_SETUP -#line 114 "core/lex-asn1.l" -return ABSENT_SYM; - YY_BREAK -case 56: -YY_RULE_SETUP -#line 115 "core/lex-asn1.l" -return DEFINED_SYM; - YY_BREAK -case 57: -YY_RULE_SETUP -#line 116 "core/lex-asn1.l" -return BY_SYM; - YY_BREAK -case 58: -YY_RULE_SETUP -#line 117 "core/lex-asn1.l" -return PLUS_INFINITY_SYM; - YY_BREAK -case 59: -YY_RULE_SETUP -#line 118 "core/lex-asn1.l" -return MINUS_INFINITY_SYM; - YY_BREAK -case 60: -YY_RULE_SETUP -#line 122 "core/lex-asn1.l" -{ - int i; - char *buf; - int bufSize; - int inComment; - int inStr; - unsigned int c, c1, c2; - - /* - * matches any first char, then - * copies everything until an uncommented, - * unquoted END. This Lex state is started - * from the yacc src (lexical tie in) - * from the MACRO_DEF production. - * - * if you don't like realloc and don't care about - * macro defs just have this return a constant string - * like "BEGIN END" after eating the definition - */ - - unput (yytext[0]); - - bufSize = 1024; - buf = Malloc (1024); - - i = 0; /* put BEGIN str at beginning */ - buf[i++] = 'B'; - buf[i++] = 'E'; - buf[i++] = 'G'; - buf[i++] = 'I'; - buf[i++] = 'N'; - buf[i++] = '\n'; - - inStr = FALSE; - inComment = FALSE; - for ( ; ; i++) - { - c = input(); - - if (i >= (bufSize - 4)) - { - bufSize += 512; - buf = (char*) Realloc (buf, bufSize); - } - - buf[i] = c; - - if ((inComment) && (c == '\n')) - inComment = FALSE; - else if (!(inStr) && (c == '-')) - { - c = input(); - if (c == '-') - { - buf[++i] = c; - inComment = !inComment; - } - else - unput (c); - } - else if (inComment) - continue; - else if (c == '"') - inStr = !inStr; - else if (inStr) - continue; - else if (c == 'E') - { - c1 = input(); - c2 = input(); - if ((c1 == 'N') && (c2 == 'D')) - { - buf[++i] = 'N'; - buf[++i] = 'D'; - buf[++i] = '\0'; - yylval.charPtr = buf; - COUNT_NEWLINES (myLineNoG, buf); - myLineNoG -=1; /* take off 1 added after "BEGIN" */ - return MACRODEFBODY_SYM; - } - else - { - unput (c2); - unput (c1); - } - } - } - /* not reached */ -} - YY_BREAK -case 61: -YY_RULE_SETUP -#line 214 "core/lex-asn1.l" -{ - int i; - /* copy and return the Macro's name only */ - /* doesn't handle comments between macro name and MACRO sym */ - for (i = 0; (yytext[i] != ' ') && - (yytext[i] != '\t') && - (yytext[i] != '\n') && - (yytext[i] != '\r'); i++); - yylval.charPtr = Malloc (i+1); - strncpy (yylval.charPtr, yytext, i); - yylval.charPtr[i] = '\0'; - return NAMEDMACRO_SYM; } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 228 "core/lex-asn1.l" -return OPERATION_SYM; - YY_BREAK -case 63: -YY_RULE_SETUP -#line 229 "core/lex-asn1.l" -return ARGUMENT_SYM; - YY_BREAK -case 64: -YY_RULE_SETUP -#line 230 "core/lex-asn1.l" -return RESULT_SYM; - YY_BREAK -case 65: -YY_RULE_SETUP -#line 231 "core/lex-asn1.l" -return ERRORS_SYM; - YY_BREAK -case 66: -YY_RULE_SETUP -#line 232 "core/lex-asn1.l" -return LINKED_SYM; - YY_BREAK -case 67: -YY_RULE_SETUP -#line 234 "core/lex-asn1.l" -return ERROR_SYM; - YY_BREAK -case 68: -YY_RULE_SETUP -#line 235 "core/lex-asn1.l" -return PARAMETER_SYM; - YY_BREAK -case 69: -YY_RULE_SETUP -#line 237 "core/lex-asn1.l" -return BIND_SYM; - YY_BREAK -case 70: -YY_RULE_SETUP -#line 238 "core/lex-asn1.l" -return BINDERROR_SYM; - YY_BREAK -case 71: -YY_RULE_SETUP -#line 239 "core/lex-asn1.l" -return UNBIND_SYM; - YY_BREAK -case 72: -YY_RULE_SETUP -#line 240 "core/lex-asn1.l" -return UNBINDERROR_SYM; - YY_BREAK -case 73: -YY_RULE_SETUP -#line 242 "core/lex-asn1.l" -return AC_SYM; - YY_BREAK -case 74: -YY_RULE_SETUP -#line 243 "core/lex-asn1.l" -return ASES_SYM; - YY_BREAK -case 75: -YY_RULE_SETUP -#line 244 "core/lex-asn1.l" -return REMOTE_SYM; - YY_BREAK -case 76: -YY_RULE_SETUP -#line 245 "core/lex-asn1.l" -return INITIATOR_SYM; - YY_BREAK -case 77: -YY_RULE_SETUP -#line 246 "core/lex-asn1.l" -return RESPONDER_SYM; - YY_BREAK -case 78: -YY_RULE_SETUP -#line 247 "core/lex-asn1.l" -{ - COUNT_NEWLINES (myLineNoG, yytext); - return ABSTRACTSYNTAXES_SYM;} - YY_BREAK -case 79: -YY_RULE_SETUP -#line 251 "core/lex-asn1.l" -return ASE_SYM; - YY_BREAK -case 80: -YY_RULE_SETUP -#line 252 "core/lex-asn1.l" -return OPERATIONS_SYM; - YY_BREAK -case 81: -YY_RULE_SETUP -#line 253 "core/lex-asn1.l" -{ - COUNT_NEWLINES (myLineNoG, yytext); - return CONSUMERINVOKES_SYM;} - YY_BREAK -case 82: -YY_RULE_SETUP -#line 257 "core/lex-asn1.l" -{ - COUNT_NEWLINES (myLineNoG, yytext); - return SUPPLIERINVOKES_SYM;} - YY_BREAK -case 83: -YY_RULE_SETUP -#line 261 "core/lex-asn1.l" -return EXTENSIONATTRIBUTE_SYM; - YY_BREAK -case 84: -YY_RULE_SETUP -#line 262 "core/lex-asn1.l" -return EXTENSIONS_SYM; - YY_BREAK -case 85: -YY_RULE_SETUP -#line 263 "core/lex-asn1.l" -return CHOSEN_SYM; - YY_BREAK -case 86: -YY_RULE_SETUP -#line 265 "core/lex-asn1.l" -return EXTENSION_SYM; - YY_BREAK -case 87: -YY_RULE_SETUP -#line 266 "core/lex-asn1.l" -return CRITICAL_SYM; - YY_BREAK -case 88: -YY_RULE_SETUP -#line 267 "core/lex-asn1.l" -return FOR_SYM; - YY_BREAK -case 89: -YY_RULE_SETUP -#line 268 "core/lex-asn1.l" -return SUBMISSION_SYM; - YY_BREAK -case 90: -YY_RULE_SETUP -#line 269 "core/lex-asn1.l" -return DELIVERY_SYM; - YY_BREAK -case 91: -YY_RULE_SETUP -#line 270 "core/lex-asn1.l" -return TRANSFER_SYM; - YY_BREAK -case 92: -YY_RULE_SETUP -#line 272 "core/lex-asn1.l" -return OBJECT_SYM; - YY_BREAK -case 93: -YY_RULE_SETUP -#line 273 "core/lex-asn1.l" -return PORTS_SYM; - YY_BREAK -case 94: -YY_RULE_SETUP -#line 275 "core/lex-asn1.l" -return PORT_SYM; - YY_BREAK -case 95: -YY_RULE_SETUP -#line 276 "core/lex-asn1.l" -{ - COUNT_NEWLINES (myLineNoG, yytext); - return ABSTRACTOPS_SYM;} - YY_BREAK -case 96: -YY_RULE_SETUP -#line 281 "core/lex-asn1.l" -return REFINE_SYM; - YY_BREAK -case 97: -YY_RULE_SETUP -#line 282 "core/lex-asn1.l" -return AS_SYM; - YY_BREAK -case 98: -YY_RULE_SETUP -#line 283 "core/lex-asn1.l" -return RECURRING_SYM; - YY_BREAK -case 99: -YY_RULE_SETUP -#line 284 "core/lex-asn1.l" -return VISIBLE_SYM; - YY_BREAK -case 100: -YY_RULE_SETUP -#line 285 "core/lex-asn1.l" -return PAIRED_SYM; - YY_BREAK -case 101: -YY_RULE_SETUP -#line 287 "core/lex-asn1.l" -return ABSTRACTBIND_SYM; - YY_BREAK -case 102: -YY_RULE_SETUP -#line 288 "core/lex-asn1.l" -return TO_SYM; - YY_BREAK -case 103: -YY_RULE_SETUP -#line 290 "core/lex-asn1.l" -return ABSTRACTUNBIND_SYM; - YY_BREAK -case 104: -YY_RULE_SETUP -#line 292 "core/lex-asn1.l" -return ABSTRACTERROR_SYM; - YY_BREAK -case 105: -YY_RULE_SETUP -#line 294 "core/lex-asn1.l" -return ABSTRACTOPERATION_SYM; - YY_BREAK -case 106: -YY_RULE_SETUP -#line 296 "core/lex-asn1.l" -return TOKEN_SYM; - YY_BREAK -case 107: -YY_RULE_SETUP -#line 298 "core/lex-asn1.l" -return TOKENDATA_SYM; - YY_BREAK -case 108: -YY_RULE_SETUP -#line 300 "core/lex-asn1.l" -return SECURITYCATEGORY_SYM; - YY_BREAK -case 109: -YY_RULE_SETUP -#line 302 "core/lex-asn1.l" -return ALGORITHM_SYM; - YY_BREAK -case 110: -YY_RULE_SETUP -#line 303 "core/lex-asn1.l" -return ENCRYPTED_SYM; - YY_BREAK -case 111: -YY_RULE_SETUP -#line 304 "core/lex-asn1.l" -return SIGNED_SYM; - YY_BREAK -case 112: -YY_RULE_SETUP -#line 305 "core/lex-asn1.l" -return SIGNATURE_SYM; - YY_BREAK -case 113: -YY_RULE_SETUP -#line 306 "core/lex-asn1.l" -return PROTECTED_SYM; - YY_BREAK -case 114: -YY_RULE_SETUP -#line 308 "core/lex-asn1.l" -return OBJECTTYPE_SYM; - YY_BREAK -case 115: -YY_RULE_SETUP -#line 309 "core/lex-asn1.l" -return SYNTAX_SYM; - YY_BREAK -case 116: -YY_RULE_SETUP -#line 310 "core/lex-asn1.l" -return ACCESS_SYM; - YY_BREAK -case 117: -YY_RULE_SETUP -#line 311 "core/lex-asn1.l" -return STATUS_SYM; - YY_BREAK -case 118: -YY_RULE_SETUP -#line 312 "core/lex-asn1.l" -return DESCRIPTION_SYM; - YY_BREAK -case 119: -YY_RULE_SETUP -#line 313 "core/lex-asn1.l" -return REFERENCE_SYM; - YY_BREAK -case 120: -YY_RULE_SETUP -#line 314 "core/lex-asn1.l" -return INDEX_SYM; - YY_BREAK -case 121: -YY_RULE_SETUP -#line 315 "core/lex-asn1.l" -return DEFVAL_SYM; - YY_BREAK -case 122: -YY_RULE_SETUP -#line 319 "core/lex-asn1.l" -{ - int i; - char *buf; - int bufSize; - int inComment; - int inStr; - int braceDepth; - char c, c1, c2; - - /* - * matches any first char, then - * copies everything until an ending "}" - * Assumes that initially parsed a "{" - * and puts one at beg. of returned string - */ - unput (yytext[0]); - - bufSize = 256; - buf = Malloc (256); - - i = 0; /* put openning brace at beginning */ - buf[i++] = '{'; - buf[i++] = ' '; - - inStr = FALSE; - inComment = FALSE; - braceDepth = 1; - for ( ; ; i++) - { - c = input(); - - if (i >= (bufSize - 2)) - { - bufSize += 256; - buf = (char*) Realloc (buf, bufSize); - } - - buf[i] = c; - - if ((inComment) && (c == '\n')) - inComment = FALSE; - else if (!(inStr) && (c == '-')) - { - c = input(); - if (c == '-') - { - buf[++i] = c; - inComment = !inComment; - } - else - unput (c); - } - else if (inComment) - continue; - else if (c == '"') - inStr = !inStr; - else if (inStr) - continue; - else if (c == '{') - braceDepth++; - else if (c == '}') - { - braceDepth--; - if (braceDepth == 0) - { - buf[++i] = '\0'; - yylval.charPtr = buf; - COUNT_NEWLINES (myLineNoG, buf); - return BRACEBAL_SYM; - } - } - } - /* not reached */ -} - YY_BREAK -case 123: -YY_RULE_SETUP -#line 396 "core/lex-asn1.l" -{ - COUNT_NEWLINES (myLineNoG, yytext); - yylval.charPtr = (char*)Malloc (yyleng); - strncpy (yylval.charPtr, yytext+1, yyleng -1); /* strip "'"s */ - yylval.charPtr[yyleng-2] = '\0'; - return BSTRING_SYM;} - YY_BREAK -case 124: -YY_RULE_SETUP -#line 403 "core/lex-asn1.l" -{ - COUNT_NEWLINES (myLineNoG, yytext); - yylval.charPtr = (char*)Malloc (yyleng); - strncpy (yylval.charPtr, yytext+1, yyleng -1); /* strip "'"s */ - yylval.charPtr[yyleng-2] = '\0'; - return HSTRING_SYM;} - YY_BREAK -case 125: -YY_RULE_SETUP -#line 410 "core/lex-asn1.l" -{ - COUNT_NEWLINES (myLineNoG, yytext); - yylval.charPtr = (char*)Malloc (yyleng); - strncpy (yylval.charPtr, yytext+1, yyleng -1); /* strip '"'s */ - yylval.charPtr[yyleng-2] = '\0'; /* 2 quotes == quote in a quote */ - return CSTRING_SYM;} - YY_BREAK -case 126: -YY_RULE_SETUP -#line 417 "core/lex-asn1.l" -{ - yylval.charPtr = (char*)Malloc (yyleng+1); - strcpy (yylval.charPtr, yytext); - yylval.charPtr[yyleng] = '\0'; - return UCASEFIRST_IDENT_SYM;} - YY_BREAK -case 127: -YY_RULE_SETUP -#line 424 "core/lex-asn1.l" -{ - yylval.charPtr = (char*)Malloc (yyleng+1); - strcpy (yylval.charPtr, yytext); - yylval.charPtr[yyleng] = '\0'; - return LCASEFIRST_IDENT_SYM;} - YY_BREAK -case 128: -YY_RULE_SETUP -#line 430 "core/lex-asn1.l" -{ /*first digit cannot be zero on multi-digit #'s*/ - errno = 0; - { - unsigned long ul = (unsigned long) strtol(yytext,NULL,10); - if (!errno && ul>(unsigned long)0xFFFFFFFF) { - errno = ERANGE; - } - if (!errno) { - yylval.uintVal = (unsigned int) ul; - return NUMBER_SYM; - } - } - yylval.charPtr = (char*)Malloc (yyleng+1); - strcpy (yylval.charPtr, yytext); - yylval.charPtr[yyleng] = '\0'; - return NUMBER_ERANGE;} - YY_BREAK -case 129: -YY_RULE_SETUP -#line 447 "core/lex-asn1.l" -{ /*allow zero as first digit on single digit #'s*/ - yylval.uintVal = 0; - return NUMBER_SYM;} - YY_BREAK -case 130: -YY_RULE_SETUP -#line 452 "core/lex-asn1.l" -{ - /* this must be before the normal comment eater so that snacc attribs - * are not treated as normal comments - */ - /* eat comments, update line no */ - int len; - COUNT_NEWLINES (myLineNoG, yytext); - yylval.charPtr = (char*)Malloc (yyleng-4); - /* skip first "--snacc" in copy to ret val */ - strcpy (yylval.charPtr, yytext + 7); - len = strlen (yylval.charPtr); - /* strip off newline or -- terminator for comment */ - if (yylval.charPtr[len-1] == '\n') - yylval.charPtr[len-1] = '\0'; - else - yylval.charPtr[len-2] = '\0'; - return SNACC_ATTRIBUTES; } - YY_BREAK -case 131: -YY_RULE_SETUP -#line 471 "core/lex-asn1.l" -{ - /* eat comments, update line no */ - COUNT_NEWLINES (myLineNoG, yytext);} - YY_BREAK -case 132: -YY_RULE_SETUP -#line 476 "core/lex-asn1.l" -ECHO; - YY_BREAK -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(MACRO_DEF): -case YY_STATE_EOF(BRACE_BAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 698 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 698 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 697); - - return yy_is_jam ? 0 : yy_current_state; - } - - -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 476 "core/lex-asn1.l" - - - -/* - * these "LexBegin..." routines are used by yacc for (ack!) - * lexical tie ins - */ - -int -LexBeginMacroDefContext() -{ - BEGIN (MACRO_DEF); -} - -int -LexBeginBraceBalContext() -{ - BEGIN (BRACE_BAL); -} - -int -LexBeginInitialContext() -{ - BEGIN (INITIAL); -} - -/* - * $Log: lex-asn1.c,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.3 2000/06/08 20:12:24 dmitch - * Mods for X port. - * - * Revision 1.1.1.1 1999/03/16 18:06:49 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1997/08/28 09:46:41 wan - * Reworked number range checking, only gives warning now. - * - * Revision 1.4 1997/06/19 09:17:17 wan - * Added isPdu flag to tables. Added value range checks during parsing. - * - * Revision 1.3 1995/07/25 19:41:30 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:37:12 rj - * snacc_config.h removed. - * - * for a list of changes relative to the 1.1 distribution, please refer to the ChangeLog. - */ diff --git a/SecuritySNACCRuntime/compiler/core/lex-asn1.l b/SecuritySNACCRuntime/compiler/core/lex-asn1.l deleted file mode 100644 index 1063641b..00000000 --- a/SecuritySNACCRuntime/compiler/core/lex-asn1.l +++ /dev/null @@ -1,523 +0,0 @@ -%START MACRO_DEF BRACE_BAL -%a 14000 -%p 12000 -%e 2000 -%n 1000 -%o 20000 - - - -/* compiler/core/lex-asn1.l */ -/* AUTHOR: Mike Sample */ -/* DATE: 91/92 */ - -/* Copyright (C) 1991, 1992 Michael Sample */ -/* and the University of British Columbia */ -/* 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. */ - -/* these comments must only be a single line each - lex blows it otherwise */ -/* due to this claim, the rcs log is at the end of this file. */ -/* $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/lex-asn1.l,v 1.1 2001/06/20 21:27:57 dmitch Exp $ */ - -/* This lex spec should compile under either lex or flex. */ - -/* There are three modes to the lexical analyzer, INITIAL, MACRO_DEF, */ -/* and BRACE_BAL. INITIAL is the normal mode. MACRO_DEF is used by */ -/* a lexical tie-in from the yacc code to eat a MACRO DEFINTION as a */ -/* single blk of text. BRACE_BAL is used to by a lexical tie-in for */ -/* eating values inside { }'s. */ - -/* if your ASN.1 source file has control characters that cause */ -/* snacc to choke, use a program like 'tr' to condition them first. */ - - -WHITESPC [ \t\n\r] - - -%{ - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "exports.h" -#include "parse-asn1.h" /* defines the returned token values */ -#include "parser.h" -#include "lex-stuff.h" -#include "errno.h" - -unsigned long int myLineNoG = 0; - -%} - -%% - -"[C]" return BOXC_SYM; -"[S]" return BOXS_SYM; - -{WHITESPC}+ { COUNT_NEWLINES (myLineNoG, yytext);} -"." return DOT_SYM; -"," return COMMA_SYM; -"{" return LEFTBRACE_SYM; -"}" return RIGHTBRACE_SYM; -"(" return LEFTPAREN_SYM; -")" return RIGHTPAREN_SYM; -"[" return LEFTBRACKET_SYM; -"]" return RIGHTBRACKET_SYM; -"<" return LESSTHAN_SYM; -"-" return MINUS_SYM; -"::=" return GETS_SYM; -"|" return BAR_SYM; -";" return SEMI_COLON_SYM; -TAGS return TAGS_SYM; -BOOLEAN return BOOLEAN_SYM; -INTEGER return INTEGER_SYM; -BIT return BIT_SYM; -STRING return STRING_SYM; -OCTET return OCTET_SYM; -NULL return NULL_SYM; -SEQUENCE return SEQUENCE_SYM; -OF return OF_SYM; -SET return SET_SYM; -IMPLICIT return IMPLICIT_SYM; -CHOICE return CHOICE_SYM; -ANY return ANY_SYM; -OBJECT{WHITESPC}*IDENTIFIER { - COUNT_NEWLINES (myLineNoG, yytext); - return OBJECT_IDENTIFIER_SYM;} -OPTIONAL return OPTIONAL_SYM; -DEFAULT return DEFAULT_SYM; -COMPONENTS return COMPONENTS_SYM; -UNIVERSAL return UNIVERSAL_SYM; -APPLICATION return APPLICATION_SYM; -PRIVATE return PRIVATE_SYM; -TRUE return TRUE_SYM; -FALSE return FALSE_SYM; -BEGIN return BEGIN_SYM; -END return END_SYM; -DEFINITIONS return DEFINITIONS_SYM; -EXPLICIT return EXPLICIT_SYM; -ENUMERATED return ENUMERATED_SYM; -EXPORTS return EXPORTS_SYM; -IMPORTS return IMPORTS_SYM; -REAL return REAL_SYM; -INCLUDES return INCLUDES_SYM; -MIN return MIN_SYM; -MAX return MAX_SYM; -SIZE return SIZE_SYM; -FROM return FROM_SYM; -WITH return WITH_SYM; -COMPONENT return COMPONENT_SYM; -PRESENT return PRESENT_SYM; -ABSENT return ABSENT_SYM; -DEFINED return DEFINED_SYM; -BY return BY_SYM; -PLUS-INFINITY return PLUS_INFINITY_SYM; -MINUS-INFINITY return MINUS_INFINITY_SYM; - - - -(.|\n) { - int i; - char *buf; - int bufSize; - int inComment; - int inStr; - unsigned int c, c1, c2; - - /* - * matches any first char, then - * copies everything until an uncommented, - * unquoted END. This Lex state is started - * from the yacc src (lexical tie in) - * from the MACRO_DEF production. - * - * if you don't like realloc and don't care about - * macro defs just have this return a constant string - * like "BEGIN END" after eating the definition - */ - - unput (yytext[0]); - - bufSize = 1024; - buf = Malloc (1024); - - i = 0; /* put BEGIN str at beginning */ - buf[i++] = 'B'; - buf[i++] = 'E'; - buf[i++] = 'G'; - buf[i++] = 'I'; - buf[i++] = 'N'; - buf[i++] = '\n'; - - inStr = FALSE; - inComment = FALSE; - for ( ; ; i++) - { - c = input(); - - if (i >= (bufSize - 4)) - { - bufSize += 512; - buf = (char*) Realloc (buf, bufSize); - } - - buf[i] = c; - - if ((inComment) && (c == '\n')) - inComment = FALSE; - else if (!(inStr) && (c == '-')) - { - c = input(); - if (c == '-') - { - buf[++i] = c; - inComment = !inComment; - } - else - unput (c); - } - else if (inComment) - continue; - else if (c == '"') - inStr = !inStr; - else if (inStr) - continue; - else if (c == 'E') - { - c1 = input(); - c2 = input(); - if ((c1 == 'N') && (c2 == 'D')) - { - buf[++i] = 'N'; - buf[++i] = 'D'; - buf[++i] = '\0'; - yylval.charPtr = buf; - COUNT_NEWLINES (myLineNoG, buf); - myLineNoG -=1; /* take off 1 added after "BEGIN" */ - return MACRODEFBODY_SYM; - } - else - { - unput (c2); - unput (c1); - } - } - } - /* not reached */ -} - - - -[A-Z](-[A-Z0-9]|[A-Z0-9])*{WHITESPC}*MACRO { - int i; - /* copy and return the Macro's name only */ - /* doesn't handle comments between macro name and MACRO sym */ - for (i = 0; (yytext[i] != ' ') && - (yytext[i] != '\t') && - (yytext[i] != '\n') && - (yytext[i] != '\r'); i++); - yylval.charPtr = Malloc (i+1); - strncpy (yylval.charPtr, yytext, i); - yylval.charPtr[i] = '\0'; - return NAMEDMACRO_SYM; } - - -OPERATION return OPERATION_SYM; -ARGUMENT return ARGUMENT_SYM; -RESULT return RESULT_SYM; -ERRORS return ERRORS_SYM; -LINKED return LINKED_SYM; - -ERROR return ERROR_SYM; -PARAMETER return PARAMETER_SYM; - -BIND return BIND_SYM; -BIND-ERROR return BINDERROR_SYM; -UNBIND return UNBIND_SYM; -UNBIND-ERROR return UNBINDERROR_SYM; - -APPLICATION-CONTEXT return AC_SYM; -APPLICATION-SERVICE-ELEMENTS return ASES_SYM; -REMOTE return REMOTE_SYM; -INITIATOR return INITIATOR_SYM; -RESPONDER return RESPONDER_SYM; -ABSTRACT{WHITESPC}*SYNTAXES { - COUNT_NEWLINES (myLineNoG, yytext); - return ABSTRACTSYNTAXES_SYM;} - -APPLICATION-SERVICE-ELEMENT return ASE_SYM; -OPERATIONS return OPERATIONS_SYM; -CONSUMER{WHITESPC}*INVOKES { - COUNT_NEWLINES (myLineNoG, yytext); - return CONSUMERINVOKES_SYM;} - -SUPPLIER{WHITESPC}*INVOKES { - COUNT_NEWLINES (myLineNoG, yytext); - return SUPPLIERINVOKES_SYM;} - -EXTENSION-ATTRIBUTE return EXTENSIONATTRIBUTE_SYM; -EXTENSIONS return EXTENSIONS_SYM; -CHOSEN return CHOSEN_SYM; - -EXTENSION return EXTENSION_SYM; -CRITICAL return CRITICAL_SYM; -FOR return FOR_SYM; -SUBMISSION return SUBMISSION_SYM; -DELIVERY return DELIVERY_SYM; -TRANSFER return TRANSFER_SYM; - -OBJECT return OBJECT_SYM; -PORTS return PORTS_SYM; - -PORT return PORT_SYM; -ABSTRACT{WHITESPC}*OPERATIONS { - COUNT_NEWLINES (myLineNoG, yytext); - return ABSTRACTOPS_SYM;} - - -REFINE return REFINE_SYM; -AS return AS_SYM; -RECURRING return RECURRING_SYM; -VISIBLE return VISIBLE_SYM; -PAIRED return PAIRED_SYM; - -ABSTRACT-BIND return ABSTRACTBIND_SYM; -TO return TO_SYM; - -ABSTRACT-UNBIND return ABSTRACTUNBIND_SYM; - -ABSTRACT-ERROR return ABSTRACTERROR_SYM; - -ABSTRACT-OPERATION return ABSTRACTOPERATION_SYM; - -TOKEN return TOKEN_SYM; - -TOKEN-DATA return TOKENDATA_SYM; - -SECURITY-CATEGORY return SECURITYCATEGORY_SYM; - -ALGORITHM return ALGORITHM_SYM; -ENCRYPTED return ENCRYPTED_SYM; -SIGNED return SIGNED_SYM; -SIGNATURE return SIGNATURE_SYM; -PROTECTED return PROTECTED_SYM; - -OBJECT-TYPE return OBJECTTYPE_SYM; -SYNTAX return SYNTAX_SYM; -ACCESS return ACCESS_SYM; -STATUS return STATUS_SYM; -DESCRIPTION return DESCRIPTION_SYM; -REFERENCE return REFERENCE_SYM; -INDEX return INDEX_SYM; -DEFVAL return DEFVAL_SYM; - - - -(.|\n) { - int i; - char *buf; - int bufSize; - int inComment; - int inStr; - int braceDepth; - char c, c1, c2; - - /* - * matches any first char, then - * copies everything until an ending "}" - * Assumes that initially parsed a "{" - * and puts one at beg. of returned string - */ - unput (yytext[0]); - - bufSize = 256; - buf = Malloc (256); - - i = 0; /* put openning brace at beginning */ - buf[i++] = '{'; - buf[i++] = ' '; - - inStr = FALSE; - inComment = FALSE; - braceDepth = 1; - for ( ; ; i++) - { - c = input(); - - if (i >= (bufSize - 2)) - { - bufSize += 256; - buf = (char*) Realloc (buf, bufSize); - } - - buf[i] = c; - - if ((inComment) && (c == '\n')) - inComment = FALSE; - else if (!(inStr) && (c == '-')) - { - c = input(); - if (c == '-') - { - buf[++i] = c; - inComment = !inComment; - } - else - unput (c); - } - else if (inComment) - continue; - else if (c == '"') - inStr = !inStr; - else if (inStr) - continue; - else if (c == '{') - braceDepth++; - else if (c == '}') - { - braceDepth--; - if (braceDepth == 0) - { - buf[++i] = '\0'; - yylval.charPtr = buf; - COUNT_NEWLINES (myLineNoG, buf); - return BRACEBAL_SYM; - } - } - } - /* not reached */ -} - - - -\'[0-1]*\'B { - COUNT_NEWLINES (myLineNoG, yytext); - yylval.charPtr = (char*)Malloc (yyleng); - strncpy (yylval.charPtr, yytext+1, yyleng -1); /* strip "'"s */ - yylval.charPtr[yyleng-2] = '\0'; - return BSTRING_SYM;} - -\'[0-9A-Fa-f]*\'H { - COUNT_NEWLINES (myLineNoG, yytext); - yylval.charPtr = (char*)Malloc (yyleng); - strncpy (yylval.charPtr, yytext+1, yyleng -1); /* strip "'"s */ - yylval.charPtr[yyleng-2] = '\0'; - return HSTRING_SYM;} - -\"([^\"]|"\"\"")*\" { - COUNT_NEWLINES (myLineNoG, yytext); - yylval.charPtr = (char*)Malloc (yyleng); - strncpy (yylval.charPtr, yytext+1, yyleng -1); /* strip '"'s */ - yylval.charPtr[yyleng-2] = '\0'; /* 2 quotes == quote in a quote */ - return CSTRING_SYM;} - -[A-Z](-[a-zA-Z0-9]|[a-zA-Z0-9])* { - yylval.charPtr = (char*)Malloc (yyleng+1); - strcpy (yylval.charPtr, yytext); - yylval.charPtr[yyleng] = '\0'; - return UCASEFIRST_IDENT_SYM;} - - -[a-z](-[a-zA-Z0-9]|[a-zA-Z0-9])* { - yylval.charPtr = (char*)Malloc (yyleng+1); - strcpy (yylval.charPtr, yytext); - yylval.charPtr[yyleng] = '\0'; - return LCASEFIRST_IDENT_SYM;} - -[1-9][0-9]* { /*first digit cannot be zero on multi-digit #'s*/ - errno = 0; - { - unsigned long ul = (unsigned long) strtol(yytext,NULL,10); - if (!errno && ul>(unsigned long)0xFFFFFFFF) { - errno = ERANGE; - } - if (!errno) { - yylval.uintVal = (unsigned int) ul; - return NUMBER_SYM; - } - } - yylval.charPtr = (char*)Malloc (yyleng+1); - strcpy (yylval.charPtr, yytext); - yylval.charPtr[yyleng] = '\0'; - return NUMBER_ERANGE;} - -0 { /*allow zero as first digit on single digit #'s*/ - yylval.uintVal = 0; - return NUMBER_SYM;} - - -"--snacc"(-[^-\n]|[^\-\n])*("--"|\n) { - /* this must be before the normal comment eater so that snacc attribs - * are not treated as normal comments - */ - /* eat comments, update line no */ - int len; - COUNT_NEWLINES (myLineNoG, yytext); - yylval.charPtr = (char*)Malloc (yyleng-4); - /* skip first "--snacc" in copy to ret val */ - strcpy (yylval.charPtr, yytext + 7); - len = strlen (yylval.charPtr); - /* strip off newline or -- terminator for comment */ - if (yylval.charPtr[len-1] == '\n') - yylval.charPtr[len-1] = '\0'; - else - yylval.charPtr[len-2] = '\0'; - return SNACC_ATTRIBUTES; } - - -"--"(-[^\-\n]|[^\-\n])*("--"|\n|"-\n") { - /* eat comments, update line no */ - COUNT_NEWLINES (myLineNoG, yytext);} - - -%% - - -/* - * these "LexBegin..." routines are used by yacc for (ack!) - * lexical tie ins - */ - -int -LexBeginMacroDefContext() -{ - BEGIN (MACRO_DEF); -} - -int -LexBeginBraceBalContext() -{ - BEGIN (BRACE_BAL); -} - -int -LexBeginInitialContext() -{ - BEGIN (INITIAL); -} - -/* - * $Log: lex-asn1.l,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:49 aram - * Originals from SMIME Free Library. - * - * Revision 1.5 1997/08/28 09:46:41 wan - * Reworked number range checking, only gives warning now. - * - * Revision 1.4 1997/06/19 09:17:17 wan - * Added isPdu flag to tables. Added value range checks during parsing. - * - * Revision 1.3 1995/07/25 19:41:30 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:37:12 rj - * snacc_config.h removed. - * - * for a list of changes relative to the 1.1 distribution, please refer to the ChangeLog. - */ diff --git a/SecuritySNACCRuntime/compiler/core/lex-stuff.h b/SecuritySNACCRuntime/compiler/core/lex-stuff.h deleted file mode 100644 index 69f482e5..00000000 --- a/SecuritySNACCRuntime/compiler/core/lex-stuff.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * compiler/core/lex_stuff.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/lex-stuff.h,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: lex-stuff.h,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:49 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 19:41:31 rj - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:48:45 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 01:16:07 rj - * decide upon type of yytext thru cxx macro provided by autoconf. - * - * Revision 1.1 1994/08/28 09:49:13 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -extern unsigned long myLineNoG; - -#ifdef YYTEXT_POINTER -extern char *yytext; -#else -extern char yytext[]; -#endif - -extern FILE *yyin; - -int LexBeginIntialContext(); -int LexBeginMacroDefContext(); -int LexBeginBraceBalContext(); -int LexBeginCommentContext(); - - -#define COUNT_NEWLINES( cumulativeTotal, nullTermStr)\ -{\ - int cnlStrIndex;\ - for (cnlStrIndex = 0; nullTermStr[cnlStrIndex] != '\0'; cnlStrIndex++)\ - if (nullTermStr[cnlStrIndex] == '\n')\ - cumulativeTotal++;\ -} diff --git a/SecuritySNACCRuntime/compiler/core/lib-types.c b/SecuritySNACCRuntime/compiler/core/lib-types.c deleted file mode 100644 index bf47db42..00000000 --- a/SecuritySNACCRuntime/compiler/core/lib-types.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * compiler/core/lib_types.c - tag form/code and any refs info - * - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/lib-types.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: lib-types.c,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:49 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:33 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:37:51 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:14 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include "asn-incl.h" -#include "asn1module.h" /* for BASICTYPE_... choice ids */ -#include "lib-types.h" - -/* - * Warning: this table must be in order of ascending - * BASICTYPE ids such that - * libTypesG[BASICTYPE_X].typeId == BASICTYPE_X - * is alwas true - */ -LibType libTypesG[ BASICTYPE_MACRODEF + 1] = -{ - { BASICTYPE_UNKNOWN, NO_TAG_CODE, NULL_FORM, NULL }, - { BASICTYPE_BOOLEAN, BOOLEAN_TAG_CODE, PRIM, NULL }, - { BASICTYPE_INTEGER, INTEGER_TAG_CODE, PRIM, NULL }, - { BASICTYPE_BITSTRING, BITSTRING_TAG_CODE, ANY_FORM, NULL }, - { BASICTYPE_OCTETSTRING, OCTETSTRING_TAG_CODE, ANY_FORM, NULL }, - { BASICTYPE_NULL, NULLTYPE_TAG_CODE, PRIM, NULL }, - { BASICTYPE_OID, OID_TAG_CODE, PRIM, NULL }, - { BASICTYPE_REAL, REAL_TAG_CODE, PRIM, NULL }, - { BASICTYPE_ENUMERATED, ENUM_TAG_CODE, PRIM, NULL }, - { BASICTYPE_SEQUENCE, SEQ_TAG_CODE, CONS, NULL }, - { BASICTYPE_SEQUENCEOF, SEQ_TAG_CODE, CONS, NULL }, - { BASICTYPE_SET, SET_TAG_CODE, CONS, NULL }, - { BASICTYPE_SETOF, SET_TAG_CODE, CONS, NULL }, - { BASICTYPE_CHOICE, NO_TAG_CODE, CONS, NULL }, - { BASICTYPE_SELECTION, NO_TAG_CODE, NULL_FORM, NULL }, - { BASICTYPE_COMPONENTSOF, NO_TAG_CODE, CONS, NULL }, - { BASICTYPE_ANY, NO_TAG_CODE, CONS, NULL }, - { BASICTYPE_ANYDEFINEDBY, NO_TAG_CODE, CONS, NULL }, - { BASICTYPE_LOCALTYPEREF, NO_TAG_CODE, NULL_FORM, NULL }, - { BASICTYPE_IMPORTTYPEREF, NO_TAG_CODE, NULL_FORM, NULL }, - { BASICTYPE_MACROTYPE, NO_TAG_CODE, NULL_FORM, NULL }, - { BASICTYPE_MACRODEF, NO_TAG_CODE, NULL_FORM, NULL } -}; diff --git a/SecuritySNACCRuntime/compiler/core/lib-types.h b/SecuritySNACCRuntime/compiler/core/lib-types.h deleted file mode 100644 index d3bf263c..00000000 --- a/SecuritySNACCRuntime/compiler/core/lib-types.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * compiler/core/lib_types.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/lib-types.h,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: lib-types.h,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:49 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:34 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:46 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:15 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -typedef struct LibType -{ - enum BasicTypeChoiceId typeId; - BER_UNIV_CODE univTagCode; - BER_FORM tagForm; - AnyRefList *anyRefs; /* these may be filled in do_macros.c*/ -} LibType; - - -extern LibType libTypesG[]; - -#define LIBTYPE_GET_UNIV_TAG_CODE( tId) (libTypesG[tId].univTagCode) -#define LIBTYPE_GET_TAG_FORM( tId) (libTypesG[tId].tagForm) -#define LIBTYPE_GET_ANY_REFS( tId) (libTypesG[tId].anyRefs) -#define LIBTYPE_GET_ANY_REFS_HNDL( tId) (&libTypesG[tId].anyRefs) -#define LIBTYPE_GET_ANY_REFS( tId) (libTypesG[tId].anyRefs) diff --git a/SecuritySNACCRuntime/compiler/core/link-types.c b/SecuritySNACCRuntime/compiler/core/link-types.c deleted file mode 100644 index 25919436..00000000 --- a/SecuritySNACCRuntime/compiler/core/link-types.c +++ /dev/null @@ -1,1273 +0,0 @@ -/* - * compiler/core/link_types.c - * - * Links type references. Also increments 'refCount' in a TypeDef - * - * Does type checking when linking SELECTION and COMPONENTS OF types - * - * MS - * 91/09/04 - * Completely Rewritten for new ModuleList data structure (ASN.1 based) - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/link-types.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: link-types.c,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:49 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:36 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:38:30 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:17 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "snacc-util.h" -#include "link-types.h" - -extern Module *usefulTypeModG; - -/* non-exported prototypes */ - -void TypeLinkImportLists PROTO ((ModuleList *m)); - -void TypeLinkTypeDef PROTO ((ModuleList *m, Module *currMod, TypeDef *head)); - -void TypeLinkElmtTypes PROTO ((ModuleList *m, Module *currMod, TypeDef *head, NamedTypeList *e)); - -void TypeLinkElmtType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, NamedType *n)); - -void TypeLinkType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *currType)); - -void TypeLinkBasicType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *type, BasicType *bt)); - -void TypeLinkSubtypes PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *currType, Subtype *s)); - -void TypeLinkSubtypeValue PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *currType, SubtypeValue *s)); - -void TypeLinkNamedElmts PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, ValueDefList *v)); - - - -void TypeLinkValueDef PROTO ((ModuleList *m, Module *currMod, ValueDef *v)); - - -void TypeLinkValue PROTO ((ModuleList *m, Module *currMod, ValueDef *head, Type *valuesType, Value *v)); - -void TypeLinkRosOperationMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosOperationMacroType *op)); - - -void TypeLinkRosErrorMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosErrorMacroType *err)); - - -void TypeLinkRosBindMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosBindMacroType *bind)); - - -void TypeLinkRosAseMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosAseMacroType *ase)); - -void TypeLinkRosAcMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosAcMacroType *ac)); - -void TypeLinkMtsasExtensionsMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionsMacroType *exts)); - -void TypeLinkMtsasExtensionMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionMacroType *ext)); - -void TypeLinkMtsasExtensionAttributeMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionAttributeMacroType *ext)); - -void TypeLinkMtsasTokenMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasTokenMacroType *tok)); - -void TypeLinkMtsasTokenDataMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasTokenDataMacroType *tok)); - -void TypeLinkMtsasSecurityCategoryMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasSecurityCategoryMacroType *sec)); - -void TypeLinkAsnObjectMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, AsnObjectMacroType *obj)); - -void TypeLinkAsnPortMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, AsnPortMacroType *p)); - -void TypeLinkAsnAbstractBindMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, AsnAbstractBindMacroType *bind)); - -void TypeLinkSnmpObjectTypeMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, SnmpObjectTypeMacroType *ot)); - - -/* end of prototypes */ - - - - -static char *asn1SrcFileNameG; - -/* - * returns 0 if no link error occured, - * otherwise returns a value < 0. - * Processing should not continue if an error is returned - */ -int -LinkTypeRefs PARAMS ((m), - ModuleList *m) -{ - Module *currMod; - TypeDef *td; - ValueDef *vd; - int linkErr = 0; - - /* - * link imported types/values to their definition if - * the defining module is in the modulelist - */ - TypeLinkImportLists (m); - - - /* link useful types */ - if (usefulTypeModG != NULL) - { - FOR_EACH_LIST_ELMT (td, usefulTypeModG->typeDefs) - { - TypeLinkTypeDef (m, usefulTypeModG, td); - } - - FOR_EACH_LIST_ELMT (vd, usefulTypeModG->valueDefs) - { - TypeLinkValueDef (m, usefulTypeModG, vd); - } - - if (usefulTypeModG->status != MOD_ERROR) - usefulTypeModG->status = MOD_OK; - else - linkErr = -1; - } - - /* - * go through types, values & macros of each module - */ - FOR_EACH_LIST_ELMT (currMod, m) - { - asn1SrcFileNameG = currMod->asn1SrcFileName; - - /* - * go through each type in typeList and link as nec - */ - FOR_EACH_LIST_ELMT (td, currMod->typeDefs) - { - TypeLinkTypeDef (m, currMod, td); - } - - - /* - * go through each value in valueList and link as nec - */ - FOR_EACH_LIST_ELMT (vd, currMod->valueDefs) - { - TypeLinkValueDef (m, currMod, vd); - } - - if (currMod->status != MOD_ERROR) - currMod->status = MOD_OK; - else - linkErr = -1; - } - - return linkErr; - -} /* LinkRefs */ - - -/* - * goes through import lists of each module making sure each - * imported type is in the referenced module. Will flag - * errors if the imported type cannot be found or is not - * exported by the referenced module. - */ -void -TypeLinkImportLists PARAMS ((m), - ModuleList *m) -{ - Module *currMod; - TypeDef *t; - ValueDef *v; - ImportModule *currImpList; - ImportElmt *currImpElmt; - Module *impRefMod; - - - /* Link each modules imports */ - FOR_EACH_LIST_ELMT (currMod, m) - { - /* - * Link each import list in the currMod. - * (there is an import list for every module - * imported from by this module - */ - FOR_EACH_LIST_ELMT (currImpList, currMod->imports) - { - /* lookup ref'd module by it's name and oid (if any) */ - impRefMod = LookupModule (m, currImpList->modId->name, currImpList->modId->oid); - - if (impRefMod == NULL) - { - /* - * The needed module is not available. - * Let user know and set fatal error - */ - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, currImpList->lineNo); - fprintf (stderr,"ERROR - cannot locate IMPORT module \"%s\", ", currImpList->modId->name); - - fprintf (stderr,"so the following types/values are missing:\n"); - FOR_EACH_LIST_ELMT (currImpElmt, currImpList->importElmts) - { - fprintf (stderr," "); /* indent */ - if (currImpElmt->privateScope) - fprintf (stderr,"%s.", currImpList->modId->name); - fprintf (stderr,"%s\n", currImpElmt->name); - } - fprintf (stderr,"\n"); - /* - * go onto next import list in this module - * to report more errors if any - */ - continue; - } - - /* - * go through each import elements and look for the - * the referenced type in the ref'd module - */ - FOR_EACH_LIST_ELMT (currImpElmt, currImpList->importElmts) - { - /* - * only do types (types have uppercase first letter) - */ - if (!isupper (currImpElmt->name[0])) - continue; - - /* look for the type in the ref'd module */ - t = LookupType (impRefMod->typeDefs, currImpElmt->name); - - if (t != NULL) - { - if (!t->exported) - { - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, currImpElmt->lineNo); - fprintf (stderr,"ERROR - \"%s\" module imports \"%s\", which is not exported from module \"%s\".\n", currMod->modId->name, currImpElmt->name, impRefMod->modId->name); - } - - /* set as ref'd if imported by someone */ - t->importRefCount++; - currImpElmt->resolvedRef = - (ImportElmtChoice*)Malloc (sizeof (ImportElmtChoice)); - currImpElmt->resolvedRef->choiceId = IMPORTELMTCHOICE_TYPE; - currImpElmt->resolvedRef->a.type = t; - - } - else /* type not found in ref'd module */ - { - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, currImpElmt->lineNo); - fprintf (stderr,"ERROR - \"%s\" is imported from module \"%s\" by module \"%s\", but is not defined in the referenced module\n", currImpElmt->name, impRefMod->modId->name, currMod->modId->name); - } - - } - } - } -} /* TypeLinkImportLists */ - - -/* - * given a type def, it goes through the entire typedef - * (aggregate parts if any) and links refs - */ -void -TypeLinkTypeDef PARAMS ((m, currMod, head), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head) -{ - if (head == NULL) - return; - - TypeLinkType (m, currMod, head, head->type); -} /* LinkTypeDef */ - - -/* - * given a type t, this routine goes through the components of - * the type and links any type references - */ -void -TypeLinkType PARAMS ((m, currMod, head, t), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t) -{ - if (t == NULL) - return; - - /* like main type information */ - TypeLinkBasicType (m, currMod, head, t, t->basicType); - - /* link any type references in the subtypes (if any)*/ - TypeLinkSubtypes (m, currMod, head, t, t->subtypes); - - /* like type refs in the default value (if any) */ - if (t->defaultVal != NULL) - TypeLinkValue (m, currMod, NULL, t, t->defaultVal->value); - -} /* TypeLinkType */ - - -/* - * given a sequence of NamedTypes (components of a SET, SEQ or - * CHOICE etc), this links any type refs in each one. - */ -void -TypeLinkElmtTypes PARAMS ((m, currMod, head, e), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - NamedTypeList *e) -{ - NamedType *n; - FOR_EACH_LIST_ELMT (n, e) - { - TypeLinkElmtType (m, currMod, head, n); - } -} /* TypeLinkElmtTypes */ - - -void -TypeLinkElmtType PARAMS ((m, currMod, head, n), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - NamedType *n) -{ - if (n != NULL) - TypeLinkType (m, currMod, head, n->type); -} - -/* - * given a BasicType, this links any type refs that are - * part of it. - */ -void -TypeLinkBasicType PARAMS ((m, currMod, head, type, bt), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *type _AND_ - BasicType *bt) -{ - TypeDef *tmpTypeDef; - TypeDefList *tmpTypeDefs; - Type *tmpType; - Module *tmpMod; - NamedType *tmpElmtType; - ImportElmt *impElmt; - ImportModule *impMod; - int implicitRef; - - if (bt == NULL) - return; - - switch (bt->choiceId) - { - - case BASICTYPE_SEQUENCE: - case BASICTYPE_SET: - case BASICTYPE_CHOICE: - TypeLinkElmtTypes (m, currMod, head, bt->a.set); - break; - - case BASICTYPE_SEQUENCEOF: - case BASICTYPE_SETOF: - TypeLinkType (m, currMod, head, bt->a.setOf); - break; - - case BASICTYPE_SELECTION: - TypeLinkType (m, currMod, head, bt->a.selection->typeRef); - - /* - * check that elmt type is CHOICE - * and set up link (if resolved) - */ - tmpType = bt->a.selection->typeRef; - if ((tmpType->basicType->choiceId == BASICTYPE_IMPORTTYPEREF) || - (tmpType->basicType->choiceId == BASICTYPE_LOCALTYPEREF)) - { - tmpTypeDef = tmpType->basicType->a.importTypeRef->link; - if (tmpTypeDef == NULL) /* unlinked import or local type */ - { - currMod->status = MOD_ERROR; - return; - } - } - else - { - PrintErrLoc (currMod->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - selection type defines type instead of referencing CHOICE field.\n"); - currMod->status = MOD_ERROR; - return; - } - - /* - * selections types must reference choice types - */ - tmpType = ParanoidGetType (tmpTypeDef->type); - if (tmpType->basicType->choiceId != BASICTYPE_CHOICE) - { - PrintErrLoc (currMod->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - SELECTION types must reference a CHOICE type\n"); - currMod->status = MOD_ERROR; - return; - } - - /* - * find field ref'd by selection - */ - tmpElmtType = LookupFieldInType (tmpTypeDef->type, bt->a.selection->fieldName); - if (tmpElmtType == NULL) - { - PrintErrLoc (currMod->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - selection type's reference field name \"%s\" is not in CHOICE \"%s\".\n", bt->a.selection->fieldName, tmpTypeDef->definedName); - currMod->status = MOD_ERROR; - return; - } - - bt->a.selection->link = tmpElmtType; - break; - - - case BASICTYPE_COMPONENTSOF: - TypeLinkType (m, currMod, head, bt->a.componentsOf); - /* error checks done in normalize.c */ - break; - - - case BASICTYPE_ANYDEFINEDBY: - /* - * set the link to the defining field if not already linked - */ - if (bt->a.anyDefinedBy->link == NULL) - { - /* - * get set or seq that holds this any def'd by - */ - tmpType = GetParent (head->type, type); - - if (tmpType == NULL) - { - PrintErrLoc (currMod->asn1SrcFileName, type->lineNo); - fprintf (stderr," ERROR - could not find parent type for linking ANY DEFINED BY\n"); - } - - /* - * find "defining" field - */ - tmpElmtType = LookupFieldInType (tmpType, bt->a.anyDefinedBy->fieldName); - - if (tmpElmtType == NULL) - { - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, type->lineNo); - fprintf (stderr," ERROR - could not find identifier field \"%s\" in type \"%s\" for linking ANY DEFINED BY\n", bt->a.anyDefinedBy->fieldName, head->definedName); - } - - bt->a.anyDefinedBy->link = tmpElmtType; - } - break; - - - case BASICTYPE_LOCALTYPEREF: - /* - * Remember: the parser sets any typeref it encounters - * to LOCALTYPE_REF, so some Localtyperefs may be import - * type refs. - */ - /* - * First, look in this module's type defs and create a - * resolvedLocalTypeRef if it's there. - */ - if ((tmpTypeDef = LookupType (currMod->typeDefs, bt->a.localTypeRef->typeName)) != NULL) - { - /* - * locally defined type - */ - tmpTypeDef->localRefCount++; - - bt->a.localTypeRef->link = tmpTypeDef; - bt->a.localTypeRef->module = currMod; - break; /* finished here */ - } - else /* not locally defined type */ - bt->choiceId = BASICTYPE_IMPORTTYPEREF; - /* !!!!!! fall through !!!!!!!! */ - - case BASICTYPE_IMPORTTYPEREF: - - /* This handles "modname.type" type refs. */ - if (bt->a.importTypeRef->moduleName != NULL) - { - /* - * Lookup the import list maintained in this module - * from the named module. (the parser generates - * an import list from Foo module for "Foo.Bar" style - * import refs) - */ - impMod = LookupImportModule (currMod, bt->a.importTypeRef->moduleName); - - if (impMod == NULL) /* whoa, compiler error */ - { - currMod->status = MOD_ERROR; - fprintf (stderr,"Compiler Error: \"%s.%s\" typeref - no import list defined from module \"%s\"\n", bt->a.importTypeRef->moduleName, bt->a.importTypeRef->typeName, bt->a.importTypeRef->moduleName); - - return; - } - impElmt = LookupImportElmtInImportElmtList (impMod->importElmts, bt->a.importTypeRef->typeName); - - if (impElmt == NULL) /* whoa, compiler error again */ - { - currMod->status = MOD_ERROR; - fprintf (stderr,"Compiler Error: \"%s.%s\" typeref - no import element defined for type \"%s\"\n", bt->a.importTypeRef->moduleName, bt->a.importTypeRef->typeName, bt->a.importTypeRef->typeName); - - return; - } - /* - * should already be resolved unless could not find - * the import for some reason - */ - if (impElmt->resolvedRef != NULL) - { - if (impElmt->resolvedRef->choiceId != IMPORTELMTCHOICE_TYPE) - fprintf (stderr,"Linker Warning: import TYPE ref \"%s\" resolves with an imported VALUE\n", impElmt->name); - - bt->a.importTypeRef->link = impElmt->resolvedRef->a.type; - bt->a.importTypeRef->link->importRefCount++; - bt->a.importTypeRef->module = impMod->moduleRef; - } - else - { - /* print loc of refs to unresolved imports */ - PrintErrLoc (currMod->asn1SrcFileName, type->lineNo); - fprintf (stderr,"reference to unresolved imported type \"%s\"\n", impElmt->name); - } - - } - else /* not a "modname.type" type ref */ - { - impElmt = LookupImportElmtInModule (currMod, bt->a.importTypeRef->typeName, &impMod); - - /* - * privateScope one's should only resolve with one's - * non-null module names (see last if) (mod.type form) - */ - if ((impElmt != NULL) && (!impElmt->privateScope)) - { - /* - * should already be resolved unless could not find - * the import for some reason - */ - if (impElmt->resolvedRef != NULL) - { - if (impElmt->resolvedRef->choiceId != IMPORTELMTCHOICE_TYPE) - fprintf (stderr,"Linker Warning: import TYPE ref \"%s\" resolves with an imported VALUE\n", impElmt->name); - - bt->a.importTypeRef->link = impElmt->resolvedRef->a.type; - bt->a.importTypeRef->link->importRefCount++; - bt->a.importTypeRef->module = impMod->moduleRef; - } - else - { - /* print loc of refs to unresolved imports */ - PrintErrLoc (currMod->asn1SrcFileName, type->lineNo); - fprintf (stderr,"reference to unresolved imported type \"%s\"\n", impElmt->name); - } - } - /* - * Since not locally defined or imported, - * look in useful types module (if any). - * Useful type references are treated as imported - * type references (from the useful types module) - */ - else if ((usefulTypeModG != NULL) && (tmpTypeDef = LookupType (usefulTypeModG->typeDefs, bt->a.localTypeRef->typeName)) != NULL) - { - bt->a.importTypeRef->link = tmpTypeDef; - bt->a.importTypeRef->module = usefulTypeModG; - } - else /* impElmt == NULL */ - { - /* - * Type not defined locally, imported or - * in useful types module. - */ - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - type \"%s\" is referenced but not defined or imported.\n", bt->a.importTypeRef->typeName); - } - } - break; - - - /* - * these types may optionally have named elmts - */ - case BASICTYPE_INTEGER: - case BASICTYPE_BITSTRING: - case BASICTYPE_ENUMERATED: - TypeLinkNamedElmts (m, currMod, head, type, bt->a.integer); - break; - - - /* - * these types have no extra info and cause no linking action - */ - case BASICTYPE_UNKNOWN: - case BASICTYPE_BOOLEAN: - case BASICTYPE_OCTETSTRING: - case BASICTYPE_NULL: - case BASICTYPE_OID: - case BASICTYPE_REAL: - case BASICTYPE_ANY: - case BASICTYPE_MACRODEF: - break; - - case BASICTYPE_MACROTYPE: - switch (bt->a.macroType->choiceId) - { - case MACROTYPE_ROSOPERATION: - case MACROTYPE_ASNABSTRACTOPERATION: - TypeLinkRosOperationMacroType (m, currMod, head, type, bt, bt->a.macroType->a.rosOperation); - break; - - case MACROTYPE_ROSERROR: - case MACROTYPE_ASNABSTRACTERROR: - TypeLinkRosErrorMacroType (m, currMod, head, type, bt, bt->a.macroType->a.rosError); - break; - - case MACROTYPE_ROSBIND: - case MACROTYPE_ROSUNBIND: - TypeLinkRosBindMacroType (m, currMod, head, type, bt, bt->a.macroType->a.rosBind); - break; - - case MACROTYPE_ROSASE: - TypeLinkRosAseMacroType (m, currMod, head, type, bt, bt->a.macroType->a.rosAse); - break; - - case MACROTYPE_MTSASEXTENSIONS: - TypeLinkMtsasExtensionsMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasExtensions); - break; - - case MACROTYPE_MTSASEXTENSION: - TypeLinkMtsasExtensionMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasExtension); - break; - - case MACROTYPE_MTSASEXTENSIONATTRIBUTE: - TypeLinkMtsasExtensionAttributeMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasExtensionAttribute); - break; - - case MACROTYPE_MTSASTOKEN: - TypeLinkMtsasTokenMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasToken); - break; - - case MACROTYPE_MTSASTOKENDATA: - TypeLinkMtsasTokenDataMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasTokenData); - break; - - case MACROTYPE_MTSASSECURITYCATEGORY: - TypeLinkMtsasSecurityCategoryMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasSecurityCategory); - break; - - case MACROTYPE_ASNOBJECT: - TypeLinkAsnObjectMacroType (m, currMod, head, type, bt, bt->a.macroType->a.asnObject); - break; - - case MACROTYPE_ASNPORT: - TypeLinkAsnPortMacroType (m, currMod, head, type, bt, bt->a.macroType->a.asnPort); - break; - - case MACROTYPE_ASNABSTRACTBIND: - case MACROTYPE_ASNABSTRACTUNBIND: - TypeLinkAsnAbstractBindMacroType (m, currMod, head, type, bt, bt->a.macroType->a.asnAbstractBind); - break; - - case MACROTYPE_AFALGORITHM: - case MACROTYPE_AFENCRYPTED: - case MACROTYPE_AFPROTECTED: - case MACROTYPE_AFSIGNATURE: - case MACROTYPE_AFSIGNED: - TypeLinkType (m, currMod, head, bt->a.macroType->a.afAlgorithm); - break; - - case MACROTYPE_SNMPOBJECTTYPE: - TypeLinkSnmpObjectTypeMacroType (m, currMod, head, type, bt, bt->a.macroType->a.snmpObjectType); - break; - - default: - fprintf (stderr, "TypeLinkBasicType: ERROR - unknown macro type id!\n"); - } - break; - - default: - fprintf (stderr, "TypeLinkBasicType: ERROR - unknown basic type id!\n"); - } - -} /* LinkBasicType */ - - - - -/* - * resolve any type/value refs in the subtypes (if any) - */ -void -TypeLinkSubtypes PARAMS ((m, currMod, head, currType, s), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *currType _AND_ - Subtype *s) -{ - Subtype *sElmt; - - if (s == NULL) - return; - - switch (s->choiceId) - { - case SUBTYPE_SINGLE: - TypeLinkSubtypeValue (m, currMod, head, currType, s->a.single); - break; - - case SUBTYPE_AND: - case SUBTYPE_OR: - case SUBTYPE_NOT: - FOR_EACH_LIST_ELMT (sElmt, s->a.and) - { - TypeLinkSubtypes (m, currMod, head, currType, sElmt); - } - break; - - default: - fprintf (stderr, "TypeLinkSubtypes: ERROR - unknown Subtype id\n"); - break; - } -} /* TypeLinkSubtypes */ - - - - -/* - * link any type referenced in the value parts of subtypes - */ -void -TypeLinkSubtypeValue PARAMS ((m, currMod, head, currType, s), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *currType _AND_ - SubtypeValue *s) -{ - Constraint *constraint; - - if (s == NULL) - return; - - switch (s->choiceId) - { - case SUBTYPEVALUE_SINGLEVALUE: - TypeLinkValue (m, currMod, NULL, currType, s->a.singleValue); - break; - - case SUBTYPEVALUE_CONTAINED: - TypeLinkType (m, currMod, head, s->a.contained); - break; - - case SUBTYPEVALUE_VALUERANGE: - TypeLinkValue (m, currMod, NULL, currType, s->a.valueRange->lowerEndValue); - TypeLinkValue (m, currMod, NULL, currType, s->a.valueRange->upperEndValue); - break; - - case SUBTYPEVALUE_PERMITTEDALPHABET: - TypeLinkSubtypes (m, currMod, head, currType, s->a.permittedAlphabet); - break; - - case SUBTYPEVALUE_SIZECONSTRAINT: - TypeLinkSubtypes (m, currMod, head, currType, s->a.sizeConstraint); - break; - - case SUBTYPEVALUE_INNERSUBTYPE: - FOR_EACH_LIST_ELMT (constraint, s->a.innerSubtype->constraints) - { - TypeLinkSubtypes (m, currMod, head, currType, constraint->valueConstraints); - } - break; - - default: - fprintf (stderr,"TypeLinkSubtype: ERROR - unknown subtype choiceId\n"); - } - -} /* TypeLinkSubtype */ - - - -/* - * go through named elements of INTEGER/ENUMERATED/BOOLEAN - * and link any type refs in the values - */ -void -TypeLinkNamedElmts PARAMS ((m, currMod, head, t, v), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - ValueDefList *v) -{ - ValueDef *vd; - FOR_EACH_LIST_ELMT (vd, v) - { - TypeLinkValue (m, currMod, vd, vd->value->type, vd->value); - } - -} /* TypeLinkNamedElmts */ - - - -/* - * only use this for 'real' value defs - * ie those in the value def list - not ones for namedElmts - * since infinitite recursion can result from the - * attempt to link the values type which will try to link - * this value again. -*/ -void -TypeLinkValueDef PARAMS ((m, currMod, v), - ModuleList *m _AND_ - Module *currMod _AND_ - ValueDef *v) -{ - if (v == NULL) - return; - - TypeLinkType (m, currMod, NULL, v->value->type); - - if ((v->value->valueType == BASICTYPE_UNKNOWN) && - (v->value->type != NULL)) - v->value->valueType = v->value->type->basicType->choiceId; - -} /* TypeLinkValueDef */ - - - -/* - * link any type refs associated with the given value. - * also sets the values type field with the given - * 'valuesType' Type. - */ -void -TypeLinkValue PARAMS ((m, currMod, head, valuesType, v), - ModuleList *m _AND_ - Module *currMod _AND_ - ValueDef *head _AND_ - Type *valuesType _AND_ - Value *v) -{ - - if (v == NULL) - return; - - v->type = valuesType; -/* TypeLinkType (m, currMod, NULL, v->typeRef); */ - - if ((v->valueType == BASICTYPE_UNKNOWN) && (valuesType != NULL)) - v->valueType = valuesType->basicType->choiceId; - -} /* TypeLinkValue */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkRosOperationMacroType PARAMS ((m, currMod, head, t, bt, op), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosOperationMacroType *op) -{ - TypeOrValue *tOrV; - - if (op->arguments != NULL) - TypeLinkType (m, currMod, head, op->arguments->type); - - if (op->result != NULL) - TypeLinkType (m, currMod, head, op->result->type); - - /* - * go through errors (if any) and link types/values - */ - FOR_EACH_LIST_ELMT (tOrV, op->errors) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - TypeLinkType (m, currMod, head, tOrV->a.type); - else - TypeLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - - /* - * go through linked operations (if any) and - * link types/values - */ - FOR_EACH_LIST_ELMT (tOrV, op->linkedOps) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - TypeLinkType (m, currMod, head, tOrV->a.type); - else - TypeLinkValue (m, currMod, NULL, t, tOrV->a.value); - } -} /* TypeLinkRosOperationMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkRosErrorMacroType PARAMS ((m, currMod, head, t, bt, err), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosErrorMacroType *err) -{ - if ((err != NULL) && (err->parameter != NULL)) - { - TypeLinkType (m, currMod, head, err->parameter->type); - } -} /* TypeLinkRosErrorMacroType */ - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkRosBindMacroType PARAMS ((m, currMod, head, t, bt, bind), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosBindMacroType *bind) -{ - if (bind != NULL) - { - TypeLinkElmtType (m, currMod, head, bind->argument); - TypeLinkElmtType (m, currMod, head, bind->result); - TypeLinkElmtType (m, currMod, head, bind->error); - } -} /* TypeLinkRosBindMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkRosAseMacroType PARAMS ((m, currMod, head, t, bt, ase), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAseMacroType *ase) -{ - Value *v; - - FOR_EACH_LIST_ELMT (v, ase->operations) - TypeLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (v, ase->consumerInvokes) - TypeLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (v, ase->supplierInvokes) - TypeLinkValue (m, currMod, NULL, t, v); - -} /* TypeLinkRosAseMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkRosAcMacroType PARAMS ((m, currMod, head, t, bt, ac), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAcMacroType *ac) -{ - Value *v; - OID *oid; - - FOR_EACH_LIST_ELMT (v, ac->nonRoElements) - TypeLinkValue (m, currMod, NULL, t, v); - - - TypeLinkType (m, currMod, head, ac->bindMacroType); - TypeLinkType (m, currMod, head, ac->unbindMacroType); - - FOR_EACH_LIST_ELMT (v, ac->operationsOf) - TypeLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (v, ac->initiatorConsumerOf) - TypeLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (v, ac->responderConsumerOf) - TypeLinkValue (m, currMod, NULL, t, v); - -} /* TypeLinkRosAcMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkMtsasExtensionsMacroType PARAMS ((m, currMod, head, t, bt, exts), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionsMacroType *exts) -{ - Value *v; - - FOR_EACH_LIST_ELMT (v, exts->extensions) - TypeLinkValue (m, currMod, NULL, t, v); - -} /* TypeLinkMtsasExtensionsMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkMtsasExtensionMacroType PARAMS ((m, currMod, head, t, bt, ext), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionMacroType *ext) -{ - TypeLinkElmtType (m, currMod, head, ext->elmtType); - TypeLinkValue (m, currMod, NULL, t, ext->defaultValue); - -} /* TypeLinkMtsasExtensionMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkMtsasExtensionAttributeMacroType PARAMS ((m, currMod, head, t, bt, ext), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionAttributeMacroType *ext) -{ - - if (ext != NULL) - TypeLinkType (m, currMod, head, ext->type); - -} /* TypeLinkMtsasExtensionAttributeMacroType */ - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkMtsasTokenMacroType PARAMS ((m, currMod, head, t, bt, tok), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenMacroType *tok) -{ - if (tok != NULL) - TypeLinkType (m, currMod, head, tok->type); - -} /* TypeLinkMtsasTokenMacroType */ - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkMtsasTokenDataMacroType PARAMS ((m, currMod, head, t, bt, tok), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenDataMacroType *tok) -{ - if (tok != NULL) - TypeLinkType (m, currMod, head, tok->type); - -} /* TypeLinkMtsasTokenDataMacroType */ - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkMtsasSecurityCategoryMacroType PARAMS ((m, currMod, head, t, bt, sec), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasSecurityCategoryMacroType *sec) -{ - - if (sec != NULL) - TypeLinkType (m, currMod, head, sec->type); - -} /* TypeLinkMtsasSecurityCategoryMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkAsnObjectMacroType PARAMS ((m, currMod, head, t, bt, obj), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnObjectMacroType *obj) -{ - AsnPort *ap; - - FOR_EACH_LIST_ELMT (ap, obj->ports) - TypeLinkValue (m, currMod, NULL, t, ap->portValue); - -} /* TypeLinkAsnObjectMacroType */ - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkAsnPortMacroType PARAMS ((m, currMod, head, t, bt, p), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnPortMacroType *p) -{ - TypeOrValue *tOrV; - - FOR_EACH_LIST_ELMT (tOrV, p->abstractOps) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - TypeLinkType (m, currMod, head, tOrV->a.type); - else - TypeLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - - - FOR_EACH_LIST_ELMT (tOrV, p->supplierInvokes) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - TypeLinkType (m, currMod, head, tOrV->a.type); - else - TypeLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - - - FOR_EACH_LIST_ELMT (tOrV, p->consumerInvokes) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - TypeLinkType (m, currMod, head, tOrV->a.type); - else - TypeLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - -} /* TypeLinkAsnPortMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkAsnAbstractBindMacroType PARAMS ((m, currMod, head, t, bt, bind), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnAbstractBindMacroType *bind) -{ - AsnPort *ap; - - FOR_EACH_LIST_ELMT (ap, bind->ports) - TypeLinkValue (m, currMod, NULL, t, ap->portValue); - -} /* TypeLinkAsnBindMacroType */ - - -/* - * link any type refs in this macro's parsed data struct - */ -void -TypeLinkSnmpObjectTypeMacroType PARAMS ((m, currMod, head, t, bt, ot), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - SnmpObjectTypeMacroType *ot) -{ - TypeOrValue *tOrV; - - TypeLinkType (m, currMod, head, ot->syntax); - TypeLinkValue (m, currMod, NULL, t, ot->description); - TypeLinkValue (m, currMod, NULL, t, ot->reference); - TypeLinkValue (m, currMod, NULL, t, ot->defVal); - - FOR_EACH_LIST_ELMT (tOrV, ot->index) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - TypeLinkType (m, currMod, head, tOrV->a.type); - else - TypeLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - -} /* TypeLinkSnmpObjectTypeMacroType */ diff --git a/SecuritySNACCRuntime/compiler/core/link-types.h b/SecuritySNACCRuntime/compiler/core/link-types.h deleted file mode 100644 index 79cb04a7..00000000 --- a/SecuritySNACCRuntime/compiler/core/link-types.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * compiler/core/link.h - * - * links type references - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/link-types.h,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: link-types.h,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:49 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:37 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:47 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:18 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -int LinkTypeRefs PROTO ((ModuleList *m)); diff --git a/SecuritySNACCRuntime/compiler/core/link-values.c b/SecuritySNACCRuntime/compiler/core/link-values.c deleted file mode 100644 index 68ae973b..00000000 --- a/SecuritySNACCRuntime/compiler/core/link-values.c +++ /dev/null @@ -1,1266 +0,0 @@ -/* - * compiler/core/link.c - * - * first links value refs in the import list then - * links value references in value defs and types' default values - * - * - * Mike Sample - * 91/09/04 - * Completely Rewritten for new ModuleList data structure (ASN.1 based) - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/link-values.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: link-values.c,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:49 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:38 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:38:43 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:19 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "snacc-util.h" -#include "link-values.h" - -extern Module *usefulTypeModG; - -/* non-exported fcn prototypes */ - - -void ValueLinkImportLists PROTO ((ModuleList *m)); - -void ValueLinkTypeDef PROTO ((ModuleList *m, Module *currMod, TypeDef *head)); - -void ValueLinkElmtTypes PROTO ((ModuleList *m, Module *currMod, TypeDef *head, NamedTypeList *e)); - -void ValueLinkElmtType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, NamedType *n)); - -void ValueLinkType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *currType)); - -void ValueLinkBasicType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *type, BasicType *bt)); - -void ValueLinkSubtypes PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *currType, Subtype *s)); - -void ValueLinkSubtypeValue PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *currType, SubtypeValue *s)); - -void ValueLinkNamedElmts PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, ValueDefList *v)); - - -void ValueLinkValueDef PROTO ((ModuleList *m, Module *currMod, ValueDef *v)); - - -void ValueLinkValue PROTO ((ModuleList *m, Module *currMod, ValueDef *head, Type *valuesType, Value *v)); - -void ValueLinkBasicValue PROTO ((ModuleList *m, Module *currMod, ValueDef *head, Type *valuesType, Value *v, BasicValue *bv)); - -void ValueLinkOid PROTO ((ModuleList *m, Module *currMod, ValueDef *head, Value *v, OID *oid)); - -void ValueLinkRosOperationMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosOperationMacroType *op)); - -void ValueLinkRosErrorMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosErrorMacroType *err)); - - -void ValueLinkRosBindMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosBindMacroType *bind)); - -void ValueLinkRosAseMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosAseMacroType *ase)); - -void ValueLinkRosAcMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, RosAcMacroType *ac)); - -void ValueLinkMtsasExtensionsMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionsMacroType *exts)); - -void ValueLinkMtsasExtensionMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionMacroType *ext)); - -void ValueLinkMtsasExtensionAttributeMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionAttributeMacroType *ext)); - -void ValueLinkMtsasTokenMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasTokenMacroType *tok)); - -void ValueLinkMtsasTokenDataMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasTokenDataMacroType *tok)); - -void ValueLinkMtsasSecurityCategoryMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, MtsasSecurityCategoryMacroType *sec)); - -void ValueLinkAsnObjectMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, AsnObjectMacroType *obj)); - -void ValueLinkAsnPortMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, AsnPortMacroType *p)); - -void ValueLinkAsnAbstractBindMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, AsnAbstractBindMacroType *bind)); - -void ValueLinkSnmpObjectTypeMacroType PROTO ((ModuleList *m, Module *currMod, TypeDef *head, Type *t, BasicType *bt, SnmpObjectTypeMacroType *ot)); - - -/* end of prototypes */ - - - - -static char *asn1SrcFileNameG; -static int linkOidCallDepthG = 0; /* big hack!! */ - -/* - * returns 0 if no link error occured - * otherwise returns a value < 0. - * processing should not continue is an error is returned - */ -int -LinkValueRefs PARAMS ((m), - ModuleList *m) -{ - Module *currMod; - TypeDef *td; - ValueDef *vd; - int linkErr = 0; - - /* - * link imported types/values to there definition if - * the defining module is in the modulelist - */ - ValueLinkImportLists (m); - - - /* link useful module, in case there are value defs there */ - if (usefulTypeModG != NULL) - { - currMod = usefulTypeModG; - asn1SrcFileNameG = currMod->asn1SrcFileName; - - /* - * link this modules object identifier value - */ - ValueLinkOid (m, currMod, NULL, NULL, currMod->modId->oid); - - - /* - * go through each type in typeList and link as nec - */ - FOR_EACH_LIST_ELMT (td, currMod->typeDefs) - { - ValueLinkTypeDef (m, currMod, td); - } - - - /* - * go through each value in valueList and link as nec - */ - FOR_EACH_LIST_ELMT (vd, currMod->valueDefs) - { - ValueLinkValueDef (m, currMod, vd); - } - - if (currMod->status != MOD_ERROR) - currMod->status = MOD_OK; - else - linkErr = -1; - } - - /* - * go through types, values & macros of each parsed module - */ - - FOR_EACH_LIST_ELMT (currMod, m) - { - - asn1SrcFileNameG = currMod->asn1SrcFileName; - - /* - * link this modules object identifier value - */ - ValueLinkOid (m, currMod, NULL, NULL, currMod->modId->oid); - - - /* - * go through each type in typeList and link as nec - */ - FOR_EACH_LIST_ELMT (td, currMod->typeDefs) - { - ValueLinkTypeDef (m, currMod, td); - } - - /* - * go through each value in valueList and link as nec - */ - FOR_EACH_LIST_ELMT (vd, currMod->valueDefs) - { - ValueLinkValueDef (m, currMod, vd); - } - - if (currMod->status != MOD_ERROR) - currMod->status = MOD_OK; - else - linkErr = -1; - } - - return linkErr; - -} /* ValueLinkRefs */ - - -/* - * go through each modules import lists and link - * any values as nec. values'symbols start with a - * lowercase letter - */ -void -ValueLinkImportLists PARAMS ((m), - ModuleList *m) -{ - Module *currMod; - TypeDef *t; - ValueDef *v; - ImportModule *currImpList; - ImportElmt *currImpElmt; - Module *impRefMod; - - - /* link imports of each module in the list */ - FOR_EACH_LIST_ELMT (currMod, m) - { - /* for each import list in the current module */ - FOR_EACH_LIST_ELMT (currImpList, currMod->imports) - { - /* see if the referenced module is in the list */ - impRefMod = LookupModule (m, currImpList->modId->name, currImpList->modId->oid); - - if (impRefMod == NULL) - { - /* the type linker will have reported this error */ - continue; - } - - /* - * link each value referencing import elmt in - * the current import list - */ - FOR_EACH_LIST_ELMT (currImpElmt, currImpList->importElmts) - { - /* - * only link values (all vals have lowercase first letter) - */ - if (!islower (currImpElmt->name[0])) - continue; - - v = LookupValue (impRefMod->valueDefs, currImpElmt->name); - if (v != NULL) - { - if (!v->exported) - { - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, currImpElmt->lineNo); - fprintf (stderr,"ERROR - \"%s\" module imports value \"%s\", which is not exported from module \"%s\".\n", currMod->modId->name, currImpElmt->name, impRefMod->modId->name); - } - /* resolve value */ - currImpElmt->resolvedRef = - (ImportElmtChoice*)Malloc (sizeof (ImportElmtChoice)); - currImpElmt->resolvedRef->choiceId = IMPORTELMTCHOICE_VALUE; - currImpElmt->resolvedRef->a.value = v; - } - else /* value not found in ref'd module */ - { - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, currImpElmt->lineNo); - fprintf (stderr,"ERROR - \"%s\" is imported from module \"%s\" by module \"%s\", but is not defined in the referenced module\n", currImpElmt->name, impRefMod->modId->name, currMod->modId->name); - } - - } - } - } -} /* ValueLinkImportLists */ - - - -void -ValueLinkTypeDef PARAMS ((m, currMod, head), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head) -{ - - if (head == NULL) - return; - - ValueLinkType (m, currMod, head, head->type); - -} /* ValueLinkTypeDef */ - - - -void -ValueLinkType PARAMS ((m, currMod, head, t), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t) -{ - - if (t == NULL) - return; - - ValueLinkBasicType (m, currMod, head, t, t->basicType); - - ValueLinkSubtypes (m, currMod, head, t, t->subtypes); - - if (t->defaultVal != NULL) - ValueLinkValue (m, currMod, NULL, t, t->defaultVal->value); - -} /* ValueLinkType */ - - - -void -ValueLinkElmtTypes PARAMS ((m, currMod, head, e), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - NamedTypeList *e) -{ - NamedType *n; - FOR_EACH_LIST_ELMT (n, e) - { - ValueLinkElmtType (m, currMod, head, n); - } -} /* ValueLinkElmtTypes */ - - -void -ValueLinkElmtType PARAMS ((m, currMod, head, n), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - NamedType *n) -{ - if (n != NULL) - ValueLinkType (m, currMod, head, n->type); -} - - -void -ValueLinkBasicType PARAMS ((m, currMod, head, type, bt), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *type _AND_ - BasicType *bt) -{ - TypeDef *tmpTypeDef; - TypeDefList *tmpTypeDefs; - Type *tmpType; - Module *tmpMod; - NamedType *tmpElmtType; - ImportElmt *impElmt; - ImportModule *impMod; - int implicitRef; - - if (bt == NULL) - return; - - switch (bt->choiceId) - { - - case BASICTYPE_SEQUENCE: - case BASICTYPE_SET: - case BASICTYPE_CHOICE: - ValueLinkElmtTypes (m, currMod, head, bt->a.set); - break; - - - - case BASICTYPE_SEQUENCEOF: - case BASICTYPE_SETOF: - ValueLinkType (m, currMod, head, bt->a.setOf); - break; - - - - case BASICTYPE_SELECTION: - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_ANYDEFINEDBY: - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_IMPORTTYPEREF: - break; - - /* - * these types may optionally have named elmts - */ - case BASICTYPE_INTEGER: - case BASICTYPE_BITSTRING: - case BASICTYPE_ENUMERATED: - ValueLinkNamedElmts (m, currMod, head, type, bt->a.integer); - break; - - - - /* - * these types have no extra info and cause no linking action - */ - case BASICTYPE_UNKNOWN: - case BASICTYPE_BOOLEAN: - case BASICTYPE_OCTETSTRING: - case BASICTYPE_NULL: - case BASICTYPE_OID: - case BASICTYPE_REAL: - case BASICTYPE_ANY: - case BASICTYPE_MACRODEF: - /* - * these have no more info - only the choiceId is used - */ - break; - - case BASICTYPE_MACROTYPE: - switch (bt->a.macroType->choiceId) - { - case MACROTYPE_ROSOPERATION: - case MACROTYPE_ASNABSTRACTOPERATION: - - ValueLinkRosOperationMacroType (m, currMod, head, type, bt, bt->a.macroType->a.rosOperation); - break; - - case MACROTYPE_ROSERROR: - case MACROTYPE_ASNABSTRACTERROR: - ValueLinkRosErrorMacroType (m, currMod, head, type, bt, bt->a.macroType->a.rosError); - break; - - case MACROTYPE_ROSBIND: - case MACROTYPE_ROSUNBIND: - ValueLinkRosBindMacroType (m, currMod, head, type, bt, bt->a.macroType->a.rosBind); - break; - - case MACROTYPE_ROSASE: - ValueLinkRosAseMacroType (m, currMod, head, type, bt, bt->a.macroType->a.rosAse); - break; - - case MACROTYPE_MTSASEXTENSIONS: - ValueLinkMtsasExtensionsMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasExtensions); - break; - - case MACROTYPE_MTSASEXTENSION: - ValueLinkMtsasExtensionMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasExtension); - break; - - case MACROTYPE_MTSASEXTENSIONATTRIBUTE: - ValueLinkMtsasExtensionAttributeMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasExtensionAttribute); - break; - - case MACROTYPE_MTSASTOKEN: - ValueLinkMtsasTokenMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasToken); - break; - - case MACROTYPE_MTSASTOKENDATA: - ValueLinkMtsasTokenDataMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasTokenData); - break; - - case MACROTYPE_MTSASSECURITYCATEGORY: - ValueLinkMtsasSecurityCategoryMacroType (m, currMod, head, type, bt, bt->a.macroType->a.mtsasSecurityCategory); - break; - - case MACROTYPE_ASNOBJECT: - ValueLinkAsnObjectMacroType (m, currMod, head, type, bt, bt->a.macroType->a.asnObject); - break; - - case MACROTYPE_ASNPORT: - ValueLinkAsnPortMacroType (m, currMod, head, type, bt, bt->a.macroType->a.asnPort); - break; - - case MACROTYPE_ASNABSTRACTBIND: - case MACROTYPE_ASNABSTRACTUNBIND: - ValueLinkAsnAbstractBindMacroType (m, currMod, head, type, bt, bt->a.macroType->a.asnAbstractBind); - break; - - case MACROTYPE_AFALGORITHM: - case MACROTYPE_AFENCRYPTED: - case MACROTYPE_AFPROTECTED: - case MACROTYPE_AFSIGNATURE: - case MACROTYPE_AFSIGNED: - ValueLinkType (m, currMod, head, bt->a.macroType->a.afAlgorithm); - break; - - case MACROTYPE_SNMPOBJECTTYPE: - ValueLinkSnmpObjectTypeMacroType (m, currMod, head, type, bt, bt->a.macroType->a.snmpObjectType); - break; - - default: - fprintf (stderr, "ValueLinkBasicType: ERROR - unknown macro type id!\n"); - break; - } - break; - - default: - fprintf (stderr, "ValueLinkBasicType: ERROR - unknown basic type id!\n"); - - } -} /* ValueLinkBasicType */ - - - - -/* - * resolve any type/value refs in the subtypes (if any) - */ -void -ValueLinkSubtypes PARAMS ((m, currMod, head, currType, s), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *currType _AND_ - Subtype *s) -{ - Subtype *sElmt; - - if (s == NULL) - return; - - switch (s->choiceId) - { - case SUBTYPE_SINGLE: - ValueLinkSubtypeValue (m, currMod, head, currType, s->a.single); - break; - - case SUBTYPE_AND: - case SUBTYPE_OR: - case SUBTYPE_NOT: - FOR_EACH_LIST_ELMT (sElmt, s->a.and) - { - ValueLinkSubtypes (m, currMod, head, currType, sElmt); - } - break; - - default: - fprintf (stderr, "ValueLinkSubtypes: ERROR - unknown Subtype id\n"); - break; - } -} /* ValueLinkSubtypes */ - - - - - -void -ValueLinkSubtypeValue PARAMS ((m, currMod, head, currType, s), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *currType _AND_ - SubtypeValue *s) -{ - Constraint *constraint; - - if (s == NULL) - return; - - switch (s->choiceId) - { - case SUBTYPEVALUE_SINGLEVALUE: - ValueLinkValue (m, currMod, NULL, currType, s->a.singleValue); - break; - - case SUBTYPEVALUE_CONTAINED: - ValueLinkType (m, currMod, head, s->a.contained); - break; - - case SUBTYPEVALUE_VALUERANGE: - ValueLinkValue (m, currMod, NULL, currType, s->a.valueRange->lowerEndValue); - ValueLinkValue (m, currMod, NULL, currType, s->a.valueRange->upperEndValue); - break; - - case SUBTYPEVALUE_PERMITTEDALPHABET: - ValueLinkSubtypes (m, currMod, head, currType, s->a.permittedAlphabet); - break; - - case SUBTYPEVALUE_SIZECONSTRAINT: - ValueLinkSubtypes (m, currMod, head, currType, s->a.sizeConstraint); - break; - - case SUBTYPEVALUE_INNERSUBTYPE: - FOR_EACH_LIST_ELMT (constraint, s->a.innerSubtype->constraints) - { - ValueLinkSubtypes (m, currMod, head, currType, constraint->valueConstraints); - } - break; - - default: - fprintf (stderr,"ValueLinkSubtype: ERROR - unknown subtype choiceId\n"); - } - -} /* ValueLinkSubtype */ - - - - -void -ValueLinkNamedElmts PARAMS ((m, currMod, head, t, v), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - ValueDefList *v) -{ - ValueDef *vd; - FOR_EACH_LIST_ELMT (vd, v) - { - ValueLinkValue (m, currMod, vd, vd->value->type, vd->value); - } - -} /* ValueLinkNamedElmts */ - - - - -void -ValueLinkValueDef PARAMS ((m, currMod, v), - ModuleList *m _AND_ - Module *currMod _AND_ - ValueDef *v) -{ - if (v == NULL) - return; - - ValueLinkType (m, currMod, NULL, v->value->type); - ValueLinkValue (m, currMod, v, v->value->type, v->value); - -} /* ValueLinkValueDef */ - - - - -void -ValueLinkValue PARAMS ((m, currMod, head, valuesType, v), - ModuleList *m _AND_ - Module *currMod _AND_ - ValueDef *head _AND_ - Type *valuesType _AND_ - Value *v) -{ - - if (v == NULL) - return; - - ValueLinkBasicValue (m, currMod, head, valuesType, v, v->basicValue); - -} /* ValueLinkValue */ - - - -void -ValueLinkBasicValue PARAMS ((m, currMod, head, valuesType, v, bv), - ModuleList *m _AND_ - Module *currMod _AND_ - ValueDef *head _AND_ - Type *valuesType _AND_ - Value *v _AND_ - BasicValue *bv) -{ - ValueDef *tmpValueDef; - Module *tmpMod; - ImportElmt *impElmt; - ImportModule *impMod; - ValueDef *n; - ValueDefList *namedElmtList; - - - if (v == NULL) - return; - - - switch (bv->choiceId) - { - case BASICVALUE_UNKNOWN: - case BASICVALUE_EMPTY: - case BASICVALUE_INTEGER: - case BASICVALUE_SPECIALINTEGER: - case BASICVALUE_BOOLEAN: - case BASICVALUE_REAL: - case BASICVALUE_SPECIALREAL: - case BASICVALUE_ASCIITEXT: - case BASICVALUE_ASCIIHEX: - case BASICVALUE_ASCIIBITSTRING: - case BASICVALUE_BERVALUE: - case BASICVALUE_PERVALUE: - case BASICVALUE_NAMEDVALUE: - case BASICVALUE_NULL: - case BASICVALUE_VALUENOTATION: - case BASICVALUE_OID: - break; - - - case BASICVALUE_LOCALVALUEREF: - - /* - * parser sets all value refs to "Local" so must - * check if local, then if import .... - */ - - /* - * first check in named elmts of the given type - */ - namedElmtList = GetAllNamedElmts (valuesType); - if (namedElmtList != NULL) - { - n = LookupValue (namedElmtList, bv->a.localValueRef->valueName); - - if (n != NULL) - { - bv->a.localValueRef->link = n; - bv->a.localValueRef->module = currMod; - - /* now free list structure (not data elmts) */ - AsnListFree (namedElmtList); - - break; /* exit switch since done here. */ - } - } - - /* - * second, look for values defined in this module - */ - tmpValueDef = LookupValue (currMod->valueDefs, bv->a.localValueRef->valueName); - - if (tmpValueDef != NULL) - { - bv->a.localValueRef->link = tmpValueDef; - break; /* exit switch since done here. */ - } - - else - bv->choiceId = BASICVALUE_IMPORTVALUEREF; - /*!!!!!!!!!! fall through from else clause */ - - - case BASICVALUE_IMPORTVALUEREF: - /* This handles "modname.value" value refs. */ - if (bv->a.importValueRef->moduleName != NULL) - { - /* - * Lookup the import list maintained in this module - * from the named module. (the parser generates - * an import list from Foo module for "Foo.Bar" style - * import refs) - */ - impMod = LookupImportModule (currMod, bv->a.importValueRef->moduleName); - - if (impMod == NULL) /* whoa, compiler error */ - { - currMod->status = MOD_ERROR; - fprintf (stderr,"Compiler Error: \"%s.%s\" valueref - no import list defined from module \"%s\".\n", bv->a.importValueRef->moduleName, bv->a.importValueRef->valueName, bv->a.importValueRef->moduleName); - - return; - } - impElmt = LookupImportElmtInImportElmtList (impMod->importElmts, bv->a.importValueRef->valueName); - - if (impElmt == NULL) /* whoa, compiler error again */ - { - currMod->status = MOD_ERROR; - fprintf (stderr,"Compiler Error: \"%s.%s\" valueref - no import element defined for value \"%s\".\n", bv->a.importValueRef->moduleName, bv->a.importValueRef->valueName, bv->a.importValueRef->valueName); - - - } - else if (impElmt->resolvedRef != NULL) - { - if (impElmt->resolvedRef->choiceId != - IMPORTELMTCHOICE_VALUE) - fprintf (stderr,"Linker Warning: import VALUE ref \"%s\" resolves with an imported TYPE\n", impElmt->name); - - bv->a.importValueRef->link = impElmt->resolvedRef->a.value; - bv->a.importValueRef->module = impMod->moduleRef; - } - else - { - PrintErrLoc (currMod->asn1SrcFileName, v->lineNo); - fprintf (stderr,"reference to unresolved imported value \"%s\"\n", impElmt->name); - } - } - else - { - impElmt = LookupImportElmtInModule (currMod, bv->a.importValueRef->valueName, &impMod); - if ((impElmt != NULL) && (!impElmt->privateScope)) - { - /* - * if import elmt is resolved then - * set up link - */ - - if (impElmt->resolvedRef != NULL) - { - if (impElmt->resolvedRef->choiceId != - IMPORTELMTCHOICE_VALUE) - fprintf (stderr,"Linker Warning: import VALUE ref \"%s\" resolves with an imported TYPE\n", impElmt->name); - - bv->a.importValueRef->link = impElmt->resolvedRef->a.value; - bv->a.importValueRef->module = impMod->moduleRef; - } - else - { - PrintErrLoc (currMod->asn1SrcFileName, v->lineNo); - fprintf (stderr,"reference to unresolved imported value \"%s\"\n", impElmt->name); - } - } - - /* - * third, look for values defined in the useful module - */ - else if ((usefulTypeModG != NULL) && - ((tmpValueDef = LookupValue (usefulTypeModG->valueDefs, bv->a.localValueRef->valueName)) != NULL)) - { - bv->a.localValueRef->link = tmpValueDef; - bv->a.localValueRef->module = usefulTypeModG; - } - else - { - /* - * value not defined locally, nor imported nor - * defined in useful types module - */ - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, v->lineNo); - fprintf (stderr,"ERROR - value \"%s\" is referenced but not defined or imported.\n", bv->a.importValueRef->valueName); - } - } - break; - - case BASICVALUE_LINKEDOID: - ValueLinkOid (m, currMod, head, v, bv->a.linkedOid); - break; - - default: - fprintf (stderr,"ValueLinkBasicValue: ERROR - unknown value type\n"); - } - -} /* ValueLinkBasicValue */ - - -/* - * link the value refs from an object identifier - * - * - * eg - * for { ccitt foo (1) bar bell (bunt) 2 } the format is - * - * ccitt - * arcnum is set to number from oid table (oid.c) - * foo (1) - * - arc num is set to 1 - * - sets up a new value def foo defined as 1 - * - makes oid valueref a value ref to foo (doesn't link it tho) - * bar - * - makes oid valueref a value ref to bar (doesn't link it tho) - * bell (bunt) - * - sets up a new value def bell defined as a val ref to bunt - * - makes oid valueref a value ref to bell (doesn't link it tho) - * 2 - * -arc num is set to 2 - * - */ -void -ValueLinkOid PARAMS ((m, currMod, head, v, oid), - ModuleList *m _AND_ - Module *currMod _AND_ - ValueDef *head _AND_ - Value *v _AND_ - OID *oid) -{ - ValueDef *tmpValueDef; - ImportElmt *impElmt; - ImportModule *impMod; - int lineNo; - OID *firstElmt; - Value *val; - - /* - * WARNING: for cyclic oid value definintions like. - * foo OID ::= { bar 1 3 } - * bar OID ::= { foo 1 3 } - * infinite recursion is prevented by - * a hack (linkOidCallDepth) - */ - if (linkOidCallDepthG > 100) - { - currMod->status = MOD_ERROR; - PrintErrLoc (currMod->asn1SrcFileName, v->lineNo); - fprintf (stderr,"ERROR - OBJECT IDENTIFIER value \"%s\" appears to be defined recursively\n", head->definedName); - linkOidCallDepthG = 0; - return; - } - else - linkOidCallDepthG++; - - for (firstElmt = oid; oid != NULL; oid = oid->next) - { - if (oid->valueRef != NULL) - { - ValueLinkValue (m, currMod, head, NULL, oid->valueRef); - - if ((oid->valueRef->basicValue->choiceId != - BASICVALUE_LOCALVALUEREF) && - (oid->valueRef->basicValue->choiceId != - BASICVALUE_IMPORTVALUEREF)) - { - fprintf (stderr,"Internal error: Oid valueref is not a ref\n"); - break; /* exit for */ - } - - /* - * leave simplification (replacement of value refs with values) - * of oid values to normalize.c - */ - } - } - - linkOidCallDepthG--; - -} /* ValueLinkOid */ - - -void -ValueLinkRosOperationMacroType PARAMS ((m, currMod, head, t, bt, op), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosOperationMacroType *op) -{ - TypeOrValue *tOrV; - - if (op->arguments != NULL) - ValueLinkType (m, currMod, head, op->arguments->type); - - if (op->result != NULL) - ValueLinkType (m, currMod, head, op->result->type); - - /* - * go through errors (if any) and link types/values - */ - FOR_EACH_LIST_ELMT (tOrV, op->errors) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - ValueLinkType (m, currMod, head, tOrV->a.type); - else - ValueLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - - /* - * go through linked operations (if any) and - * link types/values - */ - FOR_EACH_LIST_ELMT (tOrV, op->linkedOps) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - ValueLinkType (m, currMod, head, tOrV->a.type); - else - ValueLinkValue (m, currMod, NULL, t, tOrV->a.value); - } -} /* ValueLinkRosOperationMacroType */ - - -void -ValueLinkRosErrorMacroType PARAMS ((m, currMod, head, t, bt, err), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosErrorMacroType *err) -{ - if ((err != NULL) && (err->parameter != NULL)) - { - ValueLinkType (m, currMod, head, err->parameter->type); - } -} /* ValueLinkRosErrorMacroType */ - - -void -ValueLinkRosBindMacroType PARAMS ((m, currMod, head, t, bt, bind), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosBindMacroType *bind) -{ - if (bind != NULL) - { - ValueLinkElmtType (m, currMod, head, bind->argument); - ValueLinkElmtType (m, currMod, head, bind->result); - ValueLinkElmtType (m, currMod, head, bind->error); - } -} /* ValueLinkRosBindMacroType */ - - -void -ValueLinkRosAseMacroType PARAMS ((m, currMod, head, t, bt, ase), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAseMacroType *ase) -{ - Value *v; - - FOR_EACH_LIST_ELMT (v, ase->operations) - ValueLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (v, ase->consumerInvokes) - ValueLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (v, ase->supplierInvokes) - ValueLinkValue (m, currMod, NULL, t, v); - -} /* ValueLinkRosAseMacroType */ - - - -void -ValueLinkRosAcMacroType PARAMS ((m, currMod, head, t, bt, ac), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAcMacroType *ac) -{ - Value *v; - OID *oid; - - FOR_EACH_LIST_ELMT (v, ac->nonRoElements) - ValueLinkValue (m, currMod, NULL, t, v); - - - ValueLinkType (m, currMod, head, ac->bindMacroType); - ValueLinkType (m, currMod, head, ac->unbindMacroType); - - FOR_EACH_LIST_ELMT (v, ac->operationsOf) - ValueLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (v, ac->initiatorConsumerOf) - ValueLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (v, ac->responderConsumerOf) - ValueLinkValue (m, currMod, NULL, t, v); - - - FOR_EACH_LIST_ELMT (oid, ac->abstractSyntaxes) - ValueLinkOid (m, currMod, NULL, NULL, oid); - -} /* ValueLinkRosAcMacroType */ - - - -void -ValueLinkMtsasExtensionsMacroType PARAMS ((m, currMod, head, t, bt, exts), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionsMacroType *exts) -{ - Value *v; - - FOR_EACH_LIST_ELMT (v, exts->extensions) - ValueLinkValue (m, currMod, NULL, t, v); - -} /* ValueLinkMtsasExtensionsMacroType */ - - -void -ValueLinkMtsasExtensionMacroType PARAMS ((m, currMod, head, t, bt, ext), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionMacroType *ext) -{ - ValueLinkElmtType (m, currMod, head, ext->elmtType); - ValueLinkValue (m, currMod, NULL, t, ext->defaultValue); - -} /* ValueLinkMtsasExtensionMacroType */ - - -void -ValueLinkMtsasExtensionAttributeMacroType PARAMS ((m, currMod, head, t,bt, ext), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionAttributeMacroType *ext) -{ - - if (ext != NULL) - ValueLinkType (m, currMod, head, ext->type); - -} /* ValueLinkMtsasExtensionAttributeMacroType */ - - -void -ValueLinkMtsasTokenMacroType PARAMS ((m, currMod, head, t, bt, tok), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenMacroType *tok) -{ - if (tok != NULL) - ValueLinkType (m, currMod, head, tok->type); - -} /* ValueLinkMtsasTokenMacroType */ - - -void -ValueLinkMtsasTokenDataMacroType PARAMS ((m, currMod, head, t, bt, tok), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenDataMacroType *tok) -{ - if (tok != NULL) - ValueLinkType (m, currMod, head, tok->type); - -} /* ValueLinkMtsasTokenDataMacroType */ - -void -ValueLinkMtsasSecurityCategoryMacroType PARAMS ((m, currMod, head, t, bt, sec), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasSecurityCategoryMacroType *sec) -{ - - if (sec != NULL) - ValueLinkType (m, currMod, head, sec->type); - -} /* ValueLinkMtsasSecurityCategoryMacroType */ - - - -void -ValueLinkAsnObjectMacroType PARAMS ((m, currMod, head, t, bt, obj), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnObjectMacroType *obj) -{ - AsnPort *ap; - - FOR_EACH_LIST_ELMT (ap, obj->ports) - ValueLinkValue (m, currMod, NULL, t, ap->portValue); - -} /* ValueLinkAsnObjectMacroType */ - - -void -ValueLinkAsnPortMacroType PARAMS ((m, currMod, head, t, bt, p), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnPortMacroType *p) -{ - TypeOrValue *tOrV; - - FOR_EACH_LIST_ELMT (tOrV, p->abstractOps) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - ValueLinkType (m, currMod, head, tOrV->a.type); - else - ValueLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - - - FOR_EACH_LIST_ELMT (tOrV, p->supplierInvokes) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - ValueLinkType (m, currMod, head, tOrV->a.type); - else - ValueLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - - - FOR_EACH_LIST_ELMT (tOrV, p->consumerInvokes) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - ValueLinkType (m, currMod, head, tOrV->a.type); - else - ValueLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - -} /* ValueLinkAsnPortMacroType */ - - - -void -ValueLinkAsnAbstractBindMacroType PARAMS ((m, currMod, head, t, bt, bind), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnAbstractBindMacroType *bind) -{ - AsnPort *ap; - - FOR_EACH_LIST_ELMT (ap, bind->ports) - ValueLinkValue (m, currMod, NULL, t, ap->portValue); - -} /* ValueLinkAsnBindMacroType */ - - - -void -ValueLinkSnmpObjectTypeMacroType PARAMS ((m, currMod, head, t, bt, ot), - ModuleList *m _AND_ - Module *currMod _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - SnmpObjectTypeMacroType *ot) -{ - TypeOrValue *tOrV; - - ValueLinkType (m, currMod, head, ot->syntax); - ValueLinkValue (m, currMod, NULL, t, ot->description); - ValueLinkValue (m, currMod, NULL, t, ot->reference); - ValueLinkValue (m, currMod, NULL, t, ot->defVal); - - FOR_EACH_LIST_ELMT (tOrV, ot->index) - { - if (tOrV->choiceId == TYPEORVALUE_TYPE) - ValueLinkType (m, currMod, head, tOrV->a.type); - else - ValueLinkValue (m, currMod, NULL, t, tOrV->a.value); - } - -} /* ValueLinkSnmpObjectTypeMacroType */ diff --git a/SecuritySNACCRuntime/compiler/core/link-values.h b/SecuritySNACCRuntime/compiler/core/link-values.h deleted file mode 100644 index 58679f24..00000000 --- a/SecuritySNACCRuntime/compiler/core/link-values.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * compiler/core/link_values.h - * - * links value references - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/link-values.h,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: link-values.h,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:50 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:39 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/10/08 03:48:48 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:20 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -int LinkValueRefs PROTO ((ModuleList *m)); diff --git a/SecuritySNACCRuntime/compiler/core/mem.c b/SecuritySNACCRuntime/compiler/core/mem.c deleted file mode 100644 index 19fdd736..00000000 --- a/SecuritySNACCRuntime/compiler/core/mem.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * compiler/core/mem.c - used for allocating the components of the Module - * data structure. The program expects 0'ed memory - * to be returned by Malloc - this initializes ptrs - * to NULL. - * - * If there is not enough memory the Malloc exits - * (Callers of Malloc will never get a NULL return value) - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/mem.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: mem.c,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:50 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/07/25 19:11:50 rj - * use memzero that is defined in .../snacc.h to use either memset or bzero. - * - * Realloc() now checks realloc(3)'s return value. - * - * Revision 1.3 1994/10/08 03:48:49 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:39:27 rj - * snacc_config.h removed; more portable .h file inclusion. - * - * Revision 1.1 1994/08/28 09:49:21 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - */ - -#include "snacc.h" - -#if STDC_HEADERS -#include -#else -#if HAVE_STRING_H -#include -#else -#include -#endif -#if HAVE_MALLOC_H -#include -#endif -#endif - -#include - -#include "mem.h" - -void* -Malloc PARAMS ((size), int size) -{ - void *retVal = malloc (size); - - if (retVal == NULL) - { - fprintf (stderr, "out of memory! bye!\n"); - fprintf (stderr, "tried to allocate %d byes\n", size); - exit (1); - } - - memzero (retVal, size); - return retVal; - -} /* Malloc */ - -void *Realloc PARAMS ((ptr, newsize), - void *ptr _AND_ - int newsize) -{ - void *retval = realloc (ptr, newsize); - - if (retval == NULL) - { - fprintf (stderr, "out of memory! bye!\n"); - fprintf (stderr, "tried to reallocate %d byes\n", newsize); - exit (1); - } - - return retval; -} - -void Free PARAMS ((ptr), - void *ptr) -{ - free (ptr); -} diff --git a/SecuritySNACCRuntime/compiler/core/meta.c b/SecuritySNACCRuntime/compiler/core/meta.c deleted file mode 100644 index ee36dfa6..00000000 --- a/SecuritySNACCRuntime/compiler/core/meta.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * file: compiler/core/meta.c - * - * Copyright © 1994 1995 Robert Joop - * - * 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 and the associated libraries are distributed in the hope - * that they 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 and GNU Library General - * Public License for more details. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/meta.c,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: meta.c,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:50 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1995/08/17 15:00:11 rj - * the PDU flag belongs to the metacode, not only to the tcl interface. (type and variable named adjusted) - * - * Revision 1.1 1995/07/27 10:54:11 rj - * new file - * - */ - -#include - -#include "snacc.h" -#include "meta.h" - -#if META - -int isMetaPDU PARAMS ((module, type, pdus), - const char *module _AND_ - const char *type _AND_ - MetaPDU *pdus) -{ - MetaPDU *pdu; - - for (pdu=pdus; pdu; pdu=pdu->next) - if (!strcmp (pdu->module, module) && !strcmp (pdu->type, type)) - { - pdu->used = TRUE; - return TRUE; - } - - return FALSE; -} - -#endif /* META */ diff --git a/SecuritySNACCRuntime/compiler/core/meta.h b/SecuritySNACCRuntime/compiler/core/meta.h deleted file mode 100644 index 88daf5af..00000000 --- a/SecuritySNACCRuntime/compiler/core/meta.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * file: compiler/core/meta.h - * - * Copyright © 1994 1995 Robert Joop - * - * 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 and the associated libraries are distributed in the hope - * that they 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 and GNU Library General - * Public License for more details. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/meta.h,v 1.1 2001/06/20 21:27:57 dmitch Exp $ - * $Log: meta.h,v $ - * Revision 1.1 2001/06/20 21:27:57 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:50 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1995/09/07 19:14:26 rj - * enum MetaNameStyle introduced. - * - * Revision 1.3 1995/08/17 15:00:12 rj - * the PDU flag belongs to the metacode, not only to the tcl interface. (type and variable named adjusted) - * - * Revision 1.1 1995/07/27 10:54:11 rj - * new file - */ - -#if META - -typedef enum -{ - META_off = 0, /* metacode generation disabled */ - META_asn1_names, /* names as defined in .asn1 file */ - META_backend_names, /* names as being used by the backend code */ -} MetaNameStyle; - -typedef struct -{ - const char *srcfn; - FILE *srcfp; -} Meta; - -typedef struct MetaPDU -{ - const char *module, *type; - int used; - - struct MetaPDU *next; -} MetaPDU; - -extern int isMetaPDU PROTO ((const char *module, const char *type, MetaPDU *pdus)); - -#endif /* META */ diff --git a/SecuritySNACCRuntime/compiler/core/normalize.c b/SecuritySNACCRuntime/compiler/core/normalize.c deleted file mode 100644 index 6d52f951..00000000 --- a/SecuritySNACCRuntime/compiler/core/normalize.c +++ /dev/null @@ -1,860 +0,0 @@ -/* - * compiler/core/normalize.c - * - * 1. swap COMPONENTS OF for actual types - * - do this since save lots of special case handling in - * code generation - * - * 2. change SEQUENCE OF/SET OF (type def (not ref)) - * to SEQUENCE OF/SEQ OF (type ref) - * and add type def for orig. - * - do this since OF type are AsnList - * - * 3. change CHOICE defs within other constructed types - * into CHOICE refs - * - makes code production easier. can be changed - * with some work - * - * 4. change SEQUENCE/SET defs within other constructed types - * into SEQUENCE/SET refs - * - makes code production easier. can be changed - * with some work (allocation in decode is wrong - * - isPtr set incorrectly) - * - * 5. change SELECTION types to the actual field from the choice - * - * 6. convert Linked oid's with value refs into a ENC_OID's - * so values can be easily defined in C/C++. MS 92/03/01 - * - * 7. if IMPLICIT-TAGS is specified, mark type references - * as implicit, if the ref'd type is not CHOICE or ANY. - * (Extra tags on primitives (ie not references) are already - * removed in the parsing step (asn1.yacc)). - * - * 8. SET OF/SEQ OF defs nested in other SETs/SEQ/CHOICEs/SET OF/SEQ OF - * types are moved to separate type defs - added 08/92 to support - * C++ lists more easily. - * - * 9. INTEGERs with named elmts and ENUM defs nested in other - * SETs/SEQ/CHOICEs/SET OF/SEQ OF types are moved to separate type - * defs - added 08/92 to support C++ class hierarchy better. - * - * ******** 10 is no longer done - in fact it was stupid for ****** - * ******** ANY DEFINED BY types MS 09/92 ****** - * 10. Move ANY and ANY DEFINED BY type defs nested in SET/SEQ/CHOICE/SET OF - * /SEQ OF to a separate definition - this should make fixing the - * produced code simpler. - * - * Mike Sample - * 91/12/12 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/normalize.c,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: normalize.c,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:50 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:40 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:40:56 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:23 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "oid.h" -#include "lib-types.h" -#include "snacc-util.h" -#include "normalize.h" - -#define LIST_ELMT_SUFFIX "ListElmt" -#define CHOICE_SUFFIX "Choice" -#define SET_SUFFIX "Set" -#define SEQ_SUFFIX "Seq" -#define SETOF_SUFFIX "SetOf" -#define SEQOF_SUFFIX "SeqOf" -#define INT_SUFFIX "Int" -#define ENUM_SUFFIX "Enum" -#define BITS_SUFFIX "Bits" -#define ANY_SUFFIX "Any" - -long int oidRecursionCountG = 0; - -void NormalizeTypeDef PROTO ((Module *m, TypeDef *td)); - -void NormalizeType PROTO ((Module *m, TypeDef *td, Type *parent, NamedTypeList *e, Type *t)); - -void NormalizeElmtTypes PROTO ((Module *m, TypeDef *td, Type *parent, NamedTypeList *e)); - -void NormalizeBasicType PROTO ((Module *m, TypeDef *td, Type *parent, NamedTypeList *e, Type *type, BasicType *bt)); - -TypeDef *AddListElmtTypeDef PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt)); - -TypeDef *AddConsTypeDef PROTO ((Module *m, TypeDef *td, Type *t, BasicType *bt, char *suffix)); - -void NormalizeValueDef PROTO ((Module *m, ValueDef *vd)); - -int FlattenLinkedOid PROTO ((OID *o, char *asn1FileName, AsnInt lineNo, int quiet)); - -/* - * looks through the given module and performs the operations - * mentioned above - */ -void -NormalizeModule PARAMS ((m), - Module *m) -{ - TypeDef *td; - ValueDef *vd; - - /* - * go through each type in typeList - */ - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - NormalizeTypeDef (m, td); - } - - /* - * go through each value for types? - */ - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - { - NormalizeValueDef (m, vd); - } - -} /* NormalizeModule */ - - -void -NormalizeTypeDef PARAMS ((m, td), - Module *m _AND_ - TypeDef *td) -{ - if (td == NULL) - return; - - NormalizeType (m, td, NULL, NULL, td->type); - -} /* NormalizeTypeDef */ - - -void -NormalizeType PARAMS ((m, td, parent, e, t), - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *e _AND_ - Type *t) -{ - enum BasicTypeChoiceId typeId; - Type *tmpType; - Tag *lastTag; - - if (t == NULL) - return; - - NormalizeBasicType (m, td, parent, e, t, t->basicType); - - /* - * make type refs implicit if IMPLICIT-TAGS specified and - * ref'd type is OK for implicit tagging. - * Tag removal work is done in parsing (yacc). - */ - if ((m->tagDefault == IMPLICIT_TAGS)) - { - tmpType = ParanoidGetType (t); - typeId = tmpType->basicType->choiceId; - - if ((t->tags != NULL) && (!LIST_EMPTY (t->tags))) - lastTag = (Tag*)LAST_LIST_ELMT (t->tags); - else - lastTag = NULL; - - /* - * only mark as implicit if - * 1. This type has a tag in it's taglist - * 2. This type is a reference to another type - * 3. the referenced type is not an untagged CHOICE, ANY or - * ANY DEFINED BY (just need to check that it has - * tags since all other types have tags) - */ - if (((lastTag != NULL) && !(lastTag->explicit)) && - ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) && - (CountTags (t->basicType->a.localTypeRef->link->type) != 0)) - { - t->implicit = TRUE; - } - } - -} /* NormalizeType */ - - - -void -NormalizeElmtTypes PARAMS ((m, td, parent, e), - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *e) -{ - NamedType *nt; - - FOR_EACH_LIST_ELMT (nt, e) - { - NormalizeType (m, td, parent, e, nt->type); - } -} /* NormalizeElmtTypes */ - - -/* - * this is where most of the action happens - * assumes that "e"'s curr ptr is namedtype that holds "type" - */ -void -NormalizeBasicType PARAMS ((m, td, parent, e, type, bt), - Module *m _AND_ - TypeDef *td _AND_ - Type *parent _AND_ - NamedTypeList *e _AND_ - Type *type _AND_ - BasicType *bt) -{ - int i, numElmtsAdded; - NamedType *newElmt; - NamedType **newElmtHndl; - NamedType *nt; - NamedTypeList *elmts; - NamedType *origNext; - Type *compType; - Type *parentType; - TypeDef *newDef; - BasicType *tmpBasicType; - TagList *tags; - Tag *tag; - Tag **tagHndl; - - if (bt == NULL) - return; - - switch (bt->choiceId) - { - - case BASICTYPE_COMPONENTSOF: - /* - * copy elmts of COMPONENTS OF type into this type - */ - if (parent == NULL) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - COMPONENTS OF must be a SET or SEQUENCE element\n"); - m->status = MOD_ERROR; - return; - } - - compType = ParanoidGetType (bt->a.componentsOf); - parentType = ParanoidGetType (parent); - - /* COMPONENTS OF must be nested in a SET or SEQUENCE type */ - if ((parentType->basicType->choiceId != BASICTYPE_SET) && - (parentType->basicType->choiceId != BASICTYPE_SEQUENCE)) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - COMPONENTS OF must be a SET or SEQUENCE element\n"); - m->status = MOD_ERROR; - return; - } - - /* COMPONENTS OF in a SET must ref a SET and vice versa for SEQ */ - if (((parentType->basicType->choiceId == BASICTYPE_SET) && - (compType->basicType->choiceId != BASICTYPE_SET)) || - ((parentType->basicType->choiceId == BASICTYPE_SEQUENCE) && - (compType->basicType->choiceId != BASICTYPE_SEQUENCE))) - { - PrintErrLoc (m->asn1SrcFileName, type->lineNo); - fprintf (stderr,"ERROR - COMPONENTS OF in a SET must reference a SET type and COMPONENTS OF in SEQUENCE must reference a SEQUENCE type\n"); - type->basicType = compType->basicType; - m->status = MOD_ERROR; - return; - } - - /* - * replace "COMPONENTS OF" with elmts from ref'd set - */ - elmts = compType->basicType->a.set; - - if (elmts == NULL) - break; - - /* - * add new list elmts that point to elmts - * of type ref'd by COMPONENTS OF - */ - FOR_EACH_LIST_ELMT (nt, elmts) - { - newElmtHndl = (NamedType**)AsnListAdd (e); - *newElmtHndl = nt; - } - - /* - * Set e list's curr ptr to first of of the - * newly added components. - * Do this so NormalizeElmtTypes will do the - * newly added ones as well - */ - numElmtsAdded = AsnListCount (elmts); - for (i = 0; i < numElmtsAdded; i++) - AsnListPrev (e); - - /* remove the componets of ref since elmts copied in */ - AsnListRemove (e); - - break; - - - case BASICTYPE_SELECTION: - /* - * first normalize the CHOICE that is selected from - * - this will be done twice to the CHOICE but nothing - * bad should happen. The main reason for 'normalizing' - * the CHOICE first is to strip tags from the choice elmts - * if IMPLICIT-TAGS is set. - * NOTE: this call assumes that import/local type refs - * both use the 'TypeRef' struct and that a selection references - * a CHOICE by name (not definition) - */ - NormalizeType (m, type->basicType->a.selection->typeRef->basicType->a.localTypeRef->link, NULL, NULL, type->basicType->a.selection->typeRef->basicType->a.localTypeRef->link->type); - - /* - * use SELECTION field name if this is an elmt type with no - * field name. - */ - if ((e != NULL) && - (((NamedType*) e->curr->data)->fieldName == NULL)) - ((NamedType*) e->curr->data)->fieldName = - type->basicType->a.selection->link->fieldName; - - /* - * replace SELECTION type with refd type. - * must append the named CHOICE field's tags to - * any existing tags on this SELECTION type. - */ - tmpBasicType = type->basicType->a.selection->link->type->basicType; - tags = type->basicType->a.selection->link->type->tags; - - - FOR_EACH_LIST_ELMT (tag, tags) - { - if (!(((m->tagDefault == IMPLICIT_TAGS) || (type->implicit)) && - (tag == (Tag*)FIRST_LIST_ELMT (tags)))) - { - tagHndl = (Tag**) AsnListAppend (type->tags); - *tagHndl = tag; - } - type->implicit = FALSE; - } - - if (type->basicType->a.selection->link->type->implicit) - type->implicit = TRUE; - - Free (type->basicType->a.selection->fieldName); - Free (type->basicType->a.selection->typeRef->basicType); - Free (type->basicType->a.selection->typeRef); - type->basicType = tmpBasicType; - - break; - - - - case BASICTYPE_SEQUENCEOF: - case BASICTYPE_SETOF: - /* convert def inside other type into a ref */ - if (td->type != type) - { - if (bt->choiceId == BASICTYPE_SETOF) - newDef = AddConsTypeDef (m, td, type, bt, SETOF_SUFFIX); - else - newDef = AddConsTypeDef (m, td, type, bt, SEQOF_SUFFIX); - - NormalizeType (m, newDef, NULL, NULL, newDef->type); - } - else - NormalizeType (m, td, type, NULL, type->basicType->a.setOf); - break; - - /* NOT NEEDED ANY MORE - * convert typdef after SET OF/SEQ OF to type REFS - switch (bt->a.setOf->basicType->choiceId) - { - case BASICTYPE_SEQUENCE: - case BASICTYPE_SET: - case BASICTYPE_CHOICE: - case BASICTYPE_SEQUENCEOF: - case BASICTYPE_SETOF: - case BASICTYPE_COMPONENTSOF: - newDef = AddListElmtTypeDef (m, td, type, bt); - NormalizeType (m, newDef, NULL, NULL, newDef->type); - break; - - default: - NormalizeType (m, td, NULL, NULL, bt->a.setOf); - break; - } - */ - break; - - - case BASICTYPE_CHOICE: - /* - * change CHOICE defs embedded in other types - * into type refs - */ - if (td->type != type) - { - newDef = AddConsTypeDef (m, td, type, bt, CHOICE_SUFFIX); - NormalizeType (m, newDef, NULL, NULL, newDef->type); - } - else - NormalizeElmtTypes (m, td, type, bt->a.set); - - break; - - - case BASICTYPE_SEQUENCE: - /* - * change SEQ defs embedded in other types - * into type refs - */ - if (td->type != type) - { - newDef = AddConsTypeDef (m, td, type, bt, SEQ_SUFFIX); - NormalizeType (m, newDef, NULL, NULL, newDef->type); - } - else - NormalizeElmtTypes (m, td, type, bt->a.sequence); - break; - - - case BASICTYPE_SET: - /* - * change SET defs embedded in other types - * into type refs - */ - if (td->type != type) - { - newDef = AddConsTypeDef (m, td, type, bt, SET_SUFFIX); - NormalizeType (m, newDef, NULL, NULL, newDef->type); - } - else - NormalizeElmtTypes (m, td, type, bt->a.set); - break; - - - case BASICTYPE_INTEGER: - /* if they have named elements convert this def into a ref */ - if ((td->type != type) && (bt->a.integer != NULL) && - (!LIST_EMPTY (bt->a.integer))) - { - newDef = AddConsTypeDef (m, td, type, bt, INT_SUFFIX); - } - break; - - case BASICTYPE_ENUMERATED: - /* if they have named elements convert this def into a ref */ - if ((td->type != type) && (bt->a.enumerated != NULL) && - (!LIST_EMPTY (bt->a.enumerated))) - { - newDef = AddConsTypeDef (m, td, type, bt, ENUM_SUFFIX); - } - break; - - case BASICTYPE_BITSTRING: - /* if they have named elements convert this def into a ref */ - if ((td->type != type) && (bt->a.bitString != NULL) && - (!LIST_EMPTY (bt->a.bitString))) - { - newDef = AddConsTypeDef (m, td, type, bt, BITS_SUFFIX); - } - break; - - case BASICTYPE_ANY: - case BASICTYPE_ANYDEFINEDBY: - m->hasAnys = TRUE; - /* NO LONGER DONE - * change ANY defs embedded in other types - * into type refs - - if (td->type != type) - newDef = AddConsTypeDef (m, td, type, bt, ANY_SUFFIX); - */ - break; - - default: - /* the rest are not processed */ - break; - } -} /* NormalizeBasicType */ - - - - -/* - * given a set of/seq of type t within typedef td, change the - * set of /seq of elmt type def into a type ref and - * add a type def for the elmt at the top level. - */ -TypeDef* -AddListElmtTypeDef PARAMS ((m, td, t, bt), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt) -{ - TypeDef *newDef; - TypeDef **typeDefHndl; - int end; - int digit; - - /* - * make new type def - */ - newDef = (TypeDef*)Malloc (sizeof (TypeDef)); - newDef->exported = FALSE; - newDef->type = bt->a.setOf; - /* - * make name for new type - * Foo ::= SET OF SEQUENCE {...} - * --> - * FooListElmt ::= SEQUENCE {...} - * Foo ::= SET OF FooListElmt - */ - newDef->definedName = - Malloc (strlen (td->definedName) + - strlen (LIST_ELMT_SUFFIX) + 4); - - strcpy (newDef->definedName, td->definedName); - strcat (newDef->definedName, LIST_ELMT_SUFFIX); - end = strlen (newDef->definedName); - digit = 1; - while (LookupType (m->typeDefs, newDef->definedName) != NULL) - { - newDef->definedName[end] = '\0'; - AppendDigit (newDef->definedName, digit++); - } - - /* - * now put new type at head of list - */ - typeDefHndl = (TypeDef**)AsnListPrepend (m->typeDefs); - *typeDefHndl = newDef; - - - - /* - * replace SET OF/SEQ OF body with type ref - */ - bt->a.setOf = (Type*)Malloc (sizeof (Type)); - bt->a.setOf->optional = FALSE; - bt->a.setOf->implicit = FALSE; - bt->a.setOf->lineNo = t->lineNo; - bt->a.setOf->basicType = (BasicType*)Malloc (sizeof (BasicType)); - bt->a.setOf->basicType->choiceId = BASICTYPE_LOCALTYPEREF; - bt->a.setOf->basicType->a.localTypeRef = (TypeRef*)Malloc (sizeof (TypeRef)); - bt->a.setOf->basicType->a.localTypeRef->link = newDef; - bt->a.setOf->basicType->a.localTypeRef->typeName = - newDef->definedName; - bt->a.setOf->basicType->a.localTypeRef->moduleName = NULL; - - - return newDef; - -} /* AddListElmtTypeDefs */ - - - -/* - * given a CHOICE/SET/SEQ/etc type t within typedef td, make t into a ref - * to a new top level typdef of the CHOICE/SET/SEQ - */ -TypeDef* -AddConsTypeDef PARAMS ((m, td, t, bt, suffix), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - BasicType *bt _AND_ - char *suffix) -{ - TypeDef *newDef; - TypeDef **typeDefHndl; - Tag **tmpPtr; - Tag *lastTag; - int end; - int digit; - - /* - * make new type def - */ - newDef = (TypeDef*)Malloc (sizeof (TypeDef)); - newDef->exported = FALSE; - newDef->recursive = FALSE; - newDef->localRefCount = 1; - newDef->type = (Type*)Malloc (sizeof (Type)); - newDef->type->optional = FALSE; - newDef->type->lineNo = t->lineNo; - newDef->type->basicType = bt; - - /* - * make name for new choice/SET/SEQ - * Foo ::= SEQUENCE { .., bar CHOICE { ...}, ..} - * --> - * FooChoice ::= CHOICE { ...} - * Foo ::= SEQUENCE { .., bar FooChoice, .. } - */ - newDef->definedName = - Malloc (strlen (td->definedName) + - strlen (suffix) + 4); - - strcpy (newDef->definedName, td->definedName); - strcat (newDef->definedName, suffix); - end = strlen (newDef->definedName); - digit = 1; - - /* keep name unique */ - while (LookupType (m->typeDefs, newDef->definedName) != NULL) - { - newDef->definedName[end] = '\0'; - AppendDigit (newDef->definedName, digit++); - } - - /* - * now put new type at head of list - */ - typeDefHndl = (TypeDef**)AsnListPrepend (m->typeDefs); - *typeDefHndl = newDef; - - /* - * what to do with tags? Use default universal type on - * newly defined type and adjust (new) reference's tags - * appropriately - * - * NOTE: may be simpler just to move all the tags to the - * new def. - */ - - newDef->type->tags = (TagList*)AsnListNew (sizeof (void*)); - if (LIBTYPE_GET_UNIV_TAG_CODE ((newDef->type->basicType->choiceId)) - != NO_TAG_CODE) - { - tmpPtr = (Tag**)AsnListAppend (newDef->type->tags); - *tmpPtr = (Tag*)Malloc (sizeof (Tag)); - (*tmpPtr)->tclass = UNIV; - (*tmpPtr)->code = LIBTYPE_GET_UNIV_TAG_CODE ((newDef->type->basicType->choiceId)); - - - /* adjust tags of new ref to new def */ - if ((t->tags != NULL) && (!LIST_EMPTY (t->tags))) - { - lastTag = (Tag*)LAST_LIST_ELMT (t->tags); - if ((lastTag->tclass == UNIV) && - (lastTag->code == - LIBTYPE_GET_UNIV_TAG_CODE ((newDef->type->basicType->choiceId)))) - { - /* zap it since same as default universal tag */ - SET_CURR_LIST_NODE (t->tags, LAST_LIST_NODE (t->tags)); - AsnListRemove (t->tags); - t->implicit = FALSE; - } - else - { - t->implicit = TRUE; /* this will probably already be true */ - } - } - - } - /* - * replace embeded CHOICE/SET/SEQ def with ref to newly defined type - */ - t->basicType = (BasicType*)Malloc (sizeof (BasicType)); - t->basicType->choiceId = BASICTYPE_LOCALTYPEREF; - t->basicType->a.localTypeRef = (TypeRef*)Malloc (sizeof (TypeRef)); - t->basicType->a.localTypeRef->link = newDef; - t->basicType->a.localTypeRef->typeName = - newDef->definedName; - t->basicType->a.localTypeRef->moduleName = NULL; - - - return newDef; - -} /* AddConsTypeDef */ - - -void -NormalizeValueDef PARAMS ((m, vd), - Module *m _AND_ - ValueDef *vd) -{ - NormalizeValue (m, vd, vd->value, FALSE); -} - -void -NormalizeValue PARAMS ((m, vd, v, quiet), - Module *m _AND_ - ValueDef *vd _AND_ - Value *v _AND_ - int quiet) -{ - AsnOid *eoid; - OID *o; - OID *tmp; - int eLen; - - /* - * convert linked oids into ENC_OID's - */ - if (v->basicValue->choiceId == BASICVALUE_LINKEDOID) - { - if (!FlattenLinkedOid (v->basicValue->a.linkedOid, m->asn1SrcFileName, v->lineNo, quiet)) - return; - eLen = EncodedOidLen (v->basicValue->a.linkedOid); - eoid = MT (AsnOid); - eoid->octetLen = eLen; - eoid->octs = (char*)Malloc (eLen); - BuildEncodedOid (v->basicValue->a.linkedOid, eoid); - - /* free linked oid */ - for (o = v->basicValue->a.linkedOid; o != NULL; ) - { - tmp = o->next; - Free (o); - o = tmp; - } - v->basicValue->choiceId = BASICVALUE_OID; - v->basicValue->a.oid = eoid; - } -} - - -/* - * replaces value refs with the value's number if poss - * returns TRUE if successfully done. - * returns FALSE if a value ref could not be traced - * (false should not happen if the value link succeeded) - * "quiet" parameter allows err msg to be turned off - * which prevents cascading errors by other oid's that - * reference a bad oid. - */ -int -FlattenLinkedOid PARAMS ((o, asn1FileName, lineNo, quiet), - OID *o _AND_ - char *asn1FileName _AND_ - AsnInt lineNo _AND_ - int quiet) -{ - OID *firstElmt; - OID *refdOid; - OID *tmpOid; - OID **nextOid; - Value *val; - Value *valRef; - - if (oidRecursionCountG > 100) - { - PrintErrLoc (asn1FileName, lineNo); - fprintf (stderr,"ERROR - recursive OBJECT IDENTIFIER value.\n"); - return FALSE; - } - - firstElmt = o; - - for (; o != NULL; o = o->next) - { - valRef = o->valueRef; - if ((valRef == NULL) || (o->arcNum != NULL_OID_ARCNUM)) - continue; /* no linking nec for this one */ - - val = GetValue (o->valueRef); - - /* - * if the very first component is an oid val ref - * then insert that value - */ - if ((o == firstElmt) && (val->basicValue->choiceId == BASICVALUE_OID)) - { - UnbuildEncodedOid (val->basicValue->a.oid, &refdOid); - for (tmpOid = refdOid; tmpOid->next != NULL; tmpOid = tmpOid->next) - ; - tmpOid->next = o->next; - memcpy (firstElmt, refdOid, sizeof (OID)); - Free (refdOid); /* free first component of OID since copied */ - } - - else if ((o == firstElmt) && (val->basicValue->choiceId == BASICVALUE_LINKEDOID)) - { - oidRecursionCountG++; - if (!FlattenLinkedOid (val->basicValue->a.linkedOid, asn1FileName, lineNo, TRUE)) - { - oidRecursionCountG--; - return FALSE; - } - oidRecursionCountG--; - - nextOid = &refdOid; - for (tmpOid = val->basicValue->a.linkedOid; - tmpOid != NULL; tmpOid = tmpOid->next) - { - *nextOid = (OID*)Malloc (sizeof (OID)); - (*nextOid)->arcNum = tmpOid->arcNum; - nextOid = &(*nextOid)->next; - } - (*nextOid) = o->next; - memcpy (firstElmt, refdOid, sizeof (OID)); - Free (refdOid); /* since copied into firstElmt */ - } - - else if ((val->basicValue->choiceId == BASICVALUE_INTEGER)) - { - o->arcNum = val->basicValue->a.integer; - if ((o->arcNum < 0) && !quiet) - { - PrintErrLoc (asn1FileName, lineNo); - fprintf (stderr,"ERROR - OBJECT IDENTIFIER arc values cannot be negative.\n"); - } - } - else /* bad arc value type */ - { - if (!quiet) - { - PrintErrLoc (asn1FileName, lineNo); - fprintf (stderr,"ERROR - type mismatch for an arc value. Values ref'd from an OBJECT IDENTIFIER value must be either an OBJECT IDENTIFIER (first oid elmt only) or INTEGER value (this may be reported twice!)\n"); - } - return FALSE; - } - - /* free mem assoc with value ref */ - Free (valRef->basicValue->a.localValueRef->valueName); - Free (valRef->basicValue->a.localValueRef); - Free (valRef->basicValue); - Free (valRef); - o->valueRef = NULL; - } - return TRUE; -} /* FlattenLinkedOid */ diff --git a/SecuritySNACCRuntime/compiler/core/normalize.h b/SecuritySNACCRuntime/compiler/core/normalize.h deleted file mode 100644 index 87bfaa3e..00000000 --- a/SecuritySNACCRuntime/compiler/core/normalize.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * compiler/core/normalize.h - * - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/normalize.h,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: normalize.h,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:50 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1994/10/08 03:48:50 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:25 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -void NormalizeModule PROTO ((Module *m)); -void NormalizeValue PROTO ((Module *m, ValueDef *vd, Value *v, int quiet)); diff --git a/SecuritySNACCRuntime/compiler/core/oid.c b/SecuritySNACCRuntime/compiler/core/oid.c deleted file mode 100644 index 22ed2ac3..00000000 --- a/SecuritySNACCRuntime/compiler/core/oid.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - * compiler/core/oid.c - routines for: - * converting an arc number list to an ENC_OID - * converting an ENC_OID to an arc number list - * arcName mapping routine - * - * does not handle OID's with unresolved valueRefs instead of arcNums - * - * MS 91 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/oid.c,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: oid.c,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:51 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:41 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:41:33 rj - * snacc_config.h removed; oid.h includet. - * - * Revision 1.1 1994/08/28 09:49:26 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include /* for FILE * */ - -#include "asn-incl.h" -#include "oid.h" - -typedef struct ArcNameMapElmt -{ - char *arcName; - int arcNum; -} ArcNameMapElmt; - - -/* - * these are the CCITT and ISO pre-defined arc names for the - * OBJECT IDENTIFIER tree. - * Ref: CCITT X.208 1988 - Annexes B C and D - * - * NOTE: the last entry must have a NULL string and a - * -1 arcnumber to indicate the end of the array. - */ -ArcNameMapElmt oidArcNameMapG[] = -{ - "ccitt", 0, - "iso", 1, - "joint-iso-ccitt", 2, - "standard", 0, - "registration-authority", 1, - "member-body", 2, - "identified-organization", 3, - "recommendation", 0, - "question", 1, - "administration", 2, - "network-operator", 3, - NULL,-1 -}; - - -/* - * returns the arcnum (>0) of the given name if it - * is a defined oid arc name like "iso" or "ccitt" - * returns -1 if the name was not found - * - * name must be null terminated. - */ -int -OidArcNameToNum PARAMS ((name), - char *name) -{ - int i; - for (i= 0; oidArcNameMapG[i].arcName != NULL; i++) - { - if (strcmp (name, oidArcNameMapG[i].arcName) == 0) - return oidArcNameMapG[i].arcNum; - } - return -1; -} /* OidArcNameToNum */ - - - -/* - * Takes and OBJECT IDENTIFER in the linked format - * (produced by parser) and returns the number of octets - * that are needed to hold the encoded version of that - * OBJECT IDENTIFIER. - */ -unsigned long int -EncodedOidLen PARAMS ((oid), - OID *oid) -{ - unsigned long totalLen; - unsigned long headArcNum; - unsigned long tmpArcNum; - OID *tmpOid; - - /* - * oid must have at least 2 elmts - */ - if (oid->next == NULL) - return 0; - - headArcNum = (oid->arcNum * 40) + oid->next->arcNum; - - /* - * figure out total encoded length of oid - */ - tmpArcNum = headArcNum; - for (totalLen = 1; (tmpArcNum >>= 7) != 0; totalLen++) - ; - for (tmpOid = oid->next->next; tmpOid != NULL; tmpOid = tmpOid->next) - { - totalLen++; - tmpArcNum = tmpOid->arcNum; - for (; (tmpArcNum >>= 7) != 0; totalLen++) - ; - } - - return totalLen; - -} /* EncodedOidLen */ - - -/* - * Given an oid arc number list and a pre-allocated ENC_OID - * (use EncodedOidLen to figure out byte length needed) - * fills the ENC_OID with a BER encoded version - * of the oid. - */ -void -BuildEncodedOid PARAMS ((oid, result), - OID *oid _AND_ - AsnOid *result) -{ - unsigned long len; - unsigned long headArcNum; - unsigned long tmpArcNum; - char *buf; - int i; - OID *tmpOid; - - buf = result->octs; - - /* - * oid must have at least 2 elmts - */ - if (oid->next == NULL) - return; - /* - * munge together first two arcNum - * note first arcnum must be <= 2 - * and second must be < 39 if first = 0 or 1 - * see (X.209) for ref to this stupidity - */ - headArcNum = (oid->arcNum * 40) + oid->next->arcNum; - - tmpArcNum = headArcNum; - - /* - * calc # bytes needed for head arc num - */ - for (len = 0; (tmpArcNum >>= 7) != 0; len++) - ; - - /* - * write more signifcant bytes (if any) of head arc num - * with 'more' bit set - */ - for (i=0; i < len; i++) - *(buf++) = 0x80 | (headArcNum >> ((len-i)*7)); - - /* - * write least significant byte of head arc num - */ - *(buf++) = 0x7f & headArcNum; - - - /* - * write following arc nums, if any - */ - for (tmpOid = oid->next->next; tmpOid != NULL; tmpOid = tmpOid->next) - { - /* - * figure out encoded length -1 of this arcNum - */ - tmpArcNum = tmpOid->arcNum; - for (len = 0; (tmpArcNum >>= 7) != 0; len++) - ; - - - /* - * write more signifcant bytes (if any) - * with 'more' bit set - */ - for (i=0; i < len; i++) - *(buf++) = 0x80 | (tmpOid->arcNum >> ((len-i)*7)); - - /* - * write least significant byte - */ - *(buf++) = 0x7f & tmpOid->arcNum; - } - -} /* BuildEncodedOid */ - - -/* - * Given an ENC_OID, this routine converts it into a - * linked oid (OID). - */ -void -UnbuildEncodedOid PARAMS ((eoid, result), - AsnOid *eoid _AND_ - OID **result) -{ - OID **nextOid; - OID *headOid; - int arcNum; - int i; - int firstArcNum; - int secondArcNum; - - for (arcNum = 0, i=0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - i++; - - firstArcNum = arcNum / 40; - if (firstArcNum > 2) - firstArcNum = 2; - - secondArcNum = arcNum - (firstArcNum * 40); - - headOid = (OID*)Malloc (sizeof (OID)); - headOid->arcNum = firstArcNum; - headOid->next = (OID*)Malloc (sizeof (OID)); - headOid->next->arcNum = secondArcNum; - nextOid = &headOid->next->next; - - for ( ; i < eoid->octetLen; ) - { - for (arcNum = 0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - i++; - *nextOid = (OID*)Malloc (sizeof (OID)); - (*nextOid)->arcNum = arcNum; - nextOid = &(*nextOid)->next; - } - - *result = headOid; - -} /* UnbuildEncodedOid */ diff --git a/SecuritySNACCRuntime/compiler/core/oid.h b/SecuritySNACCRuntime/compiler/core/oid.h deleted file mode 100644 index 68bc5c26..00000000 --- a/SecuritySNACCRuntime/compiler/core/oid.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * compiler/core/oid.h - routine for building an ENC_OID from an arc number list - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/oid.h,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: oid.h,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:51 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1994/10/08 03:48:51 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:27 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -int OidArcNameToNum PROTO ((char *name)); -unsigned long EncodedOidLen PROTO ((OID *oid)); -void BuildEncodedOid PROTO ((OID *oid, AsnOid *result)); -void UnbuildEncodedOid PROTO ((AsnOid *eoid, OID **result)); diff --git a/SecuritySNACCRuntime/compiler/core/parse-asn1.c b/SecuritySNACCRuntime/compiler/core/parse-asn1.c deleted file mode 100644 index faf5a414..00000000 --- a/SecuritySNACCRuntime/compiler/core/parse-asn1.c +++ /dev/null @@ -1,4619 +0,0 @@ - -/* A Bison parser, made from core/parse-asn1.y - by GNU Bison version 1.25 - */ - -#define YYBISON 1 /* Identify Bison output. */ - -#define BSTRING_SYM 258 -#define HSTRING_SYM 259 -#define CSTRING_SYM 260 -#define UCASEFIRST_IDENT_SYM 261 -#define LCASEFIRST_IDENT_SYM 262 -#define NAMEDMACRO_SYM 263 -#define MACRODEFBODY_SYM 264 -#define BRACEBAL_SYM 265 -#define NUMBER_ERANGE 266 -#define NUMBER_SYM 267 -#define SNACC_ATTRIBUTES 268 -#define DOT_SYM 269 -#define COMMA_SYM 270 -#define LEFTBRACE_SYM 271 -#define RIGHTBRACE_SYM 272 -#define LEFTPAREN_SYM 273 -#define RIGHTPAREN_SYM 274 -#define LEFTBRACKET_SYM 275 -#define RIGHTBRACKET_SYM 276 -#define LESSTHAN_SYM 277 -#define MINUS_SYM 278 -#define GETS_SYM 279 -#define BAR_SYM 280 -#define TAGS_SYM 281 -#define BOOLEAN_SYM 282 -#define INTEGER_SYM 283 -#define BIT_SYM 284 -#define STRING_SYM 285 -#define OCTET_SYM 286 -#define NULL_SYM 287 -#define SEQUENCE_SYM 288 -#define OF_SYM 289 -#define SET_SYM 290 -#define IMPLICIT_SYM 291 -#define CHOICE_SYM 292 -#define ANY_SYM 293 -#define OBJECT_IDENTIFIER_SYM 294 -#define OPTIONAL_SYM 295 -#define DEFAULT_SYM 296 -#define COMPONENTS_SYM 297 -#define UNIVERSAL_SYM 298 -#define APPLICATION_SYM 299 -#define PRIVATE_SYM 300 -#define TRUE_SYM 301 -#define FALSE_SYM 302 -#define BEGIN_SYM 303 -#define END_SYM 304 -#define DEFINITIONS_SYM 305 -#define EXPLICIT_SYM 306 -#define ENUMERATED_SYM 307 -#define EXPORTS_SYM 308 -#define IMPORTS_SYM 309 -#define REAL_SYM 310 -#define INCLUDES_SYM 311 -#define MIN_SYM 312 -#define MAX_SYM 313 -#define SIZE_SYM 314 -#define FROM_SYM 315 -#define WITH_SYM 316 -#define COMPONENT_SYM 317 -#define PRESENT_SYM 318 -#define ABSENT_SYM 319 -#define DEFINED_SYM 320 -#define BY_SYM 321 -#define PLUS_INFINITY_SYM 322 -#define MINUS_INFINITY_SYM 323 -#define SEMI_COLON_SYM 324 -#define IA5STRING_SYM 325 -#define PRINTABLESTRING_SYM 326 -#define NUMERICSTRING_SYM 327 -#define TELETEXSTRING_SYM 328 -#define T61STRING_SYM 329 -#define VIDEOTEXSTRING_SYM 330 -#define VISIBLESTRING_SYM 331 -#define ISO646STRING_SYM 332 -#define GRAPHICSTRING_SYM 333 -#define GENERALSTRING_SYM 334 -#define GENERALIZEDTIME_SYM 335 -#define UTCTIME_SYM 336 -#define EXTERNAL_SYM 337 -#define OBJECTDESCRIPTOR_SYM 338 -#define OPERATION_SYM 339 -#define ARGUMENT_SYM 340 -#define RESULT_SYM 341 -#define ERRORS_SYM 342 -#define LINKED_SYM 343 -#define ERROR_SYM 344 -#define PARAMETER_SYM 345 -#define BIND_SYM 346 -#define BINDERROR_SYM 347 -#define UNBIND_SYM 348 -#define UNBINDERROR_SYM 349 -#define ASE_SYM 350 -#define OPERATIONS_SYM 351 -#define CONSUMERINVOKES_SYM 352 -#define SUPPLIERINVOKES_SYM 353 -#define AC_SYM 354 -#define ASES_SYM 355 -#define REMOTE_SYM 356 -#define INITIATOR_SYM 357 -#define RESPONDER_SYM 358 -#define ABSTRACTSYNTAXES_SYM 359 -#define CONSUMER_SYM 360 -#define EXTENSIONS_SYM 361 -#define CHOSEN_SYM 362 -#define EXTENSION_SYM 363 -#define CRITICAL_SYM 364 -#define FOR_SYM 365 -#define DELIVERY_SYM 366 -#define SUBMISSION_SYM 367 -#define TRANSFER_SYM 368 -#define EXTENSIONATTRIBUTE_SYM 369 -#define TOKEN_SYM 370 -#define TOKENDATA_SYM 371 -#define SECURITYCATEGORY_SYM 372 -#define OBJECT_SYM 373 -#define PORTS_SYM 374 -#define BOXC_SYM 375 -#define BOXS_SYM 376 -#define PORT_SYM 377 -#define ABSTRACTOPS_SYM 378 -#define REFINE_SYM 379 -#define AS_SYM 380 -#define RECURRING_SYM 381 -#define VISIBLE_SYM 382 -#define PAIRED_SYM 383 -#define ABSTRACTBIND_SYM 384 -#define ABSTRACTUNBIND_SYM 385 -#define TO_SYM 386 -#define ABSTRACTERROR_SYM 387 -#define ABSTRACTOPERATION_SYM 388 -#define ALGORITHM_SYM 389 -#define ENCRYPTED_SYM 390 -#define SIGNED_SYM 391 -#define SIGNATURE_SYM 392 -#define PROTECTED_SYM 393 -#define OBJECTTYPE_SYM 394 -#define SYNTAX_SYM 395 -#define ACCESS_SYM 396 -#define STATUS_SYM 397 -#define DESCRIPTION_SYM 398 -#define REFERENCE_SYM 399 -#define INDEX_SYM 400 -#define DEFVAL_SYM 401 - -#line 66 "core/parse-asn1.y" - - -#include "snacc.h" - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "lib-types.h" -#include "snacc-util.h" -#include "exports.h" -#include "parser.h" -#include "lex-stuff.h" - -/* - * smallErrG - * used for small errors that should prevent code generation but not - * prevent the later error checking passes - */ -int smallErrG = FALSE; - -/* - * firstTimeThroughG - * used incase the asn1.lex was compiled with flex in which - * case the lexical analyzer must be reset for every ASN.1 file - * parsed, except the first - */ -static int firstTimeThroughG = TRUE; - -/* - * modulePtrG - * used to hold the parsed value. The root of the parse tree. - */ -Module *modulePtrG; - - -/* - * oidElmtValDefsG - * used to hold integer values that are defined as arc numbers - * the modules object identifiers. - * eg. FOO-MODULE { joint-iso-ccitt dod (2) foo (2) 3 2 } DEFINITIONS ::= - * would put dod/2 and foo/2 in the oidElmtValDefsG list - * Note: only some oid's (modules name/import list module names) - * are parsed by the yacc code. The rest are parsed later - * due to ambiguities that arise without type info. - */ -ValueDefList *oidElmtValDefsG = NULL; - - -/* - * ApplTag - * used to hold APPLICATION tags that have been defined in - * a module. This permits checking for the the error of - * using the same APPLICATION tag in 1 module. The - * ApplTags list (appTagsG) is emptied for each module. - */ -typedef struct ApplTag -{ - unsigned long int lineNo; - unsigned long int tagCode; - struct ApplTag *next; -} ApplTag; - -ApplTag *applTagsG = NULL; - -/* - * Protos for ApplTag related stuff. These are defined at the - * end of this file - */ -void PushApplTag PROTO ((unsigned long int tagCode, unsigned long int lineNo)); -void FreeApplTags(); - - - -/* - * the following are globals to simplify disparity between - * productions and produced data structure - */ - -/* - * these are used in the ValueRange subtype production - */ -static int valueRangeUpperEndInclusiveG; -static int valueRangeLowerEndInclusiveG; - -/* - * used to set exports flag in Type/value defs - * exportListG holds the explicitly exported elements. - * see SetExports routine in export.c - */ -ExportElmt *exportListG = NULL; -int exportsParsedG; - - -/* - * globals for the APPLICATION-CONTEXT macro productions - */ -static ValueList *rosAcSymmetricAsesG; -static ValueList *rosAcResponderConsumerOfG; -static ValueList *rosAcInitiatorConsumerOfG; - -/* - * used with MTSAS Extension macro - * set to NULL for the initial parse. - */ -static AsnBool *mtsasCriticalForSubmissionG = NULL; -static AsnBool *mtsasCriticalForTransferG = NULL; -static AsnBool *mtsasCriticalForDeliveryG = NULL; - -/* - * Asn PORT macro globals - */ -static TypeOrValueList *asnConsumerG; -static TypeOrValueList *asnSupplierG; - - -/* - * parseErrCountG - * used to prevent too many cascade errors - */ -int parseErrCountG = 0; -#define MAX_ERR 50 -#define PARSE_ERROR()\ - parseErrCountG++;\ - modulePtrG->status = MOD_ERROR;\ - if (parseErrCountG > MAX_ERR)\ - {\ - fprintf (stderr, "Ackkkkk! too many errors - bye!\n");\ - exit (1);\ - } - - - -#line 212 "core/parse-asn1.y" -typedef union -{ - int intVal; - unsigned int uintVal; - char *charPtr; - Type *typePtr; - NamedType *namedTypePtr; - NamedTypeList *namedTypeListPtr; - Value *valuePtr; - NamedValue *namedValuePtr; - SubtypeValue *subtypeValuePtr; - Subtype *subtypePtr; - ModuleId *moduleId; - OID *oidPtr; - OidList *oidListPtr; - TypeDef *typeDefPtr; - TypeDefList *typeDefListPtr; - ValueDef *valueDefPtr; - ValueDefList *valueDefListPtr; - ExportElmt *exportList; - ImportModule *importModulePtr; - ImportModuleList *importModuleListPtr; - ImportElmt *importElmtPtr; - ImportElmtList *importElmtListPtr; - Tag *tagPtr; - TagList *tagListPtr; - Constraint *constraintPtr; - ConstraintList *constraintListPtr; - InnerSubtype *innerSubtypePtr; - ValueList *valueListPtr; - TypeOrValueList *typeOrValueListPtr; - TypeOrValue *typeOrValuePtr; - AsnPort *asnPortPtr; - AsnPortList *asnPortListPtr; - AttributeList *attrList; -} YYSTYPE; -#include - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif -#endif - - - -#define YYFINAL 671 -#define YYFLAG -32768 -#define YYNTBASE 147 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 401 ? yytranslate[x] : 334) - -static const short yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, - 146 -}; - -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 1, 2, 11, 14, 17, 19, 22, 24, 26, - 30, 32, 36, 40, 42, 44, 46, 48, 53, 57, - 61, 63, 65, 67, 70, 72, 77, 81, 83, 85, - 87, 89, 92, 94, 96, 99, 102, 104, 106, 107, - 114, 118, 124, 126, 128, 135, 140, 142, 144, 146, - 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, - 168, 170, 172, 174, 176, 178, 180, 182, 185, 188, - 190, 192, 194, 199, 201, 205, 210, 215, 217, 219, - 222, 225, 230, 232, 235, 241, 243, 245, 249, 253, - 256, 259, 261, 267, 269, 272, 276, 280, 285, 289, - 293, 297, 300, 304, 310, 313, 315, 320, 324, 327, - 331, 335, 340, 342, 344, 346, 348, 350, 352, 354, - 359, 361, 364, 369, 374, 378, 380, 384, 386, 388, - 390, 392, 394, 396, 398, 401, 406, 408, 411, 413, - 416, 418, 420, 422, 424, 427, 430, 434, 438, 440, - 442, 444, 448, 456, 458, 462, 465, 467, 470, 472, - 474, 476, 478, 480, 482, 488, 490, 492, 494, 496, - 501, 503, 505, 507, 509, 511, 513, 515, 516, 520, - 522, 524, 526, 528, 530, 532, 535, 539, 542, 544, - 546, 548, 550, 552, 554, 559, 564, 566, 568, 570, - 572, 574, 576, 578, 580, 581, 583, 585, 587, 590, - 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, - 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, - 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, - 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, - 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, - 693, 698, 701, 703, 706, 708, 710, 712, 717, 719, - 724, 726, 729, 732, 734, 739, 742, 744, 747, 749, - 752, 754, 759, 762, 764, 767, 771, 776, 781, 783, - 788, 790, 792, 801, 806, 814, 816, 822, 824, 827, - 834, 836, 843, 845, 850, 852, 854, 858, 865, 867, - 869, 871, 875, 877, 879, 881, 885, 887, 889, 894, - 896, 899, 901, 905, 907, 909, 913, 915, 917, 919, - 921, 924, 926, 929, 931, 934, 936, 939, 942, 947, - 949, 951, 955, 958, 960, 962, 964, 967, 969, 974, - 976, 978, 981, 984, 989, 994, 999, 1001, 1005, 1008, - 1010, 1013, 1015, 1019, 1023, 1025, 1029, 1031, 1035, 1037, - 1040, 1044, 1049, 1051, 1054, 1058, 1063, 1065, 1068, 1071, - 1075, 1078, 1081, 1084, 1087, 1099, 1101, 1103, 1106, 1107, - 1110, 1111, 1116, 1117, 1122 -}; - -static const short yyrhs[] = { -1, - 0, 151, 50, 150, 149, 24, 48, 153, 49, 0, - 51, 26, 0, 36, 26, 0, 249, 0, 247, 152, - 0, 236, 0, 249, 0, 154, 157, 163, 0, 249, - 0, 53, 155, 69, 0, 53, 1, 69, 0, 249, - 0, 156, 0, 249, 0, 162, 0, 156, 15, 147, - 162, 0, 54, 158, 69, 0, 54, 1, 69, 0, - 249, 0, 159, 0, 249, 0, 159, 160, 0, 160, - 0, 161, 60, 147, 151, 0, 161, 15, 162, 0, - 162, 0, 248, 0, 246, 0, 253, 0, 163, 164, - 0, 164, 0, 165, 0, 165, 69, 0, 1, 69, - 0, 168, 0, 226, 0, 0, 8, 24, 48, 147, - 166, 9, 0, 8, 24, 167, 0, 8, 24, 247, - 14, 167, 0, 248, 0, 253, 0, 248, 24, 250, - 147, 171, 250, 0, 247, 14, 147, 248, 0, 169, - 0, 248, 0, 252, 0, 172, 0, 170, 0, 203, - 0, 174, 0, 175, 0, 181, 0, 183, 0, 185, - 0, 189, 0, 191, 0, 192, 0, 193, 0, 196, - 0, 197, 0, 201, 0, 202, 0, 179, 0, 180, - 0, 31, 30, 0, 246, 171, 0, 171, 0, 27, - 0, 28, 0, 28, 16, 176, 17, 0, 177, 0, - 176, 15, 177, 0, 246, 18, 178, 19, 0, 246, - 18, 228, 19, 0, 12, 0, 11, 0, 23, 12, - 0, 23, 11, 0, 52, 16, 176, 17, 0, 55, - 0, 29, 30, 0, 29, 30, 16, 182, 17, 0, - 176, 0, 32, 0, 33, 147, 16, 0, 184, 186, - 17, 0, 184, 17, 0, 187, 250, 0, 188, 0, - 187, 15, 250, 147, 188, 0, 173, 0, 173, 40, - 0, 173, 41, 235, 0, 42, 34, 171, 0, 246, - 42, 34, 171, 0, 33, 34, 171, 0, 35, 147, - 16, 0, 190, 186, 17, 0, 190, 17, 0, 35, - 34, 171, 0, 37, 147, 16, 194, 17, 0, 195, - 250, 0, 173, 0, 195, 15, 250, 173, 0, 246, - 22, 171, 0, 198, 171, 0, 198, 36, 171, 0, - 198, 51, 171, 0, 20, 200, 199, 21, 0, 245, - 0, 228, 0, 43, 0, 44, 0, 45, 0, 249, - 0, 38, 0, 38, 65, 66, 246, 0, 39, 0, - 171, 204, 0, 35, 214, 34, 171, 0, 33, 214, - 34, 171, 0, 18, 205, 19, 0, 206, 0, 205, - 25, 206, 0, 207, 0, 208, 0, 209, 0, 215, - 0, 214, 0, 216, 0, 227, 0, 56, 171, 0, - 210, 14, 14, 211, 0, 212, 0, 212, 22, 0, - 213, 0, 22, 213, 0, 227, 0, 57, 0, 227, - 0, 58, 0, 59, 204, 0, 60, 204, 0, 61, - 62, 217, 0, 61, 42, 218, 0, 204, 0, 219, - 0, 220, 0, 16, 221, 17, 0, 16, 14, 14, - 14, 15, 221, 17, 0, 222, 0, 221, 15, 222, - 0, 246, 223, 0, 223, 0, 224, 225, 0, 204, - 0, 249, 0, 63, 0, 64, 0, 249, 0, 40, - 0, 246, 171, 24, 147, 227, 0, 230, 0, 228, - 0, 229, 0, 246, 0, 247, 14, 147, 246, 0, - 232, 0, 234, 0, 233, 0, 178, 0, 243, 0, - 242, 0, 244, 0, 0, 16, 231, 10, 0, 46, - 0, 47, 0, 67, 0, 68, 0, 32, 0, 227, - 0, 246, 227, 0, 16, 237, 17, 0, 237, 238, - 0, 238, 0, 239, 0, 240, 0, 241, 0, 245, - 0, 246, 0, 246, 18, 239, 19, 0, 246, 18, - 228, 19, 0, 3, 0, 4, 0, 5, 0, 12, - 0, 11, 0, 7, 0, 6, 0, 6, 0, 0, - 251, 0, 249, 0, 13, 0, 251, 13, 0, 254, - 0, 261, 0, 263, 0, 267, 0, 269, 0, 274, - 0, 289, 0, 283, 0, 294, 0, 295, 0, 296, - 0, 297, 0, 298, 0, 303, 0, 307, 0, 316, - 0, 318, 0, 320, 0, 321, 0, 322, 0, 323, - 0, 326, 0, 325, 0, 324, 0, 327, 0, 84, - 0, 89, 0, 91, 0, 93, 0, 95, 0, 99, - 0, 108, 0, 106, 0, 114, 0, 115, 0, 116, - 0, 117, 0, 118, 0, 122, 0, 124, 0, 129, - 0, 130, 0, 133, 0, 132, 0, 134, 0, 135, - 0, 136, 0, 137, 0, 138, 0, 139, 0, 84, - 255, 0, 256, 257, 259, 260, 0, 85, 173, 0, - 249, 0, 86, 258, 0, 249, 0, 173, 0, 249, - 0, 87, 16, 286, 17, 0, 249, 0, 88, 16, - 286, 17, 0, 249, 0, 89, 262, 0, 90, 173, - 0, 249, 0, 91, 264, 265, 266, 0, 85, 173, - 0, 249, 0, 86, 173, 0, 249, 0, 92, 173, - 0, 249, 0, 93, 264, 265, 268, 0, 94, 173, - 0, 249, 0, 95, 270, 0, 95, 271, 272, 0, - 96, 16, 273, 17, 0, 97, 16, 273, 17, 0, - 249, 0, 98, 16, 273, 17, 0, 249, 0, 285, - 0, 99, 275, 91, 171, 93, 171, 276, 281, 0, - 100, 16, 285, 17, 0, 101, 96, 16, 227, 17, - 277, 278, 0, 249, 0, 96, 34, 16, 285, 17, - 0, 249, 0, 279, 280, 0, 102, 105, 34, 16, - 285, 17, 0, 249, 0, 103, 105, 34, 16, 285, - 17, 0, 249, 0, 104, 16, 282, 17, 0, 249, - 0, 236, 0, 282, 15, 236, 0, 106, 107, 60, - 16, 284, 17, 0, 285, 0, 249, 0, 227, 0, - 285, 15, 227, 0, 287, 0, 249, 0, 288, 0, - 287, 15, 288, 0, 171, 0, 227, 0, 108, 173, - 290, 291, 0, 108, 0, 41, 227, 0, 249, 0, - 109, 110, 292, 0, 249, 0, 293, 0, 292, 15, - 293, 0, 112, 0, 113, 0, 111, 0, 114, 0, - 114, 171, 0, 115, 0, 115, 171, 0, 116, 0, - 116, 171, 0, 117, 0, 117, 171, 0, 118, 299, - 0, 119, 16, 300, 17, 0, 249, 0, 301, 0, - 300, 15, 301, 0, 227, 302, 0, 120, 0, 121, - 0, 249, 0, 122, 304, 0, 122, 0, 123, 16, - 287, 17, 0, 305, 0, 306, 0, 305, 306, 0, - 306, 305, 0, 97, 16, 287, 17, 0, 98, 16, - 287, 17, 0, 124, 315, 125, 308, 0, 309, 0, - 308, 15, 309, 0, 310, 311, 0, 315, 0, 315, - 126, 0, 312, 0, 311, 15, 312, 0, 227, 302, - 313, 0, 127, 0, 128, 61, 314, 0, 315, 0, - 314, 15, 315, 0, 227, 0, 129, 317, 0, 129, - 317, 171, 0, 131, 16, 300, 17, 0, 249, 0, - 130, 319, 0, 130, 319, 171, 0, 60, 16, 300, - 17, 0, 249, 0, 133, 255, 0, 132, 262, 0, - 134, 90, 171, 0, 135, 171, 0, 136, 171, 0, - 137, 171, 0, 138, 171, 0, 139, 140, 171, 141, - 328, 142, 329, 330, 331, 332, 333, 0, 246, 0, - 246, 0, 143, 227, 0, 0, 144, 227, 0, 0, - 145, 16, 287, 17, 0, 0, 146, 16, 227, 17, - 0, 0 -}; - -#endif - -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 461, 463, 468, 500, 502, 503, 510, 519, 521, 524, - 526, 529, 540, 547, 550, 552, 555, 563, 572, 574, - 579, 582, 584, 587, 592, 599, 610, 621, 634, 636, - 637, 650, 652, 655, 657, 658, 665, 680, 693, 695, - 734, 750, 775, 777, 784, 805, 820, 822, 832, 834, - 835, 836, 839, 841, 842, 843, 844, 845, 846, 847, - 848, 849, 850, 851, 852, 853, 854, 855, 861, 868, - 875, 882, 888, 896, 902, 909, 917, 925, 933, 939, - 950, 958, 967, 974, 980, 987, 993, 1000, 1005, 1021, - 1035, 1049, 1055, 1072, 1074, 1079, 1093, 1099, 1110, 1126, - 1130, 1145, 1160, 1174, 1191, 1204, 1210, 1225, 1240, 1266, - 1307, 1316, 1334, 1340, 1348, 1350, 1351, 1352, 1356, 1361, - 1370, 1378, 1388, 1401, 1417, 1424, 1440, 1452, 1454, 1455, - 1456, 1457, 1458, 1461, 1469, 1478, 1493, 1499, 1506, 1512, - 1519, 1521, 1528, 1530, 1537, 1547, 1556, 1563, 1571, 1586, - 1588, 1591, 1600, 1610, 1616, 1623, 1629, 1633, 1642, 1644, - 1647, 1649, 1650, 1651, 1663, 1675, 1677, 1680, 1682, 1695, - 1710, 1712, 1713, 1714, 1720, 1728, 1736, 1744, 1745, 1761, - 1768, 1777, 1784, 1794, 1804, 1810, 1819, 1846, 1856, 1861, - 1863, 1884, 1888, 1896, 1901, 1920, 1941, 1945, 1949, 1953, - 1961, 1969, 1973, 1977, 1981, 1988, 1990, 1993, 1999, 2010, - 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, - 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, - 2032, 2033, 2034, 2035, 2038, 2040, 2041, 2042, 2043, 2044, - 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, - 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2071, - 2075, 2091, 2093, 2096, 2098, 2102, 2104, 2108, 2113, 2118, - 2123, 2134, 2148, 2150, 2158, 2172, 2174, 2178, 2180, 2184, - 2186, 2194, 2209, 2211, 2219, 2228, 2240, 2248, 2253, 2257, - 2262, 2266, 2275, 2299, 2307, 2313, 2322, 2327, 2330, 2334, - 2339, 2342, 2347, 2350, 2355, 2359, 2365, 2377, 2391, 2393, - 2396, 2402, 2409, 2411, 2414, 2420, 2427, 2434, 2446, 2464, - 2476, 2478, 2481, 2483, 2487, 2489, 2492, 2498, 2503, 2516, - 2526, 2541, 2550, 2564, 2574, 2589, 2599, 2620, 2630, 2635, - 2638, 2644, 2651, 2660, 2666, 2671, 2683, 2694, 2702, 2707, - 2713, 2719, 2725, 2733, 2740, 2756, 2763, 2765, 2768, 2772, - 2774, 2777, 2779, 2782, 2789, 2791, 2795, 2797, 2800, 2813, - 2823, 2835, 2840, 2849, 2860, 2873, 2878, 2886, 2898, 2911, - 2922, 2934, 2945, 2959, 2969, 2995, 3017, 3038, 3040, 3043, - 3045, 3048, 3053, 3056, 3061 -}; -#endif - - -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) - -static const char * const yytname[] = { "$","error","$undefined.","BSTRING_SYM", -"HSTRING_SYM","CSTRING_SYM","UCASEFIRST_IDENT_SYM","LCASEFIRST_IDENT_SYM","NAMEDMACRO_SYM", -"MACRODEFBODY_SYM","BRACEBAL_SYM","NUMBER_ERANGE","NUMBER_SYM","SNACC_ATTRIBUTES", -"DOT_SYM","COMMA_SYM","LEFTBRACE_SYM","RIGHTBRACE_SYM","LEFTPAREN_SYM","RIGHTPAREN_SYM", -"LEFTBRACKET_SYM","RIGHTBRACKET_SYM","LESSTHAN_SYM","MINUS_SYM","GETS_SYM","BAR_SYM", -"TAGS_SYM","BOOLEAN_SYM","INTEGER_SYM","BIT_SYM","STRING_SYM","OCTET_SYM","NULL_SYM", -"SEQUENCE_SYM","OF_SYM","SET_SYM","IMPLICIT_SYM","CHOICE_SYM","ANY_SYM","OBJECT_IDENTIFIER_SYM", -"OPTIONAL_SYM","DEFAULT_SYM","COMPONENTS_SYM","UNIVERSAL_SYM","APPLICATION_SYM", -"PRIVATE_SYM","TRUE_SYM","FALSE_SYM","BEGIN_SYM","END_SYM","DEFINITIONS_SYM", -"EXPLICIT_SYM","ENUMERATED_SYM","EXPORTS_SYM","IMPORTS_SYM","REAL_SYM","INCLUDES_SYM", -"MIN_SYM","MAX_SYM","SIZE_SYM","FROM_SYM","WITH_SYM","COMPONENT_SYM","PRESENT_SYM", -"ABSENT_SYM","DEFINED_SYM","BY_SYM","PLUS_INFINITY_SYM","MINUS_INFINITY_SYM", -"SEMI_COLON_SYM","IA5STRING_SYM","PRINTABLESTRING_SYM","NUMERICSTRING_SYM","TELETEXSTRING_SYM", -"T61STRING_SYM","VIDEOTEXSTRING_SYM","VISIBLESTRING_SYM","ISO646STRING_SYM", -"GRAPHICSTRING_SYM","GENERALSTRING_SYM","GENERALIZEDTIME_SYM","UTCTIME_SYM", -"EXTERNAL_SYM","OBJECTDESCRIPTOR_SYM","OPERATION_SYM","ARGUMENT_SYM","RESULT_SYM", -"ERRORS_SYM","LINKED_SYM","ERROR_SYM","PARAMETER_SYM","BIND_SYM","BINDERROR_SYM", -"UNBIND_SYM","UNBINDERROR_SYM","ASE_SYM","OPERATIONS_SYM","CONSUMERINVOKES_SYM", -"SUPPLIERINVOKES_SYM","AC_SYM","ASES_SYM","REMOTE_SYM","INITIATOR_SYM","RESPONDER_SYM", -"ABSTRACTSYNTAXES_SYM","CONSUMER_SYM","EXTENSIONS_SYM","CHOSEN_SYM","EXTENSION_SYM", -"CRITICAL_SYM","FOR_SYM","DELIVERY_SYM","SUBMISSION_SYM","TRANSFER_SYM","EXTENSIONATTRIBUTE_SYM", -"TOKEN_SYM","TOKENDATA_SYM","SECURITYCATEGORY_SYM","OBJECT_SYM","PORTS_SYM", -"BOXC_SYM","BOXS_SYM","PORT_SYM","ABSTRACTOPS_SYM","REFINE_SYM","AS_SYM","RECURRING_SYM", -"VISIBLE_SYM","PAIRED_SYM","ABSTRACTBIND_SYM","ABSTRACTUNBIND_SYM","TO_SYM", -"ABSTRACTERROR_SYM","ABSTRACTOPERATION_SYM","ALGORITHM_SYM","ENCRYPTED_SYM", -"SIGNED_SYM","SIGNATURE_SYM","PROTECTED_SYM","OBJECTTYPE_SYM","SYNTAX_SYM","ACCESS_SYM", -"STATUS_SYM","DESCRIPTION_SYM","REFERENCE_SYM","INDEX_SYM","DEFVAL_SYM","LineNo", -"ModuleDefinition","@1","TagDefault","ModuleIdentifier","AssignedIdentifier", -"ModuleBody","Exports","SymbolsExported","ExportSymbolList","Imports","SymbolsImported", -"SymbolsFromModuleList","SymbolsFromModule","SymbolList","Symbol","AssignmentList", -"AssignmentOrError","Assignment","@2","MacroReference","TypeAssignment","ExternalTypeReference", -"DefinedType","Type","BuiltinType","NamedType","BooleanType","IntegerType","NamedNumberList", -"NamedNumber","SignedNumber","EnumeratedType","RealType","BitStringType","NamedBitList", -"NullType","SequenceOpening","SequenceType","ElementTypes","ElementTypeList", -"ElementType","SequenceOfType","SetOpening","SetType","SetOfType","ChoiceType", -"AlternativeTypes","AlternativeTypeList","SelectionType","TaggedType","Tag", -"ClassNumber","Class","AnyType","ObjectIdentifierType","Subtype","SubtypeSpec", -"SubtypeValueSetList","SubtypeValueSet","SingleValue","ContainedSubtype","ValueRange", -"LowerEndPoint","UpperEndPoint","LowerEndValue","UpperEndValue","SizeConstraint", -"PermittedAlphabet","InnerTypeConstraints","SingleTypeConstraint","MultipleTypeConstraints", -"FullSpecification","PartialSpecification","TypeConstraints","NamedConstraint", -"Constraint","ValueConstraint","PresenceConstraint","ValueAssignment","Value", -"DefinedValue","ExternalValueReference","BuiltinValue","@3","BooleanValue","SpecialRealValue", -"NullValue","NamedValue","ObjectIdentifierValue","ObjIdComponentList","ObjIdComponent", -"NumberForm","NameForm","NameAndNumberForm","BinaryString","HexString","CharString", -"number","identifier","modulereference","typereference","empty","SnaccAttributes", -"SnaccAttributeCommentList","DefinedMacroType","DefinedMacroName","RosOperationMacroType", -"RosOperationMacroBody","RosOpArgument","RosOpResult","RosOpResultType","RosOpErrors", -"RosOpLinkedOps","RosErrorMacroType","RosErrParameter","RosBindMacroType","RosBindArgument", -"RosBindResult","RosBindError","RosUnbindMacroType","RosUnbindError","RosAseMacroType", -"RosAseSymmetricAse","RosAseConsumerInvokes","RosAseSupplierInvokes","RosAseOperationList", -"RosAcMacroType","RosAcNonRoElements","RosAcRoElements","RosAcSymmetricAses", -"RosAcAsymmetricAses","RosAcInitiatorConsumerOf","RosAcResponderConsumerOf", -"RosAcAbstractSyntaxes","OidList","MtsasExtensionsMacroType","PossiblyEmptyValueList", -"ValueList","PossiblyEmptyTypeOrValueList","TypeOrValueList","TypeOrValue","MtsasExtensionMacroType", -"MtsasExtDefaultVal","MtsasExtCritical","MtsasExtCriticalityList","MtsasExtCriticality", -"MtsasExtensionAttributeMacroType","MtsasTokenMacroType","MtsasTokenDataMacroType", -"MtsasSecurityCategoryMacroType","AsnObjectMacroType","AsnPorts","AsnPortList", -"AsnPort","AsnPortType","AsnPortMacroType","AsnOperations","AsnConsumer","AsnSupplier", -"AsnRefineMacroType","AsnComponentList","AsnComponent","AsnObjectSpec","AsnPortSpecList", -"AsnPortSpec","AsnPortStatus","AsnObjectList","AsnObject","AsnAbstractBindMacroType", -"AsnAbstractBindPorts","AsnAbstractUnbindMacroType","AsnAbstractUnbindPorts", -"AsnAbstractOperationMacroType","AsnAbstractErrorMacroType","AfAlgorithmMacroType", -"AfEncryptedMacroType","AfSignedMacroType","AfSignatureMacroType","AfProtectedMacroType", -"SnmpObjectTypeMacroType","SnmpAccess","SnmpStatus","SnmpDescrPart","SnmpReferPart", -"SnmpIndexPart","SnmpDefValPart", NULL -}; -#endif - -static const short yyr1[] = { 0, - 147, 149, 148, 150, 150, 150, 151, 152, 152, 153, - 153, 154, 154, 154, 155, 155, 156, 156, 157, 157, - 157, 158, 158, 159, 159, 160, 161, 161, 162, 162, - 162, 163, 163, 164, 164, 164, 165, 165, 166, 165, - 165, 165, 167, 167, 168, 169, 170, 170, 171, 171, - 171, 171, 172, 172, 172, 172, 172, 172, 172, 172, - 172, 172, 172, 172, 172, 172, 172, 172, 173, 173, - 174, 175, 175, 176, 176, 177, 177, 178, 178, 178, - 178, 179, 180, 181, 181, 182, 183, 184, 185, 185, - 186, 187, 187, 188, 188, 188, 188, 188, 189, 190, - 191, 191, 192, 193, 194, 195, 195, 196, 197, 197, - 197, 198, 199, 199, 200, 200, 200, 200, 201, 201, - 202, 203, 203, 203, 204, 205, 205, 206, 206, 206, - 206, 206, 206, 207, 208, 209, 210, 210, 211, 211, - 212, 212, 213, 213, 214, 215, 216, 216, 217, 218, - 218, 219, 220, 221, 221, 222, 222, 223, 224, 224, - 225, 225, 225, 225, 226, 227, 227, 228, 228, 229, - 230, 230, 230, 230, 230, 230, 230, 231, 230, 232, - 232, 233, 233, 234, 235, 235, 236, 237, 237, 238, - 238, 238, 239, 240, 241, 241, 242, 243, 244, 245, - 245, 246, 247, 248, 249, 250, 250, 251, 251, 252, - 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, - 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, - 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, - 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, - 253, 253, 253, 253, 253, 253, 253, 253, 253, 254, - 255, 256, 256, 257, 257, 258, 258, 259, 259, 260, - 260, 261, 262, 262, 263, 264, 264, 265, 265, 266, - 266, 267, 268, 268, 269, 269, 270, 271, 271, 272, - 272, 273, 274, 275, 276, 276, 277, 277, 278, 279, - 279, 280, 280, 281, 281, 282, 282, 283, 284, 284, - 285, 285, 286, 286, 287, 287, 288, 288, 289, 289, - 290, 290, 291, 291, 292, 292, 293, 293, 293, 294, - 294, 295, 295, 296, 296, 297, 297, 298, 299, 299, - 300, 300, 301, 302, 302, 302, 303, 303, 304, 304, - 304, 304, 304, 305, 306, 307, 308, 308, 309, 310, - 310, 311, 311, 312, 313, 313, 314, 314, 315, 316, - 316, 317, 317, 318, 318, 319, 319, 320, 321, 322, - 323, 324, 325, 326, 327, 328, 329, 330, 330, 331, - 331, 332, 332, 333, 333 -}; - -static const short yyr2[] = { 0, - 0, 0, 8, 2, 2, 1, 2, 1, 1, 3, - 1, 3, 3, 1, 1, 1, 1, 4, 3, 3, - 1, 1, 1, 2, 1, 4, 3, 1, 1, 1, - 1, 2, 1, 1, 2, 2, 1, 1, 0, 6, - 3, 5, 1, 1, 6, 4, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, - 1, 1, 4, 1, 3, 4, 4, 1, 1, 2, - 2, 4, 1, 2, 5, 1, 1, 3, 3, 2, - 2, 1, 5, 1, 2, 3, 3, 4, 3, 3, - 3, 2, 3, 5, 2, 1, 4, 3, 2, 3, - 3, 4, 1, 1, 1, 1, 1, 1, 1, 4, - 1, 2, 4, 4, 3, 1, 3, 1, 1, 1, - 1, 1, 1, 1, 2, 4, 1, 2, 1, 2, - 1, 1, 1, 1, 2, 2, 3, 3, 1, 1, - 1, 3, 7, 1, 3, 2, 1, 2, 1, 1, - 1, 1, 1, 1, 5, 1, 1, 1, 1, 4, - 1, 1, 1, 1, 1, 1, 1, 0, 3, 1, - 1, 1, 1, 1, 1, 2, 3, 2, 1, 1, - 1, 1, 1, 1, 4, 4, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 1, 1, 1, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 4, 2, 1, 2, 1, 1, 1, 4, 1, 4, - 1, 2, 2, 1, 4, 2, 1, 2, 1, 2, - 1, 4, 2, 1, 2, 3, 4, 4, 1, 4, - 1, 1, 8, 4, 7, 1, 5, 1, 2, 6, - 1, 6, 1, 4, 1, 1, 3, 6, 1, 1, - 1, 3, 1, 1, 1, 3, 1, 1, 4, 1, - 2, 1, 3, 1, 1, 3, 1, 1, 1, 1, - 2, 1, 2, 1, 2, 1, 2, 2, 4, 1, - 1, 3, 2, 1, 1, 1, 2, 1, 4, 1, - 1, 2, 2, 4, 4, 4, 1, 3, 2, 1, - 2, 1, 3, 3, 1, 3, 1, 3, 1, 2, - 3, 4, 1, 2, 3, 4, 1, 2, 2, 3, - 2, 2, 2, 2, 11, 1, 1, 2, 0, 2, - 0, 4, 0, 4, 0 -}; - -static const short yydefact[] = { 0, - 203, 0, 205, 205, 0, 7, 8, 9, 0, 0, - 2, 6, 202, 201, 200, 0, 189, 190, 191, 192, - 193, 194, 5, 4, 0, 187, 188, 0, 0, 0, - 168, 0, 169, 0, 205, 196, 195, 1, 0, 0, - 205, 14, 0, 0, 204, 235, 236, 237, 238, 239, - 240, 242, 241, 243, 244, 245, 246, 247, 248, 249, - 250, 251, 253, 252, 254, 255, 256, 257, 258, 259, - 0, 15, 17, 30, 29, 16, 31, 3, 0, 0, - 21, 170, 13, 12, 1, 0, 0, 22, 25, 0, - 28, 23, 0, 0, 0, 33, 34, 37, 38, 0, - 0, 0, 20, 19, 24, 0, 1, 36, 0, 32, - 35, 204, 205, 71, 72, 0, 0, 87, 1, 1, - 1, 119, 121, 0, 83, 205, 205, 205, 205, 205, - 0, 0, 320, 330, 332, 334, 336, 205, 348, 0, - 205, 205, 205, 205, 0, 0, 0, 0, 0, 0, - 47, 51, 0, 50, 53, 54, 66, 67, 55, 56, - 0, 57, 58, 0, 59, 60, 61, 62, 63, 0, - 64, 65, 52, 0, 0, 48, 49, 210, 211, 212, - 213, 214, 215, 217, 216, 218, 219, 220, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, 233, 232, - 231, 234, 205, 18, 27, 0, 1, 41, 0, 43, - 44, 115, 116, 117, 0, 118, 0, 84, 68, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 263, 260, 205, 0, 274, 272, 0, 277, 205, 205, - 0, 0, 289, 285, 205, 0, 0, 0, 70, 205, - 0, 331, 333, 335, 337, 0, 340, 338, 0, 0, - 0, 347, 350, 351, 197, 198, 199, 79, 78, 178, - 0, 184, 180, 181, 182, 183, 174, 369, 167, 166, - 171, 173, 172, 176, 175, 177, 0, 0, 373, 370, - 0, 377, 374, 379, 378, 0, 381, 382, 383, 384, - 0, 0, 1, 122, 90, 0, 94, 0, 205, 92, - 0, 102, 0, 0, 0, 109, 0, 1, 208, 207, - 1, 206, 26, 39, 0, 0, 114, 113, 0, 74, - 0, 0, 99, 145, 88, 0, 103, 100, 0, 0, - 0, 0, 262, 205, 265, 205, 273, 276, 0, 279, - 205, 205, 0, 0, 0, 291, 286, 0, 0, 0, - 0, 322, 205, 69, 0, 0, 0, 0, 352, 353, - 0, 81, 80, 0, 0, 371, 0, 375, 380, 0, - 0, 142, 0, 0, 0, 126, 128, 129, 130, 0, - 137, 132, 131, 133, 134, 0, 0, 95, 0, 89, - 205, 91, 0, 101, 110, 111, 108, 0, 0, 209, - 0, 42, 112, 0, 73, 0, 86, 0, 124, 123, - 106, 0, 205, 120, 82, 266, 267, 264, 0, 269, - 205, 278, 0, 281, 275, 0, 284, 282, 311, 0, - 292, 0, 0, 0, 0, 205, 321, 0, 324, 319, - 205, 0, 341, 87, 317, 318, 169, 0, 0, 315, - 0, 0, 179, 356, 357, 0, 360, 0, 0, 0, - 135, 146, 0, 0, 125, 0, 0, 138, 165, 97, - 185, 96, 169, 1, 0, 46, 205, 40, 75, 0, - 0, 85, 104, 205, 105, 205, 0, 271, 261, 280, - 283, 287, 0, 288, 0, 294, 0, 310, 0, 309, - 0, 344, 345, 346, 343, 0, 339, 1, 0, 354, - 355, 349, 0, 205, 359, 362, 361, 372, 376, 386, - 0, 205, 148, 150, 151, 149, 147, 127, 0, 186, - 0, 98, 45, 76, 77, 0, 314, 0, 313, 205, - 312, 290, 205, 308, 329, 327, 328, 323, 325, 342, - 0, 316, 358, 0, 0, 0, 0, 159, 0, 154, - 157, 205, 205, 160, 0, 144, 136, 139, 143, 93, - 107, 268, 0, 0, 296, 205, 0, 365, 0, 364, - 363, 387, 389, 0, 205, 152, 164, 161, 162, 158, - 163, 156, 140, 270, 0, 0, 305, 293, 326, 0, - 0, 391, 0, 155, 0, 0, 366, 367, 388, 0, - 393, 205, 0, 306, 0, 0, 390, 0, 395, 0, - 205, 0, 304, 368, 0, 0, 385, 153, 0, 298, - 205, 307, 0, 0, 0, 0, 301, 295, 205, 392, - 0, 0, 0, 0, 303, 299, 394, 0, 0, 0, - 297, 0, 0, 0, 0, 300, 0, 302, 0, 0, - 0 -}; - -static const short yydefgoto[] = { 43, - 669, 25, 11, 2, 6, 40, 41, 71, 72, 80, - 87, 88, 89, 90, 91, 95, 96, 97, 411, 208, - 98, 151, 152, 249, 154, 307, 155, 156, 329, 330, - 277, 157, 158, 159, 418, 160, 161, 162, 308, 309, - 310, 163, 164, 165, 166, 167, 422, 423, 168, 169, - 170, 326, 215, 171, 172, 173, 304, 385, 386, 387, - 388, 389, 390, 577, 391, 578, 392, 393, 394, 537, - 533, 534, 535, 569, 570, 571, 572, 600, 99, 439, - 279, 31, 280, 371, 281, 282, 283, 482, 7, 16, - 17, 18, 19, 20, 284, 285, 286, 21, 33, 175, - 176, 320, 321, 322, 177, 77, 178, 232, 233, 346, - 428, 431, 499, 179, 236, 180, 239, 351, 435, 181, - 438, 182, 244, 245, 357, 440, 183, 247, 586, 641, - 648, 649, 656, 608, 625, 184, 509, 441, 548, 549, - 460, 185, 363, 450, 558, 559, 186, 187, 188, 189, - 190, 258, 452, 453, 515, 191, 262, 263, 264, 192, - 464, 465, 466, 525, 526, 590, 617, 467, 193, 290, - 194, 293, 195, 196, 197, 198, 199, 200, 201, 202, - 531, 593, 612, 621, 629, 637 -}; - -static const short yypact[] = { 66, --32768, 25, 20, -12, 117,-32768,-32768,-32768, 53, 63, --32768,-32768,-32768,-32768,-32768, 71,-32768,-32768,-32768,-32768, --32768, 77,-32768,-32768, 86,-32768,-32768, 92, 68, 82, --32768, 108,-32768, 121, 78,-32768,-32768,-32768, 630, 152, - 85, 156, 175, 147,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - 161, 188,-32768,-32768,-32768,-32768,-32768,-32768, 893, 113, --32768,-32768,-32768,-32768,-32768, 164, 165, 701,-32768, 5, --32768,-32768, 167, 190, 15,-32768, 169,-32768,-32768, 1989, - 195, 701,-32768,-32768,-32768, 701,-32768,-32768, 2045,-32768, --32768, 217, 93,-32768, 216, 205, 207,-32768, -2, -1, --32768, 174,-32768, 224,-32768, 158, 151, 159, 159, 89, - 148, 139, 1989, 1989, 1989, 1989, 1989, 128, -72, 557, - 118, 191, 151, 158, 160, 1989, 1989, 1989, 1989, 112, --32768,-32768, 42,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - 1255,-32768,-32768, 1389,-32768,-32768,-32768,-32768,-32768, 1509, --32768,-32768,-32768, 231, 240,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768, 242,-32768,-32768, 66,-32768,-32768, 243,-32768, --32768,-32768,-32768,-32768, 92,-32768, 175, 244,-32768, 1989, - 238, 245, 225, 1989, 246, 229, 248, 200, 175, 1989, --32768,-32768, 181, 1989,-32768,-32768, 1989,-32768, 182, 182, - 253, 254,-32768,-32768, 177, 260, 186, 218, 238, 239, - 1749, 238, 238, 238, 238, 265,-32768,-32768, 267, 268, - 272,-32768, 192, 197,-32768,-32768,-32768,-32768,-32768,-32768, - 183,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768, 170, 276,-32768, 1989, - 281,-32768, 1989,-32768,-32768, 1989, 238, 238, 238, 238, - 1989, 1037,-32768,-32768,-32768, 264, 168, 282, 79,-32768, - 1629,-32768, 283, 1989, 1989, 238, 1989,-32768,-32768,-32768, --32768, 288,-32768,-32768, 2102, 284,-32768,-32768, 44,-32768, - 290, 175, 238,-32768,-32768, 1989, 238,-32768, 1989, 1989, - 175, 129,-32768, 1989,-32768, 222,-32768,-32768, 1989,-32768, - 220, 219, 557, 557, 294,-32768,-32768, 557, 1989, 302, - 557,-32768, 211, 238, 557, 1121, 1121, 1121,-32768,-32768, - 315,-32768,-32768, 557, 557, 238, 557, 238, 238, -9, - 1989,-32768, 238, -24, 12,-32768,-32768,-32768,-32768, 312, - 305,-32768,-32768,-32768, 13, 557, 1989,-32768, 557,-32768, - 242,-32768, 295,-32768, 238, 238, 238, 322, 1989,-32768, - 323,-32768,-32768, 175,-32768, 111, 319, 318, 238, 238, --32768, 320, 132,-32768,-32768,-32768,-32768,-32768, 325,-32768, - 250,-32768, 1989,-32768,-32768, 1989,-32768,-32768,-32768, 326, - 321, 327, 557, 133, -3, 557,-32768, 232,-32768,-32768, - 90, 134,-32768,-32768, 238,-32768, 231, 331, 137,-32768, - 138, 141,-32768, 324,-32768, 557, 221, 145, 146, 175, - 238,-32768, 330, 238,-32768, 1037, 334,-32768,-32768, 238, --32768,-32768, 557,-32768, 1989,-32768, 73,-32768,-32768, 332, - 337,-32768,-32768, 242,-32768, 1121, 333,-32768,-32768,-32768, --32768,-32768, 557,-32768, 340,-32768, 1989,-32768, 342, 321, - 30,-32768,-32768,-32768,-32768, 557,-32768,-32768, 1121,-32768, --32768,-32768, 557, 90, 335,-32768,-32768,-32768,-32768,-32768, - 227, 55,-32768,-32768,-32768,-32768,-32768,-32768, 844,-32768, - 1869, 238,-32768,-32768,-32768, 1989,-32768, 343, 347, 1121, --32768,-32768, -4,-32768,-32768,-32768,-32768, 348,-32768,-32768, - 206,-32768,-32768, 98, 557, 175, 350,-32768, 149,-32768, --32768, 4, 238,-32768, 2239,-32768,-32768,-32768,-32768,-32768, --32768,-32768, 353, 275,-32768, 269, 30,-32768, 311,-32768, --32768,-32768, 235, 365, 27,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768, 364, 366,-32768,-32768,-32768, 557, - 557, 241, 368,-32768, 557, 20, 369,-32768,-32768, 557, - 249, 27, 370,-32768, 150, 557,-32768, 372, 255, 153, - 293, 20,-32768,-32768, 1121, 379,-32768,-32768, 352,-32768, - 298,-32768, 154, 557, 388, 300,-32768,-32768, 303,-32768, - 390, 557, 374, 306,-32768,-32768,-32768, 162, 394, 378, --32768, 557, 398, 163, 557,-32768, 166,-32768, 415, 417, --32768 -}; - -static const short yypgoto[] = { -14, --32768,-32768,-32768, 212,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768, 338,-32768, -22,-32768, 328,-32768,-32768, 94, --32768,-32768,-32768, -94,-32768, -122,-32768,-32768, -219, 6, - 11,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 257,-32768, - -113,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768, -192,-32768, -47,-32768, --32768,-32768,-32768,-32768,-32768, -144, 109,-32768,-32768,-32768, --32768,-32768,-32768, -189, -161, -138,-32768,-32768,-32768, -44, - -23,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -586,-32768, - 420, 409,-32768,-32768,-32768,-32768,-32768, 223, 569, 0, - -32, 46, -290,-32768,-32768, -101,-32768, 296,-32768,-32768, --32768,-32768,-32768,-32768, 299,-32768, 316, 201,-32768,-32768, --32768,-32768,-32768,-32768,-32768, -341,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768, -346, -106, -364, - -71,-32768,-32768,-32768,-32768, -140,-32768,-32768,-32768,-32768, --32768,-32768, -177, -67, -74,-32768,-32768, 187, 194,-32768, --32768, -70,-32768,-32768, -111,-32768,-32768, -139,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768 -}; - - -#define YYLAST 2307 - - -static const short yytable[] = { 3, - 287, 459, 461, 462, 30, 153, 75, 211, 302, 342, - 250, 444, 442, 302, 302, 93, 73, 473, 402, 106, - 45, 13, 94, 9, 259, 260, -141, 34, 334, 624, - 475, 220, 224, 13, -141, 5, 476, 474, 10, 252, - 253, 254, 255, 597, 302, 642, 75, 101, 8, 12, - 261, 297, 298, 299, 300, 75, 221, 221, 414, 302, - 415, 13, 101, -10, 107, 303, 598, 599, 567, 75, - 102, 1, 302, 75, 4, 316, 210, 13, 23, 204, - 42, 14, 15, 205, 76, 319, 81, 26, 24, 507, - 302, 319, 206, 401, 28, 278, 584, 1, 13, 510, - 36, 505, 14, 15, 222, 225, 227, 343, 209, 29, - 484, 347, 417, 93, 348, 35, 1, 13, 45, 13, - 94, 268, 269, 13, 92, 333, 37, 14, 15, 337, - 39, 470, 495, 271, 38, 212, 213, 214, 79, 34, - 555, 556, 557, 414, 319, 425, 494, 503, 516, 506, - 517, 519, 519, 520, 521, 519, 364, 522, 216, 516, - 516, 528, 529, 595, 632, 596, 633, 595, 519, 638, - 650, 231, 235, 238, 238, 243, 503, 503, 661, 666, - 503, 13, 668, 257, 241, 242, 289, 292, 235, 231, - 472, 327, 324, 372, 373, 376, 543, 468, 378, 469, - 78, 379, 85, 546, -11, 3, 380, 398, 399, 512, - 513, 45, 13, 109, 34, 83, 364, 421, 203, 405, - 406, 426, 407, 211, 588, 589, 432, 223, 226, 84, - -203, 217, 103, 104, 218, 108, 219, 111, 228, 229, - 234, 419, 230, 237, 420, 248, 256, 246, 288, 296, - 291, 301, 317, 318, 319, 302, 325, 395, 336, 332, - 335, 338, 339, 340, 445, 341, 344, 349, 353, 354, - 643, 455, 455, 455, 355, 358, 359, 360, 345, 361, - 365, 536, 366, 367, 350, 350, 471, 368, 396, 260, - 356, 375, 210, 259, 374, 362, 377, 397, 400, 404, - 410, 34, 480, 408, 413, 658, 409, 416, 429, 443, - 500, 433, 436, 501, 487, 664, 447, 446, 667, 448, - 451, 456, 456, 456, 463, 477, 478, 45, 485, 278, - 451, 488, 451, 414, 492, 503, 493, 497, 523, 568, - 496, 511, 502, 504, 518, 532, 527, 539, 550, 565, - 544, 479, 34, 34, 481, 545, 552, 34, 554, 582, - 34, 519, 587, 594, 34, 458, 458, 458, 566, 604, - 605, 610, 606, 34, 34, 486, 34, 611, 613, 615, - 568, 616, 622, 626, 620, 645, 631, 635, 639, 427, - 542, 430, 491, 628, 644, 34, 434, 437, 34, 646, - 636, 455, 568, 652, 653, 654, 657, 659, 449, 662, - 660, 663, 553, 665, 670, 34, 671, 323, 412, 489, - 313, 524, 110, 581, 455, 105, 490, 580, 538, 568, - 603, 395, 630, 614, 602, 27, 32, 328, 540, 295, - 352, 294, 34, 583, 240, 34, 609, 562, 560, 564, - 370, 456, 563, 591, 0, 455, 369, 0, 551, 0, - 0, 0, 0, 0, 0, 34, 0, 0, 0, 541, - 618, 451, 0, 0, 456, 34, 498, 0, 278, 0, - 0, 0, 34, 0, 0, 0, 634, 0, 0, 0, - 0, 508, 0, 0, 579, 458, 514, 0, 0, 0, - 0, 0, 34, 561, 0, 456, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 34, 0, 0, 458, 0, - 524, 0, 34, 0, 0, 0, 0, 0, 486, 0, - 579, 0, 0, 0, 0, 0, 0, 0, 34, 0, - 455, 547, 0, 0, 0, 0, 0, 0, 0, 458, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 265, - 266, 267, 1, 13, 34, 278, 619, 268, 269, 514, - 623, 0, 270, 22, 34, 627, 0, 574, 0, 271, - 0, 278, 0, 0, 22, 0, 0, 0, 272, 0, - 456, 0, 0, 0, 0, 547, 0, 0, 585, 651, - 0, 0, 273, 274, 0, 0, 0, 74, 0, 34, - 34, 82, 0, 0, 34, 0, 0, 601, 574, 34, - 0, 0, 0, 275, 276, 34, 0, 0, 0, 0, - 44, 607, 0, 0, 458, 45, 13, 0, 0, 0, - 574, 0, 0, 34, 0, 0, 0, 74, 100, 0, - 0, 34, 0, 0, 0, 0, 74, 0, 0, 0, - 0, 34, 0, 100, 34, 0, 0, 574, 174, 0, - 74, 0, 0, 0, 74, 0, 640, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 647, 0, 0, 0, - 0, 0, 0, 0, 655, 0, 0, 0, -205, 0, - 0, 251, 174, 174, 174, 174, 45, 13, 0, 0, - 0, 0, 0, 46, 174, 174, 174, 174, 47, 0, - 48, 0, 49, 0, 50, 0, 0, 0, 51, 311, - 0, 0, 311, 0, 0, 52, 0, 53, 174, 0, - 0, 0, 0, 54, 55, 56, 57, 58, 0, 0, - 0, 59, 0, 60, 0, 0, 0, 0, 61, 62, - 0, 63, 64, 65, 66, 67, 68, 69, 70, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 46, 331, 0, 0, 174, 47, - 0, 48, 174, 49, 0, 50, 0, 331, 251, 51, - 0, 0, 251, 0, 0, 251, 52, 0, 53, 0, - 0, 0, 0, 0, 54, 55, 56, 57, 58, 174, - 0, 0, 59, 0, 60, 0, 0, 0, 0, 61, - 62, 0, 63, 64, 65, 66, 67, 68, 69, 70, - 0, 0, 0, 0, 0, 0, 265, 266, 267, 1, - 13, 0, 0, 0, 268, 269, 0, 0, 174, 270, - 0, 174, 0, 0, 174, 575, 271, 0, 0, 174, - 0, 0, 0, 0, 0, 272, 0, 0, 0, 174, - 0, 0, 174, 174, 0, 174, 0, 0, 0, 273, - 274, 0, 0, 86, 0, 0, 0, 0, 45, 13, - 331, 576, 0, 0, 174, 0, 0, 174, 251, 424, - 275, 276, 251, 0, 0, 0, 0, 251, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 174, 0, 0, - 0, 0, 0, 0, 457, 457, 457, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 174, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -205, 0, 0, 0, 174, 0, 483, 0, 0, - 0, 0, 0, 0, 0, 0, 46, 174, 0, 0, - 0, 47, 331, 48, 0, 49, 0, 50, 0, 0, - 0, 51, 0, 0, 0, 0, 0, 0, 52, 0, - 53, 251, 0, 0, 251, 0, 54, 55, 56, 57, - 58, 0, 0, 0, 59, 0, 60, 0, 0, 0, - 0, 61, 62, 0, 63, 64, 65, 66, 67, 68, - 69, 70, 0, 0, 0, 0, 0, 0, 530, 265, - 266, 267, 1, 13, 0, 0, 0, 268, 269, 0, - 0, 0, 270, 174, 0, 0, 0, 0, 0, 271, - 0, 0, 0, 0, 457, 0, 0, 0, 272, 0, - 0, 0, 0, 0, 0, 174, 0, 0, 0, 0, - 0, 0, 273, 274, 0, 0, 0, 457, 0, 0, - 0, 0, 381, 382, 0, 221, 383, 384, 0, 0, - 573, 0, 0, 275, 276, 0, 0, 0, 0, 311, - 0, 0, 0, 0, 251, 0, 0, 0, 457, 0, - 0, 0, 0, 265, 266, 267, 112, 13, 0, 82, - 0, 268, 269, 0, 592, 0, 270, 0, 0, 0, - 113, 0, 0, 271, 0, 0, 0, 114, 115, 116, - 0, 117, 454, 119, 0, 120, 0, 121, 122, 123, - 0, 0, 0, 573, 0, 0, 273, 274, 0, 0, - 0, 0, 124, 0, 0, 125, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 275, 276, 0, - 573, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 457, 126, 0, 0, 0, 0, 127, - 0, 128, 0, 129, 0, 130, 0, 0, 0, 131, - 0, 0, 0, 0, 0, 0, 132, 0, 133, 0, - 0, 0, 0, 0, 134, 135, 136, 137, 138, 0, - 0, 0, 139, 0, 140, 0, 0, 0, 0, 141, - 142, 0, 143, 144, 145, 146, 147, 148, 149, 150, - 112, 13, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 305, 0, 0, 113, 0, 0, 0, 0, 0, - 0, 114, 115, 116, 0, 117, 118, 119, 0, 120, - 0, 121, 122, 123, 0, 0, 306, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 124, 0, 0, 125, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 126, 0, - 0, 0, 0, 127, 0, 128, 0, 129, 0, 130, - 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, - 132, 0, 133, 0, 0, 0, 0, 0, 134, 135, - 136, 137, 138, 0, 0, 0, 139, 0, 140, 0, - 0, 0, 0, 141, 142, 0, 143, 144, 145, 146, - 147, 148, 149, 150, 112, 13, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 312, 0, 0, 113, 0, - 0, 0, 0, 0, 0, 114, 115, 116, 0, 117, - 118, 119, 0, 120, 0, 121, 122, 123, 0, 0, - 306, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 124, 0, 0, 125, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 126, 0, 0, 0, 0, 127, 0, 128, - 0, 129, 0, 130, 0, 0, 0, 131, 0, 0, - 0, 0, 0, 0, 132, 0, 133, 0, 0, 0, - 0, 0, 134, 135, 136, 137, 138, 0, 0, 0, - 139, 0, 140, 0, 112, 13, 0, 141, 142, 0, - 143, 144, 145, 146, 147, 148, 149, 150, 113, 0, - 0, 0, 0, 0, 0, 114, 115, 116, 0, 117, - 118, 119, 0, 120, 314, 121, 122, 123, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 315, - 124, 0, 0, 125, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 126, 0, 0, 0, 0, 127, 0, 128, - 0, 129, 0, 130, 0, 0, 0, 131, 0, 0, - 0, 0, 0, 0, 132, 0, 133, 0, 0, 0, - 0, 0, 134, 135, 136, 137, 138, 0, 0, 0, - 139, 0, 140, 0, 112, 13, 0, 141, 142, 0, - 143, 144, 145, 146, 147, 148, 149, 150, 113, 0, - 317, 0, 0, 0, 0, 114, 115, 116, 0, 117, - 118, 119, 0, 120, 0, 121, 122, 123, 0, 0, - 403, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 124, 0, 0, 125, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 126, 0, 0, 0, 0, 127, 0, 128, - 0, 129, 0, 130, 0, 0, 0, 131, 0, 0, - 0, 0, 0, 0, 132, 0, 133, 0, 0, 0, - 0, 0, 134, 135, 136, 137, 138, 0, 0, 0, - 139, 0, 140, 0, 112, 13, 0, 141, 142, 0, - 143, 144, 145, 146, 147, 148, 149, 150, 113, 0, - 317, 0, 0, 0, 0, 114, 115, 116, 0, 117, - 118, 119, 0, 120, 0, 121, 122, 123, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 124, 0, 0, 125, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 126, 0, 0, 0, 0, 127, 0, 128, - 0, 129, 0, 130, 0, 0, 0, 131, 0, 0, - 0, 0, 0, 0, 132, 0, 133, 0, 0, 0, - 0, 0, 134, 135, 136, 137, 138, 0, 0, 0, - 139, 0, 140, 0, 112, 13, 0, 141, 142, 0, - 143, 144, 145, 146, 147, 148, 149, 150, 113, 0, - 0, 0, 0, 0, 0, 114, 115, 116, 0, 117, - 118, 119, 0, 120, 0, 121, 122, 123, 0, 0, - 306, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 124, 0, 0, 125, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 126, 0, 0, 0, 0, 127, 0, 128, - 0, 129, 0, 130, 0, 0, 0, 131, 0, 0, - 0, 0, 0, 0, 132, 0, 133, 0, 0, 0, - 0, 0, 134, 135, 136, 137, 138, 0, 0, 0, - 139, 0, 140, 0, 112, 13, 0, 141, 142, 0, - 143, 144, 145, 146, 147, 148, 149, 150, 113, 0, - 0, 0, 0, 0, 0, 114, 115, 116, 0, 117, - 118, 119, 0, 120, 0, 121, 122, 123, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 124, 0, 0, 125, 0, 0, 0, 0, 0, 0, - 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 126, 0, 0, 0, 0, 127, 0, 128, - 0, 129, 0, 130, 0, 0, 0, 131, 0, 0, - 0, 0, 207, 0, 132, 0, 133, 0, 0, 0, - 0, 0, 134, 135, 136, 137, 138, 45, 0, 0, - 139, 0, 140, 0, 0, 0, 0, 141, 142, 0, - 143, 144, 145, 146, 147, 148, 149, 150, 46, 0, - 0, 0, 0, 47, 0, 48, 0, 49, 0, 50, - 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, - 52, 0, 53, 0, 0, 0, 0, 0, 54, 55, - 56, 57, 58, 0, 0, 0, 59, 0, 60, 0, - 0, 0, 0, 61, 62, 0, 63, 64, 65, 66, - 67, 68, 69, 70, 0, 46, 0, 0, 0, 0, - 47, 0, 48, 0, 49, 0, 50, 0, 0, 0, - 51, 0, 0, 0, 0, 0, 0, 52, 0, 53, - 0, 0, 0, 0, 0, 54, 55, 56, 57, 58, - 0, 0, 0, 59, 0, 60, 0, 0, 0, 0, - 61, 62, 0, 63, 64, 65, 66, 67, 68, 69, - 70, 265, 266, 267, 1, 13, 0, 0, 0, 268, - 269, 0, 0, 0, 270, 0, 0, 0, 0, 0, - 0, 271, 0, 0, 0, 0, 0, 0, 0, 0, - 272, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 273, 274, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 576, 0, 0, 0, - 0, 0, 0, 0, 0, 275, 276 -}; - -static const short yycheck[] = { 0, - 140, 366, 367, 368, 28, 100, 39, 109, 18, 229, - 133, 358, 354, 18, 18, 1, 39, 42, 309, 15, - 6, 7, 8, 36, 97, 98, 14, 28, 221, 616, - 19, 34, 34, 7, 22, 16, 25, 62, 51, 134, - 135, 136, 137, 40, 18, 632, 79, 80, 3, 4, - 123, 146, 147, 148, 149, 88, 59, 59, 15, 18, - 17, 7, 95, 49, 60, 24, 63, 64, 14, 102, - 85, 6, 18, 106, 50, 170, 109, 7, 26, 102, - 35, 11, 12, 106, 39, 13, 41, 17, 26, 93, - 18, 13, 107, 15, 18, 140, 101, 6, 7, 446, - 19, 443, 11, 12, 119, 120, 121, 230, 109, 24, - 401, 234, 332, 1, 237, 48, 6, 7, 6, 7, - 8, 11, 12, 7, 79, 220, 19, 11, 12, 224, - 53, 141, 423, 23, 14, 43, 44, 45, 54, 140, - 111, 112, 113, 15, 13, 17, 15, 15, 15, 17, - 17, 15, 15, 17, 17, 15, 251, 17, 113, 15, - 15, 17, 17, 15, 15, 17, 17, 15, 15, 17, - 17, 126, 127, 128, 129, 130, 15, 15, 17, 17, - 15, 7, 17, 138, 96, 97, 141, 142, 143, 144, - 383, 215, 207, 11, 12, 290, 487, 375, 293, 377, - 49, 296, 15, 494, 49, 206, 301, 40, 41, 120, - 121, 6, 7, 24, 215, 69, 311, 340, 24, 314, - 315, 344, 317, 325, 127, 128, 349, 119, 120, 69, - 14, 16, 69, 69, 30, 69, 30, 69, 65, 16, - 90, 336, 85, 85, 339, 107, 119, 100, 131, 90, - 60, 140, 22, 14, 13, 18, 14, 302, 34, 16, - 16, 16, 34, 16, 359, 66, 86, 86, 16, 16, - 635, 366, 367, 368, 98, 16, 91, 60, 233, 41, - 16, 474, 16, 16, 239, 240, 381, 16, 303, 98, - 245, 16, 325, 97, 125, 250, 16, 34, 17, 17, - 13, 302, 397, 318, 21, 652, 321, 18, 87, 16, - 433, 92, 94, 436, 409, 662, 361, 16, 665, 109, - 365, 366, 367, 368, 10, 14, 22, 6, 34, 374, - 375, 9, 377, 15, 17, 15, 17, 88, 15, 532, - 16, 110, 17, 17, 14, 16, 126, 14, 16, 15, - 19, 396, 353, 354, 399, 19, 17, 358, 17, 17, - 361, 15, 15, 14, 365, 366, 367, 368, 142, 17, - 96, 61, 104, 374, 375, 408, 377, 143, 14, 16, - 573, 16, 15, 15, 144, 34, 17, 16, 96, 344, - 485, 346, 416, 145, 16, 396, 351, 352, 399, 102, - 146, 496, 595, 16, 105, 103, 17, 34, 363, 16, - 105, 34, 507, 16, 0, 416, 0, 206, 325, 414, - 164, 466, 95, 546, 519, 88, 416, 541, 476, 622, - 575, 476, 622, 595, 573, 16, 28, 215, 483, 144, - 240, 143, 443, 550, 129, 446, 587, 519, 516, 524, - 264, 496, 523, 565, -1, 550, 263, -1, 503, -1, - -1, -1, -1, -1, -1, 466, -1, -1, -1, 484, - 610, 516, -1, -1, 519, 476, 431, -1, 523, -1, - -1, -1, 483, -1, -1, -1, 626, -1, -1, -1, - -1, 446, -1, -1, 539, 496, 451, -1, -1, -1, - -1, -1, 503, 518, -1, 550, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 516, -1, -1, 519, -1, - 565, -1, 523, -1, -1, -1, -1, -1, 561, -1, - 575, -1, -1, -1, -1, -1, -1, -1, 539, -1, - 635, 496, -1, -1, -1, -1, -1, -1, -1, 550, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, - 4, 5, 6, 7, 565, 610, 611, 11, 12, 524, - 615, -1, 16, 5, 575, 620, -1, 532, -1, 23, - -1, 626, -1, -1, 16, -1, -1, -1, 32, -1, - 635, -1, -1, -1, -1, 550, -1, -1, 553, 644, - -1, -1, 46, 47, -1, -1, -1, 39, -1, 610, - 611, 43, -1, -1, 615, -1, -1, 572, 573, 620, - -1, -1, -1, 67, 68, 626, -1, -1, -1, -1, - 1, 586, -1, -1, 635, 6, 7, -1, -1, -1, - 595, -1, -1, 644, -1, -1, -1, 79, 80, -1, - -1, 652, -1, -1, -1, -1, 88, -1, -1, -1, - -1, 662, -1, 95, 665, -1, -1, 622, 100, -1, - 102, -1, -1, -1, 106, -1, 631, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 641, -1, -1, -1, - -1, -1, -1, -1, 649, -1, -1, -1, 69, -1, - -1, 133, 134, 135, 136, 137, 6, 7, -1, -1, - -1, -1, -1, 84, 146, 147, 148, 149, 89, -1, - 91, -1, 93, -1, 95, -1, -1, -1, 99, 161, - -1, -1, 164, -1, -1, 106, -1, 108, 170, -1, - -1, -1, -1, 114, 115, 116, 117, 118, -1, -1, - -1, 122, -1, 124, -1, -1, -1, -1, 129, 130, - -1, 132, 133, 134, 135, 136, 137, 138, 139, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 84, 217, -1, -1, 220, 89, - -1, 91, 224, 93, -1, 95, -1, 229, 230, 99, - -1, -1, 234, -1, -1, 237, 106, -1, 108, -1, - -1, -1, -1, -1, 114, 115, 116, 117, 118, 251, - -1, -1, 122, -1, 124, -1, -1, -1, -1, 129, - 130, -1, 132, 133, 134, 135, 136, 137, 138, 139, - -1, -1, -1, -1, -1, -1, 3, 4, 5, 6, - 7, -1, -1, -1, 11, 12, -1, -1, 290, 16, - -1, 293, -1, -1, 296, 22, 23, -1, -1, 301, - -1, -1, -1, -1, -1, 32, -1, -1, -1, 311, - -1, -1, 314, 315, -1, 317, -1, -1, -1, 46, - 47, -1, -1, 1, -1, -1, -1, -1, 6, 7, - 332, 58, -1, -1, 336, -1, -1, 339, 340, 341, - 67, 68, 344, -1, -1, -1, -1, 349, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 359, -1, -1, - -1, -1, -1, -1, 366, 367, 368, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 381, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 69, -1, -1, -1, 397, -1, 399, -1, -1, - -1, -1, -1, -1, -1, -1, 84, 409, -1, -1, - -1, 89, 414, 91, -1, 93, -1, 95, -1, -1, - -1, 99, -1, -1, -1, -1, -1, -1, 106, -1, - 108, 433, -1, -1, 436, -1, 114, 115, 116, 117, - 118, -1, -1, -1, 122, -1, 124, -1, -1, -1, - -1, 129, 130, -1, 132, 133, 134, 135, 136, 137, - 138, 139, -1, -1, -1, -1, -1, -1, 470, 3, - 4, 5, 6, 7, -1, -1, -1, 11, 12, -1, - -1, -1, 16, 485, -1, -1, -1, -1, -1, 23, - -1, -1, -1, -1, 496, -1, -1, -1, 32, -1, - -1, -1, -1, -1, -1, 507, -1, -1, -1, -1, - -1, -1, 46, 47, -1, -1, -1, 519, -1, -1, - -1, -1, 56, 57, -1, 59, 60, 61, -1, -1, - 532, -1, -1, 67, 68, -1, -1, -1, -1, 541, - -1, -1, -1, -1, 546, -1, -1, -1, 550, -1, - -1, -1, -1, 3, 4, 5, 6, 7, -1, 561, - -1, 11, 12, -1, 566, -1, 16, -1, -1, -1, - 20, -1, -1, 23, -1, -1, -1, 27, 28, 29, - -1, 31, 32, 33, -1, 35, -1, 37, 38, 39, - -1, -1, -1, 595, -1, -1, 46, 47, -1, -1, - -1, -1, 52, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 67, 68, -1, - 622, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 635, 84, -1, -1, -1, -1, 89, - -1, 91, -1, 93, -1, 95, -1, -1, -1, 99, - -1, -1, -1, -1, -1, -1, 106, -1, 108, -1, - -1, -1, -1, -1, 114, 115, 116, 117, 118, -1, - -1, -1, 122, -1, 124, -1, -1, -1, -1, 129, - 130, -1, 132, 133, 134, 135, 136, 137, 138, 139, - 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 17, -1, -1, 20, -1, -1, -1, -1, -1, - -1, 27, 28, 29, -1, 31, 32, 33, -1, 35, - -1, 37, 38, 39, -1, -1, 42, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 52, -1, -1, 55, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 84, -1, - -1, -1, -1, 89, -1, 91, -1, 93, -1, 95, - -1, -1, -1, 99, -1, -1, -1, -1, -1, -1, - 106, -1, 108, -1, -1, -1, -1, -1, 114, 115, - 116, 117, 118, -1, -1, -1, 122, -1, 124, -1, - -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, - 136, 137, 138, 139, 6, 7, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 17, -1, -1, 20, -1, - -1, -1, -1, -1, -1, 27, 28, 29, -1, 31, - 32, 33, -1, 35, -1, 37, 38, 39, -1, -1, - 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 52, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 84, -1, -1, -1, -1, 89, -1, 91, - -1, 93, -1, 95, -1, -1, -1, 99, -1, -1, - -1, -1, -1, -1, 106, -1, 108, -1, -1, -1, - -1, -1, 114, 115, 116, 117, 118, -1, -1, -1, - 122, -1, 124, -1, 6, 7, -1, 129, 130, -1, - 132, 133, 134, 135, 136, 137, 138, 139, 20, -1, - -1, -1, -1, -1, -1, 27, 28, 29, -1, 31, - 32, 33, -1, 35, 36, 37, 38, 39, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, - 52, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 84, -1, -1, -1, -1, 89, -1, 91, - -1, 93, -1, 95, -1, -1, -1, 99, -1, -1, - -1, -1, -1, -1, 106, -1, 108, -1, -1, -1, - -1, -1, 114, 115, 116, 117, 118, -1, -1, -1, - 122, -1, 124, -1, 6, 7, -1, 129, 130, -1, - 132, 133, 134, 135, 136, 137, 138, 139, 20, -1, - 22, -1, -1, -1, -1, 27, 28, 29, -1, 31, - 32, 33, -1, 35, -1, 37, 38, 39, -1, -1, - 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 52, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 84, -1, -1, -1, -1, 89, -1, 91, - -1, 93, -1, 95, -1, -1, -1, 99, -1, -1, - -1, -1, -1, -1, 106, -1, 108, -1, -1, -1, - -1, -1, 114, 115, 116, 117, 118, -1, -1, -1, - 122, -1, 124, -1, 6, 7, -1, 129, 130, -1, - 132, 133, 134, 135, 136, 137, 138, 139, 20, -1, - 22, -1, -1, -1, -1, 27, 28, 29, -1, 31, - 32, 33, -1, 35, -1, 37, 38, 39, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 52, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 84, -1, -1, -1, -1, 89, -1, 91, - -1, 93, -1, 95, -1, -1, -1, 99, -1, -1, - -1, -1, -1, -1, 106, -1, 108, -1, -1, -1, - -1, -1, 114, 115, 116, 117, 118, -1, -1, -1, - 122, -1, 124, -1, 6, 7, -1, 129, 130, -1, - 132, 133, 134, 135, 136, 137, 138, 139, 20, -1, - -1, -1, -1, -1, -1, 27, 28, 29, -1, 31, - 32, 33, -1, 35, -1, 37, 38, 39, -1, -1, - 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 52, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 84, -1, -1, -1, -1, 89, -1, 91, - -1, 93, -1, 95, -1, -1, -1, 99, -1, -1, - -1, -1, -1, -1, 106, -1, 108, -1, -1, -1, - -1, -1, 114, 115, 116, 117, 118, -1, -1, -1, - 122, -1, 124, -1, 6, 7, -1, 129, 130, -1, - 132, 133, 134, 135, 136, 137, 138, 139, 20, -1, - -1, -1, -1, -1, -1, 27, 28, 29, -1, 31, - 32, 33, -1, 35, -1, 37, 38, 39, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 52, -1, -1, 55, -1, -1, -1, -1, -1, -1, - 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 84, -1, -1, -1, -1, 89, -1, 91, - -1, 93, -1, 95, -1, -1, -1, 99, -1, -1, - -1, -1, 48, -1, 106, -1, 108, -1, -1, -1, - -1, -1, 114, 115, 116, 117, 118, 6, -1, -1, - 122, -1, 124, -1, -1, -1, -1, 129, 130, -1, - 132, 133, 134, 135, 136, 137, 138, 139, 84, -1, - -1, -1, -1, 89, -1, 91, -1, 93, -1, 95, - -1, -1, -1, 99, -1, -1, -1, -1, -1, -1, - 106, -1, 108, -1, -1, -1, -1, -1, 114, 115, - 116, 117, 118, -1, -1, -1, 122, -1, 124, -1, - -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, - 136, 137, 138, 139, -1, 84, -1, -1, -1, -1, - 89, -1, 91, -1, 93, -1, 95, -1, -1, -1, - 99, -1, -1, -1, -1, -1, -1, 106, -1, 108, - -1, -1, -1, -1, -1, 114, 115, 116, 117, 118, - -1, -1, -1, 122, -1, 124, -1, -1, -1, -1, - 129, 130, -1, 132, 133, 134, 135, 136, 137, 138, - 139, 3, 4, 5, 6, 7, -1, -1, -1, 11, - 12, -1, -1, -1, 16, -1, -1, -1, -1, -1, - -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, - 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 58, -1, -1, -1, - -1, -1, -1, -1, -1, 67, 68 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/local/lib/bison.simple" - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. - - 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) -#include -#else /* not sparc */ -#if defined (MSDOS) && !defined (__TURBOC__) -#include -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -#include - #pragma alloca -#else /* not MSDOS, __TURBOC__, or _AIX */ -#ifdef __hpux -#ifdef __cplusplus -extern "C" { -void *alloca (unsigned int); -}; -#else /* not __cplusplus */ -void *alloca (); -#endif /* not __cplusplus */ -#endif /* __hpux */ -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc. */ -#endif /* not GNU C. */ -#endif /* alloca not defined. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT return(0) -#define YYABORT return(1) -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -int yyparse (void); -#endif - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *to, char *from, int count) -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -#line 196 "/usr/local/lib/bison.simple" - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - int yystacksize = YYINITDEPTH; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); - yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto yybackup; - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { - -case 1: -#line 461 "core/parse-asn1.y" -{ yyval.intVal = myLineNoG; ; - break;} -case 2: -#line 466 "core/parse-asn1.y" -{ modulePtrG->tagDefault = yyvsp[0].intVal; ; - break;} -case 3: -#line 471 "core/parse-asn1.y" -{ - modulePtrG->modId = yyvsp[-7].moduleId; - - /* - * Set exported flags in type/value defs as appropriate - */ - SetExports (modulePtrG, exportListG, exportsParsedG); - - /* clean up */ - - /* Free Application tag list */ - FreeApplTags(); - - /* - * Add values defined in any parsed object identifiers. - * Only the Module name and some macro oids have been parsed, - * the rest are just "{...}" strings at this point - * (they will be parsed in later) - */ - modulePtrG->valueDefs = - AsnListConcat (modulePtrG->valueDefs, oidElmtValDefsG); - - /* - * free list head only - */ - Free (oidElmtValDefsG); - ; - break;} -case 4: -#line 501 "core/parse-asn1.y" -{ yyval.intVal = EXPLICIT_TAGS; ; - break;} -case 5: -#line 502 "core/parse-asn1.y" -{ yyval.intVal = IMPLICIT_TAGS; ; - break;} -case 6: -#line 504 "core/parse-asn1.y" -{ - /* default is EXPLICIT TAGS */ - yyval.intVal = EXPLICIT_TAGS; - ; - break;} -case 7: -#line 512 "core/parse-asn1.y" -{ - yyval.moduleId = MT (ModuleId); - yyval.moduleId->name = yyvsp[-1].charPtr; - yyval.moduleId->oid = yyvsp[0].oidPtr; - ; - break;} -case 9: -#line 521 "core/parse-asn1.y" -{ yyval.oidPtr = NULL; ; - break;} -case 12: -#line 531 "core/parse-asn1.y" -{ - /* - * allows differentiation between "EXPORTS;" - * (in which no exports allowed) - * and when the EXPORTS symbol does not appear - * (then all are exported) - */ - exportsParsedG = TRUE; - ; - break;} -case 13: -#line 541 "core/parse-asn1.y" -{ - PARSE_ERROR(); - exportsParsedG = FALSE; - exportListG = NULL; - yyerrok; - ; - break;} -case 14: -#line 547 "core/parse-asn1.y" -{ exportsParsedG = FALSE; ; - break;} -case 15: -#line 551 "core/parse-asn1.y" -{ exportListG = yyvsp[0].exportList; ; - break;} -case 16: -#line 552 "core/parse-asn1.y" -{ exportListG = NULL; ; - break;} -case 17: -#line 557 "core/parse-asn1.y" -{ - yyval.exportList = MT (ExportElmt); - yyval.exportList->name = yyvsp[0].charPtr; - yyval.exportList->lineNo = myLineNoG; - yyval.exportList->next = NULL; - ; - break;} -case 18: -#line 564 "core/parse-asn1.y" -{ - yyval.exportList = MT (ExportElmt); - yyval.exportList->name = yyvsp[0].charPtr; - yyval.exportList->next = yyvsp[-3].exportList; - yyval.exportList->lineNo = yyvsp[-1].intVal; - ; - break;} -case 20: -#line 575 "core/parse-asn1.y" -{ - PARSE_ERROR(); - yyerrok; - ; - break;} -case 22: -#line 583 "core/parse-asn1.y" -{ modulePtrG->imports = yyvsp[0].importModuleListPtr; ; - break;} -case 24: -#line 589 "core/parse-asn1.y" -{ - APPEND (yyvsp[0].importModulePtr,yyvsp[-1].importModuleListPtr); - ; - break;} -case 25: -#line 593 "core/parse-asn1.y" -{ - yyval.importModuleListPtr = NEWLIST(); - APPEND (yyvsp[0].importModulePtr, yyval.importModuleListPtr); - ; - break;} -case 26: -#line 601 "core/parse-asn1.y" -{ - yyval.importModulePtr = MT (ImportModule); - yyval.importModulePtr->modId = yyvsp[0].moduleId; - yyval.importModulePtr->lineNo = yyvsp[-1].intVal; - yyval.importModulePtr->importElmts = yyvsp[-3].importElmtListPtr; - ; - break;} -case 27: -#line 612 "core/parse-asn1.y" -{ - ImportElmt *ie; - - ie = MT (ImportElmt); - ie->name = yyvsp[0].charPtr; - ie->lineNo = myLineNoG; - APPEND (ie, yyvsp[-2].importElmtListPtr); - yyval.importElmtListPtr = yyvsp[-2].importElmtListPtr; - ; - break;} -case 28: -#line 622 "core/parse-asn1.y" -{ - ImportElmt *ie; - - /* called for the first element only, so create list head */ - yyval.importElmtListPtr = NEWLIST(); - ie = MT (ImportElmt); - ie->name = yyvsp[0].charPtr; - ie->lineNo = myLineNoG; - APPEND (ie, yyval.importElmtListPtr); - ; - break;} -case 31: -#line 638 "core/parse-asn1.y" -{ - /* - * hack to make DefinedMacroNames "freeable" - * like idents and typeref - */ - yyval.charPtr = Malloc (strlen (yyvsp[0].charPtr)+1); - strcpy (yyval.charPtr, yyvsp[0].charPtr); - ; - break;} -case 36: -#line 659 "core/parse-asn1.y" -{ - PARSE_ERROR(); - yyerrok; - ; - break;} -case 37: -#line 667 "core/parse-asn1.y" -{ - /* - * a macro may produce a null type - */ - if (yyvsp[0].typeDefPtr != NULL) - { - /* - * add to head of type def list - */ - APPEND (yyvsp[0].typeDefPtr, modulePtrG->typeDefs); - } - - ; - break;} -case 38: -#line 681 "core/parse-asn1.y" -{ - /* - * a macro may produce a null value - */ - if (yyvsp[0].valueDefPtr != NULL) - { - /* - * add to head of value def list - */ - APPEND (yyvsp[0].valueDefPtr, modulePtrG->valueDefs); - } - ; - break;} -case 39: -#line 693 "core/parse-asn1.y" -{ LexBeginMacroDefContext(); ; - break;} -case 40: -#line 695 "core/parse-asn1.y" -{ - TypeDef *tmpTypeDef; - - /* - * LEXICAL TIE IN!! - * create macro type to eliminate import resolution - * errors msgs from other modules importing the macro. - * (hopefully) Only the import list will link with - * these type defs. - * keeps macro def around incase of future processing needs - * - * NOTE: MACRODEFBODY_SYM returns the macro def body with - * with "BEGIN" at the begininning and "END" at the end - */ - - /* - * put lexical analyzer back in normal state - */ - /* BEGIN (INITIAL); */ - LexBeginInitialContext(); - - tmpTypeDef = MT (TypeDef); - SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, yyvsp[-2].intVal); - tmpTypeDef->definedName = yyvsp[-5].charPtr; - - /* - * keeps the macro def body - * (all text between & including the BEGIN and END) - * as a simple string - incase you want to fart around with - * it. - */ - tmpTypeDef->type->basicType->a.macroDef = yyvsp[0].charPtr; - - /* - * put in type list - */ - APPEND (tmpTypeDef, modulePtrG->typeDefs); - - ; - break;} -case 41: -#line 735 "core/parse-asn1.y" -{ - TypeDef *tmpTypeDef; - - tmpTypeDef = MT (TypeDef); - SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, myLineNoG); - tmpTypeDef->definedName = yyvsp[-2].charPtr; - - tmpTypeDef->type->basicType->a.macroDef = yyvsp[0].charPtr; - - /* - * put in type list - */ - APPEND (tmpTypeDef, modulePtrG->typeDefs); - - ; - break;} -case 42: -#line 751 "core/parse-asn1.y" -{ - TypeDef *tmpTypeDef; - - tmpTypeDef = MT (TypeDef); - SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, myLineNoG); - tmpTypeDef->definedName = yyvsp[-4].charPtr; - - tmpTypeDef->type->basicType->a.macroDef = - (MyString) Malloc (strlen (yyvsp[-2].charPtr) + strlen (yyvsp[0].charPtr) + 2); - - strcpy (tmpTypeDef->type->basicType->a.macroDef, yyvsp[-2].charPtr); - strcat (tmpTypeDef->type->basicType->a.macroDef, "."); - strcat (tmpTypeDef->type->basicType->a.macroDef, yyvsp[0].charPtr); - - /* - * put in type list - */ - APPEND (tmpTypeDef, modulePtrG->typeDefs); - - Free (yyvsp[-2].charPtr); - Free (yyvsp[0].charPtr); - ; - break;} -case 45: -#line 786 "core/parse-asn1.y" -{ - /* - * a macro type may produce a null type - */ - if (yyvsp[-1].typePtr != NULL) - { - yyval.typeDefPtr = MT (TypeDef); - yyval.typeDefPtr->type = yyvsp[-1].typePtr; - yyval.typeDefPtr->type->lineNo = yyvsp[-2].intVal; - yyval.typeDefPtr->type->attrList = yyvsp[0].attrList; - yyval.typeDefPtr->definedName = yyvsp[-5].charPtr; - yyval.typeDefPtr->attrList = yyvsp[-3].attrList; - } - else - yyval.typeDefPtr = NULL; - ; - break;} -case 46: -#line 807 "core/parse-asn1.y" -{ - /* allocate a Type with basic type of ImportTypeRef */ - SetupType (&yyval.typePtr, BASICTYPE_IMPORTTYPEREF, yyvsp[-1].intVal); - yyval.typePtr->basicType->a.importTypeRef = MT (TypeRef); - yyval.typePtr->basicType->a.importTypeRef->typeName = yyvsp[0].charPtr; - yyval.typePtr->basicType->a.importTypeRef->moduleName = yyvsp[-3].charPtr; - - /* add entry to this module's import list */ - AddPrivateImportElmt (modulePtrG, yyvsp[0].charPtr, yyvsp[-3].charPtr, yyvsp[-1].intVal); - ; - break;} -case 47: -#line 821 "core/parse-asn1.y" -{ yyval.typePtr = yyvsp[0].typePtr; ; - break;} -case 48: -#line 823 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_LOCALTYPEREF, myLineNoG); - yyval.typePtr->basicType->a.localTypeRef = MT (TypeRef); - yyval.typePtr->basicType->a.localTypeRef->typeName = yyvsp[0].charPtr; - ; - break;} -case 68: -#line 856 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_OCTETSTRING, myLineNoG); - ; - break;} -case 69: -#line 863 "core/parse-asn1.y" -{ - yyval.namedTypePtr = MT (NamedType); - yyval.namedTypePtr->type = yyvsp[0].typePtr; - yyval.namedTypePtr->fieldName = yyvsp[-1].charPtr; - ; - break;} -case 70: -#line 869 "core/parse-asn1.y" -{ - yyval.namedTypePtr = MT (NamedType); - yyval.namedTypePtr->type = yyvsp[0].typePtr; - ; - break;} -case 71: -#line 877 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_BOOLEAN, myLineNoG); - ; - break;} -case 72: -#line 884 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_INTEGER, myLineNoG); - yyval.typePtr->basicType->a.integer = NEWLIST(); /* empty list */ - ; - break;} -case 73: -#line 889 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_INTEGER, myLineNoG); - yyval.typePtr->basicType->a.integer = yyvsp[-1].valueDefListPtr; - ; - break;} -case 74: -#line 898 "core/parse-asn1.y" -{ - yyval.valueDefListPtr = NEWLIST(); - APPEND (yyvsp[0].valueDefPtr, yyval.valueDefListPtr); - ; - break;} -case 75: -#line 903 "core/parse-asn1.y" -{ - APPEND (yyvsp[0].valueDefPtr,yyvsp[-2].valueDefListPtr); - yyval.valueDefListPtr = yyvsp[-2].valueDefListPtr; - ; - break;} -case 76: -#line 911 "core/parse-asn1.y" -{ - yyval.valueDefPtr = MT (ValueDef); - yyval.valueDefPtr->definedName = yyvsp[-3].charPtr; - SetupValue (&yyval.valueDefPtr->value, BASICVALUE_INTEGER, myLineNoG); - yyval.valueDefPtr->value->basicValue->a.integer = yyvsp[-1].intVal; - ; - break;} -case 77: -#line 918 "core/parse-asn1.y" -{ - yyval.valueDefPtr = MT (ValueDef); - yyval.valueDefPtr->definedName = yyvsp[-3].charPtr; - yyval.valueDefPtr->value = yyvsp[-1].valuePtr; - ; - break;} -case 78: -#line 927 "core/parse-asn1.y" -{ - if (yyvsp[0].uintVal>0x7FFFFFFF) { - yyerror("Warning: positive signed number out of range"); - yyval.intVal = 0x7FFFFFFF; - } - ; - break;} -case 79: -#line 934 "core/parse-asn1.y" -{ - yyerror ("Warning: positive signed number out of range"); - yyval.intVal = 0x7FFFFFFF; - /* modulePtrG->status = MOD_ERROR; */ - ; - break;} -case 80: -#line 940 "core/parse-asn1.y" -{ - if (yyvsp[0].uintVal>0x80000000) { - yyerror("Warning: negative signed number out of range"); - yyval.intVal = -0x80000000; - } else if (yyvsp[0].uintVal==0x80000000) { - yyval.intVal = -0x80000000; - } else { - yyval.intVal = -yyvsp[0].uintVal; - } - ; - break;} -case 81: -#line 951 "core/parse-asn1.y" -{ - yyerror ("Warning: negative signed number out of range"); - yyval.intVal = -0x80000000; - /* modulePtrG->status = MOD_ERROR; */ - ; - break;} -case 82: -#line 960 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_ENUMERATED, myLineNoG); - yyval.typePtr->basicType->a.enumerated = yyvsp[-1].valueDefListPtr; - ; - break;} -case 83: -#line 969 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_REAL, myLineNoG); - ; - break;} -case 84: -#line 976 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_BITSTRING, myLineNoG); - yyval.typePtr->basicType->a.bitString = NEWLIST(); /* empty list */ - ; - break;} -case 85: -#line 981 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_BITSTRING, myLineNoG); - yyval.typePtr->basicType->a.bitString = yyvsp[-1].valueDefListPtr; - ; - break;} -case 87: -#line 995 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_NULL, myLineNoG); - ; - break;} -case 88: -#line 1002 "core/parse-asn1.y" -{ yyval.intVal = yyvsp[-1].intVal; ; - break;} -case 89: -#line 1007 "core/parse-asn1.y" -{ - NamedType *n; - - SetupType (&yyval.typePtr, BASICTYPE_SEQUENCE, yyvsp[-2].intVal); - - if (AsnListCount ((AsnList*)yyvsp[-1].namedTypeListPtr) != 0) - { - n = (NamedType*) FIRST_LIST_ELMT ((AsnList*)yyvsp[-1].namedTypeListPtr); - n->type->lineNo = yyvsp[-2].intVal; - } - - yyval.typePtr->basicType->a.sequence = yyvsp[-1].namedTypeListPtr; - - ; - break;} -case 90: -#line 1022 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_SEQUENCE, yyvsp[-1].intVal); - - /* set up empty list for SEQ with no elmts */ - yyval.typePtr->basicType->a.sequence = AsnListNew (sizeof (void*)); - ; - break;} -case 91: -#line 1037 "core/parse-asn1.y" -{ - NamedType *lastElmt; - - if (yyvsp[0].attrList != NULL) - { - lastElmt = (NamedType*)LAST_LIST_ELMT (yyvsp[-1].namedTypeListPtr); - lastElmt->type->attrList = yyvsp[0].attrList; - } - yyval.namedTypeListPtr = yyvsp[-1].namedTypeListPtr; - ; - break;} -case 92: -#line 1051 "core/parse-asn1.y" -{ - yyval.namedTypeListPtr = NEWLIST(); - APPEND (yyvsp[0].namedTypePtr,yyval.namedTypeListPtr); - ; - break;} -case 93: -#line 1056 "core/parse-asn1.y" -{ - NamedType *lastElmt; - - if (yyvsp[-2].attrList != NULL) - { - lastElmt = (NamedType*)LAST_LIST_ELMT (yyvsp[-4].namedTypeListPtr); - lastElmt->type->attrList = yyvsp[-2].attrList; - } - - APPEND (yyvsp[0].namedTypePtr, yyvsp[-4].namedTypeListPtr); - lastElmt = (NamedType*)LAST_LIST_ELMT (yyvsp[-4].namedTypeListPtr); - lastElmt->type->lineNo = yyvsp[-1].intVal; - yyval.namedTypeListPtr = yyvsp[-4].namedTypeListPtr; - ; - break;} -case 95: -#line 1075 "core/parse-asn1.y" -{ - yyval.namedTypePtr = yyvsp[-1].namedTypePtr; - yyval.namedTypePtr->type->optional = TRUE; - ; - break;} -case 96: -#line 1080 "core/parse-asn1.y" -{ - /* - * this rules uses NamedValue instead of Value - * for the stupid choice value syntax (fieldname value) - * it should be like a set/seq value (ie with - * enclosing { } - */ - yyval.namedTypePtr = yyvsp[-2].namedTypePtr; - yyval.namedTypePtr->type->defaultVal = yyvsp[0].namedValuePtr; - /* - * could link value to the elmt type here (done in link_types.c) - */ - ; - break;} -case 97: -#line 1094 "core/parse-asn1.y" -{ - yyval.namedTypePtr = MT (NamedType); - SetupType (&yyval.namedTypePtr->type, BASICTYPE_COMPONENTSOF, myLineNoG); - yyval.namedTypePtr->type->basicType->a.componentsOf = yyvsp[0].typePtr; - ; - break;} -case 98: -#line 1100 "core/parse-asn1.y" -{ - yyval.namedTypePtr = MT (NamedType); - SetupType (&yyval.namedTypePtr->type, BASICTYPE_COMPONENTSOF, myLineNoG); - yyval.namedTypePtr->fieldName = yyvsp[-3].charPtr; - yyval.namedTypePtr->type->basicType->a.componentsOf = yyvsp[0].typePtr; - ; - break;} -case 99: -#line 1112 "core/parse-asn1.y" -{ - NamedType *n; - - /* does not use SEQUENCE == SEQ OF ANY abrev*/ - SetupType (&yyval.typePtr, BASICTYPE_SEQUENCEOF, myLineNoG); - - /* grab line number from first elmt */ - if (yyvsp[0].typePtr != NULL) - yyval.typePtr->lineNo = yyvsp[0].typePtr->lineNo - 1; - - yyval.typePtr->basicType->a.sequenceOf = yyvsp[0].typePtr; - ; - break;} -case 100: -#line 1127 "core/parse-asn1.y" -{ yyval.intVal = yyvsp[-1].intVal; ; - break;} -case 101: -#line 1132 "core/parse-asn1.y" -{ - NamedType *n; - - SetupType (&yyval.typePtr, BASICTYPE_SET, yyvsp[-2].intVal); - - /* reset first elmt's line number */ - if (AsnListCount ((AsnList*)yyvsp[-1].namedTypeListPtr) != 0) - { - n = (NamedType*)FIRST_LIST_ELMT ((AsnList*)yyvsp[-1].namedTypeListPtr); - n->type->lineNo = yyvsp[-2].intVal; - } - yyval.typePtr->basicType->a.set = yyvsp[-1].namedTypeListPtr; - ; - break;} -case 102: -#line 1146 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_SET, yyvsp[-1].intVal); - - /* set up empty elmt list for SET */ - yyval.typePtr->basicType->a.set = AsnListNew (sizeof (void*)); - ; - break;} -case 103: -#line 1162 "core/parse-asn1.y" -{ - /* does not allow SET == SET OF ANY Abrev */ - SetupType (&yyval.typePtr, BASICTYPE_SETOF, myLineNoG); - - if (yyvsp[0].typePtr != NULL) - yyval.typePtr->lineNo = yyvsp[0].typePtr->lineNo; - - yyval.typePtr->basicType->a.setOf = yyvsp[0].typePtr; - ; - break;} -case 104: -#line 1176 "core/parse-asn1.y" -{ - NamedType *n; - - SetupType (&yyval.typePtr, BASICTYPE_CHOICE, yyvsp[-3].intVal); - - yyval.typePtr->basicType->a.choice = yyvsp[-1].namedTypeListPtr; - - if (AsnListCount (yyvsp[-1].namedTypeListPtr) != 0) - { - n = (NamedType*)FIRST_LIST_ELMT (yyvsp[-1].namedTypeListPtr); - n->type->lineNo = yyvsp[-3].intVal; - } - ; - break;} -case 105: -#line 1193 "core/parse-asn1.y" -{ - NamedType *lastElmt; - if (yyvsp[0].attrList != NULL) - { - lastElmt = (NamedType*)LAST_LIST_ELMT (yyvsp[-1].namedTypeListPtr); - lastElmt->type->attrList = yyvsp[0].attrList; - } - yyval.namedTypeListPtr = yyvsp[-1].namedTypeListPtr; - ; - break;} -case 106: -#line 1206 "core/parse-asn1.y" -{ - yyval.namedTypeListPtr = NEWLIST(); - APPEND (yyvsp[0].namedTypePtr, yyval.namedTypeListPtr); - ; - break;} -case 107: -#line 1211 "core/parse-asn1.y" -{ - NamedType *lastElmt; - - if (yyvsp[-1].attrList != NULL) - { - lastElmt = (NamedType*)LAST_LIST_ELMT (yyvsp[-3].namedTypeListPtr); - lastElmt->type->attrList = yyvsp[-1].attrList; - } - APPEND (yyvsp[0].namedTypePtr,yyvsp[-3].namedTypeListPtr); - yyval.namedTypeListPtr = yyvsp[-3].namedTypeListPtr; - ; - break;} -case 108: -#line 1227 "core/parse-asn1.y" -{ - /* - * the selection type should be replaced after - * link with actual type - */ - SetupType (&yyval.typePtr, BASICTYPE_SELECTION, myLineNoG); - - yyval.typePtr->basicType->a.selection = MT (SelectionType); - yyval.typePtr->basicType->a.selection->typeRef = yyvsp[0].typePtr; - yyval.typePtr->basicType->a.selection->fieldName = yyvsp[-2].charPtr; - ; - break;} -case 109: -#line 1242 "core/parse-asn1.y" -{ - Tag *tag; - - /* remove next tag if any && IMPLICIT_TAGS */ - if ((modulePtrG->tagDefault == IMPLICIT_TAGS) && - (yyvsp[0].typePtr->tags != NULL) && !LIST_EMPTY (yyvsp[0].typePtr->tags)) - { - tag = (Tag*)FIRST_LIST_ELMT (yyvsp[0].typePtr->tags); /* set curr to first */ - AsnListFirst (yyvsp[0].typePtr->tags); /* set curr to first elmt */ - AsnListRemove (yyvsp[0].typePtr->tags); /* remove first elmt */ - - /* - * set implicit if implicitly tagged built in type (ie not ref) - * (this simplifies the module ASN.1 printer (print.c)) - */ - if (tag->tclass == UNIV) - yyvsp[0].typePtr->implicit = TRUE; - - Free (tag); - } - - PREPEND (yyvsp[-1].tagPtr, yyvsp[0].typePtr->tags); - yyval.typePtr = yyvsp[0].typePtr; - ; - break;} -case 110: -#line 1267 "core/parse-asn1.y" -{ - Tag *tag; - - /* remove next tag if any */ - if ((yyvsp[0].typePtr->tags != NULL) && !LIST_EMPTY (yyvsp[0].typePtr->tags)) - { - tag = (Tag*)FIRST_LIST_ELMT (yyvsp[0].typePtr->tags); /* set curr to first */ - AsnListFirst (yyvsp[0].typePtr->tags); /* set curr to first elmt */ - AsnListRemove (yyvsp[0].typePtr->tags); /* remove first elmt */ - - if (tag->tclass == UNIV) - yyvsp[0].typePtr->implicit = TRUE; - - Free (tag); - } - - /* - * must check after linking that implicitly tagged - * local/import type refs are not untagged choice/any etc - */ - else if ((yyvsp[0].typePtr->basicType->choiceId == BASICTYPE_IMPORTTYPEREF) || - (yyvsp[0].typePtr->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (yyvsp[0].typePtr->basicType->choiceId == BASICTYPE_SELECTION)) - yyvsp[0].typePtr->implicit = TRUE; - - /* - * all other implicitly tagable types should have tags - * to remove - if this else clause fires then it is - * probably a CHOICE or ANY type - */ - else - { - PrintErrLoc (modulePtrG->asn1SrcFileName, yyvsp[0].typePtr->lineNo); - fprintf (stderr, "ERROR - attempt to implicitly reference untagged type\n"); - smallErrG = 1; - } - - PREPEND (yyvsp[-2].tagPtr, yyvsp[0].typePtr->tags); - yyval.typePtr = yyvsp[0].typePtr; - ; - break;} -case 111: -#line 1308 "core/parse-asn1.y" -{ - /* insert tag at head of list */ - yyvsp[-2].tagPtr->explicit = TRUE; - PREPEND (yyvsp[-2].tagPtr, yyvsp[0].typePtr->tags); - yyval.typePtr = yyvsp[0].typePtr; - ; - break;} -case 112: -#line 1318 "core/parse-asn1.y" -{ - yyval.tagPtr = yyvsp[-1].tagPtr; - yyval.tagPtr->tclass = yyvsp[-2].intVal; - yyval.tagPtr->explicit = FALSE; /* default to false */ - - /* - * keep track of APPLICATION Tags per module - * should only be used once - */ - if (yyvsp[-2].intVal == APPL) - { - PushApplTag (yyval.tagPtr->code, myLineNoG); - } - ; - break;} -case 113: -#line 1336 "core/parse-asn1.y" -{ - yyval.tagPtr = MT (Tag); - yyval.tagPtr->code = yyvsp[0].intVal; - ; - break;} -case 114: -#line 1341 "core/parse-asn1.y" -{ - yyval.tagPtr = MT (Tag); - yyval.tagPtr->code = NO_TAG_CODE; - yyval.tagPtr->valueRef = yyvsp[0].valuePtr; - ; - break;} -case 115: -#line 1349 "core/parse-asn1.y" -{ yyval.intVal = UNIV; ; - break;} -case 116: -#line 1350 "core/parse-asn1.y" -{ yyval.intVal = APPL; ; - break;} -case 117: -#line 1351 "core/parse-asn1.y" -{ yyval.intVal = PRIV; ; - break;} -case 118: -#line 1352 "core/parse-asn1.y" -{ yyval.intVal = CNTX; ; - break;} -case 119: -#line 1358 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_ANY, myLineNoG); - ; - break;} -case 120: -#line 1362 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_ANYDEFINEDBY, myLineNoG); - yyval.typePtr->basicType->a.anyDefinedBy = MT (AnyDefinedByType); - yyval.typePtr->basicType->a.anyDefinedBy->fieldName = yyvsp[0].charPtr; - ; - break;} -case 121: -#line 1372 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_OID, myLineNoG); - ; - break;} -case 122: -#line 1380 "core/parse-asn1.y" -{ - /* - * append new subtype list to existing one (s) if any - * with AND relation - */ - AppendSubtype (&yyvsp[-1].typePtr->subtypes, yyvsp[0].subtypePtr, SUBTYPE_AND); - yyval.typePtr = yyvsp[-1].typePtr; - ; - break;} -case 123: -#line 1389 "core/parse-asn1.y" -{ - Subtype *s; - - SetupType (&yyval.typePtr, BASICTYPE_SETOF, myLineNoG); - yyval.typePtr->basicType->a.setOf = yyvsp[0].typePtr; - - /* add size constraint */ - s = MT (Subtype); - s->choiceId = SUBTYPE_SINGLE; - s->a.single = yyvsp[-2].subtypeValuePtr; - AppendSubtype (&yyval.typePtr->subtypes, s, SUBTYPE_AND); - ; - break;} -case 124: -#line 1402 "core/parse-asn1.y" -{ - Subtype *s; - - SetupType (&yyval.typePtr, BASICTYPE_SEQUENCEOF, myLineNoG); - yyval.typePtr->basicType->a.sequenceOf = yyvsp[0].typePtr; - - /* add size constraint */ - s = MT (Subtype); - s->choiceId = SUBTYPE_SINGLE; - s->a.single = yyvsp[-2].subtypeValuePtr; - AppendSubtype (&yyval.typePtr->subtypes, s, SUBTYPE_AND); - ; - break;} -case 125: -#line 1419 "core/parse-asn1.y" -{ - yyval.subtypePtr = yyvsp[-1].subtypePtr; - ; - break;} -case 126: -#line 1426 "core/parse-asn1.y" -{ - Subtype *s; - - /* OR relation between all elmts of in ValueSetList */ - - yyval.subtypePtr = MT (Subtype); - yyval.subtypePtr->choiceId = SUBTYPE_OR; - yyval.subtypePtr->a.or = NEWLIST(); - - s = MT (Subtype); - s->choiceId = SUBTYPE_SINGLE; - s->a.single = yyvsp[0].subtypeValuePtr; - APPEND (s, yyval.subtypePtr->a.or); - ; - break;} -case 127: -#line 1441 "core/parse-asn1.y" -{ - Subtype *s; - s = MT (Subtype); - s->choiceId = SUBTYPE_SINGLE; - s->a.single = yyvsp[0].subtypeValuePtr; - APPEND (s, yyvsp[-2].subtypePtr->a.or); - yyval.subtypePtr = yyvsp[-2].subtypePtr; - ; - break;} -case 134: -#line 1463 "core/parse-asn1.y" -{ - yyval.subtypeValuePtr = MT (SubtypeValue); - yyval.subtypeValuePtr->choiceId = SUBTYPEVALUE_SINGLEVALUE; - yyval.subtypeValuePtr->a.singleValue = yyvsp[0].valuePtr; - ; - break;} -case 135: -#line 1471 "core/parse-asn1.y" -{ - yyval.subtypeValuePtr = MT (SubtypeValue); - yyval.subtypeValuePtr->choiceId = SUBTYPEVALUE_CONTAINED; - yyval.subtypeValuePtr->a.contained = yyvsp[0].typePtr; - ; - break;} -case 136: -#line 1480 "core/parse-asn1.y" -{ - yyval.subtypeValuePtr = MT (SubtypeValue); - yyval.subtypeValuePtr->choiceId = SUBTYPEVALUE_VALUERANGE; - yyval.subtypeValuePtr->a.valueRange = MT (ValueRangeSubtype); - yyval.subtypeValuePtr->a.valueRange->lowerEndInclusive = - valueRangeLowerEndInclusiveG; - yyval.subtypeValuePtr->a.valueRange->upperEndInclusive = - valueRangeUpperEndInclusiveG; - yyval.subtypeValuePtr->a.valueRange->lowerEndValue = yyvsp[-3].valuePtr; - yyval.subtypeValuePtr->a.valueRange->upperEndValue = yyvsp[0].valuePtr; - ; - break;} -case 137: -#line 1495 "core/parse-asn1.y" -{ - yyval.valuePtr = yyvsp[0].valuePtr; - valueRangeLowerEndInclusiveG = TRUE; - ; - break;} -case 138: -#line 1500 "core/parse-asn1.y" -{ - yyval.valuePtr = yyvsp[-1].valuePtr; - valueRangeLowerEndInclusiveG = FALSE; - ; - break;} -case 139: -#line 1508 "core/parse-asn1.y" -{ - yyval.valuePtr = yyvsp[0].valuePtr; - valueRangeUpperEndInclusiveG = TRUE; - ; - break;} -case 140: -#line 1513 "core/parse-asn1.y" -{ - yyval.valuePtr = yyvsp[0].valuePtr; - valueRangeUpperEndInclusiveG = FALSE; - ; - break;} -case 141: -#line 1520 "core/parse-asn1.y" -{ yyval.valuePtr = yyvsp[0].valuePtr; ; - break;} -case 142: -#line 1522 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_SPECIALINTEGER, myLineNoG); - yyval.valuePtr->basicValue->a.specialInteger = MIN_INT; - ; - break;} -case 143: -#line 1529 "core/parse-asn1.y" -{ yyval.valuePtr = yyvsp[0].valuePtr; ; - break;} -case 144: -#line 1531 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_SPECIALINTEGER, myLineNoG); - yyval.valuePtr->basicValue->a.specialInteger = MAX_INT; - ; - break;} -case 145: -#line 1539 "core/parse-asn1.y" -{ - yyval.subtypeValuePtr = MT (SubtypeValue); - yyval.subtypeValuePtr->choiceId = SUBTYPEVALUE_SIZECONSTRAINT; - yyval.subtypeValuePtr->a.sizeConstraint = yyvsp[0].subtypePtr; - ; - break;} -case 146: -#line 1549 "core/parse-asn1.y" -{ - yyval.subtypeValuePtr = MT (SubtypeValue); - yyval.subtypeValuePtr->choiceId = SUBTYPEVALUE_PERMITTEDALPHABET; - yyval.subtypeValuePtr->a.permittedAlphabet = yyvsp[0].subtypePtr; - ; - break;} -case 147: -#line 1558 "core/parse-asn1.y" -{ - yyval.subtypeValuePtr = MT (SubtypeValue); - yyval.subtypeValuePtr->choiceId = SUBTYPEVALUE_INNERSUBTYPE; - yyval.subtypeValuePtr->a.innerSubtype = yyvsp[0].innerSubtypePtr; - ; - break;} -case 148: -#line 1564 "core/parse-asn1.y" -{ - yyval.subtypeValuePtr = MT (SubtypeValue); - yyval.subtypeValuePtr->choiceId = SUBTYPEVALUE_INNERSUBTYPE; - yyval.subtypeValuePtr->a.innerSubtype = yyvsp[0].innerSubtypePtr; - ; - break;} -case 149: -#line 1573 "core/parse-asn1.y" -{ - Constraint *constraint; - - /* this constrains the elmt of setof or seq of */ - yyval.innerSubtypePtr = MT (InnerSubtype); - yyval.innerSubtypePtr->constraintType = SINGLE_CT; - yyval.innerSubtypePtr->constraints = NEWLIST(); - constraint = MT (Constraint); - APPEND (constraint, yyval.innerSubtypePtr->constraints); - constraint->valueConstraints = yyvsp[0].subtypePtr; - ; - break;} -case 152: -#line 1593 "core/parse-asn1.y" -{ - yyval.innerSubtypePtr = MT (InnerSubtype); - yyval.innerSubtypePtr->constraintType = FULL_CT; - yyval.innerSubtypePtr->constraints = yyvsp[-1].constraintListPtr; - ; - break;} -case 153: -#line 1602 "core/parse-asn1.y" -{ - yyval.innerSubtypePtr = MT (InnerSubtype); - yyval.innerSubtypePtr->constraintType = PARTIAL_CT; - yyval.innerSubtypePtr->constraints = yyvsp[-1].constraintListPtr; - ; - break;} -case 154: -#line 1612 "core/parse-asn1.y" -{ - yyval.constraintListPtr = NEWLIST(); - APPEND (yyvsp[0].constraintPtr, yyval.constraintListPtr); - ; - break;} -case 155: -#line 1617 "core/parse-asn1.y" -{ - APPEND (yyvsp[0].constraintPtr, yyvsp[-2].constraintListPtr); - yyval.constraintListPtr = yyvsp[-2].constraintListPtr; - ; - break;} -case 156: -#line 1625 "core/parse-asn1.y" -{ - yyval.constraintPtr = yyvsp[0].constraintPtr; - yyval.constraintPtr->fieldRef = yyvsp[-1].charPtr; - ; - break;} -case 158: -#line 1635 "core/parse-asn1.y" -{ - yyval.constraintPtr = MT (Constraint); - yyval.constraintPtr->presenceConstraint = yyvsp[0].intVal; - yyval.constraintPtr->valueConstraints = yyvsp[-1].subtypePtr; - ; - break;} -case 159: -#line 1643 "core/parse-asn1.y" -{ yyval.subtypePtr = yyvsp[0].subtypePtr; ; - break;} -case 160: -#line 1644 "core/parse-asn1.y" -{ yyval.subtypePtr = NULL; ; - break;} -case 161: -#line 1648 "core/parse-asn1.y" -{ yyval.intVal = PRESENT_CT; ; - break;} -case 162: -#line 1649 "core/parse-asn1.y" -{ yyval.intVal = ABSENT_CT; ; - break;} -case 163: -#line 1650 "core/parse-asn1.y" -{ yyval.intVal = EMPTY_CT; ; - break;} -case 164: -#line 1651 "core/parse-asn1.y" -{ yyval.intVal = OPTIONAL_CT; ; - break;} -case 165: -#line 1665 "core/parse-asn1.y" -{ - yyval.valueDefPtr = MT (ValueDef); - yyval.valueDefPtr->definedName = yyvsp[-4].charPtr; - yyval.valueDefPtr->value = yyvsp[0].valuePtr; - yyval.valueDefPtr->value->lineNo = yyvsp[-1].intVal; - yyval.valueDefPtr->value->type = yyvsp[-3].typePtr; - ; - break;} -case 168: -#line 1681 "core/parse-asn1.y" -{ yyval.valuePtr = yyvsp[0].valuePtr; ; - break;} -case 169: -#line 1683 "core/parse-asn1.y" -{ - /* - * for parse, may be set to BASICVALUE_IMPORTEDTYPEREF - * by linker - */ - SetupValue (&yyval.valuePtr, BASICVALUE_LOCALVALUEREF, myLineNoG); - yyval.valuePtr->basicValue->a.localValueRef = MT (ValueRef); - yyval.valuePtr->basicValue->a.localValueRef->valueName = yyvsp[0].charPtr; - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - ; - break;} -case 170: -#line 1697 "core/parse-asn1.y" -{ - /* Alloc value with basicValue of importValueRef */ - SetupValue (&yyval.valuePtr, BASICVALUE_IMPORTVALUEREF, yyvsp[-1].intVal); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.importValueRef = MT (ValueRef); - yyval.valuePtr->basicValue->a.importValueRef->valueName = yyvsp[0].charPtr; - yyval.valuePtr->basicValue->a.importValueRef->moduleName = yyvsp[-3].charPtr; - - /* add entry to this module's import list */ - AddPrivateImportElmt (modulePtrG, yyvsp[0].charPtr, yyvsp[-3].charPtr, yyvsp[-1].intVal); - ; - break;} -case 174: -#line 1715 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_INTEGER, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.integer = yyvsp[0].intVal; - ; - break;} -case 175: -#line 1721 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_ASCIIHEX, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.asciiHex = MT (AsnOcts); - yyval.valuePtr->basicValue->a.asciiHex->octs = yyvsp[0].charPtr; - yyval.valuePtr->basicValue->a.asciiHex->octetLen = strlen (yyvsp[0].charPtr); - ; - break;} -case 176: -#line 1729 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_ASCIIBITSTRING, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.asciiBitString = MT (AsnOcts); - yyval.valuePtr->basicValue->a.asciiBitString->octs = yyvsp[0].charPtr; - yyval.valuePtr->basicValue->a.asciiBitString->octetLen = strlen (yyvsp[0].charPtr); - ; - break;} -case 177: -#line 1737 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_ASCIITEXT, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.asciiText = MT (AsnOcts); - yyval.valuePtr->basicValue->a.asciiText->octs = yyvsp[0].charPtr; - yyval.valuePtr->basicValue->a.asciiText->octetLen = strlen (yyvsp[0].charPtr); - ; - break;} -case 178: -#line 1744 "core/parse-asn1.y" -{ LexBeginBraceBalContext(); ; - break;} -case 179: -#line 1745 "core/parse-asn1.y" -{ - /* - * LEXICAL TIE IN!! - * string returned by BRACEBAL_SYM has - * the $1 '{' prepended and includes everything - * upto and including '}' that balances $1 - */ - LexBeginInitialContext(); - SetupValue (&yyval.valuePtr, BASICVALUE_VALUENOTATION, myLineNoG); - yyval.valuePtr->basicValue->a.valueNotation = MT (AsnOcts); - yyval.valuePtr->basicValue->a.valueNotation->octs = yyvsp[0].charPtr; - yyval.valuePtr->basicValue->a.valueNotation->octetLen = strlen (yyvsp[0].charPtr); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - ; - break;} -case 180: -#line 1763 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_BOOLEAN, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.boolean = TRUE; - ; - break;} -case 181: -#line 1769 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_BOOLEAN, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.boolean = FALSE; - ; - break;} -case 182: -#line 1779 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_SPECIALREAL, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.specialReal = PLUS_INFINITY_REAL; - ; - break;} -case 183: -#line 1785 "core/parse-asn1.y" -{ - SetupValue (&yyval.valuePtr, BASICVALUE_SPECIALREAL, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - yyval.valuePtr->basicValue->a.specialReal = MINUS_INFINITY_REAL; - ; - break;} -case 184: -#line 1796 "core/parse-asn1.y" -{ - /* create a NULL value */ - SetupValue (&yyval.valuePtr, BASICVALUE_NULL, myLineNoG); - yyval.valuePtr->valueType = BASICTYPE_UNKNOWN; - ; - break;} -case 185: -#line 1806 "core/parse-asn1.y" -{ - yyval.namedValuePtr = MT (NamedValue); - yyval.namedValuePtr->value = yyvsp[0].valuePtr; - ; - break;} -case 186: -#line 1811 "core/parse-asn1.y" -{ - yyval.namedValuePtr = MT (NamedValue); - yyval.namedValuePtr->value = yyvsp[0].valuePtr; - yyval.namedValuePtr->fieldName = yyvsp[-1].charPtr; - ; - break;} -case 187: -#line 1821 "core/parse-asn1.y" -{ - /* - * example OID setup - * - * for { ccitt foo (1) bar bell (bunt) 2 } - * - * ccitt - * - arcnum is set to number from oid table (oid.c) - * foo (1) - * - sets up a new value def foo defined as 1 - * - makes oid valueref a value ref to foo (doesn't link it tho) - * bar - * - makes oid valueref a value ref to bar (doesn't link it tho) - * bell (bunt) - * - sets up a new value def bell defined as a val ref to bunt - * - makes oid valueref a value ref to bell (doesn't link it tho) - * 2 - * - arcnum is set to 2 - */ - - yyval.oidPtr = yyvsp[-1].oidPtr; - ; - break;} -case 188: -#line 1848 "core/parse-asn1.y" -{ - OID *o; - /* append component */ - for (o = yyvsp[-1].oidPtr; o->next != NULL; o = o->next) - ; - o->next = yyvsp[0].oidPtr; - yyval.oidPtr = yyvsp[-1].oidPtr; - ; - break;} -case 191: -#line 1864 "core/parse-asn1.y" -{ - Value *newVal; - /* - * if the arcName is a defined arc name like - * ccitt or iso etc, fill in the arc number. - * otherwise make a value ref to that named value - */ - yyval.oidPtr = MT (OID); - - yyval.oidPtr->arcNum = OidArcNameToNum (yyvsp[0].charPtr); - if (yyval.oidPtr->arcNum == NULL_OID_ARCNUM) - { - /* set up value ref to named value */ - SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG); - newVal->basicValue->a.localValueRef = MT (ValueRef); - newVal->valueType = BASICTYPE_INTEGER; - newVal->basicValue->a.localValueRef->valueName = yyvsp[0].charPtr; - yyval.oidPtr->valueRef = newVal; - } - ; - break;} -case 193: -#line 1890 "core/parse-asn1.y" -{ - yyval.oidPtr = MT (OID); - yyval.oidPtr->arcNum = yyvsp[0].intVal; - ; - break;} -case 195: -#line 1903 "core/parse-asn1.y" -{ - Value *newVal; - - yyval.oidPtr = yyvsp[-1].oidPtr; - - /* shared refs to named numbers name */ - SetupValue (&newVal, BASICVALUE_INTEGER, myLineNoG); - newVal->basicValue->a.integer = yyval.oidPtr->arcNum; - newVal->valueType = BASICTYPE_INTEGER; - AddNewValueDef (oidElmtValDefsG, yyvsp[-3].charPtr, newVal); - - SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG); - newVal->basicValue->a.localValueRef = MT (ValueRef); - newVal->basicValue->a.localValueRef->valueName = yyvsp[-3].charPtr; - - yyval.oidPtr->valueRef = newVal; - ; - break;} -case 196: -#line 1921 "core/parse-asn1.y" -{ - Value *newVal; - - /* shared refs to named numbers name */ - yyval.oidPtr = MT (OID); - yyval.oidPtr->arcNum = NULL_OID_ARCNUM; - - AddNewValueDef (oidElmtValDefsG, yyvsp[-3].charPtr, yyvsp[-1].valuePtr); - - SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG); - newVal->basicValue->a.localValueRef = MT (ValueRef); - newVal->basicValue->a.localValueRef->valueName = yyvsp[-3].charPtr; - - yyval.oidPtr->valueRef = newVal; - ; - break;} -case 200: -#line 1955 "core/parse-asn1.y" -{ - if (yyvsp[0].uintVal>0x7FFFFFFF) { - yyerror("Warning: number out of range"); - yyval.intVal = 0x7FFFFFFF; - } - ; - break;} -case 201: -#line 1962 "core/parse-asn1.y" -{ - yyerror ("Warning: number out of range"); - yyval.intVal = 0x7FFFFFFF; - /* modulePtrG->status = MOD_ERROR; */ - ; - break;} -case 207: -#line 1990 "core/parse-asn1.y" -{yyval.attrList = NULL;; - break;} -case 208: -#line 1995 "core/parse-asn1.y" -{ - yyval.attrList = NEWLIST(); - APPEND (yyvsp[0].charPtr,yyval.attrList); - ; - break;} -case 209: -#line 2000 "core/parse-asn1.y" -{ - APPEND (yyvsp[0].charPtr,yyvsp[-1].attrList); - yyval.attrList = yyvsp[-1].attrList; - ; - break;} -case 235: -#line 2039 "core/parse-asn1.y" -{ yyval.charPtr = "OPERATION"; ; - break;} -case 236: -#line 2040 "core/parse-asn1.y" -{ yyval.charPtr = "ERROR"; ; - break;} -case 237: -#line 2041 "core/parse-asn1.y" -{ yyval.charPtr = "BIND"; ; - break;} -case 238: -#line 2042 "core/parse-asn1.y" -{ yyval.charPtr = "UNBIND"; ; - break;} -case 239: -#line 2043 "core/parse-asn1.y" -{ yyval.charPtr = "APPLICATION-SERVICE-ELEMENT"; ; - break;} -case 240: -#line 2044 "core/parse-asn1.y" -{ yyval.charPtr = "APPLICATION-CONTEXT"; ; - break;} -case 241: -#line 2045 "core/parse-asn1.y" -{ yyval.charPtr = "EXTENSION"; ; - break;} -case 242: -#line 2046 "core/parse-asn1.y" -{ yyval.charPtr = "EXTENSIONS"; ; - break;} -case 243: -#line 2047 "core/parse-asn1.y" -{ yyval.charPtr = "EXTENSION-ATTRIBUTE"; ; - break;} -case 244: -#line 2048 "core/parse-asn1.y" -{ yyval.charPtr = "TOKEN"; ; - break;} -case 245: -#line 2049 "core/parse-asn1.y" -{ yyval.charPtr = "TOKEN-DATA"; ; - break;} -case 246: -#line 2050 "core/parse-asn1.y" -{ yyval.charPtr = "SECURITY-CATEGORY"; ; - break;} -case 247: -#line 2051 "core/parse-asn1.y" -{ yyval.charPtr = "OBJECT"; ; - break;} -case 248: -#line 2052 "core/parse-asn1.y" -{ yyval.charPtr = "PORT"; ; - break;} -case 249: -#line 2053 "core/parse-asn1.y" -{ yyval.charPtr = "REFINE"; ; - break;} -case 250: -#line 2054 "core/parse-asn1.y" -{ yyval.charPtr = "ABSTRACT-BIND"; ; - break;} -case 251: -#line 2055 "core/parse-asn1.y" -{ yyval.charPtr = "ABSTRACT-UNBIND"; ; - break;} -case 252: -#line 2056 "core/parse-asn1.y" -{ yyval.charPtr = "ABSTRACT-OPERATION"; ; - break;} -case 253: -#line 2057 "core/parse-asn1.y" -{ yyval.charPtr = "ABSTRACT-ERROR"; ; - break;} -case 254: -#line 2058 "core/parse-asn1.y" -{ yyval.charPtr = "ALGORITHM"; ; - break;} -case 255: -#line 2059 "core/parse-asn1.y" -{ yyval.charPtr = "ENCRYPTED"; ; - break;} -case 256: -#line 2060 "core/parse-asn1.y" -{ yyval.charPtr = "SIGNED"; ; - break;} -case 257: -#line 2061 "core/parse-asn1.y" -{ yyval.charPtr = "SIGNATURE"; ; - break;} -case 258: -#line 2062 "core/parse-asn1.y" -{ yyval.charPtr = "PROTECTED"; ; - break;} -case 259: -#line 2063 "core/parse-asn1.y" -{ yyval.charPtr = "OBJECT-TYPE"; ; - break;} -case 260: -#line 2072 "core/parse-asn1.y" -{ yyval.typePtr = yyvsp[0].typePtr; ; - break;} -case 261: -#line 2077 "core/parse-asn1.y" -{ - RosOperationMacroType *r; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ROSOPERATION, myLineNoG); - r = yyval.typePtr->basicType->a.macroType->a.rosOperation = - MT (RosOperationMacroType); - r->arguments = yyvsp[-3].namedTypePtr; - r->result = yyvsp[-2].namedTypePtr; - r->errors = yyvsp[-1].typeOrValueListPtr; - r->linkedOps = yyvsp[0].typeOrValueListPtr; - ; - break;} -case 262: -#line 2092 "core/parse-asn1.y" -{ yyval.namedTypePtr = yyvsp[0].namedTypePtr; ; - break;} -case 263: -#line 2093 "core/parse-asn1.y" -{ yyval.namedTypePtr = NULL; ; - break;} -case 264: -#line 2097 "core/parse-asn1.y" -{ yyval.namedTypePtr = yyvsp[0].namedTypePtr; ; - break;} -case 265: -#line 2098 "core/parse-asn1.y" -{ yyval.namedTypePtr = NULL; ; - break;} -case 267: -#line 2104 "core/parse-asn1.y" -{ yyval.namedTypePtr = NULL; ; - break;} -case 268: -#line 2110 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = yyvsp[-1].typeOrValueListPtr; - ; - break;} -case 269: -#line 2113 "core/parse-asn1.y" -{ yyval.typeOrValueListPtr = NULL; ; - break;} -case 270: -#line 2120 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = yyvsp[-1].typeOrValueListPtr; - ; - break;} -case 271: -#line 2123 "core/parse-asn1.y" -{ yyval.typeOrValueListPtr = NULL; ; - break;} -case 272: -#line 2136 "core/parse-asn1.y" -{ - RosErrorMacroType *r; - /* - * defines error macro type - */ - SetupMacroType (&yyval.typePtr, MACROTYPE_ROSERROR, myLineNoG); - r = yyval.typePtr->basicType->a.macroType->a.rosError = MT (RosErrorMacroType); - r->parameter = yyvsp[0].namedTypePtr; - ; - break;} -case 273: -#line 2149 "core/parse-asn1.y" -{ yyval.namedTypePtr = yyvsp[0].namedTypePtr; ; - break;} -case 274: -#line 2150 "core/parse-asn1.y" -{ yyval.namedTypePtr = NULL; ; - break;} -case 275: -#line 2160 "core/parse-asn1.y" -{ - RosBindMacroType *r; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ROSBIND, myLineNoG); - - r = yyval.typePtr->basicType->a.macroType->a.rosBind = MT (RosBindMacroType); - r->argument = yyvsp[-2].namedTypePtr; - r->result = yyvsp[-1].namedTypePtr; - r->error = yyvsp[0].namedTypePtr; - ; - break;} -case 276: -#line 2173 "core/parse-asn1.y" -{ yyval.namedTypePtr = yyvsp[0].namedTypePtr; ; - break;} -case 277: -#line 2174 "core/parse-asn1.y" -{ yyval.namedTypePtr = NULL; ; - break;} -case 278: -#line 2179 "core/parse-asn1.y" -{ yyval.namedTypePtr = yyvsp[0].namedTypePtr; ; - break;} -case 279: -#line 2180 "core/parse-asn1.y" -{ yyval.namedTypePtr = NULL; ; - break;} -case 280: -#line 2185 "core/parse-asn1.y" -{ yyval.namedTypePtr = yyvsp[0].namedTypePtr; ; - break;} -case 281: -#line 2186 "core/parse-asn1.y" -{ yyval.namedTypePtr = NULL; ; - break;} -case 282: -#line 2196 "core/parse-asn1.y" -{ - RosBindMacroType *r; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ROSUNBIND, myLineNoG); - - r = yyval.typePtr->basicType->a.macroType->a.rosUnbind = MT (RosBindMacroType); - r->argument = yyvsp[-2].namedTypePtr; - r->result = yyvsp[-1].namedTypePtr; - r->error = yyvsp[0].namedTypePtr; - ; - break;} -case 283: -#line 2210 "core/parse-asn1.y" -{ yyval.namedTypePtr = yyvsp[0].namedTypePtr; ; - break;} -case 284: -#line 2211 "core/parse-asn1.y" -{ yyval.namedTypePtr = NULL; ; - break;} -case 285: -#line 2221 "core/parse-asn1.y" -{ - RosAseMacroType *r; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ROSASE, myLineNoG); - r = yyval.typePtr->basicType->a.macroType->a.rosAse = MT (RosAseMacroType); - r->operations = yyvsp[0].valueListPtr; - ; - break;} -case 286: -#line 2229 "core/parse-asn1.y" -{ - RosAseMacroType *r; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ROSASE, myLineNoG); - r = yyval.typePtr->basicType->a.macroType->a.rosAse = MT (RosAseMacroType); - r->consumerInvokes = yyvsp[-1].valueListPtr; - r->supplierInvokes = yyvsp[0].valueListPtr; - ; - break;} -case 287: -#line 2242 "core/parse-asn1.y" -{ - yyval.valueListPtr = yyvsp[-1].valueListPtr; - ; - break;} -case 288: -#line 2250 "core/parse-asn1.y" -{ - yyval.valueListPtr = yyvsp[-1].valueListPtr; - ; - break;} -case 289: -#line 2253 "core/parse-asn1.y" -{ yyval.valueListPtr = NULL; ; - break;} -case 290: -#line 2259 "core/parse-asn1.y" -{ - yyval.valueListPtr = yyvsp[-1].valueListPtr; - ; - break;} -case 291: -#line 2262 "core/parse-asn1.y" -{ yyval.valueListPtr = NULL; ; - break;} -case 293: -#line 2282 "core/parse-asn1.y" -{ - RosAcMacroType *r; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ROSAC, myLineNoG); - r = yyval.typePtr->basicType->a.macroType->a.rosAc = MT (RosAcMacroType); - r->nonRoElements = yyvsp[-6].valueListPtr; - r->bindMacroType = yyvsp[-4].typePtr; - r->unbindMacroType = yyvsp[-2].typePtr; - r->remoteOperations = yyvsp[-1].valuePtr; - r->operationsOf = rosAcSymmetricAsesG; - r->initiatorConsumerOf = rosAcInitiatorConsumerOfG; - r->responderConsumerOf = rosAcResponderConsumerOfG; - r->abstractSyntaxes = yyvsp[0].oidListPtr; - ; - break;} -case 294: -#line 2301 "core/parse-asn1.y" -{ - yyval.valueListPtr = yyvsp[-1].valueListPtr; - ; - break;} -case 295: -#line 2310 "core/parse-asn1.y" -{ - yyval.valuePtr = yyvsp[-3].valuePtr; - ; - break;} -case 296: -#line 2314 "core/parse-asn1.y" -{ - yyval.valuePtr = NULL; - rosAcSymmetricAsesG = NULL; - rosAcInitiatorConsumerOfG = NULL; - rosAcResponderConsumerOfG = NULL; - ; - break;} -case 297: -#line 2324 "core/parse-asn1.y" -{ - rosAcSymmetricAsesG = yyvsp[-1].valueListPtr; - ; - break;} -case 298: -#line 2327 "core/parse-asn1.y" -{ rosAcSymmetricAsesG = NULL; ; - break;} -case 300: -#line 2336 "core/parse-asn1.y" -{ - rosAcInitiatorConsumerOfG = yyvsp[-1].valueListPtr; - ; - break;} -case 301: -#line 2339 "core/parse-asn1.y" -{ rosAcInitiatorConsumerOfG = NULL; ; - break;} -case 302: -#line 2344 "core/parse-asn1.y" -{ - rosAcResponderConsumerOfG = yyvsp[-1].valueListPtr; - ; - break;} -case 303: -#line 2347 "core/parse-asn1.y" -{ rosAcResponderConsumerOfG = NULL; ; - break;} -case 304: -#line 2352 "core/parse-asn1.y" -{ - yyval.oidListPtr = yyvsp[-1].oidListPtr; - ; - break;} -case 305: -#line 2355 "core/parse-asn1.y" -{ yyval.oidListPtr = NULL; ; - break;} -case 306: -#line 2361 "core/parse-asn1.y" -{ - yyval.oidListPtr = NEWLIST(); - APPEND (yyvsp[0].oidPtr,yyval.oidListPtr); - ; - break;} -case 307: -#line 2366 "core/parse-asn1.y" -{ - APPEND (yyvsp[0].oidPtr, yyvsp[-2].oidListPtr); - yyval.oidListPtr = yyvsp[-2].oidListPtr; - ; - break;} -case 308: -#line 2380 "core/parse-asn1.y" -{ - MtsasExtensionsMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASEXTENSIONS, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasExtensions = - MT (MtsasExtensionsMacroType); - m->extensions = yyvsp[-1].valueListPtr; - ; - break;} -case 310: -#line 2393 "core/parse-asn1.y" -{ yyval.valueListPtr = NULL; ; - break;} -case 311: -#line 2398 "core/parse-asn1.y" -{ - yyval.valueListPtr = NEWLIST(); - APPEND (yyvsp[0].valuePtr, yyval.valueListPtr); - ; - break;} -case 312: -#line 2403 "core/parse-asn1.y" -{ - APPEND (yyvsp[0].valuePtr,yyvsp[-2].valueListPtr); - yyval.valueListPtr = yyvsp[-2].valueListPtr; - ; - break;} -case 314: -#line 2411 "core/parse-asn1.y" -{ yyval.typeOrValueListPtr = NULL; ; - break;} -case 315: -#line 2416 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = NEWLIST(); - APPEND (yyvsp[0].typeOrValuePtr, yyval.typeOrValueListPtr); - ; - break;} -case 316: -#line 2421 "core/parse-asn1.y" -{ - APPEND (yyvsp[0].typeOrValuePtr,yyvsp[-2].typeOrValueListPtr); - yyval.typeOrValueListPtr = yyvsp[-2].typeOrValueListPtr; - ; - break;} -case 317: -#line 2429 "core/parse-asn1.y" -{ - yyval.typeOrValuePtr = MT (TypeOrValue); - yyval.typeOrValuePtr->choiceId = TYPEORVALUE_TYPE; - yyval.typeOrValuePtr->a.type = yyvsp[0].typePtr; - ; - break;} -case 318: -#line 2435 "core/parse-asn1.y" -{ - yyval.typeOrValuePtr = MT (TypeOrValue); - yyval.typeOrValuePtr->choiceId = TYPEORVALUE_VALUE; - yyval.typeOrValuePtr->a.value = yyvsp[0].valuePtr; - ; - break;} -case 319: -#line 2448 "core/parse-asn1.y" -{ - MtsasExtensionMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASEXTENSION, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasExtension = - MT (MtsasExtensionMacroType); - m->elmtType = yyvsp[-2].namedTypePtr; - m->defaultValue = yyvsp[-1].valuePtr; - m->criticalForSubmission = mtsasCriticalForSubmissionG; - m->criticalForTransfer = mtsasCriticalForTransferG; - m->criticalForDelivery = mtsasCriticalForDeliveryG; - - mtsasCriticalForSubmissionG = NULL; /* set up for next parse */ - mtsasCriticalForTransferG = NULL; - mtsasCriticalForDeliveryG = NULL; - ; - break;} -case 320: -#line 2465 "core/parse-asn1.y" -{ - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASEXTENSION, myLineNoG); - yyval.typePtr->basicType->a.macroType->a.mtsasExtension = - MT (MtsasExtensionMacroType); - /* - * all fields are NULL in the MtsasExtensionsMacroType - * for this production - */ - ; - break;} -case 321: -#line 2477 "core/parse-asn1.y" -{ yyval.valuePtr = yyvsp[0].valuePtr; ; - break;} -case 322: -#line 2478 "core/parse-asn1.y" -{ yyval.valuePtr = NULL; ; - break;} -case 327: -#line 2494 "core/parse-asn1.y" -{ - mtsasCriticalForSubmissionG = MT (AsnBool); - *mtsasCriticalForSubmissionG = TRUE; - ; - break;} -case 328: -#line 2499 "core/parse-asn1.y" -{ - mtsasCriticalForTransferG = MT (AsnBool); - *mtsasCriticalForTransferG = TRUE; - ; - break;} -case 329: -#line 2504 "core/parse-asn1.y" -{ - mtsasCriticalForDeliveryG = MT (AsnBool); - *mtsasCriticalForDeliveryG = TRUE; - ; - break;} -case 330: -#line 2518 "core/parse-asn1.y" -{ - MtsasExtensionAttributeMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASEXTENSIONATTRIBUTE, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasExtensionAttribute = - MT (MtsasExtensionAttributeMacroType); - m->type = NULL; - ; - break;} -case 331: -#line 2527 "core/parse-asn1.y" -{ - MtsasExtensionAttributeMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASEXTENSIONATTRIBUTE, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasExtensionAttribute = - MT (MtsasExtensionAttributeMacroType); - m->type = yyvsp[0].typePtr; - ; - break;} -case 332: -#line 2543 "core/parse-asn1.y" -{ - MtsasTokenMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASTOKEN, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasToken = MT (MtsasTokenMacroType); - m->type = NULL; - ; - break;} -case 333: -#line 2551 "core/parse-asn1.y" -{ - MtsasTokenMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASTOKEN, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasToken = MT (MtsasTokenMacroType); - m->type = yyvsp[0].typePtr; - ; - break;} -case 334: -#line 2566 "core/parse-asn1.y" -{ - MtsasTokenDataMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASTOKENDATA, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasTokenData = - MT (MtsasTokenDataMacroType); - m->type = NULL; - ; - break;} -case 335: -#line 2575 "core/parse-asn1.y" -{ - MtsasTokenDataMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASTOKENDATA, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasTokenData = - MT (MtsasTokenDataMacroType); - m->type = yyvsp[0].typePtr; - ; - break;} -case 336: -#line 2591 "core/parse-asn1.y" -{ - MtsasSecurityCategoryMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASSECURITYCATEGORY, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasSecurityCategory = - MT (MtsasSecurityCategoryMacroType); - m->type = NULL; - ; - break;} -case 337: -#line 2600 "core/parse-asn1.y" -{ - MtsasSecurityCategoryMacroType *m; - - SetupMacroType (&yyval.typePtr, MACROTYPE_MTSASSECURITYCATEGORY, myLineNoG); - m = yyval.typePtr->basicType->a.macroType->a.mtsasSecurityCategory = - MT (MtsasSecurityCategoryMacroType); - m->type = yyvsp[0].typePtr; - ; - break;} -case 338: -#line 2622 "core/parse-asn1.y" -{ - AsnObjectMacroType *a; - SetupMacroType (&yyval.typePtr, MACROTYPE_ASNOBJECT, myLineNoG); - a = yyval.typePtr->basicType->a.macroType->a.asnObject = MT (AsnObjectMacroType); - a->ports = yyvsp[0].asnPortListPtr; - ; - break;} -case 339: -#line 2632 "core/parse-asn1.y" -{ - yyval.asnPortListPtr = yyvsp[-1].asnPortListPtr; - ; - break;} -case 340: -#line 2635 "core/parse-asn1.y" -{ yyval.asnPortListPtr = NULL; ; - break;} -case 341: -#line 2640 "core/parse-asn1.y" -{ - yyval.asnPortListPtr = NEWLIST(); - APPEND (yyvsp[0].asnPortPtr, yyval.asnPortListPtr); - ; - break;} -case 342: -#line 2645 "core/parse-asn1.y" -{ - APPEND (yyvsp[0].asnPortPtr, yyvsp[-2].asnPortListPtr); - yyval.asnPortListPtr = yyvsp[-2].asnPortListPtr; - ; - break;} -case 343: -#line 2653 "core/parse-asn1.y" -{ - yyval.asnPortPtr = MT (AsnPort); - yyval.asnPortPtr->portValue = yyvsp[-1].valuePtr; - yyval.asnPortPtr->portType = yyvsp[0].intVal; - ; - break;} -case 344: -#line 2662 "core/parse-asn1.y" -{ - /* [C] consumer */ - yyval.intVal = CONSUMER_PORT; - ; - break;} -case 345: -#line 2667 "core/parse-asn1.y" -{ - /* [S] supplier */ - yyval.intVal = SUPPLIER_PORT; - ; - break;} -case 346: -#line 2672 "core/parse-asn1.y" -{ - /* symmetric */ - yyval.intVal = SYMMETRIC_PORT; - ; - break;} -case 347: -#line 2685 "core/parse-asn1.y" -{ - AsnPortMacroType *a; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ASNPORT, myLineNoG); - a = yyval.typePtr->basicType->a.macroType->a.asnPort = MT (AsnPortMacroType); - a->abstractOps = yyvsp[0].typeOrValueListPtr; - a->consumerInvokes = asnConsumerG; - a->supplierInvokes = asnSupplierG; - ; - break;} -case 348: -#line 2695 "core/parse-asn1.y" -{ - SetupMacroType (&yyval.typePtr, MACROTYPE_ASNPORT, myLineNoG); - yyval.typePtr->basicType->a.macroType->a.asnPort = MT (AsnPortMacroType); - ; - break;} -case 349: -#line 2704 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = yyvsp[-1].typeOrValueListPtr; - ; - break;} -case 350: -#line 2708 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = NULL; - asnConsumerG = yyvsp[0].typeOrValueListPtr; - asnSupplierG = NULL; - ; - break;} -case 351: -#line 2714 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = NULL; - asnConsumerG = yyvsp[0].typeOrValueListPtr; - asnSupplierG = NULL; - ; - break;} -case 352: -#line 2720 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = NULL; - asnConsumerG = yyvsp[-1].typeOrValueListPtr; - asnSupplierG = NULL; - ; - break;} -case 353: -#line 2726 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = NULL; - asnConsumerG = yyvsp[-1].typeOrValueListPtr; - asnSupplierG = NULL; - ; - break;} -case 354: -#line 2735 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = yyvsp[-1].typeOrValueListPtr; - ; - break;} -case 355: -#line 2742 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = yyvsp[-1].typeOrValueListPtr; - ; - break;} -case 356: -#line 2758 "core/parse-asn1.y" -{ - SetupType (&yyval.typePtr, BASICTYPE_UNKNOWN, myLineNoG); - ; - break;} -case 364: -#line 2784 "core/parse-asn1.y" -{ - yyval.intVal = 0; /* just to quiet yacc warning */ - ; - break;} -case 369: -#line 2802 "core/parse-asn1.y" -{ - yyval.intVal = 0; /* just to quiet yacc warning */ - ; - break;} -case 370: -#line 2815 "core/parse-asn1.y" -{ - AsnAbstractBindMacroType *a; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ASNABSTRACTBIND, myLineNoG); - a = yyval.typePtr->basicType->a.macroType->a.asnAbstractBind = - MT (AsnAbstractBindMacroType); - a->ports = yyvsp[0].asnPortListPtr; - ; - break;} -case 371: -#line 2824 "core/parse-asn1.y" -{ - AsnAbstractBindMacroType *a; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ASNABSTRACTBIND, myLineNoG); - a = yyval.typePtr->basicType->a.macroType->a.asnAbstractBind = - MT (AsnAbstractBindMacroType); - a->ports = yyvsp[-1].asnPortListPtr; - a->type = yyvsp[0].typePtr; - ; - break;} -case 372: -#line 2837 "core/parse-asn1.y" -{ - yyval.asnPortListPtr = yyvsp[-1].asnPortListPtr; - ; - break;} -case 373: -#line 2840 "core/parse-asn1.y" -{ yyval.asnPortListPtr = NULL; ; - break;} -case 374: -#line 2851 "core/parse-asn1.y" -{ - AsnAbstractBindMacroType *a; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ASNABSTRACTUNBIND, myLineNoG); - a = yyval.typePtr->basicType->a.macroType->a.asnAbstractUnbind = - MT (AsnAbstractBindMacroType); - - a->ports = yyvsp[0].asnPortListPtr; - ; - break;} -case 375: -#line 2861 "core/parse-asn1.y" -{ - AsnAbstractBindMacroType *a; - - SetupMacroType (&yyval.typePtr, MACROTYPE_ASNABSTRACTUNBIND, myLineNoG); - a = yyval.typePtr->basicType->a.macroType->a.asnAbstractUnbind = - MT (AsnAbstractBindMacroType); - - a->ports = yyvsp[-1].asnPortListPtr; - a->type = yyvsp[0].typePtr; - ; - break;} -case 376: -#line 2875 "core/parse-asn1.y" -{ - yyval.asnPortListPtr = yyvsp[-1].asnPortListPtr; - ; - break;} -case 377: -#line 2878 "core/parse-asn1.y" -{ yyval.asnPortListPtr = NULL; ; - break;} -case 378: -#line 2888 "core/parse-asn1.y" -{ - yyval.typePtr = yyvsp[0].typePtr; - yyvsp[0].typePtr->basicType->a.macroType->choiceId = MACROTYPE_ASNABSTRACTOPERATION; - ; - break;} -case 379: -#line 2900 "core/parse-asn1.y" -{ - SetupMacroType (&yyval.typePtr, MACROTYPE_ASNABSTRACTERROR, myLineNoG); - yyval.typePtr->basicType->a.macroType->a.asnAbstractError = MT (RosErrorMacroType); - yyval.typePtr->basicType->a.macroType->a.asnAbstractError->parameter = yyvsp[0].namedTypePtr; - ; - break;} -case 380: -#line 2913 "core/parse-asn1.y" -{ - SetupMacroType (&yyval.typePtr, MACROTYPE_AFALGORITHM, myLineNoG); - yyval.typePtr->basicType->a.macroType->a.afAlgorithm = yyvsp[0].typePtr; - ; - break;} -case 381: -#line 2924 "core/parse-asn1.y" -{ - SetupMacroType (&yyval.typePtr, MACROTYPE_AFENCRYPTED, myLineNoG); - yyval.typePtr->basicType->a.macroType->a.afEncrypted = yyvsp[0].typePtr; - ; - break;} -case 382: -#line 2936 "core/parse-asn1.y" -{ - SetupMacroType (&yyval.typePtr, MACROTYPE_AFSIGNED, myLineNoG); - yyval.typePtr->basicType->a.macroType->a.afSigned = yyvsp[0].typePtr; - ; - break;} -case 383: -#line 2947 "core/parse-asn1.y" -{ - SetupMacroType (&yyval.typePtr, MACROTYPE_AFSIGNATURE, myLineNoG); - yyval.typePtr->basicType->a.macroType->a.afSignature = yyvsp[0].typePtr; - ; - break;} -case 384: -#line 2961 "core/parse-asn1.y" -{ - SetupMacroType (&yyval.typePtr, MACROTYPE_AFPROTECTED, myLineNoG); - yyval.typePtr->basicType->a.macroType->a.afProtected = yyvsp[0].typePtr; - ; - break;} -case 385: -#line 2978 "core/parse-asn1.y" -{ - SnmpObjectTypeMacroType *s; - - SetupMacroType (&yyval.typePtr, MACROTYPE_SNMPOBJECTTYPE, myLineNoG); - s = yyval.typePtr->basicType->a.macroType->a.snmpObjectType = - MT (SnmpObjectTypeMacroType); - - s->syntax = yyvsp[-8].typePtr; - s->access = yyvsp[-6].intVal; - s->status = yyvsp[-4].intVal; - s->description = yyvsp[-3].valuePtr; - s->reference = yyvsp[-2].valuePtr; - s->index = yyvsp[-1].typeOrValueListPtr; - s->defVal = yyvsp[0].valuePtr; - ; - break;} -case 386: -#line 2997 "core/parse-asn1.y" -{ - if (strcmp (yyvsp[0].charPtr, "read-only") == 0) - yyval.intVal = SNMP_READ_ONLY; - else if (strcmp (yyvsp[0].charPtr, "read-write") == 0) - yyval.intVal = SNMP_READ_WRITE; - else if (strcmp (yyvsp[0].charPtr, "write-only") == 0) - yyval.intVal = SNMP_WRITE_ONLY; - else if (strcmp (yyvsp[0].charPtr, "not-accessible") == 0) - yyval.intVal = SNMP_NOT_ACCESSIBLE; - else - { - yyerror ("ACCESS field of SNMP OBJECT-TYPE MACRO can only be one of \"read-write\", \"write-only\" or \"not-accessible\""); - yyval.intVal = -1; - modulePtrG->status = MOD_ERROR; - } - Free (yyvsp[0].charPtr); - ; - break;} -case 387: -#line 3019 "core/parse-asn1.y" -{ - if (strcmp (yyvsp[0].charPtr, "mandatory") == 0) - yyval.intVal = SNMP_MANDATORY; - else if (strcmp (yyvsp[0].charPtr, "optional") == 0) - yyval.intVal = SNMP_OPTIONAL; - else if (strcmp (yyvsp[0].charPtr, "obsolete") == 0) - yyval.intVal = SNMP_OBSOLETE; - else if (strcmp (yyvsp[0].charPtr, "deprecated") == 0) - yyval.intVal = SNMP_DEPRECATED; - else - { - yyerror ("STATUS field of SNMP OBJECT-TYPE MACRO can only be one of \"optional\", \"obsolete\" or \"deprecated\""); - yyval.intVal = -1; - modulePtrG->status = MOD_ERROR; - } - Free (yyvsp[0].charPtr); - ; - break;} -case 388: -#line 3039 "core/parse-asn1.y" -{ yyval.valuePtr = yyvsp[0].valuePtr; ; - break;} -case 389: -#line 3040 "core/parse-asn1.y" -{ yyval.valuePtr = NULL; ; - break;} -case 390: -#line 3044 "core/parse-asn1.y" -{ yyval.valuePtr = yyvsp[0].valuePtr; ; - break;} -case 391: -#line 3045 "core/parse-asn1.y" -{ yyval.valuePtr = NULL; ; - break;} -case 392: -#line 3050 "core/parse-asn1.y" -{ - yyval.typeOrValueListPtr = yyvsp[-1].typeOrValueListPtr; - ; - break;} -case 393: -#line 3053 "core/parse-asn1.y" -{ yyval.typeOrValueListPtr = NULL; ; - break;} -case 394: -#line 3058 "core/parse-asn1.y" -{ - yyval.valuePtr = yyvsp[-1].valuePtr; - ; - break;} -case 395: -#line 3061 "core/parse-asn1.y" -{ yyval.valuePtr = NULL; ; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 498 "/usr/local/lib/bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; -} -#line 3064 "core/parse-asn1.y" - - -yyerror (s) -char*s; -{ - fprintf (stderr,"file \"%s\", line %d: %s at symbol \"%s\"\n\n", modulePtrG->asn1SrcFileName, myLineNoG, s, yytext); -} - - -/* - * given a Module*, the file name associated witht the open - * FILE *fPtr, InitAsn1Parser sets up the yacc/lex parser - * to parse an ASN.1 module read from fPtr and write the - * parse results into the given Module *mod. - */ -int -InitAsn1Parser PARAMS ((mod, fileName, fPtr), - Module *mod _AND_ - char *fileName _AND_ - FILE *fPtr) -{ - yyin = fPtr; - - /* - * reset lexical analyzer input file ptr - * (only do this on succesive calls ow yyrestart seg faults - */ -#ifdef FLEX_IN_USE - if (!firstTimeThroughG) - yyrestart (fPtr); - - firstTimeThroughG = FALSE; -#endif - - - /* - * init modulePtr - */ - memzero (mod, sizeof (Module)); - modulePtrG = mod; - mod->asn1SrcFileName = fileName; - mod->status = MOD_NOT_LINKED; - mod->hasAnys = FALSE; - - /* init lists to empty */ - mod->typeDefs = AsnListNew (sizeof (void*)); - mod->valueDefs = AsnListNew (sizeof (void*)); - - /* - * init export list stuff - */ - exportListG = NULL; - exportsParsedG = FALSE; - - /* - * reset line number to 1 - */ - myLineNoG = 1; - - /* - * reset error count - */ - parseErrCountG = 0; - - /* - * set up list to hold values defined in parsed oids - */ - oidElmtValDefsG = AsnListNew (sizeof (void *)); - - smallErrG = 0; - - return 0; - -} /* InitAsn1Parser */ - - -/* - * puts the applicatin tag code, tagCode, and line number it was - * parsed at into the applTagsG list. If the APPLICATION tag code - * is already in the applTagsG list then an error is printed. - * and the smallErrG flag set to prevent code production. - */ -void -PushApplTag PARAMS ((tagCode, lineNo), - unsigned long int tagCode _AND_ - unsigned long int lineNo) -{ - ApplTag *l; - ApplTag *new; - int wasDefined = 0; - - /* make sure not already in list */ - for (l = applTagsG; l != NULL; l = l->next) - { - if (l->tagCode == tagCode) - { - PrintErrLoc (modulePtrG->asn1SrcFileName, lineNo); - fprintf (stderr,"ERROR - APPLICATION tags can be used only once per ASN.1 module. The tag \"[APPLICATION %d]\" was previously used on line %d.\n", tagCode, l->lineNo); - wasDefined = 1; - smallErrG = 1; - } - } - if (!wasDefined) - { - new = MT (ApplTag); - new->lineNo = lineNo; - new->tagCode = tagCode; - new->next = applTagsG; - applTagsG = new; - } -} /* PushApplTag */ - - -/* - * Empties the applTagsG list. Usually done between modules. - */ -void -FreeApplTags() -{ - ApplTag *l; - ApplTag *lTmp; - - for (l = applTagsG; l != NULL; ) - { - lTmp = l->next; - Free (l); - l = lTmp; - } - applTagsG = NULL; -} /* FreeApplTags */ diff --git a/SecuritySNACCRuntime/compiler/core/parse-asn1.h b/SecuritySNACCRuntime/compiler/core/parse-asn1.h deleted file mode 100644 index 46e6443c..00000000 --- a/SecuritySNACCRuntime/compiler/core/parse-asn1.h +++ /dev/null @@ -1,183 +0,0 @@ -typedef union -{ - int intVal; - unsigned int uintVal; - char *charPtr; - Type *typePtr; - NamedType *namedTypePtr; - NamedTypeList *namedTypeListPtr; - Value *valuePtr; - NamedValue *namedValuePtr; - SubtypeValue *subtypeValuePtr; - Subtype *subtypePtr; - ModuleId *moduleId; - OID *oidPtr; - OidList *oidListPtr; - TypeDef *typeDefPtr; - TypeDefList *typeDefListPtr; - ValueDef *valueDefPtr; - ValueDefList *valueDefListPtr; - ExportElmt *exportList; - ImportModule *importModulePtr; - ImportModuleList *importModuleListPtr; - ImportElmt *importElmtPtr; - ImportElmtList *importElmtListPtr; - Tag *tagPtr; - TagList *tagListPtr; - Constraint *constraintPtr; - ConstraintList *constraintListPtr; - InnerSubtype *innerSubtypePtr; - ValueList *valueListPtr; - TypeOrValueList *typeOrValueListPtr; - TypeOrValue *typeOrValuePtr; - AsnPort *asnPortPtr; - AsnPortList *asnPortListPtr; - AttributeList *attrList; -} YYSTYPE; -#define BSTRING_SYM 258 -#define HSTRING_SYM 259 -#define CSTRING_SYM 260 -#define UCASEFIRST_IDENT_SYM 261 -#define LCASEFIRST_IDENT_SYM 262 -#define NAMEDMACRO_SYM 263 -#define MACRODEFBODY_SYM 264 -#define BRACEBAL_SYM 265 -#define NUMBER_ERANGE 266 -#define NUMBER_SYM 267 -#define SNACC_ATTRIBUTES 268 -#define DOT_SYM 269 -#define COMMA_SYM 270 -#define LEFTBRACE_SYM 271 -#define RIGHTBRACE_SYM 272 -#define LEFTPAREN_SYM 273 -#define RIGHTPAREN_SYM 274 -#define LEFTBRACKET_SYM 275 -#define RIGHTBRACKET_SYM 276 -#define LESSTHAN_SYM 277 -#define MINUS_SYM 278 -#define GETS_SYM 279 -#define BAR_SYM 280 -#define TAGS_SYM 281 -#define BOOLEAN_SYM 282 -#define INTEGER_SYM 283 -#define BIT_SYM 284 -#define STRING_SYM 285 -#define OCTET_SYM 286 -#define NULL_SYM 287 -#define SEQUENCE_SYM 288 -#define OF_SYM 289 -#define SET_SYM 290 -#define IMPLICIT_SYM 291 -#define CHOICE_SYM 292 -#define ANY_SYM 293 -#define OBJECT_IDENTIFIER_SYM 294 -#define OPTIONAL_SYM 295 -#define DEFAULT_SYM 296 -#define COMPONENTS_SYM 297 -#define UNIVERSAL_SYM 298 -#define APPLICATION_SYM 299 -#define PRIVATE_SYM 300 -#define TRUE_SYM 301 -#define FALSE_SYM 302 -#define BEGIN_SYM 303 -#define END_SYM 304 -#define DEFINITIONS_SYM 305 -#define EXPLICIT_SYM 306 -#define ENUMERATED_SYM 307 -#define EXPORTS_SYM 308 -#define IMPORTS_SYM 309 -#define REAL_SYM 310 -#define INCLUDES_SYM 311 -#define MIN_SYM 312 -#define MAX_SYM 313 -#define SIZE_SYM 314 -#define FROM_SYM 315 -#define WITH_SYM 316 -#define COMPONENT_SYM 317 -#define PRESENT_SYM 318 -#define ABSENT_SYM 319 -#define DEFINED_SYM 320 -#define BY_SYM 321 -#define PLUS_INFINITY_SYM 322 -#define MINUS_INFINITY_SYM 323 -#define SEMI_COLON_SYM 324 -#define IA5STRING_SYM 325 -#define PRINTABLESTRING_SYM 326 -#define NUMERICSTRING_SYM 327 -#define TELETEXSTRING_SYM 328 -#define T61STRING_SYM 329 -#define VIDEOTEXSTRING_SYM 330 -#define VISIBLESTRING_SYM 331 -#define ISO646STRING_SYM 332 -#define GRAPHICSTRING_SYM 333 -#define GENERALSTRING_SYM 334 -#define GENERALIZEDTIME_SYM 335 -#define UTCTIME_SYM 336 -#define EXTERNAL_SYM 337 -#define OBJECTDESCRIPTOR_SYM 338 -#define OPERATION_SYM 339 -#define ARGUMENT_SYM 340 -#define RESULT_SYM 341 -#define ERRORS_SYM 342 -#define LINKED_SYM 343 -#define ERROR_SYM 344 -#define PARAMETER_SYM 345 -#define BIND_SYM 346 -#define BINDERROR_SYM 347 -#define UNBIND_SYM 348 -#define UNBINDERROR_SYM 349 -#define ASE_SYM 350 -#define OPERATIONS_SYM 351 -#define CONSUMERINVOKES_SYM 352 -#define SUPPLIERINVOKES_SYM 353 -#define AC_SYM 354 -#define ASES_SYM 355 -#define REMOTE_SYM 356 -#define INITIATOR_SYM 357 -#define RESPONDER_SYM 358 -#define ABSTRACTSYNTAXES_SYM 359 -#define CONSUMER_SYM 360 -#define EXTENSIONS_SYM 361 -#define CHOSEN_SYM 362 -#define EXTENSION_SYM 363 -#define CRITICAL_SYM 364 -#define FOR_SYM 365 -#define DELIVERY_SYM 366 -#define SUBMISSION_SYM 367 -#define TRANSFER_SYM 368 -#define EXTENSIONATTRIBUTE_SYM 369 -#define TOKEN_SYM 370 -#define TOKENDATA_SYM 371 -#define SECURITYCATEGORY_SYM 372 -#define OBJECT_SYM 373 -#define PORTS_SYM 374 -#define BOXC_SYM 375 -#define BOXS_SYM 376 -#define PORT_SYM 377 -#define ABSTRACTOPS_SYM 378 -#define REFINE_SYM 379 -#define AS_SYM 380 -#define RECURRING_SYM 381 -#define VISIBLE_SYM 382 -#define PAIRED_SYM 383 -#define ABSTRACTBIND_SYM 384 -#define ABSTRACTUNBIND_SYM 385 -#define TO_SYM 386 -#define ABSTRACTERROR_SYM 387 -#define ABSTRACTOPERATION_SYM 388 -#define ALGORITHM_SYM 389 -#define ENCRYPTED_SYM 390 -#define SIGNED_SYM 391 -#define SIGNATURE_SYM 392 -#define PROTECTED_SYM 393 -#define OBJECTTYPE_SYM 394 -#define SYNTAX_SYM 395 -#define ACCESS_SYM 396 -#define STATUS_SYM 397 -#define DESCRIPTION_SYM 398 -#define REFERENCE_SYM 399 -#define INDEX_SYM 400 -#define DEFVAL_SYM 401 - - -extern YYSTYPE yylval; diff --git a/SecuritySNACCRuntime/compiler/core/parse-asn1.y b/SecuritySNACCRuntime/compiler/core/parse-asn1.y deleted file mode 100644 index 1228b965..00000000 --- a/SecuritySNACCRuntime/compiler/core/parse-asn1.y +++ /dev/null @@ -1,3196 +0,0 @@ -/* - * compiler/core/parse-asn1.y - * - * yacc source for ASN.1 '88 Parser - * As interpreted from Appendix II of CCITT recomendation X.208 - * - * Parses ASN.1 into a monster data structure - * - * Some old versions of yacc will croak due the length - * of some of the symbols (use -Nc10000 with other versions) - * - * Mike Sample - * 90/05/03 - * 91/09/02 Rewritten with "ASN.1" generated data struct - * - * Copyright (C) 1990, 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/parse-asn1.y,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: parse-asn1.y,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:51 aram - * Originals from SMIME Free Library. - * - * Revision 1.11 1997/08/28 09:46:41 wan - * Reworked number range checking, only gives warning now. - * - * Revision 1.10 1997/06/19 09:17:17 wan - * Added isPdu flag to tables. Added value range checks during parsing. - * - * Revision 1.9 1997/03/13 14:48:28 wan - * Parsed SEQUENCE SIZE(..) OF as SET, corrected. - * - * Revision 1.8 1997/03/03 11:58:34 wan - * Final pre-delivery stuff (I hope). - * - * Revision 1.7 1997/02/28 13:39:55 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.6 1995/07/25 19:17:55 rj - * use memzero that is defined in .../snacc.h to use either memset or bzero. - * - * changed `_' to `-' in file names. - * - * Revision 1.5 1995/02/18 12:52:21 rj - * portablity fix (string(s).h) - * - * Revision 1.4 1995/02/17 20:13:21 rj - * portablity fix (string(s).h) - * - * Revision 1.3 1994/10/08 03:42:46 rj - * renamed the FLEX cpp define to FLEX_SCANNER since that's what flex defines. - * - * Revision 1.2 1994/09/01 00:42:03 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:29 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -%{ - -#include "snacc.h" - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "lib-types.h" -#include "snacc-util.h" -#include "exports.h" -#include "parser.h" -#include "lex-stuff.h" - -/* - * smallErrG - * used for small errors that should prevent code generation but not - * prevent the later error checking passes - */ -int smallErrG = FALSE; - -/* - * firstTimeThroughG - * used incase the asn1.lex was compiled with flex in which - * case the lexical analyzer must be reset for every ASN.1 file - * parsed, except the first - */ -static int firstTimeThroughG = TRUE; - -/* - * modulePtrG - * used to hold the parsed value. The root of the parse tree. - */ -Module *modulePtrG; - - -/* - * oidElmtValDefsG - * used to hold integer values that are defined as arc numbers - * the modules object identifiers. - * eg. FOO-MODULE { joint-iso-ccitt dod (2) foo (2) 3 2 } DEFINITIONS ::= - * would put dod/2 and foo/2 in the oidElmtValDefsG list - * Note: only some oid's (modules name/import list module names) - * are parsed by the yacc code. The rest are parsed later - * due to ambiguities that arise without type info. - */ -ValueDefList *oidElmtValDefsG = NULL; - - -/* - * ApplTag - * used to hold APPLICATION tags that have been defined in - * a module. This permits checking for the the error of - * using the same APPLICATION tag in 1 module. The - * ApplTags list (appTagsG) is emptied for each module. - */ -typedef struct ApplTag -{ - unsigned long int lineNo; - unsigned long int tagCode; - struct ApplTag *next; -} ApplTag; - -ApplTag *applTagsG = NULL; - -/* - * Protos for ApplTag related stuff. These are defined at the - * end of this file - */ -void PushApplTag PROTO ((unsigned long int tagCode, unsigned long int lineNo)); -void FreeApplTags(); - - - -/* - * the following are globals to simplify disparity between - * productions and produced data structure - */ - -/* - * these are used in the ValueRange subtype production - */ -static int valueRangeUpperEndInclusiveG; -static int valueRangeLowerEndInclusiveG; - -/* - * used to set exports flag in Type/value defs - * exportListG holds the explicitly exported elements. - * see SetExports routine in export.c - */ -ExportElmt *exportListG = NULL; -int exportsParsedG; - - -/* - * globals for the APPLICATION-CONTEXT macro productions - */ -static ValueList *rosAcSymmetricAsesG; -static ValueList *rosAcResponderConsumerOfG; -static ValueList *rosAcInitiatorConsumerOfG; - -/* - * used with MTSAS Extension macro - * set to NULL for the initial parse. - */ -static AsnBool *mtsasCriticalForSubmissionG = NULL; -static AsnBool *mtsasCriticalForTransferG = NULL; -static AsnBool *mtsasCriticalForDeliveryG = NULL; - -/* - * Asn PORT macro globals - */ -static TypeOrValueList *asnConsumerG; -static TypeOrValueList *asnSupplierG; - - -/* - * parseErrCountG - * used to prevent too many cascade errors - */ -int parseErrCountG = 0; -#define MAX_ERR 50 -#define PARSE_ERROR()\ - parseErrCountG++;\ - modulePtrG->status = MOD_ERROR;\ - if (parseErrCountG > MAX_ERR)\ - {\ - fprintf (stderr, "Ackkkkk! too many errors - bye!\n");\ - exit (1);\ - } - - -%} - - -/* - * Union structure. A terminal or non-terminal can have - * one of these type values. - */ - -%union -{ - int intVal; - unsigned int uintVal; - char *charPtr; - Type *typePtr; - NamedType *namedTypePtr; - NamedTypeList *namedTypeListPtr; - Value *valuePtr; - NamedValue *namedValuePtr; - SubtypeValue *subtypeValuePtr; - Subtype *subtypePtr; - ModuleId *moduleId; - OID *oidPtr; - OidList *oidListPtr; - TypeDef *typeDefPtr; - TypeDefList *typeDefListPtr; - ValueDef *valueDefPtr; - ValueDefList *valueDefListPtr; - ExportElmt *exportList; - ImportModule *importModulePtr; - ImportModuleList *importModuleListPtr; - ImportElmt *importElmtPtr; - ImportElmtList *importElmtListPtr; - Tag *tagPtr; - TagList *tagListPtr; - Constraint *constraintPtr; - ConstraintList *constraintListPtr; - InnerSubtype *innerSubtypePtr; - ValueList *valueListPtr; - TypeOrValueList *typeOrValueListPtr; - TypeOrValue *typeOrValuePtr; - AsnPort *asnPortPtr; - AsnPortList *asnPortListPtr; - AttributeList *attrList; -} - -/* - * Terminals. Definitions can be found in input.lex. - */ - -/* - * these tokens (literals) have attributes (set in asn1.lex) - */ -%token BSTRING_SYM HSTRING_SYM CSTRING_SYM - UCASEFIRST_IDENT_SYM LCASEFIRST_IDENT_SYM - NAMEDMACRO_SYM MACRODEFBODY_SYM - BRACEBAL_SYM NUMBER_ERANGE - -%token NUMBER_SYM - -%token SNACC_ATTRIBUTES - -/* - * these tokens have no attributes - */ -%token DOT_SYM COMMA_SYM LEFTBRACE_SYM RIGHTBRACE_SYM LEFTPAREN_SYM - RIGHTPAREN_SYM LEFTBRACKET_SYM RIGHTBRACKET_SYM LESSTHAN_SYM - MINUS_SYM GETS_SYM BAR_SYM TAGS_SYM BOOLEAN_SYM INTEGER_SYM - BIT_SYM STRING_SYM OCTET_SYM NULL_SYM SEQUENCE_SYM OF_SYM - SET_SYM IMPLICIT_SYM CHOICE_SYM ANY_SYM - OBJECT_IDENTIFIER_SYM OPTIONAL_SYM DEFAULT_SYM COMPONENTS_SYM - UNIVERSAL_SYM APPLICATION_SYM PRIVATE_SYM TRUE_SYM FALSE_SYM - BEGIN_SYM END_SYM DEFINITIONS_SYM EXPLICIT_SYM ENUMERATED_SYM - EXPORTS_SYM IMPORTS_SYM REAL_SYM INCLUDES_SYM MIN_SYM MAX_SYM - SIZE_SYM FROM_SYM WITH_SYM COMPONENT_SYM PRESENT_SYM ABSENT_SYM - DEFINED_SYM BY_SYM PLUS_INFINITY_SYM MINUS_INFINITY_SYM - SEMI_COLON_SYM IA5STRING_SYM PRINTABLESTRING_SYM - NUMERICSTRING_SYM TELETEXSTRING_SYM T61STRING_SYM - VIDEOTEXSTRING_SYM VISIBLESTRING_SYM ISO646STRING_SYM - GRAPHICSTRING_SYM GENERALSTRING_SYM - GENERALIZEDTIME_SYM UTCTIME_SYM EXTERNAL_SYM - OBJECTDESCRIPTOR_SYM - /* the following are used in macros */ - OPERATION_SYM ARGUMENT_SYM RESULT_SYM ERRORS_SYM LINKED_SYM - ERROR_SYM PARAMETER_SYM - BIND_SYM BINDERROR_SYM UNBIND_SYM UNBINDERROR_SYM - ASE_SYM OPERATIONS_SYM CONSUMERINVOKES_SYM - SUPPLIERINVOKES_SYM - AC_SYM ASES_SYM REMOTE_SYM INITIATOR_SYM RESPONDER_SYM - ABSTRACTSYNTAXES_SYM CONSUMER_SYM - EXTENSIONS_SYM CHOSEN_SYM - EXTENSION_SYM CRITICAL_SYM FOR_SYM DELIVERY_SYM SUBMISSION_SYM - TRANSFER_SYM EXTENSIONATTRIBUTE_SYM - TOKEN_SYM TOKENDATA_SYM - SECURITYCATEGORY_SYM - OBJECT_SYM PORTS_SYM BOXC_SYM BOXS_SYM - PORT_SYM ABSTRACTOPS_SYM - REFINE_SYM AS_SYM RECURRING_SYM VISIBLE_SYM PAIRED_SYM - ABSTRACTBIND_SYM ABSTRACTUNBIND_SYM TO_SYM - ABSTRACTERROR_SYM ABSTRACTOPERATION_SYM - ALGORITHM_SYM ENCRYPTED_SYM SIGNED_SYM - SIGNATURE_SYM PROTECTED_SYM - OBJECTTYPE_SYM SYNTAX_SYM ACCESS_SYM STATUS_SYM - DESCRIPTION_SYM REFERENCE_SYM INDEX_SYM - DEFVAL_SYM - -/* - * Type definitions of non-terminal symbols - */ - -%type LineNo SetOpening SequenceOpening - -%type TagDefault - -%type SymbolList - -%type SymbolsFromModuleList - -%type SymbolsFromModule - -%type TypeAssignment - -%type ValueAssignment - -%type BinaryString HexString CharString - -%type number Class - -%type SignedNumber - -%type modulereference typereference identifier Symbol - - -%type ExternalValueReference -%type Value DefinedValue BuiltinValue BooleanValue - NullValue SpecialRealValue - -%type NamedValue - -%type ModuleIdentifier - -%type ObjectIdentifierValue AssignedIdentifier - ObjIdComponent NumberForm NameAndNumberForm - ObjIdComponentList -%type NameForm -%type BuiltinType DefinedType Subtype BooleanType IntegerType - BitStringType NullType SequenceType - SequenceOfType SetType SetOfType ChoiceType SelectionType - TaggedType AnyType ObjectIdentifierType - EnumeratedType RealType Type ExternalTypeReference - - - -%type NamedType ElementType - -%type AlternativeTypes AlternativeTypeList - ElementTypes ElementTypeList - -%type SubtypeValueSet SingleValue ContainedSubtype ValueRange - PermittedAlphabet SizeConstraint InnerTypeConstraints - -%type SubtypeSpec SubtypeValueSetList - -%type NamedConstraint Constraint - -%type TypeConstraints - -%type FullSpecification PartialSpecification - SingleTypeConstraint MultipleTypeConstraints - -%type LowerEndPoint UpperEndPoint LowerEndValue UpperEndValue - -%type PresenceConstraint - -%type ValueConstraint - -%type ExportSymbolList - -%type NamedNumber - -%type NamedNumberList NamedBitList - -%type Tag ClassNumber - -%type SnaccAttributes SnaccAttributeCommentList - -%type DefinedMacroName MacroReference - -%type DefinedMacroType - -%type PossiblyEmptyValueList ValueList - -%type PossiblyEmptyTypeOrValueList TypeOrValueList - -%type TypeOrValue - -%type RosOperationMacroType RosOperationMacroBody RosErrorMacroType - RosBindMacroType RosUnbindMacroType - RosAseMacroType RosAcMacroType - -%type RosOpArgument RosOpResult RosOpResultType - -%type RosOpErrors RosOpLinkedOps - -%type RosErrParameter - -%type RosBindArgument RosBindResult RosBindError RosUnbindError - -%type RosAseSymmetricAse RosAseConsumerInvokes - RosAseSupplierInvokes RosAseOperationList - -%type RosAcNonRoElements - -%type RosAcRoElements - -%type OidList RosAcAbstractSyntaxes - -%type MtsasExtensionsMacroType MtsasExtensionMacroType - MtsasExtensionAttributeMacroType MtsasTokenMacroType - MtsasTokenDataMacroType MtsasSecurityCategoryMacroType - -%type MtsasExtDefaultVal - -%type AsnObjectMacroType AsnPortMacroType AsnRefineMacroType - AsnAbstractBindMacroType AsnAbstractUnbindMacroType - AsnAbstractOperationMacroType AsnAbstractErrorMacroType - -%type AsnPorts AsnPortList - -%type AsnPort - -%type AsnPortType - -%type AsnObject AsnObjectList AsnPortSpec AsnPortSpecList - AsnObjectSpec AsnComponent AsnComponentList - -%type AsnOperations AsnConsumer AsnSupplier - -%type AsnAbstractBindPorts AsnAbstractUnbindPorts - -%type AfAlgorithmMacroType AfEncryptedMacroType - AfSignedMacroType AfSignatureMacroType - AfProtectedMacroType - -%type SnmpObjectTypeMacroType -%type SnmpStatus SnmpAccess -%type SnmpDescrPart SnmpReferPart SnmpDefValPart -%type SnmpIndexPart - -%start ModuleDefinition -%% - - - -/*-----------------------------------------------------------------------*/ -/* Module def/import/export productions */ -/*-----------------------------------------------------------------------*/ - -LineNo: { $$ = myLineNoG; } - -ModuleDefinition: - ModuleIdentifier - DEFINITIONS_SYM - TagDefault { modulePtrG->tagDefault = $3; } - GETS_SYM - BEGIN_SYM - ModuleBody - END_SYM - { - modulePtrG->modId = $1; - - /* - * Set exported flags in type/value defs as appropriate - */ - SetExports (modulePtrG, exportListG, exportsParsedG); - - /* clean up */ - - /* Free Application tag list */ - FreeApplTags(); - - /* - * Add values defined in any parsed object identifiers. - * Only the Module name and some macro oids have been parsed, - * the rest are just "{...}" strings at this point - * (they will be parsed in later) - */ - modulePtrG->valueDefs = - AsnListConcat (modulePtrG->valueDefs, oidElmtValDefsG); - - /* - * free list head only - */ - Free (oidElmtValDefsG); - } -; - -TagDefault: - EXPLICIT_SYM TAGS_SYM { $$ = EXPLICIT_TAGS; } - | IMPLICIT_SYM TAGS_SYM { $$ = IMPLICIT_TAGS; } - | empty - { - /* default is EXPLICIT TAGS */ - $$ = EXPLICIT_TAGS; - } -; - -ModuleIdentifier: - modulereference AssignedIdentifier - { - $$ = MT (ModuleId); - $$->name = $1; - $$->oid = $2; - } -; - -AssignedIdentifier: - ObjectIdentifierValue - | empty { $$ = NULL; } -; - -ModuleBody: - Exports Imports AssignmentList - | empty -; - -Exports: - EXPORTS_SYM SymbolsExported SEMI_COLON_SYM - { - /* - * allows differentiation between "EXPORTS;" - * (in which no exports allowed) - * and when the EXPORTS symbol does not appear - * (then all are exported) - */ - exportsParsedG = TRUE; - } - | EXPORTS_SYM error SEMI_COLON_SYM - { - PARSE_ERROR(); - exportsParsedG = FALSE; - exportListG = NULL; - yyerrok; - } - | empty { exportsParsedG = FALSE; } -; - -SymbolsExported: - ExportSymbolList { exportListG = $1; } - | empty { exportListG = NULL; } -; - -ExportSymbolList: - Symbol - { - $$ = MT (ExportElmt); - $$->name = $1; - $$->lineNo = myLineNoG; - $$->next = NULL; - } - | ExportSymbolList COMMA_SYM LineNo Symbol - { - $$ = MT (ExportElmt); - $$->name = $4; - $$->next = $1; - $$->lineNo = $3; - } -; - -Imports: - IMPORTS_SYM SymbolsImported SEMI_COLON_SYM - | IMPORTS_SYM error SEMI_COLON_SYM - { - PARSE_ERROR(); - yyerrok; - } - | empty -; - -SymbolsImported: - SymbolsFromModuleList { modulePtrG->imports = $1; } - | empty -; - -SymbolsFromModuleList: - SymbolsFromModuleList SymbolsFromModule - { - APPEND ($2,$1); - } - | SymbolsFromModule - { - $$ = NEWLIST(); - APPEND ($1, $$); - } -; - -SymbolsFromModule: - SymbolList FROM_SYM LineNo ModuleIdentifier - { - $$ = MT (ImportModule); - $$->modId = $4; - $$->lineNo = $3; - $$->importElmts = $1; - } -; - - -SymbolList: - SymbolList COMMA_SYM Symbol - { - ImportElmt *ie; - - ie = MT (ImportElmt); - ie->name = $3; - ie->lineNo = myLineNoG; - APPEND (ie, $1); - $$ = $1; - } - | Symbol - { - ImportElmt *ie; - - /* called for the first element only, so create list head */ - $$ = NEWLIST(); - ie = MT (ImportElmt); - ie->name = $1; - ie->lineNo = myLineNoG; - APPEND (ie, $$); - } -; - -Symbol: - typereference - | identifier - | DefinedMacroName /* This solves macro "keyword" problem */ - { - /* - * hack to make DefinedMacroNames "freeable" - * like idents and typeref - */ - $$ = Malloc (strlen ($1)+1); - strcpy ($$, $1); - } -; - - - -AssignmentList: - AssignmentList AssignmentOrError - | AssignmentOrError -; - -AssignmentOrError: - Assignment - | Assignment SEMI_COLON_SYM - | error SEMI_COLON_SYM - { - PARSE_ERROR(); - yyerrok; - } -; - -Assignment: - TypeAssignment - { - /* - * a macro may produce a null type - */ - if ($1 != NULL) - { - /* - * add to head of type def list - */ - APPEND ($1, modulePtrG->typeDefs); - } - - } - | ValueAssignment - { - /* - * a macro may produce a null value - */ - if ($1 != NULL) - { - /* - * add to head of value def list - */ - APPEND ($1, modulePtrG->valueDefs); - } - } - | NAMEDMACRO_SYM GETS_SYM BEGIN_SYM LineNo { LexBeginMacroDefContext(); } - MACRODEFBODY_SYM - { - TypeDef *tmpTypeDef; - - /* - * LEXICAL TIE IN!! - * create macro type to eliminate import resolution - * errors msgs from other modules importing the macro. - * (hopefully) Only the import list will link with - * these type defs. - * keeps macro def around incase of future processing needs - * - * NOTE: MACRODEFBODY_SYM returns the macro def body with - * with "BEGIN" at the begininning and "END" at the end - */ - - /* - * put lexical analyzer back in normal state - */ - /* BEGIN (INITIAL); */ - LexBeginInitialContext(); - - tmpTypeDef = MT (TypeDef); - SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, $4); - tmpTypeDef->definedName = $1; - - /* - * keeps the macro def body - * (all text between & including the BEGIN and END) - * as a simple string - incase you want to fart around with - * it. - */ - tmpTypeDef->type->basicType->a.macroDef = $6; - - /* - * put in type list - */ - APPEND (tmpTypeDef, modulePtrG->typeDefs); - - } - | NAMEDMACRO_SYM GETS_SYM MacroReference - { - TypeDef *tmpTypeDef; - - tmpTypeDef = MT (TypeDef); - SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, myLineNoG); - tmpTypeDef->definedName = $1; - - tmpTypeDef->type->basicType->a.macroDef = $3; - - /* - * put in type list - */ - APPEND (tmpTypeDef, modulePtrG->typeDefs); - - } - | NAMEDMACRO_SYM GETS_SYM modulereference DOT_SYM MacroReference - { - TypeDef *tmpTypeDef; - - tmpTypeDef = MT (TypeDef); - SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, myLineNoG); - tmpTypeDef->definedName = $1; - - tmpTypeDef->type->basicType->a.macroDef = - (MyString) Malloc (strlen ($3) + strlen ($5) + 2); - - strcpy (tmpTypeDef->type->basicType->a.macroDef, $3); - strcat (tmpTypeDef->type->basicType->a.macroDef, "."); - strcat (tmpTypeDef->type->basicType->a.macroDef, $5); - - /* - * put in type list - */ - APPEND (tmpTypeDef, modulePtrG->typeDefs); - - Free ($3); - Free ($5); - } -; - -MacroReference: - typereference - | DefinedMacroName -; - -/*-----------------------------------------------------------------------*/ -/* Type Notation Productions */ -/*-----------------------------------------------------------------------*/ - -TypeAssignment: - typereference GETS_SYM SnaccAttributes LineNo Type SnaccAttributes - { - /* - * a macro type may produce a null type - */ - if ($5 != NULL) - { - $$ = MT (TypeDef); - $$->type = $5; - $$->type->lineNo = $4; - $$->type->attrList = $6; - $$->definedName = $1; - $$->attrList = $3; - } - else - $$ = NULL; - } -; - - -ExternalTypeReference: - modulereference DOT_SYM LineNo typereference - { - /* allocate a Type with basic type of ImportTypeRef */ - SetupType (&$$, BASICTYPE_IMPORTTYPEREF, $3); - $$->basicType->a.importTypeRef = MT (TypeRef); - $$->basicType->a.importTypeRef->typeName = $4; - $$->basicType->a.importTypeRef->moduleName = $1; - - /* add entry to this module's import list */ - AddPrivateImportElmt (modulePtrG, $4, $1, $3); - } -; - - -DefinedType: /* could by CharacterString or Useful types too */ - ExternalTypeReference { $$ = $1; } - | typereference - { - SetupType (&$$, BASICTYPE_LOCALTYPEREF, myLineNoG); - $$->basicType->a.localTypeRef = MT (TypeRef); - $$->basicType->a.localTypeRef->typeName = $1; - } -; - - - -Type: - DefinedMacroType - | BuiltinType - | DefinedType - | Subtype -; - -BuiltinType: - BooleanType - | IntegerType - | BitStringType - | NullType - | SequenceType - | SequenceOfType - | SetType - | SetOfType - | ChoiceType - | SelectionType - | TaggedType - | AnyType - | ObjectIdentifierType - | EnumeratedType - | RealType - | OCTET_SYM STRING_SYM - { - SetupType (&$$, BASICTYPE_OCTETSTRING, myLineNoG); - } -; - -NamedType: - identifier Type - { - $$ = MT (NamedType); - $$->type = $2; - $$->fieldName = $1; - } - | Type /* this handles selectionType as well */ - { - $$ = MT (NamedType); - $$->type = $1; - } -; - -BooleanType: - BOOLEAN_SYM - { - SetupType (&$$, BASICTYPE_BOOLEAN, myLineNoG); - } -; - -IntegerType: - INTEGER_SYM - { - SetupType (&$$, BASICTYPE_INTEGER, myLineNoG); - $$->basicType->a.integer = NEWLIST(); /* empty list */ - } - | INTEGER_SYM LEFTBRACE_SYM NamedNumberList RIGHTBRACE_SYM - { - SetupType (&$$, BASICTYPE_INTEGER, myLineNoG); - $$->basicType->a.integer = $3; - } -; - - -NamedNumberList: - NamedNumber - { - $$ = NEWLIST(); - APPEND ($1, $$); - } - | NamedNumberList COMMA_SYM NamedNumber - { - APPEND ($3,$1); - $$ = $1; - } -; - -NamedNumber: - identifier LEFTPAREN_SYM SignedNumber RIGHTPAREN_SYM - { - $$ = MT (ValueDef); - $$->definedName = $1; - SetupValue (&$$->value, BASICVALUE_INTEGER, myLineNoG); - $$->value->basicValue->a.integer = $3; - } - | identifier LEFTPAREN_SYM DefinedValue RIGHTPAREN_SYM - { - $$ = MT (ValueDef); - $$->definedName = $1; - $$->value = $3; - } -; - -SignedNumber: - NUMBER_SYM - { - if ($1>0x7FFFFFFF) { - yyerror("Warning: positive signed number out of range"); - $$ = 0x7FFFFFFF; - } - } - | NUMBER_ERANGE - { - yyerror ("Warning: positive signed number out of range"); - $$ = 0x7FFFFFFF; - /* modulePtrG->status = MOD_ERROR; */ - } - | MINUS_SYM NUMBER_SYM - { - if ($2>0x80000000) { - yyerror("Warning: negative signed number out of range"); - $$ = -0x80000000; - } else if ($2==0x80000000) { - $$ = -0x80000000; - } else { - $$ = -$2; - } - } - | MINUS_SYM NUMBER_ERANGE - { - yyerror ("Warning: negative signed number out of range"); - $$ = -0x80000000; - /* modulePtrG->status = MOD_ERROR; */ - } -; - -EnumeratedType: - ENUMERATED_SYM LEFTBRACE_SYM NamedNumberList RIGHTBRACE_SYM - { - SetupType (&$$, BASICTYPE_ENUMERATED, myLineNoG); - $$->basicType->a.enumerated = $3; - } -; - - -RealType: - REAL_SYM - { - SetupType (&$$, BASICTYPE_REAL, myLineNoG); - } -; - -BitStringType: - BIT_SYM STRING_SYM - { - SetupType (&$$, BASICTYPE_BITSTRING, myLineNoG); - $$->basicType->a.bitString = NEWLIST(); /* empty list */ - } - | BIT_SYM STRING_SYM LEFTBRACE_SYM NamedBitList RIGHTBRACE_SYM - { - SetupType (&$$, BASICTYPE_BITSTRING, myLineNoG); - $$->basicType->a.bitString = $4; - } -; - -NamedBitList: - NamedNumberList -; - - - -NullType: - NULL_SYM - { - SetupType (&$$, BASICTYPE_NULL, myLineNoG); - } -; - -SequenceOpening: - SEQUENCE_SYM LineNo LEFTBRACE_SYM - { $$ = $2; } -; - -SequenceType: - SequenceOpening ElementTypes RIGHTBRACE_SYM - { - NamedType *n; - - SetupType (&$$, BASICTYPE_SEQUENCE, $1); - - if (AsnListCount ((AsnList*)$2) != 0) - { - n = (NamedType*) FIRST_LIST_ELMT ((AsnList*)$2); - n->type->lineNo = $1; - } - - $$->basicType->a.sequence = $2; - - } - | SequenceOpening RIGHTBRACE_SYM - { - SetupType (&$$, BASICTYPE_SEQUENCE, $1); - - /* set up empty list for SEQ with no elmts */ - $$->basicType->a.sequence = AsnListNew (sizeof (void*)); - } -/* | SEQUENCE_SYM LEFTBRACE_SYM error RIGHTBRACE_SYM - { - PARSE_ERROR(); - yyerrok; - } */ -; - -ElementTypes: - ElementTypeList SnaccAttributes - { - NamedType *lastElmt; - - if ($2 != NULL) - { - lastElmt = (NamedType*)LAST_LIST_ELMT ($1); - lastElmt->type->attrList = $2; - } - $$ = $1; - } -; - -ElementTypeList: - ElementType - { - $$ = NEWLIST(); - APPEND ($1,$$); - } - | ElementTypeList COMMA_SYM SnaccAttributes LineNo ElementType - { - NamedType *lastElmt; - - if ($3 != NULL) - { - lastElmt = (NamedType*)LAST_LIST_ELMT ($1); - lastElmt->type->attrList = $3; - } - - APPEND ($5, $1); - lastElmt = (NamedType*)LAST_LIST_ELMT ($1); - lastElmt->type->lineNo = $4; - $$ = $1; - } -; - -ElementType: - NamedType - | NamedType OPTIONAL_SYM - { - $$ = $1; - $$->type->optional = TRUE; - } - | NamedType DEFAULT_SYM NamedValue - { - /* - * this rules uses NamedValue instead of Value - * for the stupid choice value syntax (fieldname value) - * it should be like a set/seq value (ie with - * enclosing { } - */ - $$ = $1; - $$->type->defaultVal = $3; - /* - * could link value to the elmt type here (done in link_types.c) - */ - } - | COMPONENTS_SYM OF_SYM Type - { - $$ = MT (NamedType); - SetupType (&$$->type, BASICTYPE_COMPONENTSOF, myLineNoG); - $$->type->basicType->a.componentsOf = $3; - } - | identifier COMPONENTS_SYM OF_SYM Type - { - $$ = MT (NamedType); - SetupType (&$$->type, BASICTYPE_COMPONENTSOF, myLineNoG); - $$->fieldName = $1; - $$->type->basicType->a.componentsOf = $4; - } -; - - - -SequenceOfType: - SEQUENCE_SYM OF_SYM Type - { - NamedType *n; - - /* does not use SEQUENCE == SEQ OF ANY abrev*/ - SetupType (&$$, BASICTYPE_SEQUENCEOF, myLineNoG); - - /* grab line number from first elmt */ - if ($3 != NULL) - $$->lineNo = $3->lineNo - 1; - - $$->basicType->a.sequenceOf = $3; - } -; - -SetOpening: - SET_SYM LineNo LEFTBRACE_SYM { $$ = $2; } -; - -SetType: - SetOpening ElementTypes RIGHTBRACE_SYM - { - NamedType *n; - - SetupType (&$$, BASICTYPE_SET, $1); - - /* reset first elmt's line number */ - if (AsnListCount ((AsnList*)$2) != 0) - { - n = (NamedType*)FIRST_LIST_ELMT ((AsnList*)$2); - n->type->lineNo = $1; - } - $$->basicType->a.set = $2; - } - | SetOpening RIGHTBRACE_SYM - { - SetupType (&$$, BASICTYPE_SET, $1); - - /* set up empty elmt list for SET */ - $$->basicType->a.set = AsnListNew (sizeof (void*)); - } -/* | SET_SYM LEFTBRACE_SYM error RIGHTBRACE_SYM - { - PARSE_ERROR(); - yyerrok; - } */ -; - - -SetOfType: - SET_SYM OF_SYM Type - { - /* does not allow SET == SET OF ANY Abrev */ - SetupType (&$$, BASICTYPE_SETOF, myLineNoG); - - if ($3 != NULL) - $$->lineNo = $3->lineNo; - - $$->basicType->a.setOf = $3; - } -; - - -ChoiceType: - CHOICE_SYM LineNo LEFTBRACE_SYM AlternativeTypes RIGHTBRACE_SYM - { - NamedType *n; - - SetupType (&$$, BASICTYPE_CHOICE, $2); - - $$->basicType->a.choice = $4; - - if (AsnListCount ($4) != 0) - { - n = (NamedType*)FIRST_LIST_ELMT ($4); - n->type->lineNo = $2; - } - } -; - -AlternativeTypes: - AlternativeTypeList SnaccAttributes - { - NamedType *lastElmt; - if ($2 != NULL) - { - lastElmt = (NamedType*)LAST_LIST_ELMT ($1); - lastElmt->type->attrList = $2; - } - $$ = $1; - } -; - -AlternativeTypeList: - NamedType - { - $$ = NEWLIST(); - APPEND ($1, $$); - } - | AlternativeTypeList COMMA_SYM SnaccAttributes NamedType - { - NamedType *lastElmt; - - if ($3 != NULL) - { - lastElmt = (NamedType*)LAST_LIST_ELMT ($1); - lastElmt->type->attrList = $3; - } - APPEND ($4,$1); - $$ = $1; - } -; - - -SelectionType: - identifier LESSTHAN_SYM Type - { - /* - * the selection type should be replaced after - * link with actual type - */ - SetupType (&$$, BASICTYPE_SELECTION, myLineNoG); - - $$->basicType->a.selection = MT (SelectionType); - $$->basicType->a.selection->typeRef = $3; - $$->basicType->a.selection->fieldName = $1; - } -; - -TaggedType: - Tag Type - { - Tag *tag; - - /* remove next tag if any && IMPLICIT_TAGS */ - if ((modulePtrG->tagDefault == IMPLICIT_TAGS) && - ($2->tags != NULL) && !LIST_EMPTY ($2->tags)) - { - tag = (Tag*)FIRST_LIST_ELMT ($2->tags); /* set curr to first */ - AsnListFirst ($2->tags); /* set curr to first elmt */ - AsnListRemove ($2->tags); /* remove first elmt */ - - /* - * set implicit if implicitly tagged built in type (ie not ref) - * (this simplifies the module ASN.1 printer (print.c)) - */ - if (tag->tclass == UNIV) - $2->implicit = TRUE; - - Free (tag); - } - - PREPEND ($1, $2->tags); - $$ = $2; - } - | Tag IMPLICIT_SYM Type - { - Tag *tag; - - /* remove next tag if any */ - if (($3->tags != NULL) && !LIST_EMPTY ($3->tags)) - { - tag = (Tag*)FIRST_LIST_ELMT ($3->tags); /* set curr to first */ - AsnListFirst ($3->tags); /* set curr to first elmt */ - AsnListRemove ($3->tags); /* remove first elmt */ - - if (tag->tclass == UNIV) - $3->implicit = TRUE; - - Free (tag); - } - - /* - * must check after linking that implicitly tagged - * local/import type refs are not untagged choice/any etc - */ - else if (($3->basicType->choiceId == BASICTYPE_IMPORTTYPEREF) || - ($3->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - ($3->basicType->choiceId == BASICTYPE_SELECTION)) - $3->implicit = TRUE; - - /* - * all other implicitly tagable types should have tags - * to remove - if this else clause fires then it is - * probably a CHOICE or ANY type - */ - else - { - PrintErrLoc (modulePtrG->asn1SrcFileName, $3->lineNo); - fprintf (stderr, "ERROR - attempt to implicitly reference untagged type\n"); - smallErrG = 1; - } - - PREPEND ($1, $3->tags); - $$ = $3; - } - | Tag EXPLICIT_SYM Type - { - /* insert tag at head of list */ - $1->explicit = TRUE; - PREPEND ($1, $3->tags); - $$ = $3; - } -; - -Tag: - LEFTBRACKET_SYM Class ClassNumber RIGHTBRACKET_SYM - { - $$ = $3; - $$->tclass = $2; - $$->explicit = FALSE; /* default to false */ - - /* - * keep track of APPLICATION Tags per module - * should only be used once - */ - if ($2 == APPL) - { - PushApplTag ($$->code, myLineNoG); - } - } -; - -ClassNumber: - number - { - $$ = MT (Tag); - $$->code = $1; - } - | DefinedValue - { - $$ = MT (Tag); - $$->code = NO_TAG_CODE; - $$->valueRef = $1; - } -; - -Class: - UNIVERSAL_SYM { $$ = UNIV; } - | APPLICATION_SYM { $$ = APPL; } - | PRIVATE_SYM { $$ = PRIV; } - | empty { $$ = CNTX; } -; - - -AnyType: - ANY_SYM - { - SetupType (&$$, BASICTYPE_ANY, myLineNoG); - } - | ANY_SYM DEFINED_SYM BY_SYM identifier - { - SetupType (&$$, BASICTYPE_ANYDEFINEDBY, myLineNoG); - $$->basicType->a.anyDefinedBy = MT (AnyDefinedByType); - $$->basicType->a.anyDefinedBy->fieldName = $4; - } -; - - -ObjectIdentifierType: - OBJECT_IDENTIFIER_SYM - { - SetupType (&$$, BASICTYPE_OID, myLineNoG); - } -; - - -Subtype: - Type SubtypeSpec - { - /* - * append new subtype list to existing one (s) if any - * with AND relation - */ - AppendSubtype (&$1->subtypes, $2, SUBTYPE_AND); - $$ = $1; - } - | SET_SYM SizeConstraint OF_SYM Type - { - Subtype *s; - - SetupType (&$$, BASICTYPE_SETOF, myLineNoG); - $$->basicType->a.setOf = $4; - - /* add size constraint */ - s = MT (Subtype); - s->choiceId = SUBTYPE_SINGLE; - s->a.single = $2; - AppendSubtype (&$$->subtypes, s, SUBTYPE_AND); - } - | SEQUENCE_SYM SizeConstraint OF_SYM Type - { - Subtype *s; - - SetupType (&$$, BASICTYPE_SEQUENCEOF, myLineNoG); - $$->basicType->a.sequenceOf = $4; - - /* add size constraint */ - s = MT (Subtype); - s->choiceId = SUBTYPE_SINGLE; - s->a.single = $2; - AppendSubtype (&$$->subtypes, s, SUBTYPE_AND); - } -; - - -SubtypeSpec: - LEFTPAREN_SYM SubtypeValueSetList RIGHTPAREN_SYM - { - $$ = $2; - } -; - -SubtypeValueSetList: - SubtypeValueSet - { - Subtype *s; - - /* OR relation between all elmts of in ValueSetList */ - - $$ = MT (Subtype); - $$->choiceId = SUBTYPE_OR; - $$->a.or = NEWLIST(); - - s = MT (Subtype); - s->choiceId = SUBTYPE_SINGLE; - s->a.single = $1; - APPEND (s, $$->a.or); - } - | SubtypeValueSetList BAR_SYM SubtypeValueSet - { - Subtype *s; - s = MT (Subtype); - s->choiceId = SUBTYPE_SINGLE; - s->a.single = $3; - APPEND (s, $1->a.or); - $$ = $1; - } -; - - -SubtypeValueSet: - SingleValue - | ContainedSubtype - | ValueRange - | PermittedAlphabet - | SizeConstraint - | InnerTypeConstraints -; - -SingleValue: - Value - { - $$ = MT (SubtypeValue); - $$->choiceId = SUBTYPEVALUE_SINGLEVALUE; - $$->a.singleValue = $1; - } - -ContainedSubtype: - INCLUDES_SYM Type - { - $$ = MT (SubtypeValue); - $$->choiceId = SUBTYPEVALUE_CONTAINED; - $$->a.contained = $2; - } -; - -ValueRange: - LowerEndPoint DOT_SYM DOT_SYM UpperEndPoint - { - $$ = MT (SubtypeValue); - $$->choiceId = SUBTYPEVALUE_VALUERANGE; - $$->a.valueRange = MT (ValueRangeSubtype); - $$->a.valueRange->lowerEndInclusive = - valueRangeLowerEndInclusiveG; - $$->a.valueRange->upperEndInclusive = - valueRangeUpperEndInclusiveG; - $$->a.valueRange->lowerEndValue = $1; - $$->a.valueRange->upperEndValue = $4; - } -; - -LowerEndPoint: - LowerEndValue - { - $$ = $1; - valueRangeLowerEndInclusiveG = TRUE; - } - | LowerEndValue LESSTHAN_SYM - { - $$ = $1; - valueRangeLowerEndInclusiveG = FALSE; - } -; - -UpperEndPoint: - UpperEndValue - { - $$ = $1; - valueRangeUpperEndInclusiveG = TRUE; - } - | LESSTHAN_SYM UpperEndValue - { - $$ = $2; - valueRangeUpperEndInclusiveG = FALSE; - } -; - -LowerEndValue: - Value { $$ = $1; } - | MIN_SYM - { - SetupValue (&$$, BASICVALUE_SPECIALINTEGER, myLineNoG); - $$->basicValue->a.specialInteger = MIN_INT; - } -; - -UpperEndValue: - Value { $$ = $1; } - | MAX_SYM - { - SetupValue (&$$, BASICVALUE_SPECIALINTEGER, myLineNoG); - $$->basicValue->a.specialInteger = MAX_INT; - } -; - -SizeConstraint: - SIZE_SYM SubtypeSpec - { - $$ = MT (SubtypeValue); - $$->choiceId = SUBTYPEVALUE_SIZECONSTRAINT; - $$->a.sizeConstraint = $2; - } -; - - -PermittedAlphabet: - FROM_SYM SubtypeSpec - { - $$ = MT (SubtypeValue); - $$->choiceId = SUBTYPEVALUE_PERMITTEDALPHABET; - $$->a.permittedAlphabet = $2; - } -; - -InnerTypeConstraints: - WITH_SYM COMPONENT_SYM SingleTypeConstraint - { - $$ = MT (SubtypeValue); - $$->choiceId = SUBTYPEVALUE_INNERSUBTYPE; - $$->a.innerSubtype = $3; - } - | WITH_SYM COMPONENTS_SYM MultipleTypeConstraints - { - $$ = MT (SubtypeValue); - $$->choiceId = SUBTYPEVALUE_INNERSUBTYPE; - $$->a.innerSubtype = $3; - } -; - -SingleTypeConstraint: - SubtypeSpec - { - Constraint *constraint; - - /* this constrains the elmt of setof or seq of */ - $$ = MT (InnerSubtype); - $$->constraintType = SINGLE_CT; - $$->constraints = NEWLIST(); - constraint = MT (Constraint); - APPEND (constraint, $$->constraints); - constraint->valueConstraints = $1; - } -; - -MultipleTypeConstraints: - FullSpecification - | PartialSpecification -; - -FullSpecification: - LEFTBRACE_SYM TypeConstraints RIGHTBRACE_SYM - { - $$ = MT (InnerSubtype); - $$->constraintType = FULL_CT; - $$->constraints = $2; - } -; - -PartialSpecification: - LEFTBRACE_SYM DOT_SYM DOT_SYM DOT_SYM COMMA_SYM TypeConstraints RIGHTBRACE_SYM - { - $$ = MT (InnerSubtype); - $$->constraintType = PARTIAL_CT; - $$->constraints = $6; - } -; - - -TypeConstraints: - NamedConstraint - { - $$ = NEWLIST(); - APPEND ($1, $$); - } - | TypeConstraints COMMA_SYM NamedConstraint - { - APPEND ($3, $1); - $$ = $1; - } -; - -NamedConstraint: - identifier Constraint - { - $$ = $2; - $$->fieldRef = $1; - } - | Constraint - -; - -Constraint: - ValueConstraint PresenceConstraint - { - $$ = MT (Constraint); - $$->presenceConstraint = $2; - $$->valueConstraints = $1; - } -; - -ValueConstraint: - SubtypeSpec { $$ = $1; } - | empty { $$ = NULL; } -; - -PresenceConstraint: - PRESENT_SYM { $$ = PRESENT_CT; } - | ABSENT_SYM { $$ = ABSENT_CT; } - | empty { $$ = EMPTY_CT; } - | OPTIONAL_SYM { $$ = OPTIONAL_CT; } -; - - - - - - -/*-----------------------------------------------------------------------*/ -/* Value Notation Productions */ -/*-----------------------------------------------------------------------*/ - -ValueAssignment: - identifier Type GETS_SYM LineNo Value - { - $$ = MT (ValueDef); - $$->definedName = $1; - $$->value = $5; - $$->value->lineNo = $4; - $$->value->type = $2; - } -; - - -Value: - BuiltinValue - | DefinedValue -; - -DefinedValue: - ExternalValueReference { $$ = $1; } - | identifier /* a defined value or a named elmt ref */ - { - /* - * for parse, may be set to BASICVALUE_IMPORTEDTYPEREF - * by linker - */ - SetupValue (&$$, BASICVALUE_LOCALVALUEREF, myLineNoG); - $$->basicValue->a.localValueRef = MT (ValueRef); - $$->basicValue->a.localValueRef->valueName = $1; - $$->valueType = BASICTYPE_UNKNOWN; - } -; - -ExternalValueReference: - modulereference DOT_SYM LineNo identifier - { - /* Alloc value with basicValue of importValueRef */ - SetupValue (&$$, BASICVALUE_IMPORTVALUEREF, $3); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.importValueRef = MT (ValueRef); - $$->basicValue->a.importValueRef->valueName = $4; - $$->basicValue->a.importValueRef->moduleName = $1; - - /* add entry to this module's import list */ - AddPrivateImportElmt (modulePtrG, $4, $1, $3); - } -; - -BuiltinValue: - BooleanValue - | NullValue - | SpecialRealValue - | SignedNumber /* IntegerValue or "0" real val*/ - { - SetupValue (&$$, BASICVALUE_INTEGER, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.integer = $1; - } - | HexString /* OctetStringValue or BinaryStringValue */ - { - SetupValue (&$$, BASICVALUE_ASCIIHEX, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.asciiHex = MT (AsnOcts); - $$->basicValue->a.asciiHex->octs = $1; - $$->basicValue->a.asciiHex->octetLen = strlen ($1); - } - | BinaryString /* BinaryStringValue */ - { - SetupValue (&$$, BASICVALUE_ASCIIBITSTRING, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.asciiBitString = MT (AsnOcts); - $$->basicValue->a.asciiBitString->octs = $1; - $$->basicValue->a.asciiBitString->octetLen = strlen ($1); - } - | CharString - { - SetupValue (&$$, BASICVALUE_ASCIITEXT, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.asciiText = MT (AsnOcts); - $$->basicValue->a.asciiText->octs = $1; - $$->basicValue->a.asciiText->octetLen = strlen ($1); - } - | LEFTBRACE_SYM { LexBeginBraceBalContext(); } BRACEBAL_SYM - { - /* - * LEXICAL TIE IN!! - * string returned by BRACEBAL_SYM has - * the $1 '{' prepended and includes everything - * upto and including '}' that balances $1 - */ - LexBeginInitialContext(); - SetupValue (&$$, BASICVALUE_VALUENOTATION, myLineNoG); - $$->basicValue->a.valueNotation = MT (AsnOcts); - $$->basicValue->a.valueNotation->octs = $3; - $$->basicValue->a.valueNotation->octetLen = strlen ($3); - $$->valueType = BASICTYPE_UNKNOWN; - } -; - -BooleanValue: - TRUE_SYM - { - SetupValue (&$$, BASICVALUE_BOOLEAN, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.boolean = TRUE; - } - | FALSE_SYM - { - SetupValue (&$$, BASICVALUE_BOOLEAN, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.boolean = FALSE; - } -; - - -SpecialRealValue: - PLUS_INFINITY_SYM - { - SetupValue (&$$, BASICVALUE_SPECIALREAL, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.specialReal = PLUS_INFINITY_REAL; - } - | MINUS_INFINITY_SYM - { - SetupValue (&$$, BASICVALUE_SPECIALREAL, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - $$->basicValue->a.specialReal = MINUS_INFINITY_REAL; - } -; - - - -NullValue: - NULL_SYM - { - /* create a NULL value */ - SetupValue (&$$, BASICVALUE_NULL, myLineNoG); - $$->valueType = BASICTYPE_UNKNOWN; - } -; - - -NamedValue: - Value - { - $$ = MT (NamedValue); - $$->value = $1; - } - | identifier Value - { - $$ = MT (NamedValue); - $$->value = $2; - $$->fieldName = $1; - } -; - - -ObjectIdentifierValue: - LEFTBRACE_SYM ObjIdComponentList RIGHTBRACE_SYM - { - /* - * example OID setup - * - * for { ccitt foo (1) bar bell (bunt) 2 } - * - * ccitt - * - arcnum is set to number from oid table (oid.c) - * foo (1) - * - sets up a new value def foo defined as 1 - * - makes oid valueref a value ref to foo (doesn't link it tho) - * bar - * - makes oid valueref a value ref to bar (doesn't link it tho) - * bell (bunt) - * - sets up a new value def bell defined as a val ref to bunt - * - makes oid valueref a value ref to bell (doesn't link it tho) - * 2 - * - arcnum is set to 2 - */ - - $$ = $2; - } -; - - -ObjIdComponentList: - ObjIdComponentList ObjIdComponent - { - OID *o; - /* append component */ - for (o = $1; o->next != NULL; o = o->next) - ; - o->next = $2; - $$ = $1; - } - | ObjIdComponent - -; - - -ObjIdComponent: - NumberForm - | NameForm - { - Value *newVal; - /* - * if the arcName is a defined arc name like - * ccitt or iso etc, fill in the arc number. - * otherwise make a value ref to that named value - */ - $$ = MT (OID); - - $$->arcNum = OidArcNameToNum ($1); - if ($$->arcNum == NULL_OID_ARCNUM) - { - /* set up value ref to named value */ - SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG); - newVal->basicValue->a.localValueRef = MT (ValueRef); - newVal->valueType = BASICTYPE_INTEGER; - newVal->basicValue->a.localValueRef->valueName = $1; - $$->valueRef = newVal; - } - } - | NameAndNumberForm -; - - -NumberForm: - number - { - $$ = MT (OID); - $$->arcNum = $1; - } -; - -NameForm: - identifier -; - - -NameAndNumberForm: - identifier LEFTPAREN_SYM NumberForm RIGHTPAREN_SYM - { - Value *newVal; - - $$ = $3; - - /* shared refs to named numbers name */ - SetupValue (&newVal, BASICVALUE_INTEGER, myLineNoG); - newVal->basicValue->a.integer = $$->arcNum; - newVal->valueType = BASICTYPE_INTEGER; - AddNewValueDef (oidElmtValDefsG, $1, newVal); - - SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG); - newVal->basicValue->a.localValueRef = MT (ValueRef); - newVal->basicValue->a.localValueRef->valueName = $1; - - $$->valueRef = newVal; - } - | identifier LEFTPAREN_SYM DefinedValue RIGHTPAREN_SYM - { - Value *newVal; - - /* shared refs to named numbers name */ - $$ = MT (OID); - $$->arcNum = NULL_OID_ARCNUM; - - AddNewValueDef (oidElmtValDefsG, $1, $3); - - SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG); - newVal->basicValue->a.localValueRef = MT (ValueRef); - newVal->basicValue->a.localValueRef->valueName = $1; - - $$->valueRef = newVal; - } - -; - - - -BinaryString: - BSTRING_SYM -; - -HexString: - HSTRING_SYM -; - -CharString: - CSTRING_SYM -; - -number: - NUMBER_SYM - { - if ($1>0x7FFFFFFF) { - yyerror("Warning: number out of range"); - $$ = 0x7FFFFFFF; - } - } - | NUMBER_ERANGE - { - yyerror ("Warning: number out of range"); - $$ = 0x7FFFFFFF; - /* modulePtrG->status = MOD_ERROR; */ - } -; - -identifier: - LCASEFIRST_IDENT_SYM -; - -modulereference: - UCASEFIRST_IDENT_SYM -; - -typereference: - UCASEFIRST_IDENT_SYM -; - -empty: -; - - -/* Snacc attributes/extra type info - * - encapsulated in special comments - */ -SnaccAttributes: - SnaccAttributeCommentList - | empty {$$ = NULL;} -; - -SnaccAttributeCommentList: - SNACC_ATTRIBUTES - { - $$ = NEWLIST(); - APPEND ($1,$$); - } - | SnaccAttributeCommentList SNACC_ATTRIBUTES - { - APPEND ($2,$1); - $$ = $1; - } -; - -/* - * Macro Syntax definitions - **************************/ - -DefinedMacroType: - RosOperationMacroType - | RosErrorMacroType - | RosBindMacroType - | RosUnbindMacroType - | RosAseMacroType - | RosAcMacroType - | MtsasExtensionMacroType - | MtsasExtensionsMacroType - | MtsasExtensionAttributeMacroType - | MtsasTokenMacroType - | MtsasTokenDataMacroType - | MtsasSecurityCategoryMacroType - | AsnObjectMacroType - | AsnPortMacroType - | AsnRefineMacroType - | AsnAbstractBindMacroType - | AsnAbstractUnbindMacroType - | AsnAbstractOperationMacroType - | AsnAbstractErrorMacroType - | AfAlgorithmMacroType - | AfEncryptedMacroType - | AfProtectedMacroType - | AfSignatureMacroType - | AfSignedMacroType - | SnmpObjectTypeMacroType -; - -DefinedMacroName: - OPERATION_SYM { $$ = "OPERATION"; } - | ERROR_SYM { $$ = "ERROR"; } - | BIND_SYM { $$ = "BIND"; } - | UNBIND_SYM { $$ = "UNBIND"; } - | ASE_SYM { $$ = "APPLICATION-SERVICE-ELEMENT"; } - | AC_SYM { $$ = "APPLICATION-CONTEXT"; } - | EXTENSION_SYM { $$ = "EXTENSION"; } - | EXTENSIONS_SYM { $$ = "EXTENSIONS"; } - | EXTENSIONATTRIBUTE_SYM { $$ = "EXTENSION-ATTRIBUTE"; } - | TOKEN_SYM { $$ = "TOKEN"; } - | TOKENDATA_SYM { $$ = "TOKEN-DATA"; } - | SECURITYCATEGORY_SYM { $$ = "SECURITY-CATEGORY"; } - | OBJECT_SYM { $$ = "OBJECT"; } - | PORT_SYM { $$ = "PORT"; } - | REFINE_SYM { $$ = "REFINE"; } - | ABSTRACTBIND_SYM { $$ = "ABSTRACT-BIND"; } - | ABSTRACTUNBIND_SYM { $$ = "ABSTRACT-UNBIND"; } - | ABSTRACTOPERATION_SYM { $$ = "ABSTRACT-OPERATION"; } - | ABSTRACTERROR_SYM { $$ = "ABSTRACT-ERROR"; } - | ALGORITHM_SYM { $$ = "ALGORITHM"; } - | ENCRYPTED_SYM { $$ = "ENCRYPTED"; } - | SIGNED_SYM { $$ = "SIGNED"; } - | SIGNATURE_SYM { $$ = "SIGNATURE"; } - | PROTECTED_SYM { $$ = "PROTECTED"; } - | OBJECTTYPE_SYM { $$ = "OBJECT-TYPE"; } -; - - -/* - * Operation Macro (ROS) added by MS 91/08/27 - */ - -RosOperationMacroType: - OPERATION_SYM RosOperationMacroBody { $$ = $2; } -; - -RosOperationMacroBody: - RosOpArgument RosOpResult RosOpErrors RosOpLinkedOps - { - RosOperationMacroType *r; - - SetupMacroType (&$$, MACROTYPE_ROSOPERATION, myLineNoG); - r = $$->basicType->a.macroType->a.rosOperation = - MT (RosOperationMacroType); - r->arguments = $1; - r->result = $2; - r->errors = $3; - r->linkedOps = $4; - } -; - - -RosOpArgument: - ARGUMENT_SYM NamedType { $$ = $2; } - | empty { $$ = NULL; } -; - -RosOpResult: - RESULT_SYM RosOpResultType { $$ = $2; } - | empty { $$ = NULL; } -; - - -RosOpResultType: - NamedType - | empty { $$ = NULL; } -; - - -RosOpErrors: - ERRORS_SYM LEFTBRACE_SYM PossiblyEmptyTypeOrValueList RIGHTBRACE_SYM - { - $$ = $3; - } - | empty { $$ = NULL; } -; - - - -RosOpLinkedOps: - LINKED_SYM LEFTBRACE_SYM PossiblyEmptyTypeOrValueList RIGHTBRACE_SYM - { - $$ = $3; - } - | empty { $$ = NULL; } -; - - - - -/* - * ROS ERROR macro - ms 91/08/27 - */ - - -RosErrorMacroType: - ERROR_SYM RosErrParameter - { - RosErrorMacroType *r; - /* - * defines error macro type - */ - SetupMacroType (&$$, MACROTYPE_ROSERROR, myLineNoG); - r = $$->basicType->a.macroType->a.rosError = MT (RosErrorMacroType); - r->parameter = $2; - } -; - - -RosErrParameter: - PARAMETER_SYM NamedType { $$ = $2; } - | empty { $$ = NULL; } -; - - -/* - * ROS BIND macro - ms 91/09/13 - */ - -RosBindMacroType: - BIND_SYM RosBindArgument RosBindResult RosBindError - { - RosBindMacroType *r; - - SetupMacroType (&$$, MACROTYPE_ROSBIND, myLineNoG); - - r = $$->basicType->a.macroType->a.rosBind = MT (RosBindMacroType); - r->argument = $2; - r->result = $3; - r->error = $4; - } -; - -RosBindArgument: - ARGUMENT_SYM NamedType { $$ = $2; } - | empty { $$ = NULL; } -; - - -RosBindResult: - RESULT_SYM NamedType { $$ = $2; } - | empty { $$ = NULL; } -; - - -RosBindError: - BINDERROR_SYM NamedType { $$ = $2; } - | empty { $$ = NULL; } -; - - -/* - * ROS UNBIND ms 91/09/13 - */ - -RosUnbindMacroType: - UNBIND_SYM RosBindArgument RosBindResult RosUnbindError - { - RosBindMacroType *r; - - SetupMacroType (&$$, MACROTYPE_ROSUNBIND, myLineNoG); - - r = $$->basicType->a.macroType->a.rosUnbind = MT (RosBindMacroType); - r->argument = $2; - r->result = $3; - r->error = $4; - } -; - - -RosUnbindError: - UNBINDERROR_SYM NamedType { $$ = $2; } - | empty { $$ = NULL; } -; - - -/* - * ROS APPLICATION-SERVICE-ELEMENT macro ms 91/09/13 - */ - -RosAseMacroType: - ASE_SYM RosAseSymmetricAse - { - RosAseMacroType *r; - - SetupMacroType (&$$, MACROTYPE_ROSASE, myLineNoG); - r = $$->basicType->a.macroType->a.rosAse = MT (RosAseMacroType); - r->operations = $2; - } - | ASE_SYM RosAseConsumerInvokes RosAseSupplierInvokes - { - RosAseMacroType *r; - - SetupMacroType (&$$, MACROTYPE_ROSASE, myLineNoG); - r = $$->basicType->a.macroType->a.rosAse = MT (RosAseMacroType); - r->consumerInvokes = $2; - r->supplierInvokes = $3; - } -; - - -RosAseSymmetricAse: - OPERATIONS_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM - { - $$ = $3; - } -; - - -RosAseConsumerInvokes: - CONSUMERINVOKES_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM - { - $$ = $3; - } - | empty { $$ = NULL; } -; - - -RosAseSupplierInvokes: - SUPPLIERINVOKES_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM - { - $$ = $3; - } - | empty { $$ = NULL; } -; - - -RosAseOperationList: - ValueList -; - - -/* - * ROS APPLICATION-CONTEXT macro ms 91/09/13 - */ - -RosAcMacroType: - AC_SYM - RosAcNonRoElements - BIND_SYM Type - UNBIND_SYM Type - RosAcRoElements - RosAcAbstractSyntaxes - { - RosAcMacroType *r; - - SetupMacroType (&$$, MACROTYPE_ROSAC, myLineNoG); - r = $$->basicType->a.macroType->a.rosAc = MT (RosAcMacroType); - r->nonRoElements = $2; - r->bindMacroType = $4; - r->unbindMacroType = $6; - r->remoteOperations = $7; - r->operationsOf = rosAcSymmetricAsesG; - r->initiatorConsumerOf = rosAcInitiatorConsumerOfG; - r->responderConsumerOf = rosAcResponderConsumerOfG; - r->abstractSyntaxes = $8; - } -; - - -RosAcNonRoElements: - ASES_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM - { - $$ = $3; - } -; - - -RosAcRoElements: - REMOTE_SYM OPERATIONS_SYM LEFTBRACE_SYM Value RIGHTBRACE_SYM - RosAcSymmetricAses RosAcAsymmetricAses - { - $$ = $4; - } - | empty - { - $$ = NULL; - rosAcSymmetricAsesG = NULL; - rosAcInitiatorConsumerOfG = NULL; - rosAcResponderConsumerOfG = NULL; - } -; - -RosAcSymmetricAses: - OPERATIONS_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM - { - rosAcSymmetricAsesG = $4; - } - | empty { rosAcSymmetricAsesG = NULL; } -; - -RosAcAsymmetricAses: - RosAcInitiatorConsumerOf RosAcResponderConsumerOf -; - -RosAcInitiatorConsumerOf: - INITIATOR_SYM CONSUMER_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM - { - rosAcInitiatorConsumerOfG = $5; - } - | empty { rosAcInitiatorConsumerOfG = NULL; } -; - -RosAcResponderConsumerOf: - RESPONDER_SYM CONSUMER_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM - { - rosAcResponderConsumerOfG = $5; - } - | empty { rosAcResponderConsumerOfG = NULL; } -; - -RosAcAbstractSyntaxes: - ABSTRACTSYNTAXES_SYM LEFTBRACE_SYM OidList RIGHTBRACE_SYM - { - $$ = $3; - } - | empty { $$ = NULL; } -; - - -OidList: - ObjectIdentifierValue - { - $$ = NEWLIST(); - APPEND ($1,$$); - } - | OidList COMMA_SYM ObjectIdentifierValue - { - APPEND ($3, $1); - $$ = $1; - } -; - - -/* - * MTSAbstractSvc EXTENSIONS macro - */ - -MtsasExtensionsMacroType: - EXTENSIONS_SYM CHOSEN_SYM FROM_SYM - LEFTBRACE_SYM PossiblyEmptyValueList RIGHTBRACE_SYM - { - MtsasExtensionsMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONS, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasExtensions = - MT (MtsasExtensionsMacroType); - m->extensions = $5; - } -; - - -PossiblyEmptyValueList: - ValueList - | empty { $$ = NULL; } -; - -ValueList: - Value - { - $$ = NEWLIST(); - APPEND ($1, $$); - } - | ValueList COMMA_SYM Value - { - APPEND ($3,$1); - $$ = $1; - } -; - -PossiblyEmptyTypeOrValueList: - TypeOrValueList - | empty { $$ = NULL; } -; - -TypeOrValueList: - TypeOrValue - { - $$ = NEWLIST(); - APPEND ($1, $$); - } - | TypeOrValueList COMMA_SYM TypeOrValue - { - APPEND ($3,$1); - $$ = $1; - } -; - -TypeOrValue: - Type - { - $$ = MT (TypeOrValue); - $$->choiceId = TYPEORVALUE_TYPE; - $$->a.type = $1; - } - | Value - { - $$ = MT (TypeOrValue); - $$->choiceId = TYPEORVALUE_VALUE; - $$->a.value = $1; - } -; - -/* - * MTSAbstractSvc EXTENSION macro - */ - -MtsasExtensionMacroType: - EXTENSION_SYM NamedType MtsasExtDefaultVal MtsasExtCritical - { - MtsasExtensionMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASEXTENSION, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasExtension = - MT (MtsasExtensionMacroType); - m->elmtType = $2; - m->defaultValue = $3; - m->criticalForSubmission = mtsasCriticalForSubmissionG; - m->criticalForTransfer = mtsasCriticalForTransferG; - m->criticalForDelivery = mtsasCriticalForDeliveryG; - - mtsasCriticalForSubmissionG = NULL; /* set up for next parse */ - mtsasCriticalForTransferG = NULL; - mtsasCriticalForDeliveryG = NULL; - } - | EXTENSION_SYM - { - SetupMacroType (&$$, MACROTYPE_MTSASEXTENSION, myLineNoG); - $$->basicType->a.macroType->a.mtsasExtension = - MT (MtsasExtensionMacroType); - /* - * all fields are NULL in the MtsasExtensionsMacroType - * for this production - */ - } -; - -MtsasExtDefaultVal: - DEFAULT_SYM Value { $$ = $2; } - | empty { $$ = NULL; } -; - -MtsasExtCritical: - CRITICAL_SYM FOR_SYM MtsasExtCriticalityList - | empty -; - - -MtsasExtCriticalityList: - MtsasExtCriticality - | MtsasExtCriticalityList COMMA_SYM MtsasExtCriticality -; - -MtsasExtCriticality: - SUBMISSION_SYM - { - mtsasCriticalForSubmissionG = MT (AsnBool); - *mtsasCriticalForSubmissionG = TRUE; - } - | TRANSFER_SYM - { - mtsasCriticalForTransferG = MT (AsnBool); - *mtsasCriticalForTransferG = TRUE; - } - | DELIVERY_SYM - { - mtsasCriticalForDeliveryG = MT (AsnBool); - *mtsasCriticalForDeliveryG = TRUE; - } -; - - - -/* - * MTSAbstractSvc X.411 EXTENSION-ATTRIBUTE macro - */ - -MtsasExtensionAttributeMacroType: - EXTENSIONATTRIBUTE_SYM - { - MtsasExtensionAttributeMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONATTRIBUTE, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasExtensionAttribute = - MT (MtsasExtensionAttributeMacroType); - m->type = NULL; - } - | EXTENSIONATTRIBUTE_SYM Type - { - MtsasExtensionAttributeMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONATTRIBUTE, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasExtensionAttribute = - MT (MtsasExtensionAttributeMacroType); - m->type = $2; - } -; - - -/* - * X.411 MTSAbstractSvc TOKEN macro - */ -MtsasTokenMacroType: - TOKEN_SYM - { - MtsasTokenMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASTOKEN, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasToken = MT (MtsasTokenMacroType); - m->type = NULL; - } - | TOKEN_SYM Type - { - MtsasTokenMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASTOKEN, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasToken = MT (MtsasTokenMacroType); - m->type = $2; - } -; - - -/* - * X.411 MTSAS TOKEN-DATA macro type - */ -MtsasTokenDataMacroType: - TOKENDATA_SYM - { - MtsasTokenDataMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASTOKENDATA, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasTokenData = - MT (MtsasTokenDataMacroType); - m->type = NULL; - } - | TOKENDATA_SYM Type - { - MtsasTokenDataMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASTOKENDATA, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasTokenData = - MT (MtsasTokenDataMacroType); - m->type = $2; - } -; - - -/* - * X.411 MTSAS SECURITY-CATEGORY - */ -MtsasSecurityCategoryMacroType: - SECURITYCATEGORY_SYM - { - MtsasSecurityCategoryMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASSECURITYCATEGORY, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasSecurityCategory = - MT (MtsasSecurityCategoryMacroType); - m->type = NULL; - } - | SECURITYCATEGORY_SYM Type - { - MtsasSecurityCategoryMacroType *m; - - SetupMacroType (&$$, MACROTYPE_MTSASSECURITYCATEGORY, myLineNoG); - m = $$->basicType->a.macroType->a.mtsasSecurityCategory = - MT (MtsasSecurityCategoryMacroType); - m->type = $2; - } -; - - -/* - * X.407 Abstract Service Notation Macro Type productions - * MS 91/09/14 - */ - - -/* - * OBJECT Macro X.407 - */ -AsnObjectMacroType: - OBJECT_SYM AsnPorts - { - AsnObjectMacroType *a; - SetupMacroType (&$$, MACROTYPE_ASNOBJECT, myLineNoG); - a = $$->basicType->a.macroType->a.asnObject = MT (AsnObjectMacroType); - a->ports = $2; - } -; - -AsnPorts: - PORTS_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM - { - $$ = $3; - } - | empty { $$ = NULL; } -; - -AsnPortList: - AsnPort - { - $$ = NEWLIST(); - APPEND ($1, $$); - } - | AsnPortList COMMA_SYM AsnPort - { - APPEND ($3, $1); - $$ = $1; - } -; - -AsnPort: - Value AsnPortType - { - $$ = MT (AsnPort); - $$->portValue = $1; - $$->portType = $2; - } -; - -AsnPortType: - BOXC_SYM - { - /* [C] consumer */ - $$ = CONSUMER_PORT; - } - | BOXS_SYM - { - /* [S] supplier */ - $$ = SUPPLIER_PORT; - } - | empty - { - /* symmetric */ - $$ = SYMMETRIC_PORT; - } -; - - - -/* - * PORT Macro X.407 - */ -AsnPortMacroType: - PORT_SYM AsnOperations - { - AsnPortMacroType *a; - - SetupMacroType (&$$, MACROTYPE_ASNPORT, myLineNoG); - a = $$->basicType->a.macroType->a.asnPort = MT (AsnPortMacroType); - a->abstractOps = $2; - a->consumerInvokes = asnConsumerG; - a->supplierInvokes = asnSupplierG; - } - | PORT_SYM - { - SetupMacroType (&$$, MACROTYPE_ASNPORT, myLineNoG); - $$->basicType->a.macroType->a.asnPort = MT (AsnPortMacroType); - } -; - - -AsnOperations: - ABSTRACTOPS_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM - { - $$ = $3; - } - | AsnConsumer - { - $$ = NULL; - asnConsumerG = $1; - asnSupplierG = NULL; - } - | AsnSupplier - { - $$ = NULL; - asnConsumerG = $1; - asnSupplierG = NULL; - } - | AsnConsumer AsnSupplier - { - $$ = NULL; - asnConsumerG = $1; - asnSupplierG = NULL; - } - | AsnSupplier AsnConsumer - { - $$ = NULL; - asnConsumerG = $1; - asnSupplierG = NULL; - } -; - -AsnConsumer: - CONSUMERINVOKES_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM - { - $$ = $3; - } -; - -AsnSupplier: - SUPPLIERINVOKES_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM - { - $$ = $3; - } - -; - - - - -/* - * REFINE Macro X.407 - * - * just parse it - don't keep any info at the moment - */ -AsnRefineMacroType: - REFINE_SYM AsnObject AS_SYM AsnComponentList - { - SetupType (&$$, BASICTYPE_UNKNOWN, myLineNoG); - } -; - -AsnComponentList: - AsnComponent - | AsnComponentList COMMA_SYM AsnComponent -; - -AsnComponent: - AsnObjectSpec AsnPortSpecList -; - -AsnObjectSpec: - AsnObject - | AsnObject RECURRING_SYM -; - -AsnPortSpecList: - AsnPortSpec - | AsnPortSpecList COMMA_SYM AsnPortSpec -; - -AsnPortSpec: - Value AsnPortType AsnPortStatus - { - $$ = 0; /* just to quiet yacc warning */ - } -; - -AsnPortStatus: - VISIBLE_SYM - | PAIRED_SYM WITH_SYM AsnObjectList -; - - -AsnObjectList: - AsnObject - | AsnObjectList COMMA_SYM AsnObject -; - -AsnObject: - Value - { - $$ = 0; /* just to quiet yacc warning */ - } -; - - - - -/* - * ABSTRACT-BIND Macro X.407 - */ -AsnAbstractBindMacroType: - ABSTRACTBIND_SYM AsnAbstractBindPorts - { - AsnAbstractBindMacroType *a; - - SetupMacroType (&$$, MACROTYPE_ASNABSTRACTBIND, myLineNoG); - a = $$->basicType->a.macroType->a.asnAbstractBind = - MT (AsnAbstractBindMacroType); - a->ports = $2; - } - | ABSTRACTBIND_SYM AsnAbstractBindPorts Type - { - AsnAbstractBindMacroType *a; - - SetupMacroType (&$$, MACROTYPE_ASNABSTRACTBIND, myLineNoG); - a = $$->basicType->a.macroType->a.asnAbstractBind = - MT (AsnAbstractBindMacroType); - a->ports = $2; - a->type = $3; - } -; - -AsnAbstractBindPorts: - TO_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM - { - $$ = $3; - } - | empty { $$ = NULL; } -; - - - - -/* - * ABSTRACT-UNBIND Macro X.407 - */ -AsnAbstractUnbindMacroType: - ABSTRACTUNBIND_SYM AsnAbstractUnbindPorts - { - AsnAbstractBindMacroType *a; - - SetupMacroType (&$$, MACROTYPE_ASNABSTRACTUNBIND, myLineNoG); - a = $$->basicType->a.macroType->a.asnAbstractUnbind = - MT (AsnAbstractBindMacroType); - - a->ports = $2; - } - | ABSTRACTUNBIND_SYM AsnAbstractUnbindPorts Type - { - AsnAbstractBindMacroType *a; - - SetupMacroType (&$$, MACROTYPE_ASNABSTRACTUNBIND, myLineNoG); - a = $$->basicType->a.macroType->a.asnAbstractUnbind = - MT (AsnAbstractBindMacroType); - - a->ports = $2; - a->type = $3; - } -; - -AsnAbstractUnbindPorts: - FROM_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM - { - $$ = $3; - } - | empty { $$ = NULL; } -; - - - -/* - * ABSTRACT-OPERATION Macro X.407 (same as ROS Operation) - */ -AsnAbstractOperationMacroType: - ABSTRACTOPERATION_SYM RosOperationMacroBody - { - $$ = $2; - $2->basicType->a.macroType->choiceId = MACROTYPE_ASNABSTRACTOPERATION; - } -; - - -/* - * ABSTRACT-ERROR Macro X.407 (same as ROS Error) - */ -AsnAbstractErrorMacroType: - ABSTRACTERROR_SYM RosErrParameter - { - SetupMacroType (&$$, MACROTYPE_ASNABSTRACTERROR, myLineNoG); - $$->basicType->a.macroType->a.asnAbstractError = MT (RosErrorMacroType); - $$->basicType->a.macroType->a.asnAbstractError->parameter = $2; - } -; - - -/* - * X.509 Authentication Framework ALGORITHM macro type - */ -AfAlgorithmMacroType: - ALGORITHM_SYM PARAMETER_SYM Type - { - SetupMacroType (&$$, MACROTYPE_AFALGORITHM, myLineNoG); - $$->basicType->a.macroType->a.afAlgorithm = $3; - } -; - -/* - * X.509 Authentication Framework ENCRYPTED macro type - */ -AfEncryptedMacroType: - ENCRYPTED_SYM Type - { - SetupMacroType (&$$, MACROTYPE_AFENCRYPTED, myLineNoG); - $$->basicType->a.macroType->a.afEncrypted = $2; - } -; - - -/* - * X.509 Authentication Framework SIGNED macro type - */ -AfSignedMacroType: - SIGNED_SYM Type - { - SetupMacroType (&$$, MACROTYPE_AFSIGNED, myLineNoG); - $$->basicType->a.macroType->a.afSigned = $2; - } -; - -/* - * X.509 Authentication Framework SIGNATURE macro type - */ -AfSignatureMacroType: - SIGNATURE_SYM Type - { - SetupMacroType (&$$, MACROTYPE_AFSIGNATURE, myLineNoG); - $$->basicType->a.macroType->a.afSignature = $2; - } -; - - - -/* - * X.509 Authentication Framework PROTECTED macro type - * (same as SIGNATURE except for key word) - */ -AfProtectedMacroType: - PROTECTED_SYM Type - { - SetupMacroType (&$$, MACROTYPE_AFPROTECTED, myLineNoG); - $$->basicType->a.macroType->a.afProtected = $2; - } -; - - - -SnmpObjectTypeMacroType: - OBJECTTYPE_SYM - SYNTAX_SYM Type - ACCESS_SYM SnmpAccess - STATUS_SYM SnmpStatus - SnmpDescrPart - SnmpReferPart - SnmpIndexPart - SnmpDefValPart - { - SnmpObjectTypeMacroType *s; - - SetupMacroType (&$$, MACROTYPE_SNMPOBJECTTYPE, myLineNoG); - s = $$->basicType->a.macroType->a.snmpObjectType = - MT (SnmpObjectTypeMacroType); - - s->syntax = $3; - s->access = $5; - s->status = $7; - s->description = $8; - s->reference = $9; - s->index = $10; - s->defVal = $11; - } -; - -SnmpAccess: - identifier - { - if (strcmp ($1, "read-only") == 0) - $$ = SNMP_READ_ONLY; - else if (strcmp ($1, "read-write") == 0) - $$ = SNMP_READ_WRITE; - else if (strcmp ($1, "write-only") == 0) - $$ = SNMP_WRITE_ONLY; - else if (strcmp ($1, "not-accessible") == 0) - $$ = SNMP_NOT_ACCESSIBLE; - else - { - yyerror ("ACCESS field of SNMP OBJECT-TYPE MACRO can only be one of \"read-write\", \"write-only\" or \"not-accessible\""); - $$ = -1; - modulePtrG->status = MOD_ERROR; - } - Free ($1); - } -; - - -SnmpStatus: - identifier - { - if (strcmp ($1, "mandatory") == 0) - $$ = SNMP_MANDATORY; - else if (strcmp ($1, "optional") == 0) - $$ = SNMP_OPTIONAL; - else if (strcmp ($1, "obsolete") == 0) - $$ = SNMP_OBSOLETE; - else if (strcmp ($1, "deprecated") == 0) - $$ = SNMP_DEPRECATED; - else - { - yyerror ("STATUS field of SNMP OBJECT-TYPE MACRO can only be one of \"optional\", \"obsolete\" or \"deprecated\""); - $$ = -1; - modulePtrG->status = MOD_ERROR; - } - Free ($1); - } -; - -SnmpDescrPart: - DESCRIPTION_SYM Value { $$ = $2; } - | { $$ = NULL; } -; - -SnmpReferPart: - REFERENCE_SYM Value { $$ = $2; } - | { $$ = NULL; } -; - -SnmpIndexPart: - INDEX_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM - { - $$ = $3; - } - | { $$ = NULL; } -; - -SnmpDefValPart: - DEFVAL_SYM LEFTBRACE_SYM Value RIGHTBRACE_SYM - { - $$ = $3; - } - | { $$ = NULL; } -; - -%% - -yyerror (s) -char*s; -{ - fprintf (stderr,"file \"%s\", line %d: %s at symbol \"%s\"\n\n", modulePtrG->asn1SrcFileName, myLineNoG, s, yytext); -} - - -/* - * given a Module*, the file name associated witht the open - * FILE *fPtr, InitAsn1Parser sets up the yacc/lex parser - * to parse an ASN.1 module read from fPtr and write the - * parse results into the given Module *mod. - */ -int -InitAsn1Parser PARAMS ((mod, fileName, fPtr), - Module *mod _AND_ - char *fileName _AND_ - FILE *fPtr) -{ - yyin = fPtr; - - /* - * reset lexical analyzer input file ptr - * (only do this on succesive calls ow yyrestart seg faults - */ -#ifdef FLEX_IN_USE - if (!firstTimeThroughG) - yyrestart (fPtr); - - firstTimeThroughG = FALSE; -#endif - - - /* - * init modulePtr - */ - memzero (mod, sizeof (Module)); - modulePtrG = mod; - mod->asn1SrcFileName = fileName; - mod->status = MOD_NOT_LINKED; - mod->hasAnys = FALSE; - - /* init lists to empty */ - mod->typeDefs = AsnListNew (sizeof (void*)); - mod->valueDefs = AsnListNew (sizeof (void*)); - - /* - * init export list stuff - */ - exportListG = NULL; - exportsParsedG = FALSE; - - /* - * reset line number to 1 - */ - myLineNoG = 1; - - /* - * reset error count - */ - parseErrCountG = 0; - - /* - * set up list to hold values defined in parsed oids - */ - oidElmtValDefsG = AsnListNew (sizeof (void *)); - - smallErrG = 0; - - return 0; - -} /* InitAsn1Parser */ - - -/* - * puts the applicatin tag code, tagCode, and line number it was - * parsed at into the applTagsG list. If the APPLICATION tag code - * is already in the applTagsG list then an error is printed. - * and the smallErrG flag set to prevent code production. - */ -void -PushApplTag PARAMS ((tagCode, lineNo), - unsigned long int tagCode _AND_ - unsigned long int lineNo) -{ - ApplTag *l; - ApplTag *new; - int wasDefined = 0; - - /* make sure not already in list */ - for (l = applTagsG; l != NULL; l = l->next) - { - if (l->tagCode == tagCode) - { - PrintErrLoc (modulePtrG->asn1SrcFileName, lineNo); - fprintf (stderr,"ERROR - APPLICATION tags can be used only once per ASN.1 module. The tag \"[APPLICATION %d]\" was previously used on line %d.\n", tagCode, l->lineNo); - wasDefined = 1; - smallErrG = 1; - } - } - if (!wasDefined) - { - new = MT (ApplTag); - new->lineNo = lineNo; - new->tagCode = tagCode; - new->next = applTagsG; - applTagsG = new; - } -} /* PushApplTag */ - - -/* - * Empties the applTagsG list. Usually done between modules. - */ -void -FreeApplTags() -{ - ApplTag *l; - ApplTag *lTmp; - - for (l = applTagsG; l != NULL; ) - { - lTmp = l->next; - Free (l); - l = lTmp; - } - applTagsG = NULL; -} /* FreeApplTags */ diff --git a/SecuritySNACCRuntime/compiler/core/parser.h b/SecuritySNACCRuntime/compiler/core/parser.h deleted file mode 100644 index efcdb58b..00000000 --- a/SecuritySNACCRuntime/compiler/core/parser.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * compiler/core/parser.h - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/parser.h,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: parser.h,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/24 13:33:19 rj - * typo fixed: Pasrser -> Parser - * - * Revision 1.2 1994/10/08 03:48:52 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:31 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -extern int smallErrG; /* can continue processing but don't produce code - see more errs */ -extern int yydebug; /* set to 1 to enable debugging */ - -int InitAsn1Parser PROTO ((Module *mod, char *fileName, FILE *fPtr)); - -int yyparse(); diff --git a/SecuritySNACCRuntime/compiler/core/print.c b/SecuritySNACCRuntime/compiler/core/print.c deleted file mode 100644 index 53405281..00000000 --- a/SecuritySNACCRuntime/compiler/core/print.c +++ /dev/null @@ -1,2767 +0,0 @@ -/* - * compiler/core/print.c - * - * These routines are for printing the information from a Module - * Data strucuture in ASN.1 form. - * - * Useful for debugging the parser and seeing changes caused by - * normalization and sorting. - * - * Mike Sample - * Feb 28/91 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/print.c,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: print.c,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1 2000/05/10 21:37:46 rmurphy - * Adding back in code which had been renamed to file2.c - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.6 1997/02/28 13:39:55 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.5 1995/08/17 14:58:57 rj - * minor typographic change - * - * Revision 1.4 1995/07/25 19:41:42 rj - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:48:53 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:42:16 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:32 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "lib-types.h" -#include "print.h" - - -static int indentCountG; -static int indentG = 0; -static int indentStepG = 4; - -#define INDENT(f, i)\ - for (indentCountG = 0; indentCountG < (i); indentCountG++)\ - fputc (' ', (f))\ - -/* - * Prints the given Module *, mod, to the given FILE *f in - * ASN.1 format - */ -void -PrintModule PARAMS ((f, mod), - FILE *f _AND_ - Module *mod) -{ - - if (mod->status == MOD_ERROR) - { - fprintf (f, "WARNING: this module contains errors\n"); - fprintf (f,"(probably some type/value is referenced but is not defined or imported)\n"); - fprintf (f,"The prog. may croak, cross your fingers!\n"); - } - - - fprintf (f, "%s ",mod->modId->name); - PrintOid (f, mod->modId->oid); - - fprintf (f, "\nDEFINITIONS "); - - if (mod->tagDefault == EXPLICIT_TAGS) - fprintf (f, "EXPLICIT TAGS"); - - else if (mod->tagDefault == IMPLICIT_TAGS) - fprintf (f, "IMPLICIT TAGS"); - else - fprintf (f, "\n\n -- compiler error unknown tag default"); - - - fprintf (f, " ::=\nBEGIN\n\n"); - - - - PrintExports (f, mod); - - PrintImportLists (f, mod->imports); - - PrintTypeDefs (f, mod->typeDefs); - PrintValueDefs (f, mod->valueDefs); - - fprintf (f, "END\n"); - -} /* PrintModule */ - - -void -PrintExports PARAMS ((f, m), - FILE *f _AND_ - Module *m) -{ - TypeDef *td; - ValueDef *vd; - int first; - - if (m->exportStatus == EXPORTS_ALL) - { - fprintf (f, "\n\n-- exports everything\n\n"); - } - else if (m->exportStatus == EXPORTS_NOTHING) - { - fprintf (f, "\n\nEXPORTS -- exports nothing\n\n"); - } - else - { - fprintf (f, "\n\nEXPORTS\n"); - first = 1; - FOR_EACH_LIST_ELMT (td, m->typeDefs) - if (td->exported) - { - if (!first) - fprintf (f,", "); - fprintf (f, "%s", td->definedName); - first = 0; - } - - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - if (vd->exported) - { - if (!first) - fprintf (f,", "); - fprintf (f, "%s", vd->definedName); - first = 0; - } - - fprintf (f, "\n;\n\n"); - } -} /* PrintExports */ - - - -void -PrintOid PARAMS ((f, oid), - FILE *f _AND_ - OID *oid) -{ - int i; - - if (oid == NULL) - return; - - fprintf (f, "{ "); - for (; oid != NULL; oid = oid->next) - { - /* - * value ref to an integer or if first elmt in - * oid can ref other oid value - * { id-asdc } - */ - if (oid->valueRef != NULL) - PrintValue (f, NULL, NULL, oid->valueRef); - - /* - * just "arcNum" format - * { 2 } - */ - else if (oid->arcNum != NULL_OID_ARCNUM) - fprintf (f, "%d", oid->arcNum); - - - fprintf (f, " "); - } - fprintf (f, "}"); - -} /* PrintOid */ - - - -void -PrintImportElmt PARAMS ((f, impElmt), - FILE *f _AND_ - ImportElmt *impElmt) -{ - fprintf (f, "%s",impElmt->name); -} /* PrintImportElmt */ - - -void -PrintImportElmts PARAMS ((f, impElmtList), - FILE *f _AND_ - ImportElmtList *impElmtList) -{ - ImportElmt *ie; - ImportElmt *last; - - if ((impElmtList == NULL) || (LIST_EMPTY (impElmtList))) - return; - - last = (ImportElmt*)LAST_LIST_ELMT (impElmtList); - FOR_EACH_LIST_ELMT (ie, impElmtList) - { - PrintImportElmt (f, ie); - - if (ie != last) - fprintf (f, ", "); - } - -} /* PrintImportElmts */ - - - -void -PrintImportLists PARAMS ((f, impLists), - FILE *f _AND_ - ImportModuleList *impLists) -{ - ImportModule *impMod; - - if (impLists == NULL) - { - fprintf (f,"\n\n-- imports nothing\n\n"); - return; - } - - fprintf (f, "IMPORTS\n\n"); - FOR_EACH_LIST_ELMT (impMod, impLists) - { - PrintImportElmts (f, impMod->importElmts); - - fprintf (f, "\n FROM %s ", impMod->modId->name); - - PrintOid (f, impMod->modId->oid); - - fprintf (f, "\n\n\n"); - } - fprintf (f, ";\n\n\n"); - -} /* PrintImportLists */ - - - -void -PrintTypeDefs PARAMS ((f, typeDefs), - FILE *f _AND_ - TypeDefList *typeDefs) -{ - TypeDef *td; - - FOR_EACH_LIST_ELMT (td, typeDefs) - { - if (td->type->basicType->choiceId == BASICTYPE_MACRODEF) - PrintMacroDef (f, td); - else - { - fprintf (f,"-- %s notes: ", td->definedName); - - if (td->recursive) - fprintf (f,"recursive, "); - else - fprintf (f,"not recursive, "); - - if (td->exported) - fprintf (f,"exported,\n"); - else - fprintf (f,"not exported,\n"); - - fprintf (f,"-- locally refd %d times, ", td->localRefCount); - fprintf (f,"import refd %d times\n", td->importRefCount); - - - fprintf (f, "%s ::= ", td->definedName); - PrintType (f, td, td->type); - } - fprintf (f, "\n\n\n"); - } -} /* PrintTypeDefs */ - - - - -void -PrintType PARAMS ((f, head, t), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t) -{ - Tag *tag; - Tag *lastTag; - - if (t == NULL) - return; - - lastTag = NULL; - FOR_EACH_LIST_ELMT (tag, t->tags) - { - - - - if (! ((tag->tclass == UNIV) && - (tag->code == LIBTYPE_GET_UNIV_TAG_CODE (t->basicType->choiceId)))) - { - PrintTag (f, tag); - fprintf (f, " "); - } - lastTag = tag; - } - - /* - * check type has been implicitly tagged - */ - if (t->implicit) - fprintf (f, "IMPLICIT "); - - PrintBasicType (f, head, t, t->basicType); - - - /* - * sequences of and set of print subtypes a special way - * so ignore them here - */ - if ((t->subtypes != NULL) && - (t->basicType->choiceId != BASICTYPE_SETOF) && - (t->basicType->choiceId != BASICTYPE_SEQUENCEOF)) - { - fprintf (f," "); - PrintSubtype (f, head, t, t->subtypes); - } - - - if (t->defaultVal != NULL) - { - fprintf (f, " DEFAULT "); - if (t->defaultVal->fieldName != NULL) - fprintf (f, "%s ", t->defaultVal->fieldName); - PrintValue (f, NULL, t, t->defaultVal->value); - } - - else if (t->optional) - fprintf (f, " OPTIONAL"); - - -#ifdef DEBUG - fprintf (f, " -- lineNo = %d --", t->lineNo); -#endif - -} /* PrintType */ - - -void -PrintBasicType PARAMS ((f, head, t, bt), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt) -{ - switch (bt->choiceId) - { - - case BASICTYPE_SEQUENCE: - fprintf (f, "SEQUENCE\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtTypes (f, head, t, bt->a.sequence); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - break; - - case BASICTYPE_SET: - fprintf (f, "SET\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtTypes (f, head, t, bt->a.set); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - break; - - case BASICTYPE_CHOICE: - fprintf (f, "CHOICE\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtTypes (f, head, t, bt->a.choice); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - break; - - - - case BASICTYPE_SEQUENCEOF: - fprintf (f, "SEQUENCE "); - if (t->subtypes != NULL) - { - PrintSubtype (f, head, t, t->subtypes); - fprintf (f," "); - } - fprintf (f, "OF "); - PrintType (f, head, bt->a.sequenceOf); - break; - - case BASICTYPE_SETOF: - fprintf (f, "SET "); - if (t->subtypes != NULL) - { - PrintSubtype (f, head, t, t->subtypes); - fprintf (f," "); - } - fprintf (f, "OF "); - PrintType (f, head, bt->a.setOf); - break; - - - case BASICTYPE_SELECTION: - fprintf (f, "%s < ", bt->a.selection->fieldName); - PrintType (f, head, bt->a.selection->typeRef); - break; - - - - - case BASICTYPE_COMPONENTSOF: - fprintf (f, "COMPONENTS OF "); - PrintType (f, NULL, bt->a.componentsOf); - break; - - - - case BASICTYPE_ANYDEFINEDBY: - fprintf (f, "ANY DEFINED BY %s", bt->a.anyDefinedBy->fieldName); - break; - - - case BASICTYPE_LOCALTYPEREF: - fprintf (f, "%s", bt->a.localTypeRef->typeName); - break; - - case BASICTYPE_IMPORTTYPEREF: - /* attempt to keep special scoping, ie modname.type forms */ - if (bt->a.importTypeRef->moduleName != NULL) - fprintf (f,"%s.", bt->a.importTypeRef->moduleName); - fprintf (f, "%s", bt->a.importTypeRef->typeName); - break; - - - case BASICTYPE_UNKNOWN: - fprintf (f, "unknown type !?!"); - break; - - case BASICTYPE_BOOLEAN: - fprintf (f, "BOOLEAN"); - break; - - - case BASICTYPE_INTEGER: - fprintf (f, "INTEGER"); - if ((bt->a.integer != NULL) && !LIST_EMPTY (bt->a.integer)) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - PrintNamedElmts (f, head, t, bt->a.integer); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - } - break; - - - case BASICTYPE_BITSTRING: - fprintf (f, "BIT STRING"); - if ((bt->a.bitString != NULL) && !LIST_EMPTY (bt->a.bitString)) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - PrintNamedElmts (f, head, t, bt->a.bitString); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - } - break; - - case BASICTYPE_OCTETSTRING: - fprintf (f, "OCTET STRING"); - break; - - case BASICTYPE_NULL: - fprintf (f, "NULL"); - break; - - case BASICTYPE_OID: - fprintf (f, "OBJECT IDENTIFIER"); - break; - - case BASICTYPE_REAL: - fprintf (f, "REAL"); - break; - - case BASICTYPE_ENUMERATED: - fprintf (f, "ENUMERATED"); - if ((bt->a.enumerated != NULL) && !LIST_EMPTY (bt->a.enumerated)) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - PrintNamedElmts (f, head, t, bt->a.enumerated); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - } - break; - - case BASICTYPE_ANY: - fprintf (f, "ANY"); - break; - - case BASICTYPE_MACROTYPE: - switch (bt->a.macroType->choiceId) - { - case MACROTYPE_ROSOPERATION: - case MACROTYPE_ASNABSTRACTOPERATION: - PrintRosOperationMacroType (f, head, t, bt, bt->a.macroType->a.rosOperation); - break; - - case MACROTYPE_ROSERROR: - case MACROTYPE_ASNABSTRACTERROR: - PrintRosErrorMacroType (f, head, t, bt, bt->a.macroType->a.rosError); - break; - - case MACROTYPE_ROSBIND: - case MACROTYPE_ROSUNBIND: - PrintRosBindMacroType (f, head, t, bt, bt->a.macroType->a.rosBind); - break; - - case MACROTYPE_ROSASE: - PrintRosAseMacroType (f, head, t, bt, bt->a.macroType->a.rosAse); - break; - - case MACROTYPE_MTSASEXTENSIONS: - PrintMtsasExtensionsMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensions); - break; - - case MACROTYPE_MTSASEXTENSION: - PrintMtsasExtensionMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtension); - break; - - case MACROTYPE_MTSASEXTENSIONATTRIBUTE: - PrintMtsasExtensionAttributeMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensionAttribute); - break; - - case MACROTYPE_MTSASTOKEN: - PrintMtsasTokenMacroType (f, head, t, bt, bt->a.macroType->a.mtsasToken); - break; - - case MACROTYPE_MTSASTOKENDATA: - PrintMtsasTokenDataMacroType (f, head, t, bt, bt->a.macroType->a.mtsasTokenData); - break; - - case MACROTYPE_MTSASSECURITYCATEGORY: - PrintMtsasSecurityCategoryMacroType (f, head, t, bt, bt->a.macroType->a.mtsasSecurityCategory); - break; - - case MACROTYPE_ASNOBJECT: - PrintAsnObjectMacroType (f, head, t, bt, bt->a.macroType->a.asnObject); - break; - - case MACROTYPE_ASNPORT: - PrintAsnPortMacroType (f, head, t, bt, bt->a.macroType->a.asnPort); - break; - - case MACROTYPE_ASNABSTRACTBIND: - case MACROTYPE_ASNABSTRACTUNBIND: - PrintAsnAbstractBindMacroType (f, head, t, bt, bt->a.macroType->a.asnAbstractBind); - break; - - case MACROTYPE_AFALGORITHM: - PrintAfAlgorithmMacroType (f, head, t, bt, bt->a.macroType->a.afAlgorithm); - break; - - case MACROTYPE_AFENCRYPTED: - PrintAfEncryptedMacroType (f, head, t, bt, bt->a.macroType->a.afEncrypted); - break; - - case MACROTYPE_AFSIGNED: - PrintAfSignedMacroType (f, head, t, bt, bt->a.macroType->a.afSigned); - break; - - case MACROTYPE_AFSIGNATURE: - PrintAfSignatureMacroType (f, head, t, bt, bt->a.macroType->a.afSignature); - break; - - case MACROTYPE_AFPROTECTED: - PrintAfProtectedMacroType (f, head, t, bt, bt->a.macroType->a.afProtected); - break; - - case MACROTYPE_SNMPOBJECTTYPE: - PrintSnmpObjectTypeMacroType (f, head, t, bt, bt->a.macroType->a.snmpObjectType); - break; - - default: - fprintf (f, "< unknown macro type id ?! >"); - - } /* end macro type switch */ - break; - - /* - * @MACRO@ add new macro printers above this point - */ - - case BASICTYPE_MACRODEF: - /* - * printing this should be handled in PrintTypeDefs - */ - break; - - - default: - fprintf (f, "< unknown type id ?! >"); - - } -} /* PrintBasicType */ - - - -void -PrintElmtType PARAMS ((f, head, t, nt), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - NamedType *nt) -{ - if (nt->fieldName != NULL) - fprintf (f, "%s ", nt->fieldName); - - PrintType (f, head, nt->type); - -} /* PrintElmtType */ - -void -PrintElmtTypes PARAMS ((f, head, t, e), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - NamedTypeList *e) -{ - NamedType *nt; - NamedType *last; - - if ((e == NULL) || LIST_EMPTY (e)) - return; - - last = (NamedType*)LAST_LIST_ELMT (e); - FOR_EACH_LIST_ELMT (nt, e) - { - - PrintElmtType (f, head, t, nt); - if (nt != last) - { - fprintf (f, ",\n"); - INDENT (f, indentG); - } - } -} /* PrintElmtTypes */ - - - - -void -PrintValueDefs PARAMS ((f, vList), - FILE *f _AND_ - ValueDefList *vList) -{ - ValueDef *v; - FOR_EACH_LIST_ELMT (v, vList) - { - PrintValueDef (f, v); - } -} /* PrintValueDefs */ - - -void -PrintValueDef PARAMS ((f, v), - FILE *f _AND_ - ValueDef *v) -{ - fprintf (f, "%s ", v->definedName); - - if (v->value->type != NULL) - PrintType (f, NULL, v->value->type); - else - /* just go by valueType */ - PrintTypeById (f, v->value->valueType); - - fprintf (f, " ::= "); - indentG += indentStepG; - PrintValue (f, v, v->value->type, v->value); - fprintf (f, "\n\n"); - indentG -= indentStepG; -} /* PrintValueDef */ - - -void -PrintValue PARAMS ((f, head, valuesType, v), - FILE *f _AND_ - ValueDef *head _AND_ - Type *valuesType _AND_ - Value *v) -{ - if (v == NULL) - return; - - PrintBasicValue (f, head, valuesType, v, v->basicValue); - -} /* PrintValue */ - - -void -PrintBasicValue PARAMS ((f, head, valuesType, v, bv), - FILE *f _AND_ - ValueDef *head _AND_ - Type *valuesType _AND_ - Value *v _AND_ - BasicValue *bv) -{ - if (v == NULL) - return; - - - switch (bv->choiceId) - { - case BASICVALUE_UNKNOWN: - fprintf (f, ""); - break; - - case BASICVALUE_EMPTY: - fprintf (f,"{ }"); - break; - - case BASICVALUE_INTEGER: - fprintf (f, "%d", bv->a.integer); - break; - - case BASICVALUE_SPECIALINTEGER: - if (bv->a.specialInteger == MAX_INT) - fprintf (f, "MAX"); - else - fprintf (f, "MIN"); - - break; - - case BASICVALUE_BOOLEAN: - if (bv->a.boolean) - fprintf (f,"TRUE"); - else - fprintf (f,"FALSE"); - break; - - case BASICVALUE_REAL: - fprintf (f, "%f", bv->a.real); - break; - - case BASICVALUE_SPECIALREAL: - if (bv->a.specialReal == PLUS_INFINITY_REAL) - fprintf (f, "PLUS INFINITY"); - else - fprintf (f, "MINUS INFINITY"); - - break; - - case BASICVALUE_ASCIITEXT: - fprintf (f, "\"%s\"", bv->a.asciiText->octs); - break; - - case BASICVALUE_ASCIIHEX: - fprintf (f, "\"%s\"", bv->a.asciiHex->octs); - break; - - case BASICVALUE_ASCIIBITSTRING: - fprintf (f, "\"%s\"", bv->a.asciiBitString->octs); - break; - - case BASICVALUE_OID: - PrintEncodedOid (f, bv->a.oid); - break; - - case BASICVALUE_LINKEDOID: - PrintOid (f, bv->a.linkedOid); - break; - - case BASICVALUE_BERVALUE: - fprintf (f,"a.namedValue); - indentG -= indentStepG; - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"}"); - break; - - case BASICVALUE_NULL: - fprintf (f,"NULL"); - break; - - case BASICVALUE_LOCALVALUEREF: - fprintf (f, "%s", bv->a.localValueRef->valueName); - break; - - case BASICVALUE_IMPORTVALUEREF: - fprintf (f, "%s", bv->a.importValueRef->valueName); - break; - - case BASICVALUE_VALUENOTATION: - fprintf (f, "-- snacc warning: can't parse this value yet --"); - fprintf (f, "%s", bv->a.valueNotation->octs); - break; - - - default: - fprintf (stderr,"PrintBasicValue: ERROR - unknown value type\n"); - } - -} /* PrintBasicValue */ - - -void -PrintElmtValue PARAMS ((f, head, v, nv), - FILE *f _AND_ - ValueDef *head _AND_ - Value *v _AND_ - NamedValue *nv) -{ - if (nv->fieldName != NULL) - fprintf (f, "%s ", nv->fieldName); - - PrintValue (f, NULL, NULL, nv->value); -} /* PrintElmtValue */ - - -void -PrintElmtValues PARAMS ((f, head, v, e), - FILE *f _AND_ - ValueDef *head _AND_ - Value *v _AND_ - NamedValueList *e) -{ - NamedValue *nv; - NamedValue *last; - - if ((e == NULL) || LIST_EMPTY (e)) - return; - - last = (NamedValue*)LAST_LIST_ELMT (e); - FOR_EACH_LIST_ELMT (nv, e) - { - PrintElmtValue (f, head, v, nv); - if (nv != last) - { - fprintf (f, ",\n"); - INDENT (f, indentG); - } - } -} /* PrintElmtValues */ - - -void -PrintTypeById PARAMS ((f, typeId), - FILE *f _AND_ - int typeId) -{ - switch (typeId) - { - case BASICTYPE_UNKNOWN: - fprintf (f, "UNKNOWN"); - break; - - case BASICTYPE_BOOLEAN: - fprintf (f, "BOOLEAN"); - break; - - case BASICTYPE_INTEGER: - fprintf (f, "INTEGER"); - break; - - case BASICTYPE_BITSTRING: - fprintf (f, "BIT STRING"); - break; - - case BASICTYPE_OCTETSTRING: - fprintf (f, "OCTET STRING"); - break; - - - case BASICTYPE_NULL: - fprintf (f, "NULL"); - break; - - case BASICTYPE_SEQUENCE: - fprintf (f, "SEQUENCE"); - break; - - case BASICTYPE_SEQUENCEOF: - fprintf (f, "SEQUENCE OF"); - break; - - case BASICTYPE_SET: - fprintf (f, "SET"); - break; - - case BASICTYPE_SETOF: - fprintf (f, "SET OF"); - break; - - case BASICTYPE_CHOICE: - fprintf (f, "CHOICE"); - break; - - case BASICTYPE_SELECTION: - fprintf (f, "SELECTION"); - break; - - case BASICTYPE_ANY: - fprintf (f, "ANY"); - break; - - case BASICTYPE_ANYDEFINEDBY: - fprintf (f, "ANY DEFINED BY"); - break; - - case BASICTYPE_OID: - fprintf (f, "OBJECT IDENTIFIER"); - break; - - case BASICTYPE_ENUMERATED: - fprintf (f, "ENUMERATED"); - break; - - case BASICTYPE_REAL: - fprintf (f, "REAL"); - break; - - case BASICTYPE_COMPONENTSOF: - fprintf (f, "COMPONENTS OF"); - break; - - default: - fprintf (f, "ERROR - %d is an unknown type id\n", typeId); - } -} /* PrintTypeById */ - - -void -PrintTag PARAMS ((f, tag), - FILE *f _AND_ - Tag *tag) -{ - char *name=NULL; - - if (tag->tclass == UNIV) - { - switch (tag->code) - { - case BOOLEAN_TAG_CODE: name = "BOOLEAN"; - break; - case INTEGER_TAG_CODE: name = "INTEGER"; - break; - case BITSTRING_TAG_CODE: name = "BITSTRING"; - break; - case OCTETSTRING_TAG_CODE: name = "OCTETSTRING"; - break; - case NULLTYPE_TAG_CODE: name = "NULL TYPE"; - break; - case OID_TAG_CODE: name = "OBJECT ID"; - break; - case OD_TAG_CODE: name = "OBEJECT DESCRIPTOR"; - break; - case EXTERNAL_TAG_CODE: name = "EXTERNAL"; - break; - case REAL_TAG_CODE: name = "REAL"; - break; - case ENUM_TAG_CODE: name = "ENUMERATED"; - break; - case SEQ_TAG_CODE: name = "SEQUENCE"; - break; - case SET_TAG_CODE: name = "SET"; - break; - case NUMERICSTRING_TAG_CODE: name = "NUMERIC STRING"; - break; - case PRINTABLESTRING_TAG_CODE: name = "PRINTABLE STRING"; - break; - case TELETEXSTRING_TAG_CODE: name = "TELETEX STRING"; - break; - case VIDEOTEXSTRING_TAG_CODE: name = "VIDEOTEX STRING"; - break; - case IA5STRING_TAG_CODE: name = "IA5 STRING"; - break; - case UTCTIME_TAG_CODE: name = "UTC TIME"; - break; - case GENERALIZEDTIME_TAG_CODE: name = "GENERALIZED TIME"; - break; - case GRAPHICSTRING_TAG_CODE: name = "GRAPHIC STRING"; - break; - case VISIBLESTRING_TAG_CODE: name = "VISIBLE STRING"; - break; - case GENERALSTRING_TAG_CODE: name = "GENERAL STRING"; - break; - - default: name = "UNKNOWN UNIVERSAL TYPE"; - } - fprintf (f, "[UNIVERSAL %d]", tag->code); - } - else if (tag->tclass == APPL) - { - fprintf (f, "[APPLICATION %d]", tag->code); - } - else if (tag->tclass == PRIV) - { - fprintf (f, "[PRIVATE %d]", tag->code); - } - else if (tag->tclass == CNTX) - { - fprintf (f, "[%d]", tag->code); - } - - if (tag->explicit) - fprintf (f, " EXPLICIT"); - -} /* PrintTag */ - - -void -PrintSubtype PARAMS ((f, head, t, s), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - Subtype *s) -{ - Subtype *tmpS; - Subtype *last; - - if (s == NULL) - return; - -/* fprintf (f, "("); */ - - switch (s->choiceId) - { - case SUBTYPE_SINGLE: - PrintSubtypeValue (f, head, t, s->a.single); - break; - - case SUBTYPE_AND: - FOR_EACH_LIST_ELMT (tmpS, s->a.and) - { - fprintf (f, "("); - PrintSubtype (f, head, t, tmpS); - fprintf (f, ")"); - } - break; - - - case SUBTYPE_OR: - if ((s->a.or != NULL) && !LIST_EMPTY (s->a.or)) - last = (Subtype*)LAST_LIST_ELMT (s->a.or); - FOR_EACH_LIST_ELMT (tmpS, s->a.or) - { - fprintf (f, "("); - PrintSubtype (f, head, t, tmpS); - fprintf (f, ")"); - if (tmpS != last) - fprintf (f, " | "); - } - break; - - case SUBTYPE_NOT: - fprintf (f, "NOT ("); - PrintSubtype (f, head, t, s->a.not); - fprintf (f, ")"); - break; - - default: - fprintf (stderr, "PrintSubtype: ERROR - unknown Subtypes choiceId\n"); - break; - } - -/* fprintf (f, ")"); */ - - -} /* PrintSubtype */ - - - -void -PrintSubtypeValue PARAMS ((f, head, t, s), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - SubtypeValue *s) -{ - if (s == NULL) - return; - - switch (s->choiceId) - { - case SUBTYPEVALUE_SINGLEVALUE: - PrintValue (f, NULL, NULL, s->a.singleValue); - break; - - case SUBTYPEVALUE_CONTAINED: - fprintf (f, "a.valueRange->lowerEndValue); - if (!s->a.valueRange->lowerEndInclusive) - fprintf (f, " >"); - fprintf (f,".."); - if (!s->a.valueRange->upperEndInclusive) - fprintf (f, "< "); - PrintValue (f, NULL, NULL, s->a.valueRange->upperEndValue); - break; - - - case SUBTYPEVALUE_PERMITTEDALPHABET: - fprintf (f,"FROM "); - PrintSubtype (f, head, t, s->a.permittedAlphabet); - break; - - case SUBTYPEVALUE_SIZECONSTRAINT: - fprintf (f,"SIZE "); - PrintSubtype (f, head, t, s->a.sizeConstraint); - break; - - case SUBTYPEVALUE_INNERSUBTYPE: - PrintInnerSubtype (f, head, t, s->a.innerSubtype); - break; - - default: - fprintf (stderr, "PrintSubtype: ERROR - unknown Subtype choiceId\n"); - break; - } -} /* PrintSubtype */ - - -void -PrintInnerSubtype PARAMS ((f, head, t, i), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - InnerSubtype *i) -{ - Constraint *constraint; - if (i->constraintType == SINGLE_CT) - { - fprintf (f,"WITH COMPONENT "); - constraint = *(Constraint**)AsnListFirst (i->constraints); - PrintSubtype (f, head, t, constraint->valueConstraints); - } - else - { - fprintf (f, "WITH COMPONENTS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - if (i->constraintType == PARTIAL_CT) - { - INDENT (f, indentG); - fprintf (f, "...,\n"); - } - PrintMultipleTypeConstraints (f, head, t, i->constraints); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - - } -} /* PrintInnerSubtype */ - - - -void -PrintMultipleTypeConstraints PARAMS ((f, head, t, cList), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - ConstraintList *cList) -{ - Constraint *c; - Constraint *last; - - if ((cList == NULL) || LIST_EMPTY (cList)) - return; - - last = (Constraint*)LAST_LIST_ELMT (cList); - FOR_EACH_LIST_ELMT (c, cList) - { - if (c->fieldRef != NULL) - { - INDENT (f, indentG); - fprintf (f, "%s ", c->fieldRef); - } - - - PrintSubtype (f, head, t, c->valueConstraints); - - if (c->presenceConstraint == ABSENT_CT) - fprintf (f, " ABSENT"); - if (c->presenceConstraint == PRESENT_CT) - fprintf (f, " PRESENT"); - if (c->presenceConstraint == OPTIONAL_CT) - fprintf (f, " OPTIONAL"); - - if (c != last) - fprintf (f, ",\n"); - - } -} /* PrintMultipleTypeConstraints */ - - - -void -PrintNamedElmts PARAMS ((f, head, t, n), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - ValueDefList *n) -{ - ValueDef *vd; - ValueDef *last; - - if ((n == NULL) || LIST_EMPTY (n)) - return; - - last = (ValueDef*)LAST_LIST_ELMT (n); - FOR_EACH_LIST_ELMT (vd, n) - { - INDENT (f, indentG); - fprintf (f, "%s (", vd->definedName); - PrintValue (f, NULL, NULL, vd->value); - fprintf (f,")"); - if (vd != last) - fprintf (f,",\n"); - } -} /* PrintNamedElmts */ - - - - -void -PrintRosOperationMacroType PARAMS ((f, head, t, bt, op), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosOperationMacroType *op) -{ - TypeOrValue *tOrV; - TypeOrValue *last; - - if (bt->a.macroType->choiceId == MACROTYPE_ROSOPERATION) - fprintf (f, "OPERATION"); - else - fprintf (f, "ABSTRACT-OPERATION"); - - indentG += indentStepG; - if (op->arguments != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "ARGUMENT\n"); - indentG += indentStepG; - - INDENT (f, indentG); - - if (op->arguments->fieldName != NULL) - fprintf (f, "%s ", op->arguments->fieldName); - - PrintType (f, head, op->arguments->type); - indentG -= indentStepG; - } - - if (op->result != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "RESULT\n"); - indentG += indentStepG; - - INDENT (f, indentG); - - if (op->arguments->fieldName != NULL) - fprintf (f, "%s ", op->arguments->fieldName); - - PrintType (f, head, op->result->type); - indentG -= indentStepG; - } - - if ((op->errors == NULL) || (!LIST_EMPTY (op->errors))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "ERRORS\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (op->errors); - FOR_EACH_LIST_ELMT (tOrV, op->errors) - { - INDENT (f, indentG); - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - - } - indentG -= indentStepG; - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((op->linkedOps != NULL) && (!LIST_EMPTY (op->linkedOps))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "LINKED\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (op->linkedOps); - FOR_EACH_LIST_ELMT (tOrV, op->linkedOps) - { - INDENT (f, indentG); - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - indentG -= indentStepG; - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, " }"); - } - - indentG -= indentStepG; - -} /* PrintRosOperationMacroType */ - - - -void -PrintRosErrorMacroType PARAMS ((f, head, t, bt, err), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosErrorMacroType *err) -{ - if (bt->a.macroType->choiceId == MACROTYPE_ROSERROR) - fprintf (f,"ERROR\n"); - else - fprintf (f,"ABSTRACT-ERROR\n"); - - indentG += indentStepG; - - if (err->parameter != NULL) - { - INDENT (f, indentG); - fprintf (f,"PARAMETER "); - indentG += indentStepG; - PrintElmtType (f, head, t, err->parameter); - indentG -= indentStepG; - } - indentG -= indentStepG; - -} /* PrintRosErrorMacroType */ - - -void -PrintRosBindMacroType PARAMS ((f, head, t, bt, bind), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosBindMacroType *bind) -{ - if (bt->a.macroType->choiceId == MACROTYPE_ROSBIND) - fprintf (f,"BIND"); - else - fprintf (f,"UNBIND"); - - indentG += indentStepG; - - if (bind->argument != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"ARGUMENT\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtType (f, head, t, bind->argument); - indentG -= indentStepG; - } - - if (bind->result != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"RESULT\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtType (f, head, t, bind->result); - indentG -= indentStepG; - } - - if (bind->error != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - if (bt->a.macroType->choiceId == MACROTYPE_ROSBIND) - fprintf (f,"BIND-ERROR\n"); - else - fprintf (f,"UNBIND-ERROR\n"); - - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtType (f, head, t, bind->error); - indentG -= indentStepG; - } - - indentG -= indentStepG; - -} /* PrintRosBindMacroType */ - - -void -PrintRosAseMacroType PARAMS ((f, head, t, bt, ase), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAseMacroType *ase) -{ - Value *v; - Value *last; - - fprintf (f, "APPLICATION-SERVICE-ELEMENT"); - indentG += indentStepG; - - if ((ase->operations != NULL)&& (!LIST_EMPTY (ase->operations))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"OPERATIONS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - - last = (Value*)LAST_LIST_ELMT (ase->operations); - FOR_EACH_LIST_ELMT (v, ase->operations) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - else /* either suuplier invokes or consumer invokes will be valid */ - { - if ((ase->consumerInvokes != NULL) && (!LIST_EMPTY (ase->consumerInvokes))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"CONSUMER INVOKES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*) LAST_LIST_ELMT (ase->consumerInvokes); - FOR_EACH_LIST_ELMT (v, ase->consumerInvokes) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - if ((ase->operations != NULL) && (!LIST_EMPTY (ase->operations))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"SUPPLIER INVOKES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*)LAST_LIST_ELMT (ase->supplierInvokes); - FOR_EACH_LIST_ELMT (v, ase->supplierInvokes) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - } - indentG -= indentStepG; - -} /* PrintRosAseMacrType */ - - - - -void -PrintRosAcMacroType PARAMS ((f, head, t, bt, ac), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAcMacroType *ac) -{ - Value *v; - Value *last; - OID *oid; - OID *lastOid; - - fprintf (f, "APPLICATION-CONTEXT"); - indentG += indentStepG; - - /* - * print non Ros Elements - */ - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"APPLICATION-SERVICE-ELEMENTS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - if ((ac->nonRoElements == NULL) && (!LIST_EMPTY (ac->nonRoElements))) - last = (Value*)LAST_LIST_ELMT (ac->nonRoElements); - FOR_EACH_LIST_ELMT (v, ac->nonRoElements) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "}\n"); - - /* - * Print Bind Type - */ - INDENT (f, indentG); - fprintf (f,"BIND\n"); - INDENT (f, indentG); - PrintType (f, head, ac->bindMacroType); - fprintf (f, "\n"); - - /* - * Print unbind Type - */ - INDENT (f, indentG); - fprintf (f,"UNBIND\n"); - INDENT (f, indentG); - PrintType (f, head, ac->unbindMacroType); - - - if (ac->remoteOperations != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"REMOTE OPERATIONS { "); - PrintValue (f, NULL, t, ac->remoteOperations); - fprintf (f, " }"); - - if ((ac->operationsOf != NULL) && (!LIST_EMPTY (ac->operationsOf))) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"OPERATIONS OF\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*)LAST_LIST_ELMT (ac->operationsOf); - FOR_EACH_LIST_ELMT (v, ac->operationsOf) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((ac->initiatorConsumerOf != NULL) && (!LIST_EMPTY (ac->initiatorConsumerOf))) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"INITIATOR CONSUMER OF\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*)LAST_LIST_ELMT (ac->initiatorConsumerOf); - FOR_EACH_LIST_ELMT (v, ac->initiatorConsumerOf) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((ac->responderConsumerOf != NULL) && (!LIST_EMPTY (ac->responderConsumerOf))) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"RESPONDER CONSUMER OF\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*)LAST_LIST_ELMT (ac->responderConsumerOf); - FOR_EACH_LIST_ELMT (v, ac->responderConsumerOf) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - } - - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"ABSTRACT SYNTAXES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - if ((ac->abstractSyntaxes != NULL) && (!LIST_EMPTY (ac->abstractSyntaxes))) - lastOid = (OID*)LAST_LIST_ELMT (ac->abstractSyntaxes); - FOR_EACH_LIST_ELMT (oid, ac->abstractSyntaxes) - { - INDENT (f, indentG); - PrintOid (f, oid); - if (oid != lastOid) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - - indentG -= indentStepG; - -} /* PrintRosAcMacroType */ - - -void -PrintMtsasExtensionsMacroType PARAMS ((f, head, t, bt, exts), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionsMacroType *exts) -{ - Value *v; - Value *last; - - fprintf (f, "EXTENSIONS CHOSEN FROM"); - - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - if ((exts->extensions == NULL) && (!LIST_EMPTY (exts->extensions))) - last = (Value*)LAST_LIST_ELMT (exts->extensions); - FOR_EACH_LIST_ELMT (v, exts->extensions) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - -} /* PrintMtsasExtensionsMacroType */ - - -void -PrintMtsasExtensionMacroType PARAMS ((f, head, t, bt, ext), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionMacroType *ext) -{ - - fprintf (f, "EXTENSION"); - - indentG += indentStepG; - if (ext->elmtType != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - PrintElmtType (f, head, t, ext->elmtType); - - if (ext->defaultValue != NULL) - { - fprintf (f, " DEFAULT "); - PrintValue (f, NULL, t, ext->defaultValue); - } - } - - if ((ext->criticalForSubmission != NULL) || - (ext->criticalForTransfer != NULL) || - (ext->criticalForDelivery != NULL)) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "CRITICAL FOR "); - - if (ext->criticalForSubmission != NULL) - { - fprintf (f, "SUBMISSION"); - if ((ext->criticalForTransfer != NULL) || - (ext->criticalForDelivery != NULL)) - fprintf (f,", "); - } - - if (ext->criticalForTransfer != NULL) - { - fprintf (f, "TRANSFER, "); - if (ext->criticalForDelivery != NULL) - fprintf (f,", "); - } - - if (ext->criticalForDelivery != NULL) - fprintf (f, "DELIVERY"); - - } - - indentG -= indentStepG; - -} /* PrintMtsasExtensionMacroType */ - - - - -void -PrintMtsasExtensionAttributeMacroType PARAMS ((f, head, t, bt, ext), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionAttributeMacroType *ext) -{ - - fprintf (f, "EXTENSION-ATTRIBUTE"); - if (ext->type != NULL) - { - fprintf (f, "\n"); - indentG += indentStepG; - INDENT (f, indentG); - - PrintType (f, head, ext->type); - indentG -= indentStepG; - } - -} /* PrintMtsasExtensionAttributeMacroType */ - - - -void -PrintMtsasTokenMacroType PARAMS ((f, head, t, bt, tok), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenMacroType *tok) -{ - - fprintf (f, "TOKEN"); - if (tok->type != NULL) - { - fprintf (f, "\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintType (f, head, tok->type); - indentG -= indentStepG; - } - -} /* PrintMtsasTokenMacro */ - - -void -PrintMtsasTokenDataMacroType PARAMS ((f, head, t, bt, tok), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenDataMacroType *tok) -{ - - fprintf (f, "TOKEN-DATA"); - if (tok->type != NULL) - { - fprintf (f, "\n"); - indentG += indentStepG; - INDENT (f, indentG); - - PrintType (f, head, tok->type); - indentG -= indentStepG; - } - -} /* PrintMtsasTokenDataMacro */ - - -void -PrintMtsasSecurityCategoryMacroType PARAMS ((f, head, t, bt, sec), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasSecurityCategoryMacroType *sec) -{ - - fprintf (f, "SECURITY-CATEGORY"); - if (sec->type != NULL) - { - fprintf (f, "\n"); - indentG += indentStepG; - INDENT (f, indentG); - - PrintType (f, head, sec->type); - indentG -= indentStepG; - } - -} /* PrintMtsasSecurityCategoryMacroType */ - - - -void -PrintAsnObjectMacroType PARAMS ((f, head, t, bt, obj), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnObjectMacroType *obj) -{ - AsnPort *ap; - AsnPort *last; - - fprintf (f, "OBJECT"); - - indentG += indentStepG; - - if ((obj->ports != NULL) && !LIST_EMPTY (obj->ports)) - { - - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "PORTS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (AsnPort*)LAST_LIST_ELMT (obj->ports); - FOR_EACH_LIST_ELMT (ap, obj->ports) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, ap->portValue); - - if (ap->portType == CONSUMER_PORT) - fprintf (f, " [C]"); - else if (ap->portType == SUPPLIER_PORT) - fprintf (f, " [S]"); - - if (ap != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - indentG -= indentStepG; - -} /* PrintAsnObjectMacroType */ - - - -void -PrintAsnPortMacroType PARAMS ((f, head, t, bt, p), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnPortMacroType *p) -{ - TypeOrValue *tOrV; - TypeOrValue *last; - - fprintf (f, "PORT"); - indentG += indentStepG; - if ((p->abstractOps != NULL) && (!LIST_EMPTY (p->abstractOps))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "ABSTRACT OPERATIONS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (p->abstractOps); - FOR_EACH_LIST_ELMT (tOrV, p->abstractOps) - { - INDENT (f, indentG); - - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((p->consumerInvokes != NULL) && (!LIST_EMPTY (p->consumerInvokes))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "CONSUMER INVOKES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (p->consumerInvokes); - FOR_EACH_LIST_ELMT (tOrV, p->consumerInvokes) - { - INDENT (f, indentG); - - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((p->supplierInvokes != NULL) && (!LIST_EMPTY (p->supplierInvokes))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "SUPPLIER INVOKES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (p->supplierInvokes); - FOR_EACH_LIST_ELMT (tOrV, p->supplierInvokes) - - { - INDENT (f, indentG); - - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - indentG -= indentStepG; - -} /* PrintAsnPortMacroType */ - - - - -void -PrintAsnAbstractBindMacroType PARAMS ((f, head, t, bt, bind), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnAbstractBindMacroType *bind) -{ - AsnPort *ap; - AsnPort *last; - - if (bt->a.macroType->choiceId == MACROTYPE_ASNABSTRACTBIND) - fprintf (f, "ABSTRACT-BIND"); - else - fprintf (f, "ABSTRACT-UNBIND"); - - indentG += indentStepG; - - if ((bind->ports != NULL) && (!LIST_EMPTY (bind->ports))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - if (bt->a.macroType->choiceId == MACROTYPE_ASNABSTRACTBIND) - fprintf (f, "TO\n"); - else - fprintf (f, "FROM\n"); - - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (AsnPort*)LAST_LIST_ELMT (bind->ports); - FOR_EACH_LIST_ELMT (ap, bind->ports) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, ap->portValue); - - if (ap->portType == CONSUMER_PORT) - fprintf (f, " [C]"); - else if (ap->portType == SUPPLIER_PORT) - fprintf (f, " [S]"); - - if (ap != last) - fprintf (f, ",\n"); - } - - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if (bind->type != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - PrintType (f, head, bind->type); - } - - indentG -= indentStepG; - -} /* PrintAsnAbstractBindMacroType */ - - - -void -PrintAfAlgorithmMacroType PARAMS ((f, head, t, bt, alg), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *alg) -{ - indentG += indentStepG; - fprintf (f, "ALGORITHM PARAMETER "); - PrintType (f, head, alg); - indentG -= indentStepG; -} /* PrintAfAlgorithmMacroType */ - - -void -PrintAfEncryptedMacroType PARAMS ((f, head, t, bt, encrypt), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *encrypt) -{ - indentG += indentStepG; - fprintf (f, "ENCRYPTED "); - PrintType (f, head, encrypt); - indentG -= indentStepG; -} /* PrintAfEncryptedMacroType */ - - -void -PrintAfSignedMacroType PARAMS ((f, head, t, bt, sign), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *sign) -{ - indentG += indentStepG; - fprintf (f, "SIGNED "); - PrintType (f, head, sign); - indentG -= indentStepG; -} /* PrintAfSignedMacroType */ - - -void -PrintAfSignatureMacroType PARAMS ((f, head, t, bt, sig), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *sig) -{ - indentG += indentStepG; - fprintf (f, "SIGNATURE "); - PrintType (f, head, sig); - indentG -= indentStepG; -} /* PrintAfSignatureMacroType */ - - -void -PrintAfProtectedMacroType PARAMS ((f, head, t, bt, p), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *p) -{ - indentG += indentStepG; - fprintf (f, "PROTECTED "); - PrintType (f, head, p); - indentG -= indentStepG; -} /* PrintAfMacroType */ - - -void -PrintSnmpObjectTypeMacroType PARAMS ((f, head, t, bt, ot), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - SnmpObjectTypeMacroType *ot) -{ - TypeOrValue *tOrV; - TypeOrValue *last; - - fprintf (f, "OBJECT-TYPE\n"); - indentG += indentStepG; - INDENT (f,indentG); - fprintf (f,"SYNTAX "); - indentG += indentStepG; - PrintType (f, head, ot->syntax); - indentG -= indentStepG; - - fprintf (f,"\n"); - INDENT (f,indentG); - fprintf (f,"ACCESS "); - switch (ot->access) - { - case SNMP_READ_ONLY: - fprintf (f,"read-only"); - break; - - case SNMP_READ_WRITE: - fprintf (f,"read-write"); - break; - - case SNMP_WRITE_ONLY: - fprintf (f,"write-only"); - break; - - case SNMP_NOT_ACCESSIBLE: - fprintf (f,"not-accessible"); - break; - - default: - fprintf (f," < ?? unknown access type ?? >"); - } - - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"STATUS "); - switch (ot->status) - { - case SNMP_MANDATORY: - fprintf (f,"mandatory"); - break; - - case SNMP_OPTIONAL: - fprintf (f,"optional"); - break; - - case SNMP_OBSOLETE: - fprintf (f,"obsolete"); - break; - - case SNMP_DEPRECATED: - fprintf (f,"deprecated"); - break; - - default: - fprintf (f," < ?? unknown status type ?? >"); - } - - if (ot->description != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"DESCRIPTION\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintValue (f, NULL, t, ot->description); - indentG -= indentStepG; - } - - if (ot->reference != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"REFERENCE\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintValue (f, NULL, t, ot->reference); - indentG -= indentStepG; - } - - if (ot->index != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"INDEX\n"); - indentG += indentStepG; - INDENT (f, indentG); - last = (TypeOrValue*)LAST_LIST_ELMT (ot->index); - FOR_EACH_LIST_ELMT (tOrV, ot->index) - { - INDENT (f, indentG); - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - indentG -= indentStepG; - } - - if (ot->defVal != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"DEFVAL\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintValue (f, NULL, t, ot->defVal); - indentG -= indentStepG; - } - - fprintf (f,"\n"); - - indentG -= indentStepG; -} /* PrintSnmpObjectTypeMacroType */ - - -/* - * @MACRO@ add new macro print routines above this point - */ - -void -PrintMacroDef PARAMS ((f, head), - FILE *f _AND_ - TypeDef *head) -{ - char *s; - - fprintf (f,"\n-- Note: snacc does not use macro defs to extend the compiler."); - fprintf (f,"\n-- All macros that are understood have been hand coded."); - fprintf (f,"\n-- The macro def body is kept as a string only.\n\n"); - - s = head->type->basicType->a.macroDef; - - fprintf (f, "%s MACRO ::=\n", head->definedName); - fprintf (f, "%s", s); - -} /* PrintMacroDef */ - - - -void -PrintEncodedOid PARAMS ((f, eoid), - FILE *f _AND_ - AsnOid *eoid) -{ - int i; - int arcNum; - int firstArcNum; - int secondArcNum; - - if (eoid == NULL) - return; - - fprintf (f, "{ "); - - for (arcNum = 0, i=0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - i++; - - firstArcNum = arcNum / 40; - if (firstArcNum > 2) - firstArcNum = 2; - - secondArcNum = arcNum - (firstArcNum * 40); - - fprintf (f, "%d ", firstArcNum); - fprintf (f, "%d ", secondArcNum); - for (; i < eoid->octetLen; ) - { - for (arcNum = 0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - i++; - - fprintf (f, "%d ", arcNum); - } - - fprintf (f, "}"); - -} /* PrintEncodedOid */ - - - -/* - * this just prints a short form of the given type. It - * does not print the components of a constructed type - * such as a SEQUENCE - * This is used by the header file generators to annotate - * the C/C++ types - */ -void -SpecialPrintBasicType PARAMS ((f, head, t, bt), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt) -{ - switch (bt->choiceId) - { - - case BASICTYPE_SEQUENCE: - fprintf (f, "SEQUENCE"); - break; - - case BASICTYPE_SET: - fprintf (f, "SET"); - break; - - case BASICTYPE_CHOICE: - fprintf (f, "CHOICE"); - break; - - - - case BASICTYPE_SEQUENCEOF: - fprintf (f, "SEQUENCE "); - if (t->subtypes != NULL) - { - PrintSubtype (f, head, t, t->subtypes); - fprintf (f," "); - } - fprintf (f, "OF "); - SpecialPrintType (f, head, t->basicType->a.sequenceOf); - break; - - case BASICTYPE_SETOF: - fprintf (f, "SET "); - if (t->subtypes != NULL) - { - PrintSubtype (f, head, t, t->subtypes); - fprintf (f," "); - } - fprintf (f, "OF "); - SpecialPrintType (f, head, t->basicType->a.sequenceOf); - break; - - - case BASICTYPE_SELECTION: - fprintf (f, "%s < ", bt->a.selection->fieldName); - PrintType (f, head, bt->a.selection->typeRef); - break; - - - - - case BASICTYPE_COMPONENTSOF: - fprintf (f, "COMPONENTS OF "); - PrintType (f, NULL, bt->a.componentsOf); - break; - - - - case BASICTYPE_ANYDEFINEDBY: - fprintf (f, "ANY DEFINED BY %s", bt->a.anyDefinedBy->fieldName); - break; - - - case BASICTYPE_LOCALTYPEREF: - fprintf (f, "%s", bt->a.localTypeRef->typeName); - break; - - case BASICTYPE_IMPORTTYPEREF: - fprintf (f, "%s", bt->a.importTypeRef->typeName); - break; - - - case BASICTYPE_UNKNOWN: - fprintf (f, "unknown type !?!"); - break; - - case BASICTYPE_BOOLEAN: - fprintf (f, "BOOLEAN"); - break; - - - case BASICTYPE_INTEGER: - fprintf (f, "INTEGER"); - if ((bt->a.integer != NULL) && !LIST_EMPTY (bt->a.integer)) - SpecialPrintNamedElmts (f, head, t); - break; - - - case BASICTYPE_BITSTRING: - fprintf (f, "BIT STRING"); - if ((bt->a.bitString != NULL) && !LIST_EMPTY (bt->a.bitString)) - SpecialPrintNamedElmts (f, head, t); - break; - - case BASICTYPE_OCTETSTRING: - fprintf (f, "OCTET STRING"); - break; - - case BASICTYPE_NULL: - fprintf (f, "NULL"); - break; - - case BASICTYPE_OID: - fprintf (f, "OBJECT IDENTIFIER"); - break; - - case BASICTYPE_REAL: - fprintf (f, "REAL"); - break; - - case BASICTYPE_ENUMERATED: - fprintf (f, "ENUMERATED"); - if ((bt->a.enumerated != NULL) && !LIST_EMPTY (bt->a.enumerated)) - SpecialPrintNamedElmts (f, head, t); - - break; - - case BASICTYPE_ANY: - fprintf (f, "ANY"); - break; - - case BASICTYPE_MACROTYPE: - switch (bt->a.macroType->choiceId) - { - case MACROTYPE_ROSOPERATION: - case MACROTYPE_ASNABSTRACTOPERATION: - PrintRosOperationMacroType (f, head, t, bt, bt->a.macroType->a.rosOperation); - break; - - case MACROTYPE_ROSERROR: - case MACROTYPE_ASNABSTRACTERROR: - PrintRosErrorMacroType (f, head, t, bt, bt->a.macroType->a.rosError); - break; - - case MACROTYPE_ROSBIND: - case MACROTYPE_ROSUNBIND: - PrintRosBindMacroType (f, head, t, bt, bt->a.macroType->a.rosBind); - break; - - case MACROTYPE_ROSASE: - PrintRosAseMacroType (f, head, t, bt, bt->a.macroType->a.rosAse); - break; - - case MACROTYPE_MTSASEXTENSIONS: - PrintMtsasExtensionsMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensions); - break; - - case MACROTYPE_MTSASEXTENSION: - PrintMtsasExtensionMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtension); - break; - - case MACROTYPE_MTSASEXTENSIONATTRIBUTE: - PrintMtsasExtensionAttributeMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensionAttribute); - break; - - case MACROTYPE_MTSASTOKEN: - PrintMtsasTokenMacroType (f, head, t, bt, bt->a.macroType->a.mtsasToken); - break; - - case MACROTYPE_MTSASTOKENDATA: - PrintMtsasTokenDataMacroType (f, head, t, bt, bt->a.macroType->a.mtsasTokenData); - break; - - case MACROTYPE_MTSASSECURITYCATEGORY: - PrintMtsasSecurityCategoryMacroType (f, head, t, bt, bt->a.macroType->a.mtsasSecurityCategory); - break; - - case MACROTYPE_ASNOBJECT: - PrintAsnObjectMacroType (f, head, t, bt, bt->a.macroType->a.asnObject); - break; - - case MACROTYPE_ASNPORT: - PrintAsnPortMacroType (f, head, t, bt, bt->a.macroType->a.asnPort); - break; - - case MACROTYPE_ASNABSTRACTBIND: - case MACROTYPE_ASNABSTRACTUNBIND: - PrintAsnAbstractBindMacroType (f, head, t, bt, bt->a.macroType->a.asnAbstractBind); - break; - - case MACROTYPE_AFALGORITHM: - PrintAfAlgorithmMacroType (f, head, t, bt, bt->a.macroType->a.afAlgorithm); - break; - - case MACROTYPE_AFENCRYPTED: - PrintAfEncryptedMacroType (f, head, t, bt, bt->a.macroType->a.afEncrypted); - break; - - case MACROTYPE_AFSIGNED: - PrintAfSignedMacroType (f, head, t, bt, bt->a.macroType->a.afSigned); - break; - - case MACROTYPE_AFSIGNATURE: - PrintAfSignatureMacroType (f, head, t, bt, bt->a.macroType->a.afSignature); - break; - - case MACROTYPE_AFPROTECTED: - PrintAfProtectedMacroType (f, head, t, bt, bt->a.macroType->a.afProtected); - break; - - case MACROTYPE_SNMPOBJECTTYPE: - PrintSnmpObjectTypeMacroType (f, head, t, bt, bt->a.macroType->a.snmpObjectType); - break; - - default: - fprintf (f, "< unknown macro type id ?! >"); - - } /* end macro type switch */ - break; - - /* - * @MACRO@ add new macro printers above this point - */ - - case BASICTYPE_MACRODEF: - /* - * printing this should be handled in PrintTypeDefs - */ - break; - - - default: - fprintf (f, "< unknown type id ?! >"); - - } -} /* SpecialPrintBasicType */ - - -/* - * this just prints a short form of the given type. It - * does not print the components of a constructed type - * such as a SEQUENCE - * This is used by the header file generators to annotate - * the C types - */ -void -SpecialPrintType PARAMS ((f, head, t), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t) -{ - Tag *tag; - Tag *lastTag; - - if (t == NULL) - return; - - lastTag = NULL; - FOR_EACH_LIST_ELMT (tag, t->tags) - { - if (!(tag->tclass == UNIV && tag->code == LIBTYPE_GET_UNIV_TAG_CODE (t->basicType->choiceId))) - { - PrintTag (f, tag); - fprintf (f, " "); - } - lastTag = tag; - } - - /* - * check type has been implicitly tagged - */ - if (t->implicit) - fprintf (f, "IMPLICIT "); - - SpecialPrintBasicType (f, head, t, t->basicType); - - - /* - * sequences of and set of print subtypes a special way - * so ignore them here - */ - if ((t->subtypes != NULL) && - (t->basicType->choiceId != BASICTYPE_SETOF) && - (t->basicType->choiceId != BASICTYPE_SEQUENCEOF)) - { - fprintf (f," "); - PrintSubtype (f, head, t, t->subtypes); - } - - - if (t->defaultVal != NULL) - { - fprintf (f, " DEFAULT "); - if (t->defaultVal->fieldName != NULL) - fprintf (f, "%s ", t->defaultVal->fieldName); - PrintValue (f, NULL, t, t->defaultVal->value); - } - - else if (t->optional) - fprintf (f, " OPTIONAL"); - - -#ifdef DEBUG - fprintf (f, " -- lineNo = %d", t->lineNo); - fprintf (f, " --"); -#endif - -} /* SpecialPrintType */ - - -/* - * This is used by the header file generators to annotate - * the C/C++ types. This version prints the C version of the - * enum/bits elmt names to make sure the programmer can use - * the correct defines/enum constants. - * NOTE: this can only be called after the CTRI infor is filled in - * so the C/C++ names can be accessed - */ -void -SpecialPrintNamedElmts PARAMS ((f, head, t), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t) -{ - CNamedElmt *last; - CNamedElmt *cne; - CNamedElmts *n = NULL; - - if (t->cTypeRefInfo != NULL) - n = t->cTypeRefInfo->cNamedElmts; - - if ((n == NULL) && (t->cxxTypeRefInfo != NULL)) - n = t->cxxTypeRefInfo->namedElmts; - - - if ((n == NULL) || LIST_EMPTY (n)) - return; - - fprintf (f," { "); - last = (CNamedElmt*)LAST_LIST_ELMT (n); - FOR_EACH_LIST_ELMT (cne, n) - { - fprintf (f, "%s (%d)", cne->name, cne->value); - if (cne != last) - fprintf (f,", "); - } - fprintf (f," } "); -} /* SpecialPrintNamedElmts */ diff --git a/SecuritySNACCRuntime/compiler/core/print.h b/SecuritySNACCRuntime/compiler/core/print.h deleted file mode 100644 index 954837bd..00000000 --- a/SecuritySNACCRuntime/compiler/core/print.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * compiler/core/print.h - * - * These are the prototypes for the typetree printing - * routines. Attempts to convert a typetree back into its original - * ASN.1 def. - * - * Mike Sample - * Mar 3/91 - * - * Rewritten 91/09/05 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/print.h,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: print.h,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1994/10/08 03:48:56 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:33 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - - - -void PrintModule PROTO ((FILE *f, Module *mod)); - -void PrintExports PROTO ((FILE *f, Module *m)); - -void PrintOid PROTO ((FILE *f, OID *oid)); - -void PrintImportElmt PROTO ((FILE *f, ImportElmt *impElmt)); - -void PrintImportLists PROTO ((FILE *f, ImportModuleList *impLists)); - -void PrintTypeDefs PROTO ((FILE *f, TypeDefList *typeDefs)); - -void PrintType PROTO ((FILE *f, TypeDef *head, Type *t)); - -void PrintBasicType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt)); - -void PrintElmtType PROTO ((FILE *f, TypeDef *head, Type *t, NamedType *nt)); - -void PrintElmtTypes PROTO ((FILE *f, TypeDef *head, Type *t, NamedTypeList *e)); - -void PrintValueDefs PROTO ((FILE *f, ValueDefList *v)); - -void PrintValueDef PROTO ((FILE *f, ValueDef *v)); - -void PrintValue PROTO ((FILE *f, ValueDef *head, Type *valuesType, Value *v)); - -void PrintBasicValue PROTO ((FILE *f, ValueDef *head, Type *valuesType, Value *v, BasicValue *bv)); - -void PrintElmtValue PROTO ((FILE *f, ValueDef *head, Value *v, NamedValue *nv)); - -void PrintElmtValues PROTO ((FILE *f, ValueDef *head, Value *v, NamedValueList *e)); - -void PrintTag PROTO ((FILE *f, Tag *tag)); - -void PrintSubtype PROTO ((FILE *f, TypeDef *head, Type *t, Subtype *s)); - -void PrintSubtypeValue PROTO ((FILE *f, TypeDef *head, Type *t, SubtypeValue *s)); - -void PrintNamedElmts PROTO ((FILE *f, TypeDef *head, Type *t, ValueDefList *n)); - -void PrintInnerSubtype PROTO ((FILE *f, TypeDef *head, Type *t, InnerSubtype *i)); - -void PrintMultipleTypeConstraints PROTO ((FILE *f, TypeDef *head, Type *t, ConstraintList *c)); - -void PrintTypeById PROTO ((FILE *f, int typeId)); - - -void PrintRosOperationMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, RosOperationMacroType *op)); - -void PrintRosErrorMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, RosErrorMacroType *err)); - -void PrintRosBindMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, RosBindMacroType *bind)); - -void PrintRosAseMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, RosAseMacroType *ase)); - -void PrintRosAcMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, RosAcMacroType *ac)); - -void PrintMtsasExtensionsMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionsMacroType *exts)); - -void PrintMtsasExtensionMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionMacroType *ext)); - -void PrintMtsasExtensionAttributeMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, MtsasExtensionAttributeMacroType *ext)); - -void PrintMtsasTokenMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, MtsasTokenMacroType *tok)); - -void PrintMtsasTokenDataMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, MtsasTokenDataMacroType *tok)); - -void PrintMtsasSecurityCategoryMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, MtsasSecurityCategoryMacroType *sec)); - -void PrintAsnObjectMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, AsnObjectMacroType *obj)); - -void PrintAsnPortMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, AsnPortMacroType *p)); - -void PrintAsnAbstractBindMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, AsnAbstractBindMacroType *bind)); - -void PrintAfAlgorithmMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, Type *alg)); - -void PrintAfEncryptedMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, Type *encrypt)); - -void PrintAfSignedMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, Type *sign)); - -void PrintAfSignatureMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, Type *sig)); - -void PrintAfProtectedMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, Type *p)); - -void PrintSnmpObjectTypeMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt, SnmpObjectTypeMacroType *ot)); - -void PrintMacroDef PROTO ((FILE *f, TypeDef *head)); - -void PrintEncodedOid PROTO ((FILE *f, AsnOid *eoid)); - - -void SpecialPrintType PROTO ((FILE *f, TypeDef *head, Type *t)); - -void SpecialPrintBasicType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType *bt)); - -void SpecialPrintNamedElmts PROTO ((FILE *f, TypeDef *head, Type *t)); diff --git a/SecuritySNACCRuntime/compiler/core/print2.c b/SecuritySNACCRuntime/compiler/core/print2.c deleted file mode 100644 index 9743d062..00000000 --- a/SecuritySNACCRuntime/compiler/core/print2.c +++ /dev/null @@ -1,2764 +0,0 @@ -/* - * compiler/core/print.c - * - * These routines are for printing the information from a Module - * Data strucuture in ASN.1 form. - * - * Useful for debugging the parser and seeing changes caused by - * normalization and sorting. - * - * Mike Sample - * Feb 28/91 - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/print2.c,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: print2.c,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.6 1997/02/28 13:39:55 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.5 1995/08/17 14:58:57 rj - * minor typographic change - * - * Revision 1.4 1995/07/25 19:41:42 rj - * changed `_' to `-' in file names. - * - * Revision 1.3 1994/10/08 03:48:53 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.2 1994/09/01 00:42:16 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:32 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "lib-types.h" -#include "print.h" - - -static int indentCountG; -static int indentG = 0; -static int indentStepG = 4; - -#define INDENT(f, i)\ - for (indentCountG = 0; indentCountG < (i); indentCountG++)\ - fputc (' ', (f))\ - -/* - * Prints the given Module *, mod, to the given FILE *f in - * ASN.1 format - */ -void -PrintModule PARAMS ((f, mod), - FILE *f _AND_ - Module *mod) -{ - - if (mod->status == MOD_ERROR) - { - fprintf (f, "WARNING: this module contains errors\n"); - fprintf (f,"(probably some type/value is referenced but is not defined or imported)\n"); - fprintf (f,"The prog. may croak, cross your fingers!\n"); - } - - - fprintf (f, "%s ",mod->modId->name); - PrintOid (f, mod->modId->oid); - - fprintf (f, "\nDEFINITIONS "); - - if (mod->tagDefault == EXPLICIT_TAGS) - fprintf (f, "EXPLICIT TAGS"); - - else if (mod->tagDefault == IMPLICIT_TAGS) - fprintf (f, "IMPLICIT TAGS"); - else - fprintf (f, "\n\n -- compiler error unknown tag default"); - - - fprintf (f, " ::=\nBEGIN\n\n"); - - - - PrintExports (f, mod); - - PrintImportLists (f, mod->imports); - - PrintTypeDefs (f, mod->typeDefs); - PrintValueDefs (f, mod->valueDefs); - - fprintf (f, "END\n"); - -} /* PrintModule */ - - -void -PrintExports PARAMS ((f, m), - FILE *f _AND_ - Module *m) -{ - TypeDef *td; - ValueDef *vd; - int first; - - if (m->exportStatus == EXPORTS_ALL) - { - fprintf (f, "\n\n-- exports everything\n\n"); - } - else if (m->exportStatus == EXPORTS_NOTHING) - { - fprintf (f, "\n\nEXPORTS -- exports nothing\n\n"); - } - else - { - fprintf (f, "\n\nEXPORTS\n"); - first = 1; - FOR_EACH_LIST_ELMT (td, m->typeDefs) - if (td->exported) - { - if (!first) - fprintf (f,", "); - fprintf (f, "%s", td->definedName); - first = 0; - } - - FOR_EACH_LIST_ELMT (vd, m->valueDefs) - if (vd->exported) - { - if (!first) - fprintf (f,", "); - fprintf (f, "%s", vd->definedName); - first = 0; - } - - fprintf (f, "\n;\n\n"); - } -} /* PrintExports */ - - - -void -PrintOid PARAMS ((f, oid), - FILE *f _AND_ - OID *oid) -{ - int i; - - if (oid == NULL) - return; - - fprintf (f, "{ "); - for (; oid != NULL; oid = oid->next) - { - /* - * value ref to an integer or if first elmt in - * oid can ref other oid value - * { id-asdc } - */ - if (oid->valueRef != NULL) - PrintValue (f, NULL, NULL, oid->valueRef); - - /* - * just "arcNum" format - * { 2 } - */ - else if (oid->arcNum != NULL_OID_ARCNUM) - fprintf (f, "%d", oid->arcNum); - - - fprintf (f, " "); - } - fprintf (f, "}"); - -} /* PrintOid */ - - - -void -PrintImportElmt PARAMS ((f, impElmt), - FILE *f _AND_ - ImportElmt *impElmt) -{ - fprintf (f, "%s",impElmt->name); -} /* PrintImportElmt */ - - -void -PrintImportElmts PARAMS ((f, impElmtList), - FILE *f _AND_ - ImportElmtList *impElmtList) -{ - ImportElmt *ie; - ImportElmt *last; - - if ((impElmtList == NULL) || (LIST_EMPTY (impElmtList))) - return; - - last = (ImportElmt*)LAST_LIST_ELMT (impElmtList); - FOR_EACH_LIST_ELMT (ie, impElmtList) - { - PrintImportElmt (f, ie); - - if (ie != last) - fprintf (f, ", "); - } - -} /* PrintImportElmts */ - - - -void -PrintImportLists PARAMS ((f, impLists), - FILE *f _AND_ - ImportModuleList *impLists) -{ - ImportModule *impMod; - - if (impLists == NULL) - { - fprintf (f,"\n\n-- imports nothing\n\n"); - return; - } - - fprintf (f, "IMPORTS\n\n"); - FOR_EACH_LIST_ELMT (impMod, impLists) - { - PrintImportElmts (f, impMod->importElmts); - - fprintf (f, "\n FROM %s ", impMod->modId->name); - - PrintOid (f, impMod->modId->oid); - - fprintf (f, "\n\n\n"); - } - fprintf (f, ";\n\n\n"); - -} /* PrintImportLists */ - - - -void -PrintTypeDefs PARAMS ((f, typeDefs), - FILE *f _AND_ - TypeDefList *typeDefs) -{ - TypeDef *td; - - FOR_EACH_LIST_ELMT (td, typeDefs) - { - if (td->type->basicType->choiceId == BASICTYPE_MACRODEF) - PrintMacroDef (f, td); - else - { - fprintf (f,"-- %s notes: ", td->definedName); - - if (td->recursive) - fprintf (f,"recursive, "); - else - fprintf (f,"not recursive, "); - - if (td->exported) - fprintf (f,"exported,\n"); - else - fprintf (f,"not exported,\n"); - - fprintf (f,"-- locally refd %d times, ", td->localRefCount); - fprintf (f,"import refd %d times\n", td->importRefCount); - - - fprintf (f, "%s ::= ", td->definedName); - PrintType (f, td, td->type); - } - fprintf (f, "\n\n\n"); - } -} /* PrintTypeDefs */ - - - - -void -PrintType PARAMS ((f, head, t), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t) -{ - Tag *tag; - Tag *lastTag; - - if (t == NULL) - return; - - lastTag = NULL; - FOR_EACH_LIST_ELMT (tag, t->tags) - { - - - - if (! ((tag->tclass == UNIV) && - (tag->code == LIBTYPE_GET_UNIV_TAG_CODE (t->basicType->choiceId)))) - { - PrintTag (f, tag); - fprintf (f, " "); - } - lastTag = tag; - } - - /* - * check type has been implicitly tagged - */ - if (t->implicit) - fprintf (f, "IMPLICIT "); - - PrintBasicType (f, head, t, t->basicType); - - - /* - * sequences of and set of print subtypes a special way - * so ignore them here - */ - if ((t->subtypes != NULL) && - (t->basicType->choiceId != BASICTYPE_SETOF) && - (t->basicType->choiceId != BASICTYPE_SEQUENCEOF)) - { - fprintf (f," "); - PrintSubtype (f, head, t, t->subtypes); - } - - - if (t->defaultVal != NULL) - { - fprintf (f, " DEFAULT "); - if (t->defaultVal->fieldName != NULL) - fprintf (f, "%s ", t->defaultVal->fieldName); - PrintValue (f, NULL, t, t->defaultVal->value); - } - - else if (t->optional) - fprintf (f, " OPTIONAL"); - - -#ifdef DEBUG - fprintf (f, " -- lineNo = %d --", t->lineNo); -#endif - -} /* PrintType */ - - -void -PrintBasicType PARAMS ((f, head, t, bt), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt) -{ - switch (bt->choiceId) - { - - case BASICTYPE_SEQUENCE: - fprintf (f, "SEQUENCE\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtTypes (f, head, t, bt->a.sequence); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - break; - - case BASICTYPE_SET: - fprintf (f, "SET\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtTypes (f, head, t, bt->a.set); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - break; - - case BASICTYPE_CHOICE: - fprintf (f, "CHOICE\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtTypes (f, head, t, bt->a.choice); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - break; - - - - case BASICTYPE_SEQUENCEOF: - fprintf (f, "SEQUENCE "); - if (t->subtypes != NULL) - { - PrintSubtype (f, head, t, t->subtypes); - fprintf (f," "); - } - fprintf (f, "OF "); - PrintType (f, head, bt->a.sequenceOf); - break; - - case BASICTYPE_SETOF: - fprintf (f, "SET "); - if (t->subtypes != NULL) - { - PrintSubtype (f, head, t, t->subtypes); - fprintf (f," "); - } - fprintf (f, "OF "); - PrintType (f, head, bt->a.setOf); - break; - - - case BASICTYPE_SELECTION: - fprintf (f, "%s < ", bt->a.selection->fieldName); - PrintType (f, head, bt->a.selection->typeRef); - break; - - - - - case BASICTYPE_COMPONENTSOF: - fprintf (f, "COMPONENTS OF "); - PrintType (f, NULL, bt->a.componentsOf); - break; - - - - case BASICTYPE_ANYDEFINEDBY: - fprintf (f, "ANY DEFINED BY %s", bt->a.anyDefinedBy->fieldName); - break; - - - case BASICTYPE_LOCALTYPEREF: - fprintf (f, "%s", bt->a.localTypeRef->typeName); - break; - - case BASICTYPE_IMPORTTYPEREF: - /* attempt to keep special scoping, ie modname.type forms */ - if (bt->a.importTypeRef->moduleName != NULL) - fprintf (f,"%s.", bt->a.importTypeRef->moduleName); - fprintf (f, "%s", bt->a.importTypeRef->typeName); - break; - - - case BASICTYPE_UNKNOWN: - fprintf (f, "unknown type !?!"); - break; - - case BASICTYPE_BOOLEAN: - fprintf (f, "BOOLEAN"); - break; - - - case BASICTYPE_INTEGER: - fprintf (f, "INTEGER"); - if ((bt->a.integer != NULL) && !LIST_EMPTY (bt->a.integer)) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - PrintNamedElmts (f, head, t, bt->a.integer); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - } - break; - - - case BASICTYPE_BITSTRING: - fprintf (f, "BIT STRING"); - if ((bt->a.bitString != NULL) && !LIST_EMPTY (bt->a.bitString)) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - PrintNamedElmts (f, head, t, bt->a.bitString); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - } - break; - - case BASICTYPE_OCTETSTRING: - fprintf (f, "OCTET STRING"); - break; - - case BASICTYPE_NULL: - fprintf (f, "NULL"); - break; - - case BASICTYPE_OID: - fprintf (f, "OBJECT IDENTIFIER"); - break; - - case BASICTYPE_REAL: - fprintf (f, "REAL"); - break; - - case BASICTYPE_ENUMERATED: - fprintf (f, "ENUMERATED"); - if ((bt->a.enumerated != NULL) && !LIST_EMPTY (bt->a.enumerated)) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - PrintNamedElmts (f, head, t, bt->a.enumerated); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - } - break; - - case BASICTYPE_ANY: - fprintf (f, "ANY"); - break; - - case BASICTYPE_MACROTYPE: - switch (bt->a.macroType->choiceId) - { - case MACROTYPE_ROSOPERATION: - case MACROTYPE_ASNABSTRACTOPERATION: - PrintRosOperationMacroType (f, head, t, bt, bt->a.macroType->a.rosOperation); - break; - - case MACROTYPE_ROSERROR: - case MACROTYPE_ASNABSTRACTERROR: - PrintRosErrorMacroType (f, head, t, bt, bt->a.macroType->a.rosError); - break; - - case MACROTYPE_ROSBIND: - case MACROTYPE_ROSUNBIND: - PrintRosBindMacroType (f, head, t, bt, bt->a.macroType->a.rosBind); - break; - - case MACROTYPE_ROSASE: - PrintRosAseMacroType (f, head, t, bt, bt->a.macroType->a.rosAse); - break; - - case MACROTYPE_MTSASEXTENSIONS: - PrintMtsasExtensionsMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensions); - break; - - case MACROTYPE_MTSASEXTENSION: - PrintMtsasExtensionMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtension); - break; - - case MACROTYPE_MTSASEXTENSIONATTRIBUTE: - PrintMtsasExtensionAttributeMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensionAttribute); - break; - - case MACROTYPE_MTSASTOKEN: - PrintMtsasTokenMacroType (f, head, t, bt, bt->a.macroType->a.mtsasToken); - break; - - case MACROTYPE_MTSASTOKENDATA: - PrintMtsasTokenDataMacroType (f, head, t, bt, bt->a.macroType->a.mtsasTokenData); - break; - - case MACROTYPE_MTSASSECURITYCATEGORY: - PrintMtsasSecurityCategoryMacroType (f, head, t, bt, bt->a.macroType->a.mtsasSecurityCategory); - break; - - case MACROTYPE_ASNOBJECT: - PrintAsnObjectMacroType (f, head, t, bt, bt->a.macroType->a.asnObject); - break; - - case MACROTYPE_ASNPORT: - PrintAsnPortMacroType (f, head, t, bt, bt->a.macroType->a.asnPort); - break; - - case MACROTYPE_ASNABSTRACTBIND: - case MACROTYPE_ASNABSTRACTUNBIND: - PrintAsnAbstractBindMacroType (f, head, t, bt, bt->a.macroType->a.asnAbstractBind); - break; - - case MACROTYPE_AFALGORITHM: - PrintAfAlgorithmMacroType (f, head, t, bt, bt->a.macroType->a.afAlgorithm); - break; - - case MACROTYPE_AFENCRYPTED: - PrintAfEncryptedMacroType (f, head, t, bt, bt->a.macroType->a.afEncrypted); - break; - - case MACROTYPE_AFSIGNED: - PrintAfSignedMacroType (f, head, t, bt, bt->a.macroType->a.afSigned); - break; - - case MACROTYPE_AFSIGNATURE: - PrintAfSignatureMacroType (f, head, t, bt, bt->a.macroType->a.afSignature); - break; - - case MACROTYPE_AFPROTECTED: - PrintAfProtectedMacroType (f, head, t, bt, bt->a.macroType->a.afProtected); - break; - - case MACROTYPE_SNMPOBJECTTYPE: - PrintSnmpObjectTypeMacroType (f, head, t, bt, bt->a.macroType->a.snmpObjectType); - break; - - default: - fprintf (f, "< unknown macro type id ?! >"); - - } /* end macro type switch */ - break; - - /* - * @MACRO@ add new macro printers above this point - */ - - case BASICTYPE_MACRODEF: - /* - * printing this should be handled in PrintTypeDefs - */ - break; - - - default: - fprintf (f, "< unknown type id ?! >"); - - } -} /* PrintBasicType */ - - - -void -PrintElmtType PARAMS ((f, head, t, nt), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - NamedType *nt) -{ - if (nt->fieldName != NULL) - fprintf (f, "%s ", nt->fieldName); - - PrintType (f, head, nt->type); - -} /* PrintElmtType */ - -void -PrintElmtTypes PARAMS ((f, head, t, e), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - NamedTypeList *e) -{ - NamedType *nt; - NamedType *last; - - if ((e == NULL) || LIST_EMPTY (e)) - return; - - last = (NamedType*)LAST_LIST_ELMT (e); - FOR_EACH_LIST_ELMT (nt, e) - { - - PrintElmtType (f, head, t, nt); - if (nt != last) - { - fprintf (f, ",\n"); - INDENT (f, indentG); - } - } -} /* PrintElmtTypes */ - - - - -void -PrintValueDefs PARAMS ((f, vList), - FILE *f _AND_ - ValueDefList *vList) -{ - ValueDef *v; - FOR_EACH_LIST_ELMT (v, vList) - { - PrintValueDef (f, v); - } -} /* PrintValueDefs */ - - -void -PrintValueDef PARAMS ((f, v), - FILE *f _AND_ - ValueDef *v) -{ - fprintf (f, "%s ", v->definedName); - - if (v->value->type != NULL) - PrintType (f, NULL, v->value->type); - else - /* just go by valueType */ - PrintTypeById (f, v->value->valueType); - - fprintf (f, " ::= "); - indentG += indentStepG; - PrintValue (f, v, v->value->type, v->value); - fprintf (f, "\n\n"); - indentG -= indentStepG; -} /* PrintValueDef */ - - -void -PrintValue PARAMS ((f, head, valuesType, v), - FILE *f _AND_ - ValueDef *head _AND_ - Type *valuesType _AND_ - Value *v) -{ - if (v == NULL) - return; - - PrintBasicValue (f, head, valuesType, v, v->basicValue); - -} /* PrintValue */ - - -void -PrintBasicValue PARAMS ((f, head, valuesType, v, bv), - FILE *f _AND_ - ValueDef *head _AND_ - Type *valuesType _AND_ - Value *v _AND_ - BasicValue *bv) -{ - if (v == NULL) - return; - - - switch (bv->choiceId) - { - case BASICVALUE_UNKNOWN: - fprintf (f, ""); - break; - - case BASICVALUE_EMPTY: - fprintf (f,"{ }"); - break; - - case BASICVALUE_INTEGER: - fprintf (f, "%d", bv->a.integer); - break; - - case BASICVALUE_SPECIALINTEGER: - if (bv->a.specialInteger == MAX_INT) - fprintf (f, "MAX"); - else - fprintf (f, "MIN"); - - break; - - case BASICVALUE_BOOLEAN: - if (bv->a.boolean) - fprintf (f,"TRUE"); - else - fprintf (f,"FALSE"); - break; - - case BASICVALUE_REAL: - fprintf (f, "%f", bv->a.real); - break; - - case BASICVALUE_SPECIALREAL: - if (bv->a.specialReal == PLUS_INFINITY_REAL) - fprintf (f, "PLUS INFINITY"); - else - fprintf (f, "MINUS INFINITY"); - - break; - - case BASICVALUE_ASCIITEXT: - fprintf (f, "\"%s\"", bv->a.asciiText->octs); - break; - - case BASICVALUE_ASCIIHEX: - fprintf (f, "\"%s\"", bv->a.asciiHex->octs); - break; - - case BASICVALUE_ASCIIBITSTRING: - fprintf (f, "\"%s\"", bv->a.asciiBitString->octs); - break; - - case BASICVALUE_OID: - PrintEncodedOid (f, bv->a.oid); - break; - - case BASICVALUE_LINKEDOID: - PrintOid (f, bv->a.linkedOid); - break; - - case BASICVALUE_BERVALUE: - fprintf (f,"a.namedValue); - indentG -= indentStepG; - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"}"); - break; - - case BASICVALUE_NULL: - fprintf (f,"NULL"); - break; - - case BASICVALUE_LOCALVALUEREF: - fprintf (f, "%s", bv->a.localValueRef->valueName); - break; - - case BASICVALUE_IMPORTVALUEREF: - fprintf (f, "%s", bv->a.importValueRef->valueName); - break; - - case BASICVALUE_VALUENOTATION: - fprintf (f, "-- snacc warning: can't parse this value yet --"); - fprintf (f, "%s", bv->a.valueNotation->octs); - break; - - - default: - fprintf (stderr,"PrintBasicValue: ERROR - unknown value type\n"); - } - -} /* PrintBasicValue */ - - -void -PrintElmtValue PARAMS ((f, head, v, nv), - FILE *f _AND_ - ValueDef *head _AND_ - Value *v _AND_ - NamedValue *nv) -{ - if (nv->fieldName != NULL) - fprintf (f, "%s ", nv->fieldName); - - PrintValue (f, NULL, NULL, nv->value); -} /* PrintElmtValue */ - - -void -PrintElmtValues PARAMS ((f, head, v, e), - FILE *f _AND_ - ValueDef *head _AND_ - Value *v _AND_ - NamedValueList *e) -{ - NamedValue *nv; - NamedValue *last; - - if ((e == NULL) || LIST_EMPTY (e)) - return; - - last = (NamedValue*)LAST_LIST_ELMT (e); - FOR_EACH_LIST_ELMT (nv, e) - { - PrintElmtValue (f, head, v, nv); - if (nv != last) - { - fprintf (f, ",\n"); - INDENT (f, indentG); - } - } -} /* PrintElmtValues */ - - -void -PrintTypeById PARAMS ((f, typeId), - FILE *f _AND_ - int typeId) -{ - switch (typeId) - { - case BASICTYPE_UNKNOWN: - fprintf (f, "UNKNOWN"); - break; - - case BASICTYPE_BOOLEAN: - fprintf (f, "BOOLEAN"); - break; - - case BASICTYPE_INTEGER: - fprintf (f, "INTEGER"); - break; - - case BASICTYPE_BITSTRING: - fprintf (f, "BIT STRING"); - break; - - case BASICTYPE_OCTETSTRING: - fprintf (f, "OCTET STRING"); - break; - - - case BASICTYPE_NULL: - fprintf (f, "NULL"); - break; - - case BASICTYPE_SEQUENCE: - fprintf (f, "SEQUENCE"); - break; - - case BASICTYPE_SEQUENCEOF: - fprintf (f, "SEQUENCE OF"); - break; - - case BASICTYPE_SET: - fprintf (f, "SET"); - break; - - case BASICTYPE_SETOF: - fprintf (f, "SET OF"); - break; - - case BASICTYPE_CHOICE: - fprintf (f, "CHOICE"); - break; - - case BASICTYPE_SELECTION: - fprintf (f, "SELECTION"); - break; - - case BASICTYPE_ANY: - fprintf (f, "ANY"); - break; - - case BASICTYPE_ANYDEFINEDBY: - fprintf (f, "ANY DEFINED BY"); - break; - - case BASICTYPE_OID: - fprintf (f, "OBJECT IDENTIFIER"); - break; - - case BASICTYPE_ENUMERATED: - fprintf (f, "ENUMERATED"); - break; - - case BASICTYPE_REAL: - fprintf (f, "REAL"); - break; - - case BASICTYPE_COMPONENTSOF: - fprintf (f, "COMPONENTS OF"); - break; - - default: - fprintf (f, "ERROR - %d is an unknown type id\n", typeId); - } -} /* PrintTypeById */ - - -void -PrintTag PARAMS ((f, tag), - FILE *f _AND_ - Tag *tag) -{ - char *name=NULL; - - if (tag->tclass == UNIV) - { - switch (tag->code) - { - case BOOLEAN_TAG_CODE: name = "BOOLEAN"; - break; - case INTEGER_TAG_CODE: name = "INTEGER"; - break; - case BITSTRING_TAG_CODE: name = "BITSTRING"; - break; - case OCTETSTRING_TAG_CODE: name = "OCTETSTRING"; - break; - case NULLTYPE_TAG_CODE: name = "NULL TYPE"; - break; - case OID_TAG_CODE: name = "OBJECT ID"; - break; - case OD_TAG_CODE: name = "OBEJECT DESCRIPTOR"; - break; - case EXTERNAL_TAG_CODE: name = "EXTERNAL"; - break; - case REAL_TAG_CODE: name = "REAL"; - break; - case ENUM_TAG_CODE: name = "ENUMERATED"; - break; - case SEQ_TAG_CODE: name = "SEQUENCE"; - break; - case SET_TAG_CODE: name = "SET"; - break; - case NUMERICSTRING_TAG_CODE: name = "NUMERIC STRING"; - break; - case PRINTABLESTRING_TAG_CODE: name = "PRINTABLE STRING"; - break; - case TELETEXSTRING_TAG_CODE: name = "TELETEX STRING"; - break; - case VIDEOTEXSTRING_TAG_CODE: name = "VIDEOTEX STRING"; - break; - case IA5STRING_TAG_CODE: name = "IA5 STRING"; - break; - case UTCTIME_TAG_CODE: name = "UTC TIME"; - break; - case GENERALIZEDTIME_TAG_CODE: name = "GENERALIZED TIME"; - break; - case GRAPHICSTRING_TAG_CODE: name = "GRAPHIC STRING"; - break; - case VISIBLESTRING_TAG_CODE: name = "VISIBLE STRING"; - break; - case GENERALSTRING_TAG_CODE: name = "GENERAL STRING"; - break; - - default: name = "UNKNOWN UNIVERSAL TYPE"; - } - fprintf (f, "[UNIVERSAL %d]", tag->code); - } - else if (tag->tclass == APPL) - { - fprintf (f, "[APPLICATION %d]", tag->code); - } - else if (tag->tclass == PRIV) - { - fprintf (f, "[PRIVATE %d]", tag->code); - } - else if (tag->tclass == CNTX) - { - fprintf (f, "[%d]", tag->code); - } - - if (tag->explicit) - fprintf (f, " EXPLICIT"); - -} /* PrintTag */ - - -void -PrintSubtype PARAMS ((f, head, t, s), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - Subtype *s) -{ - Subtype *tmpS; - Subtype *last; - - if (s == NULL) - return; - -/* fprintf (f, "("); */ - - switch (s->choiceId) - { - case SUBTYPE_SINGLE: - PrintSubtypeValue (f, head, t, s->a.single); - break; - - case SUBTYPE_AND: - FOR_EACH_LIST_ELMT (tmpS, s->a.and) - { - fprintf (f, "("); - PrintSubtype (f, head, t, tmpS); - fprintf (f, ")"); - } - break; - - - case SUBTYPE_OR: - if ((s->a.or != NULL) && !LIST_EMPTY (s->a.or)) - last = (Subtype*)LAST_LIST_ELMT (s->a.or); - FOR_EACH_LIST_ELMT (tmpS, s->a.or) - { - fprintf (f, "("); - PrintSubtype (f, head, t, tmpS); - fprintf (f, ")"); - if (tmpS != last) - fprintf (f, " | "); - } - break; - - case SUBTYPE_NOT: - fprintf (f, "NOT ("); - PrintSubtype (f, head, t, s->a.not); - fprintf (f, ")"); - break; - - default: - fprintf (stderr, "PrintSubtype: ERROR - unknown Subtypes choiceId\n"); - break; - } - -/* fprintf (f, ")"); */ - - -} /* PrintSubtype */ - - - -void -PrintSubtypeValue PARAMS ((f, head, t, s), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - SubtypeValue *s) -{ - if (s == NULL) - return; - - switch (s->choiceId) - { - case SUBTYPEVALUE_SINGLEVALUE: - PrintValue (f, NULL, NULL, s->a.singleValue); - break; - - case SUBTYPEVALUE_CONTAINED: - fprintf (f, "a.valueRange->lowerEndValue); - if (!s->a.valueRange->lowerEndInclusive) - fprintf (f, " >"); - fprintf (f,".."); - if (!s->a.valueRange->upperEndInclusive) - fprintf (f, "< "); - PrintValue (f, NULL, NULL, s->a.valueRange->upperEndValue); - break; - - - case SUBTYPEVALUE_PERMITTEDALPHABET: - fprintf (f,"FROM "); - PrintSubtype (f, head, t, s->a.permittedAlphabet); - break; - - case SUBTYPEVALUE_SIZECONSTRAINT: - fprintf (f,"SIZE "); - PrintSubtype (f, head, t, s->a.sizeConstraint); - break; - - case SUBTYPEVALUE_INNERSUBTYPE: - PrintInnerSubtype (f, head, t, s->a.innerSubtype); - break; - - default: - fprintf (stderr, "PrintSubtype: ERROR - unknown Subtype choiceId\n"); - break; - } -} /* PrintSubtype */ - - -void -PrintInnerSubtype PARAMS ((f, head, t, i), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - InnerSubtype *i) -{ - Constraint *constraint; - if (i->constraintType == SINGLE_CT) - { - fprintf (f,"WITH COMPONENT "); - constraint = *(Constraint**)AsnListFirst (i->constraints); - PrintSubtype (f, head, t, constraint->valueConstraints); - } - else - { - fprintf (f, "WITH COMPONENTS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - if (i->constraintType == PARTIAL_CT) - { - INDENT (f, indentG); - fprintf (f, "...,\n"); - } - PrintMultipleTypeConstraints (f, head, t, i->constraints); - indentG -= indentStepG; - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f, "}"); - - } -} /* PrintInnerSubtype */ - - - -void -PrintMultipleTypeConstraints PARAMS ((f, head, t, cList), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - ConstraintList *cList) -{ - Constraint *c; - Constraint *last; - - if ((cList == NULL) || LIST_EMPTY (cList)) - return; - - last = (Constraint*)LAST_LIST_ELMT (cList); - FOR_EACH_LIST_ELMT (c, cList) - { - if (c->fieldRef != NULL) - { - INDENT (f, indentG); - fprintf (f, "%s ", c->fieldRef); - } - - - PrintSubtype (f, head, t, c->valueConstraints); - - if (c->presenceConstraint == ABSENT_CT) - fprintf (f, " ABSENT"); - if (c->presenceConstraint == PRESENT_CT) - fprintf (f, " PRESENT"); - if (c->presenceConstraint == OPTIONAL_CT) - fprintf (f, " OPTIONAL"); - - if (c != last) - fprintf (f, ",\n"); - - } -} /* PrintMultipleTypeConstraints */ - - - -void -PrintNamedElmts PARAMS ((f, head, t, n), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - ValueDefList *n) -{ - ValueDef *vd; - ValueDef *last; - - if ((n == NULL) || LIST_EMPTY (n)) - return; - - last = (ValueDef*)LAST_LIST_ELMT (n); - FOR_EACH_LIST_ELMT (vd, n) - { - INDENT (f, indentG); - fprintf (f, "%s (", vd->definedName); - PrintValue (f, NULL, NULL, vd->value); - fprintf (f,")"); - if (vd != last) - fprintf (f,",\n"); - } -} /* PrintNamedElmts */ - - - - -void -PrintRosOperationMacroType PARAMS ((f, head, t, bt, op), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosOperationMacroType *op) -{ - TypeOrValue *tOrV; - TypeOrValue *last; - - if (bt->a.macroType->choiceId == MACROTYPE_ROSOPERATION) - fprintf (f, "OPERATION"); - else - fprintf (f, "ABSTRACT-OPERATION"); - - indentG += indentStepG; - if (op->arguments != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "ARGUMENT\n"); - indentG += indentStepG; - - INDENT (f, indentG); - - if (op->arguments->fieldName != NULL) - fprintf (f, "%s ", op->arguments->fieldName); - - PrintType (f, head, op->arguments->type); - indentG -= indentStepG; - } - - if (op->result != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "RESULT\n"); - indentG += indentStepG; - - INDENT (f, indentG); - - if (op->arguments->fieldName != NULL) - fprintf (f, "%s ", op->arguments->fieldName); - - PrintType (f, head, op->result->type); - indentG -= indentStepG; - } - - if ((op->errors == NULL) || (!LIST_EMPTY (op->errors))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "ERRORS\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (op->errors); - FOR_EACH_LIST_ELMT (tOrV, op->errors) - { - INDENT (f, indentG); - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - - } - indentG -= indentStepG; - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((op->linkedOps != NULL) && (!LIST_EMPTY (op->linkedOps))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "LINKED\n"); - INDENT (f, indentG); - fprintf (f,"{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (op->linkedOps); - FOR_EACH_LIST_ELMT (tOrV, op->linkedOps) - { - INDENT (f, indentG); - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - indentG -= indentStepG; - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, " }"); - } - - indentG -= indentStepG; - -} /* PrintRosOperationMacroType */ - - - -void -PrintRosErrorMacroType PARAMS ((f, head, t, bt, err), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosErrorMacroType *err) -{ - if (bt->a.macroType->choiceId == MACROTYPE_ROSERROR) - fprintf (f,"ERROR\n"); - else - fprintf (f,"ABSTRACT-ERROR\n"); - - indentG += indentStepG; - - if (err->parameter != NULL) - { - INDENT (f, indentG); - fprintf (f,"PARAMETER "); - indentG += indentStepG; - PrintElmtType (f, head, t, err->parameter); - indentG -= indentStepG; - } - indentG -= indentStepG; - -} /* PrintRosErrorMacroType */ - - -void -PrintRosBindMacroType PARAMS ((f, head, t, bt, bind), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosBindMacroType *bind) -{ - if (bt->a.macroType->choiceId == MACROTYPE_ROSBIND) - fprintf (f,"BIND"); - else - fprintf (f,"UNBIND"); - - indentG += indentStepG; - - if (bind->argument != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"ARGUMENT\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtType (f, head, t, bind->argument); - indentG -= indentStepG; - } - - if (bind->result != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"RESULT\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtType (f, head, t, bind->result); - indentG -= indentStepG; - } - - if (bind->error != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - if (bt->a.macroType->choiceId == MACROTYPE_ROSBIND) - fprintf (f,"BIND-ERROR\n"); - else - fprintf (f,"UNBIND-ERROR\n"); - - indentG += indentStepG; - INDENT (f, indentG); - PrintElmtType (f, head, t, bind->error); - indentG -= indentStepG; - } - - indentG -= indentStepG; - -} /* PrintRosBindMacroType */ - - -void -PrintRosAseMacroType PARAMS ((f, head, t, bt, ase), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAseMacroType *ase) -{ - Value *v; - Value *last; - - fprintf (f, "APPLICATION-SERVICE-ELEMENT"); - indentG += indentStepG; - - if ((ase->operations != NULL)&& (!LIST_EMPTY (ase->operations))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"OPERATIONS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - - last = (Value*)LAST_LIST_ELMT (ase->operations); - FOR_EACH_LIST_ELMT (v, ase->operations) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - else /* either suuplier invokes or consumer invokes will be valid */ - { - if ((ase->consumerInvokes != NULL) && (!LIST_EMPTY (ase->consumerInvokes))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"CONSUMER INVOKES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*) LAST_LIST_ELMT (ase->consumerInvokes); - FOR_EACH_LIST_ELMT (v, ase->consumerInvokes) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - if ((ase->operations != NULL) && (!LIST_EMPTY (ase->operations))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"SUPPLIER INVOKES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*)LAST_LIST_ELMT (ase->supplierInvokes); - FOR_EACH_LIST_ELMT (v, ase->supplierInvokes) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - } - indentG -= indentStepG; - -} /* PrintRosAseMacrType */ - - - - -void -PrintRosAcMacroType PARAMS ((f, head, t, bt, ac), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - RosAcMacroType *ac) -{ - Value *v; - Value *last; - OID *oid; - OID *lastOid; - - fprintf (f, "APPLICATION-CONTEXT"); - indentG += indentStepG; - - /* - * print non Ros Elements - */ - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"APPLICATION-SERVICE-ELEMENTS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - if ((ac->nonRoElements == NULL) && (!LIST_EMPTY (ac->nonRoElements))) - last = (Value*)LAST_LIST_ELMT (ac->nonRoElements); - FOR_EACH_LIST_ELMT (v, ac->nonRoElements) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "}\n"); - - /* - * Print Bind Type - */ - INDENT (f, indentG); - fprintf (f,"BIND\n"); - INDENT (f, indentG); - PrintType (f, head, ac->bindMacroType); - fprintf (f, "\n"); - - /* - * Print unbind Type - */ - INDENT (f, indentG); - fprintf (f,"UNBIND\n"); - INDENT (f, indentG); - PrintType (f, head, ac->unbindMacroType); - - - if (ac->remoteOperations != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"REMOTE OPERATIONS { "); - PrintValue (f, NULL, t, ac->remoteOperations); - fprintf (f, " }"); - - if ((ac->operationsOf != NULL) && (!LIST_EMPTY (ac->operationsOf))) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"OPERATIONS OF\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*)LAST_LIST_ELMT (ac->operationsOf); - FOR_EACH_LIST_ELMT (v, ac->operationsOf) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((ac->initiatorConsumerOf != NULL) && (!LIST_EMPTY (ac->initiatorConsumerOf))) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"INITIATOR CONSUMER OF\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*)LAST_LIST_ELMT (ac->initiatorConsumerOf); - FOR_EACH_LIST_ELMT (v, ac->initiatorConsumerOf) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((ac->responderConsumerOf != NULL) && (!LIST_EMPTY (ac->responderConsumerOf))) - { - fprintf (f, "\n"); - INDENT (f, indentG); - fprintf (f,"RESPONDER CONSUMER OF\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - last = (Value*)LAST_LIST_ELMT (ac->responderConsumerOf); - FOR_EACH_LIST_ELMT (v, ac->responderConsumerOf) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - } - - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"ABSTRACT SYNTAXES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - - if ((ac->abstractSyntaxes != NULL) && (!LIST_EMPTY (ac->abstractSyntaxes))) - lastOid = (OID*)LAST_LIST_ELMT (ac->abstractSyntaxes); - FOR_EACH_LIST_ELMT (oid, ac->abstractSyntaxes) - { - INDENT (f, indentG); - PrintOid (f, oid); - if (oid != lastOid) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - - indentG -= indentStepG; - -} /* PrintRosAcMacroType */ - - -void -PrintMtsasExtensionsMacroType PARAMS ((f, head, t, bt, exts), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionsMacroType *exts) -{ - Value *v; - Value *last; - - fprintf (f, "EXTENSIONS CHOSEN FROM"); - - INDENT (f, indentG); - fprintf (f, "{\n"); - - indentG += indentStepG; - if ((exts->extensions == NULL) && (!LIST_EMPTY (exts->extensions))) - last = (Value*)LAST_LIST_ELMT (exts->extensions); - FOR_EACH_LIST_ELMT (v, exts->extensions) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, v); - if (v != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - -} /* PrintMtsasExtensionsMacroType */ - - -void -PrintMtsasExtensionMacroType PARAMS ((f, head, t, bt, ext), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionMacroType *ext) -{ - - fprintf (f, "EXTENSION"); - - indentG += indentStepG; - if (ext->elmtType != NULL) - { - fprintf (f, "\n"); - INDENT (f, indentG); - PrintElmtType (f, head, t, ext->elmtType); - - if (ext->defaultValue != NULL) - { - fprintf (f, " DEFAULT "); - PrintValue (f, NULL, t, ext->defaultValue); - } - } - - if ((ext->criticalForSubmission != NULL) || - (ext->criticalForTransfer != NULL) || - (ext->criticalForDelivery != NULL)) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "CRITICAL FOR "); - - if (ext->criticalForSubmission != NULL) - { - fprintf (f, "SUBMISSION"); - if ((ext->criticalForTransfer != NULL) || - (ext->criticalForDelivery != NULL)) - fprintf (f,", "); - } - - if (ext->criticalForTransfer != NULL) - { - fprintf (f, "TRANSFER, "); - if (ext->criticalForDelivery != NULL) - fprintf (f,", "); - } - - if (ext->criticalForDelivery != NULL) - fprintf (f, "DELIVERY"); - - } - - indentG -= indentStepG; - -} /* PrintMtsasExtensionMacroType */ - - - - -void -PrintMtsasExtensionAttributeMacroType PARAMS ((f, head, t, bt, ext), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasExtensionAttributeMacroType *ext) -{ - - fprintf (f, "EXTENSION-ATTRIBUTE"); - if (ext->type != NULL) - { - fprintf (f, "\n"); - indentG += indentStepG; - INDENT (f, indentG); - - PrintType (f, head, ext->type); - indentG -= indentStepG; - } - -} /* PrintMtsasExtensionAttributeMacroType */ - - - -void -PrintMtsasTokenMacroType PARAMS ((f, head, t, bt, tok), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenMacroType *tok) -{ - - fprintf (f, "TOKEN"); - if (tok->type != NULL) - { - fprintf (f, "\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintType (f, head, tok->type); - indentG -= indentStepG; - } - -} /* PrintMtsasTokenMacro */ - - -void -PrintMtsasTokenDataMacroType PARAMS ((f, head, t, bt, tok), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasTokenDataMacroType *tok) -{ - - fprintf (f, "TOKEN-DATA"); - if (tok->type != NULL) - { - fprintf (f, "\n"); - indentG += indentStepG; - INDENT (f, indentG); - - PrintType (f, head, tok->type); - indentG -= indentStepG; - } - -} /* PrintMtsasTokenDataMacro */ - - -void -PrintMtsasSecurityCategoryMacroType PARAMS ((f, head, t, bt, sec), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - MtsasSecurityCategoryMacroType *sec) -{ - - fprintf (f, "SECURITY-CATEGORY"); - if (sec->type != NULL) - { - fprintf (f, "\n"); - indentG += indentStepG; - INDENT (f, indentG); - - PrintType (f, head, sec->type); - indentG -= indentStepG; - } - -} /* PrintMtsasSecurityCategoryMacroType */ - - - -void -PrintAsnObjectMacroType PARAMS ((f, head, t, bt, obj), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnObjectMacroType *obj) -{ - AsnPort *ap; - AsnPort *last; - - fprintf (f, "OBJECT"); - - indentG += indentStepG; - - if ((obj->ports != NULL) && !LIST_EMPTY (obj->ports)) - { - - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "PORTS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (AsnPort*)LAST_LIST_ELMT (obj->ports); - FOR_EACH_LIST_ELMT (ap, obj->ports) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, ap->portValue); - - if (ap->portType == CONSUMER_PORT) - fprintf (f, " [C]"); - else if (ap->portType == SUPPLIER_PORT) - fprintf (f, " [S]"); - - if (ap != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - indentG -= indentStepG; - -} /* PrintAsnObjectMacroType */ - - - -void -PrintAsnPortMacroType PARAMS ((f, head, t, bt, p), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnPortMacroType *p) -{ - TypeOrValue *tOrV; - TypeOrValue *last; - - fprintf (f, "PORT"); - indentG += indentStepG; - if ((p->abstractOps != NULL) && (!LIST_EMPTY (p->abstractOps))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "ABSTRACT OPERATIONS\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (p->abstractOps); - FOR_EACH_LIST_ELMT (tOrV, p->abstractOps) - { - INDENT (f, indentG); - - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((p->consumerInvokes != NULL) && (!LIST_EMPTY (p->consumerInvokes))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "CONSUMER INVOKES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (p->consumerInvokes); - FOR_EACH_LIST_ELMT (tOrV, p->consumerInvokes) - { - INDENT (f, indentG); - - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if ((p->supplierInvokes != NULL) && (!LIST_EMPTY (p->supplierInvokes))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f, "SUPPLIER INVOKES\n"); - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (TypeOrValue*)LAST_LIST_ELMT (p->supplierInvokes); - FOR_EACH_LIST_ELMT (tOrV, p->supplierInvokes) - - { - INDENT (f, indentG); - - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - indentG -= indentStepG; - -} /* PrintAsnPortMacroType */ - - - - -void -PrintAsnAbstractBindMacroType PARAMS ((f, head, t, bt, bind), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - AsnAbstractBindMacroType *bind) -{ - AsnPort *ap; - AsnPort *last; - - if (bt->a.macroType->choiceId == MACROTYPE_ASNABSTRACTBIND) - fprintf (f, "ABSTRACT-BIND"); - else - fprintf (f, "ABSTRACT-UNBIND"); - - indentG += indentStepG; - - if ((bind->ports != NULL) && (!LIST_EMPTY (bind->ports))) - { - fprintf (f,"\n"); - INDENT (f, indentG); - if (bt->a.macroType->choiceId == MACROTYPE_ASNABSTRACTBIND) - fprintf (f, "TO\n"); - else - fprintf (f, "FROM\n"); - - INDENT (f, indentG); - fprintf (f, "{\n"); - indentG += indentStepG; - - last = (AsnPort*)LAST_LIST_ELMT (bind->ports); - FOR_EACH_LIST_ELMT (ap, bind->ports) - { - INDENT (f, indentG); - PrintValue (f, NULL, t, ap->portValue); - - if (ap->portType == CONSUMER_PORT) - fprintf (f, " [C]"); - else if (ap->portType == SUPPLIER_PORT) - fprintf (f, " [S]"); - - if (ap != last) - fprintf (f, ",\n"); - } - - fprintf (f, "\n"); - indentG -= indentStepG; - INDENT (f, indentG); - fprintf (f, "}"); - } - - if (bind->type != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - PrintType (f, head, bind->type); - } - - indentG -= indentStepG; - -} /* PrintAsnAbstractBindMacroType */ - - - -void -PrintAfAlgorithmMacroType PARAMS ((f, head, t, bt, alg), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *alg) -{ - indentG += indentStepG; - fprintf (f, "ALGORITHM PARAMETER "); - PrintType (f, head, alg); - indentG -= indentStepG; -} /* PrintAfAlgorithmMacroType */ - - -void -PrintAfEncryptedMacroType PARAMS ((f, head, t, bt, encrypt), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *encrypt) -{ - indentG += indentStepG; - fprintf (f, "ENCRYPTED "); - PrintType (f, head, encrypt); - indentG -= indentStepG; -} /* PrintAfEncryptedMacroType */ - - -void -PrintAfSignedMacroType PARAMS ((f, head, t, bt, sign), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *sign) -{ - indentG += indentStepG; - fprintf (f, "SIGNED "); - PrintType (f, head, sign); - indentG -= indentStepG; -} /* PrintAfSignedMacroType */ - - -void -PrintAfSignatureMacroType PARAMS ((f, head, t, bt, sig), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *sig) -{ - indentG += indentStepG; - fprintf (f, "SIGNATURE "); - PrintType (f, head, sig); - indentG -= indentStepG; -} /* PrintAfSignatureMacroType */ - - -void -PrintAfProtectedMacroType PARAMS ((f, head, t, bt, p), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - Type *p) -{ - indentG += indentStepG; - fprintf (f, "PROTECTED "); - PrintType (f, head, p); - indentG -= indentStepG; -} /* PrintAfMacroType */ - - -void -PrintSnmpObjectTypeMacroType PARAMS ((f, head, t, bt, ot), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt _AND_ - SnmpObjectTypeMacroType *ot) -{ - TypeOrValue *tOrV; - TypeOrValue *last; - - fprintf (f, "OBJECT-TYPE\n"); - indentG += indentStepG; - INDENT (f,indentG); - fprintf (f,"SYNTAX "); - indentG += indentStepG; - PrintType (f, head, ot->syntax); - indentG -= indentStepG; - - fprintf (f,"\n"); - INDENT (f,indentG); - fprintf (f,"ACCESS "); - switch (ot->access) - { - case SNMP_READ_ONLY: - fprintf (f,"read-only"); - break; - - case SNMP_READ_WRITE: - fprintf (f,"read-write"); - break; - - case SNMP_WRITE_ONLY: - fprintf (f,"write-only"); - break; - - case SNMP_NOT_ACCESSIBLE: - fprintf (f,"not-accessible"); - break; - - default: - fprintf (f," < ?? unknown access type ?? >"); - } - - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"STATUS "); - switch (ot->status) - { - case SNMP_MANDATORY: - fprintf (f,"mandatory"); - break; - - case SNMP_OPTIONAL: - fprintf (f,"optional"); - break; - - case SNMP_OBSOLETE: - fprintf (f,"obsolete"); - break; - - case SNMP_DEPRECATED: - fprintf (f,"deprecated"); - break; - - default: - fprintf (f," < ?? unknown status type ?? >"); - } - - if (ot->description != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"DESCRIPTION\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintValue (f, NULL, t, ot->description); - indentG -= indentStepG; - } - - if (ot->reference != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"REFERENCE\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintValue (f, NULL, t, ot->reference); - indentG -= indentStepG; - } - - if (ot->index != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"INDEX\n"); - indentG += indentStepG; - INDENT (f, indentG); - last = (TypeOrValue*)LAST_LIST_ELMT (ot->index); - FOR_EACH_LIST_ELMT (tOrV, ot->index) - { - INDENT (f, indentG); - if (tOrV->choiceId == TYPEORVALUE_TYPE) - PrintType (f, head, tOrV->a.type); - else - PrintValue (f, NULL, t, tOrV->a.value); - - if (tOrV != last) - fprintf (f, ",\n"); - } - indentG -= indentStepG; - } - - if (ot->defVal != NULL) - { - fprintf (f,"\n"); - INDENT (f, indentG); - fprintf (f,"DEFVAL\n"); - indentG += indentStepG; - INDENT (f, indentG); - PrintValue (f, NULL, t, ot->defVal); - indentG -= indentStepG; - } - - fprintf (f,"\n"); - - indentG -= indentStepG; -} /* PrintSnmpObjectTypeMacroType */ - - -/* - * @MACRO@ add new macro print routines above this point - */ - -void -PrintMacroDef PARAMS ((f, head), - FILE *f _AND_ - TypeDef *head) -{ - char *s; - - fprintf (f,"\n-- Note: snacc does not use macro defs to extend the compiler."); - fprintf (f,"\n-- All macros that are understood have been hand coded."); - fprintf (f,"\n-- The macro def body is kept as a string only.\n\n"); - - s = head->type->basicType->a.macroDef; - - fprintf (f, "%s MACRO ::=\n", head->definedName); - fprintf (f, "%s", s); - -} /* PrintMacroDef */ - - - -void -PrintEncodedOid PARAMS ((f, eoid), - FILE *f _AND_ - AsnOid *eoid) -{ - int i; - int arcNum; - int firstArcNum; - int secondArcNum; - - if (eoid == NULL) - return; - - fprintf (f, "{ "); - - for (arcNum = 0, i=0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - i++; - - firstArcNum = arcNum / 40; - if (firstArcNum > 2) - firstArcNum = 2; - - secondArcNum = arcNum - (firstArcNum * 40); - - fprintf (f, "%d ", firstArcNum); - fprintf (f, "%d ", secondArcNum); - for (; i < eoid->octetLen; ) - { - for (arcNum = 0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++) - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - - arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f); - i++; - - fprintf (f, "%d ", arcNum); - } - - fprintf (f, "}"); - -} /* PrintEncodedOid */ - - - -/* - * this just prints a short form of the given type. It - * does not print the components of a constructed type - * such as a SEQUENCE - * This is used by the header file generators to annotate - * the C/C++ types - */ -void -SpecialPrintBasicType PARAMS ((f, head, t, bt), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t _AND_ - BasicType *bt) -{ - switch (bt->choiceId) - { - - case BASICTYPE_SEQUENCE: - fprintf (f, "SEQUENCE"); - break; - - case BASICTYPE_SET: - fprintf (f, "SET"); - break; - - case BASICTYPE_CHOICE: - fprintf (f, "CHOICE"); - break; - - - - case BASICTYPE_SEQUENCEOF: - fprintf (f, "SEQUENCE "); - if (t->subtypes != NULL) - { - PrintSubtype (f, head, t, t->subtypes); - fprintf (f," "); - } - fprintf (f, "OF "); - SpecialPrintType (f, head, t->basicType->a.sequenceOf); - break; - - case BASICTYPE_SETOF: - fprintf (f, "SET "); - if (t->subtypes != NULL) - { - PrintSubtype (f, head, t, t->subtypes); - fprintf (f," "); - } - fprintf (f, "OF "); - SpecialPrintType (f, head, t->basicType->a.sequenceOf); - break; - - - case BASICTYPE_SELECTION: - fprintf (f, "%s < ", bt->a.selection->fieldName); - PrintType (f, head, bt->a.selection->typeRef); - break; - - - - - case BASICTYPE_COMPONENTSOF: - fprintf (f, "COMPONENTS OF "); - PrintType (f, NULL, bt->a.componentsOf); - break; - - - - case BASICTYPE_ANYDEFINEDBY: - fprintf (f, "ANY DEFINED BY %s", bt->a.anyDefinedBy->fieldName); - break; - - - case BASICTYPE_LOCALTYPEREF: - fprintf (f, "%s", bt->a.localTypeRef->typeName); - break; - - case BASICTYPE_IMPORTTYPEREF: - fprintf (f, "%s", bt->a.importTypeRef->typeName); - break; - - - case BASICTYPE_UNKNOWN: - fprintf (f, "unknown type !?!"); - break; - - case BASICTYPE_BOOLEAN: - fprintf (f, "BOOLEAN"); - break; - - - case BASICTYPE_INTEGER: - fprintf (f, "INTEGER"); - if ((bt->a.integer != NULL) && !LIST_EMPTY (bt->a.integer)) - SpecialPrintNamedElmts (f, head, t); - break; - - - case BASICTYPE_BITSTRING: - fprintf (f, "BIT STRING"); - if ((bt->a.bitString != NULL) && !LIST_EMPTY (bt->a.bitString)) - SpecialPrintNamedElmts (f, head, t); - break; - - case BASICTYPE_OCTETSTRING: - fprintf (f, "OCTET STRING"); - break; - - case BASICTYPE_NULL: - fprintf (f, "NULL"); - break; - - case BASICTYPE_OID: - fprintf (f, "OBJECT IDENTIFIER"); - break; - - case BASICTYPE_REAL: - fprintf (f, "REAL"); - break; - - case BASICTYPE_ENUMERATED: - fprintf (f, "ENUMERATED"); - if ((bt->a.enumerated != NULL) && !LIST_EMPTY (bt->a.enumerated)) - SpecialPrintNamedElmts (f, head, t); - - break; - - case BASICTYPE_ANY: - fprintf (f, "ANY"); - break; - - case BASICTYPE_MACROTYPE: - switch (bt->a.macroType->choiceId) - { - case MACROTYPE_ROSOPERATION: - case MACROTYPE_ASNABSTRACTOPERATION: - PrintRosOperationMacroType (f, head, t, bt, bt->a.macroType->a.rosOperation); - break; - - case MACROTYPE_ROSERROR: - case MACROTYPE_ASNABSTRACTERROR: - PrintRosErrorMacroType (f, head, t, bt, bt->a.macroType->a.rosError); - break; - - case MACROTYPE_ROSBIND: - case MACROTYPE_ROSUNBIND: - PrintRosBindMacroType (f, head, t, bt, bt->a.macroType->a.rosBind); - break; - - case MACROTYPE_ROSASE: - PrintRosAseMacroType (f, head, t, bt, bt->a.macroType->a.rosAse); - break; - - case MACROTYPE_MTSASEXTENSIONS: - PrintMtsasExtensionsMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensions); - break; - - case MACROTYPE_MTSASEXTENSION: - PrintMtsasExtensionMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtension); - break; - - case MACROTYPE_MTSASEXTENSIONATTRIBUTE: - PrintMtsasExtensionAttributeMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensionAttribute); - break; - - case MACROTYPE_MTSASTOKEN: - PrintMtsasTokenMacroType (f, head, t, bt, bt->a.macroType->a.mtsasToken); - break; - - case MACROTYPE_MTSASTOKENDATA: - PrintMtsasTokenDataMacroType (f, head, t, bt, bt->a.macroType->a.mtsasTokenData); - break; - - case MACROTYPE_MTSASSECURITYCATEGORY: - PrintMtsasSecurityCategoryMacroType (f, head, t, bt, bt->a.macroType->a.mtsasSecurityCategory); - break; - - case MACROTYPE_ASNOBJECT: - PrintAsnObjectMacroType (f, head, t, bt, bt->a.macroType->a.asnObject); - break; - - case MACROTYPE_ASNPORT: - PrintAsnPortMacroType (f, head, t, bt, bt->a.macroType->a.asnPort); - break; - - case MACROTYPE_ASNABSTRACTBIND: - case MACROTYPE_ASNABSTRACTUNBIND: - PrintAsnAbstractBindMacroType (f, head, t, bt, bt->a.macroType->a.asnAbstractBind); - break; - - case MACROTYPE_AFALGORITHM: - PrintAfAlgorithmMacroType (f, head, t, bt, bt->a.macroType->a.afAlgorithm); - break; - - case MACROTYPE_AFENCRYPTED: - PrintAfEncryptedMacroType (f, head, t, bt, bt->a.macroType->a.afEncrypted); - break; - - case MACROTYPE_AFSIGNED: - PrintAfSignedMacroType (f, head, t, bt, bt->a.macroType->a.afSigned); - break; - - case MACROTYPE_AFSIGNATURE: - PrintAfSignatureMacroType (f, head, t, bt, bt->a.macroType->a.afSignature); - break; - - case MACROTYPE_AFPROTECTED: - PrintAfProtectedMacroType (f, head, t, bt, bt->a.macroType->a.afProtected); - break; - - case MACROTYPE_SNMPOBJECTTYPE: - PrintSnmpObjectTypeMacroType (f, head, t, bt, bt->a.macroType->a.snmpObjectType); - break; - - default: - fprintf (f, "< unknown macro type id ?! >"); - - } /* end macro type switch */ - break; - - /* - * @MACRO@ add new macro printers above this point - */ - - case BASICTYPE_MACRODEF: - /* - * printing this should be handled in PrintTypeDefs - */ - break; - - - default: - fprintf (f, "< unknown type id ?! >"); - - } -} /* SpecialPrintBasicType */ - - -/* - * this just prints a short form of the given type. It - * does not print the components of a constructed type - * such as a SEQUENCE - * This is used by the header file generators to annotate - * the C types - */ -void -SpecialPrintType PARAMS ((f, head, t), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t) -{ - Tag *tag; - Tag *lastTag; - - if (t == NULL) - return; - - lastTag = NULL; - FOR_EACH_LIST_ELMT (tag, t->tags) - { - if (!(tag->tclass == UNIV && tag->code == LIBTYPE_GET_UNIV_TAG_CODE (t->basicType->choiceId))) - { - PrintTag (f, tag); - fprintf (f, " "); - } - lastTag = tag; - } - - /* - * check type has been implicitly tagged - */ - if (t->implicit) - fprintf (f, "IMPLICIT "); - - SpecialPrintBasicType (f, head, t, t->basicType); - - - /* - * sequences of and set of print subtypes a special way - * so ignore them here - */ - if ((t->subtypes != NULL) && - (t->basicType->choiceId != BASICTYPE_SETOF) && - (t->basicType->choiceId != BASICTYPE_SEQUENCEOF)) - { - fprintf (f," "); - PrintSubtype (f, head, t, t->subtypes); - } - - - if (t->defaultVal != NULL) - { - fprintf (f, " DEFAULT "); - if (t->defaultVal->fieldName != NULL) - fprintf (f, "%s ", t->defaultVal->fieldName); - PrintValue (f, NULL, t, t->defaultVal->value); - } - - else if (t->optional) - fprintf (f, " OPTIONAL"); - - -#ifdef DEBUG - fprintf (f, " -- lineNo = %d", t->lineNo); - fprintf (f, " --"); -#endif - -} /* SpecialPrintType */ - - -/* - * This is used by the header file generators to annotate - * the C/C++ types. This version prints the C version of the - * enum/bits elmt names to make sure the programmer can use - * the correct defines/enum constants. - * NOTE: this can only be called after the CTRI infor is filled in - * so the C/C++ names can be accessed - */ -void -SpecialPrintNamedElmts PARAMS ((f, head, t), - FILE *f _AND_ - TypeDef *head _AND_ - Type *t) -{ - CNamedElmt *last; - CNamedElmt *cne; - CNamedElmts *n = NULL; - - if (t->cTypeRefInfo != NULL) - n = t->cTypeRefInfo->cNamedElmts; - - if ((n == NULL) && (t->cxxTypeRefInfo != NULL)) - n = t->cxxTypeRefInfo->namedElmts; - - - if ((n == NULL) || LIST_EMPTY (n)) - return; - - fprintf (f," { "); - last = (CNamedElmt*)LAST_LIST_ELMT (n); - FOR_EACH_LIST_ELMT (cne, n) - { - fprintf (f, "%s (%d)", cne->name, cne->value); - if (cne != last) - fprintf (f,", "); - } - fprintf (f," } "); -} /* SpecialPrintNamedElmts */ diff --git a/SecuritySNACCRuntime/compiler/core/recursive.c b/SecuritySNACCRuntime/compiler/core/recursive.c deleted file mode 100644 index aae1c9ee..00000000 --- a/SecuritySNACCRuntime/compiler/core/recursive.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * compiler/core/recursive.c - finds and marks the recursive types in a module. - * - * ALSO: - * prints msgs for infinitely recursive types (ie recursive component - * is not OPTIONAL, nor a CHOICE elmt, nor a SET OF nor a SEQ OF elmt. - * (OPTIONALs can be left out, CHOICE elements have alternatives (hopefully), - * and SET OF and SEQUENCE OF values can have zero elements) - * - * prints msg for recursive types that hold no real information - * Foo ::= SET OF Foo (sets of sets of .... of empty sets) - * - * finds bogus recursive types (hold no info) (same as above) - * A ::= B - * B ::= C - * D ::= A - * - * MS 92 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/recursive.c,v 1.1 2001/06/20 21:27:58 dmitch Exp $ - * $Log: recursive.c,v $ - * Revision 1.1 2001/06/20 21:27:58 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:43 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:43:10 rj - * snacc_config.h removed; recursive.h includet. - * - * Revision 1.1 1994/08/28 09:49:35 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "recursive.h" -#include "snacc-util.h" - -void MkRecTypeDef PROTO ((Module *m, TypeDef *td)); - -void MkRecType PROTO ((Module *m, TypeDef *td,Type *t, int optional, int empty)); - - -void -MarkRecursiveTypes PARAMS ((m), - Module *m) -{ - TypeDef *td; - - /* first set all typedef as un-visited */ - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - td->visited = FALSE; - td->tmpRefCount = 0; - } - - FOR_EACH_LIST_ELMT (td, m->typeDefs) - { - MkRecTypeDef (m, td); - } -} /* MarkRecursiveTypes */ - - - -void -MkRecTypeDef PARAMS ((m, td), - Module *m _AND_ - TypeDef *td) -{ - MkRecType (m, td, td->type, 0, 1); -} /* MkRecTypeDef */ - - - -/* - * cruise through aggregate types and type refs looking for - * a type ref to the original type def, td. If is a ref to - * the td, then mark the td as recusive. - * - * the optional flag is set if the current type branch is - * optional via an OPTIONAL SET/SEQ elmt, CHOICE elmt, SET OF elmt - * or SEQ OF elmt. - * - * the empty flag is initially TRUE and remains true until a - * non-type reference type is encountered - */ -void -MkRecType PARAMS ((m, td, t, optional, empty), - Module *m _AND_ - TypeDef *td _AND_ - Type *t _AND_ - int optional _AND_ - int empty) -{ - int newOptional; - NamedType *e; - - switch (t->basicType->choiceId) - { - case BASICTYPE_CHOICE: - if (AsnListCount (t->basicType->a.choice) > 1) - { - empty = 0; - optional = 1; - } - FOR_EACH_LIST_ELMT (e, t->basicType->a.choice) - { - MkRecType (m, td, e->type, optional, empty); - } - break; - - case BASICTYPE_SET: - case BASICTYPE_SEQUENCE: - empty = 0; - - FOR_EACH_LIST_ELMT (e, t->basicType->a.set) - { - newOptional = optional || (e->type->optional) || - (e->type->defaultVal != NULL); - MkRecType (m, td, e->type, newOptional, empty); - } - break; - - case BASICTYPE_SETOF: - case BASICTYPE_SEQUENCEOF: - empty = 0; /* since an empty set is actual data */ - optional = 1; /* since SET OF and SEQ OF's can be empty */ - MkRecType (m, td, t->basicType->a.setOf, optional, empty); - break; - - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_IMPORTTYPEREF: - - /* - * check if ref to original type def & mark recursive if so. - */ -/* if ((strcmp (t->basicType->a.localTypeRef->typeName, td->definedName) == 0) && (t->basicType->a.localTypeRef->module == m)) - easier to just check ptrs! -*/ - if (t->basicType->a.localTypeRef->link == td) - { - td->recursive = 1; - if (empty) - { - PrintErrLoc (m->asn1SrcFileName, td->type->lineNo); - fprintf (stderr,"WARNING: Type \"%s\" appears to be infinitely recursive and can hold no values! (circular type references)\n", td->definedName); - } - else if (!optional) - { - PrintErrLoc (m->asn1SrcFileName, t->lineNo); - fprintf (stderr,"WARNING: Type \"%s\" appears to be infinitely recursive! (infinitely sized values)\n", td->definedName); - } - } - - /* - * else follow this type reference if we aren't in it already - * (ie another recursive type in td) - */ - else if (t->basicType->a.localTypeRef->link->tmpRefCount == 0) - { - /* - * mark this typedef as 'entered' to - * detect when looping in a recusive type that is contained - * in the original td (use tmpRefCount) - */ - t->basicType->a.localTypeRef->link->tmpRefCount = 1; - - newOptional = optional || (t->optional) || (t->defaultVal != NULL); - MkRecType (m, td, t->basicType->a.localTypeRef->link->type, newOptional, empty); - - /* - * un-mark this type since finished with it - * for recursive ref's to td - */ - t->basicType->a.localTypeRef->link->tmpRefCount = 0; - } - break; - - /* - * default: other types are not aggregate and - * do not make recursive refs - they can be ignored - */ - } -} /* MkRecType */ diff --git a/SecuritySNACCRuntime/compiler/core/recursive.h b/SecuritySNACCRuntime/compiler/core/recursive.h deleted file mode 100644 index f549e8d5..00000000 --- a/SecuritySNACCRuntime/compiler/core/recursive.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * compiler/core/recursive.h - find and mark the recursive types in a module - * - * MS 92 - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/recursive.h,v 1.1 2001/06/20 21:27:59 dmitch Exp $ - * $Log: recursive.h,v $ - * Revision 1.1 2001/06/20 21:27:59 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.2 1994/10/08 03:48:57 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * Revision 1.1 1994/08/28 09:49:36 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -void MarkRecursiveTypes PROTO ((Module *m)); diff --git a/SecuritySNACCRuntime/compiler/core/snacc-util.c b/SecuritySNACCRuntime/compiler/core/snacc-util.c deleted file mode 100644 index b44f6719..00000000 --- a/SecuritySNACCRuntime/compiler/core/snacc-util.c +++ /dev/null @@ -1,1334 +0,0 @@ -/* - * compiler/core/snacc_util.c - * - * utilities for dealing with the Module data structure - * - * AUTHOR: Mike Sample - * DATE: 91/09/02 - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/snacc-util.c,v 1.1 2001/06/20 21:27:59 dmitch Exp $ - * $Log: snacc-util.c,v $ - * Revision 1.1 2001/06/20 21:27:59 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:44 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:45:09 rj - * snacc_config.h removed. - * - * Revision 1.1 1994/08/28 09:49:39 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#include - -#include "asn-incl.h" -#include "mem.h" -#include "asn1module.h" -#include "lib-types.h" -#include "define.h" -#include "snacc-util.h" - - - -/* - * Allocates and initializes a type and it's basicType info - * used extensively by asn1.yacc - * (was a macro) - */ -void -SetupType PARAMS ((t, typeId, lineNum), - Type **t _AND_ - enum BasicTypeChoiceId typeId _AND_ - unsigned long lineNum) -{ - Tag **tmpPtr; - - (*t) = (Type*)Malloc (sizeof (Type)); - (*t)->lineNo = lineNum; - (*t)->basicType = (BasicType*)Malloc (sizeof (BasicType)); - (*t)->basicType->choiceId = typeId; - (*t)->tags = (TagList*)AsnListNew (sizeof (void*)); - if (LIBTYPE_GET_UNIV_TAG_CODE ((typeId)) != NO_TAG_CODE) - { - tmpPtr = (Tag**)AsnListAppend ((AsnList*)(*t)->tags); - *tmpPtr = (Tag*)Malloc (sizeof (Tag)); - (*tmpPtr)->tclass = UNIV; - (*tmpPtr)->code = LIBTYPE_GET_UNIV_TAG_CODE ((typeId)); - } -} /* SetupType */ - - -/* - * Allocates and initializes a type and it's basicType to MACROTYPE - * and sets the MACROTYPE type to the given macrotype - */ -void -SetupMacroType PARAMS ((t, macroTypeId, lineNum), - Type **t _AND_ - enum MacroTypeChoiceId macroTypeId _AND_ - unsigned long lineNum) -{ - Tag **tmpPtr; - - (*t) = MT (Type); - (*t)->lineNo = lineNum; - (*t)->basicType = MT (BasicType); - (*t)->basicType->choiceId = BASICTYPE_MACROTYPE; - (*t)->tags = (TagList*)AsnListNew (sizeof (void*)); - (*t)->basicType->a.macroType = MT (MacroType); - (*t)->basicType->a.macroType->choiceId = macroTypeId; -} /* SetupMacroType */ - - -/* - * similar to SetupType but for values instead - */ -void -SetupValue PARAMS ((v, valId, lineNum), - Value **v _AND_ - enum BasicValueChoiceId valId _AND_ - unsigned long lineNum) -{ - *v = (Value*)Malloc (sizeof (Value)); - (*v)->basicValue = (BasicValue*)Malloc (sizeof (BasicValue)); - (*v)->basicValue->choiceId = valId; - (*v)->lineNo = lineNum; -} /* SetupValue */ - - -/* - * adds elmt with given name to module m's import list from - * the module with name refdModuleName. If module m does not - * have an import list from that module one is created. - * The import element is given the private scope implied - * by the ASN.1 modname.typ-or-val-name reference format - * The passed in strings (name, refdModuleName) are copied. - */ -void -AddPrivateImportElmt PARAMS ((m, name, refdModuleName, lineNo), - Module *m _AND_ - char *name _AND_ - char *refdModuleName _AND_ - long int lineNo) -{ - ImportElmt *newElmt; - ImportElmt *ie; - ImportModule *impMod; - - - /* see if module m already imports something from "refdModule" */ - if ((impMod = LookupImportModule (m, refdModuleName)) == NULL) - { - impMod = MT (ImportModule); - impMod->modId = MT (ModuleId); - impMod->modId->name = Malloc (strlen (refdModuleName)+1); - strcpy (impMod->modId->name, refdModuleName); - - newElmt = MT (ImportElmt); - newElmt->name = Malloc (strlen (name)+1); - strcpy (newElmt->name, name); - newElmt->privateScope = TRUE; - - APPEND (newElmt, impMod->importElmts); - APPEND (impMod, m->imports); - } - else /* module "refdModule is already imported from */ - { - ie = LookupImportElmtInImportElmtList (impMod->importElmts, name); - - if (ie == NULL) - { - newElmt = MT (ImportElmt); - newElmt->name = Malloc (strlen (name)+1); - strcpy (newElmt->name, name); - APPEND (newElmt, impMod->importElmts); - } - else if (!ie->privateScope) - { - PrintErrLoc (m->asn1SrcFileName, lineNo); - fprintf (stderr, "WARNING - \"%s.%s\" type/value reference refers to a type/value already in the import list that does not have private scope.\n", refdModuleName, name); - } - } -} /* AddPrivateImportElmt */ - -/* - * looks for the named import type/value in all of the IMPORT lists of the - * given module. - * RETURNS a ptr to the import elmt if found, NULL if it was not found. - * If the item was found (ptr returned) the foundImportModule addr - * parameter will be set to the module's importModule that holds - * the found elmt. - * - * returns NULL if the named import name was not found - * - */ -ImportElmt* -LookupImportElmtInModule PARAMS ((m, name, foundImportModule), - Module *m _AND_ - char *name _AND_ - ImportModule **foundImportModule) -{ - ImportModule *importMod; - ImportElmt *importElmt; - ImportElmt *retVal; - void *tmp; - - if (m->imports == NULL) - return NULL; - - tmp = (void*)CURR_LIST_NODE (m->imports); - retVal = NULL; - FOR_EACH_LIST_ELMT (importMod, m->imports) - { - importElmt = LookupImportElmtInImportElmtList (importMod->importElmts, name); - if (importElmt != NULL) - { - *foundImportModule = importMod; - retVal = importElmt; - break; - } - } - - SET_CURR_LIST_NODE (m->imports, tmp); /* restore orig loc */ - return retVal; - -} /* LookupImportElmtInModule */ - - -/* - * given a list of import elmts, returns ptr to the elmt with - * the matching name. NULL if not found - */ -ImportElmt* -LookupImportElmtInImportElmtList PARAMS ((impElmtList, name), - ImportElmtList *impElmtList _AND_ - char *name) - -{ - ImportElmt *impElmt; - ImportElmt *retVal; - void *tmp; - - if (impElmtList == NULL) - return NULL; - - tmp = (void*) CURR_LIST_NODE (impElmtList); - retVal = NULL; - FOR_EACH_LIST_ELMT (impElmt, impElmtList) - { - if (strcmp (impElmt->name, name) == 0) - { - retVal = impElmt; - break; - } - } - - SET_CURR_LIST_NODE (impElmtList, tmp); - return retVal; - -} /* LookupImportElmtInImportElmtList */ - - - - -/* - * looks for an import list that imports from "importModuleName" - * module in the given module. - * - * returns a ptr to the ImportList if found - * returns NULL if not found - */ -ImportModule* -LookupImportModule PARAMS ((m, importModuleName), - Module *m _AND_ - char *importModuleName) -{ - ImportModule *importModule; - ImportModule *retVal; - void *tmp; - - if (m->imports == NULL) - return NULL; - - tmp = (void*)CURR_LIST_NODE (m->imports); - retVal = NULL; - FOR_EACH_LIST_ELMT (importModule, m->imports) - { - if (strcmp (importModule->modId->name, importModuleName) == 0) - { - retVal= importModule; - break; - } - } - - SET_CURR_LIST_NODE (m->imports, tmp); - return retVal; - -} /* LookupImportModule */ - - - - -/* - * Looks for the type with name matching typeName (null terminated char*) - * in the given the TypeDef list - * - * RETURNS: ptr to the TypeDef with the matching typeName (if any) - * NULL if no match was made - */ -TypeDef* -LookupType PARAMS ((typeDefList, typeName), - TypeDefList *typeDefList _AND_ - char *typeName) -{ - TypeDef *td; - TypeDef *retVal; - void *tmp; - - if (typeDefList == NULL) - return NULL; - - if (typeName == NULL) - { -#ifdef DEBUG - fprintf (stderr,"LookupType: warning - failure due to NULL key\n"); -#endif - return NULL; - } - - tmp = (void*)CURR_LIST_NODE (typeDefList); /* remember curr list spot */ - retVal = NULL; - FOR_EACH_LIST_ELMT (td, typeDefList) - { - if (strcmp (typeName, td->definedName) == 0) - { - retVal = td; - break; - } - } - - SET_CURR_LIST_NODE (typeDefList,tmp); /* restore curr location */ - - return retVal; - -} /* LookupType */ - - -/* - * Returns ptr to module that has matching name or OID - * if oid is not null, lookup done only by oid - * - * returns NULL if no match was found - */ -Module* -LookupModule PARAMS ((moduleList, modName, oid), - ModuleList *moduleList _AND_ - char *modName _AND_ - OID *oid) -{ - Module *currMod; - Module *retVal; - int strMatch = FALSE; - int oidMatch = FALSE; - OID *oid1; - OID *oid2; - void *tmp; - - if ((moduleList == NULL) || ((modName == NULL) && (oid == NULL))) - return NULL; - - tmp = (void*)CURR_LIST_NODE (moduleList); /* remember orig loc */ - retVal = NULL; - FOR_EACH_LIST_ELMT (currMod, moduleList) - { - - /* - * may fail due to unresolved int or oid value ref - * so try name match anyway. - * This is not standard (CCITT) if the oids were resolved - * but different, in which case the match should - * fail regardless of the name match. oh well, ts. - */ - if (CompareOids (oid, currMod->modId->oid)) - { - retVal = currMod; - break; /* exit for loop */ - } - - else if ((modName != NULL) && - (strcmp (modName, currMod->modId->name) == 0)) - { - retVal = currMod; - break; /* exit for loop */ - } - } - - SET_CURR_LIST_NODE (moduleList, tmp); - return retVal; - -} /* LookupModule */ - - - - -/* - * Given a constructed type, it returns the component of that - * type with the matching field name. Returns NULL if teh - * given type does not have the named field or is not - * a type that has fields. - */ -NamedType* -LookupFieldInType PARAMS ((tRef, fieldName), - Type *tRef _AND_ - char *fieldName) -{ - NamedType *e; - NamedType *retVal; - Type *t; - void *tmp; - - t = ParanoidGetType (tRef); /* skip any references etc */ - - if ((t->basicType->choiceId != BASICTYPE_SET) && - (t->basicType->choiceId != BASICTYPE_SEQUENCE) && - (t->basicType->choiceId != BASICTYPE_CHOICE)) - { -#ifdef DEBUG - fprintf (stderr,"LookupFieldInType: ERROR - attempt to look for field in a non SET/SEQ/CHOICE type\n"); -#endif - return NULL; - } - - /* return if null list */ - if (t->basicType->a.set == NULL) - return NULL; - - /* remember set's original curr elmt */ - tmp = (void*)CURR_LIST_NODE (t->basicType->a.set); - retVal = NULL; - FOR_EACH_LIST_ELMT (e, t->basicType->a.set) - { - /* remember fieldname is optional so it can be null */ - if ((e->fieldName != NULL) && (strcmp (e->fieldName, fieldName) == 0)) - { - retVal = e; - break; /* exit for loop */ - } - } - SET_CURR_LIST_NODE (t->basicType->a.set, tmp); - return retVal; - -} /* LookupFieldInType */ - - - -/* - * Goes through typerefs (if any) to get to actual - * ASN1 type. Returns the found "defining" type. - * May return the given type t, if it's not a typeref - * or if it is an unlinked type ref - */ -Type* -GetType PARAMS ((type), - Type *type) -{ - TypeDef *td; - Type *t; - - t = type; - if (t == NULL) - return NULL; - - while (1) - { - switch (t->basicType->choiceId) - { - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_IMPORTTYPEREF: - td = t->basicType->a.localTypeRef->link; - if (td == NULL) - return type; - else - t = td->type; - break; - - default: - return t; - } - } -} /* GetType */ - - -/* - * like GetType ie, skips type references to return the defining type. - * This is a paranoid version - it checks for circular type errors. - * eg: A ::= B - * B ::= A - * would make the normal GetType recurse forever (until no stk mem) - */ -Type* -ParanoidGetType PARAMS ((type), - Type *type) -{ - TypeDef *td; - Type *t; - DefinedObj *l; - - t = type; - if (t == NULL) - return NULL; - - l = NewObjList(); - while (1) - { - switch (t->basicType->choiceId) - { - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_IMPORTTYPEREF: - td = t->basicType->a.localTypeRef->link; - if ((td == NULL) || (ObjIsDefined (l, td->type, ObjPtrCmp))) - { - return type; - } - else - { - t = td->type; - DefineObj (&l, t); - } - break; - - default: - FreeDefinedObjs (&l); - return t; - } - } - -} /* ParnoidGetType */ - - -/* - * Goes through typerefs (if any) to get to actual - * ASN1 basic type (eg int, bool, seq, seq of, set, - * set of, choice, any, etc. - * Returns the typeId of that type, otherwise -1. - */ -enum BasicTypeChoiceId -GetBuiltinType PARAMS ((t), - Type *t) -{ - Type *definingType; - - definingType = GetType (t); - if (definingType != NULL) - return definingType->basicType->choiceId; - else - return -1; - -} /* GetBuiltinType */ - - -/* Paranoid version of GetBuiltinType - * goes through typerefs (if any) to get to actual - * ASN1 basic type (eg int, bool, seq, seq of, set, - * set of, choice, any, etc. - * Returns the typeId of that type, otherwise -1. - */ -enum BasicTypeChoiceId -ParanoidGetBuiltinType PARAMS ((t), - Type *t) -{ - Type *definingType; - - definingType = ParanoidGetType (t); - if (definingType != NULL) - return definingType->basicType->choiceId; - else - return -1; - -} /* GetBuiltinType */ - - - -/* - * Goes through typerefs (if any) to get to - * the namedElmts (if any) associated with the - * given type (INTEGER, ENUMERATED, BITSTRING or - * LOCAL/IMPORT REFS to these types). - * Returns NULL if there are no associated Named Elmts - */ -NamedNumberList* -GetNamedElmts PARAMS ((t), - Type *t) -{ - Type *definingType; - - if (t == NULL) - return NULL; - - definingType = ParanoidGetType (t); - - if (definingType == NULL) - return NULL; - - switch (definingType->basicType->choiceId) - { - case BASICTYPE_INTEGER: - case BASICTYPE_ENUMERATED: - case BASICTYPE_BITSTRING: - return definingType->basicType->a.integer; - - /* - * for non-named elmt types - * just return NULL - */ - default: - return NULL; - } - - /* not reached */ -} /* GetNamedElmts */ - - -/* - * [Same as GetNamedElmts except goes through CHOICEs as well & - * REQUIRES you to deallocate the list (but not its members).] - * This is nec. for CHOICEs that contain INTs etc. with named #'s] - * This is used for value linking. - * - * Goes through typerefs (if any) to get to - * the namedElmts (if any) associated with the - * given type (INTEGER, ENUMERATED, BITSTRING or - * LOCAL/IMPORT REFS to these types). Also returns - * a named element list for CHOICE types that contain - * named elemnts - * Returns an empty list if there are no associated Named Elmts. - * you are responsible for freeing this list. Do not free the list - * elmts - they are part of the types. - */ -NamedNumberList* -GetAllNamedElmts PARAMS ((t), - Type *t) -{ - Type *definingType; - NamedType *nt; - NamedNumberList *retVal; - NamedNumberList *ntElmtList; - ValueDef *nn; /* named number is a valuedef */ - ValueDef **nnHndl; - - retVal = AsnListNew (sizeof (void*)); - - if (t == NULL) - return retVal; - - definingType = ParanoidGetType (t); - - if (definingType == NULL) - return retVal; - - - switch (definingType->basicType->choiceId) - { - case BASICTYPE_INTEGER: - case BASICTYPE_ENUMERATED: - case BASICTYPE_BITSTRING: - /* - * add the named elmts (if any) to the new list - */ - FOR_EACH_LIST_ELMT (nn, definingType->basicType->a.integer) - { - nnHndl = (ValueDef**)AsnListAppend (retVal); - *nnHndl = nn; - } - break; - - /* - * for choices must group all named elmts from choice components - * and return in a list. - */ - case BASICTYPE_CHOICE: - FOR_EACH_LIST_ELMT (nt, definingType->basicType->a.choice) - { - ntElmtList = GetAllNamedElmts (nt->type); - retVal = AsnListConcat (retVal, ntElmtList); - Free (ntElmtList); /* zap now unused list head */ - } - break; - } - return retVal; -} /* GetAllNamedElmts */ - - -/* - * Recursively does pseudo breadth first search from the given ancestor - * looking for the given child node. Returns the direct parent Type - * of the child if found, NULL otherwise. This routine does not follow - * type references. - */ -Type* -GetParent PARAMS ((ancestor, child), - Type *ancestor _AND_ - Type *child) -{ - NamedType *e; - Type *parent; - void *tmp; - - if ((ancestor->basicType->choiceId != BASICTYPE_SET) && - (ancestor->basicType->choiceId != BASICTYPE_SEQUENCE) && - (ancestor->basicType->choiceId != BASICTYPE_CHOICE) && - (ancestor->basicType->choiceId != BASICTYPE_SETOF) && - (ancestor->basicType->choiceId != BASICTYPE_SEQUENCEOF)) - { - return NULL; - } - - if (ancestor->basicType->a.set == NULL) - return NULL; - - if ((ancestor->basicType->choiceId == BASICTYPE_SETOF) || - (ancestor->basicType->choiceId == BASICTYPE_SEQUENCEOF)) - { - if (child == ancestor->basicType->a.setOf) - return ancestor; - else - return GetParent (ancestor->basicType->a.setOf, child); - } - - tmp = (void*)CURR_LIST_NODE (ancestor->basicType->a.set); - /* - * look through direct children of ancestor first - */ - FOR_EACH_LIST_ELMT (e, ancestor->basicType->a.set) - { - if (child == e->type) - { - SET_CURR_LIST_NODE (ancestor->basicType->a.set, tmp); - return ancestor; - } - } - - - /* - * look through grandchildren if not in children - */ - FOR_EACH_LIST_ELMT (e, ancestor->basicType->a.set) - { - if ((parent = GetParent (e->type, child)) != NULL) - { - SET_CURR_LIST_NODE (ancestor->basicType->a.set, tmp); - return parent; - } - } - - SET_CURR_LIST_NODE (ancestor->basicType->a.set, tmp); - return NULL; -} /* GetParent */ - - - -/* - * Looks for the value with the given valueName (null term char*) in the - * given list of ValueDefs - * RETURNS: ptr to ValueDef with matching key (if any) - * NULL if no match was made - */ - -ValueDef* -LookupValue PARAMS ((valueList, valueName), - ValueDefList *valueList _AND_ - char *valueName) -{ - ValueDef *v; - ValueDef *retVal; - void *tmp; - - if (valueName == NULL) - { -#ifdef DEBUG - fprintf (stderr,"LookupType: warning - failure due to NULL key\n"); -#endif - return NULL; - } - - if (valueList == NULL) - return NULL; - - tmp = (void*)CURR_LIST_NODE (valueList); - retVal = NULL; - FOR_EACH_LIST_ELMT (v, valueList) - { - if (strcmp (valueName, v->definedName) == 0) - { - retVal = v; - break; /* exit for loop */ - } - } - - SET_CURR_LIST_NODE (valueList, tmp); - return retVal; - -} /* LookupValue */ - - - -/* - * Goes through valuerefs (if any) to get to actual - * ASN1 value. Analogous to GetType. - */ -Value* -GetValue PARAMS ((v), - Value *v) -{ - ValueDef *vd; - - while (v != NULL) - { - switch (v->basicValue->choiceId) - { - case BASICVALUE_LOCALVALUEREF: - case BASICVALUE_IMPORTVALUEREF: - vd = v->basicValue->a.localValueRef->link; - if (vd == NULL) - v = NULL; - else - v = vd->value; - break; - - default: - return v; - } - } - fprintf (stderr, "GetValue: ERROR - cannot get value for unlinked local/import value refs\n"); - return NULL; - -} /* GetValue */ - - -/* - * Returns TRUE if oid1 and oid2 are identical otherwise FALSE - */ -int -CompareOids PARAMS ((oid1, oid2), - OID *oid1 _AND_ - OID *oid2) -{ - if ((oid1 == NULL) && (oid2 == NULL)) - return FALSE; - - for (; (oid1 != NULL) && (oid2 != NULL); oid1 = oid1->next, oid2 = oid2->next) - { - /* - * fail if value refs have not been resolved or - * no match between arcnums - */ - if ((oid1->arcNum == NULL_OID_ARCNUM) || - (oid2->arcNum == NULL_OID_ARCNUM) || - (oid1->arcNum != oid2->arcNum)) - return FALSE; - - /* - * could check ref'd values for same name - * incase value ref has not been resolved - * and put in arcNum - */ - } - - if ((oid1 == NULL) && (oid2 == NULL)) - return TRUE; - else - return FALSE; - -} /* CompareOids */ - - -/* - * Returns TRUE if the given type is INTEGER, ENUMERATED or - * BIT STRING and it has named elements - * ie Foo ::= INTEGER { one (1), two (2) } would return TRUE - */ -int -HasNamedElmts PARAMS ((t), - Type *t) -{ - return ((t->basicType->choiceId == BASICTYPE_INTEGER) || - (t->basicType->choiceId == BASICTYPE_ENUMERATED) || - (t->basicType->choiceId == BASICTYPE_BITSTRING)) && - (t->basicType->a.integer != NULL) && - !LIST_EMPTY (t->basicType->a.integer); -} /* HasNamedElmts */ - - -/* - * Returns true if the given tag lists are the same - * (assumes value refs have be resolved) - */ -int -TagsAreIdentical PARAMS ((t1, t2), - TagList *t1 _AND_ - TagList *t2) -{ - Tag *tag1; - Tag *tag2; - - /* both lists are empty */ - if (((t1 == NULL) || LIST_EMPTY (t1)) && - ((t2 == NULL) || LIST_EMPTY (t2))) - return TRUE; - - else if ((t1 == NULL) || (t2 == NULL)) - return FALSE; - - else if (LIST_COUNT (t1) == LIST_COUNT (t2)) - { - SET_CURR_LIST_NODE (t2, FIRST_LIST_NODE (t2)); - FOR_EACH_LIST_ELMT (tag1, t1) - { - tag2 = (Tag*) CURR_LIST_ELMT (t2); - if ((tag1->tclass != tag2->tclass) || (tag1->code == tag2->code)) - return FALSE; - SET_CURR_LIST_NODE (t2, NEXT_LIST_NODE (t2)); - } - return TRUE; - } - else - return FALSE; - -} /* TagsAreIdentical */ - - - -/* - * Returns TRUE if the tag currently on the given type has the default - * tag specified in the type tbl. otherwise returns FALSE. - */ -int -HasDefaultTag PARAMS ((t), - Type *t) -{ - Tag *firstTag = NULL; - int dfltCode; - int dfltClass; - - dfltClass = UNIV; - dfltCode = LIBTYPE_GET_UNIV_TAG_CODE (t->basicType->choiceId); - if ((t->tags != NULL) && !LIST_EMPTY (t->tags)) - firstTag = (Tag*)FIRST_LIST_ELMT (t->tags); - - return ((firstTag != NULL) && (LIST_COUNT (t->tags) == 1) && - (firstTag->tclass == dfltClass) && (firstTag->code == dfltCode)) || - ((firstTag == NULL) && (dfltCode == NO_TAG_CODE)); - -} /* HasDefaultTag */ - - -/* - * Returns TRUE if t is a primitive type or if it is - * defined by a reference to a primitive type - */ -int -IsPrimitiveByDefOrRef PARAMS ((t), - Type *t) -{ - Type *definingType; - - definingType = GetType (t); - - if (definingType == NULL) - return FALSE; /* bad error handling */ - - return IsPrimitiveByDef (definingType); -} /* IsPrimitiveByDefOrRef */ - - -/* - * Returns TRUE if the given type is a primitive type. Does NOT - * follow type references - type refs are not considered primitive. - * The following types are considered primitive: - * BOOLEAN - * INTEGER - * BITSTRING - * OCTETSTRING - * NULL - * OID - * REAL - * ENUMERATED - */ -int -IsPrimitiveByDef PARAMS ((t), - Type *t) -{ - switch (t->basicType->choiceId) - { - case BASICTYPE_LOCALTYPEREF: - case BASICTYPE_IMPORTTYPEREF: - case BASICTYPE_SEQUENCE: - case BASICTYPE_SET: - case BASICTYPE_CHOICE: - case BASICTYPE_SEQUENCEOF: - case BASICTYPE_SETOF: - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_ANYDEFINEDBY: - case BASICTYPE_ANY: - return FALSE; - break; - - - case BASICTYPE_SELECTION: - if (t->basicType->a.selection->link != NULL) - return IsPrimitiveByDef (t->basicType->a.selection->link->type); - break; - - case BASICTYPE_BOOLEAN: - case BASICTYPE_INTEGER: - case BASICTYPE_BITSTRING: - case BASICTYPE_OCTETSTRING: - case BASICTYPE_NULL: - case BASICTYPE_OID: - case BASICTYPE_REAL: - case BASICTYPE_ENUMERATED: - return TRUE; - break; - - case BASICTYPE_UNKNOWN: - case BASICTYPE_MACROTYPE: - case BASICTYPE_MACRODEF: - return FALSE; - break; - - default: - fprintf (stderr, "IsPrimitiveByDef: ERROR - unknown type id ?!"); - } - return FALSE; -} /* IsPrimitiveByDef */ - - -/* - * Returns TRUE if the given type is a local type reference or an - * import type ref. - * e.g. - * - * Gumby ::= P1.ORName --> isTypeRef returns TRUE P1.ORName - * Bar ::= INTEGER --> isTypeRef returns FALSE for INTEGER - * Foo ::= Bar --> isTypeRef returns TRUE for Bar - */ -int -IsTypeRef PARAMS ((t), - Type *t) -{ - if ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || - (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) - return TRUE; - else - return FALSE; -} /* IsTypeRef */ - - - -/* - * Returns TRUE if the given type is defined - * by a library type such as OCTET STRING. - * Does NOT follow type refs - type refs return FALSE. - * - * NOTE - some possibly non-primitive types are defined by - * library types (ANY, ANY DEFINED BY) - * - * types defined by type refs or structured defs - * cause FALSE to be returned. i.e. - * Foo ::= Bar -> FALSE for Bar - * Bell ::= SEQUENCE { .. } -> False for SEQ... - * - * useful types are considered as type references and hence - * return FALSE. - */ -int -IsDefinedByLibraryType PARAMS ((t), - Type *t) -{ - int retVal; - - if (t == NULL) - retVal = FALSE; - - else if (IsPrimitiveByDef (t)) - retVal = TRUE; - - /* - * check for non-primitive types that - * are defined by a library type - */ - else - switch (t->basicType->choiceId) - { - case BASICTYPE_ANYDEFINEDBY: - case BASICTYPE_ANY: - retVal = TRUE; - break; - - default: - retVal = FALSE; - } - return retVal; - -} /* IsDefinedByLibraryType*/ - - -/* - * Returns FALSE if type t is - * a. a library type with default universal tags and no named elements - * OR - * b. a reference to a type with no extra tagging - * - * otherwise returns true, indicating that is is a new type derived - * by tagging or adding named elmts to another type. - * - * eg INTEGER --> FALSE (same as lib type) - * [APPLICATION 2] INTEGER --> TRUE (re-tagged lib type) - * INTEGER { one (1), two (2) } --> TRUE (lib type with named elmts) - * Bar2 --> FALSE (simple type ref) - */ -int -IsNewType PARAMS ((t), - Type *t) -{ - /* - * Type = [re-tagging] DefiningType [namedelmts] - * identical: no retagging and no named elements - */ - if (IsDefinedByLibraryType (t) && HasDefaultTag (t) && ! HasNamedElmts (t)) - return FALSE; - - else if (IsTypeRef (t) && ((t->tags == NULL) || (LIST_EMPTY (t->tags)))) - return FALSE; - - else - return TRUE; - -} /* IsNewType */ - - -/* - * Returns TRUE if elmts including curr list elmt - * onward are all optional otherwise returns FALSE. - * (note: this relies on the 'curr' ptr in the list) - * if the list is null or the curr elmt is null - * then returns TRUE - */ -int -IsTailOptional PARAMS ((e), - NamedTypeList *e) -{ - NamedType *elmt; - void *tmp; - int retVal; - - if (e == NULL) - return TRUE; - - tmp = (void*)CURR_LIST_NODE (e); - if (tmp == NULL) - return TRUE; - - retVal = TRUE; - FOR_REST_LIST_ELMT (elmt, e) - { - if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL)) - { - retVal = FALSE; - break; - } - } - SET_CURR_LIST_NODE (e, tmp); /* reset list to orig loc */ - return retVal; -} /* IsTailOptional */ - - - -/* - * Returns TRUE if all elmts after but not including the curr list elmt - * are optional otherwise returns FALSE. - * (note: this relies on the 'curr' ptr in the list) - * if the list is null or the curr elmt is null - * then returns TRUE. if there are no elmts after the curr elmt - * returns TRUE. - */ -int -NextIsTailOptional PARAMS ((e), - NamedTypeList *e) -{ - NamedType *elmt; - void *tmp; - void *tmp2; - int retVal; - - if ((e == NULL) || (LIST_EMPTY (e))) - return TRUE; - - tmp = (void*)CURR_LIST_NODE (e); - if (tmp == NULL) - return TRUE; - - tmp2 = (void*)NEXT_LIST_NODE (e); - if (tmp2 == NULL) - return TRUE; - - SET_CURR_LIST_NODE (e, tmp2); - - retVal = TRUE; - FOR_REST_LIST_ELMT (elmt, e) - { - if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL)) - { - retVal = FALSE; - break; - } - } - SET_CURR_LIST_NODE (e, tmp); /* reset list to orig loc */ - return retVal; -} /* NextIsTailOptional */ - - -/* - * Returns TRUE if all elmts of the curr list are optional - * or have default values. Useful with SET and SEQ elements. - */ -int -AllElmtsOptional PARAMS ((e), - NamedTypeList *e) -{ - NamedType *elmt; - void *tmp; - int retVal; - - if ((e == NULL) || LIST_EMPTY (e)) - return TRUE; - - tmp = (void*)CURR_LIST_NODE (e); - SET_CURR_LIST_NODE (e, FIRST_LIST_NODE (e)); - - retVal = TRUE; - FOR_REST_LIST_ELMT (elmt, e) - { - if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL)) - { - retVal = FALSE; - break; - } - } - SET_CURR_LIST_NODE (e, tmp); /* reset list to orig loc */ - return retVal; -} /* AllElmtsOptional */ - - - - - -/* - * Follows single levely of type ref or library type and returns a - * handle to its AnyRefList. Typically used in do_macros.c to - * add a hash key for the type that t is or refs. Need to get - * to the type def of type t to give the AnyRefListHndl. - */ -AnyRefList** -GetAnyRefListHndl PARAMS ((t), - Type *t) -{ - TypeDef *td; - - if (IsDefinedByLibraryType (t)) - return LIBTYPE_GET_ANY_REFS_HNDL (t->basicType->choiceId); - else - { - if (!IsTypeRef (t)) - return NULL; - else - { - td = t->basicType->a.localTypeRef->link; - return &td->anyRefs; - } - } -} /* GetAnyRefListHndl */ - - -/* - * Given a subtype list s (possibly empty *s == NULL) it tacks on - * the newSubtype in a appropriate fashion, possible chaning *s. - * Op can be SUBTYPE_AND or SUBTYPE_OR. - * - * e.g. Foo ::= INTEGER ((1..100) | 200) - * - * Add the subtypes by - * AppendSubtype (&t->subtypes, (1..100), SUBTYPE_AND) - * AppendSubtype (&t->subtypes, 200, SUBTYPE_OR) - * - * op is meaningless if s is empty - */ -void -AppendSubtype PARAMS ((s, newSubtype, op), - Subtype **s _AND_ - Subtype *newSubtype _AND_ - enum SubtypeChoiceId op) -{ - void **tmpPtr; - Subtype *sPtr; - - if (*s == NULL) - *s = newSubtype; - - else if (op == SUBTYPE_AND) - { - if ((*s)->choiceId == SUBTYPE_AND) - { - tmpPtr = (void**)AsnListAppend ((*s)->a.and); - *tmpPtr = (void*)newSubtype; - } - else - { - sPtr = (Subtype*)Malloc (sizeof (Subtype)); - sPtr->choiceId = SUBTYPE_AND; - sPtr->a.and = NEWLIST(); - tmpPtr = (void**)AsnListAppend (sPtr->a.and); - *tmpPtr = (void*)*s; - tmpPtr = (void**)AsnListAppend (sPtr->a.and); - *tmpPtr = (void*)newSubtype; - *s = sPtr; - } - } - else if (op == SUBTYPE_OR) - { - if ((*s)->choiceId == SUBTYPE_OR) - { - tmpPtr = (void**)AsnListAppend ((*s)->a.or); - *tmpPtr = (void*)newSubtype; - } - else - { - sPtr = (Subtype*)Malloc (sizeof (Subtype)); - sPtr->choiceId = SUBTYPE_OR; - sPtr->a.or = NEWLIST(); - tmpPtr = (void**)AsnListAppend (sPtr->a.or); - *tmpPtr = (void*)*s; - tmpPtr = (void**)AsnListAppend (sPtr->a.or); - *tmpPtr = (void*)newSubtype; - *s = sPtr; - } - } - else - /* NOT not supported here */ - fprintf (stderr,"AppendSubtype - unknown operation\n"); - -} /* AppendSubtype */ diff --git a/SecuritySNACCRuntime/compiler/core/snacc-util.h b/SecuritySNACCRuntime/compiler/core/snacc-util.h deleted file mode 100644 index 6f5e178b..00000000 --- a/SecuritySNACCRuntime/compiler/core/snacc-util.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * compiler/core/snacc_util.h - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/snacc-util.h,v 1.1 2001/06/20 21:27:59 dmitch Exp $ - * $Log: snacc-util.h,v $ - * Revision 1.1 2001/06/20 21:27:59 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:46 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:46:41 rj - * snacc_config.h's 2nd last macro, PrintErrLoc(), got here. - * - * Revision 1.1 1994/08/28 09:49:41 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#define PrintErrLoc( fileName, lineNo)\ - fprintf (stderr, "file \"%s\", line %d: ", fileName, lineNo) - -/* - * macro to allocate room for str & null & put in give STR* - */ -#define SETUP_STR( strPtr, string)\ - (strPtr)->str = Malloc (strlen (string) + 1);\ - strcpy ((strPtr)->str, string);\ - (strPtr)->len = strlen (string) + 1 - - -/* - * Create a new list type such that each elmt has space - * to hold a pointer - */ -#define NEWLIST() AsnListNew (sizeof (void *)) - -/* - * macro to append an element to the end of linked list - * - helps on left recursion when order must be maintained - * - * be careful of calling context if list is null - * that is, make sure the change to list is not lost. - */ -#define APPEND( elmt, list) \ -{\ - void **tmpPtr;\ - if ((list) == NULL)\ - (list) = NEWLIST();\ - tmpPtr = (void **) AsnListAppend ((AsnList *)list);\ - *tmpPtr = (void *) (elmt);\ -} - -/* - * like APPEND except puts elmt at head of list - */ -#define PREPEND( elmt, list) \ -{\ - void **tmpPtr;\ - if ((list) == NULL)\ - (list) = NEWLIST();\ - tmpPtr = (void **)AsnListPrepend ((AsnList *)list);\ - *tmpPtr = (void *) (elmt);\ -} - -void SetupType PROTO ((Type **t, enum BasicTypeChoiceId typeId, unsigned long lineNum)); - -void SetupMacroType PROTO ((Type **t, enum MacroTypeChoiceId macroTypeId, unsigned long lineNum)); - -void SetupValue PROTO ((Value **v, enum BasicValueChoiceId valId, unsigned long lineNum)); - - -void AddPrivateImportElmt PROTO ((Module *m, char *name, char *refModuleName, long int lineNo)); - -ImportElmt *LookupImportElmtInModule PROTO ((Module *m, char *name, ImportModule **importModule)); - -ImportElmt *LookupImportElmtInImportElmtList PROTO ((ImportElmtList *importElmtList, char *name)); - -ImportModule *LookupImportModule PROTO ((Module *m, char *importModuleName)); - -TypeDef *LookupType PROTO ((TypeDefList *t, char *typeName)); - -Module *LookupModule PROTO ((ModuleList *m, char *modName, OID *oid)); - -NamedType *LookupFieldInType PROTO ((Type *t, char *fieldName)); - -Type *GetType PROTO ((Type *t)); - -Type *ParanoidGetType PROTO ((Type *t)); - -enum BasicTypeChoiceId GetBuiltinType PROTO ((Type *t)); - -NamedNumberList *GetNamedElmts PROTO ((Type *t)); - -NamedNumberList *GetAllNamedElmts PROTO ((Type *t)); - -Type *GetParent PROTO ((Type *ancestor, Type *child)); - -ValueDef *LookupValue PROTO ((ValueDefList *v, char *valueName)); - -Value *GetValue PROTO ((Value *v)); - -int CompareOids PROTO ((OID *oid1, OID *oid2)); - -int HasNamedElmts PROTO ((Type *t)); - -int TagsAreIdentical PROTO ((TagList *t1, TagList *t2)); - -int HasDefaultTag PROTO ((Type *t)); - -int IsPrimitiveByDefOrRef PROTO ((Type *t)); - -int IsPrimitiveByDef PROTO ((Type *t)); - -int IsDefinedByLibraryType PROTO ((Type *t)); - -int IsTypeRef PROTO ((Type *t)); - -int IsNewType PROTO ((Type *t)); - -int IsTailOptional PROTO ((NamedTypeList *e)); - -int NextIsTailOptional PROTO ((NamedTypeList *e)); - -int AllElmtsOptional PROTO ((NamedTypeList *e)); - -AnyRefList **GetAnyRefListHndl PROTO ((Type *t)); - -void AppendSubtype PROTO ((Subtype **s, Subtype *newSubtype, enum SubtypeChoiceId op)); diff --git a/SecuritySNACCRuntime/compiler/core/snacc.c b/SecuritySNACCRuntime/compiler/core/snacc.c deleted file mode 100644 index 6650a469..00000000 --- a/SecuritySNACCRuntime/compiler/core/snacc.c +++ /dev/null @@ -1,1361 +0,0 @@ -/* - * compiler/core/snacc.c---Compiles ASN.1 src files into an internal type tree. - * Imported type/value references are resolved if possible. - * Produces C or C++ encoder/decoder/print/free code and .h for - * data struct and prototypes. - * Generated C can be either ANSI or old style via macros. - * Produces values for OBJECT IDENTIFIERs, INTEGERs and BOOLEANs - * - * Mike Sample 1991/92 - * - * NOTES - * - * See the README file for compiling tips. This should compile - * with ANSI or non-ANSI c compilers. - * - * each ASN.1 source file must contain a complete ASN.1 module: - * DEFINITIONS ::= BEGIN ... END - * - * 91/09/04---modified to handle new data struct (ASN.1 generated) - * for module info. MS. - * - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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 and the associated libraries are distributed in the hope - * that they 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 and GNU Library General - * Public License for more details. - * - * INSERT_VDA_COMMENTS - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/snacc.c,v 1.1 2001/06/20 21:27:59 dmitch Exp $ - * $Log: snacc.c,v $ - * Revision 1.1 2001/06/20 21:27:59 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:52 aram - * Originals from SMIME Free Library. - * - * Revision 1.10 1997/05/07 15:18:35 wan - * Added (limited) size constraints, bitstring and enumeration names to tables - * - * Revision 1.9 1997/02/16 15:12:21 rj - * made ``return *this after calling abort()'' a compile time option. - * - * Revision 1.8 1997/01/02 08:50:55 rj - * - use the TIME_WITH_SYS_TIME flag (checked and generated by configure) - * - do not silently ignore the -tcl option if not compiled for tcl code generation - * - * Revision 1.7 1995/09/07 19:13:39 rj - * new options -mA and -mC for snacc(1) that switch the names used between those defined in the ASN.1 files and those used in the generated C++ code. - * uses newly introduced enum MetaNameStyle. - * - * Revision 1.6 1995/08/17 15:00:13 rj - * the PDU flag belongs to the metacode, not only to the tcl interface. (type and variable named adjusted) - * - * Revision 1.5 1995/07/25 19:34:06 rj - * bug report address changed to protect an innocent's mailbox :-) - * - * snacc -h now prints the usage to stdout. - * - * allow for more than one PDU per .asn1 file set: - * - struct TclPDU becomes a linked list. - * - it gets a flag `used' to detect invalid command line arguments. - * - * code for idl backend added. - * - * by default, snacc now derives output file names from the .asn1 input file name instead of the module name. - * - * changed `_' to `-' in file names. - * - * Revision 1.4 1994/12/11 20:21:06 rj - * #include string(s).h - * - * Revision 1.3 1994/10/08 03:23:27 rj - * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. - * - * code for meta structures added (provides information about the generated code itself). - * - * code for Tcl interface added (makes use of the above mentioned meta code). - * - * Revision 1.2 1994/09/01 00:44:31 rj - * snacc_config.h and other superfluous .h files removed. version string moved into a separate version.h file. - * - * Revision 1.1 1994/08/28 09:49:37 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - -#ifdef VDADER_RULES -/* Enables VDA's DER SUPPORT. If gVDADER_RULES == 1 then support is on, - * other wise it is off. Define _gVDADER_RULES so snacc.h does not - * redefine the global gVDADER_RULES with it's extern (avoids a compile - * time warning). - ** COMPILER EXECUTION FLAGS: "-D -C -u ../../../snaccVC/asn-useful.asn1 - sm_vdatypes.asn sm_x501ud.asn sm_x411ub.asn sm_x411mtsas.asn - sm_x501if.asn sm_x520sa.asn sm_x509cmn.asn sm_x509af.asn - sm_x509ce.asn sm_cms.asn sm_ess.asn tst_email.asn - tst_email2.asn" - -D -C -u ../../../snaccVC/asn-useful.asn1 sm_vdatypes.asn sm_x501ud.asn sm_x411ub.asn sm_x411mtsas.asn sm_x501if.asn sm_x520sa.asn sm_x509cmn.asn sm_x509af.asn sm_x509ce.asn sm_cms.asn sm_ess.asn tst_email.asn tst_email2.asn - */ -#define _gVDADER_RULES -int gVDADER_RULES=0; -#endif - -#include "snacc.h" - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#if STDC_HEADERS || HAVE_STRING_H -#include -#else -#include -#endif -#include - -#include "asn-incl.h" -#include "version.h" -#include "mem.h" -#include "asn1module.h" -#include "exports.h" -#include "parser.h" /* for parser (ech!) globals */ -#include "dependency.h" -#include "link-types.h" -#include "link-values.h" -#include "err-chk.h" -#include "print.h" -#include "recursive.h" -#include "define.h" -#include "normalize.h" -#include "do-macros.h" -#include "snacc-util.h" -#if META -#include "meta.h" -#endif - -#include "str-util.h" - -#include "c-gen/rules.h" /* for c file generation */ -#include "c-gen/type-info.h" -#include "c-gen/gen-code.h" - -#include "c++-gen/rules.h" /* for c++ file generation */ -#include "c++-gen/types.h" -#include "c++-gen/gen-code.h" - -#include "gen-tbls.h" /* for type table generation */ - -#if IDL -#include "idl-gen/rules.h" -#include "idl-gen/types.h" -#include "idl-gen/gen-code.h" -#endif - - -/* prototypes for this file's routines */ - -Module *ParseAsn1File PROTO ((char *fileName)); - -void GenCCode PROTO ((ModuleList *allMods, long int longJmpVal, int genTypes, int genEncoders, int genDecoders, int genPrinters, int genValues, int genFree)); - -void GenCxxCode PROTO ((ModuleList *allMods, long int longJmpVal, int genTypes, int genEncoders, int genDecoders, int genPrinters, int genValues, int genFree, if_META (MetaNameStyle genMeta COMMA MetaPDU *meta_pdus COMMA) if_TCL (int genTcl COMMA) int novolatilefuncs)); - -void GenIDLCode PROTO ((ModuleList *allMods, long int longJmpVal, int genTypes, int genPrinters, int genValues, int genFree)); - -int ModNamesUnique PROTO ((ModuleList *m)); - -Module *usefulTypeModG = NULL; -static char versionG[] = VERSION; -static char releasedateG[] = RELDATE; -static char bugreportaddressG[] = BUGREPADDR; -int maxFileNameLenG = -1; /* values > 2 are considered valid */ - /* this is used in back_ends/c_gen/str_util.c */ - -void -Usage PARAMS ((prgName, fp), - char *prgName _AND_ - FILE *fp) -{ - fprintf (fp, "\nUsage: %s ", prgName); - fprintf (fp, "[-h] [-P] [-t] [-v] [-e] [-d] [-p] [-f]\n"); -#if IDL - fprintf (fp, " [-c | -C | -[T|O] | -idl ]\n"); -#else - fprintf (fp, " [-c | -C | -[T|O]
]\n"); -#endif - fprintf (fp, " [-u ]\n"); - fprintf (fp, " [-mm] [-mf ]\n"); - fprintf (fp, " [-l ]\n"); -#if META - fprintf (fp, " [-meta ] [-mA | -mC]\n"); -#if TCL - fprintf (fp, " [-tcl ]\n"); -#endif -#endif - fprintf (fp, " \n\n"); - fprintf (fp, " -h prints this msg\n"); - fprintf (fp, " -c generate C encoders and decoders (default)\n"); - fprintf (fp, " -C generate C++ encoders and decoders\n"); - fprintf (fp, " -novolat for broken C++ compilers: return *this after calling abort()\n"); - fprintf (fp, " -T write a type table file for the ASN.1 modules to file filename\n"); - fprintf (fp, " -O writes the type table file in the original (<1.3b2) format\n"); -#if IDL - fprintf (fp, " -idl generate CORBA IDL\n"); -#endif - fprintf (fp, " -u specifies the ASN.1 file with definition of the useful types\n"); - fprintf (fp, " (i.e. PrintableString). See the useful.asn1 file (in the\n"); - fprintf (fp, " snacc/asn1specs/ directory).\n"); - fprintf (fp, " -P print the parsed ASN.1 modules to stdout from their parse trees\n"); - fprintf (fp, " (helpful debugging)\n"); - fprintf (fp, " -t generate type definitions\n"); - fprintf (fp, " -v generate value definitions (limited)\n"); - fprintf (fp, " -e generate encode routines\n"); - fprintf (fp, " -d generate decode routines\n"); - fprintf (fp, " -p generate print routines\n"); - fprintf (fp, " -f generate hierarchical free routines (C only)\n"); - fprintf (fp, " note: if none of -t -v -e -d -p -f are given, all are generated.\n"); - fprintf (fp, " These do not affect type tables.\n"); - - - fprintf (fp, " -mm mangle output file name into module name (by default, the output file\n"); - fprintf (fp, " inherits the input file's name, with only the suffix replaced)\n"); - fprintf (fp, " -mf num is maximum file name length for the generated source files\n"); - - fprintf (fp, " -l where to start error longjmp values decending from (obscure).\n"); - -#if META - fprintf (fp, " -meta generate meta code that describes the generated types. Implies -C.\n"); - fprintf (fp, " -mA metacode: use names as defined in the ASN.1 files.\n"); - fprintf (fp, " -mC metacode: use names as used in the generated C++ files.\n"); -#if TCL - fprintf (fp, " -tcl generate code for a Tcl interpreter. Implies -meta.\n"); -#endif - fprintf (fp, " has the following syntax: .[,.[...]]\n"); - fprintf (fp, " the types listed are the top level PDUs.\n"); -#endif - - fprintf (fp, "\nUse `-' as the ASN.1 source file name to parse stdin.\n\n"); - - - fprintf (fp, "This ASN.1 compiler produces C or C++ BER encoders and decoders or type tables.\n"); - - fprintf (fp, "\nVersion %s, %s.\n", versionG, releasedateG); -#if 0 - fprintf (fp, "Please send bug reports and comments to %s.\n\n", bugreportaddressG); -#else - fprintf (fp, "Please see %s for new versions and where to send bug reports and comments.\n\n", bugreportaddressG); -#endif - - fprintf (fp, "Copyright (C) 1993 Michael Sample and UBC\n"); - fprintf (fp, "Copyright (C) 1994, 1995 by Robert Joop and GMD FOKUS\n\n"); - - fprintf (fp, "This program is free software; you can redistribute it and/or modify\n"); - fprintf (fp, "it under the terms of the GNU General Public License as published by\n"); - fprintf (fp, "the Free Software Foundation; either version 2 of the License, or\n"); - fprintf (fp, "(at your option) any later version.\n\n"); - - fprintf (fp, "This program is distributed in the hope that it will be useful,\n"); - fprintf (fp, "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"); - fprintf (fp, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"); - fprintf (fp, "GNU General Public License for more details.\n\n"); - -/* - fprintf (fp, "You should have received a copy of the GNU General Public License\n"); - fprintf (fp, "along with this program; if not, write to the Free Software\n"); - fprintf (fp, "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"); -*/ -} - - -typedef struct -{ - char *fileName; -} SRC_FILE; - - -#if META -static MetaPDU *parse_type_list (arg) - char *arg; -{ - MetaPDU *meta_pdus = NULL; - char *module; - for (module = strtok (arg, ".:"); module; module = strtok (NULL, ".:")) - { - MetaPDU *pdu = MT (MetaPDU); - char *type = strtok (NULL, " /,;"); - if (!type) - { - fprintf (stderr, "usage: {-meta|-tcl} module.type[,module.type[...]]\n"); - exit (1); - } - pdu->module = module; - pdu->type = type; - pdu->used = FALSE; - - pdu->next = meta_pdus; - meta_pdus = pdu; - } - return meta_pdus; -} -#endif - -int main PARAMS ((argc, argv), - int argc _AND_ - char **argv) -{ - int i, j, semErr; - int retVal; - int fd; - SRC_FILE *srcList; - int numSrcFiles; - ModuleList *allMods; - Module *currMod; - Module **tmpModHndl; - int currArg; - int argsProcessed; - char *usefulTypeModFileName; - FILE *fPtr; - int printModuleFlag = FALSE; /* default: Don't print */ - int genTypeTbls = 0; /* default: Don't gen tbls */ - char *tblFileName; - int genTypeCode = FALSE; - int genEncodeCode = FALSE; - int genDecodeCode = FALSE; - int genPrintCode = FALSE; - int genValueCode = FALSE; - int genFreeCode = FALSE; -#if META - MetaNameStyle genMetaCode = META_off; - MetaPDU *meta_pdus = NULL; -#if TCL - int genTclCode = FALSE; -#endif -#endif - int genCCode = FALSE; /* defaults to C if neither specified */ - int genCxxCode = FALSE; -#if IDL - int genIDLCode = FALSE; -#endif - long longJmpVal = -100; - int novolatilefuncs = FALSE; - -#ifdef YYDEBUG - /* prints yacc debugging info to stdout */ - yydebug = 1; -#endif - - - if (argc <= 1) - { - Usage (argv[0], stderr); - exit (1); - } - - srcList = (SRC_FILE*) Malloc ((argc -1) * sizeof (SRC_FILE)); - - - /* - * parse cmd line args - */ - numSrcFiles = 0; - usefulTypeModFileName = NULL; - for (currArg = 1; (currArg < argc); ) - { - if ((argv[currArg][0] == '-') && (argv[currArg][1] != '\0')) - switch (argv[currArg][1]) - { -#ifdef VDADER_RULES - case 'D': - gVDADER_RULES=1; - currArg++; - break; -#endif - case 'h': - Usage (argv[0], stdout); - exit (1); - break; - - case 'P': - printModuleFlag = TRUE; - currArg++; - break; - - case 'v': - genValueCode = TRUE; - currArg++; - break; - -#if IDL - case 'i': - if (!strcmp (argv[currArg]+1, "idl")) - { - genIDLCode = TRUE; - currArg++; - } - else - goto error; - break; -#endif - - case 't': - if (!strcmp (argv[currArg]+1, "tcl")) - { -#if TCL - meta_pdus = parse_type_list (argv[++currArg]); - genTclCode = TRUE; - if (!genMetaCode) - genMetaCode = META_backend_names; - genCxxCode = TRUE; -#else - goto error; -#endif - } - else - genTypeCode = TRUE; - currArg++; - break; - - case 'e': - genEncodeCode = TRUE; - currArg++; - break; - - case 'd': - genDecodeCode = TRUE; - currArg++; - break; - - case 'p': - genPrintCode = TRUE; - currArg++; - break; - - case 'f': - genFreeCode = TRUE; - currArg++; - break; - - case 'C': - genCxxCode = TRUE; - currArg++; - break; - - case 'n': - if (!strcmp (argv[currArg]+1, "novolat")) - { - novolatilefuncs = TRUE; - currArg++; - } - else - goto error; - break; - - case 'c': - genCCode = TRUE; - currArg++; - break; - - case 'u': - if (argv[currArg][2] != '\0') /* no space after -u */ - { - usefulTypeModFileName = &argv[currArg][2]; - currArg++; - } - else - { - usefulTypeModFileName = argv[currArg+1]; - currArg += 2; - } - break; - - case 'l': - if (argv[currArg][2] != '\0') /* no space after -l */ - { - longJmpVal = atoi (&argv[currArg][2]); - currArg++; - } - else - { - longJmpVal = atoi (argv[currArg+1]); - currArg += 2; - } - break; - - case 'T': - case 'O': - genTypeTbls = argv[currArg][1]=='T'?2:1; - if (argv[currArg][2] != '\0') /* no space after -T */ - { - tblFileName = &argv[currArg][2]; - currArg++; - } - else - { - tblFileName = argv[currArg+1]; - currArg += 2; - } - break; - - - case 'm': - if (argv[currArg][2] == 'f') - { - if (argv[currArg][3] != '\0') /* no space after -mf */ - { - maxFileNameLenG = atoi (&argv[currArg][3]); - currArg++; - } - else - { - maxFileNameLenG = atoi (argv[currArg+1]); - currArg += 2; - } - break; - } -#if META - else if (!strcmp (argv[currArg]+1, "meta")) - { - meta_pdus = parse_type_list (argv[++currArg]); - if (!genMetaCode) - genMetaCode = META_backend_names; - genCxxCode = TRUE; - currArg++; - break; - } - else if (!strcmp (argv[currArg]+1, "mA")) - { - genMetaCode = META_asn1_names; - genCxxCode = TRUE; - currArg++; - break; - } - else if (!strcmp (argv[currArg]+1, "mC")) - { - genMetaCode = META_backend_names; - genCxxCode = TRUE; - currArg++; - break; - } -#endif - else if (argv[currArg][2] == 'm') - { - keepbaseG = FALSE; - currArg++; - break; - } - - /* else fall through to default error */ - -error: - default: - fprintf (stderr, "%s: ERROR---unknown cmd line option `%s'\n\n", argv[0], argv[currArg]); - Usage (argv[0], stderr); - exit (1); - } - - else /* asn1srcFileName */ - srcList[numSrcFiles++].fileName = argv[currArg++]; - - } - - - if (numSrcFiles == 0) - { - fprintf (stderr, "%s: ERROR---no ASN.1 source files were specified\n", argv[0]); - Usage (argv[0], stderr); - exit (1); - } - - - /* - * set default options - */ - if (!(genTypeCode || genValueCode || genEncodeCode || genDecodeCode || - genFreeCode || genPrintCode)) - { - genTypeCode = TRUE; - genValueCode = TRUE; - genEncodeCode = TRUE; - genDecodeCode = TRUE; - genFreeCode = TRUE; - genPrintCode = TRUE; - } - - else if (genCCode + genCxxCode + genTypeTbls -#if IDL - + genIDLCode -#endif - > 1) - { - fprintf (stderr, "%s: ERROR---Choose only one of the -c -C or -T options\n", argv[0]); - Usage (argv[0], stderr); - exit (1); - } - - if (!genCCode && !genCxxCode && !genTypeTbls -#if IDL - && !genIDLCode -#endif - ) - genCCode = TRUE; /* default to C if neither specified */ - - - /* - * STEP 1 - * parse 'useful' type module for linking purposes only (if given) - * the useful type encode, decode, print, free routines are - * already in the runtime library. - */ - if (usefulTypeModFileName != NULL) - { - usefulTypeModG = ParseAsn1File (usefulTypeModFileName); - - if (usefulTypeModG == NULL) - exit (1); - } - else - { - fprintf (stderr, " Hmmm, you didn't specify a useful types ASN.1 file with the `-u' option.\n"); - fprintf (stderr, " I'll continue assuming your ASN.1 file(s) don't need any useful types.\n"); - } - - - /* - * STEP 2---parse each ASN.1 src file - */ - allMods = (ModuleList *)AsnListNew (sizeof (void*)); - for (i = 0; i < numSrcFiles; i++) - { - currMod = ParseAsn1File (srcList[i].fileName); - - if (currMod == NULL) - exit (1); - - /* - * insert this module at the head of the list - * of already parsed (if any) modules - */ - tmpModHndl = (Module **)AsnListAppend (allMods); - *tmpModHndl = currMod; - - } /* end per src file for loop */ - - - /* - * Check that the module names/oids are unique. - */ - if (!ModNamesUnique (allMods)) - { - fprintf (stderr, "Conflicting module names, cannot proceed.\n"); - exit (1); - } - - - - /* - * STEP 3 - * Now that all files have been parsed, - * link local and locatable import type refs - */ - if (LinkTypeRefs (allMods) < 0) - { - fprintf (stderr, "Type linking errors---cannot proceed\n"); - exit (1); - } - - - - /* - * STEP 4 - * Parse constructed values now that types are all parsed - * and have been linked. Need type info to be able to - * parse values easily (elimitate ambiguity). - */ - FOR_EACH_LIST_ELMT (currMod, allMods) - { - if (ParseValues (allMods, currMod) != 0) - fprintf (stderr, "WARNING: Value parsing error (s), attempting to continue\n"); - } - - - /* - * STEP 5 - * Value parsing may have defined some new values - * so can link local and locatable import value refs now. - */ - if (LinkValueRefs (allMods) < 0) - { - fprintf (stderr, "Value linking errors---cannot proceed\n"); - exit (1); - } - - - - /* - * STEP 6 - * process macros - * - adding type/value defs as nec - * - mark type defs with ANY DEFINED BY id if nec - * so they are put in the id to ANY type hash tbl. - */ - semErr = 0; - FOR_EACH_LIST_ELMT (currMod, allMods) - { - ProcessMacros (currMod); - if (currMod->status == MOD_ERROR) - semErr = 1; - } - if (semErr) - exit (1); - - /* - * STEP 7 - * convert silly type constructs into - * a normal format, leaving behind pure type/value info - * eg: expand COMPONENTS OF refs, SELECTION types. - * boil down values into simplest rep. (eg OID -> ENC_OID) - */ - semErr = 0; - FOR_EACH_LIST_ELMT (currMod, allMods) - { - NormalizeModule (currMod); - if (currMod->status == MOD_ERROR) - semErr = 1; - } - if (semErr) - exit (1); - - - /* - * STEP 8 - * Mark recusive types. Currently the recursive information is - * not used elsewhere. - */ - FOR_EACH_LIST_ELMT (currMod, allMods) - { - MarkRecursiveTypes (currMod); - } - - - /* - * STEP 9 - * Check for errors in the ASN.1 modules. - * Check all modules and exit if errors were found - */ - semErr = 0; - if (usefulTypeModG != NULL) - { - ErrChkModule (usefulTypeModG); - if (usefulTypeModG->status == MOD_ERROR) - semErr = 1; - } - - FOR_EACH_LIST_ELMT (currMod, allMods) - { - ErrChkModule (currMod); - if (currMod->status == MOD_ERROR) - semErr = 1; - } - - - if (semErr) - exit (1); - - - - - /* - * exit if any sundry errors occurred at any point. - * smallErrG is set upon finding small errors that prevent code - * production but should not affect the other processing/error - * checking steps. This allows full display of errors. - */ - if (smallErrG) - { - /* - * for debugging show "parsed" version of ASN.1 module if - * the print flag is set. - * Dumps each module to stdout. Printed from Module data struct - * print here before exiting otherwise print after sorting - */ - if (printModuleFlag) - { - FOR_EACH_LIST_ELMT (currMod, allMods) - { - printf ("\n\n"); - PrintModule (stdout, currMod); - } - } - - exit (1); - } - - /* - * STEP 10 - * Make C/C++ typenames/routine names for enc/decode. - * Type/Value renaming will occur if name conflicts - * arise between modules. - * - * NOTE: this is done before sorting the types because - * the type sorting routine may use the 'isPtr' - * information to help order knots of recursive types. - */ - if (genCCode) - FillCTypeInfo (&cRulesG, allMods); - - else if (genCxxCode) - FillCxxTypeInfo (&cxxRulesG, allMods); - -#if IDL - else if (genIDLCode) - FillIDLTypeInfo (&idlRulesG, allMods); -#endif - - - /* - * STEP 11 - * Sort each typedef list such that independent types are - * before the types that depend on them - * - * modules remain in same order as given on command line - * (cmd line file order should be - * least dependent module-> most dependent module - * so that include file order in generated src is correct) - * (useful.asn1 is always considered 'first' if given) - */ - SortAllDependencies (allMods); - - /* - * for debugging show "parsed" version of ASN.1 module. - * dumps each module to stdout. Printed from Module data struct - * Shows the results of normalization and sorting. - */ - if (printModuleFlag) - { - FOR_EACH_LIST_ELMT (currMod, allMods) - { - printf ("\n\n"); - PrintModule (stdout, currMod); - } - } - - /* - * Step 12 - * Final Step: Code/Type Table generation - */ - if (genCCode) - GenCCode (allMods, longJmpVal, genTypeCode, genValueCode, genEncodeCode, genDecodeCode, genPrintCode, genFreeCode); - - else if (genCxxCode) - GenCxxCode (allMods, longJmpVal, genTypeCode, genValueCode, genEncodeCode, genDecodeCode, genPrintCode, genFreeCode, if_META (genMetaCode COMMA meta_pdus COMMA) if_TCL (genTclCode COMMA) novolatilefuncs); - - else if (genTypeTbls) - GenTypeTbls (allMods, tblFileName, genTypeTbls); - -#if IDL - else if (genIDLCode) - GenIDLCode (allMods, longJmpVal, genTypeCode, genValueCode, genPrintCode, genFreeCode); -#endif - - return 0; /* keep make happy */ - -} /* end main */ - - - -/* - * Calls the yacc/lex parser given a the ASN.1 src file's filename. - * Returns a Module *for the given ASN.1 module. If the filename is - * "-" stdin is used. - */ -Module * -ParseAsn1File PARAMS ((fileName), - char *fileName) -{ - FILE *fPtr; - Module *retVal; - int parseResult; - - /* - * Open input file for lexical analyzer/parser - * Use stdin if the filename is "-" - */ - if (strcmp (fileName, "-") == 0) - if (keepbaseG) - { - fprintf (stderr, "ERROR---asn1 src file `%s' cannot be processed without output filename mangling\n", fileName); - return NULL; - } - else - fPtr = stdin; - else - fPtr = fopen (fileName, "r"); - - if (fPtr == NULL) - { - fprintf (stderr, "ERROR---asn1 src file `%s' cannot be opened for reading\n", fileName); - return NULL; - } - - retVal = (Module *)Malloc (sizeof (Module)); - - /* - * Init Parser by giving it a ptr to the Module data struct - * to initialize/use, and the file name associtated with - * the given FILE *, fPtr (for error reporting). - * fPtr should be an opened FILE *to an ASN.1 source FILE - */ - InitAsn1Parser (retVal, fileName, fPtr); - - - /* - * parse the current asn1 src file into the - * Module data struct - */ - parseResult = yyparse(); - - if (parseResult != 0 || retVal->status == MOD_ERROR) - { - /* parser will print exact err msg */ - fprintf (stderr, "Parsing errors---cannot proceed\n"); - return NULL; - } - - if (fPtr != stdin) - fclose (fPtr); - - return retVal; - -} /* ParseAsn1File */ - - -/* - * Given the list of parsed, linked, normalized, error-checked and sorted - * modules, and some code generation flags, generates C code and - * writes it to files derived from each modules name. Each module - * gets 2 source files, one .h for data struct and prototypes, the other .c - * for the enc/dec/print/free routine code. - */ -void -GenCCode PARAMS ((allMods, longJmpVal, genTypes, genValues, genEncoders, genDecoders, genPrinters, genFree), - ModuleList *allMods _AND_ - long int longJmpVal _AND_ - int genTypes _AND_ - int genValues _AND_ - int genEncoders _AND_ - int genDecoders _AND_ - int genPrinters _AND_ - int genFree) -{ - Module *currMod; - char *modBaseFileName; - FILE *cHdrFilePtr; - FILE *cSrcFilePtr; - DefinedObj *fNames; - int fNameConflict = FALSE; - - /* - * Make names for each module's encoder/decoder src and hdr files - * so import references can be made via include files. - * If file names conflict, print error msg & exit. - */ - fNames = NewObjList(); - FOR_EACH_LIST_ELMT (currMod, allMods) - { - modBaseFileName = MakeBaseFileName (keepbaseG - ? currMod->asn1SrcFileName - : currMod->modId->name); /* shorten module name if necessary (SYSV etc) */ - currMod->cHdrFileName = MakeCHdrFileName (modBaseFileName); - currMod->cSrcFileName = MakeCSrcFileName (modBaseFileName); - - if (ObjIsDefined (fNames, currMod->cHdrFileName, StrObjCmp) || - ObjIsDefined (fNames, currMod->cSrcFileName, StrObjCmp)) - { - fprintf (stderr, "Ack! ERROR---file name conflict for generated source files with names `%s' and `%s'.\n\n", currMod->cHdrFileName, currMod->cSrcFileName); - fprintf (stderr, "This usually means the max file name length is truncating the file names.\n"); - fprintf (stderr, "Try re-naming the modules with shorter names or increasing the argument to -mf option (if you are using it).\n"); - fprintf (stderr, "This error can also be caused by 2 modules with the same names but different OBJECT IDENTIFIERs."); - fprintf (stderr, " Try renaming the modules to correct this.\n"); - fNameConflict = TRUE; - } - else - { - DefineObj (&fNames, currMod->cHdrFileName); - DefineObj (&fNames, currMod->cSrcFileName); - } - Free (modBaseFileName); - } - if (fNameConflict) - exit (1); - - FreeDefinedObjs (&fNames); - /* - * make c files - */ - FOR_EACH_LIST_ELMT (currMod, allMods) - { - cHdrFilePtr = fopen (currMod->cHdrFileName, "w"); - cSrcFilePtr = fopen (currMod->cSrcFileName, "w"); - if ((cSrcFilePtr == NULL) || (cHdrFilePtr == NULL)) - perror ("fopen"); - else - { - PrintCCode (cSrcFilePtr, cHdrFilePtr, allMods, currMod, &cRulesG, longJmpVal, genTypes, genValues, genEncoders, genDecoders, genPrinters, genFree); - - fclose (cHdrFilePtr); - fclose (cSrcFilePtr); - } - } - -} /* GenCCode */ - - -/* - * Given the list of parsed, linked, normalized, error-checked and sorted - * modules, and some code generation flags, generates C++ code and - * writes it to files derived from each modules name. Each module - * gets 2 source files, one .h for data struct and prototypes, the other .C - * for the enc/dec/print/free routine code. - */ -void -GenCxxCode PARAMS ((allMods, longJmpVal, genTypes, genValues, genEncoders, genDecoders, genPrinters, genFree, if_META (genMeta COMMA meta_pdus COMMA) if_TCL (genTcl COMMA) novolatilefuncs), - ModuleList *allMods _AND_ - long int longJmpVal _AND_ - int genTypes _AND_ - int genValues _AND_ - int genEncoders _AND_ - int genDecoders _AND_ - int genPrinters _AND_ - int genFree _AND_ - if_META (MetaNameStyle genMeta _AND_) - if_META (MetaPDU *meta_pdus _AND_) - if_TCL (int genTcl _AND_) - int novolatilefuncs) -{ - Module *currMod; - char *modBaseFileName; - FILE *hdrFilePtr; - FILE *srcFilePtr; -#ifdef _IBM_ENC_ - FILE *hdbFilePtr; /* 19.8.93 IBM-ENC */ - FILE *sdbFilePtr; /* 19.8.93 IBM-ENC */ -#endif /* _IBM_ENC_ */ - DefinedObj *fNames; - int fNameConflict = FALSE; - -#if META - static const char metabasefn[] = "modules"; - Meta meta; -#if TCL - const MetaPDU *pdu; -#endif -#endif - - /* - * Make names for each module's encoder/decoder src and hdr files - * so import references can be made via include files - * check for truncation --> name conflicts & exit if nec - */ - fNames = NewObjList(); -#if META - if (genMeta) - DefineObj (&fNames, meta.srcfn = MakeCxxSrcFileName (metabasefn)); -#endif - FOR_EACH_LIST_ELMT (currMod, allMods) - { - modBaseFileName = MakeBaseFileName (keepbaseG - ? currMod->asn1SrcFileName - : currMod->modId->name); /* shorten module name if necessary (SYSV etc) */ - currMod->cxxHdrFileName = MakeCxxHdrFileName (modBaseFileName); - currMod->cxxSrcFileName = MakeCxxSrcFileName (modBaseFileName); -#ifdef _IBM_ENC_ - currMod->dbHdrFileName = MakedbHdrFileName (modBaseFileName); /* 19.8.93 IBM-ENC */ - currMod->dbSrcFileName = MakedbSrcFileName (modBaseFileName); /* 19.8.93 IBM-ENC */ -#endif /* _IBM_ENC_ */ -#if META - { - char *in, *out; - - out = currMod->cxxname = (char *)malloc (strlen (in = currMod->modId->name)+1); - do - *out++ = *in == '-' ? '_' : *in; - while (*in++); - } -#endif - - if (ObjIsDefined (fNames, currMod->cxxHdrFileName, StrObjCmp) || ObjIsDefined (fNames, currMod->cxxSrcFileName, StrObjCmp)) - { - fprintf (stderr, "Ack! ERROR---file name conflict for generated source files with names `%s' and `%s'.\n\n", currMod->cxxHdrFileName, currMod->cxxSrcFileName); - fprintf (stderr, "This usually means the max file name length is truncating the file names.\n"); - fprintf (stderr, "Try re-naming the modules with shorter names or increasing the argument to -mf option (if you are using it).\n"); - fprintf (stderr, "This error can also be caused by 2 modules have the same names but different OBJECT IDENTIFIERs."); - fprintf (stderr, " Try renaming the modules to correct this.\n"); - fNameConflict = TRUE; - } - else - { - DefineObj (&fNames, currMod->cxxHdrFileName); - DefineObj (&fNames, currMod->cxxSrcFileName); - } - Free (modBaseFileName); - } - if (fNameConflict) - exit (1); - - FreeDefinedObjs (&fNames); - - /* - * make C++ files - */ -#if META - if (genMeta) - { - time_t now = time (NULL); - - if (!(meta.srcfp = fopen (meta.srcfn, "w"))) - { - perror ("fopen"); - exit (1); - } - fprintf (meta.srcfp, "// NOTE: this is a machine generated file--editing not recommended\n"); - fprintf (meta.srcfp, "//\n"); - fprintf (meta.srcfp, "// modules.C - reference to all modules and their types\n"); - fprintf (meta.srcfp, "//\n"); - fprintf (meta.srcfp, "// This file was generated by snacc on %s", ctime (&now)); - } -#endif - FOR_EACH_LIST_ELMT (currMod, allMods) - { - /* - * create and fill .h file for module's data structs - */ - hdrFilePtr = fopen (currMod->cxxHdrFileName, "w"); - srcFilePtr = fopen (currMod->cxxSrcFileName, "w"); -#ifndef _IBM_ENC_ - if ((hdrFilePtr == NULL) || (srcFilePtr == NULL)) -#else - hdbFilePtr = fopen (currMod->dbHdrFileName, "w"); /* 19.8.93 IBM-ENC */ - sdbFilePtr = fopen (currMod->dbSrcFileName, "w"); /* 19.8.93 IBM-ENC */ - if ((hdrFilePtr == NULL) || (srcFilePtr == NULL) || - (hdbFilePtr == NULL) || (sdbFilePtr == NULL)) /* 19.8.93 IBM-ENC */ -#endif /* _IBM_ENC_ */ - perror ("fopen"); - else - { - PrintCxxCode (srcFilePtr, hdrFilePtr, - if_IBM_ENC (sdbFilePtr COMMA hdbFilePtr COMMA /* 19.8.93 IBM-ENC */) - if_META (genMeta COMMA &meta COMMA meta_pdus COMMA) - allMods, currMod, &cxxRulesG, longJmpVal, - genTypes, genValues, genEncoders, genDecoders, genPrinters, genFree, - if_TCL (genTcl COMMA) novolatilefuncs); - - fclose (hdrFilePtr); - fclose (srcFilePtr); -#ifdef _IBM_ENC_ - fclose (hdbFilePtr); /* 19.8.93 IBM-ENC */ - fclose (sdbFilePtr); /* 19.8.93 IBM-ENC */ -#endif /* _IBM_ENC_ */ - } - } -#if META - if (genMeta) - { - fprintf (meta.srcfp, "\n"); - fprintf (meta.srcfp, "#ifndef META\n"); - fprintf (meta.srcfp, "#define META 1\n"); - fprintf (meta.srcfp, "#endif\n"); - if (meta_pdus) - { - for (pdu=meta_pdus; pdu; pdu=pdu->next) - if (!pdu->used) - fprintf (stderr, "warning: PDU %s.%s couldn't be found\n", pdu->module, pdu->type); - } -#if TCL - fprintf (meta.srcfp, "#ifndef TCL\n"); - fprintf (meta.srcfp, "#define TCL META\n"); - fprintf (meta.srcfp, "#endif\n"); -#endif - fprintf (meta.srcfp, "\n"); - - fprintf (meta.srcfp, "#include \"asn-incl.h\"\n"); - FOR_EACH_LIST_ELMT (currMod, allMods) - fprintf (meta.srcfp, "#include \"%s\"\n", currMod->cxxHdrFileName); - fprintf (meta.srcfp, "\n"); - - fprintf (meta.srcfp, "#if META\n\n"); - - fprintf (meta.srcfp, "const AsnModuleDesc *asnModuleDescs[] =\n"); - fprintf (meta.srcfp, "{\n"); - FOR_EACH_LIST_ELMT (currMod, allMods) - fprintf (meta.srcfp, " &%sModuleDesc,\n", currMod->cxxname); - fprintf (meta.srcfp, " NULL\n"); - fprintf (meta.srcfp, "};\n\n"); - - if (genTcl) - { - fprintf (meta.srcfp, "#if TCL\n\n"); - - fprintf (meta.srcfp, "// hack to avoid the neccessity to list -ltk -ltcl both before and after -lasn1tcl:\n"); - fprintf (meta.srcfp, "static int (*dummy)(Tcl_Interp *) = Tcl_AppInit;\n\n"); - - fprintf (meta.srcfp, "#endif // TCL\n\n"); - } - - fprintf (meta.srcfp, "#endif // META\n"); - - fclose (meta.srcfp); - } -#endif -} /* GenCxxCode */ - - -#if IDL -/* - * Given the list of parsed, linked, normalized, error-checked and sorted - * modules, and some code generation flags, generates C++ code and - * writes it to files derived from each modules name. Each module - * gets 2 source files, one .h for data struct and prototypes, the other .C - * for the enc/dec/print/free routine code. - */ -void -GenIDLCode PARAMS ((allMods, longJmpVal, genTypes, genValues, genPrinters, genFree), - ModuleList *allMods _AND_ - long int longJmpVal _AND_ - int genTypes _AND_ - int genValues _AND_ - int genPrinters _AND_ - int genFree) -{ - Module *currMod; - char *modBaseFileName; - FILE *idlFilePtr; - DefinedObj *fNames; - int fNameConflict = FALSE; - - /* - * Make names for each module's encoder/decoder src and hdr files - * so import references can be made via include files - * check for truncation --> name conflicts & exit if nec - */ - fNames = NewObjList(); - FOR_EACH_LIST_ELMT (currMod, allMods) - { - modBaseFileName = MakeBaseFileName (keepbaseG - ? currMod->asn1SrcFileName - : currMod->modId->name); /* shorten module name if necessary (SYSV etc) */ - currMod->idlFileName = MakeIDLFileName (modBaseFileName); - { - char *in, *out; - - out = currMod->idlname = (char *)malloc (strlen (in = currMod->modId->name)+1); - do - *out++ = *in == '-' ? '_' : *in; - while (*in++); - } - - if (ObjIsDefined (fNames, currMod->idlFileName, StrObjCmp)) - { - fprintf (stderr, "Ack! ERROR---file name conflict for generated source file with name `%s'.\n\n", currMod->idlFileName); - fprintf (stderr, "This usually means the max file name length is truncating the file names.\n"); - fprintf (stderr, "Try re-naming the modules with shorter names or increasing the argument to -mf option (if you are using it).\n"); - fprintf (stderr, "This error can also be caused by 2 modules have the same names but different OBJECT IDENTIFIERs."); - fprintf (stderr, " Try renaming the modules to correct this.\n"); - fNameConflict = TRUE; - } - else - { - DefineObj (&fNames, currMod->idlFileName); - } - Free (modBaseFileName); - } - if (fNameConflict) - exit (1); - - FreeDefinedObjs (&fNames); - - /* - * make C++ files - */ - FOR_EACH_LIST_ELMT (currMod, allMods) - { - /* - * create and fill .h file for module's data structs - */ - idlFilePtr = fopen (currMod->idlFileName, "w"); - if (idlFilePtr == NULL) - perror ("fopen"); - else - { - PrintIDLCode (idlFilePtr, allMods, currMod, &idlRulesG, longJmpVal, genValues); - - fclose (idlFilePtr); - } - } -} /* GenIDLCode */ -#endif /* IDL */ - - -/* - * returns 1 if the module names and oid's are unique. - * otherwise returns 0 - */ -int ModNamesUnique PARAMS ((mods), - ModuleList *mods) -{ - DefinedObj *names; - DefinedObj *oids; - Module *m; - int retVal = 1; - - names = NewObjList(); - oids = NewObjList(); - - FOR_EACH_LIST_ELMT (m, mods) - { - if (((m->modId->oid != NULL) && - ObjIsDefined (oids, m->modId->oid, OidObjCmp))) - { - /* oops, 2 modules have the same oid */ - PrintErrLoc (m->asn1SrcFileName, 1); - fprintf (stderr, "ERROR---2 modules have the OBJECT IDENTIFIER `"); - PrintOid (stderr, m->modId->oid); - fprintf (stderr, "'.\n"); - retVal = 0; - } - /* name is only signficant if oid is empty */ - else if ((m->modId->oid == NULL) && - (ObjIsDefined (names, m->modId->name, StrObjCmp))) - { - /* oops, 2 modules have the same name */ - PrintErrLoc (m->asn1SrcFileName, 1); - fprintf (stderr, "ERROR---2 modules have the name `%s'\n", m->modId->name); - retVal = 0; - } - else - { - DefineObj (&names, m->modId->name); - if (m->modId->oid != NULL) - DefineObj (&oids, m->modId->oid); - } - } - FreeDefinedObjs (&names); - FreeDefinedObjs (&oids); - return retVal; -} /* ModNamesUnique */ diff --git a/SecuritySNACCRuntime/compiler/core/tbl.c b/SecuritySNACCRuntime/compiler/core/tbl.c deleted file mode 100644 index d6c57e26..00000000 --- a/SecuritySNACCRuntime/compiler/core/tbl.c +++ /dev/null @@ -1,574 +0,0 @@ -/* - * tbl.c - * - * "TBL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Tue Mar 19 07:24:43 2002 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "tbl.h" - - -AsnLen -BEncTBLRangeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLRange *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->to)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->from)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLRangeContent */ - - - - -AsnLen -BEncTBLNamedNumberContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumber *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->value)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLNamedNumberContent */ - - - - -AsnLen -BEncTBLNamedNumberListContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumberList *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLNamedNumberListContent */ - - - - -AsnLen -BEncTBLTypeRefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeRef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnBoolContent (b, (&v->implicit)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDef)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeRefContent */ - - - - -AsnLen -BEncTBLTagContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTag *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->code)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncTBLTagClassContent (b, (&v->tclass)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 10); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTagContent */ - - - - -AsnLen -BEncTBLTypeSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTagContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeSeqOfContent */ - - - - -AsnLen -BEncTBLTypeContentSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContentSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeContentSeqOfContent */ - - - - -AsnLen -BEncTBLTypeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLType *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->values))) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberListContent (b, (v->values)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 6); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->constraint))) - { - BEncEocIfNec (b); - itemLen = BEncTBLRangeContent (b, (v->constraint)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 5); - - totalLen += itemLen; - } - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - itemLen = BEncPrintableStringContent (b, (&v->fieldName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 4); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentContent (b, (v->content)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - if (NOT_NULL ((v->tagList))) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeSeqOfContent (b, (v->tagList)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - } - - itemLen = BEncAsnBoolContent (b, (&v->optional)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeIdContent (b, (&v->typeId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeContent */ - - - - -AsnLen -BEncTBLTypeContentContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContent *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - itemLen = BEncAsnNullContent (b, (&v->a.primType)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_ELMTS: - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentSeqOfContent (b, (v->a.elmts)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 1); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_TYPEREF: - BEncEocIfNec (b); - itemLen = BEncTBLTypeRefContent (b, (v->a.typeRef)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncTBLTypeContentContent */ - - - - -AsnLen -BEncTBLTypeDefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeDef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->isPdu))) - { - itemLen = BEncAsnNullContent (b, (v->isPdu)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 5); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, (v->type)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->typeName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 19); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDefId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeDefContent */ - - - - -AsnLen -BEncTBLModuleSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModuleSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeDefContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLModuleSeqOfContent */ - - - - -AsnLen -BEncTBLModuleContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModule *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLModuleSeqOfContent (b, (v->typeDefs)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - itemLen = BEncAsnBoolContent (b, (&v->isUseful)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - if (ASNOID_PRESENT ((&v->id))) - { - itemLen = BEncAsnOidContent (b, (&v->id)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - } - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLModuleContent */ - - - - -AsnLen -BEncTBLSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLModuleContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLSeqOfContent */ - - - - -AsnLen BEncTBL PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncTBLContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} /* BEncTBL */ - -AsnLen -BEncTBLContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLSeqOfContent (b, (v->modules)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalLenStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTags)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypes)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypeDefs)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumModules)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLContent */ - - - - diff --git a/SecuritySNACCRuntime/compiler/core/tbl.h b/SecuritySNACCRuntime/compiler/core/tbl.h deleted file mode 100644 index 6d4b19e2..00000000 --- a/SecuritySNACCRuntime/compiler/core/tbl.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * tbl.h - * - * "TBL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Tue Mar 19 07:24:43 2002 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _tbl_h_ -#define _tbl_h_ - - - - -typedef enum - { - TBL_BOOLEAN = 0, - TBL_INTEGER = 1, - TBL_BITSTRING = 2, - TBL_OCTETSTRING = 3, - TBL_NULL = 4, - TBL_OID = 5, - TBL_REAL = 6, - TBL_ENUMERATED = 7, - TBL_SEQUENCE = 8, - TBL_SET = 9, - TBL_SEQUENCEOF = 10, - TBL_SETOF = 11, - TBL_CHOICE = 12, - TBL_TYPEREF = 13 - } TBLTypeId; /* ENUMERATED { TBL_BOOLEAN (0), TBL_INTEGER (1), TBL_BITSTRING (2), TBL_OCTETSTRING (3), TBL_NULL (4), TBL_OID (5), TBL_REAL (6), TBL_ENUMERATED (7), TBL_SEQUENCE (8), TBL_SET (9), TBL_SEQUENCEOF (10), TBL_SETOF (11), TBL_CHOICE (12), TBL_TYPEREF (13) } */ - -#define BEncTBLTypeIdContent BEncAsnEnumContent - - - - -typedef AsnInt TBLTypeDefId; /* INTEGER */ - -#define BEncTBLTypeDefIdContent BEncAsnIntContent - - - - -typedef enum - { - UNIVERSAL = 0, - APPLICATION = 1, - CONTEXT = 2, - PRIVATE = 3 - } TBLTagClass; /* ENUMERATED { UNIVERSAL (0), APPLICATION (1), CONTEXT (2), PRIVATE (3) } */ - -#define BEncTBLTagClassContent BEncAsnEnumContent - - - - -typedef struct TBLRange /* SEQUENCE */ -{ - AsnInt from; /* [0] IMPLICIT INTEGER */ - AsnInt to; /* [1] IMPLICIT INTEGER */ -} TBLRange; - -AsnLen BEncTBLRangeContent PROTO ((BUF_TYPE b, TBLRange *v)); - - - - -typedef struct TBLNamedNumber /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnInt value; /* [1] IMPLICIT INTEGER */ -} TBLNamedNumber; - -AsnLen BEncTBLNamedNumberContent PROTO ((BUF_TYPE b, TBLNamedNumber *v)); - - - - -typedef AsnList TBLNamedNumberList; /* SEQUENCE OF TBLNamedNumber */ - -AsnLen BEncTBLNamedNumberListContent PROTO ((BUF_TYPE b, TBLNamedNumberList *v)); - - - - -typedef struct TBLTypeRef /* SEQUENCE */ -{ - TBLTypeDefId typeDef; /* TBLTypeDefId */ - AsnBool implicit; /* BOOLEAN */ -} TBLTypeRef; - -AsnLen BEncTBLTypeRefContent PROTO ((BUF_TYPE b, TBLTypeRef *v)); - - - - -typedef struct TBLTag /* SEQUENCE */ -{ - TBLTagClass tclass; /* TBLTagClass */ - AsnInt code; /* INTEGER (0..MAX) */ -} TBLTag; - -AsnLen BEncTBLTagContent PROTO ((BUF_TYPE b, TBLTag *v)); - - - - -typedef AsnList TBLTypeSeqOf; /* SEQUENCE OF TBLTag */ - -AsnLen BEncTBLTypeSeqOfContent PROTO ((BUF_TYPE b, TBLTypeSeqOf *v)); - - - - -typedef AsnList TBLTypeContentSeqOf; /* SEQUENCE OF TBLType */ - -AsnLen BEncTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, TBLTypeContentSeqOf *v)); - - - - -typedef struct TBLType /* SEQUENCE */ -{ - TBLTypeId typeId; /* [0] IMPLICIT TBLTypeId */ - AsnBool optional; /* [1] IMPLICIT BOOLEAN */ - TBLTypeSeqOf* tagList; /* [2] IMPLICIT TBLTypeSeqOf OPTIONAL */ - struct TBLTypeContent* content; /* [3] TBLTypeContent */ - PrintableString fieldName; /* [4] IMPLICIT PrintableString OPTIONAL */ - struct TBLRange* constraint; /* [5] IMPLICIT TBLRange OPTIONAL */ - TBLNamedNumberList* values; /* [6] IMPLICIT TBLNamedNumberList OPTIONAL */ -} TBLType; - -AsnLen BEncTBLTypeContent PROTO ((BUF_TYPE b, TBLType *v)); - - - - -typedef struct TBLTypeContent /* CHOICE */ -{ - enum TBLTypeContentChoiceId - { - TBLTYPECONTENT_PRIMTYPE, - TBLTYPECONTENT_ELMTS, - TBLTYPECONTENT_TYPEREF - } choiceId; - union TBLTypeContentChoiceUnion - { - AsnNull primType; /* [0] IMPLICIT NULL */ - TBLTypeContentSeqOf* elmts; /* [1] IMPLICIT TBLTypeContentSeqOf */ - struct TBLTypeRef* typeRef; /* [2] IMPLICIT TBLTypeRef */ - } a; -} TBLTypeContent; - -AsnLen BEncTBLTypeContentContent PROTO ((BUF_TYPE b, TBLTypeContent *v)); - - - - -typedef struct TBLTypeDef /* SEQUENCE */ -{ - TBLTypeDefId typeDefId; /* TBLTypeDefId */ - PrintableString typeName; /* PrintableString */ - struct TBLType* type; /* TBLType */ - AsnNull* isPdu; /* NULL OPTIONAL */ -} TBLTypeDef; - -AsnLen BEncTBLTypeDefContent PROTO ((BUF_TYPE b, TBLTypeDef *v)); - - - - -typedef AsnList TBLModuleSeqOf; /* SEQUENCE OF TBLTypeDef */ - -AsnLen BEncTBLModuleSeqOfContent PROTO ((BUF_TYPE b, TBLModuleSeqOf *v)); - - - - -typedef struct TBLModule /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnOid id; /* [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL */ - AsnBool isUseful; /* [2] IMPLICIT BOOLEAN */ - TBLModuleSeqOf* typeDefs; /* [3] IMPLICIT TBLModuleSeqOf */ -} TBLModule; - -AsnLen BEncTBLModuleContent PROTO ((BUF_TYPE b, TBLModule *v)); - - - - -typedef AsnList TBLSeqOf; /* SEQUENCE OF TBLModule */ - -AsnLen BEncTBLSeqOfContent PROTO ((BUF_TYPE b, TBLSeqOf *v)); - - - - -typedef struct TBL /* SEQUENCE */ -{ - AsnInt totalNumModules; /* INTEGER */ - AsnInt totalNumTypeDefs; /* INTEGER */ - AsnInt totalNumTypes; /* INTEGER */ - AsnInt totalNumTags; /* INTEGER */ - AsnInt totalNumStrings; /* INTEGER */ - AsnInt totalLenStrings; /* INTEGER */ - TBLSeqOf* modules; /* TBLSeqOf */ -} TBL; - -AsnLen BEncTBL PROTO ((BUF_TYPE b, TBL *v)); - -AsnLen BEncTBLContent PROTO ((BUF_TYPE b, TBL *v)); - - - - - -#endif /* conditional include of tbl.h */ diff --git a/SecuritySNACCRuntime/compiler/core/tblCompiler.c b/SecuritySNACCRuntime/compiler/core/tblCompiler.c deleted file mode 100644 index a3362278..00000000 --- a/SecuritySNACCRuntime/compiler/core/tblCompiler.c +++ /dev/null @@ -1,574 +0,0 @@ -/* - * tbl.c - * - * "TBL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Mon Jun 2 11:23:51 1997 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "tbl.h" - - -AsnLen -BEncTBLRangeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLRange *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->to)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->from)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLRangeContent */ - - - - -AsnLen -BEncTBLNamedNumberContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumber *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->value)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLNamedNumberContent */ - - - - -AsnLen -BEncTBLNamedNumberListContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumberList *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLNamedNumberListContent */ - - - - -AsnLen -BEncTBLTypeRefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeRef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnBoolContent (b, (&v->implicit)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDef)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeRefContent */ - - - - -AsnLen -BEncTBLTagContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTag *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->code)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncTBLTagClassContent (b, (&v->tclass)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 10); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTagContent */ - - - - -AsnLen -BEncTBLTypeSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTagContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeSeqOfContent */ - - - - -AsnLen -BEncTBLTypeContentSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContentSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeContentSeqOfContent */ - - - - -AsnLen -BEncTBLTypeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLType *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->values))) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberListContent (b, (v->values)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 6); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->constraint))) - { - BEncEocIfNec (b); - itemLen = BEncTBLRangeContent (b, (v->constraint)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 5); - - totalLen += itemLen; - } - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - itemLen = BEncPrintableStringContent (b, (&v->fieldName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 4); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentContent (b, (v->content)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - if (NOT_NULL ((v->tagList))) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeSeqOfContent (b, (v->tagList)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - } - - itemLen = BEncAsnBoolContent (b, (&v->optional)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeIdContent (b, (&v->typeId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeContent */ - - - - -AsnLen -BEncTBLTypeContentContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContent *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - itemLen = BEncAsnNullContent (b, (&v->a.primType)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_ELMTS: - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentSeqOfContent (b, (v->a.elmts)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 1); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_TYPEREF: - BEncEocIfNec (b); - itemLen = BEncTBLTypeRefContent (b, (v->a.typeRef)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncTBLTypeContentContent */ - - - - -AsnLen -BEncTBLTypeDefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeDef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->isPdu))) - { - itemLen = BEncAsnNullContent (b, (v->isPdu)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 5); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, (v->type)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->typeName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 19); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDefId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeDefContent */ - - - - -AsnLen -BEncTBLModuleSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModuleSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeDefContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLModuleSeqOfContent */ - - - - -AsnLen -BEncTBLModuleContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModule *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLModuleSeqOfContent (b, (v->typeDefs)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - itemLen = BEncAsnBoolContent (b, (&v->isUseful)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - if (ASNOID_PRESENT ((&v->id))) - { - itemLen = BEncAsnOidContent (b, (&v->id)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - } - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLModuleContent */ - - - - -AsnLen -BEncTBLSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLModuleContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLSeqOfContent */ - - - - -AsnLen BEncTBL PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncTBLContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} /* BEncTBL */ - -AsnLen -BEncTBLContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLSeqOfContent (b, (v->modules)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalLenStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTags)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypes)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypeDefs)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumModules)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLContent */ - - - - diff --git a/SecuritySNACCRuntime/compiler/core/val-parser.c b/SecuritySNACCRuntime/compiler/core/val-parser.c deleted file mode 100644 index b3c2745f..00000000 --- a/SecuritySNACCRuntime/compiler/core/val-parser.c +++ /dev/null @@ -1,734 +0,0 @@ -/* - * compiler/core/val_parser.c - * given a string with txt ASN.1 value notation, the length of - * the string and the ASN.1 type the value notion defines a value - * for, return a Value that contains the internal version - * - * - * currently limited to parsing OBJECT IDENTIFIERs. - * should be easy to extend for other values as needed - * - * Copyright (C) 1991, 1992 Michael Sample - * and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/val-parser.c,v 1.1 2001/06/20 21:27:59 dmitch Exp $ - * $Log: val-parser.c,v $ - * Revision 1.1 2001/06/20 21:27:59 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:53 aram - * Originals from SMIME Free Library. - * - * Revision 1.4 1997/10/10 13:43:16 wan - * Corrected bug in generic table decoder wrt. indefinite length elements - * Corrected compiler access to freed memory (bug reported by Markku Savela) - * Broke asnwish.c into two pieces so that one can build ones on wish - * Added beredit tool (based on asnwish, allowes to edit BER messages) - * - * Revision 1.3 1995/07/25 19:41:46 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/09/01 00:47:33 rj - * snacc_config.h removed; val_parser.h includet. - * - * Revision 1.1 1994/08/28 09:49:44 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - - -#include /* for isalpha, isdigit etc macros */ -#include - -#include "asn-incl.h" -#include "asn1module.h" -#include "mem.h" -#include "snacc-util.h" -#include "oid.h" /* arcname->number mapping */ -#include "val-parser.h" - -/* - * a bunch of macros for 'standard' parse routines - */ -#define P_LOCALS\ - char *startStr - -#define SAVE_POS()\ - startStr = *vStr; - -#define RESTORE_POS()\ - *vStr = startStr; - -#define AT_EOF()\ - (*vStr == eof) - -#define FAIL()\ -{\ - if (*vStr > farthestPosG)\ - farthestPosG = *vStr;\ - RESTORE_POS();\ - return FALSE;\ -} - -#define SUCCEED()\ - return TRUE; - -#define FATAL_ERR()\ - parseValuesErrG = 1; - -/* - * a couple macros for errmsg generation - */ -#define PRINT_ERR_LOC(m, vd)\ - fprintf (stderr,"file \"%s\", line %d (or near): ", m->asn1SrcFileName, valLineNoG); - - -#define PRINT_VAL(vd)\ - PrintValueDef (stderr, vd); - -/* - * globals - */ -static ValueDefList *newValsG; -static int parseValuesErrG; -static unsigned long valLineNoG; -static char *farthestPosG; - -/* - * prototypes for non-exported routines - */ -char *StripComments PROTO ((char *asn1Str, int len)); -Value *ParseValue PROTO ((ModuleList *mods, Module *m, ValueDef *vd, Type *t, char *valueNotation, int len)); - -Value *ParseValueInternal PROTO ((ModuleList *mods, Module *m, ValueDef *vd, Type *t, char **valueNotation, char *eof)); - -int ParseOidValue PROTO ((ModuleList *mods, Module *m, ValueDef *vd, Type *t, char **valueNotation, char *eof, Value **result)); - -void SkipWht PROTO ((char **vStr, char *eof)); -int ParseIdentifier PROTO ((char **valueNotation, char *eof, char **result)); -int ParseNum PROTO ((char **valueNotation, char *eof, char **result)); -void AddNewValueDef PROTO ((ValueDefList *vdl, char *name, Value *value)); - - - -/* - * returns 0 if no parse errors occurred - * otherwise returns non-zero - */ -int -ParseValues PARAMS ((mods, m), - ModuleList *mods _AND_ - Module *m) -{ - ValueDef *v; - Value *pv; - - newValsG = AsnListNew (sizeof (void*)); - - FOR_EACH_LIST_ELMT (v, m->valueDefs) - { - if (v->value->basicValue->choiceId == BASICVALUE_VALUENOTATION) - { - valLineNoG = v->value->lineNo; - pv = ParseValue (mods, m, v, v->value->type, v->value->basicValue->a.valueNotation->octs, v->value->basicValue->a.valueNotation->octetLen); - - /* replace value notation value with parsed version */ - if (pv != NULL) - { - pv->lineNo = v->value->lineNo; - pv->type = v->value->type; - Free (v->value->basicValue->a.valueNotation->octs); - Free (v->value->basicValue->a.valueNotation); - Free (v->value->basicValue); - Free (v->value); - v->value = pv; - } - } - } - - /* - * should traverse type structures for default values etc - * that need parsing - */ - - /* add any new value defs */ - m->valueDefs = AsnListConcat (m->valueDefs, newValsG); - Free (newValsG); - - return parseValuesErrG; - -} /* ParseValues */ - - - -/* - * returns the Value that resuls from parsing the given - * value notation string - */ -Value* -ParseValue PARAMS ((mods, m, vd, t, valueNotationStr, vnLen), - ModuleList *mods _AND_ - Module *m _AND_ - ValueDef *vd _AND_ - Type *t _AND_ - char *valueNotationStr _AND_ - int vnLen) -{ - char *vStr; - char *vStrOrig; - int vStrLen; - Value *retVal; - - /* make copy of value notation with ASN.1 comments zapped */ - vStrOrig = vStr = StripComments (valueNotationStr, vnLen); - vStrLen = strlen (vStr); - - retVal = ParseValueInternal (mods, m, vd, t, &vStr, (vStr + vStrLen)); - - /* use original since parsing has changed vStr */ - free (vStrOrig); - - return retVal; -} - -/* - * vStr is a handle to a commentless ASN.1 value string, - * eof is a char * to character after the last valid character - * in vStr. vStr will be advanced to the current parse location. - */ -Value* -ParseValueInternal PARAMS ((mods, m, vd, t, vStr, eof), - ModuleList *mods _AND_ - Module *m _AND_ - ValueDef *vd _AND_ - Type *t _AND_ - char **vStr _AND_ - char *eof) -{ - Type *dT; - Value *retVal; - int parseResult = FALSE; - - dT = ParanoidGetType (t); /* skip type refs to get defining type */ - - if (dT == NULL) - return NULL; - - retVal = NULL; - - switch (dT->basicType->choiceId) - { - case BASICTYPE_SEQUENCE: - case BASICTYPE_SET: - case BASICTYPE_CHOICE: - case BASICTYPE_SEQUENCEOF: - case BASICTYPE_SETOF: - /* don't do constructed types yet */ - break; - - - case BASICTYPE_SELECTION: - case BASICTYPE_COMPONENTSOF: - case BASICTYPE_ANYDEFINEDBY: - case BASICTYPE_UNKNOWN: - case BASICTYPE_ANY: - /* don't do weird types */ - break; - - - /* - * The following simple types will need to be filled in - * when the constructed types are parsed. - * (ie ParseValueInternal becomes recursive) - * (currenly all simple types not in {}'s are parsed - * in the main yacc parser.) - */ - - case BASICTYPE_BOOLEAN: - break; - - case BASICTYPE_INTEGER: - case BASICTYPE_ENUMERATED: - break; - - case BASICTYPE_REAL: - break; - - case BASICTYPE_BITSTRING: - break; - - case BASICTYPE_NULL: - break; - - case BASICTYPE_OCTETSTRING: - break; - - - /* assume all macro values in {}'s are OID values */ - case BASICTYPE_OID: - case BASICTYPE_MACROTYPE: - parseResult = ParseOidValue (mods, m, vd, t, vStr, eof, &retVal); - if (!parseResult) - FATAL_ERR(); - break; - - - default: - break; - } - - if (parseResult) - return retVal; - else - return NULL; - -} /* ParseValueInternal */ - - -/* - * Strips ASN.1 comments from the given string. - * returns a null terminated malloc'd copy without the comments - */ -char* -StripComments PARAMS ((s, len), - char *s _AND_ - int len) -{ - char *cpy; - int sIndex, cpyIndex; - int inComment; - - cpy = (char*)Malloc (len +1); - cpyIndex = 0; - for (sIndex = 0; sIndex < len; ) - { - if ((s[sIndex] == '-') && - ((sIndex+1) < len) && (s[sIndex+1]== '-')) - { - /* eat comment body */ - for (sIndex += 2; sIndex < len; ) - { - if ((s[sIndex] == '-') && - ((sIndex+1) < len) && (s[sIndex+1]== '-')) - { - sIndex += 2; - break; /* exit for */ - } - else if (s[sIndex] == '\n') - { - sIndex++; - break; /* exit for */ - } - else - sIndex++; - } - } - else /* not in or start of comment */ - cpy[cpyIndex++] = s[sIndex++]; - } - - cpy[cpyIndex] == '\0'; /* add NULL terminator */ - return cpy; -} /* StripComments */ - - - - -/* - * Returns TRUE if successfully parsed an OID - * otherwise returns FALSE. Puts the resulting OID Value in - * result if successful. - * The result Value's type is BASICVALUE_LINKEDOID - * - * Pseudo reg expr of the expected oid format: - * "{" - * (oid_val_ref)? - *(defined_oid_elmt_name | digit+ | int_or_enum_val_ref |name"(" digit")")* - * "}" - * - * Does not attempt to link/lookup referenced values - * - * eg - * for { ccitt foo (1) bar bell (bunt) 2 } - * - * ccitt - * arcnum is set to number from oid table (oid.c) - * foo (1) - * - arcnum set to 1 - * - sets up a new integer value def "foo" - * defined as 1 *CHANGED -see changes* - * - makes oid valueref a value ref to foo (doesn't link it tho) - * bar - * - makes oid valueref a value ref to bar (doesn't link it tho) - * bell (bunt) - * - sets up a new integer value def "bell" defined - * as a val ref to "bunt" *CHANGED -see changes* - * - makes oid valueref a value ref to bell (doesn't link it tho) - * 2 - * -arc num is set to 2 - * - * CHANGES: - * 93/05/03 - named arcs such as foo (1) or bell (bunt) handling - * changed. The names (foo and bell) are now ignored - * and *do not* define new integer values. - * The old way led to problems of defining some values - * more than once. E.g. in X.500 the { .. ds (5) } - * arc name is used everywhere - "ds INTEGER ::= 5" - * was defined multiple times as a result. - * Then the snacc error checker halted the compilation - * since the integer value "ds" was mulitply defined. - * - */ -int -ParseOidValue PARAMS ((mods, m, vd, t, vStr, eof, result), - ModuleList *mods _AND_ - Module *m _AND_ - ValueDef *vd _AND_ - Type *t _AND_ - char **vStr _AND_ - char *eof _AND_ - Value **result) -{ - Value *newVal; - Type *newType; - Value *oidVal; - OID *parsedOid; - OID **nextOid; - char *id; - char *id2; - char *id3; - char *num; - int arcNum; - int namedNumVal; - P_LOCALS; - - - SAVE_POS(); - - if (AT_EOF()) - { - PRINT_ERR_LOC (m, vd); - fprintf (stderr,"ERROR - expecting more data in OBJECT IDENTIFER value\n"); - FAIL(); - } - - SkipWht (vStr, eof); - - if (**vStr != '{') - { - PRINT_ERR_LOC (m, vd); - fprintf (stderr,"ERROR - OBJECT IDENTIFER values must begin with an \"{\".\n"); - FAIL(); - } - else - (*vStr)++; /* skip opening { */ - - SkipWht (vStr, eof); - - parsedOid = NULL; - nextOid = &parsedOid; - - while (**vStr != '}') - { - if (ParseIdentifier (vStr, eof, &id)) - { - /* - * check for named number ident (num) or ident (valref) - * make a new value def with the name ident if is name - * and number form - */ - SkipWht (vStr, eof); - if (**vStr == '(') - { - - (*vStr)++; /* skip opening ( */ - SkipWht (vStr, eof); - - arcNum = NULL_OID_ARCNUM; - /* - * ident (num)/ident (valref) yields a new value definition - * ident. The oid then refences this new value def. - */ - - /* - * first case check if of form - * { ... ident (valref) ... } - */ - if (ParseIdentifier (vStr, eof, &id2)) - { - id3 = NULL; - /* check if modname.val format */ - if (**vStr == '.') - { - (*vStr)++; - if (!ParseIdentifier (vStr, eof, &id3)) - { - PRINT_ERR_LOC (m, vd); - fprintf (stderr,"ERROR - missing a module name after the \"%s.\" value reference", id2); - FAIL(); - } - } - - /* grab closing ) */ - SkipWht (vStr, eof); - if (**vStr == ')') - (*vStr)++; - else - { - PRINT_ERR_LOC (m, vd); - fprintf (stderr,"ERROR - missing a closing \")\", after the \"%s\" value reference.\n", id2); - FAIL(); - } - - if (id3 != NULL) /* modname.val format */ - { - SetupValue (&newVal, BASICVALUE_IMPORTVALUEREF,valLineNoG); - newVal->basicValue->a.importValueRef = - (ValueRef*)Malloc (sizeof (ValueRef)); - newVal->basicValue->a.importValueRef->valueName = id2; - newVal->basicValue->a.importValueRef->moduleName = id3; - - AddPrivateImportElmt (m, id2, id3, valLineNoG); - - } - else - { - SetupValue (&newVal, BASICVALUE_LOCALVALUEREF,valLineNoG); - newVal->basicValue->a.localValueRef = - (ValueRef*)Malloc (sizeof (ValueRef)); - newVal->basicValue->a.localValueRef->valueName = id2; - } - - } - /* check this form { ... ident (2)...}*/ - else if (ParseNum (vStr, eof, &num)) - { - /* grab closing ) */ - SkipWht (vStr, eof); - if (**vStr == ')') - (*vStr)++; - else - { - PRINT_ERR_LOC (m, vd); - fprintf (stderr,"ERROR - missing a closing \")\" after the \"%s (%s\".\n", id2, num); - Free (num); - FAIL(); - } - arcNum = atoi (num); - Free (num); - newVal = NULL; - } - else /* neither an ident or num after the "(" */ - { - PRINT_ERR_LOC (m, vd); - fprintf (stderr,"ERROR - expecting either a value reference or number after the \"(\".\n"); - FAIL(); - } - - *nextOid = (OID*) Malloc (sizeof (OID)); - (*nextOid)->valueRef = newVal; - (*nextOid)->arcNum = arcNum; - nextOid = &(*nextOid)->next; - - } /* end of ident (num) and ident (ident) form */ - - else /* value ref: { ... ident .... } */ - { - *nextOid = (OID*) Malloc (sizeof (OID)); - (*nextOid)->arcNum = NULL_OID_ARCNUM; - - /* - * check if special defined oid elmt name - * like joint-iso-ccitt, iso, standard etc. - */ - - arcNum = OidArcNameToNum (id); - if (arcNum != -1) - { - (*nextOid)->arcNum = arcNum; - } - else /* value reference */ - { - SetupValue (&newVal, BASICVALUE_LOCALVALUEREF,valLineNoG); - newVal->basicValue->a.localValueRef = - (ValueRef*)Malloc (sizeof (ValueRef)); - newVal->basicValue->a.localValueRef->valueName = id; - - (*nextOid)->valueRef = newVal; - } - nextOid = &(*nextOid)->next; - } - } - else if (ParseNum (vStr, eof, &num)) /* { .. 2 .. } */ - { - *nextOid = (OID*) Malloc (sizeof (OID)); - (*nextOid)->arcNum = atoi (num); - nextOid = &(*nextOid)->next; - Free (num); - } - else - { - PRINT_ERR_LOC (m, vd); - fprintf (stderr,"ERROR - bady formed arc number\n"); - FAIL(); - } - - SkipWht (vStr, eof); - } - - (*vStr)++; /* move over closing } */ - - SetupValue (&oidVal, BASICVALUE_LINKEDOID, valLineNoG); - oidVal->basicValue->a.linkedOid = parsedOid; - *result = oidVal; - SUCCEED(); -} - - -void -SkipWht PARAMS ((vStr, eof), - char **vStr _AND_ - char *eof) -{ - while (!AT_EOF()) - switch (**vStr) - { - case '\n': /* newline */ - case '\f': /* form feed ?*/ - case '\v': /* vertical tab ?*/ - case '\r': valLineNoG++; /* carriage return */ - case '\t': /* tab */ - case ' ': /* space */ - case '\007': /* bell? */ - case '\b': /* back spc */ - (*vStr)++; - break; - - default: - return; - } -} - - -/* - * advances the vStr over ASN.1 identifier, returns a copy - * in result, and returns TRUE. otherwise returns FALSE - * - * ASN.1 identifier is: lowercase letter followed by a - * string of letters (upper and lower case allowed), digtits, or single - * hyphens. last char cannot be a hyphen. - */ -int -ParseIdentifier PARAMS ((vStr, eof, result), - char **vStr _AND_ - char *eof _AND_ - char **result) -{ - char *start; - int len; - P_LOCALS; - - SAVE_POS(); - - if (AT_EOF()) - FAIL(); - - start = *vStr; - if (!islower (**vStr)) - FAIL(); - - (*vStr)++; - - while (!AT_EOF()) - { - /* allow letters, digits and single hyphens */ - if ((isalpha (**vStr)) || isdigit (**vStr) || - ((**vStr == '-') && !(*(*vStr - 1) == '-'))) - (*vStr)++; - else - break; /* exit for loop */ - - } - - /* don't allow hyphens on the end */ - if (*(*vStr - 1) == '-') - (*vStr)--; - - len = *vStr - start; - *result = Malloc (len +1); - strncpy (*result, start, len); - (*result)[len] = '\0'; /* null terminate */ - - SUCCEED(); -} /* ParseIdentifier */ - - - -/* - * advances the vStr over ASN.1 number, returns a - * null terminated ascii copy of the number - * in result, and returns TRUE. otherwise returns FALSE - */ -int -ParseNum PARAMS ((vStr, eof, result), - char **vStr _AND_ - char *eof _AND_ - char **result) -{ - P_LOCALS; - char *start; - int len; - - SAVE_POS(); - - if (AT_EOF()) - FAIL(); - - start = *vStr; - - while (!AT_EOF()) - { - if (isdigit (**vStr)) - (*vStr)++; - else - break; /* exit for loop */ - } - len = *vStr - start; - - if (len == 0) - FAIL(); - - *result = Malloc (len +1); - strncpy (*result, start, len); - (*result)[len] = '\0'; /* null terminate */ - - SUCCEED(); -} /* ParseNum */ - -/* - * adds a new value def to the vdl. Used - * when parsing oid's that defined arc values - * eg { 1 2 foo (3) } --> defined foo INTEGER ::= 3 - * (should be foo INTEGER (0..MAX) ::= 3) - */ -void -AddNewValueDef PARAMS ((vdl, name, value), - ValueDefList *vdl _AND_ - char *name _AND_ - Value *value) -{ - ValueDef *vd; - ValueDef **tmpVd; - - vd = (ValueDef*)Malloc (sizeof (ValueDef)); - vd->definedName = name; - vd->value = value; - tmpVd = (ValueDef**)AsnListAppend (vdl); - *tmpVd = vd; -} /* AddNewValueDef */ diff --git a/SecuritySNACCRuntime/compiler/core/val-parser.h b/SecuritySNACCRuntime/compiler/core/val-parser.h deleted file mode 100644 index fee3ce4f..00000000 --- a/SecuritySNACCRuntime/compiler/core/val-parser.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * compiler/core/val_parser.h - * - * Value *ParseValue (Type *t, char *valueNotation, int vnlen); - * given a string with txt ASN.1 value notation, the length of - * the string and the ASN.1 type the value notion defines a value - * for, return a Value that contains the internal version - * - * - * Copyright (C) 1992 Michael Sample and the University of British Columbia - * - * 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. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/core/Attic/val-parser.h,v 1.1 2001/06/20 21:27:59 dmitch Exp $ - * $Log: val-parser.h,v $ - * Revision 1.1 2001/06/20 21:27:59 dmitch - * Adding missing snacc compiler files. - * - * Revision 1.1.1.1 1999/03/16 18:06:53 aram - * Originals from SMIME Free Library. - * - * Revision 1.3 1995/07/25 19:41:48 rj - * changed `_' to `-' in file names. - * - * Revision 1.2 1994/08/31 21:47:26 rj - * adjust the function declaration to the function definition. this went undetected because the .c file didn't include its .h file. - * - * Revision 1.1 1994/08/28 09:49:45 rj - * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. - * - */ - - -int ParseValues PROTO ((ModuleList *mods, Module *m)); diff --git a/SecuritySNACCRuntime/compiler/dependencies b/SecuritySNACCRuntime/compiler/dependencies deleted file mode 100644 index 8267080e..00000000 --- a/SecuritySNACCRuntime/compiler/dependencies +++ /dev/null @@ -1,766 +0,0 @@ -lex-asn1.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/exports.h core/parse-asn1.h core/parser.h \ - core/lex-stuff.h /usr/include/errno.h /usr/include/sys/errno.h -parse-asn1.o : ../snacc.h ../config.h /usr/include/stdlib.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/sys/cdefs.h ../policy.h /usr/include/string.h \ - /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/lib-types.h core/snacc-util.h core/exports.h \ - core/parser.h core/lex-stuff.h -define.o : ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h \ - /usr/include/stdio.h /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h ../c-lib/inc/mem.h \ - ../c-lib/inc/exp-buf.h ../c-lib/inc/print.h ../c-lib/inc/asn-len.h \ - ../c-lib/inc/asn-tag.h ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h \ - ../c-lib/inc/asn-enum.h ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h \ - ../c-lib/inc/asn-bits.h ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h \ - ../c-lib/inc/asn-any.h ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h \ - ../c-lib/inc/asn-useful.h core/define.h -dependency.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/snacc-util.h core/dependency.h -do-macros.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/ctype.h /usr/include/runetype.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h back-ends/str-util.h core/normalize.h \ - core/snacc-util.h core/do-macros.h -err-chk.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/snacc-util.h back-ends/tag-util.h core/define.h \ - core/err-chk.h -exports.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/snacc-util.h core/exports.h -gen-tbls.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/tbl.h core/gen-tbls.h -lib-types.o : ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h \ - /usr/include/stdio.h /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h ../c-lib/inc/mem.h \ - ../c-lib/inc/exp-buf.h ../c-lib/inc/print.h ../c-lib/inc/asn-len.h \ - ../c-lib/inc/asn-tag.h ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h \ - ../c-lib/inc/asn-enum.h ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h \ - ../c-lib/inc/asn-bits.h ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h \ - ../c-lib/inc/asn-any.h ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h \ - ../c-lib/inc/asn-useful.h core/asn1module.h core/lib-types.h -link-types.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/snacc-util.h core/link-types.h -link-values.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/snacc-util.h core/link-values.h -mem.o : ../snacc.h ../config.h /usr/include/stdlib.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/sys/cdefs.h ../policy.h /usr/include/stdio.h \ - /usr/include/sys/types.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/mem.h -meta.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h core/meta.h -normalize.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/oid.h core/lib-types.h core/snacc-util.h \ - core/normalize.h -oid.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/oid.h -print.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/lib-types.h core/print.h -recursive.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/recursive.h core/snacc-util.h -snacc.o : ../snacc.h ../config.h /usr/include/stdlib.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/sys/cdefs.h ../policy.h /usr/include/sys/time.h \ - /usr/include/sys/types.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/time.h \ - /usr/include/machine/limits.h /usr/include/ppc/limits.h \ - /usr/include/string.h /usr/include/stdio.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - ../version.h core/asn1module.h core/exports.h core/parser.h \ - core/dependency.h core/link-types.h core/link-values.h core/err-chk.h \ - core/print.h core/recursive.h core/define.h core/normalize.h \ - core/do-macros.h core/snacc-util.h core/meta.h back-ends/str-util.h \ - back-ends/c-gen/rules.h back-ends/c-gen/type-info.h \ - back-ends/c-gen/gen-code.h back-ends/c++-gen/rules.h \ - back-ends/c++-gen/types.h back-ends/c++-gen/gen-code.h core/gen-tbls.h \ - back-ends/idl-gen/rules.h back-ends/idl-gen/types.h \ - back-ends/idl-gen/gen-code.h -snacc-util.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/lib-types.h core/define.h core/snacc-util.h -val-parser.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/snacc-util.h core/oid.h core/val-parser.h -str-util.o : ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h \ - /usr/include/stdio.h /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h ../c-lib/inc/mem.h \ - ../c-lib/inc/exp-buf.h ../c-lib/inc/print.h ../c-lib/inc/asn-len.h \ - ../c-lib/inc/asn-tag.h ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h \ - ../c-lib/inc/asn-enum.h ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h \ - ../c-lib/inc/asn-bits.h ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h \ - ../c-lib/inc/asn-any.h ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h \ - ../c-lib/inc/asn-useful.h /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/unistd.h /usr/include/string.h core/asn1module.h \ - core/define.h back-ends/c-gen/rules.h back-ends/c-gen/type-info.h \ - back-ends/c-gen/kwd.h back-ends/c++-gen/kwd.h back-ends/str-util.h -tag-util.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h core/lib-types.h back-ends/c-gen/rules.h \ - back-ends/c-gen/type-info.h back-ends/str-util.h core/snacc-util.h \ - back-ends/c-gen/util.h back-ends/tag-util.h -cond.o : ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h \ - /usr/include/stdio.h /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h ../c-lib/inc/mem.h \ - ../c-lib/inc/exp-buf.h ../c-lib/inc/print.h ../c-lib/inc/asn-len.h \ - ../c-lib/inc/asn-tag.h ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h \ - ../c-lib/inc/asn-enum.h ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h \ - ../c-lib/inc/asn-bits.h ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h \ - ../c-lib/inc/asn-any.h ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h \ - ../c-lib/inc/asn-useful.h back-ends/cond.h -type-info.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/snacc-util.h core/define.h back-ends/str-util.h \ - back-ends/c-gen/rules.h back-ends/c-gen/type-info.h -util.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h back-ends/c-gen/rules.h core/snacc-util.h \ - back-ends/c-gen/util.h -rules.o : ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h \ - /usr/include/stdio.h /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h ../c-lib/inc/mem.h \ - ../c-lib/inc/exp-buf.h ../c-lib/inc/print.h ../c-lib/inc/asn-len.h \ - ../c-lib/inc/asn-tag.h ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h \ - ../c-lib/inc/asn-enum.h ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h \ - ../c-lib/inc/asn-bits.h ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h \ - ../c-lib/inc/asn-any.h ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h \ - ../c-lib/inc/asn-useful.h core/asn1module.h back-ends/c-gen/rules.h -gen-code.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/print.h back-ends/c-gen/rules.h \ - back-ends/c-gen/type-info.h back-ends/c-gen/util.h back-ends/cond.h \ - back-ends/c-gen/gen-type.h back-ends/c-gen/gen-enc.h \ - back-ends/c-gen/gen-dec.h back-ends/c-gen/gen-vals.h \ - back-ends/c-gen/gen-free.h back-ends/c-gen/gen-print.h \ - back-ends/c-gen/gen-any.h back-ends/c-gen/gen-code.h -gen-type.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/print.h back-ends/c-gen/rules.h \ - back-ends/c-gen/type-info.h back-ends/c-gen/util.h \ - back-ends/c-gen/gen-type.h -gen-enc.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h back-ends/c-gen/rules.h \ - back-ends/c-gen/type-info.h back-ends/str-util.h back-ends/c-gen/util.h \ - back-ends/tag-util.h core/snacc-util.h back-ends/c-gen/gen-enc.h -gen-dec.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h core/lib-types.h back-ends/c-gen/rules.h \ - back-ends/c-gen/type-info.h back-ends/str-util.h core/snacc-util.h \ - back-ends/c-gen/util.h back-ends/tag-util.h back-ends/c-gen/gen-dec.h -gen-vals.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/oid.h core/asn1module.h core/define.h core/lib-types.h \ - back-ends/c-gen/rules.h back-ends/c-gen/type-info.h back-ends/str-util.h \ - core/snacc-util.h back-ends/c-gen/util.h back-ends/c-gen/kwd.h \ - back-ends/c-gen/gen-vals.h -gen-free.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h back-ends/c-gen/rules.h \ - back-ends/c-gen/type-info.h back-ends/str-util.h back-ends/c-gen/util.h \ - back-ends/c-gen/gen-free.h -gen-print.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h back-ends/c-gen/rules.h \ - back-ends/c-gen/type-info.h back-ends/str-util.h back-ends/c-gen/util.h \ - back-ends/c-gen/gen-print.h -gen-any.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h back-ends/c-gen/rules.h core/define.h \ - back-ends/str-util.h back-ends/c-gen/gen-vals.h core/lib-types.h \ - back-ends/c-gen/gen-any.h -kwd.o : ../snacc.h ../config.h /usr/include/stdlib.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/sys/cdefs.h ../policy.h /usr/include/string.h \ - back-ends/c-gen/kwd.h -kwd.o : ../snacc.h ../config.h /usr/include/stdlib.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/sys/cdefs.h ../policy.h /usr/include/string.h \ - back-ends/c++-gen/kwd.h -types.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/define.h core/asn1module.h core/snacc-util.h back-ends/str-util.h \ - back-ends/c++-gen/rules.h back-ends/c++-gen/kwd.h \ - back-ends/c++-gen/types.h -rules.o : ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h \ - /usr/include/stdio.h /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h ../c-lib/inc/mem.h \ - ../c-lib/inc/exp-buf.h ../c-lib/inc/print.h ../c-lib/inc/asn-len.h \ - ../c-lib/inc/asn-tag.h ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h \ - ../c-lib/inc/asn-enum.h ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h \ - ../c-lib/inc/asn-bits.h ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h \ - ../c-lib/inc/asn-any.h ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h \ - ../c-lib/inc/asn-useful.h core/asn1module.h back-ends/c++-gen/rules.h -gen-code.o : ../snacc.h ../config.h /usr/include/stdlib.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/sys/cdefs.h ../policy.h /usr/include/sys/time.h \ - /usr/include/sys/types.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h /usr/include/time.h \ - /usr/include/machine/limits.h /usr/include/ppc/limits.h \ - /usr/include/string.h /usr/include/stdio.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h core/lib-types.h \ - back-ends/c++-gen/rules.h back-ends/c++-gen/types.h back-ends/cond.h \ - back-ends/str-util.h core/snacc-util.h core/print.h back-ends/tag-util.h \ - core/meta.h back-ends/c++-gen/gen-vals.h back-ends/c++-gen/gen-any.h \ - back-ends/c++-gen/gen-code.h -gen-vals.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/oid.h core/define.h core/lib-types.h \ - back-ends/str-util.h core/snacc-util.h back-ends/c++-gen/rules.h \ - back-ends/c++-gen/gen-vals.h -gen-any.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h back-ends/str-util.h \ - back-ends/c++-gen/rules.h back-ends/c++-gen/gen-vals.h core/lib-types.h \ - back-ends/c++-gen/gen-any.h -rules.o : ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h \ - /usr/include/stdio.h /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h ../c-lib/inc/mem.h \ - ../c-lib/inc/exp-buf.h ../c-lib/inc/print.h ../c-lib/inc/asn-len.h \ - ../c-lib/inc/asn-tag.h ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h \ - ../c-lib/inc/asn-enum.h ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h \ - ../c-lib/inc/asn-bits.h ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h \ - ../c-lib/inc/asn-any.h ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h \ - ../c-lib/inc/asn-useful.h core/asn1module.h back-ends/idl-gen/rules.h -types.o : /usr/include/ctype.h /usr/include/runetype.h \ - /usr/include/sys/cdefs.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/define.h core/asn1module.h core/snacc-util.h back-ends/str-util.h \ - back-ends/idl-gen/rules.h back-ends/c++-gen/kwd.h \ - back-ends/idl-gen/types.h -gen-any.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h back-ends/str-util.h \ - back-ends/idl-gen/rules.h back-ends/idl-gen/gen-vals.h core/lib-types.h \ - back-ends/idl-gen/gen-any.h -gen-code.o : ../snacc.h ../config.h /usr/include/stdlib.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/sys/cdefs.h ../policy.h /usr/include/string.h \ - /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/define.h core/lib-types.h \ - back-ends/idl-gen/rules.h back-ends/idl-gen/types.h back-ends/cond.h \ - back-ends/str-util.h core/snacc-util.h core/print.h back-ends/tag-util.h \ - back-ends/idl-gen/gen-vals.h back-ends/idl-gen/gen-any.h \ - back-ends/idl-gen/gen-code.h -gen-vals.o : /usr/include/stdio.h /usr/include/sys/types.h \ - /usr/include/sys/cdefs.h /usr/include/machine/types.h \ - /usr/include/ppc/types.h /usr/include/machine/ansi.h \ - /usr/include/ppc/ansi.h /usr/include/machine/endian.h \ - /usr/include/ppc/endian.h ../c-lib/inc/asn-incl.h \ - ../c-lib/inc/asn-config.h /usr/include/setjmp.h \ - /usr/include/machine/setjmp.h /usr/include/ppc/setjmp.h \ - /usr/include/machine/signal.h /usr/include/ppc/signal.h \ - /usr/include/math.h ../snacc.h ../config.h /usr/include/stdlib.h \ - ../policy.h ../c-lib/inc/mem.h ../c-lib/inc/exp-buf.h \ - ../c-lib/inc/print.h ../c-lib/inc/asn-len.h ../c-lib/inc/asn-tag.h \ - ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h ../c-lib/inc/asn-enum.h \ - ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h ../c-lib/inc/asn-bits.h \ - ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h ../c-lib/inc/asn-any.h \ - ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h ../c-lib/inc/asn-useful.h \ - core/asn1module.h core/oid.h core/define.h core/lib-types.h \ - back-ends/str-util.h core/snacc-util.h back-ends/idl-gen/rules.h \ - back-ends/idl-gen/gen-vals.h -tbl.o : ../c-lib/inc/asn-incl.h ../c-lib/inc/asn-config.h \ - /usr/include/stdio.h /usr/include/sys/types.h /usr/include/sys/cdefs.h \ - /usr/include/machine/types.h /usr/include/ppc/types.h \ - /usr/include/machine/ansi.h /usr/include/ppc/ansi.h \ - /usr/include/machine/endian.h /usr/include/ppc/endian.h \ - /usr/include/setjmp.h /usr/include/machine/setjmp.h \ - /usr/include/ppc/setjmp.h /usr/include/machine/signal.h \ - /usr/include/ppc/signal.h /usr/include/math.h ../snacc.h ../config.h \ - /usr/include/stdlib.h ../policy.h ../c-lib/inc/mem.h \ - ../c-lib/inc/exp-buf.h ../c-lib/inc/print.h ../c-lib/inc/asn-len.h \ - ../c-lib/inc/asn-tag.h ../c-lib/inc/asn-bool.h ../c-lib/inc/asn-int.h \ - ../c-lib/inc/asn-enum.h ../c-lib/inc/asn-real.h ../c-lib/inc/asn-octs.h \ - ../c-lib/inc/asn-bits.h ../c-lib/inc/asn-oid.h ../c-lib/inc/asn-null.h \ - ../c-lib/inc/asn-any.h ../c-lib/inc/hash.h ../c-lib/inc/asn-list.h \ - ../c-lib/inc/asn-useful.h core/tbl.h diff --git a/SecuritySNACCRuntime/compiler/install-sh b/SecuritySNACCRuntime/compiler/install-sh deleted file mode 100644 index ab74c882..00000000 --- a/SecuritySNACCRuntime/compiler/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -tranformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/SecuritySNACCRuntime/compiler/makefile b/SecuritySNACCRuntime/compiler/makefile deleted file mode 100644 index 7c9276f5..00000000 --- a/SecuritySNACCRuntime/compiler/makefile +++ /dev/null @@ -1,386 +0,0 @@ -# file: .../compiler/makefile -# -# makefile for ASN.1 '88 parser -# -# compiles the snacc ASN.1 compiler -# -# Mike Sample -# 1992 -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/compiler/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:08 mb -# Move from private repository to open source repository -# -# Revision 1.2 2000/12/22 01:11:42 dmitch -# include ../makehead.static to workaround broken autoconf. -# -# Revision 1.1.1.1 1999/03/16 18:06:38 aram -# Originals from SMIME Free Library. -# -# Revision 1.12 1997/09/03 12:50:33 wan -# Shifted parse and lex -# -# Revision 1.11 1997/03/03 11:58:33 wan -# Final pre-delivery stuff (I hope). -# -# Revision 1.10 1997/02/28 13:39:52 wan -# Modifications collected for new version 1.3: Bug fixes, tk4.2. -# -# Revision 1.9 1997/02/16 18:02:49 rj -# snacc is needed to generate the distfiles -# -# Revision 1.8 1997/02/16 12:34:47 rj -# let make clobber remove the link to install-sh that make made -# let make clean remove more created files -# -# Revision 1.7 1997/01/02 08:47:20 rj -# an option to snacc added (when compiling the tbl.asn1 file) -# -# Revision 1.6 1995/07/25 18:09:18 rj -# the compiler is compiled from two files, tbl.h and tbl.c, it generates itself. -# for bootstrapping purposes, initial versions are supplied with the distribution. -# -# `cd && make' instead of `cd; make'. -# -# create installation directories only if they do not exist already. -# -# the compiler is compiled from two files, tbl.h and tbl.c, it generates itself. -# for bootstrapping purposes, initial versions are supplied with the distribution. -# -# changed `_' to `-' in file names. -# -# Revision 1.5 1995/02/20 11:53:57 rj -# distribute install-sh. -# -# Revision 1.4 1995/02/13 15:06:52 rj -# augment CPPFLAGS, not overwrite. -# CFLAGS moved to ../makehead. -# -# Revision 1.3 1994/10/08 03:47:23 rj -# added bootstrapping functionality for asn-useful.[ch]. -# -# Revision 1.2 1994/09/01 00:08:49 rj -# gnu autoconf stuff added, DISTFILES, install phony target. -# -# Revision 1.1 1994/08/28 09:47:52 rj -# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. -# - -include ../makehead -include ../makehead.static - -TOP = .. - -ASN1_SRC_DIR = $(TOP)/asn1specs -USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 - -CORE_DIR = core -BACKEND_DIR = back-ends -C_BACKEND_DIR = $(BACKEND_DIR)/c-gen -C++_BACKEND_DIR = $(BACKEND_DIR)/c++-gen -IDL_BACKEND_DIR = $(BACKEND_DIR)/idl-gen - -ASN1_LIB_DIR = ../c-lib -ASN1_INC_DIR = $(ASN1_LIB_DIR)/inc -ASN1_BOOT_DIR = $(ASN1_LIB_DIR)/boot -ASN1_LIB = $(ASN1_LIB_DIR)/libasn1cCebuf.a - -# some CFLAG options: -# -DYYDEBUG use for yacc/lex debug info -# -DDEBUG use to get general debug info - -DEFS = -DCOMPILER -DUSE_NIBBLE_MEMORY=0 -DUSE_EXP_BUF -INCLUDES = -I$(CORE_DIR) -I$(ASN1_INC_DIR) -I$(ASN1_BOOT_DIR) -I$(BACKEND_DIR) -I$(TOP) -CPPFLAGS += $(DEFS) $(INCLUDES) - -compilerFLAGS = $(DEFS) -I../compiler/$(CORE_DIR) - -LFILES = \ - $(CORE_DIR)/lex-asn1.l -LCFILES = \ - $(CORE_DIR)/lex-asn1.c - -YFILES = \ - $(CORE_DIR)/parse-asn1.y -YHFILES = \ - $(CORE_DIR)/parse-asn1.h -YCFILES = \ - $(CORE_DIR)/parse-asn1.c - -HFILES.d = \ - $(CORE_DIR)/asn1module.h \ - $(CORE_DIR)/define.h \ - $(CORE_DIR)/dependency.h \ - $(CORE_DIR)/do-macros.h \ - $(CORE_DIR)/err-chk.h \ - $(CORE_DIR)/exports.h \ - $(CORE_DIR)/gen-tbls.h \ - $(CORE_DIR)/lex-stuff.h \ - $(CORE_DIR)/lib-types.h \ - $(CORE_DIR)/link-types.h \ - $(CORE_DIR)/link-values.h \ - $(CORE_DIR)/mem.h \ - $(CORE_DIR)/meta.h \ - $(CORE_DIR)/normalize.h \ - $(CORE_DIR)/oid.h \ - $(CORE_DIR)/parser.h \ - $(CORE_DIR)/print.h \ - $(CORE_DIR)/recursive.h \ - $(CORE_DIR)/snacc-util.h \ - $(CORE_DIR)/tbl.h \ - $(CORE_DIR)/val-parser.h \ - \ - $(BACKEND_DIR)/str-util.h \ - $(BACKEND_DIR)/tag-util.h \ - $(BACKEND_DIR)/cond.h \ - \ - $(C_BACKEND_DIR)/kwd.h \ - $(C_BACKEND_DIR)/gen-any.h \ - $(C_BACKEND_DIR)/gen-code.h \ - $(C_BACKEND_DIR)/gen-dec.h \ - $(C_BACKEND_DIR)/gen-enc.h \ - $(C_BACKEND_DIR)/gen-free.h \ - $(C_BACKEND_DIR)/gen-print.h \ - $(C_BACKEND_DIR)/gen-type.h \ - $(C_BACKEND_DIR)/gen-vals.h \ - $(C_BACKEND_DIR)/rules.h \ - $(C_BACKEND_DIR)/type-info.h \ - $(C_BACKEND_DIR)/util.h \ - \ - $(C++_BACKEND_DIR)/kwd.h \ - $(C++_BACKEND_DIR)/rules.h \ - $(C++_BACKEND_DIR)/types.h \ - $(C++_BACKEND_DIR)/gen-any.h \ - $(C++_BACKEND_DIR)/gen-code.h \ - $(C++_BACKEND_DIR)/gen-vals.h \ - \ - $(IDL_BACKEND_DIR)/rules.h \ - $(IDL_BACKEND_DIR)/types.h \ - $(IDL_BACKEND_DIR)/gen-any.h \ - $(IDL_BACKEND_DIR)/gen-code.h \ - $(IDL_BACKEND_DIR)/gen-vals.h - -HFILES = \ - $(HFILES.d) \ - $(CORE_DIR)/tbl.h - -CFILES.d = \ - $(CORE_DIR)/define.c \ - $(CORE_DIR)/dependency.c \ - $(CORE_DIR)/do-macros.c \ - $(CORE_DIR)/err-chk.c \ - $(CORE_DIR)/exports.c \ - $(CORE_DIR)/gen-tbls.c \ - $(CORE_DIR)/lib-types.c \ - $(CORE_DIR)/link-types.c \ - $(CORE_DIR)/link-values.c \ - $(CORE_DIR)/mem.c \ - $(CORE_DIR)/meta.c \ - $(CORE_DIR)/normalize.c \ - $(CORE_DIR)/oid.c \ - $(CORE_DIR)/print.c \ - $(CORE_DIR)/recursive.c \ - $(CORE_DIR)/snacc.c \ - $(CORE_DIR)/snacc-util.c \ - $(CORE_DIR)/val-parser.c \ - \ - $(BACKEND_DIR)/str-util.c \ - $(BACKEND_DIR)/tag-util.c \ - $(BACKEND_DIR)/cond.c \ - \ - $(C_BACKEND_DIR)/type-info.c \ - $(C_BACKEND_DIR)/util.c \ - $(C_BACKEND_DIR)/rules.c \ - $(C_BACKEND_DIR)/gen-code.c \ - $(C_BACKEND_DIR)/gen-type.c \ - $(C_BACKEND_DIR)/gen-enc.c \ - $(C_BACKEND_DIR)/gen-dec.c \ - $(C_BACKEND_DIR)/gen-vals.c \ - $(C_BACKEND_DIR)/gen-free.c \ - $(C_BACKEND_DIR)/gen-print.c \ - $(C_BACKEND_DIR)/gen-any.c \ - $(C_BACKEND_DIR)/kwd.c \ - \ - $(C++_BACKEND_DIR)/kwd.c \ - $(C++_BACKEND_DIR)/types.c \ - $(C++_BACKEND_DIR)/rules.c \ - $(C++_BACKEND_DIR)/gen-code.c \ - $(C++_BACKEND_DIR)/gen-vals.c \ - $(C++_BACKEND_DIR)/gen-any.c \ - \ - $(IDL_BACKEND_DIR)/rules.c \ - $(IDL_BACKEND_DIR)/types.c \ - $(IDL_BACKEND_DIR)/gen-any.c \ - $(IDL_BACKEND_DIR)/gen-code.c \ - $(IDL_BACKEND_DIR)/gen-vals.c - -CFILES = \ - $(CFILES.d) \ - $(CORE_DIR)/tbl.c - -OFILES = \ - $(CORE_DIR)/parse-asn1.o \ - $(CORE_DIR)/lex-asn1.o \ - \ - $(CORE_DIR)/link-types.o \ - $(CORE_DIR)/exports.o \ - $(CORE_DIR)/snacc-util.o \ - $(CORE_DIR)/dependency.o \ - $(CORE_DIR)/lib-types.o \ - $(CORE_DIR)/mem.o \ - $(CORE_DIR)/meta.o \ - $(CORE_DIR)/print.o \ - $(CORE_DIR)/do-macros.o \ - $(CORE_DIR)/oid.o \ - $(CORE_DIR)/link-values.o \ - $(CORE_DIR)/normalize.o \ - $(CORE_DIR)/val-parser.o \ - $(CORE_DIR)/err-chk.o \ - $(CORE_DIR)/define.o \ - $(CORE_DIR)/recursive.o \ - $(CORE_DIR)/snacc.o \ - $(CORE_DIR)/tbl.o \ - $(CORE_DIR)/gen-tbls.o \ - \ - $(BACKEND_DIR)/str-util.o \ - $(BACKEND_DIR)/tag-util.o \ - $(BACKEND_DIR)/cond.o \ - \ - $(C_BACKEND_DIR)/type-info.o \ - $(C_BACKEND_DIR)/util.o \ - $(C_BACKEND_DIR)/rules.o \ - $(C_BACKEND_DIR)/gen-code.o \ - $(C_BACKEND_DIR)/gen-type.o \ - $(C_BACKEND_DIR)/gen-enc.o \ - $(C_BACKEND_DIR)/gen-dec.o \ - $(C_BACKEND_DIR)/gen-vals.o \ - $(C_BACKEND_DIR)/gen-free.o \ - $(C_BACKEND_DIR)/gen-print.o \ - $(C_BACKEND_DIR)/gen-any.o \ - $(C_BACKEND_DIR)/kwd.o \ - \ - $(C++_BACKEND_DIR)/kwd.o \ - $(C++_BACKEND_DIR)/types.o \ - $(C++_BACKEND_DIR)/rules.o \ - $(C++_BACKEND_DIR)/gen-code.o \ - $(C++_BACKEND_DIR)/gen-vals.o \ - $(C++_BACKEND_DIR)/gen-any.o \ - \ - $(IDL_BACKEND_DIR)/rules.o \ - $(IDL_BACKEND_DIR)/types.o \ - $(IDL_BACKEND_DIR)/gen-any.o \ - $(IDL_BACKEND_DIR)/gen-code.o \ - $(IDL_BACKEND_DIR)/gen-vals.o - -DISTFILES = \ - README \ - makefile \ - $(HFILES.d) \ - $(LFILES) \ - $(YFILES) \ - $(CFILES.d) \ - boot/tbl.h \ - boot/tbl.c - -# end of definitions -# ---------------------------------------------------------------------- -# rules start here - -default:: all - -all:: snacc - -snacc: $(OFILES) $(ASN1_LIB) - $(REASON) - $(CC) $(LDFLAGS) -o snacc $(OFILES) $(ASN1_LIB) $(LEXLIB) $(LIBS) - -# compiling with the generated file currently doesn't work! -# otherwise, one could use the bootstrapping mechanism like for asn-useful.[ch] and tbl.[ch], below -# $(CORE_DIR)/asn1module.h: $(ASN1_SRC_DIR)/asn1module.asn1 -# ./snacc -t -u $(USEFUL_TYPES) $(ASN1_SRC_DIR)/asn1module.asn1 -# # this file is empty, anyway: -# $(RM) asn1module.c -# mv asn1module.h $(CORE_DIR) - -$(CORE_DIR)/tbl.h \ -$(CORE_DIR)/tbl.c:: - $(RM) $(CORE_DIR)/tbl.h $(CORE_DIR)/tbl.c - if [ -f snacc ]; then\ - $(MAKE) stamp-tbl;\ - else\ - $(RM) tbl.h tbl.c;\ - ln boot/tbl.h boot/tbl.c .;\ - fi - ln tbl.h $(CORE_DIR) - ln tbl.c $(CORE_DIR) - -# `../compiler/snacc' instead of `snacc' or `./snacc' to trick make(1) into believing that both are different files to avoid infinitre recursion: -stamp-tbl: ../compiler/snacc $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 makefile - $(REASON) - -mv tbl.h tbl.h.prev - -mv tbl.c tbl.c.prev - ./snacc -c -t -e -u $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 -# the dates in the two files will differ, so the files really differ if diff prints more than 4 lines of output: - @-if [ -f tbl.h.prev ]; then\ - if [ `diff tbl.h.prev tbl.h | wc -l` -gt 4 ]; then\ - $(RM) tbl.h.prev;\ - else\ - echo "tbl.h hasn't changed";\ - mv tbl.h.prev tbl.h;\ - fi;\ - fi - @-if [ -f tbl.c.prev ]; then\ - if [ `diff tbl.c.prev tbl.c | wc -l` -gt 4 ]; then\ - $(RM) tbl.c.prev;\ - else\ - echo "tbl.c hasn't changed";\ - mv tbl.c.prev tbl.c;\ - fi;\ - fi - date > $@ - -boot/tbl.h \ -boot/tbl.c: stamp-tbl - $(RM) boot/tbl.h boot/tbl.c - cp -p tbl.h tbl.c boot - -# the default rules work for .y.c, but often lack the .h -$(CORE_DIR)/parse-asn1.h \ -$(CORE_DIR)/parse-asn1.c: $(CORE_DIR)/parse-asn1.y - $(REASON) - @echo "expect 61 shift/reduce and 2 reduce/reduce conflicts" - $(YACC) -d $(CORE_DIR)/parse-asn1.y - mv y.tab.h $(CORE_DIR)/parse-asn1.h - mv y.tab.c $(CORE_DIR)/parse-asn1.c - -$(ASN1_LIB):: -# cd $(ASN1_LIB_DIR) && $(MAKE) Cebuf-lib compilerFLAGS="$(compilerFLAGS)" -# since different make versions handle the above line different, we use the more portable passing thru the environment: - cd $(ASN1_LIB_DIR) && compilerFLAGS="$(compilerFLAGS)" $(MAKE) Cebuf-lib - -install-sh: - ln $(TOP)/install-sh $@ - -install:: snacc install-sh $(bindir) - -$(bindir): - $(TOP)/mkinstalldirs $@ - -install:: - $(INSTALL_PROGRAM) snacc $(bindir)/ - -clean:: - $(RM) $(OFILES) $(LCFILES) $(YHFILES) $(YCFILES) - $(RM) *.o y.tab.c y.tab.h lex.yy.c y.output .emacs* *~ *.orig *.prev *.bak yacc.tmp yacc.acts yacc.debug - $(RM) stamp-tbl tbl.h tbl.h.prev tbl.c tbl.c.prev - -clobber:: - $(RM) snacc - $(RM) install-sh - -depend:: $(CORE_DIR)/tbl.h $(CORE_DIR)/tbl.c - -gen-distfiles:: snacc - -include ../maketail diff --git a/SecuritySNACCRuntime/compiler/stamp-tbl b/SecuritySNACCRuntime/compiler/stamp-tbl deleted file mode 100644 index c2f311f9..00000000 --- a/SecuritySNACCRuntime/compiler/stamp-tbl +++ /dev/null @@ -1 +0,0 @@ -Wed Mar 20 11:39:19 PST 2002 diff --git a/SecuritySNACCRuntime/compiler/tbl.c b/SecuritySNACCRuntime/compiler/tbl.c deleted file mode 100644 index d6c57e26..00000000 --- a/SecuritySNACCRuntime/compiler/tbl.c +++ /dev/null @@ -1,574 +0,0 @@ -/* - * tbl.c - * - * "TBL" ASN.1 module encode/decode/print/free C src. - * - * This file was generated by snacc on Tue Mar 19 07:24:43 2002 - * - * UBC snacc written by Mike Sample - * - * NOTE: This is a machine generated file - editing not recommended - */ - - - -#include "asn-incl.h" -#include "tbl.h" - - -AsnLen -BEncTBLRangeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLRange *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->to)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->from)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLRangeContent */ - - - - -AsnLen -BEncTBLNamedNumberContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumber *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->value)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLNamedNumberContent */ - - - - -AsnLen -BEncTBLNamedNumberListContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLNamedNumberList *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLNamedNumberListContent */ - - - - -AsnLen -BEncTBLTypeRefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeRef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnBoolContent (b, (&v->implicit)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDef)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeRefContent */ - - - - -AsnLen -BEncTBLTagContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTag *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - itemLen = BEncAsnIntContent (b, (&v->code)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncTBLTagClassContent (b, (&v->tclass)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 10); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTagContent */ - - - - -AsnLen -BEncTBLTypeSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTagContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeSeqOfContent */ - - - - -AsnLen -BEncTBLTypeContentSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContentSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLTypeContentSeqOfContent */ - - - - -AsnLen -BEncTBLTypeContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLType *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->values))) - { - BEncEocIfNec (b); - itemLen = BEncTBLNamedNumberListContent (b, (v->values)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 6); - - totalLen += itemLen; - } - - if (NOT_NULL ((v->constraint))) - { - BEncEocIfNec (b); - itemLen = BEncTBLRangeContent (b, (v->constraint)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 5); - - totalLen += itemLen; - } - - if (ASNOCTS_PRESENT ((&v->fieldName))) - { - itemLen = BEncPrintableStringContent (b, (&v->fieldName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 4); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentContent (b, (v->content)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - if (NOT_NULL ((v->tagList))) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeSeqOfContent (b, (v->tagList)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - } - - itemLen = BEncAsnBoolContent (b, (&v->optional)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - - itemLen = BEncTBLTypeIdContent (b, (&v->typeId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeContent */ - - - - -AsnLen -BEncTBLTypeContentContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeContent *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - switch (v->choiceId) - { - case TBLTYPECONTENT_PRIMTYPE: - itemLen = BEncAsnNullContent (b, (&v->a.primType)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_ELMTS: - BEncEocIfNec (b); - itemLen = BEncTBLTypeContentSeqOfContent (b, (v->a.elmts)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 1); - - totalLen += itemLen; - - break; - - case TBLTYPECONTENT_TYPEREF: - BEncEocIfNec (b); - itemLen = BEncTBLTypeRefContent (b, (v->a.typeRef)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 2); - - totalLen += itemLen; - - break; - - } - return totalLen; - -} /* BEncTBLTypeContentContent */ - - - - -AsnLen -BEncTBLTypeDefContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLTypeDef *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - if (NOT_NULL ((v->isPdu))) - { - itemLen = BEncAsnNullContent (b, (v->isPdu)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 5); - - totalLen += itemLen; - } - - BEncEocIfNec (b); - itemLen = BEncTBLTypeContent (b, (v->type)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncPrintableStringContent (b, (&v->typeName)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, PRIM, 19); - - totalLen += itemLen; - - itemLen = BEncTBLTypeDefIdContent (b, (&v->typeDefId)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLTypeDefContent */ - - - - -AsnLen -BEncTBLModuleSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModuleSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLTypeDefContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLModuleSeqOfContent */ - - - - -AsnLen -BEncTBLModuleContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLModule *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLModuleSeqOfContent (b, (v->typeDefs)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, CONS, 3); - - totalLen += itemLen; - - itemLen = BEncAsnBoolContent (b, (&v->isUseful)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, CNTX, PRIM, 2); - - totalLen += itemLen; - - if (ASNOID_PRESENT ((&v->id))) - { - itemLen = BEncAsnOidContent (b, (&v->id)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 1); - - totalLen += itemLen; - } - - itemLen = BEncPrintableStringContent (b, (&v->name)); - itemLen += BEncDefLen (b, itemLen); - itemLen += BEncTag1 (b, CNTX, PRIM, 0); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLModuleContent */ - - - - -AsnLen -BEncTBLSeqOfContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBLSeqOf *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - listLen = 0; - FOR_EACH_LIST_ELMT_RVS (component, v) - { - BEncEocIfNec (b); - itemLen = BEncTBLModuleContent (b, component); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - listLen += itemLen; - } - return listLen; - -} /* BEncTBLSeqOfContent */ - - - - -AsnLen BEncTBL PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen l; - BEncEocIfNec (b); - l = BEncTBLContent (b, v); - l += BEncConsLen (b, l); - l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE); - return l; -} /* BEncTBL */ - -AsnLen -BEncTBLContent PARAMS ((b, v), -BUF_TYPE b _AND_ -TBL *v) -{ - AsnLen totalLen = 0; - AsnLen itemLen; - AsnLen listLen; - void *component; - - BEncEocIfNec (b); - itemLen = BEncTBLSeqOfContent (b, (v->modules)); - itemLen += BEncConsLen (b, itemLen); - itemLen += BEncTag1 (b, UNIV, CONS, 16); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalLenStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumStrings)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTags)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypes)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumTypeDefs)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - itemLen = BEncAsnIntContent (b, (&v->totalNumModules)); - BEncDefLenTo127 (b, itemLen); - itemLen++; - itemLen += BEncTag1 (b, UNIV, PRIM, 2); - - totalLen += itemLen; - - return totalLen; - -} /* BEncTBLContent */ - - - - diff --git a/SecuritySNACCRuntime/compiler/tbl.h b/SecuritySNACCRuntime/compiler/tbl.h deleted file mode 100644 index 6d4b19e2..00000000 --- a/SecuritySNACCRuntime/compiler/tbl.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * tbl.h - * - * "TBL" ASN.1 module C type definitions and prototypes - * - * This .h file was generated by snacc on Tue Mar 19 07:24:43 2002 - * - * UBC snacc written compiler by Mike Sample - * - * NOTE: This is a machine generated file--editing not recommended - */ - - -#ifndef _tbl_h_ -#define _tbl_h_ - - - - -typedef enum - { - TBL_BOOLEAN = 0, - TBL_INTEGER = 1, - TBL_BITSTRING = 2, - TBL_OCTETSTRING = 3, - TBL_NULL = 4, - TBL_OID = 5, - TBL_REAL = 6, - TBL_ENUMERATED = 7, - TBL_SEQUENCE = 8, - TBL_SET = 9, - TBL_SEQUENCEOF = 10, - TBL_SETOF = 11, - TBL_CHOICE = 12, - TBL_TYPEREF = 13 - } TBLTypeId; /* ENUMERATED { TBL_BOOLEAN (0), TBL_INTEGER (1), TBL_BITSTRING (2), TBL_OCTETSTRING (3), TBL_NULL (4), TBL_OID (5), TBL_REAL (6), TBL_ENUMERATED (7), TBL_SEQUENCE (8), TBL_SET (9), TBL_SEQUENCEOF (10), TBL_SETOF (11), TBL_CHOICE (12), TBL_TYPEREF (13) } */ - -#define BEncTBLTypeIdContent BEncAsnEnumContent - - - - -typedef AsnInt TBLTypeDefId; /* INTEGER */ - -#define BEncTBLTypeDefIdContent BEncAsnIntContent - - - - -typedef enum - { - UNIVERSAL = 0, - APPLICATION = 1, - CONTEXT = 2, - PRIVATE = 3 - } TBLTagClass; /* ENUMERATED { UNIVERSAL (0), APPLICATION (1), CONTEXT (2), PRIVATE (3) } */ - -#define BEncTBLTagClassContent BEncAsnEnumContent - - - - -typedef struct TBLRange /* SEQUENCE */ -{ - AsnInt from; /* [0] IMPLICIT INTEGER */ - AsnInt to; /* [1] IMPLICIT INTEGER */ -} TBLRange; - -AsnLen BEncTBLRangeContent PROTO ((BUF_TYPE b, TBLRange *v)); - - - - -typedef struct TBLNamedNumber /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnInt value; /* [1] IMPLICIT INTEGER */ -} TBLNamedNumber; - -AsnLen BEncTBLNamedNumberContent PROTO ((BUF_TYPE b, TBLNamedNumber *v)); - - - - -typedef AsnList TBLNamedNumberList; /* SEQUENCE OF TBLNamedNumber */ - -AsnLen BEncTBLNamedNumberListContent PROTO ((BUF_TYPE b, TBLNamedNumberList *v)); - - - - -typedef struct TBLTypeRef /* SEQUENCE */ -{ - TBLTypeDefId typeDef; /* TBLTypeDefId */ - AsnBool implicit; /* BOOLEAN */ -} TBLTypeRef; - -AsnLen BEncTBLTypeRefContent PROTO ((BUF_TYPE b, TBLTypeRef *v)); - - - - -typedef struct TBLTag /* SEQUENCE */ -{ - TBLTagClass tclass; /* TBLTagClass */ - AsnInt code; /* INTEGER (0..MAX) */ -} TBLTag; - -AsnLen BEncTBLTagContent PROTO ((BUF_TYPE b, TBLTag *v)); - - - - -typedef AsnList TBLTypeSeqOf; /* SEQUENCE OF TBLTag */ - -AsnLen BEncTBLTypeSeqOfContent PROTO ((BUF_TYPE b, TBLTypeSeqOf *v)); - - - - -typedef AsnList TBLTypeContentSeqOf; /* SEQUENCE OF TBLType */ - -AsnLen BEncTBLTypeContentSeqOfContent PROTO ((BUF_TYPE b, TBLTypeContentSeqOf *v)); - - - - -typedef struct TBLType /* SEQUENCE */ -{ - TBLTypeId typeId; /* [0] IMPLICIT TBLTypeId */ - AsnBool optional; /* [1] IMPLICIT BOOLEAN */ - TBLTypeSeqOf* tagList; /* [2] IMPLICIT TBLTypeSeqOf OPTIONAL */ - struct TBLTypeContent* content; /* [3] TBLTypeContent */ - PrintableString fieldName; /* [4] IMPLICIT PrintableString OPTIONAL */ - struct TBLRange* constraint; /* [5] IMPLICIT TBLRange OPTIONAL */ - TBLNamedNumberList* values; /* [6] IMPLICIT TBLNamedNumberList OPTIONAL */ -} TBLType; - -AsnLen BEncTBLTypeContent PROTO ((BUF_TYPE b, TBLType *v)); - - - - -typedef struct TBLTypeContent /* CHOICE */ -{ - enum TBLTypeContentChoiceId - { - TBLTYPECONTENT_PRIMTYPE, - TBLTYPECONTENT_ELMTS, - TBLTYPECONTENT_TYPEREF - } choiceId; - union TBLTypeContentChoiceUnion - { - AsnNull primType; /* [0] IMPLICIT NULL */ - TBLTypeContentSeqOf* elmts; /* [1] IMPLICIT TBLTypeContentSeqOf */ - struct TBLTypeRef* typeRef; /* [2] IMPLICIT TBLTypeRef */ - } a; -} TBLTypeContent; - -AsnLen BEncTBLTypeContentContent PROTO ((BUF_TYPE b, TBLTypeContent *v)); - - - - -typedef struct TBLTypeDef /* SEQUENCE */ -{ - TBLTypeDefId typeDefId; /* TBLTypeDefId */ - PrintableString typeName; /* PrintableString */ - struct TBLType* type; /* TBLType */ - AsnNull* isPdu; /* NULL OPTIONAL */ -} TBLTypeDef; - -AsnLen BEncTBLTypeDefContent PROTO ((BUF_TYPE b, TBLTypeDef *v)); - - - - -typedef AsnList TBLModuleSeqOf; /* SEQUENCE OF TBLTypeDef */ - -AsnLen BEncTBLModuleSeqOfContent PROTO ((BUF_TYPE b, TBLModuleSeqOf *v)); - - - - -typedef struct TBLModule /* SEQUENCE */ -{ - PrintableString name; /* [0] IMPLICIT PrintableString */ - AsnOid id; /* [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL */ - AsnBool isUseful; /* [2] IMPLICIT BOOLEAN */ - TBLModuleSeqOf* typeDefs; /* [3] IMPLICIT TBLModuleSeqOf */ -} TBLModule; - -AsnLen BEncTBLModuleContent PROTO ((BUF_TYPE b, TBLModule *v)); - - - - -typedef AsnList TBLSeqOf; /* SEQUENCE OF TBLModule */ - -AsnLen BEncTBLSeqOfContent PROTO ((BUF_TYPE b, TBLSeqOf *v)); - - - - -typedef struct TBL /* SEQUENCE */ -{ - AsnInt totalNumModules; /* INTEGER */ - AsnInt totalNumTypeDefs; /* INTEGER */ - AsnInt totalNumTypes; /* INTEGER */ - AsnInt totalNumTags; /* INTEGER */ - AsnInt totalNumStrings; /* INTEGER */ - AsnInt totalLenStrings; /* INTEGER */ - TBLSeqOf* modules; /* TBLSeqOf */ -} TBL; - -AsnLen BEncTBL PROTO ((BUF_TYPE b, TBL *v)); - -AsnLen BEncTBLContent PROTO ((BUF_TYPE b, TBL *v)); - - - - - -#endif /* conditional include of tbl.h */ diff --git a/SecuritySNACCRuntime/config.cache b/SecuritySNACCRuntime/config.cache deleted file mode 100644 index f51a7c70..00000000 --- a/SecuritySNACCRuntime/config.cache +++ /dev/null @@ -1,68 +0,0 @@ -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -ac_cv_c_bigendian=${ac_cv_c_bigendian=yes} -ac_cv_c_const=${ac_cv_c_const=yes} -ac_cv_func_finite=${ac_cv_func_finite=yes} -ac_cv_func_isinf=${ac_cv_func_isinf=yes} -ac_cv_func_memcmp=${ac_cv_func_memcmp=yes} -ac_cv_func_memcpy=${ac_cv_func_memcpy=yes} -ac_cv_func_memset=${ac_cv_func_memset=yes} -ac_cv_func_vprintf=${ac_cv_func_vprintf=yes} -ac_cv_have_x=${ac_cv_have_x=have_x=no} -ac_cv_header_dirent_dirent_h=${ac_cv_header_dirent_dirent_h=yes} -ac_cv_header_fcntl_h=${ac_cv_header_fcntl_h=yes} -ac_cv_header_malloc_h=${ac_cv_header_malloc_h=no} -ac_cv_header_memory_h=${ac_cv_header_memory_h=yes} -ac_cv_header_stdc=${ac_cv_header_stdc=yes} -ac_cv_header_string_h=${ac_cv_header_string_h=yes} -ac_cv_header_tcl_h=${ac_cv_header_tcl_h=yes} -ac_cv_header_time=${ac_cv_header_time=yes} -ac_cv_header_unistd_h=${ac_cv_header_unistd_h=yes} -ac_cv_lib_dir_opendir=${ac_cv_lib_dir_opendir=no} -ac_cv_lib_fl_yywrap=${ac_cv_lib_fl_yywrap=no} -ac_cv_lib_ld_ldopen=${ac_cv_lib_ld_ldopen=no} -ac_cv_lib_m_sin=${ac_cv_lib_m_sin=no} -ac_cv_lib_tcl_Tcl_CreateInterp=${ac_cv_lib_tcl_Tcl_CreateInterp=yes} -ac_cv_lib_tk_Tk_CreateWindow=${ac_cv_lib_tk_Tk_CreateWindow=no} -ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'} -ac_cv_prog_AR=${ac_cv_prog_AR=ar} -ac_cv_prog_CC=${ac_cv_prog_CC=cc} -ac_cv_prog_CPP=${ac_cv_prog_CPP='cc -E -traditional-cpp'} -ac_cv_prog_CXX=${ac_cv_prog_CXX=c++} -ac_cv_prog_LEX=${ac_cv_prog_LEX=flex} -ac_cv_prog_MKDEP=${ac_cv_prog_MKDEP=mkdep} -ac_cv_prog_PATCH=${ac_cv_prog_PATCH=patch} -ac_cv_prog_RANLIB=${ac_cv_prog_RANLIB=ranlib} -ac_cv_prog_TCLSH=${ac_cv_prog_TCLSH=tclsh} -ac_cv_prog_YACC=${ac_cv_prog_YACC='bison -y'} -ac_cv_prog_cc_cc_c_o=${ac_cv_prog_cc_cc_c_o=yes} -ac_cv_prog_cc_cross=${ac_cv_prog_cc_cross=no} -ac_cv_prog_cc_g=${ac_cv_prog_cc_g=yes} -ac_cv_prog_cc_works=${ac_cv_prog_cc_works=yes} -ac_cv_prog_cxx_cross=${ac_cv_prog_cxx_cross=no} -ac_cv_prog_cxx_g=${ac_cv_prog_cxx_g=yes} -ac_cv_prog_cxx_works=${ac_cv_prog_cxx_works=yes} -ac_cv_prog_gcc=${ac_cv_prog_gcc=yes} -ac_cv_prog_gcc_traditional=${ac_cv_prog_gcc_traditional=no} -ac_cv_prog_gxx=${ac_cv_prog_gxx=yes} -ac_cv_prog_lex_root=${ac_cv_prog_lex_root=lex.yy} -ac_cv_prog_lex_yytext_pointer=${ac_cv_prog_lex_yytext_pointer=no} -ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set=yes} -ac_cv_sizeof_double=${ac_cv_sizeof_double=8} -ac_cv_sizeof_int=${ac_cv_sizeof_int=4} -ac_cv_sizeof_long=${ac_cv_sizeof_long=4} -ac_cv_sizeof_short=${ac_cv_sizeof_short=2} -ac_cv_type_size_t=${ac_cv_type_size_t=yes} -ac_cv_type_uid_t=${ac_cv_type_uid_t=yes} diff --git a/SecuritySNACCRuntime/config.h b/SecuritySNACCRuntime/config.h deleted file mode 100644 index 531ed594..00000000 --- a/SecuritySNACCRuntime/config.h +++ /dev/null @@ -1,128 +0,0 @@ -/* config.h. Generated automatically by configure. */ -/* config.h.in. Generated automatically from configure.in by autoheader. */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define if you don't have vprintf but do have _doprnt. */ -/* #undef HAVE_DOPRNT */ - -/* Define if you have the vprintf function. */ -#define HAVE_VPRINTF 1 - -/* Define if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define if your processor stores words with the most significant - byte first (like Motorola and SPARC, unlike Intel and VAX). */ -#define WORDS_BIGENDIAN 1 - -/* Define if the X Window System is missing or not being used. */ -#define X_DISPLAY_MISSING 1 - -/* Define if lex declares yytext as a char * by default, not a char[]. */ -/* #undef YYTEXT_POINTER */ - -/* - * file: acconfig.h - */ - -/* - * define IEEE_REAL_FMT if your system/compiler uses the native ieee double - * this should improve the performance of encoding reals. - * If your system has the IEEE library routines (iszero, isinf etc) - * then define IEEE_REAL_LIB. If neither are defined then - * frexp is used. Performance is probaby best for IEEE_REAL_FMT. - * - * #define IEEE_REAL_FMT - * #define IEEE_REAL_LIB - */ -/* use ANSI or K&R style C? */ -#define __USE_ANSI_C__ 1 - -/* does the C++ compiler have the bool type built-in? */ -#define BOOL_BUILTIN 1 - -/* does the C++ compiler allow variable sized automatic arryas? */ -#define HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS 1 - -/* do we have all the libs we need for the Tcl interface? */ -/* #undef HAVE_TCL */ - -/* does the compiler support volatile functions (and is abort() volatile?) */ -/* #undef COMPILER_WITHOUT_VOLATILE_FUNCTIONS */ - -/* The number of bytes in a double. */ -#define SIZEOF_DOUBLE 8 - -/* The number of bytes in a int. */ -#define SIZEOF_INT 4 - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/* The number of bytes in a short. */ -#define SIZEOF_SHORT 2 - -/* Define if you have the finite function. */ -#define HAVE_FINITE 1 - -/* Define if you have the isinf function. */ -#define HAVE_ISINF 1 - -/* Define if you have the memcmp function. */ -#define HAVE_MEMCMP 1 - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY 1 - -/* Define if you have the memset function. */ -#define HAVE_MEMSET 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the m library (-lm). */ -/* #undef HAVE_LIBM */ diff --git a/SecuritySNACCRuntime/config.h.in b/SecuritySNACCRuntime/config.h.in deleted file mode 100644 index 8de0f4fc..00000000 --- a/SecuritySNACCRuntime/config.h.in +++ /dev/null @@ -1,160 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ - -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define to `int' if doesn't define. */ -#undef gid_t - -/* Define if you don't have vprintf but do have _doprnt. */ -#undef HAVE_DOPRNT - -/* Define if you have the vprintf function. */ -#undef HAVE_VPRINTF - -/* Define if your C compiler doesn't accept -c and -o together. */ -#undef NO_MINUS_C_MINUS_O - -/* Define if you need to in order for stat and other things to work. */ -#undef _POSIX_SOURCE - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define to `int' if doesn't define. */ -#undef uid_t - -/* Define if your processor stores words with the most significant - byte first (like Motorola and SPARC, unlike Intel and VAX). */ -#undef WORDS_BIGENDIAN - -/* Define if the X Window System is missing or not being used. */ -#undef X_DISPLAY_MISSING - -/* Define if lex declares yytext as a char * by default, not a char[]. */ -#undef YYTEXT_POINTER - -/* - * file: acconfig.h - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/config.h.in,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ - * $Log: config.h.in,v $ - * Revision 1.1.1.1 2001/05/18 23:14:04 mb - * Move from private repository to open source repository - * - * Revision 1.3 2000/12/21 23:56:34 dmitch - * Misc. updates for clean build on Cheetah 1D7. - * - * Revision 1.1.1.1 1999/03/16 18:05:47 aram - * Originals from SMIME Free Library. - * - * Revision 1.7 1997/03/03 11:58:26 wan - * Final pre-delivery stuff (I hope). - * - * Revision 1.6 1997/02/28 13:39:34 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.5 1997/02/15 20:01:37 rj - * check whether the compiler supports volatile functions (and whether abort() is volatile). - * - * Revision 1.4 1995/02/20 11:16:57 rj - * cpp switch HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS added. - * - * Revision 1.3 1995/02/13 14:46:49 rj - * settings for IEEE_REAL_FMT/IEEE_REAL_LIB moved from {c_lib,c++_lib}/inc/asn_config.h to acconfig.h. - * - * Revision 1.2 1994/10/08 04:38:56 rj - * slot for autoconf Tcl detection added. - * - * Revision 1.1 1994/09/01 00:51:19 rj - * first check-in (new file). - * - */ - -/* - * define IEEE_REAL_FMT if your system/compiler uses the native ieee double - * this should improve the performance of encoding reals. - * If your system has the IEEE library routines (iszero, isinf etc) - * then define IEEE_REAL_LIB. If neither are defined then - * frexp is used. Performance is probaby best for IEEE_REAL_FMT. - * - * #define IEEE_REAL_FMT - * #define IEEE_REAL_LIB - */ -/* use ANSI or K&R style C? */ -#undef __USE_ANSI_C__ - -/* does the C++ compiler have the bool type built-in? */ -#undef BOOL_BUILTIN - -/* does the C++ compiler allow variable sized automatic arryas? */ -#undef HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS - -/* do we have all the libs we need for the Tcl interface? */ -#undef HAVE_TCL - -/* does the compiler support volatile functions (and is abort() volatile?) */ -#undef COMPILER_WITHOUT_VOLATILE_FUNCTIONS - -/* The number of bytes in a double. */ -#undef SIZEOF_DOUBLE - -/* The number of bytes in a int. */ -#undef SIZEOF_INT - -/* The number of bytes in a long. */ -#undef SIZEOF_LONG - -/* The number of bytes in a short. */ -#undef SIZEOF_SHORT - -/* Define if you have the finite function. */ -#undef HAVE_FINITE - -/* Define if you have the isinf function. */ -#undef HAVE_ISINF - -/* Define if you have the memcmp function. */ -#undef HAVE_MEMCMP - -/* Define if you have the memcpy function. */ -#undef HAVE_MEMCPY - -/* Define if you have the memset function. */ -#undef HAVE_MEMSET - -/* Define if you have the header file. */ -#undef HAVE_DIRENT_H - -/* Define if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define if you have the header file. */ -#undef HAVE_NDIR_H - -/* Define if you have the header file. */ -#undef HAVE_STRING_H - -/* Define if you have the header file. */ -#undef HAVE_SYS_DIR_H - -/* Define if you have the header file. */ -#undef HAVE_SYS_NDIR_H - -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define if you have the m library (-lm). */ -#undef HAVE_LIBM diff --git a/SecuritySNACCRuntime/config.log b/SecuritySNACCRuntime/config.log deleted file mode 100644 index 25dc28b7..00000000 --- a/SecuritySNACCRuntime/config.log +++ /dev/null @@ -1,80 +0,0 @@ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -configure:529: checking whether make sets ${MAKE} -configure:558: checking for gcc -configure:671: checking whether the C compiler (cc -DMACOS -DYYTEXT_POINTER ) works -configure:687: cc -o conftest -DMACOS -DYYTEXT_POINTER conftest.c 1>&5 -configure:713: checking whether the C compiler (cc -DMACOS -DYYTEXT_POINTER ) is a cross-compiler -configure:718: checking whether we are using GNU C -configure:746: checking whether cc accepts -g -configure:778: checking for POSIXized ISC -configure:802: checking for cc's include path -configure:811: checking how to run the C preprocessor -configure:892: checking whether cc needs -traditional -configure:942: checking whether cc understands -c and -o together -configure:993: checking whether ANSI or K&R style C -configure:1002: cc -o conftest -DMACOS -DYYTEXT_POINTER conftest.c 1>&5 -configure:1022: checking for c++ -configure:1054: checking whether the C++ compiler (c++ ) works -configure:1070: c++ -o conftest conftest.C 1>&5 -configure:1096: checking whether the C++ compiler (c++ ) is a cross-compiler -configure:1101: checking whether we are using GNU C++ -configure:1129: checking whether c++ accepts -g -configure:1168: checking for bool built-in -configure:1177: c++ -c -g -O2 conftest.C 1>&5 -configure:1191: checking for variable sized automatic arrays -configure:1200: c++ -c -g -O2 conftest.C 1>&5 -configure:1214: checking for volatile functions -configure:1223: c++ -c -g -O2 conftest.C 1>&5 -configure:1246: checking for flex -configure:1322: checking lex output file root -configure:1343: checking whether yytext is a pointer -configure:1398: checking for patch -configure:1433: checking for bison -configure:1468: checking for makedepend -configure:1503: checking for ar -configure:1536: checking for ranlib -configure:1594: checking for a BSD compatible install -configure:1647: checking whether time.h and sys/time.h may both be included -configure:1686: checking for dirent.h that defines DIR -configure:1724: checking for opendir in -ldir -configure:1807: checking for ANSI C header files -configure:1911: checking for size_t -configure:1944: checking for uid_t in sys/types.h -configure:1978: checking for ANSI C header files -configure:2085: checking for unistd.h -configure:2085: checking for memory.h -configure:2085: checking for string.h -configure:2085: checking for malloc.h -configure:2085: checking for fcntl.h -configure:2122: checking for vprintf -configure:2227: checking for working const -configure:2302: checking whether byte ordering is bigendian -configure:2392: checking size of short -configure:2431: checking size of int -configure:2470: checking size of long -configure:2509: checking size of double -configure:2548: checking for sin in -lm -configure:2597: checking for isinf -configure:2597: checking for finite -configure:2652: checking for memset -configure:2652: checking for memcpy -configure:2652: checking for memcmp -configure:2709: checking for X -configure:3543: checking for tclsh -configure:3576: checking for tcl.h -configure:3603: checking for ldopen in -lld -configure:3643: checking for Tcl_CreateInterp in -ltcl -configure:3680: checking for Tk_CreateWindow in -ltk -configure:3800: checking for latex -configure:3835: checking for bibtex -configure:3870: checking for dvips -configure:3905: checking for detex2 -configure:3905: checking for detex -configure:3940: checking for ghostview -configure:3940: checking for gs -configure:3975: checking for psbook -configure:4010: checking for psnup -configure:4045: checking for ispell -configure:4045: checking for spell diff --git a/SecuritySNACCRuntime/config.status b/SecuritySNACCRuntime/config.status deleted file mode 100644 index c930c52f..00000000 --- a/SecuritySNACCRuntime/config.status +++ /dev/null @@ -1,349 +0,0 @@ -#! /bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host localhost: -# -# ./configure -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]" -for ac_option -do - case "$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion" - exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "./config.status generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "$ac_cs_usage"; exit 0 ;; - *) echo "$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=. -ac_given_INSTALL="/usr/bin/install -c" - -trap 'rm -fr makehead config.h conftest*; exit 1' 1 2 15 - -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g; - s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF -/^[ ]*VPATH[ ]*=[^:]*$/d - -s%@SHELL@%/bin/sh%g -s%@CFLAGS@%-DMACOS -DYYTEXT_POINTER -DFLEX_IN_USE%g -s%@CPPFLAGS@%%g -s%@CXXFLAGS@%-g -O2%g -s%@FFLAGS@%%g -s%@DEFS@%-DHAVE_CONFIG_H%g -s%@LDFLAGS@%%g -s%@LIBS@%%g -s%@exec_prefix@%${prefix}%g -s%@prefix@%/usr/local%g -s%@program_transform_name@%s,x,x,%g -s%@bindir@%${exec_prefix}/bin%g -s%@sbindir@%${exec_prefix}/sbin%g -s%@libexecdir@%${exec_prefix}/libexec%g -s%@datadir@%${prefix}/share%g -s%@sysconfdir@%${prefix}/etc%g -s%@sharedstatedir@%${prefix}/com%g -s%@localstatedir@%${prefix}/var%g -s%@libdir@%${exec_prefix}/lib%g -s%@includedir@%${prefix}/include%g -s%@oldincludedir@%/usr/include%g -s%@infodir@%${prefix}/info%g -s%@mandir@%${prefix}/man%g -s%@SET_MAKE@%%g -s%@CC@%cc%g -s%@MKDEP_CCINC@%-I/usr/local/include -I/usr/libexec/gcc/darwin/ppc/2.95.2/include -F/System/Library/PrivateFrameworks%g -s%@CPP@%cc -E -traditional-cpp%g -s%@CXX@%c++%g -s%@SNACC_NOVOLAT@%%g -s%@LEX@%flex%g -s%@LEXLIB@%-ll%g -s%@LEX_OUTPUT_ROOT@%lex.yy%g -s%@LFLAGS@%%g -s%@PATCH@%patch%g -s%@YACC@%bison -y%g -s%@MKDEP@%mkdep%g -s%@AR@%ar%g -s%@RANLIB@%ranlib%g -s%@INSTALL_PROGRAM@%${INSTALL}%g -s%@INSTALL_SCRIPT@%${INSTALL_PROGRAM}%g -s%@INSTALL_DATA@%${INSTALL} -m 644%g -s%@X_CFLAGS@%%g -s%@X_PRE_LIBS@%%g -s%@X_LIBS@%%g -s%@X_EXTRA_LIBS@%%g -s%@TCLSH@%tclsh%g -s%@TCLLIBS@%%g -s%@TREELIBS@%%g -s%@LATEX@%false%g -s%@BIBTEX@%false%g -s%@DVIPS@%false%g -s%@DETEX@%false%g -s%@PSPREVIEW@%true%g -s%@PSBOOK@%false%g -s%@PSNUP@%false%g -s%@SPELL@%spell%g - -CEOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi - -CONFIG_FILES=${CONFIG_FILES-"makehead"} -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' -ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -if test "${CONFIG_HEADERS+set}" != set; then - CONFIG_HEADERS="config.h" -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - - cat > conftest.frag < conftest.out - rm -f conftest.in - mv conftest.out conftest.in - - cat > conftest.frag < conftest.out - rm -f conftest.in - mv conftest.out conftest.in - - cat > conftest.frag < conftest.out - rm -f conftest.in - mv conftest.out conftest.in - - cat > conftest.frag < conftest.out - rm -f conftest.in - mv conftest.out conftest.in - - cat > conftest.frag < conftest.out - rm -f conftest.in - mv conftest.out conftest.in - - cat > conftest.frag < conftest.out - rm -f conftest.in - mv conftest.out conftest.in - - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - fi - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done - - -date > stamp-h -exit 0 diff --git a/SecuritySNACCRuntime/configure b/SecuritySNACCRuntime/configure deleted file mode 100644 index ee4c4af5..00000000 --- a/SecuritySNACCRuntime/configure +++ /dev/null @@ -1,4458 +0,0 @@ -#! /bin/sh - -# From configure.in Revision: 1.2 # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --with-x use the X Window System" - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=compiler/core/snacc.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:529: checking whether ${MAKE-make} sets \${MAKE}" >&5 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftestmake <<\EOF -all: - @echo 'ac_maketemp="${MAKE}"' -EOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftestmake -fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$ac_t""yes" 1>&6 - SET_MAKE= -else - echo "$ac_t""no" 1>&6 - SET_MAKE="MAKE=${MAKE-make}" -fi - -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:558: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:588: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:639: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:671: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext << EOF - -#line 682 "configure" -#include "confdefs.h" - -main(){return(0);} -EOF -if { (eval echo configure:687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:713: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:718: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes -else - GCC= -fi - -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:746: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes -else - ac_cv_prog_cc_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi - -echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:778: checking for POSIXized ISC" >&5 -if test -d /etc/conf/kconfig.d && - grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 -then - echo "$ac_t""yes" 1>&6 - ISC=yes # If later tests want to check for ISC. - cat >> confdefs.h <<\EOF -#define _POSIX_SOURCE 1 -EOF - - if test "$GCC" = yes; then - CC="$CC -posix" - else - CC="$CC -Xp" - fi -else - echo "$ac_t""no" 1>&6 - ISC= -fi - -if test -n "$GCC"; then - - # hack to let X11 makedepend find .h file a little more the way gcc does: - echo $ac_n "checking for $CC's include path""... $ac_c" 1>&6 -echo "configure:802: checking for $CC's include path" >&5 - gcclibdir=`$CC -v 2>&1 | sed -n -e 's:Reading specs from \(.*\)/specs:\1:p'` - gxxincdir=`which gcc | sed "s/bin\/gcc//"` - #MKDEP_CCINC="-I$gxxincdir/lib/g++-include -I/usr/local/include -I$gcclibdir/include" - MKDEP_CCINC="-I/usr/local/include -I$gcclibdir/include -F/System/Library/PrivateFrameworks" - echo "$ac_t""$MKDEP_CCINC" 1>&6 - -fi -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:811: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:832: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:849: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:866: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:892: checking whether ${CC-cc} needs -traditional" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_pattern="Autoconf.*'x'" - cat > conftest.$ac_ext < -Autoconf TIOCGETP -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_prog_gcc_traditional=yes -else - rm -rf conftest* - ac_cv_prog_gcc_traditional=no -fi -rm -f conftest* - - - if test $ac_cv_prog_gcc_traditional = no; then - cat > conftest.$ac_ext < -Autoconf TCGETA -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_prog_gcc_traditional=yes -fi -rm -f conftest* - - fi -fi - -echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 - if test $ac_cv_prog_gcc_traditional = yes; then - CC="$CC -traditional" - fi -fi - -if test "x$CC" != xcc; then - echo $ac_n "checking whether $CC and cc understand -c and -o together""... $ac_c" 1>&6 -echo "configure:939: checking whether $CC and cc understand -c and -o together" >&5 -else - echo $ac_n "checking whether cc understands -c and -o together""... $ac_c" 1>&6 -echo "configure:942: checking whether cc understands -c and -o together" >&5 -fi -set dummy $CC; ac_cc="`echo $2 | - sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`" -if eval "test \"`echo '$''{'ac_cv_prog_cc_${ac_cc}_c_o'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'foo(){}' > conftest.c -# Make sure it works both with $CC and with simple cc. -# We do the test twice because some compilers refuse to overwrite an -# existing .o file with -o, though they will create one. -ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&5' -if { (eval echo configure:954: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } && - test -f conftest.o && { (eval echo configure:955: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; -then - eval ac_cv_prog_cc_${ac_cc}_c_o=yes - if test "x$CC" != xcc; then - # Test first that cc exists at all. - if { ac_try='cc -c conftest.c 1>&5'; { (eval echo configure:960: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then - ac_try='cc -c conftest.c -o conftest.o 1>&5' - if { (eval echo configure:962: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } && - test -f conftest.o && { (eval echo configure:963: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; - then - # cc works too. - : - else - # cc exists but doesn't like -o. - eval ac_cv_prog_cc_${ac_cc}_c_o=no - fi - fi - fi -else - eval ac_cv_prog_cc_${ac_cc}_c_o=no -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then - echo "$ac_t""yes" 1>&6 -else - echo "$ac_t""no" 1>&6 - cat >> confdefs.h <<\EOF -#define NO_MINUS_C_MINUS_O 1 -EOF - -fi - -if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then - echo "configure: warning: since -c and -o don't seem to work together" 1>&2 -fi -echo $ac_n "checking whether ANSI or K&R style C""... $ac_c" 1>&6 -echo "configure:993: checking whether ANSI or K&R style C" >&5 -if test "$cross_compiling" = yes; then - echo "$ac_t""K&R" 1>&6 -else - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""ANSI" 1>&6; cat >> confdefs.h <<\EOF -#define __USE_ANSI_C__ 1 -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""K&R" 1>&6 -fi -rm -fr conftest* -fi - -for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1022: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CXX="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CXX="$ac_cv_prog_CXX" -if test -n "$CXX"; then - echo "$ac_t""$CXX" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$CXX" && break -done -test -n "$CXX" || CXX="gcc" - - -echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1054: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 - -ac_ext=C -# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cxx_cross - -cat > conftest.$ac_ext << EOF - -#line 1065 "configure" -#include "confdefs.h" - -int main(){return(0);} -EOF -if { (eval echo configure:1070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cxx_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cxx_cross=no - else - ac_cv_prog_cxx_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cxx_works=no -fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 -if test $ac_cv_prog_cxx_works = no; then - { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1096: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 -cross_compiling=$ac_cv_prog_cxx_cross - -echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:1101: checking whether we are using GNU C++" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.C <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gxx=yes -else - ac_cv_prog_gxx=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gxx" 1>&6 - -if test $ac_cv_prog_gxx = yes; then - GXX=yes -else - GXX= -fi - -ac_test_CXXFLAGS="${CXXFLAGS+set}" -ac_save_CXXFLAGS="$CXXFLAGS" -CXXFLAGS= -echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:1129: checking whether ${CXX-g++} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.cc -if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then - ac_cv_prog_cxx_g=yes -else - ac_cv_prog_cxx_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS="$ac_save_CXXFLAGS" -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi - -ac_ext=C -# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cxx_cross - -echo $ac_n "checking for bool built-in""... $ac_c" 1>&6 -echo "configure:1168: checking for bool built-in" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - cat >> confdefs.h <<\EOF -#define BOOL_BUILTIN 1 -EOF - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -fi -rm -f conftest* -echo $ac_n "checking for variable sized automatic arrays""... $ac_c" 1>&6 -echo "configure:1191: checking for variable sized automatic arrays" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - cat >> confdefs.h <<\EOF -#define HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS 1 -EOF - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -fi -rm -f conftest* -echo $ac_n "checking for volatile functions""... $ac_c" 1>&6 -echo "configure:1214: checking for volatile functions" >&5 -cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat >> confdefs.h <<\EOF -#define COMPILER_WITHOUT_VOLATILE_FUNCTIONS 1 -EOF - SNACC_NOVOLAT=-novolat; echo "$ac_t""no" 1>&6 -fi -rm -f conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -# Extract the first word of "flex", so it can be a program name with args. -set dummy flex; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1246: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$LEX"; then - ac_cv_prog_LEX="$LEX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_LEX="flex" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_LEX" && ac_cv_prog_LEX="lex" -fi -fi -LEX="$ac_cv_prog_LEX" -if test -n "$LEX"; then - echo "$ac_t""$LEX" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$LEXLIB" -then - case "$LEX" in - flex*) ac_lib=fl ;; - *) ac_lib=l ;; - esac - echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 -echo "configure:1280: checking for yywrap in -l$ac_lib" >&5 -ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-l$ac_lib $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LEXLIB="-l$ac_lib" -else - echo "$ac_t""no" 1>&6 -fi - -fi - -echo $ac_n "checking lex output file root""... $ac_c" 1>&6 -echo "configure:1322: checking lex output file root" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_lex_root'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # The minimal lex program is just a single line: %%. But some broken lexes -# (Solaris, I think it was) want two %% lines, so accommodate them. -echo '%% -%%' | $LEX -if test -f lex.yy.c; then - ac_cv_prog_lex_root=lex.yy -elif test -f lexyy.c; then - ac_cv_prog_lex_root=lexyy -else - { echo "configure: error: cannot find output from $LEX; giving up" 1>&2; exit 1; } -fi -fi - -echo "$ac_t""$ac_cv_prog_lex_root" 1>&6 -LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root - -echo $ac_n "checking whether yytext is a pointer""... $ac_c" 1>&6 -echo "configure:1343: checking whether yytext is a pointer" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_lex_yytext_pointer'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # POSIX says lex can declare yytext either as a pointer or an array; the -# default is implementation-dependent. Figure out which it is, since -# not all implementations provide the %pointer and %array declarations. -ac_cv_prog_lex_yytext_pointer=no -echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c -ac_save_LIBS="$LIBS" -LIBS="$LIBS $LEXLIB" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - ac_cv_prog_lex_yytext_pointer=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -LIBS="$ac_save_LIBS" -rm -f "${LEX_OUTPUT_ROOT}.c" - -fi - -echo "$ac_t""$ac_cv_prog_lex_yytext_pointer" 1>&6 -if test $ac_cv_prog_lex_yytext_pointer = yes; then - cat >> confdefs.h <<\EOF -#define YYTEXT_POINTER 1 -EOF - -fi - -case "$LEX" in - lex) - LFLAGS="-Nc10000" - ;; - flex) - CFLAGS="$CFLAGS -DFLEX_IN_USE" -esac - - -# the boot strapping code in .../c-lib/ needs patch: -for ac_prog in patch -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1398: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_PATCH'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$PATCH"; then - ac_cv_prog_PATCH="$PATCH" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_PATCH="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -PATCH="$ac_cv_prog_PATCH" -if test -n "$PATCH"; then - echo "$ac_t""$PATCH" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$PATCH" && break -done -test -n "$PATCH" || PATCH="false" - -for ac_prog in 'bison -y' byacc -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1433: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$YACC"; then - ac_cv_prog_YACC="$YACC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_YACC="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -YACC="$ac_cv_prog_YACC" -if test -n "$YACC"; then - echo "$ac_t""$YACC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$YACC" && break -done -test -n "$YACC" || YACC="yacc" - -for ac_prog in makedepend mkdep mkdep.sh -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1468: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_MKDEP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$MKDEP"; then - ac_cv_prog_MKDEP="$MKDEP" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_MKDEP="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -MKDEP="$ac_cv_prog_MKDEP" -if test -n "$MKDEP"; then - echo "$ac_t""$MKDEP" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$MKDEP" && break -done -test -n "$MKDEP" || MKDEP="$CC" - -for ac_prog in ar -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1503: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_AR="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -AR="$ac_cv_prog_AR" -if test -n "$AR"; then - echo "$ac_t""$AR" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$AR" && break -done -test -n "$AR" || AR="ar" - -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1536: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1594: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_IFS" - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL="$ac_install_sh" - fi -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1647: checking whether time.h and sys/time.h may both be included" >&5 -if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -int main() { -struct tm *tp; -; return 0; } -EOF -if { (eval echo configure:1661: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_header_time=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_time=no -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_header_time" 1>&6 -if test $ac_cv_header_time = yes; then - cat >> confdefs.h <<\EOF -#define TIME_WITH_SYS_TIME 1 -EOF - -fi - -ac_header_dirent=no -for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:1686: checking for $ac_hdr that defines DIR" >&5 -if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include <$ac_hdr> -int main() { -DIR *dirp = 0; -; return 0; } -EOF -if { (eval echo configure:1699: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - eval "ac_cv_header_dirent_$ac_safe=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_dirent_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done -# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. -if test $ac_header_dirent = dirent.h; then -echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:1724: checking for opendir in -ldir" >&5 -ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldir $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -ldir" -else - echo "$ac_t""no" 1>&6 -fi - -else -echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:1765: checking for opendir in -lx" >&5 -ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lx $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -lx" -else - echo "$ac_t""no" 1>&6 -fi - -fi - -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1807: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -#include -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1820: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : -else - cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -if { (eval echo configure:1887: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no -fi -rm -fr conftest* -fi - -fi -fi - -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - -echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1911: checking for size_t" >&5 -if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#if STDC_HEADERS -#include -#include -#endif -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_type_size_t=yes -else - rm -rf conftest* - ac_cv_type_size_t=no -fi -rm -f conftest* - -fi -echo "$ac_t""$ac_cv_type_size_t" 1>&6 -if test $ac_cv_type_size_t = no; then - cat >> confdefs.h <<\EOF -#define size_t unsigned -EOF - -fi - -echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:1944: checking for uid_t in sys/types.h" >&5 -if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "uid_t" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_type_uid_t=yes -else - rm -rf conftest* - ac_cv_type_uid_t=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_type_uid_t" 1>&6 -if test $ac_cv_type_uid_t = no; then - cat >> confdefs.h <<\EOF -#define uid_t int -EOF - - cat >> confdefs.h <<\EOF -#define gid_t int -EOF - -fi - -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1978: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -#include -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : -else - cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -if { (eval echo configure:2058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no -fi -rm -fr conftest* -fi - -fi -fi - -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - -for ac_hdr in unistd.h memory.h string.h malloc.h fcntl.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2085: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2095: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done - -echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:2122: checking for vprintf" >&5 -if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char vprintf(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_vprintf) || defined (__stub___vprintf) -choke me -#else -vprintf(); -#endif - -; return 0; } -EOF -if { (eval echo configure:2150: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_vprintf=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_vprintf=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'vprintf`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define HAVE_VPRINTF 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi - -if test "$ac_cv_func_vprintf" != yes; then -echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:2174: checking for _doprnt" >&5 -if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char _doprnt(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub__doprnt) || defined (__stub____doprnt) -choke me -#else -_doprnt(); -#endif - -; return 0; } -EOF -if { (eval echo configure:2202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func__doprnt=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func__doprnt=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'_doprnt`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define HAVE_DOPRNT 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi - -fi - -echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:2227: checking for working const" >&5 -if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <j = 5; -} -{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; -} - -; return 0; } -EOF -if { (eval echo configure:2281: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_c_const=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_c_const=no -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_c_const" 1>&6 -if test $ac_cv_c_const = no; then - cat >> confdefs.h <<\EOF -#define const -EOF - -fi - -echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:2302: checking whether byte ordering is bigendian" >&5 -if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_cv_c_bigendian=unknown -# See if sys/param.h defines the BYTE_ORDER macro. -cat > conftest.$ac_ext < -#include -int main() { - -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN - bogus endian macros -#endif -; return 0; } -EOF -if { (eval echo configure:2320: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - # It does; now see whether it defined to BIG_ENDIAN or not. -cat > conftest.$ac_ext < -#include -int main() { - -#if BYTE_ORDER != BIG_ENDIAN - not big endian -#endif -; return 0; } -EOF -if { (eval echo configure:2335: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_c_bigendian=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_c_bigendian=no -fi -rm -f conftest* -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -if test $ac_cv_c_bigendian = unknown; then -if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } -else - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_c_bigendian=no -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_c_bigendian=yes -fi -rm -fr conftest* -fi - -fi -fi - -echo "$ac_t""$ac_cv_c_bigendian" 1>&6 -if test $ac_cv_c_bigendian = yes; then - cat >> confdefs.h <<\EOF -#define WORDS_BIGENDIAN 1 -EOF - -fi - -echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:2392: checking size of short" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } -else - cat > conftest.$ac_ext < -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(short)); - exit(0); -} -EOF -if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_sizeof_short=`cat conftestval` -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_sizeof_short=0 -fi -rm -fr conftest* -fi - -fi -echo "$ac_t""$ac_cv_sizeof_short" 1>&6 -cat >> confdefs.h <&6 -echo "configure:2431: checking size of int" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } -else - cat > conftest.$ac_ext < -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(int)); - exit(0); -} -EOF -if { (eval echo configure:2450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_sizeof_int=`cat conftestval` -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_sizeof_int=0 -fi -rm -fr conftest* -fi - -fi -echo "$ac_t""$ac_cv_sizeof_int" 1>&6 -cat >> confdefs.h <&6 -echo "configure:2470: checking size of long" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } -else - cat > conftest.$ac_ext < -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(long)); - exit(0); -} -EOF -if { (eval echo configure:2489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_sizeof_long=`cat conftestval` -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_sizeof_long=0 -fi -rm -fr conftest* -fi - -fi -echo "$ac_t""$ac_cv_sizeof_long" 1>&6 -cat >> confdefs.h <&6 -echo "configure:2509: checking size of double" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } -else - cat > conftest.$ac_ext < -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(double)); - exit(0); -} -EOF -if { (eval echo configure:2528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_sizeof_double=`cat conftestval` -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_sizeof_double=0 -fi -rm -fr conftest* -fi - -fi -echo "$ac_t""$ac_cv_sizeof_double" 1>&6 -cat >> confdefs.h <&6 -echo "configure:2548: checking for sin in -lm" >&5 -ac_lib_var=`echo m'_'sin | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lm $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -fi - -for ac_func in isinf finite -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2597: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:2625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -fi -done - -for ac_func in memset memcpy memcmp -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2652: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:2680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -fi -done - -# If we find X, set shell vars x_includes and x_libraries to the -# paths, otherwise set no_x=yes. -# Uses ac_ vars as temps to allow command line to override cache and checks. -# --without-x overrides everything else, but does not touch the cache. -echo $ac_n "checking for X""... $ac_c" 1>&6 -echo "configure:2709: checking for X" >&5 - -# Check whether --with-x or --without-x was given. -if test "${with_x+set}" = set; then - withval="$with_x" - : -fi - -# $have_x is `yes', `no', `disabled', or empty when we do not yet know. -if test "x$with_x" = xno; then - # The user explicitly disabled X. - have_x=disabled -else - if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then - # Both variables are already set. - have_x=yes - else -if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # One or both of the vars are not set, and there is no cached value. -ac_x_includes=NO ac_x_libraries=NO -rm -fr conftestdir -if mkdir conftestdir; then - cd conftestdir - # Make sure to not put "make" in the Imakefile rules, since we grep it out. - cat > Imakefile <<'EOF' -acfindx: - @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' -EOF - if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then - # GNU make sometimes prints "make[1]: Entering...", which would confuse us. - eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` - # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. - for ac_extension in a so sl; do - if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && - test -f $ac_im_libdir/libX11.$ac_extension; then - ac_im_usrlibdir=$ac_im_libdir; break - fi - done - # Screen out bogus values from the imake configuration. They are - # bogus both because they are the default anyway, and because - # using them would break gcc on systems where it needs fixed includes. - case "$ac_im_incroot" in - /usr/include) ;; - *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; - esac - case "$ac_im_usrlibdir" in - /usr/lib | /lib) ;; - *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; - esac - fi - cd .. - rm -fr conftestdir -fi - -if test "$ac_x_includes" = NO; then - # Guess where to find include files, by looking for this one X11 .h file. - test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h - - # First, try using that file with no special directory specified. -cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2776: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - # We can compile using X headers with no special include directory. -ac_x_includes= -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - # Look for the header file in a standard set of common directories. -# Check X11 before X11Rn because it is often a symlink to the current release. - for ac_dir in \ - /usr/X11/include \ - /usr/X11R6/include \ - /usr/X11R5/include \ - /usr/X11R4/include \ - \ - /usr/include/X11 \ - /usr/include/X11R6 \ - /usr/include/X11R5 \ - /usr/include/X11R4 \ - \ - /usr/local/X11/include \ - /usr/local/X11R6/include \ - /usr/local/X11R5/include \ - /usr/local/X11R4/include \ - \ - /usr/local/include/X11 \ - /usr/local/include/X11R6 \ - /usr/local/include/X11R5 \ - /usr/local/include/X11R4 \ - \ - /usr/X386/include \ - /usr/x386/include \ - /usr/XFree86/include/X11 \ - \ - /usr/include \ - /usr/local/include \ - /usr/unsupported/include \ - /usr/athena/include \ - /usr/local/x11r5/include \ - /usr/lpp/Xamples/include \ - \ - /usr/openwin/include \ - /usr/openwin/share/include \ - ; \ - do - if test -r "$ac_dir/$x_direct_test_include"; then - ac_x_includes=$ac_dir - break - fi - done -fi -rm -f conftest* -fi # $ac_x_includes = NO - -if test "$ac_x_libraries" = NO; then - # Check for the libraries. - - test -z "$x_direct_test_library" && x_direct_test_library=Xt - test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc - - # See if we find them without any special options. - # Don't add to $LIBS permanently. - ac_save_LIBS="$LIBS" - LIBS="-l$x_direct_test_library $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - LIBS="$ac_save_LIBS" -# We can link X programs with no special library path. -ac_x_libraries= -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - LIBS="$ac_save_LIBS" -# First see if replacing the include by lib works. -# Check X11 before X11Rn because it is often a symlink to the current release. -for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ - /usr/X11/lib \ - /usr/X11R6/lib \ - /usr/X11R5/lib \ - /usr/X11R4/lib \ - \ - /usr/lib/X11 \ - /usr/lib/X11R6 \ - /usr/lib/X11R5 \ - /usr/lib/X11R4 \ - \ - /usr/local/X11/lib \ - /usr/local/X11R6/lib \ - /usr/local/X11R5/lib \ - /usr/local/X11R4/lib \ - \ - /usr/local/lib/X11 \ - /usr/local/lib/X11R6 \ - /usr/local/lib/X11R5 \ - /usr/local/lib/X11R4 \ - \ - /usr/X386/lib \ - /usr/x386/lib \ - /usr/XFree86/lib/X11 \ - \ - /usr/lib \ - /usr/local/lib \ - /usr/unsupported/lib \ - /usr/athena/lib \ - /usr/local/x11r5/lib \ - /usr/lpp/Xamples/lib \ - /lib/usr/lib/X11 \ - \ - /usr/openwin/lib \ - /usr/openwin/share/lib \ - ; \ -do - for ac_extension in a so sl; do - if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then - ac_x_libraries=$ac_dir - break 2 - fi - done -done -fi -rm -f conftest* -fi # $ac_x_libraries = NO - -if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then - # Didn't find X anywhere. Cache the known absence of X. - ac_cv_have_x="have_x=no" -else - # Record where we found X for the cache. - ac_cv_have_x="have_x=yes \ - ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" -fi -fi - fi - eval "$ac_cv_have_x" -fi # $with_x != no - -if test "$have_x" != yes; then - echo "$ac_t""$have_x" 1>&6 - no_x=yes -else - # If each of the values was on the command line, it overrides each guess. - test "x$x_includes" = xNONE && x_includes=$ac_x_includes - test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries - # Update the cache value to reflect the command line values. - ac_cv_have_x="have_x=yes \ - ac_x_includes=$x_includes ac_x_libraries=$x_libraries" - echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 -fi - -if test "$no_x" = yes; then - # Not all programs may use this symbol, but it does not hurt to define it. - cat >> confdefs.h <<\EOF -#define X_DISPLAY_MISSING 1 -EOF - - X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= -else - if test -n "$x_includes"; then - X_CFLAGS="$X_CFLAGS -I$x_includes" - fi - - # It would also be nice to do this for all -L options, not just this one. - if test -n "$x_libraries"; then - X_LIBS="$X_LIBS -L$x_libraries" - # For Solaris; some versions of Sun CC require a space after -R and - # others require no space. Words are not sufficient . . . . - case "`(uname -sr) 2>/dev/null`" in - "SunOS 5"*) - echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 -echo "configure:2958: checking whether -R must be followed by a space" >&5 - ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - ac_R_nospace=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_R_nospace=no -fi -rm -f conftest* - if test $ac_R_nospace = yes; then - echo "$ac_t""no" 1>&6 - X_LIBS="$X_LIBS -R$x_libraries" - else - LIBS="$ac_xsave_LIBS -R $x_libraries" - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - ac_R_space=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_R_space=no -fi -rm -f conftest* - if test $ac_R_space = yes; then - echo "$ac_t""yes" 1>&6 - X_LIBS="$X_LIBS -R $x_libraries" - else - echo "$ac_t""neither works" 1>&6 - fi - fi - LIBS="$ac_xsave_LIBS" - esac - fi - - # Check for system-dependent libraries X programs must link with. - # Do this before checking for the system-independent R6 libraries - # (-lICE), since we may need -lsocket or whatever for X linking. - - if test "$ISC" = yes; then - X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" - else - # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X - # libraries were built with DECnet support. And karl@cs.umb.edu says - # the Alpha needs dnet_stub (dnet does not exist). - echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 -echo "configure:3023: checking for dnet_ntoa in -ldnet" >&5 -ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldnet $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_lib_dnet_dnet_ntoa = no; then - echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 -echo "configure:3064: checking for dnet_ntoa in -ldnet_stub" >&5 -ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldnet_stub $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" -else - echo "$ac_t""no" 1>&6 -fi - - fi - - # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, - # to get the SysV transport functions. - # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4) - # needs -lnsl. - # The nsl library prevents programs from opening the X display - # on Irix 5.2, according to dickey@clark.net. - echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:3112: checking for gethostbyname" >&5 -if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char gethostbyname(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) -choke me -#else -gethostbyname(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_gethostbyname=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_gethostbyname=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_func_gethostbyname = no; then - echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:3161: checking for gethostbyname in -lnsl" >&5 -ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lnsl $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" -else - echo "$ac_t""no" 1>&6 -fi - - fi - - # lieder@skyler.mavd.honeywell.com says without -lsocket, - # socket/setsockopt and other routines are undefined under SCO ODT - # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary - # on later versions), says simon@lia.di.epfl.ch: it contains - # gethostby* variants that don't use the nameserver (or something). - # -lsocket must be given before -lnsl if both are needed. - # We assume that if connect needs -lnsl, so does gethostbyname. - echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:3210: checking for connect" >&5 -if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char connect(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_connect) || defined (__stub___connect) -choke me -#else -connect(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_connect=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_connect=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_func_connect = no; then - echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:3259: checking for connect in -lsocket" >&5 -ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsocket $X_EXTRA_LIBS $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" -else - echo "$ac_t""no" 1>&6 -fi - - fi - - # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. - echo $ac_n "checking for remove""... $ac_c" 1>&6 -echo "configure:3302: checking for remove" >&5 -if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char remove(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_remove) || defined (__stub___remove) -choke me -#else -remove(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3330: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_remove=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_remove=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_func_remove = no; then - echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 -echo "configure:3351: checking for remove in -lposix" >&5 -ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lposix $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" -else - echo "$ac_t""no" 1>&6 -fi - - fi - - # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. - echo $ac_n "checking for shmat""... $ac_c" 1>&6 -echo "configure:3394: checking for shmat" >&5 -if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shmat(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_shmat) || defined (__stub___shmat) -choke me -#else -shmat(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_shmat=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_shmat=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_func_shmat = no; then - echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 -echo "configure:3443: checking for shmat in -lipc" >&5 -ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lipc $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" -else - echo "$ac_t""no" 1>&6 -fi - - fi - fi - - # Check for libraries that X11R6 Xt/Xaw programs need. - ac_save_LDFLAGS="$LDFLAGS" - test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" - # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to - # check for ICE first), but we must link in the order -lSM -lICE or - # we get undefined symbols. So assume we have SM if we have ICE. - # These have to be linked with before -lX11, unlike the other - # libraries we check for below, so use a different variable. - # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. - echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 -echo "configure:3495: checking for IceConnectionNumber in -lICE" >&5 -ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lICE $X_EXTRA_LIBS $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" -else - echo "$ac_t""no" 1>&6 -fi - - LDFLAGS="$ac_save_LDFLAGS" - -fi - -for ac_prog in tclsh -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3543: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_TCLSH'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$TCLSH"; then - ac_cv_prog_TCLSH="$TCLSH" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_TCLSH="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -TCLSH="$ac_cv_prog_TCLSH" -if test -n "$TCLSH"; then - echo "$ac_t""$TCLSH" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$TCLSH" && break -done -test -n "$TCLSH" || TCLSH="false" - -if test "$TCLSH" != false; then - ac_safe=`echo "tcl.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for tcl.h""... $ac_c" 1>&6 -echo "configure:3576: checking for tcl.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3586: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - echo $ac_n "checking for ldopen in -lld""... $ac_c" 1>&6 -echo "configure:3603: checking for ldopen in -lld" >&5 -ac_lib_var=`echo ld'_'ldopen | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lld $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - TCLOTHERLIBS=-lld -else - echo "$ac_t""no" 1>&6 -fi - - echo $ac_n "checking for Tcl_CreateInterp in -ltcl""... $ac_c" 1>&6 -echo "configure:3643: checking for Tcl_CreateInterp in -ltcl" >&5 -ac_lib_var=`echo tcl'_'Tcl_CreateInterp | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ltcl $TCLOTHERLIBS -lm $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - saveCFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $X_CFLAGS" - echo $ac_n "checking for Tk_CreateWindow in -ltk""... $ac_c" 1>&6 -echo "configure:3680: checking for Tk_CreateWindow in -ltk" >&5 -ac_lib_var=`echo tk'_'Tk_CreateWindow | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ltk -ltcl $TCLOTHERLIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define HAVE_TCL 1 -EOF - - TCLLIBS="-ltk -ltcl $TCLOTHERLIBS" - ac_ext=C -# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cxx_cross - - echo $ac_n "checking for Tree_Init in -lTkTree""... $ac_c" 1>&6 -echo "configure:3727: checking for Tree_Init in -lTkTree" >&5 -ac_lib_var=`echo TkTree'_'Tree_Init | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lTkTree -lTkTree -ltk -ltcl $TCLOTHERLIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - TREELIBS="-lTkTree" -else - echo "$ac_t""no" 1>&6 -echo "$ac_t""tcl/tk libs found, but tree widget is missing" 1>&6 -fi - - ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -else - echo "$ac_t""no" 1>&6 -echo "$ac_t""tcl lib found, but tk lib is missing" 1>&6 -fi - - CFLAGS="$saveCFLAGS" -else - echo "$ac_t""no" 1>&6 -echo "$ac_t""tcl library not found" 1>&6 -fi - -else - echo "$ac_t""no" 1>&6 -fi - -fi - - -for ac_prog in latex -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3800: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LATEX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$LATEX"; then - ac_cv_prog_LATEX="$LATEX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_LATEX="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -LATEX="$ac_cv_prog_LATEX" -if test -n "$LATEX"; then - echo "$ac_t""$LATEX" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$LATEX" && break -done -test -n "$LATEX" || LATEX="false" - -for ac_prog in bibtex -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3835: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_BIBTEX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$BIBTEX"; then - ac_cv_prog_BIBTEX="$BIBTEX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_BIBTEX="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -BIBTEX="$ac_cv_prog_BIBTEX" -if test -n "$BIBTEX"; then - echo "$ac_t""$BIBTEX" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$BIBTEX" && break -done -test -n "$BIBTEX" || BIBTEX="false" - -for ac_prog in dvips -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3870: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_DVIPS'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$DVIPS"; then - ac_cv_prog_DVIPS="$DVIPS" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_DVIPS="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -DVIPS="$ac_cv_prog_DVIPS" -if test -n "$DVIPS"; then - echo "$ac_t""$DVIPS" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$DVIPS" && break -done -test -n "$DVIPS" || DVIPS="false" - -for ac_prog in detex2 detex -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3905: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_DETEX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$DETEX"; then - ac_cv_prog_DETEX="$DETEX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_DETEX="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -DETEX="$ac_cv_prog_DETEX" -if test -n "$DETEX"; then - echo "$ac_t""$DETEX" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$DETEX" && break -done -test -n "$DETEX" || DETEX="false" - -for ac_prog in ghostview gs -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3940: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_PSPREVIEW'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$PSPREVIEW"; then - ac_cv_prog_PSPREVIEW="$PSPREVIEW" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_PSPREVIEW="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -PSPREVIEW="$ac_cv_prog_PSPREVIEW" -if test -n "$PSPREVIEW"; then - echo "$ac_t""$PSPREVIEW" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$PSPREVIEW" && break -done -test -n "$PSPREVIEW" || PSPREVIEW="true" - -for ac_prog in psbook -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3975: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_PSBOOK'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$PSBOOK"; then - ac_cv_prog_PSBOOK="$PSBOOK" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_PSBOOK="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -PSBOOK="$ac_cv_prog_PSBOOK" -if test -n "$PSBOOK"; then - echo "$ac_t""$PSBOOK" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$PSBOOK" && break -done -test -n "$PSBOOK" || PSBOOK="false" - -for ac_prog in psnup -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4010: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_PSNUP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$PSNUP"; then - ac_cv_prog_PSNUP="$PSNUP" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_PSNUP="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -PSNUP="$ac_cv_prog_PSNUP" -if test -n "$PSNUP"; then - echo "$ac_t""$PSNUP" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$PSNUP" && break -done -test -n "$PSNUP" || PSNUP="false" - -for ac_prog in ispell spell -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4045: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_SPELL'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$SPELL"; then - ac_cv_prog_SPELL="$SPELL" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_SPELL="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -SPELL="$ac_cv_prog_SPELL" -if test -n "$SPELL"; then - echo "$ac_t""$SPELL" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$SPELL" && break -done -test -n "$SPELL" || SPELL="spell" - -trap '' 1 2 15 -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -DEFS=-DHAVE_CONFIG_H - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS </dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" - -trap 'rm -fr `echo "makehead config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@SET_MAKE@%$SET_MAKE%g -s%@CC@%$CC%g -s%@MKDEP_CCINC@%$MKDEP_CCINC%g -s%@CPP@%$CPP%g -s%@CXX@%$CXX%g -s%@SNACC_NOVOLAT@%$SNACC_NOVOLAT%g -s%@LEX@%$LEX%g -s%@LEXLIB@%$LEXLIB%g -s%@LEX_OUTPUT_ROOT@%$LEX_OUTPUT_ROOT%g -s%@LFLAGS@%$LFLAGS%g -s%@PATCH@%$PATCH%g -s%@YACC@%$YACC%g -s%@MKDEP@%$MKDEP%g -s%@AR@%$AR%g -s%@RANLIB@%$RANLIB%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@X_CFLAGS@%$X_CFLAGS%g -s%@X_PRE_LIBS@%$X_PRE_LIBS%g -s%@X_LIBS@%$X_LIBS%g -s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g -s%@TCLSH@%$TCLSH%g -s%@TCLLIBS@%$TCLLIBS%g -s%@TREELIBS@%$TREELIBS%g -s%@LATEX@%$LATEX%g -s%@BIBTEX@%$BIBTEX%g -s%@DVIPS@%$DVIPS%g -s%@DETEX@%$DETEX%g -s%@PSPREVIEW@%$PSPREVIEW%g -s%@PSBOOK@%$PSBOOK%g -s%@PSNUP@%$PSNUP%g -s%@SPELL@%$SPELL%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' -ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -if test "${CONFIG_HEADERS+set}" != set; then -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. - -rm -f conftest.tail -while : -do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS - echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - fi - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done - -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -date > stamp-h -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - diff --git a/SecuritySNACCRuntime/configure.in b/SecuritySNACCRuntime/configure.in deleted file mode 100644 index 51f27769..00000000 --- a/SecuritySNACCRuntime/configure.in +++ /dev/null @@ -1,189 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -dnl --- -AC_REVISION($Revision: 1.1.1.1 $)dnl -dnl $Log: configure.in,v $ -dnl Revision 1.1.1.1 2001/05/18 23:14:04 mb -dnl Move from private repository to open source repository -dnl -dnl Revision 1.3 2000/12/21 23:58:39 dmitch -dnl Misc. updates for clean build on Cheetah 1D7. -dnl -dnl Revision 1.2 2000/06/08 19:57:33 dmitch -dnl Mods for X port. -dnl -dnl Revision 1.1.1.1 1999/03/16 18:05:49 aram -dnl Originals from SMIME Free Library. -dnl -dnl Revision 1.13 1997/09/04 13:54:04 wan -dnl A little more portability -dnl -dnl Revision 1.12 1997/02/28 13:39:35 wan -dnl Modifications collected for new version 1.3: Bug fixes, tk4.2. -dnl -dnl Revision 1.11 1997/02/16 16:50:27 rj -dnl made return *this after calling abort()'' a compile time option. -dnl -dnl Revision 1.10 1997/02/15 20:06:27 rj -dnl adjust to changed AC_TRY_COMPILE macro -dnl -dnl Revision 1.9 1997/02/15 20:01:38 rj -dnl check whether the compiler supports volatile functions (and whether abort() is volatile). -dnl -dnl Revision 1.8 1997/01/01 19:57:01 rj -dnl changes for autoconf version 2.12 -dnl -dnl Revision 1.7 1995/09/07 18:36:47 rj -dnl psbook and psnup are looked for (used by .../doc/makefile) -dnl -dnl Revision 1.6 1995/07/24 14:44:47 rj -dnl don't use gcc/g++ with -pipe, compiling some files may exceed virtual memory. -dnl -dnl look for tclsh(1). tcl-lib uses it to construct the tclIndex file. don't look for Tcl/Tk if the tclsh is absent. -dnl -dnl look for patch(1). the c-lib uses it to patch tbl.h. -dnl -dnl search for tree-3.6's libtktree.a and set TREELIBS in .../makehead accordingly. -dnl -dnl check for memset(3), memcpy(3) and memcmp(3). .../snacc.h reverts to bzero(3), bcopy(3) and bcmp(3) if necessary. -dnl -dnl Revision 1.5 1995/02/20 11:18:41 rj -dnl cpp switch HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS added. -dnl check for isinf(3) and finite(3) added. -dnl -dnl Revision 1.4 1995/02/17 15:15:44 rj -dnl hack to let makedepend find .h files the way gcc does. -dnl -dnl Revision 1.3 1995/02/17 14:26:40 rj -dnl adjustments for autoconf 2.x -dnl -dnl Revision 1.2 1994/10/08 04:29:37 rj -dnl search for Tcl/Tk -dnl -dnl Revision 1.1 1994/09/01 00:51:22 rj -dnl first check-in (new file). -dnl -AC_INIT( compiler/core/snacc.c) -AC_CONFIG_HEADER( config.h) -dnl --- alternative programs: -AC_PROG_MAKE_SET -AC_PROG_CC -AC_ISC_POSIX -if test -n "$GCC"; then -dnl saveCC="$CC" -dnl CC="$CC -pipe" -dnl AC_MSG_CHECKING( whether $saveCC takes -pipe) -dnl AC_TRY_LINK( , , [AC_MSG_RESULT( yes)], [AC_MSG_RESULT( no); CC="$saveCC"]) - - # hack to let X11 makedepend find .h file a little more the way gcc does: - AC_MSG_CHECKING( for $CC's include path) - gcclibdir=`$CC -v 2>&1 | sed -n -e 's:Reading specs from \(.*\)/specs:\1:p'` - gxxincdir=`which gcc | sed "s/bin\/gcc//"` - #MKDEP_CCINC="-I$gxxincdir/lib/g++-include -I/usr/local/include -I$gcclibdir/include" - MKDEP_CCINC="-I/usr/local/include -I$gcclibdir/include -F/System/Library/PrivateFrameworks" - AC_MSG_RESULT( $MKDEP_CCINC) - AC_SUBST( MKDEP_CCINC) -fi -AC_PROG_GCC_TRADITIONAL -AC_PROG_CC_C_O -if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then - AC_MSG_WARN( since -c and -o don't seem to work together, the makefiles probably won't work!) -fi -AC_MSG_CHECKING( whether ANSI or K&R style C) -AC_TRY_RUN( [main (int argc, char **argv) { void *p; return 0; }], [AC_MSG_RESULT( ANSI); AC_DEFINE( __USE_ANSI_C__)], AC_MSG_RESULT( K&R), AC_MSG_RESULT( K&R)) -AC_PROG_CXX -AC_LANG_CPLUSPLUS -dnl if test -n "$GCC"; then -dnl saveCXX="$CXX" -dnl CXX="$CXX -pipe" -dnl AC_MSG_CHECKING( whether $saveCXX takes -pipe) -dnl AC_TRY_LINK( , , [AC_MSG_RESULT( yes)], [AC_MSG_RESULT( no);CC="$saveCC"]) -dnl fi -AC_MSG_CHECKING( for bool built-in) -AC_TRY_COMPILE( , bool b = false;, [AC_DEFINE( BOOL_BUILTIN) AC_MSG_RESULT( yes)], AC_MSG_RESULT( no)) -AC_MSG_CHECKING( for variable sized automatic arrays) -AC_TRY_COMPILE( , changequote(<,>)int i = 42; char a[++i]; *a = i;changequote([,]), [AC_DEFINE( HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS) AC_MSG_RESULT( yes)], AC_MSG_RESULT( no)) -AC_MSG_CHECKING( for volatile functions) -AC_TRY_COMPILE( , changequote(<,>)abort();changequote([,]), [AC_MSG_RESULT( yes)], [AC_DEFINE( COMPILER_WITHOUT_VOLATILE_FUNCTIONS) SNACC_NOVOLAT=-novolat; AC_SUBST( SNACC_NOVOLAT) AC_MSG_RESULT( no)]) -AC_LANG_C -AC_PROG_LEX -AC_DECL_YYTEXT -case "$LEX" in - lex) - LFLAGS="-Nc10000" - ;; - flex) - CFLAGS="$CFLAGS -DFLEX_IN_USE" -esac -AC_SUBST( LFLAGS) -AC_SUBST( CFLAGS) -# the boot strapping code in .../c-lib/ needs patch: -AC_CHECK_PROGS( PATCH, patch, false) -AC_PROG_YACC -AC_CHECK_PROGS( MKDEP, makedepend mkdep mkdep.sh, $CC) -AC_CHECK_PROGS( AR, ar, ar) -AC_PROG_RANLIB -AC_PROG_INSTALL -dnl --- header files: -AC_HEADER_TIME -AC_HEADER_DIRENT -AC_TYPE_SIZE_T -AC_TYPE_UID_T -AC_HEADER_STDC -AC_CHECK_HEADERS( unistd.h memory.h string.h malloc.h fcntl.h) -AC_FUNC_VPRINTF -dnl --- system and compiler characteristics: -AC_C_CONST -AC_C_BIGENDIAN -AC_CHECK_SIZEOF( short) -AC_CHECK_SIZEOF( int) -AC_CHECK_SIZEOF( long) -AC_CHECK_SIZEOF( double) -AC_CHECK_LIB( m, sin) -AC_CHECK_FUNCS( isinf finite) -AC_CHECK_FUNCS( memset memcpy memcmp) -dnl --- -AC_PATH_X -AC_PATH_XTRA -AC_CHECK_PROGS( TCLSH, tclsh, false) -if test "$TCLSH" != false; then - AC_CHECK_HEADER( - tcl.h, - [AC_CHECK_LIB( ld, ldopen, TCLOTHERLIBS=-lld) - AC_CHECK_LIB( - tcl, - Tcl_CreateInterp, - [saveCFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $X_CFLAGS" - AC_CHECK_LIB( - tk, - Tk_CreateWindow, - [AC_DEFINE( HAVE_TCL) - TCLLIBS="-ltk -ltcl $TCLOTHERLIBS" - AC_LANG_CPLUSPLUS - AC_CHECK_LIB( - TkTree, - Tree_Init, - [TREELIBS="-lTkTree"], - [AC_MSG_RESULT( [tcl/tk libs found, but tree widget is missing])], - -lTkTree -ltk -ltcl $TCLOTHERLIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS) - AC_LANG_C], - [AC_MSG_RESULT( [tcl lib found, but tk lib is missing])], - -ltcl $TCLOTHERLIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS) - CFLAGS="$saveCFLAGS"], - [AC_MSG_RESULT( [tcl library not found])], - $TCLOTHERLIBS -lm)]) -fi -AC_SUBST( TCLLIBS) -AC_SUBST( TREELIBS) -dnl --- -AC_CHECK_PROGS( LATEX, latex, false) -AC_CHECK_PROGS( BIBTEX, bibtex, false) -AC_CHECK_PROGS( DVIPS, dvips, false) -AC_CHECK_PROGS( DETEX, detex2 detex, false) -AC_CHECK_PROGS( PSPREVIEW, ghostview gs, true) -AC_CHECK_PROGS( PSBOOK, psbook, false) -AC_CHECK_PROGS( PSNUP, psnup, false) -AC_CHECK_PROGS( SPELL, ispell spell, spell) -dnl --- -AC_OUTPUT( makehead, date > stamp-h) -dnl --- finis diff --git a/SecuritySNACCRuntime/doc/asn1-defs.tex b/SecuritySNACCRuntime/doc/asn1-defs.tex deleted file mode 100644 index 17df9029..00000000 --- a/SecuritySNACCRuntime/doc/asn1-defs.tex +++ /dev/null @@ -1,910 +0,0 @@ -% file: .../doc/asn1-defs.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/asn1-defs.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: asn1-defs.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:51 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:47 rj -% first check-in -% - -\chapter{The Module Data Structure ASN.1 Definition} - -The ASN.1 modules are parsed into an internal data structure. The -data structure was initially defined in ASN.1 with the idea that if -we needed to write a parsed module to disk, the ASN.1 encoding -routines could be used. No file format was needed so the ASN.1 was -merely an exercise. - -This procedure highlighted the problem with circular links and index -like links in ASN.1 data structures. BER does not support this type -of linking; to handle it, the offending links can be made optional -and not encoded. After decoding, these links need to be -re-established. See the type table data structure for a format -suitable for writing to files. - -The following is the ASN.1 definition of the Module data structure. -The C translation (as generated by an early version of Snacc) can be -found in {\ufn \dots/compiler/core/asn1module.h}\footnote{ - The {\ufn asn1module.h} that is produced by a current version of Snacc cannot be compiled because its type definitions are in the wrong order. - This may be caused by the {\ASN --\,--snacc cTypeName} compiler directives, since one of the affected types is BasicTypeChoiceId, but i'm not really sure. - ---rj -}. -\begin{small} -\begin{verbatim} --- .../asn1specs/asn1module.asn1 --- --- This module describes the data structure used to represent the --- compiled ASN.1. --- Using ASN.1 for the internal data structure allows writing --- (encoding) to disk for storage (not done yet due to recursive --- refs back to the module) --- --- Mike Sample 91/08/29 --- Modifed 92/05 MS --- - -Asn1Module DEFINITIONS IMPLICIT TAGS ::= -BEGIN - --- exports everything --- imports nothing - -Modules ::= [APPLICATION 0] IMPLICIT SEQUENCE -{ - creationTime INTEGER, - modules ModuleList -} - -ModuleList ::= SEQUENCE OF Module - - -Module ::= SEQUENCE -{ - status ENUMERATED { mod-ok(0), mod-not-linked(1), mod-error(2) }, - modId ModuleId, - tagDefault ENUMERATED { explicit-tags(0), implicit-tags(1) }, - exportStatus ENUMERATED { exports-all(0), exports-nothing(1), - exports-some(2) }, - imports ImportModuleList, - typeDefs TypeDefList, - valueDefs ValueDefList, - hasAnys BOOLEAN, - - asn1SrcFileName MyString, - cHdrFileName MyString, - cSrcFileName MyString, - cxxHdrFileName MyString, - cxxSrcFileName MyString - - cxxname MyString, -- META - - idlFileName MyString, -- IDL - idlname MyString -- IDL -} - - -ModuleId ::= SEQUENCE -{ - name MyString, - oid OBJECT IDENTIFIER OPTIONAL --snacc cTypeName:"OID" isPtr:"TRUE" -} - - -ImportModuleList ::= SEQUENCE OF ImportModule - - -ImportModule ::= SEQUENCE -{ - modId ModuleId, - importElmts ImportElmtList, - moduleRef Module, --snacc isEncDec:"FALSE" - lineNo INTEGER -} - - -ImportElmtList ::= SEQUENCE OF ImportElmt - - -ImportElmt ::= SEQUENCE -{ - resolvedRef CHOICE - { - type [0] TypeDef, -- not encoded - value [1] ValueDef -- not encoded - } OPTIONAL, - name MyString, - privateScope BOOLEAN, -- true if from MODNAME.TYPE ref - lineNo INTEGER -} - -TypeDefList ::= SEQUENCE OF TypeDef - -OidOrInt ::= CHOICE -{ - oid OBJECT IDENTIFIER, - intId INTEGER -} - -AnyRef ::= SEQUENCE -{ - anyIdName MyString, - id OidOrInt -} - -AnyRefList ::= SEQUENCE OF AnyRef - -TypeDef ::= SEQUENCE -{ - exported BOOLEAN, - recursive BOOLEAN, - isPdu BOOLEAN, - localRefCount INTEGER, - importRefCount INTEGER, - tmpRefCount INTEGER, - visited BOOLEAN, - definedName MyString, - type Type, - cTypeDefInfo CTDI, - cxxTypeDefInfo CxxTDI, - attrList AttributeList, - refList TypeDefList, - anyRefs AnyRefList -} - - -Tag ::= SEQUENCE -{ - tclass INTEGER, -- swap this for the BER_CLASS enum from basetypes.h - form INTEGER, -- swap this for the BER_FORM enum - code INTEGER, - explicit BOOLEAN, - valueRef Value -} - -Type ::= SEQUENCE -{ - optional BOOLEAN, - implicit BOOLEAN, - tags TagList, - defaultVal [0] IMPLICIT NamedValue OPTIONAL, - subtypes [1] Subtype OPTIONAL, - basicType [2] BasicType, - lineNo INTEGER, - cTypeRefInfo CTRI, - cxxTypeRefInfo CxxTRI, - attrList AttributeList -} - -TagList ::= SEQUENCE OF Tag - -AttributeList ::= SEQUENCE OF MyString - -NamedNumberList ::= ValueDefList - - --- BasicTypes with NULL need no more info that which type it is --- (this is known from the choice id) - -BasicType ::= CHOICE -{ - unknown [0] IMPLICIT NULL, - boolean [1] IMPLICIT NULL, - integer [2] IMPLICIT NamedNumberList, - bitString [3] IMPLICIT NamedNumberList, - octetString [4] IMPLICIT NULL, - null [5] IMPLICIT NULL, - oid [6] IMPLICIT NULL, - real [7] IMPLICIT NULL, - enumerated [8] IMPLICIT NamedNumberList, - sequence [9] IMPLICIT NamedTypeList, - sequenceOf [10] IMPLICIT Type, - set [11] IMPLICIT NamedTypeList, - setOf [12] IMPLICIT Type, - choice [13] IMPLICIT NamedTypeList, - selection [14] IMPLICIT SelectionType, - componentsOf [15] IMPLICIT Type, -- [Resolved](local/import) type ref - any [16] IMPLICIT NULL, - anyDefinedBy [17] IMPLICIT AnyDefinedByType, - localTypeRef [19] IMPLICIT TypeRef, - importTypeRef [20] IMPLICIT TypeRef, - macroType [21] MacroType, - macroDef [22] IMPLICIT MacroDef --snacc isPtr:"FALSE" -} - -MacroDef ::= MyString -- just keep the text for now - -MacroType ::= CHOICE -{ - rosOperation [0] IMPLICIT RosOperationMacroType, - rosError [1] IMPLICIT RosErrorMacroType, - rosBind [2] IMPLICIT RosBindMacroType, - rosUnbind [3] IMPLICIT RosBindMacroType, - rosAse [4] IMPLICIT RosAseMacroType, - rosAc [5] IMPLICIT RosAcMacroType, - mtsasExtension [6] IMPLICIT MtsasExtensionMacroType, - mtsasExtensions [7] IMPLICIT MtsasExtensionsMacroType, - mtsasExtensionAttribute [8] IMPLICIT MtsasExtensionAttributeMacroType, - mtsasToken [9] IMPLICIT MtsasTokenMacroType, - mtsasTokenData [10] IMPLICIT MtsasTokenDataMacroType, - mtsasSecurityCategory [11] IMPLICIT MtsasSecurityCategoryMacroType, - asnObject [12] IMPLICIT AsnObjectMacroType, - asnPort [13] IMPLICIT AsnPortMacroType, - asnRefine [14] IMPLICIT AsnRefineMacroType, - asnAbstractBind [15] IMPLICIT AsnAbstractBindMacroType, - asnAbstractUnbind [16] IMPLICIT AsnAbstractBindMacroType, - asnAbstractOperation [17] IMPLICIT RosOperationMacroType, - asnAbstractError [18] IMPLICIT RosErrorMacroType, - afAlgorithm [19] IMPLICIT Type, - afEncrypted [20] IMPLICIT Type, - afProtected [21] IMPLICIT Type, - afSignature [22] IMPLICIT Type, - afSigned [23] IMPLICIT Type, - snmpObjectType [24] IMPLICIT SnmpObjectTypeMacroType -} - - -AnyDefinedByType ::= SEQUENCE -{ - fieldName MyString, -- name of field that its defined by - link NamedType OPTIONAL -- REFERENCE not encoded -} - - -SelectionType ::= SEQUENCE -{ - fieldName MyString, -- name of field in choice - typeRef Type, -- [Resolved](local/import) type ref - link NamedType OPTIONAL -- REFERENCE not encoded -} - -NamedTypeList ::= SEQUENCE OF NamedType - -NamedType ::= SEQUENCE -{ - fieldName MyString, -- may be empty or NULL str - type Type -} - - -TypeRef ::= SEQUENCE -{ - typeName MyString, - moduleName MyString, -- used for "modname.type" refs (may be null) - module Module, --snacc isEncDec:"FALSE" - link TypeDef --snacc isEncDec:"FALSE" -} - - - -RosOperationMacroType ::= SEQUENCE -{ - arguments NamedType, - result NamedType, - errors [0] IMPLICIT TypeOrValueList OPTIONAL, - linkedOps [1] IMPLICIT TypeOrValueList OPTIONAL -} - -ValueList ::= SEQUENCE OF Value - -TypeOrValueList ::= SEQUENCE OF TypeOrValue - -TypeOrValue ::= CHOICE -{ - type [0] IMPLICIT Type, - value [1] IMPLICIT Value -} - -OidList ::= SEQUENCE OF OBJECT IDENTIFIER - - -RosErrorMacroType ::= SEQUENCE -{ - parameter NamedType -} - -RosBindMacroType ::= SEQUENCE -{ - argument NamedType, - result NamedType, - error NamedType -} - - -RosAseMacroType ::= SEQUENCE -{ - operations ValueList, - consumerInvokes ValueList, - supplierInvokes ValueList -} - -RosAcMacroType ::= SEQUENCE -{ - nonRoElements ValueList, - bindMacroType Type, - unbindMacroType Type, - remoteOperations Value, - operationsOf ValueList, - initiatorConsumerOf ValueList, - responderConsumerOf ValueList, - abstractSyntaxes OidList -} - - -MtsasExtensionMacroType ::= SEQUENCE -{ - elmtType [0] IMPLICIT NamedType OPTIONAL, - defaultValue [1] IMPLICIT Value OPTIONAL, - criticalForSubmission [2] IMPLICIT BOOLEAN OPTIONAL, - criticalForTransfer [3] IMPLICIT BOOLEAN OPTIONAL, - criticalForDelivery [4] IMPLICIT BOOLEAN OPTIONAL -} - - -MtsasExtensionsMacroType ::= SEQUENCE -{ - extensions ValueList -} - -MtsasExtensionAttributeMacroType ::= SEQUENCE -{ - type Type OPTIONAL -} - -MtsasTokenMacroType ::= SEQUENCE -{ - type Type OPTIONAL -} - -MtsasTokenDataMacroType ::= SEQUENCE -{ - type Type OPTIONAL -} - -MtsasSecurityCategoryMacroType ::= SEQUENCE -{ - type Type OPTIONAL -} - -AsnObjectMacroType ::= SEQUENCE -{ - ports AsnPortList OPTIONAL -} - -AsnPortList ::= SEQUENCE OF AsnPort - -AsnPort ::= SEQUENCE -{ - portValue Value, - portType ENUMERATED - { - consumer-port (0), - supplier-port (1), - symmetric-port (2) - } -} - - -AsnPortMacroType ::= SEQUENCE -{ - abstractOps [0] IMPLICIT TypeOrValueList OPTIONAL, - consumerInvokes [1] IMPLICIT TypeOrValueList OPTIONAL, - supplierInvokes [2] IMPLICIT TypeOrValueList OPTIONAL -} - - -AsnRefineMacroType ::= INTEGER - -AsnAbstractBindMacroType ::= SEQUENCE -{ - ports [0] IMPLICIT AsnPortList OPTIONAL, - type [1] IMPLICIT Type OPTIONAL -} - - -SnmpObjectTypeMacroType ::= SEQUENCE -{ - syntax Type, - access ENUMERATED - { snmp-read-only (0), snmp-read-write (1), - snmp-write-only (2), snmp-not-accessible (3)}, - status ENUMERATED - { snmp-mandatory (0), snmp-optional (1), - snmp-obsolete (2), snmp-deprecated (3)}, - description [0] IMPLICIT Value OPTIONAL, - reference [1] IMPLICIT Value OPTIONAL, - index [2] IMPLICIT TypeOrValueList OPTIONAL, - defVal [3] IMPLICIT Value OPTIONAL -} - - -Subtype ::= CHOICE -{ - single [0] SubtypeValue, - and [1] IMPLICIT SubtypeList, - or [2] IMPLICIT SubtypeList, - not [3] Subtype -} - -SubtypeList ::= SEQUENCE OF Subtype - -SubtypeValue ::= CHOICE -{ - singleValue [0] IMPLICIT Value, - contained [1] IMPLICIT Type, - valueRange [2] IMPLICIT ValueRangeSubtype, - permittedAlphabet [3] Subtype, -- only valuerange or singleval - sizeConstraint [4] Subtype, -- only single value ints or val range - innerSubtype [5] IMPLICIT InnerSubtype -} - - -ValueRangeSubtype ::= SEQUENCE -{ - lowerEndInclusive BOOLEAN, - upperEndInclusive BOOLEAN, - lowerEndValue Value, - upperEndValue Value -} - - -InnerSubtype ::= SEQUENCE -{ - constraintType ENUMERATED { full-ct (0), partial-ct (1), single-ct (2) }, - constraints ConstraintList -} - -ConstraintList ::= SEQUENCE OF Constraint - -Constraint ::= SEQUENCE -{ - fieldRef MyString, -- not used if in single-ct, may be null - presenceConstraint ENUMERATED - { - present-ct (0), - absent-ct (1), - empty-ct (2), - optional-ct (3) - }, - valueConstraints Subtype -} - - -ValueDefList ::= SEQUENCE OF ValueDef - - -ValueDef ::= SEQUENCE -{ - exported BOOLEAN, - definedName MyString, - value Value -} - -Value ::= SEQUENCE -{ - type Type OPTIONAL, - valueType INTEGER, -- holds one of choiceId's def'd for BasicType - basicValue BasicValue, - lineNo INTEGER -} - -BasicValue ::= CHOICE -{ - unknown [0] IMPLICIT NULL, - empty [1] IMPLICIT NULL, - integer [2] IMPLICIT INTEGER, - specialInteger [3] IMPLICIT SpecialIntegerValue, - longInteger [4] IMPLICIT INTEGER, -- put LONG before INTGEGER - boolean [5] IMPLICIT BOOLEAN, - real [6] IMPLICIT REAL, - specialReal [7] IMPLICIT SpecialRealValue, - asciiText [8] IMPLICIT OCTET STRING, - asciiHex [9] IMPLICIT OCTET STRING, - asciiBitString [10] IMPLICIT OCTET STRING, - oid [11] IMPLICIT OBJECT IDENTIFIER, - linkedOid [12] IMPLICIT OBJECT IDENTIFIER, --snacc cTypeName:"OID" - berValue [13] IMPLICIT OCTET STRING, - perValue [14] IMPLICIT OCTET STRING, - namedValue [15] IMPLICIT NamedValue, - null [16] IMPLICIT NULL, - localValueRef [17] IMPLICIT ValueRef, - importValueRef [18] IMPLICIT ValueRef, - valueNotation [19] IMPLICIT OCTET STRING -} - - - -SpecialIntegerValue ::= ENUMERATED { min-int (0), max-int (1) } -SpecialRealValue ::= ENUMERATED { minus-infinity-real (0), plus-infinity-real (1) } - - -ValueRef ::= SEQUENCE -{ - valueName MyString, - moduleName MyString, -- used for "modname.value" refs (may be null) - link ValueDef, --snacc isEncDec:"FALSE" - module Module --snacc isEncDec:"FALSE" -} - -NamedValue ::= SEQUENCE -{ - fieldName MyString, -- may be null - value Value -} - -NamedValueList ::= SEQUENCE OF NamedValue - -CTypeId ::= ENUMERATED { c-choice (0), c-list (1), c-any (2), c-anydefinedby (3), - c-lib (4), c-struct (5), c-typeref (6), c-no-type (7), - c-typedef (8) } - --- C Type Def Info - info used for routine naming --- and referencing from other types -CTDI ::= SEQUENCE -{ - asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId" - cTypeId CTypeId, - cTypeName MyString, - isPdu BOOLEAN, - isEncDec BOOLEAN, -- if false, no routines are gen - -- and not included in encodings - isPtrForTypeDef BOOLEAN, - isPtrForTypeRef BOOLEAN, - isPtrInChoice BOOLEAN, - isPtrForOpt BOOLEAN, - - -- defines these names, used by references - optTestRoutineName MyString, -- routine/macro to check whether - -- opt type is present - defaultFieldName MyString, -- base for generating field names - - printRoutineName MyString, - encodeRoutineName MyString, - decodeRoutineName MyString, - freeRoutineName MyString, - - genPrintRoutine BOOLEAN, - genEncodeRoutine BOOLEAN, - genDecodeRoutine BOOLEAN, - genFreeRoutine BOOLEAN, - genTypeDef BOOLEAN -} - - --- --- CTRI (C Type Ref Info) is used for generating C typedefinitions --- from the ASN.1 types info -CTRI ::= SEQUENCE -{ - cTypeId CTypeId, - cFieldName MyString, - cTypeName MyString, - isPtr BOOLEAN, --- isEndCType BOOLEAN, -- false for struct/union def - cNamedElmts CNamedElmts OPTIONAL, -- for C_LIB bits/int/enums - choiceIdValue INTEGER, -- enum value of this c field - choiceIdSymbol MyString, -- this fields sym in choiceId enum - choiceIdEnumName MyString, - choiceIdEnumFieldName MyString, - optTestRoutineName MyString, -- these names are gained from refd type def - printRoutineName MyString, -- or are over-ridden snacc attribute comment - encodeRoutineName MyString, - decodeRoutineName MyString, - freeRoutineName MyString, - isEncDec BOOLEAN -- whether part of enc value -} - -CNamedElmts ::= SEQUENCE OF CNamedElmt - -CNamedElmt ::= SEQUENCE -{ - name MyString, - value INTEGER -} - - -CxxTDI ::= SEQUENCE -{ - asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId" - className MyString, - isPdu BOOLEAN, - isEnc BOOLEAN, - isPtrForTypeDef BOOLEAN, - isPtrForOpt BOOLEAN, - isPtrInChoice BOOLEAN, - isPtrInSetAndSeq BOOLEAN, - isPtrInList BOOLEAN, - optTestRoutineName MyString, - defaultFieldName MyString -- base for generating field names -} - - - -CxxTRI ::= SEQUENCE -{ - isEnc BOOLEAN, - className MyString, - fieldName MyString, - isPtr BOOLEAN, - namedElmts CNamedElmts, - choiceIdSymbol MyString, - choiceIdValue INTEGER, - optTestRoutineName MyString -} - -IDLTDI ::= SEQUENCE -{ - asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId" - typeName MyString, - isPdu BOOLEAN, - isEnc BOOLEAN, - isPtrForTypeDef BOOLEAN, - isPtrForOpt BOOLEAN, - isPtrInChoice BOOLEAN, - isPtrInSetAndSeq BOOLEAN, - isPtrInList BOOLEAN, - optTestRoutineName MyString, - defaultFieldName MyString -- base for generating field names -} - -IDLTRI ::= SEQUENCE -{ - isEnc BOOLEAN, - typeName MyString, - fieldName MyString, - isPtr BOOLEAN, - namedElmts CNamedElmts, - choiceIdSymbol MyString, - choiceIdValue INTEGER, - optTestRoutineName MyString -} - --- use snacc compiler directives to overide the builtin types. --- --- All strings used in module data struct are null terminated so --- can just use a char * --- Note the snacc comments before the PrintableString --- bind with the MyString TypeDef and the ones after PrintableString --- bind with the PrintableString Type ref. - - -MyString ::= --snacc isPtrForTypeDef:"FALSE" - --snacc isPtrForTypeRef:"FALSE" - --snacc isPtrInChoice:"FALSE" - --snacc isPtrForOpt:"FALSE" - --snacc optTestRoutineName:"MYSTRING_NON_NULL" - --snacc genPrintRoutine:"FALSE" - --snacc genEncodeRoutine:"FALSE" - --snacc genDecodeRoutine:"FALSE" - --snacc genFreeRoutine:"FALSE" - --snacc printRoutineName:"printMyString" - --snacc encodeRoutineName:"EncMyString" - --snacc decodeRoutineName:"DecMyString" - --snacc freeRoutineName:"FreeMyString" - PrintableString --snacc cTypeName:"char *" - -END -\end{verbatim} -\end{small} - - -\chapter{The Type Table (TBL) Data Structure ASN.1 Definition} - -The following is the type table data structure that Snacc uses for -type table values. Using ASN.1 gives a representation suitable for -saving tables to files or sending them over a network to reconfigure a -device (e.g. SNMP mib). - -This file is actually compiled by Snacc to compile itself. -For bootstrapping purposes, an initial version is included in the distribution. - -\begin{small} -\begin{verbatim} --- .../asn1specs/tbl.asn1 --- --- TBL types describe ASN.1 data structures. --- These can be used in generic, interpretive encoders/decoders. --- Interpretive decoders are typically slower, but don't eat memory --- with type-specific encoding and decoding code. --- The tbl types can also be sent over the network --- and allow dynamic re-configuration of encoders/decoders. --- --- This definition is fairly small so it should be reasonable easy --- to understand. To learn more about semantics of this data --- struct, look in snacc/tbl-tools/print-tbl/pasn1.c. --- --- Copyright Mike Sample and UBC, 1992, 1993 --- - -TBL DEFINITIONS ::= -BEGIN - - --- imports nothing --- exports nothing - -TBL ::= --snacc isPdu:"TRUE" -- SEQUENCE -{ - totalNumModules INTEGER, -- these totals can help allocation - totalNumTypeDefs INTEGER, -- when decoding (ie use arrays) - totalNumTypes INTEGER, - totalNumTags INTEGER, - totalNumStrings INTEGER, - totalLenStrings INTEGER, - modules SEQUENCE OF TBLModule -} - -TBLModule ::= SEQUENCE -{ - name [0] IMPLICIT PrintableString, - id [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL, - isUseful [2] IMPLICIT BOOLEAN, -- true if useful types module - typeDefs [3] IMPLICIT SEQUENCE OF TBLTypeDef -} - -TBLTypeDef ::= SEQUENCE -{ - typeDefId TBLTypeDefId, - typeName PrintableString OPTIONAL, -- I have forgotten why this is opt! - type TBLType -} - -TBLType ::= SEQUENCE -{ - typeId [0] IMPLICIT TBLTypeId, - optional [1] IMPLICIT BOOLEAN, - tagList [2] IMPLICIT SEQUENCE OF TBLTag OPTIONAL, - content [3] TBLTypeContent, - fieldName [4] IMPLICIT PrintableString OPTIONAL -} - -TBLTypeContent ::= CHOICE -{ - primType [0] IMPLICIT NULL, - elmts [1] IMPLICIT SEQUENCE OF TBLType, - typeRef [2] IMPLICIT TBLTypeRef -} - -TBLTypeRef ::= SEQUENCE -{ - typeDef TBLTypeDefId, - implicit BOOLEAN -} - -TBLTypeId ::= ENUMERATED -{ - tbl-boolean (0), - tbl-integer (1), - tbl-bitstring (2), - tbl-octetstring (3), - tbl-null (4), - tbl-oid (5), - tbl-real (6), - tbl-enumerated (7), - tbl-sequence (8), - tbl-set (9), - tbl-sequenceof (10), - tbl-setof (11), - tbl-choice (12), - tbl-typeref (13) -} - -TBLTypeDefId ::= INTEGER - -TBLTag ::= SEQUENCE -{ - tclass TBLTagClass, - code INTEGER (0..MAX) -} - -TBLTagClass ::= ENUMERATED { universal (0), application (1), - context (2), private (3)} - -END - -\end{verbatim} -\end{small} - -\chapter{\label{edex-files}ASN.1 Files for the Editor Example} - -The files can be found in {\ufn \dots/tcl-example/}. - -\begin{ASNcode} -\label{edex0.asn1}% ---\,-- file: edex0.asn1\\ ---\,--\\ ---\,-- SnaccEd example, simple types module\\ -\\ -EdEx-Simple DEFINITIONS ::=\\ -BEGIN\\ -\\ -RainbowColor ::= INTEGER\\ -\{\\ - \>red(0), orange(1), yellow(2), green(3), blue(4), indigo(5), violet(6)\\ -\}\\ -\\ -DayOfTheWeek ::= ENUMERATED\\ -\{\\ - \>sunday(0), monday(1), tuesday(2), wednesday(3), thursday(4), friday(5), saturday(6)\\ -\}\\ -\\ -Hand ::= BIT STRING\\ -\{\\ - \>thumb(0), forefinger(1), middle-finger(2), ring-finger(3), little-finger(4)\\ -\}\\ -\\ -victory Hand ::= \{ forefinger, middle-finger \}\\ -\\ -END -\end{ASNcode} - -\begin{ASNcode} -\label{edex1.asn1}% ---\,-- file: edex1.asn1\\ ---\,--\\ ---\,-- SnaccEd example, structured types module\\ -\\ -EdEx-Structured DEFINITIONS ::=\\ -BEGIN\\ -\\ -IMPORTS RainbowColor, DayOfTheWeek, Hand FROM EdEx-Simple;\\ -\\ -RGBColor ::= SEQUENCE\\ -\{\+\\ - red INTEGER,\\ - green INTEGER,\\ - blue INTEGER\-\\ -\}\\ -\\ -Coordinate ::= CHOICE\\ -\{\+\\ - cartesian [0] SEQUENCE \{ x REAL, y REAL \},\\ - polar [1] SEQUENCE \{ angle REAL, distance REAL \}\-\\ -\}\\ -\\ -File ::= SET\\ -\{\+\\ - name [0] PrintableString,\\ - contents [1] OCTET STRING,\\ - checksum [2] INTEGER OPTIONAL,\\ - read-only [3] BOOLEAN DEFAULT FALSE\-\\ -\}\\ -\\ -Directory ::= SET\\ -\{\+\\ - name PrintableString,\\ - files SET OF File\-\\ -\}\\ -\\ -Simple ::= SET\\ -\{\+\\ - null [0] NULL,\\ - bool [1] BOOLEAN,\\ - day [2] DayOfTheWeek,\\ - int [3] INTEGER,\\ - color [4] RainbowColor,\\ - real [5] REAL,\\ - bits [6] Hand,\\ - str [7] OCTET STRING,\\ - optstr [8] OCTET STRING OPTIONAL\-\\ -\}\\ -\\ -Structured ::= SET\\ -\{\+\\ - coord [0] Coordinate,\\ - color [1] CHOICE \{ rainbow RainbowColor, rgb RGBColor \}\-\\ -\}\\ -\\ -Various ::= SET\\ -\{\+\\ - simple [0] Simple,\\ - struct [1] Structured,\\ - recursion [2] Various OPTIONAL\-\\ -\}\\ -\\ -END -\end{ASNcode} diff --git a/SecuritySNACCRuntime/doc/c++-gen.tex b/SecuritySNACCRuntime/doc/c++-gen.tex deleted file mode 100644 index d96209ab..00000000 --- a/SecuritySNACCRuntime/doc/c++-gen.tex +++ /dev/null @@ -1,720 +0,0 @@ -% file: .../doc/c++-gen.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/c++-gen.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: c++-gen.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:51 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:35 rj -% first check-in -% - -\chapter{\label{c++-code-gen-chapter}C++ Code Generation} - -\section{\label{intro-C++-section}Introduction} - -The C++ backend of snacc was designed after the C backend had been -written. The basic model that the generated C++ uses is similar to -that of the generated C, but benefits from the object oriented features of -C++. This was my first real foray into C++ which may be evident from -some of the design. - -As with C, two files are generated for each ASN.1 module, a {\ufn .C} -and a {\ufn .h} file. - -Some cleaner designs were rejected either due to their poor -performance or the inability of the available C++ compiler to handle -those features. - -Tags and lengths would fit nicely into their own classes but -performance was considerably worse than the technique used in the C -environment. The C design was retained in the C++ model for its -superior performance. - -For error management C++'s {\C try} and {\C throw} are obvious -replacements for the {\C setjmp} and {\C longjmp} used by the C -decoders. Unfortunately this is a newer C++ feature and is not yet -supported by gcc. - -C++ templates are very attractive for type safe lists (for SET OF and -SEQUENCE OF) without duplicating code. Template support was shaky in -gcc at the time the generated code was being tested so they were -rejected. Instead, each list generates its own new class with all of -the standard list routines. - -As with the C code generation chapter, we will use the EX1 module to -help illustrate some of the code generation. The following is the -same EX1 module used in the C section. - -\begin{ASNcode} -EX1 DEFINITIONS ::=\\ -BEGIN\\ -\\ -anOidVal OBJECT IDENTIFIER ::= \{ joint-iso-ccitt 40 foobar(29) \}\\ -theSameOidVal OBJECT IDENTIFIER ::= \{ 2 40 29 \}\\ -anIntVal INTEGER ::= 1\\ -aBoolVal BOOLEAN ::= TRUE\\ -\\ -T1 ::= SEQUENCE\\ -\{\+\\ - INTEGER OPTIONAL,\\ - OCTET STRING OPTIONAL,\\ - ENUMERATED \{ a(0), b(1), c(2) \},\\ - SEQUENCE OF INTEGER,\\ - SEQUENCE \{ id OBJECT IDENTIFIER, value OCTET STRING \},\\ - CHOICE \{ INTEGER, OBJECT IDENTIFIER \}\-\\ -\}\\ -\\ -END -\end{ASNcode} - -The C++ backend to snacc is in the {\ufn \dots/compiler/back-ends/c++-gen/} directory if you want to alter it. - -\section{\label{naming-C++-section}ASN.1 to C++ Naming Conventions} - -The C++ name for a type or value is the same as its ASN.1 name with -any hyphens converted to underscores. - -When an ASN.1 type or value name (after converting any hyphens to -underscores) conflicts with a C++ keyword or the name of a type in -another ASN.1 module (name clashes within the same ASN.1 scope are -considered errors and are detected earlier), the resulting C++ class -name will be the conflicting name with digits appended to it. - -Empty field names in SETs, SEQUENCEs, and CHOICEs will be filled. The -field name is derived from the type name for that field. The library -types such as INTEGER etc. have default field names defined by the -compiler (see {\ufn \dots/compiler/back-ends/c-gen/rules.c} and -{\ufn \dots/compiler/back-ends/c++-gen/rules.c}). -The first letter of the field name is in lower case. -Empty field names should be fixed properly by adding them to the ASN.1 source. - -New type definitions will be generated for SETs, SEQUENCEs, CHOICEs, -ENUMERATED, INTEGERs with named numbers and BIT STRINGs with named bits -whose definitions are embedded in other SET, SEQUENCE, SET OF, -SEQUENCE OF, or CHOICE definitions. The name of the new type -is derived from the name of the type in which it was embedded and will -be made unique by appending digits if necessary. - -\section{\label{type-gen-C++-section}ASN.1 to C++ Class Translation} - -This section describes how C++ classes are used to represent each -ASN.1 type. First, the general characteristics of each ASN.1 type's -C++ class will be discussed followed by how the aggregate types (SETs, -SEQUENCEs, CHOICEs, SET OFs, and SEQUENCE OFs) are represented. The -representations of non-aggregate types (INTEGER, BOOLEAN, OCTET -STRING, BIT STRING, OBJECT IDENTIFIER) and ANY and ANY DEFINED BY -types are presented in the next chapter since they form part of the -C++ ASN.1 runtime library. - -Every ASN.1 type is represented by a C++ class with the following -characteristics: -\newcounter{saveenumi} -\begin{enumerate} - \item it inherits from the {\C AsnType} base class - \item it has a parameterless constructor - \item it has a copy constructor - \item it has a destructor - \item it has a clone method, {\C Clone} - \item it has an assignment operator - \item it has a content encode and decode method, {\C BEncContent} and {\C BDecContent} - \item it has a PDU encode and decode method, {\C BEnc} and {\C BDec} - \item it has a top level interfaces to the PDU encode and decode methods (handles the {\C setjmp} etc.) for the user, {\C BEncPdu} and {\C BDecPdu} - \item it has a print method, {\C Print}, a virtual function that gets called from a global <\/<-operator - \setcounter{saveenumi}{\value{enumi}} -\end{enumerate} -If the metacode has been enabled: -\begin{enumerate} - \setcounter{enumi}{\value{saveenumi}} - \item it has a virtual function {\C \_getdesc} that returns the classes meta description% (only if metacode is enabled) - \item if it is a structured type, it has a virtual function {\C \_getref} that returns a pointer to one of its components/members, specified through its name% (only if metacode is enabled) - \setcounter{saveenumi}{\value{enumi}} -\end{enumerate} -If the Tcl code has been enabled: -\begin{enumerate} - \setcounter{enumi}{\value{saveenumi}} - \item it has a virtual function {\C TclGetDesc} to access the metacode's {\C \_getdesc} routine from Tcl% (only if Tcl code is enabled) - \item it has a virtual function {\C TclGetVal} to retrieve an instance's value% (only if Tcl code is enabled) - \item it has a virtual function {\C TclSetVal} to change an instance's value% (only if Tcl code is enabled) - \item for SET, SEQUENCE, SET OF and SEQUENCE of: it has a virtual function {\C TclUnsetVal} to clear OPTIONAL members or to delete list elements, respectively% (only if Tcl code is enabled) -\end{enumerate} - -The following C++ fragment shows the class features listed above in greater -detail. -\begin{Ccode} -class Foo: public AsnType\\ -\{\+\\ - \dots // data members\\ -\\ -\\>Foo();\\ - \>\>Foo (const Foo \&);\\ - \>\>\~{}Foo();\\ - AsnType \>\>*Clone() const;\\ - Foo \>\>\&operator = (const Foo \&);\\ -\\ - // content encode and decode routines\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tag, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - // PDU (tags/lengths/content) encode and decode routines\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - // methods most likely to be used by your code.\\ - // Returns non-zero for success\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const;\\ -\\ -\<\#if META\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ - AsnType \>\>*\_getref (const char *membername, bool create = false);\\ -\<\#if TCL\\ - int \>\>TclGetDesc (Tcl\_DString *) const;\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *valstr);\\ - int \>\>TclUnsetVal (Tcl\_Interp *, const char *membername);\\ -\<\#endif\\ -\<\#endif\\ -\<\}; -\end{Ccode} - -{\C BEnc} and {\C BDec} are PDU encode and decode methods. -{\C BEnc} encodes the tag and length pairs for the object's type as -well as the content (the object's value) to the given buffer, -{\C b}, and returns the number of bytes written to the buffer for -the encoding. - -{\C BDec} decodes the expected tag and length pairs as well as the -content of the object it is invoked upon from the given buffer, -{\C b}, and increments {\C bytesDecoded} by the byte length of -the tag(s), length(s) and value decoded. The {\C env} parameter -will be used with {\C longjmp} if any decoding error occurs. -Decoding errors can be reported via {\C longjmp} from any of the -routines that {\C BDec} calls, such as {\C BDecContent}; -{\C BDec} will call {\C longjmp} directly if the value does not -have the correct tag(s). - -{\C BEncContent} and {\C BDecContent} only deal with the content -of the type their object represents. {\C BEncContent} encodes the -object's value to the given buffer, {\C b}. - -{\C BDecContent} decodes the object's value from the given buffer, -{\C b}. The last tag and length pair on the content must be passed in -via the {\C tag} and {\C elmtLen} parameters. The {\C tag}, -although always present, will only be used when decoding OCTET STRING and -BIT STRING related types, to determine whether the encoding is -constructed. The {\C elmtLen} is the length of the content and may -be the indefinite length form. {\C bytesDecoded} is incremented by -the actual number of bytes in the content; this is normally the same -as {\C elmtLen} unless the indefinite length form was decoded. The -{\C env} parameter will be used with {\C longjmp} if any decoding -error occurs. The possible decoding errors depend on the type that is -being decoded. - -{\C BEncPdu} and {\C BDecPdu} are top-level interfaces to the PDU -encode and decode routines. They present the simplest interface; -they return TRUE if the operation succeeded and FALSE if an error -occurred. Note that the {\C BDecPdu} routine sets up the -{\C env} parameter using {\C setjmp} for any {\C longjmp} calls -that may occur. If you call {\C BDec} or {\C BDecContent} -directly from your code, you must use {\C setjmp} to setup the -{\C env} parameter. {\C BEncPdu} checks for any buffer writing -errors and {\C BDecPdu} checks for any buffer reading errors. - -The {\C Print} method prints the object's value in ASN.1 value -notation. When printing SETs and SEQUENCEs, a global variable -is used for the current indent. - -The {\C AsnType} base class, parameterless constructor and -{\C Clone} method are required by the ANY and ANY DEFINED BY type -handling mechanism explained in Sections \ref{asntype-C++-section} and -\ref{any-C++-section}. In brief, the {\C AsnType} provides a base type -that has virtual {\C BEnc}, {\C BDec} and {\C Clone} routines. -The {\C Clone} routine is used to generate a new instance (not a -copy) of the object that it is invoked on. This allows the ANY -DEFINED BY type decoder to create a new object of the correct type -from one stored in a hash table, when decoding (the {\C Clone} -routine calls the parameterless constructor). The virtual {\C BEnc} -and {\C BDec} are called from {\C AsnAny} {\C BEnc} and -{\C BDec} methods. - -The meta routines and the Tcl interface will be described in chapters \ref{meta-chapter} and \ref{tcl-if-chapter}, respectively. - -\subsection{\label{C++-set-seq-section}SET and SEQUENCE} - -SET and SEQUENCE types generate classes that have their components as -public data members. This makes accessing the components similar to -referencing the fields of a C struct. For example the {\C T1} type in -module EX1 will produce the following C++ class: - -\begin{Ccode} -class T1: public AsnType\\ -\{\\ -public:\+\\ - AsnInt \>\>*integer;\\ - AsnOcts \>\>*octs;\\ - T1Enum \>\>t1Enum;\\ - T1SeqOf \>\>t1SeqOf;\\ - T1Seq \>\>*t1Seq;\\ - T1Choice \>\>*t1Choice;\\ -\\ - \>\>T1();\\ -% {\\ -% /* init optional/default elements to NULL */\\ -% integer = NULL;\\ -% octs = NULL;\\ -% }\\ - \>\>T1 (const T1 \&);\\ - \>\>\~{}T1();\\ -% AsnType *Clone() { return new T1; }\\ - AsnType \>\>*Clone() const;\\ -\\ - T1 \>\>\&operator = (const T1 \&);\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tag, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const;\\ -\\ -\<\#if META\\ - static const AsnSequenceTypeDesc \\ - \>\>\_desc;\\ - static const AsnSequenceMemberDesc \\ - \>\>mdescs[];\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ - AsnType \>\>*\_getref (const char *membername, bool create = false);\\ -\\ -\<\#if TCL\\ - int \>\>TclGetDesc (Tcl\_DString *) const;\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *valstr);\\ - int \>\>TclUnsetVal (Tcl\_Interp *, const char *membname);\\ -\<\#endif // TCL\\ -\<\#endif // META\\ -\<\}; -\end{Ccode} - -All OPTIONAL components in a SET or SEQUENCE are referenced by pointer. -The constructor will automatically set OPTIONAL fields to {\C NULL}\@. The -other methods are as described at the beginning of this section. - -SETs and SEQUENCEs must contain all non-OPTIONAL components and -SEQUENCEs must be ordered, otherwise an error is reported. Tagging -errors are also reported. All detected errors abort the decoding -process via {\C longjmp}. - -\subsection{\label{C++-choice-section}CHOICE} - -Each CHOICE type generates a class that has an anonymous union to hold the -components of the CHOICE and a {\C choiceId} field to indicate which -component is present. - -Anonymous (un-named) unions allow you to reference the choice components -with just the field name of the component; this makes referencing the -contents of a CHOICE the same a referencing the contents of a SET or -SEQUENCE\@. - -The {\C choiceId} field contains a value in the {\C ChoiceIdEnum} -that indicates the CHOICE field that is present. The names in the -enumeration are derived from the field names of the CHOICE components. - -When building a local value to be encoded, you must be sure to set the -{\C choiceId} such that it corresponds to the value in the union. The -decoder will set the {\C choiceId} when decoding incoming values. - -Tagging errors are reported and abort the decoding process via -{\C longjmp}. - -The following C++ class is produced for the CHOICE in the EX1 module. - -\begin{Ccode} -class T1Choice: public AsnType\\ -\{\\ -public:\+\\ - enum ChoiceIdEnum\\ - \{\+\\ - integerCid = 0,\\ - oidCid = 1\-\\ - \};\\ -\\ - enum ChoiceIdEnum \>\>choiceId;\\ - union\\ - \{\+\\ - AsnInt \>*integer;\\ - AsnOid \>*oid;\-\\ - \};\\ -\\ - \>\>T1Choice();\\ - \>\>T1Choice (const T1Choice \&);\\ - \>\>\~{}T1Choice();\\ - AsnType \>\>*Clone() const;\\ -\\ - T1Choice \>\>\&operator = (const T1Choice \&);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tag, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const;\\ -\\ -\<\#if META\\ - static const AsnChoiceTypeDesc \>\>\_desc;\\ - static const AsnChoiceMemberDesc \\ - \>\>\_mdescs[];\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ - AsnType \>\>*\_getref (const char *membername, bool create = false);\\ -\\ -\<\#if TCL\\ - int \>\>TclGetDesc (Tcl\_DString *) const;\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *valstr);\\ -\<\#endif // TCL\\ -\<\#endif // META\\ -\<\}; -\end{Ccode} - - - -\subsection{\label{C++-set-of-section}SET OF and SEQUENCE OF} - -Each SET OF and SEQUENCE OF type produces its own list class, unlike -the C backend which uses a single generic list type for all lists. -This makes the C++ list routines type safe which allows the C++ -compiler to detect more programmer errors. - -C++ templates should be used to reduce the code duplication when they -become widespread and reliably implemented. The duplicated list -handling methods may bloat the size of the generated code. - -Any tagging errors are reported and abort the decoding process via -{\C longjmp}. - -From the EX1 ASN.1 module the following list is produced: -\begin{Ccode} -class T1SeqOf: public AsnType\\ -\{\\ -protected:\+\\ - unsigned long int\>\>count;\\ - struct AsnListElmt\\ - \{\+\\ - struct AsnListElmt \>*next;\\ - struct AsnListElmt \>*prev;\\ - AsnInt \>*elmt;\-\\ - \} \>\>*first, *curr, *last;\\ -\\ -\\>T1SeqOf() \{ count = 0; first = curr = last = NULL; \}\\ - \>\>\~{}T1SeqOf();\\ - AsnType \>\>*Clone() const;\\ -\\ - void \>\>SetCurrElmt (unsigned long int index);\\ - unsigned long int \>\>GetCurrElmtIndex();\\ - void \>\>SetCurrToFirst();\\ - void \>\>SetCurrToLast();\\ -\\ - // reading member fcns\\ - int \>\>Count() const;\\ - AsnInt \>\>*First() const;\\ - AsnInt \>\>*Last() const;\\ - AsnInt \>\>*Curr() const;\\ - AsnInt \>\>*Next() const;\\ - AsnInt \>\>*Prev() const;\\ -\\ - // routines that move the curr elmt\\ - AsnInt \>\>*GoNext();\\ - AsnInt \>\>*GoPrev();\\ -\\ - // write \& alloc fcns--returns new elmt\\ - AsnInt \>\>*Append(); // add elmt to end of list\\ - AsnInt \>\>*Prepend(); // add elmt to beginning of list\\ - AsnInt \>\>*InsertBefore(); // insert elmt before current elmt\\ - AsnInt \>\>*InsertAfter(); // insert elmt after current elmt\\ -\\ - // write \& alloc \& copy--returns list after copying elmt\\ - T1SeqOf \>\>\&AppendCopy (AsnInt \&elmt); // add elmt to end of list\\ - T1SeqOf \>\>\&PrependCopy (AsnInt \&elmt); // add elmt to beginning of list\\ - T1SeqOf \>\>\&InsertBeforeAndCopy (AsnInt \&elmt); // insert elmt before current elmt\\ - T1SeqOf \>\>\&InsertAfterAndCopy (AsnInt \&elmt); // insert elmt after current elmt\\ -\\ - // removing the current elmt from the list\\ - void \>\>RemoveCurrFromList();\\ -\\ - // encode and decode routines\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tag, AsnLen elmtLen,\\ - \` AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os);\\ -\\ -\<\#if META\\ - static const AsnListTypeDesc \>\>\_desc;\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ - AsnType \>\>*\_getref (const char *index, bool create = false);\\ -\\ -\<\#if TCL\\ - int \>\>TclGetDesc (Tcl\_DString *) const;\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *valstr);\\ - int \>\>TclUnsetVal (Tcl\_Interp *, const char *valstr);\\ -\<\#endif // TCL\\ -\<\#endif // META\\ -\<\}; -\end{Ccode} - -Each list is doubly linked to allow simple reverse traversal for -backwards encoding. The {\C prev} pointer will be {\C NULL} for the -first element of the list and the {\C next} pointer will be {\C NULL} for -the last element of the list. - -Each list maintains a pointer to the current element of the list. -Several routines are provided to manipulate the current item. Since -there is only one current pointer, you may have to save and restore -the current pointer with the {\C GetCurrElmtIndex} and -{\C SetCurrElmt} methods if you call routines that deal with the -list while iterating through it. - -In addition to the standard encode, decode and print methods, some -list utility routines are included in each list class. They are -fairly simple and are described briefly here. - -\begin{Ccode} -void \>\>\>SetCurrElmt (unsigned long int index); -\end{Ccode} -This sets the current pointer to the element with the given index. -Indexes start at zero, that is, the first element in the list has an -index of zero. If the given index is greater than or equal to the -number of elements in the list, the current pointer is set to the last -element of the list. - -\begin{Ccode} -unsigned long int \>\>\>GetCurrElmtIndex(); -\end{Ccode} -This returns the index of the current element. If the current pointer -is {\C NULL} (or does not reference an element of the list, which is an -error condition), the index returned will be greater than or equal to -the number of elements in the list (indexes start at zero so this is -an invalid index). - - -\begin{Ccode} -void \>\>\>SetCurrToFirst(); -\end{Ccode} -This sets the current pointer to the first element of the list. If the -list is empty, it is set to {\C NULL}\@. -\begin{Ccode} -void \>\>\>SetCurrToLast(); -\end{Ccode} -This sets the current pointer to the last element of the list. If the -list is empty, it is set to {\C NULL}\@. - - -\begin{Ccode} -int \>\>\>Count() const; -\end{Ccode} -This returns the number of elements in the list. - -\begin{Ccode} -AsnInt \>\>\>*First() const;\\ -AsnInt \>\>\>*Last() const;\\ -AsnInt \>\>\>*Curr() const;\\ -AsnInt \>\>\>*Next() const;\\ -AsnInt \>\>\>*Prev() const; -\end{Ccode} -The above routines return a pointer to the list element that the -routine name indicates. They return {\C NULL} if the requested element is -not present. For example {\C First} will return a pointer to the -first element in the list or {\C NULL} if the list is empty. These -routines do not affect the state of the list; the current pointer and -the count remain the same. - -\begin{Ccode} -AsnInt \>\>\>*GoNext();\\ -AsnInt \>\>\>*GoPrev(); -\end{Ccode} -These routines change the current pointer to the next/previous element -and return a pointer to that element. If the current element is {\C NULL} or -points to the last element, {\C GetNext} returns {\C NULL}\@. Similarly, if -the current element is {\C NULL} or points to the first element, {\C GetPrev} -returns {\C NULL}\@. - - -\begin{Ccode} -AsnInt \>\>\>*Append(); -\end{Ccode} -This allocates a new list element, appends it to the end of the list -and returns a pointer to the new list element. Notice that you must -set the value of the returned list element. - -\begin{Ccode} -AsnInt \>\>\>*Prepend(); -\end{Ccode} -This allocates a new list element, prepends it to the beginning of the -list and returns a pointer to the new list element. You must set the -value of the returned list element. - -\begin{Ccode} -AsnInt \>\>\>*InsertBefore(); -\end{Ccode} -This allocates a new list element, inserts it before the current list -element and returns a pointer to the new list element. You must set -the value of the returned list element. If the current pointer is -{\C NULL}, the new element is placed at the beginning of the list. - -\begin{Ccode} -AsnInt \>\>\>*InsertAfter(); -\end{Ccode} -This allocates a new list element, inserts it after the current list -element and returns a pointer to the new list element. You must set -the value of the returned list element. If the current pointer is -{\C NULL}, the new element is placed at the end of the list. - -\begin{Ccode} -T1SeqOf \>\>\>\&AppendCopy (AsnInt \&elmt);\\ -T1SeqOf \>\>\>\&PrependCopy (AsnInt \&elmt);\\ -T1SeqOf \>\>\>\&InsertBeforeAndCopy (AsnInt \&elmt);\\ -T1SeqOf \>\>\>\&InsertAfterAndCopy (AsnInt \&elmt); -\end{Ccode} -These are similar to the {\C Append}, {\C Prepend}, -{\C InsertBefore} and {\C InsertAfter} routines except that a -copy of the given element's value is placed in the list and the list -itself is returned. - -\subsection{\label{C++-enumerated-section}ENUMERATED, Named Numbers and Named Bits} - -The C++ type generator encapsulates each ENUMERATED type, INTEGER -with named numbers and BIT STRING with named bits in a new class that -inherits from the proper base class and defines the named elements. -This provides a separate scope for these identifiers so their symbol -will be exactly the same as their ASN.1 counterpart. Currently these -identifiers are not checked for conflicts with C++ keywords, so you -may have to modify some of them in the ASN.1 modules. - -Inheritance is used for attaching ENUMERATED, named number and named -bit information. ENUMERATED types inherit from the {\C AsnEnum} class, -INTEGERs with named number types inherit from the {\C AsnInt} class and BIT -STRINGs with named bits inherit from the {\C AsnBits} class. - -If the tagging on the type is different from the type it inherits -from, the PDU encode and decode methods are re-defined with the -correct tags to override the PDU encode and decode methods of the base -class. - -As with the other types, any tagging errors are reported and abort the -decoding process via {\C longjmp}. No range checking is done on the -decoded values although it would be easy to provide a new -{\C BDecContent} method in the new class that calls the base class's -and then checks the range of the result. - -\begin{Ccode} -/* ENUMERATED { a(0), b(1), c(2) } */\\ -class T1Enum: public AsnEnum\\ -\{\\ -public:\\ -\#if TCL\\ - \> \>\>T1Enum(): AsnEnum (\_nmdescs[0].value) \{\}\\ -\#else\\ - \> \>\>T1Enum(): AsnEnum () \{\}\\ -\#endif\+\\ - \>\>T1Enum (int i): AsnEnum (i) \{\}\\ - enum\\ - \{\+\\ - a = 0,\\ - b = 1,\\ - c = 2\-\\ - \};\\ -\\ -\<\#if META\\ - static const AsnNameDesc \>\>\_nmdescs[];\\ - static const AsnEnumTypeDesc \>\>\_desc;\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ -\<\#endif // META\\ -\<\}; -\end{Ccode} - -\section{\label{val-gen-C++-section}ASN.1 to C++ Value Translation} - -C++ {\C const} values are used to hold ASN.1 defined values. C++ -values will be produced for INTEGER, BOOLEAN and OBJECT IDENTIFIER -ASN.1 values. An {\C extern} declaration for each {\C const} value is -written at the end of the header file of the value's module. The -{\C const} values are defined at the beginning of the {\ufn .C} file -of the value's module. The {\C extern} declarations are at the end -of the header file so that any required class definitions are -available. - -The following is from the end of the header file generated for the EX1 -module: -\begin{Ccode} -extern const AsnOid \>\>\>anOidVal;\\ -extern const AsnOid \>\>\>theSameOidVal;\\ -extern const AsnInt \>\>\>anIntVal;\\ -extern const AsnBool \>\>\>aBoolVal; -% \\ extern const AsnInt \>\>\>foobar; -\end{Ccode} - -The following is from the beginning of the {\ufn .C} file generated -for the EX1 module: -\begin{Ccode} -const AsnOid \>\>\>anOidVal (2, 40, 29);\\ -const AsnOid \>\>\>theSameOidVal (2, 40, 29);\\ -const AsnInt \>\>\>anIntVal (1);\\ -const AsnBool \>\>\>aBoolVal (true); -% \\ const AsnInt \>\>\>foobar (29); -\end{Ccode} - -The C++ constructor mechanism is used to generate these values. This -mechanism is superior to C static initialization because it allows C++ -code to be run to initialize the values. - -\section{\label{compiler-dir-C++-section}Compiler Directives} -Compiler directives are ignored by the C++ backend of snacc. If you want -to implement them, look at the {\C FillCxxTypeDefInfo} routine in -file {\ufn \dots/compiler/back-ends/c++-gen/types.c}. Then look at the -way it is done for the C backend (file -{\ufn \dots/compiler/back-ends/c-gen/type-info.c}) - -\section{\label{compiling-gen-C++-section}Compiling the Generated C++ Code} - -When compiling the generated C++ code you will need: -\begin{enumerate} -\item - The include directory where the files from {\ufn \dots/c++-lib/inc/} have been installed in your include path so that the C++ sources can include these library header files. - The header files should be included with statements like {\C \#include } and your C++ compiler should be supplied with {\ufn -I/usr/local/include} in case snacc got installed under {\ufn /usr/local/}. -\item - to link with the C++ ASN.1 runtime library, {\ufn \dots/c++-lib/libasn1c++.a}. - In case snacc got installed under {\ufn /usr/local/}, your linker may need to be supplied with {\ufn -L/usr/local/lib} and {\ufn -lasn1c++} as arguments. -\item - to link with the math library ({\ufn -lm}), since the ASN.1 REAL type's encode and decode routine use some math routines. -\end{enumerate} - -See the example in {\ufn \dots/c++-examples/simple/} for a complete -example. The makefile and main routines are probably the most -important. There are several other examples in the -{\ufn \dots/c++-examples/} directory. diff --git a/SecuritySNACCRuntime/doc/c++-lib.tex b/SecuritySNACCRuntime/doc/c++-lib.tex deleted file mode 100644 index e130227a..00000000 --- a/SecuritySNACCRuntime/doc/c++-lib.tex +++ /dev/null @@ -1,973 +0,0 @@ -% file: .../doc/c++-lib.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/c++-lib.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: c++-lib.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:51 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:37 rj -% first check-in -% - -\chapter{\label{lib-C++-chapter}C++ ASN.1 Library} -\section{\label{libover-C++-section}Overview} - -The following sections describe the C++ representation of the -non-aggregate ASN.1 types, ANY and ANY DEFINED BY types and -the buffer and memory management. These classes and routines make -up the C++ ASN.1 runtime library. Every aggregate ASN.1 type will be -composed of these library types. The source files for this library -are in {\ufn \dots/c++-lib/inc/} and {\ufn \dots/c++-lib/src/}. - -As mentioned in the last chapter, each ASN.1 type is represented by a -C++ class which inherits from the {\C AsnType} base class. In -addition to the standard encode, decode, print and clone methods -described in the last chapter, each ASN.1 type class in the library -may also have special constructors and other routines that simplify -their use. - -Unlike the classes generated for some of the aggregate types such as -SETs and SEQUENCEs, the library types' data members are typically -protected and accessed via methods. - -All of the library classes' {\C BDec} routines will report tagging errors -via {\C longjmp()} as described in section~\ref{type-gen-C++-section}. - -The top level PDU encode and decode methods are the same for all -library types so they are defined as macros in -{\ufn \dots/c++-lib/inc/asn-config.h}. For clarity's sake, the macro -that is used to define these methods in the library type class -definitions will be replaced with the actual prototypes. - -Run the {\ufn test-lib} program in {\ufn \dots/c++-examples/test-lib/} -to make sure the library routines are working properly for your -architecture. The testing is not exhaustive but should point out -obvious problems. - - -\section{\label{tag-C++-section}Tags} - -The C++ tags are identical to those used in snacc's C ASN.1 -environment. While it would have been nice to define a tag class, the -performance cost would likely have been noticeable. Also, the snacc -users usually do not have to muck around with tags directly, so the -lack of a class interface will probably not be missed. The C ASN.1 -tags are described in Section~\ref{tag-C-section}. - -Initially I defined a C++ class for tags, but close examination of the -produced assembly code led me to reject it. The C++ class for tags -used the C tag representation internally and had constructor, encode -and decode methods. The constructor could not be used as -{\C switch} statement case labels like {\C MAKE\_TAG\_ID} because it -did not reduce to an integer constant; this caused problems in the -generated decoders. - -As with the C representation of tags, 4 byte long integers limit the -maximum representable tag code to $2^{21}$. Again, this should not be -a problem. - - -\section{\label{len-C++-section}Lengths} - -The C++ representation of lengths is the same at the C representation -described in Section~\ref{len-C-section}. The length type was not given -its own C++ class for reasons similar to those of tags. - - -\section{\label{asntype-C++-section}The AsnType Base Class} - -Every ASN.1 type's C++ class uses the {\C AsnType} as its base class. -The {\C AsnType} base class provides the following virtual functions: -\begin{itemize} - \item the destructor - \item {\C Clone()} - \item {\C BDec()} - \item {\C BEnc()} - \item {\C Print()} - \item {\C \_getdesc()} (metacode) - \item {\C \_getref()} (metacode) - \item {\C TclGetDesc()} (Tcl interface) - \item {\C TclGetVal()} (Tcl interface) - \item {\C TclSetVal()} (Tcl interface) - \item {\C TclUnsetVal()} (Tcl interface) -\end{itemize} - -The {\C AsnType} class is defined as follows: -\begin{Ccode} -class AsnType\\ -\{\\ -public:\+\\ - virtual \>\>\~{}AsnType();\\ -\\ -\<\#ifdef SUPPORT\_ANY\_TYPE\\ - virtual AsnType \>\>*Clone() const;\\ - virtual void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ - virtual AsnLen \>\>BEnc (BUF\_TYPE b);\\ -\<\#else\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env) \{\}\\ - AsnLen \>\>BEnc (BUF\_TYPE b) \{ return 0; \}\\ -\<\#endif\\ - virtual void \>\>Print (ostream \&os) const;\\ -\\ -\<\#if META\\ - static const AsnTypeDesc \>\>\_desc;\\ -\\ - virtual const AsnTypeDesc \>\>*\_getdesc() const;\\ - virtual AsnType \>\>*\_getref (const char *membername, bool create=false);\\ -\\ -\\>*\_typename() const;\\ -\-\\ -\#if TCL\\ -public:\+\\ - virtual int \>\>TclGetDesc (Tcl\_DString *) const;\\ - virtual int \>\>TclGetVal (Tcl\_Interp *) const;\\ - virtual int \>\>TclSetVal (Tcl\_Interp *, const char *val);\\ - virtual int \>\>TclUnsetVal (Tcl\_Interp *, const char *membernames);\-\\ -\#endif // TCL\\ -\#endif // META\\ -\}; -\end{Ccode} - -The {\C AsnType} class and its virtual functions were added to -support the ANY DEFINED BY type handling mechanism. This mechanism is -described in Section~\ref{any-C++-section}. - -Even if you do not use the ANY or ANY DEFINED BY types, the -{\C AsnType} base class may be useful for adding features that are -common to all of the types, such as changing the {\C new} and -{\C delete} functions to improve performance. - -Virtual functions provide the simplest method of handling ANY DEFINED -BY and ANY types. Unfortunately, calls to virtual functions are slower -than calls to normal functions due to their indirect nature. If you -do not need support for the ANY DEFINED BY or ANY types you can remove -most of the virtual functions to improve performance by undefining the -{\C SUPPORT\_ANY\_TYPE} symbol (see the -{\ufn asn-type.h} file). - -Note that a virtual destructor is included in the {\C AsnType} base -class as well. This is done to make sure the {\C delete} routine -always gets the correct size. See pages 215--217 of Stroustrup -\cite{stroustrup} for a discussion of this. - -\section{\label{bool-C++-section}BOOLEAN} - -The BOOLEAN type is represented by the {\C AsnBool} class. The -following is the class definition of {\C AsnBool} from the -{\ufn \dots/c++-lib/inc/asn-bool.h} file. - -\begin{Ccode} -class AsnBool: public AsnType\\ -\{\\ -protected:\+\\ - bool \>\>value;\\ -\\ -\\>AsnBool (const bool val): value (val) \{\};\\ - \>\>AsnBool() \{\};\\ - AsnType \>\>*Clone() const;\\ - \>\>operator bool() const \{ return value; \}\\ - AsnBool \>\>\&operator = (bool newvalue) \{ value = newvalue; return *this; \}\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tagId, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const;\\ -\\ -\<\#if META\\ - static const AsnBoolTypeDesc \>\>\_desc;\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *val);\-\\ -\#endif // TCL\\ -\#endif // META\\ -\}; -\end{Ccode} - -The upcoming C++ standard \cite{c++-draft} defines a type {\C bool} accompanied by {\C false} and {\C true} to denote the boolean values. -The Snacc configuration script checks whether the C++ compiler already supplies this new type and defines a look-alike if it does not. - -For backwards compatibility, {\C AsnBool::true} and {\C AsnBool::false} are still valid. - -The {\C operator bool()} is defined such that when an {\C AsnBool} -value is cast to a boolean, it returns the C++ style boolean -value of the {\C AsnBool}s value. There is also a constructor for {\C AsnBool} -that builds an {\C AsnBool} value from the given C++ style boolean -value. These two methods allow you to manipulate and access -{\C AsnBool} values in a straight forward way as the following code -illustrates. -\begin{Ccode} -Message::Send()\\ -\{\+\\ - AsnBool \>\>okToSend;\\ - bool \>\>connectionOpen;\\ - bool \>\>pduOk;\\ - \dots\\ - okToSend = connectionOpen \&\& pduOk; // assign AsnBool from bool\\ - if (okToSend) // cast AsnBool to bool\\ - \>\dots\\ -\<\} -\end{Ccode} - -The {\C AsnBool} class contains the standard encode and decode -methods that were described in Chapter~\ref{c++-code-gen-chapter}. - -{\C BDecContent} will report an error via {\C longjmp} if the -length of an encoded BOOLEAN value's content is not exactly 1 octet. - -Note that the {\C Clone} method returns an {\C AsnType~*} value -instead of an {\C AsnBool~*}. It might be more obvious to return an -{\C AsnBool~*} since due to single inheritance an {\C AsnBool} is also -an {\C AsnType}. However, it must return an {\C AsnType~*} for it -to override the virtual function {\C Clone} defined in the -{\C AsnType}. - -The {\C Print} method will print either ``TRUE'' or ``FALSE'' -depending on the {\C AsnBool} value. No newline or other formatting -characters are printed. The global indent information does not affect -the output from this method. - - -\section{\label{int-C++-section}INTEGER} - -The INTEGER type is represented by the {\C AsnInt} class. The -following is the class definition of {\C AsnInt} from the -{\ufn \dots/c++-lib/inc/asn-int.h} file. -\begin{Ccode} -class AsnInt: public AsnType\\ -\{\\ -protected:\+\\ - AsnIntType \>\>value;\\ -\\ -\\>AsnInt() \{\}\\ - \>\>AsnInt (AsnIntType val): value (val) \{\}\\ -\\ - AsnType \>\>*Clone() const;\\ -\\ - \>\>operator AsnIntType() \{ return value; \}\\ - AsnInt \>\>\&operator = (AsnIntType newvalue) \{ value = newvalue; return *this; \} -\\ - void \>\>Set (AsnIntType i) \{ value = i; \}\\ - void \>\>ReSet (AsnIntType i) \{ value = i; \}\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tagId, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const \{ os <\/< value; \}\\ -\\ -\<\#if META\\ - static const AsnIntTypeDesc \>\>\_desc;\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *val);\-\\ -\#endif /* TCL */\\ -\#endif /* META */\\ -\}; -\end{Ccode} - -The internal representation of an ASN.1 INTEGER value is a {\C AsnIntType}. -This is a {\C typedef}, the real type may be {\C int}, {\C long} or {\C short}, whatever is found to be 32 bits in size. -The types' sizes depend on the machine and compiler and are determined at configuration time. -The {\C BDecContent} routine will signal an error if the integer -value being decoded will not fit into the {\C AsnIntType} -representation. - -Unlike the C ASN.1 library, the non-negative -%{\C unsigned long int} -version of -INTEGER is not provided. If you need it, it should be relatively -trivial to combine the C unsigned version with the existing C++ class. -The unsigned version of an integer is useful if your ASN.1 source uses -subtyping similar to: -\begin{ASNcode} -Counter ::= [APPLICATION 1] IMPLICIT INTEGER (0..4294967295) -\end{ASNcode} - -\section{\label{enum-C++-section}ENUMERATED} - -The ENUMERATED type is represented by the {\C AsnEnum} class. The -following is the class definition of {\C AsnEnum} from the -{\ufn \dots/c++-lib/inc/asn-enum.h} file. -\begin{Ccode} -class AsnEnum: public AsnInt\\ -\{\\ -public:\+\\ -\<\#if !TCL\\ - \>\>AsnEnum(): AsnInt() \{\}\\ -\<\#endif\\ - \>\>AsnEnum (int i): AsnInt (i) \{\}\\ -\\ - AsnType \>\>*Clone() const;\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tagId, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ -\<\#if META\\ - static const AsnEnumTypeDesc \>\>\_desc;\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\-\\ -\#endif /* META */\\ -\}; -\end{Ccode} - -Note that it is not derived from {\C class AsnType} directly but from {\C class AsnInt} instead. - -\section{\label{null-C++-section}NULL} - -The NULL type is provided by the {\C AsnNull} class. This class has -no data members and includes only the standard methods. -\begin{Ccode} -class AsnNull: public AsnType\\ -\{\\ -public:\+\\ - \>\>AsnNull() \{\}\\ - AsnType \>\>*Clone() const;\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tagId, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const \{ os <\/< "NULL"; \}\\ -\\ -\<\#if META\\ - static const AsnNullTypeDesc \>\>\_desc;\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *val);\-\\ -\#endif /* TCL */\\ -\#endif /* META */\\ -\}; -\end{Ccode} - -\section{\label{real-C++-section}REAL} - -REAL types are represented by the {\C AsnReal} class. Internally, a -{\C double} is used to hold the real value. The following is from -{\ufn \dots/c++-lib/inc/asn-real.h}: -\begin{Ccode} -class AsnReal: public AsnType\\ -\{\\ -protected:\\ - \>double \>\>value;\\ -\\ -public:\+\\ - \>\>AsnReal(): value (0.0) \{\}\\ - \>\>AsnReal (double val): value (val) \{\}\\ - AsnType \>\>*Clone() const;\\ - \>\>operator double() const \{ return value; \}\\ - AsnReal \>\>\&operator = (double newvalue) \{ value = newvalue; return *this; \}\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tagId, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const \{ os <\/< value; \}\\ -\\ -\<\#if META\\ - static const AsnRealTypeDesc \>\>\_desc;\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *val);\-\\ -\#endif /* TCL */\\ -\#endif /* META */\\ -\};\\ -\\ -extern const AsnReal \>\>\>PLUS\_INFINITY;\\ -extern const AsnReal \>\>\>MINUS\_INFINITY; -\end{Ccode} - -The {\C double} representation and support routines can depend on -the compiler or system you are using so several different encoding -routines are provided. Even so, you may need to modify the code. - -There are three content encoding routines included and they can be selected by defining one of {\C IEEE\_REAL\_FMT}, {\C IEEE\_REAL\_LIB} or nothing. -Defining {\C IEEE\_REAL\_FMT} uses the encode routine that assumes the double representation is the standard IEEE double \cite{68881}. -Defining {\C IEEE\_REAL\_LIB} uses the encode routine that assumes the IEEE functions library (isinf, scalbn, signbit etc.) is available. -If neither are defined, the default encode routine uses {\C frexp}. -%The {\ufn \dots/configure} script tries to find the {\C isinf} and {\C finite} functions -%Look at the related comments in {\ufn \dots/c++-lib/inc/asn-config.h}. -Currently, the {\ufn \dots/configure} script has not got any checks for the IEEE format or library and therefore does not define any of the symbols. (This should be fixed.) - -{\C AsnReal} constants are used to hold {\C PLUS\_INFINITY} and -{\C MINUS\_INFINITY} values. These values are initialized using the -{\C AsnReal} constructor mechanism with the {\C AsnPlusInfinity} -and {\C AsnMinusInfinity} routines. If you do not define -{\C IEEE\_REAL\_FMT} or {\C IEEE\_REAL\_LIB}, you should rewrite the -{\C AsnPlusInfinity} routine such that it is correct for your system. - -There is only one content decoding routine and it builds the value -through multiplication and the {\C pow} routine (requires the math -library). The content decoding routine only supports the binary -encoding of a REAL, not the decimal encoding. - -\section{\label{bits-C++-section}BIT STRING} - -The BIT STRING type is represented by the {\C AsnBits} class. From\linebreak -{\ufn \dots/c++-lib/inc/asn-bits.h}: -\begin{Ccode} -class AsnBits: public AsnType\\ -\{\\ -private:\+\\ - int \>\>BitsEquiv (AsnBits \&ab);\\ - void \>\>BDecConsBits (BUF\_TYPE b, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ - void \>\>FillBitStringStk (BUF\_TYPE b, AsnLen elmtLen0,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\>bitLen;\\ - char \>\>*bits;\\ -\\ -\\>AsnBits() \{ bits = NULL; bitLen = 0; \}\\ - \>\>AsnBits (const size\_t numBits) \{ Set (numBits); \}\\ - \>\>AsnBits (const char *bitOcts, const size\_t numBits) \\ - \`\{ Set (bitOcts, numBits); \}\\ - \>\>AsnBits (const AsnBits \&b) \{ Set (b); \}\\ - \>\>\~{}AsnBits() \{ delete bits; \}\\ -\\ - AsnType \>\>*Clone() const;\\ -\\ - AsnBits \>\>\&operator = (const AsnBits \&b) \{ ReSet (b); return *this; \}\\ -\\ - size\_t \>\>BitLen() \{ return bitLen; \}\\ -\\ - bool \>\>operator == (AsnBits \&ab) const \{ return BitsEquiv (ab); \}\\ - bool \>\>operator != (AsnBits \&ab) const \{ return !BitsEquiv (ab); \}\\ -\\ - // overwrite existing bits and bitLen values\\ - void \>\>Set (size\_t numBits);\\ - void \>\>Set (const char *bitOcts, size\_t numBits);\\ - void \>\>Set (const AsnBits \&b);\\ -\\ - // free old bits value, the reset bits and bitLen values\\ - void \>\>ReSet (const size\_t numBits);\\ - void \>\>ReSet (const char *bitOcts, size\_t numBits);\\ - void \>\>ReSet (const AsnBits \&b);\\ -\\ - void \>\>SetBit (size\_t);\\ - void \>\>ClrBit (size\_t);\\ - int \>\>GetBit (size\_t) const;\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tagId, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const;\\ -\\ -\<\#if META\\ - static const AsnBitsTypeDesc \>\>\_desc;\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *val);\-\\ -\#endif /* TCL */\\ -\#endif /* META */\\ -\}; -\end{Ccode} - -The {\C AsnBits} class contains a pointer to the bits and an -integer that holds the length in bits of the BIT STRING\@. - -In addition to the standard methods, the {\C AsnBits} class has -methods for initializing and comparing bit string values and methods -for setting and getting individual bits in a value. - -An {\C AsnBits} value can be created three ways: from the number of -bits, from a {\C char~*} and its bit length or from another -{\C AsnBits} value. Look at the constructors and the {\C Set} and -{\C ReSet} methods. - -{\C SetBit} and {\C ClrBit} can be used for setting the values of -individual bits in the BIT STRING value. Given the bit's index, -{\C SetBits} sets that bit to one. {\C ClrBit} sets the bit -of the given index to zero. The bit indexes start at zero, with zero -being the first (most signficant) bit in the BIT STRING\@. {\C GetBit} -will return {\C true} if the specified bit is one and {\C false} if the bit is -zero. If the given bit index is too large, {\C SetBit} and -{\C ClrBit} do nothing and {\C GetBit} returns {\C false}\@. - -The {\C ==} and {\C !=} operators have been overloaded such that -given two {\C AsnBits} values, they will behave as expected. - -Each {\C AsnBits} value stores its bit string in a single contiguous -block of memory. Received BIT STRING values that were encoded in the -constructed form are converted to the simple, flat form (see Section -\ref{bits-C-section}). Snacc provides no facility for encoding or -internally representing constructed BIT STRING values. - -\section{\label{octets-C++-section}OCTET STRING} -OCTET STRING values are represented with the {\C AsnOcts} class. -From\linebreak {\ufn \dots/c++-lib/inc/asn-octs.h}: -\begin{Ccode} -class AsnOcts: public AsnType\\ -\{\\ -private:\+\\ - int \>\>OctsEquiv (const AsnOcts \&o);\\ - void \>\>FillBitStringStk (BUF\_TYPE b, AsnLen elmtLen0,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ - void \>\>BDecConsOcts (BUF\_TYPE b, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ -\\>octetLen;\\ - char \>\>*octs;\\ -\\ -\\>AsnOcts(): octs (NULL), octetLen (0) \{\}\\ - \>\>AsnOcts (const char *str) \{ Set (str); \}\\ - \>\>AsnOcts (const char *str, const size\_t len) \{ Set (str, len); \}\\ - \>\>AsnOcts (const AsnOcts \&o) \{ Set (o); \}\\ - \>\>\~{}AsnOcts() \{ delete octs; \}\\ - AsnType \>\>*Clone() const;\\ -\\ - AsnOcts \>\>\&operator = (const AsnOcts \&o) \{ ReSet (o); return *this; \}\\ - AsnOcts \>\>\&operator = (const char *str) \{ ReSet (str); return *this; \}\\ -\\ - size\_t \>\>Len() const \{ return octetLen; \}\\ - \>\>operator const char *() const \{ return octs; \}\\ - \>\>operator char *() \{ return octs; \}\\ -\\ - bool \>\>operator == (const AsnOcts \&o) const \{ return OctsEquiv (o); \}\\ - bool \>\>operator != (const AsnOcts \&o) const \{ return !OctsEquiv (o); \}\\ -\\ - // these set the octs and octetLen values\\ - void \>\>Set (const char *str, size\_t len);\\ - void \>\>Set (const AsnOcts \&o);\\ - void \>\>Set (const char *str);\\ -\\ - // these free the old octs value and then reset the octs and octetLen values\\ - void \>\>ReSet (const char *str, size\_t len);\\ - void \>\>ReSet (const AsnOcts \&o);\\ - void \>\>ReSet (const char *str);\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tagId, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const;\\ -\\ -\<\#if META\\ - static const AsnOctsTypeDesc \>\>\_desc;\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *val);\-\\ -\#endif /* TCL */\\ -\#endif /* META */\\ -\}; -\end{Ccode} - -The {\C AsnOcts} class contains a pointer to the octets and an -integer that holds the length in octets of the OCTET STRING\@. - -There are four constructors for {\C AsnOcts}. The parameterless -constructor will initialize the octet string to zero length with a -{\C NULL} octets pointer. The constructor that takes a single {\C char~*} -assumes that the given string is NUL terminated and initializes the octet -pointer with a pointer to a copy of the given string and sets the -{\C octetLen} to the {\C strlen} of the string (this does not usually -include the NUL terminator). The constructor that takes -{\C char~*} and a length, {\C len}, initializes the octets pointer -to point to a copy of {\C len} characters from the given string and -sets the {\C octetLen} to {\C len}. The last constructor will initialize -an {\C AsnOcts} value by copying the given {\C AsnOcts} value. - -As with the BIT STRING content decoder, OCTET STRING content decoder -can handle constructed values. These are handled in the same way as -the constructed BIT STRING values; they are converted to the simple -contiguous representation. Every OCTET STRING value will -automatically have a NUL terminator appended to it; this extra -character will not be included in the string's length and will make -some strings easier to deal with for printing etc. - -The {\C operator char~*()} is defined for the {\C AsnOcts} class to -return a pointer to the octets. The {\C Len} -method returns the length in bytes of the string value. -These may be useful for passing the -octets to other functions such as {\C memcpy} etc. - -The {\C ==} and {\C !=} operators have been overloaded such that -given two {\C AsnOcts} values, they will behave as expected. - - - -\section{\label{oid-C++-section}OBJECT IDENTIFIER} -OBJECT IDENTIFIER values are represented with the {\C AsnOid} class. -From\linebreak {\ufn \dots/c++-lib/inc/asn-oid.h}: -\begin{Ccode} -class AsnOid: public AsnType\\ -\{\\ -private:\\ - \>int \>\>OidEquiv (AsnOid o);\\ -\\ -protected:\+\\ - size\_t \>\>octetLen;\\ - char \>\>*oid;\\ -\\ -\\>AsnOid(): oid (NULL), octetLen (0) \{\}\\ - \>\>AsnOid (const char *encOid, size\_t len) \{ Set (encOid, len); \}\\ - \>\>AsnOid (const AsnOid \&o) \{ Set (o); \}\\ - \>\>AsnOid (unsigned long int a1, unsigned long int a2, long int a3 = -1,\\ - \`long int a4 = -1, long int a5 = -1, long int a6 = -1, long int a7 = -1,\\ - \`long int a8 = -1, long int a9 = -1, long int a10 = -1, long int a11 = -1);\\ - \>\>\~{}AsnOid() \{ delete oid; \}\\ - AsnType \>\>*Clone() const;\\ -\\ - AsnOid \>\>\&operator = (const AsnOid \&o) \{ ReSet (o); return *this; \}\\ -\\ - size\_t \>\>Len() \{ return octetLen; \}\\ - const char \>\>*Str() const \{ return oid; \}\\ - \>\>operator const char * () const \{ return oid; \}\\ - \>\>operator char * () \{ return oid; \}\\ - unsigned long int \>\>NumArcs() const;\\ -\\ - bool \>\>operator == (AsnOid \&o) const \{ return OidEquiv (o); \}\\ - bool \>\>operator != (AsnOid \&o) const \{ return !OidEquiv (o); \}\\ -\\ - // Set methods overwrite oid and octetLen values\\ - void \>\>Set (const char *encOid, const size\_t len);\\ - void \>\>Set (const AsnOid \&o);\\ -\\ - // first two arc numbers are mandatory. rest are optional since negative arc nums are not allowed in the\\ - // encodings, use them to indicate the 'end of arc numbers' in the optional parameters\\ - void \>\>Set (unsigned long int a1, unsigned long int a2, long int a3 = -1,\\ - \`long int a4 = -1, long int a5 = -1, long int a6 = -1, long int a7 = -1,\\ - \`long int a8 = -1, long int a9 = -1, long int a10 = -1, long int a11 = -1);\\ -\\ - // ReSet routines are like Set except the old oid value is freed\\ - void \>\>ReSet (const char *encOid, const size\_t len);\\ - void \>\>ReSet (const AsnOid \&o);\\ - void \>\>ReSet (unsigned long int a1, unsigned long int a2, long int a3 = -1,\\ - \`long int a4 = -1, long int a5 = -1, long int a6 = -1, long int a7 = -1,\\ - \`long int a8 = -1, long int a9 = -1, long int a10 = -1, long int a11 = -1);\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - AsnLen \>\>BEncContent (BUF\_TYPE b);\\ - void \>\>BDecContent (BUF\_TYPE b, AsnTag tagId, AsnLen elmtLen,\\ - \`AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const;\\ -\\ -\<\#if META\\ - static const AsnOidTypeDesc \>\>\_desc;\\ -\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *val);\-\\ -\#endif /* TCL */\\ -\#endif /* META */\\ -\}; -\end{Ccode} - -The {\C AsnOid} stores OBJECT IDENTIFIER values in their encoded form -to improve performance. It seems that the most common operation with -OBJECT IDENTIFIERs is to compare for equality, for which the encoded -representation (which is canonical) works well. - -The {\C AsnOid} is very similar to the {\C AsnOcts} class in all -respects, except that its content decoding routine does not need to -handle constructed encodings. - -The {\C AsnOid} class has four constructors which are similiar to -those of the {\C AsnOcts} class. A special constructor that takes -arc numbers as parameters and uses default parameters is provided. An -OBJECT IDENTIFIER value must have at least two arc numbers so the -first two parameters do not have default values. All of the other -parameters are optional; since their default value of {\C --1} is an -invalid arc number (they must be positive) they will not be used in the -value. For example to build the value {\C \{1 2 3\}} you simply use -{\C AsnOid (1, 2, 3)}. This constructor is convenient but is more -expensive in terms of CPU time than the others. - -The {\C operator char~*()} is defined for the {\C AsnOid} class to -return a pointer to the encoded OBJECT IDENTIFIER value. The {\C Len} -method returns the length in bytes of the encode OBJECT IDENTIFIER -value (NOT the number arcs in the value). These may be useful for -passing the octets to other functions such as {\C memcpy} etc. -{\C NumArcs} returns the number of arcs that the value is comprised of. - -The {\C ==} and {\C !=} operators have been overloaded such that -given two {\C AsnOcts} values, they will behave as expected. - - - -\section{\label{list-C++-section}SET OF and SEQUENCE OF} - -In the C ASN.1 library, the list type was in the library because it -was generic and every SET OF and SEQUENCE OF was defined as an -{\C AsnList}. In C++, a new class is defined every list, providing -a type safe list mechanism. This was described in the previous chapter. - - -\section{\label{any-C++-section}ANY and ANY DEFINED BY} - -The ANY DEFINED BY type can be handled automatically by snacc -provided you use the SNMP OBJECT-TYPE macro to specify the identifier -to type mappings. The identifier can be an INTEGER or OBJECT -IDENTIFIER\@. Handling ANY types properly will require modifications to -the generated code since there is no identifier associated with the -type. - -Look at the C and C++ ANY examples and the {\ufn any.asn1} file -included with this release for information on using the OBJECT-TYPE -macro. Note that the OBJECT-TYPE macro has been modified slightly to -allow INTEGER values (identifiers). - -An ANY DEFINED BY type is represented by the {\C AsnAny} class. -The following is from {\ufn \dots/c++-lib/inc/asn-any.h}. -\begin{Ccode} -/* AnyInfo is a hash table entry */\\ -class AnyInfo\\ -\{\\ -public:\+\\ - int \>\>anyId; // will be a value from the AnyId enum\\ - AsnOid \>\>oid; // will be zero len/null if intId is valid\\ - AsnInt \>\>intId;\\ - AsnType \>\>*typeToClone;\-\\ -\};\\ -\\ -class AsnAny: public AsnType\\ -\{\\ -public:\+\\ - static Table \>\>*oidHashTbl; // all AsnAny class instances\\ - static Table \>\>*intHashTbl; // share these tables\\ - AnyInfo \>\>*ai; // points to entry in hash tbl for this type\\ - AsnType \>\>*value;\\ -\\ - \>\>AsnAny() \{ ai = NULL; value = NULL; \}\\ -\\ - // class level methods\\ - static void \>\>InstallAnyByInt (AsnInt intId, int anyId, AsnType *type);\\ - static void \>\>InstallAnyByOid (AsnOid \&oid, int anyId, AsnType *type);\\ -\\ - int \>\>GetId() \{ return ai ? ai-->anyId : -1; \}\\ - void \>\>SetTypeByInt (AsnInt id);\\ - void \>\>SetTypeByOid (AsnOid \&id);\\ -\\ - AsnLen \>\>BEnc (BUF\_TYPE b);\\ - void \>\>BDec (BUF\_TYPE b, AsnLen \&bytesDecoded, ENV\_TYPE env);\\ -\\ - int \>\>BEncPdu (BUF\_TYPE b, AsnLen \&bytesEncoded);\\ - int \>\>BDecPdu (BUF\_TYPE b, AsnLen \&bytesDecoded);\\ -\\ - void \>\>Print (ostream \&os) const \{ value-->Print (os); \}\\ -\<\}; -\end{Ccode} - -The C++ mechanism is similar to the C mechanism which uses hash tables -to hold the identifier to type mappings. In this section we will -discuss the main differences of the C++ ANY DEFINED BY handling -mechanism. You should read Section~\ref{any-C-section} for caveats and -other important information. - -In C, the hash table entry held the size of the type and pointers to -its encode, decode, free etc. routines to describe the type. In C++ -these have been replaced with a pointer to an instance of the type. A -hash table entry contains: -\begin{itemize} -\item {the {\C anyId}} -\item {the INTEGER or OBJECT IDENTIFIER that maps to it} -\item {a pointer to an instance of the identified type} -\end{itemize} - -All C++ ASN.1 types use the {\C AsnType} base class which designates the following functions as virtual: -\begin{itemize} - \item the destructor - \item {\C Clone()} - \item {\C BDec()} - \item {\C BEnc()} - \item {\C Print()} - \item {\C \_getdesc()} (metacode) - \item {\C \_getref()} (metacode) - \item {\C TclGetDesc()} (Tcl interface) - \item {\C TclGetVal()} (Tcl interface) - \item {\C TclSetVal()} (Tcl interface) - \item {\C TclUnsetVal()} (Tcl interface) -\end{itemize} - -This allows the ANY DEFINED BY handling routines to treat a value of -any ASN.1 type as an {\C AsnType}. So, for each type the ANY -DEFINED BY handling code has access to the virtual methods. Note -that the {\C value} field in the {\C AsnAny} class and the -{\C typeToClone} field in the {\C AnyInfo} class are both -{\C AsnType~*}. - -To build an ANY DEFINED BY value, simply set the value field in the -{\C AsnAny} object to point to the object you want to encode. Then -set the identifier field for that ANY DEFINED BY value to the correct -identifier (as generated for its OBJECT-TYPE macro value). It is very -important to do this correctly because the encoder will simply call -the virtual {\C BEnc} routine for the object pointed to by the -{\C AsnAny}'s value field. There is no attempt to make sure that -the identifier field's value matches the object that was encoded. - -A potential solution to the last identifier problem is to add a type -id field to the {\C AsnType} base class. Snacc could generate a -unique identifier (that would be stored in the base class) for each -type. The encoder could then check identifiers between the value -being encoded and the value stored in the hash table. The identifier -in the base class could easily be automatically set (correctly) from -the constructors for each type (constructors are snacc generated). It -would be difficult to ensure unique identifiers for each type between -modules if the ASN.1 modules were compiled separately. - -Before an ANY DEFINED BY value can be decoded, the field that contains -its identifier must have been decoded and used with the {\C AsnAny} -value's {\C SetTypeByInt} or {\C SetTypeByOid} methods. Then the -ANY DEFINED BY value can be decoded by calling its ({\C AsnAny}) -{\C BDec} routine. This in turn calls the {\C Clone} routine on -the type in the hash table entry to generate the correct object. Then -the {\C BDec} method of the newly created object is called. - -When the C ANY DEFINED BY decoder allocates a value, it uses the size -information for the identified type. This is not safe for C++ so the -virtual {\C Clone} routine was added to the {\C AsnType} base -class. This allows the proper constructor mechanism to be used when -allocating the value. - -The virtual {\C Clone} routine simply calls its type's parameterless -constructor via {\C new} (hence every ASN.1 type's class must have a -parameterless constructor). {\C Clone} is a poor name since -the routine only produces a new instance of the given type without -copying the original's data. - -The hash tables are automatically initialized using the C++ constructor -mechanism. You do not need to call any initialization routines as -described in the C chapter. - - -\section{\label{buffer-C++-section}Buffer Management} - -The C++ buffer management provided with snacc is similar to that of -the C {\C SBuf}s. The following is from -{\ufn \dots/c++-lib/inc/asn-buf.h}: -\begin{Ccode} -class AsnBuf\\ -\{\\ -protected:\+\\ - char \>\>*dataStart;\\ - char \>\>*dataEnd;\\ - char \>\>*blkStart;\\ - char \>\>*blkEnd;\\ - char \>\>*readLoc;\\ - bool \>\>writeError;\\ - bool \>\>readError;\\ -\\ -\\>Init (char *data, size\_t dataLen);\\ - void \>\>ResetInReadMode();\\ - void \>\>ResetInWriteRvsMode();\\ - void \>\>InstallData (char *data, size\_t dataLen);\\ - size\_t \>\>DataLen();\\ - char \>\>*DataPtr();\\ - size\_t \>\>BlkLen();\\ - char \>\>*BlkPtr();\\ - bool \>\>Eod();\\ -\\ - /* the following 9 methods are required */\\ - bool \>\>ReadError();\\ - bool \>\>WriteError();\\ - void \>\>Skip (size\_t skipLen);\\ - size\_t \>\>CopyOut (char *dst, size\_t copyLen);\\ - unsigned char \>\>PeekByte();\\ - char \>\>*GetSeg (size\_t *lenPtr);\\ - void \>\>PutSegRvs (char *seg, size\_t segLen);\\ - unsigned char \>\>GetByte();\\ - void \>\>PutByteRvs (unsigned char byte);\\ -\<\}; -\end{Ccode} - -This is the only buffer type provided with the C++ library. - -\section{\label{mem-C++-section}Dynamic Memory Management} - -The built-in C++ memory management system is used by snacc ({\C new} -and {\C delete}). Better performance might be gained by using a -different management scheme. - -To change {\C new} and {\C delete} to use your own memory -management scheme the best way to start is by defining them as virtual -in the {\C AsnType} base class. More information on providing your -own memory management can be found in Stroustrup \cite{stroustrup}. - -\section{\label{error-C++-section}Error Management} - -The C++ ASN.1 error management is identical to that of the C ASN.1 -model. C++ exception handling ({\C try} and {\C throw}) were not -used to replace {\C setjmp()} and {\C longjmp()} because they were not -implemented by the C++ compiler we used. diff --git a/SecuritySNACCRuntime/doc/c-gen.tex b/SecuritySNACCRuntime/doc/c-gen.tex deleted file mode 100644 index 34d6b39b..00000000 --- a/SecuritySNACCRuntime/doc/c-gen.tex +++ /dev/null @@ -1,772 +0,0 @@ -% file: .../doc/c-gen.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/c-gen.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: c-gen.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:51 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:33 rj -% first check-in -% - -\chapter{\label{c-code-gen-chapter}C Code Generation} -\section{\label{intro-C-section}Introduction} -Snacc was designed primarily to provide high-performance encoders and -decoders. Key areas to optimize are buffer and memory management. -Buffers are used to hold encoded values and the memory management is -used when building the internal representation of a value when decoding. - -C macros are used where possible to eliminate function call overhead -for small, commonly used routines. Using macros with constant -expressions as parameters allows smarter C compilers to do some of the -calculations at compile time. In general, short-cuts that can be taken -without sacrificing the robustness of code are used. - -The generated code can be quite large; large reductions of the size of -the binaries can be achieved by using the optimizing options of your C -compiler. - -We will use an example ASN.1 module, EX1, to help explain snacc's code -generation. The EX1 module uses some of the common built-in types and -contains some simple values. The field names have been left out -to show snacc naming conventions. The C generation code is in -{\ufn \dots/compiler/back-ends/c-gen/} if you want to alter it. - -\begin{small} -\begin{verbatim} -EX1 DEFINITIONS ::= -BEGIN - -anOidVal OBJECT IDENTIFIER ::= { joint-iso-ccitt 40 foobar(29) } -theSameOidVal OBJECT IDENTIFIER ::= { 2 40 29 } -anIntVal INTEGER ::= 1 -aBoolVal BOOLEAN ::= TRUE - -T1 ::= SEQUENCE -{ - INTEGER OPTIONAL, - OCTET STRING OPTIONAL, - ENUMERATED { a(0), b(1), c(2) }, - SEQUENCE OF INTEGER, - SEQUENCE { id OBJECT IDENTIFIER, value OCTET STRING }, - CHOICE { INTEGER, OBJECT IDENTIFIER } -} - -END -\end{verbatim} -\end{small} - -\noindent -Use the following command to compile the EX1 ASN.1 module: - -\noindent -{\ufn \%1 snacc -u \dots/asn1specs/asn-useful.asn1 \dots/asn1specs/ex1.asn1} -\noindent - -This produces the files {\ufn ex1.h} and {\ufn ex1.c}. - -For each ASN.1 type an equivalent C data type, a BER encoding routine, -a BER decoding routine, a printing routine and a freeing routine will -be generated. C values will also be generated from simple ASN.1 -values. Each aspect of the C code generation will be discussed in the -next sections. - -\section{\label{naming-C-section}ASN.1 to C Naming Conventions} - -For any given module, snacc may produce C type definitions, functions -and {\C \#define}s. We assume that all C {\C typedef}, -{\C struct}, {\C enum} and {\C union} tag, {\C enum} value, -variable, {\C \#define} and function names share a single name space. - -The C type name for a type is the same as its ASN.1 type name (with -any hyphens converted to underscores) unless there is a conflict. -Since, unlike ASN.1, the C types for each ASN.1 module share the same -name space, snacc makes sure the C typenames are unique amoung all the -modules and that they do not conflict with C keywords. The conflicts -are resolved by appending digits to the conflicting name. To avoid -confusing numbered type names etc., you should edit the ASN.1 source -and name them properly. - -Named numbers, ENUMERATED values and named bits are put in entirely in -upper case to match the common C convention for {\C \#define} and -{\C enum} values. - -Empty field names in SETs, SEQUENCEs, and CHOICEs will be filled. The -field name is derived from the type name for that field. The library -types such as INTEGER have default field names defined by the compiler -(see {\ufn \dots/compiler/back-ends/c-gen/rules.c} and -{\ufn \dots/compiler/back-ends/c++-gen/rules.c}). The first letter of the field -name is in lower case. Again, empty field names should be fixed -properly by adding them to the ASN.1 source. - -New type definitions will be generated for SETs, SEQUENCEs, CHOICEs, -ENUMERATED, INTEGERs with named numbers and BIT STRING with named bits -whose definitions are embedded in other SET, SEQUENCE, SET OF, -SEQUENCE OF, or CHOICE definitions. The name of the new type is -derived from the name of the type in which it was embedded. Perhaps a -better way would use the field name as well, if present. - -\section{\label{type-gen-C-section}ASN.1 to C Data Structure Translation} - -To handle the different scoping rules between ASN.1 and C, the names -of some ASN.1 data structure elements such as ENUMERATED type symbols -may be altered to avoid conflicts. The T1 type in example ASN.1 -module EX1 has no field names so snacc will generate them. It is -recommended to provide field names in the ASN.1 source instead of -relying on compiler generated names. The following is the generated C -data structure for the EX1 module from the {\ufn ex1.h} file (function -prototypes have been removed): - -\begin{small} -\begin{verbatim} - -typedef enum -{ - A = 0, - B = 1, - C = 2 -} T1Enum; /* ENUMERATED { A(0), B(1), C(2) } */ - -typedef struct T1Choice /* CHOICE */ -{ - enum T1ChoiceChoiceId - { - T1CHOICE_INT1, - T1CHOICE_OID - } choiceId; - union T1ChoiceChoiceUnion - { - AsnInt int1; /* INTEGER */ - AsnOid *oid; /* OBJECT IDENTIFIER */ - } a; -} T1Choice; - -typedef struct T1Seq /* SEQUENCE */ -{ - AsnOid id; /* OBJECT IDENTIFIER */ - AsnOcts value; /* OCTET STRING */ -} T1Seq; - -typedef AsnList T1SeqOf; /* SEQUENCE OF INTEGER */ - -typedef struct T1 /* SEQUENCE */ -{ - AsnInt *int1; /* INTEGER OPTIONAL */ - AsnOcts octs; /* OCTET STRING OPTIONAL */ - T1Enum t1Enum; /* T1Enum */ - T1SeqOf *t1SeqOf; /* T1SeqOf */ - struct T1Seq *t1Seq; /* T1Seq */ - struct T1Choice *t1Choice; /* T1Choice */ -} T1; -\end{verbatim} -\end{small} - -Every ASN.1 type definition maps into a C {\C typedef}. SETs and -SEQUENCEs map into C structures and other simple types map into their -obvious C counterpart. SET OF and SEQUENCE OF types map into a -generic list type which is doubly linked and NULL terminated. The -reverse link on the lists allows for simpler backwards encoding. More -information on the library types can be found in Chapter~\ref{lib-C-chapter}. - -Comments that contain a fragment of each type's ASN.1 definition are -inserted in the header file to clarify cases where elements have been -re-named. - -Aggregate types that are defined in other type definitions are moved -to their own type definitions. For example, notice how the SEQUENCE -and CHOICE that are in type {\C T1} have been moved to the types -{\C T1Seq} and {\C T1Choice} in the C code. This simplifies code -generation at the cost of introducing new types. - -Identifiers for named numbers from INTEGER and ENUMERATED types and -named bits from the BIT STRING type are capitalized in the C -representation. The ENUMERATED type maps to a C {\C enum} and the INTEGER -and BIT STRING named numbers/bits are handled with {\C \#define} -statements. - -Most OPTIONAL elements of SEQUENCEs and SETs are referenced by -pointer. An element is considered present if its pointer is non-NULL\@. -OCTET STRINGs, BIT STRINGs and OBJECT IDENTIFIERs are the exceptions, -and are included by value even when they are OPTIONAL because they are -small and contain an internal pointer that can be used to determine -their presence. For an example of this, look at the first two -elements of type {\C T1}. The INTEGER type is referenced by pointer -because it is OPTIONAL, but the OCTET STRING type is included -(non-pointer) in the {\C T1} type even though it is OPTIONAL\@. - - -\section{\label{encode-gen-C-section}Encode Routines} - -Snacc generates two kinds of encoding routines. One is PDU oriented -and encodes the type's tag, length and content and the other -only encodes the type's content. The generated encoders only call the -content encoders, except in the case of ANY and ANY DEFINED BY types. -Typically, you will only call the PDU oriented routines from your -code. - -The content and PDU encoding routine interfaces are similar for all -ASN.1 types. They both take two parameters, one is a buffer pointer -and the other is a pointer to the value to be encoded. For example -the {\C T1} type from module EX1 has the following prototypes for -its encoding routines. - -\begin{verbatim} -AsnLen BEncT1Content (BUF_TYPE b, T1 *v); -AsnLen BEncT1 (BUF_TYPE b, T1 *v); -\end{verbatim} - -{\C BEnc} is short for ``BER Encode''. The {\C BUF\_TYPE} -parameter is the buffer to encode the value into and the {\C T1~*} -parameter is a pointer to the instance of the {\C T1} type that is to be -encoded. - -The {\C BEncT1Content} routine only encodes the content of a {\C T1} -type and returns its encoded length; it does not encode its tag -(UNIVERSAL (CONSTRUCTED) 16 for SEQUENCE) or length. The job of -encoding the tag and length is up to any type that encapsulates {\C T1}. -This design allows decisions about implicit tagging to be made at code -generation time instead of runtime, improving performance. Also, -different encoding rules may fit into this model more easily. - -The {\C BEncT1} routine encodes the tag (UNIVERSAL (CONSTRUCTED) 16 -for SEQUENCE), length and content of a {\C T1} type and returns its encoded -length. This is the PDU oriented routine and will only be generated -if the user designates the type as a PDU type via a compiler directive -or the type is used as -the content of an ANY or ANY DEFINED BY type (as indicated by an -OBJECT-TYPE macro). A PDU type is a type that defines an entire PDU; -the user will typically be calling the encode and decode routine for -PDU types directly. See Section~\ref{compiler-dir-C-section} for how to -designate PDU types with compiler directives. - -The snacc encoders are somewhat strange; they encode a value starting -from the end of its BER representation and work back to its beginning. -This ``backwards'' encoding technique simplifies the use of definite -lengths on constructed values. Other encoders that encode forwards, -such as those of CASN1, use an intermediate buffer format so that a -buffer containing the encoded length of a constructed value can be -inserted before its encoded content, after the content has been -encoded. Use of intermediate buffers hurts performance. Other -compilers' approaches have been to only encode indefinite lengths for -constructed values, however, this will not support some encoding rules -such as DER\@. The drawback of encoding backwards is that BER values -cannot be written to stream-oriented connections as they are encoded. - -Both definite and indefinite length encodings for constructed values' -lengths are supported. Currently the choice is made when compiling -the generated code, via the {\C USE\_INDEF\_LEN} flag. If both length -forms, definite and indefinite, are required, it easy to modify the -length encoding macros to check a global variable for the length -form to use. For most types, using definite lengths produces smaller -encodings with little performance difference. - -After calling an encode routine you should always check the buffer -you encoded into for a write error. This is the only error reporting -mechanism used for the encoders. See the C buffer section (Section -\ref{lib-buf-section}) for how to check a buffer for a write error. - - -\section{\label{decode-gen-C-section}Decode Routines} - -Decoding routines are like the encoding routines in that there are two -kinds, one that decodes the type's tag, length and content and one -that only decodes the type's content. As mentioned in the encoder -section, the content style interface allows implicit tagging decisions -to be made at compile time. - -Unlike the encoding routines, the PDU and content decoding routines -take different arguments. For the {\C T1} type the following would be -produced: -\begin{verbatim} -void BDecT1Content (BUF_TYPE b, AsnTag tagId0, AsnLen elmtLen0, T1 *v, AsnLen *bytesDecoded, ENV_TYPE env); -void BDecT1 (BUF_TYPE b, T1 *v, AsnLen *bytesDecoded, ENV_TYPE env); -\end{verbatim} - -Notice that the content decoder, {\C BDecT1Content}, has tag and -length parameters that the PDU decoder, {\C BDecT1}, does not have. -Since the content decoder does not decode the tag and length on the -value, it is necessary to pass them in as parameters. Only OCTET -STRING and BIT STRING decoders will actually use the information -in the tag parameter. - -The {\C BUF\_TYPE} parameter is the buffer that holds the BER value -being decoded. - -The {\C tagId0} parameter is the last tag that was decoded on the -content of the type that is about to be decoded. In the case of type -{\C T1}, {\C BDecT1Content} gets a tagId0 of UNIVERSAL (CONSTRUCTED) 16, -unless it is implicitly tagged by another type. Most content decoding -routines ignore the tag information. OCTET STRING and BIT STRING -decoders use the tag information to determine whether the contents are -constructed or primitive. CHOICE decoders use the tag information to -determine which CHOICE element is present. CHOICE values are treated -differently, as will be explained shortly. - -The {\C elmtLen0} parameter is the length of the content of the type -being decoded. This is simply the length decoded from the buffer by -the containing type's decoder just before calling this decode routine. - -The {\C v} parameter is a pointer to space allocated for the type -being decoded. This memory is not allocated by the decoding routine -itself; this supports the cases where the type is enclosed in the -struct of the parent (i.\,e.\ no extra allocation is necessary). If -the type to be decoded is referenced by pointer from its parent type, -the parent type's decoding routine must allocate the type. - -The {\C bytesDecoded} parameter maintains the running total of the -number of octets that have been decoded. For example, if I call -{\C BDecT1Content} with a {\C bytesDecoded} parameter that points -to 20 and the encoded length of the {\C T1} value is 30 octets, -{\C bytesDecoded} will point to 50 when {\C BDecT1Content} -returns. Maintaining the length is vital to determining the presence -or absence of OPTIONAL elements in a SET or at the end of SEQUENCE\@. -Local variables are used to hold the lengths; there is no global stack -of lengths as with CASN1. - -The {\C env} parameter is used in conjunction with {\C longjmp} -calls. When an decoder encounters a fatal error such as a missing -tag, it uses the {\C env} with a {\C longjmp} call to pop back to the -initial decode call. Section~\ref{lib-err-C-section} has more error -management details. - -CHOICEs are decoded a little differently from other types. For all -types except CHOICEs, all of the tag and length pairs on the content -are decoded by the parent type, and the last pair a passed into to -content decoding routine via the {\C tagId0} and {\C elmtLen0} -parameters. For CHOICEs, all of the tag and length pairs on the -content are decoded and then the first tag and length pair in the -CHOICE content is decoded by the parent and passed into the CHOICE -content decoding routine. The first tag in a CHOICE's content is the -important tag by which the CHOICE determines which element is present. -This technique simplifies the code for dealing with untagged CHOICEs -embedded in other CHOICEs. CHOICEs nested in this way mean that a -single tag determines which element is present in more than one -CHOICE\@. - -The decoding routines allocate memory to hold the decoded value. By -default snacc decoders use nibble memory (see Section -\ref{lib-mem-C-section}) which is very efficient in allocation and -virtually cost free for freeing. - -To save memory, decoders generated by some other tools build values -that reference the data in the encoded PDU for types like OCTET -STRING\@. Snacc decoded values do not reference the BER data in any way -for several reasons. One, the encoded value may be held in some -bizarre buffer making access to the value difficult. Two, with more -encoding rules being formalized, this technique may not always work -since the encoded format may be different from the desired internal -format. Three, snacc decoders concatenate any constructed BIT and -OCTET STRINGs values when decoding, to simplify processing in the -application. - -Snacc decoders can detect a variety of errors which will be reported -by {\C longjmp}. Any tagging errors are reported. SETs must contain -all non-OPTIONAL components and SEQUENCEs must be in order and contain -all non-OPTIONAL components. Extra components in SETs and SEQUENCEs -are considered an error. Errors will also be reported if you attempt -to decode values that exceed the limitations of the internal -representation (e.\,g.\ an integer that is larger than a -{\C long int} allows). - -\section{\label{print-gen-C-section}Print Routines} -All of the generated print routines take similar parameters. For -example the {\C T1} type's print routine prototype is: -\begin{verbatim} -void PrintT1 (FILE *f, T1 *v, unsigned short int indent); -\end{verbatim} - -The print routine writes the given value, {\C v}, to the given {\C FILE~*}, -{\C f}. The printed value is indented by {\C indent} spaces. The -values are printed in an ASN.1 value notation style. {\C PrintT1} -prints in the following style: -\begin{small} -\begin{verbatim} -{ -- SEQUENCE -- - 17, - '436c696d6220617420537175616d697368'H -- "Climb at Squamish" --, - 0, - { -- SEQUENCE OF -- - 18, - 19 - }, - { -- SEQUENCE -- - id {2 40 29}, - value '736f6d6520737472696e67'H -- "some string" -- - }, - 20 -} -\end{verbatim} -\end{small} - -OCTET STRINGs are printed in a hexadecimal notation, and any printable -characters are included after the string in an ASN.1 comment. Note -that the enumerated type value, 0, did not print its symbol, ``A'' -from the ENUMERATED type. It would be fairly easy to modify the C and -C++ back ends to generate print routines that printed the ENUMERATED -types' symbols instead of their values. - -\section{\label{free-gen-C-section}Free Routines} - -Snacc generates free routines of the form: -\begin{verbatim} -void FreeT1 (T1 *v); -\end{verbatim} - -These routines will free all the components named type. -For example the above {\C FreeT1} routine will free all the -components of the given {\C T1} value, but not the {\C T1} value itself. The -passed in pointer is not freed because it may be embedded in another -type which will be freed by another call to {\C Asn1Free}. All the pieces -of memory are freed using the {\C Asn1Free} macro defined in -{\ufn asn-config.h}. Each library type has its own free routine that -may call {\C Asn1Free}. The values are typically allocated during -decoding, using the {\C Asn1Alloc} macro. - -The memory management can be changed by editing the {\ufn asn-config.h} -file to use you own memory management routines. By default the memory -manager uses the nibble memory system described in Section -\ref{lib-mem-C-section}. The nibble memory system does not need explicit -frees of each component so the generated free routines are not needed. -However, if you change the memory management to use something like -{\C malloc} and {\C free}, you should use the generated free routines. - - -\section{\label{val-gen-C-section}ASN.1 to C Value Translation} - -C values will be produced for INTEGER, BOOLEAN and OBJECT IDENTIFIER -values. C {\C extern} declarations for the value are put at the end -of the header file (after all of the type definitions). The value -definitions are put at the beginning of the source file. For example, -the following will be produced for the EX1 module (at the end of -file ex1.h): - -\begin{small} -\begin{verbatim} -extern AsnOid anOidVal; -extern AsnOid theSameOidVal; -extern AsnInt anIntVal; -extern AsnBool aBoolVal; -extern AsnInt foobar; -\end{verbatim} -\end{small} - -(at the beginning of file ex1.c): - -\begin{small} -\begin{verbatim} -AsnOid anOidVal = { 2, "\170\35" }; -AsnOid theSameOidVal = { 2, "\170\35" }; -AsnInt anIntVal = 1; -AsnBool aBoolVal = TRUE; -AsnInt foobar = 29; -\end{verbatim} -\end{small} - -\section{\label{compiler-dir-C-section}Compiler Directives} - -Snacc allows the user to control some aspects of the generated code by -inserting special comments in the ASN.1 source. Warning! only the -{\ASN isPdu} directive has been tested to any extent. Use the others -very carefully and only if you really need to. The compiler -directives have the form: - -\begin{verbatim} ---snacc :"" :"" ... -\end{verbatim} - -The {\ASN attribute} is the name of one of the accepted attributes and -the {\ASN value} is what the {\ASN attribute}'s new value will be. -The attribute value pairs can be listed in a single {\ASN --snacc} -comment or spread out in a list of consecutive comments. - -Compiler directives are only accepted in certain places in the ASN.1 -code. Depending on their location in the ASN.1 source, the compiler -directives affect type definitions or type references. The directives -for type definitions and references are different. Module level -compiler directives to specify output file names and other information -would be useful, but are not implemented. - -Here is an example to present some of the compiler directives and -their uses. Let's say your data structure always deals with -{\C PrintableStrings} that are null terminated (internally, not in -the encoding). The default snacc string type is a structure that -includes a length and {\C char~*} for the string octets. To change -the default type to a simple {\C char~*} the best way would be define -your own string type, let's say {\ASN MyString} as follows: - -\begin{small} -\begin{verbatim} -Foo ::= SET -{ - s1 [0] MyString OPTIONAL, - s2 [1] MyString, - i1 [2] INTEGER -} - -Bar ::= CHOICE -{ - s1 MyString, - i1 INTEGER -} - -Bell ::= MyString - -MyString ::= --snacc isPtrForTypeDef:"FALSE" - --snacc isPtrForTypeRef:"FALSE" - --snacc isPtrInChoice:"FALSE" - --snacc isPtrForOpt:"FALSE" - --snacc optTestRoutineName:"MYSTRING_NON_NULL" - --snacc genPrintRoutine:"FALSE" - --snacc genEncodeRoutine:"FALSE" - --snacc genDecodeRoutine:"FALSE" - --snacc genFreeRoutine:"FALSE" - --snacc printRoutineName:"printMyString" - --snacc encodeRoutineName:"EncMyString" - --snacc decodeRoutineName:"DecMyString" - --snacc freeRoutineName:"FreeMyString" - PrintableString --snacc cTypeName:"char *" -\end{verbatim} -\end{small} - -All but the last {\ASN --snacc} comment bind with the {\ASN MyString} type -definition. The last directive comment binds with the {\ASN PrintableString} -type. The C data structure resulting from the above ASN.1 and compiler -directives is the following: -\begin{small} -\begin{verbatim} -typedef char *MyString; /* PrintableString */ - -typedef struct Foo /* SET */ -{ - MyString s1; /* [0] MyString OPTIONAL */ - MyString s2; /* [1] MyString */ - AsnInt i1; /* [2] INTEGER */ -} Foo; - -typedef struct Bar /* CHOICE */ -{ - enum BarChoiceId - { - BAR_S1, - BAR_I1 - } choiceId; - union BarChoiceUnion - { - MyString s1; /* MyString */ - AsnInt i1; /* INTEGER */ - } a; -} Bar; - -typedef MyString Bell; /* MyString */ -\end{verbatim} -\end{small} - -The compiler directives used on the {\ASN MyString} type have some -interesting effects. Notice that {\ASN MyString} is not referenced by -pointer in the CHOICE, SET, or type definition, {\ASN Bell}. - -The generated code for encoding field {\C s1} of {\C Foo} type -will use the code\linebreak``{\C MYSTRING\_NON\_NULL (\&fooVal-->s1)}'' to check -for the presence of the OPTIONAL {\C s1} field. The code associated -with MYSTRING\_NON\_NULL should return TRUE if the {\C s1} field -value is present and might look like: -\begin{verbatim} -#define MYSTRING_NON_NULL(s) (*s != NULL) -\end{verbatim} - -The argument to {\C optTestRoutine} routine will be a pointer to the -field type's defining type. Note that in the above example, -{\ASN MyString} is a {\C char~*}, therefore the {\C MYSTRING\_NON\_NULL} -macro's argument will be a {\C char~**}. - -Setting the {\ASN genPrintRoutine} etc. attributes to false makes -snacc not define or generate any encode, decode, print, or free -routines for the {\ASN MyString} type. You must provide these -yourself; the best approach is to take the normal {\ASN PrintableString} -routines and modify them to handle your special string type. - -The names of the encode, decode, print and free routines used for the -{\ASN MyString} type will be based on the ones given with the -{\ASN printRoutineName} etc.\ attributes. Snacc will prepend a -``B'' (for BER) and append a ``Content'' to the encode and decode -routines names, so you must provide the {\C BEncMyStringContent} and -{\C BDecMyStringContent} routines. You may also need the -{\C BEncMyString} and {\C BDecMyString} routines if {\ASN MyString} is a -PDU type or used in an ANY or ANY DEFINED type. - -The {\ASN PrintableString} type has its C type name changed to -{\C char~*} by the last compiler directive. Thus {\ASN MyString} is defined -as a {\C char~*}. This directive applies to the {\ASN PrintableString} -type reference. Note that these directives do not affect the tags or -the encoded representation of the {\ASN MyString} type - -The location of the {\ASN --snacc} comment(s) is important. -{\ASN --snacc} comment(s) between the {\ASN ::=} sign and the -following type are associated with the type being defined. Any -compiler directives after the type and before the next type or value -definition are associated with the type. Fields in SETs, SEQUENCEs -and CHOICEs can be modified by putting the compiler directive after -the comma that follows the field type that you wish to modify. In the -case of the last element of one of these types, where there is no -comma, just place it after the field and before the closing bracket of -the parent type. - -Attributes shadow the type attributes filled in during the target -language type information generation pass of the compiler. The type -definition attributes are: - -\begin{description} -\item[cTypeName] { this is the type name that the generated type will -have. Its value can be any string that is valid as a C type name.} - -\item[isPdu] { whether this is a PDU type. A PDU type will have -extra interfaces to the encode and decode routines generated. Its -value can be ``TRUE'' or ``FALSE''} - -\item[isPtrForTypeDef] { TRUE if other types defined solely by this type -definition are defined as a pointer to this type. Its -value can be ``TRUE'' or ``FALSE''.} - -\item[isPtrForTypeRef]{ TRUE if type references to this type -definition from a SET or SEQUENCE are by pointer. Its -value can be ``TRUE'' or ``FALSE''.} - -\item[isPtrInChoice] {TRUE if type references to this type definition -from a CHOICE are by pointer. Its value can be ``TRUE'' or ``FALSE''.} - - -\item[isPtrForOpt] { TRUE if OPTIONAL type references to this type -definition from a SET or SEQUENCE are by pointer. Its value can be -``TRUE'' or ``FALSE''.} - -\item[optTestRoutineName] {name of the routine to test whether an -OPTIONAL element of this type in a SET or SEQUENCE is present. The -routine should return TRUE if the element is present. The value of -this field is usually just the name of a C macro that tests for NON-NULL\@. -The argument to the routine will be a pointer to the type definition's -type. The optTestRoutineName value can be any string value.} - -\item[defaultFieldName] { if this type is used in a SET, SEQUENCE or -CHOICE without a field name then this value is used with a digit -appended to it. Its value can be any string that is a valid C field -name in a struct or union.} -\item[printRoutineName] { name of this type definition's printing -routine. Its value can be any string that is a C function or -macro name.} -\item[encodeRoutineName]{ name of this type definition's encoding -routine. Its value can be any string that is a C function or -macro name.} -\item[decodeRoutineName]{ name of this type definition's decoding -routine. Its value can be any string that is a C function or -macro name.} -\item[freeRoutineName] { name of this type definition's freeing -routine. Its value can be any string that is a C function or -macro name.} - -\item[isEncDec] {If this type is used in a SET or SEQUENCE then it is not -encoded or decoded. Its value can be ``TRUE'' or ``FALSE''. This is -handy for adding your own types to a standard that are only for local -use, and are not included in encoded values.} - -\item[genTypeDef] { TRUE if you want a C type to be generated for this -type definition. Its values can be ``TRUE'' or ``FALSE''.} - -\item[genPrintRoutine] { TRUE if you want a printing routine to be -generated for this type definition. Its values can be ``TRUE'' or -``FALSE''.} -\item[genEncodeRoutine] { TRUE if you want an encoding routine to be -generated for this type definition. Its values can be ``TRUE'' or -``FALSE''.} -\item[genDecodeRoutine] { TRUE if you want a decoding routine to be -generated for this type definition. Its values can be ``TRUE'' or -``FALSE''.} -\item[genFreeRoutine] { TRUE if you want a free routine to be -generated for this type definition. Its values can be ``TRUE'' or -``FALSE''.} -\end{description} - - -The type reference attributes are slightly different from the type -definition attributes due to the semantic differences between a type -definition and a type reference. Type references will inherit some of -their attributes from the referenced type definition. The following -are the valid type reference attributes: -\begin{description} -\item[cTypeName] { this is the type name that the generated type will -have. Its value can be any string that is valid as a C type name.} - -\item[cFieldName] { if this is a field in a CHOICE, SET or SEQUENCE -then this holds the C field name for this reference. Its value can be -any string that is valid as a C field name.} - -\item[isPtr] { TRUE if this is a pointer to the type named by -cTypeName. This is usually determined from the referenced type -definitions attributes. Its value can be ``TRUE'' or ``FALSE''.} - -\item[optTestRoutineName] {if this field is an OPTIONAL component then -this is the name of the routine to test whether it is present. The -routine should return TRUE if the element is present. The value of -this is usually just the name of a C macro that tests for NULL\@. The -argument to the routine will be a pointer to the type definition's -type. The optTestRoutineName value can be any string value.} - -\item[printRoutineName] { name of this type reference's printing -routine. This and the other routine name attributes are useful for -special instances of the referenced type. It is easier to modify the -referenced type definition if you want every instance of this type to -use a certain print etc.\ routine. Its value can be any string that is -a value C function or macro name.} - -\item[encodeRoutineName]{ name of this type reference's encoding -routine. Its value can be any string that is a function or -macro name.} - -\item[decodeRoutineName]{ name of this type reference's decoding -routine. Its value can be any string that is a C function or -macro name.} - -\item[freeRoutineName] { name of this type reference's freeing -routine. Its value can be any string that is a C function or -macro name.} - -\item[isEncDec] { If this type is used in a SET or SEQUENCE then the -field is not encoded or decoded. Its value can be ``TRUE'' or -``FALSE''. This is handy for adding your own types to a standard that -are only for local use, and are not included in encoded values.} - -\item[choiceIdSymbol] {if this is a component of a CHOICE, this string -attribute will be the defined/enum symbol whose value in the choiceId -field indicates the presence of this field.} -\item[choiceIdValue] {if this is a component of a CHOICE, this integer -attribute will be the value associated with the symbol in choiceIdSymbol.} - -\end{description} - - - - -\section{\label{compiling-gen-C-section}Compiling the Generated C Code} - -The generated C code (and libraries) can be compiled by both ANSI and K\&R C compilers. -C function prototypes use the {\C PROTO} macro and C function declarations use the {\C PARAMS} macro. -These macros are defined in {\ufn \dots/snacc.h} and their definitions depend on whether the {\C \_\_USE\_ANSI\_C\_\_} flag has been defined in {\ufn \dots/config.h}. - -When compiling the generated C code you will need: -\begin{enumerate} -\item - The include directory where the files from {\ufn \dots/c-lib/inc/} have been installed into in your include path so the C sources can include the library header files. - The header files should be included with statements like {\C \#include } and your C compiler should be supplied with {\ufn -I/usr/local/include} in case snacc got installed under {\ufn /usr/local/}. -\item - to link with the correct C ASN.1 runtime library, depending on the buffer type you choose. - In case snacc got installed under {\ufn /usr/local/}, your linker may need to be supplied with {\ufn -L/usr/local/lib} and one of {\ufn -lasn1cebuf}, {\ufn -lasn1cmbuf} or {\ufn -lasn1csbuf} as arguments. -\item - to link with the math library ({\ufn -lm}), since the ASN.1 REAL type's encode and decode routine use some math routines. -\end{enumerate} - -See the example in {\ufn \dots/c-examples/simple/} for a complete -example. The makefile and main routines are probably the most -important. There are several other examples in the -{\ufn \dots/c-examples/} directory. diff --git a/SecuritySNACCRuntime/doc/c-lib.tex b/SecuritySNACCRuntime/doc/c-lib.tex deleted file mode 100644 index b7f1aedc..00000000 --- a/SecuritySNACCRuntime/doc/c-lib.tex +++ /dev/null @@ -1,1384 +0,0 @@ -% file: .../doc/c-lib.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/c-lib.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: c-lib.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:52 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:34 rj -% first check-in -% - -\chapter{\label{lib-C-chapter}C ASN.1 Library} -\section{\label{libover-C-section}Overview} - -Each library type has a file in the {\ufn \dots/c-lib/src/} and -{\ufn \dots/c-lib/inc/} directories. Each source file contains the encode, -decode, free and print routines for the given type. This chapter -contains a description of each library type and its routines. -This library is also referred to as the runtime library. - -After installing Snacc, you should test the library types to make sure -that they are encoding and decoding properly. Use the -{\ufn \dots/c-examples/test-lib/} example to check them. - -In addition to other errors, most decoding routines will report an -error if they attempt to read past the end of the data. Be aware that -some buffer types do not support this type of checking. This is -explained more in the buffer management section. - -\section{\label{tag-C-section}Tags} - -Snacc's tag representation was motivated by several things. -\begin{enumerate} -\item the tags must be easy to compare for equality in {\C if} and {\C switch} statements to make tag-based decisions cheap. -\item a tag must be cheap to decode. -\item a tag must be cheap to encode. -\end{enumerate} - -The first requirement meant that tags had to be integer types (for the -{\C switch} statement). The representation of the tag within the integer -was set by the second requirement. - -The best way to decode cheaply is minimize the transformation between -the encoded and decoded (internal) format. So the four (can be set-up -for two) bytes of the long integer are used to hold the encoded tag, -starting with the first octet of the tag in the most significant byte -of the integer and the rest (if any) following. Any unused (always -trailing) bytes in the integer are zero. This limits the -representable tag code to less than $2^{21}$ but for reasonable ASN.1 -specifications this should not be a problem. - -To meet the third requirement the decoded tag representation was -bypassed entirely by using macros ({\C BEncTag1()} etc.) that -write the encoded tag octet(s) to the buffer. The writing of an -encoded tag octet involves bit shifting, bitwise ands and bitwise ors -with constant values; most optimizing C compilers can compute these at -compile time. This simplifies encoding a tag to writing some constant -byte value(s) to the buffer. - -The following excerpt from {\ufn \dots/c-lib/inc/asn-tag.h} shows some -of the tag routines. -\begin{small} -\begin{verbatim} -typedef unsigned long int AsnTag; - -#define MAKE_TAG_ID( class, form, code) ... -#define TAG_IS_CONS( tag) ... - -#define BEncTag1( b, class, form, code) ... -#define BEncTag2( b, class, form, code) ... -#define BEncTag3( b, class, form, code) ... -#define BEncTag4( b, class, form, code) ... -#define BEncTag5( b, class, form, code) ... - -AsnTag BDecTag (BUF_TYPE b, AsnLen *bytesDecoded, ENV_TYPE env); -\end{verbatim} -\end{small} - -The generated decode routines use the {\C BDecTag} to decode a tag -from the buffer. The returned tag value is either used in an -{\C if} expression or as the argument to {\C switch} statements. -The {\C MAKE\_TAG\_ID} macro is used to make a tag for comparison to -the one returned by {\C BDecTag}. The {\C MAKE\_TAG\_ID} is used is -{\C switch} statement case labels and in {\C if} statements. - -Most of the time tags are only compared for equality, however, the -OCTET STRING and BIT STRING decoders check the constructed bit in the -tag using the {\C TAG\_IS\_CONS} macro. - -The {\C BEncTag} macros are quite fragile because they return the -encoded length of the tag; they cannot be treated as a single -statement. This requires careful use of braces when using them in -your own code in places such as the sole statement in an {\C if} -statement. This ugliness is caused by the difficulty in returning -values from multi-line macros (macros are used for performance here -since encoding tags can be a significant part of BER encoding). - -The {\C BDecTag} routine will report an error via {\C longjmp} if -the encoded tag is longer than can be held in the {\C AsnTag} type -or if it read past the end of the data when decoding the tag. - -\section{\label{len-C-section}Lengths} - -Decoded lengths are represented by unsigned long integers, with the -maximum value indicating indefinite length. - -Snacc users can choose between using only indefinite or only definite -lengths when encoding constructed values' lengths when compiling the -generated code. Of course, the generated decoders can handle both -forms. Define the {\C USE\_INDEF\_LEN} symbol when compiling the -generated code if you want to use indefinite lengths when encoding -constructed values. Primitive values are always encoded with definite -lengths as required by the standard; this is necessary to avoid -confusion between a value's content and the End-Of-Contents marker. - -There is no loss of performance when using definite lengths with snacc -encoders. This is due the ``backwards'' encoding as described in -Section~\ref{encode-gen-C-section}. The schemes used by other compilers' -encoders to handle definite lengths may hurt performance. - -Most of the routines in the following code are obvious except for -{\C BEncDefLenTo127()}. This is used instead of {\C BEncDefLen} -in the generated code when the compiler knows the value being encoded -will not be over 127 octets long. Values such as BOOLEANs, -INTEGERs, and REALs are assumed to be shorter than 127 octets -(constraints on the decoded representation of INTEGERs and REALs make -this valid). -\begin{small} -\begin{verbatim} -typedef unsigned long int AsnLen; - -/* max unsigned value - used for internal rep of indef len */ -#define INDEFINITE_LEN ~0L - -#ifdef USE_INDEF_LEN -#define BEncEocIfNec( b) BEncEoc (b) -#define BEncConsLen(b, len) 2 + BEncIndefLen (b) -#else -#define BEncEocIfNec( b) -#define BEncConsLen( b, len) BEncDefLen (b, len) -#endif - -#define BEncIndefLen( b) ... -#define BEncDefLenTo127( b, len) ... -AsnLen BEncDefLen (BUF_TYPE b, AsnLen len); -AsnLen BDecLen (BUF_TYPE b, AsnLen *bytesDecoded, ENV_TYPE env); - -#define BEncEoc( b) ... -#define BDEC_2ND_EOC_OCTET( b, bytesDecoded, env) ... -void BDecEoc (BUF_TYPE b, AsnLen *bytesDecoded, ENV_TYPE env); -\end{verbatim} -\end{small} - -The {\C BDecLen} routine will report an error via {\C longjmp} if -it attempts to read past the end of the data or the decoded length is -too large to be held in the {\C AsnLen} representation. -{\C BDecEoc} will report an error if it attempts to read past the -end of the data or one of the EOC (End-Of-Contents) octets is -non-zero. - -\section{\label{bool-C-section}BOOLEAN} - -The BOOLEAN type is represented by an {\C unsigned char}. It has -the following routines for manipulating it. -\begin{small} -\begin{verbatim} -typedef unsigned char AsnBool; - -AsnLen BEncAsnBool (BUF_TYPE b, AsnBool *data); -void BDecAsnBool (BUF_TYPE b, AsnBool *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -AsnLen BEncAsnBoolContent (BUF_TYPE b, AsnBool *data); -void BDecAsnBoolContent (BUF_TYPE b, AsnTag tag, AsnLen len, - AsnBool *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -#define FreeAsnBool( v) -void PrintAsnBool (FILE *f, AsnBool *b, unsigned short int indent); -\end{verbatim} -\end{small} - -As discussed in Sections \ref{encode-gen-C-section} and \ref{decode-gen-C-section}, -{\C BEncAsnBool} and {\C BDecAsnBool} encode/decode the UNIVERSAL -tag, length and content of the given BOOLEAN value. The\linebreak {\C BEncAsnBoolContent} and {\C BDecAsnBoolContent} routine only -encode/decode the content of the given BOOLEAN value. - -The {\C FreeAsnBool} routine does nothing since the BOOLEAN type -does not contain pointers to data; the free routine generator does not -have to check which types need freeing and simply calls the type's -free routine. It also allows the user to modify the types and their -free routines without changing the free routine generator. However, -the ANY and ANY DEFINED BY type hash table initialization routine -generator does need to know which types have empty free routines -because the hash entries contain pointers to the free functions (NULL -is used for the empty free functions like {\C FreeAsnBool}). The -INTEGER, NULL, REAL and ENUMERATED types have empty free routines for -the same reason. - -{\C BDecAsnBool} will report an error if the tag is not -UNIVERSAL-PRIM-1. {\C BDecAsnBoolContent} will report an error if it -decodes past the end of the data or the length of the encoded value -(given by the {\C len} parameter) is not exactly one octet. - -\section{\label{int-C-section}INTEGER} - -The INTEGER type is represented by a 32 bit integer type, {\C AsnInt}. -The C integer type chosen depends on the machine and compiler and may be {\C int}, {\C long} or {\C short}, whatever is 32 bits in size. -If you are using INTEGER types that are only positive (via subtyping or -protocol definition) you may want to use the {\C UAsnInt} and -associated routines that use the unsigned int for a larger positive value range. -\begin{small} -\begin{verbatim} -typedef int AsnInt; -typedef unsigned int UAsnInt; - -AsnLen BEncAsnInt (BUF_TYPE b, AsnInt *data); -void BDecAsnInt (BUF_TYPE b, AsnInt *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -AsnLen BEncAsnIntContent (BUF_TYPE b, AsnInt *data); -void BDecAsnIntContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, - AsnInt *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -#define FreeAsnInt( v) -void PrintAsnInt (FILE *f, AsnInt *v, unsigned short int indent); - -AsnLen BEncUAsnInt (BUF_TYPE b, UAsnInt *data); -void BDecUAsnInt (BUF_TYPE b, UAsnInt *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -AsnLen BEncUAsnIntContent (BUF_TYPE b, UAsnInt *data); -void BDecUAsnIntContent (BUF_TYPE b, AsnTag tagId, AsnLen len, - UAsnInt *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -#define FreeUAsnInt( v) -void PrintUAsnInt (FILE *f, UAsnInt *v, unsigned short int indent); -\end{verbatim} -\end{small} - -{\C BDecAsnInt} will report an error if the tag is not -UNIVERSAL-PRIM-2. {\C BDecAsnIntContent} will report an error if it -decodes past the end of the data or the integer value is too large for -an {\C AsnInt}. - -\section{\label{null-C-section}NULL} - -The NULL type is represented by the {\C AsnNull} type. Its content -is always empty and hence its encoded length always is zero. -\begin{small} -\begin{verbatim} -typedef char AsnNull; - -AsnLen BEncAsnNull (BUF_TYPE b, AsnNull *data); -void BDecAsnNull (BUF_TYPE b, AsnNull *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -/* 'return' length of encoded NULL value, 0 */ -#define BEncAsnNullContent(b, data) 0 -void BDecAsnNullContent (BUF_TYPE b, AsnTag tag, AsnLen len, - AsnNull *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -#define FreeAsnNull( v) -void PrintAsnNull (FILE *f, AsnNull * b, unsigned short int indent); -\end{verbatim} -\end{small} - -\section{\label{real-C-section}REAL} - -The REAL type is represented by {\C AsnReal}, a double. This type's -representation can depend on the compiler or system you are using so -several different encoding routines are provided. -Even so, you may need to modify the code. - -If you are using the REAL type in your ASN.1 modules, you should call the -{\C InitAsnInfinity()} routine to setup the {\C PLUS\_INFINITY} -and {\C MINUS\_INFINITY} values. - -There are three encode routines included and they can be selected by -defining one of {\C IEEE\_REAL\_FMT}, {\C IEEE\_REAL\_LIB} or nothing. -Defining {\C IEEE\_REAL\_FMT} uses the encode routine that assumes the -double representation is the standard IEEE double \cite{68881}. -Defining {\C IEEE\_REAL\_LIB} uses the encode routine that assumes the -IEEE functions library (isinf, scalbn, signbit etc.\ ) is available. -If neither are defined, the default encode routine uses {\C frexp}. - -There is only one content decoding routine and it builds the value -through multiplication and the {\C pow} routine (requires the math -library). The content decoding routine only supports the binary -encoding of a REAL, not the decimal encoding. - -\begin{small} -\begin{verbatim} -typedef double AsnReal; - -extern AsnReal PLUS_INFINITY; -extern AsnReal MINUS_INFINITY; - -void InitAsnInfinity(); -AsnLen BEncAsnReal (BUF_TYPE b, AsnReal *data); -void BDecAsnReal (BUF_TYPE b, AsnReal *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -AsnLen BEncAsnRealContent (BUF_TYPE b, AsnReal *data); -void BDecAsnRealContent (BUF_TYPE b, AsnTag tag, AsnLen len, - AsnReal *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -/* do nothing */ -#define FreeAsnReal( v) -void PrintAsnReal (FILE *f, AsnReal *b, unsigned short int indent); -\end{verbatim} -\end{small} - -{\C BDecAsnReal} will report an error if the value's tag is not UNIVERSAL-PRIM-9. -{\C BDecAsnRealContent} will report an error if the base is not supported or the decimal type REAL encoding is received. - - -\section{\label{bits-C-section}BIT STRING} - -The BIT STRING type is represented by the {\C AsnBits} structure. It -contains a pointer to the bits and integer that holds the length -in bits of the BIT STRING\@. - -In addition to the standard encode, decode, print and free routines, -there are some other utility routines. {\C AsnBitsEquiv} returns -TRUE if the given BIT STRINGs are identical. The {\C SetAsnBit}, -{\C ClrAsnBit} and {\C GetAsnBit} are routines for writing and -reading a BIT STRING value. - -You may notice that the AsnBits type does not have any means of -handling linked pieces of BIT STRINGs. Some ASN.1 tools use lists of -structures like {\C AsnBits} to represent BIT STRINGs. This is done -because, as you should be aware, BIT STRINGs can be encoded in a -nested, constructed fashion. The snacc BIT STRING decoder attempts to -save you the hassle of dealing with fragments of BIT STRINGs by -concatenating them in the decoding step. Every BIT STRING value -returned by the decoder will have contiguous bits. - -Some people contend that fragmented BIT STRINGs are necessary to -support systems that lack enough memory to hold the entire value. -Snacc encodes value ``backwards'' so the entire value must be encoded -before it can be sent, thus you must have enough memory to hold the -whole encoded value. If the fragmented representation is useful to -your protocol implementation for other reasons, it should be fairly -simple to modify the BIT STRING routines. Remember, no significance -should be placed on where constructed BIT STRING values are fragmented. - -Snacc uses a table to hold pointers to the BIT STRING fragments in the -buffer while it is decoding them. Once the whole BIT STRING value has -been decoded, a block of memory that is large enough to hold the -entire BIT STRING is allocated and the fragments are copied into it. -The table initially can hold pointers to 128 fragments. If more table -entries are needed the stack will grow via {\C realloc} (with -associated performance loss) and will not shrink after growing. If -you wish to modify this behaviour, change the -{\ufn \dots/c-lib/inc/str-stk.h} file. - -The {\C FreeAsnBits} routine will free memory referenced by the -{\C bits} pointer. - -\begin{small} -\begin{verbatim} -typedef struct AsnBits -{ - int bitLen; - char *bits; -} AsnBits; - -extern char numToHexCharTblG[]; -#define TO_HEX( fourBits) (numToHexCharTblG[(fourBits) & 0x0f]) -#define ASNBITS_PRESENT( abits) ((abits)->bits != NULL) - -AsnLen BEncAsnBits (BUF_TYPE b, AsnBits *data); -void BDecAsnBits (BUF_TYPE b, AsnBits *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -AsnLen BEncAsnBitsContent (BUF_TYPE b, AsnBits *bits); -void BDecAsnBitsContent (BUF_TYPE b, AsnLen len, AsnTag tagId, - AsnBits *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -void FreeAsnBits (AsnBits *v); -void PrintAsnBits (FILE *f, AsnBits *b, unsigned short int indent); - -int AsnBitsEquiv (AsnBits *b1, AsnBits *b2); -void SetAsnBit (AsnBits *b1, unsigned long int bit); -void ClrAsnBit (AsnBits *b1, unsigned long int bit); -int GetAsnBit (AsnBits *b1, unsigned long int bit); -\end{verbatim} -\end{small} - -{\C BDecAsnBits} will report an error if the tag is not UNIVERSAL-CONS-3 or UNIVERSAL-PRIM-3. -When decoding constructed BIT STRING BER values, an error will be reported if a component other than the last one has non-zero unused bits in its last octet or an internal component does not have the UNIVERSAL-3 tag. -If the decoder attempts to read past the end of the data an error will be reported. - - -\section{\label{octets-C-section}OCTET STRING} -The OCTET STRING type is represented by the {\C AsnOcts} structure. -It contains a pointer to the octets and an integer that holds the length in octets of the OCTET STRING\@. - -As with BIT STRINGs, OCTET STRINGs can have constructed values. These -are handled in the same way as the constructed BIT STRING values. The -decoded representation of an OCTET STRING is always contiguous. - -The {\C FreeAsnOcts} routine will free the memory referenced by the -{\C octs} pointer. The {\C AsnOctsEquiv} routine will return TRUE -if the given OCTET STRINGs are identical. - -\begin{small} -\begin{verbatim} -typedef struct AsnOcts -{ - unsigned long int octetLen; - char *octs; -} AsnOcts; - -#define ASNOCTS_PRESENT( aocts) ((aocts)->octs != NULL) - -AsnLen BEncAsnOcts (BUF_TYPE b, AsnOcts *data); - -void BDecAsnOcts (BUF_TYPE b, AsnOcts *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -AsnLen BEncAsnOctsContent (BUF_TYPE b, AsnOcts *octs); -void BDecAsnOctsContent (BUF_TYPE b, AsnLen len, AsnTag tagId, - AsnOcts *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -void FreeAsnOcts (AsnOcts *o); -void PrintAsnOcts (FILE *f, AsnOcts *o, unsigned short int indent); - -int AsnOctsEquiv (AsnOcts *o1, AsnOcts *o2); -\end{verbatim} -\end{small} - -{\C BDecAsnOcts} will report an error if the tag is not -UNIVERSAL-CONS-4 or UNIVERSAL-PRIM-4. When decoding constructed OCTET -STRING BER values, an error will be reported if an internal component -does not have the UNIVERSAL-4 tag. If the decoder attempts to read -past the end of the data an error will be reported. - - -\section{\label{oid-C-section}OBJECT IDENTIFIER} - -In snacc, OBJECT IDENTIFIERs are kept in their encoded form to improve -performance. The {\C AsnOid} type is defined as {\C AsnOcts}, as -it holds the octets of the encoded OBJECT IDENTIFIER\@. It seems that -the most common operation with OBJECT IDENTIFIERs is to compare for -equality, for which the encoded representation (which is canonical) -works well. - -There is a linked OBJECT IDENTIFIER representation called {\C OID} -and routines to convert it to and from the {\C AsnOid} format, but it -should not be used if performance is an issue. - -Since the OBJECT IDENTIFIERs are represented {\C AsnOcts}, the -{\C AsnOcts} content encoding routine can be used for the -{\C AsnOid} content encoding routine. The other {\C AsnOcts} -encoding and decoding routines cannot be used because the OBJECT -IDENTIFIER has a different tag and cannot be encoded in a constructed -fashion. - -An OBJECT IDENTIFIER must have a minimum of two arc numbers but the -decoding routines do not check this. - -\begin{small} -\begin{verbatim} -typedef AsnOcts AsnOid; - -#define ASNOID_PRESENT( aoid) ASNOCTS_PRESENT (aoid) - -AsnLen BEncAsnOid (BUF_TYPE b, AsnOid *data); -void BDecAsnOid (BUF_TYPE b, AsnOid *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -#define BEncAsnOidContent(b, oid) BEncAsnOctsContent(b, oid) -void BDecAsnOidContent (BUF_TYPE b, AsnTag tag, AsnLen len, - AsnOid *result, AsnLen *bytesDecoded, - ENV_TYPE env); - -#define FreeAsnOid FreeAsnOcts -void PrintAsnOid (FILE *f, AsnOid *b, unsigned short int indent); - -#define AsnOidsEquiv( o1, o2) AsnOctsEquiv (o1, o2) -\end{verbatim} -\end{small} - - -\section{\label{list-C-section}SET OF and SEQUENCE OF} - -The SET OF and SEQUENCE OF type are represented by the {\C AsnList} -structure. An {\C AsnList} consists of a head object that has -pointers to the first, current and last nodes and the current number -of nodes in the list. Each list node has a pointer to its next and -previous list member and the node's data. The first list node's -previous pointer is always NULL and the last list node's next pointer -is always NULL\@. - -Each SET OF or SEQUENCE OF type is defined as an {\C AsnList}, so the -element type information (kept via a {\C void~*}) is not kept, -therefore, the {\C AsnList} type is not type safe. - -The {\C AsnList} is a doubly linked list to simplify ``backwards'' -encoding. The reverse link allows the list to be traversed in reverse -so the components can be encoded from last to first. - -Initially, the lists were designed to allow the list element itself to -be contained in the list node (hence the {\C elmtSize} parameter to -the AsnListNew() routine). The design eventually changed such that -every list element was reference by pointer from the list node. - -A small problem with the {\C AsnListNew} routine is the memory -allocation. Since it is used by the decoding routines to allocate new -lists, it uses whatever memory management you have setup with the -{\C Asn1Alloc} macro (see Section~\ref{lib-mem-C-section}). This may not be -desirable when building values to be transmitted. You may need to -provide another AsnListNew routine that uses a different allocation -scheme to solve this. - -\begin{small} -\begin{verbatim} -typedef struct AsnListNode -{ - struct AsnListNode *prev; - struct AsnListNode *next; - void *data; /* this must be the last field of this structure */ -} AsnListNode; - -typedef struct AsnList -{ - AsnListNode *first; - AsnListNode *last; - AsnListNode *curr; - int count; /* number of elements in list */ - int dataSize; /* space required in each node for the data */ -} AsnList; - -#define FOR_EACH_LIST_ELMT( elmt, list) ... -#define FOR_EACH_LIST_ELMT_RVS( elmt, list) ... -#define FOR_REST_LIST_ELMT( elmt, al) ... - -#define CURR_LIST_ELMT( al) (al)->curr->data -#define NEXT_LIST_ELMT( al) (al)->curr->next->data -#define PREV_LIST_ELMT( al) (al)->curr->prev->data -#define LAST_LIST_ELMT( al) (al)->last->data -#define FIRST_LIST_ELMT( al) (al)->first->data -#define LIST_EMPTY(al) (( al)->count == 0) - -#define CURR_LIST_NODE( al) ((al)->curr) -#define FIRST_LIST_NODE( al) ((al)->first) -#define LAST_LIST_NODE( al) ((al)->last) -#define PREV_LIST_NODE( al) ((al)->curr->prev) -#define NEXT_LIST_NODE( al) ((al)->curr->next) -#define SET_CURR_LIST_NODE( al, listNode) ((al)->curr = (listNode)) - -void AsnListRemove (AsnList *l); -void *AsnListAdd (AsnList *l); -void *AsnListInsert (AsnList *list); -void AsnListInit (AsnList *list, int dataSize); -AsnList *AsnListNew (int elmtSize); -void *AsnListPrev (AsnList *); -void *AsnListNext (AsnList *); -void *AsnListLast (AsnList *); -void *AsnListFirst (AsnList *); -void *AsnListPrepend (AsnList *); -void *AsnListAppend (AsnList *); -void *AsnListCurr (AsnList *); -int AsnListCount (AsnList *); -AsnList *AsnListConcat (AsnList *, AsnList *); -\end{verbatim} -\end{small} - -There are a number of macros for dealing with the list type, the -most important being the list traversal macros. The -{\C FOR\_EACH\_LIST\_ELMT} macro acts like a ``for'' statment that -traverses forward through the list. The first parameter should be a -pointer to the list element type that will be used to hold the current list -element for each iteration of the ``for'' loop. The second parameter is -the list of elements that you wish to traverse. - -The {\C FOR\_EACH\_LIST\_ELMT\_RVS} macro is identical to the -{\C FOR\_EACH\_LIST\_ELMT} macro except that is moves from the back of -the list to the front. The {\C FOR\_REST\_LIST\_ELMT} macro is -similar to the other two but it does not reset the {\C curr} pointer -in the {\C AsnList} type. This has the effect of iterating from the -current element to the end of the list. Look in the generated code -for a better indication of how to use these macros. The other macros -are straight forward. - - -\section{\label{any-C-section}ANY and ANY DEFINED BY} - - -The ANY and ANY DEFINED BY type are classically the most irritating -ASN.1 types for compiler writers. They rely on mechanisms outside of -ASN.1 to specify what types they contain. The 1992 ASN.1 standard has -rectified this by adding much stronger typing semantics and eliminating -macros. - -The ANY DEFINED BY type can be handled automatically by {\em snacc} if -the SNMP OBJECT-TYPE \cite{snmp} macro is used to specify the -identifier value to type mappings. The identifier can be an INTEGER -or OBJECT IDENTIFIER\@. Handling ANY types properly will require -modifications to the generated code since there is no identifier -associated with the type. - -The general approach used by {\em snacc} to handle ANY DEFINED BY -types is to lookup the identifier value in a hash table for the -identified type. The hash table entry contains information about the -type such as the routines to use for encoding and decoding. - -Two hash tables are used, one for INTEGER to type mappings and the -other for OBJECT IDENTIFIER to type mappings. {\em Snacc} generates -an {\tt InitAny} routine for each module that uses the OBJECT-TYPE -macro. This routine adds entries to the hash table(s). The {\tt -InitAny} routine(s) is called once before any encoding or decoding is -done. - - -The hash tables are constructed such that an INTEGER or OBJECT -IDENTIFIER value will hash to an entry that contains: -\begin{itemize} -\item {the {\tt anyId}} -\item {the INTEGER or OBJECT IDENTIFIER that maps to it} -\item {the size in bytes of the identified data type} -\item {a pointer to the type's PDU encode routine} -\item {a pointer to the type's PDU decode routine} -\item {a pointer to the type's print routine} -\item {a pointer to the type's free routine} -\end{itemize} -The referenced encode and decode routines are PDU oriented in that -they encode the type's tag(s) and length(s) as well as the type's -content. - -{\em Snacc} builds an {\tt enum} called {\tt AnyId} that enumerates -each mapping defined by the OBJECT-TYPE macros. The name of the value -associated with each macro is used as part of the enumerated -identifier. The {\tt anyId} in the hash table holds the identified -type's {\tt AnyId enum} value. The {\tt anyId} is handy for making -decisions based on the received identifier, without comparing OBJECT -IDENTIFIERs. If the identifiers are INTEGERs then the {\tt anyId} is -less useful. - -With ANY DEFINED BY types, it is important to have the identifier -decoded before the ANY DEFINED BY type is decoded. Hence, an ANY -DEFINED BY type should not be declared before its identifier in a SET -since SETs are un-ordered. An ANY DEFINED BY type should not be -declared after its identifier in a SEQUENCE\@. {\em Snacc} will print a -warning if either of these situations occur. - -The hash tables may be useful to plain ANY types which do not have an -identifier field like the ANY DEFINED BY types; the OBJECT-TYPE macro -can be used to define the mappings and the {\tt SetAnyTypeByInt} or -{\tt SetAnyTypeByOid} routine can be called with the appropriate -identifier value before encoding or decoding an ANY value. The -compiler will insert calls to these routines where necessary with some -of the arguments left as ``???''. There will usually be a ``{\tt /* -ANY -- Fix me! */}'' comment before code that needs to be modified to -correctly handle the ANY type. The code generated from an ASN.1 -module that uses the ANY type will not compile without modifications. - -OPTIONAL ANYs and ANY DEFINED BY types that have not been tagged are a -special problem for {\em snacc}. Unless they are the last element of a SET -or SEQUENCE, the generated code will need to be modified. {\em Snacc} will -print a warning message when it encounters one of these cases. - -To illustrate how ANY DEFINED BY values are handled, we present -typical encoding and decoding scenarios. Each ANY or ANY DEFINED BY -type is represented in C by the {\tt AsnAny} type which contains only -a {\tt void *} named {\tt value} to hold a pointer to the value and a -{\tt AnyInfo *} named {\tt ai} which points to a hash table entry. - -When encoding, before the ANY DEFINED BY value is encoded, {\tt -SetAnyTypeByOid} or {\tt SetAnyTypeByInt} (depending on the type of -the identifier) is called with the current identifier value to set the -{\tt AsnAny} value's {\tt ai} pointer to the proper hash table entry. -Then to encode the ANY DEFINED BY value, the encode routine pointed to -from the hash table entry is called with the {\tt value} {\tt void *} -from the {\tt AsnAny} value. The {\tt value} {\tt void *} in the {\tt -AsnAny} should point to a value of the correct type for the given -identifier, if the user set it up correctly. Note that setting the -{\tt void *} value is not type safe; one must make sure that the -value's type is the same as indicated by the identifier. - -For decoding, the identifier must be decoded prior to the ANY DEFINED -BY value otherwise the identifier will contain an uninitialized value. -Before the ANY or ANY DEFINED BY value is decoded, {\tt -SetAnyTypeByOid} or {\tt SetAnyTypeByInt} (depending on the type of -the identifier) is called to set the {\tt AsnAny} value's {\tt ai} -pointer to the proper hash table entry. Then a block of memory of the -size indicated in the hash table entry is allocated, and its pointer -stored in the {\tt AsnAny} value's {\tt void *} entry. Then the decode -routine pointed to from the hash table entry is called with the newly -allocated block as its value pointer parameter. The decode routine -fills in the value assuming it is of the correct type. Simple! - -There is a problem with {\em snacc}'s method for handling ANY DEFINED -BY types for specifications that have two or more ANY DEFINED BY types -that share some identifier values. Since only two hash tables are -used and they are referenced using the identifier value as a key, -duplicate identifiers will cause unresolvable hash collisions. - -Here is some of the {\C AsnAny} related code from the header file. It -should help you understand the way things are done a bit better. Look -in the {\ufn hash.c} and {\ufn hash.h} files as well. -\begin{small} -\begin{verbatim} -/* - * 1 hash table for integer keys - * 1 hash table for oid keys - */ -extern Table *anyOidHashTblG; -extern Table *anyIntHashTblG; - -typedef (*EncodeFcn) (BUF_TYPE b, void *value); -typedef void (*DecodeFcn) (BUF_TYPE b, void *value, - AsnLen *bytesDecoded, ENV_TYPE env); -typedef void (*FreeFcn) (void *v); -typedef void (*PrintFcn) (FILE *f, void *v); - -/* - * this is put into the hash table with the - * int or oid as the key - */ -typedef struct AnyInfo -{ - int anyId; /* will be a value from the AnyId enum */ - AsnOid oid; /* will be zero len/null if intId is valid */ - AsnInt intId; - unsigned int size; /* size of the C data type (ie as ret'd by sizeof) */ - EncodeFcn Encode; - DecodeFcn Decode; - FreeFcn Free; - PrintFcn Print; -} AnyInfo; - -typedef struct AsnAny -{ - AnyInfo *ai; /* point to entry in hash tbl that has routine ptrs */ - void *value; /* points to the value */ -} AsnAny; - -/* - * Returns anyId value for the given ANY type. - * Use this to determine to the type of an ANY after decoding - * it. Returns -1 if the ANY info is not available - */ -#define GetAsnAnyId( a) (((a)->ai)? (a)->ai->anyId: -1) - -/* - * used before encoding or decoding a type so the proper - * encode or decode routine is used. - */ -void SetAnyTypeByInt (AsnAny *v, AsnInt id); -void SetAnyTypeByOid (AsnAny *v, AsnOid *id); - - -/* - * used to initialize the hash table(s) - */ -void InstallAnyByInt (int anyId, AsnInt intId, - unsigned int size, EncodeFcn encode, - DecodeFcn decode, FreeFcn free, PrintFcn print); - -void InstallAnyByOid (int anyId, AsnOid *oid, unsigned int size, - EncodeFcn encode, DecodeFcn decode, FreeFcn free, - PrintFcn print); - -/* - * Standard enc, dec, free, & print routines. - * for the AsnAny type. - * These call the routines referenced from the - * given value's hash table entry. - */ -void FreeAsnAny (AsnAny *v); -AsnLen BEncAsnAny (BUF_TYPE b, AsnAny *v); -void BerDecAsnAny (BUF_TYPE b, AsnAny *result, AsnLen *bytesDecoded, - ENV_TYPE env); -void PrintAsnAny (FILE *f, AsnAny *v, unsigned short indent); - - -/* AnyDefinedBy is the same as AsnAny */ -typedef AsnAny AsnAnyDefinedBy; -#define FreeAsnAnyDefinedBy FreeAsnAny -#define BEncAsnAnyDefinedBy BEncAsnAny -#define BDecAsnAnyDefinedBy BDecAsnAny -#define PrintAsnAnyDefinedBy PrintAsnAny -\end{verbatim} -\end{small} - - -\section{\label{lib-buf-section}Buffer Management} - -Encoding and decoding performance is heavily affected by the cost of -writing to and reading from buffers, thus, efficient buffer management -is necessary. Flexibility is also important to allow integration of -the generated encoders and decoders into existing environments. To -provide both of these features, the calls to the buffer routines are -actually macros that can be configured as you want (see -{\ufn \dots/c-lib/inc/asn-config.h}). Virtually all buffer calls will -be made from the encode/decode library routines. So macros used in -the generated code will make buffer calls. - -If your environment uses a single, simple buffer type, the buffer -routine macros can be defined as the macros for your simple buffer type. -This results in the buffer type being bound at compile time, with no -function call overhead from the encode or decode routines. This also -means that the runtime library only works for that buffer type. - -If multiple buffer formats must be supported at runtime, the buffer -macros can be defined like the ISODE buffer calls, where a buffer type -contains pointers to the buffer routines and data of the current -buffer type. This approach will hurt performance since each buffer -operation will be an indirect function call. I have implemented -buffers like this for the table tools (performace is already hosed so -slower buffer routines are a drop in the bucket). See the type tables -section for their description. - -The backwards encoding technique requires special buffer primitives -that write from the end of the buffer towards the front. This -requirement will make it impossible to define buffer primitives that -write directly to stream oriented objects such as TCP connections. In -cases such as this, you must encode the entire PDU before sending it. -(Or else extend the back-end of the compiler to produce ``forwards'' -encoders as well). - -Nine buffer primitives are required by the runtime library's encode -and decode routines: -\begin{itemize} -\item {\C unsigned char BufGetByte (BUF\_TYPE b);} -\item {\C unsigned char BufPeekByte (BUF\_TYPE b);} -\item {\C char *BufGetSeg (BUF\_TYPE b, unsigned long int *lenPtr);} -\item {\C void BufCopy (char *dst, BUF\_TYPE b, unsigned long int *lenPtr);} -\item {\C void BufSkip (BUF\_TYPE b, unsigned long int len);} -\item {\C void BufPutByteRv (BUF\_TYPE b, unsigned char byte);} -\item {\C void BufPutSegRv (BUF\_TYPE b, char *data, unsigned long int len);} -\item {\C int BufReadError (BUF\_TYPE b);} -\item {\C int BufWriteError (BUF\_TYPE b);} -\end{itemize} - -These buffer operations are described in the next subsections. The -{\C ExpBuf}, {\C SBuf} and {\C MinBuf} buffer formats that come -with the Snacc distribution and how to configure the buffer operations -are discussed following that. - -\subsection{\label{buf-read-c-section}Buffer Reading Routine Semantics} - -The buffer reading routines are called by the decoder routines. The -following is the list of necessary buffer reading routines and their -semantics. Be sure to setup the buffer in reading mode before -calling any of these routines. The means of putting a buffer in -reading mode depends on the buffer type. - -\begin{verbatim} -unsigned char BufGetByte (BUF_TYPE b); -\end{verbatim} -Returns the next byte from the buffer and advances the current pointer -such that a subsequent buffer read returns the following byte(s). -This will set the read error flag if an attempt to read past the end -of the data is made. - -\begin{verbatim} -unsigned char BufPeekByte (BUF_TYPE b); -\end{verbatim} -Returns the next byte from the buffer without advancing the current -pointer. - -\begin{verbatim} -char *BufGetSeg (BUF_TYPE b, unsigned long int *lenPtr); -\end{verbatim} -Returns a pointer to the next bytes from the buffer and advances the -current pointer. {\C *lenPtr} should contain the number of bytes to -read. If the buffer has a least {\C *lenPtr} contiguous bytes -remaining to be read before calling {\C BufGetSeg}, a pointer to -them will be returned and {\C *lenPtr} will be unchanged. If there -are less than {\C *lenPtr} contiguous bytes remaining in the buffer -before the call to {\C BufGetSeg}, a pointer to them is returned and -{\C *lenPtr} is set to the actual number of bytes that are -referenced by the returned pointer. The current pointer will be -advanced by the value returned in {\C *lenPtr} (this may advance to the -next buffer segment if any). Note that the read error flag is not set -if {\C *lenPtr} is greater than the remaining number of unread -bytes. - -\begin{verbatim} -unsigned long int BufCopy (char *dst, BUF_TYPE b, unsigned long int len) -\end{verbatim} -Copies the next {\C len} bytes from the buffer into the {\C dst char~*} -and advances the current pointer appropriately. Returns the -number of bytes actually copied. The number of bytes copied will be -less than requested only if the end of data is reached, in which case -the read error flag is set. - - -\begin{verbatim} -void BufSkip (BUF_TYPE b, unsigned long int len); -\end{verbatim} -Advances the buffer's current pointer by {\C len} bytes. This will set the -read error flag if less than {\C len} unread bytes remain in the -buffer before the call to {\C BufSkip}. - -\begin{verbatim} -int BufReadError (BUF_TYPE b); -\end{verbatim} -Returns non-zero if a read error occurred for the given buffer. -Read errors occur if one of the buffer reading routines attempted to -read past the end of the buffer's data. - -\subsection{\label{buf-write-c-section}Buffer Writing Routine Semantics} - -Encoding routines call the buffer writing routines. Here is a list of -the buffer writing routine and their semantics. Before calling the -writing routines, you should make sure the buffer is setup for -writing in reverse mode. The means of doing this depends on the -buffer type. - -\begin{verbatim} -void BufPutByteRvs (BUF_TYPE b, unsigned char byte); -\end{verbatim} -Writes the given byte to the beginning of the data in the given -buffer. The newly written byte becomes part of the buffer's data such -that subsequent writes place bytes before the newly written byte. If -a buffer write error occurs, subsequent writes do nothing. - -\begin{verbatim} -void BufPutSegRvs (BUF_TYPE b, char *data, unsigned long int len); -\end{verbatim} -Prepends the given bytes, {\C data}, of length {\C len} to the -beginning of the data in the given buffer {\C b}. The {\C data} -bytes are written such that the first byte in {\C data} becomes the -first byte of the buffer's data, followed by the rest. (This means the -bytes in {\C data} are not reversed, they are simply prepended as a -unit to the buffer's original data). If a buffer write error occurs, -subsequent writes do nothing. - -\begin{verbatim} -int BufWriteError (BUF_TYPE b); -\end{verbatim} -Returns non-zero if a write error occurred for the given buffer. -Write errors occur if the buffer runs out of space for data or cannot -allocate another data block (depends on the buffer type). - -\subsection{Buffer Configuration} - -The runtime library's encode and decode routines as well as the -generated code access the buffers via the nine buffer macros -described in the last two sections. These macros can be defined to -call simple macros for speed or to call functions. Note that the -buffer configuration is bound at the time the library and generated -code are compiled. - -The following is from {\ufn \dots/include/asn-config.h} and shows how to -configure the buffer routines. This setup will make all calls to -{\C BufGetByte} in the library and generated code call your -{\C ExpBufGetByte} routine; the other buffer routines are mapped to -their {\C ExpBuf} equivalents in a similar way. - -\begin{verbatim} -#include "exp-buf.h" -#define BUF_TYPE ExpBuf ** -#define BufGetByte( b) ExpBufGetByte (b) -#define BufGetSeg( b, lenPtr) ExpBufGetSeg (b, lenPtr) -#define BufCopy( dst, b, lenPtr) ExpBufCopy (dst, b, lenPtr) -#define BufSkip( b, len) ExpBufSkip (b, len) -#define BufPeekByte( b) ExpBufPeekByte (b) -#define BufPutByteRv( b, byte) ExpBufPutByteRv (b, byte) -#define BufPutSegRv( b, data, len) ExpBufPutSegRv (b, data, len) -#define BufReadError( b) ExpBufReadError (b) -#define BufWriteError( b) ExpBufWriteError (b) -\end{verbatim} - -If you want to use your own buffer type, simply edit the -{\ufn asn-config.h} file such that it includes your buffer's header -file, sets the {\C BUF\_TYPE} type, and defines the nine buffer -routines ({\C BufGetByte} etc.) to call your buffer routines. Your -buffer routines should have the semantics and prototypes described in -the last two sections (Sections \ref{buf-read-c-section} and~\ref{buf-write-c-section}). - -\subsection{ExpBuf Buffers} - -The {\C ExpBuf} buffers are a doubly linked series of buffers that -can be expanded when encoding by adding new buffers as necessary. -Each {\C ExpBuf} consists of two blocks of memory, one for the -control and linking information and the other for the data; when -refering to an {\C ExpBuf} both parts are included. {\C ExpBuf} is -short for ``Expanding Buffer''. Look in {\ufn \dots/c-lib/exp-buf.c} -for an ASCII drawing of the {\C ExpBuf} buffers. Take a look a the -{\ufn \dots/c-examples/simple/expbuf-ex.c} file for a quick -introduction on how to use {\C ExpBufs}. - -{\C ExpBufs} are fairly general and useful when a reasonable upper -bound can not be put on the size of the encoded values that will be -encountered by the protocol. The flexibility of these buffer routines -will hurt the performance as many of the {\C ExpBuf} calls are not -macros and new buffers may need to be allocated during encoding. - -For encoding you need to write into the {\C ExpBufs}. Start with a -single ExpBuf (or the last one in a list of ExpBufs from a previous -encoding). Make sure this ExpBuf has been reset is ``Write Reverse'' -mode (use {\C ExpBufResetInWriteRvsMode}). This clears the write -error flag (and sets the read error flag in case you try a read) and -resets the data start and data end pointers such that the buffer is -empty and ready for writing from the end towards the front. - -During encoding, if an {\C ExpBuf}'s data part fills up, a new -{\C ExpBuf} before (since writing is reversed) the current buffer is -needed. If the {\C prev} pointer in the current buffer is non-NULL, -the previous buffer is reset for writing and becomes the current -buffer. If the {\C prev} pointer in the current buffer si NULL, a new -buffer is allocated, its pointer is placed in {\C prev} and it -becomes the current buffer. The notion of current buffer is handled -by the parameter to the encoding and decoding routines. The buffer -parameter is an {\C ExpBuf~**} and it always holds the current -{\C ExpBuf~*} (current buffer). - -When encoding is finished and the encoded value has been transmitted, -you have two options. You can free the entire buffer list or you can -keep them around and re-use them for the next encoding. Freeing the -buffers after each encoding may be quite slow. If you re-use the -buffers, the buffer list will grow to the size of the largest encoding -and stay there. You can easily implement other management schemes. -By default the {\C ExpBuf}s (both parts) are allocated and freed with -{\C malloc} and {\C free}; you may want to change this to fit your -environment better. If buffer allocation fails during a write, the -writeError flag will be set and subsequent writes will do nothing. - -For decoding you will want to put the encoded data into the -{\C ExpBuf} format. For example, if your encoded value is -contiguous in a single block of memory, you could use -{\C ExpBufInstallDataInBuf} to attach your data to a single ExpBuf. -Once your data is in the ExpBuf format, you should call -{\C ExpBufResetInReadMode} on the first buffer in the list (if more -than one). Then you can pass it to the desired decode routine. - -If a decode routine attempts to read past the end of a buffer (usually -due to an erroneous encoding), the readError flag will be set for the -current {\C ExpBuf} in the list. This error will typically cause -the decoding routine that called the buffer read routine to call -{\C longjmp}. - -The {\C BUF\_TYPE} is defined as {\C ExpBuf~**} so that the buffer -parameter {\C b} can be set to the next active {\C ExpBuf} by the -buffer routines. This saves having a head of the list type structure -that keeps track of the first, last and current buffers (the -indirectness of this approach would hurt performance). - -There are many routines for administrating the {\C ExpBufs} if you -want to treat them like an abstract data type. Sometimes it may be -easier to skip the utility routines and modify the fields directly. - -The following routines are the required nine buffer routines. Compile -the library and the generated code with the {\C USE\_EXP\_BUF} symbol -defined to map buffer routines that the generated and library code -calls to the {\C ExpBuf} routines (see -{\ufn \dots/c-lib/inc/asn-config.h}). These {\C ExpBuf} routines -adhere to the buffer routine prototypes and semantics defined in -Sections \ref{buf-read-c-section} and~\ref{buf-write-c-section}. - -\begin{verbatim} -void ExpBufSkip (ExpBuf **, unsigned long len); -int ExpBufCopy (char *dst, ExpBuf **b, unsigned long len); -unsigned char ExpBufPeekByte (ExpBuf **b); -char *ExpBufGetSeg (ExpBuf **b, unsigned long *len); -void ExpBufPutSegRvs (ExpBuf **b, char *data, unsigned long len); -unsigned char ExpBufGetByte (ExpBuf **b); -void ExpBufPutByteRvs (ExpBuf **b, unsigned char byte); - -#define ExpBufReadError( b) ((*b)->readError) -#define ExpBufWriteError( b) ((*b)->writeError) -\end{verbatim} - - -The following {\C ExpBuf} routines are also provided. Their -descriptions can be found in the code. -\begin{verbatim} -void ExpBufInit (unsigned long dataBlkSize); -void ExpBufInstallDataInBuf (ExpBuf *b, char *data, unsigned long int len); - -void ExpBufResetInReadMode (ExpBuf *b); -void ExpBufResetInWriteRvsMode (ExpBuf *b); - -ExpBuf *ExpBufAllocBufAndData(); -void ExpBufFreeBufAndData (ExpBuf *b); -void ExpBufFreeBufAndDataList (ExpBuf *b); - -ExpBuf *ExpBufNext (ExpBuf *b); -ExpBuf *ExpBufPrev (ExpBuf *b); -ExpBuf *ExpBufListLastBuf (ExpBuf *b); -ExpBuf *ExpBufListFirstBuf (ExpBuf *b); - -int ExpBufAtEod (ExpBuf *b); -int ExpBufFull (ExpBuf *b); -int ExpBufHasNoData (ExpBuf *b); - -char *ExpBufDataPtr (ExpBuf *b); -unsigned long ExpBufDataSize (ExpBuf *b); -unsigned long ExpBufDataBlkSize (ExpBuf *b); -\end{verbatim} - -\subsection{SBuf Buffers} - -The {\C SBuf}s are simple buffers of a fixed size, much like an -{\C ExpBuf} that cannot expand. If you attempt to write -past the end of the buffer, the writeError flag will be set and the -encoding will fail. If you attempt to read past the end of a buffer -the readError flag will be set and the decoding will fail. - -The {\C SBuf}s are useful if you can put a reasonable upper bound on -the size of the encodings you will be dealing with. The buffer -operations are much simpler because the data is contiguous. In fact, -all of the {\C SBuf} buffer operations are implemented by macros. - -Look in {\ufn \dots/c-examples/simple/sbuf-ex.c} for a quick -introduction to using {\C SBuf}s in your code. The following -operations are defined for the {\C SBuf} buffers. -\begin{verbatim} -/* The nine required buffer operations */ -#define SBufSkip(b, skipLen) ... -#define SBufCopy(dst, b, copyLen) ... -#define SBufPeekByte(b) ... -#define SBufGetSeg( b, lenPtr) ... -#define SBufPutSegRvs(b, seg, segLen) ... -#define SBufGetByte(b) ... -#define SBufPutByteRvs(b, byte) ... -#define SBufReadError(b) ... -#define SBufWriteError(b) ... - -/* other useful buffer operations */ -#define SBufInit(b, data, dataLen) ... -#define SBufResetInReadMode(b) ... -#define SBufResetInWriteRvsMode(b) ... -#define SBufInstallData(b, data, dataLen) ... -#define SBufDataLen(b) ... -#define SBufDataPtr(b) ... -#define SBufBlkLen(b) ... -#define SBufBlkPtr(b) ... -#define SBufEod(b) ... -\end{verbatim} - -Snacc is configured to use {\C SBuf}s by default. The symbols that -will affect the buffer configuration during compilation of the -libraries and generated code are {\C USE\_EXP\_BUF} and -{\C USE\_MIN\_BUF}. - -\subsection{MinBuf Buffers} - -The {\C MinBuf}s provide maximum performance but should only be used under -restricted conditions (to avoid segmentation faults etc.). No checks are -made to determine whether a decoder is reading past the end of the -buffer or if an encoder is writing ``past'' the beginning of the data -block (remember, snacc encoders write backwards). - -A {\C MinBuf} is just a {\C char~**}; the referenced {\C char~*} points -to the next byte to be read or the last byte that was written. The -read routine advances the {\C char~*} and the write reverse routines -move the {\C char~*} backwards. - -When you start encoding, the {\C MinBuf} {\C char~**} should be a -pointer to a pointer to the byte AFTER the last valid byte in your -buffer. For example the following C fragment would work: -\begin{verbatim} -PersonnelRecord pr; -char blk[128]; -char *minBuf; - -minBuf = blk + 128; /* start writing a end of block */ -BEncPersonnelRecord (&minBuf, pr); -\end{verbatim} - -The {\C MinBuf}s should only be used during encoding if the size of -the {\C MinBuf}'s buffer is guaranteed to be large enough to hold -the encoded value. Otherwise, the encoder will blindly continue -writing into whatever lies after the {\C MinBuf}'s buffer. - -When you start decoding, the {\C MinBuf} value should be a pointer -to a pointer to the first byte of the BER value to be decoded. Look -in {\ufn \dots/c-examples/simple/minbuf-ex.c} for a real example. - -The {\C MinBuf}s should only be used for decoding when the value -being decoded is certain to contain no encoding errors. Otherwise, for -encodings that are incomplete or contain length errors, the decoder may -attempt to read the memory that follows the {\C MinBuf}s. If you are -lucky, the decoder will return an error with the {\C longjmp} -mechanism. If your system has memory protection and you are unlucky -this may abort your program. If you are really unlucky, the data -following the {\C MinBuf} may fool the decoder into thinking that it -is valid and you receive a wrong PDU with no error indication. This -risky technique has been used successfully in some systems where the -encodings are not guaranteed to be correct. - -To configure the generated code to use the {\C MinBuf}s, compile it -with the {\C USE\_MIN\_BUF} symbol defined. - -\subsection{Hybrid Buffer Solutions} - -The decoding routines only call the buffer reading routines and the -encoding routines only call the buffer writing routines. You may wish -to choose a different buffer format for the encoding and decoding to -gain performance. For instance, if you can be sure that the size of -outgoing encodings is less than a certain upper bound, but don't want -to risk segmentation faults when decoding incoming values, you could -use {\C MinBuf}s for the the buffer writing (encoding) operations -and {\C SBuf}s or {\C ExpBuf}s for the buffer reading (decoding) -operations. - -In this case you will need to massage the generated code to achieve -the desired results. - -\section{\label{lib-mem-C-section}Dynamic Memory Management} - -Like buffer management, efficient memory management is very important -for efficient decoders. As a decoder decodes a value, it allocates -memory to hold the internal representation of the value. - -The runtime librarys and the generated decode routines allocate memory -using the\linebreak {\C Asn1Alloc} routine. The runtime librarys -and the generated free routines free memory using the {\C Asn1Free} -routine. The decoding routines also use {\C CheckAsn1Alloc} to make -sure that each allocation succeeded. These memory routines are defined -in the -{\ufn asn-config.h} and have the prototypes: -\begin{verbatim} -void *Asn1Alloc (unsigned long int size); -void Asn1Free (void *ptr); -int CheckAsn1Alloc (void *ptr, ENV_TYPE env); -\end{verbatim} - -The decoders assume that {\C Asn1Alloc} returns a \emph{zeroed} block -of memory. This saves explicit initialization of OPTIONAL elements with -NULL in the generated decoders. It wouldn't be too hard to modify the -compiler to produce decoders that initialized OPTIONAL elements -explicitly. - -The generated free routines hierarchically free all a value's -memory using a depth first algorithm. If you use the Nibble Memory -scheme, you will not need the generated free routines. - -By default, snacc uses a ``Nibble Memory'' scheme to provide efficient -memory management. Nibble Memory works by allocating a large block of -memory for allocating from. When the decoded value has been -processed, you can free the entire value by calling a routine that -simply resets a few pointers. There is no need to traverse the entire -value freeing a piece at a time. The following is from -{\ufn nibble-alloc.h}. -\begin{verbatim} -void InitNibbleMem (unsigned long int initialSize, - unsigned long int incrementSize); -void *NibbleAlloc (unsigned long int size); -void ResetNibbleMem(); -void ShutdownNibbleMem(); -\end{verbatim} - -You must explicitly initialize the Nibble Memory with the -{\C InitNibbleMem} routine before using a decoder. You must specify -the initial size of the nibble block and the size that it should grow -by. If you attempt to allocate a block that is larger that the -initial nibble block or its grow size, a new block of the correct size -will be allocated. Note that the ``growth'' occurs by linking -separate blocks, not by the potentially slow alternative, -{\C realloc}. - -When you have processed the decoded value you can free it by calling -{\C ResetNibbleMem}. This resets a couple pointers and frees any -extra blocks that were allocated to handle values larger than the -initial block size. The original memory block is zeroed -using {\C memset} so that all allocations will return zeroed values. -This is necessary to support the implicit initialization of OPTIONAL -elements to NULL\@. The zeroing is done in this routine instead of -{\C NibbleAlloc} under the assumption that zeroing one large block -is more efficient than zeroing pieces of it as they are allocated. - -When you no longer need the Nibble Memory, you can release it by -using\linebreak {\C ShutDownNibbleMem}. This frees all of the -memory associated with Nibble Memory, both the control data and the -block(s) used for allocation. - -There are some problems with this memory management scheme. Currently -the Nibble Memory control information is kept track of via a global -variable that holds a pointer to the control information. This can -present a problem if separate Nibble Memory contexts are needed, for -example, one to hold one value that will be kept after decoding and -another to hold a decoded value that will soon be discarded. - -The problem of separate contexts could be solved by adding another -layer that would use identifiers for different memory contexts. This -would require you to set the context using its identifier before -calling a decoding routine and to pass the context identifier to the -{\C ResetNibbleMem} routine. - -Another problem has to do with building the values to be encoded. -There is no restriction on what allocator you use to build internal -values. However, it is convenient to use the {\C AsnListNew} -routine to allocate and initialize a list type. Unfortunately, -{\C AsnListNew} is used by the decoding routines so it uses the -{\C Asn1Alloc} routine to allocate the new list. You should be -aware of this if {\C Asn1Alloc} is not what you are using to -allocate the rest of the value. This could be fixed with a different -interface to the {\C AsnListNew} routine. - -It is possible to change the memory management system without too much -difficulty. For example if you are not too worried about performance -and want to use {\C malloc} and {\C free}, you could change the -{\ufn asn-config.h} file as follows: -\begin{verbatim} -#include "malloc.h" -#define Asn1Alloc( size) calloc (1, size) -#define Asn1Free( ptr) free (ptr) -#define CheckAsn1Alloc( ptr, env)\ - if ((ptr) == NULL)\ - longjmp (env, -27); -\end{verbatim} -If you use {\C malloc} based allocators such as {\C calloc}, you -must use the generated free routines to free your values. Note that -this example used {\C calloc} instead of {\C malloc} because -{\C calloc} {\em zeroes} each allocated block of memory, as required -by the decoders. - - -\section{\label{lib-err-C-section}Error Management} - -The decoding routines use {\C longjmp} to handle any errors they -encounter in the value being decoded. {\C longjmp} works by rolling -back the stack to where the {\C setjmp} call was made. Every decode -routine takes a {\C jmp\_buf env} parameter (initialized by the -{\C setjmp} call) that tells the {\C longjmp} routine how to -restore the processor to the correct state. {\C longjmp} makes the -error management much simpler since the decoding routines do not have -to pass back error codes or check ones from other decoding routines. - -Before a PDU can be decoded, the {\C jmp\_buf env} parameter to the -decoding routine must be initialized using the {\C setjmp} routine. -This should be done immediately and only once before calling the -decoding routine. This parameter will be passed down to any other -decoding routines called within a decoding routine. The following code -fragment from {\ufn \dots/c-examples/simple/exbuf-ex.c} shows how to -use {\C setjmp} before decoding. - -\begin{small} -\begin{verbatim} -if ((val = setjmp (env)) == 0) - BDecPersonnelRecord (&buf, &pr, &decodedLen, env); -else -{ - decodeErr = TRUE; - fprintf (stderr, "ERROR - Decode routines returned %d\n", val); -} -\end{verbatim} -\end{small} - -The code that will signal an error typically looks like: -\begin{small} -\begin{verbatim} -if (mandatoryElmtCount1 != 2) -{ - Asn1Error ("BDecChildInformationContent: ERROR - non-optional elmt missing from SET.\n"); - longjmp (env, -108); -} -\end{verbatim} -\end{small} - - -Most {\C longjmp} calls are preceded by a call to {\C Asn1Error} -which takes a single {\C char~*} string as a parameter. The library -routines and the generated code try to use meaningful messages as the -parameter. {\C Asn1Error} is defined in {\ufn \dots/c-lib/inc/asn-config.h} and -currently just prints the given string to {\C stderr}. You may wish -to make it do nothing, which may shrink the size of your binary -because all of the error strings will be gone. {\C Asn1Warning} is -similar but is not used by the library or generated code anymore. - -The encoding routines do no error checking except for buffer -overflows. Hence, they do not use the {\C longjmp} mechanism and -instead require you to check the status of the buffer after encoding -(use {\C BufWriteError()}). If you are not building your values -properly, for example having random pointers for uninitialized -OPTIONAL elements, the encode routines will fail, possibly -catastrophically. diff --git a/SecuritySNACCRuntime/doc/coding.tex b/SecuritySNACCRuntime/doc/coding.tex deleted file mode 100644 index 688be5a0..00000000 --- a/SecuritySNACCRuntime/doc/coding.tex +++ /dev/null @@ -1,105 +0,0 @@ -% file: .../doc/coding.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/coding.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: coding.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:52 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:48 rj -% first check-in -% - -\chapter{\label{coding-tricks}Coding Tricks For Readability} - -\index{ANSI C} -\index{K&R C} -\index{PROTO} -\index{PARAM} -\index{COMMA} - -One of our project partners needed some additional function arguments and so they duplicated the function declarator and put a preprocessor switch around it. -The metacode and the Tcl interface added some additional compilation conditions. -Since the Tcl interface is only useful on top of the metacode, there are six different combinations instead of eight. -Even these six combinations would have made the code very ugly. -Please decide for yourself, here is an example with an example function with only up to four arguments, {\C PrintCxxCode()} has up to 17 arguments. - -\begin{Ccode} -static void\\ -\#if A\\ -FunctionName PARAMS ((a, b),\\ - \>TypeA a \_AND\_\\ - \>TypeB b)\\ -\#if B\\ -FunctionName PARAMS ((a, b, c),\\ - \>TypeA a \_AND\_\\ - \>TypeB b \_AND\_\\ - \>TypeC c)\\ -\#if C\\ -FunctionName PARAMS ((a, b, c, d),\\ - \>TypeA a \_AND\_\\ - \>TypeB b \_AND\_\\ - \>TypeC c \_AND\_\\ - \>TypeD d)\\ -\#endif\\ -\#endif\\ -\#else\\ -FunctionName PARAMS ((b),\\ - \>TypeB b)\\ -\#if B\\ -FunctionName PARAMS ((b, c),\\ - \>TypeB b \_AND\_\\ - \>TypeC c)\\ -\#if C\\ -FunctionName PARAMS ((b, c, d),\\ - \>TypeB b \_AND\_\\ - \>TypeC c \_AND\_\\ - \>TypeD d)\\ -\#endif\\ -\#endif\\ -\#endif -\end{Ccode} - -Here is the code after introduction of my shorthand: - -\begin{Ccode} -static void\\ -FunctionName PARAMS ((if\_A (a COMMA) b if\_C (COMMA c) if\_D (COMMA d)),\\ - \>if\_A (TypeA a \_AND\_)\\ - \>TypeB b\\ - \>if\_C (\_AND\_ TypeC c)\\ - \>if\_D (\_AND\_ TypeD d)) -\end{Ccode} - -The tricks are very simple. -One is the {\C if\_\dots} macro - -\begin{Ccode} -\#if A\\ -\#define if\_A( code) \>\>\>code\\ -\#else\\ -\#define if\_A( code) -\#endif -\end{Ccode} - -that lets us get rid of at least four lines of code for every invocation, and the other trick is the {\C COMMA} macro - -\begin{Ccode} -\#define COMMA \>\>\>, -\end{Ccode} - -that makes the arguments to the {\C if\_\dots{}} macros look like a single argument. -Without this trick, - -The other trick, of course is the {\C if\_\dots{}} macro itself. -The {\C if\_\dots{}} macros have to expand into code without brackets, for example {\C if\_A (a COMMA b)} exands into {\C a, b}. -The {\C COMMA} is not my invention, snacc's {\C \_AND\_} macro is exactly the same. -Both {\C \_AND\_} and {\C COMMA} serve the purpose of being a comma (``,'') as the final result (well, only for ANSI C, for K\&R C, the {\C \_AND\_} becomes a semicolon), but without being an argument separator to the C preprocessor. -The {\C PROTO} macro that was already present in snacc 1.1 gets a single argument as well, but by means of additional parenthesis, inside which commas can savely be used. -It expands into code with brackets around it: {\C PROTO ((int a, char~*b))} expands into {\C (int a, char~*b)}. -The first argument to the {\C PARAM} macro is bracketed list as well, and for the arguments purpose, to be a function argument list, this is fine. - -To have both an ANSI C and a K\&R C version, without {\C PROTO}, {\C PARAMS} and supporting macros, twelve conditional code compilations would have to be written out instead of one! -And what a tedious job to maintain all twelve versions! diff --git a/SecuritySNACCRuntime/doc/corba.bib b/SecuritySNACCRuntime/doc/corba.bib deleted file mode 100644 index 99156fab..00000000 --- a/SecuritySNACCRuntime/doc/corba.bib +++ /dev/null @@ -1,35 +0,0 @@ -% file: .../doc/corba.bib - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/corba.bib,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: corba.bib,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:52 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:51 rj -% first check-in -% - -@techreport{corba, - institution = "OMG", - author = "OMG", - title = "The Common Object Request Broker: Architecture and Specification", - year = "1993", - version = "1.2", -} - -@techreport{idl-c++, - institution = "OMG", - author = "OMG", - title = "OMG RFP Submission--IDL C++ Language Mapping Specification", - year = "1994", -} - -@techreport{gdmo-idl, - institution = "X/Open", - author = "X/Open", - title = "GDMO to OMG IDL Specification Translation Algorithm", - year = "1994", -} diff --git a/SecuritySNACCRuntime/doc/design.tex b/SecuritySNACCRuntime/doc/design.tex deleted file mode 100644 index d4ebd002..00000000 --- a/SecuritySNACCRuntime/doc/design.tex +++ /dev/null @@ -1,761 +0,0 @@ -% file: .../doc/design.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/design.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: design.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:52 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:31 rj -% first check-in -% - -\chapter{\label{comp-des-chapter}Compiler Design} - -\section{\label{comp-overview-section}Overview} -The Snacc compiler is implemented with {\ufn yacc}, {\ufn lex} -(actually GNU's equivalents, {\ufn bison} and {\ufn flex}) and -\verb$C$. Despite the shortcomings of {\ufn lex} and {\ufn yacc}, -they provide reasonable performance without too much programming -effort. Since {\ufn yacc} parsers are extremely difficult to modify -during runtime, any macro that you want the compiler to handle must -be hand coded into the ASN.1 {\ufn yacc} grammar -({\ufn \dots/compiler/core/parse-asn1.y}) followed by recompilation of snacc. -Macro definitions do not need special consideration since they are -skipped by the compiler. Macro definitions and complex value notation -are kept as text in the data structure resulting from a parse if you -want to try to parse and process them. - -To handle the anti-compiler nature of ASN.1's syntax, snacc makes -several passes on parse tree data structure when compiling. None of -these passes creates temporary files; this allows snacc to process -large ASN.1 specifications quite quickly. Each compiler pass is -explained in the next sections. The main passes of the compiler are -executed in the following order: - -\begin{enumerate} -\item parse useful types ASN.1 module -\item parse all user specified ASN.1 modules -\item link local and imported type references in all modules -\item parse values in all modules -\item link local and imported value references in all modules -\item process any macro types -\item normalize types -\item mark recursive types and signal any recursion related errors -\item check for semantic errors in all modules -\item generate C/C++ type information for each ASN.1 type -\item Sort the types from least dependent to most dependent -\item generate the C, C++, IDL or type table -\end{enumerate} - -The source code for the compiler resides in {\ufn \dots/compiler/} and the -back ends are in {\ufn \dots/compiler/back-ends/c-gen/}, {\ufn \dots/compiler/back-ends/c++-gen/} and {\ufn \dots/compiler/back-ends/idl-gen/}. - -\section{\label{comp-pass1-section}Pass 1: Parsing the Useful Types Module} -The ASN.1 useful types are not hardwired into snacc. Instead they -have been placed in a separate ASN.1 module. This allows the user to -define his own useful types or re-define the existing ones without -modifying snacc. This also has the benefit that names of useful types -are not keywords in the lexical analyzer. This step is not really a -compiler pass on the module data, however it is described as one for -simplicity. - -The useful types module should be passed to snacc with the {\ufn -u} -flag in front of it. The {\ufn -u} flag tells snacc to treat the -module in a special way. Instead of parsing the module and generating -code for it, snacc parses the module and makes the types in it -accessible to all of the other modules being parsed. Note that the -other modules do not need to explicitly import from the useful types -module. See Section~\ref{comp-pass3-section} for more information on how -useful types affect linking. - -The encode, decode, and other routines for the useful types are in the -runtime library. Currently, the useful types library routines are the -same as the ones the compiler would normally generate given the useful -types module. However, since they are in the library, you can modify -them to check character sets (string types), or convert local time -formats into their BER equivalent (UTCTime, GeneralizedTime). - -The following types are in the useful types module: -\begin{small} -\begin{verbatim} -ASN-USEFUL DEFINITIONS ::= -BEGIN -ObjectDescriptor ::= [UNIVERSAL 7] IMPLICIT OCTET STRING -NumericString ::= [UNIVERSAL 18] IMPLICIT OCTET STRING -PrintableString ::= [UNIVERSAL 19] IMPLICIT OCTET STRING -TeletexString ::= [UNIVERSAL 20] IMPLICIT OCTET STRING -T61String ::= [UNIVERSAL 20] IMPLICIT OCTET STRING -VideotexString ::= [UNIVERSAL 21] IMPLICIT OCTET STRING -IA5String ::= [UNIVERSAL 22] IMPLICIT OCTET STRING -GraphicString ::= [UNIVERSAL 25] IMPLICIT OCTET STRING -VisibleString ::= [UNIVERSAL 26] IMPLICIT OCTET STRING -ISO646String ::= [UNIVERSAL 26] IMPLICIT OCTET STRING -GeneralString ::= [UNIVERSAL 27] IMPLICIT OCTET STRING -UTCTime ::= [UNIVERSAL 23] IMPLICIT OCTET STRING -GeneralizedTime ::= [UNIVERSAL 24] IMPLICIT OCTET STRING - -EXTERNAL ::= [UNIVERSAL 8] IMPLICIT SEQUENCE -{ - direct-reference OBJECT IDENTIFIER OPTIONAL, - indirect-reference INTEGER OPTIONAL, - data-value-descriptor ObjectDescriptor OPTIONAL, - encoding CHOICE - { - single-ASN1-type [0] OCTET STRING, -- should be ANY - octet-aligned [1] IMPLICIT OCTET STRING, - arbitrary [2] IMPLICIT BIT STRING - } -} -END -\end{verbatim} -\end{small} - -If you use the EXTERNAL type, you must provide the mechanism to encode -and decode the value in the embedded CHOICE, \verb$encoding$. The -type and transfer syntax of the value in an EXTERNAL type is not known -when the ASN.1 code is compiled by snacc. Snacc cannot generate -encoders and decoders without complete type information and only -supports a single set of encoding rules, BER\@. - -\section{\label{comp-pass2-section}Pass 2: Parsing ASN.1 Modules} -During this pass, all of the specified modules are parsed into the {\em -Module} data structure. The ASN.1 source files are not consulted -again, after they are parsed. {\ufn Yacc} and {\ufn lex} are doing the work in -this step. (see files {\ufn snacc.c}, {\ufn lex-asn1.l}, {\ufn parse-asn1.y} -and {\ufn asn1module.h}). - -A lexical tie-in is where the yacc parser puts the lexical analyzer -into a different mode (and is usually considered a hack). The -different modes tokenize symbols differently, which is useful for -skipping well delimited sections that cannot be parsed easily by a -{\ufn yacc} parser on the first pass. Lexical tie-ins are used in two -places to simplify the ASN.1 grammar sufficiently for {\ufn yacc} and -{\ufn lex}. There are two special modes in the lexical analyzer, one -for ASN.1 macro definitions and the other for ASN.1 values enclosed in -\{\}'s. - -The lexical tie-in for eating macro definition bodies works with macro -definitions of the following form: - -\begin{verbatim} - MACRO ::= BEGIN ... END -\end{verbatim} - -Everything between the {\ASN BEGIN} and {\ASN END} is stuffed into a -string by {\ufn lex} and passed back as single token to the -{\ufn yacc} parser. - -Values within \{\}'s are grabbed in a similar way. Value parsing -cannot really be done at this stage since complete type information is -needed and the types are not fully parsed or linked yet. - -Most syntax errors are reported during this pass. If syntax errors -are encountered, snacc will report as many as it can from the -offending module before the parser is hopelessly lost and then exit. -If the types and values are separated with semi-colons, the parser can -recover after a syntax error and attempt to find more errors in that -module before exiting. - - -\section{\label{comp-pass3-section}Pass 3: Linking Types} -The third pass links all type references. Snacc attempts to resolve -any currently visible (i.\ e.\ not in macro definitions or constructed -values) type reference. This includes type references in simple value -definitions and subtyping information. The useful types module (if -given) is linked first. - -Snacc will exit after this pass if any type references could not be -resolved. Error messages with file and line number information will -be printed to {\C stderr}. - -This pass also counts and stores the number of times a type definition is -referenced locally and from other modules. This information is used -during the type sorting pass. - -First, each module identifier is checked for conflicts with the -others. If the module identifier includes an OBJECT IDENTIFIER, snacc -only checks for conflicts with the other module identifier OBJECT -IDENTIFIERs. When only a module name is provided, snacc checks for -conflicts with the the other module names, even if the other module -identifiers include OBJECT IDENTIFIERs. If the OBJECT IDENTIFIER of -a module identifier contains any value references, it will be ignored -for module look-up purposes. Note that value references within the -module identifier OBJECT IDENTIFIERs are not allowed in the 1992 -version of ASN.1 due to the difficulty in module name resolution they -present. - -Two modules with the same name but different OBJECT IDENTIFIERs are -not considered an error within ASN.1. However, because the generated -files use the module name as part of their name, the code generation -pass will gripe about and fail for modules with the same name. - -Next, each module's import {\em lists} are resolved by finding the -named module and then verifying that the named module contains all of -the imported types. - -Then for each module, each type reference (except those of the form -{\em modulename.typename}) is assumed to be a local type reference and -the linker attempts to find a local type definition of the same name -to resolve it with. If a matching local definition is found, the type -reference is resolved and the linker continues with the next type -reference. - -For each type reference of the form {\em modulename.typename}, the -linker looks in the module with name {\em modulename} for the type -{\em typename}. If the type is found the reference is resolved, -otherwise a linking error is reported. Note that this form of type -reference provides a special scope that does not conflict with other -local or imported types in that module. - -For type references that failed to resolve locally and are not of the -form {\em modulename.typename}, the linker looks in the import lists -of the current type reference's module for a type to resolve with. If -the type is found in the import lists, the reference is resolved. - -For the remaining unresolved type references (failed local and legal -import resolution and are not of the form {\em modulename.typename}), -the linker looks in the useful types module, if one was specified with -the {\ufn -u} option. If the type is found in the useful types module -then the reference is resolved, otherwise a linking error is reported. - -Note that when a useful types module is specified, it is globally -available to all modules, but it has the lowest linking priority. -That is, if a type reference can be resolved legally without the -useful types module, it will be. - -Some type checking must be done in this pass to link certain types -properly. These include: -\begin{itemize} -\item {a SELECTION type must reference a field of a CHOICE type.} -\item {a COMPONENTS OF type in a SET must reference a SET.} -\item {a COMPONENTS OF type in a SEQUENCE must reference a SEQUENCE.} -\end{itemize} - - - -\section{\label{comp-pass4-section}Pass 4: Parsing Values} -The fourth pass attempts to parse any value that is enclosed in \{\}'s in -the given modules. INTEGERS, REALs and BOOLEANS that are not enclosed in -braces are parsed in the first pass. - -The value parser is implemented without {\ufn yacc} and {\ufn lex} and -uses each value's type information to help parse the value. Values -within \{\}'s hidden within types such as default values and parts of -subtypes are not parsed. Since subtypes and default values do not -affect the generated code, upgrading the value parser in this respect -is not very useful. - -The only type of value in \{\}'s that is parsed is the OBJECT -IDENTIFIER\@. All of the OBJECT IDENTIFIER value forms are supported -but snacc loosens the restrictions on using arc names defined in the -OBJECT IDENTIFIER tree. - -ASN.1 allows OBJECT IDENTIFIER values to reference special built-in -arc names from the OBJECT IDENTIFIER tree defined in Annexes B, C and -D of X.208. For example the first arc in an OBJECT IDENTIFIER value -can be either {\ASN ccitt} {\ASN iso} or {\ASN joint-iso-ccitt}. The -acceptable arc names are context dependent; for example the second arc -can be one of {\ASN standard}, {\ASN registration-authority}, -{\ASN member-body} or {\ASN identified-organization} only if the first -arc was {\ASN iso} or 1. - -Snacc uses a simplified algorithm to handle references to the arc -names defined in the OBJECT IDENTIFIER tree. Any arc value that is -represented by a single identifier is checked to see if it is one of -the arc names defined in the OBJECT IDENTIFIER tree; context is -ignored. If the identifier matches one of the arc names then its -value is set accordingly. The lack of context sensitivity in snacc's -algorithm may cause the arc name to link with an arc name from the -OBJECT IDENTIFIER tree when a local or imported INTEGER was desired. -The following is the list special arc names that snacc understands and -their values (see {\ufn \dots/compiler/core/oid.c}): - -\begin{itemize} -\setlength{\itemsep}{0pt} -\setlength{\parsep}{0pt} -\nspace{0} -\item {ccitt = 0} -\item {iso = 1} -\item {joint-iso-ccitt = 2} -\item {standard = 0} -\item {registration-authority = 1} -\item {member-body = 2} -\item {identified-organization = 3} -\item {recommendation = 0} -\item {question = 1} -\item {administration = 2} -\item {network-operator = 3} -\end{itemize} - -\section{\label{comp-pass5-section}Pass 5: Linking Values} -The fifth pass links value references. The value linker looks for -value references to resolve in value definitions and type definitions, -including default values and subtyping information. The value linking -algorithm is virtually identical to the type linking pass (see Section -\ref{comp-pass3-section}). - -Currently the value parsing is limited to OBJECT IDENTIFIER values. -Simple values that are not between \{\}'s are parsed in the first -pass. Here is an example that illustrates the OBJECT IDENTIFIER -parsing and linking. The following values: - -\begin{small} -\begin{verbatim} -foo OBJECT IDENTIFIER ::= { joint-iso-ccitt 2 88 28 } -bar OBJECT IDENTIFIER ::= { foo 1 } -bell INTEGER ::= 2 -gumby OBJECT IDENTIFIER ::= { foo bell } -pokie OBJECT IDENTIFIER ::= { foo stimpy(3) } -\end{verbatim} -\end{small} - -\noindent -are equivalent to this: - -\begin{small} -\begin{verbatim} -foo OBJECT IDENTIFIER ::= { 2 2 88 28 } -bar OBJECT IDENTIFIER ::= { 2 2 88 28 1 } -bell INTEGER ::= 2 -gumby OBJECT IDENTIFIER ::= { 2 2 88 28 2 } -pokie OBJECT IDENTIFIER ::= { 2 2 88 28 3 } -\end{verbatim} -\end{small} - -Note that in version 1.0, named arcs (e.g. {\ASN stimpy(3)}) were -promoted to full integer values. This was wrong---many standards -re-used them (e.g. X.500 and {\ASN ds(5)}) leading to multiply defined -integer values. If you want to improve the value parsing, look in -{\ufn \dots/compiler/core/val-parser.c} - -\section{\label{comp-pass6-section}Pass 6: Processing Macros} - -The fifth pass processes macros. For all macros currently handled, -snacc converts type definitions inside the macro to type references -and puts the type definition in the normal scope. This way, the code -generator does not have to know about macros to generate code for the -types defined within them. - -The only macro that receives any special processing is the SNMP -OBJECT-TYPE macro. This macro's information defines an OBJECT -IDENTIFIER or INTEGER to type mapping for use with any ANY DEFINED BY -type. Note that the OBJECT-TYPE macro has been extended beyond its -SNMP definition to allow integer values for INTEGER to type mappings. - -ASN.1 allows you to define new macros within an ASN.1 module; this -can change the grammar of the ASN.1 language. Since snacc is -implemented with {\ufn yacc} and yacc grammars cannot be modified -easily during runtime, snacc cannot change its parser in response to -macro definitions it parses. - -Any macro that snacc can parse has been explicitly added to the yacc -grammar before compiling snacc. When a macro that snacc can parse is -parsed, a data structure that holds the relevant information from the -macro is added to the parse tree. The type and value linking passes -as well as the macro processing and possibly the normalization pass -need to be modified to handle any new macros that you add. - -The following macros are parsed: - -\begin{itemize} -%\begin{linespacing}{0.5} -\setlength{\itemsep}{0pt} -\setlength{\parsep}{0pt} -\nspace{0} -\item{ OPERATION (ROS) } -\item{ ERROR (ROS) } -\item{ BIND (ROS) } -\item{ UNBIND (ROS) } -\item{ APPLICATION-SERVICE-ELEMENT (ROS) } -\item{ APPLICATION-CONTEXT } -\item{ EXTENSION (MTSAS)} -\item{ EXTENSIONS (MTSAS) } -\item{ EXTENSION-ATTRIBUTE (MTSAS) } -\item{ TOKEN (MTSAS) } -\item{ TOKEN-DATA (MTSAS)} -\item{ SECURITY-CATEGORY (MTSAS) } -\item{ OBJECT (X.407) } -\item{ PORT (X.407) } -\item{ REFINE (X.407)} -\item{ ABSTRACT-BIND (X.407) } -\item{ ABSTRACT-UNBIND (X.407) } -\item{ ABSTRACT-OPERATION (X.407) } -\item{ ABSTRACT-ERROR (X.407) } -\item{ ALGORITHM (X.509)} -\item{ ENCRYPTED (X.509)} -\item{ PROTECTED (X.509)} -\item{ SIGNATURE (X.509)} -\item{ SIGNED (X.509)} -\item{ OBJECT-TYPE (SNMP) } -%\end{linespacing} -\end{itemize} - -However, no code is generated for these macros. As stated above, only -the OBJECT-TYPE macro affects the encoders and decoders. - -\section{\label{comp-pass7-section}Pass 7: Normalizing Types} -The sixth pass normalizes the types to make code generation simpler. -The following is done during normalization: -\begin{itemize} - -\item[1.] { COMPONENTS OF types are replaced with the contents of the SET -or SEQUENCE components that they reference.} - -\item[2.] { SELECTION types are replaced with the type they reference.} - -\item[3.] { SEQUENCE, SET, CHOICE, SET OF and SEQUENCE OF {\em definitions} -embedded in other types are made into separate type definitions. } - -\item[4.] { For modules in which ``IMPLICIT TAGS'' is specified, tagged -type references such as {\ASN [APPLICATION 2] Foo} are marked IMPLICIT -if the referenced type ({\ASN FOO} in this case) is not an untagged -CHOICE or untagged ANY type.} - -\item[5.] { INTEGERs with named numbers, BIT STRINGs with named bits and -ENUMERATED types embedded in other types are made into separate type -definitions.} -\end{itemize} - -The COMPONENTS OF and SELECTION type simplifications are obvious but -the motivation for the others may not be so obvious. The third type of -simplification makes type definitions only one level deep. This -simplifies the decoding routines since snacc uses local variables for -expected lengths, running length totals and tags instead of stacks. - -The implicit references caused by ``IMPLICIT TAGS'' are marked -directly on type references that need it. This saves the code -generators from worrying about whether implicit tagging is in effect -and which types can be referenced implicitly. - -The types with named numbers or bits are made into a separate type to -allow the C++ back end to simply make a class that inherits from the -INTEGER or BIT STRING class and defines the named numbers or bits -inside an enum in the new class. This is described further in the C++ -code generation chapter. - -\section{\label{comp-pass8-section}Pass 8: Marking Recursive Types} - - -This pass marks recursive types and checks for recursion related -errors. To determine whether a type definition is recursive, each -type definition is traced to its leaves, checking for references to -itself. Both local and imported type references within a type are -followed to reach the leaves of the type. A leaf type is a simple -(non-aggregate) built-in type such as an INTEGER or BOOLEAN\@. At the -moment, recursion information is only used during the type dependency -sorting pass. - -{\em Snacc} attempts to detect two types of recursion related errors. The -first type of error results from a recursive type that is composed -solely of type references. Types of this form contain no real type -information and would result in zero-sized values. For example the -following recursive types will generate this type of warning: -\begin{small} -\begin{verbatim} -A ::= B -B ::= C -C ::= A -\end{verbatim} -\end{small} - -The other recursion related error results from a type whose value will -always be infinite in size. This is caused by recursion with no -optional component that can terminate the recursion. If the recursion -includes an OPTIONAL member of a SET or SEQUENCE, a CHOICE member, or -a SET OF or SEQUENCE OF, the recursion can terminate. - -Both of the recursion errors generate warnings from snacc but will -not stop code generation. - - -\section{\label{comp-pass9-section}Pass 9: Semantic Error Checking} -The ninth pass checks for semantic errors in the ASN.1 specification -that have not been checked already. Both the type linking pass and the -recursive type marking pass do some error checking as well. Snacc attempts -to detect the following errors in this pass: - -\begin{itemize} -\item { elements of CHOICE and SET types must have distinct tags.} - -\item { CHOICE, ANY, and ANY DEFINED BY types cannot be implicitly tagged. } - -\item { type and value names within the same scope must be unique. } - -\item { field names in a SET, SEQUENCE or CHOICE must be distinct. If -a CHOICE is a member of a SET, SEQUENCE or CHOICE and has no field name, -then the embedded CHOICE's field names must be distinct from its -parents to avoid ambiguity in value notation.} - -\item { an APPLICATION tag code can only be used once per module. } - -\item { each value in a named bit list (BIT STRINGs) or named number -list (INTEGERs and ENUMERATED) must be unique within its list.} - -\item { each identifier in a named bit list or named number list must -be unique within its list.} - -\item { the tags on a series of one or more consecutive OPTIONAL or DEFAULT -SEQUENCE elements and the following element must be distinct. } - -\item { gives a warning if an ANY DEFINED BY type appears in a -SEQUENCE before its identifier or in a SET\@. These would allow encodings -where the ANY DEFINED BY value was prior to its identifier in the -encoded value; ANY DEFINED BY values are difficult to decode without -knowing their identifier.} - -\end{itemize} - -Snacc does not attempt to detect the following errors due the -limitations of the value parser. -\begin{itemize} -\item { SET and SEQUENCE values can be empty (\{\}) only if the SET or -SEQUENCE type was defined as empty or all of its elements are marked -as OPTIONAL or DEFAULT.} - -\item { each identifier in a BIT STRING value must from that BIT -STRING's named bit list (this could be done in an improved value -linker instead of this pass).} -\end{itemize} - - -\section{\label{comp-pass10-section}Pass 10: Generating C/C++ Type Information} - -This pass fills in the target language type information. The process -is different for the C and C++ back ends since the C++ ASN.1 model is -different and it was developed later (more design flaws had been -corrected for the C++ backend). - -For C and C++ there is an array that contains the type {\em definition} -information for each built-in type. For each built-in ASN.1 type, the -C array holds: - -\begin{description} -\item[typename] {the C {\C typedef} name for this type definition.} - -\item[isPdu] {TRUE if this type definition is a PDU\@. This is set -for types used in ANY and ANY DEFINED BY types and those indicated by -the user via compiler directives. Additional interfaces to the encode -and decode routines are generated for PDU types. The SNMP OBJECT-TYPE -macro is the current means of indicating whether a type is used within -an ANY or ANY DEFINED BY type.} - -\item[isPtrForTypeDef] { TRUE if other types defined solely by this type -definition are defined as a pointer to this type.} - -\item[isPtrForTypeRef] { TRUE if type references to this type -definition from a SET or SEQUENCE are by pointer.} - -\item[isPtrForOpt] { TRUE if OPTIONAL type references to this type -definition from a SET or SEQUENCE are by pointer.} - -\item[isPtrInChoice] { TRUE if type references to this type -definition from a CHOICE are by pointer.} - -\item[optTestRoutineName] { name of the routine to test whether an -OPTIONAL element of this type in a SET or SEQUENCE is present. -Usually just the name of a C macro that tests for NULL.} - -\item[printRoutineName] { name of this type definition's printing routine.} -\item[encodeRoutineName]{ name of this type definition's encoding routine.} -\item[decodeRoutineName]{ name of this type definition's decoding routine.} -\item[freeRoutineName] { name of this type definition's freeing routine.} -\end{description} - -The C++ type definition array is similar to C's. It contains: - -\begin{description} -\item[classname] { holds the C++ {\C class} name for this type definition.} -\item[isPdu] { same as C isPdu except that is does not affect the code -generation since the C++ back end includes the extra PDU encode and -decode routines by default.} -\item[isPtrForTypeDef] { same as C isPtrForTypeDef. } -\item[isPtrForOpt] { same as C isPtrForOpt.} -\item[isPtrInChoice] { same as C isPtrInChoice} -\item[isPtrInSetAndSeq] { whether type references to this class -from a SET or SEQUENCE are by pointer.} -\item[isPtrInList] {whether type references to this class -from a SET OF or SEQUENCE OF are by pointer.} -\item[optTestRoutineName] { name of the routine to test whether an -OPTIONAL element of this type in a SET or SEQUENCE is present. -Usually is just name of a C macro that tests for NULL.} -\end{description} - -The first step of this pass uses the type arrays to fill in the C or -C++ type {\em definition} information for each module's ASN.1 type -definitions. This is done for the useful types module as well. - -The next step goes through each constructed type and fills in the type -{\em reference} information for each reference to a built-in, user defined -or useful type. Much of the type reference information is taken from -the referenced type's definition information. The type reference -information contains the following (for both C and C++): - -\begin{description} -\item[fieldName] { field name for this type if it is referenced from -a CHOICE, SET or SEQUENCE.} -\item[typeName] { type name of the referenced type.} -\item[isPtr] { whether this reference is by pointer.} -\item[namedElmts] { named elements for INTEGER, ENUMERATED or BIT -STRING types with their C names and values.} -\item[choiceIdValue] { if this type reference is in a CHOICE, this -holds the value of the CHOICE's choiceId that indicates the presence -of this field.} -\item[choiceIdSymbol] { if this type reference is in a CHOICE, this -holds the C enum value symbol that has the choiceIdValue value.} -\item[optTestRoutineName] { name of the routine or macro to test for -the presence of this element if it is an OPTIONAL element of a SET or SEQUENCE.} -\end{description} - -\section{\label{comp-pass11-section}Pass 11: Sorting Types} - -This pass sorts the type definitions within each module in order of -dependence. ASN.1 does not require the types to be defined before -they are referenced but both C and C++ do. Without this pass, the -generated types/classes would probably not compile due to type -dependency problems. There is no attempt to order the modules; -command line order is used for the module dependence. If you have -problems with mutually dependent modules, the simplest approach is to -combine the dependent modules into a single ASN.1 module. - -Some compilers such as CASN1 \cite{CASN1} require the user to order -the types within the ASN.1 modules. This can be tedious and since -snacc may generate new type definitions from nested aggregate type -definitions in the normalization pass, the user does not have complete -control over the order of every type definition. (The user could use -the {\ufn -P} option to get the normalized ASN.1 and then order it but -that is painful as well.) - -Snacc attempts to sort the types from least dependent to most -dependent using the following convoluted algorithm: - -First, separate the type definitions within a module into the groups: -\begin{itemize} -\item[1.] { type definitions that are defined directly from simple built-in -types such as INTEGER.} - -\item[2.] { types such as SET, SEQUENCE, SET OF, SEQUENCE OF and CHOICE -that contain no references to types defined in this module. That, is -they are defined from only simple built-in types, imported types or -useful types.} - -\item[3.] { type definitions that reference locally defined types.} - -\item[4.] { type definitions that are not referenced by any local types.} -\end{itemize} - -Only the 3rd group of type definitions needs more sorting. After it -has been sorted, the groups are merged in the order 1, 2, 3, 4 to -yield a sorted type definition list. - -Now we describe how the 3rd group of type definitions is sorted. -\begin{itemize} - -\item[1.] {for each type definition in the third group, a list of its local type -references is built and attached to it. This type reference list only -goes one level deep; it does not follow type references to find more -type references.} - -\item[2.] { all of the linearly-dependent types are removed and sorted. -This is done by repeatedly removing type definitions that do not -directly depend on any other type definitions that remain in the 3rd -group. The process of removing the type definitions sorts them.} - -\item[3.] { the type definitions that were not removed in step 2 are -divided into two groups: recursive and non-recursive. The -non-recursive types depend on the recursive ones since they are still -in the list after step 2.} - -\item[4.] { the non-recursive types from step 3 are sorted as in step -2. All of them should sort linearly since none are recursive. } - -\item[5.] { if the target language is C, any SET OF or SEQUENCE OF -types are separated from the recursive type definitions built in step 3. -This is done because the C representation of a list type is generic -(uses a {\C void~*} to reference the list element) and therefore does -not really depend on the list's element type.} - -\item[6] { the list of local type references for the recursive types -from step 3 is re-generated as in step 1 using a relaxation: types -referenced as pointers are not added to a type's reference list.} - -\item[7] { the recursive types from step two are re-sorted as in step -2 using their new local type reference lists. Two lists are formed, -those that sorted linearly and those that did not. Hopefully the -latter list will be empty.} -\end{itemize} - -To form a sorted third group, the lists are merged in the following order: -\begin{itemize} -\item {linearly sorted types from step 2} -\item {separated list types (C only) from step 5} -\item {sorted recursive types from step 7} -\item {unsorted recursive types from step 7 (hopefully empty)} -\item {sorted non-recursive types from step 4} -\end{itemize} - - -In C, the code generator defines both {\C typedef} names and -{\C struct} tags (names). For example, -\begin{verbatim} -Foo ::= SET { a INTEGER, b BOOLEAN } - -Bar ::= SEQUENCE { a OBJECT IDENTIFIER, b Foo } -\end{verbatim} -translates to the following C data types: -\begin{verbatim} -typedef struct Foo /* SET */ -{ - AsnInt a; /* INTEGER */ - AsnBool b; /* BOOLEAN */ -} Foo; - -typedef struct Bar /* SEQUENCE */ -{ - AsnOid a; /* OBJECT IDENTIFIER */ - struct Foo *b; /* Foo */ -} Bar; -\end{verbatim} - -Note that both the {\C struct} and the {\C typedef} have the name -{\C Foo}. Also note that the Bar type references the {\C Foo} via -{\C struct Foo~*}. - -For types such as {\C Bar} that contain the {\C Foo} type, -{\C Foo} is referenced as {\C struct Foo~*} instead of just -{\C Foo~*} because C allows you to use the type {\C struct Foo~*} -(incomplete type) in defining types even prior to the actual -declaration of the the {\C struct Foo}. The {\C Foo~*} type can -{\em only} be used after the {\C Foo typedef} declaration. The use -of incomplete types can often overcome recursion related type ordering -problems (not relevant in this example since they are not recursive). - -\section{\label{comp-pass12-section}Pass 12: Generating Code} - -This pass creates and fills the source files with C or C++ code or -produces a type table containing the type descriptions from all of the -parsed modules, including the useful types module (if given). The -purpose of the normalization, sorting and error detection passes is to -simplify this pass. - -The normalization pass simplified the ASN.1 types in various ways to -make C/C++ type and code generation simpler. - -The type sorting pass hopefully eliminates type dependency problems in the -generated code. The C/C++ type generator simply proceeds through the -ordered type list writing the C/C++ type definitions to a header file. - -The error detection and linking passes will make snacc exit if errors -are found, so the code generation pass can assume the ASN.1 types are -virtually error free. This usually allows snacc to exit gracefully -instead of crashing due to an undetected error. - -The type table data structure is similar to snacc's parse tree for the -ASN.1 modules but it is much simpler. This is because all of the type -linking and error checking has been done. The type definitions in the -type tables are in defined by the type sorting pass (dependency). - -The next chapters describe the code that is generated by snacc and the -libraries the generated code uses. diff --git a/SecuritySNACCRuntime/doc/editor.tex b/SecuritySNACCRuntime/doc/editor.tex deleted file mode 100644 index 3f2ac754..00000000 --- a/SecuritySNACCRuntime/doc/editor.tex +++ /dev/null @@ -1,462 +0,0 @@ -% file: .../doc/editor.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/editor.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: editor.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:52 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:41 rj -% first check-in -% - -\chapter{\label{snacced-chapter}SnaccEd, the Snacc Editor} - -SnaccEd is a simple graphical editor for BER encoded files. -A set of ASN.1 files describes one or more hierarchical datastructures that can be displayed as an n-ary non-circular graph, in other words: a tree. - -\begin{figure}[ht!] -\begin{center} -\includegraphics[scale=0.7]{example} -\caption[SnaccEd: an example screen shot]{An example screen shot} -\label{snacced-example} -\end{center} -\end{figure} - -SnaccEd is combined from -\begin{itemize} - \item the usual Snacc BER encode and decode functions - \item the metacode (described in chapter~\ref{meta-chapter} starting on page~\pageref{meta-chapter}) - \item the Tcl library - \item the Snacc Tcl interface (described in chapter~\ref{tcl-if-chapter} starting on page~\pageref{tcl-if-chapter}) - \item the Tk widget set - \item a freeware tree widget (another Tcl extension, implemented in C++) - \item a Tcl script that glues all those parts together -\end{itemize} - -All items except for the Tcl script are compiled into an executable, the \emph{snaccwish}. -The Tk interpreter has the name {\ufn wish}, for ``windowing shell'', and consequently, I name the program that results from linking Snacc with Tk {\ufn snaccwish}. -For every individual set of ASN.1 files, a different snaccwish has to be made, because every snaccwish contains the specialized encode and decode routines for the ASN.1 files' types. - -This {\ufn snaccwish} is a Tcl interpreter that has the additional commands of the Tk widget set, the tree widget and the Snacc interface built in. -This interpreter reads the {\ufn snacced} script that implements the graphical Snacc editor. -I will henceforth refer to the script as {\ufn snacced} and to the interpreter as {\ufn snaccwish}. -You may name your script and the shell binary differently, just make sure that the script calls the correct binary!. - -Snacced can be called with various arguments, see the manual page for details. - -The {\ufn snacced} script is only the most visible entry point, other scripts will be read using Tcl's autoloading mechanism. - -The Tcl script is (or can be) always the same. -It uses the {\Tcl snacc} command to learn about the ASN.1 modules, types and PDUs. - -Since the BER format has not got any magic number or similar concept, the Snacc routines in general cannot identify the ASN.1 type contained in a BER encoded string of octets. -As a consequence, one has to choose not only the file name but the ASN.1 type as well when one opens or creates a file (see figure~\ref{selbox-pic} \sthisnextafter{selbox-pic} for an example). - -\begin{figure}[ht] -\begin{center} -\includegraphics[scale=0.7]{selbox} -\caption{The file and content type selection box} -\label{selbox-pic} -\end{center} -\end{figure} - -One can then examine and manipulate the file's structure and contents. - -\section{Manipulating the Display} - -This section describes the pointer\footnote{ - My pointer device is a mouse, but yours may be a trackball, a tablet, a joystick or something else. -} operations that change the amount of information to be shown. -(To change the file's contents, the node's content window has got be opened.) - -The file is displayed by means of a tree widget. -Only a part of the full hierarchy is shown. -The subtree's root is at the left side. -The function of the pointer buttons\footnote{ - I will refer to the buttons but their number, not their position. - I could refer to button~1 as the right button, but this might confuse you as your button~1 may in fact be on the left hand side. -} when clicking on \emph{node names} is as follows: -\begin{description} - \item[button~1] - adds or deletes the node's subnodes to or from the display, respectively. - (Except for SET OF and SEQUENCE OF types, where with button 2 you have got to open the node content editor, a list widget, and have to toggle the display of individual elements by clicking on their index numbers. This is explained at the end of section~\ref{cont-ed-list-sect} \sthisnextafter{cont-ed-list-sect}.) - \begin{itemize} - \item For nodes that have subnodes being shown, the subtree gets hidden. - \item Otherwise, the node's immediate descendents are added to the display. - \end{itemize} - \item[button~2] - opens or closes the node, where ``closed'' means that only the nodes name is being shown, and ``open'' means that an additional window showing the node's contents it put under the node's name. - This content window is explained in the next section. - \item[button~3] - adds or deletes the node's parent to or from the display, respectively. - \begin{itemize} - \item For nodes where the parent is displayed, all parents and all siblings with their subtrees will get hidden. - \item Otherwise, the parent is added to the display. - \end{itemize} -\end{description} - -Pressing and holding button 2 on a free space, the display can be dragged by moving the pointer. - -\section{The Content Window} - -\begin{figure} -\begin{center} -\includegraphics[scale=0.65]{simple} -\caption{Content editors for ASN.1 simple types} -\label{simple-content} -\end{center} -\end{figure} - -\begin{figure} -\begin{center} -\includegraphics[scale=0.7]{struct} -\caption{Content editors for ASN.1 structured types} -\label{struct-content} -\end{center} -\end{figure} - -\def\exref{ (based on the example displayed as figure~\ref{snacced-example} on page~\pageref{snacced-example})} - -\begin{figure} -\begin{center} -\includegraphics[scale=0.7]{str-popup} -\caption[Popup for import/export of OCTET STRING contents]{Popup for import/export of OCTET STRING contents\exref} -\label{str-popup} -\end{center} -\end{figure} - -\begin{figure} -\begin{center} -\includegraphics[scale=0.7]{list-popup} -\caption[Popup for action selection for SET OF and SEQUENCE OF types]{Popup for action selection for SET OF and SEQUENCE OF types\exref} -\label{list-popup} -\end{center} -\end{figure} - -The content window that may be opened beneath the node's name looks and behaves different for every content type. -An example for every ASN.1 simple type is shown in figure~\ref{simple-content} \sthisnextafter{simple-content}. -The ASN.1 input for the example can be found in appendix~\ref{edex0.asn1} on page~\pageref{edex0.asn1}. -\begin{itemize} - \item - The NULL type has only one value that cannot be changed. - \item - Values of BOOLEAN type are displayed as a toggle button. - \item - For the ENUMERATED type, SnaccEd displays a list of radio buttons listing the values' names. - (The numerical values are not shown.) - \item - INTEGER values are displayed using an entry widget where the numeric value can be seen and changed. - The entry widget's binding have been changed to allow the input of ``--'' and decimal digits only in addition to the usual control functions (procedure {\Tcl int\_entry\_bindings}). - Similar to the ENUMERATED type, values can be given a name; the list is displayed as above. - \item - Individial names in a BIT STRING may be named. - SnaccEd displays a list of buttons identifying those bits along with their name. - Clicking on one of those buttons toggles the bit's value. - \newline - The bit string is displayed and can be edited in its binary representation in an entry widget below the names. - The entry widget's binding have been changed to allow the input of ``0'' and ``1'' only in addition to the usual control functions (procedure {\Tcl bit\_string\_entry\_bindings}). - \item - OCTET STRINGs and derived types are displayed in a text widget. - Since Tcl cannot handle strings containing NUL bytes, NUL bytes are displayed as the two character combination ``\char`\\0'' and backslashes are duplicated, ``\char`\\\char`\\''. - Button 3 pops up a small menu that allows you to load or save the octet string from or to an external file, respectively (figure~\ref{str-popup} \sthisnextafter{str-popup}). - The X text selection to copy text between the text widget and e.g. an xterm can be used as well. - \item - CHOICE types allow exactly one of their subtypes to be valid and therefore are displayed as a list of radio buttons. - Clicking on a button deletes the old choice and allocates the new one. - See the ``{\C color}'' in figure~\ref{struct-content} on page~\ref{struct-content}. - \item - The SET and SEQUENCE types' elements are displayed in a list of buttons, and optional elements may be added and deleted by clicking on their buttons. - Mandatory members do not respond to button clicks and are greyed out. - Examples: the list element \#1 right in the middle of figure~\ref{snacced-example} on page~\pageref{snacced-example} or the ``{\C rgb}'' in figure~\ref{struct-content} on page~\pageref{struct-content}. - \item \label{cont-ed-list-sect} - SnaccEd visualizes the types SET OF and SEQUENCE OF in a list widget. - The widget shows the elements' ordinal numbers, the elements themselves are shown in individual widgets to the right. - Button~3 in the list widget brings up a small menu where you can choose the action to perform when (with button 1) you click on a list element (figure~\ref{list-popup} \sthisnextafter{list-popup}): - \begin{itemize} - \item toggle the display of an element - \item insert a new element - \item append a new element - \item delete an element - \end{itemize} - The cursor shape changes and reminds you of your chosen action. - An example of a list widget is ``{\C files}'' in figure~\ref{snacced-example} on page~\pageref{snacced-example}. -\end{itemize} -Some content editors can be resized: move the pointer to the content editor's frame. -Where the cursor shape changes to a ``bottom\_right\_corner'', press button~1 and drag the frame. - -\section{\label{editor-building}Building Your Own Editor} - -There isn't much to be done to get an editor that understands your BER encoded files. -This chapter's example can be found in {\ufn \dots/tcl-example/}. - -\begin{itemize} - \item - Make sure your Snacc compiler has be configured to support the Tcl code. - This can be verified by calling {\ufn `snacc -h | grep tcl`}; if the output is empty, the configuration script was unable to find Tcl/Tk. - \item - The Tcl/Tk libraries must have been compiled with with gcc in order to use its {\C main()} function. - Otherwise, the constructors and destructors of static variables may not be called. - I have added some code at the end of {\ufn \dots/.../c++-lib/src/tcl-if.C} that checks for this condition. - \newline - Tcl's default is not to use gcc but cc where present, but you can compile Tcl/Tk by calling {\ufn env CC='gcc -traditional' ./configure} instead of {\ufn ./configure}. - \item - Install the tree widget. - SnaccEd works with tree-3.6. - (tree-3.6.2 requires another Tcl extension, itcl, but to avoid complicating matters any further, SnaccEd sticks to the simpler version.) - When {\ufn \dots/configure} found the tree widget libraries, the macro definition for {\Make TREELIBS} in {\ufn \dots/makehead} will have been set to {\ufn -ltktree -lOS}. - \item - In your makefile, extend {\ufn snacc}'s list of arguments with the {\ufn -tcl} option followed by the list of PDUs (that is an additional \emph{two} arguments). - \item - Put {\ufn modules.C} into the list of files to be compiled. - \item - Compile with {\ufn -DTCL}. - \item - To link, replace {\ufn -lasn1c++} against {\ufn -lasn1tcl} and add {\ufn \$(TREELIBS)} to the list of libraries. - (You may have to add a {\ufn -L} option as well.) - \item - Call {\ufn \$(TCL\_LIB)/make-snacced \$(SNACCED) \$(WISH) \$(TCL\_LIB)}, where {\ufn \$(TCL\_LIB)} is either {\ufn \$\{prefix\}/lib/snacc/tcl/} (the place where the Tcl library files got installed by {\ufn make install}) or {\ufn \dots/tcl-lib/} (in case you haven't called {\ufn make install} yet), and {\ufn \$(WISH)} is the name of the wish executable you just compiled. - The {\ufn make-snacced} script generates a small Tcl script, {\ufn \$(SNACCED)}, that executes your wish executable, extends the Tcl variable {\Tcl auto\_path} to include your {\ufn \$(TCL\_LIB)} und through the auto loading mechanism calls the Tcl library routine {\Tcl snacced} to start the Snacc editor. -\end{itemize} - -Make sure you get the {\ufn \dots/tcl-example/} working before you despair of your own set of files. -Take {\ufn \dots/tcl-example/makefile} as a guide. - -Your can use the {\ufn .h} and {\ufn .C} file resulting from calling {\ufn snacc -tcl \dots} for both the editor and your other uses. -Just remember: if you compile with {\ufn -DTCL}, link against {\ufn libasn1tcl.a}; if you want to disable the metacode and tcl interface, compile with {\ufn -DMETA=0} and link against {\ufn libasn1c++.a}. - -Make sure that you don't link with your old {\C main()}\footnote{Or make sure your {\C main()} behaves similar to the Tk libraries'}. -The generated file {\ufn modules.C} contains the line\\ -{\C static int (*dummy)(Tcl\_Interp~*) = Tcl\_AppInit;}\\ -that forces {\ufn libasn1tcl.a(tkAppInit.o)} to be linked. -{\ufn \dots/c++-lib/src/tkAppInit.c} in turn contains the lines\\ -{\C extern int main();\\ -int *tclDummyMainPtr = (int *)main;}\\ -that force the {\C main} function in the Tk library to be linked. - -{\C Tcl\_AppInit()} calls {\C Snacc\_Init()} that is defined in {\ufn \dots/c++-lib/src/tcl-if.C}. -{\C Snacc\_Init()} installs the {\Tcl snacc} command. - -\section{\label{snacced-impl}Implementation} - -The Tcl scripts that implement the editor can be found in {\ufn \dots/tcl-lib/} and, after installation, in {\ufn \$\{prefix\}/lib/snacc/tcl/}. - -You are free to change the Tcl script(s), for example to display some data types in a more appropiate manner. -Octet strings may be user readable but often are not, pictures and audio data come to mind. - -If add procedures or {\ufn .tcl} files, you have got to rebuild Tcl's autoloading index. -This best done by adding the files to the {\Make TCLFILES.dist} list in {\ufn \dots/tcl-lib/makefile} and running {\ufn make} again. - -%!!! nicht in doc/: -The first SnaccEd was able to handle only one file at a time. -To enable the editor to handle several files simultaneously required the following steps: -\begin{itemize} - \item instead of using the default toplevel widget {\Tcl .} (dot), open a toplevel widget for every file. - The toplevel widgets get names {\Tcl .file0}, {\Tcl .file1}, \dots - The same name without the leading dot is used as a global array variable to hold miscellaneous pieces of information about the file. - You can see how the names are generated in the code example on page~\pageref{tcl-name-space-example-code}. - The name of this variable is given to many procedures in the {\Tcl fileref} parameter. - \item identify global variables. Those were - \begin{itemize} - \item the name of the file handle - \item the names of some widgets, namely the toplevel, the menubar, the canvas and the tree widget. - \end{itemize} - Other global variables can be left untouched: the help text, the list of PDU types. - This information is the same for all the files a snaccwish can handle. -\end{itemize} - -Since the file and type selection box, the help text and the dialog boxes are modal, only one instance is needed and they can have the same names for every file opened by the editor. - -The editor displays only a portion of the ASN.1 file. -The Snacc editor keeps the displayed portions of the ASN.1 file in two similar data structures. - -The contents of an ASN.1 file is accessed by calling the {\Tcl snacc} command with a {\Tcl \emph{path}} that identifies the requested data portion. - -Every ASN.1 file is displayed using one toplevel widget. -This toplevel widget is a frame for a number of subwidgets: -\begin{itemize} - \item a menubar - \item a canvas - \item two scrollbars, one vertical, one horizontal, to select the visible part of a canvas that has grown too large for the frame. -\end{itemize} - -The menubar contains two buttons, one for the usual file related commands, and a help button. - -The canvas is the main arena. -Its subwidgets are the tree widget and all the canvas items that make up the nodes and edges. -The tree widget computes the positions of the canvas items and moves them in place. - -The contents of an ASN.1 file can be seen as a tree (the data structure may by recursive using CHOICE types or OPTIONAL components, and a PDU may contain instances of a type that contain other instances of the same type (see figure~\ref{recursion} on page~\pageref{recursion} for an example), but as ASN.1 has no pointers, cycles are impossible). -To display this tree, it is mirrored in a number of Tcl data structures: -\begin{itemize} - \item - The \emph{snaccpath} is the 1:1 representation of the PDU's structure. - This is what in chapter~\ref{tcl-if-chapter} is always referred to as ``\emph{path}'' argument to most {\Tcl snacc} subcommands. - The snaccpath is a proper Tcl list. - \item - The \emph{treepath} is very similar to the snaccpath. - Its structure is the same as the snaccpath's, but its syntax and a few elements are different: - \begin{itemize} - \item - The components in a snaccpath are separated by ``~'' (space), in a treepath they are separated by ``/'' (slash). - This difference is not strictly necessary, but it helps to detect errors in argument passing as the {\Tcl snacc} commands will never accept any treepath for their path arguments. - \item - In a snaccpath, the elements of SET OF and SEQUENCE OF types are identified by their index. - In a treepath, another numeric id is used instead. - The reason for this becomes clear when we have a look at where the treepath is used and what would have to be done if the elements' list indices were used in the treepaths. - - The treepath is used in a number of places, for widget and variable names and for canvas item tags, all detailed in the below bulleted items. - - When an element of a SET OF or SEQUENCE OF type is deleted, the snaccpath's indices for the deleted element's successors have to be decremented to point to the same item; when an element is inserted, those indices need to be incremented. - As a consequence, the widget and variable names and the canvas item tags of all elements that follow the one element that has been deleted or inserted would have to be adjusted and all the names and tags of their descendants. - Even if these names and tags could easily be changed (they cannot), it would still be an enormous amount of work and the slow Tcl interpreter could need some seconds to complete this task. - This enormous labour can be avoided by introducing a table lookup: - - Every node of a SET OF or SEQUENCE OF type gets an idlist (identifier list). - This idlist is a Tcl list, its length is the same as there are elements in the ASN.1 data object. - Every idlist element corresponds to an element of the data object. - Whenever an element is deleted from the data object, the corresponding id from the idlist is removed as well; insertions are likewise performed in both the data object and the idlist. - The idlist contains numbers, zero for data objects that are not visually displayed on the canvas and locally unique non-zero numbers otherwise. - - When a data object is identified through its treepath, the id is extracted and the id's position is sought in the idlist. - The id's position in the idlist is the element's index for the snaccpath. - \end{itemize} - - The treepath is used to build the names of widgets that display a PDU's structure and content portions. - \item - The node labels and lines for the edges are canvas items, no full fledged widgets. - Canvas items can be given tags for identification purposes; the tags of an item are an ordered Tcl list. - Canvas items have a locally unique id, but as different items can have the same tag, item groups can be identified. - - Since all tags form an ordered Tcl list, individual items can be addressed:\\ - {\Tcl [lindex [\$canvas gettags \$id] \$index]}\\ - SnaccEd uses this mechanism to translate button clicks into paths: when a canvas item is clicked at, the canvas makes this item ``current'' and\\ - {\Tcl [\$canvas find withtag current]}\\ - returns the item's id. - The id is then used as described above to retrieve the tag list. - - The canvas line items that are used as edges get no tags. - - The canvas text items that make up the node labels and the canvas window items that contain the content editors get three tags. - The three tags are ordered from most general to most specific: - \begin{enumerate}\setcounter{enumi}{-1}% - \item - For node labels this tag has the form \emph{validity}-label. - The validity is either ``valid'' or ``void''. - Absent OPTIONAL components are ``void''. - Active node labels get the tag ``valid-label''. - In the procedure {\Tcl new\_file} this tag is used to bind the three pointer button events to the callback procedures {\Tcl prune\_or\_add\_children}, {\Tcl toggle\_editor} and {\Tcl set\_or\_add\_root}, respectively. - - For content editors this tag is simply ``edit'', because content editors can only be opened for valid nodes and therefore the validity would be redundant. - \item - This tag is the treepath. - It is the same for all canvas items for this node: the label and possibly the content editor. - This is the tag that is given to the tree widget. - The tree widget handles all canvas items with the same tag as a group: it uses their bounding box to calculate the tree layout and it keeps the relative distances of the group's items so that their internal layout persists any change in the tree's layout. - \item - This tag is a combination of the other two tags: it is the treepath, a colon and either ``label'' or ``edit''. - This tag is the most specific and it is used to address the individual canvas item, for example to check for a content editors existence. - No two items have the same value of this tag. - \end{enumerate} - \item - Content editors are not simple canvas items. - They are build from one or more widgets and this widget tree is put into a canvas window item. - The widgets have names of the form {\Tcl \$canvas.edit\$treepath}. - The leading \$canvas is the name of the canvas widget. - Widget names starting with that name are descendants of the canvas, here they are children. - The trailing \$treepath does not contain any dots and therefore Tk understands edit\$treepath as a single node in the widget tree. - \item - Most of the content editors modify a global variable, for example the entry widgets for INTEGER types or the radiobuttons for ENUMERATED types. - The variable's name is the simple composition {\Tcl var:\$treepath} that guarantees its uniqueness. - - SET and SEQUENCE types need a variable for each of their components: the component's name gets tacked to the end which yields {\Tcl var:\$treepath:\$name}. - - Named bits of BIT STRING types get similar variables, the bit value is put after the second colon. - The bits' toggle buttons operate on these variables. -\end{itemize} - -\begin{figure} -\begin{center} -\includegraphics[scale=.6]{recur} -\caption{`Recursive' data structures} -\label{recursion} -\end{center} -\end{figure} - -When button~2 is clicked on a node label, the procedure {\Tcl toggle\_editor} gets called: -\begin{itemize} - \item - checks whether the editor for the current node already exists. - - If it does, the editor is deleted. - - Otherwise, the editor is opened by creating a frame widget that is filled with an appropiate set of subwidgets. - The editor is supplied with the corresponding content portion from the ASN.1 file and a number of event bindings is installed that let the user modify the contents. - The frame is placed at the right place below the node name and the tree widget is called to adjust the layout. - Most of the changes to nodes containing simple ASN.1 types are detected using Tcl's trace mechanism. - For example, the entry widget for an INTEGER modifies a global variable. - The trace procedure that gets called upon every modification computes the snaccpath from the variable's name and modifies the ASN.1 file accordingly. - The only ASN.1 simple type that makes an exception to the rule is OCTET STRING. - Text widgets do not modify global variables and even if they did, copying the string back to the Snacc object for every key stroke is a waste of CPU time. - The text widget's contents is written back to the octet string when the widget receives a leave window event or, since Tk uses explicit focus (click-to-focus instead of focus-follows-pointer) and thus the widget's contents may be changed even after the pointer has left the window, it receives a focus out event. - - The structured ASN.1 types are modified explicitly, i.e. through button clicks. - The components are modified using their natural GUI counterparts. - \begin{itemize} - \item OPTIONAL members of SET and SEQUENCE types are allocated and deallcated by clicking on a checkbutton. - \item CHOICE members are selected by clicking on a radiobutton. - \item SET OF and SEQUENCE OF types are implemented as list and SnaccEd displays them using a list widget. - (This is not actually true. - Since the listbox widget allows only single selection or selection of multiple but contiguous entries, I replaced it with a text widget and with some event bindings and a tag for the selected items made it behave like a listbox widget with multiple selection. - A patch to the Tk~3.6 code that implements non-contiguous selections exists, but I didn't want to enforce the trouble of getting, patching and installing the Tk library again on anyone.) - \end{itemize} -\end{itemize} - -set\_or\_add\_root: - -When button~3 has been clicked on a node label, the callback procedure {\Tcl set\_or\_add\_root} will be called. - -\begin{itemize} - \item - The procedure checks whether the node that has been clicked at is the file's toplevel node. - In this case nothing can be done because there is no parent that could be shown or hidden. - \item - Otherwise, the routine checks whether the clicked node is currently displayed as the subtree's root. - In this case both the node's parent and grand parent are calculated. - The grand parent is not displayed, it merely corresponds to the tree widgets invisible root. - The parent is displayed by adding the node to the invisible grand parent. - The old root node and its siblings are aded by calling the {\Tcl ed\_expand} procedure. - {\Tcl ed\_expand} in turn calls {\Tcl ed\_addnode} for all the parent's children. - {\Tcl ed\_addnode} checks whether the node is already present on the canvas. - For the old root node this check yields true and the routine simply moves the node and all its descendants to below the new root node. - All other nodes are created as usually done when clicking on button~1. - \item - Otherwise, the node that has been clicked is to be shown as root. - This is simple: just tell the tree widget to display the node as root. - The tree widget removes everything else that does not belong to the subtree and calls the remove callback procedures for all these items. - The remove callback procedure is installed when a content editor is opened and is used to destroy the content editor frame widget and its subwidgets. -\end{itemize} - -selbox: - -The file-and-content-type-selection-box (short: selbox) serves different purposes. -The selbox contains three parts: a file name selection, a content type selection and a button row. -One of the two selection parts can be disabled (it will not even been shown). -In figure~\ref{selbox-pic} on page~\pageref{selbox-pic} both parts are visible. - -Both selections are necessary if a user wants to open a file. -The user is the only one to know which of the PDU types is contained in the file. - -Only the file selection is necessary to implement the usual ``Save As\dots'' functionality where the content type is already known. - -Only the content type selection is needed when the program wants the user to create a new file without giving it an external file name. -SnaccEd currently has no such function. -Instead, if a user upon opening a file does not select a file name, an internal file without an external file name gets created. - -The selection box is implemented in the file {\ufn \dots/tcl-lib/selbox.tcl}. -In this file, every procedure name starts with the prefix {\Tcl selbox\_} (except for the main entry point, {\Tcl selbox}). - -If the selbox was made non-modal, it would not break, because each individual selbox widget gets its own widget tree and all its status variables are put into a uniquely named array variable. -The code that generates the names is similar to the example on page~\pageref{tcl-name-space-example-code}. diff --git a/SecuritySNACCRuntime/doc/future-work.tex b/SecuritySNACCRuntime/doc/future-work.tex deleted file mode 100644 index 4662e587..00000000 --- a/SecuritySNACCRuntime/doc/future-work.tex +++ /dev/null @@ -1,80 +0,0 @@ -% file: .../doc/future-work.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/future-work.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: future-work.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:52 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:45 rj -% first check-in -% - -\chapter{\label{concl-chapter}Future Work} - -There are still many interesting and useful things that can be done to -Snacc. To name a few, Snacc could be improved to: -\begin{itemize} - \item{support the new features of 1993 ASN.1} - \item{generate forward encoders that use only the indefinite length form for constructed BER values} - \item{support new encoding rules such as the variants of Packed Encoding Rules (PER), - Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER).} - \item{parse complex values.} -\end{itemize} - -1993 ASN.1 has many improvements such as eliminating macros and adding -stronger mechanisms for adding type semantics. With stronger -semantics, the compiler can do more for the user. - -New encoding rules such as PER offer improved compression and -possibly better performance in certain cases. They can be added to -the compiler by adding a new backend to the compiler and providing a -runtime library. - -The ability to parse complex ASN.1 value notation values is useful for -protocol testing. It allows PDUs to be defined in a human readable -form and converted into their encoded representation. The combination -of an interpreted encoder and decoder with complex value parsing and -support for newer encoding rules would very useful for protocol -testing. - - -Here is a list of the things that I didn't get time to do: - -\begin{enumerate} - - \item {Add contexts to nibble memory. It's a pain if you decode - a table and then a value---you can't free the value without freeing - the table. This one should be relatively easy and only requires - modifications to the libraries and the example/user code.} - - \item Spiff up the table stuff. - \begin{enumerate} - \item {add subtype info (available in big parse tree) to tbl data struct} - \item {add enumerated types name/value info to tbl data struct} - \item {Add ANY DEFINED BY id to type mappings to tbl data struct (available in parse tree if using OBJECT-TYPE macro)} - \item {Support for C++ table drivers.} - \item {I'm sure there's more} - \end{enumerate} - - \item {existing bugs!} - \begin{enumerate} - \item {The hash stuff for ANY DEFINED BY mappings will bomb if you go more than 4 levels deep (unlikely, but\dots). Add linear chaining at the bottom level.} - \item {add the ability to handle CMIP style ANY DEFINED BY ids. Currently snacc gripes about this and stops.} - \begin{verbatim} - Eg ::= SEQUENCE { id Foo, ANY DEFINED BY id } - Foo::= CHOICE { a OBJECT IDENTIFIER, b INTEGER } - \end{verbatim} - \end{enumerate} - - \item {Bigger changes} - \begin{enumerate} - \item {punt yacc and lex and use PCCTS (Purdue Compiler Construction\dots) (better error reporting, easier to deal with (top down), etc.)} - \item {make an ASN.1 '93 version (no more macros!!!)} - \item {add PER.} - \item {make forwards encoders (use only indefinite lengths, though) for C, C++ and tables. Allows simpler buffer writing.} - \end{enumerate} - -\end{enumerate} diff --git a/SecuritySNACCRuntime/doc/idl-gen.tex b/SecuritySNACCRuntime/doc/idl-gen.tex deleted file mode 100644 index 3bb2d966..00000000 --- a/SecuritySNACCRuntime/doc/idl-gen.tex +++ /dev/null @@ -1,19 +0,0 @@ -% file: .../doc/idl-gen.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/idl-gen.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: idl-gen.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:52 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:42 rj -% first check-in -% - -\chapter{\label{idl-code-gen-chapter}IDL Code Generation} - -\section{\label{intro-IDL-section}Introduction} - -\emph{Under construction} diff --git a/SecuritySNACCRuntime/doc/install-sh b/SecuritySNACCRuntime/doc/install-sh deleted file mode 100644 index ab74c882..00000000 --- a/SecuritySNACCRuntime/doc/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -tranformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/SecuritySNACCRuntime/doc/intro-1.1.tex b/SecuritySNACCRuntime/doc/intro-1.1.tex deleted file mode 100644 index e9ab0491..00000000 --- a/SecuritySNACCRuntime/doc/intro-1.1.tex +++ /dev/null @@ -1,407 +0,0 @@ -% file: .../doc/intro-1.1.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/intro-1.1.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: intro-1.1.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:53 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:28 rj -% first check-in -% - -\chapter{\label{intro-1.1}Introduction to Snacc Release~1.1} - -Snacc compiles ASN.1 \cite{X.208} (Abstract Syntax Notation One) -modules into C, C++ or type tables. The generated C or C++ code -contains equivalent data structures and routines to convert values -between the internal (C or C++) representation and the corresponding -BER \cite{X.209} (Basic Encoding Rules) format. The name ``snacc'' is -an acronym for ``Sample Neufeld ASN.1 to C/C++ Compiler''. - -This compiler was written so I could do some encoding performance -research for my M.Sc. See \cite{Sample93-1}, or \cite{Sample93-2} for -the results of that research. A techreport will soo be available -via ftp from UBC, in the same directory as snacc. - -The ASN.1 data structure language can specify complex types such as -lists and recursively defined types. BER data values are defined -independently of any computer architecture, providing a universal data -value representation that is useful for sharing data in heterogeneous -networks. - -The process of converting an ASN.1 value from its C or C++ -representation into an equivalent BER data value is called encoding -and the reverse process is called decoding. This document was written -assuming that the reader is familiar ASN.1 and BER. Further -information on ASN.1 and BER can be found in \cite{ASN.1Book}, -\cite{ASN.1Overview}, \cite{X.208} and \cite{X.209}. - -Compiling ASN.1 into C is not a new idea but many other tools such as -UBC's CASN1 \cite{CASN1}, ISODE's PEPY/POSY \cite{ISODE}, and -commercial tools either do not parse ASN.1 '90, produce slow encoders -and decoders or are outrageously expensive. The aim of this tool is to -provide an ASN.1 compiler that parses ASN.1 '90, produces efficient -encoding and decoding routines and is freely available. Effort has -been made to make the generated encoders and decoders relatively easy -to fit into different software environments. - -The table driven encoders are useful for certain applications such as -protocol testing. They are also useful if you need to dynamically -load new ASN.1 definitions. It is also fairly simple to write your -own special ASN.1 tools based on tables (e.g. a protocol tester that -verifies that values conform to a given ASN.1 type definition). The -price of the flexibility is speed; they are slower (~4 times) than the -compiled C and C++ versions. - -Some of snacc's features include: -\begin {itemize} -\item {parses CCITT ASN.1 '90 including subtype notation} -\item {can compile and link inter-dependent ASN.1 modules (IMPORTS/EXPORTS)} -\item {some X.400 and SNMP macros are parsed} - -\item {macro {\em definitions} do not generate syntax errors but are -are not processed. The macro definitions are retained as a string -internally (if you want to modify the compiler to process them).} - -\item {value notation is parsed. OBJECT IDENTIFIERs, INTEGERs -and BOOLEANs are translated to C/C++ values. Any other value in \{\}'s -is kept as a string internally (if you want to modify the compiler to -process them).} - -\item {optionally supports ``;'' separated type or value definitions - in the ASN.1 source. This is useful for dealing with some macros and - other language ambiguities that introduce parsing problems.} -\item {ANY DEFINED BY types are supported via the SNMP OBJECT-TYPE macro} -\end{itemize} - -\section{\label{old-install-section}Installing snacc} - -First of all, if you haven't already done so, un-archive snacc to -produce the directory {\em snacc} and its contents. The following tools -are required to compile snacc: -\begin{itemize} -\item {\verb$lex$ or GNU's \verb$flex$ (\verb$flex$ is recommended)} -\item {\verb$yacc$ or GNU's \verb$bison$ (\verb$bison$ is recommended)} -\item {a C compiler and \verb$make$} -\end{itemize} - -Some versions of \verb$yacc$ will choke due to the large size of the -\verb$asn1.yacc$ file, however, I have had no problems with \verb$bison$. -Our \verb$yacc$ grammar for ASN.1 has 61 shift/reduce errors and 2 -reduce/reduce errors. Most of these errors were introduced when -certain macros were added to the compiler. Some of the shift/reduce -errors will require you to follow the offending macro in the ASN.1 -module with a semi-colon. The reduce/reduce errors were introduced by -macros that have ``Type or Value Lists'' because the NULL Type and -NULL values use the same symbol, ``NULL''. This is not a problem -since no real processing is done with the macros in question at the -present. - -\verb$Lex$ will work for the \verb$asn1.lex$ file but \verb$flex$ will typically -produce a smaller executable. Most versions of \verb$lex$ have a small -maximum token size that will cause problems for long tokens in the -ASN.1 source files, such as quoted strings. To avoid this problem, -increase the \verb$YYLMAX$ value in the generated {\em lex.yy.c} file to at least -2048. \verb$Flex$ does not seem to have this problem. - -The compiler and library C code has been written to support ANSI or -non-ANSI C\@. ANSI C is used by default; this can be configured in -\verb$snacc/c_include/asn_config.h$. - -By default, the compiler's makefiles use \verb$flex$, \verb$bison$ and -\verb$gcc$. If you wish to change these, edit the following files: - -\begin{verbatim} -snacc/src/makefile -snacc/src/c_lib/makefile -snacc/src/back_ends/c_gen/makefile -snacc/src/back_ends/c++_gen/makefile -\end{verbatim} - -The C runtime library uses \verb$gcc$, and its makefile is -\verb$snacc/c_lib/makefile$. The C++ runtime library uses \verb$g++$ -(\verb$gcc-2.2.3$) and its makefile is \verb$snacc/c++_lib/makefile$. -The type table library makefile uses \verb$gcc$ and is -\verb$snacc/tbl_lib/makefile$. - -Finally, to compile \verb$snacc$ and the C and C++ runtime libraries, -type the following at the shell prompt: - -\begin{verbatim} -%1 cd snacc -%2 make all -\end{verbatim} - -If you wish to install only the C (including type tables) or only the -C++ versions of the library, type \verb$make c$ or \verb$make c++$, -respectively, instead of \verb$make all$. If the make succeeds, the -snacc binary, {\em snacc}, should be in the \verb$snacc/bin/$ -directory, the C runtime libraries, {\em libasn1csbuf.a}, {\em -libasn1cebuf.a}, and {\em libasn1cmbuf.a}, should be in the -\verb$snacc/c_lib$ and the C++ runtime library, {\em libasn1c++.a} -should be in the \verb$snacc/c++_lib$. The type table library, {\em -libasn1tbl.a} will be in \verb$snacc/tbl_lib$. The type table tools, -{\em ptbl}, {\em pval} and {\em mkchdr} will be in \verb$snacc/bin$. -The \verb$.o$ and other junk files will have been removed. - -After compiling the libraries, you can test the library routines with -\linebreak \verb$snacc/c_examples/test_lib/test_lib$ or \linebreak -\verb$snacc/c++_examples/test_lib/test_lib$. These programs run -simple encoding and decoding tests on all of the library types. You -can test the snacc compiler with the other examples. - -A manual page that contains information on running snacc can be found in -\verb$snacc/doc/snacc.1$. This should be installed in section~1 of -the manual. You can use \verb$nroff -man snacc.1$ to view it if you -don't want to install it. - - -\section{\label{old-run-section}Running snacc} - -Snacc is typically invoked from the shell command line and has the synopsis: -\begin{verbatim} -snacc [-h] [-P] [-t] [-e] [-d] [-p] [-f] - [ -c | -C | -T
] - [-u ] - [-mf ] - [-l ] - -\end{verbatim} - -Snacc generates C or C++ source code for BER encode and decode -routines as well as print and free routines for each type in the given -ASN.1 modules. Alternatively, snacc can produce type tables that can -be used for table based/interpreted encoding and decoding. The type -table based methods tend to be slower than their C or C++ counterparts -but they tend use less memory (table size vs. C/C++ object code). - -Most of the 1990~ASN.1 features are parsed although some do not affect -the generated code. Fairly rigourous error checking is performed on -the ASN.1 source; any errors detected will be reported (printed to -\verb$stderr$). - -Each file in the ASN.1 file list should contain a complete ASN.1 -module. ASN.1 modules that use the IMPORTS feature must be compiled -together (specify all necessary modules in the ASN.1 file list). The -generated source files will include each module's header file in the -command line order. This makes it important to order the modules from -least dependent to most dependent on the command line to avoid type -ordering problems. Currently, snacc assumes that each ASN.1 file -given on the command line depends on all of the others on the command -line. No attempt is made to only include the header files from -modules referenced in the import list for that module. - -If the target language is C, snacc will generate a \verb$.h$ and -\verb$.c$ file for each specified ASN.1 module. If the target -language is C++, snacc will generate a \verb$.h$ and \verb$.C$ file -for each module. The generated file names will be derived from the -module names. - -The command line options are: -% zap bullet for items -%\def\labelitemi{} - -\begin{description} -\item[-h ] {short for ``help'', prints a synopsis of snacc -and exits.} - -\item[-c ] {causes snacc to generate C source code. -This is the default behaviour of snacc if neither of the \verb$-c$ or -\verb$-C$ options are given. Only one of the \verb$-c$, \verb$-C$ or -\verb$-T$ options should be specified.} - -\item[-C ] {causes snacc to generate C++ source code.} - -\item[-T {\em file}] {causes snacc to generate type tables and -write them to the given file {\em file}.} - -\item[-P ] {causes snacc to print the parsed ASN.1 -modules to \verb$stdout$ after the types have been linked, sorted, and -processed. This option is useful for debugging snacc and observing -the modifications snacc performs on the types to make code generation -simpler.} -\end{description} - -The options, \verb$-t, -v, -e, -d, -p,$ and \verb$-f$ affect -what types and routines go into the generated source code. -These options do not affect type table generation. If none of -them are given on the command line, snacc assumes that all of them are -in effect. For example, if you do not need the Free or Print -routines, you should give the \verb$-t -v -e -d$ options to snacc. -This lets you trim the size of the generated code by removing -unnecessary routines; the code generated from large ASN.1 -specifications can produce very large binaries. - -\begin{description} -\item[-t ] {causes snacc to generate type definitions in the -target language for each ASN.1 type.} - -\item[-v ] {causes snacc to generate value definitions in the -target language for each ASN.1 value. Currently value definitions are -limited to INTEGERs, BOOLEANs and OBJECT IDENTIFIERs.} - -\item[-e ] {causes snacc to generate encode routines in the -target language for each ASN.1 type.} - -\item[-d ] {causes snacc to generate decode routines in the -target language for each ASN.1 type.} - -\item[-p ] {causes snacc to generate print routines in the -target language for each ASN.1 type.} - -\item[-f ] {causes snacc to generate free routines in the -target language for each ASN.1 type. This option only works when the -target language is C\@. The free routines hierarchically free C values. -A more efficient approach is to use the provided nibble-memory system. -The nibble memory permits freeing an entire decoded value without -traversing the decoded value. This is the default memory allocator -used by snacc generated decoders. See file -\verb$snacc/c_include/asn_config.h$ to change the default memory -system. For more information on the memory management see Section~\ref{lib-mem-C-section}.} - -\item[-u {\em file}] {causes snacc to read the useful types -definitions from the ASN.1 module in file {\em file} -for linking purposes. For some ASN.1 specifications, such as SNMP, -the useful types are not needed. The types in the given useful types -file are globally available to all modules; a useful type definition -is overridden by a local or explicitly imported type with the same -name. The useful type module can be found in -\verb$snacc/asn1specs/asn-useful.asn1$ and contains: - - -\begin{itemize} -\setlength{\itemsep}{0pt} -\setlength{\parsep}{0pt} -\nspace{0} -\item ObjectDesccriptor -\item NumericString -\item PrintableString -\item TeletexString -\item T61String -\item VideoTexString -\item IA5String -\item GraphicString -\item ISO646String -\item GeneralString -\item UTCTime -\item GeneralizedTime -\item EXTERNAL -\end{itemize}} - - -\item[-mf {\em number}] {causes the names of the generated source -files to have a maximum length of {\em number} characters, including -their suffix. The {\em number} argument must be at least~3. This option -is useful for supporting operating systems that only support short -file names. A better solution is to shorten the module name of each -ASN.1 module.} - -\item[-l {\em number}] {this is fairly obscure but may be useful. Each -error that the decoders can report is given an id number. The number -{\em number} is where the error ids start decreasing from as they are -assigned to errors. The default is -100 if this option is not given. -Avoid using a number in the range -100 to 0 since they may conflict -with the library routines' error ids. If you are re-compiling the -useful types for the library use -50. Another use of this option is -to integrate newly generated code with older code; if done correctly, -the error ids will not conflict.} - -\end{description} - -Since ASN.1 has different scoping rules than C and C++, some name munging -is done for types, named-numbers etc. to eliminate conflicts. -Some capitalization schemes were chosen to fit common C programming -style. For all names, dashes in the ASN.1 source are converted to -underscores. See Sections \ref{naming-C-section} and \ref{naming-C++-section} -for more naming information. - -The module name is used as a base name for the generated source file -names. It will be put into lowercase and dashes will be replaced with -underscores. Module names that result in file names longer than -specified with the \verb$-mf$ option will be truncated. If the -\verb$-mf$ option was not given, file names will be truncated if they -are too long for the target file system. You may want to shorten long -module names to meaningful abbreviations. This will avoid file name -conflicts for module names that are truncated to the same substring. -Any module name and file name conflicts will be reported. - -If your ASN.1 modules have syntactic or semantic errors, each error -will be printed to \verb$stderr$ along with the file name and line number of -where it occurred. These errors are usable by GNU emacs compiling -tools. See the next chapter for more information on the types of -errors snacc can detect. - -More errors can be detected and reported in a single compile if type -and value definitions are separated by semi-colons. Separating type -and value definitions with semi-colons is not required, and if used, -need not be used to separate all type and value definitions. -Semi-colons are necessary after some macros that introduce ambiguity. -In general, if you get a parse error you can't figure out, try -separating the surrounding type/value definitions with semicolons. - - -\subsection{Known Bugs} - -Snacc has problems with the following case: - -\begin{verbatim} -Foo ::= SEQUENCE -{ - id IdType, - val ANY DEFINED BY id -} - -IdType ::= CHOICE -{ - a INTEGER, - b OBJECT IDENTIFIER -} -\end{verbatim} - -The error checking pass will print an error to the effect that the id -type must be INTEGER or OBJECT IDENTIFER\@. To fix this you must modify -the error checking pass as well as the code generation pass. To be -cheap about it, disable/fix the error checking and hand modify the -generated code. - -The hashing code used for handling ANY DEFINED BY id to type mappings -will encounter problems if the hash table goes more than four levels -deep (I think this is unlikely). To fix this just add linear chaining -at fourth level. - -On the deficiency side of things, the C++ classes really need to have -free methods defined for them. (Unless you have replaced new with -something like nibble memory) - -\section{\label{old-bug-section}Reporting Bugs and Your Own Improvements} - -This (1.1) is the final release of snacc (I have finished my M.Sc). -Gerald Neufeld \verb$$ was my supervisor but he -does not have time to deal with support (it is all my code anyway). -Luckily, a colleague has kindly offered to receive the bug reports and -to coordinate work done by others (i.e. you). His name is Barry -Brachman \verb$$. He did not write the code -(35,000+ lines of C) but he has used snacc for X.500 work. He may be -able to point you to someone who has fixed or encountered the same -bug. Anyway, be nice to him, it's not his job. - -Even though this is the second release of snacc, bugs are still -likely. In fact, this release was quite rushed so there are probably -lots of stupid installation bugs etc. If you find some bugs or have -other comments, please send email to \verb$snacc-bugs@cs.ubc.ca$ -(these will get to Barry and Gerald). Please include the offending -ASN.1 source, the command line options you were using and the hardware -and operating system configuration. - -If you are really keen and hack in new goodies, please share. Send -them to Barry or \verb$snacc-bugs@cs.ubc.ca$. Look in -\verb$snacc/README.future$ for things you could work on. - -As I mentioned, I have entered the real world. I am now working with -Open Systems Solutions (based in New Jersey). If your application -needs a commercially developed and supported ASN.1 compiler, try -calling 1-609-987-9073 (Yeah, I know this is a plug, but it's a good -company). diff --git a/SecuritySNACCRuntime/doc/intro-1.2.tex b/SecuritySNACCRuntime/doc/intro-1.2.tex deleted file mode 100644 index 8bf3a601..00000000 --- a/SecuritySNACCRuntime/doc/intro-1.2.tex +++ /dev/null @@ -1,422 +0,0 @@ -% file: .../doc/intro-1.2.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/intro-1.2.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: intro-1.2.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:53 aram -% Originals from SMIME Free Library. -% -% Revision 1.2 1997/02/16 16:49:30 rj -% made return *this after calling abort()'' a compile time option. -% -% Revision 1.1 1997/01/01 22:47:30 rj -% first check-in -% - -\chapter{\label{intro-1.2}Introduction} - -Snacc compiles ASN.1 \cite{X.208} (Abstract Syntax Notation One) modules into C, C++, CORBA IDL \cite{corba} or type tables. -The generated C or C++ code contains equivalent data structures and -routines to convert values between the internal (C or C++) -representation and the corresponding BER \cite{X.209} (Basic Encoding Rules) format. -The name ``snacc'' is an acronym for ``Sample Neufeld ASN.1 to C/C++ Compiler''. - -This is release 1.2rj\footnote{\emph{1.2} since it is the successor of 1.1 and \emph{rj} as i don't think that I'm the only one who worked on Snacc.} of Snacc. -This chapter lists only the differences to the original author's last release, Snacc~1.1. -The list in this chapter is incomplete---for a more thorough enumeration, see the file {\ufn .../ChangeLog}. - -New features include: -\begin{itemize} -\item - The output files generated get names derived from their input file's name, with only the suffix replaced. - This eases makefile writing, as now you can use simple suffix rules or other forms of filename pattern matching. - The old behaviour, where the output files got their name from the ASN.1 module name, can be retained by using the {\ufn -mm} command line switch to {\ufn snacc}. -\item - The C++ backend generates code with a much more complete set of constructors, destructors and assignment operators. -\item - The C++ backend can supply the generated C++ classes with \emph{meta} information about their own structure. - This information can be used to build interpreted interfaces; the Snacc 1.2rj distribution contains a Tcl interface that uses this meta information as well as a Tcl script (that uses the Tcl interface) for a simple editor. -\item - Snacc has successfully been ported to Linux and Alpha OSF/1, and should be both byte order and 64 bit clean. -\item - A new backend that generates CORBA IDL (work-in-progress, not even alpha) -\end{itemize} - -The makefiles have been rewritten. -The old ones removed the {\ufn .o} files after successful compilation, and thus, for every tiny code change, a full recompilation took place! -With the new set of makefiles, only those files that need to be remade are. -Following usual conventions, the phony targets depend, check, install, clean and clobber have been added. -\newline -NOTE: the makefiles still are not safe for parallel making. -\\ -See Appendix~\ref{makefile-sect} for some explanations of some the makefile tricks. -\\ -If you've got problems with the makefiles, please refer to the appendix! - -The 1.1 release used five config.h files, and three almost identical copies of the ASN.1 C library. -They have all been merged in the file {\ufn \dots/snacc.h}. -A very small number (currently three) of compilation switches has been put into {\ufn \dots/policy.h}. - -The previous release produced huge virtual inline functions. -Due to their size, these inlines wouldn't get inlined anyway. -Virtual functions don't get inlined (they get referenced via pointer in the virtual function table). -Due to their size they wouldn't offer any speed advantage (the function call overhead diminishes). -Instead, the compiler generated static functions in every {\ufn .C} file were the {\ufn .h} file is included! -This inflates the {\ufn .o} files and executables real quick (I'm speaking of MBytes per executable). -These functions have been turned into normal functions. - -\section{\label{install-section}Configuring and Installing Snacc} - -First of all, if you haven't already done so, un-archive Snacc to -produce the directory {\ufn snacc-1.2rj.\textit{patchlevel}} and its contents. -The directory {\ufn snacc-1.2rj.\textit{patchlevel}} will henceforth be referred to as ``{\ufn \dots}''. -The following tools are required to compile Snacc: -\begin{itemize} - \item {\ufn make} (GNU {\ufn make} is recommended) - \item {\ufn patch} (for a tiny patch in {\ufn \dots/c-lib/}) - \item {\ufn makedepend} or a look-alike (all of them have their advantages and disadvantages, it is hard to recommend any of them, see below) - \item {\ufn lex} or GNU's {\ufn flex} ({\ufn flex} is recommended) - \item {\ufn yacc} or GNU's {\ufn bison} ({\ufn bison} is recommended) - \item a C compiler (it doesn't have to support ANSI, K\&R will do) -\end{itemize} - -Some versions of {\ufn yacc} may choke due to the large size of the -{\ufn parse-asn1.y} file, however, we have had no problems with {\ufn bison}. -Our {\ufn yacc} grammar for ASN.1 has 61 shift/reduce errors and 2 -reduce/reduce errors. Most of these errors were introduced when -certain macros were added to the compiler. Some of the shift/reduce -errors will require you to follow the offending macro in the ASN.1 -module with a semi-colon. The reduce/reduce errors were introduced by -macros that have ``Type or Value Lists'' because the NULL Type and -NULL values use the same symbol, ``NULL''. This is not a problem -since no real processing is done with the macros in question at the -present. - -{\ufn Lex} will work for the {\ufn lex-asn1.l} file but {\ufn flex} will typically -produce a smaller executable. Most versions of {\ufn lex} have a small -maximum token size that will cause problems for long tokens in the -ASN.1 source files, such as quoted strings. To avoid this problem, -increase the {\C YYLMAX} value in the generated {\ufn lex-asn1.c} file to at least -2048. {\ufn Flex} does not seem to have this problem. - -The configuration process has been simplified (at least for the installer of Snacc ;-) by the use of GNU autoconf. - -The only file has may have to be edited is {\ufn \dots/policy.h}. -It contains a few compilation switches you may want to toggle. - -The behaviour of makedepend has been changed from X11R5 to R6. -The new version keeps the source files' dirname and replaces the suffix only, the old version removed the dirname. -The makefiles expect the new behaviour. -If you've still got the R5 makedepend, the compiler's dependencies will be useless. -(If you only install the code and don't make any source code changes, this won't hurt you.) -If you haven't got {\ufn makedepend}, you can use any of the look-alikes, which often are {\ufn sh}-scripts calling the compiler with the {\ufn -M}-switch. -If you don't plan to make any source code changes, you can replace {\ufn makedepend} with {\ufn /bin/true}. -\newline -Warning: MIT X11's makedepend is broken, in both R5 and R6. -It silently does not produce any output for many of Snacc's C++ files (in {\ufn \dots/c++-lib/}). -\newline -The C compiler called with the {\ufn -M}-switch gives much better results, but is \emph{much} slower. - -The Snacc compiler and library C code has been written to support ANSI or non-ANSI C\@. -The configuration script tries to find out whether your C compiler understands ANSI C\@. - -The configuration script generates two files: -\begin{description} - \item[{\ufn \dots/makehead}] gets included by all makefiles. - It contains a lot of definitions used by make. - \item[{\ufn \dots/config.h}] contains all the machine, operating system, compiler and environment dependent settings. - It is included by {\ufn \dots/snacc.h}. -\end{description} - -The C++ runtime library is known to compile with both {\ufn gcc 2.5.8} and {\ufn gcc 2.6.3}. -The latter has the {\C bool} type built-in (which the configuration script automatically detects). - -Finally, to compile {\ufn snacc} and the C and C++ runtime libraries, -type the following at the shell prompt: - -\begin{verbatim} -%1 cd snacc-1.2rj.* -%2 ./configure -%3 make -\end{verbatim} - -If you wish to install only the C (including type tables) or only the -C++ versions of the library, type {\ufn make c} or {\ufn make c++}, -respectively, instead of {\ufn make}. If the make succeeds, the -{\ufn snacc} binary should be present as {\ufn \dots/compiler/snacc}, -the C runtime libraries, {\ufn libasn1csbuf.a}, -{\ufn libasn1cebuf.a}, {\ufn libasn1cmbuf.a} and {\ufn libasn1ctbl.a}, should be in -{\ufn \dots/c-lib/} and the C++ runtime library, {\ufn libasn1c++.a} -(and, if you compiled with the Tcl option enabled, -another runtime library, {\ufn libasn1tcl.a}), -should be in {\ufn \dots/c++-lib/}. -The type table tools, -{\ufn ptbl}, {\ufn pval} and {\ufn mkchdr}, will be in their respective directories under {\ufn \dots/tbl-tools/}. - -After compiling the libraries, you can test the library routines by calling {\ufn make check} -(or by calling {\ufn make c-check} or {\ufn make c++-check} to test the C or C++ library routines only, respectively). - -Manual pages that contain information on running {\ufn snacc} and the type table tools can be found in {\ufn \dots/doc/}. - -To install Snacc, you can call {\ufn make install} (or {\ufn make c-install} or {\ufn make c++-install}, respectively). -This installs the snacc compiler binary, the libraries, the {\ufn .h} and {\ufn .asn1} files, the type table tools, as well as the manual pages into the usual directories. - -To remove the {\ufn .o} and other intermediate files, you can call {\ufn make clean}. -To remove the binaries, libraries and all other generated files as well, call {\ufn make clobber}. - -\section{\label{run-section}Running Snacc} - -Snacc is typically invoked from the shell command line and has the synopsis: -\begin{verbatim} -snacc [-h] [-P] [-t] [-e] [-d] [-p] [-f] - [ -c | -C | -idl | -T
] - [-meta .[,...]] [-mA | -mC] - [-tcl .[,...]] - [-u ] - [-mm] [-mf ] - [-l ] - [-novolat] - -\end{verbatim} - -Snacc generates C or C++ source code for BER encode and decode -routines as well as print and free routines for each type in the given -ASN.1 modules. Alternatively, snacc can produce type tables that can -be used for table based/interpreted encoding and decoding. The type -table based methods tend to be slower than their C or C++ counterparts -but they tend use less memory (table size vs. C/C++ object code). - -Snacc may also be used to generate CORBA IDL\@. -This part of Snacc is very new and I would rate it as pre-alpha. - -The {\ufn -meta}, {\ufn -mA}, {\ufn -mC} and {\ufn -tcl} options are only present when the Tcl and Tk libraries where found at configuration time. - -Most of the 1990 ASN.1 features are parsed although some do not affect -the generated code. Fairly rigourous error checking is performed on -the ASN.1 source; any errors detected will be reported (printed to -{\C stderr}). - -Each file in the ASN.1 file list should contain a complete ASN.1 -module. ASN.1 modules that use the IMPORTS feature must be compiled -together (specify all necessary modules in the ASN.1 file list). The -generated source files will include each module's header file in the -command line order. This makes it important to order the modules from -least dependent to most dependent on the command line to avoid type -ordering problems. Currently, snacc assumes that each ASN.1 file -given on the command line depends on all of the others on the command -line. No attempt is made to only include the header files from -modules referenced in the import list for that module. - -If the target language is C, snacc will generate a {\ufn .h} and {\ufn .c} file for each specified ASN.1 module. -If the target language is C++, snacc will generate a {\ufn .h} and {\ufn .C} file for each module. -If the target language is CORBA IDL, snacc will generate an {\ufn .idl} file for each module. -The generated file names will be derived from the module's filenames, or from the -module names if the {\ufn -mm} command line switch has been given. - -The command line options are: - -\begin{description} - \item[--h ] {short for ``help'', prints a synopsis of snacc and exits.} - - \item[--c ] {causes snacc to generate C source code. - This is the default behaviour of snacc if neither of the {\ufn -c} or {\ufn -C} options are given. - Only one of the {\ufn -c}, {\ufn -C}, {\ufn -idl} or {\ufn -T} options should be specified.} - - \item[--C ] {causes snacc to generate C++ source code.} - - \item[--novolat] {causes snacc to generate C++ ``{\C return *this}'' - after calling {\C abort()}. (Some broken compilers don't know about - volatile functions, or their abort() isn't correctly typed.)} - - \item[--idl ] {causes snacc to generate CORBA IDL source code.} - - \item[--T \emph{file}] {causes snacc to generate type tables and write them to the given file \emph{file}.} - - \item[--meta \emph{types}] - causes snacc to generate C++ classes with type meta information. - Requires C++ functionality and therefore implies {\ufn -C} (C++ code generation). - - The \emph{types} denote the PDUs and have the following syntax: a comma-separated list of pairs of: module name, a dot, and a type name from that module. (Example: {\ufn snacc -tcl M1.T-a,M-2.Tb mod1.asn1 m2.asn1}) - - \item[--mA \textnormal{and} --mC] - causes the metacode to use identifiers as defined in the ASN.1 source files or as used in the generated C++ code, respectively. - (It defaults to {\ufn -mC}.) - - \item[--tcl \emph{types}] - causes snacc to generate functions for a Tcl interface. - Needs the type meta information and thus implies {\ufn -meta} (see above). - The {\ufn -meta} option can and should be omitted, the \emph{types} are as for the {\ufn -meta} option (the \emph{types} arguments are additive, in case you specify both options). - - \item[--P ] {causes snacc to print the parsed ASN.1 modules to {\C stdout} after the types have been linked, sorted, and processed. - This option is useful for debugging snacc and observing the modifications snacc performs on the types to make code generation simpler.} -\end{description} - -The options, {\ufn -t, -v, -e, -d, -p,} and {\ufn -f} affect -what types and routines go into the generated source code. -These options do not affect type table generation. If none of -them are given on the command line, snacc assumes that all of them are -in effect. For example, if you do not need the Free or Print -routines, you should give the {\ufn -t -v -e -d} options to snacc. -This lets you trim the size of the generated code by removing -unnecessary routines; the code generated from large ASN.1 -specifications can produce very large binaries. - -\begin{description} -\item[--t ] - causes snacc to generate type definitions in the target language for each ASN.1 type. - -\item[--v ] - causes snacc to generate value definitions in the target language for each ASN.1 value. - Currently value definitions are limited to INTEGERs, BOOLEANs and OBJECT IDENTIFIERs. - -\item[--e ] - causes snacc to generate encode routines in the target language for each ASN.1 type. - -\item[--d ] - causes snacc to generate decode routines in the target language for each ASN.1 type. - -\item[--p ] - causes snacc to generate print routines in the target language for each ASN.1 type. - -\item[--f ] - causes snacc to generate free routines in the target language for each ASN.1 type. - This option only works when the target language is C\@. - The free routines hierarchically free C values. - A more efficient approach is to use the provided nibble-memory system. - The nibble memory permits freeing an entire decoded value without traversing the decoded value. - This is the default memory allocator used by snacc generated decoders. - See file {\ufn \dots/c-lib/inc/asn-config.h} to change the default memory system. - For more information on the memory management see Section~\ref{lib-mem-C-section}. - -\item[--u \emph{file}] - causes snacc to read the useful types definitions from the ASN.1 module in file \emph{file} for linking purposes. - For some ASN.1 specifications, such as SNMP, the useful types are not needed. - The types in the given useful types file are globally available to all modules; a useful type definition is overridden by a local or explicitly imported type with the same name. - The useful type module can be found in {\ufn \dots/asn1specs/asn-useful.asn1} and contains: - \begin{itemize} - \setlength{\itemsep}{0pt} - \setlength{\parsep}{0pt} - \nspace{0} - \item ObjectDesccriptor - \item NumericString - \item PrintableString - \item TeletexString - \item T61String - \item VideoTexString - \item IA5String - \item GraphicString - \item ISO646String - \item GeneralString - \item UTCTime - \item GeneralizedTime - \item EXTERNAL - \end{itemize} - -\item[--mm] - This switch is supplied for backwards compatibility. - Snacc versions 1.0 and 1.1 produced files with names generated from the ASN.1 module name contained in the input file. - Snacc 1.2rj by default retains the input file name and replaces the suffix only. - The new behaviour makes {\ufn makefile} writing easier, as with modern {\ufn make}s, pattern matching can be used. - -\item[--mf \emph{number}] - causes the names of the generated source files to have a maximum length of \emph{number} characters, including their suffix. - The \emph{number} argument must be at least 3. - This option is useful for supporting operating systems that only support short file names. - A better solution is to shorten the module name of each ASN.1 module. - -\item[--l \emph{number}] - this is fairly obscure but may be useful. - Each error that the decoders can report is given an id number. - The number \emph{number} is where the error ids start decreasing from as they are assigned to errors. - The default is -100 if this option is not given. - Avoid using a number in the range -100 to 0 since they may conflict with the library routines' error ids. - If you are re-compiling the useful types for the library use -50. - Another use of this option is to integrate newly generated code with older code; if done correctly, the error ids will not conflict. - -\end{description} - -Since ASN.1 has different scoping rules than C and C++, some name munging -is done for types, named-numbers etc. to eliminate conflicts. -Some capitalization schemes were chosen to fit common C programming -style. For all names, dashes in the ASN.1 source are converted to -underscores. See Sections \ref{naming-C-section} and \ref{naming-C++-section} -for more naming information. - -If the {\ufn -mm} switch has been given, the module name is used as a base name for the generated source file -names. It will be put into lowercase and dashes will be replaced with -underscores. Module names that result in file names longer than -specified with the {\ufn -mf} option will be truncated. If the -{\ufn -mf} option was not given, file names will be truncated if they -are too long for the target file system. You may want to shorten long -module names to meaningful abbreviations. This will avoid file name -conflicts for module names that are truncated to the same substring. -Any module name and file name conflicts will be reported. - -If your ASN.1 modules have syntactic or semantic errors, each error -will be printed to {\C stderr} along with the file name and line number of -where it occurred. These errors are usable by GNU emacs compiling -tools. See the next chapter for more information on the types of -errors snacc can detect. - -More errors can be detected and reported in a single compile if type -and value definitions are separated by semi-colons. Separating type -and value definitions with semi-colons is not required, and if used, -need not be used to separate all type and value definitions. -Semi-colons are necessary after some macros that introduce ambiguity. -In general, if you get a parse error you can't figure out, try -separating the surrounding type/value definitions with semicolons. - - -\subsection{Known Bugs} - -\begin{itemize} - \item - Snacc has problems with the following case: - \begin{ASNcode} - Foo ::= SEQUENCE\\ - \{\+\\ - id IdType,\\ - val ANY DEFINED BY id\-\\ - \}\\ - \\ - IdType ::= CHOICE\\ - \{\+\\ - a INTEGER,\\ - b OBJECT IDENTIFIER\-\\ - \} - \end{ASNcode} - - The error checking pass will print an error to the effect that the id - type must be INTEGER or OBJECT IDENTIFER\@. To fix this you must modify - the error checking pass as well as the code generation pass. To be - cheap about it, disable/fix the error checking and hand modify the - generated code. - - \item - The hashing code used for handling ANY DEFINED BY id to type mappings - will encounter problems if the hash table goes more than four levels - deep (I think this is unlikely). To fix this just add linear chaining - at fourth level. - - \item - The {\ufn \dots/configure} script should check whether the machine's floating point format is IEEE or whether the IEEE library exists. - - \item - The C++ library severly lacks a convenient buffer management class that automatically expands like the C libraries' ExpBuf. - What use is an efficient buffer management when you have got to build a loop a round snacc's encoding routine that reallocates larger buffers until the result fits? - - \item - Where this document describes personal experiences, it is usually unclear to which author `I' refers. - (One way to find out is to look at snacc~1.1's documentation.) - -\end{itemize} - -\section{\label{bug-section}Reporting Bugs and Your Own Improvements} - -Snacc 1.1 was Michael Sample's final release. -While he is watching Snacc's development, he isn't actively developing it himself. - -Since there are quite a number of changes from release 1.1 to 1.2rj, bug reports and new features are best sent to me. -I can be reached as \texttt{Robert Joop } or \texttt{}. diff --git a/SecuritySNACCRuntime/doc/makefile b/SecuritySNACCRuntime/doc/makefile deleted file mode 100644 index f828c22e..00000000 --- a/SecuritySNACCRuntime/doc/makefile +++ /dev/null @@ -1,237 +0,0 @@ -# file: .../doc/makefile -# -# - build the user documentation, snacc-*.ps -# - install the various manual pages -# -# MS 92 -# use nroff -man snacc.1 to see what the man page, snacc.1, looks like -# -# if latex bombs unexplainably, try 'make clean' followed by 'make' -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:10 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:53 aram -# Originals from SMIME Free Library. -# -# Revision 1.4 1997/06/19 09:28:30 wan -# Disabled making new doc due to new version string. -# -# Revision 1.3 1997/02/16 19:23:13 rj -# typo fixed -# -# Revision 1.2 1997/01/02 08:51:51 rj -# order of two files reversed to reflect the order in snacc.tex -# -# Revision 1.1 1997/01/01 22:28:25 rj -# first check-in -# - -include ../makehead - -TOP = .. - -MANUALS.1 = \ - snacc.1 \ - mkchdr.1 \ - ptbl.1 \ - pval.1 \ - snacced.1 - -MANUALS.n = \ - snacc.n - -TEX_ROOT = snacc.tex - -TEX_SRC = \ - $(TEX_ROOT) \ - misc-hyph.tex \ - version.tex \ - intro-1.2.tex \ - intro-1.1.tex \ - design.tex \ - c-gen.tex \ - c-lib.tex \ - c++-gen.tex \ - c++-lib.tex \ - meta.tex \ - tcl.tex \ - editor.tex \ - idl-gen.tex \ - ttab.tex \ - modifying.tex \ - future-work.tex \ - asn1-defs.tex \ - coding.tex \ - makefile.tex - -AUX = \ - snacc.aux \ - version.aux \ - intro-1.1.aux \ - intro-1.2.aux \ - design.aux \ - c-gen.aux \ - c-lib.aux \ - c++-gen.aux \ - c++-lib.aux \ - meta.aux \ - tcl.aux \ - editor.aux \ - idl-gen.aux \ - ttab.aux \ - modifying.aux \ - future-work.aux \ - asn1-defs.aux \ - coding.aux \ - makefile.aux - -side = \ - $(AUX) \ - snacc.toc - -side.cmp = \ - snacc.aux~ \ - version.aux~ \ - intro-1.1.aux~ \ - intro-1.2.aux~ \ - design.aux~ \ - c-gen.aux~ \ - c-lib.aux~ \ - c++-gen.aux~ \ - c++-lib.aux~ \ - meta.aux~ \ - tcl.aux~ \ - editor.aux~ \ - idl-gen.aux~ \ - ttab.aux~ \ - modifying.aux~ \ - future-work.aux~\ - asn1-defs.aux~ \ - coding.aux~ \ - makefile.aux~ \ - snacc.toc~ - -BIB_SRC = snacc.bib corba.bib tcl.bib -BIB_BBL = snacc.bbl - -EPS = \ - example.eps \ - recur.eps \ - selbox.eps \ - simple.eps \ - struct.eps \ - str-popup.eps \ - list-popup.eps \ - -DVI = snacc.dvi -A4.PS = snacc-a4.ps -A5.PS = snacc-a5.ps -A6.PS = snacc-a6.ps -BOOK.PS = snacc-book.ps - -DISTFILES = \ - makefile \ - tumble.sed \ - $(MANUALS.1) \ - $(MANUALS.n) \ - $(TEX_SRC) \ - $(BIB_SRC) \ - $(A5.PS) - -#------------------------------------------------------------------------------- - -default:: a4 -#default:: $(A5.PS) $(BOOK.PS) -all:: a4 a5 a6 book - -book:: $(BOOK.PS) -$(BOOK.PS): $(A4.PS) tumble.sed - $(REASON) - < $< $(PSBOOK) | $(PSNUP) -2 | sed -f tumble.sed > $@~ - mv $@~ $@ - -a5:: $(A5.PS) -$(A5.PS): $(A4.PS) - $(REASON) - < $< $(PSNUP) -2 > $@~ - mv $@~ $@ - -a6:: $(A6.PS) -$(A6.PS): $(A4.PS) - $(REASON) - < $< $(PSNUP) -4 > $@~ - mv $@~ $@ - -a4:: $(A4.PS) -$(A4.PS): $(DVI) - $(REASON) -# $(DVIPS) -f $< > $@~ -# mv $@~ $@ -# dvips doesn't return a useful return code: - $(DVIPS) -f $< > $@ -# $(PSPREVIEW) $@ - -dvi:: $(DVI) -$(DVI): $(TEX_SRC) $(BIB_BBL) $(side.cmp) $(EPS) - $(REASON) - trap "$(RM) $@ `basename $(TEX_ROOT) .tex`.aux" 2; $(LATEX) $(TEX_ROOT) || { e=$$?; $(RM) $@ `basename $(TEX_ROOT) .tex`.aux; exit $$e; } - for f in $(side); do\ - if cmp $$f $$f~; then\ - :;\ - else\ - cp $$f $$f~;\ - fi;\ - done - $(MAKE) $(BIB_BBL) $@ - -$(BIB_BBL): $(BIB_SRC) $(side.cmp) - $(REASON) - if [ -s snacc.aux ]; then $(BIBTEX) `basename $(TEX_ROOT) .tex`; fi - -$(side.cmp) redo: - touch $@ - -version.tex: #$(TOP)/version.h - echo '\def\snaccversion{'`sed -e '/VERSION/!d' -e 's/.*"\(.*\)".*/\1/' -e q $?`'}' > $@ - -spell:: sp_errs -sp_errs: $(TEX_SRC) - $(REASON) - $(DETEX) $(TEX_ROOT) | $(SPELL) > $@~ - mv $@~ $@ - -install-sh: - ln $(TOP)/install-sh $@ - -$(man1dir): - $(TOP)/mkinstalldirs $@ - -install:: $(MANUALS) install-sh $(man1dir) - -install:: - for man in $(MANUALS.1); do\ - $(INSTALL_DATA) $$man $(man1dir)/`basename $$man .1`.$(man1ext);\ - done - for man in $(MANUALS.n); do\ - $(INSTALL_DATA) $$man $(man1dir)/`basename $$man .n`.$(mannext);\ - done - -clean:: - $(RM) *~ *.dvi *.log *.aux *.toc *.lof *.lot *.bbl *.blg sp_errs .emacs* - -clobber:: clean - -clobber:: - $(RM) *.ps - -gen-distfiles:: $(DISTFILES) - -distfiles:: - echo $(DISTFILES) - -# dummy: -depend:: - @true diff --git a/SecuritySNACCRuntime/doc/makefile.tex b/SecuritySNACCRuntime/doc/makefile.tex deleted file mode 100644 index 203b7791..00000000 --- a/SecuritySNACCRuntime/doc/makefile.tex +++ /dev/null @@ -1,121 +0,0 @@ -% file: .../doc/makefile.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/makefile.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: makefile.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:53 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:49 rj -% first check-in -% - -\chapter{\label{makefile-sect}Makefiles} - -Some of Snacc's makefiles look rather sophisticated. -This section explains some of the tricks. - -\section{CVS, Dependencies and Make's Include Statement} - -The makefiles take advantage of the file inclusion feature. -Since this has already been supported by UNIX System III\footnote{yes, System III, not System V R3} make (somewhen around 1980), I consider it to be pretty portable. -If your make is crippled, either use a newer one (e.g. GNU make), or as a last resort, remove (better: comment out) the include statements and call make with the additional arguments {\ufn -f .../makehead -f makefile -f dependencies -f .../maketail}. - -Snacc's configuration script generates the file {\ufn makehead} which gets included by all makefiles. -It contains a lot of definitions used by make. - -The dependencies have been moved out of each makefile into a separate file called {\ufn dependencies} that is not under cvs control---otherwise, the makefiles would inflate the repository unnecessarily. -The makefiles have an include statement for their dependencies file. -GNU make automatically makes the dependencies if the file does not exist, but other versions of {\ufn make} simply give up. -In that case, an initial (empty) file has to be generated. -Snacc's top level makefile does this for you if you call {\ufn make depend}. - -A third file that is included by almost every makefile is {\ufn \dots/maketail}. -It holds the rules that are common to all makefiles where C/C++ code is compiled. - -\section{Circular Dependencies} - -In a normal makefile rule, a file depends upon other files. -If any of a file's dependencies is newer, the file is remade. -This goes well as long as the dependency graph is non-circular, but snacc is compiled from some files it has generated itself. -This recursion can lead to one of two results: in the worse case, {\ufn make} builds the compiler because its source files are newer, builds the source files because the compiler is newer, builds the compiler because some source files are newer, and so on ad infinitum\dots{} -Even if this endless recursion does not happen, one or two of the above steps will be made every time {\ufn make} is called. -To avoid this waste of time, one lets the compiler generate a new source file, but when the new and the old version are identical, the old file is kept and {\ufn make} sees that the compiler is up-to-date, and the recursion is terminated. -Of course, if the source file's contents did change, it is replaced with the new version. - -This is a simplified example of a normal makefile: - -\begin{Makefile} -snacc: \>tbl.h\\ - \>\emph{compile} snacc\\ -\\ -tbl.h: \>snacc tbl.asn1\\ - \>./snacc \dots{} tbl.asn1\\ -\end{Makefile} - -Most {\ufn make} versions will complain and print a warning about this `infinite loop' or `circular dependency'. -The first approach towards a solution could be: - -\begin{Makefile} -snacc: \>tbl.h\\ - \>\emph{compile} snacc\\ -\\ -tbl.h: \>snacc tbl.asn1\\ - \>mv tbl.h tbl.h.prev\\ - \>./snacc \dots{} tbl.asn1\\ - \>if cmp tbl.h.prev tbl.h; then\char`\\\\ - \>\> echo "tbl.h hasn't changed";\char`\\\\ - \>\> mv tbl.h.prev tbl.h;\char`\\\\ - \>else\char`\\\\ - \>\> \$(RM) tbl.h.prev;\char`\\\\ - \>fi\\ -\end{Makefile} - -The effect is that you keep snacc from being remade if the contents of tbl.h did not change, but the two steps to create tbl.h and to test whether it is different from tbl.h.prev will be made every time snacc or tbl.asn1 are newer than tbl.h, which they most often will be since few of the changes to snacc will affect tbl.h's contents. -And {\ufn make} will still complain about the recursion. -To solve all this, another file, a stamp file is introduced. -It separates the file's contents from its modification time: - -\begin{Makefile} -snacc: \>tbl.h\\ - \>\emph{compile} snacc\\ -\\ -stamp-tbl: \>snacc tbl.asn1\\ - \>mv tbl.h tbl.h.prev\\ - \>./snacc \dots{} tbl.asn1\\ - \>if cmp tbl.h.prev tbl.h; then\char`\\\\ - \>\> echo "tbl.h hasn't changed";\char`\\\\ - \>\> mv tbl.h.prev tbl.h;\char`\\\\ - \>else\char`\\\\ - \>\> \$(RM) tbl.h.prev;\char`\\\\ - \>fi\\ - \>date > \$@\\ -\\ -tbl.h: \>stamp-tbl\\ - \>@true\\ -\end{Makefile} - -The dummy command in the rule for tbl.h is necessary, since otherwise, despite stamp-tbl commands having modified tbl.h, many versions of make think that tbl.h has not been modified. - -If you want {\ufn tbl.h} to be remade (e.g. you have changed an option to snacc), you must delete {\ufn stamp-tbl}---{\ufn tbl.h} may (and should) be left in place. - -The rules in {\ufn \dots/compiler/makefile}, {\ufn \dots/c-lib/makefile} and {\ufn \dots/c++-lib/makefile} are further complicated by the fact that -\begin{enumerate} - \item snacc prints the current time into the file which the comparison must take into account - \item if snacc has not been built it cannot be used to generate its source files---a bootstrapping version of snacc's source files has got to be supplied. -\end{enumerate} - -\section{Compiling Different Libraries From One Set Of Source Files} - -The different libraries in {\ufn \dots/c-lib/} and {\ufn \dots/c++-lib/} get made by means of recursive calls to make with different macro settings. -This keeps the makefiles short as it avoids a lot of duplication of file lists and rules which would be a hassle to maintain. -The different libraries get compiled from the same set of source files, the code to be compiled is determined through {\ufn cpp} (C preprocessor) macro switches. - -\section{Configuration, Optional Code and Makefiles} - -The {\ufn \dots/configure} script looks for Tcl/Tk. -If they are absent, there is no use in trying to compile Snacc's Tcl interface. -For makefiles to detect whether the Tcl interface should be compiled or not, there is a file {\ufn \dots/tcl-p.c} that, after being compiled into {\ufn tcl-p}, exits with 0 (the shells' `true' value) if Tcl/Tk is present and the user has not disabled this option by setting {\C NO\_TCL} in {\ufn \dots/policy.h} to {\C 1}. -{\ufn tcl-p} gets made automatically. diff --git a/SecuritySNACCRuntime/doc/meta.tex b/SecuritySNACCRuntime/doc/meta.tex deleted file mode 100644 index 1db05d72..00000000 --- a/SecuritySNACCRuntime/doc/meta.tex +++ /dev/null @@ -1,670 +0,0 @@ -% file: .../doc/meta.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/meta.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: meta.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:53 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:38 rj -% first check-in -% - -\chapter{\label{meta-chapter}The Metacode} - -%----------------------------------------------------------------------------------------------------------------------------------- -\section{\label{intro-meta-section}Introduction} - -When you call snacc, during its compilation, the text in the {\ufn .asn1} files gets turned into e.g. C++ classes. -Names become identifiers, and after the C++ compilation, the user program has no more access to the original module and type names, only to pointers and the bits and bytes of the classes' contents. - -The metacode remedies this. -Using it, a program can access the modules, their types, their subtypes and the named values via strings. -Generic programs do not have to know any of the modules' or types' names---all the information can be traversed starting at a single well-known place. - -The metacode has to map strings (``component {\C "name"} in type {\C "Person"} in ASN.1 module {\C "Mail"}'') into the in-core address of the indicated object. -Moreover, using the metacode, a generic program has to be able to traverse all modules, types and their components to learn about their names and types. -Given the name of a type, the metacode must be able to return a newly allocated object instance. - -The metacode is an extension to the Snacc compiler's C++ backend and the C++ runtime library. - -Since the metacode relies heavyly on the virtual function call mechanism, it is only implemented for the C++ backend. - -A number of functions has been added to the C++ runtime library. -All code extensions have been wrapped into preprocessor conditionals. -Currently, only one or two libraries are made in {\ufn \dots/c++-lib/}, one with neither metacode nor Tcl interface, and an optional additional one with both extensions. -If you cannot or do not want to (as stated in {\ufn \dots/policy.h}) use the metacode or the Tcl interface, Snacc will be compiled without it, and only the normal library will get made. - -If you want to use the metacode but not the Tcl interface, you have got to change the makefile to compile another set of {\ufn .o} files in a directory you may want to name {\ufn \dots/c++-lib/meta/} and archive the resulting files in {\ufn libasn1meta.a}. -Compile with {\ufn -DMETA=1 -DTCL=0}. - -%----------------------------------------------------------------------------------------------------------------------------------- -\section{Implementation} - -%leftover:---------------- -With the metacode, the strings and the ASN.1 type components' type information are stored in arrays, one per structured ASN.1 type. -The type descriptions are listed in another array, one per ASN.1 module. - -In the C++ code generated by snacc, every ASN.1 type is represented by a C++ class. -These C++ classes for ASN.1 simple types are implemented in the runtime library, and for structured types they are generated by the backend. -The metacode is an extension to all of those C++ classes. -The metacode put into every C++ class is very similar: -\begin{itemize} - \item a static {\C \_desc} member is always present. - \item simple types with names (ENUMERATED, INTEGER, BIT STRING) get an additional static {\C \_nmdescs[]} member. - The array is exclusively referenced from {\C \_desc}. - The array provides the bidirectional mapping of symbolic and numeric values. - \item structured types with members (SET, SEQUENCE, CHOICE) get an additional static {\C \_mdescs[]} member. - The array is exclusively referenced from {\C \_desc}. - The array references the components' type descriptions (their {\C \_desc} data members). - \item every class gets a virtual {\C \_getref()} function. - Its only purpose is to return the address of {\C \_desc}\footnote{ - This sounds as if virtual data members were a nice idea, and in fact they are. - The C++ standards committees are currently discussing this. - % Of course, there are not a lot of compilers already implementing this feature. - }. - \item structured types with members (SET, SEQUENCE, CHOICE) get an additional virtual {\C \_getref()} function. - This function provides the member name to member address mapping. -\end{itemize} -The data members are {\C static}, and therefore get instantiated exactly once per executable, not once per class object instance. - -To get an impression, let us have a look at an example: -The two ASN.1 types -\begin{ASNcode} -File ::= SET\\ -\{\+\\ - name [0] PrintableString,\\ - contents [1] OCTET STRING,\\ - checksum [2] INTEGER OPTIONAL,\\ - read-only [3] BOOLEAN DEFAULT FALSE\-\\ -\}\\ -\\ -Directory ::= SET\\ -\{\+\\ - name PrintableString,\\ - files SET OF File\-\\ -\} -\end{ASNcode} - -get turned into two individual C++ classes: - -\begin{Ccode} -class File: public AsnType\\ -\{\\ -public:\+\\ - PrintableString \>\>name;\\ - AsnOcts \>\>contents;\\ - AsnInt \>\>*checksum;\\ - AsnBool \>\>*read\_only;\\ -\\ -\<\#if META\\ - static const AsnSetTypeDesc \>\>\_desc;\\ - static const AsnSetMemberDesc \>\>\_mdescs[];\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ - AsnType \>\>*\_getref (const char *membername, bool create = false);\\ -\<\#endif // META\\ -\\ - // \dots other functions omitted\dots\-\\ -\};\\ -\\ -class Directory: public AsnType\\ -\{\\ -public:\+\\ - PrintableString \>\>name;\\ - DirectorySetOf \>\>files;\\ -\\ -\<\#if META\\ - static const AsnSetTypeDesc \>\>\_desc;\\ - static const AsnSetMemberDesc \>\>\_mdescs[];\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ - AsnType \>\>*\_getref (const char *membername, bool create = false);\\ -\<\#endif // META\\ -\\ - // \dots other functions omitted\dots\\ -\<\}; -\end{Ccode} - -The above definitions stem from the {\ufn .h} file, the following code is taken from the {\ufn .C} file. -Only the code for the {\ASN Directory} type is shown, because the code for the {\ASN File} type looks very similar. - -\begin{Ccode} -\#if META\\ -\\ -static AsnType *createDirectory()\\ -\{\\ - \>return new Directory;\\ -\}\\ -\\ -const AsnSetMemberDesc Directory::\_mdescs[] =\\ -\{\+\\ - AsnSetMemberDesc ("name", \&PrintableString::\_desc, false), // `name'\\ - AsnSetMemberDesc ("files", \&DirectorySetOf::\_desc, false), // `files'\\ - AsnSetMemberDesc()\-\\ -\};\\ -\\ -const AsnSetTypeDesc Directory::\_desc\\ -(\+\\ - \&EdEx\_StructuredModuleDesc,\\ - "Directory", // `Directory'\\ - true,\\ - AsnTypeDesc::SET,\\ - createDirectory,\\ - \_mdescs\-\\ -);\\ -\\ -const AsnTypeDesc *Directory::\_getdesc() const\\ -\{\\ - \>return \&\_desc;\\ -\}\\ -\\ -AsnType *Directory::\_getref (const char *membername, bool create)\\ -\{\+\\ - if (!strcmp (membername, "name"))\\ - \>return \&name;\\ - if (!strcmp (membername, "files"))\\ - \>return \&files;\\ - return NULL;\-\\ -\}\\ -\\ -\#endif // META -\end{Ccode} - -The two ASN.1 types get turned into two individual C++ classes, but their {\C \_desc} members point to two different instances of the same type. -The C++ backend generates an individual C++ class for every structured ASN.1 type. -The metacode is different: -The types of the descriptions data members ({\C \_desc}, {\C \_nmdesc} and {\C \_mdesc}) despend on the \emph{general} ASN.1 type (i.e. e.g. {\ASN SET}, not {\ASN File}). - - - - - - - -%leftover:---------------- -Every {\ufn .asn1} file contains an ASN.1 module and gets translated into a {\ufn .C} file that contains an array that lists all the module's type descriptions. - -Snacc generates an additional file {\ufn modules.C} that contains an array that lists all the module descriptions. -This single top level array provides the well known entry point for the whole module and type hierarchy. -%leftover:---------------- - - - - - -The type of the {\C \_desc} member differs depending on the ASN.1 type it describes. -The different {\C \_desc} types mirror the {\C AsnType} class hierarchy. -For example, the ASN.1 BOOLEAN type is mapped into a C++ class called {\C AsnBool} and is described by a C++ class {\C AsnBoolTypeDesc}. -The root of the {\C \_desc} class hierarchy is called {\C AsnTypeDesc} and looks as follows -(taken from {\ufn \dots/c++-lib/inc/meta.h}): -\begin{Ccode} -struct AsnTypeDesc\\ -\{\+\\ - const AsnModuleDesc \>\>*module;\\ - const char \>\>*const name; // NULL for basic types\\ - const bool \>\>pdu;\\ - const enum Type \qquad // NOTE: keep this enum in sync with the typenames[]\\ - \{\+\\ - VOID,\\ - ALIAS,\\ -\\ - INTEGER,\\ - REAL,\\ - NUL\_, // sic! (can't fight the ubiquitous NULL \#define)\\ - BOOLEAN,\\ - ENUMERATED,\\ - BIT\_STRING,\\ - OCTET\_STRING,\\ - OBJECT\_IDENTIFIER,\\ -\\ - SET,\\ - SEQUENCE,\\ - SET\_OF,\\ - SEQUENCE\_OF,\\ - CHOICE,\\ - ANY,\-\\ - \} \>\>type;\\ -\\ - static const char \>\>*const typenames[];\\ -\\ - \>\>AsnTypeDesc (const AsnModuleDesc *, const char *,\\ - \`bool ispdu, AsnType *(*create)(), Type);\\ -\\ - AsnType \>\>*(*create)();\\ -\\ - virtual const AsnModuleDesc \>\>*getmodule() const;\\ - virtual const char \>\>*getname() const;\\ - virtual bool \>\>ispdu() const;\\ - virtual Type \>\>gettype() const;\\ - virtual const AsnNameDesc \>\>*getnames() const;\\ - %//virtual const AsnMemberDesc \>\>*getmembers() const;\\ -\\ -\<\#if TCL\\ - virtual int \>\>TclGetDesc (Tcl\_DString *) const;\\ - virtual int \>\>TclGetDesc2 (Tcl\_DString *) const;\-\\ -\#endif\\ -\};\\ -\\ -typedef AsnTypeDesc \>\>\>AsnRealTypeDesc;\\ -typedef AsnTypeDesc \>\>\>AsnNullTypeDesc;\\ -typedef AsnTypeDesc \>\>\>AsnBoolTypeDesc;\\ -\\ -typedef AsnTypeDesc \>\>\>AsnOctsTypeDesc;\\ -typedef AsnTypeDesc \>\>\>AsnOidTypeDesc; -\end{Ccode} - -{\C AsnTypeDesc}'s data members provide the following information: -\begin{description} - \item[\textnormal{The} {\C module}] data member points to the module description described at the end of this chapter in section~\ref{meta-modules-sect}. - - \item[\textnormal{The} {\C name}] is either the type's name as used by the backend code (default, or if snacc was called with the {\ufn -mC} switch) or the type's given names as defined in the {\ufn .asn1} file (if snacc has been called with the {\ufn -mA} command line option). - Section~\ref{naming-C++-section} on page~\pageref{naming-C++-section} explains the differences. - (For example, the backend code sometimes has an additional number tacked to the name---you can see the effect in figure~\ref{snacced-example} on page~\pageref{snacced-example}.) - The generated source code contains the respective counterpart printed in a comment. - - \item[\textnormal{The} {\C pdu}] flag is set to {\C true} iff the type was listed after snacc's {\ufn -meta} or {\ufn -tcl} switch. - - \item[\textnormal{The} {\C type}] member is used as an index into the {\C typenames} array---the virtual function call mechanism obliviates the use for any {\C switch} statements. - - \item[\textnormal{The} {\C create}] data member points to a global function that returns a pointer to a newly allocated object of the description type's mirror type, that is, gives you an instance for the generic description. - It is the counterpart to the {\C AsnType}'s {\C \_getdesc} function which goes in the opposite direction, from the object instance to its generic description. - The {\C AsnType}'s {\C Clone} function serves a similar purpose as the {\C AsnTypeDesc}'s {\C create} function. -\end{description} - -The {\C AsnTypeDesc} class is the only class in the hierarchy that has got the {\C module}, {\C name}, {\C pdu} and {\C type} data members, and {\C AsnNamesTypeDesc} the only class to implement a {\C names} data member. -Therefore, unlike {\C \_getdesc()} mentioned above, the five virtual functions {\C getmodule}, {\C getname}, {\C ispdu}, {\C gettype} and {\C getnames} are not meant to implement some kind of virtual data members, but help to implement the alias type description functionality described in section~\ref{meta-aliases}. - -As you can see looking at the last five code lines with the {\C typedef}s, the five ASN.1 simple types REAL, NULL, BOOLEAN, OCTET STRING and OBJECT IDENTIFIER are directly described by instances of this class. -The other types, having either named values or components, are more demanding and have their own classes derived from {\C AsnTypeDesc}. - -%----------------------------------------------------------------------------------------------------------------------------------- -\subsection{Named Values} - -Some basic ASN.1 types allow values to be named, namely INTEGER, ENUMERATED and BIT STRING. -The accompanying description types contain arrays listing the names and values. -The virtual function {\C getnames()} returns this array. -The respective C++ classes in the runtime library contain an {\C AsnNameDesc \_nmdescs[]} array, the address of which is given to the type descriptions constructor as last argument. - -\begin{Ccode} -struct AsnNameDesc\\ -\{\+\\ - const char \>\>*const name;\\ - const long int \>\>value;\-\\ -\};\\ -\\ -struct AsnNamesTypeDesc: AsnTypeDesc\\ -\{\+\\ - const AsnNameDesc \>\>*const names;\\ -\\ - \>\>AsnNamesTypeDesc (const AsnModuleDesc *, const char *,\\ - \`bool ispdu, AsnType *(*create)(), Type, const AsnNameDesc *);\\ -\\ - const AsnNameDesc \>\>*getnames() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetDesc (Tcl\_DString *) const;\\ - // for BIT STRING and INTEGER, ENUMERATED has its own:\\ - int \>\>TclGetDesc2 (Tcl\_DString *) const;\-\\ -\#endif\\ -\};\\ -\\ -struct AsnEnumTypeDesc: AsnNamesTypeDesc\\ -\{\\ - \> \>\>AsnEnumTypeDesc (const AsnModuleDesc *, const char *,\\ - \`bool ispdu, Type, AsnType *(*create)(), const AsnNameDesc *);\\ -\\ -\#if TCL\\ - \>int \>\>TclGetDesc2 (Tcl\_DString *) const;\\ -\#endif\\ -\};\\ -\\ -typedef AsnNamesTypeDesc \>\>\>AsnIntTypeDesc;\\ -typedef AsnNamesTypeDesc \>\>\>AsnBitsTypeDesc; -\end{Ccode} - -The ENUMERATED type gets its own description class because the Tcl interface for ENUMERATED types behaves differently than for the INTEGER and BIT STRING types. - -As for {\C AsnTypeDesc::name} above, the content of {\C AsnNameDesc::name} is either the value's name as used by the backend code (default, or if snacc was called with the {\ufn -mC} switch) or the value's name as given in the {\ufn .asn1} file (if snacc has been called with the {\ufn -mA} command line option). -The generated source code contains the respective counterpart printed in a comment. - -\subsection{Types with Members} - -The ASN.1 types CHOICE, SET and SEQUENCE are defined in terms of other types, their so-called components. -The ASN.1 components map into C++ data members. - -The three ASN.1 structured types get mapped into C++ classes that contain an {\C Asn\dots{}MemberDesc \_mdescs[]} array (with the `{\C \dots}' replaced by `{\C Choice}' `{\C Set}' or `{\C Sequence}'). -The address of this array is given to the description type's constructor as last argument. -The elements of this array point to the descriptions of the data classes data members. -This is similar to the named values above, only the integral value has been replaced by a pointer to a type description. - -\begin{Ccode} -struct AsnMemberDesc // description of CHOICE member; base class for AsnSe\_MemberDesc\\ -\{\+\\ - const char \>\>*const name;\\ - const AsnTypeDesc \>\>*const desc;\\ -\\ - \>\>AsnMemberDesc (const char *, const AsnTypeDesc *);\\ - \>\>AsnMemberDesc();\\ -\\ -\<\#if TCL\\ - virtual int \>\>TclGetDesc (Tcl\_DString *) const;\\ - virtual int \>\>TclGetDesc2 (Tcl\_DString *) const;\-\\ -\#endif\\ -\};\\ -\\ -struct AsnSe\_MemberDesc: AsnMemberDesc\qquad// \_ == t/quence; description of SET or SEQUENCE member\\ -\{\+\\ - bool \>\>optional;\\ -\\ - \>\>AsnSe\_MemberDesc (const char *, const AsnTypeDesc *, bool);\\ - \>\>AsnSe\_MemberDesc();\\ -\-\\ -\#if TCL\\ - \>int \>\>TclGetDesc2 (Tcl\_DString *) const;\\ -\#endif\\ -\};\\ -\\ -typedef AsnMemberDesc \>\>\>AsnChoiceMemberDesc;\\ -typedef AsnSe\_MemberDesc \>\>\>AsnSetMemberDesc;\\ -typedef AsnSe\_MemberDesc \>\>\>AsnSequenceMemberDesc;\\ -\\ -struct AsnMembersTypeDesc: AsnTypeDesc\\ -\{\+\\ - \>\>AsnMembersTypeDesc (const AsnModuleDesc *, const char *,\\ - \`bool ispdu, AsnType *(*create)(), Type);\\ -\\ -\<\#if TCL\\ - int \>\>TclGetDesc (Tcl\_DString *) const;\-\\ -\#endif\\ -\};\\ -\\ -struct AsnChoiceTypeDesc: AsnMembersTypeDesc\\ -\{\+\\ - const AsnChoiceMemberDesc \>\>*const members;\\ -\\ - \>\>AsnChoiceTypeDesc (const AsnModuleDesc *, const char *,\\ - \`bool ispdu, AsnType *(*create)(), Type, const AsnChoiceMemberDesc *);\\ -\\ - int \>\>choicebyname (const char *name) const;\\ - const char \>\>*choicebyvalue (int value) const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetDesc2 (Tcl\_DString *) const;\-\\ -\#endif\\ -\};\\ -\\ -struct AsnSe\_TypeDesc: AsnMembersTypeDesc\qquad// \_ == t/quence\\ -\{\+\\ - const AsnSe\_MemberDesc \>\>*const members;\\ -\\ - \>\>AsnSe\_TypeDesc (const AsnModuleDesc *, const char *,\\ - \`bool ispdu, AsnType *(*create)(), Type, const AsnSe\_MemberDesc *);\\ -\\ -\<\#if TCL\\ - int \>\>TclGetDesc2 (Tcl\_DString *) const;\-\\ -\#endif\\ -\};\\ -\\ -typedef AsnSe\_TypeDesc \>\>\>AsnSetTypeDesc;\\ -typedef AsnSe\_TypeDesc \>\>\>AsnSequenceTypeDesc; -\end{Ccode} - -As for {\C AsnTypeDesc::name} above, the content of {\C AsnMemberDesc::name} is either the member's name as used by the backend code (default, or if snacc was called with the {\ufn -mC} switch) or the component's name as defined in the {\ufn .asn1} file (if snacc has been called with the {\ufn -mA} command line option). -The generated source code contains the respective counterpart printed in a comment. -In case the ASN.1 component was not given a name, the backend's member name is used instead. - -The data classes have a member function called {\C \_getref}, that allows the C++ class members to be accessed by their name. -{\C \_getref()} is the second metacode function and it is present in all C++ classes representing composed ASN.1 types. - -A class for a SET contains the following code fragment: -\begin{Ccode} -class FooSet: public AsnType\+\\ - AsnInt \>\>bar; // an example data member\\ - \dots // lots of member functions\\ -\<\#if META\\ - static const AsnSetTypeDesc \>\>\_desc;\\ - static const AsnSetMemberDesc \>\>mdescs[];\\ - const AsnTypeDesc \>\>*\_getdesc() const;\\ - AsnType \>\>*\_getref (const char *membername, bool create = false);\\ -\<\#if TCL\\ - int \>\>TclGetDesc (Tcl\_DString *) const;\\ - int \>\>TclGetVal (Tcl\_Interp *) const;\\ - int \>\>TclSetVal (Tcl\_Interp *, const char *valstr);\\ - int \>\>TclUnsetVal (Tcl\_Interp *, const char *membername);\-\\ -\#endif // TCL \\ -\#endif // META\\ -\}; -\end{Ccode} - -{\C \_getref()}'s {\C bool} parameter {\C create} determines whether a non-existing member should be returned as a {\C NULL} pointer or whether it should instead be allocated and its address be returned. -This parameter is used by value reading and writing routines to implement their different member access semantics. - -The following four assignments are equivalent: -\begin{Ccode} -FooSet foo;\\ -foo.bar = 1;\\ -*(AsnInt *)foo.\_getref ("bar") = 1;\\ -foo.bar.TclSetVal (interp, "1");\\ -foo.\_getref ("bar")-->TclSetVal (interp, "1"); -\end{Ccode} -{\C TclSetVal()} is a virtual member function and therefore no cast from {\C AsnType~*} to {\C AsnInt~*} is required. -The Tcl interface will be described in chapter~\ref{tcl-if-chapter}. - -The C++ classes that represent CHOICE types contain an {\C enum ChoiceIdEnum} that allows {\C \_getref()} to be written using a {\C switch} statement. -The functions {\C choicebyname()} and {\C choicebyvalue()} turn the component's name into its enumeration value and vice versa. -(The enum has not been introduced with the metacode, it is used by Snacc's encoding and printing functions as well.) - -\subsection{\label{meta-list}SET OF and SEQUENCE OF} - -The list description behaves like an ASN.1 simple type's---the description type is derived directly from the type descriptions' base class and does not redefine any of the metacode functions: - -\begin{Ccode} -struct AsnListTypeDesc: AsnTypeDesc\\ -\{\+\\ - const AsnTypeDesc \>\>*const base;\\ -\\ - \>\>AsnListTypeDesc (const AsnModuleDesc *, const char *,\\ - \`bool ispdu, Type, AsnType *(*create)(), const AsnTypeDesc *);\-\\ -\\ -\#if TCL\\ - \>int \>\>TclGetDesc (Tcl\_DString *) const;\\ -\#endif\\ -\}; -\end{Ccode} - -The {\C TclGetDesc} function merely adds the base type's standard type description (module and type name, pdu flag and type) after its own, so that a programmer may take the base type's name and ask the metacode once again for the base type's full description. - -A list type's data class on the other hand has got a {\C \_getref()} function that gives access to the list's elements and it can be used to insert new elements at any desired position. - -\subsection{\label{meta-aliases}Aliases} - -For ASN.1 types being defined as a direct copy of another type, snacc in normal operation uses a C++ {\C typedef} to define the C++ type. -Since this {\C typedef} makes the two types totally equivalent, the metacode has no chance to preserve the two types' different names and thus, this contruct cannot be used. -A new C++ class has got to be defined instead. - -Example: the following ASN.1 code snippet\dots -\begin{ASNcode} -Int1 ::= INTEGER \{ foo(42) \}\\ -Int2 ::= Int1 -\end{ASNcode} -\dots maps into the following C++ definitions: -\begin{Ccode} -class Int1: public AsnInt\\ -\{\\ -public:\+\\ - \>\>Int1(): AsnInt() \{\}\\ - \>\>Int1 (int i): AsnInt (i) \{\}\\ - enum\\ - \{\\ - \>foo = 42\\ - \};\\ -\\ -\<\#if META\\ - static const AsnNameDesc \>\>\_nmdescs[];\\ - static const AsnIntTypeDesc \>\>\_desc;\\ - const AsnTypeDesc \>\>*\_getdesc() const;\-\\ -\#endif // META\\ -\};\\ -\\ -\#if META\\ -struct Int2: public Int1\\ -\{\+\\ - \>\>Int2(): Int1() \{\}\\ - \>\>Int2 (int i): Int1 (i) \{\}\\ - AsnType \>\>*Clone() const;\\ -\\ - static const AsnAliasTypeDesc \>\>\_desc;\\ - const AsnTypeDesc \>\>*\_getdesc() const;\-\\ -\};\\ -\\ -\#else // META\\ -\\ -typedef Int1 \>\>\>Int2;\\ -\\ -\#endif // META -\end{Ccode} - -The descriptor type's definition points to the reference type: - -\begin{Ccode} -struct AsnAliasTypeDesc: AsnTypeDesc\\ -\{\+\\ - const AsnTypeDesc \>\>*const alias;\\ -\\ - \>\>AsnAliasTypeDesc (const AsnModuleDesc *, const char *,\\ - \`bool ispdu, AsnType *(*create)(), Type, const AsnTypeDesc *);\\ -\\ - const AsnModuleDesc \>\>*getmodule() const;\\ - const char \>\>*getname() const;\\ - bool \>\>ispdu() const;\\ - Type \>\>gettype() const;\\ - const AsnNameDesc \>\>*getnames() const;\\ - %//const AsnMemberDesc \>\>*getmembers() const;\\ -\\ -\<\#if TCL\\ - int \>\>TclGetDesc (Tcl\_DString *) const;\-\\ -\#endif\\ -\}; -\end{Ccode} - -The {\C AsnAliasTypeDesc} is the reason for the five virtual functions from {\C getmodule} to {\C getnames} defined in both {\C AsnTypeDesc} and {\C AsnNamesTypeDesc} on the one hand and {\C AsnAliasTypeDesc} on the other hand. -While the alias type belongs to a different module or has another type name, and it may have another {\C pdu} flag value, its type and names array values are those of its reference type. -Therefore, {\C AsnAliasTypeDesc}'s first three functions of return the description's own values, and the latter two call their reference type's functions. - -The {\C getnames} function has to be defined in the hierarchy's base class because the aliases may be defined for any type of type, not only for types with named values. - -\subsection{\label{meta-any}ANY (DEFINED BY)} - -ANY DEFINED BY is quite problematic. -The ASN.1 Book \cite{ASN.1Book} calls it ``a rather half-baked attempt at solution''. -Since snacc has problems with it---the user has to modify the snacc generated code---and none of our applications requires this construct, no effort has been made to implement it. - -ANY itself on the other hand would be quite simple to implement---the virtual function call mechanism that is used to implement the ANY type is the basis for the metacode as well. -But again, since we have no need for the ANY type, it is as far unimplemented. -Besides that, according to the ASN.1 book, the ``use of ANY without the DEFINED BY construct is ``deprecated'' (frowned upon) by the standard''. -The next ASN.1 standard will probably not have the ANY type any more. -In the 1993 draft standard \cite{asn1:1993}, ANY and ANY DEFINED BY can be found in ``Annex I: Superseded features'', Section 3: ``The any type''. -% Macros can be found in this annex as well. - -\subsection{\label{meta-modules-sect}Modules} - -Every {\ufn .C} file (that corresponds to an {\ufn .asn1} file, or, an ASN.1 module), gets an array that lists all the module's types. -This array contains pointers to all the {\C \_desc} members of all classes of a module. - -\begin{Ccode} -struct AsnModuleDesc\\ -\{\+\\ - const char \>\>*const name;\\ - const AsnTypeDesc \>\>**const types;\-\\ -\};\\ -\\ -extern const AsnModuleDesc \>\>\>*asnModuleDescs[]; -\end{Ccode} - -The modules themselves are listed in yet another array, the declaration of which is shown in the preceeding line. -This array has got its own source file named {\ufn modules.C}. -This array allows all modules to be found, and every type that is defined for these modules. - -%----------------------------------------------------------------------------------------------------------------------------------- -\section{Efficiency} - -The metacode is designed with efficiency in mind. -The metacode is intended for interpreted interfaces and therefore does not need to be highly optimized. -On the other hand, the same object code should be useable for normal (non-metacode) tasks without loss of performance. - -\subsection{Normal Operation} - -The metacode does not significantly affect the normal mode of operation. -The static data members {\C \_mdescs} and {\C \_desc} do not increase the class instances' size. -The virtual function tables, which have already been present (they are used for the ANY type), get a little longer, but since these tables exist only once for every class, this difference is neglible. -The class instances reference their virtual function table with a pointer, and so the metacode does not introduce any change here. -Except for alias types, the C++ classes generated are exactly the same. -The metacode introduces a new class for alias types, but since no new data members are introduced their size stays the same; only the virtual function table pointer is different. - -All normal member functions (constructor, destructor, assignment operator, encode, decode and print functions) are identical---with only one exception: if the metacode is compiled to be usable by the Tcl interface, the constructors initialize their mandatory members. - -To sum it up, both code and data grow, but except for a longer loading time from disk and an increased probability for cache misses, the code will run as fast as it does without the metacode. - -\subsection{Metacode} - -The metacode routines are kept quite simple. -Intended to be used in conjunction with a Tcl interface, speed was not the most important concern. -Consequently, the code is optimized more towards memory usage than run time efficiency. -As an example, name to member resolution uses a linear lookup strategy instead of more elaborated algorithms like binary search or hash tables. -I think for data types that typically have up to a dozen components, more sophisticated algorithms would have been overkill. - -A typical object file gets almost 20\% larger due to the metacode (the Tcl interface adds another 25\%). - -%----------------------------------------------------------------------------------------------------------------------------------- -\section{\label{meta-ttab-comparison}Metacode Vs. Type Tables} - -Here's a list of both the type tables' (see chapter~\ref{ttab-chapter}) and the metacode's (dis)advantages: -\begin{itemize} - - \item source code language: - \begin{itemize} - \item[$-$] The type tables are implemented for C only. - \item[$-$] The metacode works only for C++. - \end{itemize} - - \item speed: - \begin{itemize} - \item[$-$] Encoding and decoding using the type tables is said to be about 4 times slower than using the C routines. - \item[$+$] The metacode does not (significantly) harm performance. - \end{itemize} - - \item code size: - \begin{itemize} - \item[$+$] The tables are a lot smaller than the compiled routines. - \item[$-$] The metacode makes the compiled code even larger. - \end{itemize} - - \item value constants: - \begin{itemize} - \item[$-$] The type tables lack the values defined in the {\ufn .asn1} files. - \item[$+$] The metacode interacts fine with these values. - \end{itemize} - - \item named values: - \begin{itemize} - \item[$-$] The type tables lack the named values defined ENUMERATED, INTEGER and BIT STRING types. - \item[$+$] The metacode interacts fine with these names. - \end{itemize} - - \item compatibility to normal snacc code: - \begin{itemize} - \item[$-$] The C structures defined by mkchdr and used by the type table encoding and decoding routines and the C structures defined by snacc's C backend are quite different. - \item[$\pm$] Where the backend's structures generated for SEQUENCE contain madatory members by value, the type table's structures contain only pointer members! - \end{itemize} - -\end{itemize} - -%----------------------------------------------------------------------------------------------------------------------------------- -\section{\label{metacode-setup}Setup for the Metacode Generator} - -To compile Snacc with the metacode generator, the following condition must be met: -\begin{itemize} - \item either the configure script must be able to find {\ufn tclsh} and the Tcl/Tk libraries or you have to insert a {\C \#define META 1} into {\ufn \dots/policy.h} - \item the {\C NO\_META} preprocessor macro in {\ufn \dots/policy.h} must not be set -\end{itemize} diff --git a/SecuritySNACCRuntime/doc/misc-hyph.tex b/SecuritySNACCRuntime/doc/misc-hyph.tex deleted file mode 100644 index 7e7a02a3..00000000 --- a/SecuritySNACCRuntime/doc/misc-hyph.tex +++ /dev/null @@ -1,23 +0,0 @@ -% file: .../doc/misc-hyph.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/misc-hyph.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: misc-hyph.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:53 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:27 rj -% first check-in -% - -\hyphenation{ - snacc-path - Asn-Type - Asn-Type-Desc - ostream - nmdescs - mdescs - desc -} diff --git a/SecuritySNACCRuntime/doc/mkchdr.1 b/SecuritySNACCRuntime/doc/mkchdr.1 deleted file mode 100644 index 45291fa5..00000000 --- a/SecuritySNACCRuntime/doc/mkchdr.1 +++ /dev/null @@ -1,60 +0,0 @@ -.\" Copyright (c) 1993 by Mike Sample and UBC -.\" See section COPYING for conditions for redistribution -.\" $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/mkchdr.1,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -.\" $Log: mkchdr.1,v $ -.\" Revision 1.1.1.1 2001/05/18 23:14:10 mb -.\" Move from private repository to open source repository -.\" -.\" Revision 1.1.1.1 1999/03/16 18:05:53 aram -.\" Originals from SMIME Free Library. -.\" -.\" Revision 1.2 1997/01/01 22:47:18 rj -.\" first check-in -.\" -.TH MKCHDR 1 "11 July 1993" -.SH NAME -mkchdr \- creates a C header file from a type table -.SH SYNOPSIS -.nf -mkchdr [output-file] -.SH DESCRIPTION -mkchdr will generate a C header file from the given type table. The C -data structures will be written to the given output file. If an -output file is not given, the C header is written to stdout. - -The generated C data structure is the value representation that table -driven encoder expects (and decoder returns) for the type definitions -in the given type table. The table driven encoder and decoder, etc. -routines do not use the generated header - they treat the data in a -generic way. The generated header file simply saves you the hassle of -dealing with ASN.1 values in the same generic way. Instead you get -properly named structs and field names. You do not need to use mkchdr -to use the table driven encoders etc. but it is recommended. -.PP -.\" there is a tab between the file name and the description -.SH FILES -.PD 0 -.TP 28 -.B snacc/tbl-tools/mkchdr/ -Source code for the mkchdr program -.PD -.SH BUGS -There is no means of customizing the generated data structure. -.SH COPYING -Copyright (c) 1993 Mike Sample and the University of British Columbia -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -.SH AUTHOR -Mike Sample , University of British Columbia -.SH ACKNOWLEDGEMENTS -This work was made possible by grants from the Canadian Institute for -Telecommunications Research (CITR) and Natural Sciences and -Engineering Research Council of Canada (NSERC). diff --git a/SecuritySNACCRuntime/doc/modifying.tex b/SecuritySNACCRuntime/doc/modifying.tex deleted file mode 100644 index 7d2a73c1..00000000 --- a/SecuritySNACCRuntime/doc/modifying.tex +++ /dev/null @@ -1,49 +0,0 @@ -% file: .../doc/modifying.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/modifying.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: modifying.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:54 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:44 rj -% first check-in -% - -\chapter{\label{modifying-chapter}Modifying the Compiler} - -The compiler consists of about 30,000 lines of yacc, lex and C code -(another 7,000+ for the runtime library routines). The best way to -understand the compiler internals is to understand the module data -structure ({\ufn \dots/compiler/core/asn1module.h}) and to read the compiler -chapter in this document to gain a conceptual understanding of each -pass of the compiler. - -The most common form of modification will likely be for macro -handling. To understand this, look at the way the OBJECT-TYPE macro is -treated in: -\begin{description} -\item[lex-asn1.l] {add any new keywords} -\item[parse-asn1.y] { parse the macro into the desired data structure. -Use the existing productions as much as possible.} -\item[link-type.c] { link any type defined or referenced in the -macro} -\item[link-values.c] { link any value defined or referenced in the -macro} -\item[do-macros.c] { perform any semantic action for the macro } - -\item[normalize.c] { move any type and value definitions in the macro -to the top level so the code generator can generate code for them -(without looking in the macro).} - -\item[code generators] { to convert any special semantics into useful -C or C++. This phase is likely to be dependent on the generated -code's target environment.} -\end{description} - -In general I have tried to put comments where funky things happen and -to use function and variable names that are meaningful. However, -things may get ugly in certain places. Thesis writing is harmful to -your coding style! diff --git a/SecuritySNACCRuntime/doc/ptbl.1 b/SecuritySNACCRuntime/doc/ptbl.1 deleted file mode 100644 index 314ce60c..00000000 --- a/SecuritySNACCRuntime/doc/ptbl.1 +++ /dev/null @@ -1,64 +0,0 @@ -.\" Copyright (c) 1993 by Mike Sample and UBC -.\" See section COPYING for conditions for redistribution -.\" $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/ptbl.1,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -.\" $Log: ptbl.1,v $ -.\" Revision 1.1.1.1 2001/05/18 23:14:10 mb -.\" Move from private repository to open source repository -.\" -.\" Revision 1.1.1.1 1999/03/16 18:05:54 aram -.\" Originals from SMIME Free Library. -.\" -.\" Revision 1.2 1997/01/01 22:47:19 rj -.\" first check-in -.\" -.TH PTBL 1 "11 July 1993" -.SH NAME -ptbl \- print a type table -.SH SYNOPSIS -.nf -ptbl [\-a] -.SH DESCRIPTION - -ptbl prints the give type table to stdout. It will print it in one of -two formats: internal style and ASN.1 stlye. The internal style shows -the contents of the type table data structure in ASN.1 value notation. -You will need to look at the tbl.asn1 file to understand the internal -form. The ASN.1 form attempts to re-create the ASN.1 that generated -the given type table. - -.SH OPTIONS - -.TP -.B \-a -Print the table in ASN.1 style (recommended) -.PP -.\" there is a tab between the file name and the description -.SH FILES -.PD 0 -.TP 28 -.B snacc/tbl-tools/ptbl/ -Source code for the ptbl program -.B snacc/asn1specs/tbl.asn1 -ASN.1 definition for the type table data structure -.PD -.SH BUGS -ptbl does not attempt to print the IMPORTs information even though it -is possible with a bit of work. -.SH COPYING -Copyright (c) 1993 Mike Sample and the University of British Columbia -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -.SH AUTHOR -Mike Sample , University of British Columbia -.SH ACKNOWLEDGEMENTS -This work was made possible by grants from the Canadian Institute for -Telecommunications Research (CITR) and Natural Sciences and -Engineering Research Council of Canada (NSERC). diff --git a/SecuritySNACCRuntime/doc/pval.1 b/SecuritySNACCRuntime/doc/pval.1 deleted file mode 100644 index 9e7a379a..00000000 --- a/SecuritySNACCRuntime/doc/pval.1 +++ /dev/null @@ -1,63 +0,0 @@ -.\" Copyright (c) 1993 by Mike Sample and UBC -.\" See section COPYING for conditions for redistribution -.\" $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/pval.1,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -.\" $Log: pval.1,v $ -.\" Revision 1.1.1.1 2001/05/18 23:14:10 mb -.\" Move from private repository to open source repository -.\" -.\" Revision 1.1.1.1 1999/03/16 18:05:54 aram -.\" Originals from SMIME Free Library. -.\" -.\" Revision 1.2 1997/01/01 22:47:20 rj -.\" first check-in -.\" -.TH PVAL 1 "11 July 1993" -.SH NAME -pval \- print BER values in ASN.1 value notation -.SH SYNOPSIS -.nf -pval \-T [\-m ] \-n - -.SH DESCRIPTION -pval prints the given BER values in their value notation. You must -specify the type name and optionally the module name of the type in -the given BER files. -.SH OPTIONS -.TP -.BI "\-T " file\c -Use the type table in the file to look for the named types definition. -.TP -.BI "\-m " modulename\c -Specifies the module in which the named type is defined. If the -module name is not specified with this option, pval looks for the -first occurence of the named type in the modules in the given type -table. -.TP -.BI "\-n " typename\c -Specifies the type of the values in the given BER files. If you -give the wrong type name, decoding errors will occur. -.PP -.\" there is a tab between the file name and the description -.SH FILES -.PD 0 -.TP 28 -.B snacc/tbl-tools/pval/ -Source code for the pval program -.SH COPYING -Copyright (c) 1993 Mike Sample and the University of British Columbia -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -.SH AUTHOR -Mike Sample , University of British Columbia -.SH ACKNOWLEDGEMENTS -This work was made possible by grants from the Canadian Institute for -Telecommunications Research (CITR) and Natural Sciences and -Engineering Research Council of Canada (NSERC). diff --git a/SecuritySNACCRuntime/doc/snacc.1 b/SecuritySNACCRuntime/doc/snacc.1 deleted file mode 100644 index ab05da58..00000000 --- a/SecuritySNACCRuntime/doc/snacc.1 +++ /dev/null @@ -1,305 +0,0 @@ -.\" Copyright (c) 1993 by Mike Sample and UBC -.\" See section COPYING for conditions for redistribution -.\" $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/snacc.1,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -.\" $Log: snacc.1,v $ -.\" Revision 1.1.1.1 2001/05/18 23:14:10 mb -.\" Move from private repository to open source repository -.\" -.\" Revision 1.1.1.1 1999/03/16 18:05:54 aram -.\" Originals from SMIME Free Library. -.\" -.\" Revision 1.3 1997/02/16 15:26:26 rj -.\" made return *this after calling abort()'' a compile time option. -.\" -.\" Revision 1.2 1997/01/01 22:47:16 rj -.\" first check-in -.\" -.TH SNACC 1 "11 July 1993" -.SH NAME -snacc \- ASN.1 to C, C++ or type table Compiler -.SH SYNOPSIS -.nf -snacc [\-h] [\-P] [\-t] [\-e] [\-d] [\-p] [\-f]\p - [\-c | \-C | \-idl | \-T
]\p - [\-u ]\p - [\-mf ]\p - [\-l ]\p - [\-meta] [\-tcl ]\p - [\-novolat]\p - -.SH -For complete and current documentation, refer to the snacc manual. -.I -.SH DESCRIPTION -Snacc (Sample Neufeld Asn.1 to C/C++ Compiler) generates C or C++ -source code for BER encode and decode routines as well as print and -free routines for each type in the given ASN.1 modules. -Alternatively, snacc can produce type tables that can be used for -table based/interpreted encoding and decoding. The type table based -methods tend to be slower than their C or C++ counterparts but they -usually use less memory (table size vs. C/C++ object code). - -Most of the 1990 ASN.1 features are parsed although some do not affect -the generated code. Fairly rigourous error checking is performed on -the ASN.1 source; any errors detected will be reported (printed to -stderr). - -Each file in the ASN.1 file list should contain a complete ASN.1 -module. ASN.1 modules that use the IMPORTS feature must be compiled -together (specify all necessary modules in the ASN.1 file list). The -generated source files will include each module's header file in the -command line order. This makes it important to order the modules from -least dependent to most dependent on the command line to avoid type -ordering problems. Currently, snacc assumes that each ASN.1 file -given on the command line depends on all of the others on the command -line. No attempt is made to only include the header files from -modules referenced in the import list for that module. - -If the target language is C, snacc will generate a \c -.B .h -and -.B .c -file for each specified ASN.1 module. If the target language is C++, -snacc will generate a -.B .h -and -.B .C -file for each module. The generated file names will be derived from the -module names. - -.SH OPTIONS - -.TP -.B \-h -Help. Prints a synopsis of snacc and exits. -.TP -.B \-c -Generate C source code. This is the default behaviour of snacc. -Only one of \c -.B \-c -, -.B \-C -or -.B \-T -should be specified. -.TP -.B \-C -Generate C++ source code. -.TP -.B \-novolat -Generate ``return *this'' after calling ``abort()''. -(Some broken compilers don't know about volatile functions, or their abort() isn't correctly typed.) -.TP -.B -meta -Generate meta code that describes the generated types. -Implies -C. -.TP -.B -tcl -.IR module.type [, module.type ] -Generate code for a Tcl interpreter where \fImodule.type\fP are the top level PDUs. -Implies -meta. -.TP -.BI "\-T " file\c -This causes snacc to generate type tables and write them to the given -file. -.TP -.B \-P -This causes snacc to print the parsed ASN.1 modules to stdout after -the types have been linked, sorted, and processed. This option is -useful for debugging snacc and observing the modifications snacc -performs on the types to make code generation simpler. -.TP -.B \-t -Generate type definitions in the target language for each ASN.1 type. -.TP -.B \-v -Generate value definitions in the target language for each ASN.1 value. -Currently value definitions are limited to INTEGERs, BOOLEANs and -OBJECT IDENTIFIERs. -.TP -.B \-e -Generate encode routines in the target language for each ASN.1 type. -.TP -.B \-d -Generate decode routines in the target language for each ASN.1 type. -.TP -.B \-p -Generate print routines in the target language for each ASN.1 type. -.TP -.B \-f -Generate free routines in the target language for each ASN.1 type. -This option only works when the target language is C. - -If none of the -.B \-t, \-v, \-e, \-d, \-p, or \-f -options are given on -the command line, snacc assumes that all of them are in effect. -They do not affect type table generation. -.TP -.BI "\-u " file\c -\&Read the useful types definitions from the ASN.1 module in file \c -.I file\c -\& for linking purposes. For some ASN.1 specifications, such as SNMP, -the useful types are not needed. The types in the given useful types -file are globally available to all modules; a useful type definition -is overridden by a local or explicitly imported type with the same -name. The current list of useful types is: -.RS 9 -ObjectDecscriptor -.br -NumericString -.br -PrintableString -.br -TeletexString -.br -T61String -.br -VideoTexString -.br -IA5String -.br -GraphicString -.br -ISO646String -.br -GeneralString -.br -UTCTime -.br -GeneralizedTime -.br -EXTERNAL -.RE -.TP -.BI "\-mf " number\c -\&This causes the generated source files to have a -maximum length of \c -.I number\c - characters, including their suffix. The \c -.I number\c - must be at least 3. This option is useful for supporting operating -systems that only support short file names. A better solution is to -shorten the module name of each ASN.1 module. - -.TP -.BI "\-l " number\c -\&This is fairly obscure but may be useful. Each error that the -decoders can report is given an id number. The number \c -.I number\c - is where the error ids start decreasing from as they are assigned to -errors . The default is -100 if this option is not given. Avoid -using a number in the range -100 to 0 since they may conflict with the -library routines' error ids. If you are re-compiling the useful types -for the library use -50. Another use of this option is to integrate -newly generated code with older code; if done correctly, the error ids -will not conflict. - -.PP -.\" there is a tab between the file name and the description -.SH FILES -.PD 0 -.TP 28 -.B snacc/asn1specs/asn-useful.asn1 -ASN.1 useful types module (use with \-u option) -.TP -.B snacc/c-lib/inc/ -C runtime library include files -.TP -.B snacc/c-lib/libasn1csbuf.a -C SBuf runtime library -.TP -.B snacc/c-lib/libasn1cmbuf.a -C MinBuf runtime library -.TP -.B snacc/c-lib/libasn1cebuf.a -C ExpBuf runtime library -.TP -.B snacc/c++-lib/inc/ -C++ runtime library include files -.TP -.B snacc/c++-lib/libasn1c++.a -C++ runtime library -.TP -.B snacc/c-lib/inc/tbl*/ -Type table runtime library include files -.TP -.B snacc/c-lib/libasn1ctbl.a -Type table runtime library -.TP -.B snacc/tbl-tools/ -Source code for table based tools (mkchdr, ptbl, pval) -.TP -.B snacc/c-examples/ -directory with ASN.1 to C examples -.TP -.B snacc/c++-examples/ -directory with ASN.1 to C++ examples -.TP -.B snacc/tbl-example -directory with an ASN.1 to type table example -.TP -.B snacc/doc -directory with snacc documentation and this man page -.PD -.SH BUGS -Snacc has problems with the following case: -.RS -.nf - -Foo ::= SEQUENCE -{ - id IdType, - val ANY DEFINED BY id -} - -IdType ::= CHOICE -{ - a INTEGER, - b OBJECT IDENTIFIER -} - -.fi -.RE -The error checking pass will print an error to the effect that the id -type must be INTEGER or OBJECT IDENTIFER. To fix this you must modify -the error checking pass as well as the code generation pass. To be -cheap about it, disable/fix the error checking and hand modify the -generated code. - -The hashing code used for handling ANY DEFINED BY id to type mappings -will encounter problems if the hash table goes more than four levels -deep (I think this is unlikely). To fix this just add linear chaining -at fourth level. - -Please send bug reports or comments to -.\".BR snacc-bugs@cs.ubc.ca . -.BR "Robert Joop " . -See the documentation about reporting bugs and (lack of) support. -.SH COPYING -Copyright (c) 1993 Mike Sample and the University of British Columbia -.br -Copyright (c) 1994 1995 Robert Joop and GMD Fokus. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -The snacc compiler is released under the GNU General Public License. -The runtime libraries are no longer under the GNU Library General -Public License. The generated code is yours. -.SH AUTHOR -Snacc was written by Mike Sample at the University of British Columbia -(UBC). He used it as a tool to do encoding/decoding performance -research. -.PP -It was augmented by Robert Joop at GMD Fokus with the help of some of its project partners. -.SH ACKNOWLEDGEMENTS -This work was made possible by grants from the Canadian Institute for -Telecommunications Research (CITR) and Natural Sciences and -Engineering Research Council of Canada (NSERC). diff --git a/SecuritySNACCRuntime/doc/snacc.bib b/SecuritySNACCRuntime/doc/snacc.bib deleted file mode 100644 index 601a09d9..00000000 --- a/SecuritySNACCRuntime/doc/snacc.bib +++ /dev/null @@ -1,269 +0,0 @@ -% file: .../doc/snacc.bib - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/snacc.bib,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: snacc.bib,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:54 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:50 rj -% first check-in -% - -@article{CASN1, - author = "Gerald Neufeld and Yeuli Yang", - title = "An ASN.1 to C Compiler", - journal = "IEEE Transactions on Software Engineering", - year = "1990", - month = "Oct", - volume = "16", - number = "10", - pages = "1209-1220", - key = "CASN1", - keywords = "ASN.1 Compiler" -} - - -@inbook{X.208, - author = "CCITT", - title = "Data Communications Networks Open systems Interconnection (OSI) Model and Notation, Service Defintion", - chapter = "Recommendation X.208, Specification of Abstract Syntax -Notation One (ASN.1)", - pages = "57-130", - publisher = "Omnicom", - year = "1989", - month = "November", - address = "115 Park St., S.E., Vienna, VA 22180 USA", - series = "Blue Book", - number = "Fascicle VIII.4", - keywords = "ASN.1" -} - -@inbook{X.209, - author = "CCITT", - title = "Data Communications Networks Open systems Interconnection (OSI) Model and Notation, Service Defintion", - chapter = "Recommendation X.209, Specification of Basic Encoding -Rules for Abstract Syntax Notation One (ASN.1)", - pages = "130-151", - publisher = "Omnicom", - year = "1989", - month = "November", - address = "115 Park St., S.E., Vienna, VA 22180 USA", - series = "Blue Book", - number = "Fascicle VIII.4", - keywords = "BER" -} - - - -@manual{ISODE, - title = "ISODE, The ISO Development Environment: User Manual", - author = "Marshall T. Rose", - organization = "Wollongong Group", - address = "1129 San Antonio Rd. Palo Alto, California, USA", - year = "1990", - month = "February" -} - - - - -@book{68881, - author = "Motorola Inc.", - title = "MC68881 Floating-Point Coprocessor User's Manual", - publisher = "Motorola Inc.", - year = "1985", - pages = "2-9 to 2-15", - key = "68881" -} - - - -@book{ASN.1Book, - author = "Douglas Steedman", - title = "ASN.1, The Tutorial and Reference", - publisher = "Technology Appraisals Ltd.", - year = "1990", - note = "ISBN 1 871802 06 7" -} - -@article{ASN.1Overview, - author = "Gerald Neufeld and Son Vuong", - title = "An Overview of ASN.1", - journal = "IEEE Networks and ISDN Systems", - year = "1992", - month = "Feb", - volume = "23", - number = "5", - pages = "393-415" -} - - - -@article{Sample93-1, - author = "Michael Sample and Gerald Neufeld", - title = "Implementing Efficient Encoders and Decoders for Network Data Representations", - journal = "IEEE INFOCOM '93 Proceedings", - year = "1993", - month = "Mar", - volume = "3", - pages = "1144-1153", - key = "Sample93-2", - ms-label = "Sample93-2" -} - - - -@mastersthesis{Sample93-2, - author = "Michael Sample", - title = "How Fast Can ASN.1 Encoding Rules Go?", - school = "University of British Columbia", - year = "1993", - month = "April", - address = "Vancouver, B.C. Canada V6T 1Z2" -} - - -@article{TCPOverhead, - author = "David D. Clark and Van Jacobson and John Romkey and Howard Salwen", - title = "An Analysis of TCP Processing Overhead", - journal = "IEEE Communications Magazine", - year = "1989", - month = "June", - pages = "23-29" -} - -@article{NewProts, - author = "David D. Clark and David L. Tennenhouse", - title = "Architectural Considerations for a New Generation of Protocols", - journal = "SIGCOMM '90", - year = "1990", - month = "Sept", - volume = "20", - number = "4", - pages = "200-208" -} - - - - -@inbook{X.500, - author = "CCITT", - title = "", - chapter = "Recommendation X.500, OSI:Specification of the -Distributed Directory System", - pages = "131-151", - publisher = "Omnicom", - year = "1989", - month = "November", - address = "115 Park St., S.E., Vienna, VA 22180 USA", - series = "Blue Book", - number = "Fascicle VIII.8", - keywords = "X.500, Distributed, Directory" -} - - - - -@article{lwer, - author = "Christian Huitema and Assem Doghri", - title = "Defining Faster Transfer Syntaxes for the OSI Presentation Layer", - journal = "Sigcomm Computer Communication Review", - year = "1989", - month = "Oct", - volume = "19", - number = "5" -} - - -@article{ASN1Perf, - author = "Christian Huitema and Ghislain Chave", - title = "Measuring the Performances fo an ASN.1 Compiler", - journal = "Upper Layer Protocols, Architechtures and Applications", - year = "1992", - month = "May", - pages = "99-112" -} - -@inbook{X.400, - author = "CCITT", - title = "Data Communicatio Networks Message Handling Systems", - chapter = "Recommendation X.400-X.420, Message Handling Systems", - pages = "57-130", - publisher = "Omnicom", - year = "1989", - month = "November", - address = "115 Park St., S.E., Vienna, VA 22180 USA", - series = "Blue Book", - number = "Fascicle VIII.7", - keywords = "ASN.1" -} - - - -@book{X.400, - author = "CCITT", - title = "Data Communication Networks Message Handling Systems, -Recommendations X.400-X.420", - publisher = "Omnicom", - year = "1989", - month = "Nov", - address = "115 Park St., S.E., Vienna, VA 22180 USA", - series = "Blue Book", - number = "Fascicle VIII.7" -} - - -@book{stroustrup, - author = "Bjarne Stroustrup", - title = "The C++ Programming Language, 2nd Edition", - publisher = "Addison-Wesley Publishing Co.", - year = "1991", - note = "ISBN 0201539926" -} - -@misc{snmp, - author = "M. Rose and K. McCloghrie", - title = "Structure and Identification of Management Information for TCP/IP-based Internets (RFC 1155)", - howpublished = "Network Information Center, SRI International", - month = "May", - year = "1990", -} - -@book{tnhd, - title = "The New Hacker's Dictionary", - editor = "Eric Raymond", - publisher = "The MIT Press, Cambridge, Mass, London, England", - year = 1991, - note = "ISBN 0-262-68069-6" -} - -@misc{asn1:1987, - author = "ISO", - number = "ISO 8824:1987(E)", - title = "Information processing systems---Open Systems Interconnection---Specification of Abstract Syntax Notation One (ASN.1)" -} - -@misc{asn1:1993, - author = "ISO", - number = "ISO/IEC DIS 8824-1", - title = "Information technology---Open Systems Interconnection---Abstract Syntax Notation One (ASN.1)" -} - -@misc{ber:1987, - author = "ISO", - number = "ISO 8825:1987(E)", - title = "Information processing systems---Open Systems Interconnection---Specification of Basic Encoding Rules for Abstract Syntax Notation One (ASN.1)" -} - -%project: -% Programming Language C++ -@misc{c++-draft, - author = "ISO", - title = "Working Paper for Draft Proposed International Standard for Information Systems---Programming Language C++", - number = "X3J16/95-0087", - date = "28 April 1995", - month = "28~" # apr, year = 1995, -} diff --git a/SecuritySNACCRuntime/doc/snacc.n b/SecuritySNACCRuntime/doc/snacc.n deleted file mode 100644 index b54521e1..00000000 --- a/SecuritySNACCRuntime/doc/snacc.n +++ /dev/null @@ -1,242 +0,0 @@ -'\" This manual page, except for the introductory troff macros, is -'\" Copyright (c) 1995 by Robert Joop. -'\" -'\" $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/snacc.n,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -'\" $Log: snacc.n,v $ -'\" Revision 1.1.1.1 2001/05/18 23:14:10 mb -'\" Move from private repository to open source repository -'\" -'\" Revision 1.1.1.1 1999/03/16 18:05:54 aram -'\" Originals from SMIME Free Library. -'\" -'\" Revision 1.1 1997/01/01 22:47:24 rj -'\" first check-in -'\" -'\" -'\" Copyright (c) 1993 The Regents of the University of California. -'\" All rights reserved. -'\" -'\" Permission is hereby granted, without written agreement and without -'\" license or royalty fees, to use, copy, modify, and distribute this -'\" documentation for any purpose, provided that the above copyright -'\" notice and the following two paragraphs appear in all copies. -'\" -'\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY -'\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES -'\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF -'\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -'\" -'\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, -'\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -'\" AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -'\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO -'\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -'\" -.\" The definitions below are for supplemental macros used in Tcl/Tk -.\" manual entries. -.\" -.\" .HS name section [date [version]] -.\" Replacement for .TH in other man pages. See below for valid -.\" section names. -.\" -.\" .AP type name in/out [indent] -.\" Start paragraph describing an argument to a library procedure. -.\" type is type of argument (int, etc.), in/out is either "in", "out", -.\" or "in/out" to describe whether procedure reads or modifies arg, -.\" and indent is equivalent to second arg of .IP (shouldn't ever be -.\" needed; use .AS below instead) -.\" -.\" .AS [type [name]] -.\" Give maximum sizes of arguments for setting tab stops. Type and -.\" name are examples of largest possible arguments that will be passed -.\" to .AP later. If args are omitted, default tab stops are used. -.\" -.\" .BS -.\" Start box enclosure. From here until next .BE, everything will be -.\" enclosed in one large box. -.\" -.\" .BE -.\" End of box enclosure. -.\" -.\" .VS -.\" Begin vertical sidebar, for use in marking newly-changed parts -.\" of man pages. -.\" -.\" .VE -.\" End of vertical sidebar. -.\" -.\" .DS -.\" Begin an indented unfilled display. -.\" -.\" .DE -.\" End of indented unfilled display. -.\" -'\" # Heading for Tcl/Tk man pages -.de HS -.ds ^3 \\0 -.if !"\\$3"" .ds ^3 \\$3 -.if '\\$2'cmds' .TH \\$1 1 \\*(^3 \\$4 -.if '\\$2'lib' .TH \\$1 3 \\*(^3 \\$4 -.if '\\$2'tcl' .TH \\$1 n \\*(^3 Tcl "Tcl Built-In Commands" -.if '\\$2'tk' .TH \\$1 n \\*(^3 Tk "Tk Commands" -.if '\\$2'tclc' .TH \\$1 3 \\*(^3 Tcl "Tcl Library Procedures" -.if '\\$2'tkc' .TH \\$1 3 \\*(^3 Tk "Tk Library Procedures" -.if '\\$2'tclcmds' .TH \\$1 1 \\*(^3 Tk "Tcl Applications" -.if '\\$2'tkcmds' .TH \\$1 1 \\*(^3 Tk "Tk Applications" -.if t .wh -1.3i ^B -.nr ^l \\n(.l -.ad b -.. -'\" # Start an argument description -.de AP -.ie !"\\$4"" .TP \\$4 -.el \{\ -. ie !"\\$2"" .TP \\n()Cu -. el .TP 15 -.\} -.ie !"\\$3"" \{\ -.ta \\n()Au \\n()Bu -\&\\$1 \\fI\\$2\\fP (\\$3) -.\".b -.\} -.el \{\ -.br -.ie !"\\$2"" \{\ -\&\\$1 \\fI\\$2\\fP -.\} -.el \{\ -\&\\fI\\$1\\fP -.\} -.\} -.. -'\" # define tabbing values for .AP -.de AS -.nr )A 10n -.if !"\\$1"" .nr )A \\w'\\$1'u+3n -.nr )B \\n()Au+15n -.\" -.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n -.nr )C \\n()Bu+\\w'(in/out)'u+2n -.. -'\" # BS - start boxed text -'\" # ^y = starting y location -'\" # ^b = 1 -.de BS -.br -.mk ^y -.nr ^b 1u -.if n .nf -.if n .ti 0 -.if n \l'\\n(.lu\(ul' -.if n .fi -.. -'\" # BE - end boxed text (draw box now) -.de BE -.nf -.ti 0 -.mk ^t -.ie n \l'\\n(^lu\(ul' -.el \{\ -.\" Draw four-sided box normally, but don't draw top of -.\" box if the box started on an earlier page. -.ie !\\n(^b-1 \{\ -\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' -.\} -.el \}\ -\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' -.\} -.\} -.fi -.br -.nr ^b 0 -.. -'\" # VS - start vertical sidebar -'\" # ^Y = starting y location -'\" # ^v = 1 (for troff; for nroff this doesn't matter) -.de VS -.mk ^Y -.ie n 'mc \s12\(br\s0 -.el .nr ^v 1u -.. -'\" # VE - end of vertical sidebar -.de VE -.ie n 'mc -.el \{\ -.ev 2 -.nf -.ti 0 -.mk ^t -\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' -.sp -1 -.fi -.ev -.\} -.nr ^v 0 -.. -'\" # Special macro to handle page bottom: finish off current -'\" # box/sidebar if in box/sidebar mode, then invoked standard -'\" # page bottom macro. -.de ^B -.ev 2 -'ti 0 -'nf -.mk ^t -.if \\n(^b \{\ -.\" Draw three-sided box if this is the box's first page, -.\" draw two sides but no top otherwise. -.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c -.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c -.\} -.if \\n(^v \{\ -.nr ^x \\n(^tu+1v-\\n(^Yu -\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c -.\} -.bp -'fi -.ev -.if \\n(^b \{\ -.mk ^y -.nr ^b 2 -.\} -.if \\n(^v \{\ -.mk ^Y -.\} -.. -'\" # DS - begin display -.de DS -.RS -.nf -.sp -.. -'\" # DE - end display -.de DE -.fi -.RE -.sp .5 -.. -.\" stupid HS macros hasn't got the right ability! -.TH snacc n "August 1995" Tcl "Tcl Extensions" -.BS -'\" Note: do not modify the .SH NAME line immediately below! -.SH NAME -snacc \- Manipulate BER encoded files -.SH SYNOPSIS -\fBsnacc \fIoption\fR ?\fIarg arg ...\fR? -.BE - -.SH DESCRIPTION -.PP -This command provides several operations on BER encoded files. -Those files can be created, opened, read, its contents examined and -manipulated and written to disk, as indicated by the \fIoption\fR. -The valid options are: -.TP -\fBsnacc create \fItype\fR -.TP -\fBsnacc open \fItype filename ?flags? ?mode?\fR -\fBfile \fBdirname \fIname\fR - -.SH SEE ALSO -.IR snacced (1) -.SH KEYWORDS -ASN.1, BER, file diff --git a/SecuritySNACCRuntime/doc/snacc.tex b/SecuritySNACCRuntime/doc/snacc.tex deleted file mode 100644 index ee34ca4d..00000000 --- a/SecuritySNACCRuntime/doc/snacc.tex +++ /dev/null @@ -1,172 +0,0 @@ -% file: .../doc/snacc.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/snacc.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: snacc.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:54 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:25 rj -% first check-in -% - -\input{misc-hyph} - -% different methods get a backslash: -% \verb_\_ -> Courier -% \char`\\ -> Times-Roman -% $\backslash$ -> math font - -% for 2up (2x A5 on A4): -%\def\fmtsize{12pt} -%% for A4: -\def\fmtsize{10pt} - -\documentclass[\fmtsize,a4paper,twoside]{report} -\usepackage{t1enc} -\usepackage{isolatin1} -\usepackage{times} -%\usepackage{latexsym} -\usepackage{amssymb} -\usepackage[dvips]{graphicx} - -\sloppypar - -\newlength{\spacing} -\setlength{\spacing}{\baselineskip} -\newcommand{\nspace}[1]{\setlength{\baselineskip}{#1\spacing}} -\newenvironment{linespacing}[1]{\nspace{#1}}{} - -%% myitemize environment---less space between items -%\newenvironment{myitemize}[0]{\begin{itemize}\nspace{0.5}} {\end{itemize}} - -%\setlength{\topmargin}{-.50in} -%\setlength{\textwidth}{6.0in} -%\setlength{\textheight}{8.5in} -%\setlength{\oddsidemargin}{.25in} -\def\myparindent{0in} -\setlength{\parindent}{\myparindent} -\def\myparskip{8pt} -\setlength{\parskip}{\myparskip} -%\def\myparsep{\parsep} -%\def\myitemsep{\itemsep} - -\input{misc-defs} - -\include{version} - -\begin{document} -\thispagestyle{empty} -\title{Snacc 1.2rj: A High Performance ASN.1 to C/C++/IDL Compiler} -\author{Michael Sample\\ - msample@cs.ubc.ca\\\\ - Department of Computer Science\\ - University of British Columbia\\ - 6356 Agricultural Rd.\\ - Vancouver, British Columbia\\ - Canada, V6T 1Z2\\\\ - \\ - augmented by:\\ - Robert Joop\\ - $<$rj@rainbow.in-berlin.de$>$} -%\date{February 1993, updated July 1993, -%augmented by Robert Joop $<$rj@rainbow.in-berlin.de$>$ 1994/1995} -\date{msample: February 1993, updated July 1993\\ -rj: 1994/1995\\ -\quad\\ -\emph{Preliminary documentation as of \today\\for Snacc \snaccversion} -} -\maketitle - -% copyright notice on software and documentation - -This work was made possible by grants from the Canadian Institute for -Telecommunications Research (CITR) and Natural Sciences and -Engineering Research Council of Canada (NSERC). - -Copyright (C) 1990, 1991, 1992, 1993 Michael Sample - and the University of British Columbia - -Copyright \copyright 1994, 1995 Robert Joop - and GMD FOKUS - -This program, Snacc, 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. - -The runtime libraries are copyright to the University of British -Columbia and Michael Sample. They are free software; you can -redistribute them and/or modify them as long as the original, -unmodified copyright information with/in them. The GNU Library -Public License has been removed as of version 1.1. - -What we're trying to say is: you can't sell the compiler but you can -sell products that use the code generated by the compiler and the -runtime libraries. - -This program and the associated libraries are distributed in the hope -that they 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 and -the GNU Library General Public License along with this program; if -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA\@. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -% table of contents -%\setlength{\parskip}{0pt} -\tableofcontents -%\setlength{\parskip}{\myparskip} - -% list of figures -\listoffigures - -% list of tables -%listoftables - -\include{intro-1.2} -\include{intro-1.1} - -\include{design} - -\include{c-gen} -\include{c-lib} -\include{c++-gen} -\include{c++-lib} - -\include{meta} -\include{tcl} -\include{editor} - -\include{idl-gen} - -\include{ttab} - -\include{modifying} - -\include{future-work} - -\appendix - -\include{asn1-defs} - -\include{coding} -\include{makefile} - -\bibliography{snacc,corba,tcl} -\bibliographystyle{plain} - -\end{document} diff --git a/SecuritySNACCRuntime/doc/snacced.1 b/SecuritySNACCRuntime/doc/snacced.1 deleted file mode 100644 index 9b60a7a2..00000000 --- a/SecuritySNACCRuntime/doc/snacced.1 +++ /dev/null @@ -1,248 +0,0 @@ -'\" This manual page, except for the introductory troff macros, is -'\" Copyright (c) 1995 by Robert Joop. -'\" -'\" $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/snacced.1,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -'\" $Log: snacced.1,v $ -'\" Revision 1.1.1.1 2001/05/18 23:14:10 mb -'\" Move from private repository to open source repository -'\" -'\" Revision 1.1.1.1 1999/03/16 18:05:54 aram -'\" Originals from SMIME Free Library. -'\" -'\" Revision 1.1 1997/01/01 22:47:21 rj -'\" first check-in -'\" -'\" -'\" Copyright (c) 1993 The Regents of the University of California. -'\" All rights reserved. -'\" -'\" Permission is hereby granted, without written agreement and without -'\" license or royalty fees, to use, copy, modify, and distribute this -'\" documentation for any purpose, provided that the above copyright -'\" notice and the following two paragraphs appear in all copies. -'\" -'\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY -'\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES -'\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF -'\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -'\" -'\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, -'\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -'\" AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -'\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO -'\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -'\" -.\" The definitions below are for supplemental macros used in Tcl/Tk -.\" manual entries. -.\" -.\" .HS name section [date [version]] -.\" Replacement for .TH in other man pages. See below for valid -.\" section names. -.\" -.\" .AP type name in/out [indent] -.\" Start paragraph describing an argument to a library procedure. -.\" type is type of argument (int, etc.), in/out is either "in", "out", -.\" or "in/out" to describe whether procedure reads or modifies arg, -.\" and indent is equivalent to second arg of .IP (shouldn't ever be -.\" needed; use .AS below instead) -.\" -.\" .AS [type [name]] -.\" Give maximum sizes of arguments for setting tab stops. Type and -.\" name are examples of largest possible arguments that will be passed -.\" to .AP later. If args are omitted, default tab stops are used. -.\" -.\" .BS -.\" Start box enclosure. From here until next .BE, everything will be -.\" enclosed in one large box. -.\" -.\" .BE -.\" End of box enclosure. -.\" -.\" .VS -.\" Begin vertical sidebar, for use in marking newly-changed parts -.\" of man pages. -.\" -.\" .VE -.\" End of vertical sidebar. -.\" -.\" .DS -.\" Begin an indented unfilled display. -.\" -.\" .DE -.\" End of indented unfilled display. -.\" -'\" # Heading for Tcl/Tk man pages -.de HS -.ds ^3 \\0 -.if !"\\$3"" .ds ^3 \\$3 -.if '\\$2'cmds' .TH \\$1 1 \\*(^3 \\$4 -.if '\\$2'lib' .TH \\$1 3 \\*(^3 \\$4 -.if '\\$2'tcl' .TH \\$1 n \\*(^3 Tcl "Tcl Built-In Commands" -.if '\\$2'tk' .TH \\$1 n \\*(^3 Tk "Tk Commands" -.if '\\$2'tclc' .TH \\$1 3 \\*(^3 Tcl "Tcl Library Procedures" -.if '\\$2'tkc' .TH \\$1 3 \\*(^3 Tk "Tk Library Procedures" -.if '\\$2'tclcmds' .TH \\$1 1 \\*(^3 Tk "Tcl Applications" -.if '\\$2'tkcmds' .TH \\$1 1 \\*(^3 Tk "Tk Applications" -.if t .wh -1.3i ^B -.nr ^l \\n(.l -.ad b -.. -'\" # Start an argument description -.de AP -.ie !"\\$4"" .TP \\$4 -.el \{\ -. ie !"\\$2"" .TP \\n()Cu -. el .TP 15 -.\} -.ie !"\\$3"" \{\ -.ta \\n()Au \\n()Bu -\&\\$1 \\fI\\$2\\fP (\\$3) -.\".b -.\} -.el \{\ -.br -.ie !"\\$2"" \{\ -\&\\$1 \\fI\\$2\\fP -.\} -.el \{\ -\&\\fI\\$1\\fP -.\} -.\} -.. -'\" # define tabbing values for .AP -.de AS -.nr )A 10n -.if !"\\$1"" .nr )A \\w'\\$1'u+3n -.nr )B \\n()Au+15n -.\" -.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n -.nr )C \\n()Bu+\\w'(in/out)'u+2n -.. -'\" # BS - start boxed text -'\" # ^y = starting y location -'\" # ^b = 1 -.de BS -.br -.mk ^y -.nr ^b 1u -.if n .nf -.if n .ti 0 -.if n \l'\\n(.lu\(ul' -.if n .fi -.. -'\" # BE - end boxed text (draw box now) -.de BE -.nf -.ti 0 -.mk ^t -.ie n \l'\\n(^lu\(ul' -.el \{\ -.\" Draw four-sided box normally, but don't draw top of -.\" box if the box started on an earlier page. -.ie !\\n(^b-1 \{\ -\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' -.\} -.el \}\ -\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' -.\} -.\} -.fi -.br -.nr ^b 0 -.. -'\" # VS - start vertical sidebar -'\" # ^Y = starting y location -'\" # ^v = 1 (for troff; for nroff this doesn't matter) -.de VS -.mk ^Y -.ie n 'mc \s12\(br\s0 -.el .nr ^v 1u -.. -'\" # VE - end of vertical sidebar -.de VE -.ie n 'mc -.el \{\ -.ev 2 -.nf -.ti 0 -.mk ^t -\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' -.sp -1 -.fi -.ev -.\} -.nr ^v 0 -.. -'\" # Special macro to handle page bottom: finish off current -'\" # box/sidebar if in box/sidebar mode, then invoked standard -'\" # page bottom macro. -.de ^B -.ev 2 -'ti 0 -'nf -.mk ^t -.if \\n(^b \{\ -.\" Draw three-sided box if this is the box's first page, -.\" draw two sides but no top otherwise. -.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c -.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c -.\} -.if \\n(^v \{\ -.nr ^x \\n(^tu+1v-\\n(^Yu -\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c -.\} -.bp -'fi -.ev -.if \\n(^b \{\ -.mk ^y -.nr ^b 2 -.\} -.if \\n(^v \{\ -.mk ^Y -.\} -.. -'\" # DS - begin display -.de DS -.RS -.nf -.sp -.. -'\" # DE - end display -.de DE -.fi -.RE -.sp .5 -.. -.TH snacced 1 "August 1995" Tk "Tk Applications" -.BS -'\" Note: do not modify the .SH NAME line immediately below! -.SH NAME -snacced \- Graphical editor for BER encoded ASN.1 files -.SH SYNOPSIS -\fBsnacced \fIoption\fR ?\fImodule type file\fR? -.BE - -.SH DESCRIPTION -.PP -This command allowes to browse and edit BER encoded files. - -The snacced script needs to be executed by a snaccwish, a Tk shell (see \fIwish\fP(1)) -with additional snacc functionality (see \fIsnacc\fP(n)). - -For directions on how to build the snaccwish, please refer to the -snacc documentation. -.SH ARGUMENTS -.TP -\fBsnacced \fImodule type file\fR -Open \fIfile\fP that has to be an instance of type \fItype\fP in the ASN.1 module \fImodule\fP. -.TP -\fBsnacced \fImodule type\fR -Create an instance of the given type. -.TP -\fBsnacced\fR -Called without arguments, pops up a file and type selection box. -.SH SEE ALSO -.IR wish (1), snacc (n) -.SH KEYWORDS -ASN.1, BER, snaccwish, snacc, editor, file diff --git a/SecuritySNACCRuntime/doc/tcl.bib b/SecuritySNACCRuntime/doc/tcl.bib deleted file mode 100644 index 316b6fd3..00000000 --- a/SecuritySNACCRuntime/doc/tcl.bib +++ /dev/null @@ -1,21 +0,0 @@ -% file: .../doc/tcl.bib - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/tcl.bib,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: tcl.bib,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:54 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:53 rj -% first check-in -% - -@book{tcl-book, - title = "Tcl and the TK Toolkit", - author = "John K. Ousterhout", - publisher = "Addison-Wesley Publishing Company", - year = 1994, - note = "ISBN 0-201-63337-X", -} diff --git a/SecuritySNACCRuntime/doc/tcl.tex b/SecuritySNACCRuntime/doc/tcl.tex deleted file mode 100644 index e2f08cc6..00000000 --- a/SecuritySNACCRuntime/doc/tcl.tex +++ /dev/null @@ -1,456 +0,0 @@ -% file: .../doc/tcl.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/tcl.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: tcl.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:54 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:40 rj -% first check-in -% - -\chapter{\label{tcl-if-chapter}Tcl Interface} - -\section{\label{intro-tcl-section}Introduction} - -This chapter describes the Snacc's Tcl interface, or: the metacode's link to the outside world. - -Tcl is a simple scripting language which the author, John K. Ousterhout, describes in his book titled ``Tcl and the TK Toolkit'' \cite{tcl-book}. -Tcl's purpose is to be embedded into other applications, to provide a user interface by extending the language. -Tk, an implementation of the Motif look and feel, is the first and best known extension to Tcl and is described in the same book. - -Tcl has got only one data type, the NUL terminated character string. -Tcl supports other data types like integers and lists, but they are represented as strings. -A function operating on an integer first converts the string into an integer, performs its operation, converts the resulting value back into another string and returns it to the Tcl interpreter. -Since lists and even the Tcl procedures are kept as strings, Tcl is rather slow. -Computations in Tcl should best be kept at a minimum, and all intensive work should be wrapped into C or C++ functions and be made available as Tcl commands. - -Since procedures and bodies of loops are kept in string form and parsed for every invocation, comments should be put outside code that is executed \emph{very} often. - -From Tcl's point of view, Snacc's Tcl interface is nothing but yet another Tcl extension. -The Snacc Tcl interface extends the Tcl language by only one command, {\Tcl snacc}. -The first argument to this command specifies the action to be taken. -This method is very practical for combining Tcl extensions since it avoids collisions with new command names from other extensions. -For example, the Tcl core defines an {\Tcl open} command. -Snacc's Tcl interface wants to offer one as well and has to choose another name. -This could have been done by naming it {\Tcl snacc\_open}, but I think it is better to stick to Tcl's well established convention and so the Tcl interface's open command became {\Tcl snacc open}. -To simplify the wording, I will refer to the `snacc subcommands' simply as `commands'. - -The usual (non-metacode) snacc generated functions operate on memory buffers containing BER encoded data; they convert them into hierarchical C++ data structures and vice versa. - -The Tcl interface is designed to allow controlled fine grained access to this hierarchical C++ data structure, to read and modify its contents. -While both the C++ code and the Tcl look very similar, for example\dots\\[1ex] -{\C -// this is C++ code\\ -x-->foo-->bar = 42;\\[1ex] -} -\dots\ and\dots\\[1ex] -{\Tcl -\# this is Tcl code\\ -snacc set \{x foo bar\} 42 -} - -\dots\ the C++ code gets compiled and the identifiers get turned into pointers and numeric offsets, and the Tcl code gets interpreted and has to mimic the C++ compiler at run time. -This is what the metacode from chapter~\ref{meta-chapter} is for. - -To enable snacc's Tcl code generator, you have to give an additional {\ufn -tcl} option, followed by the list of PDU types. -The {\ufn -meta} option can (and should) be omitted. - -\section{The {\Tcl snacc} Tcl command} - -This section explains the Tcl (sub)commands provided by the Snacc extension. -The commands are grouped in three catagories, commands operating on files (both their external and internal representation), commands accessing the meta information and commands operating on the content itself. - -The file commands check the return value from system calls and behave like for example the Tcl {\Tcl open} command, that is, they set the {\Tcl errorCode} variable to {\Tcl POSIX \emph{errno}}, e.g. {\Tcl POSIX ENOENT \{No such file or directory\}}. - -The code should be fairly robust, not just against user and programmer errors from `outside' (using the {\Tcl snacc} Tcl command), but against errors from the `inside' as well such as illegal numeric values for enumeration types or illegal choice settings as well. - -There are two types of errors: -\begin{enumerate} - \item programmer errors, where the program has no other choice as to print a regret to the user and exit - \item user errors, such as trying to write to a read-only file, where the program should tell the user about their mistake and let them try something else. -\end{enumerate} -The Tcl interface code helps the programmer for the second type of error by setting Tcl's {\Tcl errorCode} variable. -The program can {\Tcl catch} any error, and, based on the {\Tcl errorCode}, choose to deal with the mistake or rethrow the error that it is not prepared to handle. - -\subsection{File commands} - -Most snacc Tcl commands operate on so-called files. -A file is an internal data structure that -\begin{itemize} - \item references the C++ representation of an ASN.1 data structure as a pointer to {\C AsnType} - \item may be associated with an external file in the file system -\end{itemize} - -The commands operating on these files are as follows: - -\begin{description}%{ - \item[{\Tcl snacc create \emph{type}}] - The command creates a file consisting only of an instance of type \emph{type}. - \emph{type} has to be denoted as one argument, a Tcl list with two elements, module and type. - No external filename is associated with this file. -% The command returns a file handle that consists of letters and digits only and may therefore be used to construct a component in the Tk widget tree. - - \item[{\Tcl snacc open \emph{type filename} ?\emph{flags}? ?\emph{mode}?}] - Open a file and read and decode its contents. - \emph{type} has to be denoted as one argument, a list with two elements, module and type. - The optional \emph{flags} may consist of: - \begin{description} - \item[{\Tcl create}] If the file does not exist, create it. - If this flag is not given and the file does not already exist, an error occurs. - \item[{\Tcl truncate}] If the file exists, drop its contents. - \item[{\Tcl \emph{access}}] which may be either {\Tcl ro} or {\Tcl rw}, denoting read only and read/write access. - If no access mode is specified, the file will be opened read/write if it is writable, and read only otherwise. - \end{description} - If the file is created, its mode is set to \emph{mode}, minus umask, of course. - \emph{mode} may be any value accepted by {\C Tcl\_GetInt(3)} (the function accepts octal values). - At last, if the file could be opened, its contents is read and BER decoded. - As for {\Tcl snacc create} above, a file handle is returned. - - If the file cannot be opened, an error is returned identical to Tcl's {\Tcl open} command. - - More errors can be returned, as described under {\Tcl snacc read} below. - - \item[{\Tcl snacc close \emph{file}}] - closes the file \emph{file} and invalidates the file handle. - - \item[{\Tcl snacc read \emph{file} ?\emph{type filename}?}] - without the \emph{filename}, rereads the file from its old place; otherwise opens \emph{filename}, reads its contents into \emph{file} and closes it. - The file's contents gets BER decoded. - - In case no \emph{filename} has been given but the \emph{file} is not associated with a filename, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC MUSTOPEN}. - - If Snacc's decoding routines detect an error, a Tcl error is returned and {\Tcl errorCode} is set to {\Tcl SNACC DECODE \emph{errval}} where \emph{errval} is the value returned by {\C setjmp()} (see sections~\ref{error-C++-section} and~\ref{lib-err-C-section} on pages~\pageref{error-C++-section} and~\pageref{lib-err-C-section}, respectively). - - If the input file is too short, the buffer will signal a read error and a Tcl error will be returned, with {\Tcl errorCode} set to {\Tcl SNACC DECODE EOBUF}. - - \item[{\Tcl snacc write \emph{file} ?\emph{filename}?}] - BER encodes the file, then writes the file to its old place in case no \emph{filename} has been given, or opens \emph{filename}, writes \emph{file} into it and closes it. - - In case no \emph{filename} has been given but the \emph{file} is not associated with a filename, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC MUSTOPEN}. - If you try to write to a read-only file, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC WRITE READONLY}. - - \item[{\Tcl snacc finfo \emph{file}}] - returns a list with two elements, the file name associated with it (the empty string if no external file name is associated with it) and an identifier which may be - \begin{description}%{ - \item[{\Tcl bad}] the file is not associated with an external file. - \item[{\Tcl rw}] the external file has been opened read/write. - \item[{\Tcl ro}] the external file has been opened read only. - \end{description}%} -\end{description}%} - -Since Tcl cannot operate on binary strings (that is, strings containing NUL bytes), but ASN.1 octet strings may contain arbitrary binary data, the binary data has to be converted into a replacement notation that Tcl can work with and that can be converted back to binary without loss of information. -The conversion I chose is fairly simple: NUL is converted into a backslash followed by a zero digit, and every backslash is doubled. - -These conversions for the most part take place automatically. -In fact, there is only one point where the binary representation is necessary, when you want to read or write data from or into a file on disk. -Two functions have been written to offer this: the export function converts and writes an octet string to an external file, and the import function reads binary data from a file and converts it to the Tcl compatible representation. -Unlike the functions described above, these two do not operate on ASN.1 files, that is, the contents is not BER decoded/encoded, but may be used for any file in the file system. - -\begin{description}%{ - \item[{\Tcl snacc import \emph{filename}}] opens the file named, reads its contents, closes it, performs the above described conversion and returns the resulting Tcl string. - \item[{\Tcl snacc export \emph{string filename}}] converts the Tcl string into its binary counterpart, opens the file named, writes the binary buffer into it and closes it. - The file is created and truncated as necessary. - The command returns the empty string. -\end{description}%} - -\subsection{Generic Information Retrieval} - -The following functions return information about the modules and their types. -(This information is independent of any file instance, it is the information from the type descriptions in the {\ufn .asn1} files.) - -\begin{description}%{ - \item[{\Tcl snacc modules}] - returns a list of module identifiers. - \item[{\Tcl snacc types ?\emph{module}?}] - if a \emph{module} is specified, returns a list of all type names of that module. - otherwise, a list of all types is returned as a list of pairs, where each pair consists of the module name and the type name. - \item[{\Tcl snacc type \emph{type}}] - where \emph{type} is a list with two elements, module and type. - This command returns a list with the following four elements: - \begin{enumerate}%{ - \setcounter{enumi}{-1} - \item the content type as a list consisting of module name and type name - \item an identifier that is either {\Tcl pdu} or {\Tcl sub} depending on the list of PDUs that had been given after snacc's {\ufn -tcl} option. - \item the ASN.1 type (e.g. INTEGER or CHOICE) - \item a list of items that depends on the ASN.1 type: - \begin{description}%{ - \item[INTEGER] a (possibly empty) list of pairs of name and value for each named value. - \item[ENUMERATED] a (non-empty) list of names. - \item[SET, SEQUENCE \textnormal{and} CHOICE] a list of lists of four elements similar to that being described here. - Element~0 is the subtypes name, then follow content type (a pair consisting of module name and type name), \emph{pdu} vs. \emph{sub} and finally the ASN.1 type. - (The fourth element of the outer list is omitted for obvious reasons: it would explode the type's description.) - \end{description}%} - \end{enumerate}%} -\end{description}%} - -\subsection{Operations on Content and Structure} - -Finally, the last last four functions operate on the file instances itself. -All four commands get a \emph{path} argument that is constructed as follows: -\begin{itemize} - \item Every \emph{path} starts with a file handle as returned by {\Tcl snacc create} or {\Tcl snacc open}. - \item All subsequent path elements, except for the last, must indicate elements of composed types. - For CHOICE, SET and SEQUENCE, these are member names, for SET OF and SEQUENCE OF, these are numeric indices. - \item The last path element may reference a simple type. - \item For SET OF and SEQUENCE OF, instead of a numeric index, a pair consisting of the word {\Tcl insert} followed by a numeric index may be specified. - In this case, a new list element is inserted before that addressed by the index. - The index must be in the range $0\ldots{}n-1$ to address existing elements and it must be in the range $0\ldots{}n$ for insertion, where in both cases $n$ is the number of elements in the list. - \item For {\Tcl snacc unset}, the path must point to an optional member of a SET or SEQUENCE or to an element of a SET OF or SEQUENCE OF. -\end{itemize} - -The commands are: -\begin{description}%{ - \item[{\Tcl snacc info \emph{path}}] returns information about the value pointed to by \emph{path}. - The information returned is quite similar to that of {\Tcl snacc type} above, with the following exceptions: - \begin{itemize}%{ - \item element~0, the content type, contains empty names for types that have not been given a name (e.g. a SET member of type OCTET STRING - Example: the {\ASN contents} member in type {\ASN File} in file {\ufn edex1.asn1} (page~\pageref{edex1.asn1}) {\Tcl snacc info} returns {\Tcl \{\{\} \{\}\} sub \{OCTET STRING\}}). - \item the number of elements depends on the ASN.1 type: - \begin{description}%{ - \item simple types (\textbf{NULL}, \textbf{BOOLEAN}, \textbf{INTEGER}, \textbf{ENUMERATED}, \textbf{REAL}, \textbf{BIT STRING} and \textbf{OCTET STRING}): - no additional elements are returned. - For the list of named values for INTEGER, ENUMERATED and BIT STRING, you have to call {\Tcl snacc type [lindex [snacc info \emph{path}]~0]}, unless the content type equals {\Tcl \{\{\}~\{\}\}}. - \item[CHOICE] - a total of five elements is returned, number~3 is the name of the choice member currently chosen, and the final element number~4 is an identifier that is either {\Tcl void} or {\Tcl valid} depending on whether the pointer representing the choice member is {\C NULL} or pointing to some data. - \item[SET \textnormal{and} SEQUENCE] - a fourth element, a list of pairs, is returned, where the pairs are built from the member name and an identifier that is either {\Tcl valid} or {\Tcl void} - \item[SET OF \textnormal{and} SEQUENCE OF] - the number of items is returned as element number~3. - \end{description}%} - \end{itemize}%} - \item[{\Tcl snacc get \emph{path}}] - returns the value of the subtree pointed to by \emph{path}. - The value returned is a simple string for simple types, and a hierarchical structure (in Tcl that is a list of lists) otherwise. - \begin{description}%{ - \item[NULL] - the empty string is returned. - \item[BOOLEAN] - the value is returned as {\Tcl TRUE} or {\Tcl FALSE}. - \item[INTEGER] - the numeric value is returned, even if it has been assigned a name. - \item[ENUMERATED] - the symbolic value is returned. - The numeric values are inaccessible through the Tcl interface. - If the object happens to contain an illegal numeric value, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC ILLENUM}. - \item[REAL] - the value is returned as formatted by {\C sprintf (\dots, "\%g", \dots)}, except for the special values {\ASN PLUS-INFINITY} and {\ASN MINUS-INFINITY} which are returned as {\Tcl +inf} and {\Tcl -inf}, respectively. - \item[BIT STRING] - a string, consisting solely of `0' and `1', is returned. - \item[OCTET STRING] - the binary string is returned as is, except for the unavoidable NUL-escape described above. - \item[OBJECT IDENTIFIER] - the value is returned as a list of numbers. - \item[CHOICE] - is returned as a pair, the choice member chosen and its value. - \item[SET \textnormal{and} SEQUENCE] - are returned as a list of pairs of member name and value. - Absent OPTIONAL members are left out from the list. - \item[SET OF \textnormal{and} SEQUENCE OF] - are returned as a list of values. - \end{description}%} - \item[{\Tcl snacc set \emph{path value}}] sets the subtree identified by \emph{path} to \emph{value}. - The value must be of the form - \begin{description}%{ - \item[NULL] - the only legal value is the empty string. - otherwise, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC ILLNULL}. - \item[BOOLEAN] - any value that is accepted by {\C Tcl\_GetBoolean}(3) is fine. - \item[INTEGER] - both the numeric (as accepted by {\C Tcl\_GetInt(3)}) and the symbolic values are allowed. - \item[ENUMERATED] - any value must be specified by its name. - If an illegal name is given, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC ILLENUM}. - \item[REAL] - the special values {\ASN PLUS-INFINITY} and {\ASN MINUS-INFINITY} have to be given as {\Tcl +inf} and {\Tcl -inf}, respectively. - All other values may be specified in any format accepted by {\C Tcl\_GetDouble}(3). - \item[BIT STRING] - a string that must consist of `0' and `1' only has to be given. - otherwise, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC ILLBIT}. - \item[OCTET STRING] - due to the NUL-escapes necessary, any string where a backslash is followed by either another backslash or a `0' digit is legal. - Improper use of the escape character leads to an error and {\Tcl errorCode} will be set to {\Tcl SNACC ILLESC}. - \item[OBJECT IDENTIFIER] - the value has to be specified as a list of numbers. - if the arc has less than 2 or more than 10 elements, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC ILLARC <2} or {\Tcl SNACC ILLARC >10}, respectively. - \item[CHOICE] - the value expected is a pair, the choice member chosen and its value. - if an illegal member is specified, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC ILLCHOICE}. - \item[SET \textnormal{and} SEQUENCE] - the value has got to be a list of pairs of member name and value. - Any member may be specified at most once. - All mandatory members must be present. - Failure to do so will result in an error and {\Tcl errorCode} to be set to {\Tcl SNACC DUPMEMB} or {\Tcl SNACC MISSMAND}, respectively. - All optional members not listed in the value will be deallocated. - \item[SET OF \textnormal{and} SEQUENCE OF] - the whole list is replaced with the specified value that has to be a proper Tcl list. - \end{description}%} - \item[{\Tcl snacc unset \emph{path}}] - unsets the subtree pointed to by \emph{path}. - Only OPTIONAL members of SET and SEQUENCE types and list elements of SEQ OF and SEQUENCE OF may be unset. - If you try to unset a mandatory SET or SEQUENCE member, an error is returned and {\Tcl errorCode} is set to {\Tcl SNACC MANDMEMB}. -\end{description}%} - -I did not follow Tk's example where one has to set widget commands to {\Tcl \{\}} to delete them. -This method would have the drawback that one could not distinguish between an empty and a non-existing octet string (in C that would be {\C ""} vs. {\C NULL}). - -The value returned by {\Tcl snacc get} may be very long, {\Tcl snacc get file0} returns the contents of the whole file! - -\section{\label{snacc-examples}Examples} - -The following example session shall illustrate the {\Tcl snacc} commands usage. -It assumes that the editor example files {\ufn edex0.asn1} and {\ufn edex1.asn1} (see appendix~\ref{edex-files} on page~\pageref{edex-files}) have been compiled into a binary that has been linked with the necessary libraries. - -The notation used is as in the Tcl book \cite{tcl-book}, i.e. `$\Rightarrow$' indicates a normal return value and `$\varnothing$' indicates an error with the error message set in {\Tcl \emph{oblique typeface}}. - -A look at the types available: - -\begin{Tclex} - & snacc types\\ -\R & \{EdEx-Simple Hand\} \{EdEx-Structured StructuredChoice\} \{EdEx-Structured Coordinate\} \{EdEx-Structured CoordinateSeq\} \{EdEx-Structured RGBColor\} \{EdEx-Structured Simple\} \{EdEx-Simple File\} \{EdEx-Simple RainbowColor\} \{EdEx-Structured DirectorySetOf\} \{EdEx-Structured Various\} \{EdEx-Structured File1\} \{EdEx-Structured CoordinateSeq1\} \{EdEx-Structured Directory\} \{EdEx-Structured Structured\} \{EdEx-Simple DayOfTheWeek\} -\end{Tclex} - -Create a file (without filename): - -\begin{Tclex} - & set file [snacc create \{EdEx-Structured Structured\}]\\ -\R & file0 -\end{Tclex} - -The string returned is the file handle. It is used as the first snaccpath component in successive calls. - -Look at the file's type: - -\begin{Tclex} - & snacc info \$file\\ -\R & \{EdEx-Structured Structured\} sub SET \{\{coord valid\} \{color valid\}\} -\end{Tclex} - -The file's type is a SET with the name `Structured' in module `EdEx-Structured' (it is defined in file {\ufn edex1.asn1} (see page~\pageref{edex1.asn1})). -The `sub' tells us that the type has not been marked as a PDU. -The SET has the components `coord' and `color', both are present (they are not OPTIONAL, i.e. mandatory). - -Look at a component's type: - -\begin{Tclex} - & snacc info "\$file color"\\ -\R & \{EdEx-Structured StructuredChoice\} sub CHOICE rainbow valid -\end{Tclex} - -Snacc has generated the type name `StructuredChoice' for this type, this name was not defined in the {\ufn .asn1} file. -The CHOICE object currently is set to `rainbow'. -A CHOICE component is always present (CHOICE components may not be OPTIONAL), the `valid' is just for completeness. - -Ask for the CHOICE's generic type information: - -\begin{Tclex} - & snacc type \{EdEx-Structured StructuredChoice\}\\ -\R & \{EdEx-Structured StructuredChoice\} sub CHOICE \{\{rainbow \{EdEx-Simple RainbowColor\} sub INTEGER\} \{rgb \{EdEx-Structured RGBColor\} sub SEQUENCE\}\} -\end{Tclex} - -The CHOICE type has two possible components, `rainbow', an INTEGER and `rgb', a SEQUENCE. - -Look at the INTEGER's type information: - -\begin{Tclex} - & snacc type \{EdEx-Simple RainbowColor\}\\ -\R & \{EdEx-Simple RainbowColor\} sub INTEGER \{\{red~0\} \{orange~1\} \{yellow~2\} \{green~3\} \{blue~4\} \{indigo~5\} \{violet~6\}\} -\end{Tclex} - -The type has got named values. - -Access the file contents: - -\begin{Tclex} - & snacc get \$file\\ -\R & \{coord \{cartesian \{\{x 0\} \{y 0\}\}\}\} \{color \{rainbow 977768\}\} -\end{Tclex} - -The color component contains garbage. -Change that: - -\begin{Tclex} - & snacc set "\$file color rainbow" green\\ -\R &\\ - & snacc get "\$file color"\\ -\R & rainbow 3 -\end{Tclex} - -Change it again, select the CHOICE's other component type, `rgb', and set its `red' component: - -\begin{Tclex} - & snacc set "\$file color rgb red" 256\\ -\R & -\end{Tclex} - -Changing a CHOICE component selection work only for write access, on read access this is not possible: - -\begin{Tclex} - & snacc get "\$file color rainbow"\\ -\E & \emph{snacc get: illegal component "rainbow" in path}\\ - & snacc get "\$file color rgb"\\ -\R & \{red 256\} \{green 544501616\} \{blue 1814045815\} -\end{Tclex} - -Upon setting a SET or SEQUENCE type, all mandatory members have to be specified: - -\begin{Tclex} - & snacc set "\$file color rgb" \{\{green 0\} \{blue 0\}\}\\ -\E & \emph{mandatory member "red" is missing in list}\\ - & snacc set "\$file color rgb" \{\{red 0\} \{green 256\} \{blue 0\}\}\\ -\R &\\ - & snacc get "\$file color"\\ -\R & rgb \{\{red 0\} \{green 256\} \{blue 0\}\} -\end{Tclex} - -Finish up: - -\begin{Tclex} - & snacc close \$file\\ -\R &\\ - & snacc get \$file\\ -\E & \emph{snacc get: no file named "file0"} -\end{Tclex} - -\section{\label{tcl-if-impl}Implementation} - -The Tcl interface is implemented in {\ufn \dots/c++-lib/inc/tcl-if.h} and {\ufn \dots/c++-lib/src/tcl-if.C}. -It gets initialized with the help of {\ufn \dots/c++-lib/inc/init.h} and {\ufn \dots/c++-lib/src/tkAppInit.c}. - -The {\Tcl snacc} commands implementation is pretty straight forward: check the arguments, call a metacode function to perform an action and return the result, which may indicate success or an error. - -Care has been taken to check the return codes of all system calls and to set Tcl's {\Tcl errorCode} variable in case any system call returns an error. - -The file {\ufn tkAppInit.c} contains the function that introduces the {\Tcl snacc} Tcl command to the Tcl interpreter. -The path that leads to the function's invocation is a little tricky and is described in section~\ref{editor-building}, ``Building Your Own Editor''. - -\section{Setup for the Tcl Code Generator} - -To compile Snacc with the Tcl interface code generator, you have got to fulfill the following conditions: -\begin{itemize} - \item the configure script must be able to find {\ufn tclsh} and the Tcl/Tk libraries - \item the preprocessor switches {\C NO\_META} and {\C NO\_TCL} in {\ufn \dots/policy.h} must not be set -\end{itemize} - -\section{\label{tcl-if-deficiencies}Deficiencies} - -\begin{itemize} - \item - Values defined in the ASN.1 files currently are inaccessible. - Adding access functions to the metacode and Tcl interface is rather trivial: build an array of elements that hold a variable's name as a character string and an {\C AsnType~*} that points to the C++ variable. - {\C a[i].val-->\_getdesc()} would return a pointer to the variable's type description. - - (First you should fix snacc's value parser as currently it lets some values silently vanish, for example the {\ASN victory} in {\ufn edex0.asn1} that you can find in appendix~\ref{edex0.asn1} on page~\pageref{edex0.asn1}.) - \item - The Tcl interface does not provide symbolic object identifiers. - Mapping numeric to symbolic oids is a task that is difficult to get right since snacc translates\\ - {\ASN anOidVal OBJECT IDENTIFIER ::= \{ 1 2 foo(3) \}}\\ - and\\ - {\ASN anOidVal OBJECT IDENTIFIER ::= \{ 1 2 3 \}\\ - foo INTEGER ::= 3}\\ - into identical C++ code, but translating the second {\ASN anOidVal} into {\ASN \{ 1 2 foo \}} may in fact violate {\ASN foo}'s semantics. -\end{itemize} diff --git a/SecuritySNACCRuntime/doc/ttab.tex b/SecuritySNACCRuntime/doc/ttab.tex deleted file mode 100644 index 0c5f0768..00000000 --- a/SecuritySNACCRuntime/doc/ttab.tex +++ /dev/null @@ -1,532 +0,0 @@ -% file: .../doc/ttab.tex - -% $Header: /cvs/root/Security/SecuritySNACCRuntime/doc/Attic/ttab.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -% $Log: ttab.tex,v $ -% Revision 1.1.1.1 2001/05/18 23:14:10 mb -% Move from private repository to open source repository -% -% Revision 1.1.1.1 1999/03/16 18:05:55 aram -% Originals from SMIME Free Library. -% -% Revision 1.1 1997/01/01 22:47:43 rj -% first check-in -% - -\chapter{\label{ttab-chapter}Type Tables} - -Type tables are a flexible and compact way of dealing with ASN.1. -The type table data structure is included in the appendix. It was -defined in ASN.1 to provide a good storage format for the tables. - -When snacc produces a type table it includes the useful types module -as well, if one was specified. If you are really trying to limit the -size of your type tables, put the only useful types that you need in -your ASN.1 module and compile it without using the useful types -module. - -A generic buffer type (à la ISODE and XDR) was defined to allow type -table driven routines to read from a wide variety of buffer formats. -Currently slightly modified versions of the {\C ExpBuf} and the -{\C SBuf} are provided. It shouldn't be too hard for you to add -support for your own buffer formats. The generic buffers, -{\C GenBuf}s are described in more detail in a following section. - -The general procedure for using type tables is to: -\begin{enumerate} - \item Use snacc to compile your ASN.1 modules into a type table. - \item Use {\ufn mkchdr} (make C header, not make cheddar) with the - type table to produce a friendly C type description of the types in - the type table. - \item Load the type table during runtime and use it to configure the table - encode, decode and other routines. -\end{enumerate} - -Step two, making the C header file is not necessary but will make -dealing with the value easier and more type safe. Internally the -table driven encoders and decoders know nothing of these header file -and treat the types in a uniform, generic manner. This requires the -encoders and decoders to make assumptions about the way C represents -strucutures and values. Look in the {\ufn \dots/c-lib/src/tbl-enc.c} and -{\ufn \dots/c-lib/src/tbl-dec.c} files to see how this generic data -structure is manipulated. - -On the down side, the compiler directives do not affect the data -structures generated by mkchdr and the generated C type definitions -will generally be different from those generated by the C backend. -This can be fixed, but time was lacking. Type tables also do not -support ANY DEFINED BY types. Someone could fix this without too much -difficulty. Only a C type table library is provided. I didn't have -time to deal with the complexities of creating C++ objects in a -generic way. - -Currently the type tables are lacking subtyping information. It is -available in snacc's main parse tree but I didn't have time to add it -to the tables. If you want to add it, take the subtype related data -structures (in ASN.1) from asn1module.asn1 (quite a few), remove all -the cruft pertaining to linking and error checking etc, and add it to -the type table type definitions. Then change the -{\ufn \dots/compiler/core/gen-tbls.c} file to take the subtype information from -the parse tree and put it into the type table. See the appendix or -{\ufn \dots/asn1specs/} for the ASN.1 definitions of the parse tree -and type tables. - -The parse tree itself was defined in ASN.1 so it could be the table -format. The extra complexity required for linking and error checking -made this very difficult. Cycles in the data structure and the many -links between the data elements made encoding in BER difficult. -[Maybe ASN.1 needs a type refernce type (i.e. pointer)]. - - -\section{How Type Table See Values} - -As mentioned in the last section, table driven encoding, decoding, -printing etc. routines see your values in a generic way. They do not -have abstract syntax specific header files like those created by -{\ufn mkchdr}. - -The basic idea is that all of the standard primitive and list -(SEQUENCE OF and SET OF) types are used and some regular rules are -used for allocating and laying out structs for SEQUENCE, SET and -CHOICE types. - -\begin{small} -\begin{verbatim} -/* values from table driver routines' point of view */ -typedef void AVal; - -/* SEQUENCE and SET type use AStructVal */ -typedef AVal *AStructVal; /* an array of AVal ptrs */ -\end{verbatim} -\end{small} - -For SETs and SEQUENCEs, the {\C AStructVal} type is used. Its is -basically an array of pointers, one for each component of the -SET/SEQUENCE\@. Every component is referenced by pointer to simplify -allocations. OPTIONAL or DEFAULT components may be NULL\@. For -example, the type: - -\begin{small} -\begin{verbatim} -Foo ::= SEQUENCE { a INTEGER, b BOOLEAN, c OCTET STRING } -\end{verbatim} -\end{small} - -would be represented as an array of three pointers. The first pointer -would point to an {\C AsnInt} value, the second would point to an -{\C AsnBool} value, and the third would point to an {\C AsnOcts} -value. {\ufn mkchdr} would give you the following C typedef for Foo: - -\begin{small} -\begin{verbatim} -typedef struct Foo -{ - AsnInt *a; - AsnBool *b; - AsnOcts *c; -} Foo; -\end{verbatim} -\end{small} - -\begin{small} -\begin{verbatim} -/* Internal representation for a CHOICE type */ -typedef struct AChoiceVal -{ - enum { achoiceval_notused } choiceId; - AVal *val; -} AChoiceVal; -\end{verbatim} -\end{small} - - -A CHOICE type is represented in a way similar to the C backend's -output. That is, an enum to hold the id of the CHOICE component -that is present and a pointer to the component itself. For example, -the type: - -\begin{small} -\begin{verbatim} -Bar ::= CHOICE { a INTEGER, b BOOLEAN, c OCTET STRING } -\end{verbatim} -\end{small} - -would internally be represented as AChoiceVal type. However, -{\ufn mkchdr} would give you the following: - -\begin{small} -\begin{verbatim} -typedef struct Bar -{ - enum - { - a_ID = 0, - b_ID = 1, - c_ID = 2 - } choiceId; - union - { - AsnInt *a; - AsnBool *b; - AsnOcts *c; - } a; -} Bar; -\end{verbatim} -\end{small} - - -\section{Type Table Utilities} - -There are a bunch of useful routines in {\ufn \dots/c-lib/src/tbl*.c}. Look -at the source code in {\ufn \dots/tbl-tools/*/} and -{\ufn \dots/tbl-example/} to see how to use some of them. - -The {\C LoadTblFile} will decode a type table from a given file. -Notice that its definition of the {\C TBL} data structure has been -augmented to simplify encoding and decoding operations. (Look at the -patch in {\ufn \dots/c-lib/tbl.h.patch} that is applied through the makefile automatically.) -% The additional fields do not screw up the compiled encoder/decoder (in {\ufn \dots/c-lib/src/tbl.c}) provided they are recompiled. -The compiler uses unmodified {\ufn tbl.h} and {\ufn tbl.c} files. - -I don't have time to document these routines. Look through the table -tools, examples and library code. Their usage should be fairly -obvious. - - -\section{Type Table Tools} - -The {\ufn \dots/tbl-tools/} directory contains three tools, {\ufn mkchdr}, -{\ufn pval} and {\ufn ptbl}. These are described in the following -sections. - -\subsection{Making C Header Files with mkchdr} - -{\ufn mkchdr} produces a C header file from a type table. This header -file shows the representation of the types that the table tools will -expect or return for the types in the given type table. - -The main use is to provide you with an easy to use definition of the -ASN.1 types C representation. You do not need to use {\ufn mkchdr} -but it is definately recommended. Note that the table routines could -have used an even more generic data structure to represent values -(e.g. ISODE's Presentation Elements). If you have worked with these, -you know that they are cumbersome. - -Its synopsis is: -\begin{small} -\begin{verbatim} -mkchdr [output-file] -\end{verbatim} -\end{small} - -If the output file is omitted, the header file is printed to {\C stdout}. - -Here is an example of the output. Given the table that has the -following ASN.1 module in it: - -\begin{small} -\begin{verbatim} -P-REC DEFINITIONS ::= -BEGIN -PersonnelRecord ::= [APPLICATION 0] IMPLICIT SET -{ - Name, - title [0] IA5String, - EmployeeNumber, - dateOfHire [1] Date, - nameOfSpouse [2] Name, - children [3] IMPLICIT SEQUENCE OF ChildInformation DEFAULT {} -} - -ChildInformation ::= SET -{ - Name, - dateOfBirth [0] Date -} - -Name ::= [APPLICATION 1] IMPLICIT SEQUENCE -{ - givenName IA5String, - initial IA5String, - familyName IA5String -} - -EmployeeNumber ::= [APPLICATION 2] IMPLICIT INTEGER - -Date ::= [APPLICATION 3] IMPLICIT IA5String -- YYYYMMDD - -END -\end{verbatim} -\end{small} - -{\ufn mkchdr} will produce: -\begin{small} -\begin{verbatim} -typedef AsnInt EmployeeNumber; - -typedef struct Name -{ - IA5String *givenName; - IA5String *initial; - IA5String *familyName; -} Name; - -typedef IA5String Date; - -typedef struct ChildInformation -{ - Name *field0; - Date *dateOfBirth; -} ChildInformation; - -typedef AsnList PersonnelRecordSeqOf; - -typedef struct PersonnelRecord -{ - Name *field0; - IA5String *title; - EmployeeNumber *field1; - Date *dateOfHire; - Name *nameOfSpouse; - PersonnelRecordSeqOf *children; -} PersonnelRecord; - -\end{verbatim} -\end{small} - - -\subsection{Printing Tables with ptbl} - -{\ufn ptbl} is a program that will show you the contents of a type -table. It can print a table in two modes: -\begin{itemize} - \item The value notation for the TBL ASN.1 data structure (see the appendix). - \item The ASN.1 text version -\end{itemize} - -Its synopsis is: - -\begin{small} -\begin{verbatim} -ptbl [-a] -\end{verbatim} -\end{small} - -For example, using {\ufn ptbl -a p-rec.tt} to print the -PersonnelRecord module used in the last section would yield: - -\begin{small} -\begin{verbatim} -P-REC DEFINITIONS ::= -BEGIN -EmployeeNumber ::= [APPLICATION 2] IMPLICIT INTEGER -Name ::= [APPLICATION 1] IMPLICIT SEQUENCE -{ - givenName IA5String, - initial IA5String, - familyName IA5String -} -Date ::= [APPLICATION 3] IMPLICIT IA5String -ChildInformation ::= SET -{ - Name, - dateOfBirth [0] Date -} -PersonnelRecordSeqOf ::= SEQUENCE OF ChildInformation -PersonnelRecord ::= [APPLICATION 0] IMPLICIT SET -{ - Name, - title [0] IA5String, - EmployeeNumber, - dateOfHire [1] Date, - nameOfSpouse [2] Name, - children [3] IMPLICIT PersonnelRecordSeqOf -} -END --- Definitions for ASN-USEFUL -ASN-USEFUL DEFINITIONS ::= -BEGIN -ObjectDescriptor ::= [UNIVERSAL 7] IMPLICIT OCTET STRING -NumericString ::= [UNIVERSAL 18] IMPLICIT OCTET STRING -PrintableString ::= [UNIVERSAL 19] IMPLICIT OCTET STRING -TeletexString ::= [UNIVERSAL 20] IMPLICIT OCTET STRING -T61String ::= [UNIVERSAL 20] IMPLICIT OCTET STRING -VideotexString ::= [UNIVERSAL 21] IMPLICIT OCTET STRING -IA5String ::= [UNIVERSAL 22] IMPLICIT OCTET STRING -GraphicString ::= [UNIVERSAL 25] IMPLICIT OCTET STRING -VisibleString ::= [UNIVERSAL 26] IMPLICIT OCTET STRING -ISO646String ::= [UNIVERSAL 26] IMPLICIT OCTET STRING -GeneralString ::= [UNIVERSAL 27] IMPLICIT OCTET STRING -UTCTime ::= [UNIVERSAL 23] IMPLICIT OCTET STRING -GeneralizedTime ::= [UNIVERSAL 24] IMPLICIT OCTET STRING -EXTERNAL ::= [UNIVERSAL 8] IMPLICIT SEQUENCE -{ - direct-reference OBJECT IDENTIFIER, - indirect-reference INTEGER, - data-value-descriptor ObjectDescriptor, - encoding CHOICE - { - single-ASN1-type [0] OCTET STRING, - octet-aligned [1] IMPLICIT OCTET STRING, - arbitrary [2] IMPLICIT BIT STRING - } -} -END -\end{verbatim} -\end{small} - -Note that the useful type module is included in the table. As -mentioned before, to minimize the size of your tables, put the -definitions of the useful types (from {\ufn \dots/asn1specs/asn-useful.asn1}) -into your ASN.1 module and do not compile with useful types module -(i.e. don't use the -u option). If your module doesn't use any -useful types, just don't use the -u option. - -The other mode of {\ufn ptbl}, value notation for the TBL data -structure, produces a lot of output. It may be useful if you are -debugging one of the table drivers. - - -\subsection{Printing Values with pval} - -The {\ufn pval} program will convert BER values into their value -notation. Its arguments are a type table file, a module and type name -and a list of BER files of that type. - -Its synopsis is: - -\begin{small} -\begin{verbatim} -pval -T [-m ] -n -\end{verbatim} -\end{small} - -Running {\ufn pval} on a PersonnelRecord value produced the following: - -\begin{small} -\begin{verbatim} --- Contents of file "demo-tbls/p-rec.ber"-- --- module = ???, type = PersonnelRecord -- - -value P-REC.PersonnelRecord ::= -{ - { - givenName '4a6f686e'H -- "John" --, - initial '45'H -- "E" --, - familyName '536d697468'H -- "Smith" -- - }, - title '5468652042696720436865657365'H -- "The Big Cheese" --, - 99999, - dateOfHire '3139383230313034'H -- "19820104" --, - nameOfSpouse { - givenName '4d617279'H -- "Mary" --, - initial '4c'H -- "L" --, - familyName '536d697468'H -- "Smith" -- - }, - children { - { - { - givenName '4a616d6573'H -- "James" --, - initial '52'H -- "R" --, - familyName '536d697468'H -- "Smith" -- - }, - dateOfBirth '3139353730333130'H -- "19570310" -- - }, - { - { - givenName '4c697361'H -- "Lisa" --, - initial '4d'H -- "M" --, - familyName '536d697468'H -- "Smith" -- - }, - dateOfBirth '3139363130363231'H -- "19610621" -- - } - } -} - - -- decoded 143 bytes for the above value -- -\end{verbatim} -\end{small} - - -\section{Using Tables in Your Own Applications} - -The best way to get a handle on using tables is to look at the example -in {\ufn \dots/tbl-example/}. The general idea is to compile your -ASN.1 into a type table (use the snacc {\ufn -T} option). If you desire a -livable definition of the C data structures for the types in the type -table, run {\ufn mkchdr} and compile the generated header file with -your C code. During runtime, simply load your table file with -{\C LoadTblFile} (I use the {\ufn .tt} suffix naming convention for type table -files but it doesn't matter) and then use the {\C TblEncode}, -{\C TblDecode}, {\C TblPrint} and {\C TblFree} routines with -your table. Quite simple. Seriously. - -\section{Using GenBufs} - -The {\C GenBuf} generic buffers are really a way of encapsulating -other buffer formats. A {\C GenBuf} contains a table of pointers to -the buffer functions (the standardized ones (see the buffer section) -plus ``Peek'' routines that the table drivers needed). They are -defined in {\ufn \dots/c-lib/inc/gen-buf.h}. - -{\C GenBuf}s require functions for the standard buffer routines, -macros will not do since you cannot have a pointer to macro. - -The benefit of the {\C GenBuf}s is that since they can support other -buffer types, only one set of library routines is needed. (Note that -there are 3 libraries in {\ufn \dots/c-lib/} for the backend model and only one for the type table model. - -Here is most of {\ufn gen-buf.h} to give you an idea of how things work: - -\begin{small} -\begin{verbatim} -typedef unsigned char (*BufGetByteFcn) PROTO ((void *b)); -typedef unsigned char *(*BufGetSegFcn) PROTO ((void *b, - unsigned long int *lenPtr)); -typedef long int (*BufCopyFcn) PROTO ((char *dst, void *b, - unsigned long int len)); -typedef void (*BufSkipFcn) PROTO ((void *b, unsigned long int len)); -typedef unsigned char (*BufPeekByteFcn) PROTO ((void *b)); -typedef unsigned char *(*BufPeekSegFcn) PROTO ((void *b, - unsigned long int lenPtr)); -typedef long int (*BufPeekCopyFcn) PROTO ((char *dst, void *b, - unsigned long int len)); -typedef void (*BufPutByteRvsFcn) PROTO ((void *b, unsigned char byte)); -typedef void (*BufPutSegRvsFcn) PROTO ((void *b, char *data, - unsigned long int len)); -typedef int (*BufReadErrorFcn) PROTO ((void *b)); -typedef int (*BufWriteErrorFcn) PROTO ((void *b)); - -typedef struct GenBuf -{ - BufGetByteFcn getByte; - BufGetSegFcn getSeg; - BufCopyFcn copy; - BufSkipFcn skip; - BufPeekByteFcn peekByte; - BufPeekSegFcn peekSeg; - BufPeekCopyFcn peekCopy; - BufPutByteRvsFcn putByteRvs; - BufPutSegRvsFcn putSegRvs; - BufReadErrorFcn readError; - BufWriteErrorFcn writeError; - void *bufInfo; - void *spare; /* hack to save space for ExpBuf ** type */ -} GenBuf; - -#define GenBufGetByte( b) ((b)->getByte (b->bufInfo)) -#define GenBufGetSeg( b, lenPtr) ((b)->getSeg (b->bufInfo, lenPtr)) -#define GenBufCopy( dst, b, len) ((b)->copy (dst, b->bufInfo, len)) -#define GenBufSkip( b, len) ((b)->skip (b->bufInfo,len)) -#define GenBufPeekByte( b) ((b)->peekByte (b->bufInfo)) -#define GenBufPeekSeg( b, lenPtr) ((b)->peekSeg (b->bufInfo, lenPtr)) -#define GenBufPeekCopy( dst, b, len) ((b)->peekCopy (dst, b->bufInfo, len)) -#define GenBufPutByteRvs( b, byte) ((b)->putByteRvs (b->bufInfo, byte)) -#define GenBufPutSegRvs( b, data, len) ((b)->putSegRvs (b->bufInfo, data, len)) -#define GenBufReadError( b) ((b)->readError (b->bufInfo)) -#define GenBufWriteError( b) ((b)->writeError (b->bufInfo)) -\end{verbatim} -\end{small} - -\section{Type Tables Vs. Metacode} - -Please refer to section~\ref{meta-ttab-comparison} on page~\pageref{meta-ttab-comparison}. diff --git a/SecuritySNACCRuntime/doc/tumble.sed b/SecuritySNACCRuntime/doc/tumble.sed deleted file mode 100644 index 9cfaba85..00000000 --- a/SecuritySNACCRuntime/doc/tumble.sed +++ /dev/null @@ -1,4 +0,0 @@ -/^%%EndSetup$/i\ -statusdict begin\ -\ true settumble\ -end diff --git a/SecuritySNACCRuntime/doc/version.tex b/SecuritySNACCRuntime/doc/version.tex deleted file mode 100644 index 654e81de..00000000 --- a/SecuritySNACCRuntime/doc/version.tex +++ /dev/null @@ -1 +0,0 @@ -\def\snaccversion{1.3b3} diff --git a/SecuritySNACCRuntime/install-sh b/SecuritySNACCRuntime/install-sh deleted file mode 100644 index ab74c882..00000000 --- a/SecuritySNACCRuntime/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -tranformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/SecuritySNACCRuntime/makefile b/SecuritySNACCRuntime/makefile deleted file mode 100644 index 6982b1d2..00000000 --- a/SecuritySNACCRuntime/makefile +++ /dev/null @@ -1,225 +0,0 @@ -# makefile (top level) -# -# Builds and installs the snacc ASN.1 compiler and libraries. -# -# MS 92 -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:04 mb -# Move from private repository to open source repository -# -# Revision 1.3 2000/12/22 00:00:40 dmitch -# Add include makehead.static due to apparently broken autoconf, which now generates empty makehead file. -# -# Revision 1.2 2000/06/15 18:49:46 dmitch -# Trimmed EXAMPLESDIR to comply with reality. -# -# Revision 1.1.1.1 1999/03/16 18:05:49 aram -# Originals from SMIME Free Library. -# -# Revision 1.15 1997/08/27 15:53:11 wan -# Added generic table decoding, debug routines, berdecode, and asnwish. -# -# Revision 1.14 1997/03/03 11:58:26 wan -# Final pre-delivery stuff (I hope). -# -# Revision 1.13 1997/02/16 19:55:22 rj -# remove tcl-p when making clobber -# -# Revision 1.12 1997/02/16 18:30:33 rj -# correct path to configure script -# -# Revision 1.11 1997/02/16 16:52:05 rj -# generate tcl-p before it is needed... -# -# Revision 1.10 1997/02/15 20:33:33 rj -# trick to make making clean/clobber working with gmake: set MAKE_CLEAN_HACK (in makefile), and don't include the dependencies files (in maketail) if it is set. -# -# Revision 1.9 1995/07/26 21:16:56 rj -# distribute tcl-p.c -# -# Revision 1.8 1995/07/24 14:54:22 rj -# type table tools integrated. -# -# tiny .../tcl-p utility program that returns 0 if snacc's tcl interface is to be made. -# -# dummy action added to config.h.in and config.h rules to trick many makes' overoptimization. -# -# Revision 1.7 1995/02/22 09:49:07 rj -# turned the phony target `pack-tar' into a true target: $(VDIR).tar.gz. -# -# Revision 1.6 1995/02/20 11:21:27 rj -# use install-sh instead of install.sh. -# phony target distclean: don't remove the distributed file configure and stamp-h.in (they cannot be remade everywhere). -# -# Revision 1.5 1995/02/17 14:26:39 rj -# adjustments for autoconf 2.x -# -# Revision 1.4 1994/10/08 04:42:56 rj -# config.h.bot removed. -# snacc.h and policy.h added. -# -# Revision 1.3 1994/09/01 01:34:34 rj -# gen-distfiles phony target to generate up-to-date versions of the distfiles. -# -# Revision 1.2 1994/08/31 23:19:22 rj -# a lot of enhancements: -# - examples integrated, with some phony targets. -# - autoconf stuff gets automatically remade. -# - dependency boot strapping (some makes need it). -# - distributions via file list, therefore no need to clean the tree and to remove private files. -# -# Revision 1.1 1994/08/28 09:20:17 rj -# first check-in. for a list of changes to 1.1 please refer to the ChangeLog. - -TOP = . - -include makehead -include makehead.static - -SUBDIRS = compiler c-lib c++-lib tbl-tools asn1specs doc -XDIRS = tcl-lib tcl-asn - -# Apple change: the tbl-example doesn't run properly; tcl-example doesn't build Skip them. -EXAMPLESDIRS = c-examples c++-examples -#EXAMPLESDIRS = c-examples c++-examples tbl-example tcl-example - -DISTFILES = \ - COPYING \ - README NEWS INSTALL \ - ChangeLog version.h \ - configure.in configure \ - acconfig.h config.h.in stamp-h.in \ - policy.h snacc.h \ - tcl-p.c \ - makefile makehead.in maketail \ - mkinstalldirs install-sh - -#------------------------------------------------------------------------------- - -.PHONY: default all subdirs $(SUBDIRS) examples $(EXAMPLESDIRS) $(XDIRS) depend c c++ check c-check c++-check install c-install c++-install clean clobber tar - -default:: compiler c-lib c++-lib tbl-tools tcl-asn - -tcl-p: $(TCL-P) -$(TCL-P): tcl-p.c snacc.h config.h policy.h - $(REASON) - $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< - -depend $(SUBDIRS) $(EXAMPLESDIRS) $(XDIRS):: config.h version.h - -# the following hack is needed for older make versions -# (gmake doesn't need it): -depend:: - @for dir in $(SUBDIRS) tbl-example; do\ - test -f $$dir/dependencies || touch $$dir/dependencies;\ - done - @for dir in c-examples c++-examples; do\ - (cd $$dir && $(MAKE) init-depend);\ - done - -depend install gen-distfiles:: - $(MAKE) subdirs examples xdirs subtarget=$@ - -clean clobber:: - $(MAKE) subdirs examples xdirs subtarget=$@ MAKE_CLEAN_HACK=xyzzy - -subdirs:: $(SUBDIRS) -examples:: $(EXAMPLESDIRS) -xdirs:: $(XDIRS) -$(SUBDIRS) \ -$(EXAMPLESDIRS):: - cd $@ && $(MAKE) $(subtarget) -tcl-lib:: - $(MAKE) $(TCL-P) - if $(TCL-P); then cd $@ && $(MAKE) $(subtarget); fi - -tcl-asn:: - $(MAKE) $(TCL-P) - if $(TCL-P); then cd $@ && $(MAKE) $(subtarget); fi - -# compiler, C runtime libraries and type table tools: -c:: compiler c-lib tbl-tools tcl-asn -c-check:: c c-lib-check tbl-check -c-lib-check:: - $(MAKE) c-examples subtarget=check -tbl-check:: - $(MAKE) tbl-example subtarget=check -c-install:: - $(MAKE) c asn1specs subtarget=install - -# build compiler and C++ runtime library: -c++:: compiler c++-lib tcl-lib -c++-check:: c++ -c++-check:: - $(MAKE) c++-examples subtarget=check -c++-install:: - $(MAKE) c++ asn1specs subtarget=install - -# create compiler, build C and C++ runtime lib archive, type table tools, run a few checks: -all:: compiler c-lib c++-lib tbl-tools tcl-asn check - -check:: c-check c++-check - -$(srcdir)/configure: configure.in - $(REASON) - cd $(srcdir) && autoconf - -# autoheader might not change config.h.in, so touch a stamp file -$(srcdir)/config.h.in: stamp-h.in - @true -$(srcdir)/stamp-h.in: configure.in acconfig.h - $(REASON) - cd ${srcdir} && autoheader - date > $@ - -# config.status might not change config.h -config.h: stamp-h - @true -stamp-h: config.h.in config.status - $(REASON) - CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status - -makehead: makehead.in config.status - $(REASON) - CONFIG_FILES=makehead CONFIG_HEADERS= ./config.status - -config.status: $(srcdir)/configure - $(REASON) - ./config.status --recheck - -clobber distclean:: - $(RM) config.log config.cache config.status config.h stamp-h - $(RM) $(TCL-P) - -gen-distfiles:: $(DISTFILES) - -distfiles:: - echo "$(DISTFILES)";\ - for dir in $(SUBDIRS) $(EXAMPLESDIRS) $(XDIRS); do\ - subfiles=`cd $$dir && $(MAKE) -s $@`;\ - for file in $$subfiles; do\ - echo "$$dir/$$file";\ - done;\ - done - -tar:: gen-distfiles - -tar:: - vdir=snacc-`sed -e '/VERSION/!d' -e 's/.*"\(.*\)".*/\1/' -e q version.h`;\ - distfiles=`$(MAKE) -s distfiles ECHO=:`;\ - for file in $$distfiles; do\ - files="$$files $$vdir/$$file";\ - done;\ - [ -d $$vdir ] || ln -s . $$vdir;\ - $(RM) $$vdir.tar.gz;\ - gtar zcvvhf $$vdir.tar.gz $$files;\ - $(RM) $$vdir;\ - ls -l $$vdir.tar.gz - -# this one is for internal use only: -$(VDIR).tar.gz: $(FILES) - $(REASON) - $(RM) $@ - gtar zcvvhf $@ $(FILES) diff --git a/SecuritySNACCRuntime/makehead b/SecuritySNACCRuntime/makehead deleted file mode 100644 index fd0a9c6b..00000000 --- a/SecuritySNACCRuntime/makehead +++ /dev/null @@ -1,75 +0,0 @@ -# file: makehead.in -# (unless it is the file Generated automatically from makehead.in by configure.) -# -# INSERT_VDA_COMMENTS -# - -srcdir = . -top_srcdir = . -prefix = /usr/local -exec_prefix = ${prefix} - -bindir = $(exec_prefix)/bin -libexecdir = $(exec_prefix)/lib -libdir = $(prefix)/lib -incdir = $(prefix)/include -tcldir = $(libdir)/snacc/tcl -# beware setting both extensions to the same value, otherwise snacc.1 and snacc.n will collide! -man1ext = 1 -mannext = n -man1dir = $(prefix)/man/man$(man1ext) -manndir = $(prefix)/man/man$(mannext) - -SHELL = /bin/sh -ECHO = echo - - -TCLSH = tclsh -SNACC_NOVOLAT = - -MKDEP = mkdep -MKDEP_CCINC = -I/usr/local/include -I/usr/libexec/gcc/darwin/ppc/2.95.2/include -F/System/Library/PrivateFrameworks - -DEPENDENCIES = dependencies - -LEX = flex -LFLAGS = -LEXLIB = -ll -YACC = bison -y - -CC = cc -CFLAGS = -DMACOS -DYYTEXT_POINTER -DFLEX_IN_USE -DVDADER_RULES -CXX = c++ -CXXFLAGS = -g -O2 -DVDADER_RULES - -LDFLAGS = -LIBS = -CPPFLAGS.TCL = -TCLLIBS = -TREELIBS = - -CPPFLAGS.X11 = -LDFLAGS.X11 = -LDLIBS.X11pre = -LDLIBS.X11extra = - -PATCH = patch -AR = ar -RANLIB = ranlib - -INSTALL = /usr/bin/install -c -INSTALL_PROGRAM = ${INSTALL} -INSTALL_DATA = ${INSTALL} -m 644 - -LATEX = false -BIBTEX = false -DVIPS = false -DETEX = false -PSPREVIEW = true -PSBOOK = false -PSNUP = false -SPELL = spell - -TCL-P = $(TOP)/tcl-p - -REASON = @if [ -f $@ ]; then $(ECHO) "====== making $@ because of $? ======"; else $(ECHO) "====== making (creating) $@ ======"; fi diff --git a/SecuritySNACCRuntime/makehead.in b/SecuritySNACCRuntime/makehead.in deleted file mode 100644 index dc21ec19..00000000 --- a/SecuritySNACCRuntime/makehead.in +++ /dev/null @@ -1,113 +0,0 @@ -# file: makehead.in -# (unless it is the file @configure_input@) -# -# INSERT_VDA_COMMENTS -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/makehead.in,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ -# $Log: makehead.in,v $ -# Revision 1.1.1.1 2001/05/18 23:14:04 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:49 aram -# Originals from SMIME Free Library. -# -# Revision 1.7 1997/02/16 16:44:50 rj -# made return *this after calling abort()'' a compile time option. -# -# Revision 1.6 1995/09/07 18:38:39 rj -# PSBOOK and PSNUP added. (they get used in .../doc/makefile) -# -# manext and mandir split into two pairs, for sections 1 and n. -# -# Revision 1.5 1995/07/24 14:59:35 rj -# new macros added: -# libexecdir for architecture-specific stuff -# tcldir under libdir (architecture independent) -# TCLSH -# DEPENDENCIES for c*-lib's multiple dependencies via recursive make calls -# TREELIBS for tree-3.6 widget libs -# PATCH for c-lib to patch tbl.h -# TCL-P utility prog that returns whether the tcl interface should be made as exit code -# -# Revision 1.4 1995/02/18 11:53:46 rj -# added a small hack to find gcc's hidden include directory to pass it to makedepend. this shall enable X11's makedepend to find .h files a little more the way gcc does. -# -# Revision 1.3 1995/02/13 14:53:58 rj -# CFLAGS, CXXFLAGS and LDFLAGS moved from the various makefiles to here. -# -# Revision 1.2 1994/10/08 04:30:32 rj -# Tcl and X11 libs added -# -# Revision 1.1 1994/09/01 00:51:23 rj -# first check-in (new file). -# - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = $(exec_prefix)/bin -libexecdir = $(exec_prefix)/lib -libdir = $(prefix)/lib -incdir = $(prefix)/include -tcldir = $(libdir)/snacc/tcl -# beware setting both extensions to the same value, otherwise snacc.1 and snacc.n will collide! -man1ext = 1 -mannext = n -man1dir = $(prefix)/man/man$(man1ext) -manndir = $(prefix)/man/man$(mannext) - -SHELL = /bin/sh -ECHO = echo -@SET_MAKE@ - -TCLSH = @TCLSH@ -SNACC_NOVOLAT = @SNACC_NOVOLAT@ - -MKDEP = @MKDEP@ -MKDEP_CCINC = @MKDEP_CCINC@ - -DEPENDENCIES = dependencies - -LEX = @LEX@ -LFLAGS = @LFLAGS@ -LEXLIB = @LEXLIB@ -YACC = @YACC@ - -CC = @CC@ -CFLAGS = @CFLAGS@ -DVDADER_RULES -CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ -DVDADER_RULES - -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -CPPFLAGS.TCL = -TCLLIBS = @TCLLIBS@ -TREELIBS = @TREELIBS@ - -CPPFLAGS.X11 = @X_CFLAGS@ -LDFLAGS.X11 = @X_LIBS@ -LDLIBS.X11pre = @X_PRE_LIBS@ -LDLIBS.X11extra = @X_EXTRA_LIBS@ - -PATCH = @PATCH@ -AR = @AR@ -RANLIB = @RANLIB@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ - -LATEX = @LATEX@ -BIBTEX = @BIBTEX@ -DVIPS = @DVIPS@ -DETEX = @DETEX@ -PSPREVIEW = @PSPREVIEW@ -PSBOOK = @PSBOOK@ -PSNUP = @PSNUP@ -SPELL = @SPELL@ - -TCL-P = $(TOP)/tcl-p - -REASON = @if [ -f $@ ]; then $(ECHO) "====== making $@ because of $? ======"; else $(ECHO) "====== making (creating) $@ ======"; fi diff --git a/SecuritySNACCRuntime/makehead.static b/SecuritySNACCRuntime/makehead.static deleted file mode 100644 index c40c78af..00000000 --- a/SecuritySNACCRuntime/makehead.static +++ /dev/null @@ -1,134 +0,0 @@ -# -# Hack to work around (apparently) broken autoconf - it always generates this error -# when tying to create makehead -# -# ...snip... -# creating makehead -# sed: 28: conftest.s1: unescaped newline inside substitute pattern -# creating config.h -#...snip... -# -# So, this is a copy of a previously known good makehead, and all the makefiles -# which need it include this one. -# -# -# -# file: makehead.in -# (unless it is the file Generated automatically from makehead.in by configure.) -# -# INSERT_VDA_COMMENTS -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/makehead.static,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ -# $Log: makehead.static,v $ -# Revision 1.1.1.1 2001/05/18 23:14:04 mb -# Move from private repository to open source repository -# -# Revision 1.1 2000/12/22 00:01:14 dmitch -# New file, included by most makefiles here and below, due to apparently broken autoconf, which now generates empty makehead file. This one is a copy of the last makehead which worked. -# -# Revision 1.4 2000/06/15 18:50:16 dmitch -# Doc change only. -# -# Revision 1.1.1.1 1999/03/16 18:05:49 aram -# Originals from SMIME Free Library. -# -# Revision 1.7 1997/02/16 16:44:50 rj -# made return *this after calling abort()'' a compile time option. -# -# Revision 1.6 1995/09/07 18:38:39 rj -# PSBOOK and PSNUP added. (they get used in .../doc/makefile) -# -# manext and mandir split into two pairs, for sections 1 and n. -# -# Revision 1.5 1995/07/24 14:59:35 rj -# new macros added: -# libexecdir for architecture-specific stuff -# tcldir under libdir (architecture independent) -# TCLSH -# DEPENDENCIES for c*-lib's multiple dependencies via recursive make calls -# TREELIBS for tree-3.6 widget libs -# PATCH for c-lib to patch tbl.h -# TCL-P utility prog that returns whether the tcl interface should be made as exit code -# -# Revision 1.4 1995/02/18 11:53:46 rj -# added a small hack to find gcc's hidden include directory to pass it to makedepend. this shall enable X11's makedepend to find .h files a little more the way gcc does. -# -# Revision 1.3 1995/02/13 14:53:58 rj -# CFLAGS, CXXFLAGS and LDFLAGS moved from the various makefiles to here. -# -# Revision 1.2 1994/10/08 04:30:32 rj -# Tcl and X11 libs added -# -# Revision 1.1 1994/09/01 00:51:23 rj -# first check-in (new file). -# - -srcdir = . -top_srcdir = . -prefix = /usr/local -exec_prefix = ${prefix} - -bindir = $(exec_prefix)/bin -libexecdir = $(exec_prefix)/lib -libdir = $(prefix)/lib -incdir = $(prefix)/include -tcldir = $(libdir)/snacc/tcl -# beware setting both extensions to the same value, otherwise snacc.1 and snacc.n will collide! -man1ext = 1 -mannext = n -man1dir = $(prefix)/man/man$(man1ext) -manndir = $(prefix)/man/man$(mannext) - -SHELL = /bin/sh -ECHO = echo - - -TCLSH = false -SNACC_NOVOLAT = - -MKDEP = mkdep -MKDEP_CCINC = -I/usr/local/include -I/usr/libexec/ppc/2.95.2/include -F/System/Library/PrivateFrameworks - -DEPENDENCIES = dependencies - -LEX = flex -LFLAGS = -LEXLIB = -ll -YACC = bison -y - -CC = cc -CFLAGS = -DMACOS -DYYTEXT_POINTER -DFLEX_IN_USE -DVDADER_RULES -CXX = c++ -CXXFLAGS = -g -O2 -DVDADER_RULES - -LDFLAGS = -LIBS = -CPPFLAGS.TCL = -TCLLIBS = -TREELIBS = - -CPPFLAGS.X11 = -LDFLAGS.X11 = -LDLIBS.X11pre = -LDLIBS.X11extra = - -PATCH = patch -AR = ar -RANLIB = ranlib - -INSTALL = /usr/bin/install -c -INSTALL_PROGRAM = ${INSTALL} -INSTALL_DATA = ${INSTALL} -m 644 - -LATEX = false -BIBTEX = false -DVIPS = false -DETEX = false -PSPREVIEW = true -PSBOOK = false -PSNUP = false -SPELL = spell - -TCL-P = $(TOP)/tcl-p - -REASON = @if [ -f $@ ]; then $(ECHO) "====== making $@ because of $? ======"; else $(ECHO) "====== making (creating) $@ ======"; fi diff --git a/SecuritySNACCRuntime/maketail b/SecuritySNACCRuntime/maketail deleted file mode 100644 index e7a6609d..00000000 --- a/SecuritySNACCRuntime/maketail +++ /dev/null @@ -1,78 +0,0 @@ -# file: maketail -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/maketail,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ -# $Log: maketail,v $ -# Revision 1.1.1.1 2001/05/18 23:14:04 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:05:50 aram -# Originals from SMIME Free Library. -# -# Revision 1.7 1997/02/16 16:46:26 rj -# rule to generate $(TCL-P) added -# -# Revision 1.6 1997/02/15 20:33:59 rj -# trick to make making clean/clobber working with gmake: set MAKE_CLEAN_HACK (in makefile), and don't include the dependencies files (in maketail) if it is set. -# -# Revision 1.5 1995/07/24 15:02:34 rj -# .C.o default rule uses CXXFLAGS instead of CFLAGS for compilation. -# -# dependencies modified to allow c*-lib's recursive dependency-making. -# -# Revision 1.4 1995/02/18 11:53:48 rj -# added a small hack to find gcc's hidden include directory to pass it to makedepend. this shall enable X11's makedepend to find .h files a little more the way gcc does. -# -# Revision 1.3 1994/09/01 01:34:49 rj -# gen-distfiles phony target to generate up-to-date versions of the distfiles. -# -# Revision 1.2 1994/08/31 23:23:24 rj -# use a make macro MKDEP (set via autoconf) instead of a fixed name. -# generate dependencies for .c files derived from .asn1 files. -# - -# different make versions have different default rules, so we need our own to get a consistent behaviour... -.l.c: - $(REASON) - $(RM) $@ - $(LEX) $(LFLAGS) -t $< > $@~ - mv $@~ $@ -.c.o: - $(REASON) - $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -.C.o: - $(REASON) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< - -.PHONY: depend distfiles - -depend:: $(ASN1HFILES) $(ASN1CFILES) $(LCFILES) $(YHFILES) $(YCFILES) - -depend:: - if [ x"$(DEPENDENCIES)" != x ]; then\ - touch newdep;\ - $(MKDEP) -f newdep $(CPPFLAGS) -DMAKEDEPEND $(MKDEP_CCINC) $(ASN1CFILES) $(LCFILES) $(YCFILES) $(CFILES);\ - mv newdep $(DEPENDENCIES);\ - $(RM) newdep.bak;\ - fi - -ifeq "$(MAKE_CLEAN_HACK)" "" # avoid any recompilation when we just want to `make clean' -include dependencies -endif - -dependencies: - touch $@ - $(MAKE) depend - -$(TCL-P): - cd $(TOP) && $(MAKE) tcl-p -clean:: - $(RM) dependencies - -gen-distfiles:: $(DISTFILES) - -distfiles:: - echo "$(DISTFILES)" - -.PHONY: clean clobber - -clobber:: clean diff --git a/SecuritySNACCRuntime/mkinstalldirs b/SecuritySNACCRuntime/mkinstalldirs deleted file mode 100644 index 91f6d04e..00000000 --- a/SecuritySNACCRuntime/mkinstalldirs +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Last modified: 1994-03-25 -# Public domain - -errstatus=0 - -for file in ${1+"$@"} ; do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d in ${1+"$@"} ; do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" 1>&2 - mkdir "$pathcomp" || errstatus=$? - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here diff --git a/SecuritySNACCRuntime/snacc.h b/SecuritySNACCRuntime/snacc.h deleted file mode 100644 index 73dded49..00000000 --- a/SecuritySNACCRuntime/snacc.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * file: snacc.h - * - * INSERT_VDA_COMMENTS - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/Attic/snacc.h,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ - * $Log: snacc.h,v $ - * Revision 1.1.1.1 2001/05/18 23:14:04 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:16 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:05:50 aram - * Originals from SMIME Free Library. - * - * Revision 1.7 1997/04/07 13:13:18 wan - * Made more C++ readable (credits to Steve Walker) - * - * Revision 1.6 1997/02/28 13:39:35 wan - * Modifications collected for new version 1.3: Bug fixes, tk4.2. - * - * Revision 1.5 1997/02/15 20:38:48 rj - * In member functions, return *this after calling abort() for stupid compilers that don't seem to know about volatile abort() (they would otherwise abort with an error). - * - * Revision 1.4 1995/07/24 15:06:52 rj - * configure checks for mem* functions. define replacements using b* functions, if necessary. - * - */ - -#ifndef _SNACC_H_ -#define _SNACC_H_ - -#define GLASS 1 -#define KHO 1 - -#include "config.h" - -#if STDC_HEADERS -#include -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#if HAVE_MEMCMP /* memcmp(3) returns <0, 0 and 0, bcmp(3) returns only 0 and !0 */ -#define memcmpeq( a, b, len) memcmp (a, b, len) -#else -#define memcmpeq( a, b, len) bcmp (a, b, len) -#endif -#if HAVE_MEMSET -#define memzero( p, len) memset (p, 0, len) -#else -#define memzero( p, len) bzero (p, len) -#endif -#if !HAVE_MEMCPY -#define memcpy( dst, src, len) bcopy (src, dst, len) -#endif - -#ifdef __cplusplus - -#ifdef VOLATILE_RETRUN -# define RETURN_THIS_FOR_COMPILERS_WITHOUT_VOLATILE_FUNCTIONS return *this; -#else -# define RETURN_THIS_FOR_COMPILERS_WITHOUT_VOLATILE_FUNCTIONS -#endif - -#if !BOOL_BUILTIN -#ifndef true -// enum bool { false, true }; -// the above looks elegant, but leads to anachronisms (<, ==, !=, ... return value of type int, not enum bool), therefore: -typedef int bool; -enum { false, true }; -#endif -#endif - -#else /* !__cplusplus */ - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - -#endif /* __cplusplus */ - -/* - * Inspired by gdb 4.0, for better or worse... - * (grabbed from Barry Brachman - MS) - * - * These macros munge C routine declarations such - * that they work for ANSI or non-ANSI C compilers - */ -#ifdef __USE_ANSI_C__ - -#define PROTO( X) X -#define PARAMS( arglist, args) (args) -#define NOPARAMS() (void) -#define _AND_ , -#define DOTS , ... - -#else /* !__USE_ANSI_C__ */ - -#define PROTO( X) () -#define PARAMS( arglist, args) arglist args; -#define NOPARAMS() () -#define _AND_ ; -#define DOTS -#define void char - -#endif /* __USE_ANSI_C__ */ - -#include "policy.h" - -#if COMPILER -#define TCL (HAVE_TCL && !NO_TCL) -#define META (TCL && !NO_META) -#endif - -#if MAKEDEPEND -#if !NO_META -#ifdef META -#undef META -#endif -#define META 1 -#endif -#if !NO_TCL -#ifdef TCL -#undef TCL -#endif -#define TCL 1 -#endif -#endif - -#if TCL -#ifdef META -#undef META -#endif -#define META 1 -#endif - -#define COMMA , - -#ifdef _IBM_ENC_ -#define if_IBM_ENC( code) code -#else -#define if_IBM_ENC( code) -#endif - -#if META -#define if_META( code) code -#else -#define if_META( code) -#endif - -#if TCL && META -#define if_TCL( code) code -#else -#define if_TCL( code) -#endif - -#ifndef _gVDADER_RULES -extern int gVDADER_RULES; -#endif - -#endif /* _SNACC_H_ */ diff --git a/SecuritySNACCRuntime/snacc.pbproj/project.pbxproj b/SecuritySNACCRuntime/snacc.pbproj/project.pbxproj deleted file mode 100644 index 1f5405d6..00000000 --- a/SecuritySNACCRuntime/snacc.pbproj/project.pbxproj +++ /dev/null @@ -1,1137 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 36; - objects = { - 00FA20B2FFD8762011CD2A97 = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = NO; - OPTIMIZATION_CFLAGS = "-O0"; - }; - isa = PBXBuildStyle; - name = Development; - }; - 00FA20B3FFD8762011CD2A97 = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = YES; - }; - isa = PBXBuildStyle; - name = Deployment; - }; -//000 -//001 -//002 -//003 -//004 -//050 -//051 -//052 -//053 -//054 - 0509B1B6FF15460611CD283A = { - isa = PBXFrameworkReference; - path = SecuritySNACCRuntime.framework; - refType = 3; - }; -//050 -//051 -//052 -//053 -//054 -//150 -//151 -//152 -//153 -//154 - 15CACFCEFF6579E2D0A17CE7 = { - isa = PBXFileReference; - name = cdsaUtils.cpp; - path = "c++-lib/src/cdsaUtils.cpp"; - refType = 4; - }; - 15CACFCFFF6579E2D0A17CE7 = { - fileRef = 15CACFCEFF6579E2D0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 15CACFD0FF657A5BD0A17CE7 = { - isa = PBXFileReference; - name = cdsaUtils.h; - path = "c++-lib/inc/cdsaUtils.h"; - refType = 4; - }; - 15CACFD1FF657A5BD0A17CE7 = { - fileRef = 15CACFD0FF657A5BD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; -//150 -//151 -//152 -//153 -//154 -//3D0 -//3D1 -//3D2 -//3D3 -//3D4 - 3D3E9FE5FEF01C90D0A17CE7 = { - buildStyles = ( - 00FA20B2FFD8762011CD2A97, - 00FA20B3FFD8762011CD2A97, - ); - isa = PBXProject; - mainGroup = 3D3E9FE6FEF01C90D0A17CE7; - productRefGroup = 5D41A7C1FEF026FFD0A17CE7; - projectDirPath = ""; - targets = ( - 6B215E98FEF02818D0A17CE7, - 5D41A7C3FEF026FFD0A17CE7, - 3D3E9FE8FEF01D16D0A17CE7, - ); - }; - 3D3E9FE6FEF01C90D0A17CE7 = { - children = ( - 3D3E9FE7FEF01D16D0A17CE7, - 5D41A7C1FEF026FFD0A17CE7, - 6B215E9BFEF02ACDD0A17CE7, - 6B215E9CFEF02ACDD0A17CE7, - 15CACFCEFF6579E2D0A17CE7, - 9D176EDF02478EF100003D05, - ); - isa = PBXGroup; - refType = 4; - }; - 3D3E9FE7FEF01D16D0A17CE7 = { - children = ( - 5D41A792FEF026FFD0A17CE7, - 5D41A793FEF026FFD0A17CE7, - 5D41A794FEF026FFD0A17CE7, - 5D41A795FEF026FFD0A17CE7, - 5D41A796FEF026FFD0A17CE7, - 5D41A797FEF026FFD0A17CE7, - 5D41A798FEF026FFD0A17CE7, - 5D41A799FEF026FFD0A17CE7, - 5D41A79AFEF026FFD0A17CE7, - 5D41A79BFEF026FFD0A17CE7, - 5D41A79CFEF026FFD0A17CE7, - 5D41A79DFEF026FFD0A17CE7, - 5D41A79EFEF026FFD0A17CE7, - 5D41A79FFEF026FFD0A17CE7, - 5D41A7A0FEF026FFD0A17CE7, - 5D41A7A1FEF026FFD0A17CE7, - 5D41A7A2FEF026FFD0A17CE7, - 5D41A7A3FEF026FFD0A17CE7, - 5D41A7A4FEF026FFD0A17CE7, - 5D41A7A5FEF026FFD0A17CE7, - 5D41A7A6FEF026FFD0A17CE7, - 5D41A7A7FEF026FFD0A17CE7, - 5D41A7A8FEF026FFD0A17CE7, - 5D41A7A9FEF026FFD0A17CE7, - 5D41A7AAFEF026FFD0A17CE7, - 5D41A7ABFEF026FFD0A17CE7, - 5D41A7ACFEF026FFD0A17CE7, - 5D41A7ADFEF026FFD0A17CE7, - 5D41A7AEFEF026FFD0A17CE7, - 5D41A7AFFEF026FFD0A17CE7, - 5D41A7B0FEF026FFD0A17CE7, - 5D41A7B1FEF026FFD0A17CE7, - 5D41A7B2FEF026FFD0A17CE7, - 5D41A7B3FEF026FFD0A17CE7, - 5D41A7B4FEF026FFD0A17CE7, - 5D41A7B5FEF026FFD0A17CE7, - 5D41A7B6FEF026FFD0A17CE7, - 5D41A7B7FEF026FFD0A17CE7, - 5D41A7B8FEF026FFD0A17CE7, - 5D41A7B9FEF026FFD0A17CE7, - 5D41A7BAFEF026FFD0A17CE7, - 5D41A7BBFEF026FFD0A17CE7, - 5D41A7BCFEF026FFD0A17CE7, - 5D41A7BDFEF026FFD0A17CE7, - 5D41A7BEFEF026FFD0A17CE7, - 5D41A7BFFEF026FFD0A17CE7, - 5D41A7C0FEF026FFD0A17CE7, - 15CACFD0FF657A5BD0A17CE7, - ); - isa = PBXGroup; - name = "c++-lib"; - refType = 4; - }; - 3D3E9FE8FEF01D16D0A17CE7 = { - buildArgumentsString = "-f $(SRCROOT)/MacOSX-make SRCROOT=$(SRCROOT) $ACTION"; - buildPhases = ( - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ""; - HEADER_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Libraries/CIncludes\""; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = UnixBuild; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - buildToolPath = /usr/bin/make; - dependencies = ( - ); - isa = PBXLegacyTarget; - name = UnixBuild; - productName = UnixBuild; - settingsToExpand = 6; - settingsToPassInEnvironment = 287; - settingsToPassOnCommandLine = 280; - shouldUseHeadermap = 0; - }; -//3D0 -//3D1 -//3D2 -//3D3 -//3D4 -//5D0 -//5D1 -//5D2 -//5D3 -//5D4 - 5D41A792FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-any.cpp"; - path = "c++-lib/c++/asn-any.cpp"; - refType = 4; - }; - 5D41A793FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-bits.cpp"; - path = "c++-lib/c++/asn-bits.cpp"; - refType = 4; - }; - 5D41A794FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-bool.cpp"; - path = "c++-lib/c++/asn-bool.cpp"; - refType = 4; - }; - 5D41A795FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-enum.cpp"; - path = "c++-lib/c++/asn-enum.cpp"; - refType = 4; - }; - 5D41A796FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-int.cpp"; - path = "c++-lib/c++/asn-int.cpp"; - refType = 4; - }; - 5D41A797FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-len.cpp"; - path = "c++-lib/c++/asn-len.cpp"; - refType = 4; - }; - 5D41A798FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-list.cpp"; - path = "c++-lib/c++/asn-list.cpp"; - refType = 4; - }; - 5D41A799FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-null.cpp"; - path = "c++-lib/c++/asn-null.cpp"; - refType = 4; - }; - 5D41A79AFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-octs.cpp"; - path = "c++-lib/c++/asn-octs.cpp"; - refType = 4; - }; - 5D41A79BFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-oid.cpp"; - path = "c++-lib/c++/asn-oid.cpp"; - refType = 4; - }; - 5D41A79CFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-real.cpp"; - path = "c++-lib/c++/asn-real.cpp"; - refType = 4; - }; - 5D41A79DFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-tag.cpp"; - path = "c++-lib/c++/asn-tag.cpp"; - refType = 4; - }; - 5D41A79EFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-type.cpp"; - path = "c++-lib/c++/asn-type.cpp"; - refType = 4; - }; - 5D41A79FFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-useful.cpp"; - path = "c++-lib/c++/asn-useful.cpp"; - refType = 4; - }; - 5D41A7A0FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = hash.cpp; - path = "c++-lib/c++/hash.cpp"; - refType = 4; - }; - 5D41A7A1FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = meta.cpp; - path = "c++-lib/c++/meta.cpp"; - refType = 4; - }; - 5D41A7A2FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = print.cpp; - path = "c++-lib/c++/print.cpp"; - refType = 4; - }; - 5D41A7A3FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "str-stk.cpp"; - path = "c++-lib/c++/str-stk.cpp"; - refType = 4; - }; - 5D41A7A4FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "tcl-if.cpp"; - path = "c++-lib/c++/tcl-if.cpp"; - refType = 4; - }; - 5D41A7A5FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-any.h"; - path = "c++-lib/inc/asn-any.h"; - refType = 4; - }; - 5D41A7A6FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-bits.h"; - path = "c++-lib/inc/asn-bits.h"; - refType = 4; - }; - 5D41A7A7FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-bool.h"; - path = "c++-lib/inc/asn-bool.h"; - refType = 4; - }; - 5D41A7A8FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-buf.h"; - path = "c++-lib/inc/asn-buf.h"; - refType = 4; - }; - 5D41A7A9FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-config.h"; - path = "c++-lib/inc/asn-config.h"; - refType = 4; - }; - 5D41A7AAFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-enum.h"; - path = "c++-lib/inc/asn-enum.h"; - refType = 4; - }; - 5D41A7ABFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-incl.h"; - path = "c++-lib/inc/asn-incl.h"; - refType = 4; - }; - 5D41A7ACFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-int.h"; - path = "c++-lib/inc/asn-int.h"; - refType = 4; - }; - 5D41A7ADFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-len.h"; - path = "c++-lib/inc/asn-len.h"; - refType = 4; - }; - 5D41A7AEFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-list.h"; - path = "c++-lib/inc/asn-list.h"; - refType = 4; - }; - 5D41A7AFFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-null.h"; - path = "c++-lib/inc/asn-null.h"; - refType = 4; - }; - 5D41A7B0FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-octs.h"; - path = "c++-lib/inc/asn-octs.h"; - refType = 4; - }; - 5D41A7B1FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-oid.h"; - path = "c++-lib/inc/asn-oid.h"; - refType = 4; - }; - 5D41A7B2FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-real.h"; - path = "c++-lib/inc/asn-real.h"; - refType = 4; - }; - 5D41A7B3FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-tag.h"; - path = "c++-lib/inc/asn-tag.h"; - refType = 4; - }; - 5D41A7B4FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-type.h"; - path = "c++-lib/inc/asn-type.h"; - refType = 4; - }; - 5D41A7B5FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "asn-useful.h"; - path = "c++-lib/inc/asn-useful.h"; - refType = 4; - }; - 5D41A7B6FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = config.h; - path = "c++-lib/inc/config.h"; - refType = 4; - }; - 5D41A7B7FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = hash.h; - path = "c++-lib/inc/hash.h"; - refType = 4; - }; - 5D41A7B8FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = init.h; - path = "c++-lib/inc/init.h"; - refType = 4; - }; - 5D41A7B9FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = meta.h; - path = "c++-lib/inc/meta.h"; - refType = 4; - }; - 5D41A7BAFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = policy.h; - path = "c++-lib/inc/policy.h"; - refType = 4; - }; - 5D41A7BBFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = print.h; - path = "c++-lib/inc/print.h"; - refType = 4; - }; - 5D41A7BCFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = sm_vdasnacc.h; - path = "c++-lib/inc/sm_vdasnacc.h"; - refType = 4; - }; - 5D41A7BDFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = sm_vdatypes.h; - path = "c++-lib/inc/sm_vdatypes.h"; - refType = 4; - }; - 5D41A7BEFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = snacc.h; - path = "c++-lib/inc/snacc.h"; - refType = 4; - }; - 5D41A7BFFEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "str-stk.h"; - path = "c++-lib/inc/str-stk.h"; - refType = 4; - }; - 5D41A7C0FEF026FFD0A17CE7 = { - isa = PBXFileReference; - name = "tcl-if.h"; - path = "c++-lib/inc/tcl-if.h"; - refType = 4; - }; - 5D41A7C1FEF026FFD0A17CE7 = { - children = ( - 0509B1B6FF15460611CD283A, - ); - isa = PBXGroup; - name = Products; - refType = 4; - }; - 5D41A7C3FEF026FFD0A17CE7 = { - buildPhases = ( - 5D41A7C4FEF026FFD0A17CE7, - 5D41A7E1FEF026FFD0A17CE7, - 5D41A7E2FEF026FFD0A17CE7, - 5D41A7F6FEF026FFD0A17CE7, - 5D41A7F7FEF026FFD0A17CE7, - ); - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - FRAMEWORK_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)\" \"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\" \"$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks\""; - FRAMEWORK_VERSION = A; - HEADER_SEARCH_PATHS = ""; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = "-DVDADER_RULES"; - OTHER_LDFLAGS = "\"-lstdc++\""; - OTHER_LIBTOOL_FLAGS = ""; - OTHER_REZFLAGS = ""; - PRINCIPAL_CLASS = ""; - PRODUCT_NAME = SecuritySNACCRuntime; - SECTORDER_FLAGS = "-sectorder __TEXT __text \"$(APPLE_INTERNAL_DIR)/OrderFiles/SecuritySNACCRuntime.order\""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - WRAPPER_EXTENSION = framework; - }; - dependencies = ( - ); - isa = PBXFrameworkTarget; - name = snaccRuntime; - productInstallPath = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; - productName = SecuritySNACCRuntime; - productReference = 0509B1B6FF15460611CD283A; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - SecuritySNACCRuntime - CFBundleGetInfoString - - CFBundleIconFile - - CFBundleIdentifier - - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - - CFBundlePackageType - FMWK - CFBundleShortVersionString - - CFBundleSignature - ???? - CFBundleVersion - 0.0.1d1 - - -"; - shouldUseHeadermap = 1; - }; - 5D41A7C4FEF026FFD0A17CE7 = { - buildActionMask = 2147483647; - files = ( - 5D41A7C5FEF026FFD0A17CE7, - 5D41A7C6FEF026FFD0A17CE7, - 5D41A7C7FEF026FFD0A17CE7, - 5D41A7C8FEF026FFD0A17CE7, - 5D41A7C9FEF026FFD0A17CE7, - 5D41A7CAFEF026FFD0A17CE7, - 5D41A7CBFEF026FFD0A17CE7, - 5D41A7CCFEF026FFD0A17CE7, - 5D41A7CDFEF026FFD0A17CE7, - 5D41A7CEFEF026FFD0A17CE7, - 5D41A7CFFEF026FFD0A17CE7, - 5D41A7D0FEF026FFD0A17CE7, - 5D41A7D1FEF026FFD0A17CE7, - 5D41A7D2FEF026FFD0A17CE7, - 5D41A7D3FEF026FFD0A17CE7, - 5D41A7D4FEF026FFD0A17CE7, - 5D41A7D5FEF026FFD0A17CE7, - 5D41A7D6FEF026FFD0A17CE7, - 5D41A7D7FEF026FFD0A17CE7, - 5D41A7D8FEF026FFD0A17CE7, - 5D41A7D9FEF026FFD0A17CE7, - 5D41A7DAFEF026FFD0A17CE7, - 5D41A7DBFEF026FFD0A17CE7, - 5D41A7DCFEF026FFD0A17CE7, - 5D41A7DDFEF026FFD0A17CE7, - 5D41A7DEFEF026FFD0A17CE7, - 5D41A7DFFEF026FFD0A17CE7, - 5D41A7E0FEF026FFD0A17CE7, - 15CACFD1FF657A5BD0A17CE7, - ); - isa = PBXHeadersBuildPhase; - }; - 5D41A7C5FEF026FFD0A17CE7 = { - fileRef = 5D41A7A5FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7C6FEF026FFD0A17CE7 = { - fileRef = 5D41A7A6FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7C7FEF026FFD0A17CE7 = { - fileRef = 5D41A7A7FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7C8FEF026FFD0A17CE7 = { - fileRef = 5D41A7A8FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7C9FEF026FFD0A17CE7 = { - fileRef = 5D41A7A9FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7CAFEF026FFD0A17CE7 = { - fileRef = 5D41A7AAFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7CBFEF026FFD0A17CE7 = { - fileRef = 5D41A7ABFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7CCFEF026FFD0A17CE7 = { - fileRef = 5D41A7ACFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7CDFEF026FFD0A17CE7 = { - fileRef = 5D41A7ADFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7CEFEF026FFD0A17CE7 = { - fileRef = 5D41A7AEFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7CFFEF026FFD0A17CE7 = { - fileRef = 5D41A7AFFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D0FEF026FFD0A17CE7 = { - fileRef = 5D41A7B0FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D1FEF026FFD0A17CE7 = { - fileRef = 5D41A7B1FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D2FEF026FFD0A17CE7 = { - fileRef = 5D41A7B2FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D3FEF026FFD0A17CE7 = { - fileRef = 5D41A7B3FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D4FEF026FFD0A17CE7 = { - fileRef = 5D41A7B4FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D5FEF026FFD0A17CE7 = { - fileRef = 5D41A7B5FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D6FEF026FFD0A17CE7 = { - fileRef = 5D41A7B6FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D7FEF026FFD0A17CE7 = { - fileRef = 5D41A7B7FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D8FEF026FFD0A17CE7 = { - fileRef = 5D41A7B8FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7D9FEF026FFD0A17CE7 = { - fileRef = 5D41A7B9FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7DAFEF026FFD0A17CE7 = { - fileRef = 5D41A7BAFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7DBFEF026FFD0A17CE7 = { - fileRef = 5D41A7BBFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7DCFEF026FFD0A17CE7 = { - fileRef = 5D41A7BCFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7DDFEF026FFD0A17CE7 = { - fileRef = 5D41A7BDFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7DEFEF026FFD0A17CE7 = { - fileRef = 5D41A7BEFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7DFFEF026FFD0A17CE7 = { - fileRef = 5D41A7BFFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7E0FEF026FFD0A17CE7 = { - fileRef = 5D41A7C0FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Public, - ); - }; - }; - 5D41A7E1FEF026FFD0A17CE7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXResourcesBuildPhase; - }; - 5D41A7E2FEF026FFD0A17CE7 = { - buildActionMask = 2147483647; - files = ( - 5D41A7E3FEF026FFD0A17CE7, - 5D41A7E4FEF026FFD0A17CE7, - 5D41A7E5FEF026FFD0A17CE7, - 5D41A7E6FEF026FFD0A17CE7, - 5D41A7E7FEF026FFD0A17CE7, - 5D41A7E8FEF026FFD0A17CE7, - 5D41A7E9FEF026FFD0A17CE7, - 5D41A7EAFEF026FFD0A17CE7, - 5D41A7EBFEF026FFD0A17CE7, - 5D41A7ECFEF026FFD0A17CE7, - 5D41A7EDFEF026FFD0A17CE7, - 5D41A7EEFEF026FFD0A17CE7, - 5D41A7EFFEF026FFD0A17CE7, - 5D41A7F0FEF026FFD0A17CE7, - 5D41A7F1FEF026FFD0A17CE7, - 5D41A7F2FEF026FFD0A17CE7, - 5D41A7F3FEF026FFD0A17CE7, - 5D41A7F4FEF026FFD0A17CE7, - 5D41A7F5FEF026FFD0A17CE7, - 6B215E9DFEF02ACDD0A17CE7, - 6B215E9EFEF02ACDD0A17CE7, - 15CACFCFFF6579E2D0A17CE7, - ); - isa = PBXSourcesBuildPhase; - }; - 5D41A7E3FEF026FFD0A17CE7 = { - fileRef = 5D41A792FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7E4FEF026FFD0A17CE7 = { - fileRef = 5D41A793FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7E5FEF026FFD0A17CE7 = { - fileRef = 5D41A794FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7E6FEF026FFD0A17CE7 = { - fileRef = 5D41A795FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7E7FEF026FFD0A17CE7 = { - fileRef = 5D41A796FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7E8FEF026FFD0A17CE7 = { - fileRef = 5D41A797FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7E9FEF026FFD0A17CE7 = { - fileRef = 5D41A798FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7EAFEF026FFD0A17CE7 = { - fileRef = 5D41A799FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7EBFEF026FFD0A17CE7 = { - fileRef = 5D41A79AFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7ECFEF026FFD0A17CE7 = { - fileRef = 5D41A79BFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7EDFEF026FFD0A17CE7 = { - fileRef = 5D41A79CFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7EEFEF026FFD0A17CE7 = { - fileRef = 5D41A79DFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7EFFEF026FFD0A17CE7 = { - fileRef = 5D41A79EFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7F0FEF026FFD0A17CE7 = { - fileRef = 5D41A79FFEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7F1FEF026FFD0A17CE7 = { - fileRef = 5D41A7A0FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7F2FEF026FFD0A17CE7 = { - fileRef = 5D41A7A1FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7F3FEF026FFD0A17CE7 = { - fileRef = 5D41A7A2FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7F4FEF026FFD0A17CE7 = { - fileRef = 5D41A7A3FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7F5FEF026FFD0A17CE7 = { - fileRef = 5D41A7A4FEF026FFD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 5D41A7F6FEF026FFD0A17CE7 = { - buildActionMask = 2147483647; - files = ( - 9D176FDC02478EF100003D05, - ); - isa = PBXFrameworksBuildPhase; - }; - 5D41A7F7FEF026FFD0A17CE7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - }; -//5D0 -//5D1 -//5D2 -//5D3 -//5D4 -//6B0 -//6B1 -//6B2 -//6B3 -//6B4 - 6B215E98FEF02818D0A17CE7 = { - buildPhases = ( - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ""; - HEADER_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Libraries/CIncludes\""; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = World; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - dependencies = ( - 6B215E9AFEF02818D0A17CE7, - ); - isa = PBXAggregateTarget; - name = World; - productName = World; - shouldUseHeadermap = 0; - }; - 6B215E9AFEF02818D0A17CE7 = { - isa = PBXTargetDependency; - target = 5D41A7C3FEF026FFD0A17CE7; - }; - 6B215E9BFEF02ACDD0A17CE7 = { - isa = PBXFileReference; - name = sm_buffer.cpp; - path = "c++-lib/src/sm_buffer.cpp"; - refType = 4; - }; - 6B215E9CFEF02ACDD0A17CE7 = { - isa = PBXFileReference; - name = sm_vdasnacc.cpp; - path = "c++-lib/src/sm_vdasnacc.cpp"; - refType = 4; - }; - 6B215E9DFEF02ACDD0A17CE7 = { - fileRef = 6B215E9BFEF02ACDD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 6B215E9EFEF02ACDD0A17CE7 = { - fileRef = 6B215E9CFEF02ACDD0A17CE7; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; -//6B0 -//6B1 -//6B2 -//6B3 -//6B4 -//9D0 -//9D1 -//9D2 -//9D3 -//9D4 - 9D176EDF02478EF100003D05 = { - isa = PBXFrameworkReference; - name = Security.framework; - path = /System/Library/Frameworks/Security.framework; - refType = 0; - }; - 9D176FDC02478EF100003D05 = { - fileRef = 9D176EDF02478EF100003D05; - isa = PBXBuildFile; - settings = { - }; - }; - }; - rootObject = 3D3E9FE5FEF01C90D0A17CE7; -} diff --git a/SecuritySNACCRuntime/stamp-h b/SecuritySNACCRuntime/stamp-h deleted file mode 100644 index 3cd61a14..00000000 --- a/SecuritySNACCRuntime/stamp-h +++ /dev/null @@ -1 +0,0 @@ -Tue Mar 19 10:27:31 PST 2002 diff --git a/SecuritySNACCRuntime/stamp-h.in b/SecuritySNACCRuntime/stamp-h.in deleted file mode 100644 index 925eace8..00000000 --- a/SecuritySNACCRuntime/stamp-h.in +++ /dev/null @@ -1 +0,0 @@ -Thu Dec 21 14:13:51 PST 2000 diff --git a/SecuritySNACCRuntime/tbl-example/README b/SecuritySNACCRuntime/tbl-example/README deleted file mode 100644 index 073608f7..00000000 --- a/SecuritySNACCRuntime/tbl-example/README +++ /dev/null @@ -1,89 +0,0 @@ -(RCS control information is at the end of this file.) - - -Table encoder/decoder example README - MS 93 ------------------------------------- - -This directory contains an example that shows: - - 1. the process of creating and using tables. - 2. examples of decoding, printing, and encoding. - - -To dive right in just type "make" in this directory. That will -create the "example" executable (you should have previously installed -the snacc and mkchdr progs and the table library). - -Then type: - - make check - -and see what happens. Look in example.c and makefile to see how things -work. - - - -Questions and Answers ---------------------- - -Q. What is a table? (also refered to a type table or type tree) - -A. A table is simply a data structure that holds a description of - the types from an ASN.1 module. This table can then be used - by a number of "generic" routines to do ASN.1 related (BER - encoding/decoding) or other useful things such as printing - values, freeing values and whatever else you can dream up. - - -Q. How do I create a table from my ASN.1 source files? - -A. Run snacc with the -T option, e.g.: - - snacc -T mytbls.tt myMod1.asn1 myMod2.asn1 - - the above command will create the "mytbls.tt" file that - holds the descriptions of the ASN.1 types in the "myMod1.asn1" - and "myMod2.asn1" files. (look in the makefile in this directory) - - -Q. Why is there only a C interface to tables? - -A. Time. Tables drivers create/read/free these types - without having seen a typedef for them. The C implementation - uses some assumptions about how structures etc. are allocated - and accessed. With C++ this is much more difficult. It can - be done but required more time than I had. - - -Q. Ok, tables sound great, what's the catch? - -A. Well, - - 1. table driven encoding and decoding is something like - 4 times slower than the C or C++ version. - (but tables are *way* smaller than the .o's for the compiled approach) - 2. the ANY DEFINED BY stuff is not supported at all. - 3. subtype information is not included in the tables (time crunch again) - (PER encoders/decoders will need the subtype info) - 4. Values from the ASN.1 source are not included in the table. - - If you have the time and skills, you can fix 2, 3 and 4. 1 is harder. - - - -Q. Tell me more. - -A. Look at the manual. (in .../doc/) - -#------------------------------------------------------------------------------- -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tbl-example/Attic/README,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -# $Log: README,v $ -# Revision 1.1.1.1 2001/05/18 23:14:10 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:54 aram -# Originals from SMIME Free Library. -# -# Revision 1.1 1997/02/15 19:33:24 rj -# first check-in -# diff --git a/SecuritySNACCRuntime/tbl-example/dependencies b/SecuritySNACCRuntime/tbl-example/dependencies deleted file mode 100644 index e69de29b..00000000 diff --git a/SecuritySNACCRuntime/tbl-example/example.c b/SecuritySNACCRuntime/tbl-example/example.c deleted file mode 100644 index 673c0621..00000000 --- a/SecuritySNACCRuntime/tbl-example/example.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * file: .../tbl-example/example.c - decodes and prints a given BER - * PersonnelRecord value and re-encodes it to the file - * "p-rec.out.ber". This example would be similar to your user code in - * that you run "mkchdr" to build a nicely named description of data - * structure (PersonnelRecord in this case). The table tools deal with - * the same data structure in a generic way and don't use/need mkchdr. - * You must not change the output of mkchdr otherwise the table encoder - * decoder, etc will not understand it. - * - * Mike Sample - * - * Copyright (C) 1993 Michael Sample - * and the University of British Columbia - * - * 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 and the associated libraries are distributed in the hope - * that they 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 and GNU Library General - * Public License for more details. - * - * $Header: /cvs/root/Security/SecuritySNACCRuntime/tbl-example/Attic/example.c,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ - * $Log: example.c,v $ - * Revision 1.1.1.1 2001/05/18 23:14:10 mb - * Move from private repository to open source repository - * - * Revision 1.2 2001/05/05 00:59:30 rmurphy - * Adding darwin license headers - * - * Revision 1.1.1.1 1999/03/16 18:06:53 aram - * Originals from SMIME Free Library. - * - * Revision 1.1 1997/02/15 19:33:26 rj - * first check-in - * - */ - -#include "tbl-incl.h" -#include "exp-buf.h" -#include "sbuf.h" - -#include "p-rec.h" /* include the file we made with mkchdr */ - - -char *outputFileNameG = "p-rec.out.ber"; - -void Usage PARAMS ((prg), - char *prg) -{ - fprintf (stderr, "Usage: %s \n\n", prg); - fprintf (stderr, "E.g. %s p-rec.tt p-rec.ber\n\n", prg); - fprintf (stderr, "The BER values in the file list will be decoded, printed to stdout and then re-encoded to the file \"%s\"\n", outputFileNameG); -} - - -int -main PARAMS ((argc, argv), - int argc _AND_ - char **argv) -{ - char *tblFileName; - char *berFileName; - TBL *tbl; - int i; - char *fileData; - unsigned long int fsize; - PersonnelRecord *val; - unsigned long int bytesDecoded; - unsigned long int bytesEncoded; - SBuf sb; /* use simple buffers for reading in (know sizes) */ - ExpBuf *ebPtr; /* use expanding bufs for enc (usually don't know sizes)*/ - GenBuf gb; - FILE *outputFile; - - - - if (argc != 3) - { - Usage (argv[0]); - return 1; - } - - tblFileName = argv[1]; - berFileName = argv[2]; - - /* init mem pool to hold decoded val */ - InitNibbleMem (1024, 1024); - - /* read in and decode the type table */ - tbl = LoadTblFile (tblFileName); - if (tbl == NULL) - return 1; - - fileData = LoadFile (berFileName, &fsize); - if (fileData == NULL) - return 1; - - SBufInstallData (&sb, fileData, fsize); - PutSBufInGenBuf (&sb, &gb); - - fprintf (stdout, "\n\n-- decoded contents of BER PersonnelRecord file: \"%s\"--\n", berFileName); - - val = TblDecode (tbl, NULL, "PersonnelRecord", &gb, &bytesDecoded); - - if (val == NULL) - fprintf (stdout, "-- Decoding error occured somewhere -- \n"); - else - TblPrintValue (tbl, NULL, "PersonnelRecord", stdout, val); - - fprintf (stdout, "\n\n -- decoded %d bytes for the above value --\n\n", bytesDecoded, berFileName); - - free (fileData); /* was malloc'd in LoadFile */ - - /* - * process value here - * (This is where the header file generated by mkchdr is - * useful - you can access the decoded value in a standard - * /easier way). - * - * Ok, well, the names "field0" etc aren't that nice - * but what did you expect - they aren't named in the ASN.1 - * spec so mkchdr just makes them up. To fix this, just - * add field names to you ASN.1 spec - it will not change the - * way the values are encoded - so you're not making it - * incompatible with the original. (not including value notation) - */ - printf ("The following printout is an example of using the\n"); - printf ("hdr file generated by mkchdr to access the data\n"); - printf ("returned from the table decoder. Look in \"example.c\"\n\n"); - - - printf ("***** JQ GUMBY & CO Database *****************************************\n"); - printf ("Employee Name: %s %s %s\n", val->field0->givenName->octs, val->field0->initial->octs, val->field0->familyName->octs); - printf ("Title: %s\n", val->title->octs); - printf ("Employee Number: %d\n", *val->field1); - printf ("Date of Hire: %s\n", val->dateOfHire->octs); - printf ("Name of Spouse: %s %s %s\n", val->nameOfSpouse->givenName->octs, val->nameOfSpouse->initial->octs, val->nameOfSpouse->familyName->octs); - printf ("Number of Children: %d\n", AsnListCount (val->children)); - printf ("**********************************************************************\n\n"); - - /* - * finished playing with the decoded value. - * now re-encode the value. Using an expbuf to hold the encoded val - * because they can grow and in general you can predict a values - * encoded size (although we could assume that is would be close to - * the same size as the one we read in at the beginning of this prg). - * (note: the size of PersonnelRecord BER value we decoded may be - * different from the size of the re-encoded version depending on - * the use of indefinite or definite lengths. Both are valid BER.) - */ - fprintf (stdout, "now re-encoding the PersonnelRecord value to \"%s\"\n", outputFileNameG); - - ebPtr = ExpBufAllocBufAndData(); - ExpBufResetInWriteRvsMode (ebPtr); /* set up to hold encoding (= writing) */ - - PutExpBufInGenBuf (ebPtr, &gb); - - if (TblEncode (tbl, NULL, "PersonnelRecord", &gb, val, &bytesEncoded) < 0) - fprintf (stderr, "main: error encoding the PersonnelRecord\n"); - - /* copy ExpBuf data to file */ - outputFile = fopen (outputFileNameG, "w"); - if (outputFile == NULL) - { - fprintf (stderr, "error - could not open file \"%s\"\n", outputFileNameG); - perror ("main: fopen:"); - } - - ExpBufCopyToFile (ebPtr, outputFile); - - fclose (outputFile); - - /* free the encoded version */ - ExpBufFreeBufAndDataList (ebPtr); - - - return 0; -} /* main */ diff --git a/SecuritySNACCRuntime/tbl-example/makefile b/SecuritySNACCRuntime/tbl-example/makefile deleted file mode 100644 index 737ed74a..00000000 --- a/SecuritySNACCRuntime/tbl-example/makefile +++ /dev/null @@ -1,88 +0,0 @@ -# file: .../tbl-example/makefile -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tbl-example/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:10 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:53 aram -# Originals from SMIME Free Library. -# -# Revision 1.1 1997/02/15 19:33:26 rj -# first check-in -# - -include ../makehead - -TOP = .. - -ASN1_SRC_DIR = $(TOP)/asn1specs - -ASN1_C_LIB_DIR = $(TOP)/c-lib -ASN1_C_INC_DIR = $(ASN1_C_LIB_DIR)/inc -TTBL_ASN1_LIB = $(ASN1_C_LIB_DIR)/libasn1ctbl.a - -COMPILERDIR = $(TOP)/compiler -SNACC = $(COMPILERDIR)/snacc -USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 -SNACCFLAGS = -u $(USEFUL_TYPES) - -TBLTOOLSDIR = $(TOP)/tbl-tools -MKHDR = $(TBLTOOLSDIR)/mkchdr/mkchdr - -ASN1FILES = $(ASN1_SRC_DIR)/p-rec.asn1 -ASN1TTFILE = p-rec.tt -ASN1TTHFILE = p-rec.h - -CFILES = example.c -OFILES = example.o - -DISTFILES = \ - README \ - makefile \ - $(CFILES) \ - p-rec.ber - -CPPFLAGS += -I$(TOP) -I$(ASN1_C_INC_DIR) -DUSE_GEN_BUF - -#------------------------------------------------------------------------------- - -all:: example - -example: $(OFILES) $(TTBL_ASN1_LIB) - $(REASON) - $(CC) $(CFLAGS) -o example $(OFILES) $(TTBL_ASN1_LIB) $(LIBS) - -$(ASN1TTFILE): $(ASN1FILES) - $(REASON) - $(SNACC) $(SNACCFLAGS) -T $@ $(ASN1FILES) - -$(SNACC) $(MKHDR): - cd $(@D) && $(MAKE) $(@F) - -$(TTBL_ASN1_LIB): - cd $(@D) && $(MAKE) tbl-lib - -$(ASN1TTHFILE): $(ASN1TTFILE) - $(REASON) - $(MKHDR) $? $@ - -check:: example $(ASN1TTFILE) - -check:: - ./example p-rec.tt p-rec.ber - cmp p-rec.ber p-rec.out.ber - @echo "+++ the test was successful" - -# dummy: -install:: - -clean:: - $(RM) example *.o *~ core .emacs* $(ASN1TTFILE) $(ASN1TTHFILE) p-rec.out.ber - -depend:: - $(MAKE) $(MKHDR) - -depend:: $(ASN1TTHFILE) - -include ../maketail diff --git a/SecuritySNACCRuntime/tbl-example/p-rec.ber b/SecuritySNACCRuntime/tbl-example/p-rec.ber deleted file mode 100644 index f8cc9410ed7be7741ca4c0e0805cce1fbee7df6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmYdj>`N37WAVz*$P;696=My~%`C}SARxvUl98(5l$oyJoROMZoEqQAz|7b-e<7DM zhoPl~k%6Is$s!?;M&HDuN-;(ssK&*PhVqGmVys??xv9lsj6pE-z}igB4U7#94CO%D Td@_p@#Tb22XDhLfT?hx%l&cuK!^{_B{bY;1Yqy1nv-6#2-IdkX>Q{QGRBl zvRPdXzz74j&)}F4=+)&;#Qn$7b??QidNA-(Uv>fTq{2HfQ@j zm=R&JY(xNrp9b6Px(`MCH#ASO1PTB~KesCmxvO8fdhX$jaD@_8hukDngTTe`)!-#7O-BUG zlr2t6W5Y&OU};AGf{npzt=B@TJ+?w1P0Jfxc0JeS&L(eq(ysH*wHABmLw-6|DJ&1> zPsd6{v3kD=Wa!)(4c7ZLohx?L2zx&Uz3-BtCG>Kum z`T3RldS$C#eY^D`fMFPI?9u*>_cjjCys1JZ{H*QLW{Ve zT#9C0N#X9EBj+`VJ8fcjkxKIG}l;O`Y(l!yFh2R zh0VQW!G*D4f#%j$UL*)!8Yft!#dp%`>?M|cbxh9E;a*@CsEv(gR%g>h+ zg2y2CyoABI%cbQckk_^3U33xve-2NwfWz14Kx8>sb zkln=CH#CcrDbw8Rj~fXY-qch8O9U3ES^d_TTOA zef6P$>mMEs4%xGj6-v>ajjmGkiTR}Ce7a}?hgZ;9OBHq8;q2bDb+pB!yo+8_aaFM# fvFmc1-SUA<{Dn}Qbk34HLP<*=_f4$Lvr+pGi". - -"asn" offers the following possibilities: - -"asn modules" - Returns a list of all modules of the grammar. - -"asn types ?module?" - Returns a list of all type definitions of the - grammar respectively of the module given. - Each type definition is returned as a list - consisting of the module name and the type name. - -"asn type ?-followref? {?module? typedef ?subtype? ...} - Returns a description of the given type. - The description format is - " ??". - - In case of a type definition, "" is a three- - element list "{ "pdu"|"sub"}". - In case of a subtype, is the fieldname, - if any, or an empty list "{}". - - "" is one out of "BOOLEAN", "INTEGER", "BIT STRING", - "OCTET STRING", "NULL", "OBJECT IDENTIFIER", "REAL", - "ENUMERATED", "SEQUENCE", "SET", "SEQUENCE OF", "SET OF", - "CHOICE" or "TYPEREF". - - "" is either empty, or a single numeric value, - or a list of two numeric vaules. It can be available - for types "SEQUENCE OF" (giving the lower and, optionally, - the upper bounds of the index), "INTEGER" (giving the lowest - and the highest possible value) and "OCTET STRING" (giving - the minimum and, optionally, the maximum length). - - "" is either empty, or a list of two-element - lists, each consisting of an integer value and a name. - It can be available for types "BIT STRING" and "ENUMERATED". - - "??" is available for types "TYPEREF" (where it - is a two-element list "{ }" and "SEQUENCE", - "SET", "SEQUENCE OF", "SET OF", "CHOICE" (where it is a list - of subtype descriptions, each of the format given here). - -"asn decode channel {?module? typedef ?subtype? ...} valcmd ?typecmd?" - Reads from the channel the given type, BER encoded, and decodes it. - During decoding, whenever a compound type is entered or left, - the Tcl/Tk "typecmd" (if any) is executed, with the type path - as first parameter, and a "1" resp. "-1" as second, and - whenever a value is decoded, the Tcl/Tk "valcmd" is executed, - with the type path as the first and the value as the second - parameter. BOOLEAN values are represented as "TRUE" resp. - "FALSE". INTEGER and ENUMERATED values are represented by - their decimal representation. BIT STRINGs are represented by - a string of "0" and "1" characters. OCTET STRINGs and OIDs - are represented as following: printable characters (except the - character "\") are copied unchanged; non-printable characters - and the character "\" are represented by \OOO (e.g., their ASCII - value encoded by three octal digits with leading 0). The NULL - type is encoded as "NULL". REAL numbers representation follows - sprintf %G. - - Returns the number of bytes decoded. - -"asn encode channel {?module? typedef ?subtype? ...} valcmd ?typecmd?" - -"asn close" - Closes the grammar and deletes the internal data structure. diff --git a/SecuritySNACCRuntime/tcl-asn/asnwish.c b/SecuritySNACCRuntime/tcl-asn/asnwish.c deleted file mode 100644 index aec6f29e..00000000 --- a/SecuritySNACCRuntime/tcl-asn/asnwish.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#include "tk.h" - -extern int Tbl_AppInit (); - -int main(argc, argv) - int argc; /* Number of command-line arguments. */ - char **argv; /* Values of command-line arguments. */ -{ - Tk_Main(argc, argv, Tbl_AppInit); - return 0; /* Needed only to prevent compiler warning. */ -} diff --git a/SecuritySNACCRuntime/tcl-asn/beredit b/SecuritySNACCRuntime/tcl-asn/beredit deleted file mode 100644 index 807a5462..00000000 --- a/SecuritySNACCRuntime/tcl-asn/beredit +++ /dev/null @@ -1,372 +0,0 @@ -#!/bin/sh -# the next line restarts using wish \ -exec asnwish "$0" "$@" - -proc err {msg} { - tk_dialog .err Error $msg {} 0 Damn -} - -proc ref {desc} { - set res [lindex $desc 0] - if {$res==""} { - set res [lindex $desc 1] - if {$res=="TYPEREF"} { - set res [lindex [lindex $desc 4] 1] - } - } - return $res -} - -proc complete {ntp} { - global pdu - upvar $ntp tp - set tp [string trimright "$pdu $tp"] -} - -proc newenc {tp r toggle} { - global asnenc - set idx $tp - if {$toggle} { - set cur [lindex [array get asnenc $idx] 1] - set pr [lsearch -exact $cur $r] - if {$pr==-1} { - lappend cur $r - } else { - set cur [lreplace $cur $pr $pr] - } - set asnenc($idx) $cur - } else { - set asnenc($idx) $r - } - fillcomposer -} - -proc selpress {y} { - global tag - set i [.selector.l nearest $y] - if {$i==0} return - set tpval [.selector.l get $i] - if {$tag(selector)=="CHOICE"} { - newenc [lindex $tpval 0] [lindex $tpval 1] 0 - } else { - newenc [lindex $tpval 0] [lindex $tpval 1] 1 - } -} - -proc comppress {y} { - global table tag - set i [.composer.l nearest $y] - set tpval [.composer.l get $i] - set tp [lindex $tpval 0] - set val [lindex $tpval 1] - set typetoask $tp - set td [$table type -followref $typetoask] - set t [lindex $td 1] - switch $t { - CHOICE { - set tag(selector) $t - .selector.l delete 0 end - .selector.l insert end "$tp is a CHOICE of:" - foreach {subtypedesc req} [lindex $td 4] { - set r [ref $subtypedesc] - .selector.l insert end [list $tp $r] - } - wm withdraw .insertor - wm deiconify .selector - raise .selector - } - SEQUENCE { - set tag(selector) $t - .selector.l delete 0 end - .selector.l insert end "In SEQUENCE $tp, the following are OPTIONAL:" - foreach {subtypedesc req} [lindex $td 4] { - if {!$req} { - set r [ref $subtypedesc] - .selector.l insert end [list $tp $r] - } - } - wm withdraw .insertor - wm deiconify .selector - raise .selector - } - default { - if {$t=="SEQUENCE OF"} { - set text "Size of SEQUENCE OF $tp:" - } else { - set text "New value of $tp:" - } - set tag(insertor) $tp - .insertor.l configure -text $text - .insertor.e delete 0 end - .insertor.e insert 0 $val - wm withdraw .selector - wm deiconify .insertor - raise .insertor - } - } -} - -proc inspress {} { - global tag - newenc $tag(insertor) [.insertor.e get] 0 -} - -proc fillcomposer {} { - global table pdu - set fraction 0.0 - if [winfo exists .composer.l] { - set fraction [lindex [.composer.l yview] 0] - .composer.l delete 0 end - } else { - frame .composer - pack .composer -fill both -expand 1 - listbox .composer.l -yscrollcommand ".composer.v set" - scrollbar .composer.v -orient vertical -command ".composer.l yview" - pack .composer.v -fill y -side right - pack .composer.l -expand yes -fill both - bind .composer.l {comppress %y} - toplevel .selector - listbox .selector.l -yscrollcommand ".selector.v set" - scrollbar .selector.v -orient vertical -command ".selector.l yview" - pack .selector.v -fill y -side right - pack .selector.l -expand yes -fill both - bind .selector.l {selpress %y} - wm protocol .selector WM_DELETE_WINDOW {wm withdraw .selector} - wm title .selector "Snacc ASN.1 data item selection" - toplevel .insertor - label .insertor.l - entry .insertor.e - pack .insertor.l -fill x -expand yes -side top - pack .insertor.e -fill x -expand yes -side bottom - bind .insertor.e {inspress} - wm protocol .insertor WM_DELETE_WINDOW {wm withdraw .insertor} - wm title .insertor "Snacc ASN.1 data item modification" - } - wm withdraw .selector - wm withdraw .insertor - set null [open "/dev/null" w] - $table encode $null $pdu "encodevalcompose $null" - close $null - .composer.l yview moveto $fraction - wm deiconify . - raise . -} - -proc decodetype {tp val} { - complete tp - if {$val==-1} { - set l [expr [llength $tp]-1] - set final [lindex $tp $l] - set addto [lrange $tp 0 [expr $l-1]] - global table asnenc - set td [$table type -followref $addto] - if {[lindex $td 1]=="SEQUENCE"} { - if [catch {set asnenc($addto)}] { - set asnenc($addto) "" - } - foreach {elem req} [lindex $td 4] { - if {[lindex $elem 0]==$final} { - if {!$req} { - lappend asnenc($addto) $final - } - break - } - } - } else { - set asnenc($addto) $final - } - } -} - -proc decodeval {chan tp val} { - decodetype $tp -1 - global asnenc table - complete tp - set typ [$table type -followref $tp] - if {[lindex $typ 1]=="BIT STRING"} { - set namespecs [lindex $typ 3] - set bitno 0 - foreach bit [split $val ""] { - set idx [lsearch $namespecs "$bitno *"] - if {$idx>=0 && $bit} { - lappend val "[lindex {! {}} $bit][lindex [lindex $namespecs $idx] 1]($bitno)" - } - incr bitno - } - } elseif {[lindex $typ 1]=="ENUMERATED"} { - set namespecs [lindex $typ 3] - set idx [lsearch $namespecs "$val *"] - if {$idx>=0} { - lappend val "[lindex [lindex $namespecs $idx] 1]" - } - } - set asnenc($tp) $val -} - -proc encodevalcompose {chan tp} { - global asnenc - complete tp - if [catch {set val $asnenc($tp)}] { - set val {} - } - .composer.l insert end [list $tp $val] - return $val -} - -proc encodeval {chan tp val} { - global table - set prefix - - set val [subst -nobackslashes $val] - set typ [$table type -followref $tp] - if {[lindex $typ 1]=="OCTET STRING"} { - set fromto [lindex $typ 2] - set from [lindex $fromto 0] - set to [lindex $fromto 1] - if {$to==""} { - set to $from - } - regsub -all {[^\\]} $val {} slashes - set len [expr [string length $val] - [string length $slashes] * 3] - if {$from!={} && $from>$len} { - set val [format "%$prefix[expr $from]s" $val] - } elseif {$to!={} && $to<$len} { - err [list encodeval: value $val for $tp >$to] - while {$to<$len} { - set last [string last \\ $val] - if {$last==-1 || $last<[string length $val]-4} { - set val [string range $val 0 [expr [string length $val] - 2]] - } else { - set val [string range $val 0 [expr $last - 1]] - } - regsub -all {[^\\]} $val {} slashes - set len [expr [string length $val] - [string length $slashes] * 3] - } - } - } elseif {[lindex $typ 1]=="BIT STRING"} { - set namespecs [lindex $typ 3] - if {[regexp {^[01]+$} [lindex $val 0]]} { - set val [split [lindex $val 0] ""] - } else { - set names $val - set val {} - foreach name $names { - if {[regsub {([a-zA-Z_][a-zA-Z0-9_]*)?\(([0-9]+)\)} $name {\2} bitno]!=1} { - set idx [lsearch -regexp $namespecs "^\[0-9\]+ $name$"] - if {$idx<0} { - err "Bit $name of $tp not in $namespecs" - continue - } - set bitno [lindex [lindex $namespecs $idx] 0] - } - while {[llength $val]<=$bitno} { - lappend val 0 - } - set val [lreplace $val $bitno $bitno 1] - } - } - proc namespeccmp {a b} {return [expr [lindex $a 0] - [lindex $b 0]]} - set sorted [lsort -command namespeccmp -decreasing $namespecs] - set bitno [lindex [lindex $sorted 0] 0] - while {[llength $val]<=$bitno} { - lappend val 0 - } - set val [join $val ""] - } elseif {[lindex $typ 1]=="ENUMERATED"} { - set namespecs [lindex $typ 3] - if {![regexp {^[0-9]*$} [lindex $val 0]]} { - set idx [lsearch -regexp $namespecs "^\[0-9\]+ $val$"] - if {$idx<0} { - err "Named value $val of $tp not in $namespecs" - } else { - set val [lindex [lindex $namespecs $idx] 0] - } - } - } - return $val -} - -proc encodeasnenc {chan tp} { - global asnenc pdu - complete tp - if [catch {set val $asnenc($tp)}] { - set val {} - } - return [encodeval $chan $tp $val] -} - -wm title . "Snacc ASN.1 message editor" -wm geometry . 400x300 -frame .mbar -relief raised -pack .mbar -side top -fill x - -menubutton .mbar.file -text Message -menu .mbar.file.menu -pack .mbar.file -side left - -menu .mbar.file.menu -.mbar.file.menu add command -label "Open ..." -command {openfile} -.mbar.file.menu add command -label "Save As ..." -command {savefile} -.mbar.file.menu add command -label "Quit" -command {quit} -wm protocol . WM_DELETE_WINDOW {quit} - -proc readfile {fn} { - if {$fn==""} return - global table pdu asnenc - catch {unset asnenc} - set chan [open $fn r] - fconfigure $chan -translation binary - set bytes [$table decode $chan $pdu "decodeval $chan" decodetype] - close $chan - fillcomposer -} - -proc openfile {} { - readfile [tk_getOpenFile -defaultextension .ber -filetypes {{{ASN.1 data} {.ber .bin .out .tt}} {{All files} {.*}}}] -} - -proc savefile {} { - set fn [tk_getSaveFile -defaultextension .ber -filetypes {{{ASN.1 data} {.ber .bin .out .tt}} {{All files} {.*}}}] - if {$fn==""} return - global table pdu - set chan [open $fn w] - $table encode $chan $pdu "encodeasnenc $chan" - close $chan -} - -proc quit {} { - global done - set done 1 -} - -set asnfile [lindex $argv 0] -if {$asnfile==""} { - puts stderr "Usage: $argv0 ??" - puts stderr "" - puts stderr "This program is a simple editor for ASN.1 messages" - puts stderr "encoded using the Basic Encoding Rules (BER). It requires" - puts stderr "the grammar specification, in binary format as generated" - puts stderr "by \"snacc -T\", as the initial argument on the command line." - puts stderr "" - puts stderr "The purpose of this program is to demonstrate the usage of" - puts stderr "the new Tcl/Tk command \"asn\". Have a look at the Tcl/Tk" - puts stderr "script \"$argv0\"!" - exit 0 -} - -set table [asn $asnfile] - -foreach type [$table types] { - if {[lindex [$table type $type] 0]=="$type pdu"} { - set pdu $type - break - } -} - -readfile [lindex $argv 1] -fillcomposer - -update idletasks -vwait done - -$table close -exit - diff --git a/SecuritySNACCRuntime/tcl-asn/makefile b/SecuritySNACCRuntime/tcl-asn/makefile deleted file mode 100644 index e7cf3cef..00000000 --- a/SecuritySNACCRuntime/tcl-asn/makefile +++ /dev/null @@ -1,90 +0,0 @@ -# -# Makefile for the asnwish -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-asn/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:10 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:54 aram -# Originals from SMIME Free Library. -# -# Revision 1.3 1997/10/10 13:43:18 wan -# Corrected bug in generic table decoder wrt. indefinite length elements -# Corrected compiler access to freed memory (bug reported by Markku Savela) -# Broke asnwish.c into two pieces so that one can build ones on wish -# Added beredit tool (based on asnwish, allowes to edit BER messages) -# -# Revision 1.2 1997/09/03 12:13:13 wan -# Reworked asnwish to neither strip nor encapsulate; instead, -# buffer reads during decoding incrementally Tcl_Read the channel. -# -# Revision 1.1 1997/08/27 15:55:51 wan -# Added generic table decoding, debug routines, berdecode, and asnwish. -# -# - -include ../makehead - -TOP = .. - -SNACC = $(TOP)/compiler/snacc - -ASN1_SRC_DIR = $(TOP)/asn1specs -C_LIB = $(TOP)/c-lib -ASN1INC = $(C_LIB)/inc -ASN1LIB = $(C_LIB)/libasn1ctbl.a - -CPPFLAGS += -I$(TOP) -I$(ASN1INC) $(CPPFLAGS.TCL) $(CPPFLAGS.X11) - -OFILES = tclasn.o asnwish.o - -DISTFILES = makefile tclasn.c asnwish.c README beredit - -LDFLAGS += $(LDFLAGS.X11) -LDLIBS += $(ASN1LIB) $(TCLLIBS) $(LDLIBS.X11pre) -lX11 $(LDLIBS.X11extra) $(LIBS) - -WISH = asnwish - -#------------------------------------------------------------------------------- - -all:: $(WISH) - -$(WISH): $(OFILES) $(ASN1LIB) - $(REASON) - $(CC) $(LDFLAGS) -o $(WISH) $(OFILES) $(LDLIBS) - -$(ASN1LIB):: - cd $(@D) && $(MAKE) tbl-lib - -# if $(ASN1INC)/asn_useful.h doesn't exist, someone probably called `make clean` in $(C++_LIB). -$(ASN1INC)/asn-useful.h: - $(MAKE) $(ASN1LIB) - -$(SNACC):: - cd $(@D) && $(MAKE) $(@F) - -clean:: - $(RM) $(ASN1HFILES) $(ASN1CFILES) - $(RM) $(OFILES) - -clobber:: - $(RM) $(WISH) - -install-sh: - ln $(TOP)/install-sh $@ - -$(bindir): - $(TOP)/mkinstalldirs $@ - -install:: $(WISH) install-sh $(bindir) - -init-depend:: - test -f dependencies || touch dependencies - -install:: - $(INSTALL_PROGRAM) $(WISH) $(bindir)/ - $(INSTALL_PROGRAM) beredit $(bindir)/ - $(INSTALL_PROGRAM) tclasn.o $(libdir)/ - -include ../maketail diff --git a/SecuritySNACCRuntime/tcl-asn/tclasn.c b/SecuritySNACCRuntime/tcl-asn/tclasn.c deleted file mode 100644 index 86ffa762..00000000 --- a/SecuritySNACCRuntime/tcl-asn/tclasn.c +++ /dev/null @@ -1,1185 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -/* - * Wishes: - * Allow spec of PDU to decode in asn decode - * (Prefixing tp during decoding with PDU is not necessary) - * - * - */ - -#include "tk.h" -#include "tbl-gen.h" -#include "tbl-dbg.h" -#include "sbuf.h" -#include "exp-buf.h" -#include - -typedef struct ChannelBuf { - Tcl_Channel chan; - int readError; -} ChannelBuf; - -static void PutChannelBufInGenBuf _ANSI_ARGS_((Tcl_Channel chan, GenBuf* gb)); - -static unsigned char -ChanGetByte (cb) - ChannelBuf* cb; -{ - unsigned char result = 0; - if (!cb->readError) - if (Tcl_Read(cb->chan,&result,1)!=1) - cb->readError = TRUE; - return result; -} - -static char* -ChanGetSeg (cb, len) - ChannelBuf* cb; - unsigned long* len; -{ - static char result[100]; - if (cb->readError) { - *len = 0; - return NULL; - } - if (*len>sizeof(result)) - *len = sizeof(result); - *len = Tcl_Read(cb->chan,result,*len); - if (*len<0) { - cb->readError = TRUE; - *len = 0; - return NULL; - } - return result; -} - -static unsigned long -ChanCopy (dst, cb, len) - char* dst; - ChannelBuf* cb; - unsigned long len; -{ - unsigned long result; - if (cb->readError) { - return 0; - } - result = Tcl_Read(cb->chan,dst,len); - if (result!=len) { - cb->readError = TRUE; - if (result<0) - result = 0; - } - return result; -} - -static unsigned long -ChanPeekCopy (dst, cb, len) - char* dst; - ChannelBuf* cb; - unsigned long len; -{ - unsigned long result, result2; - if (cb->readError) { - return 0; - } - result = ChanCopy(dst,cb,len); - result2 = Tcl_Ungets(cb->chan,dst,result,0); - if (result2!=result) { - cb->readError = TRUE; - } - return result; -} - -static unsigned char -ChanPeekByte (cb) - ChannelBuf* cb; -{ - unsigned char result = 0; - ChanPeekCopy(&result,cb,1); - return result; -} - -static int -ChanReadError (cb) - ChannelBuf* cb; -{ - return cb->readError; -} - -static void -PutChannelBufInGenBuf (cb, gb) - ChannelBuf* cb; - GenBuf* gb; -{ - gb->bufInfo = cb; - cb->readError = FALSE; - gb->getByte = (BufGetByteFcn) ChanGetByte; - gb->getSeg = (BufGetSegFcn) ChanGetSeg; - gb->copy = (BufCopyFcn) ChanCopy; - gb->peekByte = (BufPeekByteFcn) ChanPeekByte; - gb->peekCopy = (BufPeekCopyFcn) ChanPeekCopy; - gb->readError = (BufReadErrorFcn) ChanReadError; -} - -#if TCL_MAJORVERSION<8 -#define Tcl_GetStringResult(interp) (interp->result) -#endif - -#define max(a,b) ((a)>(b)?(a):(b)) -#define min(a,b) ((a)<(b)?(a):(b)) - -extern int matherr(); -int *tclDummyMathPtr = (int *) matherr; - -Tcl_Interp* interpG; -int interpResultG; -char* tblvalcmdG; -char* tbltypecmdG; - -void myAsn1ErrorHandler (str, severity) - char* str; - int severity; -{ - Tcl_AppendResult(interpG,"ASN.1 error: ",str,NULL); - interpResultG = TCL_ERROR; -} - -int equal (char* s1, char* s2) -{ - return s1==s2 || (s1 && s2 && !strcmp(s1,s2)); -} - -int contained (char* in, char* el) -{ - int argc; - char** argv; - if (Tcl_SplitList(interpG,in,&argc,&argv)!=TCL_OK) - return FALSE; - while (argc--) - if (equal(*argv++,el)) - return TRUE; - return FALSE; -} - -static struct TypePath - { - char* typename; - char* fieldname; - int index; - } tp[20]; -static int ntp; - -int TblDbgCallProc (cmdstart, value) - char* cmdstart; - char* value; -{ - int i; - Tcl_DString cmd, type; - if (ntp<=1 || !cmdstart) - return TCL_OK; - Tcl_DStringInit(&cmd); - Tcl_DStringAppend(&cmd,cmdstart,-1); - Tcl_DStringInit(&type); - for (i=1; ibitLen = strlen(iresult); - ((AsnBits*)v)->bits = Asn1Alloc(((AsnBits*)v)->bitLen?(((AsnBits*)v)->bitLen-1)/8+1:0); - for (i=0; iresult[i]; i++) - if (iresult[i]!='0') - SetAsnBit((AsnBits*)v,i); - break; - case TBL_OCTETSTRING: - case TBL_OID: - ((AsnOcts*)v)->octs = Asn1Alloc(strlen(iresult)); /* Might be too much, but don't care */ - for (i=((AsnOcts*)v)->octetLen=0; iresult[i]; i++,((AsnOcts*)v)->octetLen++) - if (iresult[i]=='\\') - { - char* skipto; - strncpy(fmt,iresult+i+1,3); - fmt[3] = '\0'; - ((AsnOcts*)v)->octs[((AsnOcts*)v)->octetLen] = strtol(fmt,&skipto,8); - i += skipto-fmt; - } - else - ((AsnOcts*)v)->octs[((AsnOcts*)v)->octetLen] = iresult[i]; - break; - case SPECIALID_STR: - *(char**)v = Asn1Alloc(strlen(iresult)+1); - strcpy(*(char**)v,iresult); - break; - default: - break; - } - Tcl_ResetResult(interpG); - return TCL_OK; -} - -int -TblEncType PARAMS ((type, b, implicit, bytesEncoded), - TBLType *type _AND_ - BUF_TYPE b _AND_ - int implicit _AND_ - unsigned long int *bytesEncoded) -{ - int result = TCL_OK; - unsigned long int tmpBytesEncoded = 0; - unsigned int currElmt; - TBLType *elmt; - TBLType* choice; - int implicitRef; - void *tmp; - AsnBits optavail; - char* elmtname; - union { - AsnBool bo; - AsnInt in; - AsnBits bi; - AsnOcts oc; - AsnReal re; - } unival; - - if (type->typeId==TBL_TYPEREF && !tp[ntp-1].typename) - tp[ntp-1].typename = type->content->a.typeRef->typeDefPtr->typeName.octs; - if (type->typeId!=TBL_TYPEREF && !tp[ntp-1].typename) - tp[ntp-1].typename = TIN[type->typeId]; - if (!tp[ntp-1].fieldname) - tp[ntp-1].fieldname = type->fieldName.octs; - - switch (type->typeId) - { - case TBL_TYPEREF: - - /* - * carry over implicit ref if goes - * through typeref with no tags - */ - implicitRef = type->content->a.typeRef->implicit || - (implicit && - ((type->tagList == NULL) || LIST_EMPTY (type->tagList))); - - result = TblEncType (type->content->a.typeRef->typeDefPtr->type, b, implicitRef, - &tmpBytesEncoded); - if (result!=TCL_OK) - return result; - break; - - case TBL_SEQUENCE: - case TBL_SET: - /* rvs though list value and list type def */ - currElmt = LIST_COUNT (type->content->a.elmts); - tmp = CURR_LIST_NODE (type->content->a.elmts); - result = TblEncAsk(SPECIALID_STR,&elmtname,tbltypecmdG); - if (result!=TCL_OK) - return result; - FOR_EACH_LIST_ELMT_RVS (elmt, type->content->a.elmts) - { - if (!elmt->optional - || contained(elmtname,elmt->fieldName.octs) - || !elmt->fieldName.octetLen && - (elmt->typeId==TBL_TYPEREF && contained(elmtname, - elmt->content->a.typeRef->typeDefPtr->typeName.octs) - || elmt->typeId!=TBL_TYPEREF && contained(elmtname, - TIN[elmt->typeId]))) - { - tp[ntp].typename = tp[ntp].fieldname = NULL; - tp[ntp].index = 0; - ntp++; - result = TblEncType (elmt, b, FALSE, &tmpBytesEncoded); - if (result!=TCL_OK) - { - Asn1Free(optavail.bits); - return result; - } - ntp--; - } - } - Asn1Free(elmtname); - /* restore list curr in case recursive type */ - SET_CURR_LIST_NODE (type->content->a.elmts, tmp); - break; - - case TBL_SEQUENCEOF: - case TBL_SETOF: - result = TblEncAsk(TBL_INTEGER,&tp[ntp-1].index,tbltypecmdG); - if (result!=TCL_OK) - return result; - elmt = FIRST_LIST_ELMT (type->content->a.elmts); - for (;tp[ntp-1].index>=1;tp[ntp-1].index--) - { - tp[ntp].typename = tp[ntp].fieldname = NULL; - tp[ntp].index = 0; - ntp++; - result = TblEncType (elmt, b, FALSE, &tmpBytesEncoded); - if (result!=TCL_OK) - return result; - ntp--; - } - break; - - case TBL_CHOICE: - result = TblEncAsk(SPECIALID_STR,&elmtname,tbltypecmdG); - if (result!=TCL_OK) - return result; - tmp = CURR_LIST_NODE (type->content->a.elmts); - choice = NULL; - FOR_EACH_LIST_ELMT(elmt, type->content->a.elmts) - if (equal(elmtname,elmt->fieldName.octs)) - { - choice = elmt; - break; - } - if (!choice) - FOR_EACH_LIST_ELMT(elmt, type->content->a.elmts) - if (!elmt->fieldName.octetLen) - { - if (elmt->typeId==TBL_TYPEREF) - { - if (equal(elmtname,elmt->content->a.typeRef->typeDefPtr->typeName.octs)) - { - choice = elmt; - break; - } - } - else if (equal(elmtname,TIN[elmt->typeId])) - { - choice = elmt; - break; - } - } - Asn1Free(elmtname); - SET_CURR_LIST_NODE (type->content->a.elmts, tmp); - if (choice) - { - tp[ntp].typename = tp[ntp].fieldname = NULL; - tp[ntp].index = 0; - ntp++; - result = TblEncType(choice,b,FALSE,&tmpBytesEncoded); - if (result!=TCL_OK) - return result; - ntp--; - } - break; - - case TBL_BOOLEAN: - result = TblEncAsk(type->typeId,&unival,tblvalcmdG); - if (result!=TCL_OK) - return result; - tmpBytesEncoded += BEncAsnBoolContent (b, &unival.bo); - if (interpResultG!=TCL_OK) - return interpResultG; - break; - - case TBL_INTEGER: - case TBL_ENUMERATED: - result = TblEncAsk(type->typeId,&unival,tblvalcmdG); - if (result!=TCL_OK) - return result; - tmpBytesEncoded += BEncAsnIntContent (b, &unival.in); - if (interpResultG!=TCL_OK) - return interpResultG; - break; - - case TBL_BITSTRING: - result = TblEncAsk(type->typeId,&unival,tblvalcmdG); - if (result!=TCL_OK) - return result; - tmpBytesEncoded += BEncAsnBitsContent (b, &unival.bi); - Asn1Free(unival.bi.bits); - if (interpResultG!=TCL_OK) - return interpResultG; - break; - - case TBL_OCTETSTRING: - result = TblEncAsk(type->typeId,&unival,tblvalcmdG); - if (result!=TCL_OK) - return result; - tmpBytesEncoded += BEncAsnOctsContent (b, &unival.oc); - Asn1Free(unival.oc.octs); - if (interpResultG!=TCL_OK) - return interpResultG; - break; - - case TBL_NULL: - tmpBytesEncoded += BEncAsnNullContent (b, NULL); - if (interpResultG!=TCL_OK) - return interpResultG; - break; - - case TBL_OID: - result = TblEncAsk(type->typeId,&unival,tblvalcmdG); - if (result!=TCL_OK) - return result; - tmpBytesEncoded += BEncAsnOidContent (b, &unival.oc); - Asn1Free(unival.oc.octs); - if (interpResultG!=TCL_OK) - return interpResultG; - break; - - case TBL_REAL: - result = TblEncAsk(type->typeId,&unival,tblvalcmdG); - if (result!=TCL_OK) - return result; - tmpBytesEncoded += BEncAsnRealContent (b, &unival.re); - if (interpResultG!=TCL_OK) - return interpResultG; - break; - - default: - Tcl_AppendResult(interpG,"strange type",NULL); - return TCL_ERROR; - - } - - TblEncodeTagsAndLens (type, b, implicit, &tmpBytesEncoded); - (*bytesEncoded) += tmpBytesEncoded; - - return TCL_OK; - -} - -int -TblEnc PARAMS (( type, b), - TBLType *type _AND_ - BUF_TYPE b) -{ - unsigned long int bytesEncoded = 0; - int result; - ntp = 1; - result = TblEncType (type, b, FALSE, &bytesEncoded); - if (result==TCL_OK && BufWriteError (b)) - { - Tcl_AppendResult(interpG,"error writing buffer",NULL); - result = TCL_ERROR; - } - interpResultG = result; - if (result==TCL_OK) - return bytesEncoded; - else - return -1; -} - - -void -TblDbgValue (type, val, pvalue) - TBLType* type; - AVal* val; - Tcl_DString* pvalue; -{ - char fmt[20]; - switch (type->typeId) - { - case TBL_BOOLEAN: - Tcl_DStringAppend(pvalue,*(AsnBool*)val? "TRUE" :"FALSE", -1); - break; - case TBL_INTEGER: - case TBL_ENUMERATED: - sprintf(fmt,"%d",*(AsnInt*)val); - Tcl_DStringAppend(pvalue,fmt, -1); - break; - case TBL_BITSTRING: - { - AsnBits* v = (AsnBits*)val; - unsigned long i; - for (i=0; ibitLen; i++) - Tcl_DStringAppend(pvalue,GetAsnBit(v,i)?"1":"0", -1); - } - break; - case TBL_OCTETSTRING: - case TBL_OID: - { - AsnOcts* v = (AsnOcts*)val; - unsigned long i; - for (i=0; ioctetLen; i++) - if (v->octs[i]=='\\' || !isprint(v->octs[i])) - { - sprintf(fmt,"\\%03o",v->octs[i]); - Tcl_DStringAppend(pvalue,fmt,-1); - } - else - Tcl_DStringAppend(pvalue,v->octs+i,1); - } - break; - case TBL_NULL: - Tcl_DStringAppend(pvalue,"NULL", -1); - break; - case TBL_REAL: - sprintf(fmt,"%G",*(AsnReal*)val); - Tcl_DStringAppend(pvalue,fmt, -1); - break; - default: - break; - } -} - - -int -TblDbgType PARAMS ((type, val, begin), - TBLType* type _AND_ - AVal* val _AND_ - int begin) -{ - int result = TCL_OK; - if (begin) - { - if (type->typeId==TBL_TYPEREF && !tp[ntp-1].typename) - tp[ntp-1].typename = type->content->a.typeRef->typeDefPtr->typeName.octs; - if (type->typeId!=TBL_TYPEREF && !tp[ntp-1].typename) - tp[ntp-1].typename = TIN[type->typeId]; - if (!tp[ntp-1].fieldname) - tp[ntp-1].fieldname = type->fieldName.octs; - if (type->typeId >= TBL_SEQUENCE && type->typeId <= TBL_CHOICE) - { - result = TblDbgCallProc(tbltypecmdG,"1"); - if (type->typeId == TBL_SEQUENCEOF || type->typeId == TBL_SETOF) - tp[ntp-1].index = 1; - tp[ntp].typename = tp[ntp].fieldname = NULL; - tp[ntp].index = 0; - ntp++; - } - } - else if (type->typeId!=TBL_TYPEREF) - { - if (type->typeId < TBL_SEQUENCE) - { - Tcl_DString value; - Tcl_DStringInit(&value); - TblDbgValue(type,val,&value); - result = TblDbgCallProc(tblvalcmdG,Tcl_DStringValue(&value)); - Tcl_DStringFree(&value); - } else { - ntp--; - if (type->typeId == TBL_SEQUENCEOF || type->typeId == TBL_SETOF) - tp[ntp-1].index = 0; - result = TblDbgCallProc(tbltypecmdG,"-1"); - } - tp[ntp-1].typename = tp[ntp-1].fieldname = NULL; - if (ntp>=2) - if (tp[ntp-2].index) - tp[ntp-2].index++; - } - return result; -} - -TBLType* TblFindType (type, argv, followref, ptr, ptnnl) - TBLType* type; - char** argv; - int followref; - TBLRange** ptr; - TBLNamedNumberList** ptnnl; -{ - TBLType* elmt; - TBLType* result; - void *tmp; - if (!*argv) - { - if (ptr && !*ptr && type->constraint) - *ptr = type->constraint; - if (ptnnl && !*ptnnl && type->values) - *ptnnl = type->values; - if (!followref || type->typeId!=TBL_TYPEREF) - return type; - } - switch (type->typeId) - { - case TBL_TYPEREF: - return TblFindType(type->content->a.typeRef->typeDefPtr->type,argv,followref,ptr,ptnnl); - case TBL_CHOICE: - case TBL_SET: - case TBL_SEQUENCE: - tmp = CURR_LIST_NODE (type->content->a.elmts); - result = NULL; - FOR_EACH_LIST_ELMT(elmt,type->content->a.elmts) - if (equal(*argv,elmt->fieldName.octs)) - { - result = TblFindType(elmt,argv+1,followref,ptr,ptnnl); - break; - } - if (!result) { - FOR_EACH_LIST_ELMT(elmt,type->content->a.elmts) - if (!elmt->fieldName.octetLen) - { - if (elmt->typeId==TBL_TYPEREF) - { - if (equal(*argv,elmt->content->a.typeRef->typeDefPtr->typeName.octs)) { - result = TblFindType(elmt->content->a.typeRef->typeDefPtr->type,argv+1,followref,ptr,ptnnl); - break; - } - } - else if (equal(*argv,TIN[elmt->typeId])) { - result = TblFindType(elmt,argv+1,followref,ptr,ptnnl); - break; - } - } - } - SET_CURR_LIST_NODE (type->content->a.elmts, tmp); - return result; - case TBL_SETOF: - case TBL_SEQUENCEOF: - if (**argv>='0'&&**argv<='9') - argv++; - return TblFindType(FIRST_LIST_ELMT(type->content->a.elmts),argv,followref,ptr,ptnnl); - default: - return NULL; - } -} - - -TBLType* TblTypeOfPath (interp, tbl, path, followref, ptd, ptr, ptnnl) - TBL* tbl; - char* path; - int followref; - TBLTypeDef** ptd; - TBLRange** ptr; - TBLNamedNumberList** ptnnl; -{ - TBLModule* tm = NULL; - TBLTypeDef* td; - TBLType* type = NULL; - int argc; - char** argv; - if (Tcl_SplitList(interp,path,&argc,&argv)!=TCL_OK) - return NULL; - if (argc>=2 && (tm = TblFindModule(tbl,argv[0]))) - { - argv++; - argc--; - } - if (argc<1 || !(td=TblFindTypeDef(tbl,tm?tm->name.octs:NULL,argv[0],&tm)) - || !(type=TblFindType(td->type,argv+1,followref,ptr,ptnnl))) - Tcl_AppendResult(interp,"wrong typepath \"",path, - "\", should be ?module? typedef ?subtype? ...", NULL); - else if (ptd) - *ptd = td; - Tcl_Free((char*)argv); - return type; -} - -int dowrite (Tcl_Channel chan, char* buffer, int n) - { - int written = 0; - int onewrite; - while (written EOF */ - break; - haveread += oneread; - } - return haveread; - } - - -int TblCmdDecode (interp, tbl, chan, path, valcmd, typecmd) - Tcl_Interp* interp; - TBL* tbl; - Tcl_Channel chan; - char* path; - char* valcmd; - char* typecmd; -{ - int result; - ChannelBuf cb; - GenBuf gb; - unsigned long bytesDecoded; - char test; - - TBLType* type = TblTypeOfPath (interp, tbl, path, FALSE, NULL, NULL, NULL); - if (!type) - { - Tcl_AppendResult(interp,"wrong typepath \"",path,"\"",NULL); - return TCL_ERROR; - } - - result = Tcl_Read(chan,&test,1); - if (result<0) { - Tcl_AppendResult(interp,"read failed",NULL); - return TCL_ERROR; - } - if (result==0) { - Tcl_AppendResult(interp,"0",NULL); - return TCL_OK; - } - result = Tcl_Ungets(chan,&test,1,0); - if (result!=1) { - Tcl_AppendResult(interp,"ungets failed",NULL); - return TCL_ERROR; - } - - cb.chan = chan; - PutChannelBufInGenBuf(&cb,&gb); - - interpG = interp; - interpResultG = TCL_OK; - tblvalcmdG = valcmd; - tbltypecmdG = typecmd; - ntp = 1; - - result = TdeDecodeSpecific(tbl,&gb,type,&bytesDecoded,TblDbgType,NULL,NULL); - if (interpResultG==TCL_OK) - { - if (!result) - Asn1Error("TdeDecodeSpecific failed"); - } - if (interpResultG==TCL_OK) - { - char buffer[11]; - sprintf(buffer,"%u",(int)bytesDecoded); - Tcl_SetResult(interp,buffer,TCL_VOLATILE); - } - return interpResultG; -} - -int TblRealType (type) - TBLType* type; -{ - if (type->typeId==TBL_TYPEREF) - return TblRealType(type->content->a.typeRef->typeDefPtr->type); - else - return type->typeId; -} - -TBLModule* TblModuleOfTypeDef (tbl, td) - TBL* tbl; - TBLTypeDef* td; -{ - TBLModule* tm; - TBLTypeDef* td2; - void *tmp1; - void *tmp2; - - /* look in all modules and return typedef with given id */ - tmp1 = CURR_LIST_NODE (tbl->modules); - FOR_EACH_LIST_ELMT (tm, tbl->modules) - { - tmp2 = CURR_LIST_NODE (tm->typeDefs); - FOR_EACH_LIST_ELMT (td2, tm->typeDefs) - if (td2==td) - { - SET_CURR_LIST_NODE (tm->typeDefs, tmp2); - SET_CURR_LIST_NODE (tbl->modules, tmp1); - return tm; - } - SET_CURR_LIST_NODE (tm->typeDefs, tmp2); - } - SET_CURR_LIST_NODE (tbl->modules, tmp1); - return NULL; -} - -void TblDescType (ps, tbl, tm, td, type, tr, tnnl) - Tcl_DString* ps; - TBL* tbl; - TBLModule* tm; - TBLTypeDef* td; - TBLType* type; - TBLRange* tr; - TBLNamedNumberList* tnnl; -{ - if (td) { - Tcl_DStringStartSublist(ps); - Tcl_DStringAppendElement(ps,tm->name.octs); - Tcl_DStringAppendElement(ps,td->typeName.octs); - Tcl_DStringAppendElement(ps,td->isPdu?"pdu":"sub"); - Tcl_DStringEndSublist(ps); - } else { - Tcl_DStringAppendElement(ps,type->fieldName.octs); - } - Tcl_DStringAppendElement(ps,TIN[type->typeId]); - Tcl_DStringStartSublist(ps); - if (!tr) - tr = type->constraint; - if (tr) { - char fmt[20]; - sprintf(fmt,"%d",tr->from); - Tcl_DStringAppendElement(ps,fmt); - if (tr->to!=tr->from) { - sprintf(fmt,"%d",tr->to); - Tcl_DStringAppendElement(ps,fmt); - } - } - Tcl_DStringEndSublist(ps); - Tcl_DStringStartSublist(ps); - if (!tnnl) - tnnl = type->values; - if (tnnl) { - TBLNamedNumber* tnn; - FOR_EACH_LIST_ELMT(tnn,tnnl) - { - char fmt[20]; - Tcl_DStringStartSublist(ps); - sprintf(fmt,"%d",tnn->value); - Tcl_DStringAppendElement(ps,fmt); - if (tnn->name.octetLen) - Tcl_DStringAppendElement(ps,tnn->name.octs); - Tcl_DStringEndSublist(ps); - } - } - Tcl_DStringEndSublist(ps); - if (type->content) - switch (type->content->choiceId) { - case TBLTYPECONTENT_ELMTS: - { - TBLType* elmt; - void* tmp = CURR_LIST_NODE (type->content->a.elmts); - Tcl_DStringStartSublist(ps); - FOR_EACH_LIST_ELMT(elmt,type->content->a.elmts) - { - Tcl_DStringStartSublist(ps); - TblDescType(ps,tbl,tm,NULL,elmt,NULL,NULL); - Tcl_DStringEndSublist(ps); - Tcl_DStringAppendElement(ps,elmt->optional?"0":"1"); - } - Tcl_DStringEndSublist(ps); - SET_CURR_LIST_NODE (type->content->a.elmts, tmp); - } - break; - case TBLTYPECONTENT_TYPEREF: - { - TBLTypeDef* td = type->content->a.typeRef->typeDefPtr; - Tcl_DStringStartSublist(ps); - Tcl_DStringAppendElement(ps,TblModuleOfTypeDef(tbl,td)->name.octs); - Tcl_DStringAppendElement(ps,td->typeName.octs); - Tcl_DStringEndSublist(ps); - } - break; - default: - break; - } -} - -typedef struct TblCmdData { - char name[20]; - TBL* tbl; - } TblCmdData; - -int TblCmd (tcd, interp, argc, argv) - TblCmdData* tcd; - Tcl_Interp* interp; - int argc; - char* argv[]; -{ - int c; - size_t l; - if (argc>=2) { - c = *argv[1]; - l = strlen(argv[1]); - - if (argc==2 && !strncmp(argv[1],"close",l)) { - Tcl_DeleteCommand(interp,tcd->name); - return TCL_OK; - } else if (!strncmp(argv[1],"decode",l) && (argc>=5 && argc<=6)) { - int mode; - Tcl_Channel chan = Tcl_GetChannel(interp,argv[2],&mode); - if (!chan) - return TCL_ERROR; - if (!(mode & TCL_READABLE)) { - Tcl_AppendResult(interp, "channel \"", argv[2], - "\" wasn't opened for reading", NULL); - return TCL_ERROR; - } - return TblCmdDecode(interp,tcd->tbl,chan,argv[3],argv[4],argv[5]); - } else if (!strncmp(argv[1],"encode",l) && (argc>=5 && argc<=6)) { - int mode; - Tcl_Channel chan = Tcl_GetChannel(interp,argv[2],&mode); - if (!chan) - return TCL_ERROR; - if (!(mode & TCL_WRITABLE)) { - Tcl_AppendResult(interp, "channel \"", argv[2], - "\" wasn't opened for writing", NULL); - return TCL_ERROR; - } - return TblCmdEncode(interp,tcd->tbl,chan,argv[3],argv[4],argv[5]); - } else if (argc==2 && !strncmp(argv[1],"modules",l)) { - TBLModule *tm; - FOR_EACH_LIST_ELMT (tm, tcd->tbl->modules) - Tcl_AppendElement(interp,tm->name.octs); - return TCL_OK; - } else if (!strncmp(argv[1],"type",l) && (argc==3 - || argc==4 && !strncmp(argv[2],"-followref",max(strlen(argv[2]),2)))) { - TBLTypeDef* td; - TBLRange* tr = NULL; - TBLNamedNumberList* tnnl = NULL; - TBLType* type = TblTypeOfPath(interp,tcd->tbl,argv[argc-1],argc==4, - &td,&tr,&tnnl); - if (!type) - return TCL_ERROR; - else - { - Tcl_DString ds; - Tcl_DStringInit(&ds); - TblDescType(&ds,tcd->tbl,TblModuleOfTypeDef(tcd->tbl,td), - type==td->type?td:NULL,type,tr,tnnl); - Tcl_DStringResult(interp,&ds); - Tcl_DStringFree(&ds); - return TCL_OK; - } - - } else if (argc>=2 && argc<=3 && !strncmp(argv[1],"types",l)) { - TBLModule *tm; - TBLTypeDef* td; - int moduleFound = 0; - Tcl_DString ds; - Tcl_DStringInit(&ds); - FOR_EACH_LIST_ELMT (tm, tcd->tbl->modules) - if (argc==2 || equal(tm->name.octs,argv[2])) { - moduleFound = 1; - FOR_EACH_LIST_ELMT (td, tm->typeDefs) { - Tcl_DStringStartSublist(&ds); - Tcl_DStringAppendElement(&ds,tm->name.octs); - Tcl_DStringAppendElement(&ds,td->typeName.octs); - Tcl_DStringEndSublist(&ds); - } - } - Tcl_DStringResult(interp,&ds); - Tcl_DStringFree(&ds); - if (argc==3 && !moduleFound) { - Tcl_AppendResult(interp,argv[0]," ",argv[1],": module \"",argv[2], - "\" unknown",NULL); - return TCL_ERROR; - } - return TCL_OK; - } - } - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], - " modules", - " | types ?module?", - " | type ?-followref? {?module? typedef ?subtype? ...}", - " | decode channel {?module? typedef ?subtype? ...} valcmd ?typecmd?", - " | encode channel {?module? typedef ?subtype? ...} valcmd ?typecmd?", - " | close\"", - NULL); - return TCL_ERROR; -} - -void TblCmdFree (tcd) - TblCmdData* tcd; -{ - FreeTBL(tcd->tbl); - ckfree(tcd); -} - -int TableCmd (clientData, interp, argc, argv) - ClientData clientData; - Tcl_Interp* interp; - int argc; - char* argv[]; -{ - static int ntbl = 0; - TBL* tbl; - TblCmdData* tcd; - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " path\"", NULL); - return TCL_ERROR; - } - - interpG = interp; - interpResultG = TCL_OK; - tbl = LoadTblFile(argv[1]); - if (!tbl && interpResultG==TCL_OK) { - Asn1Error("Can't load grammar table"); - } - - if (interpResultG!=TCL_OK) - return interpResultG; - - tcd = (TblCmdData*) ckalloc(sizeof(*tcd)); - sprintf(tcd->name,"asn%d",++ntbl); - tcd->tbl = tbl; - Tcl_CreateCommand(interp,tcd->name,TblCmd,tcd,TblCmdFree); - Tcl_AppendResult(interp,tcd->name,NULL); - return TCL_OK; - } - -/* - *---------------------------------------------------------------------- - * - * Tcl_AppInit -- - * - * This procedure performs application-specific initialization. - * Most applications, especially those that incorporate additional - * packages, will have their own version of this procedure. - * - * Results: - * Returns a standard Tcl completion code, and leaves an error - * message in interp->result if an error occurs. - * - * Side effects: - * Depends on the startup script. - * - *---------------------------------------------------------------------- - */ - - -int -Tbl_AppInit(interp) - Tcl_Interp *interp; /* Interpreter for application. */ -{ - if (Tcl_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - if (Tk_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - - /* - * Call Tcl_CreateCommand for application-specific commands, if - * they weren't already created by the init procedures called above. - */ - - Asn1InstallErrorHandler(myAsn1ErrorHandler); - InitNibbleMem(1024,1024); - Tcl_CreateCommand(interp, "asn", TableCmd, NULL, NULL); - - return TCL_OK; -} diff --git a/SecuritySNACCRuntime/tcl-example/dependencies b/SecuritySNACCRuntime/tcl-example/dependencies deleted file mode 100644 index e69de29b..00000000 diff --git a/SecuritySNACCRuntime/tcl-example/edex0.asn1 b/SecuritySNACCRuntime/tcl-example/edex0.asn1 deleted file mode 100644 index 82ad3673..00000000 --- a/SecuritySNACCRuntime/tcl-example/edex0.asn1 +++ /dev/null @@ -1,39 +0,0 @@ --- file: edex0.asn1 --- --- snacced example, simple types module --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-example/Attic/edex0.asn1,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ --- $Log: edex0.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:10 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:06:55 aram --- Originals from SMIME Free Library. --- --- Revision 1.1 1997/01/01 22:57:11 rj --- first check-in --- - -EdEx-Simple DEFINITIONS ::= -BEGIN - -RainbowColor ::= INTEGER -{ - red(0), orange(1), yellow(2), green(3), blue(4), indigo(5), violet(6) -} - -DayOfTheWeek ::= ENUMERATED -{ - sunday(0), monday(1), tuesday(2), wednesday(3), thursday(4), friday(5), saturday(6) -} - -Hand ::= BIT STRING -{ - thumb(0), forefinger(1), middle-finger(2), ring-finger(3), little-finger(4) -} - -victory Hand ::= { forefinger, middle-finger } - -File ::= OCTET STRING - -END diff --git a/SecuritySNACCRuntime/tcl-example/edex1.asn1 b/SecuritySNACCRuntime/tcl-example/edex1.asn1 deleted file mode 100644 index 9644caa1..00000000 --- a/SecuritySNACCRuntime/tcl-example/edex1.asn1 +++ /dev/null @@ -1,78 +0,0 @@ --- file: edex1.asn1 --- --- snacced example, structured types module --- --- $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-example/Attic/edex1.asn1,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ --- $Log: edex1.asn1,v $ --- Revision 1.1.1.1 2001/05/18 23:14:10 mb --- Move from private repository to open source repository --- --- Revision 1.1.1.1 1999/03/16 18:06:55 aram --- Originals from SMIME Free Library. --- --- Revision 1.2 1997/02/28 13:39:56 wan --- Modifications collected for new version 1.3: Bug fixes, tk4.2. --- --- Revision 1.1 1997/01/01 22:57:13 rj --- first check-in --- - -EdEx-Structured DEFINITIONS ::= -BEGIN - -IMPORTS RainbowColor, DayOfTheWeek, Hand FROM EdEx-Simple; - -RGBColor ::= SEQUENCE -{ - red INTEGER, - green INTEGER, - blue INTEGER -} - -Coordinate ::= CHOICE -{ - cartesian [0] SEQUENCE { x REAL, y REAL }, - polar [1] SEQUENCE { angle REAL, distance REAL } -} - -File ::= SET -{ - name [0] PrintableString, - contents [1] OCTET STRING, - checksum [2] INTEGER OPTIONAL, - read-only [3] BOOLEAN DEFAULT FALSE -} - -Directory ::= SET -{ - name PrintableString, - files SET OF File -} - -Simple ::= SET -{ - null [0] NULL, - boolv [1] BOOLEAN, - day [2] DayOfTheWeek, - intv [3] INTEGER, - color [4] RainbowColor, - real [5] REAL, - bits [6] Hand, - str [7] OCTET STRING, - optstr [8] OCTET STRING OPTIONAL -} - -Structured ::= SET -{ - coord [0] Coordinate, - color [1] CHOICE { rainbow RainbowColor, rgb RGBColor } -} - -Various ::= SET -{ - simple [0] Simple, - struct [1] Structured, - recursion [2] Various OPTIONAL -} - -END diff --git a/SecuritySNACCRuntime/tcl-example/makefile b/SecuritySNACCRuntime/tcl-example/makefile deleted file mode 100644 index 018e85ac..00000000 --- a/SecuritySNACCRuntime/tcl-example/makefile +++ /dev/null @@ -1,102 +0,0 @@ -# -# Makefile for the snaccwish -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-example/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:10 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:55 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1997/02/16 12:53:24 rj -# remove more generated files -# -# Revision 1.1 1997/01/01 22:57:14 rj -# first check-in -# - -include ../makehead - -TOP = .. - -SNACC = $(TOP)/compiler/snacc - -ASN1_SRC_DIR = $(TOP)/asn1specs -C++_LIB = $(TOP)/c++-lib -ASN1INC = $(C++_LIB)/inc -ASN1LIB = $(C++_LIB)/libasn1tcl.a -TCL_LIB = $(TOP)/tcl-lib - -CPPFLAGS += -I$(TOP) -I$(ASN1INC) $(CPPFLAGS.TCL) $(CPPFLAGS.X11) -DTCL -DSNACC_DEEP_COPY - -PDUS = X.T1,X.T4 -PDUS = EdEx-Structured.File,EdEx-Structured.Directory,EdEx-Structured.Various - -ASN1FILES = \ - edex0.asn1 \ - edex1.asn1 - -ASN1HFILES = \ - edex0.h \ - edex1.h - -ASN1CFILES = \ - edex0.C \ - edex1.C \ - modules.C - -ASN1OFILES = \ - edex0.o \ - edex1.o \ - modules.o - -OFILES = \ - $(ASN1OFILES) - -DISTFILES = \ - makefile \ - $(ASN1FILES) - -LDFLAGS += $(LDFLAGS.X11) -LDLIBS += $(ASN1LIB) $(TREELIBS) $(TCLLIBS) $(LDLIBS.X11pre) -lX11 $(LDLIBS.X11extra) $(LIBS) - -WISH = snaccwish -SCRIPT = snacced - -#------------------------------------------------------------------------------- - -all:: $(WISH) $(SCRIPT) - -$(WISH): $(OFILES) $(ASN1LIB) - $(REASON) - $(CXX) $(LDFLAGS) -o $(WISH) $(OFILES) $(LDLIBS) - -$(SCRIPT):: - $(TCL_LIB)/make-snacced $@ ./$(WISH) $(TCL_LIB) - -$(ASN1LIB):: - cd $(@D) && $(MAKE) tcl-lib - -# if $(ASN1INC)/asn_useful.h doesn't exist, someone probably called `make clean` in $(C++_LIB). -$(ASN1INC)/asn-useful.h: - $(MAKE) $(ASN1LIB) - -$(ASN1HFILES) $(ASN1CFILES): $(SNACC) $(ASN1FILES) makefile - $(REASON) - $(SNACC) -u $(ASN1_SRC_DIR)/asn-useful.asn1 -tcl $(PDUS) $(ASN1FILES) - -$(SNACC):: - cd $(@D) && $(MAKE) $(@F) - -clean:: - $(RM) $(ASN1HFILES) $(ASN1CFILES) - $(RM) $(OFILES) - -clobber:: - $(RM) $(WISH) - -# dummy: -install:: - -include ../maketail diff --git a/SecuritySNACCRuntime/tcl-lib/bindings.tcl b/SecuritySNACCRuntime/tcl-lib/bindings.tcl deleted file mode 100644 index fc510818..00000000 --- a/SecuritySNACCRuntime/tcl-lib/bindings.tcl +++ /dev/null @@ -1,30 +0,0 @@ -# file: bindings.tcl - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc bit_string_entry_bindings {entry} \ -{ - bind $entry { } -# bind $entry {puts return} - bind $entry {%W insert insert %A} - bind $entry {%W insert insert %A} - bind $entry [bind Entry ] - bind $entry [bind Entry ] - bind $entry [bind Entry ] - bind $entry [bind Entry ] - bind $entry [bind Entry ] - bind $entry {%W icursor [expr [%W index insert] -1]} - bind $entry {%W icursor [expr [%W index insert] +1]} -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc int_entry_bindings {entry} \ -{ - bit_string_entry_bindings $entry - for {set i 2} {$i < 10} {incr i} \ - { - bind $entry {%W insert insert %A} - bind $entry {%W insert insert %A} - } - bind $entry {%W insert insert %A} - bind $entry {%W insert insert %A} -} diff --git a/SecuritySNACCRuntime/tcl-lib/help.tcl b/SecuritySNACCRuntime/tcl-lib/help.tcl deleted file mode 100644 index 63506b36..00000000 --- a/SecuritySNACCRuntime/tcl-lib/help.tcl +++ /dev/null @@ -1,48 +0,0 @@ -# file: help.tcl -# toplevel widget to display a help text (modal) -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-lib/Attic/help.tcl,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -# $Log: help.tcl,v $ -# Revision 1.1.1.1 2001/05/18 23:14:10 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:55 aram -# Originals from SMIME Free Library. -# -# Revision 1.1 1997/01/01 23:11:54 rj -# first check-in -# - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc help {w helptext} \ -{ - set help .help - set text $help.text - set sb $help.sb - set dismiss $help.dismiss - - getpos $w x y - incr x -100 - toplevel $help -class Dialog - wm title $help {Help} - wm transient $help . - wm geometry $help +$x+$y - wm minsize $help 0 0 - - text $text -borderwidth 2 -relief sunken -yscrollcommand [list $sb set] -width 32 -height 8 - scrollbar $sb -relief sunken -command [list $text yview] -width 10 -cursor arrow - button $dismiss -text Dismiss -command [list destroy $help] - - pack $dismiss -side bottom -pady 2 - pack $sb -side right -fill y - pack $text -expand true -fill both - - bind $text [list destroy $help] - - $text insert end $helptext - - set oldfocus [focus] - focus $text - tkwait window $help - focus $oldfocus -} diff --git a/SecuritySNACCRuntime/tcl-lib/make-snacced b/SecuritySNACCRuntime/tcl-lib/make-snacced deleted file mode 100644 index 893ae803..00000000 --- a/SecuritySNACCRuntime/tcl-lib/make-snacced +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -if [ $# -ne 3 ]; then - echo "usage: $0 script wish tcldir" 1>&2 - exit 1 -fi - -set -e - -exec 1> "$1" - -echo "#!$2 -f" -echo "set auto_path [linsert \$auto_path 0 $3]" -echo "snacced" - -chmod +x "$1" diff --git a/SecuritySNACCRuntime/tcl-lib/makefile b/SecuritySNACCRuntime/tcl-lib/makefile deleted file mode 100644 index ba7e6b13..00000000 --- a/SecuritySNACCRuntime/tcl-lib/makefile +++ /dev/null @@ -1,69 +0,0 @@ -# file: .../tcl-lib/makefile -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-lib/Attic/makefile,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -# $Log: makefile,v $ -# Revision 1.1.1.1 2001/05/18 23:14:10 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:55 aram -# Originals from SMIME Free Library. -# -# Revision 1.1 1997/01/01 23:11:57 rj -# first check-in -# - -include ../makehead - -TOP = .. - -TCLFILES.dist = \ - bindings.tcl \ - help.tcl \ - selbox.tcl \ - snacced.tcl \ - tkuti.tcl \ - uti.tcl - -TCLFILES = \ - $(TCLFILES.dist) \ - tclIndex - -DISTFILES = \ - $(TCLFILES.dist) \ - make-snacced \ - makefile - -default: tclIndex - -tclIndex: $(TCLFILES.dist) makefile - echo 'auto_mkindex . $(TCLFILES.dist)' | $(TCLSH) - -install-sh: - ln $(TOP)/install-sh $@ - -install:: $(TCLFILES) install-sh $(tcldir) - -$(tcldir): - $(TOP)/mkinstalldirs $@ - -install:: - $(INSTALL_PROGRAM) make-snacced $(bindir)/ - for tcl in $(TCLFILES); do\ - $(INSTALL_DATA) $$tcl $(tcldir)/;\ - done - -clean:: - $(RM) *~ *.dvi *.log *.aux *.toc *.lof *.lot *.bbl *.blg sp_errs .emacs* - -clobber:: - $(RM) tclIndex - $(RM) install-sh - -gen-distfiles:: $(DISTFILES) - -distfiles:: - echo $(DISTFILES) - -# dummy: -depend:: - @true diff --git a/SecuritySNACCRuntime/tcl-lib/selbox.tcl b/SecuritySNACCRuntime/tcl-lib/selbox.tcl deleted file mode 100644 index cd3bb905..00000000 --- a/SecuritySNACCRuntime/tcl-lib/selbox.tcl +++ /dev/null @@ -1,362 +0,0 @@ -# file: selbox.tcl -# file and content type selection box (ASN.1) -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-lib/Attic/selbox.tcl,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $ -# $Log: selbox.tcl,v $ -# Revision 1.1.1.1 2001/05/18 23:14:10 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:56 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1997/02/28 13:39:56 wan -# Modifications collected for new version 1.3: Bug fixes, tk4.2. -# -# Revision 1.1 1997/01/01 23:11:59 rj -# first check-in -# - -proc selbox_newfn {sbref} \ -{ - upvar #0 $sbref sb - - set fn $sb(toplevel).f.fn.name - - set name [$fn get] - - debug $name -} - -proc selbox_newbase {sbref} \ -{ - global $sbref - upvar #0 $sbref sb - - set fb_list $sb(toplevel).f.lists.basename - set bs [$fb_list curselection] - if {[llength $bs] == 1} \ - { - set base [$fb_list get $bs] - -debug base=$base - set path [split $sb(fn) /] - set len [llength $path] - set last [expr $len-1] -debug len=$len - if {$base == {..}} \ - { - if {$len == 0} \ - { - set $sbref\(fn) .. - } \ - else \ - { -# set sb [join [lrange $path 0 $last] /] - if {[lindex $path $last] == {..}} \ - { - append $sbref\(fn) /.. - } \ - else \ - { - set $sbref\(fn) [join [lrange $path 0 $last] /] - } - } - } \ - else \ - { - if {$len == 0} \ - { - set $sbref\(fn) $base - } \ - else \ - { -incr last -1 -# set sb [join [concat [lrange $path 0 $last] $base] /] -debug [list set $sbref\(fn) [join [concat [lrange $path 0 $last] $base] /]] - set $sbref\(fn) [join [concat [lrange $path 0 $last] $base] /] - } - } -debug "sb(fn)=$sb(fn)" - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc selbox_update {name elem op} \ -{ -debug ">selbox_update $name $elem $op" - upvar #0 $name sb - -#debug "$name=$sb" - set fb_list $sb(toplevel).f.lists.basename - $fb_list delete 0 end - $fb_list insert 0 .. - set dir [file dirname $sb(fn)] - set base [file tail $sb(fn)] - set names [lsort [glob $dir/{.*,*}]] - foreach name $names \ - { - set name [file tail $name] -# debug $name - if {$name != {.} && $name != {..}} \ - { - $fb_list insert end $name - if {$name == $base} \ - { - $fb_list select from end - $fb_list yview end - } - } - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc selbox_tm_click {sbref} \ -{ - upvar #0 $sbref sb - - global pdus - - set t $sb(toplevel).t.lists - set tm $t.modules - set tt $t.types - - set ms [$tm curselection] - if {[llength $ms] == 1} \ - { - $tt delete 0 end - eval $tt insert 0 $pdus([$tm get $ms]) - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc selbox_ok {sbref} \ -{ - upvar #0 $sbref sb - - set fn $sb(toplevel).f.fn.name - set t $sb(toplevel).t.lists - set m $t.modules - set t $t.types - - if {$sb(want_fn) && $sb(fn) == {} && $sb(force_fn)} \ - { - tk_dialog .d {select filename} "You need to enter a file name" warning 0 Ok - return - } - - if {$sb(want_ct)} \ - { - set ms [$m curselection] - set ts [$t curselection] - - if {[llength $ms] == 1 && [llength $ts] == 1} \ - { - set sb(ct) "[$m get $ms] [$t get $ts]" - } \ - else \ - { - tk_dialog .d {select content type} "You need to select a content type" warning 0 Ok - return - } - } - - set sb(rc) 1 - destroy $sb(toplevel) -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc selbox_cancel {sbref} \ -{ - upvar #0 $sbref sb - - set sb(rc) 0 - destroy $sb(toplevel) -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -# the selbox (short for `file and content type selection box') -# selbox has to be called with two arguments, which may be either empty or be the name of a global variable. -# the selbox can display two sections: one for selecting a file name, a second for selecting a content type. -# the selbox arguments denote the variable names for the the two sections. -# if a variable name is empty, its corresponding section will not be displayed. -# if filename_ref is non-empty, a filename will forced to be entered unless `nullfn' is given in args. - -# the 1x1 geometry for the listboxes below allows them to shrink when the selbox is resized. -# (otherwise, the buttons and the second listbox will disappear!) - -set #sb 0 - -proc selbox {filename_ref conttype_ref args} \ -{ - # change this if you get widget or variable name collisions: - set prefix selbox - - # choose a unique variable and widget name: - global #sb - while {[winfo exists [set toplevel .[set sbref $prefix${#sb}]]]} \ - { - incr #sb - } - - global $sbref - upvar #0 $sbref sb - - if {$filename_ref != {}} \ - { - set sb(want_fn) 1 - set sb(force_fn) 1 - upvar $filename_ref filename - } \ - else \ - { - set sb(want_fn) 0 - } - - if {$conttype_ref != {}} \ - { - set sb(want_ct) 1 - upvar $conttype_ref conttype - } \ - else \ - { - set sb(want_ct) 0 - } - - foreach arg $args \ - { - switch $arg \ - { - nullfn \ - { - set sb(force_fn) 0 - } - default \ - { - error "selbox: illegal argument $arg" - } - } - } - - set sb(toplevel) [toplevel $toplevel] - wm minsize $toplevel 1 1 - wm geometry $toplevel 300x300 - - #--- up to three frames, for the file name, for the content type, and for a row of buttons: - set borderwidth 5 - set relief ridge - if {$sb(want_fn)} \ - { - set f [frame $toplevel.f -relief $relief -bd $borderwidth] - } - if {$sb(want_ct)} \ - { - set t [frame $toplevel.t -relief $relief -bd $borderwidth] - } - set btns [frame $toplevel.btns -relief $relief -bd $borderwidth] - - #--- fill the upper file frame: - - if {$sb(want_fn)} \ - { - # set c [canvas $f.c -bg blue] - set flabel [label $f.label -text {File name:}] - set flists [frame $f.lists] - set fnf [frame $f.fn] - #$c create window 0 0 -window $flists -anchor nw - #set hsb [scrollbar $f.sb -orient horizontal -command "$c xview"] - # set fd_list [listbox $flists.dirname -relief sunken] - set fb_list [listbox $flists.basename -relief sunken -width 1 -height 1 -selectmode single] - - # set fd_sb [scrollbar $flists.dir_sb] - set fb_sb [scrollbar $flists.base_sb] - - $fb_list configure -yscrollcommand "$fb_sb set" - $fb_sb configure -command "$fb_list yview" - - # tk_listboxSingleSelect $fd_list $fb_list - # tk_listboxSingleSelect $fb_list - # bind $fd_list "sb_newdir $sb" - bind $fb_list "selbox_newbase $sbref" - - set fn [entry $fnf.name -relief sunken -textvariable $sbref\(fn)] - - #bind $fn "sb_newfn $sb" - - # pack $fd_list $fd_sb $fb_list $fb_sb -side left -expand 1 -fill y - pack $fb_list -side left -expand 1 -fill both - pack $fb_sb -side left -fill y - pack $fn - - pack $flabel -fill x - pack $fnf -fill x - pack $flists -expand 1 -fill both - # pack $c $hsb -expand 1 -fill both - - trace variable $sbref\(fn) w selbox_update - # ``set sb(fn) {}'' doesn't work! (selbox_update will be called with the alias, not the global name!) - if {[info exists filename]} \ - { - set $sbref\(fn) $filename - } \ - else \ - { - set $sbref\(fn) {} - } - - pack $f -expand 1 -fill both - } - - #--- fill the middle type frame: - - if {$sb(want_ct)} \ - { - set tlabel [label $t.label -text {Content type:}] - set tlists [frame $t.lists] - - set tm [listbox $tlists.modules -exportselection 0 -relief sunken -width 1 -height 1 -selectmode single] - set tt [listbox $tlists.types -exportselection 0 -relief sunken -width 1 -height 1 -selectmode single] - - set tm_sb [scrollbar $tlists.mod_sb] - set tt_sb [scrollbar $tlists.type_sb] - - # tk_listboxSingleSelect $tm $tt - $tm configure -yscrollcommand "$tm_sb set" - $tm_sb configure -command "$tm yview" - - global pdus - eval $tm insert 0 [array names pdus] - bind $tm <1> "[bind Listbox <1>]; selbox_tm_click $sbref" - - pack $tm $tm_sb $tt $tt_sb -side left - pack configure $tm $tt -expand 1 -fill both - pack configure $tm_sb $tt_sb -fill y - pack $tlabel -fill x - pack $tlists -expand 1 -fill both - - pack $t -expand 1 -fill both - } - - #--- fill the lower button frame: - - button $btns.ok -text Ok -command "selbox_ok $sbref" - button $btns.cancel -text Cancel -command "selbox_cancel $sbref" - - pack $btns.ok $btns.cancel -side left -padx 3m - - pack $btns -fill x - - #--- now we're set up, let's go to work: - - set of [focus] - focus $fn - - tkwait window $toplevel - # if we got an affirmative response, export the selection: - if $sb(rc) \ - { - if {$sb(want_fn)} { set filename $sb(fn) } - if {$sb(want_ct)} { set conttype $sb(ct) } - } - focus $of - return $sb(rc) -} diff --git a/SecuritySNACCRuntime/tcl-lib/snacced.tcl b/SecuritySNACCRuntime/tcl-lib/snacced.tcl deleted file mode 100644 index 295b880c..00000000 --- a/SecuritySNACCRuntime/tcl-lib/snacced.tcl +++ /dev/null @@ -1,1604 +0,0 @@ -# file: .../tcl-lib/snacced.tcl -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-lib/Attic/snacced.tcl,v 1.1.1.1 2001/05/18 23:14:11 mb Exp $ -# $Log: snacced.tcl,v $ -# Revision 1.1.1.1 2001/05/18 23:14:11 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:56 aram -# Originals from SMIME Free Library. -# -# Revision 1.2 1997/02/28 13:39:57 wan -# Modifications collected for new version 1.3: Bug fixes, tk4.2. -# -# Revision 1.1 1997/01/01 23:12:00 rj -# first check-in -# - -# todo: -# int, enum and bit string editors with scrollbar - -#\[banner "initialization"]--------------------------------------------------------------------------------------------------------- - -set version 1.0 - -#tk colormodel . monochrome - -# check all types whether they were marked as PDU. -# collect them in an associative array (indexed by module name) -foreach t [snacc types] \ -{ - if {[lindex [snacc type $t] 1] == {pdu}} \ - { - set module [lindex $t 0] - set type [lindex $t 1] - lappend pdus($module) $type - } -} - -#foreach n [array names pdus] \ -#{ -# debug "module $n: $pdus($n)" -#} - -#\[banner "debugging aid"]---------------------------------------------------------------------------------------------------------- - -set debug 0 - -proc debug {text} \ -{ - global debug - if $debug {puts $text} -} - -#\[banner "help texts"]------------------------------------------------------------------------------------------------------------- - -set helptext(about) "SnaccEd $version" - -set helptext(manoeuv) \ -"Button 1 - on label - show/hide subnodes (except for lists) - on list - perform action (selected with button 3's popup) - -Button 2 - on label - open/close value editor - on canvas, list or text - drag view - -Button 3 - on label - show/hide parent - on list - select action mode (for button 1) - on text - pops up menu for text import/export -" - -#\[banner "File loading and saving"]------------------------------------------------------------------------------------------------ - -# called from file_reload and file_load_from -# clears the display so that only the file's root gets shown -proc file_prune {fileref} \ -{ - upvar #0 $fileref file - - set tree $file(tree) - set handle $file(handle) - - list_cleanup /$handle $handle - $tree prune {} - - ed_addnode $tree {} {} {} $handle $handle valid - $tree draw -} - -# this function is called from the "File" menu. -# it reloads the file contents from its old origin: -proc file_reload {fileref} \ -{ - set rc 1 - upvar #0 $fileref file - # file_prune must be called before the snacc object is modified: - file_prune $fileref - $file(toplevel) config -cursor watch - update idletasks - if {[catch {snacc read $file(handle)} msg]} \ - { - tk_dialog .d load "Couldn't reload: $msg" warning 0 Dismiss - } \ - else \ - { - set file(modified) 0 - set rc 0 - } - $file(toplevel) config -cursor arrow - return $rc -} - -# this function is called from the "File" menu. -# it lets the user select a file and loads its contents -proc file_load_from {fileref} \ -{ - set rc 1 - upvar #0 $fileref file - if {[selbox fn ct]} \ - { - # file_prune must be called before the snacc object is modified: - file_prune $fileref - $file(toplevel) config -cursor watch - update idletasks - if {[catch {snacc read $file(handle) $ct $fn} msg]} \ - { - tk_dialog .d load "Couldn't load $fn: $msg" warning 0 Dismiss - } \ - else \ - { - set file(modified) 0 - set rc 0 - } - $file(toplevel) config -cursor arrow - } - return $rc -} - -# this function is called from the "File" menu. -# it saves the file contents to its old origin: -proc file_save {fileref} \ -{ - set rc 1 - upvar #0 $fileref file - $file(toplevel) config -cursor watch - update idletasks - if {[catch {snacc write $file(handle)} msg]} \ - { - tk_dialog .d save "Couldn't save: $msg" warning 0 Dismiss - } \ - else \ - { - set file(modified) 0 - set rc 0 - } - $file(toplevel) config -cursor arrow - return $rc -} - -# this function is called from the "File" menu. -# it lets the user select a file and saves the file's contents -proc file_save_as {fileref} \ -{ - set rc 1 - upvar #0 $fileref file - if {[selbox fn {}]} \ - { - $file(toplevel) config -cursor watch - update idletasks - if {[catch {snacc write $file(handle) $fn} msg]} \ - { - tk_dialog .d save "Couldn't save $fn: $msg" warning 0 Dismiss - } \ - else \ - { - set file(modified) 0 - set rc 0 - } - $file(toplevel) config -cursor arrow - } - return $rc -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -# this function is called from prune_or_add_children, list_click, new_choice, toggle_se* and set_or_add_root -# it adds the node's children to the display -# some of the children may already be displayed (this is usually the case when the function gets called from list_click or set_or_add_root). -# ed_addnode will be called for every child. - -proc ed_expand {tree treepath snaccpath} \ -{ - set canvas [$tree canvas] - - set info [snacc info $snaccpath] - set type [lindex $info 2] - - switch $type \ - { - SEQUENCE - - SET \ - { - debug "$type:" - foreach elem [lindex $info 3] \ - { - set name [lindex $elem 0] - set validity [lindex $elem 1] - debug " $validity $name" - ed_addnode $tree $treepath $treepath $snaccpath $name $name $validity - } - } - SEQUENCE\ OF - - SET\ OF \ - { - set len [lindex $info 3] - set varname var:$treepath - upvar #0 $varname var -debug [list treepath=$treepath] -debug [list varname=$varname] -debug [list idlist=$var(idlist)] -debug [list expand list ($type) len=$len] - for {set i 0} {$i < $len} {incr i} \ - { - set id [lindex $var(idlist) $i] -debug [list index $i id $id] - if {$id} \ - { - ed_addnode $tree $treepath $treepath $snaccpath $id $i valid - } - } - } - CHOICE \ - { - set name [lindex $info 3] - set validity [lindex $info 4] - debug " $validity $name" - ed_addnode $tree $treepath $treepath $snaccpath $name $name $validity - } - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- - -# ed_addnode is called from set_or_add_root, new_file, file_prune and ed_expand. -# the node may already be displayed (this is usually the case when the function ed_expand gets called from list_click or set_or_add_root). in this case the node gets moved to the right position. -# otherwise the node is created at the right place. - -# the arguments are: -# tree name of the tree widget -# treeparent tag of the displayed parent node. this is usually the same as the treeparentpath, except when the display gets extended into the parent direction where the root tag is {} -# treeparentpath tag of the logical parent node. -# snaccparentpath names of the -# treenode node's name, gets appended to the treeparentpath -# snaccnode node's name, gets appended to the snaccparentpath -# validity - -proc ed_addnode {tree treeparent treeparentpath snaccparentpath treenode snaccnode validity} \ -{ - set canvas [$tree canvas] - - set treepath "$treeparentpath/$treenode" - set snaccpath "$snaccparentpath $snaccnode" - - if [llength [$canvas find withtag $treepath]] \ - { -debug [list movelink $treepath $treeparent] - $tree movelink $treepath $treeparent - } \ - else \ - { -#debug [list addnode $snaccpath] - if {[llength $snaccparentpath] > 0} \ - { - set nodelabeltext $snaccnode - } \ - else \ - { - set finfo [snacc finfo [string range $snaccpath 1 end]] - if {[lindex $finfo 0] == {}} \ - { - set nodelabeltext {(unnamed)} - } \ - else \ - { - set nodelabeltext [lindex $finfo 0] - } - } - $canvas create text 0 0 -text $nodelabeltext -tags [list $validity-label $treepath $treepath:label] - - set line [$canvas create line 0 0 0 0] - - # fix for canvas bug: for reverse video, the canvas displays black items on a black background - if {[tk colormodel .] == {monochrome} && [lindex [$canvas config -background] 4] == {black}} \ - { - $canvas itemconfigure $treepath -fill white - $canvas itemconfigure $line -fill white - } - - if {$validity == {void}} \ - { - if {[tk colormodel .] == {color}} \ - { - # #b0b0b0 is the light grey of disabled checkbuttons: - $canvas itemconfigure $treepath -fill #b0b0b0 - $canvas itemconfigure $line -fill #b0b0b0 - } \ - else \ - { - $canvas itemconfigure $treepath -stipple gray50 - $canvas itemconfigure $line -stipple gray50 - } - } - -debug [list addlink $treeparent $treepath $line] - $tree addlink $treeparent $treepath $line - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -# open/drop subtree -proc prune_or_add_children {canvas} \ -{ - set tree $canvas.t -# debug $canvas - set id [$canvas find withtag current] - if {$id == {}} \ - { - debug "no item" - } \ - else \ - { - set treepath [lindex [$canvas gettags $id] 1] - set snaccpath [tree2snacc $treepath] - set type [lindex [snacc info $snaccpath] 2] - switch $type \ - { - SEQUENCE\ OF - SET\ OF - {} - default - { -# debug $treepath - if {[$tree isleaf $treepath]} \ - { - debug [list expanding $treepath $snaccpath] - ed_expand $tree $treepath $snaccpath - } \ - else \ - { - debug [list cutting $treepath] - # !!! list_cleanup usually has to be called with the node that gets removed! - # in this case calling it with the node that stays around doesn't hurt because it is guaranteed not to be a SEQUENCE OF or SET OF type (they are handled a few lines above) - list_cleanup $treepath $snaccpath - $tree prune $treepath - } - } - } - } - $tree draw -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -# this function has to be called whenever a subtree that may contain SET OF or SEQUENCE of types gets removed from the display -# it must be called *before* the snacc object gets destroyed, the function examines it! -proc list_cleanup {treepath snaccpath} \ -{ - set info [snacc info $snaccpath] - set type [lindex $info 2] - switch $type \ - { - SET - SEQUENCE - CHOICE - { - foreach elem [lindex $info 3] \ - { - set name [lindex $elem 0] - set validity [lindex $elem 1] - if {$validity == {valid}} \ - { - set subtreepath "$treepath/$name" - set subsnaccpath "$snaccpath $name" - list_cleanup $subtreepath $subsnaccpath - } - } - } - SET\ OF - SEQUENCE\ OF - { - set varname var:$treepath - global $varname -debug [list varname=$varname] - if {[info exists $varname]} \ - { - set idlist [set $varname\(idlist)] -debug [list idlist=$idlist] - set i 0 - foreach id $idlist \ - { - if {$id != 0} \ - { - set subtreepath "$treepath/$id" - set subsnaccpath "$snaccpath $i" - list_cleanup $subtreepath $subsnaccpath - } - incr i - } - unset $varname - } - } - } -} - -# this function must be called when calling "$tree root $treepath". -# it calls list_cleanup for all nodes that are neither parent nor in the subtree pointed to by $treepath. -proc list_cleanup_not_me {treepath snaccpath} \ -{ - if {[set i [llength $snaccpath]] > 1} \ - { - incr i -1 - set parenttreepath [join [lrange [split $treepath /] 0 $i] /] - incr i -1 - set parentsnaccpath [lrange $snaccpath 0 $i] - - set info [snacc info $parentsnaccpath] - set type [lindex $info 2] - switch $type \ - { - SET - SEQUENCE - CHOICE - { - foreach elem [lindex $info 3] \ - { - set name [lindex $elem 0] - set validity [lindex $elem 1] - if {$validity == {valid}} \ - { - set subparenttreepath "$parenttreepath/$name" - set subparentsnaccpath "$parentsnaccpath $name" - if {$subparenttreepath != $treepath} \ - { - list_cleanup $subparenttreepath $subparentsnaccpath - } - } - } - } - SET\ OF - SEQUENCE\ OF - { - set varname var:$parenttreepath - global $varname - debug [list varname=$varname] - set idlist [set $varname\(idlist)] -debug [list idlist=$idlist] - set i 0 - foreach id $idlist \ - { - if {$id != 0} \ - { - set subparenttreepath "$parenttreepath/$id" - set subparentsnaccpath "$parentsnaccpath $i" - if {$subparenttreepath != $treepath} \ - { - list_cleanup $subparenttreepath $subparentsnaccpath - set $varname\(idlist) [lreplace [set $varname\(idlist)] $i $i 0] - } - } - incr i - } - } - } - # recursion: - list_cleanup_not_me $parenttreepath $parentsnaccpath - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -# /file0/files/1/name \(-> { file0 files 0 name} - -proc tree2snacc {treepath} \ -{ - set subtreepath {} - foreach elem [lrange [split $treepath /] 1 end] \ - { - set treeelem $elem - if {[regexp {^[0-9]} $elem]} \ - { - set varname var:$subtreepath - global $varname - set idlist [set $varname\(idlist)] - set id $elem - set index 0 - foreach lid $idlist \ - { - if {$lid == $id} break - incr index - } - if {$index == [llength $idlist]} \ - { - error "tree2snacc: id $id not found in idlist [list $idlist]" - } - set snaccelem $index - } \ - else \ - { - set snaccelem $elem - } - append subtreepath /$treeelem - append subsnaccpath " $snaccelem" - debug [list >>$subtreepath--$subsnaccpath<<] - } - debug [list >>$subtreepath--$subsnaccpath<<] - return $subsnaccpath -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc import_text {text_w treepath} \ -{ - if {[selbox fn {}]} \ - { - if {[catch {set text [snacc import $fn]} msg]} \ - { - tk_dialog .d import "Couldn't import $fn: $msg" warning 0 Dismiss - } \ - else \ - { - $text_w delete 0.0 end - $text_w insert end $text - snacc set [tree2snacc $treepath] $text - } - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc export_text {text_w} \ -{ - if {[selbox fn {}]} \ - { - if {[catch {snacc export [$text_w get 0.0 end] $fn} msg]} \ - { - tk_dialog .d import "Couldn't export $fn: $msg" warning 0 Dismiss - } - } -} - -proc frame_resize_bindings {fileref treepath} \ -{ - upvar #0 $fileref file - - set frame $file(canvas).edit$treepath - - bind $frame [list frame_resize_start $fileref %x %y] - bind $frame [list frame_resize_cont $fileref $treepath %x %y] - bind $frame [list frame_resize_end $fileref $treepath] - - $frame config -cursor bottom_right_corner -} - -proc frame_resize_start {fileref x y} \ -{ -#debug [list frame_resize_start $fileref $x $y] - - upvar #0 $fileref file - - set file(resize_x) $x - set file(resize_y) $y -} - -proc frame_resize_cont {fileref treepath x y} \ -{ -#debug [list frame_resize_cont $fileref $treepath $x $y] - - upvar #0 $fileref file - - set frame $file(canvas).edit$treepath - set frametag $treepath:edit - - set oldw [lindex [$file(canvas) itemconfig $frametag -width] 4] - set oldh [lindex [$file(canvas) itemconfig $frametag -height] 4] -debug "old: $oldw x $oldh" - set neww [max 1 [expr $oldw+$x-$file(resize_x)]] - set newh [max 1 [expr $oldh+$y-$file(resize_y)]] -debug "new: $neww x $newh" - $file(canvas) itemconfig $frametag -width $neww -height $newh - set file(resize_x) $x - set file(resize_y) $y -} - -proc frame_resize_end {fileref treepath} \ -{ -#debug [list frame_resize_end $fileref $treepath] - - upvar #0 $fileref file - - $file(tree) nodeconfig $treepath - $file(tree) draw -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -# toggle content editor -proc toggle_editor {canvas} \ -{ - set tree $canvas.t - set id [$canvas find withtag current] - if {$id == {}} \ - { - debug "no item" - } \ - else \ - { - set treepath [lindex [$canvas gettags $id] 1] - set snaccpath [tree2snacc $treepath] - set frame $canvas.edit$treepath - if [llength [$canvas find withtag $treepath:edit]] \ - { -debug "removing editor for [list $treepath]" - $canvas delete $treepath:edit - destroy $frame - $tree nodeconfig $treepath -remove {} - } \ - else \ - { -debug "opening editor for [list $treepath]" - - set fileref [lindex [split $treepath /] 1] - - frame $frame -borderwidth 3 -bg #cdb79e - set cleanup [list [list destroy $frame]] - - set info [snacc info $snaccpath] - set type [lindex $info 2] - - switch $type \ - { - NULL \ - { - set label $frame.label - label $label -text NULL - pack $label - } - BOOLEAN \ - { - set value [snacc get $snaccpath] - - set var var:$treepath - global $var - set $var $value - - set button $frame.button - #checkbutton $button -variable $var - checkbutton $button -onvalue TRUE -offvalue FALSE -variable $var -textvariable $var -command [list debug [list $canvas $treepath]] - pack $button - - trace variable $var w change_simple - } - INTEGER \ - { - set value [snacc get $snaccpath] - - set var var:$treepath - global $var - set $var $value - - if {[lindex $info 0] != {{} {}}} \ - { - set typeinfo [snacc type [lindex $info 0]] - - foreach elem [lindex $typeinfo 3] \ - { - set en [lindex $elem 0] - set ev [lindex $elem 1] - set button $frame.button$en - radiobutton $button -text $en -variable $var -value $ev -anchor w - pack $button -fill x - } - } - - set entry $frame.entry - entry $entry -textvariable $var -width 9 -relief sunken - - int_entry_bindings $entry - - pack $entry -anchor w -fill x - - focus $entry - - trace variable $var w change_simple - } - ENUMERATED \ - { - set typeinfo [snacc type [lindex $info 0]] - - if {[catch {set value [snacc get $snaccpath]} msg] == 1} \ - { - global errorInfo errorCode - if {$errorCode == {SNACC ILLENUM}} \ - { - set value [lindex [lindex $typeinfo 3] 0] - snacc set $snaccpath $value - append msg "--setting to first legal symbolic value \"$value\"" - tk_dialog .d illenum "$msg" warning 0 Dismiss - } \ - else \ - { - error $msg $errorInfo $errorCode - } - } - - set var var:$treepath - global $var - set $var $value - - foreach ev [lindex $typeinfo 3] \ - { - set button $frame.button$ev - radiobutton $button -text $ev -variable $var -value $ev -anchor w - pack $button -fill x - } - - trace variable $var w change_simple - } - REAL \ - { - set value [snacc get $snaccpath] - - set var var:$treepath - global $var - set $var $value - - set entry $frame.entry - entry $entry -textvariable $var -relief sunken - pack $entry - - frame_resize_bindings $fileref $treepath - - focus $entry - - trace variable $var w change_simple - } - BIT\ STRING \ - { - set value [snacc get $snaccpath] - - set var var:$treepath - global $var - set $var $value - - set max_ev 0 - if {[lindex $info 0] != {{} {}}} \ - { - set typeinfo [snacc type [lindex $info 0]] - - foreach elem [lindex $typeinfo 3] \ - { - set en [lindex $elem 0] - set ev [lindex $elem 1] - set max_ev [max $ev $max_ev] - set button $frame.button$en - checkbutton $button -text $en -variable $var:$ev -command [list toggle_bit $var $ev] -anchor w - pack $button -fill x - } - } - - set entry $frame.entry - entry $entry -textvariable $var -relief sunken - set len [max 8 [string length $value] [expr $max_ev + 1]] - if {$len > 0} \ - { -debug [list length of entry is $len] - $entry config -width $len - } - pack $entry -anchor w -fill x - - bit_string_entry_bindings $entry - - focus $entry - - trace variable $var w change_bits - set $var $value; # trigger the trace - } - OBJECT\ IDENTIFIER \ - { - set value [snacc get $snaccpath] - - set var var:$treepath - global $var - set $var $value - - set entry $frame.entry - entry $entry -textvariable $var -relief sunken - pack $entry -fill both - - frame_resize_bindings $fileref $treepath - - focus $entry - - trace variable $var w change_simple - } - OCTET\ STRING \ - { - set value [snacc get $snaccpath] - - set text $frame.text - set sb $frame.sb - - text $text -borderwidth 2 -relief sunken -yscrollcommand [list $sb set] -width 32 -height 8 - scrollbar $sb -relief sunken -command [list $text yview] -width 10 -cursor arrow - - pack $sb -side right -fill y - pack $text -side left -expand true -fill both - - bind $text [list $text scan mark %y] - bind $text [list $text scan dragto %y] - - bind $text "snacc set \[tree2snacc $treepath\] \[$text get 0.0 end\]" - bind $text "snacc set \[tree2snacc $treepath\] \[$text get 0.0 end\]" - - set m $frame.menu - menu $m - $m add command -label Load... -command "[list import_text $text $treepath]; [list $m unpost]" - $m add command -label Save... -command "[list export_text $text]; [list $m unpost]" - - bind $text "[list $m] post \[expr %X -16\] \[expr %Y -8\]" - bind $m [list $m unpost] - bind $m [list $m unpost] - - $text insert end $value - focus $text - - frame_resize_bindings $fileref $treepath - } - SEQUENCE - - SET \ - { - set typeinfo [snacc type [lindex $info 0]] - - debug "$type:" - - set varelems [lindex $info 3] - set typeelems [lindex $typeinfo 3] - - for {set i 0; set len [llength $varelems]} {$i < $len} {incr i} \ - { - set varelem [lindex $varelems $i] - set typeelem [lindex $typeelems $i] - - set name [lindex $varelem 0] - set validity [lindex $varelem 1] - debug " $validity $name" - - set var var:$treepath:$name - global $var - set $var $validity - - set button $frame.$name - checkbutton $button -text $name -onvalue valid -offvalue void -variable $var -command [list toggle_se* $canvas $treepath $name] -anchor w - if {[lindex $typeelem 4] == {mandatory}} \ - { - #$button configure -disabledforeground [lindex [$button configure -fg] 4] -state disabled - $button configure -state disabled - } - pack $button -fill x - } - } - SEQUENCE\ OF - - SET\ OF \ - { - set len [lindex $info 3] - - set varname var:$treepath - upvar #0 $varname var - if {![info exists var(idlist)]} \ - { - set var(idlist) {} - set var(lastid) 0 - } - # no! needs a longer lifetime! - #lappend cleanup [list global $varname] [list unset $varname] - -# set mbar $frame.mbar - set list $frame.list - set sb $frame.sb - - scrollbar $sb -command [list $list yview] -width 10 -relief sunken -cursor arrow -# listbox $list -yscroll [list $sb set] -relief sunken -width 4 -height 5 - text $list -borderwidth 2 -relief sunken -yscrollcommand [list $sb set] -width 4 -height 8 -exportselection 0 - pack $sb -side right -fill y - pack $list -side left -expand true -fill both - -# frame $mbar -relief raised -bd 2 -# pack $mbar -side top -fill x - -# set mode $mbar.mode -# set mode $frame.mode -# set m $mode.m -# menubutton $mode -text Mode -menu $m - set m $frame.mode - menu $m - set lm "[list list_mode $canvas $treepath]; [list $m unpost]" - $m add radiobutton -label Display -variable ${varname}(mode) -value display -command $lm - $m invoke last - $m add radiobutton -label Insert -variable ${varname}(mode) -value insert -command $lm - $m add radiobutton -label Append -variable ${varname}(mode) -value append -command $lm - $m add radiobutton -label Delete -variable ${varname}(mode) -value delete -command $lm -# pack $mode -side left - -# pack $mode -side top -fill x - - $list tag config display -background #b2dfee -relief raised - bind $list [list list_click $canvas $treepath] - bind $list { } - bind $list { } - bind $list { } - - bind $list "[list $m] post \[expr %X-16\] \[expr %Y-8\]" - bind $m [list $m unpost] - bind $m [list $m unpost] - debug $m - - for {set i 0} {$i < $len} {incr i} \ - { - $list insert end [format "%4d\n" $i] - - if {[llength $var(idlist)] > $i} \ - { - if {[set id [lindex $var(idlist) $i]]} \ - { - set line [expr $i + 1] - $list tag add display $line.0 $line.end - } - } \ - else \ - { - set var(idlist) [linsert $var(idlist) $i 0] - } - } - - frame_resize_bindings $fileref $treepath - } - CHOICE \ - { - set name [lindex $info 3] - set validity [lindex $info 4] - set typeinfo [snacc type [lindex $info 0]] - - set var var:$treepath - set oldvar oldvar:$treepath - global $var $oldvar - set $var $name - set $oldvar $name - - foreach elem [lindex $typeinfo 3] \ - { - set en [lindex $elem 0] - set button $frame.button$en - radiobutton $button -text $en -variable $var -value $en -command [list new_choice $canvas $treepath] -anchor w - pack $button -fill x - } - debug " $validity $name" - } - default \ - { - error "unexpected type $type" - } - } - - scan [$canvas bbox $treepath:label] "%d%d%d%d" lx uy rx ly - $canvas create window $lx $ly -anchor nw -tags [list edit $treepath $treepath:edit] -window $frame - - update idletasks; # calculate frame's size (needed by tree widget) - - # explicitly set the frame's width&height to avoid nasty effects when resizing: - scan [$canvas bbox $treepath:edit] "%d%d%d%d" lx uy rx ly - $canvas itemconfig $treepath:edit -width [expr $rx - $lx] -height [expr $ly - $uy] - -#debug [list cleanup = [join $cleanup \;]] - $tree nodeconfig $treepath -remove [join $cleanup \;] - } - } - $tree draw -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc list_click {canvas treepath} \ -{ - set tree $canvas.t - set snaccpath [tree2snacc $treepath] - -debug [list treepath=$treepath] -debug [list snaccpath=$snaccpath] -debug [list tree2snacc: [tree2snacc $treepath]] - set varname var:$treepath - upvar #0 $varname var - set frame $canvas.edit$treepath - set list $frame.list - - debug [list list_click: $list] -debug [list varname=$varname] -debug [list idlist=$var(idlist)] -# debug [$list tag ranges display] - set text_index [$list index current] -#debug [list index: $index] - if {$text_index != ""} \ - { - # strip the column number: - set line [lindex [split $text_index .] 0] - # lines numbers start at 1, indices at 0: - set index [expr $line - 1] - set len [llength $var(idlist)] - set tags [$list tag names $text_index] - switch $var(mode) \ - { - display \ - { -debug [list tags: $tags] -debug [list line: $line] - if {$index < $len} \ - { - set id [lindex $var(idlist) $index] -debug [list index $index id $id] - if {$id} \ - { - $list tag remove display $line.0 $line.end - list_cleanup $treepath/$id "$snaccpath $index" -debug [list $tree rmlink $treepath/$id] - $tree rmlink $treepath/$id - set var(idlist) [lreplace $var(idlist) $index $index 0] - } \ - else \ - { - $list tag add display $line.0 $line.end - set var(idlist) [lreplace $var(idlist) $index $index [incr var(lastid)]] - ed_expand $tree $treepath $snaccpath - } - } - } - insert - - append \ - { - if {$var(mode) == {append}} {incr index} -debug [list insert $index 0] - set var(idlist) [linsert $var(idlist) $index 0] -debug [list $var(idlist)] -debug [list catch [list snacc set "$snaccpath {insert $index}" {}]] - catch [list snacc set "$snaccpath {insert $index}" {}] - set file(modified) 1 -debug [list [snacc get $snaccpath]] - - $list insert end [format "%4d\n" [expr [lindex [split [$list index end] .] 0] - 1]] - - for {set i $len} {$i > $index} {incr i -1} \ - { - set line [expr $i + 1] - if {[set id [lindex $var(idlist) $i]]} \ - { -debug [list $canvas itemconfigure $treepath/$id:label -text $i] - $canvas itemconfigure $treepath/$id:label -text $i - if {![lindex $var(idlist) [expr $i - 1]]} \ - { -debug [list $list tag add display $line.0 $line.end] - $list tag add display $line.0 $line.end - } - } \ - else \ - { - if {![lindex $var(idlist) [expr $i - 1]]} \ - { -debug [list $list tag remove display $line.0 $line.end] - $list tag remove display $line.0 $line.end - } - } - } - set line [expr $index + 1] -debug [list $list tag remove display $line.0 $line.end] - $list tag remove display $line.0 $line.end - } - delete \ - { - if {$index < $len} \ - { -debug [list delete $index] - - if {[set id [lindex $var(idlist) $index]]} \ - { - # list_cleanup must be called before the snacc object is modified: - list_cleanup $treepath/$id "$snaccpath $index" - $tree rmlink $treepath/$id - } - incr len -1 - for {set i $index} {$i < $len} {incr i} \ - { - set line [expr $i + 1] - if {[set id [lindex $var(idlist) [expr $i + 1]]]} \ - { -debug [list $canvas itemconfigure $treepath/$id:label -text $i] - $canvas itemconfigure $treepath/$id:label -text $i - if {![lindex $var(idlist) $i]} \ - { -debug [list $list tag add display $line.0 $line.end] - $list tag add display $line.0 $line.end - } - } \ - else \ - { - if {[lindex $var(idlist) $i]} \ - { -debug [list $list tag remove display $line.0 $line.end] - $list tag remove display $line.0 $line.end - } - } - } - - set var(idlist) [lreplace $var(idlist) $index $index] -debug [list $var(idlist)] -debug [list snacc unset "$snaccpath $index"] - snacc unset "$snaccpath $index" - set file(modified) 1 -debug [list [snacc get $snaccpath]] - $list delete [$list index {end - 1 line}] [$list index end] - } - } - } - $tree draw - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc list_mode {canvas treepath} \ -{ - set var var:$treepath - global $var - set mode [set ${var}(mode)] - set frame $canvas.edit$treepath - set list $frame.list - - switch $mode \ - { - display {set cursor arrow} - insert {set cursor based_arrow_up} - append {set cursor based_arrow_down} - delete {set cursor pirate} - } - $list config -cursor $cursor - - debug [list list_mode: ${var}(mode) set to $mode] -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc toggle_bit {var i} \ -{ - global $var:$i $var - set bit [set $var:$i] - set val [set $var] - -debug [list toggle_bit $val $i to $bit] - - set pre [string range $val 0 [expr $i - 1]] - - set fill {} - for {set l [string length $val]} {$l < $i} {incr l} \ - { - append fill 0 -debug [list appending: $val] - } - - set post [string range $val [expr $i + 1] end] - -debug [list toggle_bit combining $pre $fill $bit $post] - set $var $pre$fill$bit$post -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc change_bits {var element op} \ -{ - global $var - set val [set $var] -debug [list change_bits $var set to $val] - -debug [list set l [string length $val]] - set l [string length $val] - for {set i 0} {$i < $l} {incr i} \ - { - global $var:$i - if {[info exists $var:$i]} \ - { -debug [list set $var:$i [string index $val $i]] - set $var:$i [string index $val $i] - } \ - else \ - { -debug [list non-exist: $var:$i] - } - } - - foreach bitvar [info globals $var:*] \ - { - set i [lindex [split $bitvar :] 2] - if {$i >= $l} \ - { - global $bitvar - set $bitvar 0 - } - } - - change_simple $var $element $op -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc change_simple {var element op} \ -{ - global $var - set val [set $var] -debug [list change_simple $var set to $val] - - set treepath [lindex [split $var :] 1] -debug [list treepath= $treepath] - set fileref [lindex [split $treepath /] 1] - upvar #0 $fileref file - set canvas $file(canvas) -debug [list canvas= $canvas] - set snaccpath [tree2snacc $treepath] -debug [list snaccpath= $snaccpath] - snacc set $snaccpath $val - set file(modified) 1 -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc new_choice {canvas treepath} \ -{ - set tree $canvas.t - set snaccpath [tree2snacc $treepath] - - set var var:$treepath - set oldvar oldvar:$treepath - global $var $oldvar - set val [set $var] - set oldval [set $oldvar] - - set fileref [lindex [split $treepath /] 1] - upvar #0 $fileref file - -debug "$file(modified)" - debug [list new choice: $snaccpath = $val] - - # list_cleanup must be called before the snacc object is modified: - list_cleanup $treepath/$oldval "$snaccpath $oldval" - - catch {snacc set $snaccpath [list $val {}]} - set file(modified) 1 -debug "$file(modified)" - - if {[llength [$canvas find withtag "$treepath/$oldval"]]} \ - { - $tree rmlink "$treepath/$oldval" - ed_expand $tree $treepath $snaccpath - $tree draw - } - - set $oldvar $val -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc toggle_se* {canvas treepath name} \ -{ - set tree $canvas.t - set snaccpath [tree2snacc $treepath] - - set var var:$treepath:$name - global $var - set val [set $var] - - set fileref [lindex [split $treepath /] 1] - upvar #0 $fileref file - - debug "$snaccpath $name = $val" - - # this procedure is called after the button value has changed, so adjust the display to the current (new) setting: - if {$val == {void}} \ - { - # (change valid \(-> void) - # list_cleanup must be called before the snacc object is modified: - list_cleanup $treepath/$name "$snaccpath $name" - snacc unset "$snaccpath $name" - } \ - else \ - { - # (change void \(-> valid) - catch {snacc set "$snaccpath $name" {}} - } - set file(modified) 1 - - if {[llength [$canvas find withtag "$treepath/$name"]]} \ - { -debug [list rmlink "$treepath/$name"] - $tree rmlink "$treepath/$name" - # a bug in the tree widget requires us to redraw here: - $tree draw - ed_expand $tree $treepath $snaccpath - $tree draw - } -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -# add/drop parent and siblings -proc set_or_add_root {canvas} \ -{ - set tree $canvas.t - set id [$canvas find withtag current] - if {$id == {}} \ - { - debug "no item" - } \ - else \ - { - set treepath [lindex [$canvas gettags $id] 1] - set snaccpath [tree2snacc $treepath] -# debug $path - if {[llength $snaccpath] == 1} \ - { - debug "at root already" - } \ - else \ - { - if {[$tree isroot $treepath]} \ - { - # show the parent: -debug [list expanding [list $treepath $snaccpath]] - set i [llength $snaccpath] - - incr i -1 - - set treeparentpath [join [lrange [split $treepath /] 0 $i] /] - set treeparentnode [lindex [split $treepath /] $i] - incr i -1 - set snaccparentpath [lrange $snaccpath 0 $i] - set snaccparentnode [lindex $snaccpath $i] - - set treeparentparentpath [join [lrange [split $treepath /] 0 $i] /] - incr i -1 - set snaccparentparentpath [lrange $snaccpath 0 $i] - -#debug [list ed_addnode $tree {} $parentparentpath $parentnode valid] - ed_addnode $tree {} $treeparentparentpath $snaccparentparentpath $treeparentnode $snaccparentnode valid -#debug [list ed_expand $tree $parentpath] - ed_expand $tree $treeparentpath $snaccparentpath - } \ - else \ - { - # hide everything above this subtree: -# debug "cutting $path" - list_cleanup_not_me $treepath $snaccpath - $tree root $treepath - } -# debug [snacc info $path] - } - } - $tree draw -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc file_open {} \ -{ - if {[selbox fn ct nullfn]} \ - { -debug "fn=$fn ct=$ct" - if {$fn != {}} \ - { - if {[catch {set f [snacc open $ct $fn create]} msg]} \ - { - tk_dialog .d load "Couldn't open $fn {$ct}: $msg" warning 0 Dismiss - return -1 - } - } \ - else \ - { - if {[catch {set f [snacc create $ct]} msg]} \ - { - tk_dialog .d create "Couldn't create {$ct}: $msg" warning 0 Dismiss - return -1 - } - } - new_file $f - return 0 - } - return -1 -} - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- - -set #file 0 -set #files 0 - -# returns 1 on `cancel', otherwise exits or returns 0 -proc close_file {fileref} \ -{ - upvar #0 $fileref file - - if {$file(modified)} \ - { - set fi [snacc finfo $file(handle)] - set fn [lindex $fi 0] - set hasfn [expr {$fn != {}}] - set isrw [expr {[lindex $fi 1] == {rw}}] - set msg {There are unsaved changes} - if {$hasfn} \ - { - append msg " in `$fn'" - } - append msg {. Save them?} - switch [lindex {save discard cancel} [tk_dialog .d modified $msg questhead 0 Yes No Cancel]] \ - { - cancel \ - { - return 1 - } - save \ - { - if {$hasfn && $isrw} \ - { - if {[file_save $fileref]} \ - { - return 1 - } - } \ - else \ - { - if {[file_save_as $fileref]} \ - { - return 1 - } - } - } - } - } - - destroy $file(toplevel) - global #files - if {![incr #files -1]} \ - { - exit - } - return 0 -} - -proc file_quit {} \ -{ - global #files - for {set i 0} {${#files}} {incr i} \ - { - if {[winfo exists .[set fileref file$i]]} \ - { - if {[close_file $fileref]} \ - { - return - } - } - } -} - -proc new_file {handle} \ -{ - global #file - - while {[winfo exists [set toplevel .[set fileref file${#file}]]]} \ - { - incr #file - } - - #global $fileref - upvar #0 $fileref file - - set file(handle) $handle - - set file(toplevel) [toplevel $toplevel] - wm title $toplevel snaccEd - wm minsize $toplevel 150 100 - wm geometry $toplevel 500x500 - - global #files - incr #files - - set file(modified) 0 - - $toplevel config -cursor arrow - - set menubar $toplevel.menu - frame $menubar -relief raised -bd 2 - pack $menubar -side top -fill x - - set filem $menubar.file - set m $filem.m - menubutton $filem -text File -menu $m - menu $m - $m add command -label Reload -command [list file_reload $fileref] - $m add command -label Load... -command [list file_load_from $fileref] - $m add command -label Save -command [list file_save $fileref] - $m add command -label {Save As...} -command [list file_save_as $fileref] - $m add command -label Close -command [list close_file $fileref] - $m add separator - $m add command -label Open... -command file_open - $m add separator - $m add command -label Quit -command file_quit - set fi [snacc finfo $handle] - set hasnofn [expr {[lindex $fi 0] == {}}] - set isro [expr {[lindex $fi 1] == {ro}}] - if {$hasnofn} \ - { - $m entryconfigure Reload -state disabled - } - if {$hasnofn || $isro} \ - { - $m entryconfigure Save -state disabled - } - pack $filem -side left - - set help $menubar.help - set m $help.m - menubutton $help -text Help -menu $help.m - menu $m - $m add command -label About -command "help [list $m] \$helptext(about)" - $m add command -label Manoeuvering -command "help [list $m] \$helptext(manoeuv)" - pack $help -side right - - tk_menuBar $menubar $filem $help - - frame $toplevel.f0 - frame $toplevel.f1 - - pack $toplevel.f0 -expand true -fill both - pack $toplevel.f1 -fill x - - set file(canvas) [set canvas [canvas $toplevel.c -width 0 -height 0]] - - set hsb [scrollbar $toplevel.hsb -orient horiz -relief sunken -command [list $canvas xview]] - set vsb [scrollbar $toplevel.vsb -relief sunken -command [list $canvas yview]] - - $canvas config -xscroll [list $hsb set] -yscroll [list $vsb set] - - set blind [frame $toplevel.blind -width [lindex [$vsb config -width] 4]] - - pack $vsb -in $toplevel.f0 -side right -fill y - pack $canvas -in $toplevel.f0 -side left -expand true -fill both - - pack $blind -in $toplevel.f1 -side right - pack $hsb -in $toplevel.f1 -side left -expand true -fill x - - bind $canvas [list $canvas scan mark %x %y] - bind $canvas [list $canvas scan dragto %x %y] - - $canvas bind valid-label {prune_or_add_children %W} - $canvas bind valid-label {toggle_editor %W} - $canvas bind valid-label {set_or_add_root %W} - - set file(tree) [set tree [tree $canvas.t]] - - ed_addnode $tree {} {} {} $handle $handle valid - - $tree draw - - tkwait visibility $toplevel -} - -proc snacced {} \ -{ - wm withdraw . - - global argc argv - - if {$argc == 0} \ - { - if {[file_open]} \ - { - exit 1 - } - } \ - else \ - { - if {$argc == 3} \ - { - set ct [lrange $argv 0 1] - set fn [lindex $argv 2] - if {[catch {set f [snacc open $ct $fn create]} msg]} \ - { - tk_dialog .d load "Couldn't open $fn {$ct}: $msg" warning 0 Dismiss - exit 1 - } - } \ - elseif {$argc == 2} \ - { - set ct [lrange $argv 0 1] - if {[catch {set f [snacc create $ct]} msg]} \ - { - tk_dialog .d create "Couldn't create {$ct}: $msg" warning 0 Dismiss - exit 1 - } - } \ - else \ - { - exit 1 - } - new_file $f - } -} diff --git a/SecuritySNACCRuntime/tcl-lib/tkuti.tcl b/SecuritySNACCRuntime/tcl-lib/tkuti.tcl deleted file mode 100644 index d2feddb2..00000000 --- a/SecuritySNACCRuntime/tcl-lib/tkuti.tcl +++ /dev/null @@ -1,21 +0,0 @@ -# file: tkuti.tcl -# miscellaneous Tk utilities. -# -# $Header: /cvs/root/Security/SecuritySNACCRuntime/tcl-lib/Attic/tkuti.tcl,v 1.1.1.1 2001/05/18 23:14:11 mb Exp $ -# $Log: tkuti.tcl,v $ -# Revision 1.1.1.1 2001/05/18 23:14:11 mb -# Move from private repository to open source repository -# -# Revision 1.1.1.1 1999/03/16 18:06:56 aram -# Originals from SMIME Free Library. -# -# Revision 1.1 1997/01/01 23:12:03 rj -# first check-in -# - -proc getpos {w xn yn} \ -{ - upvar $xn x $yn y - set geom [wm geometry $w] - scan $geom {%dx%d+%d+%d} w h x y -} diff --git a/SecuritySNACCRuntime/tcl-lib/uti.tcl b/SecuritySNACCRuntime/tcl-lib/uti.tcl deleted file mode 100644 index 8f7c3fff..00000000 --- a/SecuritySNACCRuntime/tcl-lib/uti.tcl +++ /dev/null @@ -1,15 +0,0 @@ -# file: uti.tcl - -#\[sep]----------------------------------------------------------------------------------------------------------------------------- -proc max {a0 args} \ -{ - set max $a0 - foreach a $args \ - { - if {$a > $max} \ - { - set max $a - } - } - return $max -} diff --git a/SecuritySNACCRuntime/version.h b/SecuritySNACCRuntime/version.h deleted file mode 100644 index bd268d26..00000000 --- a/SecuritySNACCRuntime/version.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -#define VERSION "1.3" -#define RELDATE "1997-10-20" -#define BUGREPADDR "snacc@cs.ubc.ca" diff --git a/SecurityServer/Authorization/AuthSession.h b/SecurityServer/Authorization/AuthSession.h index 38f74a52..dcc69961 100644 --- a/SecurityServer/Authorization/AuthSession.h +++ b/SecurityServer/Authorization/AuthSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Apple Computer, Inc. All Rights Reserved. * * The contents of this file constitute Original Code as defined in and are * subject to the Apple Public Source License Version 1.2 (the 'License'). @@ -35,13 +35,20 @@ extern "C" { The Session API provides specialized applications access to Session management and inquiry functions. This is a specialized API that should not be of interest to most people. + + The Security subsystem separates all processes into Security "sessions". Each process is in + exactly one session, and session membership inherits across fork/exec. Sessions form boundaries + for security-related state such as authorizations, keychain lock status, and the like. + Typically, each successful login (whether graphical or through ssh & friends) creates + a separate session. System daemons (started at system startup) belong to the "root session" + which has no user nor graphics access. - If you do not know what "Session" means in the context of MacOS Authorization and security, - please check with your documentation and come back when you have figured it out - we won't - explain it here. - - This API is tentative, preliminary, incomplete, internal, and subject to change. - You have been warned. + Sessions are identified with SecuritySessionIds. A session has a set of attributes + that are set on creation and can be retrieved with SessionGetInfo(). + + There are similar session concepts in the system, related but not necessarily + completely congruous. In particular, graphics sessions track security sessions + (but only for graphic logins). */ @@ -51,8 +58,7 @@ extern "C" { Different sessions have different identifiers; beyond that, you can't tell anything from these values. SessionIds can be compared for equality as you'd expect, but you should be careful - to use attribute bits wherever appropriate. For example, don't rely on there being - "the" graphical login session - some day, we may have more than one... + to use attribute bits wherever appropriate. */ typedef UInt32 SecuritySessionId; @@ -65,7 +71,7 @@ typedef UInt32 SecuritySessionId; */ enum { noSecuritySession = 0, /* definitely not a valid SecuritySessionId */ - callerSecuritySession = -1 /* the Session I (the caller) am in */ + callerSecuritySession = ((SecuritySessionId)-1) /* the Session I (the caller) am in */ }; @@ -82,6 +88,7 @@ enum { sessionHasTTY = 0x0020, /* /dev/tty is available */ sessionIsRemote = 0x1000, /* session was established over the network */ + // the following bits are used internally; do not try to set them sessionWasInitialized = 0x8000 /* session has been set up by its leader */ }; @@ -116,7 +123,9 @@ enum { /*! @function SessionGetInfo - Obtain information about a session. + Obtain information about a session. You can ask about any session whose + identifier you know. Use the callerSecuritySession constant to ask about + your own session (the one your process is in). @param session (input) The Session you are asking about. Can be one of the special constants defined above. @@ -138,15 +147,23 @@ OSStatus SessionGetInfo(SecuritySessionId session, /*! @function SessionCreate - This (very specialized) function creates and/or initializes a security session. - It always sets up the session that the calling process belongs to - you cannot - create a session for someone else. + This (very specialized) function creates a security session. + Upon completion, the new session contains the calling process (and none other). + You cannot create a session for someone else, and cannot avoid being placed + into the new session. This is (currently) the only call that changes a process's + session membership. By default, a new bootstrap subset port is created for the calling process. The process - acquires this new port as its bootstrap port, which all its children will inherit. - If you happen to have created the subset port on your own, you can pass the - sessionKeepCurrentBootstrap flag, and SessionCreate will use it. Note however that - you cannot supersede a prior SessionCreate call that way; only a single SessionCreate - call is allowed for each Session (however made). + acquires this new port as its bootstrap port, which all its children will inherit. + If you happen to have created the subset port on your own, you can pass the + sessionKeepCurrentBootstrap flag, and SessionCreate will use it. Note however that + you cannot supersede a prior SessionCreate call that way; only a single SessionCreate + call is allowed for each Session (however made). + This call will discard any security information established for the calling process. + In particular, any authorization handles acquired will become invalid, and so will any + keychain related information. We recommend that you call SessionCreate before + making any other security-related calls that establish rights of any kind, to the + extent this is practical. Also, we strongly recommend that you do not perform + security-related calls in any other threads while calling SessionCreate. @param flags Flags controlling how the session is created. diff --git a/SecurityServer/Authorization/Authorization.cpp b/SecurityServer/Authorization/Authorization.cpp index 2b518cf7..b8cf83c4 100644 --- a/SecurityServer/Authorization/Authorization.cpp +++ b/SecurityServer/Authorization/Authorization.cpp @@ -22,12 +22,15 @@ // This file is the unified implementation of the Authorization and AuthSession APIs. // #include +#include +#include #include #include "AuthorizationWalkers.h" #include #include #include #include +#include using namespace SecurityServer; using namespace MachPlusPlus; @@ -54,6 +57,7 @@ OSStatus AuthorizationCreate(const AuthorizationRights *rights, AuthorizationFlags flags, AuthorizationRef *authorization) { + Debug::trace(kSecTraceAuthorizationCreateStart); BEGIN_API AuthorizationBlob result; server().authCreate(rights, environment, flags, result); @@ -67,6 +71,7 @@ OSStatus AuthorizationCreate(const AuthorizationRights *rights, // If no authorizationRef is desired free the one we just created. server().authRelease(result, flags); } + Debug::trace(kSecTraceAuthorizationCreateEnd); END_API(CSSM) } @@ -78,7 +83,7 @@ OSStatus AuthorizationFree(AuthorizationRef authorization, AuthorizationFlags fl { BEGIN_API AuthorizationBlob *auth = (AuthorizationBlob *)authorization; - server().authRelease(Required(auth), flags); + server().authRelease(Required(auth, errAuthorizationInvalidRef), flags); server().returnAllocator.free(auth); END_API(CSSM) } @@ -93,9 +98,12 @@ OSStatus AuthorizationCopyRights(AuthorizationRef authorization, AuthorizationFlags flags, AuthorizationRights **authorizedRights) { + Debug::trace(kSecTraceAuthorizationCopyRightsStart); BEGIN_API AuthorizationBlob *auth = (AuthorizationBlob *)authorization; - server().authCopyRights(Required(auth), rights, environment, flags, authorizedRights); + server().authCopyRights(Required(auth, errAuthorizationInvalidRef), + rights, environment, flags, authorizedRights); + Debug::trace(kSecTraceAuthorizationCopyRightsEnd); END_API(CSSM) } @@ -107,9 +115,12 @@ OSStatus AuthorizationCopyInfo(AuthorizationRef authorization, AuthorizationString tag, AuthorizationItemSet **info) { + Debug::trace(kSecTraceAuthorizationCopyInfoStart); BEGIN_API AuthorizationBlob *auth = (AuthorizationBlob *)authorization; - server().authCopyInfo(Required(auth), tag, Required(info)); + server().authCopyInfo(Required(auth, errAuthorizationInvalidRef), + tag, Required(info)); + Debug::trace(kSecTraceAuthorizationCopyInfoEnd); END_API(CSSM) } @@ -122,7 +133,7 @@ OSStatus AuthorizationMakeExternalForm(AuthorizationRef authorization, { BEGIN_API AuthorizationBlob *auth = (AuthorizationBlob *)authorization; - server().authExternalize(Required(auth), *extForm); + server().authExternalize(Required(auth, errAuthorizationInvalidRef), *extForm); END_API(CSSM) } @@ -132,8 +143,9 @@ OSStatus AuthorizationCreateFromExternalForm(const AuthorizationExternalForm *ex BEGIN_API AuthorizationBlob result; server().authInternalize(*extForm, result); - Required(authorization) = + Required(authorization, errAuthorizationInvalidRef) = (AuthorizationRef) new(server().returnAllocator) AuthorizationBlob(result); + END_API(CSSM) } @@ -189,5 +201,171 @@ OSStatus SessionCreate(SessionCreationFlags flags, // now call the SecurityServer and tell it to initialize the (new) session server().setupSession(flags, attributes); + // retrieve the (new) session id and set it into the process environment + SecuritySessionId id = callerSecuritySession; + SessionAttributeBits attrs; + server().getSessionInfo(id, attrs); + char idString[80]; + snprintf(idString, sizeof(idString), "%lx", id); + setenv("SECURITYSESSIONID", idString, 1); + END_API(CSSM) } + + +// +// Modify Authorization rules +// + +// +// AuthorizationRightGet +// +OSStatus AuthorizationRightGet(const char *rightName, CFDictionaryRef *rightDefinition) +{ + BEGIN_API; + Required(rightName); + CssmDataContainer definition(server().returnAllocator); + + server().authorizationdbGet(rightName, definition, server().returnAllocator); + // convert rightDefinition to dictionary + + if (rightDefinition) + { + CFRef data(CFDataCreate(NULL, static_cast(definition.data()), definition.length())); + if (!data) + CssmError::throwMe(errAuthorizationInternal); + + CFRef rightDict(static_cast(CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, NULL))); + if (!rightDict + || CFGetTypeID(rightDict) != CFDictionaryGetTypeID()) + CssmError::throwMe(errAuthorizationInternal); + + CFRetain(rightDict); + *rightDefinition = rightDict; + } + + END_API(CSSM); +} + +// +// AuthorizationRightSet +// +OSStatus AuthorizationRightSet(AuthorizationRef authRef, + const char *rightName, CFTypeRef rightDefinition, + CFStringRef descriptionKey, CFBundleRef bundle, CFStringRef tableName) +{ + BEGIN_API; + Required(rightName); + AuthorizationBlob *auth = (AuthorizationBlob *)authRef; + + CFRef rightDefinitionDict; + if (rightDefinition && (CFGetTypeID(rightDefinition) == CFStringGetTypeID())) + { + rightDefinitionDict = CFDictionaryCreateMutable(NULL, 10, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + if (!rightDefinitionDict) + CssmError::throwMe(errAuthorizationInternal); + CFDictionarySetValue(rightDefinitionDict, CFSTR(kAuthorizationRightRule), rightDefinition); + } + else + if (rightDefinition && (CFGetTypeID(rightDefinition) == CFDictionaryGetTypeID())) + { + rightDefinitionDict = CFDictionaryCreateMutableCopy(NULL, 0, static_cast(rightDefinition)); + if (!rightDefinitionDict) + CssmError::throwMe(errAuthorizationInternal); + } + else + CssmError::throwMe(errAuthorizationDenied); + + if (rightDefinitionDict) + CFRelease(rightDefinitionDict); // we just assigned things that were already retained + + if (descriptionKey) + { + CFRef localizedDescriptions(CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + + if (!localizedDescriptions) + CssmError::throwMe(errAuthorizationInternal); + + // assigning to perform a retain on either + CFRef clientBundle = bundle ? bundle : CFBundleGetMainBundle(); + + // looks like a list of CFStrings: English us_en etc. + CFRef localizations(CFBundleCopyBundleLocalizations(clientBundle)); + + if (localizations) + { + // for every CFString in localizations do + CFIndex locIndex, allLocs = CFArrayGetCount(localizations); + for (locIndex = 0; locIndex < allLocs; locIndex++) + { + CFStringRef oneLocalization = static_cast(CFArrayGetValueAtIndex(localizations, locIndex)); + + if (!oneLocalization) + continue; + + // @@@ no way to get "Localized" and "strings" as constants? + CFRef locURL(CFBundleCopyResourceURLForLocalization(clientBundle, tableName ? tableName : CFSTR("Localizable"), CFSTR("strings"), NULL /*subDirName*/, oneLocalization)); + + if (!locURL) + continue; + + CFDataRef tableData; + SInt32 errCode; + CFStringRef errStr; + CFPropertyListRef stringTable; + + CFURLCreateDataAndPropertiesFromResource(CFGetAllocator(clientBundle), locURL, &tableData, NULL, NULL, &errCode); + + if (errCode) + { + CFRelease(tableData); + continue; + } + + stringTable = CFPropertyListCreateFromXMLData(CFGetAllocator(clientBundle), tableData, kCFPropertyListImmutable, &errStr); + if (errStr != NULL) { + CFRelease(errStr); + errStr = NULL; + } + CFRelease(tableData); + + CFStringRef value = static_cast(CFDictionaryGetValue(static_cast(stringTable), descriptionKey)); + if (value == NULL || CFEqual(value, CFSTR(""))) { + CFRelease(stringTable); + continue; + } else { + // oneLocalization/value into our dictionary + CFDictionarySetValue(localizedDescriptions, oneLocalization, value); + CFRelease(stringTable); + } + } + } + + // add the description as the default localization into the dictionary + CFDictionarySetValue(localizedDescriptions, CFSTR(""), descriptionKey); + + // stuff localization table into rule definition + CFDictionarySetValue(rightDefinitionDict, CFSTR(kAuthorizationRuleParameterDefaultPrompt), localizedDescriptions); + + } + + // serialize cfdictionary with data into rightDefinitionXML + CFDataRef rightDefinitionXML = CFPropertyListCreateXMLData(NULL, rightDefinitionDict); + + server().authorizationdbSet(Required(auth), rightName, CFDataGetLength(rightDefinitionXML), CFDataGetBytePtr(rightDefinitionXML)); + + END_API(CSSM); +} + +// +// AuthorizationRightRemove +// +OSStatus AuthorizationRightRemove(AuthorizationRef authRef, const char *rightName) +{ + BEGIN_API; + Required(rightName); + AuthorizationBlob *auth = (AuthorizationBlob *)authRef; + server().authorizationdbRemove(Required(auth), rightName); + END_API(CSSM); +} + diff --git a/SecurityServer/Authorization/Authorization.h b/SecurityServer/Authorization/Authorization.h index 58c49014..b49c2d52 100644 --- a/SecurityServer/Authorization/Authorization.h +++ b/SecurityServer/Authorization/Authorization.h @@ -51,7 +51,7 @@ extern "C" { /*! - @define kAuthorizationEmptyEnvironment + @defined kAuthorizationEmptyEnvironment Parameter to specify to AuthorizationCreate when no environment is being provided. */ #define kAuthorizationEmptyEnvironment NULL @@ -61,6 +61,14 @@ extern "C" { @enum AuthorizationStatus Error codes returned by Authorization API. */ + +/* + Note: the comments that appear after these errors are used to create SecErrorMessages.strings. + The comments must not be multi-line, and should be in a form meaningful to an end user. If + a different or additional comment is needed, it can be put in the header doc format, or on a + line that does not start with errZZZ. +*/ + enum { errAuthorizationSuccess = 0, /* The operation completed successfully. */ errAuthorizationInvalidSet = -60001, /* The set parameter is invalid. */ @@ -68,14 +76,15 @@ enum { errAuthorizationInvalidTag = -60003, /* The tag parameter is invalid. */ errAuthorizationInvalidPointer = -60004, /* The authorizedRights parameter is invalid. */ errAuthorizationDenied = -60005, /* The authorization was denied. */ - errAuthorizationCanceled = -60006, /* The authorization was cancled by the user. */ + errAuthorizationCanceled = -60006, /* The authorization was cancelled by the user. */ errAuthorizationInteractionNotAllowed = -60007, /* The authorization was denied since no user interaction was possible. */ errAuthorizationInternal = -60008, /* something else went wrong */ errAuthorizationExternalizeNotAllowed = -60009, /* authorization externalization denied */ errAuthorizationInternalizeNotAllowed = -60010, /* authorization internalization denied */ errAuthorizationInvalidFlags = -60011, /* invalid option flag(s) */ errAuthorizationToolExecuteFailure = -60031, /* cannot execute privileged tool */ - errAuthorizationToolEnvironmentError = -60032 /* privileged tool environment error */ + errAuthorizationToolEnvironmentError = -60032, /* privileged tool environment error */ + errAuthorizationBadAddress = -60033, /* invalid socket address requested */ }; @@ -127,16 +136,16 @@ typedef const char *AuthorizationString; /*! - @typedef AuthorizationItem + @struct AuthorizationItem Each AuthorizationItem describes a single string-named item with optional parameter value. The value must be contiguous memory of valueLength bytes; internal structure is defined separately for each name. - @param name name of the item, as an AuthorizationString. Mandatory. - @param value Pointer to the optional parameter value associated with name. + @field name name of the item, as an AuthorizationString. Mandatory. + @field valueLength Number of bytes in parameter value. Must be 0 if no parameter value. + @field value Pointer to the optional parameter value associated with name. Must be NULL if no parameter value. - @param valueLength Number of bytes in parameter value. Must be zero if no parameter. - @param reserved Reserved field. Must be set to NULL on creation. Do not modify after that. + @field flags Reserved field. Must be set to 0 on creation. Do not modify after that. */ typedef struct { AuthorizationString name; @@ -147,11 +156,11 @@ typedef struct { /*! - @typedef AuthorizationItemSet + @struct AuthorizationItemSet An AuthorizationItemSet structure represents a set of zero or more AuthorizationItems. Since it is a set it should not contain any identical AuthorizationItems. - @param count Number of items identified by items. - @param items Pointer to an array of items. + @field count Number of items identified by items. + @field items Pointer to an array of items. */ typedef struct { UInt32 count; @@ -161,7 +170,7 @@ typedef struct { /*! - @typedef AuthorizationExternalForm + @struct AuthorizationExternalForm An AuthorizationExternalForm structure can hold the externalized form of an AuthorizationRef. As such, it can be transmitted across IPC channels to other processes, which can re-internalize it to recover a valid AuthorizationRef @@ -223,7 +232,7 @@ typedef AuthorizationItemSet AuthorizationEnvironment; errAuthorizationDenied -60005 The authorization for one or more of the requested rights was denied. - errAuthorizationCanceled -60006 The authorization was cancled by the user. + errAuthorizationCanceled -60006 The authorization was cancelled by the user. errAuthorizationInteractionNotAllowed -60007 The authorization was denied since no interaction with the user was allowed. */ @@ -275,7 +284,7 @@ OSStatus AuthorizationFree(AuthorizationRef authorization, AuthorizationFlags fl @param rights (input) A rights set (see AuthorizationCreate). @param environment (input/optional) An AuthorizationItemSet containing enviroment state used when making the autorization decision. See the AuthorizationEnvironment type for details. @param flags (input) options specified by the AuthorizationFlags enum. set all unused bits to zero to allow for future expansion. - @param authorizedRights (output/optional) A pointer to a newly allocated AuthorizationInfoSet in which the authorized subset of rights are returned (authorizedRights should be deallocated by calling AuthorizationFreeInfoSet() when it is no longer needed). If NULL the only information returned is the status. Note that if the kAuthorizationFlagPreAuthorize flag was specified rights that could not be preauthorized are returned in authorizedRights, but their flags contains the kAuthorizationFlagCanNotPreAuthorize bit. + @param authorizedRights (output/optional) A pointer to a newly allocated AuthorizationInfoSet in which the authorized subset of rights are returned (authorizedRights should be deallocated by calling AuthorizationFreeItemSet() when it is no longer needed). If NULL the only information returned is the status. Note that if the kAuthorizationFlagPreAuthorize flag was specified rights that could not be preauthorized are returned in authorizedRights, but their flags contains the kAuthorizationFlagCanNotPreAuthorize bit. @result errAuthorizationSuccess 0 No error. @@ -299,7 +308,7 @@ OSStatus AuthorizationCopyRights(AuthorizationRef authorization, @param authorization (input) The authorization object on which this operation is performed. @param tag (input/optional) An optional string tag specifing which sideband information should be returned. When NULL is specified all available information is returned. @param flags (input) options specified by the AuthorizationFlags enum. set all unused bits to zero to allow for future expansion. - @param info (output) A pointer to a newly allocated AuthorizationInfoSet in which the requested sideband infomation is returned (info should be deallocated by calling AuthorizationFreeInfoSet() when it is no longer needed). + @param info (output) A pointer to a newly allocated AuthorizationInfoSet in which the requested sideband infomation is returned (info should be deallocated by calling AuthorizationFreeItemSet() when it is no longer needed). @result errAuthorizationSuccess 0 No error. diff --git a/SecurityServer/Authorization/AuthorizationDB.h b/SecurityServer/Authorization/AuthorizationDB.h new file mode 100644 index 00000000..27cb9737 --- /dev/null +++ b/SecurityServer/Authorization/AuthorizationDB.h @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + +/* + * AuthorizationDB.h -- APIs for managing the authorization policy database + * and daemons. + */ + +#ifndef _SECURITY_AUTHORIZATIONDB_H_ +#define _SECURITY_AUTHORIZATIONDB_H_ + +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +/*! + @header AuthorizationDB + Version 1.0 + + This API allows for any programs to get, modify, delete and add new right definitions to the policy database. Meta-rights specify whether and what authorization is required to make these modifications. + + AuthorizationRightSet(NULL, "com.ifoo.ifax.send", CFSTR(kRuleIsAdmin), CFSTR("You must authenticate to send a fax."), NULL, NULL) + + add a rule for letting admins send faxes using a canned rule, delegating to a pre-specified rule that authorizes everyone who is an admin. + + AuthorizationRightSet(NULL, "com.ifoo.ifax.send", [[CFSTR(kRightRule), CFSTR(kRuleIsAdmin)], [CFSTR(kRightComment), CFSTR("authorizes sending of 1 fax message")]], CFSTR("Authorize sending of a fax"), NULL, NULL) + + add identical rule, but specify additional attributes this time. + + Keep in mind while specifying a comment to be specific about what you need to authorize for (1 fax), in terms of a general message for user. The means of proof required for kRuleIsAdmin (enter username/password for example) should not be included here, since it could be configured differently. + +*/ + +/*! @define kRightRule + rule delegation key. Instead of specifying exact behavior some canned rules + are shipped that may be switched by configurable security. +*/ +#define kAuthorizationRightRule "rule" + +/*! @defined kRuleIsAdmin + canned rule values for use with rule delegation definitions: require user to be an admin. +*/ +#define kAuthorizationRuleIsAdmin "is-admin" + +/*! @defined kRuleAuthenticateAsSessionUser + canned rule value for use with rule delegation definitions: require user to authenticate as the session owner (logged-in user). +*/ +#define kAuthorizationRuleAuthenticateAsSessionUser "authenticate-session-user" + +/*! @defined kRuleAuthenticateAsAdmin + Canned rule value for use with rule delegation definitions: require user to authenticate as admin. +*/ +#define kAuthorizationRuleAuthenticateAsAdmin "authenticate-admin" + +/*! @defined kAuthorizationRuleClassAllow + Class that allows anything. +*/ +#define kAuthorizationRuleClassAllow "allow" + +/*! @defined kAuthorizationRuleClassDeny + Class that denies anything. +*/ +#define kAuthorizationRuleClassDeny "deny" + +/*! @defined kAuthorizationComment + comments for the administrator on what is being customized here; + as opposed to (localized) descriptions presented to the user. +*/ +#define kAuthorizationComment "comment" + + + +/*! + @function AuthorizationRightGet + + Retrieves a right definition as a dictionary. There are no restrictions to keep anyone from retrieving these definitions. + + @param rightName (input) the rightname (ASCII). Wildcard rightname definitions are okay. + @param rightDefinition (output/optional) the dictionary with all keys defining the right. See documented keys. Passing in NULL will just check if there is a definition. The caller is responsible for releasing the returned dictionary. + + @result errAuthorizationSuccess 0 No error. + + errAuthorizationDenied -60005 No definition found. + +*/ +OSStatus AuthorizationRightGet(const char *rightName, + CFDictionaryRef *rightDefinition); + +/*! + @function AuthorizationRightSet + + Create or update a right entry. Only normal rights can be registered (wildcard rights are denied); wildcard rights are considered to be put in by an administrator putting together a site configuration. + + @param authRef (input) authRef to authorize modifications. + @param rightName (input) the rightname (ASCII). Wildcard rightnames are not okay. + @param rightDefinition (input) a CFString of the name of a rule to use (delegate) or CFDictionary containing keys defining one. + @param descriptionKey (input/optional) a CFString to use as a key for looking up localized descriptions. If no localization is found this will be the description itself. + @param bundle (input/optional) a bundle to get localizations from if not the main bundle. + @param localeTableName (input/optional) stringtable name to get localizations from. + + @result errAuthorizationSuccess 0 added right definition successfully. + + errAuthorizationDenied -60005 Unable to create or update right definition. + + errAuthorizationCanceled -60006 Authorization was canceled by user. + + errAuthorizationInteractionNotAllowed -60007 Interaction was required but not possible. + +*/ +OSStatus AuthorizationRightSet(AuthorizationRef authRef, + const char *rightName, + CFTypeRef rightDefinition, + CFStringRef descriptionKey, + CFBundleRef bundle, + CFStringRef localeTableName); + + + +/*! + @function AuthorizationRightRemove + + Request to remove a right from the policy database. + + @param authRef (input) authRef, to be used to authorize this action. + @param rightName (input) the rightname (ASCII). Wildcard rightnames are not okay. + +*/ +OSStatus AuthorizationRightRemove(AuthorizationRef authRef, + const char *rightName); + + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SECURITY_AUTHORIZATIONDB_H_ */ + diff --git a/SecurityServer/Authorization/AuthorizationDBPlist.cpp b/SecurityServer/Authorization/AuthorizationDBPlist.cpp new file mode 100644 index 00000000..b55eec3c --- /dev/null +++ b/SecurityServer/Authorization/AuthorizationDBPlist.cpp @@ -0,0 +1,378 @@ +/* + * AuthorizationDBPlist.cpp + * Security + * + * Created by Conrad Sauerwald on Tue Mar 18 2003. + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + */ + +#include "AuthorizationDBPlist.h" + +namespace Authorization +{ + +//using Authorization::AuthorizationDBPlist; + +AuthorizationDBPlist::AuthorizationDBPlist(const char *configFile) : mFileName(configFile), mLastChecked(DBL_MIN) +{ + memset(&mRulesFileMtimespec, 0, sizeof(mRulesFileMtimespec)); +} + +//AuthorizationDBPlist::~AuthorizationDBPlist() +//{ +//} + +void AuthorizationDBPlist::sync(CFAbsoluteTime now) +{ + if (mRules.empty()) + load(now); + else + { + // Don't do anything if we checked the timestamp less than 5 seconds ago + if (mLastChecked > now - 5.0) + return; + + struct stat st; + if (stat(mFileName.c_str(), &st)) + { + Syslog::error("Stating rules file \"%s\": %s", mFileName.c_str(), strerror(errno)); + /* @@@ No rules file found, use defaults: admin group for everything. */ + //UnixError::throwMe(errno); + } + else + { + // @@@ Make sure this is the right way to compare 2 struct timespec thingies + // Technically we should check st_dev and st_ino as well since if either of those change + // we are looking at a different file too. + if (memcmp(&st.st_mtimespec, &mRulesFileMtimespec, sizeof(mRulesFileMtimespec))) + load(now); + } + } + + mLastChecked = now; +} + +void AuthorizationDBPlist::save() const +{ + if (!mConfig) + return; + + StLock _(mReadWriteLock); + + int fd = -1; + string tempFile = mFileName + ","; + + for (;;) + { + fd = open(tempFile.c_str(), O_WRONLY|O_CREAT|O_EXCL, 0644); + if (fd == -1) + { + if (errno == EEXIST) + { + unlink(tempFile.c_str()); + continue; + } + if (errno == EINTR) + continue; + else + break; + } + else + break; + } + + if (fd == -1) + { + Syslog::error("Saving rules file \"%s\": %s", tempFile.c_str(), strerror(errno)); + return; + } + + // convert config to plist + CFDataRef configXML = CFPropertyListCreateXMLData(NULL, mConfig); + + if (!configXML) + return; + + // write out data + SInt32 configSize = CFDataGetLength(configXML); + size_t bytesWritten = write(fd, CFDataGetBytePtr(configXML), configSize); + CFRelease(configXML); + + if (bytesWritten != uint32_t(configSize)) + { + if (bytesWritten == static_cast(-1)) + Syslog::error("Writing rules file \"%s\": %s", tempFile.c_str(), strerror(errno)); + else + Syslog::error("Could only write %lu out of %ld bytes from rules file \"%s\"", + bytesWritten, configSize, tempFile.c_str()); + + close(fd); + unlink(tempFile.c_str()); + } + else + { + close(fd); + if (rename(tempFile.c_str(), mFileName.c_str())) + unlink(tempFile.c_str()); + } + return; +} + +void AuthorizationDBPlist::load(CFTimeInterval now) +{ + StLock _(mReadWriteLock); + + int fd = open(mFileName.c_str(), O_RDONLY, 0); + if (fd == -1) + { + Syslog::error("Opening rules file \"%s\": %s", mFileName.c_str(), strerror(errno)); + return; + } + + struct stat st; + if (fstat(fd, &st)) + { + int error = errno; + close(fd); + UnixError::throwMe(error); + } + + + mRulesFileMtimespec = st.st_mtimespec; + + off_t fileSize = st.st_size; + + CFMutableDataRef xmlData = CFDataCreateMutable(NULL, fileSize); + CFDataSetLength(xmlData, fileSize); + void *buffer = CFDataGetMutableBytePtr(xmlData); + size_t bytesRead = read(fd, buffer, fileSize); + if (bytesRead != fileSize) + { + if (bytesRead == static_cast(-1)) + { + Syslog::error("Reading rules file \"%s\": %s", mFileName.c_str(), strerror(errno)); + CFRelease(xmlData); + return; + } + + Syslog::error("Could only read %ul out of %ul bytes from rules file \"%s\"", + bytesRead, fileSize, mFileName.c_str()); + CFRelease(xmlData); + return; + } + + CFStringRef errorString; + CFDictionaryRef configPlist = reinterpret_cast(CFPropertyListCreateFromXMLData(NULL, xmlData, kCFPropertyListMutableContainersAndLeaves, &errorString)); + + if (!configPlist) + { + char buffer[512]; + const char *error = CFStringGetCStringPtr(errorString, kCFStringEncodingUTF8); + if (error == NULL) + { + if (CFStringGetCString(errorString, buffer, 512, kCFStringEncodingUTF8)) + error = buffer; + } + + Syslog::error("Parsing rules file \"%s\": %s", mFileName.c_str(), error); + if (errorString) + CFRelease(errorString); + + CFRelease(xmlData); + return; + } + + if (CFGetTypeID(configPlist) != CFDictionaryGetTypeID()) + { + + Syslog::error("Rules file \"%s\": is not a dictionary", mFileName.c_str()); + + CFRelease(xmlData); + CFRelease(configPlist); + return; + } + + { + StLock _(mLock); + parseConfig(configPlist); + mLastChecked = now; + } + CFRelease(xmlData); + CFRelease(configPlist); + + close(fd); +} + + + +void +AuthorizationDBPlist::parseConfig(CFDictionaryRef config) +{ + // grab items from top-level dictionary that we care about + CFStringRef rightsKey = CFSTR("rights"); + CFStringRef rulesKey = CFSTR("rules"); + CFMutableDictionaryRef newRights = NULL; + CFMutableDictionaryRef newRules = NULL; + + if (!config) + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule file + + if (CFDictionaryContainsKey(config, rulesKey)) + { + newRules = reinterpret_cast(const_cast(CFDictionaryGetValue(config, rulesKey))); + } + + if (CFDictionaryContainsKey(config, rightsKey)) + { + newRights = reinterpret_cast(const_cast(CFDictionaryGetValue(config, rightsKey))); + } + + if (newRules + && newRights + && (CFDictionaryGetTypeID() == CFGetTypeID(newRules)) + && (CFDictionaryGetTypeID() == CFGetTypeID(newRights))) + { + mConfig = config; + mConfigRights = static_cast(newRights); + mConfigRules = static_cast(newRules); + mRules.clear(); + try + { + CFDictionaryApplyFunction(newRights, parseRule, this); + } + catch (...) + { + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule file + } + } + else + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule file +} + +void AuthorizationDBPlist::parseRule(const void *key, const void *value, void *context) +{ + static_cast(context)->addRight(static_cast(key), static_cast(value)); +} + +void AuthorizationDBPlist::addRight(CFStringRef key, CFDictionaryRef definition) +{ + string keyString = cfString(key); + mRules[keyString] = Rule(keyString, definition, mConfigRules); +} + +bool +AuthorizationDBPlist::validateRule(string inRightName, CFDictionaryRef inRightDefinition) const +{ + try { + Rule newRule(inRightName, inRightDefinition, mConfigRules); + if (newRule->name() == inRightName) + return true; + } + catch (...) + { + secdebug("authrule", "invalid definition for rule %s.\n", inRightName.c_str()); + } + return false; +} + +CFDictionaryRef +AuthorizationDBPlist::getRuleDefinition(string &key) +{ + CFStringRef cfKey = makeCFString(key); + StLock _(mLock); + if (CFDictionaryContainsKey(mConfigRights, cfKey)) + { + CFDictionaryRef definition = reinterpret_cast(const_cast(CFDictionaryGetValue(mConfigRights, cfKey))); + CFRelease(cfKey); + return CFDictionaryCreateCopy(NULL, definition); + } + else + { + CFRelease(cfKey); + return NULL; + } +} + +bool +AuthorizationDBPlist::existRule(string &ruleName) const +{ + map::const_iterator rule = mRules.find(ruleName); + if (rule != mRules.end()) + return true; + + return false; +} + +Rule +AuthorizationDBPlist::getRule(const AuthItemRef &inRight) const +{ + string key(inRight->name()); + // Lock the rulemap + StLock _(mLock); + + if (mRules.empty()) + return Rule(); + + for (;;) + { + map::const_iterator rule = mRules.find(key); + + if (rule != mRules.end()) + return (*rule).second; + + // no default rule + assert (key.size()); + + // any reduction of a combination of two chars is futile + if (key.size() > 2) { + // find last dot with exception of possible dot at end + string::size_type index = key.rfind('.', key.size() - 2); + // cut right after found dot, or make it match default rule + key = key.substr(0, index == string::npos ? 0 : index + 1); + } else + key.erase(); + } +} + +void +AuthorizationDBPlist::setRule(const char *inRightName, CFDictionaryRef inRuleDefinition) +{ + if (!inRuleDefinition || !mConfigRights) + MacOSError::throwMe(errAuthorizationDenied); // errInvalidRule + + CFRef keyRef(CFStringCreateWithCString(NULL, inRightName, kCFStringEncodingASCII)); + if (!keyRef) + return; + + StLock _(mLock); + + CFDictionarySetValue(mConfigRights, keyRef, inRuleDefinition); + // release modification lock here already? + save(); + mLastChecked = 0.0; +} + +void +AuthorizationDBPlist::removeRule(const char *inRightName) +{ + if (!mConfigRights) + MacOSError::throwMe(errAuthorizationDenied); + + CFRef keyRef(CFStringCreateWithCString(NULL, inRightName, kCFStringEncodingASCII)); + if (!keyRef) + return; + + StLock _(mLock); + + if (CFDictionaryContainsKey(mConfigRights, keyRef)) + { + CFDictionaryRemoveValue(mConfigRights, keyRef); + // release modification lock here already? + save(); + mLastChecked = 0.0; + } +} + + +} // end namespace Authorization diff --git a/SecurityServer/Authorization/AuthorizationDBPlist.h b/SecurityServer/Authorization/AuthorizationDBPlist.h new file mode 100644 index 00000000..9b14bdf5 --- /dev/null +++ b/SecurityServer/Authorization/AuthorizationDBPlist.h @@ -0,0 +1,62 @@ +/* + * AuthorizationDBPlist.h + * Security + * + * Created by Conrad Sauerwald on Tue Mar 18 2003. + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + */ +#ifndef _H_AUTHORIZATIONDBPLIST +#define _H_AUTHORIZATIONDBPLIST 1 + +#include +#include "AuthorizationData.h" +#include "AuthorizationRule.h" + +namespace Authorization +{ + +class AuthorizationDBPlist /* : public AuthorizationDB */ +{ +public: + AuthorizationDBPlist(const char *configFile = "/etc/authorization"); + //~AuthorizationDBPlist(); + + void sync(CFAbsoluteTime now); + bool validateRule(string inRightName, CFDictionaryRef inRightDefinition) const; + CFDictionaryRef getRuleDefinition(string &key); + + bool existRule(string &ruleName) const; + Rule getRule(const AuthItemRef &inRight) const; + + void setRule(const char *inRightName, CFDictionaryRef inRuleDefinition); + void removeRule(const char *inRightName); + +protected: + void load(CFTimeInterval now); + void save() const; + +private: + string mFileName; + +private: + enum { kTypeRight, kTypeRule }; + void parseConfig(CFDictionaryRef config); + static void parseRule(const void *key, const void *value, void *context); + void addRight(CFStringRef key, CFDictionaryRef definition); + + CFAbsoluteTime mLastChecked; + struct timespec mRulesFileMtimespec; + + map mRules; + CFRef mConfig; + CFRef mConfigRights; + CFRef mConfigRules; + + mutable Mutex mLock; // rule map lock + mutable Mutex mReadWriteLock; // file operation lock +}; + +}; /* namespace Authorization */ + +#endif /* ! _H_AUTHORIZATIONDBPLIST */ diff --git a/SecurityServer/Authorization/AuthorizationData.cpp b/SecurityServer/Authorization/AuthorizationData.cpp index 50ff00f7..4cc97ae7 100644 --- a/SecurityServer/Authorization/AuthorizationData.cpp +++ b/SecurityServer/Authorization/AuthorizationData.cpp @@ -27,185 +27,396 @@ #include "AuthorizationData.h" +#include +#include +#include + +#include "server.h" + + +// checkpw() that uses provided struct passwd +extern "C" +{ +int checkpw_internal( const struct passwd *pw, const char* password ); +} + namespace Authorization { -// -// Right class -// -Right & -Right::overlay(AuthorizationItem &item) +AuthValueRef::AuthValueRef(const AuthValue &value) : + RefPointer(new AuthValue(value)) {} + +AuthValueRef::AuthValueRef(const AuthorizationValue &value) : + RefPointer(new AuthValue(value)) {} + +AuthValue::AuthValue(const AuthorizationValue &value) : + mOwnsValue(false) { - return static_cast(item); + mValue.length = value.length; + mValue.data = value.data; } -Right * -Right::overlay(AuthorizationItem *item) +AuthValueRef::AuthValueRef(UInt32 length, void *data) : + RefPointer(new AuthValue(length, data)) {} + +AuthValue::AuthValue(UInt32 length, void *data) : + mOwnsValue(true) { - return static_cast(item); + mValue.length = length; + mValue.data = new uint8_t[length]; + if (length) + memcpy(mValue.data, data, length); } -Right::Right() +AuthValue::~AuthValue() { - name = ""; - valueLength = 0; - value = NULL; - flags = 0; + if (mOwnsValue) + delete[] reinterpret_cast(mValue.data); } -Right::Right(AuthorizationString inName, size_t inValueLength, const void *inValue) +AuthValue & +AuthValue::operator = (const AuthValue &other) { - name = inName; - valueLength = inValueLength; - value = const_cast(inValue); + if (mOwnsValue) + delete[] reinterpret_cast(mValue.data); + + mValue = other.mValue; + mOwnsValue = other.mOwnsValue; + other.mOwnsValue = false; + return *this; } -Right::~Right() +void +AuthValue::fillInAuthorizationValue(AuthorizationValue &value) { + value.length = mValue.length; + value.data = mValue.data; } -bool -Right::operator < (const Right &other) const +AuthValueVector & +AuthValueVector::operator = (const AuthorizationValueVector& valueVector) { - return strcmp(name, other.name) < 0; + clear(); + for (unsigned int i=0; i < valueVector.count; i++) + push_back(AuthValueRef(valueVector.values[i])); + return *this; } +void +AuthValueVector::copy(AuthorizationValueVector **data, size_t *length) const +{ + AuthorizationValueVector valueVector; + valueVector.count = size(); + valueVector.values = new AuthorizationValue[valueVector.count]; + int i = 0; + for (const_iterator it = begin(); it != end(); ++it, ++i) + { + (*it)->fillInAuthorizationValue(valueVector.values[i]); + } -// -// RightSet class -// -const AuthorizationRights RightSet::gEmptyRights = { 0, NULL }; + Copier flatValueVector(&valueVector); + *length = flatValueVector.length(); + *data = flatValueVector.keep(); + + delete[] valueVector.values; +} + +AuthItem::AuthItem(const AuthorizationItem &item) : + mFlags(item.flags), + mOwnsName(true), + mOwnsValue(true) +{ + if (!item.name) + MacOSError::throwMe(errAuthorizationInternal); + size_t nameLen = strlen(item.name) + 1; + mName = new char[nameLen]; + memcpy(const_cast(mName), item.name, nameLen); + + mValue.length = item.valueLength; + mValue.data = new uint8_t[item.valueLength]; + if (mValue.length) + memcpy(mValue.data, item.value, item.valueLength); +} -RightSet::RightSet(const AuthorizationRights *rights) : -mRights(const_cast(rights ? rights : &gEmptyRights)) + +AuthItem::AuthItem(AuthorizationString name) : + mName(name), + mFlags(0), + mOwnsName(false), + mOwnsValue(false) +{ + mValue.length = 0; + mValue.data = NULL; +} + +AuthItem::AuthItem(AuthorizationString name, AuthorizationValue value, AuthorizationFlags flags) : + mFlags(flags), + mOwnsName(true), + mOwnsValue(true) +{ + if (!name) + MacOSError::throwMe(errAuthorizationInternal); + size_t nameLen = strlen(name) + 1; + mName = new char[nameLen]; + memcpy(const_cast(mName), name, nameLen); + + mValue.length = value.length; + mValue.data = new uint8_t[value.length]; + if (mValue.length) + memcpy(mValue.data, value.data, value.length); +} + +AuthItem::~AuthItem() { + if (mOwnsName) + delete[] mName; + if (mOwnsValue) + delete[] reinterpret_cast(mValue.data); } -RightSet::RightSet(const RightSet &other) +bool +AuthItem::operator < (const AuthItem &other) const { - mRights = other.mRights; + return strcmp(mName, other.mName) < 0; } -RightSet::~RightSet() +AuthItem & +AuthItem::operator = (const AuthItem &other) { + if (mOwnsName) + delete[] mName; + if (mOwnsValue) + delete[] reinterpret_cast(mValue.data); + + mName = other.mName; + mValue = other.mValue; + mFlags = other.mFlags; + mOwnsName = other.mOwnsName; + other.mOwnsName = false; + mOwnsValue = other.mOwnsValue; + other.mOwnsValue = false; + return *this; } -RightSet::const_reference -RightSet::back() const +void +AuthItem::fillInAuthorizationItem(AuthorizationItem &item) { - // @@@ Should this if empty::throwMe()? - return static_cast(mRights->items[size() - 1]); + item.name = mName; + item.valueLength = mValue.length; + item.value = mValue.data; + item.flags = mFlags; } +AuthItemRef::AuthItemRef(const AuthorizationItem &item) : RefPointer(new AuthItem(item)) {} + +AuthItemRef::AuthItemRef(AuthorizationString name) : RefPointer(new AuthItem(name)) {} + +AuthItemRef::AuthItemRef(AuthorizationString name, AuthorizationValue value, AuthorizationFlags flags) : RefPointer(new AuthItem(name, value, flags)) {} + + // -// MutableRightSet class +// AuthItemSet // -MutableRightSet::MutableRightSet(size_t count, const Right &element) : -mCapacity(count) +AuthItemSet::AuthItemSet() { - mRights = new AuthorizationRights(); - mRights->items = reinterpret_cast(malloc(sizeof(Right) * mCapacity)); - if (!mRights->items) - { - delete mRights; - throw std::bad_alloc(); - } +} - mRights->count = count; - for (size_type ix = 0; ix < count; ++ix) - mRights->items[ix] = element; +AuthItemSet::~AuthItemSet() +{ } -MutableRightSet::MutableRightSet(const RightSet &other) +AuthItemSet & +AuthItemSet::operator = (const AuthorizationItemSet& itemSet) { - size_type count = other.size(); - mCapacity = count; - mRights = new AuthorizationRights(); + clear(); + + for (unsigned int i=0; i < itemSet.count; i++) + insert(AuthItemRef(itemSet.items[i])); - mRights->items = reinterpret_cast(malloc(sizeof(Right) * mCapacity)); - if (!mRights->items) + return *this; +} + +AuthItemSet::AuthItemSet(const AuthorizationItemSet *itemSet) +{ + if (itemSet) { - delete mRights; - throw std::bad_alloc(); + for (unsigned int i=0; i < itemSet->count; i++) + insert(AuthItemRef(itemSet->items[i])); } +} - mRights->count = count; - for (size_type ix = 0; ix < count; ++ix) - mRights->items[ix] = other.mRights->items[ix]; +void +AuthItemSet::copy(AuthorizationItemSet *&data, size_t &length, CssmAllocator &alloc) const +{ + AuthorizationItemSet itemSet; + itemSet.count = size(); + itemSet.items = new AuthorizationItem[itemSet.count]; + int i = 0; + for (const_iterator it = begin(); it != end(); ++it, ++i) + { + (*it)->fillInAuthorizationItem(itemSet.items[i]); + } + + Copier flatItemSet(&itemSet, alloc); + length = flatItemSet.length(); + + data = flatItemSet.keep(); + // else flatItemSet disappears again + + delete[] itemSet.items; } -MutableRightSet::~MutableRightSet() +// +// CredentialImpl class +// + +// only for testing whether this credential is usable +CredentialImpl::CredentialImpl(const string &username, const uid_t uid, const gid_t gid, bool shared) : +mUsername(username), mShared(shared), mUid(uid), mGid(gid), mCreationTime(CFAbsoluteTimeGetCurrent()), mValid(true) { - free(mRights->items); - delete mRights; } -MutableRightSet & -MutableRightSet::operator = (const RightSet &other) +// credential with validity based on username/password combination. +CredentialImpl::CredentialImpl(const string &username, const string &password, bool shared) : +mUsername(username), mShared(shared), mCreationTime(CFAbsoluteTimeGetCurrent()), mValid(false) { - size_type count = other.size(); - if (capacity() < count) - grow(count); + // Calling into DirectoryServices can be a long term operation + Server::active().longTermActivity(); + + // try short name first + const char *user = username.c_str(); + struct passwd *pw = getpwnam(user); + + do { + + if (!pw) + { + secdebug("autheval", "user %s not found, creating invalid credential", user); + break; + } - mRights->count = count; - for (size_type ix = 0; ix < count; ++ix) - mRights->items[ix] = other.mRights->items[ix]; + mUsername = string ( pw->pw_name ); + mUid = pw->pw_uid; + mGid = pw->pw_gid; - return *this; + const char *passwd = password.c_str(); + int checkpw_status = checkpw_internal(pw, passwd); + + if (checkpw_status != CHECKPW_SUCCESS) + { + secdebug("autheval", "checkpw() for user %s failed with error %d, creating invalid credential", user, checkpw_status); + break; + } + + secdebug("autheval", "checkpw() for user %s succeeded, creating%s credential", + user, mShared ? " shared" : ""); + + mValid = true; + + endpwent(); + } + while (0); } -void -MutableRightSet::swap(MutableRightSet &other) + +CredentialImpl::~CredentialImpl() { - AuthorizationRights *rights = mRights; - size_t capacity = mCapacity; - mRights = other.mRights; - mCapacity = other.mCapacity; - other.mRights = rights; - other.mCapacity = capacity; } -MutableRightSet::reference -MutableRightSet::back() +bool +CredentialImpl::operator < (const CredentialImpl &other) const +{ + if (!mShared && other.mShared) + return true; + if (!other.mShared && mShared) + return false; + + return mUsername < other.mUsername; +} + +// Returns true if this CredentialImpl should be shared. +bool +CredentialImpl::isShared() const { - // @@@ Should this if empty::throwMe()? - return static_cast(mRights->items[size() - 1]); + return mShared; } +// Merge with other void -MutableRightSet::push_back(const_reference right) +CredentialImpl::merge(const CredentialImpl &other) { - if (size() >= capacity()) - grow(capacity() + 1); + assert(mUsername == other.mUsername); - mRights->items[mRights->count] = right; - mRights->count++; + if (other.mValid && (!mValid || mCreationTime < other.mCreationTime)) + { + mCreationTime = other.mCreationTime; + mUid = other.mUid; + mGid = other.mGid; + mValid = true; + } } -void -MutableRightSet::pop_back() +// The time at which this credential was obtained. +CFAbsoluteTime +CredentialImpl::creationTime() const { - // @@@ Should this if empty::throwMe()? - if (!empty()) - mRights->count--; + return mCreationTime; +} + +// Return true iff this credential is valid. +bool +CredentialImpl::isValid() const +{ + return mValid; } void -MutableRightSet::grow(size_type min_capacity) +CredentialImpl::invalidate() +{ + mValid = false; +} + +// +// Credential class +// +Credential::Credential() : +RefPointer(NULL) { - size_type newCapacity = mCapacity * mCapacity; - if (newCapacity < min_capacity) - newCapacity = min_capacity; +} - void *newItems = realloc(mRights->items, sizeof(*mRights->items) * newCapacity); - if (!newItems) - throw std::bad_alloc(); +Credential::Credential(CredentialImpl *impl) : +RefPointer(impl) +{ +} - mRights->items = reinterpret_cast(newItems); - mCapacity = newCapacity; +Credential::Credential(const string &username, const uid_t uid, const gid_t gid, bool shared) : +RefPointer(new CredentialImpl(username, uid, gid, shared)) +{ } +Credential::Credential(const string &username, const string &password, bool shared) : +RefPointer(new CredentialImpl(username, password, shared)) +{ +} + +Credential::~Credential() +{ +} + +bool +Credential::operator < (const Credential &other) const +{ + if (!*this) + return other; + + if (!other) + return false; + + return (**this) < (*other); +} + + } // end namespace Authorization diff --git a/SecurityServer/Authorization/AuthorizationData.h b/SecurityServer/Authorization/AuthorizationData.h index 9753fc34..92466564 100644 --- a/SecurityServer/Authorization/AuthorizationData.h +++ b/SecurityServer/Authorization/AuthorizationData.h @@ -30,119 +30,144 @@ #include #include +#include +#include + +#include +#include +#include + // ptrdiff_t needed, so including STL type closest #include namespace Authorization { - -class MutableRightSet; -class RightSet; - -class Right : protected AuthorizationItem +class AuthValueOverlay : public AuthorizationValue { - friend class MutableRightSet; - friend class RightSet; public: - static Right &overlay(AuthorizationItem &item); - static Right *overlay(AuthorizationItem *item); - Right(); - Right(AuthorizationString name, size_t valueLength, const void *value); - ~Right(); - - bool operator < (const Right &other) const; - AuthorizationString rightName() const { return name; } - size_t argumentLength() const { return valueLength; } - const void *argument() const { return value; } + AuthValueOverlay(const string& stringValue) { length = stringValue.length(); data = const_cast(stringValue.c_str()); } + AuthValueOverlay(UInt32 inLength, void *inData) { length = inLength; data = inData; } }; +class AuthValueRef; -/* A RightSet is a Container and a Back Insertion Sequence, but it is not a Sequence. Also it only - implements the const members of Container and Back Insertion Sequence. */ -class RightSet +class AuthValue : public RefCount { - friend class MutableRightSet; + friend class AuthValueRef; +private: + AuthValue(const AuthValue& value) {} +protected: + AuthValue(const AuthorizationValue &value); + AuthValue(UInt32 length, void *data); public: - // Container required memebers - typedef Right value_type; - typedef const Right &const_reference; - typedef const Right *const_pointer; - typedef const_pointer const_iterator; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - - RightSet(const AuthorizationRights *rights = NULL); - RightSet(const RightSet &other); - ~RightSet(); - - size_type size() const { return mRights->count; } - size_type max_size() const { return INT_MAX; } - const_iterator begin() const { return static_cast(mRights->items); } - const_iterator end() const { return static_cast(&mRights->items[mRights->count]); } - bool empty() const { return size() == 0; } - - // Back Insertion Sequence required memebers - const_reference back() const; - - // Other convenience members - operator const AuthorizationRights *() const { return mRights; } + AuthValue &operator = (const AuthValue &other); + ~AuthValue(); + void fillInAuthorizationValue(AuthorizationValue &value); + const AuthorizationValue& value() const { return mValue; } private: - RightSet &operator = (const RightSet &other); + AuthorizationValue mValue; + mutable bool mOwnsValue; +}; -protected: - static const AuthorizationRights gEmptyRights; - AuthorizationRights *mRights; +// AuthValueRef impl +class AuthValueRef : public RefPointer +{ +public: + AuthValueRef(const AuthValue &value); + AuthValueRef(const AuthorizationValue &value); + AuthValueRef(UInt32 length, void *data); }; -/* A MutableRightSet is a Container and a Back Insertion Sequence, but it is not a Sequence. */ -class MutableRightSet : public RightSet +// vector should become a member with accessors +class AuthValueVector : public vector { + NOCOPY(AuthValueVector) public: - // Container required memebers - typedef Right &reference; - typedef Right *pointer; - typedef pointer iterator; + AuthValueVector() {} + ~AuthValueVector() {} - MutableRightSet(size_t count = 0, const Right &element = Right()); - MutableRightSet(const RightSet &other); - ~MutableRightSet(); + AuthValueVector &operator = (const AuthorizationValueVector& valueVector); + + void copy(AuthorizationValueVector **data, size_t *length) const; +}; - MutableRightSet &operator = (const RightSet &other); - iterator begin() { return static_cast(mRights->items); } - iterator end() { return static_cast(&mRights->items[mRights->count]); } - void swap(MutableRightSet &other); - // Back Insertion Sequence required memebers - reference back(); - void push_back(const_reference right); - void pop_back(); +class AuthItemRef; - // Other convenience members - size_type capacity() const { return mCapacity; } +class AuthItem : public RefCount +{ + friend class AuthItemRef; private: - void grow(size_type min_capacity); + AuthItem(const AuthItem& item); +protected: + AuthItem(const AuthorizationItem &item); + AuthItem(AuthorizationString name); + AuthItem(AuthorizationString name, AuthorizationValue value); + AuthItem(AuthorizationString name, AuthorizationValue value, AuthorizationFlags flags); - size_type mCapacity; + bool operator < (const AuthItem &other) const; + +public: + AuthItem &operator = (const AuthItem &other); + ~AuthItem(); + + void fillInAuthorizationItem(AuthorizationItem &item); + + AuthorizationString name() const { return mName; } + const AuthorizationValue& value() const { return mValue; } + string stringValue() const { return string(static_cast(mValue.data), mValue.length); } + AuthorizationFlags flags() const { return mFlags; } + void setFlags(AuthorizationFlags inFlags) { mFlags = inFlags; }; + +private: + AuthorizationString mName; + AuthorizationValue mValue; + AuthorizationFlags mFlags; + mutable bool mOwnsName; + mutable bool mOwnsValue; }; -typedef RightSet AuthItemSet; -typedef MutableRightSet MutableAuthItemSet; +class AuthItemRef : public RefPointer +{ +public: + AuthItemRef(const AuthorizationItem &item); + AuthItemRef(AuthorizationString name); + AuthItemRef(AuthorizationString name, AuthorizationValue value, AuthorizationFlags flags = 0); + + bool operator < (const AuthItemRef &other) const + { + return **this < *other; + } +}; + +// set should become a member with accessors +class AuthItemSet : public set +{ +public: + AuthItemSet(); + ~AuthItemSet(); + AuthItemSet(const AuthorizationItemSet *item); + + AuthItemSet &operator = (const AuthorizationItemSet& itemSet); + + void copy(AuthorizationItemSet *&data, size_t &length, CssmAllocator &alloc = CssmAllocator::standard()) const; +}; class FindAuthItemByRightName { public: FindAuthItemByRightName(const char *find_name) : name(find_name) { } - bool operator()( const Right& right ) + bool operator()( const AuthItemRef& authitem ) { - return (!strcmp(name, right.rightName())); + return (!strcmp(name, authitem->name())); } - bool operator()( const AuthorizationItem* item ) + bool operator()( const AuthorizationItem* authitem ) { - return (!strcmp(name, item->name)); + return (!strcmp(name, authitem->name)); } private: @@ -150,6 +175,77 @@ private: }; + +/* Credentials are less than comparable so they can be put in sets or maps. */ +class CredentialImpl : public RefCount +{ +public: + CredentialImpl(const string &username, const uid_t uid, gid_t gid, bool shared); + CredentialImpl(const string &username, const string &password, bool shared); + ~CredentialImpl(); + + bool operator < (const CredentialImpl &other) const; + + // Returns true if this credential should be shared. + bool isShared() const; + + // Merge with other + void merge(const CredentialImpl &other); + + // The time at which this credential was obtained. + CFAbsoluteTime creationTime() const; + + // Return true iff this credential is valid. + bool isValid() const; + + // Make this credential invalid. + void invalidate(); + + // We could make Rule a friend but instead we just expose this for now + inline const string& username() const { return mUsername; } + inline const uid_t uid() const { return mUid; } + inline const gid_t gid() const { return mGid; } + + +private: + // The username of the user that provided his password. + // This and mShared are what make this credential unique. + // @@@ We do not deal with the domain as of yet. + string mUsername; + + // True iff this credential is shared. + bool mShared; + + // Fields below are not used by less than operator + + // cached pw-data as returned by getpwnam(mUsername) + uid_t mUid; + gid_t mGid; + + CFAbsoluteTime mCreationTime; + bool mValid; +}; + + +/* Credentials are less than comparable so they can be put in sets or maps. */ +class Credential : public RefPointer +{ +public: + Credential(); + Credential(CredentialImpl *impl); + Credential(const string &username, const uid_t uid, gid_t gid, bool shared); + Credential(const string &username, const string &password, bool shared); + ~Credential(); + + bool operator < (const Credential &other) const; +}; + + +typedef set CredentialSet; + + + + }; // namespace Authorization #endif /* ! _H_AUTHORIZATIONDATA */ diff --git a/SecurityServer/Authorization/AuthorizationEngine.cpp b/SecurityServer/Authorization/AuthorizationEngine.cpp index 947a38a7..1412ac8b 100644 --- a/SecurityServer/Authorization/AuthorizationEngine.cpp +++ b/SecurityServer/Authorization/AuthorizationEngine.cpp @@ -26,8 +26,10 @@ */ #include "AuthorizationEngine.h" #include +#include "AuthorizationPriv.h" +#include "AuthorizationDB.h" + -#include "server.h" #include "authority.h" #include @@ -35,6 +37,7 @@ #include #include #include "session.h" +#include "server.h" #include #include @@ -43,16 +46,6 @@ #include #include #include -#include -#include -#include -#include - -// checkpw() that uses provided struct passwd -extern "C" -{ -int checkpw_internal( const char* userName, const char* password, const struct passwd *pw ); -} namespace Authorization { @@ -75,1034 +68,18 @@ OSStatus Error::osStatus() const throw() void Error::throwMe(int err) { throw Error(err); } - -// -// CredentialImpl class -// - -// only for testing whether this credential is usable -CredentialImpl::CredentialImpl(const string &username, const uid_t uid, const gid_t gid, bool shared) : -mUsername(username), mShared(shared), mUid(uid), mGid(gid), mCreationTime(CFAbsoluteTimeGetCurrent()), mValid(true) -{ -} - -// credential with validity based on username/password combination. -CredentialImpl::CredentialImpl(const string &username, const string &password, bool shared) : -mShared(shared), mCreationTime(CFAbsoluteTimeGetCurrent()), mValid(false) -{ - // try short name first - const char *user = username.c_str(); - struct passwd *pw = getpwnam(user); - - do { - - if (!pw) - { - debug("autheval", "user %s not found, creating invalid credential", user); - break; - } - - const char *passwd = password.c_str(); - int checkpw_status = checkpw_internal(user, passwd, pw); - - if (checkpw_status != CHECKPW_SUCCESS) - { - debug("autheval", "checkpw() for user %s failed with error %d, creating invalid credential", user, checkpw_status); - break; - } - - debug("autheval", "checkpw() for user %s succeeded, creating%s credential", - user, mShared ? " shared" : ""); - - mUsername = string ( pw->pw_name ); - mUid = pw->pw_uid; - mGid = pw->pw_gid; - mValid = true; - - endpwent(); - } - while (0); -} - - -CredentialImpl::~CredentialImpl() -{ -} - -bool -CredentialImpl::operator < (const CredentialImpl &other) const -{ - if (!mShared && other.mShared) - return true; - if (!other.mShared && mShared) - return false; - - return mUsername < other.mUsername; -} - -// Returns true if this CredentialImpl should be shared. -bool -CredentialImpl::isShared() const -{ - return mShared; -} - -// Merge with other -void -CredentialImpl::merge(const CredentialImpl &other) -{ - assert(mUsername == other.mUsername); - - if (other.mValid && (!mValid || mCreationTime < other.mCreationTime)) - { - mCreationTime = other.mCreationTime; - mUid = other.mUid; - mGid = other.mGid; - mValid = true; - } -} - -// The time at which this credential was obtained. -CFAbsoluteTime -CredentialImpl::creationTime() const -{ - return mCreationTime; -} - -// Return true iff this credential is valid. -bool -CredentialImpl::isValid() const -{ - return mValid; -} - -void -CredentialImpl::invalidate() -{ - mValid = false; -} - -// -// Credential class -// -Credential::Credential() : -RefPointer(NULL) -{ -} - -Credential::Credential(CredentialImpl *impl) : -RefPointer(impl) -{ -} - -Credential::Credential(const string &username, const uid_t uid, const gid_t gid, bool shared) : -RefPointer(new CredentialImpl(username, uid, gid, shared)) -{ -} - -Credential::Credential(const string &username, const string &password, bool shared) : -RefPointer(new CredentialImpl(username, password, shared)) -{ -} - -Credential::~Credential() -{ -} - -bool -Credential::operator < (const Credential &other) const -{ - if (!*this) - return other; - - if (!other) - return false; - - return (**this) < (*other); -} - - -// -// Rule class -// -CFStringRef Rule::kUserInGroupID = CFSTR("group"); -CFStringRef Rule::kTimeoutID = CFSTR("timeout"); -CFStringRef Rule::kSharedID = CFSTR("shared"); -CFStringRef Rule::kAllowRootID = CFSTR("allow-root"); -CFStringRef Rule::kDenyID = CFSTR("deny"); -CFStringRef Rule::kAllowID = CFSTR("allow"); -CFStringRef Rule::kEvalMechID = CFSTR("eval"); - - -Rule::Rule() : -mType(kUserInGroup), mGroupName("admin"), mMaxCredentialAge(300.0), mShared(true), mAllowRoot(false) -{ - // @@@ Default rule is shared admin group with 5 minute timeout -} - -Rule::Rule(CFTypeRef cfRule) -{ - // @@@ This code is ugly. Serves me right for using CF. - if (CFGetTypeID(cfRule) == CFStringGetTypeID()) - { - CFStringRef tag = reinterpret_cast(cfRule); - if (CFEqual(kAllowID, tag)) - { - debug("authrule", "rule always allow"); - mType = kAllow; - } - else if (CFEqual(kDenyID, tag)) - { - debug("authrule", "rule always deny"); - mType = kDeny; - } - else - Error::throwMe(); - } - else if (CFGetTypeID(cfRule) == CFDictionaryGetTypeID()) - { - CFDictionaryRef dict = reinterpret_cast(cfRule); - CFTypeRef groupTag = CFDictionaryGetValue(dict, kUserInGroupID); - - // Probably a user in group rule - if (groupTag) - { - if (CFGetTypeID(groupTag) != CFStringGetTypeID()) - Error::throwMe(); - - mType = kUserInGroup; - - CFStringRef group = reinterpret_cast(groupTag); - char buffer[512]; - const char *ptr = CFStringGetCStringPtr(group, kCFStringEncodingUTF8); - if (ptr == NULL) - { - if (CFStringGetCString(group, buffer, 512, kCFStringEncodingUTF8)) - ptr = buffer; - else - Error::throwMe(); - } - - mGroupName = string(ptr); - - mMaxCredentialAge = DBL_MAX; - CFTypeRef timeoutTag = CFDictionaryGetValue(dict, kTimeoutID); - if (timeoutTag) - { - if (CFGetTypeID(timeoutTag) != CFNumberGetTypeID()) - Error::throwMe(); - CFNumberGetValue(reinterpret_cast(timeoutTag), kCFNumberDoubleType, &mMaxCredentialAge); - } - - CFTypeRef sharedTag = CFDictionaryGetValue(dict, kSharedID); - mShared = false; - if (sharedTag) - { - if (CFGetTypeID(sharedTag) != CFBooleanGetTypeID()) - Error::throwMe(); - mShared = CFBooleanGetValue(reinterpret_cast(sharedTag)); - } - - CFTypeRef allowRootTag = CFDictionaryGetValue(dict, kAllowRootID); - mAllowRoot = false; - if (allowRootTag) - { - if (CFGetTypeID(allowRootTag) != CFBooleanGetTypeID()) - Error::throwMe(); - mAllowRoot = CFBooleanGetValue(reinterpret_cast(allowRootTag)); - } - debug("authrule", "rule user in group \"%s\" timeout %g%s%s", - mGroupName.c_str(), mMaxCredentialAge, mShared ? " shared" : "", - mAllowRoot ? " allow-root" : ""); - } - else - { - CFTypeRef mechTag = CFDictionaryGetValue(dict, kEvalMechID); - if (mechTag) - { - if (CFGetTypeID(mechTag) != CFStringGetTypeID()) - Error::throwMe(); - - mType = kEvalMech; - - CFStringRef eval = reinterpret_cast(mechTag); - char buffer[512]; - const char *ptr = CFStringGetCStringPtr(eval, kCFStringEncodingUTF8); - if (ptr == NULL) - { - if (CFStringGetCString(eval, buffer, 512, kCFStringEncodingUTF8)) - ptr = buffer; - else - Error::throwMe(); - } - mEvalDef = string(ptr); - } - else - Error::throwMe(); - } - - } -} - -Rule::Rule(const Rule &other) : -mType(other.mType), -mGroupName(other.mGroupName), -mMaxCredentialAge(other.mMaxCredentialAge), -mShared(other.mShared), -mAllowRoot(other.mAllowRoot), -mEvalDef(other.mEvalDef) -{ -} - -Rule & -Rule::operator = (const Rule &other) -{ - mType = other.mType; - mGroupName = other.mGroupName; - mMaxCredentialAge = other.mMaxCredentialAge; - mShared = other.mShared; - mAllowRoot = other.mAllowRoot; - mEvalDef = other.mEvalDef; - return *this; -} - -Rule::~Rule() -{ -} - - -OSStatus -Rule::evaluateMechanism(const AuthorizationEnvironment *environment, AuthorizationToken &auth, CredentialSet &outCredentials) -{ - assert(mType == kEvalMech); - - if (mEvalDef.length() == 0) // no definition - return kAuthorizationResultAllow; - - // mechanisms are split by commas - vector mechanismNames; - { - string::size_type cursor = 0, comma = 0; - string token = ""; - - while (cursor < mEvalDef.length()) - { - comma = mEvalDef.find(',', cursor); - if (comma == string::npos) - comma = mEvalDef.length(); - - token = mEvalDef.substr(cursor, comma - cursor); - - // skip empty tokens - if (token.length() > 0) - mechanismNames.push_back(token); - - cursor = comma + 1; - } - } - - // @@@ configuration does not support arguments - const AuthorizationValueVector arguments = { 0, NULL }; - MutableAuthItemSet *context = NULL; - AuthItemSet *hints = NULL; - AuthorizationItemSet *outHints = NULL, *outContext = NULL; - bool userInteraction = true; - - CssmAllocator& alloc = CssmAllocator::standard(); - - AuthorizationResult result = kAuthorizationResultAllow; - vector::iterator currentMechanism = mechanismNames.begin(); - - while ( (result == kAuthorizationResultAllow) && - (currentMechanism != mechanismNames.end()) ) // iterate mechanisms - { - AuthorizationItemSet *inHints, *inContext; - - // release after invocation, ignored for first pass - if (outContext) - { - inContext = outContext; - debug("SSevalMech", "set up context %p as input", inContext); - delete context; - context = new MutableAuthItemSet(inContext); - } - else - { - inContext = &auth.infoSet(); // returns deep copy - debug("SSevalMech", "set up stored context %p as input", inContext); - delete context; - context = new MutableAuthItemSet(inContext); - } - - if (outHints) - { - inHints = outHints; - debug("SSevalMech", "set up hints %p as input", inHints); - delete hints; - hints = new AuthItemSet(outHints); - } - else - { - inHints = NULL; - debug("SSevalMech", "set up environment hints %p as input", environment); - delete hints; - hints = new AuthItemSet(environment); - } - - string::size_type extPlugin = currentMechanism->find(':'); - if (extPlugin != string::npos) - { - // no whitespace removal - string pluginIn(currentMechanism->substr(0, extPlugin)); - string mechanismIn(currentMechanism->substr(extPlugin + 1)); - debug("SSevalMech", "external mech %s:%s", pluginIn.c_str(), mechanismIn.c_str()); - - bool mechExecOk = false; // successfully ran a mechanism - - try - { - Process &cltProc = Server::active().connection().process; - // Authorization preserves creator's UID in setuid processes - uid_t cltUid = (cltProc.uid() != 0) ? cltProc.uid() : auth.creatorUid(); - debug("SSevalMech", "Mechanism invocation by process %d (UID %d)", cltProc.pid(), cltUid); - QueryInvokeMechanism client(cltUid, auth); - - mechExecOk = client(pluginIn, mechanismIn, &arguments, *hints, *context, &result, outHints, outContext); - debug("SSevalMech", "new context %p, new hints %p", outContext, outHints); - } - catch (...) { - debug("SSevalMech", "exception from mech eval or client death"); - // various server problems, but only if it really failed - if (mechExecOk != true) - result = kAuthorizationResultUndefined; - } - - debug("SSevalMech", "evaluate(plugin: %s, mechanism: %s) %s, result: %lu.", pluginIn.c_str(), mechanismIn.c_str(), (mechExecOk == true) ? "succeeded" : "failed", result); - debug("SSevalMech", "mech eval okay"); - - // Things worked and there is new context, so get rid of old - if (mechExecOk) - { - if (inContext) - { - debug("SSevalMech", "release input context %p", inContext); - alloc.free(inContext); - } - if (inHints) - { - debug("SSevalMech", "release input hints %p", inHints); - alloc.free(inHints); - } - } - else - { - // reset previous context and hints - debug("SSevalMech", "resetting previous input context %p and hints %p", inContext, inHints); - outContext = inContext; - outHints = inHints; - } - } - else - { - // internal mechanisms - no glue - if (*currentMechanism == "authinternal") - { - debug("SSevalMech", "evaluate authinternal"); - result = kAuthorizationResultDeny; - do { - MutableAuthItemSet::iterator found = find_if(context->begin(), context->end(), FindAuthItemByRightName(kAuthorizationEnvironmentUsername) ); - if (found == context->end()) - break; - string username(static_cast(found->argument()), found->argumentLength()); - debug("SSevalMech", "found username"); - found = find_if(context->begin(), context->end(), FindAuthItemByRightName(kAuthorizationEnvironmentPassword) ); - if (found == context->end()) - break; - string password(static_cast(found->argument()), found->argumentLength()); - debug("SSevalMech", "found password"); - Credential newCredential(username, password, true); // create a new shared credential - if (newCredential->isValid()) - { - outCredentials.clear(); // only keep last one - debug("SSevalMech", "inserting new credential"); - outCredentials.insert(newCredential); - result = kAuthorizationResultAllow; - } else - result = kAuthorizationResultDeny; - } while (0); - } - else - if (*currentMechanism == "push_hints_to_context") - { - debug("SSevalMech", "evaluate push_hints_to_context"); - userInteraction = false; // we can't talk to the user - result = kAuthorizationResultAllow; // snarfcredential doesn't block evaluation, ever, it may restart - // clean up current context - if (inContext) - { - debug("SSevalMech", "release input context %p", inContext); - alloc.free(inContext); - } - // create out context from input hints, no merge - // @@@ global copy template not being invoked... - outContext = Copier(*hints).keep(); - } - else - if (*currentMechanism == "switch_to_user") - { - try { - Process &cltProc = Server::active().connection().process; - // Authorization preserves creator's UID in setuid processes - uid_t cltUid = (cltProc.uid() != 0) ? cltProc.uid() : auth.creatorUid(); - debug("SSevalMech", "terminating agent at request of process %d (UID %d)\n", cltProc.pid(), cltUid); - QueryTerminateAgent client(cltUid, auth); - client(); - } catch (...) { - // Not our agent - } - result = kAuthorizationResultAllow; - } - - - - } - - - // we own outHints and outContext - switch(result) - { - case kAuthorizationResultAllow: - debug("SSevalMech", "result allow"); - currentMechanism++; - break; - case kAuthorizationResultDeny: - debug("SSevalMech", "result deny"); - if (inContext) - { - debug("SSevalMech", "abort eval, release input context %p", inContext); - alloc.free(inContext); - } - if (inHints) - { - debug("SSevalMech", "abort eval, release input hints %p", inHints); - alloc.free(inHints); - } - outContext = outHints = NULL; // making sure things get reset - if (userInteraction) - { - currentMechanism = mechanismNames.begin(); - result = kAuthorizationResultAllow; // stay in loop - } - break; - case kAuthorizationResultUndefined: - debug("SSevalMech", "result undefined"); - break; // abort evaluation - case kAuthorizationResultUserCanceled: - debug("SSevalMech", "result canceled"); - break; // stop evaluation, return some sideband - default: - break; // abort evaluation - } - } - - // End of evaluation, if last step produced meaningful data, incorporate - if ((result == kAuthorizationResultAllow) || - (result == kAuthorizationResultUserCanceled)) // @@@ can only pass back sideband through context - { - debug("SSevalMech", "make new context %p available", outContext); - auth.setInfoSet(*outContext); - outContext = NULL; - } - - // clean up last outContext and outHints, if any - if (outContext) - { - debug("SSevalMech", "release output context %p", outContext); - alloc.free(outContext); - } - if (outHints) - { - debug("SSevalMech", "release output hints %p", outHints); - alloc.free(outHints); - } - - // deny on user cancel - switch(result) - { - case kAuthorizationResultUndefined: - return errAuthorizationDenied; - case kAuthorizationResultDeny: - return errAuthorizationDenied; - default: - return errAuthorizationSuccess; // @@@ cancel should return cancelled - } -} - -OSStatus -Rule::evaluate(const Right &inRight, - const AuthorizationEnvironment *environment, AuthorizationFlags flags, - CFAbsoluteTime now, const CredentialSet *inCredentials, CredentialSet &credentials, - AuthorizationToken &auth) -{ - switch (mType) - { - case kAllow: - debug("autheval", "rule is always allow"); - return errAuthorizationSuccess; - case kDeny: - debug("autheval", "rule is always deny"); - return errAuthorizationDenied; - case kUserInGroup: - debug("autheval", "rule is user in group"); - break; - case kEvalMech: - debug("autheval", "rule evalutes mechanisms"); - return evaluateMechanism(environment, auth, credentials); - default: - Error::throwMe(); - } - - // If we got here, this is a kUserInGroup type rule, let's start looking for a - // credential that is satisfactory - - // Zeroth -- Here is an extra special saucy ugly hack to allow authorizations - // created by a proccess running as root to automatically get a right. - if (mAllowRoot && auth.creatorUid() == 0) - { - debug("autheval", "creator of authorization has uid == 0 granting right %s", - inRight.rightName()); - return errAuthorizationSuccess; - } - - // First -- go though the credentials we either already used or obtained during this authorize operation. - for (CredentialSet::const_iterator it = credentials.begin(); it != credentials.end(); ++it) - { - OSStatus status = evaluate(inRight, environment, now, *it, true); - if (status != errAuthorizationDenied) - { - // add credential to authinfo - auth.setCredentialInfo(*it); - return status; - } - } - - // Second -- go though the credentials passed in to this authorize operation by the state management layer. - if (inCredentials) - { - for (CredentialSet::const_iterator it = inCredentials->begin(); it != inCredentials->end(); ++it) - { - OSStatus status = evaluate(inRight, environment, now, *it, false); - if (status == errAuthorizationSuccess) - { - // Add the credential we used to the output set. - // @@@ Deal with potential credential merges. - credentials.insert(*it); - // add credential to authinfo - auth.setCredentialInfo(*it); - - return status; - } - else if (status != errAuthorizationDenied) - return status; - } - } - - // Finally -- We didn't find the credential in our passed in credential lists. Obtain a new credential if - // our flags let us do so. - if (!(flags & kAuthorizationFlagExtendRights)) - return errAuthorizationDenied; - - if (!(flags & kAuthorizationFlagInteractionAllowed)) - return errAuthorizationInteractionNotAllowed; - - Process &cltProc = Server::active().connection().process; - // Authorization preserves creator's UID in setuid processes - uid_t cltUid = (cltProc.uid() != 0) ? cltProc.uid() : auth.creatorUid(); - IFDEBUG(debug("autheval", "Auth query from process %d (UID %d)", cltProc.pid(), cltUid)); - QueryAuthorizeByGroup query(cltUid, auth); - - string usernamehint; - // username hint is taken from the user who created the authorization, unless it's clearly ineligible - if (uid_t uid = auth.creatorUid()) { - struct passwd *pw = getpwuid(uid); - if (pw != NULL) - { - // avoid hinting a locked account (ie. root) - if ( (pw->pw_passwd == NULL) || - strcmp(pw->pw_passwd, "*") ) { - // Check if username will authorize the request and set username to - // be used as a hint to the user if so - if (evaluate(inRight, environment, now, Credential(pw->pw_name, pw->pw_uid, pw->pw_gid, mShared), true) == errAuthorizationSuccess) { - - // user long name as hint - usernamehint = string( pw->pw_gecos ); -#if 0 - // minus other gecos crud - size_t comma = usernamehint.find(','); - if (comma) - usernamehint = usernamehint.substr(0, comma); - // or fallback to short username -#endif - if (usernamehint.size() == 0) - usernamehint = string( pw->pw_name ); - } //fi - } //fi - endpwent(); - } - } - - Credential newCredential; - // @@@ Keep the default reason the same, so the agent only gets userNotInGroup or invalidPassphrase - SecurityAgent::Reason reason = SecurityAgent::userNotInGroup; - // @@@ Hardcoded 3 tries to avoid infinite loops. - for (int tryCount = 0; tryCount < 3; ++tryCount) - { - // Obtain a new credential. Anything but success is considered an error. - OSStatus status = obtainCredential(query, inRight, environment, usernamehint.c_str(), newCredential, reason); - if (status) - return status; - - // Now we have successfully obtained a credential we need to make sure it authorizes the requested right - if (!newCredential->isValid()) - reason = SecurityAgent::invalidPassphrase; - else { - status = evaluate(inRight, environment, now, newCredential, true); - if (status == errAuthorizationSuccess) - { - // Add the new credential we obtained to the output set. - // @@@ Deal with potential credential merges. - credentials.insert(newCredential); - query.done(); - - // add credential to authinfo - auth.setCredentialInfo(newCredential); - - return errAuthorizationSuccess; - } - else if (status != errAuthorizationDenied) - return status; - reason = SecurityAgent::userNotInGroup; - } - } - - query.cancel(SecurityAgent::tooManyTries); - return errAuthorizationDenied; -} - -// Return errAuthorizationSuccess if this rule allows access based on the specified credential, -// return errAuthorizationDenied otherwise. -OSStatus -Rule::evaluate(const Right &inRight, const AuthorizationEnvironment *environment, CFAbsoluteTime now, - const Credential &credential, bool ignoreShared) -{ - assert(mType == kUserInGroup); - - // Get the username from the credential - const char *user = credential->username().c_str(); - - // If the credential is not valid or it's age is more than the allowed maximum age - // for a credential, deny. - if (!credential->isValid()) - { - debug("autheval", "credential for user %s is invalid, denying right %s", user, inRight.rightName()); - return errAuthorizationDenied; - } - - if (now - credential->creationTime() > mMaxCredentialAge) - { - debug("autheval", "credential for user %s has expired, denying right %s", user, inRight.rightName()); - return errAuthorizationDenied; - } - - if (!ignoreShared && !mShared && credential->isShared()) - { - debug("autheval", "shared credential for user %s cannot be used, denying right %s", user, inRight.rightName()); - return errAuthorizationDenied; - } - - // A root (uid == 0) user can do anything - if (credential->uid() == 0) - { - debug("autheval", "user %s has uid 0, granting right %s", user, inRight.rightName()); - return errAuthorizationSuccess; - } - - const char *groupname = mGroupName.c_str(); - struct group *gr = getgrnam(groupname); - if (!gr) - return errAuthorizationDenied; - - // Is this the default group of this user? - // PR-2875126 declares gr_gid int, as opposed to advertised (getgrent(3)) gid_t - // When this is fixed this warning should go away. - if (credential->gid() == gr->gr_gid) - { - debug("autheval", "user %s has group %s(%d) as default group, granting right %s", - user, groupname, gr->gr_gid, inRight.rightName()); - endgrent(); - return errAuthorizationSuccess; - } - - for (char **group = gr->gr_mem; *group; ++group) - { - if (!strcmp(*group, user)) - { - debug("autheval", "user %s is a member of group %s, granting right %s", - user, groupname, inRight.rightName()); - endgrent(); - return errAuthorizationSuccess; - } - } - - debug("autheval", "user %s is not a member of group %s, denying right %s", - user, groupname, inRight.rightName()); - endgrent(); - return errAuthorizationDenied; -} - -OSStatus -Rule::obtainCredential(QueryAuthorizeByGroup &query, const Right &inRight, - const AuthorizationEnvironment *environment, const char *usernameHint, Credential &outCredential, SecurityAgent::Reason reason) -{ - char nameBuffer[SecurityAgent::maxUsernameLength]; - char passphraseBuffer[SecurityAgent::maxPassphraseLength]; - OSStatus status = errAuthorizationDenied; - - try { - if (query(mGroupName.c_str(), usernameHint, nameBuffer, passphraseBuffer, reason)) - status = noErr; - } catch (const CssmCommonError &err) { - status = err.osStatus(); - } catch (...) { - status = errAuthorizationInternal; - } - if (status == CSSM_ERRCODE_USER_CANCELED) - { - debug("auth", "canceled obtaining credential for user in group %s", mGroupName.c_str()); - return errAuthorizationCanceled; - } - if (status == CSSM_ERRCODE_NO_USER_INTERACTION) - { - debug("auth", "user interaction not possible obtaining credential for user in group %s", mGroupName.c_str()); - return errAuthorizationInteractionNotAllowed; - } - - if (status != noErr) - { - debug("auth", "failed obtaining credential for user in group %s", mGroupName.c_str()); - return status; - } - - debug("auth", "obtained credential for user %s", nameBuffer); - - string username(nameBuffer); - string password(passphraseBuffer); - outCredential = Credential(username, password, mShared); - return errAuthorizationSuccess; -} - - // // Engine class // -Engine::Engine(const char *configFile) : -mLastChecked(DBL_MIN) +Engine::Engine(const char *configFile) : mAuthdb(configFile) { - mRulesFileName = new char[strlen(configFile) + 1]; - strcpy(mRulesFileName, configFile); - memset(&mRulesFileMtimespec, 0, sizeof(mRulesFileMtimespec)); } Engine::~Engine() { - delete[] mRulesFileName; -} - -void -Engine::updateRules(CFAbsoluteTime now) -{ - StLock _(mLock); - if (mRules.empty()) - readRules(); - else - { - // Don't do anything if we checked the timestamp less than 5 seconds ago - if (mLastChecked > now - 5.0) - return; - - struct stat st; - if (stat(mRulesFileName, &st)) - { - Syslog::error("Stating rules file \"%s\": %s", mRulesFileName, strerror(errno)); - /* @@@ No rules file found, use defaults: admin group for everything. */ - //UnixError::throwMe(errno); - } - else - { - // @@@ Make sure this is the right way to compare 2 struct timespec thingies - // Technically we should check st_dev and st_ino as well since if either of those change - // we are looking at a different file too. - if (memcmp(&st.st_mtimespec, &mRulesFileMtimespec, sizeof(mRulesFileMtimespec))) - readRules(); - } - } - - mLastChecked = now; -} - -void -Engine::readRules() -{ - // Make an entry in the mRules map that matches every right to the default Rule. - mRules.clear(); - mRules.insert(RuleMap::value_type(string(), Rule())); - - int fd = open(mRulesFileName, O_RDONLY, 0); - if (fd == -1) - { - Syslog::error("Opening rules file \"%s\": %s", mRulesFileName, strerror(errno)); - return; - } - - try - { - struct stat st; - if (fstat(fd, &st)) - UnixError::throwMe(errno); - - mRulesFileMtimespec = st.st_mtimespec; - - off_t fileSize = st.st_size; - - CFRef xmlData(CFDataCreateMutable(NULL, fileSize)); - CFDataSetLength(xmlData, fileSize); - void *buffer = CFDataGetMutableBytePtr(xmlData); - size_t bytesRead = read(fd, buffer, fileSize); - if (bytesRead != fileSize) - { - if (bytesRead == static_cast(-1)) - { - Syslog::error("Reading rules file \"%s\": %s", mRulesFileName, strerror(errno)); - return; - } - - Syslog::error("Could only read %ul out of %ul bytes from rules file \"%s\"", - bytesRead, fileSize, mRulesFileName); - return; - } - - CFStringRef errorString; - CFRef newRoot(reinterpret_cast - (CFPropertyListCreateFromXMLData(NULL, xmlData, kCFPropertyListImmutable, &errorString))); - if (!newRoot) - { - char buffer[512]; - const char *error = CFStringGetCStringPtr(errorString, kCFStringEncodingUTF8); - if (error == NULL) - { - if (CFStringGetCString(errorString, buffer, 512, kCFStringEncodingUTF8)) - error = buffer; - } - - Syslog::error("Parsing rules file \"%s\": %s", mRulesFileName, error); - return; - } - - if (CFGetTypeID(newRoot) != CFDictionaryGetTypeID()) - { - Syslog::error("Rules file \"%s\": is not a dictionary", mRulesFileName); - return; - } - - parseRules(newRoot); - } - catch(...) - { - close(fd); - } - - close(fd); -} - -void -Engine::parseRules(CFDictionaryRef rules) -{ - CFDictionaryApplyFunction(rules, parseRuleCallback, this); -} - -void -Engine::parseRuleCallback(const void *key, const void *value, void *context) -{ - Engine *engine = reinterpret_cast(context); - if (CFGetTypeID(key) != CFStringGetTypeID()) - return; - - CFStringRef right = reinterpret_cast(key); - engine->parseRule(right, reinterpret_cast(value)); -} - -void -Engine::parseRule(CFStringRef cfRight, CFTypeRef cfRule) -{ - char buffer[512]; - const char *ptr = CFStringGetCStringPtr(cfRight, kCFStringEncodingUTF8); - if (ptr == NULL) - { - if (CFStringGetCString(cfRight, buffer, 512, kCFStringEncodingUTF8)) - ptr = buffer; - } - - string right(ptr); - try - { - mRules[right] = Rule(cfRule); - debug("authrule", "added rule for right \"%s\"", right.c_str()); - } - catch (...) - { - Syslog::error("Rules file \"%s\" right \"%s\": rule is invalid", mRulesFileName, ptr); - } } -/*! - @function AuthorizationEngine::getRule - - Look up the Rule for a given right. - - @param inRight (input) the right for which we want a rule. - - @results The Rule for right -*/ -Rule -Engine::getRule(const Right &inRight) const -{ - string key(inRight.rightName()); - // Lock the rulemap - StLock _(mLock); - for (;;) - { - RuleMap::const_iterator it = mRules.find(key); - if (it != mRules.end()) - { - debug("authrule", "right \"%s\" using right expression \"%s\"", inRight.rightName(), key.c_str()); - return it->second; - } - - // no default rule - assert (key.size()); - - // any reduction of a combination of two chars is futile - if (key.size() > 2) { - // find last dot with exception of possible dot at end - string::size_type index = key.rfind('.', key.size() - 2); - // cut right after found dot, or make it match default rule - key = key.substr(0, index == string::npos ? 0 : index + 1); - } else - key.erase(); - } -} - /*! @function AuthorizationEngine::authorize @@ -1118,41 +95,38 @@ Engine::getRule(const Right &inRight) const @results Returns errAuthorizationSuccess if all rights requested are authorized, or if the kAuthorizationFlagPartialRights flag was specified. Might return other status values like errAuthorizationDenied, errAuthorizationCanceled or errAuthorizationInteractionNotAllowed */ OSStatus -Engine::authorize(const RightSet &inRights, const AuthorizationEnvironment *environment, +Engine::authorize(const AuthItemSet &inRights, const AuthItemSet &environment, AuthorizationFlags flags, const CredentialSet *inCredentials, CredentialSet *outCredentials, - MutableRightSet *outRights, AuthorizationToken &auth) + AuthItemSet &outRights, AuthorizationToken &auth) { CredentialSet credentials; - MutableRightSet rights; OSStatus status = errAuthorizationSuccess; // Get current time of day. CFAbsoluteTime now = CFAbsoluteTimeGetCurrent(); // Update rules from database if needed - updateRules(now); + mAuthdb.sync(now); // Check if a credential was passed into the environment and we were asked to extend the rights - if (environment && (flags & kAuthorizationFlagExtendRights)) + if (flags & kAuthorizationFlagExtendRights) { - const AuthorizationItem *username = NULL, *password = NULL; + string username, password; bool shared = false; - for (UInt32 ix = 0; ix < environment->count; ++ix) + for (AuthItemSet::iterator item = environment.begin(); item != environment.end(); item ++) { - const AuthorizationItem &item = environment->items[ix]; - if (!strcmp(item.name, kAuthorizationEnvironmentUsername)) - username = &item; - if (!strcmp(item.name, kAuthorizationEnvironmentPassword)) - password = &item; - if (!strcmp(item.name, kAuthorizationEnvironmentShared)) + if (!strcmp((*item)->name(), kAuthorizationEnvironmentUsername)) + username = (*item)->stringValue(); + else if (!strcmp((*item)->name(), kAuthorizationEnvironmentPassword)) + password = (*item)->stringValue(); + else if (!strcmp((*item)->name(), kAuthorizationEnvironmentShared)) shared = true; } - if (username && password) + if (username.length()) { // Let's create a credential from the passed in username and password. - Credential newCredential(string(reinterpret_cast(username->value), username->valueLength), - string(reinterpret_cast(password->value), password->valueLength), shared); + Credential newCredential(username, password, shared); // If it's valid insert it into the credentials list. Normally this is // only done if it actually authorizes a requested right, but for this // special case (environment) we do it even when no rights are being requested. @@ -1160,17 +134,35 @@ Engine::authorize(const RightSet &inRights, const AuthorizationEnvironment *envi credentials.insert(newCredential); } } + + // generate hints for every authorization + AuthItemSet environmentToClient = environment; - RightSet::const_iterator end = inRights.end(); - for (RightSet::const_iterator it = inRights.begin(); it != end; ++it) + AuthItemSet::const_iterator end = inRights.end(); + for (AuthItemSet::const_iterator it = inRights.begin(); it != end; ++it) { // Get the rule for each right we are trying to obtain. - OSStatus result = getRule(*it).evaluate(*it, environment, flags, now, - inCredentials, credentials, auth); + const Rule &toplevelRule = mAuthdb.getRule(*it); + OSStatus result = toplevelRule->evaluate(*it, toplevelRule, environmentToClient, flags, now, inCredentials, credentials, auth); + secdebug("autheval", "evaluate rule %s for right %s returned %ld.", toplevelRule->name().c_str(), (*it)->name(), result); + + { + CodeSigning::OSXCode *processCode = Server::connection().process.clientCode(); + string processName = processCode ? processCode->canonicalPath() : "unknown"; + CodeSigning::OSXCode *authCreatorCode = auth.creatorCode(); + string authCreatorName = authCreatorCode ? authCreatorCode->canonicalPath() : "unknown"; + + if (result == errAuthorizationSuccess) + Syslog::info("Succeeded authorizing right %s by process %s for authorization created by %s.", (*it)->name(), processName.c_str(), authCreatorName.c_str()); + else if (result == errAuthorizationDenied) + Syslog::notice("Failed to authorize right %s by process %s for authorization created by %s.", (*it)->name(), processName.c_str(), authCreatorName.c_str()); + } + if (result == errAuthorizationSuccess) - rights.push_back(*it); + outRights.insert(*it); else if (result == errAuthorizationDenied || result == errAuthorizationInteractionNotAllowed) { + // add creator pid to authorization token if (!(flags & kAuthorizationFlagPartialRights)) { status = result; @@ -1192,10 +184,138 @@ Engine::authorize(const RightSet &inRights, const AuthorizationEnvironment *envi if (outCredentials) outCredentials->swap(credentials); - if (outRights) - outRights->swap(rights); return status; } +OSStatus +Engine::verifyModification(string inRightName, bool remove, + const CredentialSet *inCredentials, CredentialSet *outCredentials, AuthorizationToken &auth) +{ + // Validate right + + // meta rights are constructed as follows: + // we don't allow setting of wildcard rights, so you can only be more specific + // note that you should never restrict things with a wildcard right without disallowing + // changes to the entire domain. ie. + // system.privilege. -> never + // config.add.system.privilege. -> never + // config.modify.system.privilege. -> never + // config.delete.system.privilege. -> never + // For now we don't allow any configuration of configuration rules + // config.config. -> never + + string rightnameToCheck; + + // @@@ verify right name is is not NULL or zero length + if (inRightName.length() == 0) + return errAuthorizationDenied; + + // @@@ make sure it isn't a wildcard right by checking trailing "." + if ( *(inRightName.rbegin()) == '.') + return errAuthorizationDenied; + + // @@@ make sure it isn't a configure right by checking it doesn't start with config. + if (inRightName.find(kConfigRight, 0) != string::npos) + { + // special handling of meta right change: + // config.add. config.modify. config.remove. config.{}. + // check for config. (which always starts with config.config.) + rightnameToCheck = string(kConfigRight) + inRightName; + } + else + { + // regular check of rights + bool existingRule = mAuthdb.existRule(inRightName); + if (!remove) + { + if (existingRule) + rightnameToCheck = string(kAuthorizationConfigRightModify) + inRightName; + else + rightnameToCheck = string(kAuthorizationConfigRightAdd) + inRightName; + } + else + { + if (existingRule) + rightnameToCheck = string(kAuthorizationConfigRightRemove) + inRightName; + else + { + secdebug("engine", "rule %s doesn't exist.", inRightName.c_str()); + return errAuthorizationSuccess; // doesn't exist, done + } + } + } + + + AuthItemSet rights, environment, outRights; + rights.insert(AuthItemRef(rightnameToCheck.c_str())); + secdebug("engine", "authorizing %s for db modification.", rightnameToCheck.c_str()); + return authorize(rights, environment, kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights, inCredentials, outCredentials, outRights, auth); +} + +OSStatus +Engine::getRule(string &inRightName, CFDictionaryRef *outRuleDefinition) +{ + // Get current time of day. + CFAbsoluteTime now = CFAbsoluteTimeGetCurrent(); + + // Update rules from database if needed + mAuthdb.sync(now); + + CFDictionaryRef definition = mAuthdb.getRuleDefinition(inRightName); + if (definition) + { + if (outRuleDefinition) + *outRuleDefinition = definition; + else + CFRelease(definition); + + return errAuthorizationSuccess; + } + + return errAuthorizationDenied; +} + +OSStatus +Engine::setRule(const char *inRightName, CFDictionaryRef inRuleDefinition, const CredentialSet *inCredentials, CredentialSet *outCredentials, AuthorizationToken &auth) +{ + // Get current time of day. + CFAbsoluteTime now = CFAbsoluteTimeGetCurrent(); + + // Update rules from database if needed + mAuthdb.sync(now); + + // Validate rule by constructing it from the passed dictionary + if (!mAuthdb.validateRule(inRightName, inRuleDefinition)) + return errAuthorizationDenied; // @@@ separate error for this? + + OSStatus result = verifyModification(inRightName, false /*setting, not removing*/, inCredentials, outCredentials, auth); + if (result != errAuthorizationSuccess) + return result; + + // set the rule for the right and save the database + mAuthdb.setRule(inRightName, inRuleDefinition); + + return errAuthorizationSuccess; +} + +OSStatus +Engine::removeRule(const char *inRightName, const CredentialSet *inCredentials, CredentialSet *outCredentials, AuthorizationToken &auth) +{ + // Get current time of day. + CFAbsoluteTime now = CFAbsoluteTimeGetCurrent(); + + // Update rules from database if needed + mAuthdb.sync(now); + + OSStatus result = verifyModification(inRightName, true /*removing*/, inCredentials, outCredentials, auth); + if (result != errAuthorizationSuccess) + return result; + + // set the rule for the right and save the database + mAuthdb.removeRule(inRightName); + + return errAuthorizationSuccess; +} + } // end namespace Authorization diff --git a/SecurityServer/Authorization/AuthorizationEngine.h b/SecurityServer/Authorization/AuthorizationEngine.h index fcd47d33..dc81591c 100644 --- a/SecurityServer/Authorization/AuthorizationEngine.h +++ b/SecurityServer/Authorization/AuthorizationEngine.h @@ -30,23 +30,21 @@ #include #include #include "AuthorizationData.h" +#include "AuthorizationDBPlist.h" -#include #include #include -#include "agentquery.h" #include #include #include #include -#include -#include -#include class AuthorizationToken; +using Authorization::AuthorizationDBPlist; + namespace Authorization { @@ -63,122 +61,6 @@ public: }; -/* Credentials are less than comparable so they can be put in sets or maps. */ -class CredentialImpl : public RefCount -{ -public: - CredentialImpl(const string &username, const uid_t uid, gid_t gid, bool shared); - CredentialImpl(const string &username, const string &password, bool shared); - ~CredentialImpl(); - - bool operator < (const CredentialImpl &other) const; - - // Returns true if this credential should be shared. - bool isShared() const; - - // Merge with other - void merge(const CredentialImpl &other); - - // The time at which this credential was obtained. - CFAbsoluteTime creationTime() const; - - // Return true iff this credential is valid. - bool isValid() const; - - // Make this credential invalid. - void invalidate(); - - // We could make Rule a friend but instead we just expose this for now - inline const string& username() const { return mUsername; } - inline const uid_t uid() const { return mUid; } - inline const gid_t gid() const { return mGid; } - - -private: - // The username of the user that provided his password. - // This and mShared are what make this credential unique. - // @@@ We do not deal with the domain as of yet. - string mUsername; - - // True iff this credential is shared. - bool mShared; - - // Fields below are not used by less than operator - - // cached pw-data as returned by getpwnam(mUsername) - uid_t mUid; - gid_t mGid; - - CFAbsoluteTime mCreationTime; - bool mValid; -}; - - -/* Credentials are less than comparable so they can be put in sets or maps. */ -class Credential : public RefPointer -{ -public: - Credential(); - Credential(CredentialImpl *impl); - Credential(const string &username, const uid_t uid, gid_t gid, bool shared); - Credential(const string &username, const string &password, bool shared); - ~Credential(); - - bool operator < (const Credential &other) const; -}; - - -typedef set CredentialSet; - - -class Rule -{ -public: - Rule(); - Rule(CFTypeRef cfRule); - Rule(const Rule &other); - Rule &operator = (const Rule &other); - ~Rule(); - - OSStatus evaluate(const Right &inRight, const AuthorizationEnvironment *environment, - AuthorizationFlags flags, CFAbsoluteTime now, - const CredentialSet *inCredentials, CredentialSet &credentials, - AuthorizationToken &auth); - -private: - OSStatus evaluate(const Right &inRight, const AuthorizationEnvironment *environment, - CFAbsoluteTime now, const Credential &credential, bool ignoreShared); - OSStatus obtainCredential(QueryAuthorizeByGroup &client, const Right &inRight, - const AuthorizationEnvironment *environment, const char *usernameHint, - Credential &outCredential, SecurityAgent::Reason reason); - OSStatus evaluateMechanism(const AuthorizationEnvironment *environment, AuthorizationToken &auth, CredentialSet &outCredentials); - - - enum Type - { - kDeny, - kAllow, - kUserInGroup, - kEvalMech - } mType; - - string mGroupName; - CFTimeInterval mMaxCredentialAge; - bool mShared; - bool mAllowRoot; - string mEvalDef; - - static CFStringRef kUserInGroupID; - static CFStringRef kTimeoutID; - static CFStringRef kSharedID; - static CFStringRef kAllowRootID; - static CFStringRef kDenyID; - static CFStringRef kAllowID; - static CFStringRef kEvalMechID; - -}; - - /* The engine which performs the actual authentication and authorization computations. The implementation of a typical call to AuthorizationCreate would look like: @@ -203,25 +85,18 @@ public: Engine(const char *configFile); ~Engine(); - OSStatus authorize(const RightSet &inRights, const AuthorizationEnvironment *environment, + OSStatus authorize(const AuthItemSet &inRights, const AuthItemSet &environment, AuthorizationFlags flags, const CredentialSet *inCredentials, CredentialSet *outCredentials, - MutableRightSet *outRights, AuthorizationToken &auth); -private: - void updateRules(CFAbsoluteTime now); - void readRules(); - void parseRules(CFDictionaryRef rules); - static void parseRuleCallback(const void *key, const void *value, void *context); - void parseRule(CFStringRef right, CFTypeRef rule); - - Rule getRule(const Right &inRight) const; + AuthItemSet &outRights, AuthorizationToken &auth); + OSStatus getRule(string &inRightName, CFDictionaryRef *outRuleDefinition); + OSStatus setRule(const char *inRightName, CFDictionaryRef inRuleDefinition, const CredentialSet *inCredentials, CredentialSet *outCredentials, AuthorizationToken &auth); + OSStatus removeRule(const char *inRightName, const CredentialSet *inCredentials, CredentialSet *outCredentials, AuthorizationToken &auth); - char *mRulesFileName; - CFAbsoluteTime mLastChecked; - struct timespec mRulesFileMtimespec; - - typedef map RuleMap; +private: + OSStatus verifyModification(string inRightName, bool remove, + const CredentialSet *inCredentials, CredentialSet *outCredentials, AuthorizationToken &auth); - RuleMap mRules; + AuthorizationDBPlist mAuthdb; mutable Mutex mLock; }; diff --git a/SecurityServer/Authorization/AuthorizationPlugin.h b/SecurityServer/Authorization/AuthorizationPlugin.h index 06c3a5ee..acd7b095 100644 --- a/SecurityServer/Authorization/AuthorizationPlugin.h +++ b/SecurityServer/Authorization/AuthorizationPlugin.h @@ -127,11 +127,11 @@ enum }; enum { - kAuthorizationPluginInterfaceVersion = 0, + kAuthorizationPluginInterfaceVersion = 0 }; enum { - kAuthorizationCallbacksVersion = 0, + kAuthorizationCallbacksVersion = 0 }; diff --git a/SecurityServer/Authorization/AuthorizationPriv.h b/SecurityServer/Authorization/AuthorizationPriv.h new file mode 100644 index 00000000..55cfb1d2 --- /dev/null +++ b/SecurityServer/Authorization/AuthorizationPriv.h @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * AuthorizationPriv.h -- Authorization SPIs + * Private APIs for implementing access control in applications and daemons. + * + */ + +#ifndef _SECURITY_AUTHORIZATIONPRIV_H_ +#define _SECURITY_AUTHORIZATIONPRIV_H_ + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + + +/*! + @header AuthorizationPriv + Version 1.1 04/2003 + + This header contains private APIs for authorization services. + This is the private extension of , a public header file. +*/ + + +/* meta-rightname prefixes that configure authorization for policy changes */ + +/*! + @defined kConfigRightAdd + meta-rightname for prefix adding rights. +*/ +#define kAuthorizationConfigRightAdd "config.add." +/*! + @defined kConfigRightModify + meta-rightname prefix for modifying rights. +*/ +#define kAuthorizationConfigRightModify "config.modify." +/*! + @defined kConfigRightRemove + meta-rightname prefix for removing rights. +*/ +#define kAuthorizationConfigRightRemove "config.remove." +/*! + @defined kConfigRight + meta-rightname prefix. +*/ +#define kConfigRight "config." + +/*! + @defined kRuleIsRoot + canned rule for daemon to daemon convincing (see AuthorizationDB.h for public ones) +*/ +#define kAuthorizationRuleIsRoot "is-root" + +/* rule classes the specify behavior */ + +/*! @defined kAuthorizationRuleClass + Specifying rule class +*/ +#define kAuthorizationRuleClass "class" + +/*! @defined kAuthorizationRuleClassUser + Specifying user class +*/ +#define kAuthorizationRuleClassUser "user" + +/*! @defined kAuthorizationRuleClassMechanisms + Specifying evaluate-mechanisms class +*/ +#define kAuthorizationRuleClassMechanisms "evaluate-mechanisms" + +/* rule attributes to specify above classes */ + +/*! @defined kAuthorizationRuleParameterGroup + string, group specification for user rules. +*/ +#define kAuthorizationRuleParameterGroup "group" + +/*! @defined kAuthorizationRuleParameterKofN + number, k specification for k-of-n +*/ +#define kAuthorizationRuleParameterKofN "k-of-n" + +/*! @defined kAuthorizationRuleParameterRules + rules specification for rule delegation (incl. k-of-n) +*/ +#define kAuthorizationRuleParameterRules "rules" + +/*! @defined kAuthorizationRuleParameterMechanisms + mechanism specification, a sequence of mechanisms to be evaluated */ +#define kAuthorizationRuleParameterMechanisms "mechanisms" + +/*! @defined kAuthorizationRightParameterTimeout + timeout if any when a remembered right expires. + special values: + - not specified retains previous behavior: most privileged, credential based. + - zero grants the right once +(can be achieved with zero credential timeout, needed?) + - all other values are interpreted as number of seconds since granted. +*/ +#define kAuthorizationRightParameterTimeout "timeout-right" + +/*! @defined kAuthorizationRuleParameterCredentialTimeout + timeout if any for the use of cached credentials when authorizing rights. + - not specified allows for any credentials regardless of age; rights will be remembered in authorizations, removing a credential does not stop it from granting this right, specifying a zero timeout for the right will delegate it back to requiring a credential. + - all other values are interpreted as number of seconds since the credential was created + - zero only allows for the use of credentials created "now" // This is deprecated by means of specifying zero for kRightTimeout +*/ +#define kAuthorizationRuleParameterCredentialTimeout "timeout" + +/*! @defined kAuthorizationRuleParameterCredentialShared + boolean that indicates whether credentials acquired during authorization are added to the shared pool. +*/ +#define kAuthorizationRuleParameterCredentialShared "shared" + +/*! @defined kAuthorizationRuleParameterAllowRoot + boolean that indicates whether to grant a right purely because the caller is root */ +#define kAuthorizationRuleParameterAllowRoot "allow-root" + +/*! @defined kAuthorizationRuleParameterCredentialSessionOwner + boolean that indicates whether to grant a right based on a valid session-owner credential */ +#define kAuthorizationRuleParameterCredentialSessionOwner "session-owner" + +/*! @defined kRuleDefaultPrompt + dictionary of localization-name and localized prompt pairs */ +#define kAuthorizationRuleParameterDefaultPrompt "default-prompt" + +/*! + @function AuthorizationBindPrivilegedPort + + @param fileDescriptor (input) + + @param name (input) + + @param authorization (input) The authorization object on which this operation is performed. + + @param flags (input) Bit mask of option flags to this call. + + @result errAuthorizationSuccess 0 No error. +*/ +OSStatus AuthorizationBindPrivilegedPort(int fileDescriptor, + const struct sockaddr_in *name, + AuthorizationRef authorization, + AuthorizationFlags flags); + +int __authorization_bind(int s, const struct sockaddr_in *name); + + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SECURITY_AUTHORIZATIONPRIV_H_ */ diff --git a/SecurityServer/Authorization/AuthorizationRule.cpp b/SecurityServer/Authorization/AuthorizationRule.cpp new file mode 100644 index 00000000..6592038a --- /dev/null +++ b/SecurityServer/Authorization/AuthorizationRule.cpp @@ -0,0 +1,1171 @@ +/* + * AuthorizationRule.cpp + * Security + * + * Created by Conrad Sauerwald on Wed Mar 19 2003. + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + */ + +#include "AuthorizationRule.h" +#include "AuthorizationTags.h" +#include "AuthorizationDB.h" +#include "AuthorizationPriv.h" +#include "authority.h" +#include "server.h" +#include "process.h" + + +#include +#include +#include + + +// +// Rule class +// +namespace Authorization { + +CFStringRef RuleImpl::kUserGroupID = CFSTR(kAuthorizationRuleParameterGroup); +CFStringRef RuleImpl::kTimeoutID = CFSTR(kAuthorizationRuleParameterCredentialTimeout); +CFStringRef RuleImpl::kSharedID = CFSTR(kAuthorizationRuleParameterCredentialShared); +CFStringRef RuleImpl::kAllowRootID = CFSTR(kAuthorizationRuleParameterAllowRoot); +CFStringRef RuleImpl::kMechanismsID = CFSTR(kAuthorizationRuleParameterMechanisms); +CFStringRef RuleImpl::kSessionOwnerID = CFSTR(kAuthorizationRuleParameterCredentialSessionOwner); +CFStringRef RuleImpl::kKofNID = CFSTR(kAuthorizationRuleParameterKofN); +CFStringRef RuleImpl::kPromptID = CFSTR(kAuthorizationRuleParameterDefaultPrompt); + +CFStringRef RuleImpl::kRuleClassID = CFSTR(kAuthorizationRuleClass); +CFStringRef RuleImpl::kRuleAllowID = CFSTR(kAuthorizationRuleClassAllow); +CFStringRef RuleImpl::kRuleDenyID = CFSTR(kAuthorizationRuleClassDeny); +CFStringRef RuleImpl::kRuleUserID = CFSTR(kAuthorizationRuleClassUser); +CFStringRef RuleImpl::kRuleDelegateID = CFSTR(kAuthorizationRightRule); +CFStringRef RuleImpl::kRuleMechanismsID = CFSTR(kAuthorizationRuleClassMechanisms); + +string +RuleImpl::Attribute::getString(CFDictionaryRef config, CFStringRef key, bool required = false, char *defaultValue = NULL) +{ + CFTypeRef value = CFDictionaryGetValue(config, key); + if (value && (CFGetTypeID(value) == CFStringGetTypeID())) + { + CFStringRef stringValue = reinterpret_cast(value); + char buffer[512]; + const char *ptr = CFStringGetCStringPtr(stringValue, kCFStringEncodingUTF8); + if (ptr == NULL) + { + if (CFStringGetCString(stringValue, buffer, sizeof(buffer), kCFStringEncodingUTF8)) + ptr = buffer; + else + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + } + + return string(ptr); + } + else + if (!required) + return string(defaultValue); + else + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule +} + +double +RuleImpl::Attribute::getDouble(CFDictionaryRef config, CFStringRef key, bool required = false, double defaultValue = 0.0) +{ + double doubleValue = 0; + + CFTypeRef value = CFDictionaryGetValue(config, key); + if (value && (CFGetTypeID(value) == CFNumberGetTypeID())) + { + CFNumberGetValue(reinterpret_cast(value), kCFNumberDoubleType, &doubleValue); + } + else + if (!required) + return defaultValue; + else + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + + return doubleValue; +} + +bool +RuleImpl::Attribute::getBool(CFDictionaryRef config, CFStringRef key, bool required = false, bool defaultValue = false) +{ + bool boolValue = false; + CFTypeRef value = CFDictionaryGetValue(config, key); + + if (value && (CFGetTypeID(value) == CFBooleanGetTypeID())) + { + boolValue = CFBooleanGetValue(reinterpret_cast(value)); + } + else + if (!required) + return defaultValue; + else + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + + return boolValue; +} + +// add reference to string that we're modifying +void +RuleImpl::Attribute::setString(CFMutableDictionaryRef config, CFStringRef key, string &value) +{ + CFStringRef cfstringValue = CFStringCreateWithCString(NULL /*allocator*/, value.c_str(), kCFStringEncodingUTF8); + + if (cfstringValue) + { + CFDictionarySetValue(config, key, cfstringValue); + CFRelease(cfstringValue); + } + else + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid attribute +} + +void +RuleImpl::Attribute::setDouble(CFMutableDictionaryRef config, CFStringRef key, double value) +{ + CFNumberRef doubleValue = CFNumberCreate(NULL /*allocator*/, kCFNumberDoubleType, doubleValue); + + if (doubleValue) + { + CFDictionarySetValue(config, key, doubleValue); + CFRelease(doubleValue); + } + else + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid attribute +} + +void +RuleImpl::Attribute::setBool(CFMutableDictionaryRef config, CFStringRef key, bool value) +{ + if (value) + CFDictionarySetValue(config, key, kCFBooleanTrue); + else + CFDictionarySetValue(config, key, kCFBooleanFalse); +} + +vector +RuleImpl::Attribute::getVector(CFDictionaryRef config, CFStringRef key, bool required = false) +{ + vector valueArray; + + CFTypeRef value = CFDictionaryGetValue(config, key); + if (value && (CFGetTypeID(value) == CFArrayGetTypeID())) + { + CFArrayRef evalArray = reinterpret_cast(value); + + for (int index=0; index < CFArrayGetCount(evalArray); index++) + { + CFTypeRef arrayValue = CFArrayGetValueAtIndex(evalArray, index); + if (arrayValue && (CFGetTypeID(arrayValue) == CFStringGetTypeID())) + { + CFStringRef stringValue = reinterpret_cast(arrayValue); + char buffer[512]; + const char *ptr = CFStringGetCStringPtr(stringValue, kCFStringEncodingUTF8); + if (ptr == NULL) + { + if (CFStringGetCString(stringValue, buffer, sizeof(buffer), kCFStringEncodingUTF8)) + ptr = buffer; + else + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + } + valueArray.push_back(string(ptr)); + } + } + } + else + if (required) + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + + return valueArray; +} + + +bool RuleImpl::Attribute::getLocalizedPrompts(CFDictionaryRef config, map &localizedPrompts) +{ + CFIndex numberOfPrompts = 0; + CFDictionaryRef promptsDict; + if (CFDictionaryContainsKey(config, kPromptID)) + { + promptsDict = reinterpret_cast(CFDictionaryGetValue(config, kPromptID)); + if (promptsDict && (CFGetTypeID(promptsDict) == CFDictionaryGetTypeID())) + numberOfPrompts = CFDictionaryGetCount(promptsDict); + } + if (numberOfPrompts == 0) + return false; + + const void *keys[numberOfPrompts+1]; + const void *values[numberOfPrompts+1]; + CFDictionaryGetKeysAndValues(promptsDict, &keys[0], &values[0]); + + while (numberOfPrompts-- > 0) + { + CFStringRef keyRef = reinterpret_cast(keys[numberOfPrompts]); + CFStringRef valueRef = reinterpret_cast(values[numberOfPrompts]); + if (!keyRef || (CFGetTypeID(keyRef) != CFStringGetTypeID())) + continue; + if (!valueRef || (CFGetTypeID(valueRef) != CFStringGetTypeID())) + continue; + string key = cfString(keyRef); + string value = cfString(valueRef); + localizedPrompts["description"+key] = value; + } + + return true; +} + + +// default rule +RuleImpl::RuleImpl() : +mType(kUser), mGroupName("admin"), mMaxCredentialAge(300.0), mShared(true), mAllowRoot(false), mSessionOwner(false), mTries(0) +{ + // XXX/cs read default descriptions from somewhere + // @@@ Default rule is shared admin group with 5 minute timeout +} + +// return rule built from rule definition; throw if invalid. +RuleImpl::RuleImpl(const string &inRightName, CFDictionaryRef cfRight, CFDictionaryRef cfRules) : mRightName(inRightName) +{ + // @@@ make sure cfRight is non mutable and never used that way + + if (CFGetTypeID(cfRight) != CFDictionaryGetTypeID()) + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + + mTries = 0; + + string classTag = Attribute::getString(cfRight, kRuleClassID, false, ""); + + if (classTag.length()) + { + if (classTag == kAuthorizationRuleClassAllow) + { + secdebug("authrule", "%s : rule allow", inRightName.c_str()); + mType = kAllow; + } + else if (classTag == kAuthorizationRuleClassDeny) + { + secdebug("authrule", "%s : rule deny", inRightName.c_str()); + mType = kDeny; + } + else if (classTag == kAuthorizationRuleClassUser) + { + mType = kUser; + mGroupName = Attribute::getString(cfRight, kUserGroupID); + // grab other user-in-group attributes + mMaxCredentialAge = Attribute::getDouble(cfRight, kTimeoutID, false, DBL_MAX); + mShared = Attribute::getBool(cfRight, kSharedID); + mAllowRoot = Attribute::getBool(cfRight, kAllowRootID); + mSessionOwner = Attribute::getBool(cfRight, kSessionOwnerID); + // authorization tags can have eval now too + mEvalDef = Attribute::getVector(cfRight, kMechanismsID); + mTries = 3; + + secdebug("authrule", "%s : rule user in group \"%s\" timeout %g%s%s", + inRightName.c_str(), + mGroupName.c_str(), mMaxCredentialAge, mShared ? " shared" : "", + mAllowRoot ? " allow-root" : ""); + + } + else if (classTag == kAuthorizationRuleClassMechanisms) + { + secdebug("authrule", "%s : rule evaluate mechanisms", inRightName.c_str()); + mType = kEvaluateMechanisms; + // mechanisms to evaluate + mEvalDef = Attribute::getVector(cfRight, kMechanismsID, true); + } + else if (classTag == kAuthorizationRightRule) + { + assert(cfRules); // this had better not be a rule + secdebug("authrule", "%s : rule delegate rule", inRightName.c_str()); + mType = kRuleDelegation; + + // string or + string ruleDefString = Attribute::getString(cfRight, kRuleDelegateID, false, ""); + if (ruleDefString.length()) + { + CFStringRef ruleDefRef = makeCFString(ruleDefString); + CFDictionaryRef cfRuleDef = reinterpret_cast(CFDictionaryGetValue(cfRules, ruleDefRef)); + if (ruleDefRef) + CFRelease(ruleDefRef); + if (!cfRuleDef || CFGetTypeID(cfRuleDef) != CFDictionaryGetTypeID()) + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + mRuleDef.push_back(Rule(ruleDefString, cfRuleDef, NULL)); + } + else // array + { + vector ruleDef = Attribute::getVector(cfRight, kRuleDelegateID, true); + for (vector::const_iterator it = ruleDef.begin(); it != ruleDef.end(); it++) + { + CFStringRef ruleNameRef = makeCFString(*it); + CFDictionaryRef cfRuleDef = reinterpret_cast(CFDictionaryGetValue(cfRules, ruleNameRef)); + if (ruleNameRef) + CFRelease(ruleNameRef); + if (!cfRuleDef || (CFGetTypeID(cfRuleDef) != CFDictionaryGetTypeID())) + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + mRuleDef.push_back(Rule(*it, cfRuleDef, NULL)); + } + } + + mKofN = int(Attribute::getDouble(cfRight, kKofNID, false, 0.0)); + if (mKofN) + mType = kKofN; + + } + else + { + secdebug("authrule", "%s : rule class unknown %s.", inRightName.c_str(), classTag.c_str()); + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + } + } + else + { + // no class tag means, this is the abbreviated specification from the API + // it _must_ have a definition for "rule" which will be used as a delegate + // it may have a comment (not extracted here) + // it may have a default prompt, or a whole dictionary of languages (not extracted here) + assert(cfRules); + mType = kRuleDelegation; + string ruleName = Attribute::getString(cfRight, kRuleDelegateID, true); + secdebug("authrule", "%s : rule delegate rule (1): %s", inRightName.c_str(), ruleName.c_str()); + CFStringRef ruleNameRef = makeCFString(ruleName); + CFDictionaryRef cfRuleDef = reinterpret_cast(CFDictionaryGetValue(cfRules, ruleNameRef)); + if (ruleNameRef) + CFRelease(ruleNameRef); + if (!cfRuleDef || CFGetTypeID(cfRuleDef) != CFDictionaryGetTypeID()) + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + mRuleDef.push_back(Rule(ruleName, cfRuleDef, NULL)); + } + + Attribute::getLocalizedPrompts(cfRight, mLocalizedPrompts); +} + +/* +RuleImpl::~Rule() +{ +} +*/ + +void +RuleImpl::setAgentHints(const AuthItemRef &inRight, const Rule &inTopLevelRule, AuthItemSet &environmentToClient, AuthorizationToken &auth) const +{ + string authorizeString(inRight->name()); + environmentToClient.insert(AuthItemRef(AGENT_HINT_AUTHORIZE_RIGHT, AuthValueOverlay(authorizeString))); + + // XXX/cs pid/uid/client should only be added when we're ready to call the agent + pid_t cPid = Server::connection().process.pid(); + environmentToClient.insert(AuthItemRef(AGENT_HINT_CLIENT_PID, AuthValueOverlay(sizeof(pid_t), &cPid))); + + uid_t cUid = auth.creatorUid(); + environmentToClient.insert(AuthItemRef(AGENT_HINT_CLIENT_UID, AuthValueOverlay(sizeof(uid_t), &cUid))); + + pid_t creatorPid = auth.creatorPid(); + environmentToClient.insert(AuthItemRef(AGENT_HINT_CREATOR_PID, AuthValueOverlay(sizeof(pid_t), &creatorPid))); + + { + CodeSigning::OSXCode *osxcode = auth.creatorCode(); + if (!osxcode) + MacOSError::throwMe(errAuthorizationDenied); + + string encodedBundle = osxcode->encode(); + char bundleType = (encodedBundle.c_str())[0]; // yay, no accessor + string bundlePath = osxcode->canonicalPath(); + + environmentToClient.insert(AuthItemRef(AGENT_HINT_CLIENT_TYPE, AuthValueOverlay(sizeof(bundleType), &bundleType))); + environmentToClient.insert(AuthItemRef(AGENT_HINT_CLIENT_PATH, AuthValueOverlay(bundlePath))); + } + + map defaultPrompts = inTopLevelRule->localizedPrompts(); + + if (defaultPrompts.empty()) + defaultPrompts = localizedPrompts(); + + if (!defaultPrompts.empty()) + { + map::const_iterator it; + for (it = defaultPrompts.begin(); it != defaultPrompts.end(); it++) + { + const string &key = it->first; + const string &value = it->second; + environmentToClient.insert(AuthItemRef(key.c_str(), AuthValueOverlay(value))); + } + } + + // add rulename as a hint + string ruleName = name(); + environmentToClient.insert(AuthItemRef(AGENT_HINT_AUTHORIZE_RULE, AuthValueOverlay(ruleName))); +} + +string +RuleImpl::agentNameForAuth(const AuthorizationToken &auth) const +{ + uint8_t hash[20]; + AuthorizationBlob authBlob = auth.handle(); + CssmData hashedData = CssmData::wrap(&hash, sizeof(hash)); + CssmData data = CssmData::wrap(&authBlob, sizeof(authBlob)); + CssmClient::Digest ctx(Server::csp(), CSSM_ALGID_SHA1); + try { + ctx.digest(data, hashedData); + } + catch (CssmError &e) + { + secdebug("auth", "digesting authref failed (%lu)", e.cssmError()); + return string("SecurityAgentMechanism"); + } + + uint8_t *point = static_cast(hashedData.data()); + for (uint8_t i=0; i < hashedData.length(); point++, i++) + { + uint8 value = (*point % 62) + '0'; + if (value > '9') value += 7; + if (value > 'Z') value += 6; + *point = value; + } + return string(static_cast(hashedData.data()), hashedData.length()); +} + +OSStatus +RuleImpl::evaluateMechanism(const AuthItemRef &inRight, const AuthItemSet &environment, AuthorizationToken &auth, CredentialSet &outCredentials) const +{ + string agentName = agentNameForAuth(auth); + + // @@@ configuration does not support arguments + AuthValueVector arguments; + // XXX/cs Move this up - we shouldn't know how to retrieve the ingoing context + AuthItemSet context = auth.infoSet(); + AuthItemSet hints = environment; + + AuthorizationResult result = kAuthorizationResultAllow; + vector::const_iterator currentMechanism = mEvalDef.begin(); + + while ( (result == kAuthorizationResultAllow) && + (currentMechanism != mEvalDef.end()) ) // iterate mechanisms + { + string::size_type extPlugin = currentMechanism->find(':'); + if (extPlugin != string::npos) + { + // no whitespace removal + string pluginIn(currentMechanism->substr(0, extPlugin)); + string mechanismIn(currentMechanism->substr(extPlugin + 1)); + secdebug("SSevalMech", "external mech %s:%s", pluginIn.c_str(), mechanismIn.c_str()); + + bool mechExecOk = false; // successfully ran a mechanism + + Process &cltProc = Server::active().connection().process; + // Authorization preserves creator's UID in setuid processes + uid_t cltUid = (cltProc.uid() != 0) ? cltProc.uid() : auth.creatorUid(); + secdebug("SSevalMech", "Mechanism invocation by process %d (UID %d)", cltProc.pid(), cltUid); + QueryInvokeMechanism client(cltUid, auth, agentName.c_str()); + try + { + mechExecOk = client(pluginIn, mechanismIn, arguments, hints, context, &result); + } + catch (...) { + secdebug("SSevalMech", "exception from mech eval or client death"); + // various server problems, but only if it really failed + if (mechExecOk != true) + result = kAuthorizationResultUndefined; + } + + secdebug("SSevalMech", "evaluate(plugin: %s, mechanism: %s) %s, result: %lu.", pluginIn.c_str(), mechanismIn.c_str(), (mechExecOk == true) ? "succeeded" : "failed", result); + } + else + { + // internal mechanisms - no glue + if (*currentMechanism == "authinternal") + { + secdebug("SSevalMech", "evaluate authinternal"); + result = kAuthorizationResultDeny; + do { + AuthItemSet::iterator found = find_if(context.begin(), context.end(), FindAuthItemByRightName(kAuthorizationEnvironmentUsername) ); + if (found == context.end()) + break; + string username(static_cast((*found)->value().data), (*found)->value().length); + secdebug("SSevalMech", "found username"); + found = find_if(context.begin(), context.end(), FindAuthItemByRightName(kAuthorizationEnvironmentPassword) ); + if (found == context.end()) + break; + string password(static_cast((*found)->value().data), (*found)->value().length); + secdebug("SSevalMech", "found password"); + Credential newCredential(username, password, true); // create a new shared credential + + if (newCredential->isValid()) + Syslog::info("authinternal authenticated user %s (uid %lu) for right %s.", newCredential->username().c_str(), newCredential->uid(), inRight->name()); + else + // we can't be sure that the user actually exists so inhibit logging of uid + Syslog::error("authinternal failed to authenticate user %s for right %s.", newCredential->username().c_str(), inRight->name()); + + if (newCredential->isValid()) + { + outCredentials.clear(); // only keep last one + secdebug("SSevalMech", "inserting new credential"); + outCredentials.insert(newCredential); + result = kAuthorizationResultAllow; + } else + result = kAuthorizationResultDeny; + } while (0); + } + else + if (*currentMechanism == "push_hints_to_context") + { + secdebug("SSevalMech", "evaluate push_hints_to_context"); + mTries = 1; // XXX/cs this should be set in authorization config + result = kAuthorizationResultAllow; // snarfcredential doesn't block evaluation, ever, it may restart + // create out context from input hints, no merge + // @@@ global copy template not being invoked... + context = hints; + } + else + if (*currentMechanism == "switch_to_user") + { + Process &cltProc = Server::active().connection().process; + // Authorization preserves creator's UID in setuid processes + uid_t cltUid = (cltProc.uid() != 0) ? cltProc.uid() : auth.creatorUid(); + secdebug("SSevalMech", "terminating agent at request of process %d (UID %d)\n", cltProc.pid(), cltUid); + QueryInvokeMechanism client(cltUid, auth, agentName.c_str()); + + try { + client.terminateAgent(); + } catch (...) { + // Not our agent + } + result = kAuthorizationResultAllow; + } + } + + // we own outHints and outContext + switch(result) + { + case kAuthorizationResultAllow: + secdebug("SSevalMech", "result allow"); + currentMechanism++; + break; + case kAuthorizationResultDeny: + secdebug("SSevalMech", "result deny"); + break; + case kAuthorizationResultUndefined: + secdebug("SSevalMech", "result undefined"); + break; // abort evaluation + case kAuthorizationResultUserCanceled: + secdebug("SSevalMech", "result canceled"); + break; // stop evaluation, return some sideband + default: + break; // abort evaluation + } + } + + // End of evaluation, if last step produced meaningful data, incorporate + if ((result == kAuthorizationResultAllow) || + (result == kAuthorizationResultUserCanceled)) // @@@ can only pass back sideband through context + { + secdebug("SSevalMech", "storing new context for authorization"); + auth.setInfoSet(context); + } + + switch(result) + { + case kAuthorizationResultDeny: + return errAuthorizationDenied; + case kAuthorizationResultUserCanceled: + return errAuthorizationCanceled; + case kAuthorizationResultAllow: + return errAuthorizationSuccess; + default: + return errAuthorizationInternal; + } +} + + + +OSStatus +RuleImpl::evaluateAuthorization(const AuthItemRef &inRight, const Rule &inRule, + AuthItemSet &environmentToClient, + AuthorizationFlags flags, CFAbsoluteTime now, + const CredentialSet *inCredentials, + CredentialSet &credentials, AuthorizationToken &auth) const +{ + OSStatus status = errAuthorizationDenied; + + string usernamehint; + evaluateSessionOwner(inRight, inRule, environmentToClient, now, auth, usernamehint); + if (usernamehint.length()) + environmentToClient.insert(AuthItemRef(AGENT_HINT_SUGGESTED_USER, AuthValueOverlay(usernamehint))); + + if ((mType == kUser) && (mGroupName.length())) + environmentToClient.insert(AuthItemRef(AGENT_HINT_REQUIRE_USER_IN_GROUP, AuthValueOverlay(mGroupName))); + + uint32 tries; + SecurityAgent::Reason reason = SecurityAgent::noReason; + + for (tries = 0; tries < mTries; tries++) + { + AuthItemRef retryHint(AGENT_HINT_RETRY_REASON, AuthValueOverlay(sizeof(reason), &reason)); + environmentToClient.erase(retryHint); environmentToClient.insert(retryHint); // replace + AuthItemRef triesHint(AGENT_HINT_TRIES, AuthValueOverlay(sizeof(tries), &tries)); + environmentToClient.erase(triesHint); environmentToClient.insert(triesHint); // replace + + status = evaluateMechanism(inRight, environmentToClient, auth, credentials); + + // successfully ran mechanisms to obtain credential + if (status == errAuthorizationSuccess) + { + // deny is the default + status = errAuthorizationDenied; + + // fetch context and construct a credential to be tested + AuthItemSet inContext = auth.infoSet(); + CredentialSet newCredentials = makeCredentials(inContext); + + for (CredentialSet::const_iterator it = newCredentials.begin(); it != newCredentials.end(); ++it) + { + const Credential& newCredential = *it; + + // @@@ we log the uid a process was running under when it created the authref, which is misleading in the case of loginwindow + if (newCredential->isValid()) + Syslog::info("uid %lu succeeded authenticating as user %s (uid %lu) for right %s.", auth.creatorUid(), newCredential->username().c_str(), newCredential->uid(), inRight->name()); + else + // we can't be sure that the user actually exists so inhibit logging of uid + Syslog::error("uid %lu failed to authenticate as user %s for right %s.", auth.creatorUid(), newCredential->username().c_str(), inRight->name()); + + if (!newCredential->isValid()) + { + reason = SecurityAgent::invalidPassphrase; //invalidPassphrase; + continue; + } + + // verify that this credential authorizes right + status = evaluateCredentialForRight(inRight, inRule, environmentToClient, now, newCredential, true); + + if (status == errAuthorizationSuccess) + { + // whack an equivalent credential, so it gets updated to a later achieved credential which must have been more stringent + credentials.erase(newCredential); credentials.insert(newCredential); + secdebug("SSevalMech", "added valid credential for user %s", newCredential->username().c_str()); + status = errAuthorizationSuccess; + break; + } + else + reason = SecurityAgent::userNotInGroup; //unacceptableUser; // userNotInGroup + } + + if (status == errAuthorizationSuccess) + break; + } + else + if ((status == errAuthorizationCanceled) || + (status == errAuthorizationInternal)) + break; + } + + // If we fell out of the loop because of too many tries, notify user + if (tries == mTries) + { + reason = SecurityAgent::tooManyTries; + AuthItemRef retryHint (AGENT_HINT_RETRY_REASON, AuthValueOverlay(sizeof(reason), &reason)); + environmentToClient.erase(retryHint); environmentToClient.insert(retryHint); // replace + AuthItemRef triesHint(AGENT_HINT_TRIES, AuthValueOverlay(sizeof(tries), &tries)); + environmentToClient.erase(triesHint); environmentToClient.insert(triesHint); // replace + evaluateMechanism(inRight, environmentToClient, auth, credentials); + } + + Process &cltProc = Server::active().connection().process; + // Authorization preserves creator's UID in setuid processes + uid_t cltUid = (cltProc.uid() != 0) ? cltProc.uid() : auth.creatorUid(); + secdebug("SSevalMech", "terminating agent at request of process %d (UID %d)\n", cltProc.pid(), cltUid); + string agentName = agentNameForAuth(auth); + QueryInvokeMechanism client(cltUid, auth, agentName.c_str()); + + try { + client.terminateAgent(); + } catch (...) { + // Not our agent + } + + return status; +} + +// create externally verified credentials on the basis of +// mechanism-provided information +CredentialSet +RuleImpl::makeCredentials(const AuthItemSet &context) const +{ + CredentialSet newCredentials; + + do { + AuthItemSet::const_iterator found = find_if(context.begin(), context.end(), FindAuthItemByRightName(kAuthorizationEnvironmentUsername) ); + if (found == context.end()) + break; + string username = (**found).stringValue(); + secdebug("SSevalMech", "found username"); + + const uid_t *uid = NULL; + found = find_if(context.begin(), context.end(), FindAuthItemByRightName("uid") ); + if (found != context.end()) + { + uid = static_cast((**found).value().data); + secdebug("SSevalMech", "found uid"); + } + + const gid_t *gid = NULL; + found = find_if(context.begin(), context.end(), FindAuthItemByRightName("gid") ); + if (found != context.end()) + { + gid = static_cast((**found).value().data); + secdebug("SSevalMech", "found gid"); + } + + if (username.length() && uid && gid) + { + // credential is valid because mechanism says so + newCredentials.insert(Credential(username, *uid, *gid, mShared)); + } + else + { + found = find_if(context.begin(), context.end(), FindAuthItemByRightName(kAuthorizationEnvironmentPassword) ); + if (found != context.end()) + { + secdebug("SSevalMech", "found password"); + string password = (**found).stringValue(); + secdebug("SSevalMech", "falling back on username/password credential if valid"); + newCredentials.insert(Credential(username, password, mShared)); + } + } + } while(0); + + return newCredentials; +} + +// evaluate whether a good credential of the current session owner would authorize a right +OSStatus +RuleImpl::evaluateSessionOwner(const AuthItemRef &inRight, const Rule &inRule, + const AuthItemSet &environment, + const CFAbsoluteTime now, + const AuthorizationToken &auth, + string& usernamehint) const +{ + // username hint is taken from the user who created the authorization, unless it's clearly ineligible + OSStatus status = noErr; + // @@@ we have no access to current requester uid here and the process uid is only taken when the authorization is created + // meaning that a process like loginwindow that drops privs later is screwed. + uid_t uid = auth.creatorUid(); + + Server::active().longTermActivity(); + struct passwd *pw = getpwuid(uid); + if (pw != NULL) + { + // avoid hinting a locked account (ie. root) + if ( (pw->pw_passwd == NULL) || + strcmp(pw->pw_passwd, "*") ) { + // Check if username will authorize the request and set username to + // be used as a hint to the user if so + status = evaluateCredentialForRight(inRight, inRule, environment, now, Credential(pw->pw_name, pw->pw_uid, pw->pw_gid, mShared), true); + + if (status == errAuthorizationSuccess) + usernamehint = pw->pw_name; + } //fi + endpwent(); + } + return status; +} + + + +// Return errAuthorizationSuccess if this rule allows access based on the specified credential, +// return errAuthorizationDenied otherwise. +OSStatus +RuleImpl::evaluateCredentialForRight(const AuthItemRef &inRight, const Rule &inRule, const AuthItemSet &environment, CFAbsoluteTime now, const Credential &credential, bool ignoreShared) const +{ + assert(mType == kUser); + + // Get the username from the credential + const char *user = credential->username().c_str(); + + // If the credential is not valid or it's age is more than the allowed maximum age + // for a credential, deny. + if (!credential->isValid()) + { + secdebug("autheval", "credential for user %s is invalid, denying right %s", user, inRight->name()); + return errAuthorizationDenied; + } + + if (now - credential->creationTime() > mMaxCredentialAge) + { + secdebug("autheval", "credential for user %s has expired, denying right %s", user, inRight->name()); + return errAuthorizationDenied; + } + + if (!ignoreShared && !mShared && credential->isShared()) + { + secdebug("autheval", "shared credential for user %s cannot be used, denying right %s", user, inRight->name()); + return errAuthorizationDenied; + } + + // A root (uid == 0) user can do anything + if (credential->uid() == 0) + { + secdebug("autheval", "user %s has uid 0, granting right %s", user, inRight->name()); + return errAuthorizationSuccess; + } + + // XXX/cs replace with remembered session-owner once that functionality is added to SecurityServer + if (mSessionOwner) + { + uid_t console_user; + struct stat console_stat; + if (!lstat("/dev/console", &console_stat)) + { + console_user = console_stat.st_uid; + if (credential->uid() == console_user) + { + secdebug("autheval", "user %s is session-owner(uid: %d), granting right %s", user, console_user, inRight->name()); + return errAuthorizationSuccess; + } + } + else + secdebug("autheval", "session-owner check failed."); + } + + if (mGroupName.length()) + { + const char *groupname = mGroupName.c_str(); + Server::active().longTermActivity(); + struct group *gr = getgrnam(groupname); + if (!gr) + return errAuthorizationDenied; + + // Is this the default group of this user? + // PR-2875126 declares gr_gid int, as opposed to advertised (getgrent(3)) gid_t + // When this is fixed this warning should go away. + if (credential->gid() == gr->gr_gid) + { + secdebug("autheval", "user %s has group %s(%d) as default group, granting right %s", + user, groupname, gr->gr_gid, inRight->name()); + endgrent(); + return errAuthorizationSuccess; + } + + for (char **group = gr->gr_mem; *group; ++group) + { + if (!strcmp(*group, user)) + { + secdebug("autheval", "user %s is a member of group %s, granting right %s", + user, groupname, inRight->name()); + endgrent(); + return errAuthorizationSuccess; + } + } + + secdebug("autheval", "user %s is not a member of group %s, denying right %s", + user, groupname, inRight->name()); + endgrent(); + } + + return errAuthorizationDenied; +} + +OSStatus +RuleImpl::evaluateUser(const AuthItemRef &inRight, const Rule &inRule, + AuthItemSet &environmentToClient, AuthorizationFlags flags, + CFAbsoluteTime now, const CredentialSet *inCredentials, CredentialSet &credentials, + AuthorizationToken &auth) const +{ + // If we got here, this is a kUser type rule, let's start looking for a + // credential that is satisfactory + + // Zeroth -- Here is an extra special saucy ugly hack to allow authorizations + // created by a proccess running as root to automatically get a right. + if (mAllowRoot && auth.creatorUid() == 0) + { + secdebug("autheval", "creator of authorization has uid == 0 granting right %s", + inRight->name()); + return errAuthorizationSuccess; + } + + // if this is a "is-admin" rule check that and return + // XXX/cs add way to specify is-admin class of rule: if (mNoVerify) + if (name() == kAuthorizationRuleIsAdmin) + { + string username; + if (!evaluateSessionOwner(inRight, inRule, environmentToClient, now, auth, username)) + return errAuthorizationSuccess; + } + + // First -- go though the credentials we either already used or obtained during this authorize operation. + for (CredentialSet::const_iterator it = credentials.begin(); it != credentials.end(); ++it) + { + OSStatus status = evaluateCredentialForRight(inRight, inRule, environmentToClient, now, *it, true); + if (status != errAuthorizationDenied) + { + // add credential to authinfo + auth.setCredentialInfo(*it); + return status; + } + } + + // Second -- go though the credentials passed in to this authorize operation by the state management layer. + if (inCredentials) + { + for (CredentialSet::const_iterator it = inCredentials->begin(); it != inCredentials->end(); ++it) + { + OSStatus status = evaluateCredentialForRight(inRight, inRule, environmentToClient, now, *it, false); + if (status == errAuthorizationSuccess) + { + // Add the credential we used to the output set. + // whack an equivalent credential, so it gets updated to a later achieved credential which must have been more stringent + credentials.erase(*it); credentials.insert(*it); + // add credential to authinfo + auth.setCredentialInfo(*it); + + return status; + } + else if (status != errAuthorizationDenied) + return status; + } + } + + // Finally -- We didn't find the credential in our passed in credential lists. Obtain a new credential if + // our flags let us do so. + if (!(flags & kAuthorizationFlagExtendRights)) + return errAuthorizationDenied; + + // authorizations that timeout immediately cannot be preauthorized + if ((flags & kAuthorizationFlagPreAuthorize) && + (mMaxCredentialAge == 0.0)) + { + inRight->setFlags(inRight->flags() | kAuthorizationFlagCanNotPreAuthorize); + return errAuthorizationSuccess; + } + + if (!(flags & kAuthorizationFlagInteractionAllowed)) + return errAuthorizationInteractionNotAllowed; + + setAgentHints(inRight, inRule, environmentToClient, auth); + + // If a different evaluation is prescribed, + // we'll run that and validate the credentials from there + // we fall back on a default configuration + if (mEvalDef.size() == 0) + return evaluateAuthorizationOld(inRight, inRule, environmentToClient, flags, now, inCredentials, credentials, auth); + else + return evaluateAuthorization(inRight, inRule, environmentToClient, flags, now, inCredentials, credentials, auth); +} + +// XXX/cs insert a mechanism that let's the agent live (keep-alive) only in loginwindow's case +OSStatus +RuleImpl::evaluateMechanismOnly(const AuthItemRef &inRight, const Rule &inRule, AuthItemSet &environmentToClient, AuthorizationToken &auth, CredentialSet &outCredentials) const +{ + uint32 tries = 0; + OSStatus status; + + do + { + setAgentHints(inRight, inRule, environmentToClient, auth); + AuthItemRef triesHint(AGENT_HINT_TRIES, AuthValueOverlay(sizeof(tries), &tries)); + environmentToClient.erase(triesHint); environmentToClient.insert(triesHint); // replace + + status = evaluateMechanism(inRight, environmentToClient, auth, outCredentials); + tries++; + } + while ((status == errAuthorizationDenied) // only if we have an expected failure we continue + && ((mTries == 0) // mTries == 0 means we try forever + || ((mTries > 0) // mTries > 0 means we try up to mTries times + && (tries < mTries)))); + + if (name() != "system.login.console") + { + // terminate agent + string agentName = agentNameForAuth(auth); + Process &cltProc = Server::active().connection().process; + // Authorization preserves creator's UID in setuid processes + uid_t cltUid = (cltProc.uid() != 0) ? cltProc.uid() : auth.creatorUid(); + secdebug("SSevalMech", "terminating agent at request of process %d (UID %d)\n", cltProc.pid(), cltUid); + + QueryInvokeMechanism client(cltUid, auth, agentName.c_str()); + + try + { + client.terminateAgent(); + } catch (...) { + // Not our agent + } + } + return status; +} + +OSStatus +RuleImpl::evaluateRules(const AuthItemRef &inRight, const Rule &inRule, + AuthItemSet &environmentToClient, AuthorizationFlags flags, + CFAbsoluteTime now, const CredentialSet *inCredentials, CredentialSet &credentials, + AuthorizationToken &auth) const +{ + // line up the rules to try + if (!mRuleDef.size()) + return errAuthorizationSuccess; + + uint32_t count = 0; + OSStatus status = errAuthorizationSuccess; + vector::const_iterator it; + + for (it = mRuleDef.begin();it != mRuleDef.end(); it++) + { + // are we at k yet? + if ((mType == kKofN) && (count == mKofN)) + return errAuthorizationSuccess; + + // get a rule and try it + status = (*it)->evaluate(inRight, inRule, environmentToClient, flags, now, inCredentials, credentials, auth); + + // if status is cancel/internal error abort + if ((status == errAuthorizationCanceled) || (status == errAuthorizationInternal)) + return status; + + if (status != errAuthorizationSuccess) + { + // continue if we're only looking for k of n + if (mType == kKofN) + continue; + + break; + } + else + count++; + } + + return status; // return the last failure +} + + +OSStatus +RuleImpl::evaluate(const AuthItemRef &inRight, const Rule &inRule, + AuthItemSet &environmentToClient, AuthorizationFlags flags, + CFAbsoluteTime now, const CredentialSet *inCredentials, CredentialSet &credentials, + AuthorizationToken &auth) const +{ + switch (mType) + { + case kAllow: + secdebug("autheval", "rule is always allow"); + return errAuthorizationSuccess; + case kDeny: + secdebug("autheval", "rule is always deny"); + return errAuthorizationDenied; + case kUser: + secdebug("autheval", "rule is user"); + return evaluateUser(inRight, inRule, environmentToClient, flags, now, inCredentials, credentials, auth); + case kRuleDelegation: + secdebug("autheval", "rule evaluates rules"); + return evaluateRules(inRight, inRule, environmentToClient, flags, now, inCredentials, credentials, auth); + case kKofN: + secdebug("autheval", "rule evaluates k-of-n rules"); + return evaluateRules(inRight, inRule, environmentToClient, flags, now, inCredentials, credentials, auth); + case kEvaluateMechanisms: + secdebug("autheval", "rule evaluates mechanisms"); + return evaluateMechanismOnly(inRight, inRule, environmentToClient, auth, credentials); + default: + MacOSError::throwMe(errAuthorizationInternal); // XXX/cs invalid rule + } +} + + + + +// This is slated to be removed when the new auth panel is fixed up +OSStatus +RuleImpl::evaluateAuthorizationOld(const AuthItemRef &inRight, const Rule &inRule, + AuthItemSet &environmentToClient, + AuthorizationFlags flags, CFAbsoluteTime now, + const CredentialSet *inCredentials, + CredentialSet &credentials, AuthorizationToken &auth) const +{ + Process &cltProc = Server::active().connection().process; + // Authorization preserves creator's UID in setuid processes + uid_t cltUid = (cltProc.uid() != 0) ? cltProc.uid() : auth.creatorUid(); + secdebug("autheval", "Auth query from process %d (UID %d)", cltProc.pid(), cltUid); + QueryAuthorizeByGroup query(cltUid, auth); + + string usernamehint; + + evaluateSessionOwner(inRight, inRule, environmentToClient, now, auth, usernamehint); + + Credential newCredential; + // @@@ Keep the default reason the same, so the agent only gets userNotInGroup or invalidPassphrase + SecurityAgent::Reason reason = SecurityAgent::userNotInGroup; + // @@@ Hardcoded 3 tries to avoid infinite loops. + for (uint32_t tryCount = 0; tryCount < mTries; ++tryCount) + { + // Obtain a new credential. Anything but success is considered an error. + OSStatus status = obtainCredential(query, inRight, environmentToClient, usernamehint.c_str(), newCredential, reason); + if (status) + return status; + + // Now we have successfully obtained a credential we need to make sure it authorizes the requested right + if (!newCredential->isValid()) + reason = SecurityAgent::invalidPassphrase; + else { + status = evaluateCredentialForRight(inRight, inRule, environmentToClient, now, newCredential, true); + if (status == errAuthorizationSuccess) + { + // Add the new credential we obtained to the output set. + // whack an equivalent credential, so it gets updated to a later achieved credential which must have been more stringent + credentials.erase(newCredential); credentials.insert(newCredential); + query.done(); + + // add credential to authinfo + auth.setCredentialInfo(newCredential); + + return errAuthorizationSuccess; + } + else if (status != errAuthorizationDenied) + return status; + } + reason = SecurityAgent::userNotInGroup; + } + query.cancel(SecurityAgent::tooManyTries); + return errAuthorizationDenied; +} + +OSStatus +RuleImpl::obtainCredential(QueryAuthorizeByGroup &query, const AuthItemRef &inRight, + AuthItemSet &environmentToClient, const char *usernameHint, Credential &outCredential, SecurityAgent::Reason reason) const +{ + char nameBuffer[SecurityAgent::maxUsernameLength]; + char passphraseBuffer[SecurityAgent::maxPassphraseLength]; + OSStatus status = errAuthorizationDenied; + + try { + if (query(mGroupName.c_str(), usernameHint, nameBuffer, passphraseBuffer, reason)) + status = noErr; + } catch (const CssmCommonError &err) { + status = err.osStatus(); + } catch (...) { + status = errAuthorizationInternal; + } + if (status == CSSM_ERRCODE_USER_CANCELED) + { + secdebug("auth", "canceled obtaining credential for user in group %s", mGroupName.c_str()); + return errAuthorizationCanceled; + } + if (status == CSSM_ERRCODE_NO_USER_INTERACTION) + { + secdebug("auth", "user interaction not possible obtaining credential for user in group %s", mGroupName.c_str()); + return errAuthorizationInteractionNotAllowed; + } + + if (status != noErr) + { + secdebug("auth", "failed obtaining credential for user in group %s", mGroupName.c_str()); + return status; + } + + secdebug("auth", "obtained credential for user %s", nameBuffer); + string username(nameBuffer); + string password(passphraseBuffer); + outCredential = Credential(username, password, mShared); + return errAuthorizationSuccess; +} + + +Rule::Rule() : RefPointer(new RuleImpl()) {} +Rule::Rule(const string &inRightName, CFDictionaryRef cfRight, CFDictionaryRef cfRules) : RefPointer(new RuleImpl(inRightName, cfRight, cfRules)) {} + + +} // end namespace Authorization diff --git a/SecurityServer/Authorization/AuthorizationRule.h b/SecurityServer/Authorization/AuthorizationRule.h new file mode 100644 index 00000000..91aefcf1 --- /dev/null +++ b/SecurityServer/Authorization/AuthorizationRule.h @@ -0,0 +1,146 @@ +/* + * AuthorizationRule.h + * Security + * + * Created by Conrad Sauerwald on Wed Mar 19 2003. + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + */ + +#ifndef _H_AUTHORIZATIONRULE +#define _H_AUTHORIZATIONRULE 1 + +#include +#include "AuthorizationData.h" + +#include "agentquery.h" + + +namespace Authorization +{ + +class Rule; + +class RuleImpl : public RefCount +{ +public: + RuleImpl(); + RuleImpl(const string &inRightName, CFDictionaryRef cfRight, CFDictionaryRef cfRules); + + OSStatus evaluate(const AuthItemRef &inRight, const Rule &inRule, AuthItemSet &environmentToClient, + AuthorizationFlags flags, CFAbsoluteTime now, + const CredentialSet *inCredentials, CredentialSet &credentials, + AuthorizationToken &auth) const; + + string name() const { return mRightName; } + +private: +// internal machinery + + // evaluate credential for right + OSStatus evaluateCredentialForRight(const AuthItemRef &inRight, const Rule &inRule, + const AuthItemSet &environment, + CFAbsoluteTime now, const Credential &credential, bool ignoreShared) const; + + // run mechanisms specified for this rule + OSStatus evaluateMechanism(const AuthItemRef &inRight, const AuthItemSet &environment, AuthorizationToken &auth, CredentialSet &outCredentials) const; + + OSStatus evaluateRules(const AuthItemRef &inRight, const Rule &inRule, + AuthItemSet &environmentToClient, AuthorizationFlags flags, + CFAbsoluteTime now, const CredentialSet *inCredentials, CredentialSet &credentials, + AuthorizationToken &auth) const; + + void setAgentHints(const AuthItemRef &inRight, const Rule &inTopLevelRule, AuthItemSet &environmentToClient, AuthorizationToken &auth) const; + + // perform authorization based on running specified mechanisms (see evaluateMechanism) + OSStatus evaluateAuthorization(const AuthItemRef &inRight, const Rule &inRule, AuthItemSet &environmentToClient, AuthorizationFlags flags, CFAbsoluteTime now, const CredentialSet *inCredentials, CredentialSet &credentials, AuthorizationToken &auth) const; + + OSStatus evaluateAuthorizationOld(const AuthItemRef &inRight, const Rule &inRule, AuthItemSet &environmentToClient, AuthorizationFlags flags, CFAbsoluteTime now, const CredentialSet *inCredentials, CredentialSet &credentials, AuthorizationToken &auth) const; + OSStatus obtainCredential(QueryAuthorizeByGroup &query, const AuthItemRef &inRight, AuthItemSet &environmentToClient, const char *usernameHint, Credential &outCredential, SecurityAgent::Reason reason) const; + + OSStatus evaluateUser(const AuthItemRef &inRight, const Rule &inRule, + AuthItemSet &environmentToClient, AuthorizationFlags flags, + CFAbsoluteTime now, const CredentialSet *inCredentials, CredentialSet &credentials, + AuthorizationToken &auth) const; + + OSStatus evaluateMechanismOnly(const AuthItemRef &inRight, const Rule &inRule, AuthItemSet &environmentToClient, AuthorizationToken &auth, CredentialSet &outCredentials) const; + + // find username hint based on session owner + OSStatus evaluateSessionOwner(const AuthItemRef &inRight, const Rule &inRule, const AuthItemSet &environment, const CFAbsoluteTime now, const AuthorizationToken &auth, string& usernamehint) const; + + + string agentNameForAuth(const AuthorizationToken &auth) const; + CredentialSet makeCredentials(const AuthItemSet &context) const; + + map localizedPrompts() const { return mLocalizedPrompts; } + + +// parsed attributes +private: + enum Type + { + kDeny, + kAllow, + kUser, + kRuleDelegation, + kKofN, + kEvaluateMechanisms, + } mType; + + string mRightName; + string mGroupName; + CFTimeInterval mMaxCredentialAge; + bool mShared; + bool mAllowRoot; + vector mEvalDef; + bool mSessionOwner; + vector mRuleDef; + uint32_t mKofN; + mutable uint32_t mTries; + map mLocalizedPrompts; + +private: + + class Attribute + { + public: + static bool getBool(CFDictionaryRef config, CFStringRef key, bool required, bool defaultValue); + static double getDouble(CFDictionaryRef config, CFStringRef key, bool required, double defaultValue); + static string getString(CFDictionaryRef config, CFStringRef key, bool required, char *defaultValue); + static vector getVector(CFDictionaryRef config, CFStringRef key, bool required); + static void setString(CFMutableDictionaryRef config, CFStringRef key, string &value); + static void setDouble(CFMutableDictionaryRef config, CFStringRef key, double value); + static void setBool(CFMutableDictionaryRef config, CFStringRef key, bool value); + static bool getLocalizedPrompts(CFDictionaryRef config, map &localizedPrompts); + }; + + +// keys + static CFStringRef kUserGroupID; + static CFStringRef kTimeoutID; + static CFStringRef kSharedID; + static CFStringRef kAllowRootID; + static CFStringRef kMechanismsID; + static CFStringRef kSessionOwnerID; + static CFStringRef kKofNID; + static CFStringRef kPromptID; + + static CFStringRef kRuleClassID; + static CFStringRef kRuleAllowID; + static CFStringRef kRuleDenyID; + static CFStringRef kRuleUserID; + static CFStringRef kRuleDelegateID; + static CFStringRef kRuleMechanismsID; + +}; + +class Rule : public RefPointer +{ +public: + Rule(); + Rule(const string &inRightName, CFDictionaryRef cfRight, CFDictionaryRef cfRules); +}; + +}; /* namespace Authorization */ + +#endif /* ! _H_AUTHORIZATIONRULE */ diff --git a/SecurityServer/Authorization/AuthorizationTags.h b/SecurityServer/Authorization/AuthorizationTags.h index e472bd23..0b5c7f76 100644 --- a/SecurityServer/Authorization/AuthorizationTags.h +++ b/SecurityServer/Authorization/AuthorizationTags.h @@ -59,4 +59,17 @@ */ #define kAuthorizationRightExecute "system.privilege.admin" +/*! + @define kAuthorizationEnvironmentPrompt + The name of the AuthorizationItem that should be passed into the environment when specifying a invocation specific additional text. The value should be a localized UTF8 string. +*/ +#define kAuthorizationEnvironmentPrompt "prompt" + +/*! + @define kAuthorizationEnvironmentIcon + The name of the AuthorizationItem that should be passed into the environment when specifying an alternate icon to be used. The value should be a full path to and image NSImage can deal with. +*/ +#define kAuthorizationEnvironmentIcon "icon" + + #endif /* !_SECURITY_AUTHORIZATIONTAGS_H_ */ diff --git a/SecurityServer/Authorization/AuthorizationTrampoline.cpp b/SecurityServer/Authorization/AuthorizationTrampoline.cpp index d0a12d7b..4947fae1 100644 --- a/SecurityServer/Authorization/AuthorizationTrampoline.cpp +++ b/SecurityServer/Authorization/AuthorizationTrampoline.cpp @@ -64,7 +64,7 @@ int main(int argc, const char *argv[]) const char *pathToTool = argv[1]; const char *mboxFdText = argv[2]; const char **restOfArguments = argv + 3; - debug("authtramp", "trampoline(%s,%s)", pathToTool, mboxFdText); + secdebug("authtramp", "trampoline(%s,%s)", pathToTool, mboxFdText); // read the external form AuthorizationExternalForm extForm; @@ -81,7 +81,7 @@ int main(int argc, const char *argv[]) AuthorizationRef auth; if (OSStatus error = AuthorizationCreateFromExternalForm(&extForm, &auth)) fail(error); - debug("authtramp", "authorization recovered"); + secdebug("authtramp", "authorization recovered"); // are we allowed to do this? AuthorizationItem right = { EXECUTERIGHT, 0, NULL, 0 }; @@ -110,10 +110,10 @@ int main(int argc, const char *argv[]) // note how this overwrites a known-existing argv element (that we copied earlier) *(--restOfArguments) = pathToTool; - debug("authtramp", "trampoline executes %s", pathToTool); + secdebug("authtramp", "trampoline executes %s", pathToTool); Syslog::notice("executing %s", pathToTool); execv(pathToTool, (char *const *)restOfArguments); - debug("authexec", "exec(%s) failed (errno=%d)", pathToTool, errno); + secdebug("authexec", "exec(%s) failed (errno=%d)", pathToTool, errno); // report failure OSStatus error = errAuthorizationToolExecuteFailure; @@ -125,6 +125,6 @@ int main(int argc, const char *argv[]) void fail(OSStatus cause) { write(1, &cause, sizeof(cause)); // ignore error - can't do anything if error - debug("authtramp", "trampoline aborting with status %ld", cause); + secdebug("authtramp", "trampoline aborting with status %ld", cause); exit(1); } diff --git a/SecurityServer/Authorization/AuthorizationWalkers.h b/SecurityServer/Authorization/AuthorizationWalkers.h index 4c5633a0..73808c13 100644 --- a/SecurityServer/Authorization/AuthorizationWalkers.h +++ b/SecurityServer/Authorization/AuthorizationWalkers.h @@ -32,17 +32,16 @@ #include #include // char * walker -namespace Security -{ +namespace Security { +namespace DataWalkers { -namespace DataWalkers -{ template void walk(Action &operate, AuthorizationItem &item) { + operate(item); walk(operate, item.name); - operate(item.value, item.valueLength); + operate.blob(item.value, item.valueLength); // Ignore reserved } @@ -50,7 +49,7 @@ template AuthorizationItemSet *walk(Action &operate, AuthorizationItemSet * &itemSet) { operate(itemSet); - operate(itemSet->items, itemSet->count * sizeof(AuthorizationItem)); + operate.blob(itemSet->items, itemSet->count * sizeof(itemSet->items[0])); for (uint32 n = 0; n < itemSet->count; n++) walk(operate, itemSet->items[n]); return itemSet; @@ -59,14 +58,14 @@ AuthorizationItemSet *walk(Action &operate, AuthorizationItemSet * &itemSet) template void walk(Action &operate, AuthorizationValue &authvalue) { - operate(authvalue.data, authvalue.length); + operate.blob(authvalue.data, authvalue.length); } template AuthorizationValueVector *walk(Action &operate, AuthorizationValueVector * &valueVector) { operate(valueVector); - operate(valueVector->values, valueVector->count * sizeof(AuthorizationValue)); + operate.blob(valueVector->values, valueVector->count * sizeof(valueVector->values[0])); for (uint32 n = 0; n < valueVector->count; n++) walk(operate, valueVector->values[n]); return valueVector; @@ -75,7 +74,6 @@ AuthorizationValueVector *walk(Action &operate, AuthorizationValueVector * &valu } // end namespace DataWalkers - } // end namespace Security #endif /* ! __AuthorizationWalkers__ */ diff --git a/SecurityServer/Authorization/authorization.plist b/SecurityServer/Authorization/authorization.plist index 0d0808df..c7f9188c 100644 --- a/SecurityServer/Authorization/authorization.plist +++ b/SecurityServer/Authorization/authorization.plist @@ -1,159 +1,499 @@ - - + + - - - - system.privilege.admin - - group - admin - shared - - allow-root - - timeout - 300 - - - - system.device.dvd.setregion.initial - - group - admin - shared - - - - - system.login.console - - eval - loginwindow_builtin:login,authinternal,loginwindow_builtin:success - - - system.login.pam - - eval - push_hints_to_context,authinternal - - system.login.tty - - eval - push_hints_to_context,authinternal - - system.login.done - - eval - switch_to_user - - - - - system.preferences +See remaining rules for examples. + + rights - group - admin - shared - - allow-root - + + + class + rule + comment + All other rights will be matched by this rule. +Credentials remain valid 5 minutes after they've been obtained. +An acquired credential is shared amongst all clients. + + rule + default + + config.add. + + class + allow + comment + wildcard right for adding rights. Anyone is allowed to add any (non-wildcard) rights + + config.config. + + class + deny + comment + wildcard right for any change to meta-rights for db modification. Not allowed programmatically (just edit this file) + + config.modify. + + class + rule + comment + wildcard right for modifying rights. Admins are allowed to modify any (non-wildcard) rights + rule + authenticate-admin + + config.remove. + + class + rule + comment + wildcard right for deleting rights. Admins are allowed to delete any (non-wildcard) rights + rule + authenticate-admin + + config.remove.system. + + class + deny + comment + wildcard right for deleting system rights. + + sys.openfile. + + class + user + comment + See authopen(1) for information on the use of this right. + group + admin + mechanisms + + builtin:authenticate + + shared + + timeout + 300 + + system.device.dvd.setregion.initial + + class + user + comment + Used by the dvd player to set the regioncode the first time. Note that changed the region code after it has been set requires a different right (system.device.dvd.setregion.change) +Credentials remain valid indefinitely after they've been obtained. +An acquired credential is shared amongst all clients. + group + admin + mechanisms + + builtin:authenticate + + shared + + + system.login.console + + class + evaluate-mechanisms + comment + Login mechanism based rule. Not for general use, yet. +builtin:krb5authenticate can be used to hinge local authentication on a successful kerberos authentication and kdc verification. +builtin:krb5authnoverify skips the kdc verification. Both fall back on local authentication. + mechanisms + + loginwindow_builtin:login + authinternal + loginwindow_builtin:success + builtin:getuserinfo + builtin:sso + + + system.login.done + + class + evaluate-mechanisms + comment + builtin:krb5login can be used to do kerberos authentication as a side-effect of logging in. Local username/password will be used. + mechanisms + + switch_to_user + + + system.login.pam + + class + evaluate-mechanisms + mechanisms + + push_hints_to_context + authinternal + + + system.login.screensaver + + class + rule + comment + the owner as well as any admin can unlock the screensaver;modify the group key to change this. + rule + authenticate-session-owner-or-admin + + system.login.tty + + class + evaluate-mechanisms + mechanisms + + push_hints_to_context + authinternal + + + system.keychain.create.loginkc + + allow-root + + class + evaluate-mechanisms + comment + Used by Security framework when you add an item to a unconfigured default keychain + mechanisms + + loginKC:queryCreate + loginKC:showPasswordUI + authinternal + loginKC:successOrFailure + + session-owner + + shared + + + system.keychain.modify + + class + user + comment + Used by Keychain Access when editing a system keychain. + group + admin + mechanisms + + builtin:authenticate + + shared + + timeout + 300 + + system.preferences + + allow-root + + class + user + comment + This right is checked by the Admin framework when making changes to the system preferences. +Credentials remain valid forever. +An acquired credential is shared amongst all clients. +If the proccess that created the AuthorizationRef has uid = 0 this right will automatically be granted. + group + admin + mechanisms + + builtin:authenticate + + shared + + + system.printingmanager + + class + rule + comment + The following right is checked for printing to locked printers. + rule + authenticate-admin + + system.privilege.admin + + allow-root + + class + user + comment + Used by AuthorizationExecuteWithPrivileges(...) + AuthorizationExecuteWithPrivileges is used by programs requesting + to run a tool as root (ie. some installers). + Credentials remain valid 5 minutes after they've been obtained. + An acquired credential isn't shared with other clients. + Clients running as root will be granted this right automatically. + + group + admin + mechanisms + + builtin:authenticate + + shared + + timeout + 300 + + system.restart + + class + evaluate-mechanisms + comment + Multisession restart mechanisms + mechanisms + + RestartAuthorization:restart + RestartAuthorization:authenticate + RestartAuthorization:success + + + system.shutdown + + class + evaluate-mechanisms + comment + Multisession shutdown mechanisms + mechanisms + + RestartAuthorization:shutdown + RestartAuthorization:authenticate + RestartAuthorization:success + + + system.burn + + class + allow + comment + authorization to burn media + + com.apple.server.admin.streaming + + class + user + comment + Used for admin requests with the QuickTime Streaming Server. + group + admin + shared + + allow-root + + timeout + 0 + + system.install.admin.user + + class + user + comment + Used by installer tool: user installling in admin domain (/Applications) + group + admin + mechanisms + + builtin:authenticate + + shared + + timeout + 300 + + system.install.root.user + + class + user + comment + Used by installer tool: user installling in root domain (/System) + group + admin + mechanisms + + builtin:authenticate + + shared + + timeout + 300 + + system.install.root.admin + + class + user + comment + Used by installer tool: admin installling in root domain (/System) + group + admin + mechanisms + + builtin:authenticate + + shared + + timeout + 300 + + com.apple.appserver.privilege.admin + + class + rule + comment + Used to determine administrative access to the Application Server management tool. + rule + appserver-admin + + com.apple.appserver.privilege.user + + class + rule + comment + Used to determine user access to the Application Server management tool. + k-of-n + 1 + rule + + appserver-admin + appserver-user + + - - - system.printingmanager - - group - admin - shared - - timeout - 0 - - - - sys.openfile. - - group - admin - shared - - timeout - 300 - - - - + rules - group - admin - shared - - timeout - 300 + allow + + class + allow + comment + allow anyone + + authenticate-admin + + class + user + comment + require the user asking for authorization to authenticate as an admin + group + admin + mechanisms + + builtin:authenticate + + shared + + timeout + 0 + + authenticate-session-owner + + class + user + comment + authenticate session owner + mechanisms + + builtin:authenticate + + session-owner + + + authenticate-session-owner-or-admin + + allow-root + + class + user + comment + the owner as well as any admin can authorize + group + admin + mechanisms + + builtin:authenticate + + session-owner + + shared + + + is-admin + + class + user + comment + verify the user asking for authorization is an admin + group + admin + shared + true + + is-root + + allow-root + + class + user + comment + verify the process that created this authref is root + group + nogroup + + appserver-user + + class + user + group + appserverusr + + appserver-admin + + class + user + group + appserveradm + + default + + class + user + comment + All other rights will be matched by this rule. Credentials remain valid 5 minutes after they've been obtained. +An acquired credential is shared amongst all clients. + + group + admin + mechanisms + + builtin:authenticate + + shared + + timeout + 300 + diff --git a/SecuritySNACCRuntime/c-lib/inc/tbl-dbg.h b/SecurityServer/Authorization/privPort.h similarity index 56% rename from SecuritySNACCRuntime/c-lib/inc/tbl-dbg.h rename to SecurityServer/Authorization/privPort.h index 9709c03c..b15a3503 100644 --- a/SecuritySNACCRuntime/c-lib/inc/tbl-dbg.h +++ b/SecurityServer/Authorization/privPort.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. * * The contents of this file constitute Original Code as defined in and are * subject to the Apple Public Source License Version 1.2 (the 'License'). @@ -16,14 +16,38 @@ */ -#ifndef TBL_DBG_H -#define TBL_DBG_H +// +// privPort.h - shared definitions between port server client and server side +// +#ifndef _H_PRIVPORT +#define _H_PRIVPORT -#include "tbl-gen.h" -extern TdeExceptionCode DBGMinCode; /* Defaults to TDEINFO */ -int DBGSimple PROTO ((AsnTag tag, AsnOcts* v, int begin)); -int DBGType PROTO ((TBLType* type, AVal* val, int begin)); -int DBGExc PROTO ((TdeExceptionCode code, void* p1, void* p2, void* p3)); -#endif +// +// UNIX domain port name for server connection +// +#define kPrivilegedPortBinder "/var/run/bindprivport" + + +// +// Authorization Rights used +// +#define ACCEPTRIGHT "system.privilege.port.accept" +#define CONNECTRIGHT "system.privilege.port.connect" + + +// +// Structure of a request +// +struct Request { + AuthorizationExternalForm authForm; + struct sockaddr_in requestedName; +}; + +struct Reply { + OSStatus status; +}; + + +#endif //_H_PRIVPORT diff --git a/SecurityServer/Authorization/privPortClient.cpp b/SecurityServer/Authorization/privPortClient.cpp new file mode 100644 index 00000000..324f8cab --- /dev/null +++ b/SecurityServer/Authorization/privPortClient.cpp @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// privPortClient - Authorization privileged-port binding client side +// +#include +#include +#include +#include "privPort.h" + +using namespace UnixPlusPlus; +using namespace IPPlusPlus; + + +// +// Where is the trampoline itself? +// +#if !defined(PORTSERVERPATH) +# define PORTSERVERPATH "/System/Library/CoreServices/privportserver" /* fallback */ +#endif + + +// +// Local functions +// +static void startServer(); + + +// +// The official client function. This does all the work +// +OSStatus AuthorizationBindPrivilegedPort(int fileDescriptor, + const struct sockaddr_in *name, + AuthorizationRef authorization, + AuthorizationFlags flags) +{ + BEGIN_API + unsigned short port = ntohs(name->sin_port); + secdebug("portserve", "bind request fd=%d port=%d", fileDescriptor, port); + + // must request a privileged port (don't check for debug version) +#if defined(NDEBUG) + if (port <= 0 || port >= IPPORT_RESERVED) + return errAuthorizationBadAddress; +#endif //NEBUG + + // no flags recognized so far + if (flags) + return errAuthorizationInvalidFlags; + + // form the request message + Request request; + if (OSStatus err = AuthorizationMakeExternalForm(authorization, &request.authForm)) + return err; + request.requestedName = *name; + + // connect to the port server (start it if we must) + UNSockAddress serverAddress(kPrivilegedPortBinder); + FdMover server; + server.open(AF_UNIX, SOCK_STREAM); + try { + server.connect(serverAddress); + } catch (const UnixError &error) { + switch (error.error) { + case ENOENT: // not bound + case ECONNREFUSED: // was bound, server is dead + startServer(); + server.connect(serverAddress); + break; + default: + throw; + } + } + + // send request + secdebug("portserve", "sending request"); + FdVector fds; + fds.push_back(fileDescriptor); + if (server.send(&request, sizeof(request), fds) != sizeof(request)) + UnixError::throwMe(EIO); + + // read reply + secdebug("portserve", "getting reply"); + Reply reply; + if (server.read(&reply, sizeof(reply)) != sizeof(reply)) + UnixError::throwMe(EIO); + + secdebug("portserve", "server replied %ld", reply.status); + return ntohl(reply.status); + + END_API(CSSM) +} + + +// +// Start the server (fork/exec) +// +static void startServer() +{ + const char *serverpath = PORTSERVERPATH; +#if !defined(NDEBUG) + if (const char *override = getenv("PRIVPORTSERVER")) + serverpath = override; +#endif //!NDEBUG + + secdebug("portserve", "starting %s", serverpath); + switch (fork()) { + case -1: + UnixError::throwMe(); + case 0: // child + execl(serverpath, serverpath, NULL); + secdebug("portserve", "cannot exec %s (errno=%d)", serverpath, errno); + _exit(1); + default: // parent + sleep(1); + break; + } +} + + +// +// A pure-C interface helper function for overriding bind(2). +// This obtains the authorization, then calls AuthorizationBindPrivilegedPort +// +int __authorization_bind(int s, const struct sockaddr_in *name) +{ + // obtain authorization + AuthorizationItem rights[] = { + { "system.privilege.port.connect", 0, NULL, 0 } + }; + AuthorizationRights rightSet = + { sizeof(rights) / sizeof(rights[0]), rights }; + AuthorizationRef auth; + if (AuthorizationCreate(&rightSet, NULL, + kAuthorizationFlagInteractionAllowed | + kAuthorizationFlagExtendRights | + kAuthorizationFlagPreAuthorize, + &auth)) { + errno = EPERM; + return -1; + } + + // bind + OSStatus err = AuthorizationBindPrivilegedPort(s, name, auth, 0); + AuthorizationFree(auth, 0); // ignore errors + + if (err) { + errno = (err >= errSecErrnoBase && err <= errSecErrnoLimit) ? + errno = err - errSecErrnoBase : + EPERM; + return -1; + } + return 0; +} diff --git a/SecurityServer/Authorization/privPortServer.cpp b/SecurityServer/Authorization/privPortServer.cpp new file mode 100644 index 00000000..97633fe3 --- /dev/null +++ b/SecurityServer/Authorization/privPortServer.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// privportserver.cpp - tool-side trampoline support functions +// +#include +#include +#include +#include +#include +#include +#include "privPort.h" + +using namespace UnixPlusPlus; +using namespace IPPlusPlus; + + +// +// Default values +// +#define DEFAULT_TIMEOUT (2 * 60) /* seconds */ + + +// +// Local functions +// +void usage(const char *me); +void serve(FdMover client); +void sigALRM(int signo); + + +// +// Send a reply (successful or otherwise) to the client and clean up. +// +void reply(Socket s, OSStatus error) +{ + Reply reply; + reply.status = htonl(error); + s.write(&reply, sizeof(reply)); + close(s); +} + + +// +// Server main program +// +int main(int argc, char *argv[]) +{ + unsigned timeout = DEFAULT_TIMEOUT; + + extern int optind; + extern char *optarg; + int arg; + while ((arg = getopt(argc, argv, "t:")) != -1) + switch (arg) { + case 't': + timeout = atoi(optarg); + break; + case '?': + usage(argv[0]); + } + if (optind < argc) + usage(argv[0]); + + umask(0111); // allow world-write on created socket + Socket server(AF_UNIX, SOCK_STREAM); + UNSockAddress serverAddress(kPrivilegedPortBinder); + try { + server.bind(serverAddress); + } catch (const UnixError &error) { + switch (error.error) { + case EADDRINUSE: + unlink(kPrivilegedPortBinder); + server.bind(serverAddress); + break; + default: + throw; + } + } + server.listen(5); + + // prepare signals + SigSet signals; + signals += SIGALRM; + sigMask(signals, SIG_BLOCK); + if (signal(SIGALRM, sigALRM) == SIG_ERR) { + perror("SIGALRM"); + exit(1); + } + + // server loop + for (;;) { + FdMover s; + alarm(timeout); + sigMask(signals, SIG_UNBLOCK); + server.accept(s); + sigMask(signals, SIG_BLOCK); + try { + serve(s); + } catch (const CssmCommonError &error) { + reply(s, error.cssmError()); + } catch (...) { + reply(s, -1); + } + } + + // go away + return 0; +} + + +void usage(const char *me) +{ + fprintf(stderr, "Usage: %s [-t timeout-seconds]\n", me); + exit(2); +} + + +void sigALRM(int signo) +{ + secdebug("portserver", "timeout; quitting"); + unlink(kPrivilegedPortBinder); + exit(0); +} + + +// +// Serve one request +void serve(FdMover client) +{ + secdebug("portserver", "processing port request"); + + // receive request message + Request request; + FdVector fds; + if (client.receive(&request, sizeof(request), fds) != sizeof(request)) { + // short receive - assume sender protocol error + return reply(client, 11111); + return; + } + if (fds.size() != 1) { + // must send exactly one socket to find + return reply(client, 11111); + return; + } + + // internalize the authorization + AuthorizationRef auth; + if (OSStatus err = AuthorizationCreateFromExternalForm(&request.authForm, &auth)) + return reply(client, err); + + // validate authorization; punt if not authorized + AuthorizationItem rights[] = { + { CONNECTRIGHT, 0, NULL, 0 }, + { ACCEPTRIGHT, 0, NULL, 0 } + }; + AuthorizationRights rightSet = { sizeof(rights) / sizeof(rights[0]), rights }; + AuthorizationRights *result; + if (OSStatus err = AuthorizationCopyRights(auth, &rightSet, NULL, + kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | + kAuthorizationFlagPartialRights, + &result)) + return reply(client, err); + UInt32 count = result ? result->count : 0; + AuthorizationFreeItemSet(result); + if (count == 0) + return reply(client, errAuthorizationDenied); + + // okay, bind as requested + Socket s; s = fds[0]; + s.bind(request.requestedName); + + // all is well. Tell the client + return reply(client, 0); +} diff --git a/SecurityServer/Authorization/trampolineClient.cpp b/SecurityServer/Authorization/trampolineClient.cpp index f4173b73..b17aebe9 100644 --- a/SecurityServer/Authorization/trampolineClient.cpp +++ b/SecurityServer/Authorization/trampolineClient.cpp @@ -103,17 +103,17 @@ OSStatus AuthorizationExecuteWithPrivileges(AuthorizationRef authorization, // do the standard forking tango... int delay = 1; for (int n = 5;; n--, delay *= 2) { - switch (pid_t pid = fork()) { + switch (fork()) { case -1: // error if (errno == EAGAIN) { // potentially recoverable resource shortage if (n > 0) { - debug("authexec", "resource shortage (EAGAIN), delaying %d seconds", delay); + secdebug("authexec", "resource shortage (EAGAIN), delaying %d seconds", delay); sleep(delay); continue; } } - debug("authexec", "fork failed (errno=%d)", errno); + secdebug("authexec", "fork failed (errno=%d)", errno); close(notify[READ]); close(notify[WRITE]); return errAuthorizationToolExecuteFailure; @@ -128,14 +128,14 @@ OSStatus AuthorizationExecuteWithPrivileges(AuthorizationRef authorization, // get status notification from child OSStatus status; - debug("authexec", "parent waiting for status"); - switch (ssize_t rc = read(notify[READ], &status, sizeof(status))) { + secdebug("authexec", "parent waiting for status"); + switch (IFDEBUG(ssize_t rc =) read(notify[READ], &status, sizeof(status))) { default: // weird result of read: post error - debug("authexec", "unexpected read return value %ld", long(rc)); + secdebug("authexec", "unexpected read return value %ld", long(rc)); status = errAuthorizationToolEnvironmentError; // fall through case sizeof(status): // read succeeded: child reported an error - debug("authexec", "parent received status=%ld", status); + secdebug("authexec", "parent received status=%ld", status); close(notify[READ]); if (communicationsPipe) { close(comm[READ]); close(comm[WRITE]); } return status; @@ -143,7 +143,7 @@ OSStatus AuthorizationExecuteWithPrivileges(AuthorizationRef authorization, close(notify[READ]); if (communicationsPipe) *communicationsPipe = fdopen(comm[READ], "r+"); - debug("authexec", "parent resumes (no error)"); + secdebug("authexec", "parent resumes (no error)"); return noErr; } @@ -176,11 +176,11 @@ OSStatus AuthorizationExecuteWithPrivileges(AuthorizationRef authorization, #endif //NDEBUG // okay, execute the trampoline - debug("authexec", "child exec(%s:%s)", + secdebug("authexec", "child exec(%s:%s)", trampoline, pathToTool); if (const char **argv = argVector(trampoline, pathToTool, mboxFdText, arguments)) execv(trampoline, (char *const*)argv); - debug("authexec", "trampoline exec failed (errno=%d)", errno); + secdebug("authexec", "trampoline exec failed (errno=%d)", errno); // execute failed - tell the parent { diff --git a/SecurityServer/CVSVersionInfo.txt b/SecurityServer/CVSVersionInfo.txt index 1b2616aa..80294d1b 100644 --- a/SecurityServer/CVSVersionInfo.txt +++ b/SecurityServer/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:14:00 mb Exp $ -# $Name: Security-54~1~9 $ +# $Name: $ ProjectName: SecurityServer ProjectVersion: 17.1 diff --git a/SecurityServer/Makefile.startup b/SecurityServer/Makefile.startup index bda8b415..7102d845 100644 --- a/SecurityServer/Makefile.startup +++ b/SecurityServer/Makefile.startup @@ -8,6 +8,8 @@ SYSTEM_LIBRARY_DIR=$(DSTROOT)/System/Library SYSTEM_CORE_SERVICES_DIR=/System/Library/CoreServices AUTHORIZATION_LOCATION=$(DSTROOT)/private/etc AUTHORIZATION_PLIST=$(AUTHORIZATION_LOCATION)/authorization +VARDB=$(DSTROOT)/private/var/db +CANDIDATES=$(VARDB)/CodeEquivalenceCandidates DST=$(SYSTEM_LIBRARY_DIR)/StartupItems/SecurityServer SRC=$(SRCROOT)/SecurityServer @@ -32,16 +34,21 @@ install: mkdir -p $(DST)/Resources/English.lproj cp $(SRC)/StartupItems/StartupParameters.plist $(DST) sed -e "s:@@@:$(SYSTEM_CORE_SERVICES_DIR):g" $(SRC)/StartupItems/SecurityServer >$(DST)/SecurityServer - cp $(SRC)/StartupItems/Localizable.strings $(DST)/Resources/English.lproj/Localizable.strings + cp $(SRC)/StartupItems/Localizable.strings $(DST)/Resources/English.lproj/Localizable.plist chown -R root.wheel $(DST) chmod 755 $(DST)/SecurityServer chmod 644 $(DST)/StartupParameters.plist - chmod 644 $(DST)/Resources/English.lproj/Localizable.strings + chmod 644 $(DST)/Resources/English.lproj/Localizable.plist chmod 4711 $(DSTROOT)/$(SYSTEM_CORE_SERVICES_DIR)/AuthorizationTrampoline + chmod 4711 $(DSTROOT)/$(SYSTEM_CORE_SERVICES_DIR)/privportserver mkdir -p $(AUTHORIZATION_LOCATION) cp $(SRC)/Authorization/authorization.plist $(AUTHORIZATION_PLIST) chown root.admin $(AUTHORIZATION_PLIST) - chmod 640 $(AUTHORIZATION_PLIST) + chmod 644 $(AUTHORIZATION_PLIST) + mkdir -p $(VARDB) + cp $(SRC)/StartupItems/CodeEquivalenceCandidates $(CANDIDATES) + chown root.admin $(CANDIDATES) + chmod 644 $(CANDIDATES) installhdrs: @echo null installhdrs. diff --git a/SecurityServer/SecurityAgentClient.cpp b/SecurityServer/SecurityAgentClient.cpp index 48c0ccaa..9307d4fb 100644 --- a/SecurityServer/SecurityAgentClient.cpp +++ b/SecurityServer/SecurityAgentClient.cpp @@ -47,6 +47,10 @@ #include #include #include +#include + +#include +#include // @@@ Should be in but it isn't as of Puma5F22 extern "C" int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); @@ -73,6 +77,9 @@ public: Requestor(const OSXCode *code) { if (code) extForm = code->encode(); } operator const char * () const { return extForm.c_str(); } + // use this for debugging only + const char *c_str() const { return extForm.empty() ? "(unknown)" : extForm.c_str(); } + private: string extForm; }; @@ -158,7 +165,7 @@ static void getNoSA(char *buffer, size_t bufferSize, const char *fmt, ...) // // Initialize our CSSM interface // -Client::Client() : mActive(false), mUsePBS(true), mKeepAlive(false), stage(mainStage) +Client::Client() : mActive(false), desktopUid(0), mKeepAlive(false), stage(mainStage), mAgentName("com.apple.SecurityAgent") { } @@ -169,12 +176,10 @@ Client::Client() : mActive(false), mUsePBS(true), mKeepAlive(false), stage(mainS * DiskCopy needs to be fixed to use the Security Server itself rather * than this library. */ -Client::Client(uid_t clientUID, Bootstrap clientBootstrap) : - mActive(false), desktopUid(clientUID), mUsePBS(false), - mClientBootstrap(clientBootstrap), mKeepAlive(false), stage(mainStage) +Client::Client(uid_t clientUID, Bootstrap clientBootstrap, const char *agentName) : + mActive(false), desktopUid(clientUID), + mClientBootstrap(clientBootstrap), mKeepAlive(false), stage(mainStage), mAgentName(agentName) { - setClientGroupID(); - debug("SAclnt", "Desktop: uid %d, gid %d", desktopUid, desktopGid); } Client::~Client() @@ -186,10 +191,11 @@ Client::~Client() // // Activate a session // -void Client::activate(const char *name) +void Client::activate() { if (!mActive) { - establishServer(name ? name : "SecurityAgent"); + + establishServer(); // create reply port mClientPort.allocate(MACH_PORT_RIGHT_RECEIVE); @@ -253,31 +259,16 @@ void Client::cancel() // Start it if necessary (and possible). Throw an exception if we can't get to it. // Sets mServerPort on success. // -void Client::establishServer(const char *name) +void Client::establishServer() { - /* - * Once we wean ourselves off PBS we can eliminate "bootstrap" and use - * mClientBootstrap directly. - */ - if (mUsePBS) - locateDesktop(); - else - pbsBootstrap = mClientBootstrap; - - // If the userids don't match, that means you can't do user interaction - // @@@ Check session so we don't pop up UI in a non-UI context - // @@@ Expose this to caller so it can implement its own idea of getuid()! - if (desktopUid != getuid() && getuid() != 0) - CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); - // if the server is already running, we're done - Bootstrap bootstrap(pbsBootstrap); - if (mServerPort = bootstrap.lookupOptional(name)) - return; + if (mServerPort = mClientBootstrap.lookupOptional(mAgentName.c_str())) + return; #if defined(AGENTNAME) && defined(AGENTPATH) // switch the bootstrap port to that of the logged-in user - StBootstrap bootSaver(pbsBootstrap); + + StBootstrap bootSaver(mClientBootstrap); // try to start the agent switch (pid_t pid = fork()) { @@ -288,13 +279,21 @@ void Client::establishServer(const char *name) unsetenv("LOGNAME"); unsetenv("HOME"); - debug("SAclnt", "setgid(%d)", desktopGid); - setgid(desktopGid); // switch to login-user gid - debug("SAclnt", "setuid(%d)", desktopUid); - // Must be setuid and not seteuid since we do not want the agent to be able - // to call seteuid(0) successfully. - setuid(desktopUid); // switch to login-user uid - + // tell agent which name to register + setenv("AGENTNAME", mAgentName.c_str(), 1); + + if (desktopUid) // if the user is running as root, or we're not told what uid to use, we stick with what we are + { + struct group *grent = getgrnam("nobody"); + gid_t desktopGid = grent ? grent->gr_gid : unsigned(-2); //@@@ questionable + endgrent(); + secdebug("SAclnt", "setgid(%d)", desktopGid); + setgid(desktopGid); // switch to login-user gid + secdebug("SAclnt", "setuid(%d)", desktopUid); + // Must be setuid and not seteuid since we do not want the agent to be able + // to call seteuid(0) successfully. + setuid(desktopUid); // switch to login-user uid + } // close down any files that might have been open at this point int maxDescriptors = getdtablesize (); int i; @@ -310,9 +309,9 @@ void Client::establishServer(const char *name) if (!path) path = AGENTPATH; snprintf(agentExecutable, sizeof(agentExecutable), "%s/Contents/MacOS/" AGENTNAME, path); - debug("SAclnt", "execl(%s)", agentExecutable); + secdebug("SAclnt", "execl(%s)", agentExecutable); execl(agentExecutable, agentExecutable, NULL); - debug("SAclnt", "execl of SecurityAgent failed, errno=%d", errno); + secdebug("SAclnt", "execl of SecurityAgent failed, errno=%d", errno); // Unconditional suicide follows. // See comments below on why we can't use abort() @@ -331,15 +330,15 @@ void Client::establishServer(const char *name) { static const int timeout = 300; - debug("SAclnt", "Starting security agent (%d seconds timeout)", timeout); + secdebug("SAclnt", "Starting security agent (%d seconds timeout)", timeout); struct timespec rqtp; memset(&rqtp, 0, sizeof(rqtp)); rqtp.tv_nsec = 100000000; /* 10^8 nanaseconds = 1/10th of a second */ for (int n = timeout; n > 0; nanosleep(&rqtp, NULL), n--) { - if (mServerPort = bootstrap.lookupOptional(name)) + if (mServerPort = mClientBootstrap.lookupOptional(mAgentName.c_str())) break; int status; - switch (pid_t rc = waitpid(pid, &status, WNOHANG)) { + switch (IFDEBUG(pid_t rc =) waitpid(pid, &status, WNOHANG)) { case 0: // child still running continue; case -1: // error @@ -348,31 +347,31 @@ void Client::establishServer(const char *name) case EAGAIN: // transient continue; case ECHILD: // no such child (dead; already reaped elsewhere) - debug("SAclnt", "child is dead (reaped elsewhere)"); + secdebug("SAclnt", "child is dead (reaped elsewhere)"); CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); default: - debug("SAclnt", "waitpid failed: errno=%d", errno); + secdebug("SAclnt", "waitpid failed: errno=%d", errno); UnixError::throwMe(); } default: assert(rc == pid); - debug("SAclnt", "child died without claiming the SecurityAgent port"); + secdebug("SAclnt", "child died without claiming the SecurityAgent port"); CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); } } if (mServerPort == 0) { // couldn't contact Security Agent - debug("SAclnt", "Autolaunch failed"); + secdebug("SAclnt", "Autolaunch failed"); CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); } - debug("SAclnt", "SecurityAgent located"); + secdebug("SAclnt", "SecurityAgent located"); return; } } #endif // well, this didn't work. Too bad - debug("SAclnt", "Cannot contact SecurityAgent"); + secdebug("SAclnt", "Cannot contact SecurityAgent"); CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); //@@@ or INTERNAL_ERROR? } @@ -453,7 +452,7 @@ void Client::retryUnlockDatabase(Reason reason, char passphrase[maxPassphraseLen // Ask for a (new) password for something. // void Client::queryNewPassphrase(const OSXCode *requestor, pid_t requestPid, - const char *database, Reason reason, char passphrase[maxPassphraseLength]) + const char *database, Reason reason, char passphrase[maxPassphraseLength], char oldPassphrase[maxPassphraseLength]) { Requestor req(requestor); @@ -469,11 +468,11 @@ void Client::queryNewPassphrase(const OSXCode *requestor, pid_t requestPid, activate(); check(secagent_client_queryNewPassphrase(mServerPort, mClientPort, &status, req, requestPid, database, reason, - &mStagePort.port(), passphrase)); + &mStagePort.port(), passphrase, oldPassphrase)); stage = newPassphraseStage; } -void Client::retryNewPassphrase(Reason reason, char passphrase[maxPassphraseLength]) +void Client::retryNewPassphrase(Reason reason, char passphrase[maxPassphraseLength], char oldPassphrase[maxPassphraseLength]) { if (stage != newPassphraseStage) CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); //@@@ invent a "state mismatch error"? @@ -485,7 +484,7 @@ void Client::retryNewPassphrase(Reason reason, char passphrase[maxPassphraseLeng } #endif check(secagent_client_retryNewPassphrase(mStagePort, mClientPort, - &status, reason, passphrase)); + &status, reason, passphrase, oldPassphrase)); } @@ -497,13 +496,15 @@ void Client::queryKeychainAccess(const OSXCode *requestor, pid_t requestPid, const char *database, const char *itemName, AclAuthorization action, bool needPassphrase, KeychainChoice &choice) { + Debug::trace (kSecTraceSecurityServerQueryKeychainAccess); + Requestor req(requestor); #if defined(NOSA) if (getenv("NOSA")) { char answer[maxPassphraseLength+10]; - getNoSA(answer, sizeof(answer), "Allow [someone] to do %d on %s in %s? [yn][g]%s ", - int(action), (itemName ? itemName : "[NULL item]"), + getNoSA(answer, sizeof(answer), "Allow %s to do %d on %s in %s? [yn][g]%s ", + req.c_str(), int(action), (itemName ? itemName : "[NULL item]"), (database ? database : "[NULL database]"), needPassphrase ? ":passphrase" : ""); // turn passphrase (no ':') into y:passphrase @@ -523,8 +524,46 @@ void Client::queryKeychainAccess(const OSXCode *requestor, pid_t requestPid, activate(); check(secagent_client_queryKeychainAccess(mServerPort, mClientPort, &status, req, requestPid, (database ? database : ""), itemName, action, - needPassphrase, &choice)); - terminate(); + needPassphrase, &mStagePort.port(), &choice)); + + stage = queryKeychainAccessStage; +} + + +void Client::retryQueryKeychainAccess (Reason reason, Choice &choice) +{ + if (stage != queryKeychainAccessStage) + CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); //@@@ invent a "state mismatch error"? + + check(secagent_client_retryQueryKeychainAccess (mStagePort, mClientPort, &status, reason, &choice)); +} + + + +// +// Ask the user whether a somewhat (but not cleanly) matching code identity +// should be accepted for access control purposes. +// +void Client::queryCodeIdentity(const OSXCode *requestor, pid_t requestPid, + const char *aclPath, KeychainChoice &choice) +{ + Requestor req(requestor); + +#if defined(NOSA) + if (getenv("NOSA")) { + char answer[10]; + getNoSA(answer, sizeof(answer), + "Allow %s to match an ACL for %s [yn][g]? ", + req.c_str(), aclPath ? aclPath : "(unknown)"); + choice.allowAccess = answer[0] == 'y'; + choice.continueGrantingToCaller = answer[1] == 'g'; + return; + } +#endif + activate(); + check(secagent_client_queryCodeIdentity(mServerPort, mClientPort, + &status, req, requestPid, aclPath, &choice)); + terminate(); } @@ -672,11 +711,19 @@ bool Client::retryAuthorizationAuthenticate(Reason reason, char user[maxUsername // // invokeMechanism old style // -bool Client::invokeMechanism(const string &inPluginId, const string &inMechanismId, const AuthorizationValueVector *inArguments, const AuthorizationItemSet *inHints, const AuthorizationItemSet *inContext, AuthorizationResult *outResult, AuthorizationItemSet *&outHintsPtr, AuthorizationItemSet *&outContextPtr) +bool Client::invokeMechanism(const string &inPluginId, const string &inMechanismId, const AuthValueVector &inArguments, AuthItemSet &inHints, AuthItemSet &inContext, AuthorizationResult *outResult) { - Copier inArgumentVector(inArguments); - Copier inHintsSet(inHints); - Copier inContextSet(inContext); + AuthorizationValueVector *inArgumentVector; + AuthorizationItemSet *inHintsSet, *inContextSet; + size_t inArgumentVectorLength, inHintsSetLength, inContextSetLength; + + CssmAllocator &alloc = CssmAllocator::standard(); + inArguments.copy(&inArgumentVector, &inArgumentVectorLength); + CssmAutoPtr argGuard(alloc, inArgumentVector); + inHints.copy(inHintsSet, inHintsSetLength, alloc); + CssmAutoPtr hintGuard(alloc, inHintsSet); + inContext.copy(inContextSet, inContextSetLength, alloc); + CssmAutoPtr contextGuard(alloc, inContextSet); COPY_OUT_DECL(AuthorizationItemSet, outHintsSet); COPY_OUT_DECL(AuthorizationItemSet, outContextSet); @@ -684,27 +731,25 @@ bool Client::invokeMechanism(const string &inPluginId, const string &inMechanism activate(); // either noErr (user cancel, allow) or throws authInternal - check(secagent_client_invokeMechanism(mServerPort, mClientPort, - &status, &mStagePort.port(), - inPluginId.c_str(), - inMechanismId.c_str(), - COPY(inArgumentVector), - COPY(inHintsSet), - COPY(inContextSet), - outResult, - COPY_OUT(outHintsSet), - COPY_OUT(outContextSet))); + + check(secagent_client_invokeMechanism(mServerPort, mClientPort, + &status, &mStagePort.port(), inPluginId.c_str(), inMechanismId.c_str(), + inArgumentVector, inArgumentVectorLength, inArgumentVector, + inHintsSet, inHintsSetLength, inHintsSet, + inContextSet, inContextSetLength, inContextSet, + outResult, + COPY_OUT(outHintsSet), + COPY_OUT(outContextSet))); + + VMGuard _(outHintsSet, outHintsSetLength); + VMGuard _2(outContextSet, outContextSetLength); if (status != errAuthorizationDenied) { relocate(outHintsSet, outHintsSetBase); - Copier copyHints(outHintsSet); - // the auth engine releases this when done - outHintsPtr = copyHints.keep(); - relocate(outContextSet, outContextSetBase); - Copier copyContext(outContextSet); - // the auth engine releases this when done - outContextPtr = copyContext.keep(); + inHints = *outHintsSet; + relocate(outContextSet, outContextSetBase); + inContext = *outContextSet; } return (status == noErr); @@ -713,109 +758,13 @@ bool Client::invokeMechanism(const string &inPluginId, const string &inMechanism void Client::terminateAgent() { - if (mUsePBS) - // find the right place to look - locateDesktop(); - - // make sure we're doing this for the right user - // @@@ Check session as well! - if (desktopUid != getuid() && getuid() != 0) - CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); - - // if the server is already running, it's time to kill it - bool agentRunning = false; - if (mUsePBS) - { - Bootstrap bootstrap(pbsBootstrap); - if (mServerPort = bootstrap.lookupOptional("SecurityAgent")) - agentRunning = true; - } - else - { - if (mServerPort = mClientBootstrap.lookupOptional("SecurityAgent")) - agentRunning = true; - } - if (agentRunning) + // If the agent is (still) running, kill it + if (mClientBootstrap.lookupOptional(mAgentName.c_str())) { activate(); check(secagent_client_terminate(mServerPort, mClientPort)); } } -#include -#include - -void Client::setClientGroupID(const char *grpName) -{ - /* - * desktopGid is unsigned so the compiler warns about the conversion - * of -2. - */ - struct group *grent = getgrnam(grpName ? grpName : "nobody"); - desktopGid = grent ? grent->gr_gid : -2; -} - -// -// Locate and identify the current desktop. -// This is moderately atrocious code. There really ought to be a way to identify -// the logged-in (graphics console) user (and whether there is one). As it stands, -// we locate the "pbs" (pasteboard server) process and obtain its uid. No pbs, no -// user interaction. (By all accounts, a dead pbs is a death sentence anyway.) -// -#include -#include - -void Client::locateDesktop() -{ - int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL}; - size_t bufSize; - struct kinfo_proc *procBuf; - - if (sysctl(mib, 3, NULL, &bufSize, NULL, 0) < 0) { - perror("sysctl"); - abort(); - } - - procBuf = (struct kinfo_proc *)malloc(bufSize); //@@@ which allocator? - if (sysctl(mib, 3, procBuf, &bufSize, NULL, 0)) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); - int count = bufSize / sizeof(struct kinfo_proc); - struct kinfo_proc *pbsProc = NULL; - for (struct kinfo_proc *proc = procBuf; proc < procBuf + count; proc++) { - if (!strncmp(proc->kp_proc.p_comm, "pbs", MAXCOMLEN)) { - pbsProc = proc; - break; - } - } - - if (!pbsProc) { // no pasteboard server -- user not logged in - debug("SAclnt", "No pasteboard server - no user logged in"); - CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); - } - - desktopUid = pbsProc->kp_eproc.e_ucred.cr_uid; - desktopGid = pbsProc->kp_eproc.e_ucred.cr_gid; - pid_t pbsPid = pbsProc->kp_proc.p_pid; - - debug("SAclnt", "Desktop has uid %d", desktopUid); - free(procBuf); - - kern_return_t result; - mach_port_t pbsTaskPort; - result = task_for_pid(mach_task_self(), pbsPid, &pbsTaskPort); - if (result) - { - mach_error("task_for_pid(pbs)", result); - CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); - } - - result = task_get_bootstrap_port(pbsTaskPort, &pbsBootstrap); - if (result) - { - mach_error("task_get_bootstrap_port(pbs)", result); - CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION); - } -} - } // end namespace SecurityAgent } // end namespace Security diff --git a/SecurityServer/SecurityAgentClient.h b/SecurityServer/SecurityAgentClient.h index d8405a2b..184092cd 100644 --- a/SecurityServer/SecurityAgentClient.h +++ b/SecurityServer/SecurityAgentClient.h @@ -31,6 +31,10 @@ #include #include #include +#include + +using Authorization::AuthItemSet; +using Authorization::AuthValueVector; namespace Security { @@ -48,6 +52,8 @@ namespace SecurityAgent { static const unsigned int maxPassphraseLength = 1024; static const unsigned int maxUsernameLength = 80; +#define kMaximumAuthorizationTries 3 + // // Unified reason codes transmitted to SecurityAgent (and internationalized there) // @@ -67,6 +73,7 @@ enum Reason { passphraseTooSimple, // passphrase is not complex enough passphraseRepeated, // passphrase was used before (must use new one) passphraseUnacceptable, // passphrase unacceptable for some other reason + oldPassphraseWrong, // the old passphrase given is wrong // reasons for retrying an authorization query userNotInGroup = 41, // authenticated user not in needed group @@ -79,6 +86,31 @@ enum Reason { generalErrorCancel // something went wrong so we have to give up now }; +#define AGENT_HINT_SUGGESTED_USER "suggestedUser" +#define AGENT_HINT_REQUIRE_USER_IN_GROUP "requireUserInGroup" +#define AGENT_HINT_CUSTOM_PROMPT "prompt" +#define AGENT_HINT_AUTHORIZE_RIGHT "authorizeRight" +#define AGENT_HINT_CLIENT_PID "clientPid" +#define AGENT_HINT_CLIENT_UID "clientUid" +#define AGENT_HINT_CREATOR_PID "creatorPid" +#define AGENT_HINT_CLIENT_TYPE "clientType" +#define AGENT_HINT_CLIENT_PATH "clientPath" +#define AGENT_HINT_TRIES "tries" +#define AGENT_HINT_RETRY_REASON "reason" +#define AGENT_HINT_AUTHORIZE_RULE "authorizeRule" +// +// "Login Keychain Creation" Right: Hint and context keys +// +#define AGENT_HINT_ATTR_NAME "loginKCCreate:attributeName" +#define AGENT_HINT_LOGIN_KC_NAME "loginKCCreate:pathName" +#define AGENT_HINT_LOGIN_KC_EXISTS_IN_KC_FOLDER "loginKCCreate:exists" +#define AGENT_HINT_LOGIN_KC_USER_NAME "loginKCCreate:userName" +#define AGENT_HINT_LOGIN_KC_CUST_STR1 "loginKCCreate:customStr1" +#define AGENT_HINT_LOGIN_KC_CUST_STR2 "loginKCCreate:customStr2" +#define AGENT_HINT_LOGIN_KC_USER_HAS_OTHER_KCS_STR "loginKCCreate:moreThanOneKeychainExists" + +#define LOGIN_KC_CREATION_RIGHT "system.keychain.create.loginkc" + #if defined(__cplusplus) @@ -88,10 +120,10 @@ enum Reason { class Client { public: Client(); - Client(uid_t clientUID, Bootstrap clientBootstrap); + Client(uid_t clientUID, Bootstrap clientBootstrap, const char *agentName); virtual ~Client(); - virtual void activate(const char *bootstrapName = NULL); + virtual void activate(); virtual void terminate(); bool isActive() const { return mActive; } @@ -116,8 +148,8 @@ public: // ask for a new passphrase for a database. Not yet staged void queryNewPassphrase(const OSXCode *requestor, pid_t requestPid, - const char *database, Reason reason, char passphrase[maxPassphraseLength]); - void retryNewPassphrase(Reason reason, char passphrase[maxPassphraseLength]); + const char *database, Reason reason, char passphrase[maxPassphraseLength], char oldPassphrase[maxPassphraseLength]); + void retryNewPassphrase(Reason reason, char passphrase[maxPassphraseLength], char oldPassphrase[maxPassphraseLength]); // ask permission to use an item in a database struct KeychainChoice { @@ -128,6 +160,11 @@ public: void queryKeychainAccess(const OSXCode *requestor, pid_t requestPid, const char *database, const char *itemName, AclAuthorization action, bool needPassphrase, KeychainChoice &choice); + void retryQueryKeychainAccess (Reason reason, KeychainChoice &choice); + + // one-shot code-identity confirmation query + void queryCodeIdentity(const OSXCode *requestor, pid_t requestPid, + const char *aclPath, KeychainChoice &choice); // generic old passphrase query void queryOldGenericPassphrase(const OSXCode *requestor, pid_t requestPid, @@ -150,7 +187,7 @@ public: bool retryAuthorizationAuthenticate(Reason reason, char username[maxUsernameLength], char passphrase[maxPassphraseLength]); - bool invokeMechanism(const string &inPluginId, const string &inMechanismId, const AuthorizationValueVector *inArguments, const AuthorizationItemSet *inHints, const AuthorizationItemSet *inContext, AuthorizationResult *outResult, AuthorizationItemSet *&outHintsPtr, AuthorizationItemSet *&outContextPtr); + bool invokeMechanism(const string &inPluginId, const string &inMechanismId, const AuthValueVector &inArguments, AuthItemSet &inHints, AuthItemSet &inContext, AuthorizationResult *outResult); void terminateAgent(); @@ -167,10 +204,7 @@ private: Port mClientPort; bool mActive; uid_t desktopUid; - gid_t desktopGid; - bool mUsePBS; Bootstrap mClientBootstrap; - mach_port_t pbsBootstrap; bool mKeepAlive; enum Stage { @@ -180,13 +214,14 @@ private: newGenericPassphraseStage, // in get-new-generic-passphrase sub-protocol oldGenericPassphraseStage, // in get-old-generic-passphrase sub-protocol authorizeStage, // in authorize-by-group-membership sub-protocol + queryKeychainAccessStage, invokeMechanismStage // in invoke mechanism sub-protocol } stage; Port mStagePort; + string mAgentName; - void setClientGroupID(const char *grpName = NULL); void locateDesktop(); - void establishServer(const char *name); + void establishServer(); void check(kern_return_t error); void unstage(); diff --git a/SecurityServer/SecurityServer.order b/SecurityServer/SecurityServer.order index 96e116f6..20bbfc27 100644 --- a/SecurityServer/SecurityServer.order +++ b/SecurityServer/SecurityServer.order @@ -1,103 +1,265 @@ -_ucsp_server__FP17mach_msg_header_tn1 -__Xsetup__FP17mach_msg_header_tn1 -save_world -_ucsp_server_setup__FUiUiG16security_token_tPlUiPCc -___get_eh_context -_eh_context_via_pthreads -_dcast__C14__si_type_infoRC9type_infoiPvPCB1Pv -___eq__C9type_infoRCB0 -_setupConnection__6ServerGQ212MachPlusPlus4Portn1RC16security_token_tPCc -_check__5Mutexi -rest_world -_debug__5MutexPCc -___builtin_new -___7ProcessGQ212MachPlusPlus4PortPCcUiUi -_sessionForPort__7ProcessGQ212MachPlusPlus4Port -_make__7Session -_check__5Mutexi -___10ConnectionR7ProcessGQ212MachPlusPlus4Port -_check__5Mutexi -_self__Q212MachPlusPlus4Port -__XdecodeDb__FP17mach_msg_header_tn1 -_ucsp_server_decodeDb__FUiUiG16security_token_tPlPUlPQ211DataWalkers18DLDbFlatIdentifierUiPB1P17AccessCredentialsUiPB2PvUi -_connection__6ServerUi -_beginWork__10Connection -_beginConnection__7ProcessR10Connection -_debug__5MutexPCc -_check__5Mutexi -_debug__5MutexPCc -___9XDatabaseRC14DLDbIdentifierPCQ214SecurityServer6DbBlobR7SessionPC17AccessCredentials -_check__5Mutexi -_debug__5MutexPCc -_dumpState__9XDatabasePCc -___builtin_delete -_endWork__10Connection -_checkWork__10Connection -_debug__5MutexPCc -_endConnection__7ProcessR10Connection -_handle__6ServerP17mach_msg_header_tn1 -__XisLocked__FP17mach_msg_header_tn1 -_ucsp_server_isLocked__FUiUiG16security_token_tPlUlPi -___dynamic_cast -_dcast__C17__class_type_infoRC9type_infoiPvPCB1Pv -__XunlockDb__FP17mach_msg_header_tn1 -_ucsp_server_unlockDb__FUiUiG16security_token_tPlUl -_generateNewSecrets__18DatabaseCryptoCore -_encodeKeyCore__C18DatabaseCryptoCoreR7CssmKeyRC8CssmDatan1 -___18SecurityAgentQuery -___cl__11QueryUnlockPC17AccessCredentials -_query__15QueryPassphrasePC17AccessCredentialsl -_getBatchPassphrase__15QueryPassphrasePC17AccessCredentialslR13CssmOwnedData -_queryInteractive__11QueryUnlockR13CssmOwnedData -_connection__6Server -_decodeKeyCore__C18DatabaseCryptoCorePQ214SecurityServer7KeyBlobR7CssmKeyRPvn1 -_encodeCore__C18DatabaseCryptoCoreRCQ214SecurityServer6DbBlobRC8CssmDatan2 -_decodeCore__18DatabaseCryptoCorePQ214SecurityServer6DbBlobRC8CssmDataPPv -_makeRawKey__18DatabaseCryptoCorePvUlUl -__._18DatabaseCryptoCore -__._12CssmAutoData -__._11QueryUnlock -___eh_rtime_match -___get_eh_info -___start_cp_handler -___cp_pop_exception -___is_pointer__FPv -___eh_free -_unlock__9XDatabase -_reset__12CssmAutoData -_decode__9XDatabaseRC8CssmData -_unlock__Q29XDatabase6CommonPQ214SecurityServer6DbBlobRC8CssmDataPPv -_deriveDbCryptoKey__C18DatabaseCryptoCoreRC8CssmDatan1 -_getCsp__6Server -_check__5Mutexi -_unwrapKey__10ConnectionP9XDatabaseRC7ContextP3KeyPC17AccessCredentialsPC17AclEntryPrototypeUlUlG7CssmKeyPB3P8CssmData -_ucsp_server_unwrapKey__FUiUiG16security_token_tPlUlG7ContextPvPQ27Context4AttrUiUlP17AccessCredentialsUiPB3P17AclEntryPrototypeUiPB4UlG7CssmKeyPvUiUlUlPPvPUiPUlPQ27CssmKey6Header -_ucsp_server_lockDb__FUiUiG16security_token_tPlUl -_ucsp_server_getOwner__FUiUiG16security_token_tPlQ214SecurityServer7AclKindUlPP17AclOwnerPrototypePUiPPB2 -__XgenerateKey__FP17mach_msg_header_tn1 -_ucsp_server_changePassphrase__FUiUiG16security_token_tPlUlP17AccessCredentialsUiPB1 -_debug__5MutexPCc -_reset__12CssmAutoData -_activity__Q29XDatabase6Common -_makeDictionary__FRC14DLDbIdentifier -_lockNotify__16KeychainNotifierRC14DLDbIdentifierb -start -__start -__call_mod_init_funcs -__dyld_init_check -dyld_stub_binding_helper -___18DatabaseCryptoCore -__dyld_func_lookup -__._Q210CssmClient3Key -_notifyDeadName__6ServerGQ212MachPlusPlus4Port -_abort__10Connection -__._10Connection -__._Q210CssmClient7WrapKey -_generateMac__10ConnectionRC7ContextR3KeyRC8CssmDataRB3 -_active__6Server -_encrypt__10ConnectionRC7ContextR3KeyRC8CssmDataRB3 -_key__6ServerUl -_verifyMac__10ConnectionRC7ContextR3KeyRC8CssmDatan1 -_kill__7Process -__._7Process -_self__Q212MachPlusPlus4Port +__ZN13Authorization8RightSetD1Ev +__ZN13Authorization8RightSetD4Ev +__ZN13Authorization8RightSetD2Ev +__ZN13Authorization15MutableRightSetD4Ev +__ZN13Authorization15MutableRightSetD1Ev +__ZN6Server6handleEP17mach_msg_header_tS1_ +__Z11ucsp_serverP17mach_msg_header_tS0_ +__ZN6Server14notifyDeadNameEN8Security12MachPlusPlus4PortE +past end of text +__ZN6Server10connectionEj +__ZN6Server15requestCompleteEv +__ZN6Server15setupConnectionENS_12ConnectLevelEN8Security12MachPlusPlus4PortES3_S3_RK16security_token_tPKNS1_14SecurityServer15ClientSetupInfoEPKc +__ZN6Server10connectionEb +__ZN10Connection9checkWorkEv +__ZN7ProcessD4Ev +__ZN7Session4findEN8Security12MachPlusPlus4PortE +__ZN7ProcessC4EN8Security12MachPlusPlus4PortENS1_8TaskPortEPKNS0_14SecurityServer15ClientSetupInfoEPKcjj +__ZNK13Authorization4Rule17evaluateMechanismEPK20AuthorizationItemSetR18AuthorizationTokenRSt3setINS_10CredentialESt4lessIS7_ESaIS7_EE +__ZNK13Authorization4Rule16agentNameForAuthERK18AuthorizationToken +__ZN7Process13endConnectionER10Connection +__ZN10Connection7endWorkEv +__ZN7Process15beginConnectionER10Connection +__ZN10Connection9beginWorkEv +__ZN18AuthorizationToken4findERKN8Security14SecurityServer17AuthorizationBlobE +__Z17ucsp_server_setupjj16security_token_tPljN8Security14SecurityServer15ClientSetupInfoEPKc +__ZN13Authorization4RuleC4ERKSsPK14__CFDictionaryS5_ +__ZN7Process18checkAuthorizationEP18AuthorizationToken +__ZNK13Authorization20AuthorizationDBPlist7getRuleERKNS_5RightE +__ZN7Session16mergeCredentialsERSt3setIN13Authorization10CredentialESt4lessIS2_ESaIS2_EE +__ZN13Authorization15MutableRightSet9push_backERKNS_5RightE +__ZN13Authorization6Engine9authorizeERKNS_8RightSetEPK20AuthorizationItemSetmPKSt3setINS_10CredentialESt4lessIS8_ESaIS8_EEPSC_PNS_15MutableRightSetER18AuthorizationToken +__ZN7Session13authGetRightsERKN8Security14SecurityServer17AuthorizationBlobERKN13Authorization8RightSetEPK20AuthorizationItemSetmRNS5_15MutableRightSetE +__Z26ucsp_server_getSessionInfojj16security_token_tPlPmS1_ +__Z35ucsp_server_authorizationCopyRightsjj16security_token_tPlN8Security14SecurityServer17AuthorizationBlobEP20AuthorizationItemSetjS5_mS5_jS5_PS5_PjS6_ +__ZN10ConnectionC4ER7ProcessN8Security12MachPlusPlus4PortE +__ZN7Session10addProcessEP7Process +__ZN18AuthorizationToken16mergeCredentialsERKSt3setIN13Authorization10CredentialESt4lessIS2_ESaIS2_EE +__ZNK13Authorization4Rule21evaluateMechanismOnlyERKNS_5RightERKS0_RNS_15MutableRightSetER18AuthorizationTokenRSt3setINS_10CredentialESt4lessISB_ESaISB_EE +__ZN7Session10authCreateERKN13Authorization8RightSetEPK20AuthorizationItemSetmRN8Security14SecurityServer17AuthorizationBlobE +__ZN10Connection5abortEb +__ZN7Session13authorizationERKN8Security14SecurityServer17AuthorizationBlobE +__ZN18AuthorizationTokenC4ER7SessionRKSt3setIN13Authorization10CredentialESt4lessIS4_ESaIS4_EE +__ZNK18AuthorizationToken14effectiveCredsEv +__ZN10ConnectionC1ER7ProcessN8Security12MachPlusPlus4PortE +__ZN9XDatabaseC4ERKN8Security14DLDbIdentifierEPKNS0_14SecurityServer6DbBlobER7ProcessPKNS0_17AccessCredentialsE +__ZN7ProcessC1EN8Security12MachPlusPlus4PortENS1_8TaskPortEPKNS0_14SecurityServer15ClientSetupInfoEPKcjj +__ZN5DbKeyC4EcRKN8Security8CssmDataEbj +__ZN18AuthorizationToken10endProcessER7Process +__Z7_XsetupP17mach_msg_header_tS0_ +__ZN13Authorization5RightD1Ev +__ZN13Authorization5RightD4Ev +__ZN7Process19removeAuthorizationEP18AuthorizationToken +__ZN7Session13removeProcessEP7Process +__ZN7Session4findEm +__ZNK13Authorization4Rule12evaluateUserERKNS_5RightERKS0_RNS_15MutableRightSetEmdPKSt3setINS_10CredentialESt4lessIS9_ESaIS9_EERSD_R18AuthorizationToken +__ZN18AuthorizationToken17setCredentialInfoERKN13Authorization10CredentialE +__Z16_XgetSessionInfoP17mach_msg_header_tS0_ +__ZN18SecurityAgentQuery8activateEv +__ZN13Authorization4Rule9Attribute9getVectorEPK14__CFDictionaryPK10__CFStringb +__ZN13Authorization8RightSetC1EPK20AuthorizationItemSet +__ZN13Authorization8RightSetC4EPK20AuthorizationItemSet +__ZN13Authorization8RightSetC2EPK20AuthorizationItemSet +__ZN18DatabaseCryptoCore10decodeCoreEPN8Security14SecurityServer6DbBlobEPPv +__ZN18DatabaseCryptoCore10makeRawKeyEPvmmm +__ZNK13Authorization4Rule26evaluateCredentialForRightERKNS_5RightERKS0_PK20AuthorizationItemSetdRKNS_10CredentialEb +__ZN14CodeSignatures7addLinkERKN8Security8CssmDataES3_PKcb +__ZN13Authorization4RuleD4Ev +__ZN14CodeSignatures8makeLinkERNS_8IdentityERKSsbj +__ZN13Authorization20AuthorizationDBPlist4syncEd +__ZN13Authorization15MutableRightSetC4EmRKNS_5RightE +__ZN13Authorization15MutableRightSetC1EmRKNS_5RightE +__ZN13Authorization5RightC1Ev +__ZN7ProcessD0Ev +__ZN13Authorization5RightC4Ev +__ZN17AuthorizationItemC2Ev +__ZN17AuthorizationItemC4Ev +__Z31ucsp_server_authorizationCreatejj16security_token_tPlP20AuthorizationItemSetjS2_mS2_jS2_PN8Security14SecurityServer17AuthorizationBlobE +__Z20ucsp_server_decodeDbjj16security_token_tPlPmPN8Security11DataWalkers18DLDbFlatIdentifierEjS5_PNS2_17AccessCredentialsEjS7_Pvj +__ZN13Authorization15MutableRightSet4growEm +__ZN13Authorization10CredentialD4Ev +__ZN13Authorization10CredentialD1Ev +__ZN13Authorization5RightC1EPKcmPKv +__ZN13Authorization5RightC4EPKcmPKv +__Z20ucsp_server_isLockedjj16security_token_tPlmPi +__ZN14CodeSignatures8IdentityC2Ev +__ZN14CodeSignatures8IdentityC4Ev +__ZN18AuthorizationToken10addProcessER7Process +__ZN7Process16addAuthorizationEP18AuthorizationToken +__ZN18SecurityAgentQuery9terminateEv +__Z29__MIG_check__Request__setup_tP18__Request__setup_t +__ZN7Session15authExternalizeERKN8Security14SecurityServer17AuthorizationBlobER25AuthorizationExternalForm +__Z38__MIG_check__Request__getSessionInfo_tP27__Request__getSessionInfo_t +__ZN26CheckingReconstituteWalkerC4EPvS0_mb +__Z20ucsp_server_setupNewjj16security_token_tPljN8Security14SecurityServer15ClientSetupInfoEPKcPj +__ZN18AuthorizationToken7DeleterC4ERKN8Security14SecurityServer17AuthorizationBlobE +__ZN7Session8authFreeERKN8Security14SecurityServer17AuthorizationBlobEm +__ZN14DynamicSessionC4ERKN8Security12MachPlusPlus9BootstrapE +__ZN13Authorization15MutableRightSetC4ERKNS_8RightSetE +__ZN13Authorization15MutableRightSetC1ERKNS_8RightSetE +__ZN7Process4killEb +__ZN20QueryInvokeMechanismclERKSsS1_PK24AuthorizationValueVectorRKN13Authorization8RightSetES8_PmRP20AuthorizationItemSetSC_ +__ZNK13Authorization14CredentialImplltERKS0_ +__Z30ucsp_server_addCodeEquivalencejj16security_token_tPlPvjS1_jPKci +__ZN18AuthorizationToken7infoSetEv +__ZN10ConnectionD0Ev +__ZN10ConnectionD4Ev +__ZN7SessionC4EN8Security12MachPlusPlus9BootstrapENS1_4PortEm +__ZN14CodeSignatures8IdentityD2Ev +__ZN14CodeSignatures8IdentityD4Ev +__ZN5DbKeyC1EcRKN8Security8CssmDataEbj +__ZN13Authorization4RuleD1Ev +__Z10_XisLockedP17mach_msg_header_tS0_ +__ZNK13Authorization4Rule8evaluateERKNS_5RightERKS0_RNS_15MutableRightSetEmdPKSt3setINS_10CredentialESt4lessIS9_ESaIS9_EERSD_R18AuthorizationToken +__Z25_XauthorizationCopyRightsP17mach_msg_header_tS0_ +__ZN13Authorization4RuleC1ERKSsPK14__CFDictionaryS5_ +__ZN18AuthorizationTokenD4Ev +__Z32ucsp_server_authorizationReleasejj16security_token_tPlN8Security14SecurityServer17AuthorizationBlobEm +__ZN7Process11addDatabaseEP9XDatabase +__ZN7Session15authInternalizeERK25AuthorizationExternalFormRN8Security14SecurityServer17AuthorizationBlobE +__ZN7Process14removeDatabaseEP9XDatabase +__ZN9XDatabaseD4Ev +__ZN7Session16addAuthorizationEP18AuthorizationToken +__ZNK13Authorization14CredentialImpl7isValidEv +__ZN13Authorization20AuthorizationDBPlist4loadEv +__ZN18AuthorizationToken10setInfoSetER20AuthorizationItemSet +__ZN13Authorization4Rule9Attribute7getBoolEPK14__CFDictionaryPK10__CFStringbb +__ZN7Session19removeAuthorizationEP18AuthorizationToken +__ZN13Authorization4Rule9Attribute9getStringEPK14__CFDictionaryPK10__CFStringbPc +__Z36ucsp_server_authorizationExternalizejj16security_token_tPlN8Security14SecurityServer17AuthorizationBlobEP25AuthorizationExternalForm +__ZN20QueryInvokeMechanismC1EjRK18AuthorizationTokenPKc +__ZN18SecurityAgentQueryD4Ev +__ZN20QueryInvokeMechanismC4EjRK18AuthorizationTokenPKc +__ZN18SecurityAgentQueryC2EjR7SessionPKc +__ZN18SecurityAgentQueryC4EjR7SessionPKc +__ZN18AuthorizationToken7DeleterC1ERKN8Security14SecurityServer17AuthorizationBlobE +__ZNK18DatabaseCryptoCore17deriveDbMasterKeyERKN8Security8CssmDataE +__ZN18AuthorizationTokenC1ER7SessionRKSt3setIN13Authorization10CredentialESt4lessIS4_ESaIS4_EE +__ZNK13Authorization14CredentialImpl8isSharedEv +__Z21_XauthorizationCreateP17mach_msg_header_tS0_ +__Z22_XauthorizationReleaseP17mach_msg_header_tS0_ +__Z23ucsp_server_setupThreadjj16security_token_tPlj +__Z33ucsp_server_authorizationCopyInfojj16security_token_tPlN8Security14SecurityServer17AuthorizationBlobEPKcPP20AuthorizationItemSetPjS8_ +__ZN7Session11authGetInfoERKN8Security14SecurityServer17AuthorizationBlobEPKcRP20AuthorizationItemSet +__ZN7Session14clearResourcesEv +__ZN8Listener6removeEN8Security12MachPlusPlus4PortE +__ZN8ListenerC4ER7ProcessN8Security12MachPlusPlus4PortEmm +__ZN6Server8loadCssmEv +__Z47__MIG_check__Request__authorizationCopyRights_tP36__Request__authorizationCopyRights_t +__ZN13Authorization4Rule9Attribute19getLocalizedPromptsEPK14__CFDictionaryRSt3mapISsSsSt4lessISsESaISt4pairIKSsSsEEE +__Z32__MIG_check__Request__isLocked_tP21__Request__isLocked_t +__ZN13Authorization15MutableRightSet4swapERS0_ +__ZN9XDatabaseC1ERKN8Security14DLDbIdentifierEPKNS0_14SecurityServer6DbBlobER7ProcessPKNS0_17AccessCredentialsE +__Z36ucsp_server_authorizationInternalizejj16security_token_tPl25AuthorizationExternalFormPN8Security14SecurityServer17AuthorizationBlobE +__Z20_XaddCodeEquivalenceP17mach_msg_header_tS0_ +__ZN8Listener6notifyEmmRKN8Security8CssmDataE +__Z10_XdecodeDbP17mach_msg_header_tS0_ +__Z21ucsp_server_releaseDbjj16security_token_tPlm +__Z26_XauthorizationExternalizeP17mach_msg_header_tS0_ +_main +__ZN18AuthorizationToken7Deleter6removeEv +__ZN18DatabaseCryptoCoreC4Ev +__ZN18AuthorizationTokenD1Ev +__ZN18AuthorizationToken14mayInternalizeER7Processb +__ZN7Session9eliminateEN8Security12MachPlusPlus4PortE +__ZN13Authorization14CredentialImpl5mergeERKS0_ +__ZN9XDatabase6Common6unlockEPN8Security14SecurityServer6DbBlobEPPv +__ZN13Authorization14CredentialImplC4ERKSsS2_b +__ZN9XDatabase6Common8activityEv +__ZN6ServerC4ER9AuthorityR14CodeSignaturesPKc +__ZN7SessionC2EN8Security12MachPlusPlus9BootstrapENS1_4PortEm +__Z44__MIG_check__Request__authorizationRelease_tP33__Request__authorizationRelease_t +__Z43__MIG_check__Request__authorizationCreate_tP32__Request__authorizationCreate_t +__ZN9XDatabaseD0Ev +__Z11_XreleaseDbP17mach_msg_header_tS0_ +__ZN14DynamicSessionC1ERKN8Security12MachPlusPlus9BootstrapE +__Z26_XauthorizationInternalizeP17mach_msg_header_tS0_ +__Z24ucsp_server_setupSessionjj16security_token_tPlmm +__Z10_XsetupNewP17mach_msg_header_tS0_ +__ZN9XDatabase6CommonC4ERKNS_12DbIdentifierERNS_9CommonMapE +__ZN9XDatabase6CommonC1ERKNS_12DbIdentifierERNS_9CommonMapE +__ZN18DatabaseCryptoCoreC2Ev +__Z14_XsetupSessionP17mach_msg_header_tS0_ +__Z34ucsp_server_unlockDbWithPassphrasejj16security_token_tPlmPvj +__ZN7Session5setupEmm +__ZN7Session15setupAttributesEm +__Z48__MIG_check__Request__authorizationExternalize_tP37__Request__authorizationExternalize_t +__ZN14CodeSignatures8Identity13canonicalNameERKSs +__Z32__MIG_check__Request__decodeDb_tP21__Request__decodeDb_t +__ZN13Authorization4Rule9Attribute9getDoubleEPK14__CFDictionaryPK10__CFStringbd +__Z42__MIG_check__Request__addCodeEquivalence_tP31__Request__addCodeEquivalence_tPS0_ +__ZN8Listener8notifyMeEmmRKN8Security8CssmDataE +__ZNK18AuthorizationToken14mayExternalizeER7Process +__ZN14EntropyManager17updateEntropyFileEv +__ZNK13Authorization14CredentialImpl12creationTimeEv +__ZN9XDatabase6decodeEv +__ZNK8Security14SecurityServer10CommonBlob8validateEl +__ZNK8Security14SecurityServer10CommonBlob7isValidEv +__Z13_XsetupThreadP17mach_msg_header_tS0_ +__ZN9XDatabase6unlockERKN8Security8CssmDataE +__Z23_XauthorizationCopyInfoP17mach_msg_header_tS0_ +__Z31ucsp_server_requestNotificationjj16security_token_tPljmm +__ZN16KeychainNotifier6notifyERKN8Security14DLDbIdentifierEi +__ZN18DatabaseCryptoCore5setupEPKN8Security14SecurityServer6DbBlobERKNS0_8CssmDataE +__ZN14DynamicSessionD4Ev +__ZN9XDatabase16lockAllDatabasesERNS_9CommonMapEb +__ZN9XDatabase6CommonD4Ev +__ZN13Authorization14CredentialImplC1ERKSsS2_b +__ZN13Authorization10CredentialC4ERKSsS2_b +__ZN13Authorization10CredentialC1ERKSsS2_b +__ZN20QueryInvokeMechanism14terminateAgentEv +__ZN9XDatabase6decodeERKN8Security8CssmDataE +__ZN9XDatabase12makeUnlockedERKN8Security8CssmDataE +__ZN17SecurityServerAclD2Ev +__Z36__MIG_check__Request__setupSession_tP25__Request__setupSession_t +__ZN17SecurityServerAclD4Ev +__Z32__MIG_check__Request__setupNew_tP21__Request__setupNew_t +__ZN13Authorization20AuthorizationDBPlist11parseConfigEP14__CFDictionary +__Z48__MIG_check__Request__authorizationInternalize_tP37__Request__authorizationInternalize_t +__ZN14EntropyManagerC4ERN8Security12MachPlusPlus10MachServerEPKc +__Z33__MIG_check__Request__releaseDb_tP22__Request__releaseDb_t +__ZN14EntropyManager6actionEv +__ZN16KeychainNotifier6unlockERKN8Security14DLDbIdentifierE +__ZN7SessionD4Ev +__Z21_XrequestNotificationP17mach_msg_header_tS0_ +__ZN11RootSessionC4EN8Security12MachPlusPlus4PortEm +__Z24_XunlockDbWithPassphraseP17mach_msg_header_tS0_ +__Z7initMdsv +__Z45__MIG_check__Request__authorizationCopyInfo_tP34__Request__authorizationCopyInfo_t +__Z13handleSIGCHLDi +__Z35__MIG_check__Request__setupThread_tP24__Request__setupThread_t +__ZN13Authorization20AuthorizationDBPlistC4EPKc +__ZN18DatabaseCryptoCoreD4Ev +__Z28ucsp_server_stopNotificationjj16security_token_tPlj +__ZN6Server15notifyNoSendersEN8Security12MachPlusPlus4PortEj +__ZN7Process20requestNotificationsEN8Security12MachPlusPlus4PortEmm +__ZN8ListenerC1ER7ProcessN8Security12MachPlusPlus4PortEmm +__ZN11RootSessionC1EN8Security12MachPlusPlus4PortEm +__Z46__MIG_check__Request__unlockDbWithPassphrase_tP35__Request__unlockDbWithPassphrase_t +__ZN14EntropyManagerC1ERN8Security12MachPlusPlus10MachServerEPKc +__Z43__MIG_check__Request__requestNotification_tP32__Request__requestNotification_t +__ZN6ServerC1ER9AuthorityR14CodeSignaturesPKc +__ZN18DatabaseCryptoCoreD2Ev +__ZN7Process17stopNotificationsEN8Security12MachPlusPlus4PortE +__ZN7SessionD2Ev +__ZN14DynamicSession7releaseEv +__Z18_XstopNotificationP17mach_msg_header_tS0_ +__ZN14DynamicSessionD0Ev +__Z40__MIG_check__Request__stopNotification_tP29__Request__stopNotification_t +__ZN13Authorization20AuthorizationDBPlistC1EPKc +__ZN9XDatabase6CommonD0Ev +__ZN9XDatabase7discardEPNS_6CommonE +__ZN13Authorization14CredentialImpl10invalidateEv +__ZN13Authorization6EngineC4EPKc +__ZN8ListenerD4Ev +__ZN8ListenerD0Ev +__Z14handleSIGOtheri +__ZN13Authorization6EngineC2EPKc +__ZN9AuthorityC1EPKc +__ZN9AuthorityC4EPKc +__ZN14CodeSignaturesC1EPKc +__ZN14EntropyManager14collectEntropyEv +__ZN14CodeSignaturesC4EPKc +_ucsp_notify_sender_notify +__ZN6Server3runEv +__ZN13Authorization14CredentialImplD4Ev diff --git a/SecurityServer/StartupItems/CodeEquivalenceCandidates b/SecurityServer/StartupItems/CodeEquivalenceCandidates new file mode 100644 index 00000000..77721b53 --- /dev/null +++ b/SecurityServer/StartupItems/CodeEquivalenceCandidates @@ -0,0 +1,26 @@ +/System/Library/CoreServices/Finder.app +/Applications/iChat.app +/Applications/iSync.app +/Applications/Mail.app +/Applications/Safari.app +/Applications/Utilities/AirPort Admin Utility.app +/Applications/Utilities/Keychain Access.app +/Applications/Utilities/Keychain Access.app/Contents/Resources/Keychain Agent +/System/Library/CoreServices/loginwindow.app +/System/Library/CoreServices/MirrorAgent.app +/System/Library/CoreServices/SecurityAgent.app +/System/Library/Filesystems/ftp.fs/mount_ftp +/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Support/AEServer +/System/Library/PrivateFrameworks/Admin.framework/Versions/A/Resources/writeconfig +/System/Library/PrivateFrameworks/InstantMessage.framework/iChatAgent.app +/System/Library/ScriptingAdditions/Keychain Scripting.app +/sbin/mount_smbfs +/sbin/mount_webdav +/usr/bin/certtool +/usr/bin/crlrefresh +/usr/bin/security +/usr/bin/smbutil +/usr/local/bin/cmsutil +/usr/sbin/pppd +/usr/sbin/racoon +/usr/sbin/systemkeychain diff --git a/SecurityServer/StartupItems/SecurityServer b/SecurityServer/StartupItems/SecurityServer index 0cf2129e..62fa1787 100755 --- a/SecurityServer/StartupItems/SecurityServer +++ b/SecurityServer/StartupItems/SecurityServer @@ -2,12 +2,31 @@ . /etc/rc.common -SECURITYSERVER=-YES- # needs to be put into /etc/hostconfig - -if [ "$SECURITYSERVER" != "-NO-" ]; then - ConsoleMessage "Starting SecurityServer" - export DEBUGDEST=LOG_AUTHPRIV - /System/Library/CoreServices/SecurityServer -X -else - ConsoleMessage "SecurityServer disabled" +# we could make this optional, but the system depends on SecurityServer A LOT... + +ConsoleMessage "Starting SecurityServer" + +export DEBUGDEST=LOG_AUTHPRIV +#export DEBUGOPTIONS=thread,scope # only useful with +#export DEBUGSCOPE=-mutex # debug-enabled SecurityServers +/System/Library/CoreServices/SecurityServer -X + +if [ ! -f /Library/Keychains/System.keychain -a -x /usr/sbin/systemkeychain ]; then + # no system keychain; make one + ConsoleMessage "Creating System Keychain" + if [ ! -d /Library/Keychains ]; then + mkdir -p /Library/Keychains + chown root.admin /Library/Keychains + chmod 755 /Library/Keychains # do NOT make this 775 -- Security! + fi + sleep 2 # give SecurityServer a chance to come up + /usr/sbin/systemkeychain -C + touch /Library/Keychains/.fixed + +elif [ ! -f /Library/Keychains/.fixed -a -x /usr/sbin/systemkeychain ]; then + # temporary fix: replace broken (early) system keychains (missing db schema) + sleep 2 + rm -f /Library/Keychains/System.keychain + /usr/sbin/systemkeychain -C + touch /Library/Keychains/.fixed fi diff --git a/SecurityServer/TODO b/SecurityServer/TODO index 4fb0efdc..f3d66f72 100644 --- a/SecurityServer/TODO +++ b/SecurityServer/TODO @@ -1,18 +1 @@ SecurityServer is a work in progress. - -Important items that we know need to be cleaned up for Cheetah: -Sort out which memory allocations should be sensitive, and make them so. -Use CssmAutoData & friends copiously -Replace MIG server loop with a custom version and integrate deferred - allocation release and timed events. - -Questionable for Cheetah (not important enough/too big?): -Multi-threading the SecurityServer main request loop. This would require - thread-safing the entire server core, which right now it probably isn't. - -Major missing features (for future consideration): -ACL-related callbacks (+ possibly other callbacks) - This would require IPC support that makes the IPC path asynchronous - (or else requires interesting step dancing on the client side). - It's not trivial, but eventually we'll have to do it. At least the - data structure transports are already pretty much in place. diff --git a/SecurityServer/acl_keychain.cpp b/SecurityServer/acl_keychain.cpp index 5ebe403c..eb8408db 100644 --- a/SecurityServer/acl_keychain.cpp +++ b/SecurityServer/acl_keychain.cpp @@ -87,7 +87,7 @@ bool KeychainPromptAclSubject::validate(const AclValidationContext &context, // check for special ACL-update override if (context.authorization() == CSSM_ACL_AUTHORIZATION_CHANGE_ACL && Server::connection().aclWasSetForUpdateTrigger(env->acl)) { - debug("kcacl", "honoring acl update trigger for %p(%s)", + secdebug("kcacl", "honoring acl update trigger for %p(%s)", &env->acl, description.c_str()); return true; } @@ -95,28 +95,24 @@ bool KeychainPromptAclSubject::validate(const AclValidationContext &context, // does the user need to type in the passphrase? const Database *db = env->database(); bool needPassphrase = db && (selector.flags & CSSM_ACL_KEYCHAIN_PROMPT_REQUIRE_PASSPHRASE); - debug("adhoc", "prompt acl db=%p needPassphrase=%d", db, needPassphrase); // ask the user - Process &cltProc = Server::active().connection().process; - debug("kcacl", "Keychain query from process %d (UID %d)", cltProc.pid(), cltProc.uid()); #if FECKLESS_KEYCHAIN_ACCESS_EXCEPTION - if (cltProc.clientCode()) + Process &process = Server::active().connection().process; + secdebug("kcacl", "Keychain query from process %d (UID %d)", process.pid(), process.uid()); + if (process.clientCode()) needPassphrase |= - cltProc.clientCode()->canonicalPath() == "/Applications/Utilities/Keychain Access.app"; + process.clientCode()->canonicalPath() == "/Applications/Utilities/Keychain Access.app"; #endif - QueryKeychainUse query(cltProc.uid(), cltProc.session, needPassphrase); - query((db ? db->dbName() : NULL), description.c_str(), context.authorization()); + QueryKeychainUse query(needPassphrase); + const char* dbName = db ? db->dbName() : NULL; + query.queryUser(db, dbName, description.c_str(), context.authorization()); - // verify keychain passphrase if required - if (needPassphrase && !env->database()->validatePassphrase(StringData(query.passphrase))) - return false; // needed passphrase, passphrase is wrong - // process "always allow..." response if (query.continueGrantingToCaller) { // mark for special ACL-update override (really soon) later Server::connection().setAclUpdateTrigger(env->acl); - debug("kcacl", "setting acl update trigger for %p(%s)", + secdebug("kcacl", "setting acl update trigger for %p(%s)", &env->acl, description.c_str()); // fail with prejudice (caller will retry) CssmError::throwMe(CSSMERR_CSP_APPLE_ADD_APPLICATION_ACL_SUBJECT); @@ -160,7 +156,7 @@ KeychainPromptAclSubject *KeychainPromptAclSubject::Maker::make(const TypedList ListElement *params[2]; crack(list, 2, params, CSSM_LIST_ELEMENT_DATUM, CSSM_LIST_ELEMENT_DATUM); return new KeychainPromptAclSubject(*params[1], - *CssmData(*params[0]).interpretedAs()); + *params[0]->data().interpretedAs(CSSM_ERRCODE_INVALID_ACL_SUBJECT_VALUE)); } default: CssmError::throwMe(CSSM_ERRCODE_INVALID_ACL_SUBJECT_VALUE); @@ -179,6 +175,8 @@ KeychainPromptAclSubject *KeychainPromptAclSubject::Maker::make(Version version, break; case jaguarVersion: pub(selector); + selector.version = n2h (selector.version); + selector.flags = n2h (selector.flags); pub(description); break; } @@ -207,15 +205,22 @@ KeychainPromptAclSubject::KeychainPromptAclSubject(string descr, // void KeychainPromptAclSubject::exportBlob(Writer::Counter &pub, Writer::Counter &priv) { - if (version() != 0) + if (version() != 0) { + selector.version = h2n (selector.version); + selector.flags = h2n (selector.flags); pub(selector); + } + pub.insert(description.size() + 1); } void KeychainPromptAclSubject::exportBlob(Writer &pub, Writer &priv) { - if (version() != 0) + if (version() != 0) { + selector.version = h2n (selector.version); + selector.flags = h2n (selector.flags); pub(selector); + } pub(description.c_str()); } diff --git a/SecurityServer/acls.cpp b/SecurityServer/acls.cpp index e60de410..c797248f 100644 --- a/SecurityServer/acls.cpp +++ b/SecurityServer/acls.cpp @@ -47,94 +47,38 @@ const Database *SecurityServerAcl::relatedDatabase() const // Provide environmental information to get/change-ACL calls. // Also make them virtual so our children can override them. // -void SecurityServerAcl::cssmGetAcl(const char *tag, uint32 &count, AclEntryInfo * &acls) -{ - instantiateAcl(); - return ObjectAcl::cssmGetAcl(tag, count, acls); -} - -void SecurityServerAcl::cssmGetOwner(AclOwnerPrototype &owner) -{ - instantiateAcl(); - return ObjectAcl::cssmGetOwner(owner); -} - void SecurityServerAcl::cssmChangeAcl(const AclEdit &edit, const AccessCredentials *cred) { - instantiateAcl(); SecurityServerEnvironment env(*this); ObjectAcl::cssmChangeAcl(edit, cred, &env); - noticeAclChange(); } void SecurityServerAcl::cssmChangeOwner(const AclOwnerPrototype &newOwner, const AccessCredentials *cred) { - instantiateAcl(); SecurityServerEnvironment env(*this); ObjectAcl::cssmChangeOwner(newOwner, cred, &env); - noticeAclChange(); } // // Modified validate() methods to connect all the conduits... // -void SecurityServerAcl::validate(AclAuthorization auth, const AccessCredentials *cred) const +void SecurityServerAcl::validate(AclAuthorization auth, const AccessCredentials *cred) { - instantiateAcl(); SecurityServerEnvironment env(*this); + StLock objectSequence(aclSequence); + StLock processSequence(Server::connection().process.aclSequence); ObjectAcl::validate(auth, cred, &env); } -void SecurityServerAcl::validate(AclAuthorization auth, const Context &context) const +void SecurityServerAcl::validate(AclAuthorization auth, const Context &context) { validate(auth, context.get(CSSM_ATTRIBUTE_ACCESS_CREDENTIALS)); } -// -// This function decodes the "special passphrase samples" that provide passphrases -// to the SecurityServer through ACL sample blocks. Essentially, it trolls a credentials -// structure's samples for the special markers, resolves anything that contains -// passphrases outright (and returns true), or returns false if the normal interactive -// procedures are to be followed. -// (This doesn't strongly belong to the SecurityServerAcl class, but doesn't really have -// a better home elsewhere.) -// -bool SecurityServerAcl::getBatchPassphrase(const AccessCredentials *cred, - CSSM_SAMPLE_TYPE neededSampleType, CssmOwnedData &passphrase) -{ - if (cred) { - // check all top-level samples - const SampleGroup &samples = cred->samples(); - for (uint32 n = 0; n < samples.length(); n++) { - TypedList sample = samples[n]; - if (!sample.isProper()) - CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); - if (sample.type() == neededSampleType) { - sample.snip(); - if (!sample.isProper()) - CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); - switch (sample.type()) { - case CSSM_SAMPLE_TYPE_KEYCHAIN_PROMPT: - return false; - case CSSM_SAMPLE_TYPE_PASSWORD: - if (sample.length() != 2) - CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); - passphrase = sample[1]; - return true; - default: - CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); - } - } - } - } - return false; -} - - // // Implement our environment object // @@ -153,7 +97,8 @@ pid_t SecurityServerEnvironment::getpid() const return Server::connection().process.pid(); } -bool SecurityServerEnvironment::verifyCodeSignature(const CodeSigning::Signature *signature) +bool SecurityServerEnvironment::verifyCodeSignature(const CodeSigning::Signature *signature, + const CssmData *comment) { - return Server::connection().process.verifyCodeSignature(signature); + return Server::codeSignatures().verify(Server::connection().process, signature, comment); } diff --git a/SecurityServer/acls.h b/SecurityServer/acls.h index 0bbd998c..a23e8820 100644 --- a/SecurityServer/acls.h +++ b/SecurityServer/acls.h @@ -43,22 +43,17 @@ public: AclKind kind() const { return mKind; } // validation calls restated - void validate(AclAuthorization auth, const AccessCredentials *cred) const; - void validate(AclAuthorization auth, const Context &context) const; + void validate(AclAuthorization auth, const AccessCredentials *cred); + void validate(AclAuthorization auth, const Context &context); - void cssmGetAcl(const char *tag, uint32 &count, AclEntryInfo * &acls); - void cssmGetOwner(AclOwnerPrototype &owner); void cssmChangeAcl(const AclEdit &edit, const AccessCredentials *cred); void cssmChangeOwner(const AclOwnerPrototype &newOwner, const AccessCredentials *cred); - virtual void instantiateAcl() = 0; - virtual void noticeAclChange() = 0; virtual const Database *relatedDatabase() const; -public: - static bool getBatchPassphrase(const AccessCredentials *cred, - CSSM_SAMPLE_TYPE neededSampleType, CssmOwnedData &passphrase); - + // aclSequence is taken to serialize ACL validations to pick up mutual changes + Mutex aclSequence; + private: AclKind mKind; }; @@ -83,7 +78,7 @@ public: uid_t getuid() const; gid_t getgid() const; pid_t getpid() const; - bool verifyCodeSignature(const CodeSigning::Signature *signature); + bool verifyCodeSignature(const CodeSigning::Signature *signature, const CssmData *comment); }; diff --git a/SecurityServer/agentquery.cpp b/SecurityServer/agentquery.cpp index ec6bd293..2e663a2a 100644 --- a/SecurityServer/agentquery.cpp +++ b/SecurityServer/agentquery.cpp @@ -27,23 +27,38 @@ using namespace SecurityAgent; +// +// The default Mach service name for SecurityAgent +// +const char SecurityAgentQuery::defaultName[] = "com.apple.SecurityAgent"; + + // // Construct a query object // +SecurityAgentQuery::SecurityAgentQuery() : + SecurityAgent::Client(Server::active().connection().process.uid(), + Server::active().connection().process.session.bootstrapPort(), + defaultName), + mClientSession(Server::active().connection().process.session) +{ +} + SecurityAgentQuery::SecurityAgentQuery(uid_t clientUID, - Session &clientSession) : - SecurityAgent::Client(clientUID, clientSession.bootstrapPort()), + Session &clientSession, + const char *agentName) : + SecurityAgent::Client(clientUID, clientSession.bootstrapPort(), agentName), mClientSession(clientSession) { } SecurityAgentQuery::~SecurityAgentQuery() { - // SecurityAgent::Client::~SecurityAgent already calls terminate(). + terminate(); } void -SecurityAgentQuery::activate(const char *bootstrapName = NULL) +SecurityAgentQuery::activate() { if (isActive()) return; @@ -54,9 +69,14 @@ SecurityAgentQuery::activate(const char *bootstrapName = NULL) // this may take a while Server::active().longTermActivity(); - Server::connection().useAgent(this); + Server::connection().useAgent(this); - SecurityAgent::Client::activate(bootstrapName); + try { + SecurityAgent::Client::activate(); + } catch (...) { + Server::connection().useAgent(NULL); // guess not + throw; + } } void @@ -65,7 +85,8 @@ SecurityAgentQuery::terminate() if (!isActive()) return; - Server::connection(true).useAgent(NULL); + Server::connection(true).useAgent(NULL); + SecurityAgent::Client::terminate(); } @@ -73,12 +94,49 @@ SecurityAgentQuery::terminate() // // Perform the "rogue app" access query dialog // -void QueryKeychainUse::operator () (const char *database, const char *description, +void QueryKeychainUse::queryUser (const Database *db, const char *database, const char *description, AclAuthorization action) { - queryKeychainAccess(Server::connection().process.clientCode(), + Reason reason; + int retryCount = 0; + queryKeychainAccess(Server::connection().process.clientCode(), Server::connection().process.pid(), database, description, action, needPassphrase, *this); + + CssmData data (passphrase, strlen (passphrase)); + + + if (needPassphrase) { + while (reason = (const_cast(db)->decode(data) ? noReason : invalidPassphrase)) { + if (++retryCount > kMaximumAuthorizationTries) { + cancelStagedQuery(tooManyTries); + return; + } + else { + retryQueryKeychainAccess (reason, *this); + data = CssmData (passphrase, strlen (passphrase)); + } + } + + finishStagedQuery (); // since we are only staged if we needed a passphrase + } + +} + +QueryKeychainUse::~QueryKeychainUse() +{ + // clear passphrase component (sensitive) + memset(passphrase, 0, sizeof(passphrase)); +} + + +// +// Perform code signature ACL access adjustment dialogs +// +void QueryCodeCheck::operator () (const char *aclPath) +{ + queryCodeIdentity(Server::connection().process.clientCode(), + Server::connection().process.pid(), aclPath, *this); } @@ -87,42 +145,34 @@ void QueryKeychainUse::operator () (const char *database, const char *descriptio // or we can't get another passphrase. Accept() should consume the passphrase // if it is accepted. If no passphrase is acceptable, throw out of here. // -void QueryPassphrase::query(const AccessCredentials *cred, CSSM_SAMPLE_TYPE sampleType) +Reason QueryUnlock::query() { CssmAutoData passphrase(CssmAllocator::standard(CssmAllocator::sensitive)); - if (SecurityServerAcl::getBatchPassphrase(cred, sampleType, passphrase)) { - // batch use - try the one and only, fail if unacceptable - if (accept(passphrase, false) == noReason) - return; - else - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PASSPHRASE); //@@@ not ideal - } else { - // interactive use - run a try/retry loop - unsigned int retryCount = 0; - queryInteractive(passphrase); - while (Reason reason = accept(passphrase, true)) { - if (++retryCount > maxRetries) { - cancelStagedQuery(tooManyTries); - CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_PASSPHRASE); //@@@ not ideal - } else { - retryInteractive(passphrase, reason); - } + int retryCount = 0; + queryInteractive(passphrase); + while (Reason reason = accept(passphrase)) { + if (++retryCount > maxTries) { + cancelStagedQuery(tooManyTries); + return reason; + } else { + retryInteractive(passphrase, reason); } - // accepted - finishStagedQuery(); } + // accepted + finishStagedQuery(); + return noReason; } // // Get existing passphrase (unlock) Query // -void QueryUnlock::operator () (const AccessCredentials *cred) +Reason QueryUnlock::operator () () { - query(cred, CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK); + return query(); } -Reason QueryUnlock::accept(CssmManagedData &passphrase, bool) +Reason QueryUnlock::accept(CssmManagedData &passphrase) { return database.decode(passphrase) ? noReason : invalidPassphrase; } @@ -144,57 +194,82 @@ void QueryUnlock::retryInteractive(CssmOwnedData &passphrase, Reason reason) } +// +// Obtain passphrases and submit them to the accept() method until it is accepted +// or we can't get another passphrase. Accept() should consume the passphrase +// if it is accepted. If no passphrase is acceptable, throw out of here. +// +Reason QueryNewPassphrase::query() +{ + CssmAutoData passphrase(CssmAllocator::standard(CssmAllocator::sensitive)); + CssmAutoData oldPassphrase(CssmAllocator::standard(CssmAllocator::sensitive)); + int retryCount = 0; + queryInteractive(passphrase, oldPassphrase); + while (Reason reason = accept(passphrase, + (initialReason == changePassphrase) ? &oldPassphrase.get() : NULL)) { + if (++retryCount > maxTries) { + cancelStagedQuery(tooManyTries); + return reason; + } else { + retryInteractive(passphrase, oldPassphrase, reason); + } + } + // accepted + finishStagedQuery(); + return noReason; +} + + // // Get new passphrase Query // -void QueryNewPassphrase::operator () (const AccessCredentials *cred, CssmOwnedData &passphrase) +Reason QueryNewPassphrase::operator () (CssmOwnedData &passphrase) { - query(cred, CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK); + if (Reason result = query()) + return result; // failed passphrase = mPassphrase; + return noReason; // success } -Reason QueryNewPassphrase::accept(CssmManagedData &passphrase, bool canRetry) +Reason QueryNewPassphrase::accept(CssmManagedData &passphrase, CssmData *oldPassphrase) { //@@@ acceptance criteria are currently hardwired here //@@@ This validation presumes ASCII - UTF8 might be more lenient - // if we can't retry (i.e. batch environment), accept it rather than fail terminally - if (!canRetry) { + // if we have an old passphrase, check it + if (oldPassphrase && !database.validatePassphrase(*oldPassphrase)) + return oldPassphraseWrong; + + // sanity check the new passphrase (but allow user override) + if (!(mPassphraseValid && passphrase.get() == mPassphrase)) { mPassphrase = passphrase; - return noReason; + mPassphraseValid = true; + if (mPassphrase.length() == 0) + return passphraseIsNull; + if (mPassphrase.length() < 6) + return passphraseTooSimple; } - // if the user insists (re-enters the same passphrase), allow it - if (mPassphraseValid && passphrase.get() == mPassphrase) - return noReason; - - // check simple criteria - mPassphrase = passphrase; - mPassphraseValid = true; - if (mPassphrase.length() == 0) - return passphraseIsNull; - const char *passString = mPassphrase; - if (strlen(passString) < 6) - return passphraseTooSimple; - // accept this return noReason; } -void QueryNewPassphrase::queryInteractive(CssmOwnedData &passphrase) +void QueryNewPassphrase::queryInteractive(CssmOwnedData &passphrase, CssmOwnedData &oldPassphrase) { - char passString[maxPassphraseLength]; + char passString[maxPassphraseLength], oldPassString[maxPassphraseLength]; queryNewPassphrase(Server::connection().process.clientCode(), Server::connection().process.pid(), - dbCommon.dbName(), initialReason, passString); + database.dbName(), initialReason, passString, oldPassString); passphrase.copy(passString, strlen(passString)); + oldPassphrase.copy(oldPassString, strlen(oldPassString)); } -void QueryNewPassphrase::retryInteractive(CssmOwnedData &passphrase, Reason reason) +void QueryNewPassphrase::retryInteractive(CssmOwnedData &passphrase, CssmOwnedData &oldPassphrase, Reason reason) { - char passString[maxPassphraseLength]; - retryNewPassphrase(reason, passString); + char passString[maxPassphraseLength], oldPassString[maxPassphraseLength]; + retryNewPassphrase(reason, passString, oldPassString); passphrase.copy(passString, strlen(passString)); + oldPassphrase.copy(oldPassString, strlen(oldPassString)); } @@ -202,7 +277,7 @@ void QueryNewPassphrase::retryInteractive(CssmOwnedData &passphrase, Reason reas // Authorize by group membership // QueryAuthorizeByGroup::QueryAuthorizeByGroup(uid_t clientUID, const AuthorizationToken &auth) : - SecurityAgentQuery(clientUID, auth.session), + SecurityAgentQuery(Server::active().connection().process.uid(), auth.session), authorization(auth), mActive(false) { } @@ -240,20 +315,16 @@ bool QueryAuthorizeByGroup::operator () (const char *group, const char *candidat } } -QueryInvokeMechanism::QueryInvokeMechanism(uid_t clientUID, const AuthorizationToken &auth) : - SecurityAgentQuery(clientUID, auth.session) {} +QueryInvokeMechanism::QueryInvokeMechanism(uid_t clientUID, const AuthorizationToken &auth, const char *agentName) : + SecurityAgentQuery(clientUID, auth.session, agentName) {} -bool QueryInvokeMechanism::operator () (const string &inPluginId, const string &inMechanismId, const AuthorizationValueVector *inArguments, const AuthItemSet &inHints, const AuthItemSet &inContext, AuthorizationResult *outResult, AuthorizationItemSet *&outHintsPtr, AuthorizationItemSet *&outContextPtr) +bool QueryInvokeMechanism::operator () (const string &inPluginId, const string &inMechanismId, const AuthValueVector &inArguments, AuthItemSet &inHints, AuthItemSet &inContext, AuthorizationResult *outResult) { - bool result = invokeMechanism(inPluginId, inMechanismId, inArguments, inHints, inContext, outResult, outHintsPtr, outContextPtr); - return result; + bool result = invokeMechanism(inPluginId, inMechanismId, inArguments, inHints, inContext, outResult); + return result; } -QueryTerminateAgent::QueryTerminateAgent(uid_t clientUID, const AuthorizationToken &auth) : - SecurityAgentQuery(clientUID, auth.session) {} - -void QueryTerminateAgent::operator () () +void QueryInvokeMechanism::terminateAgent() { - terminateAgent(); + SecurityAgentQuery::terminateAgent(); } - diff --git a/SecurityServer/agentquery.h b/SecurityServer/agentquery.h index 97d1a90d..f66d302f 100644 --- a/SecurityServer/agentquery.h +++ b/SecurityServer/agentquery.h @@ -38,11 +38,14 @@ class Session; class SecurityAgentQuery : protected SecurityAgent::Client { public: typedef SecurityAgent::Reason Reason; + + static const char defaultName[]; - SecurityAgentQuery(uid_t clientUID, Session &clientSession); + SecurityAgentQuery(); + SecurityAgentQuery(uid_t clientUID, Session &clientSession, const char *agentName = defaultName); virtual ~SecurityAgentQuery(); - virtual void activate(const char *bootstrapName = NULL); + virtual void activate(); virtual void terminate(); private: @@ -55,81 +58,63 @@ private: // class QueryKeychainUse : public SecurityAgent::Client::KeychainChoice, public SecurityAgentQuery { public: - QueryKeychainUse(uid_t clientUID, Session &clientSession, - bool needPass) : - SecurityAgentQuery(clientUID, clientSession), - needPassphrase(needPass) { } - void operator () (const char *database, const char *description, AclAuthorization action); + QueryKeychainUse(bool needPass) : needPassphrase(needPass) { } + void queryUser (const Database *db, const char* database, const char *description, AclAuthorization action); + ~QueryKeychainUse(); const bool needPassphrase; }; // -// Specialized for passphrase-yielding queries based on Credential markers +// Specialized for code signature adjustment queries // -class QueryPassphrase : public SecurityAgentQuery { -protected: - QueryPassphrase(uid_t clientUID, Session &clientSession, - unsigned int maxTries) : - SecurityAgentQuery(clientUID, clientSession), - maxRetries(maxTries) { } - void query(const AccessCredentials *cred, CSSM_SAMPLE_TYPE relevantSampleType); - - virtual void queryInteractive(CssmOwnedData &passphrase) = 0; - virtual void retryInteractive(CssmOwnedData &passphrase, Reason reason) = 0; - -protected: - virtual Reason accept(CssmManagedData &passphrase, bool canRetry) = 0; - -private: - const unsigned int maxRetries; +class QueryCodeCheck : public SecurityAgent::Client::KeychainChoice, public SecurityAgentQuery { +public: + void operator () (const char *aclPath); }; // // A query for an existing passphrase // -class QueryUnlock : public QueryPassphrase { - static const int maxTries = 3; +class QueryUnlock : public SecurityAgentQuery { + static const int maxTries = kMaximumAuthorizationTries; public: - QueryUnlock(uid_t clientUID, Session &clientSession, - Database &db) : - QueryPassphrase(clientUID, clientSession, maxTries), - database(db) { } + QueryUnlock(Database &db) : database(db) { } Database &database; - void operator () (const AccessCredentials *cred); + Reason operator () (); protected: + Reason query(); void queryInteractive(CssmOwnedData &passphrase); void retryInteractive(CssmOwnedData &passphrase, Reason reason); - Reason accept(CssmManagedData &passphrase, bool canRetry); + Reason accept(CssmManagedData &passphrase); }; // // A query for a new passphrase // -class QueryNewPassphrase : public QueryPassphrase { +class QueryNewPassphrase : public SecurityAgentQuery { static const int maxTries = 7; public: - QueryNewPassphrase(uid_t clientUID, Session &clientSession, - Database::Common &common, Reason reason) : - QueryPassphrase(clientUID, clientSession, maxTries), - dbCommon(common), initialReason(reason), + QueryNewPassphrase(Database &db, Reason reason) : + database(db), initialReason(reason), mPassphrase(CssmAllocator::standard(CssmAllocator::sensitive)), mPassphraseValid(false) { } - Database::Common &dbCommon; + Database &database; - void operator () (const AccessCredentials *cred, CssmOwnedData &passphrase); + Reason operator () (CssmOwnedData &passphrase); protected: - void queryInteractive(CssmOwnedData &passphrase); - void retryInteractive(CssmOwnedData &passphrase, Reason reason); - Reason accept(CssmManagedData &passphrase, bool canRetry); + Reason query(); + void queryInteractive(CssmOwnedData &passphrase, CssmOwnedData &oldPassphrase); + void retryInteractive(CssmOwnedData &passphrase, CssmOwnedData &oldPassphrase, Reason reason); + Reason accept(CssmManagedData &passphrase, CssmData *oldPassphrase); private: Reason initialReason; @@ -161,18 +146,14 @@ private: bool mActive; }; -class QueryInvokeMechanism : public SecurityAgentQuery { -public: - QueryInvokeMechanism(uid_t clientUID, const AuthorizationToken &auth); - bool operator () (const string &inPluginId, const string &inMechanismId, const AuthorizationValueVector *inArguments, const AuthItemSet &inHints, const AuthItemSet &inContext, AuthorizationResult *outResult, AuthorizationItemSet *&outHintsPtr, AuthorizationItemSet *&outContextPtr); -}; -class QueryTerminateAgent : public SecurityAgentQuery { +using Authorization::AuthValueVector; + +class QueryInvokeMechanism : public SecurityAgentQuery { public: - QueryTerminateAgent(uid_t clientUID, const AuthorizationToken &auth); - void operator () (); + QueryInvokeMechanism(uid_t clientUID, const AuthorizationToken &auth, const char *agentName); + bool operator () (const string &inPluginId, const string &inMechanismId, const AuthValueVector &inArguments, AuthItemSet &inHints, AuthItemSet &inContext, AuthorizationResult *outResult); + void terminateAgent(); }; - - #endif //_H_AGENTQUERY diff --git a/SecurityServer/authority.cpp b/SecurityServer/authority.cpp index 4873984c..60cefe45 100644 --- a/SecurityServer/authority.cpp +++ b/SecurityServer/authority.cpp @@ -27,7 +27,10 @@ #include "AuthorizationWalkers.h" -using Authorization::Right; +using Authorization::AuthItemSet; +using Authorization::AuthItemRef; +using Authorization::AuthValue; +using Authorization::AuthValueOverlay; // // The global dictionary of extant AuthorizationTokens @@ -52,10 +55,11 @@ Authority::~Authority() // // Create an authorization token. // -AuthorizationToken::AuthorizationToken(Session &ssn, const CredentialSet &base) +AuthorizationToken::AuthorizationToken(Session &ssn, const CredentialSet &base, const security_token_t &securityToken) : session(ssn), mBaseCreds(base), mTransferCount(INT_MAX), - mCreatorUid(Server::connection().process.uid()), - mCreatorCode(Server::connection().process.clientCode()), mInfoSet(NULL) + mCreatorUid(securityToken.val[0]), + mCreatorCode(Server::connection().process.clientCode()), + mCreatorPid(Server::connection().process.pid()) { // generate our (random) handle Server::active().random(mHandle); @@ -68,9 +72,9 @@ AuthorizationToken::AuthorizationToken(Session &ssn, const CredentialSet &base) session.addAuthorization(this); // all ready - IFDEBUG(debug("SSauth", "Authorization %p created using %d credentials; owner=%s", + secdebug("SSauth", "Authorization %p created using %d credentials; owner=%s", this, int(mBaseCreds.size()), - mCreatorCode ? mCreatorCode->encode().c_str() : "unknown")); + mCreatorCode ? mCreatorCode->encode().c_str() : "unknown"); } AuthorizationToken::~AuthorizationToken() @@ -82,14 +86,7 @@ AuthorizationToken::~AuthorizationToken() if (session.removeAuthorization(this)) delete &session; - // remove stored context - if (mInfoSet) - { - debug("SSauth", "Authorization %p destroying context @%p", this, mInfoSet); - CssmAllocator::standard().free(mInfoSet); // @@@ switch to sensitive allocator - } - - debug("SSauth", "Authorization %p destroyed", this); + secdebug("SSauth", "Authorization %p destroyed", this); } @@ -134,7 +131,8 @@ void AuthorizationToken::Deleter::remove() // must hold Session::mCredsLock CredentialSet AuthorizationToken::effectiveCreds() const { - IFDEBUG(debug("SSauth", "Authorization %p grabbing session %p creds %p", this, &session, &session.authCredentials())); + secdebug("SSauth", "Authorization %p grabbing session %p creds %p", + this, &session, &session.authCredentials()); CredentialSet result = session.authCredentials(); for (CredentialSet::const_iterator it = mBaseCreds.begin(); it != mBaseCreds.end(); it++) if (!(*it)->isShared()) @@ -149,12 +147,12 @@ CredentialSet AuthorizationToken::effectiveCreds() const // must hold Session::mCredsLock void AuthorizationToken::mergeCredentials(const CredentialSet &add) { - debug("SSauth", "Authorization %p merge creds %p", this, &add); + secdebug("SSauth", "Authorization %p merge creds %p", this, &add); for (CredentialSet::const_iterator it = add.begin(); it != add.end(); it++) { mBaseCreds.erase(*it); mBaseCreds.insert(*it); } - debug("SSauth", "Authorization %p merged %d new credentials for %d total", + secdebug("SSauth", "Authorization %p merged %d new credentials for %d total", this, int(add.size()), int(mBaseCreds.size())); } @@ -167,7 +165,7 @@ void AuthorizationToken::addProcess(Process &proc) { StLock _(mLock); mUsingProcesses.insert(&proc); - debug("SSauth", "Authorization %p added process %p(%d)", this, &proc, proc.pid()); + secdebug("SSauth", "Authorization %p added process %p(%d)", this, &proc, proc.pid()); } @@ -182,8 +180,8 @@ bool AuthorizationToken::endProcess(Process &proc) StLock _(mLock); assert(mUsingProcesses.find(&proc) != mUsingProcesses.end()); mUsingProcesses.erase(&proc); - IFDEBUG(debug("SSauth", "Authorization %p removed process %p(%d)%s", - this, &proc, proc.pid(), mUsingProcesses.empty() ? " FINAL" : "")); + secdebug("SSauth", "Authorization %p removed process %p(%d)%s", + this, &proc, proc.pid(), mUsingProcesses.empty() ? " FINAL" : ""); return mUsingProcesses.empty(); } @@ -202,55 +200,60 @@ bool AuthorizationToken::mayInternalize(Process &, bool countIt) if (mTransferCount > 0) { if (countIt) { mTransferCount--; - debug("SSauth", "Authorization %p decrement intcount to %d", this, mTransferCount); + secdebug("SSauth", "Authorization %p decrement intcount to %d", this, mTransferCount); } return true; } return false; } -AuthorizationItemSet & -AuthorizationToken::infoSet() +AuthItemSet +AuthorizationToken::infoSet(AuthorizationString tag) { StLock _(mLock); // consider a separate lock - MutableRightSet tempInfoSet(mInfoSet); // turn no info into empty set + + AuthItemSet tempSet; + + if (tag) + { + AuthItemSet::iterator found = find_if(mInfoSet.begin(), mInfoSet.end(), + Authorization::FindAuthItemByRightName(tag)); + if (found != mInfoSet.end()) + tempSet.insert(AuthItemRef(*found)); + + } + else + tempSet = mInfoSet; - AuthorizationItemSet *returnSet = Copier(tempInfoSet, CssmAllocator::standard()).keep(); - debug("SSauth", "Authorization %p returning context %p", this, returnSet); - return *returnSet; + secdebug("SSauth", "Authorization %p returning copy of context %s%s.", this, tag ? "for tag " : "", tag ? "" : tag); + + return tempSet; } void -AuthorizationToken::setInfoSet(AuthorizationItemSet &newInfoSet) +AuthorizationToken::setInfoSet(AuthItemSet &newInfoSet) { - StLock _(mLock); // consider a separate lock - if (mInfoSet) - CssmAllocator::standard().free(mInfoSet); // @@@ move to sensitive allocator - debug("SSauth", "Authorization %p context %p -> %p", this, mInfoSet, &newInfoSet); - mInfoSet = &newInfoSet; + StLock _(mLock); // consider a separate lock + secdebug("SSauth", "Authorization %p setting new context", this); + mInfoSet = newInfoSet; } // This is destructive (non-merging) void AuthorizationToken::setCredentialInfo(const Credential &inCred) { - StLock _(mLock); - - MutableRightSet dstInfoSet; + AuthItemSet dstInfoSet; char uid_string[16]; // fit a uid_t(u_int32_t) - + if (snprintf(uid_string, sizeof(uid_string), "%u", inCred->uid()) >= - sizeof(uid_string)) + int(sizeof(uid_string))) uid_string[0] = '\0'; - Right uidHint("uid", uid_string ? strlen(uid_string) + 1 : 0, uid_string ); - dstInfoSet.push_back(uidHint); - - const char *user = inCred->username().c_str(); - Right userHint("username", user ? strlen(user) + 1 : 0, user ); - dstInfoSet.push_back(userHint); - - AuthorizationItemSet *newInfoSet = Copier(dstInfoSet, CssmAllocator::standard()).keep(); - CssmAllocator::standard().free(mInfoSet); // @@@ move to sensitive allocator - mInfoSet = newInfoSet; + AuthItemRef uidHint("uid", AuthValueOverlay(uid_string ? strlen(uid_string) + 1 : 0, uid_string), 0); + dstInfoSet.insert(uidHint); + + AuthItemRef userHint("username", AuthValueOverlay(inCred->username()), 0); + dstInfoSet.insert(userHint); + + setInfoSet(dstInfoSet); } diff --git a/SecurityServer/authority.h b/SecurityServer/authority.h index 4ce742ba..6882a47d 100644 --- a/SecurityServer/authority.h +++ b/SecurityServer/authority.h @@ -27,8 +27,6 @@ using Authorization::Credential; using Authorization::CredentialSet; -using Authorization::RightSet; -using Authorization::MutableRightSet; using Authorization::AuthItemSet; class Process; @@ -37,7 +35,7 @@ class Session; class AuthorizationToken { public: - AuthorizationToken(Session &ssn, const CredentialSet &base); + AuthorizationToken(Session &ssn, const CredentialSet &base, const security_token_t &securityToken); ~AuthorizationToken(); Session &session; @@ -63,9 +61,10 @@ public: uid_t creatorUid() const { return mCreatorUid; } CodeSigning::OSXCode *creatorCode() const { return mCreatorCode; } - - AuthorizationItemSet &infoSet(); - void setInfoSet(AuthorizationItemSet &newInfoSet); + pid_t creatorPid() const { return mCreatorPid; } + + AuthItemSet infoSet(AuthorizationString tag = NULL); + void setInfoSet(AuthItemSet &newInfoSet); void setCredentialInfo(const Credential &inCred); public: @@ -95,8 +94,9 @@ private: uid_t mCreatorUid; // Uid of proccess that created this authorization RefPointer mCreatorCode; // code id of creator + pid_t mCreatorPid; // Pid of processs that created this authorization - AuthorizationItemSet *mInfoSet; // Side band info gathered from evaluations in this session + AuthItemSet mInfoSet; // Side band info gathered from evaluations in this session private: typedef map AuthMap; diff --git a/SecurityServer/cfnotifier.cpp b/SecurityServer/cfnotifier.cpp index 19348fd1..2baad673 100644 --- a/SecurityServer/cfnotifier.cpp +++ b/SecurityServer/cfnotifier.cpp @@ -20,8 +20,9 @@ // cfnotifier - quick & dirty code to send keychain lock notification // #include "cfnotifier.h" -#include +#include "notifications.h" #include +#include "dictionary.h" #include "session.h" @@ -29,50 +30,18 @@ using namespace Security; using namespace Security::MachPlusPlus; -#define notificationName CFSTR("com.apple.securitycore.kcevent") -#define eventTypeKey CFSTR("type") -#define pidKey CFSTR("pid") -#define keychainKey CFSTR("keychain") -#define itekey CFSTR("item") -#define keyGUID CFSTR("GUID") -#define keySubserviceId CFSTR("SubserviceId") -#define keySubserviceType CFSTR("SubserviceType") -#define keyDbName CFSTR("DbName") -#define keyDbLocation CFSTR("DbLocation") -#define keyActive CFSTR("Active") -#define keyMajorVersion CFSTR("MajorVersion") -#define keyMinorVersion CFSTR("MinorVersion") -#define defaultDLDbListKey CFSTR("DLDBSearchList") -#define defaultDomain CFSTR("com.apple.securitycore") - - -// -// Event codes -// -enum { - lockedEvent = 1, /* a keychain was locked */ - unlockedEvent = 2, /* a keychain was unlocked */ - passphraseChangedEvent = 6 /* a keychain password was (possibly) changed */ -}; - - -// -// Local functions -// -static CFDictionaryRef makeDictionary(const DLDbIdentifier &db); - // // Main methods // void KeychainNotifier::lock(const DLDbIdentifier &db) -{ notify(db, lockedEvent); } +{ notify(db, Listener::lockedEvent); } void KeychainNotifier::unlock(const DLDbIdentifier &db) -{ notify(db, unlockedEvent); } +{ notify(db, Listener::unlockedEvent); } void KeychainNotifier::passphraseChanged(const DLDbIdentifier &db) -{ notify(db, passphraseChangedEvent); } +{ notify(db, Listener::passphraseChangedEvent); } // @@ -80,88 +49,15 @@ void KeychainNotifier::passphraseChanged(const DLDbIdentifier &db) // void KeychainNotifier::notify(const DLDbIdentifier &db, int event) { - CFRef mutableDict(::CFDictionaryCreateMutable( - kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks)); - if (!mutableDict) - throw std::bad_alloc(); - - SInt32 theEvent = event; - CFRef theEventData(::CFNumberCreate( kCFAllocatorDefault, - kCFNumberSInt32Type, &theEvent)); - if (!theEventData) - throw std::bad_alloc(); - ::CFDictionarySetValue( mutableDict, eventTypeKey, theEventData ); - - CFRef dict = makeDictionary(db); - if (!dict) - throw std::bad_alloc(); - ::CFDictionarySetValue(mutableDict, keychainKey, dict); - - for (Session::Iterator it = Session::begin(); it != Session::end(); it++) { - StBootstrap bootSwitch(it->second->bootstrapPort()); - IFDEBUG(debug("cfnotify", "send event %d for database %s to session %p", - event, db.dbName(), it->second)); - ::CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), - notificationName, NULL, mutableDict, false); - } -} - -static CFDictionaryRef makeDictionary(const DLDbIdentifier &db) -{ - CFRef aDict(CFDictionaryCreateMutable(kCFAllocatorDefault,0, - &kCFTypeDictionaryKeyCallBacks,&kCFTypeDictionaryValueCallBacks)); - if (!aDict) - throw std::bad_alloc(); - - // Put SUBSERVICE_UID in dictionary - char buffer[Guid::stringRepLength+1]; - const CssmSubserviceUid& ssuid=db.ssuid(); - const Guid &theGuid = Guid::overlay(ssuid.Guid); - CFRef stringGuid(::CFStringCreateWithCString(kCFAllocatorDefault, - theGuid.toString(buffer),kCFStringEncodingMacRoman)); - if (stringGuid) - ::CFDictionarySetValue(aDict,keyGUID,stringGuid); - - if (ssuid.SubserviceId!=0) - { - CFRef subserviceId(::CFNumberCreate(kCFAllocatorDefault,kCFNumberSInt32Type,&ssuid.SubserviceId)); - if (subserviceId) - ::CFDictionarySetValue(aDict,keySubserviceId,subserviceId); - } - if (ssuid.SubserviceType!=0) - { - CFRef subserviceType(CFNumberCreate(kCFAllocatorDefault,kCFNumberSInt32Type,&ssuid.SubserviceType)); - if (subserviceType) - ::CFDictionarySetValue(aDict,keySubserviceType,subserviceType); - } - if (ssuid.Version.Major!=0 && ssuid.Version.Minor!=0) - { - CFRef majorVersion(::CFNumberCreate(kCFAllocatorDefault,kCFNumberSInt32Type,&ssuid.Version.Major)); - if (majorVersion) - ::CFDictionarySetValue(aDict,keyMajorVersion,majorVersion); - CFRef minorVersion(::CFNumberCreate(kCFAllocatorDefault,kCFNumberSInt32Type,&ssuid.Version.Minor)); - if (minorVersion) - ::CFDictionarySetValue(aDict,keyMinorVersion,minorVersion); - } - - // Put DbName in dictionary - const char *dbName=db.dbName(); - if (dbName) - { - CFRef theDbName(::CFStringCreateWithCString(kCFAllocatorDefault,dbName,kCFStringEncodingMacRoman)); - ::CFDictionarySetValue(aDict,keyDbName,theDbName); - } - // Put DbLocation in dictionary - const CSSM_NET_ADDRESS *dbLocation=db.dbLocation(); - if (dbLocation!=NULL && dbLocation->AddressType!=CSSM_ADDR_NONE) - { - CFRef theData(::CFDataCreate(kCFAllocatorDefault,dbLocation->Address.Data,dbLocation->Address.Length)); - if (theData) - ::CFDictionarySetValue(aDict,keyDbLocation,theData); - } - - ::CFRetain(aDict); - return aDict; + // export the dbID to a dictionary + NameValueDictionary nvd; + NameValueDictionary::MakeNameValueDictionaryFromDLDbIdentifier (db, nvd); + + // flatten the dictionary + CssmData data; + nvd.Export (data); + + Listener::notify (Listener::databaseNotifications, event, data); + free (data.data ()); } diff --git a/SecurityServer/cfnotifier.h b/SecurityServer/cfnotifier.h index 4f35bbcd..d3e49c09 100644 --- a/SecurityServer/cfnotifier.h +++ b/SecurityServer/cfnotifier.h @@ -24,7 +24,6 @@ #include "securityserver.h" - // // A KeychainNotifier object can send keychain-related lock state broadcasts. // diff --git a/SecurityServer/codesigdb.cpp b/SecurityServer/codesigdb.cpp new file mode 100644 index 00000000..4eed9ef4 --- /dev/null +++ b/SecurityServer/codesigdb.cpp @@ -0,0 +1,381 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// codesigdb - code-hash equivalence database +// +#include "codesigdb.h" +#include "process.h" +#include "server.h" +#include "agentquery.h" +#include + + +// +// A self-constructing database key class. +// Key format is +// where +// single ASCII character type code ('H' for hash links) +// decimal userid of owning user, or 'S' for system entries. Followed by null byte. +// variable length key value (binary). +// +class DbKey : public CssmAutoData { +public: + DbKey(char type, const CssmData &key, bool perUser = false, uid_t user = 0); +}; + +DbKey::DbKey(char type, const CssmData &key, bool perUser, uid_t user) + : CssmAutoData(CssmAllocator::standard()) +{ + using namespace LowLevelMemoryUtilities; + char header[20]; + size_t headerLength; + if (perUser) + headerLength = 1 + sprintf(header, "%c%d", type, user); + else + headerLength = 1 + sprintf(header, "%cS", type); + malloc(headerLength + key.length()); + memcpy(this->data(), header, headerLength); + memcpy(get().at(headerLength), key.data(), key.length()); +} + + +// +// A subclass of Identity made of whole cloth (from a raw CodeSignature ACL information) +// +class AclIdentity : public CodeSignatures::Identity { +public: + AclIdentity(const CodeSigning::Signature *sig, const char *comment) + : mHash(*sig), mPath(comment ? comment : "") { } + AclIdentity(const CssmData &hash, const char *comment) + : mHash(hash), mPath(comment ? comment : "") { } + +protected: + std::string getPath() const { return mPath; } + const CssmData getHash(CodeSigning::OSXSigner &) const { return mHash; } + +private: + const CssmData mHash; + std::string mPath; +}; + + +// +// Construct a CodeSignatures objects +// +CodeSignatures::CodeSignatures(const char *path) +{ + try { + mDb.open(path, O_RDWR | O_CREAT, 0644); + } catch (const CssmCommonError &err) { + try { + mDb.open(path, O_RDONLY, 0644); + Syslog::warning("database %s opened READONLY (R/W failed errno=%d)", path, err.unixError()); + secdebug("codesign", "database %s opened READONLY (R/W failed errno=%d)", path, err.unixError()); + } catch (...) { + Syslog::warning("cannot open %s; using no code equivalents", path); + secdebug("codesign", "unable to open %s; using no code equivalents", path); + } + } + if (mDb) + mDb.flush(); // in case we just created it + IFDUMPING("equiv", debugDump("open")); +} + +CodeSignatures::~CodeSignatures() +{ +} + + +// +// (Re)open the equivalence database. +// This is useful to switch to database in another volume. +// +void CodeSignatures::open(const char *path) +{ + mDb.open(path, O_RDWR | O_CREAT, 0644); + mDb.flush(); + IFDUMPING("equiv", debugDump("reopen")); +} + + +// +// Basic Identity objects +// +CodeSignatures::Identity::Identity() : mState(untried) +{ } + +CodeSignatures::Identity::~Identity() +{ } + +string CodeSignatures::Identity::canonicalName(const string &path) +{ + string::size_type slash = path.rfind('/'); + if (slash == string::npos) // bloody unlikely, but whatever... + return path; + return path.substr(slash+1); +} + + +// +// Find and store database objects (primitive layer) +// +bool CodeSignatures::find(Identity &id, uid_t user) +{ + if (id.mState != Identity::untried) + return id.mState == Identity::valid; + try { + DbKey userKey('H', id.getHash(mSigner), true, user); + CssmData linkValue; + if (mDb.get(userKey, linkValue)) { + id.mName = string(linkValue.interpretedAs(), linkValue.length()); + IFDUMPING("equiv", id.debugDump("found/user")); + id.mState = Identity::valid; + return true; + } + DbKey sysKey('H', id.getHash(mSigner)); + if (mDb.get(sysKey, linkValue)) { + id.mName = string(linkValue.interpretedAs(), linkValue.length()); + IFDUMPING("equiv", id.debugDump("found/system")); + id.mState = Identity::valid; + return true; + } + } catch (...) { + secdebug("codesign", "exception validating identity for %s - marking failed", id.path().c_str()); + id.mState = Identity::invalid; + } + return id.mState == Identity::valid; +} + +void CodeSignatures::makeLink(Identity &id, const string &ident, bool forUser, uid_t user) +{ + DbKey key('H', id.getHash(mSigner), forUser, user); + if (!mDb.put(key, StringData(ident))) + UnixError::throwMe(); +} + +void CodeSignatures::makeApplication(const std::string &name, const std::string &path) +{ + //@@@ create app record and fill (later) +} + + +// +// Administrative manipulation calls +// +void CodeSignatures::addLink(const CssmData &oldHash, const CssmData &newHash, + const char *inName, bool forSystem) +{ + string name = Identity::canonicalName(inName); + uid_t user = Server::connection().process.uid(); + if (forSystem && user) // only root user can establish forSystem links + UnixError::throwMe(EACCES); + if (!forSystem) // in fact, for now we don't allow per-user calls at all + UnixError::throwMe(EACCES); + AclIdentity oldCode(oldHash, name.c_str()); + AclIdentity newCode(newHash, name.c_str()); + secdebug("codesign", "addlink for name %s", name.c_str()); + StLock _(mDatabaseLock); + if (oldCode) { + if (oldCode.trustedName() != name) { + secdebug("codesign", "addlink does not match existing name %s", + oldCode.trustedName().c_str()); + MacOSError::throwMe(CSSMERR_CSP_VERIFY_FAILED); + } + } else { + makeLink(oldCode, name, !forSystem, user); + } + if (!newCode) + makeLink(newCode, name, !forSystem, user); + mDb.flush(); +} + +void CodeSignatures::removeLink(const CssmData &hash, const char *name, bool forSystem) +{ + AclIdentity code(hash, name); + uid_t user = Server::connection().process.uid(); + if (forSystem && user) // only root user can remove forSystem links + UnixError::throwMe(EACCES); + DbKey key('H', hash, !forSystem, user); + StLock _(mDatabaseLock); + mDb.erase(key); + mDb.flush(); +} + + +// +// Verify signature matches +// +bool CodeSignatures::verify(Process &process, + const CodeSigning::Signature *trustedSignature, const CssmData *comment) +{ + secdebug("codesign", "start verify"); + + // if we have no client code, we cannot possibly match this + if (!process.clientCode()) { + secdebug("codesign", "no code base: fail"); + return false; + } + + // first of all, if the signature directly matches the client's code, we're obviously fine + // we don't even need the database for that... + Identity &clientIdentity = process; + try { + if (clientIdentity.getHash(mSigner) == CssmData(*trustedSignature)) { + secdebug("codesign", "direct match: pass"); + return true; + } + } catch (...) { + secdebug("codesign", "exception getting client code hash: fail"); + return false; + } + + // ah well. Establish mediator objects for database signature links + AclIdentity aclIdentity(trustedSignature, comment ? comment->interpretedAs() : NULL); + + uid_t user = process.uid(); + { + StLock _(mDatabaseLock); + find(aclIdentity, user); + find(clientIdentity, user); + } + + // if both links exist, we can decide this right now + if (aclIdentity && clientIdentity) { + if (aclIdentity.trustedName() == clientIdentity.trustedName()) { + secdebug("codesign", "app references match: pass"); + return true; + } else { + secdebug("codesign", "client/acl links exist but are unequal: fail"); + return false; + } + } + + // check for name equality + secdebug("codesign", "matching client %s against acl %s", + clientIdentity.name().c_str(), aclIdentity.name().c_str()); + if (aclIdentity.name() != clientIdentity.name()) { + secdebug("codesign", "name/path mismatch: fail"); + return false; + } + + // The names match - we have a possible update. + + // Take the UI lock now to serialize "update rushes". + Server::active().longTermActivity(); + StLock uiLocker(mUILock); + + // re-read the database in case some other thread beat us to the update + { + StLock _(mDatabaseLock); + find(aclIdentity, user); + find(clientIdentity, user); + } + if (aclIdentity && clientIdentity) { + if (aclIdentity.trustedName() == clientIdentity.trustedName()) { + secdebug("codesign", "app references match: pass (on the rematch)"); + return true; + } else { + secdebug("codesign", "client/acl links exist but are unequal: fail (on the rematch)"); + return false; + } + } + + // ask the user + QueryCodeCheck query; + query(aclIdentity.path().c_str()); + if (!query.allowAccess) { + secdebug("codesign", "user declined equivalence: fail"); + return false; + } + + // take the database lock back for real + StLock _(mDatabaseLock); + + // user wants us to go ahead and establish trust (if possible) + if (aclIdentity) { + // acl is linked but new client: link the client to this application + makeLink(clientIdentity, aclIdentity.trustedName(), true, user); + mDb.flush(); + secdebug("codesign", "client %s linked to application %s: pass", + clientIdentity.path().c_str(), aclIdentity.trustedName().c_str()); + return true; + } + + if (clientIdentity) { // code link exists, acl link missing + // client is linked but ACL (hash) never seen: link the ACL to this app + makeLink(aclIdentity, clientIdentity.trustedName(), true, user); + mDb.flush(); + secdebug("codesign", "acl %s linked to client %s: pass", + aclIdentity.path().c_str(), clientIdentity.trustedName().c_str()); + return true; + } + + // the De Novo case: no links, must create everything + string ident = clientIdentity.name(); + makeApplication(ident, clientIdentity.path()); + makeLink(clientIdentity, ident, true, user); + makeLink(aclIdentity, ident, true, user); + mDb.flush(); + secdebug("codesign", "new linkages established: pass"); + return true; +} + + +// +// Debug dumping support +// +#if defined(DEBUGDUMP) + +void CodeSignatures::debugDump(const char *how) const +{ + using namespace Debug; + using namespace LowLevelMemoryUtilities; + if (!how) + how = "dump"; + CssmData key, value; + if (!mDb.first(key, value)) { + dump("CODE EQUIVALENTS DATABASE IS EMPTY (%s)\n", how); + } else { + dump("CODE EQUIVALENTS DATABASE DUMP (%s)\n", how); + do { + const char *header = key.interpretedAs(); + size_t headerLength = strlen(header) + 1; + dump("%s:", header); + dumpData(key.at(headerLength), key.length() - headerLength); + dump(" => "); + dumpData(value); + dump("\n"); + } while (mDb.next(key, value)); + dump("END DUMP\n"); + } +} + +void CodeSignatures::Identity::debugDump(const char *how) const +{ + using namespace Debug; + if (!how) + how = "dump"; + dump("IDENTITY (%s) path=%s", how, getPath().c_str()); + dump(" name=%s hash=", mName.empty() ? "(unset)" : mName.c_str()); + CodeSigning::OSXSigner signer; + dumpData(getHash(signer)); + dump("\n"); +} + +#endif //DEBUGDUMP \ No newline at end of file diff --git a/SecurityServer/codesigdb.h b/SecurityServer/codesigdb.h new file mode 100644 index 00000000..328381b8 --- /dev/null +++ b/SecurityServer/codesigdb.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// codesigdb - code-hash equivalence database +// +#ifndef _H_CODESIGDB +#define _H_CODESIGDB + +#include +#include + + +class Process; +class CodeSignatures; + + +// +// A CodeSignaturse object represents a database of code-signature equivalencies +// as (previously) expressed by a user and/or the system. +// You'll usually only need one of these. +// +class CodeSignatures { +public: + // + // Identity is an abstract class modeling a code-identity in the database. + // It can represent either an existing or latent code-hash link. + // Subclass must provide path and hash source functions. + // + class Identity { + friend class CodeSignatures; + public: + Identity(); + virtual ~Identity(); + + operator bool () const { return mState == valid; } + std::string path() { return getPath(); } + std::string name() { return canonicalName(path()); } + std::string trustedName() const { return mName; } + + static std::string canonicalName(const std::string &path); + + IFDUMP(void debugDump(const char *how = NULL) const); + + virtual std::string getPath() const = 0; + virtual const CssmData getHash(CodeSigning::OSXSigner &signer) const = 0; + + private: + enum { untried, valid, invalid } mState; + std::string mName; // link db value (canonical name linked to) + }; + +public: + CodeSignatures(const char *path); + ~CodeSignatures(); + + void open(const char *path); + +public: + bool find(Identity &id, uid_t user); + + void makeLink(Identity &id, const std::string &ident, bool forUser = false, uid_t user = 0); + void makeApplication(const std::string &name, const std::string &path); + + void addLink(const CssmData &oldHash, const CssmData &newHash, + const char *name, bool forSystem); + void removeLink(const CssmData &hash, const char *name, bool forSystem); + + IFDUMP(void debugDump(const char *how = NULL) const); + +public: + bool verify(Process &process, + const CodeSigning::Signature *trustedSignature, const CssmData *comment); + +private: + UnixPlusPlus::UnixDb mDb; + CodeSigning::OSXSigner mSigner; + + // lock hierarchy: mUILock first, then mDatabaseLock, no back-off + Mutex mDatabaseLock; // controls mDb access + Mutex mUILock; // serializes user interaction +}; + + + +#endif //_H_CODESIGDB diff --git a/SecurityServer/connection.cpp b/SecurityServer/connection.cpp index f054bd4a..7d8a9d65 100644 --- a/SecurityServer/connection.cpp +++ b/SecurityServer/connection.cpp @@ -46,7 +46,7 @@ Connection::Connection(Process &proc, Port rPort) // bump the send-rights count on the reply port so we keep the right after replying mClientPort.modRefs(MACH_PORT_RIGHT_SEND, +1); - debug("SS", "New connection %p for process %d clientport=%d", + secdebug("SS", "New connection %p for process %d clientport=%d", this, process.pid(), int(rPort)); } @@ -57,7 +57,7 @@ Connection::Connection(Process &proc, Port rPort) // Connection::~Connection() { - debug("SS", "Connection %p destroyed", this); + secdebug("SS", "Connection %p destroyed", this); assert(!agentWait); } @@ -72,7 +72,7 @@ void Connection::terminate() assert(state == idle); mClientPort.modRefs(MACH_PORT_RIGHT_SEND, -1); // discard surplus send right assert(mClientPort.getRefs(MACH_PORT_RIGHT_SEND) == 1); // one left for final reply - debug("SS", "Connection %p terminated", this); + secdebug("SS", "Connection %p terminated", this); } @@ -88,16 +88,17 @@ bool Connection::abort(bool keepReplyPort) mClientPort.destroy(); // dead as a doornail already switch (state) { case idle: - debug("SS", "Connection %p aborted", this); + secdebug("SS", "Connection %p aborted", this); return true; // just shoot me case busy: state = dying; // shoot me soon, please if (agentWait) agentWait->cancel(); - debug("SS", "Connection %p abort deferred (busy)", this); + secdebug("SS", "Connection %p abort deferred (busy)", this); return false; // but not quite yet default: assert(false); // impossible (we hope) + return true; // placebo } } @@ -116,7 +117,7 @@ void Connection::beginWork() process.beginConnection(*this); break; case busy: - debug("SS", "Attempt to re-enter connection %p(port %d)", this, mClientPort.port()); + secdebug("SS", "Attempt to re-enter connection %p(port %d)", this, mClientPort.port()); CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); //@@@ some state-error code instead? default: assert(false); @@ -145,9 +146,9 @@ bool Connection::endWork() if (aclUpdateTrigger) { if (--aclUpdateTriggerCount == 0) { aclUpdateTrigger = NULL; - debug("kcacl", "acl update trigger expires"); + secdebug("kcacl", "acl update trigger expires"); } else - debug("kcacl", "acl update trigger armed for %d calls", + secdebug("kcacl", "acl update trigger armed for %d calls", aclUpdateTriggerCount); } // end involvement @@ -155,12 +156,13 @@ bool Connection::endWork() process.endConnection(*this); return false; case dying: - debug("SS", "Connection %p abort resuming", this); + secdebug("SS", "Connection %p abort resuming", this); if (process.endConnection(*this)) delete &process; return true; default: assert(false); + return true; // placebo } } @@ -190,7 +192,7 @@ CSSM_KEY_SIZE Connection::queryKeySize(Key &key) void Connection::generateSignature(const Context &context, Key &key, CSSM_ALGORITHMS signOnlyAlgorithm, const CssmData &data, CssmData &signature) { - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)key); + context.replace(CSSM_ATTRIBUTE_KEY, key.cssmKey()); key.validate(CSSM_ACL_AUTHORIZATION_SIGN, context); CssmClient::Sign signer(Server::csp(), context.algorithm(), signOnlyAlgorithm); signer.override(context); @@ -200,7 +202,7 @@ void Connection::generateSignature(const Context &context, Key &key, void Connection::verifySignature(const Context &context, Key &key, CSSM_ALGORITHMS verifyOnlyAlgorithm, const CssmData &data, const CssmData &signature) { - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)key); + context.replace(CSSM_ATTRIBUTE_KEY, key.cssmKey()); CssmClient::Verify verifier(Server::csp(), context.algorithm(), verifyOnlyAlgorithm); verifier.override(context); verifier.verify(data, signature); @@ -209,7 +211,7 @@ void Connection::verifySignature(const Context &context, Key &key, void Connection::generateMac(const Context &context, Key &key, const CssmData &data, CssmData &mac) { - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)key); + context.replace(CSSM_ATTRIBUTE_KEY, key.cssmKey()); key.validate(CSSM_ACL_AUTHORIZATION_MAC, context); CssmClient::GenerateMac signer(Server::csp(), context.algorithm()); signer.override(context); @@ -219,7 +221,7 @@ void Connection::generateMac(const Context &context, Key &key, void Connection::verifyMac(const Context &context, Key &key, const CssmData &data, const CssmData &mac) { - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)key); + context.replace(CSSM_ATTRIBUTE_KEY, key.cssmKey()); key.validate(CSSM_ACL_AUTHORIZATION_MAC, context); CssmClient::VerifyMac verifier(Server::csp(), context.algorithm()); verifier.override(context); @@ -233,7 +235,7 @@ void Connection::verifyMac(const Context &context, Key &key, void Connection::encrypt(const Context &context, Key &key, const CssmData &clear, CssmData &cipher) { - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)key); + context.replace(CSSM_ATTRIBUTE_KEY, key.cssmKey()); key.validate(CSSM_ACL_AUTHORIZATION_ENCRYPT, context); CssmClient::Encrypt cryptor(Server::csp(), context.algorithm()); cryptor.override(context); @@ -248,7 +250,7 @@ void Connection::encrypt(const Context &context, Key &key, void Connection::decrypt(const Context &context, Key &key, const CssmData &cipher, CssmData &clear) { - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)key); + context.replace(CSSM_ATTRIBUTE_KEY, key.cssmKey()); key.validate(CSSM_ACL_AUTHORIZATION_DECRYPT, context); CssmClient::Decrypt cryptor(Server::csp(), context.algorithm()); cryptor.override(context); @@ -313,7 +315,7 @@ Key &Connection::deriveKey(Database *db, const Context &context, Key *baseKey, // prepare a key-derivation context if (baseKey) { baseKey->validate(CSSM_ACL_AUTHORIZATION_DERIVE, cred); - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)*baseKey); + context.replace(CSSM_ATTRIBUTE_KEY, baseKey->cssmKey()); } CssmClient::DeriveKey derive(Server::csp(), context.algorithm(), CSSM_ALGID_NONE); derive.override(context); @@ -333,6 +335,7 @@ Key &Connection::deriveKey(Database *db, const Context &context, Key *baseKey, // Note that the key argument (the key in the context) is optional because of the special // case of "cleartext" (null algorithm) wrapping for import/export. // + void Connection::wrapKey(const Context &context, Key *key, Key &keyToBeWrapped, const AccessCredentials *cred, const CssmData &descriptiveData, CssmKey &wrappedKey) @@ -340,8 +343,11 @@ void Connection::wrapKey(const Context &context, Key *key, keyToBeWrapped.validate(context.algorithm() == CSSM_ALGID_NONE ? CSSM_ACL_AUTHORIZATION_EXPORT_CLEAR : CSSM_ACL_AUTHORIZATION_EXPORT_WRAPPED, cred); + if(!(keyToBeWrapped.attributes() & CSSM_KEYATTR_EXTRACTABLE)) { + CssmError::throwMe(CSSMERR_CSP_INVALID_KEYATTR_MASK); + } if (key) - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)*key); + context.replace(CSSM_ATTRIBUTE_KEY, key->cssmKey()); CssmClient::WrapKey wrap(Server::csp(), context.algorithm()); wrap.override(context); wrap.cred(const_cast(cred)); //@@@ const madness - fix in client/pod @@ -354,7 +360,7 @@ Key &Connection::unwrapKey(Database *db, const Context &context, Key *key, Key *publicKey, CssmData *descriptiveData) { if (key) - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)*key); + context.replace(CSSM_ATTRIBUTE_KEY, key->cssmKey()); CssmClient::UnwrapKey unwrap(Server::csp(), context.algorithm()); unwrap.override(context); CssmKey unwrappedKey; @@ -366,7 +372,7 @@ Key &Connection::unwrapKey(Database *db, const Context &context, Key *key, // @@@ Invoking conversion operator to CssmKey & on *publicKey and take the address of the result. unwrap(wrappedKey, Key::KeySpec(usage, attrs), unwrappedKey, - descriptiveData, publicKey ? &static_cast(*publicKey) : NULL); + descriptiveData, publicKey ? &static_cast(*publicKey) : NULL); return *new Key(db, unwrappedKey, attrs & Key::managedAttributes, owner); } @@ -379,7 +385,7 @@ uint32 Connection::getOutputSize(const Context &context, Key &key, uint32 inputS { // We're fudging here somewhat, since the context can be any type. // ctx.override will fix the type, and no-one's the wiser. - context.replace(CSSM_ATTRIBUTE_KEY, (CSSM_KEY &)key); + context.replace(CSSM_ATTRIBUTE_KEY, key.cssmKey()); CssmClient::Digest ctx(Server::csp(), context.algorithm()); ctx.override(context); return ctx.getOutputSize(inputSize, encrypt); diff --git a/SecurityServer/dbcrypto.cpp b/SecurityServer/dbcrypto.cpp index 7ede24aa..a50d12b5 100644 --- a/SecurityServer/dbcrypto.cpp +++ b/SecurityServer/dbcrypto.cpp @@ -32,7 +32,7 @@ using namespace CssmClient; -DatabaseCryptoCore::DatabaseCryptoCore() : mIsValid(false) +DatabaseCryptoCore::DatabaseCryptoCore() : mHaveMaster(false), mIsValid(false) { } @@ -43,6 +43,20 @@ DatabaseCryptoCore::~DatabaseCryptoCore() } +// +// Forget the secrets +// +void DatabaseCryptoCore::invalidate() +{ + mMasterKey.release(); + mHaveMaster = false; + + mEncryptionKey.release(); + mSigningKey.release(); + mIsValid = false; +} + + // // Generate new secrets for this crypto core. // @@ -50,13 +64,13 @@ void DatabaseCryptoCore::generateNewSecrets() { // create a random DES3 key GenerateKey desGenerator(Server::csp(), CSSM_ALGID_3DES_3KEY_EDE, 24 * 8); - encryptionKey = desGenerator(KeySpec(CSSM_KEYUSE_WRAP | CSSM_KEYUSE_UNWRAP, + mEncryptionKey = desGenerator(KeySpec(CSSM_KEYUSE_WRAP | CSSM_KEYUSE_UNWRAP, CSSM_KEYATTR_RETURN_DATA | CSSM_KEYATTR_EXTRACTABLE)); - // create a random 20 byte HMAC1/SHA1 signing "key" + // create a random 20 byte HMAC/SHA1 signing "key" GenerateKey signGenerator(Server::csp(), CSSM_ALGID_SHA1HMAC, sizeof(DbBlob::PrivateBlob::SigningKey) * 8); - signingKey = signGenerator(KeySpec(CSSM_KEYUSE_SIGN | CSSM_KEYUSE_VERIFY, + mSigningKey = signGenerator(KeySpec(CSSM_KEYUSE_SIGN | CSSM_KEYUSE_VERIFY, CSSM_KEYATTR_RETURN_DATA | CSSM_KEYATTR_EXTRACTABLE)); // secrets established @@ -64,28 +78,105 @@ void DatabaseCryptoCore::generateNewSecrets() } +CssmClient::Key DatabaseCryptoCore::masterKey() +{ + assert(mHaveMaster); + return mMasterKey; +} + + +// +// Establish the master secret as derived from a passphrase passed in. +// If a DbBlob is passed, take the salt from it and remember it. +// If a NULL DbBlob is passed, generate a new (random) salt. +// Note that the passphrase is NOT remembered; only the master key. +// +void DatabaseCryptoCore::setup(const DbBlob *blob, const CssmData &passphrase) +{ + if (blob) + memcpy(mSalt, blob->salt, sizeof(mSalt)); + else + Server::active().random(mSalt); + mMasterKey = deriveDbMasterKey(passphrase); + mHaveMaster = true; +} + + +// +// Establish the master secret directly from a master key passed in. +// We will copy the KeyData (caller still owns its copy). +// Blob/salt handling as above. +// +void DatabaseCryptoCore::setup(const DbBlob *blob, CssmClient::Key master) +{ + // pre-screen the key + CssmKey::Header header = master.header(); + if (header.keyClass() != CSSM_KEYCLASS_SESSION_KEY) + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); + if (header.algorithm() != CSSM_ALGID_3DES_3KEY_EDE) + CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); + + // accept it + if (blob) + memcpy(mSalt, blob->salt, sizeof(mSalt)); + else + Server::active().random(mSalt); + mMasterKey = master; + mHaveMaster = true; +} + + +// +// Given a putative passphrase, determine whether that passphrase +// properly generates the database's master secret. +// Return a boolean accordingly. Do not change our state. +// The database must have a master secret (to compare with). +// Note that any errors thrown by the cryptography here will actually +// throw out of validatePassphrase, since they "should not happen" and +// thus indicate a problem *beyond* (just) a bad passphrase. +// +bool DatabaseCryptoCore::validatePassphrase(const CssmData &passphrase) +{ + assert(hasMaster()); + CssmClient::Key master = deriveDbMasterKey(passphrase); + + // to compare master with mMaster, see if they encrypt alike + StringData probe + ("Now is the time for all good processes to come to the aid of their kernel."); + CssmData noRemainder((void *)1, 0); // no cipher overflow + Encrypt cryptor(Server::csp(), CSSM_ALGID_3DES_3KEY_EDE); + cryptor.mode(CSSM_ALGMODE_CBCPadIV8); + cryptor.padding(CSSM_PADDING_PKCS1); + uint8 iv[8]; // leave uninitialized; pseudo-random is cool + cryptor.initVector(CssmData::wrap(iv)); + + cryptor.key(master); + CssmAutoData cipher1(Server::csp().allocator()); + cryptor.encrypt(probe, cipher1.get(), noRemainder); + + cryptor.key(mMasterKey); + CssmAutoData cipher2(Server::csp().allocator()); + cryptor.encrypt(probe, cipher2.get(), noRemainder); + + return cipher1 == cipher2; +} + + // // Encode a database blob from the core. // DbBlob *DatabaseCryptoCore::encodeCore(const DbBlob &blobTemplate, - const CssmData &passphrase, const CssmData &publicAcl, const CssmData &privateAcl) const { assert(isValid()); // must have secrets to work from - // make a new salt and IV - uint8 salt[20]; - Server::active().random(salt); + // make a new IV uint8 iv[8]; Server::active().random(iv); - // derive blob encryption key - CssmClient::Key blobCryptKey = deriveDbCryptoKey(passphrase, - CssmData(salt, sizeof(salt))); - // build the encrypted section blob - CssmData &encryptionBits = *encryptionKey; - CssmData &signingBits = *signingKey; + CssmData &encryptionBits = *mEncryptionKey; + CssmData &signingBits = *mSigningKey; CssmData incrypt[3]; incrypt[0] = encryptionBits; incrypt[1] = signingBits; @@ -94,7 +185,7 @@ DbBlob *DatabaseCryptoCore::encodeCore(const DbBlob &blobTemplate, Encrypt cryptor(Server::csp(), CSSM_ALGID_3DES_3KEY_EDE); cryptor.mode(CSSM_ALGMODE_CBCPadIV8); cryptor.padding(CSSM_PADDING_PKCS1); - cryptor.key(blobCryptKey); + cryptor.key(mMasterKey); CssmData ivd(iv, sizeof(iv)); cryptor.initVector(ivd); cryptor.encrypt(incrypt, 3, &cryptoBlob, 1, remData); @@ -108,7 +199,7 @@ DbBlob *DatabaseCryptoCore::encodeCore(const DbBlob &blobTemplate, blob->randomSignature = blobTemplate.randomSignature; blob->sequence = blobTemplate.sequence; blob->params = blobTemplate.params; - memcpy(blob->salt, salt, sizeof(salt)); + memcpy(blob->salt, mSalt, sizeof(blob->salt)); memcpy(blob->iv, iv, sizeof(iv)); memcpy(blob->publicAclBlob(), publicAcl, publicAcl.length()); blob->startCryptoBlob = sizeof(DbBlob) + publicAcl.length(); @@ -122,7 +213,7 @@ DbBlob *DatabaseCryptoCore::encodeCore(const DbBlob &blobTemplate, }; CssmData signature(blob->blobSignature, sizeof(blob->blobSignature)); GenerateMac signer(Server::csp(), CSSM_ALGID_SHA1HMAC_LEGACY); //@@@!!! CRUD - signer.key(signingKey); + signer.key(mSigningKey); signer.sign(signChunk, 2, signature); assert(signature.length() == sizeof(blob->blobSignature)); @@ -134,20 +225,18 @@ DbBlob *DatabaseCryptoCore::encodeCore(const DbBlob &blobTemplate, // // Decode a database blob into the core. -// Returns false if the decoding fails. +// Throws exceptions if decoding fails. +// Memory returned in privateAclBlob is allocated and becomes owned by caller. // -void DatabaseCryptoCore::decodeCore(DbBlob *blob, const CssmData &passphrase, - void **privateAclBlob) +void DatabaseCryptoCore::decodeCore(DbBlob *blob, void **privateAclBlob) { - // derive blob encryption key - CssmClient::Key blobCryptKey = deriveDbCryptoKey(passphrase, - CssmData(blob->salt, sizeof(blob->salt))); + assert(mHaveMaster); // must have master key installed // try to decrypt the cryptoblob section Decrypt decryptor(Server::csp(), CSSM_ALGID_3DES_3KEY_EDE); decryptor.mode(CSSM_ALGMODE_CBCPadIV8); decryptor.padding(CSSM_PADDING_PKCS1); - decryptor.key(blobCryptKey); + decryptor.key(mMasterKey); CssmData ivd(blob->iv, sizeof(blob->iv)); decryptor.initVector(ivd); CssmData cryptoBlob(blob->cryptoBlob(), blob->cryptoBlobLength()); CssmData decryptedBlob, remData; @@ -155,10 +244,10 @@ void DatabaseCryptoCore::decodeCore(DbBlob *blob, const CssmData &passphrase, DbBlob::PrivateBlob *privateBlob = decryptedBlob.interpretedAs(); // tentatively establish keys - CssmClient::Key encryptionKey = makeRawKey(privateBlob->encryptionKey, + mEncryptionKey = makeRawKey(privateBlob->encryptionKey, sizeof(privateBlob->encryptionKey), CSSM_ALGID_3DES_3KEY_EDE, CSSM_KEYUSE_WRAP | CSSM_KEYUSE_UNWRAP); - CssmClient::Key signingKey = makeRawKey(privateBlob->signingKey, + mSigningKey = makeRawKey(privateBlob->signingKey, sizeof(privateBlob->signingKey), CSSM_ALGID_SHA1HMAC, CSSM_KEYUSE_SIGN | CSSM_KEYUSE_VERIFY); @@ -169,16 +258,16 @@ void DatabaseCryptoCore::decodeCore(DbBlob *blob, const CssmData &passphrase, }; CSSM_ALGORITHMS verifyAlgorithm = CSSM_ALGID_SHA1HMAC; #if defined(COMPAT_OSX_10_0) - if (blob->version == blob->version_MacOS_10_0) + if (blob->version() == blob->version_MacOS_10_0) verifyAlgorithm = CSSM_ALGID_SHA1HMAC_LEGACY; // BSafe bug compatibility #endif VerifyMac verifier(Server::csp(), verifyAlgorithm); - verifier.key(signingKey); + verifier.key(mSigningKey); verifier.verify(signChunk, 2, CssmData(blob->blobSignature, sizeof(blob->blobSignature))); // all checks out; start extracting fields - this->encryptionKey = encryptionKey; - this->signingKey = signingKey; + this->mEncryptionKey = mEncryptionKey; + this->mSigningKey = mSigningKey; if (privateAclBlob) { // extract private ACL blob as a separately allocated area uint32 blobLength = decryptedBlob.length() - sizeof(DbBlob::PrivateBlob); @@ -208,10 +297,11 @@ KeyBlob *DatabaseCryptoCore::encodeKeyCore(const CssmKey &inKey, CssmKey key = inKey; uint32 heldAttributes = key.attributes() & managedAttributes; key.clearAttribute(managedAttributes); + key.setAttribute(forcedAttributes); // use a CMS wrap to encrypt the key WrapKey wrap(Server::csp(), CSSM_ALGID_3DES_3KEY_EDE); - wrap.key(encryptionKey); + wrap.key(mEncryptionKey); wrap.mode(CSSM_ALGMODE_CBCPadIV8); wrap.padding(CSSM_PADDING_PKCS1); CssmData ivd(iv, sizeof(iv)); wrap.initVector(ivd); @@ -221,6 +311,7 @@ KeyBlob *DatabaseCryptoCore::encodeKeyCore(const CssmKey &inKey, wrap(key, wrappedKey, &privateAcl); // stick the held attribute bits back in + key.clearAttribute(forcedAttributes); key.setAttribute(heldAttributes); // allocate the final KeyBlob, uh, blob @@ -232,6 +323,7 @@ KeyBlob *DatabaseCryptoCore::encodeKeyCore(const CssmKey &inKey, blob->initialize(); memcpy(blob->iv, iv, sizeof(iv)); blob->header = key.header(); + h2ni(blob->header); // endian-correct the header blob->wrappedHeader.blobType = wrappedKey.blobType(); blob->wrappedHeader.blobFormat = wrappedKey.blobFormat(); blob->wrappedHeader.wrapAlgorithm = wrappedKey.wrapAlgorithm(); @@ -248,7 +340,7 @@ KeyBlob *DatabaseCryptoCore::encodeKeyCore(const CssmKey &inKey, }; CssmData signature(blob->blobSignature, sizeof(blob->blobSignature)); GenerateMac signer(Server::csp(), CSSM_ALGID_SHA1HMAC_LEGACY); //@@@!!! CRUD - signer.key(signingKey); + signer.key(mSigningKey); signer.sign(signChunk, 2, signature); assert(signature.length() == sizeof(blob->blobSignature)); @@ -269,12 +361,13 @@ void DatabaseCryptoCore::decodeKeyCore(KeyBlob *blob, // Assemble the encrypted blob as a CSSM "wrapped key" CssmKey wrappedKey; wrappedKey.KeyHeader = blob->header; + h2ni(wrappedKey.KeyHeader); wrappedKey.blobType(blob->wrappedHeader.blobType); wrappedKey.blobFormat(blob->wrappedHeader.blobFormat); wrappedKey.wrapAlgorithm(blob->wrappedHeader.wrapAlgorithm); wrappedKey.wrapMode(blob->wrappedHeader.wrapMode); wrappedKey.KeyData = CssmData(blob->cryptoBlob(), blob->cryptoBlobLength()); - + // verify signature (check against corruption) CssmData signChunk[] = { CssmData::wrap(blob, offsetof(KeyBlob, blobSignature)), @@ -282,20 +375,20 @@ void DatabaseCryptoCore::decodeKeyCore(KeyBlob *blob, }; CSSM_ALGORITHMS verifyAlgorithm = CSSM_ALGID_SHA1HMAC; #if defined(COMPAT_OSX_10_0) - if (blob->version == blob->version_MacOS_10_0) + if (blob->version() == blob->version_MacOS_10_0) verifyAlgorithm = CSSM_ALGID_SHA1HMAC_LEGACY; // BSafe bug compatibility #endif VerifyMac verifier(Server::csp(), verifyAlgorithm); - verifier.key(signingKey); + verifier.key(mSigningKey); CssmData signature(blob->blobSignature, sizeof(blob->blobSignature)); verifier.verify(signChunk, 2, signature); // extract and hold some header bits the CSP does not want to see - uint32 heldAttributes = blob->header.attributes() & managedAttributes; + uint32 heldAttributes = n2h(blob->header.attributes()) & managedAttributes; // decrypt the key using an unwrapping operation UnwrapKey unwrap(Server::csp(), CSSM_ALGID_3DES_3KEY_EDE); - unwrap.key(encryptionKey); + unwrap.key(mEncryptionKey); unwrap.mode(CSSM_ALGMODE_CBCPadIV8); unwrap.padding(CSSM_PADDING_PKCS1); CssmData ivd(blob->iv, sizeof(blob->iv)); unwrap.initVector(ivd); @@ -304,16 +397,18 @@ void DatabaseCryptoCore::decodeKeyCore(KeyBlob *blob, CssmData privAclData; wrappedKey.clearAttribute(managedAttributes); //@@@ shouldn't be needed(?) unwrap(wrappedKey, - KeySpec(blob->header.usage(), blob->header.attributes() & ~managedAttributes), + KeySpec(n2h(blob->header.usage()), + (n2h(blob->header.attributes()) & ~managedAttributes) | forcedAttributes), key, &privAclData); // compare retrieved key headers with blob headers (sanity check) // @@@ this should probably be checked over carefully CssmKey::Header &real = key.header(); CssmKey::Header &incoming = blob->header; + n2hi(incoming); + if (real.HeaderVersion != incoming.HeaderVersion || - real.cspGuid() != incoming.cspGuid() || - real.blobFormat() != incoming.blobFormat()) + real.cspGuid() != incoming.cspGuid()) CssmError::throwMe(CSSMERR_CSP_INVALID_KEY); if (real.algorithm() != incoming.algorithm()) CssmError::throwMe(CSSMERR_CSP_INVALID_ALGORITHM); @@ -331,14 +426,13 @@ void DatabaseCryptoCore::decodeKeyCore(KeyBlob *blob, // // Derive the blob-specific database blob encryption key from the passphrase and the salt. // -CssmClient::Key DatabaseCryptoCore::deriveDbCryptoKey(const CssmData &passphrase, - const CssmData &salt) const +CssmClient::Key DatabaseCryptoCore::deriveDbMasterKey(const CssmData &passphrase) const { // derive an encryption key and IV from passphrase and salt CssmClient::DeriveKey makeKey(Server::csp(), CSSM_ALGID_PKCS5_PBKDF2, CSSM_ALGID_3DES_3KEY_EDE, 24 * 8); makeKey.iterationCount(1000); - makeKey.salt(salt); + makeKey.salt(CssmData::wrap(mSalt)); CSSM_PKCS5_PBKDF2_PARAMS params; params.Passphrase = passphrase; params.PseudoRandomFunction = CSSM_PKCS5_PBKDF2_PRF_HMAC_SHA1; diff --git a/SecurityServer/dbcrypto.h b/SecurityServer/dbcrypto.h index 64867115..3b71d198 100644 --- a/SecurityServer/dbcrypto.h +++ b/SecurityServer/dbcrypto.h @@ -38,28 +38,41 @@ public: virtual ~DatabaseCryptoCore(); bool isValid() const { return mIsValid; } - + bool hasMaster() const { return mHaveMaster; } + void invalidate(); + void generateNewSecrets(); + CssmClient::Key masterKey(); - DbBlob *encodeCore(const DbBlob &blobTemplate, const CssmData &passphrase, + void setup(const DbBlob *blob, const CssmData &passphrase); + void setup(const DbBlob *blob, CssmClient::Key master); + + void decodeCore(DbBlob *blob, void **privateAclBlob = NULL); + DbBlob *encodeCore(const DbBlob &blobTemplate, const CssmData &publicAcl, const CssmData &privateAcl) const; - void decodeCore(DbBlob *blob, const CssmData &passphrase, - void **privateAclBlob = NULL); KeyBlob *encodeKeyCore(const CssmKey &key, const CssmData &publicAcl, const CssmData &privateAcl) const; void decodeKeyCore(KeyBlob *blob, CssmKey &key, void * &pubAcl, void * &privAcl) const; - + static const uint32 managedAttributes = KeyBlob::managedAttributes; + static const uint32 forcedAttributes = KeyBlob::forcedAttributes; + +public: + bool validatePassphrase(const CssmData &passphrase); private: - bool mIsValid; // master secrets are valid + bool mHaveMaster; // master key has been entered (setup) + bool mIsValid; // master secrets are valid (decode or generateNew) - CssmClient::Key encryptionKey; // master encryption key - CssmClient::Key signingKey; // master signing key + CssmClient::Key mMasterKey; // database master key + uint8 mSalt[20]; // salt for master key derivation from passphrase (only) + + CssmClient::Key mEncryptionKey; // master encryption key + CssmClient::Key mSigningKey; // master signing key - CssmClient::Key deriveDbCryptoKey(const CssmData &passphrase, const CssmData &salt) const; + CssmClient::Key deriveDbMasterKey(const CssmData &passphrase) const; CssmClient::Key makeRawKey(void *data, size_t length, CSSM_ALGORITHMS algid, CSSM_KEYUSE usage); }; diff --git a/SecurityServer/dictionary.cpp b/SecurityServer/dictionary.cpp new file mode 100644 index 00000000..9f43c743 --- /dev/null +++ b/SecurityServer/dictionary.cpp @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +#include "dictionary.h" +#include + +namespace Security { + +CssmData NameValuePair::CloneData (const CssmData &value) +{ + void* clonedData = (void*) new unsigned char [value.length ()]; + memcpy (clonedData, value.data (), value.length ()); + return CssmData (clonedData, value.length ()); +} + + + +NameValuePair::NameValuePair (uint32 name, const CssmData &value) : mName (name), mValue (CloneData (value)) +{ +} + + + +NameValuePair::NameValuePair (const CssmData &data) +{ + // the first four bytes are the name + unsigned char* finger = (unsigned char*) data.data (); + mName = 0; + + unsigned int i; + for (i = 0; i < sizeof (uint32); ++i) + { + mName = (mName << 8) | *finger++; + } + + // the next four bytes are the length + uint32 length = 0; + for (i = 0; i < sizeof (uint32); ++i) + { + length = (length << 8) | *finger++; + } + + // what's left is the data + mValue = CloneData (CssmData (finger, length)); +} + + + +NameValuePair::~NameValuePair () +{ + delete (unsigned char*) mValue.data (); +} + + + +void NameValuePair::Export (CssmData &data) const +{ + // export the data in the format name length data + uint32 outSize = 2 * sizeof (uint32) + mValue.length (); + unsigned char* d = new unsigned char [outSize]; + unsigned char* finger = d; + + // export the name + uint32 intBuffer = mName; + + int i; + for (i = sizeof (uint32) - 1; i >= 0; --i) + { + finger[i] = intBuffer & 0xFF; + intBuffer >>= 8; + } + + // export the length + finger += sizeof (uint32); + intBuffer = mValue.length (); + for (i = sizeof (uint32) - 1; i >= 0; --i) + { + finger[i] = intBuffer & 0xFF; + intBuffer >>= 8; + } + + // export the data + finger += sizeof (uint32); + memcpy (finger, mValue.data (), mValue.length ()); + + data = CssmData (d, outSize); +} + + + +NameValueDictionary::NameValueDictionary () +{ +} + + + +NameValueDictionary::~NameValueDictionary () +{ + // to prevent leaks, delete all members of the vector + int i = mVector.size (); + while (i > 0) + { + delete mVector[--i]; + + mVector.erase (mVector.begin () + i); + } +} + + + +NameValueDictionary::NameValueDictionary (const CssmData &data) +{ + // reconstruct a name value dictionary from a series of exported NameValuePair blobs + unsigned char* finger = (unsigned char*) data.data (); + unsigned char* target = finger + data.length (); + + do + { + // compute the length of data blob + unsigned int i; + uint32 length = 0; + for (i = sizeof (uint32); i < 2 * sizeof (uint32); ++i) + { + length = (length << 8) | finger[i]; + } + + // add the length of the "header" + length += 2 * sizeof (uint32); + Insert (new NameValuePair (CssmData (finger, length))); + + // skip to the next data + finger += length; + } while (finger < target); +} + + + +void NameValueDictionary::Insert (NameValuePair* pair) +{ + mVector.push_back (pair); +} + + + +void NameValueDictionary::RemoveByName (uint32 name) +{ + int which = FindPositionByName (name); + if (which != -1) + { + NameValuePair* nvp = mVector[which]; + mVector.erase (mVector.begin () + which); + delete nvp; + } +} + + + +int NameValueDictionary::FindPositionByName (uint32 name) const +{ + int target = CountElements (); + int i; + + for (i = 0; i < target; ++i) + { + if (mVector[i]->Name () == name) + { + return i; + } + } + + return -1; +} + + + +const NameValuePair* NameValueDictionary::FindByName (uint32 name) const +{ + int which = FindPositionByName (name); + return which == -1 ? NULL : mVector[which]; +} + + + + +int NameValueDictionary::CountElements () const +{ + return mVector.size (); +} + + + +const NameValuePair* NameValueDictionary::GetElement (int which) +{ + return mVector[which]; +} + + + +void NameValueDictionary::Export (CssmData &outData) +{ + // get each element in the dictionary, and add it to the data blob + int i; + uint32 length = 0; + unsigned char* data = 0; + + for (i = 0; i < CountElements (); ++i) + { + CssmData exportedData; + const NameValuePair *nvp = GetElement (i); + nvp->Export (exportedData); + + uint32 oldLength = length; + length += exportedData.length (); + data = (unsigned char*) realloc (data, length); + + memcpy (data + oldLength, exportedData.data (), exportedData.length ()); + + delete (unsigned char*) exportedData.data (); + } + + outData = CssmData (data, length); +} + + + +void NameValueDictionary::MakeNameValueDictionaryFromDLDbIdentifier (const DLDbIdentifier &identifier, NameValueDictionary &nvd) +{ + // get the subserviceID + const CssmSubserviceUid &ssuid = identifier.ssuid (); + const CSSM_SUBSERVICE_UID* baseID = &ssuid; + nvd.Insert (new NameValuePair (SSUID_KEY, CssmData ((void*) (baseID), sizeof (CSSM_SUBSERVICE_UID)))); + + // get the name + const char* dbName = identifier.dbName (); + nvd.Insert (new NameValuePair (DB_NAME, CssmData ((void*) (dbName), strlen (dbName) + 1))); + + // get the net address + const CSSM_NET_ADDRESS* add = identifier.dbLocation (); + if (add != NULL) + { + nvd.Insert (new NameValuePair (DB_LOCATION, CssmData ((void*) add, sizeof (CSSM_NET_ADDRESS)))); + } +} + + + +DLDbIdentifier NameValueDictionary::MakeDLDbIdentifierFromNameValueDictionary (const NameValueDictionary &nvd) +{ + CSSM_SUBSERVICE_UID* uid = (CSSM_SUBSERVICE_UID*) nvd.FindByName (SSUID_KEY)->Value ().data (); + char* name = (char*) nvd.FindByName (DB_NAME)->Value ().data (); + + const NameValuePair* nvp = nvd.FindByName (DB_LOCATION); + CSSM_NET_ADDRESS* address = nvp ? (CSSM_NET_ADDRESS*) nvp->Value ().data () : NULL; + + return DLDbIdentifier (*uid, name, address); +} + +}; // end Security namespace diff --git a/SecurityServer/dictionary.h b/SecurityServer/dictionary.h new file mode 100644 index 00000000..8efd1c39 --- /dev/null +++ b/SecurityServer/dictionary.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +#ifndef _DICTIONARY_H__ +#define _DICTIONARY_H__ + + +#include +#include "cssmdb.h" + +namespace Security { + + + +#define PID_KEY 'pidk' +#define ITEM_KEY 'item' +#define SSUID_KEY 'ssui' +#define DB_NAME 'dbnm' +#define DB_LOCATION 'dblc' + + + +class NameValuePair +{ +protected: + uint32 mName; + CssmData mValue; + + CssmData CloneData (const CssmData &value); + +public: + NameValuePair (uint32 name, const CssmData &value); + NameValuePair (const CssmData &data); + ~NameValuePair (); + + const uint32 Name () {return mName;} + const CssmData& Value () const {return mValue;} + void Export (CssmData &data) const; +}; + + + +typedef std::vector NameValuePairVector; + + + +class NameValueDictionary +{ +protected: + NameValuePairVector mVector; + + int FindPositionByName (uint32 name) const; + +public: + NameValueDictionary (); + ~NameValueDictionary (); + NameValueDictionary (const CssmData &data); + + void Insert (NameValuePair* pair); + void RemoveByName (uint32 name); + const NameValuePair* FindByName (uint32 name) const; + + int CountElements () const; + const NameValuePair* GetElement (int which); + void Export (CssmData &data); + + // utility functions + static void MakeNameValueDictionaryFromDLDbIdentifier (const DLDbIdentifier &identifier, NameValueDictionary &nvd); + static DLDbIdentifier MakeDLDbIdentifierFromNameValueDictionary (const NameValueDictionary &nvd); +}; + + +}; + +#endif diff --git a/SecurityServer/entropy.cpp b/SecurityServer/entropy.cpp index 797a691f..8801e850 100644 --- a/SecurityServer/entropy.cpp +++ b/SecurityServer/entropy.cpp @@ -43,7 +43,7 @@ #define COLLECT_INTERVAL 15 #else #define COLLECT_INTERVAL collectInterval -#endif ENTROPY_QUICK_UPDATE +#endif //ENTROPY_QUICK_UPDATE using namespace UnixPlusPlus; @@ -104,7 +104,7 @@ void EntropyManager::collectEntropy() char buffer[timingsToCollect]; for (unsigned n = 0; n < size; n++) buffer[n] = timings[n].tv_nsec; // truncating to LSB - debug("entropy", "Entropy size %d: %02x %02x %02x %02x %02x %02x %02x %02x...", + secdebug("entropy", "Entropy size %d: %02x %02x %02x %02x %02x %02x %02x %02x...", (int)size, (unsigned char)buffer[0], (unsigned char)buffer[1], (unsigned char)buffer[2], (unsigned char)buffer[3], (unsigned char)buffer[4], (unsigned char)buffer[5], @@ -119,14 +119,14 @@ void EntropyManager::collectEntropy() void EntropyManager::updateEntropyFile() { if (Time::now() >= mNextUpdate) { - char buffer[entropyFileSize]; try { - debug("entropy", "updating %s", mEntropyFilePath.c_str()); + mNextUpdate = Time::now() + Time::Interval(updateInterval); + secdebug("entropy", "updating %s", mEntropyFilePath.c_str()); + char buffer[entropyFileSize]; random(buffer, entropyFileSize); AutoFileDesc entropyFile(mEntropyFilePath.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0600); if (entropyFile.write(buffer) != entropyFileSize) Syslog::warning("short write on entropy file %s", mEntropyFilePath.c_str()); - mNextUpdate += updateInterval; } catch (...) { Syslog::warning("error writing entropy file %s", mEntropyFilePath.c_str()); } diff --git a/SecurityServer/eventlistener.cpp b/SecurityServer/eventlistener.cpp new file mode 100644 index 00000000..e5b227e6 --- /dev/null +++ b/SecurityServer/eventlistener.cpp @@ -0,0 +1,118 @@ +#include "eventlistener.h" + + +namespace Security { +namespace SecurityServer { + +EventListener::EventListener (CssmAllocator &standard, CssmAllocator &returning) : mClientSession (standard, returning), + mMachPortRef (NULL), + mRunLoopSourceRef (NULL) + +{ + Initialize (); +} + + + +EventListener::~EventListener () +{ + if (mMachPortRef != NULL) + { + mach_port_t mp = CFMachPortGetPort (mMachPortRef); + mClientSession.stopNotification (mp); + CFRelease (mMachPortRef); + } + + if (mRunLoopSourceRef != NULL) + { + CFRelease (mRunLoopSourceRef); + } +} + + + +void EventListener::Callback (CFMachPortRef port, void *msg, CFIndex size, void *info) +{ + reinterpret_cast(info)->HandleCallback (port, msg, size); +} + + + +void EventListener::Initialize () +{ + // create a callback information structure + CFMachPortContext context = {1, this, NULL, NULL, NULL}; + + // create the CFMachPort + mMachPortRef = CFMachPortCreate (NULL, Callback, &context, NULL); + if (mMachPortRef == NULL) + { + return; + } + + // set the buffer limit for the port + mach_port_t mp = CFMachPortGetPort (mMachPortRef); + + mach_port_limits_t limits; + limits.mpl_qlimit = MACH_PORT_QLIMIT_MAX; + kern_return_t result = + mach_port_set_attributes (mach_task_self (), mp, MACH_PORT_LIMITS_INFO, + mach_port_info_t (&limits), MACH_PORT_LIMITS_INFO_COUNT); + + if (result != KERN_SUCCESS) + { + secdebug ("notify", "Got error %d when trying to maximize queue size", result); + } + + // make a run loop source for this ref + mRunLoopSourceRef = CFMachPortCreateRunLoopSource (NULL, mMachPortRef, NULL); + if (mRunLoopSourceRef == NULL) + { + CFRelease (mMachPortRef); + return; + } + + // attach this run loop source to the main run loop + CFRunLoopAddSource (CFRunLoopGetCurrent (), mRunLoopSourceRef, kCFRunLoopDefaultMode); + + // extract the actual port from the run loop, and request callbacks on that port + mClientSession.requestNotification (mp, Listener::databaseNotifications, + Listener::allEvents); +} + + + +void EventListener::HandleCallback (CFMachPortRef port, void *msg, CFIndex size) +{ + // we need to parse the message and see what happened + mClientSession.dispatchNotification (reinterpret_cast(msg), ProcessMessage, this); +} + + + +OSStatus EventListener::ProcessMessage (Listener::Domain domain, Listener::Event event, const void *data, size_t dataLength, void *context) +{ + reinterpret_cast(context)->EventReceived (domain, event, data, dataLength); + return noErr; +} + + + +void EventListener::RequestEvents (Listener::Domain whichDomain, Listener::EventMask whichEvents) +{ + // stop the old event request and change to the new one + mach_port_t mp = CFMachPortGetPort (mMachPortRef); + mClientSession.stopNotification (mp); + mClientSession.requestNotification (mp, whichDomain, whichEvents); +} + + + +void EventListener::EventReceived (Listener::Domain domain, Listener::Event event, const void* data, size_t dataLength) +{ +} + + + +}; +}; diff --git a/SecurityServer/eventlistener.h b/SecurityServer/eventlistener.h new file mode 100644 index 00000000..921e3c14 --- /dev/null +++ b/SecurityServer/eventlistener.h @@ -0,0 +1,41 @@ +#ifndef _H_EVENTLISTENER +#define _H_EVENTLISTENER + +#include + + + +#undef verify + +namespace Security { +namespace SecurityServer { + + +class EventListener +{ +protected: + ClientSession mClientSession; + CFMachPortRef mMachPortRef; + CFRunLoopSourceRef mRunLoopSourceRef; + + static void Callback (CFMachPortRef port, void *msg, CFIndex size, void *info); + static OSStatus ProcessMessage (Listener::Domain domain, Listener::Event event, const void *data, size_t dataLength, void *context); + void HandleCallback (CFMachPortRef port, void *msg, CFIndex size); + void HandleMessage (); + void Initialize (); + +public: + EventListener (CssmAllocator &standard = CssmAllocator::standard(), CssmAllocator &returning = CssmAllocator::standard()); + virtual ~EventListener (); + + void RequestEvents (Listener::Domain domain, Listener::EventMask eventMask); + virtual void EventReceived (Listener::Domain domain, Listener::Event event, const void* data, size_t dataLength); +}; + + +}; // end namespace SecurityServer +}; // end namespace Security + + + +#endif diff --git a/SecurityServer/flippers.cpp b/SecurityServer/flippers.cpp new file mode 100644 index 00000000..795b732d --- /dev/null +++ b/SecurityServer/flippers.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// process - track a single client process and its belongings +// +#include "flippers.h" +#include "memutils.h" + +using namespace LowLevelMemoryUtilities; + + +namespace Flippers { + + +// +// Automatically generated flippers +// +#include "flip_gen.cpp" + + +// +// The raw byte reversal flipper +// +void flip(void *addr, size_t size) +{ + assert(size > 1 && (size % 2 == 0)); + Byte *word = reinterpret_cast(addr); + for (size_t n = 0; n < size/2; n++) { + Byte b = word[n]; + word[n] = word[size-1-n]; + word[size-1-n] = b; + } +} + + +// +// Basic flippers +// +void flip(uint32 &obj) { flip(&obj, sizeof(obj)); } +void flip(uint16 &obj) { flip(&obj, sizeof(obj)); } +void flip(sint32 &obj) { flip(&obj, sizeof(obj)); } +void flip(sint16 &obj) { flip(&obj, sizeof(obj)); } + + +// +// Flip a context attribute. This is heavily polymorphic. +// +void flip(CSSM_CONTEXT_ATTRIBUTE &obj) +{ + flip(obj.AttributeType); + flip(obj.AttributeLength); + switch (obj.AttributeType & CSSM_ATTRIBUTE_TYPE_MASK) { + case CSSM_ATTRIBUTE_DATA_UINT32: + flip(obj.Attribute.Uint32); + break; + // all other alternatives are handled by CSSM_CONTEXT_ATTRIBUTE's walker + default: + break; + } +} + + +} // end namespace Flippers diff --git a/SecurityServer/flippers.h b/SecurityServer/flippers.h new file mode 100644 index 00000000..68d7c157 --- /dev/null +++ b/SecurityServer/flippers.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// process - track a single client process and its belongings +// +#ifndef _H_FLIPPERS +#define _H_FLIPPERS + +#include +#include + +// various types we make flippers for +#include +#include +#include +#include +#include +#include +#include + + +namespace Flippers { + + +// +// The default flipper does nothing +// +template +inline void flip(T &obj) +{ } + + +// +// It's a bad idea to try to flip a const, so flag that +// +template +inline void flip(const T &) +{ tryingToFlipAConstWontWork(); } + + +// +// Basic flippers +// +void flip(uint32 &obj); +void flip(uint16 &obj); +void flip(sint32 &obj); +void flip(sint16 &obj); + +template +inline void flip(Base * &obj) { flip(&obj, sizeof(obj)); } + + +// +// The raw byte reversal flipper +// +void flip(void *addr, size_t size); + + +// +// Include automatically generated flipper declarations +// +#include "flip_gen.h" + + +} // end namespace flippers + + +#endif //_H_FLIPPERS diff --git a/SecurityServer/generate.cf b/SecurityServer/generate.cf new file mode 100644 index 00000000..8557c3ef --- /dev/null +++ b/SecurityServer/generate.cf @@ -0,0 +1,42 @@ +# +# Byte flipper generator configuration. +# +# Syntax of each non-comment line: +# cssmType[/podwrapperType] field1 ... fieldn +# cssmType[/podwrapperType] * +# Generates flippers for each cssmType (with forwarders for podwrapperType if present), +# flipping the fields given. If '*' is used, take field definitions from cssmtype.h. +# + +# +# CSSM standard structures +# +CSSM_DATA/CssmData Length +CSSM_VERSION * +CSSM_SUBSERVICE_UID/CssmSubserviceUid * +CSSM_NET_ADDRESS * +CSSM_LIST_ELEMENT/ListElement WordID ElementType +CSSM_DL_DB_HANDLE * +CSSM_CONTEXT_ATTRIBUTE/Context::Attr CUSTOM +CSSM_CONTEXT/Context * +CSSM_LIST/CssmList/TypedList ListType Tail +CSSM_SAMPLE/CssmSample * +CSSM_SAMPLEGROUP/SampleGroup NumberOfSamples +CSSM_ACCESS_CREDENTIALS/AccessCredentials Callback CallerCtx +CSSM_AUTHORIZATIONGROUP/AuthorizationGroup NumberOfAuthTags +CSSM_ACL_VALIDITY_PERIOD * +CSSM_ACL_ENTRY_PROTOTYPE/AclEntryPrototype Delegate +CSSM_ACL_OWNER_PROTOTYPE/AclOwnerPrototype Delegate +CSSM_ACL_ENTRY_INPUT/AclEntryInput Callback CallerContext +CSSM_ACL_ENTRY_INFO/AclEntryInfo EntryHandle +CSSM_RANGE * +CSSM_KEY_SIZE/CssmKeySize * +CSSM_KEYHEADER/CssmKey::Header * +CSSM_KEY/CssmKey KeyHeader + + +# +# Authorization structures +# +AuthorizationItem valueLength flags +AuthorizationItemSet count diff --git a/SecurityServer/generate.pl b/SecurityServer/generate.pl new file mode 100755 index 00000000..3426267e --- /dev/null +++ b/SecurityServer/generate.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl +# +# +# +use strict; + +my $disclaimer = "Automatically generated - do not edit on penalty of futility!"; + + +# arguments +my ($configfile, $out_h, $out_cpp, $types) = @ARGV; + + +# open configuration file +open(CFG, "$configfile") || die "$configfile: $!"; + +# open and load cssmtypes file +open(TYPES, "$types") || die "$types: $!"; +$/=undef; +my $types_h = ; +close(TYPES); $/="\n"; + +# open output files +open(H, ">$out_h") || die "$out_h: $!"; +open(CPP, ">$out_cpp") || die "$out_cpp: $!"; + +# cautionary headings to each file +print H <) { + chomp; + next if /^[ ]*#/; + next if /^[ ]*$/; + + my @args = split; + $_ = shift @args; + my ($cssmName, @aliases) = split /\//; + + print H "void flip($cssmName &obj);\n"; + for my $alias (@aliases) { + print H "inline void flip($alias &obj) { flip(static_cast<$cssmName &>(obj)); }\n"; + } + + next if ($args[0] eq 'CUSTOM'); + + if ($args[0] eq '*') { + # extract definition from types file + my ($list) = $types_h =~ /{\s+([^}]+)\s+}\s*$cssmName,/; + die "cannot find struct definition for $cssmName in $types" unless $list; + @args = $list =~ /([A-Za-z0-9_]+);/gm; + } + + print CPP "void flip($cssmName &obj)\n{\n"; + for my $field (@args) { + print CPP "\tflip(obj.$field);\n"; + } + print CPP "}\n\n"; +} diff --git a/SecurityServer/key.cpp b/SecurityServer/key.cpp index 7087712b..f26d3b54 100644 --- a/SecurityServer/key.cpp +++ b/SecurityServer/key.cpp @@ -30,12 +30,12 @@ // Note that this doesn't decode the blob (yet). // Key::Key(Database &db, const KeyBlob *blob) -: SecurityServerAcl(keyAcl, CssmAllocator::standard()) +: SecurityServerAcl(keyAcl, CssmAllocator::standard()), mDigest(Server::csp().allocator()) { // perform basic validation on the incoming blob assert(blob); blob->validate(CSSMERR_APPLEDL_INVALID_KEY_BLOB); - switch (blob->version) { + switch (blob->version()) { #if defined(COMPAT_OSX_10_0) case blob->version_MacOS_10_0: break; @@ -53,7 +53,8 @@ Key::Key(Database &db, const KeyBlob *blob) mValidBlob = true; mValidKey = false; mValidUID = false; - debug("SSkey", "%p created from blob version %lx", this, blob->version); + secdebug("SSkey", "%p (handle 0x%lx) created from blob version %lx", + this, handle(), blob->version()); } @@ -62,7 +63,7 @@ Key::Key(Database &db, const KeyBlob *blob) // Key::Key(Database *db, const CssmKey &newKey, uint32 moreAttributes, const AclEntryPrototype *owner) -: SecurityServerAcl(keyAcl, CssmAllocator::standard()) +: SecurityServerAcl(keyAcl, CssmAllocator::standard()), mDigest(Server::csp().allocator()) { if (moreAttributes & CSSM_KEYATTR_PERMANENT) { // better have a database to make it permanent in... @@ -85,8 +86,8 @@ Key::Key(Database *db, const CssmKey &newKey, uint32 moreAttributes, cssmSetInitial(*owner); // specified else cssmSetInitial(new AnyAclSubject()); // defaulted - debug("SSkey", "%p created from key alg=%ld use=0x%lx attr=0x%lx db=%p", - this, mKey.algorithm(), mKey.usage(), mAttributes, db); + secdebug("SSkey", "%p (handle 0x%lx) created from key alg=%ld use=0x%lx attr=0x%lx db=%p", + this, handle(), mKey.header().algorithm(), mKey.header().usage(), mAttributes, db); } @@ -95,11 +96,12 @@ Key::Key(Database *db, const CssmKey &newKey, uint32 moreAttributes, // void Key::setup(const CssmKey &newKey, uint32 moreAttributes) { - CssmKey::Header &header = mKey.header(); + mKey = CssmClient::Key(Server::csp(), newKey, false); + CssmKey::Header &header = mKey->header(); // copy key header header = newKey.header(); - mAttributes = header.attributes() | moreAttributes; + mAttributes = (header.attributes() & ~forcedAttributes) | moreAttributes; // apply initial values of derived attributes (these are all in managedAttributes) if (!(mAttributes & CSSM_KEYATTR_EXTRACTABLE)) @@ -108,19 +110,14 @@ void Key::setup(const CssmKey &newKey, uint32 moreAttributes) mAttributes |= CSSM_KEYATTR_ALWAYS_SENSITIVE; // verify internal/external attribute separation - assert(!(header.attributes() & managedAttributes)); - - // copy key data field, using the CSP's allocator (so the release operation works later) - mKey.KeyData = CssmAutoData(Server::csp().allocator(), newKey).release(); + assert((header.attributes() & managedAttributes) == forcedAttributes); } Key::~Key() { CssmAllocator::standard().free(mBlob); - if (mValidKey) - Server::csp()->freeKey(mKey); - debug("SSkey", "%p destroyed", this); + secdebug("SSkey", "%p destroyed", this); } @@ -128,14 +125,14 @@ Key::~Key() // Form a KeySpec with checking and masking // Key::KeySpec::KeySpec(uint32 usage, uint32 attrs) - : CssmClient::KeySpec(usage, attrs & ~managedAttributes) + : CssmClient::KeySpec(usage, (attrs & ~managedAttributes) | forcedAttributes) { if (attrs & generatedAttributes) CssmError::throwMe(CSSMERR_CSP_INVALID_KEYATTR_MASK); } Key::KeySpec::KeySpec(uint32 usage, uint32 attrs, const CssmData &label) - : CssmClient::KeySpec(usage, attrs & ~managedAttributes, label) + : CssmClient::KeySpec(usage, (attrs & ~managedAttributes) | forcedAttributes, label) { if (attrs & generatedAttributes) CssmError::throwMe(CSSMERR_CSP_INVALID_KEYATTR_MASK); @@ -146,7 +143,7 @@ Key::KeySpec::KeySpec(uint32 usage, uint32 attrs, const CssmData &label) // Retrieve the actual CssmKey value for the key object. // This will decode its blob if needed (and appropriate). // -CssmKey &Key::keyValue() +CssmClient::Key Key::keyValue() { decode(); return mKey; @@ -165,14 +162,17 @@ void Key::decode() // decode the key void *publicAcl, *privateAcl; - database()->decodeKey(mBlob, mKey, publicAcl, privateAcl); + CssmKey key; + database()->decodeKey(mBlob, key, publicAcl, privateAcl); + mKey = CssmClient::Key(Server::csp(), key); importBlob(publicAcl, privateAcl); // publicAcl points into the blob; privateAcl was allocated for us CssmAllocator::standard().free(privateAcl); // extract managed attribute bits - mAttributes = mKey.attributes() & managedAttributes; - mKey.clearAttribute(managedAttributes); + mAttributes = mKey.header().attributes() & managedAttributes; + mKey.header().clearAttribute(managedAttributes); + mKey.header().setAttribute(forcedAttributes); // key is valid now mValidKey = true; @@ -180,21 +180,6 @@ void Key::decode() } -// -// Retrieve the header (only) of a key. -// This is taking the clear header from the blob *without* verifying it. -// -CssmKey::Header &Key::keyHeader() -{ - if (mValidKey) { - return mKey.header(); - } else { - assert(mValidBlob); - return mBlob->header; - } -} - - // // Return a key's handle and header in external form // @@ -202,13 +187,41 @@ void Key::returnKey(Handle &h, CssmKey::Header &hdr) { // return handle h = handle(); + + // obtain the key header, from the valid key or the blob if no valid key + if (mValidKey) { + hdr = mKey.header(); + } else { + assert(mValidBlob); + hdr = mBlob->header; + n2hi(hdr); // correct for endian-ness + } - // return header with external attributes merged - hdr = keyHeader(); + // adjust for external attributes + hdr.clearAttribute(forcedAttributes); hdr.setAttribute(mAttributes); } +// +// Generate the canonical key digest. +// This is defined by a CSP feature that we invoke here. +// +const CssmData &Key::canonicalDigest() +{ + if (!mDigest) { + CssmClient::PassThrough ctx(Server::csp()); + ctx.key(keyValue()); + CssmData *digest = NULL; + ctx(CSSM_APPLECSP_KEYDIGEST, (const void *)NULL, &digest); + assert(digest); + mDigest.set(*digest); // takes ownership of digest data + Server::csp().allocator().free(digest); // the CssmData itself + } + return mDigest.get(); +} + + // // Encode a key into a blob. // We'll have to ask our Database to do this - we don't have its keys. @@ -228,6 +241,7 @@ KeyBlob *Key::blob() // assemble external key form CssmKey externalKey = mKey; + externalKey.clearAttribute(forcedAttributes); externalKey.setAttribute(mAttributes); // encode the key and replace blob @@ -266,7 +280,7 @@ void Key::instantiateAcl() decode(); } -void Key::noticeAclChange() +void Key::changedAcl() { mValidBlob = false; } diff --git a/SecurityServer/key.h b/SecurityServer/key.h index 21faa0f4..222bea06 100644 --- a/SecurityServer/key.h +++ b/SecurityServer/key.h @@ -31,7 +31,6 @@ class Database; - // // A Key object represents a CSSM_KEY known to the SecurityServer. // We give each Key a handle that allows our clients to access it, while we use @@ -43,13 +42,10 @@ class Database; // when talking to our CSP; the external bits are used when negotiating with our client(s). // The difference is the bits in managedAttributes, which relate to persistent key storage // and are not digestible by our CSP. The internal attributes are kept in mKey. The external -// ones are kept in mAttributes, and are a superset of the internal ones. +// ones are kept in mAttributes. // class Key : public HandleObject, public SecurityServerAcl { public: - //Key(Database *db, const CssmKey &newKey, uint32 usage, uint32 attrs, - // const AclEntryPrototype *owner = NULL); - //Key(Database *db, const CssmKey &newKey, const AclEntryPrototype *owner = NULL); Key(Database &db, const KeyBlob *blob); Key(Database *db, const CssmKey &newKey, uint32 moreAttributes, const AclEntryPrototype *owner = NULL); @@ -59,13 +55,17 @@ public: bool hasDatabase() const { return mDatabase != NULL; } // yield the decoded internal key -- internal attributes - operator CssmKey &() { return keyValue(); } - operator CSSM_KEY & () { return keyValue(); } - size_t length() { return keyValue().length(); } - void *data() { return keyValue().data(); } + CssmClient::Key key() { return keyValue(); } + const CssmKey &cssmKey() { return keyValue(); } + operator CssmClient::Key () { return keyValue(); } + operator const CssmKey &() { return keyValue(); } + operator const CSSM_KEY & () { return keyValue(); } // yield the approximate external key header -- external attributes void returnKey(Handle &h, CssmKey::Header &hdr); + + // generate the canonical key digest + const CssmData &canonicalDigest(); // we can also yield an encoded KeyBlob *if* we belong to a database KeyBlob *blob(); @@ -75,11 +75,13 @@ public: // ACL state management hooks void instantiateAcl(); - void noticeAclChange(); + void changedAcl(); const Database *relatedDatabase() const; // key attributes that should not be passed on to the CSP static const uint32 managedAttributes = KeyBlob::managedAttributes; + // these attributes are "forced on" in internal keys (but not always in external attributes) + static const uint32 forcedAttributes = KeyBlob::forcedAttributes; // these attributes are internally generated, and invalid on input static const uint32 generatedAttributes = CSSM_KEYATTR_ALWAYS_SENSITIVE | CSSM_KEYATTR_NEVER_EXTRACTABLE; @@ -90,17 +92,19 @@ public: KeySpec(uint32 usage, uint32 attrs); KeySpec(uint32 usage, uint32 attrs, const CssmData &label); }; - + CSSM_KEYATTR_FLAGS attributes() { return mAttributes; } + private: void setup(const CssmKey &newKey, uint32 attrs); void decode(); - CssmKey::Header &keyHeader(); - CssmKey &keyValue(); + CssmClient::Key keyValue(); private: - CssmKey mKey; // clear form CssmKey (attributes modified) + CssmClient::Key mKey; // clear form CssmKey (attributes modified) + CssmKey::Header mHeaderCache; // cached, cleaned blob header cache CSSM_KEYATTR_FLAGS mAttributes; // full attributes (external form) bool mValidKey; // CssmKey form is valid + CssmAutoData mDigest; // computed key digest (cached) Database *mDatabase; // the database we belong to, NULL if independent diff --git a/SecurityServer/main.cpp b/SecurityServer/main.cpp index 8e7b5743..46568c6e 100644 --- a/SecurityServer/main.cpp +++ b/SecurityServer/main.cpp @@ -35,12 +35,15 @@ #include #include +#include "ktracecodes.h" + // ACL subject types (their makers are instantiated here) #include #include #include #include #include +#include #include #include "acl_keychain.h" @@ -52,6 +55,7 @@ namespace Security // Program options (set by argument scan and environment) // uint32 debugMode = 0; +const char *bootstrapName = NULL; } // end namespace Security @@ -69,20 +73,22 @@ static void handleSIGOther(int); // int main(int argc, char *argv[]) { + Debug::trace (kSecTraceSecurityServerStart); + // program arguments (preset to defaults) bool forceCssmInit = false; bool reExecute = false; int workerTimeout = 0; int maxThreads = 0; const char *authorizationConfig = "/etc/authorization"; - const char *bootstrapName = "SecurityServer"; const char *entropyFile = "/var/db/SystemEntropyCache"; + const char *equivDbFile = EQUIVALENCEDBPATH; // parse command line arguments extern char *optarg; extern int optind; int arg; - while ((arg = getopt(argc, argv, "a:dEfN:t:T:X")) != -1) { + while ((arg = getopt(argc, argv, "a:de:E:fN:t:T:X")) != -1) { switch (arg) { case 'a': authorizationConfig = optarg; @@ -90,6 +96,9 @@ int main(int argc, char *argv[]) case 'd': debugMode++; break; + case 'e': + equivDbFile = optarg; + break; case 'E': entropyFile = optarg; break; @@ -118,13 +127,20 @@ int main(int argc, char *argv[]) // take no non-option arguments if (optind < argc) usage(argv[0]); + + // figure out the bootstrap name + IFDEBUG(if (!bootstrapName) bootstrapName = getenv(SECURITYSERVER_BOOTSTRAP_ENV)); + + if (!bootstrapName) { + bootstrapName = SECURITYSERVER_BOOTSTRAP_NAME; + } // configure logging first if (debugMode) { - Syslog::open(argv[0], LOG_AUTHPRIV, LOG_PERROR); + Syslog::open(bootstrapName, LOG_AUTHPRIV, LOG_PERROR); Syslog::notice("SecurityServer started in debug mode"); } else { - Syslog::open(argv[0], LOG_AUTHPRIV, LOG_CONS); + Syslog::open(bootstrapName, LOG_AUTHPRIV, LOG_CONS); } // if we're not running as root in production mode, fail @@ -136,12 +152,12 @@ int main(int argc, char *argv[]) exit(1); #else fprintf(stderr, "SecurityServer is unprivileged; some features may not work.\n"); - debug("SS", "Running as user %d (you have been warned)", uid); + secdebug("SS", "Running as user %d (you have been warned)", uid); #endif //NDEBUG } // turn into a properly diabolical daemon unless debugMode is on - if (!debugMode) { + if (!debugMode) { if (!Daemon::incarnate()) exit(1); // can't daemonize @@ -161,19 +177,19 @@ int main(int argc, char *argv[]) new ProtectedPasswordAclSubject::Maker(); new ThresholdAclSubject::Maker(); new CommentAclSubject::Maker(); - new CodeSignatureAclSubject::Maker(signer); + new ProcessAclSubject::Maker(); + new CodeSignatureAclSubject::Maker(signer); new KeychainPromptAclSubject::Maker(); // add a temporary registration for a subject type that went out in 10.2 seed 1 // this should probably be removed for the next major release >10.2 new KeychainPromptAclSubject::Maker(CSSM_WORDID__RESERVED_1); + // establish the code equivalents database + CodeSignatures codeSignatures(equivDbFile); + // create the main server object and register it - Server server(authority, bootstrapName); - - // create the RootSession object (if -d, give it graphics and tty attributes) - RootSession rootSession(server.primaryServicePort(), - debugMode ? (sessionHasGraphicAccess | sessionHasTTY) : 0); + Server server(authority, codeSignatures, bootstrapName); // set server configuration from arguments, if specified if (workerTimeout) @@ -187,21 +203,28 @@ int main(int argc, char *argv[]) # else if (!getuid()) new EntropyManager(server, entropyFile); # endif + + // create the RootSession object (if -d, give it graphics and tty attributes) + RootSession rootSession(server.primaryServicePort(), + debugMode ? (sessionHasGraphicAccess | sessionHasTTY) : 0); // set up signal handlers if (signal(SIGCHLD, handleSIGCHLD) == SIG_ERR) - debug("SS", "Cannot ignore SIGCHLD: errno=%d", errno); + secdebug("SS", "Cannot ignore SIGCHLD: errno=%d", errno); if (signal(SIGINT, handleSIGOther) == SIG_ERR) - debug("SS", "Cannot handle SIGINT: errno=%d", errno); + secdebug("SS", "Cannot handle SIGINT: errno=%d", errno); if (signal(SIGTERM, handleSIGOther) == SIG_ERR) - debug("SS", "Cannot handle SIGTERM: errno=%d", errno); + secdebug("SS", "Cannot handle SIGTERM: errno=%d", errno); // initialize CSSM now if requested if (forceCssmInit) server.loadCssm(); Syslog::notice("Entering service"); - debug("SS", "Entering service run loop"); + secdebug("SS", "%s initialized", bootstrapName); + + Debug::trace (kSecTraceSecurityServerStart); + server.run(); // fell out of runloop (should not happen) @@ -227,15 +250,16 @@ static void usage(const char *me) static void handleSIGCHLD(int) { int status; - switch (pid_t pid = waitpid(-1, &status, WNOHANG)) { + pid_t pid = waitpid(-1, &status, WNOHANG); + switch (pid) { case 0: - debug("SS", "Spurious SIGCHLD ignored"); + //secdebug("SS", "Spurious SIGCHLD ignored"); return; case -1: - debug("SS", "waitpid after SIGCHLD failed: errno=%d", errno); + //secdebug("SS", "waitpid after SIGCHLD failed: errno=%d", errno); return; default: - debug("SS", "Reaping child pid=%d", pid); + //secdebug("SS", "Reaping child pid=%d", pid); return; } } @@ -248,11 +272,11 @@ static void handleSIGOther(int sig) { switch (sig) { case SIGINT: - debug("SS", "Interrupt signal; terminating"); + //secdebug("SS", "Interrupt signal; terminating"); Syslog::notice("received interrupt signal; terminating"); exit(0); case SIGTERM: - debug("SS", "Termination signal; terminating"); + //secdebug("SS", "Termination signal; terminating"); Syslog::notice("received termination signal; terminating"); exit(0); } diff --git a/SecurityServer/notifications.cpp b/SecurityServer/notifications.cpp index dea6b37b..df74d3bb 100644 --- a/SecurityServer/notifications.cpp +++ b/SecurityServer/notifications.cpp @@ -43,7 +43,7 @@ Listener::Listener(Process &proc, Port receiver, Domain dom, EventMask evs) // let's get told when the receiver port dies Server::active().notifyIfDead(receiver); - debug("notify", "%p created domain %ld events 0x%lx port %d", + secdebug("notify", "%p created domain %ld events 0x%lx port %d", this, domain, events, mNotificationPort.port()); } @@ -53,8 +53,7 @@ Listener::Listener(Process &proc, Port receiver, Domain dom, EventMask evs) // Listener::~Listener() { - mNotificationPort.deallocate(); - debug("notify", "%p destroyed", this); + secdebug("notify", "%p destroyed", this); } @@ -66,15 +65,15 @@ void Listener::notifyMe(Domain domain, Event event, const CssmData &data) if (domain != this->domain || !(event & events)) return; // not interested - debug("notify", "%p sending domain %ld event 0x%lx to port %d process %d", + secdebug("notify", "%p sending domain %ld event 0x%lx to port %d process %d", this, domain, event, mNotificationPort.port(), process.pid()); // send mach message (via MIG simpleroutine) - if (kern_return_t rc = ucsp_notify_sender_notify(mNotificationPort, + if (IFDEBUG(kern_return_t rc =) ucsp_notify_sender_notify(mNotificationPort, MACH_SEND_TIMEOUT, 0, domain, event, data.data(), data.length(), 0 /*@@@ placeholder for sender ID */)) - debug("notify", "%p send failed (error=%d)", this, rc); + secdebug("notify", "%p send failed (error=%d)", this, rc); } @@ -101,9 +100,9 @@ bool Listener::remove(Port port) if (range.first == range.second) return false; // not one of ours - Server::active().notifyIfDead(port, false); for (Iterator it = range.first; it != range.second; it++) delete it->second; listeners.erase(range.first, range.second); + port.destroy(); return true; // got it } diff --git a/SecurityServer/process.cpp b/SecurityServer/process.cpp index deb5cfb8..8de3420f 100644 --- a/SecurityServer/process.cpp +++ b/SecurityServer/process.cpp @@ -23,50 +23,56 @@ #include "server.h" #include "session.h" #include "authority.h" +#include "flippers.h" // // Construct a Process object. // -Process::Process(Port servicePort, TaskPort taskPort, const char *identity, uid_t uid, gid_t gid) +Process::Process(Port servicePort, TaskPort taskPort, + const ClientSetupInfo *info, const char *identity, uid_t uid, gid_t gid) : session(Session::find(servicePort)), mBusyCount(0), mDying(false), - mTaskPort(taskPort), mUid(uid), mGid(gid) + mTaskPort(taskPort), mByteFlipped(false), mUid(uid), mGid(gid), + mClientIdent(deferred) { + // examine info passed + assert(info); + uint32 pversion = info->version; + if (pversion == SSPROTOVERSION) { + // correct protocol, same byte order, cool + } else { + Flippers::flip(pversion); + if (pversion == SSPROTOVERSION) { + // correct protocol, reversed byte order + mByteFlipped = true; + } else { + // unsupported protocol version + CssmError::throwMe(CSSM_ERRCODE_INCOMPATIBLE_VERSION); + } + } + // let's take a look at our wannabe client... mPid = mTaskPort.pid(); // register with the session session.addProcess(this); - // identify the client-on-disk - // @@@ do this lazily on first use? - // @@@ note that the paradigm will shift here when kernel-supported id happens - mClientCode = CodeSigning::OSXCode::decode(identity); - - debug("SS", "New process %p(%d) uid=%d gid=%d session=%p TP=%d for %s", + secdebug("SS", "New process %p(%d) uid=%d gid=%d session=%p TP=%d %sfor %s", this, mPid, mUid, mGid, &session, - mTaskPort.port(), identity ? identity : "(unknown)"); -} - -#if 0 -Process::Process(Process &prior) - : session(Session::find(prior.mTaskPort.bootstrap())), mBusyCount(0), mDying(false), - mTaskPort(prior.mTaskPort), mUid(prior.mUid), mGid(prior.mGid) -{ - // copy more - mPid = prior.mPid; + mTaskPort.port(), + mByteFlipped ? "FLIP " : "", + (identity && identity[0]) ? identity : "(unknown)"); - // register with the session - session.addProcess(this); - - // copy the client-code id (and clear it in the prior so it doesn't get destroyed there) - mClientCode = prior.mClientCode; - prior.mTaskPort = Port(); - - debug("SS", "Process %p(%d) recloned uid=%d gid=%d session=%p", - this, mPid, mUid, mGid, &session); + try { + mClientCode = CodeSigning::OSXCode::decode(identity); + } catch (...) { + secdebug("SS", "process %p(%d) identity decode threw exception", this, pid()); + } + if (!mClientCode) { + mClientIdent = unknown; // no chance to squeeze a code identity from this + secdebug("SS", "process %p(%d) no clientCode - marked anonymous", this, pid()); + } } -#endif Process::~Process() @@ -75,41 +81,45 @@ Process::~Process() // tell all our authorizations that we're gone IFDEBUG(if (!mAuthorizations.empty()) - debug("SS", "Process %p(%d) clearing %d authorizations", + secdebug("SS", "Process %p(%d) clearing %d authorizations", this, mPid, int(mAuthorizations.size()))); for (AuthorizationSet::iterator it = mAuthorizations.begin(); - it != mAuthorizations.end(); it++) { + it != mAuthorizations.end(); ) { AuthorizationToken *auth = *it; - if (removeAuthorization(auth)) - delete auth; + while (++it != mAuthorizations.end() && *it == auth) ; // Skip duplicates + if (auth->endProcess(*this)) + delete auth; } - + // remove all database handles that belong to this process IFDEBUG(if (!mDatabases.empty()) - debug("SS", "Process %p(%d) clearing %d database handles", + secdebug("SS", "Process %p(%d) clearing %d database handles", this, mPid, int(mDatabases.size()))); for (DatabaseSet::iterator it = mDatabases.begin(); it != mDatabases.end(); it++) delete *it; // no need to lock here; the client process has no more active threads - debug("SS", "Process %p(%d) has died", this, mPid); + secdebug("SS", "Process %p(%d) has died", this, mPid); // release our name for the process's task port if (mTaskPort) - mTaskPort.destroy(); // either dead or taken by reclone + mTaskPort.destroy(); // deregister from session if (session.removeProcess(this)) delete &session; } -bool Process::kill() +bool Process::kill(bool keepTaskPort) { + StLock _(mLock); + if (keepTaskPort) + mTaskPort = Port(); // clear port so we don't destroy it later if (mBusyCount == 0) { return true; // destroy me now } else { - debug("SS", "Process %p(%d) destruction deferred for %d busy connections", + secdebug("SS", "Process %p(%d) destruction deferred for %d busy connections", this, mPid, int(mBusyCount)); mDying = true; return false; // destroy me later @@ -151,17 +161,39 @@ void Process::removeDatabase(Database *database) // -// Verify the code signature of the a process's on-disk source. -// @@@ In a truly secure solution, we would ask the OS to verify this. -// @@@ Only the OS knows for sure what disk file (if any) originated a process. -// @@@ In the meantime, we fake it. +// CodeSignatures implementation of Identity. +// The caller must make sure we have a valid (not necessarily hash-able) clientCode(). // -bool Process::verifyCodeSignature(const CodeSigning::Signature *signature) +string Process::getPath() const { - if (mClientCode) - return Server::signer().verify(*mClientCode, signature); - else - return false; // identity not known; can't verify + assert(mClientCode); + return mClientCode->canonicalPath(); +} + +const CssmData Process::getHash(CodeSigning::OSXSigner &signer) const +{ + switch (mClientIdent) { + case deferred: + try { + // try to calculate our signature hash (first time use) + mCachedSignature.reset(mClientCode->sign(signer)); + assert(mCachedSignature.get()); + mClientIdent = known; + secdebug("SS", "process %p(%d) code signature computed", this, pid()); + break; + } catch (...) { + // couldn't get client signature (unreadable, gone, hack attack, ...) + mClientIdent = unknown; + secdebug("SS", "process %p(%d) no code signature - anonymous", this, pid()); + CssmError::throwMe(CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION); + } + case known: + assert(mCachedSignature.get()); + break; + case unknown: + CssmError::throwMe(CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION); + } + return CssmData(*mCachedSignature); } @@ -176,17 +208,31 @@ void Process::addAuthorization(AuthorizationToken *auth) auth->addProcess(*this); } +void Process::checkAuthorization(AuthorizationToken *auth) +{ + assert(auth); + StLock _(mLock); + if (mAuthorizations.find(auth) == mAuthorizations.end()) + MacOSError::throwMe(errAuthorizationInvalidRef); +} + bool Process::removeAuthorization(AuthorizationToken *auth) { assert(auth); StLock _(mLock); // we do everything with a single set lookup call... typedef AuthorizationSet::iterator Iter; - pair range = mAuthorizations.equal_range(auth); - assert(range.first != mAuthorizations.end()); - Iter next = range.first; next++; // next element after first hit - mAuthorizations.erase(range.first); // erase first hit - if (next == range.second) { // if no more hits... + Iter it = mAuthorizations.lower_bound(auth); + bool isLast; + if (it == mAuthorizations.end() || auth != *it) { + Syslog::error("process is missing authorization to remove"); // temp. diagnostic + isLast = true; + } else { + Iter next = it; ++next; // following element + isLast = (next == mAuthorizations.end()) || auth != *next; + mAuthorizations.erase(it); // remove first match + } + if (isLast) { if (auth->endProcess(*this)) // ... tell it to remove us, return true; // ... and tell the caller } diff --git a/SecurityServer/process.h b/SecurityServer/process.h index 4fd68eab..7d5a3721 100644 --- a/SecurityServer/process.h +++ b/SecurityServer/process.h @@ -24,9 +24,9 @@ #include "securityserver.h" #include "SecurityAgentClient.h" -#include #include #include "key.h" +#include "codesigdb.h" #include "notifications.h" #include @@ -41,28 +41,28 @@ class AuthorizationToken; // A Process object represents a UNIX process (and associated Mach Task) that has // had contact with us and may have some state associated with it. // -class Process { +class Process : public CodeSignatures::Identity { public: - Process(Port servicePort, TaskPort tPort, const char *identity, uid_t uid, gid_t gid); -#if 0 - Process(Process &prior); // specialized reclone facility -#endif + Process(Port servicePort, TaskPort tPort, + const ClientSetupInfo *info, const char *identity, + uid_t uid, gid_t gid); virtual ~Process(); uid_t uid() const { return mUid; } gid_t gid() const { return mGid; } pid_t pid() const { return mPid; } TaskPort taskPort() const { return mTaskPort; } + bool byteFlipped() const { return mByteFlipped; } - CodeSigning::OSXCode *clientCode() const { return mClientCode; } - bool verifyCodeSignature(const CodeSigning::Signature *signature); + CodeSigning::OSXCode *clientCode() const { return (mClientIdent == unknown) ? NULL : mClientCode; } void addAuthorization(AuthorizationToken *auth); + void checkAuthorization(AuthorizationToken *auth); bool removeAuthorization(AuthorizationToken *auth); void beginConnection(Connection &); bool endConnection(Connection &); - bool kill(); + bool kill(bool keepTaskPort = false); void addDatabase(Database *database); void removeDatabase(Database *database); @@ -72,6 +72,13 @@ public: void postNotification(Listener::Domain domain, Listener::Event event, const CssmData &data); Session &session; + + // aclSequence is taken to serialize ACL validations to pick up mutual changes + Mutex aclSequence; + +protected: + std::string getPath() const; + const CssmData getHash(CodeSigning::OSXSigner &signer) const; private: Mutex mLock; // object lock @@ -80,11 +87,14 @@ private: // peer state: established during connection startup; fixed thereafter TaskPort mTaskPort; // task port + bool mByteFlipped; // client's byte order is reverse of ours pid_t mPid; // process id uid_t mUid; // UNIX uid credential gid_t mGid; // primary UNIX gid credential - RefPointer mClientCode; // code object for client + RefPointer mClientCode; // code object for client (NULL if unknown) + mutable enum { deferred, known, unknown } mClientIdent; // state of client identity + mutable auto_ptr mCachedSignature; // cached signature (if already known) // authorization dictionary typedef multiset AuthorizationSet; diff --git a/SecurityServer/secagent.defs b/SecurityServer/secagent.defs index f1314ed2..7f55bead 100644 --- a/SecurityServer/secagent.defs +++ b/SecurityServer/secagent.defs @@ -72,8 +72,8 @@ routine retryUnlockDatabase(UCSP_PORTS; in reason: Reason; out passphrase: Strin routine queryNewPassphrase(UCSP_PORTS; in requestor: ConstString; in requestPid: pid_t; in database: ConstString; in reason: Reason; - out stagePort: mach_port_copy_send_t; out passphrase: String); -routine retryNewPassphrase(UCSP_PORTS; in reason: Reason; out passphrase: String); + out stagePort: mach_port_copy_send_t; out passphrase: String; out oldPassphrase: String); +routine retryNewPassphrase(UCSP_PORTS; in reason: Reason; out passphrase: String; out oldPassphrase: String); // // "Rogue App" alert/confirm function @@ -81,7 +81,13 @@ routine retryNewPassphrase(UCSP_PORTS; in reason: Reason; out passphrase: String routine queryKeychainAccess(UCSP_PORTS; in requestor: ConstString; in requestPid: pid_t; in database: ConstString; in item: ConstString; in operation: AclAuthorization; in needPassphrase: MigBoolean; - out choice: Choice); + out stagePort: mach_port_copy_send_t; out choice: Choice); + +routine retryQueryKeychainAccess (UCSP_PORTS; + in reason: Reason; out choice: Choice); + +routine queryCodeIdentity(UCSP_PORTS; + in requestor: ConstString; in requestPid: pid_t; in aclPath: ConstString; out choice: Choice); // // Generic new/old password prompt interface diff --git a/SecurityServer/secagent_types.h b/SecurityServer/secagent_types.h index 92882c77..8b328bf2 100644 --- a/SecurityServer/secagent_types.h +++ b/SecurityServer/secagent_types.h @@ -58,4 +58,5 @@ typedef uint32 AuthorizationResultInt; #define UseStaticTemplates 0 + } // end namespace Security diff --git a/SecurityServer/securityserver.h b/SecurityServer/securityserver.h index ccf344b5..58be6f75 100644 --- a/SecurityServer/securityserver.h +++ b/SecurityServer/securityserver.h @@ -45,6 +45,7 @@ using namespace UnixPlusPlus; // Logging and verbosity levels // extern uint32 debugMode; +extern const char *bootstrapName; } // end namespace Security diff --git a/SecurityServer/server.cpp b/SecurityServer/server.cpp index 2ce0e382..35914b5f 100644 --- a/SecurityServer/server.cpp +++ b/SecurityServer/server.cpp @@ -32,12 +32,13 @@ using namespace MachPlusPlus; // // Construct the server object // -Server::Server(Authority &myAuthority, const char *bootstrapName) +Server::Server(Authority &authority, CodeSignatures &signatures, const char *bootstrapName) : MachServer(bootstrapName), mBootstrapName(bootstrapName), mCurrentConnection(false), mCSPModule(gGuidAppleCSP, mCssm), mCSP(mCSPModule), - mAuthority(myAuthority) + mAuthority(authority), + mCodeSignatures(signatures) { // engage the subsidiary port handler for sleep notifications add(sleepWatcher); @@ -63,13 +64,13 @@ Connection &Server::connection(mach_port_t port) { Server &server = active(); StLock _(server.lock); - if (Connection *conn = server.connections[port]) { - active().mCurrentConnection = conn; - conn->beginWork(); - return *conn; - } - // unknown client port -- could be a hack attempt - CssmError::throwMe(CSSM_ERRCODE_INVALID_CONTEXT_HANDLE); + ConnectionMap::iterator it = server.connections.find(port); + if (it == server.connections.end()) // unknown client port -- could be a hack attempt + CssmError::throwMe(CSSM_ERRCODE_INVALID_CONTEXT_HANDLE); + Connection *conn = it->second; + active().mCurrentConnection = conn; + conn->beginWork(); + return *conn; } Connection &Server::connection(bool tolerant) @@ -138,11 +139,11 @@ static const struct IPCName { const char *name; int ipc; } ipcNames[] = boolean_t Server::handle(mach_msg_header_t *in, mach_msg_header_t *out) { const int first = ipcNames[0].ipc; - assert(in->msgh_id >= first && in->msgh_id < first + ucsp_MSG_COUNT); - const char *name = ipcNames[in->msgh_id - first].name; - debug("SSreq", "begin %s (%d)", name, in->msgh_id); + const char *name = (in->msgh_id >= first && in->msgh_id < first + ucsp_MSG_COUNT) ? + ipcNames[in->msgh_id - first].name : "OUT OF BOUNDS"; + secdebug("SSreq", "begin %s (%d)", name, in->msgh_id); boolean_t result = ucsp_server(in, out); - debug("SSreq", "end %s (%d)", name, in->msgh_id); + secdebug("SSreq", "end %s (%d)", name, in->msgh_id); return result; } @@ -152,15 +153,33 @@ boolean_t Server::handle(mach_msg_header_t *in, mach_msg_header_t *out) // // Set up a new Connection. This establishes the environment (process et al) as needed // and registers a properly initialized Connection object to run with. +// Type indicates how "deep" we need to initialize (new session, process, or connection). +// Everything at and below that level is constructed. This is straight-forward except +// in the case of session re-initialization (see below). // -void Server::setupConnection(Port servicePort, Port replyPort, Port taskPort, - const security_token_t &securityToken, const char *identity) +void Server::setupConnection(ConnectLevel type, Port servicePort, Port replyPort, Port taskPort, + const security_token_t &securityToken, const ClientSetupInfo *info, const char *identity) { // first, make or find the process based on task port StLock _(lock); Process * &proc = processes[taskPort]; - if (proc == NULL) { - proc = new Process(servicePort, taskPort, identity, + if (type == connectNewSession && proc) { + // The client has talked to us before and now wants to create a new session. + // We'll unmoor the old process object and cast it adrift (it will die either now + // or later following the usual deferred-death mechanics). + // The connection object will die (it's probably already dead) because the client + // has destroyed its replyPort. So we don't worry about this here. + secdebug("server", "session setup - marooning old process %p(%d) of session %p", + proc, proc->pid(), &proc->session); + if (proc->kill(true)) + delete proc; + proc = NULL; + } + if (!proc) { + if (type == connectNewThread) // client error (or attack) + CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); + assert(info && identity); + proc = new Process(servicePort, taskPort, info, identity, securityToken.val[0], securityToken.val[1]); notifyIfDead(taskPort); } @@ -189,45 +208,6 @@ void Server::endConnection(Port replyPort) } -// -// Take an existing Connection/Process combo. Tear them down even though -// the client-side thread/process is still alive and construct new ones in their place. -// This is a high-wire act with a frayed net. We use it ONLY to deal with clients -// who change their Session (by changing their bootstrap subset port) in mid-stream. -// In other words, this is a hack that the client would be well advised to avoid. -// (Avoid it by calling SessionCreate before calling any other Security interfaces in -// the process's life.) -// -#if 0 -Process *Server::resetConnection() -{ - Connection *oldConnection = mCurrentConnection; - Process *oldProcess = &oldConnection->process; - debug("SS", "reset process %p connection %p for session switch", - oldProcess, oldConnection); - - Port replyPort = oldConnection->clientPort(); - - oldConnection->endWork(); - oldConnection->abort(true); - delete oldConnection; - - oldProcess->kill(); - - Process * &proc = processes[oldProcess->taskPort()]; - proc = new Process(*oldProcess); - delete oldProcess; - - Connection *connection = new Connection(*proc, replyPort); - connections[replyPort] = connection; - mCurrentConnection = connection; - connection->beginWork(); - - return proc; -} -#endif - - // // Handling dead-port notifications. // This receives DPNs for all kinds of ports we're interested in. @@ -235,7 +215,7 @@ Process *Server::resetConnection() void Server::notifyDeadName(Port port) { StLock _(lock); - debug("SSports", "port %d is dead", port.port()); + secdebug("SSports", "port %d is dead", port.port()); // is it a connection? ConnectionMap::iterator conIt = connections.find(port); @@ -261,7 +241,7 @@ void Server::notifyDeadName(Port port) if (Listener::remove(port)) return; - debug("server", "spurious dead port notification for port %d", port.port()); + secdebug("server", "spurious dead port notification for port %d", port.port()); } @@ -271,7 +251,7 @@ void Server::notifyDeadName(Port port) // void Server::notifyNoSenders(Port port, mach_port_mscount_t) { - debug("SSports", "port %d no senders", port.port()); + secdebug("SSports", "port %d no senders", port.port()); Session::eliminate(port); } @@ -281,8 +261,8 @@ void Server::notifyNoSenders(Port port, mach_port_mscount_t) // void Server::SleepWatcher::systemWillSleep() { - debug("SS", "sleep notification received"); - Database::lockAllDatabases(true); + secdebug("SS", "sleep notification received"); + Session::lockAllDatabases(true); } @@ -309,12 +289,24 @@ void Server::loadCssm() if (!mCssm->isActive()) { StLock _(lock); if (!mCssm->isActive()) { - initMds(); - debug("SS", "CSSM initializing"); + try { + initMds(); + } catch (const CssmError &error) { + switch (error.cssmError()) { + case CSSMERR_DL_MDS_ERROR: + case CSSMERR_DL_OS_ACCESS_DENIED: + secdebug("SS", "MDS initialization failed; continuing"); + Syslog::warning("MDS initialization failed; continuing"); + break; + default: + throw; + } + } + secdebug("SS", "CSSM initializing"); mCssm->init(); mCSP->attach(); - char guids[Guid::stringRepLength+1]; - IFDEBUG(debug("SS", "CSSM ready with CSP %s", mCSP->guid().toString(guids))); + IFDEBUG(char guids[Guid::stringRepLength+1]); + secdebug("SS", "CSSM ready with CSP %s", mCSP->guid().toString(guids)); } } } @@ -323,7 +315,7 @@ void Server::loadCssm() static void initMds() { - debug("SS", "MDS initializing"); + secdebug("SS", "MDS initializing"); CssmAllocatorMemoryFunctions memory(CssmAllocator::standard()); MDS_FUNCS functions; MDS_HANDLE handle; diff --git a/SecurityServer/server.h b/SecurityServer/server.h index dde5d868..3da8b93c 100644 --- a/SecurityServer/server.h +++ b/SecurityServer/server.h @@ -30,19 +30,22 @@ #include #include #include +#include "codesigdb.h" #include "connection.h" #include "key.h" #include "xdatabase.h" #include "authority.h" #include +#define EQUIVALENCEDBPATH "/var/db/CodeEquivalenceDatabase" + class Server : public MachPlusPlus::MachServer, public UniformRandomBlobs { public: - Server(Authority &myAuthority, const char *bootstrapName); + Server(Authority &myAuthority, CodeSignatures &signatures, const char *bootstrapName); ~Server(); - + // run the server until it shuts down void run(); @@ -58,24 +61,29 @@ public: static void requestComplete(); static Key &key(KeyHandle key) - { return findHandle(key, CSSMERR_CSP_INVALID_KEY); } + { return findHandle(key, CSSMERR_CSP_INVALID_KEY_REFERENCE); } static Key *optionalKey(KeyHandle k) { return (k == noKey) ? NULL : &key(k); } static Database &database(DbHandle db) { return findHandle(db, CSSMERR_DL_INVALID_DB_HANDLE); } static Database *optionalDatabase(DbHandle db) { return db ? &database(db) : NULL; } static Authority &authority() { return active().mAuthority; } - static CodeSigning::OSXSigner &signer() { return active().mSigner; } + static CodeSignatures &codeSignatures() { return active().mCodeSignatures; } static SecurityServerAcl &aclBearer(AclKind kind, CSSM_HANDLE handle); static CssmClient::CSP &csp() { return active().getCsp(); } void loadCssm(); public: - void setupConnection(Port servicePort, Port replyPort, Port taskPort, - const security_token_t &securityToken, const char *executablePath); -#if 0 - Process *resetConnection(); -#endif + // set up a new connection + enum ConnectLevel { + connectNewSession, + connectNewProcess, + connectNewThread + }; + void setupConnection(ConnectLevel type, Port servicePort, Port replyPort, Port taskPort, + const security_token_t &securityToken, + const ClientSetupInfo *info = NULL, const char *executablePath = NULL); + void endConnection(Port replyPort); static void releaseWhenDone(CssmAllocator &alloc, void *memory) @@ -111,17 +119,18 @@ private: ProcessMap processes; // Current connection, if any (per thread). - // Set as a side effect of calling the connection() method. + // Set as a side effect of calling connection(mach_port_t) + // and returned by connection(bool). PerThreadPointer mCurrentConnection; // CSSM components - CssmClient::Cssm mCssm; - CssmClient::Module mCSPModule; - CssmClient::CSP mCSP; - CssmClient::CSP &getCsp(); + CssmClient::Cssm mCssm; // CSSM instance + CssmClient::Module mCSPModule; // CSP module + CssmClient::CSP mCSP; // CSP attachment + CssmClient::CSP &getCsp(); // lazily initialize, then return CSP attachment Authority &mAuthority; - CodeSigning::OSXSigner mSigner; + CodeSignatures &mCodeSignatures; }; #endif //_H_SERVER diff --git a/SecurityServer/session.cpp b/SecurityServer/session.cpp index ecdeda94..090275ed 100644 --- a/SecurityServer/session.cpp +++ b/SecurityServer/session.cpp @@ -44,7 +44,7 @@ Session::Session(Bootstrap bootstrap, Port servicePort, SessionAttributeBits att : mBootstrap(bootstrap), mServicePort(servicePort), mAttributes(attrs), mProcessCount(0), mAuthCount(0), mDying(false) { - debug("SSsession", "%p CREATED: handle=0x%lx bootstrap=%d service=%d attrs=0x%lx", + secdebug("SSsession", "%p CREATED: handle=0x%lx bootstrap=%d service=%d attrs=0x%lx", this, handle(), mBootstrap.port(), mServicePort.port(), mAttributes); } @@ -91,8 +91,9 @@ DynamicSession::~DynamicSession() Server::active().remove(*this); // if this is a (the) graphic login session, lock all databases - if (attribute(sessionHasGraphicAccess)) - Database::lockAllDatabases(); + secdebug("session", "%p Locking all %ld databases", + this, databases().size()); + Database::lockAllDatabases(databases()); } @@ -108,7 +109,7 @@ void DynamicSession::release() Session::~Session() { assert(mProcessCount == 0); // can't die with processes still alive - debug("SSsession", "%p DESTROYED: handle=0x%lx bootstrap=%d", + secdebug("SSsession", "%p DESTROYED: handle=0x%lx bootstrap=%d", this, handle(), mBootstrap.port()); } @@ -156,7 +157,7 @@ void Session::eliminate(Port servPort) if (session->clearResources()) delete session; else - debug("SSsession", "session %p zombified for %d processes and %d auths", + secdebug("SSsession", "session %p zombified for %d processes and %d auths", session, int(session->mProcessCount), int(session->mAuthCount)); } @@ -172,7 +173,7 @@ bool Session::clearResources() StLock _(mCredsLock); IFDEBUG(if (!mSessionCreds.empty()) - debug("SSauth", "session %p clearing %d shared credentials", + secdebug("SSauth", "session %p clearing %d shared credentials", this, int(mSessionCreds.size()))); for (CredentialSet::iterator it = mSessionCreds.begin(); it != mSessionCreds.end(); it++) (*it)->invalidate(); @@ -182,6 +183,20 @@ bool Session::clearResources() } +// +// Relay lockAllDatabases to all known sessions +// +void Session::lockAllDatabases(bool forSleep) +{ + StLock _(sessionMapLock); + for (SessionMap::const_iterator it = begin(); it != end(); it++) { + secdebug("SSdb", "locking all %d known databases %s in session %p", + int(it->second->databases().size()), forSleep ? " for sleep" : "", it->second); + Database::lockAllDatabases(it->second->databases(), forSleep); + } +} + + // // Process management // @@ -219,16 +234,17 @@ bool Session::removeAuthorization(AuthorizationToken *) // // Authorization operations // -OSStatus Session::authCreate(const RightSet &rights, - const AuthorizationEnvironment *environment, +OSStatus Session::authCreate(const AuthItemSet &rights, + const AuthItemSet &environment, AuthorizationFlags flags, - AuthorizationBlob &newHandle) + AuthorizationBlob &newHandle, + const security_token_t &securityToken) { // invoke the authorization computation engine CredentialSet resultCreds; // this will acquire mLock, so we delay acquiring it - auto_ptr auth(new AuthorizationToken(*this, resultCreds)); + auto_ptr auth(new AuthorizationToken(*this, resultCreds, securityToken)); // Make a copy of the mSessionCreds CredentialSet sessionCreds; @@ -237,8 +253,9 @@ OSStatus Session::authCreate(const RightSet &rights, sessionCreds = mSessionCreds; } + AuthItemSet outRights; OSStatus result = Server::authority().authorize(rights, environment, flags, - &sessionCreds, &resultCreds, NULL, *auth); + &sessionCreds, &resultCreds, outRights, *auth); newHandle = auth->handle(); // merge resulting creds into shared pool @@ -261,6 +278,8 @@ void Session::authFree(const AuthorizationBlob &authBlob, AuthorizationFlags fla { AuthorizationToken::Deleter deleter(authBlob); AuthorizationToken &auth = deleter; + Process &process = Server::connection().process; + process.checkAuthorization(&auth); if (flags & kAuthorizationFlagDestroyRights) { // explicitly invalidate all shared credentials and remove them from the session @@ -270,14 +289,14 @@ void Session::authFree(const AuthorizationBlob &authBlob, AuthorizationFlags fla } // now get rid of the authorization itself - if (Server::connection().process.removeAuthorization(&auth)) + if (process.removeAuthorization(&auth)) deleter.remove(); } OSStatus Session::authGetRights(const AuthorizationBlob &authBlob, - const RightSet &rights, const AuthorizationEnvironment *environment, + const AuthItemSet &rights, const AuthItemSet &environment, AuthorizationFlags flags, - MutableRightSet &grantedRights) + AuthItemSet &grantedRights) { CredentialSet resultCreds; AuthorizationToken &auth = authorization(authBlob); @@ -287,7 +306,7 @@ OSStatus Session::authGetRights(const AuthorizationBlob &authBlob, effective = auth.effectiveCreds(); } OSStatus result = Server::authority().authorize(rights, environment, flags, - &effective, &resultCreds, &grantedRights, auth); + &effective, &resultCreds, grantedRights, auth); // merge resulting creds into shared pool if ((flags & kAuthorizationFlagExtendRights) && !(flags & kAuthorizationFlagDestroyRights)) @@ -297,38 +316,33 @@ OSStatus Session::authGetRights(const AuthorizationBlob &authBlob, auth.mergeCredentials(resultCreds); } - IFDEBUG(debug("SSauth", "Authorization %p copyRights asked for %d got %d", - &authorization(authBlob), int(rights.size()), int(grantedRights.size()))); + secdebug("SSauth", "Authorization %p copyRights asked for %d got %d", + &authorization(authBlob), int(rights.size()), int(grantedRights.size())); return result; } OSStatus Session::authGetInfo(const AuthorizationBlob &authBlob, const char *tag, - AuthorizationItemSet *&contextInfo) + AuthItemSet &contextInfo) { - StLock _(mLock); AuthorizationToken &auth = authorization(authBlob); - debug("SSauth", "Authorization %p get-info", &auth); - if (tag) { // @@@ no tag support yet - return errAuthorizationInvalidTag; - } else { // return all tags - contextInfo = &auth.infoSet(); - return noErr; - } + secdebug("SSauth", "Authorization %p get-info", &auth); + contextInfo = auth.infoSet(tag); + return noErr; } OSStatus Session::authExternalize(const AuthorizationBlob &authBlob, AuthorizationExternalForm &extForm) { - StLock _(mLock); const AuthorizationToken &auth = authorization(authBlob); + StLock _(mLock); if (auth.mayExternalize(Server::connection().process)) { memset(&extForm, 0, sizeof(extForm)); AuthorizationExternalBlob &extBlob = reinterpret_cast(extForm); extBlob.blob = auth.handle(); extBlob.session = bootstrapPort(); - debug("SSauth", "Authorization %p externalized", &auth); + secdebug("SSauth", "Authorization %p externalized", &auth); return noErr; } else return errAuthorizationExternalizeNotAllowed; @@ -337,8 +351,6 @@ OSStatus Session::authExternalize(const AuthorizationBlob &authBlob, OSStatus Session::authInternalize(const AuthorizationExternalForm &extForm, AuthorizationBlob &authBlob) { - StLock _(mLock); - // interpret the external form const AuthorizationExternalBlob &extBlob = reinterpret_cast(extForm); @@ -348,10 +360,11 @@ OSStatus Session::authInternalize(const AuthorizationExternalForm &extForm, // check for permission and do it if (sourceAuth.mayInternalize(Server::connection().process, true)) { + StLock _(mLock); authBlob = extBlob.blob; Server::connection().process.addAuthorization(&sourceAuth); mAuthCount++; - debug("SSauth", "Authorization %p internalized", &sourceAuth); + secdebug("SSauth", "Authorization %p internalized", &sourceAuth); return noErr; } else return errAuthorizationInternalizeNotAllowed; @@ -367,17 +380,13 @@ void Session::setup(SessionCreationFlags flags, SessionAttributeBits attrs) { // check current process object - it may have been cached before the client's bootstrap switch Process *process = &Server::connection().process; -#if 0 - if (process->taskPort().bootstrap() != process->session.bootstrapPort()) - process = Server::active().resetConnection(); -#endif process->session.setupAttributes(attrs); } void Session::setupAttributes(SessionAttributeBits attrs) { - debug("SSsession", "%p setup attrs=0x%lx", this, attrs); + secdebug("SSsession", "%p setup attrs=0x%lx", this, attrs); if (attrs & ~settableAttributes) MacOSError::throwMe(errSessionInvalidAttributes); if (attribute(sessionWasInitialized)) @@ -386,13 +395,70 @@ void Session::setupAttributes(SessionAttributeBits attrs) } +OSStatus Session::authorizationdbGet(AuthorizationString inRightName, CFDictionaryRef *rightDict) +{ + string rightName(inRightName); + return Server::authority().getRule(rightName, rightDict); +} + + +OSStatus Session::authorizationdbSet(const AuthorizationBlob &authBlob, AuthorizationString inRightName, CFDictionaryRef rightDict) +{ + CredentialSet resultCreds; + AuthorizationToken &auth = authorization(authBlob); + CredentialSet effective; + + { + StLock _(mCredsLock); + effective = auth.effectiveCreds(); + } + + OSStatus result = Server::authority().setRule(inRightName, rightDict, &effective, &resultCreds, auth); + + { + StLock _(mCredsLock); + mergeCredentials(resultCreds); + auth.mergeCredentials(resultCreds); + } + + secdebug("SSauth", "Authorization %p authorizationdbSet %s (result=%ld)", + &authorization(authBlob), inRightName, result); + return result; +} + + +OSStatus Session::authorizationdbRemove(const AuthorizationBlob &authBlob, AuthorizationString inRightName) +{ + CredentialSet resultCreds; + AuthorizationToken &auth = authorization(authBlob); + CredentialSet effective; + + { + StLock _(mCredsLock); + effective = auth.effectiveCreds(); + } + + OSStatus result = Server::authority().removeRule(inRightName, &effective, &resultCreds, auth); + + { + StLock _(mCredsLock); + mergeCredentials(resultCreds); + auth.mergeCredentials(resultCreds); + } + + secdebug("SSauth", "Authorization %p authorizationdbRemove %s (result=%ld)", + &authorization(authBlob), inRightName, result); + return result; +} + + // // Merge a set of credentials into the shared-session credential pool // // must hold mCredsLock void Session::mergeCredentials(CredentialSet &creds) { - debug("SSsession", "%p merge creds @%p", this, &creds); + secdebug("SSsession", "%p merge creds @%p", this, &creds); for (CredentialSet::const_iterator it = creds.begin(); it != creds.end(); it++) if (((*it)->isShared() && (*it)->isValid())) { CredentialSet::iterator old = mSessionCreds.find(*it); @@ -413,5 +479,7 @@ void Session::mergeCredentials(CredentialSet &creds) // AuthorizationToken &Session::authorization(const AuthorizationBlob &blob) { - return AuthorizationToken::find(blob); + AuthorizationToken &auth = AuthorizationToken::find(blob); + Server::connection().process.checkAuthorization(&auth); + return auth; } diff --git a/SecurityServer/session.h b/SecurityServer/session.h index c7d080ae..3ceb2abb 100644 --- a/SecurityServer/session.h +++ b/SecurityServer/session.h @@ -40,6 +40,8 @@ using __gnu_cxx::hash_map; class Key; class Connection; +class Database; +class Database::CommonMap; // @@ -84,17 +86,21 @@ protected: public: const CredentialSet &authCredentials() const { return mSessionCreds; } - OSStatus authCreate(const RightSet &rights, const AuthorizationEnvironment *environment, - AuthorizationFlags flags, AuthorizationBlob &newHandle); + OSStatus authCreate(const AuthItemSet &rights, const AuthItemSet &environment, + AuthorizationFlags flags, AuthorizationBlob &newHandle, const security_token_t &securityToken); void authFree(const AuthorizationBlob &auth, AuthorizationFlags flags); OSStatus authGetRights(const AuthorizationBlob &auth, - const RightSet &requestedRights, const AuthorizationEnvironment *environment, - AuthorizationFlags flags, MutableRightSet &grantedRights); - OSStatus authGetInfo(const AuthorizationBlob &auth, const char *tag, AuthorizationItemSet *&contextInfo); + const AuthItemSet &requestedRights, const AuthItemSet &environment, + AuthorizationFlags flags, AuthItemSet &grantedRights); + OSStatus authGetInfo(const AuthorizationBlob &auth, const char *tag, AuthItemSet &contextInfo); OSStatus authExternalize(const AuthorizationBlob &auth, AuthorizationExternalForm &extForm); OSStatus authInternalize(const AuthorizationExternalForm &extForm, AuthorizationBlob &auth); + OSStatus authorizationdbGet(AuthorizationString inRightName, CFDictionaryRef *rightDict); + OSStatus authorizationdbSet(const AuthorizationBlob &authBlob, AuthorizationString inRightName, CFDictionaryRef rightDict); + OSStatus authorizationdbRemove(const AuthorizationBlob &authBlob, AuthorizationString inRightName); + private: struct AuthorizationExternalBlob { AuthorizationBlob blob; @@ -111,6 +117,8 @@ public: static Session &find(Port servPort); static Session &find(SecuritySessionId id); static void eliminate(Port servPort); + + static void lockAllDatabases(bool forSleep = false); protected: mutable Mutex mLock; // object lock @@ -129,11 +137,18 @@ private: typedef map SessionMap; static SessionMap sessionMap; static Mutex sessionMapLock; - + public: typedef SessionMap::iterator Iterator; static Iterator begin() { return sessionMap.begin(); } static Iterator end() { return sessionMap.end(); } + +private: + Database::CommonMap mCommons; // all database commons open in this session + +public: + Database::CommonMap &databases() + { return mCommons; } }; diff --git a/SecurityServer/ssblob.cpp b/SecurityServer/ssblob.cpp index 517b2122..705ffc48 100644 --- a/SecurityServer/ssblob.cpp +++ b/SecurityServer/ssblob.cpp @@ -32,16 +32,21 @@ namespace SecurityServer { void CommonBlob::initialize(uint32 version) { magic = magicNumber; - this->version = version; + this->blobVersion = version; } // // Verify the blob header for basic sane-ness. -// Version is checked (for equality) if non-zero. +// +bool CommonBlob::isValid() const +{ + return magic == magicNumber; +} + void CommonBlob::validate(CSSM_RETURN failureCode) const { - if (magic != magicNumber) + if (!isValid()) CssmError::throwMe(failureCode); } diff --git a/SecurityServer/ssblob.h b/SecurityServer/ssblob.h index 915b5e76..490746c0 100644 --- a/SecurityServer/ssblob.h +++ b/SecurityServer/ssblob.h @@ -17,7 +17,7 @@ // -// ssblob - objects to represent key and database blobs to SecurityServer +// ssblob - objects to represent persistent blobs used by SecurityServer // #ifndef _H_SSBLOB #define _H_SSBLOB @@ -28,20 +28,25 @@ #include #include #include +#include -namespace Security -{ +namespace Security { +namespace SecurityServer { using LowLevelMemoryUtilities::increment; -namespace SecurityServer -{ // -// A generic blob +// A generic blob. +// Note that Blob and its subclasses are meant to be Byte Order Corrected. +// Make sure all non-byte fields are Endian<> qualified. // class Blob { +public: + typedef Endian uint32e; + typedef Endian sint32e; + protected: template T *at(off_t offset) { return LowLevelMemoryUtilities::increment(this, offset); } @@ -55,8 +60,9 @@ protected: class CommonBlob : public Blob { public: // initial fixed fields for versioning - uint32 magic; // magic number - uint32 version; // version code + uint32e magic; // magic number + uint32e blobVersion; // version code + uint32 version() const { return blobVersion; } static const uint32 magicNumber = 0xfade0711; @@ -66,6 +72,7 @@ public: public: void initialize(uint32 version = currentVersion); + bool isValid() const; void validate(CSSM_RETURN failureCode) const; void *data() { return at(0); } @@ -99,11 +106,11 @@ public: public: // position separators between variable-length fields (see below) - uint32 startCryptoBlob; // end of public ACL; start of crypto blob - uint32 totalLength; // end of crypto blob; end of entire blob + uint32e startCryptoBlob; // end of public ACL; start of crypto blob + uint32e totalLength; // end of crypto blob; end of entire blob Signature randomSignature; // randomizing database signature - uint32 sequence; // database sequence number + uint32e sequence; // database sequence number DBParameters params; // database settable parameters uint8 salt[20]; // derivation salt @@ -135,17 +142,17 @@ public: // class KeyBlob : public CommonBlob { public: - uint32 startCryptoBlob; // end of public ACL; start of crypto blob - uint32 totalLength; // end of crypto blob; end of entire blob + uint32e startCryptoBlob; // end of public ACL; start of crypto blob + uint32e totalLength; // end of crypto blob; end of entire blob uint8 iv[8]; // encryption iv CssmKey::Header header; // key header as-is struct WrappedFields { - CSSM_KEYBLOB_TYPE blobType; - CSSM_KEYBLOB_FORMAT blobFormat; - CSSM_ALGORITHMS wrapAlgorithm; - CSSM_ENCRYPT_MODE wrapMode; + Endian blobType; + Endian blobFormat; + Endian wrapAlgorithm; + Endian wrapMode; } wrappedHeader; uint8 blobSignature[20]; // HMAC/SHA1 of entire blob except itself @@ -164,7 +171,10 @@ public: static const uint32 managedAttributes = CSSM_KEYATTR_ALWAYS_SENSITIVE | CSSM_KEYATTR_NEVER_EXTRACTABLE | - CSSM_KEYATTR_PERMANENT; + CSSM_KEYATTR_PERMANENT | + CSSM_KEYATTR_EXTRACTABLE; + static const uint32 forcedAttributes = + CSSM_KEYATTR_EXTRACTABLE; public: KeyBlob *copy(CssmAllocator &alloc) const @@ -176,8 +186,18 @@ public: }; -} // end namespace SecurityServer +// +// An auto-unlock record (database identity plus raw unlock key) +// +class UnlockBlob : public CommonBlob { +public: + typedef uint8 MasterKey[24]; + MasterKey masterKey; // raw bits (triple-DES) - make your own CssmKey + DbBlob::Signature signature; // signature is index +}; + +} // end namespace SecurityServer } // end namespace Security diff --git a/SecurityServer/ssclient.cpp b/SecurityServer/ssclient.cpp index 413cbe85..26cf46a3 100644 --- a/SecurityServer/ssclient.cpp +++ b/SecurityServer/ssclient.cpp @@ -38,6 +38,7 @@ namespace SecurityServer { UnixPlusPlus::StaticForkMonitor ClientSession::mHasForked; ModuleNexus ClientSession::mGlobal; bool ClientSession::mSetupSession; +const char *ClientSession::mContactName; // @@ -65,7 +66,7 @@ void ClientSession::activate() // (that has not exec'ed), our apparent connection to SecurityServer // is just a mirage, and we better reset it. if (mHasForked()) { - debug("SSclnt", "process has forked (now pid=%d) - resetting connection object", getpid()); + secdebug("SSclnt", "process has forked (now pid=%d) - resetting connection object", getpid()); mGlobal.reset(); } @@ -74,14 +75,32 @@ void ClientSession::activate() Thread &thread = global.thread(); if (!thread) { // first time for this thread - use abbreviated registration - IPCN(ucsp_client_setup(UCSP_ARGS, mach_task_self(), "")); + IPCN(ucsp_client_setupThread(UCSP_ARGS, mach_task_self())); thread.registered = true; global.serverPort.requestNotify(thread.replyPort, MACH_NOTIFY_DEAD_NAME, true); - debug("SSclnt", "Thread registered with SecurityServer"); + secdebug("SSclnt", "Thread registered with %s", mContactName); } } +// +// The contactName method allows the caller to explicitly override the bootstrap +// name under which SecurityServer is located. Use this only with great caution, +// and probably only for debugging. +// Note that no explicit locking is done here. It is the caller's responsibility +// to make sure this is called from thread-safe context before the real dance begins. +// +void ClientSession::contactName(const char *name) +{ + mContactName = name; +} + +const char *ClientSession::contactName() const +{ + return mContactName; +} + + // // Construct the process-global state object. // The ModuleNexus construction magic will ensure that this happens uniquely @@ -92,36 +111,42 @@ void ClientSession::activate() ClientSession::Global::Global() { // find server port - Bootstrap myBootstrap; - serverPort = myBootstrap.lookup("SecurityServer"); - debug("SSclnt", "contacting SecurityServer at port %d", serverPort.port()); + IFDEBUG(if (!mContactName) mContactName = getenv(SECURITYSERVER_BOOTSTRAP_ENV)); + if (!mContactName) + mContactName = SECURITYSERVER_BOOTSTRAP_NAME; + secdebug("SSclnt", "Locating %s", mContactName); + serverPort = Bootstrap().lookup(mContactName); + secdebug("SSclnt", "contacting %s at port %d", mContactName, serverPort.port()); // send identification/setup message string extForm; try { myself = OSXCode::main(); extForm = myself->encode(); - debug("SSclnt", "my OSXCode extForm=%s", extForm.c_str()); + secdebug("SSclnt", "my OSXCode extForm=%s", extForm.c_str()); } catch (...) { // leave extForm empty - debug("SSclnt", "failed to obtain my own OSXCode"); + secdebug("SSclnt", "failed to obtain my own OSXCode"); } + + ClientSetupInfo info = { SSPROTOVERSION }; + // cannot use UCSP_ARGS here because it uses mGlobal() -> deadlock Thread &thread = this->thread(); if (mSetupSession) { - debug("SSclnt", "sending session setup request"); + secdebug("SSclnt", "sending session setup request"); mSetupSession = false; IPCN(ucsp_client_setupNew(serverPort, thread.replyPort, &rcode, - mach_task_self(), extForm.c_str(), &serverPort.port())); - debug("SSclnt", "new session server port is %d", serverPort.port()); - } else { + mach_task_self(), info, extForm.c_str(), &serverPort.port())); + secdebug("SSclnt", "new session server port is %d", serverPort.port()); + } else { IPCN(ucsp_client_setup(serverPort, thread.replyPort, &rcode, - mach_task_self(), extForm.c_str())); + mach_task_self(), info, extForm.c_str())); } thread.registered = true; // as a side-effect of setup call above serverPort.requestNotify(thread.replyPort, MACH_NOTIFY_DEAD_NAME, true); - debug("SSclnt", "contact with SecurityServer established"); + secdebug("SSclnt", "contact with %s established", mContactName); } @@ -131,10 +156,9 @@ ClientSession::Global::Global() void ClientSession::terminate() { // currently defunct - debug("SSclnt", "ClientSession::terminate() call ignored"); + secdebug("SSclnt", "ClientSession::terminate() call ignored"); } } // end namespace SecurityServer - } // end namespace Security diff --git a/SecurityServer/ssclient.h b/SecurityServer/ssclient.h index 95b937d2..21ece701 100644 --- a/SecurityServer/ssclient.h +++ b/SecurityServer/ssclient.h @@ -38,7 +38,8 @@ #include #include #include - +#include +#include namespace Security { namespace SecurityServer { @@ -47,6 +48,14 @@ using MachPlusPlus::Port; using MachPlusPlus::ReceivePort; +// +// The default Mach bootstrap registration name for SecurityServer, +// and the environment variable to override it +// +#define SECURITYSERVER_BOOTSTRAP_NAME "com.apple.SecurityServer" +#define SECURITYSERVER_BOOTSTRAP_ENV "SECURITYSERVER" + + // // Common data types // @@ -74,6 +83,11 @@ struct AuthorizationBlob { } }; +struct ClientSetupInfo { + uint32 version; +}; +#define SSPROTOVERSION 4 + enum AclKind { dbAcl, keyAcl, loginAcl }; @@ -101,21 +115,16 @@ public: public: typedef CSSM_DB_ACCESS_TYPE DBAccessType; + typedef Security::Context Context; - typedef uint32 NotifyEvent; - typedef uint32 NotifyEvents; - enum { - allEvents = uint32(-1) - }; - - typedef uint32 NotifyDomain; - enum { - databaseNotifications = 1 - }; - public: void activate(); void terminate(); + +public: + // use this only if you know what you're doing... + void contactName(const char *name); + const char *contactName() const; public: // database sessions @@ -130,8 +139,12 @@ public: void authenticateDb(DbHandle db, DBAccessType type, const AccessCredentials *cred); void setDbParameters(DbHandle db, const DBParameters ¶ms); void getDbParameters(DbHandle db, DBParameters ¶ms); + void getDbSuggestedIndex(DbHandle db, CssmData &index, CssmAllocator &alloc); + void getDbSuggestedIndex(DbHandle db, CssmData &index) + { return getDbSuggestedIndex(db, index, returnAllocator); } void changePassphrase(DbHandle db, const AccessCredentials *cred); void lock(DbHandle db); + void lockAll(bool forSleep); void unlock(DbHandle db); void unlock(DbHandle db, const CssmData &passPhrase); bool isLocked(DbHandle db); @@ -144,25 +157,30 @@ public: void releaseKey(KeyHandle key); CssmKeySize queryKeySizeInBits(KeyHandle key); - uint32 getOutputSize(const Context &context, KeyHandle key, + uint32 getOutputSize(const Security::Context &context, KeyHandle key, uint32 inputSize, bool encrypt = true); + + void getKeyDigest(KeyHandle key, CssmData &digest, CssmAllocator &alloc); + void getKeyDigest(KeyHandle key, CssmData &digest) + { return getKeyDigest(key, digest, returnAllocator); } + public: // key wrapping and unwrapping - void wrapKey(const Context &context, KeyHandle key, KeyHandle keyToBeWrapped, + void wrapKey(const Security::Context &context, KeyHandle key, KeyHandle keyToBeWrapped, const AccessCredentials *cred, const CssmData *descriptiveData, CssmWrappedKey &wrappedKey, CssmAllocator &alloc); - void wrapKey(const Context &context, KeyHandle key, KeyHandle keyToBeWrapped, + void wrapKey(const Security::Context &context, KeyHandle key, KeyHandle keyToBeWrapped, const AccessCredentials *cred, const CssmData *descriptiveData, CssmWrappedKey &wrappedKey) { return wrapKey(context, key, keyToBeWrapped, cred, descriptiveData, wrappedKey, returnAllocator); } - void unwrapKey(DbHandle db, const Context &context, KeyHandle key, KeyHandle publicKey, + void unwrapKey(DbHandle db, const Security::Context &context, KeyHandle key, KeyHandle publicKey, const CssmWrappedKey &wrappedKey, uint32 keyUsage, uint32 keyAttr, const AccessCredentials *cred, const AclEntryInput *owner, CssmData &data, KeyHandle &newKey, CssmKey::Header &newKeyHeader, CssmAllocator &alloc); - void unwrapKey(DbHandle db, const Context &context, KeyHandle key, KeyHandle publicKey, + void unwrapKey(DbHandle db, const Security::Context &context, KeyHandle key, KeyHandle publicKey, const CssmWrappedKey &wrappedKey, uint32 keyUsage, uint32 keyAttr, const AccessCredentials *cred, const AclEntryInput *owner, CssmData &data, KeyHandle &newKey, CssmKey::Header &newKeyHeader) @@ -170,20 +188,20 @@ public: cred, owner, data, newKey, newKeyHeader, returnAllocator); } // key generation and derivation - void generateKey(DbHandle db, const Context &context, uint32 keyUsage, uint32 keyAttr, + void generateKey(DbHandle db, const Security::Context &context, uint32 keyUsage, uint32 keyAttr, const AccessCredentials *cred, const AclEntryInput *owner, KeyHandle &newKey, CssmKey::Header &newHeader); - void generateKey(DbHandle db, const Context &context, + void generateKey(DbHandle db, const Security::Context &context, uint32 pubKeyUsage, uint32 pubKeyAttr, uint32 privKeyUsage, uint32 privKeyAttr, const AccessCredentials *cred, const AclEntryInput *owner, KeyHandle &pubKey, CssmKey::Header &pubHeader, KeyHandle &privKey, CssmKey::Header &privHeader); - void deriveKey(DbHandle db, const Context &context, KeyHandle baseKey, + void deriveKey(DbHandle db, const Security::Context &context, KeyHandle baseKey, uint32 keyUsage, uint32 keyAttr, CssmData ¶m, const AccessCredentials *cred, const AclEntryInput *owner, KeyHandle &newKey, CssmKey::Header &newHeader, CssmAllocator &alloc); - void deriveKey(DbHandle db, const Context &context, KeyHandle baseKey, + void deriveKey(DbHandle db, const Security::Context &context, KeyHandle baseKey, uint32 keyUsage, uint32 keyAttr, CssmData ¶m, const AccessCredentials *cred, const AclEntryInput *owner, KeyHandle &newKey, CssmKey::Header &newHeader) @@ -193,33 +211,33 @@ public: void generateRandom(CssmData &data); // encrypt/decrypt - void encrypt(const Context &context, KeyHandle key, + void encrypt(const Security::Context &context, KeyHandle key, const CssmData &in, CssmData &out, CssmAllocator &alloc); - void encrypt(const Context &context, KeyHandle key, const CssmData &in, CssmData &out) + void encrypt(const Security::Context &context, KeyHandle key, const CssmData &in, CssmData &out) { return encrypt(context, key, in, out, returnAllocator); } - void decrypt(const Context &context, KeyHandle key, + void decrypt(const Security::Context &context, KeyHandle key, const CssmData &in, CssmData &out, CssmAllocator &alloc); - void decrypt(const Context &context, KeyHandle key, const CssmData &in, CssmData &out) + void decrypt(const Security::Context &context, KeyHandle key, const CssmData &in, CssmData &out) { return decrypt(context, key, in, out, returnAllocator); } // signatures - void generateSignature(const Context &context, KeyHandle key, + void generateSignature(const Security::Context &context, KeyHandle key, const CssmData &data, CssmData &signature, CssmAllocator &alloc, CSSM_ALGORITHMS signOnlyAlgorithm = CSSM_ALGID_NONE); - void generateSignature(const Context &context, KeyHandle key, + void generateSignature(const Security::Context &context, KeyHandle key, const CssmData &data, CssmData &signature, CSSM_ALGORITHMS signOnlyAlgorithm = CSSM_ALGID_NONE) { return generateSignature(context, key, data, signature, returnAllocator, signOnlyAlgorithm); } - void verifySignature(const Context &context, KeyHandle key, + void verifySignature(const Security::Context &context, KeyHandle key, const CssmData &data, const CssmData &signature, CSSM_ALGORITHMS verifyOnlyAlgorithm = CSSM_ALGID_NONE); // MACs - void generateMac(const Context &context, KeyHandle key, + void generateMac(const Security::Context &context, KeyHandle key, const CssmData &data, CssmData &mac, CssmAllocator &alloc); - void generateMac(const Context &context, KeyHandle key, + void generateMac(const Security::Context &context, KeyHandle key, const CssmData &data, CssmData &mac) { return generateMac(context, key, data, mac, returnAllocator); } - void verifyMac(const Context &context, KeyHandle key, + void verifyMac(const Security::Context &context, KeyHandle key, const CssmData &data, const CssmData &mac); // key ACL management @@ -247,6 +265,18 @@ public: { return getDbOwner(db, owner, returnAllocator); } void changeDbOwner(DbHandle db, const AccessCredentials &cred, const AclOwnerPrototype &edit); + + // database key manipulations + void extractMasterKey(DbHandle db, const Context &context, DbHandle sourceDb, + uint32 keyUsage, uint32 keyAttr, + const AccessCredentials *cred, const AclEntryInput *owner, + KeyHandle &newKey, CssmKey::Header &newHeader, CssmAllocator &alloc); + void extractMasterKey(DbHandle db, const Context &context, DbHandle sourceDb, + uint32 keyUsage, uint32 keyAttr, + const AccessCredentials *cred, const AclEntryInput *owner, + KeyHandle &newKey, CssmKey::Header &newHeader) + { return extractMasterKey(db, context, sourceDb, keyUsage, keyAttr, cred, owner, + newKey, newHeader, returnAllocator); } public: // Authorization API support @@ -267,14 +297,27 @@ public: public: // Notification core support - void requestNotification(Port receiver, NotifyDomain domain, NotifyEvents events); + void requestNotification(Port receiver, Listener::Domain domain, Listener::EventMask events); void stopNotification(Port receiver); - void postNotification(NotifyDomain domain, NotifyEvent event, const CssmData &data); + void postNotification(Listener::Domain domain, Listener::Event event, const CssmData &data); - typedef OSStatus ConsumeNotification(NotifyDomain domain, NotifyEvent event, + typedef OSStatus ConsumeNotification(Listener::Domain domain, Listener::Event event, const void *data, size_t dataLength, void *context); OSStatus dispatchNotification(const mach_msg_header_t *message, - ConsumeNotification *consumer, void *context); + ConsumeNotification *consumer, void *context) throw(); + +public: + // AuthorizationDB API + void authorizationdbGet(const AuthorizationString rightname, CssmData &rightDefinition, CssmAllocator &alloc); + void authorizationdbSet(const AuthorizationBlob &auth, const AuthorizationString rightname, uint32_t rightdefinitionLength, const void *rightdefinition); + void authorizationdbRemove(const AuthorizationBlob &auth, const AuthorizationString rightname); + +public: + // miscellaneous administrative calls + void addCodeEquivalence(const CssmData &oldCode, const CssmData &newCode, + const char *name, bool forSystem = false); + void removeCodeEquivalence(const CssmData &code, const char *name, bool forSystem = false); + void setAlternateSystemRoot(const char *path); private: void getAcl(AclKind kind, KeyHandle key, const char *tag, @@ -305,6 +348,7 @@ private: static ModuleNexus mGlobal; static bool mSetupSession; + static const char *mContactName; }; diff --git a/SecurityServer/sstransit.cpp b/SecurityServer/sstransit.cpp index f7dec076..c680b4df 100644 --- a/SecurityServer/sstransit.cpp +++ b/SecurityServer/sstransit.cpp @@ -23,9 +23,11 @@ // MIG IPC client calls, plus their supporting machinery. // #include "sstransit.h" +#include +#include +#include -namespace Security -{ +namespace Security { using MachPlusPlus::check; using MachPlusPlus::VMGuard; @@ -65,7 +67,7 @@ CssmList chunkCopy(CssmList &list, CssmAllocator &alloc) // In addition to collecting the context into a contiguous blob for transmission, // we also evaluate CssmCryptoData callbacks at this time. // -SendContext::SendContext(const Context &ctx) : context(ctx) +SendContext::SendContext(const Security::Context &ctx) : context(ctx) { CssmCryptoData cryptoDataValue; // holding area for CssmCryptoData element IFDEBUG(uint32 cryptoDataUsed = 0); @@ -102,6 +104,67 @@ SendContext::SendContext(const Context &ctx) : context(ctx) } +// +// Copy an AccessCredentials for shipment. +// In addition, scan the samples for "special" database locking samples +// and translate certain items for safe shipment. Note that this overwrites +// part of the CssmList value (CSPHandle -> SS/KeyHandle), but we do it on +// the COPY, so that's okay. +// +DatabaseAccessCredentials::DatabaseAccessCredentials(const AccessCredentials *creds, CssmAllocator &alloc) + : Copier(creds, alloc) +{ + if (creds) { + for (uint32 n = 0; n < value()->samples().length(); n++) { + TypedList sample = value()->samples()[n]; + sample.checkProper(); + switch (sample.type()) { + case CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK: + case CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK: + sample.snip(); // skip sample type + sample.checkProper(); + if (sample.type() == CSSM_WORDID_SYMMETRIC_KEY) { + secdebug("SSclient", "key sample encountered"); + // proper form is sample[1] = DATA:CSPHandle, sample[2] = DATA:CSSM_KEY + if (sample.length() != 3 + || sample[1].type() != CSSM_LIST_ELEMENT_DATUM + || sample[2].type() != CSSM_LIST_ELEMENT_DATUM) + CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); + mapKeySample( + *sample[1].data().interpretedAs(CSSM_ERRCODE_INVALID_SAMPLE_VALUE), + *sample[2].data().interpretedAs(CSSM_ERRCODE_INVALID_SAMPLE_VALUE)); + } + break; + default: + break; + } + } + } +} + +void DatabaseAccessCredentials::mapKeySample(CSSM_CSP_HANDLE &cspHandle, CssmKey &key) +{ + // if the key belongs to the AppleCSPDL, look it up and write the SS KeyHandle + // into the CSPHandle element for transmission + if (key.header().cspGuid() == gGuidAppleCSPDL) { + // @@@ can't use CssmClient (it makes its own attachments) + CSSM_CC_HANDLE ctx; + if (CSSM_RETURN err = CSSM_CSP_CreatePassThroughContext(cspHandle, &key, &ctx)) + CssmError::throwMe(err); + KeyHandle ssKey; + CSSM_RETURN passthroughError = + CSSM_CSP_PassThrough(ctx, CSSM_APPLESCPDL_CSP_GET_KEYHANDLE, NULL, (void **)&ssKey); + CSSM_DeleteContext(ctx); // ignore error + if (passthroughError) + CssmError::throwMe(passthroughError); + // we happen to know that they're both uint32 values + assert(sizeof(CSSM_CSP_HANDLE) >= sizeof(KeyHandle)); + cspHandle = ssKey; + secdebug("SSclient", "key sample mapped to key 0x%lx", ssKey); + } +} + + namespace SecurityServer { @@ -112,7 +175,7 @@ DbHandle ClientSession::createDb(const DLDbIdentifier &dbId, const AccessCredentials *cred, const AclEntryInput *owner, const DBParameters ¶ms) { - Copier creds(cred, internalAllocator); + DatabaseAccessCredentials creds(cred, internalAllocator); Copier proto(&owner->proto(), internalAllocator); DataWalkers::DLDbFlatIdentifier ident(dbId); Copier id(&ident, internalAllocator); @@ -124,7 +187,7 @@ DbHandle ClientSession::createDb(const DLDbIdentifier &dbId, DbHandle ClientSession::decodeDb(const DLDbIdentifier &dbId, const AccessCredentials *cred, const CssmData &blob) { - Copier creds(cred, internalAllocator); + DatabaseAccessCredentials creds(cred, internalAllocator); DataWalkers::DLDbFlatIdentifier ident(dbId); Copier id(&ident, internalAllocator); DbHandle db; @@ -143,10 +206,16 @@ void ClientSession::releaseDb(DbHandle db) IPC(ucsp_client_releaseDb(UCSP_ARGS, db)); } +void ClientSession::getDbSuggestedIndex(DbHandle db, CssmData &index, CssmAllocator &alloc) +{ + DataOutput outBlob(index, alloc); + IPC(ucsp_client_getDbIndex(UCSP_ARGS, db, DATA(outBlob))); +} + void ClientSession::authenticateDb(DbHandle db, DBAccessType type, const AccessCredentials *cred) { - Copier creds(cred, internalAllocator); + DatabaseAccessCredentials creds(cred, internalAllocator); IPC(ucsp_client_authenticateDb(UCSP_ARGS, db, COPY(creds))); } @@ -172,6 +241,11 @@ void ClientSession::lock(DbHandle db) IPC(ucsp_client_lockDb(UCSP_ARGS, db)); } +void ClientSession::lockAll (bool forSleep) +{ + IPC(ucsp_client_lockAll (UCSP_ARGS, forSleep)); +} + void ClientSession::unlock(DbHandle db) { IPC(ucsp_client_unlockDb(UCSP_ARGS, db)); @@ -310,6 +384,8 @@ void ClientSession::encrypt(const Context &context, KeyHandle key, void ClientSession::decrypt(const Context &context, KeyHandle key, const CssmData &cipher, CssmData &clear, CssmAllocator &alloc) { + Debug::trace (kSecTraceUCSPServerDecryptBegin); + SendContext ctx(context); DataOutput clearOut(clear, alloc); IPC(ucsp_client_decrypt(UCSP_ARGS, CONTEXT(ctx), key, DATA(cipher), DATA(clearOut))); @@ -369,7 +445,8 @@ void ClientSession::deriveKey(DbHandle db, const Context &context, KeyHandle bas switch (context.algorithm()) { case CSSM_ALGID_PKCS5_PBKDF2: { typedef CSSM_PKCS5_PBKDF2_PARAMS Params; - Copier params(param.interpretedAs (sizeof(Params)), internalAllocator); + Copier params(param.interpretedAs(CSSM_ERRCODE_INVALID_INPUT_POINTER), + internalAllocator); IPC(ucsp_client_deriveKey(UCSP_ARGS, db, CONTEXT(ctx), baseKey, COPY(creds), COPY(proto), COPY(params), DATA(paramOutput), keyUsage, keyAttr, &newKey, &newHeader)); @@ -385,6 +462,16 @@ void ClientSession::deriveKey(DbHandle db, const Context &context, KeyHandle bas } +// +// Digest generation +// +void ClientSession::getKeyDigest(KeyHandle key, CssmData &digest, CssmAllocator &allocator) +{ + DataOutput dig(digest, allocator); + IPC(ucsp_client_getKeyDigest(UCSP_ARGS, key, DATA(dig))); +} + + // // Key wrapping and unwrapping // @@ -510,6 +597,23 @@ void ClientSession::changeDbOwner(DbHandle db, const AccessCredentials &cred, { changeOwner(dbAcl, db, cred, edit); } +// +// Database key management +// +void ClientSession::extractMasterKey(DbHandle db, const Context &context, DbHandle sourceDb, + uint32 keyUsage, uint32 keyAttr, + const AccessCredentials *cred, const AclEntryInput *owner, + KeyHandle &newKey, CssmKey::Header &newHeader, CssmAllocator &alloc) +{ + SendContext ctx(context); + Copier creds(cred, internalAllocator); + Copier proto(&owner->proto(), internalAllocator); + IPC(ucsp_client_extractMasterKey(UCSP_ARGS, db, CONTEXT(ctx), sourceDb, + COPY(creds), COPY(proto), + keyUsage, keyAttr, &newKey, &newHeader)); +} + + // // Authorization subsystem entry // @@ -577,25 +681,44 @@ void ClientSession::authInternalize(const AuthorizationExternalForm &extForm, // -// Session management API +// Get session information (security session status) // void ClientSession::getSessionInfo(SecuritySessionId &sessionId, SessionAttributeBits &attrs) { IPC(ucsp_client_getSessionInfo(UCSP_ARGS, &sessionId, &attrs)); } + +// +// Create a new session. +// +// Caveat: This discards all SecurityServer held state for this process, including +// authorizations, database handles, etc. If you are multi-threaded at this point, +// and other threads have talked to SecurityServer, they will leak a few resources +// (mach ports and the like). Nothing horrendous, unless you create masses of sessions +// that way (which we wouldn't exactly recommend for other reasons). +// +// Hacker's note: This engages in an interesting dance with SecurityServer's state tracking. +// If you don't know the choreography, don't change things here until talking to an expert. +// +// Yes, if the client had multiple threads each of which has talked to SecurityServer, +// the reply ports for all but the calling thread will leak. If that ever turns out to +// be a real problem, we can fix it by keeping a (locked) set of client replyPorts to ditch. +// Hardly worth it, though. This is a rare call. +// void ClientSession::setupSession(SessionCreationFlags flags, SessionAttributeBits attrs) { + mGlobal().thread().replyPort.destroy(); // kill this thread's reply port + mGlobal.reset(); // kill existing cache (leak all other threads) mSetupSession = true; // global flag to Global constructor - mGlobal.reset(); // kill existing cache, all threads - IPC(ucsp_client_setupSession(UCSP_ARGS, flags, attrs)); + IPC(ucsp_client_setupSession(UCSP_ARGS, flags, attrs)); // reinitialize and call } // // Notification subsystem // -void ClientSession::requestNotification(Port receiver, NotifyDomain domain, NotifyEvents events) +void ClientSession::requestNotification(Port receiver, Listener::Domain domain, Listener::EventMask events) { IPC(ucsp_client_requestNotification(UCSP_ARGS, receiver, domain, events)); } @@ -605,13 +728,13 @@ void ClientSession::stopNotification(Port port) IPC(ucsp_client_stopNotification(UCSP_ARGS, port.port())); } -void ClientSession::postNotification(NotifyDomain domain, NotifyEvent event, const CssmData &data) +void ClientSession::postNotification(Listener::Domain domain, Listener::Event event, const CssmData &data) { IPC(ucsp_client_postNotification(UCSP_ARGS, domain, event, DATA(data))); } OSStatus ClientSession::dispatchNotification(const mach_msg_header_t *message, - ConsumeNotification *consumer, void *context) + ConsumeNotification *consumer, void *context) throw() { struct Message { mach_msg_header_t Head; @@ -625,9 +748,16 @@ OSStatus ClientSession::dispatchNotification(const mach_msg_header_t *message, mach_msg_type_number_t dataCnt; uint32 sender; } *msg = (Message *)message; - - OSStatus status = consumer(msg->domain, msg->event, msg->data.address, msg->dataCnt, context); - + + OSStatus status; + try + { + status = consumer(msg->domain, msg->event, msg->data.address, msg->dataCnt, context); + } + catch (const CssmCommonError &err) { status = err.osStatus(); } + catch (const std::bad_alloc &) { status = memFullErr; } + catch (...) { status = internalComponentErr; } + mig_deallocate((vm_offset_t) msg->data.address, msg->dataCnt); msg->data.address = (vm_offset_t) 0; msg->data.size = (mach_msg_size_t) 0; @@ -636,5 +766,47 @@ OSStatus ClientSession::dispatchNotification(const mach_msg_header_t *message, } +// +// authorizationdbGet/Set/Remove +// +void ClientSession::authorizationdbGet(const AuthorizationString rightname, CssmData &rightDefinition, CssmAllocator &alloc) +{ + DataOutput definition(rightDefinition, alloc); + IPC(ucsp_client_authorizationdbGet(UCSP_ARGS, rightname, DATA(definition))); +} + +void ClientSession::authorizationdbSet(const AuthorizationBlob &auth, const AuthorizationString rightname, uint32_t rightDefinitionLength, const void *rightDefinition) +{ + // @@@ DATA_IN in transition.cpp is not const void * + IPC(ucsp_client_authorizationdbSet(UCSP_ARGS, auth, rightname, const_cast(rightDefinition), rightDefinitionLength)); +} + +void ClientSession::authorizationdbRemove(const AuthorizationBlob &auth, const AuthorizationString rightname) +{ + IPC(ucsp_client_authorizationdbRemove(UCSP_ARGS, auth, rightname)); +} + + +// +// Miscellaneous administrative calls +// +void ClientSession::addCodeEquivalence(const CssmData &oldHash, const CssmData &newHash, + const char *name, bool forSystem /* = false */) +{ + IPC(ucsp_client_addCodeEquivalence(UCSP_ARGS, DATA(oldHash), DATA(newHash), + name, forSystem)); +} + +void ClientSession::removeCodeEquivalence(const CssmData &hash, const char *name, bool forSystem /* = false */) +{ + IPC(ucsp_client_removeCodeEquivalence(UCSP_ARGS, DATA(hash), name, forSystem)); +} + +void ClientSession::setAlternateSystemRoot(const char *path) +{ + IPC(ucsp_client_setAlternateSystemRoot(UCSP_ARGS, path)); +} + + } // end namespace SecurityServer } // end namespace Security diff --git a/SecurityServer/sstransit.h b/SecurityServer/sstransit.h index f4eb4a59..b5120193 100644 --- a/SecurityServer/sstransit.h +++ b/SecurityServer/sstransit.h @@ -79,6 +79,19 @@ private: }; +// +// Bundle up an AccessCredentials meant for a database, parsing it for +// "special" samples that need extra evidence to be passed along. +// +class DatabaseAccessCredentials : public Copier { +public: + DatabaseAccessCredentials(const AccessCredentials *creds, CssmAllocator &alloc); + +private: + void mapKeySample(CSSM_CSP_HANDLE &cspHandle, CssmKey &key); +}; + + // // Bundle up a Context for IPC transmission // diff --git a/SecurityServer/systemkeychain.cpp b/SecurityServer/systemkeychain.cpp new file mode 100644 index 00000000..37b1255a --- /dev/null +++ b/SecurityServer/systemkeychain.cpp @@ -0,0 +1,373 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// systemkeychain command - set up and manipulate system-unlocked keychains +// +#include +#include +#include +#include +#include +#include "ssblob.h" +#include + +using namespace SecurityServer; +using namespace CssmClient; +using namespace UnixPlusPlus; + + +static const char *unlockConfig = kSystemUnlockFile; + + +// +// Values set from command-line options +// +const char *systemKCName = kSystemKeychainDir kSystemKeychainName; +bool verbose = false; +bool createIfNeeded = false; +bool force = false; + + +// +// CSSM record attribute names +// +static const CSSM_DB_ATTRIBUTE_INFO dlInfoLabel = { + CSSM_DB_ATTRIBUTE_NAME_AS_STRING, + {"Label"}, + CSSM_DB_ATTRIBUTE_FORMAT_BLOB +}; + + + +// +// Local functions +void usage(); +void createSystemKeychain(const char *kcName, const char *passphrase); +void extract(const char *srcName, const char *dstName); +void test(const char *kcName); + +void notice(const char *fmt, ...); +void fail(const char *fmt, ...); + +void masterKeyIndex(Db &db, CssmOwnedData &index); +void labelForMasterKey(Db &db, CssmOwnedData &data); +void deleteKey(Db &db, const CssmData &label); // delete key with this label + + +// +// Main program: parse options and dispatch, catching exceptions +// +int main (int argc, char * argv[]) +{ + enum Action { + showUsage, + setupSystem, + copyKey, + testUnlock + } action = showUsage; + + extern int optind; + extern char *optarg; + int arg; + while ((arg = getopt(argc, argv, "cCfk:stv")) != -1) { + switch (arg) { + case 'c': + createIfNeeded = true; + break; + case 'C': + action = setupSystem; + break; + case 'f': + force = true; + break; + case 'k': + systemKCName = optarg; + break; + case 's': + action = copyKey; + break; + case 't': + action = testUnlock; + break; + case 'v': + verbose = true; + break; + default: + usage(); + } + } + try { + switch (action) { + case setupSystem: + if (optind < argc - 1) + usage(); + createSystemKeychain(systemKCName, argv[optind]); + break; + case copyKey: + if (optind == argc) + usage(); + do { + extract(argv[optind], systemKCName); + } while (argv[++optind]); + break; + case testUnlock: + test(systemKCName); + break; + default: + usage(); + } + exit(0); + } catch (const CssmError &error) { + cssmPerror(systemKCName, error.cssmError()); + exit(1); + } catch (const UnixError &error) { + fail("%s: %s", systemKCName, strerror(error.error)); + exit(1); + } catch (...) { + fail("Unexpected exception"); + exit(1); + } +} + + +// +// Partial usage message (some features aren't worth emphasizing...) +// +void usage() +{ + fprintf(stderr, "Usage: systemkeychain -S [passphrase] # (re)create system root keychain" + "\n\tsystemkeychain [-k destination-keychain] -s source-keychain ..." + "\n"); + exit(2); +} + + +// +// Create a keychain and set it up as the system-root secret +// +void createSystemKeychain(const char *kcName, const char *passphrase) +{ + // for the default path only, make sure the directory exists + if (!strcmp(kcName, kSystemKeychainDir kSystemKeychainName)) + ::mkdir(kSystemKeychainDir, 0755); + + CSP csp(gGuidAppleCSPDL); + DL dl(gGuidAppleCSPDL); + + // create the keychain, using appropriate credentials + Db db(dl, kcName); + CssmAllocator &alloc = db.allocator(); + AutoCredentials cred(alloc); // will leak, but we're quitting soon :-) + CSSM_CSP_HANDLE cspHandle = csp->handle(); + Key masterKey; + if (passphrase) { + // use this passphrase + cred += TypedList(alloc, CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK, + new(alloc) ListElement(CSSM_SAMPLE_TYPE_PASSWORD), + new(alloc) ListElement(StringData(passphrase))); + db->accessCredentials(&cred); + } else { + // generate a random key + notice("warning: this keychain cannot be unlocked with any passphrase"); + GenerateKey generate(csp, CSSM_ALGID_3DES_3KEY_EDE, 64 * 3); + masterKey = generate(KeySpec(CSSM_KEYUSE_ANY, + CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_EXTRACTABLE)); + cred += TypedList(alloc, CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK, + new(alloc) ListElement(CSSM_WORDID_SYMMETRIC_KEY), + new(alloc) ListElement(CssmData::wrap(cspHandle)), + new(alloc) ListElement(CssmData::wrap(static_cast(masterKey)))); + db->accessCredentials(&cred); + } + db->dbInfo(&KeychainCore::Schema::DBInfo); // Set the standard schema + try { + db->create(); + } catch (const CssmError &error) { + if (error.cssmError() == CSSMERR_DL_DATASTORE_ALREADY_EXISTS && force) { + notice("recreating %s", kcName); + unlink(kcName); + db->create(); + } else + throw; + } + chmod(db->name(), 0644); + + // extract the key into the CSPDL + DeriveKey derive(csp, CSSM_ALGID_KEYCHAIN_KEY, CSSM_ALGID_3DES_3KEY, 3 * 64); + CSSM_DL_DB_HANDLE dlDb = db->handle(); + CssmData dlDbData = CssmData::wrap(dlDb); + CssmKey refKey; + KeySpec spec(CSSM_KEYUSE_ANY, + CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_EXTRACTABLE); + derive(&dlDbData, spec, refKey); + + // now extract the raw keybits + CssmKey rawKey; + WrapKey wrap(csp, CSSM_ALGID_NONE); + wrap(refKey, rawKey); + + // form the evidence record + UnlockBlob blob; + blob.initialize(0); + CssmAutoData index(CssmAllocator::standard()); + masterKeyIndex(db, index); + memcpy(&blob.signature, index.data(), sizeof(blob.signature)); + memcpy(blob.masterKey, rawKey.data(), sizeof(blob.masterKey)); + + // write it out, forcibly overwriting an existing file + string tempFile(string(unlockConfig) + ","); + FileDesc blobFile(tempFile, O_WRONLY | O_CREAT | O_TRUNC, 0400); + if (blobFile.write(blob) != sizeof(blob)) { + unlink(tempFile.c_str()); + fail("unable to write %s", tempFile.c_str()); + } + blobFile.close(); + ::rename(tempFile.c_str(), unlockConfig); + + notice("%s installed as system keychain", kcName); +} + + +// +// Extract the master secret from a keychain and install it in another keychain for unlocking +// +void extract(const char *srcName, const char *dstName) +{ + CSP csp(gGuidAppleCSPDL); + DL dl(gGuidAppleCSPDL); + + // open source database + Db srcDb(dl, srcName); + + // open destination database + Db dstDb(dl, dstName); + try { + dstDb->open(); + } catch (const CssmError &err) { + if (err.cssmError() == CSSMERR_DL_DATASTORE_DOESNOT_EXIST && createIfNeeded) { + notice("creating %s", dstName); + dstDb->create(); + } else + throw; + } + + // extract master key and place into destination keychain + DeriveKey derive(csp, CSSM_ALGID_KEYCHAIN_KEY, CSSM_ALGID_3DES_3KEY, 3 * 64); + CSSM_DL_DB_HANDLE dstDlDb = dstDb->handle(); + derive.add(CSSM_ATTRIBUTE_DL_DB_HANDLE, dstDlDb); + CSSM_DL_DB_HANDLE srcDlDb = srcDb->handle(); + CssmData dlDbData = CssmData::wrap(srcDlDb); + CssmAutoData keyLabel(CssmAllocator::standard()); + labelForMasterKey(srcDb, keyLabel); + KeySpec spec(CSSM_KEYUSE_ANY, + CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_PERMANENT | CSSM_KEYATTR_SENSITIVE, + keyLabel); + CssmKey masterKey; + try { + derive(&dlDbData, spec, masterKey); + } catch (const CssmError &error) { + if (error.cssmError() != CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA) + throw; + if (!force) + fail("existing key in %s not overwritten. Use -f to replace it.", dstDb->name()); + notice("replacing existing record in %s", dstDb->name()); + deleteKey(dstDb, keyLabel); + derive(&dlDbData, spec, masterKey); + } + notice("%s can now be unlocked with a key in %s", srcName, dstName); +} + + +// +// Run a simple test to see if the system-root keychain can auto-unlock. +// This isn't trying really hard to diagnose any problems; it's just a yay-or-nay check. +// +void test(const char *kcName) +{ + CSP csp(gGuidAppleCSPDL); + DL dl(gGuidAppleCSPDL); + + // lock, then unlock the keychain + Db db(dl, kcName); + printf("Testing system unlock of %s\n", kcName); + printf("(If you are prompted for a passphrase, cancel)\n"); + try { + db->lock(); + db->unlock(); + notice("System unlock is working"); + } catch (...) { + fail("System unlock is NOT working\n"); + } +} + + +// +// Utility functions +// +void masterKeyIndex(Db &db, CssmOwnedData &index) +{ + SecurityServer::ClientSession ss(CssmAllocator::standard(), CssmAllocator::standard()); + SecurityServer::DbHandle dbHandle; + db->passThrough(CSSM_APPLECSPDL_DB_GET_HANDLE, (const void *)NULL, &dbHandle); + ss.getDbSuggestedIndex(dbHandle, index.get()); +} + + +void labelForMasterKey(Db &db, CssmOwnedData &label) +{ + label = StringData("SYSKC**"); // 8 bytes exactly + CssmAutoData index(label.allocator); + masterKeyIndex(db, index); + label.append(index); +} + + +void deleteKey(Db &db, const CssmData &label) +{ + DbCursor search(db); + search->recordType(CSSM_DL_DB_RECORD_SYMMETRIC_KEY); + search->add(CSSM_DB_EQUAL, dlInfoLabel, label); + DbUniqueRecord id; + if (search->next(NULL, NULL, id)) + id->deleteRecord(); +} + + +// +// Message helpers +// +void notice(const char *fmt, ...) +{ + if (verbose) { + va_list args; + va_start(args, fmt); + vprintf(fmt, args); + putchar('\n'); + va_end(args); + } +} + +void fail(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vprintf(fmt, args); + putchar('\n'); + va_end(args); + exit(1); +} diff --git a/SecurityServer/transition.cpp b/SecurityServer/transition.cpp index 20aba38c..86da930d 100644 --- a/SecurityServer/transition.cpp +++ b/SecurityServer/transition.cpp @@ -19,23 +19,25 @@ // // transition - SecurityServer IPC-to-class-methods transition layer // -#include #include "server.h" #include "ucsp.h" #include "session.h" #include "xdatabase.h" +#include "transwalkers.h" #include +#include +#include // // Bracket Macros // #define UCSP_ARGS mach_port_t servicePort, mach_port_t replyPort, security_token_t securityToken, \ CSSM_RETURN *rcode -#define CONTEXT_ARGS Context context, Pointer contextBase, Context::Attr *attributes, mach_msg_type_number_t attrCount +#define CONTEXT_ARGS Context context, Pointer contextBase, Context::Attr *attributes, mach_msg_type_number_t attrSize #define BEGIN_IPCN *rcode = CSSM_OK; try { -#define BEGIN_IPC BEGIN_IPCN Connection &connection = Server::connection(replyPort); +#define BEGIN_IPC BEGIN_IPCN Connection &connection __attribute__((unused)) = Server::connection(replyPort); #define END_IPC(base) END_IPCN(base) Server::requestComplete(); return KERN_SUCCESS; #define END_IPCN(base) } \ catch (const CssmCommonError &err) { *rcode = err.cssmError(CSSM_ ## base ## _BASE_ERROR); } \ @@ -79,71 +81,49 @@ private: // -// A CheckingReconstituteWalker is a variant of an ordinary ReconstituteWalker -// that checks object pointers and sizes against the incoming block limits. -// It throws an exception if incoming data has pointers outside the incoming block. -// This avoids trouble inside of the SecurityServer caused (by bug or malice) -// from someone spoofing the client access side. +// Setup/Teardown functions. // -class CheckingReconstituteWalker { -public: - CheckingReconstituteWalker(void *ptr, void *base, size_t size) - : mBase(base), mLimit(increment(base, size)), mOffset(difference(ptr, base)) { } - - template - void operator () (T * &addr, size_t size = sizeof(T)) - { - if (addr) { - if (addr < mBase || increment(addr, size) > mLimit) - CssmError::throwMe(CSSM_ERRCODE_INVALID_POINTER); - addr = increment(addr, mOffset); - } - } - - static const bool needsRelinking = true; - static const bool needsSize = false; - -private: - void *mBase; // old base address - void *mLimit; // old last byte address + 1 - off_t mOffset; // relocation offset -}; - -template -void relocate(T *obj, T *base, size_t size) +kern_return_t ucsp_server_setup(UCSP_ARGS, mach_port_t taskPort, ClientSetupInfo info, const char *identity) { - if (obj) { - if (base == NULL) // invalid, could confuse walkers - CssmError::throwMe(CSSM_ERRCODE_INVALID_POINTER); - CheckingReconstituteWalker w(obj, base, size); - walk(w, base); - } + BEGIN_IPCN + Server::active().setupConnection(Server::connectNewProcess, servicePort, replyPort, + taskPort, securityToken, &info, identity); + END_IPCN(CSSM) + return KERN_SUCCESS; } - -// -// Setup/Teardown functions. -// -kern_return_t ucsp_server_setup(UCSP_ARGS, mach_port_t taskPort, const char *identity) +kern_return_t ucsp_server_setupNew(UCSP_ARGS, mach_port_t taskPort, + ClientSetupInfo info, const char *identity, + mach_port_t *newServicePort) { BEGIN_IPCN - Server::active().setupConnection(servicePort, replyPort, taskPort, securityToken, identity); + try { + Session *session = new DynamicSession(TaskPort(taskPort).bootstrap()); + Server::active().setupConnection(Server::connectNewSession, session->servicePort(), replyPort, + taskPort, securityToken, &info, identity); + *newServicePort = session->servicePort(); + } catch (const MachPlusPlus::Error &err) { + switch (err.error) { + case BOOTSTRAP_SERVICE_ACTIVE: + MacOSError::throwMe(errSessionAuthorizationDenied); // translate + default: + throw; + } + } END_IPCN(CSSM) return KERN_SUCCESS; } -kern_return_t ucsp_server_setupNew(UCSP_ARGS, mach_port_t taskPort, const char *identity, - mach_port_t *newServicePort) +kern_return_t ucsp_server_setupThread(UCSP_ARGS, mach_port_t taskPort) { BEGIN_IPCN - Session *session = new DynamicSession(TaskPort(taskPort).bootstrap()); - Server::active().setupConnection(session->servicePort(), replyPort, - taskPort, securityToken, identity); - *newServicePort = session->servicePort(); + Server::active().setupConnection(Server::connectNewThread, servicePort, replyPort, + taskPort, securityToken); END_IPCN(CSSM) return KERN_SUCCESS; } + kern_return_t ucsp_server_teardown(UCSP_ARGS) { BEGIN_IPCN @@ -183,7 +163,7 @@ kern_return_t ucsp_server_decodeDb(UCSP_ARGS, DbHandle *db, kern_return_t ucsp_server_encodeDb(UCSP_ARGS, DbHandle db, DATA_OUT(blob)) { BEGIN_IPC - DbBlob *dbBlob = Server::database(db).encode(); // memory owned by database + DbBlob *dbBlob = Server::database(db).blob(); // memory owned by database *blob = dbBlob; *blobLength = dbBlob->length(); END_IPC(DL) @@ -196,6 +176,14 @@ kern_return_t ucsp_server_releaseDb(UCSP_ARGS, DbHandle db) END_IPC(DL) } +kern_return_t ucsp_server_getDbIndex(UCSP_ARGS, DbHandle db, DATA_OUT(index)) +{ + BEGIN_IPC + OutputData indexData(index, indexLength); + Server::database(db).getDbIndex(indexData); + END_IPC(DL) +} + kern_return_t ucsp_server_authenticateDb(UCSP_ARGS, DbHandle db, COPY_IN(AccessCredentials, cred)) { @@ -235,6 +223,13 @@ kern_return_t ucsp_server_lockDb(UCSP_ARGS, DbHandle db) END_IPC(DL) } +kern_return_t ucsp_server_lockAll (UCSP_ARGS, boolean_t forSleep) +{ + BEGIN_IPC + Database::lockAllDatabases(connection.process.session.databases(), forSleep); + END_IPC(DL) +} + kern_return_t ucsp_server_unlockDb(UCSP_ARGS, DbHandle db) { BEGIN_IPC @@ -283,6 +278,7 @@ kern_return_t ucsp_server_decodeKey(UCSP_ARGS, KeyHandle *keyh, CssmKey::Header BEGIN_IPC Key &key = *new Key(Server::database(db), DATA(blob).interpretedAs()); key.returnKey(*keyh, *header); + flip(*header); END_IPC(CSP) } @@ -296,7 +292,7 @@ kern_return_t ucsp_server_releaseKey(UCSP_ARGS, KeyHandle key) kern_return_t ucsp_server_queryKeySizeInBits(UCSP_ARGS, KeyHandle key, CSSM_KEY_SIZE *length) { BEGIN_IPC - *length = connection.queryKeySize(findHandle(key)); + *length = connection.queryKeySize(Server::key(key)); END_IPC(CSP) } @@ -304,11 +300,19 @@ kern_return_t ucsp_server_getOutputSize(UCSP_ARGS, CONTEXT_ARGS, KeyHandle key, uint32 inputSize, boolean_t encrypt, uint32 *outputSize) { BEGIN_IPC - context.postIPC(contextBase, attributes); - *outputSize = connection.getOutputSize(context, findHandle(key), inputSize, encrypt); + relocate(context, contextBase, attributes, attrSize); + *outputSize = connection.getOutputSize(context, Server::key(key), inputSize, encrypt); END_IPC(CSP) } +kern_return_t ucsp_server_getKeyDigest(UCSP_ARGS, KeyHandle key, DATA_OUT(digest)) +{ + BEGIN_IPC + CssmData digestData = Server::key(key).canonicalDigest(); + *digest = digestData.data(); + *digestLength = digestData.length(); + END_IPC(CSP) +} // // RNG interface @@ -333,9 +337,9 @@ kern_return_t ucsp_server_generateSignature(UCSP_ARGS, CONTEXT_ARGS, KeyHandle k CSSM_ALGORITHMS signOnlyAlgorithm, DATA_IN(data), DATA_OUT(signature)) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); OutputData sigData(signature, signatureLength); - connection.generateSignature(context, findHandle(key), signOnlyAlgorithm, + connection.generateSignature(context, Server::key(key), signOnlyAlgorithm, DATA(data), sigData); END_IPC(CSP) } @@ -344,8 +348,8 @@ kern_return_t ucsp_server_verifySignature(UCSP_ARGS, CONTEXT_ARGS, KeyHandle key CSSM_ALGORITHMS verifyOnlyAlgorithm, DATA_IN(data), DATA_IN(signature)) { BEGIN_IPC - context.postIPC(contextBase, attributes); - connection.verifySignature(context, findHandle(key), verifyOnlyAlgorithm, + relocate(context, contextBase, attributes, attrSize); + connection.verifySignature(context, Server::key(key), verifyOnlyAlgorithm, DATA(data), DATA(signature)); END_IPC(CSP) } @@ -354,9 +358,9 @@ kern_return_t ucsp_server_generateMac(UCSP_ARGS, CONTEXT_ARGS, KeyHandle key, DATA_IN(data), DATA_OUT(mac)) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); OutputData macData(mac, macLength); - connection.generateMac(context, findHandle(key), + connection.generateMac(context, Server::key(key), DATA(data), macData); END_IPC(CSP) } @@ -365,9 +369,8 @@ kern_return_t ucsp_server_verifyMac(UCSP_ARGS, CONTEXT_ARGS, KeyHandle key, DATA_IN(data), DATA_IN(mac)) { BEGIN_IPC - context.postIPC(contextBase, attributes); - connection.verifyMac(context, findHandle(key), - DATA(data), DATA(mac)); + relocate(context, contextBase, attributes, attrSize); + connection.verifyMac(context, Server::key(key), DATA(data), DATA(mac)); END_IPC(CSP) } @@ -379,9 +382,9 @@ kern_return_t ucsp_server_encrypt(UCSP_ARGS, CONTEXT_ARGS, KeyHandle key, DATA_IN(clear), DATA_OUT(cipher)) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); OutputData cipherOut(cipher, cipherLength); - connection.encrypt(context, findHandle(key), + connection.encrypt(context, Server::key(key), DATA(clear), cipherOut); END_IPC(CSP) } @@ -390,9 +393,9 @@ kern_return_t ucsp_server_decrypt(UCSP_ARGS, CONTEXT_ARGS, KeyHandle key, DATA_IN(cipher), DATA_OUT(clear)) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); OutputData clearOut(clear, clearLength); - connection.decrypt(context, findHandle(key), + connection.decrypt(context, Server::key(key), DATA(cipher), clearOut); END_IPC(CSP) } @@ -406,13 +409,14 @@ kern_return_t ucsp_server_generateKey(UCSP_ARGS, DbHandle db, CONTEXT_ARGS, uint32 usage, uint32 attrs, KeyHandle *newKey, CssmKey::Header *newHeader) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); relocate(cred, credBase, credLength); relocate(owner, ownerBase, ownerLength); Key *key; connection.generateKey(Server::optionalDatabase(db), context, cred, owner, usage, attrs, key); key->returnKey(*newKey, *newHeader); + flip(*newHeader); END_IPC(CSP) } @@ -422,7 +426,7 @@ kern_return_t ucsp_server_generateKeyPair(UCSP_ARGS, DbHandle db, CONTEXT_ARGS, KeyHandle *pubKey, CssmKey::Header *pubHeader, KeyHandle *privKey, CssmKey::Header *privHeader) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); relocate(cred, credBase, credLength); relocate(owner, ownerBase, ownerLength); Key *pub, *priv; @@ -430,7 +434,9 @@ kern_return_t ucsp_server_generateKeyPair(UCSP_ARGS, DbHandle db, CONTEXT_ARGS, context, cred, owner, pubUsage, pubAttrs, privUsage, privAttrs, pub, priv); pub->returnKey(*pubKey, *pubHeader); + flip(*pubHeader); priv->returnKey(*privKey, *privHeader); + flip(*privHeader); END_IPC(CSP) } @@ -451,7 +457,7 @@ kern_return_t ucsp_server_deriveKey(UCSP_ARGS, DbHandle db, CONTEXT_ARGS, KeyHan uint32 usage, uint32 attrs, KeyHandle *newKey, CssmKey::Header *newHeader) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); relocate(cred, credBase, credLength); relocate(owner, ownerBase, ownerLength); @@ -471,6 +477,7 @@ kern_return_t ucsp_server_deriveKey(UCSP_ARGS, DbHandle db, CONTEXT_ARGS, KeyHan Key &theKey = connection.deriveKey(Server::optionalDatabase(db), context, Server::optionalKey(key), cred, owner, ¶m, usage, attrs); theKey.returnKey(*newKey, *newHeader); + flip(*newHeader); if (param.length()) { if (!param) // CSP screwed up CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); @@ -490,7 +497,7 @@ kern_return_t ucsp_server_wrapKey(UCSP_ARGS, CONTEXT_ARGS, KeyHandle key, DATA_IN(descriptiveData), CssmKey *wrappedKey, DATA_OUT(keyData)) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); relocate(cred, credBase, credLength); connection.wrapKey(context, Server::optionalKey(key), Server::key(keyToBeWrapped), cred, DATA(descriptiveData), *wrappedKey); @@ -498,6 +505,7 @@ kern_return_t ucsp_server_wrapKey(UCSP_ARGS, CONTEXT_ARGS, KeyHandle key, *keyData = wrappedKey->data(); *keyDataLength = wrappedKey->length(); Server::releaseWhenDone(*keyData); + flip(*wrappedKey); END_IPC(CSP) } @@ -508,7 +516,8 @@ kern_return_t ucsp_server_unwrapKey(UCSP_ARGS, DbHandle db, CONTEXT_ARGS, KeyHan KeyHandle *newKey, CssmKey::Header *newHeader) { BEGIN_IPC - context.postIPC(contextBase, attributes); + relocate(context, contextBase, attributes, attrSize); + flip(wrappedKey); wrappedKey.KeyData = DATA(wrappedKeyData); relocate(cred, credBase, credLength); relocate(owner, ownerBase, ownerLength); @@ -517,6 +526,7 @@ kern_return_t ucsp_server_unwrapKey(UCSP_ARGS, DbHandle db, CONTEXT_ARGS, KeyHan context, Server::optionalKey(key), cred, owner, usage, attr, wrappedKey, Server::optionalKey(publicKey), &descriptiveDatas); theKey.returnKey(*newKey, *newHeader); + flip(*newHeader); *descriptiveData = descriptiveDatas.data(); *descriptiveDataLength = descriptiveDatas.length(); Server::releaseWhenDone(*descriptiveData); @@ -536,8 +546,8 @@ kern_return_t ucsp_server_getOwner(UCSP_ARGS, AclKind kind, KeyHandle key, Server::aclBearer(kind, key).cssmGetOwner(owner); // allocates memory in owner Copier owners(&owner, CssmAllocator::standard()); // make flat copy { ChunkFreeWalker free; walk(free, owner); } // release chunked original - *ownerOut = *ownerOutBase = owners; *ownerOutLength = owners.length(); + flips(owners.value(), ownerOut, ownerOutBase); Server::releaseWhenDone(owners.keep()); // throw flat copy out when done END_IPC(CSP) } @@ -567,11 +577,21 @@ kern_return_t ucsp_server_getAcl(UCSP_ARGS, AclKind kind, KeyHandle key, ChunkFreeWalker free; for (uint32 n = 0; n < count; n++) walk(free, aclList[n]); + + // release the memory allocated for the list itself when we are done + CssmAllocator::standard().free (aclList); } - // set result - *acls = *aclsBase = aclsOut; + // set result (note: this is *almost* flips(), but on an array) *aclsLength = aclsOut.length(); + *acls = *aclsBase = aclsOut; + if (flipClient()) { + FlipWalker w; + for (uint32 n = 0; n < count; n++) + walk(w, (*acls)[n]); + w.doFlips(); + Flippers::flip(*aclsBase); + } Server::releaseWhenDone(aclsOut.keep()); END_IPC(CSP) } @@ -588,20 +608,43 @@ kern_return_t ucsp_server_changeAcl(UCSP_ARGS, AclKind kind, KeyHandle key, } +// +// Database key management. +// ExtractMasterKey looks vaguely like a key derivation operation, and is in fact +// presented by the CSPDL's CSSM layer as such. +// +kern_return_t ucsp_server_extractMasterKey(UCSP_ARGS, DbHandle db, CONTEXT_ARGS, DbHandle sourceDb, + COPY_IN(AccessCredentials, cred), COPY_IN(AclEntryPrototype, owner), + uint32 usage, uint32 attrs, KeyHandle *newKey, CssmKey::Header *newHeader) +{ + BEGIN_IPC + context.postIPC(contextBase, attributes); + relocate(cred, credBase, credLength); + relocate(owner, ownerBase, ownerLength); + Key *masterKey = Server::database(sourceDb).extractMasterKey(Server::optionalDatabase(db), + cred, owner, usage, attrs); + masterKey->returnKey(*newKey, *newHeader); + flip(*newHeader); + END_IPC(CSP) +} + + // // Authorization subsystem support // kern_return_t ucsp_server_authorizationCreate(UCSP_ARGS, - COPY_IN(AuthorizationItemSet, rights), + COPY_IN(AuthorizationItemSet, inRights), uint32 flags, - COPY_IN(AuthorizationItemSet, environment), + COPY_IN(AuthorizationItemSet, inEnvironment), AuthorizationBlob *authorization) { BEGIN_IPC - relocate(rights, rightsBase, rightsLength); - relocate(environment, environmentBase, environmentLength); + relocate(inRights, inRightsBase, inRightsLength); + relocate(inEnvironment, inEnvironmentBase, inEnvironmentLength); + Authorization::AuthItemSet rights(inRights), environment(inEnvironment); + *rcode = connection.process.session.authCreate(rights, environment, - flags, *authorization); + flags, *authorization, securityToken); END_IPC(CSSM) } @@ -615,21 +658,26 @@ kern_return_t ucsp_server_authorizationRelease(UCSP_ARGS, kern_return_t ucsp_server_authorizationCopyRights(UCSP_ARGS, AuthorizationBlob authorization, - COPY_IN(AuthorizationItemSet, rights), + COPY_IN(AuthorizationItemSet, inRights), uint32 flags, - COPY_IN(AuthorizationItemSet, environment), + COPY_IN(AuthorizationItemSet, inEnvironment), COPY_OUT(AuthorizationItemSet, result)) { BEGIN_IPC - relocate(rights, rightsBase, rightsLength); - relocate(environment, environmentBase, environmentLength); - Authorization::MutableRightSet grantedRights; + relocate(inRights, inRightsBase, inRightsLength); + relocate(inEnvironment, inEnvironmentBase, inEnvironmentLength); + Authorization::AuthItemSet rights(inRights), environment(inEnvironment), grantedRights; *rcode = connection.process.session.authGetRights(authorization, rights, environment, flags, grantedRights); - Copier returnedRights(grantedRights, CssmAllocator::standard()); - *result = *resultBase = returnedRights; - *resultLength = returnedRights.length(); - Server::releaseWhenDone(returnedRights.keep()); + if (result && resultLength) + { + size_t resultSize; + grantedRights.copy(*result, resultSize); + *resultLength = resultSize; + *resultBase = *result; + flips(*result, result, resultBase); + Server::releaseWhenDone(*result); + } END_IPC(CSSM) } @@ -639,16 +687,18 @@ kern_return_t ucsp_server_authorizationCopyInfo(UCSP_ARGS, COPY_OUT(AuthorizationItemSet, info)) { BEGIN_IPC - AuthorizationItemSet *result; + Authorization::AuthItemSet infoSet; *info = *infoBase = NULL; *infoLength = 0; *rcode = connection.process.session.authGetInfo(authorization, - tag[0] ? tag : NULL, result); // result is a deep copy - if (*rcode == noErr) - { - *info = *infoBase = result; - *infoLength = size(result); - Server::releaseWhenDone(result); + tag[0] ? tag : NULL, infoSet); + if (*rcode == noErr) { + size_t infoSize; + infoSet.copy(*info, infoSize); + *infoLength = infoSize; + *infoBase = *info; + flips(*info, info, infoBase); + Server::releaseWhenDone(*info); } END_IPC(CSSM) } @@ -715,3 +765,89 @@ kern_return_t ucsp_server_postNotification(UCSP_ARGS, uint32 domain, uint32 even connection.process.postNotification(domain, event, DATA(data)); END_IPC(CSSM) } + + +// +// AuthorizationDB modification +// +kern_return_t ucsp_server_authorizationdbGet(UCSP_ARGS, const char *rightname, DATA_OUT(rightDefinition)) +{ + BEGIN_IPC + CFDictionaryRef rightDict; + + *rcode = connection.process.session.authorizationdbGet(rightname, &rightDict); + + if (!*rcode && rightDict) + { + CFRef data(CFPropertyListCreateXMLData (NULL, rightDict)); + CFRelease(rightDict); + if (!data) + return errAuthorizationInternal; + + // @@@ copy data to avoid having to do a delayed cfrelease + mach_msg_type_number_t length = CFDataGetLength(data); + void *xmlData = CssmAllocator::standard().malloc(length); + memcpy(xmlData, CFDataGetBytePtr(data), length); + Server::releaseWhenDone(xmlData); + + *rightDefinition = xmlData; + *rightDefinitionLength = length; + } + END_IPC(CSSM) +} + +kern_return_t ucsp_server_authorizationdbSet(UCSP_ARGS, AuthorizationBlob authorization, const char *rightname, DATA_IN(rightDefinition)) +{ + BEGIN_IPC + CFRef data(CFDataCreate(NULL, (UInt8 *)rightDefinition, rightDefinitionLength)); + + if (!data) + return errAuthorizationInternal; + + CFRef rightDefinition(static_cast(CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, NULL))); + + if (!rightDefinition || (CFGetTypeID(rightDefinition) != CFDictionaryGetTypeID())) + return errAuthorizationInternal; + + *rcode = connection.process.session.authorizationdbSet(authorization, rightname, rightDefinition); + + END_IPC(CSSM) +} + +kern_return_t ucsp_server_authorizationdbRemove(UCSP_ARGS, AuthorizationBlob authorization, const char *rightname) +{ + BEGIN_IPC + *rcode = connection.process.session.authorizationdbRemove(authorization, rightname); + END_IPC(CSSM) +} + + +// +// Miscellaneous administrative functions +// +kern_return_t ucsp_server_addCodeEquivalence(UCSP_ARGS, DATA_IN(oldHash), DATA_IN(newHash), + const char *name, boolean_t forSystem) +{ + BEGIN_IPC + Server::codeSignatures().addLink(DATA(oldHash), DATA(newHash), name, forSystem); + END_IPC(CSSM) +} + +kern_return_t ucsp_server_removeCodeEquivalence(UCSP_ARGS, DATA_IN(hash), + const char *name, boolean_t forSystem) +{ + BEGIN_IPC + Server::codeSignatures().removeLink(DATA(hash), name, forSystem); + END_IPC(CSSM) +} + +kern_return_t ucsp_server_setAlternateSystemRoot(UCSP_ARGS, const char *root) +{ + BEGIN_IPC +#if defined(NDEBUG) + if (connection.process.uid() != 0) + CssmError::throwMe(CSSM_ERRCODE_OS_ACCESS_DENIED); +#endif //NDEBUG + Server::codeSignatures().open((string(root) + EQUIVALENCEDBPATH).c_str()); + END_IPC(CSSM) +} diff --git a/SecurityServer/transwalkers.cpp b/SecurityServer/transwalkers.cpp new file mode 100644 index 00000000..8a6345eb --- /dev/null +++ b/SecurityServer/transwalkers.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// transwalkers - server side transition data walking support +// +// These are data walker operators for securely marshaling and unmarshaling +// data structures across IPC. They are also in charge of fixing byte order +// inconsistencies between server and clients. +// +#include + + +using LowLevelMemoryUtilities::increment; +using LowLevelMemoryUtilities::difference; + + +bool flipClient() +{ + return Server::connection().process.byteFlipped(); +} + + +// +// CheckingRelocateWalkers +// +CheckingReconstituteWalker::CheckingReconstituteWalker(void *ptr, void *base, size_t size, bool flip) + : mBase(base), mFlip(flip) +{ + if (mFlip) + Flippers::flip(mBase); // came in reversed; fix for base use + mOffset = difference(ptr, mBase); + mLimit = increment(mBase, size); +} + + +// +// Relocation support +// +void relocate(Context &context, void *base, Context::Attr *attrs, uint32 attrSize) +{ + flip(context); + CheckingReconstituteWalker relocator(attrs, base, attrSize, flipClient()); + context.ContextAttributes = attrs; // fix context->attr vector link + for (uint32 n = 0; n < context.attributesInUse(); n++) + walk(relocator, context[n]); +} + + +// +// Outbound flipping support +// +FlipWalker::~FlipWalker() +{ + for (set::const_iterator it = mFlips.begin(); it != mFlips.end(); it++) + delete it->impl; +} + +void FlipWalker::doFlips(bool active) +{ + if (active) { + secdebug("flipwalkers", "starting outbound flips"); + for (set::const_iterator it = mFlips.begin(); it != mFlips.end(); it++) + it->impl->flip(); + secdebug("flipwalkers", "outbound flips done"); + } +} diff --git a/SecurityServer/transwalkers.h b/SecurityServer/transwalkers.h new file mode 100644 index 00000000..ea69d09d --- /dev/null +++ b/SecurityServer/transwalkers.h @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// transwalkers - server side transition data walking support +// +// These are data walker operators for securely marshaling and unmarshaling +// data structures across IPC. They are also in charge of fixing byte order +// inconsistencies between server and clients. +// +#ifndef _H_TRANSWALKERS +#define _H_TRANSWALKERS + +#include +#include "flippers.h" +#include "server.h" +#include + +using LowLevelMemoryUtilities::increment; +using LowLevelMemoryUtilities::difference; + + +// +// Should we flip data? +// This looks at the current client's process information (a thread-global state) +// to determine flip status. Valid (only) within BEGIN_IPC/END_IPC brackets. +// +bool flipClient(); + + +// +// A CheckingReconstituteWalker is a variant of an ordinary ReconstituteWalker +// that checks object pointers and sizes against the incoming block limits. +// It throws an exception if incoming data has pointers outside the incoming block. +// This avoids trouble inside of the SecurityServer caused (by bug or malice) +// from someone spoofing the client access side. +// +class CheckingReconstituteWalker { +private: + void check(void *addr, size_t size) + { + if (addr < mBase || increment(addr, size) > mLimit) + CssmError::throwMe(CSSM_ERRCODE_INVALID_POINTER); + } + +public: + CheckingReconstituteWalker(void *ptr, void *base, size_t size, bool flip); + + template + void operator () (T &obj, size_t size = sizeof(T)) + { + check(increment(&obj, -mOffset), size); + if (mFlip) + Flippers::flip(obj); + } + + template + void operator () (T * &addr, size_t size = sizeof(T)) + { + DEBUGWALK("checkreconst:ptr"); + if (addr) { + // process the pointer + void *p = addr; + blob(p, size); + addr = reinterpret_cast(p); + + // now flip the contents + if (mFlip) + Flippers::flip(*addr); + } + } + + template + void blob(T * &addr, size_t size) + { + DEBUGWALK("checkreconst:blob"); + if (addr) { + // flip the address (the pointer itself) + if (mFlip) { + secdebug("flippers", "flipping %s@%p", Debug::typeName(addr).c_str(), addr); + Flippers::flip(addr); + } + + // check the address against the transmitted bounds + check(addr, size); + + // relocate it + addr = increment(addr, mOffset); + } + } + + static const bool needsRelinking = true; + static const bool needsSize = false; + +private: + void *mBase; // old base address + void *mLimit; // old last byte address + 1 + off_t mOffset; // relocation offset + bool mFlip; // apply byte order flipping +}; + + +// +// Process an incoming (IPC) data blob of type T. +// This relocates pointers to fit in the local address space, +// and fixes byte order issues as needed. +// +template +void relocate(T *obj, T *base, size_t size) +{ + if (obj) { + if (base == NULL) // invalid, could confuse walkers + CssmError::throwMe(CSSM_ERRCODE_INVALID_POINTER); + CheckingReconstituteWalker relocator(obj, base, size, + Server::connection().process.byteFlipped()); + walk(relocator, base); + } +} + + +// +// Special handling for incoming CSSM contexts. +// +void relocate(Context &context, void *base, Context::Attr *attrs, uint32 attrSize); + + +// +// A FlipWalker is a walker operator that collects its direct invocations +// into a set of memory objects. These objects can then collectively be +// byte-flipped (exactly once :-) at the flick of a function. +// +class FlipWalker { +private: + struct FlipBase { + virtual ~FlipBase() { } + virtual void flip() const = 0; + }; + + template + struct FlipRef : public FlipBase { + T &obj; + FlipRef(T &s) : obj(s) { } + void flip() const +{ secdebug("outflip", "%p flip/ref %s@%p", this, Debug::typeName(obj).c_str(), &obj); +{ Flippers::flip(obj); } +} + }; + + template + struct FlipPtr : public FlipBase { + T * &obj; + FlipPtr(T * &s) : obj(s) { } + void flip() const +{ secdebug("outflip", "%p flip/ptr %s@%p(%p)", this, Debug::typeName(obj).c_str(), &obj, obj); +{ Flippers::flip(*obj); Flippers::flip(obj); } +} +}; + + template + struct FlipBlob : public FlipBase { + T * &obj; + FlipBlob(T * &s) : obj(s) { } + void flip() const +{ secdebug("outflip", "%p flip/blob %s@%p(%p)", this, Debug::typeName(obj).c_str(), &obj, obj); +{ Flippers::flip(obj); } +} + }; + + struct Flipper { + FlipBase *impl; + Flipper(FlipBase *p) : impl(p) { } + bool operator < (const Flipper &other) const + { return impl < other.impl; } + }; + +public: + ~FlipWalker(); + void doFlips(bool active = true); + + template + void operator () (T &obj, size_t = sizeof(T)) + { mFlips.insert(new FlipRef(obj)); } + + template + T *operator () (T * &addr, size_t size = sizeof(T)) + { mFlips.insert(new FlipPtr(addr)); return addr; } + + template + void blob(T * &addr, size_t size) + { mFlips.insert(new FlipBlob(addr)); } + + static const bool needsRelinking = true; + static const bool needsSize = true; + +private: + set mFlips; +}; + + +// +// A raw flip, conditioned on the client's flip state +// +template +void flip(T &addr) +{ + if (flipClient()) { + secdebug("flippers", "raw flipping %s", Debug::typeName(addr).c_str()); + Flippers::flip(addr); + } +} + +template +void flips(T *value, T ** &addr, T ** &base) +{ + *addr = *base = value; + if (flipClient()) { + FlipWalker w; // collector + walk(w, value); // collect all flippings needed + w.doFlips(); // execute flips (flips value but leaves addr alone) + Flippers::flip(*base); // flip base (so it arrives right side up) + } +} + + +#endif //_H_TRANSWALKERS diff --git a/SecurityServer/ucsp.defs b/SecurityServer/ucsp.defs index dfc24967..9c8370ac 100644 --- a/SecurityServer/ucsp.defs +++ b/SecurityServer/ucsp.defs @@ -17,6 +17,9 @@ import "ucsp_types.h"; // type Data = array [] of char; +type Pointer = unsigned32; +type BasePointer = unsigned32; + type KeyHandle = unsigned32; type KeyBlob = Data ctype: Pointer; @@ -27,56 +30,63 @@ type DbBlob = Data type AclEntryPrototypeBlob = Data ctype: AclEntryPrototypePtr; -type AclEntryPrototypePtr = unsigned32; +type AclEntryPrototypePtr = BasePointer; type AclEntryInfoBlob = Data ctype: AclEntryInfoPtr; -type AclEntryInfoPtr = unsigned32; +type AclEntryInfoPtr = BasePointer; type AclEntryInputBlob = Data ctype: AclEntryInputPtr; -type AclEntryInputPtr = unsigned32; +type AclEntryInputPtr = BasePointer; type AclOwnerPrototypeBlob = Data ctype: AclOwnerPrototypePtr; -type AclOwnerPrototypePtr = unsigned32; +type AclOwnerPrototypePtr = BasePointer; type AccessCredentialsBlob = Data ctype: AccessCredentialsPtr; -type AccessCredentialsPtr = unsigned32; +type AccessCredentialsPtr = BasePointer; type DLDbIdentBlob = Data ctype: DLDbIdentPtr; -type DLDbIdentPtr = unsigned32; +type DLDbIdentPtr = BasePointer; + +type ParamInputBlob = Data + ctype: ParamInputPtr; +type ParamInputPtr = BasePointer; type VoidBlob = Data ctype: VoidPtr; type VoidPtr = unsigned32; -type Context = struct [9] of unsigned32 +type SetupInfo = struct[4] of uint8_t + ctype: ClientSetupInfo; + +type Context = struct [9*4] of uint8_t ctype: CSSM_CONTEXT intran: Context inTrans(CSSM_CONTEXT); type ContextAttributes = array [] of char cservertype: ContextAttributesPointer; -type CssmKeyHeader = struct [23] of unsigned32; +type CssmKeyHeader = struct [23*4] of uint8_t; -type CssmKey = struct [23+2] of unsigned32 +type CssmKey = struct [(23+2)*4] of uint8_t ctype: CSSM_KEY intran: CssmKey inTrans(CSSM_KEY) outtran: CSSM_KEY outTrans(CssmKey); -type CSSM_KEY_SIZE = struct [2] of unsigned32 +type CSSM_KEY_SIZE = struct [2*4] of uint32_t ctype: CSSM_KEY_SIZE; -type DBParameters = struct [1] of unsigned32; +type DBParameters = struct [1*4] of uint32_t; type AuthorizationItemSetBlob = Data ctype: AuthorizationItemSetPtr; -type AuthorizationItemSetPtr = unsigned32; +type AuthorizationItemSetPtr = BasePointer; -type AuthorizationBlob = struct [2] of unsigned32; // 8 opaque bytes -type AuthorizationExternalForm = struct [8] of unsigned32; // 32 opaque bytes +type AuthorizationBlob = struct [8] of uint8_t; // 8 opaque bytes +type AuthorizationExternalForm = struct [32] of uint8_t; // 32 opaque bytes type CssmString = c_string[*:64+4]; type AuthorizationString = c_string[*:1024]; @@ -90,8 +100,6 @@ type SecuritySessionId = unsigned32; type SessionAttributeBits = unsigned32; type SessionCreationFlags = unsigned32; -type Pointer = unsigned32; - type ExecutablePath = c_string[*:2048]; @@ -102,7 +110,7 @@ type ExecutablePath = c_string[*:2048]; replyport rport: mach_port_make_send_t; \ serversectoken sourceSecurity: security_token_t; \ out rcode: CSSM_RETURN -#define IN_CONTEXT in context: Context; in contextBase: Pointer; in attrs: ContextAttributes +#define IN_CONTEXT in context: Context; in contextBase: BasePointer; in attrs: ContextAttributes #define IN_BLOB(name,type) in name: type##Blob; in name##Base: type##Ptr #define OUT_BLOB(name,type) out name: type##Blob; out name##Base: type##Ptr @@ -110,9 +118,10 @@ type ExecutablePath = c_string[*:2048]; // // Management and administrative functions // -routine setup(UCSP_PORTS; in tport: mach_port_t; in executablePath: ExecutablePath); -routine setupNew(UCSP_PORTS; in tport: mach_port_t; in executablePath: ExecutablePath; +routine setup(UCSP_PORTS; in tport: mach_port_t; in info: SetupInfo; in executablePath: ExecutablePath); +routine setupNew(UCSP_PORTS; in tport: mach_port_t; in info: SetupInfo; in executablePath: ExecutablePath; out newServicePort: mach_port_make_send_t); +routine setupThread(UCSP_PORTS; in tport: mach_port_t); routine teardown(UCSP_PORTS); @@ -132,6 +141,7 @@ routine getDbParameters(UCSP_PORTS; in db: DbHandle; out params: DBParameters); routine changePassphrase(UCSP_PORTS; in db: DbHandle; IN_BLOB(accessCredentials,AccessCredentials)); routine lockDb(UCSP_PORTS; in db: DbHandle); +routine lockAll(UCSP_PORTS; in forSleep: boolean_t); routine unlockDb(UCSP_PORTS; in db: DbHandle); routine unlockDbWithPassphrase(UCSP_PORTS; in db: DbHandle; in passPhrase: Data); routine isLocked(UCSP_PORTS; in db: DbHandle; out locked: boolean_t); @@ -150,6 +160,8 @@ routine queryKeySizeInBits(UCSP_PORTS; in key: KeyHandle; out length: CSSM_KEY_S routine getOutputSize(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle; in inputSize: uint32; in encrypt: boolean_t; out outputSize: uint32); +routine getKeyDigest(UCSP_PORTS; in key: KeyHandle; out digest: Data); + // // Random numbers // @@ -181,7 +193,7 @@ routine generateKeyPair(UCSP_PORTS; in db: DbHandle; IN_CONTEXT; out privKey: KeyHandle; out privHeader: CssmKeyHeader); routine deriveKey(UCSP_PORTS; in db: DbHandle; IN_CONTEXT; in baseKey: KeyHandle; IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype); - IN_BLOB(paramInput,Void); out paramOutput: Data; + IN_BLOB(paramInput,ParamInput); out paramOutput: Data; in keyUsage: uint32; in keyAttrs: uint32; out key: KeyHandle; out header: CssmKeyHeader); routine wrapKey(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle; @@ -252,3 +264,30 @@ routine setupSession(UCSP_PORTS; in flags: SessionCreationFlags; in attrs: Sessi routine requestNotification(UCSP_PORTS; in receiver: mach_port_t; in domain: uint32; in events: uint32); routine stopNotification(UCSP_PORTS; in receiver: mach_port_t); routine postNotification(UCSP_PORTS; in domain: uint32; in event: uint32; in data: Data); + + +// +// Database key management +// +routine extractMasterKey(UCSP_PORTS; in db: DbHandle; IN_CONTEXT; in sourceDb: DbHandle; + IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype); + in keyUsage: uint32; in keyAttrs: uint32; out key: KeyHandle; out header: CssmKeyHeader); + +routine getDbIndex(UCSP_PORTS; in db: DbHandle; out index: Data); + +// +// AuthorizationDB operations +// +routine authorizationdbGet(UCSP_PORTS; in rightname: AuthorizationString; out rightdefinition: Data); +routine authorizationdbSet(UCSP_PORTS; in authorization: AuthorizationBlob; in rightname: AuthorizationString; in rightDefinition: Data); +routine authorizationdbRemove(UCSP_PORTS; in authorization: AuthorizationBlob; in rightname: AuthorizationString); + + +// +// Miscellaneous administrative calls +// +routine addCodeEquivalence(UCSP_PORTS; in oldCode: Data; in newCode: Data; in name: ExecutablePath; + in forSystem: boolean_t); +routine removeCodeEquivalence(UCSP_PORTS; in code: Data; in name: ExecutablePath; + in forSystem: boolean_t); +routine setAlternateSystemRoot(UCSP_PORTS; in path: ExecutablePath); diff --git a/SecurityServer/ucsp_types.h b/SecurityServer/ucsp_types.h index 7f055b1e..eb6213c7 100644 --- a/SecurityServer/ucsp_types.h +++ b/SecurityServer/ucsp_types.h @@ -32,6 +32,7 @@ using namespace SecurityServer; typedef void *Data; typedef void *Pointer; +typedef void *BasePointer; typedef const char *CssmString; @@ -43,6 +44,7 @@ typedef AclEntryInput *AclEntryInputPtr; typedef AclEntryInfo *AclEntryInfoPtr; typedef AclOwnerPrototype *AclOwnerPrototypePtr; typedef AccessCredentials *AccessCredentialsPtr; +typedef void *ParamInputPtr; typedef void *VoidPtr; typedef DataWalkers::DLDbFlatIdentifier DLDbIdentBlob; @@ -70,4 +72,11 @@ inline CSSM_KEY &outTrans(CssmKey &key) { return key; } #define UseStaticTemplates 0 + +// +// MIG-used byte swapping macros +// +#define __NDR_convert__int_rep__BasePointer__defined +#define __NDR_convert__int_rep__BasePointer(a, f) /* do not flip */ + } // end namespace Security diff --git a/SecurityServer/xdatabase.cpp b/SecurityServer/xdatabase.cpp index 9dd0fba6..1e71b102 100644 --- a/SecurityServer/xdatabase.cpp +++ b/SecurityServer/xdatabase.cpp @@ -23,17 +23,13 @@ #include "agentquery.h" #include "key.h" #include "server.h" +#include "session.h" #include "cfnotifier.h" // legacy #include "notifications.h" #include "SecurityAgentClient.h" #include // for default owner ACLs - - -// -// The map of database common segments -// -Mutex Database::commonLock; -Database::CommonMap Database::commons; +#include +#include // @@ -53,18 +49,24 @@ Database::Database(const DLDbIdentifier &id, const DBParameters ¶ms, Process DbIdentifier ident(id, newSig); // create common block and initialize - common = new Common(ident); + CommonMap &commons = proc.session.databases(); + common = new Common(ident, commons); StLock _(*common); - { StLock _(commonLock); + { StLock _(commons); assert(commons.find(ident) == commons.end()); // better be new! - commons[ident] = common = new Common(ident); + commons[ident] = common; common->useCount++; } // new common is now visible but we hold its lock + + // establish the new master secret + establishNewSecrets(cred, SecurityAgent::newDatabase); - // obtain initial passphrase and generate keys + // set initial database parameters common->mParams = params; - common->setupKeys(cred); + + // we're unlocked now + common->makeNewSecrets(); // establish initial ACL if (owner) @@ -74,15 +76,13 @@ Database::Database(const DLDbIdentifier &id, const DBParameters ¶ms, Process mValidData = true; // for now, create the blob immediately - //@@@ this could be deferred, at the cost of some additional - //@@@ state monitoring. What happens if it locks before we have a blob? encode(); // register with process process.addDatabase(this); - IFDEBUG(debug("SSdb", "database %s(%p) created, common at %p", - common->dbName(), this, common)); + secdebug("SSdb", "database %s(%p) created, common at %p", + common->dbName(), this, common); IFDUMPING("SSdb", debugDump("creation complete")); } @@ -98,7 +98,7 @@ Database::Database(const DLDbIdentifier &id, const DbBlob *blob, Process &proc, // perform basic validation on the incoming blob assert(blob); blob->validate(CSSMERR_APPLEDL_INVALID_DATABASE_BLOB); - switch (blob->version) { + switch (blob->version()) { #if defined(COMPAT_OSX_10_0) case blob->version_MacOS_10_0: break; @@ -114,7 +114,8 @@ Database::Database(const DLDbIdentifier &id, const DbBlob *blob, Process &proc, // check to see if we already know about this database DbIdentifier ident(id, blob->randomSignature); - StLock mapLock(commonLock); + CommonMap &commons = proc.session.databases(); + StLock mapLock(commons); CommonMap::iterator it = commons.find(ident); if (it != commons.end()) { // already there @@ -122,16 +123,16 @@ Database::Database(const DLDbIdentifier &id, const DbBlob *blob, Process &proc, //@@@ arbitrate sequence number here, perhaps update common->mParams StLock _(*common); // lock common against other users common->useCount++; - IFDEBUG(debug("SSdb", + secdebug("SSdb", "open database %s(%p) version %lx at known common %p(%d)", - common->dbName(), this, blob->version, common, int(common->useCount))); + common->dbName(), this, blob->version(), common, int(common->useCount)); } else { // newly introduced - commons[ident] = common = new Common(ident); + commons[ident] = common = new Common(ident, commons); common->mParams = blob->params; common->useCount++; - IFDEBUG(debug("SSdb", "open database %s(%p) version %lx with new common %p", - common->dbName(), this, blob->version, common)); + secdebug("SSdb", "open database %s(%p) version %lx with new common %p", + common->dbName(), this, blob->version(), common); } // register with process @@ -147,14 +148,16 @@ Database::Database(const DLDbIdentifier &id, const DbBlob *blob, Process &proc, // Database::~Database() { - IFDEBUG(debug("SSdb", "deleting database %s(%p) common %p (%d refs)", - common->dbName(), this, common, int(common->useCount))); + secdebug("SSdb", "deleting database %s(%p) common %p (%d refs)", + common->dbName(), this, common, int(common->useCount)); IFDUMPING("SSdb", debugDump("deleting database instance")); process.removeDatabase(this); CssmAllocator::standard().free(mCred); + CssmAllocator::standard().free(mBlob); // take the commonLock to avoid races against re-use of the common - StLock __(commonLock); + CommonMap &commons = process.session.databases(); + StLock __(commons); if (--common->useCount == 0 && common->isLocked()) { // last use of this database, and it's locked - discard IFDUMPING("SSdb", debugDump("discarding common")); @@ -170,65 +173,65 @@ Database::~Database() void Database::authenticate(const AccessCredentials *cred) { StLock _(*common); + AccessCredentials *newCred = DataWalkers::copy(cred, CssmAllocator::standard()); CssmAllocator::standard().free(mCred); - mCred = DataWalkers::copy(cred, CssmAllocator::standard()); + mCred = newCred; } // -// Encode the current database as a blob. -// Note that this returns memory we own and keep. +// Return the database blob, recalculating it as needed. // -DbBlob *Database::encode() +DbBlob *Database::blob() { StLock _(*common); if (!validBlob()) { - // unlock the database - makeUnlocked(); - - // create new up-to-date blob - DbBlob *blob = common->encode(*this); - CssmAllocator::standard().free(mBlob); - mBlob = blob; - version = common->version; - debug("SSdb", "encoded database %p(%s) version %ld", this, dbName(), version); + makeUnlocked(); // unlock to get master secret + encode(); // (re)encode blob if needed } - activity(); - assert(mBlob); + activity(); // reset timeout + assert(validBlob()); // better have a valid blob now... return mBlob; } +// +// Encode the current database as a blob. +// Note that this returns memory we own and keep. +// Caller must hold common lock. +// +void Database::encode() +{ + DbBlob *blob = common->encode(*this); + CssmAllocator::standard().free(mBlob); + mBlob = blob; + version = common->version; + secdebug("SSdb", "encoded database %p common %p(%s) version %ld params=(%ld,%d)", + this, common, dbName(), version, + common->mParams.idleTimeout, common->mParams.lockOnSleep); +} + + // // Change the passphrase on a database // void Database::changePassphrase(const AccessCredentials *cred) { + // get and hold the common lock (don't let other threads break in here) StLock _(*common); - if (isLocked()) { - CssmAutoData passphrase(CssmAllocator::standard(CssmAllocator::sensitive)); - if (getBatchPassphrase(cred, CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK, passphrase)) { - // incoming sample contained data for unlock - makeUnlocked(passphrase); - } else { - // perform standard unlock - makeUnlocked(); - } - } else if (!mValidData) // need to decode to get our ACLs, passphrase available - decode(common->passphrase); - - // get the new passphrase - // @@@ unstaged version -- revise to filter passphrases - Process &cltProc = Server::active().connection().process; - IFDEBUG(debug("SSdb", "New passphrase query from PID %d (UID %d)", cltProc.pid(), cltProc.uid())); - QueryNewPassphrase query(cltProc.uid(), cltProc.session, *common, SecurityAgent::changePassphrase); - query(cred, common->passphrase); + + // establish OLD secret - i.e. unlock the database + //@@@ do we want to leave the final lock state alone? + makeUnlocked(cred); + + // establish NEW secret + establishNewSecrets(cred, SecurityAgent::changePassphrase); common->version++; // blob state changed - IFDEBUG(debug("SSdb", "Database %s(%p) passphrase changed", common->dbName(), this)); + secdebug("SSdb", "Database %s(%p) master secret changed", common->dbName(), this); + encode(); // force rebuild of local blob // send out a notification KeychainNotifier::passphraseChanged(identifier()); - notify(passphraseChangedEvent); // I guess this counts as an activity activity(); @@ -236,38 +239,83 @@ void Database::changePassphrase(const AccessCredentials *cred) // -// Unlock this database (if needed) by obtaining the passphrase in some -// suitable way and then proceeding to unlock with it. Performs retries -// where appropriate. Does absolutely nothing if the database is already unlocked. +// Extract the database master key as a proper Key object. +// +Key *Database::extractMasterKey(Database *db, + const AccessCredentials *cred, const AclEntryPrototype *owner, + uint32 usage, uint32 attrs) +{ + // get and hold common lock + StLock _(*common); + + // unlock to establish master secret + makeUnlocked(cred); + + // extract the raw cryptographic key + CssmClient::WrapKey wrap(Server::csp(), CSSM_ALGID_NONE); + CssmKey key; + wrap(common->masterKey(), key); + + // make the key object and return it + return new Key(db, key, attrs & Key::managedAttributes, owner); +} + + +// +// Construct a binary blob of moderate size that is suitable for constructing +// an index identifying this database. +// We construct this from the database's marker blob, which is created with +// the database is made, and stays stable thereafter. +// Note: Ownership of the index blob passes to the caller. +// @@@ This means that physical copies share this index. +// +void Database::getDbIndex(CssmData &indexData) +{ + if (!mBlob) + encode(); // force blob creation + assert(mBlob); + CssmData signature = CssmData::wrap(mBlob->randomSignature); + indexData = CssmAutoData(CssmAllocator::standard(), signature).release(); +} + + +// +// Unlock this database (if needed) by obtaining the master secret in some +// suitable way and then proceeding to unlock with it. +// Does absolutely nothing if the database is already unlocked. +// The makeUnlocked forms are identical except the assume the caller already +// holds the common lock. // void Database::unlock() { StLock _(*common); makeUnlocked(); } - + void Database::makeUnlocked() +{ + return makeUnlocked(mCred); +} + +void Database::makeUnlocked(const AccessCredentials *cred) { IFDUMPING("SSdb", debugDump("default procedures unlock")); if (isLocked()) { - assert(mBlob || (mValidData && common->passphrase)); - - Process &cltProc = Server::active().connection().process; - IFDEBUG(debug("SSdb", "Unlock query from process %d (UID %d)", cltProc.pid(), cltProc.uid())); - QueryUnlock query(cltProc.uid(), cltProc.session, *this); - query(mCred); - if (isLocked()) // still locked, unlock failed - CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); - - // successfully unlocked + assert(mBlob || (mValidData && common->hasMaster())); + establishOldSecrets(cred); activity(); // set timeout timer - } else if (!mValidData) // need to decode to get our ACLs, passphrase available - decode(common->passphrase); + } else if (!mValidData) { // need to decode to get our ACLs, passphrase available + if (!decode()) + CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); + } + assert(!isLocked()); + assert(mValidData); } // -// Perform programmatic unlock of a database, given a passphrase. +// The following unlock given an explicit passphrase, rather than using +// (special cred sample based) default procedures. // void Database::unlock(const CssmData &passphrase) { @@ -282,45 +330,254 @@ void Database::makeUnlocked(const CssmData &passphrase) return; else CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); - } else if (!mValidData) - decode(common->passphrase); + } else if (!mValidData) { // need to decode to get our ACLs, passphrase available + if (!decode()) + CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); + } + assert(!isLocked()); + assert(mValidData); } // -// Perform an actual unlock operation given a passphrase. +// Nonthrowing passphrase-based unlock. This returns false if unlock failed. +// Note that this requires an explicitly given passphrase. // Caller must hold common lock. // bool Database::decode(const CssmData &passphrase) { - if (mValidData && common->passphrase) { // just check - return common->unlock(passphrase); - } else { // decode our blob + assert(mBlob); + common->setup(mBlob, passphrase); + return decode(); +} + + +// +// Given the established master secret, decode the working keys and other +// functional secrets for this database. Return false (do NOT throw) if +// the decode fails. Call this in low(er) level code once you established +// the master key. +// +bool Database::decode() +{ + assert(mBlob); + assert(common->hasMaster()); + void *privateAclBlob; + if (common->unlock(mBlob, &privateAclBlob)) { + if (!mValidData) { + importBlob(mBlob->publicAclBlob(), privateAclBlob); + mValidData = true; + } + CssmAllocator::standard().free(privateAclBlob); + return true; + } + secdebug("SSdb", "%p decode failed", this); + return false; +} + + +// +// Given an AccessCredentials for this database, wring out the existing primary +// database secret by whatever means necessary. +// On entry, caller must hold the database common lock. It will be held throughout. +// On exit, the crypto core has its master secret. If things go wrong, +// we will throw a suitable exception. Note that encountering any malformed +// credential sample will throw, but this is not guaranteed -- don't assume +// that NOT throwing means creds is entirely well-formed. +// +// How this works: +// Walk through the creds. Fish out those credentials (in order) that +// are for unlock processing (they have no ACL subject correspondents), +// and (try to) obey each in turn, until one produces a valid secret +// or you run out. If no special samples are found at all, interpret that as +// "use the system global default," which happens to be hard-coded right here. +// +void Database::establishOldSecrets(const AccessCredentials *creds) +{ + list samples; + if (creds && creds->samples().collect(CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK, samples)) { + for (list::iterator it = samples.begin(); it != samples.end(); it++) { + TypedList &sample = *it; + sample.checkProper(); + switch (sample.type()) { + // interactively prompt the user - no additional data + case CSSM_SAMPLE_TYPE_KEYCHAIN_PROMPT: + { + secdebug("SSdb", "%p attempting interactive unlock", this); + QueryUnlock query(*this); + if (query() == SecurityAgent::noReason) + return; + } + break; + // try to use an explicitly given passphrase - Data:passphrase + case CSSM_SAMPLE_TYPE_PASSWORD: + if (sample.length() != 2) + CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); + secdebug("SSdb", "%p attempting passphrase unlock", this); + if (decode(sample[1])) + return; + break; + // try to open with a given master key - Data:CSP or KeyHandle, Data:CssmKey + case CSSM_WORDID_SYMMETRIC_KEY: + assert(mBlob); + secdebug("SSdb", "%p attempting explicit key unlock", this); + common->setup(mBlob, keyFromCreds(sample)); + if (decode()) + return; + break; + // explicitly defeat the default action but don't try anything in particular + case CSSM_WORDID_CANCELED: + secdebug("SSdb", "%p defeat default action", this); + break; + default: + // Unknown sub-sample for unlocking. + // If we wanted to be fascist, we could now do + // CssmError::throwMe(CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED); + // But instead we try to be tolerant and continue on. + // This DOES however count as an explicit attempt at specifying unlock, + // so we will no longer try the default case below... + secdebug("SSdb", "%p unknown sub-sample unlock (%ld) ignored", this, sample.type()); + break; + } + } + } else { + // default action assert(mBlob); - void *privateAclBlob; - if (common->unlock(mBlob, passphrase, &privateAclBlob)) { - if (!mValidData) { - importBlob(mBlob->publicAclBlob(), privateAclBlob); - mValidData = true; + SystemKeychainKey systemKeychain(kSystemUnlockFile); + if (systemKeychain.matches(mBlob->randomSignature)) { + secdebug("SSdb", "%p attempting system unlock", this); + common->setup(mBlob, CssmClient::Key(Server::csp(), systemKeychain.key(), true)); + if (decode()) + return; + } + + QueryUnlock query(*this); + if (query() == SecurityAgent::noReason) + return; + } + + // out of options - no secret obtained + CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); +} + + +// +// Same thing, but obtain a new secret somehow and set it into the common. +// +void Database::establishNewSecrets(const AccessCredentials *creds, SecurityAgent::Reason reason) +{ + list samples; + if (creds && creds->samples().collect(CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK, samples)) { + for (list::iterator it = samples.begin(); it != samples.end(); it++) { + TypedList &sample = *it; + sample.checkProper(); + switch (sample.type()) { + // interactively prompt the user + case CSSM_SAMPLE_TYPE_KEYCHAIN_PROMPT: + { + secdebug("SSdb", "%p specified interactive passphrase", this); + QueryNewPassphrase query(*this, reason); + CssmAutoData passphrase(CssmAllocator::standard(CssmAllocator::sensitive)); + if (query(passphrase) == SecurityAgent::noReason) { + common->setup(NULL, passphrase); + return; + } + } + break; + // try to use an explicitly given passphrase + case CSSM_SAMPLE_TYPE_PASSWORD: + secdebug("SSdb", "%p specified explicit passphrase", this); + if (sample.length() != 2) + CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); + common->setup(NULL, sample[1]); + return; + // try to open with a given master key + case CSSM_WORDID_SYMMETRIC_KEY: + secdebug("SSdb", "%p specified explicit master key", this); + common->setup(NULL, keyFromCreds(sample)); + return; + // explicitly defeat the default action but don't try anything in particular + case CSSM_WORDID_CANCELED: + secdebug("SSdb", "%p defeat default action", this); + break; + default: + // Unknown sub-sample for acquiring new secret. + // If we wanted to be fascist, we could now do + // CssmError::throwMe(CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED); + // But instead we try to be tolerant and continue on. + // This DOES however count as an explicit attempt at specifying unlock, + // so we will no longer try the default case below... + secdebug("SSdb", "%p unknown sub-sample acquisition (%ld) ignored", + this, sample.type()); + break; } - CssmAllocator::standard().free(privateAclBlob); - return true; + } + } else { + // default action -- interactive (only) + QueryNewPassphrase query(*this, reason); + CssmAutoData passphrase(CssmAllocator::standard(CssmAllocator::sensitive)); + if (query(passphrase) == SecurityAgent::noReason) { + common->setup(NULL, passphrase); + return; } } - return false; + + // out of options - no secret obtained + CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); +} + + +// +// Given a (truncated) Database credentials TypedList specifying a master key, +// locate the key and return a reference to it. +// +CssmClient::Key Database::keyFromCreds(const TypedList &sample) +{ + // decode TypedList structure (sample type; Data:CSPHandle; Data:CSSM_KEY) + assert(sample.type() == CSSM_WORDID_SYMMETRIC_KEY); + if (sample.length() != 3 + || sample[1].type() != CSSM_LIST_ELEMENT_DATUM + || sample[2].type() != CSSM_LIST_ELEMENT_DATUM) + CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); + CSSM_CSP_HANDLE &handle = *sample[1].data().interpretedAs(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); + CssmKey &key = *sample[2].data().interpretedAs(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); + + if (key.header().cspGuid() == gGuidAppleCSPDL) { + // handleOrKey is a SecurityServer KeyHandle; ignore key argument + return Server::key(handle); + } else { + // not a KeyHandle reference; use key as a raw key + if (key.header().blobType() != CSSM_KEYBLOB_RAW) + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_REFERENCE); + if (key.header().keyClass() != CSSM_KEYCLASS_SESSION_KEY) + CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_CLASS); + return CssmClient::Key(Server::csp(), key, true); + } } // // Verify a putative database passphrase. -// This requires that the database be already unlocked; -// it will not unlock the database (and will not lock it -// if the proffered phrase is wrong). +// If the database is already unlocked, just check the passphrase. +// Otherwise, unlock with that passphrase and report success. +// Caller must hold the common lock. // bool Database::validatePassphrase(const CssmData &passphrase) const { - assert(!isLocked()); - return passphrase == common->passphrase; + if (common->hasMaster()) { + // verify against known secret + return common->validatePassphrase(passphrase); + } else { + // no master secret - perform "blind" unlock to avoid actual unlock + try { + DatabaseCryptoCore test; + test.setup(mBlob, passphrase); + test.decodeCore(mBlob, NULL); + return true; + } catch (...) { + return false; + } + } } @@ -329,7 +586,7 @@ bool Database::validatePassphrase(const CssmData &passphrase) const // void Database::lock() { - common->lock(); + common->lock(false); } @@ -338,10 +595,9 @@ void Database::lock() // This is an interim stop-gap measure, until we can work out how database // state should interact with true multi-session operation. // -void Database::lockAllDatabases(bool forSleep) +void Database::lockAllDatabases(CommonMap &commons, bool forSleep) { - StLock _(commonLock); // hold all changes to Common map - debug("SSdb", "locking all %d known databases", int(commons.size())); + StLock _(commons); // hold all changes to Common map for (CommonMap::iterator it = commons.begin(); it != commons.end(); it++) it->second->lock(true, forSleep); // lock, already holding commonLock } @@ -352,7 +608,7 @@ void Database::lockAllDatabases(bool forSleep) // KeyBlob *Database::encodeKey(const CssmKey &key, const CssmData &pubAcl, const CssmData &privAcl) { - makeUnlocked(); + unlock(); // tell the cryptocore to form the key blob return common->encodeKeyCore(key, pubAcl, privAcl); @@ -363,10 +619,9 @@ KeyBlob *Database::encodeKey(const CssmKey &key, const CssmData &pubAcl, const C // Given a "blobbed" key for this database, decode it into its real // key object and (re)populate its ACL. // -void Database::decodeKey(KeyBlob *blob, CssmKey &key, - void * &pubAcl, void * &privAcl) +void Database::decodeKey(KeyBlob *blob, CssmKey &key, void * &pubAcl, void * &privAcl) { - makeUnlocked(); // we need our keys + unlock(); // we need our keys common->decodeKeyCore(blob, key, pubAcl, privAcl); // memory protocol: pubAcl points into blob; privAcl was allocated @@ -385,6 +640,8 @@ void Database::setParameters(const DBParameters ¶ms) common->mParams = params; common->version++; // invalidate old blobs activity(); + secdebug("SSdb", "%p common %p(%s) set params=(%ld,%d)", + this, common, dbName(), params.idleTimeout, params.lockOnSleep); } @@ -409,7 +666,7 @@ void Database::instantiateAcl() makeUnlocked(); } -void Database::noticeAclChange() +void Database::changedAcl() { StLock _(*common); version = 0; @@ -453,44 +710,66 @@ void Database::debugDump(const char *msg) // // Database::Common basic features // -Database::Common::Common(const DbIdentifier &id) -: mIdentifier(id), sequence(0), passphrase(CssmAllocator::standard(CssmAllocator::sensitive)), - useCount(0), version(1), - mIsLocked(true) +Database::Common::Common(const DbIdentifier &id, CommonMap &commonPool) +: pool(commonPool), mIdentifier(id), sequence(0), useCount(0), version(1), + mIsLocked(true), mValidParams(false) { } Database::Common::~Common() { // explicitly unschedule ourselves Server::active().clearTimer(this); + pool.erase(identifier()); +} + + +void Database::Common::makeNewSecrets() +{ + // we already have a master key (right?) + assert(hasMaster()); + + // tell crypto core to generate the use keys + DatabaseCryptoCore::generateNewSecrets(); + + // we're now officially "unlocked"; set the timer + mIsLocked = false; + activity(); } void Database::discard(Common *common) { - // LOCKING: commonLock held, *common NOT held - debug("SSdb", "discarding dbcommon %p (no users, locked)", common); - commons.erase(common->identifier()); + // LOCKING: pool lock held, *common NOT held + secdebug("SSdb", "discarding dbcommon %p (no users, locked)", common); delete common; } -bool Database::Common::unlock(DbBlob *blob, const CssmData &passphrase, - void **privateAclBlob) + +// +// All unlocking activity ultimately funnels through this method. +// This unlocks a Common using the secrets setup in its crypto core +// component, and performs all the housekeeping needed to represent +// the state change. +// +bool Database::Common::unlock(DbBlob *blob, void **privateAclBlob) { try { // Tell the cryptocore to (try to) decode itself. This will fail // in an astonishing variety of ways if the passphrase is wrong. - decodeCore(blob, passphrase, privateAclBlob); + assert(hasMaster()); + decodeCore(blob, privateAclBlob); + secdebug("SSdb", "%p unlock successful", this); } catch (...) { - //@@@ which errors should we let through? Any? + secdebug("SSdb", "%p unlock failed", this); return false; } - - // save the passphrase (we'll need it for database encoding) - this->passphrase = passphrase; - // retrieve some public arguments - mParams = blob->params; + // get the database parameters only if we haven't got them yet + if (!mValidParams) { + mParams = blob->params; + n2hi(mParams.idleTimeout); + mValidParams = true; // sticky + } // now successfully unlocked mIsLocked = false; @@ -500,29 +779,10 @@ bool Database::Common::unlock(DbBlob *blob, const CssmData &passphrase, // broadcast unlock notification KeychainNotifier::unlock(identifier()); - notify(unlockedEvent); return true; } -// -// Fast-path unlock: secrets already valid; just check passphrase and approve. -// -bool Database::Common::unlock(const CssmData &passphrase) -{ - assert(isValid()); - if (isLocked()) { - if (passphrase == this->passphrase) { - mIsLocked = false; - KeychainNotifier::unlock(identifier()); - notify(unlockedEvent); - return true; // okay - } else - return false; // failed - } else - return true; // was unlocked; no problem -} - void Database::Common::lock(bool holdingCommonLock, bool forSleep) { StLock locker(*this); @@ -530,13 +790,13 @@ void Database::Common::lock(bool holdingCommonLock, bool forSleep) if (forSleep && !mParams.lockOnSleep) return; // it doesn't want to - //@@@ discard secrets here? That would make fast-path impossible. mIsLocked = true; + DatabaseCryptoCore::invalidate(); KeychainNotifier::lock(identifier()); - notify(lockedEvent); + Server::active().clearTimer(this); // if no database refers to us now, we're history - StLock _(commonLock, false); + StLock _(pool, false); if (!holdingCommonLock) _.lock(); if (useCount == 0) { @@ -559,7 +819,10 @@ DbBlob *Database::Common::encode(Database &db) form.randomSignature = identifier(); form.sequence = sequence; form.params = mParams; - DbBlob *blob = encodeCore(form, passphrase, pubAcl, privAcl); + h2ni(form.params.idleTimeout); + + assert(hasMaster()); + DbBlob *blob = encodeCore(form, pubAcl, privAcl); // clean up and go db.allocator.free(pubAcl); @@ -569,53 +832,77 @@ DbBlob *Database::Common::encode(Database &db) // -// Send out database-related notifications +// Perform deferred lock processing for a database. // -void Database::Common::notify(Listener::Event event) +void Database::Common::action() { - IFDEBUG(debug("SSdb", "common %s(%p) sending event %ld", dbName(), this, event)); - DLDbFlatIdentifier flatId(mIdentifier); // walkable form of DLDbIdentifier - CssmAutoData data(CssmAllocator::standard()); - copy(&flatId, CssmAllocator::standard(), data.get()); - Listener::notify(Listener::databaseNotifications, event, data); + secdebug("SSdb", "common %s(%p) locked by timer (%d refs)", + dbName(), this, int(useCount)); + lock(false); +} + +void Database::Common::activity() +{ + if (!isLocked()) + Server::active().setTimer(this, Time::Interval(int(mParams.idleTimeout))); } // -// Initialize a (new) database's key information. -// This acquires the passphrase in the appropriate way. -// When (successfully) done, the database is in the unlocked state. +// Implementation of a "system keychain unlock key store" // -void Database::Common::setupKeys(const AccessCredentials *cred) +SystemKeychainKey::SystemKeychainKey(const char *path) + : mPath(path) { - // get the new passphrase - // @@@ Un-staged version of the API - revise with acceptability tests - Process &cltProc = Server::active().connection().process; - IFDEBUG(debug("SSdb", "New passphrase request from process %d (UID %d)", cltProc.pid(), cltProc.uid())); - QueryNewPassphrase query(cltProc.uid(), cltProc.session, *this, SecurityAgent::newDatabase); - query(cred, passphrase); - - // we have the passphrase now - generateNewSecrets(); - - // we're unlocked now - mIsLocked = false; - activity(); + // explicitly set up a key header for a raw 3DES key + CssmKey::Header &hdr = mKey.header(); + hdr.blobType(CSSM_KEYBLOB_RAW); + hdr.blobFormat(CSSM_KEYBLOB_RAW_FORMAT_OCTET_STRING); + hdr.keyClass(CSSM_KEYCLASS_SESSION_KEY); + hdr.algorithm(CSSM_ALGID_3DES_3KEY_EDE); + hdr.KeyAttr = 0; + hdr.KeyUsage = CSSM_KEYUSE_ANY; + mKey = CssmData::wrap(mBlob.masterKey); } +SystemKeychainKey::~SystemKeychainKey() +{ +} -// -// Perform deferred lock processing for a database. -// -void Database::Common::action() +bool SystemKeychainKey::matches(const DbBlob::Signature &signature) { - IFDEBUG(debug("SSdb", "common %s(%p) locked by timer (%d refs)", - dbName(), this, int(useCount))); - lock(); + return update() && signature == mBlob.signature; } -void Database::Common::activity() +bool SystemKeychainKey::update() { - if (!isLocked()) - Server::active().setTimer(this, int(mParams.idleTimeout)); + // if we checked recently, just assume it's okay + if (mUpdateThreshold > Time::now()) + return mValid; + + // check the file + struct stat st; + if (::stat(mPath.c_str(), &st)) { + // something wrong with the file; can't use it + mUpdateThreshold = Time::now() + Time::Interval(checkDelay); + return mValid = false; + } + if (mValid && Time::Absolute(st.st_mtimespec) == mCachedDate) + return true; + mUpdateThreshold = Time::now() + Time::Interval(checkDelay); + + try { + secdebug("syskc", "reading system unlock record from %s", mPath.c_str()); + AutoFileDesc fd(mPath, O_RDONLY); + if (fd.read(mBlob) != sizeof(mBlob)) + return false; + if (mBlob.isValid()) { + mCachedDate = st.st_mtimespec; + return mValid = true; + } else + return mValid = false; + } catch (...) { + secdebug("syskc", "system unlock record not available"); + return false; + } } diff --git a/SecurityServer/xdatabase.h b/SecurityServer/xdatabase.h index b2b333d6..2446f667 100644 --- a/SecurityServer/xdatabase.h +++ b/SecurityServer/xdatabase.h @@ -30,7 +30,8 @@ #include #include #include -#include +#include "SecurityAgentClient.h" +#include #include #include @@ -85,6 +86,10 @@ public: DLDbIdentifier mIdent; Signature mSig; }; + +public: + class CommonMap : public map, public Mutex { + }; public: // @@ -96,41 +101,39 @@ public: // class Common : public DatabaseCryptoCore, public MachServer::Timer, public Mutex { public: - Common(const DbIdentifier &id); + Common(const DbIdentifier &id, CommonMap &pool); ~Common(); - bool unlock(DbBlob *blob, const CssmData &passphrase, - void **privateAclBlob = NULL); - bool unlock(const CssmData &passphrase); - void lock(bool holdingCommonLock = false, bool forSleep = false); // versatile lock primitive + bool unlock(DbBlob *blob, void **privateAclBlob = NULL); + void lock(bool holdingCommonLock, bool forSleep = false); // versatile lock primitive bool isLocked() const { return mIsLocked; } // lock status void activity(); // reset lock timeout + void makeNewSecrets(); + const DbIdentifier &identifier() const {return mIdentifier; } const DLDbIdentifier &dlDbIdent() const { return identifier(); } const char *dbName() const { return dlDbIdent().dbName(); } DbBlob *encode(Database &db); - void setupKeys(const AccessCredentials *cred); - - void notify(Listener::Event event); protected: void action(); // timer queue action to lock keychain public: + CommonMap &pool; // the CommonMap we belong to + DbIdentifier mIdentifier; // database external identifier [const] // all following data locked with object lock uint32 sequence; // change sequence number DBParameters mParams; // database parameters (arbitrated copy) - - CssmAutoData passphrase; // passphrase if available, or NULL data uint32 useCount; // database sessions we belong to uint32 version; // version stamp for change tracking private: bool mIsLocked; // database is LOGICALLY locked + bool mValidParams; // mParams has been set }; const DbIdentifier &identifier() const { return common->identifier(); } @@ -138,27 +141,34 @@ public: public: // encoding/decoding databases - DbBlob *encode(); + DbBlob *blob(); Database(const DLDbIdentifier &id, const DbBlob *blob, Process &proc, const AccessCredentials *cred); void authenticate(const AccessCredentials *cred); void changePassphrase(const AccessCredentials *cred); + Key *extractMasterKey(Database *db, + const AccessCredentials *cred, const AclEntryPrototype *owner, + uint32 usage, uint32 attrs); + void getDbIndex(CssmData &indexData); // lock/unlock processing void lock(); // unconditional lock void unlock(); // full-feature unlock void unlock(const CssmData &passphrase); // unlock with passphrase - bool decode(const CssmData &passphrase); // try unlock/don't fail - bool validatePassphrase(const CssmData &passphrase) const; // validate passphrase (no status change) + + bool decode(); // unlock given established master key + bool decode(const CssmData &passphrase); // set master key from PP, try unlock + + bool validatePassphrase(const CssmData &passphrase) const; // nonthrowing validation bool isLocked() const { return common->isLocked(); } // lock status void activity() const { common->activity(); } // reset timeout clock - static void lockAllDatabases(bool forSleep = false); // lock them all + static void lockAllDatabases(CommonMap &commons, bool forSleep = false); // lock all in session // encoding/decoding keys void decodeKey(KeyBlob *blob, CssmKey &key, void * &pubAcl, void * &privAcl); KeyBlob *encodeKey(const CssmKey &key, const CssmData &pubAcl, const CssmData &privAcl); - + bool validBlob() const { return mBlob && version == common->version; } // manage database parameters @@ -167,19 +177,25 @@ public: // ACL state management hooks void instantiateAcl(); - void noticeAclChange(); + void changedAcl(); const Database *relatedDatabase() const; // "self", for SecurityServerAcl's sake - - // notifications - void notify(Listener::Event event) { common->notify(event); } // debugging IFDUMP(void debugDump(const char *msg)); protected: void makeUnlocked(); // interior version of unlock() + void makeUnlocked(const AccessCredentials *cred); // like () with explicit cred void makeUnlocked(const CssmData &passphrase); // interior version of unlock(CssmData) - static void discard(Common *common); + + void establishOldSecrets(const AccessCredentials *creds); + void establishNewSecrets(const AccessCredentials *creds, SecurityAgent::Reason reason); + + static CssmClient::Key keyFromCreds(const TypedList &sample); + + void encode(); // (re)generate mBlob if needed + + static void discard(Common *common); // safely kill a Common private: Common *common; // shared features of all instances of this database [const] @@ -191,14 +207,33 @@ private: DbBlob *mBlob; // database blob (encoded) AccessCredentials *mCred; // local access credentials (always valid) - -private: - // @@@ Arguably, this should be a member of the Server or Session. - // @@@ If we do this, encapsulate it as a DatabaseMap object of sorts. - static Mutex commonLock; // lock for commons map (only) - typedef map CommonMap; - static CommonMap commons; // map of extant database objects }; +// +// This class implements a "system keychaiin unlock record" store +// +class SystemKeychainKey { +public: + SystemKeychainKey(const char *path); + ~SystemKeychainKey(); + + bool matches(const DbBlob::Signature &signature); + CssmKey &key() { return mKey; } + +private: + std::string mPath; // path to file + CssmKey mKey; // proper CssmKey with data in mBlob + + bool mValid; // mBlob was validly read from mPath + UnlockBlob mBlob; // contents of mPath as last read + + Time::Absolute mCachedDate; // modify date of file when last read + Time::Absolute mUpdateThreshold; // cutoff threshold for checking again + + static const int checkDelay = 1; // seconds minimum delay between update checks + + bool update(); +}; + #endif //_H_DATABASE diff --git a/cdsa/CVSVersionInfo.txt b/cdsa/CVSVersionInfo.txt index e90e0480..dbee6b90 100644 --- a/cdsa/CVSVersionInfo.txt +++ b/cdsa/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:53 mb Exp $ -# $Name: Security-54~1~9 $ +# $Name: $ ProjectName: cdsa ProjectVersion: 21 diff --git a/cdsa/cdsa/certextensions.h b/cdsa/cdsa/certextensions.h index e1b8e6b7..74a5b3a3 100644 --- a/cdsa/cdsa/certextensions.h +++ b/cdsa/cdsa/certextensions.h @@ -34,22 +34,33 @@ ***/ /* - * GeneralName, used in AuthorityKeyID and SubjectAltName. + * GeneralName, used in AuthorityKeyID, SubjectAltName, and + * IssuerAltName. * * For now, we just provide explicit support for the types which are * represented as IA5Strings, OIDs, and octet strings. Constructed types * such as EDIPartyName and x400Address are not explicitly handled - * right now and must be encoded and decoded by the caller. In those - * cases the CE_GeneralName.name.Data field represents the BER contents - * octets; CE_GeneralName.name,Length is the length of the contents; the - * tag of the field is not needed - the BER encoding uses context-specific - * implicit tagging. The berEncoded field is set to CSSM_TRUE in these - * case. Simple types have berEncoded = CSSM_FALS. + * right now and must be encoded and decoded by the caller. (See exception + * for Name and OtherName, below). In those cases the CE_GeneralName.name.Data field + * represents the BER contents octets; CE_GeneralName.name.Length is the + * length of the contents; the tag of the field is not needed - the BER + * encoding uses context-specific implicit tagging. The berEncoded field + * is set to CSSM_TRUE in these case. Simple types have berEncoded = CSSM_FALSE. + * + * In the case of a GeneralName in the form of a Name, we parse the Name + * into a CSSM_X509_NAME and place a pointer to the CSSM_X509_NAME in the + * CE_GeneralName.name.Data field. CE_GeneralName.name.Length is set to + * sizeof(CSSM_X509_NAME). In this case berEncoded is false. + * + * In the case of a GeneralName in the form of a OtherName, we parse the fields + * into a CE_OtherName and place a pointer to the CE_OtherName in the + * CE_GeneralName.name.Data field. CE_GeneralName.name.Length is set to + * sizeof(CE_OtherName). In this case berEncoded is false. * * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName * * GeneralName ::= CHOICE { - * otherName [0] OtherName (i.e., OID), + * otherName [0] OtherName * rfc822Name [1] IA5String, * dNSName [2] IA5String, * x400Address [3] ORAddress, @@ -79,6 +90,11 @@ typedef enum { GNT_RegisteredID } CE_GeneralNameType; +typedef struct { + CSSM_OID typeId; + CSSM_DATA value; // unparsed, BER-encoded +} CE_OtherName; + typedef struct { CE_GeneralNameType nameType; // GNT_RFC822Name, etc. CSSM_BOOL berEncoded; @@ -148,6 +164,35 @@ typedef uint16 CE_KeyUsage; #define CE_KU_EncipherOnly 0x0100 #define CE_KU_DecipherOnly 0x0080 +/* + * id-ce-cRLReason OBJECT IDENTIFIER ::= { id-ce 21 } + * + * -- reasonCode ::= { CRLReason } + * + * CRLReason ::= ENUMERATED { + * unspecified (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6), + * removeFromCRL (8) } + * + * CSSM OID = CSSMOID_CrlReason + * + */ +typedef uint32 CE_CrlReason; + +#define CE_CR_Unspecified 0 +#define CE_CR_KeyCompromise 1 +#define CE_CR_CACompromise 2 +#define CE_CR_AffiliationChanged 3 +#define CE_CR_Superseded 4 +#define CE_CR_CessationOfOperation 5 +#define CE_CR_CertificateHold 6 +#define CE_CR_RemoveFromCRL 8 + /* * id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } * @@ -235,7 +280,7 @@ typedef struct { * * We only support down to the level of Qualifier, and then only the CPSuri * choice. UserNotice is transmitted to and from this library as a raw - * CSSM_DATA representing the Contents octets of the BER-encoded UserNotice sequence. + * CSSM_DATA containing the BER-encoded UserNotice sequence. */ typedef struct { @@ -264,6 +309,128 @@ typedef struct { */ typedef uint16 CE_NetscapeCertType; +/* + * CRLDistributionPoints. + * + * id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= { id-ce 31 } + * + * cRLDistributionPoints ::= { + * CRLDistPointsSyntax } + * + * CRLDistPointsSyntax ::= SEQUENCE SIZE (1..MAX) OF DistributionPoint + * + * NOTE: RFC 2459 claims that the tag for the optional DistributionPointName + * is IMPLICIT as shown here, but in practice it is EXPLICIT. It has to be - + * because the underlying type also uses an implicit tag for distinguish + * between CHOICEs. + * + * DistributionPoint ::= SEQUENCE { + * distributionPoint [0] DistributionPointName OPTIONAL, + * reasons [1] ReasonFlags OPTIONAL, + * cRLIssuer [2] GeneralNames OPTIONAL } + * + * DistributionPointName ::= CHOICE { + * fullName [0] GeneralNames, + * nameRelativeToCRLIssuer [1] RelativeDistinguishedName } + * + * ReasonFlags ::= BIT STRING { + * unused (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6) } + * + * CSSM OID = CSSMOID_CrlDistributionPoints + */ + +/* + * Note that this looks similar to CE_CrlReason, but that's an enum and this + * is an OR-able bit string. + */ +typedef uint8 CE_CrlDistReasonFlags; + +#define CE_CD_Unspecified 0x80 +#define CE_CD_KeyCompromise 0x40 +#define CE_CD_CACompromise 0x20 +#define CE_CD_AffiliationChanged 0x10 +#define CE_CD_Superseded 0x08 +#define CE_CD_CessationOfOperation 0x04 +#define CE_CD_CertificateHold 0x02 + +typedef enum { + CE_CDNT_FullName, + CE_CDNT_NameRelativeToCrlIssuer +} CE_CrlDistributionPointNameType; + +typedef struct { + CE_CrlDistributionPointNameType nameType; + union { + CE_GeneralNames *fullName; + CSSM_X509_RDN_PTR rdn; + }; +} CE_DistributionPointName; + +/* + * The top-level CRLDistributionPoint. + * All fields are optional; NULL pointers indicate absence. + */ +typedef struct { + CE_DistributionPointName *distPointName; + CSSM_BOOL reasonsPresent; + CE_CrlDistReasonFlags reasons; + CE_GeneralNames *crlIssuer; +} CE_CRLDistributionPoint; + +typedef struct { + uint32 numDistPoints; + CE_CRLDistributionPoint *distPoints; +} CE_CRLDistPointsSyntax; + + +/*** CRL extensions ***/ + +/* + * cRLNumber, an integer. + * + * CSSM OID = CSSMOID_CrlNumber + */ +typedef uint32 CE_CrlNumber; + +/* + * deltaCRLIndicator, an integer. + * + * CSSM OID = CSSMOID_DeltaCrlIndicator + */ +typedef uint32 CE_DeltaCrl; + +/* + * IssuingDistributionPoint + * + * id-ce-issuingDistributionPoint OBJECT IDENTIFIER ::= { id-ce 28 } + * + * issuingDistributionPoint ::= SEQUENCE { + * distributionPoint [0] DistributionPointName OPTIONAL, + * onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE, + * onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE, + * onlySomeReasons [3] ReasonFlags OPTIONAL, + * indirectCRL [4] BOOLEAN DEFAULT FALSE } + * + * CSSM OID = CSSMOID_IssuingDistributionPoint + */ +typedef struct { + CE_DistributionPointName *distPointName; // optional + CSSM_BOOL onlyUserCertsPresent; + CSSM_BOOL onlyUserCerts; + CSSM_BOOL onlyCACertsPresent; + CSSM_BOOL onlyCACerts; + CSSM_BOOL onlySomeReasonsPresent; + CE_CrlDistReasonFlags onlySomeReasons; + CSSM_BOOL indirectCrlPresent; + CSSM_BOOL indirectCrl; +} CE_IssuingDistributionPoint; + /* * An enumerated list identifying one of the above per-extension * structs. @@ -273,26 +440,38 @@ typedef enum { DT_SubjectKeyID, // CE_SubjectKeyID DT_KeyUsage, // CE_KeyUsage DT_SubjectAltName, // implies CE_GeneralName + DT_IssuerAltName, // implies CE_GeneralName DT_ExtendedKeyUsage, // CE_ExtendedKeyUsage DT_BasicConstraints, // CE_BasicConstraints DT_CertPolicies, // CE_CertPolicies DT_NetscapeCertType, // CE_NetscapeCertType + DT_CrlNumber, // CE_CrlNumber + DT_DeltaCrl, // CE_DeltaCrl + DT_CrlReason, // CE_CrlReason + DT_CrlDistributionPoints, // CE_CRLDistPointsSyntax + DT_IssuingDistributionPoint,// CE_IssuingDistributionPoint DT_Other // unknown, raw data as a CSSM_DATA } CE_DataType; /* - * One unified representation of all the cert extensions we know about. + * One unified representation of all the cert adn CRL extensions we know about. */ typedef union { - CE_AuthorityKeyID authorityKeyID; - CE_SubjectKeyID subjectKeyID; - CE_KeyUsage keyUsage; - CE_GeneralNames subjectAltName; - CE_ExtendedKeyUsage extendedKeyUsage; - CE_BasicConstraints basicConstraints; - CE_CertPolicies certPolicies; - CE_NetscapeCertType netscapeCertType; - CSSM_DATA rawData; // unknown, not decoded + CE_AuthorityKeyID authorityKeyID; + CE_SubjectKeyID subjectKeyID; + CE_KeyUsage keyUsage; + CE_GeneralNames subjectAltName; + CE_GeneralNames issuerAltName; + CE_ExtendedKeyUsage extendedKeyUsage; + CE_BasicConstraints basicConstraints; + CE_CertPolicies certPolicies; + CE_NetscapeCertType netscapeCertType; + CE_CrlNumber crlNumber; + CE_DeltaCrl deltaCrl; + CE_CrlReason crlReason; + CE_CRLDistPointsSyntax crlDistPoints; + CE_IssuingDistributionPoint issuingDistPoint; + CSSM_DATA rawData; // unknown, not decoded } CE_Data; typedef struct { diff --git a/cdsa/cdsa/cssmapple.h b/cdsa/cdsa/cssmapple.h index c166ac19..7cc78f6d 100644 --- a/cdsa/cdsa/cssmapple.h +++ b/cdsa/cdsa/cssmapple.h @@ -27,7 +27,7 @@ #include #include -#include /* for CSSM_APPLE_ROOT_CERT_REQUEST fields */ +#include /* for CSSM_APPLE_TP_CERT_REQUEST fields */ #include /* ditto */ #include /* for the BSD *_t types */ @@ -64,6 +64,8 @@ enum CSSM_WORDID_KEYCHAIN_CHANGE_LOCK, CSSM_WORDID_PROCESS, CSSM_WORDID__RESERVED_1, // was used in 10.2 test seeds; no longer in use + CSSM_WORDID_SYMMETRIC_KEY, + CSSM_WORDID_SYSTEM, CSSM_WORDID__FIRST_UNUSED }; @@ -149,9 +151,24 @@ enum CSSM_ALGID_FEEDEXP, /* 2:1 FEE asymmetric encryption */ CSSM_ALGID_ASC, /* Apple Secure Compression */ CSSM_ALGID_SHA1HMAC_LEGACY, /* HMAC/SHA1, legacy compatible */ + CSSM_ALGID_KEYCHAIN_KEY, /* derive or manipulate keychain master keys */ + CSSM_ALGID_PKCS12_PBE_ENCR, /* PKCS12, encrypt/decrypt key */ + CSSM_ALGID_PKCS12_PBE_MAC, /* PKCS12, MAC key */ CSSM_ALGID__FIRST_UNUSED }; +/* Apple defined keyblob formats */ +enum { + CSSM_KEYBLOB_RAW_FORMAT_VENDOR_DEFINED = 0x80000000 +}; +enum { + /* X509 SubjectPublicKeyInfo */ + CSSM_KEYBLOB_RAW_FORMAT_X509 = CSSM_KEYBLOB_RAW_FORMAT_VENDOR_DEFINED, + /* openssh */ + CSSM_KEYBLOB_RAW_FORMAT_OPENSSH, + /* openssl-style DSA private key */ + CSSM_KEYBLOB_RAW_FORMAT_OPENSSL +}; /* Apple adds some "common" error codes. CDSA does not define an official start value for this. */ enum @@ -160,7 +177,8 @@ enum CSSM_ERRCODE_NO_USER_INTERACTION = 0x00e0, CSSM_ERRCODE_USER_CANCELED = 0x00e1, - CSSM_ERRCODE_SERVICE_NOT_AVAILABLE = 0x00e2 + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE = 0x00e2, + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION = 0x00e3 }; enum { @@ -183,12 +201,31 @@ enum { CSSMERR_CSP_SERVICE_NOT_AVAILABLE = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE, CSSMERR_CL_SERVICE_NOT_AVAILABLE = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE, CSSMERR_DL_SERVICE_NOT_AVAILABLE = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE, - CSSMERR_TP_SERVICE_NOT_AVAILABLE = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE + CSSMERR_TP_SERVICE_NOT_AVAILABLE = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE, + + CSSMERR_CSSM_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_CSSM_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION, + CSSMERR_AC_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_AC_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION, + CSSMERR_CSP_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION, + CSSMERR_CL_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION, + CSSMERR_DL_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION, + CSSMERR_TP_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION }; -/* AppleCSPDL private error codes. */ +/* AppleCSPDL, AppleCSP private error codes. */ enum { - CSSMERR_CSP_APPLE_ADD_APPLICATION_ACL_SUBJECT = CSSM_CSP_PRIVATE_ERROR + 0 + CSSMERR_CSP_APPLE_ADD_APPLICATION_ACL_SUBJECT = CSSM_CSP_PRIVATE_ERROR + 0, + /* + * An attempt was made to use a public key which is incomplete due to + * the lack of algorithm-specific parameters. + */ + CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE = CSSM_CSP_PRIVATE_ERROR + 1, + + /* a code signature match failed */ + CSSMERR_CSP_APPLE_SIGNATURE_MISMATCH = CSSM_CSP_PRIVATE_ERROR + 2, + + /* Key StartDate/EndDate invalid */ + CSSMERR_CSP_APPLE_INVALID_KEY_START_DATE = CSSM_CSP_PRIVATE_ERROR + 3, + CSSMERR_CSP_APPLE_INVALID_KEY_END_DATE = CSSM_CSP_PRIVATE_ERROR + 4 }; @@ -201,7 +238,7 @@ enum CSSM_DL_DB_RECORD_X509_CERTIFICATE = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0x1000, CSSM_DL_DB_RECORD_USER_TRUST, - + CSSM_DL_DB_RECORD_X509_CRL, CSSM_DL_DB_RECORD_METADATA = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0x8000 }; @@ -268,28 +305,81 @@ enum CSSMERR_APPLETP_INVALID_ID_LINKAGE = CSSM_TP_PRIVATE_ERROR + 8, /* PathLengthConstraint exceeded */ CSSMERR_APPLETP_PATH_LEN_CONSTRAINT = CSSM_TP_PRIVATE_ERROR + 9, + /* Cert group terminated at a root cert which did not self-verify */ + CSSMERR_APPLETP_INVALID_ROOT = CSSM_TP_PRIVATE_ERROR + 10, + /* CRL expired/not valid yet */ + CSSMERR_APPLETP_CRL_EXPIRED = CSSM_TP_PRIVATE_ERROR + 11, + CSSMERR_APPLETP_CRL_NOT_VALID_YET = CSSM_TP_PRIVATE_ERROR + 12, + /* Can't find appropriate CRL */ + CSSMERR_APPLETP_CRL_NOT_FOUND = CSSM_TP_PRIVATE_ERROR + 13, + /* specified CRL server down */ + CSSMERR_APPLETP_CRL_SERVER_DOWN = CSSM_TP_PRIVATE_ERROR + 14, + /* illegible CRL distribution point URL */ + CSSMERR_APPLETP_CRL_BAD_URI = CSSM_TP_PRIVATE_ERROR + 15, + /* Unknown critical cert/CRL extension */ + CSSMERR_APPLETP_UNKNOWN_CERT_EXTEN = CSSM_TP_PRIVATE_ERROR + 16, + CSSMERR_APPLETP_UNKNOWN_CRL_EXTEN = CSSM_TP_PRIVATE_ERROR + 17, + /* CRL not verifiable to anchor or root */ + CSSMERR_APPLETP_CRL_NOT_TRUSTED = CSSM_TP_PRIVATE_ERROR + 18, + /* CRL verified to untrusted root */ + CSSMERR_APPLETP_CRL_INVALID_ANCHOR_CERT = CSSM_TP_PRIVATE_ERROR + 19, + /* CRL failed policy verification */ + CSSMERR_APPLETP_CRL_POLICY_FAIL = CSSM_TP_PRIVATE_ERROR + 20, + /* IssuingDistributionPoint extension violation */ + CSSMERR_APPLETP_IDP_FAIL = CSSM_TP_PRIVATE_ERROR + 21, + /* Cert not found at specified issuerAltName */ + CSSMERR_APPLETP_CERT_NOT_FOUND_FROM_ISSUER = CSSM_TP_PRIVATE_ERROR + 22, + /* Bad cert obtained from specified issuerAltName */ + CSSMERR_APPLETP_BAD_CERT_FROM_ISSUER = CSSM_TP_PRIVATE_ERROR + 23, + /* S/MIME Email address mismatch */ + CSSMERR_APPLETP_SMIME_EMAIL_ADDRS_NOT_FOUND = CSSM_TP_PRIVATE_ERROR + 24, + /* Appropriate S/MIME ExtendedKeyUsage not found */ + CSSMERR_APPLETP_SMIME_BAD_EXT_KEY_USE = CSSM_TP_PRIVATE_ERROR + 25, + /* S/MIME KeyUsage incompatiblity */ + CSSMERR_APPLETP_SMIME_BAD_KEY_USE = CSSM_TP_PRIVATE_ERROR + 26, + /* S/MIME, cert with KeyUsage flagged !critical */ + CSSMERR_APPLETP_SMIME_KEYUSAGE_NOT_CRITICAL = CSSM_TP_PRIVATE_ERROR + 27, + /* S/MIME, leaf with empty subject name and no email addrs + * in SubjectAltName */ + CSSMERR_APPLETP_SMIME_NO_EMAIL_ADDRS = CSSM_TP_PRIVATE_ERROR + 28, + /* S/MIME, leaf with empty subject name, SubjectAltName + * not critical */ + CSSMERR_APPLETP_SMIME_SUBJ_ALT_NAME_NOT_CRIT = CSSM_TP_PRIVATE_ERROR + 29 }; enum { - CSSM_APPLEDL_OPEN_PARAMETERS_VERSION = 0 + CSSM_APPLEDL_OPEN_PARAMETERS_VERSION = 1 +}; + +enum cssm_appledl_open_parameters_mask +{ + kCSSM_APPLEDL_MASK_MODE = (1 << 0) }; /* Pass a CSSM_APPLEDL_OPEN_PARAMETERS_PTR as the OpenParameters argument to - CSSM_DL_DbCreate or CSSM_DL_DbOpen. */ + CSSM_DL_DbCreate or CSSM_DL_DbOpen. When using this struct, you must zero + out the entire struct before setting any additional parameters to ensure + forward compatibility. */ typedef struct cssm_appledl_open_parameters { uint32 length; /* Should be sizeof(CSSM_APPLEDL_OPEN_PARAMETERS). */ uint32 version; /* Should be CSSM_APPLEDL_OPEN_PARAMETERS_VERSION. */ - /* If no OpenParameters are specified autoCommit is on (!CSSM_FALSE) by default. - When autoCommit is on (!CSSM_FALSE) changes made to the Db are written to disk + /* If no OpenParameters are specified, autoCommit is on (!CSSM_FALSE) by default. + When autoCommit is on (!CSSM_FALSE), changes made to the Db are written to disk before returning from each function. - When autoCommit is off (CSSM_FALSE) changes made to the database are not guaranteed + When autoCommit is off (CSSM_FALSE), changes made to the database are not guaranteed to be written to disk until the Db is closed. This is useful for bulk writes. - Beware that if autoCommit is off changes made in previous calls to the DL might + Be aware that if autoCommit is off, changes made in previous calls to the DL might get rolled back if a new modification operation fails. */ CSSM_BOOL autoCommit; + + /* Mask marking which of the following fields are to be used. */ + uint32 mask; + + /* When calling DbCreate, the initial mode to create the database file with; ignored on DbOpen. You must set the kCSSM_APPLEDL_MASK_MODE bit in mask or mode is ignored. */ + mode_t mode; } CSSM_APPLEDL_OPEN_PARAMETERS, *CSSM_APPLEDL_OPEN_PARAMETERS_PTR; @@ -301,7 +391,7 @@ enum CSSM_APPLECSPDL_DB_LOCK = 0, /* Tell the SecurityServer to unlock the database specified by the DLDBHandle argument. - The InputParameters argument is a CSSM_DATA_PTR containing the password. Or NULL if + The InputParameters argument is a CSSM_DATA_PTR containing the password, or NULL if the SecurityServer should prompt for the password. The OutputParams argument is ignored. The SecurityServer will put up UI (though the SecurityAgent) when this function is called @@ -311,8 +401,8 @@ enum /* Ask the SecurityServer to get the db settings specified for the database specified by the DLDBHandle argument. The settings are returned in the OutputParameters argument. The OutputParameters argument is a pointer to a CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR. - Upon successful completion the AppleCSPDL will have allocated a - CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS structure using the application specified + Upon successful completion, the AppleCSPDL will have allocated a + CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS structure using the application-specified allocators for the DL attachment specified by the DLDBHandle argument. The structure will contain the current database settings for the specified database. The client should free the CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR after it has finished using it. @@ -331,8 +421,8 @@ enum /* Ask the SecurityServer whether the database specified by the DLDBHandle argument is locked. The InputParameters argument is ignored. The OutputParameters argument is a pointer to a CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR. - Upon successful completion the AppleCSPDL will have allocated a - CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS structure using the application specified + Upon successful completion, the AppleCSPDL will have allocated a + CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS structure using the application-specified allocators for the DL attachment specified by the DLDBHandle argument. The structure will contain the current lock status for the specified database. The client should free the CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR after it has finished using it. @@ -344,17 +434,22 @@ enum The InputParameters argument is a const CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS * containing a CSSM_ACCESS_CREDENTIALS * which determines how the password will be changed. If the - accessCredentials are NULL the SecurityAgent will prompt for the old and the new password for the - specified database. If credentials are specified there should be 2 entries. First a 3 element - list containing: + accessCredentials are NULL, the SecurityAgent will prompt for the old and the new password for the + specified database. If credentials are specified, there should be 2 entries: + 1. a 3-element list containing: CSSM_WORDID_KEYCHAIN_LOCK, CSSM_SAMPLE_TYPE_PASSWORD, and the old password. - Second a 3 element list containing: + 2. a 3-element list containing: CSSM_WORDID_KEYCHAIN_CHANGE_LOCK, CSSM_SAMPLE_TYPE_PASSWORD, and the new password. The OutputParams argument is ignored. The SecurityServer might put up UI (though the SecurityAgent) when this function is called. */ CSSM_APPLECSPDL_DB_CHANGE_PASSWORD =5, - + + /* Return the SecurityServer database handle for the database specified by the DLDBHandle */ + CSSM_APPLECSPDL_DB_GET_HANDLE = 6, + + /* Given a CSSM_KEY for the CSPDL, return the SecurityServer key handle */ + CSSM_APPLESCPDL_CSP_GET_KEYHANDLE = 7, /* Given a CSSM_KEY_PTR in any format, obtain the SHA-1 hash of the * associated key blob. @@ -364,6 +459,8 @@ enum CSSM_APPLECSP_KEYDIGEST = 0x100 }; + + /* AppleCSPDL passthough parameters */ typedef struct cssm_applecspdl_db_settings_parameters { @@ -417,6 +514,19 @@ enum { */ CSSM_ATTRIBUTE_ASC_OPTIMIZATION = (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 3)), + + /* + * RSA blinding. Value is integer, nonzero (blinding on) or zero. + */ + CSSM_ATTRIBUTE_RSA_BLINDING = + (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 4)), + + /* + * Additional public key from which to obtain algorithm-specific + * parameters. + */ + CSSM_ATTRIBUTE_PARAM_KEY = + (CSSM_ATTRIBUTE_DATA_KEY | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 5)) }; /* @@ -452,6 +562,17 @@ enum { CSSM_ASC_OPTIMIZE_ASCII, /* optimized for ASCC text, not implemented */ }; +/* + * Apple custom CSSM_KEYATTR_FLAGS. + */ +enum { + /* + * When set, indicates a public key which is incomplete (though + * still valid) due to the lack of algorithm-specific parameters. + */ + CSSM_KEYATTR_PARTIAL = 0x00010000 +}; + /* * Name/OID pair used in CSSM_APPLE_TP_CERT_REQUEST */ @@ -520,6 +641,63 @@ typedef struct { const char *ServerName; // optional } CSSM_APPLE_TP_SSL_OPTIONS; +/* + * Options for X509TP's CSSM_TP_CertGroupVerify for policy + * CSSMOID_APPLE_TP_REVOCATION_CRL. A pointer to, and length of, one + * of these is optionally placed in + * CSSM_TP_VERIFY_CONTEXT.Cred->Policy.PolicyIds[n].FieldValue. + */ +#define CSSM_APPLE_TP_CRL_OPTS_VERSION 0 + +typedef uint32 CSSM_APPLE_TP_CRL_OPT_FLAGS; +enum { + // require CRL verification for each cert; default is "try" + CSSM_TP_ACTION_REQUIRE_CRL_PER_CERT = 0x00000001, + // enable fetch from network + CSSM_TP_ACTION_FETCH_CRL_FROM_NET = 0x00000002 +}; + +typedef struct { + uint32 Version; // CSSM_APPLE_TP_CRL_OPTS_VERSION + CSSM_APPLE_TP_CRL_OPT_FLAGS CrlFlags; + + /* + * When non-NULL, store CRLs fetched from net here. + * This is most likely a pointer to one of the + * CSSM_TP_CALLERAUTH_CONTEXT.DBList entries but that + * is not a strict requirement. + */ + CSSM_DL_DB_HANDLE_PTR crlStore; +} CSSM_APPLE_TP_CRL_OPTIONS; + +/* + * Options for X509TP's CSSM_TP_CertGroupVerify for policy + * CSSMOID_APPLE_TP_SMIME. A pointer to, and length of, one + * of these is optionally placed in + * CSSM_TP_VERIFY_CONTEXT.Cred->Policy.PolicyIds[n].FieldValue. + */ +#define CSSM_APPLE_TP_SMIME_OPTS_VERSION 0 +typedef struct { + uint32 Version; // CSSM_APPLE_TP_SMIME_OPTS_VERSION + + /* + * Intended usage of the leaf cert. The cert's KeyUsage extension, + * if present, must be a superset of this. + */ + CE_KeyUsage IntendedUsage; + + /* + * The email address of the sender. If there is an email address + * in the sender's cert, that email address must match this one. + * Both (email address in the cert, and this one) are optional. + * Expressed as a C string, optionally NULL terminated (i.e., + * SenderEmail[SenderEmailLen - 1] may or may not be NULL). + */ + uint32 SenderEmailLen; + const char *SenderEmail; // optional +} CSSM_APPLE_TP_SMIME_OPTIONS; + + /* * Optional ActionData for all X509TP CertGroupVerify policies. * A pointer to, and length of, one of these is optionally placed in @@ -527,9 +705,10 @@ typedef struct { */ typedef uint32 CSSM_APPLE_TP_ACTION_FLAGS; enum { - CSSM_TP_ACTION_ALLOW_EXPIRED = 0x00000001, // allow expired certs - CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT = 0x00000008, // allow expired roots - /* other flags TBD */ + CSSM_TP_ACTION_ALLOW_EXPIRED = 0x00000001, // allow expired certs + CSSM_TP_ACTION_LEAF_IS_CA = 0x00000002, // first cert is a CA + CSSM_TP_ACTION_FETCH_CERT_FROM_NET = 0x00000004, // enable net fetch of CA cert + CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT = 0x00000008, // allow expired roots }; #define CSSM_APPLE_TP_ACTION_VERSION 0 @@ -552,7 +731,8 @@ enum CSSM_CERT_STATUS_NOT_VALID_YET = 0x00000002, CSSM_CERT_STATUS_IS_IN_INPUT_CERTS = 0x00000004, CSSM_CERT_STATUS_IS_IN_ANCHORS = 0x00000008, - CSSM_CERT_STATUS_IS_ROOT = 0x00000010 + CSSM_CERT_STATUS_IS_ROOT = 0x00000010, + CSSM_CERT_STATUS_IS_FROM_NET = 0x00000020 }; typedef struct { @@ -641,9 +821,37 @@ typedef struct { const char *challengeString; } CSSM_APPLE_CL_CSR_REQUEST; +/* + * When a CRL with no NextUpdate field is encountered, we use this time + * as the NextUpdate attribute when storing in a DB. It represents the + * virtual end of time in CSSM_TIMESTRING form. + */ +#define CSSM_APPLE_CRL_END_OF_TIME "99991231235959" + +/* + * Default filesystem names and locations for SecurityServer features + * (included here for lack of a better place) + */ +#define kKeychainSuffix ".keychain" +#define kSystemKeychainName "System.keychain" +#define kSystemKeychainDir "/Library/Keychains/" +#define kSystemUnlockFile "/var/db/SystemKey" + void cssmPerror(const char *how, CSSM_RETURN error); +/* Convert between CSSM_OID and CSSM_ALGORITHMS */ +bool cssmOidToAlg(const CSSM_OID *oid, CSSM_ALGORITHMS *alg); +const CSSM_OID *cssmAlgToOid(CSSM_ALGORITHMS algId); + +/* + * The MacOS OSStatus space has an embedding for UNIX errno values, similar to + * the way we embed CSSM_RETURN values in OSStatus. These are the base and limit + * values for this embedding. + */ +#define errSecErrnoBase 100000 +#define errSecErrnoLimit 100255 + #ifdef __cplusplus } #endif // __cplusplus diff --git a/cdsa/cdsa/cssmconfig.h b/cdsa/cdsa/cssmconfig.h index e0293978..bd8de875 100644 --- a/cdsa/cdsa/cssmconfig.h +++ b/cdsa/cdsa/cssmconfig.h @@ -49,11 +49,6 @@ typedef UInt32 uint32; typedef UInt16 uint16; typedef UInt8 uint8; -#if 0 -#define CSSM_EXTERN(_type) EXTERN_API_C(_type) -#define CSSM_DEFINE(_type) DEFINE_API_C(_type) -#define CSSM_CALLBACK(_type, _name) CALLBACK_API_C(_type, _name) -#else #define CSSMACI #define CSSMAPI #define CSSMCLI @@ -62,7 +57,6 @@ typedef UInt8 uint8; #define CSSMKRI #define CSSMSPI #define CSSMTPI -#endif #ifdef __cplusplus } diff --git a/cdsa/cdsa/cssmspi.h b/cdsa/cdsa/cssmspi.h index a2f4725a..760f504f 100644 --- a/cdsa/cdsa/cssmspi.h +++ b/cdsa/cdsa/cssmspi.h @@ -121,28 +121,6 @@ CSSM_SPI_ModuleAttach (const CSSM_GUID *ModuleGuid, CSSM_RETURN CSSMSPI CSSM_SPI_ModuleDetach (CSSM_MODULE_HANDLE ModuleHandle); -#if 0 -/* XXX You should call these though the Upcalls structure passed into - moduleattach, --Michael. */ - -/* CSSM Upcalls for Service Provider Modules */ - -CSSM_RETURN CSSMAPI -cssm_CcToHandle (CSSM_CC_HANDLE Cc, - CSSM_MODULE_HANDLE *ModuleHandle); - -CSSM_RETURN CSSMAPI -cssm_GetModuleInfo (CSSM_MODULE_HANDLE Module, - CSSM_GUID_PTR Guid, - CSSM_VERSION_PTR Version, - uint32 *SubServiceId, - CSSM_SERVICE_TYPE *SubServiceType, - CSSM_ATTACH_FLAGS *AttachFlags, - CSSM_KEY_HIERARCHY *KeyHierarchy, - CSSM_API_MEMORY_FUNCS_PTR AttachedMemFuncs, - CSSM_FUNC_NAME_ADDR_PTR FunctionTable, - uint32 NumFunctions); -#endif #ifdef __cplusplus } diff --git a/cdsa/cdsa/cssmtype.h b/cdsa/cdsa/cssmtype.h index 023fb93f..86b1c714 100644 --- a/cdsa/cdsa/cssmtype.h +++ b/cdsa/cdsa/cssmtype.h @@ -1126,7 +1126,7 @@ typedef struct cssm_context_attribute { CSSM_RANGE_PTR Range; CSSM_CRYPTO_DATA_PTR CryptoData; CSSM_VERSION_PTR Version; - CSSM_DL_DB_HANDLE_PTR DLDbHandle; + CSSM_DL_DB_HANDLE_PTR DLDBHandle; struct cssm_kr_profile *KRProfile; } Attribute; } CSSM_CONTEXT_ATTRIBUTE, *CSSM_CONTEXT_ATTRIBUTE_PTR; diff --git a/cdsa/cdsa/oidsalg.h b/cdsa/cdsa/oidsalg.h index bb7c307b..d2267366 100644 --- a/cdsa/cdsa/oidsalg.h +++ b/cdsa/cdsa/oidsalg.h @@ -42,22 +42,54 @@ extern const CSSM_OID CSSMOID_MD4WithRSA, CSSMOID_MD5WithRSA, CSSMOID_SHA1WithRSA, + CSSMOID_SHA1WithRSA_OIW, + CSSMOID_ANSI_DH_PUB_NUMBER, + CSSMOID_ANSI_DH_STATIC, + CSSMOID_ANSI_DH_ONE_FLOW, + CSSMOID_ANSI_DH_EPHEM, + CSSMOID_ANSI_DH_HYBRID1, + CSSMOID_ANSI_DH_HYBRID2, + CSSMOID_ANSI_DH_HYBRID_ONEFLOW, + CSSMOID_ANSI_MQV1, + CSSMOID_ANSI_MQV2, + CSSMOID_ANSI_DH_STATIC_SHA1, + CSSMOID_ANSI_DH_ONE_FLOW_SHA1, + CSSMOID_ANSI_DH_EPHEM_SHA1, + CSSMOID_ANSI_DH_HYBRID1_SHA1, + CSSMOID_ANSI_DH_HYBRID2_SHA1, + CSSMOID_ANSI_MQV1_SHA1, + CSSMOID_ANSI_MQV2_SHA1, + CSSMOID_PKCS3, CSSMOID_DH, - CSSMOID_DSA, - CSSMOID_SHA1WithDSA, + CSSMOID_DSA, // BSAFE only + CSSMOID_DSA_CMS, // X509/CMS + CSSMOID_DSA_JDK, // JDK 1.1 + CSSMOID_SHA1WithDSA, // BSAFE + CSSMOID_SHA1WithDSA_CMS, // X509/CMS + CSSMOID_SHA1WithDSA_JDK, // JDK 1.1 CSSMOID_SHA1, CSSMOID_APPLE_ISIGN, CSSMOID_APPLE_X509_BASIC, CSSMOID_APPLE_TP_SSL, CSSMOID_APPLE_TP_LOCAL_CERT_GEN, CSSMOID_APPLE_TP_CSR_GEN, + CSSMOID_APPLE_TP_REVOCATION_CRL, + CSSMOID_APPLE_TP_REVOCATION_OCSP, + CSSMOID_APPLE_TP_SMIME, + CSSMOID_APPLE_TP_EAP, CSSMOID_APPLE_FEE, CSSMOID_APPLE_ASC, CSSMOID_APPLE_FEE_MD5, CSSMOID_APPLE_FEE_SHA1, CSSMOID_APPLE_FEED, CSSMOID_APPLE_FEEDEXP, - CSSMOID_APPLE_ECDSA; + CSSMOID_APPLE_ECDSA, + CSSMOID_PKCS12_pbeWithSHAAnd128BitRC4, + CSSMOID_PKCS12_pbeWithSHAAnd40BitRC4, + CSSMOID_PKCS12_pbeWithSHAAnd3Key3DESCBC, + CSSMOID_PKCS12_pbeWithSHAAnd2Key3DESCBC, + CSSMOID_PKCS12_pbeWithSHAAnd128BitRC2CBC, + CSSMOID_PKCS12_pbewithSHAAnd40BitRC2CBC; #ifdef __cplusplus } diff --git a/cdsa/cdsa/oidsattr.h b/cdsa/cdsa/oidsattr.h index db04cb35..cf15366a 100644 --- a/cdsa/cdsa/oidsattr.h +++ b/cdsa/cdsa/oidsattr.h @@ -117,4 +117,32 @@ extern const CSSM_OID CSSMOID_QT_CPS, CSSMOID_QT_UNOTICE; +/* PKCS7 */ +extern const CSSM_OID + CSSMOID_PKCS7_Data, + CSSMOID_PKCS7_SignedData, + CSSMOID_PKCS7_EnvelopedData, + CSSMOID_PKCS7_SignedAndEnvelopedData, + CSSMOID_PKCS7_DigestedData, + CSSMOID_PKCS7_EncryptedData, + CSSMOID_PKCS7_DataWithAttributes, + CSSMOID_PKCS7_EncryptedPrivateKeyInfo, + +/* PKCS8 */ + CSSMOID_PKCS9_FriendlyName, + CSSMOID_PKCS9_LocalKeyId, + CSSMOID_PKCS9_CertTypes, + CSSMOID_PKCS9_CrlTypes, + CSSMOID_PKCS9_X509Certificate, + CSSMOID_PKCS9_SdsiCertificate, + CSSMOID_PKCS9_X509Crl, + +/* PKCS12 */ + CSSMOID_PKCS12_keyBag, + CSSMOID_PKCS12_shroudedKeyBag, + CSSMOID_PKCS12_certBag, + CSSMOID_PKCS12_crlBag, + CSSMOID_PKCS12_secretBag, + CSSMOID_PKCS12_safeContentsBag; + #endif /* _CDSA_OIDSATTR_H_*/ diff --git a/cdsa/cdsa/oidsbase.h b/cdsa/cdsa/oidsbase.h index fc52dfa1..213aef50 100644 --- a/cdsa/cdsa/oidsbase.h +++ b/cdsa/cdsa/oidsbase.h @@ -100,12 +100,27 @@ representation is implied */ #define OID_PKCS_9 OID_PKCS, 9 #define OID_PKCS_9_LENGTH OID_PKCS_LENGTH +1 #define OID_PKCS_10 OID_PKCS, 10 +#define OID_PKCS_11 OID_PKCS, 11 +#define OID_PKCS_11_LENGTH OID_PKCS_LENGTH +1 +#define OID_PKCS_12 OID_PKCS, 12 +#define OID_PKCS_12_LENGTH OID_PKCS_LENGTH +1 + +/* ANSI X9.42 */ +#define OID_ANSI_X9_42 OID_US, 206, 62, 2 +#define OID_ANSI_X9_42_LEN OID_US_LENGTH + 3 +#define OID_ANSI_X9_42_SCHEME OID_ANSI_X9_42, 3 +#define OID_ANSI_X9_42_SCHEME_LEN OID_ANSI_X9_42_LEN + 1 +#define OID_ANSI_X9_42_NAMED_SCHEME OID_ANSI_X9_42, 4 +#define OID_ANSI_X9_42_NAMED_SCHEME_LEN OID_ANSI_X9_42_LEN + 1 #define OID_PKIX OID_DOD, 1, 5, 5, 7 #define OID_PKIX_LENGTH 6 #define OID_QT OID_PKIX, 2 #define OID_QT_LENGTH OID_PKIX_LENGTH + 1 +#define OID_KP OID_PKIX, 3 +#define OID_KP_LENGTH OID_PKIX_LENGTH + 1 + #define OID_OIW_SECSIG OID_OIW, 3 #define OID_OIW_LENGTH 2 #define OID_OIW_SECSIG_LENGTH OID_OIW_LENGTH +1 diff --git a/cdsa/cdsa/oidscert.h b/cdsa/cdsa/oidscert.h index b9bd47a6..ac840b11 100644 --- a/cdsa/cdsa/oidscert.h +++ b/cdsa/cdsa/oidscert.h @@ -61,13 +61,15 @@ extern const CSSM_OID CSSMOID_X509V3CertificateCStruct, CSSMOID_X509V1Version, CSSMOID_X509V1SerialNumber, - CSSMOID_X509V1IssuerName, - CSSMOID_X509V1IssuerNameCStruct, + CSSMOID_X509V1IssuerName, // normalized & encoded + CSSMOID_X509V1IssuerNameStd, // encoded + CSSMOID_X509V1IssuerNameCStruct, // CSSM_X509_NAME CSSMOID_X509V1IssuerNameLDAP, CSSMOID_X509V1ValidityNotBefore, CSSMOID_X509V1ValidityNotAfter, - CSSMOID_X509V1SubjectName, - CSSMOID_X509V1SubjectNameCStruct, + CSSMOID_X509V1SubjectName, // normalized & encoded + CSSMOID_X509V1SubjectNameStd, // encoded + CSSMOID_X509V1SubjectNameCStruct, // CSSM_X509_NAME CSSMOID_X509V1SubjectNameLDAP, CSSMOID_CSSMKeyStruct, CSSMOID_X509V1SubjectPublicKeyCStruct, @@ -105,13 +107,13 @@ extern const CSSM_OID ***/ /* - * Standard Cert extensions. + * Standard Cert and CRL extensions. */ extern const CSSM_OID CSSMOID_SubjectDirectoryAttributes, CSSMOID_SubjectKeyIdentifier, CSSMOID_KeyUsage, - CSSMOID_PrivateKeyUsagePeriod , + CSSMOID_PrivateKeyUsagePeriod, CSSMOID_SubjectAltName, CSSMOID_IssuerAltName, CSSMOID_BasicConstraints, @@ -120,7 +122,9 @@ extern const CSSM_OID CSSMOID_HoldInstructionCode, CSSMOID_InvalidityDate, CSSMOID_DeltaCrlIndicator, + CSSMOID_IssuingDistributionPoint, CSSMOID_IssuingDistributionPoints, + CSSMOID_CertIssuer, CSSMOID_NameConstraints, CSSMOID_CrlDistributionPoints, CSSMOID_CertificatePolicies, @@ -128,8 +132,14 @@ extern const CSSM_OID CSSMOID_PolicyConstraints, CSSMOID_AuthorityKeyIdentifier, CSSMOID_ExtendedKeyUsage, - CSSMOID_ExtendedUseCodeSigning; - + CSSMOID_ExtendedKeyUsageAny, + CSSMOID_ServerAuth, + CSSMOID_ClientAuth, + CSSMOID_ExtendedUseCodeSigning, + CSSMOID_EmailProtection, + CSSMOID_TimeStamping, + CSSMOID_OCSPSigning; + /* * Netscape extensions. */ diff --git a/cdsa/cdsa/x509defs.h b/cdsa/cdsa/x509defs.h index 618db42b..fe16bd21 100644 --- a/cdsa/cdsa/x509defs.h +++ b/cdsa/cdsa/x509defs.h @@ -121,7 +121,7 @@ typedef struct cssm_x509ext_basicConstraints { typedef enum extension_data_format { CSSM_X509_DATAFORMAT_ENCODED = 0, CSSM_X509_DATAFORMAT_PARSED, - CSSM_X509_DATAFORMAT_PAIR, + CSSM_X509_DATAFORMAT_PAIR } CSSM_X509EXT_DATA_FORMAT; typedef struct cssm_x509_extensionTagAndValue { diff --git a/cdsa/cdsa_client/aclclient.cpp b/cdsa/cdsa_client/aclclient.cpp index 15eceeb7..3195052a 100644 --- a/cdsa/cdsa_client/aclclient.cpp +++ b/cdsa/cdsa_client/aclclient.cpp @@ -21,7 +21,8 @@ // #include #include -#include +#include +#include namespace Security { @@ -133,23 +134,53 @@ const AccessCredentials *AclFactory::unlockCred() const { return &statics().unlockCred; } - -AclFactory::PasswordChangeCredentials::PasswordChangeCredentials (const CssmData& password, CssmAllocator& allocator) : - mAllocator (allocator) +// +// Manage the (pseudo) credentials used to explicitly provide a passphrase to a keychain. +// Use the eternal unlockCred() for normal (protected prompt) unlocking. +// +AclFactory::KeychainCredentials::~KeychainCredentials () { - mCredentials = new (allocator) AutoCredentials (allocator);; - mCredentials->sample(0) = TypedList(allocator, CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK, new (allocator) ListElement (CSSM_SAMPLE_TYPE_PASSWORD), - new (allocator) ListElement (password)); + DataWalkers::chunkFree (mCredentials, allocator); } +AclFactory::PassphraseUnlockCredentials::PassphraseUnlockCredentials (const CssmData& password, + CssmAllocator& allocator) : KeychainCredentials(allocator) +{ + mCredentials->sample(0) = TypedList(allocator, CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK, + new (allocator) ListElement (CSSM_SAMPLE_TYPE_PASSWORD), + new (allocator) ListElement (CssmAutoData(allocator, password).release())); +} -AclFactory::PasswordChangeCredentials::~PasswordChangeCredentials () +// +// Manage the (pseudo) credentials used to explicitly change a keychain's passphrase +// +AclFactory::PasswordChangeCredentials::PasswordChangeCredentials (const CssmData& password, + CssmAllocator& allocator) : KeychainCredentials(allocator) { - DataWalkers::chunkFree (mCredentials, mAllocator); + mCredentials->sample(0) = TypedList(allocator, CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK, + new (allocator) ListElement (CSSM_SAMPLE_TYPE_PASSWORD), + new (allocator) ListElement (CssmAutoData(allocator, password).release())); } +// +// Create an ANY style AclEntryInput. +// This can be used to explicitly request wide-open authorization on a new CSSM object. +// +AclFactory::AnyResourceContext::AnyResourceContext(const CSSM_ACCESS_CREDENTIALS *cred) + : mAny(CSSM_ACL_SUBJECT_TYPE_ANY), mTag(CSSM_ACL_AUTHORIZATION_ANY) +{ + // set up an ANY/EVERYTHING AclEntryInput + input().proto().subject() += &mAny; + AuthorizationGroup &authGroup = input().proto().authorization(); + authGroup.NumberOfAuthTags = 1; + authGroup.AuthTags = &mTag; + + // install the cred (not copied) + credentials(cred); +} + } // end namespace CssmClient } // end namespace Security diff --git a/cdsa/cdsa_client/aclclient.h b/cdsa/cdsa_client/aclclient.h index 8124bfbe..81f56efa 100644 --- a/cdsa/cdsa_client/aclclient.h +++ b/cdsa/cdsa_client/aclclient.h @@ -23,6 +23,7 @@ #define _H_CDSA_CLIENT_ACLCLIENT 1 #include +#include #include #include #include @@ -78,21 +79,43 @@ public: const AccessCredentials *promptCred() const; const AccessCredentials *unlockCred() const; -public: - // HHS password change credentials are used, amazingly enough, to change passwords... - class PasswordChangeCredentials - { +protected: + class KeychainCredentials { + public: + KeychainCredentials(CssmAllocator &alloc) + : allocator(alloc), mCredentials(new AutoCredentials(alloc)) { } + virtual ~KeychainCredentials(); + + CssmAllocator &allocator; + + operator const AccessCredentials* () { return mCredentials; } + protected: - AutoCredentials* mCredentials; - CssmAllocator& mAllocator; + AutoCredentials *mCredentials; + }; +public: + // create a self-managed AccessCredentials to explicitly provide a keychain passphrase + class PassphraseUnlockCredentials : public KeychainCredentials { public: - PasswordChangeCredentials (const CssmData& password, - CssmAllocator& allocator); - ~PasswordChangeCredentials (); + PassphraseUnlockCredentials (const CssmData& password, CssmAllocator& allocator); + }; - operator const AccessCredentials* () {return mCredentials;} + // create a self-managed AccessCredentials to change a keychain passphrase + class PasswordChangeCredentials : public KeychainCredentials { + public: + PasswordChangeCredentials (const CssmData& password, CssmAllocator& allocator); }; + +public: + class AnyResourceContext : public ResourceControlContext { + public: + AnyResourceContext(const CSSM_ACCESS_CREDENTIALS *cred = NULL); + + private: + ListElement mAny; + CSSM_ACL_AUTHORIZATION_TAG mTag; + }; }; diff --git a/cdsa/cdsa_client/aclsupport.cpp b/cdsa/cdsa_client/aclsupport.cpp deleted file mode 100644 index 998c494c..00000000 --- a/cdsa/cdsa_client/aclsupport.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// -// aclsupport.h - support for special Keychain style acls -// - -#include -#include -#include -#include "aclsupport.h" -#include "keychainacl.h" -#include - -using namespace CssmClient; - - -// --------------------------------------------------------------------------- -// TrustedApplicationImpl -// --------------------------------------------------------------------------- - -TrustedApplicationImpl::TrustedApplicationImpl(const CssmData &signature, const CssmData &comment, bool enabled) : - mSignature(CssmAllocator::standard(), signature), - mComment(CssmAllocator::standard(), comment), - mEnabled(enabled) -{ -} - -TrustedApplicationImpl::TrustedApplicationImpl(const char *path, const CssmData &comment, bool enabled) : mSignature(CssmAllocator::standard()), - mComment(CssmAllocator::standard(), comment), - mEnabled(enabled) -{ - calcSignature(path, mSignature); -} - - -const CssmData & TrustedApplicationImpl::signature() const -{ - - return mSignature; -} - -const CssmData & TrustedApplicationImpl::comment() const -{ - return mComment; -} - -bool TrustedApplicationImpl::enabled() const -{ - return mEnabled; -} - -void TrustedApplicationImpl::enabled(bool enabled) -{ - mEnabled = enabled; -} - -bool TrustedApplicationImpl::sameSignature(const char *path) -{ - // return true if object at given path has same signature - CssmAutoData otherSignature(CssmAllocator::standard()); - calcSignature(path, otherSignature); - return (mSignature.get() == otherSignature); -} - -void TrustedApplicationImpl::calcSignature(const char *path, CssmOwnedData &signature) -{ - // generate a signature for the given object - RefPointer objToVerify(CodeSigning::OSXCode::at(path)); - CodeSigning::OSXSigner signer; - auto_ptr osxSignature(signer.sign(*objToVerify)); - signature.copy(osxSignature->data(), osxSignature->length()); -} - -// --------------------------------------------------------------------------- -// TrustedApplication -// --------------------------------------------------------------------------- - -TrustedApplication::TrustedApplication() -{ -} - -TrustedApplication::TrustedApplication( - const char *path, const CssmData &comment, bool enabled) : -RefPointer(new TrustedApplicationImpl(path, comment, enabled)) -{ -} - -TrustedApplication::TrustedApplication( - const CssmData &signature, const CssmData &comment, bool enabled) : -RefPointer(new TrustedApplicationImpl(signature, comment, enabled)) -{ -} - -// --------------------------------------------------------------------------- -// KeychainACL -// --------------------------------------------------------------------------- - -KeychainACL::KeychainACL(const Key &key) : - mLabel(CssmAllocator::standard()), mSelector(CssmAllocator::standard()) -{ - mKey = key; - initialize(); -} - -void KeychainACL::initialize() -{ - mAnyAllow=false; - mAlwaysAskUser=false; - - CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR defaultSelector - = { CSSM_ACL_KEYCHAIN_PROMPT_CURRENT_VERSION, 0 }; - mSelector.copy(&defaultSelector, sizeof(defaultSelector)); - - AutoAclEntryInfoList aclInfos; - mKey->getAcl(aclInfos); - mHandle = CSSM_INVALID_HANDLE; - const AclEntryInfo *theInfo = NULL; - for(uint32 entry=0; entryproto().subject(); - assert(subject.isProper()); - const ListElement *element = subject.first(); - - switch(*element) - { - case CSSM_ACL_SUBJECT_TYPE_ANY: - assert(element->next() == NULL); - mAnyAllow=true; - return; - - case CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT: - mAlwaysAskUser=true; - assert(subject.length() == 3); - mSelector = subject[1].data(); - mLabel = subject[2].data(); - return; - - case CSSM_ACL_SUBJECT_TYPE_THRESHOLD: - break; - - default: - mIsCustomACL = true; - return; - } - - // OK, it's a threshold acl - element = element->next(); - assert(element && element->type() == CSSM_LIST_ELEMENT_WORDID); - if (*element != 1) { - mIsCustomACL = true; - return; - } - element = element->next(); - assert(element && element->type() == CSSM_LIST_ELEMENT_WORDID); - uint32 n = *element; - assert(n > 0); - - int isEnabled=1; - for (uint32 ix = 0; ix < n; ++ix) - { - element = element->next(); - assert(element && element->type() == CSSM_LIST_ELEMENT_SUBLIST); - const TypedList &subList = *element; - assert(subList.isProper()); - const ListElement *subElement = subList.first(); - - switch(*subElement) - { - case CSSM_ACL_SUBJECT_TYPE_ANY: - // Must be first subList in list. - assert(ix == 0 && subElement->next() == NULL); - mAnyAllow=true; - break; - - case CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT: - // Must be last subList in list. - assert(ix == n - 1); - mAlwaysAskUser=true; - assert(subList.length() == 3); - mSelector = subList[1].data(); - mLabel = subList[2].data(); - break; - - - case CSSM_ACL_SUBJECT_TYPE_COMMENT: - case CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE: - { - // when the app is disabled it is commented out. - if(*subElement==CSSM_ACL_SUBJECT_TYPE_COMMENT) - { - isEnabled=0; - subElement = subElement->next(); - } - subElement = subElement->next(); - assert(subElement && subElement->type() == CSSM_LIST_ELEMENT_WORDID); - uint32 sigType = *subElement; - subElement = subElement->next(); - assert(subElement && subElement->type() == CSSM_LIST_ELEMENT_DATUM); - const CssmData &sig = subElement->data(); - subElement = subElement->next(); - assert(subElement && subElement->type() == CSSM_LIST_ELEMENT_DATUM && subElement->next() == NULL); - const CssmData &comment = subElement->data(); - // Only if sigType is CSSM_ACL_CODE_SIGNATURE_OSX this element is enabled. - // @@@ Otherwsie it should be CSSM_ACL_CODE_SIGNATURE_NONE (which is not defined yet). - // additionally the enabled flag must be respected. - push_back(TrustedApplication(sig, comment, (sigType == CSSM_ACL_CODE_SIGNATURE_OSX) && isEnabled)); - break; - } - - default: - mIsCustomACL = true; - return; - } - } - - // Since we looked at N values we should be done. - assert(element->next() == NULL); -} - -void KeychainACL::commit() -{ - TrackingAllocator allocator(CssmAllocator::standard()); - - // hhs replaced with new aclFactory - AclFactory aclFactory; - - CssmList &list = *new(allocator) CssmList(); - - list.append(new(allocator) ListElement(CSSM_ACL_SUBJECT_TYPE_THRESHOLD)); - list.append(new(allocator) ListElement(1)); - list.append(new(allocator) ListElement(size()+mAnyAllow+mAlwaysAskUser)); - - if(mAnyAllow) - { - CssmList &sublist = *new(allocator) CssmList(); - sublist.append(new(allocator) ListElement(CSSM_ACL_SUBJECT_TYPE_ANY)); - list.append(new(allocator) ListElement(sublist)); - } - - - for (uint32 ix = 0; ix < size(); ++ix) - { - TrustedApplication app = at(ix); - CssmList &sublist = *new(allocator) CssmList(); - if(!app->enabled()) sublist.append(new(allocator) ListElement(CSSM_ACL_SUBJECT_TYPE_COMMENT)); - sublist.append(new(allocator) ListElement(CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE)); - sublist.append(new(allocator) ListElement(CSSM_ACL_CODE_SIGNATURE_OSX)); - sublist.append(new(allocator) ListElement(app->signature())); - sublist.append(new(allocator) ListElement(app->comment())); - list.append(new(allocator) ListElement(sublist)); - } - - if(mAlwaysAskUser) - { - CssmList &sublist = *new(allocator) CssmList(); - sublist.append(new(allocator) ListElement(CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT)); - sublist.append(new(allocator) ListElement(mSelector.get())); - sublist.append(new(allocator) ListElement(mLabel.get())); - list.append(new(allocator) ListElement(sublist)); - } - - AclEntryPrototype aclEntry(list); - // @@@ @@@ Force "decrypt" authorization for now -- should take this from input!! @@@ - AuthorizationGroup &anyDecryptAuthGroup = aclEntry.authorization(); - CSSM_ACL_AUTHORIZATION_TAG decryptTag = CSSM_ACL_AUTHORIZATION_DECRYPT; - anyDecryptAuthGroup.NumberOfAuthTags = 1; - anyDecryptAuthGroup.AuthTags = &decryptTag; - const AccessCredentials *promptCred = aclFactory.promptCred (); - AclEdit edit(mHandle, aclEntry); - mKey->changeAcl(edit, promptCred); -} - -void KeychainACL::anyAllow(bool allow) -{ - mAnyAllow=allow; -} - -bool KeychainACL::anyAllow() const -{ - return mAnyAllow; -} - -void KeychainACL::alwaysAskUser(bool ask) -{ - mAlwaysAskUser=ask; -} - -bool KeychainACL::alwaysAskUser() const -{ - return mAlwaysAskUser; -} - -bool KeychainACL::isCustomACL() const -{ - return mIsCustomACL; -} - -void KeychainACL::label(const CssmData &label) -{ - mLabel = label; -} diff --git a/cdsa/cdsa_client/aclsupport.h b/cdsa/cdsa_client/aclsupport.h deleted file mode 100644 index 6ca75315..00000000 --- a/cdsa/cdsa_client/aclsupport.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please obtain - * a copy of the License at http://www.apple.com/publicsource and read it before - * using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS - * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT - * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the - * specific language governing rights and limitations under the License. - */ - - -// -// aclsupport.h - support for special Keychain style acls -// - -#ifndef _ACLSUPPORT_H_ -#define _ACLSUPPORT_H_ - -#include -#include -#include -#include -#include -#include - - -namespace Security -{ - -namespace CssmClient -{ - -class TrustedApplicationImpl : public RefCount -{ -public: - TrustedApplicationImpl(const CssmData &signature, const CssmData &comment, bool enabled); - TrustedApplicationImpl(const char *path, const CssmData &comment, bool enabled); - - const CssmData &signature() const; - const CssmData &comment() const; - bool enabled() const; - void enabled(bool enabled); - - bool sameSignature(const char *path); // return true if object at path has same signature - -protected: - void calcSignature(const char *path, CssmOwnedData &signature); // generate a signature - -private: - CssmAutoData mSignature; - CssmAutoData mComment; - bool mEnabled; -}; - -class TrustedApplication : public RefPointer -{ -public: - TrustedApplication(); - TrustedApplication(const CssmData &signature, const CssmData &comment, bool enabled = true); - TrustedApplication(const char *path, const CssmData &comment, bool enabled = true); -}; - -class KeychainACL : public vector -{ -public: - KeychainACL(const Key &key); - void commit(); - - void anyAllow(bool allow); - bool anyAllow() const; - - void alwaysAskUser(bool allow); - bool alwaysAskUser() const; - bool isCustomACL() const; - void label(const CssmData &label); - -private: - void initialize(); - Key mKey; - bool mAnyAllow; - bool mAlwaysAskUser; - bool mIsCustomACL; - CssmAutoData mLabel; - CssmAutoData mSelector; - - CSSM_ACL_HANDLE mHandle; -}; - -}; // end namespace CssmClient - -} // end namespace Security - -#endif // _ACLSUPPORT_H_ diff --git a/cdsa/cdsa_client/cryptoclient.cpp b/cdsa/cdsa_client/cryptoclient.cpp index b6ad3ab9..9a47fb66 100644 --- a/cdsa/cdsa_client/cryptoclient.cpp +++ b/cdsa/cdsa_client/cryptoclient.cpp @@ -33,6 +33,12 @@ Crypt::Crypt(const CSP &csp, CSSM_ALGORITHMS alg) : Context(csp, alg) mPadding = CSSM_PADDING_NONE; } +void Crypt::key(const Key &key) +{ + mKey = key; + set(CSSM_ATTRIBUTE_KEY, static_cast(key)); +} + void Crypt::activate() { diff --git a/cdsa/cdsa_client/cryptoclient.h b/cdsa/cdsa_client/cryptoclient.h index 247b6a30..69a67451 100644 --- a/cdsa/cdsa_client/cryptoclient.h +++ b/cdsa/cdsa_client/cryptoclient.h @@ -43,7 +43,7 @@ public: const AccessCredentials *cred() const { return mCred; } void cred(const AccessCredentials *c); Key key() const { return mKey; } - void key(const Key &k) { mKey = k; set(CSSM_ATTRIBUTE_KEY, k); } + void key(const Key &k); const CssmData &initVector() const { return *mInitVector; } void initVector(const CssmData &v) { mInitVector = &v; set(CSSM_ATTRIBUTE_INIT_VECTOR, v); } CSSM_PADDING padding() const { return mPadding; } diff --git a/cdsa/cdsa_client/cspclient.cpp b/cdsa/cdsa_client/cspclient.cpp index 6fe31a53..ba692ca0 100644 --- a/cdsa/cdsa_client/cspclient.cpp +++ b/cdsa/cdsa_client/cspclient.cpp @@ -91,7 +91,7 @@ void CssmClient::Context::algorithm(CSSM_ALGORITHMS alg) // // Query context operation output sizes. // -uint32 CssmClient::Context::getOutputSize(uint32 inputSize, bool encrypt = true) +uint32 CssmClient::Context::getOutputSize(uint32 inputSize, bool encrypt /*= true*/) { CSSM_QUERY_SIZE_DATA data; data.SizeInputBlock = inputSize; @@ -99,7 +99,7 @@ uint32 CssmClient::Context::getOutputSize(uint32 inputSize, bool encrypt = true) return data.SizeOutputBlock; } -void CssmClient::Context::getOutputSize(CSSM_QUERY_SIZE_DATA &sizes, uint32 count, bool encrypt = true) +void CssmClient::Context::getOutputSize(CSSM_QUERY_SIZE_DATA &sizes, uint32 count, bool encrypt /*= true*/) { check(CSSM_QuerySize(handle(), encrypt, count, &sizes)); } diff --git a/cdsa/cdsa_client/cspclient.h b/cdsa/cdsa_client/cspclient.h index ce79289c..ff11f9cd 100644 --- a/cdsa/cdsa_client/cspclient.h +++ b/cdsa/cdsa_client/cspclient.h @@ -136,6 +136,14 @@ public: public: void operator () (uint32 passThroughId, const void *inData, void **outData); + + template + void operator () (uint32 passThroughId, const TIn *inData, TOut **outData) + { operator () (passThroughId, (const void *)inData, (void **)outData); } + + template + void operator () (uint32 passThroughId, const TIn *inData) + { operator () (passThroughId, (const void *)inData, NULL); } const CSSM_KEY *key() const { return mKey; } void key(const CSSM_KEY *k) { mKey = k; set(CSSM_ATTRIBUTE_KEY, k); } diff --git a/cdsa/cdsa_client/cssmclient.h b/cdsa/cdsa_client/cssmclient.h index 9c910170..e942a242 100644 --- a/cdsa/cdsa_client/cssmclient.h +++ b/cdsa/cdsa_client/cssmclient.h @@ -148,6 +148,7 @@ public: bool isActive() const { return mImpl && mImpl->isActive(); } CssmAllocator &allocator() const { return mImpl->allocator(); } + void release() { mImpl = NULL; } bool operator <(const Object &other) const { return mImpl && other.mImpl ? *mImpl < *other.mImpl : mImpl < other.mImpl; } diff --git a/cdsa/cdsa_client/dlclient.cpp b/cdsa/cdsa_client/dlclient.cpp index 38824ea8..0e28671e 100644 --- a/cdsa/cdsa_client/dlclient.cpp +++ b/cdsa/cdsa_client/dlclient.cpp @@ -20,6 +20,8 @@ // dlclient - client interface to CSSM DLs and their operations // #include +#include +#include using namespace CssmClient; @@ -97,11 +99,23 @@ DbImpl::create() if (mActive) CssmError::throwMe(CSSMERR_DL_DATASTORE_ALREADY_EXISTS); - assert(mDbInfo != nil); + if (mDbInfo == nil) { + // handle a missing (null) mDbInfo as an all-zero one + static const CSSM_DBINFO nullDbInfo = { }; + mDbInfo = &nullDbInfo; + } mHandle.DLHandle = dl()->handle(); - check(CSSM_DL_DbCreate(mHandle.DLHandle, name(), dbLocation(), mDbInfo, + + if (!mResourceControlContext && mAccessCredentials) { + AclFactory::AnyResourceContext ctx(mAccessCredentials); + check(CSSM_DL_DbCreate(mHandle.DLHandle, name(), dbLocation(), mDbInfo, + mAccessRequest, &ctx, + mOpenParameters, &mHandle.DBHandle)); + } else { + check(CSSM_DL_DbCreate(mHandle.DLHandle, name(), dbLocation(), mDbInfo, mAccessRequest, mResourceControlContext, mOpenParameters, &mHandle.DBHandle)); + } mActive = true; } @@ -143,6 +157,18 @@ DbImpl::deleteDb() mAccessCredentials)); } +void +DbImpl::rename(const char *newName) +{ + // Deactivate so the db gets closed if it was open. + deactivate(); + if (::rename(name(), newName)) + UnixError::throwMe(errno); + + // Change our DbName to reflect this rename. + mDbName = DbName(newName, mDbName.dbLocation()); +} + void DbImpl::authenticate(CSSM_DB_ACCESS_TYPE inAccessRequest, const CSSM_ACCESS_CREDENTIALS *inAccessCredentials) @@ -202,41 +228,15 @@ DbImpl::insert(CSSM_DB_RECORDTYPE recordType, const CSSM_DB_RECORD_ATTRIBUTE_DAT return uniqueId; } -#if 0 -// @@@ These methods have been moved to DbUniqueRecord. -void -DbImpl::deleteRecord(const DbUniqueRecord &uniqueId) -{ - check(CSSM_DL_DataDelete(handle(), uniqueId)); -} -void -DbImpl::modify(CSSM_DB_RECORDTYPE recordType, DbUniqueRecord &uniqueId, - const CSSM_DB_RECORD_ATTRIBUTE_DATA *attributes, - const CSSM_DATA *data, - CSSM_DB_MODIFY_MODE modifyMode) +// +// Generic Passthrough interface +// +void DbImpl::passThrough(uint32 passThroughId, const void *in, void **out) { - check(CSSM_DL_DataModify(handle(), recordType, uniqueId, - attributes, - data, modifyMode)); + check(CSSM_DL_PassThrough(handle(), passThroughId, in, out)); } -void -DbImpl::get(const DbUniqueRecord &uniqueId, DbAttributes *attributes, - ::CssmDataContainer *data) -{ - if (attributes) - attributes->deleteValues(); - - if (data) - data->clear(); - - // @@@ Fix the const_cast here. - check(CSSM_DL_DataGetFromUniqueRecordId(handle(), uniqueId, - attributes, - data)); -} -#endif // // Passthrough functions (only implemented by AppleCSPDL). @@ -298,6 +298,24 @@ DbImpl::changePassphrase(const CSSM_ACCESS_CREDENTIALS *cred) check(CSSM_DL_PassThrough(handle(), CSSM_APPLECSPDL_DB_CHANGE_PASSWORD, ¶ms, NULL)); } +bool +DbImpl::getUnlockKeyIndex(CssmData &index) +{ + try { + SecurityServer::DbHandle dbHandle; + if (CSSM_DL_PassThrough(handle(), + CSSM_APPLECSPDL_DB_GET_HANDLE, NULL, (void **)&dbHandle)) + return false; // can't get index + SecurityServer::ClientSession ss(allocator(), allocator()); + ss.getDbSuggestedIndex(dbHandle, index); + return true; + } catch (const CssmError &error) { + if (error.cssmError() == CSSMERR_DL_DATASTORE_DOESNOT_EXIST) + return false; + throw; + } +} + // // DbCursorMaker @@ -378,6 +396,8 @@ DbDbCursorImpl::next(DbAttributes *attributes, ::CssmDataContainer *data, DbUniq unique); if (result == CSSM_OK) mActive = true; + else if (data != NULL) + data->invalidate (); } else { @@ -386,6 +406,11 @@ DbDbCursorImpl::next(DbAttributes *attributes, ::CssmDataContainer *data, DbUniq attributes, data, unique); + + if (result != CSSM_OK && data != NULL) + { + data->invalidate (); + } } if (result == CSSMERR_DL_ENDOFDATA) @@ -488,9 +513,17 @@ DbUniqueRecordImpl::get(DbAttributes *attributes, data->clear(); // @@@ Fix the allocators for attributes and data. - check(CSSM_DL_DataGetFromUniqueRecordId(database()->handle(), mUniqueId, + CSSM_RETURN result; + result = CSSM_DL_DataGetFromUniqueRecordId(database()->handle(), mUniqueId, attributes, - data)); + data); + + if (result != CSSM_OK && data != NULL) // the data returned is no longer valid + { + data->invalidate (); + } + + check(result); } void diff --git a/cdsa/cdsa_client/dlclient.h b/cdsa/cdsa_client/dlclient.h index 39e4c780..d57a691e 100644 --- a/cdsa/cdsa_client/dlclient.h +++ b/cdsa/cdsa_client/dlclient.h @@ -241,6 +241,7 @@ public: virtual void create(); virtual void close(); virtual void deleteDb(); + virtual void rename(const char *newName); virtual void authenticate(CSSM_DB_ACCESS_TYPE inAccessRequest, const CSSM_ACCESS_CREDENTIALS *inAccessCredentials); virtual void name(char *&outName); // CSSM_DL_GetDbNameFromHandle() @@ -257,17 +258,6 @@ public: const CSSM_DB_RECORD_ATTRIBUTE_DATA *attributes, const CSSM_DATA *data); -#if 0 - // @@@ These methods have been moved to DbUniqueRecord. - virtual void deleteRecord(const DbUniqueRecord &uniqueId); - virtual void modify(CSSM_DB_RECORDTYPE recordType, DbUniqueRecord &uniqueId, - const CSSM_DB_RECORD_ATTRIBUTE_DATA *attributes, - const CSSM_DATA *data, - CSSM_DB_MODIFY_MODE modifyMode); - virtual void get(const DbUniqueRecord &uniqueId, DbAttributes *attributes, - ::CssmDataContainer *data); -#endif - const CSSM_DL_DB_HANDLE &handle() { activate(); return mHandle; } const DbName &dbName() { return mDbName; } @@ -292,10 +282,16 @@ public: const CSSM_DBINFO *dbInfo() const { return mDbInfo; } void dbInfo(const CSSM_DBINFO *inDbInfo) { mDbInfo = inDbInfo; } - const CSSM_RESOURCE_CONTROL_CONTEXT *resourceControlContext() const + const ResourceControlContext *resourceControlContext() const { return mResourceControlContext; } void resourceControlContext(const CSSM_RESOURCE_CONTROL_CONTEXT *inResourceControlContext) - { mResourceControlContext = inResourceControlContext; } + { mResourceControlContext = ResourceControlContext::overlay(inResourceControlContext); } + + void passThrough(uint32 passThroughId, const void *in, void **out = NULL); + + template + void passThrough(uint32 passThroughId, const TIn *in, TOut *out = NULL) + { passThrough(passThroughId, (const void *)in, (void **)out); } // Passthrough functions (only implemented by AppleCSPDL). virtual void lock(); @@ -305,6 +301,7 @@ public: virtual void setSettings(uint32 inIdleTimeout, bool inLockOnSleep); virtual bool isLocked(); virtual void changePassphrase(const CSSM_ACCESS_CREDENTIALS *cred); + virtual bool getUnlockKeyIndex(CssmData &index); // Utility methods virtual DLDbIdentifier dlDbIdentifier() const; @@ -330,7 +327,7 @@ private: // Arguments to create const CSSM_DBINFO *mDbInfo; - const CSSM_RESOURCE_CONTROL_CONTEXT *mResourceControlContext; + const ResourceControlContext *mResourceControlContext; }; diff --git a/cdsa/cdsa_client/keyclient.cpp b/cdsa/cdsa_client/keyclient.cpp index f98f7375..5627ce71 100644 --- a/cdsa/cdsa_client/keyclient.cpp +++ b/cdsa/cdsa_client/keyclient.cpp @@ -20,6 +20,8 @@ // keyclient // #include +#include + using namespace CssmClient; @@ -29,8 +31,10 @@ KeyImpl::KeyImpl(const CSP &csp) : ObjectImpl(csp), CssmKey() mActive=false; } -KeyImpl::KeyImpl(const CSP &csp, CSSM_KEY &key) : ObjectImpl(csp), CssmKey(key) +KeyImpl::KeyImpl(const CSP &csp, const CSSM_KEY &key, bool copy) : ObjectImpl(csp), CssmKey(key) { + if (copy) + keyData() = CssmAutoData(csp.allocator(), keyData()).release(); mActive=true; } diff --git a/cdsa/cdsa_client/keyclient.h b/cdsa/cdsa_client/keyclient.h index db6cdaff..258186eb 100644 --- a/cdsa/cdsa_client/keyclient.h +++ b/cdsa/cdsa_client/keyclient.h @@ -38,7 +38,7 @@ class KeyImpl : public ObjectImpl, public AclBearer, public CssmKey { public: KeyImpl(const CSP &csp); - KeyImpl(const CSP &csp, CSSM_KEY &key); + KeyImpl(const CSP &csp, const CSSM_KEY &key, bool copy = false); KeyImpl(const CSP &csp, const CSSM_DATA &keyData); virtual ~KeyImpl(); @@ -71,21 +71,24 @@ public: explicit Key(Impl *impl) : Object(impl) {} Key() : Object(NULL) {} - Key(const CSP &csp, CSSM_KEY &key) : Object(new Impl(csp, key)) {} - Key(const CSP &csp, CSSM_DATA &keyData) : Object(new Impl(csp, keyData)) {} + Key(const CSP &csp, const CSSM_KEY &key, bool copy = false) : Object(new Impl(csp, key, copy)) {} + Key(const CSP &csp, const CSSM_DATA &keyData) : Object(new Impl(csp, keyData)) {} // Creates an inactive key, client must call activate() after this. Key(const CSP &csp) : Object(new Impl(csp)) {} - Impl *operator ->() const { return (*this) ? &impl() : NULL; } - Impl &operator *() const { return impl(); } + Impl *operator ->() const { return (*this) ? &impl() : NULL; } + Impl &operator *() const { return impl(); } // Conversion operators to CssmKey baseclass. - operator const CssmKey * () const { return (*this) ? &(**this) : NULL; } - operator const CssmKey & () const { return **this; } + operator const CssmKey * () const { return (*this) ? &(**this) : NULL; } + operator const CssmKey & () const { return **this; } + + // a few shortcuts to make life easier + CssmKey::Header &header() const { return (*this)->header(); } // Creates an inactive key, client must call activate() after this. - CssmKey *makeNewKey(const CSP &csp) { (*this) = Key(csp); return &(**this); } + CssmKey *makeNewKey(const CSP &csp) { (*this) = Key(csp); return &(**this); } // inquiries CssmKeySize sizeInBits() const { return (*this)->sizeInBits(); } diff --git a/cdsa/cdsa_client/securestorage.cpp b/cdsa/cdsa_client/securestorage.cpp index 4ae49b07..535af18f 100644 --- a/cdsa/cdsa_client/securestorage.cpp +++ b/cdsa/cdsa_client/securestorage.cpp @@ -18,7 +18,6 @@ #include "securestorage.h" #include "genkey.h" -//#include "aclsupport.h" #include #include #include @@ -208,7 +207,7 @@ SSGroupImpl::SSGroupImpl(const SSDb &ssDb, random.generate(mLabel, mLabel.Length); // Overwrite the first 4 bytes with the magic cookie for a group. - reinterpret_cast(mLabel.Data)[0] = kGroupMagic; + reinterpret_cast(mLabel.Data)[0] = h2n(uint32(kGroupMagic)); // @@@ Ensure that the label is unique (Chance of collision is 2^80 -- // birthday paradox). @@ -238,7 +237,7 @@ SSGroupImpl::SSGroupImpl(const SSDb &ssDb, const CSSM_DATA &dataBlob) CssmError::throwMe(CSSMERR_DL_RECORD_NOT_FOUND); // Not a SS record mLabel = CssmData(dataBlob.Data, kLabelSize); - if (*reinterpret_cast(mLabel.Data) != kGroupMagic) + if (*reinterpret_cast(mLabel.Data) != h2n (uint32(kGroupMagic))) CssmError::throwMe(CSSMERR_DL_RECORD_NOT_FOUND); // Not a SS record // Look up the symmetric key with that label. @@ -264,7 +263,7 @@ bool SSGroupImpl::isGroup(const CSSM_DATA &dataBlob) { return dataBlob.Length >= kLabelSize + kIVSize - && *reinterpret_cast(dataBlob.Data) == kGroupMagic; + && *reinterpret_cast(dataBlob.Data) == h2n(uint32(kGroupMagic)); } const CssmData @@ -306,25 +305,11 @@ SSGroupImpl::decodeDataBlob(const CSSM_DATA &dataBlob, throw; // The user checked to don't ask again checkbox in the rogue app alert. Let's edit the ACL for this key and add the calling application to it. -#if 1 Key key(this); // the underlying key - RefPointer access = new Access(*key); // extract access rights - RefPointer thisApp = new TrustedApplication; + SecPointer access = new Access(*key); // extract access rights + SecPointer thisApp = new TrustedApplication; access->addApplicationToRight(CSSM_ACL_AUTHORIZATION_DECRYPT, thisApp.get()); // add this app access->setAccess(*key, true); // commit -#else - KeychainACL acl(Key(this)); - acl.anyAllow(false); - acl.alwaysAskUser(true); - - RefPointer code(CodeSigning::OSXCode::main()); - const char *path = code->canonicalPath().c_str(); - CssmData comment(const_cast(path), strlen(path) + 1); - acl.push_back(TrustedApplication(path, comment)); - - // Change the acl. - acl.commit(); -#endif // Retry the decrypt operation. Decrypt decrypt(csp(), algorithm()); diff --git a/cdsa/cdsa_client/securestorage.h b/cdsa/cdsa_client/securestorage.h index d1994a0c..42ac7cd2 100644 --- a/cdsa/cdsa_client/securestorage.h +++ b/cdsa/cdsa_client/securestorage.h @@ -159,13 +159,6 @@ public: const CSSM_DATA *data, const CSSM_RESOURCE_CONTROL_CONTEXT *rc = NULL); -#if 0 - SSDbUniqueRecord insert(CSSM_DB_RECORDTYPE recordType, - const CSSM_DB_RECORD_ATTRIBUTE_DATA *attributes, - const CSSM_DATA *data, - const AutoAclEntryInfoList &keyAcl); -#endif - SSDbUniqueRecord insert(CSSM_DB_RECORDTYPE recordType, const CSSM_DB_RECORD_ATTRIBUTE_DATA *attributes, const CSSM_DATA *data, const SSGroup &group, diff --git a/cdsa/cdsa_client/tpclient.cpp b/cdsa/cdsa_client/tpclient.cpp index 32ab29f4..c1448516 100644 --- a/cdsa/cdsa_client/tpclient.cpp +++ b/cdsa/cdsa_client/tpclient.cpp @@ -69,7 +69,7 @@ void TPImpl::certGroupVerify(const CertGroup &certGroup, void TPImpl::setupCL() { if (mUseCL == NULL) { - debug("tpclient", "TP is auto-attaching supporting CL"); + secdebug("tpclient", "TP is auto-attaching supporting CL"); mUseCL = new CL(gGuidAppleX509CL); mOwnCL = true; } @@ -78,7 +78,7 @@ void TPImpl::setupCL() void TPImpl::setupCSP() { if (mUseCSP == NULL) { - debug("tpclient", "TP is auto-attaching supporting CSP"); + secdebug("tpclient", "TP is auto-attaching supporting CSP"); mUseCSP = new CSP(gGuidAppleCSP); mOwnCSP = true; } diff --git a/cdsa/cdsa_pluginlib/CSPsession.cpp b/cdsa/cdsa_pluginlib/CSPsession.cpp index f972732d..ffa64479 100644 --- a/cdsa/cdsa_pluginlib/CSPsession.cpp +++ b/cdsa/cdsa_pluginlib/CSPsession.cpp @@ -714,7 +714,7 @@ void CSPFullPluginSession::QueryKeySizeInBits(CSSM_CC_HANDLE ccHandle, CSSM_KEY_SIZE &keySize) { if (context) { - getKeySize(context->get(CSSM_ATTRIBUTE_KEY, CSSMERR_CSP_MISSING_ATTR_KEY), + getKeySize(context->get(CSSM_ATTRIBUTE_KEY, CSSMERR_CSP_MISSING_ATTR_KEY), keySize); } else { getKeySize(CssmKey::required(key), keySize); @@ -913,7 +913,8 @@ void KeyPool::add(ReferencedKey &referencedKey) { StLock _(mKeyMapLock); - bool inserted = mKeyMap.insert(KeyMap::value_type(referencedKey.keyReference(), &referencedKey)).second; + IFDEBUG(bool inserted =) + mKeyMap.insert(KeyMap::value_type(referencedKey.keyReference(), &referencedKey)).second; // Since add is only called from the constructor of ReferencedKey we should // never add a key that is already in mKeyMap assert(inserted); diff --git a/cdsa/cdsa_pluginlib/csputilities.cpp b/cdsa/cdsa_pluginlib/csputilities.cpp index e5629ee7..e61c1f2f 100644 --- a/cdsa/cdsa_pluginlib/csputilities.cpp +++ b/cdsa/cdsa_pluginlib/csputilities.cpp @@ -22,6 +22,8 @@ #include #include #include +#include + #include //@@@ debug using LowLevelMemoryUtilities::increment; @@ -89,7 +91,7 @@ void CSPFullPluginSession::Writer::use(size_t used) vec++; } else if (vec > lastVec) { assert(false); // 2nd try to overflow end -#endif !NDEBUG +#endif /* !NDEBUG */ } else { currentBuffer = NULL; // no more output buffer currentSize = 0; @@ -133,6 +135,15 @@ void CSPFullPluginSession::setKey(CssmKey &key, key.KeyHeader.KeyUsage = use; key.KeyHeader.KeyAttr = attrs; + CssmDate *theDate = context.get(CSSM_ATTRIBUTE_START_DATE); + if(theDate) { + key.KeyHeader.StartDate = *theDate; + } + theDate = context.get(CSSM_ATTRIBUTE_END_DATE); + if(theDate) { + key.KeyHeader.EndDate = *theDate; + } + // defaults (change as needed) key.KeyHeader.WrapAlgorithmId = CSSM_ALGID_NONE; diff --git a/cdsa/cdsa_pluginlib/generator.cfg b/cdsa/cdsa_pluginlib/generator.cfg index f596500f..1a8cea2e 100644 --- a/cdsa/cdsa_pluginlib/generator.cfg +++ b/cdsa/cdsa_pluginlib/generator.cfg @@ -10,50 +10,49 @@ # # CSP -optional Login LoginName -optional GetLoginAcl SelectionTag -optional GetKeyAcl SelectionTag -optional GetDbAcl SelectionTag -optional GenerateKey KeyLabel CredAndAclEntry -optional GenerateKeyPair PrivateKeyLabel PublicKeyLabel CredAndAclEntry -optional WrapKey DescriptiveData -optional UnwrapKey PublicKey KeyLabel CredAndAclEntry -optional DeriveKey KeyLabel CredAndAclEntry -optional FreeKey AccessCred -optional QuerySize DataBlock -optional QueryKeySizeInBits Context Key +optional CSP:Login LoginName +optional CSP:GetLoginAcl SelectionTag +optional CSP:GetKeyAcl SelectionTag +optional DL:GetDbAcl SelectionTag +optional CSP:GenerateKey KeyLabel CredAndAclEntry +optional CSP:GenerateKeyPair PrivateKeyLabel PublicKeyLabel CredAndAclEntry +optional CSP:WrapKey DescriptiveData +optional CSP:UnwrapKey PublicKey KeyLabel CredAndAclEntry +optional CSP:DeriveKey KeyLabel CredAndAclEntry +optional CSP:FreeKey AccessCred +optional CSP:QuerySize DataBlock +optional CSP:QueryKeySizeInBits Context Key # CL/TP -optional SubmitCredRequest PreferredAuthority CallerAuthContext -optional RetrieveCredResult CallerAuthCredentials -optional ConfirmCredResult CallerAuthCredentials PreferredAuthority -optional CertReclaimKey CredAndAclEntry -optional FormRequest PreferredAuthority -optional FormSubmit ClearanceAuthority RepresentedAuthority Credentials -optional CertGroupVerify VerifyContext VerifyContextResult -optional CertSign SignScope SignerVerifyContext -optional CrlVerify VerifyContext -optional CertRevoke OldCrlTemplate -optional CertRemoveFromCrlTemplate OldCrlTemplate -optional CrlSign SignerVerifyContext -optional ApplyCrlToDb ApplyCrlVerifyContext -optional PassThrough DBList -optional AuthCompute Credentials RequestedAuthorizationPeriod -optional CertSign SignScope -optional CertVerify SignerCert VerifyScope -optional CertGroupToSignedBundle SignerCert BundleInfo -optional CertGroupFromVerifiedBundle SignerCert -optional CrlSign SignScope -optional CrlVerify VerifyScope -optional CrlGetFirstCachedFieldValue CrlRecordIndex -optional FreeFieldValue Value +optional TP:SubmitCredRequest PreferredAuthority CallerAuthContext +optional TP:RetrieveCredResult CallerAuthCredentials +optional TP:ConfirmCredResult CallerAuthCredentials PreferredAuthority +optional TP:CertReclaimKey CredAndAclEntry +optional TP:FormRequest PreferredAuthority +optional TP:FormSubmit ClearanceAuthority RepresentedAuthority Credentials +optional TP:CertGroupVerify VerifyContext VerifyContextResult +optional TP:CertSign SignerVerifyContext SignerVerifyResult +optional TP:CrlVerify VerifyContext RevokerVerifyResult +optional TP:CertRevoke OldCrlTemplate +optional TP:CertRemoveFromCrlTemplate OldCrlTemplate +optional TP:CrlSign SignerVerifyContext SignerVerifyResult +optional TP:ApplyCrlToDb ApplyCrlVerifyContext +optional TP:PassThrough DBList +optional AC:AuthCompute Credentials RequestedAuthorizationPeriod +optional CL:CertSign SignScope +optional CL:CertVerify SignerCert VerifyScope +optional CL:CertGroupToSignedBundle SignerCert BundleInfo +optional CL:CertGroupFromVerifiedBundle SignerCert +optional CL:CrlSign SignScope +optional CL:CrlVerify SignerCert VerifyScope +optional CL:CrlGetFirstCachedFieldValue CrlRecordIndex # DL -optional DbOpen DbLocation AccessCred -optional DbCreate DbLocation CredAndAclEntry -optional DbDelete DbLocation AccessCred -optional DataInsert Attributes Data -optional DataModify AttributesToBeModified DataToBeModified -optional DataGetFirst Query Attributes Data -optional DataGetNext Query Attributes Data -optional DataGetFromUniqueRecordId Attributes Data +optional DL:DbOpen DbLocation AccessCred +optional DL:DbCreate DbLocation CredAndAclEntry +optional DL:DbDelete DbLocation AccessCred +optional DL:DataInsert Attributes Data +optional DL:DataModify AttributesToBeModified DataToBeModified +optional DL:DataGetFirst Query Attributes Data +optional DL:DataGetNext Query Attributes Data +optional DL:DataGetFromUniqueRecordId Attributes Data diff --git a/cdsa/cdsa_pluginlib/generator.pl b/cdsa/cdsa_pluginlib/generator.pl index 1addca66..925fc278 100644 --- a/cdsa/cdsa_pluginlib/generator.pl +++ b/cdsa/cdsa_pluginlib/generator.pl @@ -28,7 +28,7 @@ $/=undef; # gulp file open(APICFG, $APICFG) or die "Cannot open $APICFG: $^E"; $_=; close(APICFG); -%optionals = /^\s*optional\s+(\w+)\s+(.*)$/gm; +%optionals = /^\s*optional\s+(\w+:\w+)\s+(.*)$/gm; # @@ -124,7 +124,7 @@ while (($type, $header) = each %SPI_H) { # # Fix optional arguments # - foreach $opt (split " ", $optionals{$function}) { + foreach $opt (split " ", $optionals{"$type:$function"}) { $methods{$function} =~ s/\&$opt\b/\*$opt/; # turn refs back into pointers $actuals{$function} =~ s/::required\($opt\)/::optional($opt)/; # optional specific $actuals{$function} =~ s/Required\($opt\)/$opt/; # optional generic diff --git a/cdsa/cdsa_utilities/AppleDatabase.cpp b/cdsa/cdsa_utilities/AppleDatabase.cpp index 01bef0a2..b6173ee9 100644 --- a/cdsa/cdsa_utilities/AppleDatabase.cpp +++ b/cdsa/cdsa_utilities/AppleDatabase.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2000-2001, 2003 Apple Computer, Inc. All Rights Reserved. * * The contents of this file constitute Original Code as defined in and are * subject to the Apple Public Source License Version 1.2 (the 'License'). @@ -231,7 +231,7 @@ ModifiedTable::deleteRecord(const RecordId &inRecordId) } const RecordId -ModifiedTable::insertRecord(AtomicFile::VersionId inVersionId, +ModifiedTable::insertRecord(uint32 inVersionId, const CSSM_DB_RECORD_ATTRIBUTE_DATA *inAttributes, const CssmData *inData) { @@ -436,7 +436,7 @@ ModifiedTable::writeIndexSection(WriteSection &tableSection, uint32 offset) } uint32 -ModifiedTable::writeTable(AtomicFile &inAtomicFile, uint32 inSectionOffset) +ModifiedTable::writeTable(AtomicTempFile &inAtomicTempFile, uint32 inSectionOffset) { if (mTable && !mIsModified) { // the table has not been modified, so we can just dump the old table @@ -445,7 +445,7 @@ ModifiedTable::writeTable(AtomicFile &inAtomicFile, uint32 inSectionOffset) const ReadSection &tableSection = mTable->getTableSection(); uint32 tableSize = tableSection.at(Table::OffsetSize); - inAtomicFile.write(AtomicFile::FromStart, inSectionOffset, + inAtomicTempFile.write(AtomicFile::FromStart, inSectionOffset, tableSection.range(Range(0, tableSize)), tableSize); return inSectionOffset + tableSize; @@ -505,7 +505,7 @@ ModifiedTable::writeTable(AtomicFile &inAtomicFile, uint32 inSectionOffset) // to but not including the current one to the new file. if (aBlockSize > 0) { - inAtomicFile.write(AtomicFile::FromStart, anOffset, + inAtomicTempFile.write(AtomicFile::FromStart, anOffset, aRecordsSection.range(Range(aBlockStart, aBlockSize)), aBlockSize); @@ -522,7 +522,7 @@ ModifiedTable::writeTable(AtomicFile &inAtomicFile, uint32 inSectionOffset) // Copy all records that have not yet been copied to the new file. if (aBlockSize > 0) { - inAtomicFile.write(AtomicFile::FromStart, anOffset, + inAtomicTempFile.write(AtomicFile::FromStart, anOffset, aRecordsSection.range(Range(aBlockStart, aBlockSize)), aBlockSize); @@ -542,7 +542,7 @@ ModifiedTable::writeTable(AtomicFile &inAtomicFile, uint32 inSectionOffset) // Put offset relative to start of this table in recordNumber array. aTableSection.put(Table::OffsetRecordNumbers + AtomSize * aRecordNumber, anOffset - inSectionOffset); - inAtomicFile.write(AtomicFile::FromStart, anOffset, + inAtomicTempFile.write(AtomicFile::FromStart, anOffset, aRecord.address(), aRecord.size()); anOffset += aRecord.size(); aRecordsCount++; @@ -580,7 +580,7 @@ ModifiedTable::writeTable(AtomicFile &inAtomicFile, uint32 inSectionOffset) { uint32 indexOffset = anOffset; anOffset = writeIndexSection(aTableSection, anOffset); - inAtomicFile.write(AtomicFile::FromStart, inSectionOffset + indexOffset, + inAtomicTempFile.write(AtomicFile::FromStart, inSectionOffset + indexOffset, aTableSection.address() + indexOffset, anOffset - indexOffset); } @@ -589,7 +589,7 @@ ModifiedTable::writeTable(AtomicFile &inAtomicFile, uint32 inSectionOffset) aTableSection.put(Table::OffsetRecordsCount, aRecordsCount); // Write out aTableSection header. - inAtomicFile.write(AtomicFile::FromStart, inSectionOffset, + inAtomicTempFile.write(AtomicFile::FromStart, inSectionOffset, aTableSection.address(), aTableSection.size()); return anOffset + inSectionOffset; @@ -739,15 +739,16 @@ static const CSSM_DB_ATTRIBUTE_INFO AttrSchemaParsingModule[] = // // DbVersion // -DbVersion::DbVersion(AtomicFile &inDatabaseFile, - const AppleDatabase &db) : - mDatabase(reinterpret_cast(NULL), 0), mDatabaseFile(&inDatabaseFile), - mDb(db) -{ - const uint8 *aFileAddress; - size_t aLength; - mVersionId = mDatabaseFile->enterRead(aFileAddress, aLength); - mDatabase = ReadSection(aFileAddress, aLength); +DbVersion::DbVersion(const AppleDatabase &db, const RefPointer &inAtomicBufferedFile) : + mDatabase(reinterpret_cast(NULL), 0), + mDb(db), + mBufferedFile(inAtomicBufferedFile) +{ + off_t aLength = mBufferedFile->length(); + off_t bytesRead = 0; + const uint8 *ptr = mBufferedFile->read(0, aLength, bytesRead); + mBufferedFile->close(); + mDatabase = ReadSection(ptr, bytesRead); open(); } @@ -756,27 +757,18 @@ DbVersion::~DbVersion() try { for_each_map_delete(mTableMap.begin(), mTableMap.end()); - if (mDatabaseFile) - mDatabaseFile->exitRead(mVersionId); } catch(...) {} } -bool -DbVersion::isDirty() const -{ - if (mDatabaseFile) - return mDatabaseFile->isDirty(mVersionId); - - return true; -} - void DbVersion::open() { try { // This is the oposite of DbModifier::commit() + mVersionId = mDatabase[mDatabase.size() - AtomSize]; + const ReadSection aHeaderSection = mDatabase.subsection(HeaderOffset, HeaderSize); if (aHeaderSection.at(OffsetMagic) != HeaderMagic) @@ -898,93 +890,78 @@ DbVersion::open() ReadSection aRecordSection = MetaRecord::readSection(aRecordsSection, aReadOffset); uint32 aRecordSize = aRecordSection.size(); aReadOffset += aRecordSize; -#if 0 - try - { -#endif - aMetaRecord.unpackRecord(aRecordSection, recordAllocator, - &aRecordAttributeData, NULL, 0); - // Create the attribute coresponding to this entry - if (aRecordData[0].size() != 1 || aRecordData[0].format() != CSSM_DB_ATTRIBUTE_FORMAT_UINT32) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - uint32 aRelationId = aRecordData[0]; - - // Skip the schema relations for the meta tables themselves. - // FIXME: this hard-wires the meta-table relation IDs to be - // within {CSSM_DB_RECORDTYPE_SCHEMA_START... - // CSSM_DB_RECORDTYPE_SCHEMA_END} (which is {0..4}). - // Bogus - the MDS schema relation IDs start at - // CSSM_DB_RELATIONID_MDS_START which is 0x40000000. - // Ref. Radar 2817921. - if (CSSM_DB_RECORDTYPE_SCHEMA_START <= aRelationId && aRelationId < CSSM_DB_RECORDTYPE_SCHEMA_END) - continue; - - // Get the MetaRecord corresponding to the specified RelationId - MetaRecord &aMetaRecord = findTable(aRelationId).getMetaRecord(); - - if (aRecordData[1].size() != 1 - || aRecordData[1].format() != CSSM_DB_ATTRIBUTE_FORMAT_UINT32 - || aRecordData[2].size() != 1 - || aRecordData[2].format() != CSSM_DB_ATTRIBUTE_FORMAT_UINT32 - || aRecordData[5].size() != 1 - || aRecordData[5].format() != CSSM_DB_ATTRIBUTE_FORMAT_UINT32) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + aMetaRecord.unpackRecord(aRecordSection, recordAllocator, + &aRecordAttributeData, NULL, 0); + // Create the attribute coresponding to this entry + if (aRecordData[0].size() != 1 || aRecordData[0].format() != CSSM_DB_ATTRIBUTE_FORMAT_UINT32) + CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + uint32 aRelationId = aRecordData[0]; + + // Skip the schema relations for the meta tables themselves. + // FIXME: this hard-wires the meta-table relation IDs to be + // within {CSSM_DB_RECORDTYPE_SCHEMA_START... + // CSSM_DB_RECORDTYPE_SCHEMA_END} (which is {0..4}). + // Bogus - the MDS schema relation IDs start at + // CSSM_DB_RELATIONID_MDS_START which is 0x40000000. + // Ref. Radar 2817921. + if (CSSM_DB_RECORDTYPE_SCHEMA_START <= aRelationId && aRelationId < CSSM_DB_RECORDTYPE_SCHEMA_END) + continue; - uint32 anAttributeId = aRecordData[1]; - uint32 anAttributeNameFormat = aRecordData[2]; - uint32 anAttributeFormat = aRecordData[5]; - auto_ptr aName; - const CssmData *aNameID = NULL; + // Get the MetaRecord corresponding to the specified RelationId + MetaRecord &aMetaRecord = findTable(aRelationId).getMetaRecord(); - if (aRecordData[3].size() == 1) - { - if (aRecordData[3].format() != CSSM_DB_ATTRIBUTE_FORMAT_STRING) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + if (aRecordData[1].size() != 1 + || aRecordData[1].format() != CSSM_DB_ATTRIBUTE_FORMAT_UINT32 + || aRecordData[2].size() != 1 + || aRecordData[2].format() != CSSM_DB_ATTRIBUTE_FORMAT_UINT32 + || aRecordData[5].size() != 1 + || aRecordData[5].format() != CSSM_DB_ATTRIBUTE_FORMAT_UINT32) + CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - auto_ptr aName2(new string(static_cast(aRecordData[3]))); - aName = aName2; - } + uint32 anAttributeId = aRecordData[1]; + uint32 anAttributeNameFormat = aRecordData[2]; + uint32 anAttributeFormat = aRecordData[5]; + auto_ptr aName; + const CssmData *aNameID = NULL; - if (aRecordData[4].size() == 1) - { - if (aRecordData[4].format() != CSSM_DB_ATTRIBUTE_FORMAT_BLOB) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + if (aRecordData[3].size() == 1) + { + if (aRecordData[3].format() != CSSM_DB_ATTRIBUTE_FORMAT_STRING) + CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - // @@@ Invoking conversion operator to CssmData & on aRecordData[4] - // And taking address of result. - aNameID = &static_cast(aRecordData[4]); - } + auto_ptr aName2(new string(static_cast(aRecordData[3]))); + aName = aName2; + } - // Make sure that the attribute specified by anAttributeNameFormat is present. - switch (anAttributeNameFormat) - { - case CSSM_DB_ATTRIBUTE_NAME_AS_STRING: - if (aRecordData[3].size() != 1) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - break; - case CSSM_DB_ATTRIBUTE_NAME_AS_OID: - if (aRecordData[4].size() != 1) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - break; - case CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER: - break; - default: + if (aRecordData[4].size() == 1) + { + if (aRecordData[4].format() != CSSM_DB_ATTRIBUTE_FORMAT_BLOB) CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - } - - // Create the attribute - aMetaRecord.createAttribute(aName.get(), aNameID, anAttributeId, anAttributeFormat); -#if 0 - // Free the data. - aRecordData.deleteValues(CssmAllocator::standard()); + // @@@ Invoking conversion operator to CssmData & on aRecordData[4] + // And taking address of result. + aNameID = &static_cast(aRecordData[4]); } - catch(...) + + // Make sure that the attribute specified by anAttributeNameFormat is present. + switch (anAttributeNameFormat) { - aRecordData.deleteValues(CssmAllocator::standard()); - throw; + case CSSM_DB_ATTRIBUTE_NAME_AS_STRING: + if (aRecordData[3].size() != 1) + CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + break; + case CSSM_DB_ATTRIBUTE_NAME_AS_OID: + if (aRecordData[4].size() != 1) + CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + break; + case CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER: + break; + default: + CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); } -#endif + + // Create the attribute + aMetaRecord.createAttribute(aName.get(), aNameID, anAttributeId, anAttributeFormat); } // initialize the indexes associated with each table @@ -1248,7 +1225,6 @@ DbModifier::DbModifier(AtomicFile &inAtomicFile, const AppleDatabase &db) : Metadata(), mDbVersion(), mAtomicFile(inAtomicFile), - mWriting(false), mDb(db) { } @@ -1258,9 +1234,7 @@ DbModifier::~DbModifier() try { for_each_map_delete(mModifiedTableMap.begin(), mModifiedTableMap.end()); - - if (mWriting) - rollback(); + // mAtomicTempFile will do automatic rollback on destruction. } catch(...) {} } @@ -1269,26 +1243,40 @@ const RefPointer DbModifier::getDbVersion() { StLock _(mDbVersionLock); - if (mDbVersion && mDbVersion->isDirty()) - mDbVersion = NULL; + RefPointer atomicBufferedFile(mAtomicFile.read()); + off_t length = atomicBufferedFile->open(); + if (mDbVersion) + { + if (length < AtomSize) + CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + + off_t bytesRead = 0; + const uint8 *ptr = atomicBufferedFile->read(length - AtomSize, AtomSize, bytesRead); + ReadSection aVersionSection(ptr, bytesRead); + uint32 aVersionId = aVersionSection[0]; - if (mDbVersion == NULL) - mDbVersion = new DbVersion(mAtomicFile, mDb); + if (aVersionId == mDbVersion->getVersionId()) + return mDbVersion; + } + + mDbVersion = new DbVersion(mDb, atomicBufferedFile); return mDbVersion; } void DbModifier::createDatabase(const CSSM_DBINFO &inDbInfo, - const CSSM_ACL_ENTRY_INPUT *inInitialAclEntry) + const CSSM_ACL_ENTRY_INPUT *inInitialAclEntry, + mode_t mode) { // XXX This needs better locking. There is a possible race condition between // two concurrent creators. Or a writer/creator or a close/create etc. - if (mWriting || !mModifiedTableMap.empty()) + if (mAtomicTempFile || !mModifiedTableMap.empty()) CssmError::throwMe(CSSMERR_DL_DATASTORE_ALREADY_EXISTS); - mVersionId = mAtomicFile.enterCreate(mFileRef); - mWriting = true; + mAtomicTempFile = mAtomicFile.create(mode); + // Set mVersionId to one since this is the first version of the database. + mVersionId = 1; // we need to create the meta tables first, because inserting tables // (including the meta tables themselves) relies on them being there @@ -1356,26 +1344,19 @@ void DbModifier::deleteDatabase() void DbModifier::modifyDatabase() { - if (mWriting) + if (mAtomicTempFile) return; try { - const uint8 *aFileAddress; - size_t aLength; - mVersionId = mAtomicFile.enterWrite(aFileAddress, aLength, mFileRef); - mWriting = true; - { - // Aquire the mutex protecting mDbVersion - StLock _l(mDbVersionLock); - if (mDbVersion == nil || mDbVersion->getVersionId() != mVersionId) - { - // This will call enterRead(). Now that we hold the write - // lock on the file this ensures we get the same verison - // enterWrite just returned. - mDbVersion = new DbVersion(mAtomicFile, mDb); - } - } + mAtomicTempFile = mAtomicFile.write(); + // Now we are holding the write lock make sure we get the latest greatest version of the db. + // Also set mVersionId to one more that that of the old database. + mVersionId = getDbVersion()->getVersionId() + 1; + + // Never make a database with mVersionId 0 since it makes bad things happen to Jaguar and older systems + if (mVersionId == 0) + mVersionId = 1; // Remove all old modified tables for_each_map_delete(mModifiedTableMap.begin(), mModifiedTableMap.end()); @@ -1425,6 +1406,7 @@ DbModifier::updateRecord(Table::Id inTableId, const RecordId &inRecordId, const CssmData *inData, CSSM_DB_MODIFY_MODE inModifyMode) { + // @@@ Investigate why update is forcing a commit unlike delete and insert? commit(); // XXX this is not thread safe, but what is? modifyDatabase(); return findTable(inTableId).updateRecord(inRecordId, inAttributes, inData, inModifyMode); @@ -1481,8 +1463,8 @@ DbModifier::writeAuthSection(uint32 inSectionOffset) uint32 anOffset = anAuthSection.put(0, 0); anAuthSection.size(anOffset); - mAtomicFile.write(AtomicFile::FromStart, inSectionOffset, - anAuthSection.address(), anAuthSection.size()); + mAtomicTempFile->write(AtomicFile::FromStart, inSectionOffset, + anAuthSection.address(), anAuthSection.size()); return inSectionOffset + anOffset; } @@ -1505,12 +1487,12 @@ DbModifier::writeSchemaSection(uint32 inSectionOffset) // this section into the tables array aTableSection.put(OffsetTables + AtomSize * aTableNumber, anOffset - inSectionOffset); - anOffset = anIt->second->writeTable(mAtomicFile, anOffset); + anOffset = anIt->second->writeTable(*mAtomicTempFile, anOffset); } aTableSection.put(OffsetSchemaSize, anOffset - inSectionOffset); - mAtomicFile.write(AtomicFile::FromStart, inSectionOffset, - aTableSection.address(), aTableSection.size()); + mAtomicTempFile->write(AtomicFile::FromStart, inSectionOffset, + aTableSection.address(), aTableSection.size()); return anOffset; } @@ -1518,7 +1500,7 @@ DbModifier::writeSchemaSection(uint32 inSectionOffset) void DbModifier::commit() { - if (!mWriting) + if (!mAtomicTempFile) return; try { @@ -1539,31 +1521,32 @@ DbModifier::commit() // Write out the file header. aHeaderSection.put(OffsetMagic, HeaderMagic); aHeaderSection.put(OffsetVersion, HeaderVersion); - mAtomicFile.write(AtomicFile::FromStart, HeaderOffset, - aHeaderSection.address(), aHeaderSection.size()); + mAtomicTempFile->write(AtomicFile::FromStart, HeaderOffset, + aHeaderSection.address(), aHeaderSection.size()); + + // Write out the versionId. + WriteSection aVersionSection(CssmAllocator::standard(), size_t(AtomSize)); + anOffset = aVersionSection.put(0, mVersionId); + aVersionSection.size(anOffset); + + mAtomicTempFile->write(AtomicFile::FromEnd, 0, + aVersionSection.address(), aVersionSection.size()); + + mAtomicTempFile->commit(); + mAtomicTempFile = NULL; } catch(...) { - try - { - rollback(); // Sets mWriting to false; - } - catch(...) {} + rollback(); throw; } - - mWriting = false; - mAtomicFile.commit(); } void -DbModifier::rollback() +DbModifier::rollback() throw() { - if (mWriting) - { - mWriting = false; - mAtomicFile.rollback(); - } + // This will destroy the AtomicTempFile if we have one causing it to rollback. + mAtomicTempFile = NULL; } const RecordId @@ -1797,28 +1780,57 @@ AppleDatabaseManager::make(const DbName &inDbName) return new AppleDatabase(inDbName, mTableNames); } + // // AppleDbContext implementation // + +/* This is the version 0 CSSM_APPLEDL_OPEN_PARAMETERS struct used up to 10.2.x. */ +extern "C" { + +typedef struct cssm_appledl_open_parameters_v0 +{ + uint32 length; /* Should be sizeof(CSSM_APPLEDL_OPEN_PARAMETERS_V0). */ + uint32 version; /* Should be 0. */ + CSSM_BOOL autoCommit; +} CSSM_APPLEDL_OPEN_PARAMETERS_V0; + +}; + AppleDbContext::AppleDbContext(Database &inDatabase, DatabaseSession &inDatabaseSession, CSSM_DB_ACCESS_TYPE inAccessRequest, const AccessCredentials *inAccessCred, const void *inOpenParameters) : - DbContext(inDatabase, inDatabaseSession, inAccessRequest, inAccessCred) + DbContext(inDatabase, inDatabaseSession, inAccessRequest, inAccessCred), + mAutoCommit(true), + mMode(0666) { const CSSM_APPLEDL_OPEN_PARAMETERS *anOpenParameters = reinterpret_cast(inOpenParameters); + if (anOpenParameters) { - if (anOpenParameters->length < sizeof(CSSM_APPLEDL_OPEN_PARAMETERS) - || anOpenParameters->version != 0) - CssmError::throwMe(CSSMERR_APPLEDL_INVALID_OPEN_PARAMETERS); + switch (anOpenParameters->version) + { + case 1: + if (anOpenParameters->length < sizeof(CSSM_APPLEDL_OPEN_PARAMETERS)) + CssmError::throwMe(CSSMERR_APPLEDL_INVALID_OPEN_PARAMETERS); + + if (anOpenParameters->mask & kCSSM_APPLEDL_MASK_MODE) + mMode = anOpenParameters->mode; + /*DROPTHROUGH*/ + case 0: + if (anOpenParameters->length < sizeof(CSSM_APPLEDL_OPEN_PARAMETERS_V0)) + CssmError::throwMe(CSSMERR_APPLEDL_INVALID_OPEN_PARAMETERS); + + mAutoCommit = anOpenParameters->autoCommit == CSSM_FALSE ? false : true; + break; - mAutoCommit = anOpenParameters->autoCommit == CSSM_FALSE ? false : true; + default: + CssmError::throwMe(CSSMERR_APPLEDL_INVALID_OPEN_PARAMETERS); + } } - else - mAutoCommit = true; } AppleDbContext::~AppleDbContext() @@ -1842,7 +1854,7 @@ AppleDatabase::AppleDatabase(const DbName &inDbName, const AppleDatabaseTableNam schemaParsingModule(tableNames[AppleDatabaseTableName::kSchemaParsingModule].mTableId, sizeof(AttrSchemaParsingModule) / sizeof(CSSM_DB_ATTRIBUTE_INFO), const_cast(AttrSchemaParsingModule)), - mAtomicFile(mDbName), + mAtomicFile(mDbName.dbName()), mDbModifier(mAtomicFile, *this), mTableNames(tableNames) { @@ -1881,17 +1893,18 @@ void AppleDatabase::dbCreate(DbContext &inDbContext, const CSSM_DBINFO &inDBInfo, const CSSM_ACL_ENTRY_INPUT *inInitialAclEntry) { + AppleDbContext &context = safer_cast(inDbContext); try { StLock _(mWriteLock); - mDbModifier.createDatabase(inDBInfo, inInitialAclEntry); + mDbModifier.createDatabase(inDBInfo, inInitialAclEntry, context.mode()); } catch(...) { mDbModifier.rollback(); throw; } - if (safer_cast(inDbContext).autoCommit()) + if (context.autoCommit()) mDbModifier.commit(); } @@ -2240,5 +2253,3 @@ AppleDatabase::passThrough(DbContext &dbContext, break; } } - - diff --git a/cdsa/cdsa_utilities/AppleDatabase.h b/cdsa/cdsa_utilities/AppleDatabase.h index 5151ecb7..1b6d27c1 100644 --- a/cdsa/cdsa_utilities/AppleDatabase.h +++ b/cdsa/cdsa_utilities/AppleDatabase.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2000-2001, 2003 Apple Computer, Inc. All Rights Reserved. * * The contents of this file constitute Original Code as defined in and are * subject to the Apple Public Source License Version 1.2 (the 'License'). @@ -71,18 +71,6 @@ public: Table(const ReadSection &inTableSection); ~Table(); -#if 0 - Table(const CSSM_DB_RECORD_ATTRIBUTE_INFO &inInfo) : - mMetaRecord (inInfo) {} - Table(Id inTableId, const string &inTableName, - uint32 inNumberOfAttributes, - const CSSM_DB_SCHEMA_ATTRIBUTE_INFO *inAttributeInfo, - uint32 inNumberOfIndexes, - const CSSM_DB_SCHEMA_INDEX_INFO *inIndexInfo) : - mMetaRecord(inTableId, inTableName, - inNumberOfAttributes, inAttributeInfo) - { /* XXX Use inIndexInfo */ } -#endif // Return a newly created cursor satisfying inQuery on the receiving table // The returned Cursor may or may not use indexes depending on their availability. @@ -152,7 +140,7 @@ public: // Mark the record with inRecordId as deleted. void deleteRecord(const RecordId &inRecordId); - const RecordId insertRecord(AtomicFile::VersionId inVersionId, + const RecordId insertRecord(uint32 inVersionId, const CSSM_DB_RECORD_ATTRIBUTE_DATA *inAttributes, const CssmData *inData); const RecordId updateRecord(const RecordId &inRecordId, @@ -167,7 +155,7 @@ public: DbMutableIndex &findIndex(uint32 indexId, const MetaRecord &metaRecord, bool isUniqueIndex); // Write this table to inOutputFile at inSectionOffset and return the new offset. - uint32 writeTable(AtomicFile &inOutputFile, uint32 inSectionOffset); + uint32 writeTable(AtomicTempFile &inAtomicTempFile, uint32 inSectionOffset); private: // Return the next available record number for this table. @@ -244,14 +232,10 @@ class DbVersion : public Metadata, public RefCount { NOCOPY(DbVersion) public: - DbVersion(AtomicFile &inDatabaseFile, const class AppleDatabase &db); + DbVersion(const class AppleDatabase &db, const RefPointer &inAtomicBufferedFile); ~DbVersion(); - // Return true if the file on which this DbVersion is based - // has been modified. - bool isDirty() const; - - AtomicFile::VersionId getVersionId() const { return mVersionId; } + uint32 getVersionId() const { return mVersionId; } const RecordId getRecord(Table::Id inTableId, const RecordId &inRecordId, CSSM_DB_RECORD_ATTRIBUTE_DATA *inoutAttributes, CssmData *inoutData, CssmAllocator &inAllocator) const; @@ -264,13 +248,13 @@ private: void open(); // Part of constructor contract. ReadSection mDatabase; - AtomicFile *mDatabaseFile; - AtomicFile::VersionId mVersionId; + uint32 mVersionId; friend class DbModifier; // XXX Fixme typedef map TableMap; TableMap mTableMap; const class AppleDatabase &mDb; + RefPointer mBufferedFile; public: typedef Table value_type; @@ -413,13 +397,14 @@ public: // Whole database affecting members. void createDatabase(const CSSM_DBINFO &inDbInfo, - const CSSM_ACL_ENTRY_INPUT *inInitialAclEntry); + const CSSM_ACL_ENTRY_INPUT *inInitialAclEntry, + mode_t mode); void openDatabase(); // This is optional right now. void closeDatabase(); void deleteDatabase(); void commit(); - void rollback(); + void rollback() throw(); // Record changing members void deleteRecord(Table::Id inTableId, const RecordId &inRecordId); @@ -469,9 +454,8 @@ private: Mutex mDbVersionLock; AtomicFile &mAtomicFile; - AtomicFile::VersionId mVersionId; - AtomicFile::FileRef mFileRef; - bool mWriting; + uint32 mVersionId; + RefPointer mAtomicTempFile; typedef map ModifiedTableMap; ModifiedTableMap mModifiedTableMap; @@ -506,9 +490,11 @@ public: virtual ~AppleDbContext(); bool autoCommit() const { return mAutoCommit; } void autoCommit(bool on) { mAutoCommit = on; } - + mode_t mode() const { return mMode; } + private: bool mAutoCommit; + mode_t mMode; }; // diff --git a/cdsa/cdsa_utilities/AtomicFile.cpp b/cdsa/cdsa_utilities/AtomicFile.cpp index f7be0728..bbde5634 100644 --- a/cdsa/cdsa_utilities/AtomicFile.cpp +++ b/cdsa/cdsa_utilities/AtomicFile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2000-2001, 2003 Apple Computer, Inc. All Rights Reserved. * * The contents of this file constitute Original Code as defined in and are * subject to the Apple Public Source License Version 1.2 (the 'License'). @@ -16,583 +16,433 @@ */ -// -// AtomicFile.cpp - Description t.b.d. -// -#ifdef __MWERKS__ -#define _CPP_ATOMICFILE -#endif - #include -#include -#include -#include -#include -#include -#include +#include -#if _USE_IO == _USE_IO_POSIX -#include +#include +#include +#include +#include +#include #include -#include +#include -#include -//#include -#include -#include -#include -#include -#elif _USE_IO == _USE_IO_MACOS -typedef SInt32 ssize_t; -#endif +#define kAtomicFileMaxBlockSize INT_MAX -using namespace std; -AtomicFile::AtomicFile(const DbName &inDbName) : - mReadFile(nil), - mReadFilename(inDbName.dbName()), - mWriteFile(nil), - mWriteFilename(mReadFilename + ",") // XXX Do some more work here like resolving symlinks/aliases etc. +// +// AtomicFile.cpp - Description t.b.d. +// +AtomicFile::AtomicFile(const std::string &inPath) : + mPath(inPath) { - debug("atomicfile", "%p construct name=%s", this, mReadFilename.c_str()); - // We only support databases with string names of non-zero length. - if (inDbName.dbLocation() != nil || inDbName.dbName().length() == 0) - CssmError::throwMe(CSSMERR_DL_INVALID_DB_LOCATION); + pathSplit(inPath, mDir, mFile); } AtomicFile::~AtomicFile() { - // Assume there are no more running theads in this object. - debug("atomicfile", "%p destroyed", this); - - // Try hard to clean up as much as possible. - try - { - // Rollback any pending write. - if (mWriteFile) - rollback(); - } - catch(...) {} - - // Close and delete all files in mOpenFileMap - for (OpenFileMap::iterator it = mOpenFileMap.begin(); it != mOpenFileMap.end(); it++) - { - try - { - it->second->close(); - } - catch(...) {} - try - { - delete it->second; - } - catch(...) {} - } } +// Aquire the write lock and remove the file. void -AtomicFile::close() +AtomicFile::performDelete() { - debug("atomicfile", "%p close", this); - StLock _(mReadLock); - - // If we have no read file we have nothing to close. - if (mReadFile == nil) - return; + AtomicLockedFile lock(*this); + if (::unlink(mPath.c_str()) != 0) + { + int error = errno; + secdebug("atomicfile", "unlink %s: %s", mPath.c_str(), strerror(error)); + if (error == ENOENT) + CssmError::throwMe(CSSMERR_DL_DATASTORE_DOESNOT_EXIST); + else + UnixError::throwMe(error); + } +} - // Remember mReadFile and set it to nil, so that it will be closed after any pending write completes - OpenFile *aOpenFile = mReadFile; - mReadFile = nil; +// Aquire the write lock and rename the file (and bump the version and stuff). +void +AtomicFile::rename(const std::string &inNewPath) +{ + const char *path = mPath.c_str(); + const char *newPath = inNewPath.c_str(); - // If aOpenFile has a zero use count no other thread is currently using it, - // so we can safely remove it from the map. - if (aOpenFile->mUseCount == 0) - { - // Do not close any files (nor remove them from the map) while some thread is writing - // since doing so might release the lock we are holding. - if (mWriteLock.tryLock()) - { - // Release the write lock immediately since tryLock just aquired it and we don't want to write. - mWriteLock.unlock(); - - // Remove aOpenFile from the map of open files. - mOpenFileMap.erase(aOpenFile->versionId()); - try - { - aOpenFile->close(); - } - catch(...) - { - delete aOpenFile; - throw; - } - delete aOpenFile; - } - } + // @@@ lock the destination file too. + AtomicLockedFile lock(*this); + if (::rename(path, newPath) != 0) + { + int error = errno; + secdebug("atomicfile", "rename(%s, %s): %s", path, newPath, strerror(error)); + UnixError::throwMe(error); + } } -AtomicFile::VersionId -AtomicFile::enterRead(const uint8 *&outFileAddress, size_t &outLength) +// Lock the file for writing and return a newly created AtomicTempFile. +RefPointer +AtomicFile::create(mode_t mode) { - StLock _(mReadLock); + const char *path = mPath.c_str(); - // If we already have a read file check if it is still current. - if (mReadFile != nil) - { - if (mReadFile->isDirty()) - { - // Remember mReadFile and set it to nil in case an exception is thrown - OpenFile *aOpenFile = mReadFile; - mReadFile = nil; - - // If aOpenFile has a zero use count no other thread is currently using it, - // so we can safely remove it from the map. - if (aOpenFile->mUseCount == 0) - { - // Do not close any files (nor remove them from the map) while some thread is writing - // since doing so might release the lock we are holding. - if (mWriteLock.tryLock()) - { - // Release the write lock immediately since tryLock just aquired it and we don't want to write. - mWriteLock.unlock(); - - // Remove aOpenFile from the map of open files. - mOpenFileMap.erase(aOpenFile->versionId()); - try - { - aOpenFile->close(); - } - catch(...) - { - delete aOpenFile; - throw; - } - delete aOpenFile; - } - } - } - } + // First make sure the directory to this file exists and is writable + mkpath(mDir); - // If we never had or no longer have an open read file. Open it now. - if (mReadFile == nil) + RefPointer lock(new AtomicLockedFile(*this)); + int fileRef = ropen(path, O_WRONLY|O_CREAT|O_EXCL, mode); + if (fileRef == -1) { - mReadFile = new OpenFile(mReadFilename, false, false, 0, 0); - mOpenFileMap.insert(OpenFileMap::value_type(mReadFile->versionId(), mReadFile)); + int error = errno; + secdebug("atomicfile", "open %s: %s", path, strerror(error)); + + // Do the obvious error code translations here. + // @@@ Consider moving these up a level. + if (error == EACCES) + CssmError::throwMe(CSSM_ERRCODE_OS_ACCESS_DENIED); + else if (error == EEXIST) + CssmError::throwMe(CSSMERR_DL_DATASTORE_ALREADY_EXISTS); + else + UnixError::throwMe(error); } - // Note that mReadFile->isDirty() might actually return true here, but all that means is - // that we are looking at data that was commited after we opened the file which might - // happen in a few miliseconds anyway. + rclose(fileRef); - // Bump up the use count of our OpenFile. - mReadFile->mUseCount++; + try + { + // Now that we have created the lock and the new db file create a tempfile + // object. + RefPointer temp(new AtomicTempFile(*this, lock, mode)); + secdebug("atomicfile", "%p created %s", this, path); + return temp; + } + catch (...) + { + // Creating the temp file failed so remove the db file we just created too. + if (::unlink(path) == -1) + { + secdebug("atomicfile", "unlink %s: %s", path, strerror(errno)); + } + throw; + } +} - // Return the length of the file and the mapped address. - outLength = mReadFile->length(); - outFileAddress = mReadFile->address(); - return mReadFile->versionId(); +// Lock the database file for writing and return a newly created AtomicTempFile. +RefPointer +AtomicFile::write() +{ + RefPointer lock(new AtomicLockedFile(*this)); + return new AtomicTempFile(*this, lock); } -void -AtomicFile::exitRead(VersionId inVersionId) +// Return a bufferedFile containing current version of the file for reading. +RefPointer +AtomicFile::read() { - StLock _(mReadLock); - OpenFileMap::iterator it = mOpenFileMap.find(inVersionId); - // If the inVersionId is not in the map anymore something really bad happned. - if (it == mOpenFileMap.end()) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); - - OpenFile *aOpenFile = it->second; - aOpenFile->mUseCount--; - - // Don't close the current active file even if its mUseCount hits 0 since someone - // else will probably request it soon. - if (aOpenFile->mUseCount == 0 && aOpenFile != mReadFile) - { - // Do not close any files (nor remove them from the map) while some thread is writing - // since doing so might release the lock we are holding. - if (mWriteLock.tryLock()) - { - // Release the write lock immidiatly since tryLock just aquired it and we don't want to write. - mWriteLock.unlock(); - - // Remove from the map, close and delete aOpenFile. - mOpenFileMap.erase(it); - try - { - aOpenFile->close(); - } - catch(...) - { - delete aOpenFile; - throw; - } - delete aOpenFile; - } - } + return new AtomicBufferedFile(mPath); } -bool AtomicFile::isDirty(VersionId inVersionId) +mode_t +AtomicFile::mode() const { - StLock _(mReadLock); - OpenFileMap::iterator it = mOpenFileMap.find(inVersionId); - // If the inVersionId is not in the map anymore something really bad happned. - if (it == mOpenFileMap.end()) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); + const char *path = mPath.c_str(); + struct stat st; + if (::stat(path, &st) == -1) + { + int error = errno; + secdebug("atomicfile", "stat %s: %s", path, strerror(error)); + UnixError::throwMe(error); + } + return st.st_mode; +} - return it->second->isDirty(); +// Split full into a dir and file component. +void +AtomicFile::pathSplit(const std::string &inFull, std::string &outDir, std::string &outFile) +{ + std::string::size_type slash, len = inFull.size(); + slash = inFull.rfind('/'); + if (slash == std::string::npos) + { + outDir = ""; + outFile = inFull; + } + else if (slash + 1 == len) + { + outDir = inFull; + outFile = ""; + } + else + { + outDir = inFull.substr(0, slash + 1); + outFile = inFull.substr(slash + 1, len); + } } +// +// Make sure the directory up to inDir exists inDir *must* end in a slash. +// void -AtomicFile::performDelete() +AtomicFile::mkpath(const std::string &inDir, mode_t mode) { - // Prevent any other threads in this process from writing. - mWriteLock.lock(); + for (std::string::size_type pos = 0; (pos = inDir.find('/', pos + 1)) != std::string::npos;) + { + std::string path = inDir.substr(0, pos); + const char *cpath = path.c_str(); + struct stat sb; + if (::stat(cpath, &sb)) + { + if (errno != ENOENT || ::mkdir(cpath, mode)) + UnixError::throwMe(errno); + } + else if (!S_ISDIR(sb.st_mode)) + CssmError::throwMe(CSSM_ERRCODE_OS_ACCESS_DENIED); // @@@ Should be is a directory + } +} - OpenFile *aReadFile = nil; - try - { - // Keep reopening mReadFilename until the lock has been aquired on a non-dirty file. - // XXX This is a potential infinite loop. - for (;;) - { - aReadFile = new OpenFile(mReadFilename, true, true, 0, 0); - if (!aReadFile->isDirty()) - break; +int +AtomicFile::ropen(const char *const name, int flags, mode_t mode) +{ + int fd, tries_left = 4 /* kNoResRetry */; + do + { + fd = ::open(name, flags, mode); + } while (fd < 0 && (errno == EINTR || errno == ENFILE && --tries_left >= 0)); - aReadFile->close(); - delete aReadFile; - aReadFile = nil; - } + return fd; +} - // Aquire the read lock so no other thread will open the file - StLock _(mReadLock); +int +AtomicFile::rclose(int fd) +{ + int result; + do + { + result = ::close(fd); + } while(result && errno == EINTR); - // Delete the file. - unlink(mReadFilename); + return result; +} - // Clear our current mReadFile since it refers to the deleted file. - mReadFile = nil; +// +// AtomicBufferedFile - This represents an instance of a file opened for reading. +// The file is read into memory and closed after this is done. +// The memory is released when this object is destroyed. +// +AtomicBufferedFile::AtomicBufferedFile(const std::string &inPath) : + mPath(inPath), + mFileRef(-1), + mBuffer(NULL), + mLength(0) +{ +} - // Mark the old file as modified - aReadFile->setDirty(); +AtomicBufferedFile::~AtomicBufferedFile() +{ + if (mFileRef >= 0) + { + AtomicFile::rclose(mFileRef); + secdebug("atomicfile", "%p closed %s", this, mPath.c_str()); + } - // Close any open files. - endWrite(); - } - catch(...) - { - if (aReadFile) - { - try - { - VersionId aVersionId = aReadFile->versionId(); - aReadFile->close(); - mOpenFileMap.erase(aVersionId); - } catch(...) {} - delete aReadFile; - } - endWrite(); - throw; - } - endWrite(); + if (mBuffer) + { + secdebug("atomicfile", "%p free %s buffer %p", this, mPath.c_str(), mBuffer); + free(mBuffer); + } } -AtomicFile::VersionId -AtomicFile::enterCreate(FileRef &outWriteRef) +// +// Open the file and return the length in bytes. +// +off_t +AtomicBufferedFile::open() { - // Prevent any other threads in this process from writing. - mWriteLock.lock(); - OpenFile *aReadFile = nil; - try + const char *path = mPath.c_str(); + if (mFileRef >= 0) + { + secdebug("atomicfile", "open %s: already open, closing and reopening", path); + close(); + } + + mFileRef = AtomicFile::ropen(path, O_RDONLY, 0); + if (mFileRef == -1) { - // No threads can read during creation - StLock _(mReadLock); + int error = errno; + secdebug("atomicfile", "open %s: %s", path, strerror(error)); - // Create mReadFilename until the lock has been aquired on a non-dirty file. - aReadFile = new OpenFile(mReadFilename, false, true, 1, 0666); + // Do the obvious error code translations here. + // @@@ Consider moving these up a level. + if (error == ENOENT) + CssmError::throwMe(CSSMERR_DL_DATASTORE_DOESNOT_EXIST); + else if (error == EACCES) + CssmError::throwMe(CSSM_ERRCODE_OS_ACCESS_DENIED); + else + UnixError::throwMe(error); + } - // Open mWriteFile for writing. - mWriteFile = new OpenFile(mWriteFilename, true, false, aReadFile->versionId() + 1, 0666); + mLength = ::lseek(mFileRef, 0, SEEK_END); + if (mLength == -1) + { + int error = errno; + secdebug("atomicfile", "lseek(%s, END): %s", path, strerror(error)); + AtomicFile::rclose(mFileRef); + UnixError::throwMe(error); + } - // Insert aReadFile into the map (do this after opening mWriteFile just in case that throws). - mOpenFileMap.insert(OpenFileMap::value_type(-1, aReadFile)); + secdebug("atomicfile", "%p opened %s: %qd bytes", this, path, mLength); - outWriteRef = mWriteFile->fileRef(); - mCreating = true; // So rollback() will delete mReadFileName. - return aReadFile->versionId(); - } - catch(...) - { - // Make sure we don't thow during cleanup since that would clobber the original - // error and prevent us from releasing mWriteLock - try - { - if (aReadFile) - { - try - { - aReadFile->close(); - // XXX We should only unlink if we know that no one else is currently creating the file. - //unlink(mReadFilename); - mOpenFileMap.erase(-1); - } catch(...) {} - delete aReadFile; - } - - if (mWriteFile) - { - try - { - mWriteFile->close(); - unlink(mWriteFilename); - } catch(...) {} - delete mWriteFile; - mWriteFile = nil; - } - } - catch(...) {} // Do not throw since we already have an error. - - // Release the write lock and remove any unused files from the map - endWrite(); - throw; - } + return mLength; } -AtomicFile::VersionId -AtomicFile::enterWrite(const uint8 *&outFileAddress, size_t &outLength, FileRef &outWriteRef) +// +// Read the file starting at inOffset for inLength bytes into the buffer and return +// a pointer to it. On return outLength contain the actual number of bytes read, it +// will only ever be less than inLength if EOF was reached, and it will never be more +// than inLength. +// +const uint8 * +AtomicBufferedFile::read(off_t inOffset, off_t inLength, off_t &outLength) { - // Wait for all other threads in this process to finish writing. - mWriteLock.lock(); - mCreating = false; // So rollback() will not delete mReadFileName. - OpenFile *aReadFile = nil; - try - { - // Keep reopening mReadFilename until the lock has been aquired on a non-dirty file. - // XXX This is a potential infinite loop. - for (;;) - { - aReadFile = new OpenFile(mReadFilename, true, true, 0, 0); - if (!aReadFile->isDirty()) - break; - - aReadFile->close(); - delete aReadFile; - aReadFile = nil; - } - - // We have the write lock on the file now we start modifying our shared data - // stuctures so aquire the read lock. - StLock _(mReadLock); - - // Open mWriteFile for writing. - mWriteFile = new OpenFile(mWriteFilename, true, false, aReadFile->versionId() + 1, aReadFile->mode()); - - // Insert aReadFile into the map (do this after opening mWriteFile just in case that throws). - mOpenFileMap.insert(OpenFileMap::value_type(-1, aReadFile)); - - outWriteRef = mWriteFile->fileRef(); - outLength = aReadFile->length(); - outFileAddress = aReadFile->address(); - return aReadFile->versionId(); - } - catch(...) - { - // Make sure we don't thow during cleanup since that would clobber the original - // error and prevent us from releasing mWriteLock - try - { - if (aReadFile) - { - try - { - aReadFile->close(); - mOpenFileMap.erase(-1); - } catch(...) {} - delete aReadFile; - } - - if (mWriteFile) - { - try - { - mWriteFile->close(); - unlink(mWriteFilename); - } catch(...) {} - delete mWriteFile; - mWriteFile = nil; - } - } - catch(...) {} // Do not throw since we already have an error. - - // Release the write lock and remove any unused files from the map - endWrite(); - throw; - } -} + if (mFileRef < 0) + { + secdebug("atomicfile", "read %s: file yet not opened, opening", mPath.c_str()); + open(); + } -AtomicFile::VersionId -AtomicFile::commit() -{ - debug("atomicfile", "%p commit", this); - StLock _(mReadLock); - if (mWriteFile == nil) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); + off_t bytesLeft = inLength; + uint8 *ptr; + if (mBuffer) + { + secdebug("atomicfile", "%p free %s buffer %p", this, mPath.c_str(), mBuffer); + free(mBuffer); + } - try - { - VersionId aVersionId = mWriteFile->versionId(); - mWriteFile->close(); - delete mWriteFile; - mWriteFile = nil; + mBuffer = ptr = reinterpret_cast(malloc(bytesLeft)); + secdebug("atomicfile", "%p allocated %s buffer %p size %qd", this, mPath.c_str(), mBuffer, bytesLeft); + off_t pos = inOffset; + while (bytesLeft) + { + size_t toRead = bytesLeft > kAtomicFileMaxBlockSize ? kAtomicFileMaxBlockSize : size_t(bytesLeft); + ssize_t bytesRead = ::pread(mFileRef, ptr, toRead, pos); + if (bytesRead == -1) + { + int error = errno; + if (error == EINTR) + { + // We got interrupted by a signal, so try again. + secdebug("atomicfile", "pread %s: interrupted, retrying", mPath.c_str()); + continue; + } - OpenFileMap::iterator it = mOpenFileMap.find(-1); - if (it == mOpenFileMap.end()) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); + secdebug("atomicfile", "pread %s: %s", mPath.c_str(), strerror(error)); + free(mBuffer); + mBuffer = NULL; + UnixError::throwMe(error); + } - // First rename the file and them mark the old one as modified - rename(mWriteFilename, mReadFilename); - OpenFile *aOpenFile = it->second; + // Read returning 0 means EOF was reached so we're done. + if (bytesRead == 0) + break; - // Clear our current mReadFile since it refers to the old file. - mReadFile = nil; + secdebug("atomicfile", "%p read %s: %d bytes to %p", this, mPath.c_str(), bytesRead, ptr); - // Mark the old file as modified - aOpenFile->setDirty(); + bytesLeft -= bytesRead; + ptr += bytesRead; + pos += bytesRead; + } - // Close all unused files (in particular aOpenFile) and remove them from mOpenFileMap - endWrite(); - debug("atomicfile", "%p commit done", this); - return aVersionId; - } - catch (...) - { - // Unlink the new file to rollback the transaction and close any open files. - try - { - unlink(mWriteFilename); - }catch(...) {} - endWrite(); - debug("atomicfile", "%p commit failed, rethrowing", this); - throw; - } + // Compute length + outLength = ptr - mBuffer; + + return mBuffer; } void -AtomicFile::rollback() +AtomicBufferedFile::close() { - debug("atomicfile", "%p rollback", this); - StLock _(mReadLock); - if (mWriteFile == nil) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); + if (mFileRef < 0) + { + secdebug("atomicfile", "close %s: already closed", mPath.c_str()); + } + else + { + int result = AtomicFile::rclose(mFileRef); + mFileRef = -1; + if (result == -1) + { + int error = errno; + secdebug("atomicfile", "close %s: %s", mPath.c_str(), strerror(errno)); + UnixError::throwMe(error); + } - try - { - mWriteFile->close(); - delete mWriteFile; - mWriteFile = nil; - - // First rename the file and them mark the old one as modified - unlink(mWriteFilename); - if (mCreating) - unlink(mReadFilename); - endWrite(); - debug("atomicfile", "%p rollback complete", this); - } - catch(...) - { - // Unlink the new file to rollback the transaction and close any open files. - try - { - unlink(mWriteFilename); - }catch(...) {} - endWrite(); - debug("atomicfile", "%p rollback failed, rethrowing", this); - throw; - } + secdebug("atomicfile", "%p closed %s", this, mPath.c_str()); + } } -// This private function is called by a successfull commit(), rollback() or performDelete() as well -// as by a failed enterWrite() or enterCreate(). -void -AtomicFile::endWrite() + +// +// AtomicTempFile - A temporary file to write changes to. +// +AtomicTempFile::AtomicTempFile(AtomicFile &inFile, const RefPointer &inLockedFile, mode_t mode) : + mFile(inFile), + mLockedFile(inLockedFile), + mCreating(true) { - try - { - // We need to go in and close and delete all unused files from the queue - stack aDeleteList; - OpenFileMap::iterator it; - for (it = mOpenFileMap.begin(); - it != mOpenFileMap.end(); - it++) - { - OpenFile *aOpenFile = it->second; - // If aOpenFile is unused and it is not the mReadFile schedule it for close and removal. - // Note that if this is being called after a commit mReadFile will have been set to nil. - if (aOpenFile != mReadFile && aOpenFile->mUseCount == 0) - aDeleteList.push(it->first); - } - - // Remove everything that was scheduled for removal - while (!aDeleteList.empty()) - { - it = mOpenFileMap.find(aDeleteList.top()); - aDeleteList.pop(); - try - { - it->second->close(); - } - catch(...) {} - delete it->second; - mOpenFileMap.erase(it); - } - - if (mWriteFile) - { - mWriteFile->close(); - } - } - catch(...) - { - delete mWriteFile; - mWriteFile = nil; - mWriteLock.unlock(); - throw; - } + create(mode); +} - delete mWriteFile; - mWriteFile = nil; - mWriteLock.unlock(); +AtomicTempFile::AtomicTempFile(AtomicFile &inFile, const RefPointer &inLockedFile) : + mFile(inFile), + mLockedFile(inLockedFile), + mCreating(false) +{ + create(mFile.mode()); } -void -AtomicFile::rename(const string &inSrcFilename, const string &inDestFilename) +AtomicTempFile::~AtomicTempFile() { - if (::rename(inSrcFilename.c_str(), inDestFilename.c_str())) - UnixError::throwMe(errno); + // rollback if we didn't commit yet. + if (mFileRef >= 0) + rollback(); } +// +// Open the file and return the length in bytes. +// void -AtomicFile::unlink(const string &inFilename) +AtomicTempFile::create(mode_t mode) { - if (::unlink(inFilename.c_str())) - UnixError::throwMe(errno); + mPath = mFile.dir() + "," + mFile.file(); + const char *path = mPath.c_str(); + + mFileRef = AtomicFile::ropen(path, O_WRONLY|O_CREAT|O_TRUNC, mode); + if (mFileRef == -1) + { + int error = errno; + secdebug("atomicfile", "open %s: %s", path, strerror(error)); + + // Do the obvious error code translations here. + // @@@ Consider moving these up a level. + if (error == EACCES) + CssmError::throwMe(CSSM_ERRCODE_OS_ACCESS_DENIED); + else + UnixError::throwMe(error); + } + + secdebug("atomicfile", "%p created %s", this, path); } void -AtomicFile::write(OffsetType inOffsetType, uint32 inOffset, const uint32 inData) +AtomicTempFile::write(AtomicFile::OffsetType inOffsetType, off_t inOffset, const uint32 inData) { uint32 aData = htonl(inData); write(inOffsetType, inOffset, reinterpret_cast(&aData), sizeof(aData)); } void -AtomicFile::write(OffsetType inOffsetType, uint32 inOffset, +AtomicTempFile::write(AtomicFile::OffsetType inOffsetType, off_t inOffset, const uint32 *inData, uint32 inCount) { #ifdef HOST_LONG_IS_NETWORK_LONG - // XXX Optimize this for the case where hl == nl + // Optimize this for the case where hl == nl const uint32 *aBuffer = inData; #else auto_array aBuffer(inCount); @@ -605,435 +455,430 @@ AtomicFile::write(OffsetType inOffsetType, uint32 inOffset, } void -AtomicFile::write(OffsetType inOffsetType, uint32 inOffset, const uint8 *inData, uint32 inLength) -{ - // Seriously paranoid check. - if (mWriteFile == nil) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); - - if (inOffsetType != None) - { - if (::lseek(mWriteFile->mFileRef, inOffset, inOffsetType == FromStart ? SEEK_SET : SEEK_CUR) == -1) - UnixError::throwMe(errno); - } - - if (::write(mWriteFile->mFileRef, reinterpret_cast(inData), - inLength) != static_cast(inLength)) - UnixError::throwMe(errno); -} - -// AtomicFile::OpenFile implementation - -AtomicFile::OpenFile::OpenFile(const string &inFilename, bool write, bool lock, VersionId inVersionId, mode_t mode) : - mUseCount(0), - mVersionId(inVersionId), - mAddress(NULL), - mLength(0) +AtomicTempFile::write(AtomicFile::OffsetType inOffsetType, off_t inOffset, const uint8 *inData, size_t inLength) { - int flags; - if (write && lock) - { - flags = O_RDWR; - mState = ReadWrite; - } - else if (write && !lock) - { - flags = O_WRONLY|O_CREAT|O_TRUNC; - mState = Write; - } - else if (!write && lock) - { - flags = O_WRONLY|O_CREAT|O_TRUNC|O_EXCL; - mState = Create; - } - else - { - flags = O_RDONLY; - mState = Read; - } - debug("atomicfile", "%p openfile(%s,%s%s,%d,0x%x) -> flags=0x%x, state=%d", - this, inFilename.c_str(), write ? "write" : "read", lock ? ",lock" : "", - inVersionId, mode, flags, mState); - - mFileRef = ::open(inFilename.c_str(), flags, mode); - if (mFileRef == -1) - { - int error = errno; - debug("atomicfile", "%p openfile open failed(errno=%d)", this, error); - -#if _USE_IO == _USE_IO_POSIX - // Do the obvious error code translations here. - if (error == ENOENT) + off_t pos; + if (inOffsetType == AtomicFile::FromEnd) + { + pos = ::lseek(mFileRef, 0, SEEK_END); + if (pos == -1) + { + int error = errno; + secdebug("atomicfile", "lseek(%s, %qd): %s", mPath.c_str(), inOffset, strerror(error)); + UnixError::throwMe(error); + } + } + else if (inOffsetType == AtomicFile::FromStart) + pos = inOffset; + else + CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); + + off_t bytesLeft = inLength; + const uint8 *ptr = inData; + while (bytesLeft) + { + size_t toWrite = bytesLeft > kAtomicFileMaxBlockSize ? kAtomicFileMaxBlockSize : size_t(bytesLeft); + ssize_t bytesWritten = ::pwrite(mFileRef, ptr, toWrite, pos); + if (bytesWritten == -1) { - // Throw CSSMERR_DL_DATASTORE_DOESNOT_EXIST even in Write state since it means someone threw away our parent directory. - if (mState == ReadWrite || mState == Read || mState == Write) - CssmError::throwMe(CSSMERR_DL_DATASTORE_DOESNOT_EXIST); - if (mState == Create) + int error = errno; + if (error == EINTR) { - // Attempt to create the path to inFilename since one or more of the directories - // in the path do not yet exist. - mkpath(inFilename); - - // Now try the open again. - mFileRef = ::open(inFilename.c_str(), flags, mode); - debug("atomicfile", "%p openfile reopen %s (%d)", - this, (mFileRef == -1) ? "failed" : "ok", errno); - error = mFileRef == -1 ? errno : 0; - if (error == ENOENT) - CssmError::throwMe(CSSM_ERRCODE_OS_ACCESS_DENIED); + // We got interrupted by a signal, so try again. + secdebug("atomicfile", "write %s: interrupted, retrying", mPath.c_str()); + continue; } - } - if (error == EACCES) - CssmError::throwMe(CSSM_ERRCODE_OS_ACCESS_DENIED); - - if (error == EEXIST) - CssmError::throwMe(CSSMERR_DL_DATASTORE_ALREADY_EXISTS); -#endif - - // Check if we are still in an error state. - if (error) - UnixError::throwMe(errno); - } + secdebug("atomicfile", "write %s: %s", mPath.c_str(), strerror(error)); + UnixError::throwMe(error); + } - // If this is a new file write out the versionId - if (mState == Create) - writeVersionId(mVersionId); + // Write returning 0 is bad mmkay. + if (bytesWritten == 0) + { + secdebug("atomicfile", "write %s: 0 bytes written", mPath.c_str()); + CssmError::throwMe(CSSMERR_DL_INTERNAL_ERROR); + } - // If this is a temp output file we are done. - if (mState == Write) - return; + secdebug("atomicfile", "%p wrote %s %d bytes from %p", this, mPath.c_str(), bytesWritten, ptr); - try - { - mLength = ::lseek(mFileRef, 0, SEEK_END); - if (mLength == static_cast(-1)) - UnixError::throwMe(errno); - if (mLength == 0) - { - // XXX What to set versionId to? - mVersionId = 0; - return; // No point in mapping a zero length file. - } - -#if _USE_IO == _USE_IO_POSIX - // Lock the file if required. - if (lock) - { - struct flock mLock; - mLock.l_start = 0; - mLock.l_len = 1; - mLock.l_pid = getpid(); - mLock.l_type = F_WRLCK; - mLock.l_whence = SEEK_SET; - - // Keep trying to obtain the lock if we get interupted. - for (;;) - { - if (::fcntl(mFileRef, F_SETLKW, reinterpret_cast(&mLock)) == -1) - { - int error = errno; - if (error == EINTR) - continue; - - if (error != ENOTSUP) - UnixError::throwMe(error); - - // XXX Filesystem does not support locking with fcntl use an alternative. - mFcntlLock = false; - } - else - mFcntlLock = true; - - break; - } - } - - if (mState != Create) - { - mAddress = reinterpret_cast - (::mmap(0, mLength, PROT_READ, MAP_FILE|MAP_SHARED, - mFileRef, 0)); - if (mAddress == reinterpret_cast(-1)) - { - mAddress = NULL; - UnixError::throwMe(errno); - } - - mVersionId = readVersionId(); - } -#else - if (mState != Create) - { - mAddress = reinterpret_cast(-1); - auto_array aBuffer(mLength); - if (::read(mFileRef, aBuffer.get(), mLength) != mLength) - UnixError::throwMe(errno); - - mAddress = reinterpret_cast(aBuffer.release()); - mVersionId = readVersionId(); - } -#endif - } - catch(...) - { - if (mState != Closed) - ::close(mFileRef); - throw; - } -} - -AtomicFile::OpenFile::~OpenFile() -{ - close(); + bytesLeft -= bytesWritten; + ptr += bytesWritten; + pos += bytesWritten; + } } void -AtomicFile::OpenFile::close() +AtomicTempFile::fsync() { - IFDEBUG(if (mState != Closed) debug("atomicfile", "%p openfile closing(ref=%d)", - this, mFileRef)); - int error = 0; - if (mAddress != NULL) - { -#if _USE_IO == _USE_IO_POSIX - debug("atomicfile", "%p openfile is unmapping %p:%ld", this, mAddress, mLength); - if (::munmap(const_cast(mAddress), mLength) == -1) - error = errno; -#else - debug("atomicfile", "%p openfile deleting %p", this, mAddress); - delete[] mAddress; -#endif - - mAddress = NULL; - } - - if (mState == Write) - writeVersionId(mVersionId); - - if (mState != Closed) - { - mState = Closed; - if (::close(mFileRef) == -1) - error = errno; - } - - if (error != 0) - UnixError::throwMe(error); -} - -bool -AtomicFile::OpenFile::isDirty() -{ - if (mAddress == NULL) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); - - return (mVersionId != readVersionId()) || mVersionId == 0; -} + if (mFileRef < 0) + { + secdebug("atomicfile", "fsync %s: already closed", mPath.c_str()); + } + else + { + int result; + do + { + result = ::fsync(mFileRef); + } while (result && errno == EINTR); -// Set the files dirty bit (requires the file to be writeable and locked). -void -AtomicFile::OpenFile::setDirty() -{ - if (mState != ReadWrite && mState != Create) - CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR); + if (result == -1) + { + int error = errno; + secdebug("atomicfile", "fsync %s: %s", mPath.c_str(), strerror(errno)); + UnixError::throwMe(error); + } - writeVersionId(0); + secdebug("atomicfile", "%p fsynced %s", this, mPath.c_str()); + } } void -AtomicFile::OpenFile::unlock() +AtomicTempFile::close() { -// XXX This should be called. -#if 0 - if (mFcntlLock) + if (mFileRef < 0) { - struct flock mLock; - mLock.l_start = 0; - mLock.l_len = 1; - mLock.l_pid = getpid(); - mLock.l_type = F_UNLCK; - mLock.l_whence = SEEK_SET; - if (::fcntl(mFileRef, F_SETLK, reinterpret_cast(&mLock)) == -1) - UnixError::throwMe(errno); + secdebug("atomicfile", "close %s: already closed", mPath.c_str()); } -#endif -} + else + { + int result = AtomicFile::rclose(mFileRef); + mFileRef = -1; + if (result == -1) + { + int error = errno; + secdebug("atomicfile", "close %s: %s", mPath.c_str(), strerror(errno)); + UnixError::throwMe(error); + } -mode_t -AtomicFile::OpenFile::mode() -{ - struct stat st; - if (::fstat(mFileRef, &st) == -1) - UnixError::throwMe(errno); - return st.st_mode; + secdebug("atomicfile", "%p closed %s", this, mPath.c_str()); + } } - -AtomicFile::VersionId -AtomicFile::OpenFile::readVersionId() +// Commit the current create or write and close the write file. Note that a throw during the commit does an automatic rollback. +void +AtomicTempFile::commit() { - const uint8 *ptr; - char buf[4]; - - // Read the VersionId - if (mAddress == NULL) - { - // Seek to the end of the file minus 4 - if (mLength < 4) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - - if (::lseek(mFileRef, mLength - 4, SEEK_SET) == -1) - UnixError::throwMe(errno); - - ptr = reinterpret_cast(buf); - if (::read(mFileRef, buf, 4) != 4) - UnixError::throwMe(errno); - } - else - { - ptr = mAddress + mLength - 4; - if (mLength < 4) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - } + try + { + fsync(); + close(); + const char *oldPath = mPath.c_str(); + const char *newPath = mFile.path().c_str(); + if (::rename(oldPath, newPath) == -1) + { + int error = errno; + secdebug("atomicfile", "rename (%s, %s): %s", oldPath, newPath, strerror(errno)); + UnixError::throwMe(error); + } - VersionId aVersionId = 0; - for (int i = 0; i < 4; i++) - { - aVersionId = (aVersionId << 8) + ptr[i]; - } + // Unlock the lockfile + mLockedFile = NULL; - return aVersionId; + secdebug("atomicfile", "%p commited %s", this, oldPath); + } + catch (...) + { + rollback(); + throw; + } } +// Rollback the current create or write (happens automatically if commit() isn't called before the destructor is. void -AtomicFile::OpenFile::writeVersionId(VersionId inVersionId) +AtomicTempFile::rollback() throw() { - if (mState == ReadWrite) + if (mFileRef >= 0) { - // Seek to the end of the file minus 4 - if (mLength < 4) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); + AtomicFile::rclose(mFileRef); + mFileRef = -1; + } - if (::lseek(mFileRef, mLength - 4, SEEK_SET) == -1) - UnixError::throwMe(errno); + // @@@ Log errors if this fails. + const char *path = mPath.c_str(); + if (::unlink(path) == -1) + { + secdebug("atomicfile", "unlink %s: %s", path, strerror(errno)); + // rollback can't throw } - else /* if (mState == Create || mState == Write) */ + + // @@@ Think about this. Depending on how we do locking we might not need this. + if (mCreating) { - // Seek to the end of the file. - if (::lseek(mFileRef, 0, SEEK_END) == -1) - UnixError::throwMe(errno); + const char *path = mFile.path().c_str(); + if (::unlink(path) == -1) + { + secdebug("atomicfile", "unlink %s: %s", path, strerror(errno)); + // rollback can't throw + } } +} - uint8 buf[4]; - // Serialize the VersionId - for (int i = 3; i >= 0; i--) - { - buf[i] = inVersionId & 0xff; - inVersionId = inVersionId >> 8; - } - // Write the VersionId - if (::write(mFileRef, reinterpret_cast(buf), 4) != 4) - UnixError::throwMe(errno); +// +// An advisory write lock for inFile. +// +AtomicLockedFile::AtomicLockedFile(AtomicFile &inFile) : + mDir(inFile.dir()), + mPath(inFile.dir() + "lck~" + inFile.file()) +{ + lock(); } -void -AtomicFile::OpenFile::mkpath(const std::string &inFilename) +AtomicLockedFile::~AtomicLockedFile() { - const char *path = inFilename.c_str(); - struct stat sb; - char dirPath[MAXPATHLEN]; - size_t slash = 0; + unlock(); +} - for (;;) - { - slash += strspn(path + slash, "/"); - slash += strcspn(path + slash, "/"); +std::string +AtomicLockedFile::unique(mode_t mode) +{ + static const int randomPart = 16; + DevRandomGenerator randomGen; + std::string::size_type dirSize = mDir.size(); + std::string fullname(dirSize + randomPart + 2, '\0'); + fullname.replace(0, dirSize, mDir); + fullname[dirSize] = '~'; /* UNIQ_PREFIX */ + char buf[randomPart]; + struct stat filebuf; + int result, fd = -1; - if (path[slash] == '\0') - break; + for (int retries = 0; retries < 10; ++retries) + { + /* Make a random filename. */ + randomGen.random(buf, randomPart); + for (int ix = 0; ix < randomPart; ++ix) + { + char ch = buf[ix] & 0x3f; + fullname[ix + dirSize + 1] = ch + + ( ch < 26 ? 'A' + : ch < 26 + 26 ? 'a' - 26 + : ch < 26 + 26 + 10 ? '0' - 26 - 26 + : ch == 26 + 26 + 10 ? '-' - 26 - 26 - 10 + : '_' - 26 - 26 - 11); + } - if (slash >= MAXPATHLEN) - UnixError::throwMe(ENAMETOOLONG); - strncpy(dirPath, path, slash); - dirPath[slash] = '\0'; + result = lstat(fullname.c_str(), &filebuf); + if (result && errno == ENAMETOOLONG) + { + do + fullname.erase(fullname.end() - 1); + while((result = lstat(fullname.c_str(), &filebuf)) && errno == ENAMETOOLONG && fullname.size() > dirSize + 8); + } /* either it stopped being a problem or we ran out of filename */ - if (stat(dirPath, &sb)) + if (result && errno == ENOENT) { - if (errno != ENOENT || mkdir(dirPath, 0777)) - UnixError::throwMe(errno); + fd = AtomicFile::ropen(fullname.c_str(), O_WRONLY|O_CREAT|O_EXCL, mode); + if (fd >= 0 || errno != EEXIST) + break; } - else if (!S_ISDIR(sb.st_mode)) - CssmError::throwMe(CSSM_ERRCODE_OS_ACCESS_DENIED); // @@@ Should be is a directory } -} + if (fd < 0) + { + int error = errno; + ::syslog(LOG_ERR, "Couldn't create temp file %s: %s", fullname.c_str(), strerror(error)); + secdebug("atomicfile", "Couldn't create temp file %s: %s", fullname.c_str(), strerror(error)); + UnixError::throwMe(error); + } + /* @@@ Check for EINTR. */ + write(fd, "0", 1); /* pid 0, `works' across networks */ -// Constructor uglyness to work around C++ language limitations. -struct AtomicFileRef::InitArg -{ - AtomicFile::VersionId versionId; - const uint8 *address; - size_t length; -}; + AtomicFile::rclose(fd); -AtomicFileRef::~AtomicFileRef() -{ + return fullname; } -AtomicFileRef::AtomicFileRef(AtomicFile &inAtomicFile, const InitArg &inInitArg) : - mVersionId(inInitArg.versionId), - mAtomicFile(inAtomicFile), - mAddress(inInitArg.address), - mLength(inInitArg.length) +/* Return 0 on success and 1 on failure if st is set to the result of stat(old) and -1 on failure if the stat(old) failed. */ +int +AtomicLockedFile::rlink(const char *const old, const char *const newn, struct stat &sto) { + int result = ::link(old,newn); + if (result) + { + int serrno = errno; + if (::lstat(old, &sto) == 0) + { + struct stat stn; + if (::lstat(newn, &stn) == 0 + && sto.st_dev == stn.st_dev + && sto.st_ino == stn.st_ino + && sto.st_uid == stn.st_uid + && sto.st_gid == stn.st_gid + && !S_ISLNK(sto.st_mode)) + { + /* Link failed but files are the same so the link really went ok. */ + return 0; + } + else + result = 1; + } + errno = serrno; /* Restore errno from link() */ + } + + return result; } -AtomicFileReadRef::~AtomicFileReadRef() +/* NFS-resistant rename() + * rename with fallback for systems that don't support it + * Note that this does not preserve the contents of the file. */ +int +AtomicLockedFile::myrename(const char *const old, const char *const newn) { - try { - mAtomicFile.exitRead(mVersionId); - } - catch(...) { + struct stat stbuf; + int fd = -1; + int ret; + + /* Try a real hardlink */ + ret = rlink(old, newn, stbuf); + if (ret > 0) + { + if (stbuf.st_nlink < 2 && (errno == EXDEV || errno == ENOTSUP)) + { + /* Hard link failed so just create a new file with O_EXCL instead. */ + fd = AtomicFile::ropen(newn, O_WRONLY|O_CREAT|O_EXCL, stbuf.st_mode); + if (fd >= 0) + ret = 0; + } } -} -AtomicFileRef::InitArg -AtomicFileReadRef::enterRead(AtomicFile &inAtomicFile) -{ - InitArg anInitArg; - anInitArg.versionId = inAtomicFile.enterRead(anInitArg.address, anInitArg.length); - return anInitArg; + /* We want the errno from the link or the ropen, not that of the unlink. */ + int serrno = errno; + + /* Unlink the temp file. */ + ::unlink(old); + if (fd > 0) + AtomicFile::rclose(fd); + + errno = serrno; + return ret; } -AtomicFileReadRef::AtomicFileReadRef(AtomicFile &inAtomicFile) : - AtomicFileRef(inAtomicFile, enterRead(inAtomicFile)) +int +AtomicLockedFile::xcreat(const char *const name, mode_t mode, time_t &tim) { + std::string uniqueName = unique(mode); + const char *uniquePath = uniqueName.c_str(); + struct stat stbuf; /* return the filesystem time to the caller */ + stat(uniquePath, &stbuf); + tim = stbuf.st_mtime; + return myrename(uniquePath, name); } -AtomicFileWriteRef::~AtomicFileWriteRef() +void +AtomicLockedFile::lock(mode_t mode) { - if (mOpen) { - try { - mAtomicFile.rollback(); + const char *path = mPath.c_str(); + bool triedforce = false; + struct stat stbuf; + time_t t, locktimeout = 1024; /* DEFlocktimeout, 17 minutes. */ + bool doSyslog = false; + bool failed = false; + int retries = 0; + + while (!failed) + { + /* Don't syslog first time through. */ + if (doSyslog) + ::syslog(LOG_NOTICE, "Locking %s", path); + else + doSyslog = true; + + secdebug("atomicfile", "Locking %s", path); /* in order to cater for clock skew: get */ + if (!xcreat(path, mode, t)) /* time t from the filesystem */ + { + /* lock acquired, hurray! */ + break; } - catch (...) + switch(errno) { + case EEXIST: /* check if it's time for a lock override */ + if (!lstat(path, &stbuf) && stbuf.st_size <= 16 /* MAX_locksize */ && locktimeout + && !lstat(path, &stbuf) && locktimeout < t - stbuf.st_mtime) + /* stat() till unlink() should be atomic, but can't guarantee that. */ + { + if (triedforce) + { + /* Already tried, force lock override, not trying again */ + failed = true; + break; + } + else if (S_ISDIR(stbuf.st_mode) || ::unlink(path)) + { + triedforce=true; + ::syslog(LOG_ERR, "Forced unlock denied on %s", path); + secdebug("atomicfile", "Forced unlock denied on %s", path); + } + else + { + ::syslog(LOG_ERR, "Forcing lock on %s", path); + secdebug("atomicfile", "Forcing lock on %s", path); + sleep(16 /* DEFsuspend */); + break; + } + } + else + triedforce = false; /* legitimate iteration, clear flag */ + + /* Reset retry counter. */ + retries = 0; + sleep(8 /* DEFlocksleep */); + break; + + case ENOSPC: /* no space left, treat it as a transient */ +#ifdef EDQUOT /* NFS failure */ + case EDQUOT: /* maybe it was a short term shortage? */ +#endif + case ENOENT: + case ENOTDIR: + case EIO: + /*case EACCES:*/ + if(++retries < (7 + 1)) /* nfsTRY number of times+1 to ignore spurious NFS errors */ + sleep(8 /* DEFlocksleep */); + else + failed = true; + break; + +#ifdef ENAMETOOLONG + case ENAMETOOLONG: /* Filename is too long, shorten and retry */ + if (mPath.size() > mDir.size() + 8) + { + secdebug("atomicfile", "Truncating %s and retrying lock", path); + mPath.erase(mPath.end() - 1); + path = mPath.c_str(); + /* Reset retry counter. */ + retries = 0; + break; + } + /* DROPTHROUGH */ +#endif + default: + failed = true; + break; } } -} -AtomicFileRef::InitArg -AtomicFileWriteRef::enterWrite(AtomicFile &inAtomicFile, AtomicFile::FileRef &outWriteFileRef) -{ - InitArg anInitArg; - anInitArg.versionId = inAtomicFile.enterWrite(anInitArg.address, anInitArg.length, outWriteFileRef); - return anInitArg; + if (failed) + { + int error = errno; + ::syslog(LOG_ERR, "Lock failure on %s: %s", path, strerror(error)); + secdebug("atomicfile", "Lock failure on %s: %s", path, strerror(error)); + UnixError::throwMe(error); + } } -AtomicFileWriteRef::AtomicFileWriteRef(AtomicFile &inAtomicFile) : - AtomicFileRef(inAtomicFile, enterWrite(inAtomicFile, mFileRef)) +void +AtomicLockedFile::unlock() throw() { + const char *path = mPath.c_str(); + if (::unlink(path) == -1) + { + secdebug("atomicfile", "unlink %s: %s", path, strerror(errno)); + // unlock can't throw + } } + + +#undef kAtomicFileMaxBlockSize diff --git a/cdsa/cdsa_utilities/AtomicFile.h b/cdsa/cdsa_utilities/AtomicFile.h index 80ad70ae..6fc66e0c 100644 --- a/cdsa/cdsa_utilities/AtomicFile.h +++ b/cdsa/cdsa_utilities/AtomicFile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2000-2001, 2003 Apple Computer, Inc. All Rights Reserved. * * The contents of this file constitute Original Code as defined in and are * subject to the Apple Public Source License Version 1.2 (the 'License'). @@ -19,209 +19,185 @@ // // AtomicFile.h - Description t.b.d. // -#ifndef _H_ATOMICFILE -#define _H_ATOMICFILE +#ifndef _SECURITY_ATOMICFILE_H_ +#define _SECURITY_ATOMICFILE_H_ 1 -#include - -#include +#include #include - -#if _USE_IO == _USE_IO_POSIX -#include -#include -#elif _USE_IO == _USE_IO_MACOS -#define htonl(X) (X) -#define ntohl(X) (X) -#endif - -#ifdef _CPP_ATOMICFILE -#pragma export on -#endif +#include namespace Security { -class DbName; +class AtomicBufferedFile; +class AtomicLockedFile; +class AtomicTempFile; class AtomicFile { public: - typedef int FileRef; - typedef int VersionId; - - AtomicFile(const DbName &inDbName); + AtomicFile(const std::string &inPath); ~AtomicFile(); - // Close the currently open AtomicFile. (If there are transactions outstanding this call - // has no effect until after they have completed. - void close(); - - // Start a read operation. Returns a mmaped region with the file in it. Return the size of the - // file in length. Each call to enterRead() *must* be paired with a call to exitRead. - VersionId enterRead(const uint8 *&outFileAddress, size_t &outLength); - - // End a read operation. - void exitRead(VersionId inVersionId); - - // Return true if inVersionId is not the most recent version of this file. - bool isDirty(VersionId inVersionId); - // Aquire the write lock and remove the file. void performDelete(); - // Create and lock the database file for writing, and set outWriteRef to a newly created - // file open for writing. - // Return the new VersionId this file will have after a succesful commit. - VersionId enterCreate(FileRef &outWriteRef); + // Aquire the write lock and rename the file. + void rename(const std::string &inNewPath); + + // Lock the file for writing and return a newly created AtomicTempFile. + RefPointer create(mode_t mode); + + // Lock the file for writing and return a newly created AtomicTempFile. + RefPointer write(); - // Lock the database file for writing, map the database file for reading and - // set outWriteRef to a newly created file open for writing. - // Return the VersionId or the file being modified. - VersionId enterWrite(const uint8 *&outFileAddress, size_t &outLength, FileRef &outWriteRef); + // Return a bufferedFile containing current version of the file for reading. + RefPointer read(); - // Commit the current create or write and close the write file. Return the VersionId of the new file. - VersionId commit(); + string path() const { return mPath; } + string dir() const { return mDir; } + string file() const { return mFile; } - // Rollback the current create or write. - void rollback(); + mode_t mode() const; - enum OffsetType { - None, + enum OffsetType + { FromStart, - FromCurrent + FromEnd // only works with offset of 0 }; - void write(OffsetType inOffsetType, uint32 inOffset, const uint32 *inData, uint32 inCount); - void write(OffsetType inOffsetType, uint32 inOffset, const uint8 *inData, uint32 inLength); - void write(OffsetType inOffsetType, uint32 inOffset, const uint32 inData); - const string filename() const { return mReadFilename; } + static void pathSplit(const std::string &inFull, std::string &outDir, std::string &outFile); + static void mkpath(const std::string &inDir, mode_t mode = 0777); + static int ropen(const char *const name, int flags, mode_t mode); + static int rclose(int fd); + private: - void endWrite(); - void rename(const string &inSrcFilename, const string &inDestFilename); - void unlink(const string &inFilename); - - class OpenFile - { - public: - OpenFile(const std::string &inFilename, bool write, bool lock, VersionId inVersionId, mode_t mode); - ~OpenFile(); - - void close(); - VersionId versionId() const { return mVersionId; } - FileRef fileRef() const { return mFileRef; } - const uint8 *address() const { return mAddress; } - size_t length() const { return mLength; } - - // Check if the file has its dirty bit set. - bool isDirty(); - // Set the files dirty bit (requires the file to be writeable and locked). - void setDirty(); - - void lock(); - void unlock(); - - // Return the mode bits of the file - mode_t mode(); - - int mUseCount; - FileRef mFileRef; - private: - VersionId readVersionId(); - void writeVersionId(VersionId inVersionId); - static void mkpath(const std::string &inFilename); - - VersionId mVersionId; - const uint8 *mAddress; - size_t mLength; - bool mFcntlLock; - enum - { - Closed, - Read, - Write, - ReadWrite, - Create - } mState; - }; + string mPath; + string mDir; + string mFile; +}; - Mutex mReadLock; - OpenFile *mReadFile; - string mReadFilename; - Mutex mWriteLock; - OpenFile *mWriteFile; - string mWriteFilename; +// +// AtomicBufferedFile - This represents an instance of a file opened for reading. +// The file is read into memory and closed after this is done. +// The memory is released when this object is destroyed. +// +class AtomicBufferedFile : public RefCount +{ +public: + AtomicBufferedFile(const std::string &inPath); + ~AtomicBufferedFile(); - typedef std::map OpenFileMap; - OpenFileMap mOpenFileMap; + // Open the file and return it's size. + off_t open(); - bool mCreating; -}; + // Read inLength bytes starting at inOffset. + const uint8 *read(off_t inOffset, off_t inLength, off_t &outLength); + // Return the current mode bits of the file + mode_t mode(); -class AtomicFileRef -{ -public: - virtual ~AtomicFileRef(); - - uint32 at(uint32 inOffset) - { - return ntohl(*reinterpret_cast(mAddress + inOffset)); - } - - uint32 operator[](uint32 inOffset) - { - if (inOffset + sizeof(uint32) > mLength) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - return at(inOffset); - } - - const uint8 *range(uint32 inOffset, uint32 inLength) - { - if (inOffset + inLength > mLength) - CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - return mAddress + inOffset; - } - - const AtomicFile::VersionId mVersionId; -protected: - struct InitArg; - AtomicFileRef(AtomicFile &inAtomicFile, const InitArg &inInitArg); - - AtomicFile &mAtomicFile; - const uint8 *mAddress; - const size_t mLength; + // Close the file (this doesn't release the buffer). + void close(); + + // Return the length of the file. + off_t length() const { return mLength; } + +private: + // Complete path to the file + string mPath; + + // File descriptor to the file or -1 if it's not currently open. + int mFileRef; + + // This is where the data from the file is read in to. + uint8 *mBuffer; + + // Length of file in bytes. + off_t mLength; }; -// Use this class to open an AtomicFile for reading. -class AtomicFileReadRef : public AtomicFileRef + +// +// AtomicTempFile - A temporary file to write changes to. +// +class AtomicTempFile : public RefCount { public: - AtomicFileReadRef(AtomicFile &inAtomicFile); - virtual ~AtomicFileReadRef(); + // Start a write for a new file. + AtomicTempFile(AtomicFile &inFile, const RefPointer &inLockedFile, mode_t mode); + + // Start a write of an existing file. + AtomicTempFile(AtomicFile &inFile, const RefPointer &inLockedFile); + + ~AtomicTempFile(); + + // Commit the current create or write and close the write file. + void commit(); + + void write(AtomicFile::OffsetType inOffsetType, off_t inOffset, const uint32 *inData, uint32 inCount); + void write(AtomicFile::OffsetType inOffsetType, off_t inOffset, const uint8 *inData, uint32 inLength); + void write(AtomicFile::OffsetType inOffsetType, off_t inOffset, const uint32 inData); + private: - static InitArg enterRead(AtomicFile &inAtomicFile); + // Called by both constructors. + void create(mode_t mode); + + // Fsync the file + void fsync(); + + // Close the file + void close(); + + // Rollback the current create or write (happens automatically if commit() isn't called before the destructor is). + void rollback() throw(); + +private: + // Our AtomicFile object. + AtomicFile &mFile; + + RefPointer mLockedFile; + + // Complete path to the file + string mPath; + + // File descriptor to the file or -1 if it's not currently open. + int mFileRef; + + // If this is true we unlink both mPath and mFile.path() when we rollback. + bool mCreating; }; -// Use this class to open an AtomicFile for writing. -class AtomicFileWriteRef : public AtomicFileRef + +// The current lock being held. +class AtomicLockedFile : public RefCount { public: - AtomicFileWriteRef(AtomicFile &inAtomicFile); - virtual ~AtomicFileWriteRef(); - AtomicFile::VersionId commit() { mOpen = false; return mAtomicFile.commit(); } + // Create a write lock for inFile. + AtomicLockedFile(AtomicFile &inFile); + + ~AtomicLockedFile(); + +private: + void lock(mode_t mode = (S_IRUSR|S_IRGRP|S_IROTH) /* === 0444 */); + void unlock() throw(); private: - static InitArg enterWrite(AtomicFile &inAtomicFile, AtomicFile::FileRef &outWriteFileRef); - AtomicFile::FileRef mFileRef; - bool mOpen; + std::string unique(mode_t mode); + int rlink(const char *const old, const char *const newn, struct stat &sto); + int myrename(const char *const old, const char *const newn); + int xcreat(const char *const name, mode_t mode, time_t &tim); + + // The directory in which we create the lock + string mDir; + + // Complete path to the file + string mPath; }; + } // end namespace Security -#ifdef _CPP_ATOMICFILE -#pragma export off -#endif -#endif //_H_ATOMICFILE +#endif // _SECURITY_ATOMICFILE_H_ diff --git a/cdsa/cdsa_utilities/DatabaseSession.cpp b/cdsa/cdsa_utilities/DatabaseSession.cpp index 02d90d78..b5da6cc6 100644 --- a/cdsa/cdsa_utilities/DatabaseSession.cpp +++ b/cdsa/cdsa_utilities/DatabaseSession.cpp @@ -30,7 +30,7 @@ #include /* log open/close events */ -#define DOCDebug(args...) debug("DBOpen", ## args) +#define DOCDebug(args...) secdebug("DBOpen", ## args) using namespace std; @@ -263,7 +263,7 @@ DatabaseSession::DataInsert(CSSM_DB_HANDLE inDbHandle, const CssmData *inData, CSSM_DB_UNIQUE_RECORD_PTR &outUniqueId) { - debug("dbsession", "%p DataInsert(%lx,%lx)", this, inDbHandle, inRecordType); + secdebug("dbsession", "%p DataInsert(%lx,%lx)", this, inDbHandle, inRecordType); DbContext &aDbContext = findDbContext(inDbHandle); outUniqueId = aDbContext.mDatabase.dataInsert(aDbContext, inRecordType, inAttributes, inData); } @@ -273,7 +273,7 @@ void DatabaseSession::DataDelete(CSSM_DB_HANDLE inDbHandle, const CSSM_DB_UNIQUE_RECORD &inUniqueRecordIdentifier) { - debug("dbsession", "%p DataDelete(%lx)", this, inDbHandle); + secdebug("dbsession", "%p DataDelete(%lx)", this, inDbHandle); DbContext &aDbContext = findDbContext(inDbHandle); aDbContext.mDatabase.dataDelete(aDbContext, inUniqueRecordIdentifier); } @@ -287,7 +287,7 @@ DatabaseSession::DataModify(CSSM_DB_HANDLE inDbHandle, const CssmData *inDataToBeModified, CSSM_DB_MODIFY_MODE inModifyMode) { - debug("dbsession", "%p DataModify(%lx,%lx)", this, inDbHandle, inRecordType); + secdebug("dbsession", "%p DataModify(%lx,%lx)", this, inDbHandle, inRecordType); DbContext &aDbContext = findDbContext(inDbHandle); aDbContext.mDatabase.dataModify(aDbContext, inRecordType, inoutUniqueRecordIdentifier, inAttributesToBeModified, inDataToBeModified, inModifyMode); @@ -300,7 +300,7 @@ DatabaseSession::DataGetFirst(CSSM_DB_HANDLE inDbHandle, CssmData *inoutData, CSSM_DB_UNIQUE_RECORD_PTR &outUniqueId) { - debug("dbsession", "%p DataGetFirst(%lx)", this, inDbHandle); + secdebug("dbsession", "%p DataGetFirst(%lx)", this, inDbHandle); DbContext &aDbContext = findDbContext(inDbHandle); return aDbContext.mDatabase.dataGetFirst(aDbContext, inQuery, @@ -314,7 +314,7 @@ DatabaseSession::DataGetNext(CSSM_DB_HANDLE inDbHandle, CssmData *inoutData, CSSM_DB_UNIQUE_RECORD_PTR &outUniqueRecord) { - debug("dbsession", "%p DataGetNext(%lx)", this, inDbHandle); + secdebug("dbsession", "%p DataGetNext(%lx)", this, inDbHandle); DbContext &aDbContext = findDbContext(inDbHandle); return aDbContext.mDatabase.dataGetNext(aDbContext, inResultsHandle, inoutAttributes, @@ -325,7 +325,7 @@ void DatabaseSession::DataAbortQuery(CSSM_DB_HANDLE inDbHandle, CSSM_HANDLE inResultsHandle) { - debug("dbsession", "%p DataAbortQuery(%lx)", this, inDbHandle); + secdebug("dbsession", "%p DataAbortQuery(%lx)", this, inDbHandle); DbContext &aDbContext = findDbContext(inDbHandle); aDbContext.mDatabase.dataAbortQuery(aDbContext, inResultsHandle); } @@ -336,7 +336,7 @@ DatabaseSession::DataGetFromUniqueRecordId(CSSM_DB_HANDLE inDbHandle, CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR inoutAttributes, CssmData *inoutData) { - debug("dbsession", "%p DataGetFromUniqueId(%lx)", this, inDbHandle); + secdebug("dbsession", "%p DataGetFromUniqueId(%lx)", this, inDbHandle); DbContext &aDbContext = findDbContext(inDbHandle); aDbContext.mDatabase.dataGetFromUniqueRecordId(aDbContext, inUniqueRecord, inoutAttributes, inoutData); diff --git a/cdsa/cdsa_utilities/DbContext.cpp b/cdsa/cdsa_utilities/DbContext.cpp index ebe270bc..5633728a 100644 --- a/cdsa/cdsa_utilities/DbContext.cpp +++ b/cdsa/cdsa_utilities/DbContext.cpp @@ -43,86 +43,3 @@ DbContext::~DbContext () //delete mAccessCred; // XXX How do we delete these? } - -#if 0 -CSSM_HANDLE -DbContext::dataGetFirst(const DLQuery *inQuery, - CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR inoutAttributes, - CssmData *inoutData, - CSSM_DB_UNIQUE_RECORD_PTR &outUniqueRecord) -{ - auto_ptr aQuery(mDatabase.makeQuery(const DLQuery *inQuery)); - try - { - mDatabase.dataGetNext(*aQuery, inoutAttributes, inoutData, outUniqueRecord); - - StLock _(mDbQuerySet); - mDbQuerySet.insert(aQuery.get()); - } - catch(...) - { - mDatabase.dataAbortQuery(*aQuery); - throw; - } - - return reinterpret_cast(aQuery.release()); -} - -void -DbContext::dataGetNext(CSSM_HANDLE inResultsHandle, - CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR inoutAttributes, - CssmData *inoutData, - CSSM_DB_UNIQUE_RECORD_PTR &outUniqueRecord) -{ - DbQuery *aQuery = reinterpret_cast(inResultsHandle); - { - StLock _(mDbQuerySet); - DbQuerySet::iterator it = mDbQuerySet.find(aQuery); - if (it == mDbContextMap.end()) - CssmError::throwMe(CSSMERR_DL_INVALID_RESULTS_HANDLE); - } - - try - { - mDatabase.dataGetNext(*aQuery, inoutAttributes, inoutData, outUniqueRecord); - } - catch(...) - { - { - StLock _(mDbQuerySet); - mDbQuerySet.erase(aQuery); - } - try - { - mDatabase.dataAbortQuery(*aQuery); - } - catch(...) {} - delete aQuery; - throw; - } -} - -void -DbContext::dataAbortQuery(CSSM_HANDLE inResultsHandle) -{ - DbQuery *aQuery = reinterpret_cast(inResultsHandle); - { - StLock _(mDbQuerySet); - DbQuerySet::iterator it = mDbQuerySet.find(aQuery); - if (it == mDbContextMap.end()) - CssmError::throwMe(CSSMERR_DL_INVALID_RESULTS_HANDLE); - mDbContextMap.erase(it); - } - - try - { - mDatabase.dataAbortQuery(*aQuery); - } - catch(...) - { - delete aQuery; - throw; - } - delete aQuery; -} -#endif diff --git a/cdsa/cdsa_utilities/DbIndex.cpp b/cdsa/cdsa_utilities/DbIndex.cpp index 0b2a5edc..03359f62 100644 --- a/cdsa/cdsa_utilities/DbIndex.cpp +++ b/cdsa/cdsa_utilities/DbIndex.cpp @@ -149,11 +149,11 @@ DbConstIndex::DbConstIndex(const Table &table, const ReadSection &indexSection) uint32 numRecords = indexSection.at(offset); offset += AtomSize; mKeyOffsetVector.overlay(numRecords, - reinterpret_cast(indexSection.range(Range(offset, numRecords * AtomSize)))); + reinterpret_cast(indexSection.range(Range(offset, numRecords * AtomSize)))); offset += numRecords * AtomSize; mRecordNumberVector.overlay(numRecords, - reinterpret_cast(indexSection.range(Range(offset, numRecords * AtomSize)))); + reinterpret_cast(indexSection.range(Range(offset, numRecords * AtomSize)))); } // Check to see if this index can be used to perform a given query, based on @@ -413,7 +413,7 @@ DbMutableIndex::insertRecordMulti(uint32 recordNumber, const ReadSection &packed uint32 newKeySize = keySize; metaAttribute.copyValueBytes(i, packedRecord, keyData, newKeySize); - if (attributeIndex == mAttributes.size()) { + if (attributeIndex + 1 == mAttributes.size()) { uint32 offset = mIndexDataSize; mIndexDataSize = mIndexData.put(mIndexDataSize, newKeySize, keyData.address()); mIndexData.size(mIndexDataSize); diff --git a/cdsa/cdsa_utilities/DbIndex.h b/cdsa/cdsa_utilities/DbIndex.h index 0b02f408..bfeaadd1 100644 --- a/cdsa/cdsa_utilities/DbIndex.h +++ b/cdsa/cdsa_utilities/DbIndex.h @@ -32,7 +32,7 @@ class Table; class DbConstIndex; class DbIndex; -typedef constVector DbOffsetVector; +typedef constVector DbOffsetVector; typedef DbOffsetVector::const_iterator DbIndexIterator; diff --git a/cdsa/cdsa_utilities/MetaAttribute.h b/cdsa/cdsa_utilities/MetaAttribute.h index cd2ad831..78a7f77c 100644 --- a/cdsa/cdsa_utilities/MetaAttribute.h +++ b/cdsa/cdsa_utilities/MetaAttribute.h @@ -135,11 +135,15 @@ public: bool evaluate(const DbValue *value, const ReadSection &rs, CSSM_DB_OPERATOR op) const { uint32 offset, numValues; - unpackNumberOfValues(rs, numValues, offset); - if (numValues == 0) - return false; + unpackNumberOfValues(rs, numValues, offset); - return (dynamic_cast(value))->evaluate(T(rs, offset), op); + /* If any of the values for this attribute match we have a + match. This is the same behaviour that indexes have. */ + for (uint32 ix = 0; ix < numValues; ++ix) + if (dynamic_cast(value)->evaluate(T(rs, offset), op)) + return true; + + return false; } bool evaluate(const DbValue *value1, const DbValue *value2, CSSM_DB_OPERATOR op) const diff --git a/cdsa/cdsa_utilities/MetaRecord.cpp b/cdsa/cdsa_utilities/MetaRecord.cpp index 044c56e5..8a67d4d6 100644 --- a/cdsa/cdsa_utilities/MetaRecord.cpp +++ b/cdsa/cdsa_utilities/MetaRecord.cpp @@ -46,12 +46,6 @@ MetaRecord::MetaRecord(CSSM_DB_RECORDTYPE inRelationID, const CSSM_DB_SCHEMA_ATTRIBUTE_INFO *inAttributeInfo) : mRecordType(inRelationID) { - // XXX Is there any particular reason not to allow this? -#if 0 - if (inNumberOfAttributes == 0 || inAttributeInfo == NULL) - CssmError::throwMe(CSSMERR_DL_UNSUPPORTED_NUM_ATTRIBUTES); -#endif - try { for (uint32 anIndex = 0; anIndex < inNumberOfAttributes; anIndex++) { @@ -84,12 +78,6 @@ MetaRecord::~MetaRecord() void MetaRecord::setRecordAttributeInfo(const CSSM_DB_RECORD_ATTRIBUTE_INFO &inInfo) { - // XXX Is there any particular reason not to allow this? -#if 0 - if (inInfo.NumberOfAttributes == 0 || inInfo.AttributeInfo == NULL) - CssmError::throwMe(CSSMERR_DL_UNSUPPORTED_NUM_ATTRIBUTES); -#endif - for (uint32 anIndex = 0; anIndex < inInfo.NumberOfAttributes; anIndex++) { switch (inInfo.AttributeInfo[anIndex].AttributeNameFormat) @@ -322,7 +310,7 @@ MetaRecord::attributeIndex(const CSSM_DB_ATTRIBUTE_INFO &inAttributeInfo) const for(it = mNameStringMap.begin(); it != mNameStringMap.end(); it++) { - printf("name %s val %ul\n", it->first.c_str(), it->second); + printf("name %s val %lu\n", it->first.c_str(), it->second); } #endif CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME); diff --git a/cdsa/cdsa_utilities/ReadWriteSection.h b/cdsa/cdsa_utilities/ReadWriteSection.h index 01d36f83..5d4b789a 100644 --- a/cdsa/cdsa_utilities/ReadWriteSection.h +++ b/cdsa/cdsa_utilities/ReadWriteSection.h @@ -25,6 +25,7 @@ #include #include +#include namespace Security { @@ -33,20 +34,7 @@ namespace Security // Atom -- An Atom is a 32-bit unsigned integer value that is always internally // represented using network byte order. // -class Atom -{ -public: - typedef constVector Vector; - - Atom() : mValue(0) {} - Atom(uint32 value) : mValue(htonl(value)) {} - - operator uint32 () const { return ntohl(mValue); } - Atom &operator = (uint32 value) { mValue = htonl(value); return *this; } - -private: - uint32 mValue; -}; +typedef Endian Atom; enum { AtomSize = sizeof(uint32) // XXX Why not just use sizeof(Atom)? diff --git a/cdsa/cdsa_utilities/acl_codesigning.cpp b/cdsa/cdsa_utilities/acl_codesigning.cpp index 76f50038..44487772 100644 --- a/cdsa/cdsa_utilities/acl_codesigning.cpp +++ b/cdsa/cdsa_utilities/acl_codesigning.cpp @@ -25,6 +25,7 @@ #include #include +#include #include @@ -59,7 +60,8 @@ bool CodeSignatureAclSubject::validate(const AclValidationContext &context) cons { // a suitable environment is required for a match if (Environment *env = context.environment()) - return env->verifyCodeSignature(mSignature); + return env->verifyCodeSignature(mSignature, + mHaveComment ? &mComment.get() : NULL); else return false; } @@ -109,7 +111,7 @@ CodeSignatureAclSubject *CodeSignatureAclSubject::Maker::make(Version version, { assert(version == 0); CssmAllocator &alloc = CssmAllocator::standard(); - uint32 sigType; pub(sigType); + Endian sigType; pub(sigType); const void *data; uint32 length; pub.countedData(data, length); const void *commentData; uint32 commentLength; pub.countedData(commentData, commentLength); return new CodeSignatureAclSubject(alloc, @@ -123,14 +125,14 @@ CodeSignatureAclSubject *CodeSignatureAclSubject::Maker::make(Version version, // void CodeSignatureAclSubject::exportBlob(Writer::Counter &pub, Writer::Counter &priv) { - uint32 sigType = mSignature->type(); pub(sigType); + Endian sigType = mSignature->type(); pub(sigType); pub.countedData(*mSignature); pub.countedData(mComment); } void CodeSignatureAclSubject::exportBlob(Writer &pub, Writer &priv) { - uint32 sigType = mSignature->type(); pub(sigType); + Endian sigType = mSignature->type(); pub(sigType); pub.countedData(*mSignature); pub.countedData(mComment); } diff --git a/cdsa/cdsa_utilities/acl_codesigning.h b/cdsa/cdsa_utilities/acl_codesigning.h index 30778d0f..cc302574 100644 --- a/cdsa/cdsa_utilities/acl_codesigning.h +++ b/cdsa/cdsa_utilities/acl_codesigning.h @@ -60,7 +60,7 @@ public: public: class Environment : public virtual AclValidationEnvironment { public: - virtual bool verifyCodeSignature(const Signature *signature) = 0; + virtual bool verifyCodeSignature(const Signature *signature, const CssmData *comment) = 0; }; public: diff --git a/cdsa/cdsa_utilities/acl_password.cpp b/cdsa/cdsa_utilities/acl_password.cpp index ad61d9f2..276cdd78 100644 --- a/cdsa/cdsa_utilities/acl_password.cpp +++ b/cdsa/cdsa_utilities/acl_password.cpp @@ -25,6 +25,7 @@ #include #include +#include #include diff --git a/cdsa/cdsa_utilities/acl_process.cpp b/cdsa/cdsa_utilities/acl_process.cpp index 82b3199a..3dac7618 100644 --- a/cdsa/cdsa_utilities/acl_process.cpp +++ b/cdsa/cdsa_utilities/acl_process.cpp @@ -19,25 +19,17 @@ // // acl_process - Process-attribute ACL subject type. // -#ifdef __MWERKS__ -#define _CPP_ACL_PROCESS -#endif - #include +#include #include -#include // testing - // -// Validate a credential set against this subject +// Validate a credential set against this subject. +// No credential is required for this match. // -bool ProcessAclSubject::validate(const AclValidationContext &context, - const TypedList &sample) const +bool ProcessAclSubject::validate(const AclValidationContext &context) const { - if (sample.length() != 1) // no-argument sample - CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); - // reality check (internal structure was validated when created) assert(select.uses(CSSM_ACL_MATCH_BITS)); @@ -101,6 +93,10 @@ ProcessAclSubject *ProcessAclSubject::Maker::make(const TypedList &list) const ProcessAclSubject *ProcessAclSubject::Maker::make(Version, Reader &pub, Reader &priv) const { AclProcessSubjectSelector selector; pub(selector); + n2hi(selector.version); + n2hi(selector.mask); + n2hi(selector.uid); + n2hi(selector.gid); return new ProcessAclSubject(selector); } @@ -115,7 +111,12 @@ void ProcessAclSubject::exportBlob(Writer::Counter &pub, Writer::Counter &priv) void ProcessAclSubject::exportBlob(Writer &pub, Writer &priv) { - pub(select); + AclProcessSubjectSelector temp; + temp.version = h2n (select.version); + temp.mask = h2n (select.mask); + temp.uid = h2n (select.uid); + temp.gid = h2n (select.gid); + pub(temp); } diff --git a/cdsa/cdsa_utilities/acl_process.h b/cdsa/cdsa_utilities/acl_process.h index 91ae8378..64b5c6df 100644 --- a/cdsa/cdsa_utilities/acl_process.h +++ b/cdsa/cdsa_utilities/acl_process.h @@ -31,10 +31,6 @@ #include #include -#ifdef _CPP_ACL_PROCESS -#pragma export on -#endif - namespace Security { @@ -52,13 +48,13 @@ public: // The ProcessAclSubject matches process attributes securely identified // by the system across IPC channels. // -class ProcessAclSubject : public SimpleAclSubject { +class ProcessAclSubject : public AclSubject { public: - bool validate(const AclValidationContext &baseCtx, const TypedList &sample) const; + bool validate(const AclValidationContext &baseCtx) const; CssmList toList(CssmAllocator &alloc) const; ProcessAclSubject(const AclProcessSubjectSelector &selector) - : SimpleAclSubject(CSSM_ACL_SUBJECT_TYPE_PROCESS, CSSM_SAMPLE_TYPE_PROCESS), + : AclSubject(CSSM_ACL_SUBJECT_TYPE_PROCESS), select(selector) { } void exportBlob(Writer::Counter &pub, Writer::Counter &priv); @@ -87,9 +83,5 @@ private: } // end namespace Security -#ifdef _CPP_ACL_PROCESS -#pragma export off -#endif - #endif //_ACL_PROCESS diff --git a/cdsa/cdsa_utilities/acl_threshold.cpp b/cdsa/cdsa_utilities/acl_threshold.cpp index da968743..6a44701c 100644 --- a/cdsa/cdsa_utilities/acl_threshold.cpp +++ b/cdsa/cdsa_utilities/acl_threshold.cpp @@ -25,6 +25,7 @@ #include #include +#include // @@ -108,14 +109,14 @@ ThresholdAclSubject *ThresholdAclSubject::Maker::make(const TypedList &list) con AclSubjectVector elements(totalSubjects); const ListElement *subSubject = &list[3]; for (uint32 n = 0; n < totalSubjects; n++, subSubject = subSubject->next()) - elements[n] = ObjectAcl::make(*subSubject); + elements[n] = ObjectAcl::make(subSubject->typedList()); return new ThresholdAclSubject(totalSubjects, minimumNeeded, elements); } ThresholdAclSubject *ThresholdAclSubject::Maker::make(Version, Reader &pub, Reader &priv) const { - uint32 totalSubjects; pub(totalSubjects); - uint32 minimumNeeded; pub(minimumNeeded); + Endian totalSubjects; pub(totalSubjects); + Endian minimumNeeded; pub(minimumNeeded); AclSubjectVector subSubjects(totalSubjects); for (uint32 n = 0; n < totalSubjects; n++) subSubjects[n] = ObjectAcl::importSubject(pub, priv); @@ -136,8 +137,8 @@ ThresholdAclSubject::ThresholdAclSubject(uint32 n, uint32 k, template void ThresholdAclSubject::exportBlobForm(Action &pub, Action &priv) { - pub(totalSubjects); - pub(minimumNeeded); + pub(h2n(totalSubjects)); + pub(h2n(minimumNeeded)); for (uint32 n = 0; n < totalSubjects; n++) ObjectAcl::exportSubject(elements[n], pub, priv); } diff --git a/cdsa/cdsa_utilities/bufferfifo.h b/cdsa/cdsa_utilities/bufferfifo.h index 61764e5c..571f2336 100644 --- a/cdsa/cdsa_utilities/bufferfifo.h +++ b/cdsa/cdsa_utilities/bufferfifo.h @@ -67,4 +67,4 @@ private: } // end namespace Security -#endif _H_BUFFERFIFO +#endif /* _H_BUFFERFIFO */ diff --git a/cdsa/cdsa_utilities/cfutilities.h b/cdsa/cdsa_utilities/cfutilities.h index 5a3f6309..c55a661d 100644 --- a/cdsa/cdsa_utilities/cfutilities.h +++ b/cdsa/cdsa_utilities/cfutilities.h @@ -40,9 +40,12 @@ public: CFRef(CFType ref) : mRef(ref) { } CFRef(const CFRef &ref) : mRef(ref) { if (ref) CFRetain(ref); } ~CFRef() { if (mRef) CFRelease(mRef); } + + CFRef &take(CFType ref) + { if (mRef) CFRelease(mRef); mRef = ref; return *this; } CFRef &operator = (CFType ref) - { if (ref) CFRetain(ref); if (mRef) CFRelease(mRef); mRef = ref; return *this; } + { if (ref) CFRetain(ref); return take(ref); } operator CFType () const { return mRef; } operator bool () const { return mRef != NULL; } @@ -60,8 +63,11 @@ public: CFCopyRef(const CFCopyRef &ref) : mRef(ref) { if (ref) CFRetain(ref); } ~CFCopyRef() { if (mRef) CFRelease(mRef); } + CFCopyRef &take(CFType ref) + { if (mRef) CFRelease(mRef); mRef = ref; return *this; } + CFCopyRef &operator = (CFType ref) - { if (ref) CFRetain(ref); if (mRef) CFRelease(mRef); mRef = ref; return *this; } + { if (ref) CFRetain(ref); return take(ref); } operator CFType () const { return mRef; } operator bool () const { return mRef != NULL; } @@ -74,18 +80,19 @@ private: // // A simple function that turns a non-array CFTypeRef into -// an array of one with that element. +// an array of one with that element. This will retain its argument +// (directly or indirectly). // inline CFArrayRef cfArrayize(CFTypeRef arrayOrItem) { if (arrayOrItem == NULL) return NULL; // NULL is NULL - else if (CFGetTypeID(arrayOrItem) == CFArrayGetTypeID()) + else if (CFGetTypeID(arrayOrItem) == CFArrayGetTypeID()) { + CFRetain(arrayOrItem); return CFArrayRef(arrayOrItem); // already an array - else { + } else { CFArrayRef array = CFArrayCreate(NULL, (const void **)&arrayOrItem, 1, &kCFTypeArrayCallBacks); - CFRelease(arrayOrItem); // was retained by ArrayCreate return array; } } @@ -172,7 +179,7 @@ private: uint32 mCount; }; -template +template CFToVector::CFToVector(CFArrayRef arrayRef) { if (arrayRef == NULL) { diff --git a/cdsa/cdsa_utilities/codesigning.h b/cdsa/cdsa_utilities/codesigning.h index 782a7c34..c1f13173 100644 --- a/cdsa/cdsa_utilities/codesigning.h +++ b/cdsa/cdsa_utilities/codesigning.h @@ -35,6 +35,8 @@ #pragma export on #endif +#undef verify + namespace Security { diff --git a/cdsa/cdsa_utilities/context.cpp b/cdsa/cdsa_utilities/context.cpp index ca2e2e5e..3f25f1a2 100644 --- a/cdsa/cdsa_utilities/context.cpp +++ b/cdsa/cdsa_utilities/context.cpp @@ -32,6 +32,17 @@ #include +// +// Construct Context objects +// +Context::Context(CSSM_CONTEXT_TYPE type, CSSM_ALGORITHMS algorithmId) +{ + clearPod(); + ContextType = type; + AlgorithmType = algorithmId; +} + + // // Delete a single attribute from a Context by type. // We implement this by simply nulling out the slot - the memory is not released, diff --git a/cdsa/cdsa_utilities/context.h b/cdsa/cdsa_utilities/context.h index f99e392a..84cd5d33 100644 --- a/cdsa/cdsa_utilities/context.h +++ b/cdsa/cdsa_utilities/context.h @@ -27,6 +27,7 @@ #include #include #include // to serialize/copy access credentials +#include #ifdef _CPP_CONTEXT # pragma export on @@ -46,8 +47,7 @@ namespace Security // class Context : public PodWrapper { public: - Context(CSSM_CONTEXT_TYPE type, CSSM_ALGORITHMS algorithmId) - { ContextType = type; AlgorithmType = algorithmId; } + Context(CSSM_CONTEXT_TYPE type, CSSM_ALGORITHMS algorithmId); uint32 attributesInUse() const { return NumberOfAttributes; } CSSM_CONTEXT_TYPE type() const { return ContextType; } @@ -103,10 +103,13 @@ public: operator CSSM_DL_DB_HANDLE &() const { assert(baseType() == CSSM_ATTRIBUTE_DATA_DL_DB_HANDLE); - if (Attribute.DLDbHandle == NULL) + if (Attribute.DLDBHandle == NULL) CssmError::throwMe(CSSMERR_CSP_INVALID_ATTR_DL_DB_HANDLE); - return *Attribute.DLDbHandle; + return *Attribute.DLDBHandle; } + operator CssmDate & () const + { assert(baseType() == CSSM_ATTRIBUTE_DATA_DATE); + return CssmDate::overlay(*Attribute.Date); } // @@@ etc. etc. - add yours today! void operator = (uint32 value) { Attribute.Uint32 = value; } @@ -214,6 +217,7 @@ namespace DataWalkers template void walk(Action &operate, CSSM_CONTEXT_ATTRIBUTE &attr) { + operate(attr); switch (attr.AttributeType & CSSM_ATTRIBUTE_TYPE_MASK) { case CSSM_ATTRIBUTE_DATA_CSSM_DATA: walk(operate, attr.Attribute.Data); break; @@ -232,15 +236,22 @@ void walk(Action &operate, CSSM_CONTEXT_ATTRIBUTE &attr) case CSSM_ATTRIBUTE_DATA_VERSION: walk(operate, attr.Attribute.Version); break; case CSSM_ATTRIBUTE_DATA_DL_DB_HANDLE: - walk(operate, attr.Attribute.DLDbHandle); break; + walk(operate, attr.Attribute.DLDBHandle); break; case CSSM_ATTRIBUTE_NONE: case CSSM_ATTRIBUTE_DATA_UINT32: break; default: - assert(false); // unexpected type + secdebug("walkers", "invalid attribute (%lx) in context", attr.AttributeType); + break; } } +template +void walk(Action &operate, Context::Attr &attr) +{ + walk(operate, static_cast(attr)); +} + } // end namespace DataWalkers diff --git a/cdsa/cdsa_utilities/cssmacl.cpp b/cdsa/cdsa_utilities/cssmacl.cpp index 9d9f2070..5f5af270 100644 --- a/cdsa/cdsa_utilities/cssmacl.cpp +++ b/cdsa/cdsa_utilities/cssmacl.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace DataWalkers; @@ -135,8 +136,11 @@ public: }; void ObjectAcl::validate(AclAuthorization auth, const AccessCredentials *cred, - AclValidationEnvironment *env) const + AclValidationEnvironment *env) { + // make sure we are ready to go + instantiateAcl(); + //@@@ should pre-screen based on requested auth, maybe? BaseValidationContext ctx(cred, auth, env); @@ -144,7 +148,7 @@ void ObjectAcl::validate(AclAuthorization auth, const AccessCredentials *cred, // try owner (owner can do anything) if (owner.validate(ctx)) return; -#endif ACL_OMNIPOTENT_OWNER +#endif //ACL_OMNIPOTENT_OWNER // try applicable ACLs pair range; @@ -160,8 +164,9 @@ void ObjectAcl::validate(AclAuthorization auth, const AccessCredentials *cred, } void ObjectAcl::validateOwner(AclAuthorization authorizationHint, - const AccessCredentials *cred, AclValidationEnvironment *env) const + const AccessCredentials *cred, AclValidationEnvironment *env) { + instantiateAcl(); BaseValidationContext ctx(cred, authorizationHint, env); if (owner.validate(ctx)) return; @@ -176,7 +181,7 @@ void ObjectAcl::validateOwner(AclAuthorization authorizationHint, void ObjectAcl::exportBlob(CssmData &publicBlob, CssmData &privateBlob) { Writer::Counter pubSize, privSize; - uint32 entryCount = entries.size(); + Endian entryCount = entries.size(); owner.exportBlob(pubSize, privSize); pubSize(entryCount); for (Iterator it = begin(); it != end(); it++) @@ -202,7 +207,9 @@ void ObjectAcl::importBlob(const void *publicBlob, const void *privateBlob) { Reader pubReader(publicBlob), privReader(privateBlob); owner.importBlob(pubReader, privReader); - uint32 entryCount; pubReader(entryCount); + Endian entryCountIn; pubReader(entryCountIn); + uint32 entryCount = entryCountIn; + entries.erase(begin(), end()); for (uint32 n = 0; n < entryCount; n++) { AclEntry newEntry; @@ -220,11 +227,25 @@ void ObjectAcl::importBlob(const void *publicBlob, const void *privateBlob) // AclSubject *ObjectAcl::importSubject(Reader &pub, Reader &priv) { - uint32 typeAndVersion; pub(typeAndVersion); + Endian typeAndVersion; pub(typeAndVersion); return make(typeAndVersion, pub, priv); } +// +// Setup/update hooks +// +void ObjectAcl::instantiateAcl() +{ + // nothing by default +} + +void ObjectAcl::changedAcl() +{ + // nothing by default +} + + // // ACL utility methods // @@ -257,6 +278,7 @@ ObjectAcl::Iterator ObjectAcl::findEntryHandle(CSSM_ACL_HANDLE handle) // void ObjectAcl::cssmGetAcl(const char *tag, uint32 &count, AclEntryInfo * &acls) { + instantiateAcl(); pair range; count = getRange(tag, range); acls = allocator.alloc(count); @@ -273,6 +295,9 @@ void ObjectAcl::cssmChangeAcl(const AclEdit &edit, { IFDUMPING("acl", debugDump("acl-change-from")); + // make sure we're ready to go + instantiateAcl(); + // validate access credentials validateOwner(CSSM_ACL_AUTHORIZATION_CHANGE_ACL, cred, env); @@ -299,12 +324,16 @@ void ObjectAcl::cssmChangeAcl(const AclEdit &edit, default: CssmError::throwMe(CSSM_ERRCODE_INVALID_ACL_EDIT_MODE); } + + // notify change + changedAcl(); IFDUMPING("acl", debugDump("acl-change-to")); } void ObjectAcl::cssmGetOwner(AclOwnerPrototype &outOwner) { + instantiateAcl(); outOwner.TypedSubject = owner.subject->toList(allocator); outOwner.Delegate = owner.delegate; } @@ -314,11 +343,15 @@ void ObjectAcl::cssmChangeOwner(const AclOwnerPrototype &newOwner, { IFDUMPING("acl", debugDump("owner-change-from")); + instantiateAcl(); + // only the owner entry can match validateOwner(CSSM_ACL_AUTHORIZATION_CHANGE_OWNER, cred, env); // okay, replace it owner = newOwner; + + changedAcl(); IFDUMPING("acl", debugDump("owner-change-to")); } @@ -335,7 +368,10 @@ void ObjectAcl::Entry::init(const AclSubjectPointer &subject, bool delegate) void ObjectAcl::Entry::importBlob(Reader &pub, Reader &priv) { - uint32 del; pub(del); delegate = del; // 4 bytes delegate flag + Endian del; + pub(del); // read del from the public blob + + delegate = del; // 4 bytes delegate flag subject = importSubject(pub, priv); } @@ -405,15 +441,17 @@ void ObjectAcl::AclEntry::importBlob(Reader &pub, Reader &priv) const char *s; pub(s); tag = s; // authorizesAnything is on disk as a 4-byte flag - uint32 tmpAuthorizesAnything; + Endian tmpAuthorizesAnything; pub(tmpAuthorizesAnything); authorizesAnything = tmpAuthorizesAnything; authorizations.erase(authorizations.begin(), authorizations.end()); if (!authorizesAnything) { - uint32 count; pub(count); + Endian countIn; pub(countIn); + uint32 count = countIn; + for (uint32 n = 0; n < count; n++) { - AclAuthorization auth; pub(auth); + Endian auth; pub(auth); authorizations.insert(auth); } } @@ -438,7 +476,7 @@ AclSubject *ObjectAcl::make(const TypedList &list) AclSubject *ObjectAcl::make(uint32 typeAndVersion, Reader &pub, Reader &priv) { - // this type is encode as (version << 24) | type + // this type is encoded as (version << 24) | type return makerFor(typeAndVersion & ~AclSubject::versionMask).make(typeAndVersion >> AclSubject::versionShift, pub, priv); } @@ -474,7 +512,7 @@ void AclSubject::Maker::crack(const CssmList &list, uint32 count, ListElement ** } CSSM_WORDID_TYPE AclSubject::Maker::getWord(const ListElement &elem, - int min = 0, int max = INT_MAX) + int min /*= 0*/, int max /*= INT_MAX*/) { if (elem.type() != CSSM_LIST_ELEMENT_WORDID) CssmError::throwMe(CSSM_ERRCODE_INVALID_ACL_SUBJECT_VALUE); diff --git a/cdsa/cdsa_utilities/cssmacl.h b/cdsa/cdsa_utilities/cssmacl.h index 086f6aee..4e48475b 100644 --- a/cdsa/cdsa_utilities/cssmacl.h +++ b/cdsa/cdsa_utilities/cssmacl.h @@ -128,7 +128,7 @@ public: // // An AclValidationEnvironment can be subclassed to add context access to ACL subject // validation. If you use ACL subject classes that need context beyond the credential -// structure itself, add that context to (a subclass of) CredentialsContext, pass that +// structure itself, add that context to (a subclass of) AclValidationContext, pass that // to ObjectAcl::validate() along with the credentials, and have the Subject implementation // access validationContext.environment(). // @@ -200,9 +200,9 @@ public: // access control validation: succeed or throw exception void validate(AclAuthorization auth, const AccessCredentials *cred, - AclValidationEnvironment *env = NULL) const; + AclValidationEnvironment *env = NULL); void validateOwner(AclAuthorization authorizationHint, const AccessCredentials *cred, - AclValidationEnvironment *env = NULL) const; + AclValidationEnvironment *env = NULL); // CSSM-style ACL access operations // (Gets are not const because underlying implementations usually want them writable) @@ -220,7 +220,11 @@ public: void exportBlob(CssmData &publicBlob, CssmData &privateBlob); void importBlob(const void *publicBlob, const void *privateBlob); - // debugging support (always there but stubbed out unless DEBUGDUMP) + // setup hooks (called to delayed-construct the contents before use) - empty defaults + virtual void instantiateAcl(); // called before ACL contents are used by external calls + virtual void changedAcl(); // called after an ACL has been (possibly) changed + + // debug dump support (always there but stubbed out unless DEBUGDUMP) virtual void debugDump(const char *what = NULL) const; public: @@ -240,7 +244,7 @@ public: template void ObjectAcl::Entry::exportBlob(Action &pub, Action &priv) { - uint32 del = delegate; pub(del); // 4 bytes delegate flag + Endian del = delegate; pub(del); // 4 bytes delegate flag exportSubject(subject, pub, priv); // subject itself (polymorphic) } void importBlob(Reader &pub, Reader &priv); @@ -294,10 +298,10 @@ public: const char *s = tag.c_str(); pub(s); uint32 aa = authorizesAnything; pub(aa); if (!authorizesAnything) { - uint32 count = authorizations.size(); pub(count); + Endian count = authorizations.size(); pub(count); for (AclAuthorizationSet::iterator it = authorizations.begin(); it != authorizations.end(); it++) { - AclAuthorization auth = *it; pub(auth); + Endian auth = *it; pub(auth); } } //@@@ export time range @@ -313,7 +317,7 @@ public: template static void ObjectAcl::exportSubject(AclSubject *subject, Action &pub, Action &priv) { - uint32 typeAndVersion = subject->type() | subject->version() << AclSubject::versionShift; + Endian typeAndVersion = subject->type() | subject->version() << AclSubject::versionShift; pub(typeAndVersion); subject->exportBlob(pub, priv); } @@ -356,7 +360,7 @@ private: // class ResourceControlContext : public PodWrapper { public: - ResourceControlContext() { } + ResourceControlContext() { clearPod(); } ResourceControlContext(const AclEntryInput &initial, AccessCredentials *cred = NULL) { InitialAclEntry = initial; AccessCred = cred; } diff --git a/cdsa/cdsa_utilities/cssmaclpod.h b/cdsa/cdsa_utilities/cssmaclpod.h index 8102010e..67a5fa24 100644 --- a/cdsa/cdsa_utilities/cssmaclpod.h +++ b/cdsa/cdsa_utilities/cssmaclpod.h @@ -26,12 +26,7 @@ #include #include -#ifdef _CPP_CSSMACLPOD -#pragma export on -#endif - -namespace Security -{ +namespace Security { // a nicer name for an authorization tag typedef CSSM_ACL_AUTHORIZATION_TAG AclAuthorization; @@ -94,8 +89,8 @@ public: class AclEntryInfo : public PodWrapper { public: AclEntryPrototype &proto() { return AclEntryPrototype::overlay(EntryPublicInfo); } - const AclEntryPrototype &proto() - const { return AclEntryPrototype::overlay(EntryPublicInfo); } + const AclEntryPrototype &proto() const + { return AclEntryPrototype::overlay(EntryPublicInfo); } operator AclEntryPrototype &() { return proto(); } operator const AclEntryPrototype &() const { return proto(); } @@ -164,7 +159,8 @@ public: : mAclEntryInfo(NULL), mNumberOfAclEntries(0), mAllocator(allocator) { } ~AutoAclEntryInfoList(); - operator CSSM_ACL_ENTRY_INFO_PTR *() { return &CSSM_ACL_ENTRY_INFO_PTR(mAclEntryInfo); } + operator CSSM_ACL_ENTRY_INFO_PTR *() + { return reinterpret_cast(&mAclEntryInfo); } operator uint32 *() { return &mNumberOfAclEntries; } void allocator(CssmAllocator &allocator); @@ -206,38 +202,65 @@ template AclEntryInput *walk(Action &operate, AclEntryInput * &input) { operate(input); - walk(operate, *input); + walk(operate, input->proto()); return input; } template void walk(Action &operate, AclEntryInput &input) -{ walk(operate, input.proto()); } +{ + operate(input); + walk(operate, input.proto()); +} // AclEntryInfo template void walk(Action &operate, AclEntryInfo &info) -{ walk(operate, info.proto()); } +{ + operate(info); + walk(operate, info.proto()); +} template void walk(Action &operate, const AclEntryInfo &info) { walk(operate, const_cast(info)); } +// AuthorizationGroup +template +void walk(Action &operate, AuthorizationGroup &auth) +{ + operate(auth); + uint32 count = auth.count(); + operate.blob(auth.AuthTags, count * sizeof(AclAuthorization)); + for (uint32 n = 0; n < count; n++) + walk(operate, auth.AuthTags[n]); +} + +template +void walk(Action &operate, CSSM_AUTHORIZATIONGROUP &auth) +{ walk(operate, static_cast(auth)); } + // AclEntryPrototype template -void walk(Action &operate, AclEntryPrototype &proto) +void enumerate(Action &operate, AclEntryPrototype &proto) { walk(operate, proto.subject()); - operate(proto.Authorization.AuthTags, - sizeof(CSSM_ACL_AUTHORIZATION_TAG) * proto.Authorization.NumberOfAuthTags); + walk(operate, proto.authorization()); //@@@ ignoring validity period } +template +void walk(Action &operate, AclEntryPrototype &proto) +{ + operate(proto); + enumerate(operate, proto); +} + template AclEntryPrototype *walk(Action &operate, AclEntryPrototype * &proto) { operate(proto); - walk(operate, *proto); + enumerate(operate, *proto); return proto; } @@ -245,6 +268,7 @@ AclEntryPrototype *walk(Action &operate, AclEntryPrototype * &proto) template void walk(Action &operate, AclOwnerPrototype &proto) { + operate(proto); walk(operate, proto.subject()); } @@ -252,7 +276,7 @@ template AclOwnerPrototype *walk(Action &operate, AclOwnerPrototype * &proto) { operate(proto); - walk(operate, *proto); + walk(operate, proto->subject()); return proto; } @@ -261,9 +285,5 @@ AclOwnerPrototype *walk(Action &operate, AclOwnerPrototype * &proto) } // end namespace Security -#ifdef _CPP_CSSMACLPOD -#pragma export off -#endif - #endif //_CSSMACLPOD diff --git a/cdsa/cdsa_utilities/cssmalloc.h b/cdsa/cdsa_utilities/cssmalloc.h index 5fd3d636..18bd5097 100644 --- a/cdsa/cdsa_utilities/cssmalloc.h +++ b/cdsa/cdsa_utilities/cssmalloc.h @@ -158,9 +158,13 @@ private: // // Global C++ allocation hooks to use CssmAllocators // -inline void *operator new (size_t size, CssmAllocator &allocator) throw(std::bad_alloc) +inline void *operator new (size_t size, CssmAllocator &allocator) throw (std::bad_alloc) { return allocator.malloc(size); } +inline void *operator new[] (size_t size, CssmAllocator &allocator) throw (std::bad_alloc) +{ return allocator.malloc(size); } + + // // You'd think that this is operator delete(const T *, CssmAllocator &), but you'd // be wrong. Specialized operator delete is only called during constructor cleanup. diff --git a/cdsa/cdsa_utilities/cssmcert.cpp b/cdsa/cdsa_utilities/cssmcert.cpp index 9777e5d8..ff26e706 100644 --- a/cdsa/cdsa_utilities/cssmcert.cpp +++ b/cdsa/cdsa_utilities/cssmcert.cpp @@ -63,10 +63,12 @@ void CertGroup::destroy(CssmAllocator &allocator) // array of CSSM_DATA elements for (uint32 n = 0; n < count(); n++) allocator.free(blobCerts()[n].data()); + allocator.free (blobCerts ()); break; case CSSM_CERTGROUP_ENCODED_CERT: for (uint32 n = 0; n < count(); n++) allocator.free(encodedCerts()[n].data()); + allocator.free (blobCerts ()); break; case CSSM_CERTGROUP_PARSED_CERT: // CSSM_PARSED_CERTS array -- unimplemented diff --git a/cdsa/cdsa_utilities/cssmcred.cpp b/cdsa/cdsa_utilities/cssmcred.cpp index d65d5371..781e47d6 100644 --- a/cdsa/cdsa_utilities/cssmcred.cpp +++ b/cdsa/cdsa_utilities/cssmcred.cpp @@ -38,6 +38,27 @@ const AccessCredentials &AccessCredentials::null = #endif +// +// Scan a SampleGroup for samples with a given CSSM_SAMPLE_TYPE. +// Collect all matching samples into a list (which is cleared to begin with). +// Return true if any were found, false if none. +// Throw if any of the samples are obviously malformed. +// +bool SampleGroup::collect(CSSM_SAMPLE_TYPE sampleType, list &matches) const +{ + for (uint32 n = 0; n < length(); n++) { + TypedList sample = (*this)[n]; + sample.checkProper(); + if (sample.type() == sampleType) { + sample.snip(); // skip sample type + matches.push_back(sample); + } + } + return !matches.empty(); +} + + + // // AutoCredentials self-constructing credentials structure // diff --git a/cdsa/cdsa_utilities/cssmcred.h b/cdsa/cdsa_utilities/cssmcred.h index 4b51e17b..ecd41a01 100644 --- a/cdsa/cdsa_utilities/cssmcred.h +++ b/cdsa/cdsa_utilities/cssmcred.h @@ -25,13 +25,10 @@ #include #include #include +#include -#ifdef _CPP_CSSMCRED -#pragma export on -#endif +namespace Security { -namespace Security -{ // // PodWrappers for samples and sample groups @@ -58,6 +55,11 @@ public: const CssmSample &operator [] (uint32 n) const { assert(n < length()); return CssmSample::overlay(Samples[n]); } + +public: + // extract all samples of a given sample type. return true if any found + // note that you get a shallow copy of the sample structures for temporary use ONLY + bool collect(CSSM_SAMPLE_TYPE sampleType, list &samples) const; }; @@ -122,6 +124,7 @@ namespace DataWalkers template void walk(Action &operate, CssmSample &sample) { + operate(sample); walk(operate, sample.value()); if (sample.verifier()) walk(operate, sample.verifier()); @@ -135,7 +138,9 @@ void walk(Action &operate, const CssmSample &sample) template void walk(Action &operate, SampleGroup &samples) { - operate(samples.Samples, samples.length() * sizeof(CssmSample)); + operate(samples); + operate.blob(const_cast(samples.Samples), + samples.length() * sizeof(CSSM_SAMPLE)); for (uint32 n = 0; n < samples.length(); n++) walk(operate, samples[n]); } @@ -155,14 +160,13 @@ template CSSM_ACCESS_CREDENTIALS *walk(Action &operate, CSSM_ACCESS_CREDENTIALS * &cred) { return walk(operate, AccessCredentials::overlayVar(cred)); } +template +AutoCredentials *walk(Action &operate, AutoCredentials * &cred) +{ return (AutoCredentials *)walk(operate, (AccessCredentials * &)cred); } -} // end namespace DataWalkers +} // end namespace DataWalkers } // end namespace Security -#ifdef _CPP_CSSMCRED -#pragma export off -#endif - #endif //_CSSMCRED diff --git a/cdsa/cdsa_utilities/cssmdata.h b/cdsa/cdsa_utilities/cssmdata.h index b7754d14..6b997fe6 100644 --- a/cdsa/cdsa_utilities/cssmdata.h +++ b/cdsa/cdsa_utilities/cssmdata.h @@ -38,6 +38,7 @@ namespace Security { class StringData : public CssmData { public: StringData(const char *s) : CssmData(const_cast(s), strlen(s)) { } + StringData(const std::string &s) : CssmData(const_cast(s.c_str()), s.size()) { } }; @@ -101,6 +102,25 @@ public: }; +inline bool operator == (const CssmManagedData &d1, const CssmData &d2) +{ return d1.get() == d2; } + +inline bool operator == (const CssmData &d1, const CssmManagedData &d2) +{ return d1 == d2.get(); } + +inline bool operator == (const CssmManagedData &d1, const CssmManagedData &d2) +{ return d1.get() == d2.get(); } + +inline bool operator != (const CssmManagedData &d1, const CssmData &d2) +{ return d1.get() != d2; } + +inline bool operator != (const CssmData &d1, const CssmManagedData &d2) +{ return d1 != d2.get(); } + +inline bool operator != (const CssmManagedData &d1, const CssmManagedData &d2) +{ return d1.get() != d2.get(); } + + // // A CssmOwnedData is a CssmManagedData that unilaterally owns its data storage. // It has its CssmData object provided during construction. @@ -395,6 +415,7 @@ public: CssmData(inAllocator.malloc(length), length), mAllocator(inAllocator) { if (length) ::memcpy(Data, data, length); } void clear() { if (Data) { mAllocator.free(Data); Data = NULL; Length = 0; } } + void invalidate () {Data = NULL; Length = 0;} ~CssmDataContainer() { if (Data) mAllocator.free(Data); } void append(const CssmPolyData &data) { diff --git a/cdsa/cdsa_utilities/cssmdates.h b/cdsa/cdsa_utilities/cssmdates.h index f19e0e7e..a832cbb2 100644 --- a/cdsa/cdsa_utilities/cssmdates.h +++ b/cdsa/cdsa_utilities/cssmdates.h @@ -84,9 +84,12 @@ public: CssmUniformDate(CFDateRef ref); operator CFDateRef() const; + // convert to/from CFAbsoluteTime + CssmUniformDate(CFAbsoluteTime ct) : mTime(ct) { } + operator CFAbsoluteTime() const { return mTime; } + // convert to/from CSSM_DATE CssmUniformDate(const CssmDate &src); - CssmUniformDate(const CSSM_DATE &src); operator CssmDate () const; // convert to/from DATA format (1999-06-30_15:05:39 form) diff --git a/cdsa/cdsa_utilities/cssmdb.cpp b/cdsa/cdsa_utilities/cssmdb.cpp index eb7b7f1a..aa779b0a 100644 --- a/cdsa/cdsa_utilities/cssmdb.cpp +++ b/cdsa/cdsa_utilities/cssmdb.cpp @@ -26,43 +26,6 @@ #include -#if 0 -// XXX Obsolete -CSSM_RETURN AddFooToIntelList( void** theIntelListToAddItTo, unsigned long* theNumberOfThingsAlreadyInTheList, const void* theThingToAdd, size_t theSizeOfTheThingToAdd) -{ // this is to make adding things to Intel LISTs (also called Arrays by the rest of us) easy! We do it everywhere! Join the fun! - CSSM_RETURN result = CSSM_OK; - void* theReallocatedBuffer = NULL; - if( *theIntelListToAddItTo == NULL ) - { - - *theIntelListToAddItTo = malloc(theSizeOfTheThingToAdd); - if(!*theIntelListToAddItTo) - { - result = CSSMERR_CSSM_MEMORY_ERROR; - } - } - else - { - theReallocatedBuffer = realloc((void*)*theIntelListToAddItTo, (*theNumberOfThingsAlreadyInTheList+1) * (theSizeOfTheThingToAdd) ); - if(!theReallocatedBuffer) - { - result = CSSMERR_CSSM_MEMORY_ERROR; - } - else - { - *theIntelListToAddItTo = theReallocatedBuffer; - } - } - - if(result == CSSM_OK ) - { - memcpy( (void*)((char*)*theIntelListToAddItTo+(theSizeOfTheThingToAdd * (*theNumberOfThingsAlreadyInTheList))), theThingToAdd, theSizeOfTheThingToAdd); - (*theNumberOfThingsAlreadyInTheList)++; - } - - return result; -} -#endif // // CssmDbAttributeInfo @@ -305,7 +268,7 @@ static bool CompareAttributeInfos (const CSSM_DB_ATTRIBUTE_INFO &a, const CSSM_D CssmDbAttributeData* CssmAutoDbRecordAttributeData::findAttribute (const CSSM_DB_ATTRIBUTE_INFO &info) { // walk through the data, looking for an attribute of the same type - int i; + unsigned i; for (i = 0; i < size (); ++i) { CssmDbAttributeData& d = at (i); @@ -363,7 +326,7 @@ CssmAutoDbRecordAttributeData::add(const CSSM_DB_ATTRIBUTE_INFO &info, const Css // CssmAutoQuery // CssmAutoQuery::CssmAutoQuery(const CSSM_QUERY &query, CssmAllocator &allocator) -: ArrayBuilder(static_cast(SelectionPredicate), +: ArrayBuilder(CssmSelectionPredicate::overlayVar(SelectionPredicate), NumSelectionPredicates, query.NumSelectionPredicates, allocator) { diff --git a/cdsa/cdsa_utilities/cssmdb.h b/cdsa/cdsa_utilities/cssmdb.h index d1b5ea47..f6aadfb7 100644 --- a/cdsa/cdsa_utilities/cssmdb.h +++ b/cdsa/cdsa_utilities/cssmdb.h @@ -37,14 +37,6 @@ namespace Security { -#if 0 -// -// XXX Obsolete --mb -// -// some prototypes for utility functions -CSSM_RETURN AddFooToIntelList( void** theIntelListToAddItTo, unsigned long* theNumberOfThingsAlreadyInTheList, const void* theThingToAdd, size_t theSizeOfTheThingToAdd); -#endif - // // Template class to build and maintain external arrays. // Feel free to add and vector<> member functions and behaviours as needed. @@ -245,7 +237,7 @@ class CssmAutoDbRecordAttributeInfo: public CssmDbRecordAttributeInfo, public Ar public: CssmAutoDbRecordAttributeInfo(uint32 capacity = 0, CssmAllocator &allocator = CssmAllocator::standard()) : CssmDbRecordAttributeInfo(), - ArrayBuilder(static_cast(AttributeInfo), + ArrayBuilder(CssmDbAttributeInfo::overlayVar(AttributeInfo), NumberOfAttributes, capacity, allocator) {} }; @@ -428,7 +420,7 @@ public: CssmAllocator &valueAllocator = CssmAllocator::standard(), CssmAllocator &dataAllocator = CssmAllocator::standard()) : CssmDbRecordAttributeData(), - ArrayBuilder(static_cast(AttributeData), + ArrayBuilder(CssmDbAttributeData::overlayVar(AttributeData), NumberOfAttributes, capacity, dataAllocator), mValueAllocator(valueAllocator) {} ~CssmAutoDbRecordAttributeData(); @@ -522,7 +514,7 @@ class CssmAutoQuery : public CssmQuery, public ArrayBuilder(static_cast(SelectionPredicate), + ArrayBuilder(CssmSelectionPredicate::overlayVar(SelectionPredicate), NumSelectionPredicates, capacity, allocator) {} ~CssmAutoQuery(); @@ -557,10 +549,10 @@ protected: const char *dbName() const { return mDbName.dbName().c_str(); } const CssmNetAddress *dbLocation() const { return mDbName.dbLocation(); } - // operators + // comparison (simple lexicographic) bool operator < (const Impl &other) const - { return (mCssmSubserviceUid < other.mCssmSubserviceUid || - (!(other.mCssmSubserviceUid < mCssmSubserviceUid) && mDbName < other.mDbName)); } + { return mCssmSubserviceUid < other.mCssmSubserviceUid || + (mCssmSubserviceUid == other.mCssmSubserviceUid && mDbName < other.mDbName); } bool operator == (const Impl &other) const { return mCssmSubserviceUid == other.mCssmSubserviceUid && mDbName == other.mDbName; } @@ -586,6 +578,8 @@ public: { return mImpl && other.mImpl ? *mImpl < *other.mImpl : mImpl.get() < other.mImpl.get(); } bool operator ==(const DLDbIdentifier &other) const { return mImpl && other.mImpl ? *mImpl == *other.mImpl : mImpl.get() == other.mImpl.get(); } + DLDbIdentifier &operator =(const DLDbIdentifier &other) + { mImpl = other.mImpl; return *this; } // Accessors const CssmSubserviceUid &ssuid() const { return mImpl->ssuid(); } diff --git a/cdsa/cdsa_utilities/cssmerrno.cpp b/cdsa/cdsa_utilities/cssmerrno.cpp index 23029da8..47e58b09 100644 --- a/cdsa/cdsa_utilities/cssmerrno.cpp +++ b/cdsa/cdsa_utilities/cssmerrno.cpp @@ -19,10 +19,9 @@ // // cssmerrno - number-to-string translation for CSSM error codes // -#ifdef __MWERKS__ -#define _CPP_CSSMERRNO -#endif #include +#include +#include #include #include #include @@ -71,21 +70,29 @@ void cssmPerror(const char *how, CSSM_RETURN error) // -// Produce a diagnostic string from a CSSM error number or exception +// Produce a diagnostic string from a CSSM error number or exception. +// Small numbers are tried as convertible errors first. +// Unknown errors are output numerically with a note. // string cssmErrorString(CSSM_RETURN error) { if (error == CSSM_OK) { return "[ok]"; + } else if (error >= errSecErrnoBase && error <= errSecErrnoLimit) { + return string("UNIX[") + strerror(error - errSecErrnoBase) + "]"; } else if (error > 0 && - int(error) < int(sizeof(convErrorList) / sizeof(convErrorList[0]))) { + int(error) < int(sizeof(convErrorList) / sizeof(convErrorList[0])) && + convErrorList[error]) { return string("COMMON[") + convErrorList[error] + "]"; } else { ErrorMap::const_iterator it = errorMap().find(error); - if (it == errorMap().end()) - return "[UNKNOWN]"; - else + if (it == errorMap().end()) { + char msg[80]; + snprintf(msg, sizeof(msg), "[UNKNOWN:0x%lx=%ld]", error, error); + return msg; + } else { return it->second; + } } } diff --git a/cdsa/cdsa_utilities/cssmlist.cpp b/cdsa/cdsa_utilities/cssmlist.cpp index 1bb5176a..4e3648f8 100644 --- a/cdsa/cdsa_utilities/cssmlist.cpp +++ b/cdsa/cdsa_utilities/cssmlist.cpp @@ -98,6 +98,16 @@ const CssmList &ListElement::list() const return CssmList::overlay(Element.Sublist); } +TypedList &ListElement::typedList() +{ + return static_cast(list()); +} + +const TypedList &ListElement::typedList() const +{ + return static_cast(list()); +} + CSSM_WORDID_TYPE ListElement::word() const { assert(type() == CSSM_LIST_ELEMENT_WORDID); @@ -270,3 +280,9 @@ bool TypedList::isProper() const { return first() && first()->type() == CSSM_LIST_ELEMENT_WORDID; } + +void TypedList::checkProper(CSSM_RETURN error) const +{ + if (!isProper()) + CssmError::throwMe(error); +} diff --git a/cdsa/cdsa_utilities/cssmlist.h b/cdsa/cdsa_utilities/cssmlist.h index 58653b9a..b5b1ec4f 100644 --- a/cdsa/cdsa_utilities/cssmlist.h +++ b/cdsa/cdsa_utilities/cssmlist.h @@ -24,14 +24,10 @@ #include #include -#include +#include -#ifdef _CPP_CSSMLIST -#pragma export on -#endif -namespace Security -{ +namespace Security { class CssmList; class TypedList; @@ -57,9 +53,9 @@ public: ListElement *last(); // CssmData personality - ListElement(const CssmData &data); - ListElement(CssmAllocator &alloc, const CssmData &data); - ListElement(CssmAllocator &alloc, const std::string &stringData); + explicit ListElement(const CssmData &data); + explicit ListElement(CssmAllocator &alloc, const CssmData &data); + explicit ListElement(CssmAllocator &alloc, const std::string &stringData); CssmData &data(); string toString() const { return data().toString(); } const CssmData &data() const; @@ -74,22 +70,20 @@ public: { data().extract(destination, error); } // CssmList (sublist) personality - ListElement(const CssmList &list); + explicit ListElement(const CssmList &list); CssmList &list(); const CssmList &list() const; + TypedList &typedList(); + const TypedList &typedList() const; ListElement &operator = (const CssmList &list); operator CssmList &() { return list(); } - operator const CssmList &() const { return list(); } operator TypedList &(); - operator const TypedList &() const; // WORDID (number) personality - ListElement(CSSM_WORDID_TYPE word); + explicit ListElement(CSSM_WORDID_TYPE word); CSSM_WORDID_TYPE word() const; ListElement &operator = (CSSM_WORDID_TYPE word); operator CSSM_WORDID_TYPE () const { return word(); } - bool operator == (CSSM_WORDID_TYPE other) const { return word() == other; } - bool operator != (CSSM_WORDID_TYPE other) const { return word() != other; } public: void *operator new (size_t size, CssmAllocator &alloc) @@ -107,8 +101,8 @@ inline void destroy(ListElement *elem, CssmAllocator &alloc) alloc.free(elem); } -namespace Security -{ +namespace Security { + // // A POD Wrapper for CSSM_LIST. @@ -160,7 +154,7 @@ namespace Security // class TypedList : public CssmList { public: - TypedList(const CSSM_LIST &list) { *(CSSM_LIST *)this = list; } + explicit TypedList(const CSSM_LIST &list) { *(CSSM_LIST *)this = list; } TypedList(CssmAllocator &alloc, CSSM_WORDID_TYPE type); TypedList(CssmAllocator &alloc, CSSM_WORDID_TYPE type, ListElement *elem1); TypedList(CssmAllocator &alloc, CSSM_WORDID_TYPE type, ListElement *elem1, @@ -171,6 +165,7 @@ public: ListElement *elem2, ListElement *elem3, ListElement *elem4); bool isProper() const; // format check (does not throw) + void checkProper(CSSM_RETURN error = CSSM_ERRCODE_INVALID_SAMPLE_VALUE) const; static TypedList &overlay(CSSM_LIST &list) { return static_cast(list); } static const TypedList &overlay(const CSSM_LIST &list) @@ -183,17 +178,14 @@ public: inline ListElement::operator TypedList &() { return TypedList::overlay(operator CssmList &()); } -inline ListElement::operator const TypedList &() const -{ return TypedList::overlay(operator const CssmList &()); } - // // Data walkers to parse list elements and lists. // @@@ Walking lists by recursing over next() is stack intensive. Do this in CssmList walker by loop? // -namespace DataWalkers -{ +namespace DataWalkers { +// ListElement template ListElement *walk(Action &operate, ListElement * &elem) { @@ -208,7 +200,8 @@ ListElement *walk(Action &operate, ListElement * &elem) case CSSM_LIST_ELEMENT_WORDID: break; default: - assert(false); + secdebug("walkers", "invalid list element type (%lx)", elem->type()); + break; } if (elem->next()) walk(operate, elem->next()); @@ -217,10 +210,11 @@ ListElement *walk(Action &operate, ListElement * &elem) template ListElement *walk(Action &operate, CSSM_LIST_ELEMENT * &elem) -{ walk(operate, ListElement::overlay(elem)); } +{ walk(operate, ListElement::overlayVar(elem)); } +// CssmList template -void walk(Action &operate, CssmList &list) +void enumerate(Action &operate, CssmList &list) { if (!list.empty()) { walk(operate, list.first()); @@ -229,6 +223,25 @@ void walk(Action &operate, CssmList &list) } } +template +CssmList *walk(Action &operate, CssmList * &list) +{ + operate(list); + enumerate(operate, *list); + return list; +} + +template +void walk(Action &operate, CssmList &list) +{ + operate(list); + enumerate(operate, list); +} + +template +void walk(Action &operate, const CssmList &list) +{ walk(operate, const_cast(list)); } + template void walk(Action &operate, CSSM_LIST &list) { walk(operate, CssmList::overlay(list)); } @@ -238,24 +251,20 @@ void walk(Action &operate, const CSSM_LIST &list) { walk(operate, const_cast(list)); } template -void walk(Action &operate, const CssmList &list) -{ walk(operate, const_cast(list)); } +CSSM_LIST *walk(Action &operate, CSSM_LIST * &list) +{ return walk(operate, CssmList::overlayVar(list)); } +template +TypedList *walk(Action &operate, TypedList * &list) +{ return static_cast(walk(operate, reinterpret_cast(list))); } template -CSSM_LIST *walk(Action &operate, CSSM_LIST * &list) -{ - operate(list); - walk(operate, *list); - return list; -} +void walk(Action &operate, TypedList &list) +{ walk(operate, static_cast(list)); } -} // end namespace DataWalkers -}; // end namespace Security +} // end namespace DataWalkers +} // end namespace Security -#ifdef _CPP_CSSMLIST -#pragma export off -#endif #endif //_H_CSSMLIST diff --git a/cdsa/cdsa_utilities/cssmtrust.h b/cdsa/cdsa_utilities/cssmtrust.h index d95940a8..a1ff8a2f 100644 --- a/cdsa/cdsa_utilities/cssmtrust.h +++ b/cdsa/cdsa_utilities/cssmtrust.h @@ -65,6 +65,22 @@ public: operator bool() const { return DLHandle && DBHandle; } }; +inline bool operator < (const CSSM_DL_DB_HANDLE &h1, const CSSM_DL_DB_HANDLE &h2) +{ + return h1.DLHandle < h2.DLHandle + || (h1.DLHandle == h2.DLHandle && h1.DBHandle < h2.DBHandle); +} + +inline bool operator == (const CSSM_DL_DB_HANDLE &h1, const CSSM_DL_DB_HANDLE &h2) +{ + return h1.DLHandle == h2.DLHandle && h1.DBHandle == h2.DBHandle; +} + +inline bool operator != (const CSSM_DL_DB_HANDLE &h1, const CSSM_DL_DB_HANDLE &h2) +{ + return h1.DLHandle != h2.DLHandle || h1.DBHandle != h2.DBHandle; +} + class CssmDlDbList : public PodWrapper { public: diff --git a/cdsa/cdsa_utilities/cssmwalkers.h b/cdsa/cdsa_utilities/cssmwalkers.h index 5fdb0773..3ba1afae 100644 --- a/cdsa/cdsa_utilities/cssmwalkers.h +++ b/cdsa/cdsa_utilities/cssmwalkers.h @@ -24,40 +24,46 @@ #include -#ifdef _CPP_CSSMWALKERS -# pragma export on -#endif +namespace Security { +namespace DataWalkers { -namespace Security -{ - -namespace DataWalkers -{ // -// Walk an INLINE CSSM_DATA by dealing with the data it points to. -// Note that this is not the walker for an OUT OF LINE CSSM_DATA, -// which is quite regular and handled below. +// The full set of walkers for CssmData in all its forms. // template -void walk(Action &operate, CSSM_DATA &data) +void walk(Action &operate, CssmData &data) { - void *p = data.Data; - operate(p, data.Length); - data.Data = reinterpret_cast(p); + operate(data); + operate.blob(data.Data, data.Length); } +template +CssmData *walk(Action &operate, CssmData * &data) +{ + operate(data); + operate.blob(data->Data, data->Length); + return data; +} + +template +void walk(Action &operate, CSSM_DATA &data) +{ walk(operate, CssmData::overlay(data)); } + +template +CSSM_DATA *walk(Action &operate, CSSM_DATA * &data) +{ return walk(operate, CssmData::overlayVar(data)); } + + // // Walking a C string is almost regular (the size comes from strlen()). +// Just make sure you honor the needsSize preference of the operator. // template char *walk(Action &operate, char * &s) { - // A string's length is obtained by reading the string value. - // We must honor the operator's preference for not calculating length - // (e.g. because s won't be valid until some magic thing was done to it). operate(s, operate.needsSize ? (strlen(s) + 1) : 0); return s; } @@ -82,18 +88,6 @@ uint32 walk(Action &, uint32 arg) // Flattener functions for common CSSM data types that have internal // structure. (The flat ones are handled by the default above.) // -template -CssmData *walk(Action &operate, CssmData * &data) -{ - operate(data); - walk(operate, *data); - return data; -} - -template -CSSM_DATA *walk(Action &operate, CSSM_DATA * &data) -{ return walk(operate, CssmData::overlayVar(data)); } - template CssmKey *walk(Action &operate, CssmKey * &key) { @@ -128,11 +122,6 @@ CSSM_PKCS5_PBKDF2_PARAMS *walk(Action &operate, CSSM_PKCS5_PBKDF2_PARAMS * &data } // end namespace DataWalkers - } // end namespace Security -#ifdef _CPP_CSSMWALKERS -# pragma export off -#endif - #endif //_H_CSSMWALKERS diff --git a/cdsa/cdsa_utilities/daemon.cpp b/cdsa/cdsa_utilities/daemon.cpp index 604c8e30..c8e47fae 100644 --- a/cdsa/cdsa_utilities/daemon.cpp +++ b/cdsa/cdsa_utilities/daemon.cpp @@ -87,12 +87,12 @@ bool executeSelf(char **argv) { static const char reExecEnv[] = "_RE_EXECUTE"; if (getenv(reExecEnv)) { // was re-executed - debug("daemon", "self-execution complete"); + secdebug("daemon", "self-execution complete"); unsetenv(reExecEnv); return true; } else { setenv(reExecEnv, "go", 1); - debug("daemon", "self-executing (ouch!)"); + secdebug("daemon", "self-executing (ouch!)"); execv(argv[0], argv); perror("re-execution"); Syslog::error("Re-execution attempt failed"); diff --git a/cdsa/cdsa_utilities/db++.cpp b/cdsa/cdsa_utilities/db++.cpp new file mode 100644 index 00000000..33b9f772 --- /dev/null +++ b/cdsa/cdsa_utilities/db++.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// dbm++ - generic C++ layer interface to [n]dbm +// +#include "db++.h" +#include + + +namespace Security { +namespace UnixPlusPlus { + +UnixDb::UnixDb() : mDb(NULL) +{ +} + +UnixDb::UnixDb(const char *path, int flags, int mode, DBTYPE type) : mDb(NULL) +{ + open(path, flags, mode); +} + +UnixDb::UnixDb(const std::string &path, int flags, int mode, DBTYPE type) : mDb(NULL) +{ + open(path, flags, mode); +} + +UnixDb::~UnixDb() +{ + close(); +} + +void UnixDb::open(const char *path, int flags, int mode, DBTYPE type) +{ + if (DB* newDb = ::dbopen(path, flags, mode, type, NULL)) { + close(); + mDb = newDb; + setFd(mDb->fd(mDb)); + secdebug("unixdb", "open(%s,0x%x,0x%x,type=%d)=%p", path, flags, mode, type, mDb); + } else + UnixError::throwMe(); +} + +void UnixDb::open(const std::string &path, int flags, int mode, DBTYPE type) +{ + open(path.c_str(), flags, mode); +} + +void UnixDb::close() +{ + if (mDb) { + secdebug("unixdb", "close(%p)", mDb); + mDb->close(mDb); + mDb = NULL; + setFd(invalidFd); + } +} + +bool UnixDb::get(const CssmData &key, CssmData &value, int flags) const +{ + Data dKey(key); + Data val; + int rc = mDb->get(mDb, &dKey, &val, flags); + secdebug("unixdb", "get(%p,[:%ld],flags=0x%x)=%d[:%ld]", + mDb, key.length(), flags, rc, value.length()); + checkError(rc); + if (!rc) { + value = val; + return true; + } else + return false; +} + +bool UnixDb::get(const CssmData &key, CssmOwnedData &value, int flags) const +{ + CssmData val; + if (get(key, val, flags)) { + value = val; + return true; + } else + return false; +} + +bool UnixDb::put(const CssmData &key, const CssmData &value, int flags) +{ + Data dKey(key); + Data dValue(value); + int rc = mDb->put(mDb, &dKey, &dValue, flags); + secdebug("unixdb", "put(%p,[:%ld],[:%ld],flags=0x%x)=%d", + mDb, key.length(), value.length(), flags, rc); + checkError(rc); + return !rc; +} + +void UnixDb::erase(const CssmData &key, int flags) +{ + Data dKey(key); + secdebug("unixdb", "delete(%p,[:%ld],flags=0x%x)", mDb, key.length(), flags); + checkError(mDb->del(mDb, &dKey, flags)); +} + +bool UnixDb::next(CssmData &key, CssmData &value, int flags /* = R_NEXT */) const +{ + Data dKey, dValue; + int rc = mDb->seq(mDb, &dKey, &dValue, flags); + checkError(rc); + if (!rc) { + key = dKey; + value = dValue; + return true; + } else + return false; +} + + +void UnixDb::flush(int flags) +{ + checkError(mDb->sync(mDb, flags)); +} + + +} // end namespace UnixPlusPlus +} // end namespace Security diff --git a/cdsa/cdsa_utilities/db++.h b/cdsa/cdsa_utilities/db++.h new file mode 100644 index 00000000..38ae4811 --- /dev/null +++ b/cdsa/cdsa_utilities/db++.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// dbm++ - generic C++ layer interface to [n]dbm +// +#ifndef _H_DBMPP +#define _H_DBMPP + +#include +#include +#include +#include +#include + + +namespace Security { +namespace UnixPlusPlus { + + +class UnixDb : public FileDesc { +public: + UnixDb(); + UnixDb(const char *path, int flags = O_RDWR, int mode = 0666, DBTYPE type = DB_HASH); + UnixDb(const std::string &path, int flags = O_RDWR, int mode = 0666, DBTYPE type = DB_HASH); + + virtual ~UnixDb(); + + void open(const char *path, int flags = O_RDWR, int mode = 0666, DBTYPE type = DB_HASH); + void open(const std::string &path, int flags = O_RDWR, int mode = 0666, DBTYPE type = DB_HASH); + void close(); + + bool get(const CssmData &key, CssmData &value, int flags = 0) const; + bool get(const CssmData &key, CssmOwnedData &value, int flags = 0) const; + bool put(const CssmData &key, const CssmData &value, int flags = 0); + void erase(const CssmData &key, int flags = 0); + void flush(int flags = 0); + + bool next(CssmData &key, CssmData &value, int flags = R_NEXT) const; + bool first(CssmData &key, CssmData &value) const + { return next(key, value, R_FIRST); } + + operator bool () const + { return mDb; } + +public: + struct Data : public PodWrapper { + template + Data(const T &src) { DBT::data = src.data(); DBT::size = src.length(); } + + Data() { } + Data(void *data, size_t length) { DBT::data = data; DBT::size = length; } + Data(const DBT &dat) { DBT::data = dat.data; DBT::size = dat.size; } + + void *data() const { return DBT::data; } + size_t length() const { return size; } + operator bool () const { return DBT::data != NULL; } + operator CssmData () const { return CssmData(data(), length()); } + }; + +private: + DB *mDb; +}; + + +} // end namespace UnixPlusPlus +} // end namespace Security + + +#endif //_H_DBMPP diff --git a/cdsa/cdsa_utilities/debugging.cpp b/cdsa/cdsa_utilities/debugging.cpp index 40085f6a..8a9eb254 100644 --- a/cdsa/cdsa_utilities/debugging.cpp +++ b/cdsa/cdsa_utilities/debugging.cpp @@ -27,31 +27,22 @@ #define SYSLOG_NAMES // compile syslog name tables #include -#if !defined(USE_CXXABI) -#define USE_CXXABI 0 // only available in gcc3 >v1100 -#endif +#include // for name demangling -#if USE_CXXABI -# include // for name demangling -#endif //USE_CXXABI +// enable kernel tracing +#define ENABLE_SECTRACE 1 namespace Security { namespace Debug { -#if defined(NDEBUG) - -void Scope::operator () (const char *, ...) { } - -#else // NDEBUG - // // Main debug functions (global and in-scope) // void debug(const char *scope, const char *format, ...) { -#if !defined(NDEBUG_STUBS) +#if !defined(NDEBUG_CODE) va_list args; va_start(args, format); Target::get().message(scope, format, args); @@ -61,24 +52,14 @@ void debug(const char *scope, const char *format, ...) void vdebug(const char *scope, const char *format, va_list args) { -#if !defined(NDEBUG_STUBS) +#if !defined(NDEBUG_CODE) Target::get().message(scope, format, args); #endif } -void Scope::operator () (const char *format, ...) -{ -#if !defined(NDEBUG_STUBS) - va_list args; - va_start(args, format); - Target::get().message(mScope, format, args); - va_end(args); -#endif -} - bool debugging(const char *scope) { -#if !defined(NDEBUG_STUBS) +#if !defined(NDEBUG_CODE) return Target::get().debugging(scope); #else return false; @@ -86,6 +67,28 @@ bool debugging(const char *scope) } +// +// C equivalents for some basic uses +// +extern "C" { + int __security_debugging(const char *scope); + void __security_debug(const char *scope, const char *format, ...); +}; + +int __security_debugging(const char *scope) +{ return debugging(scope); } + +void __security_debug(const char *scope, const char *format, ...) +{ +#if !defined(NDEBUG_CODE) + va_list args; + va_start(args, format); + vdebug(scope, format, args); + va_end(args); +#endif +} + + // // Dump facility // @@ -100,7 +103,7 @@ bool dumping(const char *scope) void dump(const char *format, ...) { -#if !defined(NDEBUG_STUBS) +#if !defined(NDEBUG_CODE) va_list args; va_start(args, format); Target::get().dump(format, args); @@ -110,7 +113,7 @@ void dump(const char *format, ...) void dumpData(const void *ptr, size_t size) { -#if !defined(NDEBUG_STUBS) +#if !defined(NDEBUG_CODE) const char *addr = reinterpret_cast(ptr); const char *end = addr + size; bool isText = true; @@ -132,7 +135,7 @@ void dumpData(const void *ptr, size_t size) void dumpData(const char *title, const void *ptr, size_t size) { -#if !defined(NDEBUG_STUBS) +#if !defined(NDEBUG_CODE) dump("%s: ", title); dumpData(ptr, size); dump("\n"); @@ -143,28 +146,27 @@ void dumpData(const char *title, const void *ptr, size_t size) // // Turn a C++ typeid into a nice type name. // This uses the C++ ABI where available. +// We're stripping out a few C++ prefixes; they're pretty redundant (and obvious). // string makeTypeName(const type_info &type) { -#if USE_CXXABI int status; char *cname = abi::__cxa_demangle(type.name(), NULL, NULL, &status); - string name = cname; // save the value - ::free(cname); // yes, really (ABI rule) + string name = !strncmp(cname, "Security::", 10) ? (cname + 10) : + !strncmp(cname, "std::", 5) ? (cname + 5) : + cname; + ::free(cname); // yes, really (ABI rules) return name; -#else - return type.name(); // can't demangle; just return internal name -#endif } // // Target initialization // -#if !defined(NDEBUG_STUBS) +#if !defined(NDEBUG_CODE) Target::Target() - : showScope(false), showThread(false), showPid(false), + : showScope(false), showThread(false), showPid(false), sink(NULL) { // put into singleton slot if first @@ -455,8 +457,11 @@ void FileSink::dump(const char *text) void FileSink::configure(const char *options) { - if (options == NULL || !strstr(options, "noflush")) + if (options == NULL || !strstr(options, "noflush")) { + // we mean "if the file isn't unbuffered", but what's the portable way to say that? + if (file != stderr) setlinebuf(file); + } if (options) { addDate = strstr(options, "date"); lockIO = !strstr(options, "nolock"); @@ -502,11 +507,21 @@ void SyslogSink::configure(const char *options) { } -#endif //NDEBUG_STUBS +#endif //NDEBUG_CODE -#endif // NDEBUG +// +// kernel tracing support (C version) +// +extern "C" void security_ktrace(int); -} // end namespace Debug +void security_ktrace(int code) +{ +#if defined(ENABLE_SECTRACE) + syscall(180, code, 0, 0, 0, 0); +#endif +} + +} // end namespace Debug } // end namespace Security diff --git a/cdsa/cdsa_utilities/debugging.h b/cdsa/cdsa_utilities/debugging.h index e75c522e..6343576f 100644 --- a/cdsa/cdsa_utilities/debugging.h +++ b/cdsa/cdsa_utilities/debugging.h @@ -22,23 +22,27 @@ #ifndef _H_DEBUGGING #define _H_DEBUGGING +#ifdef __cplusplus + #include #include #include + namespace Security { namespace Debug { - -#if !defined(NDEBUG) - - -// Debug to standard target +// +// Debug logging functions always exist. +// They may be stubs depending on build options. +// +bool debugging(const char *scope); void debug(const char *scope, const char *format, ...) __attribute__((format(printf,2,3))); void vdebug(const char *scope, const char *format, va_list args); -bool debugging(const char *scope); -// Stream dumping to standard target +// +// Ditto with debug dumping functions. +// bool dumping(const char *scope); void dump(const char *format, ...) __attribute((format(printf,1,2))); void dumpData(const void *data, size_t length); @@ -48,31 +52,12 @@ template inline void dumpData(const Data &obj) template inline void dumpData(const char *title, const Data &obj) { dumpData(title, obj.data(), obj.length()); } -#if defined(DEBUGDUMP) -# define IFDUMP(code) code -# define IFDUMPING(scope,code) if (Debug::dumping(scope)) code; else /* no */ -#else -# define IFDUMP(code) /* no-op */ -# define IFDUMPING(scope,code) /* no-op */ -#endif - - -// -// A (prepared) debug scope object. -// -class Scope { -public: - Scope(const char *string) { mScope = string; } - - void operator () (const char *format, ...); - -private: - const char *mScope; -}; - // -// Given an object of any type, produce the proper name of its type. +// The following functions perform runtime recovery of type names. +// This is meant for debugging ONLY. Don't even THINK of depending +// on this for program correctness. For all you know, we may replace +// all those names with "XXX" tomorrow. // string makeTypeName(const type_info &info); @@ -82,61 +67,70 @@ string typeName(const Object &obj) return makeTypeName(typeid(obj)); } - -#else // NDEBUG +template +string typeName() +{ + return makeTypeName(typeid(Object)); +} // -// If NDEBUG is defined, we try to make all debugging functions weightless +// Now for the conditional inline code // +#if !defined(NDEBUG) +# define secdebug(scope, format...) Security::Debug::debug(scope, ## format) +#else //NDEBUG +# define secdebug(scope, format...) /* nothing */ +#endif //NDEBUG -#if __GNUC__ > 2 -inline void debug(const char *, const char *, ...) { } + +// +// Conditional dump code +// +#if defined(DEBUGDUMP) +# define IFDUMP(code) code +# define IFDUMPING(scope,code) if (Debug::dumping(scope)) code; else /* no */ #else -// @@@ Hack to work around the fact that gcc2 can't inline empty varargs functions. -extern "C" inline void debug() { } +# define IFDUMP(code) /* no-op */ +# define IFDUMPING(scope,code) /* no-op */ #endif -inline void vdebug(const char *, const char *, va_list) { } -inline bool debugging(const char *) { return false; } -class Scope { -public: - Scope(const char *) { } +// +// Kernel trace support +// +inline void trace(int code, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0) +{ +#if defined(ENABLE_SECTRACE) + syscall(180, code, arg1, arg2, arg3, arg4); +#endif +} - // @@@ Hack to work around the fact that gcc can't inline empty varargs functions. - //void operator () (const char *, ...) { } - void operator () (const char *, ...); -}; -inline bool dumping(const char *) { return false; } +} // end namespace Debug +} // end namespace Security -// @@@ Hack to work around the fact that gcc can't inline empty varargs functions. -//inline void dump(const char *, ...) { } -extern "C" inline void dump() { } +// We intentionally leak a few functions into the global namespace +// @@@ (not much longer: after the switch to secdebug(), this will go) +using Security::Debug::debug; -inline void dumpData(const void *, size_t) { } -void dumpData(const char *, const void *, size_t); -template inline void dumpData(const Data &) { } -template inline void dumpData(const char *, const Data &) { } -// debugdumping is forced off -#if defined(DEBUGDUMP) -# undef DEBUGDUMP -#endif -# define IFDUMP(code) /* no-op */ -# define IFDUMPING(scope,code) /* no-op */ +#else //!__cplusplus, C code -// no debug typeName; don't call this if NDEBUG -#endif // NDEBUG +extern void __security_debug(const char *scope, const char *format, ...); +extern int __security_debugging(const char *scope); +#if !defined(NDEBUG) +# define secdebug(scope, format...) __security_debug(scope, ## format) +#else +# define secdebug(scope, format...) /* nothing */ +#endif -} // end namespace Debug -} // end namespace Security -// We intentionally leak a few functions into the global namespace -using Security::Debug::debug; +// ktrace support (C style) +extern void security_ktrace(int code); +#endif //__cplusplus #endif //_H_DEBUGGING diff --git a/cdsa/cdsa_utilities/debugsupport.h b/cdsa/cdsa_utilities/debugsupport.h index bc152d35..7833bfa0 100644 --- a/cdsa/cdsa_utilities/debugsupport.h +++ b/cdsa/cdsa_utilities/debugsupport.h @@ -29,11 +29,6 @@ // client code that may have been generated with debug enabled. You don't actually // get *real* debug logging, of course, just cheap dummy stubs to keep the linker happy. // -#if defined(NDEBUG) && !defined(CLEAN_NDEBUG) -# undef NDEBUG -# define NDEBUG_STUBS -#endif - #include #include #include @@ -43,9 +38,6 @@ namespace Security { namespace Debug { -#if !defined(NDEBUG) - - // // Debug scope names - short strings with value semantics. // We don't use STL strings because of overhead. @@ -184,19 +176,7 @@ private: }; -#else // NDEBUG - -// -// Note that we don't scaffold up the entire Target hierarchy for NDEBUG. -// If you directly manipulate debug Targets, Names, or Sinks, you need to -// conditionalize the code based on NDEBUG. -// - -#endif // NDEBUG - - } // end namespace Debug - } // end namespace Security diff --git a/cdsa/cdsa_utilities/devrandom.cpp b/cdsa/cdsa_utilities/devrandom.cpp index 835b8def..05b180a0 100644 --- a/cdsa/cdsa_utilities/devrandom.cpp +++ b/cdsa/cdsa_utilities/devrandom.cpp @@ -20,6 +20,7 @@ // devrandom - RNG operations based on /dev/random // #include +#include using namespace UnixPlusPlus; @@ -30,22 +31,15 @@ namespace Security { // // The common (shared) open file descriptor to /dev/random // -ModuleNexus DevRandomGenerator::mDevRandom; +ModuleNexus DevRandomGenerator::mReader; +ModuleNexus DevRandomGenerator::mWriter; // -// DevRandomGenerator objects immediately open their file descriptors +// In the current implementation, opening the file descriptor is deferred. // DevRandomGenerator::DevRandomGenerator(bool writable) { - FileDesc &fd = mDevRandom(); - if (!fd) { - fd.open("/dev/random", writable ? O_RDWR : O_RDONLY); - } else if (writable && !fd.isWritable()) { - FileDesc newFd("/dev/random", O_RDWR); - fd.close(); - fd = newFd; - } } @@ -54,7 +48,18 @@ DevRandomGenerator::DevRandomGenerator(bool writable) // void DevRandomGenerator::random(void *data, size_t length) { - mDevRandom().read(data, length); + try { + size_t bytesRead = mReader().read(data, length); + if (bytesRead != length) { // short read (shouldn't happen) + Syslog::error("DevRandomGenerator: wanted %ld got %ld bytes", + length, bytesRead); + UnixError::throwMe(EIO); + } + } catch(const UnixError &uerr) { + Syslog::error("DevRandomGenerator: error %d reading /dev/random", + uerr.error); + throw; + } } @@ -63,7 +68,8 @@ void DevRandomGenerator::random(void *data, size_t length) // void DevRandomGenerator::addEntropy(const void *data, size_t length) { - mDevRandom().write(data, length); + if (mWriter().write(data, length) != length) + UnixError::throwMe(EIO); // short write (shouldn't happen) } diff --git a/cdsa/cdsa_utilities/devrandom.h b/cdsa/cdsa_utilities/devrandom.h index 2905546a..708df47e 100644 --- a/cdsa/cdsa_utilities/devrandom.h +++ b/cdsa/cdsa_utilities/devrandom.h @@ -35,6 +35,14 @@ namespace Security { // It is not repeatable. AddEntropy() contributes random entropy to a global pool (only). // class DevRandomGenerator { + struct Readonly : public UnixPlusPlus::FileDesc { + Readonly() { open("/dev/random", O_RDONLY); } + }; + + struct Writable : public UnixPlusPlus::FileDesc { + Writable() { open("/dev/random", O_RDWR); } + }; + public: DevRandomGenerator(bool writable = false); @@ -42,7 +50,8 @@ public: void addEntropy(const void *data, size_t length); private: - static ModuleNexus mDevRandom; + static ModuleNexus mReader; + static ModuleNexus mWriter; }; diff --git a/cdsa/cdsa_utilities/endian.cpp b/cdsa/cdsa_utilities/endian.cpp new file mode 100644 index 00000000..f890d5a4 --- /dev/null +++ b/cdsa/cdsa_utilities/endian.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// Byte order ("endian-ness") handling +// +#include + +namespace Security { + + +void n2hi(CssmKey::Header &header) +{ + header.HeaderVersion = n2h(header.HeaderVersion); + header.CspId.Data1 = n2h(header.CspId.Data1); + header.CspId.Data2 = n2h(header.CspId.Data2); + header.CspId.Data3 = n2h(header.CspId.Data3); + header.BlobType = n2h(header.BlobType); + header.Format = n2h(header.Format); + header.AlgorithmId = n2h(header.AlgorithmId); + header.KeyClass = n2h(header.KeyClass); + header.LogicalKeySizeInBits = n2h(header.LogicalKeySizeInBits); + header.KeyAttr = n2h(header.KeyAttr); + header.KeyUsage = n2h(header.KeyUsage); + header.WrapAlgorithmId = n2h(header.WrapAlgorithmId); + header.WrapMode = n2h(header.WrapMode); + header.Reserved = n2h(header.Reserved); +} + +void h2ni(CssmKey::Header &key) +{ + n2hi(key); +} + +} // end namespace Security + diff --git a/cdsa/cdsa_utilities/endian.h b/cdsa/cdsa_utilities/endian.h new file mode 100644 index 00000000..083b1d3b --- /dev/null +++ b/cdsa/cdsa_utilities/endian.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +/* + * cssm utilities + */ +#ifndef _H_ENDIAN +#define _H_ENDIAN + +#include +#include +#include + +namespace Security { + + +// +// Encode/decode operations by type, overloaded. +// You can use these functions directly, but consider using +// the higher-level constructs below instead. +// +inline uint32 h2n(uint32 v) { return htonl(v); } +inline sint32 h2n(sint32 v) { return htonl(v); } +inline uint16 h2n(uint16 v) { return htons(v); } +inline sint16 h2n(sint16 v) { return htons(v); } +inline uint8 h2n(uint8 v) { return v; } +inline sint8 h2n(sint8 v) { return v; } + +inline uint32 n2h(uint32 v) { return ntohl(v); } +inline sint32 n2h(sint32 v) { return ntohl(v); } +inline uint16 n2h(uint16 v) { return ntohs(v); } +inline sint16 n2h(sint16 v) { return ntohs(v); } +inline uint8 n2h(uint8 v) { return v; } +inline sint8 n2h(sint8 v) { return v; } + + +// +// Flip pointers +// +template +inline Base *h2n(Base *p) { return (Base *)h2n(LowLevelMemoryUtilities::PointerInt(p)); } + +template +inline Base *n2h(Base *p) { return (Base *)n2h(LowLevelMemoryUtilities::PointerInt(p)); } + + +// +// Generic template - do nothing, issue debug warning +// +template +inline const Type &h2n(const Type &v) +{ + secdebug("endian", "generic h2n called for type %s", Debug::typeName(v).c_str()); + return v; +} + +template +inline const Type &n2h(const Type &v) +{ + secdebug("endian", "generic n2h called for type %s", Debug::typeName(v).c_str()); + return v; +} + + +// +// In-place fix operations +// +template +inline void h2ni(Type &v) { v = h2n(v); } + +template +inline void n2hi(Type &v) { v = n2h(v); } + + +// +// Some structs we may want swapped in-place +// +void n2hi(CssmKey::Header &key); +void h2ni(CssmKey::Header &key); + +inline void n2hi(CSSM_KEYHEADER &key) { n2hi(CssmKey::Header::overlay (key));} +inline void h2ni(CSSM_KEYHEADER &key) { h2ni(CssmKey::Header::overlay (key));} + + +// +// Endian keeps NBO values in memory and converts +// during loads and stores. This presumes that you are using +// memory blocks thare are read/written/mapped as amorphous byte +// streams, but want to be byte-order clean using them. +// +// The generic definition uses h2n/n2h to flip bytes. Feel free +// to declare specializations of Endian as appropriate. +// +// Note well that the address of an Endian is not an address-of-T, +// and there is no conversion available. +// +template +class Endian { +public: + typedef Type Value; + Endian() : mValue(0) { } + Endian(Value v) : mValue(h2n(v)) { } + + operator Value () const { return n2h(mValue); } + Endian &operator = (Value v) { mValue = h2n(v); return *this; } + +private: + Value mValue; +}; + +} // end namespace Security + + +#endif //_H_ENDIAN diff --git a/cdsa/cdsa_utilities/fdmover.cpp b/cdsa/cdsa_utilities/fdmover.cpp new file mode 100644 index 00000000..d686f388 --- /dev/null +++ b/cdsa/cdsa_utilities/fdmover.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// ip++ - C++ layer for IP socket and address management +// +// [Also see comments in header file.] +// +#include "fdmover.h" +#include +#include + + +namespace Security { +namespace IPPlusPlus { + + +void *FdMover::Element::operator new (size_t base, size_t more) +{ + Element *element = (Element *)::malloc(CMSG_SPACE(more)); + element->cmsg_len = CMSG_LEN(more); + return element; +} + +void FdMover::Element::operator delete (void *data, size_t base) +{ + ::free(data); +} + +FdMover::Element::Element(int level, int type) +{ + cmsg_level = level; + cmsg_type = type; +} + + +FdMover::Message::Message(const void *data, size_t length) + : iovec(data, length) +{ + msg_name = NULL; + msg_namelen = 0; + msg_iov = &iovec; + msg_iovlen = 1; + msg_control = NULL; + msg_controllen = 0; + msg_flags = 0; +} + +void FdMover::Message::set(Element *elem) +{ + msg_control = (caddr_t)elem; + msg_controllen = elem->cmsg_len; +} + + +size_t FdMover::send(const void *data, size_t length, const FdVector &fds) +{ + auto_ptr elem(new (fds.size() * sizeof(int)) Element (SOL_SOCKET, SCM_RIGHTS)); + copy(fds.begin(), fds.end(), &elem.get()->payload()); + Message msg(data, length); + msg.set(elem.get()); + ssize_t rc = ::sendmsg(fd(), &msg, 0); + checkError(rc); + return rc; +} + + +size_t FdMover::receive(void *data, size_t length, FdVector &fds) +{ + static const int maxFds = 20; // arbitrary limit + Message msg(data, length); + auto_ptr elem(new (maxFds * sizeof(int)) Element); + msg.set(elem.get()); + ssize_t rc = ::recvmsg(fd(), &msg, 0); + checkError(rc); + unsigned count = elem.get()->payloadSize() / sizeof(int); + FdVector result; + copy(&elem.get()->payload(), &elem.get()->payload() + count, back_inserter(result)); + swap(fds, result); + return rc; +} + + +} // end namespace IPPlusPlus +} // end namespace Security diff --git a/cdsa/cdsa_utilities/fdmover.h b/cdsa/cdsa_utilities/fdmover.h new file mode 100644 index 00000000..2d6a5b24 --- /dev/null +++ b/cdsa/cdsa_utilities/fdmover.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// fdmover - send/receive file descriptors over a UNIX domain socket connection +// +// An FdMover object is a very specialized Socket: +// It must be bound to a UNIX domain address +// +#ifndef _H_FDMOVER +#define _H_FDMOVER + +#include "ip++.h" +#include + +using namespace UnixPlusPlus; + + +namespace Security { +namespace IPPlusPlus { + + +// an ordered list of file descriptors +typedef std::vector FdVector; + + +// +// An FdMover - a specialized Socket for transferring file descriptors +// across UNIX domain sockets. +// +class FdMover : public Socket { +private: + class Element : public cmsghdr { + public: + void *operator new (size_t base, size_t more); + void operator delete (void *addr, size_t size); + + Element() { } + Element(int level, int type); + + template T &payload() { return *reinterpret_cast(CMSG_DATA(this)); } + size_t payloadSize() const { return cmsg_len - ((caddr_t)CMSG_DATA(this) - (caddr_t)this); } + }; + + class Message : public msghdr { + public: + Message(const void *data, size_t length); + void set(Element *elem); + Element *element() const { return (Element *)msg_control; } + Element *next(Element *elem) const { return (Element *)CMSG_NXTHDR(this, elem); } + + public: + IOVec iovec; + }; + +public: + FdMover() { } + FdMover(Socket s) : Socket(s) { } + + size_t send(const void *data, size_t length, const FdVector &fds); + size_t receive(void *data, size_t length, FdVector &fds); + +private: + +}; + + +} // end namespace IPPlusPlus +} // end namespace Security + + +#endif //_H_FDMOVER diff --git a/cdsa/cdsa_utilities/generator.pl b/cdsa/cdsa_utilities/generator.pl index 54b87a61..1b3fd9ad 100644 --- a/cdsa/cdsa_utilities/generator.pl +++ b/cdsa/cdsa_utilities/generator.pl @@ -10,8 +10,9 @@ $ERR_H="cssmerr.h"; $APPLE_ERR_H="cssmapple.h"; -$SOURCEDIR=$ARGV[0]; # directory with inputs -$TARGETDIR=$ARGV[1]; +$SOURCEDIR=$ARGV[0]; # directory with cdsa headers +$TARGETDIR=$ARGV[1]; # where to put the output file +@INPUTFILES=@ARGV[2 .. 9999]; # list of input files $TABLES="$TARGETDIR/errorcodes.gen"; # error name tables @@ -36,6 +37,17 @@ while ($name = shift @convertibles) { $convErrors[hex $value] = $name; }; + +# +# Read Keychain-level headers for more error codes (errSecBlahBlah) +# +open(ERR, "cat " . join(" ", @INPUTFILES) . "|") or die "Cannot open error header files"; +$/=undef; # still gulping +$_ = ; +@kcerrors = /err((?:Sec|Authorization)\w+)\s*=\s*-?\d+/gm; +close(ERR); + + # # Now we will generate the error name tables. # @@ -52,6 +64,9 @@ HDR foreach $name (@fullErrors) { print " { CSSMERR_$name, \"$name\" },\n"; }; +foreach $err (@kcerrors) { + print " { err$err, \"$err\" },\n"; +}; print <unlock below provides it for free - debug("nexus", "ModuleNexus %p constructed object 0x%x", this, pointer); } catch (...) { - debug("nexus", "ModuleNexus %p construction failed", this); + secdebug("nexus", "ModuleNexus %p construction failed", this); mutex->unlock(); if (--sync == 0) { delete mutex; diff --git a/cdsa/cdsa_utilities/globalizer.h b/cdsa/cdsa_utilities/globalizer.h index 793d779c..d709bd26 100644 --- a/cdsa/cdsa_utilities/globalizer.h +++ b/cdsa/cdsa_utilities/globalizer.h @@ -72,7 +72,11 @@ public: Type &operator () () { AtomicWord p = pointer; // latch pointer - return *reinterpret_cast((p && !(p & 0x1)) ? p : create(make)); + if (!p || (p & 0x1)) { + p = create(make); + secdebug("nexus", "module %s 0x%x", Debug::typeName().c_str(), pointer); + } + return *reinterpret_cast(p); } void reset() @@ -92,7 +96,7 @@ class CleanModuleNexus : public ModuleNexus { public: ~CleanModuleNexus() { - debug("nexus", "ModuleNexus %p destroyed object 0x%x", this, pointer); + secdebug("nexus", "ModuleNexus %p destroyed object 0x%x", this, pointer); delete reinterpret_cast(pointer); } }; @@ -127,7 +131,7 @@ class CleanModuleNexus : public ModuleNexus { public: ~CleanModuleNexus() { - debug("nexus", "ModuleNexus %p destroyed object 0x%x", this, mSingleton); + secdebug("nexus", "ModuleNexus %p destroyed object 0x%x", this, mSingleton); delete mSingleton; } }; diff --git a/cdsa/cdsa_utilities/handleobject.cpp b/cdsa/cdsa_utilities/handleobject.cpp index 1296eb4c..0d6e1a49 100644 --- a/cdsa/cdsa_utilities/handleobject.cpp +++ b/cdsa/cdsa_utilities/handleobject.cpp @@ -55,7 +55,7 @@ void HandleObject::State::make(HandleObject *obj) for (;;) { Handle handle = reinterpret_cast(obj) ^ (++sequence << 19); if (handleMap[handle] == NULL) { - debug("handleobj", "create 0x%lx for %p", handle, obj); + secdebug("handleobj", "create 0x%lx for %p", handle, obj); obj->setHandle(handle); handleMap[handle] = obj; return; diff --git a/cdsa/cdsa_utilities/headermap.cpp b/cdsa/cdsa_utilities/headermap.cpp index 47025649..4e87b1ff 100644 --- a/cdsa/cdsa_utilities/headermap.cpp +++ b/cdsa/cdsa_utilities/headermap.cpp @@ -21,6 +21,7 @@ // #include "headermap.h" #include +#include using namespace std; diff --git a/cdsa/cdsa_utilities/headermap.h b/cdsa/cdsa_utilities/headermap.h index fdc5fe22..10c414f4 100644 --- a/cdsa/cdsa_utilities/headermap.h +++ b/cdsa/cdsa_utilities/headermap.h @@ -84,4 +84,4 @@ private: } // end namespace Security -#endif _H_HEADERMAP +#endif /* _H_HEADERMAP */ diff --git a/cdsa/cdsa_utilities/hosts.cpp b/cdsa/cdsa_utilities/hosts.cpp index 4dd47c70..03ab46e2 100644 --- a/cdsa/cdsa_utilities/hosts.cpp +++ b/cdsa/cdsa_utilities/hosts.cpp @@ -124,7 +124,7 @@ NamedHost::NamedHost(const char *name) : mName(name) if (hostent *he = gethostbyname(name)) { for (char **p = he->h_addr_list; *p; p++) mAddrs.insert(*reinterpret_cast(*p)); - debug("ipname", "host %s resolves to %ld address(es)", mName.c_str(), mAddrs.size()); + secdebug("ipname", "host %s resolves to %ld address(es)", mName.c_str(), mAddrs.size()); return; } UnixError::throwMe(ENOENT); //@@@ h_errno translation or other source diff --git a/cdsa/cdsa_utilities/hosts.h b/cdsa/cdsa_utilities/hosts.h index 4ddfb5c4..10ea27aa 100644 --- a/cdsa/cdsa_utilities/hosts.h +++ b/cdsa/cdsa_utilities/hosts.h @@ -73,4 +73,4 @@ private: } // end namespace Security -#endif _H_HOSTS +#endif /* _H_HOSTS */ diff --git a/cdsa/cdsa_utilities/ip++.cpp b/cdsa/cdsa_utilities/ip++.cpp index 0bd8f3cc..537a35fe 100644 --- a/cdsa/cdsa_utilities/ip++.cpp +++ b/cdsa/cdsa_utilities/ip++.cpp @@ -104,26 +104,63 @@ IPSockAddress IPSockAddress::defaults(IPPort defaultPort) const } +// +// UNSockAddress +// +UNSockAddress::UNSockAddress() +{ + sun_family = AF_UNIX; +} + +UNSockAddress::UNSockAddress(const char *path) +{ + sun_family = AF_UNIX; + size_t length = strlen(path); + if (length >= sizeof(sun_path)) // won't fit into struct sockaddr_un + UnixError::throwMe(EINVAL); + memcpy(sun_path, path, length + 1); +} + +UNSockAddress::UNSockAddress(const string &path) +{ + sun_family = AF_UNIX; + if (path.length() >= sizeof(sun_path)) // won't fit into struct sockaddr_un + UnixError::throwMe(EINVAL); + memcpy(sun_path, path.c_str(), path.length() + 1); +} + + +string UNSockAddress::path() const +{ + return sun_path; +} + + // // Sockets // -Socket::Socket(int type, int protocol) +Socket::Socket(int type) +{ + open(type); +} + +Socket::Socket(int domain, int type, int protocol) { - open(type, protocol); + open(domain, type, protocol); } -void Socket::open(int type, int protocol) +void Socket::open(int domain, int type, int protocol) { - checkSetFd(::socket(AF_INET, type, protocol)); + checkSetFd(::socket(domain, type, protocol)); mAtEnd = false; - debug("sockio", "socket(%d,%d) -> %d", type, protocol, fd()); + secdebug("sockio", "socket(%d,%d) -> %d", type, protocol, fd()); } -void Socket::prepare(int fdFlags, int type, int protocol) +void Socket::prepare(int fdFlags, int domain, int type, int protocol) { // if file descriptor is closed, open it - otherwise take what's there if (!isOpen()) - open(type, protocol); + open(domain, type, protocol); // if flags were passed in, set them on the file descriptor now if (fdFlags) @@ -139,7 +176,13 @@ void Socket::bind(const IPAddress &addr, IPPort port) void Socket::bind(const IPSockAddress &local) { checkError(::bind(fd(), local, sizeof(local))); - IFDEBUG(debug("sockio", "%d bind to %s", fd(), string(local).c_str())); + secdebug("sockio", "%d bind to %s", fd(), string(local).c_str()); +} + +void Socket::bind(const UNSockAddress &local) +{ + checkError(::bind(fd(), local, sizeof(local))); + secdebug("sockio", "%d bind to %s", fd(), string(local).c_str()); } @@ -162,23 +205,30 @@ void Socket::accept(Socket &s, IPSockAddress &peer) assert(length == sizeof(IPSockAddress)); } +void Socket::accept(Socket &s, UNSockAddress &peer) +{ + int length = sizeof(UNSockAddress); + s.checkSetFd(::accept(fd(), peer, &length)); + assert(length == sizeof(UNSockAddress)); +} + bool Socket::connect(const IPSockAddress &peer) { if (::connect(fd(), peer, sizeof(peer))) { switch (errno) { case EINPROGRESS: - IFDEBUG(debug("sockio", "%d connecting to %s", fd(), string(peer).c_str())); + secdebug("sockio", "%d connecting to %s", fd(), string(peer).c_str()); return false; case EALREADY: if (int err = error()) // connect failed UnixError::throwMe(err); // just keep trying - IFDEBUG(debug("sockio", "%d still trying to connect", fd())); + secdebug("sockio", "%d still trying to connect", fd()); return false; case EISCONN: if (flags() & O_NONBLOCK) { - debug("sockio", "%d now connected", fd()); + secdebug("sockio", "%d now connected", fd()); return true; } else { UnixError::throwMe(); @@ -187,7 +237,7 @@ bool Socket::connect(const IPSockAddress &peer) UnixError::throwMe(); } } else { - IFDEBUG(debug("sockio", "%d connect to %s", fd(), string(peer).c_str())); + secdebug("sockio", "%d connect to %s", fd(), string(peer).c_str()); return true; } } @@ -197,6 +247,14 @@ bool Socket::connect(const IPAddress &addr, IPPort port) return connect(IPSockAddress(addr, port)); } +bool Socket::connect(const UNSockAddress &peer) +{ + // no nice async support here: local operation (but keep the niceties) + checkError(::connect(fd(), peer, sizeof(peer))); + secdebug("sockio", "%d connect to %s", fd(), string(peer).c_str()); + return true; +} + // void Socket::connect(const Host &host, ...): see below. @@ -225,12 +283,12 @@ IPSockAddress Socket::peerAddress() const return addr; } -void Socket::getOption(void *value, int &length, int name, int level = SOL_SOCKET) const +void Socket::getOption(void *value, int &length, int name, int level /*= SOL_SOCKET*/) const { UnixError::check(::getsockopt(fd(), level, name, value, &length)); } -void Socket::setOption(const void *value, int length, int name, int level = SOL_SOCKET) const +void Socket::setOption(const void *value, int length, int name, int level /*= SOL_SOCKET*/) const { UnixError::check(::setsockopt(fd(), level, name, value, length)); } @@ -250,7 +308,7 @@ void Socket::connect(const Host &host, IPPort port) for (set::const_iterator it = addrs.begin(); it != addrs.end(); it++) { const IPSockAddress address(*it, port); if (::connect(fd(), address, sizeof(IPSockAddress)) == 0) { - IFDEBUG(debug("sockio", "%d connect to %s", fd(), string(address).c_str())); + secdebug("sockio", "%d connect to %s", fd(), string(address).c_str()); return; } } @@ -267,19 +325,19 @@ void Socket::connect(const Host &host, IPPort port) // void TCPClientSocket::open(const IPSockAddress &peer, int fdFlags) { - prepare(fdFlags, SOCK_STREAM); + prepare(fdFlags, AF_INET, SOCK_STREAM); connect(peer); } void TCPClientSocket::open(const IPAddress &addr, IPPort port, int fdFlags) { - prepare(fdFlags, SOCK_STREAM); + prepare(fdFlags, AF_INET, SOCK_STREAM); connect(addr, port); } void TCPClientSocket::open(const Host &host, IPPort port, int fdFlags) { - prepare(fdFlags, SOCK_STREAM); + prepare(fdFlags, AF_INET, SOCK_STREAM); connect(host, port); } @@ -291,7 +349,7 @@ TCPClientSocket::~TCPClientSocket() void TCPServerSocket::open(const IPSockAddress &addr, int depth) { - prepare(0, SOCK_STREAM); + prepare(0, AF_INET, SOCK_STREAM); bind(addr); listen(depth); } diff --git a/cdsa/cdsa_utilities/ip++.h b/cdsa/cdsa_utilities/ip++.h index bfc105c6..56b99c5a 100644 --- a/cdsa/cdsa_utilities/ip++.h +++ b/cdsa/cdsa_utilities/ip++.h @@ -35,6 +35,7 @@ #include "timeflow.h" #include #include +#include #include #include #include @@ -112,6 +113,27 @@ public: }; +// +// UNIX Domain Socket addresses, for those who care. +// An "UNAddress", such as it were, is simply a string. +// +class UNSockAddress : public sockaddr_un { +public: + UNSockAddress(); + UNSockAddress(const char *path); + UNSockAddress(const std::string &path); + + string path() const; + operator string () const { return path(); } + + // automatically convert to struct sockaddr * for use in system calls + operator struct sockaddr * () + { return reinterpret_cast(this); } + operator const struct sockaddr * () const + { return reinterpret_cast(this); } +}; + + // // An IP socket. // This inherits all functionality of a FileDesc, so I/O is fun and easy. @@ -123,21 +145,27 @@ public: class Socket : public FileDesc { public: Socket() { } - explicit Socket(int type, int protocol = 0); + explicit Socket(int domain, int type, int protocol = 0); + explicit Socket(int type); Socket &operator = (int fd) { setFd(fd); return *this; } // basic open (socket system call) - void open(int type, int protocol = 0); + void open(int domain, int type, int protocol = 0); + void open(int type) { open(AF_INET, type, 0); } // standard socket operations void bind(const IPSockAddress &addr); // to this socket address void bind(const IPAddress &addr = IPAddress::any, IPPort port = 0); + void bind(const UNSockAddress &addr); // to this UNIX domain socket void listen(int backlog = 1); void accept(Socket &s); void accept(Socket &s, IPSockAddress &peer); + void accept(Socket &s, UNSockAddress &peer); + bool connect(const struct sockaddr *peer); bool connect(const IPSockAddress &peer); bool connect(const IPAddress &addr, IPPort port); + bool connect(const UNSockAddress &peer); void connect(const Host &host, IPPort port); // any address of this host void shutdown(int type); enum { shutdownRead = 0, shutdownWrite = 1, shutdownBoth = 2 }; @@ -173,7 +201,7 @@ public: #endif protected: - void prepare(int fdFlags, int type, int protocol = 0); + void prepare(int fdFlags, int domain, int type, int protocol = 0); }; diff --git a/cdsa/cdsa_utilities/ktracecodes.h b/cdsa/cdsa_utilities/ktracecodes.h new file mode 100644 index 00000000..816a27ce --- /dev/null +++ b/cdsa/cdsa_utilities/ktracecodes.h @@ -0,0 +1,120 @@ +#ifndef _KTRACE_CODES_H_ +#define _KTRACE_CODES_H_ + +#include +#include + +/* + we format as follows (not really done this way because bitfields are compiler dependent): + + struct DebugCode + { + int DebugClass : 8; + int SubClass : 8; + int SecurityAppClass : 4; + int SecurityCodeClass : 10; + int FunctionQualifier : 2; + }; +*/ + +// Define the following as macros to keep objective c happy. + +// define app class constants +#define APP_DEBUG_CLASS 0x40 + +// define the sub class for security +#define SECURITY_SUB_CLASS 0xAA + +// define the app classes used by security +#define APP_CLASS_SFAUTHORIZATION 0 +#define APP_CLASS_SECURITY_AGENT 1 +#define APP_CLASS_AUTHORIZATION 2 +#define APP_CLASS_SECURITY_SERVER 3 +#define APP_CLASS_ADHOC 4 + +// define function qualifiers +#define FUNCTION_START DBG_FUNC_START +#define FUNCTION_END DBG_FUNC_END +#define FUNCTION_TIMEPOINT DBG_FUNC_NONE + +// define SFAuthorization code class +#define CODE_CLASS_SFAUTHORIZATION_BUTTON_PRESSED 0 +#define CODE_CLASS_SFAUTHORIZATION_AUTHORIZATION 1 + +// define SecurityAgent code class +#define CODE_CLASS_SECURITY_AGENT_START 0 +#define CODE_CLASS_SECURITY_AGENT_STARTED_BY_SECURITY_SERVER 1 +#define CODE_CLASS_SECURITY_AGENT_BEFORE_MECHANISM_INVOKE 2 +#define CODE_CLASS_SECURITY_AGENT_CONFIRM_ACCESS 3 + +// define Authorization code classes +#define CODE_CLASS_AUTHORIZATION_CREATE 0 +#define CODE_CLASS_AUTHORIZATION_COPY_RIGHTS 1 +#define CODE_CLASS_AUTHORIZATION_COPY_INFO 2 + +// define SecurityServer code classes +#define CODE_CLASS_SECURITY_SERVER_INITIALIZE 0 + +// define adhoc code classes (may change by need) +#define CODE_CLASS_ADHOC_FINDGENERICPASSWORD_BEGIN 0 +#define CODE_CLASS_ADHOC_UCSP_CLIENT_BEGIN 1 +#define CODE_CLASS_ADHOC_UCSP_SERVER_DECRYPT_BEGIN 2 +#define CODE_CLASS_ADHOC_UCSP_QUERYKEYCHAINACCESS_BEGIN 3 + +// define SecurityServer code classes +#define TRACECODE(_debugclass, _subclass, _appclass, _codeclass, _functionqualifier) \ + ((_debugclass << 24) | (_subclass << 16) | (_appclass << 12) | (_codeclass << 2) | (_functionqualifier)) + +/* + * Trace code allocations. + */ + enum { + kSecTraceSFAuthorizationButtonPressedStart = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SFAUTHORIZATION, CODE_CLASS_SFAUTHORIZATION_BUTTON_PRESSED, FUNCTION_START), + kSecTraceSFAuthorizationAuthorizationStart = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SFAUTHORIZATION, CODE_CLASS_SFAUTHORIZATION_AUTHORIZATION, FUNCTION_START), + kSecTraceSFAuthorizationAuthorizationEnd = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SFAUTHORIZATION, CODE_CLASS_SFAUTHORIZATION_AUTHORIZATION, FUNCTION_END), + kSecTraceSFAuthorizationButtonPressedEnd = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SFAUTHORIZATION, CODE_CLASS_SFAUTHORIZATION_BUTTON_PRESSED, FUNCTION_END), + + kSecTraceSecurityAgentStart = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SECURITY_AGENT, CODE_CLASS_SECURITY_AGENT_START, FUNCTION_TIMEPOINT), + kSecTraceSecurityAgentStartedBySecurityServer = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SECURITY_AGENT, CODE_CLASS_SECURITY_AGENT_STARTED_BY_SECURITY_SERVER, + FUNCTION_TIMEPOINT), + kSecTraceSecurityAgentBeforeMechanismInvoke = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SECURITY_AGENT, CODE_CLASS_SECURITY_AGENT_BEFORE_MECHANISM_INVOKE, + FUNCTION_TIMEPOINT), + kSecTraceSecurityAgentConfimAccess = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SECURITY_AGENT, CODE_CLASS_SECURITY_AGENT_CONFIRM_ACCESS, FUNCTION_TIMEPOINT), + + kSecTraceAuthorizationCreateStart = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_AUTHORIZATION, CODE_CLASS_AUTHORIZATION_CREATE, FUNCTION_START), + kSecTraceAuthorizationCreateEnd = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_AUTHORIZATION, CODE_CLASS_AUTHORIZATION_CREATE, FUNCTION_END), + kSecTraceAuthorizationCopyRightsStart = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_AUTHORIZATION, CODE_CLASS_AUTHORIZATION_COPY_RIGHTS, FUNCTION_START), + kSecTraceAuthorizationCopyRightsEnd = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_AUTHORIZATION, CODE_CLASS_AUTHORIZATION_COPY_RIGHTS, FUNCTION_END), + kSecTraceAuthorizationCopyInfoStart = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_AUTHORIZATION, CODE_CLASS_AUTHORIZATION_COPY_INFO, FUNCTION_START), + kSecTraceAuthorizationCopyInfoEnd = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_AUTHORIZATION, CODE_CLASS_AUTHORIZATION_COPY_INFO, FUNCTION_END), + + kSecTraceSecurityServerStart = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SECURITY_SERVER, CODE_CLASS_SECURITY_SERVER_INITIALIZE, FUNCTION_START), + kSecTraceSecurityServerInitialized = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_SECURITY_SERVER, CODE_CLASS_SECURITY_SERVER_INITIALIZE, FUNCTION_END), + + kSecTraceSecurityFrameworkSecKeychainFindGenericPasswordBegin = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_ADHOC, CODE_CLASS_ADHOC_FINDGENERICPASSWORD_BEGIN, FUNCTION_TIMEPOINT), + kSecTraceUCSPClientDecryptBegin = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_ADHOC, CODE_CLASS_ADHOC_UCSP_CLIENT_BEGIN, FUNCTION_TIMEPOINT), + kSecTraceUCSPServerDecryptBegin = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_ADHOC, CODE_CLASS_ADHOC_UCSP_SERVER_DECRYPT_BEGIN, FUNCTION_TIMEPOINT), + kSecTraceSecurityServerQueryKeychainAccess = + TRACECODE (APP_DEBUG_CLASS, SECURITY_SUB_CLASS, APP_CLASS_ADHOC, CODE_CLASS_ADHOC_UCSP_QUERYKEYCHAINACCESS_BEGIN, FUNCTION_TIMEPOINT) + }; + +#endif /* _KTRACE_CODES_H_ */ diff --git a/cdsa/cdsa_utilities/logging.cpp b/cdsa/cdsa_utilities/logging.cpp index 7628b1bd..ed2d5c76 100644 --- a/cdsa/cdsa_utilities/logging.cpp +++ b/cdsa/cdsa_utilities/logging.cpp @@ -37,7 +37,7 @@ namespace Syslog // // Open and initialize logging // -void open(const char *ident, int facility, int options = 0) +void open(const char *ident, int facility, int options /*= 0*/) { ::openlog(ident, options, facility); } diff --git a/cdsa/cdsa_utilities/mach++.cpp b/cdsa/cdsa_utilities/mach++.cpp index 4b747046..9758c560 100644 --- a/cdsa/cdsa_utilities/mach++.cpp +++ b/cdsa/cdsa_utilities/mach++.cpp @@ -29,6 +29,9 @@ namespace Security { namespace MachPlusPlus { +// +// Mach subsystem exceptions, a subclass of CssmCommonError +// Error::Error(kern_return_t err) : error(err) { } @@ -83,7 +86,7 @@ void Error::debugDiagnose(const void *id) const case BOOTSTRAP_SERVICE_ACTIVE: name = "BOOTSTRAP_SERVICE_ACTIVE"; break; } - debug("exception", "%p Mach Error %s (%d) osStatus %ld", + secdebug("exception", "%p Mach Error %s (%d) osStatus %ld", id, name, error, osStatus()); } #endif //NDEBUG @@ -114,12 +117,29 @@ mach_port_urefs_t Port::getRefs(mach_port_right_t right) check(::mach_port_get_refs(self(), mPort, right, &count)); return count; } + mach_port_t Port::requestNotify(mach_port_t notify, mach_msg_id_t type, mach_port_mscount_t sync) { mach_port_t previous; check(mach_port_request_notification(self(), mPort, type, sync, notify, MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous)); - debug("port", "%d request notify(%d) to %d (sync=%d)", port(), type, notify, sync); + +#if !defined(NDEBUG) + const char *typeName; + switch (type) { + case MACH_NOTIFY_PORT_DELETED: typeName = "port deleted"; break; + case MACH_NOTIFY_PORT_DESTROYED:typeName = "port destroyed"; break; + case MACH_NOTIFY_NO_SENDERS: typeName = "no senders"; break; + case MACH_NOTIFY_SEND_ONCE: typeName = "send once"; break; + case MACH_NOTIFY_DEAD_NAME: typeName = "dead name"; break; + default: typeName = "???"; break; + } + if (notify == MACH_PORT_NULL) + secdebug("port", "%d cancel notify %s", port(), typeName); + else + secdebug("port", "%d request notify %s to %d (sync %d)", port(), typeName, notify, sync); +#endif //!NDEBUG + return previous; } @@ -129,7 +149,6 @@ mach_port_t Port::cancelNotify(mach_msg_id_t type) // (EVEN if the DPN has already been sent!) So just ignore that case... if (isDead()) return MACH_PORT_NULL; - debug("port", "%d cancel DPN", port()); return requestNotify(MACH_PORT_NULL, type); } @@ -196,7 +215,7 @@ mach_port_t Bootstrap::checkInOptional(const char *name) const case BOOTSTRAP_SERVICE_ACTIVE: case BOOTSTRAP_UNKNOWN_SERVICE: case BOOTSTRAP_NOT_PRIVILEGED: - return 0; + return MACH_PORT_NULL; default: check(err); } @@ -205,7 +224,7 @@ mach_port_t Bootstrap::checkInOptional(const char *name) const void Bootstrap::registerAs(mach_port_t port, const char *name) const { - debug("bootstrap", "creating service port %d in %d:%s", port, this->port(), name); + secdebug("bootstrap", "creating service port %d in %d:%s", port, this->port(), name); check(::bootstrap_register(mPort, makeName(name), port)); } @@ -263,13 +282,13 @@ StBootstrap::StBootstrap(const Bootstrap &newBoot, const TaskPort &task) { mOldBoot = Bootstrap(); mTask.bootstrap(newBoot); - debug("StBoot", "bootstrap for %d switched to %d", mTask.port(), newBoot.port()); + secdebug("StBoot", "bootstrap for %d switched to %d", mTask.port(), newBoot.port()); } StBootstrap::~StBootstrap() { mTask.bootstrap(mOldBoot); - debug("StBoot", "bootstrap for %d returned to %d", mTask.port(), mOldBoot.port()); + secdebug("StBoot", "bootstrap for %d returned to %d", mTask.port(), mOldBoot.port()); } diff --git a/cdsa/cdsa_utilities/machrunloopserver.cpp b/cdsa/cdsa_utilities/machrunloopserver.cpp index 3a621a21..cf860dbf 100644 --- a/cdsa/cdsa_utilities/machrunloopserver.cpp +++ b/cdsa/cdsa_utilities/machrunloopserver.cpp @@ -83,10 +83,10 @@ void MachRunLoopServer::blockNewRequests(bool block) { if (block) { CFRunLoopRemoveSource(runLoop, runLoopSource, kCFRunLoopDefaultMode); - debug("machsrv", "disabled request reception"); + secdebug("machsrv", "disabled request reception"); } else { CFRunLoopAddSource(runLoop, runLoopSource, kCFRunLoopDefaultMode); - debug("machsrv", "enabled request reception"); + secdebug("machsrv", "enabled request reception"); } } @@ -101,7 +101,7 @@ void MachRunLoopServer::alsoListenOn(Port port) CFRef source = CFMachPortCreateRunLoopSource(NULL, cfPort, 10); //@@@ no idea what order is good CFRunLoopAddSource(runLoop, source, kCFRunLoopDefaultMode); - debug("machsrv", "also receiving from port %d", port.port()); + secdebug("machsrv", "also receiving from port %d", port.port()); } void MachRunLoopServer::stopListenOn(Port port) @@ -111,7 +111,7 @@ void MachRunLoopServer::stopListenOn(Port port) CFRef source = CFMachPortCreateRunLoopSource(NULL, cfPort, 10); //@@@ no idea what order is good CFRunLoopRemoveSource(runLoop, source, kCFRunLoopDefaultMode); - debug("machsrv", "no longer receiving from port %d", port.port()); + secdebug("machsrv", "no longer receiving from port %d", port.port()); } @@ -125,7 +125,10 @@ void MachRunLoopServer::notifyIfDead(Port port) const //@@@ not clear how to deal with CFRetainCount of cfPort here // will CF clean up the cfPort when it dies? Or do we have to keep a set? CFMachPortRef cfPort = CFMachPortCreateWithPort(NULL, port, NULL, NULL, NULL); - CFMachPortSetInvalidationCallBack(cfPort, cfInvalidateCallback); + if (cfPort != NULL) // check to make sure that we got a valid port reference back + { + CFMachPortSetInvalidationCallBack(cfPort, cfInvalidateCallback); + } } void MachRunLoopServer::cfInvalidateCallback(CFMachPortRef cfPort, void *) @@ -147,20 +150,20 @@ void MachRunLoopServer::oneRequest(mach_msg_header_t *request) if (!handle(request, replyBuffer)) { // MIG dispatch did not recognize the request. Ignore/Retry/Fail? :-) //@@@ Should send an error reply back here, I suppose. Later... - debug("machrls", "MachRunLoopServer dispatch failed"); + secdebug("machrls", "MachRunLoopServer dispatch failed"); return; } // MIG dispatch handled the call. Send reply back to caller. // This boilerplate stolen from mach_msg_server, since MIG can't seem to // generate send-only code for replies (without explicit simpleroutines). - if (kern_return_t err = mach_msg_overwrite(replyBuffer, + if (IFDEBUG(kern_return_t err =) mach_msg_overwrite(replyBuffer, (MACH_MSGH_BITS_REMOTE(replyBuffer->msgh_bits) == MACH_MSG_TYPE_MOVE_SEND_ONCE) ? MACH_SEND_MSG : MACH_SEND_MSG|MACH_SEND_TIMEOUT, replyBuffer->msgh_size, 0, MACH_PORT_NULL, 0, MACH_PORT_NULL, (mach_msg_header_t *) 0, 0)) { //@@@ should at least clean up resources here, I suppose. - debug("machsrv", "RunloopServer cannot post reply: %s", mach_error_string(err)); + secdebug("machsrv", "RunloopServer cannot post reply: %s", mach_error_string(err)); active().releaseDeferredAllocations(); return; } diff --git a/cdsa/cdsa_utilities/machserver.cpp b/cdsa/cdsa_utilities/machserver.cpp index 68598cad..80db1fd5 100644 --- a/cdsa/cdsa_utilities/machserver.cpp +++ b/cdsa/cdsa_utilities/machserver.cpp @@ -58,7 +58,7 @@ MachServer::MachServer(const char *name, const Bootstrap &boot) void MachServer::setup(const char *name) { - debug("machsrv", "%p preparing service for \"%s\"", this, name); + secdebug("machsrv", "%p preparing service for \"%s\"", this, name); workerTimeout = 60 * 2; // 2 minutes default timeout maxWorkerCount = 100; // sanity check limit @@ -69,7 +69,7 @@ MachServer::~MachServer() { // The ReceivePort members will clean themselves up. // The bootstrap server will clear us from its map when our receive port dies. - debug("machsrv", "%p destroyed", this); + secdebug("machsrv", "%p destroyed", this); } @@ -80,13 +80,13 @@ MachServer::~MachServer() // void MachServer::add(Port receiver) { - debug("machsrv", "adding port %d to primary dispatch", receiver.port()); + secdebug("machsrv", "adding port %d to primary dispatch", receiver.port()); mPortSet += receiver; } void MachServer::remove(Port receiver) { - debug("machsrv", "removing port %d from primary dispatch", receiver.port()); + secdebug("machsrv", "removing port %d from primary dispatch", receiver.port()); mPortSet -= receiver; } @@ -159,7 +159,7 @@ void MachServer::runServerThread(bool doTimeout) // all exits from runServerThread are through exceptions try { // register as a worker thread - debug("machsrv", "%p starting service on port %d", this, int(mServerPort)); + secdebug("machsrv", "%p starting service on port %d", this, int(mServerPort)); perThread().server = this; for (;;) { @@ -175,13 +175,13 @@ void MachServer::runServerThread(bool doTimeout) // perform self-timeout processing if (doTimeout) { if (workerCount > maxWorkerCount) { - debug("machsrv", "%p too many threads; reaping immediately", this); + secdebug("machsrv", "%p too many threads; reaping immediately", this); break; } Time::Absolute rightNow = Time::now(); if (rightNow >= nextCheckTime) { // reaping period complete; process uint32 idlers = leastIdleWorkers; - debug("machsrv", "%p end of reaping period: %ld (min) idle of %ld total", + secdebug("machsrv", "%p end of reaping period: %ld (min) idle of %ld total", this, idlers, workerCount); nextCheckTime = rightNow + workerTimeout; leastIdleWorkers = INT_MAX; @@ -248,7 +248,7 @@ void MachServer::runServerThread(bool doTimeout) } else { // normal request message { StLock _(managerLock); idleCount--; } - debug("machsrvreq", + secdebug("machsrvreq", "servicing port %d request id=%d", bufRequest.localPort().port(), bufRequest.msgId()); @@ -265,7 +265,7 @@ void MachServer::runServerThread(bool doTimeout) handle(bufRequest, bufReply); } - debug("machsrvreq", "request complete"); + secdebug("machsrvreq", "request complete"); { StLock _(managerLock); idleCount++; } } @@ -314,11 +314,11 @@ void MachServer::runServerThread(bool doTimeout) } } perThread().server = NULL; - debug("machsrv", "%p ending service on port %d", this, int(mServerPort)); + secdebug("machsrv", "%p ending service on port %d", this, int(mServerPort)); } catch (...) { perThread().server = NULL; - debug("machsrv", "%p aborted by exception (port %d)", this, int(mServerPort)); + secdebug("machsrv", "%p aborted by exception (port %d)", this, int(mServerPort)); throw; } } @@ -367,7 +367,7 @@ void MachServer::releaseWhenDone(CssmAllocator &alloc, void *memory) if (memory) { set &releaseSet = perThread().deferredAllocations; assert(releaseSet.find(Allocation(memory, alloc)) == releaseSet.end()); - debug("machsrvmem", "%p register %p for release with %p", + secdebug("machsrvmem", "%p register %p for release with %p", this, memory, &alloc); releaseSet.insert(Allocation(memory, alloc)); } @@ -385,7 +385,7 @@ void MachServer::releaseDeferredAllocations() { set &releaseSet = perThread().deferredAllocations; for (set::iterator it = releaseSet.begin(); it != releaseSet.end(); it++) { - debug("machsrvmem", "%p release %p with %p", this, it->addr, it->allocator); + secdebug("machsrvmem", "%p release %p with %p", this, it->addr, it->allocator); it->allocator->free(it->addr); } releaseSet.erase(releaseSet.begin(), releaseSet.end()); @@ -425,7 +425,7 @@ void MachServer::addThread(Thread *thread) StLock _(managerLock); workerCount++; idleCount++; - debug("machsrv", "%p adding worker thread (%ld workers, %ld idle)", + secdebug("machsrv", "%p adding worker thread (%ld workers, %ld idle)", this, workerCount, idleCount); workers.insert(thread); } @@ -435,7 +435,7 @@ void MachServer::removeThread(Thread *thread) StLock _(managerLock); workerCount--; idleCount--; - debug("machsrv", "%p removing worker thread (%ld workers, %ld idle)", + secdebug("machsrv", "%p removing worker thread (%ld workers, %ld idle)", this, workerCount, idleCount); workers.erase(thread); } @@ -451,13 +451,13 @@ bool MachServer::processTimer() if (!(top = static_cast(timers.pop(Time::now())))) return false; // nothing (more) to be done now } // drop lock; work has been retrieved - debug("machsrvtime", "%p timer %p executing at %.3f", + secdebug("machsrvtime", "%p timer %p executing at %.3f", this, top, Time::now().internalForm()); try { top->action(); - debug("machsrvtime", "%p timer %p done", this, top); + secdebug("machsrvtime", "%p timer %p done", this, top); } catch (...) { - debug("machsrvtime", "%p server timer %p failed with exception", this, top); + secdebug("machsrvtime", "%p server timer %p failed with exception", this, top); } return true; } diff --git a/cdsa/cdsa_utilities/memstreams.h b/cdsa/cdsa_utilities/memstreams.h new file mode 100644 index 00000000..8b3bb4cf --- /dev/null +++ b/cdsa/cdsa_utilities/memstreams.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2000-2003 Apple Computer, Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// memstreams - primitive memory block streaming support +// +#ifndef _H_MEMSTREAMS +#define _H_MEMSTREAMS + +#include +#include + + +namespace Security +{ + +// +// Encapsulate these very sharp tools in a separate namespace +// +namespace LowLevelMemoryUtilities +{ + + +// +// A simple utility for incremental creation of a contiguous memory block. +// +// Note that Writer and Writer::Counter go together. They use the same alignment +// and padding rules, so Writer::Counter will correctly calculate total buffer +// size for Writer, *presuming* that they are called in the same order. +// +// This layer allocates no memory; that's up to the caller (you). +// +// WARNING: There is no check for overflow. If you write too much, you will die. +// Writer::Counter can tell you how much you need. +// +class Writer { +private: + void *advance(size_t size) + { + void *here = alignUp(writePos); + writePos = increment(here, size); + return here; + } + +public: + Writer() { } + Writer(void *base) : writePos(base) { } + void operator = (void *base) { writePos = base; } + + template + T *operator () (const T &obj) + { T *here = (T *)advance(sizeof(T)); *here = obj; return here; } + + void *operator () (const void *addr, size_t size) + { void *here = advance(size); return memcpy(here, addr, size); } + + char *operator () (const char *s) + { return (char *)(*this)(s, strlen(s) + 1); } + + void countedData(const void *data, uint32 length) + { Endian temp = length; (*this)(temp); (*this)(data, length); } + + template + void countedData(const Data &data) + { countedData(data.data(), data.length()); } + + class Counter; + +private: + void *writePos; // next byte address +}; + +class Writer::Counter { +private: + void align() { totalSoFar = alignUp(totalSoFar); } + +public: + Counter() : totalSoFar(0) { } + operator size_t () { return totalSoFar; } + + template size_t operator () (const T &) { align(); return totalSoFar += sizeof(T); } + size_t insert(size_t size) { align(); return totalSoFar += size; } + size_t operator () (const char *s) { align(); return totalSoFar += strlen(s) + 1; } + + void countedData(const void *, uint32 length) + { insert(sizeof(uint32)); insert(length); } + + template + void countedData(const Data &data) + { countedData(data.data(), data.length()); } + +private: + size_t totalSoFar; // total size counted so far +}; + + +// +// The Reader counter-part for a Writer. +// Again, Reader and Writer share alignment and representation rules, so what was +// Written shall be Read again, just fine. +// +class Reader { +private: + const void *advance(size_t size = 0) + { + const void *here = alignUp(readPos); + readPos = increment(here, size); + return here; + } + +public: + Reader() { } + Reader(const void *base) : readPos(base) { } + void operator = (const void *base) { readPos = base; } + + template + void operator () (T &obj) { obj = *reinterpret_cast(advance(sizeof(T))); } + void operator () (void *addr, size_t size) { memcpy(addr, advance(size), size); } + void operator () (const char * &s) + { s = reinterpret_cast(advance()); advance(strlen(s) + 1); } + template + const T *get(size_t size) + { return reinterpret_cast(advance(size)); } + + void countedData(const void * &data, uint32 &length) + { Endian temp; (*this)(temp); length = temp; data = advance(length); } + +private: + // Explicitly forbid some invocations that are likely to be wrong. + void operator () (char * &s); // can't get writable string in-place + +private: + const void *readPos; // next byte address +}; + + +} // end namespace LowLevelMemoryUtilities + +} // end namespace Security + +#endif //_H_MEMUTILS diff --git a/cdsa/cdsa_utilities/memutils.h b/cdsa/cdsa_utilities/memutils.h index aaea469d..ff7e10ad 100644 --- a/cdsa/cdsa_utilities/memutils.h +++ b/cdsa/cdsa_utilities/memutils.h @@ -27,11 +27,6 @@ #include -#ifdef _CPP_MEMUTILS -# pragma export on -#endif - - namespace Security { @@ -108,122 +103,8 @@ inline ptrdiff_t difference(const void *p1, const void *p2) { return PointerInt(p1) - PointerInt(p2); } -// -// A simple utility for incremental creation of a contiguous memory block. -// -// Note that Writer and Writer::Counter go together. They use the same alignment -// and padding rules, so Writer::Counter will correctly calculate total buffer -// size for Writer, *presuming* that they are called in the same order. -// -// WARNING: There is no check for overflow. If you write too much, you will die. -// -class Writer { -private: - void *advance(size_t size) - { - void *here = alignUp(writePos); - writePos = increment(here, size); - return here; - } - -public: - Writer() { } - Writer(void *base) : writePos(base) { } - void operator = (void *base) { writePos = base; } - - template - T *operator () (const T &obj) - { T *here = (T *)advance(sizeof(T)); *here = obj; return here; } - - void *operator () (const void *addr, size_t size) - { void *here = advance(size); return memcpy(here, addr, size); } - - char *operator () (const char *s) - { return (char *)(*this)(s, strlen(s) + 1); } - - void countedData(const void *data, uint32 length) - { (*this)(length); (*this)(data, length); } - - template - void countedData(const Data &data) - { countedData(data.data(), data.length()); } - - class Counter; - -private: - void *writePos; // next byte address -}; - -class Writer::Counter { -private: - void align() { totalSoFar = alignUp(totalSoFar); } - -public: - Counter() : totalSoFar(0) { } - operator size_t () { return totalSoFar; } - - template size_t operator () (const T &) { align(); return totalSoFar += sizeof(T); } - size_t insert(size_t size) { align(); return totalSoFar += size; } - size_t operator () (const char *s) { align(); return totalSoFar += strlen(s) + 1; } - - void countedData(const void *, uint32 length) - { insert(sizeof(uint32)); insert(length); } - - template - void countedData(const Data &data) - { countedData(data.data(), data.length()); } - -private: - size_t totalSoFar; // total size counted so far -}; - - -// -// The Reader counter-part for a Writer. -// Again, Reader and Writer share alignment and representation rules, so what was -// Written shall be Read again, just fine. -// -class Reader { -private: - const void *advance(size_t size = 0) - { - const void *here = alignUp(readPos); - readPos = increment(here, size); - return here; - } - -public: - Reader() { } - Reader(const void *base) : readPos(base) { } - void operator = (const void *base) { readPos = base; } - - template - void operator () (T &obj) { obj = *reinterpret_cast(advance(sizeof(T))); } - void operator () (void *addr, size_t size) { memcpy(addr, advance(size), size); } - void operator () (const char * &s) - { s = reinterpret_cast(advance()); advance(strlen(s) + 1); } - template - const T *get(size_t size) - { return reinterpret_cast(advance(size)); } - - void countedData(const void * &data, uint32 &length) - { (*this)(length); data = advance(length); } - -private: - // Explicitly forbid some invocations that are likely to be wrong. - void operator () (char * &s); // can't get writable string in-place - -private: - const void *readPos; // next byte address -}; - - } // end namespace LowLevelMemoryUtilities } // end namespace Security -#ifdef _CPP_MEMUTILS -# pragma export off -#endif - #endif //_H_MEMUTILS diff --git a/cdsa/cdsa_utilities/osxsigning.cpp b/cdsa/cdsa_utilities/osxsigning.cpp index 4a9ec8e9..7401bb15 100644 --- a/cdsa/cdsa_utilities/osxsigning.cpp +++ b/cdsa/cdsa_utilities/osxsigning.cpp @@ -63,7 +63,7 @@ void OSXCode::scanFile(const char *pathname, Signer::State &state) UnixError::throwMe(); // scan it - debug("codesign", "scanning file %s (%ld bytes)", pathname, long(st.st_size)); + secdebug("codesign", "scanning file %s (%ld bytes)", pathname, long(st.st_size)); state.enumerateContents(p, st.st_size); // unmap it (ignore error) @@ -147,7 +147,13 @@ OSXCode *OSXCode::at(const char *path) UnixError::throwMe(); if ((st.st_mode & S_IFMT) == S_IFDIR) { // directory - assume bundle return new GenericBundle(path); - } else { // not directory - assume tool + } else { + // look for .../Contents/MacOS/ + if (const char *slash = strrchr(path, '/')) + if (const char *contents = strstr(path, "/Contents/MacOS/")) + if (contents + 15 == slash) + return new GenericBundle(string(path).substr(0, contents-path).c_str()); + // assume tool (single executable) return new ExecutableTool(path); } } @@ -224,12 +230,12 @@ void LoadableBundle::load() { if (!CFBundleLoadExecutable(mBundle)) CssmError::throwMe(CSSMERR_CSSM_ADDIN_LOAD_FAILED); - IFDEBUG(debug("bundle", "%p (%s) loaded", this, path().c_str())); + secdebug("bundle", "%p (%s) loaded", this, path().c_str()); } void LoadableBundle::unload() { - IFDEBUG(debug("bundle", "%p (%s) unloaded", this, path().c_str())); + secdebug("bundle", "%p (%s) unloaded", this, path().c_str()); CFBundleUnloadExecutable(mBundle); } diff --git a/cdsa/cdsa_utilities/powerwatch.cpp b/cdsa/cdsa_utilities/powerwatch.cpp index daef9eb4..69d6dd67 100644 --- a/cdsa/cdsa_utilities/powerwatch.cpp +++ b/cdsa/cdsa_utilities/powerwatch.cpp @@ -53,38 +53,38 @@ void PowerWatcher::ioCallback(void *refCon, io_service_t service, enum { allow, refuse, ignore } reaction; switch (messageType) { case kIOMessageSystemWillSleep: - debug("powerwatch", "system will sleep"); + secdebug("powerwatch", "system will sleep"); me->systemWillSleep(); reaction = allow; break; case kIOMessageSystemHasPoweredOn: - debug("powerwatch", "system has powered on"); + secdebug("powerwatch", "system has powered on"); me->systemIsWaking(); reaction = ignore; break; case kIOMessageSystemWillPowerOff: - debug("powerwatch", "system will power off"); + secdebug("powerwatch", "system will power off"); me->systemWillPowerDown(); reaction = allow; break; case kIOMessageSystemWillNotPowerOff: - debug("powerwatch", "system will not power off"); + secdebug("powerwatch", "system will not power off"); reaction = ignore; break; case kIOMessageCanSystemSleep: - debug("powerwatch", "can system sleep"); + secdebug("powerwatch", "can system sleep"); reaction = allow; break; case kIOMessageSystemWillNotSleep: - debug("powerwatch", "system will not sleep"); + secdebug("powerwatch", "system will not sleep"); reaction = ignore; break; case kIOMessageCanSystemPowerOff: - debug("powerwatch", "can system power off"); + secdebug("powerwatch", "can system power off"); reaction = allow; break; default: - debug("powerwatch", + secdebug("powerwatch", "type 0x%x message received (ignored)", messageType); reaction = ignore; break; @@ -93,15 +93,15 @@ void PowerWatcher::ioCallback(void *refCon, io_service_t service, // handle acknowledgments switch (reaction) { case allow: - debug("powerwatch", "calling IOAllowPowerChange"); + secdebug("powerwatch", "calling IOAllowPowerChange"); IOAllowPowerChange(me->mKernelPort, long(argument)); break; case refuse: - debug("powerwatch", "calling IOCancelPowerChange"); + secdebug("powerwatch", "calling IOCancelPowerChange"); IOCancelPowerChange(me->mKernelPort, long(argument)); break; case ignore: - debug("powerwatch", "sending no response"); + secdebug("powerwatch", "sending no response"); break; } } diff --git a/cdsa/cdsa_utilities/selector.cpp b/cdsa/cdsa_utilities/selector.cpp index 4e2dbfb2..da59de69 100644 --- a/cdsa/cdsa_utilities/selector.cpp +++ b/cdsa/cdsa_utilities/selector.cpp @@ -53,7 +53,7 @@ void Selector::add(int fd, Client &client, Type type) assert(!client.isActive()); // one Selector per client, and no re-adding assert(fd >= 0); - debug("selector", "add client %p fd %d type=%d", &client, fd, type); + secdebug("selector", "add client %p fd %d type=%d", &client, fd, type); // grow FDSets if needed unsigned int pos = fd / NFDBITS; @@ -92,7 +92,7 @@ void Selector::remove(int fd) assert(it != clientMap.end()); assert(it->second->mSelector == this); - debug("selector", "remove client %p fd %d", it->second, fd); + secdebug("selector", "remove client %p fd %d", it->second, fd); // remove from FDSets set(fd, none); @@ -122,7 +122,7 @@ void Selector::set(int fd, Type type) inSet.set(fd, type & input); outSet.set(fd, type & output); errSet.set(fd, type & critical); - debug("selector", "fd %d notifications 0x%x", fd, type); + secdebug("selector", "fd %d notifications 0x%x", fd, type); } @@ -149,8 +149,8 @@ void Selector::operator () (Time::Absolute stopTime) void Selector::singleStep(Time::Interval maxWait) { assert(!clientMap.empty()); - IFDEBUG(debug("selector", "select(%d) [%d-%d] for %ld clients", - fdMax + 1, fdMin, fdMax, clientMap.size())); + secdebug("selector", "select(%d) [%d-%d] for %ld clients", + fdMax + 1, fdMin, fdMax, clientMap.size()); for (;;) { // pseudo-loop - only retries struct timeval duration = maxWait.timevalInterval(); #if defined(__APPLE__) @@ -165,13 +165,13 @@ void Selector::singleStep(Time::Interval maxWait) case -1: // error if (errno == EINTR) continue; - debug("selector", "select failed: errno=%d", errno); + secdebug("selector", "select failed: errno=%d", errno); UnixError::throwMe(); case 0: // no events - debug("selector", "select returned nothing"); + secdebug("selector", "select returned nothing"); return; default: // some events - debug("selector", "%d pending descriptors", hits); + secdebug("selector", "%d pending descriptors", hits); //@@@ This could be optimized as a word-merge scan. //@@@ The typical case doesn't benefit from this though, though browsers might //@@@ and integrated servers definitely would. @@ -181,7 +181,7 @@ void Selector::singleStep(Time::Interval maxWait) if (outSet[fd]) types |= output; if (errSet[fd]) types |= critical; if (types) { - debug("selector", "notify fd %d client %p type %d", + secdebug("selector", "notify fd %d client %p type %d", fd, clientMap[fd], types); clientMap[fd]->notify(fd, types); hits--; diff --git a/cdsa/cdsa_utilities/socks++4.cpp b/cdsa/cdsa_utilities/socks++4.cpp index 2ed2f20b..ec8a6eaf 100644 --- a/cdsa/cdsa_utilities/socks++4.cpp +++ b/cdsa/cdsa_utilities/socks++4.cpp @@ -41,7 +41,7 @@ void Server::connect(SocksClientSocket &me, const IPSockAddress &peer) request.send(me, "nobody"); (Message(me)); // read and check reply message me.mPeerAddress = peer; // best guess, Mr. Sulu - debug("socks", "%d socks4 connected to %s", me.fd(), string(peer).c_str()); + secdebug("socks", "%d socks4 connected to %s", me.fd(), string(peer).c_str()); } void Server::connect(SocksClientSocket &me, const Host &host, IPPort port) @@ -71,7 +71,7 @@ void Server::bind(SocksServerSocket &me, const IPAddress &peer, IPPort port) request.send(me, "nobody"); Message reply(me); me.mLocalAddress = reply.address().defaults(mServerAddress.address()); - debug("socks", "%d socks4 bound to %s", me.fd(), string(me.mLocalAddress).c_str()); + secdebug("socks", "%d socks4 bound to %s", me.fd(), string(me.mLocalAddress).c_str()); } void Server::receive(SocksServerSocket &me, SocksClientSocket &receiver) @@ -79,7 +79,7 @@ void Server::receive(SocksServerSocket &me, SocksClientSocket &receiver) Message reply(me); receiver.setFd(me.fd(), me.mLocalAddress, reply.address()); me.clear(); // clear our own (don't close on destruction) - debug("socks", "%d socks4 inbound connect", receiver.fd()); + secdebug("socks", "%d socks4 inbound connect", receiver.fd()); } diff --git a/cdsa/cdsa_utilities/socks++5.cpp b/cdsa/cdsa_utilities/socks++5.cpp index 467c01a5..3039e13f 100644 --- a/cdsa/cdsa_utilities/socks++5.cpp +++ b/cdsa/cdsa_utilities/socks++5.cpp @@ -35,13 +35,13 @@ void Server::open(Socket &s, Support &my) { s.open(SOCK_STREAM); s.connect(my.mServer->address()); - debug("socks", "%d connected to server %s", s.fd(), string(my.mServer->address()).c_str()); + secdebug("socks", "%d connected to server %s", s.fd(), string(my.mServer->address()).c_str()); Byte request[] = { 5, 1, socksAuthPublic }; s.write(request, sizeof(request)); Byte reply[2]; s.read(reply, sizeof(reply)); if (reply[0] != 5 || reply[1] != socksAuthPublic) { - debug("socks", "%d server failed (v%d auth=%d)", s.fd(), reply[0], reply[1]); + secdebug("socks", "%d server failed (v%d auth=%d)", s.fd(), reply[0], reply[1]); s.close(); UnixError::throwMe(EPROTONOSUPPORT); } @@ -55,7 +55,7 @@ void Server::connect(SocksClientSocket &me, const IPSockAddress &peer) Message reply(me); me.mLocalAddress = reply.address(); me.mPeerAddress = peer; - debug("socks", "%d socks connected to %s", me.fd(), string(peer).c_str()); + secdebug("socks", "%d socks connected to %s", me.fd(), string(peer).c_str()); } void Server::connect(SocksClientSocket &me, const Host &host, IPPort port) @@ -82,7 +82,7 @@ void Server::connect(SocksClientSocket &me, const Host &host, IPPort port) Message reply(me); me.mLocalAddress = reply.address(); //me.mPeerAddress = not provided by Socks5 protocol; - debug("socks", "%d socks connected to %s", me.fd(), host.name().c_str()); + secdebug("socks", "%d socks connected to %s", me.fd(), host.name().c_str()); #endif } @@ -95,7 +95,7 @@ void Server::bind(SocksServerSocket &me, const IPAddress &peer, IPPort port) Message reply(me); me.mLocalAddress = reply.address(); //me.mPeerAddress not available yet; - debug("socks", "%d socks bound to %s", me.fd(), string(me.mLocalAddress).c_str()); + secdebug("socks", "%d socks bound to %s", me.fd(), string(me.mLocalAddress).c_str()); } void Server::receive(SocksServerSocket &me, SocksClientSocket &receiver) @@ -103,7 +103,7 @@ void Server::receive(SocksServerSocket &me, SocksClientSocket &receiver) Message reply(me); receiver.setFd(me.fd(), me.mLocalAddress, reply.address()); me.clear(); // clear our own (don't close on destruction) - debug("socks", "%d socks received from %s", receiver.fd(), string(reply.address()).c_str()); + secdebug("socks", "%d socks received from %s", receiver.fd(), string(reply.address()).c_str()); } diff --git a/cdsa/cdsa_utilities/streams.h b/cdsa/cdsa_utilities/streams.h index 2085deae..e7adcee9 100644 --- a/cdsa/cdsa_utilities/streams.h +++ b/cdsa/cdsa_utilities/streams.h @@ -183,4 +183,4 @@ private: } // end namespace Security -#endif _H_STREAMS +#endif /* _H_STREAMS */ diff --git a/cdsa/cdsa_utilities/threading.cpp b/cdsa/cdsa_utilities/threading.cpp index d187a8e3..cfe9dd66 100644 --- a/cdsa/cdsa_utilities/threading.cpp +++ b/cdsa/cdsa_utilities/threading.cpp @@ -25,10 +25,8 @@ // Since we are planning to generate "stub" out of line code for threading methods, // we must force THREAD_NDEBUG to off while compiling our header. Trust me. // -#if !defined(THREAD_CLEAN_NDEBUG) -# define THREAD_MAKE_STUBS -#endif #include +#include // @@ -46,10 +44,7 @@ ThreadStoreSlot::~ThreadStoreSlot() { //@@@ if we wanted to dispose of pending task objects, we'd have //@@@ to keep a set of them and delete them explicitly here -#if BUG_2998157 - // @@@ bug 2998157 does not clear slots on delete or allocate. Leak them for now pthread_key_delete(mKey); -#endif //BUG_2998157 } #endif @@ -60,8 +55,6 @@ ThreadStoreSlot::~ThreadStoreSlot() // #if _USE_THREADS == _USE_PTHREADS -#if !defined(THREAD_CLEAN_NDEBUG) - bool Mutex::debugHasInitialized; bool Mutex::loggingMutexi; @@ -71,7 +64,7 @@ Mutex::Mutex(bool log) // this debug-setup code isn't interlocked, but it's idempotent // (don't worry, be happy) if (!debugHasInitialized) { - loggingMutexi = Debug::debugging("mutex"); + loggingMutexi = Debug::debugging("mutex") || Debug::debugging("mutex-c"); debugHasInitialized = true; } debugLog = log && loggingMutexi; @@ -85,8 +78,13 @@ Mutex::Mutex(bool log) Mutex::~Mutex() { #if !defined(THREAD_NDEBUG) - if (debugLog && (useCount > 100 || contentionCount > 0)) - debug("mutex", "%p destroyed after %ld/%ld locks/contentions", this, useCount, contentionCount); + if (debugLog) { + if (contentionCount > 0) + secdebug("mutex-c", "%p destroyed after %ld/%ld locks/contentions", + this, useCount, contentionCount); + else if (useCount > 100) + secdebug("mutex", "%p destroyed after %ld locks", this, useCount); + } #endif //THREAD_NDEBUG check(pthread_mutex_destroy(&me)); } @@ -101,16 +99,16 @@ void Mutex::lock() break; case EBUSY: if (debugLog) - debug("mutex", "%p contended (%ld of %ld)", this, ++contentionCount, useCount); + secdebug("mutex-c", "%p contended (%ld of %ld)", this, ++contentionCount, useCount); check(pthread_mutex_lock(&me)); break; default: UnixError::throwMe(err); } if (useCount % 100 == 0) - debug("mutex", "%p locked %ld", this, useCount); + secdebug("mutex", "%p locked %ld", this, useCount); else - debug("mutex", "%p locked", this); + secdebug("mutex", "%p locked", this); return; } #endif //THREAD_NDEBUG @@ -125,7 +123,7 @@ bool Mutex::tryLock() UnixError::throwMe(err); #if !defined(THREAD_NDEBUG) if (debugLog) - debug("mutex", "%p trylock contended (%ld of %ld)", + secdebug("mutex-c", "%p trylock contended (%ld of %ld)", this, ++contentionCount, useCount); #endif //THREAD_NDEBUG return false; @@ -133,9 +131,9 @@ bool Mutex::tryLock() #if !defined(THREAD_NDEBUG) if (debugLog) if (useCount % 100 == 0) - debug("mutex", "%p locked %ld", this, useCount); + secdebug("mutex", "%p locked %ld", this, useCount); else - debug("mutex", "%p locked", this); + secdebug("mutex", "%p locked", this); #endif //THREAD_NDEBUG return true; } @@ -144,12 +142,11 @@ void Mutex::unlock() { #if !defined(MUTEX_NDEBUG) if (debugLog) - debug("mutex", "%p unlocked", this); + secdebug("mutex", "%p unlocked", this); #endif //MUTEX_NDEBUG check(pthread_mutex_unlock(&me)); } -#endif //!THREAD_CLEAN_NDEBUG #endif //PTHREADS @@ -164,7 +161,7 @@ void CountingMutex::enter() { lock(); mCount++; - debug("mutex", "%p up to %d", this, mCount); + secdebug("mutex", "%p up to %d", this, mCount); unlock(); } @@ -173,7 +170,7 @@ bool CountingMutex::tryEnter() if (!tryLock()) return false; mCount++; - debug("mutex", "%p up to %d (was try)", this, mCount); + secdebug("mutex", "%p up to %d (was try)", this, mCount); unlock(); return true; } @@ -183,14 +180,14 @@ void CountingMutex::exit() lock(); assert(mCount > 0); mCount--; - debug("mutex", "%p down to %d", this, mCount); + secdebug("mutex", "%p down to %d", this, mCount); unlock(); } void CountingMutex::finishEnter() { mCount++; - debug("mutex", "%p finish up to %d", this, mCount); + secdebug("mutex", "%p finish up to %d", this, mCount); unlock(); } @@ -198,7 +195,7 @@ void CountingMutex::finishExit() { assert(mCount > 0); mCount--; - debug("mutex", "%p finish down to %d", this, mCount); + secdebug("mutex", "%p finish down to %d", this, mCount); unlock(); } @@ -217,7 +214,7 @@ void Thread::run() { if (int err = pthread_create(&self.mIdent, NULL, runner, this)) UnixError::throwMe(err); - debug("thread", "%p created", self.mIdent); + secdebug("thread", "%p created", self.mIdent); } void *Thread::runner(void *arg) @@ -225,9 +222,9 @@ void *Thread::runner(void *arg) Thread *me = static_cast(arg); if (int err = pthread_detach(me->self.mIdent)) UnixError::throwMe(err); - debug("thread", "%p starting", me->self.mIdent); + secdebug("thread", "%p starting", me->self.mIdent); me->action(); - debug("thread", "%p terminating", me->self.mIdent); + secdebug("thread", "%p terminating", me->self.mIdent); delete me; return NULL; } @@ -237,21 +234,21 @@ void Thread::yield() sched_yield(); } -#if !defined(NDEBUG) - -#include +// +// Make a more-or-less unique string representation of a thread id. +// This is meant FOR DEBUGGING ONLY. Don't use this in production code. +// void Thread::Identity::getIdString(char id[idLength]) { pthread_t current = pthread_self(); // We're not supposed to know what a pthread_t is. Just print the first few bytes... // (On MacOS X, it's a pointer to a pthread_t internal structure, so this works fine.) - void *p; - memcpy(&p, ¤t, sizeof(p)); - snprintf(id, idLength, "%lx", long(p)); + long ids; + memcpy(&ids, ¤t, sizeof(ids)); + snprintf(id, idLength, "%lx", ids); } -#endif // NDEBUG #endif // PTHREADS diff --git a/cdsa/cdsa_utilities/threading.h b/cdsa/cdsa_utilities/threading.h index 7c61af01..50284a39 100644 --- a/cdsa/cdsa_utilities/threading.h +++ b/cdsa/cdsa_utilities/threading.h @@ -142,34 +142,20 @@ class Mutex { void check(int err) { if (err) UnixError::throwMe(err); } public: -#if defined(THREAD_NDEBUG) && !defined(THREAD_MAKE_STUBS) - Mutex(bool = true) { check(pthread_mutex_init(&me, NULL)); } - void lock() { check(pthread_mutex_lock(&me)); } - bool tryLock() { - if (int err = pthread_mutex_trylock(&me)) - if (err == EBUSY) return false; else UnixError::throwMe(err); - else return true; - } - void unlock() { check(pthread_mutex_unlock(&me)); } - ~Mutex() { check(pthread_mutex_destroy(&me)); } -#else //THREAD_NDEBUG Mutex(bool log = true); ~Mutex(); void lock(); bool tryLock(); void unlock(); -#endif //THREAD_NDEBUG private: pthread_mutex_t me; -#if !defined(THREAD_CLEAN_NDEBUG) bool debugLog; // log *this* mutex unsigned long useCount; // number of locks succeeded unsigned long contentionCount; // number of contentions (valid only if debugLog) static bool debugHasInitialized; // global: debug state set up static bool loggingMutexi; // global: we are debug-logging mutexi -#endif //THREAD_CLEAN_NDEBUG }; #elif _USE_THREADS == _USE_NO_THREADS @@ -323,10 +309,10 @@ public: bool operator != (const Identity &other) const { return !(*this == other); } -#if !defined(NDEBUG) + // visible thread identifiers are FOR DEBUGGING ONLY + // if you use this for production code, your code will rot after shipment :-) static const int idLength = 10; static void getIdString(char id[idLength]); -#endif //NDEBUG private: pthread_t mIdent; diff --git a/cdsa/cdsa_utilities/timeflow.cpp b/cdsa/cdsa_utilities/timeflow.cpp index 9814ce48..88566798 100644 --- a/cdsa/cdsa_utilities/timeflow.cpp +++ b/cdsa/cdsa_utilities/timeflow.cpp @@ -45,6 +45,9 @@ Absolute now() Absolute::Absolute(const struct timeval &tv) { mValue = tv.tv_sec + double(tv.tv_usec) / 1E6; } +Absolute::Absolute(const struct timespec &tv) +{ mValue = tv.tv_sec + double(tv.tv_nsec) / 1E9; } + Absolute::operator struct timeval () const { struct timeval tv; @@ -54,11 +57,25 @@ Absolute::operator struct timeval () const } else { tv.tv_sec = int32_t(mValue); double intPart; - tv.tv_usec = int32_t(modf(mValue, &intPart)); + tv.tv_usec = int32_t(modf(mValue, &intPart) * 1E6); } return tv; } +Absolute::operator struct timespec () const +{ + struct timespec ts; + if (mValue > LONG_MAX) { + ts.tv_sec = LONG_MAX; + ts.tv_nsec = 0; + } else { + ts.tv_sec = time_t(mValue); + double intPart; + ts.tv_nsec = int32_t(modf(mValue, &intPart) * 1E9); + } + return ts; +} + struct timeval Interval::timevalInterval() const { struct timeval tv; @@ -70,7 +87,7 @@ struct timeval Interval::timevalInterval() const } else { tv.tv_sec = int32_t(mValue); double intPart; - tv.tv_usec = int32_t(modf(mValue, &intPart)); + tv.tv_usec = int32_t(modf(mValue, &intPart) * 1E6); } return tv; } diff --git a/cdsa/cdsa_utilities/timeflow.h b/cdsa/cdsa_utilities/timeflow.h index 8dfb6202..b2b65572 100644 --- a/cdsa/cdsa_utilities/timeflow.h +++ b/cdsa/cdsa_utilities/timeflow.h @@ -83,6 +83,7 @@ public: Absolute() { } // uninitialized Absolute(time_t t) { mValue = t; } // from time_t Absolute(const struct timeval &tv); // from timeval + Absolute(const struct timespec &ts); // from timespec // *crement operators Absolute &operator += (Interval rel) { mValue += rel.mValue; return *this; } @@ -98,6 +99,7 @@ public: // express as conventional (absolute!) time measures operator struct timeval() const; + operator struct timespec() const; operator time_t () const { return time_t(mValue); } // internal form for debugging ONLY diff --git a/cdsa/cdsa_utilities/tqueue.h b/cdsa/cdsa_utilities/tqueue.h index 98f1359e..ec969f6a 100644 --- a/cdsa/cdsa_utilities/tqueue.h +++ b/cdsa/cdsa_utilities/tqueue.h @@ -90,7 +90,7 @@ void ScheduleQueue