From 2ee5864540fb75e8446751ab0302d1b0e9d40369 Mon Sep 17 00:00:00 2001 From: 5HT Date: Wed, 25 Sep 2024 21:55:50 +0300 Subject: [PATCH] alsmost done basic profile except tensors --- Package.swift | 10 +-- Sources/ASN1Identifier.swift | 57 -------------- Sources/ASN1SCG/Name.swift | 21 ------ Sources/Suite/ASN1Identifier.swift | 74 +++++++++++++++++++ Sources/{ => Suite}/ASN1SCG/Accuracy.swift | 0 Sources/{ => Suite}/ASN1SCG/Ack.swift | 0 Sources/{ => Suite}/ASN1SCG/AddRequest.swift | 0 .../ASN1SCG/AlgorithmIdentifier.swift | 8 +- Sources/{ => Suite}/ASN1SCG/Attribute.swift | 6 +- .../ASN1SCG/AttributeTypeAndValue.swift | 6 +- .../ASN1SCG/AttributeValueAssertion.swift | 0 Sources/{ => Suite}/ASN1SCG/Auth.swift | 0 Sources/{ => Suite}/ASN1SCG/AuthType.swift | 0 .../ASN1SCG/AuthenticationChoice.swift | 0 .../ASN1SCG/BasicOCSPResponse.swift | 0 Sources/{ => Suite}/ASN1SCG/BinaryField.swift | 0 .../ASN1SCG/BinaryField_p_Choice.swift | 0 Sources/{ => Suite}/ASN1SCG/BindRequest.swift | 0 .../{ => Suite}/ASN1SCG/BindResponse.swift | 0 Sources/{ => Suite}/ASN1SCG/CHATMessage.swift | 0 .../{ => Suite}/ASN1SCG/CHATProtocol.swift | 0 Sources/{ => Suite}/ASN1SCG/CMSVersion.swift | 0 Sources/{ => Suite}/ASN1SCG/CRLListID.swift | 0 Sources/{ => Suite}/ASN1SCG/CRLReason.swift | 0 Sources/{ => Suite}/ASN1SCG/CertID.swift | 0 Sources/{ => Suite}/ASN1SCG/CertStatus.swift | 0 Sources/{ => Suite}/ASN1SCG/Certificate.swift | 0 .../{ => Suite}/ASN1SCG/CertificateList.swift | 0 .../{ => Suite}/ASN1SCG/CompareRequest.swift | 0 Sources/{ => Suite}/ASN1SCG/Contact.swift | 0 .../{ => Suite}/ASN1SCG/ContactStatus.swift | 0 Sources/{ => Suite}/ASN1SCG/ContentInfo.swift | 0 Sources/{ => Suite}/ASN1SCG/Control.swift | 2 +- Sources/{ => Suite}/ASN1SCG/Criteria.swift | 0 .../{ => Suite}/ASN1SCG/CrlIdentifier.swift | 0 Sources/{ => Suite}/ASN1SCG/CrlOcspRef.swift | 0 .../{ => Suite}/ASN1SCG/CrlValidatedID.swift | 0 .../{ => Suite}/ASN1SCG/DSTU4145Params.swift | 0 .../DSTU4145Params_definition_Choice.swift | 0 .../{ => Suite}/ASN1SCG/DirectoryString.swift | 0 Sources/{ => Suite}/ASN1SCG/DisplayText.swift | 0 Sources/{ => Suite}/ASN1SCG/ECBinary.swift | 0 Sources/{ => Suite}/ASN1SCG/ESSCertIDv2.swift | 0 .../ASN1SCG/EncapsulatedContentInfo.swift | 0 .../{ => Suite}/ASN1SCG/ExtendedRequest.swift | 2 +- .../ASN1SCG/ExtendedResponse.swift | 0 Sources/{ => Suite}/ASN1SCG/Extension.swift | 2 +- Sources/{ => Suite}/ASN1SCG/Feature.swift | 0 Sources/{ => Suite}/ASN1SCG/FileDesc.swift | 0 Sources/{ => Suite}/ASN1SCG/Filter.swift | 0 Sources/{ => Suite}/ASN1SCG/Friend.swift | 0 Sources/{ => Suite}/ASN1SCG/Friendship.swift | 0 Sources/{ => Suite}/ASN1SCG/GeneralName.swift | 0 Sources/{ => Suite}/ASN1SCG/History.swift | 0 .../{ => Suite}/ASN1SCG/HistoryStatus.swift | 0 .../ASN1SCG/History_feed_Choice.swift | 0 .../ASN1SCG/IntermediateResponse.swift | 0 .../ASN1SCG/IssuerAndSerialNumber.swift | 0 .../{ => Suite}/ASN1SCG/IssuerSerial.swift | 0 Sources/{ => Suite}/ASN1SCG/LDAPMessage.swift | 0 .../LDAPMessage_protocolOp_Choice.swift | 0 Sources/{ => Suite}/ASN1SCG/LDAPResult.swift | 0 .../ASN1SCG/LDAPResult_resultCode_Enum.swift | 0 Sources/{ => Suite}/ASN1SCG/MUC.swift | 0 .../ASN1SCG/MatchingRuleAssertion.swift | 4 +- Sources/{ => Suite}/ASN1SCG/Member.swift | 0 .../{ => Suite}/ASN1SCG/MemberStatus.swift | 0 .../ASN1SCG/Member_feed_id_Choice.swift | 0 Sources/{ => Suite}/ASN1SCG/Message.swift | 0 .../{ => Suite}/ASN1SCG/MessageImprint.swift | 0 .../{ => Suite}/ASN1SCG/MessageStatus.swift | 0 Sources/{ => Suite}/ASN1SCG/MessageType.swift | 0 .../ASN1SCG/Message_feed_id_Choice.swift | 0 .../{ => Suite}/ASN1SCG/ModifyDNRequest.swift | 2 +- .../{ => Suite}/ASN1SCG/ModifyRequest.swift | 0 .../ModifyRequest_changes_Sequence.swift | 0 ...uest_changes_Sequence_operation_Enum.swift | 0 Sources/Suite/ASN1SCG/Name.swift | 42 +++++++++++ Sources/{ => Suite}/ASN1SCG/OS.swift | 0 .../{ => Suite}/ASN1SCG/OcspIdentifier.swift | 0 Sources/{ => Suite}/ASN1SCG/OcspListID.swift | 0 .../{ => Suite}/ASN1SCG/OcspResponsesID.swift | 0 Sources/{ => Suite}/ASN1SCG/OtherHash.swift | 0 .../ASN1SCG/OtherHashAlgAndValue.swift | 0 .../{ => Suite}/ASN1SCG/OtherRevRefs.swift | 0 .../{ => Suite}/ASN1SCG/OtherRevVals.swift | 0 Sources/{ => Suite}/ASN1SCG/P2P.swift | 0 Sources/{ => Suite}/ASN1SCG/PKIStatus.swift | 0 .../{ => Suite}/ASN1SCG/PKIStatusInfo.swift | 0 .../ASN1SCG/PartialAttribute.swift | 0 Sources/{ => Suite}/ASN1SCG/Pentanomial.swift | 0 .../ASN1SCG/PolicyInformation.swift | 0 .../ASN1SCG/PolicyQualifierInfo.swift | 2 +- Sources/{ => Suite}/ASN1SCG/Presence.swift | 0 .../{ => Suite}/ASN1SCG/PresenceType.swift | 0 Sources/{ => Suite}/ASN1SCG/Profile.swift | 0 Sources/{ => Suite}/ASN1SCG/Register.swift | 0 Sources/{ => Suite}/ASN1SCG/ResponderID.swift | 0 .../{ => Suite}/ASN1SCG/ResponseData.swift | 0 .../ASN1SCG/RevocationValues.swift | 0 Sources/{ => Suite}/ASN1SCG/RevokedInfo.swift | 0 Sources/{ => Suite}/ASN1SCG/Room.swift | 0 Sources/{ => Suite}/ASN1SCG/RoomStatus.swift | 0 Sources/{ => Suite}/ASN1SCG/RoomType.swift | 0 Sources/{ => Suite}/ASN1SCG/Roster.swift | 0 .../{ => Suite}/ASN1SCG/RosterStatus.swift | 0 .../{ => Suite}/ASN1SCG/SaslCredentials.swift | 0 Sources/{ => Suite}/ASN1SCG/Scope.swift | 0 Sources/{ => Suite}/ASN1SCG/Search.swift | 0 .../{ => Suite}/ASN1SCG/SearchRequest.swift | 2 +- .../SearchRequest_derefAliases_Enum.swift | 0 .../ASN1SCG/SearchRequest_scope_Enum.swift | 0 .../ASN1SCG/SearchResultEntry.swift | 0 .../{ => Suite}/ASN1SCG/SearchStatus.swift | 0 Sources/{ => Suite}/ASN1SCG/Server.swift | 0 Sources/{ => Suite}/ASN1SCG/Service.swift | 0 .../{ => Suite}/ASN1SCG/ServiceStatus.swift | 0 Sources/{ => Suite}/ASN1SCG/ServiceType.swift | 0 .../ASN1SCG/SigPolicyQualifierInfo.swift | 0 .../ASN1SCG/SignaturePolicyId.swift | 0 .../ASN1SCG/SignaturePolicyIdentifier.swift | 0 Sources/{ => Suite}/ASN1SCG/SignedData.swift | 0 .../ASN1SCG/SignerIdentifier.swift | 0 Sources/{ => Suite}/ASN1SCG/SignerInfo.swift | 0 .../ASN1SCG/SigningCertificateV2.swift | 0 .../{ => Suite}/ASN1SCG/SingleResponse.swift | 0 .../ASN1SCG/SubjectPublicKeyInfo.swift | 0 .../{ => Suite}/ASN1SCG/SubstringFilter.swift | 0 .../SubstringFilter_substrings_Choice.swift | 0 Sources/{ => Suite}/ASN1SCG/TBSCertList.swift | 0 ...ertList_revokedCertificates_Sequence.swift | 0 .../{ => Suite}/ASN1SCG/TBSCertificate.swift | 0 Sources/{ => Suite}/ASN1SCG/TSTInfo.swift | 0 .../ASN1SCG/TSTInfo_version_IntEnum.swift | 0 Sources/{ => Suite}/ASN1SCG/Time.swift | 0 .../{ => Suite}/ASN1SCG/TimeStampReq.swift | 2 +- .../TimeStampReq_version_IntEnum.swift | 0 .../{ => Suite}/ASN1SCG/TimeStampResp.swift | 0 Sources/{ => Suite}/ASN1SCG/Typing.swift | 0 Sources/{ => Suite}/ASN1SCG/Validity.swift | 0 Sources/{ => Suite}/ASN1SCG/Version.swift | 0 Sources/Suite/main.swift | 33 +++++++++ asn1.ex | 18 ++--- priv/basic/DSTU.asn1 | 4 +- 144 files changed, 181 insertions(+), 116 deletions(-) delete mode 100644 Sources/ASN1Identifier.swift delete mode 100644 Sources/ASN1SCG/Name.swift create mode 100644 Sources/Suite/ASN1Identifier.swift rename Sources/{ => Suite}/ASN1SCG/Accuracy.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Ack.swift (100%) rename Sources/{ => Suite}/ASN1SCG/AddRequest.swift (100%) rename Sources/{ => Suite}/ASN1SCG/AlgorithmIdentifier.swift (82%) rename Sources/{ => Suite}/ASN1SCG/Attribute.swift (85%) rename Sources/{ => Suite}/ASN1SCG/AttributeTypeAndValue.swift (83%) rename Sources/{ => Suite}/ASN1SCG/AttributeValueAssertion.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Auth.swift (100%) rename Sources/{ => Suite}/ASN1SCG/AuthType.swift (100%) rename Sources/{ => Suite}/ASN1SCG/AuthenticationChoice.swift (100%) rename Sources/{ => Suite}/ASN1SCG/BasicOCSPResponse.swift (100%) rename Sources/{ => Suite}/ASN1SCG/BinaryField.swift (100%) rename Sources/{ => Suite}/ASN1SCG/BinaryField_p_Choice.swift (100%) rename Sources/{ => Suite}/ASN1SCG/BindRequest.swift (100%) rename Sources/{ => Suite}/ASN1SCG/BindResponse.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CHATMessage.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CHATProtocol.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CMSVersion.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CRLListID.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CRLReason.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CertID.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CertStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Certificate.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CertificateList.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CompareRequest.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Contact.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ContactStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ContentInfo.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Control.swift (94%) rename Sources/{ => Suite}/ASN1SCG/Criteria.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CrlIdentifier.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CrlOcspRef.swift (100%) rename Sources/{ => Suite}/ASN1SCG/CrlValidatedID.swift (100%) rename Sources/{ => Suite}/ASN1SCG/DSTU4145Params.swift (100%) rename Sources/{ => Suite}/ASN1SCG/DSTU4145Params_definition_Choice.swift (100%) rename Sources/{ => Suite}/ASN1SCG/DirectoryString.swift (100%) rename Sources/{ => Suite}/ASN1SCG/DisplayText.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ECBinary.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ESSCertIDv2.swift (100%) rename Sources/{ => Suite}/ASN1SCG/EncapsulatedContentInfo.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ExtendedRequest.swift (90%) rename Sources/{ => Suite}/ASN1SCG/ExtendedResponse.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Extension.swift (94%) rename Sources/{ => Suite}/ASN1SCG/Feature.swift (100%) rename Sources/{ => Suite}/ASN1SCG/FileDesc.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Filter.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Friend.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Friendship.swift (100%) rename Sources/{ => Suite}/ASN1SCG/GeneralName.swift (100%) rename Sources/{ => Suite}/ASN1SCG/History.swift (100%) rename Sources/{ => Suite}/ASN1SCG/HistoryStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/History_feed_Choice.swift (100%) rename Sources/{ => Suite}/ASN1SCG/IntermediateResponse.swift (100%) rename Sources/{ => Suite}/ASN1SCG/IssuerAndSerialNumber.swift (100%) rename Sources/{ => Suite}/ASN1SCG/IssuerSerial.swift (100%) rename Sources/{ => Suite}/ASN1SCG/LDAPMessage.swift (100%) rename Sources/{ => Suite}/ASN1SCG/LDAPMessage_protocolOp_Choice.swift (100%) rename Sources/{ => Suite}/ASN1SCG/LDAPResult.swift (100%) rename Sources/{ => Suite}/ASN1SCG/LDAPResult_resultCode_Enum.swift (100%) rename Sources/{ => Suite}/ASN1SCG/MUC.swift (100%) rename Sources/{ => Suite}/ASN1SCG/MatchingRuleAssertion.swift (88%) rename Sources/{ => Suite}/ASN1SCG/Member.swift (100%) rename Sources/{ => Suite}/ASN1SCG/MemberStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Member_feed_id_Choice.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Message.swift (100%) rename Sources/{ => Suite}/ASN1SCG/MessageImprint.swift (100%) rename Sources/{ => Suite}/ASN1SCG/MessageStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/MessageType.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Message_feed_id_Choice.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ModifyDNRequest.swift (95%) rename Sources/{ => Suite}/ASN1SCG/ModifyRequest.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ModifyRequest_changes_Sequence.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ModifyRequest_changes_Sequence_operation_Enum.swift (100%) create mode 100644 Sources/Suite/ASN1SCG/Name.swift rename Sources/{ => Suite}/ASN1SCG/OS.swift (100%) rename Sources/{ => Suite}/ASN1SCG/OcspIdentifier.swift (100%) rename Sources/{ => Suite}/ASN1SCG/OcspListID.swift (100%) rename Sources/{ => Suite}/ASN1SCG/OcspResponsesID.swift (100%) rename Sources/{ => Suite}/ASN1SCG/OtherHash.swift (100%) rename Sources/{ => Suite}/ASN1SCG/OtherHashAlgAndValue.swift (100%) rename Sources/{ => Suite}/ASN1SCG/OtherRevRefs.swift (100%) rename Sources/{ => Suite}/ASN1SCG/OtherRevVals.swift (100%) rename Sources/{ => Suite}/ASN1SCG/P2P.swift (100%) rename Sources/{ => Suite}/ASN1SCG/PKIStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/PKIStatusInfo.swift (100%) rename Sources/{ => Suite}/ASN1SCG/PartialAttribute.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Pentanomial.swift (100%) rename Sources/{ => Suite}/ASN1SCG/PolicyInformation.swift (100%) rename Sources/{ => Suite}/ASN1SCG/PolicyQualifierInfo.swift (94%) rename Sources/{ => Suite}/ASN1SCG/Presence.swift (100%) rename Sources/{ => Suite}/ASN1SCG/PresenceType.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Profile.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Register.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ResponderID.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ResponseData.swift (100%) rename Sources/{ => Suite}/ASN1SCG/RevocationValues.swift (100%) rename Sources/{ => Suite}/ASN1SCG/RevokedInfo.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Room.swift (100%) rename Sources/{ => Suite}/ASN1SCG/RoomStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/RoomType.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Roster.swift (100%) rename Sources/{ => Suite}/ASN1SCG/RosterStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SaslCredentials.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Scope.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Search.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SearchRequest.swift (97%) rename Sources/{ => Suite}/ASN1SCG/SearchRequest_derefAliases_Enum.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SearchRequest_scope_Enum.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SearchResultEntry.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SearchStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Server.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Service.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ServiceStatus.swift (100%) rename Sources/{ => Suite}/ASN1SCG/ServiceType.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SigPolicyQualifierInfo.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SignaturePolicyId.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SignaturePolicyIdentifier.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SignedData.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SignerIdentifier.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SignerInfo.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SigningCertificateV2.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SingleResponse.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SubjectPublicKeyInfo.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SubstringFilter.swift (100%) rename Sources/{ => Suite}/ASN1SCG/SubstringFilter_substrings_Choice.swift (100%) rename Sources/{ => Suite}/ASN1SCG/TBSCertList.swift (100%) rename Sources/{ => Suite}/ASN1SCG/TBSCertList_revokedCertificates_Sequence.swift (100%) rename Sources/{ => Suite}/ASN1SCG/TBSCertificate.swift (100%) rename Sources/{ => Suite}/ASN1SCG/TSTInfo.swift (100%) rename Sources/{ => Suite}/ASN1SCG/TSTInfo_version_IntEnum.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Time.swift (100%) rename Sources/{ => Suite}/ASN1SCG/TimeStampReq.swift (96%) rename Sources/{ => Suite}/ASN1SCG/TimeStampReq_version_IntEnum.swift (100%) rename Sources/{ => Suite}/ASN1SCG/TimeStampResp.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Typing.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Validity.swift (100%) rename Sources/{ => Suite}/ASN1SCG/Version.swift (100%) create mode 100644 Sources/Suite/main.swift diff --git a/Package.swift b/Package.swift index 52bd55e..e360490 100644 --- a/Package.swift +++ b/Package.swift @@ -4,14 +4,12 @@ import PackageDescription import class Foundation.ProcessInfo let package = Package( - name: "chat-asn1", + name: "chat-x509", platforms: [ .macOS(.v12), .iOS(.v13) ], - products: [ .library(name: "chat-asn1", targets: ["ASN1SCG"]), ], - targets: [ .target(name: "ASN1SCG", dependencies: [ - .product(name: "SwiftASN1", package: "swift-asn1"), ]), ] + products: [ .executable(name: "chat-x509", targets: ["Suite"]), ], + targets: [ .executableTarget(name: "Suite", dependencies: [ .product(name: "SwiftASN1", package: "swift-asn1"), ]), ] ) if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { - package.dependencies += [ - .package(url: "https://github.com/apple/swift-asn1.git", from: "1.2.0"), ] + package.dependencies += [ .package(url: "https://github.com/apple/swift-asn1.git", from: "1.2.0"), ] } diff --git a/Sources/ASN1Identifier.swift b/Sources/ASN1Identifier.swift deleted file mode 100644 index ab98946..0000000 --- a/Sources/ASN1Identifier.swift +++ /dev/null @@ -1,57 +0,0 @@ -import SwiftASN1 -import Foundation - -@usableFromInline public struct ASN1VisibleString: DERImplicitlyTaggable, BERImplicitlyTaggable { - - @inlinable - public static var defaultIdentifier: ASN1Identifier { - .visibleString - } - - @inlinable - public init(derEncoded node: ASN1Node, withIdentifier identifier: ASN1Identifier) throws { - guard node.identifier == identifier else { - throw ASN1Error.unexpectedFieldType(node.identifier) - } - - guard case .primitive(let content) = node.content else { - preconditionFailure("ASN.1 parser generated primitive node with constructed content") - } - - self.bytes = content - } - -} - -extension ASN1Identifier { - public static let boolean = ASN1Identifier(shortIdentifier: 0x01) - public static let integer = ASN1Identifier(shortIdentifier: 0x02) - public static let bitString = ASN1Identifier(shortIdentifier: 0x03) - public static let octetString = ASN1Identifier(shortIdentifier: 0x04) - public static let null = ASN1Identifier(shortIdentifier: 0x05) - public static let objectIdentifier = ASN1Identifier(shortIdentifier: 0x06) - public static let objectDescriptor = ASN1Identifier(shortIdentifier: 0x07) - public static let external = ASN1Identifier(shortIdentifier: 0x08) - public static let real = ASN1Identifier(shortIdentifier: 0x09) - public static let enumerated = ASN1Identifier(shortIdentifier: 0x0a) - public static let embedded = ASN1Identifier(shortIdentifier: 0x0b) - public static let utf8String = ASN1Identifier(shortIdentifier: 0x0c) - public static let relativeIdentifier = ASN1Identifier(shortIdentifier: 0x0d) - public static let time = ASN1Identifier(shortIdentifier: 0x0e) - public static let sequenceOf = ASN1Identifier(shortIdentifier: 0x10) - public static let setOf = ASN1Identifier(shortIdentifier: 0x11) - public static let numericString = ASN1Identifier(shortIdentifier: 0x12) - public static let printableString = ASN1Identifier(shortIdentifier: 0x13) - public static let teletexString = ASN1Identifier(shortIdentifier: 0x14) - public static let videotexString = ASN1Identifier(shortIdentifier: 0x15) - public static let ia5String = ASN1Identifier(shortIdentifier: 0x16) - public static let utcTime = ASN1Identifier(shortIdentifier: 0x17) - public static let generalizedTime = ASN1Identifier(shortIdentifier: 0x18) - public static let graphicString = ASN1Identifier(shortIdentifier: 0x19) - public static let visibleString = ASN1Identifier(shortIdentifier: 0x1a) - public static let generalString = ASN1Identifier(shortIdentifier: 0x1b) - public static let universalString = ASN1Identifier(shortIdentifier: 0x1c) - public static let bmpString = ASN1Identifier(shortIdentifier: 0x1e) - public static let sequence = ASN1Identifier(shortIdentifier: 0x30) - public static let set = ASN1Identifier(shortIdentifier: 0x31) -} diff --git a/Sources/ASN1SCG/Name.swift b/Sources/ASN1SCG/Name.swift deleted file mode 100644 index 3806e97..0000000 --- a/Sources/ASN1SCG/Name.swift +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ASN1.ERP.UNO Compiler, Copyright © 2023 Namdak Tonpa. -import SwiftASN1 -import Foundation - -@usableFromInline indirect enum Name: DERImplicitlyTaggable, DERParseable, DERSerializable, Hashable, Sendable { - @inlinable static var defaultIdentifier: ASN1Identifier { .enumerated } - case rdnSequence([[AttributeTypeAndValue]]) - @inlinable init(derEncoded rootNode: ASN1Node, withIdentifier: ASN1Identifier) throws { - switch rootNode.identifier { - case [[AttributeTypeAndValue]].defaultIdentifier: - self = .rdnSequence(try [[AttributeTypeAndValue]](derEncoded: rootNode)) - default: throw ASN1Error.unexpectedFieldType(rootNode.identifier) - } - } - @inlinable func serialize(into coder: inout DER.Serializer, withIdentifier: ASN1Identifier) throws { - switch self { - case .rdnSequence(let rdnSequence): try coder.serialize(rdnSequence) - } - } - -} diff --git a/Sources/Suite/ASN1Identifier.swift b/Sources/Suite/ASN1Identifier.swift new file mode 100644 index 0000000..e809398 --- /dev/null +++ b/Sources/Suite/ASN1Identifier.swift @@ -0,0 +1,74 @@ +import SwiftASN1 +import Foundation + +public struct ASN1VisibleString: DERImplicitlyTaggable { + + @inlinable + public static var defaultIdentifier: ASN1Identifier { + .visibleString + } + + public var bytes: ArraySlice + + @inlinable + public init(contentBytes: ArraySlice) { + self.bytes = contentBytes + } + + @inlinable + public init(derEncoded node: ASN1Node, withIdentifier identifier: ASN1Identifier) throws { + guard node.identifier == identifier else { + throw ASN1Error.unexpectedFieldType(node.identifier) + } + + guard case .primitive(let content) = node.content else { + preconditionFailure("ASN.1 parser generated primitive node with constructed content") + } + + self.bytes = content + } + + @inlinable + public func serialize(into coder: inout DER.Serializer, withIdentifier identifier: ASN1Identifier) throws { + let octet = ASN1OctetString(contentBytes: self.bytes) + try octet.serialize(into: &coder, withIdentifier: identifier) + } + +} + +extension ASN1Identifier { + public static let sequenceOf = ASN1Identifier(tagWithNumber: 0x10, tagClass: ASN1Identifier.TagClass.universal) + public static let setOf = ASN1Identifier(tagWithNumber: 0x11, tagClass: ASN1Identifier.TagClass.universal) +/* + public static let boolean = ASN1Identifier(tagWithNumber: 0x01, tagClass: ASN1Identifier.TagClass.universal) + public static let integer = ASN1Identifier(tagWithNumber: 0x02, tagClass: ASN1Identifier.TagClass.universal) + public static let bitString = ASN1Identifier(tagWithNumber: 0x03, tagClass: ASN1Identifier.TagClass.universal) + public static let octetString = ASN1Identifier(tagWithNumber: 0x04, tagClass: ASN1Identifier.TagClass.universal) + public static let null = ASN1Identifier(tagWithNumber: 0x05, tagClass: ASN1Identifier.TagClass.universal) + public static let objectIdentifier = ASN1Identifier(tagWithNumber: 0x06, tagClass: ASN1Identifier.TagClass.universal) + public static let objectDescriptor = ASN1Identifier(tagWithNumber: 0x07, tagClass: ASN1Identifier.TagClass.universal) + public static let external = ASN1Identifier(tagWithNumber: 0x08, tagClass: ASN1Identifier.TagClass.universal) + public static let real = ASN1Identifier(tagWithNumber: 0x09, tagClass: ASN1Identifier.TagClass.universal) + public static let enumerated = ASN1Identifier(tagWithNumber: 0x0a, tagClass: ASN1Identifier.TagClass.universal) + public static let embedded = ASN1Identifier(tagWithNumber: 0x0b, tagClass: ASN1Identifier.TagClass.universal) + public static let utf8String = ASN1Identifier(tagWithNumber: 0x0c, tagClass: ASN1Identifier.TagClass.universal) + public static let relativeIdentifier = ASN1Identifier(tagWithNumber: 0x0d, tagClass: ASN1Identifier.TagClass.universal) + public static let time = ASN1Identifier(tagWithNumber: 0x0e, tagClass: ASN1Identifier.TagClass.universal) + public static let numericString = ASN1Identifier(tagWithNumber: 0x12, tagClass: ASN1Identifier.TagClass.universal) + public static let printableString = ASN1Identifier(tagWithNumber: 0x13, tagClass: ASN1Identifier.TagClass.universal) + public static let teletexString = ASN1Identifier(tagWithNumber: 0x14, tagClass: ASN1Identifier.TagClass.universal) + public static let videotexString = ASN1Identifier(tagWithNumber: 0x15, tagClass: ASN1Identifier.TagClass.universal) + public static let ia5String = ASN1Identifier(tagWithNumber: 0x16, tagClass: ASN1Identifier.TagClass.universal) + public static let utcTime = ASN1Identifier(tagWithNumber: 0x17, tagClass: ASN1Identifier.TagClass.universal) + public static let generalizedTime = ASN1Identifier(tagWithNumber: 0x18, tagClass: ASN1Identifier.TagClass.universal) + public static let graphicString = ASN1Identifier(tagWithNumber: 0x19, tagClass: ASN1Identifier.TagClass.universal) + public static let visibleString = ASN1Identifier(tagWithNumber: 0x1a, tagClass: ASN1Identifier.TagClass.universal) + public static let generalString = ASN1Identifier(tagWithNumber: 0x1b, tagClass: ASN1Identifier.TagClass.universal) + public static let universalString = ASN1Identifier(tagWithNumber: 0x1c, tagClass: ASN1Identifier.TagClass.universal) + public static let bmpString = ASN1Identifier(tagWithNumber: 0x1e, tagClass: ASN1Identifier.TagClass.universal) + public static let sequence = ASN1Identifier(tagWithNumber: 0x30, tagClass: ASN1Identifier.TagClass.universal) + public static let set = ASN1Identifier(tagWithNumber: 0x31, tagClass: ASN1Identifier.TagClass.universal) +*/ +} + + diff --git a/Sources/ASN1SCG/Accuracy.swift b/Sources/Suite/ASN1SCG/Accuracy.swift similarity index 100% rename from Sources/ASN1SCG/Accuracy.swift rename to Sources/Suite/ASN1SCG/Accuracy.swift diff --git a/Sources/ASN1SCG/Ack.swift b/Sources/Suite/ASN1SCG/Ack.swift similarity index 100% rename from Sources/ASN1SCG/Ack.swift rename to Sources/Suite/ASN1SCG/Ack.swift diff --git a/Sources/ASN1SCG/AddRequest.swift b/Sources/Suite/ASN1SCG/AddRequest.swift similarity index 100% rename from Sources/ASN1SCG/AddRequest.swift rename to Sources/Suite/ASN1SCG/AddRequest.swift diff --git a/Sources/ASN1SCG/AlgorithmIdentifier.swift b/Sources/Suite/ASN1SCG/AlgorithmIdentifier.swift similarity index 82% rename from Sources/ASN1SCG/AlgorithmIdentifier.swift rename to Sources/Suite/ASN1SCG/AlgorithmIdentifier.swift index e312436..4166c17 100644 --- a/Sources/ASN1SCG/AlgorithmIdentifier.swift +++ b/Sources/Suite/ASN1SCG/AlgorithmIdentifier.swift @@ -5,8 +5,8 @@ import Foundation @usableFromInline struct AlgorithmIdentifier: DERImplicitlyTaggable, Hashable, Sendable { @inlinable static var defaultIdentifier: ASN1Identifier { .sequence } @usableFromInline var algorithm: ASN1ObjectIdentifier - @usableFromInline var parameters: ASN1Any - @inlinable init(algorithm: ASN1ObjectIdentifier, parameters: ASN1Any) { + @usableFromInline var parameters: ASN1Any? + @inlinable init(algorithm: ASN1ObjectIdentifier, parameters: ASN1Any?) { self.algorithm = algorithm self.parameters = parameters } @@ -14,7 +14,7 @@ import Foundation withIdentifier identifier: ASN1Identifier) throws { self = try DER.sequence(root, identifier: identifier) { nodes in let algorithm: ASN1ObjectIdentifier = try ASN1ObjectIdentifier(derEncoded: &nodes) - let parameters: ASN1Any = try ASN1Any(derEncoded: &nodes) + let parameters: ASN1Any? = nodes.next().map { ASN1Any(derEncoded: $0) } return AlgorithmIdentifier(algorithm: algorithm, parameters: parameters) } } @@ -22,7 +22,7 @@ import Foundation withIdentifier identifier: ASN1Identifier) throws { try coder.appendConstructedNode(identifier: identifier) { coder in try coder.serialize(algorithm) - try coder.serialize(parameters) + if let parameters = self.parameters { try coder.serialize(parameters) } } } } diff --git a/Sources/ASN1SCG/Attribute.swift b/Sources/Suite/ASN1SCG/Attribute.swift similarity index 85% rename from Sources/ASN1SCG/Attribute.swift rename to Sources/Suite/ASN1SCG/Attribute.swift index 7c18438..c9806ff 100644 --- a/Sources/ASN1SCG/Attribute.swift +++ b/Sources/Suite/ASN1SCG/Attribute.swift @@ -5,8 +5,8 @@ import Foundation @usableFromInline struct Attribute: DERImplicitlyTaggable, Hashable, Sendable { @inlinable static var defaultIdentifier: ASN1Identifier { .sequence } @usableFromInline var attrType: ASN1ObjectIdentifier - @usableFromInline var attrValues: [ASN1Any] - @inlinable init(attrType: ASN1ObjectIdentifier, attrValues: [ASN1Any]) { + @usableFromInline var attrValues: [ASN1OctetString] + @inlinable init(attrType: ASN1ObjectIdentifier, attrValues: [ASN1OctetString]) { self.attrType = attrType self.attrValues = attrValues } @@ -14,7 +14,7 @@ import Foundation withIdentifier identifier: ASN1Identifier) throws { self = try DER.sequence(root, identifier: identifier) { nodes in let attrType: ASN1ObjectIdentifier = try ASN1ObjectIdentifier(derEncoded: &nodes) - let attrValues: [ASN1Any] = try DER.set(of: ASN1Any.self, identifier: .set, nodes: &nodes) + let attrValues: [ASN1OctetString] = try DER.set(of: ASN1OctetString.self, identifier: .set, nodes: &nodes) return Attribute(attrType: attrType, attrValues: attrValues) } } diff --git a/Sources/ASN1SCG/AttributeTypeAndValue.swift b/Sources/Suite/ASN1SCG/AttributeTypeAndValue.swift similarity index 83% rename from Sources/ASN1SCG/AttributeTypeAndValue.swift rename to Sources/Suite/ASN1SCG/AttributeTypeAndValue.swift index 38f8dfe..90831b5 100644 --- a/Sources/ASN1SCG/AttributeTypeAndValue.swift +++ b/Sources/Suite/ASN1SCG/AttributeTypeAndValue.swift @@ -5,8 +5,8 @@ import Foundation @usableFromInline struct AttributeTypeAndValue: DERImplicitlyTaggable, Hashable, Sendable { @inlinable static var defaultIdentifier: ASN1Identifier { .sequence } @usableFromInline var type: ASN1ObjectIdentifier - @usableFromInline var value: ASN1OctetString - @inlinable init(type: ASN1ObjectIdentifier, value: ASN1OctetString) { + @usableFromInline var value: ASN1Any + @inlinable init(type: ASN1ObjectIdentifier, value: ASN1Any) { self.type = type self.value = value } @@ -14,7 +14,7 @@ import Foundation withIdentifier identifier: ASN1Identifier) throws { self = try DER.sequence(root, identifier: identifier) { nodes in let type: ASN1ObjectIdentifier = try ASN1ObjectIdentifier(derEncoded: &nodes) - let value: ASN1OctetString = try ASN1OctetString(derEncoded: &nodes) + let value: ASN1Any = try ASN1Any(derEncoded: &nodes) return AttributeTypeAndValue(type: type, value: value) } } diff --git a/Sources/ASN1SCG/AttributeValueAssertion.swift b/Sources/Suite/ASN1SCG/AttributeValueAssertion.swift similarity index 100% rename from Sources/ASN1SCG/AttributeValueAssertion.swift rename to Sources/Suite/ASN1SCG/AttributeValueAssertion.swift diff --git a/Sources/ASN1SCG/Auth.swift b/Sources/Suite/ASN1SCG/Auth.swift similarity index 100% rename from Sources/ASN1SCG/Auth.swift rename to Sources/Suite/ASN1SCG/Auth.swift diff --git a/Sources/ASN1SCG/AuthType.swift b/Sources/Suite/ASN1SCG/AuthType.swift similarity index 100% rename from Sources/ASN1SCG/AuthType.swift rename to Sources/Suite/ASN1SCG/AuthType.swift diff --git a/Sources/ASN1SCG/AuthenticationChoice.swift b/Sources/Suite/ASN1SCG/AuthenticationChoice.swift similarity index 100% rename from Sources/ASN1SCG/AuthenticationChoice.swift rename to Sources/Suite/ASN1SCG/AuthenticationChoice.swift diff --git a/Sources/ASN1SCG/BasicOCSPResponse.swift b/Sources/Suite/ASN1SCG/BasicOCSPResponse.swift similarity index 100% rename from Sources/ASN1SCG/BasicOCSPResponse.swift rename to Sources/Suite/ASN1SCG/BasicOCSPResponse.swift diff --git a/Sources/ASN1SCG/BinaryField.swift b/Sources/Suite/ASN1SCG/BinaryField.swift similarity index 100% rename from Sources/ASN1SCG/BinaryField.swift rename to Sources/Suite/ASN1SCG/BinaryField.swift diff --git a/Sources/ASN1SCG/BinaryField_p_Choice.swift b/Sources/Suite/ASN1SCG/BinaryField_p_Choice.swift similarity index 100% rename from Sources/ASN1SCG/BinaryField_p_Choice.swift rename to Sources/Suite/ASN1SCG/BinaryField_p_Choice.swift diff --git a/Sources/ASN1SCG/BindRequest.swift b/Sources/Suite/ASN1SCG/BindRequest.swift similarity index 100% rename from Sources/ASN1SCG/BindRequest.swift rename to Sources/Suite/ASN1SCG/BindRequest.swift diff --git a/Sources/ASN1SCG/BindResponse.swift b/Sources/Suite/ASN1SCG/BindResponse.swift similarity index 100% rename from Sources/ASN1SCG/BindResponse.swift rename to Sources/Suite/ASN1SCG/BindResponse.swift diff --git a/Sources/ASN1SCG/CHATMessage.swift b/Sources/Suite/ASN1SCG/CHATMessage.swift similarity index 100% rename from Sources/ASN1SCG/CHATMessage.swift rename to Sources/Suite/ASN1SCG/CHATMessage.swift diff --git a/Sources/ASN1SCG/CHATProtocol.swift b/Sources/Suite/ASN1SCG/CHATProtocol.swift similarity index 100% rename from Sources/ASN1SCG/CHATProtocol.swift rename to Sources/Suite/ASN1SCG/CHATProtocol.swift diff --git a/Sources/ASN1SCG/CMSVersion.swift b/Sources/Suite/ASN1SCG/CMSVersion.swift similarity index 100% rename from Sources/ASN1SCG/CMSVersion.swift rename to Sources/Suite/ASN1SCG/CMSVersion.swift diff --git a/Sources/ASN1SCG/CRLListID.swift b/Sources/Suite/ASN1SCG/CRLListID.swift similarity index 100% rename from Sources/ASN1SCG/CRLListID.swift rename to Sources/Suite/ASN1SCG/CRLListID.swift diff --git a/Sources/ASN1SCG/CRLReason.swift b/Sources/Suite/ASN1SCG/CRLReason.swift similarity index 100% rename from Sources/ASN1SCG/CRLReason.swift rename to Sources/Suite/ASN1SCG/CRLReason.swift diff --git a/Sources/ASN1SCG/CertID.swift b/Sources/Suite/ASN1SCG/CertID.swift similarity index 100% rename from Sources/ASN1SCG/CertID.swift rename to Sources/Suite/ASN1SCG/CertID.swift diff --git a/Sources/ASN1SCG/CertStatus.swift b/Sources/Suite/ASN1SCG/CertStatus.swift similarity index 100% rename from Sources/ASN1SCG/CertStatus.swift rename to Sources/Suite/ASN1SCG/CertStatus.swift diff --git a/Sources/ASN1SCG/Certificate.swift b/Sources/Suite/ASN1SCG/Certificate.swift similarity index 100% rename from Sources/ASN1SCG/Certificate.swift rename to Sources/Suite/ASN1SCG/Certificate.swift diff --git a/Sources/ASN1SCG/CertificateList.swift b/Sources/Suite/ASN1SCG/CertificateList.swift similarity index 100% rename from Sources/ASN1SCG/CertificateList.swift rename to Sources/Suite/ASN1SCG/CertificateList.swift diff --git a/Sources/ASN1SCG/CompareRequest.swift b/Sources/Suite/ASN1SCG/CompareRequest.swift similarity index 100% rename from Sources/ASN1SCG/CompareRequest.swift rename to Sources/Suite/ASN1SCG/CompareRequest.swift diff --git a/Sources/ASN1SCG/Contact.swift b/Sources/Suite/ASN1SCG/Contact.swift similarity index 100% rename from Sources/ASN1SCG/Contact.swift rename to Sources/Suite/ASN1SCG/Contact.swift diff --git a/Sources/ASN1SCG/ContactStatus.swift b/Sources/Suite/ASN1SCG/ContactStatus.swift similarity index 100% rename from Sources/ASN1SCG/ContactStatus.swift rename to Sources/Suite/ASN1SCG/ContactStatus.swift diff --git a/Sources/ASN1SCG/ContentInfo.swift b/Sources/Suite/ASN1SCG/ContentInfo.swift similarity index 100% rename from Sources/ASN1SCG/ContentInfo.swift rename to Sources/Suite/ASN1SCG/ContentInfo.swift diff --git a/Sources/ASN1SCG/Control.swift b/Sources/Suite/ASN1SCG/Control.swift similarity index 94% rename from Sources/ASN1SCG/Control.swift rename to Sources/Suite/ASN1SCG/Control.swift index d0e7766..885bbd4 100644 --- a/Sources/ASN1SCG/Control.swift +++ b/Sources/Suite/ASN1SCG/Control.swift @@ -16,7 +16,7 @@ import Foundation withIdentifier identifier: ASN1Identifier) throws { self = try DER.sequence(root, identifier: identifier) { nodes in let controlType: ASN1OctetString = try ASN1OctetString(derEncoded: &nodes) - let criticality: Bool = try Bool(derEncoded: &nodes) + let criticality: Bool = try DER.decodeDefault(&nodes, defaultValue: false) let controlValue: ASN1OctetString? = try ASN1OctetString(derEncoded: &nodes) return Control(controlType: controlType, criticality: criticality, controlValue: controlValue) } diff --git a/Sources/ASN1SCG/Criteria.swift b/Sources/Suite/ASN1SCG/Criteria.swift similarity index 100% rename from Sources/ASN1SCG/Criteria.swift rename to Sources/Suite/ASN1SCG/Criteria.swift diff --git a/Sources/ASN1SCG/CrlIdentifier.swift b/Sources/Suite/ASN1SCG/CrlIdentifier.swift similarity index 100% rename from Sources/ASN1SCG/CrlIdentifier.swift rename to Sources/Suite/ASN1SCG/CrlIdentifier.swift diff --git a/Sources/ASN1SCG/CrlOcspRef.swift b/Sources/Suite/ASN1SCG/CrlOcspRef.swift similarity index 100% rename from Sources/ASN1SCG/CrlOcspRef.swift rename to Sources/Suite/ASN1SCG/CrlOcspRef.swift diff --git a/Sources/ASN1SCG/CrlValidatedID.swift b/Sources/Suite/ASN1SCG/CrlValidatedID.swift similarity index 100% rename from Sources/ASN1SCG/CrlValidatedID.swift rename to Sources/Suite/ASN1SCG/CrlValidatedID.swift diff --git a/Sources/ASN1SCG/DSTU4145Params.swift b/Sources/Suite/ASN1SCG/DSTU4145Params.swift similarity index 100% rename from Sources/ASN1SCG/DSTU4145Params.swift rename to Sources/Suite/ASN1SCG/DSTU4145Params.swift diff --git a/Sources/ASN1SCG/DSTU4145Params_definition_Choice.swift b/Sources/Suite/ASN1SCG/DSTU4145Params_definition_Choice.swift similarity index 100% rename from Sources/ASN1SCG/DSTU4145Params_definition_Choice.swift rename to Sources/Suite/ASN1SCG/DSTU4145Params_definition_Choice.swift diff --git a/Sources/ASN1SCG/DirectoryString.swift b/Sources/Suite/ASN1SCG/DirectoryString.swift similarity index 100% rename from Sources/ASN1SCG/DirectoryString.swift rename to Sources/Suite/ASN1SCG/DirectoryString.swift diff --git a/Sources/ASN1SCG/DisplayText.swift b/Sources/Suite/ASN1SCG/DisplayText.swift similarity index 100% rename from Sources/ASN1SCG/DisplayText.swift rename to Sources/Suite/ASN1SCG/DisplayText.swift diff --git a/Sources/ASN1SCG/ECBinary.swift b/Sources/Suite/ASN1SCG/ECBinary.swift similarity index 100% rename from Sources/ASN1SCG/ECBinary.swift rename to Sources/Suite/ASN1SCG/ECBinary.swift diff --git a/Sources/ASN1SCG/ESSCertIDv2.swift b/Sources/Suite/ASN1SCG/ESSCertIDv2.swift similarity index 100% rename from Sources/ASN1SCG/ESSCertIDv2.swift rename to Sources/Suite/ASN1SCG/ESSCertIDv2.swift diff --git a/Sources/ASN1SCG/EncapsulatedContentInfo.swift b/Sources/Suite/ASN1SCG/EncapsulatedContentInfo.swift similarity index 100% rename from Sources/ASN1SCG/EncapsulatedContentInfo.swift rename to Sources/Suite/ASN1SCG/EncapsulatedContentInfo.swift diff --git a/Sources/ASN1SCG/ExtendedRequest.swift b/Sources/Suite/ASN1SCG/ExtendedRequest.swift similarity index 90% rename from Sources/ASN1SCG/ExtendedRequest.swift rename to Sources/Suite/ASN1SCG/ExtendedRequest.swift index b2a2630..7a9d845 100644 --- a/Sources/ASN1SCG/ExtendedRequest.swift +++ b/Sources/Suite/ASN1SCG/ExtendedRequest.swift @@ -13,7 +13,7 @@ import Foundation @inlinable init(derEncoded root: ASN1Node, withIdentifier identifier: ASN1Identifier) throws { self = try DER.sequence(root, identifier: identifier) { nodes in - let requestName: ASN1OctetString = try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 0, tagClass: .contextSpecific)) + let requestName: ASN1OctetString = (try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 0, tagClass: .contextSpecific)))! let requestValue: ASN1OctetString? = try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 1, tagClass: .contextSpecific)) return ExtendedRequest(requestName: requestName, requestValue: requestValue) } diff --git a/Sources/ASN1SCG/ExtendedResponse.swift b/Sources/Suite/ASN1SCG/ExtendedResponse.swift similarity index 100% rename from Sources/ASN1SCG/ExtendedResponse.swift rename to Sources/Suite/ASN1SCG/ExtendedResponse.swift diff --git a/Sources/ASN1SCG/Extension.swift b/Sources/Suite/ASN1SCG/Extension.swift similarity index 94% rename from Sources/ASN1SCG/Extension.swift rename to Sources/Suite/ASN1SCG/Extension.swift index 0e430cd..0f041b0 100644 --- a/Sources/ASN1SCG/Extension.swift +++ b/Sources/Suite/ASN1SCG/Extension.swift @@ -16,7 +16,7 @@ import Foundation withIdentifier identifier: ASN1Identifier) throws { self = try DER.sequence(root, identifier: identifier) { nodes in let extnID: ASN1ObjectIdentifier = try ASN1ObjectIdentifier(derEncoded: &nodes) - let critical: Bool = try Bool(derEncoded: &nodes) + let critical: Bool = try DER.decodeDefault(&nodes, defaultValue: false) let extnvalue: ASN1OctetString = try ASN1OctetString(derEncoded: &nodes) return Extension(extnID: extnID, critical: critical, extnvalue: extnvalue) } diff --git a/Sources/ASN1SCG/Feature.swift b/Sources/Suite/ASN1SCG/Feature.swift similarity index 100% rename from Sources/ASN1SCG/Feature.swift rename to Sources/Suite/ASN1SCG/Feature.swift diff --git a/Sources/ASN1SCG/FileDesc.swift b/Sources/Suite/ASN1SCG/FileDesc.swift similarity index 100% rename from Sources/ASN1SCG/FileDesc.swift rename to Sources/Suite/ASN1SCG/FileDesc.swift diff --git a/Sources/ASN1SCG/Filter.swift b/Sources/Suite/ASN1SCG/Filter.swift similarity index 100% rename from Sources/ASN1SCG/Filter.swift rename to Sources/Suite/ASN1SCG/Filter.swift diff --git a/Sources/ASN1SCG/Friend.swift b/Sources/Suite/ASN1SCG/Friend.swift similarity index 100% rename from Sources/ASN1SCG/Friend.swift rename to Sources/Suite/ASN1SCG/Friend.swift diff --git a/Sources/ASN1SCG/Friendship.swift b/Sources/Suite/ASN1SCG/Friendship.swift similarity index 100% rename from Sources/ASN1SCG/Friendship.swift rename to Sources/Suite/ASN1SCG/Friendship.swift diff --git a/Sources/ASN1SCG/GeneralName.swift b/Sources/Suite/ASN1SCG/GeneralName.swift similarity index 100% rename from Sources/ASN1SCG/GeneralName.swift rename to Sources/Suite/ASN1SCG/GeneralName.swift diff --git a/Sources/ASN1SCG/History.swift b/Sources/Suite/ASN1SCG/History.swift similarity index 100% rename from Sources/ASN1SCG/History.swift rename to Sources/Suite/ASN1SCG/History.swift diff --git a/Sources/ASN1SCG/HistoryStatus.swift b/Sources/Suite/ASN1SCG/HistoryStatus.swift similarity index 100% rename from Sources/ASN1SCG/HistoryStatus.swift rename to Sources/Suite/ASN1SCG/HistoryStatus.swift diff --git a/Sources/ASN1SCG/History_feed_Choice.swift b/Sources/Suite/ASN1SCG/History_feed_Choice.swift similarity index 100% rename from Sources/ASN1SCG/History_feed_Choice.swift rename to Sources/Suite/ASN1SCG/History_feed_Choice.swift diff --git a/Sources/ASN1SCG/IntermediateResponse.swift b/Sources/Suite/ASN1SCG/IntermediateResponse.swift similarity index 100% rename from Sources/ASN1SCG/IntermediateResponse.swift rename to Sources/Suite/ASN1SCG/IntermediateResponse.swift diff --git a/Sources/ASN1SCG/IssuerAndSerialNumber.swift b/Sources/Suite/ASN1SCG/IssuerAndSerialNumber.swift similarity index 100% rename from Sources/ASN1SCG/IssuerAndSerialNumber.swift rename to Sources/Suite/ASN1SCG/IssuerAndSerialNumber.swift diff --git a/Sources/ASN1SCG/IssuerSerial.swift b/Sources/Suite/ASN1SCG/IssuerSerial.swift similarity index 100% rename from Sources/ASN1SCG/IssuerSerial.swift rename to Sources/Suite/ASN1SCG/IssuerSerial.swift diff --git a/Sources/ASN1SCG/LDAPMessage.swift b/Sources/Suite/ASN1SCG/LDAPMessage.swift similarity index 100% rename from Sources/ASN1SCG/LDAPMessage.swift rename to Sources/Suite/ASN1SCG/LDAPMessage.swift diff --git a/Sources/ASN1SCG/LDAPMessage_protocolOp_Choice.swift b/Sources/Suite/ASN1SCG/LDAPMessage_protocolOp_Choice.swift similarity index 100% rename from Sources/ASN1SCG/LDAPMessage_protocolOp_Choice.swift rename to Sources/Suite/ASN1SCG/LDAPMessage_protocolOp_Choice.swift diff --git a/Sources/ASN1SCG/LDAPResult.swift b/Sources/Suite/ASN1SCG/LDAPResult.swift similarity index 100% rename from Sources/ASN1SCG/LDAPResult.swift rename to Sources/Suite/ASN1SCG/LDAPResult.swift diff --git a/Sources/ASN1SCG/LDAPResult_resultCode_Enum.swift b/Sources/Suite/ASN1SCG/LDAPResult_resultCode_Enum.swift similarity index 100% rename from Sources/ASN1SCG/LDAPResult_resultCode_Enum.swift rename to Sources/Suite/ASN1SCG/LDAPResult_resultCode_Enum.swift diff --git a/Sources/ASN1SCG/MUC.swift b/Sources/Suite/ASN1SCG/MUC.swift similarity index 100% rename from Sources/ASN1SCG/MUC.swift rename to Sources/Suite/ASN1SCG/MUC.swift diff --git a/Sources/ASN1SCG/MatchingRuleAssertion.swift b/Sources/Suite/ASN1SCG/MatchingRuleAssertion.swift similarity index 88% rename from Sources/ASN1SCG/MatchingRuleAssertion.swift rename to Sources/Suite/ASN1SCG/MatchingRuleAssertion.swift index eeb1138..eeb1ec8 100644 --- a/Sources/ASN1SCG/MatchingRuleAssertion.swift +++ b/Sources/Suite/ASN1SCG/MatchingRuleAssertion.swift @@ -19,8 +19,8 @@ import Foundation self = try DER.sequence(root, identifier: identifier) { nodes in let matchingRule: ASN1OctetString? = try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 1, tagClass: .contextSpecific)) let type: ASN1OctetString? = try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 2, tagClass: .contextSpecific)) - let matchValue: ASN1OctetString = try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 3, tagClass: .contextSpecific)) - let dnAttributes: Bool = try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 4, tagClass: .contextSpecific)) + let matchValue: ASN1OctetString = (try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 3, tagClass: .contextSpecific)))! + let dnAttributes: Bool = (try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 4, tagClass: .contextSpecific)))! return MatchingRuleAssertion(matchingRule: matchingRule, type: type, matchValue: matchValue, dnAttributes: dnAttributes) } } diff --git a/Sources/ASN1SCG/Member.swift b/Sources/Suite/ASN1SCG/Member.swift similarity index 100% rename from Sources/ASN1SCG/Member.swift rename to Sources/Suite/ASN1SCG/Member.swift diff --git a/Sources/ASN1SCG/MemberStatus.swift b/Sources/Suite/ASN1SCG/MemberStatus.swift similarity index 100% rename from Sources/ASN1SCG/MemberStatus.swift rename to Sources/Suite/ASN1SCG/MemberStatus.swift diff --git a/Sources/ASN1SCG/Member_feed_id_Choice.swift b/Sources/Suite/ASN1SCG/Member_feed_id_Choice.swift similarity index 100% rename from Sources/ASN1SCG/Member_feed_id_Choice.swift rename to Sources/Suite/ASN1SCG/Member_feed_id_Choice.swift diff --git a/Sources/ASN1SCG/Message.swift b/Sources/Suite/ASN1SCG/Message.swift similarity index 100% rename from Sources/ASN1SCG/Message.swift rename to Sources/Suite/ASN1SCG/Message.swift diff --git a/Sources/ASN1SCG/MessageImprint.swift b/Sources/Suite/ASN1SCG/MessageImprint.swift similarity index 100% rename from Sources/ASN1SCG/MessageImprint.swift rename to Sources/Suite/ASN1SCG/MessageImprint.swift diff --git a/Sources/ASN1SCG/MessageStatus.swift b/Sources/Suite/ASN1SCG/MessageStatus.swift similarity index 100% rename from Sources/ASN1SCG/MessageStatus.swift rename to Sources/Suite/ASN1SCG/MessageStatus.swift diff --git a/Sources/ASN1SCG/MessageType.swift b/Sources/Suite/ASN1SCG/MessageType.swift similarity index 100% rename from Sources/ASN1SCG/MessageType.swift rename to Sources/Suite/ASN1SCG/MessageType.swift diff --git a/Sources/ASN1SCG/Message_feed_id_Choice.swift b/Sources/Suite/ASN1SCG/Message_feed_id_Choice.swift similarity index 100% rename from Sources/ASN1SCG/Message_feed_id_Choice.swift rename to Sources/Suite/ASN1SCG/Message_feed_id_Choice.swift diff --git a/Sources/ASN1SCG/ModifyDNRequest.swift b/Sources/Suite/ASN1SCG/ModifyDNRequest.swift similarity index 95% rename from Sources/ASN1SCG/ModifyDNRequest.swift rename to Sources/Suite/ASN1SCG/ModifyDNRequest.swift index f369afe..92f25ed 100644 --- a/Sources/ASN1SCG/ModifyDNRequest.swift +++ b/Sources/Suite/ASN1SCG/ModifyDNRequest.swift @@ -19,7 +19,7 @@ import Foundation self = try DER.sequence(root, identifier: identifier) { nodes in let entry: ASN1OctetString = try ASN1OctetString(derEncoded: &nodes) let newrdn: ASN1OctetString = try ASN1OctetString(derEncoded: &nodes) - let deleteoldrdn: Bool = try Bool(derEncoded: &nodes) + let deleteoldrdn: Bool = try DER.decodeDefault(&nodes, defaultValue: false) let newSuperior: ASN1OctetString? = try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: 0, tagClass: .contextSpecific)) return ModifyDNRequest(entry: entry, newrdn: newrdn, deleteoldrdn: deleteoldrdn, newSuperior: newSuperior) } diff --git a/Sources/ASN1SCG/ModifyRequest.swift b/Sources/Suite/ASN1SCG/ModifyRequest.swift similarity index 100% rename from Sources/ASN1SCG/ModifyRequest.swift rename to Sources/Suite/ASN1SCG/ModifyRequest.swift diff --git a/Sources/ASN1SCG/ModifyRequest_changes_Sequence.swift b/Sources/Suite/ASN1SCG/ModifyRequest_changes_Sequence.swift similarity index 100% rename from Sources/ASN1SCG/ModifyRequest_changes_Sequence.swift rename to Sources/Suite/ASN1SCG/ModifyRequest_changes_Sequence.swift diff --git a/Sources/ASN1SCG/ModifyRequest_changes_Sequence_operation_Enum.swift b/Sources/Suite/ASN1SCG/ModifyRequest_changes_Sequence_operation_Enum.swift similarity index 100% rename from Sources/ASN1SCG/ModifyRequest_changes_Sequence_operation_Enum.swift rename to Sources/Suite/ASN1SCG/ModifyRequest_changes_Sequence_operation_Enum.swift diff --git a/Sources/Suite/ASN1SCG/Name.swift b/Sources/Suite/ASN1SCG/Name.swift new file mode 100644 index 0000000..26def6f --- /dev/null +++ b/Sources/Suite/ASN1SCG/Name.swift @@ -0,0 +1,42 @@ +// Generated by ASN1.ERP.UNO Compiler, Copyright © 2023 Namdak Tonpa. +import SwiftASN1 +import Foundation + +// 'NameRDN':encode('Name',{'rdnSequence',[[{'AttributeTypeAndValue',{2,5,4,6},<<19,2,85,65>>}]]}). +// {ok,<<48,13,49,11,48,9,6,3,85,4,6,19,2,85,65>>} +// DER.name [48,13,49,11,48,9,6,3,85,4,6,19,2,85,65] + +@usableFromInline indirect enum Name: DERParseable, DERSerializable, Hashable, Sendable { + case rdnSequence([[AttributeTypeAndValue]]) + @inlinable init(derEncoded root: ASN1Node) throws { + switch root.identifier { + case ASN1Identifier.sequenceOf: + var w: [[AttributeTypeAndValue]] = [] + try DER.sequence(root, identifier: .sequence) { nodes in + var w1: [AttributeTypeAndValue] = [] + while let node = nodes.next() { + w1.append(contentsOf: + try DER.set(of: AttributeTypeAndValue.self, identifier: .set, rootNode: node)) + } + w.append(w1) + } + self = Name.rdnSequence(w) + default: throw ASN1Error.unexpectedFieldType(root.identifier) + } + + } + @inlinable func serialize(into coder: inout DER.Serializer) throws { + switch self { + case .rdnSequence(let w): + try coder.appendConstructedNode(identifier: ASN1Identifier.sequence) { codec1 in + for w1 in w { + try codec1.appendConstructedNode(identifier: ASN1Identifier.set) { codec1_1 in + for w2 in w1 { + try codec1_1.serialize(w2) + } + } + } + } + } + } +} diff --git a/Sources/ASN1SCG/OS.swift b/Sources/Suite/ASN1SCG/OS.swift similarity index 100% rename from Sources/ASN1SCG/OS.swift rename to Sources/Suite/ASN1SCG/OS.swift diff --git a/Sources/ASN1SCG/OcspIdentifier.swift b/Sources/Suite/ASN1SCG/OcspIdentifier.swift similarity index 100% rename from Sources/ASN1SCG/OcspIdentifier.swift rename to Sources/Suite/ASN1SCG/OcspIdentifier.swift diff --git a/Sources/ASN1SCG/OcspListID.swift b/Sources/Suite/ASN1SCG/OcspListID.swift similarity index 100% rename from Sources/ASN1SCG/OcspListID.swift rename to Sources/Suite/ASN1SCG/OcspListID.swift diff --git a/Sources/ASN1SCG/OcspResponsesID.swift b/Sources/Suite/ASN1SCG/OcspResponsesID.swift similarity index 100% rename from Sources/ASN1SCG/OcspResponsesID.swift rename to Sources/Suite/ASN1SCG/OcspResponsesID.swift diff --git a/Sources/ASN1SCG/OtherHash.swift b/Sources/Suite/ASN1SCG/OtherHash.swift similarity index 100% rename from Sources/ASN1SCG/OtherHash.swift rename to Sources/Suite/ASN1SCG/OtherHash.swift diff --git a/Sources/ASN1SCG/OtherHashAlgAndValue.swift b/Sources/Suite/ASN1SCG/OtherHashAlgAndValue.swift similarity index 100% rename from Sources/ASN1SCG/OtherHashAlgAndValue.swift rename to Sources/Suite/ASN1SCG/OtherHashAlgAndValue.swift diff --git a/Sources/ASN1SCG/OtherRevRefs.swift b/Sources/Suite/ASN1SCG/OtherRevRefs.swift similarity index 100% rename from Sources/ASN1SCG/OtherRevRefs.swift rename to Sources/Suite/ASN1SCG/OtherRevRefs.swift diff --git a/Sources/ASN1SCG/OtherRevVals.swift b/Sources/Suite/ASN1SCG/OtherRevVals.swift similarity index 100% rename from Sources/ASN1SCG/OtherRevVals.swift rename to Sources/Suite/ASN1SCG/OtherRevVals.swift diff --git a/Sources/ASN1SCG/P2P.swift b/Sources/Suite/ASN1SCG/P2P.swift similarity index 100% rename from Sources/ASN1SCG/P2P.swift rename to Sources/Suite/ASN1SCG/P2P.swift diff --git a/Sources/ASN1SCG/PKIStatus.swift b/Sources/Suite/ASN1SCG/PKIStatus.swift similarity index 100% rename from Sources/ASN1SCG/PKIStatus.swift rename to Sources/Suite/ASN1SCG/PKIStatus.swift diff --git a/Sources/ASN1SCG/PKIStatusInfo.swift b/Sources/Suite/ASN1SCG/PKIStatusInfo.swift similarity index 100% rename from Sources/ASN1SCG/PKIStatusInfo.swift rename to Sources/Suite/ASN1SCG/PKIStatusInfo.swift diff --git a/Sources/ASN1SCG/PartialAttribute.swift b/Sources/Suite/ASN1SCG/PartialAttribute.swift similarity index 100% rename from Sources/ASN1SCG/PartialAttribute.swift rename to Sources/Suite/ASN1SCG/PartialAttribute.swift diff --git a/Sources/ASN1SCG/Pentanomial.swift b/Sources/Suite/ASN1SCG/Pentanomial.swift similarity index 100% rename from Sources/ASN1SCG/Pentanomial.swift rename to Sources/Suite/ASN1SCG/Pentanomial.swift diff --git a/Sources/ASN1SCG/PolicyInformation.swift b/Sources/Suite/ASN1SCG/PolicyInformation.swift similarity index 100% rename from Sources/ASN1SCG/PolicyInformation.swift rename to Sources/Suite/ASN1SCG/PolicyInformation.swift diff --git a/Sources/ASN1SCG/PolicyQualifierInfo.swift b/Sources/Suite/ASN1SCG/PolicyQualifierInfo.swift similarity index 94% rename from Sources/ASN1SCG/PolicyQualifierInfo.swift rename to Sources/Suite/ASN1SCG/PolicyQualifierInfo.swift index 658c4b4..264f7f4 100644 --- a/Sources/ASN1SCG/PolicyQualifierInfo.swift +++ b/Sources/Suite/ASN1SCG/PolicyQualifierInfo.swift @@ -14,7 +14,7 @@ import Foundation withIdentifier identifier: ASN1Identifier) throws { self = try DER.sequence(root, identifier: identifier) { nodes in let policyQualifierId: ASN1ObjectIdentifier = try ASN1ObjectIdentifier(derEncoded: &nodes) - let qualifier: ASN1Any? = try ASN1Any(derEncoded: &nodes) + let qualifier: ASN1Any? = nodes.next().map { ASN1Any(derEncoded: $0) } return PolicyQualifierInfo(policyQualifierId: policyQualifierId, qualifier: qualifier) } } diff --git a/Sources/ASN1SCG/Presence.swift b/Sources/Suite/ASN1SCG/Presence.swift similarity index 100% rename from Sources/ASN1SCG/Presence.swift rename to Sources/Suite/ASN1SCG/Presence.swift diff --git a/Sources/ASN1SCG/PresenceType.swift b/Sources/Suite/ASN1SCG/PresenceType.swift similarity index 100% rename from Sources/ASN1SCG/PresenceType.swift rename to Sources/Suite/ASN1SCG/PresenceType.swift diff --git a/Sources/ASN1SCG/Profile.swift b/Sources/Suite/ASN1SCG/Profile.swift similarity index 100% rename from Sources/ASN1SCG/Profile.swift rename to Sources/Suite/ASN1SCG/Profile.swift diff --git a/Sources/ASN1SCG/Register.swift b/Sources/Suite/ASN1SCG/Register.swift similarity index 100% rename from Sources/ASN1SCG/Register.swift rename to Sources/Suite/ASN1SCG/Register.swift diff --git a/Sources/ASN1SCG/ResponderID.swift b/Sources/Suite/ASN1SCG/ResponderID.swift similarity index 100% rename from Sources/ASN1SCG/ResponderID.swift rename to Sources/Suite/ASN1SCG/ResponderID.swift diff --git a/Sources/ASN1SCG/ResponseData.swift b/Sources/Suite/ASN1SCG/ResponseData.swift similarity index 100% rename from Sources/ASN1SCG/ResponseData.swift rename to Sources/Suite/ASN1SCG/ResponseData.swift diff --git a/Sources/ASN1SCG/RevocationValues.swift b/Sources/Suite/ASN1SCG/RevocationValues.swift similarity index 100% rename from Sources/ASN1SCG/RevocationValues.swift rename to Sources/Suite/ASN1SCG/RevocationValues.swift diff --git a/Sources/ASN1SCG/RevokedInfo.swift b/Sources/Suite/ASN1SCG/RevokedInfo.swift similarity index 100% rename from Sources/ASN1SCG/RevokedInfo.swift rename to Sources/Suite/ASN1SCG/RevokedInfo.swift diff --git a/Sources/ASN1SCG/Room.swift b/Sources/Suite/ASN1SCG/Room.swift similarity index 100% rename from Sources/ASN1SCG/Room.swift rename to Sources/Suite/ASN1SCG/Room.swift diff --git a/Sources/ASN1SCG/RoomStatus.swift b/Sources/Suite/ASN1SCG/RoomStatus.swift similarity index 100% rename from Sources/ASN1SCG/RoomStatus.swift rename to Sources/Suite/ASN1SCG/RoomStatus.swift diff --git a/Sources/ASN1SCG/RoomType.swift b/Sources/Suite/ASN1SCG/RoomType.swift similarity index 100% rename from Sources/ASN1SCG/RoomType.swift rename to Sources/Suite/ASN1SCG/RoomType.swift diff --git a/Sources/ASN1SCG/Roster.swift b/Sources/Suite/ASN1SCG/Roster.swift similarity index 100% rename from Sources/ASN1SCG/Roster.swift rename to Sources/Suite/ASN1SCG/Roster.swift diff --git a/Sources/ASN1SCG/RosterStatus.swift b/Sources/Suite/ASN1SCG/RosterStatus.swift similarity index 100% rename from Sources/ASN1SCG/RosterStatus.swift rename to Sources/Suite/ASN1SCG/RosterStatus.swift diff --git a/Sources/ASN1SCG/SaslCredentials.swift b/Sources/Suite/ASN1SCG/SaslCredentials.swift similarity index 100% rename from Sources/ASN1SCG/SaslCredentials.swift rename to Sources/Suite/ASN1SCG/SaslCredentials.swift diff --git a/Sources/ASN1SCG/Scope.swift b/Sources/Suite/ASN1SCG/Scope.swift similarity index 100% rename from Sources/ASN1SCG/Scope.swift rename to Sources/Suite/ASN1SCG/Scope.swift diff --git a/Sources/ASN1SCG/Search.swift b/Sources/Suite/ASN1SCG/Search.swift similarity index 100% rename from Sources/ASN1SCG/Search.swift rename to Sources/Suite/ASN1SCG/Search.swift diff --git a/Sources/ASN1SCG/SearchRequest.swift b/Sources/Suite/ASN1SCG/SearchRequest.swift similarity index 97% rename from Sources/ASN1SCG/SearchRequest.swift rename to Sources/Suite/ASN1SCG/SearchRequest.swift index 80690cb..411be5c 100644 --- a/Sources/ASN1SCG/SearchRequest.swift +++ b/Sources/Suite/ASN1SCG/SearchRequest.swift @@ -30,7 +30,7 @@ import Foundation let derefAliases: SearchRequest_derefAliases_Enum = try SearchRequest_derefAliases_Enum(derEncoded: &nodes) let sizeLimit: ArraySlice = try ArraySlice(derEncoded: &nodes) let timeLimit: ArraySlice = try ArraySlice(derEncoded: &nodes) - let typesOnly: Bool = try Bool(derEncoded: &nodes) + let typesOnly: Bool = try DER.decodeDefault(&nodes, defaultValue: false) let filter: Filter = try Filter(derEncoded: &nodes) let attributes: [ASN1OctetString] = try DER.sequence(of: ASN1OctetString.self, identifier: .sequence, nodes: &nodes) return SearchRequest(baseObject: baseObject, scope: scope, derefAliases: derefAliases, sizeLimit: sizeLimit, timeLimit: timeLimit, typesOnly: typesOnly, filter: filter, attributes: attributes) diff --git a/Sources/ASN1SCG/SearchRequest_derefAliases_Enum.swift b/Sources/Suite/ASN1SCG/SearchRequest_derefAliases_Enum.swift similarity index 100% rename from Sources/ASN1SCG/SearchRequest_derefAliases_Enum.swift rename to Sources/Suite/ASN1SCG/SearchRequest_derefAliases_Enum.swift diff --git a/Sources/ASN1SCG/SearchRequest_scope_Enum.swift b/Sources/Suite/ASN1SCG/SearchRequest_scope_Enum.swift similarity index 100% rename from Sources/ASN1SCG/SearchRequest_scope_Enum.swift rename to Sources/Suite/ASN1SCG/SearchRequest_scope_Enum.swift diff --git a/Sources/ASN1SCG/SearchResultEntry.swift b/Sources/Suite/ASN1SCG/SearchResultEntry.swift similarity index 100% rename from Sources/ASN1SCG/SearchResultEntry.swift rename to Sources/Suite/ASN1SCG/SearchResultEntry.swift diff --git a/Sources/ASN1SCG/SearchStatus.swift b/Sources/Suite/ASN1SCG/SearchStatus.swift similarity index 100% rename from Sources/ASN1SCG/SearchStatus.swift rename to Sources/Suite/ASN1SCG/SearchStatus.swift diff --git a/Sources/ASN1SCG/Server.swift b/Sources/Suite/ASN1SCG/Server.swift similarity index 100% rename from Sources/ASN1SCG/Server.swift rename to Sources/Suite/ASN1SCG/Server.swift diff --git a/Sources/ASN1SCG/Service.swift b/Sources/Suite/ASN1SCG/Service.swift similarity index 100% rename from Sources/ASN1SCG/Service.swift rename to Sources/Suite/ASN1SCG/Service.swift diff --git a/Sources/ASN1SCG/ServiceStatus.swift b/Sources/Suite/ASN1SCG/ServiceStatus.swift similarity index 100% rename from Sources/ASN1SCG/ServiceStatus.swift rename to Sources/Suite/ASN1SCG/ServiceStatus.swift diff --git a/Sources/ASN1SCG/ServiceType.swift b/Sources/Suite/ASN1SCG/ServiceType.swift similarity index 100% rename from Sources/ASN1SCG/ServiceType.swift rename to Sources/Suite/ASN1SCG/ServiceType.swift diff --git a/Sources/ASN1SCG/SigPolicyQualifierInfo.swift b/Sources/Suite/ASN1SCG/SigPolicyQualifierInfo.swift similarity index 100% rename from Sources/ASN1SCG/SigPolicyQualifierInfo.swift rename to Sources/Suite/ASN1SCG/SigPolicyQualifierInfo.swift diff --git a/Sources/ASN1SCG/SignaturePolicyId.swift b/Sources/Suite/ASN1SCG/SignaturePolicyId.swift similarity index 100% rename from Sources/ASN1SCG/SignaturePolicyId.swift rename to Sources/Suite/ASN1SCG/SignaturePolicyId.swift diff --git a/Sources/ASN1SCG/SignaturePolicyIdentifier.swift b/Sources/Suite/ASN1SCG/SignaturePolicyIdentifier.swift similarity index 100% rename from Sources/ASN1SCG/SignaturePolicyIdentifier.swift rename to Sources/Suite/ASN1SCG/SignaturePolicyIdentifier.swift diff --git a/Sources/ASN1SCG/SignedData.swift b/Sources/Suite/ASN1SCG/SignedData.swift similarity index 100% rename from Sources/ASN1SCG/SignedData.swift rename to Sources/Suite/ASN1SCG/SignedData.swift diff --git a/Sources/ASN1SCG/SignerIdentifier.swift b/Sources/Suite/ASN1SCG/SignerIdentifier.swift similarity index 100% rename from Sources/ASN1SCG/SignerIdentifier.swift rename to Sources/Suite/ASN1SCG/SignerIdentifier.swift diff --git a/Sources/ASN1SCG/SignerInfo.swift b/Sources/Suite/ASN1SCG/SignerInfo.swift similarity index 100% rename from Sources/ASN1SCG/SignerInfo.swift rename to Sources/Suite/ASN1SCG/SignerInfo.swift diff --git a/Sources/ASN1SCG/SigningCertificateV2.swift b/Sources/Suite/ASN1SCG/SigningCertificateV2.swift similarity index 100% rename from Sources/ASN1SCG/SigningCertificateV2.swift rename to Sources/Suite/ASN1SCG/SigningCertificateV2.swift diff --git a/Sources/ASN1SCG/SingleResponse.swift b/Sources/Suite/ASN1SCG/SingleResponse.swift similarity index 100% rename from Sources/ASN1SCG/SingleResponse.swift rename to Sources/Suite/ASN1SCG/SingleResponse.swift diff --git a/Sources/ASN1SCG/SubjectPublicKeyInfo.swift b/Sources/Suite/ASN1SCG/SubjectPublicKeyInfo.swift similarity index 100% rename from Sources/ASN1SCG/SubjectPublicKeyInfo.swift rename to Sources/Suite/ASN1SCG/SubjectPublicKeyInfo.swift diff --git a/Sources/ASN1SCG/SubstringFilter.swift b/Sources/Suite/ASN1SCG/SubstringFilter.swift similarity index 100% rename from Sources/ASN1SCG/SubstringFilter.swift rename to Sources/Suite/ASN1SCG/SubstringFilter.swift diff --git a/Sources/ASN1SCG/SubstringFilter_substrings_Choice.swift b/Sources/Suite/ASN1SCG/SubstringFilter_substrings_Choice.swift similarity index 100% rename from Sources/ASN1SCG/SubstringFilter_substrings_Choice.swift rename to Sources/Suite/ASN1SCG/SubstringFilter_substrings_Choice.swift diff --git a/Sources/ASN1SCG/TBSCertList.swift b/Sources/Suite/ASN1SCG/TBSCertList.swift similarity index 100% rename from Sources/ASN1SCG/TBSCertList.swift rename to Sources/Suite/ASN1SCG/TBSCertList.swift diff --git a/Sources/ASN1SCG/TBSCertList_revokedCertificates_Sequence.swift b/Sources/Suite/ASN1SCG/TBSCertList_revokedCertificates_Sequence.swift similarity index 100% rename from Sources/ASN1SCG/TBSCertList_revokedCertificates_Sequence.swift rename to Sources/Suite/ASN1SCG/TBSCertList_revokedCertificates_Sequence.swift diff --git a/Sources/ASN1SCG/TBSCertificate.swift b/Sources/Suite/ASN1SCG/TBSCertificate.swift similarity index 100% rename from Sources/ASN1SCG/TBSCertificate.swift rename to Sources/Suite/ASN1SCG/TBSCertificate.swift diff --git a/Sources/ASN1SCG/TSTInfo.swift b/Sources/Suite/ASN1SCG/TSTInfo.swift similarity index 100% rename from Sources/ASN1SCG/TSTInfo.swift rename to Sources/Suite/ASN1SCG/TSTInfo.swift diff --git a/Sources/ASN1SCG/TSTInfo_version_IntEnum.swift b/Sources/Suite/ASN1SCG/TSTInfo_version_IntEnum.swift similarity index 100% rename from Sources/ASN1SCG/TSTInfo_version_IntEnum.swift rename to Sources/Suite/ASN1SCG/TSTInfo_version_IntEnum.swift diff --git a/Sources/ASN1SCG/Time.swift b/Sources/Suite/ASN1SCG/Time.swift similarity index 100% rename from Sources/ASN1SCG/Time.swift rename to Sources/Suite/ASN1SCG/Time.swift diff --git a/Sources/ASN1SCG/TimeStampReq.swift b/Sources/Suite/ASN1SCG/TimeStampReq.swift similarity index 96% rename from Sources/ASN1SCG/TimeStampReq.swift rename to Sources/Suite/ASN1SCG/TimeStampReq.swift index b753eba..dc7efd9 100644 --- a/Sources/ASN1SCG/TimeStampReq.swift +++ b/Sources/Suite/ASN1SCG/TimeStampReq.swift @@ -25,7 +25,7 @@ import Foundation let messageImprint: MessageImprint = try MessageImprint(derEncoded: &nodes) let reqPolicy: ASN1ObjectIdentifier? = try ASN1ObjectIdentifier(derEncoded: &nodes) let nonce: ArraySlice? = try ArraySlice(derEncoded: &nodes) - let certReq: Bool = try Bool(derEncoded: &nodes) + let certReq: Bool = try DER.decodeDefault(&nodes, defaultValue: false) let extensions: [Extension] = try DER.sequence(of: Extension.self, identifier: ASN1Identifier(tagWithNumber: 0, tagClass: .contextSpecific), nodes: &nodes) return TimeStampReq(version: version, messageImprint: messageImprint, reqPolicy: reqPolicy, nonce: nonce, certReq: certReq, extensions: extensions) } diff --git a/Sources/ASN1SCG/TimeStampReq_version_IntEnum.swift b/Sources/Suite/ASN1SCG/TimeStampReq_version_IntEnum.swift similarity index 100% rename from Sources/ASN1SCG/TimeStampReq_version_IntEnum.swift rename to Sources/Suite/ASN1SCG/TimeStampReq_version_IntEnum.swift diff --git a/Sources/ASN1SCG/TimeStampResp.swift b/Sources/Suite/ASN1SCG/TimeStampResp.swift similarity index 100% rename from Sources/ASN1SCG/TimeStampResp.swift rename to Sources/Suite/ASN1SCG/TimeStampResp.swift diff --git a/Sources/ASN1SCG/Typing.swift b/Sources/Suite/ASN1SCG/Typing.swift similarity index 100% rename from Sources/ASN1SCG/Typing.swift rename to Sources/Suite/ASN1SCG/Typing.swift diff --git a/Sources/ASN1SCG/Validity.swift b/Sources/Suite/ASN1SCG/Validity.swift similarity index 100% rename from Sources/ASN1SCG/Validity.swift rename to Sources/Suite/ASN1SCG/Validity.swift diff --git a/Sources/ASN1SCG/Version.swift b/Sources/Suite/ASN1SCG/Version.swift similarity index 100% rename from Sources/ASN1SCG/Version.swift rename to Sources/Suite/ASN1SCG/Version.swift diff --git a/Sources/Suite/main.swift b/Sources/Suite/main.swift new file mode 100644 index 0000000..6a9d950 --- /dev/null +++ b/Sources/Suite/main.swift @@ -0,0 +1,33 @@ +import SwiftASN1 +import Foundation + +try Console.loop() + +public class Console { + + public static func exists(f: String) -> Bool { return FileManager.default.fileExists(atPath: f) } + + public static func showName(data: Array) throws { + let name: Name? = try Name(derEncoded: data) + if let name { print(": name \(name)") } + var serializer = DER.Serializer() + try name!.serialize(into: &serializer) + print(": DER.name \(serializer.serializedBytes)") + } + + public static func showCertificate(name: String) throws { + let url = URL(fileURLWithPath: name) + if (!Console.exists(f: url.path)) { print(": CERT file not found.") } else { + let data = try Data(contentsOf: url) + let cert = try Certificate(derEncoded: Array(data)) + print(": \(cert)") + } + } + + public static func loop() throws { + try showName(data: [48,13,49,11,48,9,6,3,85,4,6,19,2,85,65]) + try showCertificate(name: "ca.crt") + print(": PASSED") + } + +} diff --git a/asn1.ex b/asn1.ex index 0cb7701..94e68fb 100755 --- a/asn1.ex +++ b/asn1.ex @@ -16,7 +16,6 @@ defmodule ASN1 do "" -> [] _ -> print 'array: #{level} : ~ts = [~ts] ~p ~n', [name1, type1, tag] end -# :io.format 'seqof:8: ~p [~ts]~n', [name1, lookup(bin(type1)) ] setEnv(name1, "[#{type1}]") setEnv({:array, name1}, {tag, type1}) name1 @@ -36,20 +35,13 @@ defmodule ASN1 do def fieldType(_,_,{:"BIT STRING", _}), do: "ASN1BitString" def fieldType(_,_,{:pt, {_,_,_,type}, _}) when is_atom(type), do: "#{type}" def fieldType(_,_,{:ANY_DEFINED_BY, type}) when is_atom(type), do: "ASN1Any" - def fieldType(_name,_field,{:Externaltypereference,_,_,type}) when type == :OrganizationalUnitNames do -# :io.format 'seqof:1: ~p.~p ~ts~n', [name, field, type ] #lookup(bin(type)) ] - "#{substituteType(lookup(bin(type)))}" - end - def fieldType(_name,_field,{:Externaltypereference,_,_,type}) do -# :io.format 'seqof:2: ~p.~p ~ts~n', [name, field, :io_lib.format('~p',[type]) ] - "#{substituteType(lookup(bin(type)))}" - end + def fieldType(_name,_field,{:Externaltypereference,_,_,type}) when type == :OrganizationalUnitNames, do: "#{substituteType(lookup(bin(type)))}" + def fieldType(_name,_field,{:Externaltypereference,_,_,type}), do: "#{substituteType(lookup(bin(type)))}" def fieldType(_,_,{:ObjectClassFieldType,_,_,[{_,type}],_}), do: "#{type}" def fieldType(_,_,type) when is_atom(type), do: "#{type}" def fieldType(name,_,_), do: "#{name}" def sequenceOf(name,field,type) do -# :io.format 'seqof:3: ~p.~p~n', [name, field] sequenceOf2(name,field,type) end @@ -107,7 +99,11 @@ defmodule ASN1 do def emitSequenceDecoderBodyElement(_, plicit, no, name, type) when plicit == "Explicit", do: "let #{name}: #{type} = try DER.explicitlyTagged(&nodes, tagNumber: #{no}, tagClass: .contextSpecific) { node in return try #{type}(derEncoded: node) }" def emitSequenceDecoderBodyElement(_, plicit, no, name, type) when plicit == "Implicit", do: - "let #{name}: #{type} = try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: #{no}, tagClass: .contextSpecific))" + "let #{name}: #{type} = (try DER.optionalImplicitlyTagged(&nodes, tag: ASN1Identifier(tagWithNumber: #{no}, tagClass: .contextSpecific)))!" + def emitSequenceDecoderBodyElement(:OPTIONAL, _, _, name, "ASN1Any"), do: + "let #{name}: ASN1Any? = nodes.next().map { ASN1Any(derEncoded: $0) }" + def emitSequenceDecoderBodyElement(_, _, _, name, "Bool"), do: + "let #{name}: Bool = try DER.decodeDefault(&nodes, defaultValue: false)" def emitSequenceDecoderBodyElement(optional, _, _, name, type), do: "let #{name}: #{type}#{opt(optional)} = try #{type}(derEncoded: &nodes)" diff --git a/priv/basic/DSTU.asn1 b/priv/basic/DSTU.asn1 index 218b0a9..a553494 100644 --- a/priv/basic/DSTU.asn1 +++ b/priv/basic/DSTU.asn1 @@ -48,7 +48,7 @@ id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt (2) ds (5) 4} AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, - parameters ANY } + parameters ANY OPTIONAL } -- DEFINED BY algorithm OPTIONAL @@ -66,7 +66,7 @@ SubjectPublicKeyInfo ::= SEQUENCE { AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, - parameters ANY } + parameters ANY OPTIONAL } -- DEFINED BY algorithm OPTIONAL DSTU4145Params::= SEQUENCE {